"use strict";Object.defineProperty(exports, "__esModule", {value: true});// src/core/utils.ts var _common = require('@vue-macros/common'); function filterMacro(stmts) { return stmts.map((raw) => { let node = raw; if (raw.type === "ExpressionStatement") node = raw.expression; return _common.isCallOf.call(void 0, node, _common.DEFINE_OPTIONS) ? node : void 0; }).filter((node) => !!node); } function hasPropsOrEmits(node) { return node.properties.some( (prop) => (prop.type === "ObjectProperty" || prop.type === "ObjectMethod") && prop.key.type === "Identifier" && (prop.key.name === "props" || prop.key.name === "emits") ); } // src/core/transform.ts var _astwalkerscope = require('ast-walker-scope'); function transformDefineOptions(code, id) { if (!code.includes(_common.DEFINE_OPTIONS)) return; const sfc = _common.parseSFC.call(void 0, code, id); if (!sfc.scriptSetup) return; const { scriptSetup, getSetupAst, getScriptAst } = sfc; const setupOffset = scriptSetup.loc.start.offset; const setupAst = getSetupAst(); const nodes = filterMacro(setupAst.body); if (nodes.length === 0) { return; } else if (nodes.length > 1) throw new SyntaxError(`duplicate ${_common.DEFINE_OPTIONS}() call`); const scriptAst = getScriptAst(); if (scriptAst) checkDefaultExport(scriptAst.body); const setupBindings = getIdentifiers(setupAst.body); const s = new (0, _common.MagicString)(code); const [node] = nodes; const [arg] = node.arguments; if (arg) { const normalScript = _common.addNormalScript.call(void 0, sfc, s); const scriptOffset = normalScript.start(); _common.importHelperFn.call(void 0, s, scriptOffset, "defineComponent", "vue"); s.appendLeft( scriptOffset, ` export default /*#__PURE__*/ ${_common.HELPER_PREFIX}defineComponent(` ); if (arg.type === "ObjectExpression" && hasPropsOrEmits(arg)) throw new SyntaxError( `${_common.DEFINE_OPTIONS}() please use defineProps or defineEmits instead.` ); _common.checkInvalidScopeReference.call(void 0, arg, _common.DEFINE_OPTIONS, setupBindings); s.moveNode(arg, scriptOffset, { offset: setupOffset }); s.remove(setupOffset + node.start, setupOffset + arg.start); s.remove(setupOffset + arg.end, setupOffset + node.end); s.appendRight(scriptOffset, ");"); normalScript.end(); } else { s.removeNode(node, { offset: setupOffset }); } return _common.getTransformResult.call(void 0, s, id); } var checkDefaultExport = (stmts) => { const hasDefaultExport = stmts.some( (node) => node.type === "ExportDefaultDeclaration" ); if (hasDefaultExport) throw new SyntaxError( `${_common.DEFINE_OPTIONS} cannot be used with default export within