"use strict";Object.defineProperty(exports, "__esModule", {value: true});





var _chunkPHNH3HILjs = require('./chunk-PHNH3HIL.js');



var _chunkD7ITITQTjs = require('./chunk-D7ITITQT.js');

// src/core/transform.ts
_chunkD7ITITQTjs.init_cjs_shims.call(void 0, );
var transform = (code, id) => {
  const sfc = _chunkPHNH3HILjs.parseSFC.call(void 0, code, id);
  if (!sfc.scriptSetup)
    return;
  sfc.scriptSetup = _chunkPHNH3HILjs.compileScript.call(void 0, sfc, {
    id
  });
  const { script, scriptSetup, source } = sfc;
  const nodes = _chunkPHNH3HILjs.filterMarco.call(void 0, scriptSetup);
  if (nodes.length === 0)
    return;
  else if (nodes.length > 1)
    throw new SyntaxError(`duplicate ${_chunkD7ITITQTjs.DEFINE_OPTIONS_NAME}() call`);
  if (script)
    throw new SyntaxError(`${_chunkD7ITITQTjs.DEFINE_OPTIONS_NAME} cannot be used, with both script and script-setup.`);
  const node = nodes[0];
  const arg = node.arguments[0];
  if (!(node.arguments.length === 1 && arg.type === "ObjectExpression")) {
    throw new SyntaxError(`${_chunkD7ITITQTjs.DEFINE_OPTIONS_NAME}() arguments error`);
  }
  _chunkPHNH3HILjs.checkInvalidScopeReference.call(void 0, arg, _chunkD7ITITQTjs.DEFINE_OPTIONS_NAME, scriptSetup.bindings);
  const argLoc = arg.loc;
  const argText = scriptSetup.loc.source.slice(argLoc.start.index, argLoc.end.index);
  const s = new (0, _chunkPHNH3HILjs.MagicString)(source);
  s.prepend(`<script lang="${scriptSetup.attrs.lang || "js"}">
export default ${argText}<\/script>
`);
  s.remove(scriptSetup.loc.start.offset + node.loc.start.index, scriptSetup.loc.start.offset + node.loc.end.index);
  return {
    code: s.toString(),
    get map() {
      return s.generateMap({
        source: id,
        includeContent: true
      });
    }
  };
};



exports.transform = transform;
//# sourceMappingURL=chunk-FJFVOX24.js.map