/**
 * Minified by jsDelivr using Terser v5.39.0.
 * Original file: /npm/@babel/plugin-transform-modules-commonjs@7.27.1/lib/index.js
 *
 * Do NOT use SRI with dynamically generated files! More information: https://www.jsdelivr.com/using-sri-with-dynamic-files
 */
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.default=void 0,Object.defineProperty(exports,"defineCommonJSHook",{enumerable:!0,get:function(){return _hooks.defineCommonJSHook}});var _helperPluginUtils=require("@babel/helper-plugin-utils"),_helperModuleTransforms=require("@babel/helper-module-transforms"),_core=require("@babel/core"),_dynamicImport=require("./dynamic-import.js"),_lazy=require("./lazy.js"),_hooks=require("./hooks.js"),_default=exports.default=(0,_helperPluginUtils.declare)(((e,r)=>{var o,t,s;e.assertVersion(7);const{strictNamespace:n=!1,mjsStrictNamespace:i=n,allowTopLevelThis:a,strict:p,strictMode:l,noInterop:c,importInterop:m,lazy:u=!1,allowCommonJSExports:d=!0,loose:f=!1}=r,h=null!=(o=e.assumption("constantReexports"))?o:f,g=null!=(t=e.assumption("enumerableModuleMeta"))?t:f,y=null!=(s=e.assumption("noIncompleteNsImportDetection"))&&s;if(!("boolean"==typeof u||"function"==typeof u||Array.isArray(u)&&u.every((e=>"string"==typeof e))))throw new Error(".lazy must be a boolean, array of strings, or a function");if("boolean"!=typeof n)throw new Error(".strictNamespace must be a boolean, or undefined");if("boolean"!=typeof i)throw new Error(".mjsStrictNamespace must be a boolean, or undefined");const _=e=>_core.template.expression.ast`
    (function(){
      throw new Error(
        "The CommonJS '" + "${e}" + "' variable is not available in ES6 modules." +
        "Consider setting setting sourceType:script or sourceType:unambiguous in your " +
        "Babel config for this file.");
    })()
  `,b={ReferencedIdentifier(e){const r=e.node.name;if("module"!==r&&"exports"!==r)return;const o=e.scope.getBinding(r);this.scope.getBinding(r)!==o||e.parentPath.isObjectProperty({value:e.node})&&e.parentPath.parentPath.isObjectPattern()||e.parentPath.isAssignmentExpression({left:e.node})||e.isAssignmentExpression({left:e.node})||e.replaceWith(_(r))},UpdateExpression(e){const r=e.get("argument");if(!r.isIdentifier())return;const o=r.node.name;if("module"!==o&&"exports"!==o)return;const t=e.scope.getBinding(o);this.scope.getBinding(o)===t&&e.replaceWith(_core.types.assignmentExpression(e.node.operator[0]+"=",r.node,_(o)))},AssignmentExpression(e){const r=e.get("left");if(r.isIdentifier()){const o=r.node.name;if("module"!==o&&"exports"!==o)return;const t=e.scope.getBinding(o);if(this.scope.getBinding(o)!==t)return;const s=e.get("right");s.replaceWith(_core.types.sequenceExpression([s.node,_(o)]))}else if(r.isPattern()){const o=r.getOuterBindingIdentifiers(),t=Object.keys(o).find((r=>("module"===r||"exports"===r)&&this.scope.getBinding(r)===e.scope.getBinding(r)));if(t){const r=e.get("right");r.replaceWith(_core.types.sequenceExpression([r.node,_(t)]))}}}};return{name:"transform-modules-commonjs",pre(){this.file.set("@babel/plugin-transform-modules-*","commonjs"),u&&(0,_hooks.defineCommonJSHook)(this.file,(0,_lazy.lazyImportsHook)(u))},visitor:{["CallExpression"+(e.types.importExpression?"|ImportExpression":"")](e){if(!this.file.has("@babel/plugin-proposal-dynamic-import"))return;if(e.isCallExpression()&&!_core.types.isImport(e.node.callee))return;let{scope:r}=e;do{r.rename("require")}while(r=r.parent);(0,_dynamicImport.transformDynamicImport)(e,c,this.file)},Program:{exit(e,o){if(!(0,_helperModuleTransforms.isModule)(e))return;e.scope.rename("exports"),e.scope.rename("module"),e.scope.rename("require"),e.scope.rename("__filename"),e.scope.rename("__dirname"),d||e.traverse(b,{scope:e.scope});let t=(0,_helperModuleTransforms.getModuleName)(this.file.opts,r);t&&(t=_core.types.stringLiteral(t));const s=(0,_hooks.makeInvokers)(this.file),{meta:f,headers:_}=(0,_helperModuleTransforms.rewriteModuleStatementsAndPrepareHeader)(e,{exportName:"exports",constantReexports:h,enumerableModuleMeta:g,strict:p,strictMode:l,allowTopLevelThis:a,noInterop:c,importInterop:m,wrapReference:s.wrapReference,getWrapperPayload:s.getWrapperPayload,esNamespaceOnly:"string"==typeof o.filename&&/\.mjs$/.test(o.filename)?i:n,noIncompleteNsImportDetection:y,filename:this.file.opts.filename});for(const[r,o]of f.source){const t=_core.types.callExpression(_core.types.identifier("require"),[_core.types.stringLiteral(r)]);let n;if((0,_helperModuleTransforms.isSideEffectImport)(o)){if(u&&"function"===o.wrap)throw new Error("Assertion failure");n=_core.types.expressionStatement(t)}else{const r=(0,_helperModuleTransforms.wrapInterop)(e,t,o.interop)||t;if(o.wrap){const e=s.buildRequireWrapper(o.name,r,o.wrap,o.referenced);if(!1===e)continue;n=e}null!=n||(n=_core.template.statement.ast`
                var ${o.name} = ${r};
              `)}n.loc=o.loc,_.push(n),_.push(...(0,_helperModuleTransforms.buildNamespaceInitStatements)(f,o,h,s.wrapReference))}(0,_helperModuleTransforms.ensureStatementsHoisted)(_),e.unshiftContainer("body",_),e.get("body").forEach((e=>{_.includes(e.node)&&e.isVariableDeclaration()&&e.scope.registerDeclaration(e)}))}}}}}));
//# sourceMappingURL=/sm/08d881810b95f366efc0c5013899bada6820991b6863797f4d09b6389c08e7fb.map