/*
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 pdf_exports = {};
__export(pdf_exports, {
  printToPdf: () => printToPdf
});
module.exports = __toCommonJS(pdf_exports);
var import_obsidian = require('obsidian');
var import_html_element = require('../html-element.cjs');
const ELECTRON_PRINT_TO_PDF_CHANNEL = "print-to-pdf";
async function printToPdf(el, options) {
  if (import_obsidian.Platform.isMobile) {
    throw new Error("Printing to PDF is not supported on mobile devices.");
  }
  const printDiv = activeDocument.body.createDiv("print");
  printDiv.appendChild(el);
  await (0, import_html_element.ensureLoaded)(printDiv);
  const DEFAULT_SCALE_FACTOR = 100;
  const DEFAULT_OPTIONS = {
    filepath: "Untitled.pdf",
    includeName: false,
    landscape: false,
    marginsType: 0,
    open: true,
    pageSize: "A4",
    scale: 1,
    scaleFactor: DEFAULT_SCALE_FACTOR
  };
  const fullOptions = { ...DEFAULT_OPTIONS, ...options };
  try {
    await new Promise((resolve) => {
      activeWindow.electron.ipcRenderer.once(ELECTRON_PRINT_TO_PDF_CHANNEL, resolve);
      activeWindow.electron.ipcRenderer.send(ELECTRON_PRINT_TO_PDF_CHANNEL, fullOptions);
    });
  } finally {
    printDiv.remove();
  }
}
// Annotate the CommonJS export names for ESM import in node:
0 && (module.exports = {
  printToPdf
});
//# sourceMappingURL=data:application/json;base64,ewogICJ2ZXJzaW9uIjogMywKICAic291cmNlcyI6IFsiLi4vLi4vLi4vLi4vc3JjL29ic2lkaWFuL3BkZi50cyJdLAogICJzb3VyY2VzQ29udGVudCI6IFsiLyoqXG4gKiBAZmlsZVxuICpcbiAqIENvbnRhaW5zIHV0aWxpdHkgZnVuY3Rpb25zIGZvciBwcmludGluZyB0byBQREYuXG4gKi9cblxuaW1wb3J0IHsgUGxhdGZvcm0gfSBmcm9tICdvYnNpZGlhbic7XG5cbmltcG9ydCB7IGVuc3VyZUxvYWRlZCB9IGZyb20gJy4uL2h0bWwtZWxlbWVudC50cyc7XG5cbmludGVyZmFjZSBQcmludFRvUGRmT3B0aW9ucyB7XG4gIHJlYWRvbmx5IGZpbGVwYXRoOiBzdHJpbmc7XG4gIHJlYWRvbmx5IGluY2x1ZGVOYW1lOiBib29sZWFuO1xuICByZWFkb25seSBsYW5kc2NhcGU6IGJvb2xlYW47XG4gIHJlYWRvbmx5IG1hcmdpbnNUeXBlOiBudW1iZXI7XG4gIHJlYWRvbmx5IG9wZW46IGJvb2xlYW47XG4gIHJlYWRvbmx5IHBhZ2VTaXplOiBzdHJpbmc7XG4gIHJlYWRvbmx5IHNjYWxlOiBudW1iZXI7XG4gIHJlYWRvbmx5IHNjYWxlRmFjdG9yOiBudW1iZXI7XG59XG5cbmNvbnN0IEVMRUNUUk9OX1BSSU5UX1RPX1BERl9DSEFOTkVMID0gJ3ByaW50LXRvLXBkZic7XG5cbi8qKlxuICogUHJpbnQgdGhlIGdp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