image-salon-sdk 1.0.63 → 1.0.65
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/image-salon-sdk.js
CHANGED
|
@@ -6738,6 +6738,9 @@ self.addEventListener('message', async (e) => {
|
|
|
6738
6738
|
}
|
|
6739
6739
|
return Ze.getDataUrlFromFile = Te, Ze.getFilefromDataUrl = we, Ze.loadImage = pe, Ze.drawImageInCanvas = de, Ze.drawFileInCanvas = ke, Ze.canvasToFile = He, Ze.getExifOrientation = Ln, Ze.handleMaxWidthOrHeight = mn, Ze.followExifOrientation = gn, Ze.cleanupCanvasMemory = _e, Ze.isAutoOrientationInBrowser = Bt, Ze.approximateBelowMaximumCanvasSizeOfBrowser = Ue, Ze.copyExifWithoutOrientation = e, Ze.getBrowserName = be, Ze.version = "2.0.1", Ze;
|
|
6740
6740
|
});
|
|
6741
|
+
console.log("window", typeof window);
|
|
6742
|
+
typeof window < "u" && console.log("I am here 3597");
|
|
6743
|
+
window.imageCompression = imageCompression;
|
|
6741
6744
|
const Ms = imageCompression;
|
|
6742
6745
|
class Vs extends Xe {
|
|
6743
6746
|
constructor() {
|
|
@@ -21,7 +21,7 @@ self.addEventListener('message', async (e) => {
|
|
|
21
21
|
self.postMessage({ error: e.message + '\\n' + e.stack, id })
|
|
22
22
|
}
|
|
23
23
|
})
|
|
24
|
-
`;let gn;function zn(P,Z){return new Promise((J,E)=>{gn||(gn=function(C){const p=[];return p.push(C),URL.createObjectURL(new Blob(p))}(qn));const o=new Worker(gn);o.addEventListener("message",function(C){if(Z.signal&&Z.signal.aborted)o.terminate();else if(C.data.progress===void 0){if(C.data.error)return E(new Error(C.data.error)),void o.terminate();J(C.data.file),o.terminate()}else Z.onProgress(C.data.progress)}),o.addEventListener("error",E),Z.signal&&Z.signal.addEventListener("abort",()=>{E(Z.signal.reason),o.terminate()}),o.postMessage({file:P,imageCompressionLibUrl:Z.libURL,options:{...Z,onProgress:void 0,signal:void 0}})})}function Ke(P,Z){return new Promise(function(J,E){let o,a,C,p,I,U;if(o={...Z},C=0,{onProgress:p}=o,o.maxSizeMB=o.maxSizeMB||Number.POSITIVE_INFINITY,I=typeof o.useWebWorker!="boolean"||o.useWebWorker,delete o.useWebWorker,o.onProgress=m=>{C=m,typeof p=="function"&&p(C)},!(P instanceof Blob||P instanceof ie))return E(new Error("The file given is not an instance of Blob or File"));if(!/^image/.test(P.type))return E(new Error("The file given is not an image"));if(U=typeof WorkerGlobalScope<"u"&&self instanceof WorkerGlobalScope,!I||typeof Worker!="function"||U)return Ln(P,o).then((function(m){try{return a=m,l.call(this)}catch(A){return E(A)}}).bind(this),E);var c=(function(){try{return l.call(this)}catch(m){return E(m)}}).bind(this),h=function(m){try{return Ln(P,o).then(function(A){try{return a=A,c()}catch(O){return E(O)}},E)}catch(A){return E(A)}};try{return o.libURL=o.libURL||"https://cdn.jsdelivr.net/npm/browser-image-compression@2.0.1/dist/browser-image-compression.js",zn(P,o).then(function(m){try{return a=m,c()}catch{return h()}},h)}catch{h()}function l(){try{a.name=P.name,a.lastModified=P.lastModified}catch{}try{o.preserveExif&&P.type==="image/jpeg"&&(!o.fileType||o.fileType&&o.fileType===P.type)&&(a=e(P,a))}catch{}return J(a)}})}return Ke.getDataUrlFromFile=Ue,Ke.getFilefromDataUrl=we,Ke.loadImage=me,Ke.drawImageInCanvas=de,Ke.drawFileInCanvas=Fe,Ke.canvasToFile=Ze,Ke.getExifOrientation=jn,Ke.handleMaxWidthOrHeight=Nn,Ke.followExifOrientation=Tn,Ke.cleanupCanvasMemory=Re,Ke.isAutoOrientationInBrowser=jt,Ke.approximateBelowMaximumCanvasSizeOfBrowser=Se,Ke.copyExifWithoutOrientation=e,Ke.getBrowserName=be,Ke.version="2.0.1",Ke});const Ss=imageCompression;class Rs extends Je{constructor(){super("com.hamropatro.grpc.cms.ImageUploadRequest",[{no:1,name:"mime_type",kind:"scalar",T:9}])}create(e){const t=globalThis.Object.create(this.messagePrototype);return t.mimeType="",e!==void 0&&$e(this,t,e),t}internalBinaryRead(e,t,n,i){let s=i??this.create(),d=e.pos+t;for(;e.pos<d;){let[u,g]=e.tag();switch(u){case 1:s.mimeType=e.string();break;default:let v=n.readUnknownField;if(v==="throw")throw new globalThis.Error(`Unknown field ${u} (wire type ${g}) for ${this.typeName}`);let V=e.skip(g);v!==!1&&(v===!0?ue.onRead:v)(this.typeName,s,u,g,V)}}return s}internalBinaryWrite(e,t,n){e.mimeType!==""&&t.tag(1,te.LengthDelimited).string(e.mimeType);let i=n.writeUnknownFields;return i!==!1&&(i==!0?ue.onWrite:i)(this.typeName,e,t),t}}const dr=new Rs;class Ds extends Je{constructor(){super("com.hamropatro.grpc.cms.ImageUploadResponse",[{no:1,name:"key",kind:"scalar",T:9},{no:2,name:"url",kind:"scalar",T:9}])}create(e){const t=globalThis.Object.create(this.messagePrototype);return t.key="",t.url="",e!==void 0&&$e(this,t,e),t}internalBinaryRead(e,t,n,i){let s=i??this.create(),d=e.pos+t;for(;e.pos<d;){let[u,g]=e.tag();switch(u){case 1:s.key=e.string();break;case 2:s.url=e.string();break;default:let v=n.readUnknownField;if(v==="throw")throw new globalThis.Error(`Unknown field ${u} (wire type ${g}) for ${this.typeName}`);let V=e.skip(g);v!==!1&&(v===!0?ue.onRead:v)(this.typeName,s,u,g,V)}}return s}internalBinaryWrite(e,t,n){e.key!==""&&t.tag(1,te.LengthDelimited).string(e.key),e.url!==""&&t.tag(2,te.LengthDelimited).string(e.url);let i=n.writeUnknownFields;return i!==!1&&(i==!0?ue.onWrite:i)(this.typeName,e,t),t}}const ti=new Ds,hr=new er("com.hamropatro.grpc.cms.ImageUploadService",[{name:"Upload",options:{},I:dr,O:ti},{name:"UploadUserImage",options:{},I:dr,O:ti}]);class Ms{constructor(e){Be(this,"typeName",hr.typeName);Be(this,"methods",hr.methods);Be(this,"options",hr.options);this._transport=e}upload(e,t){const n=this.methods[0],i=this._transport.mergeOptions(t);return dt("unary",this._transport,n,i,e)}uploadUserImage(e,t){const n=this.methods[1],i=this._transport.mergeOptions(t);return dt("unary",this._transport,n,i,e)}}const Vs=async(r,e,t=!0)=>{var d;const n=(d=window.ImageSalonSDK)==null?void 0:d.grpcConfig,i=new Ms(n),s=dr.create();try{return s.mimeType=r,t?await i.upload(s,e):await i.uploadUserImage(s,e)}catch(u){throw u}},ur=async(r,e,t,n=!0)=>{try{const i=Hs(r,e),d=(await Vs(e==null?void 0:e.type,t,n)).response.url;return await fetch(d,{method:"PUT",headers:{"Content-Type":e==null?void 0:e.type,"x-amz-acl":"public-read"},body:i}),d==null?void 0:d.split("?")[0]}catch(i){throw i}},Hs=(r,e)=>{const t=e.type.split("/")[0];let n="";t==="video"?n=r==null?void 0:r.replace(/^data:video\/\w+;base64,/,""):t==="image"?n=r==null?void 0:r.replace(/^data:image\/\w+;base64,/,""):t==="audio"&&(n=r==null?void 0:r.replace(/^data:audio\/\w+;base64,/,""));const i=atob(n),s=new Uint8Array(i.length);for(let d=0;d<i.length;d++)s[d]=i.charCodeAt(d);return s};async function ni(r){const e={maxSizeMB:2,useWebWorker:!0,libURL:"/workers/browser-image-compression.js",alwaysKeepResolution:!0};try{return await Ss(r,e)}catch(t){throw t}}class ri{constructor(e){ce(this,Dt);ce(this,He);ce(this,We);ce(this,xt);ce(this,Oe,[]);ce(this,ze,[]);ce(this,yt);ce(this,ot);ce(this,Gt);ce(this,Mt);ce(this,vt,[]);ce(this,bt);ce(this,Vt);ce(this,on);ce(this,fr);ce(this,Ht);ce(this,Wt);ce(this,Ut);ce(this,Jt);ce(this,At);ce(this,kt);ce(this,Pt);ce(this,$t);ce(this,_t);ce(this,an);ce(this,vn);ce(this,Ge);ce(this,Bt);ce(this,An,!1);ce(this,$n);ce(this,kn);ce(this,It);ce(this,ln);ce(this,Zt);ce(this,cn);ce(this,dn);ce(this,hn);ce(this,un);ce(this,fn);ce(this,In);ce(this,Fn);ce(this,pn);ce(this,Ft);ce(this,mn);ce(this,Zn);G(this,kn,e.isAdmin),G(this,yt,!1),e.handleUpload&&G(this,on,e.handleUpload.bind(this)),G(this,vn,e.accessToken),G(this,cn,e==null?void 0:e.mode),this._grpcOptionInitializer(),this._init(e).then(()=>{G(this,An,!0),e!=null&&e.parentContainerId&&this._renderView(e),this.updateWindowObject({initialized:!0}),this._initializeGrpcConfig(e.mode,e.endPoint)})}async _init(e){try{const{mode:t}=e;this.updateWindowObject({mode:t})}catch{throw Error("Initialization failed")}}_isAdminOptions(e){return e.isAdmin===!0}_renderView(e){var t,n,i,s;return this._isAdminOptions(e)?(G(this,ot,!1),G(this,Gt,!1),G(this,Ht,0),G(this,kt,""),G(this,_t,!1),G(this,cn,e.mode),G(this,Pt,!1),G(this,Zt,""),G(this,Bt,null),this._removeToastContainer(),this._renderAdminView(e)):(G(this,ln,""),G(this,dn,e==null?void 0:e.restrictedFileSize),G(this,hn,e==null?void 0:e.localizedFileRestrictedMessage),G(this,fn,e==null?void 0:e.localizedSuccessMessage),G(this,un,e==null?void 0:e.localizedErrorMessage),G(this,Ft,e==null?void 0:e.imagePreviewWidth),G(this,mn,e==null?void 0:e.imagePreviewHeight),G(this,In,(t=e==null?void 0:e.removeImageConfirm)==null?void 0:t.bind(this)),G(this,Fn,(n=e==null?void 0:e.removeImagePreviewCB)==null?void 0:n.bind(this)),G(this,pn,(i=e==null?void 0:e.getUploadingState)==null?void 0:i.bind(this)),G(this,Zn,(s=e==null?void 0:e.handleUploadFromSource)==null?void 0:s.bind(this)),this._removeUserToast(),this._renderUserView(e))}_renderAdminView(e){if(!F(this,An))return;const{parentContainerId:t}=e;if(e.isAdmin===!0)var{buttonProps:n}=e;G(this,Dt,document.getElementById(t));const i=document.createElement("button");i.className=n!=null&&n.buttonClass?n==null?void 0:n.buttonClass:"browse-image-button",i.addEventListener("focus",()=>{i.blur()});const s=document.createElement("span");s.textContent=n!=null&&n.buttonText?n==null?void 0:n.buttonText:"Browse Files";const d=document.createElement("span");d.innerHTML=n!=null&&n.buttonIcon?n==null?void 0:n.buttonIcon:"",i.type="button",i.append(s,d),n!=null&&n.buttonStyle&&Object.assign(i.style,n==null?void 0:n.buttonStyle),i.addEventListener("click",()=>{this._selectedImageContainer()}),F(this,Dt).appendChild(i)}async _grpcOptionInitializer(){G(this,Ge,await _s(F(this,vn),F(this,cn)))}_selectedImageContainer(){var ne;G(this,Vt,st(`Save (${(ne=F(this,Oe))==null?void 0:ne.length})`,"dialog-btn confirm")),G(this,Wt,le("folder-container")),G(this,Ut,le("folder-list-wrapper")),this._fetchAllFolders();const e=st("Cancel","dialog-btn cancel");st("","dialog-modal-close-btn","",!1,'<svg xmlns="http://www.w3.org/2000/svg" x="0px" y="0px" width="24" height="24" viewBox="0 0 50 50"> <path d="M 9.15625 6.3125 L 6.3125 9.15625 L 22.15625 25 L 6.21875 40.96875 L 9.03125 43.78125 L 25 27.84375 L 40.9375 43.78125 L 43.78125 40.9375 L 27.84375 25 L 43.6875 9.15625 L 40.84375 6.3125 L 25 22.15625 Z"></path> </svg>').addEventListener("click",()=>{Pn.hide(),G(this,Oe,[]),G(this,ze,[])}),G(this,He,le("browse-container"));const n=le();n.style.display="flex",n.style.alignItems="center",n.style.justifyContent="space-between",n.style.padding="10px 20px";const i=En("Folders","folder-title"),s=st("","add-folder-btn");s.append(Gr()),this._createUpdateFolderDialog(s,"create"),n.append(i,s),F(this,Wt).append(n,F(this,Ut));const d=this._renderSearchField(),u=this._createBrowseMoreContainer(),g=this._createBrowseImageMain(),v=le("footer");e.onclick=()=>{Pn.hide(),G(this,ze,[]),G(this,Oe,[])},F(this,Vt).onclick=()=>{F(this,on).call(this),Pn.hide(),G(this,Oe,[]),G(this,ze,[])},v.append(e,F(this,Vt));const V=le("container-right-main");V.append(d,u,g,v),F(this,He).append(F(this,Wt),V),Pn.show({content:F(this,He)})}_renderUserView(e){const{parentContainerId:t,restrictedFileSize:n,imagePreview:i}=e;G(this,Dt,document.getElementById(t)),G(this,It,pe("div","user-view-container"));const s=le("user-view-browse-wrapper","user-view-browse-wrapper"),d=pe("span","","",""),u=this._renderUserViewBrowseButton(),g=pe("p","","margin-block: 0px; font-size:14px");if(g.append(d,u),n){const v=pe("p","","margin-block: 0px; font-size: 13px; color: #777",`Max File size: ${n}MB`);s.append(ar(),g,v)}else s.append(ar(),g);return F(this,It).append(s),i&&this._renderImagePreview(i,"",s,!0),F(this,Dt).appendChild(F(this,It)),F(this,Dt)}_renderImagePreview(e,t,n,i=!1){var me;const s=document.getElementById("user-view-browse-wrapper"),d=s||n;d&&(d.style.display="none");const u=document.getElementById("user-image-preview");u&&u.remove();const g=pe("div","user-image-preview");g.id="user-image-preview";const v=this._renderImageLoadingContainer();g.appendChild(v);const V=pe("img","",`max-width: ${F(this,Ft)?F(this,Ft):230}px;max-height:${F(this,mn)?F(this,mn):250}px;object-fit:cover;`);V.src=e,V.alt=t||"";const ne=this._renderImageErrorContainer();g.appendChild(ne),V.onload=()=>{he.style.display="none",v.style.display="none",v.remove(),ne.style.display="none",ne.remove(),V.style.display="block",he.style.display=i?"flex":"none"},V.onerror=be=>{v.style.display="none",v.remove(),ne.style.display="flex",V.style.display="none",he.style.display="none"};const ie=ne.querySelector("#retry-image-btn");ie==null||ie.addEventListener("click",()=>{v.style.display="flex",ne.style.display="none",he.style.display="none",V.src=e});const he=pe("div","","width: 18px; height: 18px; display:none; cursor:pointer; align-items: center; justify-content: center; padding: 4px; position: absolute; top: -5px; right: -5px; background: #c10007; border-radius: 50%;z-index:1");he.id="remove-preview-btn";const we=or();we.style.fill="#fff",he==null||he.appendChild(we),he.addEventListener("click",()=>{F(this,In).call(this)});const Ue=pe("button","","display:none");Ue.id="image-preview-hidden-btn",Ue.addEventListener("click",be=>{var Se;be.preventDefault(),be.stopPropagation(),(Se=F(this,It))==null||Se.removeChild(g),F(this,Fn).call(this),this._removeUserToast(),d&&(d.style.display="flex")}),g==null||g.append(V,he,Ue),(me=F(this,It))==null||me.append(g)}_renderImageErrorContainer(){const e=pe("div","","display: none; text-align: center;");return e.innerHTML=`
|
|
24
|
+
`;let gn;function zn(P,Z){return new Promise((J,E)=>{gn||(gn=function(C){const p=[];return p.push(C),URL.createObjectURL(new Blob(p))}(qn));const o=new Worker(gn);o.addEventListener("message",function(C){if(Z.signal&&Z.signal.aborted)o.terminate();else if(C.data.progress===void 0){if(C.data.error)return E(new Error(C.data.error)),void o.terminate();J(C.data.file),o.terminate()}else Z.onProgress(C.data.progress)}),o.addEventListener("error",E),Z.signal&&Z.signal.addEventListener("abort",()=>{E(Z.signal.reason),o.terminate()}),o.postMessage({file:P,imageCompressionLibUrl:Z.libURL,options:{...Z,onProgress:void 0,signal:void 0}})})}function Ke(P,Z){return new Promise(function(J,E){let o,a,C,p,I,U;if(o={...Z},C=0,{onProgress:p}=o,o.maxSizeMB=o.maxSizeMB||Number.POSITIVE_INFINITY,I=typeof o.useWebWorker!="boolean"||o.useWebWorker,delete o.useWebWorker,o.onProgress=m=>{C=m,typeof p=="function"&&p(C)},!(P instanceof Blob||P instanceof ie))return E(new Error("The file given is not an instance of Blob or File"));if(!/^image/.test(P.type))return E(new Error("The file given is not an image"));if(U=typeof WorkerGlobalScope<"u"&&self instanceof WorkerGlobalScope,!I||typeof Worker!="function"||U)return Ln(P,o).then((function(m){try{return a=m,l.call(this)}catch(A){return E(A)}}).bind(this),E);var c=(function(){try{return l.call(this)}catch(m){return E(m)}}).bind(this),h=function(m){try{return Ln(P,o).then(function(A){try{return a=A,c()}catch(O){return E(O)}},E)}catch(A){return E(A)}};try{return o.libURL=o.libURL||"https://cdn.jsdelivr.net/npm/browser-image-compression@2.0.1/dist/browser-image-compression.js",zn(P,o).then(function(m){try{return a=m,c()}catch{return h()}},h)}catch{h()}function l(){try{a.name=P.name,a.lastModified=P.lastModified}catch{}try{o.preserveExif&&P.type==="image/jpeg"&&(!o.fileType||o.fileType&&o.fileType===P.type)&&(a=e(P,a))}catch{}return J(a)}})}return Ke.getDataUrlFromFile=Ue,Ke.getFilefromDataUrl=we,Ke.loadImage=me,Ke.drawImageInCanvas=de,Ke.drawFileInCanvas=Fe,Ke.canvasToFile=Ze,Ke.getExifOrientation=jn,Ke.handleMaxWidthOrHeight=Nn,Ke.followExifOrientation=Tn,Ke.cleanupCanvasMemory=Re,Ke.isAutoOrientationInBrowser=jt,Ke.approximateBelowMaximumCanvasSizeOfBrowser=Se,Ke.copyExifWithoutOrientation=e,Ke.getBrowserName=be,Ke.version="2.0.1",Ke}),console.log("window",typeof window),typeof window<"u"&&console.log("I am here 3597"),window.imageCompression=imageCompression;const Ss=imageCompression;class Rs extends Je{constructor(){super("com.hamropatro.grpc.cms.ImageUploadRequest",[{no:1,name:"mime_type",kind:"scalar",T:9}])}create(e){const t=globalThis.Object.create(this.messagePrototype);return t.mimeType="",e!==void 0&&$e(this,t,e),t}internalBinaryRead(e,t,n,i){let s=i??this.create(),d=e.pos+t;for(;e.pos<d;){let[u,g]=e.tag();switch(u){case 1:s.mimeType=e.string();break;default:let v=n.readUnknownField;if(v==="throw")throw new globalThis.Error(`Unknown field ${u} (wire type ${g}) for ${this.typeName}`);let V=e.skip(g);v!==!1&&(v===!0?ue.onRead:v)(this.typeName,s,u,g,V)}}return s}internalBinaryWrite(e,t,n){e.mimeType!==""&&t.tag(1,te.LengthDelimited).string(e.mimeType);let i=n.writeUnknownFields;return i!==!1&&(i==!0?ue.onWrite:i)(this.typeName,e,t),t}}const dr=new Rs;class Ds extends Je{constructor(){super("com.hamropatro.grpc.cms.ImageUploadResponse",[{no:1,name:"key",kind:"scalar",T:9},{no:2,name:"url",kind:"scalar",T:9}])}create(e){const t=globalThis.Object.create(this.messagePrototype);return t.key="",t.url="",e!==void 0&&$e(this,t,e),t}internalBinaryRead(e,t,n,i){let s=i??this.create(),d=e.pos+t;for(;e.pos<d;){let[u,g]=e.tag();switch(u){case 1:s.key=e.string();break;case 2:s.url=e.string();break;default:let v=n.readUnknownField;if(v==="throw")throw new globalThis.Error(`Unknown field ${u} (wire type ${g}) for ${this.typeName}`);let V=e.skip(g);v!==!1&&(v===!0?ue.onRead:v)(this.typeName,s,u,g,V)}}return s}internalBinaryWrite(e,t,n){e.key!==""&&t.tag(1,te.LengthDelimited).string(e.key),e.url!==""&&t.tag(2,te.LengthDelimited).string(e.url);let i=n.writeUnknownFields;return i!==!1&&(i==!0?ue.onWrite:i)(this.typeName,e,t),t}}const ti=new Ds,hr=new er("com.hamropatro.grpc.cms.ImageUploadService",[{name:"Upload",options:{},I:dr,O:ti},{name:"UploadUserImage",options:{},I:dr,O:ti}]);class Ms{constructor(e){Be(this,"typeName",hr.typeName);Be(this,"methods",hr.methods);Be(this,"options",hr.options);this._transport=e}upload(e,t){const n=this.methods[0],i=this._transport.mergeOptions(t);return dt("unary",this._transport,n,i,e)}uploadUserImage(e,t){const n=this.methods[1],i=this._transport.mergeOptions(t);return dt("unary",this._transport,n,i,e)}}const Vs=async(r,e,t=!0)=>{var d;const n=(d=window.ImageSalonSDK)==null?void 0:d.grpcConfig,i=new Ms(n),s=dr.create();try{return s.mimeType=r,t?await i.upload(s,e):await i.uploadUserImage(s,e)}catch(u){throw u}},ur=async(r,e,t,n=!0)=>{try{const i=Hs(r,e),d=(await Vs(e==null?void 0:e.type,t,n)).response.url;return await fetch(d,{method:"PUT",headers:{"Content-Type":e==null?void 0:e.type,"x-amz-acl":"public-read"},body:i}),d==null?void 0:d.split("?")[0]}catch(i){throw i}},Hs=(r,e)=>{const t=e.type.split("/")[0];let n="";t==="video"?n=r==null?void 0:r.replace(/^data:video\/\w+;base64,/,""):t==="image"?n=r==null?void 0:r.replace(/^data:image\/\w+;base64,/,""):t==="audio"&&(n=r==null?void 0:r.replace(/^data:audio\/\w+;base64,/,""));const i=atob(n),s=new Uint8Array(i.length);for(let d=0;d<i.length;d++)s[d]=i.charCodeAt(d);return s};async function ni(r){const e={maxSizeMB:2,useWebWorker:!0,libURL:"/workers/browser-image-compression.js",alwaysKeepResolution:!0};try{return await Ss(r,e)}catch(t){throw t}}class ri{constructor(e){ce(this,Dt);ce(this,He);ce(this,We);ce(this,xt);ce(this,Oe,[]);ce(this,ze,[]);ce(this,yt);ce(this,ot);ce(this,Gt);ce(this,Mt);ce(this,vt,[]);ce(this,bt);ce(this,Vt);ce(this,on);ce(this,fr);ce(this,Ht);ce(this,Wt);ce(this,Ut);ce(this,Jt);ce(this,At);ce(this,kt);ce(this,Pt);ce(this,$t);ce(this,_t);ce(this,an);ce(this,vn);ce(this,Ge);ce(this,Bt);ce(this,An,!1);ce(this,$n);ce(this,kn);ce(this,It);ce(this,ln);ce(this,Zt);ce(this,cn);ce(this,dn);ce(this,hn);ce(this,un);ce(this,fn);ce(this,In);ce(this,Fn);ce(this,pn);ce(this,Ft);ce(this,mn);ce(this,Zn);G(this,kn,e.isAdmin),G(this,yt,!1),e.handleUpload&&G(this,on,e.handleUpload.bind(this)),G(this,vn,e.accessToken),G(this,cn,e==null?void 0:e.mode),this._grpcOptionInitializer(),this._init(e).then(()=>{G(this,An,!0),e!=null&&e.parentContainerId&&this._renderView(e),this.updateWindowObject({initialized:!0}),this._initializeGrpcConfig(e.mode,e.endPoint)})}async _init(e){try{const{mode:t}=e;this.updateWindowObject({mode:t})}catch{throw Error("Initialization failed")}}_isAdminOptions(e){return e.isAdmin===!0}_renderView(e){var t,n,i,s;return this._isAdminOptions(e)?(G(this,ot,!1),G(this,Gt,!1),G(this,Ht,0),G(this,kt,""),G(this,_t,!1),G(this,cn,e.mode),G(this,Pt,!1),G(this,Zt,""),G(this,Bt,null),this._removeToastContainer(),this._renderAdminView(e)):(G(this,ln,""),G(this,dn,e==null?void 0:e.restrictedFileSize),G(this,hn,e==null?void 0:e.localizedFileRestrictedMessage),G(this,fn,e==null?void 0:e.localizedSuccessMessage),G(this,un,e==null?void 0:e.localizedErrorMessage),G(this,Ft,e==null?void 0:e.imagePreviewWidth),G(this,mn,e==null?void 0:e.imagePreviewHeight),G(this,In,(t=e==null?void 0:e.removeImageConfirm)==null?void 0:t.bind(this)),G(this,Fn,(n=e==null?void 0:e.removeImagePreviewCB)==null?void 0:n.bind(this)),G(this,pn,(i=e==null?void 0:e.getUploadingState)==null?void 0:i.bind(this)),G(this,Zn,(s=e==null?void 0:e.handleUploadFromSource)==null?void 0:s.bind(this)),this._removeUserToast(),this._renderUserView(e))}_renderAdminView(e){if(!F(this,An))return;const{parentContainerId:t}=e;if(e.isAdmin===!0)var{buttonProps:n}=e;G(this,Dt,document.getElementById(t));const i=document.createElement("button");i.className=n!=null&&n.buttonClass?n==null?void 0:n.buttonClass:"browse-image-button",i.addEventListener("focus",()=>{i.blur()});const s=document.createElement("span");s.textContent=n!=null&&n.buttonText?n==null?void 0:n.buttonText:"Browse Files";const d=document.createElement("span");d.innerHTML=n!=null&&n.buttonIcon?n==null?void 0:n.buttonIcon:"",i.type="button",i.append(s,d),n!=null&&n.buttonStyle&&Object.assign(i.style,n==null?void 0:n.buttonStyle),i.addEventListener("click",()=>{this._selectedImageContainer()}),F(this,Dt).appendChild(i)}async _grpcOptionInitializer(){G(this,Ge,await _s(F(this,vn),F(this,cn)))}_selectedImageContainer(){var ne;G(this,Vt,st(`Save (${(ne=F(this,Oe))==null?void 0:ne.length})`,"dialog-btn confirm")),G(this,Wt,le("folder-container")),G(this,Ut,le("folder-list-wrapper")),this._fetchAllFolders();const e=st("Cancel","dialog-btn cancel");st("","dialog-modal-close-btn","",!1,'<svg xmlns="http://www.w3.org/2000/svg" x="0px" y="0px" width="24" height="24" viewBox="0 0 50 50"> <path d="M 9.15625 6.3125 L 6.3125 9.15625 L 22.15625 25 L 6.21875 40.96875 L 9.03125 43.78125 L 25 27.84375 L 40.9375 43.78125 L 43.78125 40.9375 L 27.84375 25 L 43.6875 9.15625 L 40.84375 6.3125 L 25 22.15625 Z"></path> </svg>').addEventListener("click",()=>{Pn.hide(),G(this,Oe,[]),G(this,ze,[])}),G(this,He,le("browse-container"));const n=le();n.style.display="flex",n.style.alignItems="center",n.style.justifyContent="space-between",n.style.padding="10px 20px";const i=En("Folders","folder-title"),s=st("","add-folder-btn");s.append(Gr()),this._createUpdateFolderDialog(s,"create"),n.append(i,s),F(this,Wt).append(n,F(this,Ut));const d=this._renderSearchField(),u=this._createBrowseMoreContainer(),g=this._createBrowseImageMain(),v=le("footer");e.onclick=()=>{Pn.hide(),G(this,ze,[]),G(this,Oe,[])},F(this,Vt).onclick=()=>{F(this,on).call(this),Pn.hide(),G(this,Oe,[]),G(this,ze,[])},v.append(e,F(this,Vt));const V=le("container-right-main");V.append(d,u,g,v),F(this,He).append(F(this,Wt),V),Pn.show({content:F(this,He)})}_renderUserView(e){const{parentContainerId:t,restrictedFileSize:n,imagePreview:i}=e;G(this,Dt,document.getElementById(t)),G(this,It,pe("div","user-view-container"));const s=le("user-view-browse-wrapper","user-view-browse-wrapper"),d=pe("span","","",""),u=this._renderUserViewBrowseButton(),g=pe("p","","margin-block: 0px; font-size:14px");if(g.append(d,u),n){const v=pe("p","","margin-block: 0px; font-size: 13px; color: #777",`Max File size: ${n}MB`);s.append(ar(),g,v)}else s.append(ar(),g);return F(this,It).append(s),i&&this._renderImagePreview(i,"",s,!0),F(this,Dt).appendChild(F(this,It)),F(this,Dt)}_renderImagePreview(e,t,n,i=!1){var me;const s=document.getElementById("user-view-browse-wrapper"),d=s||n;d&&(d.style.display="none");const u=document.getElementById("user-image-preview");u&&u.remove();const g=pe("div","user-image-preview");g.id="user-image-preview";const v=this._renderImageLoadingContainer();g.appendChild(v);const V=pe("img","",`max-width: ${F(this,Ft)?F(this,Ft):230}px;max-height:${F(this,mn)?F(this,mn):250}px;object-fit:cover;`);V.src=e,V.alt=t||"";const ne=this._renderImageErrorContainer();g.appendChild(ne),V.onload=()=>{he.style.display="none",v.style.display="none",v.remove(),ne.style.display="none",ne.remove(),V.style.display="block",he.style.display=i?"flex":"none"},V.onerror=be=>{v.style.display="none",v.remove(),ne.style.display="flex",V.style.display="none",he.style.display="none"};const ie=ne.querySelector("#retry-image-btn");ie==null||ie.addEventListener("click",()=>{v.style.display="flex",ne.style.display="none",he.style.display="none",V.src=e});const he=pe("div","","width: 18px; height: 18px; display:none; cursor:pointer; align-items: center; justify-content: center; padding: 4px; position: absolute; top: -5px; right: -5px; background: #c10007; border-radius: 50%;z-index:1");he.id="remove-preview-btn";const we=or();we.style.fill="#fff",he==null||he.appendChild(we),he.addEventListener("click",()=>{F(this,In).call(this)});const Ue=pe("button","","display:none");Ue.id="image-preview-hidden-btn",Ue.addEventListener("click",be=>{var Se;be.preventDefault(),be.stopPropagation(),(Se=F(this,It))==null||Se.removeChild(g),F(this,Fn).call(this),this._removeUserToast(),d&&(d.style.display="flex")}),g==null||g.append(V,he,Ue),(me=F(this,It))==null||me.append(g)}_renderImageErrorContainer(){const e=pe("div","","display: none; text-align: center;");return e.innerHTML=`
|
|
25
25
|
<div style="display: flex; flex-direction: column; align-items: center; justify-content: center; height: 100%;">
|
|
26
26
|
<p style="color: #c10007;margin-block:0px;">Failed to load image</p>
|
|
27
27
|
<button type="button" id="retry-image-btn" style="margin-top: 10px; padding: 5px 10px; background: #3498db; color: white; border: none; border-radius: 4px; cursor: pointer;">
|