import { createOpenMediaManagerFn } from "./create-open-media-manager-fn.js";
import { MediaManagerMediaType } from "./types.js";
const createImageFileSelectionFn = (services) => {
  const openMediaManager = createOpenMediaManagerFn();
  if (!openMediaManager) {
    return void 0;
  }
  return (updateEntity, options, onCancel) => openMediaManager({
    mediaType: MediaManagerMediaType.IMAGE,
    appDefId: services.wixInstance().appDefId,
    isMultiSelect: options.multiple
  }).then((items) => {
    const imageData = items.map(
      ({
        title,
        uri,
        height,
        width
      }) => ({
        id: uri,
        height,
        width,
        original_file_name: title,
        file_name: uri
      })
    );
    updateEntity({
      data: imageData,
      // @ts-expect-error
      index: options.index
    });
  }).catch(onCancel);
};
export {
  createImageFileSelectionFn
};
//# sourceMappingURL=create-image-file-selection-fn.js.map
