'use strict';
'use client';
import { c } from 'react/compiler-runtime';
import { jsx } from 'react/jsx-runtime';
import { FileUpload } from '../../components/file-upload/FileUpload.js';
import { useAsyncEffect } from '../../../../fd-toolbox/hooks/use-async-effect.js';
import { onInitBlobList } from './EditResourceBlobField.funcs.js';
import { fileUploadTypes } from '../../../../fd-toolbox/enums/enums.js';

var __defProp = Object.defineProperty;
var __name = (target, value) => __defProp(target, "name", {
  value,
  configurable: true
});
function EditResourceBlobField(t0) {
  const $ = c(12);
  const {
    label,
    form,
    relatedResourceId,
    propertyMeta,
    isNew
  } = t0;
  let t1;
  if ($[0] !== form.setValue || $[1] !== propertyMeta || $[2] !== relatedResourceId) {
    t1 = async () => {
      await onInitBlobList(propertyMeta, relatedResourceId, form?.setValue);
    };
    $[0] = form.setValue;
    $[1] = propertyMeta;
    $[2] = relatedResourceId;
    $[3] = t1;
  } else {
    t1 = $[3];
  }
  let t2;
  if ($[4] !== relatedResourceId) {
    t2 = [relatedResourceId];
    $[4] = relatedResourceId;
    $[5] = t2;
  } else {
    t2 = $[5];
  }
  useAsyncEffect(t1, t2);
  let t3;
  if ($[6] !== form || $[7] !== isNew || $[8] !== label || $[9] !== propertyMeta || $[10] !== relatedResourceId) {
    t3 = jsx("div", {
      className: "relative",
      children: jsx(FileUpload, {
        label,
        allowMultiple: propertyMeta.fileUploadType === fileUploadTypes.multiple,
        value: form.getValues(propertyMeta.name),
        isNew,
        relatedResourceId,
        propertyMeta
      })
    });
    $[6] = form;
    $[7] = isNew;
    $[8] = label;
    $[9] = propertyMeta;
    $[10] = relatedResourceId;
    $[11] = t3;
  } else {
    t3 = $[11];
  }
  return t3;
}
__name(EditResourceBlobField, "EditResourceBlobField");

export { EditResourceBlobField };
