import { jsx as d } from "../../../../../../../external/.pnpm/preact@10.28.2/node_modules/preact/jsx-runtime/dist/jsxRuntime.module.js";
import { useMemo as c } from "../../../../../../../external/.pnpm/preact@10.28.2/node_modules/preact/hooks/dist/hooks.module.js";
import { FormSelect as u } from "../../../../../../internal/FormWrappers/FormSelect.js";
import { useWizardFormContext as f } from "../../../../../../../hooks/form/wizard/WizardFormContext.js";
import p from "../../../../../../../core/Context/preact/useCoreContext.js";
const h = ({ countriesData: o, isFetchingCountries: l, countryDatasetData: r, isFetchingCountryDataset: s }) => {
  const { i18n: m } = p(), { fieldsConfig: n } = f(), a = c(() => {
    const i = new Set(n?.countryCode?.options ?? o?.data?.map(({ countryCode: e }) => e) ?? []);
    return (r?.length ? r : o?.data?.map(({ countryCode: e, countryName: t }) => ({ id: e, name: t })) ?? []).filter(({ id: e }) => !i.size || i.has(e)).sort((e, t) => e.name.localeCompare(t.name));
  }, [o?.data, r, n]);
  return /* @__PURE__ */ d(
    u,
    {
      clearable: !0,
      filterable: !0,
      fieldName: "countryCode",
      label: m.get("payByLink.creation.fields.country.label"),
      items: a,
      readonly: l || s
    }
  );
};
export {
  h as CountryRegionField
};
