import { Schema } from "effect";
const ZhLocaleItem = Schema.Struct({
  locale: Schema.Literal("zh").annotations({
    description: "\u5FC5\u987B\u4E3A zh"
  }),
  message: Schema.String.annotations({
    description: "\u9488\u5BF9\u8BE5\u8BED\u8A00\u7684 UI \u6587\u672C"
  })
});
const OtherLocaleItem = Schema.Struct({
  locale: Schema.Literal("ja", "en", "ko").annotations({
    description: "\u652F\u6301\u7684\u8BED\u8A00\u7801\uFF0C\u4EC5\u9650 ja\u3001en\u3001ko"
  }),
  message: Schema.String.annotations({
    description: "\u9488\u5BF9\u8BE5\u8BED\u8A00\u7684 UI \u6587\u672C"
  })
});
export const Locale = Schema.Tuple(
  [ZhLocaleItem],
  OtherLocaleItem
).annotations({
  title: "Locale",
  description: "\u672C\u5730\u5316\u6587\u672C\u5217\u8868\uFF0Czh \u5FC5\u987B\u4E3A\u9996\u9879"
});
export function hasVisibleLocaleValue(value) {
  return value?.some((item) => item.message.trim().length > 0) ?? false;
}
export function getLocalizedText(messages, locale) {
  if (!messages) {
    return void 0;
  }
  const localizedMessage = messages.find((message) => message.locale === locale && message.message.trim().length > 0);
  if (localizedMessage) {
    return localizedMessage.message;
  }
  return messages.find((message) => message.message.trim().length > 0)?.message;
}
