import { m as o } from "./index-C-CV5vnh.js";
class s extends Error {
  constructor(t) {
    super(t), this.name = "FrontMatterLoadError";
  }
}
function n(r, t) {
  const e = {
    javascript: {
      parse: () => {
        throw new Error("JavaScript front-matter is not allowed");
      }
    }
  }, a = {
    ...t,
    engines: {
      ...t && "engines" in t ? t.engines : {},
      ...e
    }
  };
  return o(r, a);
}
function f(r) {
  try {
    const { data: t, content: e } = n(r.content);
    if (Object.keys(t).length === 0)
      return { frontMatter: void 0, content: e };
    const a = r.schema.safeParse(t);
    if (!a.success)
      throw new s(`Front matter validation failed: ${JSON.stringify(a.error)}`);
    return { frontMatter: a.data, content: e };
  } catch (t) {
    throw new s(
      `Failed to parse front matter: ${t instanceof Error ? t.message : String(t)}`
    );
  }
}
function u(r, t) {
  try {
    if (t?.customYamlParser) {
      const a = n(r, {
        engines: {
          yaml: {
            parse: t.customYamlParser
          }
        }
      });
      return { data: a.data, content: a.content };
    }
    const e = n(r);
    return { data: e.data, content: e.content };
  } catch (e) {
    throw new s(
      `Failed to parse front matter: ${e instanceof Error ? e.message : String(e)}`
    );
  }
}
function m(r) {
  if (!r || !c(r))
    return r;
  const { content: t } = n(r);
  return t;
}
function c(r) {
  return r.trim().startsWith("---");
}
export {
  s as F,
  u as a,
  c as h,
  f as p,
  m as s
};
//# sourceMappingURL=parse-front-matter-CXai4UYs.js.map
