"use strict";function _interopDefault(e){return e&&"object"==typeof e&&"default"in e?e.default:e}var syntaxJsx=_interopDefault(require("@babel/plugin-syntax-jsx"));const autoImportGetCurrentInstance=(e,t)=>{const n=t.get("body").filter(e=>e.isImportDeclaration()).map(e=>e.node);const i=n.filter(e=>"@vue/composition-api"===e.source.value);const o=i.some(t=>t.specifiers.some(t=>e.isImportSpecifier(t)&&"getCurrentInstance"===t.local.name));if(!o){const n=e.importSpecifier(e.identifier("getCurrentInstance"),e.identifier("getCurrentInstance"));i.length>0?i[0].specifiers.push(n):t.unshiftContainer("body",e.importDeclaration([n],e.stringLiteral("@vue/composition-api")))}},injectInstanceId="__currentInstance";var index=({types:t})=>({inherits:syntaxJsx,visitor:{Program(e){e.traverse({"ObjectMethod|ObjectProperty"(n){if("setup"===n.node.key.name){let i=!1;n.traverse({JSXAttribute(o){const r=o.get("name");["v-on","on-input","on-change","model"].includes(r.node.name)&&o.traverse({MemberExpression(o){const r=o.get("object"),s=o.get("property");t.isThisExpression(r)&&t.isIdentifier(s)&&["$","_"].includes(s.node.name[0])&&(autoImportGetCurrentInstance(t,e),i||(n.node.value.body.body.unshift(t.variableDeclaration("const",[t.variableDeclarator(t.identifier(injectInstanceId),t.callExpression(t.identifier("getCurrentInstance"),[]))])),i=!0),r.replaceWith(t.identifier(injectInstanceId)))}})}})}}})}}});module.exports=index;
