import { H as HttpService } from './httpService-7986aeed.js';
import { d as createStore } from './auth.store-dba2c2da.js';

const { state, reset } = createStore({
  mediaUploading: false,
});
const mediaStore = { state, reset };

class MediaService {
  constructor() { }
  static getInstance() {
    if (!MediaService.instance) {
      MediaService.instance = new MediaService();
    }
    return MediaService.instance;
  }
  async uploadImage(files) {
    let formData = new FormData();
    for (let i = 0; i < files.length; i++) {
      formData.append("uploads[]", files[i], files[i].name);
    }
    mediaStore.state.mediaUploading = true;
    let result;
    try {
      result = await HttpService.http.post(`api/v1/MediaItems/Upload`, formData);
      if (result) {
        mediaStore.state.mediaUploading = false;
      }
    }
    catch (e) {
      mediaStore.state.mediaUploading = false;
    }
    return result;
  }
}

export { MediaService as M, mediaStore as m };
