"use strict";const R=require("./javascript.cjs.js");A.displayName="js-templates";A.aliases=[];function A(_){_.register(R),(function(a){var d=a.languages.javascript["template-string"],O=d.pattern.source,h=d.inside.interpolation,C=h.inside["interpolation-punctuation"],E=h.pattern.source;function v(t,n){if(a.languages[t])return{pattern:RegExp("((?:"+n+")\\s*)"+O),lookbehind:!0,greedy:!0,inside:{"template-punctuation":{pattern:/^`|`$/,alias:"string"},"embedded-code":{pattern:/[\s\S]+/,alias:t}}}}a.languages.javascript["template-string"]=[v("css",/\b(?:styled(?:\([^)]*\))?(?:\s*\.\s*\w+(?:\([^)]*\))*)*|css(?:\s*\.\s*(?:global|resolve))?|createGlobalStyle|keyframes)/.source),v("html",/\bhtml|\.\s*(?:inner|outer)HTML\s*\+?=/.source),v("svg",/\bsvg/.source),v("markdown",/\b(?:markdown|md)/.source),v("graphql",/\b(?:gql|graphql(?:\s*\.\s*experimental)?)/.source),v("sql",/\bsql/.source),d].filter(Boolean);function S(t,n){return"___"+n.toUpperCase()+"_"+t+"___"}function w(t,n,r){var e={code:t,grammar:n,language:r};return a.hooks.run("before-tokenize",e),e.tokens=a.tokenize(e.code,e.grammar),a.hooks.run("after-tokenize",e),e.tokens}function L(t){var n={};n["interpolation-punctuation"]=C;var r=a.tokenize(t,n);if(r.length===3){var e=[1,1];e.push.apply(e,w(r[1],a.languages.javascript,"javascript")),r.splice.apply(r,e)}return new a.Token("interpolation",r,h.alias,t)}function G(t,n,r){var e=a.tokenize(t,{interpolation:{pattern:RegExp(E),lookbehind:!0}}),l=0,f={},p=e.map(function(s){if(typeof s=="string")return s;for(var o=s.content,i;t.indexOf(i=S(l++,r))!==-1;);return f[i]=o,i}).join(""),g=w(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 j=y[l],k=typeof i=="string"?i:i.content,z=k.indexOf(j);if(z!==-1){++l;var T=k.substring(0,z),M=L(f[j]),q=k.substring(z+j.length),c=[];if(T&&c.push(T),c.push(M),q){var x=[q];u(x),c.push.apply(c,x)}typeof i=="string"?(s.splice.apply(s,[o,1].concat(c)),o+=c.length-1):i.content=c}}else{var m=i.content;Array.isArray(m)?u(m):u([m])}}}return u(g),new a.Token(r,g,"language-"+r,t)}var H={javascript:!0,js:!0,typescript:!0,ts:!0,jsx:!0,tsx:!0};a.hooks.add("after-tokenize",function(t){if(!(t.language in H))return;function n(r){for(var e=0,l=r.length;e<l;e++){var f=r[e];if(typeof f!="string"){var p=f.content;if(!Array.isArray(p)){typeof p!="string"&&n([p]);continue}if(f.type==="template-string"){var g=p[1];if(p.length===3&&typeof g!="string"&&g.type==="embedded-code"){var y=b(g),u=g.alias,s=Array.isArray(u)?u[0]:u,o=a.languages[s];if(!o)continue;p[1]=G(y,o,s)}}else n(p)}}}n(t.tokens)});function b(t){return typeof t=="string"?t:Array.isArray(t)?t.map(b).join(""):b(t.content)}})(_)}module.exports=A;
//# sourceMappingURL=js-templates.cjs.js.map
