"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.default=default_1;const config_1=require("../../../../config/config"),_pluginTransformWorklet=()=>require("../../../../utils/babel_plugin_worklet"),babel7=()=>require("@babel/core"),worklet=(e,r)=>{const o=babel7();let t;try{const s={babelrc:!1,plugins:[require("../../../../utils/babel_plugin_worklet")],sourceFileName:r,inputSourceMap:!1,configFile:!1,code:!1,ast:!0,cloneInputAst:!1};if(e.astInfo){if(e.astInfo.type!==config_1.AstType.Babel)throw new Error("ast type is not babel");t=o.transformFromAstSync(e.astInfo.ast,e.sourceCode,s)}else{if(null===e.sourceCode)throw new Error("source.targetCode is null");t=babel7().transform(e.sourceCode,s)}}catch(e){const o=`file: ${r}\n ${e.message}`,t=new Error(o);throw t.code=config_1.BABEL_TRANS_JS_ERR,t}return{sourceCode:e.sourceCode,inputMap:e.inputMap,astInfo:{ast:t.ast,type:config_1.AstType.Babel}}};function default_1(e,r){return{name:"summer-worklet",workerMethods:{worklet:worklet},async transform(e,r,o,{isBabelIgnore:t}){if(r.endsWith(".js")&&!t){const{source:r}=e;if(r.sourceCode.includes('"worklet"')||r.sourceCode.includes("'worklet'")){const t=Date.now(),s=await this.runWorkerMethod("worklet",r,o);return Object.assign(Object.assign({},e),{source:Object.assign(Object.assign({},e.source),s),process:[...e.process,{cost:Date.now()-t,pluginName:"summer-worklet",action:"transform"}]})}return e}return e}}}