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,EAAM5L,GAC1BJ,EAAUgM,GAAQ5L,CACpB,EA+PE6L,eA5PF,WACEjM,EAAY,CAAC,CACf,EA2PEkM,SAzPF,SAAmBpM,GACZI,EAAeJ,EAAOM,YAAWF,EAAeJ,EAAOM,UAAY,CAAC,GACrEN,EAAOyB,IACTrB,EAAeJ,EAAOM,UAAUN,EAAOyB,KAAO,CAC5CM,OAAQ/B,EAAO+B,QAAU/B,EAAOgC,OAChCgG,UAAYhI,EAAOgI,WAAahI,EAAOiI,WAAc,IACrD5I,QAAS,CAAC,GAGZe,EAAeJ,EAAOM,UAAUqK,KAAO,CACrC5I,OAAQ/B,EAAO+B,QAAU/B,EAAOgC,OAChCG,OAAQ,KACRgG,QAAS,KAGf,EA2OEkE,WArOF,SAAqBvP,EAAM6E,GACzB,GAAoB,iBAAT7E,EACL6E,SAAexB,EAAOrD,GAAMuC,QAAQsC,UAC5BxB,EAAOrD,QACd,GAAoB,iBAATA,EAAmB,CACnC,MAAMkD,EAASlD,EACXkD,EAAOyB,WAAYrB,EAAeJ,EAAOM,UAAUN,EAAOyB,YAClDrB,EAAeJ,EAAOM,SACpC,MAAWN,EAAOO,UAAY,GAAGrD,QAAQ+N,MAAM,8CACjD,EA6NEd,SACAmC,UAAWnC,U","sources":["webpack://teddy/webpack/bootstrap","webpack://teddy/./cheerioPolyfill.js","webpack://teddy/./teddy.js"],"sourcesContent":["// The module cache\nvar __webpack_module_cache__ = {};\n\n// The require function\nfunction __webpack_require__(moduleId) {\n\t// Check if module is in cache\n\tvar cachedModule = __webpack_module_cache__[moduleId];\n\tif (cachedModule !== undefined) {\n\t\treturn cachedModule.exports;\n\t}\n\t// Create a new module (and put it into the cache)\n\tvar module = __webpack_module_cache__[moduleId] = {\n\t\t// no module.id needed\n\t\t// no module.loaded needed\n\t\texports: {}\n\t};\n\n\t// Execute the module function\n\t__webpack_modules__[moduleId](module, module.exports, __webpack_require__);\n\n\t// Return the exports of the module\n\treturn module.exports;\n}\n\n","// stub out cheerio using native dom methods for frontend so we don't have to bundle cheerio on the frontend\nexport function load (html) {\n  const doc = parseTeddyDOMFromString(html) // create a DOM\n\n  // return a querySelector function with function chains\n  // e.g. dom('include') or dom(el) from teddy\n  const $ = function (query) { // query can be a string, or a dom object\n    // if query is a string, we need to create a dom object from the string: an object with elements in it, e.g. a list of include tag objects\n    if (typeof query === 'string') {\n      const els = doc.querySelectorAll(query)\n      return els // return the object collection\n    }\n\n    // if query is an object, it's assumed we're trying to perform operations on a single dom node\n    const el = query\n    return {\n\n      // e.g. dom(el).children() from teddy\n      children: function () {\n        return el.childNodes\n      },\n\n      // e.g. dom(el).find() from teddy\n      find: function (selector) {\n        return el.querySelectorAll(selector)\n      },\n\n      // e.g. dom(arg).html() from teddy\n      html: function () {\n        return getTeddyDOMInnerHTML(el)\n      },\n\n      // e.g. dom(arg).toString() from teddy\n      toString: function () {\n        return getTeddyDOMOuterHTML(el)\n      },\n\n      // e.g. dom(el).attr('teddydeferreddynamicinclude', 'true') from teddy\n      attr: function (attr, val) {\n        return el.setAttribute(attr, val)\n      },\n\n      // dom(el).removeAttr(attr) from teddy\n      removeAttr: function (attr) {\n        return el.removeAttribute(attr)\n      },\n\n      // e.g. dom(el).replaceWith(localDom.html()) from teddy\n      replaceWith: function (html) {\n        // can either be a string or an array of elements\n        if (typeof html === 'object') {\n          let newHtml = ''\n          for (const el of html) {\n            if (el.nodeType === window.Node.COMMENT_NODE) newHtml += '<!--' + el.textContent + '-->'\n            else newHtml += el.outerHTML || el.textContent\n          }\n          html = newHtml\n        }\n        const temp = document.createElement('div')\n        temp.innerHTML = html\n        el.replaceWith(...temp.childNodes)\n      },\n\n      // e.g. dom(el).remove() from teddy\n      remove: function () {\n        return el.remove()\n      }\n    }\n  }\n\n  // e.g. dom.html() from teddy\n  $.html = function () {\n    return getTeddyDOMInnerHTML(doc)\n  }\n\n  // e.g. dom.toString() from teddy\n  $.toString = function () {\n    return getTeddyDOMOuterHTML(doc)\n  }\n\n  return $\n}\n\nload.isCheerioPolyfill = true\n\n// DOM parser function like DOMParser's parseFromString but allows Teddy elements to exist in places where they otherwise wouldn't be allowed, like inside of <select> elements\nfunction parseTeddyDOMFromString (html) {\n  const selfClosingTags = new Set(['area', 'base', 'br', 'col', 'embed', 'hr', 'img', 'input', 'link', 'meta', 'param', 'source', 'track', 'wbr'])\n  const root = document.createElement('body')\n  const dom = [root]\n  const openTags = [] // stack to track open tags\n  const tagAndCommentRegex = /<\\/?([a-zA-Z0-9]+)([^>]*)>|<!--([\\s\\S]*?)-->/g\n  const attrRegex = /([a-zA-Z0-9-:._]+)(?:=([\"'])(.*?)\\2|([^>\\s]+))?/g\n  let lastIndex = 0\n  let match\n\n  // loop through each match and build a DOM\n  while ((match = tagAndCommentRegex.exec(html)) !== null) {\n    if (!dom[dom.length - 1]) throw new Error('Error parsing your template. There may be a coding mistake in your HTML. Look for extra closing </tags> and other common mistakes.')\n    const textBeforeMatch = html.slice(lastIndex, match.index)\n\n    // append text nodes\n    if (textBeforeMatch.trim()) {\n      const textNode = document.createTextNode(textBeforeMatch)\n      dom[dom.length - 1].appendChild(textNode)\n    }\n\n    if (match[0].startsWith('<!--')) {\n      // handle comments\n      const commentNode = document.createComment(match[3])\n      dom[dom.length - 1].appendChild(commentNode)\n    } else {\n      // handle tags\n      const [fullMatch, tagName, attrString] = match\n      const lowerCaseTagName = tagName.toLowerCase()\n      const isClosingTag = fullMatch.startsWith('</')\n      if (isClosingTag) {\n        if (selfClosingTags.has(lowerCaseTagName)) {\n          // convert incorrect closing tag for self-closing tag to self-closing tag\n          const element = document.createElement(tagName)\n          dom[dom.length - 1].appendChild(element)\n        } else {\n          // check if the closing tag matches the most recent open tag\n          if (openTags.length > 0 && openTags[openTags.length - 1] === lowerCaseTagName) {\n            openTags.pop()\n            dom.pop()\n          }\n        }\n      } else {\n        // create a new element\n        const element = document.createElement(tagName)\n\n        // set attributes\n        let attrMatch\n        const attrMap = new Map()\n        while ((attrMatch = attrRegex.exec(attrString)) !== null) {\n          const attrName = attrMatch[1]\n          const attrValue = attrMatch[3] || attrMatch[4] || ''\n\n          // handle duplicate attributes for special tags\n          if (attrMap.has(attrName)) {\n            let count = 1\n            let newAttrName\n            do {\n              newAttrName = `${attrName}-teddyduplicate${count}`\n              count++\n            } while (attrMap.has(newAttrName))\n            attrMap.set(newAttrName, attrValue)\n          } else attrMap.set(attrName, attrValue)\n        }\n\n        // apply attributes to the element\n        for (const [name, value] of attrMap) {\n          try {\n            // replace elements with `src` attributes with `data-teddy-defer-attr-src` so the browser doesn't try to prefetch the asset\n            // this is needed because the value of the `src` attribute could be a {teddyVariable} and that fetch won't resolve\n            switch (lowerCaseTagName) {\n              case 'img':\n              case 'video':\n              case 'audio':\n              case 'iframe':\n              case 'script':\n                if (name === 'src') element.setAttribute('data-teddy-defer-attr-src', value) // replace src with data-teddy-defer-attr-src\n                else element.setAttribute(name, value || '')\n                break\n              case 'link':\n                if (name === 'href') element.setAttribute('data-teddy-defer-attr-href', value) // replace src with data-teddy-defer-attr-href\n                else element.setAttribute(name, value || '')\n                break\n              default:\n                element.setAttribute(name, value || '')\n            }\n          } catch (e) {\n            console.warn('Error parsing an element attribute. You might have a typo in your HTML. A common cause is two spaces between element attributes.')\n          }\n        }\n\n        // append the new element to the current parent\n        dom[dom.length - 1].appendChild(element)\n\n        // push the new element to the dom if it's not self-closing\n        if (!selfClosingTags.has(lowerCaseTagName) && !fullMatch.endsWith('/>')) {\n          dom.push(element)\n          openTags.push(lowerCaseTagName)\n        }\n      }\n    }\n\n    lastIndex = tagAndCommentRegex.lastIndex\n  }\n\n  // append any remaining text after the last match\n  if (lastIndex < html.length) {\n    const remainingText = html.slice(lastIndex)\n    if (remainingText.trim()) {\n      const textNode = document.createTextNode(remainingText)\n      dom[dom.length - 1].appendChild(textNode)\n    }\n  }\n\n  return root\n}\n\n// custom functions to get inner/outer HTML without escaping various things to prevent teddy from infinitely escaping them\nconst doublyEncodedEntities = {\n  '&amp;amp;': '&amp;',\n  '&amp;lt;': '&lt;',\n  '&amp;gt;': '&gt;',\n  '&amp;quot;': '&quot;',\n  '&amp;#39;': '&#39;',\n  '&amp;#x2F;': '&#x2F;'\n}\nconst entityEntries = Object.entries(doublyEncodedEntities)\nfunction getTeddyDOMInnerHTML (node) {\n  // build html string\n  let html = ''\n  for (const child of node.childNodes) {\n    if (child.nodeType === window.Node.ELEMENT_NODE) {\n      let outerHTML = child.outerHTML\n      for (const [doublyEncoded, singleEncoded] of entityEntries) outerHTML = outerHTML.replace(new RegExp(doublyEncoded, 'g'), singleEncoded)\n      html += outerHTML\n    } else if (child.nodeType === window.Node.TEXT_NODE) {\n      let textContent = child.textContent\n      for (const [doublyEncoded, singleEncoded] of entityEntries) textContent = textContent.replace(new RegExp(doublyEncoded, 'g'), singleEncoded)\n      html += textContent\n    } else if (child.nodeType === window.Node.COMMENT_NODE) {\n      let commentContent = child.textContent\n      for (const [doublyEncoded, singleEncoded] of entityEntries) commentContent = commentContent.replace(new RegExp(doublyEncoded, 'g'), singleEncoded)\n      html += `<!--${commentContent}-->`\n    }\n  }\n\n  return html\n}\nfunction getTeddyDOMOuterHTML (node) {\n  // start with the outerHTML of the node\n  let outerHTML = ''\n\n  if (node.nodeType === window.Node.ELEMENT_NODE) {\n    outerHTML = node.outerHTML\n  } else if (node.nodeType === window.Node.TEXT_NODE) {\n    outerHTML = node.textContent\n  } else if (node.nodeType === window.Node.COMMENT_NODE) {\n    outerHTML = `<!--${node.textContent}-->`\n  }\n\n  // replace doubly encoded entities\n  for (const [doublyEncoded, singleEncoded] of entityEntries) outerHTML = outerHTML.replace(new RegExp(doublyEncoded, 'g'), singleEncoded)\n\n  return outerHTML\n}\n","// #region globals\n\nimport fs from 'fs' // node filesystem module\nimport path from 'path' // node path module\nimport { load as cheerioLoad } from 'cheerio/slim' // dom parser\n\nconst cheerioOptions = { xml: { xmlMode: false, lowerCaseAttributeNames: false, decodeEntities: false } }\nconst browser = cheerioLoad.isCheerioPolyfill // true if we are executing in the browser context\nconst params = {} // teddy parameters\nsetDefaultParams() // set params to the defaults\nlet templates = {} // loaded templates are stored as object collections, e.g. { \"myTemplate.html\": \"<p>some markup</p>\"}\nconst caches = {} // a place to store cached portions of templates\nconst templateCaches = {} // a place to store cached full templates\n\n// #endregion\n\n// #region private methods\n\n// loads the template from the filesystem\nfunction loadTemplate (template) {\n  // ensure template is a string\n  if (typeof template !== 'string') {\n    if (params.verbosity > 1) console.warn('teddy.loadTemplate attempted to load a template which is not a string.')\n    return ''\n  }\n  const name = template\n  let register = false\n  if (!templates[template] && template.indexOf('<') === -1 && fs && fs.readFileSync) {\n    // template is not found, it is not code, and we're in the node.js context\n    register = true\n    // append extension if not present\n    if (template.slice(-5) !== '.html') template += '.html'\n    try {\n      template = fs.readFileSync(template, 'utf8')\n    } catch (e) {\n      try {\n        template = fs.readFileSync(params.templateRoot + template, 'utf8')\n      } catch (e) {\n        try {\n          template = fs.readFileSync(params.templateRoot + '/' + template, 'utf8')\n        } catch (e) {\n          // do nothing, attempt to render it as code\n          register = false\n        }\n      }\n    }\n  } else {\n    if (templates[template]) {\n      template = templates[template]\n      register = true\n    } else {\n      // didn't find it; append extension if not present and check it again\n      if (template.slice(-5) !== '.html') {\n        template += '.html'\n      }\n      if (templates[template]) {\n        template = templates[template]\n        register = true\n      }\n      template = removeTeddyComments(template)\n    }\n  }\n  if (register) {\n    // register the new template and return the code\n    template = removeTeddyComments(template)\n    templates[name] = template\n    return template\n  } else {\n    // return the template name which is presumed to be code\n    return template.slice(-5) === '.html' ? template.substring(0, template.length - 5) : template\n  }\n}\n\n// remove teddy {! comments !} and <!--! comments -->; also replace <!--# content --> with <escape>content</escape>\nfunction removeTeddyComments (renderedTemplate) {\n  let oldTemplate\n  do {\n    oldTemplate = renderedTemplate\n    let vars\n\n    try {\n      vars = matchByDelimiter(renderedTemplate, '{!', '!}')\n    } catch (e) {\n      return renderedTemplate // it will match {! comments {! with comments in them !} !} but if there are unbalanced brackets, just return the original text\n    }\n    for (let i = 0; i < vars.length; i++) renderedTemplate = renderedTemplate.replace(`{!${vars[i]}!}`, '')\n\n    try {\n      vars = matchByDelimiter(renderedTemplate, '<!--!', '-->')\n    } catch (e) {\n      return renderedTemplate\n    }\n    for (let i = 0; i < vars.length; i++) renderedTemplate = renderedTemplate.replace(`<!--!${vars[i]}-->`, '')\n\n    try {\n      vars = matchByDelimiter(renderedTemplate, '<!--#', '-->')\n    } catch (e) {\n      return renderedTemplate\n    }\n    for (let i = 0; i < vars.length; i++) renderedTemplate = renderedTemplate.replace(`<!--#${vars[i]}-->`, `<escape>${vars[i]}</escape>`)\n  } while (oldTemplate !== renderedTemplate)\n  return renderedTemplate\n}\n\n// find all cache elements and replace them with the rendered contents of their cache, then remove the cache element\nfunction replaceCacheElements (dom, model) {\n  let parsedTags\n  do {\n    parsedTags = 0\n    const tags = dom('cache:not([defer])')\n    if (tags.length > 0) {\n      for (const el of tags) {\n        if (browser) el.attribs = getAttribs(el)\n        const name = el.attribs.name\n        if (name.includes('{')) continue\n        const key = el.attribs.key || 'none'\n        if (key.includes('{')) continue\n        const cache = caches[name]\n        if (cache && cache.entries) {\n          const keyVal = el.attribs.key ? getOrSetObjectByDotNotation(model, key) : 'none'\n          if (cache.entries[keyVal]) {\n            const now = Date.now()\n            // if max age is not set, then there is no max age and the cache content is still valid\n            // or if last accessed + max age > now then the cache is not stale and the cache is still valid\n            if (!(cache.maxAge && !cache.maxage) || cache.entries[keyVal].lastAccessed + (cache.maxAge || cache.maxage) > now) {\n              const cacheContent = cache.entries[keyVal].markup\n              cache.entries[keyVal].lastAccessed = now\n              dom(el).replaceWith(cacheContent)\n            } else {\n              // if last accessed + max age <= now then the cache is stale and the cache is no longer valid\n              delete caches[name].entries[keyVal]\n              dom(el).attr('defer', 'true') // create a new cache\n            }\n          } else dom(el).attr('defer', 'true') // no cache exists for this yet; create after the template renders\n        } else dom(el).attr('defer', 'true') // no cache exists for this yet; create after the template renders\n        parsedTags++\n      }\n    }\n  } while (parsedTags)\n  return dom\n}\n\n// add an id to all <noteddy> or <noparse> tags, then remove their content temporarily until the template is fully parsed\nfunction tagNoParseBlocks (dom, model) {\n  let parsedTags\n  do {\n    parsedTags = 0\n    let tags = dom('noteddy:not([id]), noparse:not([id])')\n    if (tags.length > 0) {\n      for (const el of tags) {\n        const id = model._noTeddyBlocks.push(dom(el).html()) - 1\n        dom(el).replaceWith(`<noteddy id=\"${id}\"></noteddy>`)\n        parsedTags++\n      }\n    }\n    tags = dom('pre:not([id]):not([parse])')\n    if (tags.length > 0) {\n      for (const el of tags) {\n        const id = model._noTeddyBlocks.push(dom(el).toString()) - 1\n        dom(el).replaceWith(`<noteddy id=\"${id}\" pre=\"true\"></noteddy>`)\n        parsedTags++\n      }\n    }\n  } while (parsedTags)\n  return dom\n}\n\n// parse <include> tags\nfunction parseIncludes (dom, model, dynamic) {\n  let parsedTags\n  let passes = 0\n  do {\n    passes++\n    if (passes > params.maxPasses) throw new Error(`teddy could not finish rendering the template because the max number of passes over the template (${params.maxPasses}) was exceeded; there may be an infinite loop in your template logic.`)\n    parsedTags = 0\n    let tags\n    // dynamic includes are includes like <include src=\"{sourcedFromVariable}\"></include>\n    if (dynamic) tags = dom('include') // parse all includes\n    else tags = dom('include:not([teddydeferreddynamicinclude])') // parse only includes that aren't dynamic\n    if (tags.length > 0) {\n      for (const el of tags) {\n        // ensure this isn't the child of a no parse block\n        let foundBody = false\n        let next = false\n        let parent = el.parent || el.parentNode\n        while (!foundBody) {\n          let parentName\n          if (!parent) parentName = 'body'\n          else parentName = parent.nodeName?.toLowerCase() || parent.name\n          if (parentName === 'noparse' || parentName === 'noteddy') {\n            next = true\n            break\n          } else if (parentName === 'body') foundBody = true\n          else parent = parent.parent || parent.parentNode\n        }\n        if (next) continue\n        // get attributes\n        if (browser) el.attribs = getAttribs(el)\n        const src = el.attribs.src\n        if (!src) {\n          if (params.verbosity > 1) console.warn('teddy encountered an include tag with no src attribute.')\n          continue\n        }\n        if (src.startsWith('{')) {\n          dom(el).attr('teddydeferreddynamicinclude', 'true') // mark it dynamic and then skip it\n          continue\n        }\n        loadTemplate(src) // load the partial into the template list\n        let contents = templates[src] || ''\n        if (typeof templates[src] !== 'string' && params.includeNotFoundBehavior === 'display') {\n          contents = `Template \"${src}\" not found!`\n          if (params.verbosity > 1) console.warn(`teddy encountered an include tag with a src set to a template that could not be found: ${src}`)\n        }\n        const localModel = Object.assign({}, model)\n        for (const arg of dom(el).children()) {\n          const argName = browser ? arg.nodeName?.toLowerCase() : arg.name\n          if (argName === 'arg') {\n            if (browser) arg.attribs = getAttribs(arg)\n            const argval = Object.keys(arg.attribs)[0]\n            getOrSetObjectByDotNotation(localModel, argval, dom(arg).html())\n          }\n        }\n        const hasNoteddy = contents.includes('</noteddy>')\n        const hasNoparse = contents.includes('</noparse>')\n        const hasPre = contents.includes('</pre>')\n        const hasIf = contents.includes('</if>')\n        const hasUnless = contents.includes('</unless>')\n        const hasTrue = contents.includes(' true=')\n        const hasFalse = contents.includes(' false=')\n        const hasLoop = contents.includes('</loop>')\n        const hasInline = contents.includes('</inline>')\n        const hasEscape = contents.includes('</escape>') || contents.includes('<!--#')\n        const hasSelected = contents.includes(' selected-value=') || contents.includes(' checked-value=')\n        if (hasEscape) contents = parseEscapes(contents)\n        let localDom\n        if (hasNoteddy || hasNoparse || hasPre) {\n          localDom = cheerioLoad(contents, cheerioOptions)\n          localDom = tagNoParseBlocks(localDom, localModel)\n          contents = localDom.html()\n        }\n        localDom = cheerioLoad(parseVars(contents, localModel), cheerioOptions)\n        if (hasIf || hasUnless) localDom = parseConditionals(localDom, localModel)\n        if (hasTrue || hasFalse) localDom = parseOneLineConditionals(localDom, localModel)\n        if (hasLoop) localDom = parseLoops(localDom, localModel)\n        if (hasInline) localDom = parseInlines(localDom, localModel)\n        if (hasSelected) localDom = parseSelectedAttributeValues(localDom, localModel)\n        dom(el).replaceWith(localDom.html())\n        parsedTags++\n      }\n    }\n  } while (parsedTags)\n  return dom\n}\n\n// parse <if>, <elseif>, <unless>, <elseunless>, and <else> tags\nfunction parseConditionals (dom, model) {\n  let parsedTags\n  do {\n    parsedTags = 0\n    const tags = dom('if, unless')\n    if (tags.length > 0) {\n      for (const el of tags) {\n        // ensure this isn't the child of a loop or a no parse block\n        let foundBody = false\n        let next = false\n        let parent = el.parent || el.parentNode\n        while (!foundBody) {\n          let parentName\n          if (!parent) parentName = 'body'\n          else parentName = parent.nodeName?.toLowerCase() || parent.name\n          if (parentName === 'loop' || parentName === 'noparse' || parentName === 'noteddy') {\n            next = true\n            break\n          } else if (parentName === 'body') foundBody = true\n          else parent = parent.parent || parent.parentNode\n        }\n        if (next) continue\n        // get conditions\n        let args = []\n        if (browser) el.attribs = getAttribs(el)\n        for (let attr in el.attribs) {\n          if (attr.includes('-teddyduplicate')) attr = attr.split('-teddyduplicate')[0] // the condition is a duplicate, so remove the `-teddyduplicate1` from `conditionName-teddyduplicate1`, `conditionName-teddyduplicate2`, etc\n          let val = el.attribs[attr]\n          if (val) {\n            if (val.startsWith('{')) val = parseVars(val, model)\n            args.push(`${attr}=${val}`)\n          } else args.push(attr)\n        }\n        // check if it's an if tag and not an unless tag\n        let isIf = true\n        const elName = browser ? el.nodeName?.toLowerCase() : el.name\n        if (elName === 'unless') isIf = false\n        // evaluate conditional\n        const condResult = evaluateConditional(args, model)\n        if ((isIf && condResult) || ((!isIf && !condResult))) {\n          // render the true block and discard the elseif, elseunless, and else blocks\n          let nextSibling = el.nextSibling\n          const removeStack = []\n          while (nextSibling) {\n            const nextSiblingName = browser ? nextSibling.nodeName?.toLowerCase() : nextSibling.name\n            switch (nextSiblingName) {\n              case 'elseif':\n              case 'elseunless':\n              case 'else':\n                removeStack.push(nextSibling)\n                nextSibling = nextSibling.nextSibling\n                break\n              case 'if':\n              case 'unless':\n                nextSibling = false\n                break\n              default:\n                nextSibling = nextSibling.nextSibling\n            }\n          }\n          for (const element of removeStack) dom(element).replaceWith('')\n          dom(el).replaceWith(el.childNodes || el.children)\n          parsedTags++\n        } else {\n          // true block is false; find the next elseif, elseunless, or else tag to evaluate\n          let nextSibling = el.nextSibling\n          while (nextSibling) {\n            const nextSiblingName = browser ? nextSibling.nodeName?.toLowerCase() : nextSibling.name\n            switch (nextSiblingName) {\n              case 'elseif':\n                // get conditions\n                args = []\n                if (browser) nextSibling.attribs = getAttribs(nextSibling)\n                for (const attr in nextSibling.attribs) {\n                  const val = nextSibling.attribs[attr]\n                  if (val) args.push(`${attr}=${val}`)\n                  else args.push(attr)\n                }\n                if (evaluateConditional(args, model)) {\n                  // render the true block and discard the elseif, elseunless, and else blocks\n                  const replaceSibling = nextSibling\n                  dom(replaceSibling).replaceWith(replaceSibling.childNodes || replaceSibling.children)\n                  nextSibling = el.nextSibling\n                  const removeStack = []\n                  while (nextSibling) {\n                    const nextSiblingName = browser ? nextSibling.nodeName?.toLowerCase() : nextSibling.name\n                    switch (nextSiblingName) {\n                      case 'elseif':\n                      case 'elseunless':\n                      case 'else':\n                        removeStack.push(nextSibling)\n                        nextSibling = nextSibling.nextSibling\n                        break\n                      case 'if':\n                      case 'unless':\n                        nextSibling = false\n                        break\n                      default:\n                        nextSibling = nextSibling.nextSibling\n                    }\n                  }\n                  for (const element of removeStack) dom(element).replaceWith('')\n                  nextSibling = false\n                  parsedTags++\n                } else {\n                  // true block is false; find the next elseif, elseunless, or else tag to evaluate\n                  const siblingToWipe = nextSibling\n                  nextSibling = nextSibling.nextSibling\n                  dom(siblingToWipe).replaceWith('')\n                }\n                break\n              case 'elseunless':\n                // get conditions\n                args = []\n                if (browser) nextSibling.attribs = getAttribs(nextSibling)\n                for (const attr in nextSibling.attribs) {\n                  const val = nextSibling.attribs[attr]\n                  if (val) args.push(`${attr}=${val}`)\n                  else args.push(attr)\n                }\n                if (!evaluateConditional(args, model)) {\n                  // render the true block and discard the elseif, elseunless, and else blocks\n                  const replaceSibling = nextSibling\n                  dom(replaceSibling).replaceWith(replaceSibling.childNodes || replaceSibling.children)\n                  nextSibling = el.nextSibling\n                  const removeStack = []\n                  while (nextSibling) {\n                    const nextSiblingName = browser ? nextSibling.nodeName?.toLowerCase() : nextSibling.name\n                    switch (nextSiblingName) {\n                      case 'elseif':\n                      case 'elseunless':\n                      case 'else':\n                        removeStack.push(nextSibling)\n                        nextSibling = nextSibling.nextSibling\n                        break\n                      case 'if':\n                      case 'unless':\n                        nextSibling = false\n                        break\n                      default:\n                        nextSibling = nextSibling.nextSibling\n                    }\n                  }\n                  for (const element of removeStack) dom(element).replaceWith('')\n                  nextSibling = false\n                  parsedTags++\n                } else {\n                  // true block is false; find the next elseif, elseunless, or else tag to evaluate\n                  const siblingToWipe = nextSibling\n                  nextSibling = nextSibling.nextSibling\n                  dom(siblingToWipe).replaceWith('')\n                }\n                break\n              case 'else':\n                // else is always true, so if we've gotten here, then there's nothing to evaluate and we've reached the end of the conditional blocks\n                dom(nextSibling).replaceWith(nextSibling.childNodes || nextSibling.children)\n                nextSibling = false\n                parsedTags++\n                break\n              case 'if':\n              case 'unless':\n                // if we encounter another fresh if statement or unless statement, then there's nothing left to evaluate and we've reached the end of this conditional's blocks\n                nextSibling = false\n                break\n              default:\n                // if we encounter any other element or a text node we assume there could still be more elseif, elseunless, or else tags ahead so we keep going\n                nextSibling = nextSibling.nextSibling\n            }\n          }\n          dom(el).replaceWith('') // remove the original if statement once done with finding its siblings\n        }\n      }\n    }\n  } while (parsedTags)\n  return dom\n}\n\n// evaluates a single <if> or <unless> tag\nfunction evaluateConditional (conditions, model) {\n  const conditionsLength = conditions.length\n  // loop through conditions and reduce them to booleans\n  for (let i = 0; i < conditionsLength; i++) {\n    const condition = conditions[i]\n    if (typeof condition === 'boolean') continue // if the condition is already a boolean then we don't need to reduce it to a boolean to evaluate it\n    // reject conditions with invalid formatting\n    if (condition.startsWith('=') || condition.endsWith('=')) {\n      if (params.verbosity > 1) console.warn('teddy encountered a conditional statement with \"=\" at the beginning or end of a condition.')\n      return false\n    }\n    if (condition.includes(':') && !condition.startsWith('not:')) {\n      if (params.verbosity > 1) console.warn('teddy encountered a conditional statement with a \"not:\" that isn\\'t at the beginning of a condition.')\n      return false\n    }\n    // deal with boolean logic\n    if (condition === 'and') {\n      if (conditions[i - 1] && evaluateCondition(conditions[i + 1], model)) {\n        // if both sides of an and are true, then reduce all 3 condition blocks to true\n        conditions[i - 1] = true\n        conditions[i] = true\n        conditions[i + 1] = true\n      } else {\n        // if either side of an and is false, then reduce all 3 condition blocks to false\n        conditions[i - 1] = false\n        conditions[i] = false\n        conditions[i + 1] = false\n      }\n    } else if (condition === 'or') {\n      if (conditions[i - 1] || evaluateCondition(conditions[i + 1], model)) {\n        // if either side of an or is true, then reduce all 3 condition blocks to true, as well as all condition blocks that precded this or\n        conditions.fill(true, 0, i + 2)\n      } else {\n        // if both sides of an or are false, then reduce all 3 condition blocks to false\n        conditions[i - 1] = false\n        conditions[i] = false\n        conditions[i + 1] = false\n      }\n    } else if (condition === 'xor') {\n      if (!!conditions[i - 1] === !!evaluateCondition(conditions[i + 1], model)) {\n        // if both sides of an xor are equal to each other, then reduce all 3 condition blocks to false\n        conditions[i - 1] = false\n        conditions[i] = false\n        conditions[i + 1] = false\n      } else {\n        // if the two sides of an xor are not equal to each other, then reduce all 3 condition blocks to true\n        conditions[i - 1] = true\n        conditions[i] = true\n        conditions[i + 1] = true\n      }\n    } else conditions[i] = evaluateCondition(condition, model)\n  }\n  return conditions.every(item => item === true) || false // if any of the booleans are false, then return false. otherwise return true\n}\n\n// determines whether a single condition in a teddy conditional is true or false\nfunction evaluateCondition (condition, model) {\n  let not // stores whether the :not modifier is present\n  if (typeof condition === 'string' && condition.includes('=')) { // it's an equality check condition\n    not = !!condition.startsWith('not:') // true if \"not:\" is present\n    if (not) condition = condition.slice(4) // remove the :not prefix\n    const parts = condition.split('=') // something=\"Some content\"\n    const cond = parts[0] // something\n    delete parts[0] // remove the something=\n    const val = parts.join('') // \"Some content\" — the path.join method ensures the string gets rebuilt even if it contains another = character\n    const lookup = getOrSetObjectByDotNotation(model, cond)\n    // the == is necessary because teddy does type-insensitive equality checks\n    if (lookup == val) return !not // eslint-disable-line\n    else return not // false\n  } else { // it's a presence check\n    not = typeof condition === 'string' ? !!condition.startsWith('not:') : false // true if \"not:\" is present\n    if (not) condition = condition.slice(4) // remove the :not prefix\n    const lookup = getOrSetObjectByDotNotation(model, condition)\n    if (lookup) {\n      if (typeof lookup === 'object' && Object.keys(lookup).length === 0) return not // false; empty object or array\n      return !not // true; var is present\n    } else return not // false; var is not present\n  }\n}\n\n// render one-line if attributes, e.g. <p if-something=\"value\" true=\"class='class-applied-if-true'\" false=\"class='class-applied-if-false'\">hello</p>\nfunction parseOneLineConditionals (dom, model) {\n  let parsedTags\n  do {\n    parsedTags = 0\n    const tags = dom('[true], [false]')\n    if (tags.length > 0) {\n      for (const el of tags) {\n        // skip parsing this if it uses variables as part of its conditions; it will get caught in the next pass after parseVars runs\n        let defer = false\n        if (browser) el.attribs = getAttribs(el)\n        for (const attr in el.attribs) {\n          const val = el.attribs[attr]\n          if (val.startsWith('{')) {\n            defer = true\n            break\n          }\n        }\n        if (defer) {\n          dom(el).attr('teddydeferredonelineconditional', 'true')\n          continue\n        }\n        // ensure this isn't the child of a loop or a no parse block\n        let foundBody = false\n        let next = false\n        let parent = el.parent || el.parentNode\n        while (!foundBody) {\n          let parentName\n          if (!parent) parentName = 'body'\n          else parentName = parent.nodeName?.toLowerCase() || parent.name\n          if (parentName === 'loop' || parentName === 'noparse' || parentName === 'noteddy') {\n            next = true\n            break\n          } else if (parentName === 'body') foundBody = true\n          else parent = parent.parent || parent.parentNode\n        }\n        if (next) continue\n        // get conditions\n        let ifTrue\n        let ifFalse\n        if (browser) el.attribs = getAttribs(el)\n        const args = []\n        for (const origAttr in el.attribs) {\n          let attr = origAttr\n          let val = el.attribs[attr]\n          if (attr.includes('-teddyduplicate')) attr = attr.split('-teddyduplicate')[0] // the condition is a duplicate, so remove the `-teddyduplicate1` from `conditionName-teddyduplicate1`, `conditionName-teddyduplicate2`, etc\n          if (val?.startsWith('{')) val = parseVars(val, model)\n          if (attr.startsWith('if-')) {\n            const parts = attr.split('if-')\n            if (val) args.push(`${parts[1]}=${val}`)\n            else args.push(parts[1])\n            dom(el).removeAttr(origAttr)\n          } else if (attr === 'true') {\n            ifTrue = val.replaceAll('&quot;', '\"') // true=\"class='blah'\"\n            dom(el).removeAttr(origAttr)\n          } else if (attr === 'false') {\n            ifFalse = val.replaceAll('&quot;', '\"') // false=\"class='blah'\"\n            dom(el).removeAttr(origAttr)\n          } else if (attr === 'and' || attr === 'or' || attr === 'xor') {\n            args.push(attr)\n            dom(el).removeAttr(origAttr)\n          }\n        }\n        // evaluate conditional\n        if (evaluateConditional(args, model)) {\n          if (ifTrue) {\n            const parts = ifTrue.split('=')\n            dom(el).attr(parts[0], parts[1] ? parts[1].replace(/[\"']/g, '') : '')\n          }\n          parsedTags++\n        } else if (ifFalse) {\n          if (ifFalse) {\n            const parts = ifFalse.split('=')\n            dom(el).attr(parts[0], parts[1] ? parts[1].replace(/[\"']/g, '') : '')\n          }\n          parsedTags++\n        }\n      }\n    }\n  } while (parsedTags)\n  return dom\n}\n\n// render <loop> tags\nfunction parseLoops (dom, model) {\n  let parsedTags\n  do {\n    parsedTags = 0\n    const tags = dom('loop')\n    if (tags.length > 0) {\n      for (const el of tags) {\n        // get attributes\n        let loopThrough\n        let keyName\n        let valName\n        if (browser) el.attribs = getAttribs(el)\n        for (const attr in el.attribs) {\n          if (attr === 'through') {\n            let attrVal = el.attribs[attr]\n            if (attrVal.startsWith('{')) attrVal = parseVars(attrVal, model)\n            loopThrough = getOrSetObjectByDotNotation(model, attrVal)\n          } else if (attr === 'key') keyName = el.attribs[attr]\n          else if (attr === 'val') valName = el.attribs[attr]\n        }\n        // reject the loop if it has invalid attributes\n        if (!loopThrough) {\n          if (params.verbosity > 1) console.warn('teddy encountered a loop without a through attribute.')\n          dom(el).replaceWith('')\n          continue\n        }\n        if (!keyName && !valName) {\n          if (params.verbosity > 1) console.warn('teddy encountered a loop without a key or a val attribute.')\n          dom(el).replaceWith('')\n          continue\n        }\n        // loop through model[loopThrough] and parse teddy tags within the loop's iteration against the local model\n        let newMarkup = ''\n        let loopContents = dom(el).html()\n        if (loopThrough instanceof Set) loopThrough = [...loopThrough] // convert Sets to arrays\n        for (const key in loopThrough) {\n          const val = loopThrough[key]\n          const localModel = Object.assign({}, model)\n          getOrSetObjectByDotNotation(localModel, keyName, key)\n          getOrSetObjectByDotNotation(localModel, valName, val)\n          const hasNoteddyLoopContents = loopContents.includes('</noteddy>')\n          const hasNoparseLoopContents = loopContents.includes('</noparse>')\n          const hasPreLoopContents = loopContents.includes('</pre>')\n          const hasEscape = loopContents.includes('</escape>') || loopContents.includes('<!--#')\n          if (hasEscape) loopContents = parseEscapes(loopContents)\n          if (hasNoteddyLoopContents || hasNoparseLoopContents || hasPreLoopContents) {\n            let localDom = cheerioLoad(loopContents, cheerioOptions)\n            localDom = tagNoParseBlocks(localDom, localModel)\n            loopContents = localDom.html()\n          }\n          const localMarkup = parseVars(loopContents, localModel) || ''\n          const hasNoteddy = localMarkup.includes('</noteddy>')\n          const hasNoparse = localMarkup.includes('</noparse>')\n          const hasIf = localMarkup.includes('</if>')\n          const hasUnless = localMarkup.includes('</unless>')\n          const hasTrue = localMarkup.includes(' true=')\n          const hasFalse = localMarkup.includes(' false=')\n          const hasLoop = localMarkup.includes('</loop>')\n          const hasInline = localMarkup.includes('</inline>')\n          const hasSelected = localMarkup.includes(' selected-value=') || localMarkup.includes(' checked-value=')\n          let localDom = cheerioLoad(localMarkup || '', cheerioOptions)\n          if (hasNoteddy || hasNoparse) localDom = tagNoParseBlocks(localDom, localModel)\n          if (hasIf || hasUnless) localDom = parseConditionals(localDom, localModel)\n          if (hasTrue || hasFalse) localDom = parseOneLineConditionals(localDom, localModel)\n          if (hasLoop) localDom = parseLoops(localDom, localModel)\n          if (hasInline) localDom = parseInlines(localDom, localModel)\n          if (hasSelected) localDom = parseSelectedAttributeValues(localDom, localModel)\n          newMarkup += localDom.html()\n        }\n        const newDom = cheerioLoad(newMarkup || '', cheerioOptions)\n        dom(el).replaceWith(newDom.html())\n        parsedTags++\n      }\n    }\n  } while (parsedTags)\n  return dom\n}\n\n// render <inline> tags\nfunction parseInlines (dom, model) {\n  let parsedTags\n  do {\n    parsedTags = 0\n    const tags = dom('inline')\n    if (tags.length > 0) {\n      for (const el of tags) {\n        // get attributes\n        let css\n        let js\n        if (browser) el.attribs = getAttribs(el)\n        for (const attr in el.attribs) {\n          if (attr === 'css') css = getOrSetObjectByDotNotation(model, el.attribs[attr])\n          else if (attr === 'js') js = getOrSetObjectByDotNotation(model, el.attribs[attr])\n        }\n        // reject if it has invalid attributes\n        if (!css && !js) {\n          if (params.verbosity > 1) console.warn('teddy encountered an <inline> element without a css or js attribute.')\n          dom(el).replaceWith('')\n          continue\n        }\n        let replaceWith = ''\n        if (css) replaceWith = `<style>${css}</style>`\n        else replaceWith = `<script>${js}</script>`\n        dom(el).replaceWith(replaceWith)\n        parsedTags++\n      }\n    }\n  } while (parsedTags)\n  return dom\n}\n\n// render <escape> tags\nfunction parseEscapes (templateString) {\n  return templateString.replace(/<escape>(.*?)<\\/escape>/gs, (_, content) => escapeEntities(content.trim()))\n}\n\n// render `selected-value` and `checked-value` attributes\nfunction parseSelectedAttributeValues (dom, model) {\n  let parsedTags\n  do {\n    parsedTags = 0\n    const tags = dom('select[selected-value], [checked-value]')\n    if (tags.length > 0) {\n      for (const el of tags) {\n        // get attributes\n        if (browser) el.attribs = getAttribs(el)\n        for (let attr in el.attribs) {\n          const origAttr = attr\n          if (attr.includes('-teddyduplicate')) attr = attr.split('-teddyduplicate')[0]\n          if (attr === 'selected-value') {\n            const val = parseVars(el.attribs[origAttr], model) || el.attribs[origAttr]\n            const children = dom(el).find('option[value]')\n            for (const opt of children) {\n              if (browser) opt.attribs = getAttribs(opt)\n              if (opt.attribs.value === val) dom(opt).attr('selected', 'selected')\n            }\n            dom(el).removeAttr(origAttr)\n          } else if (attr === 'checked-value') {\n            const val = parseVars(el.attribs[origAttr], model) || el.attribs[origAttr]\n            const children = dom(el).find('input[type=\"checkbox\"][value], input[type=\"radio\"][value]')\n            for (const opt of children) {\n              if (browser) opt.attribs = getAttribs(opt)\n              if (opt.attribs.value === val) dom(opt).attr('checked', 'checked')\n            }\n            dom(el).removeAttr(origAttr)\n          }\n        }\n        parsedTags++\n      }\n    }\n  } while (parsedTags)\n  return dom\n}\n\n// render {variables}\nfunction parseVars (templateString, model) {\n  let vars\n  try {\n    vars = matchByDelimiter(templateString, '{', '}')\n  } catch (e) {\n    return templateString // it will match {vars{withVarsInThem}} but if there are unbalanced brackets, just return the original text\n  }\n  const varsLength = vars.length\n  for (let i = 0; i < varsLength; i++) {\n    let match = vars[i]\n    if (match === '') continue // empty {}\n    if (!/^(\\d+|[a-zA-Z_$][a-zA-Z0-9_$|{}.-]*(\\.[a-zA-Z_$][a-zA-Z0-9_$|{}.-]*)*)$/.test(match)) {\n      if (params.verbosity > 2) console.warn(`teddy.parseVars encountered a {variable} that could not be parsed: {${match}}`)\n      continue // skip invalid variables\n    }\n    if (match.includes('{')) {\n      // there's a variable inside the variable name\n      const originalMatch = match\n      match = parseVars(match, model)\n      try {\n        templateString = templateString.replace(new RegExp(`\\${${originalMatch}}`, 'i'), () => `\\${${match}}`)\n        templateString = templateString.replace(new RegExp(`{${originalMatch}}`, 'i'), () => `{${match}}`)\n      } catch (e) {\n        if (params.verbosity > 2) console.warn(`teddy.parseVars encountered a {variable} that could not be parsed: {${originalMatch}}`)\n      }\n    }\n    const lastSixChars = match.slice(-6)\n    if (lastSixChars.includes('|p')) { // no parse flag is set\n      const originalMatch = match\n      match = match.substring(0, match.length - (lastSixChars.split('|').length - 1) * 2) // remove last 2-n chars\n      let parsed = getOrSetObjectByDotNotation(model, match)\n      if (!parsed && !lastSixChars.includes('|d') && (params.emptyVarBehavior === 'hide' || lastSixChars.includes('|h'))) parsed = '' // display empty string instead of the variable text verbatim if this setting is set\n      if (typeof parsed === 'string' && parsed.startsWith('{') && parsed.includes('|d')) parsed = parsed.replace('|d', '')\n      if (parsed || parsed === '') {\n        const id = model._noTeddyBlocks.push(parsed) - 1\n        try {\n          try {\n            templateString = templateString.replace(new RegExp(`\\${${originalMatch}}`.replace(/[|\\\\{}()[\\]^$+*?.]/g, '\\\\$&').replace(/-/g, '\\\\x2d'), 'i'), `<noteddy id=\"${id}\"></noteddy>`)\n            templateString = templateString.replace(new RegExp(`{${originalMatch}}`.replace(/[|\\\\{}()[\\]^$+*?.]/g, '\\\\$&').replace(/-/g, '\\\\x2d'), 'i'), `<noteddy id=\"${id}\"></noteddy>`)\n          } catch (e) {\n            if (params.verbosity > 2) console.warn(`teddy.parseVars encountered a {variable} that could not be parsed: {${originalMatch}}`)\n          }\n        } catch (e) {\n          return templateString\n        }\n      }\n    } else if (lastSixChars.includes('|s')) { // no escape flag is set\n      const originalMatch = match\n      match = match.substring(0, match.length - (lastSixChars.split('|').length - 1) * 2) // remove last 2-n chars\n      let parsed = getOrSetObjectByDotNotation(model, match)\n      let skipTemplateLiteralReplacement = false\n      if (!parsed && !lastSixChars.includes('|d') && (params.emptyVarBehavior === 'hide' || lastSixChars.includes('|h'))) parsed = '' // display empty string instead of the variable text verbatim if this setting is set\n      else if (!parsed && parsed !== '') {\n        skipTemplateLiteralReplacement = true\n        parsed = `{${originalMatch}}`\n      }\n      if (typeof parsed === 'string' && parsed.startsWith('{') && parsed.includes('|d')) parsed = parsed.replace('|d', '')\n      try {\n        if (!skipTemplateLiteralReplacement) templateString = templateString.replace(new RegExp(`\\${${originalMatch}}`.replace(/[|\\\\{}()[\\]^$+*?.]/g, '\\\\$&').replace(/-/g, '\\\\x2d'), 'i'), () => parsed)\n        templateString = templateString.replace(new RegExp(`{${originalMatch}}`.replace(/[|\\\\{}()[\\]^$+*?.]/g, '\\\\$&').replace(/-/g, '\\\\x2d'), 'i'), () => parsed)\n      } catch (e) {\n        return templateString\n      }\n    } else { // no flags are set\n      let parsed = getOrSetObjectByDotNotation(model, match)\n      let skipTemplateLiteralReplacement = false\n      if (!parsed && !lastSixChars.includes('|d') && (params.emptyVarBehavior === 'hide' || lastSixChars.includes('|h'))) parsed = '' // display empty string instead of the variable text verbatim if this setting is set\n      else if (parsed || parsed === '') parsed = escapeEntities(parsed)\n      else if (parsed === 0) parsed = '0'\n      else {\n        skipTemplateLiteralReplacement = true\n        parsed = `{${match}}`\n      }\n      if (typeof parsed === 'string' && parsed.startsWith('{') && parsed.includes('|d')) parsed = parsed.replace('|d', '')\n      try {\n        if (!skipTemplateLiteralReplacement) templateString = templateString.replace(new RegExp(`\\${${match}}`.replace(/[|\\\\{}()[\\]^$+*?.]/g, '\\\\$&').replace(/-/g, '\\\\x2d'), 'i'), () => parsed)\n        templateString = templateString.replace(new RegExp(`{${match}}`.replace(/[|\\\\{}()[\\]^$+*?.]/g, '\\\\$&').replace(/-/g, '\\\\x2d'), 'i'), () => parsed)\n      } catch (e) {\n        return templateString\n      }\n    }\n  }\n  return templateString\n}\n\n// once the template is fully rendered, find all cache elements that still exist and cache their contents\nfunction defineNewCaches (dom, model) {\n  let parsedTags\n  do {\n    parsedTags = 0\n    const tags = dom('cache[defer]')\n    if (tags.length > 0) {\n      for (const el of tags) {\n        if (browser) el.attribs = getAttribs(el)\n        const name = el.attribs.name\n        const key = el.attribs.key || 'none'\n        const maxAge = parseInt(el.attribs.maxAge || el.attribs.maxage) || 0\n        const maxCaches = parseInt(el.attribs.maxCaches || el.attribs.maxcaches) || 1000\n        const timestamp = Date.now()\n        const markup = dom(el).html()\n        if (!caches[name]) {\n          caches[name] = {\n            key,\n            maxAge,\n            maxCaches,\n            entries: {}\n          }\n        }\n        caches[name].entries[el.attribs.key ? getOrSetObjectByDotNotation(model, key) : 'none'] = {\n          lastAccessed: timestamp,\n          created: timestamp,\n          markup\n        }\n        // invalidate oldest cache if we've reached max caches limit\n        if (Object.keys(caches[name].entries).length > maxCaches) {\n          const lowestKeyVal = Object.keys(caches[name].entries).reduce((a, b) => caches[name].entries[a].lastAccessed < caches[name].entries[b].lastAccessed ? a : b)\n          delete caches[name].entries[lowestKeyVal]\n        }\n        dom(el).replaceWith(markup)\n        parsedTags++\n      }\n    }\n  } while (parsedTags)\n  return dom\n}\n\n// removes any remaining teddy tags from the dom before returning the parsed html to the user\nfunction cleanupStrayTeddyTags (dom) {\n  let parsedTags\n  do {\n    parsedTags = 0\n    const tags = dom('[teddydeferredonelineconditional], pre[parse], include, arg, if, unless, elseif, elseunless, else, loop, cache')\n    if (tags.length > 0) {\n      for (const el of tags) {\n        const tagName = browser ? el.nodeName?.toLowerCase() : el.name\n        if (tagName === 'include' || tagName === 'arg' || tagName === 'if' || tagName === 'unless' || tagName === 'elseif' || tagName === 'elseunless' || tagName === 'else' || tagName === 'loop' || tagName === 'cache') {\n          dom(el).remove()\n        }\n        if (browser) el.attribs = getAttribs(el)\n        for (const attr in el.attribs) {\n          if (attr === 'true' || attr === 'false' || attr === 'parse' || attr === 'teddydeferredonelineconditional' || attr.startsWith('if-')) {\n            dom(el).removeAttr(attr)\n          }\n        }\n      }\n    }\n  } while (parsedTags)\n  return dom\n}\n\n// escapes sensitive characters to prevent xss\nconst escapeHtmlEntities = {\n  '&': '&amp;',\n  '<': '&lt;',\n  '>': '&gt;',\n  '\"': '&#34;',\n  \"'\": '&#39;'\n}\nconst entityKeys = Object.keys(escapeHtmlEntities)\nconst ekl = entityKeys.length\nfunction escapeEntities (value) {\n  let escapedEntity = false\n  let newValue = ''\n  let i\n  let j\n\n  if (typeof value === 'object') { // cannot escape on this value\n    if (!value) return false // it is falsey to return false\n    else if (Array.isArray(value)) {\n      if (value.length === 0) return false // empty arrays are falsey\n      else return '[Array]' // print that it is an array with content in it, but do not print the contents\n    }\n    return '[Object]' // just print that it is an object, do not print the contents\n  } else if (value === undefined) return false // cannot escape on this value; undefined is falsey\n  else if (typeof value === 'boolean' || typeof value === 'number') return value // cannot escape on these values; if it's already a boolean or a number just return it\n  else {\n    // loop through value to find html entities\n    for (i = 0; i < value.length; i++) {\n      escapedEntity = false\n\n      // loop through list of html entities to escape\n      for (j = 0; j < ekl; j++) {\n        if (value[i] === entityKeys[j]) { // alter value to show escaped html entities\n          newValue += escapeHtmlEntities[entityKeys[j]]\n          escapedEntity = true\n          break\n        }\n      }\n\n      if (!escapedEntity) newValue += value[i]\n    }\n  }\n\n  return newValue\n}\n\n// if an entity is double-encoded, this will fix that\nfunction reverseDoubleEncodedEntities (str) {\n  return str.replace(/&amp;(#\\d+;|#x[0-9A-Fa-f]+;|[A-Za-z]+;)/g, '&$1')\n}\n\n// match strings by a custom delimiter\nfunction matchByDelimiter (input, openDelimiter, closeDelimiter) {\n  const stack = []\n  const result = []\n  const openLength = openDelimiter.length\n  const closeLength = closeDelimiter.length\n\n  for (let i = 0; i < input.length; i++) {\n    if (input.substring(i, i + openLength) === openDelimiter) {\n      stack.push(i + openLength)\n      i += openLength - 1\n    } else if (input.substring(i, i + closeLength) === closeDelimiter) {\n      const start = stack.pop()\n      if (stack.length === 0) {\n        result.push(input.substring(start, i))\n      }\n      i += closeLength - 1\n    }\n  }\n\n  const individualSegments = []\n  const regex = /{!([^{}]*)!}/g\n  let match\n\n  for (const segment of result) {\n    while ((match = regex.exec(segment)) !== null) {\n      individualSegments.push(match[1])\n    }\n    individualSegments.push(segment)\n  }\n\n  return individualSegments\n}\n\n// gets or sets an object by dot notation, e.g. thing.nestedThing.furtherNestedThing: two arguments gets, three arguments sets\nfunction getOrSetObjectByDotNotation (obj, dotNotation, value) {\n  if (!obj) return false\n  if (!dotNotation || typeof dotNotation === 'boolean' || typeof dotNotation === 'number') return dotNotation\n  if (typeof dotNotation === 'string') return getOrSetObjectByDotNotation(obj, dotNotation.split('.'), value)\n  else if (dotNotation.length === 1 && value !== undefined) {\n    obj[dotNotation[0]] = value\n    return obj[dotNotation[0]]\n  } else if (dotNotation.length === 0) return obj\n  else if (dotNotation.length === 1) {\n    if (obj) return caseInsensitiveLookup(obj, dotNotation[0])\n    return false\n  } else return getOrSetObjectByDotNotation(caseInsensitiveLookup(obj, dotNotation[0]), dotNotation.slice(1), value)\n  function caseInsensitiveLookup (obj, key) {\n    if (key === 'length') return obj.length\n    const lowerCaseKey = key.toLowerCase()\n    const normalizedObj = Object.keys(obj).reduce((acc, k) => {\n      acc[k.toLowerCase()] = obj[k]\n      return acc\n    }, {})\n    return normalizedObj[lowerCaseKey]\n  }\n}\n\n// cheerio polyfill\nfunction getAttribs (element) {\n  const attributes = element.attributes\n  const attributesObject = {}\n\n  for (let i = 0; i < attributes.length; i++) {\n    const attr = attributes[i]\n    attributesObject[attr.name] = attr.value\n  }\n\n  return attributesObject\n}\n\n// #endregion\n\n// #region public methods\n\n// set params to the defaults\nfunction setDefaultParams () {\n  params.verbosity = 1\n  params.templateRoot = './'\n  params.maxPasses = 1000\n  params.emptyVarBehavior = 'display' // or 'hide'\n  params.includeNotFoundBehavior = 'display' // or 'hide'\n}\n\n// mutator method to set verbosity param. takes human-readable string argument and converts it to an integer for more efficient checks against the setting\nfunction setVerbosity (v) {\n  switch (v) {\n    case 'none':\n    case 0:\n      v = 0\n      break\n    case 'verbose':\n    case 2:\n      v = 2\n      break\n    case 'debug':\n    case 'DEBUG':\n    case 3:\n      v = 3\n      break\n    default: // concise\n      v = 1\n  }\n  params.verbosity = v\n}\n\n// mutator method to set template root param; must be a string\nfunction setTemplateRoot (v) {\n  params.templateRoot = String(v)\n}\n\n// mutator method to set max passes param: the number of times the parser can iterate over the template\nfunction setMaxPasses (v) {\n  params.maxPasses = Number(v)\n}\n\n// mutator method to set empty var behavior param: whether to display {variables} that don't resolve as text ('display') or as an empty string ('hide')\nfunction setEmptyVarBehavior (v) {\n  if (v === 'hide') params.emptyVarBehavior = 'hide'\n  else params.emptyVarBehavior = 'display'\n}\n\n// mutator method to set include tag not found param: whether to display an error when an <include> tag src can't be found\nfunction setIncludeNotFoundBehavior (v) {\n  if (v === 'hide') params.includeNotFoundBehavior = 'hide'\n  else params.includeNotFoundBehavior = 'display'\n}\n\n// access templates\nfunction getTemplates () {\n  return templates\n}\n\n// takes in a template string and outputs a function which when given data will render out html\nfunction compile (templateString) {\n  return function (model) {\n    return render(templateString, model)\n  }\n}\n\n// mutator method to cache template\nfunction setTemplate (file, template) {\n  templates[file] = template\n}\n\n// mutator method to clear template cache entirely\nfunction clearTemplates () {\n  templates = {}\n}\n\nfunction setCache (params) {\n  if (!templateCaches[params.template]) templateCaches[params.template] = {}\n  if (params.key) {\n    templateCaches[params.template][params.key] = {\n      maxAge: params.maxAge || params.maxage,\n      maxCaches: (params.maxCaches || params.maxcaches) || 1000,\n      entries: {}\n    }\n  } else {\n    templateCaches[params.template].none = {\n      maxAge: params.maxAge || params.maxage,\n      markup: null,\n      created: null\n    }\n  }\n}\n\n// delete one or more cached templates\n// 1 string argument deletes the whole cache at that name for template partial caches\n// 2 arguments deletes just the value at that keyVal for template partial caches\n// 1 object argument assumes we're clearing whole template level cache\nfunction clearCache (name, keyVal) {\n  if (typeof name === 'string') {\n    if (keyVal) delete caches[name].entries[keyVal]\n    else delete caches[name]\n  } else if (typeof name === 'object') {\n    const params = name\n    if (params.key) delete templateCaches[params.template][params.key]\n    else delete templateCaches[params.template]\n  } else if (params.verbosity > 0) console.error('teddy: invalid params passed to clearCache.')\n}\n\n// parses a template\nfunction render (template, model, callback) {\n  // ensure template is a string\n  if (typeof template !== 'string') {\n    if (params.verbosity > 1) console.warn('teddy.render attempted to render a template which is not a string.')\n    if (typeof callback === 'function') return callback(null, '')\n    else return ''\n  }\n\n  // ensure model is an object\n  if (typeof model !== 'object') {\n    if (params.verbosity > 1) console.warn('teddy.render was passed an invalid model.')\n    model = {} // allow the template to render if an invalid model is supplied, but it will have an empty model\n  }\n\n  // declare vars\n  let dom\n  let renderedTemplate\n  model._noTeddyBlocks = [] // will store code blocks exempt from teddy parsing\n\n  // express.js support\n  if (model.settings && model.settings.views && path) params.templateRoot = path.resolve(model.settings.views)\n\n  // remove templateRoot from template name if necessary\n  if (template.slice(params.templateRoot.length) === params.templateRoot) template = template.replace(params.templateRoot, '')\n\n  // whole template caching\n  const templateCache = templateCaches[template]\n  let cacheKey = null\n  let cacheKeyModelVal = null\n  if (templateCache) {\n    const singletonCache = templateCache.none\n    if (singletonCache) {\n      // check if the timestamp exceeds max age\n      if (!singletonCache.created) cacheKey = 'none'\n      else if (!singletonCache.maxAge && singletonCache.maxage) {\n        // if no max age is set, then this cache doesn't expire\n        if (typeof callback === 'function') return callback(null, singletonCache.markup)\n        else return singletonCache.markup\n      } else if (singletonCache.created + (singletonCache.maxAge || singletonCache.maxage) < Date.now()) cacheKey = 'none' // if yes re-render the template and cache it again\n      else {\n        // if no return the cached markup and skip the template render\n        if (typeof callback === 'function') return callback(null, singletonCache.markup)\n        else return singletonCache.markup\n      }\n    } else {\n      // loop through its keys\n      for (const key in templateCache) {\n        // if there's a model value for that key name\n        cacheKeyModelVal = getOrSetObjectByDotNotation(model, key)\n        if (cacheKeyModelVal) {\n          // loop through its entries\n          const templateCacheAtThisKey = templateCache[key]\n          for (const entryKey in templateCacheAtThisKey.entries) {\n            // if any entry keys match the model value for that key name\n            if (entryKey === cacheKeyModelVal) {\n              // check if the timestamp exceeds max age\n              const entry = templateCacheAtThisKey.entries[entryKey]\n              if (!templateCacheAtThisKey.maxAge && !templateCacheAtThisKey.maxage) {\n                // if no max age is set, then this cache doesn't expire\n                if (typeof callback === 'function') return callback(null, entry.markup)\n                else return entry.markup\n              } else if (entry.created + (templateCacheAtThisKey.maxAge || templateCacheAtThisKey.maxage) < Date.now()) {\n                // if yes re-render the template and cache it again\n                cacheKey = key\n                break\n              } else {\n                // if no return the cached markup and skip the template render\n                if (typeof callback === 'function') return callback(null, entry.markup)\n                else return entry.markup\n              }\n            }\n          }\n          // this is a new model value so it needs a new entry\n          cacheKey = key\n          break\n        }\n      }\n    }\n  }\n\n  // start the render\n  renderedTemplate = loadTemplate(template)\n\n  // replace duplicate attributes with temporary unique names before loading into cheerio\n  if (!browser) {\n    renderedTemplate = renderedTemplate.replace(/<([a-zA-Z][a-zA-Z0-9-]*)([^>]*)>/g, (match, tagName, attributes) => {\n      const attrRegex = /([a-zA-Z0-9-:._]+)(?:=([\"'])(.*?)\\2|([^>\\s]+))?/g\n      const attrMap = new Map()\n      let count = 1\n      const processedAttributes = attributes.replace(attrRegex, (attrMatch, attrName, quote, attrValue) => {\n        if (attrMap.has(attrName)) {\n          const newAttrName = `${attrName}-teddyduplicate${count++}`\n          return attrMatch.replace(attrName, newAttrName)\n        } else {\n          attrMap.set(attrName, true)\n          return attrMatch\n        }\n      })\n      return `<${tagName}${processedAttributes}>`\n    })\n  }\n\n  const hasEscape = renderedTemplate.includes('</escape>') || renderedTemplate.includes('<!--#')\n  if (hasEscape) renderedTemplate = parseEscapes(renderedTemplate)\n\n  dom = cheerioLoad(renderedTemplate || '', cheerioOptions)\n  let oldTemplate\n  let passes = 0\n  let parseDynamicIncludes = false\n  do {\n    passes++\n    if (passes > params.maxPasses) {\n      if (params.verbosity > 0) console.error(`teddy could not finish rendering the template because the max number of passes over the template (${params.maxPasses}) was exceeded; there may be an infinite loop in your template logic.`)\n      break\n    }\n    const hasCache = renderedTemplate.includes('</cache>')\n    const hasNoteddy = renderedTemplate.includes('</noteddy>')\n    const hasNoparse = renderedTemplate.includes('</noparse>')\n    const hasPre = renderedTemplate.includes('</pre>')\n    const hasIf = renderedTemplate.includes('</if>')\n    const hasUnless = renderedTemplate.includes('</unless>')\n    const hasTrue = renderedTemplate.includes(' true=')\n    const hasFalse = renderedTemplate.includes(' false=')\n    const hasInclude = renderedTemplate.includes('</include>')\n    const hasLoop = renderedTemplate.includes('</loop>')\n    const hasInline = renderedTemplate.includes('</inline>')\n    const hasSelected = renderedTemplate.includes(' selected-value=') || renderedTemplate.includes(' checked-value=')\n    oldTemplate = renderedTemplate || ''\n    if (passes > 1) {\n      dom = cheerioLoad(renderedTemplate || '', cheerioOptions)\n      if (parseDynamicIncludes) dom = parseIncludes(dom, model, true)\n    }\n    if (hasCache) dom = replaceCacheElements(dom, model)\n    if (hasNoteddy || hasNoparse || hasPre) dom = tagNoParseBlocks(dom, model)\n    if (hasIf || hasUnless) dom = parseConditionals(dom, model)\n    if (hasTrue || hasFalse) dom = parseOneLineConditionals(dom, model)\n    if (hasInclude) dom = parseIncludes(dom, model)\n    if (hasLoop) dom = parseLoops(dom, model)\n    if (hasInline) dom = parseInlines(dom, model)\n    if (hasSelected) dom = parseSelectedAttributeValues(dom, model)\n    const cachesStillPresent = renderedTemplate.includes('</cache>')\n    renderedTemplate = dom.html()\n    renderedTemplate = parseVars(renderedTemplate, model)\n    if (parseDynamicIncludes) {\n      renderedTemplate = removeTeddyComments(renderedTemplate)\n      parseDynamicIncludes = false\n    }\n    if (renderedTemplate.includes('teddydeferreddynamicinclude=\"true\"')) {\n      oldTemplate = '' // reset old template to force another pass\n      parseDynamicIncludes = true\n    }\n    if (oldTemplate === renderedTemplate && cachesStillPresent) {\n      dom = cheerioLoad(renderedTemplate || '', cheerioOptions)\n      dom = defineNewCaches(dom, model)\n      renderedTemplate = dom.html()\n    }\n  } while (oldTemplate !== renderedTemplate)\n\n  // remove stray teddy tags if any exist\n  if (renderedTemplate.includes('teddydeferredonelineconditional=\"true\"') || renderedTemplate.includes('</include>') || renderedTemplate.includes('</arg>') || renderedTemplate.includes('</if>') || renderedTemplate.includes('</unless>') || renderedTemplate.includes('</elseif>') || renderedTemplate.includes('</elseunless>') || renderedTemplate.includes('</else>') || renderedTemplate.includes('</loop>') || renderedTemplate.includes('</cache>') || renderedTemplate.includes('</pre>')) {\n    dom = cheerioLoad(renderedTemplate || '', cheerioOptions)\n    dom = cleanupStrayTeddyTags(dom)\n    renderedTemplate = dom.html()\n  }\n\n  // replace <noteddy> blocks with the hidden code\n  for (const blockId in model._noTeddyBlocks) {\n    renderedTemplate = renderedTemplate.replace(`<noteddy id=\"${blockId}\"></noteddy>`, () => model._noTeddyBlocks[blockId])\n    renderedTemplate = renderedTemplate.replace(`<noteddy id=\"${blockId}\" pre=\"true\"></noteddy>`, () => model._noTeddyBlocks[blockId])\n  }\n\n  if (browser) {\n    // fix double-encoding html entity bug in client-side mode\n    renderedTemplate = reverseDoubleEncodedEntities(renderedTemplate)\n\n    // now that we're done with the render, reset data-teddy-defer-attr-src and data-teddy-defer-attr-href to native attributes\n    renderedTemplate = renderedTemplate.replaceAll('data-teddy-defer-attr-src', 'src').replaceAll('data-teddy-defer-attr-href', 'href')\n  }\n\n  // cache the template\n  if (cacheKey === 'none') {\n    templateCaches[template].none.markup = renderedTemplate\n    templateCaches[template].none.created = Date.now()\n  } else if (cacheKey) {\n    if (!templateCaches[template][cacheKey].entries[cacheKeyModelVal]) templateCaches[template][cacheKey].entries[cacheKeyModelVal] = {}\n    templateCaches[template][cacheKey].entries[cacheKeyModelVal].markup = renderedTemplate\n    templateCaches[template][cacheKey].entries[cacheKeyModelVal].created = Date.now()\n    // invalidate oldest cache if we've reached max caches limit\n    if (Object.keys(templateCaches[template][cacheKey].entries).length > templateCaches[template][cacheKey].maxCaches) {\n      const lowestKeyVal = Object.keys(templateCaches[template][cacheKey].entries).reduce((a, b) => templateCaches[template][cacheKey].entries[a].created < templateCaches[template][cacheKey].entries[b].created ? a : b)\n      delete templateCaches[template][cacheKey].entries[lowestKeyVal]\n    }\n  }\n\n  if (typeof callback === 'function') return callback(null, renderedTemplate)\n  else return renderedTemplate\n}\n\n// #endregion\n\nexport default {\n  params,\n  caches,\n  templateCaches,\n\n  // functions\n  compile,\n  setDefaultParams,\n  setVerbosity,\n  setTemplateRoot,\n  setMaxPasses,\n  setEmptyVarBehavior,\n  setIncludeNotFoundBehavior,\n  getTemplates,\n  setTemplate,\n  clearTemplates,\n  setCache,\n  clearCache,\n  render,\n  __express: render\n}\n"],"names":["__webpack_module_cache__","__webpack_require__","moduleId","cachedModule","undefined","exports","module","__webpack_modules__","load","html","doc","selfClosingTags","Set","root","document","createElement","dom","openTags","tagAndCommentRegex","attrRegex","match","lastIndex","exec","length","Error","textBeforeMatch","slice","index","trim","textNode","createTextNode","appendChild","startsWith","commentNode","createComment","fullMatch","tagName","attrString","lowerCaseTagName","toLowerCase","has","element","pop","attrMatch","attrMap","Map","attrName","attrValue","newAttrName","count","set","name","value","setAttribute","e","console","warn","endsWith","push","remainingText","parseTeddyDOMFromString","$","query","querySelectorAll","el","children","childNodes","find","selector","getTeddyDOMInnerHTML","toString","getTeddyDOMOuterHTML","attr","val","removeAttr","removeAttribute","replaceWith","newHtml","nodeType","window","Node","COMMENT_NODE","textContent","outerHTML","temp","innerHTML","remove","isCheerioPolyfill","entityEntries","Object","entries","node","child","ELEMENT_NODE","doublyEncoded","singleEncoded","replace","RegExp","TEXT_NODE","commentContent","browser","params","setDefaultParams","templates","caches","templateCaches","loadTemplate","template","verbosity","register","indexOf","templateRoot","removeTeddyComments","substring","renderedTemplate","oldTemplate","vars","matchByDelimiter","i","replaceCacheElements","model","parsedTags","tags","attribs","getAttribs","includes","key","cache","keyVal","getOrSetObjectByDotNotation","now","Date","maxAge","maxage","lastAccessed","cacheContent","markup","tagNoParseBlocks","id","_noTeddyBlocks","parseIncludes","dynamic","passes","maxPasses","foundBody","next","parent","parentNode","parentName","nodeName","src","contents","includeNotFoundBehavior","localModel","assign","arg","keys","hasNoteddy","hasNoparse","hasPre","hasIf","hasUnless","hasTrue","hasFalse","hasLoop","hasInline","hasEscape","hasSelected","localDom","parseEscapes","parseVars","parseConditionals","parseOneLineConditionals","parseLoops","parseInlines","parseSelectedAttributeValues","args","split","isIf","condResult","evaluateConditional","nextSibling","removeStack","replaceSibling","siblingToWipe","conditions","conditionsLength","condition","evaluateCondition","fill","every","item","not","parts","cond","join","lookup","defer","ifTrue","ifFalse","origAttr","replaceAll","loopThrough","keyName","valName","attrVal","newMarkup","loopContents","hasNoteddyLoopContents","hasNoparseLoopContents","hasPreLoopContents","localMarkup","newDom","css","js","templateString","_","content","escapeEntities","opt","varsLength","test","originalMatch","lastSixChars","parsed","emptyVarBehavior","skipTemplateLiteralReplacement","defineNewCaches","parseInt","maxCaches","maxcaches","timestamp","created","lowestKeyVal","reduce","a","b","escapeHtmlEntities","entityKeys","ekl","j","escapedEntity","newValue","Array","isArray","input","openDelimiter","closeDelimiter","stack","result","openLength","closeLength","start","individualSegments","regex","segment","obj","dotNotation","caseInsensitiveLookup","lowerCaseKey","acc","k","attributes","attributesObject","render","callback","settings","views","templateCache","cacheKey","cacheKeyModelVal","singletonCache","none","templateCacheAtThisKey","entryKey","entry","quote","parseDynamicIncludes","error","hasCache","hasInclude","cachesStillPresent","cleanupStrayTeddyTags","blockId","compile","setVerbosity","v","setTemplateRoot","String","setMaxPasses","Number","setEmptyVarBehavior","setIncludeNotFoundBehavior","getTemplates","setTemplate","file","clearTemplates","setCache","clearCache","__express"],"sourceRoot":""}