var z, O;
function B() {
  if (O)
    return z;
  O = 1, z = d, d.displayName = "jsTemplates", d.aliases = [];
  function d(C) {
    (function(a) {
      var h = a.languages.javascript["template-string"], E = h.pattern.source, b = h.inside.interpolation, S = b.inside["interpolation-punctuation"], L = b.pattern.source;
      function c(e, n) {
        if (a.languages[e])
          return {
            pattern: RegExp("((?:" + n + ")\\s*)" + E),
            lookbehind: !0,
            greedy: !0,
            inside: {
              "template-punctuation": {
                pattern: /^`|`$/,
                alias: "string"
              },
              "embedded-code": {
                pattern: /[\s\S]+/,
                alias: e
              }
            }
          };
      }
      a.languages.javascript["template-string"] = [
        // styled-jsx:
        //   css`a { color: #25F; }`
        // styled-components:
        //   styled.h1`color: red;`
        c("css", /\b(?:styled(?:\([^)]*\))?(?:\s*\.\s*\w+(?:\([^)]*\))*)*|css(?:\s*\.\s*(?:global|resolve))?|createGlobalStyle|keyframes)/.source),
        // html`<p></p>`
        // div.innerHTML = `<p></p>`
        c("html", /\bhtml|\.\s*(?:inner|outer)HTML\s*\+?=/.source),
        // svg`<path fill="#fff" d="M55.37 ..."/>`
        c("svg", /\bsvg/.source),
        // md`# h1`, markdown`## h2`
        c("markdown", /\b(?:markdown|md)/.source),
        // gql`...`, graphql`...`, graphql.experimental`...`
        c("graphql", /\b(?:gql|graphql(?:\s*\.\s*experimental)?)/.source),
        // sql`...`
        c("sql", /\bsql/.source),
        // vanilla template string
        h
      ].filter(Boolean);
      function R(e, n) {
        return "___" + n.toUpperCase() + "_" + e + "___";
      }
      function q(e, n, r) {
        var t = {
          code: e,
          grammar: n,
          language: r
        };
        return a.hooks.run("before-tokenize", t), t.tokens = a.tokenize(t.code, t.grammar), a.hooks.run("after-tokenize", t), t.tokens;
      }
      function G(e) {
        var n = {};
        n["interpolation-punctuation"] = S;
        var r = a.tokenize(e, n);
        if (r.length === 3) {
          var t = [1, 1];
          t.push.apply(t, q(r[1], a.languages.javascript, "javascript")), r.splice.apply(r, t);
        }
        return new a.Token("interpolation", r, b.alias, e);
      }
      function H(e, n, r) {
        var t = a.tokenize(e, {
          interpolation: {
            pattern: RegExp(L),
            lookbehind: !0
          }
        }), l = 0, f = {}, p = t.map(function(s) {
          if (typeof s == "string")
            return s;
          for (var o = s.content, i; e.indexOf(i = R(l++, r)) !== -1; )
            ;
          return f[i] = o, i;
        }).join(""), v = q(p, n, r), y = Object.keys(f);
        l = 0;
        function u(s) {
          for (var o = 0; o < s.length; o++) {
            if (l >= y.length)
              return;
            var i = s[o];
            if (typeof i == "string" || typeof i.content == "string") {
              var k = y[l], m = typeof i == "string" ? i : (
                /** @type {string} */
                i.content
              ), T = m.indexOf(k);
              if (T !== -1) {
                ++l;
                var A = m.substring(0, T), M = G(f[k]), w = m.substring(T + k.length), g = [];
                if (A && g.push(A), g.push(M), w) {
                  var x = [w];
                  u(x), g.push.apply(g, x);
                }
                typeof i == "string" ? (s.splice.apply(s, [o, 1].concat(g)), o += g.length - 1) : i.content = g;
              }
            } else {
              var _ = i.content;
              Array.isArray(_) ? u(_) : u([_]);
            }
          }
        }
        return u(v), new a.Token(r, v, "language-" + r, e);
      }
      var J = {
        javascript: !0,
        js: !0,
        typescript: !0,
        ts: !0,
        jsx: !0,
        tsx: !0
      };
      a.hooks.add("after-tokenize", function(e) {
        if (!(e.language in J))
          return;
        function n(r) {
          for (var t = 0, l = r.length; t < l; t++) {
            var f = r[t];
            if (typeof f != "string") {
              var p = f.content;
              if (!Array.isArray(p)) {
                typeof p != "string" && n([p]);
                continue;
              }
              if (f.type === "template-string") {
                var v = p[1];
                if (p.length === 3 && typeof v != "string" && v.type === "embedded-code") {
                  var y = j(v), u = v.alias, s = Array.isArray(u) ? u[0] : u, o = a.languages[s];
                  if (!o)
                    continue;
                  p[1] = H(y, o, s);
                }
              } else
                n(p);
            }
          }
        }
        n(e.tokens);
      });
      function j(e) {
        return typeof e == "string" ? e : Array.isArray(e) ? e.map(j).join("") : j(e.content);
      }
    })(C);
  }
  return z;
}
export {
  B as __require
};
