import{r as i,i as t,h as s,H as e,e as o}from"./p-ee1e0eb4.js";import{M as p}from"./p-1adc98f6.js";import"./p-b06e2bef.js";import"./p-2f569553.js";import"./p-ff7a8a71.js";import"./p-871106e0.js";import"./p-add30d46.js";import"./p-d68092b7.js";import"./p-bd90903e.js";import"./p-7dae0f0e.js";import"./p-5d409601.js";const a=class{constructor(s){i(this,s),this.fileUploaded=t(this,"fileUploaded",7),this.uploadImageLoading=!1}componentDidLoad(){}async uploadImage(i){this.uploadImageLoading=!0;var t=i.target.files;let s=await p.getInstance().uploadImage(t);s.Succeeded?(console.log(s),this.uploadImageLoading=!1,this.uploadedImage=s.Data.length>0?s.Data[0].FullImageUrl:"",this.value=this.uploadedImage,this.fileUploaded.emit(this.uploadedImage)):(this.uploadImageLoading=!1,this.errorMessage="There is an error while uploading an image.")}selectFile(){this.el.shadowRoot.querySelector("#fileInput").click()}render(){return s(e,null,this.uploadedImage?s("ion-item",{class:"ion-padding",lines:"none"},s("img",{class:"uploaded-image",src:this.uploadedImage})):"",s("ion-item",{lines:"none"},s("input",{type:"file",id:"fileInput",onChange:i=>this.uploadImage(i),style:{display:"none"},accept:"image/*,application/pdf,application/msword,application/vnd.ms-excel,application/vnd.ms-powerpoint,text/plain"}),this.uploadImageLoading?s("ion-spinner",{color:"primary"}):"",s("ion-button",{slot:"start",onClick:()=>this.selectFile()},s("ion-icon",{name:"add"}),"Upload Image")))}get el(){return o(this)}};a.style="";export{a as sparkle_file_upload}