Files
erp-system/.next/dev/server/chunks/ssr/node_modules_019cy5-._.js
T
2026-05-20 18:58:23 +00:00

11100 lines
405 KiB
JavaScript

module.exports = [
"[project]/node_modules/lucide-react/dist/esm/icons/arrow-left.mjs [app-ssr] (ecmascript)", ((__turbopack_context__) => {
"use strict";
__turbopack_context__.s([
"__iconNode",
()=>__iconNode,
"default",
()=>ArrowLeft
]);
/**
* @license lucide-react v1.14.0 - ISC
*
* This source code is licensed under the ISC license.
* See the LICENSE file in the root directory of this source tree.
*/ var __TURBOPACK__imported__module__$5b$project$5d2f$node_modules$2f$lucide$2d$react$2f$dist$2f$esm$2f$createLucideIcon$2e$mjs__$5b$app$2d$ssr$5d$__$28$ecmascript$29$__ = __turbopack_context__.i("[project]/node_modules/lucide-react/dist/esm/createLucideIcon.mjs [app-ssr] (ecmascript)");
;
const __iconNode = [
[
"path",
{
d: "m12 19-7-7 7-7",
key: "1l729n"
}
],
[
"path",
{
d: "M19 12H5",
key: "x3x0zl"
}
]
];
const ArrowLeft = (0, __TURBOPACK__imported__module__$5b$project$5d2f$node_modules$2f$lucide$2d$react$2f$dist$2f$esm$2f$createLucideIcon$2e$mjs__$5b$app$2d$ssr$5d$__$28$ecmascript$29$__["default"])("arrow-left", __iconNode);
;
}),
"[project]/node_modules/lucide-react/dist/esm/icons/arrow-left.mjs [app-ssr] (ecmascript) <export default as ArrowLeft>", ((__turbopack_context__) => {
"use strict";
__turbopack_context__.s([
"ArrowLeft",
()=>__TURBOPACK__imported__module__$5b$project$5d2f$node_modules$2f$lucide$2d$react$2f$dist$2f$esm$2f$icons$2f$arrow$2d$left$2e$mjs__$5b$app$2d$ssr$5d$__$28$ecmascript$29$__["default"]
]);
var __TURBOPACK__imported__module__$5b$project$5d2f$node_modules$2f$lucide$2d$react$2f$dist$2f$esm$2f$icons$2f$arrow$2d$left$2e$mjs__$5b$app$2d$ssr$5d$__$28$ecmascript$29$__ = __turbopack_context__.i("[project]/node_modules/lucide-react/dist/esm/icons/arrow-left.mjs [app-ssr] (ecmascript)");
}),
"[project]/node_modules/lucide-react/dist/esm/icons/printer.mjs [app-ssr] (ecmascript)", ((__turbopack_context__) => {
"use strict";
__turbopack_context__.s([
"__iconNode",
()=>__iconNode,
"default",
()=>Printer
]);
/**
* @license lucide-react v1.14.0 - ISC
*
* This source code is licensed under the ISC license.
* See the LICENSE file in the root directory of this source tree.
*/ var __TURBOPACK__imported__module__$5b$project$5d2f$node_modules$2f$lucide$2d$react$2f$dist$2f$esm$2f$createLucideIcon$2e$mjs__$5b$app$2d$ssr$5d$__$28$ecmascript$29$__ = __turbopack_context__.i("[project]/node_modules/lucide-react/dist/esm/createLucideIcon.mjs [app-ssr] (ecmascript)");
;
const __iconNode = [
[
"path",
{
d: "M6 18H4a2 2 0 0 1-2-2v-5a2 2 0 0 1 2-2h16a2 2 0 0 1 2 2v5a2 2 0 0 1-2 2h-2",
key: "143wyd"
}
],
[
"path",
{
d: "M6 9V3a1 1 0 0 1 1-1h10a1 1 0 0 1 1 1v6",
key: "1itne7"
}
],
[
"rect",
{
x: "6",
y: "14",
width: "12",
height: "8",
rx: "1",
key: "1ue0tg"
}
]
];
const Printer = (0, __TURBOPACK__imported__module__$5b$project$5d2f$node_modules$2f$lucide$2d$react$2f$dist$2f$esm$2f$createLucideIcon$2e$mjs__$5b$app$2d$ssr$5d$__$28$ecmascript$29$__["default"])("printer", __iconNode);
;
}),
"[project]/node_modules/lucide-react/dist/esm/icons/printer.mjs [app-ssr] (ecmascript) <export default as Printer>", ((__turbopack_context__) => {
"use strict";
__turbopack_context__.s([
"Printer",
()=>__TURBOPACK__imported__module__$5b$project$5d2f$node_modules$2f$lucide$2d$react$2f$dist$2f$esm$2f$icons$2f$printer$2e$mjs__$5b$app$2d$ssr$5d$__$28$ecmascript$29$__["default"]
]);
var __TURBOPACK__imported__module__$5b$project$5d2f$node_modules$2f$lucide$2d$react$2f$dist$2f$esm$2f$icons$2f$printer$2e$mjs__$5b$app$2d$ssr$5d$__$28$ecmascript$29$__ = __turbopack_context__.i("[project]/node_modules/lucide-react/dist/esm/icons/printer.mjs [app-ssr] (ecmascript)");
}),
"[project]/node_modules/dompurify/dist/purify.cjs.js [app-ssr] (ecmascript)", ((__turbopack_context__, module, exports) => {
"use strict";
/*! @license DOMPurify 3.4.3 | (c) Cure53 and other contributors | Released under the Apache license 2.0 and Mozilla Public License 2.0 | github.com/cure53/DOMPurify/blob/3.4.3/LICENSE */ function _arrayLikeToArray(r, a) {
(null == a || a > r.length) && (a = r.length);
for(var e = 0, n = Array(a); e < a; e++)n[e] = r[e];
return n;
}
function _arrayWithHoles(r) {
if (Array.isArray(r)) return r;
}
function _iterableToArrayLimit(r, l) {
var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"];
if (null != t) {
var e, n, i, u, a = [], f = true, o = false;
try {
if (i = (t = t.call(r)).next, 0 === l) ;
else for(; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0);
} catch (r) {
o = true, n = r;
} finally{
try {
if (!f && null != t.return && (u = t.return(), Object(u) !== u)) return;
} finally{
if (o) throw n;
}
}
return a;
}
}
function _nonIterableRest() {
throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
}
function _slicedToArray(r, e) {
return _arrayWithHoles(r) || _iterableToArrayLimit(r, e) || _unsupportedIterableToArray(r, e) || _nonIterableRest();
}
function _unsupportedIterableToArray(r, a) {
if (r) {
if ("string" == typeof r) return _arrayLikeToArray(r, a);
var t = ({}).toString.call(r).slice(8, -1);
return "Object" === t && r.constructor && (t = r.constructor.name), "Map" === t || "Set" === t ? Array.from(r) : "Arguments" === t || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t) ? _arrayLikeToArray(r, a) : void 0;
}
}
const entries = Object.entries, setPrototypeOf = Object.setPrototypeOf, isFrozen = Object.isFrozen, getPrototypeOf = Object.getPrototypeOf, getOwnPropertyDescriptor = Object.getOwnPropertyDescriptor;
let freeze = Object.freeze, seal = Object.seal, create = Object.create; // eslint-disable-line import/no-mutable-exports
let _ref = typeof Reflect !== 'undefined' && Reflect, apply = _ref.apply, construct = _ref.construct;
if (!freeze) {
freeze = function freeze(x) {
return x;
};
}
if (!seal) {
seal = function seal(x) {
return x;
};
}
if (!apply) {
apply = function apply(func, thisArg) {
for(var _len = arguments.length, args = new Array(_len > 2 ? _len - 2 : 0), _key = 2; _key < _len; _key++){
args[_key - 2] = arguments[_key];
}
return func.apply(thisArg, args);
};
}
if (!construct) {
construct = function construct(Func) {
for(var _len2 = arguments.length, args = new Array(_len2 > 1 ? _len2 - 1 : 0), _key2 = 1; _key2 < _len2; _key2++){
args[_key2 - 1] = arguments[_key2];
}
return new Func(...args);
};
}
const arrayForEach = unapply(Array.prototype.forEach);
const arrayLastIndexOf = unapply(Array.prototype.lastIndexOf);
const arrayPop = unapply(Array.prototype.pop);
const arrayPush = unapply(Array.prototype.push);
const arraySplice = unapply(Array.prototype.splice);
const arrayIsArray = Array.isArray;
const stringToLowerCase = unapply(String.prototype.toLowerCase);
const stringToString = unapply(String.prototype.toString);
const stringMatch = unapply(String.prototype.match);
const stringReplace = unapply(String.prototype.replace);
const stringIndexOf = unapply(String.prototype.indexOf);
const stringTrim = unapply(String.prototype.trim);
const numberToString = unapply(Number.prototype.toString);
const booleanToString = unapply(Boolean.prototype.toString);
const bigintToString = typeof BigInt === 'undefined' ? null : unapply(BigInt.prototype.toString);
const symbolToString = typeof Symbol === 'undefined' ? null : unapply(Symbol.prototype.toString);
const objectHasOwnProperty = unapply(Object.prototype.hasOwnProperty);
const objectToString = unapply(Object.prototype.toString);
const regExpTest = unapply(RegExp.prototype.test);
const typeErrorCreate = unconstruct(TypeError);
/**
* Creates a new function that calls the given function with a specified thisArg and arguments.
*
* @param func - The function to be wrapped and called.
* @returns A new function that calls the given function with a specified thisArg and arguments.
*/ function unapply(func) {
return function(thisArg) {
if (thisArg instanceof RegExp) {
thisArg.lastIndex = 0;
}
for(var _len3 = arguments.length, args = new Array(_len3 > 1 ? _len3 - 1 : 0), _key3 = 1; _key3 < _len3; _key3++){
args[_key3 - 1] = arguments[_key3];
}
return apply(func, thisArg, args);
};
}
/**
* Creates a new function that constructs an instance of the given constructor function with the provided arguments.
*
* @param func - The constructor function to be wrapped and called.
* @returns A new function that constructs an instance of the given constructor function with the provided arguments.
*/ function unconstruct(Func) {
return function() {
for(var _len4 = arguments.length, args = new Array(_len4), _key4 = 0; _key4 < _len4; _key4++){
args[_key4] = arguments[_key4];
}
return construct(Func, args);
};
}
/**
* Add properties to a lookup table
*
* @param set - The set to which elements will be added.
* @param array - The array containing elements to be added to the set.
* @param transformCaseFunc - An optional function to transform the case of each element before adding to the set.
* @returns The modified set with added elements.
*/ function addToSet(set, array) {
let transformCaseFunc = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : stringToLowerCase;
if (setPrototypeOf) {
// Make 'in' and truthy checks like Boolean(set.constructor)
// independent of any properties defined on Object.prototype.
// Prevent prototype setters from intercepting set as a this value.
setPrototypeOf(set, null);
}
if (!arrayIsArray(array)) {
return set;
}
let l = array.length;
while(l--){
let element = array[l];
if (typeof element === 'string') {
const lcElement = transformCaseFunc(element);
if (lcElement !== element) {
// Config presets (e.g. tags.js, attrs.js) are immutable.
if (!isFrozen(array)) {
array[l] = lcElement;
}
element = lcElement;
}
}
set[element] = true;
}
return set;
}
/**
* Clean up an array to harden against CSPP
*
* @param array - The array to be cleaned.
* @returns The cleaned version of the array
*/ function cleanArray(array) {
for(let index = 0; index < array.length; index++){
const isPropertyExist = objectHasOwnProperty(array, index);
if (!isPropertyExist) {
array[index] = null;
}
}
return array;
}
/**
* Shallow clone an object
*
* @param object - The object to be cloned.
* @returns A new object that copies the original.
*/ function clone(object) {
const newObject = create(null);
for (const _ref2 of entries(object)){
var _ref3 = _slicedToArray(_ref2, 2);
const property = _ref3[0];
const value = _ref3[1];
const isPropertyExist = objectHasOwnProperty(object, property);
if (isPropertyExist) {
if (arrayIsArray(value)) {
newObject[property] = cleanArray(value);
} else if (value && typeof value === 'object' && value.constructor === Object) {
newObject[property] = clone(value);
} else {
newObject[property] = value;
}
}
}
return newObject;
}
/**
* Convert non-node values into strings without depending on direct property access.
*
* @param value - The value to stringify.
* @returns A string representation of the provided value.
*/ function stringifyValue(value) {
switch(typeof value){
case 'string':
{
return value;
}
case 'number':
{
return numberToString(value);
}
case 'boolean':
{
return booleanToString(value);
}
case 'bigint':
{
return bigintToString ? bigintToString(value) : '0';
}
case 'symbol':
{
return symbolToString ? symbolToString(value) : 'Symbol()';
}
case 'undefined':
{
return objectToString(value);
}
case 'function':
case 'object':
{
if (value === null) {
return objectToString(value);
}
const valueAsRecord = value;
const valueToString = lookupGetter(valueAsRecord, 'toString');
if (typeof valueToString === 'function') {
const stringified = valueToString(valueAsRecord);
return typeof stringified === 'string' ? stringified : objectToString(stringified);
}
return objectToString(value);
}
default:
{
return objectToString(value);
}
}
}
/**
* This method automatically checks if the prop is function or getter and behaves accordingly.
*
* @param object - The object to look up the getter function in its prototype chain.
* @param prop - The property name for which to find the getter function.
* @returns The getter function found in the prototype chain or a fallback function.
*/ function lookupGetter(object, prop) {
while(object !== null){
const desc = getOwnPropertyDescriptor(object, prop);
if (desc) {
if (desc.get) {
return unapply(desc.get);
}
if (typeof desc.value === 'function') {
return unapply(desc.value);
}
}
object = getPrototypeOf(object);
}
function fallbackValue() {
return null;
}
return fallbackValue;
}
function isRegex(value) {
try {
regExpTest(value, '');
return true;
} catch (_unused) {
return false;
}
}
const html$1 = freeze([
'a',
'abbr',
'acronym',
'address',
'area',
'article',
'aside',
'audio',
'b',
'bdi',
'bdo',
'big',
'blink',
'blockquote',
'body',
'br',
'button',
'canvas',
'caption',
'center',
'cite',
'code',
'col',
'colgroup',
'content',
'data',
'datalist',
'dd',
'decorator',
'del',
'details',
'dfn',
'dialog',
'dir',
'div',
'dl',
'dt',
'element',
'em',
'fieldset',
'figcaption',
'figure',
'font',
'footer',
'form',
'h1',
'h2',
'h3',
'h4',
'h5',
'h6',
'head',
'header',
'hgroup',
'hr',
'html',
'i',
'img',
'input',
'ins',
'kbd',
'label',
'legend',
'li',
'main',
'map',
'mark',
'marquee',
'menu',
'menuitem',
'meter',
'nav',
'nobr',
'ol',
'optgroup',
'option',
'output',
'p',
'picture',
'pre',
'progress',
'q',
'rp',
'rt',
'ruby',
's',
'samp',
'search',
'section',
'select',
'shadow',
'slot',
'small',
'source',
'spacer',
'span',
'strike',
'strong',
'style',
'sub',
'summary',
'sup',
'table',
'tbody',
'td',
'template',
'textarea',
'tfoot',
'th',
'thead',
'time',
'tr',
'track',
'tt',
'u',
'ul',
'var',
'video',
'wbr'
]);
const svg$1 = freeze([
'svg',
'a',
'altglyph',
'altglyphdef',
'altglyphitem',
'animatecolor',
'animatemotion',
'animatetransform',
'circle',
'clippath',
'defs',
'desc',
'ellipse',
'enterkeyhint',
'exportparts',
'filter',
'font',
'g',
'glyph',
'glyphref',
'hkern',
'image',
'inputmode',
'line',
'lineargradient',
'marker',
'mask',
'metadata',
'mpath',
'part',
'path',
'pattern',
'polygon',
'polyline',
'radialgradient',
'rect',
'stop',
'style',
'switch',
'symbol',
'text',
'textpath',
'title',
'tref',
'tspan',
'view',
'vkern'
]);
const svgFilters = freeze([
'feBlend',
'feColorMatrix',
'feComponentTransfer',
'feComposite',
'feConvolveMatrix',
'feDiffuseLighting',
'feDisplacementMap',
'feDistantLight',
'feDropShadow',
'feFlood',
'feFuncA',
'feFuncB',
'feFuncG',
'feFuncR',
'feGaussianBlur',
'feImage',
'feMerge',
'feMergeNode',
'feMorphology',
'feOffset',
'fePointLight',
'feSpecularLighting',
'feSpotLight',
'feTile',
'feTurbulence'
]);
// List of SVG elements that are disallowed by default.
// We still need to know them so that we can do namespace
// checks properly in case one wants to add them to
// allow-list.
const svgDisallowed = freeze([
'animate',
'color-profile',
'cursor',
'discard',
'font-face',
'font-face-format',
'font-face-name',
'font-face-src',
'font-face-uri',
'foreignobject',
'hatch',
'hatchpath',
'mesh',
'meshgradient',
'meshpatch',
'meshrow',
'missing-glyph',
'script',
'set',
'solidcolor',
'unknown',
'use'
]);
const mathMl$1 = freeze([
'math',
'menclose',
'merror',
'mfenced',
'mfrac',
'mglyph',
'mi',
'mlabeledtr',
'mmultiscripts',
'mn',
'mo',
'mover',
'mpadded',
'mphantom',
'mroot',
'mrow',
'ms',
'mspace',
'msqrt',
'mstyle',
'msub',
'msup',
'msubsup',
'mtable',
'mtd',
'mtext',
'mtr',
'munder',
'munderover',
'mprescripts'
]);
// Similarly to SVG, we want to know all MathML elements,
// even those that we disallow by default.
const mathMlDisallowed = freeze([
'maction',
'maligngroup',
'malignmark',
'mlongdiv',
'mscarries',
'mscarry',
'msgroup',
'mstack',
'msline',
'msrow',
'semantics',
'annotation',
'annotation-xml',
'mprescripts',
'none'
]);
const text = freeze([
'#text'
]);
const html = freeze([
'accept',
'action',
'align',
'alt',
'autocapitalize',
'autocomplete',
'autopictureinpicture',
'autoplay',
'background',
'bgcolor',
'border',
'capture',
'cellpadding',
'cellspacing',
'checked',
'cite',
'class',
'clear',
'color',
'cols',
'colspan',
'controls',
'controlslist',
'coords',
'crossorigin',
'datetime',
'decoding',
'default',
'dir',
'disabled',
'disablepictureinpicture',
'disableremoteplayback',
'download',
'draggable',
'enctype',
'enterkeyhint',
'exportparts',
'face',
'for',
'headers',
'height',
'hidden',
'high',
'href',
'hreflang',
'id',
'inert',
'inputmode',
'integrity',
'ismap',
'kind',
'label',
'lang',
'list',
'loading',
'loop',
'low',
'max',
'maxlength',
'media',
'method',
'min',
'minlength',
'multiple',
'muted',
'name',
'nonce',
'noshade',
'novalidate',
'nowrap',
'open',
'optimum',
'part',
'pattern',
'placeholder',
'playsinline',
'popover',
'popovertarget',
'popovertargetaction',
'poster',
'preload',
'pubdate',
'radiogroup',
'readonly',
'rel',
'required',
'rev',
'reversed',
'role',
'rows',
'rowspan',
'spellcheck',
'scope',
'selected',
'shape',
'size',
'sizes',
'slot',
'span',
'srclang',
'start',
'src',
'srcset',
'step',
'style',
'summary',
'tabindex',
'title',
'translate',
'type',
'usemap',
'valign',
'value',
'width',
'wrap',
'xmlns'
]);
const svg = freeze([
'accent-height',
'accumulate',
'additive',
'alignment-baseline',
'amplitude',
'ascent',
'attributename',
'attributetype',
'azimuth',
'basefrequency',
'baseline-shift',
'begin',
'bias',
'by',
'class',
'clip',
'clippathunits',
'clip-path',
'clip-rule',
'color',
'color-interpolation',
'color-interpolation-filters',
'color-profile',
'color-rendering',
'cx',
'cy',
'd',
'dx',
'dy',
'diffuseconstant',
'direction',
'display',
'divisor',
'dur',
'edgemode',
'elevation',
'end',
'exponent',
'fill',
'fill-opacity',
'fill-rule',
'filter',
'filterunits',
'flood-color',
'flood-opacity',
'font-family',
'font-size',
'font-size-adjust',
'font-stretch',
'font-style',
'font-variant',
'font-weight',
'fx',
'fy',
'g1',
'g2',
'glyph-name',
'glyphref',
'gradientunits',
'gradienttransform',
'height',
'href',
'id',
'image-rendering',
'in',
'in2',
'intercept',
'k',
'k1',
'k2',
'k3',
'k4',
'kerning',
'keypoints',
'keysplines',
'keytimes',
'lang',
'lengthadjust',
'letter-spacing',
'kernelmatrix',
'kernelunitlength',
'lighting-color',
'local',
'marker-end',
'marker-mid',
'marker-start',
'markerheight',
'markerunits',
'markerwidth',
'maskcontentunits',
'maskunits',
'max',
'mask',
'mask-type',
'media',
'method',
'mode',
'min',
'name',
'numoctaves',
'offset',
'operator',
'opacity',
'order',
'orient',
'orientation',
'origin',
'overflow',
'paint-order',
'path',
'pathlength',
'patterncontentunits',
'patterntransform',
'patternunits',
'points',
'preservealpha',
'preserveaspectratio',
'primitiveunits',
'r',
'rx',
'ry',
'radius',
'refx',
'refy',
'repeatcount',
'repeatdur',
'restart',
'result',
'rotate',
'scale',
'seed',
'shape-rendering',
'slope',
'specularconstant',
'specularexponent',
'spreadmethod',
'startoffset',
'stddeviation',
'stitchtiles',
'stop-color',
'stop-opacity',
'stroke-dasharray',
'stroke-dashoffset',
'stroke-linecap',
'stroke-linejoin',
'stroke-miterlimit',
'stroke-opacity',
'stroke',
'stroke-width',
'style',
'surfacescale',
'systemlanguage',
'tabindex',
'tablevalues',
'targetx',
'targety',
'transform',
'transform-origin',
'text-anchor',
'text-decoration',
'text-rendering',
'textlength',
'type',
'u1',
'u2',
'unicode',
'values',
'viewbox',
'visibility',
'version',
'vert-adv-y',
'vert-origin-x',
'vert-origin-y',
'width',
'word-spacing',
'wrap',
'writing-mode',
'xchannelselector',
'ychannelselector',
'x',
'x1',
'x2',
'xmlns',
'y',
'y1',
'y2',
'z',
'zoomandpan'
]);
const mathMl = freeze([
'accent',
'accentunder',
'align',
'bevelled',
'close',
'columnalign',
'columnlines',
'columnspacing',
'columnspan',
'denomalign',
'depth',
'dir',
'display',
'displaystyle',
'encoding',
'fence',
'frame',
'height',
'href',
'id',
'largeop',
'length',
'linethickness',
'lquote',
'lspace',
'mathbackground',
'mathcolor',
'mathsize',
'mathvariant',
'maxsize',
'minsize',
'movablelimits',
'notation',
'numalign',
'open',
'rowalign',
'rowlines',
'rowspacing',
'rowspan',
'rspace',
'rquote',
'scriptlevel',
'scriptminsize',
'scriptsizemultiplier',
'selection',
'separator',
'separators',
'stretchy',
'subscriptshift',
'supscriptshift',
'symmetric',
'voffset',
'width',
'xmlns'
]);
const xml = freeze([
'xlink:href',
'xml:id',
'xlink:title',
'xml:space',
'xmlns:xlink'
]);
const MUSTACHE_EXPR = seal(/{{[\w\W]*|^[\w\W]*}}/g);
const ERB_EXPR = seal(/<%[\w\W]*|^[\w\W]*%>/g);
const TMPLIT_EXPR = seal(/\${[\w\W]*/g);
const DATA_ATTR = seal(/^data-[\-\w.\u00B7-\uFFFF]+$/); // eslint-disable-line no-useless-escape
const ARIA_ATTR = seal(/^aria-[\-\w]+$/); // eslint-disable-line no-useless-escape
const IS_ALLOWED_URI = seal(/^(?:(?:(?:f|ht)tps?|mailto|tel|callto|sms|cid|xmpp|matrix):|[^a-z]|[a-z+.\-]+(?:[^a-z+.\-:]|$))/i // eslint-disable-line no-useless-escape
);
const IS_SCRIPT_OR_DATA = seal(/^(?:\w+script|data):/i);
const ATTR_WHITESPACE = seal(/[\u0000-\u0020\u00A0\u1680\u180E\u2000-\u2029\u205F\u3000]/g // eslint-disable-line no-control-regex
);
const DOCTYPE_NAME = seal(/^html$/i);
const CUSTOM_ELEMENT = seal(/^[a-z][.\w]*(-[.\w]+)+$/i);
/* eslint-disable @typescript-eslint/indent */ // https://developer.mozilla.org/en-US/docs/Web/API/Node/nodeType
const NODE_TYPE = {
element: 1,
text: 3,
// Deprecated
progressingInstruction: 7,
comment: 8,
document: 9
};
const getGlobal = function getGlobal() {
return ("TURBOPACK compile-time truthy", 1) ? null : "TURBOPACK unreachable";
};
/**
* Creates a no-op policy for internal use only.
* Don't export this function outside this module!
* @param trustedTypes The policy factory.
* @param purifyHostElement The Script element used to load DOMPurify (to determine policy name suffix).
* @return The policy created (or null, if Trusted Types
* are not supported or creating the policy failed).
*/ const _createTrustedTypesPolicy = function _createTrustedTypesPolicy(trustedTypes, purifyHostElement) {
if (typeof trustedTypes !== 'object' || typeof trustedTypes.createPolicy !== 'function') {
return null;
}
// Allow the callers to control the unique policy name
// by adding a data-tt-policy-suffix to the script element with the DOMPurify.
// Policy creation with duplicate names throws in Trusted Types.
let suffix = null;
const ATTR_NAME = 'data-tt-policy-suffix';
if (purifyHostElement && purifyHostElement.hasAttribute(ATTR_NAME)) {
suffix = purifyHostElement.getAttribute(ATTR_NAME);
}
const policyName = 'dompurify' + (suffix ? '#' + suffix : '');
try {
return trustedTypes.createPolicy(policyName, {
createHTML (html) {
return html;
},
createScriptURL (scriptUrl) {
return scriptUrl;
}
});
} catch (_) {
// Policy creation failed (most likely another DOMPurify script has
// already run). Skip creating the policy, as this will only cause errors
// if TT are enforced.
console.warn('TrustedTypes policy ' + policyName + ' could not be created.');
return null;
}
};
const _createHooksMap = function _createHooksMap() {
return {
afterSanitizeAttributes: [],
afterSanitizeElements: [],
afterSanitizeShadowDOM: [],
beforeSanitizeAttributes: [],
beforeSanitizeElements: [],
beforeSanitizeShadowDOM: [],
uponSanitizeAttribute: [],
uponSanitizeElement: [],
uponSanitizeShadowNode: []
};
};
function createDOMPurify() {
let window = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : getGlobal();
const DOMPurify = (root)=>createDOMPurify(root);
DOMPurify.version = '3.4.3';
DOMPurify.removed = [];
if (!window || !window.document || window.document.nodeType !== NODE_TYPE.document || !window.Element) {
// Not running in a browser, provide a factory function
// so that you can pass your own Window
DOMPurify.isSupported = false;
return DOMPurify;
}
let document = window.document;
const originalDocument = document;
const currentScript = originalDocument.currentScript;
const DocumentFragment = window.DocumentFragment, HTMLTemplateElement = window.HTMLTemplateElement, Node = window.Node, Element = window.Element, NodeFilter = window.NodeFilter, _window$NamedNodeMap = window.NamedNodeMap, NamedNodeMap = _window$NamedNodeMap === void 0 ? window.NamedNodeMap || window.MozNamedAttrMap : _window$NamedNodeMap, HTMLFormElement = window.HTMLFormElement, DOMParser = window.DOMParser, trustedTypes = window.trustedTypes;
const ElementPrototype = Element.prototype;
const cloneNode = lookupGetter(ElementPrototype, 'cloneNode');
const remove = lookupGetter(ElementPrototype, 'remove');
const getNextSibling = lookupGetter(ElementPrototype, 'nextSibling');
const getChildNodes = lookupGetter(ElementPrototype, 'childNodes');
const getParentNode = lookupGetter(ElementPrototype, 'parentNode');
// As per issue #47, the web-components registry is inherited by a
// new document created via createHTMLDocument. As per the spec
// (http://w3c.github.io/webcomponents/spec/custom/#creating-and-passing-registries)
// a new empty registry is used when creating a template contents owner
// document, so we use that as our parent document to ensure nothing
// is inherited.
if (typeof HTMLTemplateElement === 'function') {
const template = document.createElement('template');
if (template.content && template.content.ownerDocument) {
document = template.content.ownerDocument;
}
}
let trustedTypesPolicy;
let emptyHTML = '';
const _document = document, implementation = _document.implementation, createNodeIterator = _document.createNodeIterator, createDocumentFragment = _document.createDocumentFragment, getElementsByTagName = _document.getElementsByTagName;
const importNode = originalDocument.importNode;
let hooks = _createHooksMap();
/**
* Expose whether this browser supports running the full DOMPurify.
*/ DOMPurify.isSupported = typeof entries === 'function' && typeof getParentNode === 'function' && implementation && implementation.createHTMLDocument !== undefined;
const MUSTACHE_EXPR$1 = MUSTACHE_EXPR, ERB_EXPR$1 = ERB_EXPR, TMPLIT_EXPR$1 = TMPLIT_EXPR, DATA_ATTR$1 = DATA_ATTR, ARIA_ATTR$1 = ARIA_ATTR, IS_SCRIPT_OR_DATA$1 = IS_SCRIPT_OR_DATA, ATTR_WHITESPACE$1 = ATTR_WHITESPACE, CUSTOM_ELEMENT$1 = CUSTOM_ELEMENT;
let IS_ALLOWED_URI$1 = IS_ALLOWED_URI;
/**
* We consider the elements and attributes below to be safe. Ideally
* don't add any new ones but feel free to remove unwanted ones.
*/ /* allowed element names */ let ALLOWED_TAGS = null;
const DEFAULT_ALLOWED_TAGS = addToSet({}, [
...html$1,
...svg$1,
...svgFilters,
...mathMl$1,
...text
]);
/* Allowed attribute names */ let ALLOWED_ATTR = null;
const DEFAULT_ALLOWED_ATTR = addToSet({}, [
...html,
...svg,
...mathMl,
...xml
]);
/*
* Configure how DOMPurify should handle custom elements and their attributes as well as customized built-in elements.
* @property {RegExp|Function|null} tagNameCheck one of [null, regexPattern, predicate]. Default: `null` (disallow any custom elements)
* @property {RegExp|Function|null} attributeNameCheck one of [null, regexPattern, predicate]. Default: `null` (disallow any attributes not on the allow list)
* @property {boolean} allowCustomizedBuiltInElements allow custom elements derived from built-ins if they pass CUSTOM_ELEMENT_HANDLING.tagNameCheck. Default: `false`.
*/ let CUSTOM_ELEMENT_HANDLING = Object.seal(create(null, {
tagNameCheck: {
writable: true,
configurable: false,
enumerable: true,
value: null
},
attributeNameCheck: {
writable: true,
configurable: false,
enumerable: true,
value: null
},
allowCustomizedBuiltInElements: {
writable: true,
configurable: false,
enumerable: true,
value: false
}
}));
/* Explicitly forbidden tags (overrides ALLOWED_TAGS/ADD_TAGS) */ let FORBID_TAGS = null;
/* Explicitly forbidden attributes (overrides ALLOWED_ATTR/ADD_ATTR) */ let FORBID_ATTR = null;
/* Config object to store ADD_TAGS/ADD_ATTR functions (when used as functions) */ const EXTRA_ELEMENT_HANDLING = Object.seal(create(null, {
tagCheck: {
writable: true,
configurable: false,
enumerable: true,
value: null
},
attributeCheck: {
writable: true,
configurable: false,
enumerable: true,
value: null
}
}));
/* Decide if ARIA attributes are okay */ let ALLOW_ARIA_ATTR = true;
/* Decide if custom data attributes are okay */ let ALLOW_DATA_ATTR = true;
/* Decide if unknown protocols are okay */ let ALLOW_UNKNOWN_PROTOCOLS = false;
/* Decide if self-closing tags in attributes are allowed.
* Usually removed due to a mXSS issue in jQuery 3.0 */ let ALLOW_SELF_CLOSE_IN_ATTR = true;
/* Output should be safe for common template engines.
* This means, DOMPurify removes data attributes, mustaches and ERB
*/ let SAFE_FOR_TEMPLATES = false;
/* Output should be safe even for XML used within HTML and alike.
* This means, DOMPurify removes comments when containing risky content.
*/ let SAFE_FOR_XML = true;
/* Decide if document with <html>... should be returned */ let WHOLE_DOCUMENT = false;
/* Track whether config is already set on this instance of DOMPurify. */ let SET_CONFIG = false;
/* Decide if all elements (e.g. style, script) must be children of
* document.body. By default, browsers might move them to document.head */ let FORCE_BODY = false;
/* Decide if a DOM `HTMLBodyElement` should be returned, instead of a html
* string (or a TrustedHTML object if Trusted Types are supported).
* If `WHOLE_DOCUMENT` is enabled a `HTMLHtmlElement` will be returned instead
*/ let RETURN_DOM = false;
/* Decide if a DOM `DocumentFragment` should be returned, instead of a html
* string (or a TrustedHTML object if Trusted Types are supported) */ let RETURN_DOM_FRAGMENT = false;
/* Try to return a Trusted Type object instead of a string, return a string in
* case Trusted Types are not supported */ let RETURN_TRUSTED_TYPE = false;
/* Output should be free from DOM clobbering attacks?
* This sanitizes markups named with colliding, clobberable built-in DOM APIs.
*/ let SANITIZE_DOM = true;
/* Achieve full DOM Clobbering protection by isolating the namespace of named
* properties and JS variables, mitigating attacks that abuse the HTML/DOM spec rules.
*
* HTML/DOM spec rules that enable DOM Clobbering:
* - Named Access on Window (§7.3.3)
* - DOM Tree Accessors (§3.1.5)
* - Form Element Parent-Child Relations (§4.10.3)
* - Iframe srcdoc / Nested WindowProxies (§4.8.5)
* - HTMLCollection (§4.2.10.2)
*
* Namespace isolation is implemented by prefixing `id` and `name` attributes
* with a constant string, i.e., `user-content-`
*/ let SANITIZE_NAMED_PROPS = false;
const SANITIZE_NAMED_PROPS_PREFIX = 'user-content-';
/* Keep element content when removing element? */ let KEEP_CONTENT = true;
/* If a `Node` is passed to sanitize(), then performs sanitization in-place instead
* of importing it into a new Document and returning a sanitized copy */ let IN_PLACE = false;
/* Allow usage of profiles like html, svg and mathMl */ let USE_PROFILES = {};
/* Tags to ignore content of when KEEP_CONTENT is true */ let FORBID_CONTENTS = null;
const DEFAULT_FORBID_CONTENTS = addToSet({}, [
'annotation-xml',
'audio',
'colgroup',
'desc',
'foreignobject',
'head',
'iframe',
'math',
'mi',
'mn',
'mo',
'ms',
'mtext',
'noembed',
'noframes',
'noscript',
'plaintext',
'script',
'style',
'svg',
'template',
'thead',
'title',
'video',
'xmp'
]);
/* Tags that are safe for data: URIs */ let DATA_URI_TAGS = null;
const DEFAULT_DATA_URI_TAGS = addToSet({}, [
'audio',
'video',
'img',
'source',
'image',
'track'
]);
/* Attributes safe for values like "javascript:" */ let URI_SAFE_ATTRIBUTES = null;
const DEFAULT_URI_SAFE_ATTRIBUTES = addToSet({}, [
'alt',
'class',
'for',
'id',
'label',
'name',
'pattern',
'placeholder',
'role',
'summary',
'title',
'value',
'style',
'xmlns'
]);
const MATHML_NAMESPACE = 'http://www.w3.org/1998/Math/MathML';
const SVG_NAMESPACE = 'http://www.w3.org/2000/svg';
const HTML_NAMESPACE = 'http://www.w3.org/1999/xhtml';
/* Document namespace */ let NAMESPACE = HTML_NAMESPACE;
let IS_EMPTY_INPUT = false;
/* Allowed XHTML+XML namespaces */ let ALLOWED_NAMESPACES = null;
const DEFAULT_ALLOWED_NAMESPACES = addToSet({}, [
MATHML_NAMESPACE,
SVG_NAMESPACE,
HTML_NAMESPACE
], stringToString);
let MATHML_TEXT_INTEGRATION_POINTS = addToSet({}, [
'mi',
'mo',
'mn',
'ms',
'mtext'
]);
let HTML_INTEGRATION_POINTS = addToSet({}, [
'annotation-xml'
]);
// Certain elements are allowed in both SVG and HTML
// namespace. We need to specify them explicitly
// so that they don't get erroneously deleted from
// HTML namespace.
const COMMON_SVG_AND_HTML_ELEMENTS = addToSet({}, [
'title',
'style',
'font',
'a',
'script'
]);
/* Parsing of strict XHTML documents */ let PARSER_MEDIA_TYPE = null;
const SUPPORTED_PARSER_MEDIA_TYPES = [
'application/xhtml+xml',
'text/html'
];
const DEFAULT_PARSER_MEDIA_TYPE = 'text/html';
let transformCaseFunc = null;
/* Keep a reference to config to pass to hooks */ let CONFIG = null;
/* Ideally, do not touch anything below this line */ /* ______________________________________________ */ const formElement = document.createElement('form');
const isRegexOrFunction = function isRegexOrFunction(testValue) {
return testValue instanceof RegExp || testValue instanceof Function;
};
/**
* _parseConfig
*
* @param cfg optional config literal
*/ // eslint-disable-next-line complexity
const _parseConfig = function _parseConfig() {
let cfg = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
if (CONFIG && CONFIG === cfg) {
return;
}
/* Shield configuration object from tampering */ if (!cfg || typeof cfg !== 'object') {
cfg = {};
}
/* Shield configuration object from prototype pollution */ cfg = clone(cfg);
PARSER_MEDIA_TYPE = // eslint-disable-next-line unicorn/prefer-includes
SUPPORTED_PARSER_MEDIA_TYPES.indexOf(cfg.PARSER_MEDIA_TYPE) === -1 ? DEFAULT_PARSER_MEDIA_TYPE : cfg.PARSER_MEDIA_TYPE;
// HTML tags and attributes are not case-sensitive, converting to lowercase. Keeping XHTML as is.
transformCaseFunc = PARSER_MEDIA_TYPE === 'application/xhtml+xml' ? stringToString : stringToLowerCase;
/* Set configuration parameters */ ALLOWED_TAGS = objectHasOwnProperty(cfg, 'ALLOWED_TAGS') && arrayIsArray(cfg.ALLOWED_TAGS) ? addToSet({}, cfg.ALLOWED_TAGS, transformCaseFunc) : DEFAULT_ALLOWED_TAGS;
ALLOWED_ATTR = objectHasOwnProperty(cfg, 'ALLOWED_ATTR') && arrayIsArray(cfg.ALLOWED_ATTR) ? addToSet({}, cfg.ALLOWED_ATTR, transformCaseFunc) : DEFAULT_ALLOWED_ATTR;
ALLOWED_NAMESPACES = objectHasOwnProperty(cfg, 'ALLOWED_NAMESPACES') && arrayIsArray(cfg.ALLOWED_NAMESPACES) ? addToSet({}, cfg.ALLOWED_NAMESPACES, stringToString) : DEFAULT_ALLOWED_NAMESPACES;
URI_SAFE_ATTRIBUTES = objectHasOwnProperty(cfg, 'ADD_URI_SAFE_ATTR') && arrayIsArray(cfg.ADD_URI_SAFE_ATTR) ? addToSet(clone(DEFAULT_URI_SAFE_ATTRIBUTES), cfg.ADD_URI_SAFE_ATTR, transformCaseFunc) : DEFAULT_URI_SAFE_ATTRIBUTES;
DATA_URI_TAGS = objectHasOwnProperty(cfg, 'ADD_DATA_URI_TAGS') && arrayIsArray(cfg.ADD_DATA_URI_TAGS) ? addToSet(clone(DEFAULT_DATA_URI_TAGS), cfg.ADD_DATA_URI_TAGS, transformCaseFunc) : DEFAULT_DATA_URI_TAGS;
FORBID_CONTENTS = objectHasOwnProperty(cfg, 'FORBID_CONTENTS') && arrayIsArray(cfg.FORBID_CONTENTS) ? addToSet({}, cfg.FORBID_CONTENTS, transformCaseFunc) : DEFAULT_FORBID_CONTENTS;
FORBID_TAGS = objectHasOwnProperty(cfg, 'FORBID_TAGS') && arrayIsArray(cfg.FORBID_TAGS) ? addToSet({}, cfg.FORBID_TAGS, transformCaseFunc) : clone({});
FORBID_ATTR = objectHasOwnProperty(cfg, 'FORBID_ATTR') && arrayIsArray(cfg.FORBID_ATTR) ? addToSet({}, cfg.FORBID_ATTR, transformCaseFunc) : clone({});
USE_PROFILES = objectHasOwnProperty(cfg, 'USE_PROFILES') ? cfg.USE_PROFILES && typeof cfg.USE_PROFILES === 'object' ? clone(cfg.USE_PROFILES) : cfg.USE_PROFILES : false;
ALLOW_ARIA_ATTR = cfg.ALLOW_ARIA_ATTR !== false; // Default true
ALLOW_DATA_ATTR = cfg.ALLOW_DATA_ATTR !== false; // Default true
ALLOW_UNKNOWN_PROTOCOLS = cfg.ALLOW_UNKNOWN_PROTOCOLS || false; // Default false
ALLOW_SELF_CLOSE_IN_ATTR = cfg.ALLOW_SELF_CLOSE_IN_ATTR !== false; // Default true
SAFE_FOR_TEMPLATES = cfg.SAFE_FOR_TEMPLATES || false; // Default false
SAFE_FOR_XML = cfg.SAFE_FOR_XML !== false; // Default true
WHOLE_DOCUMENT = cfg.WHOLE_DOCUMENT || false; // Default false
RETURN_DOM = cfg.RETURN_DOM || false; // Default false
RETURN_DOM_FRAGMENT = cfg.RETURN_DOM_FRAGMENT || false; // Default false
RETURN_TRUSTED_TYPE = cfg.RETURN_TRUSTED_TYPE || false; // Default false
FORCE_BODY = cfg.FORCE_BODY || false; // Default false
SANITIZE_DOM = cfg.SANITIZE_DOM !== false; // Default true
SANITIZE_NAMED_PROPS = cfg.SANITIZE_NAMED_PROPS || false; // Default false
KEEP_CONTENT = cfg.KEEP_CONTENT !== false; // Default true
IN_PLACE = cfg.IN_PLACE || false; // Default false
IS_ALLOWED_URI$1 = isRegex(cfg.ALLOWED_URI_REGEXP) ? cfg.ALLOWED_URI_REGEXP : IS_ALLOWED_URI; // Default regexp
NAMESPACE = typeof cfg.NAMESPACE === 'string' ? cfg.NAMESPACE : HTML_NAMESPACE; // Default HTML namespace
MATHML_TEXT_INTEGRATION_POINTS = objectHasOwnProperty(cfg, 'MATHML_TEXT_INTEGRATION_POINTS') && cfg.MATHML_TEXT_INTEGRATION_POINTS && typeof cfg.MATHML_TEXT_INTEGRATION_POINTS === 'object' ? clone(cfg.MATHML_TEXT_INTEGRATION_POINTS) : addToSet({}, [
'mi',
'mo',
'mn',
'ms',
'mtext'
]); // Default built-in map
HTML_INTEGRATION_POINTS = objectHasOwnProperty(cfg, 'HTML_INTEGRATION_POINTS') && cfg.HTML_INTEGRATION_POINTS && typeof cfg.HTML_INTEGRATION_POINTS === 'object' ? clone(cfg.HTML_INTEGRATION_POINTS) : addToSet({}, [
'annotation-xml'
]); // Default built-in map
const customElementHandling = objectHasOwnProperty(cfg, 'CUSTOM_ELEMENT_HANDLING') && cfg.CUSTOM_ELEMENT_HANDLING && typeof cfg.CUSTOM_ELEMENT_HANDLING === 'object' ? clone(cfg.CUSTOM_ELEMENT_HANDLING) : create(null);
CUSTOM_ELEMENT_HANDLING = create(null);
if (objectHasOwnProperty(customElementHandling, 'tagNameCheck') && isRegexOrFunction(customElementHandling.tagNameCheck)) {
CUSTOM_ELEMENT_HANDLING.tagNameCheck = customElementHandling.tagNameCheck; // Default undefined
}
if (objectHasOwnProperty(customElementHandling, 'attributeNameCheck') && isRegexOrFunction(customElementHandling.attributeNameCheck)) {
CUSTOM_ELEMENT_HANDLING.attributeNameCheck = customElementHandling.attributeNameCheck; // Default undefined
}
if (objectHasOwnProperty(customElementHandling, 'allowCustomizedBuiltInElements') && typeof customElementHandling.allowCustomizedBuiltInElements === 'boolean') {
CUSTOM_ELEMENT_HANDLING.allowCustomizedBuiltInElements = customElementHandling.allowCustomizedBuiltInElements; // Default undefined
}
if (SAFE_FOR_TEMPLATES) {
ALLOW_DATA_ATTR = false;
}
if (RETURN_DOM_FRAGMENT) {
RETURN_DOM = true;
}
/* Parse profile info */ if (USE_PROFILES) {
ALLOWED_TAGS = addToSet({}, text);
ALLOWED_ATTR = create(null);
if (USE_PROFILES.html === true) {
addToSet(ALLOWED_TAGS, html$1);
addToSet(ALLOWED_ATTR, html);
}
if (USE_PROFILES.svg === true) {
addToSet(ALLOWED_TAGS, svg$1);
addToSet(ALLOWED_ATTR, svg);
addToSet(ALLOWED_ATTR, xml);
}
if (USE_PROFILES.svgFilters === true) {
addToSet(ALLOWED_TAGS, svgFilters);
addToSet(ALLOWED_ATTR, svg);
addToSet(ALLOWED_ATTR, xml);
}
if (USE_PROFILES.mathMl === true) {
addToSet(ALLOWED_TAGS, mathMl$1);
addToSet(ALLOWED_ATTR, mathMl);
addToSet(ALLOWED_ATTR, xml);
}
}
/* Always reset function-based ADD_TAGS / ADD_ATTR checks to prevent
* leaking across calls when switching from function to array config */ EXTRA_ELEMENT_HANDLING.tagCheck = null;
EXTRA_ELEMENT_HANDLING.attributeCheck = null;
/* Merge configuration parameters */ if (objectHasOwnProperty(cfg, 'ADD_TAGS')) {
if (typeof cfg.ADD_TAGS === 'function') {
EXTRA_ELEMENT_HANDLING.tagCheck = cfg.ADD_TAGS;
} else if (arrayIsArray(cfg.ADD_TAGS)) {
if (ALLOWED_TAGS === DEFAULT_ALLOWED_TAGS) {
ALLOWED_TAGS = clone(ALLOWED_TAGS);
}
addToSet(ALLOWED_TAGS, cfg.ADD_TAGS, transformCaseFunc);
}
}
if (objectHasOwnProperty(cfg, 'ADD_ATTR')) {
if (typeof cfg.ADD_ATTR === 'function') {
EXTRA_ELEMENT_HANDLING.attributeCheck = cfg.ADD_ATTR;
} else if (arrayIsArray(cfg.ADD_ATTR)) {
if (ALLOWED_ATTR === DEFAULT_ALLOWED_ATTR) {
ALLOWED_ATTR = clone(ALLOWED_ATTR);
}
addToSet(ALLOWED_ATTR, cfg.ADD_ATTR, transformCaseFunc);
}
}
if (objectHasOwnProperty(cfg, 'ADD_URI_SAFE_ATTR') && arrayIsArray(cfg.ADD_URI_SAFE_ATTR)) {
addToSet(URI_SAFE_ATTRIBUTES, cfg.ADD_URI_SAFE_ATTR, transformCaseFunc);
}
if (objectHasOwnProperty(cfg, 'FORBID_CONTENTS') && arrayIsArray(cfg.FORBID_CONTENTS)) {
if (FORBID_CONTENTS === DEFAULT_FORBID_CONTENTS) {
FORBID_CONTENTS = clone(FORBID_CONTENTS);
}
addToSet(FORBID_CONTENTS, cfg.FORBID_CONTENTS, transformCaseFunc);
}
if (objectHasOwnProperty(cfg, 'ADD_FORBID_CONTENTS') && arrayIsArray(cfg.ADD_FORBID_CONTENTS)) {
if (FORBID_CONTENTS === DEFAULT_FORBID_CONTENTS) {
FORBID_CONTENTS = clone(FORBID_CONTENTS);
}
addToSet(FORBID_CONTENTS, cfg.ADD_FORBID_CONTENTS, transformCaseFunc);
}
/* Add #text in case KEEP_CONTENT is set to true */ if (KEEP_CONTENT) {
ALLOWED_TAGS['#text'] = true;
}
/* Add html, head and body to ALLOWED_TAGS in case WHOLE_DOCUMENT is true */ if (WHOLE_DOCUMENT) {
addToSet(ALLOWED_TAGS, [
'html',
'head',
'body'
]);
}
/* Add tbody to ALLOWED_TAGS in case tables are permitted, see #286, #365 */ if (ALLOWED_TAGS.table) {
addToSet(ALLOWED_TAGS, [
'tbody'
]);
delete FORBID_TAGS.tbody;
}
if (cfg.TRUSTED_TYPES_POLICY) {
if (typeof cfg.TRUSTED_TYPES_POLICY.createHTML !== 'function') {
throw typeErrorCreate('TRUSTED_TYPES_POLICY configuration option must provide a "createHTML" hook.');
}
if (typeof cfg.TRUSTED_TYPES_POLICY.createScriptURL !== 'function') {
throw typeErrorCreate('TRUSTED_TYPES_POLICY configuration option must provide a "createScriptURL" hook.');
}
// Overwrite existing TrustedTypes policy.
trustedTypesPolicy = cfg.TRUSTED_TYPES_POLICY;
// Sign local variables required by `sanitize`.
emptyHTML = trustedTypesPolicy.createHTML('');
} else {
// Uninitialized policy, attempt to initialize the internal dompurify policy.
if (trustedTypesPolicy === undefined) {
trustedTypesPolicy = _createTrustedTypesPolicy(trustedTypes, currentScript);
}
// If creating the internal policy succeeded sign internal variables.
if (trustedTypesPolicy !== null && typeof emptyHTML === 'string') {
emptyHTML = trustedTypesPolicy.createHTML('');
}
}
// Prevent further manipulation of configuration.
// Not available in IE8, Safari 5, etc.
if (freeze) {
freeze(cfg);
}
CONFIG = cfg;
};
/* Keep track of all possible SVG and MathML tags
* so that we can perform the namespace checks
* correctly. */ const ALL_SVG_TAGS = addToSet({}, [
...svg$1,
...svgFilters,
...svgDisallowed
]);
const ALL_MATHML_TAGS = addToSet({}, [
...mathMl$1,
...mathMlDisallowed
]);
/**
* @param element a DOM element whose namespace is being checked
* @returns Return false if the element has a
* namespace that a spec-compliant parser would never
* return. Return true otherwise.
*/ const _checkValidNamespace = function _checkValidNamespace(element) {
let parent = getParentNode(element);
// In JSDOM, if we're inside shadow DOM, then parentNode
// can be null. We just simulate parent in this case.
if (!parent || !parent.tagName) {
parent = {
namespaceURI: NAMESPACE,
tagName: 'template'
};
}
const tagName = stringToLowerCase(element.tagName);
const parentTagName = stringToLowerCase(parent.tagName);
if (!ALLOWED_NAMESPACES[element.namespaceURI]) {
return false;
}
if (element.namespaceURI === SVG_NAMESPACE) {
// The only way to switch from HTML namespace to SVG
// is via <svg>. If it happens via any other tag, then
// it should be killed.
if (parent.namespaceURI === HTML_NAMESPACE) {
return tagName === 'svg';
}
// The only way to switch from MathML to SVG is via`
// svg if parent is either <annotation-xml> or MathML
// text integration points.
if (parent.namespaceURI === MATHML_NAMESPACE) {
return tagName === 'svg' && (parentTagName === 'annotation-xml' || MATHML_TEXT_INTEGRATION_POINTS[parentTagName]);
}
// We only allow elements that are defined in SVG
// spec. All others are disallowed in SVG namespace.
return Boolean(ALL_SVG_TAGS[tagName]);
}
if (element.namespaceURI === MATHML_NAMESPACE) {
// The only way to switch from HTML namespace to MathML
// is via <math>. If it happens via any other tag, then
// it should be killed.
if (parent.namespaceURI === HTML_NAMESPACE) {
return tagName === 'math';
}
// The only way to switch from SVG to MathML is via
// <math> and HTML integration points
if (parent.namespaceURI === SVG_NAMESPACE) {
return tagName === 'math' && HTML_INTEGRATION_POINTS[parentTagName];
}
// We only allow elements that are defined in MathML
// spec. All others are disallowed in MathML namespace.
return Boolean(ALL_MATHML_TAGS[tagName]);
}
if (element.namespaceURI === HTML_NAMESPACE) {
// The only way to switch from SVG to HTML is via
// HTML integration points, and from MathML to HTML
// is via MathML text integration points
if (parent.namespaceURI === SVG_NAMESPACE && !HTML_INTEGRATION_POINTS[parentTagName]) {
return false;
}
if (parent.namespaceURI === MATHML_NAMESPACE && !MATHML_TEXT_INTEGRATION_POINTS[parentTagName]) {
return false;
}
// We disallow tags that are specific for MathML
// or SVG and should never appear in HTML namespace
return !ALL_MATHML_TAGS[tagName] && (COMMON_SVG_AND_HTML_ELEMENTS[tagName] || !ALL_SVG_TAGS[tagName]);
}
// For XHTML and XML documents that support custom namespaces
if (PARSER_MEDIA_TYPE === 'application/xhtml+xml' && ALLOWED_NAMESPACES[element.namespaceURI]) {
return true;
}
// The code should never reach this place (this means
// that the element somehow got namespace that is not
// HTML, SVG, MathML or allowed via ALLOWED_NAMESPACES).
// Return false just in case.
return false;
};
/**
* _forceRemove
*
* @param node a DOM node
*/ const _forceRemove = function _forceRemove(node) {
arrayPush(DOMPurify.removed, {
element: node
});
try {
// eslint-disable-next-line unicorn/prefer-dom-node-remove
getParentNode(node).removeChild(node);
} catch (_) {
remove(node);
}
};
/**
* _removeAttribute
*
* @param name an Attribute name
* @param element a DOM node
*/ const _removeAttribute = function _removeAttribute(name, element) {
try {
arrayPush(DOMPurify.removed, {
attribute: element.getAttributeNode(name),
from: element
});
} catch (_) {
arrayPush(DOMPurify.removed, {
attribute: null,
from: element
});
}
element.removeAttribute(name);
// We void attribute values for unremovable "is" attributes
if (name === 'is') {
if (RETURN_DOM || RETURN_DOM_FRAGMENT) {
try {
_forceRemove(element);
} catch (_) {}
} else {
try {
element.setAttribute(name, '');
} catch (_) {}
}
}
};
/**
* _initDocument
*
* @param dirty - a string of dirty markup
* @return a DOM, filled with the dirty markup
*/ const _initDocument = function _initDocument(dirty) {
/* Create a HTML document */ let doc = null;
let leadingWhitespace = null;
if (FORCE_BODY) {
dirty = '<remove></remove>' + dirty;
} else {
/* If FORCE_BODY isn't used, leading whitespace needs to be preserved manually */ const matches = stringMatch(dirty, /^[\r\n\t ]+/);
leadingWhitespace = matches && matches[0];
}
if (PARSER_MEDIA_TYPE === 'application/xhtml+xml' && NAMESPACE === HTML_NAMESPACE) {
// Root of XHTML doc must contain xmlns declaration (see https://www.w3.org/TR/xhtml1/normative.html#strict)
dirty = '<html xmlns="http://www.w3.org/1999/xhtml"><head></head><body>' + dirty + '</body></html>';
}
const dirtyPayload = trustedTypesPolicy ? trustedTypesPolicy.createHTML(dirty) : dirty;
/*
* Use the DOMParser API by default, fallback later if needs be
* DOMParser not work for svg when has multiple root element.
*/ if (NAMESPACE === HTML_NAMESPACE) {
try {
doc = new DOMParser().parseFromString(dirtyPayload, PARSER_MEDIA_TYPE);
} catch (_) {}
}
/* Use createHTMLDocument in case DOMParser is not available */ if (!doc || !doc.documentElement) {
doc = implementation.createDocument(NAMESPACE, 'template', null);
try {
doc.documentElement.innerHTML = IS_EMPTY_INPUT ? emptyHTML : dirtyPayload;
} catch (_) {
// Syntax error if dirtyPayload is invalid xml
}
}
const body = doc.body || doc.documentElement;
if (dirty && leadingWhitespace) {
body.insertBefore(document.createTextNode(leadingWhitespace), body.childNodes[0] || null);
}
/* Work on whole document or just its body */ if (NAMESPACE === HTML_NAMESPACE) {
return getElementsByTagName.call(doc, WHOLE_DOCUMENT ? 'html' : 'body')[0];
}
return WHOLE_DOCUMENT ? doc.documentElement : body;
};
/**
* Creates a NodeIterator object that you can use to traverse filtered lists of nodes or elements in a document.
*
* @param root The root element or node to start traversing on.
* @return The created NodeIterator
*/ const _createNodeIterator = function _createNodeIterator(root) {
return createNodeIterator.call(root.ownerDocument || root, root, // eslint-disable-next-line no-bitwise
NodeFilter.SHOW_ELEMENT | NodeFilter.SHOW_COMMENT | NodeFilter.SHOW_TEXT | NodeFilter.SHOW_PROCESSING_INSTRUCTION | NodeFilter.SHOW_CDATA_SECTION, null);
};
/**
* _isClobbered
*
* @param element element to check for clobbering attacks
* @return true if clobbered, false if safe
*/ const _isClobbered = function _isClobbered(element) {
return element instanceof HTMLFormElement && (typeof element.nodeName !== 'string' || typeof element.textContent !== 'string' || typeof element.removeChild !== 'function' || !(element.attributes instanceof NamedNodeMap) || typeof element.removeAttribute !== 'function' || typeof element.setAttribute !== 'function' || typeof element.namespaceURI !== 'string' || typeof element.insertBefore !== 'function' || typeof element.hasChildNodes !== 'function');
};
/**
* Checks whether the given object is a DOM node.
*
* @param value object to check whether it's a DOM node
* @return true is object is a DOM node
*/ const _isNode = function _isNode(value) {
return typeof Node === 'function' && value instanceof Node;
};
function _executeHooks(hooks, currentNode, data) {
arrayForEach(hooks, (hook)=>{
hook.call(DOMPurify, currentNode, data, CONFIG);
});
}
/**
* _sanitizeElements
*
* @protect nodeName
* @protect textContent
* @protect removeChild
* @param currentNode to check for permission to exist
* @return true if node was killed, false if left alive
*/ const _sanitizeElements = function _sanitizeElements(currentNode) {
let content = null;
/* Execute a hook if present */ _executeHooks(hooks.beforeSanitizeElements, currentNode, null);
/* Check if element is clobbered or can clobber */ if (_isClobbered(currentNode)) {
_forceRemove(currentNode);
return true;
}
/* Now let's check the element's type and name */ const tagName = transformCaseFunc(currentNode.nodeName);
/* Execute a hook if present */ _executeHooks(hooks.uponSanitizeElement, currentNode, {
tagName,
allowedTags: ALLOWED_TAGS
});
/* Detect mXSS attempts abusing namespace confusion */ if (SAFE_FOR_XML && currentNode.hasChildNodes() && !_isNode(currentNode.firstElementChild) && regExpTest(/<[/\w!]/g, currentNode.innerHTML) && regExpTest(/<[/\w!]/g, currentNode.textContent)) {
_forceRemove(currentNode);
return true;
}
/* Remove risky CSS construction leading to mXSS */ if (SAFE_FOR_XML && currentNode.namespaceURI === HTML_NAMESPACE && tagName === 'style' && _isNode(currentNode.firstElementChild)) {
_forceRemove(currentNode);
return true;
}
/* Remove any occurrence of processing instructions */ if (currentNode.nodeType === NODE_TYPE.progressingInstruction) {
_forceRemove(currentNode);
return true;
}
/* Remove any kind of possibly harmful comments */ if (SAFE_FOR_XML && currentNode.nodeType === NODE_TYPE.comment && regExpTest(/<[/\w]/g, currentNode.data)) {
_forceRemove(currentNode);
return true;
}
/* Remove element if anything forbids its presence */ if (FORBID_TAGS[tagName] || !(EXTRA_ELEMENT_HANDLING.tagCheck instanceof Function && EXTRA_ELEMENT_HANDLING.tagCheck(tagName)) && !ALLOWED_TAGS[tagName]) {
/* Check if we have a custom element to handle */ if (!FORBID_TAGS[tagName] && _isBasicCustomElement(tagName)) {
if (CUSTOM_ELEMENT_HANDLING.tagNameCheck instanceof RegExp && regExpTest(CUSTOM_ELEMENT_HANDLING.tagNameCheck, tagName)) {
return false;
}
if (CUSTOM_ELEMENT_HANDLING.tagNameCheck instanceof Function && CUSTOM_ELEMENT_HANDLING.tagNameCheck(tagName)) {
return false;
}
}
/* Keep content except for bad-listed elements */ if (KEEP_CONTENT && !FORBID_CONTENTS[tagName]) {
const parentNode = getParentNode(currentNode) || currentNode.parentNode;
const childNodes = getChildNodes(currentNode) || currentNode.childNodes;
if (childNodes && parentNode) {
const childCount = childNodes.length;
for(let i = childCount - 1; i >= 0; --i){
const childClone = cloneNode(childNodes[i], true);
parentNode.insertBefore(childClone, getNextSibling(currentNode));
}
}
}
_forceRemove(currentNode);
return true;
}
/* Check whether element has a valid namespace */ if (currentNode instanceof Element && !_checkValidNamespace(currentNode)) {
_forceRemove(currentNode);
return true;
}
/* Make sure that older browsers don't get fallback-tag mXSS */ if ((tagName === 'noscript' || tagName === 'noembed' || tagName === 'noframes') && regExpTest(/<\/no(script|embed|frames)/i, currentNode.innerHTML)) {
_forceRemove(currentNode);
return true;
}
/* Sanitize element content to be template-safe */ if (SAFE_FOR_TEMPLATES && currentNode.nodeType === NODE_TYPE.text) {
/* Get the element's text content */ content = currentNode.textContent;
arrayForEach([
MUSTACHE_EXPR$1,
ERB_EXPR$1,
TMPLIT_EXPR$1
], (expr)=>{
content = stringReplace(content, expr, ' ');
});
if (currentNode.textContent !== content) {
arrayPush(DOMPurify.removed, {
element: currentNode.cloneNode()
});
currentNode.textContent = content;
}
}
/* Execute a hook if present */ _executeHooks(hooks.afterSanitizeElements, currentNode, null);
return false;
};
/**
* _isValidAttribute
*
* @param lcTag Lowercase tag name of containing element.
* @param lcName Lowercase attribute name.
* @param value Attribute value.
* @return Returns true if `value` is valid, otherwise false.
*/ // eslint-disable-next-line complexity
const _isValidAttribute = function _isValidAttribute(lcTag, lcName, value) {
/* FORBID_ATTR must always win, even if ADD_ATTR predicate would allow it */ if (FORBID_ATTR[lcName]) {
return false;
}
/* Make sure attribute cannot clobber */ if (SANITIZE_DOM && (lcName === 'id' || lcName === 'name') && (value in document || value in formElement)) {
return false;
}
const nameIsPermitted = ALLOWED_ATTR[lcName] || EXTRA_ELEMENT_HANDLING.attributeCheck instanceof Function && EXTRA_ELEMENT_HANDLING.attributeCheck(lcName, lcTag);
/* Allow valid data-* attributes: At least one character after "-"
(https://html.spec.whatwg.org/multipage/dom.html#embedding-custom-non-visible-data-with-the-data-*-attributes)
XML-compatible (https://html.spec.whatwg.org/multipage/infrastructure.html#xml-compatible and http://www.w3.org/TR/xml/#d0e804)
We don't need to check the value; it's always URI safe. */ if (ALLOW_DATA_ATTR && !FORBID_ATTR[lcName] && regExpTest(DATA_ATTR$1, lcName)) ;
else if (ALLOW_ARIA_ATTR && regExpTest(ARIA_ATTR$1, lcName)) ;
else if (!nameIsPermitted || FORBID_ATTR[lcName]) {
if (// First condition does a very basic check if a) it's basically a valid custom element tagname AND
// b) if the tagName passes whatever the user has configured for CUSTOM_ELEMENT_HANDLING.tagNameCheck
// and c) if the attribute name passes whatever the user has configured for CUSTOM_ELEMENT_HANDLING.attributeNameCheck
_isBasicCustomElement(lcTag) && (CUSTOM_ELEMENT_HANDLING.tagNameCheck instanceof RegExp && regExpTest(CUSTOM_ELEMENT_HANDLING.tagNameCheck, lcTag) || CUSTOM_ELEMENT_HANDLING.tagNameCheck instanceof Function && CUSTOM_ELEMENT_HANDLING.tagNameCheck(lcTag)) && (CUSTOM_ELEMENT_HANDLING.attributeNameCheck instanceof RegExp && regExpTest(CUSTOM_ELEMENT_HANDLING.attributeNameCheck, lcName) || CUSTOM_ELEMENT_HANDLING.attributeNameCheck instanceof Function && CUSTOM_ELEMENT_HANDLING.attributeNameCheck(lcName, lcTag)) || // Alternative, second condition checks if it's an `is`-attribute, AND
// the value passes whatever the user has configured for CUSTOM_ELEMENT_HANDLING.tagNameCheck
lcName === 'is' && CUSTOM_ELEMENT_HANDLING.allowCustomizedBuiltInElements && (CUSTOM_ELEMENT_HANDLING.tagNameCheck instanceof RegExp && regExpTest(CUSTOM_ELEMENT_HANDLING.tagNameCheck, value) || CUSTOM_ELEMENT_HANDLING.tagNameCheck instanceof Function && CUSTOM_ELEMENT_HANDLING.tagNameCheck(value))) ;
else {
return false;
}
/* Check value is safe. First, is attr inert? If so, is safe */ } else if (URI_SAFE_ATTRIBUTES[lcName]) ;
else if (regExpTest(IS_ALLOWED_URI$1, stringReplace(value, ATTR_WHITESPACE$1, ''))) ;
else if ((lcName === 'src' || lcName === 'xlink:href' || lcName === 'href') && lcTag !== 'script' && stringIndexOf(value, 'data:') === 0 && DATA_URI_TAGS[lcTag]) ;
else if (ALLOW_UNKNOWN_PROTOCOLS && !regExpTest(IS_SCRIPT_OR_DATA$1, stringReplace(value, ATTR_WHITESPACE$1, ''))) ;
else if (value) {
return false;
} else ;
return true;
};
/* Names the HTML spec reserves from valid-custom-element-name; these must
* never be treated as basic custom elements even when a permissive
* CUSTOM_ELEMENT_HANDLING.tagNameCheck is configured. */ const RESERVED_CUSTOM_ELEMENT_NAMES = addToSet({}, [
'annotation-xml',
'color-profile',
'font-face',
'font-face-format',
'font-face-name',
'font-face-src',
'font-face-uri',
'missing-glyph'
]);
/**
* _isBasicCustomElement
* checks if at least one dash is included in tagName, and it's not the first char
* for more sophisticated checking see https://github.com/sindresorhus/validate-element-name
*
* @param tagName name of the tag of the node to sanitize
* @returns Returns true if the tag name meets the basic criteria for a custom element, otherwise false.
*/ const _isBasicCustomElement = function _isBasicCustomElement(tagName) {
return !RESERVED_CUSTOM_ELEMENT_NAMES[stringToLowerCase(tagName)] && regExpTest(CUSTOM_ELEMENT$1, tagName);
};
/**
* _sanitizeAttributes
*
* @protect attributes
* @protect nodeName
* @protect removeAttribute
* @protect setAttribute
*
* @param currentNode to sanitize
*/ const _sanitizeAttributes = function _sanitizeAttributes(currentNode) {
/* Execute a hook if present */ _executeHooks(hooks.beforeSanitizeAttributes, currentNode, null);
const attributes = currentNode.attributes;
/* Check if we have attributes; if not we might have a text node */ if (!attributes || _isClobbered(currentNode)) {
return;
}
const hookEvent = {
attrName: '',
attrValue: '',
keepAttr: true,
allowedAttributes: ALLOWED_ATTR,
forceKeepAttr: undefined
};
let l = attributes.length;
/* Go backwards over all attributes; safely remove bad ones */ while(l--){
const attr = attributes[l];
const name = attr.name, namespaceURI = attr.namespaceURI, attrValue = attr.value;
const lcName = transformCaseFunc(name);
const initValue = attrValue;
let value = name === 'value' ? initValue : stringTrim(initValue);
/* Execute a hook if present */ hookEvent.attrName = lcName;
hookEvent.attrValue = value;
hookEvent.keepAttr = true;
hookEvent.forceKeepAttr = undefined; // Allows developers to see this is a property they can set
_executeHooks(hooks.uponSanitizeAttribute, currentNode, hookEvent);
value = hookEvent.attrValue;
/* Full DOM Clobbering protection via namespace isolation,
* Prefix id and name attributes with `user-content-`
*/ if (SANITIZE_NAMED_PROPS && (lcName === 'id' || lcName === 'name') && stringIndexOf(value, SANITIZE_NAMED_PROPS_PREFIX) !== 0) {
// Remove the attribute with this value
_removeAttribute(name, currentNode);
// Prefix the value and later re-create the attribute with the sanitized value
value = SANITIZE_NAMED_PROPS_PREFIX + value;
}
// Else: already prefixed, leave the attribute alone — the prefix is
// itself the clobbering protection, and re-applying it is incorrect.
/* Work around a security issue with comments inside attributes */ if (SAFE_FOR_XML && regExpTest(/((--!?|])>)|<\/(style|script|title|xmp|textarea|noscript|iframe|noembed|noframes)/i, value)) {
_removeAttribute(name, currentNode);
continue;
}
/* Make sure we cannot easily use animated hrefs, even if animations are allowed */ if (lcName === 'attributename' && stringMatch(value, 'href')) {
_removeAttribute(name, currentNode);
continue;
}
/* Did the hooks approve of the attribute? */ if (hookEvent.forceKeepAttr) {
continue;
}
/* Did the hooks approve of the attribute? */ if (!hookEvent.keepAttr) {
_removeAttribute(name, currentNode);
continue;
}
/* Work around a security issue in jQuery 3.0 */ if (!ALLOW_SELF_CLOSE_IN_ATTR && regExpTest(/\/>/i, value)) {
_removeAttribute(name, currentNode);
continue;
}
/* Sanitize attribute content to be template-safe */ if (SAFE_FOR_TEMPLATES) {
arrayForEach([
MUSTACHE_EXPR$1,
ERB_EXPR$1,
TMPLIT_EXPR$1
], (expr)=>{
value = stringReplace(value, expr, ' ');
});
}
/* Is `value` valid for this attribute? */ const lcTag = transformCaseFunc(currentNode.nodeName);
if (!_isValidAttribute(lcTag, lcName, value)) {
_removeAttribute(name, currentNode);
continue;
}
/* Handle attributes that require Trusted Types */ if (trustedTypesPolicy && typeof trustedTypes === 'object' && typeof trustedTypes.getAttributeType === 'function') {
if (namespaceURI) ;
else {
switch(trustedTypes.getAttributeType(lcTag, lcName)){
case 'TrustedHTML':
{
value = trustedTypesPolicy.createHTML(value);
break;
}
case 'TrustedScriptURL':
{
value = trustedTypesPolicy.createScriptURL(value);
break;
}
}
}
}
/* Handle invalid data-* attribute set by try-catching it */ if (value !== initValue) {
try {
if (namespaceURI) {
currentNode.setAttributeNS(namespaceURI, name, value);
} else {
/* Fallback to setAttribute() for browser-unrecognized namespaces e.g. "x-schema". */ currentNode.setAttribute(name, value);
}
if (_isClobbered(currentNode)) {
_forceRemove(currentNode);
} else {
arrayPop(DOMPurify.removed);
}
} catch (_) {
_removeAttribute(name, currentNode);
}
}
}
/* Execute a hook if present */ _executeHooks(hooks.afterSanitizeAttributes, currentNode, null);
};
/**
* _sanitizeShadowDOM
*
* @param fragment to iterate over recursively
*/ const _sanitizeShadowDOM2 = function _sanitizeShadowDOM(fragment) {
let shadowNode = null;
const shadowIterator = _createNodeIterator(fragment);
/* Execute a hook if present */ _executeHooks(hooks.beforeSanitizeShadowDOM, fragment, null);
while(shadowNode = shadowIterator.nextNode()){
/* Execute a hook if present */ _executeHooks(hooks.uponSanitizeShadowNode, shadowNode, null);
/* Sanitize tags and elements */ _sanitizeElements(shadowNode);
/* Check attributes next */ _sanitizeAttributes(shadowNode);
/* Deep shadow DOM detected */ if (shadowNode.content instanceof DocumentFragment) {
_sanitizeShadowDOM2(shadowNode.content);
}
}
/* Execute a hook if present */ _executeHooks(hooks.afterSanitizeShadowDOM, fragment, null);
};
/**
* _sanitizeAttachedShadowRoots
*
* Walks `root` and feeds every attached shadow root we encounter into
* the existing _sanitizeShadowDOM pipeline. The default node iterator
* does not descend into shadow trees, so nodes inside an attached
* shadow root would otherwise be skipped entirely.
*
* Two real input paths put attached shadow roots in front of us:
* 1. IN_PLACE on a DOM node that already has shadow roots attached.
* 2. DOM-node input where importNode(dirty, true) deep-clones the
* shadow root because it was created with `clonable: true`.
*
* This pass runs once, up front, so the main iteration loop (and the
* existing _sanitizeShadowDOM template-content recursion) stay
* untouched — string-input paths are not affected.
*
* @param root the subtree root to walk for attached shadow roots
*/ const _sanitizeAttachedShadowRoots2 = function _sanitizeAttachedShadowRoots(root) {
if (root.nodeType === NODE_TYPE.element && root.shadowRoot instanceof DocumentFragment) {
const sr = root.shadowRoot;
// Recurse first so that nested shadow roots are reached even if
// _sanitizeShadowDOM removes hosts at this level.
_sanitizeAttachedShadowRoots2(sr);
_sanitizeShadowDOM2(sr);
}
// Snapshot children before recursing. Sanitization of one subtree
// (e.g. via an uponSanitizeShadowNode hook) may detach siblings,
// and naive nextSibling traversal would silently skip the rest of
// the list once a node is detached.
const childNodes = root.childNodes;
if (!childNodes) {
return;
}
const snapshot = [];
arrayForEach(childNodes, (child)=>{
arrayPush(snapshot, child);
});
for (const child of snapshot){
_sanitizeAttachedShadowRoots2(child);
}
};
// eslint-disable-next-line complexity
DOMPurify.sanitize = function(dirty) {
let cfg = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
let body = null;
let importedNode = null;
let currentNode = null;
let returnNode = null;
/* Make sure we have a string to sanitize.
DO NOT return early, as this will return the wrong type if
the user has requested a DOM object rather than a string */ IS_EMPTY_INPUT = !dirty;
if (IS_EMPTY_INPUT) {
dirty = '<!-->';
}
/* Stringify, in case dirty is an object */ if (typeof dirty !== 'string' && !_isNode(dirty)) {
dirty = stringifyValue(dirty);
if (typeof dirty !== 'string') {
throw typeErrorCreate('dirty is not a string, aborting');
}
}
/* Return dirty HTML if DOMPurify cannot run */ if (!DOMPurify.isSupported) {
return dirty;
}
/* Assign config vars */ if (!SET_CONFIG) {
_parseConfig(cfg);
}
/* Clean up removed elements */ DOMPurify.removed = [];
/* Check if dirty is correctly typed for IN_PLACE */ if (typeof dirty === 'string') {
IN_PLACE = false;
}
if (IN_PLACE) {
/* Do some early pre-sanitization to avoid unsafe root nodes */ const nn = dirty.nodeName;
if (typeof nn === 'string') {
const tagName = transformCaseFunc(nn);
if (!ALLOWED_TAGS[tagName] || FORBID_TAGS[tagName]) {
throw typeErrorCreate('root node is forbidden and cannot be sanitized in-place');
}
}
/* Sanitize attached shadow roots before the main iterator runs.
The iterator does not descend into shadow trees. */ _sanitizeAttachedShadowRoots2(dirty);
} else if (dirty instanceof Node) {
/* If dirty is a DOM element, append to an empty document to avoid
elements being stripped by the parser */ body = _initDocument('<!---->');
importedNode = body.ownerDocument.importNode(dirty, true);
if (importedNode.nodeType === NODE_TYPE.element && importedNode.nodeName === 'BODY') {
/* Node is already a body, use as is */ body = importedNode;
} else if (importedNode.nodeName === 'HTML') {
body = importedNode;
} else {
// eslint-disable-next-line unicorn/prefer-dom-node-append
body.appendChild(importedNode);
}
/* Clonable shadow roots are deep-cloned by importNode(); sanitize
them before the main iterator runs, since the iterator does not
descend into shadow trees. */ _sanitizeAttachedShadowRoots2(importedNode);
} else {
/* Exit directly if we have nothing to do */ if (!RETURN_DOM && !SAFE_FOR_TEMPLATES && !WHOLE_DOCUMENT && // eslint-disable-next-line unicorn/prefer-includes
dirty.indexOf('<') === -1) {
return trustedTypesPolicy && RETURN_TRUSTED_TYPE ? trustedTypesPolicy.createHTML(dirty) : dirty;
}
/* Initialize the document to work on */ body = _initDocument(dirty);
/* Check we have a DOM node from the data */ if (!body) {
return RETURN_DOM ? null : RETURN_TRUSTED_TYPE ? emptyHTML : '';
}
}
/* Remove first element node (ours) if FORCE_BODY is set */ if (body && FORCE_BODY) {
_forceRemove(body.firstChild);
}
/* Get node iterator */ const nodeIterator = _createNodeIterator(IN_PLACE ? dirty : body);
/* Now start iterating over the created document */ while(currentNode = nodeIterator.nextNode()){
/* Sanitize tags and elements */ _sanitizeElements(currentNode);
/* Check attributes next */ _sanitizeAttributes(currentNode);
/* Shadow DOM detected, sanitize it */ if (currentNode.content instanceof DocumentFragment) {
_sanitizeShadowDOM2(currentNode.content);
}
}
/* If we sanitized `dirty` in-place, return it. */ if (IN_PLACE) {
return dirty;
}
/* Return sanitized string or DOM */ if (RETURN_DOM) {
if (SAFE_FOR_TEMPLATES) {
body.normalize();
let html = body.innerHTML;
arrayForEach([
MUSTACHE_EXPR$1,
ERB_EXPR$1,
TMPLIT_EXPR$1
], (expr)=>{
html = stringReplace(html, expr, ' ');
});
body.innerHTML = html;
}
if (RETURN_DOM_FRAGMENT) {
returnNode = createDocumentFragment.call(body.ownerDocument);
while(body.firstChild){
// eslint-disable-next-line unicorn/prefer-dom-node-append
returnNode.appendChild(body.firstChild);
}
} else {
returnNode = body;
}
if (ALLOWED_ATTR.shadowroot || ALLOWED_ATTR.shadowrootmode) {
/*
AdoptNode() is not used because internal state is not reset
(e.g. the past names map of a HTMLFormElement), this is safe
in theory but we would rather not risk another attack vector.
The state that is cloned by importNode() is explicitly defined
by the specs.
*/ returnNode = importNode.call(originalDocument, returnNode, true);
}
return returnNode;
}
let serializedHTML = WHOLE_DOCUMENT ? body.outerHTML : body.innerHTML;
/* Serialize doctype if allowed */ if (WHOLE_DOCUMENT && ALLOWED_TAGS['!doctype'] && body.ownerDocument && body.ownerDocument.doctype && body.ownerDocument.doctype.name && regExpTest(DOCTYPE_NAME, body.ownerDocument.doctype.name)) {
serializedHTML = '<!DOCTYPE ' + body.ownerDocument.doctype.name + '>\n' + serializedHTML;
}
/* Sanitize final string template-safe */ if (SAFE_FOR_TEMPLATES) {
arrayForEach([
MUSTACHE_EXPR$1,
ERB_EXPR$1,
TMPLIT_EXPR$1
], (expr)=>{
serializedHTML = stringReplace(serializedHTML, expr, ' ');
});
}
return trustedTypesPolicy && RETURN_TRUSTED_TYPE ? trustedTypesPolicy.createHTML(serializedHTML) : serializedHTML;
};
DOMPurify.setConfig = function() {
let cfg = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
_parseConfig(cfg);
SET_CONFIG = true;
};
DOMPurify.clearConfig = function() {
CONFIG = null;
SET_CONFIG = false;
};
DOMPurify.isValidAttribute = function(tag, attr, value) {
/* Initialize shared config vars if necessary. */ if (!CONFIG) {
_parseConfig({});
}
const lcTag = transformCaseFunc(tag);
const lcName = transformCaseFunc(attr);
return _isValidAttribute(lcTag, lcName, value);
};
DOMPurify.addHook = function(entryPoint, hookFunction) {
if (typeof hookFunction !== 'function') {
return;
}
arrayPush(hooks[entryPoint], hookFunction);
};
DOMPurify.removeHook = function(entryPoint, hookFunction) {
if (hookFunction !== undefined) {
const index = arrayLastIndexOf(hooks[entryPoint], hookFunction);
return index === -1 ? undefined : arraySplice(hooks[entryPoint], index, 1)[0];
}
return arrayPop(hooks[entryPoint]);
};
DOMPurify.removeHooks = function(entryPoint) {
hooks[entryPoint] = [];
};
DOMPurify.removeAllHooks = function() {
hooks = _createHooksMap();
};
return DOMPurify;
}
var purify = createDOMPurify();
module.exports = purify;
}),
"[project]/node_modules/performance-now/lib/performance-now.js [app-ssr] (ecmascript)", ((__turbopack_context__, module, exports) => {
// Generated by CoffeeScript 1.12.2
(function() {
var getNanoSeconds, hrtime, loadTime, moduleLoadTime, nodeLoadTime, upTime;
if (typeof performance !== "undefined" && performance !== null && performance.now) {
module.exports = function() {
return performance.now();
};
} else if (typeof process !== "undefined" && process !== null && process.hrtime) {
module.exports = function() {
return (getNanoSeconds() - nodeLoadTime) / 1e6;
};
hrtime = process.hrtime;
getNanoSeconds = function() {
var hr;
hr = hrtime();
return hr[0] * 1e9 + hr[1];
};
moduleLoadTime = getNanoSeconds();
upTime = process.uptime() * 1e9;
nodeLoadTime = moduleLoadTime - upTime;
} else if (Date.now) {
module.exports = function() {
return Date.now() - loadTime;
};
loadTime = Date.now();
} else {
module.exports = function() {
return new Date().getTime() - loadTime;
};
loadTime = new Date().getTime();
}
}).call(/*TURBOPACK member replacement*/ __turbopack_context__.e);
}),
"[project]/node_modules/raf/index.js [app-ssr] (ecmascript)", ((__turbopack_context__, module, exports) => {
var now = __turbopack_context__.r("[project]/node_modules/performance-now/lib/performance-now.js [app-ssr] (ecmascript)"), root = ("TURBOPACK compile-time truthy", 1) ? /*TURBOPACK member replacement*/ __turbopack_context__.g : "TURBOPACK unreachable", vendors = [
'moz',
'webkit'
], suffix = 'AnimationFrame', raf = root['request' + suffix], caf = root['cancel' + suffix] || root['cancelRequest' + suffix];
for(var i = 0; !raf && i < vendors.length; i++){
raf = root[vendors[i] + 'Request' + suffix];
caf = root[vendors[i] + 'Cancel' + suffix] || root[vendors[i] + 'CancelRequest' + suffix];
}
// Some versions of FF have rAF but not cAF
if (!raf || !caf) {
var last = 0, id = 0, queue = [], frameDuration = 1000 / 60;
raf = function(callback) {
if (queue.length === 0) {
var _now = now(), next = Math.max(0, frameDuration - (_now - last));
last = next + _now;
setTimeout(function() {
var cp = queue.slice(0);
// Clear queue here to prevent
// callbacks from appending listeners
// to the current frame's queue
queue.length = 0;
for(var i = 0; i < cp.length; i++){
if (!cp[i].cancelled) {
try {
cp[i].callback(last);
} catch (e) {
setTimeout(function() {
throw e;
}, 0);
}
}
}
}, Math.round(next));
}
queue.push({
handle: ++id,
callback: callback,
cancelled: false
});
return id;
};
caf = function(handle) {
for(var i = 0; i < queue.length; i++){
if (queue[i].handle === handle) {
queue[i].cancelled = true;
}
}
};
}
module.exports = function(fn) {
// Wrap in a new function to prevent
// `cancel` potentially being assigned
// to the native rAF function
return raf.call(root, fn);
};
module.exports.cancel = function() {
caf.apply(root, arguments);
};
module.exports.polyfill = function(object) {
if (!object) {
object = root;
}
object.requestAnimationFrame = raf;
object.cancelAnimationFrame = caf;
};
}),
"[project]/node_modules/rgbcolor/index.js [app-ssr] (ecmascript)", ((__turbopack_context__, module, exports) => {
/*
Based on rgbcolor.js by Stoyan Stefanov <sstoo@gmail.com>
http://www.phpied.com/rgb-color-parser-in-javascript/
*/ module.exports = function(color_string) {
this.ok = false;
this.alpha = 1.0;
// strip any leading #
if (color_string.charAt(0) == '#') {
color_string = color_string.substr(1, 6);
}
color_string = color_string.replace(/ /g, '');
color_string = color_string.toLowerCase();
// before getting into regexps, try simple matches
// and overwrite the input
var simple_colors = {
aliceblue: 'f0f8ff',
antiquewhite: 'faebd7',
aqua: '00ffff',
aquamarine: '7fffd4',
azure: 'f0ffff',
beige: 'f5f5dc',
bisque: 'ffe4c4',
black: '000000',
blanchedalmond: 'ffebcd',
blue: '0000ff',
blueviolet: '8a2be2',
brown: 'a52a2a',
burlywood: 'deb887',
cadetblue: '5f9ea0',
chartreuse: '7fff00',
chocolate: 'd2691e',
coral: 'ff7f50',
cornflowerblue: '6495ed',
cornsilk: 'fff8dc',
crimson: 'dc143c',
cyan: '00ffff',
darkblue: '00008b',
darkcyan: '008b8b',
darkgoldenrod: 'b8860b',
darkgray: 'a9a9a9',
darkgreen: '006400',
darkkhaki: 'bdb76b',
darkmagenta: '8b008b',
darkolivegreen: '556b2f',
darkorange: 'ff8c00',
darkorchid: '9932cc',
darkred: '8b0000',
darksalmon: 'e9967a',
darkseagreen: '8fbc8f',
darkslateblue: '483d8b',
darkslategray: '2f4f4f',
darkturquoise: '00ced1',
darkviolet: '9400d3',
deeppink: 'ff1493',
deepskyblue: '00bfff',
dimgray: '696969',
dodgerblue: '1e90ff',
feldspar: 'd19275',
firebrick: 'b22222',
floralwhite: 'fffaf0',
forestgreen: '228b22',
fuchsia: 'ff00ff',
gainsboro: 'dcdcdc',
ghostwhite: 'f8f8ff',
gold: 'ffd700',
goldenrod: 'daa520',
gray: '808080',
green: '008000',
greenyellow: 'adff2f',
honeydew: 'f0fff0',
hotpink: 'ff69b4',
indianred: 'cd5c5c',
indigo: '4b0082',
ivory: 'fffff0',
khaki: 'f0e68c',
lavender: 'e6e6fa',
lavenderblush: 'fff0f5',
lawngreen: '7cfc00',
lemonchiffon: 'fffacd',
lightblue: 'add8e6',
lightcoral: 'f08080',
lightcyan: 'e0ffff',
lightgoldenrodyellow: 'fafad2',
lightgrey: 'd3d3d3',
lightgreen: '90ee90',
lightpink: 'ffb6c1',
lightsalmon: 'ffa07a',
lightseagreen: '20b2aa',
lightskyblue: '87cefa',
lightslateblue: '8470ff',
lightslategray: '778899',
lightsteelblue: 'b0c4de',
lightyellow: 'ffffe0',
lime: '00ff00',
limegreen: '32cd32',
linen: 'faf0e6',
magenta: 'ff00ff',
maroon: '800000',
mediumaquamarine: '66cdaa',
mediumblue: '0000cd',
mediumorchid: 'ba55d3',
mediumpurple: '9370d8',
mediumseagreen: '3cb371',
mediumslateblue: '7b68ee',
mediumspringgreen: '00fa9a',
mediumturquoise: '48d1cc',
mediumvioletred: 'c71585',
midnightblue: '191970',
mintcream: 'f5fffa',
mistyrose: 'ffe4e1',
moccasin: 'ffe4b5',
navajowhite: 'ffdead',
navy: '000080',
oldlace: 'fdf5e6',
olive: '808000',
olivedrab: '6b8e23',
orange: 'ffa500',
orangered: 'ff4500',
orchid: 'da70d6',
palegoldenrod: 'eee8aa',
palegreen: '98fb98',
paleturquoise: 'afeeee',
palevioletred: 'd87093',
papayawhip: 'ffefd5',
peachpuff: 'ffdab9',
peru: 'cd853f',
pink: 'ffc0cb',
plum: 'dda0dd',
powderblue: 'b0e0e6',
purple: '800080',
rebeccapurple: '663399',
red: 'ff0000',
rosybrown: 'bc8f8f',
royalblue: '4169e1',
saddlebrown: '8b4513',
salmon: 'fa8072',
sandybrown: 'f4a460',
seagreen: '2e8b57',
seashell: 'fff5ee',
sienna: 'a0522d',
silver: 'c0c0c0',
skyblue: '87ceeb',
slateblue: '6a5acd',
slategray: '708090',
snow: 'fffafa',
springgreen: '00ff7f',
steelblue: '4682b4',
tan: 'd2b48c',
teal: '008080',
thistle: 'd8bfd8',
tomato: 'ff6347',
turquoise: '40e0d0',
violet: 'ee82ee',
violetred: 'd02090',
wheat: 'f5deb3',
white: 'ffffff',
whitesmoke: 'f5f5f5',
yellow: 'ffff00',
yellowgreen: '9acd32'
};
color_string = simple_colors[color_string] || color_string;
// emd of simple type-in colors
// array of color definition objects
var color_defs = [
{
re: /^rgba\((\d{1,3}),\s*(\d{1,3}),\s*(\d{1,3}),\s*((?:\d?\.)?\d)\)$/,
example: [
'rgba(123, 234, 45, 0.8)',
'rgba(255,234,245,1.0)'
],
process: function(bits) {
return [
parseInt(bits[1]),
parseInt(bits[2]),
parseInt(bits[3]),
parseFloat(bits[4])
];
}
},
{
re: /^rgb\((\d{1,3}),\s*(\d{1,3}),\s*(\d{1,3})\)$/,
example: [
'rgb(123, 234, 45)',
'rgb(255,234,245)'
],
process: function(bits) {
return [
parseInt(bits[1]),
parseInt(bits[2]),
parseInt(bits[3])
];
}
},
{
re: /^([0-9a-fA-F]{2})([0-9a-fA-F]{2})([0-9a-fA-F]{2})$/,
example: [
'#00ff00',
'336699'
],
process: function(bits) {
return [
parseInt(bits[1], 16),
parseInt(bits[2], 16),
parseInt(bits[3], 16)
];
}
},
{
re: /^([0-9a-fA-F]{1})([0-9a-fA-F]{1})([0-9a-fA-F]{1})$/,
example: [
'#fb0',
'f0f'
],
process: function(bits) {
return [
parseInt(bits[1] + bits[1], 16),
parseInt(bits[2] + bits[2], 16),
parseInt(bits[3] + bits[3], 16)
];
}
}
];
// search through the definitions to find a match
for(var i = 0; i < color_defs.length; i++){
var re = color_defs[i].re;
var processor = color_defs[i].process;
var bits = re.exec(color_string);
if (bits) {
var channels = processor(bits);
this.r = channels[0];
this.g = channels[1];
this.b = channels[2];
if (channels.length > 3) {
this.alpha = channels[3];
}
this.ok = true;
}
}
// validate/cleanup values
this.r = this.r < 0 || isNaN(this.r) ? 0 : this.r > 255 ? 255 : this.r;
this.g = this.g < 0 || isNaN(this.g) ? 0 : this.g > 255 ? 255 : this.g;
this.b = this.b < 0 || isNaN(this.b) ? 0 : this.b > 255 ? 255 : this.b;
this.alpha = this.alpha < 0 ? 0 : this.alpha > 1.0 || isNaN(this.alpha) ? 1.0 : this.alpha;
// some getters
this.toRGB = function() {
return 'rgb(' + this.r + ', ' + this.g + ', ' + this.b + ')';
};
this.toRGBA = function() {
return 'rgba(' + this.r + ', ' + this.g + ', ' + this.b + ', ' + this.alpha + ')';
};
this.toHex = function() {
var r = this.r.toString(16);
var g = this.g.toString(16);
var b = this.b.toString(16);
if (r.length == 1) r = '0' + r;
if (g.length == 1) g = '0' + g;
if (b.length == 1) b = '0' + b;
return '#' + r + g + b;
};
// help
this.getHelpXML = function() {
var examples = new Array();
// add regexps
for(var i = 0; i < color_defs.length; i++){
var example = color_defs[i].example;
for(var j = 0; j < example.length; j++){
examples[examples.length] = example[j];
}
}
// add type-in colors
for(var sc in simple_colors){
examples[examples.length] = sc;
}
var xml = document.createElement('ul');
xml.setAttribute('id', 'rgbcolor-examples');
for(var i = 0; i < examples.length; i++){
try {
var list_item = document.createElement('li');
var list_color = new RGBColor(examples[i]);
var example_div = document.createElement('div');
example_div.style.cssText = 'margin: 3px; ' + 'border: 1px solid black; ' + 'background:' + list_color.toHex() + '; ' + 'color:' + list_color.toHex();
example_div.appendChild(document.createTextNode('test'));
var list_item_value = document.createTextNode(' ' + examples[i] + ' -> ' + list_color.toRGB() + ' -> ' + list_color.toHex());
list_item.appendChild(example_div);
list_item.appendChild(list_item_value);
xml.appendChild(list_item);
} catch (e) {}
}
return xml;
};
};
}),
"[project]/node_modules/@babel/runtime/helpers/arrayWithoutHoles.js [app-ssr] (ecmascript)", ((__turbopack_context__, module, exports) => {
var arrayLikeToArray = __turbopack_context__.r("[project]/node_modules/@babel/runtime/helpers/arrayLikeToArray.js [app-ssr] (ecmascript)");
function _arrayWithoutHoles(r) {
if (Array.isArray(r)) return arrayLikeToArray(r);
}
module.exports = _arrayWithoutHoles, module.exports.__esModule = true, module.exports["default"] = module.exports;
}),
"[project]/node_modules/@babel/runtime/helpers/iterableToArray.js [app-ssr] (ecmascript)", ((__turbopack_context__, module, exports) => {
function _iterableToArray(r) {
if ("undefined" != typeof Symbol && null != r[Symbol.iterator] || null != r["@@iterator"]) return Array.from(r);
}
module.exports = _iterableToArray, module.exports.__esModule = true, module.exports["default"] = module.exports;
}),
"[project]/node_modules/@babel/runtime/helpers/nonIterableSpread.js [app-ssr] (ecmascript)", ((__turbopack_context__, module, exports) => {
function _nonIterableSpread() {
throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
}
module.exports = _nonIterableSpread, module.exports.__esModule = true, module.exports["default"] = module.exports;
}),
"[project]/node_modules/@babel/runtime/helpers/toConsumableArray.js [app-ssr] (ecmascript)", ((__turbopack_context__, module, exports) => {
var arrayWithoutHoles = __turbopack_context__.r("[project]/node_modules/@babel/runtime/helpers/arrayWithoutHoles.js [app-ssr] (ecmascript)");
var iterableToArray = __turbopack_context__.r("[project]/node_modules/@babel/runtime/helpers/iterableToArray.js [app-ssr] (ecmascript)");
var unsupportedIterableToArray = __turbopack_context__.r("[project]/node_modules/@babel/runtime/helpers/unsupportedIterableToArray.js [app-ssr] (ecmascript)");
var nonIterableSpread = __turbopack_context__.r("[project]/node_modules/@babel/runtime/helpers/nonIterableSpread.js [app-ssr] (ecmascript)");
function _toConsumableArray(r) {
return arrayWithoutHoles(r) || iterableToArray(r) || unsupportedIterableToArray(r) || nonIterableSpread();
}
module.exports = _toConsumableArray, module.exports.__esModule = true, module.exports["default"] = module.exports;
}),
"[project]/node_modules/@babel/runtime/helpers/superPropBase.js [app-ssr] (ecmascript)", ((__turbopack_context__, module, exports) => {
var getPrototypeOf = __turbopack_context__.r("[project]/node_modules/@babel/runtime/helpers/getPrototypeOf.js [app-ssr] (ecmascript)");
function _superPropBase(t, o) {
for(; !({}).hasOwnProperty.call(t, o) && null !== (t = getPrototypeOf(t)););
return t;
}
module.exports = _superPropBase, module.exports.__esModule = true, module.exports["default"] = module.exports;
}),
"[project]/node_modules/@babel/runtime/helpers/get.js [app-ssr] (ecmascript)", ((__turbopack_context__, module, exports) => {
var superPropBase = __turbopack_context__.r("[project]/node_modules/@babel/runtime/helpers/superPropBase.js [app-ssr] (ecmascript)");
function _get() {
return module.exports = _get = "undefined" != typeof Reflect && Reflect.get ? Reflect.get.bind() : function(e, t, r) {
var p = superPropBase(e, t);
if (p) {
var n = Object.getOwnPropertyDescriptor(p, t);
return n.get ? n.get.call(arguments.length < 3 ? e : r) : n.value;
}
}, module.exports.__esModule = true, module.exports["default"] = module.exports, _get.apply(null, arguments);
}
module.exports = _get, module.exports.__esModule = true, module.exports["default"] = module.exports;
}),
"[project]/node_modules/svg-pathdata/lib/SVGPathData.cjs [app-ssr] (ecmascript)", ((__turbopack_context__, module, exports) => {
!function(t, r) {
("TURBOPACK compile-time truthy", 1) ? r(exports) : "TURBOPACK unreachable";
}(/*TURBOPACK member replacement*/ __turbopack_context__.e, function(t) {
"use strict";
/*! *****************************************************************************
Copyright (c) Microsoft Corporation.
Permission to use, copy, modify, and/or distribute this software for any
purpose with or without fee is hereby granted.
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
PERFORMANCE OF THIS SOFTWARE.
***************************************************************************** */ var r = function(t, e) {
return (r = Object.setPrototypeOf || ({
__proto__: []
}) instanceof Array && function(t, r) {
t.__proto__ = r;
} || function(t, r) {
for(var e in r)Object.prototype.hasOwnProperty.call(r, e) && (t[e] = r[e]);
})(t, e);
};
function e(t, e) {
if ("function" != typeof e && null !== e) throw new TypeError("Class extends value " + String(e) + " is not a constructor or null");
function a() {
this.constructor = t;
}
r(t, e), t.prototype = null === e ? Object.create(e) : (a.prototype = e.prototype, new a);
}
var a = " ";
function i(t) {
var r = "";
Array.isArray(t) || (t = [
t
]);
for(var e = 0; e < t.length; e++){
var i = t[e];
if (i.type === N.CLOSE_PATH) r += "z";
else if (i.type === N.HORIZ_LINE_TO) r += (i.relative ? "h" : "H") + i.x;
else if (i.type === N.VERT_LINE_TO) r += (i.relative ? "v" : "V") + i.y;
else if (i.type === N.MOVE_TO) r += (i.relative ? "m" : "M") + i.x + a + i.y;
else if (i.type === N.LINE_TO) r += (i.relative ? "l" : "L") + i.x + a + i.y;
else if (i.type === N.CURVE_TO) r += (i.relative ? "c" : "C") + i.x1 + a + i.y1 + a + i.x2 + a + i.y2 + a + i.x + a + i.y;
else if (i.type === N.SMOOTH_CURVE_TO) r += (i.relative ? "s" : "S") + i.x2 + a + i.y2 + a + i.x + a + i.y;
else if (i.type === N.QUAD_TO) r += (i.relative ? "q" : "Q") + i.x1 + a + i.y1 + a + i.x + a + i.y;
else if (i.type === N.SMOOTH_QUAD_TO) r += (i.relative ? "t" : "T") + i.x + a + i.y;
else {
if (i.type !== N.ARC) throw new Error('Unexpected command type "' + i.type + '" at index ' + e + ".");
r += (i.relative ? "a" : "A") + i.rX + a + i.rY + a + i.xRot + a + +i.lArcFlag + a + +i.sweepFlag + a + i.x + a + i.y;
}
}
return r;
}
function n(t, r) {
var e = t[0], a = t[1];
return [
e * Math.cos(r) - a * Math.sin(r),
e * Math.sin(r) + a * Math.cos(r)
];
}
function o() {
for(var t = [], r = 0; r < arguments.length; r++)t[r] = arguments[r];
for(var e = 0; e < t.length; e++)if ("number" != typeof t[e]) throw new Error("assertNumbers arguments[" + e + "] is not a number. " + typeof t[e] + " == typeof " + t[e]);
return !0;
}
var s = Math.PI;
function u(t, r, e) {
t.lArcFlag = 0 === t.lArcFlag ? 0 : 1, t.sweepFlag = 0 === t.sweepFlag ? 0 : 1;
var a = t.rX, i = t.rY, o = t.x, u = t.y;
a = Math.abs(t.rX), i = Math.abs(t.rY);
var h = n([
(r - o) / 2,
(e - u) / 2
], -t.xRot / 180 * s), c = h[0], m = h[1], y = Math.pow(c, 2) / Math.pow(a, 2) + Math.pow(m, 2) / Math.pow(i, 2);
1 < y && (a *= Math.sqrt(y), i *= Math.sqrt(y)), t.rX = a, t.rY = i;
var p = Math.pow(a, 2) * Math.pow(m, 2) + Math.pow(i, 2) * Math.pow(c, 2), f = (t.lArcFlag !== t.sweepFlag ? 1 : -1) * Math.sqrt(Math.max(0, (Math.pow(a, 2) * Math.pow(i, 2) - p) / p)), T = a * m / i * f, O = -i * c / a * f, l = n([
T,
O
], t.xRot / 180 * s);
t.cX = l[0] + (r + o) / 2, t.cY = l[1] + (e + u) / 2, t.phi1 = Math.atan2((m - O) / i, (c - T) / a), t.phi2 = Math.atan2((-m - O) / i, (-c - T) / a), 0 === t.sweepFlag && t.phi2 > t.phi1 && (t.phi2 -= 2 * s), 1 === t.sweepFlag && t.phi2 < t.phi1 && (t.phi2 += 2 * s), t.phi1 *= 180 / s, t.phi2 *= 180 / s;
}
function h(t, r, e) {
o(t, r, e);
var a = t * t + r * r - e * e;
if (0 > a) return [];
if (0 === a) return [
[
t * e / (t * t + r * r),
r * e / (t * t + r * r)
]
];
var i = Math.sqrt(a);
return [
[
(t * e + r * i) / (t * t + r * r),
(r * e - t * i) / (t * t + r * r)
],
[
(t * e - r * i) / (t * t + r * r),
(r * e + t * i) / (t * t + r * r)
]
];
}
var c = Math.PI / 180;
function m(t, r, e) {
return (1 - e) * t + e * r;
}
function y(t, r, e, a) {
return t + Math.cos(a / 180 * s) * r + Math.sin(a / 180 * s) * e;
}
function p(t, r, e, a) {
var i = 1e-6, n = r - t, o = e - r, s = 3 * n + 3 * (a - e) - 6 * o, u = 6 * (o - n), h = 3 * n;
return Math.abs(s) < i ? [
-h / u
] : function(t, r, e) {
void 0 === e && (e = 1e-6);
var a = t * t / 4 - r;
if (a < -e) return [];
if (a <= e) return [
-t / 2
];
var i = Math.sqrt(a);
return [
-t / 2 - i,
-t / 2 + i
];
}(u / s, h / s, i);
}
function f(t, r, e, a, i) {
var n = 1 - i;
return t * (n * n * n) + r * (3 * n * n * i) + e * (3 * n * i * i) + a * (i * i * i);
}
t.SVGPathDataTransformer = void 0, function(t) {
function r() {
return i(function(t, r, e) {
return t.relative && (void 0 !== t.x1 && (t.x1 += r), void 0 !== t.y1 && (t.y1 += e), void 0 !== t.x2 && (t.x2 += r), void 0 !== t.y2 && (t.y2 += e), void 0 !== t.x && (t.x += r), void 0 !== t.y && (t.y += e), t.relative = !1), t;
});
}
function e() {
var t = NaN, r = NaN, e = NaN, a = NaN;
return i(function(i, n, o) {
return i.type & N.SMOOTH_CURVE_TO && (i.type = N.CURVE_TO, t = isNaN(t) ? n : t, r = isNaN(r) ? o : r, i.x1 = i.relative ? n - t : 2 * n - t, i.y1 = i.relative ? o - r : 2 * o - r), i.type & N.CURVE_TO ? (t = i.relative ? n + i.x2 : i.x2, r = i.relative ? o + i.y2 : i.y2) : (t = NaN, r = NaN), i.type & N.SMOOTH_QUAD_TO && (i.type = N.QUAD_TO, e = isNaN(e) ? n : e, a = isNaN(a) ? o : a, i.x1 = i.relative ? n - e : 2 * n - e, i.y1 = i.relative ? o - a : 2 * o - a), i.type & N.QUAD_TO ? (e = i.relative ? n + i.x1 : i.x1, a = i.relative ? o + i.y1 : i.y1) : (e = NaN, a = NaN), i;
});
}
function a() {
var t = NaN, r = NaN;
return i(function(e, a, i) {
if (e.type & N.SMOOTH_QUAD_TO && (e.type = N.QUAD_TO, t = isNaN(t) ? a : t, r = isNaN(r) ? i : r, e.x1 = e.relative ? a - t : 2 * a - t, e.y1 = e.relative ? i - r : 2 * i - r), e.type & N.QUAD_TO) {
t = e.relative ? a + e.x1 : e.x1, r = e.relative ? i + e.y1 : e.y1;
var n = e.x1, o = e.y1;
e.type = N.CURVE_TO, e.x1 = ((e.relative ? 0 : a) + 2 * n) / 3, e.y1 = ((e.relative ? 0 : i) + 2 * o) / 3, e.x2 = (e.x + 2 * n) / 3, e.y2 = (e.y + 2 * o) / 3;
} else t = NaN, r = NaN;
return e;
});
}
function i(t) {
var r = 0, e = 0, a = NaN, i = NaN;
return function(n) {
if (isNaN(a) && !(n.type & N.MOVE_TO)) throw new Error("path must start with moveto");
var o = t(n, r, e, a, i);
return n.type & N.CLOSE_PATH && (r = a, e = i), void 0 !== n.x && (r = n.relative ? r + n.x : n.x), void 0 !== n.y && (e = n.relative ? e + n.y : n.y), n.type & N.MOVE_TO && (a = r, i = e), o;
};
}
function s(t, r, e, a, n, s) {
return o(t, r, e, a, n, s), i(function(i, o, u, h) {
var c = i.x1, m = i.x2, y = i.relative && !isNaN(h), p = void 0 !== i.x ? i.x : y ? 0 : o, f = void 0 !== i.y ? i.y : y ? 0 : u;
function T(t) {
return t * t;
}
i.type & N.HORIZ_LINE_TO && 0 !== r && (i.type = N.LINE_TO, i.y = i.relative ? 0 : u), i.type & N.VERT_LINE_TO && 0 !== e && (i.type = N.LINE_TO, i.x = i.relative ? 0 : o), void 0 !== i.x && (i.x = i.x * t + f * e + (y ? 0 : n)), void 0 !== i.y && (i.y = p * r + i.y * a + (y ? 0 : s)), void 0 !== i.x1 && (i.x1 = i.x1 * t + i.y1 * e + (y ? 0 : n)), void 0 !== i.y1 && (i.y1 = c * r + i.y1 * a + (y ? 0 : s)), void 0 !== i.x2 && (i.x2 = i.x2 * t + i.y2 * e + (y ? 0 : n)), void 0 !== i.y2 && (i.y2 = m * r + i.y2 * a + (y ? 0 : s));
var O = t * a - r * e;
if (void 0 !== i.xRot && (1 !== t || 0 !== r || 0 !== e || 1 !== a)) if (0 === O) delete i.rX, delete i.rY, delete i.xRot, delete i.lArcFlag, delete i.sweepFlag, i.type = N.LINE_TO;
else {
var l = i.xRot * Math.PI / 180, v = Math.sin(l), _ = Math.cos(l), d = 1 / T(i.rX), x = 1 / T(i.rY), A = T(_) * d + T(v) * x, E = 2 * v * _ * (d - x), C = T(v) * d + T(_) * x, M = A * a * a - E * r * a + C * r * r, R = E * (t * a + r * e) - 2 * (A * e * a + C * t * r), S = A * e * e - E * t * e + C * t * t, g = (Math.atan2(R, M - S) + Math.PI) % Math.PI / 2, I = Math.sin(g), V = Math.cos(g);
i.rX = Math.abs(O) / Math.sqrt(M * T(V) + R * I * V + S * T(I)), i.rY = Math.abs(O) / Math.sqrt(M * T(I) - R * I * V + S * T(V)), i.xRot = 180 * g / Math.PI;
}
return void 0 !== i.sweepFlag && 0 > O && (i.sweepFlag = +!i.sweepFlag), i;
});
}
function T() {
return function(t) {
var r = {};
for(var e in t)r[e] = t[e];
return r;
};
}
t.ROUND = function(t) {
function r(r) {
return Math.round(r * t) / t;
}
return void 0 === t && (t = 1e13), o(t), function(t) {
return void 0 !== t.x1 && (t.x1 = r(t.x1)), void 0 !== t.y1 && (t.y1 = r(t.y1)), void 0 !== t.x2 && (t.x2 = r(t.x2)), void 0 !== t.y2 && (t.y2 = r(t.y2)), void 0 !== t.x && (t.x = r(t.x)), void 0 !== t.y && (t.y = r(t.y)), void 0 !== t.rX && (t.rX = r(t.rX)), void 0 !== t.rY && (t.rY = r(t.rY)), t;
};
}, t.TO_ABS = r, t.TO_REL = function() {
return i(function(t, r, e) {
return t.relative || (void 0 !== t.x1 && (t.x1 -= r), void 0 !== t.y1 && (t.y1 -= e), void 0 !== t.x2 && (t.x2 -= r), void 0 !== t.y2 && (t.y2 -= e), void 0 !== t.x && (t.x -= r), void 0 !== t.y && (t.y -= e), t.relative = !0), t;
});
}, t.NORMALIZE_HVZ = function(t, r, e) {
return void 0 === t && (t = !0), void 0 === r && (r = !0), void 0 === e && (e = !0), i(function(a, i, n, o, s) {
if (isNaN(o) && !(a.type & N.MOVE_TO)) throw new Error("path must start with moveto");
return r && a.type & N.HORIZ_LINE_TO && (a.type = N.LINE_TO, a.y = a.relative ? 0 : n), e && a.type & N.VERT_LINE_TO && (a.type = N.LINE_TO, a.x = a.relative ? 0 : i), t && a.type & N.CLOSE_PATH && (a.type = N.LINE_TO, a.x = a.relative ? o - i : o, a.y = a.relative ? s - n : s), a.type & N.ARC && (0 === a.rX || 0 === a.rY) && (a.type = N.LINE_TO, delete a.rX, delete a.rY, delete a.xRot, delete a.lArcFlag, delete a.sweepFlag), a;
});
}, t.NORMALIZE_ST = e, t.QT_TO_C = a, t.INFO = i, t.SANITIZE = function(t) {
void 0 === t && (t = 0), o(t);
var r = NaN, e = NaN, a = NaN, n = NaN;
return i(function(i, o, s, u, h) {
var c = Math.abs, m = !1, y = 0, p = 0;
if (i.type & N.SMOOTH_CURVE_TO && (y = isNaN(r) ? 0 : o - r, p = isNaN(e) ? 0 : s - e), i.type & (N.CURVE_TO | N.SMOOTH_CURVE_TO) ? (r = i.relative ? o + i.x2 : i.x2, e = i.relative ? s + i.y2 : i.y2) : (r = NaN, e = NaN), i.type & N.SMOOTH_QUAD_TO ? (a = isNaN(a) ? o : 2 * o - a, n = isNaN(n) ? s : 2 * s - n) : i.type & N.QUAD_TO ? (a = i.relative ? o + i.x1 : i.x1, n = i.relative ? s + i.y1 : i.y2) : (a = NaN, n = NaN), i.type & N.LINE_COMMANDS || i.type & N.ARC && (0 === i.rX || 0 === i.rY || !i.lArcFlag) || i.type & N.CURVE_TO || i.type & N.SMOOTH_CURVE_TO || i.type & N.QUAD_TO || i.type & N.SMOOTH_QUAD_TO) {
var f = void 0 === i.x ? 0 : i.relative ? i.x : i.x - o, T = void 0 === i.y ? 0 : i.relative ? i.y : i.y - s;
y = isNaN(a) ? void 0 === i.x1 ? y : i.relative ? i.x : i.x1 - o : a - o, p = isNaN(n) ? void 0 === i.y1 ? p : i.relative ? i.y : i.y1 - s : n - s;
var O = void 0 === i.x2 ? 0 : i.relative ? i.x : i.x2 - o, l = void 0 === i.y2 ? 0 : i.relative ? i.y : i.y2 - s;
c(f) <= t && c(T) <= t && c(y) <= t && c(p) <= t && c(O) <= t && c(l) <= t && (m = !0);
}
return i.type & N.CLOSE_PATH && c(o - u) <= t && c(s - h) <= t && (m = !0), m ? [] : i;
});
}, t.MATRIX = s, t.ROTATE = function(t, r, e) {
void 0 === r && (r = 0), void 0 === e && (e = 0), o(t, r, e);
var a = Math.sin(t), i = Math.cos(t);
return s(i, a, -a, i, r - r * i + e * a, e - r * a - e * i);
}, t.TRANSLATE = function(t, r) {
return void 0 === r && (r = 0), o(t, r), s(1, 0, 0, 1, t, r);
}, t.SCALE = function(t, r) {
return void 0 === r && (r = t), o(t, r), s(t, 0, 0, r, 0, 0);
}, t.SKEW_X = function(t) {
return o(t), s(1, 0, Math.atan(t), 1, 0, 0);
}, t.SKEW_Y = function(t) {
return o(t), s(1, Math.atan(t), 0, 1, 0, 0);
}, t.X_AXIS_SYMMETRY = function(t) {
return void 0 === t && (t = 0), o(t), s(-1, 0, 0, 1, t, 0);
}, t.Y_AXIS_SYMMETRY = function(t) {
return void 0 === t && (t = 0), o(t), s(1, 0, 0, -1, 0, t);
}, t.A_TO_C = function() {
return i(function(t, r, e) {
return N.ARC === t.type ? function(t, r, e) {
var a, i, o, s;
t.cX || u(t, r, e);
for(var h = Math.min(t.phi1, t.phi2), y = Math.max(t.phi1, t.phi2) - h, p = Math.ceil(y / 90), f = new Array(p), T = r, O = e, l = 0; l < p; l++){
var v = m(t.phi1, t.phi2, l / p), _ = m(t.phi1, t.phi2, (l + 1) / p), d = _ - v, x = 4 / 3 * Math.tan(d * c / 4), A = [
Math.cos(v * c) - x * Math.sin(v * c),
Math.sin(v * c) + x * Math.cos(v * c)
], E = A[0], C = A[1], M = [
Math.cos(_ * c),
Math.sin(_ * c)
], R = M[0], S = M[1], g = [
R + x * Math.sin(_ * c),
S - x * Math.cos(_ * c)
], I = g[0], V = g[1];
f[l] = {
relative: t.relative,
type: N.CURVE_TO
};
var D = function(r, e) {
var a = n([
r * t.rX,
e * t.rY
], t.xRot), i = a[0], o = a[1];
return [
t.cX + i,
t.cY + o
];
};
a = D(E, C), f[l].x1 = a[0], f[l].y1 = a[1], i = D(I, V), f[l].x2 = i[0], f[l].y2 = i[1], o = D(R, S), f[l].x = o[0], f[l].y = o[1], t.relative && (f[l].x1 -= T, f[l].y1 -= O, f[l].x2 -= T, f[l].y2 -= O, f[l].x -= T, f[l].y -= O), T = (s = [
f[l].x,
f[l].y
])[0], O = s[1];
}
return f;
}(t, t.relative ? 0 : r, t.relative ? 0 : e) : t;
});
}, t.ANNOTATE_ARCS = function() {
return i(function(t, r, e) {
return t.relative && (r = 0, e = 0), N.ARC === t.type && u(t, r, e), t;
});
}, t.CLONE = T, t.CALCULATE_BOUNDS = function() {
var t = function(t) {
var r = {};
for(var e in t)r[e] = t[e];
return r;
}, n = r(), o = a(), s = e(), c = i(function(r, e, a) {
var i = s(o(n(t(r))));
function m(t) {
t > c.maxX && (c.maxX = t), t < c.minX && (c.minX = t);
}
function T(t) {
t > c.maxY && (c.maxY = t), t < c.minY && (c.minY = t);
}
if (i.type & N.DRAWING_COMMANDS && (m(e), T(a)), i.type & N.HORIZ_LINE_TO && m(i.x), i.type & N.VERT_LINE_TO && T(i.y), i.type & N.LINE_TO && (m(i.x), T(i.y)), i.type & N.CURVE_TO) {
m(i.x), T(i.y);
for(var O = 0, l = p(e, i.x1, i.x2, i.x); O < l.length; O++){
0 < (H = l[O]) && 1 > H && m(f(e, i.x1, i.x2, i.x, H));
}
for(var v = 0, _ = p(a, i.y1, i.y2, i.y); v < _.length; v++){
0 < (H = _[v]) && 1 > H && T(f(a, i.y1, i.y2, i.y, H));
}
}
if (i.type & N.ARC) {
m(i.x), T(i.y), u(i, e, a);
for(var d = i.xRot / 180 * Math.PI, x = Math.cos(d) * i.rX, A = Math.sin(d) * i.rX, E = -Math.sin(d) * i.rY, C = Math.cos(d) * i.rY, M = i.phi1 < i.phi2 ? [
i.phi1,
i.phi2
] : -180 > i.phi2 ? [
i.phi2 + 360,
i.phi1 + 360
] : [
i.phi2,
i.phi1
], R = M[0], S = M[1], g = function(t) {
var r = t[0], e = t[1], a = 180 * Math.atan2(e, r) / Math.PI;
return a < R ? a + 360 : a;
}, I = 0, V = h(E, -x, 0).map(g); I < V.length; I++){
(H = V[I]) > R && H < S && m(y(i.cX, x, E, H));
}
for(var D = 0, L = h(C, -A, 0).map(g); D < L.length; D++){
var H;
(H = L[D]) > R && H < S && T(y(i.cY, A, C, H));
}
}
return r;
});
return c.minX = 1 / 0, c.maxX = -1 / 0, c.minY = 1 / 0, c.maxY = -1 / 0, c;
};
}(t.SVGPathDataTransformer || (t.SVGPathDataTransformer = {}));
var T, O = function() {
function r() {}
return r.prototype.round = function(r) {
return this.transform(t.SVGPathDataTransformer.ROUND(r));
}, r.prototype.toAbs = function() {
return this.transform(t.SVGPathDataTransformer.TO_ABS());
}, r.prototype.toRel = function() {
return this.transform(t.SVGPathDataTransformer.TO_REL());
}, r.prototype.normalizeHVZ = function(r, e, a) {
return this.transform(t.SVGPathDataTransformer.NORMALIZE_HVZ(r, e, a));
}, r.prototype.normalizeST = function() {
return this.transform(t.SVGPathDataTransformer.NORMALIZE_ST());
}, r.prototype.qtToC = function() {
return this.transform(t.SVGPathDataTransformer.QT_TO_C());
}, r.prototype.aToC = function() {
return this.transform(t.SVGPathDataTransformer.A_TO_C());
}, r.prototype.sanitize = function(r) {
return this.transform(t.SVGPathDataTransformer.SANITIZE(r));
}, r.prototype.translate = function(r, e) {
return this.transform(t.SVGPathDataTransformer.TRANSLATE(r, e));
}, r.prototype.scale = function(r, e) {
return this.transform(t.SVGPathDataTransformer.SCALE(r, e));
}, r.prototype.rotate = function(r, e, a) {
return this.transform(t.SVGPathDataTransformer.ROTATE(r, e, a));
}, r.prototype.matrix = function(r, e, a, i, n, o) {
return this.transform(t.SVGPathDataTransformer.MATRIX(r, e, a, i, n, o));
}, r.prototype.skewX = function(r) {
return this.transform(t.SVGPathDataTransformer.SKEW_X(r));
}, r.prototype.skewY = function(r) {
return this.transform(t.SVGPathDataTransformer.SKEW_Y(r));
}, r.prototype.xSymmetry = function(r) {
return this.transform(t.SVGPathDataTransformer.X_AXIS_SYMMETRY(r));
}, r.prototype.ySymmetry = function(r) {
return this.transform(t.SVGPathDataTransformer.Y_AXIS_SYMMETRY(r));
}, r.prototype.annotateArcs = function() {
return this.transform(t.SVGPathDataTransformer.ANNOTATE_ARCS());
}, r;
}(), l = function(t) {
return " " === t || "\t" === t || "\r" === t || "\n" === t;
}, v = function(t) {
return "0".charCodeAt(0) <= t.charCodeAt(0) && t.charCodeAt(0) <= "9".charCodeAt(0);
}, _ = function(t) {
function r() {
var r = t.call(this) || this;
return r.curNumber = "", r.curCommandType = -1, r.curCommandRelative = !1, r.canParseCommandOrComma = !0, r.curNumberHasExp = !1, r.curNumberHasExpDigits = !1, r.curNumberHasDecimal = !1, r.curArgs = [], r;
}
return e(r, t), r.prototype.finish = function(t) {
if (void 0 === t && (t = []), this.parse(" ", t), 0 !== this.curArgs.length || !this.canParseCommandOrComma) throw new SyntaxError("Unterminated command at the path end.");
return t;
}, r.prototype.parse = function(t, r) {
var e = this;
void 0 === r && (r = []);
for(var a = function(t) {
r.push(t), e.curArgs.length = 0, e.canParseCommandOrComma = !0;
}, i = 0; i < t.length; i++){
var n = t[i], o = !(this.curCommandType !== N.ARC || 3 !== this.curArgs.length && 4 !== this.curArgs.length || 1 !== this.curNumber.length || "0" !== this.curNumber && "1" !== this.curNumber), s = v(n) && ("0" === this.curNumber && "0" === n || o);
if (!v(n) || s) if ("e" !== n && "E" !== n) if ("-" !== n && "+" !== n || !this.curNumberHasExp || this.curNumberHasExpDigits) if ("." !== n || this.curNumberHasExp || this.curNumberHasDecimal || o) {
if (this.curNumber && -1 !== this.curCommandType) {
var u = Number(this.curNumber);
if (isNaN(u)) throw new SyntaxError("Invalid number ending at " + i);
if (this.curCommandType === N.ARC) {
if (0 === this.curArgs.length || 1 === this.curArgs.length) {
if (0 > u) throw new SyntaxError('Expected positive number, got "' + u + '" at index "' + i + '"');
} else if ((3 === this.curArgs.length || 4 === this.curArgs.length) && "0" !== this.curNumber && "1" !== this.curNumber) throw new SyntaxError('Expected a flag, got "' + this.curNumber + '" at index "' + i + '"');
}
this.curArgs.push(u), this.curArgs.length === d[this.curCommandType] && (N.HORIZ_LINE_TO === this.curCommandType ? a({
type: N.HORIZ_LINE_TO,
relative: this.curCommandRelative,
x: u
}) : N.VERT_LINE_TO === this.curCommandType ? a({
type: N.VERT_LINE_TO,
relative: this.curCommandRelative,
y: u
}) : this.curCommandType === N.MOVE_TO || this.curCommandType === N.LINE_TO || this.curCommandType === N.SMOOTH_QUAD_TO ? (a({
type: this.curCommandType,
relative: this.curCommandRelative,
x: this.curArgs[0],
y: this.curArgs[1]
}), N.MOVE_TO === this.curCommandType && (this.curCommandType = N.LINE_TO)) : this.curCommandType === N.CURVE_TO ? a({
type: N.CURVE_TO,
relative: this.curCommandRelative,
x1: this.curArgs[0],
y1: this.curArgs[1],
x2: this.curArgs[2],
y2: this.curArgs[3],
x: this.curArgs[4],
y: this.curArgs[5]
}) : this.curCommandType === N.SMOOTH_CURVE_TO ? a({
type: N.SMOOTH_CURVE_TO,
relative: this.curCommandRelative,
x2: this.curArgs[0],
y2: this.curArgs[1],
x: this.curArgs[2],
y: this.curArgs[3]
}) : this.curCommandType === N.QUAD_TO ? a({
type: N.QUAD_TO,
relative: this.curCommandRelative,
x1: this.curArgs[0],
y1: this.curArgs[1],
x: this.curArgs[2],
y: this.curArgs[3]
}) : this.curCommandType === N.ARC && a({
type: N.ARC,
relative: this.curCommandRelative,
rX: this.curArgs[0],
rY: this.curArgs[1],
xRot: this.curArgs[2],
lArcFlag: this.curArgs[3],
sweepFlag: this.curArgs[4],
x: this.curArgs[5],
y: this.curArgs[6]
})), this.curNumber = "", this.curNumberHasExpDigits = !1, this.curNumberHasExp = !1, this.curNumberHasDecimal = !1, this.canParseCommandOrComma = !0;
}
if (!l(n)) if ("," === n && this.canParseCommandOrComma) this.canParseCommandOrComma = !1;
else if ("+" !== n && "-" !== n && "." !== n) if (s) this.curNumber = n, this.curNumberHasDecimal = !1;
else {
if (0 !== this.curArgs.length) throw new SyntaxError("Unterminated command at index " + i + ".");
if (!this.canParseCommandOrComma) throw new SyntaxError('Unexpected character "' + n + '" at index ' + i + ". Command cannot follow comma");
if (this.canParseCommandOrComma = !1, "z" !== n && "Z" !== n) if ("h" === n || "H" === n) this.curCommandType = N.HORIZ_LINE_TO, this.curCommandRelative = "h" === n;
else if ("v" === n || "V" === n) this.curCommandType = N.VERT_LINE_TO, this.curCommandRelative = "v" === n;
else if ("m" === n || "M" === n) this.curCommandType = N.MOVE_TO, this.curCommandRelative = "m" === n;
else if ("l" === n || "L" === n) this.curCommandType = N.LINE_TO, this.curCommandRelative = "l" === n;
else if ("c" === n || "C" === n) this.curCommandType = N.CURVE_TO, this.curCommandRelative = "c" === n;
else if ("s" === n || "S" === n) this.curCommandType = N.SMOOTH_CURVE_TO, this.curCommandRelative = "s" === n;
else if ("q" === n || "Q" === n) this.curCommandType = N.QUAD_TO, this.curCommandRelative = "q" === n;
else if ("t" === n || "T" === n) this.curCommandType = N.SMOOTH_QUAD_TO, this.curCommandRelative = "t" === n;
else {
if ("a" !== n && "A" !== n) throw new SyntaxError('Unexpected character "' + n + '" at index ' + i + ".");
this.curCommandType = N.ARC, this.curCommandRelative = "a" === n;
}
else r.push({
type: N.CLOSE_PATH
}), this.canParseCommandOrComma = !0, this.curCommandType = -1;
}
else this.curNumber = n, this.curNumberHasDecimal = "." === n;
} else this.curNumber += n, this.curNumberHasDecimal = !0;
else this.curNumber += n;
else this.curNumber += n, this.curNumberHasExp = !0;
else this.curNumber += n, this.curNumberHasExpDigits = this.curNumberHasExp;
}
return r;
}, r.prototype.transform = function(t) {
return Object.create(this, {
parse: {
value: function(r, e) {
void 0 === e && (e = []);
for(var a = 0, i = Object.getPrototypeOf(this).parse.call(this, r); a < i.length; a++){
var n = i[a], o = t(n);
Array.isArray(o) ? e.push.apply(e, o) : e.push(o);
}
return e;
}
}
});
}, r;
}(O), N = function(r) {
function a(t) {
var e = r.call(this) || this;
return e.commands = "string" == typeof t ? a.parse(t) : t, e;
}
return e(a, r), a.prototype.encode = function() {
return a.encode(this.commands);
}, a.prototype.getBounds = function() {
var r = t.SVGPathDataTransformer.CALCULATE_BOUNDS();
return this.transform(r), r;
}, a.prototype.transform = function(t) {
for(var r = [], e = 0, a = this.commands; e < a.length; e++){
var i = t(a[e]);
Array.isArray(i) ? r.push.apply(r, i) : r.push(i);
}
return this.commands = r, this;
}, a.encode = function(t) {
return i(t);
}, a.parse = function(t) {
var r = new _, e = [];
return r.parse(t, e), r.finish(e), e;
}, a.CLOSE_PATH = 1, a.MOVE_TO = 2, a.HORIZ_LINE_TO = 4, a.VERT_LINE_TO = 8, a.LINE_TO = 16, a.CURVE_TO = 32, a.SMOOTH_CURVE_TO = 64, a.QUAD_TO = 128, a.SMOOTH_QUAD_TO = 256, a.ARC = 512, a.LINE_COMMANDS = a.LINE_TO | a.HORIZ_LINE_TO | a.VERT_LINE_TO, a.DRAWING_COMMANDS = a.HORIZ_LINE_TO | a.VERT_LINE_TO | a.LINE_TO | a.CURVE_TO | a.SMOOTH_CURVE_TO | a.QUAD_TO | a.SMOOTH_QUAD_TO | a.ARC, a;
}(O), d = ((T = {})[N.MOVE_TO] = 2, T[N.LINE_TO] = 2, T[N.HORIZ_LINE_TO] = 1, T[N.VERT_LINE_TO] = 1, T[N.CLOSE_PATH] = 0, T[N.QUAD_TO] = 4, T[N.SMOOTH_QUAD_TO] = 2, T[N.CURVE_TO] = 6, T[N.SMOOTH_CURVE_TO] = 4, T[N.ARC] = 7, T);
t.COMMAND_ARG_COUNTS = d, t.SVGPathData = N, t.SVGPathDataParser = _, t.encodeSVGPath = i, Object.defineProperty(t, "__esModule", {
value: !0
});
});
}),
"[project]/node_modules/stackblur-canvas/dist/stackblur-es.js [app-ssr] (ecmascript)", ((__turbopack_context__) => {
"use strict";
__turbopack_context__.s([
"BlurStack",
()=>BlurStack,
"canvasRGB",
()=>processCanvasRGB,
"canvasRGBA",
()=>processCanvasRGBA,
"image",
()=>processImage,
"imageDataRGB",
()=>processImageDataRGB,
"imageDataRGBA",
()=>processImageDataRGBA
]);
function _typeof(obj) {
"@babel/helpers - typeof";
if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") {
_typeof = function(obj) {
return typeof obj;
};
} else {
_typeof = function(obj) {
return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj;
};
}
return _typeof(obj);
}
function _classCallCheck(instance, Constructor) {
if (!(instance instanceof Constructor)) {
throw new TypeError("Cannot call a class as a function");
}
}
/* eslint-disable no-bitwise -- used for calculations */ /* eslint-disable unicorn/prefer-query-selector -- aiming at
backward-compatibility */ /**
* StackBlur - a fast almost Gaussian Blur For Canvas
*
* In case you find this class useful - especially in commercial projects -
* I am not totally unhappy for a small donation to my PayPal account
* mario@quasimondo.de
*
* Or support me on flattr:
* {@link https://flattr.com/thing/72791/StackBlur-a-fast-almost-Gaussian-Blur-Effect-for-CanvasJavascript}.
*
* @module StackBlur
* @author Mario Klingemann
* Contact: mario@quasimondo.com
* Website: {@link http://www.quasimondo.com/StackBlurForCanvas/StackBlurDemo.html}
* Twitter: @quasimondo
*
* @copyright (c) 2010 Mario Klingemann
*
* Permission is hereby granted, free of charge, to any person
* obtaining a copy of this software and associated documentation
* files (the "Software"), to deal in the Software without
* restriction, including without limitation the rights to use,
* copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following
* conditions:
*
* The above copyright notice and this permission notice shall be
* included in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
* OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
* HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
* WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
* OTHER DEALINGS IN THE SOFTWARE.
*/ var mulTable = [
512,
512,
456,
512,
328,
456,
335,
512,
405,
328,
271,
456,
388,
335,
292,
512,
454,
405,
364,
328,
298,
271,
496,
456,
420,
388,
360,
335,
312,
292,
273,
512,
482,
454,
428,
405,
383,
364,
345,
328,
312,
298,
284,
271,
259,
496,
475,
456,
437,
420,
404,
388,
374,
360,
347,
335,
323,
312,
302,
292,
282,
273,
265,
512,
497,
482,
468,
454,
441,
428,
417,
405,
394,
383,
373,
364,
354,
345,
337,
328,
320,
312,
305,
298,
291,
284,
278,
271,
265,
259,
507,
496,
485,
475,
465,
456,
446,
437,
428,
420,
412,
404,
396,
388,
381,
374,
367,
360,
354,
347,
341,
335,
329,
323,
318,
312,
307,
302,
297,
292,
287,
282,
278,
273,
269,
265,
261,
512,
505,
497,
489,
482,
475,
468,
461,
454,
447,
441,
435,
428,
422,
417,
411,
405,
399,
394,
389,
383,
378,
373,
368,
364,
359,
354,
350,
345,
341,
337,
332,
328,
324,
320,
316,
312,
309,
305,
301,
298,
294,
291,
287,
284,
281,
278,
274,
271,
268,
265,
262,
259,
257,
507,
501,
496,
491,
485,
480,
475,
470,
465,
460,
456,
451,
446,
442,
437,
433,
428,
424,
420,
416,
412,
408,
404,
400,
396,
392,
388,
385,
381,
377,
374,
370,
367,
363,
360,
357,
354,
350,
347,
344,
341,
338,
335,
332,
329,
326,
323,
320,
318,
315,
312,
310,
307,
304,
302,
299,
297,
294,
292,
289,
287,
285,
282,
280,
278,
275,
273,
271,
269,
267,
265,
263,
261,
259
];
var shgTable = [
9,
11,
12,
13,
13,
14,
14,
15,
15,
15,
15,
16,
16,
16,
16,
17,
17,
17,
17,
17,
17,
17,
18,
18,
18,
18,
18,
18,
18,
18,
18,
19,
19,
19,
19,
19,
19,
19,
19,
19,
19,
19,
19,
19,
19,
20,
20,
20,
20,
20,
20,
20,
20,
20,
20,
20,
20,
20,
20,
20,
20,
20,
20,
21,
21,
21,
21,
21,
21,
21,
21,
21,
21,
21,
21,
21,
21,
21,
21,
21,
21,
21,
21,
21,
21,
21,
21,
21,
21,
21,
22,
22,
22,
22,
22,
22,
22,
22,
22,
22,
22,
22,
22,
22,
22,
22,
22,
22,
22,
22,
22,
22,
22,
22,
22,
22,
22,
22,
22,
22,
22,
22,
22,
22,
22,
22,
22,
23,
23,
23,
23,
23,
23,
23,
23,
23,
23,
23,
23,
23,
23,
23,
23,
23,
23,
23,
23,
23,
23,
23,
23,
23,
23,
23,
23,
23,
23,
23,
23,
23,
23,
23,
23,
23,
23,
23,
23,
23,
23,
23,
23,
23,
23,
23,
23,
23,
23,
23,
23,
23,
23,
24,
24,
24,
24,
24,
24,
24,
24,
24,
24,
24,
24,
24,
24,
24,
24,
24,
24,
24,
24,
24,
24,
24,
24,
24,
24,
24,
24,
24,
24,
24,
24,
24,
24,
24,
24,
24,
24,
24,
24,
24,
24,
24,
24,
24,
24,
24,
24,
24,
24,
24,
24,
24,
24,
24,
24,
24,
24,
24,
24,
24,
24,
24,
24,
24,
24,
24,
24,
24,
24,
24,
24,
24,
24
];
/**
* @param {string|HTMLImageElement} img
* @param {string|HTMLCanvasElement} canvas
* @param {Float} radius
* @param {boolean} blurAlphaChannel
* @param {boolean} useOffset
* @param {boolean} skipStyles
* @returns {undefined}
*/ function processImage(img, canvas, radius, blurAlphaChannel, useOffset, skipStyles) {
if (typeof img === 'string') {
img = document.getElementById(img);
}
if (!img || Object.prototype.toString.call(img).slice(8, -1) === 'HTMLImageElement' && !('naturalWidth' in img)) {
return;
}
var dimensionType = useOffset ? 'offset' : 'natural';
var w = img[dimensionType + 'Width'];
var h = img[dimensionType + 'Height']; // add ImageBitmap support,can blur texture source
if (Object.prototype.toString.call(img).slice(8, -1) === 'ImageBitmap') {
w = img.width;
h = img.height;
}
if (typeof canvas === 'string') {
canvas = document.getElementById(canvas);
}
if (!canvas || !('getContext' in canvas)) {
return;
}
if (!skipStyles) {
canvas.style.width = w + 'px';
canvas.style.height = h + 'px';
}
canvas.width = w;
canvas.height = h;
var context = canvas.getContext('2d');
context.clearRect(0, 0, w, h);
context.drawImage(img, 0, 0, img.naturalWidth, img.naturalHeight, 0, 0, w, h);
if (isNaN(radius) || radius < 1) {
return;
}
if (blurAlphaChannel) {
processCanvasRGBA(canvas, 0, 0, w, h, radius);
} else {
processCanvasRGB(canvas, 0, 0, w, h, radius);
}
}
/**
* @param {string|HTMLCanvasElement} canvas
* @param {Integer} topX
* @param {Integer} topY
* @param {Integer} width
* @param {Integer} height
* @throws {Error|TypeError}
* @returns {ImageData} See {@link https://html.spec.whatwg.org/multipage/canvas.html#imagedata}
*/ function getImageDataFromCanvas(canvas, topX, topY, width, height) {
if (typeof canvas === 'string') {
canvas = document.getElementById(canvas);
}
if (!canvas || _typeof(canvas) !== 'object' || !('getContext' in canvas)) {
throw new TypeError('Expecting canvas with `getContext` method ' + 'in processCanvasRGB(A) calls!');
}
var context = canvas.getContext('2d');
try {
return context.getImageData(topX, topY, width, height);
} catch (e) {
throw new Error('unable to access image data: ' + e);
}
}
/**
* @param {HTMLCanvasElement} canvas
* @param {Integer} topX
* @param {Integer} topY
* @param {Integer} width
* @param {Integer} height
* @param {Float} radius
* @returns {undefined}
*/ function processCanvasRGBA(canvas, topX, topY, width, height, radius) {
if (isNaN(radius) || radius < 1) {
return;
}
radius |= 0;
var imageData = getImageDataFromCanvas(canvas, topX, topY, width, height);
imageData = processImageDataRGBA(imageData, topX, topY, width, height, radius);
canvas.getContext('2d').putImageData(imageData, topX, topY);
}
/**
* @param {ImageData} imageData
* @param {Integer} topX
* @param {Integer} topY
* @param {Integer} width
* @param {Integer} height
* @param {Float} radius
* @returns {ImageData}
*/ function processImageDataRGBA(imageData, topX, topY, width, height, radius) {
var pixels = imageData.data;
var div = 2 * radius + 1; // const w4 = width << 2;
var widthMinus1 = width - 1;
var heightMinus1 = height - 1;
var radiusPlus1 = radius + 1;
var sumFactor = radiusPlus1 * (radiusPlus1 + 1) / 2;
var stackStart = new BlurStack();
var stack = stackStart;
var stackEnd;
for(var i = 1; i < div; i++){
stack = stack.next = new BlurStack();
if (i === radiusPlus1) {
stackEnd = stack;
}
}
stack.next = stackStart;
var stackIn = null, stackOut = null, yw = 0, yi = 0;
var mulSum = mulTable[radius];
var shgSum = shgTable[radius];
for(var y = 0; y < height; y++){
stack = stackStart;
var pr = pixels[yi], pg = pixels[yi + 1], pb = pixels[yi + 2], pa = pixels[yi + 3];
for(var _i = 0; _i < radiusPlus1; _i++){
stack.r = pr;
stack.g = pg;
stack.b = pb;
stack.a = pa;
stack = stack.next;
}
var rInSum = 0, gInSum = 0, bInSum = 0, aInSum = 0, rOutSum = radiusPlus1 * pr, gOutSum = radiusPlus1 * pg, bOutSum = radiusPlus1 * pb, aOutSum = radiusPlus1 * pa, rSum = sumFactor * pr, gSum = sumFactor * pg, bSum = sumFactor * pb, aSum = sumFactor * pa;
for(var _i2 = 1; _i2 < radiusPlus1; _i2++){
var p = yi + ((widthMinus1 < _i2 ? widthMinus1 : _i2) << 2);
var r = pixels[p], g = pixels[p + 1], b = pixels[p + 2], a = pixels[p + 3];
var rbs = radiusPlus1 - _i2;
rSum += (stack.r = r) * rbs;
gSum += (stack.g = g) * rbs;
bSum += (stack.b = b) * rbs;
aSum += (stack.a = a) * rbs;
rInSum += r;
gInSum += g;
bInSum += b;
aInSum += a;
stack = stack.next;
}
stackIn = stackStart;
stackOut = stackEnd;
for(var x = 0; x < width; x++){
var paInitial = aSum * mulSum >>> shgSum;
pixels[yi + 3] = paInitial;
if (paInitial !== 0) {
var _a2 = 255 / paInitial;
pixels[yi] = (rSum * mulSum >>> shgSum) * _a2;
pixels[yi + 1] = (gSum * mulSum >>> shgSum) * _a2;
pixels[yi + 2] = (bSum * mulSum >>> shgSum) * _a2;
} else {
pixels[yi] = pixels[yi + 1] = pixels[yi + 2] = 0;
}
rSum -= rOutSum;
gSum -= gOutSum;
bSum -= bOutSum;
aSum -= aOutSum;
rOutSum -= stackIn.r;
gOutSum -= stackIn.g;
bOutSum -= stackIn.b;
aOutSum -= stackIn.a;
var _p = x + radius + 1;
_p = yw + (_p < widthMinus1 ? _p : widthMinus1) << 2;
rInSum += stackIn.r = pixels[_p];
gInSum += stackIn.g = pixels[_p + 1];
bInSum += stackIn.b = pixels[_p + 2];
aInSum += stackIn.a = pixels[_p + 3];
rSum += rInSum;
gSum += gInSum;
bSum += bInSum;
aSum += aInSum;
stackIn = stackIn.next;
var _stackOut = stackOut, _r = _stackOut.r, _g = _stackOut.g, _b = _stackOut.b, _a = _stackOut.a;
rOutSum += _r;
gOutSum += _g;
bOutSum += _b;
aOutSum += _a;
rInSum -= _r;
gInSum -= _g;
bInSum -= _b;
aInSum -= _a;
stackOut = stackOut.next;
yi += 4;
}
yw += width;
}
for(var _x = 0; _x < width; _x++){
yi = _x << 2;
var _pr = pixels[yi], _pg = pixels[yi + 1], _pb = pixels[yi + 2], _pa = pixels[yi + 3], _rOutSum = radiusPlus1 * _pr, _gOutSum = radiusPlus1 * _pg, _bOutSum = radiusPlus1 * _pb, _aOutSum = radiusPlus1 * _pa, _rSum = sumFactor * _pr, _gSum = sumFactor * _pg, _bSum = sumFactor * _pb, _aSum = sumFactor * _pa;
stack = stackStart;
for(var _i3 = 0; _i3 < radiusPlus1; _i3++){
stack.r = _pr;
stack.g = _pg;
stack.b = _pb;
stack.a = _pa;
stack = stack.next;
}
var yp = width;
var _gInSum = 0, _bInSum = 0, _aInSum = 0, _rInSum = 0;
for(var _i4 = 1; _i4 <= radius; _i4++){
yi = yp + _x << 2;
var _rbs = radiusPlus1 - _i4;
_rSum += (stack.r = _pr = pixels[yi]) * _rbs;
_gSum += (stack.g = _pg = pixels[yi + 1]) * _rbs;
_bSum += (stack.b = _pb = pixels[yi + 2]) * _rbs;
_aSum += (stack.a = _pa = pixels[yi + 3]) * _rbs;
_rInSum += _pr;
_gInSum += _pg;
_bInSum += _pb;
_aInSum += _pa;
stack = stack.next;
if (_i4 < heightMinus1) {
yp += width;
}
}
yi = _x;
stackIn = stackStart;
stackOut = stackEnd;
for(var _y = 0; _y < height; _y++){
var _p2 = yi << 2;
pixels[_p2 + 3] = _pa = _aSum * mulSum >>> shgSum;
if (_pa > 0) {
_pa = 255 / _pa;
pixels[_p2] = (_rSum * mulSum >>> shgSum) * _pa;
pixels[_p2 + 1] = (_gSum * mulSum >>> shgSum) * _pa;
pixels[_p2 + 2] = (_bSum * mulSum >>> shgSum) * _pa;
} else {
pixels[_p2] = pixels[_p2 + 1] = pixels[_p2 + 2] = 0;
}
_rSum -= _rOutSum;
_gSum -= _gOutSum;
_bSum -= _bOutSum;
_aSum -= _aOutSum;
_rOutSum -= stackIn.r;
_gOutSum -= stackIn.g;
_bOutSum -= stackIn.b;
_aOutSum -= stackIn.a;
_p2 = _x + ((_p2 = _y + radiusPlus1) < heightMinus1 ? _p2 : heightMinus1) * width << 2;
_rSum += _rInSum += stackIn.r = pixels[_p2];
_gSum += _gInSum += stackIn.g = pixels[_p2 + 1];
_bSum += _bInSum += stackIn.b = pixels[_p2 + 2];
_aSum += _aInSum += stackIn.a = pixels[_p2 + 3];
stackIn = stackIn.next;
_rOutSum += _pr = stackOut.r;
_gOutSum += _pg = stackOut.g;
_bOutSum += _pb = stackOut.b;
_aOutSum += _pa = stackOut.a;
_rInSum -= _pr;
_gInSum -= _pg;
_bInSum -= _pb;
_aInSum -= _pa;
stackOut = stackOut.next;
yi += width;
}
}
return imageData;
}
/**
* @param {HTMLCanvasElement} canvas
* @param {Integer} topX
* @param {Integer} topY
* @param {Integer} width
* @param {Integer} height
* @param {Float} radius
* @returns {undefined}
*/ function processCanvasRGB(canvas, topX, topY, width, height, radius) {
if (isNaN(radius) || radius < 1) {
return;
}
radius |= 0;
var imageData = getImageDataFromCanvas(canvas, topX, topY, width, height);
imageData = processImageDataRGB(imageData, topX, topY, width, height, radius);
canvas.getContext('2d').putImageData(imageData, topX, topY);
}
/**
* @param {ImageData} imageData
* @param {Integer} topX
* @param {Integer} topY
* @param {Integer} width
* @param {Integer} height
* @param {Float} radius
* @returns {ImageData}
*/ function processImageDataRGB(imageData, topX, topY, width, height, radius) {
var pixels = imageData.data;
var div = 2 * radius + 1; // const w4 = width << 2;
var widthMinus1 = width - 1;
var heightMinus1 = height - 1;
var radiusPlus1 = radius + 1;
var sumFactor = radiusPlus1 * (radiusPlus1 + 1) / 2;
var stackStart = new BlurStack();
var stack = stackStart;
var stackEnd;
for(var i = 1; i < div; i++){
stack = stack.next = new BlurStack();
if (i === radiusPlus1) {
stackEnd = stack;
}
}
stack.next = stackStart;
var stackIn = null;
var stackOut = null;
var mulSum = mulTable[radius];
var shgSum = shgTable[radius];
var p, rbs;
var yw = 0, yi = 0;
for(var y = 0; y < height; y++){
var pr = pixels[yi], pg = pixels[yi + 1], pb = pixels[yi + 2], rOutSum = radiusPlus1 * pr, gOutSum = radiusPlus1 * pg, bOutSum = radiusPlus1 * pb, rSum = sumFactor * pr, gSum = sumFactor * pg, bSum = sumFactor * pb;
stack = stackStart;
for(var _i5 = 0; _i5 < radiusPlus1; _i5++){
stack.r = pr;
stack.g = pg;
stack.b = pb;
stack = stack.next;
}
var rInSum = 0, gInSum = 0, bInSum = 0;
for(var _i6 = 1; _i6 < radiusPlus1; _i6++){
p = yi + ((widthMinus1 < _i6 ? widthMinus1 : _i6) << 2);
rSum += (stack.r = pr = pixels[p]) * (rbs = radiusPlus1 - _i6);
gSum += (stack.g = pg = pixels[p + 1]) * rbs;
bSum += (stack.b = pb = pixels[p + 2]) * rbs;
rInSum += pr;
gInSum += pg;
bInSum += pb;
stack = stack.next;
}
stackIn = stackStart;
stackOut = stackEnd;
for(var x = 0; x < width; x++){
pixels[yi] = rSum * mulSum >>> shgSum;
pixels[yi + 1] = gSum * mulSum >>> shgSum;
pixels[yi + 2] = bSum * mulSum >>> shgSum;
rSum -= rOutSum;
gSum -= gOutSum;
bSum -= bOutSum;
rOutSum -= stackIn.r;
gOutSum -= stackIn.g;
bOutSum -= stackIn.b;
p = yw + ((p = x + radius + 1) < widthMinus1 ? p : widthMinus1) << 2;
rInSum += stackIn.r = pixels[p];
gInSum += stackIn.g = pixels[p + 1];
bInSum += stackIn.b = pixels[p + 2];
rSum += rInSum;
gSum += gInSum;
bSum += bInSum;
stackIn = stackIn.next;
rOutSum += pr = stackOut.r;
gOutSum += pg = stackOut.g;
bOutSum += pb = stackOut.b;
rInSum -= pr;
gInSum -= pg;
bInSum -= pb;
stackOut = stackOut.next;
yi += 4;
}
yw += width;
}
for(var _x2 = 0; _x2 < width; _x2++){
yi = _x2 << 2;
var _pr2 = pixels[yi], _pg2 = pixels[yi + 1], _pb2 = pixels[yi + 2], _rOutSum2 = radiusPlus1 * _pr2, _gOutSum2 = radiusPlus1 * _pg2, _bOutSum2 = radiusPlus1 * _pb2, _rSum2 = sumFactor * _pr2, _gSum2 = sumFactor * _pg2, _bSum2 = sumFactor * _pb2;
stack = stackStart;
for(var _i7 = 0; _i7 < radiusPlus1; _i7++){
stack.r = _pr2;
stack.g = _pg2;
stack.b = _pb2;
stack = stack.next;
}
var _rInSum2 = 0, _gInSum2 = 0, _bInSum2 = 0;
for(var _i8 = 1, yp = width; _i8 <= radius; _i8++){
yi = yp + _x2 << 2;
_rSum2 += (stack.r = _pr2 = pixels[yi]) * (rbs = radiusPlus1 - _i8);
_gSum2 += (stack.g = _pg2 = pixels[yi + 1]) * rbs;
_bSum2 += (stack.b = _pb2 = pixels[yi + 2]) * rbs;
_rInSum2 += _pr2;
_gInSum2 += _pg2;
_bInSum2 += _pb2;
stack = stack.next;
if (_i8 < heightMinus1) {
yp += width;
}
}
yi = _x2;
stackIn = stackStart;
stackOut = stackEnd;
for(var _y2 = 0; _y2 < height; _y2++){
p = yi << 2;
pixels[p] = _rSum2 * mulSum >>> shgSum;
pixels[p + 1] = _gSum2 * mulSum >>> shgSum;
pixels[p + 2] = _bSum2 * mulSum >>> shgSum;
_rSum2 -= _rOutSum2;
_gSum2 -= _gOutSum2;
_bSum2 -= _bOutSum2;
_rOutSum2 -= stackIn.r;
_gOutSum2 -= stackIn.g;
_bOutSum2 -= stackIn.b;
p = _x2 + ((p = _y2 + radiusPlus1) < heightMinus1 ? p : heightMinus1) * width << 2;
_rSum2 += _rInSum2 += stackIn.r = pixels[p];
_gSum2 += _gInSum2 += stackIn.g = pixels[p + 1];
_bSum2 += _bInSum2 += stackIn.b = pixels[p + 2];
stackIn = stackIn.next;
_rOutSum2 += _pr2 = stackOut.r;
_gOutSum2 += _pg2 = stackOut.g;
_bOutSum2 += _pb2 = stackOut.b;
_rInSum2 -= _pr2;
_gInSum2 -= _pg2;
_bInSum2 -= _pb2;
stackOut = stackOut.next;
yi += width;
}
}
return imageData;
}
/**
*
*/ var BlurStack = /**
* Set properties.
*/ function BlurStack() {
_classCallCheck(this, BlurStack);
this.r = 0;
this.g = 0;
this.b = 0;
this.a = 0;
this.next = null;
};
;
}),
"[project]/node_modules/fflate/lib/node.cjs [app-ssr] (ecmascript)", ((__turbopack_context__, module, exports) => {
"use strict";
// DEFLATE is a complex format; to read this code, you should probably check the RFC first:
// https://tools.ietf.org/html/rfc1951
// You may also wish to take a look at the guide I made about this program:
// https://gist.github.com/101arrowz/253f31eb5abc3d9275ab943003ffecad
// Some of the following code is similar to that of UZIP.js:
// https://github.com/photopea/UZIP.js
// However, the vast majority of the codebase has diverged from UZIP.js to increase performance and reduce bundle size.
// Sometimes 0 will appear where -1 would be more appropriate. This is because using a uint
// is better for memory in most engines (I *think*).
// Mediocre shim
var Worker;
var workerAdd = ";var __w=require('worker_threads');__w.parentPort.on('message',function(m){onmessage({data:m})}),postMessage=function(m,t){__w.parentPort.postMessage(m,t)},close=process.exit;self=global";
try {
Worker = __turbopack_context__.r("[externals]/worker_threads [external] (worker_threads, cjs)").Worker;
} catch (e) {}
var node_worker_1 = {};
node_worker_1["default"] = Worker ? function(c, _, msg, transfer, cb) {
var done = false;
var w = new Worker(c + workerAdd, {
eval: true
}).on('error', function(e) {
return cb(e, null);
}).on('message', function(m) {
return cb(null, m);
}).on('exit', function(c) {
if (c && !done) cb(new Error('exited with code ' + c), null);
});
w.postMessage(msg, transfer);
w.terminate = function() {
done = true;
return Worker.prototype.terminate.call(w);
};
return w;
} : function(_, __, ___, ____, cb) {
setImmediate(function() {
return cb(new Error('async operations unsupported - update to Node 12+ (or Node 10-11 with the --experimental-worker CLI flag)'), null);
});
var NOP = function() {};
return {
terminate: NOP,
postMessage: NOP
};
};
// aliases for shorter compressed code (most minifers don't do this)
var u8 = Uint8Array, u16 = Uint16Array, i32 = Int32Array;
// fixed length extra bits
var fleb = new u8([
0,
0,
0,
0,
0,
0,
0,
0,
1,
1,
1,
1,
2,
2,
2,
2,
3,
3,
3,
3,
4,
4,
4,
4,
5,
5,
5,
5,
0,
/* unused */ 0,
0,
/* impossible */ 0
]);
// fixed distance extra bits
var fdeb = new u8([
0,
0,
0,
0,
1,
1,
2,
2,
3,
3,
4,
4,
5,
5,
6,
6,
7,
7,
8,
8,
9,
9,
10,
10,
11,
11,
12,
12,
13,
13,
/* unused */ 0,
0
]);
// code length index map
var clim = new u8([
16,
17,
18,
0,
8,
7,
9,
6,
10,
5,
11,
4,
12,
3,
13,
2,
14,
1,
15
]);
// get base, reverse index map from extra bits
var freb = function(eb, start) {
var b = new u16(31);
for(var i = 0; i < 31; ++i){
b[i] = start += 1 << eb[i - 1];
}
// numbers here are at max 18 bits
var r = new i32(b[30]);
for(var i = 1; i < 30; ++i){
for(var j = b[i]; j < b[i + 1]; ++j){
r[j] = j - b[i] << 5 | i;
}
}
return {
b: b,
r: r
};
};
var _a = freb(fleb, 2), fl = _a.b, revfl = _a.r;
// we can ignore the fact that the other numbers are wrong; they never happen anyway
fl[28] = 258, revfl[258] = 28;
var _b = freb(fdeb, 0), fd = _b.b, revfd = _b.r;
// map of value to reverse (assuming 16 bits)
var rev = new u16(32768);
for(var i = 0; i < 32768; ++i){
// reverse table algorithm from SO
var x = (i & 0xAAAA) >> 1 | (i & 0x5555) << 1;
x = (x & 0xCCCC) >> 2 | (x & 0x3333) << 2;
x = (x & 0xF0F0) >> 4 | (x & 0x0F0F) << 4;
rev[i] = ((x & 0xFF00) >> 8 | (x & 0x00FF) << 8) >> 1;
}
// create huffman tree from u8 "map": index -> code length for code index
// mb (max bits) must be at most 15
// TODO: optimize/split up?
var hMap = function(cd, mb, r) {
var s = cd.length;
// index
var i = 0;
// u16 "map": index -> # of codes with bit length = index
var l = new u16(mb);
// length of cd must be 288 (total # of codes)
for(; i < s; ++i){
if (cd[i]) ++l[cd[i] - 1];
}
// u16 "map": index -> minimum code for bit length = index
var le = new u16(mb);
for(i = 1; i < mb; ++i){
le[i] = le[i - 1] + l[i - 1] << 1;
}
var co;
if (r) {
// u16 "map": index -> number of actual bits, symbol for code
co = new u16(1 << mb);
// bits to remove for reverser
var rvb = 15 - mb;
for(i = 0; i < s; ++i){
// ignore 0 lengths
if (cd[i]) {
// num encoding both symbol and bits read
var sv = i << 4 | cd[i];
// free bits
var r_1 = mb - cd[i];
// start value
var v = le[cd[i] - 1]++ << r_1;
// m is end value
for(var m = v | (1 << r_1) - 1; v <= m; ++v){
// every 16 bit value starting with the code yields the same result
co[rev[v] >> rvb] = sv;
}
}
}
} else {
co = new u16(s);
for(i = 0; i < s; ++i){
if (cd[i]) {
co[i] = rev[le[cd[i] - 1]++] >> 15 - cd[i];
}
}
}
return co;
};
// fixed length tree
var flt = new u8(288);
for(var i = 0; i < 144; ++i)flt[i] = 8;
for(var i = 144; i < 256; ++i)flt[i] = 9;
for(var i = 256; i < 280; ++i)flt[i] = 7;
for(var i = 280; i < 288; ++i)flt[i] = 8;
// fixed distance tree
var fdt = new u8(32);
for(var i = 0; i < 32; ++i)fdt[i] = 5;
// fixed length map
var flm = /*#__PURE__*/ hMap(flt, 9, 0), flrm = /*#__PURE__*/ hMap(flt, 9, 1);
// fixed distance map
var fdm = /*#__PURE__*/ hMap(fdt, 5, 0), fdrm = /*#__PURE__*/ hMap(fdt, 5, 1);
// find max of array
var max = function(a) {
var m = a[0];
for(var i = 1; i < a.length; ++i){
if (a[i] > m) m = a[i];
}
return m;
};
// read d, starting at bit p and mask with m
var bits = function(d, p, m) {
var o = p / 8 | 0;
return (d[o] | d[o + 1] << 8) >> (p & 7) & m;
};
// read d, starting at bit p continuing for at least 16 bits
var bits16 = function(d, p) {
var o = p / 8 | 0;
return (d[o] | d[o + 1] << 8 | d[o + 2] << 16) >> (p & 7);
};
// get end of byte
var shft = function(p) {
return (p + 7) / 8 | 0;
};
// typed array slice - allows garbage collector to free original reference,
// while being more compatible than .slice
var slc = function(v, s, e) {
if (s == null || s < 0) s = 0;
if (e == null || e > v.length) e = v.length;
// can't use .constructor in case user-supplied
return new u8(v.subarray(s, e));
};
/**
* Codes for errors generated within this library
*/ exports.FlateErrorCode = {
UnexpectedEOF: 0,
InvalidBlockType: 1,
InvalidLengthLiteral: 2,
InvalidDistance: 3,
StreamFinished: 4,
NoStreamHandler: 5,
InvalidHeader: 6,
NoCallback: 7,
InvalidUTF8: 8,
ExtraFieldTooLong: 9,
InvalidDate: 10,
FilenameTooLong: 11,
StreamFinishing: 12,
InvalidZipData: 13,
UnknownCompressionMethod: 14
};
// error codes
var ec = [
'unexpected EOF',
'invalid block type',
'invalid length/literal',
'invalid distance',
'stream finished',
'no stream handler',
,
'no callback',
'invalid UTF-8 data',
'extra field too long',
'date not in range 1980-2099',
'filename too long',
'stream finishing',
'invalid zip data'
];
;
var err = function(ind, msg, nt) {
var e = new Error(msg || ec[ind]);
e.code = ind;
if (Error.captureStackTrace) Error.captureStackTrace(e, err);
if (!nt) throw e;
return e;
};
// expands raw DEFLATE data
var inflt = function(dat, st, buf, dict) {
// source length dict length
var sl = dat.length, dl = dict ? dict.length : 0;
if (!sl || st.f && !st.l) return buf || new u8(0);
var noBuf = !buf;
// have to estimate size
var resize = noBuf || st.i != 2;
// no state
var noSt = st.i;
// Assumes roughly 33% compression ratio average
if (noBuf) buf = new u8(sl * 3);
// ensure buffer can fit at least l elements
var cbuf = function(l) {
var bl = buf.length;
// need to increase size to fit
if (l > bl) {
// Double or set to necessary, whichever is greater
var nbuf = new u8(Math.max(bl * 2, l));
nbuf.set(buf);
buf = nbuf;
}
};
// last chunk bitpos bytes
var final = st.f || 0, pos = st.p || 0, bt = st.b || 0, lm = st.l, dm = st.d, lbt = st.m, dbt = st.n;
// total bits
var tbts = sl * 8;
do {
if (!lm) {
// BFINAL - this is only 1 when last chunk is next
final = bits(dat, pos, 1);
// type: 0 = no compression, 1 = fixed huffman, 2 = dynamic huffman
var type = bits(dat, pos + 1, 3);
pos += 3;
if (!type) {
// go to end of byte boundary
var s = shft(pos) + 4, l = dat[s - 4] | dat[s - 3] << 8, t = s + l;
if (t > sl) {
if (noSt) err(0);
break;
}
// ensure size
if (resize) cbuf(bt + l);
// Copy over uncompressed data
buf.set(dat.subarray(s, t), bt);
// Get new bitpos, update byte count
st.b = bt += l, st.p = pos = t * 8, st.f = final;
continue;
} else if (type == 1) lm = flrm, dm = fdrm, lbt = 9, dbt = 5;
else if (type == 2) {
// literal lengths
var hLit = bits(dat, pos, 31) + 257, hcLen = bits(dat, pos + 10, 15) + 4;
var tl = hLit + bits(dat, pos + 5, 31) + 1;
pos += 14;
// length+distance tree
var ldt = new u8(tl);
// code length tree
var clt = new u8(19);
for(var i = 0; i < hcLen; ++i){
// use index map to get real code
clt[clim[i]] = bits(dat, pos + i * 3, 7);
}
pos += hcLen * 3;
// code lengths bits
var clb = max(clt), clbmsk = (1 << clb) - 1;
// code lengths map
var clm = hMap(clt, clb, 1);
for(var i = 0; i < tl;){
var r = clm[bits(dat, pos, clbmsk)];
// bits read
pos += r & 15;
// symbol
var s = r >> 4;
// code length to copy
if (s < 16) {
ldt[i++] = s;
} else {
// copy count
var c = 0, n = 0;
if (s == 16) n = 3 + bits(dat, pos, 3), pos += 2, c = ldt[i - 1];
else if (s == 17) n = 3 + bits(dat, pos, 7), pos += 3;
else if (s == 18) n = 11 + bits(dat, pos, 127), pos += 7;
while(n--)ldt[i++] = c;
}
}
// length tree distance tree
var lt = ldt.subarray(0, hLit), dt = ldt.subarray(hLit);
// max length bits
lbt = max(lt);
// max dist bits
dbt = max(dt);
lm = hMap(lt, lbt, 1);
dm = hMap(dt, dbt, 1);
} else err(1);
if (pos > tbts) {
if (noSt) err(0);
break;
}
}
// Make sure the buffer can hold this + the largest possible addition
// Maximum chunk size (practically, theoretically infinite) is 2^17
if (resize) cbuf(bt + 131072);
var lms = (1 << lbt) - 1, dms = (1 << dbt) - 1;
var lpos = pos;
for(;; lpos = pos){
// bits read, code
var c = lm[bits16(dat, pos) & lms], sym = c >> 4;
pos += c & 15;
if (pos > tbts) {
if (noSt) err(0);
break;
}
if (!c) err(2);
if (sym < 256) buf[bt++] = sym;
else if (sym == 256) {
lpos = pos, lm = null;
break;
} else {
var add = sym - 254;
// no extra bits needed if less
if (sym > 264) {
// index
var i = sym - 257, b = fleb[i];
add = bits(dat, pos, (1 << b) - 1) + fl[i];
pos += b;
}
// dist
var d = dm[bits16(dat, pos) & dms], dsym = d >> 4;
if (!d) err(3);
pos += d & 15;
var dt = fd[dsym];
if (dsym > 3) {
var b = fdeb[dsym];
dt += bits16(dat, pos) & (1 << b) - 1, pos += b;
}
if (pos > tbts) {
if (noSt) err(0);
break;
}
if (resize) cbuf(bt + 131072);
var end = bt + add;
if (bt < dt) {
var shift = dl - dt, dend = Math.min(dt, end);
if (shift + bt < 0) err(3);
for(; bt < dend; ++bt)buf[bt] = dict[shift + bt];
}
for(; bt < end; ++bt)buf[bt] = buf[bt - dt];
}
}
st.l = lm, st.p = lpos, st.b = bt, st.f = final;
if (lm) final = 1, st.m = lbt, st.d = dm, st.n = dbt;
}while (!final)
// don't reallocate for streams or user buffers
return bt != buf.length && noBuf ? slc(buf, 0, bt) : buf.subarray(0, bt);
};
// starting at p, write the minimum number of bits that can hold v to d
var wbits = function(d, p, v) {
v <<= p & 7;
var o = p / 8 | 0;
d[o] |= v;
d[o + 1] |= v >> 8;
};
// starting at p, write the minimum number of bits (>8) that can hold v to d
var wbits16 = function(d, p, v) {
v <<= p & 7;
var o = p / 8 | 0;
d[o] |= v;
d[o + 1] |= v >> 8;
d[o + 2] |= v >> 16;
};
// creates code lengths from a frequency table
var hTree = function(d, mb) {
// Need extra info to make a tree
var t = [];
for(var i = 0; i < d.length; ++i){
if (d[i]) t.push({
s: i,
f: d[i]
});
}
var s = t.length;
var t2 = t.slice();
if (!s) return {
t: et,
l: 0
};
if (s == 1) {
var v = new u8(t[0].s + 1);
v[t[0].s] = 1;
return {
t: v,
l: 1
};
}
t.sort(function(a, b) {
return a.f - b.f;
});
// after i2 reaches last ind, will be stopped
// freq must be greater than largest possible number of symbols
t.push({
s: -1,
f: 25001
});
var l = t[0], r = t[1], i0 = 0, i1 = 1, i2 = 2;
t[0] = {
s: -1,
f: l.f + r.f,
l: l,
r: r
};
// efficient algorithm from UZIP.js
// i0 is lookbehind, i2 is lookahead - after processing two low-freq
// symbols that combined have high freq, will start processing i2 (high-freq,
// non-composite) symbols instead
// see https://reddit.com/r/photopea/comments/ikekht/uzipjs_questions/
while(i1 != s - 1){
l = t[t[i0].f < t[i2].f ? i0++ : i2++];
r = t[i0 != i1 && t[i0].f < t[i2].f ? i0++ : i2++];
t[i1++] = {
s: -1,
f: l.f + r.f,
l: l,
r: r
};
}
var maxSym = t2[0].s;
for(var i = 1; i < s; ++i){
if (t2[i].s > maxSym) maxSym = t2[i].s;
}
// code lengths
var tr = new u16(maxSym + 1);
// max bits in tree
var mbt = ln(t[i1 - 1], tr, 0);
if (mbt > mb) {
// more algorithms from UZIP.js
// TODO: find out how this code works (debt)
// ind debt
var i = 0, dt = 0;
// left cost
var lft = mbt - mb, cst = 1 << lft;
t2.sort(function(a, b) {
return tr[b.s] - tr[a.s] || a.f - b.f;
});
for(; i < s; ++i){
var i2_1 = t2[i].s;
if (tr[i2_1] > mb) {
dt += cst - (1 << mbt - tr[i2_1]);
tr[i2_1] = mb;
} else break;
}
dt >>= lft;
while(dt > 0){
var i2_2 = t2[i].s;
if (tr[i2_2] < mb) dt -= 1 << mb - tr[i2_2]++ - 1;
else ++i;
}
for(; i >= 0 && dt; --i){
var i2_3 = t2[i].s;
if (tr[i2_3] == mb) {
--tr[i2_3];
++dt;
}
}
mbt = mb;
}
return {
t: new u8(tr),
l: mbt
};
};
// get the max length and assign length codes
var ln = function(n, l, d) {
return n.s == -1 ? Math.max(ln(n.l, l, d + 1), ln(n.r, l, d + 1)) : l[n.s] = d;
};
// length codes generation
var lc = function(c) {
var s = c.length;
// Note that the semicolon was intentional
while(s && !c[--s]);
var cl = new u16(++s);
// ind num streak
var cli = 0, cln = c[0], cls = 1;
var w = function(v) {
cl[cli++] = v;
};
for(var i = 1; i <= s; ++i){
if (c[i] == cln && i != s) ++cls;
else {
if (!cln && cls > 2) {
for(; cls > 138; cls -= 138)w(32754);
if (cls > 2) {
w(cls > 10 ? cls - 11 << 5 | 28690 : cls - 3 << 5 | 12305);
cls = 0;
}
} else if (cls > 3) {
w(cln), --cls;
for(; cls > 6; cls -= 6)w(8304);
if (cls > 2) w(cls - 3 << 5 | 8208), cls = 0;
}
while(cls--)w(cln);
cls = 1;
cln = c[i];
}
}
return {
c: cl.subarray(0, cli),
n: s
};
};
// calculate the length of output from tree, code lengths
var clen = function(cf, cl) {
var l = 0;
for(var i = 0; i < cl.length; ++i)l += cf[i] * cl[i];
return l;
};
// writes a fixed block
// returns the new bit pos
var wfblk = function(out, pos, dat) {
// no need to write 00 as type: TypedArray defaults to 0
var s = dat.length;
var o = shft(pos + 2);
out[o] = s & 255;
out[o + 1] = s >> 8;
out[o + 2] = out[o] ^ 255;
out[o + 3] = out[o + 1] ^ 255;
for(var i = 0; i < s; ++i)out[o + i + 4] = dat[i];
return (o + 4 + s) * 8;
};
// writes a block
var wblk = function(dat, out, final, syms, lf, df, eb, li, bs, bl, p) {
wbits(out, p++, final);
++lf[256];
var _a = hTree(lf, 15), dlt = _a.t, mlb = _a.l;
var _b = hTree(df, 15), ddt = _b.t, mdb = _b.l;
var _c = lc(dlt), lclt = _c.c, nlc = _c.n;
var _d = lc(ddt), lcdt = _d.c, ndc = _d.n;
var lcfreq = new u16(19);
for(var i = 0; i < lclt.length; ++i)++lcfreq[lclt[i] & 31];
for(var i = 0; i < lcdt.length; ++i)++lcfreq[lcdt[i] & 31];
var _e = hTree(lcfreq, 7), lct = _e.t, mlcb = _e.l;
var nlcc = 19;
for(; nlcc > 4 && !lct[clim[nlcc - 1]]; --nlcc);
var flen = bl + 5 << 3;
var ftlen = clen(lf, flt) + clen(df, fdt) + eb;
var dtlen = clen(lf, dlt) + clen(df, ddt) + eb + 14 + 3 * nlcc + clen(lcfreq, lct) + 2 * lcfreq[16] + 3 * lcfreq[17] + 7 * lcfreq[18];
if (bs >= 0 && flen <= ftlen && flen <= dtlen) return wfblk(out, p, dat.subarray(bs, bs + bl));
var lm, ll, dm, dl;
wbits(out, p, 1 + (dtlen < ftlen)), p += 2;
if (dtlen < ftlen) {
lm = hMap(dlt, mlb, 0), ll = dlt, dm = hMap(ddt, mdb, 0), dl = ddt;
var llm = hMap(lct, mlcb, 0);
wbits(out, p, nlc - 257);
wbits(out, p + 5, ndc - 1);
wbits(out, p + 10, nlcc - 4);
p += 14;
for(var i = 0; i < nlcc; ++i)wbits(out, p + 3 * i, lct[clim[i]]);
p += 3 * nlcc;
var lcts = [
lclt,
lcdt
];
for(var it = 0; it < 2; ++it){
var clct = lcts[it];
for(var i = 0; i < clct.length; ++i){
var len = clct[i] & 31;
wbits(out, p, llm[len]), p += lct[len];
if (len > 15) wbits(out, p, clct[i] >> 5 & 127), p += clct[i] >> 12;
}
}
} else {
lm = flm, ll = flt, dm = fdm, dl = fdt;
}
for(var i = 0; i < li; ++i){
var sym = syms[i];
if (sym > 255) {
var len = sym >> 18 & 31;
wbits16(out, p, lm[len + 257]), p += ll[len + 257];
if (len > 7) wbits(out, p, sym >> 23 & 31), p += fleb[len];
var dst = sym & 31;
wbits16(out, p, dm[dst]), p += dl[dst];
if (dst > 3) wbits16(out, p, sym >> 5 & 8191), p += fdeb[dst];
} else {
wbits16(out, p, lm[sym]), p += ll[sym];
}
}
wbits16(out, p, lm[256]);
return p + ll[256];
};
// deflate options (nice << 13) | chain
var deo = /*#__PURE__*/ new i32([
65540,
131080,
131088,
131104,
262176,
1048704,
1048832,
2114560,
2117632
]);
// empty
var et = /*#__PURE__*/ new u8(0);
// compresses data into a raw DEFLATE buffer
var dflt = function(dat, lvl, plvl, pre, post, st) {
var s = st.z || dat.length;
var o = new u8(pre + s + 5 * (1 + Math.ceil(s / 7000)) + post);
// writing to this writes to the output buffer
var w = o.subarray(pre, o.length - post);
var lst = st.l;
var pos = (st.r || 0) & 7;
if (lvl) {
if (pos) w[0] = st.r >> 3;
var opt = deo[lvl - 1];
var n = opt >> 13, c = opt & 8191;
var msk_1 = (1 << plvl) - 1;
// prev 2-byte val map curr 2-byte val map
var prev = st.p || new u16(32768), head = st.h || new u16(msk_1 + 1);
var bs1_1 = Math.ceil(plvl / 3), bs2_1 = 2 * bs1_1;
var hsh = function(i) {
return (dat[i] ^ dat[i + 1] << bs1_1 ^ dat[i + 2] << bs2_1) & msk_1;
};
// 24576 is an arbitrary number of maximum symbols per block
// 424 buffer for last block
var syms = new i32(25000);
// length/literal freq distance freq
var lf = new u16(288), df = new u16(32);
// l/lcnt exbits index l/lind waitdx blkpos
var lc_1 = 0, eb = 0, i = st.i || 0, li = 0, wi = st.w || 0, bs = 0;
for(; i + 2 < s; ++i){
// hash value
var hv = hsh(i);
// index mod 32768 previous index mod
var imod = i & 32767, pimod = head[hv];
prev[imod] = pimod;
head[hv] = imod;
// We always should modify head and prev, but only add symbols if
// this data is not yet processed ("wait" for wait index)
if (wi <= i) {
// bytes remaining
var rem = s - i;
if ((lc_1 > 7000 || li > 24576) && (rem > 423 || !lst)) {
pos = wblk(dat, w, 0, syms, lf, df, eb, li, bs, i - bs, pos);
li = lc_1 = eb = 0, bs = i;
for(var j = 0; j < 286; ++j)lf[j] = 0;
for(var j = 0; j < 30; ++j)df[j] = 0;
}
// len dist chain
var l = 2, d = 0, ch_1 = c, dif = imod - pimod & 32767;
if (rem > 2 && hv == hsh(i - dif)) {
var maxn = Math.min(n, rem) - 1;
var maxd = Math.min(32767, i);
// max possible length
// not capped at dif because decompressors implement "rolling" index population
var ml = Math.min(258, rem);
while(dif <= maxd && --ch_1 && imod != pimod){
if (dat[i + l] == dat[i + l - dif]) {
var nl = 0;
for(; nl < ml && dat[i + nl] == dat[i + nl - dif]; ++nl);
if (nl > l) {
l = nl, d = dif;
// break out early when we reach "nice" (we are satisfied enough)
if (nl > maxn) break;
// now, find the rarest 2-byte sequence within this
// length of literals and search for that instead.
// Much faster than just using the start
var mmd = Math.min(dif, nl - 2);
var md = 0;
for(var j = 0; j < mmd; ++j){
var ti = i - dif + j & 32767;
var pti = prev[ti];
var cd = ti - pti & 32767;
if (cd > md) md = cd, pimod = ti;
}
}
}
// check the previous match
imod = pimod, pimod = prev[imod];
dif += imod - pimod & 32767;
}
}
// d will be nonzero only when a match was found
if (d) {
// store both dist and len data in one int32
// Make sure this is recognized as a len/dist with 28th bit (2^28)
syms[li++] = 268435456 | revfl[l] << 18 | revfd[d];
var lin = revfl[l] & 31, din = revfd[d] & 31;
eb += fleb[lin] + fdeb[din];
++lf[257 + lin];
++df[din];
wi = i + l;
++lc_1;
} else {
syms[li++] = dat[i];
++lf[dat[i]];
}
}
}
for(i = Math.max(i, wi); i < s; ++i){
syms[li++] = dat[i];
++lf[dat[i]];
}
pos = wblk(dat, w, lst, syms, lf, df, eb, li, bs, i - bs, pos);
if (!lst) {
st.r = pos & 7 | w[pos / 8 | 0] << 3;
// shft(pos) now 1 less if pos & 7 != 0
pos -= 7;
st.h = head, st.p = prev, st.i = i, st.w = wi;
}
} else {
for(var i = st.w || 0; i < s + lst; i += 65535){
// end
var e = i + 65535;
if (e >= s) {
// write final block
w[pos / 8 | 0] = lst;
e = s;
}
pos = wfblk(w, pos + 1, dat.subarray(i, e));
}
st.i = s;
}
return slc(o, 0, pre + shft(pos) + post);
};
// CRC32 table
var crct = /*#__PURE__*/ function() {
var t = new Int32Array(256);
for(var i = 0; i < 256; ++i){
var c = i, k = 9;
while(--k)c = (c & 1 && -306674912) ^ c >>> 1;
t[i] = c;
}
return t;
}();
// CRC32
var crc = function() {
var c = -1;
return {
p: function(d) {
// closures have awful performance
var cr = c;
for(var i = 0; i < d.length; ++i)cr = crct[cr & 255 ^ d[i]] ^ cr >>> 8;
c = cr;
},
d: function() {
return ~c;
}
};
};
// Adler32
var adler = function() {
var a = 1, b = 0;
return {
p: function(d) {
// closures have awful performance
var n = a, m = b;
var l = d.length | 0;
for(var i = 0; i != l;){
var e = Math.min(i + 2655, l);
for(; i < e; ++i)m += n += d[i];
n = (n & 65535) + 15 * (n >> 16), m = (m & 65535) + 15 * (m >> 16);
}
a = n, b = m;
},
d: function() {
a %= 65521, b %= 65521;
return (a & 255) << 24 | (a & 0xFF00) << 8 | (b & 255) << 8 | b >> 8;
}
};
};
;
// deflate with opts
var dopt = function(dat, opt, pre, post, st) {
if (!st) {
st = {
l: 1
};
if (opt.dictionary) {
var dict = opt.dictionary.subarray(-32768);
var newDat = new u8(dict.length + dat.length);
newDat.set(dict);
newDat.set(dat, dict.length);
dat = newDat;
st.w = dict.length;
}
}
return dflt(dat, opt.level == null ? 6 : opt.level, opt.mem == null ? st.l ? Math.ceil(Math.max(8, Math.min(13, Math.log(dat.length))) * 1.5) : 20 : 12 + opt.mem, pre, post, st);
};
// Walmart object spread
var mrg = function(a, b) {
var o = {};
for(var k in a)o[k] = a[k];
for(var k in b)o[k] = b[k];
return o;
};
// worker clone
// This is possibly the craziest part of the entire codebase, despite how simple it may seem.
// The only parameter to this function is a closure that returns an array of variables outside of the function scope.
// We're going to try to figure out the variable names used in the closure as strings because that is crucial for workerization.
// We will return an object mapping of true variable name to value (basically, the current scope as a JS object).
// The reason we can't just use the original variable names is minifiers mangling the toplevel scope.
// This took me three weeks to figure out how to do.
var wcln = function(fn, fnStr, td) {
var dt = fn();
var st = fn.toString();
var ks = st.slice(st.indexOf('[') + 1, st.lastIndexOf(']')).replace(/\s+/g, '').split(',');
for(var i = 0; i < dt.length; ++i){
var v = dt[i], k = ks[i];
if (typeof v == 'function') {
fnStr += ';' + k + '=';
var st_1 = v.toString();
if (v.prototype) {
// for global objects
if (st_1.indexOf('[native code]') != -1) {
var spInd = st_1.indexOf(' ', 8) + 1;
fnStr += st_1.slice(spInd, st_1.indexOf('(', spInd));
} else {
fnStr += st_1;
for(var t in v.prototype)fnStr += ';' + k + '.prototype.' + t + '=' + v.prototype[t].toString();
}
} else fnStr += st_1;
} else td[k] = v;
}
return fnStr;
};
var ch = [];
// clone bufs
var cbfs = function(v) {
var tl = [];
for(var k in v){
if (v[k].buffer) {
tl.push((v[k] = new v[k].constructor(v[k])).buffer);
}
}
return tl;
};
// use a worker to execute code
var wrkr = function(fns, init, id, cb) {
if (!ch[id]) {
var fnStr = '', td_1 = {}, m = fns.length - 1;
for(var i = 0; i < m; ++i)fnStr = wcln(fns[i], fnStr, td_1);
ch[id] = {
c: wcln(fns[m], fnStr, td_1),
e: td_1
};
}
var td = mrg({}, ch[id].e);
return (0, node_worker_1.default)(ch[id].c + ';onmessage=function(e){for(var k in e.data)self[k]=e.data[k];onmessage=' + init.toString() + '}', id, td, cbfs(td), cb);
};
// base async inflate fn
var bInflt = function() {
return [
u8,
u16,
i32,
fleb,
fdeb,
clim,
fl,
fd,
flrm,
fdrm,
rev,
ec,
hMap,
max,
bits,
bits16,
shft,
slc,
err,
inflt,
inflateSync,
pbf,
gopt
];
};
var bDflt = function() {
return [
u8,
u16,
i32,
fleb,
fdeb,
clim,
revfl,
revfd,
flm,
flt,
fdm,
fdt,
rev,
deo,
et,
hMap,
wbits,
wbits16,
hTree,
ln,
lc,
clen,
wfblk,
wblk,
shft,
slc,
dflt,
dopt,
deflateSync,
pbf
];
};
// gzip extra
var gze = function() {
return [
gzh,
gzhl,
wbytes,
crc,
crct
];
};
// gunzip extra
var guze = function() {
return [
gzs,
gzl
];
};
// zlib extra
var zle = function() {
return [
zlh,
wbytes,
adler
];
};
// unzlib extra
var zule = function() {
return [
zls
];
};
// post buf
var pbf = function(msg) {
return postMessage(msg, [
msg.buffer
]);
};
// get opts
var gopt = function(o) {
return o && {
out: o.size && new u8(o.size),
dictionary: o.dictionary
};
};
// async helper
var cbify = function(dat, opts, fns, init, id, cb) {
var w = wrkr(fns, init, id, function(err, dat) {
w.terminate();
cb(err, dat);
});
w.postMessage([
dat,
opts
], opts.consume ? [
dat.buffer
] : []);
return function() {
w.terminate();
};
};
// auto stream
var astrm = function(strm) {
strm.ondata = function(dat, final) {
return postMessage([
dat,
final
], [
dat.buffer
]);
};
return function(ev) {
if (ev.data.length) {
strm.push(ev.data[0], ev.data[1]);
postMessage([
ev.data[0].length
]);
} else strm.flush();
};
};
// async stream attach
var astrmify = function(fns, strm, opts, init, id, flush, ext) {
var t;
var w = wrkr(fns, init, id, function(err, dat) {
if (err) w.terminate(), strm.ondata.call(strm, err);
else if (!Array.isArray(dat)) ext(dat);
else if (dat.length == 1) {
strm.queuedSize -= dat[0];
if (strm.ondrain) strm.ondrain(dat[0]);
} else {
if (dat[1]) w.terminate();
strm.ondata.call(strm, err, dat[0], dat[1]);
}
});
w.postMessage(opts);
strm.queuedSize = 0;
strm.push = function(d, f) {
if (!strm.ondata) err(5);
if (t) strm.ondata(err(4, 0, 1), null, !!f);
strm.queuedSize += d.length;
w.postMessage([
d,
t = f
], [
d.buffer
]);
};
strm.terminate = function() {
w.terminate();
};
if (flush) {
strm.flush = function() {
w.postMessage([]);
};
}
};
// read 2 bytes
var b2 = function(d, b) {
return d[b] | d[b + 1] << 8;
};
// read 4 bytes
var b4 = function(d, b) {
return (d[b] | d[b + 1] << 8 | d[b + 2] << 16 | d[b + 3] << 24) >>> 0;
};
var b8 = function(d, b) {
return b4(d, b) + b4(d, b + 4) * 4294967296;
};
// write bytes
var wbytes = function(d, b, v) {
for(; v; ++b)d[b] = v, v >>>= 8;
};
// gzip header
var gzh = function(c, o) {
var fn = o.filename;
c[0] = 31, c[1] = 139, c[2] = 8, c[8] = o.level < 2 ? 4 : o.level == 9 ? 2 : 0, c[9] = 3; // assume Unix
if (o.mtime != 0) wbytes(c, 4, Math.floor(new Date(o.mtime || Date.now()) / 1000));
if (fn) {
c[3] = 8;
for(var i = 0; i <= fn.length; ++i)c[i + 10] = fn.charCodeAt(i);
}
};
// gzip footer: -8 to -4 = CRC, -4 to -0 is length
// gzip start
var gzs = function(d) {
if (d[0] != 31 || d[1] != 139 || d[2] != 8) err(6, 'invalid gzip data');
var flg = d[3];
var st = 10;
if (flg & 4) st += (d[10] | d[11] << 8) + 2;
for(var zs = (flg >> 3 & 1) + (flg >> 4 & 1); zs > 0; zs -= !d[st++]);
return st + (flg & 2);
};
// gzip length
var gzl = function(d) {
var l = d.length;
return (d[l - 4] | d[l - 3] << 8 | d[l - 2] << 16 | d[l - 1] << 24) >>> 0;
};
// gzip header length
var gzhl = function(o) {
return 10 + (o.filename ? o.filename.length + 1 : 0);
};
// zlib header
var zlh = function(c, o) {
var lv = o.level, fl = lv == 0 ? 0 : lv < 6 ? 1 : lv == 9 ? 3 : 2;
c[0] = 120, c[1] = fl << 6 | (o.dictionary && 32);
c[1] |= 31 - (c[0] << 8 | c[1]) % 31;
if (o.dictionary) {
var h = adler();
h.p(o.dictionary);
wbytes(c, 2, h.d());
}
};
// zlib start
var zls = function(d, dict) {
if ((d[0] & 15) != 8 || d[0] >> 4 > 7 || (d[0] << 8 | d[1]) % 31) err(6, 'invalid zlib data');
if ((d[1] >> 5 & 1) == +!dict) err(6, 'invalid zlib data: ' + (d[1] & 32 ? 'need' : 'unexpected') + ' dictionary');
return (d[1] >> 3 & 4) + 2;
};
function StrmOpt(opts, cb) {
if (typeof opts == 'function') cb = opts, opts = {};
this.ondata = cb;
return opts;
}
/**
* Streaming DEFLATE compression
*/ var Deflate = function() {
function Deflate(opts, cb) {
if (typeof opts == 'function') cb = opts, opts = {};
this.ondata = cb;
this.o = opts || {};
this.s = {
l: 0,
i: 32768,
w: 32768,
z: 32768
};
// Buffer length must always be 0 mod 32768 for index calculations to be correct when modifying head and prev
// 98304 = 32768 (lookback) + 65536 (common chunk size)
this.b = new u8(98304);
if (this.o.dictionary) {
var dict = this.o.dictionary.subarray(-32768);
this.b.set(dict, 32768 - dict.length);
this.s.i = 32768 - dict.length;
}
}
Deflate.prototype.p = function(c, f) {
this.ondata(dopt(c, this.o, 0, 0, this.s), f);
};
/**
* Pushes a chunk to be deflated
* @param chunk The chunk to push
* @param final Whether this is the last chunk
*/ Deflate.prototype.push = function(chunk, final) {
if (!this.ondata) err(5);
if (this.s.l) err(4);
var endLen = chunk.length + this.s.z;
if (endLen > this.b.length) {
if (endLen > 2 * this.b.length - 32768) {
var newBuf = new u8(endLen & -32768);
newBuf.set(this.b.subarray(0, this.s.z));
this.b = newBuf;
}
var split = this.b.length - this.s.z;
this.b.set(chunk.subarray(0, split), this.s.z);
this.s.z = this.b.length;
this.p(this.b, false);
this.b.set(this.b.subarray(-32768));
this.b.set(chunk.subarray(split), 32768);
this.s.z = chunk.length - split + 32768;
this.s.i = 32766, this.s.w = 32768;
} else {
this.b.set(chunk, this.s.z);
this.s.z += chunk.length;
}
this.s.l = final & 1;
if (this.s.z > this.s.w + 8191 || final) {
this.p(this.b, final || false);
this.s.w = this.s.i, this.s.i -= 2;
}
};
/**
* Flushes buffered uncompressed data. Useful to immediately retrieve the
* deflated output for small inputs.
*/ Deflate.prototype.flush = function() {
if (!this.ondata) err(5);
if (this.s.l) err(4);
this.p(this.b, false);
this.s.w = this.s.i, this.s.i -= 2;
};
return Deflate;
}();
exports.Deflate = Deflate;
/**
* Asynchronous streaming DEFLATE compression
*/ var AsyncDeflate = function() {
function AsyncDeflate(opts, cb) {
astrmify([
bDflt,
function() {
return [
astrm,
Deflate
];
}
], this, StrmOpt.call(this, opts, cb), function(ev) {
var strm = new Deflate(ev.data);
onmessage = astrm(strm);
}, 6, 1);
}
return AsyncDeflate;
}();
exports.AsyncDeflate = AsyncDeflate;
function deflate(data, opts, cb) {
if (!cb) cb = opts, opts = {};
if (typeof cb != 'function') err(7);
return cbify(data, opts, [
bDflt
], function(ev) {
return pbf(deflateSync(ev.data[0], ev.data[1]));
}, 0, cb);
}
exports.deflate = deflate;
/**
* Compresses data with DEFLATE without any wrapper
* @param data The data to compress
* @param opts The compression options
* @returns The deflated version of the data
*/ function deflateSync(data, opts) {
return dopt(data, opts || {}, 0, 0);
}
exports.deflateSync = deflateSync;
/**
* Streaming DEFLATE decompression
*/ var Inflate = function() {
function Inflate(opts, cb) {
// no StrmOpt here to avoid adding to workerizer
if (typeof opts == 'function') cb = opts, opts = {};
this.ondata = cb;
var dict = opts && opts.dictionary && opts.dictionary.subarray(-32768);
this.s = {
i: 0,
b: dict ? dict.length : 0
};
this.o = new u8(32768);
this.p = new u8(0);
if (dict) this.o.set(dict);
}
Inflate.prototype.e = function(c) {
if (!this.ondata) err(5);
if (this.d) err(4);
if (!this.p.length) this.p = c;
else if (c.length) {
var n = new u8(this.p.length + c.length);
n.set(this.p), n.set(c, this.p.length), this.p = n;
}
};
Inflate.prototype.c = function(final) {
this.s.i = +(this.d = final || false);
var bts = this.s.b;
var dt = inflt(this.p, this.s, this.o);
this.ondata(slc(dt, bts, this.s.b), this.d);
this.o = slc(dt, this.s.b - 32768), this.s.b = this.o.length;
this.p = slc(this.p, this.s.p / 8 | 0), this.s.p &= 7;
};
/**
* Pushes a chunk to be inflated
* @param chunk The chunk to push
* @param final Whether this is the final chunk
*/ Inflate.prototype.push = function(chunk, final) {
this.e(chunk), this.c(final);
};
return Inflate;
}();
exports.Inflate = Inflate;
/**
* Asynchronous streaming DEFLATE decompression
*/ var AsyncInflate = function() {
function AsyncInflate(opts, cb) {
astrmify([
bInflt,
function() {
return [
astrm,
Inflate
];
}
], this, StrmOpt.call(this, opts, cb), function(ev) {
var strm = new Inflate(ev.data);
onmessage = astrm(strm);
}, 7, 0);
}
return AsyncInflate;
}();
exports.AsyncInflate = AsyncInflate;
function inflate(data, opts, cb) {
if (!cb) cb = opts, opts = {};
if (typeof cb != 'function') err(7);
return cbify(data, opts, [
bInflt
], function(ev) {
return pbf(inflateSync(ev.data[0], gopt(ev.data[1])));
}, 1, cb);
}
exports.inflate = inflate;
/**
* Expands DEFLATE data with no wrapper
* @param data The data to decompress
* @param opts The decompression options
* @returns The decompressed version of the data
*/ function inflateSync(data, opts) {
return inflt(data, {
i: 2
}, opts && opts.out, opts && opts.dictionary);
}
exports.inflateSync = inflateSync;
// before you yell at me for not just using extends, my reason is that TS inheritance is hard to workerize.
/**
* Streaming GZIP compression
*/ var Gzip = function() {
function Gzip(opts, cb) {
this.c = crc();
this.l = 0;
this.v = 1;
Deflate.call(this, opts, cb);
}
/**
* Pushes a chunk to be GZIPped
* @param chunk The chunk to push
* @param final Whether this is the last chunk
*/ Gzip.prototype.push = function(chunk, final) {
this.c.p(chunk);
this.l += chunk.length;
Deflate.prototype.push.call(this, chunk, final);
};
Gzip.prototype.p = function(c, f) {
var raw = dopt(c, this.o, this.v && gzhl(this.o), f && 8, this.s);
if (this.v) gzh(raw, this.o), this.v = 0;
if (f) wbytes(raw, raw.length - 8, this.c.d()), wbytes(raw, raw.length - 4, this.l);
this.ondata(raw, f);
};
/**
* Flushes buffered uncompressed data. Useful to immediately retrieve the
* GZIPped output for small inputs.
*/ Gzip.prototype.flush = function() {
Deflate.prototype.flush.call(this);
};
return Gzip;
}();
exports.Gzip = Gzip;
exports.Compress = Gzip;
/**
* Asynchronous streaming GZIP compression
*/ var AsyncGzip = function() {
function AsyncGzip(opts, cb) {
astrmify([
bDflt,
gze,
function() {
return [
astrm,
Deflate,
Gzip
];
}
], this, StrmOpt.call(this, opts, cb), function(ev) {
var strm = new Gzip(ev.data);
onmessage = astrm(strm);
}, 8, 1);
}
return AsyncGzip;
}();
exports.AsyncGzip = AsyncGzip;
exports.AsyncCompress = AsyncGzip;
function gzip(data, opts, cb) {
if (!cb) cb = opts, opts = {};
if (typeof cb != 'function') err(7);
return cbify(data, opts, [
bDflt,
gze,
function() {
return [
gzipSync
];
}
], function(ev) {
return pbf(gzipSync(ev.data[0], ev.data[1]));
}, 2, cb);
}
exports.gzip = gzip;
exports.compress = gzip;
/**
* Compresses data with GZIP
* @param data The data to compress
* @param opts The compression options
* @returns The gzipped version of the data
*/ function gzipSync(data, opts) {
if (!opts) opts = {};
var c = crc(), l = data.length;
c.p(data);
var d = dopt(data, opts, gzhl(opts), 8), s = d.length;
return gzh(d, opts), wbytes(d, s - 8, c.d()), wbytes(d, s - 4, l), d;
}
exports.gzipSync = gzipSync;
exports.compressSync = gzipSync;
/**
* Streaming single or multi-member GZIP decompression
*/ var Gunzip = function() {
function Gunzip(opts, cb) {
this.v = 1;
this.r = 0;
Inflate.call(this, opts, cb);
}
/**
* Pushes a chunk to be GUNZIPped
* @param chunk The chunk to push
* @param final Whether this is the last chunk
*/ Gunzip.prototype.push = function(chunk, final) {
Inflate.prototype.e.call(this, chunk);
this.r += chunk.length;
if (this.v) {
var p = this.p.subarray(this.v - 1);
var s = p.length > 3 ? gzs(p) : 4;
if (s > p.length) {
if (!final) return;
} else if (this.v > 1 && this.onmember) {
this.onmember(this.r - p.length);
}
this.p = p.subarray(s), this.v = 0;
}
// necessary to prevent TS from using the closure value
// This allows for workerization to function correctly
Inflate.prototype.c.call(this, final);
// process concatenated GZIP
if (this.s.f && !this.s.l && !final) {
this.v = shft(this.s.p) + 9;
this.s = {
i: 0
};
this.o = new u8(0);
this.push(new u8(0), final);
}
};
return Gunzip;
}();
exports.Gunzip = Gunzip;
/**
* Asynchronous streaming single or multi-member GZIP decompression
*/ var AsyncGunzip = function() {
function AsyncGunzip(opts, cb) {
var _this = this;
astrmify([
bInflt,
guze,
function() {
return [
astrm,
Inflate,
Gunzip
];
}
], this, StrmOpt.call(this, opts, cb), function(ev) {
var strm = new Gunzip(ev.data);
strm.onmember = function(offset) {
return postMessage(offset);
};
onmessage = astrm(strm);
}, 9, 0, function(offset) {
return _this.onmember && _this.onmember(offset);
});
}
return AsyncGunzip;
}();
exports.AsyncGunzip = AsyncGunzip;
function gunzip(data, opts, cb) {
if (!cb) cb = opts, opts = {};
if (typeof cb != 'function') err(7);
return cbify(data, opts, [
bInflt,
guze,
function() {
return [
gunzipSync
];
}
], function(ev) {
return pbf(gunzipSync(ev.data[0], ev.data[1]));
}, 3, cb);
}
exports.gunzip = gunzip;
/**
* Expands GZIP data
* @param data The data to decompress
* @param opts The decompression options
* @returns The decompressed version of the data
*/ function gunzipSync(data, opts) {
var st = gzs(data);
if (st + 8 > data.length) err(6, 'invalid gzip data');
return inflt(data.subarray(st, -8), {
i: 2
}, opts && opts.out || new u8(gzl(data)), opts && opts.dictionary);
}
exports.gunzipSync = gunzipSync;
/**
* Streaming Zlib compression
*/ var Zlib = function() {
function Zlib(opts, cb) {
this.c = adler();
this.v = 1;
Deflate.call(this, opts, cb);
}
/**
* Pushes a chunk to be zlibbed
* @param chunk The chunk to push
* @param final Whether this is the last chunk
*/ Zlib.prototype.push = function(chunk, final) {
this.c.p(chunk);
Deflate.prototype.push.call(this, chunk, final);
};
Zlib.prototype.p = function(c, f) {
var raw = dopt(c, this.o, this.v && (this.o.dictionary ? 6 : 2), f && 4, this.s);
if (this.v) zlh(raw, this.o), this.v = 0;
if (f) wbytes(raw, raw.length - 4, this.c.d());
this.ondata(raw, f);
};
/**
* Flushes buffered uncompressed data. Useful to immediately retrieve the
* zlibbed output for small inputs.
*/ Zlib.prototype.flush = function() {
Deflate.prototype.flush.call(this);
};
return Zlib;
}();
exports.Zlib = Zlib;
/**
* Asynchronous streaming Zlib compression
*/ var AsyncZlib = function() {
function AsyncZlib(opts, cb) {
astrmify([
bDflt,
zle,
function() {
return [
astrm,
Deflate,
Zlib
];
}
], this, StrmOpt.call(this, opts, cb), function(ev) {
var strm = new Zlib(ev.data);
onmessage = astrm(strm);
}, 10, 1);
}
return AsyncZlib;
}();
exports.AsyncZlib = AsyncZlib;
function zlib(data, opts, cb) {
if (!cb) cb = opts, opts = {};
if (typeof cb != 'function') err(7);
return cbify(data, opts, [
bDflt,
zle,
function() {
return [
zlibSync
];
}
], function(ev) {
return pbf(zlibSync(ev.data[0], ev.data[1]));
}, 4, cb);
}
exports.zlib = zlib;
/**
* Compress data with Zlib
* @param data The data to compress
* @param opts The compression options
* @returns The zlib-compressed version of the data
*/ function zlibSync(data, opts) {
if (!opts) opts = {};
var a = adler();
a.p(data);
var d = dopt(data, opts, opts.dictionary ? 6 : 2, 4);
return zlh(d, opts), wbytes(d, d.length - 4, a.d()), d;
}
exports.zlibSync = zlibSync;
/**
* Streaming Zlib decompression
*/ var Unzlib = function() {
function Unzlib(opts, cb) {
Inflate.call(this, opts, cb);
this.v = opts && opts.dictionary ? 2 : 1;
}
/**
* Pushes a chunk to be unzlibbed
* @param chunk The chunk to push
* @param final Whether this is the last chunk
*/ Unzlib.prototype.push = function(chunk, final) {
Inflate.prototype.e.call(this, chunk);
if (this.v) {
if (this.p.length < 6 && !final) return;
this.p = this.p.subarray(zls(this.p, this.v - 1)), this.v = 0;
}
if (final) {
if (this.p.length < 4) err(6, 'invalid zlib data');
this.p = this.p.subarray(0, -4);
}
// necessary to prevent TS from using the closure value
// This allows for workerization to function correctly
Inflate.prototype.c.call(this, final);
};
return Unzlib;
}();
exports.Unzlib = Unzlib;
/**
* Asynchronous streaming Zlib decompression
*/ var AsyncUnzlib = function() {
function AsyncUnzlib(opts, cb) {
astrmify([
bInflt,
zule,
function() {
return [
astrm,
Inflate,
Unzlib
];
}
], this, StrmOpt.call(this, opts, cb), function(ev) {
var strm = new Unzlib(ev.data);
onmessage = astrm(strm);
}, 11, 0);
}
return AsyncUnzlib;
}();
exports.AsyncUnzlib = AsyncUnzlib;
function unzlib(data, opts, cb) {
if (!cb) cb = opts, opts = {};
if (typeof cb != 'function') err(7);
return cbify(data, opts, [
bInflt,
zule,
function() {
return [
unzlibSync
];
}
], function(ev) {
return pbf(unzlibSync(ev.data[0], gopt(ev.data[1])));
}, 5, cb);
}
exports.unzlib = unzlib;
/**
* Expands Zlib data
* @param data The data to decompress
* @param opts The decompression options
* @returns The decompressed version of the data
*/ function unzlibSync(data, opts) {
return inflt(data.subarray(zls(data, opts && opts.dictionary), -4), {
i: 2
}, opts && opts.out, opts && opts.dictionary);
}
exports.unzlibSync = unzlibSync;
/**
* Streaming GZIP, Zlib, or raw DEFLATE decompression
*/ var Decompress = function() {
function Decompress(opts, cb) {
this.o = StrmOpt.call(this, opts, cb) || {};
this.G = Gunzip;
this.I = Inflate;
this.Z = Unzlib;
}
// init substream
// overriden by AsyncDecompress
Decompress.prototype.i = function() {
var _this = this;
this.s.ondata = function(dat, final) {
_this.ondata(dat, final);
};
};
/**
* Pushes a chunk to be decompressed
* @param chunk The chunk to push
* @param final Whether this is the last chunk
*/ Decompress.prototype.push = function(chunk, final) {
if (!this.ondata) err(5);
if (!this.s) {
if (this.p && this.p.length) {
var n = new u8(this.p.length + chunk.length);
n.set(this.p), n.set(chunk, this.p.length);
} else this.p = chunk;
if (this.p.length > 2) {
this.s = this.p[0] == 31 && this.p[1] == 139 && this.p[2] == 8 ? new this.G(this.o) : (this.p[0] & 15) != 8 || this.p[0] >> 4 > 7 || (this.p[0] << 8 | this.p[1]) % 31 ? new this.I(this.o) : new this.Z(this.o);
this.i();
this.s.push(this.p, final);
this.p = null;
}
} else this.s.push(chunk, final);
};
return Decompress;
}();
exports.Decompress = Decompress;
/**
* Asynchronous streaming GZIP, Zlib, or raw DEFLATE decompression
*/ var AsyncDecompress = function() {
function AsyncDecompress(opts, cb) {
Decompress.call(this, opts, cb);
this.queuedSize = 0;
this.G = AsyncGunzip;
this.I = AsyncInflate;
this.Z = AsyncUnzlib;
}
AsyncDecompress.prototype.i = function() {
var _this = this;
this.s.ondata = function(err, dat, final) {
_this.ondata(err, dat, final);
};
this.s.ondrain = function(size) {
_this.queuedSize -= size;
if (_this.ondrain) _this.ondrain(size);
};
};
/**
* Pushes a chunk to be decompressed
* @param chunk The chunk to push
* @param final Whether this is the last chunk
*/ AsyncDecompress.prototype.push = function(chunk, final) {
this.queuedSize += chunk.length;
Decompress.prototype.push.call(this, chunk, final);
};
return AsyncDecompress;
}();
exports.AsyncDecompress = AsyncDecompress;
function decompress(data, opts, cb) {
if (!cb) cb = opts, opts = {};
if (typeof cb != 'function') err(7);
return data[0] == 31 && data[1] == 139 && data[2] == 8 ? gunzip(data, opts, cb) : (data[0] & 15) != 8 || data[0] >> 4 > 7 || (data[0] << 8 | data[1]) % 31 ? inflate(data, opts, cb) : unzlib(data, opts, cb);
}
exports.decompress = decompress;
/**
* Expands compressed GZIP, Zlib, or raw DEFLATE data, automatically detecting the format
* @param data The data to decompress
* @param opts The decompression options
* @returns The decompressed version of the data
*/ function decompressSync(data, opts) {
return data[0] == 31 && data[1] == 139 && data[2] == 8 ? gunzipSync(data, opts) : (data[0] & 15) != 8 || data[0] >> 4 > 7 || (data[0] << 8 | data[1]) % 31 ? inflateSync(data, opts) : unzlibSync(data, opts);
}
exports.decompressSync = decompressSync;
// flatten a directory structure
var fltn = function(d, p, t, o) {
for(var k in d){
var val = d[k], n = p + k, op = o;
if (Array.isArray(val)) op = mrg(o, val[1]), val = val[0];
if (val instanceof u8) t[n] = [
val,
op
];
else {
t[n += '/'] = [
new u8(0),
op
];
fltn(val, n, t, o);
}
}
};
// text encoder
var te = typeof TextEncoder != 'undefined' && /*#__PURE__*/ new TextEncoder();
// text decoder
var td = typeof TextDecoder != 'undefined' && /*#__PURE__*/ new TextDecoder();
// text decoder stream
var tds = 0;
try {
td.decode(et, {
stream: true
});
tds = 1;
} catch (e) {}
// decode UTF8
var dutf8 = function(d) {
for(var r = '', i = 0;;){
var c = d[i++];
var eb = (c > 127) + (c > 223) + (c > 239);
if (i + eb > d.length) return {
s: r,
r: slc(d, i - 1)
};
if (!eb) r += String.fromCharCode(c);
else if (eb == 3) {
c = ((c & 15) << 18 | (d[i++] & 63) << 12 | (d[i++] & 63) << 6 | d[i++] & 63) - 65536, r += String.fromCharCode(55296 | c >> 10, 56320 | c & 1023);
} else if (eb & 1) r += String.fromCharCode((c & 31) << 6 | d[i++] & 63);
else r += String.fromCharCode((c & 15) << 12 | (d[i++] & 63) << 6 | d[i++] & 63);
}
};
/**
* Streaming UTF-8 decoding
*/ var DecodeUTF8 = function() {
/**
* Creates a UTF-8 decoding stream
* @param cb The callback to call whenever data is decoded
*/ function DecodeUTF8(cb) {
this.ondata = cb;
if (tds) this.t = new TextDecoder();
else this.p = et;
}
/**
* Pushes a chunk to be decoded from UTF-8 binary
* @param chunk The chunk to push
* @param final Whether this is the last chunk
*/ DecodeUTF8.prototype.push = function(chunk, final) {
if (!this.ondata) err(5);
final = !!final;
if (this.t) {
this.ondata(this.t.decode(chunk, {
stream: true
}), final);
if (final) {
if (this.t.decode().length) err(8);
this.t = null;
}
return;
}
if (!this.p) err(4);
var dat = new u8(this.p.length + chunk.length);
dat.set(this.p);
dat.set(chunk, this.p.length);
var _a = dutf8(dat), s = _a.s, r = _a.r;
if (final) {
if (r.length) err(8);
this.p = null;
} else this.p = r;
this.ondata(s, final);
};
return DecodeUTF8;
}();
exports.DecodeUTF8 = DecodeUTF8;
/**
* Streaming UTF-8 encoding
*/ var EncodeUTF8 = function() {
/**
* Creates a UTF-8 decoding stream
* @param cb The callback to call whenever data is encoded
*/ function EncodeUTF8(cb) {
this.ondata = cb;
}
/**
* Pushes a chunk to be encoded to UTF-8
* @param chunk The string data to push
* @param final Whether this is the last chunk
*/ EncodeUTF8.prototype.push = function(chunk, final) {
if (!this.ondata) err(5);
if (this.d) err(4);
this.ondata(strToU8(chunk), this.d = final || false);
};
return EncodeUTF8;
}();
exports.EncodeUTF8 = EncodeUTF8;
/**
* Converts a string into a Uint8Array for use with compression/decompression methods
* @param str The string to encode
* @param latin1 Whether or not to interpret the data as Latin-1. This should
* not need to be true unless decoding a binary string.
* @returns The string encoded in UTF-8/Latin-1 binary
*/ function strToU8(str, latin1) {
if (latin1) {
var ar_1 = new u8(str.length);
for(var i = 0; i < str.length; ++i)ar_1[i] = str.charCodeAt(i);
return ar_1;
}
if (te) return te.encode(str);
var l = str.length;
var ar = new u8(str.length + (str.length >> 1));
var ai = 0;
var w = function(v) {
ar[ai++] = v;
};
for(var i = 0; i < l; ++i){
if (ai + 5 > ar.length) {
var n = new u8(ai + 8 + (l - i << 1));
n.set(ar);
ar = n;
}
var c = str.charCodeAt(i);
if (c < 128 || latin1) w(c);
else if (c < 2048) w(192 | c >> 6), w(128 | c & 63);
else if (c > 55295 && c < 57344) c = 65536 + (c & 1023 << 10) | str.charCodeAt(++i) & 1023, w(240 | c >> 18), w(128 | c >> 12 & 63), w(128 | c >> 6 & 63), w(128 | c & 63);
else w(224 | c >> 12), w(128 | c >> 6 & 63), w(128 | c & 63);
}
return slc(ar, 0, ai);
}
exports.strToU8 = strToU8;
/**
* Converts a Uint8Array to a string
* @param dat The data to decode to string
* @param latin1 Whether or not to interpret the data as Latin-1. This should
* not need to be true unless encoding to binary string.
* @returns The original UTF-8/Latin-1 string
*/ function strFromU8(dat, latin1) {
if (latin1) {
var r = '';
for(var i = 0; i < dat.length; i += 16384)r += String.fromCharCode.apply(null, dat.subarray(i, i + 16384));
return r;
} else if (td) {
return td.decode(dat);
} else {
var _a = dutf8(dat), s = _a.s, r = _a.r;
if (r.length) err(8);
return s;
}
}
exports.strFromU8 = strFromU8;
;
// deflate bit flag
var dbf = function(l) {
return l == 1 ? 3 : l < 6 ? 2 : l == 9 ? 1 : 0;
};
// skip local zip header
var slzh = function(d, b) {
return b + 30 + b2(d, b + 26) + b2(d, b + 28);
};
// read zip header
var zh = function(d, b, z) {
var fnl = b2(d, b + 28), fn = strFromU8(d.subarray(b + 46, b + 46 + fnl), !(b2(d, b + 8) & 2048)), es = b + 46 + fnl, bs = b4(d, b + 20);
var _a = z && bs == 4294967295 ? z64e(d, es) : [
bs,
b4(d, b + 24),
b4(d, b + 42)
], sc = _a[0], su = _a[1], off = _a[2];
return [
b2(d, b + 10),
sc,
su,
fn,
es + b2(d, b + 30) + b2(d, b + 32),
off
];
};
// read zip64 extra field
var z64e = function(d, b) {
for(; b2(d, b) != 1; b += 4 + b2(d, b + 2));
return [
b8(d, b + 12),
b8(d, b + 4),
b8(d, b + 20)
];
};
// extra field length
var exfl = function(ex) {
var le = 0;
if (ex) {
for(var k in ex){
var l = ex[k].length;
if (l > 65535) err(9);
le += l + 4;
}
}
return le;
};
// write zip header
var wzh = function(d, b, f, fn, u, c, ce, co) {
var fl = fn.length, ex = f.extra, col = co && co.length;
var exl = exfl(ex);
wbytes(d, b, ce != null ? 0x2014B50 : 0x4034B50), b += 4;
if (ce != null) d[b++] = 20, d[b++] = f.os;
d[b] = 20, b += 2; // spec compliance? what's that?
d[b++] = f.flag << 1 | (c < 0 && 8), d[b++] = u && 8;
d[b++] = f.compression & 255, d[b++] = f.compression >> 8;
var dt = new Date(f.mtime == null ? Date.now() : f.mtime), y = dt.getFullYear() - 1980;
if (y < 0 || y > 119) err(10);
wbytes(d, b, y << 25 | dt.getMonth() + 1 << 21 | dt.getDate() << 16 | dt.getHours() << 11 | dt.getMinutes() << 5 | dt.getSeconds() >> 1), b += 4;
if (c != -1) {
wbytes(d, b, f.crc);
wbytes(d, b + 4, c < 0 ? -c - 2 : c);
wbytes(d, b + 8, f.size);
}
wbytes(d, b + 12, fl);
wbytes(d, b + 14, exl), b += 16;
if (ce != null) {
wbytes(d, b, col);
wbytes(d, b + 6, f.attrs);
wbytes(d, b + 10, ce), b += 14;
}
d.set(fn, b);
b += fl;
if (exl) {
for(var k in ex){
var exf = ex[k], l = exf.length;
wbytes(d, b, +k);
wbytes(d, b + 2, l);
d.set(exf, b + 4), b += 4 + l;
}
}
if (col) d.set(co, b), b += col;
return b;
};
// write zip footer (end of central directory)
var wzf = function(o, b, c, d, e) {
wbytes(o, b, 0x6054B50); // skip disk
wbytes(o, b + 8, c);
wbytes(o, b + 10, c);
wbytes(o, b + 12, d);
wbytes(o, b + 16, e);
};
/**
* A pass-through stream to keep data uncompressed in a ZIP archive.
*/ var ZipPassThrough = function() {
/**
* Creates a pass-through stream that can be added to ZIP archives
* @param filename The filename to associate with this data stream
*/ function ZipPassThrough(filename) {
this.filename = filename;
this.c = crc();
this.size = 0;
this.compression = 0;
}
/**
* Processes a chunk and pushes to the output stream. You can override this
* method in a subclass for custom behavior, but by default this passes
* the data through. You must call this.ondata(err, chunk, final) at some
* point in this method.
* @param chunk The chunk to process
* @param final Whether this is the last chunk
*/ ZipPassThrough.prototype.process = function(chunk, final) {
this.ondata(null, chunk, final);
};
/**
* Pushes a chunk to be added. If you are subclassing this with a custom
* compression algorithm, note that you must push data from the source
* file only, pre-compression.
* @param chunk The chunk to push
* @param final Whether this is the last chunk
*/ ZipPassThrough.prototype.push = function(chunk, final) {
if (!this.ondata) err(5);
this.c.p(chunk);
this.size += chunk.length;
if (final) this.crc = this.c.d();
this.process(chunk, final || false);
};
return ZipPassThrough;
}();
exports.ZipPassThrough = ZipPassThrough;
// I don't extend because TypeScript extension adds 1kB of runtime bloat
/**
* Streaming DEFLATE compression for ZIP archives. Prefer using AsyncZipDeflate
* for better performance
*/ var ZipDeflate = function() {
/**
* Creates a DEFLATE stream that can be added to ZIP archives
* @param filename The filename to associate with this data stream
* @param opts The compression options
*/ function ZipDeflate(filename, opts) {
var _this = this;
if (!opts) opts = {};
ZipPassThrough.call(this, filename);
this.d = new Deflate(opts, function(dat, final) {
_this.ondata(null, dat, final);
});
this.compression = 8;
this.flag = dbf(opts.level);
}
ZipDeflate.prototype.process = function(chunk, final) {
try {
this.d.push(chunk, final);
} catch (e) {
this.ondata(e, null, final);
}
};
/**
* Pushes a chunk to be deflated
* @param chunk The chunk to push
* @param final Whether this is the last chunk
*/ ZipDeflate.prototype.push = function(chunk, final) {
ZipPassThrough.prototype.push.call(this, chunk, final);
};
return ZipDeflate;
}();
exports.ZipDeflate = ZipDeflate;
/**
* Asynchronous streaming DEFLATE compression for ZIP archives
*/ var AsyncZipDeflate = function() {
/**
* Creates an asynchronous DEFLATE stream that can be added to ZIP archives
* @param filename The filename to associate with this data stream
* @param opts The compression options
*/ function AsyncZipDeflate(filename, opts) {
var _this = this;
if (!opts) opts = {};
ZipPassThrough.call(this, filename);
this.d = new AsyncDeflate(opts, function(err, dat, final) {
_this.ondata(err, dat, final);
});
this.compression = 8;
this.flag = dbf(opts.level);
this.terminate = this.d.terminate;
}
AsyncZipDeflate.prototype.process = function(chunk, final) {
this.d.push(chunk, final);
};
/**
* Pushes a chunk to be deflated
* @param chunk The chunk to push
* @param final Whether this is the last chunk
*/ AsyncZipDeflate.prototype.push = function(chunk, final) {
ZipPassThrough.prototype.push.call(this, chunk, final);
};
return AsyncZipDeflate;
}();
exports.AsyncZipDeflate = AsyncZipDeflate;
// TODO: Better tree shaking
/**
* A zippable archive to which files can incrementally be added
*/ var Zip = function() {
/**
* Creates an empty ZIP archive to which files can be added
* @param cb The callback to call whenever data for the generated ZIP archive
* is available
*/ function Zip(cb) {
this.ondata = cb;
this.u = [];
this.d = 1;
}
/**
* Adds a file to the ZIP archive
* @param file The file stream to add
*/ Zip.prototype.add = function(file) {
var _this = this;
if (!this.ondata) err(5);
// finishing or finished
if (this.d & 2) this.ondata(err(4 + (this.d & 1) * 8, 0, 1), null, false);
else {
var f = strToU8(file.filename), fl_1 = f.length;
var com = file.comment, o = com && strToU8(com);
var u = fl_1 != file.filename.length || o && com.length != o.length;
var hl_1 = fl_1 + exfl(file.extra) + 30;
if (fl_1 > 65535) this.ondata(err(11, 0, 1), null, false);
var header = new u8(hl_1);
wzh(header, 0, file, f, u, -1);
var chks_1 = [
header
];
var pAll_1 = function() {
for(var _i = 0, chks_2 = chks_1; _i < chks_2.length; _i++){
var chk = chks_2[_i];
_this.ondata(null, chk, false);
}
chks_1 = [];
};
var tr_1 = this.d;
this.d = 0;
var ind_1 = this.u.length;
var uf_1 = mrg(file, {
f: f,
u: u,
o: o,
t: function() {
if (file.terminate) file.terminate();
},
r: function() {
pAll_1();
if (tr_1) {
var nxt = _this.u[ind_1 + 1];
if (nxt) nxt.r();
else _this.d = 1;
}
tr_1 = 1;
}
});
var cl_1 = 0;
file.ondata = function(err, dat, final) {
if (err) {
_this.ondata(err, dat, final);
_this.terminate();
} else {
cl_1 += dat.length;
chks_1.push(dat);
if (final) {
var dd = new u8(16);
wbytes(dd, 0, 0x8074B50);
wbytes(dd, 4, file.crc);
wbytes(dd, 8, cl_1);
wbytes(dd, 12, file.size);
chks_1.push(dd);
uf_1.c = cl_1, uf_1.b = hl_1 + cl_1 + 16, uf_1.crc = file.crc, uf_1.size = file.size;
if (tr_1) uf_1.r();
tr_1 = 1;
} else if (tr_1) pAll_1();
}
};
this.u.push(uf_1);
}
};
/**
* Ends the process of adding files and prepares to emit the final chunks.
* This *must* be called after adding all desired files for the resulting
* ZIP file to work properly.
*/ Zip.prototype.end = function() {
var _this = this;
if (this.d & 2) {
this.ondata(err(4 + (this.d & 1) * 8, 0, 1), null, true);
return;
}
if (this.d) this.e();
else this.u.push({
r: function() {
if (!(_this.d & 1)) return;
_this.u.splice(-1, 1);
_this.e();
},
t: function() {}
});
this.d = 3;
};
Zip.prototype.e = function() {
var bt = 0, l = 0, tl = 0;
for(var _i = 0, _a = this.u; _i < _a.length; _i++){
var f = _a[_i];
tl += 46 + f.f.length + exfl(f.extra) + (f.o ? f.o.length : 0);
}
var out = new u8(tl + 22);
for(var _b = 0, _c = this.u; _b < _c.length; _b++){
var f = _c[_b];
wzh(out, bt, f, f.f, f.u, -f.c - 2, l, f.o);
bt += 46 + f.f.length + exfl(f.extra) + (f.o ? f.o.length : 0), l += f.b;
}
wzf(out, bt, this.u.length, tl, l);
this.ondata(null, out, true);
this.d = 2;
};
/**
* A method to terminate any internal workers used by the stream. Subsequent
* calls to add() will fail.
*/ Zip.prototype.terminate = function() {
for(var _i = 0, _a = this.u; _i < _a.length; _i++){
var f = _a[_i];
f.t();
}
this.d = 2;
};
return Zip;
}();
exports.Zip = Zip;
function zip(data, opts, cb) {
if (!cb) cb = opts, opts = {};
if (typeof cb != 'function') err(7);
var r = {};
fltn(data, '', r, opts);
var k = Object.keys(r);
var lft = k.length, o = 0, tot = 0;
var slft = lft, files = new Array(lft);
var term = [];
var tAll = function() {
for(var i = 0; i < term.length; ++i)term[i]();
};
var cbd = function(a, b) {
mt(function() {
cb(a, b);
});
};
mt(function() {
cbd = cb;
});
var cbf = function() {
var out = new u8(tot + 22), oe = o, cdl = tot - o;
tot = 0;
for(var i = 0; i < slft; ++i){
var f = files[i];
try {
var l = f.c.length;
wzh(out, tot, f, f.f, f.u, l);
var badd = 30 + f.f.length + exfl(f.extra);
var loc = tot + badd;
out.set(f.c, loc);
wzh(out, o, f, f.f, f.u, l, tot, f.m), o += 16 + badd + (f.m ? f.m.length : 0), tot = loc + l;
} catch (e) {
return cbd(e, null);
}
}
wzf(out, o, files.length, cdl, oe);
cbd(null, out);
};
if (!lft) cbf();
var _loop_1 = function(i) {
var fn = k[i];
var _a = r[fn], file = _a[0], p = _a[1];
var c = crc(), size = file.length;
c.p(file);
var f = strToU8(fn), s = f.length;
var com = p.comment, m = com && strToU8(com), ms = m && m.length;
var exl = exfl(p.extra);
var compression = p.level == 0 ? 0 : 8;
var cbl = function(e, d) {
if (e) {
tAll();
cbd(e, null);
} else {
var l = d.length;
files[i] = mrg(p, {
size: size,
crc: c.d(),
c: d,
f: f,
m: m,
u: s != fn.length || m && com.length != ms,
compression: compression
});
o += 30 + s + exl + l;
tot += 76 + 2 * (s + exl) + (ms || 0) + l;
if (!--lft) cbf();
}
};
if (s > 65535) cbl(err(11, 0, 1), null);
if (!compression) cbl(null, file);
else if (size < 160000) {
try {
cbl(null, deflateSync(file, p));
} catch (e) {
cbl(e, null);
}
} else term.push(deflate(file, p, cbl));
};
// Cannot use lft because it can decrease
for(var i = 0; i < slft; ++i){
_loop_1(i);
}
return tAll;
}
exports.zip = zip;
/**
* Synchronously creates a ZIP file. Prefer using `zip` for better performance
* with more than one file.
* @param data The directory structure for the ZIP archive
* @param opts The main options, merged with per-file options
* @returns The generated ZIP archive
*/ function zipSync(data, opts) {
if (!opts) opts = {};
var r = {};
var files = [];
fltn(data, '', r, opts);
var o = 0;
var tot = 0;
for(var fn in r){
var _a = r[fn], file = _a[0], p = _a[1];
var compression = p.level == 0 ? 0 : 8;
var f = strToU8(fn), s = f.length;
var com = p.comment, m = com && strToU8(com), ms = m && m.length;
var exl = exfl(p.extra);
if (s > 65535) err(11);
var d = compression ? deflateSync(file, p) : file, l = d.length;
var c = crc();
c.p(file);
files.push(mrg(p, {
size: file.length,
crc: c.d(),
c: d,
f: f,
m: m,
u: s != fn.length || m && com.length != ms,
o: o,
compression: compression
}));
o += 30 + s + exl + l;
tot += 76 + 2 * (s + exl) + (ms || 0) + l;
}
var out = new u8(tot + 22), oe = o, cdl = tot - o;
for(var i = 0; i < files.length; ++i){
var f = files[i];
wzh(out, f.o, f, f.f, f.u, f.c.length);
var badd = 30 + f.f.length + exfl(f.extra);
out.set(f.c, f.o + badd);
wzh(out, o, f, f.f, f.u, f.c.length, f.o, f.m), o += 16 + badd + (f.m ? f.m.length : 0);
}
wzf(out, o, files.length, cdl, oe);
return out;
}
exports.zipSync = zipSync;
/**
* Streaming pass-through decompression for ZIP archives
*/ var UnzipPassThrough = function() {
function UnzipPassThrough() {}
UnzipPassThrough.prototype.push = function(data, final) {
this.ondata(null, data, final);
};
UnzipPassThrough.compression = 0;
return UnzipPassThrough;
}();
exports.UnzipPassThrough = UnzipPassThrough;
/**
* Streaming DEFLATE decompression for ZIP archives. Prefer AsyncZipInflate for
* better performance.
*/ var UnzipInflate = function() {
/**
* Creates a DEFLATE decompression that can be used in ZIP archives
*/ function UnzipInflate() {
var _this = this;
this.i = new Inflate(function(dat, final) {
_this.ondata(null, dat, final);
});
}
UnzipInflate.prototype.push = function(data, final) {
try {
this.i.push(data, final);
} catch (e) {
this.ondata(e, null, final);
}
};
UnzipInflate.compression = 8;
return UnzipInflate;
}();
exports.UnzipInflate = UnzipInflate;
/**
* Asynchronous streaming DEFLATE decompression for ZIP archives
*/ var AsyncUnzipInflate = function() {
/**
* Creates a DEFLATE decompression that can be used in ZIP archives
*/ function AsyncUnzipInflate(_, sz) {
var _this = this;
if (sz < 320000) {
this.i = new Inflate(function(dat, final) {
_this.ondata(null, dat, final);
});
} else {
this.i = new AsyncInflate(function(err, dat, final) {
_this.ondata(err, dat, final);
});
this.terminate = this.i.terminate;
}
}
AsyncUnzipInflate.prototype.push = function(data, final) {
if (this.i.terminate) data = slc(data, 0);
this.i.push(data, final);
};
AsyncUnzipInflate.compression = 8;
return AsyncUnzipInflate;
}();
exports.AsyncUnzipInflate = AsyncUnzipInflate;
/**
* A ZIP archive decompression stream that emits files as they are discovered
*/ var Unzip = function() {
/**
* Creates a ZIP decompression stream
* @param cb The callback to call whenever a file in the ZIP archive is found
*/ function Unzip(cb) {
this.onfile = cb;
this.k = [];
this.o = {
0: UnzipPassThrough
};
this.p = et;
}
/**
* Pushes a chunk to be unzipped
* @param chunk The chunk to push
* @param final Whether this is the last chunk
*/ Unzip.prototype.push = function(chunk, final) {
var _this = this;
if (!this.onfile) err(5);
if (!this.p) err(4);
if (this.c > 0) {
var len = Math.min(this.c, chunk.length);
var toAdd = chunk.subarray(0, len);
this.c -= len;
if (this.d) this.d.push(toAdd, !this.c);
else this.k[0].push(toAdd);
chunk = chunk.subarray(len);
if (chunk.length) return this.push(chunk, final);
} else {
var f = 0, i = 0, is = void 0, buf = void 0;
if (!this.p.length) buf = chunk;
else if (!chunk.length) buf = this.p;
else {
buf = new u8(this.p.length + chunk.length);
buf.set(this.p), buf.set(chunk, this.p.length);
}
var l = buf.length, oc = this.c, add = oc && this.d;
var _loop_2 = function() {
var _a;
var sig = b4(buf, i);
if (sig == 0x4034B50) {
f = 1, is = i;
this_1.d = null;
this_1.c = 0;
var bf = b2(buf, i + 6), cmp_1 = b2(buf, i + 8), u = bf & 2048, dd = bf & 8, fnl = b2(buf, i + 26), es = b2(buf, i + 28);
if (l > i + 30 + fnl + es) {
var chks_3 = [];
this_1.k.unshift(chks_3);
f = 2;
var sc_1 = b4(buf, i + 18), su_1 = b4(buf, i + 22);
var fn_1 = strFromU8(buf.subarray(i + 30, i += 30 + fnl), !u);
if (sc_1 == 4294967295) {
_a = dd ? [
-2
] : z64e(buf, i), sc_1 = _a[0], su_1 = _a[1];
} else if (dd) sc_1 = -1;
i += es;
this_1.c = sc_1;
var d_1;
var file_1 = {
name: fn_1,
compression: cmp_1,
start: function() {
if (!file_1.ondata) err(5);
if (!sc_1) file_1.ondata(null, et, true);
else {
var ctr = _this.o[cmp_1];
if (!ctr) file_1.ondata(err(14, 'unknown compression type ' + cmp_1, 1), null, false);
d_1 = sc_1 < 0 ? new ctr(fn_1) : new ctr(fn_1, sc_1, su_1);
d_1.ondata = function(err, dat, final) {
file_1.ondata(err, dat, final);
};
for(var _i = 0, chks_4 = chks_3; _i < chks_4.length; _i++){
var dat = chks_4[_i];
d_1.push(dat, false);
}
if (_this.k[0] == chks_3 && _this.c) _this.d = d_1;
else d_1.push(et, true);
}
},
terminate: function() {
if (d_1 && d_1.terminate) d_1.terminate();
}
};
if (sc_1 >= 0) file_1.size = sc_1, file_1.originalSize = su_1;
this_1.onfile(file_1);
}
return "break";
} else if (oc) {
if (sig == 0x8074B50) {
is = i += 12 + (oc == -2 && 8), f = 3, this_1.c = 0;
return "break";
} else if (sig == 0x2014B50) {
is = i -= 4, f = 3, this_1.c = 0;
return "break";
}
}
};
var this_1 = this;
for(; i < l - 4; ++i){
var state_1 = _loop_2();
if (state_1 === "break") break;
}
this.p = et;
if (oc < 0) {
var dat = f ? buf.subarray(0, is - 12 - (oc == -2 && 8) - (b4(buf, is - 16) == 0x8074B50 && 4)) : buf.subarray(0, i);
if (add) add.push(dat, !!f);
else this.k[+(f == 2)].push(dat);
}
if (f & 2) return this.push(buf.subarray(i), final);
this.p = buf.subarray(i);
}
if (final) {
if (this.c) err(13);
this.p = null;
}
};
/**
* Registers a decoder with the stream, allowing for files compressed with
* the compression type provided to be expanded correctly
* @param decoder The decoder constructor
*/ Unzip.prototype.register = function(decoder) {
this.o[decoder.compression] = decoder;
};
return Unzip;
}();
exports.Unzip = Unzip;
var mt = typeof queueMicrotask == 'function' ? queueMicrotask : typeof setTimeout == 'function' ? setTimeout : function(fn) {
fn();
};
function unzip(data, opts, cb) {
if (!cb) cb = opts, opts = {};
if (typeof cb != 'function') err(7);
var term = [];
var tAll = function() {
for(var i = 0; i < term.length; ++i)term[i]();
};
var files = {};
var cbd = function(a, b) {
mt(function() {
cb(a, b);
});
};
mt(function() {
cbd = cb;
});
var e = data.length - 22;
for(; b4(data, e) != 0x6054B50; --e){
if (!e || data.length - e > 65558) {
cbd(err(13, 0, 1), null);
return tAll;
}
}
;
var lft = b2(data, e + 8);
if (lft) {
var c = lft;
var o = b4(data, e + 16);
var z = o == 4294967295 || c == 65535;
if (z) {
var ze = b4(data, e - 12);
z = b4(data, ze) == 0x6064B50;
if (z) {
c = lft = b4(data, ze + 32);
o = b4(data, ze + 48);
}
}
var fltr = opts && opts.filter;
var _loop_3 = function(i) {
var _a = zh(data, o, z), c_1 = _a[0], sc = _a[1], su = _a[2], fn = _a[3], no = _a[4], off = _a[5], b = slzh(data, off);
o = no;
var cbl = function(e, d) {
if (e) {
tAll();
cbd(e, null);
} else {
if (d) files[fn] = d;
if (!--lft) cbd(null, files);
}
};
if (!fltr || fltr({
name: fn,
size: sc,
originalSize: su,
compression: c_1
})) {
if (!c_1) cbl(null, slc(data, b, b + sc));
else if (c_1 == 8) {
var infl = data.subarray(b, b + sc);
// Synchronously decompress under 512KB, or barely-compressed data
if (su < 524288 || sc > 0.8 * su) {
try {
cbl(null, inflateSync(infl, {
out: new u8(su)
}));
} catch (e) {
cbl(e, null);
}
} else term.push(inflate(infl, {
size: su
}, cbl));
} else cbl(err(14, 'unknown compression type ' + c_1, 1), null);
} else cbl(null, null);
};
for(var i = 0; i < c; ++i){
_loop_3(i);
}
} else cbd(null, {});
return tAll;
}
exports.unzip = unzip;
/**
* Synchronously decompresses a ZIP archive. Prefer using `unzip` for better
* performance with more than one file.
* @param data The raw compressed ZIP file
* @param opts The ZIP extraction options
* @returns The decompressed files
*/ function unzipSync(data, opts) {
var files = {};
var e = data.length - 22;
for(; b4(data, e) != 0x6054B50; --e){
if (!e || data.length - e > 65558) err(13);
}
;
var c = b2(data, e + 8);
if (!c) return {};
var o = b4(data, e + 16);
var z = o == 4294967295 || c == 65535;
if (z) {
var ze = b4(data, e - 12);
z = b4(data, ze) == 0x6064B50;
if (z) {
c = b4(data, ze + 32);
o = b4(data, ze + 48);
}
}
var fltr = opts && opts.filter;
for(var i = 0; i < c; ++i){
var _a = zh(data, o, z), c_2 = _a[0], sc = _a[1], su = _a[2], fn = _a[3], no = _a[4], off = _a[5], b = slzh(data, off);
o = no;
if (!fltr || fltr({
name: fn,
size: sc,
originalSize: su,
compression: c_2
})) {
if (!c_2) files[fn] = slc(data, b, b + sc);
else if (c_2 == 8) files[fn] = inflateSync(data.subarray(b, b + sc), {
out: new u8(su)
});
else err(14, 'unknown compression type ' + c_2);
}
}
return files;
}
exports.unzipSync = unzipSync;
}),
"[project]/node_modules/iobuffer/lib-esm/text.js [app-ssr] (ecmascript)", ((__turbopack_context__) => {
"use strict";
__turbopack_context__.s([
"decode",
()=>decode,
"encode",
()=>encode
]);
function decode(bytes, encoding = 'utf8') {
const decoder = new TextDecoder(encoding);
return decoder.decode(bytes);
}
const encoder = new TextEncoder();
function encode(str) {
return encoder.encode(str);
}
}),
"[project]/node_modules/iobuffer/lib-esm/IOBuffer.js [app-ssr] (ecmascript)", ((__turbopack_context__) => {
"use strict";
__turbopack_context__.s([
"IOBuffer",
()=>IOBuffer
]);
var __TURBOPACK__imported__module__$5b$project$5d2f$node_modules$2f$iobuffer$2f$lib$2d$esm$2f$text$2e$js__$5b$app$2d$ssr$5d$__$28$ecmascript$29$__ = __turbopack_context__.i("[project]/node_modules/iobuffer/lib-esm/text.js [app-ssr] (ecmascript)");
;
const defaultByteLength = 1024 * 8;
const hostBigEndian = (()=>{
const array = new Uint8Array(4);
const view = new Uint32Array(array.buffer);
return !((view[0] = 1) & array[0]);
})();
const typedArrays = {
int8: globalThis.Int8Array,
uint8: globalThis.Uint8Array,
int16: globalThis.Int16Array,
uint16: globalThis.Uint16Array,
int32: globalThis.Int32Array,
uint32: globalThis.Uint32Array,
uint64: globalThis.BigUint64Array,
int64: globalThis.BigInt64Array,
float32: globalThis.Float32Array,
float64: globalThis.Float64Array
};
class IOBuffer {
/**
* Reference to the internal ArrayBuffer object.
*/ buffer;
/**
* Byte length of the internal ArrayBuffer.
*/ byteLength;
/**
* Byte offset of the internal ArrayBuffer.
*/ byteOffset;
/**
* Byte length of the internal ArrayBuffer.
*/ length;
/**
* The current offset of the buffer's pointer.
*/ offset;
lastWrittenByte;
littleEndian;
_data;
_mark;
_marks;
/**
* Create a new IOBuffer.
* @param data - The data to construct the IOBuffer with.
* If data is a number, it will be the new buffer's length<br>
* If data is `undefined`, the buffer will be initialized with a default length of 8Kb<br>
* If data is an ArrayBuffer, SharedArrayBuffer, an ArrayBufferView (Typed Array), an IOBuffer instance,
* or a Node.js Buffer, a view will be created over the underlying ArrayBuffer.
* @param options - An object for the options.
* @returns A new IOBuffer instance.
*/ constructor(data = defaultByteLength, options = {}){
let dataIsGiven = false;
if (typeof data === 'number') {
data = new ArrayBuffer(data);
} else {
dataIsGiven = true;
this.lastWrittenByte = data.byteLength;
}
const offset = options.offset ? options.offset >>> 0 : 0;
const byteLength = data.byteLength - offset;
let dvOffset = offset;
if (ArrayBuffer.isView(data) || data instanceof IOBuffer) {
if (data.byteLength !== data.buffer.byteLength) {
dvOffset = data.byteOffset + offset;
}
data = data.buffer;
}
if (dataIsGiven) {
this.lastWrittenByte = byteLength;
} else {
this.lastWrittenByte = 0;
}
this.buffer = data;
this.length = byteLength;
this.byteLength = byteLength;
this.byteOffset = dvOffset;
this.offset = 0;
this.littleEndian = true;
this._data = new DataView(this.buffer, dvOffset, byteLength);
this._mark = 0;
this._marks = [];
}
/**
* Checks if the memory allocated to the buffer is sufficient to store more
* bytes after the offset.
* @param byteLength - The needed memory in bytes.
* @returns `true` if there is sufficient space and `false` otherwise.
*/ available(byteLength = 1) {
return this.offset + byteLength <= this.length;
}
/**
* Check if little-endian mode is used for reading and writing multi-byte
* values.
* @returns `true` if little-endian mode is used, `false` otherwise.
*/ isLittleEndian() {
return this.littleEndian;
}
/**
* Set little-endian mode for reading and writing multi-byte values.
* @returns This.
*/ setLittleEndian() {
this.littleEndian = true;
return this;
}
/**
* Check if big-endian mode is used for reading and writing multi-byte values.
* @returns `true` if big-endian mode is used, `false` otherwise.
*/ isBigEndian() {
return !this.littleEndian;
}
/**
* Switches to big-endian mode for reading and writing multi-byte values.
* @returns This.
*/ setBigEndian() {
this.littleEndian = false;
return this;
}
/**
* Move the pointer n bytes forward.
* @param n - Number of bytes to skip.
* @returns This.
*/ skip(n = 1) {
this.offset += n;
return this;
}
/**
* Move the pointer n bytes backward.
* @param n - Number of bytes to move back.
* @returns This.
*/ back(n = 1) {
this.offset -= n;
return this;
}
/**
* Move the pointer to the given offset.
* @param offset - The offset to move to.
* @returns This.
*/ seek(offset) {
this.offset = offset;
return this;
}
/**
* Store the current pointer offset.
* @see {@link IOBuffer#reset}
* @returns This.
*/ mark() {
this._mark = this.offset;
return this;
}
/**
* Move the pointer back to the last pointer offset set by mark.
* @see {@link IOBuffer#mark}
* @returns This.
*/ reset() {
this.offset = this._mark;
return this;
}
/**
* Push the current pointer offset to the mark stack.
* @see {@link IOBuffer#popMark}
* @returns This.
*/ pushMark() {
this._marks.push(this.offset);
return this;
}
/**
* Pop the last pointer offset from the mark stack, and set the current
* pointer offset to the popped value.
* @see {@link IOBuffer#pushMark}
* @returns This.
*/ popMark() {
const offset = this._marks.pop();
if (offset === undefined) {
throw new Error('Mark stack empty');
}
this.seek(offset);
return this;
}
/**
* Move the pointer offset back to 0.
* @returns This.
*/ rewind() {
this.offset = 0;
return this;
}
/**
* Make sure the buffer has sufficient memory to write a given byteLength at
* the current pointer offset.
* If the buffer's memory is insufficient, this method will create a new
* buffer (a copy) with a length that is twice (byteLength + current offset).
* @param byteLength - The needed memory in bytes.
* @returns This.
*/ ensureAvailable(byteLength = 1) {
if (!this.available(byteLength)) {
const lengthNeeded = this.offset + byteLength;
const newLength = lengthNeeded * 2;
const newArray = new Uint8Array(newLength);
newArray.set(new Uint8Array(this.buffer));
this.buffer = newArray.buffer;
this.length = newLength;
this.byteLength = newLength;
this._data = new DataView(this.buffer);
}
return this;
}
/**
* Read a byte and return false if the byte's value is 0, or true otherwise.
* Moves pointer forward by one byte.
* @returns The read boolean.
*/ readBoolean() {
return this.readUint8() !== 0;
}
/**
* Read a signed 8-bit integer and move pointer forward by 1 byte.
* @returns The read byte.
*/ readInt8() {
return this._data.getInt8(this.offset++);
}
/**
* Read an unsigned 8-bit integer and move pointer forward by 1 byte.
* @returns The read byte.
*/ readUint8() {
return this._data.getUint8(this.offset++);
}
/**
* Alias for {@link IOBuffer#readUint8}.
* @returns The read byte.
*/ readByte() {
return this.readUint8();
}
/**
* Read `n` bytes and move pointer forward by `n` bytes.
* @param n - Number of bytes to read.
* @returns The read bytes.
*/ readBytes(n = 1) {
return this.readArray(n, 'uint8');
}
/**
* Creates an array of corresponding to the type `type` and size `size`.
* For example type `uint8` will create a `Uint8Array`.
* @param size - size of the resulting array
* @param type - number type of elements to read
* @returns The read array.
*/ readArray(size, type) {
const bytes = typedArrays[type].BYTES_PER_ELEMENT * size;
const offset = this.byteOffset + this.offset;
const slice = this.buffer.slice(offset, offset + bytes);
if (this.littleEndian === hostBigEndian && type !== 'uint8' && type !== 'int8') {
const slice = new Uint8Array(this.buffer.slice(offset, offset + bytes));
slice.reverse();
const returnArray = new typedArrays[type](slice.buffer);
this.offset += bytes;
returnArray.reverse();
return returnArray;
}
const returnArray = new typedArrays[type](slice);
this.offset += bytes;
return returnArray;
}
/**
* Read a 16-bit signed integer and move pointer forward by 2 bytes.
* @returns The read value.
*/ readInt16() {
const value = this._data.getInt16(this.offset, this.littleEndian);
this.offset += 2;
return value;
}
/**
* Read a 16-bit unsigned integer and move pointer forward by 2 bytes.
* @returns The read value.
*/ readUint16() {
const value = this._data.getUint16(this.offset, this.littleEndian);
this.offset += 2;
return value;
}
/**
* Read a 32-bit signed integer and move pointer forward by 4 bytes.
* @returns The read value.
*/ readInt32() {
const value = this._data.getInt32(this.offset, this.littleEndian);
this.offset += 4;
return value;
}
/**
* Read a 32-bit unsigned integer and move pointer forward by 4 bytes.
* @returns The read value.
*/ readUint32() {
const value = this._data.getUint32(this.offset, this.littleEndian);
this.offset += 4;
return value;
}
/**
* Read a 32-bit floating number and move pointer forward by 4 bytes.
* @returns The read value.
*/ readFloat32() {
const value = this._data.getFloat32(this.offset, this.littleEndian);
this.offset += 4;
return value;
}
/**
* Read a 64-bit floating number and move pointer forward by 8 bytes.
* @returns The read value.
*/ readFloat64() {
const value = this._data.getFloat64(this.offset, this.littleEndian);
this.offset += 8;
return value;
}
/**
* Read a 64-bit signed integer number and move pointer forward by 8 bytes.
* @returns The read value.
*/ readBigInt64() {
const value = this._data.getBigInt64(this.offset, this.littleEndian);
this.offset += 8;
return value;
}
/**
* Read a 64-bit unsigned integer number and move pointer forward by 8 bytes.
* @returns The read value.
*/ readBigUint64() {
const value = this._data.getBigUint64(this.offset, this.littleEndian);
this.offset += 8;
return value;
}
/**
* Read a 1-byte ASCII character and move pointer forward by 1 byte.
* @returns The read character.
*/ readChar() {
// eslint-disable-next-line unicorn/prefer-code-point
return String.fromCharCode(this.readInt8());
}
/**
* Read `n` 1-byte ASCII characters and move pointer forward by `n` bytes.
* @param n - Number of characters to read.
* @returns The read characters.
*/ readChars(n = 1) {
let result = '';
for(let i = 0; i < n; i++){
result += this.readChar();
}
return result;
}
/**
* Read the next `n` bytes, return a UTF-8 decoded string and move pointer
* forward by `n` bytes.
* @param n - Number of bytes to read.
* @returns The decoded string.
*/ readUtf8(n = 1) {
return (0, __TURBOPACK__imported__module__$5b$project$5d2f$node_modules$2f$iobuffer$2f$lib$2d$esm$2f$text$2e$js__$5b$app$2d$ssr$5d$__$28$ecmascript$29$__["decode"])(this.readBytes(n));
}
/**
* Read the next `n` bytes, return a string decoded with `encoding` and move pointer
* forward by `n` bytes.
* If no encoding is passed, the function is equivalent to @see {@link IOBuffer#readUtf8}
* @param n - Number of bytes to read.
* @param encoding - The encoding to use. Default is 'utf8'.
* @returns The decoded string.
*/ decodeText(n = 1, encoding = 'utf8') {
return (0, __TURBOPACK__imported__module__$5b$project$5d2f$node_modules$2f$iobuffer$2f$lib$2d$esm$2f$text$2e$js__$5b$app$2d$ssr$5d$__$28$ecmascript$29$__["decode"])(this.readBytes(n), encoding);
}
/**
* Write 0xff if the passed value is truthy, 0x00 otherwise and move pointer
* forward by 1 byte.
* @param value - The value to write.
* @returns This.
*/ writeBoolean(value) {
this.writeUint8(value ? 0xff : 0x00);
return this;
}
/**
* Write `value` as an 8-bit signed integer and move pointer forward by 1 byte.
* @param value - The value to write.
* @returns This.
*/ writeInt8(value) {
this.ensureAvailable(1);
this._data.setInt8(this.offset++, value);
this._updateLastWrittenByte();
return this;
}
/**
* Write `value` as an 8-bit unsigned integer and move pointer forward by 1
* byte.
* @param value - The value to write.
* @returns This.
*/ writeUint8(value) {
this.ensureAvailable(1);
this._data.setUint8(this.offset++, value);
this._updateLastWrittenByte();
return this;
}
/**
* An alias for {@link IOBuffer#writeUint8}.
* @param value - The value to write.
* @returns This.
*/ writeByte(value) {
return this.writeUint8(value);
}
/**
* Write all elements of `bytes` as uint8 values and move pointer forward by
* `bytes.length` bytes.
* @param bytes - The array of bytes to write.
* @returns This.
*/ writeBytes(bytes) {
this.ensureAvailable(bytes.length);
// eslint-disable-next-line @typescript-eslint/prefer-for-of
for(let i = 0; i < bytes.length; i++){
this._data.setUint8(this.offset++, bytes[i]);
}
this._updateLastWrittenByte();
return this;
}
/**
* Write `value` as a 16-bit signed integer and move pointer forward by 2
* bytes.
* @param value - The value to write.
* @returns This.
*/ writeInt16(value) {
this.ensureAvailable(2);
this._data.setInt16(this.offset, value, this.littleEndian);
this.offset += 2;
this._updateLastWrittenByte();
return this;
}
/**
* Write `value` as a 16-bit unsigned integer and move pointer forward by 2
* bytes.
* @param value - The value to write.
* @returns This.
*/ writeUint16(value) {
this.ensureAvailable(2);
this._data.setUint16(this.offset, value, this.littleEndian);
this.offset += 2;
this._updateLastWrittenByte();
return this;
}
/**
* Write `value` as a 32-bit signed integer and move pointer forward by 4
* bytes.
* @param value - The value to write.
* @returns This.
*/ writeInt32(value) {
this.ensureAvailable(4);
this._data.setInt32(this.offset, value, this.littleEndian);
this.offset += 4;
this._updateLastWrittenByte();
return this;
}
/**
* Write `value` as a 32-bit unsigned integer and move pointer forward by 4
* bytes.
* @param value - The value to write.
* @returns This.
*/ writeUint32(value) {
this.ensureAvailable(4);
this._data.setUint32(this.offset, value, this.littleEndian);
this.offset += 4;
this._updateLastWrittenByte();
return this;
}
/**
* Write `value` as a 32-bit floating number and move pointer forward by 4
* bytes.
* @param value - The value to write.
* @returns This.
*/ writeFloat32(value) {
this.ensureAvailable(4);
this._data.setFloat32(this.offset, value, this.littleEndian);
this.offset += 4;
this._updateLastWrittenByte();
return this;
}
/**
* Write `value` as a 64-bit floating number and move pointer forward by 8
* bytes.
* @param value - The value to write.
* @returns This.
*/ writeFloat64(value) {
this.ensureAvailable(8);
this._data.setFloat64(this.offset, value, this.littleEndian);
this.offset += 8;
this._updateLastWrittenByte();
return this;
}
/**
* Write `value` as a 64-bit signed bigint and move pointer forward by 8
* bytes.
* @param value - The value to write.
* @returns This.
*/ writeBigInt64(value) {
this.ensureAvailable(8);
this._data.setBigInt64(this.offset, value, this.littleEndian);
this.offset += 8;
this._updateLastWrittenByte();
return this;
}
/**
* Write `value` as a 64-bit unsigned bigint and move pointer forward by 8
* bytes.
* @param value - The value to write.
* @returns This.
*/ writeBigUint64(value) {
this.ensureAvailable(8);
this._data.setBigUint64(this.offset, value, this.littleEndian);
this.offset += 8;
this._updateLastWrittenByte();
return this;
}
/**
* Write the charCode of `str`'s first character as an 8-bit unsigned integer
* and move pointer forward by 1 byte.
* @param str - The character to write.
* @returns This.
*/ writeChar(str) {
// eslint-disable-next-line unicorn/prefer-code-point
return this.writeUint8(str.charCodeAt(0));
}
/**
* Write the charCodes of all `str`'s characters as 8-bit unsigned integers
* and move pointer forward by `str.length` bytes.
* @param str - The characters to write.
* @returns This.
*/ writeChars(str) {
for(let i = 0; i < str.length; i++){
// eslint-disable-next-line unicorn/prefer-code-point
this.writeUint8(str.charCodeAt(i));
}
return this;
}
/**
* UTF-8 encode and write `str` to the current pointer offset and move pointer
* forward according to the encoded length.
* @param str - The string to write.
* @returns This.
*/ writeUtf8(str) {
return this.writeBytes((0, __TURBOPACK__imported__module__$5b$project$5d2f$node_modules$2f$iobuffer$2f$lib$2d$esm$2f$text$2e$js__$5b$app$2d$ssr$5d$__$28$ecmascript$29$__["encode"])(str));
}
/**
* Export a Uint8Array view of the internal buffer.
* The view starts at the byte offset and its length
* is calculated to stop at the last written byte or the original length.
* @returns A new Uint8Array view.
*/ toArray() {
return new Uint8Array(this.buffer, this.byteOffset, this.lastWrittenByte);
}
/**
* Get the total number of bytes written so far, regardless of the current offset.
* @returns - Total number of bytes.
*/ getWrittenByteLength() {
return this.lastWrittenByte - this.byteOffset;
}
/**
* Update the last written byte offset
* @private
*/ _updateLastWrittenByte() {
if (this.offset > this.lastWrittenByte) {
this.lastWrittenByte = this.offset;
}
}
}
}),
"[project]/node_modules/fast-png/lib-esm/helpers/crc.js [app-ssr] (ecmascript)", ((__turbopack_context__) => {
"use strict";
__turbopack_context__.s([
"checkCrc",
()=>checkCrc,
"writeCrc",
()=>writeCrc
]);
const crcTable = [];
for(let n = 0; n < 256; n++){
let c = n;
for(let k = 0; k < 8; k++){
if (c & 1) {
c = 0xedb88320 ^ c >>> 1;
} else {
c = c >>> 1;
}
}
crcTable[n] = c;
}
const initialCrc = 0xffffffff;
function updateCrc(currentCrc, data, length) {
let c = currentCrc;
for(let n = 0; n < length; n++){
c = crcTable[(c ^ data[n]) & 0xff] ^ c >>> 8;
}
return c;
}
function crc(data, length) {
return (updateCrc(initialCrc, data, length) ^ initialCrc) >>> 0;
}
function checkCrc(buffer, crcLength, chunkName) {
const expectedCrc = buffer.readUint32();
const actualCrc = crc(new Uint8Array(buffer.buffer, buffer.byteOffset + buffer.offset - crcLength - 4, crcLength), crcLength); // "- 4" because we already advanced by reading the CRC
if (actualCrc !== expectedCrc) {
throw new Error(`CRC mismatch for chunk ${chunkName}. Expected ${expectedCrc}, found ${actualCrc}`);
}
}
function writeCrc(buffer, length) {
buffer.writeUint32(crc(new Uint8Array(buffer.buffer, buffer.byteOffset + buffer.offset - length, length), length));
}
}),
"[project]/node_modules/fast-png/lib-esm/helpers/unfilter.js [app-ssr] (ecmascript)", ((__turbopack_context__) => {
"use strict";
__turbopack_context__.s([
"unfilterAverage",
()=>unfilterAverage,
"unfilterNone",
()=>unfilterNone,
"unfilterPaeth",
()=>unfilterPaeth,
"unfilterSub",
()=>unfilterSub,
"unfilterUp",
()=>unfilterUp
]);
function unfilterNone(currentLine, newLine, bytesPerLine) {
for(let i = 0; i < bytesPerLine; i++){
newLine[i] = currentLine[i];
}
}
function unfilterSub(currentLine, newLine, bytesPerLine, bytesPerPixel) {
let i = 0;
for(; i < bytesPerPixel; i++){
// just copy first bytes
newLine[i] = currentLine[i];
}
for(; i < bytesPerLine; i++){
newLine[i] = currentLine[i] + newLine[i - bytesPerPixel] & 0xff;
}
}
function unfilterUp(currentLine, newLine, prevLine, bytesPerLine) {
let i = 0;
if (prevLine.length === 0) {
// just copy bytes for first line
for(; i < bytesPerLine; i++){
newLine[i] = currentLine[i];
}
} else {
for(; i < bytesPerLine; i++){
newLine[i] = currentLine[i] + prevLine[i] & 0xff;
}
}
}
function unfilterAverage(currentLine, newLine, prevLine, bytesPerLine, bytesPerPixel) {
let i = 0;
if (prevLine.length === 0) {
for(; i < bytesPerPixel; i++){
newLine[i] = currentLine[i];
}
for(; i < bytesPerLine; i++){
newLine[i] = currentLine[i] + (newLine[i - bytesPerPixel] >> 1) & 0xff;
}
} else {
for(; i < bytesPerPixel; i++){
newLine[i] = currentLine[i] + (prevLine[i] >> 1) & 0xff;
}
for(; i < bytesPerLine; i++){
newLine[i] = currentLine[i] + (newLine[i - bytesPerPixel] + prevLine[i] >> 1) & 0xff;
}
}
}
function unfilterPaeth(currentLine, newLine, prevLine, bytesPerLine, bytesPerPixel) {
let i = 0;
if (prevLine.length === 0) {
for(; i < bytesPerPixel; i++){
newLine[i] = currentLine[i];
}
for(; i < bytesPerLine; i++){
newLine[i] = currentLine[i] + newLine[i - bytesPerPixel] & 0xff;
}
} else {
for(; i < bytesPerPixel; i++){
newLine[i] = currentLine[i] + prevLine[i] & 0xff;
}
for(; i < bytesPerLine; i++){
newLine[i] = currentLine[i] + paethPredictor(newLine[i - bytesPerPixel], prevLine[i], prevLine[i - bytesPerPixel]) & 0xff;
}
}
}
function paethPredictor(a, b, c) {
const p = a + b - c;
const pa = Math.abs(p - a);
const pb = Math.abs(p - b);
const pc = Math.abs(p - c);
if (pa <= pb && pa <= pc) return a;
else if (pb <= pc) return b;
else return c;
}
}),
"[project]/node_modules/fast-png/lib-esm/helpers/applyUnfilter.js [app-ssr] (ecmascript)", ((__turbopack_context__) => {
"use strict";
__turbopack_context__.s([
"applyUnfilter",
()=>applyUnfilter
]);
var __TURBOPACK__imported__module__$5b$project$5d2f$node_modules$2f$fast$2d$png$2f$lib$2d$esm$2f$helpers$2f$unfilter$2e$js__$5b$app$2d$ssr$5d$__$28$ecmascript$29$__ = __turbopack_context__.i("[project]/node_modules/fast-png/lib-esm/helpers/unfilter.js [app-ssr] (ecmascript)");
;
function applyUnfilter(filterType, currentLine, newLine, prevLine, passLineBytes, bytesPerPixel) {
switch(filterType){
case 0:
(0, __TURBOPACK__imported__module__$5b$project$5d2f$node_modules$2f$fast$2d$png$2f$lib$2d$esm$2f$helpers$2f$unfilter$2e$js__$5b$app$2d$ssr$5d$__$28$ecmascript$29$__["unfilterNone"])(currentLine, newLine, passLineBytes);
break;
case 1:
(0, __TURBOPACK__imported__module__$5b$project$5d2f$node_modules$2f$fast$2d$png$2f$lib$2d$esm$2f$helpers$2f$unfilter$2e$js__$5b$app$2d$ssr$5d$__$28$ecmascript$29$__["unfilterSub"])(currentLine, newLine, passLineBytes, bytesPerPixel);
break;
case 2:
(0, __TURBOPACK__imported__module__$5b$project$5d2f$node_modules$2f$fast$2d$png$2f$lib$2d$esm$2f$helpers$2f$unfilter$2e$js__$5b$app$2d$ssr$5d$__$28$ecmascript$29$__["unfilterUp"])(currentLine, newLine, prevLine, passLineBytes);
break;
case 3:
(0, __TURBOPACK__imported__module__$5b$project$5d2f$node_modules$2f$fast$2d$png$2f$lib$2d$esm$2f$helpers$2f$unfilter$2e$js__$5b$app$2d$ssr$5d$__$28$ecmascript$29$__["unfilterAverage"])(currentLine, newLine, prevLine, passLineBytes, bytesPerPixel);
break;
case 4:
(0, __TURBOPACK__imported__module__$5b$project$5d2f$node_modules$2f$fast$2d$png$2f$lib$2d$esm$2f$helpers$2f$unfilter$2e$js__$5b$app$2d$ssr$5d$__$28$ecmascript$29$__["unfilterPaeth"])(currentLine, newLine, prevLine, passLineBytes, bytesPerPixel);
break;
default:
throw new Error(`Unsupported filter: ${filterType}`);
}
}
}),
"[project]/node_modules/fast-png/lib-esm/helpers/decodeInterlaceAdam7.js [app-ssr] (ecmascript)", ((__turbopack_context__) => {
"use strict";
__turbopack_context__.s([
"decodeInterlaceAdam7",
()=>decodeInterlaceAdam7
]);
var __TURBOPACK__imported__module__$5b$project$5d2f$node_modules$2f$fast$2d$png$2f$lib$2d$esm$2f$helpers$2f$applyUnfilter$2e$js__$5b$app$2d$ssr$5d$__$28$ecmascript$29$__ = __turbopack_context__.i("[project]/node_modules/fast-png/lib-esm/helpers/applyUnfilter.js [app-ssr] (ecmascript)");
;
const uint16 = new Uint16Array([
0x00ff
]);
const uint8 = new Uint8Array(uint16.buffer);
const osIsLittleEndian = uint8[0] === 0xff;
function decodeInterlaceAdam7(params) {
const { data, width, height, channels, depth } = params;
// Adam7 interlacing pattern
const passes = [
{
x: 0,
y: 0,
xStep: 8,
yStep: 8
},
{
x: 4,
y: 0,
xStep: 8,
yStep: 8
},
{
x: 0,
y: 4,
xStep: 4,
yStep: 8
},
{
x: 2,
y: 0,
xStep: 4,
yStep: 4
},
{
x: 0,
y: 2,
xStep: 2,
yStep: 4
},
{
x: 1,
y: 0,
xStep: 2,
yStep: 2
},
{
x: 0,
y: 1,
xStep: 1,
yStep: 2
}
];
const bytesPerPixel = Math.ceil(depth / 8) * channels;
const resultData = new Uint8Array(height * width * bytesPerPixel);
let offset = 0;
// Process each pass
for(let passIndex = 0; passIndex < 7; passIndex++){
const pass = passes[passIndex];
// Calculate pass dimensions
const passWidth = Math.ceil((width - pass.x) / pass.xStep);
const passHeight = Math.ceil((height - pass.y) / pass.yStep);
if (passWidth <= 0 || passHeight <= 0) continue;
const passLineBytes = passWidth * bytesPerPixel;
const prevLine = new Uint8Array(passLineBytes);
// Process each scanline in this pass
for(let y = 0; y < passHeight; y++){
// First byte is the filter type
const filterType = data[offset++];
const currentLine = data.subarray(offset, offset + passLineBytes);
offset += passLineBytes;
// Create a new line for the unfiltered data
const newLine = new Uint8Array(passLineBytes);
// Apply the appropriate unfilter
(0, __TURBOPACK__imported__module__$5b$project$5d2f$node_modules$2f$fast$2d$png$2f$lib$2d$esm$2f$helpers$2f$applyUnfilter$2e$js__$5b$app$2d$ssr$5d$__$28$ecmascript$29$__["applyUnfilter"])(filterType, currentLine, newLine, prevLine, passLineBytes, bytesPerPixel);
prevLine.set(newLine);
for(let x = 0; x < passWidth; x++){
const outputX = pass.x + x * pass.xStep;
const outputY = pass.y + y * pass.yStep;
if (outputX >= width || outputY >= height) continue;
for(let i = 0; i < bytesPerPixel; i++){
resultData[(outputY * width + outputX) * bytesPerPixel + i] = newLine[x * bytesPerPixel + i];
}
}
}
}
if (depth === 16) {
const uint16Data = new Uint16Array(resultData.buffer);
if (osIsLittleEndian) {
for(let k = 0; k < uint16Data.length; k++){
// PNG is always big endian. Swap the bytes.
uint16Data[k] = swap16(uint16Data[k]);
}
}
return uint16Data;
} else {
return resultData;
}
}
function swap16(val) {
return (val & 0xff) << 8 | val >> 8 & 0xff;
}
}),
"[project]/node_modules/fast-png/lib-esm/helpers/decodeInterlaceNull.js [app-ssr] (ecmascript)", ((__turbopack_context__) => {
"use strict";
__turbopack_context__.s([
"decodeInterlaceNull",
()=>decodeInterlaceNull
]);
var __TURBOPACK__imported__module__$5b$project$5d2f$node_modules$2f$fast$2d$png$2f$lib$2d$esm$2f$helpers$2f$unfilter$2e$js__$5b$app$2d$ssr$5d$__$28$ecmascript$29$__ = __turbopack_context__.i("[project]/node_modules/fast-png/lib-esm/helpers/unfilter.js [app-ssr] (ecmascript)");
;
const uint16 = new Uint16Array([
0x00ff
]);
const uint8 = new Uint8Array(uint16.buffer);
const osIsLittleEndian = uint8[0] === 0xff;
const empty = new Uint8Array(0);
function decodeInterlaceNull(params) {
const { data, width, height, channels, depth } = params;
const bytesPerPixel = Math.ceil(depth / 8) * channels;
const bytesPerLine = Math.ceil(depth / 8 * channels * width);
const newData = new Uint8Array(height * bytesPerLine);
let prevLine = empty;
let offset = 0;
let currentLine;
let newLine;
for(let i = 0; i < height; i++){
currentLine = data.subarray(offset + 1, offset + 1 + bytesPerLine);
newLine = newData.subarray(i * bytesPerLine, (i + 1) * bytesPerLine);
switch(data[offset]){
case 0:
(0, __TURBOPACK__imported__module__$5b$project$5d2f$node_modules$2f$fast$2d$png$2f$lib$2d$esm$2f$helpers$2f$unfilter$2e$js__$5b$app$2d$ssr$5d$__$28$ecmascript$29$__["unfilterNone"])(currentLine, newLine, bytesPerLine);
break;
case 1:
(0, __TURBOPACK__imported__module__$5b$project$5d2f$node_modules$2f$fast$2d$png$2f$lib$2d$esm$2f$helpers$2f$unfilter$2e$js__$5b$app$2d$ssr$5d$__$28$ecmascript$29$__["unfilterSub"])(currentLine, newLine, bytesPerLine, bytesPerPixel);
break;
case 2:
(0, __TURBOPACK__imported__module__$5b$project$5d2f$node_modules$2f$fast$2d$png$2f$lib$2d$esm$2f$helpers$2f$unfilter$2e$js__$5b$app$2d$ssr$5d$__$28$ecmascript$29$__["unfilterUp"])(currentLine, newLine, prevLine, bytesPerLine);
break;
case 3:
(0, __TURBOPACK__imported__module__$5b$project$5d2f$node_modules$2f$fast$2d$png$2f$lib$2d$esm$2f$helpers$2f$unfilter$2e$js__$5b$app$2d$ssr$5d$__$28$ecmascript$29$__["unfilterAverage"])(currentLine, newLine, prevLine, bytesPerLine, bytesPerPixel);
break;
case 4:
(0, __TURBOPACK__imported__module__$5b$project$5d2f$node_modules$2f$fast$2d$png$2f$lib$2d$esm$2f$helpers$2f$unfilter$2e$js__$5b$app$2d$ssr$5d$__$28$ecmascript$29$__["unfilterPaeth"])(currentLine, newLine, prevLine, bytesPerLine, bytesPerPixel);
break;
default:
throw new Error(`Unsupported filter: ${data[offset]}`);
}
prevLine = newLine;
offset += bytesPerLine + 1;
}
if (depth === 16) {
const uint16Data = new Uint16Array(newData.buffer);
if (osIsLittleEndian) {
for(let k = 0; k < uint16Data.length; k++){
// PNG is always big endian. Swap the bytes.
uint16Data[k] = swap16(uint16Data[k]);
}
}
return uint16Data;
} else {
return newData;
}
}
function swap16(val) {
return (val & 0xff) << 8 | val >> 8 & 0xff;
}
}),
"[project]/node_modules/fast-png/lib-esm/helpers/signature.js [app-ssr] (ecmascript)", ((__turbopack_context__) => {
"use strict";
__turbopack_context__.s([
"checkSignature",
()=>checkSignature,
"hasPngSignature",
()=>hasPngSignature,
"writeSignature",
()=>writeSignature
]);
// https://www.w3.org/TR/PNG/#5PNG-file-signature
const pngSignature = Uint8Array.of(137, 80, 78, 71, 13, 10, 26, 10);
function writeSignature(buffer) {
buffer.writeBytes(pngSignature);
}
function checkSignature(buffer) {
if (!hasPngSignature(buffer.readBytes(pngSignature.length))) {
throw new Error('wrong PNG signature');
}
}
function hasPngSignature(array) {
if (array.length < pngSignature.length) {
return false;
}
for(let i = 0; i < pngSignature.length; i++){
if (array[i] !== pngSignature[i]) {
return false;
}
}
return true;
}
}),
"[project]/node_modules/fast-png/lib-esm/helpers/text.js [app-ssr] (ecmascript)", ((__turbopack_context__) => {
"use strict";
__turbopack_context__.s([
"decodetEXt",
()=>decodetEXt,
"encodetEXt",
()=>encodetEXt,
"readKeyword",
()=>readKeyword,
"readLatin1",
()=>readLatin1,
"textChunkName",
()=>textChunkName
]);
var __TURBOPACK__imported__module__$5b$project$5d2f$node_modules$2f$fast$2d$png$2f$lib$2d$esm$2f$helpers$2f$crc$2e$js__$5b$app$2d$ssr$5d$__$28$ecmascript$29$__ = __turbopack_context__.i("[project]/node_modules/fast-png/lib-esm/helpers/crc.js [app-ssr] (ecmascript)");
;
const textChunkName = 'tEXt';
const NULL = 0;
const latin1Decoder = new TextDecoder('latin1');
function validateKeyword(keyword) {
validateLatin1(keyword);
if (keyword.length === 0 || keyword.length > 79) {
throw new Error('keyword length must be between 1 and 79');
}
}
// eslint-disable-next-line no-control-regex
const latin1Regex = /^[\u0000-\u00FF]*$/;
function validateLatin1(text) {
if (!latin1Regex.test(text)) {
throw new Error('invalid latin1 text');
}
}
function decodetEXt(text, buffer, length) {
const keyword = readKeyword(buffer);
text[keyword] = readLatin1(buffer, length - keyword.length - 1);
}
function encodetEXt(buffer, keyword, text) {
validateKeyword(keyword);
validateLatin1(text);
const length = keyword.length + 1 /* NULL */ + text.length;
buffer.writeUint32(length);
buffer.writeChars(textChunkName);
buffer.writeChars(keyword);
buffer.writeByte(NULL);
buffer.writeChars(text);
(0, __TURBOPACK__imported__module__$5b$project$5d2f$node_modules$2f$fast$2d$png$2f$lib$2d$esm$2f$helpers$2f$crc$2e$js__$5b$app$2d$ssr$5d$__$28$ecmascript$29$__["writeCrc"])(buffer, length + 4);
}
function readKeyword(buffer) {
buffer.mark();
while(buffer.readByte() !== NULL){
/* advance */ }
const end = buffer.offset;
buffer.reset();
const keyword = latin1Decoder.decode(buffer.readBytes(end - buffer.offset - 1));
// NULL
buffer.skip(1);
validateKeyword(keyword);
return keyword;
}
function readLatin1(buffer, length) {
return latin1Decoder.decode(buffer.readBytes(length));
}
}),
"[project]/node_modules/fast-png/lib-esm/internalTypes.js [app-ssr] (ecmascript)", ((__turbopack_context__) => {
"use strict";
__turbopack_context__.s([
"BlendOpType",
()=>BlendOpType,
"ColorType",
()=>ColorType,
"CompressionMethod",
()=>CompressionMethod,
"DisposeOpType",
()=>DisposeOpType,
"FilterMethod",
()=>FilterMethod,
"InterlaceMethod",
()=>InterlaceMethod
]);
const ColorType = {
UNKNOWN: -1,
GREYSCALE: 0,
TRUECOLOUR: 2,
INDEXED_COLOUR: 3,
GREYSCALE_ALPHA: 4,
TRUECOLOUR_ALPHA: 6
};
const CompressionMethod = {
UNKNOWN: -1,
DEFLATE: 0
};
const FilterMethod = {
UNKNOWN: -1,
ADAPTIVE: 0
};
const InterlaceMethod = {
UNKNOWN: -1,
NO_INTERLACE: 0,
ADAM7: 1
};
const DisposeOpType = {
NONE: 0,
BACKGROUND: 1,
PREVIOUS: 2
};
const BlendOpType = {
SOURCE: 0,
OVER: 1
};
}),
"[project]/node_modules/fast-png/lib-esm/PngDecoder.js [app-ssr] (ecmascript)", ((__turbopack_context__) => {
"use strict";
__turbopack_context__.s([
"default",
()=>PngDecoder
]);
var __TURBOPACK__imported__module__$5b$project$5d2f$node_modules$2f$iobuffer$2f$lib$2d$esm$2f$IOBuffer$2e$js__$5b$app$2d$ssr$5d$__$28$ecmascript$29$__ = __turbopack_context__.i("[project]/node_modules/iobuffer/lib-esm/IOBuffer.js [app-ssr] (ecmascript)");
var __TURBOPACK__imported__module__$5b$project$5d2f$node_modules$2f$pako$2f$dist$2f$pako$2e$esm$2e$mjs__$5b$app$2d$ssr$5d$__$28$ecmascript$29$__ = __turbopack_context__.i("[project]/node_modules/pako/dist/pako.esm.mjs [app-ssr] (ecmascript)");
var __TURBOPACK__imported__module__$5b$project$5d2f$node_modules$2f$fast$2d$png$2f$lib$2d$esm$2f$helpers$2f$crc$2e$js__$5b$app$2d$ssr$5d$__$28$ecmascript$29$__ = __turbopack_context__.i("[project]/node_modules/fast-png/lib-esm/helpers/crc.js [app-ssr] (ecmascript)");
var __TURBOPACK__imported__module__$5b$project$5d2f$node_modules$2f$fast$2d$png$2f$lib$2d$esm$2f$helpers$2f$decodeInterlaceAdam7$2e$js__$5b$app$2d$ssr$5d$__$28$ecmascript$29$__ = __turbopack_context__.i("[project]/node_modules/fast-png/lib-esm/helpers/decodeInterlaceAdam7.js [app-ssr] (ecmascript)");
var __TURBOPACK__imported__module__$5b$project$5d2f$node_modules$2f$fast$2d$png$2f$lib$2d$esm$2f$helpers$2f$decodeInterlaceNull$2e$js__$5b$app$2d$ssr$5d$__$28$ecmascript$29$__ = __turbopack_context__.i("[project]/node_modules/fast-png/lib-esm/helpers/decodeInterlaceNull.js [app-ssr] (ecmascript)");
var __TURBOPACK__imported__module__$5b$project$5d2f$node_modules$2f$fast$2d$png$2f$lib$2d$esm$2f$helpers$2f$signature$2e$js__$5b$app$2d$ssr$5d$__$28$ecmascript$29$__ = __turbopack_context__.i("[project]/node_modules/fast-png/lib-esm/helpers/signature.js [app-ssr] (ecmascript)");
var __TURBOPACK__imported__module__$5b$project$5d2f$node_modules$2f$fast$2d$png$2f$lib$2d$esm$2f$helpers$2f$text$2e$js__$5b$app$2d$ssr$5d$__$28$ecmascript$29$__ = __turbopack_context__.i("[project]/node_modules/fast-png/lib-esm/helpers/text.js [app-ssr] (ecmascript)");
var __TURBOPACK__imported__module__$5b$project$5d2f$node_modules$2f$fast$2d$png$2f$lib$2d$esm$2f$internalTypes$2e$js__$5b$app$2d$ssr$5d$__$28$ecmascript$29$__ = __turbopack_context__.i("[project]/node_modules/fast-png/lib-esm/internalTypes.js [app-ssr] (ecmascript)");
;
;
;
;
;
;
;
;
class PngDecoder extends __TURBOPACK__imported__module__$5b$project$5d2f$node_modules$2f$iobuffer$2f$lib$2d$esm$2f$IOBuffer$2e$js__$5b$app$2d$ssr$5d$__$28$ecmascript$29$__["IOBuffer"] {
_checkCrc;
_inflator;
_png;
_apng;
_end;
_hasPalette;
_palette;
_hasTransparency;
_transparency;
_compressionMethod;
_filterMethod;
_interlaceMethod;
_colorType;
_isAnimated;
_numberOfFrames;
_numberOfPlays;
_frames;
_writingDataChunks;
constructor(data, options = {}){
super(data);
const { checkCrc = false } = options;
this._checkCrc = checkCrc;
this._inflator = new __TURBOPACK__imported__module__$5b$project$5d2f$node_modules$2f$pako$2f$dist$2f$pako$2e$esm$2e$mjs__$5b$app$2d$ssr$5d$__$28$ecmascript$29$__["Inflate"]();
this._png = {
width: -1,
height: -1,
channels: -1,
data: new Uint8Array(0),
depth: 1,
text: {}
};
this._apng = {
width: -1,
height: -1,
channels: -1,
depth: 1,
numberOfFrames: 1,
numberOfPlays: 0,
text: {},
frames: []
};
this._end = false;
this._hasPalette = false;
this._palette = [];
this._hasTransparency = false;
this._transparency = new Uint16Array(0);
this._compressionMethod = __TURBOPACK__imported__module__$5b$project$5d2f$node_modules$2f$fast$2d$png$2f$lib$2d$esm$2f$internalTypes$2e$js__$5b$app$2d$ssr$5d$__$28$ecmascript$29$__["CompressionMethod"].UNKNOWN;
this._filterMethod = __TURBOPACK__imported__module__$5b$project$5d2f$node_modules$2f$fast$2d$png$2f$lib$2d$esm$2f$internalTypes$2e$js__$5b$app$2d$ssr$5d$__$28$ecmascript$29$__["FilterMethod"].UNKNOWN;
this._interlaceMethod = __TURBOPACK__imported__module__$5b$project$5d2f$node_modules$2f$fast$2d$png$2f$lib$2d$esm$2f$internalTypes$2e$js__$5b$app$2d$ssr$5d$__$28$ecmascript$29$__["InterlaceMethod"].UNKNOWN;
this._colorType = __TURBOPACK__imported__module__$5b$project$5d2f$node_modules$2f$fast$2d$png$2f$lib$2d$esm$2f$internalTypes$2e$js__$5b$app$2d$ssr$5d$__$28$ecmascript$29$__["ColorType"].UNKNOWN;
this._isAnimated = false;
this._numberOfFrames = 1;
this._numberOfPlays = 0;
this._frames = [];
this._writingDataChunks = false;
// PNG is always big endian
// https://www.w3.org/TR/PNG/#7Integers-and-byte-order
this.setBigEndian();
}
decode() {
(0, __TURBOPACK__imported__module__$5b$project$5d2f$node_modules$2f$fast$2d$png$2f$lib$2d$esm$2f$helpers$2f$signature$2e$js__$5b$app$2d$ssr$5d$__$28$ecmascript$29$__["checkSignature"])(this);
while(!this._end){
const length = this.readUint32();
const type = this.readChars(4);
this.decodeChunk(length, type);
}
this.decodeImage();
return this._png;
}
decodeApng() {
(0, __TURBOPACK__imported__module__$5b$project$5d2f$node_modules$2f$fast$2d$png$2f$lib$2d$esm$2f$helpers$2f$signature$2e$js__$5b$app$2d$ssr$5d$__$28$ecmascript$29$__["checkSignature"])(this);
while(!this._end){
const length = this.readUint32();
const type = this.readChars(4);
this.decodeApngChunk(length, type);
}
this.decodeApngImage();
return this._apng;
}
// https://www.w3.org/TR/PNG/#5Chunk-layout
decodeChunk(length, type) {
const offset = this.offset;
switch(type){
// 11.2 Critical chunks
case 'IHDR':
this.decodeIHDR();
break;
case 'PLTE':
this.decodePLTE(length);
break;
case 'IDAT':
this.decodeIDAT(length);
break;
case 'IEND':
this._end = true;
break;
// 11.3 Ancillary chunks
case 'tRNS':
this.decodetRNS(length);
break;
case 'iCCP':
this.decodeiCCP(length);
break;
case __TURBOPACK__imported__module__$5b$project$5d2f$node_modules$2f$fast$2d$png$2f$lib$2d$esm$2f$helpers$2f$text$2e$js__$5b$app$2d$ssr$5d$__$28$ecmascript$29$__["textChunkName"]:
(0, __TURBOPACK__imported__module__$5b$project$5d2f$node_modules$2f$fast$2d$png$2f$lib$2d$esm$2f$helpers$2f$text$2e$js__$5b$app$2d$ssr$5d$__$28$ecmascript$29$__["decodetEXt"])(this._png.text, this, length);
break;
case 'pHYs':
this.decodepHYs();
break;
default:
this.skip(length);
break;
}
if (this.offset - offset !== length) {
throw new Error(`Length mismatch while decoding chunk ${type}`);
}
if (this._checkCrc) {
(0, __TURBOPACK__imported__module__$5b$project$5d2f$node_modules$2f$fast$2d$png$2f$lib$2d$esm$2f$helpers$2f$crc$2e$js__$5b$app$2d$ssr$5d$__$28$ecmascript$29$__["checkCrc"])(this, length + 4, type);
} else {
this.skip(4);
}
}
decodeApngChunk(length, type) {
const offset = this.offset;
if (type !== 'fdAT' && type !== 'IDAT' && this._writingDataChunks) {
this.pushDataToFrame();
}
switch(type){
case 'acTL':
this.decodeACTL();
break;
case 'fcTL':
this.decodeFCTL();
break;
case 'fdAT':
this.decodeFDAT(length);
break;
default:
this.decodeChunk(length, type);
this.offset = offset + length;
break;
}
if (this.offset - offset !== length) {
throw new Error(`Length mismatch while decoding chunk ${type}`);
}
if (this._checkCrc) {
(0, __TURBOPACK__imported__module__$5b$project$5d2f$node_modules$2f$fast$2d$png$2f$lib$2d$esm$2f$helpers$2f$crc$2e$js__$5b$app$2d$ssr$5d$__$28$ecmascript$29$__["checkCrc"])(this, length + 4, type);
} else {
this.skip(4);
}
}
// https://www.w3.org/TR/PNG/#11IHDR
decodeIHDR() {
const image = this._png;
image.width = this.readUint32();
image.height = this.readUint32();
image.depth = checkBitDepth(this.readUint8());
const colorType = this.readUint8();
this._colorType = colorType;
let channels;
switch(colorType){
case __TURBOPACK__imported__module__$5b$project$5d2f$node_modules$2f$fast$2d$png$2f$lib$2d$esm$2f$internalTypes$2e$js__$5b$app$2d$ssr$5d$__$28$ecmascript$29$__["ColorType"].GREYSCALE:
channels = 1;
break;
case __TURBOPACK__imported__module__$5b$project$5d2f$node_modules$2f$fast$2d$png$2f$lib$2d$esm$2f$internalTypes$2e$js__$5b$app$2d$ssr$5d$__$28$ecmascript$29$__["ColorType"].TRUECOLOUR:
channels = 3;
break;
case __TURBOPACK__imported__module__$5b$project$5d2f$node_modules$2f$fast$2d$png$2f$lib$2d$esm$2f$internalTypes$2e$js__$5b$app$2d$ssr$5d$__$28$ecmascript$29$__["ColorType"].INDEXED_COLOUR:
channels = 1;
break;
case __TURBOPACK__imported__module__$5b$project$5d2f$node_modules$2f$fast$2d$png$2f$lib$2d$esm$2f$internalTypes$2e$js__$5b$app$2d$ssr$5d$__$28$ecmascript$29$__["ColorType"].GREYSCALE_ALPHA:
channels = 2;
break;
case __TURBOPACK__imported__module__$5b$project$5d2f$node_modules$2f$fast$2d$png$2f$lib$2d$esm$2f$internalTypes$2e$js__$5b$app$2d$ssr$5d$__$28$ecmascript$29$__["ColorType"].TRUECOLOUR_ALPHA:
channels = 4;
break;
// Kept for exhaustiveness.
// eslint-disable-next-line unicorn/no-useless-switch-case
case __TURBOPACK__imported__module__$5b$project$5d2f$node_modules$2f$fast$2d$png$2f$lib$2d$esm$2f$internalTypes$2e$js__$5b$app$2d$ssr$5d$__$28$ecmascript$29$__["ColorType"].UNKNOWN:
default:
throw new Error(`Unknown color type: ${colorType}`);
}
this._png.channels = channels;
this._compressionMethod = this.readUint8();
if (this._compressionMethod !== __TURBOPACK__imported__module__$5b$project$5d2f$node_modules$2f$fast$2d$png$2f$lib$2d$esm$2f$internalTypes$2e$js__$5b$app$2d$ssr$5d$__$28$ecmascript$29$__["CompressionMethod"].DEFLATE) {
throw new Error(`Unsupported compression method: ${this._compressionMethod}`);
}
this._filterMethod = this.readUint8();
this._interlaceMethod = this.readUint8();
}
decodeACTL() {
this._numberOfFrames = this.readUint32();
this._numberOfPlays = this.readUint32();
this._isAnimated = true;
}
decodeFCTL() {
const image = {
sequenceNumber: this.readUint32(),
width: this.readUint32(),
height: this.readUint32(),
xOffset: this.readUint32(),
yOffset: this.readUint32(),
delayNumber: this.readUint16(),
delayDenominator: this.readUint16(),
disposeOp: this.readUint8(),
blendOp: this.readUint8(),
data: new Uint8Array(0)
};
this._frames.push(image);
}
// https://www.w3.org/TR/PNG/#11PLTE
decodePLTE(length) {
if (length % 3 !== 0) {
throw new RangeError(`PLTE field length must be a multiple of 3. Got ${length}`);
}
const l = length / 3;
this._hasPalette = true;
const palette = [];
this._palette = palette;
for(let i = 0; i < l; i++){
palette.push([
this.readUint8(),
this.readUint8(),
this.readUint8()
]);
}
}
// https://www.w3.org/TR/PNG/#11IDAT
decodeIDAT(length) {
this._writingDataChunks = true;
const dataLength = length;
const dataOffset = this.offset + this.byteOffset;
this._inflator.push(new Uint8Array(this.buffer, dataOffset, dataLength));
if (this._inflator.err) {
throw new Error(`Error while decompressing the data: ${this._inflator.err}`);
}
this.skip(length);
}
decodeFDAT(length) {
this._writingDataChunks = true;
let dataLength = length;
let dataOffset = this.offset + this.byteOffset;
dataOffset += 4;
dataLength -= 4;
this._inflator.push(new Uint8Array(this.buffer, dataOffset, dataLength));
if (this._inflator.err) {
throw new Error(`Error while decompressing the data: ${this._inflator.err}`);
}
this.skip(length);
}
// https://www.w3.org/TR/PNG/#11tRNS
decodetRNS(length) {
switch(this._colorType){
case __TURBOPACK__imported__module__$5b$project$5d2f$node_modules$2f$fast$2d$png$2f$lib$2d$esm$2f$internalTypes$2e$js__$5b$app$2d$ssr$5d$__$28$ecmascript$29$__["ColorType"].GREYSCALE:
case __TURBOPACK__imported__module__$5b$project$5d2f$node_modules$2f$fast$2d$png$2f$lib$2d$esm$2f$internalTypes$2e$js__$5b$app$2d$ssr$5d$__$28$ecmascript$29$__["ColorType"].TRUECOLOUR:
{
if (length % 2 !== 0) {
throw new RangeError(`tRNS chunk length must be a multiple of 2. Got ${length}`);
}
if (length / 2 > this._png.width * this._png.height) {
throw new Error(`tRNS chunk contains more alpha values than there are pixels (${length / 2} vs ${this._png.width * this._png.height})`);
}
this._hasTransparency = true;
this._transparency = new Uint16Array(length / 2);
for(let i = 0; i < length / 2; i++){
this._transparency[i] = this.readUint16();
}
break;
}
case __TURBOPACK__imported__module__$5b$project$5d2f$node_modules$2f$fast$2d$png$2f$lib$2d$esm$2f$internalTypes$2e$js__$5b$app$2d$ssr$5d$__$28$ecmascript$29$__["ColorType"].INDEXED_COLOUR:
{
if (length > this._palette.length) {
throw new Error(`tRNS chunk contains more alpha values than there are palette colors (${length} vs ${this._palette.length})`);
}
let i = 0;
for(; i < length; i++){
const alpha = this.readByte();
this._palette[i].push(alpha);
}
for(; i < this._palette.length; i++){
this._palette[i].push(255);
}
break;
}
// Kept for exhaustiveness.
/* eslint-disable unicorn/no-useless-switch-case */ case __TURBOPACK__imported__module__$5b$project$5d2f$node_modules$2f$fast$2d$png$2f$lib$2d$esm$2f$internalTypes$2e$js__$5b$app$2d$ssr$5d$__$28$ecmascript$29$__["ColorType"].UNKNOWN:
case __TURBOPACK__imported__module__$5b$project$5d2f$node_modules$2f$fast$2d$png$2f$lib$2d$esm$2f$internalTypes$2e$js__$5b$app$2d$ssr$5d$__$28$ecmascript$29$__["ColorType"].GREYSCALE_ALPHA:
case __TURBOPACK__imported__module__$5b$project$5d2f$node_modules$2f$fast$2d$png$2f$lib$2d$esm$2f$internalTypes$2e$js__$5b$app$2d$ssr$5d$__$28$ecmascript$29$__["ColorType"].TRUECOLOUR_ALPHA:
default:
{
throw new Error(`tRNS chunk is not supported for color type ${this._colorType}`);
}
}
}
// https://www.w3.org/TR/PNG/#11iCCP
decodeiCCP(length) {
const name = (0, __TURBOPACK__imported__module__$5b$project$5d2f$node_modules$2f$fast$2d$png$2f$lib$2d$esm$2f$helpers$2f$text$2e$js__$5b$app$2d$ssr$5d$__$28$ecmascript$29$__["readKeyword"])(this);
const compressionMethod = this.readUint8();
if (compressionMethod !== __TURBOPACK__imported__module__$5b$project$5d2f$node_modules$2f$fast$2d$png$2f$lib$2d$esm$2f$internalTypes$2e$js__$5b$app$2d$ssr$5d$__$28$ecmascript$29$__["CompressionMethod"].DEFLATE) {
throw new Error(`Unsupported iCCP compression method: ${compressionMethod}`);
}
const compressedProfile = this.readBytes(length - name.length - 2);
this._png.iccEmbeddedProfile = {
name,
profile: (0, __TURBOPACK__imported__module__$5b$project$5d2f$node_modules$2f$pako$2f$dist$2f$pako$2e$esm$2e$mjs__$5b$app$2d$ssr$5d$__$28$ecmascript$29$__["inflate"])(compressedProfile)
};
}
// https://www.w3.org/TR/PNG/#11pHYs
decodepHYs() {
const ppuX = this.readUint32();
const ppuY = this.readUint32();
const unitSpecifier = this.readByte();
this._png.resolution = {
x: ppuX,
y: ppuY,
unit: unitSpecifier
};
}
decodeApngImage() {
this._apng.width = this._png.width;
this._apng.height = this._png.height;
this._apng.channels = this._png.channels;
this._apng.depth = this._png.depth;
this._apng.numberOfFrames = this._numberOfFrames;
this._apng.numberOfPlays = this._numberOfPlays;
this._apng.text = this._png.text;
this._apng.resolution = this._png.resolution;
for(let i = 0; i < this._numberOfFrames; i++){
const newFrame = {
sequenceNumber: this._frames[i].sequenceNumber,
delayNumber: this._frames[i].delayNumber,
delayDenominator: this._frames[i].delayDenominator,
data: this._apng.depth === 8 ? new Uint8Array(this._apng.width * this._apng.height * this._apng.channels) : new Uint16Array(this._apng.width * this._apng.height * this._apng.channels)
};
const frame = this._frames.at(i);
if (frame) {
frame.data = (0, __TURBOPACK__imported__module__$5b$project$5d2f$node_modules$2f$fast$2d$png$2f$lib$2d$esm$2f$helpers$2f$decodeInterlaceNull$2e$js__$5b$app$2d$ssr$5d$__$28$ecmascript$29$__["decodeInterlaceNull"])({
data: frame.data,
width: frame.width,
height: frame.height,
channels: this._apng.channels,
depth: this._apng.depth
});
if (this._hasPalette) {
this._apng.palette = this._palette;
}
if (this._hasTransparency) {
this._apng.transparency = this._transparency;
}
if (i === 0 || frame.xOffset === 0 && frame.yOffset === 0 && frame.width === this._png.width && frame.height === this._png.height) {
newFrame.data = frame.data;
} else {
const prevFrame = this._apng.frames.at(i - 1);
this.disposeFrame(frame, prevFrame, newFrame);
this.addFrameDataToCanvas(newFrame, frame);
}
this._apng.frames.push(newFrame);
}
}
return this._apng;
}
disposeFrame(frame, prevFrame, imageFrame) {
switch(frame.disposeOp){
case __TURBOPACK__imported__module__$5b$project$5d2f$node_modules$2f$fast$2d$png$2f$lib$2d$esm$2f$internalTypes$2e$js__$5b$app$2d$ssr$5d$__$28$ecmascript$29$__["DisposeOpType"].NONE:
break;
case __TURBOPACK__imported__module__$5b$project$5d2f$node_modules$2f$fast$2d$png$2f$lib$2d$esm$2f$internalTypes$2e$js__$5b$app$2d$ssr$5d$__$28$ecmascript$29$__["DisposeOpType"].BACKGROUND:
for(let row = 0; row < this._png.height; row++){
for(let col = 0; col < this._png.width; col++){
const index = (row * frame.width + col) * this._png.channels;
for(let channel = 0; channel < this._png.channels; channel++){
imageFrame.data[index + channel] = 0;
}
}
}
break;
case __TURBOPACK__imported__module__$5b$project$5d2f$node_modules$2f$fast$2d$png$2f$lib$2d$esm$2f$internalTypes$2e$js__$5b$app$2d$ssr$5d$__$28$ecmascript$29$__["DisposeOpType"].PREVIOUS:
imageFrame.data.set(prevFrame.data);
break;
default:
throw new Error('Unknown disposeOp');
}
}
addFrameDataToCanvas(imageFrame, frame) {
const maxValue = 1 << this._png.depth;
const calculatePixelIndices = (row, col)=>{
const index = ((row + frame.yOffset) * this._png.width + frame.xOffset + col) * this._png.channels;
const frameIndex = (row * frame.width + col) * this._png.channels;
return {
index,
frameIndex
};
};
switch(frame.blendOp){
case __TURBOPACK__imported__module__$5b$project$5d2f$node_modules$2f$fast$2d$png$2f$lib$2d$esm$2f$internalTypes$2e$js__$5b$app$2d$ssr$5d$__$28$ecmascript$29$__["BlendOpType"].SOURCE:
for(let row = 0; row < frame.height; row++){
for(let col = 0; col < frame.width; col++){
const { index, frameIndex } = calculatePixelIndices(row, col);
for(let channel = 0; channel < this._png.channels; channel++){
imageFrame.data[index + channel] = frame.data[frameIndex + channel];
}
}
}
break;
// https://www.w3.org/TR/png-3/#13Alpha-channel-processing
case __TURBOPACK__imported__module__$5b$project$5d2f$node_modules$2f$fast$2d$png$2f$lib$2d$esm$2f$internalTypes$2e$js__$5b$app$2d$ssr$5d$__$28$ecmascript$29$__["BlendOpType"].OVER:
for(let row = 0; row < frame.height; row++){
for(let col = 0; col < frame.width; col++){
const { index, frameIndex } = calculatePixelIndices(row, col);
for(let channel = 0; channel < this._png.channels; channel++){
const sourceAlpha = frame.data[frameIndex + this._png.channels - 1] / maxValue;
const foregroundValue = channel % (this._png.channels - 1) === 0 ? 1 : frame.data[frameIndex + channel];
const value = Math.floor(sourceAlpha * foregroundValue + (1 - sourceAlpha) * imageFrame.data[index + channel]);
imageFrame.data[index + channel] += value;
}
}
}
break;
default:
throw new Error('Unknown blendOp');
}
}
decodeImage() {
if (this._inflator.err) {
throw new Error(`Error while decompressing the data: ${this._inflator.err}`);
}
const data = this._isAnimated ? (this._frames?.at(0)).data : this._inflator.result;
if (this._filterMethod !== __TURBOPACK__imported__module__$5b$project$5d2f$node_modules$2f$fast$2d$png$2f$lib$2d$esm$2f$internalTypes$2e$js__$5b$app$2d$ssr$5d$__$28$ecmascript$29$__["FilterMethod"].ADAPTIVE) {
throw new Error(`Filter method ${this._filterMethod} not supported`);
}
if (this._interlaceMethod === __TURBOPACK__imported__module__$5b$project$5d2f$node_modules$2f$fast$2d$png$2f$lib$2d$esm$2f$internalTypes$2e$js__$5b$app$2d$ssr$5d$__$28$ecmascript$29$__["InterlaceMethod"].NO_INTERLACE) {
this._png.data = (0, __TURBOPACK__imported__module__$5b$project$5d2f$node_modules$2f$fast$2d$png$2f$lib$2d$esm$2f$helpers$2f$decodeInterlaceNull$2e$js__$5b$app$2d$ssr$5d$__$28$ecmascript$29$__["decodeInterlaceNull"])({
data: data,
width: this._png.width,
height: this._png.height,
channels: this._png.channels,
depth: this._png.depth
});
} else if (this._interlaceMethod === __TURBOPACK__imported__module__$5b$project$5d2f$node_modules$2f$fast$2d$png$2f$lib$2d$esm$2f$internalTypes$2e$js__$5b$app$2d$ssr$5d$__$28$ecmascript$29$__["InterlaceMethod"].ADAM7) {
this._png.data = (0, __TURBOPACK__imported__module__$5b$project$5d2f$node_modules$2f$fast$2d$png$2f$lib$2d$esm$2f$helpers$2f$decodeInterlaceAdam7$2e$js__$5b$app$2d$ssr$5d$__$28$ecmascript$29$__["decodeInterlaceAdam7"])({
data: data,
width: this._png.width,
height: this._png.height,
channels: this._png.channels,
depth: this._png.depth
});
} else {
throw new Error(`Interlace method ${this._interlaceMethod} not supported`);
}
if (this._hasPalette) {
this._png.palette = this._palette;
}
if (this._hasTransparency) {
this._png.transparency = this._transparency;
}
}
pushDataToFrame() {
const result = this._inflator.result;
const lastFrame = this._frames.at(-1);
if (lastFrame) {
lastFrame.data = result;
} else {
this._frames.push({
sequenceNumber: 0,
width: this._png.width,
height: this._png.height,
xOffset: 0,
yOffset: 0,
delayNumber: 0,
delayDenominator: 0,
disposeOp: __TURBOPACK__imported__module__$5b$project$5d2f$node_modules$2f$fast$2d$png$2f$lib$2d$esm$2f$internalTypes$2e$js__$5b$app$2d$ssr$5d$__$28$ecmascript$29$__["DisposeOpType"].NONE,
blendOp: __TURBOPACK__imported__module__$5b$project$5d2f$node_modules$2f$fast$2d$png$2f$lib$2d$esm$2f$internalTypes$2e$js__$5b$app$2d$ssr$5d$__$28$ecmascript$29$__["BlendOpType"].SOURCE,
data: result
});
}
this._inflator = new __TURBOPACK__imported__module__$5b$project$5d2f$node_modules$2f$pako$2f$dist$2f$pako$2e$esm$2e$mjs__$5b$app$2d$ssr$5d$__$28$ecmascript$29$__["Inflate"]();
this._writingDataChunks = false;
}
}
function checkBitDepth(value) {
if (value !== 1 && value !== 2 && value !== 4 && value !== 8 && value !== 16) {
throw new Error(`invalid bit depth: ${value}`);
}
return value;
}
}),
"[project]/node_modules/fast-png/lib-esm/PngEncoder.js [app-ssr] (ecmascript)", ((__turbopack_context__) => {
"use strict";
__turbopack_context__.s([
"default",
()=>PngEncoder
]);
var __TURBOPACK__imported__module__$5b$project$5d2f$node_modules$2f$iobuffer$2f$lib$2d$esm$2f$IOBuffer$2e$js__$5b$app$2d$ssr$5d$__$28$ecmascript$29$__ = __turbopack_context__.i("[project]/node_modules/iobuffer/lib-esm/IOBuffer.js [app-ssr] (ecmascript)");
var __TURBOPACK__imported__module__$5b$project$5d2f$node_modules$2f$pako$2f$dist$2f$pako$2e$esm$2e$mjs__$5b$app$2d$ssr$5d$__$28$ecmascript$29$__ = __turbopack_context__.i("[project]/node_modules/pako/dist/pako.esm.mjs [app-ssr] (ecmascript)");
var __TURBOPACK__imported__module__$5b$project$5d2f$node_modules$2f$fast$2d$png$2f$lib$2d$esm$2f$helpers$2f$crc$2e$js__$5b$app$2d$ssr$5d$__$28$ecmascript$29$__ = __turbopack_context__.i("[project]/node_modules/fast-png/lib-esm/helpers/crc.js [app-ssr] (ecmascript)");
var __TURBOPACK__imported__module__$5b$project$5d2f$node_modules$2f$fast$2d$png$2f$lib$2d$esm$2f$helpers$2f$signature$2e$js__$5b$app$2d$ssr$5d$__$28$ecmascript$29$__ = __turbopack_context__.i("[project]/node_modules/fast-png/lib-esm/helpers/signature.js [app-ssr] (ecmascript)");
var __TURBOPACK__imported__module__$5b$project$5d2f$node_modules$2f$fast$2d$png$2f$lib$2d$esm$2f$helpers$2f$text$2e$js__$5b$app$2d$ssr$5d$__$28$ecmascript$29$__ = __turbopack_context__.i("[project]/node_modules/fast-png/lib-esm/helpers/text.js [app-ssr] (ecmascript)");
var __TURBOPACK__imported__module__$5b$project$5d2f$node_modules$2f$fast$2d$png$2f$lib$2d$esm$2f$internalTypes$2e$js__$5b$app$2d$ssr$5d$__$28$ecmascript$29$__ = __turbopack_context__.i("[project]/node_modules/fast-png/lib-esm/internalTypes.js [app-ssr] (ecmascript)");
;
;
;
;
;
;
const defaultZlibOptions = {
level: 3
};
class PngEncoder extends __TURBOPACK__imported__module__$5b$project$5d2f$node_modules$2f$iobuffer$2f$lib$2d$esm$2f$IOBuffer$2e$js__$5b$app$2d$ssr$5d$__$28$ecmascript$29$__["IOBuffer"] {
_png;
_zlibOptions;
_colorType;
_interlaceMethod;
constructor(data, options = {}){
super();
this._colorType = __TURBOPACK__imported__module__$5b$project$5d2f$node_modules$2f$fast$2d$png$2f$lib$2d$esm$2f$internalTypes$2e$js__$5b$app$2d$ssr$5d$__$28$ecmascript$29$__["ColorType"].UNKNOWN;
this._zlibOptions = {
...defaultZlibOptions,
...options.zlib
};
this._png = this._checkData(data);
this._interlaceMethod = (options.interlace === 'Adam7' ? __TURBOPACK__imported__module__$5b$project$5d2f$node_modules$2f$fast$2d$png$2f$lib$2d$esm$2f$internalTypes$2e$js__$5b$app$2d$ssr$5d$__$28$ecmascript$29$__["InterlaceMethod"].ADAM7 : __TURBOPACK__imported__module__$5b$project$5d2f$node_modules$2f$fast$2d$png$2f$lib$2d$esm$2f$internalTypes$2e$js__$5b$app$2d$ssr$5d$__$28$ecmascript$29$__["InterlaceMethod"].NO_INTERLACE) ?? __TURBOPACK__imported__module__$5b$project$5d2f$node_modules$2f$fast$2d$png$2f$lib$2d$esm$2f$internalTypes$2e$js__$5b$app$2d$ssr$5d$__$28$ecmascript$29$__["InterlaceMethod"].NO_INTERLACE;
this.setBigEndian();
}
encode() {
(0, __TURBOPACK__imported__module__$5b$project$5d2f$node_modules$2f$fast$2d$png$2f$lib$2d$esm$2f$helpers$2f$signature$2e$js__$5b$app$2d$ssr$5d$__$28$ecmascript$29$__["writeSignature"])(this);
this.encodeIHDR();
if (this._png.palette) {
this.encodePLTE();
if (this._png.palette[0].length === 4) {
this.encodeTRNS();
}
}
this.encodeData();
if (this._png.text) {
for (const [keyword, text] of Object.entries(this._png.text)){
(0, __TURBOPACK__imported__module__$5b$project$5d2f$node_modules$2f$fast$2d$png$2f$lib$2d$esm$2f$helpers$2f$text$2e$js__$5b$app$2d$ssr$5d$__$28$ecmascript$29$__["encodetEXt"])(this, keyword, text);
}
}
this.encodeIEND();
return this.toArray();
}
// https://www.w3.org/TR/PNG/#11IHDR
encodeIHDR() {
this.writeUint32(13);
this.writeChars('IHDR');
this.writeUint32(this._png.width);
this.writeUint32(this._png.height);
this.writeByte(this._png.depth);
this.writeByte(this._colorType);
this.writeByte(__TURBOPACK__imported__module__$5b$project$5d2f$node_modules$2f$fast$2d$png$2f$lib$2d$esm$2f$internalTypes$2e$js__$5b$app$2d$ssr$5d$__$28$ecmascript$29$__["CompressionMethod"].DEFLATE);
this.writeByte(__TURBOPACK__imported__module__$5b$project$5d2f$node_modules$2f$fast$2d$png$2f$lib$2d$esm$2f$internalTypes$2e$js__$5b$app$2d$ssr$5d$__$28$ecmascript$29$__["FilterMethod"].ADAPTIVE);
this.writeByte(this._interlaceMethod);
(0, __TURBOPACK__imported__module__$5b$project$5d2f$node_modules$2f$fast$2d$png$2f$lib$2d$esm$2f$helpers$2f$crc$2e$js__$5b$app$2d$ssr$5d$__$28$ecmascript$29$__["writeCrc"])(this, 17);
}
// https://www.w3.org/TR/PNG/#11IEND
encodeIEND() {
this.writeUint32(0);
this.writeChars('IEND');
(0, __TURBOPACK__imported__module__$5b$project$5d2f$node_modules$2f$fast$2d$png$2f$lib$2d$esm$2f$helpers$2f$crc$2e$js__$5b$app$2d$ssr$5d$__$28$ecmascript$29$__["writeCrc"])(this, 4);
}
encodePLTE() {
const paletteLength = this._png.palette?.length * 3;
this.writeUint32(paletteLength);
this.writeChars('PLTE');
for (const color of this._png.palette){
this.writeByte(color[0]);
this.writeByte(color[1]);
this.writeByte(color[2]);
}
(0, __TURBOPACK__imported__module__$5b$project$5d2f$node_modules$2f$fast$2d$png$2f$lib$2d$esm$2f$helpers$2f$crc$2e$js__$5b$app$2d$ssr$5d$__$28$ecmascript$29$__["writeCrc"])(this, 4 + paletteLength);
}
encodeTRNS() {
const alpha = this._png.palette.filter((color)=>{
return color.at(-1) !== 255;
});
this.writeUint32(alpha.length);
this.writeChars('tRNS');
for (const el of alpha){
this.writeByte(el.at(-1));
}
(0, __TURBOPACK__imported__module__$5b$project$5d2f$node_modules$2f$fast$2d$png$2f$lib$2d$esm$2f$helpers$2f$crc$2e$js__$5b$app$2d$ssr$5d$__$28$ecmascript$29$__["writeCrc"])(this, 4 + alpha.length);
}
// https://www.w3.org/TR/PNG/#11IDAT
encodeIDAT(data) {
this.writeUint32(data.length);
this.writeChars('IDAT');
this.writeBytes(data);
(0, __TURBOPACK__imported__module__$5b$project$5d2f$node_modules$2f$fast$2d$png$2f$lib$2d$esm$2f$helpers$2f$crc$2e$js__$5b$app$2d$ssr$5d$__$28$ecmascript$29$__["writeCrc"])(this, data.length + 4);
}
encodeData() {
const { width, height, channels, depth, data } = this._png;
const slotsPerLine = depth <= 8 ? Math.ceil(width * depth / 8) * channels : Math.ceil(width * depth / 8 * channels / 2);
const newData = new __TURBOPACK__imported__module__$5b$project$5d2f$node_modules$2f$iobuffer$2f$lib$2d$esm$2f$IOBuffer$2e$js__$5b$app$2d$ssr$5d$__$28$ecmascript$29$__["IOBuffer"]().setBigEndian();
let offset = 0;
if (this._interlaceMethod === __TURBOPACK__imported__module__$5b$project$5d2f$node_modules$2f$fast$2d$png$2f$lib$2d$esm$2f$internalTypes$2e$js__$5b$app$2d$ssr$5d$__$28$ecmascript$29$__["InterlaceMethod"].NO_INTERLACE) {
for(let i = 0; i < height; i++){
newData.writeByte(0); // no filter
if (depth === 16) {
offset = writeDataUint16(data, newData, slotsPerLine, offset);
} else {
offset = writeDataBytes(data, newData, slotsPerLine, offset);
}
}
} else if (this._interlaceMethod === __TURBOPACK__imported__module__$5b$project$5d2f$node_modules$2f$fast$2d$png$2f$lib$2d$esm$2f$internalTypes$2e$js__$5b$app$2d$ssr$5d$__$28$ecmascript$29$__["InterlaceMethod"].ADAM7) {
// Adam7 interlacing
offset = writeDataInterlaced(this._png, data, newData, offset);
}
const buffer = newData.toArray();
const compressed = (0, __TURBOPACK__imported__module__$5b$project$5d2f$node_modules$2f$pako$2f$dist$2f$pako$2e$esm$2e$mjs__$5b$app$2d$ssr$5d$__$28$ecmascript$29$__["deflate"])(buffer, this._zlibOptions);
this.encodeIDAT(compressed);
}
_checkData(data) {
const { colorType, channels, depth } = getColorType(data, data.palette);
const png = {
width: checkInteger(data.width, 'width'),
height: checkInteger(data.height, 'height'),
channels,
data: data.data,
depth,
text: data.text,
palette: data.palette
};
this._colorType = colorType;
const expectedSize = depth < 8 ? Math.ceil(png.width * depth / 8) * png.height * channels : png.width * png.height * channels;
if (png.data.length !== expectedSize) {
throw new RangeError(`wrong data size. Found ${png.data.length}, expected ${expectedSize}`);
}
return png;
}
}
function checkInteger(value, name) {
if (Number.isInteger(value) && value > 0) {
return value;
}
throw new TypeError(`${name} must be a positive integer`);
}
function getColorType(data, palette) {
const { channels = 4, depth = 8 } = data;
if (channels !== 4 && channels !== 3 && channels !== 2 && channels !== 1) {
throw new RangeError(`unsupported number of channels: ${channels}`);
}
const returnValue = {
channels,
depth,
colorType: __TURBOPACK__imported__module__$5b$project$5d2f$node_modules$2f$fast$2d$png$2f$lib$2d$esm$2f$internalTypes$2e$js__$5b$app$2d$ssr$5d$__$28$ecmascript$29$__["ColorType"].UNKNOWN
};
switch(channels){
case 4:
returnValue.colorType = __TURBOPACK__imported__module__$5b$project$5d2f$node_modules$2f$fast$2d$png$2f$lib$2d$esm$2f$internalTypes$2e$js__$5b$app$2d$ssr$5d$__$28$ecmascript$29$__["ColorType"].TRUECOLOUR_ALPHA;
break;
case 3:
returnValue.colorType = __TURBOPACK__imported__module__$5b$project$5d2f$node_modules$2f$fast$2d$png$2f$lib$2d$esm$2f$internalTypes$2e$js__$5b$app$2d$ssr$5d$__$28$ecmascript$29$__["ColorType"].TRUECOLOUR;
break;
case 1:
if (palette) {
returnValue.colorType = __TURBOPACK__imported__module__$5b$project$5d2f$node_modules$2f$fast$2d$png$2f$lib$2d$esm$2f$internalTypes$2e$js__$5b$app$2d$ssr$5d$__$28$ecmascript$29$__["ColorType"].INDEXED_COLOUR;
} else {
returnValue.colorType = __TURBOPACK__imported__module__$5b$project$5d2f$node_modules$2f$fast$2d$png$2f$lib$2d$esm$2f$internalTypes$2e$js__$5b$app$2d$ssr$5d$__$28$ecmascript$29$__["ColorType"].GREYSCALE;
}
break;
case 2:
returnValue.colorType = __TURBOPACK__imported__module__$5b$project$5d2f$node_modules$2f$fast$2d$png$2f$lib$2d$esm$2f$internalTypes$2e$js__$5b$app$2d$ssr$5d$__$28$ecmascript$29$__["ColorType"].GREYSCALE_ALPHA;
break;
default:
throw new Error('unsupported number of channels');
}
return returnValue;
}
function writeDataBytes(data, newData, slotsPerLine, offset) {
for(let j = 0; j < slotsPerLine; j++){
newData.writeByte(data[offset++]);
}
return offset;
}
function writeDataInterlaced(imageData, data, newData, offset) {
const passes = [
{
x: 0,
y: 0,
xStep: 8,
yStep: 8
},
{
x: 4,
y: 0,
xStep: 8,
yStep: 8
},
{
x: 0,
y: 4,
xStep: 4,
yStep: 8
},
{
x: 2,
y: 0,
xStep: 4,
yStep: 4
},
{
x: 0,
y: 2,
xStep: 2,
yStep: 4
},
{
x: 1,
y: 0,
xStep: 2,
yStep: 2
},
{
x: 0,
y: 1,
xStep: 1,
yStep: 2
}
];
const { width, height, channels, depth } = imageData;
let pixelSize = 0;
if (depth === 16) {
pixelSize = channels * depth / 8 / 2;
} else {
pixelSize = channels * depth / 8;
}
// Process each pass
for(let passIndex = 0; passIndex < 7; passIndex++){
const pass = passes[passIndex];
const passWidth = Math.floor((width - pass.x + pass.xStep - 1) / pass.xStep);
const passHeight = Math.floor((height - pass.y + pass.yStep - 1) / pass.yStep);
if (passWidth <= 0 || passHeight <= 0) continue;
const passLineBytes = passWidth * pixelSize;
// For each scanline in this pass
for(let y = 0; y < passHeight; y++){
const imageY = pass.y + y * pass.yStep;
// Extract raw scanline data
const rawScanline = depth <= 8 ? new Uint8Array(passLineBytes) : new Uint16Array(passLineBytes);
let rawOffset = 0;
for(let x = 0; x < passWidth; x++){
const imageX = pass.x + x * pass.xStep;
if (imageX < width && imageY < height) {
const srcPos = (imageY * width + imageX) * pixelSize;
for(let i = 0; i < pixelSize; i++){
rawScanline[rawOffset++] = data[srcPos + i];
}
}
}
newData.writeByte(0); // no filter
if (depth === 8) {
newData.writeBytes(rawScanline);
} else if (depth === 16) {
for (const value of rawScanline){
newData.writeByte(value >> 8 & 0xff); // High byte
newData.writeByte(value & 0xff);
}
}
}
}
return offset;
}
function writeDataUint16(data, newData, slotsPerLine, offset) {
for(let j = 0; j < slotsPerLine; j++){
newData.writeUint16(data[offset++]);
}
return offset;
}
}),
"[project]/node_modules/fast-png/lib-esm/types.js [app-ssr] (ecmascript)", ((__turbopack_context__) => {
"use strict";
__turbopack_context__.s([
"ResolutionUnitSpecifier",
()=>ResolutionUnitSpecifier
]);
var ResolutionUnitSpecifier;
(function(ResolutionUnitSpecifier) {
/**
* Unit is unknown
*/ ResolutionUnitSpecifier[ResolutionUnitSpecifier["UNKNOWN"] = 0] = "UNKNOWN";
/**
* Unit is the metre
*/ ResolutionUnitSpecifier[ResolutionUnitSpecifier["METRE"] = 1] = "METRE";
})(ResolutionUnitSpecifier || (ResolutionUnitSpecifier = {}));
}),
"[project]/node_modules/fast-png/lib-esm/index.js [app-ssr] (ecmascript) <locals>", ((__turbopack_context__) => {
"use strict";
__turbopack_context__.s([
"decode",
()=>decodePng,
"decodeApng",
()=>decodeApng,
"encode",
()=>encodePng
]);
var __TURBOPACK__imported__module__$5b$project$5d2f$node_modules$2f$fast$2d$png$2f$lib$2d$esm$2f$PngDecoder$2e$js__$5b$app$2d$ssr$5d$__$28$ecmascript$29$__ = __turbopack_context__.i("[project]/node_modules/fast-png/lib-esm/PngDecoder.js [app-ssr] (ecmascript)");
var __TURBOPACK__imported__module__$5b$project$5d2f$node_modules$2f$fast$2d$png$2f$lib$2d$esm$2f$PngEncoder$2e$js__$5b$app$2d$ssr$5d$__$28$ecmascript$29$__ = __turbopack_context__.i("[project]/node_modules/fast-png/lib-esm/PngEncoder.js [app-ssr] (ecmascript)");
var __TURBOPACK__imported__module__$5b$project$5d2f$node_modules$2f$fast$2d$png$2f$lib$2d$esm$2f$helpers$2f$signature$2e$js__$5b$app$2d$ssr$5d$__$28$ecmascript$29$__ = __turbopack_context__.i("[project]/node_modules/fast-png/lib-esm/helpers/signature.js [app-ssr] (ecmascript)");
var __TURBOPACK__imported__module__$5b$project$5d2f$node_modules$2f$fast$2d$png$2f$lib$2d$esm$2f$types$2e$js__$5b$app$2d$ssr$5d$__$28$ecmascript$29$__ = __turbopack_context__.i("[project]/node_modules/fast-png/lib-esm/types.js [app-ssr] (ecmascript)");
;
;
;
;
function decodePng(data, options) {
const decoder = new __TURBOPACK__imported__module__$5b$project$5d2f$node_modules$2f$fast$2d$png$2f$lib$2d$esm$2f$PngDecoder$2e$js__$5b$app$2d$ssr$5d$__$28$ecmascript$29$__["default"](data, options);
return decoder.decode();
}
function encodePng(png, options) {
const encoder = new __TURBOPACK__imported__module__$5b$project$5d2f$node_modules$2f$fast$2d$png$2f$lib$2d$esm$2f$PngEncoder$2e$js__$5b$app$2d$ssr$5d$__$28$ecmascript$29$__["default"](png, options);
return encoder.encode();
}
function decodeApng(data, options) {
const decoder = new __TURBOPACK__imported__module__$5b$project$5d2f$node_modules$2f$fast$2d$png$2f$lib$2d$esm$2f$PngDecoder$2e$js__$5b$app$2d$ssr$5d$__$28$ecmascript$29$__["default"](data, options);
return decoder.decodeApng();
}
;
;
}),
"[project]/node_modules/fast-png/lib-esm/convertIndexedToRgb.js [app-ssr] (ecmascript)", ((__turbopack_context__) => {
"use strict";
/**
* Converts indexed data into RGB/RGBA format
* @param decodedImage - Image to decode data from.
* @returns Uint8Array with RGB data.
*/ __turbopack_context__.s([
"convertIndexedToRgb",
()=>convertIndexedToRgb
]);
function convertIndexedToRgb(decodedImage) {
const palette = decodedImage.palette;
const depth = decodedImage.depth;
if (!palette) {
throw new Error('Color palette is undefined.');
}
checkDataSize(decodedImage);
const indexSize = decodedImage.width * decodedImage.height;
const resSize = indexSize * palette[0].length;
const res = new Uint8Array(resSize);
let indexPos = 0;
let offset = 0;
const indexes = new Uint8Array(indexSize);
let bit = 0xff;
switch(depth){
case 1:
bit = 0x80;
break;
case 2:
bit = 0xc0;
break;
case 4:
bit = 0xf0;
break;
case 8:
bit = 0xff;
break;
default:
throw new Error('Incorrect depth value');
}
for (const byte of decodedImage.data){
let bit2 = bit;
let shift = 8;
while(bit2){
shift -= depth;
indexes[indexPos++] = (byte & bit2) >> shift;
bit2 = bit2 >> depth;
if (indexPos % decodedImage.width === 0) {
break;
}
}
}
if (decodedImage.palette) {
for (const index of indexes){
const color = decodedImage.palette.at(index);
if (!color) {
throw new Error('Incorrect index of palette color');
}
res.set(color, offset);
offset += color.length;
}
}
return res;
}
function checkDataSize(image) {
const expectedSize = image.depth < 8 ? Math.ceil(image.width * image.depth / 8) * image.height * image.channels : image.width * image.height * image.channels;
if (image.data.length !== expectedSize) {
throw new RangeError(`wrong data size. Found ${image.data.length}, expected ${expectedSize}`);
}
}
}),
"[project]/node_modules/fast-png/lib-esm/index.js [app-ssr] (ecmascript)", ((__turbopack_context__) => {
"use strict";
__turbopack_context__.s([
"ResolutionUnitSpecifier",
()=>__TURBOPACK__imported__module__$5b$project$5d2f$node_modules$2f$fast$2d$png$2f$lib$2d$esm$2f$types$2e$js__$5b$app$2d$ssr$5d$__$28$ecmascript$29$__["ResolutionUnitSpecifier"],
"convertIndexedToRgb",
()=>__TURBOPACK__imported__module__$5b$project$5d2f$node_modules$2f$fast$2d$png$2f$lib$2d$esm$2f$convertIndexedToRgb$2e$js__$5b$app$2d$ssr$5d$__$28$ecmascript$29$__["convertIndexedToRgb"],
"decode",
()=>__TURBOPACK__imported__module__$5b$project$5d2f$node_modules$2f$fast$2d$png$2f$lib$2d$esm$2f$index$2e$js__$5b$app$2d$ssr$5d$__$28$ecmascript$29$__$3c$locals$3e$__["decode"],
"decodeApng",
()=>__TURBOPACK__imported__module__$5b$project$5d2f$node_modules$2f$fast$2d$png$2f$lib$2d$esm$2f$index$2e$js__$5b$app$2d$ssr$5d$__$28$ecmascript$29$__$3c$locals$3e$__["decodeApng"],
"encode",
()=>__TURBOPACK__imported__module__$5b$project$5d2f$node_modules$2f$fast$2d$png$2f$lib$2d$esm$2f$index$2e$js__$5b$app$2d$ssr$5d$__$28$ecmascript$29$__$3c$locals$3e$__["encode"],
"hasPngSignature",
()=>__TURBOPACK__imported__module__$5b$project$5d2f$node_modules$2f$fast$2d$png$2f$lib$2d$esm$2f$helpers$2f$signature$2e$js__$5b$app$2d$ssr$5d$__$28$ecmascript$29$__["hasPngSignature"]
]);
var __TURBOPACK__imported__module__$5b$project$5d2f$node_modules$2f$fast$2d$png$2f$lib$2d$esm$2f$index$2e$js__$5b$app$2d$ssr$5d$__$28$ecmascript$29$__$3c$locals$3e$__ = __turbopack_context__.i("[project]/node_modules/fast-png/lib-esm/index.js [app-ssr] (ecmascript) <locals>");
var __TURBOPACK__imported__module__$5b$project$5d2f$node_modules$2f$fast$2d$png$2f$lib$2d$esm$2f$helpers$2f$signature$2e$js__$5b$app$2d$ssr$5d$__$28$ecmascript$29$__ = __turbopack_context__.i("[project]/node_modules/fast-png/lib-esm/helpers/signature.js [app-ssr] (ecmascript)");
var __TURBOPACK__imported__module__$5b$project$5d2f$node_modules$2f$fast$2d$png$2f$lib$2d$esm$2f$types$2e$js__$5b$app$2d$ssr$5d$__$28$ecmascript$29$__ = __turbopack_context__.i("[project]/node_modules/fast-png/lib-esm/types.js [app-ssr] (ecmascript)");
var __TURBOPACK__imported__module__$5b$project$5d2f$node_modules$2f$fast$2d$png$2f$lib$2d$esm$2f$convertIndexedToRgb$2e$js__$5b$app$2d$ssr$5d$__$28$ecmascript$29$__ = __turbopack_context__.i("[project]/node_modules/fast-png/lib-esm/convertIndexedToRgb.js [app-ssr] (ecmascript)");
}),
"[project]/node_modules/jspdf-autotable/dist/jspdf.plugin.autotable.mjs [app-ssr] (ecmascript)", ((__turbopack_context__) => {
"use strict";
__turbopack_context__.s([
"Cell",
()=>Cell,
"CellHookData",
()=>CellHookData,
"Column",
()=>Column,
"HookData",
()=>HookData,
"Row",
()=>Row,
"Table",
()=>Table,
"__createTable",
()=>__createTable,
"__drawTable",
()=>__drawTable,
"applyPlugin",
()=>applyPlugin,
"autoTable",
()=>autoTable,
"default",
()=>autoTable
]);
/**
* Improved text function with halign and valign support
* Inspiration from: http://stackoverflow.com/questions/28327510/align-text-right-using-jspdf/28433113#28433113
*/ function autoTableText(text, x, y, styles, doc) {
styles = styles || {};
var PHYSICAL_LINE_HEIGHT = 1.15;
var k = doc.internal.scaleFactor;
var fontSize = doc.internal.getFontSize() / k;
var lineHeightFactor = doc.getLineHeightFactor ? doc.getLineHeightFactor() : PHYSICAL_LINE_HEIGHT;
var lineHeight = fontSize * lineHeightFactor;
var splitRegex = /\r\n|\r|\n/g;
var splitText = '';
var lineCount = 1;
if (styles.valign === 'middle' || styles.valign === 'bottom' || styles.halign === 'center' || styles.halign === 'right') {
splitText = typeof text === 'string' ? text.split(splitRegex) : text;
lineCount = splitText.length || 1;
}
// Align the top
y += fontSize * (2 - PHYSICAL_LINE_HEIGHT);
if (styles.valign === 'middle') y -= lineCount / 2 * lineHeight;
else if (styles.valign === 'bottom') y -= lineCount * lineHeight;
if (styles.halign === 'center' || styles.halign === 'right') {
var alignSize = fontSize;
if (styles.halign === 'center') alignSize *= 0.5;
if (splitText && lineCount >= 1) {
for(var iLine = 0; iLine < splitText.length; iLine++){
doc.text(splitText[iLine], x - doc.getStringUnitWidth(splitText[iLine]) * alignSize, y);
y += lineHeight;
}
return doc;
}
x -= doc.getStringUnitWidth(text) * alignSize;
}
if (styles.halign === 'justify') {
doc.text(text, x, y, {
maxWidth: styles.maxWidth || 100,
align: 'justify'
});
} else {
doc.text(text, x, y);
}
return doc;
}
var globalDefaults = {};
var DocHandler = function() {
function DocHandler(jsPDFDocument) {
this.jsPDFDocument = jsPDFDocument;
this.userStyles = {
// Black for versions of jspdf without getTextColor
textColor: jsPDFDocument.getTextColor ? this.jsPDFDocument.getTextColor() : 0,
fontSize: jsPDFDocument.internal.getFontSize(),
fontStyle: jsPDFDocument.internal.getFont().fontStyle,
font: jsPDFDocument.internal.getFont().fontName,
// 0 for versions of jspdf without getLineWidth
lineWidth: jsPDFDocument.getLineWidth ? this.jsPDFDocument.getLineWidth() : 0,
// Black for versions of jspdf without getDrawColor
lineColor: jsPDFDocument.getDrawColor ? this.jsPDFDocument.getDrawColor() : 0
};
}
DocHandler.setDefaults = function(defaults, doc) {
if (doc === void 0) {
doc = null;
}
if (doc) {
doc.__autoTableDocumentDefaults = defaults;
} else {
globalDefaults = defaults;
}
};
DocHandler.unifyColor = function(c) {
if (Array.isArray(c)) {
return c;
} else if (typeof c === 'number') {
return [
c,
c,
c
];
} else if (typeof c === 'string') {
return [
c
];
} else {
return null;
}
};
DocHandler.prototype.applyStyles = function(styles, fontOnly) {
// Font style needs to be applied before font
// https://github.com/simonbengtsson/jsPDF-AutoTable/issues/632
var _a, _b, _c;
if (fontOnly === void 0) {
fontOnly = false;
}
if (styles.fontStyle && this.jsPDFDocument.setFontStyle) {
this.jsPDFDocument.setFontStyle(styles.fontStyle);
}
var _d = this.jsPDFDocument.internal.getFont(), fontStyle = _d.fontStyle, fontName = _d.fontName;
if (styles.font) fontName = styles.font;
if (styles.fontStyle) {
fontStyle = styles.fontStyle;
var availableFontStyles = this.getFontList()[fontName];
if (availableFontStyles && availableFontStyles.indexOf(fontStyle) === -1 && this.jsPDFDocument.setFontStyle) {
// Common issue was that the default bold in headers
// made custom fonts not work. For example:
// https://github.com/simonbengtsson/jsPDF-AutoTable/issues/653
this.jsPDFDocument.setFontStyle(availableFontStyles[0]);
fontStyle = availableFontStyles[0];
}
}
this.jsPDFDocument.setFont(fontName, fontStyle);
if (styles.fontSize) this.jsPDFDocument.setFontSize(styles.fontSize);
if (fontOnly) {
return; // Performance improvement
}
var color = DocHandler.unifyColor(styles.fillColor);
if (color) (_a = this.jsPDFDocument).setFillColor.apply(_a, color);
color = DocHandler.unifyColor(styles.textColor);
if (color) (_b = this.jsPDFDocument).setTextColor.apply(_b, color);
color = DocHandler.unifyColor(styles.lineColor);
if (color) (_c = this.jsPDFDocument).setDrawColor.apply(_c, color);
if (typeof styles.lineWidth === 'number') {
this.jsPDFDocument.setLineWidth(styles.lineWidth);
}
};
DocHandler.prototype.splitTextToSize = function(text, size, opts) {
return this.jsPDFDocument.splitTextToSize(text, size, opts);
};
/**
* Adds a rectangle to the PDF
* @param x Coordinate (in units declared at inception of PDF document) against left edge of the page
* @param y Coordinate (in units declared at inception of PDF document) against upper edge of the page
* @param width Width (in units declared at inception of PDF document)
* @param height Height (in units declared at inception of PDF document)
* @param fillStyle A string specifying the painting style or null. Valid styles include: 'S' [default] - stroke, 'F' - fill, and 'DF' (or 'FD') - fill then stroke.
*/ DocHandler.prototype.rect = function(x, y, width, height, fillStyle) {
// null is excluded from fillStyle possible values because it isn't needed
// and is prone to bugs as it's used to postpone setting the style
// https://rawgit.com/MrRio/jsPDF/master/docs/jsPDF.html#rect
return this.jsPDFDocument.rect(x, y, width, height, fillStyle);
};
DocHandler.prototype.getLastAutoTable = function() {
return this.jsPDFDocument.lastAutoTable || null;
};
DocHandler.prototype.getTextWidth = function(text) {
return this.jsPDFDocument.getTextWidth(text);
};
DocHandler.prototype.getDocument = function() {
return this.jsPDFDocument;
};
DocHandler.prototype.setPage = function(page) {
this.jsPDFDocument.setPage(page);
};
DocHandler.prototype.addPage = function() {
return this.jsPDFDocument.addPage();
};
DocHandler.prototype.getFontList = function() {
return this.jsPDFDocument.getFontList();
};
DocHandler.prototype.getGlobalOptions = function() {
return globalDefaults || {};
};
DocHandler.prototype.getDocumentOptions = function() {
return this.jsPDFDocument.__autoTableDocumentDefaults || {};
};
DocHandler.prototype.pageSize = function() {
var pageSize = this.jsPDFDocument.internal.pageSize;
// JSPDF 1.4 uses get functions instead of properties on pageSize
if (pageSize.width == null) {
pageSize = {
width: pageSize.getWidth(),
height: pageSize.getHeight()
};
}
return pageSize;
};
DocHandler.prototype.scaleFactor = function() {
return this.jsPDFDocument.internal.scaleFactor;
};
DocHandler.prototype.getLineHeightFactor = function() {
var doc = this.jsPDFDocument;
return doc.getLineHeightFactor ? doc.getLineHeightFactor() : 1.15;
};
DocHandler.prototype.getLineHeight = function(fontSize) {
return fontSize / this.scaleFactor() * this.getLineHeightFactor();
};
DocHandler.prototype.pageNumber = function() {
var pageInfo = this.jsPDFDocument.internal.getCurrentPageInfo();
if (!pageInfo) {
// Only recent versions of jspdf has pageInfo
return this.jsPDFDocument.internal.getNumberOfPages();
}
return pageInfo.pageNumber;
};
return DocHandler;
}();
/******************************************************************************
Copyright (c) Microsoft Corporation.
Permission to use, copy, modify, and/or distribute this software for any
purpose with or without fee is hereby granted.
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
PERFORMANCE OF THIS SOFTWARE.
***************************************************************************** */ /* global Reflect, Promise, SuppressedError, Symbol, Iterator */ var extendStatics = function(d, b) {
extendStatics = Object.setPrototypeOf || ({
__proto__: []
}) instanceof Array && function(d, b) {
d.__proto__ = b;
} || function(d, b) {
for(var p in b)if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p];
};
return extendStatics(d, b);
};
function __extends(d, b) {
if (typeof b !== "function" && b !== null) throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
extendStatics(d, b);
function __() {
this.constructor = d;
}
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
}
typeof SuppressedError === "function" ? SuppressedError : function(error, suppressed, message) {
var e = new Error(message);
return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
};
var HtmlRowInput = function(_super) {
__extends(HtmlRowInput, _super);
function HtmlRowInput(element) {
var _this = _super.call(this) || this;
_this._element = element;
return _this;
}
return HtmlRowInput;
}(Array);
// Base style for all themes
function defaultStyles(scaleFactor) {
return {
font: 'helvetica',
fontStyle: 'normal',
overflow: 'linebreak',
fillColor: false,
textColor: 20,
halign: 'left',
valign: 'top',
fontSize: 10,
cellPadding: 5 / scaleFactor,
lineColor: 200,
lineWidth: 0,
cellWidth: 'auto',
minCellHeight: 0,
minCellWidth: 0
};
}
function getTheme(name) {
var themes = {
striped: {
table: {
fillColor: 255,
textColor: 80,
fontStyle: 'normal'
},
head: {
textColor: 255,
fillColor: [
41,
128,
185
],
fontStyle: 'bold'
},
body: {},
foot: {
textColor: 255,
fillColor: [
41,
128,
185
],
fontStyle: 'bold'
},
alternateRow: {
fillColor: 245
}
},
grid: {
table: {
fillColor: 255,
textColor: 80,
fontStyle: 'normal',
lineWidth: 0.1
},
head: {
textColor: 255,
fillColor: [
26,
188,
156
],
fontStyle: 'bold',
lineWidth: 0
},
body: {},
foot: {
textColor: 255,
fillColor: [
26,
188,
156
],
fontStyle: 'bold',
lineWidth: 0
},
alternateRow: {}
},
plain: {
head: {
fontStyle: 'bold'
},
foot: {
fontStyle: 'bold'
}
}
};
return themes[name];
}
function getStringWidth(text, styles, doc) {
doc.applyStyles(styles, true);
var textArr = Array.isArray(text) ? text : [
text
];
var widestLineWidth = textArr.map(function(text) {
return doc.getTextWidth(text);
}).reduce(function(a, b) {
return Math.max(a, b);
}, 0);
return widestLineWidth;
}
function addTableBorder(doc, table, startPos, cursor) {
var lineWidth = table.settings.tableLineWidth;
var lineColor = table.settings.tableLineColor;
doc.applyStyles({
lineWidth: lineWidth,
lineColor: lineColor
});
var fillStyle = getFillStyle(lineWidth, false);
if (fillStyle) {
doc.rect(startPos.x, startPos.y, table.getWidth(doc.pageSize().width), cursor.y - startPos.y, fillStyle);
}
}
function getFillStyle(lineWidth, fillColor) {
var drawLine = lineWidth > 0;
var drawBackground = fillColor || fillColor === 0;
if (drawLine && drawBackground) {
return 'DF'; // Fill then stroke
} else if (drawLine) {
return 'S'; // Only stroke (transparent background)
} else if (drawBackground) {
return 'F'; // Only fill, no stroke
} else {
return null;
}
}
function parseSpacing(value, defaultValue) {
var _a, _b, _c, _d;
value = value || defaultValue;
if (Array.isArray(value)) {
if (value.length >= 4) {
return {
top: value[0],
right: value[1],
bottom: value[2],
left: value[3]
};
} else if (value.length === 3) {
return {
top: value[0],
right: value[1],
bottom: value[2],
left: value[1]
};
} else if (value.length === 2) {
return {
top: value[0],
right: value[1],
bottom: value[0],
left: value[1]
};
} else if (value.length === 1) {
value = value[0];
} else {
value = defaultValue;
}
}
if (typeof value === 'object') {
if (typeof value.vertical === 'number') {
value.top = value.vertical;
value.bottom = value.vertical;
}
if (typeof value.horizontal === 'number') {
value.right = value.horizontal;
value.left = value.horizontal;
}
return {
left: (_a = value.left) !== null && _a !== void 0 ? _a : defaultValue,
top: (_b = value.top) !== null && _b !== void 0 ? _b : defaultValue,
right: (_c = value.right) !== null && _c !== void 0 ? _c : defaultValue,
bottom: (_d = value.bottom) !== null && _d !== void 0 ? _d : defaultValue
};
}
if (typeof value !== 'number') {
value = defaultValue;
}
return {
top: value,
right: value,
bottom: value,
left: value
};
}
function getPageAvailableWidth(doc, table) {
var margins = parseSpacing(table.settings.margin, 0);
return doc.pageSize().width - (margins.left + margins.right);
}
// Limitations
// - No support for border spacing
// - No support for transparency
function parseCss(supportedFonts, element, scaleFactor, style, window) {
var result = {};
var pxScaleFactor = 96 / 72;
var backgroundColor = parseColor(element, function(elem) {
return window.getComputedStyle(elem)['backgroundColor'];
});
if (backgroundColor != null) result.fillColor = backgroundColor;
var textColor = parseColor(element, function(elem) {
return window.getComputedStyle(elem)['color'];
});
if (textColor != null) result.textColor = textColor;
var padding = parsePadding(style, scaleFactor);
if (padding) result.cellPadding = padding;
var borderColorSide = 'borderTopColor';
var finalScaleFactor = pxScaleFactor * scaleFactor;
var btw = style.borderTopWidth;
if (style.borderBottomWidth === btw && style.borderRightWidth === btw && style.borderLeftWidth === btw) {
var borderWidth = (parseFloat(btw) || 0) / finalScaleFactor;
if (borderWidth) result.lineWidth = borderWidth;
} else {
result.lineWidth = {
top: (parseFloat(style.borderTopWidth) || 0) / finalScaleFactor,
right: (parseFloat(style.borderRightWidth) || 0) / finalScaleFactor,
bottom: (parseFloat(style.borderBottomWidth) || 0) / finalScaleFactor,
left: (parseFloat(style.borderLeftWidth) || 0) / finalScaleFactor
};
// Choose border color of first available side
// could be improved by supporting object as lineColor
if (!result.lineWidth.top) {
if (result.lineWidth.right) {
borderColorSide = 'borderRightColor';
} else if (result.lineWidth.bottom) {
borderColorSide = 'borderBottomColor';
} else if (result.lineWidth.left) {
borderColorSide = 'borderLeftColor';
}
}
}
var borderColor = parseColor(element, function(elem) {
return window.getComputedStyle(elem)[borderColorSide];
});
if (borderColor != null) result.lineColor = borderColor;
var accepted = [
'left',
'right',
'center',
'justify'
];
if (accepted.indexOf(style.textAlign) !== -1) {
result.halign = style.textAlign;
}
accepted = [
'middle',
'bottom',
'top'
];
if (accepted.indexOf(style.verticalAlign) !== -1) {
result.valign = style.verticalAlign;
}
var res = parseInt(style.fontSize || '');
if (!isNaN(res)) result.fontSize = res / pxScaleFactor;
var fontStyle = parseFontStyle(style);
if (fontStyle) result.fontStyle = fontStyle;
var font = (style.fontFamily || '').toLowerCase();
if (supportedFonts.indexOf(font) !== -1) {
result.font = font;
}
return result;
}
function parseFontStyle(style) {
var res = '';
if (style.fontWeight === 'bold' || style.fontWeight === 'bolder' || parseInt(style.fontWeight) >= 700) {
res = 'bold';
}
if (style.fontStyle === 'italic' || style.fontStyle === 'oblique') {
res += 'italic';
}
return res;
}
function parseColor(element, styleGetter) {
var cssColor = realColor(element, styleGetter);
if (!cssColor) return null;
var rgba = cssColor.match(/^rgba?\((\d+),\s*(\d+),\s*(\d+)(?:,\s*(\d*\.?\d*))?\)$/);
if (!rgba || !Array.isArray(rgba)) {
return null;
}
var color = [
parseInt(rgba[1]),
parseInt(rgba[2]),
parseInt(rgba[3])
];
var alpha = parseInt(rgba[4]);
if (alpha === 0 || isNaN(color[0]) || isNaN(color[1]) || isNaN(color[2])) {
return null;
}
return color;
}
function realColor(elem, styleGetter) {
var bg = styleGetter(elem);
if (bg === 'rgba(0, 0, 0, 0)' || bg === 'transparent' || bg === 'initial' || bg === 'inherit') {
if (elem.parentElement == null) {
return null;
}
return realColor(elem.parentElement, styleGetter);
} else {
return bg;
}
}
function parsePadding(style, scaleFactor) {
var val = [
style.paddingTop,
style.paddingRight,
style.paddingBottom,
style.paddingLeft
];
var pxScaleFactor = 96 / (72 / scaleFactor);
var linePadding = (parseInt(style.lineHeight) - parseInt(style.fontSize)) / scaleFactor / 2;
var inputPadding = val.map(function(n) {
return parseInt(n || '0') / pxScaleFactor;
});
var padding = parseSpacing(inputPadding, 0);
if (linePadding > padding.top) {
padding.top = linePadding;
}
if (linePadding > padding.bottom) {
padding.bottom = linePadding;
}
return padding;
}
function parseHtml(doc, input, window, includeHiddenHtml, useCss) {
var _a, _b;
if (includeHiddenHtml === void 0) {
includeHiddenHtml = false;
}
if (useCss === void 0) {
useCss = false;
}
var tableElement;
if (typeof input === 'string') {
tableElement = window.document.querySelector(input);
} else {
tableElement = input;
}
var supportedFonts = Object.keys(doc.getFontList());
var scaleFactor = doc.scaleFactor();
var head = [], body = [], foot = [];
if (!tableElement) {
console.error('Html table could not be found with input: ', input);
return {
head: head,
body: body,
foot: foot
};
}
for(var i = 0; i < tableElement.rows.length; i++){
var element = tableElement.rows[i];
var tagName = (_b = (_a = element === null || element === void 0 ? void 0 : element.parentElement) === null || _a === void 0 ? void 0 : _a.tagName) === null || _b === void 0 ? void 0 : _b.toLowerCase();
var row = parseRowContent(supportedFonts, scaleFactor, window, element, includeHiddenHtml, useCss);
if (!row) continue;
if (tagName === 'thead') {
head.push(row);
} else if (tagName === 'tfoot') {
foot.push(row);
} else {
// Add to body both if parent is tbody or table
body.push(row);
}
}
return {
head: head,
body: body,
foot: foot
};
}
function parseRowContent(supportedFonts, scaleFactor, window, row, includeHidden, useCss) {
var resultRow = new HtmlRowInput(row);
for(var i = 0; i < row.cells.length; i++){
var cell = row.cells[i];
var style_1 = window.getComputedStyle(cell);
if (includeHidden || style_1.display !== 'none') {
var cellStyles = void 0;
if (useCss) {
cellStyles = parseCss(supportedFonts, cell, scaleFactor, style_1, window);
}
resultRow.push({
rowSpan: cell.rowSpan,
colSpan: cell.colSpan,
styles: cellStyles,
_element: cell,
content: parseCellContent(cell)
});
}
}
var style = window.getComputedStyle(row);
if (resultRow.length > 0 && (includeHidden || style.display !== 'none')) {
return resultRow;
}
}
function parseCellContent(orgCell) {
// Work on cloned node to make sure no changes are applied to html table
var cell = orgCell.cloneNode(true);
// Remove extra space and line breaks in markup to make it more similar to
// what would be shown in html
cell.innerHTML = cell.innerHTML.replace(/\n/g, '').replace(/ +/g, ' ');
// Preserve <br> tags as line breaks in the pdf
cell.innerHTML = cell.innerHTML.split(/<br.*?>/) //start with '<br' and ends with '>'.
.map(function(part) {
return part.trim();
}).join('\n');
// innerText for ie
return cell.innerText || cell.textContent || '';
}
function validateInput(global, document, current) {
for(var _i = 0, _a = [
global,
document,
current
]; _i < _a.length; _i++){
var options = _a[_i];
if (options && typeof options !== 'object') {
console.error('The options parameter should be of type object, is: ' + typeof options);
}
if (options.startY && typeof options.startY !== 'number') {
console.error('Invalid value for startY option', options.startY);
delete options.startY;
}
}
}
/* eslint-disable @typescript-eslint/no-unused-vars */ // https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/assign
function assign(target, s, s1, s2, s3) {
if (target == null) {
throw new TypeError('Cannot convert undefined or null to object');
}
var to = Object(target);
for(var index = 1; index < arguments.length; index++){
// eslint-disable-next-line prefer-rest-params
var nextSource = arguments[index];
if (nextSource != null) {
// Skip over if undefined or null
for(var nextKey in nextSource){
// Avoid bugs when hasOwnProperty is shadowed
if (Object.prototype.hasOwnProperty.call(nextSource, nextKey)) {
to[nextKey] = nextSource[nextKey];
}
}
}
}
return to;
}
function parseInput(d, current) {
var doc = new DocHandler(d);
var document = doc.getDocumentOptions();
var global = doc.getGlobalOptions();
validateInput(global, document, current);
var options = assign({}, global, document, current);
var win;
if ("TURBOPACK compile-time falsy", 0) //TURBOPACK unreachable
;
var styles = parseStyles(global, document, current);
var hooks = parseHooks(global, document, current);
var settings = parseSettings(doc, options);
var content = parseContent$1(doc, options, win);
return {
id: current.tableId,
content: content,
hooks: hooks,
styles: styles,
settings: settings
};
}
function parseStyles(gInput, dInput, cInput) {
var styleOptions = {
styles: {},
headStyles: {},
bodyStyles: {},
footStyles: {},
alternateRowStyles: {},
columnStyles: {}
};
var _loop_1 = function(prop) {
if (prop === 'columnStyles') {
var global_1 = gInput[prop];
var document_1 = dInput[prop];
var current = cInput[prop];
styleOptions.columnStyles = assign({}, global_1, document_1, current);
} else {
var allOptions = [
gInput,
dInput,
cInput
];
var styles = allOptions.map(function(opts) {
return opts[prop] || {};
});
styleOptions[prop] = assign({}, styles[0], styles[1], styles[2]);
}
};
for(var _i = 0, _a = Object.keys(styleOptions); _i < _a.length; _i++){
var prop = _a[_i];
_loop_1(prop);
}
return styleOptions;
}
function parseHooks(global, document, current) {
var allOptions = [
global,
document,
current
];
var result = {
didParseCell: [],
willDrawCell: [],
didDrawCell: [],
willDrawPage: [],
didDrawPage: []
};
for(var _i = 0, allOptions_1 = allOptions; _i < allOptions_1.length; _i++){
var options = allOptions_1[_i];
if (options.didParseCell) result.didParseCell.push(options.didParseCell);
if (options.willDrawCell) result.willDrawCell.push(options.willDrawCell);
if (options.didDrawCell) result.didDrawCell.push(options.didDrawCell);
if (options.willDrawPage) result.willDrawPage.push(options.willDrawPage);
if (options.didDrawPage) result.didDrawPage.push(options.didDrawPage);
}
return result;
}
function parseSettings(doc, options) {
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m;
var margin = parseSpacing(options.margin, 40 / doc.scaleFactor());
var startY = (_a = getStartY(doc, options.startY)) !== null && _a !== void 0 ? _a : margin.top;
var showFoot;
if (options.showFoot === true) {
showFoot = 'everyPage';
} else if (options.showFoot === false) {
showFoot = 'never';
} else {
showFoot = (_b = options.showFoot) !== null && _b !== void 0 ? _b : 'everyPage';
}
var showHead;
if (options.showHead === true) {
showHead = 'everyPage';
} else if (options.showHead === false) {
showHead = 'never';
} else {
showHead = (_c = options.showHead) !== null && _c !== void 0 ? _c : 'everyPage';
}
var useCss = (_d = options.useCss) !== null && _d !== void 0 ? _d : false;
var theme = options.theme || (useCss ? 'plain' : 'striped');
var horizontalPageBreak = !!options.horizontalPageBreak;
var horizontalPageBreakRepeat = (_e = options.horizontalPageBreakRepeat) !== null && _e !== void 0 ? _e : null;
return {
includeHiddenHtml: (_f = options.includeHiddenHtml) !== null && _f !== void 0 ? _f : false,
useCss: useCss,
theme: theme,
startY: startY,
margin: margin,
pageBreak: (_g = options.pageBreak) !== null && _g !== void 0 ? _g : 'auto',
rowPageBreak: (_h = options.rowPageBreak) !== null && _h !== void 0 ? _h : 'auto',
tableWidth: (_j = options.tableWidth) !== null && _j !== void 0 ? _j : 'auto',
showHead: showHead,
showFoot: showFoot,
tableLineWidth: (_k = options.tableLineWidth) !== null && _k !== void 0 ? _k : 0,
tableLineColor: (_l = options.tableLineColor) !== null && _l !== void 0 ? _l : 200,
horizontalPageBreak: horizontalPageBreak,
horizontalPageBreakRepeat: horizontalPageBreakRepeat,
horizontalPageBreakBehaviour: (_m = options.horizontalPageBreakBehaviour) !== null && _m !== void 0 ? _m : 'afterAllRows'
};
}
function getStartY(doc, userStartY) {
var previous = doc.getLastAutoTable();
var sf = doc.scaleFactor();
var currentPage = doc.pageNumber();
var isSamePageAsPreviousTable = false;
if (previous && previous.startPageNumber) {
var endingPage = previous.startPageNumber + previous.pageNumber - 1;
isSamePageAsPreviousTable = endingPage === currentPage;
}
if (typeof userStartY === 'number') {
return userStartY;
} else if (userStartY == null || userStartY === false) {
if (isSamePageAsPreviousTable && (previous === null || previous === void 0 ? void 0 : previous.finalY) != null) {
// Some users had issues with overlapping tables when they used multiple
// tables without setting startY so setting it here to a sensible default.
return previous.finalY + 20 / sf;
}
}
return null;
}
function parseContent$1(doc, options, window) {
var head = options.head || [];
var body = options.body || [];
var foot = options.foot || [];
if (options.html) {
var hidden = options.includeHiddenHtml;
if (window) {
var htmlContent = parseHtml(doc, options.html, window, hidden, options.useCss) || {};
head = htmlContent.head || head;
body = htmlContent.body || head;
foot = htmlContent.foot || head;
} else {
console.error('Cannot parse html in non browser environment');
}
}
var columns = options.columns || parseColumns(head, body, foot);
return {
columns: columns,
head: head,
body: body,
foot: foot
};
}
function parseColumns(head, body, foot) {
var firstRow = head[0] || body[0] || foot[0] || [];
var result = [];
Object.keys(firstRow).filter(function(key) {
return key !== '_element';
}).forEach(function(key) {
var colSpan = 1;
var input;
if (Array.isArray(firstRow)) {
input = firstRow[parseInt(key)];
} else {
input = firstRow[key];
}
if (typeof input === 'object' && !Array.isArray(input)) {
colSpan = (input === null || input === void 0 ? void 0 : input.colSpan) || 1;
}
for(var i = 0; i < colSpan; i++){
var id = void 0;
if (Array.isArray(firstRow)) {
id = result.length;
} else {
id = key + (i > 0 ? "_".concat(i) : '');
}
var rowResult = {
dataKey: id
};
result.push(rowResult);
}
});
return result;
}
var HookData = function() {
function HookData(doc, table, cursor) {
this.table = table;
this.pageNumber = table.pageNumber;
this.settings = table.settings;
this.cursor = cursor;
this.doc = doc.getDocument();
}
return HookData;
}();
var CellHookData = function(_super) {
__extends(CellHookData, _super);
function CellHookData(doc, table, cell, row, column, cursor) {
var _this = _super.call(this, doc, table, cursor) || this;
_this.cell = cell;
_this.row = row;
_this.column = column;
_this.section = row.section;
return _this;
}
return CellHookData;
}(HookData);
var Table = function() {
function Table(input, content) {
this.pageNumber = 1;
this.id = input.id;
this.settings = input.settings;
this.styles = input.styles;
this.hooks = input.hooks;
this.columns = content.columns;
this.head = content.head;
this.body = content.body;
this.foot = content.foot;
}
Table.prototype.getHeadHeight = function(columns) {
return this.head.reduce(function(acc, row) {
return acc + row.getMaxCellHeight(columns);
}, 0);
};
Table.prototype.getFootHeight = function(columns) {
return this.foot.reduce(function(acc, row) {
return acc + row.getMaxCellHeight(columns);
}, 0);
};
Table.prototype.allRows = function() {
return this.head.concat(this.body).concat(this.foot);
};
Table.prototype.callCellHooks = function(doc, handlers, cell, row, column, cursor) {
for(var _i = 0, handlers_1 = handlers; _i < handlers_1.length; _i++){
var handler = handlers_1[_i];
var data = new CellHookData(doc, this, cell, row, column, cursor);
var result = handler(data) === false;
// Make sure text is always string[] since user can assign string
cell.text = Array.isArray(cell.text) ? cell.text : [
cell.text
];
if (result) {
return false;
}
}
return true;
};
Table.prototype.callEndPageHooks = function(doc, cursor) {
doc.applyStyles(doc.userStyles);
for(var _i = 0, _a = this.hooks.didDrawPage; _i < _a.length; _i++){
var handler = _a[_i];
handler(new HookData(doc, this, cursor));
}
};
Table.prototype.callWillDrawPageHooks = function(doc, cursor) {
for(var _i = 0, _a = this.hooks.willDrawPage; _i < _a.length; _i++){
var handler = _a[_i];
handler(new HookData(doc, this, cursor));
}
};
Table.prototype.getWidth = function(pageWidth) {
if (typeof this.settings.tableWidth === 'number') {
return this.settings.tableWidth;
} else if (this.settings.tableWidth === 'wrap') {
var wrappedWidth = this.columns.reduce(function(total, col) {
return total + col.wrappedWidth;
}, 0);
return wrappedWidth;
} else {
var margin = this.settings.margin;
return pageWidth - margin.left - margin.right;
}
};
return Table;
}();
var Row = function() {
function Row(raw, index, section, cells, spansMultiplePages) {
if (spansMultiplePages === void 0) {
spansMultiplePages = false;
}
this.height = 0;
this.raw = raw;
if (raw instanceof HtmlRowInput) {
this.raw = raw._element;
this.element = raw._element;
}
this.index = index;
this.section = section;
this.cells = cells;
this.spansMultiplePages = spansMultiplePages;
}
Row.prototype.getMaxCellHeight = function(columns) {
var _this = this;
return columns.reduce(function(acc, column) {
var _a;
return Math.max(acc, ((_a = _this.cells[column.index]) === null || _a === void 0 ? void 0 : _a.height) || 0);
}, 0);
};
Row.prototype.hasRowSpan = function(columns) {
var _this = this;
return columns.filter(function(column) {
var cell = _this.cells[column.index];
if (!cell) return false;
return cell.rowSpan > 1;
}).length > 0;
};
Row.prototype.canEntireRowFit = function(height, columns) {
return this.getMaxCellHeight(columns) <= height;
};
Row.prototype.getMinimumRowHeight = function(columns, doc) {
var _this = this;
return columns.reduce(function(acc, column) {
var cell = _this.cells[column.index];
if (!cell) return 0;
var lineHeight = doc.getLineHeight(cell.styles.fontSize);
var vPadding = cell.padding('vertical');
var oneRowHeight = vPadding + lineHeight;
return oneRowHeight > acc ? oneRowHeight : acc;
}, 0);
};
return Row;
}();
var Cell = function() {
function Cell(raw, styles, section) {
var _a;
this.contentHeight = 0;
this.contentWidth = 0;
this.wrappedWidth = 0;
this.minReadableWidth = 0;
this.minWidth = 0;
this.width = 0;
this.height = 0;
this.x = 0;
this.y = 0;
this.styles = styles;
this.section = section;
this.raw = raw;
var content = raw;
if (raw != null && typeof raw === 'object' && !Array.isArray(raw)) {
this.rowSpan = raw.rowSpan || 1;
this.colSpan = raw.colSpan || 1;
content = (_a = raw.content) !== null && _a !== void 0 ? _a : raw;
if (raw._element) {
this.raw = raw._element;
}
} else {
this.rowSpan = 1;
this.colSpan = 1;
}
// Stringify 0 and false, but not undefined or null
var text = content != null ? '' + content : '';
var splitRegex = /\r\n|\r|\n/g;
this.text = text.split(splitRegex);
}
Cell.prototype.getTextPos = function() {
var y;
if (this.styles.valign === 'top') {
y = this.y + this.padding('top');
} else if (this.styles.valign === 'bottom') {
y = this.y + this.height - this.padding('bottom');
} else {
var netHeight = this.height - this.padding('vertical');
y = this.y + netHeight / 2 + this.padding('top');
}
var x;
if (this.styles.halign === 'right') {
x = this.x + this.width - this.padding('right');
} else if (this.styles.halign === 'center') {
var netWidth = this.width - this.padding('horizontal');
x = this.x + netWidth / 2 + this.padding('left');
} else {
x = this.x + this.padding('left');
}
return {
x: x,
y: y
};
};
// TODO (v4): replace parameters with only (lineHeight)
Cell.prototype.getContentHeight = function(scaleFactor, lineHeightFactor) {
if (lineHeightFactor === void 0) {
lineHeightFactor = 1.15;
}
var lineCount = Array.isArray(this.text) ? this.text.length : 1;
var lineHeight = this.styles.fontSize / scaleFactor * lineHeightFactor;
var height = lineCount * lineHeight + this.padding('vertical');
return Math.max(height, this.styles.minCellHeight);
};
Cell.prototype.padding = function(name) {
var padding = parseSpacing(this.styles.cellPadding, 0);
if (name === 'vertical') {
return padding.top + padding.bottom;
} else if (name === 'horizontal') {
return padding.left + padding.right;
} else {
return padding[name];
}
};
return Cell;
}();
var Column = function() {
function Column(dataKey, raw, index) {
this.wrappedWidth = 0;
this.minReadableWidth = 0;
this.minWidth = 0;
this.width = 0;
this.dataKey = dataKey;
this.raw = raw;
this.index = index;
}
Column.prototype.getMaxCustomCellWidth = function(table) {
var max = 0;
for(var _i = 0, _a = table.allRows(); _i < _a.length; _i++){
var row = _a[_i];
var cell = row.cells[this.index];
if (cell && typeof cell.styles.cellWidth === 'number') {
max = Math.max(max, cell.styles.cellWidth);
}
}
return max;
};
return Column;
}();
/**
* Calculate the column widths
*/ function calculateWidths(doc, table) {
calculate(doc, table);
var resizableColumns = [];
var initialTableWidth = 0;
table.columns.forEach(function(column) {
var customWidth = column.getMaxCustomCellWidth(table);
if (customWidth) {
// final column width
column.width = customWidth;
} else {
// initial column width (will be resized)
column.width = column.wrappedWidth;
resizableColumns.push(column);
}
initialTableWidth += column.width;
});
// width difference that needs to be distributed
var resizeWidth = table.getWidth(doc.pageSize().width) - initialTableWidth;
// first resize attempt: with respect to minReadableWidth and minWidth
if (resizeWidth) {
resizeWidth = resizeColumns(resizableColumns, resizeWidth, function(column) {
return Math.max(column.minReadableWidth, column.minWidth);
});
}
// second resize attempt: ignore minReadableWidth but respect minWidth
if (resizeWidth) {
resizeWidth = resizeColumns(resizableColumns, resizeWidth, function(column) {
return column.minWidth;
});
}
resizeWidth = Math.abs(resizeWidth);
if (!table.settings.horizontalPageBreak && resizeWidth > 0.1 / doc.scaleFactor()) {
// Table can't get smaller due to custom-width or minWidth restrictions
// We can't really do much here. Up to user to for example
// reduce font size, increase page size or remove custom cell widths
// to allow more columns to be reduced in size
resizeWidth = resizeWidth < 1 ? resizeWidth : Math.round(resizeWidth);
console.log("Of the table content, ".concat(resizeWidth, " units width could not fit page"));
}
applyColSpans(table);
fitContent(table, doc);
applyRowSpans(table);
}
function calculate(doc, table) {
var sf = doc.scaleFactor();
var horizontalPageBreak = table.settings.horizontalPageBreak;
var availablePageWidth = getPageAvailableWidth(doc, table);
table.allRows().forEach(function(row) {
for(var _i = 0, _a = table.columns; _i < _a.length; _i++){
var column = _a[_i];
var cell = row.cells[column.index];
if (!cell) continue;
var hooks = table.hooks.didParseCell;
table.callCellHooks(doc, hooks, cell, row, column, null);
var padding = cell.padding('horizontal');
cell.contentWidth = getStringWidth(cell.text, cell.styles, doc) + padding;
// Using [^\S\u00A0] instead of \s ensures that we split the text on all
// whitespace except non-breaking spaces (\u00A0). We need to preserve
// them in the split process to ensure correct word separation and width
// calculation.
var longestWordWidth = getStringWidth(cell.text.join(' ').split(/[^\S\u00A0]+/), cell.styles, doc);
cell.minReadableWidth = longestWordWidth + cell.padding('horizontal');
if (typeof cell.styles.cellWidth === 'number') {
cell.minWidth = cell.styles.cellWidth;
cell.wrappedWidth = cell.styles.cellWidth;
} else if (cell.styles.cellWidth === 'wrap' || horizontalPageBreak === true) {
// cell width should not be more than available page width
if (cell.contentWidth > availablePageWidth) {
cell.minWidth = availablePageWidth;
cell.wrappedWidth = availablePageWidth;
} else {
cell.minWidth = cell.contentWidth;
cell.wrappedWidth = cell.contentWidth;
}
} else {
// auto
var defaultMinWidth = 10 / sf;
cell.minWidth = cell.styles.minCellWidth || defaultMinWidth;
cell.wrappedWidth = cell.contentWidth;
if (cell.minWidth > cell.wrappedWidth) {
cell.wrappedWidth = cell.minWidth;
}
}
}
});
table.allRows().forEach(function(row) {
for(var _i = 0, _a = table.columns; _i < _a.length; _i++){
var column = _a[_i];
var cell = row.cells[column.index];
// For now we ignore the minWidth and wrappedWidth of colspan cells when calculating colspan widths.
// Could probably be improved upon however.
if (cell && cell.colSpan === 1) {
column.wrappedWidth = Math.max(column.wrappedWidth, cell.wrappedWidth);
column.minWidth = Math.max(column.minWidth, cell.minWidth);
column.minReadableWidth = Math.max(column.minReadableWidth, cell.minReadableWidth);
} else {
// Respect cellWidth set in columnStyles even if there is no cells for this column
// or if the column only have colspan cells. Since the width of colspan cells
// does not affect the width of columns, setting columnStyles cellWidth enables the
// user to at least do it manually.
// Note that this is not perfect for now since for example row and table styles are
// not accounted for
var columnStyles = table.styles.columnStyles[column.dataKey] || table.styles.columnStyles[column.index] || {};
var cellWidth = columnStyles.cellWidth || columnStyles.minCellWidth;
if (cellWidth && typeof cellWidth === 'number') {
column.minWidth = cellWidth;
column.wrappedWidth = cellWidth;
}
}
if (cell) {
// Make sure all columns get at least min width even though width calculations are not based on them
if (cell.colSpan > 1 && !column.minWidth) {
column.minWidth = cell.minWidth;
}
if (cell.colSpan > 1 && !column.wrappedWidth) {
column.wrappedWidth = cell.minWidth;
}
}
}
});
}
/**
* Distribute resizeWidth on passed resizable columns
*/ function resizeColumns(columns, resizeWidth, getMinWidth) {
var initialResizeWidth = resizeWidth;
var sumWrappedWidth = columns.reduce(function(acc, column) {
return acc + column.wrappedWidth;
}, 0);
for(var i = 0; i < columns.length; i++){
var column = columns[i];
var ratio = column.wrappedWidth / sumWrappedWidth;
var suggestedChange = initialResizeWidth * ratio;
var suggestedWidth = column.width + suggestedChange;
var minWidth = getMinWidth(column);
var newWidth = suggestedWidth < minWidth ? minWidth : suggestedWidth;
resizeWidth -= newWidth - column.width;
column.width = newWidth;
}
resizeWidth = Math.round(resizeWidth * 1e10) / 1e10;
// Run the resizer again if there's remaining width needs
// to be distributed and there're columns that can be resized
if (resizeWidth) {
var resizableColumns = columns.filter(function(column) {
return resizeWidth < 0 ? column.width > getMinWidth(column) // check if column can shrink
: true; // check if column can grow
});
if (resizableColumns.length) {
resizeWidth = resizeColumns(resizableColumns, resizeWidth, getMinWidth);
}
}
return resizeWidth;
}
function applyRowSpans(table) {
var rowSpanCells = {};
var colRowSpansLeft = 1;
var all = table.allRows();
for(var rowIndex = 0; rowIndex < all.length; rowIndex++){
var row = all[rowIndex];
for(var _i = 0, _a = table.columns; _i < _a.length; _i++){
var column = _a[_i];
var data = rowSpanCells[column.index];
if (colRowSpansLeft > 1) {
colRowSpansLeft--;
delete row.cells[column.index];
} else if (data) {
data.cell.height += row.height;
colRowSpansLeft = data.cell.colSpan;
delete row.cells[column.index];
data.left--;
if (data.left <= 1) {
delete rowSpanCells[column.index];
}
} else {
var cell = row.cells[column.index];
if (!cell) {
continue;
}
cell.height = row.height;
if (cell.rowSpan > 1) {
var remaining = all.length - rowIndex;
var left = cell.rowSpan > remaining ? remaining : cell.rowSpan;
rowSpanCells[column.index] = {
cell: cell,
left: left,
row: row
};
}
}
}
}
}
function applyColSpans(table) {
var all = table.allRows();
for(var rowIndex = 0; rowIndex < all.length; rowIndex++){
var row = all[rowIndex];
var colSpanCell = null;
var combinedColSpanWidth = 0;
var colSpansLeft = 0;
for(var columnIndex = 0; columnIndex < table.columns.length; columnIndex++){
var column = table.columns[columnIndex];
// Width and colspan
colSpansLeft -= 1;
if (colSpansLeft > 1 && table.columns[columnIndex + 1]) {
combinedColSpanWidth += column.width;
delete row.cells[column.index];
} else if (colSpanCell) {
var cell = colSpanCell;
delete row.cells[column.index];
colSpanCell = null;
cell.width = column.width + combinedColSpanWidth;
} else {
var cell = row.cells[column.index];
if (!cell) continue;
colSpansLeft = cell.colSpan;
combinedColSpanWidth = 0;
if (cell.colSpan > 1) {
colSpanCell = cell;
combinedColSpanWidth += column.width;
continue;
}
cell.width = column.width + combinedColSpanWidth;
}
}
}
}
function fitContent(table, doc) {
var rowSpanHeight = {
count: 0,
height: 0
};
for(var _i = 0, _a = table.allRows(); _i < _a.length; _i++){
var row = _a[_i];
for(var _b = 0, _c = table.columns; _b < _c.length; _b++){
var column = _c[_b];
var cell = row.cells[column.index];
if (!cell) continue;
doc.applyStyles(cell.styles, true);
var textSpace = cell.width - cell.padding('horizontal');
if (cell.styles.overflow === 'linebreak') {
// Add one pt to textSpace to fix rounding error
cell.text = doc.splitTextToSize(cell.text, textSpace + 1 / doc.scaleFactor(), {
fontSize: cell.styles.fontSize
});
} else if (cell.styles.overflow === 'ellipsize') {
cell.text = ellipsize(cell.text, textSpace, cell.styles, doc, '...');
} else if (cell.styles.overflow === 'hidden') {
cell.text = ellipsize(cell.text, textSpace, cell.styles, doc, '');
} else if (typeof cell.styles.overflow === 'function') {
var result = cell.styles.overflow(cell.text, textSpace);
if (typeof result === 'string') {
cell.text = [
result
];
} else {
cell.text = result;
}
}
cell.contentHeight = cell.getContentHeight(doc.scaleFactor(), doc.getLineHeightFactor());
var realContentHeight = cell.contentHeight / cell.rowSpan;
if (cell.rowSpan > 1 && rowSpanHeight.count * rowSpanHeight.height < realContentHeight * cell.rowSpan) {
rowSpanHeight = {
height: realContentHeight,
count: cell.rowSpan
};
} else if (rowSpanHeight && rowSpanHeight.count > 0) {
if (rowSpanHeight.height > realContentHeight) {
realContentHeight = rowSpanHeight.height;
}
}
if (realContentHeight > row.height) {
row.height = realContentHeight;
}
}
rowSpanHeight.count--;
}
}
function ellipsize(text, width, styles, doc, overflow) {
return text.map(function(str) {
return ellipsizeStr(str, width, styles, doc, overflow);
});
}
function ellipsizeStr(text, width, styles, doc, overflow) {
var precision = 10000 * doc.scaleFactor();
width = Math.ceil(width * precision) / precision;
if (width >= getStringWidth(text, styles, doc)) {
return text;
}
while(width < getStringWidth(text + overflow, styles, doc)){
if (text.length <= 1) {
break;
}
text = text.substring(0, text.length - 1);
}
return text.trim() + overflow;
}
function createTable(jsPDFDoc, input) {
var doc = new DocHandler(jsPDFDoc);
var content = parseContent(input, doc.scaleFactor());
var table = new Table(input, content);
calculateWidths(doc, table);
doc.applyStyles(doc.userStyles);
return table;
}
function parseContent(input, sf) {
var content = input.content;
var columns = createColumns(content.columns);
// If no head or foot is set, try generating it with content from columns
if (content.head.length === 0) {
var sectionRow = generateSectionRow(columns, 'head');
if (sectionRow) content.head.push(sectionRow);
}
if (content.foot.length === 0) {
var sectionRow = generateSectionRow(columns, 'foot');
if (sectionRow) content.foot.push(sectionRow);
}
var theme = input.settings.theme;
var styles = input.styles;
return {
columns: columns,
head: parseSection('head', content.head, columns, styles, theme, sf),
body: parseSection('body', content.body, columns, styles, theme, sf),
foot: parseSection('foot', content.foot, columns, styles, theme, sf)
};
}
function parseSection(sectionName, sectionRows, columns, styleProps, theme, scaleFactor) {
var rowSpansLeftForColumn = {};
var result = sectionRows.map(function(rawRow, rowIndex) {
var skippedRowForRowSpans = 0;
var cells = {};
var colSpansAdded = 0;
var columnSpansLeft = 0;
for(var _i = 0, columns_1 = columns; _i < columns_1.length; _i++){
var column = columns_1[_i];
if (rowSpansLeftForColumn[column.index] == null || rowSpansLeftForColumn[column.index].left === 0) {
if (columnSpansLeft === 0) {
var rawCell = void 0;
if (Array.isArray(rawRow)) {
rawCell = rawRow[column.index - colSpansAdded - skippedRowForRowSpans];
} else {
rawCell = rawRow[column.dataKey];
}
var cellInputStyles = {};
if (typeof rawCell === 'object' && !Array.isArray(rawCell)) {
cellInputStyles = (rawCell === null || rawCell === void 0 ? void 0 : rawCell.styles) || {};
}
var styles = cellStyles(sectionName, column, rowIndex, theme, styleProps, scaleFactor, cellInputStyles);
var cell = new Cell(rawCell, styles, sectionName);
// dataKey is not used internally no more but keep for
// backwards compat in hooks
cells[column.dataKey] = cell;
cells[column.index] = cell;
columnSpansLeft = cell.colSpan - 1;
rowSpansLeftForColumn[column.index] = {
left: cell.rowSpan - 1,
times: columnSpansLeft
};
} else {
columnSpansLeft--;
colSpansAdded++;
}
} else {
rowSpansLeftForColumn[column.index].left--;
columnSpansLeft = rowSpansLeftForColumn[column.index].times;
skippedRowForRowSpans++;
}
}
return new Row(rawRow, rowIndex, sectionName, cells);
});
return result;
}
function generateSectionRow(columns, section) {
var sectionRow = {};
columns.forEach(function(col) {
if (col.raw != null) {
var title = getSectionTitle(section, col.raw);
if (title != null) sectionRow[col.dataKey] = title;
}
});
return Object.keys(sectionRow).length > 0 ? sectionRow : null;
}
function getSectionTitle(section, column) {
if (section === 'head') {
if (typeof column === 'object') {
return column.header || null;
} else if (typeof column === 'string' || typeof column === 'number') {
return column;
}
} else if (section === 'foot' && typeof column === 'object') {
return column.footer;
}
return null;
}
function createColumns(columns) {
return columns.map(function(input, index) {
var _a;
var key;
if (typeof input === 'object') {
key = (_a = input.dataKey) !== null && _a !== void 0 ? _a : index;
} else {
key = index;
}
return new Column(key, input, index);
});
}
function cellStyles(sectionName, column, rowIndex, themeName, styles, scaleFactor, cellInputStyles) {
var theme = getTheme(themeName);
var sectionStyles;
if (sectionName === 'head') {
sectionStyles = styles.headStyles;
} else if (sectionName === 'body') {
sectionStyles = styles.bodyStyles;
} else if (sectionName === 'foot') {
sectionStyles = styles.footStyles;
}
var otherStyles = assign({}, theme.table, theme[sectionName], styles.styles, sectionStyles);
var columnStyles = styles.columnStyles[column.dataKey] || styles.columnStyles[column.index] || {};
var colStyles = sectionName === 'body' ? columnStyles : {};
var rowStyles = sectionName === 'body' && rowIndex % 2 === 0 ? assign({}, theme.alternateRow, styles.alternateRowStyles) : {};
var defaultStyle = defaultStyles(scaleFactor);
var themeStyles = assign({}, defaultStyle, otherStyles, rowStyles, colStyles);
return assign(themeStyles, cellInputStyles);
}
// get columns can be fit into page
function getColumnsCanFitInPage(doc, table, config) {
var _a;
if (config === void 0) {
config = {};
}
// Get page width
var remainingWidth = getPageAvailableWidth(doc, table);
// Get column data key to repeat
var repeatColumnsMap = new Map();
var colIndexes = [];
var columns = [];
var horizontalPageBreakRepeat = [];
if (Array.isArray(table.settings.horizontalPageBreakRepeat)) {
horizontalPageBreakRepeat = table.settings.horizontalPageBreakRepeat;
// It can be a single value of type string or number (even number: 0)
} else if (typeof table.settings.horizontalPageBreakRepeat === 'string' || typeof table.settings.horizontalPageBreakRepeat === 'number') {
horizontalPageBreakRepeat = [
table.settings.horizontalPageBreakRepeat
];
}
// Code to repeat the given column in split pages
horizontalPageBreakRepeat.forEach(function(field) {
var col = table.columns.find(function(item) {
return item.dataKey === field || item.index === field;
});
if (col && !repeatColumnsMap.has(col.index)) {
repeatColumnsMap.set(col.index, true);
colIndexes.push(col.index);
columns.push(table.columns[col.index]);
remainingWidth -= col.wrappedWidth;
}
});
var first = true;
var i = (_a = config === null || config === void 0 ? void 0 : config.start) !== null && _a !== void 0 ? _a : 0; // make sure couter is initiated outside the loop
while(i < table.columns.length){
// Prevent duplicates
if (repeatColumnsMap.has(i)) {
i++;
continue;
}
var colWidth = table.columns[i].wrappedWidth;
// Take at least one column even if it doesn't fit
if (first || remainingWidth >= colWidth) {
first = false;
colIndexes.push(i);
columns.push(table.columns[i]);
remainingWidth -= colWidth;
} else {
break;
}
i++;
}
return {
colIndexes: colIndexes,
columns: columns,
lastIndex: i - 1
};
}
function calculateAllColumnsCanFitInPage(doc, table) {
var allResults = [];
for(var i = 0; i < table.columns.length; i++){
var result = getColumnsCanFitInPage(doc, table, {
start: i
});
if (result.columns.length) {
allResults.push(result);
i = result.lastIndex;
}
}
return allResults;
}
function drawTable(jsPDFDoc, table) {
var settings = table.settings;
var startY = settings.startY;
var margin = settings.margin;
var cursor = {
x: margin.left,
y: startY
};
var sectionsHeight = table.getHeadHeight(table.columns) + table.getFootHeight(table.columns);
var minTableBottomPos = startY + margin.bottom + sectionsHeight;
if (settings.pageBreak === 'avoid') {
var rows = table.body;
var tableHeight = rows.reduce(function(acc, row) {
return acc + row.height;
}, 0);
minTableBottomPos += tableHeight;
}
var doc = new DocHandler(jsPDFDoc);
if (settings.pageBreak === 'always' || settings.startY != null && minTableBottomPos > doc.pageSize().height) {
nextPage(doc);
cursor.y = margin.top;
}
table.callWillDrawPageHooks(doc, cursor);
var startPos = assign({}, cursor);
table.startPageNumber = doc.pageNumber();
if (settings.horizontalPageBreak) {
// managed flow for split columns
printTableWithHorizontalPageBreak(doc, table, startPos, cursor);
} else {
// normal flow
doc.applyStyles(doc.userStyles);
if (settings.showHead === 'firstPage' || settings.showHead === 'everyPage') {
table.head.forEach(function(row) {
return printRow(doc, table, row, cursor, table.columns);
});
}
doc.applyStyles(doc.userStyles);
table.body.forEach(function(row, index) {
var isLastRow = index === table.body.length - 1;
printFullRow(doc, table, row, isLastRow, startPos, cursor, table.columns);
});
doc.applyStyles(doc.userStyles);
if (settings.showFoot === 'lastPage' || settings.showFoot === 'everyPage') {
table.foot.forEach(function(row) {
return printRow(doc, table, row, cursor, table.columns);
});
}
}
addTableBorder(doc, table, startPos, cursor);
table.callEndPageHooks(doc, cursor);
table.finalY = cursor.y;
jsPDFDoc.lastAutoTable = table;
doc.applyStyles(doc.userStyles);
}
function printTableWithHorizontalPageBreak(doc, table, startPos, cursor) {
// calculate width of columns and render only those which can fit into page
var allColumnsCanFitResult = calculateAllColumnsCanFitInPage(doc, table);
var settings = table.settings;
if (settings.horizontalPageBreakBehaviour === 'afterAllRows') {
allColumnsCanFitResult.forEach(function(colsAndIndexes, index) {
doc.applyStyles(doc.userStyles);
// add page to print next columns in new page
if (index > 0) {
// When adding a page here, make sure not to print the footers
// because they were already printed before on this same loop
addPage(doc, table, startPos, cursor, colsAndIndexes.columns, true);
} else {
// print head for selected columns
printHead(doc, table, cursor, colsAndIndexes.columns);
}
// print body & footer for selected columns
printBody(doc, table, startPos, cursor, colsAndIndexes.columns);
printFoot(doc, table, cursor, colsAndIndexes.columns);
});
} else {
var lastRowIndexOfLastPage_1 = -1;
var firstColumnsToFitResult = allColumnsCanFitResult[0];
var _loop_1 = function() {
// Print the first columns, taking note of the last row printed
var lastPrintedRowIndex = lastRowIndexOfLastPage_1;
if (firstColumnsToFitResult) {
doc.applyStyles(doc.userStyles);
var firstColumnsToFit = firstColumnsToFitResult.columns;
if (lastRowIndexOfLastPage_1 >= 0) {
// When adding a page here, make sure not to print the footers
// because they were already printed before on this same loop
addPage(doc, table, startPos, cursor, firstColumnsToFit, true);
} else {
printHead(doc, table, cursor, firstColumnsToFit);
}
lastPrintedRowIndex = printBodyWithoutPageBreaks(doc, table, lastRowIndexOfLastPage_1 + 1, cursor, firstColumnsToFit);
printFoot(doc, table, cursor, firstColumnsToFit);
}
// Check how many rows were printed, so that the next columns would not print more rows than that
var maxNumberOfRows = lastPrintedRowIndex - lastRowIndexOfLastPage_1;
// Print the next columns, never exceding maxNumberOfRows
allColumnsCanFitResult.slice(1).forEach(function(colsAndIndexes) {
doc.applyStyles(doc.userStyles);
// When adding a page here, make sure not to print the footers
// because they were already printed before on this same loop
addPage(doc, table, startPos, cursor, colsAndIndexes.columns, true);
printBodyWithoutPageBreaks(doc, table, lastRowIndexOfLastPage_1 + 1, cursor, colsAndIndexes.columns, maxNumberOfRows);
printFoot(doc, table, cursor, colsAndIndexes.columns);
});
lastRowIndexOfLastPage_1 = lastPrintedRowIndex;
};
while(lastRowIndexOfLastPage_1 < table.body.length - 1){
_loop_1();
}
}
}
function printHead(doc, table, cursor, columns) {
var settings = table.settings;
doc.applyStyles(doc.userStyles);
if (settings.showHead === 'firstPage' || settings.showHead === 'everyPage') {
table.head.forEach(function(row) {
return printRow(doc, table, row, cursor, columns);
});
}
}
function printBody(doc, table, startPos, cursor, columns) {
doc.applyStyles(doc.userStyles);
table.body.forEach(function(row, index) {
var isLastRow = index === table.body.length - 1;
printFullRow(doc, table, row, isLastRow, startPos, cursor, columns);
});
}
function printBodyWithoutPageBreaks(doc, table, startRowIndex, cursor, columns, maxNumberOfRows) {
doc.applyStyles(doc.userStyles);
maxNumberOfRows = maxNumberOfRows !== null && maxNumberOfRows !== void 0 ? maxNumberOfRows : table.body.length;
var endRowIndex = Math.min(startRowIndex + maxNumberOfRows, table.body.length);
var lastPrintedRowIndex = -1;
table.body.slice(startRowIndex, endRowIndex).forEach(function(row, index) {
var isLastRow = startRowIndex + index === table.body.length - 1;
var remainingSpace = getRemainingPageSpace(doc, table, isLastRow, cursor);
if (row.canEntireRowFit(remainingSpace, columns)) {
printRow(doc, table, row, cursor, columns);
lastPrintedRowIndex = startRowIndex + index;
}
});
return lastPrintedRowIndex;
}
function printFoot(doc, table, cursor, columns) {
var settings = table.settings;
doc.applyStyles(doc.userStyles);
if (settings.showFoot === 'lastPage' || settings.showFoot === 'everyPage') {
table.foot.forEach(function(row) {
return printRow(doc, table, row, cursor, columns);
});
}
}
function getRemainingLineCount(cell, remainingPageSpace, doc) {
var lineHeight = doc.getLineHeight(cell.styles.fontSize);
var vPadding = cell.padding('vertical');
var remainingLines = Math.floor((remainingPageSpace - vPadding) / lineHeight);
return Math.max(0, remainingLines);
}
function modifyRowToFit(row, remainingPageSpace, table, doc) {
var cells = {};
row.spansMultiplePages = true;
row.height = 0;
var rowHeight = 0;
for(var _i = 0, _a = table.columns; _i < _a.length; _i++){
var column = _a[_i];
var cell = row.cells[column.index];
if (!cell) continue;
if (!Array.isArray(cell.text)) {
cell.text = [
cell.text
];
}
var remainderCell = new Cell(cell.raw, cell.styles, cell.section);
remainderCell = assign(remainderCell, cell);
remainderCell.text = [];
var remainingLineCount = getRemainingLineCount(cell, remainingPageSpace, doc);
if (cell.text.length > remainingLineCount) {
remainderCell.text = cell.text.splice(remainingLineCount, cell.text.length);
}
var scaleFactor = doc.scaleFactor();
var lineHeightFactor = doc.getLineHeightFactor();
cell.contentHeight = cell.getContentHeight(scaleFactor, lineHeightFactor);
if (cell.contentHeight >= remainingPageSpace) {
cell.contentHeight = remainingPageSpace;
remainderCell.styles.minCellHeight -= remainingPageSpace;
}
if (cell.contentHeight > row.height) {
row.height = cell.contentHeight;
}
remainderCell.contentHeight = remainderCell.getContentHeight(scaleFactor, lineHeightFactor);
if (remainderCell.contentHeight > rowHeight) {
rowHeight = remainderCell.contentHeight;
}
cells[column.index] = remainderCell;
}
var remainderRow = new Row(row.raw, -1, row.section, cells, true);
remainderRow.height = rowHeight;
for(var _b = 0, _c = table.columns; _b < _c.length; _b++){
var column = _c[_b];
var remainderCell = remainderRow.cells[column.index];
if (remainderCell) {
remainderCell.height = remainderRow.height;
}
var cell = row.cells[column.index];
if (cell) {
cell.height = row.height;
}
}
return remainderRow;
}
function shouldPrintOnCurrentPage(doc, row, remainingPageSpace, table) {
var pageHeight = doc.pageSize().height;
var margin = table.settings.margin;
var marginHeight = margin.top + margin.bottom;
var maxRowHeight = pageHeight - marginHeight;
if (row.section === 'body') {
// Should also take into account that head and foot is not
// on every page with some settings
maxRowHeight -= table.getHeadHeight(table.columns) + table.getFootHeight(table.columns);
}
var minRowHeight = row.getMinimumRowHeight(table.columns, doc);
var minRowFits = minRowHeight < remainingPageSpace;
if (minRowHeight > maxRowHeight) {
console.log("Will not be able to print row ".concat(row.index, " correctly since it's minimum height is larger than page height"));
return true;
}
if (!minRowFits) {
return false;
}
var rowHasRowSpanCell = row.hasRowSpan(table.columns);
var rowHigherThanPage = row.getMaxCellHeight(table.columns) > maxRowHeight;
if (rowHigherThanPage) {
if (rowHasRowSpanCell) {
console.log("The content of row ".concat(row.index, " will not be drawn correctly since drawing rows with a height larger than the page height and has cells with rowspans is not supported."));
}
return true;
}
if (rowHasRowSpanCell) {
// Currently a new page is required whenever a rowspan row don't fit a page.
return false;
}
if (table.settings.rowPageBreak === 'avoid') {
return false;
}
// In all other cases print the row on current page
return true;
}
function printFullRow(doc, table, row, isLastRow, startPos, cursor, columns) {
var remainingSpace = getRemainingPageSpace(doc, table, isLastRow, cursor);
if (row.canEntireRowFit(remainingSpace, columns)) {
// The row fits in the current page
printRow(doc, table, row, cursor, columns);
} else if (shouldPrintOnCurrentPage(doc, row, remainingSpace, table)) {
// The row gets split in two here, each piece in one page
var remainderRow = modifyRowToFit(row, remainingSpace, table, doc);
printRow(doc, table, row, cursor, columns);
addPage(doc, table, startPos, cursor, columns);
printFullRow(doc, table, remainderRow, isLastRow, startPos, cursor, columns);
} else {
// The row get printed entirelly on the next page
addPage(doc, table, startPos, cursor, columns);
printFullRow(doc, table, row, isLastRow, startPos, cursor, columns);
}
}
function printRow(doc, table, row, cursor, columns) {
cursor.x = table.settings.margin.left;
for(var _i = 0, columns_1 = columns; _i < columns_1.length; _i++){
var column = columns_1[_i];
var cell = row.cells[column.index];
if (!cell) {
cursor.x += column.width;
continue;
}
doc.applyStyles(cell.styles);
cell.x = cursor.x;
cell.y = cursor.y;
var result = table.callCellHooks(doc, table.hooks.willDrawCell, cell, row, column, cursor);
if (result === false) {
cursor.x += column.width;
continue;
}
drawCellRect(doc, cell, cursor);
var textPos = cell.getTextPos();
autoTableText(cell.text, textPos.x, textPos.y, {
halign: cell.styles.halign,
valign: cell.styles.valign,
maxWidth: Math.ceil(cell.width - cell.padding('left') - cell.padding('right'))
}, doc.getDocument());
table.callCellHooks(doc, table.hooks.didDrawCell, cell, row, column, cursor);
cursor.x += column.width;
}
cursor.y += row.height;
}
function drawCellRect(doc, cell, cursor) {
var cellStyles = cell.styles;
// https://github.com/simonbengtsson/jsPDF-AutoTable/issues/774
// TODO (v4): better solution?
doc.getDocument().setFillColor(doc.getDocument().getFillColor());
if (typeof cellStyles.lineWidth === 'number') {
// Draw cell background with normal borders
var fillStyle = getFillStyle(cellStyles.lineWidth, cellStyles.fillColor);
if (fillStyle) {
doc.rect(cell.x, cursor.y, cell.width, cell.height, fillStyle);
}
} else if (typeof cellStyles.lineWidth === 'object') {
// Draw cell background
if (cellStyles.fillColor) {
doc.rect(cell.x, cursor.y, cell.width, cell.height, 'F');
}
// Draw cell individual borders
drawCellBorders(doc, cell, cursor, cellStyles.lineWidth);
}
}
/**
* Draw all specified borders. Borders are centered on cell's edge and lengthened
* to overlap with neighbours to create sharp corners.
* @param doc
* @param cell
* @param cursor
* @param fillColor
* @param lineWidth
*/ function drawCellBorders(doc, cell, cursor, lineWidth) {
var x1, y1, x2, y2;
if (lineWidth.top) {
x1 = cursor.x;
y1 = cursor.y;
x2 = cursor.x + cell.width;
y2 = cursor.y;
if (lineWidth.right) {
x2 += 0.5 * lineWidth.right;
}
if (lineWidth.left) {
x1 -= 0.5 * lineWidth.left;
}
drawLine(lineWidth.top, x1, y1, x2, y2);
}
if (lineWidth.bottom) {
x1 = cursor.x;
y1 = cursor.y + cell.height;
x2 = cursor.x + cell.width;
y2 = cursor.y + cell.height;
if (lineWidth.right) {
x2 += 0.5 * lineWidth.right;
}
if (lineWidth.left) {
x1 -= 0.5 * lineWidth.left;
}
drawLine(lineWidth.bottom, x1, y1, x2, y2);
}
if (lineWidth.left) {
x1 = cursor.x;
y1 = cursor.y;
x2 = cursor.x;
y2 = cursor.y + cell.height;
if (lineWidth.top) {
y1 -= 0.5 * lineWidth.top;
}
if (lineWidth.bottom) {
y2 += 0.5 * lineWidth.bottom;
}
drawLine(lineWidth.left, x1, y1, x2, y2);
}
if (lineWidth.right) {
x1 = cursor.x + cell.width;
y1 = cursor.y;
x2 = cursor.x + cell.width;
y2 = cursor.y + cell.height;
if (lineWidth.top) {
y1 -= 0.5 * lineWidth.top;
}
if (lineWidth.bottom) {
y2 += 0.5 * lineWidth.bottom;
}
drawLine(lineWidth.right, x1, y1, x2, y2);
}
function drawLine(width, x1, y1, x2, y2) {
doc.getDocument().setLineWidth(width);
doc.getDocument().line(x1, y1, x2, y2, 'S');
}
}
function getRemainingPageSpace(doc, table, isLastRow, cursor) {
var bottomContentHeight = table.settings.margin.bottom;
var showFoot = table.settings.showFoot;
if (showFoot === 'everyPage' || showFoot === 'lastPage' && isLastRow) {
bottomContentHeight += table.getFootHeight(table.columns);
}
return doc.pageSize().height - cursor.y - bottomContentHeight;
}
function addPage(doc, table, startPos, cursor, columns, suppressFooter) {
if (columns === void 0) {
columns = [];
}
if (suppressFooter === void 0) {
suppressFooter = false;
}
doc.applyStyles(doc.userStyles);
if (table.settings.showFoot === 'everyPage' && !suppressFooter) {
table.foot.forEach(function(row) {
return printRow(doc, table, row, cursor, columns);
});
}
// Add user content just before adding new page ensure it will
// be drawn above other things on the page
table.callEndPageHooks(doc, cursor);
var margin = table.settings.margin;
addTableBorder(doc, table, startPos, cursor);
nextPage(doc);
table.pageNumber++;
cursor.x = margin.left;
cursor.y = margin.top;
startPos.y = margin.top;
// call didAddPage hooks before any content is added to the page
table.callWillDrawPageHooks(doc, cursor);
if (table.settings.showHead === 'everyPage') {
table.head.forEach(function(row) {
return printRow(doc, table, row, cursor, columns);
});
doc.applyStyles(doc.userStyles);
}
}
function nextPage(doc) {
var current = doc.pageNumber();
doc.setPage(current + 1);
var newCurrent = doc.pageNumber();
if (newCurrent === current) {
doc.addPage();
return true;
}
return false;
}
function applyPlugin(jsPDF) {
// eslint-disable-next-line @typescript-eslint/no-explicit-any
jsPDF.API.autoTable = function() {
var args = [];
for(var _i = 0; _i < arguments.length; _i++){
args[_i] = arguments[_i];
}
var options = args[0];
var input = parseInput(this, options);
var table = createTable(this, input);
drawTable(this, table);
return this;
};
// Assign false to enable `doc.lastAutoTable.finalY || 40` sugar
jsPDF.API.lastAutoTable = false;
jsPDF.API.autoTableText = function(text, x, y, styles) {
autoTableText(text, x, y, styles, this);
};
jsPDF.API.autoTableSetDefaults = function(defaults) {
DocHandler.setDefaults(defaults, this);
return this;
};
jsPDF.autoTableSetDefaults = function(defaults, doc) {
DocHandler.setDefaults(defaults, doc);
};
jsPDF.API.autoTableHtmlToJson = function(tableElem, includeHiddenElements) {
var _a;
if (includeHiddenElements === void 0) {
includeHiddenElements = false;
}
if ("TURBOPACK compile-time truthy", 1) {
console.error('Cannot run autoTableHtmlToJson in non browser environment');
return null;
}
//TURBOPACK unreachable
;
var doc;
var _b, head, body;
var columns;
};
}
var _a;
function autoTable(d, options) {
var input = parseInput(d, options);
var table = createTable(d, input);
drawTable(d, table);
}
// Experimental export
function __createTable(d, options) {
var input = parseInput(d, options);
return createTable(d, input);
}
function __drawTable(d, table) {
drawTable(d, table);
}
try {
if ("TURBOPACK compile-time falsy", 0) //TURBOPACK unreachable
{
// eslint-disable-next-line @typescript-eslint/no-explicit-any
var anyWindow;
var jsPDF;
}
} catch (error) {
console.error('Could not apply autoTable plugin', error);
}
;
}),
];
//# sourceMappingURL=node_modules_019cy5-._.js.map