import { lS as e, lA as r, lR as o } from "./ant-design-icons-14ab96af.js";
import { useState as s, useEffect as t, createElement as i } from "react";
import { eY as n, eZ as a, e_ as m, e$ as l, f0 as p, f1 as d } from "./index-8935f1b4.js";
import { a as c } from "./rehype-raw-41b6145f.js";
import "./alasql-f59e855e.js";
import "./axios-125479b5.js";
import "./redux-devtools-f8b1cd80.js";
import "./react-router-8d1fc2f1.js";
import "./antd-97b654da.js";
import "react-dom";
import "./dayjs-7fc5ce65.js";
import "./lodash-226cb5b1.js";
import "./fontawesome-89eb6278.js";
import "./dnd-kit-e67c9595.js";
import "./moment-d8baa15a.js";
import "./crypto-js-8020edb5.js";
import "./styled-components-c6abe9a3.js";
import "./numbro-48e81844.js";
import "./papaparse-088c0adc.js";
import "./uuid-82f303b2.js";
import "./supabase-2e4a9112.js";
import "./fetch-6a200310.js";
import "./react-draggable-fda4f1cb.js";
import "./remark-gfm-e9b5dec7.js";
import "./buffer-e20f80c8.js";
import "./rehype-sanitize-deb53e9a.js";
import "./simplebar-react-cab52c82.js";
import "./react-best-gradient-color-picker-812be7ee.js";
import "./ua-parser-js-1d18a3f8.js";
import "./clsx-469c2c43.js";
import "./loglevel-5e7e37fc.js";
import "./codemirror-edf161cb.js";
import "./really-relaxed-json-e5391d6a.js";
import "./immer-c0428a8d.js";
import "./redux-saga-1b0a458d.js";
import "./hotkeys-js-0dddb21a.js";
import "./cnchar-8c3eaa86.js";
import "./react-documents-ae08f8b5.js";
import "./sql-formatter-69e8df59.js";
import "./rc-trigger-9e54e169.js";
import "./react-json-view-364658b4.js";
import "./qrcode-react-e4f7745b.js";
import "./katex-cda5b990.js";
import "./parse5-6476676e.js";
import "./ecogis-maps-10bb29cf.js";
import "./devextreme-28d23085.js";
import "./exceljs-1678d36b.js";
import "./file-saver-es-c18fae8f.js";
const u = [], f = { allowDangerousHtml: true }, j = /^(https?|ircs?|mailto|xmpp)$/i, g = [{ from: "astPlugins", id: "remove-buggy-html-in-markdown-parser" }, { from: "allowDangerousHtml", id: "remove-buggy-html-in-markdown-parser" }, { from: "allowNode", id: "replace-allownode-allowedtypes-and-disallowedtypes", to: "allowElement" }, { from: "allowedTypes", id: "replace-allownode-allowedtypes-and-disallowedtypes", to: "allowedElements" }, { from: "disallowedTypes", id: "replace-allownode-allowedtypes-and-disallowedtypes", to: "disallowedElements" }, { from: "escapeHtml", id: "remove-buggy-html-in-markdown-parser" }, { from: "includeElementIndex", id: "#remove-includeelementindex" }, { from: "includeNodeIndex", id: "change-includenodeindex-to-includeelementindex" }, { from: "linkTarget", id: "remove-linktarget" }, { from: "plugins", id: "change-plugins-to-remarkplugins", to: "remarkPlugins" }, { from: "rawSourcePos", id: "#remove-rawsourcepos" }, { from: "renderers", id: "change-renderers-to-components", to: "components" }, { from: "source", id: "change-source-to-children", to: "children" }, { from: "sourcePos", id: "#remove-sourcepos" }, { from: "transformImageUri", id: "#add-urltransform", to: "urlTransform" }, { from: "transformLinkUri", id: "#add-urltransform", to: "urlTransform" }];
function y(e2) {
  const r2 = x(e2), o2 = k(e2);
  return v(r2.runSync(r2.parse(o2), o2), e2);
}
async function w(e2) {
  const r2 = x(e2), o2 = k(e2);
  return v(await r2.run(r2.parse(o2), o2), e2);
}
function h(r2) {
  const o2 = x(r2), [n2, a2] = s(void 0), [m2, l2] = s(void 0);
  if (t(function() {
    const e2 = k(r2);
    o2.run(o2.parse(e2), e2, function(e3, r3) {
      a2(e3), l2(r3);
    });
  }, [r2.children, r2.rehypePlugins, r2.remarkPlugins, r2.remarkRehypeOptions]), n2)
    throw n2;
  return m2 ? v(m2, r2) : i(e);
}
function x(e2) {
  const r2 = e2.rehypePlugins || u, o2 = e2.remarkPlugins || u, s2 = e2.remarkRehypeOptions ? { ...e2.remarkRehypeOptions, ...f } : f;
  return n().use(a).use(o2).use(m, s2).use(r2);
}
function k(e2) {
  const r2 = e2.children || "", o2 = new l();
  return "string" == typeof r2 && (o2.value = r2), o2;
}
function v(s2, t2) {
  const i2 = t2.allowedElements, n2 = t2.allowElement, a2 = t2.components, m2 = t2.disallowedElements, l2 = t2.skipHtml, u2 = t2.unwrapDisallowed, f2 = t2.urlTransform || b;
  for (const e2 of g)
    ;
  return t2.className && (s2 = { type: "element", tagName: "div", properties: { className: t2.className }, children: "root" === s2.type ? s2.children : [s2] }), c(s2, function(e2, r2, o2) {
    if ("raw" === e2.type && o2 && "number" == typeof r2)
      return l2 ? o2.children.splice(r2, 1) : o2.children[r2] = { type: "text", value: e2.value }, r2;
    if ("element" === e2.type) {
      let r3;
      for (r3 in d)
        if (Object.hasOwn(d, r3) && Object.hasOwn(e2.properties, r3)) {
          const o3 = e2.properties[r3], s3 = d[r3];
          (null === s3 || s3.includes(e2.tagName)) && (e2.properties[r3] = f2(String(o3 || ""), r3, e2));
        }
    }
    if ("element" === e2.type) {
      let s3 = i2 ? !i2.includes(e2.tagName) : !!m2 && m2.includes(e2.tagName);
      if (!s3 && n2 && "number" == typeof r2 && (s3 = !n2(e2, r2, o2)), s3 && o2 && "number" == typeof r2)
        return u2 && e2.children ? o2.children.splice(r2, 1, ...e2.children) : o2.children.splice(r2, 1), r2;
    }
  }), p(s2, { Fragment: e, components: a2, ignoreInvalidStyle: true, jsx: r, jsxs: o, passKeys: true, passNode: true });
}
function b(e2) {
  const r2 = e2.indexOf(":"), o2 = e2.indexOf("?"), s2 = e2.indexOf("#"), t2 = e2.indexOf("/");
  return -1 === r2 || -1 !== t2 && r2 > t2 || -1 !== o2 && r2 > o2 || -1 !== s2 && r2 > s2 || j.test(e2.slice(0, r2)) ? e2 : "";
}
export {
  w as MarkdownAsync,
  h as MarkdownHooks,
  y as default,
  b as defaultUrlTransform
};
