UNPKG

fhir

Version:

Library that assists in handling FHIR resources. Supports serialization between JSON and XML, validation and FhirPath evaluation.

2 lines 3.31 MB
/*! For license information please see bundle.js.LICENSE.txt */ var Fhir;(()=>{var e={381:(e,i)=>{"use strict";Object.defineProperty(i,"__esModule",{value:!0}),i.Constants=void 0;class a{}i.Constants=a,a.PrimitiveTypes=["instant","time","date","dateTime","decimal","boolean","integer","base64Binary","string","uri","url","unsignedInt","positiveInt","code","id","oid","markdown","canonical","Element"],a.DataTypes=["Reference","Narrative","Ratio","Period","Range","Attachment","Identifier","HumanName","Annotation","Address","ContactPoint","SampledData","Quantity","CodeableConcept","Signature","Coding","Timing","Age","Distance","SimpleQuantity","Duration","Count","Money"],a.PrimitiveNumberTypes=["unsignedInt","positiveInt","decimal","integer"],a.PrimitiveDateRegex=/([0-9]([0-9]([0-9][1-9]|[1-9]0)|[1-9]00)|[1-9]000)(-(0[1-9]|1[0-2])(-(0[1-9]|[1-2][0-9]|3[0-1]))?)?/i,a.PrimitiveDateTimeRegex=/([0-9]([0-9]([0-9][1-9]|[1-9]0)|[1-9]00)|[1-9]000)(-(0[1-9]|1[0-2])(-(0[1-9]|[1-2][0-9]|3[0-1])(T([01][0-9]|2[0-3]):[0-5][0-9]:([0-5][0-9]|60)(\.[0-9]+)?(Z|(\+|-)((0[0-9]|1[0-3]):[0-5][0-9]|14:00)))?)?)?/i,a.PrimitiveTimeRegex=/([01][0-9]|2[0-3]):[0-5][0-9]:([0-5][0-9]|60)(\.[0-9]+)?/i,a.PrimitiveCodeRegex=/[^\s]+(\s[^\s]+)*/i,a.PrimitiveOidRegex=/urn:oid:[0-2](\.[1-9]\d*)+/i,a.PrimitiveIdRegex=/[A-Za-z0-9\-\.]{1,64}/i,a.PrimitivePositiveIntRegex=/^(?!0+$)\d+$/i,a.PrimitiveUnsignedIntRegex=/[0]|([1-9][0-9]*)/i,a.PrimitiveIntegerRegex=/[0]|[-+]?[1-9][0-9]*/i,a.PrimitiveDecimalRegex=/-?([0]|([1-9][0-9]*))(\.[0-9]+)?/i},27:(e,i,a)=>{"use strict";Object.defineProperty(i,"__esModule",{value:!0}),i.ConvertToJs=void 0;const t=a(888),l=a(136),o=a(301),r=a(381);i.ConvertToJs=class{constructor(e){this.parser=e||new l.ParseConformance(!0)}convert(e){const i=t.xml2js(e).elements.find((e=>"element"===e.type));if(i)return this.resourceToJS(i,null)}convertToJSON(e){const i=t.xml2js(e);if(1!==i.elements.length)return;const a={},l=this.resourceToJS(i.elements[0],a),o=this.maxLengthOfDs(l);let r="";for(let e=0;e<o+5;e++)r+="D";a.str=r;const d=JSON.stringify(l,null,"\t"),s=new RegExp('"?'+a.str+'"?',"g");return d.replace(s,"")}maxLengthOfDs(e){function i(e){const i=e.match(/DDDD+/g);return i?i.map((e=>e.length)).reduce(((e,i)=>Math.max(e,i)),0):0}return function e(a,t){let l;return l="string"==typeof t?Math.max(a,i(t)):"object"==typeof t?Object.keys(t).map((l=>Math.max(i(l),e(a,t[l])))).reduce(((e,i)=>Math.max(e,i)),a):a,l}(0,e)}resourceToJS(e,i){const a=this.parser.parsedStructureDefinitions[e.name],t={resourceType:e.name};if(!a)throw new Error("Unknown resource type: "+e.name);return a._properties.forEach((a=>{this.propertyToJS(e,t,a,i)})),t}findReferenceType(e){if(!e||!e.startsWith("#"))return;const i=e.substring(1,e.indexOf(".")),a=e.substring(i.length+2),t=this.parser.parsedStructureDefinitions[i],l=a.split(".");if(!t)throw new Error("Could not find resource definition for "+i);let o=t;for(let e=0;e<l.length;e++){const i=l[e];if(o=o._properties.find((e=>e._name===i)),!o)return}return JSON.parse(JSON.stringify(o))}propertyToJS(e,i,a,l){const d=[];if(e.elements)for(const i of e.elements)i.name===a._name&&d.push(i);const s=[];if(e.attributes){const i=Object.keys(e.attributes);for(const t of i)t===a._name&&s.push({name:t,type:"attribute",attributes:{value:e.attributes[t]}})}const n=d.concat(s);if(!n||0===n.length)return;if(a._type&&0===a._type.indexOf("#")){const e=this.findReferenceType(a._type);if(!e)throw new Error("Could not find reference to element definition "+e);e._name=a._name,e._multiple=a._multiple,e._required=a._required,a=e}const p=(e,t)=>{const o=e.attributes&&e.attributes.id,r=!!(e.elements||[]).find((e=>"extension"===e.name));(o||r)&&(i["_"+a._name]||(i["_"+a._name]=i[a._name]instanceof Array?[]:{}));const d=i["_"+a._name];if((o||r)&&d instanceof Array){if(d.length<t+1)for(let e=0;e<t;e++)d[e]||(d[e]=null);d[t]={}}if(o&&(d instanceof Array?d[t].id=e.attributes.id:d.id=e.attributes.id),r){const i={_name:"extension",_type:"Extension",_multiple:!0,_required:!1};this.propertyToJS(e,d instanceof Array?d[t]:d,i,l)}},c=(e,r)=>{if(e)switch(a._type){case"string":case"base64Binary":case"code":case"id":case"markdown":case"uri":case"url":case"canonical":case"oid":case"date":case"dateTime":case"time":case"instant":p(e,r),e.attributes&&e.attributes.value&&(i[a._name]instanceof Array?i[a._name].push(e.attributes.value):i[a._name]=e.attributes.value);break;case"decimal":p(e,r),e.attributes.value&&(i[a._name]instanceof Array?i[a._name].push(m(e.attributes.value,l)):i[a._name]=m(e.attributes.value,l));break;case"boolean":p(e,r),e.attributes.value&&(i[a._name]instanceof Array?i[a._name].push(y(e.attributes.value)):i[a._name]=y(e.attributes.value));break;case"integer":case"unsignedInt":case"positiveInt":p(e,r),e.attributes&&e.attributes.value&&(i[a._name]instanceof Array?i[a._name].push(u(e.attributes.value)):i[a._name]=u(e.attributes.value));break;case"xhtml":if(e.elements&&e.elements.length>0){const l=t.js2xml({elements:[o.XmlHelper.escapeInvalidCharacters(e)]});i[a._name]instanceof Array?i[a._name].push(l):i[a._name]=l}break;case"Element":case"BackboneElement":const d={};for(const i in a._properties){const t=a._properties[i];this.propertyToJS(e,d,t,l)}i[a._name]instanceof Array?i[a._name].push(d):i[a._name]=d;break;case"Resource":if(e.elements&&e.elements.length>0){const t=e.elements.findIndex((e=>"element"===e.type)),o=this.resourceToJS(e.elements[t],l);if(e.elements.length>1){const i=e.elements.filter((e=>"comment"===e.type));i&&i.length>0&&(o.fhir_comments||(o.fhir_comments=[]),o.fhir_comments.push(...i.map((e=>e.comment))))}i[a._name]instanceof Array?i[a._name].push(o):i[a._name]=o}break;default:const s=this.parser.parsedStructureDefinitions[a._type];if(s){const t={};s._properties.forEach((i=>{this.propertyToJS(e,t,i,l)})),i[a._name]instanceof Array?i[a._name].push(t):i[a._name]=t}else console.log("do something")}};function y(e){if("true"===e)return!0;if("false"===e)return!1;throw new Error("Value should be a boolean but got: "+e)}function u(e){if(0==/^-?\d+$/.test(e))throw new Error("Value should be a number but got: "+e);return parseInt(e,10)}function m(e,i){if(0==/^-?([0]|([1-9][0-9]*))(\.[0-9]+)?$/.test(e))throw new Error("Value should be a decimal number but got: "+e);return i?{value:e,toJSON:function(){return i.str+e+i.str}}:e}a._multiple&&(i[a._name]=[]);for(let t=0;t<n.length;t++){let l,o=null;const d=(e.elements||[]).indexOf(n[t]);for(;null!=o||!l;){l||(l=[]);const i=l.length+1;if(d-i<0)break;o=d>0&&"comment"===e.elements[d-i].type?e.elements[d-i]:null,o&&l.push(o)}const s="_"+a._name;c(n[t],t),l&&l.length>0&&(r.Constants.PrimitiveTypes.indexOf(a._type)>=0?a._multiple?(i[s]||(i[s]=[]),i[s][t]||(i[s][t]={}),i[s][t].fhir_comments=l.reverse().map((e=>e.comment))):(i[s]||(i[s]={}),i[s].fhir_comments=l.reverse().map((e=>e.comment))):a._multiple?(i[a._name]||(i[a._name]=[]),i[a._name][t]||(i[a._name][t]={}),i[a._name][t].fhir_comments=l.reverse().map((e=>e.comment))):(i[a._name]||(i[a._name]={}),i[a._name].fhir_comments=l.reverse().map((e=>e.comment))))}}}},248:(e,i,a)=>{"use strict";Object.defineProperty(i,"__esModule",{value:!0}),i.ConvertToXml=void 0;const t=a(888),l=a(136),o=a(301),r=a(381);i.ConvertToXml=class{constructor(e){this.attributeProperties={Extension:"url"},this.parser=e||new l.ParseConformance(!0)}convert(e){if(e.hasOwnProperty("resourceType")){const i=this.resourceToXML(e);return t.js2xml(i)}}resourceToXML(e,i){const a={type:"element",name:e.resourceType,attributes:{xmlns:"http://hl7.org/fhir"},elements:[]};if(i||(i={declaration:{attributes:{version:"1.0",encoding:"UTF-8"}},elements:[a]}),!this.parser.parsedStructureDefinitions[e.resourceType])throw new Error("Unknown resource type: "+e.resourceType);const t=this.parser.parsedStructureDefinitions[e.resourceType]._properties||[];for(const i of t)this.propertyToXML(a,this.parser.parsedStructureDefinitions[e.resourceType],e,i._name);return i}propertyToXML(e,i,a,l,d){const s="id"===l&&!!d||this.attributeProperties[d]===l;if(l.startsWith("_"))return;const n=i._properties.find((e=>e._name==l)),p=(i,a)=>{const r={type:"element",name:l,elements:[],attributes:{}};if(a){if(a.id&&(r.attributes.id=a.id),a.fhir_comments)for(const i of a.fhir_comments)e.elements.push({type:"comment",comment:i});if(a.extension){const e=this.parser.parsedStructureDefinitions.Extension;this.propertyToXML(r,e,a,"extension")}}switch(n._type){case"string":case"base64Binary":case"code":case"id":case"markdown":case"uri":case"url":case"canonical":case"oid":case"boolean":case"integer":case"decimal":case"unsignedInt":case"positiveInt":case"date":case"dateTime":case"time":case"instant":const e=i&&"string"==typeof i?function(e){return e.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/\r/g,"&#xD;").replace(/\n/g,"&#xA;")}(i):i;r.attributes.value=e;break;case"xhtml":if("div"===l&&i){let e;try{e=t.xml2js(i),e=o.XmlHelper.escapeInvalidCharacters(e)}catch(e){throw new Error("The embedded xhtml is not properly formatted/escaped: "+e.message)}1===e.elements.length&&"div"===e.elements[0].name&&(e.elements[0].attributes=e.elements[0].attributes||{},e.elements[0].attributes.xmlns="http://www.w3.org/1999/xhtml",r.elements=e.elements[0].elements,r.attributes=e.elements[0].attributes)}break;case"Resource":if(i){const e=this.resourceToXML(i).elements;for(const i in e)e[i].attributes&&delete e[i].attributes.xmlns;r.elements.push(...e)}break;case"Element":case"BackboneElement":for(const e in n._properties){const a=n._properties[e];this.propertyToXML(r,n,i,a._name,n._type)}break;default:let a=this.parser.parsedStructureDefinitions[n._type];if(n._type.startsWith("#")){const e=n._type.substring(1).split(".");for(let i=0;i<e.length&&(a=0==i?this.parser.parsedStructureDefinitions[e[i]]:a._properties.find((a=>a._name===e[i])),a);i++);}if(a)for(const e of a._properties)this.propertyToXML(r,a,i,e._name,n._type);else console.log("Could not find type "+n._type)}let d=!1;const p=r.elements&&r.elements.length>0;if(r.attributes)for(const e in r.attributes)(r.attributes[e]||!1===r.attributes[e]||0===r.attributes[e])&&(d=!0);s&&r.attributes&&r.attributes.hasOwnProperty("value")?(e.attributes||(e.attributes={}),e.attributes[r.name]=r.attributes.value):(d||p)&&e.elements.push(r)};if(a){let e;if(n._multiple&&a[l])for(let i=0;i<a[l].length;i++)r.Constants.PrimitiveTypes.indexOf(n._type)>=0?a["_"+l]&&(e=a["_"+l][i]):e={fhir_comments:a[l][i].fhir_comments},p(a[l][i],e);else r.Constants.PrimitiveTypes.indexOf(n._type)>=0?e=a["_"+l]:a[l]&&(e={fhir_comments:a[l].fhir_comments}),p(a[l],e)}}}},899:(e,i,a)=>{"use strict";Object.defineProperty(i,"__esModule",{value:!0}),i.Fhir=i.Versions=void 0;const t=a(136),l=a(961),o=a(27),r=a(248),d=a(609),s=a(145);var n;(n=i.Versions||(i.Versions={})).STU3="STU3",n.R4="R4",n.R5="R5",i.Fhir=class{constructor(e){this.parser=e||new t.ParseConformance(!0)}jsonToXml(e){const i=JSON.parse(e);return this.objToXml(i)}objToXml(e){return new r.ConvertToXml(this.parser).convert(e)}xmlToObj(e){return new o.ConvertToJs(this.parser).convert(e)}xmlToJson(e){return new o.ConvertToJs(this.parser).convertToJSON(e)}validate(e,i){return new l.Validator(this.parser,i).validate(e)}evaluate(e,i){const a=new d.FhirPath(e,this.parser);return a.resolve=this.resolve,a.evaluate(i)}resolve(e){}generateSnapshot(e){new s.SnapshotGenerator(this.parser,e).generate()}}},609:(e,i,a)=>{"use strict";Object.defineProperty(i,"__esModule",{value:!0}),i.FhirPath=void 0;const t=a(136);i.FhirPath=class{constructor(e,i){this.operators=["=","!","&","<",">","~"],this.resources=e instanceof Array?e:[e],this.parser=i||new t.ParseConformance(!0)}findClosingParenIndex(e,i){let a=0;for(let t=i;t<e.length;t++)if("("===e[t])a++;else if(")"===e[t]){if(!(a>0))return t;a--}}findClosingQuoteIndex(e,i){for(let a=i;a<e.length;a++)if("'"===e[a]){if("\\"===e[a-1])continue;return a}}internalResolve(e){const i=e.trim().match(/^([A-z]+)\/(.+?)$/);if(i){const e=function e(i,a,t){for(let l=0;l<i.length;l++){const o=i[l];if("Bundle"===o.resourceType){const i=e(o.entry.map((e=>e.resource)),a,t);if(i)return i}if(o.resourceType.toLowerCase()===a.toLowerCase()&&o.id.toLowerCase()===t.toLowerCase())return o}}(this.resources,i[1],i[2]);if(e)return e}return this.resolve(e)}resolve(e){}getResourceTypes(){const e=this;return Object.keys(this.parser.parsedStructureDefinitions).filter((i=>"resource"===e.parser.parsedStructureDefinitions[i]._kind))}parse(e){const i=[];let a={};const t=e.split("."),l=this.getResourceTypes();t.length>0&&l.indexOf(t[0])>=0&&(a.resourceType=t[0],e=e.substring(t[0].length+1));for(let i=0;i<e.length;i++){const t=e[i];if("'"===t){if(0===i){const t=this.findClosingQuoteIndex(e,i+1);a.value=e.substring(i+1,t),i=t}}else if("("===t){if(a.path&&a.path.length>0){const t={name:a.path.pop().toLowerCase()};a.path.push(t);const l=this.findClosingParenIndex(e,i+1),o=e.substring(i+1,l);t.params=this.parse(o),i=l}}else if("'"===t);else if(" "===t);else{if(this.operators.indexOf(t)>=0){const l=a;let o=e.substring(i+1),r=t;this.operators.indexOf(o[0])>=0&&(r+=o[0],o=o.substring(1)),a={left:l,right:this.parse(o.trim())[0],op:r},a.left.path&&a.left.path.length>0&&(a.left.path[a.left.path.length-1]=a.left.path[a.left.path.length-1].trim()),a.right.path&&a.right.path.length>0&&(a.right.path[a.right.path.length-1]=a.right.path[a.right.path.length-1].trim());break}"."===t?a.path.push(""):(a.hasOwnProperty("path")||(a.path=[""]),a.path[a.path.length-1]+=t)}}return i.push(a),i}getValue(e,i){if(void 0===e||null==e)return e;if(!i||0===i.length)return e;const a=i[0],t=i.slice(1);if(e instanceof Array){if("string"==typeof a){let i=[];t.unshift(a);for(let a=0;a<e.length;a++){const l=this.getValue(e[a],t);l instanceof Array?i=i.concat(l):null!=l&&i.push(l)}return i}if("first"===a.name)return this.getValue(e[0],t);if("last"===a.name)return this.getValue(e[e.length-1],t);if("where"===a.name){if(!a.params||0===a.params.length)throw new Error("Expected .where() to have a parameter");const i=[];for(let t=0;t<e.length;t++){const l=JSON.parse(JSON.stringify(a.params)),o=this.internalEvaluate(e[t],l);("boolean"==typeof o&&!0===o||o instanceof Array&&1===o.length&&o[0])&&i.push(e[t])}return this.getValue(i,t)}throw new Error("Unsupported function for arrays "+a.name)}if("string"==typeof a)return this.getValue(e[a],t);if("resolve"===a.name){const i="string"==typeof e?e:e.reference,a=this.internalResolve(i);return this.getValue(a,t)}if("startswith"===a.name){if(!a.params||1!==a.params.length)throw new Error("Expected a single parameter to startsWith()");if("string"!=typeof e)throw new Error("startsWith() must be used on string types");const i=a.params[0].value||this.getValue(e,a.params[0].path);return!(!i||0!==e.indexOf(i))}throw new Error("Unsupported function for objects "+a.name)}internalEvaluate(e,i){let a=[];for(let t=0;t<i.length;t++){const l=i[t];if(l.path&&(l.value=this.getValue(e,l.path)),l.left&&l.left.path&&(l.left.value=this.getValue(e,l.left.path)),l.right&&l.right.path&&(l.right.value=this.getValue(e,l.right.path)),l.op){if(!l.left||!l.right)return!1;switch(l.op){case"=":case"==":return l.left.value===l.right.value;case"!=":return l.left.value!==l.right.value}}else l.value instanceof Array?a=a.concat(l.value):a.push(l.value)}return a}shouldReturnArray(e){return 1===e.length&&(e[0].path||[]).filter((e=>"where"===e.name)).length>0}evaluate(e){if(!e)return;const i=this.parse(e);let a=[];for(let e=0;e<this.resources.length;e++){const t=this.resources[e];a=a.concat(this.internalEvaluate(t,i))}return 1!==this.resources.length||1!==a.length||this.shouldReturnArray(i)?a:a[0]}}},99:(e,i,a)=>{!function(e){e.parser=function(e,i){return new l(e,i)},e.SAXParser=l,e.SAXStream=r,e.createStream=function(e,i){return new r(e,i)},e.MAX_BUFFER_LENGTH=65536;var i,t=["comment","sgmlDecl","textNode","tagName","doctype","procInstName","procInstBody","entity","attribName","attribValue","cdata","script"];function l(i,a){if(!(this instanceof l))return new l(i,a);var o=this;!function(e){for(var i=0,a=t.length;i<a;i++)e[t[i]]=""}(o),o.q=o.c="",o.bufferCheckPosition=e.MAX_BUFFER_LENGTH,o.opt=a||{},o.opt.lowercase=o.opt.lowercase||o.opt.lowercasetags,o.looseCase=o.opt.lowercase?"toLowerCase":"toUpperCase",o.tags=[],o.closed=o.closedRoot=o.sawRoot=!1,o.tag=o.error=null,o.strict=!!i,o.noscript=!(!i&&!o.opt.noscript),o.state=q.BEGIN,o.strictEntities=o.opt.strictEntities,o.ENTITIES=o.strictEntities?Object.create(e.XML_ENTITIES):Object.create(e.ENTITIES),o.attribList=[],o.opt.xmlns&&(o.ns=Object.create(c)),o.trackPosition=!1!==o.opt.position,o.trackPosition&&(o.position=o.line=o.column=0),R(o,"onready")}e.EVENTS=["text","processinginstruction","sgmldeclaration","doctype","comment","opentagstart","attribute","opentag","closetag","opencdata","cdata","closecdata","error","end","ready","script","opennamespace","closenamespace"],Object.create||(Object.create=function(e){function i(){}return i.prototype=e,new i}),Object.keys||(Object.keys=function(e){var i=[];for(var a in e)e.hasOwnProperty(a)&&i.push(a);return i}),l.prototype={end:function(){T(this)},write:function(i){var a=this;if(this.error)throw this.error;if(a.closed)return x(a,"Cannot write after close. Assign an onready handler.");if(null===i)return T(a);"object"==typeof i&&(i=i.toString());for(var l=0,o="";o=W(i,l++),a.c=o,o;)switch(a.trackPosition&&(a.position++,"\n"===o?(a.line++,a.column=0):a.column++),a.state){case q.BEGIN:if(a.state=q.BEGIN_WHITESPACE,"\ufeff"===o)continue;B(a,o);continue;case q.BEGIN_WHITESPACE:B(a,o);continue;case q.TEXT:if(a.sawRoot&&!a.closedRoot){for(var r=l-1;o&&"<"!==o&&"&"!==o;)(o=W(i,l++))&&a.trackPosition&&(a.position++,"\n"===o?(a.line++,a.column=0):a.column++);a.textNode+=i.substring(r,l-1)}"<"!==o||a.sawRoot&&a.closedRoot&&!a.strict?(f(o)||a.sawRoot&&!a.closedRoot||M(a,"Text data outside of root node."),"&"===o?a.state=q.TEXT_ENTITY:a.textNode+=o):(a.state=q.OPEN_WAKA,a.startTagPosition=a.position);continue;case q.SCRIPT:"<"===o?a.state=q.SCRIPT_ENDING:a.script+=o;continue;case q.SCRIPT_ENDING:"/"===o?a.state=q.CLOSE_TAG:(a.script+="<"+o,a.state=q.SCRIPT);continue;case q.OPEN_WAKA:if("!"===o)a.state=q.SGML_DECL,a.sgmlDecl="";else if(f(o));else if(S(y,o))a.state=q.OPEN_TAG,a.tagName=o;else if("/"===o)a.state=q.CLOSE_TAG,a.tagName="";else if("?"===o)a.state=q.PROC_INST,a.procInstName=a.procInstBody="";else{if(M(a,"Unencoded <"),a.startTagPosition+1<a.position){var n=a.position-a.startTagPosition;o=new Array(n).join(" ")+o}a.textNode+="<"+o,a.state=q.TEXT}continue;case q.SGML_DECL:(a.sgmlDecl+o).toUpperCase()===d?(D(a,"onopencdata"),a.state=q.CDATA,a.sgmlDecl="",a.cdata=""):a.sgmlDecl+o==="--"?(a.state=q.COMMENT,a.comment="",a.sgmlDecl=""):(a.sgmlDecl+o).toUpperCase()===s?(a.state=q.DOCTYPE,(a.doctype||a.sawRoot)&&M(a,"Inappropriately located doctype declaration"),a.doctype="",a.sgmlDecl=""):">"===o?(D(a,"onsgmldeclaration",a.sgmlDecl),a.sgmlDecl="",a.state=q.TEXT):g(o)?(a.state=q.SGML_DECL_QUOTED,a.sgmlDecl+=o):a.sgmlDecl+=o;continue;case q.SGML_DECL_QUOTED:o===a.q&&(a.state=q.SGML_DECL,a.q=""),a.sgmlDecl+=o;continue;case q.DOCTYPE:">"===o?(a.state=q.TEXT,D(a,"ondoctype",a.doctype),a.doctype=!0):(a.doctype+=o,"["===o?a.state=q.DOCTYPE_DTD:g(o)&&(a.state=q.DOCTYPE_QUOTED,a.q=o));continue;case q.DOCTYPE_QUOTED:a.doctype+=o,o===a.q&&(a.q="",a.state=q.DOCTYPE);continue;case q.DOCTYPE_DTD:a.doctype+=o,"]"===o?a.state=q.DOCTYPE:g(o)&&(a.state=q.DOCTYPE_DTD_QUOTED,a.q=o);continue;case q.DOCTYPE_DTD_QUOTED:a.doctype+=o,o===a.q&&(a.state=q.DOCTYPE_DTD,a.q="");continue;case q.COMMENT:"-"===o?a.state=q.COMMENT_ENDING:a.comment+=o;continue;case q.COMMENT_ENDING:"-"===o?(a.state=q.COMMENT_ENDED,a.comment=A(a.opt,a.comment),a.comment&&D(a,"oncomment",a.comment),a.comment=""):(a.comment+="-"+o,a.state=q.COMMENT);continue;case q.COMMENT_ENDED:">"!==o?(M(a,"Malformed comment"),a.comment+="--"+o,a.state=q.COMMENT):a.state=q.TEXT;continue;case q.CDATA:"]"===o?a.state=q.CDATA_ENDING:a.cdata+=o;continue;case q.CDATA_ENDING:"]"===o?a.state=q.CDATA_ENDING_2:(a.cdata+="]"+o,a.state=q.CDATA);continue;case q.CDATA_ENDING_2:">"===o?(a.cdata&&D(a,"oncdata",a.cdata),D(a,"onclosecdata"),a.cdata="",a.state=q.TEXT):"]"===o?a.cdata+="]":(a.cdata+="]]"+o,a.state=q.CDATA);continue;case q.PROC_INST:"?"===o?a.state=q.PROC_INST_ENDING:f(o)?a.state=q.PROC_INST_BODY:a.procInstName+=o;continue;case q.PROC_INST_BODY:if(!a.procInstBody&&f(o))continue;"?"===o?a.state=q.PROC_INST_ENDING:a.procInstBody+=o;continue;case q.PROC_INST_ENDING:">"===o?(D(a,"onprocessinginstruction",{name:a.procInstName,body:a.procInstBody}),a.procInstName=a.procInstBody="",a.state=q.TEXT):(a.procInstBody+="?"+o,a.state=q.PROC_INST_BODY);continue;case q.OPEN_TAG:S(u,o)?a.tagName+=o:(V(a),">"===o?k(a):"/"===o?a.state=q.OPEN_TAG_SLASH:(f(o)||M(a,"Invalid character in tag name"),a.state=q.ATTRIB));continue;case q.OPEN_TAG_SLASH:">"===o?(k(a,!0),O(a)):(M(a,"Forward-slash in opening tag not followed by >"),a.state=q.ATTRIB);continue;case q.ATTRIB:if(f(o))continue;">"===o?k(a):"/"===o?a.state=q.OPEN_TAG_SLASH:S(y,o)?(a.attribName=o,a.attribValue="",a.state=q.ATTRIB_NAME):M(a,"Invalid attribute name");continue;case q.ATTRIB_NAME:"="===o?a.state=q.ATTRIB_VALUE:">"===o?(M(a,"Attribute without value"),a.attribValue=a.attribName,L(a),k(a)):f(o)?a.state=q.ATTRIB_NAME_SAW_WHITE:S(u,o)?a.attribName+=o:M(a,"Invalid attribute name");continue;case q.ATTRIB_NAME_SAW_WHITE:if("="===o)a.state=q.ATTRIB_VALUE;else{if(f(o))continue;M(a,"Attribute without value"),a.tag.attributes[a.attribName]="",a.attribValue="",D(a,"onattribute",{name:a.attribName,value:""}),a.attribName="",">"===o?k(a):S(y,o)?(a.attribName=o,a.state=q.ATTRIB_NAME):(M(a,"Invalid attribute name"),a.state=q.ATTRIB)}continue;case q.ATTRIB_VALUE:if(f(o))continue;g(o)?(a.q=o,a.state=q.ATTRIB_VALUE_QUOTED):(M(a,"Unquoted attribute value"),a.state=q.ATTRIB_VALUE_UNQUOTED,a.attribValue=o);continue;case q.ATTRIB_VALUE_QUOTED:if(o!==a.q){"&"===o?a.state=q.ATTRIB_VALUE_ENTITY_Q:a.attribValue+=o;continue}L(a),a.q="",a.state=q.ATTRIB_VALUE_CLOSED;continue;case q.ATTRIB_VALUE_CLOSED:f(o)?a.state=q.ATTRIB:">"===o?k(a):"/"===o?a.state=q.OPEN_TAG_SLASH:S(y,o)?(M(a,"No whitespace between attributes"),a.attribName=o,a.attribValue="",a.state=q.ATTRIB_NAME):M(a,"Invalid attribute name");continue;case q.ATTRIB_VALUE_UNQUOTED:if(!h(o)){"&"===o?a.state=q.ATTRIB_VALUE_ENTITY_U:a.attribValue+=o;continue}L(a),">"===o?k(a):a.state=q.ATTRIB;continue;case q.CLOSE_TAG:if(a.tagName)">"===o?O(a):S(u,o)?a.tagName+=o:a.script?(a.script+="</"+a.tagName,a.tagName="",a.state=q.SCRIPT):(f(o)||M(a,"Invalid tagname in closing tag"),a.state=q.CLOSE_TAG_SAW_WHITE);else{if(f(o))continue;b(y,o)?a.script?(a.script+="</"+o,a.state=q.SCRIPT):M(a,"Invalid tagname in closing tag."):a.tagName=o}continue;case q.CLOSE_TAG_SAW_WHITE:if(f(o))continue;">"===o?O(a):M(a,"Invalid characters in closing tag");continue;case q.TEXT_ENTITY:case q.ATTRIB_VALUE_ENTITY_Q:case q.ATTRIB_VALUE_ENTITY_U:var p,c;switch(a.state){case q.TEXT_ENTITY:p=q.TEXT,c="textNode";break;case q.ATTRIB_VALUE_ENTITY_Q:p=q.ATTRIB_VALUE_QUOTED,c="attribValue";break;case q.ATTRIB_VALUE_ENTITY_U:p=q.ATTRIB_VALUE_UNQUOTED,c="attribValue"}";"===o?(a[c]+=w(a),a.entity="",a.state=p):S(a.entity.length?_:m,o)?a.entity+=o:(M(a,"Invalid character in entity name"),a[c]+="&"+a.entity+o,a.entity="",a.state=p);continue;default:throw new Error(a,"Unknown state: "+a.state)}return a.position>=a.bufferCheckPosition&&function(i){for(var a=Math.max(e.MAX_BUFFER_LENGTH,10),l=0,o=0,r=t.length;o<r;o++){var d=i[t[o]].length;if(d>a)switch(t[o]){case"textNode":I(i);break;case"cdata":D(i,"oncdata",i.cdata),i.cdata="";break;case"script":D(i,"onscript",i.script),i.script="";break;default:x(i,"Max buffer length exceeded: "+t[o])}l=Math.max(l,d)}var s=e.MAX_BUFFER_LENGTH-l;i.bufferCheckPosition=s+i.position}(a),a},resume:function(){return this.error=null,this},close:function(){return this.write(null)},flush:function(){var e;I(e=this),""!==e.cdata&&(D(e,"oncdata",e.cdata),e.cdata=""),""!==e.script&&(D(e,"onscript",e.script),e.script="")}};try{i=Object(function(){var e=new Error("Cannot find module 'stream'");throw e.code="MODULE_NOT_FOUND",e}())}catch(e){i=function(){}}var o=e.EVENTS.filter((function(e){return"error"!==e&&"end"!==e}));function r(e,a){if(!(this instanceof r))return new r(e,a);i.apply(this),this._parser=new l(e,a),this.writable=!0,this.readable=!0;var t=this;this._parser.onend=function(){t.emit("end")},this._parser.onerror=function(e){t.emit("error",e),t._parser.error=null},this._decoder=null,o.forEach((function(e){Object.defineProperty(t,"on"+e,{get:function(){return t._parser["on"+e]},set:function(i){if(!i)return t.removeAllListeners(e),t._parser["on"+e]=i,i;t.on(e,i)},enumerable:!0,configurable:!1})}))}r.prototype=Object.create(i.prototype,{constructor:{value:r}}),r.prototype.write=function(e){if("function"==typeof Buffer&&"function"==typeof Buffer.isBuffer&&Buffer.isBuffer(e)){if(!this._decoder){var i=a(111).StringDecoder;this._decoder=new i("utf8")}e=this._decoder.write(e)}return this._parser.write(e.toString()),this.emit("data",e),!0},r.prototype.end=function(e){return e&&e.length&&this.write(e),this._parser.end(),!0},r.prototype.on=function(e,a){var t=this;return t._parser["on"+e]||-1===o.indexOf(e)||(t._parser["on"+e]=function(){var i=1===arguments.length?[arguments[0]]:Array.apply(null,arguments);i.splice(0,0,e),t.emit.apply(t,i)}),i.prototype.on.call(t,e,a)};var d="[CDATA[",s="DOCTYPE",n="http://www.w3.org/XML/1998/namespace",p="http://www.w3.org/2000/xmlns/",c={xml:n,xmlns:p},y=/[:_A-Za-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD]/,u=/[:_A-Za-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD\u00B7\u0300-\u036F\u203F-\u2040.\d-]/,m=/[#:_A-Za-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD]/,_=/[#:_A-Za-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD\u00B7\u0300-\u036F\u203F-\u2040.\d-]/;function f(e){return" "===e||"\n"===e||"\r"===e||"\t"===e}function g(e){return'"'===e||"'"===e}function h(e){return">"===e||f(e)}function S(e,i){return e.test(i)}function b(e,i){return!S(e,i)}var v,C,P,q=0;for(var E in e.STATE={BEGIN:q++,BEGIN_WHITESPACE:q++,TEXT:q++,TEXT_ENTITY:q++,OPEN_WAKA:q++,SGML_DECL:q++,SGML_DECL_QUOTED:q++,DOCTYPE:q++,DOCTYPE_QUOTED:q++,DOCTYPE_DTD:q++,DOCTYPE_DTD_QUOTED:q++,COMMENT_STARTING:q++,COMMENT:q++,COMMENT_ENDING:q++,COMMENT_ENDED:q++,CDATA:q++,CDATA_ENDING:q++,CDATA_ENDING_2:q++,PROC_INST:q++,PROC_INST_BODY:q++,PROC_INST_ENDING:q++,OPEN_TAG:q++,OPEN_TAG_SLASH:q++,ATTRIB:q++,ATTRIB_NAME:q++,ATTRIB_NAME_SAW_WHITE:q++,ATTRIB_VALUE:q++,ATTRIB_VALUE_QUOTED:q++,ATTRIB_VALUE_CLOSED:q++,ATTRIB_VALUE_UNQUOTED:q++,ATTRIB_VALUE_ENTITY_Q:q++,ATTRIB_VALUE_ENTITY_U:q++,CLOSE_TAG:q++,CLOSE_TAG_SAW_WHITE:q++,SCRIPT:q++,SCRIPT_ENDING:q++},e.XML_ENTITIES={amp:"&",gt:">",lt:"<",quot:'"',apos:"'"},e.ENTITIES={amp:"&",gt:">",lt:"<",quot:'"',apos:"'",AElig:198,Aacute:193,Acirc:194,Agrave:192,Aring:197,Atilde:195,Auml:196,Ccedil:199,ETH:208,Eacute:201,Ecirc:202,Egrave:200,Euml:203,Iacute:205,Icirc:206,Igrave:204,Iuml:207,Ntilde:209,Oacute:211,Ocirc:212,Ograve:210,Oslash:216,Otilde:213,Ouml:214,THORN:222,Uacute:218,Ucirc:219,Ugrave:217,Uuml:220,Yacute:221,aacute:225,acirc:226,aelig:230,agrave:224,aring:229,atilde:227,auml:228,ccedil:231,eacute:233,ecirc:234,egrave:232,eth:240,euml:235,iacute:237,icirc:238,igrave:236,iuml:239,ntilde:241,oacute:243,ocirc:244,ograve:242,oslash:248,otilde:245,ouml:246,szlig:223,thorn:254,uacute:250,ucirc:251,ugrave:249,uuml:252,yacute:253,yuml:255,copy:169,reg:174,nbsp:160,iexcl:161,cent:162,pound:163,curren:164,yen:165,brvbar:166,sect:167,uml:168,ordf:170,laquo:171,not:172,shy:173,macr:175,deg:176,plusmn:177,sup1:185,sup2:178,sup3:179,acute:180,micro:181,para:182,middot:183,cedil:184,ordm:186,raquo:187,frac14:188,frac12:189,frac34:190,iquest:191,times:215,divide:247,OElig:338,oelig:339,Scaron:352,scaron:353,Yuml:376,fnof:402,circ:710,tilde:732,Alpha:913,Beta:914,Gamma:915,Delta:916,Epsilon:917,Zeta:918,Eta:919,Theta:920,Iota:921,Kappa:922,Lambda:923,Mu:924,Nu:925,Xi:926,Omicron:927,Pi:928,Rho:929,Sigma:931,Tau:932,Upsilon:933,Phi:934,Chi:935,Psi:936,Omega:937,alpha:945,beta:946,gamma:947,delta:948,epsilon:949,zeta:950,eta:951,theta:952,iota:953,kappa:954,lambda:955,mu:956,nu:957,xi:958,omicron:959,pi:960,rho:961,sigmaf:962,sigma:963,tau:964,upsilon:965,phi:966,chi:967,psi:968,omega:969,thetasym:977,upsih:978,piv:982,ensp:8194,emsp:8195,thinsp:8201,zwnj:8204,zwj:8205,lrm:8206,rlm:8207,ndash:8211,mdash:8212,lsquo:8216,rsquo:8217,sbquo:8218,ldquo:8220,rdquo:8221,bdquo:8222,dagger:8224,Dagger:8225,bull:8226,hellip:8230,permil:8240,prime:8242,Prime:8243,lsaquo:8249,rsaquo:8250,oline:8254,frasl:8260,euro:8364,image:8465,weierp:8472,real:8476,trade:8482,alefsym:8501,larr:8592,uarr:8593,rarr:8594,darr:8595,harr:8596,crarr:8629,lArr:8656,uArr:8657,rArr:8658,dArr:8659,hArr:8660,forall:8704,part:8706,exist:8707,empty:8709,nabla:8711,isin:8712,notin:8713,ni:8715,prod:8719,sum:8721,minus:8722,lowast:8727,radic:8730,prop:8733,infin:8734,ang:8736,and:8743,or:8744,cap:8745,cup:8746,int:8747,there4:8756,sim:8764,cong:8773,asymp:8776,ne:8800,equiv:8801,le:8804,ge:8805,sub:8834,sup:8835,nsub:8836,sube:8838,supe:8839,oplus:8853,otimes:8855,perp:8869,sdot:8901,lceil:8968,rceil:8969,lfloor:8970,rfloor:8971,lang:9001,rang:9002,loz:9674,spades:9824,clubs:9827,hearts:9829,diams:9830},Object.keys(e.ENTITIES).forEach((function(i){var a=e.ENTITIES[i],t="number"==typeof a?String.fromCharCode(a):a;e.ENTITIES[i]=t})),e.STATE)e.STATE[e.STATE[E]]=E;function R(e,i,a){e[i]&&e[i](a)}function D(e,i,a){e.textNode&&I(e),R(e,i,a)}function I(e){e.textNode=A(e.opt,e.textNode),e.textNode&&R(e,"ontext",e.textNode),e.textNode=""}function A(e,i){return e.trim&&(i=i.trim()),e.normalize&&(i=i.replace(/\s+/g," ")),i}function x(e,i){return I(e),e.trackPosition&&(i+="\nLine: "+e.line+"\nColumn: "+e.column+"\nChar: "+e.c),i=new Error(i),e.error=i,R(e,"onerror",i),e}function T(e){return e.sawRoot&&!e.closedRoot&&M(e,"Unclosed root tag"),e.state!==q.BEGIN&&e.state!==q.BEGIN_WHITESPACE&&e.state!==q.TEXT&&x(e,"Unexpected end"),I(e),e.c="",e.closed=!0,R(e,"onend"),l.call(e,e.strict,e.opt),e}function M(e,i){if("object"!=typeof e||!(e instanceof l))throw new Error("bad call to strictFail");e.strict&&x(e,i)}function V(e){e.strict||(e.tagName=e.tagName[e.looseCase]());var i=e.tags[e.tags.length-1]||e,a=e.tag={name:e.tagName,attributes:{}};e.opt.xmlns&&(a.ns=i.ns),e.attribList.length=0,D(e,"onopentagstart",a)}function F(e,i){var a=e.indexOf(":")<0?["",e]:e.split(":"),t=a[0],l=a[1];return i&&"xmlns"===e&&(t="xmlns",l=""),{prefix:t,local:l}}function L(e){if(e.strict||(e.attribName=e.attribName[e.looseCase]()),-1!==e.attribList.indexOf(e.attribName)||e.tag.attributes.hasOwnProperty(e.attribName))e.attribName=e.attribValue="";else{if(e.opt.xmlns){var i=F(e.attribName,!0),a=i.prefix,t=i.local;if("xmlns"===a)if("xml"===t&&e.attribValue!==n)M(e,"xml: prefix must be bound to "+n+"\nActual: "+e.attribValue);else if("xmlns"===t&&e.attribValue!==p)M(e,"xmlns: prefix must be bound to "+p+"\nActual: "+e.attribValue);else{var l=e.tag,o=e.tags[e.tags.length-1]||e;l.ns===o.ns&&(l.ns=Object.create(o.ns)),l.ns[t]=e.attribValue}e.attribList.push([e.attribName,e.attribValue])}else e.tag.attributes[e.attribName]=e.attribValue,D(e,"onattribute",{name:e.attribName,value:e.attribValue});e.attribName=e.attribValue=""}}function k(e,i){if(e.opt.xmlns){var a=e.tag,t=F(e.tagName);a.prefix=t.prefix,a.local=t.local,a.uri=a.ns[t.prefix]||"",a.prefix&&!a.uri&&(M(e,"Unbound namespace prefix: "+JSON.stringify(e.tagName)),a.uri=t.prefix);var l=e.tags[e.tags.length-1]||e;a.ns&&l.ns!==a.ns&&Object.keys(a.ns).forEach((function(i){D(e,"onopennamespace",{prefix:i,uri:a.ns[i]})}));for(var o=0,r=e.attribList.length;o<r;o++){var d=e.attribList[o],s=d[0],n=d[1],p=F(s,!0),c=p.prefix,y=p.local,u=""===c?"":a.ns[c]||"",m={name:s,value:n,prefix:c,local:y,uri:u};c&&"xmlns"!==c&&!u&&(M(e,"Unbound namespace prefix: "+JSON.stringify(c)),m.uri=c),e.tag.attributes[s]=m,D(e,"onattribute",m)}e.attribList.length=0}e.tag.isSelfClosing=!!i,e.sawRoot=!0,e.tags.push(e.tag),D(e,"onopentag",e.tag),i||(e.noscript||"script"!==e.tagName.toLowerCase()?e.state=q.TEXT:e.state=q.SCRIPT,e.tag=null,e.tagName=""),e.attribName=e.attribValue="",e.attribList.length=0}function O(e){if(!e.tagName)return M(e,"Weird empty close tag."),e.textNode+="</>",void(e.state=q.TEXT);if(e.script){if("script"!==e.tagName)return e.script+="</"+e.tagName+">",e.tagName="",void(e.state=q.SCRIPT);D(e,"onscript",e.script),e.script=""}var i=e.tags.length,a=e.tagName;e.strict||(a=a[e.looseCase]());for(var t=a;i--&&e.tags[i].name!==t;)M(e,"Unexpected close tag");if(i<0)return M(e,"Unmatched closing tag: "+e.tagName),e.textNode+="</"+e.tagName+">",void(e.state=q.TEXT);e.tagName=a;for(var l=e.tags.length;l-- >i;){var o=e.tag=e.tags.pop();e.tagName=e.tag.name,D(e,"onclosetag",e.tagName);var r={};for(var d in o.ns)r[d]=o.ns[d];var s=e.tags[e.tags.length-1]||e;e.opt.xmlns&&o.ns!==s.ns&&Object.keys(o.ns).forEach((function(i){var a=o.ns[i];D(e,"onclosenamespace",{prefix:i,uri:a})}))}0===i&&(e.closedRoot=!0),e.tagName=e.attribValue=e.attribName="",e.attribList.length=0,e.state=q.TEXT}function w(e){var i,a=e.entity,t=a.toLowerCase(),l="";return e.ENTITIES[a]?e.ENTITIES[a]:e.ENTITIES[t]?e.ENTITIES[t]:("#"===(a=t).charAt(0)&&("x"===a.charAt(1)?(a=a.slice(2),l=(i=parseInt(a,16)).toString(16)):(a=a.slice(1),l=(i=parseInt(a,10)).toString(10))),a=a.replace(/^0+/,""),isNaN(i)||l.toLowerCase()!==a?(M(e,"Invalid character entity"),"&"+e.entity+";"):String.fromCodePoint(i))}function B(e,i){"<"===i?(e.state=q.OPEN_WAKA,e.startTagPosition=e.position):f(i)||(M(e,"Non-whitespace before first tag."),e.textNode=i,e.state=q.TEXT)}function W(e,i){var a="";return i<e.length&&(a=e.charAt(i)),a}q=e.STATE,String.fromCodePoint||(v=String.fromCharCode,C=Math.floor,P=function(){var e,i,a=[],t=-1,l=arguments.length;if(!l)return"";for(var o="";++t<l;){var r=Number(arguments[t]);if(!isFinite(r)||r<0||r>1114111||C(r)!==r)throw RangeError("Invalid code point: "+r);r<=65535?a.push(r):(e=55296+((r-=65536)>>10),i=r%1024+56320,a.push(e,i)),(t+1===l||a.length>16384)&&(o+=v.apply(null,a),a.length=0)}return o},Object.defineProperty?Object.defineProperty(String,"fromCodePoint",{value:P,configurable:!0,writable:!0}):String.fromCodePoint=P)}(i)},881:e=>{e.exports={isArray:function(e){return Array.isArray?Array.isArray(e):"[object Array]"===Object.prototype.toString.call(e)}}},888:(e,i,a)=>{var t=a(229),l=a(388),o=a(501),r=a(673);e.exports={xml2js:t,xml2json:l,js2xml:o,json2xml:r}},501:(e,i,a)=>{var t,l,o=a(740),r=a(881).isArray;function d(e,i,a){return(!a&&e.spaces?"\n":"")+Array(i+1).join(e.spaces)}function s(e,i,a){if(i.ignoreAttributes)return"";"attributesFn"in i&&(e=i.attributesFn(e,l,t));var o,r,s,n,p=[];for(o in e)e.hasOwnProperty(o)&&null!==e[o]&&void 0!==e[o]&&(n=i.noQuotesForNativeAttributes&&"string"!=typeof e[o]?"":'"',r=(r=""+e[o]).replace(/"/g,"&quot;"),s="attributeNameFn"in i?i.attributeNameFn(o,r,l,t):o,p.push(i.spaces&&i.indentAttributes?d(i,a+1,!1):" "),p.push(s+"="+n+("attributeValueFn"in i?i.attributeValueFn(r,o,l,t):r)+n));return e&&Object.keys(e).length&&i.spaces&&i.indentAttributes&&p.push(d(i,a,!1)),p.join("")}function n(e,i,a){return t=e,l="xml",i.ignoreDeclaration?"":"<?xml"+s(e[i.attributesKey],i,a)+"?>"}function p(e,i,a){if(i.ignoreInstruction)return"";var o;for(o in e)if(e.hasOwnProperty(o))break;var r="instructionNameFn"in i?i.instructionNameFn(o,e[o],l,t):o;if("object"==typeof e[o])return t=e,l=r,"<?"+r+s(e[o][i.attributesKey],i,a)+"?>";var d=e[o]?e[o]:"";return"instructionFn"in i&&(d=i.instructionFn(d,o,l,t)),"<?"+r+(d?" "+d:"")+"?>"}function c(e,i){return i.ignoreComment?"":"\x3c!--"+("commentFn"in i?i.commentFn(e,l,t):e)+"--\x3e"}function y(e,i){return i.ignoreCdata?"":"<![CDATA["+("cdataFn"in i?i.cdataFn(e,l,t):e)+"]]>"}function u(e,i){return i.ignoreDoctype?"":"<!DOCTYPE "+("doctypeFn"in i?i.doctypeFn(e,l,t):e)+">"}function m(e,i){return i.ignoreText?"":(e=(e=(e=""+e).replace(/&amp;/g,"&")).replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;"),"textFn"in i?i.textFn(e,l,t):e)}function _(e,i,a,o){return e.reduce((function(e,r){var n=d(i,a,o&&!e);switch(r.type){case"element":return e+n+function(e,i,a){t=e,l=e.name;var o=[],r="elementNameFn"in i?i.elementNameFn(e.name,e):e.name;o.push("<"+r),e[i.attributesKey]&&o.push(s(e[i.attributesKey],i,a));var d=e[i.elementsKey]&&e[i.elementsKey].length||e[i.attributesKey]&&"preserve"===e[i.attributesKey]["xml:space"];return d||(d="fullTagEmptyElementFn"in i?i.fullTagEmptyElementFn(e.name,e):i.fullTagEmptyElement),d?(o.push(">"),e[i.elementsKey]&&e[i.elementsKey].length&&(o.push(_(e[i.elementsKey],i,a+1)),t=e,l=e.name),o.push(i.spaces&&function(e,i){var a;if(e.elements&&e.elements.length)for(a=0;a<e.elements.length;++a)switch(e.elements[a][i.typeKey]){case"text":if(i.indentText)return!0;break;case"cdata":if(i.indentCdata)return!0;break;case"instruction":if(i.indentInstruction)return!0;break;default:return!0}return!1}(e,i)?"\n"+Array(a+1).join(i.spaces):""),o.push("</"+r+">")):o.push("/>"),o.join("")}(r,i,a);case"comment":return e+n+c(r[i.commentKey],i);case"doctype":return e+n+u(r[i.doctypeKey],i);case"cdata":return e+(i.indentCdata?n:"")+y(r[i.cdataKey],i);case"text":return e+(i.indentText?n:"")+m(r[i.textKey],i);case"instruction":var f={};return f[r[i.nameKey]]=r[i.attributesKey]?r:r[i.instructionKey],e+(i.indentInstruction?n:"")+p(f,i,a)}}),"")}function f(e,i,a){var t;for(t in e)if(e.hasOwnProperty(t))switch(t){case i.parentKey:case i.attributesKey:break;case i.textKey:if(i.indentText||a)return!0;break;case i.cdataKey:if(i.indentCdata||a)return!0;break;case i.instructionKey:if(i.indentInstruction||a)return!0;break;case i.doctypeKey:case i.commentKey:default:return!0}return!1}function g(e,i,a,o,r){t=e,l=i;var n="elementNameFn"in a?a.elementNameFn(i,e):i;if(null==e)return"fullTagEmptyElementFn"in a&&a.fullTagEmptyElementFn(i,e)||a.fullTagEmptyElement?"<"+n+"></"+n+">":"<"+n+"/>";var p=[];if(i){if(p.push("<"+n),"object"!=typeof e)return p.push(">"+m(e,a)+"</"+n+">"),p.join("");e[a.attributesKey]&&p.push(s(e[a.attributesKey],a,o));var c=f(e,a,!0)||e[a.attributesKey]&&"preserve"===e[a.attributesKey]["xml:space"];if(c||(c="fullTagEmptyElementFn"in a?a.fullTagEmptyElementFn(i,e):a.fullTagEmptyElement),!c)return p.push("/>"),p.join("");p.push(">")}return p.push(h(e,a,o+1,!1)),t=e,l=i,i&&p.push((r?d(a,o,!1):"")+"</"+n+">"),p.join("")}function h(e,i,a,t){var l,o,s,_=[];for(o in e)if(e.hasOwnProperty(o))for(s=r(e[o])?e[o]:[e[o]],l=0;l<s.length;++l){switch(o){case i.declarationKey:_.push(n(s[l],i,a));break;case i.instructionKey:_.push((i.indentInstruction?d(i,a,t):"")+p(s[l],i,a));break;case i.attributesKey:case i.parentKey:break;case i.textKey:_.push((i.indentText?d(i,a,t):"")+m(s[l],i));break;case i.cdataKey:_.push((i.indentCdata?d(i,a,t):"")+y(s[l],i));break;case i.doctypeKey:_.push(d(i,a,t)+u(s[l],i));break;case i.commentKey:_.push(d(i,a,t)+c(s[l],i));break;default:_.push(d(i,a,t)+g(s[l],o,i,a,f(s[l],i)))}t=t&&!_.length}return _.join("")}e.exports=function(e,i){i=function(e){var i=o.copyOptions(e);return o.ensureFlagExists("ignoreDeclaration",i),o.ensureFlagExists("ignoreInstruction",i),o.ensureFlagExists("ignoreAttributes",i),o.ensureFlagExists("ignoreText",i),o.ensureFlagExists("ignoreComment",i),o.ensureFlagExists("ignoreCdata",i),o.ensureFlagExists("ignoreDoctype",i),o.ensureFlagExists("compact",i),o.ensureFlagExists("indentText",i),o.ensureFlagExists("indentCdata",i),o.ensureFlagExists("indentAttributes",i),o.ensureFlagExists("indentInstruction",i),o.ensureFlagExists("fullTagEmptyElement",i),o.ensureFlagExists("noQuotesForNativeAttributes",i),o.ensureSpacesExists(i),"number"==typeof i.spaces&&(i.spaces=Array(i.spaces+1).join(" ")),o.ensureKeyExists("declaration",i),o.ensureKeyExists("instruction",i),o.ensureKeyExists("attributes",i),o.ensureKeyExists("text",i),o.ensureKeyExists("comment",i),o.ensureKeyExists("cdata",i),o.ensureKeyExists("doctype",i),o.ensureKeyExists("type",i),o.ensureKeyExists("name",i),o.ensureKeyExists("elements",i),o.checkFnExists("doctype",i),o.checkFnExists("instruction",i),o.checkFnExists("cdata",i),o.checkFnExists("comment",i),o.checkFnExists("text",i),o.checkFnExists("instructionName",i),o.checkFnExists("elementName",i),o.checkFnExists("attributeName",i),o.checkFnExists("attributeValue",i),o.checkFnExists("attributes",i),o.checkFnExists("fullTagEmptyElement",i),i}(i);var a=[];return t=e,l="_root_",i.compact?a.push(h(e,i,0,!0)):(e[i.declarationKey]&&a.push(n(e[i.declarationKey],i,0)),e[i.elementsKey]&&e[i.elementsKey].length&&a.push(_(e[i.elementsKey],i,0,!a.length))),a.join("")}},673:(e,i,a)=>{var t=a(501);e.exports=function(e,i){e instanceof Buffer&&(e=e.toString());var a=null;if("string"==typeof e)try{a=JSON.parse(e)}catch(e){throw new Error("The JSON structure is invalid")}else a=e;return t(a,i)}},740:(e,i,a)=>{var t=a(881).isArray;e.exports={copyOptions:function(e){var i,a={};for(i in e)e.hasOwnProperty(i)&&(a[i]=e[i]);return a},ensureFlagExists:function(e,i){e in i&&"boolean"==typeof i[e]||(i[e]=!1)},ensureSpacesExists:function(e){(!("spaces"in e)||"number"!=typeof e.spaces&&"string"!=typeof e.spaces)&&(e.spaces=0)},ensureAlwaysArrayExists:function(e){"alwaysArray"in e&&("boolean"==typeof e.alwaysArray||t(e.alwaysArray))||(e.alwaysArray=!1)},ensureKeyExists:function(e,i){e+"Key"in i&&"string"==typeof i[e+"Key"]||(i[e+"Key"]=i.compact?"_"+e:e)},checkFnExists:function(e,i){return e+"Fn"in i}}},229:(e,i,a)=>{var t,l,o=a(99),r=a(740),d=a(881).isArray;function s(e){var i=Number(e);if(!isNaN(i))return i;var a=e.toLowerCase();return"true"===a||"false"!==a&&e}function n(e,i){var a;if(t.compact){if(!l[t[e+"Key"]]&&(d(t.alwaysArray)?-1!==t.alwaysArray.indexOf(t[e+"Key"]):t.alwaysArray)&&(l[t[e+"Key"]]=[]),l[t[e+"Key"]]&&!d(l[t[e+"Key"]])&&(l[t[e+"Key"]]=[l[t[e+"Key"]]]),e+"Fn"in t&&"string"==typeof i&&(i=t[e+"Fn"](i,l)),"instruction"===e&&("instructionFn"in t||"instructionNameFn"in t))for(a in i)if(i.hasOwnProperty(a))if("instructionFn"in t)i[a]=t.instructionFn(i[a],a,l);else{var o=i[a];delete i[a],i[t.instructionNameFn(a,o,l)]=o}d(l[t[e+"Key"]])?l[t[e+"Key"]].push(i):l[t[e+"Key"]]=i}else{l[t.elementsKey]||(l[t.elementsKey]=[]);var r={};if(r[t.typeKey]=e,"instruction"===e){for(a in i)if(i.hasOwnProperty(a))break;r[t.nameKey]="instructionNameFn"in t?t.instructionNameFn(a,i,l):a,t.instructionHasAttributes?(r[t.attributesKey]=i[a][t.attributesKey],"instructionFn"in t&&(r[t.attributesKey]=t.instructionFn(r[t.attributesKey],a,l))):("instructionFn"in t&&(i[a]=t.instructionFn(i[a],a,l)),r[t.instructionKey]=i[a])}else e+"Fn"in t&&(i=t[e+"Fn"](i,l)),r[t[e+"Key"]]=i;t.addParent&&(r[t.parentKey]=l),l[t.elementsKey].push(r)}}function p(e){var i;if("attributesFn"in t&&e&&(e=t.attributesFn(e,l)),(t.trim||"attributeValueFn"in t||"attributeNameFn"in t||t.nativeTypeAttributes)&&e)for(i in e)if(e.hasOwnProperty(i)&&(t.trim&&(e[i]=e[i].trim()),t.nativeTypeAttributes&&(e[i]=s(e[i])),"attributeValueFn"in t&&(e[i]=t.attributeValueFn(e[i],i,l)),"attributeNameFn"in t)){var a=e[i];delete e[i],e[t.attributeNameFn(i,e[i],l)]=a}return e}function c(e){var i={};if(e.body&&("xml"===e.name.toLowerCase()||t.instructionHasAttributes)){for(var a,o=/([\w:-]+)\s*=\s*(?:"([^"]*)"|'([^']*)'|(\w+))\s*/g;null!==(a=o.exec(e.body));)i[a[1]]=a[2]||a[3]||a[4];i=p(i)}if("xml"===e.name.toLowerCase()){if(t.ignoreDeclaration)return;l[t.declarationKey]={},Object.keys(i).length&&(l[t.declarationKey][t.attributesKey]=i),t.addParent&&(l[t.declarationKey][t.parentKey]=l)}else{if(t.ignoreInstruction)return;t.trim&&(e.body=e.body.trim());var r={};t.instructionHasAttributes&&Object.keys(i).length?(r[e.name]={},r[e.name][t.attributesKey]=i):r[e.name]=e.body,n("instruction",r)}}function y(e,i){var a;if("object"==typeof e&&(i=e.attributes,e=e.name),i=p(i),"elementNameFn"in t&&(e=t.elementNameFn(e,l)),t.compact){var o;if(a={},!t.ignoreAttributes&&i&&Object.keys(i).length)for(o in a[t.attributesKey]={},i)i.hasOwnProperty(o)&&(a[t.attributesKey][o]=i[o]);!(e in l)&&(d(t.alwaysArray)?-1!==t.alwaysArray.indexOf(e):t.alwaysArray)&&(l[e]=[]),l[e]&&!d(l[e])&&(l[e]=[l[e]]),d(l[e])?l[e].push(a):l[e]=a}else l[t.elementsKey]||(l[t.elementsKey]=[]),(a={})[t.typeKey]="element",a[t.nameKey]=e,!t.ignoreAttributes&&i&&Object.keys(i).length&&(a[t.attributesKey]=i),t.alwaysChildren&&(a[t.elementsKey]=[]),l[t.elementsKey].push(a);a[t.parentKey]=l,l=a}function u(e){t.ignoreText||(e.trim()||t.captureSpacesBetweenElements)&&(t.trim&&(e=e.trim()),t.nativeType&&(e=s(e)),t.sanitize&&(e=e.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;")),n("text",e))}function m(e){t.ignoreComment||(t.trim&&(e=e.trim()),n("comment",e))}function _(e){var i=l[t.parentKey];t.addParent||delete l[t.parentKey],l=i}function f(e){t.ignoreCdata||(t.trim&&(e=e.trim()),n("cdata",e))}function g(e){t.ignoreDoctype||(e=e.replace(/^ /,""),t.trim&&(e=e.trim()),n("doctype",e))}function h(e){e.note=e}e.exports=function(e,i){var a=o.parser(!0,{}),d={};if(l=d,t=function(e){return t=r.copyOptions(e),r.ensureFlagExists("ignoreDeclaration",t),r.ensureFlagExists("ignoreInstruction",t),r.ensureFlagExists("ignoreAttributes",t),r.ensureFlagExists("ignoreText",t),r.ensureFlagExists("ignoreComment",t),r.ensureFlagExists("ignoreCdata",t),r.ensureFlagExists("ignoreDoctype",t),r.ensureFlagExists("compact",t),r.ensureFlagExists("alwaysChildren",t),r.ensureFlagExists("addParent",t),r.ensureFlagExists("trim",t),r.ensureFlagExists("nativeType",t),r.ensureFlagExists("nativeTypeAttributes",t),r.ensureFlagExists("sanitize",t),r.ensureFlagExists("instructionHasAttributes",t),r.ensureFlagExists("captureSpacesBetweenElements",t),r.ensureAlwaysArrayExists(t),r.ensureKeyExists("declaration",t),r.ensureKeyExists("instruction",t),r.ensureKeyExists("attributes",t),r.ensureKeyExists("text",t),r.ensureKeyExists("comment",t),r.ensureKeyExists("cdata",t),r.ensureKeyExists("doctype",t),r.ensureKeyExists("type",t),r.ensureKeyExists("name",t),r.ensureKeyExists("elements",t),r.ensureKeyExists("parent",t),r.checkFnExists("doctype",t),r.checkFnExists("instruction",t),r.checkFnExists("cdata",t),r.checkFnExists("comment",t),r.checkFnExists("text",t),r.checkFnExists("instructionName",t),r.checkFnExists("elementName",t),r.checkFnExists("attributeName",t),r.checkFnExists("attributeValue",t),r.checkFnExists("attributes",t),t}(i),a.opt={strictEntities:!0},a.onopentag=y,a.ontext=u,a.oncomment=m,a.onclosetag=_,a.onerror=h,a.oncdata=f,a.ondoctype=g,a.onprocessinginstruction=c,a.write(e).close(),d[t.elementsKey]){var s=d[t.elementsKey];delete d[t.elementsKey],d[t.elementsKey]=s,delete d.text}return d}},388:(e,i,a)=>{var t=a(740),l=a(229);e.exports=function(e,i){var a,o,r;return a=function(e){var i=t.copyOptions(e);return t.ensureSpacesExists(i),i}(i),o=l(e,a),r="compact"in a&&a.compact?"_parent":"parent",("addParent"in a&&a.addParent?JSON.stringify(o,(function(e,i){return e===r?"_":i}),a.spaces):JSON.stringify(o,null,a.spaces)).replace(/\u2028/g,"\\u2028").replace(/\u2029/g,"\\u2029")}},136:(e,i,a)=>{"use strict";Object.defineProperty(i,"__esModule",{value:!0}),i.ParseConformance=void 0;const t=a(899),l=a(381);class o{constructor(e,i){this.structureDefinitions=[],this.parsedStructureDefinitions=e?a(471):{},this.parsedValueSets=e?a(771):{},this.version=i||t.Versions.R4,this.codeSystems=[],this.ensurePropertyMetaData()}isBaseProfile(e){let i;switch(this.version){case t.Versions.STU3:i=["http://hl7.org/fhir/StructureDefinition/Account","http://hl7.org/fhir/StructureDefinition/ActivityDefinition","http://hl7.org/fhir/StructureDefinition/AllergyIntolerance","http://hl7.org/fhir/StructureDefinition/AdverseEvent","http://hl7.org/fhir/StructureDefinition/Appointment","http://hl7.org/fhir/StructureDefinition/AppointmentResponse","http://hl7.org/fhir/StructureDefinition/AuditEvent","http://hl7.org/fhir/StructureDefinition/Basic","http://hl7.org/fhir/StructureDefinition/Binary","http://hl7.org/fhir/StructureDefinition/BodySite","http://hl7.org/fhir/StructureDefinition/Bundle","http://hl7.org/fhir/StructureDefinition/CapabilityStatement","http://hl7.org/fhir/StructureDefinition/CarePlan","http://hl7.org/fhir/StructureDefinition/CareTeam","http://hl7.org/fhir/StructureDefinition/ChargeItem","http://hl7.org/fhir/StructureDefinition/Claim","http://hl7.org/fhir/StructureDefinition/ClaimResponse","http://hl7.org/fhir/StructureDefinition/ClinicalImpression","http://hl7.org/fhir/StructureDefinition/CodeSystem","http://hl7.org/fhir/StructureDefinition/Communication","http://hl7.org/fhir/StructureDefinition/CommunicationRequest","http://hl7.org/fhir/StructureDefinition/CompartmentDefinition","http://hl7.org/fhir/StructureDefinition/Composition","http://hl7.org/fhir/StructureDefinition/ConceptMap","http://hl7.org/fhir/StructureDefinition/Condition (aka Problem)","http://hl7.org/fhir/StructureDefinition/Consent","http://hl7.org/fhir/StructureDefinition/Contract","http://hl7.org/fhir/StructureDefinition/Coverage","http://hl7.org/fhir/StructureDefinition/DataElement","http://hl7.org/fhir/StructureDefinition/DetectedIssue","http://hl7.org/fhir/StructureDefinition/Device","http://hl7.org/fhir/StructureDefinition/DeviceComponent","http://hl7.org/fhir/StructureDefinition/DeviceMetric","http://hl7.org/fhir/StructureDefinition/DeviceRequest","http://hl7.org/fhir/StructureDefinition/DeviceUseStatement","http://hl7.org/fhir/StructureDefinition/DiagnosticReport","http://hl7.org/fhir/StructureDefinition/DocumentManifest","http://hl7.org/fhir/StructureDefinition/DocumentReference","http://hl7.org/fhir/StructureDefinition/EligibilityRequest","http://hl7.or