"use strict";var T=(s,e,t)=>new Promise((p,a)=>{var o=i=>{try{c(t.next(i))}catch(n){a(n)}},u=i=>{try{c(t.throw(i))}catch(n){a(n)}},c=i=>i.done?p(i.value):Promise.resolve(i.value).then(o,u);c((t=t.apply(s,e)).next())});const r=require("@code-inspector/core"),x=["isJsx","isTsx","lang.jsx","lang.tsx"];function S(s){return T(this,null,function*(){var f,y,g;this.cacheable&&this.cacheable(!0);let e=r.normalizePath(this.resourcePath),t=new URLSearchParams(((f=this.resource.split("?"))==null?void 0:f[1])||"");const p=this.query;let{escapeTags:a=[],mappings:o}=p||{};if(r.isExcludedFile(e,p))return s;if(e=r.getMappingFilePath(e,o),r.isJsTypeFile(e)||e.endsWith(".vue")&&x.some(l=>t.get(l)!==null))return r.transformCode({content:s,filePath:e,fileType:"jsx",escapeTags:a,pathType:p.pathType});if(e.endsWith(".vue")&&(t.get("lang")==="tsx"||t.get("lang")==="jsx")){const{descriptor:l}=r.parseSFC(s,{sourceMap:!1}),d=[(y=l.script)==null?void 0:y.content,(g=l.scriptSetup)==null?void 0:g.content];for(const h of d){if(!h)continue;const m=r.transformCode({content:h,filePath:e,fileType:"jsx",escapeTags:a,pathType:p.pathType});s=s.replace(h,m)}return s}const i=e.endsWith(".vue")&&t.get("type")!=="style"&&t.get("type")!=="script"&&t.get("raw")===null,n=e.endsWith(".html")&&t.get("type")==="template"&&t.has("vue");return i||n?r.transformCode({content:s,filePath:e,fileType:"vue",escapeTags:a,pathType:p.pathType}):e.endsWith(".svelte")?r.transformCode({content:s,filePath:e,fileType:"svelte",escapeTags:a,pathType:p.pathType}):s})}module.exports=S;
