@d1g1tal/transportr 0.1.3 → 0.1.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,9 +1,14 @@
1
1
  var Transportr = (() => {
2
+ var __create = Object.create;
2
3
  var __defProp = Object.defineProperty;
3
4
  var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
5
  var __getOwnPropNames = Object.getOwnPropertyNames;
6
+ var __getProtoOf = Object.getPrototypeOf;
5
7
  var __hasOwnProp = Object.prototype.hasOwnProperty;
6
8
  var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
9
+ var __commonJS = (cb, mod) => function __require() {
10
+ return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
11
+ };
7
12
  var __export = (target, all) => {
8
13
  for (var name in all)
9
14
  __defProp(target, name, { get: all[name], enumerable: true });
@@ -16,6 +21,14 @@ var Transportr = (() => {
16
21
  }
17
22
  return to;
18
23
  };
24
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
25
+ // If the importer is in node compatibility mode or this is not an ESM
26
+ // file that has been converted to a CommonJS file using a Babel-
27
+ // compatible transform (i.e. "__esModule" has not been set), then set
28
+ // "default" to the CommonJS "module.exports" for node compatibility.
29
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
30
+ mod
31
+ ));
19
32
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
20
33
  var __publicField = (obj, key, value) => {
21
34
  __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
@@ -44,6 +57,2605 @@ var Transportr = (() => {
44
57
  return method;
45
58
  };
46
59
 
60
+ // node_modules/@xmldom/xmldom/lib/conventions.js
61
+ var require_conventions = __commonJS({
62
+ "node_modules/@xmldom/xmldom/lib/conventions.js"(exports) {
63
+ "use strict";
64
+ function find(list, predicate, ac) {
65
+ if (ac === void 0) {
66
+ ac = Array.prototype;
67
+ }
68
+ if (list && typeof ac.find === "function") {
69
+ return ac.find.call(list, predicate);
70
+ }
71
+ for (var i = 0; i < list.length; i++) {
72
+ if (Object.prototype.hasOwnProperty.call(list, i)) {
73
+ var item = list[i];
74
+ if (predicate.call(void 0, item, i, list)) {
75
+ return item;
76
+ }
77
+ }
78
+ }
79
+ }
80
+ function freeze(object, oc) {
81
+ if (oc === void 0) {
82
+ oc = Object;
83
+ }
84
+ return oc && typeof oc.freeze === "function" ? oc.freeze(object) : object;
85
+ }
86
+ function assign(target, source) {
87
+ if (target === null || typeof target !== "object") {
88
+ throw new TypeError("target is not an object");
89
+ }
90
+ for (var key in source) {
91
+ if (Object.prototype.hasOwnProperty.call(source, key)) {
92
+ target[key] = source[key];
93
+ }
94
+ }
95
+ return target;
96
+ }
97
+ var MIME_TYPE = freeze({
98
+ /**
99
+ * `text/html`, the only mime type that triggers treating an XML document as HTML.
100
+ *
101
+ * @see DOMParser.SupportedType.isHTML
102
+ * @see https://www.iana.org/assignments/media-types/text/html IANA MimeType registration
103
+ * @see https://en.wikipedia.org/wiki/HTML Wikipedia
104
+ * @see https://developer.mozilla.org/en-US/docs/Web/API/DOMParser/parseFromString MDN
105
+ * @see https://html.spec.whatwg.org/multipage/dynamic-markup-insertion.html#dom-domparser-parsefromstring WHATWG HTML Spec
106
+ */
107
+ HTML: "text/html",
108
+ /**
109
+ * Helper method to check a mime type if it indicates an HTML document
110
+ *
111
+ * @param {string} [value]
112
+ * @returns {boolean}
113
+ *
114
+ * @see https://www.iana.org/assignments/media-types/text/html IANA MimeType registration
115
+ * @see https://en.wikipedia.org/wiki/HTML Wikipedia
116
+ * @see https://developer.mozilla.org/en-US/docs/Web/API/DOMParser/parseFromString MDN
117
+ * @see https://html.spec.whatwg.org/multipage/dynamic-markup-insertion.html#dom-domparser-parsefromstring */
118
+ isHTML: function(value) {
119
+ return value === MIME_TYPE.HTML;
120
+ },
121
+ /**
122
+ * `application/xml`, the standard mime type for XML documents.
123
+ *
124
+ * @see https://www.iana.org/assignments/media-types/application/xml IANA MimeType registration
125
+ * @see https://tools.ietf.org/html/rfc7303#section-9.1 RFC 7303
126
+ * @see https://en.wikipedia.org/wiki/XML_and_MIME Wikipedia
127
+ */
128
+ XML_APPLICATION: "application/xml",
129
+ /**
130
+ * `text/html`, an alias for `application/xml`.
131
+ *
132
+ * @see https://tools.ietf.org/html/rfc7303#section-9.2 RFC 7303
133
+ * @see https://www.iana.org/assignments/media-types/text/xml IANA MimeType registration
134
+ * @see https://en.wikipedia.org/wiki/XML_and_MIME Wikipedia
135
+ */
136
+ XML_TEXT: "text/xml",
137
+ /**
138
+ * `application/xhtml+xml`, indicates an XML document that has the default HTML namespace,
139
+ * but is parsed as an XML document.
140
+ *
141
+ * @see https://www.iana.org/assignments/media-types/application/xhtml+xml IANA MimeType registration
142
+ * @see https://dom.spec.whatwg.org/#dom-domimplementation-createdocument WHATWG DOM Spec
143
+ * @see https://en.wikipedia.org/wiki/XHTML Wikipedia
144
+ */
145
+ XML_XHTML_APPLICATION: "application/xhtml+xml",
146
+ /**
147
+ * `image/svg+xml`,
148
+ *
149
+ * @see https://www.iana.org/assignments/media-types/image/svg+xml IANA MimeType registration
150
+ * @see https://www.w3.org/TR/SVG11/ W3C SVG 1.1
151
+ * @see https://en.wikipedia.org/wiki/Scalable_Vector_Graphics Wikipedia
152
+ */
153
+ XML_SVG_IMAGE: "image/svg+xml"
154
+ });
155
+ var NAMESPACE = freeze({
156
+ /**
157
+ * The XHTML namespace.
158
+ *
159
+ * @see http://www.w3.org/1999/xhtml
160
+ */
161
+ HTML: "http://www.w3.org/1999/xhtml",
162
+ /**
163
+ * Checks if `uri` equals `NAMESPACE.HTML`.
164
+ *
165
+ * @param {string} [uri]
166
+ *
167
+ * @see NAMESPACE.HTML
168
+ */
169
+ isHTML: function(uri) {
170
+ return uri === NAMESPACE.HTML;
171
+ },
172
+ /**
173
+ * The SVG namespace.
174
+ *
175
+ * @see http://www.w3.org/2000/svg
176
+ */
177
+ SVG: "http://www.w3.org/2000/svg",
178
+ /**
179
+ * The `xml:` namespace.
180
+ *
181
+ * @see http://www.w3.org/XML/1998/namespace
182
+ */
183
+ XML: "http://www.w3.org/XML/1998/namespace",
184
+ /**
185
+ * The `xmlns:` namespace
186
+ *
187
+ * @see https://www.w3.org/2000/xmlns/
188
+ */
189
+ XMLNS: "http://www.w3.org/2000/xmlns/"
190
+ });
191
+ exports.assign = assign;
192
+ exports.find = find;
193
+ exports.freeze = freeze;
194
+ exports.MIME_TYPE = MIME_TYPE;
195
+ exports.NAMESPACE = NAMESPACE;
196
+ }
197
+ });
198
+
199
+ // node_modules/@xmldom/xmldom/lib/dom.js
200
+ var require_dom = __commonJS({
201
+ "node_modules/@xmldom/xmldom/lib/dom.js"(exports) {
202
+ var conventions = require_conventions();
203
+ var find = conventions.find;
204
+ var NAMESPACE = conventions.NAMESPACE;
205
+ function notEmptyString(input) {
206
+ return input !== "";
207
+ }
208
+ function splitOnASCIIWhitespace(input) {
209
+ return input ? input.split(/[\t\n\f\r ]+/).filter(notEmptyString) : [];
210
+ }
211
+ function orderedSetReducer(current, element) {
212
+ if (!current.hasOwnProperty(element)) {
213
+ current[element] = true;
214
+ }
215
+ return current;
216
+ }
217
+ function toOrderedSet(input) {
218
+ if (!input)
219
+ return [];
220
+ var list = splitOnASCIIWhitespace(input);
221
+ return Object.keys(list.reduce(orderedSetReducer, {}));
222
+ }
223
+ function arrayIncludes(list) {
224
+ return function(element) {
225
+ return list && list.indexOf(element) !== -1;
226
+ };
227
+ }
228
+ function copy(src, dest) {
229
+ for (var p in src) {
230
+ if (Object.prototype.hasOwnProperty.call(src, p)) {
231
+ dest[p] = src[p];
232
+ }
233
+ }
234
+ }
235
+ function _extends(Class, Super) {
236
+ var pt = Class.prototype;
237
+ if (!(pt instanceof Super)) {
238
+ let t2 = function() {
239
+ };
240
+ var t = t2;
241
+ ;
242
+ t2.prototype = Super.prototype;
243
+ t2 = new t2();
244
+ copy(pt, t2);
245
+ Class.prototype = pt = t2;
246
+ }
247
+ if (pt.constructor != Class) {
248
+ if (typeof Class != "function") {
249
+ console.error("unknown Class:" + Class);
250
+ }
251
+ pt.constructor = Class;
252
+ }
253
+ }
254
+ var NodeType = {};
255
+ var ELEMENT_NODE = NodeType.ELEMENT_NODE = 1;
256
+ var ATTRIBUTE_NODE = NodeType.ATTRIBUTE_NODE = 2;
257
+ var TEXT_NODE = NodeType.TEXT_NODE = 3;
258
+ var CDATA_SECTION_NODE = NodeType.CDATA_SECTION_NODE = 4;
259
+ var ENTITY_REFERENCE_NODE = NodeType.ENTITY_REFERENCE_NODE = 5;
260
+ var ENTITY_NODE = NodeType.ENTITY_NODE = 6;
261
+ var PROCESSING_INSTRUCTION_NODE = NodeType.PROCESSING_INSTRUCTION_NODE = 7;
262
+ var COMMENT_NODE = NodeType.COMMENT_NODE = 8;
263
+ var DOCUMENT_NODE = NodeType.DOCUMENT_NODE = 9;
264
+ var DOCUMENT_TYPE_NODE = NodeType.DOCUMENT_TYPE_NODE = 10;
265
+ var DOCUMENT_FRAGMENT_NODE = NodeType.DOCUMENT_FRAGMENT_NODE = 11;
266
+ var NOTATION_NODE = NodeType.NOTATION_NODE = 12;
267
+ var ExceptionCode = {};
268
+ var ExceptionMessage = {};
269
+ var INDEX_SIZE_ERR = ExceptionCode.INDEX_SIZE_ERR = (ExceptionMessage[1] = "Index size error", 1);
270
+ var DOMSTRING_SIZE_ERR = ExceptionCode.DOMSTRING_SIZE_ERR = (ExceptionMessage[2] = "DOMString size error", 2);
271
+ var HIERARCHY_REQUEST_ERR = ExceptionCode.HIERARCHY_REQUEST_ERR = (ExceptionMessage[3] = "Hierarchy request error", 3);
272
+ var WRONG_DOCUMENT_ERR = ExceptionCode.WRONG_DOCUMENT_ERR = (ExceptionMessage[4] = "Wrong document", 4);
273
+ var INVALID_CHARACTER_ERR = ExceptionCode.INVALID_CHARACTER_ERR = (ExceptionMessage[5] = "Invalid character", 5);
274
+ var NO_DATA_ALLOWED_ERR = ExceptionCode.NO_DATA_ALLOWED_ERR = (ExceptionMessage[6] = "No data allowed", 6);
275
+ var NO_MODIFICATION_ALLOWED_ERR = ExceptionCode.NO_MODIFICATION_ALLOWED_ERR = (ExceptionMessage[7] = "No modification allowed", 7);
276
+ var NOT_FOUND_ERR = ExceptionCode.NOT_FOUND_ERR = (ExceptionMessage[8] = "Not found", 8);
277
+ var NOT_SUPPORTED_ERR = ExceptionCode.NOT_SUPPORTED_ERR = (ExceptionMessage[9] = "Not supported", 9);
278
+ var INUSE_ATTRIBUTE_ERR = ExceptionCode.INUSE_ATTRIBUTE_ERR = (ExceptionMessage[10] = "Attribute in use", 10);
279
+ var INVALID_STATE_ERR = ExceptionCode.INVALID_STATE_ERR = (ExceptionMessage[11] = "Invalid state", 11);
280
+ var SYNTAX_ERR = ExceptionCode.SYNTAX_ERR = (ExceptionMessage[12] = "Syntax error", 12);
281
+ var INVALID_MODIFICATION_ERR = ExceptionCode.INVALID_MODIFICATION_ERR = (ExceptionMessage[13] = "Invalid modification", 13);
282
+ var NAMESPACE_ERR = ExceptionCode.NAMESPACE_ERR = (ExceptionMessage[14] = "Invalid namespace", 14);
283
+ var INVALID_ACCESS_ERR = ExceptionCode.INVALID_ACCESS_ERR = (ExceptionMessage[15] = "Invalid access", 15);
284
+ function DOMException(code, message) {
285
+ if (message instanceof Error) {
286
+ var error = message;
287
+ } else {
288
+ error = this;
289
+ Error.call(this, ExceptionMessage[code]);
290
+ this.message = ExceptionMessage[code];
291
+ if (Error.captureStackTrace)
292
+ Error.captureStackTrace(this, DOMException);
293
+ }
294
+ error.code = code;
295
+ if (message)
296
+ this.message = this.message + ": " + message;
297
+ return error;
298
+ }
299
+ DOMException.prototype = Error.prototype;
300
+ copy(ExceptionCode, DOMException);
301
+ function NodeList() {
302
+ }
303
+ NodeList.prototype = {
304
+ /**
305
+ * The number of nodes in the list. The range of valid child node indices is 0 to length-1 inclusive.
306
+ * @standard level1
307
+ */
308
+ length: 0,
309
+ /**
310
+ * Returns the indexth item in the collection. If index is greater than or equal to the number of nodes in the list, this returns null.
311
+ * @standard level1
312
+ * @param index unsigned long
313
+ * Index into the collection.
314
+ * @return Node
315
+ * The node at the indexth position in the NodeList, or null if that is not a valid index.
316
+ */
317
+ item: function(index) {
318
+ return this[index] || null;
319
+ },
320
+ toString: function(isHTML, nodeFilter) {
321
+ for (var buf = [], i = 0; i < this.length; i++) {
322
+ serializeToString(this[i], buf, isHTML, nodeFilter);
323
+ }
324
+ return buf.join("");
325
+ },
326
+ /**
327
+ * @private
328
+ * @param {function (Node):boolean} predicate
329
+ * @returns {Node[]}
330
+ */
331
+ filter: function(predicate) {
332
+ return Array.prototype.filter.call(this, predicate);
333
+ },
334
+ /**
335
+ * @private
336
+ * @param {Node} item
337
+ * @returns {number}
338
+ */
339
+ indexOf: function(item) {
340
+ return Array.prototype.indexOf.call(this, item);
341
+ }
342
+ };
343
+ function LiveNodeList(node, refresh) {
344
+ this._node = node;
345
+ this._refresh = refresh;
346
+ _updateLiveList(this);
347
+ }
348
+ function _updateLiveList(list) {
349
+ var inc = list._node._inc || list._node.ownerDocument._inc;
350
+ if (list._inc != inc) {
351
+ var ls = list._refresh(list._node);
352
+ __set__(list, "length", ls.length);
353
+ copy(ls, list);
354
+ list._inc = inc;
355
+ }
356
+ }
357
+ LiveNodeList.prototype.item = function(i) {
358
+ _updateLiveList(this);
359
+ return this[i];
360
+ };
361
+ _extends(LiveNodeList, NodeList);
362
+ function NamedNodeMap() {
363
+ }
364
+ function _findNodeIndex(list, node) {
365
+ var i = list.length;
366
+ while (i--) {
367
+ if (list[i] === node) {
368
+ return i;
369
+ }
370
+ }
371
+ }
372
+ function _addNamedNode(el, list, newAttr, oldAttr) {
373
+ if (oldAttr) {
374
+ list[_findNodeIndex(list, oldAttr)] = newAttr;
375
+ } else {
376
+ list[list.length++] = newAttr;
377
+ }
378
+ if (el) {
379
+ newAttr.ownerElement = el;
380
+ var doc = el.ownerDocument;
381
+ if (doc) {
382
+ oldAttr && _onRemoveAttribute(doc, el, oldAttr);
383
+ _onAddAttribute(doc, el, newAttr);
384
+ }
385
+ }
386
+ }
387
+ function _removeNamedNode(el, list, attr) {
388
+ var i = _findNodeIndex(list, attr);
389
+ if (i >= 0) {
390
+ var lastIndex = list.length - 1;
391
+ while (i < lastIndex) {
392
+ list[i] = list[++i];
393
+ }
394
+ list.length = lastIndex;
395
+ if (el) {
396
+ var doc = el.ownerDocument;
397
+ if (doc) {
398
+ _onRemoveAttribute(doc, el, attr);
399
+ attr.ownerElement = null;
400
+ }
401
+ }
402
+ } else {
403
+ throw new DOMException(NOT_FOUND_ERR, new Error(el.tagName + "@" + attr));
404
+ }
405
+ }
406
+ NamedNodeMap.prototype = {
407
+ length: 0,
408
+ item: NodeList.prototype.item,
409
+ getNamedItem: function(key) {
410
+ var i = this.length;
411
+ while (i--) {
412
+ var attr = this[i];
413
+ if (attr.nodeName == key) {
414
+ return attr;
415
+ }
416
+ }
417
+ },
418
+ setNamedItem: function(attr) {
419
+ var el = attr.ownerElement;
420
+ if (el && el != this._ownerElement) {
421
+ throw new DOMException(INUSE_ATTRIBUTE_ERR);
422
+ }
423
+ var oldAttr = this.getNamedItem(attr.nodeName);
424
+ _addNamedNode(this._ownerElement, this, attr, oldAttr);
425
+ return oldAttr;
426
+ },
427
+ /* returns Node */
428
+ setNamedItemNS: function(attr) {
429
+ var el = attr.ownerElement, oldAttr;
430
+ if (el && el != this._ownerElement) {
431
+ throw new DOMException(INUSE_ATTRIBUTE_ERR);
432
+ }
433
+ oldAttr = this.getNamedItemNS(attr.namespaceURI, attr.localName);
434
+ _addNamedNode(this._ownerElement, this, attr, oldAttr);
435
+ return oldAttr;
436
+ },
437
+ /* returns Node */
438
+ removeNamedItem: function(key) {
439
+ var attr = this.getNamedItem(key);
440
+ _removeNamedNode(this._ownerElement, this, attr);
441
+ return attr;
442
+ },
443
+ // raises: NOT_FOUND_ERR,NO_MODIFICATION_ALLOWED_ERR
444
+ //for level2
445
+ removeNamedItemNS: function(namespaceURI, localName) {
446
+ var attr = this.getNamedItemNS(namespaceURI, localName);
447
+ _removeNamedNode(this._ownerElement, this, attr);
448
+ return attr;
449
+ },
450
+ getNamedItemNS: function(namespaceURI, localName) {
451
+ var i = this.length;
452
+ while (i--) {
453
+ var node = this[i];
454
+ if (node.localName == localName && node.namespaceURI == namespaceURI) {
455
+ return node;
456
+ }
457
+ }
458
+ return null;
459
+ }
460
+ };
461
+ function DOMImplementation() {
462
+ }
463
+ DOMImplementation.prototype = {
464
+ /**
465
+ * The DOMImplementation.hasFeature() method returns a Boolean flag indicating if a given feature is supported.
466
+ * The different implementations fairly diverged in what kind of features were reported.
467
+ * The latest version of the spec settled to force this method to always return true, where the functionality was accurate and in use.
468
+ *
469
+ * @deprecated It is deprecated and modern browsers return true in all cases.
470
+ *
471
+ * @param {string} feature
472
+ * @param {string} [version]
473
+ * @returns {boolean} always true
474
+ *
475
+ * @see https://developer.mozilla.org/en-US/docs/Web/API/DOMImplementation/hasFeature MDN
476
+ * @see https://www.w3.org/TR/REC-DOM-Level-1/level-one-core.html#ID-5CED94D7 DOM Level 1 Core
477
+ * @see https://dom.spec.whatwg.org/#dom-domimplementation-hasfeature DOM Living Standard
478
+ */
479
+ hasFeature: function(feature, version) {
480
+ return true;
481
+ },
482
+ /**
483
+ * Creates an XML Document object of the specified type with its document element.
484
+ *
485
+ * __It behaves slightly different from the description in the living standard__:
486
+ * - There is no interface/class `XMLDocument`, it returns a `Document` instance.
487
+ * - `contentType`, `encoding`, `mode`, `origin`, `url` fields are currently not declared.
488
+ * - this implementation is not validating names or qualified names
489
+ * (when parsing XML strings, the SAX parser takes care of that)
490
+ *
491
+ * @param {string|null} namespaceURI
492
+ * @param {string} qualifiedName
493
+ * @param {DocumentType=null} doctype
494
+ * @returns {Document}
495
+ *
496
+ * @see https://developer.mozilla.org/en-US/docs/Web/API/DOMImplementation/createDocument MDN
497
+ * @see https://www.w3.org/TR/DOM-Level-2-Core/core.html#Level-2-Core-DOM-createDocument DOM Level 2 Core (initial)
498
+ * @see https://dom.spec.whatwg.org/#dom-domimplementation-createdocument DOM Level 2 Core
499
+ *
500
+ * @see https://dom.spec.whatwg.org/#validate-and-extract DOM: Validate and extract
501
+ * @see https://www.w3.org/TR/xml/#NT-NameStartChar XML Spec: Names
502
+ * @see https://www.w3.org/TR/xml-names/#ns-qualnames XML Namespaces: Qualified names
503
+ */
504
+ createDocument: function(namespaceURI, qualifiedName, doctype) {
505
+ var doc = new Document();
506
+ doc.implementation = this;
507
+ doc.childNodes = new NodeList();
508
+ doc.doctype = doctype || null;
509
+ if (doctype) {
510
+ doc.appendChild(doctype);
511
+ }
512
+ if (qualifiedName) {
513
+ var root = doc.createElementNS(namespaceURI, qualifiedName);
514
+ doc.appendChild(root);
515
+ }
516
+ return doc;
517
+ },
518
+ /**
519
+ * Returns a doctype, with the given `qualifiedName`, `publicId`, and `systemId`.
520
+ *
521
+ * __This behavior is slightly different from the in the specs__:
522
+ * - this implementation is not validating names or qualified names
523
+ * (when parsing XML strings, the SAX parser takes care of that)
524
+ *
525
+ * @param {string} qualifiedName
526
+ * @param {string} [publicId]
527
+ * @param {string} [systemId]
528
+ * @returns {DocumentType} which can either be used with `DOMImplementation.createDocument` upon document creation
529
+ * or can be put into the document via methods like `Node.insertBefore()` or `Node.replaceChild()`
530
+ *
531
+ * @see https://developer.mozilla.org/en-US/docs/Web/API/DOMImplementation/createDocumentType MDN
532
+ * @see https://www.w3.org/TR/DOM-Level-2-Core/core.html#Level-2-Core-DOM-createDocType DOM Level 2 Core
533
+ * @see https://dom.spec.whatwg.org/#dom-domimplementation-createdocumenttype DOM Living Standard
534
+ *
535
+ * @see https://dom.spec.whatwg.org/#validate-and-extract DOM: Validate and extract
536
+ * @see https://www.w3.org/TR/xml/#NT-NameStartChar XML Spec: Names
537
+ * @see https://www.w3.org/TR/xml-names/#ns-qualnames XML Namespaces: Qualified names
538
+ */
539
+ createDocumentType: function(qualifiedName, publicId, systemId) {
540
+ var node = new DocumentType();
541
+ node.name = qualifiedName;
542
+ node.nodeName = qualifiedName;
543
+ node.publicId = publicId || "";
544
+ node.systemId = systemId || "";
545
+ return node;
546
+ }
547
+ };
548
+ function Node() {
549
+ }
550
+ Node.prototype = {
551
+ firstChild: null,
552
+ lastChild: null,
553
+ previousSibling: null,
554
+ nextSibling: null,
555
+ attributes: null,
556
+ parentNode: null,
557
+ childNodes: null,
558
+ ownerDocument: null,
559
+ nodeValue: null,
560
+ namespaceURI: null,
561
+ prefix: null,
562
+ localName: null,
563
+ // Modified in DOM Level 2:
564
+ insertBefore: function(newChild, refChild) {
565
+ return _insertBefore(this, newChild, refChild);
566
+ },
567
+ replaceChild: function(newChild, oldChild) {
568
+ _insertBefore(this, newChild, oldChild, assertPreReplacementValidityInDocument);
569
+ if (oldChild) {
570
+ this.removeChild(oldChild);
571
+ }
572
+ },
573
+ removeChild: function(oldChild) {
574
+ return _removeChild(this, oldChild);
575
+ },
576
+ appendChild: function(newChild) {
577
+ return this.insertBefore(newChild, null);
578
+ },
579
+ hasChildNodes: function() {
580
+ return this.firstChild != null;
581
+ },
582
+ cloneNode: function(deep) {
583
+ return cloneNode(this.ownerDocument || this, this, deep);
584
+ },
585
+ // Modified in DOM Level 2:
586
+ normalize: function() {
587
+ var child = this.firstChild;
588
+ while (child) {
589
+ var next = child.nextSibling;
590
+ if (next && next.nodeType == TEXT_NODE && child.nodeType == TEXT_NODE) {
591
+ this.removeChild(next);
592
+ child.appendData(next.data);
593
+ } else {
594
+ child.normalize();
595
+ child = next;
596
+ }
597
+ }
598
+ },
599
+ // Introduced in DOM Level 2:
600
+ isSupported: function(feature, version) {
601
+ return this.ownerDocument.implementation.hasFeature(feature, version);
602
+ },
603
+ // Introduced in DOM Level 2:
604
+ hasAttributes: function() {
605
+ return this.attributes.length > 0;
606
+ },
607
+ /**
608
+ * Look up the prefix associated to the given namespace URI, starting from this node.
609
+ * **The default namespace declarations are ignored by this method.**
610
+ * See Namespace Prefix Lookup for details on the algorithm used by this method.
611
+ *
612
+ * _Note: The implementation seems to be incomplete when compared to the algorithm described in the specs._
613
+ *
614
+ * @param {string | null} namespaceURI
615
+ * @returns {string | null}
616
+ * @see https://www.w3.org/TR/DOM-Level-3-Core/core.html#Node3-lookupNamespacePrefix
617
+ * @see https://www.w3.org/TR/DOM-Level-3-Core/namespaces-algorithms.html#lookupNamespacePrefixAlgo
618
+ * @see https://dom.spec.whatwg.org/#dom-node-lookupprefix
619
+ * @see https://github.com/xmldom/xmldom/issues/322
620
+ */
621
+ lookupPrefix: function(namespaceURI) {
622
+ var el = this;
623
+ while (el) {
624
+ var map = el._nsMap;
625
+ if (map) {
626
+ for (var n in map) {
627
+ if (Object.prototype.hasOwnProperty.call(map, n) && map[n] === namespaceURI) {
628
+ return n;
629
+ }
630
+ }
631
+ }
632
+ el = el.nodeType == ATTRIBUTE_NODE ? el.ownerDocument : el.parentNode;
633
+ }
634
+ return null;
635
+ },
636
+ // Introduced in DOM Level 3:
637
+ lookupNamespaceURI: function(prefix) {
638
+ var el = this;
639
+ while (el) {
640
+ var map = el._nsMap;
641
+ if (map) {
642
+ if (Object.prototype.hasOwnProperty.call(map, prefix)) {
643
+ return map[prefix];
644
+ }
645
+ }
646
+ el = el.nodeType == ATTRIBUTE_NODE ? el.ownerDocument : el.parentNode;
647
+ }
648
+ return null;
649
+ },
650
+ // Introduced in DOM Level 3:
651
+ isDefaultNamespace: function(namespaceURI) {
652
+ var prefix = this.lookupPrefix(namespaceURI);
653
+ return prefix == null;
654
+ }
655
+ };
656
+ function _xmlEncoder(c) {
657
+ return c == "<" && "&lt;" || c == ">" && "&gt;" || c == "&" && "&amp;" || c == '"' && "&quot;" || "&#" + c.charCodeAt() + ";";
658
+ }
659
+ copy(NodeType, Node);
660
+ copy(NodeType, Node.prototype);
661
+ function _visitNode(node, callback) {
662
+ if (callback(node)) {
663
+ return true;
664
+ }
665
+ if (node = node.firstChild) {
666
+ do {
667
+ if (_visitNode(node, callback)) {
668
+ return true;
669
+ }
670
+ } while (node = node.nextSibling);
671
+ }
672
+ }
673
+ function Document() {
674
+ this.ownerDocument = this;
675
+ }
676
+ function _onAddAttribute(doc, el, newAttr) {
677
+ doc && doc._inc++;
678
+ var ns = newAttr.namespaceURI;
679
+ if (ns === NAMESPACE.XMLNS) {
680
+ el._nsMap[newAttr.prefix ? newAttr.localName : ""] = newAttr.value;
681
+ }
682
+ }
683
+ function _onRemoveAttribute(doc, el, newAttr, remove) {
684
+ doc && doc._inc++;
685
+ var ns = newAttr.namespaceURI;
686
+ if (ns === NAMESPACE.XMLNS) {
687
+ delete el._nsMap[newAttr.prefix ? newAttr.localName : ""];
688
+ }
689
+ }
690
+ function _onUpdateChild(doc, el, newChild) {
691
+ if (doc && doc._inc) {
692
+ doc._inc++;
693
+ var cs = el.childNodes;
694
+ if (newChild) {
695
+ cs[cs.length++] = newChild;
696
+ } else {
697
+ var child = el.firstChild;
698
+ var i = 0;
699
+ while (child) {
700
+ cs[i++] = child;
701
+ child = child.nextSibling;
702
+ }
703
+ cs.length = i;
704
+ delete cs[cs.length];
705
+ }
706
+ }
707
+ }
708
+ function _removeChild(parentNode, child) {
709
+ var previous = child.previousSibling;
710
+ var next = child.nextSibling;
711
+ if (previous) {
712
+ previous.nextSibling = next;
713
+ } else {
714
+ parentNode.firstChild = next;
715
+ }
716
+ if (next) {
717
+ next.previousSibling = previous;
718
+ } else {
719
+ parentNode.lastChild = previous;
720
+ }
721
+ child.parentNode = null;
722
+ child.previousSibling = null;
723
+ child.nextSibling = null;
724
+ _onUpdateChild(parentNode.ownerDocument, parentNode);
725
+ return child;
726
+ }
727
+ function hasValidParentNodeType(node) {
728
+ return node && (node.nodeType === Node.DOCUMENT_NODE || node.nodeType === Node.DOCUMENT_FRAGMENT_NODE || node.nodeType === Node.ELEMENT_NODE);
729
+ }
730
+ function hasInsertableNodeType(node) {
731
+ return node && (isElementNode(node) || isTextNode(node) || isDocTypeNode(node) || node.nodeType === Node.DOCUMENT_FRAGMENT_NODE || node.nodeType === Node.COMMENT_NODE || node.nodeType === Node.PROCESSING_INSTRUCTION_NODE);
732
+ }
733
+ function isDocTypeNode(node) {
734
+ return node && node.nodeType === Node.DOCUMENT_TYPE_NODE;
735
+ }
736
+ function isElementNode(node) {
737
+ return node && node.nodeType === Node.ELEMENT_NODE;
738
+ }
739
+ function isTextNode(node) {
740
+ return node && node.nodeType === Node.TEXT_NODE;
741
+ }
742
+ function isElementInsertionPossible(doc, child) {
743
+ var parentChildNodes = doc.childNodes || [];
744
+ if (find(parentChildNodes, isElementNode) || isDocTypeNode(child)) {
745
+ return false;
746
+ }
747
+ var docTypeNode = find(parentChildNodes, isDocTypeNode);
748
+ return !(child && docTypeNode && parentChildNodes.indexOf(docTypeNode) > parentChildNodes.indexOf(child));
749
+ }
750
+ function isElementReplacementPossible(doc, child) {
751
+ var parentChildNodes = doc.childNodes || [];
752
+ function hasElementChildThatIsNotChild(node) {
753
+ return isElementNode(node) && node !== child;
754
+ }
755
+ if (find(parentChildNodes, hasElementChildThatIsNotChild)) {
756
+ return false;
757
+ }
758
+ var docTypeNode = find(parentChildNodes, isDocTypeNode);
759
+ return !(child && docTypeNode && parentChildNodes.indexOf(docTypeNode) > parentChildNodes.indexOf(child));
760
+ }
761
+ function assertPreInsertionValidity1to5(parent, node, child) {
762
+ if (!hasValidParentNodeType(parent)) {
763
+ throw new DOMException(HIERARCHY_REQUEST_ERR, "Unexpected parent node type " + parent.nodeType);
764
+ }
765
+ if (child && child.parentNode !== parent) {
766
+ throw new DOMException(NOT_FOUND_ERR, "child not in parent");
767
+ }
768
+ if (
769
+ // 4. If `node` is not a DocumentFragment, DocumentType, Element, or CharacterData node, then throw a "HierarchyRequestError" DOMException.
770
+ !hasInsertableNodeType(node) || // 5. If either `node` is a Text node and `parent` is a document,
771
+ // the sax parser currently adds top level text nodes, this will be fixed in 0.9.0
772
+ // || (node.nodeType === Node.TEXT_NODE && parent.nodeType === Node.DOCUMENT_NODE)
773
+ // or `node` is a doctype and `parent` is not a document, then throw a "HierarchyRequestError" DOMException.
774
+ isDocTypeNode(node) && parent.nodeType !== Node.DOCUMENT_NODE
775
+ ) {
776
+ throw new DOMException(
777
+ HIERARCHY_REQUEST_ERR,
778
+ "Unexpected node type " + node.nodeType + " for parent node type " + parent.nodeType
779
+ );
780
+ }
781
+ }
782
+ function assertPreInsertionValidityInDocument(parent, node, child) {
783
+ var parentChildNodes = parent.childNodes || [];
784
+ var nodeChildNodes = node.childNodes || [];
785
+ if (node.nodeType === Node.DOCUMENT_FRAGMENT_NODE) {
786
+ var nodeChildElements = nodeChildNodes.filter(isElementNode);
787
+ if (nodeChildElements.length > 1 || find(nodeChildNodes, isTextNode)) {
788
+ throw new DOMException(HIERARCHY_REQUEST_ERR, "More than one element or text in fragment");
789
+ }
790
+ if (nodeChildElements.length === 1 && !isElementInsertionPossible(parent, child)) {
791
+ throw new DOMException(HIERARCHY_REQUEST_ERR, "Element in fragment can not be inserted before doctype");
792
+ }
793
+ }
794
+ if (isElementNode(node)) {
795
+ if (!isElementInsertionPossible(parent, child)) {
796
+ throw new DOMException(HIERARCHY_REQUEST_ERR, "Only one element can be added and only after doctype");
797
+ }
798
+ }
799
+ if (isDocTypeNode(node)) {
800
+ if (find(parentChildNodes, isDocTypeNode)) {
801
+ throw new DOMException(HIERARCHY_REQUEST_ERR, "Only one doctype is allowed");
802
+ }
803
+ var parentElementChild = find(parentChildNodes, isElementNode);
804
+ if (child && parentChildNodes.indexOf(parentElementChild) < parentChildNodes.indexOf(child)) {
805
+ throw new DOMException(HIERARCHY_REQUEST_ERR, "Doctype can only be inserted before an element");
806
+ }
807
+ if (!child && parentElementChild) {
808
+ throw new DOMException(HIERARCHY_REQUEST_ERR, "Doctype can not be appended since element is present");
809
+ }
810
+ }
811
+ }
812
+ function assertPreReplacementValidityInDocument(parent, node, child) {
813
+ var parentChildNodes = parent.childNodes || [];
814
+ var nodeChildNodes = node.childNodes || [];
815
+ if (node.nodeType === Node.DOCUMENT_FRAGMENT_NODE) {
816
+ var nodeChildElements = nodeChildNodes.filter(isElementNode);
817
+ if (nodeChildElements.length > 1 || find(nodeChildNodes, isTextNode)) {
818
+ throw new DOMException(HIERARCHY_REQUEST_ERR, "More than one element or text in fragment");
819
+ }
820
+ if (nodeChildElements.length === 1 && !isElementReplacementPossible(parent, child)) {
821
+ throw new DOMException(HIERARCHY_REQUEST_ERR, "Element in fragment can not be inserted before doctype");
822
+ }
823
+ }
824
+ if (isElementNode(node)) {
825
+ if (!isElementReplacementPossible(parent, child)) {
826
+ throw new DOMException(HIERARCHY_REQUEST_ERR, "Only one element can be added and only after doctype");
827
+ }
828
+ }
829
+ if (isDocTypeNode(node)) {
830
+ let hasDoctypeChildThatIsNotChild2 = function(node2) {
831
+ return isDocTypeNode(node2) && node2 !== child;
832
+ };
833
+ var hasDoctypeChildThatIsNotChild = hasDoctypeChildThatIsNotChild2;
834
+ if (find(parentChildNodes, hasDoctypeChildThatIsNotChild2)) {
835
+ throw new DOMException(HIERARCHY_REQUEST_ERR, "Only one doctype is allowed");
836
+ }
837
+ var parentElementChild = find(parentChildNodes, isElementNode);
838
+ if (child && parentChildNodes.indexOf(parentElementChild) < parentChildNodes.indexOf(child)) {
839
+ throw new DOMException(HIERARCHY_REQUEST_ERR, "Doctype can only be inserted before an element");
840
+ }
841
+ }
842
+ }
843
+ function _insertBefore(parent, node, child, _inDocumentAssertion) {
844
+ assertPreInsertionValidity1to5(parent, node, child);
845
+ if (parent.nodeType === Node.DOCUMENT_NODE) {
846
+ (_inDocumentAssertion || assertPreInsertionValidityInDocument)(parent, node, child);
847
+ }
848
+ var cp = node.parentNode;
849
+ if (cp) {
850
+ cp.removeChild(node);
851
+ }
852
+ if (node.nodeType === DOCUMENT_FRAGMENT_NODE) {
853
+ var newFirst = node.firstChild;
854
+ if (newFirst == null) {
855
+ return node;
856
+ }
857
+ var newLast = node.lastChild;
858
+ } else {
859
+ newFirst = newLast = node;
860
+ }
861
+ var pre = child ? child.previousSibling : parent.lastChild;
862
+ newFirst.previousSibling = pre;
863
+ newLast.nextSibling = child;
864
+ if (pre) {
865
+ pre.nextSibling = newFirst;
866
+ } else {
867
+ parent.firstChild = newFirst;
868
+ }
869
+ if (child == null) {
870
+ parent.lastChild = newLast;
871
+ } else {
872
+ child.previousSibling = newLast;
873
+ }
874
+ do {
875
+ newFirst.parentNode = parent;
876
+ } while (newFirst !== newLast && (newFirst = newFirst.nextSibling));
877
+ _onUpdateChild(parent.ownerDocument || parent, parent);
878
+ if (node.nodeType == DOCUMENT_FRAGMENT_NODE) {
879
+ node.firstChild = node.lastChild = null;
880
+ }
881
+ return node;
882
+ }
883
+ function _appendSingleChild(parentNode, newChild) {
884
+ if (newChild.parentNode) {
885
+ newChild.parentNode.removeChild(newChild);
886
+ }
887
+ newChild.parentNode = parentNode;
888
+ newChild.previousSibling = parentNode.lastChild;
889
+ newChild.nextSibling = null;
890
+ if (newChild.previousSibling) {
891
+ newChild.previousSibling.nextSibling = newChild;
892
+ } else {
893
+ parentNode.firstChild = newChild;
894
+ }
895
+ parentNode.lastChild = newChild;
896
+ _onUpdateChild(parentNode.ownerDocument, parentNode, newChild);
897
+ return newChild;
898
+ }
899
+ Document.prototype = {
900
+ //implementation : null,
901
+ nodeName: "#document",
902
+ nodeType: DOCUMENT_NODE,
903
+ /**
904
+ * The DocumentType node of the document.
905
+ *
906
+ * @readonly
907
+ * @type DocumentType
908
+ */
909
+ doctype: null,
910
+ documentElement: null,
911
+ _inc: 1,
912
+ insertBefore: function(newChild, refChild) {
913
+ if (newChild.nodeType == DOCUMENT_FRAGMENT_NODE) {
914
+ var child = newChild.firstChild;
915
+ while (child) {
916
+ var next = child.nextSibling;
917
+ this.insertBefore(child, refChild);
918
+ child = next;
919
+ }
920
+ return newChild;
921
+ }
922
+ _insertBefore(this, newChild, refChild);
923
+ newChild.ownerDocument = this;
924
+ if (this.documentElement === null && newChild.nodeType === ELEMENT_NODE) {
925
+ this.documentElement = newChild;
926
+ }
927
+ return newChild;
928
+ },
929
+ removeChild: function(oldChild) {
930
+ if (this.documentElement == oldChild) {
931
+ this.documentElement = null;
932
+ }
933
+ return _removeChild(this, oldChild);
934
+ },
935
+ replaceChild: function(newChild, oldChild) {
936
+ _insertBefore(this, newChild, oldChild, assertPreReplacementValidityInDocument);
937
+ newChild.ownerDocument = this;
938
+ if (oldChild) {
939
+ this.removeChild(oldChild);
940
+ }
941
+ if (isElementNode(newChild)) {
942
+ this.documentElement = newChild;
943
+ }
944
+ },
945
+ // Introduced in DOM Level 2:
946
+ importNode: function(importedNode, deep) {
947
+ return importNode(this, importedNode, deep);
948
+ },
949
+ // Introduced in DOM Level 2:
950
+ getElementById: function(id) {
951
+ var rtv = null;
952
+ _visitNode(this.documentElement, function(node) {
953
+ if (node.nodeType == ELEMENT_NODE) {
954
+ if (node.getAttribute("id") == id) {
955
+ rtv = node;
956
+ return true;
957
+ }
958
+ }
959
+ });
960
+ return rtv;
961
+ },
962
+ /**
963
+ * The `getElementsByClassName` method of `Document` interface returns an array-like object
964
+ * of all child elements which have **all** of the given class name(s).
965
+ *
966
+ * Returns an empty list if `classeNames` is an empty string or only contains HTML white space characters.
967
+ *
968
+ *
969
+ * Warning: This is a live LiveNodeList.
970
+ * Changes in the DOM will reflect in the array as the changes occur.
971
+ * If an element selected by this array no longer qualifies for the selector,
972
+ * it will automatically be removed. Be aware of this for iteration purposes.
973
+ *
974
+ * @param {string} classNames is a string representing the class name(s) to match; multiple class names are separated by (ASCII-)whitespace
975
+ *
976
+ * @see https://developer.mozilla.org/en-US/docs/Web/API/Document/getElementsByClassName
977
+ * @see https://dom.spec.whatwg.org/#concept-getelementsbyclassname
978
+ */
979
+ getElementsByClassName: function(classNames) {
980
+ var classNamesSet = toOrderedSet(classNames);
981
+ return new LiveNodeList(this, function(base) {
982
+ var ls = [];
983
+ if (classNamesSet.length > 0) {
984
+ _visitNode(base.documentElement, function(node) {
985
+ if (node !== base && node.nodeType === ELEMENT_NODE) {
986
+ var nodeClassNames = node.getAttribute("class");
987
+ if (nodeClassNames) {
988
+ var matches = classNames === nodeClassNames;
989
+ if (!matches) {
990
+ var nodeClassNamesSet = toOrderedSet(nodeClassNames);
991
+ matches = classNamesSet.every(arrayIncludes(nodeClassNamesSet));
992
+ }
993
+ if (matches) {
994
+ ls.push(node);
995
+ }
996
+ }
997
+ }
998
+ });
999
+ }
1000
+ return ls;
1001
+ });
1002
+ },
1003
+ //document factory method:
1004
+ createElement: function(tagName) {
1005
+ var node = new Element();
1006
+ node.ownerDocument = this;
1007
+ node.nodeName = tagName;
1008
+ node.tagName = tagName;
1009
+ node.localName = tagName;
1010
+ node.childNodes = new NodeList();
1011
+ var attrs = node.attributes = new NamedNodeMap();
1012
+ attrs._ownerElement = node;
1013
+ return node;
1014
+ },
1015
+ createDocumentFragment: function() {
1016
+ var node = new DocumentFragment();
1017
+ node.ownerDocument = this;
1018
+ node.childNodes = new NodeList();
1019
+ return node;
1020
+ },
1021
+ createTextNode: function(data) {
1022
+ var node = new Text();
1023
+ node.ownerDocument = this;
1024
+ node.appendData(data);
1025
+ return node;
1026
+ },
1027
+ createComment: function(data) {
1028
+ var node = new Comment();
1029
+ node.ownerDocument = this;
1030
+ node.appendData(data);
1031
+ return node;
1032
+ },
1033
+ createCDATASection: function(data) {
1034
+ var node = new CDATASection();
1035
+ node.ownerDocument = this;
1036
+ node.appendData(data);
1037
+ return node;
1038
+ },
1039
+ createProcessingInstruction: function(target, data) {
1040
+ var node = new ProcessingInstruction();
1041
+ node.ownerDocument = this;
1042
+ node.tagName = node.target = target;
1043
+ node.nodeValue = node.data = data;
1044
+ return node;
1045
+ },
1046
+ createAttribute: function(name) {
1047
+ var node = new Attr();
1048
+ node.ownerDocument = this;
1049
+ node.name = name;
1050
+ node.nodeName = name;
1051
+ node.localName = name;
1052
+ node.specified = true;
1053
+ return node;
1054
+ },
1055
+ createEntityReference: function(name) {
1056
+ var node = new EntityReference();
1057
+ node.ownerDocument = this;
1058
+ node.nodeName = name;
1059
+ return node;
1060
+ },
1061
+ // Introduced in DOM Level 2:
1062
+ createElementNS: function(namespaceURI, qualifiedName) {
1063
+ var node = new Element();
1064
+ var pl = qualifiedName.split(":");
1065
+ var attrs = node.attributes = new NamedNodeMap();
1066
+ node.childNodes = new NodeList();
1067
+ node.ownerDocument = this;
1068
+ node.nodeName = qualifiedName;
1069
+ node.tagName = qualifiedName;
1070
+ node.namespaceURI = namespaceURI;
1071
+ if (pl.length == 2) {
1072
+ node.prefix = pl[0];
1073
+ node.localName = pl[1];
1074
+ } else {
1075
+ node.localName = qualifiedName;
1076
+ }
1077
+ attrs._ownerElement = node;
1078
+ return node;
1079
+ },
1080
+ // Introduced in DOM Level 2:
1081
+ createAttributeNS: function(namespaceURI, qualifiedName) {
1082
+ var node = new Attr();
1083
+ var pl = qualifiedName.split(":");
1084
+ node.ownerDocument = this;
1085
+ node.nodeName = qualifiedName;
1086
+ node.name = qualifiedName;
1087
+ node.namespaceURI = namespaceURI;
1088
+ node.specified = true;
1089
+ if (pl.length == 2) {
1090
+ node.prefix = pl[0];
1091
+ node.localName = pl[1];
1092
+ } else {
1093
+ node.localName = qualifiedName;
1094
+ }
1095
+ return node;
1096
+ }
1097
+ };
1098
+ _extends(Document, Node);
1099
+ function Element() {
1100
+ this._nsMap = {};
1101
+ }
1102
+ Element.prototype = {
1103
+ nodeType: ELEMENT_NODE,
1104
+ hasAttribute: function(name) {
1105
+ return this.getAttributeNode(name) != null;
1106
+ },
1107
+ getAttribute: function(name) {
1108
+ var attr = this.getAttributeNode(name);
1109
+ return attr && attr.value || "";
1110
+ },
1111
+ getAttributeNode: function(name) {
1112
+ return this.attributes.getNamedItem(name);
1113
+ },
1114
+ setAttribute: function(name, value) {
1115
+ var attr = this.ownerDocument.createAttribute(name);
1116
+ attr.value = attr.nodeValue = "" + value;
1117
+ this.setAttributeNode(attr);
1118
+ },
1119
+ removeAttribute: function(name) {
1120
+ var attr = this.getAttributeNode(name);
1121
+ attr && this.removeAttributeNode(attr);
1122
+ },
1123
+ //four real opeartion method
1124
+ appendChild: function(newChild) {
1125
+ if (newChild.nodeType === DOCUMENT_FRAGMENT_NODE) {
1126
+ return this.insertBefore(newChild, null);
1127
+ } else {
1128
+ return _appendSingleChild(this, newChild);
1129
+ }
1130
+ },
1131
+ setAttributeNode: function(newAttr) {
1132
+ return this.attributes.setNamedItem(newAttr);
1133
+ },
1134
+ setAttributeNodeNS: function(newAttr) {
1135
+ return this.attributes.setNamedItemNS(newAttr);
1136
+ },
1137
+ removeAttributeNode: function(oldAttr) {
1138
+ return this.attributes.removeNamedItem(oldAttr.nodeName);
1139
+ },
1140
+ //get real attribute name,and remove it by removeAttributeNode
1141
+ removeAttributeNS: function(namespaceURI, localName) {
1142
+ var old = this.getAttributeNodeNS(namespaceURI, localName);
1143
+ old && this.removeAttributeNode(old);
1144
+ },
1145
+ hasAttributeNS: function(namespaceURI, localName) {
1146
+ return this.getAttributeNodeNS(namespaceURI, localName) != null;
1147
+ },
1148
+ getAttributeNS: function(namespaceURI, localName) {
1149
+ var attr = this.getAttributeNodeNS(namespaceURI, localName);
1150
+ return attr && attr.value || "";
1151
+ },
1152
+ setAttributeNS: function(namespaceURI, qualifiedName, value) {
1153
+ var attr = this.ownerDocument.createAttributeNS(namespaceURI, qualifiedName);
1154
+ attr.value = attr.nodeValue = "" + value;
1155
+ this.setAttributeNode(attr);
1156
+ },
1157
+ getAttributeNodeNS: function(namespaceURI, localName) {
1158
+ return this.attributes.getNamedItemNS(namespaceURI, localName);
1159
+ },
1160
+ getElementsByTagName: function(tagName) {
1161
+ return new LiveNodeList(this, function(base) {
1162
+ var ls = [];
1163
+ _visitNode(base, function(node) {
1164
+ if (node !== base && node.nodeType == ELEMENT_NODE && (tagName === "*" || node.tagName == tagName)) {
1165
+ ls.push(node);
1166
+ }
1167
+ });
1168
+ return ls;
1169
+ });
1170
+ },
1171
+ getElementsByTagNameNS: function(namespaceURI, localName) {
1172
+ return new LiveNodeList(this, function(base) {
1173
+ var ls = [];
1174
+ _visitNode(base, function(node) {
1175
+ if (node !== base && node.nodeType === ELEMENT_NODE && (namespaceURI === "*" || node.namespaceURI === namespaceURI) && (localName === "*" || node.localName == localName)) {
1176
+ ls.push(node);
1177
+ }
1178
+ });
1179
+ return ls;
1180
+ });
1181
+ }
1182
+ };
1183
+ Document.prototype.getElementsByTagName = Element.prototype.getElementsByTagName;
1184
+ Document.prototype.getElementsByTagNameNS = Element.prototype.getElementsByTagNameNS;
1185
+ _extends(Element, Node);
1186
+ function Attr() {
1187
+ }
1188
+ Attr.prototype.nodeType = ATTRIBUTE_NODE;
1189
+ _extends(Attr, Node);
1190
+ function CharacterData() {
1191
+ }
1192
+ CharacterData.prototype = {
1193
+ data: "",
1194
+ substringData: function(offset, count) {
1195
+ return this.data.substring(offset, offset + count);
1196
+ },
1197
+ appendData: function(text) {
1198
+ text = this.data + text;
1199
+ this.nodeValue = this.data = text;
1200
+ this.length = text.length;
1201
+ },
1202
+ insertData: function(offset, text) {
1203
+ this.replaceData(offset, 0, text);
1204
+ },
1205
+ appendChild: function(newChild) {
1206
+ throw new Error(ExceptionMessage[HIERARCHY_REQUEST_ERR]);
1207
+ },
1208
+ deleteData: function(offset, count) {
1209
+ this.replaceData(offset, count, "");
1210
+ },
1211
+ replaceData: function(offset, count, text) {
1212
+ var start = this.data.substring(0, offset);
1213
+ var end = this.data.substring(offset + count);
1214
+ text = start + text + end;
1215
+ this.nodeValue = this.data = text;
1216
+ this.length = text.length;
1217
+ }
1218
+ };
1219
+ _extends(CharacterData, Node);
1220
+ function Text() {
1221
+ }
1222
+ Text.prototype = {
1223
+ nodeName: "#text",
1224
+ nodeType: TEXT_NODE,
1225
+ splitText: function(offset) {
1226
+ var text = this.data;
1227
+ var newText = text.substring(offset);
1228
+ text = text.substring(0, offset);
1229
+ this.data = this.nodeValue = text;
1230
+ this.length = text.length;
1231
+ var newNode = this.ownerDocument.createTextNode(newText);
1232
+ if (this.parentNode) {
1233
+ this.parentNode.insertBefore(newNode, this.nextSibling);
1234
+ }
1235
+ return newNode;
1236
+ }
1237
+ };
1238
+ _extends(Text, CharacterData);
1239
+ function Comment() {
1240
+ }
1241
+ Comment.prototype = {
1242
+ nodeName: "#comment",
1243
+ nodeType: COMMENT_NODE
1244
+ };
1245
+ _extends(Comment, CharacterData);
1246
+ function CDATASection() {
1247
+ }
1248
+ CDATASection.prototype = {
1249
+ nodeName: "#cdata-section",
1250
+ nodeType: CDATA_SECTION_NODE
1251
+ };
1252
+ _extends(CDATASection, CharacterData);
1253
+ function DocumentType() {
1254
+ }
1255
+ DocumentType.prototype.nodeType = DOCUMENT_TYPE_NODE;
1256
+ _extends(DocumentType, Node);
1257
+ function Notation() {
1258
+ }
1259
+ Notation.prototype.nodeType = NOTATION_NODE;
1260
+ _extends(Notation, Node);
1261
+ function Entity() {
1262
+ }
1263
+ Entity.prototype.nodeType = ENTITY_NODE;
1264
+ _extends(Entity, Node);
1265
+ function EntityReference() {
1266
+ }
1267
+ EntityReference.prototype.nodeType = ENTITY_REFERENCE_NODE;
1268
+ _extends(EntityReference, Node);
1269
+ function DocumentFragment() {
1270
+ }
1271
+ DocumentFragment.prototype.nodeName = "#document-fragment";
1272
+ DocumentFragment.prototype.nodeType = DOCUMENT_FRAGMENT_NODE;
1273
+ _extends(DocumentFragment, Node);
1274
+ function ProcessingInstruction() {
1275
+ }
1276
+ ProcessingInstruction.prototype.nodeType = PROCESSING_INSTRUCTION_NODE;
1277
+ _extends(ProcessingInstruction, Node);
1278
+ function XMLSerializer() {
1279
+ }
1280
+ XMLSerializer.prototype.serializeToString = function(node, isHtml, nodeFilter) {
1281
+ return nodeSerializeToString.call(node, isHtml, nodeFilter);
1282
+ };
1283
+ Node.prototype.toString = nodeSerializeToString;
1284
+ function nodeSerializeToString(isHtml, nodeFilter) {
1285
+ var buf = [];
1286
+ var refNode = this.nodeType == 9 && this.documentElement || this;
1287
+ var prefix = refNode.prefix;
1288
+ var uri = refNode.namespaceURI;
1289
+ if (uri && prefix == null) {
1290
+ var prefix = refNode.lookupPrefix(uri);
1291
+ if (prefix == null) {
1292
+ var visibleNamespaces = [
1293
+ { namespace: uri, prefix: null }
1294
+ //{namespace:uri,prefix:''}
1295
+ ];
1296
+ }
1297
+ }
1298
+ serializeToString(this, buf, isHtml, nodeFilter, visibleNamespaces);
1299
+ return buf.join("");
1300
+ }
1301
+ function needNamespaceDefine(node, isHTML, visibleNamespaces) {
1302
+ var prefix = node.prefix || "";
1303
+ var uri = node.namespaceURI;
1304
+ if (!uri) {
1305
+ return false;
1306
+ }
1307
+ if (prefix === "xml" && uri === NAMESPACE.XML || uri === NAMESPACE.XMLNS) {
1308
+ return false;
1309
+ }
1310
+ var i = visibleNamespaces.length;
1311
+ while (i--) {
1312
+ var ns = visibleNamespaces[i];
1313
+ if (ns.prefix === prefix) {
1314
+ return ns.namespace !== uri;
1315
+ }
1316
+ }
1317
+ return true;
1318
+ }
1319
+ function addSerializedAttribute(buf, qualifiedName, value) {
1320
+ buf.push(" ", qualifiedName, '="', value.replace(/[<>&"\t\n\r]/g, _xmlEncoder), '"');
1321
+ }
1322
+ function serializeToString(node, buf, isHTML, nodeFilter, visibleNamespaces) {
1323
+ if (!visibleNamespaces) {
1324
+ visibleNamespaces = [];
1325
+ }
1326
+ if (nodeFilter) {
1327
+ node = nodeFilter(node);
1328
+ if (node) {
1329
+ if (typeof node == "string") {
1330
+ buf.push(node);
1331
+ return;
1332
+ }
1333
+ } else {
1334
+ return;
1335
+ }
1336
+ }
1337
+ switch (node.nodeType) {
1338
+ case ELEMENT_NODE:
1339
+ var attrs = node.attributes;
1340
+ var len = attrs.length;
1341
+ var child = node.firstChild;
1342
+ var nodeName = node.tagName;
1343
+ isHTML = NAMESPACE.isHTML(node.namespaceURI) || isHTML;
1344
+ var prefixedNodeName = nodeName;
1345
+ if (!isHTML && !node.prefix && node.namespaceURI) {
1346
+ var defaultNS;
1347
+ for (var ai = 0; ai < attrs.length; ai++) {
1348
+ if (attrs.item(ai).name === "xmlns") {
1349
+ defaultNS = attrs.item(ai).value;
1350
+ break;
1351
+ }
1352
+ }
1353
+ if (!defaultNS) {
1354
+ for (var nsi = visibleNamespaces.length - 1; nsi >= 0; nsi--) {
1355
+ var namespace = visibleNamespaces[nsi];
1356
+ if (namespace.prefix === "" && namespace.namespace === node.namespaceURI) {
1357
+ defaultNS = namespace.namespace;
1358
+ break;
1359
+ }
1360
+ }
1361
+ }
1362
+ if (defaultNS !== node.namespaceURI) {
1363
+ for (var nsi = visibleNamespaces.length - 1; nsi >= 0; nsi--) {
1364
+ var namespace = visibleNamespaces[nsi];
1365
+ if (namespace.namespace === node.namespaceURI) {
1366
+ if (namespace.prefix) {
1367
+ prefixedNodeName = namespace.prefix + ":" + nodeName;
1368
+ }
1369
+ break;
1370
+ }
1371
+ }
1372
+ }
1373
+ }
1374
+ buf.push("<", prefixedNodeName);
1375
+ for (var i = 0; i < len; i++) {
1376
+ var attr = attrs.item(i);
1377
+ if (attr.prefix == "xmlns") {
1378
+ visibleNamespaces.push({ prefix: attr.localName, namespace: attr.value });
1379
+ } else if (attr.nodeName == "xmlns") {
1380
+ visibleNamespaces.push({ prefix: "", namespace: attr.value });
1381
+ }
1382
+ }
1383
+ for (var i = 0; i < len; i++) {
1384
+ var attr = attrs.item(i);
1385
+ if (needNamespaceDefine(attr, isHTML, visibleNamespaces)) {
1386
+ var prefix = attr.prefix || "";
1387
+ var uri = attr.namespaceURI;
1388
+ addSerializedAttribute(buf, prefix ? "xmlns:" + prefix : "xmlns", uri);
1389
+ visibleNamespaces.push({ prefix, namespace: uri });
1390
+ }
1391
+ serializeToString(attr, buf, isHTML, nodeFilter, visibleNamespaces);
1392
+ }
1393
+ if (nodeName === prefixedNodeName && needNamespaceDefine(node, isHTML, visibleNamespaces)) {
1394
+ var prefix = node.prefix || "";
1395
+ var uri = node.namespaceURI;
1396
+ addSerializedAttribute(buf, prefix ? "xmlns:" + prefix : "xmlns", uri);
1397
+ visibleNamespaces.push({ prefix, namespace: uri });
1398
+ }
1399
+ if (child || isHTML && !/^(?:meta|link|img|br|hr|input)$/i.test(nodeName)) {
1400
+ buf.push(">");
1401
+ if (isHTML && /^script$/i.test(nodeName)) {
1402
+ while (child) {
1403
+ if (child.data) {
1404
+ buf.push(child.data);
1405
+ } else {
1406
+ serializeToString(child, buf, isHTML, nodeFilter, visibleNamespaces.slice());
1407
+ }
1408
+ child = child.nextSibling;
1409
+ }
1410
+ } else {
1411
+ while (child) {
1412
+ serializeToString(child, buf, isHTML, nodeFilter, visibleNamespaces.slice());
1413
+ child = child.nextSibling;
1414
+ }
1415
+ }
1416
+ buf.push("</", prefixedNodeName, ">");
1417
+ } else {
1418
+ buf.push("/>");
1419
+ }
1420
+ return;
1421
+ case DOCUMENT_NODE:
1422
+ case DOCUMENT_FRAGMENT_NODE:
1423
+ var child = node.firstChild;
1424
+ while (child) {
1425
+ serializeToString(child, buf, isHTML, nodeFilter, visibleNamespaces.slice());
1426
+ child = child.nextSibling;
1427
+ }
1428
+ return;
1429
+ case ATTRIBUTE_NODE:
1430
+ return addSerializedAttribute(buf, node.name, node.value);
1431
+ case TEXT_NODE:
1432
+ return buf.push(
1433
+ node.data.replace(/[<&>]/g, _xmlEncoder)
1434
+ );
1435
+ case CDATA_SECTION_NODE:
1436
+ return buf.push("<![CDATA[", node.data, "]]>");
1437
+ case COMMENT_NODE:
1438
+ return buf.push("<!--", node.data, "-->");
1439
+ case DOCUMENT_TYPE_NODE:
1440
+ var pubid = node.publicId;
1441
+ var sysid = node.systemId;
1442
+ buf.push("<!DOCTYPE ", node.name);
1443
+ if (pubid) {
1444
+ buf.push(" PUBLIC ", pubid);
1445
+ if (sysid && sysid != ".") {
1446
+ buf.push(" ", sysid);
1447
+ }
1448
+ buf.push(">");
1449
+ } else if (sysid && sysid != ".") {
1450
+ buf.push(" SYSTEM ", sysid, ">");
1451
+ } else {
1452
+ var sub = node.internalSubset;
1453
+ if (sub) {
1454
+ buf.push(" [", sub, "]");
1455
+ }
1456
+ buf.push(">");
1457
+ }
1458
+ return;
1459
+ case PROCESSING_INSTRUCTION_NODE:
1460
+ return buf.push("<?", node.target, " ", node.data, "?>");
1461
+ case ENTITY_REFERENCE_NODE:
1462
+ return buf.push("&", node.nodeName, ";");
1463
+ default:
1464
+ buf.push("??", node.nodeName);
1465
+ }
1466
+ }
1467
+ function importNode(doc, node, deep) {
1468
+ var node2;
1469
+ switch (node.nodeType) {
1470
+ case ELEMENT_NODE:
1471
+ node2 = node.cloneNode(false);
1472
+ node2.ownerDocument = doc;
1473
+ case DOCUMENT_FRAGMENT_NODE:
1474
+ break;
1475
+ case ATTRIBUTE_NODE:
1476
+ deep = true;
1477
+ break;
1478
+ }
1479
+ if (!node2) {
1480
+ node2 = node.cloneNode(false);
1481
+ }
1482
+ node2.ownerDocument = doc;
1483
+ node2.parentNode = null;
1484
+ if (deep) {
1485
+ var child = node.firstChild;
1486
+ while (child) {
1487
+ node2.appendChild(importNode(doc, child, deep));
1488
+ child = child.nextSibling;
1489
+ }
1490
+ }
1491
+ return node2;
1492
+ }
1493
+ function cloneNode(doc, node, deep) {
1494
+ var node2 = new node.constructor();
1495
+ for (var n in node) {
1496
+ if (Object.prototype.hasOwnProperty.call(node, n)) {
1497
+ var v = node[n];
1498
+ if (typeof v != "object") {
1499
+ if (v != node2[n]) {
1500
+ node2[n] = v;
1501
+ }
1502
+ }
1503
+ }
1504
+ }
1505
+ if (node.childNodes) {
1506
+ node2.childNodes = new NodeList();
1507
+ }
1508
+ node2.ownerDocument = doc;
1509
+ switch (node2.nodeType) {
1510
+ case ELEMENT_NODE:
1511
+ var attrs = node.attributes;
1512
+ var attrs2 = node2.attributes = new NamedNodeMap();
1513
+ var len = attrs.length;
1514
+ attrs2._ownerElement = node2;
1515
+ for (var i = 0; i < len; i++) {
1516
+ node2.setAttributeNode(cloneNode(doc, attrs.item(i), true));
1517
+ }
1518
+ break;
1519
+ ;
1520
+ case ATTRIBUTE_NODE:
1521
+ deep = true;
1522
+ }
1523
+ if (deep) {
1524
+ var child = node.firstChild;
1525
+ while (child) {
1526
+ node2.appendChild(cloneNode(doc, child, deep));
1527
+ child = child.nextSibling;
1528
+ }
1529
+ }
1530
+ return node2;
1531
+ }
1532
+ function __set__(object, key, value) {
1533
+ object[key] = value;
1534
+ }
1535
+ try {
1536
+ if (Object.defineProperty) {
1537
+ let getTextContent2 = function(node) {
1538
+ switch (node.nodeType) {
1539
+ case ELEMENT_NODE:
1540
+ case DOCUMENT_FRAGMENT_NODE:
1541
+ var buf = [];
1542
+ node = node.firstChild;
1543
+ while (node) {
1544
+ if (node.nodeType !== 7 && node.nodeType !== 8) {
1545
+ buf.push(getTextContent2(node));
1546
+ }
1547
+ node = node.nextSibling;
1548
+ }
1549
+ return buf.join("");
1550
+ default:
1551
+ return node.nodeValue;
1552
+ }
1553
+ };
1554
+ getTextContent = getTextContent2;
1555
+ Object.defineProperty(LiveNodeList.prototype, "length", {
1556
+ get: function() {
1557
+ _updateLiveList(this);
1558
+ return this.$$length;
1559
+ }
1560
+ });
1561
+ Object.defineProperty(Node.prototype, "textContent", {
1562
+ get: function() {
1563
+ return getTextContent2(this);
1564
+ },
1565
+ set: function(data) {
1566
+ switch (this.nodeType) {
1567
+ case ELEMENT_NODE:
1568
+ case DOCUMENT_FRAGMENT_NODE:
1569
+ while (this.firstChild) {
1570
+ this.removeChild(this.firstChild);
1571
+ }
1572
+ if (data || String(data)) {
1573
+ this.appendChild(this.ownerDocument.createTextNode(data));
1574
+ }
1575
+ break;
1576
+ default:
1577
+ this.data = data;
1578
+ this.value = data;
1579
+ this.nodeValue = data;
1580
+ }
1581
+ }
1582
+ });
1583
+ __set__ = function(object, key, value) {
1584
+ object["$$" + key] = value;
1585
+ };
1586
+ }
1587
+ } catch (e) {
1588
+ }
1589
+ var getTextContent;
1590
+ exports.DocumentType = DocumentType;
1591
+ exports.DOMException = DOMException;
1592
+ exports.DOMImplementation = DOMImplementation;
1593
+ exports.Element = Element;
1594
+ exports.Node = Node;
1595
+ exports.NodeList = NodeList;
1596
+ exports.XMLSerializer = XMLSerializer;
1597
+ }
1598
+ });
1599
+
1600
+ // node_modules/@xmldom/xmldom/lib/entities.js
1601
+ var require_entities = __commonJS({
1602
+ "node_modules/@xmldom/xmldom/lib/entities.js"(exports) {
1603
+ var freeze = require_conventions().freeze;
1604
+ exports.XML_ENTITIES = freeze({ amp: "&", apos: "'", gt: ">", lt: "<", quot: '"' });
1605
+ exports.HTML_ENTITIES = freeze({
1606
+ lt: "<",
1607
+ gt: ">",
1608
+ amp: "&",
1609
+ quot: '"',
1610
+ apos: "'",
1611
+ Agrave: "\xC0",
1612
+ Aacute: "\xC1",
1613
+ Acirc: "\xC2",
1614
+ Atilde: "\xC3",
1615
+ Auml: "\xC4",
1616
+ Aring: "\xC5",
1617
+ AElig: "\xC6",
1618
+ Ccedil: "\xC7",
1619
+ Egrave: "\xC8",
1620
+ Eacute: "\xC9",
1621
+ Ecirc: "\xCA",
1622
+ Euml: "\xCB",
1623
+ Igrave: "\xCC",
1624
+ Iacute: "\xCD",
1625
+ Icirc: "\xCE",
1626
+ Iuml: "\xCF",
1627
+ ETH: "\xD0",
1628
+ Ntilde: "\xD1",
1629
+ Ograve: "\xD2",
1630
+ Oacute: "\xD3",
1631
+ Ocirc: "\xD4",
1632
+ Otilde: "\xD5",
1633
+ Ouml: "\xD6",
1634
+ Oslash: "\xD8",
1635
+ Ugrave: "\xD9",
1636
+ Uacute: "\xDA",
1637
+ Ucirc: "\xDB",
1638
+ Uuml: "\xDC",
1639
+ Yacute: "\xDD",
1640
+ THORN: "\xDE",
1641
+ szlig: "\xDF",
1642
+ agrave: "\xE0",
1643
+ aacute: "\xE1",
1644
+ acirc: "\xE2",
1645
+ atilde: "\xE3",
1646
+ auml: "\xE4",
1647
+ aring: "\xE5",
1648
+ aelig: "\xE6",
1649
+ ccedil: "\xE7",
1650
+ egrave: "\xE8",
1651
+ eacute: "\xE9",
1652
+ ecirc: "\xEA",
1653
+ euml: "\xEB",
1654
+ igrave: "\xEC",
1655
+ iacute: "\xED",
1656
+ icirc: "\xEE",
1657
+ iuml: "\xEF",
1658
+ eth: "\xF0",
1659
+ ntilde: "\xF1",
1660
+ ograve: "\xF2",
1661
+ oacute: "\xF3",
1662
+ ocirc: "\xF4",
1663
+ otilde: "\xF5",
1664
+ ouml: "\xF6",
1665
+ oslash: "\xF8",
1666
+ ugrave: "\xF9",
1667
+ uacute: "\xFA",
1668
+ ucirc: "\xFB",
1669
+ uuml: "\xFC",
1670
+ yacute: "\xFD",
1671
+ thorn: "\xFE",
1672
+ yuml: "\xFF",
1673
+ nbsp: "\xA0",
1674
+ iexcl: "\xA1",
1675
+ cent: "\xA2",
1676
+ pound: "\xA3",
1677
+ curren: "\xA4",
1678
+ yen: "\xA5",
1679
+ brvbar: "\xA6",
1680
+ sect: "\xA7",
1681
+ uml: "\xA8",
1682
+ copy: "\xA9",
1683
+ ordf: "\xAA",
1684
+ laquo: "\xAB",
1685
+ not: "\xAC",
1686
+ shy: "\xAD\xAD",
1687
+ reg: "\xAE",
1688
+ macr: "\xAF",
1689
+ deg: "\xB0",
1690
+ plusmn: "\xB1",
1691
+ sup2: "\xB2",
1692
+ sup3: "\xB3",
1693
+ acute: "\xB4",
1694
+ micro: "\xB5",
1695
+ para: "\xB6",
1696
+ middot: "\xB7",
1697
+ cedil: "\xB8",
1698
+ sup1: "\xB9",
1699
+ ordm: "\xBA",
1700
+ raquo: "\xBB",
1701
+ frac14: "\xBC",
1702
+ frac12: "\xBD",
1703
+ frac34: "\xBE",
1704
+ iquest: "\xBF",
1705
+ times: "\xD7",
1706
+ divide: "\xF7",
1707
+ forall: "\u2200",
1708
+ part: "\u2202",
1709
+ exist: "\u2203",
1710
+ empty: "\u2205",
1711
+ nabla: "\u2207",
1712
+ isin: "\u2208",
1713
+ notin: "\u2209",
1714
+ ni: "\u220B",
1715
+ prod: "\u220F",
1716
+ sum: "\u2211",
1717
+ minus: "\u2212",
1718
+ lowast: "\u2217",
1719
+ radic: "\u221A",
1720
+ prop: "\u221D",
1721
+ infin: "\u221E",
1722
+ ang: "\u2220",
1723
+ and: "\u2227",
1724
+ or: "\u2228",
1725
+ cap: "\u2229",
1726
+ cup: "\u222A",
1727
+ "int": "\u222B",
1728
+ there4: "\u2234",
1729
+ sim: "\u223C",
1730
+ cong: "\u2245",
1731
+ asymp: "\u2248",
1732
+ ne: "\u2260",
1733
+ equiv: "\u2261",
1734
+ le: "\u2264",
1735
+ ge: "\u2265",
1736
+ sub: "\u2282",
1737
+ sup: "\u2283",
1738
+ nsub: "\u2284",
1739
+ sube: "\u2286",
1740
+ supe: "\u2287",
1741
+ oplus: "\u2295",
1742
+ otimes: "\u2297",
1743
+ perp: "\u22A5",
1744
+ sdot: "\u22C5",
1745
+ Alpha: "\u0391",
1746
+ Beta: "\u0392",
1747
+ Gamma: "\u0393",
1748
+ Delta: "\u0394",
1749
+ Epsilon: "\u0395",
1750
+ Zeta: "\u0396",
1751
+ Eta: "\u0397",
1752
+ Theta: "\u0398",
1753
+ Iota: "\u0399",
1754
+ Kappa: "\u039A",
1755
+ Lambda: "\u039B",
1756
+ Mu: "\u039C",
1757
+ Nu: "\u039D",
1758
+ Xi: "\u039E",
1759
+ Omicron: "\u039F",
1760
+ Pi: "\u03A0",
1761
+ Rho: "\u03A1",
1762
+ Sigma: "\u03A3",
1763
+ Tau: "\u03A4",
1764
+ Upsilon: "\u03A5",
1765
+ Phi: "\u03A6",
1766
+ Chi: "\u03A7",
1767
+ Psi: "\u03A8",
1768
+ Omega: "\u03A9",
1769
+ alpha: "\u03B1",
1770
+ beta: "\u03B2",
1771
+ gamma: "\u03B3",
1772
+ delta: "\u03B4",
1773
+ epsilon: "\u03B5",
1774
+ zeta: "\u03B6",
1775
+ eta: "\u03B7",
1776
+ theta: "\u03B8",
1777
+ iota: "\u03B9",
1778
+ kappa: "\u03BA",
1779
+ lambda: "\u03BB",
1780
+ mu: "\u03BC",
1781
+ nu: "\u03BD",
1782
+ xi: "\u03BE",
1783
+ omicron: "\u03BF",
1784
+ pi: "\u03C0",
1785
+ rho: "\u03C1",
1786
+ sigmaf: "\u03C2",
1787
+ sigma: "\u03C3",
1788
+ tau: "\u03C4",
1789
+ upsilon: "\u03C5",
1790
+ phi: "\u03C6",
1791
+ chi: "\u03C7",
1792
+ psi: "\u03C8",
1793
+ omega: "\u03C9",
1794
+ thetasym: "\u03D1",
1795
+ upsih: "\u03D2",
1796
+ piv: "\u03D6",
1797
+ OElig: "\u0152",
1798
+ oelig: "\u0153",
1799
+ Scaron: "\u0160",
1800
+ scaron: "\u0161",
1801
+ Yuml: "\u0178",
1802
+ fnof: "\u0192",
1803
+ circ: "\u02C6",
1804
+ tilde: "\u02DC",
1805
+ ensp: "\u2002",
1806
+ emsp: "\u2003",
1807
+ thinsp: "\u2009",
1808
+ zwnj: "\u200C",
1809
+ zwj: "\u200D",
1810
+ lrm: "\u200E",
1811
+ rlm: "\u200F",
1812
+ ndash: "\u2013",
1813
+ mdash: "\u2014",
1814
+ lsquo: "\u2018",
1815
+ rsquo: "\u2019",
1816
+ sbquo: "\u201A",
1817
+ ldquo: "\u201C",
1818
+ rdquo: "\u201D",
1819
+ bdquo: "\u201E",
1820
+ dagger: "\u2020",
1821
+ Dagger: "\u2021",
1822
+ bull: "\u2022",
1823
+ hellip: "\u2026",
1824
+ permil: "\u2030",
1825
+ prime: "\u2032",
1826
+ Prime: "\u2033",
1827
+ lsaquo: "\u2039",
1828
+ rsaquo: "\u203A",
1829
+ oline: "\u203E",
1830
+ euro: "\u20AC",
1831
+ trade: "\u2122",
1832
+ larr: "\u2190",
1833
+ uarr: "\u2191",
1834
+ rarr: "\u2192",
1835
+ darr: "\u2193",
1836
+ harr: "\u2194",
1837
+ crarr: "\u21B5",
1838
+ lceil: "\u2308",
1839
+ rceil: "\u2309",
1840
+ lfloor: "\u230A",
1841
+ rfloor: "\u230B",
1842
+ loz: "\u25CA",
1843
+ spades: "\u2660",
1844
+ clubs: "\u2663",
1845
+ hearts: "\u2665",
1846
+ diams: "\u2666"
1847
+ });
1848
+ exports.entityMap = exports.HTML_ENTITIES;
1849
+ }
1850
+ });
1851
+
1852
+ // node_modules/@xmldom/xmldom/lib/sax.js
1853
+ var require_sax = __commonJS({
1854
+ "node_modules/@xmldom/xmldom/lib/sax.js"(exports) {
1855
+ var NAMESPACE = require_conventions().NAMESPACE;
1856
+ var nameStartChar = /[A-Z_a-z\xC0-\xD6\xD8-\xF6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD]/;
1857
+ var nameChar = new RegExp("[\\-\\.0-9" + nameStartChar.source.slice(1, -1) + "\\u00B7\\u0300-\\u036F\\u203F-\\u2040]");
1858
+ var tagNamePattern = new RegExp("^" + nameStartChar.source + nameChar.source + "*(?::" + nameStartChar.source + nameChar.source + "*)?$");
1859
+ var S_TAG = 0;
1860
+ var S_ATTR = 1;
1861
+ var S_ATTR_SPACE = 2;
1862
+ var S_EQ = 3;
1863
+ var S_ATTR_NOQUOT_VALUE = 4;
1864
+ var S_ATTR_END = 5;
1865
+ var S_TAG_SPACE = 6;
1866
+ var S_TAG_CLOSE = 7;
1867
+ function ParseError(message, locator) {
1868
+ this.message = message;
1869
+ this.locator = locator;
1870
+ if (Error.captureStackTrace)
1871
+ Error.captureStackTrace(this, ParseError);
1872
+ }
1873
+ ParseError.prototype = new Error();
1874
+ ParseError.prototype.name = ParseError.name;
1875
+ function XMLReader() {
1876
+ }
1877
+ XMLReader.prototype = {
1878
+ parse: function(source, defaultNSMap, entityMap) {
1879
+ var domBuilder = this.domBuilder;
1880
+ domBuilder.startDocument();
1881
+ _copy(defaultNSMap, defaultNSMap = {});
1882
+ parse2(
1883
+ source,
1884
+ defaultNSMap,
1885
+ entityMap,
1886
+ domBuilder,
1887
+ this.errorHandler
1888
+ );
1889
+ domBuilder.endDocument();
1890
+ }
1891
+ };
1892
+ function parse2(source, defaultNSMapCopy, entityMap, domBuilder, errorHandler) {
1893
+ function fixedFromCharCode(code) {
1894
+ if (code > 65535) {
1895
+ code -= 65536;
1896
+ var surrogate1 = 55296 + (code >> 10), surrogate2 = 56320 + (code & 1023);
1897
+ return String.fromCharCode(surrogate1, surrogate2);
1898
+ } else {
1899
+ return String.fromCharCode(code);
1900
+ }
1901
+ }
1902
+ function entityReplacer(a2) {
1903
+ var k = a2.slice(1, -1);
1904
+ if (Object.hasOwnProperty.call(entityMap, k)) {
1905
+ return entityMap[k];
1906
+ } else if (k.charAt(0) === "#") {
1907
+ return fixedFromCharCode(parseInt(k.substr(1).replace("x", "0x")));
1908
+ } else {
1909
+ errorHandler.error("entity not found:" + a2);
1910
+ return a2;
1911
+ }
1912
+ }
1913
+ function appendText(end2) {
1914
+ if (end2 > start) {
1915
+ var xt = source.substring(start, end2).replace(/&#?\w+;/g, entityReplacer);
1916
+ locator && position(start);
1917
+ domBuilder.characters(xt, 0, end2 - start);
1918
+ start = end2;
1919
+ }
1920
+ }
1921
+ function position(p, m) {
1922
+ while (p >= lineEnd && (m = linePattern.exec(source))) {
1923
+ lineStart = m.index;
1924
+ lineEnd = lineStart + m[0].length;
1925
+ locator.lineNumber++;
1926
+ }
1927
+ locator.columnNumber = p - lineStart + 1;
1928
+ }
1929
+ var lineStart = 0;
1930
+ var lineEnd = 0;
1931
+ var linePattern = /.*(?:\r\n?|\n)|.*$/g;
1932
+ var locator = domBuilder.locator;
1933
+ var parseStack = [{ currentNSMap: defaultNSMapCopy }];
1934
+ var closeMap = {};
1935
+ var start = 0;
1936
+ while (true) {
1937
+ try {
1938
+ var tagStart = source.indexOf("<", start);
1939
+ if (tagStart < 0) {
1940
+ if (!source.substr(start).match(/^\s*$/)) {
1941
+ var doc = domBuilder.doc;
1942
+ var text = doc.createTextNode(source.substr(start));
1943
+ doc.appendChild(text);
1944
+ domBuilder.currentElement = text;
1945
+ }
1946
+ return;
1947
+ }
1948
+ if (tagStart > start) {
1949
+ appendText(tagStart);
1950
+ }
1951
+ switch (source.charAt(tagStart + 1)) {
1952
+ case "/":
1953
+ var end = source.indexOf(">", tagStart + 3);
1954
+ var tagName = source.substring(tagStart + 2, end).replace(/[ \t\n\r]+$/g, "");
1955
+ var config = parseStack.pop();
1956
+ if (end < 0) {
1957
+ tagName = source.substring(tagStart + 2).replace(/[\s<].*/, "");
1958
+ errorHandler.error("end tag name: " + tagName + " is not complete:" + config.tagName);
1959
+ end = tagStart + 1 + tagName.length;
1960
+ } else if (tagName.match(/\s</)) {
1961
+ tagName = tagName.replace(/[\s<].*/, "");
1962
+ errorHandler.error("end tag name: " + tagName + " maybe not complete");
1963
+ end = tagStart + 1 + tagName.length;
1964
+ }
1965
+ var localNSMap = config.localNSMap;
1966
+ var endMatch = config.tagName == tagName;
1967
+ var endIgnoreCaseMach = endMatch || config.tagName && config.tagName.toLowerCase() == tagName.toLowerCase();
1968
+ if (endIgnoreCaseMach) {
1969
+ domBuilder.endElement(config.uri, config.localName, tagName);
1970
+ if (localNSMap) {
1971
+ for (var prefix in localNSMap) {
1972
+ if (Object.prototype.hasOwnProperty.call(localNSMap, prefix)) {
1973
+ domBuilder.endPrefixMapping(prefix);
1974
+ }
1975
+ }
1976
+ }
1977
+ if (!endMatch) {
1978
+ errorHandler.fatalError("end tag name: " + tagName + " is not match the current start tagName:" + config.tagName);
1979
+ }
1980
+ } else {
1981
+ parseStack.push(config);
1982
+ }
1983
+ end++;
1984
+ break;
1985
+ case "?":
1986
+ locator && position(tagStart);
1987
+ end = parseInstruction(source, tagStart, domBuilder);
1988
+ break;
1989
+ case "!":
1990
+ locator && position(tagStart);
1991
+ end = parseDCC(source, tagStart, domBuilder, errorHandler);
1992
+ break;
1993
+ default:
1994
+ locator && position(tagStart);
1995
+ var el = new ElementAttributes();
1996
+ var currentNSMap = parseStack[parseStack.length - 1].currentNSMap;
1997
+ var end = parseElementStartPart(source, tagStart, el, currentNSMap, entityReplacer, errorHandler);
1998
+ var len = el.length;
1999
+ if (!el.closed && fixSelfClosed(source, end, el.tagName, closeMap)) {
2000
+ el.closed = true;
2001
+ if (!entityMap.nbsp) {
2002
+ errorHandler.warning("unclosed xml attribute");
2003
+ }
2004
+ }
2005
+ if (locator && len) {
2006
+ var locator2 = copyLocator(locator, {});
2007
+ for (var i = 0; i < len; i++) {
2008
+ var a = el[i];
2009
+ position(a.offset);
2010
+ a.locator = copyLocator(locator, {});
2011
+ }
2012
+ domBuilder.locator = locator2;
2013
+ if (appendElement(el, domBuilder, currentNSMap)) {
2014
+ parseStack.push(el);
2015
+ }
2016
+ domBuilder.locator = locator;
2017
+ } else {
2018
+ if (appendElement(el, domBuilder, currentNSMap)) {
2019
+ parseStack.push(el);
2020
+ }
2021
+ }
2022
+ if (NAMESPACE.isHTML(el.uri) && !el.closed) {
2023
+ end = parseHtmlSpecialContent(source, end, el.tagName, entityReplacer, domBuilder);
2024
+ } else {
2025
+ end++;
2026
+ }
2027
+ }
2028
+ } catch (e) {
2029
+ if (e instanceof ParseError) {
2030
+ throw e;
2031
+ }
2032
+ errorHandler.error("element parse error: " + e);
2033
+ end = -1;
2034
+ }
2035
+ if (end > start) {
2036
+ start = end;
2037
+ } else {
2038
+ appendText(Math.max(tagStart, start) + 1);
2039
+ }
2040
+ }
2041
+ }
2042
+ function copyLocator(f, t) {
2043
+ t.lineNumber = f.lineNumber;
2044
+ t.columnNumber = f.columnNumber;
2045
+ return t;
2046
+ }
2047
+ function parseElementStartPart(source, start, el, currentNSMap, entityReplacer, errorHandler) {
2048
+ function addAttribute(qname, value2, startIndex) {
2049
+ if (el.attributeNames.hasOwnProperty(qname)) {
2050
+ errorHandler.fatalError("Attribute " + qname + " redefined");
2051
+ }
2052
+ el.addValue(
2053
+ qname,
2054
+ // @see https://www.w3.org/TR/xml/#AVNormalize
2055
+ // since the xmldom sax parser does not "interpret" DTD the following is not implemented:
2056
+ // - recursive replacement of (DTD) entity references
2057
+ // - trimming and collapsing multiple spaces into a single one for attributes that are not of type CDATA
2058
+ value2.replace(/[\t\n\r]/g, " ").replace(/&#?\w+;/g, entityReplacer),
2059
+ startIndex
2060
+ );
2061
+ }
2062
+ var attrName;
2063
+ var value;
2064
+ var p = ++start;
2065
+ var s = S_TAG;
2066
+ while (true) {
2067
+ var c = source.charAt(p);
2068
+ switch (c) {
2069
+ case "=":
2070
+ if (s === S_ATTR) {
2071
+ attrName = source.slice(start, p);
2072
+ s = S_EQ;
2073
+ } else if (s === S_ATTR_SPACE) {
2074
+ s = S_EQ;
2075
+ } else {
2076
+ throw new Error("attribute equal must after attrName");
2077
+ }
2078
+ break;
2079
+ case "'":
2080
+ case '"':
2081
+ if (s === S_EQ || s === S_ATTR) {
2082
+ if (s === S_ATTR) {
2083
+ errorHandler.warning('attribute value must after "="');
2084
+ attrName = source.slice(start, p);
2085
+ }
2086
+ start = p + 1;
2087
+ p = source.indexOf(c, start);
2088
+ if (p > 0) {
2089
+ value = source.slice(start, p);
2090
+ addAttribute(attrName, value, start - 1);
2091
+ s = S_ATTR_END;
2092
+ } else {
2093
+ throw new Error("attribute value no end '" + c + "' match");
2094
+ }
2095
+ } else if (s == S_ATTR_NOQUOT_VALUE) {
2096
+ value = source.slice(start, p);
2097
+ addAttribute(attrName, value, start);
2098
+ errorHandler.warning('attribute "' + attrName + '" missed start quot(' + c + ")!!");
2099
+ start = p + 1;
2100
+ s = S_ATTR_END;
2101
+ } else {
2102
+ throw new Error('attribute value must after "="');
2103
+ }
2104
+ break;
2105
+ case "/":
2106
+ switch (s) {
2107
+ case S_TAG:
2108
+ el.setTagName(source.slice(start, p));
2109
+ case S_ATTR_END:
2110
+ case S_TAG_SPACE:
2111
+ case S_TAG_CLOSE:
2112
+ s = S_TAG_CLOSE;
2113
+ el.closed = true;
2114
+ case S_ATTR_NOQUOT_VALUE:
2115
+ case S_ATTR:
2116
+ case S_ATTR_SPACE:
2117
+ break;
2118
+ default:
2119
+ throw new Error("attribute invalid close char('/')");
2120
+ }
2121
+ break;
2122
+ case "":
2123
+ errorHandler.error("unexpected end of input");
2124
+ if (s == S_TAG) {
2125
+ el.setTagName(source.slice(start, p));
2126
+ }
2127
+ return p;
2128
+ case ">":
2129
+ switch (s) {
2130
+ case S_TAG:
2131
+ el.setTagName(source.slice(start, p));
2132
+ case S_ATTR_END:
2133
+ case S_TAG_SPACE:
2134
+ case S_TAG_CLOSE:
2135
+ break;
2136
+ case S_ATTR_NOQUOT_VALUE:
2137
+ case S_ATTR:
2138
+ value = source.slice(start, p);
2139
+ if (value.slice(-1) === "/") {
2140
+ el.closed = true;
2141
+ value = value.slice(0, -1);
2142
+ }
2143
+ case S_ATTR_SPACE:
2144
+ if (s === S_ATTR_SPACE) {
2145
+ value = attrName;
2146
+ }
2147
+ if (s == S_ATTR_NOQUOT_VALUE) {
2148
+ errorHandler.warning('attribute "' + value + '" missed quot(")!');
2149
+ addAttribute(attrName, value, start);
2150
+ } else {
2151
+ if (!NAMESPACE.isHTML(currentNSMap[""]) || !value.match(/^(?:disabled|checked|selected)$/i)) {
2152
+ errorHandler.warning('attribute "' + value + '" missed value!! "' + value + '" instead!!');
2153
+ }
2154
+ addAttribute(value, value, start);
2155
+ }
2156
+ break;
2157
+ case S_EQ:
2158
+ throw new Error("attribute value missed!!");
2159
+ }
2160
+ return p;
2161
+ case "\x80":
2162
+ c = " ";
2163
+ default:
2164
+ if (c <= " ") {
2165
+ switch (s) {
2166
+ case S_TAG:
2167
+ el.setTagName(source.slice(start, p));
2168
+ s = S_TAG_SPACE;
2169
+ break;
2170
+ case S_ATTR:
2171
+ attrName = source.slice(start, p);
2172
+ s = S_ATTR_SPACE;
2173
+ break;
2174
+ case S_ATTR_NOQUOT_VALUE:
2175
+ var value = source.slice(start, p);
2176
+ errorHandler.warning('attribute "' + value + '" missed quot(")!!');
2177
+ addAttribute(attrName, value, start);
2178
+ case S_ATTR_END:
2179
+ s = S_TAG_SPACE;
2180
+ break;
2181
+ }
2182
+ } else {
2183
+ switch (s) {
2184
+ case S_ATTR_SPACE:
2185
+ var tagName = el.tagName;
2186
+ if (!NAMESPACE.isHTML(currentNSMap[""]) || !attrName.match(/^(?:disabled|checked|selected)$/i)) {
2187
+ errorHandler.warning('attribute "' + attrName + '" missed value!! "' + attrName + '" instead2!!');
2188
+ }
2189
+ addAttribute(attrName, attrName, start);
2190
+ start = p;
2191
+ s = S_ATTR;
2192
+ break;
2193
+ case S_ATTR_END:
2194
+ errorHandler.warning('attribute space is required"' + attrName + '"!!');
2195
+ case S_TAG_SPACE:
2196
+ s = S_ATTR;
2197
+ start = p;
2198
+ break;
2199
+ case S_EQ:
2200
+ s = S_ATTR_NOQUOT_VALUE;
2201
+ start = p;
2202
+ break;
2203
+ case S_TAG_CLOSE:
2204
+ throw new Error("elements closed character '/' and '>' must be connected to");
2205
+ }
2206
+ }
2207
+ }
2208
+ p++;
2209
+ }
2210
+ }
2211
+ function appendElement(el, domBuilder, currentNSMap) {
2212
+ var tagName = el.tagName;
2213
+ var localNSMap = null;
2214
+ var i = el.length;
2215
+ while (i--) {
2216
+ var a = el[i];
2217
+ var qName = a.qName;
2218
+ var value = a.value;
2219
+ var nsp = qName.indexOf(":");
2220
+ if (nsp > 0) {
2221
+ var prefix = a.prefix = qName.slice(0, nsp);
2222
+ var localName = qName.slice(nsp + 1);
2223
+ var nsPrefix = prefix === "xmlns" && localName;
2224
+ } else {
2225
+ localName = qName;
2226
+ prefix = null;
2227
+ nsPrefix = qName === "xmlns" && "";
2228
+ }
2229
+ a.localName = localName;
2230
+ if (nsPrefix !== false) {
2231
+ if (localNSMap == null) {
2232
+ localNSMap = {};
2233
+ _copy(currentNSMap, currentNSMap = {});
2234
+ }
2235
+ currentNSMap[nsPrefix] = localNSMap[nsPrefix] = value;
2236
+ a.uri = NAMESPACE.XMLNS;
2237
+ domBuilder.startPrefixMapping(nsPrefix, value);
2238
+ }
2239
+ }
2240
+ var i = el.length;
2241
+ while (i--) {
2242
+ a = el[i];
2243
+ var prefix = a.prefix;
2244
+ if (prefix) {
2245
+ if (prefix === "xml") {
2246
+ a.uri = NAMESPACE.XML;
2247
+ }
2248
+ if (prefix !== "xmlns") {
2249
+ a.uri = currentNSMap[prefix || ""];
2250
+ }
2251
+ }
2252
+ }
2253
+ var nsp = tagName.indexOf(":");
2254
+ if (nsp > 0) {
2255
+ prefix = el.prefix = tagName.slice(0, nsp);
2256
+ localName = el.localName = tagName.slice(nsp + 1);
2257
+ } else {
2258
+ prefix = null;
2259
+ localName = el.localName = tagName;
2260
+ }
2261
+ var ns = el.uri = currentNSMap[prefix || ""];
2262
+ domBuilder.startElement(ns, localName, tagName, el);
2263
+ if (el.closed) {
2264
+ domBuilder.endElement(ns, localName, tagName);
2265
+ if (localNSMap) {
2266
+ for (prefix in localNSMap) {
2267
+ if (Object.prototype.hasOwnProperty.call(localNSMap, prefix)) {
2268
+ domBuilder.endPrefixMapping(prefix);
2269
+ }
2270
+ }
2271
+ }
2272
+ } else {
2273
+ el.currentNSMap = currentNSMap;
2274
+ el.localNSMap = localNSMap;
2275
+ return true;
2276
+ }
2277
+ }
2278
+ function parseHtmlSpecialContent(source, elStartEnd, tagName, entityReplacer, domBuilder) {
2279
+ if (/^(?:script|textarea)$/i.test(tagName)) {
2280
+ var elEndStart = source.indexOf("</" + tagName + ">", elStartEnd);
2281
+ var text = source.substring(elStartEnd + 1, elEndStart);
2282
+ if (/[&<]/.test(text)) {
2283
+ if (/^script$/i.test(tagName)) {
2284
+ domBuilder.characters(text, 0, text.length);
2285
+ return elEndStart;
2286
+ }
2287
+ text = text.replace(/&#?\w+;/g, entityReplacer);
2288
+ domBuilder.characters(text, 0, text.length);
2289
+ return elEndStart;
2290
+ }
2291
+ }
2292
+ return elStartEnd + 1;
2293
+ }
2294
+ function fixSelfClosed(source, elStartEnd, tagName, closeMap) {
2295
+ var pos = closeMap[tagName];
2296
+ if (pos == null) {
2297
+ pos = source.lastIndexOf("</" + tagName + ">");
2298
+ if (pos < elStartEnd) {
2299
+ pos = source.lastIndexOf("</" + tagName);
2300
+ }
2301
+ closeMap[tagName] = pos;
2302
+ }
2303
+ return pos < elStartEnd;
2304
+ }
2305
+ function _copy(source, target) {
2306
+ for (var n in source) {
2307
+ if (Object.prototype.hasOwnProperty.call(source, n)) {
2308
+ target[n] = source[n];
2309
+ }
2310
+ }
2311
+ }
2312
+ function parseDCC(source, start, domBuilder, errorHandler) {
2313
+ var next = source.charAt(start + 2);
2314
+ switch (next) {
2315
+ case "-":
2316
+ if (source.charAt(start + 3) === "-") {
2317
+ var end = source.indexOf("-->", start + 4);
2318
+ if (end > start) {
2319
+ domBuilder.comment(source, start + 4, end - start - 4);
2320
+ return end + 3;
2321
+ } else {
2322
+ errorHandler.error("Unclosed comment");
2323
+ return -1;
2324
+ }
2325
+ } else {
2326
+ return -1;
2327
+ }
2328
+ default:
2329
+ if (source.substr(start + 3, 6) == "CDATA[") {
2330
+ var end = source.indexOf("]]>", start + 9);
2331
+ domBuilder.startCDATA();
2332
+ domBuilder.characters(source, start + 9, end - start - 9);
2333
+ domBuilder.endCDATA();
2334
+ return end + 3;
2335
+ }
2336
+ var matchs = split(source, start);
2337
+ var len = matchs.length;
2338
+ if (len > 1 && /!doctype/i.test(matchs[0][0])) {
2339
+ var name = matchs[1][0];
2340
+ var pubid = false;
2341
+ var sysid = false;
2342
+ if (len > 3) {
2343
+ if (/^public$/i.test(matchs[2][0])) {
2344
+ pubid = matchs[3][0];
2345
+ sysid = len > 4 && matchs[4][0];
2346
+ } else if (/^system$/i.test(matchs[2][0])) {
2347
+ sysid = matchs[3][0];
2348
+ }
2349
+ }
2350
+ var lastMatch = matchs[len - 1];
2351
+ domBuilder.startDTD(name, pubid, sysid);
2352
+ domBuilder.endDTD();
2353
+ return lastMatch.index + lastMatch[0].length;
2354
+ }
2355
+ }
2356
+ return -1;
2357
+ }
2358
+ function parseInstruction(source, start, domBuilder) {
2359
+ var end = source.indexOf("?>", start);
2360
+ if (end) {
2361
+ var match = source.substring(start, end).match(/^<\?(\S*)\s*([\s\S]*?)\s*$/);
2362
+ if (match) {
2363
+ var len = match[0].length;
2364
+ domBuilder.processingInstruction(match[1], match[2]);
2365
+ return end + 2;
2366
+ } else {
2367
+ return -1;
2368
+ }
2369
+ }
2370
+ return -1;
2371
+ }
2372
+ function ElementAttributes() {
2373
+ this.attributeNames = {};
2374
+ }
2375
+ ElementAttributes.prototype = {
2376
+ setTagName: function(tagName) {
2377
+ if (!tagNamePattern.test(tagName)) {
2378
+ throw new Error("invalid tagName:" + tagName);
2379
+ }
2380
+ this.tagName = tagName;
2381
+ },
2382
+ addValue: function(qName, value, offset) {
2383
+ if (!tagNamePattern.test(qName)) {
2384
+ throw new Error("invalid attribute:" + qName);
2385
+ }
2386
+ this.attributeNames[qName] = this.length;
2387
+ this[this.length++] = { qName, value, offset };
2388
+ },
2389
+ length: 0,
2390
+ getLocalName: function(i) {
2391
+ return this[i].localName;
2392
+ },
2393
+ getLocator: function(i) {
2394
+ return this[i].locator;
2395
+ },
2396
+ getQName: function(i) {
2397
+ return this[i].qName;
2398
+ },
2399
+ getURI: function(i) {
2400
+ return this[i].uri;
2401
+ },
2402
+ getValue: function(i) {
2403
+ return this[i].value;
2404
+ }
2405
+ // ,getIndex:function(uri, localName)){
2406
+ // if(localName){
2407
+ //
2408
+ // }else{
2409
+ // var qName = uri
2410
+ // }
2411
+ // },
2412
+ // getValue:function(){return this.getValue(this.getIndex.apply(this,arguments))},
2413
+ // getType:function(uri,localName){}
2414
+ // getType:function(i){},
2415
+ };
2416
+ function split(source, start) {
2417
+ var match;
2418
+ var buf = [];
2419
+ var reg = /'[^']+'|"[^"]+"|[^\s<>\/=]+=?|(\/?\s*>|<)/g;
2420
+ reg.lastIndex = start;
2421
+ reg.exec(source);
2422
+ while (match = reg.exec(source)) {
2423
+ buf.push(match);
2424
+ if (match[1])
2425
+ return buf;
2426
+ }
2427
+ }
2428
+ exports.XMLReader = XMLReader;
2429
+ exports.ParseError = ParseError;
2430
+ }
2431
+ });
2432
+
2433
+ // node_modules/@xmldom/xmldom/lib/dom-parser.js
2434
+ var require_dom_parser = __commonJS({
2435
+ "node_modules/@xmldom/xmldom/lib/dom-parser.js"(exports) {
2436
+ var conventions = require_conventions();
2437
+ var dom = require_dom();
2438
+ var entities = require_entities();
2439
+ var sax = require_sax();
2440
+ var DOMImplementation = dom.DOMImplementation;
2441
+ var NAMESPACE = conventions.NAMESPACE;
2442
+ var ParseError = sax.ParseError;
2443
+ var XMLReader = sax.XMLReader;
2444
+ function normalizeLineEndings(input) {
2445
+ return input.replace(/\r[\n\u0085]/g, "\n").replace(/[\r\u0085\u2028]/g, "\n");
2446
+ }
2447
+ function DOMParser2(options) {
2448
+ this.options = options || { locator: {} };
2449
+ }
2450
+ DOMParser2.prototype.parseFromString = function(source, mimeType) {
2451
+ var options = this.options;
2452
+ var sax2 = new XMLReader();
2453
+ var domBuilder = options.domBuilder || new DOMHandler();
2454
+ var errorHandler = options.errorHandler;
2455
+ var locator = options.locator;
2456
+ var defaultNSMap = options.xmlns || {};
2457
+ var isHTML = /\/x?html?$/.test(mimeType);
2458
+ var entityMap = isHTML ? entities.HTML_ENTITIES : entities.XML_ENTITIES;
2459
+ if (locator) {
2460
+ domBuilder.setDocumentLocator(locator);
2461
+ }
2462
+ sax2.errorHandler = buildErrorHandler(errorHandler, domBuilder, locator);
2463
+ sax2.domBuilder = options.domBuilder || domBuilder;
2464
+ if (isHTML) {
2465
+ defaultNSMap[""] = NAMESPACE.HTML;
2466
+ }
2467
+ defaultNSMap.xml = defaultNSMap.xml || NAMESPACE.XML;
2468
+ var normalize = options.normalizeLineEndings || normalizeLineEndings;
2469
+ if (source && typeof source === "string") {
2470
+ sax2.parse(
2471
+ normalize(source),
2472
+ defaultNSMap,
2473
+ entityMap
2474
+ );
2475
+ } else {
2476
+ sax2.errorHandler.error("invalid doc source");
2477
+ }
2478
+ return domBuilder.doc;
2479
+ };
2480
+ function buildErrorHandler(errorImpl, domBuilder, locator) {
2481
+ if (!errorImpl) {
2482
+ if (domBuilder instanceof DOMHandler) {
2483
+ return domBuilder;
2484
+ }
2485
+ errorImpl = domBuilder;
2486
+ }
2487
+ var errorHandler = {};
2488
+ var isCallback = errorImpl instanceof Function;
2489
+ locator = locator || {};
2490
+ function build(key) {
2491
+ var fn = errorImpl[key];
2492
+ if (!fn && isCallback) {
2493
+ fn = errorImpl.length == 2 ? function(msg) {
2494
+ errorImpl(key, msg);
2495
+ } : errorImpl;
2496
+ }
2497
+ errorHandler[key] = fn && function(msg) {
2498
+ fn("[xmldom " + key + "] " + msg + _locator(locator));
2499
+ } || function() {
2500
+ };
2501
+ }
2502
+ build("warning");
2503
+ build("error");
2504
+ build("fatalError");
2505
+ return errorHandler;
2506
+ }
2507
+ function DOMHandler() {
2508
+ this.cdata = false;
2509
+ }
2510
+ function position(locator, node) {
2511
+ node.lineNumber = locator.lineNumber;
2512
+ node.columnNumber = locator.columnNumber;
2513
+ }
2514
+ DOMHandler.prototype = {
2515
+ startDocument: function() {
2516
+ this.doc = new DOMImplementation().createDocument(null, null, null);
2517
+ if (this.locator) {
2518
+ this.doc.documentURI = this.locator.systemId;
2519
+ }
2520
+ },
2521
+ startElement: function(namespaceURI, localName, qName, attrs) {
2522
+ var doc = this.doc;
2523
+ var el = doc.createElementNS(namespaceURI, qName || localName);
2524
+ var len = attrs.length;
2525
+ appendElement(this, el);
2526
+ this.currentElement = el;
2527
+ this.locator && position(this.locator, el);
2528
+ for (var i = 0; i < len; i++) {
2529
+ var namespaceURI = attrs.getURI(i);
2530
+ var value = attrs.getValue(i);
2531
+ var qName = attrs.getQName(i);
2532
+ var attr = doc.createAttributeNS(namespaceURI, qName);
2533
+ this.locator && position(attrs.getLocator(i), attr);
2534
+ attr.value = attr.nodeValue = value;
2535
+ el.setAttributeNode(attr);
2536
+ }
2537
+ },
2538
+ endElement: function(namespaceURI, localName, qName) {
2539
+ var current = this.currentElement;
2540
+ var tagName = current.tagName;
2541
+ this.currentElement = current.parentNode;
2542
+ },
2543
+ startPrefixMapping: function(prefix, uri) {
2544
+ },
2545
+ endPrefixMapping: function(prefix) {
2546
+ },
2547
+ processingInstruction: function(target, data) {
2548
+ var ins = this.doc.createProcessingInstruction(target, data);
2549
+ this.locator && position(this.locator, ins);
2550
+ appendElement(this, ins);
2551
+ },
2552
+ ignorableWhitespace: function(ch, start, length) {
2553
+ },
2554
+ characters: function(chars, start, length) {
2555
+ chars = _toString.apply(this, arguments);
2556
+ if (chars) {
2557
+ if (this.cdata) {
2558
+ var charNode = this.doc.createCDATASection(chars);
2559
+ } else {
2560
+ var charNode = this.doc.createTextNode(chars);
2561
+ }
2562
+ if (this.currentElement) {
2563
+ this.currentElement.appendChild(charNode);
2564
+ } else if (/^\s*$/.test(chars)) {
2565
+ this.doc.appendChild(charNode);
2566
+ }
2567
+ this.locator && position(this.locator, charNode);
2568
+ }
2569
+ },
2570
+ skippedEntity: function(name) {
2571
+ },
2572
+ endDocument: function() {
2573
+ this.doc.normalize();
2574
+ },
2575
+ setDocumentLocator: function(locator) {
2576
+ if (this.locator = locator) {
2577
+ locator.lineNumber = 0;
2578
+ }
2579
+ },
2580
+ //LexicalHandler
2581
+ comment: function(chars, start, length) {
2582
+ chars = _toString.apply(this, arguments);
2583
+ var comm = this.doc.createComment(chars);
2584
+ this.locator && position(this.locator, comm);
2585
+ appendElement(this, comm);
2586
+ },
2587
+ startCDATA: function() {
2588
+ this.cdata = true;
2589
+ },
2590
+ endCDATA: function() {
2591
+ this.cdata = false;
2592
+ },
2593
+ startDTD: function(name, publicId, systemId) {
2594
+ var impl = this.doc.implementation;
2595
+ if (impl && impl.createDocumentType) {
2596
+ var dt = impl.createDocumentType(name, publicId, systemId);
2597
+ this.locator && position(this.locator, dt);
2598
+ appendElement(this, dt);
2599
+ this.doc.doctype = dt;
2600
+ }
2601
+ },
2602
+ /**
2603
+ * @see org.xml.sax.ErrorHandler
2604
+ * @link http://www.saxproject.org/apidoc/org/xml/sax/ErrorHandler.html
2605
+ */
2606
+ warning: function(error) {
2607
+ console.warn("[xmldom warning] " + error, _locator(this.locator));
2608
+ },
2609
+ error: function(error) {
2610
+ console.error("[xmldom error] " + error, _locator(this.locator));
2611
+ },
2612
+ fatalError: function(error) {
2613
+ throw new ParseError(error, this.locator);
2614
+ }
2615
+ };
2616
+ function _locator(l) {
2617
+ if (l) {
2618
+ return "\n@" + (l.systemId || "") + "#[line:" + l.lineNumber + ",col:" + l.columnNumber + "]";
2619
+ }
2620
+ }
2621
+ function _toString(chars, start, length) {
2622
+ if (typeof chars == "string") {
2623
+ return chars.substr(start, length);
2624
+ } else {
2625
+ if (chars.length >= start + length || start) {
2626
+ return new java.lang.String(chars, start, length) + "";
2627
+ }
2628
+ return chars;
2629
+ }
2630
+ }
2631
+ "endDTD,startEntity,endEntity,attributeDecl,elementDecl,externalEntityDecl,internalEntityDecl,resolveEntity,getExternalSubset,notationDecl,unparsedEntityDecl".replace(/\w+/g, function(key) {
2632
+ DOMHandler.prototype[key] = function() {
2633
+ return null;
2634
+ };
2635
+ });
2636
+ function appendElement(hander, node) {
2637
+ if (!hander.currentElement) {
2638
+ hander.doc.appendChild(node);
2639
+ } else {
2640
+ hander.currentElement.appendChild(node);
2641
+ }
2642
+ }
2643
+ exports.__DOMHandler = DOMHandler;
2644
+ exports.normalizeLineEndings = normalizeLineEndings;
2645
+ exports.DOMParser = DOMParser2;
2646
+ }
2647
+ });
2648
+
2649
+ // node_modules/@xmldom/xmldom/lib/index.js
2650
+ var require_lib = __commonJS({
2651
+ "node_modules/@xmldom/xmldom/lib/index.js"(exports) {
2652
+ var dom = require_dom();
2653
+ exports.DOMImplementation = dom.DOMImplementation;
2654
+ exports.XMLSerializer = dom.XMLSerializer;
2655
+ exports.DOMParser = require_dom_parser().DOMParser;
2656
+ }
2657
+ });
2658
+
47
2659
  // src/transportr.js
48
2660
  var transportr_exports = {};
49
2661
  __export(transportr_exports, {
@@ -512,10 +3124,10 @@ var Transportr = (() => {
512
3124
  #responseStatus;
513
3125
  /**
514
3126
  * @param {string} [message] The error message.
515
- * @param {HttpErrorOptions} [options] The error options.
516
- * @param {Error} [options.cause] The cause of the error.
517
- * @param {ResponseStatus} [options.status] The response status.
518
- * @param {ResponseBody} [options.entity] The error entity from the server, if any.
3127
+ * @param {HttpErrorOptions} [httpErrorOptions] The http error options.
3128
+ * @param {any} [httpErrorOptions.cause] The cause of the error.
3129
+ * @param {ResponseStatus} [httpErrorOptions.status] The response status.
3130
+ * @param {ResponseBody} [httpErrorOptions.entity] The error entity from the server, if any.
519
3131
  */
520
3132
  constructor(message, { cause, status, entity }) {
521
3133
  super(message, { cause });
@@ -547,7 +3159,6 @@ var Transportr = (() => {
547
3159
  return this.#responseStatus?.text;
548
3160
  }
549
3161
  };
550
- var http_error_default = HttpError;
551
3162
 
552
3163
  // src/http-media-type.js
553
3164
  var HttpMediaType = {
@@ -1658,6 +4269,7 @@ var Transportr = (() => {
1658
4269
  };
1659
4270
 
1660
4271
  // src/transportr.js
4272
+ var import_xmldom = __toESM(require_lib(), 1);
1661
4273
  var endsWithSlashRegEx = /\/$/;
1662
4274
  var _handleText = async (response) => await response.text();
1663
4275
  var _handleScript = async (response) => {
@@ -1677,16 +4289,16 @@ var Transportr = (() => {
1677
4289
  var _handleImage = async (response) => URL.createObjectURL(await response.blob());
1678
4290
  var _handleBuffer = async (response) => await response.arrayBuffer();
1679
4291
  var _handleReadableStream = async (response) => response.body;
1680
- var _handleXml = async (response) => new DOMParser().parseFromString(await response.text(), Transportr.MediaType.XML.essence);
1681
- var _handleHtml = async (response) => new DOMParser().parseFromString(await response.text(), Transportr.MediaType.HTML.essence);
4292
+ var _handleXml = async (response) => new import_xmldom.DOMParser().parseFromString(await response.text(), http_media_type_default.XML.essence);
4293
+ var _handleHtml = async (response) => new import_xmldom.DOMParser().parseFromString(await response.text(), http_media_type_default.HTML.essence);
1682
4294
  var _handleHtmlFragment = async (response) => document.createRange().createContextualFragment(await response.text());
1683
- var _baseUrl, _options, _contentTypeHandlers, _defaultRequestOptions, _get, get_fn, _createUrl, createUrl_fn, _request, request_fn, _processResponse, processResponse_fn, _needsSerialization, needsSerialization_fn;
4295
+ var _baseUrl, _options, _contentTypeHandlers, _defaultRequestOptions, _get, get_fn, _request, request_fn, _processResponse, processResponse_fn, _createUrl, createUrl_fn, _needsSerialization, needsSerialization_fn;
1684
4296
  var _Transportr = class {
1685
4297
  /**
1686
4298
  * Create a new Transportr instance with the provided location or origin and context path.
1687
4299
  *
1688
- * @param {URL | string | RequestOptions} [url = location.origin] The URL for {@link fetch} requests.
1689
- * @param {RequestOptions} [options = Transportr.#defaultRequestOptions] The default {@link RequestOptions} for this instance.
4300
+ * @param {URL | string | RequestOptions} [url=location.origin] The URL for {@link fetch} requests.
4301
+ * @param {RequestOptions} [options=Transportr.#defaultRequestOptions] The default {@link RequestOptions} for this instance.
1690
4302
  */
1691
4303
  constructor(url = location.origin, options = __privateGet(_Transportr, _defaultRequestOptions)) {
1692
4304
  /**
@@ -1696,8 +4308,9 @@ var Transportr = (() => {
1696
4308
  * @private
1697
4309
  * @async
1698
4310
  * @param {string} path - The path to the endpoint you want to call.
1699
- * @param {RequestOptions} options - The options for the request.
1700
- * @param {ResponseHandler<ResponseBody>} responseHandler - A function that will be called with the response object.
4311
+ * @param {RequestOptions} [userOptions] - The options passed to the public function to use for the request.
4312
+ * @param {RequestOptions} [options] - The options for the request.
4313
+ * @param {ResponseHandler<ResponseBody>} [responseHandler] - A function that will be called with the response object.
1701
4314
  * @returns {Promise<ResponseBody>} The result of the #request method.
1702
4315
  */
1703
4316
  __privateAdd(this, _get);
@@ -1708,7 +4321,8 @@ var Transportr = (() => {
1708
4321
  * @private
1709
4322
  * @async
1710
4323
  * @param {string} path - The path to the resource you want to access.
1711
- * @param {RequestOptions} options - The options to use for the request.
4324
+ * @param {RequestOptions} [userOptions={}] - The options passed to the public function to use for the request.
4325
+ * @param {RequestOptions} [options={}] - The options to use for the request.
1712
4326
  * @param {ResponseHandler<ResponseBody>} [responseHandler] - A function that will be called with the response body as a parameter. This
1713
4327
  * is useful if you want to do something with the response body before returning it.
1714
4328
  * @returns {Promise<ResponseBody>} The response from the API call.
@@ -1742,11 +4356,11 @@ var Transportr = (() => {
1742
4356
  *
1743
4357
  * @async
1744
4358
  * @param {string} path - The path to the resource you want to get.
1745
- * @param {RequestOptions} [options={}] - The options for the request.
4359
+ * @param {RequestOptions} [options] - The options for the request.
1746
4360
  * @returns {Promise<ResponseBody>} A promise that resolves to the response of the request.
1747
4361
  */
1748
- async get(path, options = {}) {
1749
- return __privateMethod(this, _request, request_fn).call(this, path, object_merge_default(options, { method: http_request_methods_default.GET }));
4362
+ async get(path, options) {
4363
+ return __privateMethod(this, _get, get_fn).call(this, path, options);
1750
4364
  }
1751
4365
  /**
1752
4366
  * This function makes a POST request to the given path with the given body and options.
@@ -1754,11 +4368,11 @@ var Transportr = (() => {
1754
4368
  * @async
1755
4369
  * @param {string} path - The path to the endpoint you want to call.
1756
4370
  * @param {Object} body - The body of the request.
1757
- * @param {RequestOptions} [options={}] - The options for the request.
4371
+ * @param {RequestOptions} [options] - The options for the request.
1758
4372
  * @returns {Promise<ResponseBody>} A promise that resolves to the response body.
1759
4373
  */
1760
- async post(path, body, options = {}) {
1761
- return __privateMethod(this, _request, request_fn).call(this, path, object_merge_default(options, { body, method: http_request_methods_default.POST }));
4374
+ async post(path, body, options) {
4375
+ return __privateMethod(this, _request, request_fn).call(this, path, options, { body, method: http_request_methods_default.POST });
1762
4376
  }
1763
4377
  /**
1764
4378
  * This function returns a promise that resolves to the result of a request to the specified path with
@@ -1766,65 +4380,65 @@ var Transportr = (() => {
1766
4380
  *
1767
4381
  * @async
1768
4382
  * @param {string} path - The path to the endpoint you want to call.
1769
- * @param {RequestOptions} [options={}] - The options for the request.
4383
+ * @param {RequestOptions} [options] - The options for the request.
1770
4384
  * @returns {Promise<ResponseBody>} The return value of the #request method.
1771
4385
  */
1772
- async put(path, options = {}) {
1773
- return __privateMethod(this, _request, request_fn).call(this, path, object_merge_default(options, { method: http_request_methods_default.PUT }));
4386
+ async put(path, options) {
4387
+ return __privateMethod(this, _request, request_fn).call(this, path, options, { method: http_request_methods_default.PUT });
1774
4388
  }
1775
4389
  /**
1776
4390
  * It takes a path and options, and returns a request with the method set to PATCH.
1777
4391
  *
1778
4392
  * @async
1779
4393
  * @param {string} path - The path to the endpoint you want to hit.
1780
- * @param {RequestOptions} [options={}] - The options for the request.
4394
+ * @param {RequestOptions} [options] - The options for the request.
1781
4395
  * @returns {Promise<ResponseBody>} A promise that resolves to the response of the request.
1782
4396
  */
1783
- async patch(path, options = {}) {
1784
- return __privateMethod(this, _request, request_fn).call(this, path, object_merge_default(options, { method: http_request_methods_default.PATCH }));
4397
+ async patch(path, options) {
4398
+ return __privateMethod(this, _request, request_fn).call(this, path, options, { method: http_request_methods_default.PATCH });
1785
4399
  }
1786
4400
  /**
1787
4401
  * It takes a path and options, and returns a request with the method set to DELETE.
1788
4402
  *
1789
4403
  * @async
1790
4404
  * @param {string} path - The path to the resource you want to access.
1791
- * @param {RequestOptions} [options={}] - The options for the request.
4405
+ * @param {RequestOptions} [options] - The options for the request.
1792
4406
  * @returns {Promise<ResponseBody>} The result of the request.
1793
4407
  */
1794
- async delete(path, options = {}) {
1795
- return __privateMethod(this, _request, request_fn).call(this, path, object_merge_default(options, { method: http_request_methods_default.DELETE }));
4408
+ async delete(path, options) {
4409
+ return __privateMethod(this, _request, request_fn).call(this, path, options, { method: http_request_methods_default.DELETE });
1796
4410
  }
1797
4411
  /**
1798
4412
  * Returns the response headers of a request to the given path.
1799
4413
  *
1800
4414
  * @async
1801
4415
  * @param {string} path - The path to the resource you want to access.
1802
- * @param {RequestOptions} [options={}] - The options for the request.
4416
+ * @param {RequestOptions} [options] - The options for the request.
1803
4417
  * @returns {Promise<ResponseBody>} A promise that resolves to the response object.
1804
4418
  */
1805
- async head(path, options = {}) {
1806
- return __privateMethod(this, _request, request_fn).call(this, path, object_merge_default(options, { method: http_request_methods_default.HEAD }));
4419
+ async head(path, options) {
4420
+ return __privateMethod(this, _request, request_fn).call(this, path, options, { method: http_request_methods_default.HEAD });
1807
4421
  }
1808
4422
  /**
1809
4423
  * It takes a path and options, and returns a request with the method set to OPTIONS.
1810
4424
  *
1811
4425
  * @async
1812
4426
  * @param {string} path - The path to the resource.
1813
- * @param {RequestOptions} [options={}] - The options for the request.
4427
+ * @param {RequestOptions} [options] - The options for the request.
1814
4428
  * @returns {Promise<ResponseBody>} The return value of the #request method.
1815
4429
  */
1816
- async options(path, options = {}) {
1817
- return __privateMethod(this, _request, request_fn).call(this, path, object_merge_default(options, { method: http_request_methods_default.OPTIONS }));
4430
+ async options(path, options) {
4431
+ return __privateMethod(this, _request, request_fn).call(this, path, options, { method: http_request_methods_default.OPTIONS });
1818
4432
  }
1819
4433
  /**
1820
4434
  * It takes a path and options, and makes a request to the server.
1821
4435
  *
1822
4436
  * @async
1823
4437
  * @param {string} path - The path to the endpoint you want to hit.
1824
- * @param {RequestOptions} [options={}] - The options for the request.
4438
+ * @param {RequestOptions} [options] - The options for the request.
1825
4439
  * @returns {Promise<ResponseBody>} The return value of the function is the return value of the function that is passed to the `then` method of the promise returned by the `fetch` method.
1826
4440
  */
1827
- async request(path, options = {}) {
4441
+ async request(path, options) {
1828
4442
  return __privateMethod(this, _request, request_fn).call(this, path, options);
1829
4443
  }
1830
4444
  /**
@@ -1832,43 +4446,35 @@ var Transportr = (() => {
1832
4446
  *
1833
4447
  * @async
1834
4448
  * @param {string} path - The path to the resource.
1835
- * @param {RequestOptions} [options={}] - The options object to pass to the request.
4449
+ * @param {RequestOptions} [options] - The options object to pass to the request.
1836
4450
  * @returns {Promise<JsonObject>} A promise that resolves to the response body as a JSON object.
1837
4451
  */
1838
- async getJson(path, options = {}) {
1839
- return __privateMethod(this, _get, get_fn).call(this, path, object_merge_default(options, { headers: { [http_request_headers_default.ACCEPT]: _Transportr.MediaType.JSON } }), _handleJson);
4452
+ async getJson(path, options) {
4453
+ return __privateMethod(this, _get, get_fn).call(this, path, options, { headers: { [http_request_headers_default.ACCEPT]: http_media_type_default.JSON } }, _handleJson);
1840
4454
  }
1841
4455
  /**
1842
4456
  * It gets the XML representation of the resource at the given path.
1843
4457
  *
1844
4458
  * @async
1845
4459
  * @param {string} path - The path to the resource you want to get.
1846
- * @param {RequestOptions} [options={}] - The options for the request.
4460
+ * @param {RequestOptions} [options] - The options for the request.
1847
4461
  * @returns {Promise<Document>} The result of the function call to #get.
1848
4462
  */
1849
- async getXml(path, options = {}) {
1850
- return await __privateMethod(this, _get, get_fn).call(this, path, object_merge_default(options, { headers: { [http_request_headers_default.ACCEPT]: _Transportr.MediaType.XML } }), _handleXml);
4463
+ async getXml(path, options) {
4464
+ return __privateMethod(this, _get, get_fn).call(this, path, options, { headers: { [http_request_headers_default.ACCEPT]: http_media_type_default.XML } }, _handleXml);
1851
4465
  }
1852
- /**
1853
- * TODO - Add way to return portion of the retrieved HTML using a selector. Like jQuery.
1854
- *
1855
- * @async
1856
- * @param {string} path
1857
- * @param {RequestOptions} [options = {}]
1858
- * @returns {Promise<Document>}
1859
- */
1860
4466
  /**
1861
4467
  * Get the HTML content of the specified path.
1862
4468
  *
1863
4469
  * @todo Add way to return portion of the retrieved HTML using a selector. Like jQuery.
1864
4470
  * @async
1865
4471
  * @param {string} path - The path to the resource.
1866
- * @param {RequestOptions} [options={}] - The options for the request.
4472
+ * @param {RequestOptions} [options] - The options for the request.
1867
4473
  * @returns {Promise<Document>} The return value of the function is the return value of the function passed to the `then`
1868
4474
  * method of the promise returned by the `#get` method.
1869
4475
  */
1870
- async getHtml(path, options = {}) {
1871
- return __privateMethod(this, _get, get_fn).call(this, path, object_merge_default(options, { headers: { [http_request_headers_default.ACCEPT]: http_media_type_default.HTML } }), _handleHtml);
4476
+ async getHtml(path, options) {
4477
+ return __privateMethod(this, _get, get_fn).call(this, path, options, { headers: { [http_request_headers_default.ACCEPT]: http_media_type_default.HTML } }, _handleHtml);
1872
4478
  }
1873
4479
  /**
1874
4480
  * It returns a promise that resolves to the HTML fragment at the given path.
@@ -1876,11 +4482,11 @@ var Transportr = (() => {
1876
4482
  * @todo - Add way to return portion of the retrieved HTML using a selector. Like jQuery.
1877
4483
  * @async
1878
4484
  * @param {string} path - The path to the resource.
1879
- * @param {RequestOptions} [options={}] - The options for the request.
4485
+ * @param {RequestOptions} [options] - The options for the request.
1880
4486
  * @returns {Promise<DocumentFragment>} A promise that resolves to an HTML fragment.
1881
4487
  */
1882
- async getHtmlFragment(path, options = {}) {
1883
- return __privateMethod(this, _get, get_fn).call(this, path, object_merge_default(options, { headers: { [http_request_headers_default.ACCEPT]: http_media_type_default.HTML } }), _handleHtmlFragment);
4488
+ async getHtmlFragment(path, options) {
4489
+ return __privateMethod(this, _get, get_fn).call(this, path, options, { headers: { [http_request_headers_default.ACCEPT]: http_media_type_default.HTML } }, _handleHtmlFragment);
1884
4490
  }
1885
4491
  /**
1886
4492
  * It gets a script from the server, and appends the script to the {@link Document} {@link HTMLHeadElement}
@@ -1888,66 +4494,66 @@ var Transportr = (() => {
1888
4494
  *
1889
4495
  * @async
1890
4496
  * @param {string} path - The path to the script.
1891
- * @param {RequestOptions} [options={}] - The options for the request.
4497
+ * @param {RequestOptions} [options] - The options for the request.
1892
4498
  * @returns {Promise<void>} A promise that has been resolved.
1893
4499
  */
1894
- async getScript(path, options = {}) {
1895
- return __privateMethod(this, _get, get_fn).call(this, path, object_merge_default(options, { headers: { [http_request_headers_default.ACCEPT]: http_media_type_default.JAVA_SCRIPT } }), _handleScript);
4500
+ async getScript(path, options) {
4501
+ return __privateMethod(this, _get, get_fn).call(this, path, options, { headers: { [http_request_headers_default.ACCEPT]: http_media_type_default.JAVA_SCRIPT } }, _handleScript);
1896
4502
  }
1897
4503
  /**
1898
4504
  * Gets a stylesheet from the server, and adds it as a {@link Blob} {@link URL}.
1899
4505
  *
1900
4506
  * @async
1901
4507
  * @param {string} path - The path to the stylesheet.
1902
- * @param {RequestOptions} [options={}] - The options for the request.
4508
+ * @param {RequestOptions} [options] - The options for the request.
1903
4509
  * @returns {Promise<void>} A promise that has been resolved.
1904
4510
  */
1905
- async getStylesheet(path, options = {}) {
1906
- return __privateMethod(this, _get, get_fn).call(this, path, object_merge_default(options, { headers: { [http_request_headers_default.ACCEPT]: http_media_type_default.CSS } }), _handleCss);
4511
+ async getStylesheet(path, options) {
4512
+ return __privateMethod(this, _get, get_fn).call(this, path, options, { headers: { [http_request_headers_default.ACCEPT]: http_media_type_default.CSS } }, _handleCss);
1907
4513
  }
1908
4514
  /**
1909
4515
  * It returns a blob from the specified path.
1910
4516
  *
1911
4517
  * @async
1912
4518
  * @param {string} path - The path to the resource.
1913
- * @param {RequestOptions} [options={}] - The options for the request.
4519
+ * @param {RequestOptions} [options] - The options for the request.
1914
4520
  * @returns {Promise<Blob>} A promise that resolves to a blob.
1915
4521
  */
1916
- async getBlob(path, options = {}) {
1917
- return await __privateMethod(this, _get, get_fn).call(this, path, object_merge_default(options, { headers: { [http_request_headers_default.ACCEPT]: http_media_type_default.BIN } }), _handleBlob);
4522
+ async getBlob(path, options) {
4523
+ return __privateMethod(this, _get, get_fn).call(this, path, options, { headers: { [http_request_headers_default.ACCEPT]: http_media_type_default.BIN } }, _handleBlob);
1918
4524
  }
1919
4525
  /**
1920
4526
  * It returns a promise that resolves to an object URL.
1921
4527
  *
1922
4528
  * @async
1923
4529
  * @param {string} path - The path to the resource.
1924
- * @param {RequestOptions} [options={}] - The options for the request.
4530
+ * @param {RequestOptions} [options] - The options for the request.
1925
4531
  * @returns {Promise<string>} A promise that resolves to an object URL.
1926
4532
  */
1927
- async getImage(path, options = {}) {
1928
- return await __privateMethod(this, _get, get_fn).call(this, path, object_merge_default(options, { headers: { [http_request_headers_default.ACCEPT]: "image/*" } }), _handleImage);
4533
+ async getImage(path, options) {
4534
+ return __privateMethod(this, _get, get_fn).call(this, path, options, { headers: { [http_request_headers_default.ACCEPT]: "image/*" } }, _handleImage);
1929
4535
  }
1930
4536
  /**
1931
4537
  * It gets a buffer from the specified path
1932
4538
  *
1933
4539
  * @async
1934
4540
  * @param {string} path - The path to the resource.
1935
- * @param {RequestOptions} [options={}] - The options for the request.
4541
+ * @param {RequestOptions} [options] - The options for the request.
1936
4542
  * @returns {Promise<ArrayBuffer>} A promise that resolves to a buffer.
1937
4543
  */
1938
- async getBuffer(path, options = {}) {
1939
- return await __privateMethod(this, _get, get_fn).call(this, path, object_merge_default(options, { headers: { [http_request_headers_default.ACCEPT]: http_media_type_default.BIN } }), _handleBuffer);
4544
+ async getBuffer(path, options) {
4545
+ return __privateMethod(this, _get, get_fn).call(this, path, options, { headers: { [http_request_headers_default.ACCEPT]: http_media_type_default.BIN } }, _handleBuffer);
1940
4546
  }
1941
4547
  /**
1942
4548
  * It returns a readable stream of the response body from the specified path.
1943
4549
  *
1944
4550
  * @async
1945
4551
  * @param {string} path - The path to the resource.
1946
- * @param {RequestOptions} [options={}] - The options for the request.
4552
+ * @param {RequestOptions} [options] - The options for the request.
1947
4553
  * @returns {Promise<ReadableStream<Uint8Array>>} A readable stream.
1948
4554
  */
1949
- async getStream(path, options = {}) {
1950
- return await __privateMethod(this, _get, get_fn).call(this, path, object_merge_default(options, { headers: { [http_request_headers_default.ACCEPT]: http_media_type_default.BIN } }), _handleReadableStream);
4555
+ async getStream(path, options) {
4556
+ return __privateMethod(this, _get, get_fn).call(this, path, options, { headers: { [http_request_headers_default.ACCEPT]: http_media_type_default.BIN } }, _handleReadableStream);
1951
4557
  }
1952
4558
  };
1953
4559
  var Transportr = _Transportr;
@@ -1956,24 +4562,19 @@ var Transportr = (() => {
1956
4562
  _contentTypeHandlers = new WeakMap();
1957
4563
  _defaultRequestOptions = new WeakMap();
1958
4564
  _get = new WeakSet();
1959
- get_fn = async function(path, options, responseHandler) {
1960
- return __privateMethod(this, _request, request_fn).call(this, path, object_merge_default(options, { method: _Transportr.Method.GET }), responseHandler);
1961
- };
1962
- _createUrl = new WeakSet();
1963
- createUrl_fn = function(url, path, searchParams = new URLSearchParams()) {
1964
- url = path.startsWith("/") ? new URL(`${url.pathname.replace(endsWithSlashRegEx, "")}${path}`, url.origin) : new URL(path);
1965
- for (const [name, value] of searchParams) {
1966
- url.searchParams.append(name, value);
1967
- }
1968
- return url;
4565
+ get_fn = async function(path, userOptions, options, responseHandler) {
4566
+ return __privateMethod(this, _request, request_fn).call(this, path, userOptions, options, responseHandler);
1969
4567
  };
1970
4568
  _request = new WeakSet();
1971
- request_fn = async function(path, options, responseHandler) {
4569
+ request_fn = async function(path, userOptions = {}, options = {}, responseHandler) {
1972
4570
  var _a, _b, _c, _d;
1973
- const requestOptions = object_merge_default(__privateGet(this, _options), options);
1974
- const headers = new Headers(requestOptions.headers);
4571
+ if (object_type_default(userOptions.headers) == Headers) {
4572
+ userOptions.headers = Object.fromEntries(userOptions.headers.entries());
4573
+ }
4574
+ const requestOptions = object_merge_default(__privateGet(this, _options), userOptions, options);
4575
+ requestOptions.headers = new Headers(requestOptions.headers);
1975
4576
  const errorMessage = `An error has occurred with your Request: ${path}`;
1976
- if (__privateMethod(_a = _Transportr, _needsSerialization, needsSerialization_fn).call(_a, options.method, headers)) {
4577
+ if (__privateMethod(_a = _Transportr, _needsSerialization, needsSerialization_fn).call(_a, requestOptions.method, requestOptions.headers.get(http_request_headers_default.CONTENT_TYPE))) {
1977
4578
  requestOptions.body = JSON.stringify(requestOptions.body);
1978
4579
  }
1979
4580
  if (requestOptions.searchParams && !(requestOptions.searchParams instanceof URLSearchParams)) {
@@ -1984,10 +4585,10 @@ var Transportr = (() => {
1984
4585
  response = await fetch(__privateMethod(_b = _Transportr, _createUrl, createUrl_fn).call(_b, __privateGet(this, _baseUrl), path, requestOptions.searchParams), requestOptions);
1985
4586
  } catch (error) {
1986
4587
  console.error(errorMessage, error);
1987
- throw new http_error_default(errorMessage, { cause: error, status: new ResponseStatus(response.status, response.statusText) });
4588
+ throw new HttpError(errorMessage, { cause: error, status: new ResponseStatus(response.status, response.statusText) });
1988
4589
  }
1989
4590
  if (!response.ok) {
1990
- throw new http_error_default(errorMessage, { status: new ResponseStatus(response.status, response.statusText), entity: await __privateMethod(_c = _Transportr, _processResponse, processResponse_fn).call(_c, response) });
4591
+ throw new HttpError(errorMessage, { status: new ResponseStatus(response.status, response.statusText), entity: await __privateMethod(_c = _Transportr, _processResponse, processResponse_fn).call(_c, response) });
1991
4592
  }
1992
4593
  return await __privateMethod(_d = _Transportr, _processResponse, processResponse_fn).call(_d, response, responseHandler);
1993
4594
  };
@@ -2009,13 +4610,31 @@ var Transportr = (() => {
2009
4610
  } catch (error) {
2010
4611
  const errorMessage = "Unable to process response.";
2011
4612
  console.error(errorMessage, error, response);
2012
- throw new http_error_default(errorMessage, { cause: error });
4613
+ throw new HttpError(errorMessage, { cause: error });
2013
4614
  }
2014
4615
  };
4616
+ _createUrl = new WeakSet();
4617
+ createUrl_fn = function(url, path, searchParams = new URLSearchParams()) {
4618
+ url = path.startsWith("/") ? new URL(`${url.pathname.replace(endsWithSlashRegEx, "")}${path}`, url.origin) : new URL(path);
4619
+ searchParams.forEach(([name, value]) => url.searchParams.append(name, value));
4620
+ return url;
4621
+ };
2015
4622
  _needsSerialization = new WeakSet();
2016
- needsSerialization_fn = function(method, headers) {
2017
- return [http_request_methods_default.POST, http_request_methods_default.PUT, http_request_methods_default.PATCH].includes(method) && headers.get(_Transportr.RequestHeader.CONTENT_TYPE) == _Transportr.MediaType.JSON;
4623
+ needsSerialization_fn = function(method, contentType) {
4624
+ return contentType == http_media_type_default.JSON && [http_request_methods_default.POST, http_request_methods_default.PUT, http_request_methods_default.PATCH].includes(method);
2018
4625
  };
4626
+ /**
4627
+ * It takes a response and a handler, and if the handler is not defined, it tries to find a handler
4628
+ * based on the response's content type
4629
+ *
4630
+ * @private
4631
+ * @static
4632
+ * @async
4633
+ * @param {Response} response - The response object returned by the fetch API.
4634
+ * @param {ResponseHandler<ResponseBody>} [handler] - The handler to use for processing the response.
4635
+ * @returns {Promise<ResponseBody>} The response is being returned.
4636
+ */
4637
+ __privateAdd(Transportr, _processResponse);
2019
4638
  /**
2020
4639
  * It takes a URL, a path, and a set of search parameters, and returns a new URL with the path and
2021
4640
  * search parameters applied.
@@ -2029,18 +4648,6 @@ var Transportr = (() => {
2029
4648
  * appended to the end of the pathname.
2030
4649
  */
2031
4650
  __privateAdd(Transportr, _createUrl);
2032
- /**
2033
- * It takes a response and a handler, and if the handler is not defined, it tries to find a handler
2034
- * based on the response's content type
2035
- *
2036
- * @private
2037
- * @static
2038
- * @async
2039
- * @param {Response} response - The response object returned by the fetch API.
2040
- * @param {ResponseHandler<ResponseBody>} [handler] - The handler to use for processing the response.
2041
- * @returns {Promise<ResponseBody>} The response is being returned.
2042
- */
2043
- __privateAdd(Transportr, _processResponse);
2044
4651
  /**
2045
4652
  * If the request method is POST, PUT, or PATCH, and the content type is JSON, then the request body
2046
4653
  * needs to be serialized.
@@ -2048,7 +4655,7 @@ var Transportr = (() => {
2048
4655
  * @private
2049
4656
  * @static
2050
4657
  * @param {RequestMethod} method - The HTTP request method.
2051
- * @param {RequestHeaders} headers - The headers of the request.
4658
+ * @param {HttpMediaType} contentType - The headers of the request.
2052
4659
  * @returns {boolean} `true` if the request body needs to be serialized, `false` otherwise.
2053
4660
  */
2054
4661
  __privateAdd(Transportr, _needsSerialization);
@@ -2069,69 +4676,70 @@ var Transportr = (() => {
2069
4676
  ]));
2070
4677
  /**
2071
4678
  * @static
2072
- * @constant {Object<string, RequestMethod>}
4679
+ * @constant {Object<string, HttpRequestMethod>}
2073
4680
  */
2074
4681
  __publicField(Transportr, "Method", Object.freeze(http_request_methods_default));
2075
4682
  /**
2076
4683
  * @static
2077
- * @constant {Object<string, string>}
4684
+ * @constant {Object<string, HttpMediaType>}
2078
4685
  */
2079
- __publicField(Transportr, "MediaType", http_media_type_default);
4686
+ __publicField(Transportr, "MediaType", Object.freeze(http_media_type_default));
2080
4687
  /**
2081
4688
  * @static
2082
- * @constant {Object<string, string>}
4689
+ * @see {@link HttpRequestHeader}
4690
+ * @constant {Object<string, HttpRequestHeader>}
2083
4691
  */
2084
- __publicField(Transportr, "RequestHeader", http_request_headers_default);
4692
+ __publicField(Transportr, "RequestHeader", Object.freeze(http_request_headers_default));
2085
4693
  /**
2086
4694
  * @static
2087
- * @constant {Object<string, string>}
4695
+ * @constant {Object<string, HttpResponseHeader>}
2088
4696
  */
2089
4697
  __publicField(Transportr, "ResponseHeader", Object.freeze(http_response_headers_default));
2090
4698
  /**
2091
4699
  * @static
2092
4700
  * @constant {Object<string, RequestCache>}
2093
4701
  */
2094
- __publicField(Transportr, "CachingPolicy", {
4702
+ __publicField(Transportr, "CachingPolicy", Object.freeze({
2095
4703
  DEFAULT: "default",
2096
4704
  FORCE_CACHE: "force-cache",
2097
4705
  NO_CACHE: "no-cache",
2098
4706
  NO_STORE: "no-store",
2099
4707
  ONLY_IF_CACHED: "only-if-cached",
2100
4708
  RELOAD: "reload"
2101
- });
4709
+ }));
2102
4710
  /**
2103
4711
  * @static
2104
4712
  * @constant {Object<string, RequestCredentials>}
2105
4713
  */
2106
- __publicField(Transportr, "CredentialsPolicy", {
4714
+ __publicField(Transportr, "CredentialsPolicy", Object.freeze({
2107
4715
  INCLUDE: "include",
2108
4716
  OMIT: "omit",
2109
4717
  SAME_ORIGIN: "same-origin"
2110
- });
4718
+ }));
2111
4719
  /**
2112
4720
  * @static
2113
4721
  * @constant {Object<string, RequestMode>}
2114
4722
  */
2115
- __publicField(Transportr, "RequestMode", {
4723
+ __publicField(Transportr, "RequestMode", Object.freeze({
2116
4724
  CORS: "cors",
2117
4725
  NAVIGATE: "navigate",
2118
4726
  NO_CORS: "no-cors",
2119
4727
  SAME_ORIGIN: "same-origin"
2120
- });
4728
+ }));
2121
4729
  /**
2122
4730
  * @static
2123
4731
  * @constant {Object<string, RequestRedirect>}
2124
4732
  */
2125
- __publicField(Transportr, "RedirectPolicy", {
4733
+ __publicField(Transportr, "RedirectPolicy", Object.freeze({
2126
4734
  ERROR: "error",
2127
4735
  FOLLOW: "follow",
2128
4736
  MANUAL: "manual"
2129
- });
4737
+ }));
2130
4738
  /**
2131
4739
  * @static
2132
4740
  * @constant {Object<string, ReferrerPolicy>}
2133
4741
  */
2134
- __publicField(Transportr, "ReferrerPolicy", {
4742
+ __publicField(Transportr, "ReferrerPolicy", Object.freeze({
2135
4743
  NO_REFERRER: "no-referrer",
2136
4744
  NO_REFERRER_WHEN_DOWNGRADE: "no-referrer-when-downgrade",
2137
4745
  ORIGIN: "origin",
@@ -2140,26 +4748,27 @@ var Transportr = (() => {
2140
4748
  STRICT_ORIGIN: "strict-origin",
2141
4749
  STRICT_ORIGIN_WHEN_CROSS_ORIGIN: "strict-origin-when-cross-origin",
2142
4750
  UNSAFE_URL: "unsafe-url"
2143
- });
4751
+ }));
2144
4752
  /**
4753
+ * @private
2145
4754
  * @static
2146
4755
  * @type {RequestOptions}
2147
4756
  */
2148
- __privateAdd(Transportr, _defaultRequestOptions, {
4757
+ __privateAdd(Transportr, _defaultRequestOptions, Object.freeze({
2149
4758
  body: null,
2150
4759
  cache: _Transportr.CachingPolicy.NO_STORE,
2151
4760
  credentials: _Transportr.CredentialsPolicy.SAME_ORIGIN,
2152
4761
  headers: {},
2153
4762
  integrity: void 0,
2154
4763
  keepalive: void 0,
2155
- method: void 0,
4764
+ method: http_request_methods_default.GET,
2156
4765
  mode: _Transportr.RequestMode.CORS,
2157
4766
  redirect: _Transportr.RedirectPolicy.FOLLOW,
2158
4767
  referrer: "about:client",
2159
4768
  referrerPolicy: _Transportr.ReferrerPolicy.STRICT_ORIGIN_WHEN_CROSS_ORIGIN,
2160
4769
  signal: null,
2161
4770
  window: null
2162
- });
4771
+ }));
2163
4772
  return __toCommonJS(transportr_exports);
2164
4773
  })();
2165
4774
  window.Transportr = Transportr.default;