'use strict';
'use client';
import { c } from 'react/compiler-runtime';
import { jsx, jsxs } from 'react/jsx-runtime';
import { Select, SelectTrigger, SelectValue, SelectContent, SelectItem, SelectGroup } from '../../../fd-component-toolbox/select/Select.js';
import { useState } from 'react';
import { oDataOperators } from '../../../../fd-toolbox/enums/enums.js';
import { setFlagsEnumValue } from './EditResourceFlagsEnumField.funcs.js';
import { useElementId } from '../../../../fd-toolbox/hooks/use-element-id.js';

var __defProp = Object.defineProperty;
var __name = (target, value) => __defProp(target, "name", {
  value,
  configurable: true
});
function EditResourceFlagsEnumField(t0) {
  const $ = c(17);
  const {
    uiPropertyMeta,
    form,
    disabled,
    readOnly,
    skipAnimationOnce,
    onChange,
    propertyMeta,
    parentContextName
  } = t0;
  const [isOpen, setIsOpen] = useState(false);
  const editResourceFlagsEnumSelectId = useElementId(EditResourceFlagsEnumField.displayName, parentContextName);
  let t1;
  if ($[0] !== disabled || $[1] !== editResourceFlagsEnumSelectId || $[2] !== form || $[3] !== isOpen || $[4] !== onChange || $[5] !== propertyMeta.displayName || $[6] !== propertyMeta.enumerationDisplayName || $[7] !== propertyMeta.enumerationValues || $[8] !== propertyMeta.required || $[9] !== readOnly || $[10] !== skipAnimationOnce || $[11] !== uiPropertyMeta.name) {
    let t2;
    if ($[13] !== form.setValue || $[14] !== onChange || $[15] !== uiPropertyMeta.name) {
      t2 = value => setFlagsEnumValue(uiPropertyMeta.name, form.setValue, value ?? void 0, onChange);
      $[13] = form.setValue;
      $[14] = onChange;
      $[15] = uiPropertyMeta.name;
      $[16] = t2;
    } else {
      t2 = $[16];
    }
    t1 = jsx("div", {
      className: "w-full",
      children: jsxs(Select, {
        value: form.getValues(uiPropertyMeta.name) ?? "0",
        onValueChange: t2,
        disabled,
        open: isOpen && !readOnly,
        onOpenChange: setIsOpen,
        children: [jsx(SelectTrigger, {
          id: editResourceFlagsEnumSelectId,
          skipAnimationOnce,
          label: propertyMeta.displayName,
          shouldAnimate: true,
          children: jsx(SelectValue, {})
        }), jsxs(SelectContent, {
          children: [!propertyMeta.required && jsx(SelectItem, {
            value: oDataOperators.empty
          }), jsx(SelectGroup, {
            children: propertyMeta.enumerationValues?.map((val, index) => jsx(SelectItem, {
              value: val.toString(),
              children: propertyMeta.enumerationDisplayName[index]
            }, val))
          })]
        })]
      })
    });
    $[0] = disabled;
    $[1] = editResourceFlagsEnumSelectId;
    $[2] = form;
    $[3] = isOpen;
    $[4] = onChange;
    $[5] = propertyMeta.displayName;
    $[6] = propertyMeta.enumerationDisplayName;
    $[7] = propertyMeta.enumerationValues;
    $[8] = propertyMeta.required;
    $[9] = readOnly;
    $[10] = skipAnimationOnce;
    $[11] = uiPropertyMeta.name;
    $[12] = t1;
  } else {
    t1 = $[12];
  }
  return t1;
}
__name(EditResourceFlagsEnumField, "EditResourceFlagsEnumField");
EditResourceFlagsEnumField.displayName = "EditResourceFlagsEnumField";

export { EditResourceFlagsEnumField };
