image-salon-sdk 1.0.30 → 1.0.32

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/README.md CHANGED
@@ -18,6 +18,7 @@ const imageSalon = new ImageSalon({
18
18
  handleImageUpload();
19
19
  },
20
20
  mode: "development",
21
+ accessToken: `${accessToken}`,
21
22
  parentContainerId: "example",
22
23
  buttonProps: {
23
24
  // optional
@@ -40,8 +41,9 @@ parameters for ImageUpload class
40
41
  ```typescript
41
42
  handleUpload: () => void; //callback to handle upload event on click.
42
43
  parentContainerId: string; //id of the container where you want to load message snippet.
43
- mode: "production" || "development"
44
- endPoint?: string // custom endpoint- ignores mode
44
+ mode: "production" || "development";
45
+ accessToken: string;
46
+ endPoint?: string; // custom endpoint- ignores mode
45
47
  buttonProps?: {
46
48
  buttonText?: string;
47
49
  buttonStyle?: object; // style css object
@@ -4084,7 +4084,7 @@ const Fr = async (i) => {
4084
4084
  let e;
4085
4085
  try {
4086
4086
  i && (e = {
4087
- Authorization: "Bearer " + i
4087
+ Authorization: i
4088
4088
  });
4089
4089
  } catch (n) {
4090
4090
  if (n) throw n;
@@ -4230,7 +4230,7 @@ const xr = async () => {
4230
4230
  return await fetch(r, {
4231
4231
  method: "PUT",
4232
4232
  headers: {
4233
- "Content-Type": "image/*",
4233
+ "Content-Type": e.type.includes("image/") ? e.type : "image/*",
4234
4234
  "x-amz-acl": "public-read"
4235
4235
  },
4236
4236
  body: t
@@ -2,7 +2,7 @@ import './style.css';
2
2
  (function(F,B){typeof exports=="object"&&typeof module<"u"?module.exports=B():typeof define=="function"&&define.amd?define(B):(F=typeof globalThis<"u"?globalThis:F||self,F.ImageSalonSdk=B())})(this,function(){"use strict";var _r=Object.defineProperty;var vn=F=>{throw TypeError(F)};var Dr=(F,B,x)=>B in F?_r(F,B,{enumerable:!0,configurable:!0,writable:!0,value:x}):F[B]=x;var _=(F,B,x)=>Dr(F,typeof B!="symbol"?B+"":B,x),Bn=(F,B,x)=>B.has(F)||vn("Cannot "+x);var d=(F,B,x)=>(Bn(F,B,"read from private field"),x?x.call(F):B.get(F)),k=(F,B,x)=>B.has(F)?vn("Cannot add the same private member more than once"):B instanceof WeakSet?B.add(F):B.set(F,x),f=(F,B,x,Te)=>(Bn(F,B,"write to private field"),Te?Te.call(F,x):B.set(F,x),x);var ue,ve,Be,M,pe,D,$,ye,J,xe,Ce,le,ne,Ee,Pe,Ne,ke,fe,Oe,ce,de,Fe,Ie,me,De,je,z,ge,Ze,qe,Le;function F(i){let e=typeof i;if(e=="object"){if(Array.isArray(i))return"array";if(i===null)return"null"}return e}function B(i){return i!==null&&typeof i=="object"&&!Array.isArray(i)}let x="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/".split(""),Te=[];for(let i=0;i<x.length;i++)Te[x[i].charCodeAt(0)]=i;Te[45]=x.indexOf("+"),Te[95]=x.indexOf("/");function Ct(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=Te[i.charCodeAt(a)],s===void 0)switch(i[a]){case"=":r=0;case`
3
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 Et(i){let e="",t=0,n,r=0;for(let s=0;s<i.length;s++)switch(n=i[s],t){case 0:e+=x[n>>2],r=(n&3)<<4,t=1;break;case 1:e+=x[r|n>>4],r=(n&15)<<2,t=2;break;case 2:e+=x[r|n>>6],e+=x[n&63],t=0;break}return t&&(e+=x[r],e+="=",t==1&&(e+="=")),e}var N;(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])})(N||(N={}));function xn(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 On(){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 st(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 Xe=65536*65536;function Nt(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>=Xe&&(r=r+(n/Xe|0),n=n%Xe)}return s(-24,-18),s(-18,-12),s(-12,-6),s(-6),[e,n,r]}function ot(i,e){if(e>>>0<=2097151)return""+(Xe*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,g){let w=h?String(h):"";return g?"0000000".slice(w.length)+w:w}return c(a,0)+c(o,a)+c(s,1)}function kt(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 _n(){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 I;function Dn(){const i=new DataView(new ArrayBuffer(8));I=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}Dn();function Ft(i){if(!i)throw new Error("BigInt unavailable, see https://github.com/timostamm/protobuf-ts/blob/v1.0.8/MANUAL.md#bigint-support")}const It=/^-?[0-9]+$/,Ge=4294967296,Je=2147483648;class Lt{constructor(e,t){this.lo=e|0,this.hi=t|0}isZero(){return this.lo==0&&this.hi==0}toNumber(){let e=this.hi*Ge+(this.lo>>>0);if(!Number.isSafeInteger(e))throw new Error("cannot convert to safe number");return e}}class Z extends Lt{static from(e){if(I)switch(typeof e){case"string":if(e=="0")return this.ZERO;if(e=="")throw new Error("string is no integer");e=I.C(e);case"number":if(e===0)return this.ZERO;e=I.C(e);case"bigint":if(!e)return this.ZERO;if(e<I.UMIN)throw new Error("signed value for ulong");if(e>I.UMAX)throw new Error("ulong too large");return I.V.setBigUint64(0,e,!0),new Z(I.V.getInt32(0,!0),I.V.getInt32(4,!0))}else switch(typeof e){case"string":if(e=="0")return this.ZERO;if(e=e.trim(),!It.test(e))throw new Error("string is no integer");let[t,n,r]=Nt(e);if(t)throw new Error("signed value for ulong");return new Z(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 Z(e,e/Ge)}throw new Error("unknown value "+typeof e)}toString(){return I?this.toBigInt().toString():ot(this.lo,this.hi)}toBigInt(){return Ft(I),I.V.setInt32(0,this.lo,!0),I.V.setInt32(4,this.hi,!0),I.V.getBigUint64(0,!0)}}Z.ZERO=new Z(0,0);class U extends Lt{static from(e){if(I)switch(typeof e){case"string":if(e=="0")return this.ZERO;if(e=="")throw new Error("string is no integer");e=I.C(e);case"number":if(e===0)return this.ZERO;e=I.C(e);case"bigint":if(!e)return this.ZERO;if(e<I.MIN)throw new Error("signed long too small");if(e>I.MAX)throw new Error("signed long too large");return I.V.setBigInt64(0,e,!0),new U(I.V.getInt32(0,!0),I.V.getInt32(4,!0))}else switch(typeof e){case"string":if(e=="0")return this.ZERO;if(e=e.trim(),!It.test(e))throw new Error("string is no integer");let[t,n,r]=Nt(e);if(t){if(r>Je||r==Je&&n!=0)throw new Error("signed long too small")}else if(r>=Je)throw new Error("signed long too large");let s=new U(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 U(e,e/Ge):new U(-e,-e/Ge).negate()}throw new Error("unknown value "+typeof e)}isNegative(){return(this.hi&Je)!==0}negate(){let e=~this.hi,t=this.lo;return t?t=~t+1:e+=1,new U(t,e)}toString(){if(I)return this.toBigInt().toString();if(this.isNegative()){let e=this.negate();return"-"+ot(e.lo,e.hi)}return ot(this.lo,this.hi)}toBigInt(){return Ft(I),I.V.setInt32(0,this.lo,!0),I.V.setInt32(4,this.hi,!0),I.V.getBigInt64(0,!0)}}U.ZERO=new U(0,0);const At={readUnknownField:!0,readerFactory:i=>new Un(i)};function Sn(i){return i?Object.assign(Object.assign({},At),i):At}class Un{constructor(e,t){this.varint64=On,this.uint32=_n,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 U(...this.varint64())}uint64(){return new Z(...this.varint64())}sint64(){let[e,t]=this.varint64(),n=-(e&1);return e=(e>>>1|(t&1)<<31)^n,t=t>>>1^n,new U(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 Z(this.sfixed32(),this.sfixed32())}sfixed64(){return new U(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 E(i,e){if(!i)throw new Error(e)}const Rn=34028234663852886e22,Mn=-34028234663852886e22,Vn=4294967295,Hn=2147483647,$n=-2147483648;function Me(i){if(typeof i!="number")throw new Error("invalid int 32: "+typeof i);if(!Number.isInteger(i)||i>Hn||i<$n)throw new Error("invalid int 32: "+i)}function ze(i){if(typeof i!="number")throw new Error("invalid uint 32: "+typeof i);if(!Number.isInteger(i)||i>Vn||i<0)throw new Error("invalid uint 32: "+i)}function at(i){if(typeof i!="number")throw new Error("invalid float 32: "+typeof i);if(Number.isFinite(i)&&(i>Rn||i<Mn))throw new Error("invalid float 32: "+i)}const Tt={writeUnknownFields:!0,writerFactory:()=>new Pn};function Wn(i){return i?Object.assign(Object.assign({},Tt),i):Tt}class Pn{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(ze(e);e>127;)this.buf.push(e&127|128),e=e>>>7;return this.buf.push(e),this}int32(e){return Me(e),kt(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){at(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){ze(e);let t=new Uint8Array(4);return new DataView(t.buffer).setUint32(0,e,!0),this.raw(t)}sfixed32(e){Me(e);let t=new Uint8Array(4);return new DataView(t.buffer).setInt32(0,e,!0),this.raw(t)}sint32(e){return Me(e),e=(e<<1^e>>31)>>>0,kt(e,this.buf),this}sfixed64(e){let t=new Uint8Array(8),n=new DataView(t.buffer),r=U.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=Z.from(e);return n.setInt32(0,r.lo,!0),n.setInt32(4,r.hi,!0),this.raw(t)}int64(e){let t=U.from(e);return st(t.lo,t.hi,this.buf),this}sint64(e){let t=U.from(e),n=t.hi>>31,r=t.lo<<1^n,s=(t.hi<<1|t.lo>>>31)^n;return st(r,s,this.buf),this}uint64(e){let t=Z.from(e);return st(t.lo,t.hi,this.buf),this}}const vt={emitDefaultValues:!1,enumAsInteger:!1,useProtoFieldName:!1,prettySpaces:0},Bt={ignoreUnknownFields:!1};function jn(i){return i?Object.assign(Object.assign({},Bt),i):Bt}function Zn(i){return i?Object.assign(Object.assign({},vt),i):vt}function qn(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 xt=Symbol.for("protobuf-ts/message-type");function lt(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 se;(function(i){i[i.BIGINT=0]="BIGINT",i[i.STRING=1]="STRING",i[i.NUMBER=2]="NUMBER"})(se||(se={}));var Ye;(function(i){i[i.NO=0]="NO",i[i.PACKED=1]="PACKED",i[i.UNPACKED=2]="UNPACKED"})(Ye||(Ye={}));function Kn(i){var e,t,n,r;return i.localName=(e=i.localName)!==null&&e!==void 0?e:lt(i.name),i.jsonName=(t=i.jsonName)!==null&&t!==void 0?t:lt(i.name),i.repeat=(n=i.repeat)!==null&&n!==void 0?n:Ye.NO,i.opt=(r=i.opt)!==null&&r!==void 0?r:i.repeat||i.oneof?!1:i.kind=="message",i}function Xn(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 Gn{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(!Xn(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 se.BIGINT:return r=="bigint";case se.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,se.STRING)}}}function ee(i,e){switch(e){case se.BIGINT:return i.toBigInt();case se.NUMBER:return i.toNumber();default:return i.toString()}}class Jn{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=F(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(B(o),a.name,o);const h=c[l];for(const[g,w]of Object.entries(o)){this.assert(w!==null,a.name+" map value",null);let T;switch(a.V.kind){case"message":T=a.V.T().internalJsonRead(w,n);break;case"enum":if(T=this.enum(a.V.T(),w,a.name,n.ignoreUnknownFields),T===!1)continue;break;case"scalar":T=this.scalar(w,a.V.T,a.V.L,a.name);break}this.assert(T!==void 0,a.name+" map value",w);let O=g;a.K==u.BOOL&&(O=O=="true"?!0:O=="false"?!1:O),O=this.scalar(O,a.K,se.STRING,a.name).toString(),h[O]=T}}else if(a.repeat){if(o===null)continue;this.assert(Array.isArray(o),a.name,o);const h=c[l];for(const g of o){this.assert(g!==null,a.name,null);let w;switch(a.kind){case"message":w=a.T().internalJsonRead(g,n);break;case"enum":if(w=this.enum(a.T(),g,a.name,n.ignoreUnknownFields),w===!1)continue;break;case"scalar":w=this.scalar(g,a.T,a.L,a.name);break}this.assert(w!==void 0,a.name,o),h.push(w)}}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"&&E(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 E(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:(E(typeof o=="number",`Unable to parse field ${this.info.typeName}#${n}, enum ${e[0]} has no value for "${t}".`),o)}E(!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&&at(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?ze(a):Me(a),a;case u.INT64:case u.SFIXED64:case u.SINT64:if(e===null)return ee(U.ZERO,n);if(typeof e!="number"&&typeof e!="string")break;return ee(U.from(e),n);case u.FIXED64:case u.UINT64:if(e===null)return ee(Z.ZERO,n);if(typeof e!="number"&&typeof e!="string")break;return ee(Z.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 Ct(e)}}catch(o){s=o.message}this.assert(!1,r+(s?" - "+s:""),e)}}class zn{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);E(l!==void 0),n[t.useProtoFieldName?s.name:s.jsonName]=l}return n}field(e,t,n){let r;if(e.kind=="map"){E(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);E(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);E(h!==void 0),s[l.toString()]=h}break;case"enum":const a=e.V.T();for(const[l,c]of Object.entries(t)){E(c===void 0||typeof c=="number");const h=this.enum(a,c,e.name,!1,!0,n.enumAsInteger);E(h!==void 0),s[l.toString()]=h}break}(n.emitDefaultValues||Object.keys(s).length>0)&&(r=s)}else if(e.repeat){E(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);E(c!==void 0),s.push(c)}break;case"enum":const o=e.T();for(let l=0;l<t.length;l++){E(t[l]===void 0||typeof t[l]=="number");const c=this.enum(o,t[l],e.name,e.opt,!0,n.enumAsInteger);E(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);E(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){E(r);return}if(!(t===0&&!s&&!r))return E(typeof t=="number"),E(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){E(r);return}const o=s||r;switch(e){case u.INT32:case u.SFIXED32:case u.SINT32:return t===0?o?0:void 0:(Me(t),t);case u.FIXED32:case u.UINT32:return t===0?o?0:void 0:(ze(t),t);case u.FLOAT:at(t);case u.DOUBLE:return t===0?o?0:void 0:(E(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:(E(typeof t=="string"),t);case u.BOOL:return t===!1?o?!1:void 0:(E(typeof t=="boolean"),t);case u.UINT64:case u.FIXED64:E(typeof t=="number"||typeof t=="string"||typeof t=="bigint");let a=Z.from(t);return a.isZero()&&!o?void 0:a.toString();case u.INT64:case u.SFIXED64:case u.SINT64:E(typeof t=="number"||typeof t=="string"||typeof t=="bigint");let l=U.from(t);return l.isZero()&&!o?void 0:l.toString();case u.BYTES:return E(t instanceof Uint8Array),t.byteLength?Et(t):o?"":void 0}}}function ct(i,e=se.STRING){switch(i){case u.BOOL:return!1;case u.UINT64:case u.FIXED64:return ee(Z.ZERO,e);case u.INT64:case u.SFIXED64:case u.SINT64:return ee(U.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 Yn{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 w=n.readUnknownField;if(w=="throw")throw new Error(`Unknown field ${o} (wire type ${a}) for ${this.info.typeName}`);let T=e.skip(a);w!==!1&&(w===!0?N.onRead:w)(this.info.typeName,t,o,a,T);continue}let c=t,h=l.repeat,g=l.localName;switch(l.oneof&&(c=c[l.oneof],c.oneofKind!==g&&(c=t[l.oneof]={oneofKind:g})),l.kind){case"scalar":case"enum":let w=l.kind=="enum"?u.INT32:l.T,T=l.kind=="scalar"?l.L:void 0;if(h){let v=c[g];if(a==m.LengthDelimited&&w!=u.STRING&&w!=u.BYTES){let j=e.uint32()+e.pos;for(;e.pos<j;)v.push(this.scalar(e,w,T))}else v.push(this.scalar(e,w,T))}else c[g]=this.scalar(e,w,T);break;case"message":if(h){let v=c[g],j=l.T().internalBinaryRead(e,e.uint32(),n);v.push(j)}else c[g]=l.T().internalBinaryRead(e,e.uint32(),n,c[g]);break;case"map":let[O,P]=this.mapEntry(l,e,n);c[g][O]=P;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,se.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=ct(e.K);o=e.K==u.BOOL?l.toString():l}if(a===void 0)switch(e.V.kind){case"scalar":a=ct(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 ee(e.int64(),n);case u.UINT64:return ee(e.uint64(),n);case u.FIXED64:return ee(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 ee(e.sfixed64(),n);case u.SINT32:return e.sint32();case u.SINT64:return ee(e.sint64(),n)}}}class Qn{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(E(Array.isArray(o)),l==Ye.PACKED)this.packed(t,h,s.no,o);else for(const g of o)this.scalar(t,h,s.no,g,!0);else o===void 0?E(s.opt):this.scalar(t,h,s.no,o,a||s.opt);break;case"message":if(l){E(Array.isArray(o));for(const g of o)this.message(t,n,s.T(),s.no,g)}else this.message(t,n,s.T(),s.no,o);break;case"map":E(typeof o=="object"&&o!==null);for(const[g,w]of Object.entries(o))this.mapEntry(t,n,s,g,w);break}}let r=n.writeUnknownFields;r!==!1&&(r===!0?N.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:E(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;E(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||U.from(t).isZero(),r="int64";break;case u.UINT64:o=s||Z.from(t).isZero(),r="uint64";break;case u.FIXED64:o=s||Z.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||U.from(t).isZero(),n=m.Bit64,r="sfixed64";break;case u.SINT32:r="sint32";break;case u.SINT64:o=s||U.from(t).isZero(),r="sint64";break}return[n,r,s||o]}}function ei(i){const e=i.messagePrototype?Object.create(i.messagePrototype):Object.defineProperty({},xt,{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]=ct(t.T,t.L);break;case"enum":e[n]=0;break;case"map":e[n]={};break}}return e}function H(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 ti(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?_t(a,s,o):Ot(a,s,o)))return!1;break;case"map":if(!(n.V.kind=="message"?Dt(n.V.T(),Qe(s),Qe(o)):_t(n.V.kind=="enum"?u.INT32:n.V.T,Qe(s),Qe(o))))return!1;break;case"message":let l=n.T();if(!(n.repeat?Dt(l,s,o):l.equals(s,o)))return!1;break}}return!0}const Qe=Object.values;function Ot(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 _t(i,e,t){if(e.length!==t.length)return!1;for(let n=0;n<e.length;n++)if(!Ot(i,e[n],t[n]))return!1;return!0}function Dt(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 ni=Object.getOwnPropertyDescriptors(Object.getPrototypeOf({}));class q{constructor(e,t,n){this.defaultCheckDepth=16,this.typeName=e,this.fields=t.map(Kn),this.options=n??{},this.messagePrototype=Object.create(null,Object.assign(Object.assign({},ni),{[xt]:{value:this}})),this.refTypeCheck=new Gn(this),this.refJsonReader=new Jn(this),this.refJsonWriter=new zn(this),this.refBinReader=new Yn(this),this.refBinWriter=new Qn(this)}create(e){let t=ei(this);return e!==void 0&&H(this,t,e),t}clone(e){let t=this.create();return H(this,t,e),t}equals(e,t){return ti(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){H(this,e,t)}fromBinary(e,t){let n=Sn(t);return this.internalBinaryRead(n.readerFactory(e),e.byteLength,n)}fromJson(e,t){return this.internalJsonRead(e,jn(t))}fromJsonString(e,t){let n=JSON.parse(e);return this.fromJson(n,t)}toJson(e,t){return this.internalJsonWrite(e,Zn(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=Wn(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 ${F(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 ii(i,e){var t,n,r;let s=i;return s.service=e,s.localName=(t=s.localName)!==null&&t!==void 0?t:lt(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 dt{constructor(e,t,n){this.typeName=e,this.methods=t.map(r=>ii(r,this)),this.options=n??{}}}class L extends Error{constructor(e,t="UNKNOWN",n){super(e),this.name="RpcError",Object.setPrototypeOf(this,new.target.prototype),this.code=t,this.meta=n??{}}toString(){const e=[this.name+": "+this.message];this.code&&(e.push(""),e.push("Code: "+this.code)),this.serviceName&&this.methodName&&e.push("Method: "+this.serviceName+"/"+this.methodName);let t=Object.entries(this.meta);if(t.length){e.push(""),e.push("Meta:");for(let[n,r]of t)e.push(` ${n}: ${r}`)}return e.join(`
4
4
  `)}}function ri(i,e){if(!e)return i;let t={};et(i,t),et(e,t);for(let n of Object.keys(e)){let r=e[n];switch(n){case"jsonOptions":t.jsonOptions=qn(i.jsonOptions,t.jsonOptions);break;case"binaryOptions":t.binaryOptions=xn(i.binaryOptions,t.binaryOptions);break;case"meta":t.meta={},et(i.meta,t.meta),et(e.meta,t.meta);break;case"interceptors":t.interceptors=i.interceptors?i.interceptors.concat(r):r.concat();break}}return t}function et(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 Y;(function(i){i[i.PENDING=0]="PENDING",i[i.REJECTED=1]="REJECTED",i[i.RESOLVED=2]="RESOLVED"})(Y||(Y={}));class we{constructor(e=!0){this._state=Y.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!==Y.PENDING)throw new Error(`cannot resolve ${Y[this.state].toLowerCase()}`);this._resolve(e),this._state=Y.RESOLVED}reject(e){if(this.state!==Y.PENDING)throw new Error(`cannot reject ${Y[this.state].toLowerCase()}`);this._reject(e),this._state=Y.REJECTED}resolvePending(e){this._state===Y.PENDING&&this.resolve(e)}rejectPending(e){this._state===Y.PENDING&&this.reject(e)}}class si{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){E((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){E(!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){E(!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(){E(!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;E(e,"bad state"),E(!e.p,"iterator contract broken");let t=e.q.shift();return t?"value"in t?Promise.resolve(t):Promise.reject(t):(e.p=new we,e.p.promise)}}}pushIt(e){let t=this._itState;if(t)if(t.p){const n=t.p;E(n.state==Y.PENDING,"iterator contract broken"),"value"in e?n.resolve(e):n.reject(e),delete t.p}else t.q.push(e)}}var oi=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(g){o(g)}}function l(h){try{c(n.throw(h))}catch(g){o(g)}}function c(h){h.done?s(h.value):r(h.value).then(a,l)}c((n=n.apply(i,e||[])).next())})};class ai{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 oi(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 li=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(g){o(g)}}function l(h){try{c(n.throw(h))}catch(g){o(g)}}function c(h){h.done?s(h.value):r(h.value).then(a,l)}c((n=n.apply(i,e||[])).next())})};class ci{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 li(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 oe(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,g)=>a.interceptUnary(l,c,h,g)}return o(t,r,n)}}var p;(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"})(p||(p={}));var di=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(g){o(g)}}function l(h){try{c(n.throw(h))}catch(g){o(g)}}function c(h){h.done?s(h.value):r(h.value).then(a,l)}c((n=n.apply(i,e||[])).next())})};function St(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 L(`timeout ${t} ms exceeded`,p[p.DEADLINE_EXCEEDED]);i.set("grpc-timeout",`${t}m`)}else if(t){const s=t.getTime(),o=Date.now();if(s<=o)throw new L(`deadline ${t} exceeded`,p[p.DEADLINE_EXCEEDED]);i.set("grpc-timeout",`${s-o}m`)}return i}function Ut(i,e){let t=new Uint8Array(5+i.length);t[0]=te.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:Et(t)}function ht(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 L(`fetch response type ${l.type}`,p[p.UNKNOWN])}return ht(fi(l.headers),l.status,l.statusText)}let n=i,r=e>=200&&e<300,s=$t(n),[o,a]=Ht(n);return(o===void 0||o===p.OK)&&!r&&(o=mi(e),a=t),[o,a,s]}function Rt(i){let e=pi(i),[t,n]=Ht(e),r=$t(e);return[t??p.OK,n,r]}var te;(function(i){i[i.DATA=0]="DATA",i[i.TRAILER=128]="TRAILER"})(te||(te={}));function Mt(i,e,t){return di(this,void 0,void 0,function*(){let n,r="",s=new Uint8Array(0),o=ui(e);if(hi(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=Vt(s,Ct(r.substring(0,l))),r=r.substring(l)}else s=Vt(s,a.value);for(;s.length>=5&&s[0]===te.DATA;){let l=0;for(let c=1;c<5;c++)l=(l<<8)+s[c];if(s.length-5>=l)t(te.DATA,s.subarray(5,5+l)),s=s.subarray(5+l);else break}}if(a.done){if(s.length===0)break;if(s[0]!==te.TRAILER||s.length<5)throw new L("premature EOF",p[p.DATA_LOSS]);t(te.TRAILER,s.subarray(5));break}}})}const hi=i=>typeof i.getReader=="function";function Vt(i,e){let t=new Uint8Array(i.length+e.length);return t.set(i),t.set(e,i.length),t}function ui(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 L("missing response content type",p[p.INTERNAL]);default:throw new L("unexpected response content type: "+i,p[p.INTERNAL])}}function Ht(i){let e,t,n=i["grpc-message"];if(n!==void 0){if(Array.isArray(n))return[p.INTERNAL,"invalid grpc-web message"];t=n}let r=i["grpc-status"];if(r!==void 0){if(Array.isArray(r))return[p.INTERNAL,"invalid grpc-web status"];if(e=parseInt(r,10),p[e]===void 0)return[p.INTERNAL,"invalid grpc-web status"]}return[e,t]}function $t(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 pi(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 fi(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 mi(i){switch(i){case 200:return p.OK;case 400:return p.INVALID_ARGUMENT;case 401:return p.UNAUTHENTICATED;case 403:return p.PERMISSION_DENIED;case 404:return p.NOT_FOUND;case 409:return p.ABORTED;case 412:return p.FAILED_PRECONDITION;case 429:return p.RESOURCE_EXHAUSTED;case 499:return p.CANCELLED;case 500:return p.UNKNOWN;case 501:return p.UNIMPLEMENTED;case 503:return p.UNAVAILABLE;case 504:return p.DEADLINE_EXCEEDED;default:return p.UNKNOWN}}class gi{constructor(e){this.defaultOptions=e}mergeOptions(e){return ri(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 L("Client streaming is not supported by grpc-web",p[p.UNIMPLEMENTED]);throw t.methodName=e.name,t.serviceName=e.service.typeName,t}duplex(e){const t=new L("Duplex streaming is not supported by grpc-web",p[p.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:{},g=this.makeUrl(e,l),w=e.I.toBinary(t,l.binaryOptions),T=new we,O=new si,P=!0,v,j=new we,K,ie=new we;return globalThis.fetch(g,Object.assign(Object.assign({},h),{method:"POST",headers:St(new globalThis.Headers,c,l.timeout,l.meta),body:Ut(w,c),signal:(o=n.abort)!==null&&o!==void 0?o:null})).then(C=>{let[y,V,X]=ht(C);if(T.resolve(X),y!=null&&y!==p.OK)throw new L(V??p[y],p[y],X);return y!=null&&(v={code:p[y],detail:V??p[y]}),C}).then(C=>{if(!C.body)throw new L("missing response body",p[p.INTERNAL]);return Mt(C.body,C.headers.get("content-type"),(y,V)=>{switch(y){case te.DATA:O.notifyMessage(e.O.fromBinary(V,l.binaryOptions)),P=!1;break;case te.TRAILER:let X,re;[X,re,K]=Rt(V),v={code:p[X],detail:re??p[X]};break}})}).then(()=>{if(!K&&!P)throw new L("missing trailers",p[p.DATA_LOSS]);if(!v)throw new L("missing status",p[p.INTERNAL]);if(v.code!=="OK")throw new L(v.detail,v.code,K);O.notifyComplete(),j.resolve(v),ie.resolve(K||{})}).catch(C=>{let y;C instanceof L?y=C:C instanceof Error&&C.name==="AbortError"?y=new L(C.message,p[p.CANCELLED]):y=new L(C instanceof Error?C.message:""+C,p[p.INTERNAL]),y.methodName=e.name,y.serviceName=e.service.typeName,T.rejectPending(y),O.notifyError(y),j.rejectPending(y),ie.rejectPending(y)}),new ci(e,(a=l.meta)!==null&&a!==void 0?a:{},t,T.promise,O,j.promise,ie.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:{},g=this.makeUrl(e,l),w=e.I.toBinary(t,l.binaryOptions),T=new we,O,P=new we,v,j=new we,K,ie=new we;return globalThis.fetch(g,Object.assign(Object.assign({},h),{method:"POST",headers:St(new globalThis.Headers,c,l.timeout,l.meta),body:Ut(w,c),signal:(o=n.abort)!==null&&o!==void 0?o:null})).then(C=>{let[y,V,X]=ht(C);if(T.resolve(X),y!=null&&y!==p.OK)throw new L(V??p[y],p[y],X);return y!=null&&(v={code:p[y],detail:V??p[y]}),C}).then(C=>{if(!C.body)throw new L("missing response body",p[p.INTERNAL]);return Mt(C.body,C.headers.get("content-type"),(y,V)=>{switch(y){case te.DATA:if(O)throw new L("unary call received 2nd message",p[p.DATA_LOSS]);O=e.O.fromBinary(V,l.binaryOptions);break;case te.TRAILER:let X,re;[X,re,K]=Rt(V),v={code:p[X],detail:re??p[X]};break}})}).then(()=>{if(!K&&O)throw new L("missing trailers",p[p.DATA_LOSS]);if(!v)throw new L("missing status",p[p.INTERNAL]);if(!O&&v.code==="OK")throw new L("expected error status",p[p.DATA_LOSS]);if(!O)throw new L(v.detail,v.code,K);if(P.resolve(O),v.code!=="OK")throw new L(v.detail,v.code,K);j.resolve(v),ie.resolve(K||{})}).catch(C=>{let y;C instanceof L?y=C:C instanceof Error&&C.name==="AbortError"?y=new L(C.message,p[p.CANCELLED]):y=new L(C instanceof Error?C.message:""+C,p[p.INTERNAL]),y.methodName=e.name,y.serviceName=e.service.typeName,T.rejectPending(y),P.rejectPending(y),j.rejectPending(y),ie.rejectPending(y)}),new ai(e,(a=l.meta)!==null&&a!==void 0?a:{},t,T.promise,P.promise,j.promise,ie.promise)}}var ut=(i=>(i[i.IMAGE=0]="IMAGE",i[i.AUDIO=1]="AUDIO",i[i.VIDEO=2]="VIDEO",i[i.ALL=3]="ALL",i[i.FOLDER=4]="FOLDER",i))(ut||{});class wi extends q{constructor(){super("com.hamropatro.grpc.cms.SearchRequest",[{no:1,name:"search_value",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.searchValue="",t.cursor="",t.limit=0,e!==void 0&&H(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.searchValue=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?N.onRead:c)(this.typeName,s,a,l,h)}}return s}internalBinaryWrite(e,t,n){e.searchValue!==""&&t.tag(1,m.LengthDelimited).string(e.searchValue),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?N.onWrite:r)(this.typeName,e,t),t}}const Wt=new wi;class bi extends q{constructor(){super("com.hamropatro.grpc.cms.SearchResult",[{no:1,name:"items",kind:"message",repeat:1,T:()=>ae},{no:2,name:"next_page_cursor",kind:"scalar",T:9}])}create(e){const t=globalThis.Object.create(this.messagePrototype);return t.items=[],t.nextPageCursor="",e!==void 0&&H(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.items.push(ae.internalBinaryRead(e,e.uint32(),n));break;case 2:s.nextPageCursor=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?N.onRead:c)(this.typeName,s,a,l,h)}}return s}internalBinaryWrite(e,t,n){for(let s=0;s<e.items.length;s++)ae.internalBinaryWrite(e.items[s],t.tag(1,m.LengthDelimited).fork(),n).join();e.nextPageCursor!==""&&t.tag(2,m.LengthDelimited).string(e.nextPageCursor);let r=n.writeUnknownFields;return r!==!1&&(r==!0?N.onWrite:r)(this.typeName,e,t),t}}const yi=new bi;class Ci extends q{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",ut]}])}create(e){const t=globalThis.Object.create(this.messagePrototype);return t.name="",t.folderName="",t.nestedFolderName="",t.url="",t.type=0,e!==void 0&&H(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?N.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?N.onWrite:r)(this.typeName,e,t),t}}const Pt=new Ci;class Ei extends q{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",ut]},{no:9,name:"metadata",kind:"message",T:()=>pt}])}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&&H(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=pt.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?N.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&&pt.internalBinaryWrite(e.metadata,t.tag(9,m.LengthDelimited).fork(),n).join();let r=n.writeUnknownFields;return r!==!1&&(r==!0?N.onWrite:r)(this.typeName,e,t),t}}const ae=new Ei;class Ni extends q{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&&H(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?N.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?N.onWrite:r)(this.typeName,e,t),t}}const pt=new Ni;class ki extends q{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&&H(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?N.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?N.onWrite:r)(this.typeName,e,t),t}}const jt=new ki;class Fi extends q{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&&H(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?N.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?N.onWrite:r)(this.typeName,e,t),t}}const Ii=new Fi;class Li extends q{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&&H(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?N.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?N.onWrite:r)(this.typeName,e,t),t}}const Zt=new Li;class Ai extends q{constructor(){super("com.hamropatro.grpc.cms.GetFilesByFolderResponse",[{no:1,name:"files",kind:"message",repeat:1,T:()=>ae},{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&&H(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(ae.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?N.onRead:c)(this.typeName,s,a,l,h)}}return s}internalBinaryWrite(e,t,n){for(let s=0;s<e.files.length;s++)ae.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?N.onWrite:r)(this.typeName,e,t),t}}const Ti=new Ai,ft=new dt("com.hamropatro.grpc.cms.FileService",[{name:"createFile",options:{},I:Pt,O:ae},{name:"updateFile",options:{},I:ae,O:ae},{name:"deleteFile",options:{},I:jt,O:Ii},{name:"getFilesByFolder",options:{},I:Zt,O:Ti},{name:"search",options:{},I:Wt,O:yi}]);class Ve{constructor(e){_(this,"typeName",ft.typeName);_(this,"methods",ft.methods);_(this,"options",ft.options);this._transport=e}createFile(e,t){const n=this.methods[0],r=this._transport.mergeOptions(t);return oe("unary",this._transport,n,r,e)}updateFile(e,t){const n=this.methods[1],r=this._transport.mergeOptions(t);return oe("unary",this._transport,n,r,e)}deleteFile(e,t){const n=this.methods[2],r=this._transport.mergeOptions(t);return oe("unary",this._transport,n,r,e)}getFilesByFolder(e,t){const n=this.methods[3],r=this._transport.mergeOptions(t);return oe("unary",this._transport,n,r,e)}search(e,t){const n=this.methods[4],r=this._transport.mergeOptions(t);return oe("unary",this._transport,n,r,e)}}const vi=async(i,e,t,n,r,s)=>{var o;try{const a=(o=window.ImageSalonSDK)==null?void 0:o.grpcConfig,l=new Ve(a),c=Pt.create();return c.name=i,c.nestedFolderName=e,c.url=t,c.type=n,c.folderName=r,await l.createFile(c,s)}catch(a){throw a}},Bi=async(i,e,t,n)=>{var r;try{const s=(r=window.ImageSalonSDK)==null?void 0:r.grpcConfig,o=new Ve(s),a=Zt.create();return a.folderName=i,a.cursor=e,a.limit=t,await o.getFilesByFolder(a,n)}catch(s){throw s}},xi=async(i,e,t=20,n)=>{var r;try{const s=(r=window.ImageSalonSDK)==null?void 0:r.grpcConfig,o=new Ve(s),a=Wt.create();return a.searchValue=i,a.cursor=e,a.limit=t,await o.search(a,n)}catch(s){throw s}},Oi=async(i,e,t,n,r,s,o,a,l)=>{var c;try{const h=(c=window.ImageSalonSDK)==null?void 0:c.grpcConfig,g=new Ve(h),w=ae.create();return w.key=i,w.name=e,w.nestedFolderName=t,w.url=n,w.thumborUrl=r,w.proxyUrl=s,w.type=o,w.folderName=a,await g.updateFile(w,l)}catch(h){throw h}},_i=async(i,e)=>{var t;try{const n=(t=window.ImageSalonSDK)==null?void 0:t.grpcConfig,r=new Ve(n),s=jt.create();return s.key=i,await r.deleteFile(s,e)}catch(n){throw n}};class Di extends q{constructor(){super("com.hamropatro.grpc.cms.DeleteFolderRequest",[{no:1,name:"key",kind:"scalar",T:9}])}create(e){const t=globalThis.Object.create(this.messagePrototype);return t.key="",e!==void 0&&H(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?N.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?N.onWrite:r)(this.typeName,e,t),t}}const qt=new Di;class Si extends q{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&&H(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?N.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?N.onWrite:r)(this.typeName,e,t),t}}const Kt=new Si;class Ui extends q{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&&H(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?N.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?N.onWrite:r)(this.typeName,e,t),t}}const Xt=new Ui;class Ri extends q{constructor(){super("com.hamropatro.grpc.cms.GetAllFoldersResponse",[{no:1,name:"folder",kind:"message",repeat:1,T:()=>be},{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&&H(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(be.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?N.onRead:c)(this.typeName,s,a,l,h)}}return s}internalBinaryWrite(e,t,n){for(let s=0;s<e.folder.length;s++)be.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?N.onWrite:r)(this.typeName,e,t),t}}const Mi=new Ri;class Vi extends q{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&&H(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?N.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?N.onWrite:r)(this.typeName,e,t),t}}const be=new Vi,mt=new dt("com.hamropatro.grpc.cms.FolderService",[{name:"createFolder",options:{},I:Kt,O:be},{name:"getFolders",options:{},I:Xt,O:Mi},{name:"updateFolder",options:{},I:be,O:be},{name:"deleteFolder",options:{},I:qt,O:be}]);class tt{constructor(e){_(this,"typeName",mt.typeName);_(this,"methods",mt.methods);_(this,"options",mt.options);this._transport=e}createFolder(e,t){const n=this.methods[0],r=this._transport.mergeOptions(t);return oe("unary",this._transport,n,r,e)}getFolders(e,t){const n=this.methods[1],r=this._transport.mergeOptions(t);return oe("unary",this._transport,n,r,e)}updateFolder(e,t){const n=this.methods[2],r=this._transport.mergeOptions(t);return oe("unary",this._transport,n,r,e)}deleteFolder(e,t){const n=this.methods[3],r=this._transport.mergeOptions(t);return oe("unary",this._transport,n,r,e)}}const Hi=async(i,e=20,t)=>{var o;const n=(o=window.ImageSalonSDK)==null?void 0:o.grpcConfig,r=new tt(n),s=Xt.create();try{return s.cursor=i,s.limit=e,await r.getFolders(s,t)}catch(a){throw a}},$i=async(i,e,t,n)=>{var r;try{const s=(r=window.ImageSalonSDK)==null?void 0:r.grpcConfig,o=new tt(s),a=Kt.create();return a.name=i,a.nestedFolderName=e,a.createdBy=t,await o.createFolder(a,n)}catch(s){throw s}},Wi=async(i,e,t,n,r)=>{var s;try{const o=(s=window.ImageSalonSDK)==null?void 0:s.grpcConfig,a=new tt(o),l=be.create();return l.name=e,l.key=i,l.nestedFolderName=t,l.createdBy=n,await a.updateFolder(l,r)}catch(o){throw o}},Pi=async(i,e)=>{var t;try{const n=(t=window.ImageSalonSDK)==null?void 0:t.grpcConfig,r=new tt(n),s=qt.create();return s.key=i,await r.deleteFolder(s,e)}catch(n){throw n}},Gt=(i,e,t)=>{const n=document.createElementNS("http://www.w3.org/2000/svg","svg");n.setAttribute("xmlns","http://www.w3.org/2000/svg"),n.setAttribute("width",i||"20"),n.setAttribute("height",e||"20"),n.setAttribute("viewBox","0 0 24 24"),n.setAttribute("fill","none"),n.setAttribute("stroke",t||"#ee3f3f"),n.setAttribute("stroke-width","2"),n.setAttribute("stroke-linecap","round"),n.setAttribute("stroke-linejoin","round"),n.classList.add("lucide","lucide-circle-alert");const r=document.createElementNS("http://www.w3.org/2000/svg","circle");r.setAttribute("cx","12"),r.setAttribute("cy","12"),r.setAttribute("r","10");const s=document.createElementNS("http://www.w3.org/2000/svg","line");s.setAttribute("x1","12"),s.setAttribute("x2","12"),s.setAttribute("y1","8"),s.setAttribute("y2","12");const o=document.createElementNS("http://www.w3.org/2000/svg","line");return o.setAttribute("x1","12"),o.setAttribute("x2","12.01"),o.setAttribute("y1","16"),o.setAttribute("y2","16"),n.appendChild(r),n.appendChild(s),n.appendChild(o),n};function Jt(){const i=document.createElementNS("http://www.w3.org/2000/svg","svg");i.setAttribute("xmlns","http://www.w3.org/2000/svg"),i.setAttribute("height","24px"),i.setAttribute("width","24px"),i.setAttribute("viewBox","0 -960 960 960"),i.setAttribute("fill","#333");const e=document.createElementNS("http://www.w3.org/2000/svg","path");return e.setAttribute("d","M504-480 320-664l56-56 240 240-240 240-56-56 184-184Z"),i.appendChild(e),i}function ji(){const i=document.createElementNS("http://www.w3.org/2000/svg","svg");i.setAttribute("xmlns","http://www.w3.org/2000/svg"),i.setAttribute("width","12"),i.setAttribute("height","12"),i.setAttribute("viewBox","0 0 24 24"),i.setAttribute("fill","none"),i.setAttribute("stroke","currentColor"),i.setAttribute("stroke-width","2"),i.setAttribute("stroke-linecap","round"),i.setAttribute("stroke-linejoin","round"),i.classList.add("lucide","lucide-music-4");const e=document.createElementNS("http://www.w3.org/2000/svg","path");e.setAttribute("d","M9 18V5l12-2v13");const t=document.createElementNS("http://www.w3.org/2000/svg","path");t.setAttribute("d","m9 9 12-2");const n=document.createElementNS("http://www.w3.org/2000/svg","circle");n.setAttribute("cx","6"),n.setAttribute("cy","18"),n.setAttribute("r","3");const r=document.createElementNS("http://www.w3.org/2000/svg","circle");return r.setAttribute("cx","18"),r.setAttribute("cy","16"),r.setAttribute("r","3"),i.appendChild(e),i.appendChild(t),i.appendChild(n),i.appendChild(r),document.body.appendChild(i),i}const Zi=()=>{const i=document.createElementNS("http://www.w3.org/2000/svg","svg");i.setAttribute("xmlns","http://www.w3.org/2000/svg"),i.setAttribute("width","20"),i.setAttribute("height","20"),i.setAttribute("viewBox","0 0 24 24"),i.setAttribute("fill","none"),i.setAttribute("stroke","currentColor"),i.setAttribute("stroke-width","2"),i.setAttribute("stroke-linecap","round"),i.setAttribute("stroke-linejoin","round"),i.classList.add("lucide","lucide-circle-check-big");const e=document.createElementNS("http://www.w3.org/2000/svg","path");e.setAttribute("d","M21.801 10A10 10 0 1 1 17 3.335");const t=document.createElementNS("http://www.w3.org/2000/svg","path");return t.setAttribute("d","m9 11 3 3L22 4"),i.appendChild(e),i.appendChild(t),i};function zt(i="#333"){const e=document.createElementNS("http://www.w3.org/2000/svg","svg");e.setAttribute("xmlns","http://www.w3.org/2000/svg"),e.setAttribute("x","0px"),e.setAttribute("y","0px"),e.setAttribute("width","18"),e.setAttribute("height","18"),e.setAttribute("viewBox","0 0 50 50"),e.setAttribute("fill",i);const t=document.createElementNS("http://www.w3.org/2000/svg","path");return t.setAttribute("d","M 9.15625 6.3125 L 6.3125 9.15625 L 22.15625 25 L 6.21875 40.96875 L 9.03125 43.78125 L 25 27.84375 L 40.9375 43.78125 L 43.78125 40.9375 L 27.84375 25 L 43.6875 9.15625 L 40.84375 6.3125 L 25 22.15625 Z"),e.appendChild(t),e}function Yt(){const i=document.createElementNS("http://www.w3.org/2000/svg","svg");i.setAttribute("xmlns","http://www.w3.org/2000/svg"),i.setAttribute("width","16"),i.setAttribute("height","16"),i.setAttribute("viewBox","0 0 24 24"),i.setAttribute("fill","none"),i.setAttribute("stroke","#2c96f8"),i.setAttribute("stroke-width","2"),i.setAttribute("stroke-linecap","round"),i.setAttribute("stroke-linejoin","round"),i.classList.add("lucide","lucide-pencil");const e=document.createElementNS("http://www.w3.org/2000/svg","path");e.setAttribute("d","M21.174 6.812a1 1 0 0 0-3.986-3.987L3.842 16.174a2 2 0 0 0-.5.83l-1.321 4.352a.5.5 0 0 0 .623.622l4.353-1.32a2 2 0 0 0 .83-.497z");const t=document.createElementNS("http://www.w3.org/2000/svg","path");return t.setAttribute("d","m15 5 4 4"),i.appendChild(e),i.appendChild(t),document.body.appendChild(i),i}function He(){const i=document.createElementNS("http://www.w3.org/2000/svg","svg");i.setAttribute("xmlns","http://www.w3.org/2000/folder"),i.setAttribute("x","0px"),i.setAttribute("y","0px"),i.setAttribute("width","24"),i.setAttribute("height","24"),i.setAttribute("viewBox","0 0 48 48");const e=document.createElementNS("http://www.w3.org/2000/svg","path");e.setAttribute("fill","#FFA000"),e.setAttribute("d","M40,12H22l-4-4H8c-2.2,0-4,1.8-4,4v8h40v-4C44,13.8,42.2,12,40,12z");const t=document.createElementNS("http://www.w3.org/2000/svg","path");return t.setAttribute("fill","#FFCA28"),t.setAttribute("d","M40,12H8c-2.2,0-4,1.8-4,4v20c0,2.2,1.8,4,4,4h32c2.2,0,4-1.8,4-4V16C44,13.8,42.2,12,40,12z"),i.appendChild(e),i.appendChild(t),i}function qi(){const i="http://www.w3.org/2000/svg",e=document.createElementNS(i,"svg");e.setAttribute("width","12"),e.setAttribute("height","12"),e.setAttribute("viewBox","0 0 24 24"),e.setAttribute("fill","none"),e.setAttribute("stroke","currentColor"),e.setAttribute("stroke-width","3"),e.setAttribute("stroke-linecap","round"),e.setAttribute("stroke-linejoin","round"),e.classList.add("lucide","lucide-image");const t=document.createElementNS(i,"rect");t.setAttribute("width","18"),t.setAttribute("height","18"),t.setAttribute("x","3"),t.setAttribute("y","3"),t.setAttribute("rx","2"),t.setAttribute("ry","2");const n=document.createElementNS(i,"circle");n.setAttribute("cx","9"),n.setAttribute("cy","9"),n.setAttribute("r","2");const r=document.createElementNS(i,"path");return r.setAttribute("d","m21 15-3.086-3.086a2 2 0 0 0-2.828 0L6 21"),e.appendChild(t),e.appendChild(n),e.appendChild(r),document.body.appendChild(e),e}function Ki(){const i=document.createElementNS("http://www.w3.org/2000/svg","svg");i.setAttribute("xmlns","http://www.w3.org/2000/svg"),i.setAttribute("height","24px"),i.setAttribute("viewBox","0 -960 960 960"),i.setAttribute("width","24px"),i.setAttribute("fill","currentColor");const e=document.createElementNS("http://www.w3.org/2000/svg","path");return e.setAttribute("d","m488-400-65 65 56 56 161-161-161-161-56 56 65 65H320v80h168ZM160-160q-33 0-56.5-23.5T80-240v-480q0-33 23.5-56.5T160-800h240l80 80h320q33 0 56.5 23.5T880-640v400q0 33-23.5 56.5T800-160H160Zm0-80h640v-400H447l-80-80H160v480Zm0 0v-480 480Z"),i.appendChild(e),i}function Qt(){const i=document.createElementNS("http://www.w3.org/2000/svg","svg");i.setAttribute("xmlns","http://www.w3.org/2000/svg"),i.setAttribute("fill","none"),i.setAttribute("width","20"),i.setAttribute("height","20"),i.setAttribute("viewBox","0 0 24 24"),i.setAttribute("stroke-width","1.5"),i.setAttribute("stroke","currentColor"),i.setAttribute("class","size-2");const e=document.createElementNS("http://www.w3.org/2000/svg","path");return e.setAttribute("stroke-linecap","round"),e.setAttribute("stroke-linejoin","round"),e.setAttribute("d","M12 4.5v15m7.5-7.5h-15"),i.appendChild(e),i}function Xi(){const i="http://www.w3.org/2000/svg",e=document.createElementNS(i,"svg");e.setAttribute("width","16"),e.setAttribute("height","16"),e.setAttribute("viewBox","0 0 24 24"),e.setAttribute("fill","none"),e.setAttribute("stroke","currentColor"),e.setAttribute("stroke-width","2"),e.setAttribute("stroke-linecap","round"),e.setAttribute("stroke-linejoin","round"),e.classList.add("lucide","lucide-eye");const t=document.createElementNS(i,"path");t.setAttribute("d","M2.062 12.348a1 1 0 0 1 0-.696 10.75 10.75 0 0 1 19.876 0 1 1 0 0 1 0 .696 10.75 10.75 0 0 1-19.876 0"),e.appendChild(t);const n=document.createElementNS(i,"circle");return n.setAttribute("cx","12"),n.setAttribute("cy","12"),n.setAttribute("r","3"),e.appendChild(n),document.body.appendChild(e),e}function Gi(){const i=document.createElementNS("http://www.w3.org/2000/svg","svg");i.setAttribute("xmlns","http://www.w3.org/2000/svg"),i.setAttribute("height","24px"),i.setAttribute("width","24px"),i.setAttribute("viewBox","0 0 30 30"),i.setAttribute("fill","#999");const e=document.createElementNS("http://www.w3.org/2000/svg","path");return e.setAttribute("d","M 13 3 C 7.4889971 3 3 7.4889971 3 13 C 3 18.511003 7.4889971 23 13 23 C 15.396508 23 17.597385 22.148986 19.322266 20.736328 L 25.292969 26.707031 A 1.0001 1.0001 0 1 0 26.707031 25.292969 L 20.736328 19.322266 C 22.148986 17.597385 23 15.396508 23 13 C 23 7.4889971 18.511003 3 13 3 z M 13 5 C 17.430123 5 21 8.5698774 21 13 C 21 17.430123 17.430123 21 13 21 C 8.5698774 21 5 17.430123 5 13 C 5 8.5698774 8.5698774 5 13 5 z"),i.appendChild(e),i}function en(){const i=document.createElementNS("http://www.w3.org/2000/svg","svg");i.setAttribute("xmlns","http://www.w3.org/2000/svg"),i.setAttribute("width","16"),i.setAttribute("height","16"),i.setAttribute("viewBox","0 0 24 24"),i.setAttribute("fill","none"),i.setAttribute("stroke","#f14b4b"),i.setAttribute("stroke-width","2"),i.setAttribute("stroke-linecap","round"),i.setAttribute("stroke-linejoin","round"),i.classList.add("lucide","lucide-trash-2");const e=document.createElementNS("http://www.w3.org/2000/svg","path");e.setAttribute("d","M3 6h18");const t=document.createElementNS("http://www.w3.org/2000/svg","path");t.setAttribute("d","M19 6v14c0 1-1 2-2 2H7c-1 0-2-1-2-2V6");const n=document.createElementNS("http://www.w3.org/2000/svg","path");n.setAttribute("d","M8 6V4c0-1 1-2 2-2h4c1 0 2 1 2 2v2");const r=document.createElementNS("http://www.w3.org/2000/svg","line");r.setAttribute("x1","10"),r.setAttribute("x2","10"),r.setAttribute("y1","11"),r.setAttribute("y2","17");const s=document.createElementNS("http://www.w3.org/2000/svg","line");return s.setAttribute("x1","14"),s.setAttribute("x2","14"),s.setAttribute("y1","11"),s.setAttribute("y2","17"),i.appendChild(e),i.appendChild(t),i.appendChild(n),i.appendChild(r),i.appendChild(s),document.body.appendChild(i),i}function Ji(){const i="http://www.w3.org/2000/svg",e=document.createElementNS(i,"svg");e.setAttribute("xmlns",i),e.setAttribute("height","20px"),e.setAttribute("viewBox","0 -960 960 960"),e.setAttribute("width","20px"),e.setAttribute("fill","#fff");const t=document.createElementNS(i,"path");return t.setAttribute("d","M440-320v-326L336-542l-56-58 200-200 200 200-56 58-104-104v326h-80ZM240-160q-33 0-56.5-23.5T160-240v-120h80v120h480v-120h80v120q0 33-23.5 56.5T720-160H240Z"),e.appendChild(t),e}function zi(){const i="http://www.w3.org/2000/svg",e=document.createElementNS(i,"svg");e.setAttribute("width","12"),e.setAttribute("height","12"),e.setAttribute("viewBox","0 0 24 24"),e.setAttribute("fill","none"),e.setAttribute("stroke","currentColor"),e.setAttribute("stroke-width","3"),e.setAttribute("stroke-linecap","round"),e.setAttribute("stroke-linejoin","round"),e.classList.add("lucide","lucide-video");const t=document.createElementNS(i,"path");t.setAttribute("d","m16 13 5.223 3.482a.5.5 0 0 0 .777-.416V7.87a.5.5 0 0 0-.752-.432L16 10.5");const n=document.createElementNS(i,"rect");return n.setAttribute("x","2"),n.setAttribute("y","6"),n.setAttribute("width","14"),n.setAttribute("height","12"),n.setAttribute("rx","2"),e.appendChild(t),e.appendChild(n),document.body.appendChild(e),e}function W(i,e,t){let n=document.createElement(i);return n.className+=e,t&&t.appendChild(n),n}class Yi{constructor(){k(this,ue);f(this,ue,document.createElementNS("http://www.w3.org/2000/svg","svg")),d(this,ue).setAttribute("viewBox","25 25 50 50"),d(this,ue).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,ue).appendChild(e)}show(e){e.appendChild(d(this,ue))}hide(){d(this,ue).remove()}}ue=new WeakMap;const tn=new Yi,nt=document.body;class nn{constructor(){_(this,"main");_(this,"dialogContainer");_(this,"dialog");_(this,"dialogBackdrop");_(this,"dialogContent");_(this,"dialogHeader");_(this,"dialogBody");_(this,"dialogFooter");_(this,"confirmButton");_(this,"cancelButton");_(this,"confirmCallback");_(this,"cancelCallback");this.main=W("div"),this.dialog=W("div"),this.confirmCallback=void 0,this.cancelCallback=void 0}_init(e){this.main=W("div","dialog-presentation",nt),this.main.setAttribute("role","presentation"),this.dialogContainer=W("div","dialog-container",this.main),this.dialogBackdrop=W("div","dialog-backdrop",this.dialogContainer),this.dialog=W("div","dialog",this.dialogContainer),this.dialog.setAttribute("tabIndex","-1");const t=document.activeElement;if(t&&t!==document.body&&(t.blur(),this.dialog.focus()),this.dialog.className="dialog",this.dialogContent=W("div","dialog-content",this.dialog),e!=null&&e.dialogContentStyle&&Object.assign(this.dialogContent.style,e.dialogContentStyle),this.confirmButton=W("button","dialog-btn confirm",this.dialogFooter),this.confirmButton.type="button",this.cancelButton=W("button","dialog-btn cancel",this.dialogFooter),this.cancelButton.type="button",e.showCloseBtn){const n=W("button","dialog-close-btn",this.dialogContent);n.appendChild(zt()),n.onclick=()=>this.hide()}return e.header&&this._setHeader(e),this._setBody(e),this._setFooter(e),this.confirmButton.textContent=e.confirmButtonText||"Upload",this.cancelButton.textContent=e.cancelButtonText||"Cancel",nt.style.overflow="hidden",this.confirmButton.textContent=e.confirmButtonText||"Upload",this.cancelButton.textContent=e.cancelButtonText||"Cancel",nt.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)})}_setHeader(e){if(this.dialogHeader=W("div","dialog-header",this.dialogContent),!e.header)this.dialogHeader.innerHTML="";else if(typeof e.header=="string"){const t=W("h4","dialog-header-text",this.dialogHeader);t.textContent=e.header}else this.dialogHeader.innerHTML="",this.dialogHeader.appendChild(e.header)}_setBody(e){this.dialogBody=W("div","dialog-body",this.dialogContent),typeof e.content=="string"?this.dialogBody.innerHTML=e.content:(this.dialogBody.innerHTML="",this.dialogBody.appendChild(e.content))}_setFooter(e){this.dialogFooter=W("div","dialog-footer",this.dialogContent),e.showFooter?this.dialogFooter.append(this.cancelButton,this.confirmButton):(this.dialogFooter.innerHTML="",this.dialogFooter.remove())}show(e){this._init(e),setTimeout(()=>{this.dialogContainer.style.opacity="1",this.dialog.style.transform="scale(1)",this.dialog.style.transition="transform 150ms ease-in",this.dialog.style.opacity="1",this.dialogBackdrop.style.opacity="1"},150)}hide(){this.main||nt.style.removeProperty("overflow"),this.dialog.style.transform="scale(0.8)",this.dialog.style.transition="transform 150ms ease-out",this.dialogBackdrop.style.opacity="0",setTimeout(()=>{this.dialogContainer.style.opacity="0",this.dialog.style.opacity="0",this.dialogContent.style.opacity="0",this.main.remove()},150)}updateUploadBtn(e){e?(tn.show(this.confirmButton),this.confirmButton.disabled=!0):(tn.hide(),this.confirmButton.disabled=!1)}}const it=new nn,R=new nn;class Qi{constructor(){_(this,"main");_(this,"dialogBody");this.main=W("div"),this.dialogBody=W("div"),this.hide()}show(e){this.main=W("div","popover",e.mainContainer),this.dialogBody=W("div","popover-body",this.main),this.main.id=e.divId,this.dialogBody.append(e.content)}hide(){this.main.remove()}}const Q=new Qi;var he=(i=>(i[i.IMAGE=0]="IMAGE",i[i.AUDIO=1]="AUDIO",i[i.VIDEO=2]="VIDEO",i[i.ALL=3]="ALL",i[i.FOLDER=4]="FOLDER",i))(he||{});const $e={0:"IMAGE",1:"AUDIO",2:"VIDEO",3:"ALL",4:"FOLDER"};function er(i){switch(i){case"image":return $e[he.IMAGE];case"video":return $e[he.VIDEO];case"audio":return $e[he.AUDIO];default:return $e[he.ALL]}}function tr(i){const e={};i.forEach(r=>{e[r.key]={...r,children:{}}});const t=r=>(Object.values(e).filter(o=>o.nestedFolderName==r.key).forEach(o=>{r.children[o.key]=t(o)}),r);return i.reduce((r,s)=>(s.nestedFolderName||r.push(t(e[s.key])),r),[])}function nr(i,e){const t=n=>{if(n.key===e.nestedFolderName)return n.children[e.key]={...e,children:{}},!0;for(const r in n.children){const s=n.children[r];if(t(s))return!0}return!1};for(const n of i)if(t(n))break;return i}const ir=async i=>{let e;try{i&&(e={Authorization:"Bearer "+i})}catch(n){if(n)throw n}return{meta:e}};function b(i,e){const t=document.createElement("div");return i&&(t.className=i),e&&(t.id=e),t}function We(i,e,t){const n=document.createElement("p");return e&&(n.className=e),t&&(n.id=t),i&&(n.textContent=i),n}function A(i,e){const t=document.createElement("span");return e&&(t.className=e),i&&(t.textContent=i),t}function rn(i,e,t,n){const r=document.createElement("img");return e&&(r.className=e),r.src=i,r}function rr(i,e,t){const n=document.createElement("video"),r=document.createElement("source");return n.className=e,r.src=i,n.appendChild(r),n}function sr(i,e,t){const n=document.createElement("audio"),r=document.createElement("source");return n.className=e,n.controls=!0,r.src=i,n.appendChild(r),n}function G(i,e,t,n,r){const s=document.createElement("button");return e&&(s.className=e),t&&(s.id=t),i&&(s.textContent=i),r&&(s.innerHTML=r),s.disabled=n,s}function sn(i,e,t){const n=document.createElement("input");return n.className=e,n.defaultValue=t,i&&(n.type=i),n}class or extends q{constructor(){super("com.hamropatro.grpc.cms.ImageUploadRequest",[])}create(e){const t=globalThis.Object.create(this.messagePrototype);return e!==void 0&&H(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?N.onWrite:r)(this.typeName,e,t),t}}const on=new or;class ar extends q{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&&H(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?N.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?N.onWrite:r)(this.typeName,e,t),t}}const lr=new ar,gt=new dt("com.hamropatro.grpc.cms.ImageUploadService",[{name:"Upload",options:{},I:on,O:lr}]);class cr{constructor(e){_(this,"typeName",gt.typeName);_(this,"methods",gt.methods);_(this,"options",gt.options);this._transport=e}upload(e,t){const n=this.methods[0],r=this._transport.mergeOptions(t);return oe("unary",this._transport,n,r,e)}}const dr=async()=>{var i;try{const e=(i=window.ImageSalonSDK)==null?void 0:i.grpcConfig,t=new cr(e),n=on.create();return await t.upload(n)}catch(e){throw e}},hr=async(i,e)=>{try{const t=ur(i,e),r=(await dr()).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}},ur=(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};class pr{constructor(e){k(this,ve);k(this,Be);k(this,M);k(this,pe);k(this,D,[]);k(this,$,[]);k(this,ye);k(this,J);k(this,xe);k(this,Ce);k(this,le,[]);k(this,ne);k(this,Ee);k(this,Pe);k(this,Ne);k(this,ke);k(this,fe);k(this,Oe);k(this,ce);k(this,de);k(this,Fe);k(this,Ie);k(this,me);k(this,De);k(this,je);k(this,z);k(this,ge);k(this,Ze,!1);k(this,qe);k(this,Le);f(this,ye,!1),f(this,J,!1),f(this,xe,!1),f(this,Pe,e.handleUpload.bind(this)),f(this,Ne,0),f(this,de,""),f(this,Fe,!1),f(this,me,!1),f(this,je,e.accessToken),f(this,ge,null),f(this,Le,""),this._removeToastContainer(),this._grpcOptionInitializer(),this._init(e).then(()=>{f(this,Ze,!0),this._create(e),this.updateWindowObject({initialized:!0}),this._initializeGrpcConfig(e.mode,e.endPoint)}),f(this,qe,e.enableMultiSelect)}async _init(e){try{const{mode:t}=e;this.updateWindowObject({mode:t})}catch{throw Error("Initialization failed")}}_create(e){if(!d(this,Ze))return;const{parentContainerId:t,buttonProps:n}=e;f(this,ve,document.getElementById(t));const r=document.createElement("button");r.className=n!=null&&n.buttonClass?n==null?void 0:n.buttonClass:"browse-image-button",r.addEventListener("focus",()=>{r.blur()});const s=document.createElement("span");s.textContent=n!=null&&n.buttonText?n==null?void 0:n.buttonText:"Browse Files";const o=document.createElement("span");return o.innerHTML=n!=null&&n.buttonIcon?n==null?void 0:n.buttonIcon:"",r.type="button",r.append(s,o),n!=null&&n.buttonStyle&&Object.assign(r.style,n==null?void 0:n.buttonStyle),r.addEventListener("click",()=>{this._selectedImageContainer()}),d(this,ve)&&d(this,ve).appendChild(r),d(this,ve)}async _grpcOptionInitializer(){f(this,z,await ir(d(this,je)))}_selectedImageContainer(){var g;f(this,Ee,G(`Save (${(g=d(this,D))==null?void 0:g.length})`,"dialog-btn confirm")),f(this,ke,b("folder-container")),f(this,fe,b("folder-list-wrapper")),this._fetchAllFolders();const e=G("Cancel","dialog-btn cancel");G("","dialog-modal-close-btn","",!1,'<svg xmlns="http://www.w3.org/2000/svg" x="0px" y="0px" width="24" height="24" viewBox="0 0 50 50"> <path d="M 9.15625 6.3125 L 6.3125 9.15625 L 22.15625 25 L 6.21875 40.96875 L 9.03125 43.78125 L 25 27.84375 L 40.9375 43.78125 L 43.78125 40.9375 L 27.84375 25 L 43.6875 9.15625 L 40.84375 6.3125 L 25 22.15625 Z"></path> </svg>').addEventListener("click",()=>{it.hide(),f(this,D,[]),f(this,$,[])}),f(this,Be,b("browse-container"));const n=b();n.style.display="flex",n.style.alignItems="center",n.style.justifyContent="space-between",n.style.padding="10px 20px";const r=We("Folders","folder-title"),s=G("","add-folder-btn");s.append(Qt()),this._createUpdateFolderDialog(s,"create"),n.append(r,s),d(this,ke).append(n,d(this,fe));const o=this._renderSearchField(),a=this._createBrowseMoreContainer(),l=this._createBrowseImageMain(),c=b("footer");e.onclick=()=>{it.hide(),f(this,$,[]),f(this,D,[])},d(this,Ee).onclick=()=>{d(this,Pe).call(this),it.hide(),f(this,D,[]),f(this,$,[])},c.append(e,d(this,Ee));const h=b("container-right-main");h.append(o,a,l,c),d(this,Be).append(d(this,ke),h),it.show({content:d(this,Be)})}_createAllAndSelectedTab(e){const t=b("select-options"),n=We("Browse","select"),r=We("Selected","select","selected-images-tab");n.classList.add("selected"),[n,r].forEach((o,a)=>{o.addEventListener("click",()=>{var l;f(this,Ne,a),(l=document.querySelector(".select.selected"))==null||l.classList.remove("selected"),o.classList.add("selected"),this._updateSelectedImageListContainerUI()})}),t.append(n,r),e.appendChild(t)}_renderUploadButton(){const e=sn("file");e.style.display="none",e.setAttribute("multiple","true"),e.setAttribute("accept","image/*,video/*,audio/*,.gif"),f(this,pe,document.createElement("button")),d(this,pe).className="browse-more-btn";const t=document.createElement("span");return t.textContent="Upload",d(this,pe).append(Ji(),t),d(this,pe).type="button",d(this,pe).addEventListener("click",()=>e.click()),e.addEventListener("change",()=>{const n=e.files;Object.values(n).forEach(r=>{const s=new FileReader;s.readAsDataURL(r),s.onload=async()=>{await this._uploadAndAddSelectedImageList(s.result,r)}}),e.value=""}),d(this,pe)}_renderCreateFolderBtn(){const e=document.createElement("button");e.className="create-folder-btn";const t=document.createElement("span");return t.textContent="Create",e.append(Qt(),t),this._createUpdateFolderDialog(e,"create"),e}_renderSearchField(){let e;const t=b("search-browse-container"),n=b("search-input-wrapper","search-input-wrapper");f(this,Ie,sn("search")),d(this,Ie).value="",d(this,Ie).addEventListener("input",s=>{f(this,$,[]);const o=s.target;e&&clearTimeout(e),e=setTimeout(()=>{if(!o.value){f(this,de,""),f(this,Fe,!1),f(this,me,!1),this._fetchFilesFromFolder(d(this,Ce));return}f(this,me,!0),f(this,De,o.value),this._search(d(this,De))},750)}),d(this,Ie).setAttribute("placeholder","Search");const r=Gi();return r.style.position="absolute",r.style.top="50%",r.style.left="5%",r.style.transform="translate(-5%, -50%)",n.append(r,d(this,Ie)),t.append(n),t}_createBrowseMoreContainer(){f(this,Oe,b("browse-more-btn-container")),this._createAllAndSelectedTab(d(this,Oe));const e=this._renderUploadButton(),t=this._renderCreateFolderBtn(),n=document.createElement("div");return n.style.display="flex",n.style.alignItems="center",n.style.gap="10px",n.append(e,t),d(this,Oe).appendChild(n),d(this,Oe)}_createBrowseImageMain(){const e=b("browse-image-main");return f(this,M,b("selected-image-container")),d(this,M).addEventListener("scroll",()=>{const t=d(this,M).clientHeight,n=d(this,M).scrollTop,r=d(this,M).scrollHeight;t+n>=r-5&&d(this,Fe)&&(d(this,me)?this._search(d(this,De)):this._fetchFilesFromFolder(d(this,Ce)))}),e.appendChild(d(this,M)),e}_renderFetchingSkeletonUI(){for(let e=0;e<20;e++){const t=b("skeleton");t.innerHTML="",d(this,M).append(t)}}_renderEmptyImageContainer(){if(d(this,J)||d(this,ye))return;const e=b(),t=b(),n=document.createElement("p");d(this,me)&&d(this,Ne)===0?(t.innerHTML=`
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 fi(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 mi(i){switch(i){case 200:return p.OK;case 400:return p.INVALID_ARGUMENT;case 401:return p.UNAUTHENTICATED;case 403:return p.PERMISSION_DENIED;case 404:return p.NOT_FOUND;case 409:return p.ABORTED;case 412:return p.FAILED_PRECONDITION;case 429:return p.RESOURCE_EXHAUSTED;case 499:return p.CANCELLED;case 500:return p.UNKNOWN;case 501:return p.UNIMPLEMENTED;case 503:return p.UNAVAILABLE;case 504:return p.DEADLINE_EXCEEDED;default:return p.UNKNOWN}}class gi{constructor(e){this.defaultOptions=e}mergeOptions(e){return ri(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 L("Client streaming is not supported by grpc-web",p[p.UNIMPLEMENTED]);throw t.methodName=e.name,t.serviceName=e.service.typeName,t}duplex(e){const t=new L("Duplex streaming is not supported by grpc-web",p[p.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:{},g=this.makeUrl(e,l),w=e.I.toBinary(t,l.binaryOptions),T=new we,O=new si,P=!0,v,j=new we,K,ie=new we;return globalThis.fetch(g,Object.assign(Object.assign({},h),{method:"POST",headers:St(new globalThis.Headers,c,l.timeout,l.meta),body:Ut(w,c),signal:(o=n.abort)!==null&&o!==void 0?o:null})).then(C=>{let[y,V,X]=ht(C);if(T.resolve(X),y!=null&&y!==p.OK)throw new L(V??p[y],p[y],X);return y!=null&&(v={code:p[y],detail:V??p[y]}),C}).then(C=>{if(!C.body)throw new L("missing response body",p[p.INTERNAL]);return Mt(C.body,C.headers.get("content-type"),(y,V)=>{switch(y){case te.DATA:O.notifyMessage(e.O.fromBinary(V,l.binaryOptions)),P=!1;break;case te.TRAILER:let X,re;[X,re,K]=Rt(V),v={code:p[X],detail:re??p[X]};break}})}).then(()=>{if(!K&&!P)throw new L("missing trailers",p[p.DATA_LOSS]);if(!v)throw new L("missing status",p[p.INTERNAL]);if(v.code!=="OK")throw new L(v.detail,v.code,K);O.notifyComplete(),j.resolve(v),ie.resolve(K||{})}).catch(C=>{let y;C instanceof L?y=C:C instanceof Error&&C.name==="AbortError"?y=new L(C.message,p[p.CANCELLED]):y=new L(C instanceof Error?C.message:""+C,p[p.INTERNAL]),y.methodName=e.name,y.serviceName=e.service.typeName,T.rejectPending(y),O.notifyError(y),j.rejectPending(y),ie.rejectPending(y)}),new ci(e,(a=l.meta)!==null&&a!==void 0?a:{},t,T.promise,O,j.promise,ie.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:{},g=this.makeUrl(e,l),w=e.I.toBinary(t,l.binaryOptions),T=new we,O,P=new we,v,j=new we,K,ie=new we;return globalThis.fetch(g,Object.assign(Object.assign({},h),{method:"POST",headers:St(new globalThis.Headers,c,l.timeout,l.meta),body:Ut(w,c),signal:(o=n.abort)!==null&&o!==void 0?o:null})).then(C=>{let[y,V,X]=ht(C);if(T.resolve(X),y!=null&&y!==p.OK)throw new L(V??p[y],p[y],X);return y!=null&&(v={code:p[y],detail:V??p[y]}),C}).then(C=>{if(!C.body)throw new L("missing response body",p[p.INTERNAL]);return Mt(C.body,C.headers.get("content-type"),(y,V)=>{switch(y){case te.DATA:if(O)throw new L("unary call received 2nd message",p[p.DATA_LOSS]);O=e.O.fromBinary(V,l.binaryOptions);break;case te.TRAILER:let X,re;[X,re,K]=Rt(V),v={code:p[X],detail:re??p[X]};break}})}).then(()=>{if(!K&&O)throw new L("missing trailers",p[p.DATA_LOSS]);if(!v)throw new L("missing status",p[p.INTERNAL]);if(!O&&v.code==="OK")throw new L("expected error status",p[p.DATA_LOSS]);if(!O)throw new L(v.detail,v.code,K);if(P.resolve(O),v.code!=="OK")throw new L(v.detail,v.code,K);j.resolve(v),ie.resolve(K||{})}).catch(C=>{let y;C instanceof L?y=C:C instanceof Error&&C.name==="AbortError"?y=new L(C.message,p[p.CANCELLED]):y=new L(C instanceof Error?C.message:""+C,p[p.INTERNAL]),y.methodName=e.name,y.serviceName=e.service.typeName,T.rejectPending(y),P.rejectPending(y),j.rejectPending(y),ie.rejectPending(y)}),new ai(e,(a=l.meta)!==null&&a!==void 0?a:{},t,T.promise,P.promise,j.promise,ie.promise)}}var ut=(i=>(i[i.IMAGE=0]="IMAGE",i[i.AUDIO=1]="AUDIO",i[i.VIDEO=2]="VIDEO",i[i.ALL=3]="ALL",i[i.FOLDER=4]="FOLDER",i))(ut||{});class wi extends q{constructor(){super("com.hamropatro.grpc.cms.SearchRequest",[{no:1,name:"search_value",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.searchValue="",t.cursor="",t.limit=0,e!==void 0&&H(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.searchValue=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?N.onRead:c)(this.typeName,s,a,l,h)}}return s}internalBinaryWrite(e,t,n){e.searchValue!==""&&t.tag(1,m.LengthDelimited).string(e.searchValue),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?N.onWrite:r)(this.typeName,e,t),t}}const Wt=new wi;class bi extends q{constructor(){super("com.hamropatro.grpc.cms.SearchResult",[{no:1,name:"items",kind:"message",repeat:1,T:()=>ae},{no:2,name:"next_page_cursor",kind:"scalar",T:9}])}create(e){const t=globalThis.Object.create(this.messagePrototype);return t.items=[],t.nextPageCursor="",e!==void 0&&H(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.items.push(ae.internalBinaryRead(e,e.uint32(),n));break;case 2:s.nextPageCursor=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?N.onRead:c)(this.typeName,s,a,l,h)}}return s}internalBinaryWrite(e,t,n){for(let s=0;s<e.items.length;s++)ae.internalBinaryWrite(e.items[s],t.tag(1,m.LengthDelimited).fork(),n).join();e.nextPageCursor!==""&&t.tag(2,m.LengthDelimited).string(e.nextPageCursor);let r=n.writeUnknownFields;return r!==!1&&(r==!0?N.onWrite:r)(this.typeName,e,t),t}}const yi=new bi;class Ci extends q{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",ut]}])}create(e){const t=globalThis.Object.create(this.messagePrototype);return t.name="",t.folderName="",t.nestedFolderName="",t.url="",t.type=0,e!==void 0&&H(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?N.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?N.onWrite:r)(this.typeName,e,t),t}}const Pt=new Ci;class Ei extends q{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",ut]},{no:9,name:"metadata",kind:"message",T:()=>pt}])}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&&H(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=pt.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?N.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&&pt.internalBinaryWrite(e.metadata,t.tag(9,m.LengthDelimited).fork(),n).join();let r=n.writeUnknownFields;return r!==!1&&(r==!0?N.onWrite:r)(this.typeName,e,t),t}}const ae=new Ei;class Ni extends q{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&&H(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?N.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?N.onWrite:r)(this.typeName,e,t),t}}const pt=new Ni;class ki extends q{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&&H(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?N.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?N.onWrite:r)(this.typeName,e,t),t}}const jt=new ki;class Fi extends q{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&&H(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?N.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?N.onWrite:r)(this.typeName,e,t),t}}const Ii=new Fi;class Li extends q{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&&H(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?N.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?N.onWrite:r)(this.typeName,e,t),t}}const Zt=new Li;class Ai extends q{constructor(){super("com.hamropatro.grpc.cms.GetFilesByFolderResponse",[{no:1,name:"files",kind:"message",repeat:1,T:()=>ae},{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&&H(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(ae.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?N.onRead:c)(this.typeName,s,a,l,h)}}return s}internalBinaryWrite(e,t,n){for(let s=0;s<e.files.length;s++)ae.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?N.onWrite:r)(this.typeName,e,t),t}}const Ti=new Ai,ft=new dt("com.hamropatro.grpc.cms.FileService",[{name:"createFile",options:{},I:Pt,O:ae},{name:"updateFile",options:{},I:ae,O:ae},{name:"deleteFile",options:{},I:jt,O:Ii},{name:"getFilesByFolder",options:{},I:Zt,O:Ti},{name:"search",options:{},I:Wt,O:yi}]);class Ve{constructor(e){_(this,"typeName",ft.typeName);_(this,"methods",ft.methods);_(this,"options",ft.options);this._transport=e}createFile(e,t){const n=this.methods[0],r=this._transport.mergeOptions(t);return oe("unary",this._transport,n,r,e)}updateFile(e,t){const n=this.methods[1],r=this._transport.mergeOptions(t);return oe("unary",this._transport,n,r,e)}deleteFile(e,t){const n=this.methods[2],r=this._transport.mergeOptions(t);return oe("unary",this._transport,n,r,e)}getFilesByFolder(e,t){const n=this.methods[3],r=this._transport.mergeOptions(t);return oe("unary",this._transport,n,r,e)}search(e,t){const n=this.methods[4],r=this._transport.mergeOptions(t);return oe("unary",this._transport,n,r,e)}}const vi=async(i,e,t,n,r,s)=>{var o;try{const a=(o=window.ImageSalonSDK)==null?void 0:o.grpcConfig,l=new Ve(a),c=Pt.create();return c.name=i,c.nestedFolderName=e,c.url=t,c.type=n,c.folderName=r,await l.createFile(c,s)}catch(a){throw a}},Bi=async(i,e,t,n)=>{var r;try{const s=(r=window.ImageSalonSDK)==null?void 0:r.grpcConfig,o=new Ve(s),a=Zt.create();return a.folderName=i,a.cursor=e,a.limit=t,await o.getFilesByFolder(a,n)}catch(s){throw s}},xi=async(i,e,t=20,n)=>{var r;try{const s=(r=window.ImageSalonSDK)==null?void 0:r.grpcConfig,o=new Ve(s),a=Wt.create();return a.searchValue=i,a.cursor=e,a.limit=t,await o.search(a,n)}catch(s){throw s}},Oi=async(i,e,t,n,r,s,o,a,l)=>{var c;try{const h=(c=window.ImageSalonSDK)==null?void 0:c.grpcConfig,g=new Ve(h),w=ae.create();return w.key=i,w.name=e,w.nestedFolderName=t,w.url=n,w.thumborUrl=r,w.proxyUrl=s,w.type=o,w.folderName=a,await g.updateFile(w,l)}catch(h){throw h}},_i=async(i,e)=>{var t;try{const n=(t=window.ImageSalonSDK)==null?void 0:t.grpcConfig,r=new Ve(n),s=jt.create();return s.key=i,await r.deleteFile(s,e)}catch(n){throw n}};class Di extends q{constructor(){super("com.hamropatro.grpc.cms.DeleteFolderRequest",[{no:1,name:"key",kind:"scalar",T:9}])}create(e){const t=globalThis.Object.create(this.messagePrototype);return t.key="",e!==void 0&&H(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?N.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?N.onWrite:r)(this.typeName,e,t),t}}const qt=new Di;class Si extends q{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&&H(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?N.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?N.onWrite:r)(this.typeName,e,t),t}}const Kt=new Si;class Ui extends q{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&&H(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?N.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?N.onWrite:r)(this.typeName,e,t),t}}const Xt=new Ui;class Ri extends q{constructor(){super("com.hamropatro.grpc.cms.GetAllFoldersResponse",[{no:1,name:"folder",kind:"message",repeat:1,T:()=>be},{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&&H(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(be.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?N.onRead:c)(this.typeName,s,a,l,h)}}return s}internalBinaryWrite(e,t,n){for(let s=0;s<e.folder.length;s++)be.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?N.onWrite:r)(this.typeName,e,t),t}}const Mi=new Ri;class Vi extends q{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&&H(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?N.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?N.onWrite:r)(this.typeName,e,t),t}}const be=new Vi,mt=new dt("com.hamropatro.grpc.cms.FolderService",[{name:"createFolder",options:{},I:Kt,O:be},{name:"getFolders",options:{},I:Xt,O:Mi},{name:"updateFolder",options:{},I:be,O:be},{name:"deleteFolder",options:{},I:qt,O:be}]);class tt{constructor(e){_(this,"typeName",mt.typeName);_(this,"methods",mt.methods);_(this,"options",mt.options);this._transport=e}createFolder(e,t){const n=this.methods[0],r=this._transport.mergeOptions(t);return oe("unary",this._transport,n,r,e)}getFolders(e,t){const n=this.methods[1],r=this._transport.mergeOptions(t);return oe("unary",this._transport,n,r,e)}updateFolder(e,t){const n=this.methods[2],r=this._transport.mergeOptions(t);return oe("unary",this._transport,n,r,e)}deleteFolder(e,t){const n=this.methods[3],r=this._transport.mergeOptions(t);return oe("unary",this._transport,n,r,e)}}const Hi=async(i,e=20,t)=>{var o;const n=(o=window.ImageSalonSDK)==null?void 0:o.grpcConfig,r=new tt(n),s=Xt.create();try{return s.cursor=i,s.limit=e,await r.getFolders(s,t)}catch(a){throw a}},$i=async(i,e,t,n)=>{var r;try{const s=(r=window.ImageSalonSDK)==null?void 0:r.grpcConfig,o=new tt(s),a=Kt.create();return a.name=i,a.nestedFolderName=e,a.createdBy=t,await o.createFolder(a,n)}catch(s){throw s}},Wi=async(i,e,t,n,r)=>{var s;try{const o=(s=window.ImageSalonSDK)==null?void 0:s.grpcConfig,a=new tt(o),l=be.create();return l.name=e,l.key=i,l.nestedFolderName=t,l.createdBy=n,await a.updateFolder(l,r)}catch(o){throw o}},Pi=async(i,e)=>{var t;try{const n=(t=window.ImageSalonSDK)==null?void 0:t.grpcConfig,r=new tt(n),s=qt.create();return s.key=i,await r.deleteFolder(s,e)}catch(n){throw n}},Gt=(i,e,t)=>{const n=document.createElementNS("http://www.w3.org/2000/svg","svg");n.setAttribute("xmlns","http://www.w3.org/2000/svg"),n.setAttribute("width",i||"20"),n.setAttribute("height",e||"20"),n.setAttribute("viewBox","0 0 24 24"),n.setAttribute("fill","none"),n.setAttribute("stroke",t||"#ee3f3f"),n.setAttribute("stroke-width","2"),n.setAttribute("stroke-linecap","round"),n.setAttribute("stroke-linejoin","round"),n.classList.add("lucide","lucide-circle-alert");const r=document.createElementNS("http://www.w3.org/2000/svg","circle");r.setAttribute("cx","12"),r.setAttribute("cy","12"),r.setAttribute("r","10");const s=document.createElementNS("http://www.w3.org/2000/svg","line");s.setAttribute("x1","12"),s.setAttribute("x2","12"),s.setAttribute("y1","8"),s.setAttribute("y2","12");const o=document.createElementNS("http://www.w3.org/2000/svg","line");return o.setAttribute("x1","12"),o.setAttribute("x2","12.01"),o.setAttribute("y1","16"),o.setAttribute("y2","16"),n.appendChild(r),n.appendChild(s),n.appendChild(o),n};function Jt(){const i=document.createElementNS("http://www.w3.org/2000/svg","svg");i.setAttribute("xmlns","http://www.w3.org/2000/svg"),i.setAttribute("height","24px"),i.setAttribute("width","24px"),i.setAttribute("viewBox","0 -960 960 960"),i.setAttribute("fill","#333");const e=document.createElementNS("http://www.w3.org/2000/svg","path");return e.setAttribute("d","M504-480 320-664l56-56 240 240-240 240-56-56 184-184Z"),i.appendChild(e),i}function ji(){const i=document.createElementNS("http://www.w3.org/2000/svg","svg");i.setAttribute("xmlns","http://www.w3.org/2000/svg"),i.setAttribute("width","12"),i.setAttribute("height","12"),i.setAttribute("viewBox","0 0 24 24"),i.setAttribute("fill","none"),i.setAttribute("stroke","currentColor"),i.setAttribute("stroke-width","2"),i.setAttribute("stroke-linecap","round"),i.setAttribute("stroke-linejoin","round"),i.classList.add("lucide","lucide-music-4");const e=document.createElementNS("http://www.w3.org/2000/svg","path");e.setAttribute("d","M9 18V5l12-2v13");const t=document.createElementNS("http://www.w3.org/2000/svg","path");t.setAttribute("d","m9 9 12-2");const n=document.createElementNS("http://www.w3.org/2000/svg","circle");n.setAttribute("cx","6"),n.setAttribute("cy","18"),n.setAttribute("r","3");const r=document.createElementNS("http://www.w3.org/2000/svg","circle");return r.setAttribute("cx","18"),r.setAttribute("cy","16"),r.setAttribute("r","3"),i.appendChild(e),i.appendChild(t),i.appendChild(n),i.appendChild(r),document.body.appendChild(i),i}const Zi=()=>{const i=document.createElementNS("http://www.w3.org/2000/svg","svg");i.setAttribute("xmlns","http://www.w3.org/2000/svg"),i.setAttribute("width","20"),i.setAttribute("height","20"),i.setAttribute("viewBox","0 0 24 24"),i.setAttribute("fill","none"),i.setAttribute("stroke","currentColor"),i.setAttribute("stroke-width","2"),i.setAttribute("stroke-linecap","round"),i.setAttribute("stroke-linejoin","round"),i.classList.add("lucide","lucide-circle-check-big");const e=document.createElementNS("http://www.w3.org/2000/svg","path");e.setAttribute("d","M21.801 10A10 10 0 1 1 17 3.335");const t=document.createElementNS("http://www.w3.org/2000/svg","path");return t.setAttribute("d","m9 11 3 3L22 4"),i.appendChild(e),i.appendChild(t),i};function zt(i="#333"){const e=document.createElementNS("http://www.w3.org/2000/svg","svg");e.setAttribute("xmlns","http://www.w3.org/2000/svg"),e.setAttribute("x","0px"),e.setAttribute("y","0px"),e.setAttribute("width","18"),e.setAttribute("height","18"),e.setAttribute("viewBox","0 0 50 50"),e.setAttribute("fill",i);const t=document.createElementNS("http://www.w3.org/2000/svg","path");return t.setAttribute("d","M 9.15625 6.3125 L 6.3125 9.15625 L 22.15625 25 L 6.21875 40.96875 L 9.03125 43.78125 L 25 27.84375 L 40.9375 43.78125 L 43.78125 40.9375 L 27.84375 25 L 43.6875 9.15625 L 40.84375 6.3125 L 25 22.15625 Z"),e.appendChild(t),e}function Yt(){const i=document.createElementNS("http://www.w3.org/2000/svg","svg");i.setAttribute("xmlns","http://www.w3.org/2000/svg"),i.setAttribute("width","16"),i.setAttribute("height","16"),i.setAttribute("viewBox","0 0 24 24"),i.setAttribute("fill","none"),i.setAttribute("stroke","#2c96f8"),i.setAttribute("stroke-width","2"),i.setAttribute("stroke-linecap","round"),i.setAttribute("stroke-linejoin","round"),i.classList.add("lucide","lucide-pencil");const e=document.createElementNS("http://www.w3.org/2000/svg","path");e.setAttribute("d","M21.174 6.812a1 1 0 0 0-3.986-3.987L3.842 16.174a2 2 0 0 0-.5.83l-1.321 4.352a.5.5 0 0 0 .623.622l4.353-1.32a2 2 0 0 0 .83-.497z");const t=document.createElementNS("http://www.w3.org/2000/svg","path");return t.setAttribute("d","m15 5 4 4"),i.appendChild(e),i.appendChild(t),document.body.appendChild(i),i}function He(){const i=document.createElementNS("http://www.w3.org/2000/svg","svg");i.setAttribute("xmlns","http://www.w3.org/2000/folder"),i.setAttribute("x","0px"),i.setAttribute("y","0px"),i.setAttribute("width","24"),i.setAttribute("height","24"),i.setAttribute("viewBox","0 0 48 48");const e=document.createElementNS("http://www.w3.org/2000/svg","path");e.setAttribute("fill","#FFA000"),e.setAttribute("d","M40,12H22l-4-4H8c-2.2,0-4,1.8-4,4v8h40v-4C44,13.8,42.2,12,40,12z");const t=document.createElementNS("http://www.w3.org/2000/svg","path");return t.setAttribute("fill","#FFCA28"),t.setAttribute("d","M40,12H8c-2.2,0-4,1.8-4,4v20c0,2.2,1.8,4,4,4h32c2.2,0,4-1.8,4-4V16C44,13.8,42.2,12,40,12z"),i.appendChild(e),i.appendChild(t),i}function qi(){const i="http://www.w3.org/2000/svg",e=document.createElementNS(i,"svg");e.setAttribute("width","12"),e.setAttribute("height","12"),e.setAttribute("viewBox","0 0 24 24"),e.setAttribute("fill","none"),e.setAttribute("stroke","currentColor"),e.setAttribute("stroke-width","3"),e.setAttribute("stroke-linecap","round"),e.setAttribute("stroke-linejoin","round"),e.classList.add("lucide","lucide-image");const t=document.createElementNS(i,"rect");t.setAttribute("width","18"),t.setAttribute("height","18"),t.setAttribute("x","3"),t.setAttribute("y","3"),t.setAttribute("rx","2"),t.setAttribute("ry","2");const n=document.createElementNS(i,"circle");n.setAttribute("cx","9"),n.setAttribute("cy","9"),n.setAttribute("r","2");const r=document.createElementNS(i,"path");return r.setAttribute("d","m21 15-3.086-3.086a2 2 0 0 0-2.828 0L6 21"),e.appendChild(t),e.appendChild(n),e.appendChild(r),document.body.appendChild(e),e}function Ki(){const i=document.createElementNS("http://www.w3.org/2000/svg","svg");i.setAttribute("xmlns","http://www.w3.org/2000/svg"),i.setAttribute("height","24px"),i.setAttribute("viewBox","0 -960 960 960"),i.setAttribute("width","24px"),i.setAttribute("fill","currentColor");const e=document.createElementNS("http://www.w3.org/2000/svg","path");return e.setAttribute("d","m488-400-65 65 56 56 161-161-161-161-56 56 65 65H320v80h168ZM160-160q-33 0-56.5-23.5T80-240v-480q0-33 23.5-56.5T160-800h240l80 80h320q33 0 56.5 23.5T880-640v400q0 33-23.5 56.5T800-160H160Zm0-80h640v-400H447l-80-80H160v480Zm0 0v-480 480Z"),i.appendChild(e),i}function Qt(){const i=document.createElementNS("http://www.w3.org/2000/svg","svg");i.setAttribute("xmlns","http://www.w3.org/2000/svg"),i.setAttribute("fill","none"),i.setAttribute("width","20"),i.setAttribute("height","20"),i.setAttribute("viewBox","0 0 24 24"),i.setAttribute("stroke-width","1.5"),i.setAttribute("stroke","currentColor"),i.setAttribute("class","size-2");const e=document.createElementNS("http://www.w3.org/2000/svg","path");return e.setAttribute("stroke-linecap","round"),e.setAttribute("stroke-linejoin","round"),e.setAttribute("d","M12 4.5v15m7.5-7.5h-15"),i.appendChild(e),i}function Xi(){const i="http://www.w3.org/2000/svg",e=document.createElementNS(i,"svg");e.setAttribute("width","16"),e.setAttribute("height","16"),e.setAttribute("viewBox","0 0 24 24"),e.setAttribute("fill","none"),e.setAttribute("stroke","currentColor"),e.setAttribute("stroke-width","2"),e.setAttribute("stroke-linecap","round"),e.setAttribute("stroke-linejoin","round"),e.classList.add("lucide","lucide-eye");const t=document.createElementNS(i,"path");t.setAttribute("d","M2.062 12.348a1 1 0 0 1 0-.696 10.75 10.75 0 0 1 19.876 0 1 1 0 0 1 0 .696 10.75 10.75 0 0 1-19.876 0"),e.appendChild(t);const n=document.createElementNS(i,"circle");return n.setAttribute("cx","12"),n.setAttribute("cy","12"),n.setAttribute("r","3"),e.appendChild(n),document.body.appendChild(e),e}function Gi(){const i=document.createElementNS("http://www.w3.org/2000/svg","svg");i.setAttribute("xmlns","http://www.w3.org/2000/svg"),i.setAttribute("height","24px"),i.setAttribute("width","24px"),i.setAttribute("viewBox","0 0 30 30"),i.setAttribute("fill","#999");const e=document.createElementNS("http://www.w3.org/2000/svg","path");return e.setAttribute("d","M 13 3 C 7.4889971 3 3 7.4889971 3 13 C 3 18.511003 7.4889971 23 13 23 C 15.396508 23 17.597385 22.148986 19.322266 20.736328 L 25.292969 26.707031 A 1.0001 1.0001 0 1 0 26.707031 25.292969 L 20.736328 19.322266 C 22.148986 17.597385 23 15.396508 23 13 C 23 7.4889971 18.511003 3 13 3 z M 13 5 C 17.430123 5 21 8.5698774 21 13 C 21 17.430123 17.430123 21 13 21 C 8.5698774 21 5 17.430123 5 13 C 5 8.5698774 8.5698774 5 13 5 z"),i.appendChild(e),i}function en(){const i=document.createElementNS("http://www.w3.org/2000/svg","svg");i.setAttribute("xmlns","http://www.w3.org/2000/svg"),i.setAttribute("width","16"),i.setAttribute("height","16"),i.setAttribute("viewBox","0 0 24 24"),i.setAttribute("fill","none"),i.setAttribute("stroke","#f14b4b"),i.setAttribute("stroke-width","2"),i.setAttribute("stroke-linecap","round"),i.setAttribute("stroke-linejoin","round"),i.classList.add("lucide","lucide-trash-2");const e=document.createElementNS("http://www.w3.org/2000/svg","path");e.setAttribute("d","M3 6h18");const t=document.createElementNS("http://www.w3.org/2000/svg","path");t.setAttribute("d","M19 6v14c0 1-1 2-2 2H7c-1 0-2-1-2-2V6");const n=document.createElementNS("http://www.w3.org/2000/svg","path");n.setAttribute("d","M8 6V4c0-1 1-2 2-2h4c1 0 2 1 2 2v2");const r=document.createElementNS("http://www.w3.org/2000/svg","line");r.setAttribute("x1","10"),r.setAttribute("x2","10"),r.setAttribute("y1","11"),r.setAttribute("y2","17");const s=document.createElementNS("http://www.w3.org/2000/svg","line");return s.setAttribute("x1","14"),s.setAttribute("x2","14"),s.setAttribute("y1","11"),s.setAttribute("y2","17"),i.appendChild(e),i.appendChild(t),i.appendChild(n),i.appendChild(r),i.appendChild(s),document.body.appendChild(i),i}function Ji(){const i="http://www.w3.org/2000/svg",e=document.createElementNS(i,"svg");e.setAttribute("xmlns",i),e.setAttribute("height","20px"),e.setAttribute("viewBox","0 -960 960 960"),e.setAttribute("width","20px"),e.setAttribute("fill","#fff");const t=document.createElementNS(i,"path");return t.setAttribute("d","M440-320v-326L336-542l-56-58 200-200 200 200-56 58-104-104v326h-80ZM240-160q-33 0-56.5-23.5T160-240v-120h80v120h480v-120h80v120q0 33-23.5 56.5T720-160H240Z"),e.appendChild(t),e}function zi(){const i="http://www.w3.org/2000/svg",e=document.createElementNS(i,"svg");e.setAttribute("width","12"),e.setAttribute("height","12"),e.setAttribute("viewBox","0 0 24 24"),e.setAttribute("fill","none"),e.setAttribute("stroke","currentColor"),e.setAttribute("stroke-width","3"),e.setAttribute("stroke-linecap","round"),e.setAttribute("stroke-linejoin","round"),e.classList.add("lucide","lucide-video");const t=document.createElementNS(i,"path");t.setAttribute("d","m16 13 5.223 3.482a.5.5 0 0 0 .777-.416V7.87a.5.5 0 0 0-.752-.432L16 10.5");const n=document.createElementNS(i,"rect");return n.setAttribute("x","2"),n.setAttribute("y","6"),n.setAttribute("width","14"),n.setAttribute("height","12"),n.setAttribute("rx","2"),e.appendChild(t),e.appendChild(n),document.body.appendChild(e),e}function W(i,e,t){let n=document.createElement(i);return n.className+=e,t&&t.appendChild(n),n}class Yi{constructor(){k(this,ue);f(this,ue,document.createElementNS("http://www.w3.org/2000/svg","svg")),d(this,ue).setAttribute("viewBox","25 25 50 50"),d(this,ue).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,ue).appendChild(e)}show(e){e.appendChild(d(this,ue))}hide(){d(this,ue).remove()}}ue=new WeakMap;const tn=new Yi,nt=document.body;class nn{constructor(){_(this,"main");_(this,"dialogContainer");_(this,"dialog");_(this,"dialogBackdrop");_(this,"dialogContent");_(this,"dialogHeader");_(this,"dialogBody");_(this,"dialogFooter");_(this,"confirmButton");_(this,"cancelButton");_(this,"confirmCallback");_(this,"cancelCallback");this.main=W("div"),this.dialog=W("div"),this.confirmCallback=void 0,this.cancelCallback=void 0}_init(e){this.main=W("div","dialog-presentation",nt),this.main.setAttribute("role","presentation"),this.dialogContainer=W("div","dialog-container",this.main),this.dialogBackdrop=W("div","dialog-backdrop",this.dialogContainer),this.dialog=W("div","dialog",this.dialogContainer),this.dialog.setAttribute("tabIndex","-1");const t=document.activeElement;if(t&&t!==document.body&&(t.blur(),this.dialog.focus()),this.dialog.className="dialog",this.dialogContent=W("div","dialog-content",this.dialog),e!=null&&e.dialogContentStyle&&Object.assign(this.dialogContent.style,e.dialogContentStyle),this.confirmButton=W("button","dialog-btn confirm",this.dialogFooter),this.confirmButton.type="button",this.cancelButton=W("button","dialog-btn cancel",this.dialogFooter),this.cancelButton.type="button",e.showCloseBtn){const n=W("button","dialog-close-btn",this.dialogContent);n.appendChild(zt()),n.onclick=()=>this.hide()}return e.header&&this._setHeader(e),this._setBody(e),this._setFooter(e),this.confirmButton.textContent=e.confirmButtonText||"Upload",this.cancelButton.textContent=e.cancelButtonText||"Cancel",nt.style.overflow="hidden",this.confirmButton.textContent=e.confirmButtonText||"Upload",this.cancelButton.textContent=e.cancelButtonText||"Cancel",nt.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)})}_setHeader(e){if(this.dialogHeader=W("div","dialog-header",this.dialogContent),!e.header)this.dialogHeader.innerHTML="";else if(typeof e.header=="string"){const t=W("h4","dialog-header-text",this.dialogHeader);t.textContent=e.header}else this.dialogHeader.innerHTML="",this.dialogHeader.appendChild(e.header)}_setBody(e){this.dialogBody=W("div","dialog-body",this.dialogContent),typeof e.content=="string"?this.dialogBody.innerHTML=e.content:(this.dialogBody.innerHTML="",this.dialogBody.appendChild(e.content))}_setFooter(e){this.dialogFooter=W("div","dialog-footer",this.dialogContent),e.showFooter?this.dialogFooter.append(this.cancelButton,this.confirmButton):(this.dialogFooter.innerHTML="",this.dialogFooter.remove())}show(e){this._init(e),setTimeout(()=>{this.dialogContainer.style.opacity="1",this.dialog.style.transform="scale(1)",this.dialog.style.transition="transform 150ms ease-in",this.dialog.style.opacity="1",this.dialogBackdrop.style.opacity="1"},150)}hide(){this.main||nt.style.removeProperty("overflow"),this.dialog.style.transform="scale(0.8)",this.dialog.style.transition="transform 150ms ease-out",this.dialogBackdrop.style.opacity="0",setTimeout(()=>{this.dialogContainer.style.opacity="0",this.dialog.style.opacity="0",this.dialogContent.style.opacity="0",this.main.remove()},150)}updateUploadBtn(e){e?(tn.show(this.confirmButton),this.confirmButton.disabled=!0):(tn.hide(),this.confirmButton.disabled=!1)}}const it=new nn,R=new nn;class Qi{constructor(){_(this,"main");_(this,"dialogBody");this.main=W("div"),this.dialogBody=W("div"),this.hide()}show(e){this.main=W("div","popover",e.mainContainer),this.dialogBody=W("div","popover-body",this.main),this.main.id=e.divId,this.dialogBody.append(e.content)}hide(){this.main.remove()}}const Q=new Qi;var he=(i=>(i[i.IMAGE=0]="IMAGE",i[i.AUDIO=1]="AUDIO",i[i.VIDEO=2]="VIDEO",i[i.ALL=3]="ALL",i[i.FOLDER=4]="FOLDER",i))(he||{});const $e={0:"IMAGE",1:"AUDIO",2:"VIDEO",3:"ALL",4:"FOLDER"};function er(i){switch(i){case"image":return $e[he.IMAGE];case"video":return $e[he.VIDEO];case"audio":return $e[he.AUDIO];default:return $e[he.ALL]}}function tr(i){const e={};i.forEach(r=>{e[r.key]={...r,children:{}}});const t=r=>(Object.values(e).filter(o=>o.nestedFolderName==r.key).forEach(o=>{r.children[o.key]=t(o)}),r);return i.reduce((r,s)=>(s.nestedFolderName||r.push(t(e[s.key])),r),[])}function nr(i,e){const t=n=>{if(n.key===e.nestedFolderName)return n.children[e.key]={...e,children:{}},!0;for(const r in n.children){const s=n.children[r];if(t(s))return!0}return!1};for(const n of i)if(t(n))break;return i}const ir=async i=>{let e;try{i&&(e={Authorization:i})}catch(n){if(n)throw n}return{meta:e}};function b(i,e){const t=document.createElement("div");return i&&(t.className=i),e&&(t.id=e),t}function We(i,e,t){const n=document.createElement("p");return e&&(n.className=e),t&&(n.id=t),i&&(n.textContent=i),n}function A(i,e){const t=document.createElement("span");return e&&(t.className=e),i&&(t.textContent=i),t}function rn(i,e,t,n){const r=document.createElement("img");return e&&(r.className=e),r.src=i,r}function rr(i,e,t){const n=document.createElement("video"),r=document.createElement("source");return n.className=e,r.src=i,n.appendChild(r),n}function sr(i,e,t){const n=document.createElement("audio"),r=document.createElement("source");return n.className=e,n.controls=!0,r.src=i,n.appendChild(r),n}function G(i,e,t,n,r){const s=document.createElement("button");return e&&(s.className=e),t&&(s.id=t),i&&(s.textContent=i),r&&(s.innerHTML=r),s.disabled=n,s}function sn(i,e,t){const n=document.createElement("input");return n.className=e,n.defaultValue=t,i&&(n.type=i),n}class or extends q{constructor(){super("com.hamropatro.grpc.cms.ImageUploadRequest",[])}create(e){const t=globalThis.Object.create(this.messagePrototype);return e!==void 0&&H(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?N.onWrite:r)(this.typeName,e,t),t}}const on=new or;class ar extends q{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&&H(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?N.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?N.onWrite:r)(this.typeName,e,t),t}}const lr=new ar,gt=new dt("com.hamropatro.grpc.cms.ImageUploadService",[{name:"Upload",options:{},I:on,O:lr}]);class cr{constructor(e){_(this,"typeName",gt.typeName);_(this,"methods",gt.methods);_(this,"options",gt.options);this._transport=e}upload(e,t){const n=this.methods[0],r=this._transport.mergeOptions(t);return oe("unary",this._transport,n,r,e)}}const dr=async()=>{var i;try{const e=(i=window.ImageSalonSDK)==null?void 0:i.grpcConfig,t=new cr(e),n=on.create();return await t.upload(n)}catch(e){throw e}},hr=async(i,e)=>{try{const t=ur(i,e),r=(await dr()).response.url;return await fetch(r,{method:"PUT",headers:{"Content-Type":e.type.includes("image/")?e.type:"image/*","x-amz-acl":"public-read"},body:t}),r==null?void 0:r.split("?")[0]}catch(t){throw t}},ur=(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};class pr{constructor(e){k(this,ve);k(this,Be);k(this,M);k(this,pe);k(this,D,[]);k(this,$,[]);k(this,ye);k(this,J);k(this,xe);k(this,Ce);k(this,le,[]);k(this,ne);k(this,Ee);k(this,Pe);k(this,Ne);k(this,ke);k(this,fe);k(this,Oe);k(this,ce);k(this,de);k(this,Fe);k(this,Ie);k(this,me);k(this,De);k(this,je);k(this,z);k(this,ge);k(this,Ze,!1);k(this,qe);k(this,Le);f(this,ye,!1),f(this,J,!1),f(this,xe,!1),f(this,Pe,e.handleUpload.bind(this)),f(this,Ne,0),f(this,de,""),f(this,Fe,!1),f(this,me,!1),f(this,je,e.accessToken),f(this,ge,null),f(this,Le,""),this._removeToastContainer(),this._grpcOptionInitializer(),this._init(e).then(()=>{f(this,Ze,!0),this._create(e),this.updateWindowObject({initialized:!0}),this._initializeGrpcConfig(e.mode,e.endPoint)}),f(this,qe,e.enableMultiSelect)}async _init(e){try{const{mode:t}=e;this.updateWindowObject({mode:t})}catch{throw Error("Initialization failed")}}_create(e){if(!d(this,Ze))return;const{parentContainerId:t,buttonProps:n}=e;f(this,ve,document.getElementById(t));const r=document.createElement("button");r.className=n!=null&&n.buttonClass?n==null?void 0:n.buttonClass:"browse-image-button",r.addEventListener("focus",()=>{r.blur()});const s=document.createElement("span");s.textContent=n!=null&&n.buttonText?n==null?void 0:n.buttonText:"Browse Files";const o=document.createElement("span");return o.innerHTML=n!=null&&n.buttonIcon?n==null?void 0:n.buttonIcon:"",r.type="button",r.append(s,o),n!=null&&n.buttonStyle&&Object.assign(r.style,n==null?void 0:n.buttonStyle),r.addEventListener("click",()=>{this._selectedImageContainer()}),d(this,ve)&&d(this,ve).appendChild(r),d(this,ve)}async _grpcOptionInitializer(){f(this,z,await ir(d(this,je)))}_selectedImageContainer(){var g;f(this,Ee,G(`Save (${(g=d(this,D))==null?void 0:g.length})`,"dialog-btn confirm")),f(this,ke,b("folder-container")),f(this,fe,b("folder-list-wrapper")),this._fetchAllFolders();const e=G("Cancel","dialog-btn cancel");G("","dialog-modal-close-btn","",!1,'<svg xmlns="http://www.w3.org/2000/svg" x="0px" y="0px" width="24" height="24" viewBox="0 0 50 50"> <path d="M 9.15625 6.3125 L 6.3125 9.15625 L 22.15625 25 L 6.21875 40.96875 L 9.03125 43.78125 L 25 27.84375 L 40.9375 43.78125 L 43.78125 40.9375 L 27.84375 25 L 43.6875 9.15625 L 40.84375 6.3125 L 25 22.15625 Z"></path> </svg>').addEventListener("click",()=>{it.hide(),f(this,D,[]),f(this,$,[])}),f(this,Be,b("browse-container"));const n=b();n.style.display="flex",n.style.alignItems="center",n.style.justifyContent="space-between",n.style.padding="10px 20px";const r=We("Folders","folder-title"),s=G("","add-folder-btn");s.append(Qt()),this._createUpdateFolderDialog(s,"create"),n.append(r,s),d(this,ke).append(n,d(this,fe));const o=this._renderSearchField(),a=this._createBrowseMoreContainer(),l=this._createBrowseImageMain(),c=b("footer");e.onclick=()=>{it.hide(),f(this,$,[]),f(this,D,[])},d(this,Ee).onclick=()=>{d(this,Pe).call(this),it.hide(),f(this,D,[]),f(this,$,[])},c.append(e,d(this,Ee));const h=b("container-right-main");h.append(o,a,l,c),d(this,Be).append(d(this,ke),h),it.show({content:d(this,Be)})}_createAllAndSelectedTab(e){const t=b("select-options"),n=We("Browse","select"),r=We("Selected","select","selected-images-tab");n.classList.add("selected"),[n,r].forEach((o,a)=>{o.addEventListener("click",()=>{var l;f(this,Ne,a),(l=document.querySelector(".select.selected"))==null||l.classList.remove("selected"),o.classList.add("selected"),this._updateSelectedImageListContainerUI()})}),t.append(n,r),e.appendChild(t)}_renderUploadButton(){const e=sn("file");e.style.display="none",e.setAttribute("multiple","true"),e.setAttribute("accept","image/*,video/*,audio/*,.gif"),f(this,pe,document.createElement("button")),d(this,pe).className="browse-more-btn";const t=document.createElement("span");return t.textContent="Upload",d(this,pe).append(Ji(),t),d(this,pe).type="button",d(this,pe).addEventListener("click",()=>e.click()),e.addEventListener("change",()=>{const n=e.files;Object.values(n).forEach(r=>{const s=new FileReader;s.readAsDataURL(r),s.onload=async()=>{await this._uploadAndAddSelectedImageList(s.result,r)}}),e.value=""}),d(this,pe)}_renderCreateFolderBtn(){const e=document.createElement("button");e.className="create-folder-btn";const t=document.createElement("span");return t.textContent="Create",e.append(Qt(),t),this._createUpdateFolderDialog(e,"create"),e}_renderSearchField(){let e;const t=b("search-browse-container"),n=b("search-input-wrapper","search-input-wrapper");f(this,Ie,sn("search")),d(this,Ie).value="",d(this,Ie).addEventListener("input",s=>{f(this,$,[]);const o=s.target;e&&clearTimeout(e),e=setTimeout(()=>{if(!o.value){f(this,de,""),f(this,Fe,!1),f(this,me,!1),this._fetchFilesFromFolder(d(this,Ce));return}f(this,me,!0),f(this,De,o.value),this._search(d(this,De))},750)}),d(this,Ie).setAttribute("placeholder","Search");const r=Gi();return r.style.position="absolute",r.style.top="50%",r.style.left="5%",r.style.transform="translate(-5%, -50%)",n.append(r,d(this,Ie)),t.append(n),t}_createBrowseMoreContainer(){f(this,Oe,b("browse-more-btn-container")),this._createAllAndSelectedTab(d(this,Oe));const e=this._renderUploadButton(),t=this._renderCreateFolderBtn(),n=document.createElement("div");return n.style.display="flex",n.style.alignItems="center",n.style.gap="10px",n.append(e,t),d(this,Oe).appendChild(n),d(this,Oe)}_createBrowseImageMain(){const e=b("browse-image-main");return f(this,M,b("selected-image-container")),d(this,M).addEventListener("scroll",()=>{const t=d(this,M).clientHeight,n=d(this,M).scrollTop,r=d(this,M).scrollHeight;t+n>=r-5&&d(this,Fe)&&(d(this,me)?this._search(d(this,De)):this._fetchFilesFromFolder(d(this,Ce)))}),e.appendChild(d(this,M)),e}_renderFetchingSkeletonUI(){for(let e=0;e<20;e++){const t=b("skeleton");t.innerHTML="",d(this,M).append(t)}}_renderEmptyImageContainer(){if(d(this,J)||d(this,ye))return;const e=b(),t=b(),n=document.createElement("p");d(this,me)&&d(this,Ne)===0?(t.innerHTML=`
6
6
  <svg width="300" height="300" viewBox="0 0 1000 1000" fill="none" xmlns="http://www.w3.org/2000/svg">
7
7
  <g clip-path="url(#clip0_2304_257)">
8
8
  <path d="M564.829 772.4H336.658V948.386H564.829V772.4Z" fill="#EBEBEB"/>
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "image-salon-sdk",
3
- "version": "1.0.30",
3
+ "version": "1.0.32",
4
4
  "license": "ISC",
5
5
  "type": "module",
6
6
  "files": [
@@ -21,7 +21,8 @@
21
21
  "dev": "vite",
22
22
  "build": "rm -rf dist/ && tsc && vite build",
23
23
  "preview": "vite preview",
24
- "serve": "vite serve"
24
+ "serve": "vite serve",
25
+ "publish": "vite build && npm publish"
25
26
  },
26
27
  "devDependencies": {
27
28
  "typescript": "^5.5.4",