@uxbertlabs/reportly 1.0.4 → 1.0.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -344,24 +344,26 @@ class Modal {
344
344
  }
345
345
 
346
346
  class Toolbar {
347
+ // private currentTool: AnnotationTool;
348
+ // private currentColor: string;
347
349
  constructor(callbacks) {
348
350
  this.callbacks = callbacks;
349
351
  this.toolbar = null;
350
352
  this.toggleButton = null;
351
353
  this.isToolbarExpanded = false;
352
- this.currentTool = 'pen';
353
- this.currentColor = '#ef4444';
354
+ // this.currentTool = "pen";
355
+ // this.currentColor = "#ef4444";
354
356
  }
355
357
  create() {
356
358
  // Create toggle button
357
- this.toggleButton = document.createElement('button');
358
- this.toggleButton.className = 'uxbert-toolbar-toggle';
359
- this.toggleButton.innerHTML = '🛠️';
360
- this.toggleButton.title = 'Toggle Annotation Tools';
359
+ this.toggleButton = document.createElement("button");
360
+ this.toggleButton.className = "uxbert-toolbar-toggle";
361
+ this.toggleButton.innerHTML = "🛠️";
362
+ this.toggleButton.title = "Toggle Annotation Tools";
361
363
  document.body.appendChild(this.toggleButton);
362
364
  // Create toolbar
363
- this.toolbar = document.createElement('div');
364
- this.toolbar.className = 'uxbert-toolbar';
365
+ this.toolbar = document.createElement("div");
366
+ this.toolbar.className = "uxbert-toolbar";
365
367
  this.toolbar.innerHTML = `
366
368
  <div class="uxbert-toolbar-header">
367
369
  <div class="uxbert-toolbar-title">Annotation Tools</div>
@@ -401,19 +403,19 @@ class Toolbar {
401
403
  if (!this.toolbar || !this.toggleButton)
402
404
  return;
403
405
  // Toggle button
404
- this.toggleButton.addEventListener('click', () => {
406
+ this.toggleButton.addEventListener("click", () => {
405
407
  this.toggleToolbar();
406
408
  });
407
409
  // Minimize button
408
- const minimizeBtn = this.toolbar.querySelector('#uxbert-minimize-btn');
409
- minimizeBtn.addEventListener('click', () => {
410
+ const minimizeBtn = this.toolbar.querySelector("#uxbert-minimize-btn");
411
+ minimizeBtn.addEventListener("click", () => {
410
412
  this.toggleToolbar();
411
413
  });
412
414
  // Tool buttons
413
- const toolBtns = this.toolbar.querySelectorAll('[data-tool]');
414
- toolBtns.forEach(btn => {
415
- btn.addEventListener('click', () => {
416
- const tool = btn.getAttribute('data-tool');
415
+ const toolBtns = this.toolbar.querySelectorAll("[data-tool]");
416
+ toolBtns.forEach((btn) => {
417
+ btn.addEventListener("click", () => {
418
+ const tool = btn.getAttribute("data-tool");
417
419
  this.setTool(tool);
418
420
  if (this.callbacks.onToolChange) {
419
421
  this.callbacks.onToolChange(tool);
@@ -421,10 +423,10 @@ class Toolbar {
421
423
  });
422
424
  });
423
425
  // Color buttons
424
- const colorBtns = this.toolbar.querySelectorAll('[data-color]');
425
- colorBtns.forEach(btn => {
426
- btn.addEventListener('click', () => {
427
- const color = btn.getAttribute('data-color');
426
+ const colorBtns = this.toolbar.querySelectorAll("[data-color]");
427
+ colorBtns.forEach((btn) => {
428
+ btn.addEventListener("click", () => {
429
+ const color = btn.getAttribute("data-color");
428
430
  this.setColor(color);
429
431
  if (this.callbacks.onColorChange) {
430
432
  this.callbacks.onColorChange(color);
@@ -432,57 +434,57 @@ class Toolbar {
432
434
  });
433
435
  });
434
436
  // Action buttons
435
- const undoBtn = this.toolbar.querySelector('#uxbert-undo-btn');
436
- undoBtn.addEventListener('click', () => {
437
+ const undoBtn = this.toolbar.querySelector("#uxbert-undo-btn");
438
+ undoBtn.addEventListener("click", () => {
437
439
  if (this.callbacks.onUndo) {
438
440
  this.callbacks.onUndo();
439
441
  }
440
442
  });
441
- const clearBtn = this.toolbar.querySelector('#uxbert-clear-btn');
442
- clearBtn.addEventListener('click', () => {
443
+ const clearBtn = this.toolbar.querySelector("#uxbert-clear-btn");
444
+ clearBtn.addEventListener("click", () => {
443
445
  if (this.callbacks.onClear) {
444
446
  this.callbacks.onClear();
445
447
  }
446
448
  });
447
- const doneBtn = this.toolbar.querySelector('#uxbert-done-btn');
448
- doneBtn.addEventListener('click', () => {
449
+ const doneBtn = this.toolbar.querySelector("#uxbert-done-btn");
450
+ doneBtn.addEventListener("click", () => {
449
451
  if (this.callbacks.onDone) {
450
452
  this.callbacks.onDone();
451
453
  }
452
454
  });
453
455
  // Exit button
454
- const exitBtn = this.toolbar.querySelector('#uxbert-exit-btn');
455
- exitBtn.addEventListener('click', () => {
456
+ const exitBtn = this.toolbar.querySelector("#uxbert-exit-btn");
457
+ exitBtn.addEventListener("click", () => {
456
458
  if (this.callbacks.onExit) {
457
459
  this.callbacks.onExit();
458
460
  }
459
461
  });
460
462
  }
461
463
  setTool(tool) {
462
- this.currentTool = tool;
464
+ // this.currentTool = tool;
463
465
  if (!this.toolbar)
464
466
  return;
465
- const toolBtns = this.toolbar.querySelectorAll('[data-tool]');
466
- toolBtns.forEach(btn => {
467
- if (btn.getAttribute('data-tool') === tool) {
468
- btn.classList.add('active');
467
+ const toolBtns = this.toolbar.querySelectorAll("[data-tool]");
468
+ toolBtns.forEach((btn) => {
469
+ if (btn.getAttribute("data-tool") === tool) {
470
+ btn.classList.add("active");
469
471
  }
470
472
  else {
471
- btn.classList.remove('active');
473
+ btn.classList.remove("active");
472
474
  }
473
475
  });
474
476
  }
475
477
  setColor(color) {
476
- this.currentColor = color;
478
+ // this.currentColor = color;
477
479
  if (!this.toolbar)
478
480
  return;
479
- const colorBtns = this.toolbar.querySelectorAll('[data-color]');
480
- colorBtns.forEach(btn => {
481
- if (btn.getAttribute('data-color') === color) {
482
- btn.classList.add('active');
481
+ const colorBtns = this.toolbar.querySelectorAll("[data-color]");
482
+ colorBtns.forEach((btn) => {
483
+ if (btn.getAttribute("data-color") === color) {
484
+ btn.classList.add("active");
483
485
  }
484
486
  else {
485
- btn.classList.remove('active');
487
+ btn.classList.remove("active");
486
488
  }
487
489
  });
488
490
  }
@@ -491,40 +493,40 @@ class Toolbar {
491
493
  return;
492
494
  this.isToolbarExpanded = !this.isToolbarExpanded;
493
495
  if (this.isToolbarExpanded) {
494
- this.toolbar.classList.add('expanded');
495
- this.toggleButton.classList.add('hidden');
496
+ this.toolbar.classList.add("expanded");
497
+ this.toggleButton.classList.add("hidden");
496
498
  }
497
499
  else {
498
- this.toolbar.classList.remove('expanded');
499
- this.toggleButton.classList.remove('hidden');
500
+ this.toolbar.classList.remove("expanded");
501
+ this.toggleButton.classList.remove("hidden");
500
502
  }
501
503
  }
502
504
  show() {
503
505
  if (this.toolbar && this.toggleButton) {
504
- this.toolbar.classList.add('active');
505
- this.toggleButton.classList.add('active');
506
+ this.toolbar.classList.add("active");
507
+ this.toggleButton.classList.add("active");
506
508
  // Use setTimeout to ensure DOM is ready before checking width and applying classes
507
509
  setTimeout(() => {
508
510
  // Auto-expand on desktop, collapsed on mobile
509
511
  if (window.innerWidth > 768) {
510
512
  this.isToolbarExpanded = true;
511
- this.toolbar.classList.add('expanded');
512
- this.toggleButton.classList.add('hidden');
513
+ this.toolbar.classList.add("expanded");
514
+ this.toggleButton.classList.add("hidden");
513
515
  }
514
516
  else {
515
517
  this.isToolbarExpanded = false;
516
- this.toolbar.classList.remove('expanded');
517
- this.toggleButton.classList.remove('hidden');
518
+ this.toolbar.classList.remove("expanded");
519
+ this.toggleButton.classList.remove("hidden");
518
520
  }
519
521
  }, 50);
520
522
  }
521
523
  }
522
524
  hide() {
523
525
  if (this.toolbar && this.toggleButton) {
524
- this.toolbar.classList.remove('active');
525
- this.toolbar.classList.remove('expanded');
526
- this.toggleButton.classList.remove('active');
527
- this.toggleButton.classList.remove('hidden');
526
+ this.toolbar.classList.remove("active");
527
+ this.toolbar.classList.remove("expanded");
528
+ this.toggleButton.classList.remove("active");
529
+ this.toggleButton.classList.remove("hidden");
528
530
  this.isToolbarExpanded = false;
529
531
  }
530
532
  }
@@ -541,11 +543,11 @@ class Toolbar {
541
543
  }
542
544
 
543
545
  /*!
544
- * html2canvas 1.4.1 <https://html2canvas.hertzen.com>
545
- * Copyright (c) 2022 Niklas von Hertzen <https://hertzen.com>
546
+ * html2canvas-pro 1.5.12 <https://yorickshan.github.io/html2canvas-pro/>
547
+ * Copyright (c) 2024-present yorickshan and html2canvas-pro contributors
546
548
  * Released under MIT License
547
549
  */
548
- /*! *****************************************************************************
550
+ /******************************************************************************
549
551
  Copyright (c) Microsoft Corporation.
550
552
 
551
553
  Permission to use, copy, modify, and/or distribute this software for any
@@ -559,7 +561,7 @@ LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
559
561
  OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
560
562
  PERFORMANCE OF THIS SOFTWARE.
561
563
  ***************************************************************************** */
562
- /* global Reflect, Promise */
564
+ /* global Reflect, Promise, SuppressedError, Symbol */
563
565
 
564
566
  var extendStatics = function(d, b) {
565
567
  extendStatics = Object.setPrototypeOf ||
@@ -603,7 +605,7 @@ function __generator(thisArg, body) {
603
605
  function verb(n) { return function (v) { return step([n, v]); }; }
604
606
  function step(op) {
605
607
  if (f) throw new TypeError("Generator is already executing.");
606
- while (_) try {
608
+ while (g && (g = 0, op[0] && (_ = 0)), _) try {
607
609
  if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
608
610
  if (y = 0, t) op = [op[0] & 2, t.value];
609
611
  switch (op[0]) {
@@ -632,8 +634,13 @@ function __spreadArray(to, from, pack) {
632
634
  ar[i] = from[i];
633
635
  }
634
636
  }
635
- return to.concat(ar || from);
636
- }
637
+ return to.concat(ar || Array.prototype.slice.call(from));
638
+ }
639
+
640
+ typeof SuppressedError === "function" ? SuppressedError : function (error, suppressed, message) {
641
+ var e = new Error(message);
642
+ return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
643
+ };
637
644
 
638
645
  var Bounds = /** @class */ (function () {
639
646
  function Bounds(left, top, width, height) {
@@ -1528,38 +1535,38 @@ var stringToNumber = function (codePoints) {
1528
1535
  return sign * (int + frac * Math.pow(10, -fracd)) * Math.pow(10, expsign * exp);
1529
1536
  };
1530
1537
  var LEFT_PARENTHESIS_TOKEN = {
1531
- type: 2 /* LEFT_PARENTHESIS_TOKEN */
1538
+ type: 2 /* TokenType.LEFT_PARENTHESIS_TOKEN */
1532
1539
  };
1533
1540
  var RIGHT_PARENTHESIS_TOKEN = {
1534
- type: 3 /* RIGHT_PARENTHESIS_TOKEN */
1535
- };
1536
- var COMMA_TOKEN = { type: 4 /* COMMA_TOKEN */ };
1537
- var SUFFIX_MATCH_TOKEN = { type: 13 /* SUFFIX_MATCH_TOKEN */ };
1538
- var PREFIX_MATCH_TOKEN = { type: 8 /* PREFIX_MATCH_TOKEN */ };
1539
- var COLUMN_TOKEN = { type: 21 /* COLUMN_TOKEN */ };
1540
- var DASH_MATCH_TOKEN = { type: 9 /* DASH_MATCH_TOKEN */ };
1541
- var INCLUDE_MATCH_TOKEN = { type: 10 /* INCLUDE_MATCH_TOKEN */ };
1541
+ type: 3 /* TokenType.RIGHT_PARENTHESIS_TOKEN */
1542
+ };
1543
+ var COMMA_TOKEN = { type: 4 /* TokenType.COMMA_TOKEN */ };
1544
+ var SUFFIX_MATCH_TOKEN = { type: 13 /* TokenType.SUFFIX_MATCH_TOKEN */ };
1545
+ var PREFIX_MATCH_TOKEN = { type: 8 /* TokenType.PREFIX_MATCH_TOKEN */ };
1546
+ var COLUMN_TOKEN = { type: 21 /* TokenType.COLUMN_TOKEN */ };
1547
+ var DASH_MATCH_TOKEN = { type: 9 /* TokenType.DASH_MATCH_TOKEN */ };
1548
+ var INCLUDE_MATCH_TOKEN = { type: 10 /* TokenType.INCLUDE_MATCH_TOKEN */ };
1542
1549
  var LEFT_CURLY_BRACKET_TOKEN = {
1543
- type: 11 /* LEFT_CURLY_BRACKET_TOKEN */
1550
+ type: 11 /* TokenType.LEFT_CURLY_BRACKET_TOKEN */
1544
1551
  };
1545
1552
  var RIGHT_CURLY_BRACKET_TOKEN = {
1546
- type: 12 /* RIGHT_CURLY_BRACKET_TOKEN */
1547
- };
1548
- var SUBSTRING_MATCH_TOKEN = { type: 14 /* SUBSTRING_MATCH_TOKEN */ };
1549
- var BAD_URL_TOKEN = { type: 23 /* BAD_URL_TOKEN */ };
1550
- var BAD_STRING_TOKEN = { type: 1 /* BAD_STRING_TOKEN */ };
1551
- var CDO_TOKEN = { type: 25 /* CDO_TOKEN */ };
1552
- var CDC_TOKEN = { type: 24 /* CDC_TOKEN */ };
1553
- var COLON_TOKEN = { type: 26 /* COLON_TOKEN */ };
1554
- var SEMICOLON_TOKEN = { type: 27 /* SEMICOLON_TOKEN */ };
1553
+ type: 12 /* TokenType.RIGHT_CURLY_BRACKET_TOKEN */
1554
+ };
1555
+ var SUBSTRING_MATCH_TOKEN = { type: 14 /* TokenType.SUBSTRING_MATCH_TOKEN */ };
1556
+ var BAD_URL_TOKEN = { type: 23 /* TokenType.BAD_URL_TOKEN */ };
1557
+ var BAD_STRING_TOKEN = { type: 1 /* TokenType.BAD_STRING_TOKEN */ };
1558
+ var CDO_TOKEN = { type: 25 /* TokenType.CDO_TOKEN */ };
1559
+ var CDC_TOKEN = { type: 24 /* TokenType.CDC_TOKEN */ };
1560
+ var COLON_TOKEN = { type: 26 /* TokenType.COLON_TOKEN */ };
1561
+ var SEMICOLON_TOKEN = { type: 27 /* TokenType.SEMICOLON_TOKEN */ };
1555
1562
  var LEFT_SQUARE_BRACKET_TOKEN = {
1556
- type: 28 /* LEFT_SQUARE_BRACKET_TOKEN */
1563
+ type: 28 /* TokenType.LEFT_SQUARE_BRACKET_TOKEN */
1557
1564
  };
1558
1565
  var RIGHT_SQUARE_BRACKET_TOKEN = {
1559
- type: 29 /* RIGHT_SQUARE_BRACKET_TOKEN */
1566
+ type: 29 /* TokenType.RIGHT_SQUARE_BRACKET_TOKEN */
1560
1567
  };
1561
- var WHITESPACE_TOKEN = { type: 31 /* WHITESPACE_TOKEN */ };
1562
- var EOF_TOKEN = { type: 32 /* EOF_TOKEN */ };
1568
+ var WHITESPACE_TOKEN = { type: 31 /* TokenType.WHITESPACE_TOKEN */ };
1569
+ var EOF_TOKEN = { type: 32 /* TokenType.EOF_TOKEN */ };
1563
1570
  var Tokenizer = /** @class */ (function () {
1564
1571
  function Tokenizer() {
1565
1572
  this._value = [];
@@ -1588,7 +1595,7 @@ var Tokenizer = /** @class */ (function () {
1588
1595
  if (isNameCodePoint(c1) || isValidEscape(c2, c3)) {
1589
1596
  var flags = isIdentifierStart(c1, c2, c3) ? FLAG_ID : FLAG_UNRESTRICTED;
1590
1597
  var value = this.consumeName();
1591
- return { type: 5 /* HASH_TOKEN */, value: value, flags: flags };
1598
+ return { type: 5 /* TokenType.HASH_TOKEN */, value: value, flags: flags };
1592
1599
  }
1593
1600
  break;
1594
1601
  case DOLLAR_SIGN:
@@ -1677,7 +1684,7 @@ var Tokenizer = /** @class */ (function () {
1677
1684
  var a3 = this.peekCodePoint(2);
1678
1685
  if (isIdentifierStart(a1, a2, a3)) {
1679
1686
  var value = this.consumeName();
1680
- return { type: 7 /* AT_KEYWORD_TOKEN */, value: value };
1687
+ return { type: 7 /* TokenType.AT_KEYWORD_TOKEN */, value: value };
1681
1688
  }
1682
1689
  break;
1683
1690
  case LEFT_SQUARE_BRACKET:
@@ -1741,7 +1748,7 @@ var Tokenizer = /** @class */ (function () {
1741
1748
  this.reconsumeCodePoint(codePoint);
1742
1749
  return this.consumeIdentLikeToken();
1743
1750
  }
1744
- return { type: 6 /* DELIM_TOKEN */, value: fromCodePoint$1(codePoint) };
1751
+ return { type: 6 /* TokenType.DELIM_TOKEN */, value: fromCodePoint$1(codePoint) };
1745
1752
  };
1746
1753
  Tokenizer.prototype.consumeCodePoint = function () {
1747
1754
  var value = this._value.shift();
@@ -1772,7 +1779,7 @@ var Tokenizer = /** @class */ (function () {
1772
1779
  if (questionMarks) {
1773
1780
  var start_1 = parseInt(fromCodePoint$1.apply(void 0, digits.map(function (digit) { return (digit === QUESTION_MARK ? ZERO : digit); })), 16);
1774
1781
  var end = parseInt(fromCodePoint$1.apply(void 0, digits.map(function (digit) { return (digit === QUESTION_MARK ? F : digit); })), 16);
1775
- return { type: 30 /* UNICODE_RANGE_TOKEN */, start: start_1, end: end };
1782
+ return { type: 30 /* TokenType.UNICODE_RANGE_TOKEN */, start: start_1, end: end };
1776
1783
  }
1777
1784
  var start = parseInt(fromCodePoint$1.apply(void 0, digits), 16);
1778
1785
  if (this.peekCodePoint(0) === HYPHEN_MINUS && isHex(this.peekCodePoint(1))) {
@@ -1784,10 +1791,10 @@ var Tokenizer = /** @class */ (function () {
1784
1791
  codePoint = this.consumeCodePoint();
1785
1792
  }
1786
1793
  var end = parseInt(fromCodePoint$1.apply(void 0, endDigits), 16);
1787
- return { type: 30 /* UNICODE_RANGE_TOKEN */, start: start, end: end };
1794
+ return { type: 30 /* TokenType.UNICODE_RANGE_TOKEN */, start: start, end: end };
1788
1795
  }
1789
1796
  else {
1790
- return { type: 30 /* UNICODE_RANGE_TOKEN */, start: start, end: start };
1797
+ return { type: 30 /* TokenType.UNICODE_RANGE_TOKEN */, start: start, end: start };
1791
1798
  }
1792
1799
  };
1793
1800
  Tokenizer.prototype.consumeIdentLikeToken = function () {
@@ -1798,24 +1805,24 @@ var Tokenizer = /** @class */ (function () {
1798
1805
  }
1799
1806
  else if (this.peekCodePoint(0) === LEFT_PARENTHESIS) {
1800
1807
  this.consumeCodePoint();
1801
- return { type: 19 /* FUNCTION_TOKEN */, value: value };
1808
+ return { type: 19 /* TokenType.FUNCTION_TOKEN */, value: value };
1802
1809
  }
1803
- return { type: 20 /* IDENT_TOKEN */, value: value };
1810
+ return { type: 20 /* TokenType.IDENT_TOKEN */, value: value };
1804
1811
  };
1805
1812
  Tokenizer.prototype.consumeUrlToken = function () {
1806
1813
  var value = [];
1807
1814
  this.consumeWhiteSpace();
1808
1815
  if (this.peekCodePoint(0) === EOF) {
1809
- return { type: 22 /* URL_TOKEN */, value: '' };
1816
+ return { type: 22 /* TokenType.URL_TOKEN */, value: '' };
1810
1817
  }
1811
1818
  var next = this.peekCodePoint(0);
1812
1819
  if (next === APOSTROPHE || next === QUOTATION_MARK) {
1813
1820
  var stringToken = this.consumeStringToken(this.consumeCodePoint());
1814
- if (stringToken.type === 0 /* STRING_TOKEN */) {
1821
+ if (stringToken.type === 0 /* TokenType.STRING_TOKEN */) {
1815
1822
  this.consumeWhiteSpace();
1816
1823
  if (this.peekCodePoint(0) === EOF || this.peekCodePoint(0) === RIGHT_PARENTHESIS) {
1817
1824
  this.consumeCodePoint();
1818
- return { type: 22 /* URL_TOKEN */, value: stringToken.value };
1825
+ return { type: 22 /* TokenType.URL_TOKEN */, value: stringToken.value };
1819
1826
  }
1820
1827
  }
1821
1828
  this.consumeBadUrlRemnants();
@@ -1824,13 +1831,13 @@ var Tokenizer = /** @class */ (function () {
1824
1831
  while (true) {
1825
1832
  var codePoint = this.consumeCodePoint();
1826
1833
  if (codePoint === EOF || codePoint === RIGHT_PARENTHESIS) {
1827
- return { type: 22 /* URL_TOKEN */, value: fromCodePoint$1.apply(void 0, value) };
1834
+ return { type: 22 /* TokenType.URL_TOKEN */, value: fromCodePoint$1.apply(void 0, value) };
1828
1835
  }
1829
1836
  else if (isWhiteSpace(codePoint)) {
1830
1837
  this.consumeWhiteSpace();
1831
1838
  if (this.peekCodePoint(0) === EOF || this.peekCodePoint(0) === RIGHT_PARENTHESIS) {
1832
1839
  this.consumeCodePoint();
1833
- return { type: 22 /* URL_TOKEN */, value: fromCodePoint$1.apply(void 0, value) };
1840
+ return { type: 22 /* TokenType.URL_TOKEN */, value: fromCodePoint$1.apply(void 0, value) };
1834
1841
  }
1835
1842
  this.consumeBadUrlRemnants();
1836
1843
  return BAD_URL_TOKEN;
@@ -1890,7 +1897,7 @@ var Tokenizer = /** @class */ (function () {
1890
1897
  var codePoint = this._value[i];
1891
1898
  if (codePoint === EOF || codePoint === undefined || codePoint === endingCodePoint) {
1892
1899
  value += this.consumeStringSlice(i);
1893
- return { type: 0 /* STRING_TOKEN */, value: value };
1900
+ return { type: 0 /* TokenType.STRING_TOKEN */, value: value };
1894
1901
  }
1895
1902
  if (codePoint === LINE_FEED) {
1896
1903
  this._value.splice(0, i);
@@ -1952,13 +1959,13 @@ var Tokenizer = /** @class */ (function () {
1952
1959
  var c3 = this.peekCodePoint(2);
1953
1960
  if (isIdentifierStart(c1, c2, c3)) {
1954
1961
  var unit = this.consumeName();
1955
- return { type: 15 /* DIMENSION_TOKEN */, number: number, flags: flags, unit: unit };
1962
+ return { type: 15 /* TokenType.DIMENSION_TOKEN */, number: number, flags: flags, unit: unit };
1956
1963
  }
1957
1964
  if (c1 === PERCENTAGE_SIGN) {
1958
1965
  this.consumeCodePoint();
1959
- return { type: 16 /* PERCENTAGE_TOKEN */, number: number, flags: flags };
1966
+ return { type: 16 /* TokenType.PERCENTAGE_TOKEN */, number: number, flags: flags };
1960
1967
  }
1961
- return { type: 17 /* NUMBER_TOKEN */, number: number, flags: flags };
1968
+ return { type: 17 /* TokenType.NUMBER_TOKEN */, number: number, flags: flags };
1962
1969
  };
1963
1970
  Tokenizer.prototype.consumeEscapedCodePoint = function () {
1964
1971
  var codePoint = this.consumeCodePoint();
@@ -2017,18 +2024,18 @@ var Parser = /** @class */ (function () {
2017
2024
  };
2018
2025
  Parser.prototype.parseComponentValue = function () {
2019
2026
  var token = this.consumeToken();
2020
- while (token.type === 31 /* WHITESPACE_TOKEN */) {
2027
+ while (token.type === 31 /* TokenType.WHITESPACE_TOKEN */) {
2021
2028
  token = this.consumeToken();
2022
2029
  }
2023
- if (token.type === 32 /* EOF_TOKEN */) {
2030
+ if (token.type === 32 /* TokenType.EOF_TOKEN */) {
2024
2031
  throw new SyntaxError("Error parsing CSS component value, unexpected EOF");
2025
2032
  }
2026
2033
  this.reconsumeToken(token);
2027
2034
  var value = this.consumeComponentValue();
2028
2035
  do {
2029
2036
  token = this.consumeToken();
2030
- } while (token.type === 31 /* WHITESPACE_TOKEN */);
2031
- if (token.type === 32 /* EOF_TOKEN */) {
2037
+ } while (token.type === 31 /* TokenType.WHITESPACE_TOKEN */);
2038
+ if (token.type === 32 /* TokenType.EOF_TOKEN */) {
2032
2039
  return value;
2033
2040
  }
2034
2041
  throw new SyntaxError("Error parsing CSS component value, multiple values found when expecting only one");
@@ -2037,7 +2044,7 @@ var Parser = /** @class */ (function () {
2037
2044
  var values = [];
2038
2045
  while (true) {
2039
2046
  var value = this.consumeComponentValue();
2040
- if (value.type === 32 /* EOF_TOKEN */) {
2047
+ if (value.type === 32 /* TokenType.EOF_TOKEN */) {
2041
2048
  return values;
2042
2049
  }
2043
2050
  values.push(value);
@@ -2047,11 +2054,11 @@ var Parser = /** @class */ (function () {
2047
2054
  Parser.prototype.consumeComponentValue = function () {
2048
2055
  var token = this.consumeToken();
2049
2056
  switch (token.type) {
2050
- case 11 /* LEFT_CURLY_BRACKET_TOKEN */:
2051
- case 28 /* LEFT_SQUARE_BRACKET_TOKEN */:
2052
- case 2 /* LEFT_PARENTHESIS_TOKEN */:
2057
+ case 11 /* TokenType.LEFT_CURLY_BRACKET_TOKEN */:
2058
+ case 28 /* TokenType.LEFT_SQUARE_BRACKET_TOKEN */:
2059
+ case 2 /* TokenType.LEFT_PARENTHESIS_TOKEN */:
2053
2060
  return this.consumeSimpleBlock(token.type);
2054
- case 19 /* FUNCTION_TOKEN */:
2061
+ case 19 /* TokenType.FUNCTION_TOKEN */:
2055
2062
  return this.consumeFunction(token);
2056
2063
  }
2057
2064
  return token;
@@ -2060,7 +2067,7 @@ var Parser = /** @class */ (function () {
2060
2067
  var block = { type: type, values: [] };
2061
2068
  var token = this.consumeToken();
2062
2069
  while (true) {
2063
- if (token.type === 32 /* EOF_TOKEN */ || isEndingTokenFor(token, type)) {
2070
+ if (token.type === 32 /* TokenType.EOF_TOKEN */ || isEndingTokenFor(token, type)) {
2064
2071
  return block;
2065
2072
  }
2066
2073
  this.reconsumeToken(token);
@@ -2072,11 +2079,11 @@ var Parser = /** @class */ (function () {
2072
2079
  var cssFunction = {
2073
2080
  name: functionToken.value,
2074
2081
  values: [],
2075
- type: 18 /* FUNCTION */
2082
+ type: 18 /* TokenType.FUNCTION */
2076
2083
  };
2077
2084
  while (true) {
2078
2085
  var token = this.consumeToken();
2079
- if (token.type === 32 /* EOF_TOKEN */ || token.type === 3 /* RIGHT_PARENTHESIS_TOKEN */) {
2086
+ if (token.type === 32 /* TokenType.EOF_TOKEN */ || token.type === 3 /* TokenType.RIGHT_PARENTHESIS_TOKEN */) {
2080
2087
  return cssFunction;
2081
2088
  }
2082
2089
  this.reconsumeToken(token);
@@ -2092,22 +2099,22 @@ var Parser = /** @class */ (function () {
2092
2099
  };
2093
2100
  return Parser;
2094
2101
  }());
2095
- var isDimensionToken = function (token) { return token.type === 15 /* DIMENSION_TOKEN */; };
2096
- var isNumberToken = function (token) { return token.type === 17 /* NUMBER_TOKEN */; };
2097
- var isIdentToken = function (token) { return token.type === 20 /* IDENT_TOKEN */; };
2098
- var isStringToken = function (token) { return token.type === 0 /* STRING_TOKEN */; };
2102
+ var isDimensionToken = function (token) { return token.type === 15 /* TokenType.DIMENSION_TOKEN */; };
2103
+ var isNumberToken = function (token) { return token.type === 17 /* TokenType.NUMBER_TOKEN */; };
2104
+ var isIdentToken = function (token) { return token.type === 20 /* TokenType.IDENT_TOKEN */; };
2105
+ var isStringToken = function (token) { return token.type === 0 /* TokenType.STRING_TOKEN */; };
2099
2106
  var isIdentWithValue = function (token, value) {
2100
2107
  return isIdentToken(token) && token.value === value;
2101
2108
  };
2102
- var nonWhiteSpace = function (token) { return token.type !== 31 /* WHITESPACE_TOKEN */; };
2109
+ var nonWhiteSpace = function (token) { return token.type !== 31 /* TokenType.WHITESPACE_TOKEN */; };
2103
2110
  var nonFunctionArgSeparator = function (token) {
2104
- return token.type !== 31 /* WHITESPACE_TOKEN */ && token.type !== 4 /* COMMA_TOKEN */;
2111
+ return token.type !== 31 /* TokenType.WHITESPACE_TOKEN */ && token.type !== 4 /* TokenType.COMMA_TOKEN */;
2105
2112
  };
2106
2113
  var parseFunctionArgs = function (tokens) {
2107
2114
  var args = [];
2108
2115
  var arg = [];
2109
2116
  tokens.forEach(function (token) {
2110
- if (token.type === 4 /* COMMA_TOKEN */) {
2117
+ if (token.type === 4 /* TokenType.COMMA_TOKEN */) {
2111
2118
  if (arg.length === 0) {
2112
2119
  throw new Error("Error parsing function args, zero tokens for arg");
2113
2120
  }
@@ -2115,7 +2122,7 @@ var parseFunctionArgs = function (tokens) {
2115
2122
  arg = [];
2116
2123
  return;
2117
2124
  }
2118
- if (token.type !== 31 /* WHITESPACE_TOKEN */) {
2125
+ if (token.type !== 31 /* TokenType.WHITESPACE_TOKEN */) {
2119
2126
  arg.push(token);
2120
2127
  }
2121
2128
  });
@@ -2125,37 +2132,37 @@ var parseFunctionArgs = function (tokens) {
2125
2132
  return args;
2126
2133
  };
2127
2134
  var isEndingTokenFor = function (token, type) {
2128
- if (type === 11 /* LEFT_CURLY_BRACKET_TOKEN */ && token.type === 12 /* RIGHT_CURLY_BRACKET_TOKEN */) {
2135
+ if (type === 11 /* TokenType.LEFT_CURLY_BRACKET_TOKEN */ && token.type === 12 /* TokenType.RIGHT_CURLY_BRACKET_TOKEN */) {
2129
2136
  return true;
2130
2137
  }
2131
- if (type === 28 /* LEFT_SQUARE_BRACKET_TOKEN */ && token.type === 29 /* RIGHT_SQUARE_BRACKET_TOKEN */) {
2138
+ if (type === 28 /* TokenType.LEFT_SQUARE_BRACKET_TOKEN */ && token.type === 29 /* TokenType.RIGHT_SQUARE_BRACKET_TOKEN */) {
2132
2139
  return true;
2133
2140
  }
2134
- return type === 2 /* LEFT_PARENTHESIS_TOKEN */ && token.type === 3 /* RIGHT_PARENTHESIS_TOKEN */;
2141
+ return type === 2 /* TokenType.LEFT_PARENTHESIS_TOKEN */ && token.type === 3 /* TokenType.RIGHT_PARENTHESIS_TOKEN */;
2135
2142
  };
2136
2143
 
2137
2144
  var isLength = function (token) {
2138
- return token.type === 17 /* NUMBER_TOKEN */ || token.type === 15 /* DIMENSION_TOKEN */;
2145
+ return token.type === 17 /* TokenType.NUMBER_TOKEN */ || token.type === 15 /* TokenType.DIMENSION_TOKEN */;
2139
2146
  };
2140
2147
 
2141
2148
  var isLengthPercentage = function (token) {
2142
- return token.type === 16 /* PERCENTAGE_TOKEN */ || isLength(token);
2149
+ return token.type === 16 /* TokenType.PERCENTAGE_TOKEN */ || isLength(token);
2143
2150
  };
2144
2151
  var parseLengthPercentageTuple = function (tokens) {
2145
2152
  return tokens.length > 1 ? [tokens[0], tokens[1]] : [tokens[0]];
2146
2153
  };
2147
2154
  var ZERO_LENGTH = {
2148
- type: 17 /* NUMBER_TOKEN */,
2155
+ type: 17 /* TokenType.NUMBER_TOKEN */,
2149
2156
  number: 0,
2150
2157
  flags: FLAG_INTEGER
2151
2158
  };
2152
2159
  var FIFTY_PERCENT = {
2153
- type: 16 /* PERCENTAGE_TOKEN */,
2160
+ type: 16 /* TokenType.PERCENTAGE_TOKEN */,
2154
2161
  number: 50,
2155
2162
  flags: FLAG_INTEGER
2156
2163
  };
2157
2164
  var HUNDRED_PERCENT = {
2158
- type: 16 /* PERCENTAGE_TOKEN */,
2165
+ type: 16 /* TokenType.PERCENTAGE_TOKEN */,
2159
2166
  number: 100,
2160
2167
  flags: FLAG_INTEGER
2161
2168
  };
@@ -2164,7 +2171,7 @@ var getAbsoluteValueForTuple = function (tuple, width, height) {
2164
2171
  return [getAbsoluteValue(x, width), getAbsoluteValue(typeof y !== 'undefined' ? y : x, height)];
2165
2172
  };
2166
2173
  var getAbsoluteValue = function (token, parent) {
2167
- if (token.type === 16 /* PERCENTAGE_TOKEN */) {
2174
+ if (token.type === 16 /* TokenType.PERCENTAGE_TOKEN */) {
2168
2175
  return (token.number / 100) * parent;
2169
2176
  }
2170
2177
  if (isDimensionToken(token)) {
@@ -2187,7 +2194,7 @@ var TURN = 'turn';
2187
2194
  var angle = {
2188
2195
  name: 'angle',
2189
2196
  parse: function (_context, value) {
2190
- if (value.type === 15 /* DIMENSION_TOKEN */) {
2197
+ if (value.type === 15 /* TokenType.DIMENSION_TOKEN */) {
2191
2198
  switch (value.unit) {
2192
2199
  case DEG:
2193
2200
  return (Math.PI * value.number) / 180;
@@ -2203,7 +2210,7 @@ var angle = {
2203
2210
  }
2204
2211
  };
2205
2212
  var isAngle = function (value) {
2206
- if (value.type === 15 /* DIMENSION_TOKEN */) {
2213
+ if (value.type === 15 /* TokenType.DIMENSION_TOKEN */) {
2207
2214
  if (value.unit === DEG || value.unit === GRAD || value.unit === RAD || value.unit === TURN) {
2208
2215
  return true;
2209
2216
  }
@@ -2253,87 +2260,154 @@ var parseNamedSide = function (tokens) {
2253
2260
  };
2254
2261
  var deg = function (deg) { return (Math.PI * deg) / 180; };
2255
2262
 
2256
- var color$1 = {
2257
- name: 'color',
2258
- parse: function (context, value) {
2259
- if (value.type === 18 /* FUNCTION */) {
2260
- var colorFunction = SUPPORTED_COLOR_FUNCTIONS[value.name];
2261
- if (typeof colorFunction === 'undefined') {
2262
- throw new Error("Attempting to parse an unsupported color function \"" + value.name + "\"");
2263
- }
2264
- return colorFunction(context, value.values);
2265
- }
2266
- if (value.type === 5 /* HASH_TOKEN */) {
2267
- if (value.value.length === 3) {
2268
- var r = value.value.substring(0, 1);
2269
- var g = value.value.substring(1, 2);
2270
- var b = value.value.substring(2, 3);
2271
- return pack(parseInt(r + r, 16), parseInt(g + g, 16), parseInt(b + b, 16), 1);
2272
- }
2273
- if (value.value.length === 4) {
2274
- var r = value.value.substring(0, 1);
2275
- var g = value.value.substring(1, 2);
2276
- var b = value.value.substring(2, 3);
2277
- var a = value.value.substring(3, 4);
2278
- return pack(parseInt(r + r, 16), parseInt(g + g, 16), parseInt(b + b, 16), parseInt(a + a, 16) / 255);
2279
- }
2280
- if (value.value.length === 6) {
2281
- var r = value.value.substring(0, 2);
2282
- var g = value.value.substring(2, 4);
2283
- var b = value.value.substring(4, 6);
2284
- return pack(parseInt(r, 16), parseInt(g, 16), parseInt(b, 16), 1);
2285
- }
2286
- if (value.value.length === 8) {
2287
- var r = value.value.substring(0, 2);
2288
- var g = value.value.substring(2, 4);
2289
- var b = value.value.substring(4, 6);
2290
- var a = value.value.substring(6, 8);
2291
- return pack(parseInt(r, 16), parseInt(g, 16), parseInt(b, 16), parseInt(a, 16) / 255);
2292
- }
2293
- }
2294
- if (value.type === 20 /* IDENT_TOKEN */) {
2295
- var namedColor = COLORS[value.value.toUpperCase()];
2296
- if (typeof namedColor !== 'undefined') {
2297
- return namedColor;
2298
- }
2299
- }
2300
- return COLORS.TRANSPARENT;
2301
- }
2302
- };
2303
2263
  var isTransparent = function (color) { return (0xff & color) === 0; };
2304
2264
  var asString = function (color) {
2305
2265
  var alpha = 0xff & color;
2306
2266
  var blue = 0xff & (color >> 8);
2307
2267
  var green = 0xff & (color >> 16);
2308
2268
  var red = 0xff & (color >> 24);
2309
- return alpha < 255 ? "rgba(" + red + "," + green + "," + blue + "," + alpha / 255 + ")" : "rgb(" + red + "," + green + "," + blue + ")";
2269
+ return alpha < 255 ? "rgba(".concat(red, ",").concat(green, ",").concat(blue, ",").concat(alpha / 255, ")") : "rgb(".concat(red, ",").concat(green, ",").concat(blue, ")");
2310
2270
  };
2311
2271
  var pack = function (r, g, b, a) {
2312
2272
  return ((r << 24) | (g << 16) | (b << 8) | (Math.round(a * 255) << 0)) >>> 0;
2313
2273
  };
2314
2274
  var getTokenColorValue = function (token, i) {
2315
- if (token.type === 17 /* NUMBER_TOKEN */) {
2275
+ if (token.type === 17 /* TokenType.NUMBER_TOKEN */) {
2316
2276
  return token.number;
2317
2277
  }
2318
- if (token.type === 16 /* PERCENTAGE_TOKEN */) {
2278
+ if (token.type === 16 /* TokenType.PERCENTAGE_TOKEN */) {
2319
2279
  var max = i === 3 ? 1 : 255;
2320
2280
  return i === 3 ? (token.number / 100) * max : Math.round((token.number / 100) * max);
2321
2281
  }
2322
2282
  return 0;
2323
2283
  };
2324
- var rgb = function (_context, args) {
2325
- var tokens = args.filter(nonFunctionArgSeparator);
2326
- if (tokens.length === 3) {
2327
- var _a = tokens.map(getTokenColorValue), r = _a[0], g = _a[1], b = _a[2];
2328
- return pack(r, g, b, 1);
2329
- }
2330
- if (tokens.length === 4) {
2331
- var _b = tokens.map(getTokenColorValue), r = _b[0], g = _b[1], b = _b[2], a = _b[3];
2332
- return pack(r, g, b, a);
2333
- }
2334
- return 0;
2284
+ var isRelativeTransform = function (tokens) {
2285
+ return (tokens[0].type === 20 /* TokenType.IDENT_TOKEN */ ? tokens[0].value : 'unknown') === 'from';
2286
+ };
2287
+ var clamp = function (value, min, max) {
2288
+ return Math.min(Math.max(value, min), max);
2289
+ };
2290
+ var multiplyMatrices = function (A, B) {
2291
+ return [
2292
+ A[0] * B[0] + A[1] * B[1] + A[2] * B[2],
2293
+ A[3] * B[0] + A[4] * B[1] + A[5] * B[2],
2294
+ A[6] * B[0] + A[7] * B[1] + A[8] * B[2]
2295
+ ];
2335
2296
  };
2336
- function hue2rgb(t1, t2, hue) {
2297
+ var packSrgb = function (args) {
2298
+ return pack(clamp(Math.round(args[0] * 255), 0, 255), clamp(Math.round(args[1] * 255), 0, 255), clamp(Math.round(args[2] * 255), 0, 255), clamp(args[3], 0, 1));
2299
+ };
2300
+ var packSrgbLinear = function (_a) {
2301
+ var r = _a[0], g = _a[1], b = _a[2], a = _a[3];
2302
+ var rgb = srgbLinear2rgb([r, g, b]);
2303
+ return pack(clamp(Math.round(rgb[0] * 255), 0, 255), clamp(Math.round(rgb[1] * 255), 0, 255), clamp(Math.round(rgb[2] * 255), 0, 255), a);
2304
+ };
2305
+ var packXYZ = function (args) {
2306
+ var srgb_linear = xyz2rgbLinear([args[0], args[1], args[2]]);
2307
+ return packSrgbLinear([srgb_linear[0], srgb_linear[1], srgb_linear[2], args[3]]);
2308
+ };
2309
+ var packLab = function (_context, args) {
2310
+ if (isRelativeTransform(args.filter(nonFunctionArgSeparator))) {
2311
+ throw new Error('Relative color not supported for lab()');
2312
+ }
2313
+ var _a = extractLabComponents(args), l = _a[0], a = _a[1], b = _a[2], alpha = _a[3], rgb = srgbLinear2rgb(xyz2rgbLinear(lab2xyz([l, a, b])));
2314
+ return pack(clamp(Math.round(rgb[0] * 255), 0, 255), clamp(Math.round(rgb[1] * 255), 0, 255), clamp(Math.round(rgb[2] * 255), 0, 255), alpha);
2315
+ };
2316
+ var packOkLab = function (_context, args) {
2317
+ if (isRelativeTransform(args.filter(nonFunctionArgSeparator))) {
2318
+ throw new Error('Relative color not supported for oklab()');
2319
+ }
2320
+ var _a = extractLabComponents(args), l = _a[0], a = _a[1], b = _a[2], alpha = _a[3], rgb = srgbLinear2rgb(xyz2rgbLinear(oklab2xyz([l, a, b])));
2321
+ return pack(clamp(Math.round(rgb[0] * 255), 0, 255), clamp(Math.round(rgb[1] * 255), 0, 255), clamp(Math.round(rgb[2] * 255), 0, 255), alpha);
2322
+ };
2323
+ var packOkLch = function (_context, args) {
2324
+ if (isRelativeTransform(args.filter(nonFunctionArgSeparator))) {
2325
+ throw new Error('Relative color not supported for oklch()');
2326
+ }
2327
+ var _a = extractOkLchComponents(args), l = _a[0], c = _a[1], h = _a[2], alpha = _a[3], rgb = srgbLinear2rgb(xyz2rgbLinear(oklab2xyz(lch2lab([l, c, h]))));
2328
+ return pack(clamp(Math.round(rgb[0] * 255), 0, 255), clamp(Math.round(rgb[1] * 255), 0, 255), clamp(Math.round(rgb[2] * 255), 0, 255), alpha);
2329
+ };
2330
+ var packLch = function (_context, args) {
2331
+ if (isRelativeTransform(args.filter(nonFunctionArgSeparator))) {
2332
+ throw new Error('Relative color not supported for lch()');
2333
+ }
2334
+ var _a = extractLchComponents(args), l = _a[0], c = _a[1], h = _a[2], a = _a[3], rgb = srgbLinear2rgb(xyz2rgbLinear(lab2xyz(lch2lab([l, c, h]))));
2335
+ return pack(clamp(Math.round(rgb[0] * 255), 0, 255), clamp(Math.round(rgb[1] * 255), 0, 255), clamp(Math.round(rgb[2] * 255), 0, 255), a);
2336
+ };
2337
+ var extractHslComponents = function (context, args) {
2338
+ var tokens = args.filter(nonFunctionArgSeparator), hue = tokens[0], saturation = tokens[1], lightness = tokens[2], alpha = tokens[3], h = (hue.type === 17 /* TokenType.NUMBER_TOKEN */ ? deg(hue.number) : angle.parse(context, hue)) / (Math.PI * 2), s = isLengthPercentage(saturation) ? saturation.number / 100 : 0, l = isLengthPercentage(lightness) ? lightness.number / 100 : 0, a = typeof alpha !== 'undefined' && isLengthPercentage(alpha) ? getAbsoluteValue(alpha, 1) : 1;
2339
+ return [h, s, l, a];
2340
+ };
2341
+ var packHSL = function (context, args) {
2342
+ if (isRelativeTransform(args)) {
2343
+ throw new Error('Relative color not supported for hsl()');
2344
+ }
2345
+ var _a = extractHslComponents(context, args), h = _a[0], s = _a[1], l = _a[2], a = _a[3], rgb = hsl2rgb([h, s, l]);
2346
+ return pack(rgb[0] * 255, rgb[1] * 255, rgb[2] * 255, s === 0 ? 1 : a);
2347
+ };
2348
+ var extractLchComponents = function (args) {
2349
+ var tokens = args.filter(nonFunctionArgSeparator), l = isLengthPercentage(tokens[0]) ? tokens[0].number : 0, c = isLengthPercentage(tokens[1]) ? tokens[1].number : 0, h = isNumberToken(tokens[2]) || isDimensionToken(tokens[2]) ? tokens[2].number : 0, a = typeof tokens[4] !== 'undefined' && isLengthPercentage(tokens[4]) ? getAbsoluteValue(tokens[4], 1) : 1;
2350
+ return [l, c, h, a];
2351
+ };
2352
+ var extractLabComponents = function (args) {
2353
+ var tokens = args.filter(nonFunctionArgSeparator),
2354
+ // eslint-disable-next-line prettier/prettier
2355
+ l = tokens[0].type === 16 /* TokenType.PERCENTAGE_TOKEN */
2356
+ ? tokens[0].number / 100
2357
+ : isNumberToken(tokens[0])
2358
+ ? tokens[0].number
2359
+ : 0,
2360
+ // eslint-disable-next-line prettier/prettier
2361
+ a = tokens[1].type === 16 /* TokenType.PERCENTAGE_TOKEN */
2362
+ ? tokens[1].number / 100
2363
+ : isNumberToken(tokens[1])
2364
+ ? tokens[1].number
2365
+ : 0, b = isNumberToken(tokens[2]) || isDimensionToken(tokens[2]) ? tokens[2].number : 0, alpha = typeof tokens[4] !== 'undefined' && isLengthPercentage(tokens[4]) ? getAbsoluteValue(tokens[4], 1) : 1;
2366
+ return [l, a, b, alpha];
2367
+ };
2368
+ var extractOkLchComponents = function (args) {
2369
+ var tokens = args.filter(nonFunctionArgSeparator),
2370
+ // eslint-disable-next-line prettier/prettier
2371
+ l = tokens[0].type === 16 /* TokenType.PERCENTAGE_TOKEN */
2372
+ ? tokens[0].number / 100
2373
+ : isNumberToken(tokens[0])
2374
+ ? tokens[0].number
2375
+ : 0,
2376
+ // eslint-disable-next-line prettier/prettier
2377
+ c = tokens[1].type === 16 /* TokenType.PERCENTAGE_TOKEN */
2378
+ ? tokens[1].number / 100
2379
+ : isNumberToken(tokens[1])
2380
+ ? tokens[1].number
2381
+ : 0, h = isNumberToken(tokens[2]) || isDimensionToken(tokens[2]) ? tokens[2].number : 0, a = typeof tokens[4] !== 'undefined' && isLengthPercentage(tokens[4]) ? getAbsoluteValue(tokens[4], 1) : 1;
2382
+ return [l, c, h, a];
2383
+ };
2384
+ /**
2385
+ * Convert D65 to D50
2386
+ *
2387
+ * @param xyz
2388
+ */
2389
+ var d65toD50 = function (xyz) {
2390
+ return multiplyMatrices(
2391
+ // eslint-disable-next-line prettier/prettier
2392
+ [
2393
+ 1.0479297925449969, 0.022946870601609652, -0.05019226628920524, 0.02962780877005599, 0.9904344267538799,
2394
+ -0.017073799063418826, -0.009243040646204504, 0.015055191490298152, 0.7518742814281371
2395
+ ], xyz);
2396
+ };
2397
+ /**
2398
+ * Convert D50 to D65
2399
+ *
2400
+ * @param xyz
2401
+ */
2402
+ var d50toD65 = function (xyz) {
2403
+ return multiplyMatrices(
2404
+ // eslint-disable-next-line prettier/prettier
2405
+ [
2406
+ 0.955473421488075, -0.02309845494876471, 0.06325924320057072, -0.0283697093338637, 1.0099953980813041,
2407
+ 0.021041441191917323, 0.012314014864481998, -0.020507649298898964, 1.330365926242124
2408
+ ], xyz);
2409
+ };
2410
+ var hue2rgb = function (t1, t2, hue) {
2337
2411
  if (hue < 0) {
2338
2412
  hue += 1;
2339
2413
  }
@@ -2352,29 +2426,783 @@ function hue2rgb(t1, t2, hue) {
2352
2426
  else {
2353
2427
  return t1;
2354
2428
  }
2355
- }
2356
- var hsl = function (context, args) {
2357
- var tokens = args.filter(nonFunctionArgSeparator);
2358
- var hue = tokens[0], saturation = tokens[1], lightness = tokens[2], alpha = tokens[3];
2359
- var h = (hue.type === 17 /* NUMBER_TOKEN */ ? deg(hue.number) : angle.parse(context, hue)) / (Math.PI * 2);
2360
- var s = isLengthPercentage(saturation) ? saturation.number / 100 : 0;
2361
- var l = isLengthPercentage(lightness) ? lightness.number / 100 : 0;
2362
- var a = typeof alpha !== 'undefined' && isLengthPercentage(alpha) ? getAbsoluteValue(alpha, 1) : 1;
2429
+ };
2430
+ var hsl2rgb = function (_a) {
2431
+ var h = _a[0], s = _a[1], l = _a[2];
2363
2432
  if (s === 0) {
2364
- return pack(l * 255, l * 255, l * 255, 1);
2433
+ return [l * 255, l * 255, l * 255];
2365
2434
  }
2366
- var t2 = l <= 0.5 ? l * (s + 1) : l + s - l * s;
2367
- var t1 = l * 2 - t2;
2368
- var r = hue2rgb(t1, t2, h + 1 / 3);
2369
- var g = hue2rgb(t1, t2, h);
2370
- var b = hue2rgb(t1, t2, h - 1 / 3);
2371
- return pack(r * 255, g * 255, b * 255, a);
2435
+ var t2 = l <= 0.5 ? l * (s + 1) : l + s - l * s, t1 = l * 2 - t2, r = hue2rgb(t1, t2, h + 1 / 3), g = hue2rgb(t1, t2, h), b = hue2rgb(t1, t2, h - 1 / 3);
2436
+ return [r, g, b];
2437
+ };
2438
+ /**
2439
+ * Convert lch to OKLab
2440
+ *
2441
+ * @param l
2442
+ * @param c
2443
+ * @param h
2444
+ */
2445
+ var lch2lab = function (_a) {
2446
+ var l = _a[0], c = _a[1], h = _a[2];
2447
+ if (c < 0) {
2448
+ c = 0;
2449
+ }
2450
+ if (isNaN(h)) {
2451
+ h = 0;
2452
+ }
2453
+ return [l, c * Math.cos((h * Math.PI) / 180), c * Math.sin((h * Math.PI) / 180)];
2454
+ };
2455
+ /**
2456
+ * Convert OKLab to XYZ relative to D65
2457
+ *
2458
+ * @param lab
2459
+ */
2460
+ var oklab2xyz = function (lab) {
2461
+ var LMSg = multiplyMatrices(
2462
+ // eslint-disable-next-line prettier/prettier
2463
+ [
2464
+ 1, 0.3963377773761749, 0.2158037573099136, 1, -0.1055613458156586, -0.0638541728258133, 1,
2465
+ -0.0894841775298119, -1.2914855480194092
2466
+ ], lab), LMS = LMSg.map(function (val) { return Math.pow(val, 3); });
2467
+ return multiplyMatrices(
2468
+ // eslint-disable-next-line prettier/prettier
2469
+ [
2470
+ 1.2268798758459243, -0.5578149944602171, 0.2813910456659647, -0.0405757452148008, 1.112286803280317,
2471
+ -0.0717110580655164, -0.0763729366746601, -0.4214933324022432, 1.5869240198367816
2472
+ ], LMS);
2473
+ };
2474
+ /**
2475
+ * Convert Lab to D50-adapted XYZ
2476
+ *
2477
+ * @param lab
2478
+ */
2479
+ var lab2xyz = function (lab) {
2480
+ var fy = (lab[0] + 16) / 116, fx = lab[1] / 500 + fy, fz = fy - lab[2] / 200, k = 24389 / 27, e = 24 / 116, xyz = [
2481
+ ((fx > e ? Math.pow(fx, 3) : (116 * fx - 16) / k) * 0.3457) / 0.3585,
2482
+ lab[0] > 8 ? Math.pow(fy, 3) : lab[0] / k,
2483
+ ((fz > e ? Math.pow(fz, 3) : (116 * fz - 16) / k) * (1.0 - 0.3457 - 0.3585)) / 0.3585
2484
+ ];
2485
+ return d50toD65([xyz[0], xyz[1], xyz[2]]);
2486
+ };
2487
+ /**
2488
+ * Convert RGB to XYZ
2489
+ *
2490
+ * @param _context
2491
+ * @param args
2492
+ */
2493
+ var rgbToXyz = function (_context, args) {
2494
+ var tokens = args.filter(nonFunctionArgSeparator);
2495
+ if (tokens.length === 3) {
2496
+ var _a = tokens.map(getTokenColorValue), r = _a[0], g = _a[1], b = _a[2], rgb_linear = rgb2rgbLinear([r / 255, g / 255, b / 255]), _b = rgbLinear2xyz([rgb_linear[0], rgb_linear[1], rgb_linear[2]]), x = _b[0], y = _b[1], z = _b[2];
2497
+ return [x, y, z, 1];
2498
+ }
2499
+ if (tokens.length === 4) {
2500
+ var _c = tokens.map(getTokenColorValue), r = _c[0], g = _c[1], b = _c[2], a = _c[3], rgb_linear = rgb2rgbLinear([r / 255, g / 255, b / 255]), _d = rgbLinear2xyz([rgb_linear[0], rgb_linear[1], rgb_linear[2]]), x = _d[0], y = _d[1], z = _d[2];
2501
+ return [x, y, z, a];
2502
+ }
2503
+ return [0, 0, 0, 1];
2504
+ };
2505
+ /**
2506
+ * HSL to XYZ
2507
+ *
2508
+ * @param context
2509
+ * @param args
2510
+ */
2511
+ var hslToXyz = function (context, args) {
2512
+ var _a = extractHslComponents(context, args), h = _a[0], s = _a[1], l = _a[2], a = _a[3], rgb_linear = rgb2rgbLinear(hsl2rgb([h, s, l])), _b = rgbLinear2xyz([rgb_linear[0], rgb_linear[1], rgb_linear[2]]), x = _b[0], y = _b[1], z = _b[2];
2513
+ return [x, y, z, a];
2514
+ };
2515
+ /**
2516
+ * LAB to XYZ
2517
+ *
2518
+ * @param _context
2519
+ * @param args
2520
+ */
2521
+ var labToXyz = function (_context, args) {
2522
+ var _a = extractLabComponents(args), l = _a[0], a = _a[1], b = _a[2], alpha = _a[3], _b = lab2xyz([l, a, b]), x = _b[0], y = _b[1], z = _b[2];
2523
+ return [x, y, z, alpha];
2524
+ };
2525
+ /**
2526
+ * LCH to XYZ
2527
+ *
2528
+ * @param _context
2529
+ * @param args
2530
+ */
2531
+ var lchToXyz = function (_context, args) {
2532
+ var _a = extractLchComponents(args), l = _a[0], c = _a[1], h = _a[2], alpha = _a[3], _b = lab2xyz(lch2lab([l, c, h])), x = _b[0], y = _b[1], z = _b[2];
2533
+ return [x, y, z, alpha];
2534
+ };
2535
+ /**
2536
+ * OKLch to XYZ
2537
+ *
2538
+ * @param _context
2539
+ * @param args
2540
+ */
2541
+ var oklchToXyz = function (_context, args) {
2542
+ var _a = extractOkLchComponents(args), l = _a[0], c = _a[1], h = _a[2], alpha = _a[3], _b = oklab2xyz(lch2lab([l, c, h])), x = _b[0], y = _b[1], z = _b[2];
2543
+ return [x, y, z, alpha];
2544
+ };
2545
+ /**
2546
+ * OKLab to XYZ
2547
+ *
2548
+ * @param _context
2549
+ * @param args
2550
+ */
2551
+ var oklabToXyz = function (_context, args) {
2552
+ var _a = extractLabComponents(args), l = _a[0], c = _a[1], h = _a[2], alpha = _a[3], _b = oklab2xyz([l, c, h]), x = _b[0], y = _b[1], z = _b[2];
2553
+ return [x, y, z, alpha];
2554
+ };
2555
+ /**
2556
+ * XYZ-50 to XYZ
2557
+ *
2558
+ * @param args
2559
+ */
2560
+ var xyz50ToXYZ = function (args) {
2561
+ return d50toD65([args[0], args[1], args[2]]);
2562
+ };
2563
+ /**
2564
+ * Does nothing, required for SUPPORTED_COLOR_SPACES_FROM_XYZ in the _color() function
2565
+ *
2566
+ * @param args
2567
+ */
2568
+ var xyzFromXYZ = function (args) {
2569
+ return args;
2570
+ };
2571
+ /**
2572
+ * XYZ-65 to XYZ-50
2573
+ *
2574
+ * @param args
2575
+ */
2576
+ var xyz50FromXYZ = function (args) {
2577
+ var _a = d65toD50([args[0], args[2], args[3]]), x = _a[0], y = _a[1], z = _a[2];
2578
+ return [x, y, z, args[3]];
2579
+ };
2580
+ /**
2581
+ * Convert XYZ to SRGB and Pack
2582
+ *
2583
+ * @param args
2584
+ */
2585
+ var convertXyz = function (args) {
2586
+ return packXYZ([args[0], args[1], args[2], args[3]]);
2587
+ };
2588
+ /**
2589
+ * Convert XYZ-50 to SRGB and Pack
2590
+ *
2591
+ * @param args
2592
+ */
2593
+ var convertXyz50 = function (args) {
2594
+ var xyz = xyz50ToXYZ([args[0], args[1], args[2]]);
2595
+ return packXYZ([xyz[0], xyz[1], xyz[2], args[3]]);
2596
+ };
2597
+
2598
+ /**
2599
+ * SRGB related functions
2600
+ */
2601
+ /**
2602
+ * Convert XYZ to linear-light sRGB
2603
+ *
2604
+ * @param xyz
2605
+ */
2606
+ var xyz2rgbLinear = function (xyz) {
2607
+ return multiplyMatrices(
2608
+ // eslint-disable-next-line prettier/prettier
2609
+ [
2610
+ 3.2409699419045226, -1.537383177570094, -0.4986107602930034, -0.9692436362808796, 1.8759675015077202,
2611
+ 0.04155505740717559, 0.05563007969699366, -0.20397695888897652, 1.0569715142428786
2612
+ ], xyz);
2613
+ };
2614
+ /**
2615
+ * Convert XYZ to linear-light sRGB
2616
+ *
2617
+ * @param xyz
2618
+ */
2619
+ var rgbLinear2xyz = function (xyz) {
2620
+ return multiplyMatrices(
2621
+ // eslint-disable-next-line prettier/prettier
2622
+ [
2623
+ 0.41239079926595934, 0.357584339383878, 0.1804807884018343, 0.21263900587151027, 0.715168678767756,
2624
+ 0.07219231536073371, 0.01933081871559182, 0.11919477979462598, 0.9505321522496607
2625
+ ], xyz);
2626
+ };
2627
+ /**
2628
+ * Convert sRGB to RGB
2629
+ *
2630
+ * @param rgb
2631
+ */
2632
+ var srgbLinear2rgb = function (rgb) {
2633
+ return rgb.map(function (c) {
2634
+ var sign = c < 0 ? -1 : 1, abs = Math.abs(c);
2635
+ // eslint-disable-next-line prettier/prettier
2636
+ return abs > 0.0031308 ? sign * (1.055 * Math.pow(abs, (1 / 2.4)) - 0.055) : 12.92 * c;
2637
+ });
2638
+ };
2639
+ /**
2640
+ * Convert RGB to sRGB
2641
+ *
2642
+ * @param rgb
2643
+ */
2644
+ var rgb2rgbLinear = function (rgb) {
2645
+ return rgb.map(function (c) {
2646
+ var sign = c < 0 ? -1 : 1, abs = Math.abs(c);
2647
+ // eslint-disable-next-line prettier/prettier
2648
+ return abs <= 0.04045 ? c / 12.92 : sign * Math.pow(((abs + 0.055) / 1.055), 2.4);
2649
+ });
2650
+ };
2651
+ /**
2652
+ * XYZ to SRGB
2653
+ *
2654
+ * @param args
2655
+ */
2656
+ var srgbFromXYZ = function (args) {
2657
+ var _a = srgbLinear2rgb(xyz2rgbLinear([args[0], args[1], args[2]])), r = _a[0], g = _a[1], b = _a[2];
2658
+ return [r, g, b, args[3]];
2659
+ };
2660
+ /**
2661
+ * XYZ to SRGB-Linear
2662
+ * @param args
2663
+ */
2664
+ var srgbLinearFromXYZ = function (args) {
2665
+ var _a = xyz2rgbLinear([args[0], args[1], args[2]]), r = _a[0], g = _a[1], b = _a[2];
2666
+ return [
2667
+ clamp(Math.round(r * 255), 0, 255),
2668
+ clamp(Math.round(g * 255), 0, 255),
2669
+ clamp(Math.round(b * 255), 0, 255),
2670
+ args[3]
2671
+ ];
2672
+ };
2673
+
2674
+ /**
2675
+ * Display-P3 related functions
2676
+ */
2677
+ /**
2678
+ * Convert P3 Linear to xyz
2679
+ *
2680
+ * @param p3l
2681
+ */
2682
+ var p3LinearToXyz = function (p3l) {
2683
+ return multiplyMatrices(
2684
+ // eslint-disable-next-line prettier/prettier
2685
+ [
2686
+ 0.4865709486482162, 0.26566769316909306, 0.1982172852343625, 0.2289745640697488, 0.6917385218365064,
2687
+ 0.079286914093745, 0.0, 0.04511338185890264, 1.043944368900976
2688
+ ], p3l);
2689
+ };
2690
+ /**
2691
+ * Convert XYZ to P3 Linear
2692
+ *
2693
+ * @param xyz
2694
+ */
2695
+ var xyzToP3Linear = function (xyz) {
2696
+ return multiplyMatrices(
2697
+ // eslint-disable-next-line prettier/prettier
2698
+ [
2699
+ 2.493496911941425, -0.9313836179191239, -0.40271078445071684, -0.8294889695615747, 1.7626640603183463,
2700
+ 0.023624685841943577, 0.03584583024378447, -0.07617238926804182, 0.9568845240076872
2701
+ ], xyz);
2702
+ };
2703
+ /**
2704
+ * Convert P3 to P3 linear
2705
+ *
2706
+ * @param p3
2707
+ */
2708
+ var p32p3Linear = function (p3) {
2709
+ return p3.map(function (c) {
2710
+ var sign = c < 0 ? -1 : 1, abs = c * sign;
2711
+ if (abs <= 0.04045) {
2712
+ return c / 12.92;
2713
+ }
2714
+ // eslint-disable-next-line prettier/prettier
2715
+ return sign * Math.pow(((c + 0.055) / 1.055), 2.4) || 0;
2716
+ });
2717
+ };
2718
+ /**
2719
+ * Convert P3 Linear to P3
2720
+ *
2721
+ * @param p3l
2722
+ */
2723
+ var p3Linear2p3 = function (p3l) {
2724
+ return srgbLinear2rgb(p3l);
2725
+ };
2726
+ /**
2727
+ * Convert P3 to XYZ
2728
+ *
2729
+ * @param args
2730
+ */
2731
+ var p3ToXYZ = function (args) {
2732
+ var p3_linear = p32p3Linear([args[0], args[1], args[2]]);
2733
+ return p3LinearToXyz([p3_linear[0], p3_linear[1], p3_linear[2]]);
2734
+ };
2735
+ /**
2736
+ * Convert XYZ to P3
2737
+ *
2738
+ * @param args
2739
+ */
2740
+ var p3FromXYZ = function (args) {
2741
+ var _a = p3Linear2p3(xyzToP3Linear([args[0], args[1], args[2]])), r = _a[0], g = _a[1], b = _a[2];
2742
+ return [r, g, b, args[3]];
2743
+ };
2744
+ /**
2745
+ * Convert P3 to SRGB and Pack
2746
+ *
2747
+ * @param args
2748
+ */
2749
+ var convertP3 = function (args) {
2750
+ var xyz = p3ToXYZ([args[0], args[1], args[2]]);
2751
+ return packXYZ([xyz[0], xyz[1], xyz[2], args[3]]);
2752
+ };
2753
+
2754
+ /**
2755
+ * A98-RGB related functions
2756
+ */
2757
+ /**
2758
+ * Convert XYZ to a98 linear
2759
+ *
2760
+ * @param xyz
2761
+ */
2762
+ var xyz2a98Linear = function (xyz) {
2763
+ return multiplyMatrices(
2764
+ // eslint-disable-next-line prettier/prettier
2765
+ [
2766
+ 2.0415879038107465, -0.5650069742788596, -0.34473135077832956, -0.9692436362808795, 1.8759675015077202,
2767
+ 0.04155505740717557, 0.013444280632031142, -0.11836239223101838, 1.0151749943912054
2768
+ ], xyz);
2769
+ };
2770
+ /**
2771
+ * Convert XYZ to a98 linear
2772
+ *
2773
+ * @param a98
2774
+ */
2775
+ var a98Linear2xyz = function (a98) {
2776
+ return multiplyMatrices(
2777
+ // eslint-disable-next-line prettier/prettier
2778
+ [
2779
+ 0.5766690429101305, 0.1855582379065463, 0.1882286462349947, 0.29734497525053605, 0.6273635662554661,
2780
+ 0.0752914584939978, 0.02703136138641234, 0.07068885253582723, 0.9913375368376388
2781
+ ], a98);
2782
+ };
2783
+ /**
2784
+ * Convert A98 RGB to rgb linear
2785
+ *
2786
+ * @param rgb
2787
+ */
2788
+ var a982a98Linear = function (rgb) {
2789
+ var mapped = rgb.map(function (c) {
2790
+ var sign = c < 0 ? -1 : 1, abs = Math.abs(c);
2791
+ return sign * Math.pow(abs, (563 / 256));
2792
+ });
2793
+ return [mapped[0], mapped[1], mapped[2]];
2794
+ };
2795
+ /**
2796
+ * Convert A98 RGB Linear to A98
2797
+ *
2798
+ * @param rgb
2799
+ */
2800
+ var a98Linear2a98 = function (rgb) {
2801
+ var mapped = rgb.map(function (c) {
2802
+ var sign = c < 0 ? -1 : 1, abs = Math.abs(c);
2803
+ return sign * Math.pow(abs, (256 / 563));
2804
+ });
2805
+ return [mapped[0], mapped[1], mapped[2]];
2806
+ };
2807
+ /**
2808
+ * Convert XYZ to A98
2809
+ *
2810
+ * @param args
2811
+ */
2812
+ var a98FromXYZ = function (args) {
2813
+ var _a = a98Linear2a98(xyz2a98Linear([args[0], args[1], args[2]])), r = _a[0], g = _a[1], b = _a[2];
2814
+ return [r, g, b, args[3]];
2815
+ };
2816
+ /**
2817
+ * Convert A98 to XYZ and Pack
2818
+ *
2819
+ * @param args
2820
+ */
2821
+ var convertA98rgb = function (args) {
2822
+ var srgb_linear = xyz2rgbLinear(a98Linear2xyz(a982a98Linear([args[0], args[1], args[2]])));
2823
+ return packSrgbLinear([srgb_linear[0], srgb_linear[1], srgb_linear[2], args[3]]);
2824
+ };
2825
+
2826
+ /**
2827
+ * Pro Photo related functions
2828
+ */
2829
+ /**
2830
+ * Convert linear-light display-p3 to XYZ D65
2831
+ *
2832
+ * @param p3
2833
+ */
2834
+ var proPhotoLinearToXyz = function (p3) {
2835
+ return multiplyMatrices(
2836
+ // eslint-disable-next-line prettier/prettier
2837
+ [
2838
+ 0.7977666449006423, 0.13518129740053308, 0.0313477341283922, 0.2880748288194013, 0.711835234241873,
2839
+ 0.00008993693872564, 0.0, 0.0, 0.8251046025104602
2840
+ ], p3);
2841
+ };
2842
+ /**
2843
+ * Convert XYZ D65 to linear-light display-p3
2844
+ *
2845
+ * @param xyz
2846
+ */
2847
+ var xyzToProPhotoLinear = function (xyz) {
2848
+ return multiplyMatrices(
2849
+ // eslint-disable-next-line prettier/prettier
2850
+ [
2851
+ 1.3457868816471583, -0.25557208737979464, -0.05110186497554526, -0.5446307051249019, 1.5082477428451468,
2852
+ 0.02052744743642139, 0.0, 0.0, 1.2119675456389452
2853
+ ], xyz);
2854
+ };
2855
+ /**
2856
+ * Convert Pro-Photo to Pro-Photo Linear
2857
+ *
2858
+ * @param p3
2859
+ */
2860
+ var proPhotoToProPhotoLinear = function (p3) {
2861
+ return p3.map(function (c) {
2862
+ return c < 16 / 512 ? c / 16 : Math.pow(c, 1.8);
2863
+ });
2864
+ };
2865
+ /**
2866
+ * Convert Pro-Photo Linear to Pro-Photo
2867
+ *
2868
+ * @param p3
2869
+ */
2870
+ var proPhotoLinearToProPhoto = function (p3) {
2871
+ return p3.map(function (c) {
2872
+ return c > 1 / 512 ? Math.pow(c, (1 / 1.8)) : c * 16;
2873
+ });
2874
+ };
2875
+ /**
2876
+ * Convert Pro-Photo to XYZ
2877
+ *
2878
+ * @param args
2879
+ */
2880
+ var proPhotoToXYZ = function (args) {
2881
+ var prophoto_linear = proPhotoToProPhotoLinear([args[0], args[1], args[2]]);
2882
+ return d50toD65(proPhotoLinearToXyz([prophoto_linear[0], prophoto_linear[1], prophoto_linear[2]]));
2883
+ };
2884
+ /**
2885
+ * Convert XYZ to Pro-Photo
2886
+ *
2887
+ * @param args
2888
+ */
2889
+ var proPhotoFromXYZ = function (args) {
2890
+ var _a = proPhotoLinearToProPhoto(xyzToProPhotoLinear(d65toD50([args[0], args[1], args[2]]))), r = _a[0], g = _a[1], b = _a[2];
2891
+ return [r, g, b, args[3]];
2892
+ };
2893
+ /**
2894
+ * Convert Pro-Photo to XYZ and Pack
2895
+ *
2896
+ * @param args
2897
+ */
2898
+ var convertProPhoto = function (args) {
2899
+ var xyz = proPhotoToXYZ([args[0], args[1], args[2]]);
2900
+ return packXYZ([xyz[0], xyz[1], xyz[2], args[3]]);
2901
+ };
2902
+
2903
+ /**
2904
+ * REC2020 related functions
2905
+ */
2906
+ var _a = 1.09929682680944;
2907
+ var _b = 0.018053968510807;
2908
+ /**
2909
+ * Convert rec2020 to rec2020 linear
2910
+ *
2911
+ * @param rgb
2912
+ */
2913
+ var rec20202rec2020Linear = function (rgb) {
2914
+ return rgb.map(function (c) {
2915
+ return c < _b * 4.5 ? c / 4.5 : Math.pow((c + _a - 1) / _a, 1 / 0.45);
2916
+ });
2917
+ };
2918
+ /**
2919
+ * Convert rec2020 linear to rec2020
2920
+ *
2921
+ * @param rgb
2922
+ */
2923
+ var rec2020Linear2rec2020 = function (rgb) {
2924
+ return rgb.map(function (c) {
2925
+ return c >= _b ? _a * Math.pow(c, 0.45) - (_a - 1) : 4.5 * c;
2926
+ });
2927
+ };
2928
+ /**
2929
+ * Convert rec2020 linear to XYZ D65
2930
+ *
2931
+ * @param rec
2932
+ */
2933
+ var rec2020LinearToXyz = function (rec) {
2934
+ return multiplyMatrices(
2935
+ // eslint-disable-next-line prettier/prettier
2936
+ [
2937
+ 0.6369580483012914, 0.14461690358620832, 0.1688809751641721, 0.2627002120112671, 0.6779980715188708,
2938
+ 0.05930171646986196, 0.0, 0.028072693049087428, 1.060985057710791
2939
+ ], rec);
2940
+ };
2941
+ /**
2942
+ * Convert XYZ D65 to rec2020 linear
2943
+ *
2944
+ * @param xyz
2945
+ */
2946
+ var xyzToRec2020Linear = function (xyz) {
2947
+ return multiplyMatrices(
2948
+ // eslint-disable-next-line prettier/prettier
2949
+ [
2950
+ 1.716651187971268, -0.355670783776392, -0.25336628137366, -0.666684351832489, 1.616481236634939,
2951
+ 0.0157685458139111, 0.017639857445311, -0.042770613257809, 0.942103121235474
2952
+ ], xyz);
2953
+ };
2954
+ /**
2955
+ * Convert Rec2020 to XYZ
2956
+ *
2957
+ * @param args
2958
+ */
2959
+ var rec2020ToXYZ = function (args) {
2960
+ var rec2020_linear = rec20202rec2020Linear([args[0], args[1], args[2]]);
2961
+ return rec2020LinearToXyz([rec2020_linear[0], rec2020_linear[1], rec2020_linear[2]]);
2962
+ };
2963
+ /**
2964
+ * Convert XYZ to Rec2020
2965
+ *
2966
+ * @param args
2967
+ */
2968
+ var rec2020FromXYZ = function (args) {
2969
+ var _c = rec2020Linear2rec2020(xyzToRec2020Linear([args[0], args[1], args[2]])), r = _c[0], g = _c[1], b = _c[2];
2970
+ return [r, g, b, args[3]];
2971
+ };
2972
+ /**
2973
+ * Convert Rec2020 to SRGB and Pack
2974
+ *
2975
+ * @param args
2976
+ */
2977
+ var convertRec2020 = function (args) {
2978
+ var xyz = rec2020ToXYZ([args[0], args[1], args[2]]);
2979
+ return packXYZ([xyz[0], xyz[1], xyz[2], args[3]]);
2980
+ };
2981
+
2982
+ var color$1 = {
2983
+ name: 'color',
2984
+ parse: function (context, value) {
2985
+ if (value.type === 18 /* TokenType.FUNCTION */) {
2986
+ var colorFunction = SUPPORTED_COLOR_FUNCTIONS[value.name];
2987
+ if (typeof colorFunction === 'undefined') {
2988
+ throw new Error("Attempting to parse an unsupported color function \"".concat(value.name, "\""));
2989
+ }
2990
+ return colorFunction(context, value.values);
2991
+ }
2992
+ if (value.type === 5 /* TokenType.HASH_TOKEN */) {
2993
+ var _a = hash2rgb(value), r = _a[0], g = _a[1], b = _a[2], a = _a[3];
2994
+ return pack(r, g, b, a);
2995
+ }
2996
+ if (value.type === 20 /* TokenType.IDENT_TOKEN */) {
2997
+ var namedColor = COLORS[value.value.toUpperCase()];
2998
+ if (typeof namedColor !== 'undefined') {
2999
+ return namedColor;
3000
+ }
3001
+ }
3002
+ return COLORS.TRANSPARENT;
3003
+ }
3004
+ };
3005
+ var hash2rgb = function (token) {
3006
+ if (token.value.length === 3) {
3007
+ var r = token.value.substring(0, 1);
3008
+ var g = token.value.substring(1, 2);
3009
+ var b = token.value.substring(2, 3);
3010
+ return [parseInt(r + r, 16), parseInt(g + g, 16), parseInt(b + b, 16), 1];
3011
+ }
3012
+ if (token.value.length === 4) {
3013
+ var r = token.value.substring(0, 1);
3014
+ var g = token.value.substring(1, 2);
3015
+ var b = token.value.substring(2, 3);
3016
+ var a = token.value.substring(3, 4);
3017
+ return [parseInt(r + r, 16), parseInt(g + g, 16), parseInt(b + b, 16), parseInt(a + a, 16) / 255];
3018
+ }
3019
+ if (token.value.length === 6) {
3020
+ var r = token.value.substring(0, 2);
3021
+ var g = token.value.substring(2, 4);
3022
+ var b = token.value.substring(4, 6);
3023
+ return [parseInt(r, 16), parseInt(g, 16), parseInt(b, 16), 1];
3024
+ }
3025
+ if (token.value.length === 8) {
3026
+ var r = token.value.substring(0, 2);
3027
+ var g = token.value.substring(2, 4);
3028
+ var b = token.value.substring(4, 6);
3029
+ var a = token.value.substring(6, 8);
3030
+ return [parseInt(r, 16), parseInt(g, 16), parseInt(b, 16), parseInt(a, 16) / 255];
3031
+ }
3032
+ return [0, 0, 0, 1];
3033
+ };
3034
+ var rgb = function (_context, args) {
3035
+ var tokens = args.filter(nonFunctionArgSeparator);
3036
+ if (isRelativeTransform(tokens)) {
3037
+ throw new Error('Relative color not supported for rgb()');
3038
+ }
3039
+ if (tokens.length === 3) {
3040
+ var _a = tokens.map(getTokenColorValue), r = _a[0], g = _a[1], b = _a[2];
3041
+ return pack(r, g, b, 1);
3042
+ }
3043
+ if (tokens.length === 4) {
3044
+ var _b = tokens.map(getTokenColorValue), r = _b[0], g = _b[1], b = _b[2], a = _b[3];
3045
+ return pack(r, g, b, a);
3046
+ }
3047
+ return 0;
3048
+ };
3049
+ /**
3050
+ * Handle the CSS color() function
3051
+ *
3052
+ * @param context
3053
+ * @param args
3054
+ */
3055
+ var _color = function (context, args) {
3056
+ var tokens = args.filter(nonFunctionArgSeparator), token_1_value = tokens[0].type === 20 /* TokenType.IDENT_TOKEN */ ? tokens[0].value : 'unknown', is_absolute = !isRelativeTransform(tokens);
3057
+ if (is_absolute) {
3058
+ var color_space = token_1_value, colorSpaceFunction = SUPPORTED_COLOR_SPACES_ABSOLUTE[color_space];
3059
+ if (typeof colorSpaceFunction === 'undefined') {
3060
+ throw new Error("Attempting to parse an unsupported color space \"".concat(color_space, "\" for color() function"));
3061
+ }
3062
+ var c1 = isNumberToken(tokens[1]) ? tokens[1].number : 0, c2 = isNumberToken(tokens[2]) ? tokens[2].number : 0, c3 = isNumberToken(tokens[3]) ? tokens[3].number : 0, a = tokens.length > 4 &&
3063
+ tokens[4].type === 6 /* TokenType.DELIM_TOKEN */ &&
3064
+ tokens[4].value === '/' &&
3065
+ isNumberToken(tokens[5])
3066
+ ? tokens[5].number
3067
+ : 1;
3068
+ return colorSpaceFunction([c1, c2, c3, a]);
3069
+ }
3070
+ else {
3071
+ var extractComponent = function (color, token) {
3072
+ if (isNumberToken(token)) {
3073
+ return token.number;
3074
+ }
3075
+ var posFromVal = function (value) {
3076
+ return value === 'r' || value === 'x' ? 0 : value === 'g' || value === 'y' ? 1 : 2;
3077
+ };
3078
+ if (isIdentToken(token)) {
3079
+ var position = posFromVal(token.value);
3080
+ return color[position];
3081
+ }
3082
+ var parseCalc = function (args) {
3083
+ var parts = args.filter(nonFunctionArgSeparator);
3084
+ var expression = '(';
3085
+ for (var _i = 0, parts_1 = parts; _i < parts_1.length; _i++) {
3086
+ var part = parts_1[_i];
3087
+ expression +=
3088
+ part.type === 18 /* TokenType.FUNCTION */ && part.name === 'calc'
3089
+ ? parseCalc(part.values)
3090
+ : isNumberToken(part)
3091
+ ? part.number
3092
+ : part.type === 6 /* TokenType.DELIM_TOKEN */ || isIdentToken(part)
3093
+ ? part.value
3094
+ : '';
3095
+ }
3096
+ expression += ')';
3097
+ return expression;
3098
+ };
3099
+ if (token.type === 18 /* TokenType.FUNCTION */) {
3100
+ var args_1 = token.values.filter(nonFunctionArgSeparator);
3101
+ if (token.name === 'calc') {
3102
+ var expression = parseCalc(args_1)
3103
+ .replace(/r|x/, color[0].toString())
3104
+ .replace(/g|y/, color[1].toString())
3105
+ .replace(/b|z/, color[2].toString());
3106
+ return new Function('return ' + expression)();
3107
+ }
3108
+ }
3109
+ return null;
3110
+ };
3111
+ var from_colorspace = tokens[1].type === 18 /* TokenType.FUNCTION */
3112
+ ? tokens[1].name
3113
+ : isIdentToken(tokens[1]) || tokens[1].type === 5 /* TokenType.HASH_TOKEN */
3114
+ ? 'rgb'
3115
+ : 'unknown', to_colorspace = isIdentToken(tokens[2]) ? tokens[2].value : 'unknown';
3116
+ var from = tokens[1].type === 18 /* TokenType.FUNCTION */ ? tokens[1].values : isIdentToken(tokens[1]) ? [tokens[1]] : [];
3117
+ if (isIdentToken(tokens[1])) {
3118
+ var named_color = COLORS[tokens[1].value.toUpperCase()];
3119
+ if (typeof named_color === 'undefined') {
3120
+ throw new Error("Attempting to use unknown color in relative color 'from'");
3121
+ }
3122
+ else {
3123
+ var _c = parseColor(context, tokens[1].value), alpha = 0xff & _c, blue = 0xff & (_c >> 8), green = 0xff & (_c >> 16), red = 0xff & (_c >> 24);
3124
+ from = [
3125
+ { type: 17 /* TokenType.NUMBER_TOKEN */, number: red, flags: 1 },
3126
+ { type: 17 /* TokenType.NUMBER_TOKEN */, number: green, flags: 1 },
3127
+ { type: 17 /* TokenType.NUMBER_TOKEN */, number: blue, flags: 1 },
3128
+ { type: 17 /* TokenType.NUMBER_TOKEN */, number: alpha > 1 ? alpha / 255 : alpha, flags: 1 }
3129
+ ];
3130
+ }
3131
+ }
3132
+ else if (tokens[1].type === 5 /* TokenType.HASH_TOKEN */) {
3133
+ var _a = hash2rgb(tokens[1]), red = _a[0], green = _a[1], blue = _a[2], alpha = _a[3];
3134
+ from = [
3135
+ { type: 17 /* TokenType.NUMBER_TOKEN */, number: red, flags: 1 },
3136
+ { type: 17 /* TokenType.NUMBER_TOKEN */, number: green, flags: 1 },
3137
+ { type: 17 /* TokenType.NUMBER_TOKEN */, number: blue, flags: 1 },
3138
+ { type: 17 /* TokenType.NUMBER_TOKEN */, number: alpha > 1 ? alpha / 255 : alpha, flags: 1 }
3139
+ ];
3140
+ }
3141
+ if (from.length === 0) {
3142
+ throw new Error("Attempting to use unknown color in relative color 'from'");
3143
+ }
3144
+ if (to_colorspace === 'unknown') {
3145
+ throw new Error("Attempting to use unknown colorspace in relative color 'to'");
3146
+ }
3147
+ var fromColorToXyz = SUPPORTED_COLOR_SPACES_TO_XYZ[from_colorspace], toColorFromXyz = SUPPORTED_COLOR_SPACES_FROM_XYZ[to_colorspace], toColorPack = SUPPORTED_COLOR_SPACES_ABSOLUTE[to_colorspace];
3148
+ if (typeof fromColorToXyz === 'undefined') {
3149
+ throw new Error("Attempting to parse an unsupported color space \"".concat(from_colorspace, "\" for color() function"));
3150
+ }
3151
+ if (typeof toColorFromXyz === 'undefined') {
3152
+ throw new Error("Attempting to parse an unsupported color space \"".concat(to_colorspace, "\" for color() function"));
3153
+ }
3154
+ var from_color = fromColorToXyz(context, from), from_final_colorspace = toColorFromXyz(from_color), c1 = extractComponent(from_final_colorspace, tokens[3]), c2 = extractComponent(from_final_colorspace, tokens[4]), c3 = extractComponent(from_final_colorspace, tokens[5]), a = tokens.length > 6 &&
3155
+ tokens[6].type === 6 /* TokenType.DELIM_TOKEN */ &&
3156
+ tokens[6].value === '/' &&
3157
+ isNumberToken(tokens[7])
3158
+ ? tokens[7].number
3159
+ : 1;
3160
+ if (c1 === null || c2 === null || c3 === null) {
3161
+ throw new Error("Invalid relative color in color() function");
3162
+ }
3163
+ return toColorPack([c1, c2, c3, a]);
3164
+ }
3165
+ };
3166
+ var SUPPORTED_COLOR_SPACES_ABSOLUTE = {
3167
+ srgb: packSrgb,
3168
+ 'srgb-linear': packSrgbLinear,
3169
+ 'display-p3': convertP3,
3170
+ 'a98-rgb': convertA98rgb,
3171
+ 'prophoto-rgb': convertProPhoto,
3172
+ xyz: convertXyz,
3173
+ 'xyz-d50': convertXyz50,
3174
+ 'xyz-d65': convertXyz,
3175
+ rec2020: convertRec2020
3176
+ };
3177
+ var SUPPORTED_COLOR_SPACES_TO_XYZ = {
3178
+ rgb: rgbToXyz,
3179
+ hsl: hslToXyz,
3180
+ lab: labToXyz,
3181
+ lch: lchToXyz,
3182
+ oklab: oklabToXyz,
3183
+ oklch: oklchToXyz
3184
+ };
3185
+ var SUPPORTED_COLOR_SPACES_FROM_XYZ = {
3186
+ srgb: srgbFromXYZ,
3187
+ 'srgb-linear': srgbLinearFromXYZ,
3188
+ 'display-p3': p3FromXYZ,
3189
+ 'a98-rgb': a98FromXYZ,
3190
+ 'prophoto-rgb': proPhotoFromXYZ,
3191
+ xyz: xyzFromXYZ,
3192
+ 'xyz-d50': xyz50FromXYZ,
3193
+ 'xyz-d65': xyzFromXYZ,
3194
+ rec2020: rec2020FromXYZ
2372
3195
  };
2373
3196
  var SUPPORTED_COLOR_FUNCTIONS = {
2374
- hsl: hsl,
2375
- hsla: hsl,
3197
+ hsl: packHSL,
3198
+ hsla: packHSL,
2376
3199
  rgb: rgb,
2377
- rgba: rgb
3200
+ rgba: rgb,
3201
+ lch: packLch,
3202
+ oklch: packOkLch,
3203
+ oklab: packOkLab,
3204
+ lab: packLab,
3205
+ color: _color
2378
3206
  };
2379
3207
  var parseColor = function (context, value) {
2380
3208
  return color$1.parse(context, Parser.create(value).parseComponentValue());
@@ -2535,18 +3363,18 @@ var backgroundClip = {
2535
3363
  name: 'background-clip',
2536
3364
  initialValue: 'border-box',
2537
3365
  prefix: false,
2538
- type: 1 /* LIST */,
3366
+ type: 1 /* PropertyDescriptorParsingType.LIST */,
2539
3367
  parse: function (_context, tokens) {
2540
3368
  return tokens.map(function (token) {
2541
3369
  if (isIdentToken(token)) {
2542
3370
  switch (token.value) {
2543
3371
  case 'padding-box':
2544
- return 1 /* PADDING_BOX */;
3372
+ return 1 /* BACKGROUND_CLIP.PADDING_BOX */;
2545
3373
  case 'content-box':
2546
- return 2 /* CONTENT_BOX */;
3374
+ return 2 /* BACKGROUND_CLIP.CONTENT_BOX */;
2547
3375
  }
2548
3376
  }
2549
- return 0 /* BORDER_BOX */;
3377
+ return 0 /* BACKGROUND_CLIP.BORDER_BOX */;
2550
3378
  });
2551
3379
  }
2552
3380
  };
@@ -2555,7 +3383,7 @@ var backgroundColor = {
2555
3383
  name: "background-color",
2556
3384
  initialValue: 'transparent',
2557
3385
  prefix: false,
2558
- type: 3 /* TYPE_VALUE */,
3386
+ type: 3 /* PropertyDescriptorParsingType.TYPE_VALUE */,
2559
3387
  format: 'color'
2560
3388
  };
2561
3389
 
@@ -2658,24 +3486,24 @@ var calculateRadius = function (gradient, x, y, width, height) {
2658
3486
  var rx = 0;
2659
3487
  var ry = 0;
2660
3488
  switch (gradient.size) {
2661
- case 0 /* CLOSEST_SIDE */:
3489
+ case 0 /* CSSRadialExtent.CLOSEST_SIDE */:
2662
3490
  // The ending shape is sized so that that it exactly meets the side of the gradient box closest to the gradient’s center.
2663
3491
  // If the shape is an ellipse, it exactly meets the closest side in each dimension.
2664
- if (gradient.shape === 0 /* CIRCLE */) {
3492
+ if (gradient.shape === 0 /* CSSRadialShape.CIRCLE */) {
2665
3493
  rx = ry = Math.min(Math.abs(x), Math.abs(x - width), Math.abs(y), Math.abs(y - height));
2666
3494
  }
2667
- else if (gradient.shape === 1 /* ELLIPSE */) {
3495
+ else if (gradient.shape === 1 /* CSSRadialShape.ELLIPSE */) {
2668
3496
  rx = Math.min(Math.abs(x), Math.abs(x - width));
2669
3497
  ry = Math.min(Math.abs(y), Math.abs(y - height));
2670
3498
  }
2671
3499
  break;
2672
- case 2 /* CLOSEST_CORNER */:
3500
+ case 2 /* CSSRadialExtent.CLOSEST_CORNER */:
2673
3501
  // The ending shape is sized so that that it passes through the corner of the gradient box closest to the gradient’s center.
2674
3502
  // If the shape is an ellipse, the ending shape is given the same aspect-ratio it would have if closest-side were specified.
2675
- if (gradient.shape === 0 /* CIRCLE */) {
3503
+ if (gradient.shape === 0 /* CSSRadialShape.CIRCLE */) {
2676
3504
  rx = ry = Math.min(distance(x, y), distance(x, y - height), distance(x - width, y), distance(x - width, y - height));
2677
3505
  }
2678
- else if (gradient.shape === 1 /* ELLIPSE */) {
3506
+ else if (gradient.shape === 1 /* CSSRadialShape.ELLIPSE */) {
2679
3507
  // Compute the ratio ry/rx (which is to be the same as for "closest-side")
2680
3508
  var c = Math.min(Math.abs(y), Math.abs(y - height)) / Math.min(Math.abs(x), Math.abs(x - width));
2681
3509
  var _a = findCorner(width, height, x, y, true), cx = _a[0], cy = _a[1];
@@ -2683,23 +3511,23 @@ var calculateRadius = function (gradient, x, y, width, height) {
2683
3511
  ry = c * rx;
2684
3512
  }
2685
3513
  break;
2686
- case 1 /* FARTHEST_SIDE */:
3514
+ case 1 /* CSSRadialExtent.FARTHEST_SIDE */:
2687
3515
  // Same as closest-side, except the ending shape is sized based on the farthest side(s)
2688
- if (gradient.shape === 0 /* CIRCLE */) {
3516
+ if (gradient.shape === 0 /* CSSRadialShape.CIRCLE */) {
2689
3517
  rx = ry = Math.max(Math.abs(x), Math.abs(x - width), Math.abs(y), Math.abs(y - height));
2690
3518
  }
2691
- else if (gradient.shape === 1 /* ELLIPSE */) {
3519
+ else if (gradient.shape === 1 /* CSSRadialShape.ELLIPSE */) {
2692
3520
  rx = Math.max(Math.abs(x), Math.abs(x - width));
2693
3521
  ry = Math.max(Math.abs(y), Math.abs(y - height));
2694
3522
  }
2695
3523
  break;
2696
- case 3 /* FARTHEST_CORNER */:
3524
+ case 3 /* CSSRadialExtent.FARTHEST_CORNER */:
2697
3525
  // Same as closest-corner, except the ending shape is sized based on the farthest corner.
2698
3526
  // If the shape is an ellipse, the ending shape is given the same aspect ratio it would have if farthest-side were specified.
2699
- if (gradient.shape === 0 /* CIRCLE */) {
3527
+ if (gradient.shape === 0 /* CSSRadialShape.CIRCLE */) {
2700
3528
  rx = ry = Math.max(distance(x, y), distance(x, y - height), distance(x - width, y), distance(x - width, y - height));
2701
3529
  }
2702
- else if (gradient.shape === 1 /* ELLIPSE */) {
3530
+ else if (gradient.shape === 1 /* CSSRadialShape.ELLIPSE */) {
2703
3531
  // Compute the ratio ry/rx (which is to be the same as for "farthest-side")
2704
3532
  var c = Math.max(Math.abs(y), Math.abs(y - height)) / Math.max(Math.abs(x), Math.abs(x - width));
2705
3533
  var _b = findCorner(width, height, x, y, false), cx = _b[0], cy = _b[1];
@@ -2721,7 +3549,7 @@ var linearGradient = function (context, tokens) {
2721
3549
  parseFunctionArgs(tokens).forEach(function (arg, i) {
2722
3550
  if (i === 0) {
2723
3551
  var firstToken = arg[0];
2724
- if (firstToken.type === 20 /* IDENT_TOKEN */ && firstToken.value === 'to') {
3552
+ if (firstToken.type === 20 /* TokenType.IDENT_TOKEN */ && firstToken.value === 'to') {
2725
3553
  angle$1 = parseNamedSide(arg);
2726
3554
  return;
2727
3555
  }
@@ -2733,7 +3561,7 @@ var linearGradient = function (context, tokens) {
2733
3561
  var colorStop = parseColorStop(context, arg);
2734
3562
  stops.push(colorStop);
2735
3563
  });
2736
- return { angle: angle$1, stops: stops, type: 1 /* LINEAR_GRADIENT */ };
3564
+ return { angle: angle$1, stops: stops, type: 1 /* CSSImageType.LINEAR_GRADIENT */ };
2737
3565
  };
2738
3566
 
2739
3567
  var prefixLinearGradient = function (context, tokens) {
@@ -2742,7 +3570,7 @@ var prefixLinearGradient = function (context, tokens) {
2742
3570
  parseFunctionArgs(tokens).forEach(function (arg, i) {
2743
3571
  if (i === 0) {
2744
3572
  var firstToken = arg[0];
2745
- if (firstToken.type === 20 /* IDENT_TOKEN */ &&
3573
+ if (firstToken.type === 20 /* TokenType.IDENT_TOKEN */ &&
2746
3574
  ['top', 'left', 'right', 'bottom'].indexOf(firstToken.value) !== -1) {
2747
3575
  angle$1 = parseNamedSide(arg);
2748
3576
  return;
@@ -2758,30 +3586,30 @@ var prefixLinearGradient = function (context, tokens) {
2758
3586
  return {
2759
3587
  angle: angle$1,
2760
3588
  stops: stops,
2761
- type: 1 /* LINEAR_GRADIENT */
3589
+ type: 1 /* CSSImageType.LINEAR_GRADIENT */
2762
3590
  };
2763
3591
  };
2764
3592
 
2765
3593
  var webkitGradient = function (context, tokens) {
2766
3594
  var angle = deg(180);
2767
3595
  var stops = [];
2768
- var type = 1 /* LINEAR_GRADIENT */;
2769
- var shape = 0 /* CIRCLE */;
2770
- var size = 3 /* FARTHEST_CORNER */;
3596
+ var type = 1 /* CSSImageType.LINEAR_GRADIENT */;
3597
+ var shape = 0 /* CSSRadialShape.CIRCLE */;
3598
+ var size = 3 /* CSSRadialExtent.FARTHEST_CORNER */;
2771
3599
  var position = [];
2772
3600
  parseFunctionArgs(tokens).forEach(function (arg, i) {
2773
3601
  var firstToken = arg[0];
2774
3602
  if (i === 0) {
2775
3603
  if (isIdentToken(firstToken) && firstToken.value === 'linear') {
2776
- type = 1 /* LINEAR_GRADIENT */;
3604
+ type = 1 /* CSSImageType.LINEAR_GRADIENT */;
2777
3605
  return;
2778
3606
  }
2779
3607
  else if (isIdentToken(firstToken) && firstToken.value === 'radial') {
2780
- type = 2 /* RADIAL_GRADIENT */;
3608
+ type = 2 /* CSSImageType.RADIAL_GRADIENT */;
2781
3609
  return;
2782
3610
  }
2783
3611
  }
2784
- if (firstToken.type === 18 /* FUNCTION */) {
3612
+ if (firstToken.type === 18 /* TokenType.FUNCTION */) {
2785
3613
  if (firstToken.name === 'from') {
2786
3614
  var color = color$1.parse(context, firstToken.values[0]);
2787
3615
  stops.push({ stop: ZERO_LENGTH, color: color });
@@ -2797,7 +3625,7 @@ var webkitGradient = function (context, tokens) {
2797
3625
  var stop_1 = values[0];
2798
3626
  if (isNumberToken(stop_1)) {
2799
3627
  stops.push({
2800
- stop: { type: 16 /* PERCENTAGE_TOKEN */, number: stop_1.number * 100, flags: stop_1.flags },
3628
+ stop: { type: 16 /* TokenType.PERCENTAGE_TOKEN */, number: stop_1.number * 100, flags: stop_1.flags },
2801
3629
  color: color
2802
3630
  });
2803
3631
  }
@@ -2805,7 +3633,7 @@ var webkitGradient = function (context, tokens) {
2805
3633
  }
2806
3634
  }
2807
3635
  });
2808
- return type === 1 /* LINEAR_GRADIENT */
3636
+ return type === 1 /* CSSImageType.LINEAR_GRADIENT */
2809
3637
  ? {
2810
3638
  angle: (angle + deg(180)) % deg(360),
2811
3639
  stops: stops,
@@ -2823,8 +3651,8 @@ var ELLIPSE = 'ellipse';
2823
3651
  var COVER = 'cover';
2824
3652
  var CONTAIN = 'contain';
2825
3653
  var radialGradient = function (context, tokens) {
2826
- var shape = 0 /* CIRCLE */;
2827
- var size = 3 /* FARTHEST_CORNER */;
3654
+ var shape = 0 /* CSSRadialShape.CIRCLE */;
3655
+ var size = 3 /* CSSRadialExtent.FARTHEST_CORNER */;
2828
3656
  var stops = [];
2829
3657
  var position = [];
2830
3658
  parseFunctionArgs(tokens).forEach(function (arg, i) {
@@ -2855,27 +3683,27 @@ var radialGradient = function (context, tokens) {
2855
3683
  else if (isIdentToken(token)) {
2856
3684
  switch (token.value) {
2857
3685
  case CIRCLE:
2858
- shape = 0 /* CIRCLE */;
3686
+ shape = 0 /* CSSRadialShape.CIRCLE */;
2859
3687
  return false;
2860
3688
  case ELLIPSE:
2861
- shape = 1 /* ELLIPSE */;
3689
+ shape = 1 /* CSSRadialShape.ELLIPSE */;
2862
3690
  return false;
2863
3691
  case 'at':
2864
3692
  isAtPosition_1 = true;
2865
3693
  return false;
2866
3694
  case CLOSEST_SIDE:
2867
- size = 0 /* CLOSEST_SIDE */;
3695
+ size = 0 /* CSSRadialExtent.CLOSEST_SIDE */;
2868
3696
  return false;
2869
3697
  case COVER:
2870
3698
  case FARTHEST_SIDE:
2871
- size = 1 /* FARTHEST_SIDE */;
3699
+ size = 1 /* CSSRadialExtent.FARTHEST_SIDE */;
2872
3700
  return false;
2873
3701
  case CONTAIN:
2874
3702
  case CLOSEST_CORNER:
2875
- size = 2 /* CLOSEST_CORNER */;
3703
+ size = 2 /* CSSRadialExtent.CLOSEST_CORNER */;
2876
3704
  return false;
2877
3705
  case FARTHEST_CORNER:
2878
- size = 3 /* FARTHEST_CORNER */;
3706
+ size = 3 /* CSSRadialExtent.FARTHEST_CORNER */;
2879
3707
  return false;
2880
3708
  }
2881
3709
  }
@@ -2894,12 +3722,12 @@ var radialGradient = function (context, tokens) {
2894
3722
  stops.push(colorStop);
2895
3723
  }
2896
3724
  });
2897
- return { size: size, shape: shape, stops: stops, position: position, type: 2 /* RADIAL_GRADIENT */ };
3725
+ return { size: size, shape: shape, stops: stops, position: position, type: 2 /* CSSImageType.RADIAL_GRADIENT */ };
2898
3726
  };
2899
3727
 
2900
3728
  var prefixRadialGradient = function (context, tokens) {
2901
- var shape = 0 /* CIRCLE */;
2902
- var size = 3 /* FARTHEST_CORNER */;
3729
+ var shape = 0 /* CSSRadialShape.CIRCLE */;
3730
+ var size = 3 /* CSSRadialExtent.FARTHEST_CORNER */;
2903
3731
  var stops = [];
2904
3732
  var position = [];
2905
3733
  parseFunctionArgs(tokens).forEach(function (arg, i) {
@@ -2933,24 +3761,24 @@ var prefixRadialGradient = function (context, tokens) {
2933
3761
  if (isIdentToken(token)) {
2934
3762
  switch (token.value) {
2935
3763
  case CIRCLE:
2936
- shape = 0 /* CIRCLE */;
3764
+ shape = 0 /* CSSRadialShape.CIRCLE */;
2937
3765
  return false;
2938
3766
  case ELLIPSE:
2939
- shape = 1 /* ELLIPSE */;
3767
+ shape = 1 /* CSSRadialShape.ELLIPSE */;
2940
3768
  return false;
2941
3769
  case CONTAIN:
2942
3770
  case CLOSEST_SIDE:
2943
- size = 0 /* CLOSEST_SIDE */;
3771
+ size = 0 /* CSSRadialExtent.CLOSEST_SIDE */;
2944
3772
  return false;
2945
3773
  case FARTHEST_SIDE:
2946
- size = 1 /* FARTHEST_SIDE */;
3774
+ size = 1 /* CSSRadialExtent.FARTHEST_SIDE */;
2947
3775
  return false;
2948
3776
  case CLOSEST_CORNER:
2949
- size = 2 /* CLOSEST_CORNER */;
3777
+ size = 2 /* CSSRadialExtent.CLOSEST_CORNER */;
2950
3778
  return false;
2951
3779
  case COVER:
2952
3780
  case FARTHEST_CORNER:
2953
- size = 3 /* FARTHEST_CORNER */;
3781
+ size = 3 /* CSSRadialExtent.FARTHEST_CORNER */;
2954
3782
  return false;
2955
3783
  }
2956
3784
  }
@@ -2969,36 +3797,36 @@ var prefixRadialGradient = function (context, tokens) {
2969
3797
  stops.push(colorStop);
2970
3798
  }
2971
3799
  });
2972
- return { size: size, shape: shape, stops: stops, position: position, type: 2 /* RADIAL_GRADIENT */ };
3800
+ return { size: size, shape: shape, stops: stops, position: position, type: 2 /* CSSImageType.RADIAL_GRADIENT */ };
2973
3801
  };
2974
3802
 
2975
3803
  var isLinearGradient = function (background) {
2976
- return background.type === 1 /* LINEAR_GRADIENT */;
3804
+ return background.type === 1 /* CSSImageType.LINEAR_GRADIENT */;
2977
3805
  };
2978
3806
  var isRadialGradient = function (background) {
2979
- return background.type === 2 /* RADIAL_GRADIENT */;
3807
+ return background.type === 2 /* CSSImageType.RADIAL_GRADIENT */;
2980
3808
  };
2981
3809
  var image = {
2982
3810
  name: 'image',
2983
3811
  parse: function (context, value) {
2984
- if (value.type === 22 /* URL_TOKEN */) {
2985
- var image_1 = { url: value.value, type: 0 /* URL */ };
3812
+ if (value.type === 22 /* TokenType.URL_TOKEN */) {
3813
+ var image_1 = { url: value.value, type: 0 /* CSSImageType.URL */ };
2986
3814
  context.cache.addImage(value.value);
2987
3815
  return image_1;
2988
3816
  }
2989
- if (value.type === 18 /* FUNCTION */) {
3817
+ if (value.type === 18 /* TokenType.FUNCTION */) {
2990
3818
  var imageFunction = SUPPORTED_IMAGE_FUNCTIONS[value.name];
2991
3819
  if (typeof imageFunction === 'undefined') {
2992
- throw new Error("Attempting to parse an unsupported image function \"" + value.name + "\"");
3820
+ throw new Error("Attempting to parse an unsupported image function \"".concat(value.name, "\""));
2993
3821
  }
2994
3822
  return imageFunction(context, value.values);
2995
3823
  }
2996
- throw new Error("Unsupported image type " + value.type);
3824
+ throw new Error("Unsupported image type ".concat(value.type));
2997
3825
  }
2998
3826
  };
2999
3827
  function isSupportedImage(value) {
3000
- return (!(value.type === 20 /* IDENT_TOKEN */ && value.value === 'none') &&
3001
- (value.type !== 18 /* FUNCTION */ || !!SUPPORTED_IMAGE_FUNCTIONS[value.name]));
3828
+ return (!(value.type === 20 /* TokenType.IDENT_TOKEN */ && value.value === 'none') &&
3829
+ (value.type !== 18 /* TokenType.FUNCTION */ || !!SUPPORTED_IMAGE_FUNCTIONS[value.name]));
3002
3830
  }
3003
3831
  var SUPPORTED_IMAGE_FUNCTIONS = {
3004
3832
  'linear-gradient': linearGradient,
@@ -3017,14 +3845,14 @@ var SUPPORTED_IMAGE_FUNCTIONS = {
3017
3845
  var backgroundImage = {
3018
3846
  name: 'background-image',
3019
3847
  initialValue: 'none',
3020
- type: 1 /* LIST */,
3848
+ type: 1 /* PropertyDescriptorParsingType.LIST */,
3021
3849
  prefix: false,
3022
3850
  parse: function (context, tokens) {
3023
3851
  if (tokens.length === 0) {
3024
3852
  return [];
3025
3853
  }
3026
3854
  var first = tokens[0];
3027
- if (first.type === 20 /* IDENT_TOKEN */ && first.value === 'none') {
3855
+ if (first.type === 20 /* TokenType.IDENT_TOKEN */ && first.value === 'none') {
3028
3856
  return [];
3029
3857
  }
3030
3858
  return tokens
@@ -3037,18 +3865,18 @@ var backgroundOrigin = {
3037
3865
  name: 'background-origin',
3038
3866
  initialValue: 'border-box',
3039
3867
  prefix: false,
3040
- type: 1 /* LIST */,
3868
+ type: 1 /* PropertyDescriptorParsingType.LIST */,
3041
3869
  parse: function (_context, tokens) {
3042
3870
  return tokens.map(function (token) {
3043
3871
  if (isIdentToken(token)) {
3044
3872
  switch (token.value) {
3045
3873
  case 'padding-box':
3046
- return 1 /* PADDING_BOX */;
3874
+ return 1 /* BACKGROUND_ORIGIN.PADDING_BOX */;
3047
3875
  case 'content-box':
3048
- return 2 /* CONTENT_BOX */;
3876
+ return 2 /* BACKGROUND_ORIGIN.CONTENT_BOX */;
3049
3877
  }
3050
3878
  }
3051
- return 0 /* BORDER_BOX */;
3879
+ return 0 /* BACKGROUND_ORIGIN.BORDER_BOX */;
3052
3880
  });
3053
3881
  }
3054
3882
  };
@@ -3056,7 +3884,7 @@ var backgroundOrigin = {
3056
3884
  var backgroundPosition = {
3057
3885
  name: 'background-position',
3058
3886
  initialValue: '0% 0%',
3059
- type: 1 /* LIST */,
3887
+ type: 1 /* PropertyDescriptorParsingType.LIST */,
3060
3888
  prefix: false,
3061
3889
  parse: function (_context, tokens) {
3062
3890
  return parseFunctionArgs(tokens)
@@ -3069,7 +3897,7 @@ var backgroundRepeat = {
3069
3897
  name: 'background-repeat',
3070
3898
  initialValue: 'repeat',
3071
3899
  prefix: false,
3072
- type: 1 /* LIST */,
3900
+ type: 1 /* PropertyDescriptorParsingType.LIST */,
3073
3901
  parse: function (_context, tokens) {
3074
3902
  return parseFunctionArgs(tokens)
3075
3903
  .map(function (values) {
@@ -3084,16 +3912,16 @@ var backgroundRepeat = {
3084
3912
  var parseBackgroundRepeat = function (value) {
3085
3913
  switch (value) {
3086
3914
  case 'no-repeat':
3087
- return 1 /* NO_REPEAT */;
3915
+ return 1 /* BACKGROUND_REPEAT.NO_REPEAT */;
3088
3916
  case 'repeat-x':
3089
3917
  case 'repeat no-repeat':
3090
- return 2 /* REPEAT_X */;
3918
+ return 2 /* BACKGROUND_REPEAT.REPEAT_X */;
3091
3919
  case 'repeat-y':
3092
3920
  case 'no-repeat repeat':
3093
- return 3 /* REPEAT_Y */;
3921
+ return 3 /* BACKGROUND_REPEAT.REPEAT_Y */;
3094
3922
  case 'repeat':
3095
3923
  default:
3096
- return 0 /* REPEAT */;
3924
+ return 0 /* BACKGROUND_REPEAT.REPEAT */;
3097
3925
  }
3098
3926
  };
3099
3927
 
@@ -3107,7 +3935,7 @@ var backgroundSize = {
3107
3935
  name: 'background-size',
3108
3936
  initialValue: '0',
3109
3937
  prefix: false,
3110
- type: 1 /* LIST */,
3938
+ type: 1 /* PropertyDescriptorParsingType.LIST */,
3111
3939
  parse: function (_context, tokens) {
3112
3940
  return parseFunctionArgs(tokens).map(function (values) { return values.filter(isBackgroundSizeInfoToken); });
3113
3941
  }
@@ -3117,10 +3945,10 @@ var isBackgroundSizeInfoToken = function (value) {
3117
3945
  };
3118
3946
 
3119
3947
  var borderColorForSide = function (side) { return ({
3120
- name: "border-" + side + "-color",
3948
+ name: "border-".concat(side, "-color"),
3121
3949
  initialValue: 'transparent',
3122
3950
  prefix: false,
3123
- type: 3 /* TYPE_VALUE */,
3951
+ type: 3 /* PropertyDescriptorParsingType.TYPE_VALUE */,
3124
3952
  format: 'color'
3125
3953
  }); };
3126
3954
  var borderTopColor = borderColorForSide('top');
@@ -3129,10 +3957,10 @@ var borderBottomColor = borderColorForSide('bottom');
3129
3957
  var borderLeftColor = borderColorForSide('left');
3130
3958
 
3131
3959
  var borderRadiusForSide = function (side) { return ({
3132
- name: "border-radius-" + side,
3960
+ name: "border-radius-".concat(side),
3133
3961
  initialValue: '0 0',
3134
3962
  prefix: false,
3135
- type: 1 /* LIST */,
3963
+ type: 1 /* PropertyDescriptorParsingType.LIST */,
3136
3964
  parse: function (_context, tokens) {
3137
3965
  return parseLengthPercentageTuple(tokens.filter(isLengthPercentage));
3138
3966
  }
@@ -3143,22 +3971,22 @@ var borderBottomRightRadius = borderRadiusForSide('bottom-right');
3143
3971
  var borderBottomLeftRadius = borderRadiusForSide('bottom-left');
3144
3972
 
3145
3973
  var borderStyleForSide = function (side) { return ({
3146
- name: "border-" + side + "-style",
3974
+ name: "border-".concat(side, "-style"),
3147
3975
  initialValue: 'solid',
3148
3976
  prefix: false,
3149
- type: 2 /* IDENT_VALUE */,
3977
+ type: 2 /* PropertyDescriptorParsingType.IDENT_VALUE */,
3150
3978
  parse: function (_context, style) {
3151
3979
  switch (style) {
3152
3980
  case 'none':
3153
- return 0 /* NONE */;
3981
+ return 0 /* BORDER_STYLE.NONE */;
3154
3982
  case 'dashed':
3155
- return 2 /* DASHED */;
3983
+ return 2 /* BORDER_STYLE.DASHED */;
3156
3984
  case 'dotted':
3157
- return 3 /* DOTTED */;
3985
+ return 3 /* BORDER_STYLE.DOTTED */;
3158
3986
  case 'double':
3159
- return 4 /* DOUBLE */;
3987
+ return 4 /* BORDER_STYLE.DOUBLE */;
3160
3988
  }
3161
- return 1 /* SOLID */;
3989
+ return 1 /* BORDER_STYLE.SOLID */;
3162
3990
  }
3163
3991
  }); };
3164
3992
  var borderTopStyle = borderStyleForSide('top');
@@ -3167,9 +3995,9 @@ var borderBottomStyle = borderStyleForSide('bottom');
3167
3995
  var borderLeftStyle = borderStyleForSide('left');
3168
3996
 
3169
3997
  var borderWidthForSide = function (side) { return ({
3170
- name: "border-" + side + "-width",
3998
+ name: "border-".concat(side, "-width"),
3171
3999
  initialValue: '0',
3172
- type: 0 /* VALUE */,
4000
+ type: 0 /* PropertyDescriptorParsingType.VALUE */,
3173
4001
  prefix: false,
3174
4002
  parse: function (_context, token) {
3175
4003
  if (isDimensionToken(token)) {
@@ -3187,7 +4015,7 @@ var color = {
3187
4015
  name: "color",
3188
4016
  initialValue: 'transparent',
3189
4017
  prefix: false,
3190
- type: 3 /* TYPE_VALUE */,
4018
+ type: 3 /* PropertyDescriptorParsingType.TYPE_VALUE */,
3191
4019
  format: 'color'
3192
4020
  };
3193
4021
 
@@ -3195,14 +4023,14 @@ var direction = {
3195
4023
  name: 'direction',
3196
4024
  initialValue: 'ltr',
3197
4025
  prefix: false,
3198
- type: 2 /* IDENT_VALUE */,
4026
+ type: 2 /* PropertyDescriptorParsingType.IDENT_VALUE */,
3199
4027
  parse: function (_context, direction) {
3200
4028
  switch (direction) {
3201
4029
  case 'rtl':
3202
- return 1 /* RTL */;
4030
+ return 1 /* DIRECTION.RTL */;
3203
4031
  case 'ltr':
3204
4032
  default:
3205
- return 0 /* LTR */;
4033
+ return 0 /* DIRECTION.LTR */;
3206
4034
  }
3207
4035
  }
3208
4036
  };
@@ -3211,97 +4039,97 @@ var display = {
3211
4039
  name: 'display',
3212
4040
  initialValue: 'inline-block',
3213
4041
  prefix: false,
3214
- type: 1 /* LIST */,
4042
+ type: 1 /* PropertyDescriptorParsingType.LIST */,
3215
4043
  parse: function (_context, tokens) {
3216
4044
  return tokens.filter(isIdentToken).reduce(function (bit, token) {
3217
- return bit | parseDisplayValue(token.value);
3218
- }, 0 /* NONE */);
4045
+ return bit | parseDisplayValue$1(token.value);
4046
+ }, 0 /* DISPLAY.NONE */);
3219
4047
  }
3220
4048
  };
3221
- var parseDisplayValue = function (display) {
4049
+ var parseDisplayValue$1 = function (display) {
3222
4050
  switch (display) {
3223
4051
  case 'block':
3224
4052
  case '-webkit-box':
3225
- return 2 /* BLOCK */;
4053
+ return 2 /* DISPLAY.BLOCK */;
3226
4054
  case 'inline':
3227
- return 4 /* INLINE */;
4055
+ return 4 /* DISPLAY.INLINE */;
3228
4056
  case 'run-in':
3229
- return 8 /* RUN_IN */;
4057
+ return 8 /* DISPLAY.RUN_IN */;
3230
4058
  case 'flow':
3231
- return 16 /* FLOW */;
4059
+ return 16 /* DISPLAY.FLOW */;
3232
4060
  case 'flow-root':
3233
- return 32 /* FLOW_ROOT */;
4061
+ return 32 /* DISPLAY.FLOW_ROOT */;
3234
4062
  case 'table':
3235
- return 64 /* TABLE */;
4063
+ return 64 /* DISPLAY.TABLE */;
3236
4064
  case 'flex':
3237
4065
  case '-webkit-flex':
3238
- return 128 /* FLEX */;
4066
+ return 128 /* DISPLAY.FLEX */;
3239
4067
  case 'grid':
3240
4068
  case '-ms-grid':
3241
- return 256 /* GRID */;
4069
+ return 256 /* DISPLAY.GRID */;
3242
4070
  case 'ruby':
3243
- return 512 /* RUBY */;
4071
+ return 512 /* DISPLAY.RUBY */;
3244
4072
  case 'subgrid':
3245
- return 1024 /* SUBGRID */;
4073
+ return 1024 /* DISPLAY.SUBGRID */;
3246
4074
  case 'list-item':
3247
- return 2048 /* LIST_ITEM */;
4075
+ return 2048 /* DISPLAY.LIST_ITEM */;
3248
4076
  case 'table-row-group':
3249
- return 4096 /* TABLE_ROW_GROUP */;
4077
+ return 4096 /* DISPLAY.TABLE_ROW_GROUP */;
3250
4078
  case 'table-header-group':
3251
- return 8192 /* TABLE_HEADER_GROUP */;
4079
+ return 8192 /* DISPLAY.TABLE_HEADER_GROUP */;
3252
4080
  case 'table-footer-group':
3253
- return 16384 /* TABLE_FOOTER_GROUP */;
4081
+ return 16384 /* DISPLAY.TABLE_FOOTER_GROUP */;
3254
4082
  case 'table-row':
3255
- return 32768 /* TABLE_ROW */;
4083
+ return 32768 /* DISPLAY.TABLE_ROW */;
3256
4084
  case 'table-cell':
3257
- return 65536 /* TABLE_CELL */;
4085
+ return 65536 /* DISPLAY.TABLE_CELL */;
3258
4086
  case 'table-column-group':
3259
- return 131072 /* TABLE_COLUMN_GROUP */;
4087
+ return 131072 /* DISPLAY.TABLE_COLUMN_GROUP */;
3260
4088
  case 'table-column':
3261
- return 262144 /* TABLE_COLUMN */;
4089
+ return 262144 /* DISPLAY.TABLE_COLUMN */;
3262
4090
  case 'table-caption':
3263
- return 524288 /* TABLE_CAPTION */;
4091
+ return 524288 /* DISPLAY.TABLE_CAPTION */;
3264
4092
  case 'ruby-base':
3265
- return 1048576 /* RUBY_BASE */;
4093
+ return 1048576 /* DISPLAY.RUBY_BASE */;
3266
4094
  case 'ruby-text':
3267
- return 2097152 /* RUBY_TEXT */;
4095
+ return 2097152 /* DISPLAY.RUBY_TEXT */;
3268
4096
  case 'ruby-base-container':
3269
- return 4194304 /* RUBY_BASE_CONTAINER */;
4097
+ return 4194304 /* DISPLAY.RUBY_BASE_CONTAINER */;
3270
4098
  case 'ruby-text-container':
3271
- return 8388608 /* RUBY_TEXT_CONTAINER */;
4099
+ return 8388608 /* DISPLAY.RUBY_TEXT_CONTAINER */;
3272
4100
  case 'contents':
3273
- return 16777216 /* CONTENTS */;
4101
+ return 16777216 /* DISPLAY.CONTENTS */;
3274
4102
  case 'inline-block':
3275
- return 33554432 /* INLINE_BLOCK */;
4103
+ return 33554432 /* DISPLAY.INLINE_BLOCK */;
3276
4104
  case 'inline-list-item':
3277
- return 67108864 /* INLINE_LIST_ITEM */;
4105
+ return 67108864 /* DISPLAY.INLINE_LIST_ITEM */;
3278
4106
  case 'inline-table':
3279
- return 134217728 /* INLINE_TABLE */;
4107
+ return 134217728 /* DISPLAY.INLINE_TABLE */;
3280
4108
  case 'inline-flex':
3281
- return 268435456 /* INLINE_FLEX */;
4109
+ return 268435456 /* DISPLAY.INLINE_FLEX */;
3282
4110
  case 'inline-grid':
3283
- return 536870912 /* INLINE_GRID */;
4111
+ return 536870912 /* DISPLAY.INLINE_GRID */;
3284
4112
  }
3285
- return 0 /* NONE */;
4113
+ return 0 /* DISPLAY.NONE */;
3286
4114
  };
3287
4115
 
3288
4116
  var float = {
3289
4117
  name: 'float',
3290
4118
  initialValue: 'none',
3291
4119
  prefix: false,
3292
- type: 2 /* IDENT_VALUE */,
4120
+ type: 2 /* PropertyDescriptorParsingType.IDENT_VALUE */,
3293
4121
  parse: function (_context, float) {
3294
4122
  switch (float) {
3295
4123
  case 'left':
3296
- return 1 /* LEFT */;
4124
+ return 1 /* FLOAT.LEFT */;
3297
4125
  case 'right':
3298
- return 2 /* RIGHT */;
4126
+ return 2 /* FLOAT.RIGHT */;
3299
4127
  case 'inline-start':
3300
- return 3 /* INLINE_START */;
4128
+ return 3 /* FLOAT.INLINE_START */;
3301
4129
  case 'inline-end':
3302
- return 4 /* INLINE_END */;
4130
+ return 4 /* FLOAT.INLINE_END */;
3303
4131
  }
3304
- return 0 /* NONE */;
4132
+ return 0 /* FLOAT.NONE */;
3305
4133
  }
3306
4134
  };
3307
4135
 
@@ -3309,15 +4137,15 @@ var letterSpacing = {
3309
4137
  name: 'letter-spacing',
3310
4138
  initialValue: '0',
3311
4139
  prefix: false,
3312
- type: 0 /* VALUE */,
4140
+ type: 0 /* PropertyDescriptorParsingType.VALUE */,
3313
4141
  parse: function (_context, token) {
3314
- if (token.type === 20 /* IDENT_TOKEN */ && token.value === 'normal') {
4142
+ if (token.type === 20 /* TokenType.IDENT_TOKEN */ && token.value === 'normal') {
3315
4143
  return 0;
3316
4144
  }
3317
- if (token.type === 17 /* NUMBER_TOKEN */) {
4145
+ if (token.type === 17 /* TokenType.NUMBER_TOKEN */) {
3318
4146
  return token.number;
3319
4147
  }
3320
- if (token.type === 15 /* DIMENSION_TOKEN */) {
4148
+ if (token.type === 15 /* TokenType.DIMENSION_TOKEN */) {
3321
4149
  return token.number;
3322
4150
  }
3323
4151
  return 0;
@@ -3333,7 +4161,7 @@ var lineBreak = {
3333
4161
  name: 'line-break',
3334
4162
  initialValue: 'normal',
3335
4163
  prefix: false,
3336
- type: 2 /* IDENT_VALUE */,
4164
+ type: 2 /* PropertyDescriptorParsingType.IDENT_VALUE */,
3337
4165
  parse: function (_context, lineBreak) {
3338
4166
  switch (lineBreak) {
3339
4167
  case 'strict':
@@ -3349,13 +4177,13 @@ var lineHeight = {
3349
4177
  name: 'line-height',
3350
4178
  initialValue: 'normal',
3351
4179
  prefix: false,
3352
- type: 4 /* TOKEN_VALUE */
4180
+ type: 4 /* PropertyDescriptorParsingType.TOKEN_VALUE */
3353
4181
  };
3354
4182
  var computeLineHeight = function (token, fontSize) {
3355
4183
  if (isIdentToken(token) && token.value === 'normal') {
3356
4184
  return 1.2 * fontSize;
3357
4185
  }
3358
- else if (token.type === 17 /* NUMBER_TOKEN */) {
4186
+ else if (token.type === 17 /* TokenType.NUMBER_TOKEN */) {
3359
4187
  return fontSize * token.number;
3360
4188
  }
3361
4189
  else if (isLengthPercentage(token)) {
@@ -3367,10 +4195,10 @@ var computeLineHeight = function (token, fontSize) {
3367
4195
  var listStyleImage = {
3368
4196
  name: 'list-style-image',
3369
4197
  initialValue: 'none',
3370
- type: 0 /* VALUE */,
4198
+ type: 0 /* PropertyDescriptorParsingType.VALUE */,
3371
4199
  prefix: false,
3372
4200
  parse: function (context, token) {
3373
- if (token.type === 20 /* IDENT_TOKEN */ && token.value === 'none') {
4201
+ if (token.type === 20 /* TokenType.IDENT_TOKEN */ && token.value === 'none') {
3374
4202
  return null;
3375
4203
  }
3376
4204
  return image.parse(context, token);
@@ -3381,14 +4209,14 @@ var listStylePosition = {
3381
4209
  name: 'list-style-position',
3382
4210
  initialValue: 'outside',
3383
4211
  prefix: false,
3384
- type: 2 /* IDENT_VALUE */,
4212
+ type: 2 /* PropertyDescriptorParsingType.IDENT_VALUE */,
3385
4213
  parse: function (_context, position) {
3386
4214
  switch (position) {
3387
4215
  case 'inside':
3388
- return 0 /* INSIDE */;
4216
+ return 0 /* LIST_STYLE_POSITION.INSIDE */;
3389
4217
  case 'outside':
3390
4218
  default:
3391
- return 1 /* OUTSIDE */;
4219
+ return 1 /* LIST_STYLE_POSITION.OUTSIDE */;
3392
4220
  }
3393
4221
  }
3394
4222
  };
@@ -3397,127 +4225,127 @@ var listStyleType = {
3397
4225
  name: 'list-style-type',
3398
4226
  initialValue: 'none',
3399
4227
  prefix: false,
3400
- type: 2 /* IDENT_VALUE */,
4228
+ type: 2 /* PropertyDescriptorParsingType.IDENT_VALUE */,
3401
4229
  parse: function (_context, type) {
3402
4230
  switch (type) {
3403
4231
  case 'disc':
3404
- return 0 /* DISC */;
4232
+ return 0 /* LIST_STYLE_TYPE.DISC */;
3405
4233
  case 'circle':
3406
- return 1 /* CIRCLE */;
4234
+ return 1 /* LIST_STYLE_TYPE.CIRCLE */;
3407
4235
  case 'square':
3408
- return 2 /* SQUARE */;
4236
+ return 2 /* LIST_STYLE_TYPE.SQUARE */;
3409
4237
  case 'decimal':
3410
- return 3 /* DECIMAL */;
4238
+ return 3 /* LIST_STYLE_TYPE.DECIMAL */;
3411
4239
  case 'cjk-decimal':
3412
- return 4 /* CJK_DECIMAL */;
4240
+ return 4 /* LIST_STYLE_TYPE.CJK_DECIMAL */;
3413
4241
  case 'decimal-leading-zero':
3414
- return 5 /* DECIMAL_LEADING_ZERO */;
4242
+ return 5 /* LIST_STYLE_TYPE.DECIMAL_LEADING_ZERO */;
3415
4243
  case 'lower-roman':
3416
- return 6 /* LOWER_ROMAN */;
4244
+ return 6 /* LIST_STYLE_TYPE.LOWER_ROMAN */;
3417
4245
  case 'upper-roman':
3418
- return 7 /* UPPER_ROMAN */;
4246
+ return 7 /* LIST_STYLE_TYPE.UPPER_ROMAN */;
3419
4247
  case 'lower-greek':
3420
- return 8 /* LOWER_GREEK */;
4248
+ return 8 /* LIST_STYLE_TYPE.LOWER_GREEK */;
3421
4249
  case 'lower-alpha':
3422
- return 9 /* LOWER_ALPHA */;
4250
+ return 9 /* LIST_STYLE_TYPE.LOWER_ALPHA */;
3423
4251
  case 'upper-alpha':
3424
- return 10 /* UPPER_ALPHA */;
4252
+ return 10 /* LIST_STYLE_TYPE.UPPER_ALPHA */;
3425
4253
  case 'arabic-indic':
3426
- return 11 /* ARABIC_INDIC */;
4254
+ return 11 /* LIST_STYLE_TYPE.ARABIC_INDIC */;
3427
4255
  case 'armenian':
3428
- return 12 /* ARMENIAN */;
4256
+ return 12 /* LIST_STYLE_TYPE.ARMENIAN */;
3429
4257
  case 'bengali':
3430
- return 13 /* BENGALI */;
4258
+ return 13 /* LIST_STYLE_TYPE.BENGALI */;
3431
4259
  case 'cambodian':
3432
- return 14 /* CAMBODIAN */;
4260
+ return 14 /* LIST_STYLE_TYPE.CAMBODIAN */;
3433
4261
  case 'cjk-earthly-branch':
3434
- return 15 /* CJK_EARTHLY_BRANCH */;
4262
+ return 15 /* LIST_STYLE_TYPE.CJK_EARTHLY_BRANCH */;
3435
4263
  case 'cjk-heavenly-stem':
3436
- return 16 /* CJK_HEAVENLY_STEM */;
4264
+ return 16 /* LIST_STYLE_TYPE.CJK_HEAVENLY_STEM */;
3437
4265
  case 'cjk-ideographic':
3438
- return 17 /* CJK_IDEOGRAPHIC */;
4266
+ return 17 /* LIST_STYLE_TYPE.CJK_IDEOGRAPHIC */;
3439
4267
  case 'devanagari':
3440
- return 18 /* DEVANAGARI */;
4268
+ return 18 /* LIST_STYLE_TYPE.DEVANAGARI */;
3441
4269
  case 'ethiopic-numeric':
3442
- return 19 /* ETHIOPIC_NUMERIC */;
4270
+ return 19 /* LIST_STYLE_TYPE.ETHIOPIC_NUMERIC */;
3443
4271
  case 'georgian':
3444
- return 20 /* GEORGIAN */;
4272
+ return 20 /* LIST_STYLE_TYPE.GEORGIAN */;
3445
4273
  case 'gujarati':
3446
- return 21 /* GUJARATI */;
4274
+ return 21 /* LIST_STYLE_TYPE.GUJARATI */;
3447
4275
  case 'gurmukhi':
3448
- return 22 /* GURMUKHI */;
4276
+ return 22 /* LIST_STYLE_TYPE.GURMUKHI */;
3449
4277
  case 'hebrew':
3450
- return 22 /* HEBREW */;
4278
+ return 52 /* LIST_STYLE_TYPE.HEBREW */;
3451
4279
  case 'hiragana':
3452
- return 23 /* HIRAGANA */;
4280
+ return 23 /* LIST_STYLE_TYPE.HIRAGANA */;
3453
4281
  case 'hiragana-iroha':
3454
- return 24 /* HIRAGANA_IROHA */;
4282
+ return 24 /* LIST_STYLE_TYPE.HIRAGANA_IROHA */;
3455
4283
  case 'japanese-formal':
3456
- return 25 /* JAPANESE_FORMAL */;
4284
+ return 25 /* LIST_STYLE_TYPE.JAPANESE_FORMAL */;
3457
4285
  case 'japanese-informal':
3458
- return 26 /* JAPANESE_INFORMAL */;
4286
+ return 26 /* LIST_STYLE_TYPE.JAPANESE_INFORMAL */;
3459
4287
  case 'kannada':
3460
- return 27 /* KANNADA */;
4288
+ return 27 /* LIST_STYLE_TYPE.KANNADA */;
3461
4289
  case 'katakana':
3462
- return 28 /* KATAKANA */;
4290
+ return 28 /* LIST_STYLE_TYPE.KATAKANA */;
3463
4291
  case 'katakana-iroha':
3464
- return 29 /* KATAKANA_IROHA */;
4292
+ return 29 /* LIST_STYLE_TYPE.KATAKANA_IROHA */;
3465
4293
  case 'khmer':
3466
- return 30 /* KHMER */;
4294
+ return 30 /* LIST_STYLE_TYPE.KHMER */;
3467
4295
  case 'korean-hangul-formal':
3468
- return 31 /* KOREAN_HANGUL_FORMAL */;
4296
+ return 31 /* LIST_STYLE_TYPE.KOREAN_HANGUL_FORMAL */;
3469
4297
  case 'korean-hanja-formal':
3470
- return 32 /* KOREAN_HANJA_FORMAL */;
4298
+ return 32 /* LIST_STYLE_TYPE.KOREAN_HANJA_FORMAL */;
3471
4299
  case 'korean-hanja-informal':
3472
- return 33 /* KOREAN_HANJA_INFORMAL */;
4300
+ return 33 /* LIST_STYLE_TYPE.KOREAN_HANJA_INFORMAL */;
3473
4301
  case 'lao':
3474
- return 34 /* LAO */;
4302
+ return 34 /* LIST_STYLE_TYPE.LAO */;
3475
4303
  case 'lower-armenian':
3476
- return 35 /* LOWER_ARMENIAN */;
4304
+ return 35 /* LIST_STYLE_TYPE.LOWER_ARMENIAN */;
3477
4305
  case 'malayalam':
3478
- return 36 /* MALAYALAM */;
4306
+ return 36 /* LIST_STYLE_TYPE.MALAYALAM */;
3479
4307
  case 'mongolian':
3480
- return 37 /* MONGOLIAN */;
4308
+ return 37 /* LIST_STYLE_TYPE.MONGOLIAN */;
3481
4309
  case 'myanmar':
3482
- return 38 /* MYANMAR */;
4310
+ return 38 /* LIST_STYLE_TYPE.MYANMAR */;
3483
4311
  case 'oriya':
3484
- return 39 /* ORIYA */;
4312
+ return 39 /* LIST_STYLE_TYPE.ORIYA */;
3485
4313
  case 'persian':
3486
- return 40 /* PERSIAN */;
4314
+ return 40 /* LIST_STYLE_TYPE.PERSIAN */;
3487
4315
  case 'simp-chinese-formal':
3488
- return 41 /* SIMP_CHINESE_FORMAL */;
4316
+ return 41 /* LIST_STYLE_TYPE.SIMP_CHINESE_FORMAL */;
3489
4317
  case 'simp-chinese-informal':
3490
- return 42 /* SIMP_CHINESE_INFORMAL */;
4318
+ return 42 /* LIST_STYLE_TYPE.SIMP_CHINESE_INFORMAL */;
3491
4319
  case 'tamil':
3492
- return 43 /* TAMIL */;
4320
+ return 43 /* LIST_STYLE_TYPE.TAMIL */;
3493
4321
  case 'telugu':
3494
- return 44 /* TELUGU */;
4322
+ return 44 /* LIST_STYLE_TYPE.TELUGU */;
3495
4323
  case 'thai':
3496
- return 45 /* THAI */;
4324
+ return 45 /* LIST_STYLE_TYPE.THAI */;
3497
4325
  case 'tibetan':
3498
- return 46 /* TIBETAN */;
4326
+ return 46 /* LIST_STYLE_TYPE.TIBETAN */;
3499
4327
  case 'trad-chinese-formal':
3500
- return 47 /* TRAD_CHINESE_FORMAL */;
4328
+ return 47 /* LIST_STYLE_TYPE.TRAD_CHINESE_FORMAL */;
3501
4329
  case 'trad-chinese-informal':
3502
- return 48 /* TRAD_CHINESE_INFORMAL */;
4330
+ return 48 /* LIST_STYLE_TYPE.TRAD_CHINESE_INFORMAL */;
3503
4331
  case 'upper-armenian':
3504
- return 49 /* UPPER_ARMENIAN */;
4332
+ return 49 /* LIST_STYLE_TYPE.UPPER_ARMENIAN */;
3505
4333
  case 'disclosure-open':
3506
- return 50 /* DISCLOSURE_OPEN */;
4334
+ return 50 /* LIST_STYLE_TYPE.DISCLOSURE_OPEN */;
3507
4335
  case 'disclosure-closed':
3508
- return 51 /* DISCLOSURE_CLOSED */;
4336
+ return 51 /* LIST_STYLE_TYPE.DISCLOSURE_CLOSED */;
3509
4337
  case 'none':
3510
4338
  default:
3511
- return -1 /* NONE */;
4339
+ return -1 /* LIST_STYLE_TYPE.NONE */;
3512
4340
  }
3513
4341
  }
3514
4342
  };
3515
4343
 
3516
4344
  var marginForSide = function (side) { return ({
3517
- name: "margin-" + side,
4345
+ name: "margin-".concat(side),
3518
4346
  initialValue: '0',
3519
4347
  prefix: false,
3520
- type: 4 /* TOKEN_VALUE */
4348
+ type: 4 /* PropertyDescriptorParsingType.TOKEN_VALUE */
3521
4349
  }); };
3522
4350
  var marginTop = marginForSide('top');
3523
4351
  var marginRight = marginForSide('right');
@@ -3528,21 +4356,21 @@ var overflow = {
3528
4356
  name: 'overflow',
3529
4357
  initialValue: 'visible',
3530
4358
  prefix: false,
3531
- type: 1 /* LIST */,
4359
+ type: 1 /* PropertyDescriptorParsingType.LIST */,
3532
4360
  parse: function (_context, tokens) {
3533
4361
  return tokens.filter(isIdentToken).map(function (overflow) {
3534
4362
  switch (overflow.value) {
3535
4363
  case 'hidden':
3536
- return 1 /* HIDDEN */;
4364
+ return 1 /* OVERFLOW.HIDDEN */;
3537
4365
  case 'scroll':
3538
- return 2 /* SCROLL */;
4366
+ return 2 /* OVERFLOW.SCROLL */;
3539
4367
  case 'clip':
3540
- return 3 /* CLIP */;
4368
+ return 3 /* OVERFLOW.CLIP */;
3541
4369
  case 'auto':
3542
- return 4 /* AUTO */;
4370
+ return 4 /* OVERFLOW.AUTO */;
3543
4371
  case 'visible':
3544
4372
  default:
3545
- return 0 /* VISIBLE */;
4373
+ return 0 /* OVERFLOW.VISIBLE */;
3546
4374
  }
3547
4375
  });
3548
4376
  }
@@ -3552,23 +4380,23 @@ var overflowWrap = {
3552
4380
  name: 'overflow-wrap',
3553
4381
  initialValue: 'normal',
3554
4382
  prefix: false,
3555
- type: 2 /* IDENT_VALUE */,
4383
+ type: 2 /* PropertyDescriptorParsingType.IDENT_VALUE */,
3556
4384
  parse: function (_context, overflow) {
3557
4385
  switch (overflow) {
3558
4386
  case 'break-word':
3559
- return "break-word" /* BREAK_WORD */;
4387
+ return "break-word" /* OVERFLOW_WRAP.BREAK_WORD */;
3560
4388
  case 'normal':
3561
4389
  default:
3562
- return "normal" /* NORMAL */;
4390
+ return "normal" /* OVERFLOW_WRAP.NORMAL */;
3563
4391
  }
3564
4392
  }
3565
4393
  };
3566
4394
 
3567
4395
  var paddingForSide = function (side) { return ({
3568
- name: "padding-" + side,
4396
+ name: "padding-".concat(side),
3569
4397
  initialValue: '0',
3570
4398
  prefix: false,
3571
- type: 3 /* TYPE_VALUE */,
4399
+ type: 3 /* PropertyDescriptorParsingType.TYPE_VALUE */,
3572
4400
  format: 'length-percentage'
3573
4401
  }); };
3574
4402
  var paddingTop = paddingForSide('top');
@@ -3580,17 +4408,17 @@ var textAlign = {
3580
4408
  name: 'text-align',
3581
4409
  initialValue: 'left',
3582
4410
  prefix: false,
3583
- type: 2 /* IDENT_VALUE */,
4411
+ type: 2 /* PropertyDescriptorParsingType.IDENT_VALUE */,
3584
4412
  parse: function (_context, textAlign) {
3585
4413
  switch (textAlign) {
3586
4414
  case 'right':
3587
- return 2 /* RIGHT */;
4415
+ return 2 /* TEXT_ALIGN.RIGHT */;
3588
4416
  case 'center':
3589
4417
  case 'justify':
3590
- return 1 /* CENTER */;
4418
+ return 1 /* TEXT_ALIGN.CENTER */;
3591
4419
  case 'left':
3592
4420
  default:
3593
- return 0 /* LEFT */;
4421
+ return 0 /* TEXT_ALIGN.LEFT */;
3594
4422
  }
3595
4423
  }
3596
4424
  };
@@ -3599,26 +4427,26 @@ var position = {
3599
4427
  name: 'position',
3600
4428
  initialValue: 'static',
3601
4429
  prefix: false,
3602
- type: 2 /* IDENT_VALUE */,
4430
+ type: 2 /* PropertyDescriptorParsingType.IDENT_VALUE */,
3603
4431
  parse: function (_context, position) {
3604
4432
  switch (position) {
3605
4433
  case 'relative':
3606
- return 1 /* RELATIVE */;
4434
+ return 1 /* POSITION.RELATIVE */;
3607
4435
  case 'absolute':
3608
- return 2 /* ABSOLUTE */;
4436
+ return 2 /* POSITION.ABSOLUTE */;
3609
4437
  case 'fixed':
3610
- return 3 /* FIXED */;
4438
+ return 3 /* POSITION.FIXED */;
3611
4439
  case 'sticky':
3612
- return 4 /* STICKY */;
4440
+ return 4 /* POSITION.STICKY */;
3613
4441
  }
3614
- return 0 /* STATIC */;
4442
+ return 0 /* POSITION.STATIC */;
3615
4443
  }
3616
4444
  };
3617
4445
 
3618
4446
  var textShadow = {
3619
4447
  name: 'text-shadow',
3620
4448
  initialValue: 'none',
3621
- type: 1 /* LIST */,
4449
+ type: 1 /* PropertyDescriptorParsingType.LIST */,
3622
4450
  prefix: false,
3623
4451
  parse: function (context, tokens) {
3624
4452
  if (tokens.length === 1 && isIdentWithValue(tokens[0], 'none')) {
@@ -3659,17 +4487,17 @@ var textTransform = {
3659
4487
  name: 'text-transform',
3660
4488
  initialValue: 'none',
3661
4489
  prefix: false,
3662
- type: 2 /* IDENT_VALUE */,
4490
+ type: 2 /* PropertyDescriptorParsingType.IDENT_VALUE */,
3663
4491
  parse: function (_context, textTransform) {
3664
4492
  switch (textTransform) {
3665
4493
  case 'uppercase':
3666
- return 2 /* UPPERCASE */;
4494
+ return 2 /* TEXT_TRANSFORM.UPPERCASE */;
3667
4495
  case 'lowercase':
3668
- return 1 /* LOWERCASE */;
4496
+ return 1 /* TEXT_TRANSFORM.LOWERCASE */;
3669
4497
  case 'capitalize':
3670
- return 3 /* CAPITALIZE */;
4498
+ return 3 /* TEXT_TRANSFORM.CAPITALIZE */;
3671
4499
  }
3672
- return 0 /* NONE */;
4500
+ return 0 /* TEXT_TRANSFORM.NONE */;
3673
4501
  }
3674
4502
  };
3675
4503
 
@@ -3677,38 +4505,58 @@ var transform$1 = {
3677
4505
  name: 'transform',
3678
4506
  initialValue: 'none',
3679
4507
  prefix: true,
3680
- type: 0 /* VALUE */,
4508
+ type: 0 /* PropertyDescriptorParsingType.VALUE */,
3681
4509
  parse: function (_context, token) {
3682
- if (token.type === 20 /* IDENT_TOKEN */ && token.value === 'none') {
4510
+ if (token.type === 20 /* TokenType.IDENT_TOKEN */ && token.value === 'none') {
3683
4511
  return null;
3684
4512
  }
3685
- if (token.type === 18 /* FUNCTION */) {
4513
+ if (token.type === 18 /* TokenType.FUNCTION */) {
3686
4514
  var transformFunction = SUPPORTED_TRANSFORM_FUNCTIONS[token.name];
3687
4515
  if (typeof transformFunction === 'undefined') {
3688
- throw new Error("Attempting to parse an unsupported transform function \"" + token.name + "\"");
4516
+ throw new Error("Attempting to parse an unsupported transform function \"".concat(token.name, "\""));
3689
4517
  }
3690
- return transformFunction(token.values);
4518
+ return transformFunction(_context, token.values);
3691
4519
  }
3692
4520
  return null;
3693
4521
  }
3694
4522
  };
3695
- var matrix = function (args) {
3696
- var values = args.filter(function (arg) { return arg.type === 17 /* NUMBER_TOKEN */; }).map(function (arg) { return arg.number; });
4523
+ var matrix = function (_context, args) {
4524
+ var values = args.filter(function (arg) { return arg.type === 17 /* TokenType.NUMBER_TOKEN */; }).map(function (arg) { return arg.number; });
3697
4525
  return values.length === 6 ? values : null;
3698
4526
  };
3699
4527
  // doesn't support 3D transforms at the moment
3700
- var matrix3d = function (args) {
3701
- var values = args.filter(function (arg) { return arg.type === 17 /* NUMBER_TOKEN */; }).map(function (arg) { return arg.number; });
4528
+ var matrix3d = function (_context, args) {
4529
+ var values = args.filter(function (arg) { return arg.type === 17 /* TokenType.NUMBER_TOKEN */; }).map(function (arg) { return arg.number; });
3702
4530
  var a1 = values[0], b1 = values[1]; values[2]; values[3]; var a2 = values[4], b2 = values[5]; values[6]; values[7]; values[8]; values[9]; values[10]; values[11]; var a4 = values[12], b4 = values[13]; values[14]; values[15];
3703
4531
  return values.length === 16 ? [a1, b1, a2, b2, a4, b4] : null;
3704
4532
  };
4533
+ var rotate$1 = function (context, args) {
4534
+ if (args.length !== 1) {
4535
+ return null;
4536
+ }
4537
+ var arg = args[0];
4538
+ var radians = 0;
4539
+ if (arg.type === 17 /* TokenType.NUMBER_TOKEN */ && arg.number === 0) {
4540
+ radians = 0;
4541
+ }
4542
+ else if (arg.type === 15 /* TokenType.DIMENSION_TOKEN */) {
4543
+ radians = angle.parse(context, arg);
4544
+ }
4545
+ else {
4546
+ return null;
4547
+ }
4548
+ var cos = Math.cos(radians);
4549
+ var sin = Math.sin(radians);
4550
+ return [cos, sin, -sin, cos, 0, 0];
4551
+ };
3705
4552
  var SUPPORTED_TRANSFORM_FUNCTIONS = {
3706
4553
  matrix: matrix,
3707
- matrix3d: matrix3d
4554
+ matrix3d: matrix3d,
4555
+ rotate: rotate$1
3708
4556
  };
3709
4557
 
3710
4558
  var DEFAULT_VALUE = {
3711
- type: 16 /* PERCENTAGE_TOKEN */,
4559
+ type: 16 /* TokenType.PERCENTAGE_TOKEN */,
3712
4560
  number: 50,
3713
4561
  flags: FLAG_INTEGER
3714
4562
  };
@@ -3717,7 +4565,7 @@ var transformOrigin = {
3717
4565
  name: 'transform-origin',
3718
4566
  initialValue: '50% 50%',
3719
4567
  prefix: true,
3720
- type: 1 /* LIST */,
4568
+ type: 1 /* PropertyDescriptorParsingType.LIST */,
3721
4569
  parse: function (_context, tokens) {
3722
4570
  var origins = tokens.filter(isLengthPercentage);
3723
4571
  if (origins.length !== 2) {
@@ -3727,20 +4575,44 @@ var transformOrigin = {
3727
4575
  }
3728
4576
  };
3729
4577
 
4578
+ var rotate = {
4579
+ name: 'rotate',
4580
+ initialValue: 'none',
4581
+ prefix: false,
4582
+ type: 0 /* PropertyDescriptorParsingType.VALUE */,
4583
+ parse: function (_context, token) {
4584
+ if (token.type === 20 /* TokenType.IDENT_TOKEN */ && token.value === 'none') {
4585
+ return null;
4586
+ }
4587
+ if (token.type === 17 /* TokenType.NUMBER_TOKEN */) {
4588
+ if (token.number === 0) {
4589
+ return 0;
4590
+ }
4591
+ }
4592
+ if (token.type === 15 /* TokenType.DIMENSION_TOKEN */) {
4593
+ // Parse angle and convert to degrees for storage
4594
+ var radians = angle.parse(_context, token);
4595
+ // Store as degrees for consistency
4596
+ return (radians * 180) / Math.PI;
4597
+ }
4598
+ return null;
4599
+ }
4600
+ };
4601
+
3730
4602
  var visibility = {
3731
4603
  name: 'visible',
3732
4604
  initialValue: 'none',
3733
4605
  prefix: false,
3734
- type: 2 /* IDENT_VALUE */,
4606
+ type: 2 /* PropertyDescriptorParsingType.IDENT_VALUE */,
3735
4607
  parse: function (_context, visibility) {
3736
4608
  switch (visibility) {
3737
4609
  case 'hidden':
3738
- return 1 /* HIDDEN */;
4610
+ return 1 /* VISIBILITY.HIDDEN */;
3739
4611
  case 'collapse':
3740
- return 2 /* COLLAPSE */;
4612
+ return 2 /* VISIBILITY.COLLAPSE */;
3741
4613
  case 'visible':
3742
4614
  default:
3743
- return 0 /* VISIBLE */;
4615
+ return 0 /* VISIBILITY.VISIBLE */;
3744
4616
  }
3745
4617
  }
3746
4618
  };
@@ -3755,7 +4627,7 @@ var wordBreak = {
3755
4627
  name: 'word-break',
3756
4628
  initialValue: 'normal',
3757
4629
  prefix: false,
3758
- type: 2 /* IDENT_VALUE */,
4630
+ type: 2 /* PropertyDescriptorParsingType.IDENT_VALUE */,
3759
4631
  parse: function (_context, wordBreak) {
3760
4632
  switch (wordBreak) {
3761
4633
  case 'break-all':
@@ -3773,9 +4645,9 @@ var zIndex = {
3773
4645
  name: 'z-index',
3774
4646
  initialValue: 'auto',
3775
4647
  prefix: false,
3776
- type: 0 /* VALUE */,
4648
+ type: 0 /* PropertyDescriptorParsingType.VALUE */,
3777
4649
  parse: function (_context, token) {
3778
- if (token.type === 20 /* IDENT_TOKEN */) {
4650
+ if (token.type === 20 /* TokenType.IDENT_TOKEN */) {
3779
4651
  return { auto: true, order: 0 };
3780
4652
  }
3781
4653
  if (isNumberToken(token)) {
@@ -3788,7 +4660,7 @@ var zIndex = {
3788
4660
  var time = {
3789
4661
  name: 'time',
3790
4662
  parse: function (_context, value) {
3791
- if (value.type === 15 /* DIMENSION_TOKEN */) {
4663
+ if (value.type === 15 /* TokenType.DIMENSION_TOKEN */) {
3792
4664
  switch (value.unit.toLowerCase()) {
3793
4665
  case 's':
3794
4666
  return 1000 * value.number;
@@ -3803,7 +4675,7 @@ var time = {
3803
4675
  var opacity = {
3804
4676
  name: 'opacity',
3805
4677
  initialValue: '1',
3806
- type: 0 /* VALUE */,
4678
+ type: 0 /* PropertyDescriptorParsingType.VALUE */,
3807
4679
  prefix: false,
3808
4680
  parse: function (_context, token) {
3809
4681
  if (isNumberToken(token)) {
@@ -3817,7 +4689,7 @@ var textDecorationColor = {
3817
4689
  name: "text-decoration-color",
3818
4690
  initialValue: 'transparent',
3819
4691
  prefix: false,
3820
- type: 3 /* TYPE_VALUE */,
4692
+ type: 3 /* PropertyDescriptorParsingType.TYPE_VALUE */,
3821
4693
  format: 'color'
3822
4694
  };
3823
4695
 
@@ -3825,24 +4697,24 @@ var textDecorationLine = {
3825
4697
  name: 'text-decoration-line',
3826
4698
  initialValue: 'none',
3827
4699
  prefix: false,
3828
- type: 1 /* LIST */,
4700
+ type: 1 /* PropertyDescriptorParsingType.LIST */,
3829
4701
  parse: function (_context, tokens) {
3830
4702
  return tokens
3831
4703
  .filter(isIdentToken)
3832
4704
  .map(function (token) {
3833
4705
  switch (token.value) {
3834
4706
  case 'underline':
3835
- return 1 /* UNDERLINE */;
4707
+ return 1 /* TEXT_DECORATION_LINE.UNDERLINE */;
3836
4708
  case 'overline':
3837
- return 2 /* OVERLINE */;
4709
+ return 2 /* TEXT_DECORATION_LINE.OVERLINE */;
3838
4710
  case 'line-through':
3839
- return 3 /* LINE_THROUGH */;
4711
+ return 3 /* TEXT_DECORATION_LINE.LINE_THROUGH */;
3840
4712
  case 'none':
3841
- return 4 /* BLINK */;
4713
+ return 4 /* TEXT_DECORATION_LINE.BLINK */;
3842
4714
  }
3843
- return 0 /* NONE */;
4715
+ return 0 /* TEXT_DECORATION_LINE.NONE */;
3844
4716
  })
3845
- .filter(function (line) { return line !== 0 /* NONE */; });
4717
+ .filter(function (line) { return line !== 0 /* TEXT_DECORATION_LINE.NONE */; });
3846
4718
  }
3847
4719
  };
3848
4720
 
@@ -3850,20 +4722,20 @@ var fontFamily = {
3850
4722
  name: "font-family",
3851
4723
  initialValue: '',
3852
4724
  prefix: false,
3853
- type: 1 /* LIST */,
4725
+ type: 1 /* PropertyDescriptorParsingType.LIST */,
3854
4726
  parse: function (_context, tokens) {
3855
4727
  var accumulator = [];
3856
4728
  var results = [];
3857
4729
  tokens.forEach(function (token) {
3858
4730
  switch (token.type) {
3859
- case 20 /* IDENT_TOKEN */:
3860
- case 0 /* STRING_TOKEN */:
4731
+ case 20 /* TokenType.IDENT_TOKEN */:
4732
+ case 0 /* TokenType.STRING_TOKEN */:
3861
4733
  accumulator.push(token.value);
3862
4734
  break;
3863
- case 17 /* NUMBER_TOKEN */:
4735
+ case 17 /* TokenType.NUMBER_TOKEN */:
3864
4736
  accumulator.push(token.number.toString());
3865
4737
  break;
3866
- case 4 /* COMMA_TOKEN */:
4738
+ case 4 /* TokenType.COMMA_TOKEN */:
3867
4739
  results.push(accumulator.join(' '));
3868
4740
  accumulator.length = 0;
3869
4741
  break;
@@ -3872,7 +4744,7 @@ var fontFamily = {
3872
4744
  if (accumulator.length) {
3873
4745
  results.push(accumulator.join(' '));
3874
4746
  }
3875
- return results.map(function (result) { return (result.indexOf(' ') === -1 ? result : "'" + result + "'"); });
4747
+ return results.map(function (result) { return (result.indexOf(' ') === -1 ? result : "'".concat(result, "'")); });
3876
4748
  }
3877
4749
  };
3878
4750
 
@@ -3880,14 +4752,14 @@ var fontSize = {
3880
4752
  name: "font-size",
3881
4753
  initialValue: '0',
3882
4754
  prefix: false,
3883
- type: 3 /* TYPE_VALUE */,
4755
+ type: 3 /* PropertyDescriptorParsingType.TYPE_VALUE */,
3884
4756
  format: 'length'
3885
4757
  };
3886
4758
 
3887
4759
  var fontWeight = {
3888
4760
  name: 'font-weight',
3889
4761
  initialValue: 'normal',
3890
- type: 0 /* VALUE */,
4762
+ type: 0 /* PropertyDescriptorParsingType.VALUE */,
3891
4763
  prefix: false,
3892
4764
  parse: function (_context, token) {
3893
4765
  if (isNumberToken(token)) {
@@ -3909,7 +4781,7 @@ var fontWeight = {
3909
4781
  var fontVariant = {
3910
4782
  name: 'font-variant',
3911
4783
  initialValue: 'none',
3912
- type: 1 /* LIST */,
4784
+ type: 1 /* PropertyDescriptorParsingType.LIST */,
3913
4785
  prefix: false,
3914
4786
  parse: function (_context, tokens) {
3915
4787
  return tokens.filter(isIdentToken).map(function (token) { return token.value; });
@@ -3920,16 +4792,16 @@ var fontStyle = {
3920
4792
  name: 'font-style',
3921
4793
  initialValue: 'normal',
3922
4794
  prefix: false,
3923
- type: 2 /* IDENT_VALUE */,
4795
+ type: 2 /* PropertyDescriptorParsingType.IDENT_VALUE */,
3924
4796
  parse: function (_context, overflow) {
3925
4797
  switch (overflow) {
3926
4798
  case 'oblique':
3927
- return "oblique" /* OBLIQUE */;
4799
+ return "oblique" /* FONT_STYLE.OBLIQUE */;
3928
4800
  case 'italic':
3929
- return "italic" /* ITALIC */;
4801
+ return "italic" /* FONT_STYLE.ITALIC */;
3930
4802
  case 'normal':
3931
4803
  default:
3932
- return "normal" /* NORMAL */;
4804
+ return "normal" /* FONT_STYLE.NORMAL */;
3933
4805
  }
3934
4806
  }
3935
4807
  };
@@ -3939,14 +4811,14 @@ var contains = function (bit, value) { return (bit & value) !== 0; };
3939
4811
  var content = {
3940
4812
  name: 'content',
3941
4813
  initialValue: 'none',
3942
- type: 1 /* LIST */,
4814
+ type: 1 /* PropertyDescriptorParsingType.LIST */,
3943
4815
  prefix: false,
3944
4816
  parse: function (_context, tokens) {
3945
4817
  if (tokens.length === 0) {
3946
4818
  return [];
3947
4819
  }
3948
4820
  var first = tokens[0];
3949
- if (first.type === 20 /* IDENT_TOKEN */ && first.value === 'none') {
4821
+ if (first.type === 20 /* TokenType.IDENT_TOKEN */ && first.value === 'none') {
3950
4822
  return [];
3951
4823
  }
3952
4824
  return tokens;
@@ -3957,13 +4829,13 @@ var counterIncrement = {
3957
4829
  name: 'counter-increment',
3958
4830
  initialValue: 'none',
3959
4831
  prefix: true,
3960
- type: 1 /* LIST */,
4832
+ type: 1 /* PropertyDescriptorParsingType.LIST */,
3961
4833
  parse: function (_context, tokens) {
3962
4834
  if (tokens.length === 0) {
3963
4835
  return null;
3964
4836
  }
3965
4837
  var first = tokens[0];
3966
- if (first.type === 20 /* IDENT_TOKEN */ && first.value === 'none') {
4838
+ if (first.type === 20 /* TokenType.IDENT_TOKEN */ && first.value === 'none') {
3967
4839
  return null;
3968
4840
  }
3969
4841
  var increments = [];
@@ -3971,7 +4843,7 @@ var counterIncrement = {
3971
4843
  for (var i = 0; i < filtered.length; i++) {
3972
4844
  var counter = filtered[i];
3973
4845
  var next = filtered[i + 1];
3974
- if (counter.type === 20 /* IDENT_TOKEN */) {
4846
+ if (counter.type === 20 /* TokenType.IDENT_TOKEN */) {
3975
4847
  var increment = next && isNumberToken(next) ? next.number : 1;
3976
4848
  increments.push({ counter: counter.value, increment: increment });
3977
4849
  }
@@ -3984,7 +4856,7 @@ var counterReset = {
3984
4856
  name: 'counter-reset',
3985
4857
  initialValue: 'none',
3986
4858
  prefix: true,
3987
- type: 1 /* LIST */,
4859
+ type: 1 /* PropertyDescriptorParsingType.LIST */,
3988
4860
  parse: function (_context, tokens) {
3989
4861
  if (tokens.length === 0) {
3990
4862
  return [];
@@ -4007,7 +4879,7 @@ var duration = {
4007
4879
  name: 'duration',
4008
4880
  initialValue: '0s',
4009
4881
  prefix: false,
4010
- type: 1 /* LIST */,
4882
+ type: 1 /* PropertyDescriptorParsingType.LIST */,
4011
4883
  parse: function (context, tokens) {
4012
4884
  return tokens.filter(isDimensionToken).map(function (token) { return time.parse(context, token); });
4013
4885
  }
@@ -4017,13 +4889,13 @@ var quotes = {
4017
4889
  name: 'quotes',
4018
4890
  initialValue: 'none',
4019
4891
  prefix: true,
4020
- type: 1 /* LIST */,
4892
+ type: 1 /* PropertyDescriptorParsingType.LIST */,
4021
4893
  parse: function (_context, tokens) {
4022
4894
  if (tokens.length === 0) {
4023
4895
  return null;
4024
4896
  }
4025
4897
  var first = tokens[0];
4026
- if (first.type === 20 /* IDENT_TOKEN */ && first.value === 'none') {
4898
+ if (first.type === 20 /* TokenType.IDENT_TOKEN */ && first.value === 'none') {
4027
4899
  return null;
4028
4900
  }
4029
4901
  var quotes = [];
@@ -4053,7 +4925,7 @@ var getQuote = function (quotes, depth, open) {
4053
4925
  var boxShadow = {
4054
4926
  name: 'box-shadow',
4055
4927
  initialValue: 'none',
4056
- type: 1 /* LIST */,
4928
+ type: 1 /* PropertyDescriptorParsingType.LIST */,
4057
4929
  prefix: false,
4058
4930
  parse: function (context, tokens) {
4059
4931
  if (tokens.length === 1 && isIdentWithValue(tokens[0], 'none')) {
@@ -4102,20 +4974,20 @@ var paintOrder = {
4102
4974
  name: 'paint-order',
4103
4975
  initialValue: 'normal',
4104
4976
  prefix: false,
4105
- type: 1 /* LIST */,
4977
+ type: 1 /* PropertyDescriptorParsingType.LIST */,
4106
4978
  parse: function (_context, tokens) {
4107
- var DEFAULT_VALUE = [0 /* FILL */, 1 /* STROKE */, 2 /* MARKERS */];
4979
+ var DEFAULT_VALUE = [0 /* PAINT_ORDER_LAYER.FILL */, 1 /* PAINT_ORDER_LAYER.STROKE */, 2 /* PAINT_ORDER_LAYER.MARKERS */];
4108
4980
  var layers = [];
4109
4981
  tokens.filter(isIdentToken).forEach(function (token) {
4110
4982
  switch (token.value) {
4111
4983
  case 'stroke':
4112
- layers.push(1 /* STROKE */);
4984
+ layers.push(1 /* PAINT_ORDER_LAYER.STROKE */);
4113
4985
  break;
4114
4986
  case 'fill':
4115
- layers.push(0 /* FILL */);
4987
+ layers.push(0 /* PAINT_ORDER_LAYER.FILL */);
4116
4988
  break;
4117
4989
  case 'markers':
4118
- layers.push(2 /* MARKERS */);
4990
+ layers.push(2 /* PAINT_ORDER_LAYER.MARKERS */);
4119
4991
  break;
4120
4992
  }
4121
4993
  });
@@ -4132,14 +5004,14 @@ var webkitTextStrokeColor = {
4132
5004
  name: "-webkit-text-stroke-color",
4133
5005
  initialValue: 'currentcolor',
4134
5006
  prefix: false,
4135
- type: 3 /* TYPE_VALUE */,
5007
+ type: 3 /* PropertyDescriptorParsingType.TYPE_VALUE */,
4136
5008
  format: 'color'
4137
5009
  };
4138
5010
 
4139
5011
  var webkitTextStrokeWidth = {
4140
5012
  name: "-webkit-text-stroke-width",
4141
5013
  initialValue: '0',
4142
- type: 0 /* VALUE */,
5014
+ type: 0 /* PropertyDescriptorParsingType.VALUE */,
4143
5015
  prefix: false,
4144
5016
  parse: function (_context, token) {
4145
5017
  if (isDimensionToken(token)) {
@@ -4149,6 +5021,31 @@ var webkitTextStrokeWidth = {
4149
5021
  }
4150
5022
  };
4151
5023
 
5024
+ var objectFit = {
5025
+ name: 'objectFit',
5026
+ initialValue: 'fill',
5027
+ prefix: false,
5028
+ type: 1 /* PropertyDescriptorParsingType.LIST */,
5029
+ parse: function (_context, tokens) {
5030
+ return tokens.filter(isIdentToken).reduce(function (bit, token) {
5031
+ return bit | parseDisplayValue(token.value);
5032
+ }, 0 /* OBJECT_FIT.FILL */);
5033
+ }
5034
+ };
5035
+ var parseDisplayValue = function (display) {
5036
+ switch (display) {
5037
+ case 'contain':
5038
+ return 2 /* OBJECT_FIT.CONTAIN */;
5039
+ case 'cover':
5040
+ return 4 /* OBJECT_FIT.COVER */;
5041
+ case 'none':
5042
+ return 8 /* OBJECT_FIT.NONE */;
5043
+ case 'scale-down':
5044
+ return 16 /* OBJECT_FIT.SCALE_DOWN */;
5045
+ }
5046
+ return 0 /* OBJECT_FIT.FILL */;
5047
+ };
5048
+
4152
5049
  var CSSParsedDeclaration = /** @class */ (function () {
4153
5050
  function CSSParsedDeclaration(context, declaration) {
4154
5051
  var _a, _b;
@@ -4214,37 +5111,39 @@ var CSSParsedDeclaration = /** @class */ (function () {
4214
5111
  this.textTransform = parse(context, textTransform, declaration.textTransform);
4215
5112
  this.transform = parse(context, transform$1, declaration.transform);
4216
5113
  this.transformOrigin = parse(context, transformOrigin, declaration.transformOrigin);
5114
+ this.rotate = parse(context, rotate, declaration.rotate);
4217
5115
  this.visibility = parse(context, visibility, declaration.visibility);
4218
5116
  this.webkitTextStrokeColor = parse(context, webkitTextStrokeColor, declaration.webkitTextStrokeColor);
4219
5117
  this.webkitTextStrokeWidth = parse(context, webkitTextStrokeWidth, declaration.webkitTextStrokeWidth);
4220
5118
  this.wordBreak = parse(context, wordBreak, declaration.wordBreak);
4221
5119
  this.zIndex = parse(context, zIndex, declaration.zIndex);
5120
+ this.objectFit = parse(context, objectFit, declaration.objectFit);
4222
5121
  }
4223
5122
  CSSParsedDeclaration.prototype.isVisible = function () {
4224
- return this.display > 0 && this.opacity > 0 && this.visibility === 0 /* VISIBLE */;
5123
+ return this.display > 0 && this.opacity > 0 && this.visibility === 0 /* VISIBILITY.VISIBLE */;
4225
5124
  };
4226
5125
  CSSParsedDeclaration.prototype.isTransparent = function () {
4227
5126
  return isTransparent(this.backgroundColor);
4228
5127
  };
4229
5128
  CSSParsedDeclaration.prototype.isTransformed = function () {
4230
- return this.transform !== null;
5129
+ return this.transform !== null || this.rotate !== null;
4231
5130
  };
4232
5131
  CSSParsedDeclaration.prototype.isPositioned = function () {
4233
- return this.position !== 0 /* STATIC */;
5132
+ return this.position !== 0 /* POSITION.STATIC */;
4234
5133
  };
4235
5134
  CSSParsedDeclaration.prototype.isPositionedWithZIndex = function () {
4236
5135
  return this.isPositioned() && !this.zIndex.auto;
4237
5136
  };
4238
5137
  CSSParsedDeclaration.prototype.isFloating = function () {
4239
- return this.float !== 0 /* NONE */;
5138
+ return this.float !== 0 /* FLOAT.NONE */;
4240
5139
  };
4241
5140
  CSSParsedDeclaration.prototype.isInlineLevel = function () {
4242
- return (contains(this.display, 4 /* INLINE */) ||
4243
- contains(this.display, 33554432 /* INLINE_BLOCK */) ||
4244
- contains(this.display, 268435456 /* INLINE_FLEX */) ||
4245
- contains(this.display, 536870912 /* INLINE_GRID */) ||
4246
- contains(this.display, 67108864 /* INLINE_LIST_ITEM */) ||
4247
- contains(this.display, 134217728 /* INLINE_TABLE */));
5141
+ return (contains(this.display, 4 /* DISPLAY.INLINE */) ||
5142
+ contains(this.display, 33554432 /* DISPLAY.INLINE_BLOCK */) ||
5143
+ contains(this.display, 268435456 /* DISPLAY.INLINE_FLEX */) ||
5144
+ contains(this.display, 536870912 /* DISPLAY.INLINE_GRID */) ||
5145
+ contains(this.display, 67108864 /* DISPLAY.INLINE_LIST_ITEM */) ||
5146
+ contains(this.display, 134217728 /* DISPLAY.INLINE_TABLE */));
4248
5147
  };
4249
5148
  return CSSParsedDeclaration;
4250
5149
  }());
@@ -4269,16 +5168,16 @@ var parse = function (context, descriptor, style) {
4269
5168
  tokenizer.write(value);
4270
5169
  var parser = new Parser(tokenizer.read());
4271
5170
  switch (descriptor.type) {
4272
- case 2 /* IDENT_VALUE */:
5171
+ case 2 /* PropertyDescriptorParsingType.IDENT_VALUE */:
4273
5172
  var token = parser.parseComponentValue();
4274
5173
  return descriptor.parse(context, isIdentToken(token) ? token.value : descriptor.initialValue);
4275
- case 0 /* VALUE */:
5174
+ case 0 /* PropertyDescriptorParsingType.VALUE */:
4276
5175
  return descriptor.parse(context, parser.parseComponentValue());
4277
- case 1 /* LIST */:
5176
+ case 1 /* PropertyDescriptorParsingType.LIST */:
4278
5177
  return descriptor.parse(context, parser.parseComponentValues());
4279
- case 4 /* TOKEN_VALUE */:
5178
+ case 4 /* PropertyDescriptorParsingType.TOKEN_VALUE */:
4280
5179
  return parser.parseComponentValue();
4281
- case 3 /* TYPE_VALUE */:
5180
+ case 3 /* PropertyDescriptorParsingType.TYPE_VALUE */:
4282
5181
  switch (descriptor.format) {
4283
5182
  case 'angle':
4284
5183
  return angle.parse(context, parser.parseComponentValue());
@@ -4304,20 +5203,20 @@ var getElementDebugType = function (element) {
4304
5203
  var attribute = element.getAttribute(elementDebuggerAttribute);
4305
5204
  switch (attribute) {
4306
5205
  case 'all':
4307
- return 1 /* ALL */;
5206
+ return 1 /* DebuggerType.ALL */;
4308
5207
  case 'clone':
4309
- return 2 /* CLONE */;
5208
+ return 2 /* DebuggerType.CLONE */;
4310
5209
  case 'parse':
4311
- return 3 /* PARSE */;
5210
+ return 3 /* DebuggerType.PARSE */;
4312
5211
  case 'render':
4313
- return 4 /* RENDER */;
5212
+ return 4 /* DebuggerType.RENDER */;
4314
5213
  default:
4315
- return 0 /* NONE */;
5214
+ return 0 /* DebuggerType.NONE */;
4316
5215
  }
4317
5216
  };
4318
5217
  var isDebugging = function (element, type) {
4319
5218
  var elementType = getElementDebugType(element);
4320
- return elementType === 1 /* ALL */ || type === elementType;
5219
+ return elementType === 1 /* DebuggerType.ALL */ || type === elementType;
4321
5220
  };
4322
5221
 
4323
5222
  var ElementContainer = /** @class */ (function () {
@@ -4326,7 +5225,7 @@ var ElementContainer = /** @class */ (function () {
4326
5225
  this.textNodes = [];
4327
5226
  this.elements = [];
4328
5227
  this.flags = 0;
4329
- if (isDebugging(element, 3 /* PARSE */)) {
5228
+ if (isDebugging(element, 3 /* DebuggerType.PARSE */)) {
4330
5229
  debugger;
4331
5230
  }
4332
5231
  this.styles = new CSSParsedDeclaration(context, window.getComputedStyle(element, null));
@@ -4338,10 +5237,14 @@ var ElementContainer = /** @class */ (function () {
4338
5237
  // getBoundingClientRect takes transforms into account
4339
5238
  element.style.transform = 'none';
4340
5239
  }
5240
+ if (this.styles.rotate !== null) {
5241
+ // Handle rotate property similarly to transform
5242
+ element.style.rotate = 'none';
5243
+ }
4341
5244
  }
4342
5245
  this.bounds = parseBounds(this.context, element);
4343
- if (isDebugging(element, 4 /* RENDER */)) {
4344
- this.flags |= 16 /* DEBUG_RENDER */;
5246
+ if (isDebugging(element, 4 /* DebuggerType.RENDER */)) {
5247
+ this.flags |= 16 /* FLAGS.DEBUG_RENDER */;
4345
5248
  }
4346
5249
  }
4347
5250
  return ElementContainer;
@@ -4735,7 +5638,7 @@ var testRangeBounds = function (document) {
4735
5638
  var range = document.createRange();
4736
5639
  if (range.getBoundingClientRect) {
4737
5640
  var testElement = document.createElement('boundtest');
4738
- testElement.style.height = TEST_HEIGHT + "px";
5641
+ testElement.style.height = "".concat(TEST_HEIGHT, "px");
4739
5642
  testElement.style.display = 'block';
4740
5643
  document.body.appendChild(testElement);
4741
5644
  range.selectNode(testElement);
@@ -4825,8 +5728,8 @@ var testForeignObject = function (document) {
4825
5728
  ctx.fillStyle = 'red';
4826
5729
  ctx.fillRect(0, 0, size, size);
4827
5730
  var node = document.createElement('div');
4828
- node.style.backgroundImage = "url(" + greenImageSrc + ")";
4829
- node.style.height = size + "px";
5731
+ node.style.backgroundImage = "url(".concat(greenImageSrc, ")");
5732
+ node.style.height = "".concat(size, "px");
4830
5733
  // Firefox 55 does not render inline <img /> tags
4831
5734
  return isGreenPixel(data)
4832
5735
  ? loadSerializedSVG$1(createForeignObjectSVG(size, size, 0, 0, node))
@@ -4859,7 +5762,7 @@ var loadSerializedSVG$1 = function (svg) {
4859
5762
  var img = new Image();
4860
5763
  img.onload = function () { return resolve(img); };
4861
5764
  img.onerror = reject;
4862
- img.src = "data:image/svg+xml;charset=utf-8," + encodeURIComponent(new XMLSerializer().serializeToString(svg));
5765
+ img.src = "data:image/svg+xml;charset=utf-8,".concat(encodeURIComponent(new XMLSerializer().serializeToString(svg)));
4863
5766
  });
4864
5767
  };
4865
5768
  var FEATURES = {
@@ -5003,7 +5906,7 @@ var wordSeparators = [0x0020, 0x00a0, 0x1361, 0x10100, 0x10101, 0x1039, 0x1091];
5003
5906
  var breakWords = function (str, styles) {
5004
5907
  var breaker = LineBreaker(str, {
5005
5908
  lineBreak: styles.lineBreak,
5006
- wordBreak: styles.overflowWrap === "break-word" /* BREAK_WORD */ ? 'break-word' : styles.wordBreak
5909
+ wordBreak: styles.overflowWrap === "break-word" /* OVERFLOW_WRAP.BREAK_WORD */ ? 'break-word' : styles.wordBreak
5007
5910
  });
5008
5911
  var words = [];
5009
5912
  var bk;
@@ -5044,11 +5947,11 @@ var TextContainer = /** @class */ (function () {
5044
5947
  }());
5045
5948
  var transform = function (text, transform) {
5046
5949
  switch (transform) {
5047
- case 1 /* LOWERCASE */:
5950
+ case 1 /* TEXT_TRANSFORM.LOWERCASE */:
5048
5951
  return text.toLowerCase();
5049
- case 3 /* CAPITALIZE */:
5952
+ case 3 /* TEXT_TRANSFORM.CAPITALIZE */:
5050
5953
  return text.replace(CAPITALIZE, capitalize);
5051
- case 2 /* UPPERCASE */:
5954
+ case 2 /* TEXT_TRANSFORM.UPPERCASE */:
5052
5955
  return text.toUpperCase();
5053
5956
  default:
5054
5957
  return text;
@@ -5093,9 +5996,9 @@ var SVGElementContainer = /** @class */ (function (_super) {
5093
5996
  var _this = _super.call(this, context, img) || this;
5094
5997
  var s = new XMLSerializer();
5095
5998
  var bounds = parseBounds(context, img);
5096
- img.setAttribute('width', bounds.width + "px");
5097
- img.setAttribute('height', bounds.height + "px");
5098
- _this.svg = "data:image/svg+xml," + encodeURIComponent(s.serializeToString(img));
5999
+ img.setAttribute('width', "".concat(bounds.width, "px"));
6000
+ img.setAttribute('height', "".concat(bounds.height, "px"));
6001
+ _this.svg = "data:image/svg+xml,".concat(encodeURIComponent(s.serializeToString(img)));
5099
6002
  _this.intrinsicWidth = img.width.baseVal.value;
5100
6003
  _this.intrinsicHeight = img.height.baseVal.value;
5101
6004
  _this.context.cache.addImage(_this.svg);
@@ -5127,7 +6030,7 @@ var OLElementContainer = /** @class */ (function (_super) {
5127
6030
 
5128
6031
  var CHECKBOX_BORDER_RADIUS = [
5129
6032
  {
5130
- type: 15 /* DIMENSION_TOKEN */,
6033
+ type: 15 /* TokenType.DIMENSION_TOKEN */,
5131
6034
  flags: 0,
5132
6035
  unit: 'px',
5133
6036
  number: 3
@@ -5135,7 +6038,7 @@ var CHECKBOX_BORDER_RADIUS = [
5135
6038
  ];
5136
6039
  var RADIO_BORDER_RADIUS = [
5137
6040
  {
5138
- type: 16 /* PERCENTAGE_TOKEN */,
6041
+ type: 16 /* TokenType.PERCENTAGE_TOKEN */,
5139
6042
  flags: 0,
5140
6043
  number: 50
5141
6044
  }
@@ -5180,9 +6083,9 @@ var InputElementContainer = /** @class */ (function (_super) {
5180
6083
  _this.styles.borderRightStyle =
5181
6084
  _this.styles.borderBottomStyle =
5182
6085
  _this.styles.borderLeftStyle =
5183
- 1 /* SOLID */;
5184
- _this.styles.backgroundClip = [0 /* BORDER_BOX */];
5185
- _this.styles.backgroundOrigin = [0 /* BORDER_BOX */];
6086
+ 1 /* BORDER_STYLE.SOLID */;
6087
+ _this.styles.backgroundClip = [0 /* BACKGROUND_CLIP.BORDER_BOX */];
6088
+ _this.styles.backgroundOrigin = [0 /* BACKGROUND_ORIGIN.BORDER_BOX */];
5186
6089
  _this.bounds = reformatInputBounds(_this.bounds);
5187
6090
  }
5188
6091
  switch (_this.type) {
@@ -5264,7 +6167,8 @@ var LIST_OWNERS = ['OL', 'UL', 'MENU'];
5264
6167
  var parseNodeTree = function (context, node, parent, root) {
5265
6168
  for (var childNode = node.firstChild, nextNode = void 0; childNode; childNode = nextNode) {
5266
6169
  nextNode = childNode.nextSibling;
5267
- if (isTextNode(childNode) && childNode.data.trim().length > 0) {
6170
+ // Fixes #2238 #1624 - Fix the issue of TextNode content being overlooked in rendering due to being perceived as blank by trim().
6171
+ if (isTextNode(childNode) && childNode.data.length > 0) {
5268
6172
  parent.textNodes.push(new TextContainer(context, childNode, parent.styles));
5269
6173
  }
5270
6174
  else if (isElementNode(childNode)) {
@@ -5275,13 +6179,13 @@ var parseNodeTree = function (context, node, parent, root) {
5275
6179
  var container = createContainer(context, childNode);
5276
6180
  if (container.styles.isVisible()) {
5277
6181
  if (createsRealStackingContext(childNode, container, root)) {
5278
- container.flags |= 4 /* CREATES_REAL_STACKING_CONTEXT */;
6182
+ container.flags |= 4 /* FLAGS.CREATES_REAL_STACKING_CONTEXT */;
5279
6183
  }
5280
6184
  else if (createsStackingContext(container.styles)) {
5281
- container.flags |= 2 /* CREATES_STACKING_CONTEXT */;
6185
+ container.flags |= 2 /* FLAGS.CREATES_STACKING_CONTEXT */;
5282
6186
  }
5283
6187
  if (LIST_OWNERS.indexOf(childNode.tagName) !== -1) {
5284
- container.flags |= 8 /* IS_LIST_OWNER */;
6188
+ container.flags |= 8 /* FLAGS.IS_LIST_OWNER */;
5285
6189
  }
5286
6190
  parent.elements.push(container);
5287
6191
  childNode.slot;
@@ -5330,7 +6234,7 @@ var createContainer = function (context, element) {
5330
6234
  };
5331
6235
  var parseTree = function (context, element) {
5332
6236
  var container = createContainer(context, element);
5333
- container.flags |= 4 /* CREATES_REAL_STACKING_CONTEXT */;
6237
+ container.flags |= 4 /* FLAGS.CREATES_REAL_STACKING_CONTEXT */;
5334
6238
  parseNodeTree(context, element, container, container);
5335
6239
  return container;
5336
6240
  };
@@ -5598,7 +6502,7 @@ var CJK_TEN_HIGH_COEFFICIENTS = 1 << 2;
5598
6502
  var CJK_HUNDRED_COEFFICIENTS = 1 << 3;
5599
6503
  var createCJKCounter = function (value, numbers, multipliers, negativeSign, suffix, flags) {
5600
6504
  if (value < -9999 || value > 9999) {
5601
- return createCounterText(value, 4 /* CJK_DECIMAL */, suffix.length > 0);
6505
+ return createCounterText(value, 4 /* LIST_STYLE_TYPE.CJK_DECIMAL */, suffix.length > 0);
5602
6506
  }
5603
6507
  var tmp = Math.abs(value);
5604
6508
  var string = suffix;
@@ -5634,101 +6538,101 @@ var createCounterText = function (value, type, appendSuffix) {
5634
6538
  var koreanSuffix = appendSuffix ? ', ' : '';
5635
6539
  var spaceSuffix = appendSuffix ? ' ' : '';
5636
6540
  switch (type) {
5637
- case 0 /* DISC */:
6541
+ case 0 /* LIST_STYLE_TYPE.DISC */:
5638
6542
  return '•' + spaceSuffix;
5639
- case 1 /* CIRCLE */:
6543
+ case 1 /* LIST_STYLE_TYPE.CIRCLE */:
5640
6544
  return '◦' + spaceSuffix;
5641
- case 2 /* SQUARE */:
6545
+ case 2 /* LIST_STYLE_TYPE.SQUARE */:
5642
6546
  return '◾' + spaceSuffix;
5643
- case 5 /* DECIMAL_LEADING_ZERO */:
6547
+ case 5 /* LIST_STYLE_TYPE.DECIMAL_LEADING_ZERO */:
5644
6548
  var string = createCounterStyleFromRange(value, 48, 57, true, defaultSuffix);
5645
- return string.length < 4 ? "0" + string : string;
5646
- case 4 /* CJK_DECIMAL */:
6549
+ return string.length < 4 ? "0".concat(string) : string;
6550
+ case 4 /* LIST_STYLE_TYPE.CJK_DECIMAL */:
5647
6551
  return createCounterStyleFromSymbols(value, '〇一二三四五六七八九', cjkSuffix);
5648
- case 6 /* LOWER_ROMAN */:
5649
- return createAdditiveCounter(value, 1, 3999, ROMAN_UPPER, 3 /* DECIMAL */, defaultSuffix).toLowerCase();
5650
- case 7 /* UPPER_ROMAN */:
5651
- return createAdditiveCounter(value, 1, 3999, ROMAN_UPPER, 3 /* DECIMAL */, defaultSuffix);
5652
- case 8 /* LOWER_GREEK */:
6552
+ case 6 /* LIST_STYLE_TYPE.LOWER_ROMAN */:
6553
+ return createAdditiveCounter(value, 1, 3999, ROMAN_UPPER, 3 /* LIST_STYLE_TYPE.DECIMAL */, defaultSuffix).toLowerCase();
6554
+ case 7 /* LIST_STYLE_TYPE.UPPER_ROMAN */:
6555
+ return createAdditiveCounter(value, 1, 3999, ROMAN_UPPER, 3 /* LIST_STYLE_TYPE.DECIMAL */, defaultSuffix);
6556
+ case 8 /* LIST_STYLE_TYPE.LOWER_GREEK */:
5653
6557
  return createCounterStyleFromRange(value, 945, 969, false, defaultSuffix);
5654
- case 9 /* LOWER_ALPHA */:
6558
+ case 9 /* LIST_STYLE_TYPE.LOWER_ALPHA */:
5655
6559
  return createCounterStyleFromRange(value, 97, 122, false, defaultSuffix);
5656
- case 10 /* UPPER_ALPHA */:
6560
+ case 10 /* LIST_STYLE_TYPE.UPPER_ALPHA */:
5657
6561
  return createCounterStyleFromRange(value, 65, 90, false, defaultSuffix);
5658
- case 11 /* ARABIC_INDIC */:
6562
+ case 11 /* LIST_STYLE_TYPE.ARABIC_INDIC */:
5659
6563
  return createCounterStyleFromRange(value, 1632, 1641, true, defaultSuffix);
5660
- case 12 /* ARMENIAN */:
5661
- case 49 /* UPPER_ARMENIAN */:
5662
- return createAdditiveCounter(value, 1, 9999, ARMENIAN, 3 /* DECIMAL */, defaultSuffix);
5663
- case 35 /* LOWER_ARMENIAN */:
5664
- return createAdditiveCounter(value, 1, 9999, ARMENIAN, 3 /* DECIMAL */, defaultSuffix).toLowerCase();
5665
- case 13 /* BENGALI */:
6564
+ case 12 /* LIST_STYLE_TYPE.ARMENIAN */:
6565
+ case 49 /* LIST_STYLE_TYPE.UPPER_ARMENIAN */:
6566
+ return createAdditiveCounter(value, 1, 9999, ARMENIAN, 3 /* LIST_STYLE_TYPE.DECIMAL */, defaultSuffix);
6567
+ case 35 /* LIST_STYLE_TYPE.LOWER_ARMENIAN */:
6568
+ return createAdditiveCounter(value, 1, 9999, ARMENIAN, 3 /* LIST_STYLE_TYPE.DECIMAL */, defaultSuffix).toLowerCase();
6569
+ case 13 /* LIST_STYLE_TYPE.BENGALI */:
5666
6570
  return createCounterStyleFromRange(value, 2534, 2543, true, defaultSuffix);
5667
- case 14 /* CAMBODIAN */:
5668
- case 30 /* KHMER */:
6571
+ case 14 /* LIST_STYLE_TYPE.CAMBODIAN */:
6572
+ case 30 /* LIST_STYLE_TYPE.KHMER */:
5669
6573
  return createCounterStyleFromRange(value, 6112, 6121, true, defaultSuffix);
5670
- case 15 /* CJK_EARTHLY_BRANCH */:
6574
+ case 15 /* LIST_STYLE_TYPE.CJK_EARTHLY_BRANCH */:
5671
6575
  return createCounterStyleFromSymbols(value, '子丑寅卯辰巳午未申酉戌亥', cjkSuffix);
5672
- case 16 /* CJK_HEAVENLY_STEM */:
6576
+ case 16 /* LIST_STYLE_TYPE.CJK_HEAVENLY_STEM */:
5673
6577
  return createCounterStyleFromSymbols(value, '甲乙丙丁戊己庚辛壬癸', cjkSuffix);
5674
- case 17 /* CJK_IDEOGRAPHIC */:
5675
- case 48 /* TRAD_CHINESE_INFORMAL */:
6578
+ case 17 /* LIST_STYLE_TYPE.CJK_IDEOGRAPHIC */:
6579
+ case 48 /* LIST_STYLE_TYPE.TRAD_CHINESE_INFORMAL */:
5676
6580
  return createCJKCounter(value, '零一二三四五六七八九', CHINESE_INFORMAL_MULTIPLIERS, '負', cjkSuffix, CJK_TEN_COEFFICIENTS | CJK_TEN_HIGH_COEFFICIENTS | CJK_HUNDRED_COEFFICIENTS);
5677
- case 47 /* TRAD_CHINESE_FORMAL */:
6581
+ case 47 /* LIST_STYLE_TYPE.TRAD_CHINESE_FORMAL */:
5678
6582
  return createCJKCounter(value, '零壹貳參肆伍陸柒捌玖', CHINESE_FORMAL_MULTIPLIERS, '負', cjkSuffix, CJK_ZEROS | CJK_TEN_COEFFICIENTS | CJK_TEN_HIGH_COEFFICIENTS | CJK_HUNDRED_COEFFICIENTS);
5679
- case 42 /* SIMP_CHINESE_INFORMAL */:
6583
+ case 42 /* LIST_STYLE_TYPE.SIMP_CHINESE_INFORMAL */:
5680
6584
  return createCJKCounter(value, '零一二三四五六七八九', CHINESE_INFORMAL_MULTIPLIERS, '负', cjkSuffix, CJK_TEN_COEFFICIENTS | CJK_TEN_HIGH_COEFFICIENTS | CJK_HUNDRED_COEFFICIENTS);
5681
- case 41 /* SIMP_CHINESE_FORMAL */:
6585
+ case 41 /* LIST_STYLE_TYPE.SIMP_CHINESE_FORMAL */:
5682
6586
  return createCJKCounter(value, '零壹贰叁肆伍陆柒捌玖', CHINESE_FORMAL_MULTIPLIERS, '负', cjkSuffix, CJK_ZEROS | CJK_TEN_COEFFICIENTS | CJK_TEN_HIGH_COEFFICIENTS | CJK_HUNDRED_COEFFICIENTS);
5683
- case 26 /* JAPANESE_INFORMAL */:
6587
+ case 26 /* LIST_STYLE_TYPE.JAPANESE_INFORMAL */:
5684
6588
  return createCJKCounter(value, '〇一二三四五六七八九', '十百千万', JAPANESE_NEGATIVE, cjkSuffix, 0);
5685
- case 25 /* JAPANESE_FORMAL */:
6589
+ case 25 /* LIST_STYLE_TYPE.JAPANESE_FORMAL */:
5686
6590
  return createCJKCounter(value, '零壱弐参四伍六七八九', '拾百千万', JAPANESE_NEGATIVE, cjkSuffix, CJK_ZEROS | CJK_TEN_COEFFICIENTS | CJK_TEN_HIGH_COEFFICIENTS);
5687
- case 31 /* KOREAN_HANGUL_FORMAL */:
6591
+ case 31 /* LIST_STYLE_TYPE.KOREAN_HANGUL_FORMAL */:
5688
6592
  return createCJKCounter(value, '영일이삼사오육칠팔구', '십백천만', KOREAN_NEGATIVE, koreanSuffix, CJK_ZEROS | CJK_TEN_COEFFICIENTS | CJK_TEN_HIGH_COEFFICIENTS);
5689
- case 33 /* KOREAN_HANJA_INFORMAL */:
6593
+ case 33 /* LIST_STYLE_TYPE.KOREAN_HANJA_INFORMAL */:
5690
6594
  return createCJKCounter(value, '零一二三四五六七八九', '十百千萬', KOREAN_NEGATIVE, koreanSuffix, 0);
5691
- case 32 /* KOREAN_HANJA_FORMAL */:
6595
+ case 32 /* LIST_STYLE_TYPE.KOREAN_HANJA_FORMAL */:
5692
6596
  return createCJKCounter(value, '零壹貳參四五六七八九', '拾百千', KOREAN_NEGATIVE, koreanSuffix, CJK_ZEROS | CJK_TEN_COEFFICIENTS | CJK_TEN_HIGH_COEFFICIENTS);
5693
- case 18 /* DEVANAGARI */:
6597
+ case 18 /* LIST_STYLE_TYPE.DEVANAGARI */:
5694
6598
  return createCounterStyleFromRange(value, 0x966, 0x96f, true, defaultSuffix);
5695
- case 20 /* GEORGIAN */:
5696
- return createAdditiveCounter(value, 1, 19999, GEORGIAN, 3 /* DECIMAL */, defaultSuffix);
5697
- case 21 /* GUJARATI */:
6599
+ case 20 /* LIST_STYLE_TYPE.GEORGIAN */:
6600
+ return createAdditiveCounter(value, 1, 19999, GEORGIAN, 3 /* LIST_STYLE_TYPE.DECIMAL */, defaultSuffix);
6601
+ case 21 /* LIST_STYLE_TYPE.GUJARATI */:
5698
6602
  return createCounterStyleFromRange(value, 0xae6, 0xaef, true, defaultSuffix);
5699
- case 22 /* GURMUKHI */:
6603
+ case 22 /* LIST_STYLE_TYPE.GURMUKHI */:
5700
6604
  return createCounterStyleFromRange(value, 0xa66, 0xa6f, true, defaultSuffix);
5701
- case 22 /* HEBREW */:
5702
- return createAdditiveCounter(value, 1, 10999, HEBREW, 3 /* DECIMAL */, defaultSuffix);
5703
- case 23 /* HIRAGANA */:
6605
+ case 52 /* LIST_STYLE_TYPE.HEBREW */:
6606
+ return createAdditiveCounter(value, 1, 10999, HEBREW, 3 /* LIST_STYLE_TYPE.DECIMAL */, defaultSuffix);
6607
+ case 23 /* LIST_STYLE_TYPE.HIRAGANA */:
5704
6608
  return createCounterStyleFromSymbols(value, 'あいうえおかきくけこさしすせそたちつてとなにぬねのはひふへほまみむめもやゆよらりるれろわゐゑをん');
5705
- case 24 /* HIRAGANA_IROHA */:
6609
+ case 24 /* LIST_STYLE_TYPE.HIRAGANA_IROHA */:
5706
6610
  return createCounterStyleFromSymbols(value, 'いろはにほへとちりぬるをわかよたれそつねならむうゐのおくやまけふこえてあさきゆめみしゑひもせす');
5707
- case 27 /* KANNADA */:
6611
+ case 27 /* LIST_STYLE_TYPE.KANNADA */:
5708
6612
  return createCounterStyleFromRange(value, 0xce6, 0xcef, true, defaultSuffix);
5709
- case 28 /* KATAKANA */:
6613
+ case 28 /* LIST_STYLE_TYPE.KATAKANA */:
5710
6614
  return createCounterStyleFromSymbols(value, 'アイウエオカキクケコサシスセソタチツテトナニヌネノハヒフヘホマミムメモヤユヨラリルレロワヰヱヲン', cjkSuffix);
5711
- case 29 /* KATAKANA_IROHA */:
6615
+ case 29 /* LIST_STYLE_TYPE.KATAKANA_IROHA */:
5712
6616
  return createCounterStyleFromSymbols(value, 'イロハニホヘトチリヌルヲワカヨタレソツネナラムウヰノオクヤマケフコエテアサキユメミシヱヒモセス', cjkSuffix);
5713
- case 34 /* LAO */:
6617
+ case 34 /* LIST_STYLE_TYPE.LAO */:
5714
6618
  return createCounterStyleFromRange(value, 0xed0, 0xed9, true, defaultSuffix);
5715
- case 37 /* MONGOLIAN */:
6619
+ case 37 /* LIST_STYLE_TYPE.MONGOLIAN */:
5716
6620
  return createCounterStyleFromRange(value, 0x1810, 0x1819, true, defaultSuffix);
5717
- case 38 /* MYANMAR */:
6621
+ case 38 /* LIST_STYLE_TYPE.MYANMAR */:
5718
6622
  return createCounterStyleFromRange(value, 0x1040, 0x1049, true, defaultSuffix);
5719
- case 39 /* ORIYA */:
6623
+ case 39 /* LIST_STYLE_TYPE.ORIYA */:
5720
6624
  return createCounterStyleFromRange(value, 0xb66, 0xb6f, true, defaultSuffix);
5721
- case 40 /* PERSIAN */:
6625
+ case 40 /* LIST_STYLE_TYPE.PERSIAN */:
5722
6626
  return createCounterStyleFromRange(value, 0x6f0, 0x6f9, true, defaultSuffix);
5723
- case 43 /* TAMIL */:
6627
+ case 43 /* LIST_STYLE_TYPE.TAMIL */:
5724
6628
  return createCounterStyleFromRange(value, 0xbe6, 0xbef, true, defaultSuffix);
5725
- case 44 /* TELUGU */:
6629
+ case 44 /* LIST_STYLE_TYPE.TELUGU */:
5726
6630
  return createCounterStyleFromRange(value, 0xc66, 0xc6f, true, defaultSuffix);
5727
- case 45 /* THAI */:
6631
+ case 45 /* LIST_STYLE_TYPE.THAI */:
5728
6632
  return createCounterStyleFromRange(value, 0xe50, 0xe59, true, defaultSuffix);
5729
- case 46 /* TIBETAN */:
6633
+ case 46 /* LIST_STYLE_TYPE.TIBETAN */:
5730
6634
  return createCounterStyleFromRange(value, 0xf20, 0xf29, true, defaultSuffix);
5731
- case 3 /* DECIMAL */:
6635
+ case 3 /* LIST_STYLE_TYPE.DECIMAL */:
5732
6636
  default:
5733
6637
  return createCounterStyleFromRange(value, 48, 57, true, defaultSuffix);
5734
6638
  }
@@ -5778,7 +6682,7 @@ var DocumentCloner = /** @class */ (function () {
5778
6682
  onclone = this.options.onclone;
5779
6683
  referenceElement = this.clonedReferenceElement;
5780
6684
  if (typeof referenceElement === 'undefined') {
5781
- return [2 /*return*/, Promise.reject("Error finding the " + this.referenceElement.nodeName + " in the cloned document")];
6685
+ return [2 /*return*/, Promise.reject("Error finding the ".concat(this.referenceElement.nodeName, " in the cloned document"))];
5782
6686
  }
5783
6687
  if (!(documentClone.fonts && documentClone.fonts.ready)) return [3 /*break*/, 2];
5784
6688
  return [4 /*yield*/, documentClone.fonts.ready];
@@ -5801,16 +6705,33 @@ var DocumentCloner = /** @class */ (function () {
5801
6705
  }
5802
6706
  });
5803
6707
  }); });
6708
+ /**
6709
+ * The baseURI of the document will be lost after documentClone.open().
6710
+ * We save it before open() to preserve the original base URI for resource resolution.
6711
+ * */
6712
+ var baseUri = documentClone.baseURI;
5804
6713
  documentClone.open();
5805
- documentClone.write(serializeDoctype(document.doctype) + "<html></html>");
6714
+ documentClone.write("".concat(serializeDoctype(document.doctype), "<html></html>"));
5806
6715
  // Chrome scrolls the parent document for some reason after the write to the cloned window???
5807
6716
  restoreOwnerScroll(this.referenceElement.ownerDocument, scrollX, scrollY);
5808
- documentClone.replaceChild(documentClone.adoptNode(this.documentElement), documentClone.documentElement);
6717
+ /**
6718
+ * Note: adoptNode() should be called AFTER documentClone.open() and close()
6719
+ *
6720
+ * In Chrome, calling adoptNode() before or during open/write may cause
6721
+ * styles with uppercase characters in class names (e.g. ".MyClass") to not apply correctly.
6722
+ *
6723
+ * Fix:
6724
+ * - Make sure adoptNode() is called after documentClone.open() and close()
6725
+ * - This allows Chrome to properly match and apply all CSS rules including mixed-case class selectors.
6726
+ * */
6727
+ var adoptedNode = documentClone.adoptNode(this.documentElement);
6728
+ addBase(adoptedNode, baseUri);
6729
+ documentClone.replaceChild(adoptedNode, documentClone.documentElement);
5809
6730
  documentClone.close();
5810
6731
  return iframeLoad;
5811
6732
  };
5812
6733
  DocumentCloner.prototype.createElementClone = function (node) {
5813
- if (isDebugging(node, 2 /* CLONE */)) {
6734
+ if (isDebugging(node, 2 /* DebuggerType.CLONE */)) {
5814
6735
  debugger;
5815
6736
  }
5816
6737
  if (isCanvasElement(node)) {
@@ -5883,7 +6804,7 @@ var DocumentCloner = /** @class */ (function () {
5883
6804
  clonedCanvas.width = canvas.width;
5884
6805
  clonedCanvas.height = canvas.height;
5885
6806
  var ctx = canvas.getContext('2d');
5886
- var clonedCtx = clonedCanvas.getContext('2d');
6807
+ var clonedCtx = clonedCanvas.getContext('2d', { willReadFrequently: true });
5887
6808
  if (clonedCtx) {
5888
6809
  if (!this.options.allowTaint && ctx) {
5889
6810
  clonedCtx.putImageData(ctx.getImageData(0, 0, canvas.width, canvas.height), 0, 0);
@@ -6018,16 +6939,16 @@ var DocumentCloner = /** @class */ (function () {
6018
6939
  var anonymousReplacedElement = document.createElement('html2canvaspseudoelement');
6019
6940
  copyCSSStyles(style, anonymousReplacedElement);
6020
6941
  declaration.content.forEach(function (token) {
6021
- if (token.type === 0 /* STRING_TOKEN */) {
6942
+ if (token.type === 0 /* TokenType.STRING_TOKEN */) {
6022
6943
  anonymousReplacedElement.appendChild(document.createTextNode(token.value));
6023
6944
  }
6024
- else if (token.type === 22 /* URL_TOKEN */) {
6945
+ else if (token.type === 22 /* TokenType.URL_TOKEN */) {
6025
6946
  var img = document.createElement('img');
6026
6947
  img.src = token.value;
6027
6948
  img.style.opacity = '1';
6028
6949
  anonymousReplacedElement.appendChild(img);
6029
6950
  }
6030
- else if (token.type === 18 /* FUNCTION */) {
6951
+ else if (token.type === 18 /* TokenType.FUNCTION */) {
6031
6952
  if (token.name === 'attr') {
6032
6953
  var attr = token.values.filter(isIdentToken);
6033
6954
  if (attr.length) {
@@ -6040,7 +6961,7 @@ var DocumentCloner = /** @class */ (function () {
6040
6961
  var counterState = _this.counters.getCounterValue(counter.value);
6041
6962
  var counterType = counterStyle && isIdentToken(counterStyle)
6042
6963
  ? listStyleType.parse(_this.context, counterStyle.value)
6043
- : 3 /* DECIMAL */;
6964
+ : 3 /* LIST_STYLE_TYPE.DECIMAL */;
6044
6965
  anonymousReplacedElement.appendChild(document.createTextNode(createCounterText(counterState, counterType, false)));
6045
6966
  }
6046
6967
  }
@@ -6050,8 +6971,8 @@ var DocumentCloner = /** @class */ (function () {
6050
6971
  var counterStates = _this.counters.getCounterValues(counter.value);
6051
6972
  var counterType_1 = counterStyle && isIdentToken(counterStyle)
6052
6973
  ? listStyleType.parse(_this.context, counterStyle.value)
6053
- : 3 /* DECIMAL */;
6054
- var separator = delim && delim.type === 0 /* STRING_TOKEN */ ? delim.value : '';
6974
+ : 3 /* LIST_STYLE_TYPE.DECIMAL */;
6975
+ var separator = delim && delim.type === 0 /* TokenType.STRING_TOKEN */ ? delim.value : '';
6055
6976
  var text = counterStates
6056
6977
  .map(function (value) { return createCounterText(value, counterType_1, false); })
6057
6978
  .join(separator);
@@ -6060,7 +6981,7 @@ var DocumentCloner = /** @class */ (function () {
6060
6981
  }
6061
6982
  else ;
6062
6983
  }
6063
- else if (token.type === 20 /* IDENT_TOKEN */) {
6984
+ else if (token.type === 20 /* TokenType.IDENT_TOKEN */) {
6064
6985
  switch (token.value) {
6065
6986
  case 'open-quote':
6066
6987
  anonymousReplacedElement.appendChild(document.createTextNode(getQuote(declaration.quotes, _this.quoteDepth++, true)));
@@ -6074,10 +6995,10 @@ var DocumentCloner = /** @class */ (function () {
6074
6995
  }
6075
6996
  }
6076
6997
  });
6077
- anonymousReplacedElement.className = PSEUDO_HIDE_ELEMENT_CLASS_BEFORE + " " + PSEUDO_HIDE_ELEMENT_CLASS_AFTER;
6998
+ anonymousReplacedElement.className = "".concat(PSEUDO_HIDE_ELEMENT_CLASS_BEFORE, " ").concat(PSEUDO_HIDE_ELEMENT_CLASS_AFTER);
6078
6999
  var newClassName = pseudoElt === PseudoElementType.BEFORE
6079
- ? " " + PSEUDO_HIDE_ELEMENT_CLASS_BEFORE
6080
- : " " + PSEUDO_HIDE_ELEMENT_CLASS_AFTER;
7000
+ ? " ".concat(PSEUDO_HIDE_ELEMENT_CLASS_BEFORE)
7001
+ : " ".concat(PSEUDO_HIDE_ELEMENT_CLASS_AFTER);
6081
7002
  if (isSVGElementNode(clone)) {
6082
7003
  clone.className.baseValue += newClassName;
6083
7004
  }
@@ -6151,8 +7072,8 @@ var iframeLoader = function (iframe) {
6151
7072
  });
6152
7073
  };
6153
7074
  var ignoredStyleProperties = [
6154
- 'all',
6155
- 'd',
7075
+ 'all', // #2476
7076
+ 'd', // #2483
6156
7077
  'content' // Safari shows pseudoelements if content is set
6157
7078
  ];
6158
7079
  var copyCSSStyles = function (style, target) {
@@ -6176,10 +7097,10 @@ var serializeDoctype = function (doctype) {
6176
7097
  str += doctype.internalSubset;
6177
7098
  }
6178
7099
  if (doctype.publicId) {
6179
- str += "\"" + doctype.publicId + "\"";
7100
+ str += "\"".concat(doctype.publicId, "\"");
6180
7101
  }
6181
7102
  if (doctype.systemId) {
6182
- str += "\"" + doctype.systemId + "\"";
7103
+ str += "\"".concat(doctype.systemId, "\"");
6183
7104
  }
6184
7105
  str += '>';
6185
7106
  }
@@ -6203,7 +7124,7 @@ var PSEUDO_HIDE_ELEMENT_CLASS_BEFORE = '___html2canvas___pseudoelement_before';
6203
7124
  var PSEUDO_HIDE_ELEMENT_CLASS_AFTER = '___html2canvas___pseudoelement_after';
6204
7125
  var PSEUDO_HIDE_ELEMENT_STYLE = "{\n content: \"\" !important;\n display: none !important;\n}";
6205
7126
  var createPseudoHideStyles = function (body) {
6206
- 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);
7127
+ createStyles(body, ".".concat(PSEUDO_HIDE_ELEMENT_CLASS_BEFORE).concat(PSEUDO_BEFORE).concat(PSEUDO_HIDE_ELEMENT_STYLE, "\n .").concat(PSEUDO_HIDE_ELEMENT_CLASS_AFTER).concat(PSEUDO_AFTER).concat(PSEUDO_HIDE_ELEMENT_STYLE));
6207
7128
  };
6208
7129
  var createStyles = function (body, styles) {
6209
7130
  var document = body.ownerDocument;
@@ -6213,6 +7134,13 @@ var createStyles = function (body, styles) {
6213
7134
  body.appendChild(style);
6214
7135
  }
6215
7136
  };
7137
+ var addBase = function (targetELement, baseUri) {
7138
+ var _a;
7139
+ var baseNode = targetELement.ownerDocument.createElement('base');
7140
+ baseNode.href = baseUri;
7141
+ var headEle = targetELement.getElementsByTagName('head').item(0);
7142
+ headEle === null || headEle === void 0 ? void 0 : headEle.insertBefore(baseNode, (_a = headEle === null || headEle === void 0 ? void 0 : headEle.firstChild) !== null && _a !== void 0 ? _a : null);
7143
+ };
6216
7144
 
6217
7145
  var CacheStorage = /** @class */ (function () {
6218
7146
  function CacheStorage() {
@@ -6262,12 +7190,21 @@ var Cache = /** @class */ (function () {
6262
7190
  };
6263
7191
  Cache.prototype.loadImage = function (key) {
6264
7192
  return __awaiter(this, void 0, void 0, function () {
6265
- var isSameOrigin, useCORS, useProxy, src;
7193
+ var isSameOrigin, _a, useCORS, useProxy, src;
6266
7194
  var _this = this;
6267
- return __generator(this, function (_a) {
6268
- switch (_a.label) {
7195
+ return __generator(this, function (_b) {
7196
+ switch (_b.label) {
6269
7197
  case 0:
6270
- isSameOrigin = CacheStorage.isSameOrigin(key);
7198
+ if (!(typeof this._options.customIsSameOrigin === 'function')) return [3 /*break*/, 2];
7199
+ return [4 /*yield*/, this._options.customIsSameOrigin(key, CacheStorage.isSameOrigin)];
7200
+ case 1:
7201
+ _a = _b.sent();
7202
+ return [3 /*break*/, 3];
7203
+ case 2:
7204
+ _a = CacheStorage.isSameOrigin(key);
7205
+ _b.label = 3;
7206
+ case 3:
7207
+ isSameOrigin = _a;
6271
7208
  useCORS = !isInlineImage(key) && this._options.useCORS === true && FEATURES.SUPPORT_CORS_IMAGES && !isSameOrigin;
6272
7209
  useProxy = !isInlineImage(key) &&
6273
7210
  !isSameOrigin &&
@@ -6284,13 +7221,13 @@ var Cache = /** @class */ (function () {
6284
7221
  return [2 /*return*/];
6285
7222
  }
6286
7223
  src = key;
6287
- if (!useProxy) return [3 /*break*/, 2];
7224
+ if (!useProxy) return [3 /*break*/, 5];
6288
7225
  return [4 /*yield*/, this.proxy(src)];
6289
- case 1:
6290
- src = _a.sent();
6291
- _a.label = 2;
6292
- case 2:
6293
- this.context.logger.debug("Added image " + key.substring(0, 256));
7226
+ case 4:
7227
+ src = _b.sent();
7228
+ _b.label = 5;
7229
+ case 5:
7230
+ this.context.logger.debug("Added image ".concat(key.substring(0, 256)));
6294
7231
  return [4 /*yield*/, new Promise(function (resolve, reject) {
6295
7232
  var img = new Image();
6296
7233
  img.onload = function () { return resolve(img); };
@@ -6305,10 +7242,10 @@ var Cache = /** @class */ (function () {
6305
7242
  setTimeout(function () { return resolve(img); }, 500);
6306
7243
  }
6307
7244
  if (_this._options.imageTimeout > 0) {
6308
- setTimeout(function () { return reject("Timed out (" + _this._options.imageTimeout + "ms) loading image"); }, _this._options.imageTimeout);
7245
+ setTimeout(function () { return reject("Timed out (".concat(_this._options.imageTimeout, "ms) loading image")); }, _this._options.imageTimeout);
6309
7246
  }
6310
7247
  })];
6311
- case 3: return [2 /*return*/, _a.sent()];
7248
+ case 6: return [2 /*return*/, _b.sent()];
6312
7249
  }
6313
7250
  });
6314
7251
  });
@@ -6342,19 +7279,19 @@ var Cache = /** @class */ (function () {
6342
7279
  }
6343
7280
  }
6344
7281
  else {
6345
- reject("Failed to proxy resource " + key + " with status code " + xhr.status);
7282
+ reject("Failed to proxy resource ".concat(key, " with status code ").concat(xhr.status));
6346
7283
  }
6347
7284
  };
6348
7285
  xhr.onerror = reject;
6349
7286
  var queryString = proxy.indexOf('?') > -1 ? '&' : '?';
6350
- xhr.open('GET', "" + proxy + queryString + "url=" + encodeURIComponent(src) + "&responseType=" + responseType);
7287
+ xhr.open('GET', "".concat(proxy).concat(queryString, "url=").concat(encodeURIComponent(src), "&responseType=").concat(responseType));
6351
7288
  if (responseType !== 'text' && xhr instanceof XMLHttpRequest) {
6352
7289
  xhr.responseType = responseType;
6353
7290
  }
6354
7291
  if (_this._options.imageTimeout) {
6355
7292
  var timeout_1 = _this._options.imageTimeout;
6356
7293
  xhr.timeout = timeout_1;
6357
- xhr.ontimeout = function () { return reject("Timed out (" + timeout_1 + "ms) proxying " + key); };
7294
+ xhr.ontimeout = function () { return reject("Timed out (".concat(timeout_1, "ms) proxying ").concat(key)); };
6358
7295
  }
6359
7296
  xhr.send();
6360
7297
  });
@@ -6372,7 +7309,7 @@ var isSVG = function (src) { return src.substr(-3).toLowerCase() === 'svg' || IN
6372
7309
 
6373
7310
  var Vector = /** @class */ (function () {
6374
7311
  function Vector(x, y) {
6375
- this.type = 0 /* VECTOR */;
7312
+ this.type = 0 /* PathType.VECTOR */;
6376
7313
  this.x = x;
6377
7314
  this.y = y;
6378
7315
  }
@@ -6387,7 +7324,7 @@ var lerp = function (a, b, t) {
6387
7324
  };
6388
7325
  var BezierCurve = /** @class */ (function () {
6389
7326
  function BezierCurve(start, startControl, endControl, end) {
6390
- this.type = 1 /* BEZIER_CURVE */;
7327
+ this.type = 1 /* PathType.BEZIER_CURVE */;
6391
7328
  this.start = start;
6392
7329
  this.startControl = startControl;
6393
7330
  this.endControl = endControl;
@@ -6410,7 +7347,7 @@ var BezierCurve = /** @class */ (function () {
6410
7347
  };
6411
7348
  return BezierCurve;
6412
7349
  }());
6413
- var isBezierCurve = function (path) { return path.type === 1 /* BEZIER_CURVE */; };
7350
+ var isBezierCurve = function (path) { return path.type === 1 /* PathType.BEZIER_CURVE */; };
6414
7351
 
6415
7352
  var BoundCurves = /** @class */ (function () {
6416
7353
  function BoundCurves(element) {
@@ -6597,8 +7534,8 @@ var TransformEffect = /** @class */ (function () {
6597
7534
  this.offsetX = offsetX;
6598
7535
  this.offsetY = offsetY;
6599
7536
  this.matrix = matrix;
6600
- this.type = 0 /* TRANSFORM */;
6601
- this.target = 2 /* BACKGROUND_BORDERS */ | 4 /* CONTENT */;
7537
+ this.type = 0 /* EffectType.TRANSFORM */;
7538
+ this.target = 2 /* EffectTarget.BACKGROUND_BORDERS */ | 4 /* EffectTarget.CONTENT */;
6602
7539
  }
6603
7540
  return TransformEffect;
6604
7541
  }());
@@ -6606,23 +7543,23 @@ var ClipEffect = /** @class */ (function () {
6606
7543
  function ClipEffect(path, target) {
6607
7544
  this.path = path;
6608
7545
  this.target = target;
6609
- this.type = 1 /* CLIP */;
7546
+ this.type = 1 /* EffectType.CLIP */;
6610
7547
  }
6611
7548
  return ClipEffect;
6612
7549
  }());
6613
7550
  var OpacityEffect = /** @class */ (function () {
6614
7551
  function OpacityEffect(opacity) {
6615
7552
  this.opacity = opacity;
6616
- this.type = 2 /* OPACITY */;
6617
- this.target = 2 /* BACKGROUND_BORDERS */ | 4 /* CONTENT */;
7553
+ this.type = 2 /* EffectType.OPACITY */;
7554
+ this.target = 2 /* EffectTarget.BACKGROUND_BORDERS */ | 4 /* EffectTarget.CONTENT */;
6618
7555
  }
6619
7556
  return OpacityEffect;
6620
7557
  }());
6621
7558
  var isTransformEffect = function (effect) {
6622
- return effect.type === 0 /* TRANSFORM */;
7559
+ return effect.type === 0 /* EffectType.TRANSFORM */;
6623
7560
  };
6624
- var isClipEffect = function (effect) { return effect.type === 1 /* CLIP */; };
6625
- var isOpacityEffect = function (effect) { return effect.type === 2 /* OPACITY */; };
7561
+ var isClipEffect = function (effect) { return effect.type === 1 /* EffectType.CLIP */; };
7562
+ var isOpacityEffect = function (effect) { return effect.type === 2 /* EffectType.OPACITY */; };
6626
7563
 
6627
7564
  var equalPath = function (a, b) {
6628
7565
  if (a.length === b.length) {
@@ -6668,40 +7605,51 @@ var ElementPaint = /** @class */ (function () {
6668
7605
  if (this.container.styles.opacity < 1) {
6669
7606
  this.effects.push(new OpacityEffect(this.container.styles.opacity));
6670
7607
  }
7608
+ if (this.container.styles.rotate !== null) {
7609
+ var offsetX = this.container.bounds.left + this.container.styles.transformOrigin[0].number;
7610
+ var offsetY = this.container.bounds.top + this.container.styles.transformOrigin[1].number;
7611
+ // Apply rotate property if present
7612
+ var angle = this.container.styles.rotate;
7613
+ var rad = (angle * Math.PI) / 180;
7614
+ var cos = Math.cos(rad);
7615
+ var sin = Math.sin(rad);
7616
+ var rotateMatrix = [cos, sin, -sin, cos, 0, 0];
7617
+ this.effects.push(new TransformEffect(offsetX, offsetY, rotateMatrix));
7618
+ }
6671
7619
  if (this.container.styles.transform !== null) {
6672
7620
  var offsetX = this.container.bounds.left + this.container.styles.transformOrigin[0].number;
6673
7621
  var offsetY = this.container.bounds.top + this.container.styles.transformOrigin[1].number;
6674
7622
  var matrix = this.container.styles.transform;
6675
7623
  this.effects.push(new TransformEffect(offsetX, offsetY, matrix));
6676
7624
  }
6677
- if (this.container.styles.overflowX !== 0 /* VISIBLE */) {
7625
+ if (this.container.styles.overflowX !== 0 /* OVERFLOW.VISIBLE */) {
6678
7626
  var borderBox = calculateBorderBoxPath(this.curves);
6679
7627
  var paddingBox = calculatePaddingBoxPath(this.curves);
6680
7628
  if (equalPath(borderBox, paddingBox)) {
6681
- this.effects.push(new ClipEffect(borderBox, 2 /* BACKGROUND_BORDERS */ | 4 /* CONTENT */));
7629
+ this.effects.push(new ClipEffect(borderBox, 2 /* EffectTarget.BACKGROUND_BORDERS */ | 4 /* EffectTarget.CONTENT */));
6682
7630
  }
6683
7631
  else {
6684
- this.effects.push(new ClipEffect(borderBox, 2 /* BACKGROUND_BORDERS */));
6685
- this.effects.push(new ClipEffect(paddingBox, 4 /* CONTENT */));
7632
+ this.effects.push(new ClipEffect(borderBox, 2 /* EffectTarget.BACKGROUND_BORDERS */));
7633
+ this.effects.push(new ClipEffect(paddingBox, 4 /* EffectTarget.CONTENT */));
6686
7634
  }
6687
7635
  }
6688
7636
  }
6689
7637
  ElementPaint.prototype.getEffects = function (target) {
6690
- var inFlow = [2 /* ABSOLUTE */, 3 /* FIXED */].indexOf(this.container.styles.position) === -1;
7638
+ var inFlow = [2 /* POSITION.ABSOLUTE */, 3 /* POSITION.FIXED */].indexOf(this.container.styles.position) === -1;
6691
7639
  var parent = this.parent;
6692
7640
  var effects = this.effects.slice(0);
6693
7641
  while (parent) {
6694
7642
  var croplessEffects = parent.effects.filter(function (effect) { return !isClipEffect(effect); });
6695
- if (inFlow || parent.container.styles.position !== 0 /* STATIC */ || !parent.parent) {
6696
- effects.unshift.apply(effects, croplessEffects);
6697
- inFlow = [2 /* ABSOLUTE */, 3 /* FIXED */].indexOf(parent.container.styles.position) === -1;
6698
- if (parent.container.styles.overflowX !== 0 /* VISIBLE */) {
7643
+ if (inFlow || parent.container.styles.position !== 0 /* POSITION.STATIC */ || !parent.parent) {
7644
+ inFlow = [2 /* POSITION.ABSOLUTE */, 3 /* POSITION.FIXED */].indexOf(parent.container.styles.position) === -1;
7645
+ if (parent.container.styles.overflowX !== 0 /* OVERFLOW.VISIBLE */) {
6699
7646
  var borderBox = calculateBorderBoxPath(parent.curves);
6700
7647
  var paddingBox = calculatePaddingBoxPath(parent.curves);
6701
7648
  if (!equalPath(borderBox, paddingBox)) {
6702
- effects.unshift(new ClipEffect(paddingBox, 2 /* BACKGROUND_BORDERS */ | 4 /* CONTENT */));
7649
+ effects.unshift(new ClipEffect(paddingBox, 2 /* EffectTarget.BACKGROUND_BORDERS */ | 4 /* EffectTarget.CONTENT */));
6703
7650
  }
6704
7651
  }
7652
+ effects.unshift.apply(effects, croplessEffects);
6705
7653
  }
6706
7654
  else {
6707
7655
  effects.unshift.apply(effects, croplessEffects);
@@ -6714,13 +7662,13 @@ var ElementPaint = /** @class */ (function () {
6714
7662
  }());
6715
7663
  var parseStackTree = function (parent, stackingContext, realStackingContext, listItems) {
6716
7664
  parent.container.elements.forEach(function (child) {
6717
- var treatAsRealStackingContext = contains(child.flags, 4 /* CREATES_REAL_STACKING_CONTEXT */);
6718
- var createsStackingContext = contains(child.flags, 2 /* CREATES_STACKING_CONTEXT */);
7665
+ var treatAsRealStackingContext = contains(child.flags, 4 /* FLAGS.CREATES_REAL_STACKING_CONTEXT */);
7666
+ var createsStackingContext = contains(child.flags, 2 /* FLAGS.CREATES_STACKING_CONTEXT */);
6719
7667
  var paintContainer = new ElementPaint(child, parent);
6720
- if (contains(child.styles.display, 2048 /* LIST_ITEM */)) {
7668
+ if (contains(child.styles.display, 2048 /* DISPLAY.LIST_ITEM */)) {
6721
7669
  listItems.push(paintContainer);
6722
7670
  }
6723
- var listOwnerItems = contains(child.flags, 8 /* IS_LIST_OWNER */) ? [] : listItems;
7671
+ var listOwnerItems = contains(child.flags, 8 /* FLAGS.IS_LIST_OWNER */) ? [] : listItems;
6724
7672
  if (treatAsRealStackingContext || createsStackingContext) {
6725
7673
  var parentStack = treatAsRealStackingContext || child.styles.isPositioned() ? realStackingContext : stackingContext;
6726
7674
  var stack = new StackingContext(paintContainer);
@@ -6777,7 +7725,7 @@ var parseStackTree = function (parent, stackingContext, realStackingContext, lis
6777
7725
  }
6778
7726
  parseStackTree(paintContainer, stackingContext, realStackingContext, listOwnerItems);
6779
7727
  }
6780
- if (contains(child.flags, 8 /* IS_LIST_OWNER */)) {
7728
+ if (contains(child.flags, 8 /* FLAGS.IS_LIST_OWNER */)) {
6781
7729
  processListItems(child, listOwnerItems);
6782
7730
  }
6783
7731
  });
@@ -6918,19 +7866,19 @@ var contentBox = function (element) {
6918
7866
  };
6919
7867
 
6920
7868
  var calculateBackgroundPositioningArea = function (backgroundOrigin, element) {
6921
- if (backgroundOrigin === 0 /* BORDER_BOX */) {
7869
+ if (backgroundOrigin === 0 /* BACKGROUND_ORIGIN.BORDER_BOX */) {
6922
7870
  return element.bounds;
6923
7871
  }
6924
- if (backgroundOrigin === 2 /* CONTENT_BOX */) {
7872
+ if (backgroundOrigin === 2 /* BACKGROUND_ORIGIN.CONTENT_BOX */) {
6925
7873
  return contentBox(element);
6926
7874
  }
6927
7875
  return paddingBox(element);
6928
7876
  };
6929
7877
  var calculateBackgroundPaintingArea = function (backgroundClip, element) {
6930
- if (backgroundClip === 0 /* BORDER_BOX */) {
7878
+ if (backgroundClip === 0 /* BACKGROUND_CLIP.BORDER_BOX */) {
6931
7879
  return element.bounds;
6932
7880
  }
6933
- if (backgroundClip === 2 /* CONTENT_BOX */) {
7881
+ if (backgroundClip === 2 /* BACKGROUND_CLIP.CONTENT_BOX */) {
6934
7882
  return contentBox(element);
6935
7883
  }
6936
7884
  return paddingBox(element);
@@ -6944,6 +7892,8 @@ var calculateBackgroundRendering = function (container, index, intrinsicSize) {
6944
7892
  var path = calculateBackgroundRepeatPath(getBackgroundValueForIndex(container.styles.backgroundRepeat, index), position, backgroundImageSize, backgroundPositioningArea, backgroundPaintingArea);
6945
7893
  var offsetX = Math.round(backgroundPositioningArea.left + position[0]);
6946
7894
  var offsetY = Math.round(backgroundPositioningArea.top + position[1]);
7895
+ sizeWidth = Math.max(1, sizeWidth);
7896
+ sizeHeight = Math.max(1, sizeHeight);
6947
7897
  return [path, offsetX, offsetY, sizeWidth, sizeHeight];
6948
7898
  };
6949
7899
  var isAuto = function (token) { return isIdentToken(token) && token.value === BACKGROUND_SIZE.AUTO; };
@@ -7058,21 +8008,21 @@ var calculateBackgroundRepeatPath = function (repeat, _a, _b, backgroundPosition
7058
8008
  var x = _a[0], y = _a[1];
7059
8009
  var width = _b[0], height = _b[1];
7060
8010
  switch (repeat) {
7061
- case 2 /* REPEAT_X */:
8011
+ case 2 /* BACKGROUND_REPEAT.REPEAT_X */:
7062
8012
  return [
7063
8013
  new Vector(Math.round(backgroundPositioningArea.left), Math.round(backgroundPositioningArea.top + y)),
7064
8014
  new Vector(Math.round(backgroundPositioningArea.left + backgroundPositioningArea.width), Math.round(backgroundPositioningArea.top + y)),
7065
8015
  new Vector(Math.round(backgroundPositioningArea.left + backgroundPositioningArea.width), Math.round(height + backgroundPositioningArea.top + y)),
7066
8016
  new Vector(Math.round(backgroundPositioningArea.left), Math.round(height + backgroundPositioningArea.top + y))
7067
8017
  ];
7068
- case 3 /* REPEAT_Y */:
8018
+ case 3 /* BACKGROUND_REPEAT.REPEAT_Y */:
7069
8019
  return [
7070
8020
  new Vector(Math.round(backgroundPositioningArea.left + x), Math.round(backgroundPositioningArea.top)),
7071
8021
  new Vector(Math.round(backgroundPositioningArea.left + x + width), Math.round(backgroundPositioningArea.top)),
7072
8022
  new Vector(Math.round(backgroundPositioningArea.left + x + width), Math.round(backgroundPositioningArea.height + backgroundPositioningArea.top)),
7073
8023
  new Vector(Math.round(backgroundPositioningArea.left + x), Math.round(backgroundPositioningArea.height + backgroundPositioningArea.top))
7074
8024
  ];
7075
- case 1 /* NO_REPEAT */:
8025
+ case 1 /* BACKGROUND_REPEAT.NO_REPEAT */:
7076
8026
  return [
7077
8027
  new Vector(Math.round(backgroundPositioningArea.left + x), Math.round(backgroundPositioningArea.top + y)),
7078
8028
  new Vector(Math.round(backgroundPositioningArea.left + x + width), Math.round(backgroundPositioningArea.top + y)),
@@ -7132,7 +8082,7 @@ var FontMetrics = /** @class */ (function () {
7132
8082
  return { baseline: baseline, middle: middle };
7133
8083
  };
7134
8084
  FontMetrics.prototype.getMetrics = function (fontFamily, fontSize) {
7135
- var key = fontFamily + " " + fontSize;
8085
+ var key = "".concat(fontFamily, " ").concat(fontSize);
7136
8086
  if (typeof this._data[key] === 'undefined') {
7137
8087
  this._data[key] = this.parseMetrics(fontFamily, fontSize);
7138
8088
  }
@@ -7160,15 +8110,15 @@ var CanvasRenderer = /** @class */ (function (_super) {
7160
8110
  if (!options.canvas) {
7161
8111
  _this.canvas.width = Math.floor(options.width * options.scale);
7162
8112
  _this.canvas.height = Math.floor(options.height * options.scale);
7163
- _this.canvas.style.width = options.width + "px";
7164
- _this.canvas.style.height = options.height + "px";
8113
+ _this.canvas.style.width = "".concat(options.width, "px");
8114
+ _this.canvas.style.height = "".concat(options.height, "px");
7165
8115
  }
7166
8116
  _this.fontMetrics = new FontMetrics(document);
7167
8117
  _this.ctx.scale(_this.options.scale, _this.options.scale);
7168
8118
  _this.ctx.translate(-options.x, -options.y);
7169
8119
  _this.ctx.textBaseline = 'bottom';
7170
8120
  _this._activeEffects = [];
7171
- _this.context.logger.debug("Canvas renderer initialized (" + options.width + "x" + options.height + ") with scale " + options.scale);
8121
+ _this.context.logger.debug("Canvas renderer initialized (".concat(options.width, "x").concat(options.height, ") with scale ").concat(options.scale));
7172
8122
  return _this;
7173
8123
  }
7174
8124
  CanvasRenderer.prototype.applyEffects = function (effects) {
@@ -7220,7 +8170,7 @@ var CanvasRenderer = /** @class */ (function (_super) {
7220
8170
  return __generator(this, function (_a) {
7221
8171
  switch (_a.label) {
7222
8172
  case 0:
7223
- if (contains(paint.container.flags, 16 /* DEBUG_RENDER */)) {
8173
+ if (contains(paint.container.flags, 16 /* FLAGS.DEBUG_RENDER */)) {
7224
8174
  debugger;
7225
8175
  }
7226
8176
  if (!paint.container.styles.isVisible()) return [3 /*break*/, 3];
@@ -7239,7 +8189,15 @@ var CanvasRenderer = /** @class */ (function (_super) {
7239
8189
  CanvasRenderer.prototype.renderTextWithLetterSpacing = function (text, letterSpacing, baseline) {
7240
8190
  var _this = this;
7241
8191
  if (letterSpacing === 0) {
7242
- this.ctx.fillText(text.text, text.bounds.left, text.bounds.top + baseline);
8192
+ // Fixed an issue with characters moving up in non-Firefox.
8193
+ // https://github.com/niklasvh/html2canvas/issues/2107#issuecomment-692462900
8194
+ if (navigator.userAgent.indexOf('Firefox') === -1) {
8195
+ this.ctx.textBaseline = 'ideographic';
8196
+ this.ctx.fillText(text.text, text.bounds.left, text.bounds.top + text.bounds.height);
8197
+ }
8198
+ else {
8199
+ this.ctx.fillText(text.text, text.bounds.left, text.bounds.top + baseline);
8200
+ }
7243
8201
  }
7244
8202
  else {
7245
8203
  var letters = segmentGraphemes(text.text);
@@ -7255,8 +8213,8 @@ var CanvasRenderer = /** @class */ (function (_super) {
7255
8213
  .join('');
7256
8214
  var fontFamily = fixIOSSystemFonts(styles.fontFamily).join(', ');
7257
8215
  var fontSize = isDimensionToken(styles.fontSize)
7258
- ? "" + styles.fontSize.number + styles.fontSize.unit
7259
- : styles.fontSize.number + "px";
8216
+ ? "".concat(styles.fontSize.number).concat(styles.fontSize.unit)
8217
+ : "".concat(styles.fontSize.number, "px");
7260
8218
  return [
7261
8219
  [styles.fontStyle, fontVariant, styles.fontWeight, fontSize, fontFamily].join(' '),
7262
8220
  fontFamily,
@@ -7265,22 +8223,21 @@ var CanvasRenderer = /** @class */ (function (_super) {
7265
8223
  };
7266
8224
  CanvasRenderer.prototype.renderTextNode = function (text, styles) {
7267
8225
  return __awaiter(this, void 0, void 0, function () {
7268
- var _a, font, fontFamily, fontSize, _b, baseline, middle, paintOrder;
8226
+ var font, paintOrder;
7269
8227
  var _this = this;
7270
- return __generator(this, function (_c) {
7271
- _a = this.createFontStyle(styles), font = _a[0], fontFamily = _a[1], fontSize = _a[2];
8228
+ return __generator(this, function (_a) {
8229
+ font = this.createFontStyle(styles)[0];
7272
8230
  this.ctx.font = font;
7273
- this.ctx.direction = styles.direction === 1 /* RTL */ ? 'rtl' : 'ltr';
8231
+ this.ctx.direction = styles.direction === 1 /* DIRECTION.RTL */ ? 'rtl' : 'ltr';
7274
8232
  this.ctx.textAlign = 'left';
7275
8233
  this.ctx.textBaseline = 'alphabetic';
7276
- _b = this.fontMetrics.getMetrics(fontFamily, fontSize), baseline = _b.baseline, middle = _b.middle;
7277
8234
  paintOrder = styles.paintOrder;
7278
8235
  text.textBounds.forEach(function (text) {
7279
8236
  paintOrder.forEach(function (paintOrderLayer) {
7280
8237
  switch (paintOrderLayer) {
7281
- case 0 /* FILL */:
8238
+ case 0 /* PAINT_ORDER_LAYER.FILL */:
7282
8239
  _this.ctx.fillStyle = asString(styles.color);
7283
- _this.renderTextWithLetterSpacing(text, styles.letterSpacing, baseline);
8240
+ _this.renderTextWithLetterSpacing(text, styles.letterSpacing, styles.fontSize.number);
7284
8241
  var textShadows = styles.textShadow;
7285
8242
  if (textShadows.length && text.text.trim().length) {
7286
8243
  textShadows
@@ -7291,7 +8248,7 @@ var CanvasRenderer = /** @class */ (function (_super) {
7291
8248
  _this.ctx.shadowOffsetX = textShadow.offsetX.number * _this.options.scale;
7292
8249
  _this.ctx.shadowOffsetY = textShadow.offsetY.number * _this.options.scale;
7293
8250
  _this.ctx.shadowBlur = textShadow.blur.number;
7294
- _this.renderTextWithLetterSpacing(text, styles.letterSpacing, baseline);
8251
+ _this.renderTextWithLetterSpacing(text, styles.letterSpacing, styles.fontSize.number);
7295
8252
  });
7296
8253
  _this.ctx.shadowColor = '';
7297
8254
  _this.ctx.shadowOffsetX = 0;
@@ -7300,32 +8257,30 @@ var CanvasRenderer = /** @class */ (function (_super) {
7300
8257
  }
7301
8258
  if (styles.textDecorationLine.length) {
7302
8259
  _this.ctx.fillStyle = asString(styles.textDecorationColor || styles.color);
8260
+ var decorationLineHeight_1 = 1;
7303
8261
  styles.textDecorationLine.forEach(function (textDecorationLine) {
8262
+ // Fix the issue where textDecorationLine exhibits x-axis positioning errors on high-resolution devices due to varying devicePixelRatio, corrected by using relative values of element heights.
7304
8263
  switch (textDecorationLine) {
7305
- case 1 /* UNDERLINE */:
7306
- // Draws a line at the baseline of the font
7307
- // TODO As some browsers display the line as more than 1px if the font-size is big,
7308
- // need to take that into account both in position and size
7309
- _this.ctx.fillRect(text.bounds.left, Math.round(text.bounds.top + baseline), text.bounds.width, 1);
8264
+ case 1 /* TEXT_DECORATION_LINE.UNDERLINE */:
8265
+ _this.ctx.fillRect(text.bounds.left, text.bounds.top + text.bounds.height - decorationLineHeight_1, text.bounds.width, decorationLineHeight_1);
7310
8266
  break;
7311
- case 2 /* OVERLINE */:
7312
- _this.ctx.fillRect(text.bounds.left, Math.round(text.bounds.top), text.bounds.width, 1);
8267
+ case 2 /* TEXT_DECORATION_LINE.OVERLINE */:
8268
+ _this.ctx.fillRect(text.bounds.left, text.bounds.top, text.bounds.width, decorationLineHeight_1);
7313
8269
  break;
7314
- case 3 /* LINE_THROUGH */:
7315
- // TODO try and find exact position for line-through
7316
- _this.ctx.fillRect(text.bounds.left, Math.ceil(text.bounds.top + middle), text.bounds.width, 1);
8270
+ case 3 /* TEXT_DECORATION_LINE.LINE_THROUGH */:
8271
+ _this.ctx.fillRect(text.bounds.left, text.bounds.top + (text.bounds.height / 2 - decorationLineHeight_1 / 2), text.bounds.width, decorationLineHeight_1);
7317
8272
  break;
7318
8273
  }
7319
8274
  });
7320
8275
  }
7321
8276
  break;
7322
- case 1 /* STROKE */:
8277
+ case 1 /* PAINT_ORDER_LAYER.STROKE */:
7323
8278
  if (styles.webkitTextStrokeWidth && text.text.trim().length) {
7324
8279
  _this.ctx.strokeStyle = asString(styles.webkitTextStrokeColor);
7325
8280
  _this.ctx.lineWidth = styles.webkitTextStrokeWidth;
7326
8281
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
7327
8282
  _this.ctx.lineJoin = !!window.chrome ? 'miter' : 'round';
7328
- _this.ctx.strokeText(text.text, text.bounds.left, text.bounds.top + baseline);
8283
+ _this.ctx.strokeText(text.text, text.bounds.left, text.bounds.top + text.bounds.height);
7329
8284
  }
7330
8285
  _this.ctx.strokeStyle = '';
7331
8286
  _this.ctx.lineWidth = 0;
@@ -7339,23 +8294,99 @@ var CanvasRenderer = /** @class */ (function (_super) {
7339
8294
  });
7340
8295
  };
7341
8296
  CanvasRenderer.prototype.renderReplacedElement = function (container, curves, image) {
7342
- if (image && container.intrinsicWidth > 0 && container.intrinsicHeight > 0) {
8297
+ var intrinsicWidth = image.naturalWidth || container.intrinsicWidth;
8298
+ var intrinsicHeight = image.naturalHeight || container.intrinsicHeight;
8299
+ if (image && intrinsicWidth > 0 && intrinsicHeight > 0) {
7343
8300
  var box = contentBox(container);
7344
8301
  var path = calculatePaddingBoxPath(curves);
7345
8302
  this.path(path);
7346
8303
  this.ctx.save();
7347
8304
  this.ctx.clip();
7348
- this.ctx.drawImage(image, 0, 0, container.intrinsicWidth, container.intrinsicHeight, box.left, box.top, box.width, box.height);
8305
+ var sx = 0, sy = 0, sw = intrinsicWidth, sh = intrinsicHeight, dx = box.left, dy = box.top, dw = box.width, dh = box.height;
8306
+ var objectFit = container.styles.objectFit;
8307
+ var boxRatio = dw / dh;
8308
+ var imgRatio = sw / sh;
8309
+ if (objectFit === 2 /* OBJECT_FIT.CONTAIN */) {
8310
+ if (imgRatio > boxRatio) {
8311
+ dh = dw / imgRatio;
8312
+ dy += (box.height - dh) / 2;
8313
+ }
8314
+ else {
8315
+ dw = dh * imgRatio;
8316
+ dx += (box.width - dw) / 2;
8317
+ }
8318
+ }
8319
+ else if (objectFit === 4 /* OBJECT_FIT.COVER */) {
8320
+ if (imgRatio > boxRatio) {
8321
+ sw = sh * boxRatio;
8322
+ sx += (intrinsicWidth - sw) / 2;
8323
+ }
8324
+ else {
8325
+ sh = sw / boxRatio;
8326
+ sy += (intrinsicHeight - sh) / 2;
8327
+ }
8328
+ }
8329
+ else if (objectFit === 8 /* OBJECT_FIT.NONE */) {
8330
+ if (sw > dw) {
8331
+ sx += (sw - dw) / 2;
8332
+ sw = dw;
8333
+ }
8334
+ else {
8335
+ dx += (dw - sw) / 2;
8336
+ dw = sw;
8337
+ }
8338
+ if (sh > dh) {
8339
+ sy += (sh - dh) / 2;
8340
+ sh = dh;
8341
+ }
8342
+ else {
8343
+ dy += (dh - sh) / 2;
8344
+ dh = sh;
8345
+ }
8346
+ }
8347
+ else if (objectFit === 16 /* OBJECT_FIT.SCALE_DOWN */) {
8348
+ var containW = imgRatio > boxRatio ? dw : dh * imgRatio;
8349
+ var noneW = sw > dw ? sw : dw;
8350
+ if (containW < noneW) {
8351
+ if (imgRatio > boxRatio) {
8352
+ dh = dw / imgRatio;
8353
+ dy += (box.height - dh) / 2;
8354
+ }
8355
+ else {
8356
+ dw = dh * imgRatio;
8357
+ dx += (box.width - dw) / 2;
8358
+ }
8359
+ }
8360
+ else {
8361
+ if (sw > dw) {
8362
+ sx += (sw - dw) / 2;
8363
+ sw = dw;
8364
+ }
8365
+ else {
8366
+ dx += (dw - sw) / 2;
8367
+ dw = sw;
8368
+ }
8369
+ if (sh > dh) {
8370
+ sy += (sh - dh) / 2;
8371
+ sh = dh;
8372
+ }
8373
+ else {
8374
+ dy += (dh - sh) / 2;
8375
+ dh = sh;
8376
+ }
8377
+ }
8378
+ }
8379
+ this.ctx.drawImage(image, sx, sy, sw, sh, dx, dy, dw, dh);
7349
8380
  this.ctx.restore();
7350
8381
  }
7351
8382
  };
7352
8383
  CanvasRenderer.prototype.renderNodeContent = function (paint) {
7353
8384
  return __awaiter(this, void 0, void 0, function () {
7354
- var container, curves, styles, _i, _a, child, image, image, iframeRenderer, canvas, size, _b, fontFamily, fontSize, baseline, bounds, x, textBounds, img, image, url, fontFamily, bounds;
8385
+ var container, curves, styles, _i, _a, child, image, image, iframeRenderer, canvas, size, _b, font, fontFamily, fontSize, baseline, bounds, x, textBounds, img, image, url, font, bounds;
7355
8386
  return __generator(this, function (_c) {
7356
8387
  switch (_c.label) {
7357
8388
  case 0:
7358
- this.applyEffects(paint.getEffects(4 /* CONTENT */));
8389
+ this.applyEffects(paint.getEffects(4 /* EffectTarget.CONTENT */));
7359
8390
  container = paint.container;
7360
8391
  curves = paint.curves;
7361
8392
  styles = container.styles;
@@ -7383,7 +8414,7 @@ var CanvasRenderer = /** @class */ (function (_super) {
7383
8414
  return [3 /*break*/, 8];
7384
8415
  case 7:
7385
8416
  _c.sent();
7386
- this.context.logger.error("Error loading image " + container.src);
8417
+ this.context.logger.error("Error loading image ".concat(container.src));
7387
8418
  return [3 /*break*/, 8];
7388
8419
  case 8:
7389
8420
  if (container instanceof CanvasElementContainer) {
@@ -7400,7 +8431,7 @@ var CanvasRenderer = /** @class */ (function (_super) {
7400
8431
  return [3 /*break*/, 12];
7401
8432
  case 11:
7402
8433
  _c.sent();
7403
- this.context.logger.error("Error loading svg " + container.svg.substring(0, 255));
8434
+ this.context.logger.error("Error loading svg ".concat(container.svg.substring(0, 255)));
7404
8435
  return [3 /*break*/, 12];
7405
8436
  case 12:
7406
8437
  if (!(container instanceof IFrameElementContainer && container.tree)) return [3 /*break*/, 14];
@@ -7451,19 +8482,19 @@ var CanvasRenderer = /** @class */ (function (_super) {
7451
8482
  }
7452
8483
  }
7453
8484
  if (isTextInputElement(container) && container.value.length) {
7454
- _b = this.createFontStyle(styles), fontFamily = _b[0], fontSize = _b[1];
8485
+ _b = this.createFontStyle(styles), font = _b[0], fontFamily = _b[1], fontSize = _b[2];
7455
8486
  baseline = this.fontMetrics.getMetrics(fontFamily, fontSize).baseline;
7456
- this.ctx.font = fontFamily;
8487
+ this.ctx.font = font;
7457
8488
  this.ctx.fillStyle = asString(styles.color);
7458
8489
  this.ctx.textBaseline = 'alphabetic';
7459
8490
  this.ctx.textAlign = canvasTextAlign(container.styles.textAlign);
7460
8491
  bounds = contentBox(container);
7461
8492
  x = 0;
7462
8493
  switch (container.styles.textAlign) {
7463
- case 1 /* CENTER */:
8494
+ case 1 /* TEXT_ALIGN.CENTER */:
7464
8495
  x += bounds.width / 2;
7465
8496
  break;
7466
- case 2 /* RIGHT */:
8497
+ case 2 /* TEXT_ALIGN.RIGHT */:
7467
8498
  x += bounds.width;
7468
8499
  break;
7469
8500
  }
@@ -7481,10 +8512,10 @@ var CanvasRenderer = /** @class */ (function (_super) {
7481
8512
  this.ctx.textBaseline = 'alphabetic';
7482
8513
  this.ctx.textAlign = 'left';
7483
8514
  }
7484
- if (!contains(container.styles.display, 2048 /* LIST_ITEM */)) return [3 /*break*/, 20];
8515
+ if (!contains(container.styles.display, 2048 /* DISPLAY.LIST_ITEM */)) return [3 /*break*/, 20];
7485
8516
  if (!(container.styles.listStyleImage !== null)) return [3 /*break*/, 19];
7486
8517
  img = container.styles.listStyleImage;
7487
- if (!(img.type === 0 /* URL */)) return [3 /*break*/, 18];
8518
+ if (!(img.type === 0 /* CSSImageType.URL */)) return [3 /*break*/, 18];
7488
8519
  image = void 0;
7489
8520
  url = img.url;
7490
8521
  _c.label = 15;
@@ -7497,13 +8528,13 @@ var CanvasRenderer = /** @class */ (function (_super) {
7497
8528
  return [3 /*break*/, 18];
7498
8529
  case 17:
7499
8530
  _c.sent();
7500
- this.context.logger.error("Error loading list-style-image " + url);
8531
+ this.context.logger.error("Error loading list-style-image ".concat(url));
7501
8532
  return [3 /*break*/, 18];
7502
8533
  case 18: return [3 /*break*/, 20];
7503
8534
  case 19:
7504
- if (paint.listValue && container.styles.listStyleType !== -1 /* NONE */) {
7505
- fontFamily = this.createFontStyle(styles)[0];
7506
- this.ctx.font = fontFamily;
8535
+ if (paint.listValue && container.styles.listStyleType !== -1 /* LIST_STYLE_TYPE.NONE */) {
8536
+ font = this.createFontStyle(styles)[0];
8537
+ this.ctx.font = font;
7507
8538
  this.ctx.fillStyle = asString(styles.color);
7508
8539
  this.ctx.textBaseline = 'middle';
7509
8540
  this.ctx.textAlign = 'right';
@@ -7524,7 +8555,7 @@ var CanvasRenderer = /** @class */ (function (_super) {
7524
8555
  return __generator(this, function (_p) {
7525
8556
  switch (_p.label) {
7526
8557
  case 0:
7527
- if (contains(stack.element.container.flags, 16 /* DEBUG_RENDER */)) {
8558
+ if (contains(stack.element.container.flags, 16 /* FLAGS.DEBUG_RENDER */)) {
7528
8559
  debugger;
7529
8560
  }
7530
8561
  // https://www.w3.org/TR/css-position-3/#painting-order
@@ -7672,10 +8703,11 @@ var CanvasRenderer = /** @class */ (function (_super) {
7672
8703
  this.ctx.translate(-offsetX, -offsetY);
7673
8704
  };
7674
8705
  CanvasRenderer.prototype.resizeImage = function (image, width, height) {
8706
+ // https://github.com/niklasvh/html2canvas/pull/2911
8707
+ // if (image.width === width && image.height === height) {
8708
+ // return image;
8709
+ // }
7675
8710
  var _a;
7676
- if (image.width === width && image.height === height) {
7677
- return image;
7678
- }
7679
8711
  var ownerDocument = (_a = this.canvas.ownerDocument) !== null && _a !== void 0 ? _a : document;
7680
8712
  var canvas = ownerDocument.createElement('canvas');
7681
8713
  canvas.width = Math.max(1, width);
@@ -7692,11 +8724,11 @@ var CanvasRenderer = /** @class */ (function (_super) {
7692
8724
  case 0:
7693
8725
  index = container.styles.backgroundImage.length - 1;
7694
8726
  _loop_1 = function (backgroundImage) {
7695
- var image, url, _c, path, x, y, width, height, pattern, _d, path, x, y, width, height, _e, lineLength, x0, x1, y0, y1, canvas, ctx, gradient_1, pattern, _f, path, left, top_1, width, height, position, x, y, _g, rx, ry, radialGradient_1, midX, midY, f, invF;
8727
+ var image, url, imageWidth, imageHeight, _c, path, x, y, width, height, pattern, _d, path, x, y, width, height, _e, lineLength, x0, x1, y0, y1, canvas, ctx, gradient_1, pattern, _f, path, left, top_1, width, height, position, x, y, _g, rx, ry, radialGradient_1, midX, midY, f, invF;
7696
8728
  return __generator(this, function (_h) {
7697
8729
  switch (_h.label) {
7698
8730
  case 0:
7699
- if (!(backgroundImage.type === 0 /* URL */)) return [3 /*break*/, 5];
8731
+ if (!(backgroundImage.type === 0 /* CSSImageType.URL */)) return [3 /*break*/, 5];
7700
8732
  image = void 0;
7701
8733
  url = backgroundImage.url;
7702
8734
  _h.label = 1;
@@ -7708,14 +8740,16 @@ var CanvasRenderer = /** @class */ (function (_super) {
7708
8740
  return [3 /*break*/, 4];
7709
8741
  case 3:
7710
8742
  _h.sent();
7711
- this_1.context.logger.error("Error loading background-image " + url);
8743
+ this_1.context.logger.error("Error loading background-image ".concat(url));
7712
8744
  return [3 /*break*/, 4];
7713
8745
  case 4:
7714
8746
  if (image) {
8747
+ imageWidth = isNaN(image.width) || image.width === 0 ? 1 : image.width;
8748
+ imageHeight = isNaN(image.height) || image.height === 0 ? 1 : image.height;
7715
8749
  _c = calculateBackgroundRendering(container, index, [
7716
- image.width,
7717
- image.height,
7718
- image.width / image.height
8750
+ imageWidth,
8751
+ imageHeight,
8752
+ imageWidth / imageHeight
7719
8753
  ]), path = _c[0], x = _c[1], y = _c[2], width = _c[3], height = _c[4];
7720
8754
  pattern = this_1.ctx.createPattern(this_1.resizeImage(image, width, height), 'repeat');
7721
8755
  this_1.renderRepeat(path, pattern, x, y);
@@ -7730,7 +8764,7 @@ var CanvasRenderer = /** @class */ (function (_super) {
7730
8764
  canvas.height = height;
7731
8765
  ctx = canvas.getContext('2d');
7732
8766
  gradient_1 = ctx.createLinearGradient(x0, y0, x1, y1);
7733
- processColorStops(backgroundImage.stops, lineLength).forEach(function (colorStop) {
8767
+ processColorStops(backgroundImage.stops, lineLength || 1).forEach(function (colorStop) {
7734
8768
  return gradient_1.addColorStop(colorStop.stop, asString(colorStop.color));
7735
8769
  });
7736
8770
  ctx.fillStyle = gradient_1;
@@ -7840,7 +8874,7 @@ var CanvasRenderer = /** @class */ (function (_super) {
7840
8874
  return __generator(this, function (_a) {
7841
8875
  switch (_a.label) {
7842
8876
  case 0:
7843
- this.applyEffects(paint.getEffects(2 /* BACKGROUND_BORDERS */));
8877
+ this.applyEffects(paint.getEffects(2 /* EffectTarget.BACKGROUND_BORDERS */));
7844
8878
  styles = paint.container.styles;
7845
8879
  hasBackground = !isTransparent(styles.backgroundColor) || styles.backgroundImage.length;
7846
8880
  borders = [
@@ -7896,20 +8930,20 @@ var CanvasRenderer = /** @class */ (function (_super) {
7896
8930
  case 3:
7897
8931
  if (!(_i < borders_1.length)) return [3 /*break*/, 13];
7898
8932
  border = borders_1[_i];
7899
- if (!(border.style !== 0 /* NONE */ && !isTransparent(border.color) && border.width > 0)) return [3 /*break*/, 11];
7900
- if (!(border.style === 2 /* DASHED */)) return [3 /*break*/, 5];
7901
- return [4 /*yield*/, this.renderDashedDottedBorder(border.color, border.width, side, paint.curves, 2 /* DASHED */)];
8933
+ if (!(border.style !== 0 /* BORDER_STYLE.NONE */ && !isTransparent(border.color) && border.width > 0)) return [3 /*break*/, 11];
8934
+ if (!(border.style === 2 /* BORDER_STYLE.DASHED */)) return [3 /*break*/, 5];
8935
+ return [4 /*yield*/, this.renderDashedDottedBorder(border.color, border.width, side, paint.curves, 2 /* BORDER_STYLE.DASHED */)];
7902
8936
  case 4:
7903
8937
  _a.sent();
7904
8938
  return [3 /*break*/, 11];
7905
8939
  case 5:
7906
- if (!(border.style === 3 /* DOTTED */)) return [3 /*break*/, 7];
7907
- return [4 /*yield*/, this.renderDashedDottedBorder(border.color, border.width, side, paint.curves, 3 /* DOTTED */)];
8940
+ if (!(border.style === 3 /* BORDER_STYLE.DOTTED */)) return [3 /*break*/, 7];
8941
+ return [4 /*yield*/, this.renderDashedDottedBorder(border.color, border.width, side, paint.curves, 3 /* BORDER_STYLE.DOTTED */)];
7908
8942
  case 6:
7909
8943
  _a.sent();
7910
8944
  return [3 /*break*/, 11];
7911
8945
  case 7:
7912
- if (!(border.style === 4 /* DOUBLE */)) return [3 /*break*/, 9];
8946
+ if (!(border.style === 4 /* BORDER_STYLE.DOUBLE */)) return [3 /*break*/, 9];
7913
8947
  return [4 /*yield*/, this.renderDoubleBorder(border.color, border.width, side, paint.curves)];
7914
8948
  case 8:
7915
8949
  _a.sent();
@@ -7936,7 +8970,7 @@ var CanvasRenderer = /** @class */ (function (_super) {
7936
8970
  this.ctx.save();
7937
8971
  strokePaths = parsePathForBorderStroke(curvePoints, side);
7938
8972
  boxPaths = parsePathForBorder(curvePoints, side);
7939
- if (style === 2 /* DASHED */) {
8973
+ if (style === 2 /* BORDER_STYLE.DASHED */) {
7940
8974
  this.path(boxPaths);
7941
8975
  this.ctx.clip();
7942
8976
  }
@@ -7963,7 +8997,7 @@ var CanvasRenderer = /** @class */ (function (_super) {
7963
8997
  length = Math.abs(startY - endY);
7964
8998
  }
7965
8999
  this.ctx.beginPath();
7966
- if (style === 3 /* DOTTED */) {
9000
+ if (style === 3 /* BORDER_STYLE.DOTTED */) {
7967
9001
  this.formatPath(strokePaths);
7968
9002
  }
7969
9003
  else {
@@ -7971,7 +9005,7 @@ var CanvasRenderer = /** @class */ (function (_super) {
7971
9005
  }
7972
9006
  dashLength = width < 3 ? width * 3 : width * 2;
7973
9007
  spaceLength = width < 3 ? width * 2 : width;
7974
- if (style === 3 /* DOTTED */) {
9008
+ if (style === 3 /* BORDER_STYLE.DOTTED */) {
7975
9009
  dashLength = width;
7976
9010
  spaceLength = width;
7977
9011
  }
@@ -7994,14 +9028,14 @@ var CanvasRenderer = /** @class */ (function (_super) {
7994
9028
  : maxSpace;
7995
9029
  }
7996
9030
  if (useLineDash) {
7997
- if (style === 3 /* DOTTED */) {
9031
+ if (style === 3 /* BORDER_STYLE.DOTTED */) {
7998
9032
  this.ctx.setLineDash([0, dashLength + spaceLength]);
7999
9033
  }
8000
9034
  else {
8001
9035
  this.ctx.setLineDash([dashLength, spaceLength]);
8002
9036
  }
8003
9037
  }
8004
- if (style === 3 /* DOTTED */) {
9038
+ if (style === 3 /* BORDER_STYLE.DOTTED */) {
8005
9039
  this.ctx.lineCap = 'round';
8006
9040
  this.ctx.lineWidth = width;
8007
9041
  }
@@ -8012,7 +9046,7 @@ var CanvasRenderer = /** @class */ (function (_super) {
8012
9046
  this.ctx.stroke();
8013
9047
  this.ctx.setLineDash([]);
8014
9048
  // dashed round edge gap
8015
- if (style === 2 /* DASHED */) {
9049
+ if (style === 2 /* BORDER_STYLE.DASHED */) {
8016
9050
  if (isBezierCurve(boxPaths[0])) {
8017
9051
  path1 = boxPaths[3];
8018
9052
  path2 = boxPaths[0];
@@ -8069,22 +9103,22 @@ var isTextInputElement = function (container) {
8069
9103
  };
8070
9104
  var calculateBackgroundCurvedPaintingArea = function (clip, curves) {
8071
9105
  switch (clip) {
8072
- case 0 /* BORDER_BOX */:
9106
+ case 0 /* BACKGROUND_CLIP.BORDER_BOX */:
8073
9107
  return calculateBorderBoxPath(curves);
8074
- case 2 /* CONTENT_BOX */:
9108
+ case 2 /* BACKGROUND_CLIP.CONTENT_BOX */:
8075
9109
  return calculateContentBoxPath(curves);
8076
- case 1 /* PADDING_BOX */:
9110
+ case 1 /* BACKGROUND_CLIP.PADDING_BOX */:
8077
9111
  default:
8078
9112
  return calculatePaddingBoxPath(curves);
8079
9113
  }
8080
9114
  };
8081
9115
  var canvasTextAlign = function (textAlign) {
8082
9116
  switch (textAlign) {
8083
- case 1 /* CENTER */:
9117
+ case 1 /* TEXT_ALIGN.CENTER */:
8084
9118
  return 'center';
8085
- case 2 /* RIGHT */:
9119
+ case 2 /* TEXT_ALIGN.RIGHT */:
8086
9120
  return 'right';
8087
- case 0 /* LEFT */:
9121
+ case 0 /* TEXT_ALIGN.LEFT */:
8088
9122
  default:
8089
9123
  return 'left';
8090
9124
  }
@@ -8106,11 +9140,11 @@ var ForeignObjectRenderer = /** @class */ (function (_super) {
8106
9140
  _this.options = options;
8107
9141
  _this.canvas.width = Math.floor(options.width * options.scale);
8108
9142
  _this.canvas.height = Math.floor(options.height * options.scale);
8109
- _this.canvas.style.width = options.width + "px";
8110
- _this.canvas.style.height = options.height + "px";
9143
+ _this.canvas.style.width = "".concat(options.width, "px");
9144
+ _this.canvas.style.height = "".concat(options.height, "px");
8111
9145
  _this.ctx.scale(_this.options.scale, _this.options.scale);
8112
9146
  _this.ctx.translate(-options.x, -options.y);
8113
- _this.context.logger.debug("EXPERIMENTAL ForeignObject renderer initialized (" + options.width + "x" + options.height + " at " + options.x + "," + options.y + ") with scale " + options.scale);
9147
+ _this.context.logger.debug("EXPERIMENTAL ForeignObject renderer initialized (".concat(options.width, "x").concat(options.height, " at ").concat(options.x, ",").concat(options.y, ") with scale ").concat(options.scale));
8114
9148
  return _this;
8115
9149
  }
8116
9150
  ForeignObjectRenderer.prototype.render = function (element) {
@@ -8142,7 +9176,7 @@ var loadSerializedSVG = function (svg) {
8142
9176
  resolve(img);
8143
9177
  };
8144
9178
  img.onerror = reject;
8145
- img.src = "data:image/svg+xml;charset=utf-8," + encodeURIComponent(new XMLSerializer().serializeToString(svg));
9179
+ img.src = "data:image/svg+xml;charset=utf-8,".concat(encodeURIComponent(new XMLSerializer().serializeToString(svg)));
8146
9180
  });
8147
9181
  };
8148
9182
 
@@ -8163,7 +9197,7 @@ var Logger = /** @class */ (function () {
8163
9197
  // eslint-disable-next-line no-console
8164
9198
  if (typeof window !== 'undefined' && window.console && typeof console.debug === 'function') {
8165
9199
  // eslint-disable-next-line no-console
8166
- console.debug.apply(console, __spreadArray([this.id, this.getTime() + "ms"], args));
9200
+ console.debug.apply(console, __spreadArray([this.id, "".concat(this.getTime(), "ms")], args, false));
8167
9201
  }
8168
9202
  else {
8169
9203
  this.info.apply(this, args);
@@ -8183,7 +9217,7 @@ var Logger = /** @class */ (function () {
8183
9217
  // eslint-disable-next-line no-console
8184
9218
  if (typeof window !== 'undefined' && window.console && typeof console.info === 'function') {
8185
9219
  // eslint-disable-next-line no-console
8186
- console.info.apply(console, __spreadArray([this.id, this.getTime() + "ms"], args));
9220
+ console.info.apply(console, __spreadArray([this.id, "".concat(this.getTime(), "ms")], args, false));
8187
9221
  }
8188
9222
  }
8189
9223
  };
@@ -8197,7 +9231,7 @@ var Logger = /** @class */ (function () {
8197
9231
  // eslint-disable-next-line no-console
8198
9232
  if (typeof window !== 'undefined' && window.console && typeof console.warn === 'function') {
8199
9233
  // eslint-disable-next-line no-console
8200
- console.warn.apply(console, __spreadArray([this.id, this.getTime() + "ms"], args));
9234
+ console.warn.apply(console, __spreadArray([this.id, "".concat(this.getTime(), "ms")], args, false));
8201
9235
  }
8202
9236
  else {
8203
9237
  this.info.apply(this, args);
@@ -8214,7 +9248,7 @@ var Logger = /** @class */ (function () {
8214
9248
  // eslint-disable-next-line no-console
8215
9249
  if (typeof window !== 'undefined' && window.console && typeof console.error === 'function') {
8216
9250
  // eslint-disable-next-line no-console
8217
- console.error.apply(console, __spreadArray([this.id, this.getTime() + "ms"], args));
9251
+ console.error.apply(console, __spreadArray([this.id, "".concat(this.getTime(), "ms")], args, false));
8218
9252
  }
8219
9253
  else {
8220
9254
  this.info.apply(this, args);
@@ -8229,7 +9263,7 @@ var Context = /** @class */ (function () {
8229
9263
  function Context(options, windowBounds) {
8230
9264
  var _a;
8231
9265
  this.windowBounds = windowBounds;
8232
- this.instanceName = "#" + Context.instanceCount++;
9266
+ this.instanceName = "#".concat(Context.instanceCount++);
8233
9267
  this.logger = new Logger({ id: this.instanceName, enabled: options.logging });
8234
9268
  this.cache = (_a = options.cache) !== null && _a !== void 0 ? _a : new Cache(this, options);
8235
9269
  }
@@ -8265,7 +9299,8 @@ var renderElement = function (element, opts) { return __awaiter(void 0, void 0,
8265
9299
  allowTaint: (_b = opts.allowTaint) !== null && _b !== void 0 ? _b : false,
8266
9300
  imageTimeout: (_c = opts.imageTimeout) !== null && _c !== void 0 ? _c : 15000,
8267
9301
  proxy: opts.proxy,
8268
- useCORS: (_d = opts.useCORS) !== null && _d !== void 0 ? _d : false
9302
+ useCORS: (_d = opts.useCORS) !== null && _d !== void 0 ? _d : false,
9303
+ customIsSameOrigin: opts.customIsSameOrigin
8269
9304
  };
8270
9305
  contextOptions = __assign({ logging: (_e = opts.logging) !== null && _e !== void 0 ? _e : true, cache: opts.cache }, resourceOptions);
8271
9306
  windowOptions = {
@@ -8284,7 +9319,7 @@ var renderElement = function (element, opts) { return __awaiter(void 0, void 0,
8284
9319
  inlineImages: foreignObjectRendering,
8285
9320
  copyStyles: foreignObjectRendering
8286
9321
  };
8287
- context.logger.debug("Starting document clone with size " + windowBounds.width + "x" + windowBounds.height + " scrolled to " + -windowBounds.left + "," + -windowBounds.top);
9322
+ context.logger.debug("Starting document clone with size ".concat(windowBounds.width, "x").concat(windowBounds.height, " scrolled to ").concat(-windowBounds.left, ",").concat(-windowBounds.top));
8288
9323
  documentCloner = new DocumentCloner(context, element, cloneOptions);
8289
9324
  clonedElement = documentCloner.clonedReferenceElement;
8290
9325
  if (!clonedElement) {
@@ -8314,13 +9349,13 @@ var renderElement = function (element, opts) { return __awaiter(void 0, void 0,
8314
9349
  canvas = _u.sent();
8315
9350
  return [3 /*break*/, 5];
8316
9351
  case 3:
8317
- context.logger.debug("Document cloned, element located at " + left + "," + top + " with size " + width + "x" + height + " using computed rendering");
9352
+ context.logger.debug("Document cloned, element located at ".concat(left, ",").concat(top, " with size ").concat(width, "x").concat(height, " using computed rendering"));
8318
9353
  context.logger.debug("Starting DOM parsing");
8319
9354
  root = parseTree(context, clonedElement);
8320
9355
  if (backgroundColor === root.styles.backgroundColor) {
8321
9356
  root.styles.backgroundColor = COLORS.TRANSPARENT;
8322
9357
  }
8323
- context.logger.debug("Starting renderer for element at " + renderOptions.x + "," + renderOptions.y + " with size " + renderOptions.width + "x" + renderOptions.height);
9358
+ context.logger.debug("Starting renderer for element at ".concat(renderOptions.x, ",").concat(renderOptions.y, " with size ").concat(renderOptions.width, "x").concat(renderOptions.height));
8324
9359
  renderer = new CanvasRenderer(context, renderOptions);
8325
9360
  return [4 /*yield*/, renderer.render(root)];
8326
9361
  case 4:
@@ -8381,38 +9416,38 @@ class Screenshot {
8381
9416
  useCORS: true,
8382
9417
  logging: false,
8383
9418
  width: fullPageWidth,
8384
- height: fullPageHeight
9419
+ height: fullPageHeight,
8385
9420
  });
8386
9421
  // Restore scroll position
8387
9422
  window.scrollTo(0, originalScrollY);
8388
9423
  // Show UXbert UI elements again
8389
9424
  this.showUXbertElements();
8390
9425
  // Convert to base64
8391
- this.currentScreenshot = canvas.toDataURL('image/png');
9426
+ this.currentScreenshot = canvas.toDataURL("image/png");
8392
9427
  return this.currentScreenshot;
8393
9428
  }
8394
9429
  catch (error) {
8395
- console.error('Screenshot capture failed:', error);
9430
+ console.error("Screenshot capture failed:", error);
8396
9431
  this.showUXbertElements();
8397
9432
  throw error;
8398
9433
  }
8399
9434
  }
8400
9435
  hideUXbertElements() {
8401
9436
  const elements = document.querySelectorAll('[class*="uxbert-"]');
8402
- elements.forEach(el => {
9437
+ elements.forEach((el) => {
8403
9438
  const element = el;
8404
- element.setAttribute('data-uxbert-display', element.style.display || '');
8405
- element.style.display = 'none';
9439
+ element.setAttribute("data-uxbert-display", element.style.display || "");
9440
+ element.style.display = "none";
8406
9441
  });
8407
9442
  }
8408
9443
  showUXbertElements() {
8409
9444
  const elements = document.querySelectorAll('[class*="uxbert-"]');
8410
- elements.forEach(el => {
9445
+ elements.forEach((el) => {
8411
9446
  const element = el;
8412
- const originalDisplay = element.getAttribute('data-uxbert-display');
9447
+ const originalDisplay = element.getAttribute("data-uxbert-display");
8413
9448
  if (originalDisplay !== null) {
8414
9449
  element.style.display = originalDisplay;
8415
- element.removeAttribute('data-uxbert-display');
9450
+ element.removeAttribute("data-uxbert-display");
8416
9451
  }
8417
9452
  });
8418
9453
  }