/*
THIS IS A GENERATED/BUNDLED FILE BY ESBUILD
if you want to view the source, please visit the github repository of this plugin
*/

(function initCjs() {
  // eslint-disable-next-line obsidianmd/no-global-this -- Actively use globalThis.
  const globalThisRecord = globalThis;
  globalThisRecord['__name'] ??= name;
  const originalRequire = require;
  if (originalRequire && !originalRequire.__isPatched) {
    // eslint-disable-next-line no-global-assign, no-implicit-globals -- We need to patch the `require()` function.
    require = Object.assign(
      (id) => requirePatched(id),
      originalRequire,
      {
        __isPatched: true
      }
    );
  }

  const newFuncs = {
    __extractDefault() {
      return extractDefault;
    },
    process() {
      const browserProcess = {
        browser: true,
        cwd() {
          return '/';
        },
        env: {},
        platform: 'android'
      };
      return browserProcess;
    }
  };

  for (const key of Object.keys(newFuncs)) {
    globalThisRecord[key] ??= newFuncs[key]?.();
  }

  function name(obj) {
    return obj;
  }

  function extractDefault(module) {
    return module && module.__esModule && 'default' in module ? module.default : module;
  }

  const OBSIDIAN_BUILT_IN_MODULE_NAMES = [
  'obsidian',
  '@codemirror/autocomplete',
  '@codemirror/collab',
  '@codemirror/commands',
  '@codemirror/language',
  '@codemirror/lint',
  '@codemirror/search',
  '@codemirror/state',
  '@codemirror/text',
  '@codemirror/view',
  '@lezer/common',
  '@lezer/lr',
  '@lezer/highlight'];


  const DEPRECATED_OBSIDIAN_BUILT_IN_MODULE_NAMES = [
  '@codemirror/closebrackets',
  '@codemirror/comment',
  '@codemirror/fold',
  '@codemirror/gutter',
  '@codemirror/highlight',
  '@codemirror/history',
  '@codemirror/matchbrackets',
  '@codemirror/panel',
  '@codemirror/rangeset',
  '@codemirror/rectangular-selection',
  '@codemirror/stream-parser',
  '@codemirror/tooltip'];


  function requirePatched(id) {
    if (OBSIDIAN_BUILT_IN_MODULE_NAMES.includes(id) || DEPRECATED_OBSIDIAN_BUILT_IN_MODULE_NAMES.includes(id)) {
      return originalRequire?.(id);
    }

    // eslint-disable-next-line @typescript-eslint/no-deprecated, obsidianmd/no-global-this  -- Need access to app. Actively use globalThis.
    if (globalThis.app.isMobile) {
      if (id === 'process' || id === 'node:process') {
        // eslint-disable-next-line no-console -- Valid usage.
        console.debug(`The most likely you can safely ignore this error. Module not found: ${id}. Fake process object is returned instead.`);
        // eslint-disable-next-line obsidianmd/no-global-this -- Actively use globalThis.
        return globalThis.process;
      }
    } else {
      const module = originalRequire?.(id);
      if (module) {
        return extractDefault(module);
      }
    }

    // eslint-disable-next-line no-console -- Valid usage.
    console.debug(`The most likely you can safely ignore this error. Module not found: ${id}. Empty object is returned instead.`);
    return {};
  }
})();

"use strict";
var __defProp = Object.defineProperty;
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
var __getOwnPropNames = Object.getOwnPropertyNames;
var __hasOwnProp = Object.prototype.hasOwnProperty;
var __export = (target, all) => {
  for (var name in all)
    __defProp(target, name, { get: all[name], enumerable: true });
};
var __copyProps = (to, from, except, desc) => {
  if (from && typeof from === "object" || typeof from === "function") {
    for (let key of __getOwnPropNames(from))
      if (!__hasOwnProp.call(to, key) && key !== except)
        __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
  }
  return to;
};
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
var npm_run_exports = {};
__export(npm_run_exports, {
  npmRun: () => npmRun,
  npmRunOptional: () => npmRunOptional
});
module.exports = __toCommonJS(npm_run_exports);
var import_debug = require('../debug.cjs');
var import_npm = require('./npm.cjs');
var import_root = require('./root.cjs');
async function npmRun(command) {
  const packageJson = await (0, import_npm.readPackageJson)();
  const isKnownCommand = Object.keys(packageJson.scripts ?? {}).includes(command);
  if (isKnownCommand) {
    await (0, import_root.execFromRoot)(["npm", "run", command]);
  } else {
    throw new Error(`Command ${command} is not defined in the package.json`);
  }
}
async function npmRunOptional(command) {
  const packageJson = await (0, import_npm.readPackageJson)();
  const isKnownCommand = Object.keys(packageJson.scripts ?? {}).includes(command);
  if (isKnownCommand) {
    await (0, import_root.execFromRoot)(["npm", "run", command]);
    return true;
  }
  (0, import_debug.getLibDebugger)("npmRunOptional")(`Command ${command} is not defined in the package.json, skipping`);
  return false;
}
// Annotate the CommonJS export names for ESM import in node:
0 && (module.exports = {
  npmRun,
  npmRunOptional
});
//# sourceMappingURL=data:application/json;base64,ewogICJ2ZXJzaW9uIjogMywKICAic291cmNlcyI6IFsiLi4vLi4vLi4vLi4vc3JjL3NjcmlwdC11dGlscy9ucG0tcnVuLnRzIl0sCiAgInNvdXJjZXNDb250ZW50IjogWyIvKipcbiAqIEBmaWxlXG4gKlxuICogTlBNIHJ1biB1dGlsaXRpZXMuXG4gKi9cblxuaW1wb3J0IHsgZ2V0TGliRGVidWdnZXIgfSBmcm9tICcuLi9kZWJ1Zy50cyc7XG5pbXBvcnQgeyByZWFkUGFja2FnZUpzb24gfSBmcm9tICcuL25wbS50cyc7XG5pbXBvcnQgeyBleGVjRnJvbVJvb3QgfSBmcm9tICcuL3Jvb3QudHMnO1xuXG4vKipcbiAqIFJ1bnMgYSBjb21tYW5kIHVzaW5nIG5wbSBjaGVja2luZyBpZiB0aGUgY29tbWFuZCBpcyBvdmVycmlkZGVuIGluIHRoZSBwYWNrYWdlLmpzb24uXG4gKlxuICogQHBhcmFtIGNvbW1hbmQgLSBUaGUgY29tbWFuZCB0byBydW4uXG4gKi9cbmV4cG9ydCBhc3luYyBmdW5jdGlvbiBucG1SdW4oY29tbWFuZDogc3RyaW5nKTogUHJvbWlzZTx2b2lkPiB7XG4gIGNvbnN0IHBhY2thZ2VKc29uID0gYXdhaXQgcmVhZFBhY2thZ2VKc29uKCk7XG4gIGNvbnN0IGlzS25vd25Db21tYW5kID0gT2JqZWN0LmtleXMocGFja2FnZUpzb24uc2NyaXB0cyA/PyB7fSkuaW5jbHVkZXMoY29tbWFuZCk7XG4gIGlmIChpc0tub3duQ29tbWFuZCkge1xuICAgIGF3YWl0IGV4ZWNGcm9tUm9vdChbJ25wbScsICdydW4nLCBjb21tYW5kXSk7XG4gIH0gZWxzZSB7XG4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