osm2geojson-lite 1.2.0 → 2.1.0

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,161 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.XmlParser = void 0;
4
- function conditioned(evt) {
5
- return evt.match(/^(.+?)\[(.+?)\]>$/g) !== null;
6
- }
7
- function parseEvent(evt) {
8
- const match = /^(.+?)\[(.+?)\]>$/g.exec(evt);
9
- if (match) {
10
- return { evt: match[1] + '>', exp: match[2] };
11
- }
12
- return { evt };
13
- }
14
- function genConditionFunc(cond) {
15
- const body = 'return ' + cond.replace(/(\$.+?)(?=[=!.])/g, 'node.$&') + ';';
16
- return new Function('node', body);
17
- }
18
- class XmlParser {
19
- constructor(opts) {
20
- this.queryParent = false;
21
- this.progressive = false;
22
- this.parentMap = new WeakMap();
23
- if (opts) {
24
- this.queryParent = opts.queryParent ? true : false;
25
- this.progressive = opts.progressive;
26
- if (this.queryParent) {
27
- this.parentMap = new WeakMap();
28
- }
29
- }
30
- this.evtListeners = {};
31
- }
32
- parse(xml, parent, dir) {
33
- dir = dir ? dir + '.' : '';
34
- const nodeRegEx = /<([^ >\/]+)(.*?)>/mg;
35
- const nodes = [];
36
- let nodeMatch = nodeRegEx.exec(xml);
37
- while (nodeMatch) {
38
- const tag = nodeMatch[1];
39
- const node = { $tag: tag };
40
- const fullTag = dir + tag;
41
- const attrText = nodeMatch[2].trim();
42
- let closed = false;
43
- if (attrText.endsWith('/') || tag.startsWith('?') || tag.startsWith('!')) {
44
- closed = true;
45
- }
46
- const attRegEx1 = /([^ ]+?)="(.+?)"/g;
47
- const attRegEx2 = /([^ ]+?)='(.+?)'/g;
48
- let attMatch = attRegEx1.exec(attrText);
49
- let hasAttrs = false;
50
- while (attMatch) {
51
- hasAttrs = true;
52
- node[attMatch[1]] = attMatch[2];
53
- attMatch = attRegEx1.exec(attrText);
54
- }
55
- if (!hasAttrs) {
56
- attMatch = attRegEx2.exec(attrText);
57
- while (attMatch) {
58
- hasAttrs = true;
59
- node[attMatch[1]] = attMatch[2];
60
- attMatch = attRegEx2.exec(attrText);
61
- }
62
- }
63
- if (!hasAttrs && attrText !== '') {
64
- node.text = attrText;
65
- }
66
- if (this.progressive) {
67
- this.emit(`<${fullTag}>`, node, parent);
68
- }
69
- if (!closed) {
70
- const innerRegEx = new RegExp(`([^]+?)<\/${tag}>`, 'g');
71
- innerRegEx.lastIndex = nodeRegEx.lastIndex;
72
- const innerMatch = innerRegEx.exec(xml);
73
- if (innerMatch && innerMatch[1]) {
74
- nodeRegEx.lastIndex = innerRegEx.lastIndex;
75
- const innerNodes = this.parse(innerMatch[1], node, fullTag);
76
- if (innerNodes.length > 0) {
77
- node.$innerNodes = innerNodes;
78
- }
79
- else {
80
- node.$innerText = innerMatch[1];
81
- }
82
- }
83
- }
84
- if (this.queryParent && parent) {
85
- this.parentMap.set(node, parent);
86
- }
87
- if (this.progressive) {
88
- this.emit(`</${fullTag}>`, node, parent);
89
- }
90
- nodes.push(node);
91
- nodeMatch = nodeRegEx.exec(xml);
92
- }
93
- return nodes;
94
- }
95
- getParent(node) {
96
- if (this.queryParent) {
97
- return this.parentMap.get(node);
98
- }
99
- return null;
100
- }
101
- // support javascript condition for the last tag
102
- addListener(evt, func) {
103
- if (conditioned(evt)) {
104
- // func.prototype = evt;
105
- const ev = parseEvent(evt);
106
- if (ev.exp) {
107
- func.condition = genConditionFunc(ev.exp);
108
- }
109
- evt = ev.evt;
110
- }
111
- this.$addListener(evt, func);
112
- }
113
- removeListener(evt, func) {
114
- if (conditioned(evt)) {
115
- const ev = parseEvent(evt);
116
- evt = ev.evt;
117
- }
118
- this.$removeListener(evt, func);
119
- }
120
- on(evt, func) {
121
- this.addListener(evt, func);
122
- }
123
- off(evt, func) {
124
- this.removeListener(evt, func);
125
- }
126
- $addListener(evt, func) {
127
- const funcs = this.evtListeners[evt];
128
- if (funcs) {
129
- funcs.push(func);
130
- }
131
- else {
132
- this.evtListeners[evt] = [func];
133
- }
134
- }
135
- $removeListener(evt, func) {
136
- const funcs = this.evtListeners[evt];
137
- let idx = -1;
138
- if (funcs) {
139
- idx = funcs.indexOf(func);
140
- }
141
- if (idx >= 0) {
142
- funcs.splice(idx, 1);
143
- }
144
- }
145
- emit(evt, ...args) {
146
- const funcs = this.evtListeners[evt];
147
- if (funcs) {
148
- for (const func of funcs) {
149
- if (func.condition) {
150
- if (func.condition.apply(null, args) === true) {
151
- func.apply(null, args);
152
- }
153
- }
154
- else {
155
- func.apply(null, args);
156
- }
157
- }
158
- }
159
- }
160
- }
161
- exports.XmlParser = XmlParser;
@@ -1 +0,0 @@
1
- !function(e){"object"==typeof exports&&"undefined"!=typeof module?module.exports=e():"function"==typeof define&&define.amd?define([],e):("undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:this).osm2geojson=e()}(function(){return function s(o,i,a){function n(t,e){if(!i[t]){if(!o[t]){var r="function"==typeof require&&require;if(!e&&r)return r(t,!0);if(l)return l(t,!0);throw(e=new Error("Cannot find module '"+t+"'")).code="MODULE_NOT_FOUND",e}r=i[t]={exports:{}},o[t][0].call(r.exports,function(e){return n(o[t][1][e]||e)},r,r.exports,s,o,i,a)}return i[t].exports}for(var l="function"==typeof require&&require,e=0;e<a.length;e++)n(a[e]);return n}({1:[function(e,t,r){let v=e("./utils"),b=e("./xmlparser"),w=e("./node"),x=e("./way"),L=e("./relation"),T=e("./ref-elements");t.exports=function(e,t){var{completeFeature:r,renderTagged:s,excludeWay:o}=(t=t)?(n=void 0===t.excludeWay||t.excludeWay,{completeFeature:!!t.completeFeature,renderTagged:!!t.renderTagged,excludeWay:n}):{completeFeature:!1,renderTagged:!1,excludeWay:!0};let i=(t=e).elements?"json":0<=t.indexOf("<osm")?"xml":t.trim().startsWith("{")?"json-raw":"invalid";var l,a,n=new T.RefElements;let d=[];if("json-raw"===i&&(e=JSON.parse(e),i=e.elements?"json":"invalid"),"json"===i){var u,h=n;for(u of e.elements)switch(u.type){case"node":var f=new w.Node(u.id,h);u.tags&&f.addTags(u.tags),f.addProps((0,v.purgeProps)(u,["id","type","tags","lat","lon"])),f.setLatLng(u);break;case"way":var c=new x.Way(u.id,h);if(u.tags&&c.addTags(u.tags),c.addProps((0,v.purgeProps)(u,["id","type","tags","nodes","geometry"])),u.geometry)c.setLatLngArray(u.geometry);else if(u.nodes)for(var p of u.nodes)c.addNodeRef(p);break;case"relation":var g=new L.Relation(u.id,h);if(u.bounds&&g.setBounds([parseFloat(u.bounds.minlon),parseFloat(u.bounds.minlat),parseFloat(u.bounds.maxlon),parseFloat(u.bounds.maxlat)]),u.tags&&g.addTags(u.tags),g.addProps((0,v.purgeProps)(u,["id","type","tags","bounds","members"])),u.members)for(var y of u.members)g.addMember(y)}}else"xml"===i&&(t=e,l=n,(e=new b.XmlParser({progressive:!0})).on("</osm.node>",e=>{var t,r,s=new w.Node(e.id,l);for([t,r]of Object.entries(e))!t.startsWith("$")&&["id","lon","lat"].indexOf(t)<0&&s.addProp(t,r);if(s.setLatLng(e),e.$innerNodes)for(var o of e.$innerNodes)"tag"===o.$tag&&s.addTag(o.k,o.v)}),e.on("</osm.way>",e=>{var t,r,s=new x.Way(e.id,l);for([t,r]of Object.entries(e))!t.startsWith("$")&&["id"].indexOf(t)<0&&s.addProp(t,r);if(e.$innerNodes)for(var o of e.$innerNodes)"nd"===o.$tag?o.lon&&o.lat?s.addLatLng(o):o.ref&&s.addNodeRef(o.ref):"tag"===o.$tag&&s.addTag(o.k,o.v)}),e.on("<osm.relation>",e=>new L.Relation(e.id,l)),e.on("</osm.relation.member>",(e,t)=>{var t=l.get("relation/"+(null==t?void 0:t.id)),r={type:e.type,role:e.role||"",ref:e.ref};if(e.lat&&e.lon){r.lat=e.lat,r.lon=e.lon,r.tags={};for(var[s,o]of Object.entries(e))!s.startsWith("$")&&["type","lat","lon"].indexOf(s)<0&&(r[s]=o)}if(e.$innerNodes){var i,a=[],n=[];for(i of e.$innerNodes)i.lat&&i.lon?a.push(i):i.ref&&n.push(i.ref);0<a.length?r.geometry=a:0<n.length&&(r.nodes=n)}t.addMember(r)}),e.on("</osm.relation.bounds>",(e,t)=>{l.get("relation/"+(null==t?void 0:t.id)).setBounds([parseFloat(e.minlon),parseFloat(e.minlat),parseFloat(e.maxlon),parseFloat(e.maxlat)])}),e.on("</osm.relation.tag>",(e,t)=>{l.get("relation/"+(null==t?void 0:t.id)).addTag(e.k,e.v)}),e.parse(t));n.bindAll();for(a of n.values())if(!(0<a.refCount)||a.hasTag&&s&&!(a instanceof x.Way&&o)){var m=a.toFeatureArray();if(a instanceof L.Relation&&!r&&0<m.length)return m[0].geometry;d=d.concat(m)}return{type:"FeatureCollection",features:d}}},{"./node":3,"./ref-elements":6,"./relation":7,"./utils":8,"./way":10,"./xmlparser":11}],2:[function(e,t,r){Object.defineProperty(r,"__esModule",{value:!0}),r.LateBinder=void 0;r.LateBinder=class{constructor(e,t,r,s){this.container=e,this.valueFunc=t,this.ctx=r,this.args=s}bind(){var e=this.valueFunc.apply(this.ctx,this.args),t=this.container.indexOf(this);t<0||(t=[t,1],e&&t.push(e),Array.prototype.splice.apply(this.container,t))}}},{}],3:[function(e,t,r){Object.defineProperty(r,"__esModule",{value:!0}),r.Node=void 0;var s=e("./osm-object");let o=e("./utils");class i extends s.OsmObject{constructor(e,t){super("node",e,t)}setLatLng(e){this.latLng=e}toFeatureArray(){return this.latLng?[{type:"Feature",id:this.getCompositeId(),properties:this.getProps(),geometry:{type:"Point",coordinates:(0,o.strArrayToFloat)([this.latLng.lon,this.latLng.lat])}}]:[]}getLatLng(){return this.latLng}}r.Node=i},{"./osm-object":4,"./utils":8}],4:[function(e,t,r){Object.defineProperty(r,"__esModule",{value:!0}),r.OsmObject=void 0;r.OsmObject=class{constructor(e,t,r){this.type=e,this.id=t,this.refElems=r,this.tags={},this.props={id:this.getCompositeId()},this.refCount=0,this.hasTag=!1,r&&r.add(this.getCompositeId(),this)}addTags(e){this.tags=Object.assign(this.tags,e),this.hasTag=!0}addTag(e,t){this.tags[e]=t,this.hasTag=!0}addProp(e,t){this.props[e]=t}addProps(e){this.props=Object.assign(this.props,e)}getCompositeId(){return this.type+"/"+this.id}getProps(){return Object.assign(this.props,this.tags)}}},{}],5:[function(e,t,r){t.exports={building:{},highway:{whitelist:["services","rest_area","escape","elevator"]},natural:{blacklist:["coastline","cliff","ridge","arete","tree_row"]},landuse:{},waterway:{whitelist:["riverbank","dock","boatyard","dam"]},amenity:{},leisure:{},barrier:{whitelist:["city_wall","ditch","hedge","retaining_wall","wall","spikes"]},railway:{whitelist:["station","turntable","roundhouse","platform"]},area:{},boundary:{},man_made:{blacklist:["cutline","embankment","pipeline"]},power:{whitelist:["plant","substation","generator","transformer"]},place:{},shop:{},aeroway:{blacklist:["taxiway"]},tourism:{},historic:{},public_transport:{},office:{},"building:part":{},military:{},ruins:{},"area:highway":{},craft:{},golf:{},indoor:{}}},{}],6:[function(e,t,r){Object.defineProperty(r,"__esModule",{value:!0}),r.RefElements=void 0;class s extends Map{constructor(){super(),this.binders=[]}add(e,t){this.set(e,t)}addBinder(e){this.binders.push(e)}bindAll(){this.binders.forEach(e=>e.bind())}}r.RefElements=s},{}],7:[function(e,t,r){Object.defineProperty(r,"__esModule",{value:!0}),r.Relation=void 0;var s=e("./osm-object");let n=e("./way"),l=e("./node"),p=e("./way-collection"),d=e("./late-binder"),a=e("./utils");class o extends s.OsmObject{constructor(e,t){super("relation",e,t),this.relations=[],this.nodes=[],this.bounds=void 0,this.ways=[],this.roles=[]}setBounds(e){this.bounds=e}addMember(e){switch(e.type){case"relation":var t=new d.LateBinder(this.relations,e=>{e=this.refElems.get("relation/"+e);if(e)return e.refCount++,e},this,[e.ref]);this.relations.push(t),this.refElems.addBinder(t);break;case"way":if(e.role||(e.role=""),e.geometry){t=new n.Way(e.ref,this.refElems);t.setLatLngArray(e.geometry),t.refCount++,this.ways.push(t),this.roles.push(e.role)}else if(e.nodes){var r,s=new n.Way(e.ref,this.refElems);for(r of e.nodes)s.addNodeRef(r);s.refCount++,this.ways.push(s),this.roles.push(e.role)}else{t=new d.LateBinder(this.ways,e=>{e=this.refElems.get("way/"+e);if(e)return e.refCount++,e},this,[e.ref]);this.ways.push(t),this.roles.push(e.role),this.refElems.addBinder(t)}break;case"node":var o=null;if(e.lat&&e.lon){(o=new l.Node(e.ref,this.refElems)).setLatLng({lon:e.lon,lat:e.lat}),e.tags&&o.addTags(e.tags);for(var[i,a]of Object.entries(e))["id","type","lat","lon"].indexOf(i)<0&&o.addProp(i,a);o.refCount++,this.nodes.push(o)}else{t=new d.LateBinder(this.nodes,e=>{e=this.refElems.get("node/"+e);if(e)return e.refCount++,e},this,[e.ref]);this.nodes.push(t),this.refElems.addBinder(t)}}}constructStringGeometry(e){e=e?e.mergeWays():[];return 0===e.length?null:{type:"MultiLineString",coordinates:e}}constructPolygonGeometry(e,t){var r=e?e.toRings("counterclockwise"):[],s=t?t.toRings("clockwise"):[];if(0<r.length){var o=[];let e;for(e of r)o.push([e]);for(e=s.shift();e;){for(var i in r)if((0,a.pointInsidePolygon)((0,a.first)(e),r[i])){o[i].push(e);break}e=s.shift()}return 1===o.length?{type:"Polygon",coordinates:o[0]}:{type:"MultiPolygon",coordinates:o}}return null}collectAllWaysForRelation(e,t){var r=[...e.ways],s=[...e.roles];if(0!==e.relations.length)for(var o of e.relations)if(o){t.has(o.id)||this.collectAllWaysForRelation(o,t);var i=t.get(o.id);for(let e=0;e<i.ways.length;e++)r.push(i.ways[e]),s.push(i.roles[e])}return t.set(e.id,{ways:r,roles:s}),{ways:r,roles:s}}toFeatureArray(){var e=[],t=[];let r=[];var s,o=new Map,i=this.collectAllWaysForRelation(this,o),o={type:"Feature",id:this.getCompositeId(),bbox:this.bounds,properties:this.getProps(),geometry:null};if(this.bounds||delete o.bbox,this.roles.some(e=>"outer"===e)){var a=new p.WayCollection,n=new p.WayCollection;for(let e=0;e<i.ways.length;e++){var l=i.ways[e],d=i.roles[e];"outer"===d?a.addWay(l):"inner"===d&&n.addWay(l)}var u=Object.assign({},o),h=this.constructPolygonGeometry(a,n);h&&(u.geometry=h,e.push(u))}else{var f,c=new p.WayCollection;for(f of i.ways)c.addWay(f);h=this.constructStringGeometry(c);h&&((u=Object.assign({},o)).geometry=h,t.push(u))}for(s of this.nodes)r=r.concat(s.toFeatureArray());return[...e,...t,...r]}}r.Relation=o},{"./late-binder":2,"./node":3,"./osm-object":4,"./utils":8,"./way":10,"./way-collection":9}],8:[function(e,t,r){function s(e){return e[0]}function o(e){return e[e.length-1]}function i(e){return e.join(",")}function a(e){return e.map(parseFloat)}Object.defineProperty(r,"__esModule",{value:!0}),r.purgeProps=function(e,t){if(e){var r=Object.assign({},e);if(t)for(var s of t)delete r[s];return r}return{}},r.first=s,r.last=o,r.coordsToKey=i,r.addToMap=function(e,t,r){var s=e[t];s?s.push(r):e[t]=[r]},r.removeFromMap=function(e,t,r){let s=e[t],o=-1;s&&(o=s.indexOf(r));0<=o&&s.splice(o,1)},r.getFirstFromMap=function(e,t){e=e[t];if(e&&0<e.length)return e[0];return null},r.isRing=function(e){return 3<e.length&&i(e[0])===i(o(e))},r.ringDirection=function(s,o,e){o=o||0,e=e||1;var t=s.reduce((e,t,r)=>s[e][o||0]>t[o||0]?e:r,0),r=t<=0?s.length-2:t-1,i=t>=s.length-1?1:t+1,a=s[r][o],n=s[t][o],l=s[i][o],r=s[r][e],t=s[t][e],i=s[i][e],e=(n-a)*(i-r)-(l-a)*(t-r);return e<0?"clockwise":"counterclockwise"},r.pointInsidePolygon=function(r,s,o,i){o=o||0,i=i||1;let a=!1;for(let e=0,t=s.length-1;e<s.length;t=e++)(s[e][o]<=r[o]&&r[o]<s[t][o]||s[t][o]<=r[o]&&r[o]<s[e][o])&&r[i]<(s[t][i]-s[e][i])*(r[o]-s[e][o])/(s[t][o]-s[e][o])+s[e][i]&&(a=!a);return a},r.strArrayArrayToFloat=function(e){return e.map(a)},r.strArrayToFloat=a},{}],9:[function(e,t,r){Object.defineProperty(r,"__esModule",{value:!0}),r.WayCollection=void 0;let i=e("./utils");class s extends Array{constructor(){super(),this.firstMap={},this.lastMap={}}addWay(e){e=e.toCoordsArray();0<e.length&&(this.push(e),(0,i.addToMap)(this.firstMap,(0,i.coordsToKey)((0,i.first)(e)),e),(0,i.addToMap)(this.lastMap,(0,i.coordsToKey)((0,i.last)(e)),e))}mergeWays(){var r=[];let s=this.shift();for(;s;){(0,i.removeFromMap)(this.firstMap,(0,i.coordsToKey)((0,i.first)(s)),s),(0,i.removeFromMap)(this.lastMap,(0,i.coordsToKey)((0,i.last)(s)),s);let e=s,t;do{var o=this.getNextWay(e),o=(t=o.next,o.mergeType);if(t)switch(this.splice(this.indexOf(t),1),(0,i.removeFromMap)(this.firstMap,(0,i.coordsToKey)((0,i.first)(t)),t),(0,i.removeFromMap)(this.lastMap,(0,i.coordsToKey)((0,i.last)(t)),t),o){case 0:e=e.concat(t.slice(1));break;case 1:t.reverse(),e=e.concat(t.slice(1));break;case 2:e.reverse(),e=e.concat(t.slice(1));break;case 3:(e=t.concat(e.slice(1))).reverse()}}while(t);r.push((0,i.strArrayArrayToFloat)(e)),s=this.shift()}return r}getNextWay(e){var t=(0,i.coordsToKey)((0,i.last)(e)),e=(0,i.coordsToKey)((0,i.first)(e)),r=0<this.length?this[0]:null;if(r){var s=(0,i.coordsToKey)((0,i.first)(r)),o=(0,i.coordsToKey)((0,i.last)(r));if(t===s)return{next:r,mergeType:0};if(t===o)return{next:r,mergeType:1};if(e===s)return{next:r,mergeType:2};if(e===o)return{next:r,mergeType:3}}return(r=(0,i.getFirstFromMap)(this.firstMap,t))?{next:r,mergeType:0}:{next:(0,i.getFirstFromMap)(this.lastMap,t),mergeType:1}}toRings(e){var t=this.mergeWays(),r=[];let s=t.shift();for(;s;)(0,i.isRing)(s)&&((0,i.ringDirection)(s)!==e&&s.reverse(),r.push(s)),s=t.shift();return r}}r.WayCollection=s},{"./utils":8}],10:[function(e,t,r){var s=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}},o=(Object.defineProperty(r,"__esModule",{value:!0}),r.Way=void 0,e("./osm-object"));let i=e("./late-binder"),a=e("./utils"),n=s(e("./polytags.json"));class l extends o.OsmObject{constructor(e,t){super("way",e,t),this.latLngArray=[],this.isPolygon=!1}addLatLng(e){this.latLngArray.push(e)}setLatLngArray(e){this.latLngArray=e}addNodeRef(e){e=new i.LateBinder(this.latLngArray,e=>{e=this.refElems.get("node/"+e);if(e)return e.refCount++,e.getLatLng()},this,[e]);this.latLngArray.push(e),this.refElems.addBinder(e)}addTags(e){super.addTags(e);for(var[t,r]of Object.entries(e))this.analyzeTag(t,r)}addTag(e,t){super.addTag(e,t),this.analyzeTag(e,t)}toCoordsArray(){return this.latLngArray.map(e=>[e.lon,e.lat])}toFeatureArray(){var e,t=this.toCoordsArray();return 1<t.length?(t=(0,a.strArrayArrayToFloat)(t),e={type:"Feature",id:this.getCompositeId(),properties:this.getProps(),geometry:{type:"LineString",coordinates:t}},this.isPolygon&&(0,a.isRing)(t)&&("counterclockwise"!==(0,a.ringDirection)(t)&&t.reverse(),e.geometry={type:"Polygon",coordinates:[t]}),[e]):[]}analyzeTag(e,t){e=n.default[e];e&&(this.isPolygon=!0,e.whitelist?this.isPolygon=0<=e.whitelist.indexOf(t):e.blacklist&&(this.isPolygon=!(0<=e.blacklist.indexOf(t))))}}r.Way=l},{"./late-binder":2,"./osm-object":4,"./polytags.json":5,"./utils":8}],11:[function(e,t,r){function o(e){return null!==e.match(/^(.+?)\[(.+?)\]>$/g)}function i(e){var t=/^(.+?)\[(.+?)\]>$/g.exec(e);return t?{evt:t[1]+">",exp:t[2]}:{evt:e}}Object.defineProperty(r,"__esModule",{value:!0}),r.XmlParser=void 0;class s{constructor(e){this.queryParent=!1,this.progressive=!1,this.parentMap=new WeakMap,e&&(this.queryParent=!!e.queryParent,this.progressive=e.progressive,this.queryParent)&&(this.parentMap=new WeakMap),this.evtListeners={}}parse(s,o,i){i=i?i+".":"";var a=/<([^ >\/]+)(.*?)>/gm,n=[];let l=a.exec(s);for(;l;){var d=l[1],u={$tag:d},h=i+d,f=l[2].trim();let e=!1;(f.endsWith("/")||d.startsWith("?")||d.startsWith("!"))&&(e=!0);var c,p=/([^ ]+?)="(.+?)"/g,g=/([^ ]+?)='(.+?)'/g;let t=p.exec(f),r=!1;for(;t;)r=!0,u[t[1]]=t[2],t=p.exec(f);if(!r)for(t=g.exec(f);t;)r=!0,u[t[1]]=t[2],t=g.exec(f);r||""===f||(u.text=f),this.progressive&&this.emit(`<${h}>`,u,o),e||((d=new RegExp(`([^]+?)</${d}>`,"g")).lastIndex=a.lastIndex,(c=d.exec(s))&&c[1]&&(a.lastIndex=d.lastIndex,0<(d=this.parse(c[1],u,h)).length?u.$innerNodes=d:u.$innerText=c[1])),this.queryParent&&o&&this.parentMap.set(u,o),this.progressive&&this.emit(`</${h}>`,u,o),n.push(u),l=a.exec(s)}return n}getParent(e){return this.queryParent?this.parentMap.get(e):null}addListener(e,t){var r,s;o(e)&&((r=i(e)).exp&&(t.condition=(s="return "+(s=r.exp).replace(/(\$.+?)(?=[=!.])/g,"node.$&")+";",new Function("node",s))),e=r.evt),this.$addListener(e,t)}removeListener(e,t){o(e)&&(e=i(e).evt),this.$removeListener(e,t)}on(e,t){this.addListener(e,t)}off(e,t){this.removeListener(e,t)}$addListener(e,t){var r=this.evtListeners[e];r?r.push(t):this.evtListeners[e]=[t]}$removeListener(e,t){e=this.evtListeners[e];let r=-1;0<=(r=e?e.indexOf(t):r)&&e.splice(r,1)}emit(e,...t){e=this.evtListeners[e];if(e)for(var r of e)(!r.condition||!0===r.condition.apply(null,t))&&r.apply(null,t)}}r.XmlParser=s},{}]},{},[1])(1)});