/*
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 editor_exports = {};
__export(editor_exports, {
  lockEditor: () => lockEditor,
  unlockEditor: () => unlockEditor
});
module.exports = __toCommonJS(editor_exports);
var import_state = require('@codemirror/state');
var import_view = require('@codemirror/view');
const editorCompartmentMap = /* @__PURE__ */ new WeakMap();
function lockEditor(editor) {
  const compartment = ensureCompartment(editor);
  editor.cm.dispatch({
    effects: compartment.reconfigure([
      import_state.EditorState.readOnly.of(true),
      import_view.EditorView.editable.of(false)
    ])
  });
}
function unlockEditor(editor) {
  const compartment = ensureCompartment(editor);
  editor.cm.dispatch({
    effects: compartment.reconfigure([
      import_state.EditorState.readOnly.of(false),
      import_view.EditorView.editable.of(true)
    ])
  });
}
function ensureCompartment(editor) {
  let compartment = editorCompartmentMap.get(editor);
  if (!compartment) {
    compartment = new import_state.Compartment();
    editorCompartmentMap.set(editor, compartment);
  }
  return compartment;
}
// Annotate the CommonJS export names for ESM import in node:
0 && (module.exports = {
  lockEditor,
  unlockEditor
});
//# sourceMappingURL=data:application/json;base64,ewogICJ2ZXJzaW9uIjogMywKICAic291cmNlcyI6IFsiLi4vLi4vLi4vLi4vc3JjL29ic2lkaWFuL2VkaXRvci50cyJdLAogICJzb3VyY2VzQ29udGVudCI6IFsiLyoqXG4gKiBAZmlsZVxuICpcbiAqIFRoaXMgbW9kdWxlIHByb3ZpZGVzIHV0aWxpdHkgZnVuY3Rpb25zIGZvciB3b3JraW5nIHdpdGggbWFya2Rvd24gZWRpdG9ycyBpbiBPYnNpZGlhblxuICovXG5cbmltcG9ydCB0eXBlIHsgRWRpdG9yIH0gZnJvbSAnb2JzaWRpYW4nO1xuXG5pbXBvcnQge1xuICBDb21wYXJ0bWVudCxcbiAgRWRpdG9yU3RhdGVcbn0gZnJvbSAnQGNvZGVtaXJyb3Ivc3RhdGUnO1xuaW1wb3J0IHsgRWRpdG9yVmlldyB9IGZyb20gJ0Bjb2RlbWlycm9yL3ZpZXcnO1xuXG5jb25zdCBlZGl0b3JDb21wYXJ0bWVudE1hcCA9IG5ldyBXZWFrTWFwPEVkaXRvciwgQ29tcGFydG1lbnQ+KCk7XG5cbi8qKlxuICogTG9ja3MgdGhlIGVkaXRvci5cbiAqXG4gKiBAcGFyYW0gZWRpdG9yIC0gVGhlIGVkaXRvciB0byBsb2NrLlxuICovXG5leHBvcnQgZnVuY3Rpb24gbG9ja0VkaXRvcihlZGl0b3I6IEVkaXRvcik6IHZvaWQge1xuICBjb25zdCBjb21wYXJ0bWVudCA9IGVuc3VyZUNvbXBhcnRtZW50KGVkaXRvcik7XG4gIGVkaXRvci5jbS5kaXNwYXRjaCh7XG4gICAgZWZmZWN0czogY29tcGFydG1lbnQucmVjb25maWd1cmUoW1xuICAgICAgRWRpdG9yU3RhdGUucmVhZE9ubHkub2YodHJ1ZSksX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