import { defineComponent as S, onServerPrefetch as k, useSSRContext as _, openBlock as a, createElementBlock as s, Fragment as d, renderList as H, unref as o, createBlock as p, withCtx as I, createVNode as C, createCommentVNode as L } from "vue";
import { ScalarMarkdown as h } from "@scalar/components";
import { createHash as x, ssrState as B } from "@scalar/oas-utils/helpers";
import { computedAsync as M } from "@vueuse/core";
import N from "../../IntersectionObserver.vue.js";
import { splitMarkdownInSections as P } from "../../../helpers/splitMarkdownInSections.js";
import { getHeadingsFromMarkdown as f } from "../../../helpers/getHeadingsFromMarkdown.js";
import { getLowestHeadingLevel as R } from "../../../helpers/getLowestHeadingLevel.js";
import { sleep as b } from "../../../helpers/sleep.js";
import { useNavState as D } from "../../../hooks/useNavState.js";
import { joinWithSlash as E } from "../../../helpers/joinWithSlash.js";
const F = {
  key: 0,
  class: "introduction-description"
}, Q = /* @__PURE__ */ S({
  __name: "Description",
  props: {
    value: {}
  },
  setup(v) {
    const r = v, i = `components-Content-Introduction-Description-sections${x(r.value)}`, c = M(
      async () => {
        if (!r.value)
          return [];
        const e = await f(r.value), n = R(e);
        return await Promise.all(
          P(r.value, n).map(
            async (t) => ({
              heading: (await f(t))[0],
              content: t
            })
          )
        );
      },
      B[i] ?? []
      // initial state
    ), { getHeadingId: l, hash: g, isIntersectionEnabled: w, pathRouting: u } = D();
    function y(e = "") {
      if (!w.value) return;
      const n = new URL(window.location.href);
      u.value ? n.pathname = E(u.value.basePath, e) : n.hash = e, g.value = e, window.history.replaceState({}, "", n);
    }
    return k(async () => {
      const e = _();
      await b(1), e.payload.data[i] = c.value;
    }), (e, n) => e.value ? (a(), s("div", F, [
      (a(!0), s(d, null, H(o(c), (t, m) => (a(), s(d, { key: m }, [
        t.heading ? (a(), p(N, {
          key: 0,
          id: o(l)(t.heading),
          class: "introduction-description-heading",
          onIntersecting: () => y(o(l)(t.heading))
        }, {
          default: I(() => [
            C(o(h), {
              value: t.content,
              withImages: ""
            }, null, 8, ["value"])
          ]),
          _: 2
        }, 1032, ["id", "onIntersecting"])) : (a(), p(o(h), {
          key: 1,
          value: t.content,
          withImages: ""
        }, null, 8, ["value"]))
      ], 64))), 128))
    ])) : L("", !0);
  }
});
export {
  Q as default
};
