import{jsx as m,Fragment as c}from"react/jsx-runtime";import{useState as f,memo as d,useCallback as h,useMemo as x}from"react";import{useAtomValue as y}from"jotai";import{SimpleEnums as E}from"./SimpleEnums.js";import{DescriptionEnums as T}from"./DescriptionEnums.js";import{globalOptionsAtom as A}from"../../jotai/store.js";import{useTranslate as B}from"../../hooks/index.js";function C(o){return Array.isArray(o)&&o||Object.entries(o||{}).map(([r,e])=>({value:r,description:e}))}function V({values:o,type:r}){const e=B(),[s,g]=f(!0),{maxDisplayedEnumValues:t}=y(A),l=h(()=>{g(!s)},[s]),p=!Array.isArray(o),n=C(o),a=x(()=>s&&t?n.slice(0,t):n,[n,s,t]);if(!n.length)return null;const i=t?n.length>t:!1,u=t?s?`+${n.length-t} ${e("openapi.actions.more","more")}`:e("openapi.actions.hide","Hide"):"";return m(c,{children:p?m(T,{enums:a,toggle:l,showToggleButton:i,toggleButtonText:u,type:r,translate:e}):m(E,{enums:a,type:r,toggle:l,toggleButtonText:u,showToggleButton:i,translate:e})})}const S=d(V);export{S as EnumValues};
