"use strict";
var __create = Object.create;
var __defProp = Object.defineProperty;
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
var __getOwnPropNames = Object.getOwnPropertyNames;
var __getProtoOf = Object.getPrototypeOf;
var __hasOwnProp = Object.prototype.hasOwnProperty;
var __export = (target, all) => {
  for (var name in all)
    __defProp(target, name, { get: all[name], enumerable: true });
};
var __copyProps = (to, from, except, desc) => {
  if (from && typeof from === "object" || typeof from === "function") {
    for (let key of __getOwnPropNames(from))
      if (!__hasOwnProp.call(to, key) && key !== except)
        __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
  }
  return to;
};
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
  // If the importer is in node compatibility mode or this is not an ESM
  // file that has been converted to a CommonJS file using a Babel-
  // compatible transform (i.e. "__esModule" has not been set), then set
  // "default" to the CommonJS "module.exports" for node compatibility.
  isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
  mod
));
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
var locale_resource_provider_exports = {};
__export(locale_resource_provider_exports, {
  LocaleResourceProvider: () => LocaleResourceProvider,
  default: () => locale_resource_provider_default
});
module.exports = __toCommonJS(locale_resource_provider_exports);
var import_react = __toESM(require("react"));
var import_wix_rich_content_common = require("./../../wix-rich-content-common/index.js");
function LocaleResourceProvider({
  locale,
  children,
  fallback
}) {
  const [currentLocaleResource, setLocaleResource] = (0, import_react.useState)(null);
  (0, import_react.useEffect)(() => {
    const handleLocaleResource = async () => {
      const localeResource = await (0, import_wix_rich_content_common.fetchEditorTranslations)(locale);
      if (localeResource) {
        setLocaleResource(localeResource);
      }
    };
    handleLocaleResource();
  }, []);
  if (!currentLocaleResource) {
    return fallback;
  }
  return /* @__PURE__ */ import_react.default.createElement(
    import_wix_rich_content_common.RicosTranslate,
    {
      locale: currentLocaleResource.locale,
      localeResource: currentLocaleResource.localeResource ?? {}
    },
    children(currentLocaleResource.locale)
  );
}
var locale_resource_provider_default = LocaleResourceProvider;
//# sourceMappingURL=locale-resource-provider.js.map
