image-salon-sdk 1.0.4 → 1.0.5
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
|
@@ -89,7 +89,7 @@ function kt(i, e) {
|
|
|
89
89
|
const t = document.createElement("span");
|
|
90
90
|
return t.classList.add(e), t.textContent = i, t;
|
|
91
91
|
}
|
|
92
|
-
function
|
|
92
|
+
function fe(i, e, t, n) {
|
|
93
93
|
const r = document.createElement("img");
|
|
94
94
|
return e && r.classList.add(e), r.src = i, r;
|
|
95
95
|
}
|
|
@@ -2869,7 +2869,7 @@ const dn = new fn();
|
|
|
2869
2869
|
class mn extends v {
|
|
2870
2870
|
constructor() {
|
|
2871
2871
|
super("com.hamropatro.grpc.cms.GetAllFoldersResponse", [
|
|
2872
|
-
{ no: 1, name: "folder", kind: "message", repeat: 1, T: () =>
|
|
2872
|
+
{ no: 1, name: "folder", kind: "message", repeat: 1, T: () => le },
|
|
2873
2873
|
{
|
|
2874
2874
|
no: 2,
|
|
2875
2875
|
name: "next_cursor",
|
|
@@ -2897,7 +2897,7 @@ class mn extends v {
|
|
|
2897
2897
|
switch (o) {
|
|
2898
2898
|
case /* repeated com.hamropatro.grpc.cms.Folder folder */
|
|
2899
2899
|
1:
|
|
2900
|
-
s.folder.push(
|
|
2900
|
+
s.folder.push(le.internalBinaryRead(e, e.uint32(), n));
|
|
2901
2901
|
break;
|
|
2902
2902
|
case /* string next_cursor */
|
|
2903
2903
|
2:
|
|
@@ -2919,7 +2919,7 @@ class mn extends v {
|
|
|
2919
2919
|
}
|
|
2920
2920
|
internalBinaryWrite(e, t, n) {
|
|
2921
2921
|
for (let s = 0; s < e.folder.length; s++)
|
|
2922
|
-
|
|
2922
|
+
le.internalBinaryWrite(e.folder[s], t.tag(1, m.LengthDelimited).fork(), n).join();
|
|
2923
2923
|
e.nextCursor !== "" && t.tag(2, m.LengthDelimited).string(e.nextCursor), e.hasMore !== !1 && t.tag(3, m.Varint).bool(e.hasMore);
|
|
2924
2924
|
let r = n.writeUnknownFields;
|
|
2925
2925
|
return r !== !1 && (r == !0 ? N.onWrite : r)(this.typeName, e, t), t;
|
|
@@ -3000,10 +3000,10 @@ class gn extends v {
|
|
|
3000
3000
|
return r !== !1 && (r == !0 ? N.onWrite : r)(this.typeName, e, t), t;
|
|
3001
3001
|
}
|
|
3002
3002
|
}
|
|
3003
|
-
const
|
|
3004
|
-
{ name: "createFolder", options: {}, I: ft, O:
|
|
3003
|
+
const le = new gn(), Fe = new ve("com.hamropatro.grpc.cms.FolderService", [
|
|
3004
|
+
{ name: "createFolder", options: {}, I: ft, O: le },
|
|
3005
3005
|
{ name: "getFolders", options: {}, I: dn, O: pn },
|
|
3006
|
-
{ name: "updateFolder", options: {}, I:
|
|
3006
|
+
{ name: "updateFolder", options: {}, I: le, O: le }
|
|
3007
3007
|
]);
|
|
3008
3008
|
class bn {
|
|
3009
3009
|
constructor(e) {
|
|
@@ -3232,7 +3232,7 @@ class yn extends v {
|
|
|
3232
3232
|
return r !== !1 && (r == !0 ? N.onWrite : r)(this.typeName, e, t), t;
|
|
3233
3233
|
}
|
|
3234
3234
|
}
|
|
3235
|
-
const
|
|
3235
|
+
const ce = new yn();
|
|
3236
3236
|
class Nn extends v {
|
|
3237
3237
|
constructor() {
|
|
3238
3238
|
super("com.hamropatro.grpc.cms.FileMetadata", [
|
|
@@ -3459,7 +3459,7 @@ const Bn = new On();
|
|
|
3459
3459
|
class Fn extends v {
|
|
3460
3460
|
constructor() {
|
|
3461
3461
|
super("com.hamropatro.grpc.cms.GetFilesByFolderResponse", [
|
|
3462
|
-
{ no: 1, name: "files", kind: "message", repeat: 1, T: () =>
|
|
3462
|
+
{ no: 1, name: "files", kind: "message", repeat: 1, T: () => ce },
|
|
3463
3463
|
{
|
|
3464
3464
|
no: 2,
|
|
3465
3465
|
name: "next_cursor",
|
|
@@ -3487,7 +3487,7 @@ class Fn extends v {
|
|
|
3487
3487
|
switch (o) {
|
|
3488
3488
|
case /* repeated com.hamropatro.grpc.cms.File files */
|
|
3489
3489
|
1:
|
|
3490
|
-
s.files.push(
|
|
3490
|
+
s.files.push(ce.internalBinaryRead(e, e.uint32(), n));
|
|
3491
3491
|
break;
|
|
3492
3492
|
case /* string next_cursor */
|
|
3493
3493
|
2:
|
|
@@ -3509,15 +3509,15 @@ class Fn extends v {
|
|
|
3509
3509
|
}
|
|
3510
3510
|
internalBinaryWrite(e, t, n) {
|
|
3511
3511
|
for (let s = 0; s < e.files.length; s++)
|
|
3512
|
-
|
|
3512
|
+
ce.internalBinaryWrite(e.files[s], t.tag(1, m.LengthDelimited).fork(), n).join();
|
|
3513
3513
|
e.nextCursor !== "" && t.tag(2, m.LengthDelimited).string(e.nextCursor), e.hasMore !== !1 && t.tag(3, m.Varint).bool(e.hasMore);
|
|
3514
3514
|
let r = n.writeUnknownFields;
|
|
3515
3515
|
return r !== !1 && (r == !0 ? N.onWrite : r)(this.typeName, e, t), t;
|
|
3516
3516
|
}
|
|
3517
3517
|
}
|
|
3518
3518
|
const An = new Fn(), De = new ve("com.hamropatro.grpc.cms.FileService", [
|
|
3519
|
-
{ name: "createFile", options: {}, I: dt, O:
|
|
3520
|
-
{ name: "updateFile", options: {}, I:
|
|
3519
|
+
{ name: "createFile", options: {}, I: dt, O: ce },
|
|
3520
|
+
{ name: "updateFile", options: {}, I: ce, O: ce },
|
|
3521
3521
|
{ name: "deleteFile", options: {}, I: En, O: Tn },
|
|
3522
3522
|
{ name: "getFilesByFolder", options: {}, I: Bn, O: An }
|
|
3523
3523
|
]);
|
|
@@ -3648,7 +3648,7 @@ const _n = {
|
|
|
3648
3648
|
baseUrl: "https://hamro-cms-backend-grpc.hamrostack.com"
|
|
3649
3649
|
}, Me = new un({
|
|
3650
3650
|
baseUrl: _n.baseUrl
|
|
3651
|
-
}), Cn = new bn(Me), ye = ft.create(), vn = new Dn(Me),
|
|
3651
|
+
}), Cn = new bn(Me), ye = ft.create(), vn = new Dn(Me), oe = dt.create(), Sn = new xn(Me);
|
|
3652
3652
|
mt.create();
|
|
3653
3653
|
const pt = async () => {
|
|
3654
3654
|
try {
|
|
@@ -3687,8 +3687,8 @@ const pt = async () => {
|
|
|
3687
3687
|
}
|
|
3688
3688
|
}, jn = async (i, e, t, n, r) => {
|
|
3689
3689
|
try {
|
|
3690
|
-
return
|
|
3691
|
-
|
|
3690
|
+
return oe.name = i, oe.nestedFolderName = e, oe.url = t, oe.type = n, oe.folderName = r, await vn.createFile(
|
|
3691
|
+
oe
|
|
3692
3692
|
);
|
|
3693
3693
|
} catch (s) {
|
|
3694
3694
|
throw s;
|
|
@@ -3696,11 +3696,11 @@ const pt = async () => {
|
|
|
3696
3696
|
};
|
|
3697
3697
|
var gt = /* @__PURE__ */ ((i) => (i[i.IMAGE = 0] = "IMAGE", i[i.AUDIO = 1] = "AUDIO", i[i.VIDEO = 2] = "VIDEO", i[i.ALL = 3] = "ALL", i))(gt || {});
|
|
3698
3698
|
const Pn = "data:image/svg+xml,%3csvg%20xmlns='http://www.w3.org/2000/svg'%20width='24'%20height='24'%20viewBox='0%200%2024%2024'%20fill='none'%20stroke='currentColor'%20stroke-width='2'%20stroke-linecap='round'%20stroke-linejoin='round'%20class='lucide%20lucide-cloud-upload'%3e%3cpath%20d='M4%2014.899A7%207%200%201%201%2015.71%208h1.79a4.5%204.5%200%200%201%202.5%208.242'/%3e%3cpath%20d='M12%2012v9'/%3e%3cpath%20d='m16%2016-4-4-4%204'/%3e%3c/svg%3e", et = "data:image/svg+xml,%3csvg%20xmlns='http://www.w3.org/2000/svg'%20viewBox='0%200%20100%20100'%20preserveAspectRatio='xMidYMid'%20width='200'%20height='200'%20style='shape-rendering:%20auto;%20display:%20block;%20background:%20rgb(255,%20255,%20255);%20--darkreader-inline-bgimage:%20initial;%20--darkreader-inline-bgcolor:%20%231e1e2e;'%20data-darkreader-inline-bgimage=''%20data-darkreader-inline-bgcolor=''%20xmlns:xlink='http://www.w3.org/1999/xlink'%3e%3cg%3e%3ccircle%20stroke-dasharray='164.93361431346415%2056.97787143782138'%20r='35'%20stroke-width='10'%20stroke='%23e15b64'%20fill='none'%20cy='50'%20cx='50'%3e%3canimateTransform%20keyTimes='0;1'%20values='0%2050%2050;360%2050%2050'%20dur='1s'%20repeatCount='indefinite'%20type='rotate'%20attributeName='transform'%3e%3c/animateTransform%3e%3c/circle%3e%3cg%3e%3c/g%3e%3c/g%3e%3c!--%20[ldio]%20generated%20by%20https://loading.io%20--%3e%3c/svg%3e", Wn = "data:image/svg+xml,%3csvg%20xmlns='http://www.w3.org/2000/svg'%20width='24'%20height='24'%20viewBox='0%200%2024%2024'%20fill='none'%20stroke='white'%20stroke-width='2'%20stroke-linecap='round'%20stroke-linejoin='round'%20class='lucide%20lucide-cloud-upload'%20%3e%3cpath%20d='M4%2014.899A7%207%200%201%201%2015.71%208h1.79a4.5%204.5%200%200%201%202.5%208.242'%20/%3e%3cpath%20d='M12%2012v9'%20/%3e%3cpath%20d='m16%2016-4-4-4%204'%20/%3e%3c/svg%3e";
|
|
3699
|
-
var ie,
|
|
3699
|
+
var ie, ue, re, B, q, se, K, ae, T, Q, he, me;
|
|
3700
3700
|
class Kn {
|
|
3701
3701
|
constructor(e) {
|
|
3702
3702
|
_(this, ie);
|
|
3703
|
-
_(this,
|
|
3703
|
+
_(this, ue);
|
|
3704
3704
|
_(this, re);
|
|
3705
3705
|
_(this, B);
|
|
3706
3706
|
_(this, q);
|
|
@@ -3709,26 +3709,26 @@ class Kn {
|
|
|
3709
3709
|
_(this, ae);
|
|
3710
3710
|
_(this, T, []);
|
|
3711
3711
|
_(this, Q);
|
|
3712
|
-
_(this,
|
|
3712
|
+
_(this, he);
|
|
3713
3713
|
_(this, me);
|
|
3714
|
-
I(this, q, null), I(this, K, !1), I(this, Q, !1), I(this,
|
|
3714
|
+
I(this, q, null), I(this, K, !1), I(this, Q, !1), I(this, he, e.folderName), I(this, me, e.handleUpload.bind(this));
|
|
3715
3715
|
}
|
|
3716
3716
|
_init() {
|
|
3717
|
-
!!sessionStorage.getItem("folderCreated") || this.createFolder(d(this,
|
|
3717
|
+
!!sessionStorage.getItem("folderCreated") || this.createFolder(d(this, he));
|
|
3718
3718
|
}
|
|
3719
3719
|
create(e) {
|
|
3720
3720
|
I(this, ie, document.getElementById(
|
|
3721
3721
|
e.imageUploadMainContainerId
|
|
3722
|
-
)), I(this,
|
|
3722
|
+
)), I(this, ue, J("browse-container")), I(this, re, J("browse-image-main"));
|
|
3723
3723
|
let t;
|
|
3724
|
-
|
|
3724
|
+
t = fe(Pn, "upload-btn-icon");
|
|
3725
3725
|
const n = kt("Upload Image", "upload-span-text"), r = pe(
|
|
3726
|
-
|
|
3726
|
+
"Browser Files",
|
|
3727
3727
|
"browse-image-button"
|
|
3728
3728
|
);
|
|
3729
3729
|
return r.addEventListener("click", () => {
|
|
3730
3730
|
this.selectedImageContainer();
|
|
3731
|
-
}), d(this, re) && d(this, re).append(t, n, r), d(this,
|
|
3731
|
+
}), d(this, re) && d(this, re).append(t, n, r), d(this, ue).appendChild(d(this, re)), d(this, ie) && d(this, ie).appendChild(d(this, ue)), d(this, ie);
|
|
3732
3732
|
}
|
|
3733
3733
|
selectedImageContainer() {
|
|
3734
3734
|
var a;
|
|
@@ -3784,7 +3784,7 @@ class Kn {
|
|
|
3784
3784
|
"browse-more-btn"
|
|
3785
3785
|
), n = Et("file");
|
|
3786
3786
|
n.style.display = "none";
|
|
3787
|
-
const r =
|
|
3787
|
+
const r = fe(Wn);
|
|
3788
3788
|
return t.append(r), t.addEventListener("click", () => n.click()), n.addEventListener("change", () => {
|
|
3789
3789
|
const s = n.files[0], a = new FileReader();
|
|
3790
3790
|
a.readAsDataURL(s), a.onload = async () => {
|
|
@@ -3807,7 +3807,7 @@ class Kn {
|
|
|
3807
3807
|
if (d(this, B).innerHTML = "", d(this, T).length > 0)
|
|
3808
3808
|
d(this, T).forEach((e) => {
|
|
3809
3809
|
var l;
|
|
3810
|
-
const t = J("selected-image-content"), n = pe("x", "selected-image-btn"), r =
|
|
3810
|
+
const t = J("selected-image-content"), n = pe("x", "selected-image-btn"), r = fe(e == null ? void 0 : e.url, "selected-image");
|
|
3811
3811
|
n.addEventListener("click", () => {
|
|
3812
3812
|
if (I(this, T, d(this, T).filter(
|
|
3813
3813
|
(c) => (c == null ? void 0 : c.url) !== (e == null ? void 0 : e.url)
|
|
@@ -3826,7 +3826,7 @@ class Kn {
|
|
|
3826
3826
|
s.classList.contains("checked") ? (s.classList.remove("checked"), I(this, T, d(this, T).filter(
|
|
3827
3827
|
(c) => (c == null ? void 0 : c.url) !== (e == null ? void 0 : e.url)
|
|
3828
3828
|
))) : (s.classList.add("checked"), d(this, T).push(e)), this._updateDialogContent();
|
|
3829
|
-
}), d(this, Q) ? (I(this, ae,
|
|
3829
|
+
}), d(this, Q) ? (I(this, ae, fe(et, "loader")), d(this, B).insertBefore(
|
|
3830
3830
|
d(this, ae),
|
|
3831
3831
|
d(this, B).firstChild
|
|
3832
3832
|
)) : (s.append(r, n), d(this, B).style.width = "100%", d(this, B).appendChild(s));
|
|
@@ -3844,7 +3844,7 @@ class Kn {
|
|
|
3844
3844
|
), d(this, B).style.width = "100%", d(this, B).appendChild(s);
|
|
3845
3845
|
});
|
|
3846
3846
|
else if (d(this, Q))
|
|
3847
|
-
I(this, ae,
|
|
3847
|
+
I(this, ae, fe(et, "loader")), d(this, B).style.width = "100%", d(this, B).appendChild(d(this, ae));
|
|
3848
3848
|
else {
|
|
3849
3849
|
const e = ne();
|
|
3850
3850
|
e.textContent = "No images selected", d(this, B).style.textAlign = "center", d(this, B).style.width = "auto", d(this, B).appendChild(e);
|
|
@@ -3895,13 +3895,13 @@ class Kn {
|
|
|
3895
3895
|
"",
|
|
3896
3896
|
t == null ? void 0 : t.url,
|
|
3897
3897
|
gt.IMAGE,
|
|
3898
|
-
d(this,
|
|
3898
|
+
d(this, he)
|
|
3899
3899
|
);
|
|
3900
3900
|
e.push(n.response);
|
|
3901
3901
|
}
|
|
3902
3902
|
}
|
|
3903
3903
|
}
|
|
3904
|
-
ie = new WeakMap(),
|
|
3904
|
+
ie = new WeakMap(), ue = new WeakMap(), re = new WeakMap(), B = new WeakMap(), q = new WeakMap(), se = new WeakMap(), K = new WeakMap(), ae = new WeakMap(), T = new WeakMap(), Q = new WeakMap(), he = new WeakMap(), me = new WeakMap();
|
|
3905
3905
|
export {
|
|
3906
3906
|
Kn as default
|
|
3907
3907
|
};
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import './style.css';
|
|
2
|
-
(function(w,T){typeof exports=="object"&&typeof module<"u"?module.exports=T():typeof define=="function"&&define.amd?define(T):(w=typeof globalThis<"u"?globalThis:w||self,w.ImageSalonSdk=T())})(this,function(){"use strict";var Wn=Object.defineProperty;var gt=w=>{throw TypeError(w)};var qn=(w,T,x)=>T in w?Wn(w,T,{enumerable:!0,configurable:!0,writable:!0,value:x}):w[T]=x;var _=(w,T,x)=>qn(w,typeof T!="symbol"?T+"":T,x),bt=(w,T,x)=>T.has(w)||gt("Cannot "+x);var d=(w,T,x)=>(bt(w,T,"read from private field"),x?x.call(w):T.get(w)),S=(w,T,x)=>T.has(w)?gt("Cannot add the same private member more than once"):T instanceof WeakSet?T.add(w):T.set(w,x),O=(w,T,x,ce)=>(bt(w,T,"write to private field"),ce?ce.call(w,x):T.set(w,x),x);var Y,re,
|
|
2
|
+
(function(w,T){typeof exports=="object"&&typeof module<"u"?module.exports=T():typeof define=="function"&&define.amd?define(T):(w=typeof globalThis<"u"?globalThis:w||self,w.ImageSalonSdk=T())})(this,function(){"use strict";var Wn=Object.defineProperty;var gt=w=>{throw TypeError(w)};var qn=(w,T,x)=>T in w?Wn(w,T,{enumerable:!0,configurable:!0,writable:!0,value:x}):w[T]=x;var _=(w,T,x)=>qn(w,typeof T!="symbol"?T+"":T,x),bt=(w,T,x)=>T.has(w)||gt("Cannot "+x);var d=(w,T,x)=>(bt(w,T,"read from private field"),x?x.call(w):T.get(w)),S=(w,T,x)=>T.has(w)?gt("Cannot add the same private member more than once"):T instanceof WeakSet?T.add(w):T.set(w,x),O=(w,T,x,ce)=>(bt(w,T,"write to private field"),ce?ce.call(w,x):T.set(w,x),x);var Y,re,de,se,A,X,ae,G,oe,B,te,me,be;function w(i,e,t){let n=document.createElement(i);return n.className+=e,t&&t.appendChild(n),n}class T{constructor(){S(this,Y);O(this,Y,document.createElementNS("http://www.w3.org/2000/svg","svg")),d(this,Y).setAttribute("viewBox","25 25 50 50"),d(this,Y).classList.add("loader-svg");const e=document.createElementNS("http://www.w3.org/2000/svg","circle");e.setAttribute("r","20"),e.setAttribute("cy","50"),e.setAttribute("cx","50"),e.classList.add("loader-circle"),d(this,Y).appendChild(e)}show(e){e.appendChild(d(this,Y))}hide(){d(this,Y).remove()}}Y=new WeakMap;const x=new T,ce=document.body;class wt{constructor(){_(this,"main");_(this,"dialogHeader");_(this,"dialogBody");_(this,"dialogFooter");_(this,"confirmButton");_(this,"cancelButton");_(this,"confirmCallback");_(this,"cancelCallback");this.main=w("div"),this.dialogHeader=w("div"),this.dialogBody=w("div"),this.dialogFooter=w("div"),this.confirmButton=document.createElement("button"),this.cancelButton=document.createElement("button"),this.confirmCallback=void 0,this.cancelCallback=void 0}show(e){this.main=w("div","dialog",ce);const t=w("div","dialog-content",this.main);return this.dialogHeader=w("div","dialog-header",t),this.dialogBody=w("div","dialog-body",t),this.dialogFooter=w("div","dialog-footer",t),this.confirmButton=w("button","dialog-btn confirm",this.dialogFooter),this.confirmButton.disabled=!0,this.cancelButton=w("button","dialog-btn cancel",this.dialogFooter),typeof e.title=="string"?this.dialogHeader.innerHTML=e.title:(this.dialogHeader.innerHTML="",this.dialogHeader.appendChild(e.title)),typeof e.content=="string"?this.dialogBody.innerHTML=e.content:(this.dialogBody.innerHTML="",this.dialogBody.appendChild(e.content)),this.confirmButton.textContent=e.confirmButtonText||"Upload",this.cancelButton.textContent=e.cancelButtonText||"Cancel",ce.classList.add("dialog-visible"),new Promise(n=>{const r=s=>()=>{this.hide(),n(s==="confirm")};this.confirmCallback=e.onConfirm||r("confirm"),this.confirmButton.addEventListener("click",this.confirmCallback),this.cancelCallback=e.onCancel||r("cancel"),this.cancelButton.addEventListener("click",this.cancelCallback)})}hide(){ce.classList.remove("dialog-visible"),this.main.remove()}updateUploadBtnText(e){this.confirmButton&&(this.confirmButton.textContent=e)}disableConfirmButton(e){this.confirmButton&&(this.confirmButton.disabled=e)}updateUploadBtn(e){e?(x.show(this.confirmButton),this.disableConfirmButton(!0)):(x.hide(),this.disableConfirmButton(!1))}}const j=new wt;function H(i,e){const t=document.createElement("div");return i&&t.classList.add(i),e&&(t.id=e),t}function ie(i,e,t){const n=document.createElement("p");return e&&n.classList.add(e),i&&(n.textContent=i),n}function yt(i,e){const t=document.createElement("span");return t.classList.add(e),t.textContent=i,t}function pe(i,e,t,n){const r=document.createElement("img");return e&&r.classList.add(e),r.src=i,r}function we(i,e,t,n,r){const s=document.createElement("button");return e&&s.classList.add(e),t&&(s.id=t),i&&(s.textContent=i),r&&(s.innerHTML=r),s.disabled=n,s}function Nt(i){const e=document.createElement("input");return e.type=i,e}function je(i){let e=typeof i;if(e=="object"){if(Array.isArray(i))return"array";if(i===null)return"null"}return e}function kt(i){return i!==null&&typeof i=="object"&&!Array.isArray(i)}let Z="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/".split(""),ye=[];for(let i=0;i<Z.length;i++)ye[Z[i].charCodeAt(0)]=i;ye[45]=Z.indexOf("+"),ye[95]=Z.indexOf("/");function Pe(i){let e=i.length*3/4;i[i.length-2]=="="?e-=2:i[i.length-1]=="="&&(e-=1);let t=new Uint8Array(e),n=0,r=0,s,a=0;for(let o=0;o<i.length;o++){if(s=ye[i.charCodeAt(o)],s===void 0)switch(i[o]){case"=":r=0;case`
|
|
3
3
|
`:case"\r":case" ":case" ":continue;default:throw Error("invalid base64 string.")}switch(r){case 0:a=s,r=1;break;case 1:t[n++]=a<<2|(s&48)>>4,a=s,r=2;break;case 2:t[n++]=(a&15)<<4|(s&60)>>2,a=s,r=3;break;case 3:t[n++]=(a&3)<<6|s,r=0;break}}if(r==1)throw Error("invalid base64 string.");return t.subarray(0,n)}function We(i){let e="",t=0,n,r=0;for(let s=0;s<i.length;s++)switch(n=i[s],t){case 0:e+=Z[n>>2],r=(n&3)<<4,t=1;break;case 1:e+=Z[r|n>>4],r=(n&15)<<2,t=2;break;case 2:e+=Z[r|n>>6],e+=Z[n&63],t=0;break}return t&&(e+=Z[r],e+="=",t==1&&(e+="=")),e}var k;(function(i){i.symbol=Symbol.for("protobuf-ts/unknown"),i.onRead=(t,n,r,s,a)=>{(e(n)?n[i.symbol]:n[i.symbol]=[]).push({no:r,wireType:s,data:a})},i.onWrite=(t,n,r)=>{for(let{no:s,wireType:a,data:o}of i.list(n))r.tag(s,a).raw(o)},i.list=(t,n)=>{if(e(t)){let r=t[i.symbol];return n?r.filter(s=>s.no==n):r}return[]},i.last=(t,n)=>i.list(t,n).slice(-1)[0];const e=t=>t&&Array.isArray(t[i.symbol])})(k||(k={}));function Et(i,e){return Object.assign(Object.assign({},i),e)}var m;(function(i){i[i.Varint=0]="Varint",i[i.Bit64=1]="Bit64",i[i.LengthDelimited=2]="LengthDelimited",i[i.StartGroup=3]="StartGroup",i[i.EndGroup=4]="EndGroup",i[i.Bit32=5]="Bit32"})(m||(m={}));function It(){let i=0,e=0;for(let n=0;n<28;n+=7){let r=this.buf[this.pos++];if(i|=(r&127)<<n,!(r&128))return this.assertBounds(),[i,e]}let t=this.buf[this.pos++];if(i|=(t&15)<<28,e=(t&112)>>4,!(t&128))return this.assertBounds(),[i,e];for(let n=3;n<=31;n+=7){let r=this.buf[this.pos++];if(e|=(r&127)<<n,!(r&128))return this.assertBounds(),[i,e]}throw new Error("invalid varint")}function Ae(i,e,t){for(let s=0;s<28;s=s+7){const a=i>>>s,o=!(!(a>>>7)&&e==0),l=(o?a|128:a)&255;if(t.push(l),!o)return}const n=i>>>28&15|(e&7)<<4,r=!!(e>>3);if(t.push((r?n|128:n)&255),!!r){for(let s=3;s<31;s=s+7){const a=e>>>s,o=!!(a>>>7),l=(o?a|128:a)&255;if(t.push(l),!o)return}t.push(e>>>31&1)}}const Ne=65536*65536;function qe(i){let e=i[0]=="-";e&&(i=i.slice(1));const t=1e6;let n=0,r=0;function s(a,o){const l=Number(i.slice(a,o));r*=t,n=n*t+l,n>=Ne&&(r=r+(n/Ne|0),n=n%Ne)}return s(-24,-18),s(-18,-12),s(-12,-6),s(-6),[e,n,r]}function De(i,e){if(e>>>0<=2097151)return""+(Ne*e+(i>>>0));let t=i&16777215,n=(i>>>24|e<<8)>>>0&16777215,r=e>>16&65535,s=t+n*6777216+r*6710656,a=n+r*8147497,o=r*2,l=1e7;s>=l&&(a+=Math.floor(s/l),s%=l),a>=l&&(o+=Math.floor(a/l),a%=l);function c(h,p){let y=h?String(h):"";return p?"0000000".slice(y.length)+y:y}return c(o,0)+c(a,o)+c(s,1)}function Ke(i,e){if(i>=0){for(;i>127;)e.push(i&127|128),i=i>>>7;e.push(i)}else{for(let t=0;t<9;t++)e.push(i&127|128),i=i>>7;e.push(1)}}function Tt(){let i=this.buf[this.pos++],e=i&127;if(!(i&128))return this.assertBounds(),e;if(i=this.buf[this.pos++],e|=(i&127)<<7,!(i&128))return this.assertBounds(),e;if(i=this.buf[this.pos++],e|=(i&127)<<14,!(i&128))return this.assertBounds(),e;if(i=this.buf[this.pos++],e|=(i&127)<<21,!(i&128))return this.assertBounds(),e;i=this.buf[this.pos++],e|=(i&15)<<28;for(let t=5;i&128&&t<10;t++)i=this.buf[this.pos++];if(i&128)throw new Error("invalid varint");return this.assertBounds(),e>>>0}let E;function Ot(){const i=new DataView(new ArrayBuffer(8));E=globalThis.BigInt!==void 0&&typeof i.getBigInt64=="function"&&typeof i.getBigUint64=="function"&&typeof i.setBigInt64=="function"&&typeof i.setBigUint64=="function"?{MIN:BigInt("-9223372036854775808"),MAX:BigInt("9223372036854775807"),UMIN:BigInt("0"),UMAX:BigInt("18446744073709551615"),C:BigInt,V:i}:void 0}Ot();function Xe(i){if(!i)throw new Error("BigInt unavailable, see https://github.com/timostamm/protobuf-ts/blob/v1.0.8/MANUAL.md#bigint-support")}const Ge=/^-?[0-9]+$/,ke=4294967296,Ee=2147483648;class Je{constructor(e,t){this.lo=e|0,this.hi=t|0}isZero(){return this.lo==0&&this.hi==0}toNumber(){let e=this.hi*ke+(this.lo>>>0);if(!Number.isSafeInteger(e))throw new Error("cannot convert to safe number");return e}}class C extends Je{static from(e){if(E)switch(typeof e){case"string":if(e=="0")return this.ZERO;if(e=="")throw new Error("string is no integer");e=E.C(e);case"number":if(e===0)return this.ZERO;e=E.C(e);case"bigint":if(!e)return this.ZERO;if(e<E.UMIN)throw new Error("signed value for ulong");if(e>E.UMAX)throw new Error("ulong too large");return E.V.setBigUint64(0,e,!0),new C(E.V.getInt32(0,!0),E.V.getInt32(4,!0))}else switch(typeof e){case"string":if(e=="0")return this.ZERO;if(e=e.trim(),!Ge.test(e))throw new Error("string is no integer");let[t,n,r]=qe(e);if(t)throw new Error("signed value for ulong");return new C(n,r);case"number":if(e==0)return this.ZERO;if(!Number.isSafeInteger(e))throw new Error("number is no integer");if(e<0)throw new Error("signed value for ulong");return new C(e,e/ke)}throw new Error("unknown value "+typeof e)}toString(){return E?this.toBigInt().toString():De(this.lo,this.hi)}toBigInt(){return Xe(E),E.V.setInt32(0,this.lo,!0),E.V.setInt32(4,this.hi,!0),E.V.getBigUint64(0,!0)}}C.ZERO=new C(0,0);class D extends Je{static from(e){if(E)switch(typeof e){case"string":if(e=="0")return this.ZERO;if(e=="")throw new Error("string is no integer");e=E.C(e);case"number":if(e===0)return this.ZERO;e=E.C(e);case"bigint":if(!e)return this.ZERO;if(e<E.MIN)throw new Error("signed long too small");if(e>E.MAX)throw new Error("signed long too large");return E.V.setBigInt64(0,e,!0),new D(E.V.getInt32(0,!0),E.V.getInt32(4,!0))}else switch(typeof e){case"string":if(e=="0")return this.ZERO;if(e=e.trim(),!Ge.test(e))throw new Error("string is no integer");let[t,n,r]=qe(e);if(t){if(r>Ee||r==Ee&&n!=0)throw new Error("signed long too small")}else if(r>=Ee)throw new Error("signed long too large");let s=new D(n,r);return t?s.negate():s;case"number":if(e==0)return this.ZERO;if(!Number.isSafeInteger(e))throw new Error("number is no integer");return e>0?new D(e,e/ke):new D(-e,-e/ke).negate()}throw new Error("unknown value "+typeof e)}isNegative(){return(this.hi&Ee)!==0}negate(){let e=~this.hi,t=this.lo;return t?t=~t+1:e+=1,new D(t,e)}toString(){if(E)return this.toBigInt().toString();if(this.isNegative()){let e=this.negate();return"-"+De(e.lo,e.hi)}return De(this.lo,this.hi)}toBigInt(){return Xe(E),E.V.setInt32(0,this.lo,!0),E.V.setInt32(4,this.hi,!0),E.V.getBigInt64(0,!0)}}D.ZERO=new D(0,0);const He={readUnknownField:!0,readerFactory:i=>new Ft(i)};function Bt(i){return i?Object.assign(Object.assign({},He),i):He}class Ft{constructor(e,t){this.varint64=It,this.uint32=Tt,this.buf=e,this.len=e.length,this.pos=0,this.view=new DataView(e.buffer,e.byteOffset,e.byteLength),this.textDecoder=t??new TextDecoder("utf-8",{fatal:!0,ignoreBOM:!0})}tag(){let e=this.uint32(),t=e>>>3,n=e&7;if(t<=0||n<0||n>5)throw new Error("illegal tag: field no "+t+" wire type "+n);return[t,n]}skip(e){let t=this.pos;switch(e){case m.Varint:for(;this.buf[this.pos++]&128;);break;case m.Bit64:this.pos+=4;case m.Bit32:this.pos+=4;break;case m.LengthDelimited:let n=this.uint32();this.pos+=n;break;case m.StartGroup:let r;for(;(r=this.tag()[1])!==m.EndGroup;)this.skip(r);break;default:throw new Error("cant skip wire type "+e)}return this.assertBounds(),this.buf.subarray(t,this.pos)}assertBounds(){if(this.pos>this.len)throw new RangeError("premature EOF")}int32(){return this.uint32()|0}sint32(){let e=this.uint32();return e>>>1^-(e&1)}int64(){return new D(...this.varint64())}uint64(){return new C(...this.varint64())}sint64(){let[e,t]=this.varint64(),n=-(e&1);return e=(e>>>1|(t&1)<<31)^n,t=t>>>1^n,new D(e,t)}bool(){let[e,t]=this.varint64();return e!==0||t!==0}fixed32(){return this.view.getUint32((this.pos+=4)-4,!0)}sfixed32(){return this.view.getInt32((this.pos+=4)-4,!0)}fixed64(){return new C(this.sfixed32(),this.sfixed32())}sfixed64(){return new D(this.sfixed32(),this.sfixed32())}float(){return this.view.getFloat32((this.pos+=4)-4,!0)}double(){return this.view.getFloat64((this.pos+=8)-8,!0)}bytes(){let e=this.uint32(),t=this.pos;return this.pos+=e,this.assertBounds(),this.buf.subarray(t,t+e)}string(){return this.textDecoder.decode(this.bytes())}}function b(i,e){if(!i)throw new Error(e)}const At=34028234663852886e22,Dt=-34028234663852886e22,Lt=4294967295,Ut=2147483647,Rt=-2147483648;function ge(i){if(typeof i!="number")throw new Error("invalid int 32: "+typeof i);if(!Number.isInteger(i)||i>Ut||i<Rt)throw new Error("invalid int 32: "+i)}function Ie(i){if(typeof i!="number")throw new Error("invalid uint 32: "+typeof i);if(!Number.isInteger(i)||i>Lt||i<0)throw new Error("invalid uint 32: "+i)}function Le(i){if(typeof i!="number")throw new Error("invalid float 32: "+typeof i);if(Number.isFinite(i)&&(i>At||i<Dt))throw new Error("invalid float 32: "+i)}const Ze={writeUnknownFields:!0,writerFactory:()=>new _t};function xt(i){return i?Object.assign(Object.assign({},Ze),i):Ze}class _t{constructor(e){this.stack=[],this.textEncoder=e??new TextEncoder,this.chunks=[],this.buf=[]}finish(){this.chunks.push(new Uint8Array(this.buf));let e=0;for(let r=0;r<this.chunks.length;r++)e+=this.chunks[r].length;let t=new Uint8Array(e),n=0;for(let r=0;r<this.chunks.length;r++)t.set(this.chunks[r],n),n+=this.chunks[r].length;return this.chunks=[],t}fork(){return this.stack.push({chunks:this.chunks,buf:this.buf}),this.chunks=[],this.buf=[],this}join(){let e=this.finish(),t=this.stack.pop();if(!t)throw new Error("invalid state, fork stack empty");return this.chunks=t.chunks,this.buf=t.buf,this.uint32(e.byteLength),this.raw(e)}tag(e,t){return this.uint32((e<<3|t)>>>0)}raw(e){return this.buf.length&&(this.chunks.push(new Uint8Array(this.buf)),this.buf=[]),this.chunks.push(e),this}uint32(e){for(Ie(e);e>127;)this.buf.push(e&127|128),e=e>>>7;return this.buf.push(e),this}int32(e){return ge(e),Ke(e,this.buf),this}bool(e){return this.buf.push(e?1:0),this}bytes(e){return this.uint32(e.byteLength),this.raw(e)}string(e){let t=this.textEncoder.encode(e);return this.uint32(t.byteLength),this.raw(t)}float(e){Le(e);let t=new Uint8Array(4);return new DataView(t.buffer).setFloat32(0,e,!0),this.raw(t)}double(e){let t=new Uint8Array(8);return new DataView(t.buffer).setFloat64(0,e,!0),this.raw(t)}fixed32(e){Ie(e);let t=new Uint8Array(4);return new DataView(t.buffer).setUint32(0,e,!0),this.raw(t)}sfixed32(e){ge(e);let t=new Uint8Array(4);return new DataView(t.buffer).setInt32(0,e,!0),this.raw(t)}sint32(e){return ge(e),e=(e<<1^e>>31)>>>0,Ke(e,this.buf),this}sfixed64(e){let t=new Uint8Array(8),n=new DataView(t.buffer),r=D.from(e);return n.setInt32(0,r.lo,!0),n.setInt32(4,r.hi,!0),this.raw(t)}fixed64(e){let t=new Uint8Array(8),n=new DataView(t.buffer),r=C.from(e);return n.setInt32(0,r.lo,!0),n.setInt32(4,r.hi,!0),this.raw(t)}int64(e){let t=D.from(e);return Ae(t.lo,t.hi,this.buf),this}sint64(e){let t=D.from(e),n=t.hi>>31,r=t.lo<<1^n,s=(t.hi<<1|t.lo>>>31)^n;return Ae(r,s,this.buf),this}uint64(e){let t=C.from(e);return Ae(t.lo,t.hi,this.buf),this}}const Ye={emitDefaultValues:!1,enumAsInteger:!1,useProtoFieldName:!1,prettySpaces:0},ze={ignoreUnknownFields:!1};function Ct(i){return i?Object.assign(Object.assign({},ze),i):ze}function vt(i){return i?Object.assign(Object.assign({},Ye),i):Ye}function St(i,e){var t,n;let r=Object.assign(Object.assign({},i),e);return r.typeRegistry=[...(t=i==null?void 0:i.typeRegistry)!==null&&t!==void 0?t:[],...(n=e==null?void 0:e.typeRegistry)!==null&&n!==void 0?n:[]],r}const Qe=Symbol.for("protobuf-ts/message-type");function Ue(i){let e=!1;const t=[];for(let n=0;n<i.length;n++){let r=i.charAt(n);r=="_"?e=!0:/\d/.test(r)?(t.push(r),e=!0):e?(t.push(r.toUpperCase()),e=!1):n==0?t.push(r.toLowerCase()):t.push(r)}return t.join("")}var u;(function(i){i[i.DOUBLE=1]="DOUBLE",i[i.FLOAT=2]="FLOAT",i[i.INT64=3]="INT64",i[i.UINT64=4]="UINT64",i[i.INT32=5]="INT32",i[i.FIXED64=6]="FIXED64",i[i.FIXED32=7]="FIXED32",i[i.BOOL=8]="BOOL",i[i.STRING=9]="STRING",i[i.BYTES=12]="BYTES",i[i.UINT32=13]="UINT32",i[i.SFIXED32=15]="SFIXED32",i[i.SFIXED64=16]="SFIXED64",i[i.SINT32=17]="SINT32",i[i.SINT64=18]="SINT64"})(u||(u={}));var K;(function(i){i[i.BIGINT=0]="BIGINT",i[i.STRING=1]="STRING",i[i.NUMBER=2]="NUMBER"})(K||(K={}));var Te;(function(i){i[i.NO=0]="NO",i[i.PACKED=1]="PACKED",i[i.UNPACKED=2]="UNPACKED"})(Te||(Te={}));function Mt(i){var e,t,n,r;return i.localName=(e=i.localName)!==null&&e!==void 0?e:Ue(i.name),i.jsonName=(t=i.jsonName)!==null&&t!==void 0?t:Ue(i.name),i.repeat=(n=i.repeat)!==null&&n!==void 0?n:Te.NO,i.opt=(r=i.opt)!==null&&r!==void 0?r:i.repeat||i.oneof?!1:i.kind=="message",i}function Vt(i){if(typeof i!="object"||i===null||!i.hasOwnProperty("oneofKind"))return!1;switch(typeof i.oneofKind){case"string":return i[i.oneofKind]===void 0?!1:Object.keys(i).length==2;case"undefined":return Object.keys(i).length==1;default:return!1}}class $t{constructor(e){var t;this.fields=(t=e.fields)!==null&&t!==void 0?t:[]}prepare(){if(this.data)return;const e=[],t=[],n=[];for(let r of this.fields)if(r.oneof)n.includes(r.oneof)||(n.push(r.oneof),e.push(r.oneof),t.push(r.oneof));else switch(t.push(r.localName),r.kind){case"scalar":case"enum":(!r.opt||r.repeat)&&e.push(r.localName);break;case"message":r.repeat&&e.push(r.localName);break;case"map":e.push(r.localName);break}this.data={req:e,known:t,oneofs:Object.values(n)}}is(e,t,n=!1){if(t<0)return!0;if(e==null||typeof e!="object")return!1;this.prepare();let r=Object.keys(e),s=this.data;if(r.length<s.req.length||s.req.some(a=>!r.includes(a))||!n&&r.some(a=>!s.known.includes(a)))return!1;if(t<1)return!0;for(const a of s.oneofs){const o=e[a];if(!Vt(o))return!1;if(o.oneofKind===void 0)continue;const l=this.fields.find(c=>c.localName===o.oneofKind);if(!l||!this.field(o[o.oneofKind],l,n,t))return!1}for(const a of this.fields)if(a.oneof===void 0&&!this.field(e[a.localName],a,n,t))return!1;return!0}field(e,t,n,r){let s=t.repeat;switch(t.kind){case"scalar":return e===void 0?t.opt:s?this.scalars(e,t.T,r,t.L):this.scalar(e,t.T,t.L);case"enum":return e===void 0?t.opt:s?this.scalars(e,u.INT32,r):this.scalar(e,u.INT32);case"message":return e===void 0?!0:s?this.messages(e,t.T(),n,r):this.message(e,t.T(),n,r);case"map":if(typeof e!="object"||e===null)return!1;if(r<2)return!0;if(!this.mapKeys(e,t.K,r))return!1;switch(t.V.kind){case"scalar":return this.scalars(Object.values(e),t.V.T,r,t.V.L);case"enum":return this.scalars(Object.values(e),u.INT32,r);case"message":return this.messages(Object.values(e),t.V.T(),n,r)}break}return!0}message(e,t,n,r){return n?t.isAssignable(e,r):t.is(e,r)}messages(e,t,n,r){if(!Array.isArray(e))return!1;if(r<2)return!0;if(n){for(let s=0;s<e.length&&s<r;s++)if(!t.isAssignable(e[s],r-1))return!1}else for(let s=0;s<e.length&&s<r;s++)if(!t.is(e[s],r-1))return!1;return!0}scalar(e,t,n){let r=typeof e;switch(t){case u.UINT64:case u.FIXED64:case u.INT64:case u.SFIXED64:case u.SINT64:switch(n){case K.BIGINT:return r=="bigint";case K.NUMBER:return r=="number"&&!isNaN(e);default:return r=="string"}case u.BOOL:return r=="boolean";case u.STRING:return r=="string";case u.BYTES:return e instanceof Uint8Array;case u.DOUBLE:case u.FLOAT:return r=="number"&&!isNaN(e);default:return r=="number"&&Number.isInteger(e)}}scalars(e,t,n,r){if(!Array.isArray(e))return!1;if(n<2)return!0;if(Array.isArray(e)){for(let s=0;s<e.length&&s<n;s++)if(!this.scalar(e[s],t,r))return!1}return!0}mapKeys(e,t,n){let r=Object.keys(e);switch(t){case u.INT32:case u.FIXED32:case u.SFIXED32:case u.SINT32:case u.UINT32:return this.scalars(r.slice(0,n).map(s=>parseInt(s)),t,n);case u.BOOL:return this.scalars(r.slice(0,n).map(s=>s=="true"?!0:s=="false"?!1:s),t,n);default:return this.scalars(r,t,n,K.STRING)}}}function P(i,e){switch(e){case K.BIGINT:return i.toBigInt();case K.NUMBER:return i.toNumber();default:return i.toString()}}class jt{constructor(e){this.info=e}prepare(){var e;if(this.fMap===void 0){this.fMap={};const t=(e=this.info.fields)!==null&&e!==void 0?e:[];for(const n of t)this.fMap[n.name]=n,this.fMap[n.jsonName]=n,this.fMap[n.localName]=n}}assert(e,t,n){if(!e){let r=je(n);throw(r=="number"||r=="boolean")&&(r=n.toString()),new Error(`Cannot parse JSON ${r} for ${this.info.typeName}#${t}`)}}read(e,t,n){this.prepare();const r=[];for(const[s,a]of Object.entries(e)){const o=this.fMap[s];if(!o){if(!n.ignoreUnknownFields)throw new Error(`Found unknown field while reading ${this.info.typeName} from JSON format. JSON key: ${s}`);continue}const l=o.localName;let c;if(o.oneof){if(a===null&&(o.kind!=="enum"||o.T()[0]!=="google.protobuf.NullValue"))continue;if(r.includes(o.oneof))throw new Error(`Multiple members of the oneof group "${o.oneof}" of ${this.info.typeName} are present in JSON.`);r.push(o.oneof),c=t[o.oneof]={oneofKind:l}}else c=t;if(o.kind=="map"){if(a===null)continue;this.assert(kt(a),o.name,a);const h=c[l];for(const[p,y]of Object.entries(a)){this.assert(y!==null,o.name+" map value",null);let U;switch(o.V.kind){case"message":U=o.V.T().internalJsonRead(y,n);break;case"enum":if(U=this.enum(o.V.T(),y,o.name,n.ignoreUnknownFields),U===!1)continue;break;case"scalar":U=this.scalar(y,o.V.T,o.V.L,o.name);break}this.assert(U!==void 0,o.name+" map value",y);let L=p;o.K==u.BOOL&&(L=L=="true"?!0:L=="false"?!1:L),L=this.scalar(L,o.K,K.STRING,o.name).toString(),h[L]=U}}else if(o.repeat){if(a===null)continue;this.assert(Array.isArray(a),o.name,a);const h=c[l];for(const p of a){this.assert(p!==null,o.name,null);let y;switch(o.kind){case"message":y=o.T().internalJsonRead(p,n);break;case"enum":if(y=this.enum(o.T(),p,o.name,n.ignoreUnknownFields),y===!1)continue;break;case"scalar":y=this.scalar(p,o.T,o.L,o.name);break}this.assert(y!==void 0,o.name,a),h.push(y)}}else switch(o.kind){case"message":if(a===null&&o.T().typeName!="google.protobuf.Value"){this.assert(o.oneof===void 0,o.name+" (oneof member)",null);continue}c[l]=o.T().internalJsonRead(a,n,c[l]);break;case"enum":let h=this.enum(o.T(),a,o.name,n.ignoreUnknownFields);if(h===!1)continue;c[l]=h;break;case"scalar":c[l]=this.scalar(a,o.T,o.L,o.name);break}}}enum(e,t,n,r){if(e[0]=="google.protobuf.NullValue"&&b(t===null||t==="NULL_VALUE",`Unable to parse field ${this.info.typeName}#${n}, enum ${e[0]} only accepts null.`),t===null)return 0;switch(typeof t){case"number":return b(Number.isInteger(t),`Unable to parse field ${this.info.typeName}#${n}, enum can only be integral number, got ${t}.`),t;case"string":let s=t;e[2]&&t.substring(0,e[2].length)===e[2]&&(s=t.substring(e[2].length));let a=e[1][s];return typeof a>"u"&&r?!1:(b(typeof a=="number",`Unable to parse field ${this.info.typeName}#${n}, enum ${e[0]} has no value for "${t}".`),a)}b(!1,`Unable to parse field ${this.info.typeName}#${n}, cannot parse enum value from ${typeof t}".`)}scalar(e,t,n,r){let s;try{switch(t){case u.DOUBLE:case u.FLOAT:if(e===null)return 0;if(e==="NaN")return Number.NaN;if(e==="Infinity")return Number.POSITIVE_INFINITY;if(e==="-Infinity")return Number.NEGATIVE_INFINITY;if(e===""){s="empty string";break}if(typeof e=="string"&&e.trim().length!==e.length){s="extra whitespace";break}if(typeof e!="string"&&typeof e!="number")break;let a=Number(e);if(Number.isNaN(a)){s="not a number";break}if(!Number.isFinite(a)){s="too large or small";break}return t==u.FLOAT&&Le(a),a;case u.INT32:case u.FIXED32:case u.SFIXED32:case u.SINT32:case u.UINT32:if(e===null)return 0;let o;if(typeof e=="number"?o=e:e===""?s="empty string":typeof e=="string"&&(e.trim().length!==e.length?s="extra whitespace":o=Number(e)),o===void 0)break;return t==u.UINT32?Ie(o):ge(o),o;case u.INT64:case u.SFIXED64:case u.SINT64:if(e===null)return P(D.ZERO,n);if(typeof e!="number"&&typeof e!="string")break;return P(D.from(e),n);case u.FIXED64:case u.UINT64:if(e===null)return P(C.ZERO,n);if(typeof e!="number"&&typeof e!="string")break;return P(C.from(e),n);case u.BOOL:if(e===null)return!1;if(typeof e!="boolean")break;return e;case u.STRING:if(e===null)return"";if(typeof e!="string"){s="extra whitespace";break}try{encodeURIComponent(e)}catch(l){l="invalid UTF8";break}return e;case u.BYTES:if(e===null||e==="")return new Uint8Array(0);if(typeof e!="string")break;return Pe(e)}}catch(a){s=a.message}this.assert(!1,r+(s?" - "+s:""),e)}}class Pt{constructor(e){var t;this.fields=(t=e.fields)!==null&&t!==void 0?t:[]}write(e,t){const n={},r=e;for(const s of this.fields){if(!s.oneof){let c=this.field(s,r[s.localName],t);c!==void 0&&(n[t.useProtoFieldName?s.name:s.jsonName]=c);continue}const a=r[s.oneof];if(a.oneofKind!==s.localName)continue;const o=s.kind=="scalar"||s.kind=="enum"?Object.assign(Object.assign({},t),{emitDefaultValues:!0}):t;let l=this.field(s,a[s.localName],o);b(l!==void 0),n[t.useProtoFieldName?s.name:s.jsonName]=l}return n}field(e,t,n){let r;if(e.kind=="map"){b(typeof t=="object"&&t!==null);const s={};switch(e.V.kind){case"scalar":for(const[l,c]of Object.entries(t)){const h=this.scalar(e.V.T,c,e.name,!1,!0);b(h!==void 0),s[l.toString()]=h}break;case"message":const a=e.V.T();for(const[l,c]of Object.entries(t)){const h=this.message(a,c,e.name,n);b(h!==void 0),s[l.toString()]=h}break;case"enum":const o=e.V.T();for(const[l,c]of Object.entries(t)){b(c===void 0||typeof c=="number");const h=this.enum(o,c,e.name,!1,!0,n.enumAsInteger);b(h!==void 0),s[l.toString()]=h}break}(n.emitDefaultValues||Object.keys(s).length>0)&&(r=s)}else if(e.repeat){b(Array.isArray(t));const s=[];switch(e.kind){case"scalar":for(let l=0;l<t.length;l++){const c=this.scalar(e.T,t[l],e.name,e.opt,!0);b(c!==void 0),s.push(c)}break;case"enum":const a=e.T();for(let l=0;l<t.length;l++){b(t[l]===void 0||typeof t[l]=="number");const c=this.enum(a,t[l],e.name,e.opt,!0,n.enumAsInteger);b(c!==void 0),s.push(c)}break;case"message":const o=e.T();for(let l=0;l<t.length;l++){const c=this.message(o,t[l],e.name,n);b(c!==void 0),s.push(c)}break}(n.emitDefaultValues||s.length>0||n.emitDefaultValues)&&(r=s)}else switch(e.kind){case"scalar":r=this.scalar(e.T,t,e.name,e.opt,n.emitDefaultValues);break;case"enum":r=this.enum(e.T(),t,e.name,e.opt,n.emitDefaultValues,n.enumAsInteger);break;case"message":r=this.message(e.T(),t,e.name,n);break}return r}enum(e,t,n,r,s,a){if(e[0]=="google.protobuf.NullValue")return!s&&!r?void 0:null;if(t===void 0){b(r);return}if(!(t===0&&!s&&!r))return b(typeof t=="number"),b(Number.isInteger(t)),a||!e[1].hasOwnProperty(t)?t:e[2]?e[2]+e[1][t]:e[1][t]}message(e,t,n,r){return t===void 0?r.emitDefaultValues?null:void 0:e.internalJsonWrite(t,r)}scalar(e,t,n,r,s){if(t===void 0){b(r);return}const a=s||r;switch(e){case u.INT32:case u.SFIXED32:case u.SINT32:return t===0?a?0:void 0:(ge(t),t);case u.FIXED32:case u.UINT32:return t===0?a?0:void 0:(Ie(t),t);case u.FLOAT:Le(t);case u.DOUBLE:return t===0?a?0:void 0:(b(typeof t=="number"),Number.isNaN(t)?"NaN":t===Number.POSITIVE_INFINITY?"Infinity":t===Number.NEGATIVE_INFINITY?"-Infinity":t);case u.STRING:return t===""?a?"":void 0:(b(typeof t=="string"),t);case u.BOOL:return t===!1?a?!1:void 0:(b(typeof t=="boolean"),t);case u.UINT64:case u.FIXED64:b(typeof t=="number"||typeof t=="string"||typeof t=="bigint");let o=C.from(t);return o.isZero()&&!a?void 0:o.toString();case u.INT64:case u.SFIXED64:case u.SINT64:b(typeof t=="number"||typeof t=="string"||typeof t=="bigint");let l=D.from(t);return l.isZero()&&!a?void 0:l.toString();case u.BYTES:return b(t instanceof Uint8Array),t.byteLength?We(t):a?"":void 0}}}function Re(i,e=K.STRING){switch(i){case u.BOOL:return!1;case u.UINT64:case u.FIXED64:return P(C.ZERO,e);case u.INT64:case u.SFIXED64:case u.SINT64:return P(D.ZERO,e);case u.DOUBLE:case u.FLOAT:return 0;case u.BYTES:return new Uint8Array(0);case u.STRING:return"";default:return 0}}class Wt{constructor(e){this.info=e}prepare(){var e;if(!this.fieldNoToField){const t=(e=this.info.fields)!==null&&e!==void 0?e:[];this.fieldNoToField=new Map(t.map(n=>[n.no,n]))}}read(e,t,n,r){this.prepare();const s=r===void 0?e.len:e.pos+r;for(;e.pos<s;){const[a,o]=e.tag(),l=this.fieldNoToField.get(a);if(!l){let y=n.readUnknownField;if(y=="throw")throw new Error(`Unknown field ${a} (wire type ${o}) for ${this.info.typeName}`);let U=e.skip(o);y!==!1&&(y===!0?k.onRead:y)(this.info.typeName,t,a,o,U);continue}let c=t,h=l.repeat,p=l.localName;switch(l.oneof&&(c=c[l.oneof],c.oneofKind!==p&&(c=t[l.oneof]={oneofKind:p})),l.kind){case"scalar":case"enum":let y=l.kind=="enum"?u.INT32:l.T,U=l.kind=="scalar"?l.L:void 0;if(h){let F=c[p];if(o==m.LengthDelimited&&y!=u.STRING&&y!=u.BYTES){let q=e.uint32()+e.pos;for(;e.pos<q;)F.push(this.scalar(e,y,U))}else F.push(this.scalar(e,y,U))}else c[p]=this.scalar(e,y,U);break;case"message":if(h){let F=c[p],q=l.T().internalBinaryRead(e,e.uint32(),n);F.push(q)}else c[p]=l.T().internalBinaryRead(e,e.uint32(),n,c[p]);break;case"map":let[L,ne]=this.mapEntry(l,e,n);c[p][L]=ne;break}}}mapEntry(e,t,n){let r=t.uint32(),s=t.pos+r,a,o;for(;t.pos<s;){let[l,c]=t.tag();switch(l){case 1:e.K==u.BOOL?a=t.bool().toString():a=this.scalar(t,e.K,K.STRING);break;case 2:switch(e.V.kind){case"scalar":o=this.scalar(t,e.V.T,e.V.L);break;case"enum":o=t.int32();break;case"message":o=e.V.T().internalBinaryRead(t,t.uint32(),n);break}break;default:throw new Error(`Unknown field ${l} (wire type ${c}) in map entry for ${this.info.typeName}#${e.name}`)}}if(a===void 0){let l=Re(e.K);a=e.K==u.BOOL?l.toString():l}if(o===void 0)switch(e.V.kind){case"scalar":o=Re(e.V.T,e.V.L);break;case"enum":o=0;break;case"message":o=e.V.T().create();break}return[a,o]}scalar(e,t,n){switch(t){case u.INT32:return e.int32();case u.STRING:return e.string();case u.BOOL:return e.bool();case u.DOUBLE:return e.double();case u.FLOAT:return e.float();case u.INT64:return P(e.int64(),n);case u.UINT64:return P(e.uint64(),n);case u.FIXED64:return P(e.fixed64(),n);case u.FIXED32:return e.fixed32();case u.BYTES:return e.bytes();case u.UINT32:return e.uint32();case u.SFIXED32:return e.sfixed32();case u.SFIXED64:return P(e.sfixed64(),n);case u.SINT32:return e.sint32();case u.SINT64:return P(e.sint64(),n)}}}class qt{constructor(e){this.info=e}prepare(){if(!this.fields){const e=this.info.fields?this.info.fields.concat():[];this.fields=e.sort((t,n)=>t.no-n.no)}}write(e,t,n){this.prepare();for(const s of this.fields){let a,o,l=s.repeat,c=s.localName;if(s.oneof){const h=e[s.oneof];if(h.oneofKind!==c)continue;a=h[c],o=!0}else a=e[c],o=!1;switch(s.kind){case"scalar":case"enum":let h=s.kind=="enum"?u.INT32:s.T;if(l)if(b(Array.isArray(a)),l==Te.PACKED)this.packed(t,h,s.no,a);else for(const p of a)this.scalar(t,h,s.no,p,!0);else a===void 0?b(s.opt):this.scalar(t,h,s.no,a,o||s.opt);break;case"message":if(l){b(Array.isArray(a));for(const p of a)this.message(t,n,s.T(),s.no,p)}else this.message(t,n,s.T(),s.no,a);break;case"map":b(typeof a=="object"&&a!==null);for(const[p,y]of Object.entries(a))this.mapEntry(t,n,s,p,y);break}}let r=n.writeUnknownFields;r!==!1&&(r===!0?k.onWrite:r)(this.info.typeName,e,t)}mapEntry(e,t,n,r,s){e.tag(n.no,m.LengthDelimited),e.fork();let a=r;switch(n.K){case u.INT32:case u.FIXED32:case u.UINT32:case u.SFIXED32:case u.SINT32:a=Number.parseInt(r);break;case u.BOOL:b(r=="true"||r=="false"),a=r=="true";break}switch(this.scalar(e,n.K,1,a,!0),n.V.kind){case"scalar":this.scalar(e,n.V.T,2,s,!0);break;case"enum":this.scalar(e,u.INT32,2,s,!0);break;case"message":this.message(e,t,n.V.T(),2,s);break}e.join()}message(e,t,n,r,s){s!==void 0&&(n.internalBinaryWrite(s,e.tag(r,m.LengthDelimited).fork(),t),e.join())}scalar(e,t,n,r,s){let[a,o,l]=this.scalarInfo(t,r);(!l||s)&&(e.tag(n,a),e[o](r))}packed(e,t,n,r){if(!r.length)return;b(t!==u.BYTES&&t!==u.STRING),e.tag(n,m.LengthDelimited),e.fork();let[,s]=this.scalarInfo(t);for(let a=0;a<r.length;a++)e[s](r[a]);e.join()}scalarInfo(e,t){let n=m.Varint,r,s=t===void 0,a=t===0;switch(e){case u.INT32:r="int32";break;case u.STRING:a=s||!t.length,n=m.LengthDelimited,r="string";break;case u.BOOL:a=t===!1,r="bool";break;case u.UINT32:r="uint32";break;case u.DOUBLE:n=m.Bit64,r="double";break;case u.FLOAT:n=m.Bit32,r="float";break;case u.INT64:a=s||D.from(t).isZero(),r="int64";break;case u.UINT64:a=s||C.from(t).isZero(),r="uint64";break;case u.FIXED64:a=s||C.from(t).isZero(),n=m.Bit64,r="fixed64";break;case u.BYTES:a=s||!t.byteLength,n=m.LengthDelimited,r="bytes";break;case u.FIXED32:n=m.Bit32,r="fixed32";break;case u.SFIXED32:n=m.Bit32,r="sfixed32";break;case u.SFIXED64:a=s||D.from(t).isZero(),n=m.Bit64,r="sfixed64";break;case u.SINT32:r="sint32";break;case u.SINT64:a=s||D.from(t).isZero(),r="sint64";break}return[n,r,s||a]}}function Kt(i){const e=i.messagePrototype?Object.create(i.messagePrototype):Object.defineProperty({},Qe,{value:i});for(let t of i.fields){let n=t.localName;if(!t.opt)if(t.oneof)e[t.oneof]={oneofKind:void 0};else if(t.repeat)e[n]=[];else switch(t.kind){case"scalar":e[n]=Re(t.T,t.L);break;case"enum":e[n]=0;break;case"map":e[n]={};break}}return e}function v(i,e,t){let n,r=t,s;for(let a of i.fields){let o=a.localName;if(a.oneof){const l=r[a.oneof];if((l==null?void 0:l.oneofKind)==null)continue;if(n=l[o],s=e[a.oneof],s.oneofKind=l.oneofKind,n==null){delete s[o];continue}}else if(n=r[o],s=e,n==null)continue;switch(a.repeat&&(s[o].length=n.length),a.kind){case"scalar":case"enum":if(a.repeat)for(let c=0;c<n.length;c++)s[o][c]=n[c];else s[o]=n;break;case"message":let l=a.T();if(a.repeat)for(let c=0;c<n.length;c++)s[o][c]=l.create(n[c]);else s[o]===void 0?s[o]=l.create(n):l.mergePartial(s[o],n);break;case"map":switch(a.V.kind){case"scalar":case"enum":Object.assign(s[o],n);break;case"message":let c=a.V.T();for(let h of Object.keys(n))s[o][h]=c.create(n[h]);break}break}}}function Xt(i,e,t){if(e===t)return!0;if(!e||!t)return!1;for(let n of i.fields){let r=n.localName,s=n.oneof?e[n.oneof][r]:e[r],a=n.oneof?t[n.oneof][r]:t[r];switch(n.kind){case"enum":case"scalar":let o=n.kind=="enum"?u.INT32:n.T;if(!(n.repeat?tt(o,s,a):et(o,s,a)))return!1;break;case"map":if(!(n.V.kind=="message"?nt(n.V.T(),Oe(s),Oe(a)):tt(n.V.kind=="enum"?u.INT32:n.V.T,Oe(s),Oe(a))))return!1;break;case"message":let l=n.T();if(!(n.repeat?nt(l,s,a):l.equals(s,a)))return!1;break}}return!0}const Oe=Object.values;function et(i,e,t){if(e===t)return!0;if(i!==u.BYTES)return!1;let n=e,r=t;if(n.length!==r.length)return!1;for(let s=0;s<n.length;s++)if(n[s]!=r[s])return!1;return!0}function tt(i,e,t){if(e.length!==t.length)return!1;for(let n=0;n<e.length;n++)if(!et(i,e[n],t[n]))return!1;return!0}function nt(i,e,t){if(e.length!==t.length)return!1;for(let n=0;n<e.length;n++)if(!i.equals(e[n],t[n]))return!1;return!0}const Gt=Object.getOwnPropertyDescriptors(Object.getPrototypeOf({}));class M{constructor(e,t,n){this.defaultCheckDepth=16,this.typeName=e,this.fields=t.map(Mt),this.options=n??{},this.messagePrototype=Object.create(null,Object.assign(Object.assign({},Gt),{[Qe]:{value:this}})),this.refTypeCheck=new $t(this),this.refJsonReader=new jt(this),this.refJsonWriter=new Pt(this),this.refBinReader=new Wt(this),this.refBinWriter=new qt(this)}create(e){let t=Kt(this);return e!==void 0&&v(this,t,e),t}clone(e){let t=this.create();return v(this,t,e),t}equals(e,t){return Xt(this,e,t)}is(e,t=this.defaultCheckDepth){return this.refTypeCheck.is(e,t,!1)}isAssignable(e,t=this.defaultCheckDepth){return this.refTypeCheck.is(e,t,!0)}mergePartial(e,t){v(this,e,t)}fromBinary(e,t){let n=Bt(t);return this.internalBinaryRead(n.readerFactory(e),e.byteLength,n)}fromJson(e,t){return this.internalJsonRead(e,Ct(t))}fromJsonString(e,t){let n=JSON.parse(e);return this.fromJson(n,t)}toJson(e,t){return this.internalJsonWrite(e,vt(t))}toJsonString(e,t){var n;let r=this.toJson(e,t);return JSON.stringify(r,null,(n=t==null?void 0:t.prettySpaces)!==null&&n!==void 0?n:0)}toBinary(e,t){let n=xt(t);return this.internalBinaryWrite(e,n.writerFactory(),n).finish()}internalJsonRead(e,t,n){if(e!==null&&typeof e=="object"&&!Array.isArray(e)){let r=n??this.create();return this.refJsonReader.read(e,r,t),r}throw new Error(`Unable to parse message ${this.typeName} from JSON ${je(e)}.`)}internalJsonWrite(e,t){return this.refJsonWriter.write(e,t)}internalBinaryWrite(e,t,n){return this.refBinWriter.write(e,t,n),t}internalBinaryRead(e,t,n,r){let s=r??this.create();return this.refBinReader.read(e,s,n,t),s}}function Jt(i,e){var t,n,r;let s=i;return s.service=e,s.localName=(t=s.localName)!==null&&t!==void 0?t:Ue(s.name),s.serverStreaming=!!s.serverStreaming,s.clientStreaming=!!s.clientStreaming,s.options=(n=s.options)!==null&&n!==void 0?n:{},s.idempotency=(r=s.idempotency)!==null&&r!==void 0?r:void 0,s}class xe{constructor(e,t,n){this.typeName=e,this.methods=t.map(r=>Jt(r,this)),this.options=n??{}}}class I extends Error{constructor(e,t="UNKNOWN",n){super(e),this.name="RpcError",Object.setPrototypeOf(this,new.target.prototype),this.code=t,this.meta=n??{}}toString(){const e=[this.name+": "+this.message];this.code&&(e.push(""),e.push("Code: "+this.code)),this.serviceName&&this.methodName&&e.push("Method: "+this.serviceName+"/"+this.methodName);let t=Object.entries(this.meta);if(t.length){e.push(""),e.push("Meta:");for(let[n,r]of t)e.push(` ${n}: ${r}`)}return e.join(`
|
|
4
4
|
`)}}function Ht(i,e){if(!e)return i;let t={};Be(i,t),Be(e,t);for(let n of Object.keys(e)){let r=e[n];switch(n){case"jsonOptions":t.jsonOptions=St(i.jsonOptions,t.jsonOptions);break;case"binaryOptions":t.binaryOptions=Et(i.binaryOptions,t.binaryOptions);break;case"meta":t.meta={},Be(i.meta,t.meta),Be(e.meta,t.meta);break;case"interceptors":t.interceptors=i.interceptors?i.interceptors.concat(r):r.concat();break}}return t}function Be(i,e){if(!i)return;let t=e;for(let[n,r]of Object.entries(i))r instanceof Date?t[n]=new Date(r.getTime()):Array.isArray(r)?t[n]=r.concat():t[n]=r}var $;(function(i){i[i.PENDING=0]="PENDING",i[i.REJECTED=1]="REJECTED",i[i.RESOLVED=2]="RESOLVED"})($||($={}));class Q{constructor(e=!0){this._state=$.PENDING,this._promise=new Promise((t,n)=>{this._resolve=t,this._reject=n}),e&&this._promise.catch(t=>{})}get state(){return this._state}get promise(){return this._promise}resolve(e){if(this.state!==$.PENDING)throw new Error(`cannot resolve ${$[this.state].toLowerCase()}`);this._resolve(e),this._state=$.RESOLVED}reject(e){if(this.state!==$.PENDING)throw new Error(`cannot reject ${$[this.state].toLowerCase()}`);this._reject(e),this._state=$.REJECTED}resolvePending(e){this._state===$.PENDING&&this.resolve(e)}rejectPending(e){this._state===$.PENDING&&this.reject(e)}}class Zt{constructor(){this._lis={nxt:[],msg:[],err:[],cmp:[]},this._closed=!1}onNext(e){return this.addLis(e,this._lis.nxt)}onMessage(e){return this.addLis(e,this._lis.msg)}onError(e){return this.addLis(e,this._lis.err)}onComplete(e){return this.addLis(e,this._lis.cmp)}addLis(e,t){return t.push(e),()=>{let n=t.indexOf(e);n>=0&&t.splice(n,1)}}clearLis(){for(let e of Object.values(this._lis))e.splice(0,e.length)}get closed(){return this._closed!==!1}notifyNext(e,t,n){b((e?1:0)+(t?1:0)+(n?1:0)<=1,"only one emission at a time"),e&&this.notifyMessage(e),t&&this.notifyError(t),n&&this.notifyComplete()}notifyMessage(e){b(!this.closed,"stream is closed"),this.pushIt({value:e,done:!1}),this._lis.msg.forEach(t=>t(e)),this._lis.nxt.forEach(t=>t(e,void 0,!1))}notifyError(e){b(!this.closed,"stream is closed"),this._closed=e,this.pushIt(e),this._lis.err.forEach(t=>t(e)),this._lis.nxt.forEach(t=>t(void 0,e,!1)),this.clearLis()}notifyComplete(){b(!this.closed,"stream is closed"),this._closed=!0,this.pushIt({value:null,done:!0}),this._lis.cmp.forEach(e=>e()),this._lis.nxt.forEach(e=>e(void 0,void 0,!0)),this.clearLis()}[Symbol.asyncIterator](){return this._itState||(this._itState={q:[]}),this._closed===!0?this.pushIt({value:null,done:!0}):this._closed!==!1&&this.pushIt(this._closed),{next:()=>{let e=this._itState;b(e,"bad state"),b(!e.p,"iterator contract broken");let t=e.q.shift();return t?"value"in t?Promise.resolve(t):Promise.reject(t):(e.p=new Q,e.p.promise)}}}pushIt(e){let t=this._itState;if(t)if(t.p){const n=t.p;b(n.state==$.PENDING,"iterator contract broken"),"value"in e?n.resolve(e):n.reject(e),delete t.p}else t.q.push(e)}}var Yt=function(i,e,t,n){function r(s){return s instanceof t?s:new t(function(a){a(s)})}return new(t||(t=Promise))(function(s,a){function o(h){try{c(n.next(h))}catch(p){a(p)}}function l(h){try{c(n.throw(h))}catch(p){a(p)}}function c(h){h.done?s(h.value):r(h.value).then(o,l)}c((n=n.apply(i,e||[])).next())})};class zt{constructor(e,t,n,r,s,a,o){this.method=e,this.requestHeaders=t,this.request=n,this.headers=r,this.response=s,this.status=a,this.trailers=o}then(e,t){return this.promiseFinished().then(n=>e?Promise.resolve(e(n)):n,n=>t?Promise.resolve(t(n)):Promise.reject(n))}promiseFinished(){return Yt(this,void 0,void 0,function*(){let[e,t,n,r]=yield Promise.all([this.headers,this.response,this.status,this.trailers]);return{method:this.method,requestHeaders:this.requestHeaders,request:this.request,headers:e,response:t,status:n,trailers:r}})}}var Qt=function(i,e,t,n){function r(s){return s instanceof t?s:new t(function(a){a(s)})}return new(t||(t=Promise))(function(s,a){function o(h){try{c(n.next(h))}catch(p){a(p)}}function l(h){try{c(n.throw(h))}catch(p){a(p)}}function c(h){h.done?s(h.value):r(h.value).then(o,l)}c((n=n.apply(i,e||[])).next())})};class en{constructor(e,t,n,r,s,a,o){this.method=e,this.requestHeaders=t,this.request=n,this.headers=r,this.responses=s,this.status=a,this.trailers=o}then(e,t){return this.promiseFinished().then(n=>e?Promise.resolve(e(n)):n,n=>t?Promise.resolve(t(n)):Promise.reject(n))}promiseFinished(){return Qt(this,void 0,void 0,function*(){let[e,t,n]=yield Promise.all([this.headers,this.status,this.trailers]);return{method:this.method,requestHeaders:this.requestHeaders,request:this.request,headers:e,status:t,trailers:n}})}}function ee(i,e,t,n,r){var s;{let a=(o,l,c)=>e.unary(o,l,c);for(const o of((s=n.interceptors)!==null&&s!==void 0?s:[]).filter(l=>l.interceptUnary).reverse()){const l=a;a=(c,h,p)=>o.interceptUnary(l,c,h,p)}return a(t,r,n)}}var f;(function(i){i[i.OK=0]="OK",i[i.CANCELLED=1]="CANCELLED",i[i.UNKNOWN=2]="UNKNOWN",i[i.INVALID_ARGUMENT=3]="INVALID_ARGUMENT",i[i.DEADLINE_EXCEEDED=4]="DEADLINE_EXCEEDED",i[i.NOT_FOUND=5]="NOT_FOUND",i[i.ALREADY_EXISTS=6]="ALREADY_EXISTS",i[i.PERMISSION_DENIED=7]="PERMISSION_DENIED",i[i.UNAUTHENTICATED=16]="UNAUTHENTICATED",i[i.RESOURCE_EXHAUSTED=8]="RESOURCE_EXHAUSTED",i[i.FAILED_PRECONDITION=9]="FAILED_PRECONDITION",i[i.ABORTED=10]="ABORTED",i[i.OUT_OF_RANGE=11]="OUT_OF_RANGE",i[i.UNIMPLEMENTED=12]="UNIMPLEMENTED",i[i.INTERNAL=13]="INTERNAL",i[i.UNAVAILABLE=14]="UNAVAILABLE",i[i.DATA_LOSS=15]="DATA_LOSS"})(f||(f={}));var tn=function(i,e,t,n){function r(s){return s instanceof t?s:new t(function(a){a(s)})}return new(t||(t=Promise))(function(s,a){function o(h){try{c(n.next(h))}catch(p){a(p)}}function l(h){try{c(n.throw(h))}catch(p){a(p)}}function c(h){h.done?s(h.value):r(h.value).then(o,l)}c((n=n.apply(i,e||[])).next())})};function it(i,e,t,n,r){if(n)for(let[s,a]of Object.entries(n))if(typeof a=="string")i.append(s,a);else for(let o of a)i.append(s,o);if(i.set("Content-Type",e==="text"?"application/grpc-web-text":"application/grpc-web+proto"),e=="text"&&i.set("Accept","application/grpc-web-text"),i.set("X-Grpc-Web","1"),typeof t=="number"){if(t<=0)throw new I(`timeout ${t} ms exceeded`,f[f.DEADLINE_EXCEEDED]);i.set("grpc-timeout",`${t}m`)}else if(t){const s=t.getTime(),a=Date.now();if(s<=a)throw new I(`deadline ${t} exceeded`,f[f.DEADLINE_EXCEEDED]);i.set("grpc-timeout",`${s-a}m`)}return i}function rt(i,e){let t=new Uint8Array(5+i.length);t[0]=W.DATA;for(let n=i.length,r=4;r>0;r--)t[r]=n%256,n>>>=8;return t.set(i,5),e==="binary"?t:We(t)}function _e(i,e,t){if(arguments.length===1){let l=i,c;try{c=l.type}catch{}switch(c){case"error":case"opaque":case"opaqueredirect":throw new I(`fetch response type ${l.type}`,f[f.UNKNOWN])}return _e(an(l.headers),l.status,l.statusText)}let n=i,r=e>=200&&e<300,s=ct(n),[a,o]=lt(n);return(a===void 0||a===f.OK)&&!r&&(a=on(e),o=t),[a,o,s]}function st(i){let e=sn(i),[t,n]=lt(e),r=ct(e);return[t??f.OK,n,r]}var W;(function(i){i[i.DATA=0]="DATA",i[i.TRAILER=128]="TRAILER"})(W||(W={}));function at(i,e,t){return tn(this,void 0,void 0,function*(){let n,r="",s=new Uint8Array(0),a=rn(e);if(nn(i)){let o=i.getReader();n={next:()=>o.read()}}else n=i[Symbol.asyncIterator]();for(;;){let o=yield n.next();if(o.value!==void 0){if(a==="text"){for(let c=0;c<o.value.length;c++)r+=String.fromCharCode(o.value[c]);let l=r.length-r.length%4;if(l===0)continue;s=ot(s,Pe(r.substring(0,l))),r=r.substring(l)}else s=ot(s,o.value);for(;s.length>=5&&s[0]===W.DATA;){let l=0;for(let c=1;c<5;c++)l=(l<<8)+s[c];if(s.length-5>=l)t(W.DATA,s.subarray(5,5+l)),s=s.subarray(5+l);else break}}if(o.done){if(s.length===0)break;if(s[0]!==W.TRAILER||s.length<5)throw new I("premature EOF",f[f.DATA_LOSS]);t(W.TRAILER,s.subarray(5));break}}})}const nn=i=>typeof i.getReader=="function";function ot(i,e){let t=new Uint8Array(i.length+e.length);return t.set(i),t.set(e,i.length),t}function rn(i){switch(i){case"application/grpc-web-text":case"application/grpc-web-text+proto":return"text";case"application/grpc-web":case"application/grpc-web+proto":return"binary";case void 0:case null:throw new I("missing response content type",f[f.INTERNAL]);default:throw new I("unexpected response content type: "+i,f[f.INTERNAL])}}function lt(i){let e,t,n=i["grpc-message"];if(n!==void 0){if(Array.isArray(n))return[f.INTERNAL,"invalid grpc-web message"];t=n}let r=i["grpc-status"];if(r!==void 0){if(Array.isArray(r))return[f.INTERNAL,"invalid grpc-web status"];if(e=parseInt(r,10),f[e]===void 0)return[f.INTERNAL,"invalid grpc-web status"]}return[e,t]}function ct(i){let e={};for(let[t,n]of Object.entries(i))switch(t){case"grpc-message":case"grpc-status":case"content-type":break;default:e[t]=n}return e}function sn(i){let e={};for(let t of String.fromCharCode.apply(String,i).trim().split(`\r
|
|
5
|
-
`)){if(t=="")continue;let[n,...r]=t.split(":");const s=r.join(":").trim();n=n.trim();let a=e[n];typeof a=="string"?e[n]=[a,s]:Array.isArray(a)?a.push(s):e[n]=s}return e}function an(i){let e={};return i.forEach((t,n)=>{let r=e[n];typeof r=="string"?e[n]=[r,t]:Array.isArray(r)?r.push(t):e[n]=t}),e}function on(i){switch(i){case 200:return f.OK;case 400:return f.INVALID_ARGUMENT;case 401:return f.UNAUTHENTICATED;case 403:return f.PERMISSION_DENIED;case 404:return f.NOT_FOUND;case 409:return f.ABORTED;case 412:return f.FAILED_PRECONDITION;case 429:return f.RESOURCE_EXHAUSTED;case 499:return f.CANCELLED;case 500:return f.UNKNOWN;case 501:return f.UNIMPLEMENTED;case 503:return f.UNAVAILABLE;case 504:return f.DEADLINE_EXCEEDED;default:return f.UNKNOWN}}class ln{constructor(e){this.defaultOptions=e}mergeOptions(e){return Ht(this.defaultOptions,e)}makeUrl(e,t){let n=t.baseUrl;return n.endsWith("/")&&(n=n.substring(0,n.length-1)),`${n}/${e.service.typeName}/${e.name}`}clientStreaming(e){const t=new I("Client streaming is not supported by grpc-web",f[f.UNIMPLEMENTED]);throw t.methodName=e.name,t.serviceName=e.service.typeName,t}duplex(e){const t=new I("Duplex streaming is not supported by grpc-web",f[f.UNIMPLEMENTED]);throw t.methodName=e.name,t.serviceName=e.service.typeName,t}serverStreaming(e,t,n){var r,s,a,o;let l=n,c=(r=l.format)!==null&&r!==void 0?r:"text",h=(s=l.fetchInit)!==null&&s!==void 0?s:{},p=this.makeUrl(e,l),y=e.I.toBinary(t,l.binaryOptions),U=new Q,L=new Zt,ne=!0,F,q=new Q,J,le=new Q;return globalThis.fetch(p,Object.assign(Object.assign({},h),{method:"POST",headers:it(new globalThis.Headers,c,l.timeout,l.meta),body:rt(y,c),signal:(a=n.abort)!==null&&a!==void 0?a:null})).then(N=>{let[g,R,V]=_e(N);if(U.resolve(V),g!=null&&g!==f.OK)throw new I(R??f[g],f[g],V);return g!=null&&(F={code:f[g],detail:R??f[g]}),N}).then(N=>{if(!N.body)throw new I("missing response body",f[f.INTERNAL]);return at(N.body,N.headers.get("content-type"),(g,R)=>{switch(g){case W.DATA:L.notifyMessage(e.O.fromBinary(R,l.binaryOptions)),ne=!1;break;case W.TRAILER:let V,z;[V,z,J]=st(R),F={code:f[V],detail:z??f[V]};break}})}).then(()=>{if(!J&&!ne)throw new I("missing trailers",f[f.DATA_LOSS]);if(!F)throw new I("missing status",f[f.INTERNAL]);if(F.code!=="OK")throw new I(F.detail,F.code,J);L.notifyComplete(),q.resolve(F),le.resolve(J||{})}).catch(N=>{let g;N instanceof I?g=N:N instanceof Error&&N.name==="AbortError"?g=new I(N.message,f[f.CANCELLED]):g=new I(N instanceof Error?N.message:""+N,f[f.INTERNAL]),g.methodName=e.name,g.serviceName=e.service.typeName,U.rejectPending(g),L.notifyError(g),q.rejectPending(g),le.rejectPending(g)}),new en(e,(o=l.meta)!==null&&o!==void 0?o:{},t,U.promise,L,q.promise,le.promise)}unary(e,t,n){var r,s,a,o;let l=n,c=(r=l.format)!==null&&r!==void 0?r:"text",h=(s=l.fetchInit)!==null&&s!==void 0?s:{},p=this.makeUrl(e,l),y=e.I.toBinary(t,l.binaryOptions),U=new Q,L,ne=new Q,F,q=new Q,J,le=new Q;return globalThis.fetch(p,Object.assign(Object.assign({},h),{method:"POST",headers:it(new globalThis.Headers,c,l.timeout,l.meta),body:rt(y,c),signal:(a=n.abort)!==null&&a!==void 0?a:null})).then(N=>{let[g,R,V]=_e(N);if(U.resolve(V),g!=null&&g!==f.OK)throw new I(R??f[g],f[g],V);return g!=null&&(F={code:f[g],detail:R??f[g]}),N}).then(N=>{if(!N.body)throw new I("missing response body",f[f.INTERNAL]);return at(N.body,N.headers.get("content-type"),(g,R)=>{switch(g){case W.DATA:if(L)throw new I("unary call received 2nd message",f[f.DATA_LOSS]);L=e.O.fromBinary(R,l.binaryOptions);break;case W.TRAILER:let V,z;[V,z,J]=st(R),F={code:f[V],detail:z??f[V]};break}})}).then(()=>{if(!J&&L)throw new I("missing trailers",f[f.DATA_LOSS]);if(!F)throw new I("missing status",f[f.INTERNAL]);if(!L&&F.code==="OK")throw new I("expected error status",f[f.DATA_LOSS]);if(!L)throw new I(F.detail,F.code,J);if(ne.resolve(L),F.code!=="OK")throw new I(F.detail,F.code,J);q.resolve(F),le.resolve(J||{})}).catch(N=>{let g;N instanceof I?g=N:N instanceof Error&&N.name==="AbortError"?g=new I(N.message,f[f.CANCELLED]):g=new I(N instanceof Error?N.message:""+N,f[f.INTERNAL]),g.methodName=e.name,g.serviceName=e.service.typeName,U.rejectPending(g),ne.rejectPending(g),q.rejectPending(g),le.rejectPending(g)}),new zt(e,(o=l.meta)!==null&&o!==void 0?o:{},t,U.promise,ne.promise,q.promise,le.promise)}}class cn extends M{constructor(){super("com.hamropatro.grpc.cms.CreateFolderRequest",[{no:1,name:"name",kind:"scalar",T:9},{no:2,name:"nested_folder_name",kind:"scalar",T:9},{no:3,name:"created_by",kind:"scalar",T:9}])}create(e){const t=globalThis.Object.create(this.messagePrototype);return t.name="",t.nestedFolderName="",t.createdBy="",e!==void 0&&v(this,t,e),t}internalBinaryRead(e,t,n,r){let s=r??this.create(),a=e.pos+t;for(;e.pos<a;){let[o,l]=e.tag();switch(o){case 1:s.name=e.string();break;case 2:s.nestedFolderName=e.string();break;case 3:s.createdBy=e.string();break;default:let c=n.readUnknownField;if(c==="throw")throw new globalThis.Error(`Unknown field ${o} (wire type ${l}) for ${this.typeName}`);let h=e.skip(l);c!==!1&&(c===!0?k.onRead:c)(this.typeName,s,o,l,h)}}return s}internalBinaryWrite(e,t,n){e.name!==""&&t.tag(1,m.LengthDelimited).string(e.name),e.nestedFolderName!==""&&t.tag(2,m.LengthDelimited).string(e.nestedFolderName),e.createdBy!==""&&t.tag(3,m.LengthDelimited).string(e.createdBy);let r=n.writeUnknownFields;return r!==!1&&(r==!0?k.onWrite:r)(this.typeName,e,t),t}}const ut=new cn;class un extends M{constructor(){super("com.hamropatro.grpc.cms.GetAllFoldersRequest",[{no:1,name:"cursor",kind:"scalar",T:9},{no:2,name:"limit",kind:"scalar",T:5}])}create(e){const t=globalThis.Object.create(this.messagePrototype);return t.cursor="",t.limit=0,e!==void 0&&v(this,t,e),t}internalBinaryRead(e,t,n,r){let s=r??this.create(),a=e.pos+t;for(;e.pos<a;){let[o,l]=e.tag();switch(o){case 1:s.cursor=e.string();break;case 2:s.limit=e.int32();break;default:let c=n.readUnknownField;if(c==="throw")throw new globalThis.Error(`Unknown field ${o} (wire type ${l}) for ${this.typeName}`);let h=e.skip(l);c!==!1&&(c===!0?k.onRead:c)(this.typeName,s,o,l,h)}}return s}internalBinaryWrite(e,t,n){e.cursor!==""&&t.tag(1,m.LengthDelimited).string(e.cursor),e.limit!==0&&t.tag(2,m.Varint).int32(e.limit);let r=n.writeUnknownFields;return r!==!1&&(r==!0?k.onWrite:r)(this.typeName,e,t),t}}const hn=new un;class fn extends M{constructor(){super("com.hamropatro.grpc.cms.GetAllFoldersResponse",[{no:1,name:"folder",kind:"message",repeat:1,T:()=>he},{no:2,name:"next_cursor",kind:"scalar",T:9},{no:3,name:"has_more",kind:"scalar",T:8}])}create(e){const t=globalThis.Object.create(this.messagePrototype);return t.folder=[],t.nextCursor="",t.hasMore=!1,e!==void 0&&v(this,t,e),t}internalBinaryRead(e,t,n,r){let s=r??this.create(),a=e.pos+t;for(;e.pos<a;){let[o,l]=e.tag();switch(o){case 1:s.folder.push(he.internalBinaryRead(e,e.uint32(),n));break;case 2:s.nextCursor=e.string();break;case 3:s.hasMore=e.bool();break;default:let c=n.readUnknownField;if(c==="throw")throw new globalThis.Error(`Unknown field ${o} (wire type ${l}) for ${this.typeName}`);let h=e.skip(l);c!==!1&&(c===!0?k.onRead:c)(this.typeName,s,o,l,h)}}return s}internalBinaryWrite(e,t,n){for(let s=0;s<e.folder.length;s++)he.internalBinaryWrite(e.folder[s],t.tag(1,m.LengthDelimited).fork(),n).join();e.nextCursor!==""&&t.tag(2,m.LengthDelimited).string(e.nextCursor),e.hasMore!==!1&&t.tag(3,m.Varint).bool(e.hasMore);let r=n.writeUnknownFields;return r!==!1&&(r==!0?k.onWrite:r)(this.typeName,e,t),t}}const dn=new fn;class mn extends M{constructor(){super("com.hamropatro.grpc.cms.Folder",[{no:1,name:"key",kind:"scalar",T:9},{no:2,name:"name",kind:"scalar",T:9},{no:3,name:"nested_folder_name",kind:"scalar",T:9},{no:4,name:"created_by",kind:"scalar",T:9}])}create(e){const t=globalThis.Object.create(this.messagePrototype);return t.key="",t.name="",t.nestedFolderName="",t.createdBy="",e!==void 0&&v(this,t,e),t}internalBinaryRead(e,t,n,r){let s=r??this.create(),a=e.pos+t;for(;e.pos<a;){let[o,l]=e.tag();switch(o){case 1:s.key=e.string();break;case 2:s.name=e.string();break;case 3:s.nestedFolderName=e.string();break;case 4:s.createdBy=e.string();break;default:let c=n.readUnknownField;if(c==="throw")throw new globalThis.Error(`Unknown field ${o} (wire type ${l}) for ${this.typeName}`);let h=e.skip(l);c!==!1&&(c===!0?k.onRead:c)(this.typeName,s,o,l,h)}}return s}internalBinaryWrite(e,t,n){e.key!==""&&t.tag(1,m.LengthDelimited).string(e.key),e.name!==""&&t.tag(2,m.LengthDelimited).string(e.name),e.nestedFolderName!==""&&t.tag(3,m.LengthDelimited).string(e.nestedFolderName),e.createdBy!==""&&t.tag(4,m.LengthDelimited).string(e.createdBy);let r=n.writeUnknownFields;return r!==!1&&(r==!0?k.onWrite:r)(this.typeName,e,t),t}}const he=new mn,Ce=new xe("com.hamropatro.grpc.cms.FolderService",[{name:"createFolder",options:{},I:ut,O:he},{name:"getFolders",options:{},I:hn,O:dn},{name:"updateFolder",options:{},I:he,O:he}]);class pn{constructor(e){_(this,"typeName",Ce.typeName);_(this,"methods",Ce.methods);_(this,"options",Ce.options);this._transport=e}createFolder(e,t){const n=this.methods[0],r=this._transport.mergeOptions(t);return ee("unary",this._transport,n,r,e)}getFolders(e,t){const n=this.methods[1],r=this._transport.mergeOptions(t);return ee("unary",this._transport,n,r,e)}updateFolder(e,t){const n=this.methods[2],r=this._transport.mergeOptions(t);return ee("unary",this._transport,n,r,e)}}var ve=(i=>(i[i.IMAGE=0]="IMAGE",i[i.AUDIO=1]="AUDIO",i[i.VIDEO=2]="VIDEO",i[i.ALL=3]="ALL",i))(ve||{});class gn extends M{constructor(){super("com.hamropatro.grpc.cms.CreateFileRequest",[{no:1,name:"name",kind:"scalar",T:9},{no:2,name:"folder_name",kind:"scalar",T:9},{no:3,name:"nested_folder_name",kind:"scalar",T:9},{no:4,name:"url",kind:"scalar",T:9},{no:5,name:"type",kind:"enum",T:()=>["com.hamropatro.grpc.cms.FileType",ve]}])}create(e){const t=globalThis.Object.create(this.messagePrototype);return t.name="",t.folderName="",t.nestedFolderName="",t.url="",t.type=0,e!==void 0&&v(this,t,e),t}internalBinaryRead(e,t,n,r){let s=r??this.create(),a=e.pos+t;for(;e.pos<a;){let[o,l]=e.tag();switch(o){case 1:s.name=e.string();break;case 2:s.folderName=e.string();break;case 3:s.nestedFolderName=e.string();break;case 4:s.url=e.string();break;case 5:s.type=e.int32();break;default:let c=n.readUnknownField;if(c==="throw")throw new globalThis.Error(`Unknown field ${o} (wire type ${l}) for ${this.typeName}`);let h=e.skip(l);c!==!1&&(c===!0?k.onRead:c)(this.typeName,s,o,l,h)}}return s}internalBinaryWrite(e,t,n){e.name!==""&&t.tag(1,m.LengthDelimited).string(e.name),e.folderName!==""&&t.tag(2,m.LengthDelimited).string(e.folderName),e.nestedFolderName!==""&&t.tag(3,m.LengthDelimited).string(e.nestedFolderName),e.url!==""&&t.tag(4,m.LengthDelimited).string(e.url),e.type!==0&&t.tag(5,m.Varint).int32(e.type);let r=n.writeUnknownFields;return r!==!1&&(r==!0?k.onWrite:r)(this.typeName,e,t),t}}const ht=new gn;class bn extends M{constructor(){super("com.hamropatro.grpc.cms.File",[{no:1,name:"key",kind:"scalar",T:9},{no:2,name:"name",kind:"scalar",T:9},{no:3,name:"folder_name",kind:"scalar",T:9},{no:4,name:"nested_folder_name",kind:"scalar",T:9},{no:5,name:"url",kind:"scalar",T:9},{no:6,name:"thumbor_url",kind:"scalar",T:9},{no:7,name:"proxy_url",kind:"scalar",T:9},{no:8,name:"type",kind:"enum",T:()=>["com.hamropatro.grpc.cms.FileType",ve]},{no:9,name:"metadata",kind:"message",T:()=>Se}])}create(e){const t=globalThis.Object.create(this.messagePrototype);return t.key="",t.name="",t.folderName="",t.nestedFolderName="",t.url="",t.thumborUrl="",t.proxyUrl="",t.type=0,e!==void 0&&v(this,t,e),t}internalBinaryRead(e,t,n,r){let s=r??this.create(),a=e.pos+t;for(;e.pos<a;){let[o,l]=e.tag();switch(o){case 1:s.key=e.string();break;case 2:s.name=e.string();break;case 3:s.folderName=e.string();break;case 4:s.nestedFolderName=e.string();break;case 5:s.url=e.string();break;case 6:s.thumborUrl=e.string();break;case 7:s.proxyUrl=e.string();break;case 8:s.type=e.int32();break;case 9:s.metadata=Se.internalBinaryRead(e,e.uint32(),n,s.metadata);break;default:let c=n.readUnknownField;if(c==="throw")throw new globalThis.Error(`Unknown field ${o} (wire type ${l}) for ${this.typeName}`);let h=e.skip(l);c!==!1&&(c===!0?k.onRead:c)(this.typeName,s,o,l,h)}}return s}internalBinaryWrite(e,t,n){e.key!==""&&t.tag(1,m.LengthDelimited).string(e.key),e.name!==""&&t.tag(2,m.LengthDelimited).string(e.name),e.folderName!==""&&t.tag(3,m.LengthDelimited).string(e.folderName),e.nestedFolderName!==""&&t.tag(4,m.LengthDelimited).string(e.nestedFolderName),e.url!==""&&t.tag(5,m.LengthDelimited).string(e.url),e.thumborUrl!==""&&t.tag(6,m.LengthDelimited).string(e.thumborUrl),e.proxyUrl!==""&&t.tag(7,m.LengthDelimited).string(e.proxyUrl),e.type!==0&&t.tag(8,m.Varint).int32(e.type),e.metadata&&Se.internalBinaryWrite(e.metadata,t.tag(9,m.LengthDelimited).fork(),n).join();let r=n.writeUnknownFields;return r!==!1&&(r==!0?k.onWrite:r)(this.typeName,e,t),t}}const fe=new bn;class wn extends M{constructor(){super("com.hamropatro.grpc.cms.FileMetadata",[{no:1,name:"height",kind:"scalar",T:5},{no:2,name:"width",kind:"scalar",T:5},{no:3,name:"background_color",kind:"scalar",T:9},{no:4,name:"aspect_ratio",kind:"scalar",T:1}])}create(e){const t=globalThis.Object.create(this.messagePrototype);return t.height=0,t.width=0,t.backgroundColor="",t.aspectRatio=0,e!==void 0&&v(this,t,e),t}internalBinaryRead(e,t,n,r){let s=r??this.create(),a=e.pos+t;for(;e.pos<a;){let[o,l]=e.tag();switch(o){case 1:s.height=e.int32();break;case 2:s.width=e.int32();break;case 3:s.backgroundColor=e.string();break;case 4:s.aspectRatio=e.double();break;default:let c=n.readUnknownField;if(c==="throw")throw new globalThis.Error(`Unknown field ${o} (wire type ${l}) for ${this.typeName}`);let h=e.skip(l);c!==!1&&(c===!0?k.onRead:c)(this.typeName,s,o,l,h)}}return s}internalBinaryWrite(e,t,n){e.height!==0&&t.tag(1,m.Varint).int32(e.height),e.width!==0&&t.tag(2,m.Varint).int32(e.width),e.backgroundColor!==""&&t.tag(3,m.LengthDelimited).string(e.backgroundColor),e.aspectRatio!==0&&t.tag(4,m.Bit64).double(e.aspectRatio);let r=n.writeUnknownFields;return r!==!1&&(r==!0?k.onWrite:r)(this.typeName,e,t),t}}const Se=new wn;class yn extends M{constructor(){super("com.hamropatro.grpc.cms.DeleteFileRequest",[{no:1,name:"key",kind:"scalar",T:9}])}create(e){const t=globalThis.Object.create(this.messagePrototype);return t.key="",e!==void 0&&v(this,t,e),t}internalBinaryRead(e,t,n,r){let s=r??this.create(),a=e.pos+t;for(;e.pos<a;){let[o,l]=e.tag();switch(o){case 1:s.key=e.string();break;default:let c=n.readUnknownField;if(c==="throw")throw new globalThis.Error(`Unknown field ${o} (wire type ${l}) for ${this.typeName}`);let h=e.skip(l);c!==!1&&(c===!0?k.onRead:c)(this.typeName,s,o,l,h)}}return s}internalBinaryWrite(e,t,n){e.key!==""&&t.tag(1,m.LengthDelimited).string(e.key);let r=n.writeUnknownFields;return r!==!1&&(r==!0?k.onWrite:r)(this.typeName,e,t),t}}const Nn=new yn;class kn extends M{constructor(){super("com.hamropatro.grpc.cms.DeleteFileResponse",[{no:1,name:"is_deleted",kind:"scalar",T:8}])}create(e){const t=globalThis.Object.create(this.messagePrototype);return t.isDeleted=!1,e!==void 0&&v(this,t,e),t}internalBinaryRead(e,t,n,r){let s=r??this.create(),a=e.pos+t;for(;e.pos<a;){let[o,l]=e.tag();switch(o){case 1:s.isDeleted=e.bool();break;default:let c=n.readUnknownField;if(c==="throw")throw new globalThis.Error(`Unknown field ${o} (wire type ${l}) for ${this.typeName}`);let h=e.skip(l);c!==!1&&(c===!0?k.onRead:c)(this.typeName,s,o,l,h)}}return s}internalBinaryWrite(e,t,n){e.isDeleted!==!1&&t.tag(1,m.Varint).bool(e.isDeleted);let r=n.writeUnknownFields;return r!==!1&&(r==!0?k.onWrite:r)(this.typeName,e,t),t}}const En=new kn;class In extends M{constructor(){super("com.hamropatro.grpc.cms.GetFilesByFolderRequest",[{no:1,name:"folder_name",kind:"scalar",T:9},{no:2,name:"cursor",kind:"scalar",T:9},{no:3,name:"limit",kind:"scalar",T:5}])}create(e){const t=globalThis.Object.create(this.messagePrototype);return t.folderName="",t.cursor="",t.limit=0,e!==void 0&&v(this,t,e),t}internalBinaryRead(e,t,n,r){let s=r??this.create(),a=e.pos+t;for(;e.pos<a;){let[o,l]=e.tag();switch(o){case 1:s.folderName=e.string();break;case 2:s.cursor=e.string();break;case 3:s.limit=e.int32();break;default:let c=n.readUnknownField;if(c==="throw")throw new globalThis.Error(`Unknown field ${o} (wire type ${l}) for ${this.typeName}`);let h=e.skip(l);c!==!1&&(c===!0?k.onRead:c)(this.typeName,s,o,l,h)}}return s}internalBinaryWrite(e,t,n){e.folderName!==""&&t.tag(1,m.LengthDelimited).string(e.folderName),e.cursor!==""&&t.tag(2,m.LengthDelimited).string(e.cursor),e.limit!==0&&t.tag(3,m.Varint).int32(e.limit);let r=n.writeUnknownFields;return r!==!1&&(r==!0?k.onWrite:r)(this.typeName,e,t),t}}const Tn=new In;class On extends M{constructor(){super("com.hamropatro.grpc.cms.GetFilesByFolderResponse",[{no:1,name:"files",kind:"message",repeat:1,T:()=>fe},{no:2,name:"next_cursor",kind:"scalar",T:9},{no:3,name:"has_more",kind:"scalar",T:8}])}create(e){const t=globalThis.Object.create(this.messagePrototype);return t.files=[],t.nextCursor="",t.hasMore=!1,e!==void 0&&v(this,t,e),t}internalBinaryRead(e,t,n,r){let s=r??this.create(),a=e.pos+t;for(;e.pos<a;){let[o,l]=e.tag();switch(o){case 1:s.files.push(fe.internalBinaryRead(e,e.uint32(),n));break;case 2:s.nextCursor=e.string();break;case 3:s.hasMore=e.bool();break;default:let c=n.readUnknownField;if(c==="throw")throw new globalThis.Error(`Unknown field ${o} (wire type ${l}) for ${this.typeName}`);let h=e.skip(l);c!==!1&&(c===!0?k.onRead:c)(this.typeName,s,o,l,h)}}return s}internalBinaryWrite(e,t,n){for(let s=0;s<e.files.length;s++)fe.internalBinaryWrite(e.files[s],t.tag(1,m.LengthDelimited).fork(),n).join();e.nextCursor!==""&&t.tag(2,m.LengthDelimited).string(e.nextCursor),e.hasMore!==!1&&t.tag(3,m.Varint).bool(e.hasMore);let r=n.writeUnknownFields;return r!==!1&&(r==!0?k.onWrite:r)(this.typeName,e,t),t}}const Bn=new On,Me=new xe("com.hamropatro.grpc.cms.FileService",[{name:"createFile",options:{},I:ht,O:fe},{name:"updateFile",options:{},I:fe,O:fe},{name:"deleteFile",options:{},I:Nn,O:En},{name:"getFilesByFolder",options:{},I:Tn,O:Bn}]);class Fn{constructor(e){_(this,"typeName",Me.typeName);_(this,"methods",Me.methods);_(this,"options",Me.options);this._transport=e}createFile(e,t){const n=this.methods[0],r=this._transport.mergeOptions(t);return ee("unary",this._transport,n,r,e)}updateFile(e,t){const n=this.methods[1],r=this._transport.mergeOptions(t);return ee("unary",this._transport,n,r,e)}deleteFile(e,t){const n=this.methods[2],r=this._transport.mergeOptions(t);return ee("unary",this._transport,n,r,e)}getFilesByFolder(e,t){const n=this.methods[3],r=this._transport.mergeOptions(t);return ee("unary",this._transport,n,r,e)}}class An extends M{constructor(){super("com.hamropatro.grpc.cms.ImageUploadRequest",[])}create(e){const t=globalThis.Object.create(this.messagePrototype);return e!==void 0&&v(this,t,e),t}internalBinaryRead(e,t,n,r){return r??this.create()}internalBinaryWrite(e,t,n){let r=n.writeUnknownFields;return r!==!1&&(r==!0?k.onWrite:r)(this.typeName,e,t),t}}const ft=new An;class Dn extends M{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&&v(this,t,e),t}internalBinaryRead(e,t,n,r){let s=r??this.create(),a=e.pos+t;for(;e.pos<a;){let[o,l]=e.tag();switch(o){case 1:s.key=e.string();break;case 2:s.url=e.string();break;default:let c=n.readUnknownField;if(c==="throw")throw new globalThis.Error(`Unknown field ${o} (wire type ${l}) for ${this.typeName}`);let h=e.skip(l);c!==!1&&(c===!0?k.onRead:c)(this.typeName,s,o,l,h)}}return s}internalBinaryWrite(e,t,n){e.key!==""&&t.tag(1,m.LengthDelimited).string(e.key),e.url!==""&&t.tag(2,m.LengthDelimited).string(e.url);let r=n.writeUnknownFields;return r!==!1&&(r==!0?k.onWrite:r)(this.typeName,e,t),t}}const Ln=new Dn,Ve=new xe("com.hamropatro.grpc.cms.ImageUploadService",[{name:"Upload",options:{},I:ft,O:Ln}]);class Un{constructor(e){_(this,"typeName",Ve.typeName);_(this,"methods",Ve.methods);_(this,"options",Ve.options);this._transport=e}upload(e,t){const n=this.methods[0],r=this._transport.mergeOptions(t);return ee("unary",this._transport,n,r,e)}}const Rn={baseUrl:"https://hamro-cms-backend-grpc.hamrostack.com"},$e=new ln({baseUrl:Rn.baseUrl}),xn=new pn($e),Fe=ut.create(),_n=new Fn($e),de=ht.create(),Cn=new Un($e);ft.create();const dt=async()=>{try{return await Cn.upload(dt)}catch(i){throw i}},vn=async(i,e)=>{try{const t=Sn(i),r=(await dt()).response.url;return await fetch(r,{method:"PUT",headers:{"Content-Type":"image/*","x-amz-acl":"public-read"},body:t}),r==null?void 0:r.split("?")[0]}catch(t){throw t}},Sn=i=>{const e=i==null?void 0:i.replace(/^data:image\/\w+;base64,/,""),t=atob(e),n=new Uint8Array(t.length);for(let r=0;r<t.length;r++)n[r]=t.charCodeAt(r);return n},Mn=async(i,e,t)=>{try{return Fe.name=i,Fe.nestedFolderName=e,Fe.createdBy=t,await xn.createFolder(Fe)}catch(n){throw n}},Vn=async(i,e,t,n,r)=>{try{return de.name=i,de.nestedFolderName=e,de.url=t,de.type=n,de.folderName=r,await _n.createFile(de)}catch(s){throw s}};var mt=(i=>(i[i.IMAGE=0]="IMAGE",i[i.AUDIO=1]="AUDIO",i[i.VIDEO=2]="VIDEO",i[i.ALL=3]="ALL",i))(mt||{});const $n="data:image/svg+xml,%3csvg%20xmlns='http://www.w3.org/2000/svg'%20width='24'%20height='24'%20viewBox='0%200%2024%2024'%20fill='none'%20stroke='currentColor'%20stroke-width='2'%20stroke-linecap='round'%20stroke-linejoin='round'%20class='lucide%20lucide-cloud-upload'%3e%3cpath%20d='M4%2014.899A7%207%200%201%201%2015.71%208h1.79a4.5%204.5%200%200%201%202.5%208.242'/%3e%3cpath%20d='M12%2012v9'/%3e%3cpath%20d='m16%2016-4-4-4%204'/%3e%3c/svg%3e",pt="data:image/svg+xml,%3csvg%20xmlns='http://www.w3.org/2000/svg'%20viewBox='0%200%20100%20100'%20preserveAspectRatio='xMidYMid'%20width='200'%20height='200'%20style='shape-rendering:%20auto;%20display:%20block;%20background:%20rgb(255,%20255,%20255);%20--darkreader-inline-bgimage:%20initial;%20--darkreader-inline-bgcolor:%20%231e1e2e;'%20data-darkreader-inline-bgimage=''%20data-darkreader-inline-bgcolor=''%20xmlns:xlink='http://www.w3.org/1999/xlink'%3e%3cg%3e%3ccircle%20stroke-dasharray='164.93361431346415%2056.97787143782138'%20r='35'%20stroke-width='10'%20stroke='%23e15b64'%20fill='none'%20cy='50'%20cx='50'%3e%3canimateTransform%20keyTimes='0;1'%20values='0%2050%2050;360%2050%2050'%20dur='1s'%20repeatCount='indefinite'%20type='rotate'%20attributeName='transform'%3e%3c/animateTransform%3e%3c/circle%3e%3cg%3e%3c/g%3e%3c/g%3e%3c!--%20[ldio]%20generated%20by%20https://loading.io%20--%3e%3c/svg%3e",jn="data:image/svg+xml,%3csvg%20xmlns='http://www.w3.org/2000/svg'%20width='24'%20height='24'%20viewBox='0%200%2024%2024'%20fill='none'%20stroke='white'%20stroke-width='2'%20stroke-linecap='round'%20stroke-linejoin='round'%20class='lucide%20lucide-cloud-upload'%20%3e%3cpath%20d='M4%2014.899A7%207%200%201%201%2015.71%208h1.79a4.5%204.5%200%200%201%202.5%208.242'%20/%3e%3cpath%20d='M12%2012v9'%20/%3e%3cpath%20d='m16%2016-4-4-4%204'%20/%3e%3c/svg%3e";class Pn{constructor(e){S(this,re);S(this,me);S(this,se);S(this,A);S(this,X);S(this,ae);S(this,G);S(this,oe);S(this,B,[]);S(this,te);S(this,pe);S(this,be);O(this,X,null),O(this,G,!1),O(this,te,!1),O(this,pe,e.folderName),O(this,be,e.handleUpload.bind(this))}_init(){!!sessionStorage.getItem("folderCreated")||this.createFolder(d(this,pe))}create(e){O(this,re,document.getElementById(e.imageUploadMainContainerId)),O(this,me,H("browse-container")),O(this,se,H("browse-image-main"));let t;e!=null&&e.uploadIcon?t=ue(e==null?void 0:e.uploadIcon,"upload-btn-icon"):t=ue($n,"upload-btn-icon");const n=yt("Upload Image","upload-span-text"),r=we(e.uploadButtonText?e.uploadButtonText:"Browser Files","browse-image-button");return r.addEventListener("click",()=>{this.selectedImageContainer()}),d(this,se)&&d(this,se).append(t,n,r),d(this,me).appendChild(d(this,se)),d(this,re)&&d(this,re).appendChild(d(this,me)),d(this,re)}selectedImageContainer(){var a;const e=we("","dialog-modal-close-btn","",!1,`<svg
|
|
5
|
+
`)){if(t=="")continue;let[n,...r]=t.split(":");const s=r.join(":").trim();n=n.trim();let a=e[n];typeof a=="string"?e[n]=[a,s]:Array.isArray(a)?a.push(s):e[n]=s}return e}function an(i){let e={};return i.forEach((t,n)=>{let r=e[n];typeof r=="string"?e[n]=[r,t]:Array.isArray(r)?r.push(t):e[n]=t}),e}function on(i){switch(i){case 200:return f.OK;case 400:return f.INVALID_ARGUMENT;case 401:return f.UNAUTHENTICATED;case 403:return f.PERMISSION_DENIED;case 404:return f.NOT_FOUND;case 409:return f.ABORTED;case 412:return f.FAILED_PRECONDITION;case 429:return f.RESOURCE_EXHAUSTED;case 499:return f.CANCELLED;case 500:return f.UNKNOWN;case 501:return f.UNIMPLEMENTED;case 503:return f.UNAVAILABLE;case 504:return f.DEADLINE_EXCEEDED;default:return f.UNKNOWN}}class ln{constructor(e){this.defaultOptions=e}mergeOptions(e){return Ht(this.defaultOptions,e)}makeUrl(e,t){let n=t.baseUrl;return n.endsWith("/")&&(n=n.substring(0,n.length-1)),`${n}/${e.service.typeName}/${e.name}`}clientStreaming(e){const t=new I("Client streaming is not supported by grpc-web",f[f.UNIMPLEMENTED]);throw t.methodName=e.name,t.serviceName=e.service.typeName,t}duplex(e){const t=new I("Duplex streaming is not supported by grpc-web",f[f.UNIMPLEMENTED]);throw t.methodName=e.name,t.serviceName=e.service.typeName,t}serverStreaming(e,t,n){var r,s,a,o;let l=n,c=(r=l.format)!==null&&r!==void 0?r:"text",h=(s=l.fetchInit)!==null&&s!==void 0?s:{},p=this.makeUrl(e,l),y=e.I.toBinary(t,l.binaryOptions),U=new Q,L=new Zt,ne=!0,F,q=new Q,J,le=new Q;return globalThis.fetch(p,Object.assign(Object.assign({},h),{method:"POST",headers:it(new globalThis.Headers,c,l.timeout,l.meta),body:rt(y,c),signal:(a=n.abort)!==null&&a!==void 0?a:null})).then(N=>{let[g,R,V]=_e(N);if(U.resolve(V),g!=null&&g!==f.OK)throw new I(R??f[g],f[g],V);return g!=null&&(F={code:f[g],detail:R??f[g]}),N}).then(N=>{if(!N.body)throw new I("missing response body",f[f.INTERNAL]);return at(N.body,N.headers.get("content-type"),(g,R)=>{switch(g){case W.DATA:L.notifyMessage(e.O.fromBinary(R,l.binaryOptions)),ne=!1;break;case W.TRAILER:let V,z;[V,z,J]=st(R),F={code:f[V],detail:z??f[V]};break}})}).then(()=>{if(!J&&!ne)throw new I("missing trailers",f[f.DATA_LOSS]);if(!F)throw new I("missing status",f[f.INTERNAL]);if(F.code!=="OK")throw new I(F.detail,F.code,J);L.notifyComplete(),q.resolve(F),le.resolve(J||{})}).catch(N=>{let g;N instanceof I?g=N:N instanceof Error&&N.name==="AbortError"?g=new I(N.message,f[f.CANCELLED]):g=new I(N instanceof Error?N.message:""+N,f[f.INTERNAL]),g.methodName=e.name,g.serviceName=e.service.typeName,U.rejectPending(g),L.notifyError(g),q.rejectPending(g),le.rejectPending(g)}),new en(e,(o=l.meta)!==null&&o!==void 0?o:{},t,U.promise,L,q.promise,le.promise)}unary(e,t,n){var r,s,a,o;let l=n,c=(r=l.format)!==null&&r!==void 0?r:"text",h=(s=l.fetchInit)!==null&&s!==void 0?s:{},p=this.makeUrl(e,l),y=e.I.toBinary(t,l.binaryOptions),U=new Q,L,ne=new Q,F,q=new Q,J,le=new Q;return globalThis.fetch(p,Object.assign(Object.assign({},h),{method:"POST",headers:it(new globalThis.Headers,c,l.timeout,l.meta),body:rt(y,c),signal:(a=n.abort)!==null&&a!==void 0?a:null})).then(N=>{let[g,R,V]=_e(N);if(U.resolve(V),g!=null&&g!==f.OK)throw new I(R??f[g],f[g],V);return g!=null&&(F={code:f[g],detail:R??f[g]}),N}).then(N=>{if(!N.body)throw new I("missing response body",f[f.INTERNAL]);return at(N.body,N.headers.get("content-type"),(g,R)=>{switch(g){case W.DATA:if(L)throw new I("unary call received 2nd message",f[f.DATA_LOSS]);L=e.O.fromBinary(R,l.binaryOptions);break;case W.TRAILER:let V,z;[V,z,J]=st(R),F={code:f[V],detail:z??f[V]};break}})}).then(()=>{if(!J&&L)throw new I("missing trailers",f[f.DATA_LOSS]);if(!F)throw new I("missing status",f[f.INTERNAL]);if(!L&&F.code==="OK")throw new I("expected error status",f[f.DATA_LOSS]);if(!L)throw new I(F.detail,F.code,J);if(ne.resolve(L),F.code!=="OK")throw new I(F.detail,F.code,J);q.resolve(F),le.resolve(J||{})}).catch(N=>{let g;N instanceof I?g=N:N instanceof Error&&N.name==="AbortError"?g=new I(N.message,f[f.CANCELLED]):g=new I(N instanceof Error?N.message:""+N,f[f.INTERNAL]),g.methodName=e.name,g.serviceName=e.service.typeName,U.rejectPending(g),ne.rejectPending(g),q.rejectPending(g),le.rejectPending(g)}),new zt(e,(o=l.meta)!==null&&o!==void 0?o:{},t,U.promise,ne.promise,q.promise,le.promise)}}class cn extends M{constructor(){super("com.hamropatro.grpc.cms.CreateFolderRequest",[{no:1,name:"name",kind:"scalar",T:9},{no:2,name:"nested_folder_name",kind:"scalar",T:9},{no:3,name:"created_by",kind:"scalar",T:9}])}create(e){const t=globalThis.Object.create(this.messagePrototype);return t.name="",t.nestedFolderName="",t.createdBy="",e!==void 0&&v(this,t,e),t}internalBinaryRead(e,t,n,r){let s=r??this.create(),a=e.pos+t;for(;e.pos<a;){let[o,l]=e.tag();switch(o){case 1:s.name=e.string();break;case 2:s.nestedFolderName=e.string();break;case 3:s.createdBy=e.string();break;default:let c=n.readUnknownField;if(c==="throw")throw new globalThis.Error(`Unknown field ${o} (wire type ${l}) for ${this.typeName}`);let h=e.skip(l);c!==!1&&(c===!0?k.onRead:c)(this.typeName,s,o,l,h)}}return s}internalBinaryWrite(e,t,n){e.name!==""&&t.tag(1,m.LengthDelimited).string(e.name),e.nestedFolderName!==""&&t.tag(2,m.LengthDelimited).string(e.nestedFolderName),e.createdBy!==""&&t.tag(3,m.LengthDelimited).string(e.createdBy);let r=n.writeUnknownFields;return r!==!1&&(r==!0?k.onWrite:r)(this.typeName,e,t),t}}const ut=new cn;class un extends M{constructor(){super("com.hamropatro.grpc.cms.GetAllFoldersRequest",[{no:1,name:"cursor",kind:"scalar",T:9},{no:2,name:"limit",kind:"scalar",T:5}])}create(e){const t=globalThis.Object.create(this.messagePrototype);return t.cursor="",t.limit=0,e!==void 0&&v(this,t,e),t}internalBinaryRead(e,t,n,r){let s=r??this.create(),a=e.pos+t;for(;e.pos<a;){let[o,l]=e.tag();switch(o){case 1:s.cursor=e.string();break;case 2:s.limit=e.int32();break;default:let c=n.readUnknownField;if(c==="throw")throw new globalThis.Error(`Unknown field ${o} (wire type ${l}) for ${this.typeName}`);let h=e.skip(l);c!==!1&&(c===!0?k.onRead:c)(this.typeName,s,o,l,h)}}return s}internalBinaryWrite(e,t,n){e.cursor!==""&&t.tag(1,m.LengthDelimited).string(e.cursor),e.limit!==0&&t.tag(2,m.Varint).int32(e.limit);let r=n.writeUnknownFields;return r!==!1&&(r==!0?k.onWrite:r)(this.typeName,e,t),t}}const hn=new un;class fn extends M{constructor(){super("com.hamropatro.grpc.cms.GetAllFoldersResponse",[{no:1,name:"folder",kind:"message",repeat:1,T:()=>ue},{no:2,name:"next_cursor",kind:"scalar",T:9},{no:3,name:"has_more",kind:"scalar",T:8}])}create(e){const t=globalThis.Object.create(this.messagePrototype);return t.folder=[],t.nextCursor="",t.hasMore=!1,e!==void 0&&v(this,t,e),t}internalBinaryRead(e,t,n,r){let s=r??this.create(),a=e.pos+t;for(;e.pos<a;){let[o,l]=e.tag();switch(o){case 1:s.folder.push(ue.internalBinaryRead(e,e.uint32(),n));break;case 2:s.nextCursor=e.string();break;case 3:s.hasMore=e.bool();break;default:let c=n.readUnknownField;if(c==="throw")throw new globalThis.Error(`Unknown field ${o} (wire type ${l}) for ${this.typeName}`);let h=e.skip(l);c!==!1&&(c===!0?k.onRead:c)(this.typeName,s,o,l,h)}}return s}internalBinaryWrite(e,t,n){for(let s=0;s<e.folder.length;s++)ue.internalBinaryWrite(e.folder[s],t.tag(1,m.LengthDelimited).fork(),n).join();e.nextCursor!==""&&t.tag(2,m.LengthDelimited).string(e.nextCursor),e.hasMore!==!1&&t.tag(3,m.Varint).bool(e.hasMore);let r=n.writeUnknownFields;return r!==!1&&(r==!0?k.onWrite:r)(this.typeName,e,t),t}}const dn=new fn;class mn extends M{constructor(){super("com.hamropatro.grpc.cms.Folder",[{no:1,name:"key",kind:"scalar",T:9},{no:2,name:"name",kind:"scalar",T:9},{no:3,name:"nested_folder_name",kind:"scalar",T:9},{no:4,name:"created_by",kind:"scalar",T:9}])}create(e){const t=globalThis.Object.create(this.messagePrototype);return t.key="",t.name="",t.nestedFolderName="",t.createdBy="",e!==void 0&&v(this,t,e),t}internalBinaryRead(e,t,n,r){let s=r??this.create(),a=e.pos+t;for(;e.pos<a;){let[o,l]=e.tag();switch(o){case 1:s.key=e.string();break;case 2:s.name=e.string();break;case 3:s.nestedFolderName=e.string();break;case 4:s.createdBy=e.string();break;default:let c=n.readUnknownField;if(c==="throw")throw new globalThis.Error(`Unknown field ${o} (wire type ${l}) for ${this.typeName}`);let h=e.skip(l);c!==!1&&(c===!0?k.onRead:c)(this.typeName,s,o,l,h)}}return s}internalBinaryWrite(e,t,n){e.key!==""&&t.tag(1,m.LengthDelimited).string(e.key),e.name!==""&&t.tag(2,m.LengthDelimited).string(e.name),e.nestedFolderName!==""&&t.tag(3,m.LengthDelimited).string(e.nestedFolderName),e.createdBy!==""&&t.tag(4,m.LengthDelimited).string(e.createdBy);let r=n.writeUnknownFields;return r!==!1&&(r==!0?k.onWrite:r)(this.typeName,e,t),t}}const ue=new mn,Ce=new xe("com.hamropatro.grpc.cms.FolderService",[{name:"createFolder",options:{},I:ut,O:ue},{name:"getFolders",options:{},I:hn,O:dn},{name:"updateFolder",options:{},I:ue,O:ue}]);class pn{constructor(e){_(this,"typeName",Ce.typeName);_(this,"methods",Ce.methods);_(this,"options",Ce.options);this._transport=e}createFolder(e,t){const n=this.methods[0],r=this._transport.mergeOptions(t);return ee("unary",this._transport,n,r,e)}getFolders(e,t){const n=this.methods[1],r=this._transport.mergeOptions(t);return ee("unary",this._transport,n,r,e)}updateFolder(e,t){const n=this.methods[2],r=this._transport.mergeOptions(t);return ee("unary",this._transport,n,r,e)}}var ve=(i=>(i[i.IMAGE=0]="IMAGE",i[i.AUDIO=1]="AUDIO",i[i.VIDEO=2]="VIDEO",i[i.ALL=3]="ALL",i))(ve||{});class gn extends M{constructor(){super("com.hamropatro.grpc.cms.CreateFileRequest",[{no:1,name:"name",kind:"scalar",T:9},{no:2,name:"folder_name",kind:"scalar",T:9},{no:3,name:"nested_folder_name",kind:"scalar",T:9},{no:4,name:"url",kind:"scalar",T:9},{no:5,name:"type",kind:"enum",T:()=>["com.hamropatro.grpc.cms.FileType",ve]}])}create(e){const t=globalThis.Object.create(this.messagePrototype);return t.name="",t.folderName="",t.nestedFolderName="",t.url="",t.type=0,e!==void 0&&v(this,t,e),t}internalBinaryRead(e,t,n,r){let s=r??this.create(),a=e.pos+t;for(;e.pos<a;){let[o,l]=e.tag();switch(o){case 1:s.name=e.string();break;case 2:s.folderName=e.string();break;case 3:s.nestedFolderName=e.string();break;case 4:s.url=e.string();break;case 5:s.type=e.int32();break;default:let c=n.readUnknownField;if(c==="throw")throw new globalThis.Error(`Unknown field ${o} (wire type ${l}) for ${this.typeName}`);let h=e.skip(l);c!==!1&&(c===!0?k.onRead:c)(this.typeName,s,o,l,h)}}return s}internalBinaryWrite(e,t,n){e.name!==""&&t.tag(1,m.LengthDelimited).string(e.name),e.folderName!==""&&t.tag(2,m.LengthDelimited).string(e.folderName),e.nestedFolderName!==""&&t.tag(3,m.LengthDelimited).string(e.nestedFolderName),e.url!==""&&t.tag(4,m.LengthDelimited).string(e.url),e.type!==0&&t.tag(5,m.Varint).int32(e.type);let r=n.writeUnknownFields;return r!==!1&&(r==!0?k.onWrite:r)(this.typeName,e,t),t}}const ht=new gn;class bn extends M{constructor(){super("com.hamropatro.grpc.cms.File",[{no:1,name:"key",kind:"scalar",T:9},{no:2,name:"name",kind:"scalar",T:9},{no:3,name:"folder_name",kind:"scalar",T:9},{no:4,name:"nested_folder_name",kind:"scalar",T:9},{no:5,name:"url",kind:"scalar",T:9},{no:6,name:"thumbor_url",kind:"scalar",T:9},{no:7,name:"proxy_url",kind:"scalar",T:9},{no:8,name:"type",kind:"enum",T:()=>["com.hamropatro.grpc.cms.FileType",ve]},{no:9,name:"metadata",kind:"message",T:()=>Se}])}create(e){const t=globalThis.Object.create(this.messagePrototype);return t.key="",t.name="",t.folderName="",t.nestedFolderName="",t.url="",t.thumborUrl="",t.proxyUrl="",t.type=0,e!==void 0&&v(this,t,e),t}internalBinaryRead(e,t,n,r){let s=r??this.create(),a=e.pos+t;for(;e.pos<a;){let[o,l]=e.tag();switch(o){case 1:s.key=e.string();break;case 2:s.name=e.string();break;case 3:s.folderName=e.string();break;case 4:s.nestedFolderName=e.string();break;case 5:s.url=e.string();break;case 6:s.thumborUrl=e.string();break;case 7:s.proxyUrl=e.string();break;case 8:s.type=e.int32();break;case 9:s.metadata=Se.internalBinaryRead(e,e.uint32(),n,s.metadata);break;default:let c=n.readUnknownField;if(c==="throw")throw new globalThis.Error(`Unknown field ${o} (wire type ${l}) for ${this.typeName}`);let h=e.skip(l);c!==!1&&(c===!0?k.onRead:c)(this.typeName,s,o,l,h)}}return s}internalBinaryWrite(e,t,n){e.key!==""&&t.tag(1,m.LengthDelimited).string(e.key),e.name!==""&&t.tag(2,m.LengthDelimited).string(e.name),e.folderName!==""&&t.tag(3,m.LengthDelimited).string(e.folderName),e.nestedFolderName!==""&&t.tag(4,m.LengthDelimited).string(e.nestedFolderName),e.url!==""&&t.tag(5,m.LengthDelimited).string(e.url),e.thumborUrl!==""&&t.tag(6,m.LengthDelimited).string(e.thumborUrl),e.proxyUrl!==""&&t.tag(7,m.LengthDelimited).string(e.proxyUrl),e.type!==0&&t.tag(8,m.Varint).int32(e.type),e.metadata&&Se.internalBinaryWrite(e.metadata,t.tag(9,m.LengthDelimited).fork(),n).join();let r=n.writeUnknownFields;return r!==!1&&(r==!0?k.onWrite:r)(this.typeName,e,t),t}}const he=new bn;class wn extends M{constructor(){super("com.hamropatro.grpc.cms.FileMetadata",[{no:1,name:"height",kind:"scalar",T:5},{no:2,name:"width",kind:"scalar",T:5},{no:3,name:"background_color",kind:"scalar",T:9},{no:4,name:"aspect_ratio",kind:"scalar",T:1}])}create(e){const t=globalThis.Object.create(this.messagePrototype);return t.height=0,t.width=0,t.backgroundColor="",t.aspectRatio=0,e!==void 0&&v(this,t,e),t}internalBinaryRead(e,t,n,r){let s=r??this.create(),a=e.pos+t;for(;e.pos<a;){let[o,l]=e.tag();switch(o){case 1:s.height=e.int32();break;case 2:s.width=e.int32();break;case 3:s.backgroundColor=e.string();break;case 4:s.aspectRatio=e.double();break;default:let c=n.readUnknownField;if(c==="throw")throw new globalThis.Error(`Unknown field ${o} (wire type ${l}) for ${this.typeName}`);let h=e.skip(l);c!==!1&&(c===!0?k.onRead:c)(this.typeName,s,o,l,h)}}return s}internalBinaryWrite(e,t,n){e.height!==0&&t.tag(1,m.Varint).int32(e.height),e.width!==0&&t.tag(2,m.Varint).int32(e.width),e.backgroundColor!==""&&t.tag(3,m.LengthDelimited).string(e.backgroundColor),e.aspectRatio!==0&&t.tag(4,m.Bit64).double(e.aspectRatio);let r=n.writeUnknownFields;return r!==!1&&(r==!0?k.onWrite:r)(this.typeName,e,t),t}}const Se=new wn;class yn extends M{constructor(){super("com.hamropatro.grpc.cms.DeleteFileRequest",[{no:1,name:"key",kind:"scalar",T:9}])}create(e){const t=globalThis.Object.create(this.messagePrototype);return t.key="",e!==void 0&&v(this,t,e),t}internalBinaryRead(e,t,n,r){let s=r??this.create(),a=e.pos+t;for(;e.pos<a;){let[o,l]=e.tag();switch(o){case 1:s.key=e.string();break;default:let c=n.readUnknownField;if(c==="throw")throw new globalThis.Error(`Unknown field ${o} (wire type ${l}) for ${this.typeName}`);let h=e.skip(l);c!==!1&&(c===!0?k.onRead:c)(this.typeName,s,o,l,h)}}return s}internalBinaryWrite(e,t,n){e.key!==""&&t.tag(1,m.LengthDelimited).string(e.key);let r=n.writeUnknownFields;return r!==!1&&(r==!0?k.onWrite:r)(this.typeName,e,t),t}}const Nn=new yn;class kn extends M{constructor(){super("com.hamropatro.grpc.cms.DeleteFileResponse",[{no:1,name:"is_deleted",kind:"scalar",T:8}])}create(e){const t=globalThis.Object.create(this.messagePrototype);return t.isDeleted=!1,e!==void 0&&v(this,t,e),t}internalBinaryRead(e,t,n,r){let s=r??this.create(),a=e.pos+t;for(;e.pos<a;){let[o,l]=e.tag();switch(o){case 1:s.isDeleted=e.bool();break;default:let c=n.readUnknownField;if(c==="throw")throw new globalThis.Error(`Unknown field ${o} (wire type ${l}) for ${this.typeName}`);let h=e.skip(l);c!==!1&&(c===!0?k.onRead:c)(this.typeName,s,o,l,h)}}return s}internalBinaryWrite(e,t,n){e.isDeleted!==!1&&t.tag(1,m.Varint).bool(e.isDeleted);let r=n.writeUnknownFields;return r!==!1&&(r==!0?k.onWrite:r)(this.typeName,e,t),t}}const En=new kn;class In extends M{constructor(){super("com.hamropatro.grpc.cms.GetFilesByFolderRequest",[{no:1,name:"folder_name",kind:"scalar",T:9},{no:2,name:"cursor",kind:"scalar",T:9},{no:3,name:"limit",kind:"scalar",T:5}])}create(e){const t=globalThis.Object.create(this.messagePrototype);return t.folderName="",t.cursor="",t.limit=0,e!==void 0&&v(this,t,e),t}internalBinaryRead(e,t,n,r){let s=r??this.create(),a=e.pos+t;for(;e.pos<a;){let[o,l]=e.tag();switch(o){case 1:s.folderName=e.string();break;case 2:s.cursor=e.string();break;case 3:s.limit=e.int32();break;default:let c=n.readUnknownField;if(c==="throw")throw new globalThis.Error(`Unknown field ${o} (wire type ${l}) for ${this.typeName}`);let h=e.skip(l);c!==!1&&(c===!0?k.onRead:c)(this.typeName,s,o,l,h)}}return s}internalBinaryWrite(e,t,n){e.folderName!==""&&t.tag(1,m.LengthDelimited).string(e.folderName),e.cursor!==""&&t.tag(2,m.LengthDelimited).string(e.cursor),e.limit!==0&&t.tag(3,m.Varint).int32(e.limit);let r=n.writeUnknownFields;return r!==!1&&(r==!0?k.onWrite:r)(this.typeName,e,t),t}}const Tn=new In;class On extends M{constructor(){super("com.hamropatro.grpc.cms.GetFilesByFolderResponse",[{no:1,name:"files",kind:"message",repeat:1,T:()=>he},{no:2,name:"next_cursor",kind:"scalar",T:9},{no:3,name:"has_more",kind:"scalar",T:8}])}create(e){const t=globalThis.Object.create(this.messagePrototype);return t.files=[],t.nextCursor="",t.hasMore=!1,e!==void 0&&v(this,t,e),t}internalBinaryRead(e,t,n,r){let s=r??this.create(),a=e.pos+t;for(;e.pos<a;){let[o,l]=e.tag();switch(o){case 1:s.files.push(he.internalBinaryRead(e,e.uint32(),n));break;case 2:s.nextCursor=e.string();break;case 3:s.hasMore=e.bool();break;default:let c=n.readUnknownField;if(c==="throw")throw new globalThis.Error(`Unknown field ${o} (wire type ${l}) for ${this.typeName}`);let h=e.skip(l);c!==!1&&(c===!0?k.onRead:c)(this.typeName,s,o,l,h)}}return s}internalBinaryWrite(e,t,n){for(let s=0;s<e.files.length;s++)he.internalBinaryWrite(e.files[s],t.tag(1,m.LengthDelimited).fork(),n).join();e.nextCursor!==""&&t.tag(2,m.LengthDelimited).string(e.nextCursor),e.hasMore!==!1&&t.tag(3,m.Varint).bool(e.hasMore);let r=n.writeUnknownFields;return r!==!1&&(r==!0?k.onWrite:r)(this.typeName,e,t),t}}const Bn=new On,Me=new xe("com.hamropatro.grpc.cms.FileService",[{name:"createFile",options:{},I:ht,O:he},{name:"updateFile",options:{},I:he,O:he},{name:"deleteFile",options:{},I:Nn,O:En},{name:"getFilesByFolder",options:{},I:Tn,O:Bn}]);class Fn{constructor(e){_(this,"typeName",Me.typeName);_(this,"methods",Me.methods);_(this,"options",Me.options);this._transport=e}createFile(e,t){const n=this.methods[0],r=this._transport.mergeOptions(t);return ee("unary",this._transport,n,r,e)}updateFile(e,t){const n=this.methods[1],r=this._transport.mergeOptions(t);return ee("unary",this._transport,n,r,e)}deleteFile(e,t){const n=this.methods[2],r=this._transport.mergeOptions(t);return ee("unary",this._transport,n,r,e)}getFilesByFolder(e,t){const n=this.methods[3],r=this._transport.mergeOptions(t);return ee("unary",this._transport,n,r,e)}}class An extends M{constructor(){super("com.hamropatro.grpc.cms.ImageUploadRequest",[])}create(e){const t=globalThis.Object.create(this.messagePrototype);return e!==void 0&&v(this,t,e),t}internalBinaryRead(e,t,n,r){return r??this.create()}internalBinaryWrite(e,t,n){let r=n.writeUnknownFields;return r!==!1&&(r==!0?k.onWrite:r)(this.typeName,e,t),t}}const ft=new An;class Dn extends M{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&&v(this,t,e),t}internalBinaryRead(e,t,n,r){let s=r??this.create(),a=e.pos+t;for(;e.pos<a;){let[o,l]=e.tag();switch(o){case 1:s.key=e.string();break;case 2:s.url=e.string();break;default:let c=n.readUnknownField;if(c==="throw")throw new globalThis.Error(`Unknown field ${o} (wire type ${l}) for ${this.typeName}`);let h=e.skip(l);c!==!1&&(c===!0?k.onRead:c)(this.typeName,s,o,l,h)}}return s}internalBinaryWrite(e,t,n){e.key!==""&&t.tag(1,m.LengthDelimited).string(e.key),e.url!==""&&t.tag(2,m.LengthDelimited).string(e.url);let r=n.writeUnknownFields;return r!==!1&&(r==!0?k.onWrite:r)(this.typeName,e,t),t}}const Ln=new Dn,Ve=new xe("com.hamropatro.grpc.cms.ImageUploadService",[{name:"Upload",options:{},I:ft,O:Ln}]);class Un{constructor(e){_(this,"typeName",Ve.typeName);_(this,"methods",Ve.methods);_(this,"options",Ve.options);this._transport=e}upload(e,t){const n=this.methods[0],r=this._transport.mergeOptions(t);return ee("unary",this._transport,n,r,e)}}const Rn={baseUrl:"https://hamro-cms-backend-grpc.hamrostack.com"},$e=new ln({baseUrl:Rn.baseUrl}),xn=new pn($e),Fe=ut.create(),_n=new Fn($e),fe=ht.create(),Cn=new Un($e);ft.create();const dt=async()=>{try{return await Cn.upload(dt)}catch(i){throw i}},vn=async(i,e)=>{try{const t=Sn(i),r=(await dt()).response.url;return await fetch(r,{method:"PUT",headers:{"Content-Type":"image/*","x-amz-acl":"public-read"},body:t}),r==null?void 0:r.split("?")[0]}catch(t){throw t}},Sn=i=>{const e=i==null?void 0:i.replace(/^data:image\/\w+;base64,/,""),t=atob(e),n=new Uint8Array(t.length);for(let r=0;r<t.length;r++)n[r]=t.charCodeAt(r);return n},Mn=async(i,e,t)=>{try{return Fe.name=i,Fe.nestedFolderName=e,Fe.createdBy=t,await xn.createFolder(Fe)}catch(n){throw n}},Vn=async(i,e,t,n,r)=>{try{return fe.name=i,fe.nestedFolderName=e,fe.url=t,fe.type=n,fe.folderName=r,await _n.createFile(fe)}catch(s){throw s}};var mt=(i=>(i[i.IMAGE=0]="IMAGE",i[i.AUDIO=1]="AUDIO",i[i.VIDEO=2]="VIDEO",i[i.ALL=3]="ALL",i))(mt||{});const $n="data:image/svg+xml,%3csvg%20xmlns='http://www.w3.org/2000/svg'%20width='24'%20height='24'%20viewBox='0%200%2024%2024'%20fill='none'%20stroke='currentColor'%20stroke-width='2'%20stroke-linecap='round'%20stroke-linejoin='round'%20class='lucide%20lucide-cloud-upload'%3e%3cpath%20d='M4%2014.899A7%207%200%201%201%2015.71%208h1.79a4.5%204.5%200%200%201%202.5%208.242'/%3e%3cpath%20d='M12%2012v9'/%3e%3cpath%20d='m16%2016-4-4-4%204'/%3e%3c/svg%3e",pt="data:image/svg+xml,%3csvg%20xmlns='http://www.w3.org/2000/svg'%20viewBox='0%200%20100%20100'%20preserveAspectRatio='xMidYMid'%20width='200'%20height='200'%20style='shape-rendering:%20auto;%20display:%20block;%20background:%20rgb(255,%20255,%20255);%20--darkreader-inline-bgimage:%20initial;%20--darkreader-inline-bgcolor:%20%231e1e2e;'%20data-darkreader-inline-bgimage=''%20data-darkreader-inline-bgcolor=''%20xmlns:xlink='http://www.w3.org/1999/xlink'%3e%3cg%3e%3ccircle%20stroke-dasharray='164.93361431346415%2056.97787143782138'%20r='35'%20stroke-width='10'%20stroke='%23e15b64'%20fill='none'%20cy='50'%20cx='50'%3e%3canimateTransform%20keyTimes='0;1'%20values='0%2050%2050;360%2050%2050'%20dur='1s'%20repeatCount='indefinite'%20type='rotate'%20attributeName='transform'%3e%3c/animateTransform%3e%3c/circle%3e%3cg%3e%3c/g%3e%3c/g%3e%3c!--%20[ldio]%20generated%20by%20https://loading.io%20--%3e%3c/svg%3e",jn="data:image/svg+xml,%3csvg%20xmlns='http://www.w3.org/2000/svg'%20width='24'%20height='24'%20viewBox='0%200%2024%2024'%20fill='none'%20stroke='white'%20stroke-width='2'%20stroke-linecap='round'%20stroke-linejoin='round'%20class='lucide%20lucide-cloud-upload'%20%3e%3cpath%20d='M4%2014.899A7%207%200%201%201%2015.71%208h1.79a4.5%204.5%200%200%201%202.5%208.242'%20/%3e%3cpath%20d='M12%2012v9'%20/%3e%3cpath%20d='m16%2016-4-4-4%204'%20/%3e%3c/svg%3e";class Pn{constructor(e){S(this,re);S(this,de);S(this,se);S(this,A);S(this,X);S(this,ae);S(this,G);S(this,oe);S(this,B,[]);S(this,te);S(this,me);S(this,be);O(this,X,null),O(this,G,!1),O(this,te,!1),O(this,me,e.folderName),O(this,be,e.handleUpload.bind(this))}_init(){!!sessionStorage.getItem("folderCreated")||this.createFolder(d(this,me))}create(e){O(this,re,document.getElementById(e.imageUploadMainContainerId)),O(this,de,H("browse-container")),O(this,se,H("browse-image-main"));let t;t=pe($n,"upload-btn-icon");const n=yt("Upload Image","upload-span-text"),r=we("Browser Files","browse-image-button");return r.addEventListener("click",()=>{this.selectedImageContainer()}),d(this,se)&&d(this,se).append(t,n,r),d(this,de).appendChild(d(this,se)),d(this,re)&&d(this,re).appendChild(d(this,de)),d(this,re)}selectedImageContainer(){var a;const e=we("","dialog-modal-close-btn","",!1,`<svg
|
|
6
6
|
xmlns="http://www.w3.org/2000/svg"
|
|
7
7
|
width="26"
|
|
8
8
|
height="28"
|
|
@@ -16,4 +16,4 @@ import './style.css';
|
|
|
16
16
|
>
|
|
17
17
|
<path d="M18 6 6 18" />
|
|
18
18
|
<path d="m6 6 12 12" />
|
|
19
|
-
</svg>`);e.addEventListener("click",()=>{j.hide(),O(this,B,[])}),O(this,ae,`Upload (${(a=d(this,B))==null?void 0:a.length})`);const t=H("browse-container"),n=this.createUploadOptions(),r=this.createBrowseMoreContainer(),s=this.createBrowseImageMain();t.append(n,r,s),j.show({title:e,content:t,confirmButtonText:d(this,ae),onConfirm:()=>{d(this,be).call(this)},onCancel:()=>{j.hide(),O(this,B,[])}})}createUploadOptions(){const e=H("browse-options"),t=ie("From Computer","options");return ie("From URL","options"),t.classList.add("selected"),[t].forEach(r=>{r.addEventListener("click",()=>{var s;(s=document.querySelector(".options.selected"))==null||s.classList.remove("selected"),r.classList.add("selected")})}),e.append(t),e}createBrowseMoreContainer(){const e=H("browse-more-btn-container"),t=we("Browse More File","browse-more-btn"),n=Nt("file");n.style.display="none";const r=
|
|
19
|
+
</svg>`);e.addEventListener("click",()=>{j.hide(),O(this,B,[])}),O(this,ae,`Upload (${(a=d(this,B))==null?void 0:a.length})`);const t=H("browse-container"),n=this.createUploadOptions(),r=this.createBrowseMoreContainer(),s=this.createBrowseImageMain();t.append(n,r,s),j.show({title:e,content:t,confirmButtonText:d(this,ae),onConfirm:()=>{d(this,be).call(this)},onCancel:()=>{j.hide(),O(this,B,[])}})}createUploadOptions(){const e=H("browse-options"),t=ie("From Computer","options");return ie("From URL","options"),t.classList.add("selected"),[t].forEach(r=>{r.addEventListener("click",()=>{var s;(s=document.querySelector(".options.selected"))==null||s.classList.remove("selected"),r.classList.add("selected")})}),e.append(t),e}createBrowseMoreContainer(){const e=H("browse-more-btn-container"),t=we("Browse More File","browse-more-btn"),n=Nt("file");n.style.display="none";const r=pe(jn);return t.append(r),t.addEventListener("click",()=>n.click()),n.addEventListener("change",()=>{const s=n.files[0],a=new FileReader;a.readAsDataURL(s),a.onload=async()=>{await this.addSelectedImages(a.result,s),n.value=""}}),e.appendChild(t),e}createBrowseImageMain(){var t;const e=H("browse-image-main");return O(this,X,ie(`Selected Images (${(t=d(this,B))==null?void 0:t.length})`)),d(this,X).style.textAlign="left",d(this,X).style.fontSize="18px",O(this,A,H("selected-image-container")),this.updateSelectedImages(),e.append(d(this,X),d(this,A)),e}updateSelectedImages(){if(!(!d(this,A)||!d(this,X))){if(d(this,A).innerHTML="",d(this,B).length>0)d(this,B).forEach(e=>{var l;const t=H("selected-image-content"),n=we("x","selected-image-btn"),r=pe(e==null?void 0:e.url,"selected-image");n.addEventListener("click",()=>{if(O(this,B,d(this,B).filter(c=>(c==null?void 0:c.url)!==(e==null?void 0:e.url))),s.remove(),d(this,B).length===0){d(this,A).innerHTML="";const c=ie();c.textContent="No images selected",d(this,A).style.textAlign="center",d(this,A).style.width="auto",d(this,A).appendChild(c)}this._updateDialogContent()});const s=H("selected-image-wrapper",e==null?void 0:e.url);s.classList.add("checked"),r.addEventListener("click",()=>{s.classList.contains("checked")?(s.classList.remove("checked"),O(this,B,d(this,B).filter(c=>(c==null?void 0:c.url)!==(e==null?void 0:e.url)))):(s.classList.add("checked"),d(this,B).push(e)),this._updateDialogContent()}),d(this,te)?(O(this,oe,pe(pt,"loader")),d(this,A).insertBefore(d(this,oe),d(this,A).firstChild)):(s.append(r,n),d(this,A).style.width="100%",d(this,A).appendChild(s));const a=ie(e.name,"selected-image-name"),o=ie(`${(l=e.type)==null?void 0:l.split("/")[1]} - ${Math.round(e.size/1024)}KB`,"selected-image-size");t.appendChild(r),s.append(t,a,o),d(this,A).style.width="100%",d(this,A).appendChild(s)});else if(d(this,te))O(this,oe,pe(pt,"loader")),d(this,A).style.width="100%",d(this,A).appendChild(d(this,oe));else{const e=ie();e.textContent="No images selected",d(this,A).style.textAlign="center",d(this,A).style.width="auto",d(this,A).appendChild(e)}this._updateDialogContent()}}_updateDialogContent(){var e;d(this,X).textContent=`Selected Images (${d(this,B).length})`,O(this,ae,`Upload (${d(this,B).length})`),j.updateUploadBtnText(d(this,ae)),j.disableConfirmButton(((e=d(this,B))==null?void 0:e.length)<=0)}async addSelectedImages(e,t){O(this,te,!0),this.updateSelectedImages();const n=await vn(e);d(this,B).push({url:n,name:t.name,type:t.type,size:t.size}),this.updateSelectedImages(),O(this,te,!1),this.updateSelectedImages()}async createFolder(e,t=2){try{await Mn(e,"",""),sessionStorage.setItem("folderCreated","true")}catch{if(t>1)this.createFolder(e,--t);else throw new Error("Error creating folder: "+e)}}async _upload(){var t,n;if(!d(this,B)||d(this,B).length===0)throw new Error("No images to upload");O(this,G,!0),j.updateUploadBtnText(`Uploading (${(t=d(this,B))==null?void 0:t.length})`),j.updateUploadBtn(d(this,G));let e=[];try{return await this._uploadImages(e),O(this,G,!1),O(this,B,[]),j.hide(),j.updateUploadBtn(d(this,G)),e}catch{throw O(this,G,!1),j.updateUploadBtnText(`Upload(${(n=d(this,B))==null?void 0:n.length})`),j.updateUploadBtn(d(this,G)),new Error("something went wrong")}}async _uploadImages(e){for(const t of d(this,B)){const n=await Vn(t==null?void 0:t.name,"",t==null?void 0:t.url,mt.IMAGE,d(this,me));e.push(n.response)}}}return re=new WeakMap,de=new WeakMap,se=new WeakMap,A=new WeakMap,X=new WeakMap,ae=new WeakMap,G=new WeakMap,oe=new WeakMap,B=new WeakMap,te=new WeakMap,me=new WeakMap,be=new WeakMap,Pn});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "image-salon-sdk",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.5",
|
|
4
4
|
"license": "ISC",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"files": [
|
|
@@ -8,18 +8,19 @@
|
|
|
8
8
|
],
|
|
9
9
|
"main": "./dist/image-salon-sdk.umd.cjs",
|
|
10
10
|
"module": "./dist/image-salon-sdk.js",
|
|
11
|
-
"types": "./dist/
|
|
11
|
+
"types": "./dist/index.d.ts",
|
|
12
12
|
"style": "./dist/style.css",
|
|
13
13
|
"exports": {
|
|
14
14
|
".": {
|
|
15
|
-
"import": "./
|
|
16
|
-
"require": "./
|
|
15
|
+
"import": "./image-salon-sdk.js",
|
|
16
|
+
"require": "./image-salon-sdk.umd.cjs",
|
|
17
|
+
"types": "./index.d.ts"
|
|
17
18
|
}
|
|
18
19
|
},
|
|
19
20
|
"scripts": {
|
|
20
21
|
"dev": "vite",
|
|
21
22
|
"build": "rm -rf dist/ && tsc && vite build",
|
|
22
|
-
"preview": "vite
|
|
23
|
+
"preview": "vite preview",
|
|
23
24
|
"serve": "vite serve"
|
|
24
25
|
},
|
|
25
26
|
"devDependencies": {
|