import { componentNames } from "#og-image-virtual/component-names.mjs";
import { useRuntimeConfig } from "nitropack/runtime";
import { joinURL } from "ufo";
import { buildOgImageUrl } from "../shared.js";
export function getOgImagePath(_pagePath, _options) {
  const baseURL = useRuntimeConfig().app.baseURL;
  const { defaults } = useOgImageRuntimeConfig();
  const extension = _options?.extension || defaults.extension;
  const isStatic = import.meta.prerender;
  const options = { ..._options, _path: _pagePath };
  const componentName = _options?.component || componentNames?.[0]?.pascalName;
  const component = componentNames?.find((c) => c.pascalName === componentName || c.kebabName === componentName);
  if (component?.hash)
    options._componentHash = component.hash;
  const result = buildOgImageUrl(options, extension, isStatic, defaults);
  return {
    path: joinURL("/", baseURL, result.url),
    hash: result.hash
  };
}
export function useOgImageRuntimeConfig(e) {
  const c = useRuntimeConfig(e);
  return {
    defaults: {},
    ...c["nuxt-og-image"],
    app: {
      baseURL: c.app.baseURL
    }
  };
}
