image-salon-sdk 1.0.6 → 1.0.7
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
|
@@ -646,7 +646,7 @@ function Ee(i) {
|
|
|
646
646
|
if (!Number.isInteger(i) || i > Rt || i < 0)
|
|
647
647
|
throw new Error("invalid uint 32: " + i);
|
|
648
648
|
}
|
|
649
|
-
function
|
|
649
|
+
function ve(i) {
|
|
650
650
|
if (typeof i != "number")
|
|
651
651
|
throw new Error("invalid float 32: " + typeof i);
|
|
652
652
|
if (Number.isFinite(i) && (i > Lt || i < Ut))
|
|
@@ -654,12 +654,12 @@ function Ce(i) {
|
|
|
654
654
|
}
|
|
655
655
|
const qe = {
|
|
656
656
|
writeUnknownFields: !0,
|
|
657
|
-
writerFactory: () => new
|
|
657
|
+
writerFactory: () => new Ct()
|
|
658
658
|
};
|
|
659
|
-
function
|
|
659
|
+
function vt(i) {
|
|
660
660
|
return i ? Object.assign(Object.assign({}, qe), i) : qe;
|
|
661
661
|
}
|
|
662
|
-
class
|
|
662
|
+
class Ct {
|
|
663
663
|
constructor(e) {
|
|
664
664
|
this.stack = [], this.textEncoder = e ?? new TextEncoder(), this.chunks = [], this.buf = [];
|
|
665
665
|
}
|
|
@@ -748,7 +748,7 @@ class vt {
|
|
|
748
748
|
* Write a `float` value, 32-bit floating point number.
|
|
749
749
|
*/
|
|
750
750
|
float(e) {
|
|
751
|
-
|
|
751
|
+
ve(e);
|
|
752
752
|
let t = new Uint8Array(4);
|
|
753
753
|
return new DataView(t.buffer).setFloat32(0, e, !0), this.raw(t);
|
|
754
754
|
}
|
|
@@ -1230,7 +1230,7 @@ class Wt {
|
|
|
1230
1230
|
s = "too large or small";
|
|
1231
1231
|
break;
|
|
1232
1232
|
}
|
|
1233
|
-
return t == u.FLOAT &&
|
|
1233
|
+
return t == u.FLOAT && ve(a), a;
|
|
1234
1234
|
case u.INT32:
|
|
1235
1235
|
case u.FIXED32:
|
|
1236
1236
|
case u.SFIXED32:
|
|
@@ -1416,7 +1416,7 @@ class qt {
|
|
|
1416
1416
|
case u.UINT32:
|
|
1417
1417
|
return t === 0 ? a ? 0 : void 0 : (Ee(t), t);
|
|
1418
1418
|
case u.FLOAT:
|
|
1419
|
-
|
|
1419
|
+
ve(t);
|
|
1420
1420
|
case u.DOUBLE:
|
|
1421
1421
|
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);
|
|
1422
1422
|
case u.STRING:
|
|
@@ -1901,7 +1901,7 @@ function Je(i, e, t) {
|
|
|
1901
1901
|
return !0;
|
|
1902
1902
|
}
|
|
1903
1903
|
const Ht = Object.getOwnPropertyDescriptors(Object.getPrototypeOf({}));
|
|
1904
|
-
class
|
|
1904
|
+
class C {
|
|
1905
1905
|
constructor(e, t, n) {
|
|
1906
1906
|
this.defaultCheckDepth = 16, this.typeName = e, this.fields = t.map($t), this.options = n ?? {}, this.messagePrototype = Object.create(null, Object.assign(Object.assign({}, Ht), { [lt]: { value: this } })), this.refTypeCheck = new Pt(this), this.refJsonReader = new Wt(this), this.refJsonWriter = new qt(this), this.refBinReader = new Kt(this), this.refBinWriter = new Xt(this);
|
|
1907
1907
|
}
|
|
@@ -1987,7 +1987,7 @@ class v {
|
|
|
1987
1987
|
* Write the message to binary format.
|
|
1988
1988
|
*/
|
|
1989
1989
|
toBinary(e, t) {
|
|
1990
|
-
let n =
|
|
1990
|
+
let n = vt(t);
|
|
1991
1991
|
return this.internalBinaryWrite(e, n.writerFactory(), n).finish();
|
|
1992
1992
|
}
|
|
1993
1993
|
/**
|
|
@@ -2042,7 +2042,7 @@ function Zt(i, e) {
|
|
|
2042
2042
|
let s = i;
|
|
2043
2043
|
return s.service = e, s.localName = (t = s.localName) !== null && t !== void 0 ? t : Re(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;
|
|
2044
2044
|
}
|
|
2045
|
-
class
|
|
2045
|
+
class Ce {
|
|
2046
2046
|
constructor(e, t, n) {
|
|
2047
2047
|
this.typeName = e, this.methods = t.map((r) => Zt(r, this)), this.options = n ?? {};
|
|
2048
2048
|
}
|
|
@@ -2658,9 +2658,9 @@ class un {
|
|
|
2658
2658
|
signal: (a = n.abort) !== null && a !== void 0 ? a : null
|
|
2659
2659
|
// node-fetch@3.0.0-beta.9 rejects `undefined`
|
|
2660
2660
|
})).then((y) => {
|
|
2661
|
-
let [g, L,
|
|
2662
|
-
if (D.resolve(
|
|
2663
|
-
throw new k(L ?? f[g], f[g],
|
|
2661
|
+
let [g, L, v] = _e(y);
|
|
2662
|
+
if (D.resolve(v), g != null && g !== f.OK)
|
|
2663
|
+
throw new k(L ?? f[g], f[g], v);
|
|
2664
2664
|
return g != null && (O = {
|
|
2665
2665
|
code: f[g],
|
|
2666
2666
|
detail: L ?? f[g]
|
|
@@ -2674,10 +2674,10 @@ class un {
|
|
|
2674
2674
|
F.notifyMessage(e.O.fromBinary(L, l.binaryOptions)), Y = !1;
|
|
2675
2675
|
break;
|
|
2676
2676
|
case P.TRAILER:
|
|
2677
|
-
let
|
|
2678
|
-
[
|
|
2679
|
-
code: f[
|
|
2680
|
-
detail: G ?? f[
|
|
2677
|
+
let v, G;
|
|
2678
|
+
[v, G, W] = Ye(L), O = {
|
|
2679
|
+
code: f[v],
|
|
2680
|
+
detail: G ?? f[v]
|
|
2681
2681
|
};
|
|
2682
2682
|
break;
|
|
2683
2683
|
}
|
|
@@ -2705,9 +2705,9 @@ class un {
|
|
|
2705
2705
|
signal: (a = n.abort) !== null && a !== void 0 ? a : null
|
|
2706
2706
|
// node-fetch@3.0.0-beta.9 rejects `undefined`
|
|
2707
2707
|
})).then((y) => {
|
|
2708
|
-
let [g, L,
|
|
2709
|
-
if (D.resolve(
|
|
2710
|
-
throw new k(L ?? f[g], f[g],
|
|
2708
|
+
let [g, L, v] = _e(y);
|
|
2709
|
+
if (D.resolve(v), g != null && g !== f.OK)
|
|
2710
|
+
throw new k(L ?? f[g], f[g], v);
|
|
2711
2711
|
return g != null && (O = {
|
|
2712
2712
|
code: f[g],
|
|
2713
2713
|
detail: L ?? f[g]
|
|
@@ -2723,10 +2723,10 @@ class un {
|
|
|
2723
2723
|
F = e.O.fromBinary(L, l.binaryOptions);
|
|
2724
2724
|
break;
|
|
2725
2725
|
case P.TRAILER:
|
|
2726
|
-
let
|
|
2727
|
-
[
|
|
2728
|
-
code: f[
|
|
2729
|
-
detail: G ?? f[
|
|
2726
|
+
let v, G;
|
|
2727
|
+
[v, G, W] = Ye(L), O = {
|
|
2728
|
+
code: f[v],
|
|
2729
|
+
detail: G ?? f[v]
|
|
2730
2730
|
};
|
|
2731
2731
|
break;
|
|
2732
2732
|
}
|
|
@@ -2749,7 +2749,7 @@ class un {
|
|
|
2749
2749
|
}), new en(e, (o = l.meta) !== null && o !== void 0 ? o : {}, t, D.promise, Y.promise, M.promise, te.promise);
|
|
2750
2750
|
}
|
|
2751
2751
|
}
|
|
2752
|
-
class hn extends
|
|
2752
|
+
class hn extends C {
|
|
2753
2753
|
constructor() {
|
|
2754
2754
|
super("com.hamropatro.grpc.cms.CreateFolderRequest", [
|
|
2755
2755
|
{
|
|
@@ -2813,7 +2813,7 @@ class hn extends v {
|
|
|
2813
2813
|
}
|
|
2814
2814
|
}
|
|
2815
2815
|
const ft = new hn();
|
|
2816
|
-
class fn extends
|
|
2816
|
+
class fn extends C {
|
|
2817
2817
|
constructor() {
|
|
2818
2818
|
super("com.hamropatro.grpc.cms.GetAllFoldersRequest", [
|
|
2819
2819
|
{
|
|
@@ -2866,7 +2866,7 @@ class fn extends v {
|
|
|
2866
2866
|
}
|
|
2867
2867
|
}
|
|
2868
2868
|
const dn = new fn();
|
|
2869
|
-
class mn extends
|
|
2869
|
+
class mn extends C {
|
|
2870
2870
|
constructor() {
|
|
2871
2871
|
super("com.hamropatro.grpc.cms.GetAllFoldersResponse", [
|
|
2872
2872
|
{ no: 1, name: "folder", kind: "message", repeat: 1, T: () => le },
|
|
@@ -2926,7 +2926,7 @@ class mn extends v {
|
|
|
2926
2926
|
}
|
|
2927
2927
|
}
|
|
2928
2928
|
const pn = new mn();
|
|
2929
|
-
class gn extends
|
|
2929
|
+
class gn extends C {
|
|
2930
2930
|
constructor() {
|
|
2931
2931
|
super("com.hamropatro.grpc.cms.Folder", [
|
|
2932
2932
|
{
|
|
@@ -3000,7 +3000,7 @@ 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 le = new gn(), Fe = new
|
|
3003
|
+
const le = new gn(), Fe = new Ce("com.hamropatro.grpc.cms.FolderService", [
|
|
3004
3004
|
{ name: "createFolder", options: {}, I: ft, O: le },
|
|
3005
3005
|
{ name: "getFolders", options: {}, I: dn, O: pn },
|
|
3006
3006
|
{ name: "updateFolder", options: {}, I: le, O: le }
|
|
@@ -3035,7 +3035,7 @@ class bn {
|
|
|
3035
3035
|
}
|
|
3036
3036
|
}
|
|
3037
3037
|
var Se = /* @__PURE__ */ ((i) => (i[i.IMAGE = 0] = "IMAGE", i[i.AUDIO = 1] = "AUDIO", i[i.VIDEO = 2] = "VIDEO", i[i.ALL = 3] = "ALL", i))(Se || {});
|
|
3038
|
-
class wn extends
|
|
3038
|
+
class wn extends C {
|
|
3039
3039
|
constructor() {
|
|
3040
3040
|
super("com.hamropatro.grpc.cms.CreateFileRequest", [
|
|
3041
3041
|
{
|
|
@@ -3115,7 +3115,7 @@ class wn extends v {
|
|
|
3115
3115
|
}
|
|
3116
3116
|
}
|
|
3117
3117
|
const dt = new wn();
|
|
3118
|
-
class yn extends
|
|
3118
|
+
class yn extends C {
|
|
3119
3119
|
constructor() {
|
|
3120
3120
|
super("com.hamropatro.grpc.cms.File", [
|
|
3121
3121
|
{
|
|
@@ -3233,7 +3233,7 @@ class yn extends v {
|
|
|
3233
3233
|
}
|
|
3234
3234
|
}
|
|
3235
3235
|
const ce = new yn();
|
|
3236
|
-
class Nn extends
|
|
3236
|
+
class Nn extends C {
|
|
3237
3237
|
constructor() {
|
|
3238
3238
|
super("com.hamropatro.grpc.cms.FileMetadata", [
|
|
3239
3239
|
{
|
|
@@ -3308,7 +3308,7 @@ class Nn extends v {
|
|
|
3308
3308
|
}
|
|
3309
3309
|
}
|
|
3310
3310
|
const Ae = new Nn();
|
|
3311
|
-
class kn extends
|
|
3311
|
+
class kn extends C {
|
|
3312
3312
|
constructor() {
|
|
3313
3313
|
super("com.hamropatro.grpc.cms.DeleteFileRequest", [
|
|
3314
3314
|
{
|
|
@@ -3350,7 +3350,7 @@ class kn extends v {
|
|
|
3350
3350
|
}
|
|
3351
3351
|
}
|
|
3352
3352
|
const En = new kn();
|
|
3353
|
-
class In extends
|
|
3353
|
+
class In extends C {
|
|
3354
3354
|
constructor() {
|
|
3355
3355
|
super("com.hamropatro.grpc.cms.DeleteFileResponse", [
|
|
3356
3356
|
{
|
|
@@ -3392,7 +3392,7 @@ class In extends v {
|
|
|
3392
3392
|
}
|
|
3393
3393
|
}
|
|
3394
3394
|
const Tn = new In();
|
|
3395
|
-
class On extends
|
|
3395
|
+
class On extends C {
|
|
3396
3396
|
constructor() {
|
|
3397
3397
|
super("com.hamropatro.grpc.cms.GetFilesByFolderRequest", [
|
|
3398
3398
|
{
|
|
@@ -3456,7 +3456,7 @@ class On extends v {
|
|
|
3456
3456
|
}
|
|
3457
3457
|
}
|
|
3458
3458
|
const Bn = new On();
|
|
3459
|
-
class Fn extends
|
|
3459
|
+
class Fn extends C {
|
|
3460
3460
|
constructor() {
|
|
3461
3461
|
super("com.hamropatro.grpc.cms.GetFilesByFolderResponse", [
|
|
3462
3462
|
{ no: 1, name: "files", kind: "message", repeat: 1, T: () => ce },
|
|
@@ -3515,7 +3515,7 @@ class Fn extends v {
|
|
|
3515
3515
|
return r !== !1 && (r == !0 ? N.onWrite : r)(this.typeName, e, t), t;
|
|
3516
3516
|
}
|
|
3517
3517
|
}
|
|
3518
|
-
const An = new Fn(), De = new
|
|
3518
|
+
const An = new Fn(), De = new Ce("com.hamropatro.grpc.cms.FileService", [
|
|
3519
3519
|
{ name: "createFile", options: {}, I: dt, O: ce },
|
|
3520
3520
|
{ name: "updateFile", options: {}, I: ce, O: ce },
|
|
3521
3521
|
{ name: "deleteFile", options: {}, I: En, O: Tn },
|
|
@@ -3557,7 +3557,7 @@ class Dn {
|
|
|
3557
3557
|
return ee("unary", this._transport, n, r, e);
|
|
3558
3558
|
}
|
|
3559
3559
|
}
|
|
3560
|
-
class Ln extends
|
|
3560
|
+
class Ln extends C {
|
|
3561
3561
|
constructor() {
|
|
3562
3562
|
super("com.hamropatro.grpc.cms.ImageUploadRequest", []);
|
|
3563
3563
|
}
|
|
@@ -3574,7 +3574,7 @@ class Ln extends v {
|
|
|
3574
3574
|
}
|
|
3575
3575
|
}
|
|
3576
3576
|
const mt = new Ln();
|
|
3577
|
-
class Un extends
|
|
3577
|
+
class Un extends C {
|
|
3578
3578
|
constructor() {
|
|
3579
3579
|
super("com.hamropatro.grpc.cms.ImageUploadResponse", [
|
|
3580
3580
|
{
|
|
@@ -3626,7 +3626,7 @@ class Un extends v {
|
|
|
3626
3626
|
return r !== !1 && (r == !0 ? N.onWrite : r)(this.typeName, e, t), t;
|
|
3627
3627
|
}
|
|
3628
3628
|
}
|
|
3629
|
-
const Rn = new Un(), Le = new
|
|
3629
|
+
const Rn = new Un(), Le = new Ce("com.hamropatro.grpc.cms.ImageUploadService", [
|
|
3630
3630
|
{ name: "Upload", options: {}, I: mt, O: Rn }
|
|
3631
3631
|
]);
|
|
3632
3632
|
class xn {
|
|
@@ -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
|
-
}),
|
|
3651
|
+
}), vn = new bn(Me), ye = ft.create(), Cn = new Dn(Me), oe = dt.create(), Sn = new xn(Me);
|
|
3652
3652
|
mt.create();
|
|
3653
3653
|
const pt = async () => {
|
|
3654
3654
|
try {
|
|
@@ -3660,7 +3660,7 @@ const pt = async () => {
|
|
|
3660
3660
|
}
|
|
3661
3661
|
}, Mn = async (i, e) => {
|
|
3662
3662
|
try {
|
|
3663
|
-
const t = Vn(i), r = (await pt()).response.url;
|
|
3663
|
+
const t = Vn(i, e), r = (await pt()).response.url;
|
|
3664
3664
|
return await fetch(r, {
|
|
3665
3665
|
method: "PUT",
|
|
3666
3666
|
headers: {
|
|
@@ -3672,14 +3672,17 @@ const pt = async () => {
|
|
|
3672
3672
|
} catch (t) {
|
|
3673
3673
|
throw t;
|
|
3674
3674
|
}
|
|
3675
|
-
}, Vn = (i) => {
|
|
3676
|
-
const
|
|
3677
|
-
|
|
3678
|
-
|
|
3679
|
-
|
|
3675
|
+
}, Vn = (i, e) => {
|
|
3676
|
+
const t = e.type.split("/")[0];
|
|
3677
|
+
let n = "";
|
|
3678
|
+
t === "video" ? n = i == null ? void 0 : i.replace(/^data:video\/\w+;base64,/, "") : t === "image" && (n = i == null ? void 0 : i.replace(/^data:image\/\w+;base64,/, ""));
|
|
3679
|
+
const r = atob(n), s = new Uint8Array(r.length);
|
|
3680
|
+
for (let a = 0; a < r.length; a++)
|
|
3681
|
+
s[a] = r.charCodeAt(a);
|
|
3682
|
+
return s;
|
|
3680
3683
|
}, $n = async (i, e, t) => {
|
|
3681
3684
|
try {
|
|
3682
|
-
return ye.name = i, ye.nestedFolderName = e, ye.createdBy = t, await
|
|
3685
|
+
return ye.name = i, ye.nestedFolderName = e, ye.createdBy = t, await vn.createFolder(
|
|
3683
3686
|
ye
|
|
3684
3687
|
);
|
|
3685
3688
|
} catch (n) {
|
|
@@ -3687,7 +3690,7 @@ const pt = async () => {
|
|
|
3687
3690
|
}
|
|
3688
3691
|
}, jn = async (i, e, t, n, r) => {
|
|
3689
3692
|
try {
|
|
3690
|
-
return oe.name = i, oe.nestedFolderName = e, oe.url = t, oe.type = n, oe.folderName = r, await
|
|
3693
|
+
return oe.name = i, oe.nestedFolderName = e, oe.url = t, oe.type = n, oe.folderName = r, await Cn.createFile(
|
|
3691
3694
|
oe
|
|
3692
3695
|
);
|
|
3693
3696
|
} catch (s) {
|
|
@@ -3826,10 +3829,7 @@ class Kn {
|
|
|
3826
3829
|
s.classList.contains("checked") ? (s.classList.remove("checked"), I(this, T, d(this, T).filter(
|
|
3827
3830
|
(c) => (c == null ? void 0 : c.url) !== (e == null ? void 0 : e.url)
|
|
3828
3831
|
))) : (s.classList.add("checked"), d(this, T).push(e)), this._updateDialogContent();
|
|
3829
|
-
}), d(this, Q) ? (I(this, ae, fe(et, "loader")), d(this, B).
|
|
3830
|
-
d(this, ae),
|
|
3831
|
-
d(this, B).firstChild
|
|
3832
|
-
)) : (s.append(r, n), d(this, B).style.width = "100%", d(this, B).appendChild(s));
|
|
3832
|
+
}), d(this, Q) ? d(this, B).querySelector(".loader") || (I(this, ae, fe(et, "loader")), d(this, B).style.width = "100%", d(this, B).appendChild(d(this, ae))) : (s.append(r, n), d(this, B).style.width = "100%", d(this, B).appendChild(s));
|
|
3833
3833
|
const a = ne(
|
|
3834
3834
|
e.name,
|
|
3835
3835
|
"selected-image-name"
|
|
@@ -3858,13 +3858,13 @@ class Kn {
|
|
|
3858
3858
|
}
|
|
3859
3859
|
async addSelectedImages(e, t) {
|
|
3860
3860
|
I(this, Q, !0), this.updateSelectedImages();
|
|
3861
|
-
const n = await Mn(e);
|
|
3862
|
-
d(this, T).
|
|
3861
|
+
const n = await Mn(e, t);
|
|
3862
|
+
d(this, T).unshift({
|
|
3863
3863
|
url: n,
|
|
3864
3864
|
name: t.name,
|
|
3865
3865
|
type: t.type,
|
|
3866
3866
|
size: t.size
|
|
3867
|
-
}),
|
|
3867
|
+
}), I(this, Q, !1), this.updateSelectedImages();
|
|
3868
3868
|
}
|
|
3869
3869
|
async createFolder(e, t = 2) {
|
|
3870
3870
|
try {
|
|
@@ -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,de,se,
|
|
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
|
-
`)}}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(
|
|
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
|
|
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,F,X,oe,G,ae,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,o=0;for(let a=0;a<i.length;a++){if(s=ye[i.charCodeAt(a)],s===void 0)switch(i[a]){case"=":r=0;case`
|
|
3
|
+
`:case"\r":case" ":case" ":continue;default:throw Error("invalid base64 string.")}switch(r){case 0:o=s,r=1;break;case 1:t[n++]=o<<2|(s&48)>>4,o=s,r=2;break;case 2:t[n++]=(o&15)<<4|(s&60)>>2,o=s,r=3;break;case 3:t[n++]=(o&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,o)=>{(e(n)?n[i.symbol]:n[i.symbol]=[]).push({no:r,wireType:s,data:o})},i.onWrite=(t,n,r)=>{for(let{no:s,wireType:o,data:a}of i.list(n))r.tag(s,o).raw(a)},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 o=i>>>s,a=!(!(o>>>7)&&e==0),l=(a?o|128:o)&255;if(t.push(l),!a)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 o=e>>>s,a=!!(o>>>7),l=(a?o|128:o)&255;if(t.push(l),!a)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(o,a){const l=Number(i.slice(o,a));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,o=n+r*8147497,a=r*2,l=1e7;s>=l&&(o+=Math.floor(s/l),s%=l),o>=l&&(a+=Math.floor(o/l),o%=l);function c(h,p){let y=h?String(h):"";return p?"0000000".slice(y.length)+y:y}return c(a,0)+c(o,a)+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 v 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 v(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 v(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 v(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)}}v.ZERO=new v(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 v(...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 v(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=v.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=v.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 vt(i){return i?Object.assign(Object.assign({},ze),i):ze}function Ct(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(o=>!r.includes(o))||!n&&r.some(o=>!s.known.includes(o)))return!1;if(t<1)return!0;for(const o of s.oneofs){const a=e[o];if(!Vt(a))return!1;if(a.oneofKind===void 0)continue;const l=this.fields.find(c=>c.localName===a.oneofKind);if(!l||!this.field(a[a.oneofKind],l,n,t))return!1}for(const o of this.fields)if(o.oneof===void 0&&!this.field(e[o.localName],o,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,o]of Object.entries(e)){const a=this.fMap[s];if(!a){if(!n.ignoreUnknownFields)throw new Error(`Found unknown field while reading ${this.info.typeName} from JSON format. JSON key: ${s}`);continue}const l=a.localName;let c;if(a.oneof){if(o===null&&(a.kind!=="enum"||a.T()[0]!=="google.protobuf.NullValue"))continue;if(r.includes(a.oneof))throw new Error(`Multiple members of the oneof group "${a.oneof}" of ${this.info.typeName} are present in JSON.`);r.push(a.oneof),c=t[a.oneof]={oneofKind:l}}else c=t;if(a.kind=="map"){if(o===null)continue;this.assert(kt(o),a.name,o);const h=c[l];for(const[p,y]of Object.entries(o)){this.assert(y!==null,a.name+" map value",null);let U;switch(a.V.kind){case"message":U=a.V.T().internalJsonRead(y,n);break;case"enum":if(U=this.enum(a.V.T(),y,a.name,n.ignoreUnknownFields),U===!1)continue;break;case"scalar":U=this.scalar(y,a.V.T,a.V.L,a.name);break}this.assert(U!==void 0,a.name+" map value",y);let L=p;a.K==u.BOOL&&(L=L=="true"?!0:L=="false"?!1:L),L=this.scalar(L,a.K,K.STRING,a.name).toString(),h[L]=U}}else if(a.repeat){if(o===null)continue;this.assert(Array.isArray(o),a.name,o);const h=c[l];for(const p of o){this.assert(p!==null,a.name,null);let y;switch(a.kind){case"message":y=a.T().internalJsonRead(p,n);break;case"enum":if(y=this.enum(a.T(),p,a.name,n.ignoreUnknownFields),y===!1)continue;break;case"scalar":y=this.scalar(p,a.T,a.L,a.name);break}this.assert(y!==void 0,a.name,o),h.push(y)}}else switch(a.kind){case"message":if(o===null&&a.T().typeName!="google.protobuf.Value"){this.assert(a.oneof===void 0,a.name+" (oneof member)",null);continue}c[l]=a.T().internalJsonRead(o,n,c[l]);break;case"enum":let h=this.enum(a.T(),o,a.name,n.ignoreUnknownFields);if(h===!1)continue;c[l]=h;break;case"scalar":c[l]=this.scalar(o,a.T,a.L,a.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 o=e[1][s];return typeof o>"u"&&r?!1:(b(typeof o=="number",`Unable to parse field ${this.info.typeName}#${n}, enum ${e[0]} has no value for "${t}".`),o)}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 o=Number(e);if(Number.isNaN(o)){s="not a number";break}if(!Number.isFinite(o)){s="too large or small";break}return t==u.FLOAT&&Le(o),o;case u.INT32:case u.FIXED32:case u.SFIXED32:case u.SINT32:case u.UINT32:if(e===null)return 0;let a;if(typeof e=="number"?a=e:e===""?s="empty string":typeof e=="string"&&(e.trim().length!==e.length?s="extra whitespace":a=Number(e)),a===void 0)break;return t==u.UINT32?Ie(a):ge(a),a;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(v.ZERO,n);if(typeof e!="number"&&typeof e!="string")break;return P(v.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(o){s=o.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 o=r[s.oneof];if(o.oneofKind!==s.localName)continue;const a=s.kind=="scalar"||s.kind=="enum"?Object.assign(Object.assign({},t),{emitDefaultValues:!0}):t;let l=this.field(s,o[s.localName],a);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 o=e.V.T();for(const[l,c]of Object.entries(t)){const h=this.message(o,c,e.name,n);b(h!==void 0),s[l.toString()]=h}break;case"enum":const a=e.V.T();for(const[l,c]of Object.entries(t)){b(c===void 0||typeof c=="number");const h=this.enum(a,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 o=e.T();for(let l=0;l<t.length;l++){b(t[l]===void 0||typeof t[l]=="number");const c=this.enum(o,t[l],e.name,e.opt,!0,n.enumAsInteger);b(c!==void 0),s.push(c)}break;case"message":const a=e.T();for(let l=0;l<t.length;l++){const c=this.message(a,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,o){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)),o||!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 o=s||r;switch(e){case u.INT32:case u.SFIXED32:case u.SINT32:return t===0?o?0:void 0:(ge(t),t);case u.FIXED32:case u.UINT32:return t===0?o?0:void 0:(Ie(t),t);case u.FLOAT:Le(t);case u.DOUBLE:return t===0?o?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===""?o?"":void 0:(b(typeof t=="string"),t);case u.BOOL:return t===!1?o?!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 a=v.from(t);return a.isZero()&&!o?void 0:a.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()&&!o?void 0:l.toString();case u.BYTES:return b(t instanceof Uint8Array),t.byteLength?We(t):o?"":void 0}}}function Re(i,e=K.STRING){switch(i){case u.BOOL:return!1;case u.UINT64:case u.FIXED64:return P(v.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[o,a]=e.tag(),l=this.fieldNoToField.get(o);if(!l){let y=n.readUnknownField;if(y=="throw")throw new Error(`Unknown field ${o} (wire type ${a}) for ${this.info.typeName}`);let U=e.skip(a);y!==!1&&(y===!0?k.onRead:y)(this.info.typeName,t,o,a,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 A=c[p];if(a==m.LengthDelimited&&y!=u.STRING&&y!=u.BYTES){let q=e.uint32()+e.pos;for(;e.pos<q;)A.push(this.scalar(e,y,U))}else A.push(this.scalar(e,y,U))}else c[p]=this.scalar(e,y,U);break;case"message":if(h){let A=c[p],q=l.T().internalBinaryRead(e,e.uint32(),n);A.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,o,a;for(;t.pos<s;){let[l,c]=t.tag();switch(l){case 1:e.K==u.BOOL?o=t.bool().toString():o=this.scalar(t,e.K,K.STRING);break;case 2:switch(e.V.kind){case"scalar":a=this.scalar(t,e.V.T,e.V.L);break;case"enum":a=t.int32();break;case"message":a=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(o===void 0){let l=Re(e.K);o=e.K==u.BOOL?l.toString():l}if(a===void 0)switch(e.V.kind){case"scalar":a=Re(e.V.T,e.V.L);break;case"enum":a=0;break;case"message":a=e.V.T().create();break}return[o,a]}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 o,a,l=s.repeat,c=s.localName;if(s.oneof){const h=e[s.oneof];if(h.oneofKind!==c)continue;o=h[c],a=!0}else o=e[c],a=!1;switch(s.kind){case"scalar":case"enum":let h=s.kind=="enum"?u.INT32:s.T;if(l)if(b(Array.isArray(o)),l==Te.PACKED)this.packed(t,h,s.no,o);else for(const p of o)this.scalar(t,h,s.no,p,!0);else o===void 0?b(s.opt):this.scalar(t,h,s.no,o,a||s.opt);break;case"message":if(l){b(Array.isArray(o));for(const p of o)this.message(t,n,s.T(),s.no,p)}else this.message(t,n,s.T(),s.no,o);break;case"map":b(typeof o=="object"&&o!==null);for(const[p,y]of Object.entries(o))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 o=r;switch(n.K){case u.INT32:case u.FIXED32:case u.UINT32:case u.SFIXED32:case u.SINT32:o=Number.parseInt(r);break;case u.BOOL:b(r=="true"||r=="false"),o=r=="true";break}switch(this.scalar(e,n.K,1,o,!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[o,a,l]=this.scalarInfo(t,r);(!l||s)&&(e.tag(n,o),e[a](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 o=0;o<r.length;o++)e[s](r[o]);e.join()}scalarInfo(e,t){let n=m.Varint,r,s=t===void 0,o=t===0;switch(e){case u.INT32:r="int32";break;case u.STRING:o=s||!t.length,n=m.LengthDelimited,r="string";break;case u.BOOL:o=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:o=s||D.from(t).isZero(),r="int64";break;case u.UINT64:o=s||v.from(t).isZero(),r="uint64";break;case u.FIXED64:o=s||v.from(t).isZero(),n=m.Bit64,r="fixed64";break;case u.BYTES:o=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:o=s||D.from(t).isZero(),n=m.Bit64,r="sfixed64";break;case u.SINT32:r="sint32";break;case u.SINT64:o=s||D.from(t).isZero(),r="sint64";break}return[n,r,s||o]}}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 C(i,e,t){let n,r=t,s;for(let o of i.fields){let a=o.localName;if(o.oneof){const l=r[o.oneof];if((l==null?void 0:l.oneofKind)==null)continue;if(n=l[a],s=e[o.oneof],s.oneofKind=l.oneofKind,n==null){delete s[a];continue}}else if(n=r[a],s=e,n==null)continue;switch(o.repeat&&(s[a].length=n.length),o.kind){case"scalar":case"enum":if(o.repeat)for(let c=0;c<n.length;c++)s[a][c]=n[c];else s[a]=n;break;case"message":let l=o.T();if(o.repeat)for(let c=0;c<n.length;c++)s[a][c]=l.create(n[c]);else s[a]===void 0?s[a]=l.create(n):l.mergePartial(s[a],n);break;case"map":switch(o.V.kind){case"scalar":case"enum":Object.assign(s[a],n);break;case"message":let c=o.V.T();for(let h of Object.keys(n))s[a][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],o=n.oneof?t[n.oneof][r]:t[r];switch(n.kind){case"enum":case"scalar":let a=n.kind=="enum"?u.INT32:n.T;if(!(n.repeat?tt(a,s,o):et(a,s,o)))return!1;break;case"map":if(!(n.V.kind=="message"?nt(n.V.T(),Oe(s),Oe(o)):tt(n.V.kind=="enum"?u.INT32:n.V.T,Oe(s),Oe(o))))return!1;break;case"message":let l=n.T();if(!(n.repeat?nt(l,s,o):l.equals(s,o)))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&&C(this,t,e),t}clone(e){let t=this.create();return C(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){C(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,vt(t))}fromJsonString(e,t){let n=JSON.parse(e);return this.fromJson(n,t)}toJson(e,t){return this.internalJsonWrite(e,Ct(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
|
+
`)}}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(o){o(s)})}return new(t||(t=Promise))(function(s,o){function a(h){try{c(n.next(h))}catch(p){o(p)}}function l(h){try{c(n.throw(h))}catch(p){o(p)}}function c(h){h.done?s(h.value):r(h.value).then(a,l)}c((n=n.apply(i,e||[])).next())})};class zt{constructor(e,t,n,r,s,o,a){this.method=e,this.requestHeaders=t,this.request=n,this.headers=r,this.response=s,this.status=o,this.trailers=a}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(o){o(s)})}return new(t||(t=Promise))(function(s,o){function a(h){try{c(n.next(h))}catch(p){o(p)}}function l(h){try{c(n.throw(h))}catch(p){o(p)}}function c(h){h.done?s(h.value):r(h.value).then(a,l)}c((n=n.apply(i,e||[])).next())})};class en{constructor(e,t,n,r,s,o,a){this.method=e,this.requestHeaders=t,this.request=n,this.headers=r,this.responses=s,this.status=o,this.trailers=a}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 o=(a,l,c)=>e.unary(a,l,c);for(const a of((s=n.interceptors)!==null&&s!==void 0?s:[]).filter(l=>l.interceptUnary).reverse()){const l=o;o=(c,h,p)=>a.interceptUnary(l,c,h,p)}return o(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(o){o(s)})}return new(t||(t=Promise))(function(s,o){function a(h){try{c(n.next(h))}catch(p){o(p)}}function l(h){try{c(n.throw(h))}catch(p){o(p)}}function c(h){h.done?s(h.value):r(h.value).then(a,l)}c((n=n.apply(i,e||[])).next())})};function it(i,e,t,n,r){if(n)for(let[s,o]of Object.entries(n))if(typeof o=="string")i.append(s,o);else for(let a of o)i.append(s,a);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(),o=Date.now();if(s<=o)throw new I(`deadline ${t} exceeded`,f[f.DEADLINE_EXCEEDED]);i.set("grpc-timeout",`${s-o}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(on(l.headers),l.status,l.statusText)}let n=i,r=e>=200&&e<300,s=ct(n),[o,a]=lt(n);return(o===void 0||o===f.OK)&&!r&&(o=an(e),a=t),[o,a,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 ot(i,e,t){return tn(this,void 0,void 0,function*(){let n,r="",s=new Uint8Array(0),o=rn(e);if(nn(i)){let a=i.getReader();n={next:()=>a.read()}}else n=i[Symbol.asyncIterator]();for(;;){let a=yield n.next();if(a.value!==void 0){if(o==="text"){for(let c=0;c<a.value.length;c++)r+=String.fromCharCode(a.value[c]);let l=r.length-r.length%4;if(l===0)continue;s=at(s,Pe(r.substring(0,l))),r=r.substring(l)}else s=at(s,a.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(a.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 at(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 o=e[n];typeof o=="string"?e[n]=[o,s]:Array.isArray(o)?o.push(s):e[n]=s}return e}function on(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 an(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,o,a;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,A,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:(o=n.abort)!==null&&o!==void 0?o: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&&(A={code:f[g],detail:R??f[g]}),N}).then(N=>{if(!N.body)throw new I("missing response body",f[f.INTERNAL]);return ot(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),A={code:f[V],detail:z??f[V]};break}})}).then(()=>{if(!J&&!ne)throw new I("missing trailers",f[f.DATA_LOSS]);if(!A)throw new I("missing status",f[f.INTERNAL]);if(A.code!=="OK")throw new I(A.detail,A.code,J);L.notifyComplete(),q.resolve(A),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,(a=l.meta)!==null&&a!==void 0?a:{},t,U.promise,L,q.promise,le.promise)}unary(e,t,n){var r,s,o,a;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,A,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:(o=n.abort)!==null&&o!==void 0?o: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&&(A={code:f[g],detail:R??f[g]}),N}).then(N=>{if(!N.body)throw new I("missing response body",f[f.INTERNAL]);return ot(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),A={code:f[V],detail:z??f[V]};break}})}).then(()=>{if(!J&&L)throw new I("missing trailers",f[f.DATA_LOSS]);if(!A)throw new I("missing status",f[f.INTERNAL]);if(!L&&A.code==="OK")throw new I("expected error status",f[f.DATA_LOSS]);if(!L)throw new I(A.detail,A.code,J);if(ne.resolve(L),A.code!=="OK")throw new I(A.detail,A.code,J);q.resolve(A),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,(a=l.meta)!==null&&a!==void 0?a:{},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&&C(this,t,e),t}internalBinaryRead(e,t,n,r){let s=r??this.create(),o=e.pos+t;for(;e.pos<o;){let[a,l]=e.tag();switch(a){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 ${a} (wire type ${l}) for ${this.typeName}`);let h=e.skip(l);c!==!1&&(c===!0?k.onRead:c)(this.typeName,s,a,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&&C(this,t,e),t}internalBinaryRead(e,t,n,r){let s=r??this.create(),o=e.pos+t;for(;e.pos<o;){let[a,l]=e.tag();switch(a){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 ${a} (wire type ${l}) for ${this.typeName}`);let h=e.skip(l);c!==!1&&(c===!0?k.onRead:c)(this.typeName,s,a,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&&C(this,t,e),t}internalBinaryRead(e,t,n,r){let s=r??this.create(),o=e.pos+t;for(;e.pos<o;){let[a,l]=e.tag();switch(a){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 ${a} (wire type ${l}) for ${this.typeName}`);let h=e.skip(l);c!==!1&&(c===!0?k.onRead:c)(this.typeName,s,a,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&&C(this,t,e),t}internalBinaryRead(e,t,n,r){let s=r??this.create(),o=e.pos+t;for(;e.pos<o;){let[a,l]=e.tag();switch(a){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 ${a} (wire type ${l}) for ${this.typeName}`);let h=e.skip(l);c!==!1&&(c===!0?k.onRead:c)(this.typeName,s,a,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,ve=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",ve.typeName);_(this,"methods",ve.methods);_(this,"options",ve.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 Ce=(i=>(i[i.IMAGE=0]="IMAGE",i[i.AUDIO=1]="AUDIO",i[i.VIDEO=2]="VIDEO",i[i.ALL=3]="ALL",i))(Ce||{});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",Ce]}])}create(e){const t=globalThis.Object.create(this.messagePrototype);return t.name="",t.folderName="",t.nestedFolderName="",t.url="",t.type=0,e!==void 0&&C(this,t,e),t}internalBinaryRead(e,t,n,r){let s=r??this.create(),o=e.pos+t;for(;e.pos<o;){let[a,l]=e.tag();switch(a){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 ${a} (wire type ${l}) for ${this.typeName}`);let h=e.skip(l);c!==!1&&(c===!0?k.onRead:c)(this.typeName,s,a,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",Ce]},{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&&C(this,t,e),t}internalBinaryRead(e,t,n,r){let s=r??this.create(),o=e.pos+t;for(;e.pos<o;){let[a,l]=e.tag();switch(a){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 ${a} (wire type ${l}) for ${this.typeName}`);let h=e.skip(l);c!==!1&&(c===!0?k.onRead:c)(this.typeName,s,a,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&&C(this,t,e),t}internalBinaryRead(e,t,n,r){let s=r??this.create(),o=e.pos+t;for(;e.pos<o;){let[a,l]=e.tag();switch(a){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 ${a} (wire type ${l}) for ${this.typeName}`);let h=e.skip(l);c!==!1&&(c===!0?k.onRead:c)(this.typeName,s,a,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&&C(this,t,e),t}internalBinaryRead(e,t,n,r){let s=r??this.create(),o=e.pos+t;for(;e.pos<o;){let[a,l]=e.tag();switch(a){case 1:s.key=e.string();break;default:let c=n.readUnknownField;if(c==="throw")throw new globalThis.Error(`Unknown field ${a} (wire type ${l}) for ${this.typeName}`);let h=e.skip(l);c!==!1&&(c===!0?k.onRead:c)(this.typeName,s,a,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&&C(this,t,e),t}internalBinaryRead(e,t,n,r){let s=r??this.create(),o=e.pos+t;for(;e.pos<o;){let[a,l]=e.tag();switch(a){case 1:s.isDeleted=e.bool();break;default:let c=n.readUnknownField;if(c==="throw")throw new globalThis.Error(`Unknown field ${a} (wire type ${l}) for ${this.typeName}`);let h=e.skip(l);c!==!1&&(c===!0?k.onRead:c)(this.typeName,s,a,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&&C(this,t,e),t}internalBinaryRead(e,t,n,r){let s=r??this.create(),o=e.pos+t;for(;e.pos<o;){let[a,l]=e.tag();switch(a){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 ${a} (wire type ${l}) for ${this.typeName}`);let h=e.skip(l);c!==!1&&(c===!0?k.onRead:c)(this.typeName,s,a,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&&C(this,t,e),t}internalBinaryRead(e,t,n,r){let s=r??this.create(),o=e.pos+t;for(;e.pos<o;){let[a,l]=e.tag();switch(a){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 ${a} (wire type ${l}) for ${this.typeName}`);let h=e.skip(l);c!==!1&&(c===!0?k.onRead:c)(this.typeName,s,a,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&&C(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&&C(this,t,e),t}internalBinaryRead(e,t,n,r){let s=r??this.create(),o=e.pos+t;for(;e.pos<o;){let[a,l]=e.tag();switch(a){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 ${a} (wire type ${l}) for ${this.typeName}`);let h=e.skip(l);c!==!1&&(c===!0?k.onRead:c)(this.typeName,s,a,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(),vn=new Un($e);ft.create();const dt=async()=>{try{return await vn.upload(dt)}catch(i){throw i}},Cn=async(i,e)=>{try{const t=Sn(i,e),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,e)=>{const t=e.type.split("/")[0];let n="";t==="video"?n=i==null?void 0:i.replace(/^data:video\/\w+;base64,/,""):t==="image"&&(n=i==null?void 0:i.replace(/^data:image\/\w+;base64,/,""));const r=atob(n),s=new Uint8Array(r.length);for(let o=0;o<r.length;o++)s[o]=r.charCodeAt(o);return s},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,F);S(this,X);S(this,oe);S(this,G);S(this,ae);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 o;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,
|
|
19
|
+
</svg>`);e.addEventListener("click",()=>{j.hide(),O(this,B,[])}),O(this,oe,`Upload (${(o=d(this,B))==null?void 0:o.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,oe),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],o=new FileReader;o.readAsDataURL(s),o.onload=async()=>{await this.addSelectedImages(o.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,F,H("selected-image-container")),this.updateSelectedImages(),e.append(d(this,X),d(this,F)),e}updateSelectedImages(){if(!(!d(this,F)||!d(this,X))){if(d(this,F).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,F).innerHTML="";const c=ie();c.textContent="No images selected",d(this,F).style.textAlign="center",d(this,F).style.width="auto",d(this,F).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)?d(this,F).querySelector(".loader")||(O(this,ae,pe(pt,"loader")),d(this,F).style.width="100%",d(this,F).appendChild(d(this,ae))):(s.append(r,n),d(this,F).style.width="100%",d(this,F).appendChild(s));const o=ie(e.name,"selected-image-name"),a=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,o,a),d(this,F).style.width="100%",d(this,F).appendChild(s)});else if(d(this,te))O(this,ae,pe(pt,"loader")),d(this,F).style.width="100%",d(this,F).appendChild(d(this,ae));else{const e=ie();e.textContent="No images selected",d(this,F).style.textAlign="center",d(this,F).style.width="auto",d(this,F).appendChild(e)}this._updateDialogContent()}}_updateDialogContent(){var e;d(this,X).textContent=`Selected Images (${d(this,B).length})`,O(this,oe,`Upload (${d(this,B).length})`),j.updateUploadBtnText(d(this,oe)),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 Cn(e,t);d(this,B).unshift({url:n,name:t.name,type:t.type,size:t.size}),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,F=new WeakMap,X=new WeakMap,oe=new WeakMap,G=new WeakMap,ae=new WeakMap,B=new WeakMap,te=new WeakMap,me=new WeakMap,be=new WeakMap,Pn});
|