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GAChC,MAAM,EAAW,EAAI,EACjB,IAAU,EAAM,EAAS,EAAgB,EAAK,IAClD,QAAI,IAAuB,EAAK,OAGhC,IAAK,EAEH,YADA,EAAI,GAAK,IAAM,GAQjB,GAHA,EAAI,GAAK,IAAM,EAGH,OAAR,EAAc,OAElB,EAAI,GAAK,MAWc,EAXS,EAYzB,EAAQ,KAAK,EAAK,UAAW,GAZG,KAWzC,IAAyB,CAVzB,CAtBI,CAAe,EAAK,EAAK,GAJzB,OAAO,KAAK,GAAK,SAAQ,SAAS,GAChC,EAAgB,EAAK,EAAM,EAAI,GACjC,GAIJ,CAsBA,SAAS,EAAY,GACnB,OAAO,GAAQ,EAAK,KAAO,CAC7B,CAUA,SAAS,EAAU,GACjB,OAAO,EAAO,IAAQ,CACxB,CAEA,SAAS,EAAS,GAChB,OAAO,aAAiB,KAC1B,CAED,CAxOW,CAwOU,iBAAZ,SAAwB,SAAW,CAAC","file":"/npm/to-xml@0.1.11/to-xml.js","sourceRoot":"","sourcesContent":["/**\n * Minified by jsDelivr using Terser v5.37.0.\n * Original file: /npm/to-xml@0.1.11/to-xml.js\n *\n * Do NOT use SRI with dynamically generated files! More information: https://www.jsdelivr.com/using-sri-with-dynamic-files\n */\n","/**\n * The toXML() method converts a JavaScript value to an XML string.\n *\n * @function toXML\n * @param value {Object} The value to convert to an XML string.\n * @param [replacer] {Function} A function that alters the behavior\n * of the stringification process.\n * @param [space] {Number|String} A String or Number object that's\n * used to insert white space into the output XML string for\n * readability purposes. If this is a Number, it indicates the number\n * of space characters to use as white space.\n * If this is a String, the string is used as white space.\n * @returns {String}\n */\n\n/* exported toXML */\nvar toXML = (function(exports) {\n\n  const TYPES = {\n    \"boolean\": fromString,\n    \"number\": fromString,\n    \"object\": fromObject,\n    \"string\": fromString\n  };\n\n  const ESCAPE = {\n    \"\\t\": \"&#x09;\",\n    \"\\n\": \"&#x0a;\",\n    \"\\r\": \"&#x0d;\",\n    \" \": \"&#x20;\",\n    \"&\": \"&amp;\",\n    \"<\": \"&lt;\",\n    \">\": \"&gt;\",\n    '\"': \"&quot;\"\n  };\n\n  const ATTRIBUTE_KEY = \"@\";\n  const CHILD_NODE_KEY = \"#\";\n  const LF = \"\\n\";\n\n  const isArray = Array.isArray || _isArray;\n\n  const REPLACE = String.prototype.replace;\n\n  return (exports.toXML = _toXML);\n\n  function _toXML(value, replacer, space) {\n    const job = createJob(replacer, space);\n    fromAny(job, \"\", value);\n    return job.r;\n  }\n\n  function createJob(replacer, space) {\n    const job = {\n      f: replacer, // replacer function\n      // s: \"\", // indent string\n      // i: 0, // indent string length\n      l: \"\", // current indent string\n      r: \"\" // result string\n    };\n\n    if (space) {\n      let str = \"\";\n\n      if (space > 0) {\n        for (let i = space; i; i--) {\n          str += \" \";\n        }\n      } else {\n        str += space; // stringify\n      }\n      job.s = str;\n\n      // indent string length\n      job.i = str.length;\n    }\n\n    return job;\n  }\n\n  function fromAny(job, key, value) {\n    // child node synonym\n    if (key === CHILD_NODE_KEY) key = \"\";\n\n    if (_isArray(value)) return fromArray(job, key, value);\n\n    const replacer = job.f;\n    if (replacer) value = replacer(key, value);\n\n    const f = TYPES[typeof value];\n    if (f) f(job, key, value);\n  }\n\n  function fromString(job, key, value) {\n    if (key === \"?\") {\n      // XML declaration\n      value = \"<?\" + value + \"?>\";\n    } else if (key === \"!\") {\n      // comment, CDATA section\n      value = \"<!\" + value + \">\";\n    } else {\n      value = escapeTextNode(value);\n      if (key) {\n        // text element without attributes\n        value = \"<\" + key + \">\" + value + \"</\" + key + \">\";\n      }\n    }\n\n    if (key && job.i && job.r) {\n      job.r += LF + job.l; // indent\n    }\n\n    job.r += value;\n  }\n\n  function fromArray(job, key, value) {\n    Array.prototype.forEach.call(value, function(value) {\n      fromAny(job, key, value);\n    });\n  }\n\n  function fromObject(job, key, value) {\n    // empty tag\n    const hasTag = !!key;\n    const closeTag = (value === null);\n    if (closeTag) {\n      if (!hasTag) return;\n      value = {};\n    }\n\n    const keys = Object.keys(value);\n    const keyLength = keys.length;\n    const attrs = keys.filter(isAttribute);\n    const attrLength = attrs.length;\n    const hasIndent = job.i;\n    const curIndent = job.l;\n    let willIndent = hasTag && hasIndent;\n    let didIndent;\n\n    // open tag\n    if (hasTag) {\n      if (hasIndent && job.r) {\n        job.r += LF + curIndent;\n      }\n\n      job.r += '<' + key;\n\n      // attributes\n      attrs.forEach(function(name) {\n        writeAttributes(job, name.substr(1), value[name]);\n      });\n\n      // empty element\n      const isEmpty = closeTag || (attrLength && keyLength === attrLength);\n      if (isEmpty) {\n        const firstChar = key[0];\n        if (firstChar !== \"!\" && firstChar !== \"?\") {\n          job.r += \"/\";\n        }\n      }\n\n      job.r += '>';\n\n      if (isEmpty) return;\n    }\n\n    keys.forEach(function(name) {\n      // skip attribute\n      if (isAttribute(name)) return;\n\n      // indent when it has child node but not fragment\n      if (willIndent && ((name && name !== CHILD_NODE_KEY) || isArray(value[name]))) {\n        job.l += job.s; // increase indent level\n        willIndent = 0;\n        didIndent = 1;\n      }\n\n      // child node or text node\n      fromAny(job, name, value[name]);\n    });\n\n    if (didIndent) {\n      // decrease indent level\n      job.l = job.l.substr(job.i);\n\n      job.r += LF + job.l;\n    }\n\n    // close tag\n    if (hasTag) {\n      job.r += '</' + key + '>';\n    }\n  }\n\n  function writeAttributes(job, key, val) {\n    if (isArray(val)) {\n      val.forEach(function(child) {\n        writeAttributes(job, key, child);\n      });\n    } else if (!key && \"object\" === typeof val) {\n      Object.keys(val).forEach(function(name) {\n        writeAttributes(job, name, val[name]);\n      });\n    } else {\n      writeAttribute(job, key, val);\n    }\n  }\n\n  function writeAttribute(job, key, val) {\n    const replacer = job.f;\n    if (replacer) val = replacer(ATTRIBUTE_KEY + key, val);\n    if (\"undefined\" === typeof val) return;\n\n    // empty attribute name\n    if (!key) {\n      job.r += ' ' + val;\n      return;\n    }\n\n    // attribute name\n    job.r += ' ' + key;\n\n    // property attribute\n    if (val === null) return;\n\n    job.r += '=\"' + escapeAttribute(val) + '\"';\n  }\n\n  function isAttribute(name) {\n    return name && name[0] === ATTRIBUTE_KEY;\n  }\n\n  function escapeTextNode(str) {\n    return REPLACE.call(str, /(^\\s|[&<>]|\\s$)/g, escapeRef);\n  }\n\n  function escapeAttribute(str) {\n    return REPLACE.call(str, /([&\"])/g, escapeRef);\n  }\n\n  function escapeRef(str) {\n    return ESCAPE[str] || str;\n  }\n\n  function _isArray(array) {\n    return array instanceof Array;\n  }\n\n})(typeof exports === 'object' && exports || {});\n"]}