{"version":3,"file":"npm.domhandler.js","mappings":";;;;;;;;;AAAa;AACb;AACA;AACA,mCAAmC,oCAAoC,gBAAgB;AACvF,CAAC;AACD;AACA;AACA,CAAC;AACD;AACA;AACA;AACA,8CAA6C,EAAE,aAAa,EAAC;AAC7D,kBAAkB;AAClB,aAAa,mBAAO,CAAC,qDAAQ;AAC7B,aAAa,mBAAO,CAAC,qDAAQ;AAC7B;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,CAAC;AACD,kBAAkB;AAClB,kBAAe;;;;;;;;;;;AC/KF;AACb;AACA;AACA;AACA,eAAe,gBAAgB,sCAAsC,kBAAkB;AACvF,8BAA8B;AAC9B;AACA;AACA;AACA;AACA,wBAAwB;AACxB;AACA;AACA,CAAC;AACD;AACA;AACA,iDAAiD,OAAO;AACxD;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,8CAA6C,EAAE,aAAa,EAAC;AAC7D,iBAAiB,GAAG,eAAe,GAAG,wBAAwB,GAAG,6BAA6B,GAAG,eAAe,GAAG,YAAY,GAAG,gBAAgB,GAAG,YAAY;AACjK;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,SAAS;AACT;AACA;AACA,KAAK;AACL;AACA;AACA;AACA;AACA,SAAS;AACT;AACA;AACA,SAAS;AACT;AACA;AACA,KAAK;AACL;AACA;AACA;AACA,SAAS;AACT;AACA;AACA,SAAS;AACT;AACA;AACA,KAAK;AACL;AACA;AACA;AACA,SAAS;AACT;AACA;AACA,SAAS;AACT;AACA;AACA,KAAK;AACL;AACA;AACA;AACA;AACA;AACA;AACA;AACA,oCAAoC;AACpC;AACA;AACA;AACA,CAAC;AACD,YAAY;AACZ;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,SAAS;AACT;AACA;AACA,SAAS;AACT;AACA;AACA,KAAK;AACL;AACA,CAAC;AACD,gBAAgB;AAChB;AACA;AACA;AACA;AACA;AACA;AACA,CAAC;AACD,YAAY;AACZ;AACA;AACA;AACA;AACA;AACA;AACA,CAAC;AACD,eAAe;AACf;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,CAAC;AACD,6BAA6B;AAC7B;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,SAAS;AACT;AACA;AACA,KAAK;AACL;AACA;AACA;AACA;AACA;AACA,SAAS;AACT;AACA;AACA,KAAK;AACL;AACA;AACA;AACA,SAAS;AACT;AACA;AACA,SAAS;AACT;AACA;AACA,KAAK;AACL;AACA,CAAC;AACD,wBAAwB;AACxB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,mCAAmC;AACnC;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,SAAS;AACT;AACA;AACA,SAAS;AACT;AACA;AACA,KAAK;AACL;AACA;AACA;AACA,mEAAmE;AACnE;AACA;AACA,aAAa,IAAI;AACjB,SAAS;AACT;AACA;AACA,KAAK;AACL;AACA,CAAC;AACD,eAAe;AACf;AACA;AACA;AACA;AACA;AACA;AACA;AACA,gCAAgC;AAChC;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,4DAA4D;AAC5D,gDAAgD,kCAAkC;AAClF;AACA;AACA;AACA;AACA;AACA;AACA,gDAAgD,kCAAkC;AAClF;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,iBAAiB;AACjB;AACA,iDAAiD,gCAAgC;AACjF,oBAAoB,qBAAqB;AACzC;AACA;AACA;AACA;AACA","sources":["webpack://giveeasy.cloud/./node_modules/domhandler/lib/index.js","webpack://giveeasy.cloud/./node_modules/domhandler/lib/node.js"],"sourcesContent":["\"use strict\";\nvar __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {\n if (k2 === undefined) k2 = k;\n Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });\n}) : (function(o, m, k, k2) {\n if (k2 === undefined) k2 = k;\n o[k2] = m[k];\n}));\nvar __exportStar = (this && this.__exportStar) || function(m, exports) {\n for (var p in m) if (p !== \"default\" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);\n};\nObject.defineProperty(exports, \"__esModule\", { value: true });\nexports.DomHandler = void 0;\nvar node_1 = require(\"./node\");\n__exportStar(require(\"./node\"), exports);\nvar reWhitespace = /\\s+/g;\n// Default options\nvar defaultOpts = {\n normalizeWhitespace: false,\n withStartIndices: false,\n withEndIndices: false,\n};\nvar DomHandler = /** @class */ (function () {\n /**\n * @param callback Called once parsing has completed.\n * @param options Settings for the handler.\n * @param elementCB Callback whenever a tag is closed.\n */\n function DomHandler(callback, options, elementCB) {\n /** The constructed DOM */\n this.dom = [];\n /** Indicated whether parsing has been completed. */\n this._done = false;\n /** Stack of open tags. */\n this._tagStack = [];\n /** A data node that is still being written to. */\n this._lastNode = null;\n /** Reference to the parser instance. Used for location information. */\n this._parser = null;\n // Make it possible to skip arguments, for backwards-compatibility\n if (typeof options === \"function\") {\n elementCB = options;\n options = defaultOpts;\n }\n if (typeof callback === \"object\") {\n options = callback;\n callback = undefined;\n }\n this._callback = callback !== null && callback !== void 0 ? callback : null;\n this._options = options !== null && options !== void 0 ? options : defaultOpts;\n this._elementCB = elementCB !== null && elementCB !== void 0 ? elementCB : null;\n }\n DomHandler.prototype.onparserinit = function (parser) {\n this._parser = parser;\n };\n // Resets the handler back to starting state\n DomHandler.prototype.onreset = function () {\n var _a;\n this.dom = [];\n this._done = false;\n this._tagStack = [];\n this._lastNode = null;\n this._parser = (_a = this._parser) !== null && _a !== void 0 ? _a : null;\n };\n // Signals the handler that parsing is done\n DomHandler.prototype.onend = function () {\n if (this._done)\n return;\n this._done = true;\n this._parser = null;\n this.handleCallback(null);\n };\n DomHandler.prototype.onerror = function (error) {\n this.handleCallback(error);\n };\n DomHandler.prototype.onclosetag = function () {\n this._lastNode = null;\n var elem = this._tagStack.pop();\n if (!elem || !this._parser) {\n return;\n }\n if (this._options.withEndIndices) {\n elem.endIndex = this._parser.endIndex;\n }\n if (this._elementCB)\n this._elementCB(elem);\n };\n DomHandler.prototype.onopentag = function (name, attribs) {\n var element = new node_1.Element(name, attribs);\n this.addNode(element);\n this._tagStack.push(element);\n };\n DomHandler.prototype.ontext = function (data) {\n var normalize = this._options.normalizeWhitespace;\n var _lastNode = this._lastNode;\n if (_lastNode && _lastNode.type === \"text\" /* Text */) {\n if (normalize) {\n _lastNode.data = (_lastNode.data + data).replace(reWhitespace, \" \");\n }\n else {\n _lastNode.data += data;\n }\n }\n else {\n if (normalize) {\n data = data.replace(reWhitespace, \" \");\n }\n var node = new node_1.Text(data);\n this.addNode(node);\n this._lastNode = node;\n }\n };\n DomHandler.prototype.oncomment = function (data) {\n if (this._lastNode && this._lastNode.type === \"comment\" /* Comment */) {\n this._lastNode.data += data;\n return;\n }\n var node = new node_1.Comment(data);\n this.addNode(node);\n this._lastNode = node;\n };\n DomHandler.prototype.oncommentend = function () {\n this._lastNode = null;\n };\n DomHandler.prototype.oncdatastart = function () {\n var text = new node_1.Text(\"\");\n var node = new node_1.NodeWithChildren(\"cdata\" /* CDATA */, [text]);\n this.addNode(node);\n text.parent = node;\n this._lastNode = text;\n };\n DomHandler.prototype.oncdataend = function () {\n this._lastNode = null;\n };\n DomHandler.prototype.onprocessinginstruction = function (name, data) {\n var node = new node_1.ProcessingInstruction(name, data);\n this.addNode(node);\n };\n DomHandler.prototype.handleCallback = function (error) {\n if (typeof this._callback === \"function\") {\n this._callback(error, this.dom);\n }\n else if (error) {\n throw error;\n }\n };\n DomHandler.prototype.addNode = function (node) {\n var parent = this._tagStack[this._tagStack.length - 1];\n var siblings = parent ? parent.children : this.dom;\n var previousSibling = siblings[siblings.length - 1];\n if (this._parser) {\n if (this._options.withStartIndices) {\n node.startIndex = this._parser.startIndex;\n }\n if (this._options.withEndIndices) {\n node.endIndex = this._parser.endIndex;\n }\n }\n siblings.push(node);\n if (previousSibling) {\n node.prev = previousSibling;\n previousSibling.next = node;\n }\n if (parent) {\n node.parent = parent;\n }\n this._lastNode = null;\n };\n DomHandler.prototype.addDataNode = function (node) {\n this.addNode(node);\n this._lastNode = node;\n };\n return DomHandler;\n}());\nexports.DomHandler = DomHandler;\nexports.default = DomHandler;\n","\"use strict\";\nvar __extends = (this && this.__extends) || (function () {\n var extendStatics = function (d, b) {\n extendStatics = Object.setPrototypeOf ||\n ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||\n function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };\n return extendStatics(d, b);\n };\n return function (d, b) {\n extendStatics(d, b);\n function __() { this.constructor = d; }\n d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());\n };\n})();\nvar __assign = (this && this.__assign) || function () {\n __assign = Object.assign || function(t) {\n for (var s, i = 1, n = arguments.length; i < n; i++) {\n s = arguments[i];\n for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))\n t[p] = s[p];\n }\n return t;\n };\n return __assign.apply(this, arguments);\n};\nObject.defineProperty(exports, \"__esModule\", { value: true });\nexports.cloneNode = exports.Element = exports.NodeWithChildren = exports.ProcessingInstruction = exports.Comment = exports.Text = exports.DataNode = exports.Node = void 0;\nvar nodeTypes = new Map([\n [\"tag\" /* Tag */, 1],\n [\"script\" /* Script */, 1],\n [\"style\" /* Style */, 1],\n [\"directive\" /* Directive */, 1],\n [\"text\" /* Text */, 3],\n [\"cdata\" /* CDATA */, 4],\n [\"comment\" /* Comment */, 8],\n]);\n/**\n * This object will be used as the prototype for Nodes when creating a\n * DOM-Level-1-compliant structure.\n */\nvar Node = /** @class */ (function () {\n /**\n *\n * @param type The type of the node.\n */\n function Node(type) {\n this.type = type;\n /** Parent of the node */\n this.parent = null;\n /** Previous sibling */\n this.prev = null;\n /** Next sibling */\n this.next = null;\n /** The start index of the node. Requires `withStartIndices` on the handler to be `true. */\n this.startIndex = null;\n /** The end index of the node. Requires `withEndIndices` on the handler to be `true. */\n this.endIndex = null;\n }\n Object.defineProperty(Node.prototype, \"nodeType\", {\n // Read-only aliases\n get: function () {\n var _a;\n return (_a = nodeTypes.get(this.type)) !== null && _a !== void 0 ? _a : 1;\n },\n enumerable: false,\n configurable: true\n });\n Object.defineProperty(Node.prototype, \"parentNode\", {\n // Read-write aliases for properties\n get: function () {\n return this.parent;\n },\n set: function (parent) {\n this.parent = parent;\n },\n enumerable: false,\n configurable: true\n });\n Object.defineProperty(Node.prototype, \"previousSibling\", {\n get: function () {\n return this.prev;\n },\n set: function (prev) {\n this.prev = prev;\n },\n enumerable: false,\n configurable: true\n });\n Object.defineProperty(Node.prototype, \"nextSibling\", {\n get: function () {\n return this.next;\n },\n set: function (next) {\n this.next = next;\n },\n enumerable: false,\n configurable: true\n });\n /**\n * Clone this node, and optionally its children.\n *\n * @param recursive Clone child nodes as well.\n * @returns A clone of the node.\n */\n Node.prototype.cloneNode = function (recursive) {\n if (recursive === void 0) { recursive = false; }\n return cloneNode(this, recursive);\n };\n return Node;\n}());\nexports.Node = Node;\nvar DataNode = /** @class */ (function (_super) {\n __extends(DataNode, _super);\n /**\n * @param type The type of the node\n * @param data The content of the data node\n */\n function DataNode(type, data) {\n var _this = _super.call(this, type) || this;\n _this.data = data;\n return _this;\n }\n Object.defineProperty(DataNode.prototype, \"nodeValue\", {\n get: function () {\n return this.data;\n },\n set: function (data) {\n this.data = data;\n },\n enumerable: false,\n configurable: true\n });\n return DataNode;\n}(Node));\nexports.DataNode = DataNode;\nvar Text = /** @class */ (function (_super) {\n __extends(Text, _super);\n function Text(data) {\n return _super.call(this, \"text\" /* Text */, data) || this;\n }\n return Text;\n}(DataNode));\nexports.Text = Text;\nvar Comment = /** @class */ (function (_super) {\n __extends(Comment, _super);\n function Comment(data) {\n return _super.call(this, \"comment\" /* Comment */, data) || this;\n }\n return Comment;\n}(DataNode));\nexports.Comment = Comment;\nvar ProcessingInstruction = /** @class */ (function (_super) {\n __extends(ProcessingInstruction, _super);\n function ProcessingInstruction(name, data) {\n var _this = _super.call(this, \"directive\" /* Directive */, data) || this;\n _this.name = name;\n return _this;\n }\n return ProcessingInstruction;\n}(DataNode));\nexports.ProcessingInstruction = ProcessingInstruction;\nvar NodeWithChildren = /** @class */ (function (_super) {\n __extends(NodeWithChildren, _super);\n /**\n *\n * @param type Type of the node.\n * @param children Children of the node. Only certain node types can have children.\n */\n function NodeWithChildren(type, children) {\n var _this = _super.call(this, type) || this;\n _this.children = children;\n return _this;\n }\n Object.defineProperty(NodeWithChildren.prototype, \"firstChild\", {\n // Aliases\n get: function () {\n var _a;\n return (_a = this.children[0]) !== null && _a !== void 0 ? _a : null;\n },\n enumerable: false,\n configurable: true\n });\n Object.defineProperty(NodeWithChildren.prototype, \"lastChild\", {\n get: function () {\n return this.children.length > 0\n ? this.children[this.children.length - 1]\n : null;\n },\n enumerable: false,\n configurable: true\n });\n Object.defineProperty(NodeWithChildren.prototype, \"childNodes\", {\n get: function () {\n return this.children;\n },\n set: function (children) {\n this.children = children;\n },\n enumerable: false,\n configurable: true\n });\n return NodeWithChildren;\n}(Node));\nexports.NodeWithChildren = NodeWithChildren;\nvar Element = /** @class */ (function (_super) {\n __extends(Element, _super);\n /**\n * @param name Name of the tag, eg. `div`, `span`.\n * @param attribs Object mapping attribute names to attribute values.\n * @param children Children of the node.\n */\n function Element(name, attribs, children) {\n if (children === void 0) { children = []; }\n var _this = _super.call(this, name === \"script\"\n ? \"script\" /* Script */\n : name === \"style\"\n ? \"style\" /* Style */\n : \"tag\" /* Tag */, children) || this;\n _this.name = name;\n _this.attribs = attribs;\n _this.attribs = attribs;\n return _this;\n }\n Object.defineProperty(Element.prototype, \"tagName\", {\n // DOM Level 1 aliases\n get: function () {\n return this.name;\n },\n set: function (name) {\n this.name = name;\n },\n enumerable: false,\n configurable: true\n });\n Object.defineProperty(Element.prototype, \"attributes\", {\n get: function () {\n var _this = this;\n return Object.keys(this.attribs).map(function (name) { return ({\n name: name,\n value: _this.attribs[name],\n }); });\n },\n enumerable: false,\n configurable: true\n });\n return Element;\n}(NodeWithChildren));\nexports.Element = Element;\n/**\n * Clone a node, and optionally its children.\n *\n * @param recursive Clone child nodes as well.\n * @returns A clone of the node.\n */\nfunction cloneNode(node, recursive) {\n if (recursive === void 0) { recursive = false; }\n switch (node.type) {\n case \"text\" /* Text */:\n return new Text(node.data);\n case \"directive\" /* Directive */: {\n var instr = node;\n return new ProcessingInstruction(instr.name, instr.data);\n }\n case \"comment\" /* Comment */:\n return new Comment(node.data);\n case \"tag\" /* Tag */:\n case \"script\" /* Script */:\n case \"style\" /* Style */: {\n var elem = node;\n var children = recursive ? cloneChildren(elem.children) : [];\n var clone_1 = new Element(elem.name, __assign({}, elem.attribs), children);\n children.forEach(function (child) { return (child.parent = clone_1); });\n return clone_1;\n }\n case \"cdata\" /* CDATA */: {\n var cdata = node;\n var children = recursive ? cloneChildren(cdata.children) : [];\n var clone_2 = new NodeWithChildren(\"cdata\" /* CDATA */, children);\n children.forEach(function (child) { return (child.parent = clone_2); });\n return clone_2;\n }\n case \"doctype\" /* Doctype */: {\n // This type isn't used yet.\n throw new Error(\"Not implemented yet: ElementType.Doctype case\");\n }\n }\n}\nexports.cloneNode = cloneNode;\nfunction cloneChildren(childs) {\n var children = childs.map(function (child) { return cloneNode(child, true); });\n for (var i = 1; i < children.length; i++) {\n children[i].prev = children[i - 1];\n children[i - 1].next = children[i];\n }\n return children;\n}\n"],"names":[],"sourceRoot":""}