@nethesis/chat-island 0.1.6 → 0.1.8

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -43,7 +43,7 @@ function w(e) {
43
43
  //#endregion
44
44
  //#region src/drag.ts
45
45
  var T = 8;
46
- function E(e, t) {
46
+ function ee(e, t) {
47
47
  let [n, a] = c(() => {
48
48
  try {
49
49
  let e = localStorage.getItem(t);
@@ -103,7 +103,7 @@ function E(e, t) {
103
103
  }
104
104
  //#endregion
105
105
  //#region node_modules/ltx/lib/escape.js
106
- var D = /* @__PURE__ */ y(((e) => {
106
+ var E = /* @__PURE__ */ y(((e) => {
107
107
  var t = {
108
108
  "&": "&",
109
109
  "<": "&lt;",
@@ -145,8 +145,8 @@ var D = /* @__PURE__ */ y(((e) => {
145
145
  return e.replace(/&(amp|#38|lt|#60|gt|#62);/g, i);
146
146
  }
147
147
  e.escapeXML = a, e.escapeXMLText = s, e.unescapeXML = o, e.unescapeXMLText = c;
148
- })), O = /* @__PURE__ */ y(((e, t) => {
149
- var n = D(), r = class e {
148
+ })), D = /* @__PURE__ */ y(((e, t) => {
149
+ var n = E(), r = class e {
150
150
  constructor(e, t) {
151
151
  this.name = e, this.parent = null, this.children = [], this.attrs = {}, this.setAttrs(t);
152
152
  }
@@ -277,8 +277,8 @@ var D = /* @__PURE__ */ y(((e) => {
277
277
  }
278
278
  };
279
279
  r.prototype.tree = r.prototype.root, t.exports = r;
280
- })), ee = /* @__PURE__ */ y(((e, t) => {
281
- var n = O();
280
+ })), O = /* @__PURE__ */ y(((e, t) => {
281
+ var n = D();
282
282
  function r(e, t) {
283
283
  if (Array.isArray(t)) {
284
284
  for (let n of t) r(e, n);
@@ -472,7 +472,7 @@ var D = /* @__PURE__ */ y(((e) => {
472
472
  else throw TypeError("The \"emitter\" argument must be of type EventEmitter. Received type " + typeof e);
473
473
  }
474
474
  })), te = /* @__PURE__ */ y(((e, t) => {
475
- var n = k(), r = D(), i = 0, a = 1, o = 2, s = 3, c = 4, l = 5, u = 6, d = 7, f = 8, p = 9, m = 10;
475
+ var n = k(), r = E(), i = 0, a = 1, o = 2, s = 3, c = 4, l = 5, u = 6, d = 7, f = 8, p = 9, m = 10;
476
476
  t.exports = class extends n.EventEmitter {
477
477
  constructor() {
478
478
  super();
@@ -565,14 +565,14 @@ var D = /* @__PURE__ */ y(((e) => {
565
565
  e && this.write(e), this.write = function() {};
566
566
  }
567
567
  };
568
- })), A = D(), j = /* @__PURE__ */ x(O(), 1), ne = /* @__PURE__ */ x(ee(), 1), M = k(), re = /* @__PURE__ */ x(te(), 1), ie = class extends Error {
568
+ })), A = E(), j = /* @__PURE__ */ x(D(), 1), M = /* @__PURE__ */ x(O(), 1), N = k(), ne = /* @__PURE__ */ x(te(), 1), re = class extends Error {
569
569
  constructor(e) {
570
570
  super(e), this.name = "TimeoutError";
571
571
  }
572
572
  };
573
573
  //#endregion
574
574
  //#region node_modules/@xmpp/events/lib/delay.js
575
- function ae(e) {
575
+ function ie(e) {
576
576
  let t, n = new Promise((n) => {
577
577
  t = setTimeout(n, e);
578
578
  });
@@ -580,32 +580,32 @@ function ae(e) {
580
580
  }
581
581
  //#endregion
582
582
  //#region node_modules/@xmpp/events/lib/timeout.js
583
- function oe(e, t) {
584
- let n = ae(t);
583
+ function ae(e, t) {
584
+ let n = ie(t);
585
585
  function r() {
586
586
  clearTimeout(n.timeout);
587
587
  }
588
- let i = new ie();
588
+ let i = new re();
589
589
  return Promise.race([e.finally(r), n.then(() => {
590
590
  throw i;
591
591
  })]);
592
592
  }
593
593
  //#endregion
594
594
  //#region node_modules/@xmpp/events/lib/onoff.js
595
- var se = /* @__PURE__ */ new WeakMap();
596
- function ce(e) {
597
- let t = se.get(e);
595
+ var oe = /* @__PURE__ */ new WeakMap();
596
+ function se(e) {
597
+ let t = oe.get(e);
598
598
  return t || (t = {
599
599
  on: (e.addEventListener ?? e.addListener).bind(e),
600
600
  off: (e.removeEventListener ?? e.removeListener).bind(e),
601
601
  once: (e.once ?? ((t, n) => e.addEventListener(t, n, { once: !0 }))).bind(e)
602
- }, se.set(e, t)), t;
602
+ }, oe.set(e, t)), t;
603
603
  }
604
604
  //#endregion
605
605
  //#region node_modules/@xmpp/events/lib/promise.js
606
- function N(e, t, n = "error", r) {
606
+ function P(e, t, n = "error", r) {
607
607
  return new Promise((i, a) => {
608
- let o, { off: s, once: c } = ce(e), l = () => {
608
+ let o, { off: s, once: c } = se(e), l = () => {
609
609
  clearTimeout(o), s(t, d), s(n, u);
610
610
  };
611
611
  function u(e) {
@@ -615,7 +615,7 @@ function N(e, t, n = "error", r) {
615
615
  i(e), l();
616
616
  }
617
617
  if (c(t, d), n && c(n, u), r) {
618
- let e = new ie();
618
+ let e = new re();
619
619
  o = setTimeout(() => {
620
620
  l(), a(e);
621
621
  }, r);
@@ -624,14 +624,14 @@ function N(e, t, n = "error", r) {
624
624
  }
625
625
  //#endregion
626
626
  //#region node_modules/@xmpp/events/lib/Deferred.js
627
- function le() {
627
+ function ce() {
628
628
  this.promise = new Promise((e, t) => {
629
629
  this.resolve = e, this.reject = t;
630
630
  });
631
631
  }
632
632
  //#endregion
633
633
  //#region node_modules/@xmpp/events/lib/procedure.js
634
- function ue(e, t = null, n) {
634
+ function le(e, t = null, n) {
635
635
  return new Promise((r, i) => {
636
636
  function a(t) {
637
637
  e.removeListener("nonza", s), i(t);
@@ -651,28 +651,28 @@ function ue(e, t = null, n) {
651
651
  }
652
652
  //#endregion
653
653
  //#region node_modules/@xmpp/events/lib/listeners.js
654
- function de(e) {
654
+ function ue(e) {
655
655
  return {
656
656
  subscribe(t) {
657
- let { on: n } = ce(t);
657
+ let { on: n } = se(t);
658
658
  for (let [t, r] of Object.entries(e)) n(t, r);
659
659
  },
660
660
  unsubscribe(t) {
661
- let { off: n } = ce(t);
661
+ let { off: n } = se(t);
662
662
  for (let [t, r] of Object.entries(e)) n(t, r);
663
663
  }
664
664
  };
665
665
  }
666
666
  //#endregion
667
667
  //#region node_modules/@xmpp/xml/lib/XMLError.js
668
- var fe = class extends Error {
668
+ var F = class extends Error {
669
669
  constructor(...e) {
670
670
  super(...e), this.name = "XMLError";
671
671
  }
672
- }, pe = class extends M.EventEmitter {
672
+ }, de = class extends N.EventEmitter {
673
673
  constructor() {
674
674
  super();
675
- let e = new re.default();
675
+ let e = new ne.default();
676
676
  this.root = null, this.cursor = null, e.on("startElement", this.onStartElement.bind(this)), e.on("endElement", this.onEndElement.bind(this)), e.on("text", this.onText.bind(this)), this.parser = e;
677
677
  }
678
678
  onStartElement(e, t) {
@@ -682,7 +682,7 @@ var fe = class extends Error {
682
682
  onEndElement(e) {
683
683
  let { root: t, cursor: n } = this;
684
684
  if (e !== n.name) {
685
- this.emit("error", new fe(`${n.name} must be closed.`));
685
+ this.emit("error", new F(`${n.name} must be closed.`));
686
686
  return;
687
687
  }
688
688
  if (n === t) {
@@ -698,7 +698,7 @@ var fe = class extends Error {
698
698
  onText(e) {
699
699
  let { cursor: t } = this;
700
700
  if (!t) {
701
- this.emit("error", new fe(`${e} must be a child.`));
701
+ this.emit("error", new F(`${e} must be a child.`));
702
702
  return;
703
703
  }
704
704
  t.t(e);
@@ -710,37 +710,37 @@ var fe = class extends Error {
710
710
  e && this.parser.write(e);
711
711
  }
712
712
  };
713
- pe.XMLError = fe;
713
+ de.XMLError = F;
714
714
  //#endregion
715
715
  //#region node_modules/@xmpp/xml/index.js
716
- function P(...e) {
717
- return (0, ne.default)(...e);
716
+ function I(...e) {
717
+ return (0, M.default)(...e);
718
718
  }
719
- Object.assign(P, {
719
+ Object.assign(I, {
720
720
  Element: j.default,
721
- createElement: ne.default,
722
- Parser: pe,
721
+ createElement: M.default,
722
+ Parser: de,
723
723
  escapeXML: A.escapeXML,
724
724
  unescapeXML: A.unescapeXML,
725
725
  escapeXMLText: A.escapeXMLText,
726
726
  unescapeXMLText: A.unescapeXMLText,
727
- XMLError: fe,
728
- xml: P
727
+ XMLError: F,
728
+ xml: I
729
729
  });
730
730
  //#endregion
731
731
  //#region node_modules/@xmpp/jid/lib/escaping.js
732
- function me(e) {
732
+ function fe(e) {
733
733
  return !(!e || e.replaceAll(String.raw`\20`, "").replaceAll(String.raw`\22`, "").replaceAll(String.raw`\26`, "").replaceAll(String.raw`\27`, "").replaceAll(String.raw`\2f`, "").replaceAll(String.raw`\3a`, "").replaceAll(String.raw`\3c`, "").replaceAll(String.raw`\3e`, "").replaceAll(String.raw`\40`, "").replaceAll(String.raw`\5c`, "").search(/[ "&'/:<>@\\]/g) === -1);
734
734
  }
735
- function he(e) {
735
+ function pe(e) {
736
736
  return e === null ? null : e.replaceAll(/^\s+|\s+$/g, "").replaceAll("\\", String.raw`\5c`).replaceAll(" ", String.raw`\20`).replaceAll("\"", String.raw`\22`).replaceAll("&", String.raw`\26`).replaceAll("'", String.raw`\27`).replaceAll("/", String.raw`\2f`).replaceAll(":", String.raw`\3a`).replaceAll("<", String.raw`\3c`).replaceAll(">", String.raw`\3e`).replaceAll("@", String.raw`\40`);
737
737
  }
738
- function ge(e) {
738
+ function me(e) {
739
739
  return e === null ? null : e.replaceAll(String.raw`\20`, " ").replaceAll(String.raw`\22`, "\"").replaceAll(String.raw`\26`, "&").replaceAll(String.raw`\27`, "'").replaceAll(String.raw`\2f`, "/").replaceAll(String.raw`\3a`, ":").replaceAll(String.raw`\3c`, "<").replaceAll(String.raw`\3e`, ">").replaceAll(String.raw`\40`, "@").replaceAll(String.raw`\5c`, "\\");
740
740
  }
741
741
  //#endregion
742
742
  //#region node_modules/@xmpp/jid/lib/JID.js
743
- var F = class e {
743
+ var L = class e {
744
744
  constructor(e, t, n) {
745
745
  if (typeof t != "string" || !t) throw TypeError("Invalid domain.");
746
746
  this.setDomain(t), this.setLocal(typeof e == "string" ? e : ""), this.setResource(typeof n == "string" ? n : "");
@@ -759,11 +759,11 @@ var F = class e {
759
759
  return this._local === e._local && this._domain === e._domain && this._resource === e._resource;
760
760
  }
761
761
  setLocal(e, t) {
762
- return t ||= me(e), t && (e = he(e)), this._local = e && e.toLowerCase(), this;
762
+ return t ||= fe(e), t && (e = pe(e)), this._local = e && e.toLowerCase(), this;
763
763
  }
764
764
  getLocal(e = !1) {
765
765
  let t = null;
766
- return t = e ? ge(this._local) : this._local, t;
766
+ return t = e ? me(this._local) : this._local, t;
767
767
  }
768
768
  setDomain(e) {
769
769
  return this._domain = e.toLowerCase(), this;
@@ -778,37 +778,37 @@ var F = class e {
778
778
  return this._resource;
779
779
  }
780
780
  };
781
- Object.defineProperty(F.prototype, "local", {
782
- get: F.prototype.getLocal,
783
- set: F.prototype.setLocal
784
- }), Object.defineProperty(F.prototype, "domain", {
785
- get: F.prototype.getDomain,
786
- set: F.prototype.setDomain
787
- }), Object.defineProperty(F.prototype, "resource", {
788
- get: F.prototype.getResource,
789
- set: F.prototype.setResource
781
+ Object.defineProperty(L.prototype, "local", {
782
+ get: L.prototype.getLocal,
783
+ set: L.prototype.setLocal
784
+ }), Object.defineProperty(L.prototype, "domain", {
785
+ get: L.prototype.getDomain,
786
+ set: L.prototype.setDomain
787
+ }), Object.defineProperty(L.prototype, "resource", {
788
+ get: L.prototype.getResource,
789
+ set: L.prototype.setResource
790
790
  });
791
791
  //#endregion
792
792
  //#region node_modules/@xmpp/jid/lib/parse.js
793
- function _e(e) {
793
+ function he(e) {
794
794
  let t, n, r = e.indexOf("/");
795
795
  r !== -1 && (n = e.slice(r + 1), e = e.slice(0, r));
796
796
  let i = e.indexOf("@");
797
- return i !== -1 && (t = e.slice(0, i), e = e.slice(i + 1)), new F(t, e, n);
797
+ return i !== -1 && (t = e.slice(0, i), e = e.slice(i + 1)), new L(t, e, n);
798
798
  }
799
799
  //#endregion
800
800
  //#region node_modules/@xmpp/jid/index.js
801
- function ve(e, t) {
801
+ function ge(e, t) {
802
802
  return e.equals(t);
803
803
  }
804
- function ye(...e) {
805
- return !e[1] && !e[2] ? _e(...e) : new F(...e);
804
+ function _e(...e) {
805
+ return !e[1] && !e[2] ? he(...e) : new L(...e);
806
806
  }
807
- var I = ye.bind();
808
- I.jid = ye, I.JID = F, I.parse = _e, I.equal = ve, I.detectEscape = me, I.escapeLocal = he, I.unescapeLocal = ge;
807
+ var R = _e.bind();
808
+ R.jid = _e, R.JID = L, R.parse = he, R.equal = ge, R.detectEscape = fe, R.escapeLocal = pe, R.unescapeLocal = me;
809
809
  //#endregion
810
810
  //#region node_modules/@xmpp/error/index.js
811
- var L = class extends Error {
811
+ var ve = class extends Error {
812
812
  constructor(e, t, n) {
813
813
  super(e + (t ? ` - ${t}` : "")), this.name = "XMPPError", this.condition = e, this.text = t, this.application = n;
814
814
  }
@@ -818,14 +818,14 @@ var L = class extends Error {
818
818
  let o = new this(t.name, i ? i.text() : "", a);
819
819
  return o.element = e, o;
820
820
  }
821
- }, be = class extends L {
821
+ }, ye = class extends ve {
822
822
  constructor(...e) {
823
823
  super(...e), this.name = "StreamError";
824
824
  }
825
825
  };
826
826
  //#endregion
827
827
  //#region node_modules/@xmpp/connection/lib/util.js
828
- function xe(e) {
828
+ function be(e) {
829
829
  let { port: t, hostname: n, protocol: r } = new URL(e);
830
830
  return n === "[::1]" && (n = "::1"), {
831
831
  port: t,
@@ -833,19 +833,19 @@ function xe(e) {
833
833
  protocol: r
834
834
  };
835
835
  }
836
- function Se(e) {
837
- let { port: t, hostname: n } = xe(`http://${e}`);
836
+ function xe(e) {
837
+ let { port: t, hostname: n } = be(`http://${e}`);
838
838
  return {
839
839
  port: t,
840
840
  hostname: n
841
841
  };
842
842
  }
843
- function Ce(e) {
844
- return e.includes("://") ? xe(e) : Se(e);
843
+ function Se(e) {
844
+ return e.includes("://") ? be(e) : xe(e);
845
845
  }
846
846
  //#endregion
847
847
  //#region node_modules/@xmpp/connection/index.js
848
- var we = "urn:ietf:params:xml:ns:xmpp-streams", Te = "http://etherx.jabber.org/streams", R = class extends M.EventEmitter {
848
+ var Ce = "urn:ietf:params:xml:ns:xmpp-streams", we = "http://etherx.jabber.org/streams", Te = class extends N.EventEmitter {
849
849
  #e = null;
850
850
  #t = null;
851
851
  constructor(e = {}) {
@@ -856,7 +856,7 @@ var we = "urn:ietf:params:xml:ns:xmpp-streams", Te = "http://etherx.jabber.org/s
856
856
  }
857
857
  async _streamError(e, t) {
858
858
  try {
859
- await this.send(P("stream:error", {}, [P(e, { xmlns: we }, t)]));
859
+ await this.send(I("stream:error", {}, [I(e, { xmlns: Ce }, t)]));
860
860
  } catch {}
861
861
  return this.disconnect();
862
862
  }
@@ -880,7 +880,7 @@ var we = "urn:ietf:params:xml:ns:xmpp-streams", Te = "http://etherx.jabber.org/s
880
880
  });
881
881
  }
882
882
  _attachSocket(e) {
883
- this.socket = e, this.#e ??= de({
883
+ this.socket = e, this.#e ??= ue({
884
884
  data: this._onData.bind(this),
885
885
  close: this.#r.bind(this),
886
886
  connect: () => this._status("connect"),
@@ -891,19 +891,19 @@ var we = "urn:ietf:params:xml:ns:xmpp-streams", Te = "http://etherx.jabber.org/s
891
891
  this.socket && this.#e?.unsubscribe(this.socket), this.socket = null;
892
892
  }
893
893
  _onElement(e) {
894
- let t = e.is("error", Te);
894
+ let t = e.is("error", we);
895
895
  t && this._onStreamError(e), this.emit("element", e), this.emit(this.isStanza(e) ? "stanza" : "nonza", e), t && this.disconnect();
896
896
  }
897
897
  _onStreamError(e) {
898
- let t = be.fromElement(e);
898
+ let t = ye.fromElement(e);
899
899
  if (t.condition === "see-other-host") return this._onSeeOtherHost(t);
900
900
  this.emit("error", t);
901
901
  }
902
902
  async _onSeeOtherHost(e) {
903
- let { protocol: t } = Ce(this.options.service), n = e.element.getChildText("see-other-host"), { port: r } = Se(n), i;
903
+ let { protocol: t } = Se(this.options.service), n = e.element.getChildText("see-other-host"), { port: r } = xe(n), i;
904
904
  i = r ? `${t || "xmpp:"}//${n}` : (t ? `${t}//` : "") + n;
905
905
  try {
906
- await N(this, "disconnect");
906
+ await P(this, "disconnect");
907
907
  let { domain: e, lang: t } = this.options;
908
908
  await this.connect(i), await this.open({
909
909
  domain: e,
@@ -914,7 +914,7 @@ var we = "urn:ietf:params:xml:ns:xmpp-streams", Te = "http://etherx.jabber.org/s
914
914
  }
915
915
  }
916
916
  _attachParser(e) {
917
- this.parser = e, this.#t ??= de({
917
+ this.parser = e, this.#t ??= ue({
918
918
  element: this._onElement.bind(this),
919
919
  error: this.#n.bind(this),
920
920
  end: this.#i.bind(this),
@@ -925,7 +925,7 @@ var we = "urn:ietf:params:xml:ns:xmpp-streams", Te = "http://etherx.jabber.org/s
925
925
  this.parser && this.#t?.unsubscribe(this.parser), this.parser = null, this.root = null;
926
926
  }
927
927
  _jid(e) {
928
- return this.jid = I(e), this.jid;
928
+ return this.jid = R(e), this.jid;
929
929
  }
930
930
  _status(e, ...t) {
931
931
  this.status !== e && (this.status = e, this.emit("status", e, ...t), this.emit(e, ...t));
@@ -951,7 +951,7 @@ var we = "urn:ietf:params:xml:ns:xmpp-streams", Te = "http://etherx.jabber.org/s
951
951
  if (this.status !== "offline") throw Error("Connection is not offline");
952
952
  let { service: e, domain: t, lang: n } = this.options;
953
953
  await this.connect(e);
954
- let r = N(this, "online");
954
+ let r = P(this, "online");
955
955
  return await this.open({
956
956
  domain: t,
957
957
  lang: n
@@ -960,15 +960,15 @@ var we = "urn:ietf:params:xml:ns:xmpp-streams", Te = "http://etherx.jabber.org/s
960
960
  async connect(e) {
961
961
  this._status("connecting", e);
962
962
  let t = new this.Socket();
963
- return this._attachSocket(t), t.connect(this.socketParameters(e)), N(t, "connect");
963
+ return this._attachSocket(t), t.connect(this.socketParameters(e)), P(t, "connect");
964
964
  }
965
965
  async _closeSocket(e = this.timeout) {
966
- this._status("disconnecting"), this.socket.end(), await N(this.socket, "close", "error", e);
966
+ this._status("disconnecting"), this.socket.end(), await P(this.socket, "close", "error", e);
967
967
  }
968
968
  async open(e) {
969
969
  this._status("opening");
970
970
  let { domain: t, lang: n } = e, r = this.headerElement();
971
- return r.attrs.to = t, r.attrs["xml:lang"] = n, this.root = r, this._attachParser(new this.Parser()), await this.write(this.header(r)), N(this, "open", "error", this.timeout);
971
+ return r.attrs.to = t, r.attrs["xml:lang"] = n, this.root = r, this._attachParser(new this.Parser()), await this.write(this.header(r)), P(this, "open", "error", this.timeout);
972
972
  }
973
973
  async stop() {
974
974
  let e = await this.disconnect();
@@ -977,7 +977,7 @@ var we = "urn:ietf:params:xml:ns:xmpp-streams", Te = "http://etherx.jabber.org/s
977
977
  async _closeStream(e = this.timeout) {
978
978
  await this.#c("close");
979
979
  let t = this.footer(this.footerElement());
980
- return await this.write(t), this._status("closing"), N(this.parser, "end", "error", e);
980
+ return await this.write(t), this._status("closing"), P(this.parser, "end", "error", e);
981
981
  }
982
982
  async restart() {
983
983
  this._detachParser();
@@ -991,7 +991,7 @@ var we = "urn:ietf:params:xml:ns:xmpp-streams", Te = "http://etherx.jabber.org/s
991
991
  e.parent = this.root, await this.write(e.toString()), this.emit("send", e);
992
992
  }
993
993
  sendReceive(e, t = this.timeout) {
994
- return Promise.all([this.send(e), N(this, "element", "error", t)]).then(([, e]) => e);
994
+ return Promise.all([this.send(e), P(this, "element", "error", t)]).then(([, e]) => e);
995
995
  }
996
996
  async write(e) {
997
997
  if (this.status === "closing") throw Error("Connection is closing");
@@ -1010,7 +1010,7 @@ var we = "urn:ietf:params:xml:ns:xmpp-streams", Te = "http://etherx.jabber.org/s
1010
1010
  return e.toString();
1011
1011
  }
1012
1012
  headerElement() {
1013
- return new P.Element("", {
1013
+ return new I.Element("", {
1014
1014
  version: "1.0",
1015
1015
  xmlns: this.NS
1016
1016
  });
@@ -1045,10 +1045,10 @@ var we = "urn:ietf:params:xml:ns:xmpp-streams", Te = "http://etherx.jabber.org/s
1045
1045
  }));
1046
1046
  }
1047
1047
  };
1048
- R.prototype.NS = "", R.prototype.Socket = null, R.prototype.Parser = null;
1048
+ Te.prototype.NS = "", Te.prototype.Socket = null, Te.prototype.Parser = null;
1049
1049
  //#endregion
1050
1050
  //#region node_modules/@xmpp/client-core/lib/Client.js
1051
- var Ee = class extends R {
1051
+ var Ee = class extends Te {
1052
1052
  constructor(e) {
1053
1053
  super(e), this.transports = [];
1054
1054
  }
@@ -1092,7 +1092,7 @@ var Ee = class extends R {
1092
1092
  Ee.prototype.NS = "jabber:client";
1093
1093
  //#endregion
1094
1094
  //#region node_modules/@xmpp/reconnect/index.js
1095
- var De = class extends M.EventEmitter {
1095
+ var De = class extends N.EventEmitter {
1096
1096
  constructor(e) {
1097
1097
  super(), this.delay = 1e3, this.entity = e, this._timeout = null;
1098
1098
  }
@@ -1133,14 +1133,14 @@ function Oe({ entity: e }) {
1133
1133
  //#region node_modules/@xmpp/websocket/lib/Socket.js
1134
1134
  var ke = "ECONNERROR";
1135
1135
  function Ae(e) {
1136
- let t = xe(e);
1136
+ let t = be(e);
1137
1137
  return !!(t.protocol === "wss:" || [
1138
1138
  "localhost",
1139
1139
  "127.0.0.1",
1140
1140
  "::1"
1141
1141
  ].includes(t.hostname));
1142
1142
  }
1143
- var je = class extends M.EventEmitter {
1143
+ var je = class extends N.EventEmitter {
1144
1144
  #e = null;
1145
1145
  socket = null;
1146
1146
  url = null;
@@ -1149,7 +1149,7 @@ var je = class extends M.EventEmitter {
1149
1149
  this.url = e, this.secure = Ae(e), this._attachSocket(new WebSocket(e, ["xmpp"]));
1150
1150
  }
1151
1151
  _attachSocket(e) {
1152
- this.socket = e, this.#e ??= de({
1152
+ this.socket = e, this.#e ??= ue({
1153
1153
  open: () => this.emit("connect"),
1154
1154
  message: ({ data: e }) => this.emit("data", e),
1155
1155
  error: (e) => {
@@ -1179,7 +1179,7 @@ var je = class extends M.EventEmitter {
1179
1179
  }
1180
1180
  n();
1181
1181
  }
1182
- }, Me = class extends pe {
1182
+ }, Me = class extends de {
1183
1183
  onStartElement(e, t) {
1184
1184
  let n = new j.default(e, t), { cursor: r } = this;
1185
1185
  r && r.append(n), this.cursor = n;
@@ -1187,7 +1187,7 @@ var je = class extends M.EventEmitter {
1187
1187
  onEndElement(e) {
1188
1188
  let { cursor: t } = this;
1189
1189
  if (e !== t.name) {
1190
- this.emit("error", new fe(`${t.name} must be closed.`));
1190
+ this.emit("error", new F(`${t.name} must be closed.`));
1191
1191
  return;
1192
1192
  }
1193
1193
  if (t.parent) {
@@ -1196,7 +1196,7 @@ var je = class extends M.EventEmitter {
1196
1196
  }
1197
1197
  t.is("open", "urn:ietf:params:xml:ns:xmpp-framing") ? this.emit("start", t) : t.is("close", "urn:ietf:params:xml:ns:xmpp-framing") ? this.emit("end", t) : this.emit("element", t), this.cursor = null;
1198
1198
  }
1199
- }, Ne = "urn:ietf:params:xml:ns:xmpp-framing", Pe = class extends R {
1199
+ }, Ne = "urn:ietf:params:xml:ns:xmpp-framing", Pe = class extends Te {
1200
1200
  send(e, ...t) {
1201
1201
  return e.attrs.xmlns ??= this.NS, super.send(e, ...t);
1202
1202
  }
@@ -1204,7 +1204,7 @@ var je = class extends M.EventEmitter {
1204
1204
  for (let t of e) t.attrs.xmlns ??= this.NS, t.parent = this.root, this.socket.write(t.toString()), this.emit("send", t);
1205
1205
  }
1206
1206
  footerElement() {
1207
- return new P.Element("close", { xmlns: Ne });
1207
+ return new I.Element("close", { xmlns: Ne });
1208
1208
  }
1209
1209
  headerElement() {
1210
1210
  let e = super.headerElement();
@@ -1255,13 +1255,13 @@ var Ie = /* @__PURE__ */ y(((e, t) => {
1255
1255
  constructor(e, t) {
1256
1256
  super(e, t);
1257
1257
  let { jid: n } = e, { domain: r } = e.options ?? {}, i = t.attrs.to || n?.toString(), a = t.attrs.from || r;
1258
- i && (this.to = new I(i)), a && (this.from = new I(a), this.local = this.from.local, this.domain = this.from.domain, this.resource = this.from.resource);
1258
+ i && (this.to = new R(i)), a && (this.from = new R(a), this.local = this.from.local, this.domain = this.from.domain, this.resource = this.from.resource);
1259
1259
  }
1260
1260
  }, Ve = class extends ze {
1261
1261
  constructor(e, t) {
1262
1262
  super(e, t);
1263
1263
  let { jid: n } = e, { domain: r } = e.options ?? {}, i = t.attrs.from || n?.toString(), a = t.attrs.to || r;
1264
- i && (this.from = new I(i)), a && (this.to = new I(a), this.local = this.to.local, this.domain = this.to.domain, this.resource = this.to.resource);
1264
+ i && (this.from = new R(i)), a && (this.to = new R(a), this.local = this.to.local, this.domain = this.to.domain, this.resource = this.to.resource);
1265
1265
  }
1266
1266
  };
1267
1267
  //#endregion
@@ -1310,7 +1310,7 @@ function Ke() {
1310
1310
  }
1311
1311
  //#endregion
1312
1312
  //#region node_modules/@xmpp/middleware/lib/StanzaError.js
1313
- var qe = class extends L {
1313
+ var qe = class extends ve {
1314
1314
  constructor(e, t, n, r) {
1315
1315
  super(e, t, n), this.type = r, this.name = "StanzaError";
1316
1316
  }
@@ -1342,10 +1342,10 @@ var Ye = class {
1342
1342
  }
1343
1343
  async request(e, t = 3e4) {
1344
1344
  e.attrs.id || (e.attrs.id = Ke());
1345
- let n = new le();
1345
+ let n = new ce();
1346
1346
  this.handlers.set(e.attrs.id, n);
1347
1347
  try {
1348
- await this.entity.send(e), await oe(n.promise, t);
1348
+ await this.entity.send(e), await ae(n.promise, t);
1349
1349
  } catch (t) {
1350
1350
  throw this.handlers.delete(e.attrs.id), t;
1351
1351
  }
@@ -1353,7 +1353,7 @@ var Ye = class {
1353
1353
  }
1354
1354
  _childRequest(e, t, n, ...r) {
1355
1355
  let { name: i, attrs: { xmlns: a } } = t;
1356
- return this.request(P("iq", {
1356
+ return this.request(I("iq", {
1357
1357
  type: e,
1358
1358
  to: n
1359
1359
  }, t), ...r).then((e) => e.getChild(i, a));
@@ -1379,7 +1379,7 @@ function $e({ type: e }, t, n) {
1379
1379
  return !(e !== "get" && e !== "set" || t.length !== 1 || !n);
1380
1380
  }
1381
1381
  function et({ stanza: e }) {
1382
- return P("iq", {
1382
+ return I("iq", {
1383
1383
  to: e.attrs.from,
1384
1384
  from: e.attrs.to,
1385
1385
  id: e.attrs.id
@@ -1394,7 +1394,7 @@ function nt(e, t, n) {
1394
1394
  return r.attrs.type = "error", n && r.append(n), r.append(t), r;
1395
1395
  }
1396
1396
  function rt(e, t) {
1397
- return P("error", { type: e }, P(t, Ze));
1397
+ return I("error", { type: e }, I(t, Ze));
1398
1398
  }
1399
1399
  function it(e) {
1400
1400
  return async function(t, n) {
@@ -1408,7 +1408,7 @@ function it(e) {
1408
1408
  } catch (t) {
1409
1409
  e.emit("error", t), o = rt("cancel", "internal-server-error");
1410
1410
  }
1411
- return o ||= rt("cancel", "service-unavailable"), o instanceof P.Element && o.is("error") ? nt(t, o, a) : tt(t, o instanceof P.Element ? o : void 0);
1411
+ return o ||= rt("cancel", "service-unavailable"), o instanceof I.Element && o.is("error") ? nt(t, o, a) : tt(t, o instanceof I.Element ? o : void 0);
1412
1412
  };
1413
1413
  }
1414
1414
  function at(e, t, n, r) {
@@ -1532,7 +1532,7 @@ function ft(e, t = {}) {
1532
1532
  //#endregion
1533
1533
  //#region node_modules/@xmpp/xml/lib/parse.js
1534
1534
  function pt(e) {
1535
- let t = new pe(), n = null, r = null;
1535
+ let t = new de(), n = null, r = null;
1536
1536
  if (t.on("start", (e) => {
1537
1537
  n = e;
1538
1538
  }), t.on("element", (e) => {
@@ -1594,7 +1594,7 @@ async function bt(e, t) {
1594
1594
  e._status("connecting", n);
1595
1595
  let i = r.prototype.socketParameters(n), a = new r.prototype.Socket();
1596
1596
  try {
1597
- a.connect(i), await N(a, "connect");
1597
+ a.connect(i), await P(a, "connect");
1598
1598
  } catch {
1599
1599
  return bt(e, t);
1600
1600
  }
@@ -1623,7 +1623,7 @@ function Ct(e) {
1623
1623
  }
1624
1624
  //#endregion
1625
1625
  //#region node_modules/@xmpp/sasl/lib/SASLError.js
1626
- var wt = class extends L {
1626
+ var wt = class extends ve {
1627
1627
  constructor(...e) {
1628
1628
  super(...e), this.name = "SASLError";
1629
1629
  }
@@ -1645,7 +1645,7 @@ async function Dt({ saslFactory: e, entity: t, mechanism: n, credentials: r }) {
1645
1645
  serviceName: a,
1646
1646
  ...r
1647
1647
  };
1648
- await ue(t, i.clientFirst && P("auth", {
1648
+ await le(t, i.clientFirst && I("auth", {
1649
1649
  xmlns: Tt,
1650
1650
  mechanism: i.name
1651
1651
  }, St(await i.response(o))), async (e, n) => {
@@ -1653,7 +1653,7 @@ async function Dt({ saslFactory: e, entity: t, mechanism: n, credentials: r }) {
1653
1653
  if (e.name === "challenge") {
1654
1654
  await i.challenge(Ct(e.text()));
1655
1655
  let n = await i.response(o);
1656
- await t.send(P("response", {
1656
+ await t.send(I("response", {
1657
1657
  xmlns: Tt,
1658
1658
  mechanism: i.name
1659
1659
  }, typeof n == "string" ? St(n) : ""));
@@ -1695,11 +1695,11 @@ async function At({ saslFactory: e, entity: t, mechanism: n, credentials: r, use
1695
1695
  serviceName: c,
1696
1696
  ...r
1697
1697
  };
1698
- await ue(t, P("authenticate", {
1698
+ await le(t, I("authenticate", {
1699
1699
  xmlns: kt,
1700
1700
  mechanism: s.name
1701
1701
  }, [
1702
- s.clientFirst && P("initial-response", {}, St(await s.response(l))),
1702
+ s.clientFirst && I("initial-response", {}, St(await s.response(l))),
1703
1703
  i,
1704
1704
  ...a
1705
1705
  ]), async (e, n) => {
@@ -1707,7 +1707,7 @@ async function At({ saslFactory: e, entity: t, mechanism: n, credentials: r, use
1707
1707
  if (e.name === "challenge") {
1708
1708
  await s.challenge(Ct(e.text()));
1709
1709
  let n = await s.response(l);
1710
- await t.send(P("response", {
1710
+ await t.send(I("response", {
1711
1711
  xmlns: kt,
1712
1712
  mechanism: s.name
1713
1713
  }, typeof n == "string" ? St(n) : ""));
@@ -1775,7 +1775,7 @@ async function Mt({ element: e, features: t }) {
1775
1775
  //#region node_modules/@xmpp/resource-binding/index.js
1776
1776
  var Nt = "urn:ietf:params:xml:ns:xmpp-bind";
1777
1777
  function Pt(e) {
1778
- return P("bind", { xmlns: Nt }, e && P("resource", {}, e));
1778
+ return I("bind", { xmlns: Nt }, e && I("resource", {}, e));
1779
1779
  }
1780
1780
  async function Ft(e, t, n) {
1781
1781
  let r = (await t.set(Pt(n))).getChildText("jid");
@@ -1832,36 +1832,36 @@ function Vt({ streamFeatures: e, sm: t, entity: n, resumed: r, failed: i, enable
1832
1832
  });
1833
1833
  }
1834
1834
  function Ht(e, t) {
1835
- return ue(e, Wt({ sm: t }), (e, t) => {
1835
+ return le(e, Wt({ sm: t }), (e, t) => {
1836
1836
  if (e.is("enabled", "urn:xmpp:sm:3")) return t(e);
1837
- if (e.is("failed", "urn:xmpp:sm:3")) throw L.fromElement(e);
1837
+ if (e.is("failed", "urn:xmpp:sm:3")) throw ve.fromElement(e);
1838
1838
  });
1839
1839
  }
1840
1840
  async function Ut(e, t) {
1841
- return ue(e, Gt({ sm: t }), (e, t) => {
1841
+ return le(e, Gt({ sm: t }), (e, t) => {
1842
1842
  if (e.is("resumed", "urn:xmpp:sm:3")) return t(e);
1843
- if (e.is("failed", "urn:xmpp:sm:3")) throw L.fromElement(e);
1843
+ if (e.is("failed", "urn:xmpp:sm:3")) throw ve.fromElement(e);
1844
1844
  });
1845
1845
  }
1846
1846
  //#endregion
1847
1847
  //#region node_modules/@xmpp/stream-management/index.js
1848
1848
  var B = "urn:xmpp:sm:3";
1849
1849
  function Wt({ sm: e }) {
1850
- return P("enable", {
1850
+ return I("enable", {
1851
1851
  xmlns: B,
1852
1852
  max: e.preferredMaximum,
1853
1853
  resume: "true"
1854
1854
  });
1855
1855
  }
1856
1856
  function Gt({ sm: e }) {
1857
- return P("resume", {
1857
+ return I("resume", {
1858
1858
  xmlns: B,
1859
1859
  h: e.inbound,
1860
1860
  previd: e.id
1861
1861
  });
1862
1862
  }
1863
1863
  function Kt({ streamFeatures: e, entity: t, middleware: n, bind2: r, sasl2: i }) {
1864
- let a = null, o = null, s = null, c = new M.EventEmitter();
1864
+ let a = null, o = null, s = null, c = new N.EventEmitter();
1865
1865
  Object.assign(c, {
1866
1866
  preferredMaximum: null,
1867
1867
  enabled: !1,
@@ -1877,7 +1877,7 @@ function Kt({ streamFeatures: e, entity: t, middleware: n, bind2: r, sasl2: i })
1877
1877
  });
1878
1878
  async function l() {
1879
1879
  try {
1880
- await t.send(P("a", {
1880
+ await t.send(I("a", {
1881
1881
  xmlns: B,
1882
1882
  h: c.inbound
1883
1883
  }));
@@ -1940,7 +1940,7 @@ function Kt({ streamFeatures: e, entity: t, middleware: n, bind2: r, sasl2: i })
1940
1940
  function g() {
1941
1941
  clearTimeout(o), clearTimeout(s), c.enabled && (c.timeout && !a && (a = setTimeout(() => {
1942
1942
  clearTimeout(o), t.disconnect().catch(() => {});
1943
- }, c.timeout)), t.send(P("r", { xmlns: B })).catch(() => {}), h());
1943
+ }, c.timeout)), t.send(I("r", { xmlns: B })).catch(() => {}), h());
1944
1944
  }
1945
1945
  return n.filter((e, t) => {
1946
1946
  let { stanza: n } = e;
@@ -1963,7 +1963,7 @@ function Kt({ streamFeatures: e, entity: t, middleware: n, bind2: r, sasl2: i })
1963
1963
  }
1964
1964
  function qt({ entity: e, item: t }) {
1965
1965
  let { stanza: n, stamp: r } = t;
1966
- return n.name === "message" && !n.getChild("delay", "urn:xmpp:delay") && n.append(P("delay", {
1966
+ return n.name === "message" && !n.getChild("delay", "urn:xmpp:delay") && n.append(I("delay", {
1967
1967
  xmlns: "urn:xmpp:delay",
1968
1968
  from: e.jid.toString(),
1969
1969
  stamp: r
@@ -1981,7 +1981,7 @@ function Yt({ sasl2: e, entity: t }, n) {
1981
1981
  element: e,
1982
1982
  features: r
1983
1983
  });
1984
- return P("bind", { xmlns: "urn:xmpp:bind:0" }, n && P("tag", null, n), ...t);
1984
+ return I("bind", { xmlns: "urn:xmpp:bind:0" }, n && I("tag", null, n), ...t);
1985
1985
  }, (e) => {
1986
1986
  if (e.is("bound")) {
1987
1987
  t._ready(!1);
@@ -2034,7 +2034,7 @@ var Zt = /* @__PURE__ */ y(((e, t) => {
2034
2034
  });
2035
2035
  })))(), 1), V = "urn:xmpp:fast:0";
2036
2036
  function $t({ sasl2: e, entity: t }) {
2037
- let n = new Qt.default(), r, i = new M.EventEmitter();
2037
+ let n = new Qt.default(), r, i = new N.EventEmitter();
2038
2038
  Object.assign(i, {
2039
2039
  mechanism: null,
2040
2040
  mechanisms: [],
@@ -2081,7 +2081,7 @@ function $t({ sasl2: e, entity: t }) {
2081
2081
  ...r,
2082
2082
  password: c.token
2083
2083
  },
2084
- streamFeatures: [...o, P("fast", { xmlns: V })],
2084
+ streamFeatures: [...o, I("fast", { xmlns: V })],
2085
2085
  entity: t,
2086
2086
  userAgent: n,
2087
2087
  features: s
@@ -2095,7 +2095,7 @@ function $t({ sasl2: e, entity: t }) {
2095
2095
  }
2096
2096
  });
2097
2097
  function a(e) {
2098
- e.push(P("request-token", {
2098
+ e.push(I("request-token", {
2099
2099
  xmlns: V,
2100
2100
  mechanism: i.mechanism
2101
2101
  }));
@@ -2221,7 +2221,7 @@ function mn(e = {}) {
2221
2221
  let { resource: t, credentials: n, username: r, password: i, userAgent: a, ...o } = e, { domain: s, service: c } = o;
2222
2222
  !s && c && (o.domain = pn(c));
2223
2223
  let l = new Ee(o);
2224
- r && o.domain && (l.jid = I(r, o.domain));
2224
+ r && o.domain && (l.jid = R(r, o.domain));
2225
2225
  let u = Oe({ entity: l }), d = Fe({ entity: l }), f = hn(z.default, { entity: l }), p = hn(z.default, { entity: l }), m = We({ entity: l }), h = Ge({ middleware: m }), g = Xe({
2226
2226
  middleware: m,
2227
2227
  entity: l
@@ -2233,7 +2233,7 @@ function mn(e = {}) {
2233
2233
  plain: rn,
2234
2234
  anonymous: sn
2235
2235
  }).map(([e, t]) => ({ [e]: t(y) }));
2236
- a ??= P("user-agent", { id: globalThis.crypto.randomUUID() });
2236
+ a ??= I("user-agent", { id: globalThis.crypto.randomUUID() });
2237
2237
  let x = hn(z.default, { streamFeatures: h }), S = jt({
2238
2238
  streamFeatures: h,
2239
2239
  saslFactory: y
@@ -2256,13 +2256,13 @@ function mn(e = {}) {
2256
2256
  }, dn(n ?? {
2257
2257
  username: r,
2258
2258
  password: i
2259
- }, a)), E = Kt({
2259
+ }, a)), ee = Kt({
2260
2260
  streamFeatures: h,
2261
2261
  entity: l,
2262
2262
  middleware: m,
2263
2263
  bind2: w,
2264
2264
  sasl2: S
2265
- }), D = Lt({
2265
+ }), E = Lt({
2266
2266
  iqCaller: g,
2267
2267
  streamFeatures: h
2268
2268
  }, t);
@@ -2281,8 +2281,8 @@ function mn(e = {}) {
2281
2281
  saslFactory: y,
2282
2282
  sasl2: S,
2283
2283
  sasl: T,
2284
- resourceBinding: D,
2285
- streamManagement: E,
2284
+ resourceBinding: E,
2285
+ streamManagement: ee,
2286
2286
  mechanisms: b,
2287
2287
  bind2: w,
2288
2288
  fast: C
@@ -2320,7 +2320,9 @@ var U = {
2320
2320
  conference: "jabber:x:conference",
2321
2321
  vcard: "vcard-temp",
2322
2322
  ping: "urn:xmpp:ping",
2323
- reactions: "urn:xmpp:reactions:0"
2323
+ reactions: "urn:xmpp:reactions:0",
2324
+ reply: "urn:xmpp:reply:0",
2325
+ fallback: "urn:xmpp:fallback:0"
2324
2326
  }, gn = 3e4, _n = class {
2325
2327
  xmpp;
2326
2328
  me;
@@ -2349,7 +2351,7 @@ var U = {
2349
2351
  this.stopped || this.unauthorized || ((e === "connecting" || e === "opening" || e === "connect") && this.h.status("connecting"), (e === "disconnect" || e === "close") && (this.connected = !1, window.clearInterval(this.pingTimer), this.forgetPresence(), this.h.status("offline")), e === "disconnect" && this.scheduleRetry());
2350
2352
  }), this.xmpp.on("error", (e) => {
2351
2353
  if (!this.stopped) {
2352
- if (vn(e)) {
2354
+ if (yn(e)) {
2353
2355
  this.unauthorized = !0, window.clearTimeout(this.retryTimer), this.h.status("unauthorized", e.message);
2354
2356
  return;
2355
2357
  }
@@ -2362,10 +2364,10 @@ var U = {
2362
2364
  }
2363
2365
  this.attempt = 0, this.connected = !0;
2364
2366
  try {
2365
- await this.xmpp.send(P("iq", {
2367
+ await this.xmpp.send(I("iq", {
2366
2368
  type: "set",
2367
2369
  id: "carbons"
2368
- }, P("enable", { xmlns: U.carbons }))), await this.xmpp.send(P("presence"));
2370
+ }, I("enable", { xmlns: U.carbons }))), await this.xmpp.send(I("presence"));
2369
2371
  } catch {
2370
2372
  return;
2371
2373
  }
@@ -2391,10 +2393,10 @@ var U = {
2391
2393
  document.visibilityState === "visible" && this.wake();
2392
2394
  };
2393
2395
  ping() {
2394
- this.connected && this.xmpp.iqCaller.request(P("iq", {
2396
+ this.connected && this.xmpp.iqCaller.request(I("iq", {
2395
2397
  type: "get",
2396
2398
  to: this.domain
2397
- }, P("ping", { xmlns: U.ping })), 1e4).catch((e) => {
2399
+ }, I("ping", { xmlns: U.ping })), 1e4).catch((e) => {
2398
2400
  !this.stopped && this.connected && e.name !== "StanzaError" && this.xmpp.disconnect().catch(() => {});
2399
2401
  });
2400
2402
  }
@@ -2408,7 +2410,7 @@ var U = {
2408
2410
  let e = this.xmpp;
2409
2411
  (e.status === "offline" ? this.xmpp.start() : e.connect(e.options.service).then(() => e.open({ domain: e.options.domain }))).catch((e) => {
2410
2412
  if (!this.stopped) {
2411
- if (vn(e)) {
2413
+ if (yn(e)) {
2412
2414
  this.unauthorized = !0, this.h.status("unauthorized", e.message);
2413
2415
  return;
2414
2416
  }
@@ -2424,22 +2426,32 @@ var U = {
2424
2426
  isGroup(e) {
2425
2427
  return e.endsWith("@" + this.mucHost);
2426
2428
  }
2427
- async send(e, t, n) {
2428
- let r = crypto.randomUUID(), i = [
2429
- P("body", {}, t),
2430
- P("origin-id", {
2429
+ async send(e, t, n, r) {
2430
+ let i = crypto.randomUUID(), a = this.isGroup(e), o = r ? `> ${r.quote ?? ""}\n` : "", s = [
2431
+ I("body", {}, o + t),
2432
+ I("origin-id", {
2431
2433
  xmlns: U.sid,
2432
- id: r
2434
+ id: i
2433
2435
  }),
2434
- P("store", { xmlns: U.hints })
2436
+ I("store", { xmlns: U.hints })
2435
2437
  ];
2436
- return n && i.push(P("x", { xmlns: U.oob }, P("url", {}, n))), this.isGroup(e) ? (await this.xmpp.send(P("message", {
2438
+ return n && s.push(I("x", { xmlns: U.oob }, I("url", {}, n))), r && (s.push(I("reply", {
2439
+ xmlns: U.reply,
2440
+ id: r.id,
2441
+ to: a ? `${e}/${r.author}` : `${r.author}@${this.domain}`
2442
+ })), s.push(I("fallback", {
2443
+ xmlns: U.fallback,
2444
+ for: U.reply
2445
+ }, I("body", {
2446
+ start: "0",
2447
+ end: String([...o].length)
2448
+ })))), a ? (await this.xmpp.send(I("message", {
2437
2449
  to: e,
2438
2450
  type: "groupchat",
2439
- id: r
2440
- }, ...i)), {
2441
- id: r,
2442
- oid: r,
2451
+ id: i
2452
+ }, ...s)), {
2453
+ id: i,
2454
+ oid: i,
2443
2455
  from: e,
2444
2456
  to: this.cfg.username,
2445
2457
  body: t,
@@ -2447,51 +2459,53 @@ var U = {
2447
2459
  mine: !0,
2448
2460
  oob: n,
2449
2461
  room: e,
2450
- nick: this.cfg.username
2451
- }) : (i.push(P("active", { xmlns: U.chatstates })), await this.xmpp.send(P("message", {
2462
+ nick: this.cfg.username,
2463
+ reply: r
2464
+ }) : (s.push(I("active", { xmlns: U.chatstates })), await this.xmpp.send(I("message", {
2452
2465
  to: `${e}@${this.domain}`,
2453
2466
  type: "chat",
2454
- id: r
2455
- }, ...i)), {
2456
- id: r,
2457
- oid: r,
2467
+ id: i
2468
+ }, ...s)), {
2469
+ id: i,
2470
+ oid: i,
2458
2471
  from: this.cfg.username,
2459
2472
  to: e,
2460
2473
  body: t,
2461
2474
  ts: Date.now(),
2462
2475
  mine: !0,
2463
- oob: n
2476
+ oob: n,
2477
+ reply: r
2464
2478
  });
2465
2479
  }
2466
2480
  async react(e, t, n) {
2467
- let r = this.isGroup(e), i = P("reactions", {
2481
+ let r = this.isGroup(e), i = I("reactions", {
2468
2482
  xmlns: U.reactions,
2469
2483
  id: t
2470
- }, ...n.map((e) => P("reaction", {}, e)));
2471
- await this.xmpp.send(P("message", {
2484
+ }, ...n.map((e) => I("reaction", {}, e)));
2485
+ await this.xmpp.send(I("message", {
2472
2486
  to: r ? e : `${e}@${this.domain}`,
2473
2487
  type: r ? "groupchat" : "chat",
2474
2488
  id: crypto.randomUUID()
2475
- }, i, P("store", { xmlns: U.hints })));
2489
+ }, i, I("store", { xmlns: U.hints })));
2476
2490
  }
2477
2491
  async announce(e) {
2478
- for (let t of e) await this.xmpp.send(P("presence", { to: `${t}@${this.domain}` }, P("x", { xmlns: U.hello }))).catch(() => {});
2492
+ for (let t of e) await this.xmpp.send(I("presence", { to: `${t}@${this.domain}` }, I("x", { xmlns: U.hello }))).catch(() => {});
2479
2493
  }
2480
2494
  typing(e, t) {
2481
- return this.isGroup(e) ? Promise.resolve() : this.xmpp.send(P("message", {
2495
+ return this.isGroup(e) ? Promise.resolve() : this.xmpp.send(I("message", {
2482
2496
  to: `${e}@${this.domain}`,
2483
2497
  type: "chat"
2484
- }, P(t ? "composing" : "paused", { xmlns: U.chatstates })));
2498
+ }, I(t ? "composing" : "paused", { xmlns: U.chatstates })));
2485
2499
  }
2486
2500
  enablePush(e, t) {
2487
- return this.xmpp.iqCaller.request(P("iq", { type: "set" }, P("enable", {
2501
+ return this.xmpp.iqCaller.request(I("iq", { type: "set" }, I("enable", {
2488
2502
  xmlns: U.push,
2489
2503
  jid: e,
2490
2504
  node: t
2491
2505
  })), 15e3);
2492
2506
  }
2493
2507
  disablePush(e, t) {
2494
- return this.xmpp.iqCaller.request(P("iq", { type: "set" }, P("disable", {
2508
+ return this.xmpp.iqCaller.request(I("iq", { type: "set" }, I("disable", {
2495
2509
  xmlns: U.push,
2496
2510
  jid: e,
2497
2511
  node: t
@@ -2506,20 +2520,20 @@ var U = {
2506
2520
  async mam(e, t, n) {
2507
2521
  let r = crypto.randomUUID();
2508
2522
  this.mamQueries.set(r, []), this.mamReactions.set(r, []);
2509
- let i = P("set", { xmlns: U.rsm }, P("max", {}, String(n)), P("before", {}, t ?? "")), a = [P("field", {
2523
+ let i = I("set", { xmlns: U.rsm }, I("max", {}, String(n)), I("before", {}, t ?? "")), a = [I("field", {
2510
2524
  var: "FORM_TYPE",
2511
2525
  type: "hidden"
2512
- }, P("value", {}, U.mam))];
2513
- e && a.push(P("field", { var: "with" }, P("value", {}, this.isGroup(e) ? e : `${e}@${this.domain}`)));
2514
- let o = P("x", {
2526
+ }, I("value", {}, U.mam))];
2527
+ e && a.push(I("field", { var: "with" }, I("value", {}, this.isGroup(e) ? e : `${e}@${this.domain}`)));
2528
+ let o = I("x", {
2515
2529
  xmlns: U.data,
2516
2530
  type: "submit"
2517
2531
  }, ...a), s, c, l;
2518
2532
  try {
2519
- s = await this.xmpp.iqCaller.request(P("iq", {
2533
+ s = await this.xmpp.iqCaller.request(I("iq", {
2520
2534
  type: "set",
2521
2535
  id: r
2522
- }, P("query", {
2536
+ }, I("query", {
2523
2537
  xmlns: U.mam,
2524
2538
  queryid: r
2525
2539
  }, o, i)), 3e4);
@@ -2536,42 +2550,42 @@ var U = {
2536
2550
  }
2537
2551
  async createGroup(e, t, n) {
2538
2552
  let r = `g-${Math.random().toString(36).slice(2, 10)}@${this.mucHost}`, i = this.cfg.username, a = this.waitFor((e) => e.is("presence") && W(e.attrs.from) === r, 1e4);
2539
- await this.xmpp.send(P("presence", { to: `${r}/${i}` }, P("x", { xmlns: U.muc }))), await a;
2540
- let o = (e, t) => P("field", { var: e }, P("value", {}, t));
2541
- await this.xmpp.iqCaller.request(P("iq", {
2553
+ await this.xmpp.send(I("presence", { to: `${r}/${i}` }, I("x", { xmlns: U.muc }))), await a;
2554
+ let o = (e, t) => I("field", { var: e }, I("value", {}, t));
2555
+ await this.xmpp.iqCaller.request(I("iq", {
2542
2556
  type: "set",
2543
2557
  to: r
2544
- }, P("query", { xmlns: U.mucOwner }, P("x", {
2558
+ }, I("query", { xmlns: U.mucOwner }, I("x", {
2545
2559
  xmlns: U.data,
2546
2560
  type: "submit"
2547
2561
  }, o("FORM_TYPE", "http://jabber.org/protocol/muc#roomconfig"), o("muc#roomconfig_roomname", e), o("muc#roomconfig_persistentroom", "1"), o("muc#roomconfig_membersonly", "1"), o("muc#roomconfig_publicroom", "0"), o("muc#roomconfig_whois", "anyone"), o("allow_subscription", "1"), o("mam", "1")))), 15e3), n && await this.setGroupAvatar(r, n).catch(() => {});
2548
2562
  let s = t.filter((e) => e && e !== this.cfg.username);
2549
- await this.xmpp.iqCaller.request(P("iq", {
2563
+ await this.xmpp.iqCaller.request(I("iq", {
2550
2564
  type: "set",
2551
2565
  to: r
2552
- }, P("query", { xmlns: U.mucAdmin }, ...s.map((e) => P("item", {
2566
+ }, I("query", { xmlns: U.mucAdmin }, ...s.map((e) => I("item", {
2553
2567
  affiliation: "member",
2554
2568
  jid: `${e}@${this.domain}`
2555
2569
  })))), 15e3);
2556
- for (let e of s) await this.xmpp.iqCaller.request(P("iq", {
2570
+ for (let e of s) await this.xmpp.iqCaller.request(I("iq", {
2557
2571
  type: "set",
2558
2572
  to: r
2559
- }, P("subscribe", {
2573
+ }, I("subscribe", {
2560
2574
  xmlns: U.mucsub,
2561
2575
  jid: `${e}@${this.domain}`,
2562
2576
  nick: e
2563
- }, P("event", { node: U.mucsubMessages }), P("event", { node: U.mucsubConfig }))), 15e3).catch(() => {});
2564
- await this.xmpp.iqCaller.request(P("iq", {
2577
+ }, I("event", { node: U.mucsubMessages }), I("event", { node: U.mucsubConfig }))), 15e3).catch(() => {});
2578
+ await this.xmpp.iqCaller.request(I("iq", {
2565
2579
  type: "set",
2566
2580
  to: r
2567
- }, P("subscribe", {
2581
+ }, I("subscribe", {
2568
2582
  xmlns: U.mucsub,
2569
2583
  nick: i
2570
- }, P("event", { node: U.mucsubMessages }), P("event", { node: U.mucsubConfig }))), 15e3), await this.xmpp.send(P("presence", {
2584
+ }, I("event", { node: U.mucsubMessages }), I("event", { node: U.mucsubConfig }))), 15e3), await this.xmpp.send(I("presence", {
2571
2585
  to: `${r}/${i}`,
2572
2586
  type: "unavailable"
2573
2587
  }));
2574
- for (let t of s) await this.xmpp.send(P("message", { to: `${t}@${this.domain}` }, P("x", {
2588
+ for (let t of s) await this.xmpp.send(I("message", { to: `${t}@${this.domain}` }, I("x", {
2575
2589
  xmlns: U.conference,
2576
2590
  jid: r,
2577
2591
  reason: e
@@ -2579,58 +2593,58 @@ var U = {
2579
2593
  return r;
2580
2594
  }
2581
2595
  async leaveGroup(e, t) {
2582
- t ? await this.xmpp.iqCaller.request(P("iq", {
2596
+ t ? await this.xmpp.iqCaller.request(I("iq", {
2583
2597
  type: "set",
2584
2598
  to: e
2585
- }, P("query", { xmlns: U.mucOwner }, P("destroy", {}))), 1e4) : await this.xmpp.iqCaller.request(P("iq", {
2599
+ }, I("query", { xmlns: U.mucOwner }, I("destroy", {}))), 1e4) : await this.xmpp.iqCaller.request(I("iq", {
2586
2600
  type: "set",
2587
2601
  to: e
2588
- }, P("unsubscribe", { xmlns: U.mucsub })), 1e4);
2602
+ }, I("unsubscribe", { xmlns: U.mucsub })), 1e4);
2589
2603
  }
2590
2604
  async setGroupAvatar(e, t) {
2591
2605
  let n = /^data:(image\/[a-z+]+);base64,(.+)$/i.exec(t);
2592
- n && await this.xmpp.iqCaller.request(P("iq", {
2606
+ n && await this.xmpp.iqCaller.request(I("iq", {
2593
2607
  type: "set",
2594
2608
  to: e
2595
- }, P("vCard", { xmlns: U.vcard }, P("PHOTO", {}, P("TYPE", {}, n[1]), P("BINVAL", {}, n[2])))), 15e3);
2609
+ }, I("vCard", { xmlns: U.vcard }, I("PHOTO", {}, I("TYPE", {}, n[1]), I("BINVAL", {}, n[2])))), 15e3);
2596
2610
  }
2597
2611
  async groupAvatar(e) {
2598
- let t = (await this.xmpp.iqCaller.request(P("iq", {
2612
+ let t = (await this.xmpp.iqCaller.request(I("iq", {
2599
2613
  type: "get",
2600
2614
  to: e
2601
- }, P("vCard", { xmlns: U.vcard })), 1e4)).getChild("vCard", U.vcard)?.getChild("PHOTO"), n = t?.getChildText("BINVAL");
2615
+ }, I("vCard", { xmlns: U.vcard })), 1e4)).getChild("vCard", U.vcard)?.getChild("PHOTO"), n = t?.getChildText("BINVAL");
2602
2616
  return n ? `data:${t?.getChildText("TYPE") || "image/jpeg"};base64,${n.replace(/\s+/g, "")}` : void 0;
2603
2617
  }
2604
2618
  async listGroups() {
2605
- let e = ((await this.xmpp.iqCaller.request(P("iq", {
2619
+ let e = ((await this.xmpp.iqCaller.request(I("iq", {
2606
2620
  type: "get",
2607
2621
  to: this.mucHost
2608
- }, P("subscriptions", { xmlns: U.mucsub })), 15e3)).getChild("subscriptions", U.mucsub)?.getChildren("subscription") ?? []).map((e) => e.attrs.jid);
2622
+ }, I("subscriptions", { xmlns: U.mucsub })), 15e3)).getChild("subscriptions", U.mucsub)?.getChildren("subscription") ?? []).map((e) => e.attrs.jid);
2609
2623
  return Promise.all(e.map((e) => this.groupInfo(e)));
2610
2624
  }
2611
2625
  async subscribed(e) {
2612
- return ((await this.xmpp.iqCaller.request(P("iq", {
2626
+ return ((await this.xmpp.iqCaller.request(I("iq", {
2613
2627
  type: "get",
2614
2628
  to: this.mucHost
2615
- }, P("subscriptions", { xmlns: U.mucsub })), 15e3)).getChild("subscriptions", U.mucsub)?.getChildren("subscription") ?? []).some((t) => W(t.attrs.jid) === e);
2629
+ }, I("subscriptions", { xmlns: U.mucsub })), 15e3)).getChild("subscriptions", U.mucsub)?.getChildren("subscription") ?? []).some((t) => W(t.attrs.jid) === e);
2616
2630
  }
2617
2631
  async groupInfo(e) {
2618
2632
  let t = e.split("@")[0], n = [], r = !1;
2619
2633
  try {
2620
- t = (await this.xmpp.iqCaller.request(P("iq", {
2634
+ t = (await this.xmpp.iqCaller.request(I("iq", {
2621
2635
  type: "get",
2622
2636
  to: e
2623
- }, P("query", { xmlns: U.discoInfo })), 1e4)).getChild("query", U.discoInfo)?.getChild("identity")?.attrs.name || t;
2637
+ }, I("query", { xmlns: U.discoInfo })), 1e4)).getChild("query", U.discoInfo)?.getChild("identity")?.attrs.name || t;
2624
2638
  } catch {}
2625
2639
  try {
2626
- n = ((await this.xmpp.iqCaller.request(P("iq", {
2640
+ n = ((await this.xmpp.iqCaller.request(I("iq", {
2627
2641
  type: "get",
2628
2642
  to: e
2629
- }, P("query", { xmlns: U.mucAdmin }, P("item", { affiliation: "member" }))), 1e4)).getChild("query", U.mucAdmin)?.getChildren("item") ?? []).map((e) => G(e.attrs.jid));
2630
- let t = await this.xmpp.iqCaller.request(P("iq", {
2643
+ }, I("query", { xmlns: U.mucAdmin }, I("item", { affiliation: "member" }))), 1e4)).getChild("query", U.mucAdmin)?.getChildren("item") ?? []).map((e) => G(e.attrs.jid));
2644
+ let t = await this.xmpp.iqCaller.request(I("iq", {
2631
2645
  type: "get",
2632
2646
  to: e
2633
- }, P("query", { xmlns: U.mucAdmin }, P("item", { affiliation: "owner" }))), 1e4);
2647
+ }, I("query", { xmlns: U.mucAdmin }, I("item", { affiliation: "owner" }))), 1e4);
2634
2648
  for (let e of t.getChild("query", U.mucAdmin)?.getChildren("item") ?? []) n.push(G(e.attrs.jid)), G(e.attrs.jid) === this.cfg.username && (r = !0);
2635
2649
  } catch {}
2636
2650
  let i = await this.groupAvatar(e).catch(() => void 0);
@@ -2643,10 +2657,10 @@ var U = {
2643
2657
  };
2644
2658
  }
2645
2659
  async upload(e) {
2646
- let t = await this.findUploadService(), n = (await this.xmpp.iqCaller.request(P("iq", {
2660
+ let t = await this.findUploadService(), n = (await this.xmpp.iqCaller.request(I("iq", {
2647
2661
  type: "get",
2648
2662
  to: t
2649
- }, P("request", {
2663
+ }, I("request", {
2650
2664
  xmlns: U.upload,
2651
2665
  filename: e.name,
2652
2666
  size: String(e.size),
@@ -2667,19 +2681,19 @@ var U = {
2667
2681
  if (this.uploadService) return this.uploadService;
2668
2682
  let e = async (e) => {
2669
2683
  try {
2670
- return (await this.xmpp.iqCaller.request(P("iq", {
2684
+ return (await this.xmpp.iqCaller.request(I("iq", {
2671
2685
  type: "get",
2672
2686
  to: e
2673
- }, P("query", { xmlns: U.discoInfo })), 1e4)).getChild("query", U.discoInfo)?.getChildren("feature").some((e) => e.attrs.var === U.upload) ?? !1;
2687
+ }, I("query", { xmlns: U.discoInfo })), 1e4)).getChild("query", U.discoInfo)?.getChildren("feature").some((e) => e.attrs.var === U.upload) ?? !1;
2674
2688
  } catch {
2675
2689
  return !1;
2676
2690
  }
2677
2691
  }, t = [`upload.${this.domain}`];
2678
2692
  try {
2679
- let e = await this.xmpp.iqCaller.request(P("iq", {
2693
+ let e = await this.xmpp.iqCaller.request(I("iq", {
2680
2694
  type: "get",
2681
2695
  to: this.domain
2682
- }, P("query", { xmlns: U.disco })), 1e4);
2696
+ }, I("query", { xmlns: U.disco })), 1e4);
2683
2697
  for (let n of e.getChild("query", U.disco)?.getChildren("item") ?? []) t.includes(n.attrs.jid) || t.push(n.attrs.jid);
2684
2698
  } catch {}
2685
2699
  for (let n of t) if (await e(n)) return this.uploadService = n, n;
@@ -2706,7 +2720,7 @@ var U = {
2706
2720
  let r = G(n), i = this.online.get(r) ?? /* @__PURE__ */ new Set();
2707
2721
  e.attrs.type === "unavailable" ? i.delete(t) : i.add(t), this.online.set(r, i), this.h.presence(r, i.size > 0);
2708
2722
  let a = e.getChild("x", U.hello);
2709
- a && !a.attrs.reply && e.attrs.type !== "unavailable" && this.xmpp.send(P("presence", { to: n }, P("x", {
2723
+ a && !a.attrs.reply && e.attrs.type !== "unavailable" && this.xmpp.send(I("presence", { to: n }, I("x", {
2710
2724
  xmlns: U.hello,
2711
2725
  reply: "1"
2712
2726
  }))).catch(() => {});
@@ -2720,7 +2734,7 @@ var U = {
2720
2734
  if (e && r) {
2721
2735
  let t = this.reactionOf(e);
2722
2736
  t && this.mamReactions.get(n.attrs.queryid)?.push(t);
2723
- let i = t ? void 0 : this.toMessage(e, n.attrs.id, yn(n.getChild("forwarded", U.forward)));
2737
+ let i = t ? void 0 : this.toMessage(e, n.attrs.id, bn(n.getChild("forwarded", U.forward)));
2724
2738
  i && r.push(i);
2725
2739
  }
2726
2740
  return;
@@ -2735,7 +2749,7 @@ var U = {
2735
2749
  let i = e.getChild("event", U.pubsubEvent);
2736
2750
  if (i?.getChild("items")?.attrs.node === U.mucsubConfig) {
2737
2751
  let t = W(e.attrs.from);
2738
- this.isGroup(t) && bn(i, "presence")?.getChild("x", U.mucUser)?.getChild("destroy") && this.h.groupDestroyed(t);
2752
+ this.isGroup(t) && xn(i, "presence")?.getChild("x", U.mucUser)?.getChild("destroy") && this.h.groupDestroyed(t);
2739
2753
  return;
2740
2754
  }
2741
2755
  let a = e.getChild("x", U.conference);
@@ -2752,7 +2766,7 @@ var U = {
2752
2766
  this.h.reaction(t);
2753
2767
  return;
2754
2768
  }
2755
- let n = this.toMessage(e, e.getChild("stanza-id", U.sid)?.attrs.id, yn(e));
2769
+ let n = this.toMessage(e, e.getChild("stanza-id", U.sid)?.attrs.id, bn(e));
2756
2770
  if (n) {
2757
2771
  this.h.message(n);
2758
2772
  return;
@@ -2765,7 +2779,7 @@ var U = {
2765
2779
  let t = e.getChild("event", U.pubsubEvent), n = e, r;
2766
2780
  if (t && t.getChild("items")?.attrs.node === U.mucsubMessages) {
2767
2781
  r = W(e.attrs.from);
2768
- let i = xn(t);
2782
+ let i = Sn(t);
2769
2783
  if (!this.isGroup(r) || !i || W(i.attrs.from) !== r) return;
2770
2784
  n = i;
2771
2785
  } else if (e.attrs.type === "groupchat" && (r = W(e.attrs.from), !this.isGroup(r))) return;
@@ -2791,11 +2805,15 @@ var U = {
2791
2805
  } : void 0;
2792
2806
  }
2793
2807
  toMessage(e, t, n) {
2808
+ let r = this.parseMessage(e, t, n);
2809
+ return r && vn(r, xn(e, "reply") ? e.getChild("event", U.pubsubEvent) ? Sn(e.getChild("event", U.pubsubEvent)) : e : void 0);
2810
+ }
2811
+ parseMessage(e, t, n) {
2794
2812
  let r = e.getChild("event", U.pubsubEvent);
2795
2813
  if (r && r.getChild("items")?.attrs.node === U.mucsubMessages) {
2796
2814
  let i = W(e.attrs.from);
2797
2815
  if (!this.isGroup(i)) return;
2798
- let a = xn(r);
2816
+ let a = Sn(r);
2799
2817
  if (!a || W(a.attrs.from) !== i) return;
2800
2818
  let o = (a.attrs.from ?? "").split("/")[1] ?? "", s = a.getChildText("body");
2801
2819
  return s == null ? void 0 : {
@@ -2804,7 +2822,7 @@ var U = {
2804
2822
  from: i,
2805
2823
  to: this.cfg.username,
2806
2824
  body: s,
2807
- ts: yn(a) !== n && a.getChild("delay", U.delay) ? yn(a) : n,
2825
+ ts: bn(a) !== n && a.getChild("delay", U.delay) ? bn(a) : n,
2808
2826
  mine: o === this.cfg.username,
2809
2827
  oob: a.getChild("x", U.oob)?.getChildText("url") ?? void 0,
2810
2828
  room: i,
@@ -2843,20 +2861,43 @@ var U = {
2843
2861
  oob: e.getChild("x", U.oob)?.getChildText("url") ?? void 0
2844
2862
  };
2845
2863
  }
2846
- }, W = (e = "") => e.split("/")[0], vn = (e) => e.name === "SASLError" || e.condition === "not-authorized", G = (e = "") => e.split("@")[0], yn = (e) => {
2864
+ }, W = (e = "") => e.split("/")[0];
2865
+ function vn(e, t) {
2866
+ let n = t?.getChild("reply", U.reply);
2867
+ if (!n?.attrs.id) return e;
2868
+ let r = n.attrs.to ?? "", i = e.room ? r.split("/")[1] ?? "" : G(W(r)), a = t.getChildren("fallback", U.fallback).find((e) => e.attrs.for === U.reply)?.getChild("body"), o = [...e.body], s = Number(a?.attrs.start ?? 0), c = Number(a?.attrs.end ?? 0);
2869
+ if (!a || !(c > s) || c > o.length) return {
2870
+ ...e,
2871
+ reply: {
2872
+ id: n.attrs.id,
2873
+ author: i
2874
+ }
2875
+ };
2876
+ let l = o.slice(s, c).join("").replace(/^> ?/gm, "").trim();
2877
+ return {
2878
+ ...e,
2879
+ body: (o.slice(0, s).join("") + o.slice(c).join("")).trim(),
2880
+ reply: {
2881
+ id: n.attrs.id,
2882
+ author: i,
2883
+ quote: l
2884
+ }
2885
+ };
2886
+ }
2887
+ var yn = (e) => e.name === "SASLError" || e.condition === "not-authorized", G = (e = "") => e.split("@")[0], bn = (e) => {
2847
2888
  let t = e?.getChild("delay", U.delay)?.attrs.stamp;
2848
2889
  return t ? Date.parse(t) : Date.now();
2849
2890
  };
2850
- function bn(e, t) {
2891
+ function xn(e, t) {
2851
2892
  for (let n of e.children) {
2852
2893
  if (typeof n == "string") continue;
2853
2894
  if (n.name === t) return n;
2854
- let e = bn(n, t);
2895
+ let e = xn(n, t);
2855
2896
  if (e) return e;
2856
2897
  }
2857
2898
  }
2858
- var xn = (e) => bn(e, "message"), K;
2859
- function Sn() {
2899
+ var Sn = (e) => xn(e, "message"), K;
2900
+ function Cn() {
2860
2901
  try {
2861
2902
  K ??= new AudioContext(), K.state === "suspended" && K.resume();
2862
2903
  let e = K.currentTime;
@@ -2876,7 +2917,7 @@ function Sn() {
2876
2917
  }
2877
2918
  //#endregion
2878
2919
  //#region node_modules/zustand/esm/vanilla.mjs
2879
- var Cn = (e) => {
2920
+ var wn = (e) => {
2880
2921
  let t, n = /* @__PURE__ */ new Set(), r = (e, r) => {
2881
2922
  let i = typeof e == "function" ? e(t) : e;
2882
2923
  if (!Object.is(i, t)) {
@@ -2893,15 +2934,15 @@ var Cn = (e) => {
2893
2934
  }
2894
2935
  }, o = t = e(r, i, a);
2895
2936
  return a;
2896
- }, wn = (e) => e ? Cn(e) : Cn, { useDebugValue: Tn } = e, { useSyncExternalStoreWithSelector: En } = l, Dn = (e) => e;
2897
- function On(e, t = Dn, n) {
2898
- let r = En(e.subscribe, e.getState, e.getServerState || e.getInitialState, t, n);
2899
- return Tn(r), r;
2937
+ }, Tn = (e) => e ? wn(e) : wn, { useDebugValue: En } = e, { useSyncExternalStoreWithSelector: Dn } = l, On = (e) => e;
2938
+ function kn(e, t = On, n) {
2939
+ let r = Dn(e.subscribe, e.getState, e.getServerState || e.getInitialState, t, n);
2940
+ return En(r), r;
2900
2941
  }
2901
- var kn = (e) => {
2902
- let t = typeof e == "function" ? wn(e) : e, n = (e, n) => On(t, e, n);
2942
+ var An = (e) => {
2943
+ let t = typeof e == "function" ? Tn(e) : e, n = (e, n) => kn(t, e, n);
2903
2944
  return Object.assign(n, t), n;
2904
- }, An = (e) => e ? kn(e) : kn, jn = (e) => e.room ?? (e.mine ? e.to : e.from), q = (e, t) => ({
2945
+ }, jn = (e) => e ? An(e) : An, Mn = (e) => e.room ?? (e.mine ? e.to : e.from), q = (e, t) => ({
2905
2946
  peer: e,
2906
2947
  kind: t && e.endsWith("@" + t) ? "group" : "chat",
2907
2948
  messages: [],
@@ -2909,14 +2950,15 @@ var kn = (e) => {
2909
2950
  typing: !1,
2910
2951
  loaded: !1,
2911
2952
  complete: !1
2912
- }), Mn = (e, t, n, r) => {
2953
+ }), Nn = (e, t, n, r) => {
2913
2954
  if (e.includes(t)) return e;
2914
2955
  let i = [t, ...e];
2915
2956
  if (i.length <= n) return i;
2916
2957
  let a = [...i].reverse().find((e) => e !== r);
2917
2958
  return i.filter((e) => e !== a);
2918
- }, J = An((e, t) => ({
2959
+ }, J = jn((e, t) => ({
2919
2960
  me: "",
2961
+ myName: "",
2920
2962
  mucHost: "",
2921
2963
  status: "connecting",
2922
2964
  contacts: {},
@@ -2980,7 +3022,7 @@ var kn = (e) => {
2980
3022
  seed: (t, n) => e((e) => {
2981
3023
  let r = { ...e.conversations };
2982
3024
  for (let i of t) {
2983
- let t = jn(i);
3025
+ let t = Mn(i);
2984
3026
  if (!t || t === n) continue;
2985
3027
  let a = r[t] ?? q(t, e.mucHost);
2986
3028
  if (a.messages.some((e) => e.id === i.id)) continue;
@@ -3003,7 +3045,7 @@ var kn = (e) => {
3003
3045
  let i = e.conversations[t] ?? q(t, e.mucHost), a = i.messages.filter((e) => e.id !== n.id && !(e.pending && n.mine && e.body === n.body && e.oob === n.oob)), o = a.length;
3004
3046
  for (; o > 0 && a[o - 1].ts > n.ts;) o--;
3005
3047
  a.splice(o, 0, n);
3006
- let s = e.open === t, c = r?.live && !n.mine && !s ? i.unread + 1 : i.unread, l = Mn(e.order, t, e.maxHeads, e.open);
3048
+ let s = e.open === t, c = r?.live && !n.mine && !s ? i.unread + 1 : i.unread, l = Nn(e.order, t, e.maxHeads, e.open);
3007
3049
  return {
3008
3050
  conversations: {
3009
3051
  ...e.conversations,
@@ -3054,7 +3096,7 @@ var kn = (e) => {
3054
3096
  ...e.conversations,
3055
3097
  [t]: q(t, e.mucHost)
3056
3098
  },
3057
- order: Mn(e.order, t, e.maxHeads, e.open),
3099
+ order: Nn(e.order, t, e.maxHeads, e.open),
3058
3100
  open: t,
3059
3101
  picker: !1
3060
3102
  })),
@@ -3083,29 +3125,30 @@ var kn = (e) => {
3083
3125
  }));
3084
3126
  //#endregion
3085
3127
  //#region src/api.ts
3086
- async function Nn(e, t, n) {
3128
+ async function Pn(e, t, n) {
3087
3129
  let r = await fetch(`https://${e}/api${n}`, { headers: { Authorization: `Bearer ${t}` } });
3088
3130
  if (!r.ok) throw Error(`${n}: HTTP ${r.status}`);
3089
3131
  return await r.json();
3090
3132
  }
3091
- async function Pn(e, t, n) {
3092
- let r = await Nn(e, t, "/user/endpoints/all"), i = {};
3133
+ async function Fn(e, t, n, r) {
3134
+ let i = await Pn(e, t, "/user/endpoints/all"), a = {};
3093
3135
  try {
3094
- i = await Nn(e, t, "/user/all_avatars");
3136
+ a = await Pn(e, t, "/user/all_avatars");
3095
3137
  } catch {}
3096
- return Object.values(r).filter((e) => e.username && e.username !== n).map((e) => ({
3138
+ let o = Object.values(i).find((e) => e.username === n)?.name;
3139
+ return o && r?.(o), Object.values(i).filter((e) => e.username && e.username !== n).map((e) => ({
3097
3140
  username: e.username,
3098
3141
  name: e.name || e.username,
3099
- avatar: i[e.username],
3142
+ avatar: a[e.username],
3100
3143
  presence: e.mainPresence
3101
3144
  })).sort((e, t) => e.name.localeCompare(t.name));
3102
3145
  }
3103
- async function Fn(e, t) {
3146
+ async function In(e, t) {
3104
3147
  let n = await fetch(`https://${e}/chat-gw/push/mobile`, { headers: { Authorization: `Bearer ${t}` } });
3105
3148
  if (!n.ok) throw Error(`push/mobile: HTTP ${n.status}`);
3106
3149
  return (await n.json()).users;
3107
3150
  }
3108
- async function In(e, t, n) {
3151
+ async function Ln(e, t, n) {
3109
3152
  let r = await fetch(`https://${e}/chat-gw/conversations/${encodeURIComponent(n)}`, {
3110
3153
  method: "DELETE",
3111
3154
  headers: { Authorization: `Bearer ${t}` }
@@ -3114,16 +3157,16 @@ async function In(e, t, n) {
3114
3157
  }
3115
3158
  //#endregion
3116
3159
  //#region src/push.ts
3117
- var Ln = (e) => {
3160
+ var Rn = (e) => {
3118
3161
  let t = atob((e + "=".repeat((4 - e.length % 4) % 4)).replace(/-/g, "+").replace(/_/g, "/"));
3119
3162
  return Uint8Array.from(t, (e) => e.charCodeAt(0));
3120
- }, Rn = !1;
3121
- function zn() {
3122
- Rn || (Rn = !0, navigator.serviceWorker.addEventListener("message", (e) => {
3163
+ }, zn = !1;
3164
+ function Bn() {
3165
+ zn || (zn = !0, navigator.serviceWorker.addEventListener("message", (e) => {
3123
3166
  e.data?.type === "chat-island-open" && typeof e.data.username == "string" && window.dispatchEvent(new CustomEvent("chat-island-open", { detail: { username: e.data.username } }));
3124
3167
  }));
3125
3168
  }
3126
- async function Bn(e, t) {
3169
+ async function Vn(e, t) {
3127
3170
  if (!("serviceWorker" in navigator) || !("PushManager" in window)) throw Error("push not supported by this browser");
3128
3171
  if (Notification.permission === "denied" || Notification.permission !== "granted" && await Notification.requestPermission() !== "granted") return null;
3129
3172
  let n = `https://${e.host}/chat-gw`, r = await fetch(`${n}/push/vapid`);
@@ -3132,7 +3175,7 @@ async function Bn(e, t) {
3132
3175
  await navigator.serviceWorker.ready;
3133
3176
  let o = await a.pushManager.getSubscription() ?? await a.pushManager.subscribe({
3134
3177
  userVisibleOnly: !0,
3135
- applicationServerKey: Ln(i.publicKey)
3178
+ applicationServerKey: Rn(i.publicKey)
3136
3179
  }), s = await fetch(`${n}/push/web`, {
3137
3180
  method: "POST",
3138
3181
  headers: {
@@ -3143,7 +3186,7 @@ async function Bn(e, t) {
3143
3186
  });
3144
3187
  if (!s.ok) throw Error(`push/web: HTTP ${s.status} ${(await s.text()).slice(0, 120)}`);
3145
3188
  let c = await s.json();
3146
- return zn(), {
3189
+ return Bn(), {
3147
3190
  node: c.node,
3148
3191
  service: c.service
3149
3192
  };
@@ -3159,8 +3202,8 @@ function X(e, t) {
3159
3202
  }
3160
3203
  //#endregion
3161
3204
  //#region src/components/Avatar.tsx
3162
- var Vn = (e) => e.split(/\s+/).slice(0, 2).map((e) => e[0]?.toUpperCase() ?? "").join("");
3163
- function Hn({ contact: e, username: t, size: n = 40 }) {
3205
+ var Hn = (e) => e.split(/\s+/).slice(0, 2).map((e) => e[0]?.toUpperCase() ?? "").join("");
3206
+ function Un({ contact: e, username: t, size: n = 40 }) {
3164
3207
  let r = e?.name || t, i = {
3165
3208
  width: n,
3166
3209
  height: n,
@@ -3175,13 +3218,13 @@ function Hn({ contact: e, username: t, size: n = 40 }) {
3175
3218
  }) : /* @__PURE__ */ d("div", {
3176
3219
  style: i,
3177
3220
  className: "ci-rounded-full ci-shrink-0 ci-flex ci-items-center ci-justify-center ci-font-medium ci-bg-gray-700 ci-text-gray-50 dark:ci-bg-gray-300 dark:ci-text-gray-900",
3178
- children: Vn(r)
3221
+ children: Hn(r)
3179
3222
  });
3180
3223
  }
3181
- function Un({ online: e, presence: t, mobile: n }) {
3224
+ function Wn({ online: e, presence: t, mobile: n }) {
3182
3225
  return /* @__PURE__ */ d("span", { className: `ci-absolute ci-bottom-0 ci-right-0 ci-w-3 ci-h-3 ci-rounded-full ci-ring-2 ci-ring-gray-50 dark:ci-ring-gray-950 ${t === "dnd" || t === "busy" ? "ci-bg-phoneIslandClose dark:ci-bg-phoneIslandCloseDark" : e || n ? "ci-bg-phoneIslandCall dark:ci-bg-phoneIslandCallDark" : "ci-bg-gray-400 dark:ci-bg-gray-600"}` });
3183
3226
  }
3184
- function Wn({ name: e, size: t = 40, avatar: n }) {
3227
+ function Gn({ name: e, size: t = 40, avatar: n }) {
3185
3228
  let r = {
3186
3229
  width: t,
3187
3230
  height: t,
@@ -3196,12 +3239,12 @@ function Wn({ name: e, size: t = 40, avatar: n }) {
3196
3239
  }) : /* @__PURE__ */ d("div", {
3197
3240
  style: r,
3198
3241
  className: "ci-rounded-full ci-shrink-0 ci-flex ci-items-center ci-justify-center ci-font-medium ci-bg-iconSecondary dark:ci-bg-iconSecondaryDark ci-text-white",
3199
- children: Vn(e || "G")
3242
+ children: Hn(e || "G")
3200
3243
  });
3201
3244
  }
3202
3245
  //#endregion
3203
3246
  //#region src/components/Button.tsx
3204
- var Gn = "ci-flex ci-content-center ci-items-center ci-justify-center ci-tracking-wide ci-duration-200 ci-transform ci-outline-none focus:ci-ring-2 focus:ci-z-20 focus:ci-ring-offset-2 disabled:ci-opacity-40 disabled:ci-cursor-not-allowed ci-border ci-border-transparent focus:ci-ring-offset-white dark:focus:ci-ring-offset-black ci-text-sm ci-leading-4 ci-transition-colors ci-shrink-0 ci-font-light", Kn = {
3247
+ var Kn = "ci-flex ci-content-center ci-items-center ci-justify-center ci-tracking-wide ci-duration-200 ci-transform ci-outline-none focus:ci-ring-2 focus:ci-z-20 focus:ci-ring-offset-2 disabled:ci-opacity-40 disabled:ci-cursor-not-allowed ci-border ci-border-transparent focus:ci-ring-offset-white dark:focus:ci-ring-offset-black ci-text-sm ci-leading-4 ci-transition-colors ci-shrink-0 ci-font-light", qn = {
3205
3248
  default: "ci-bg-phoneIslandActive dark:ci-bg-phoneIslandActiveDark hover:ci-bg-gray-500 dark:hover:ci-bg-gray-50 focus:ci-ring-emerald-500 dark:focus:ci-ring-emerald-300 ci-text-primaryInvert dark:ci-text-primaryInvertDark ci-h-12 ci-w-12 ci-rounded-full",
3206
3249
  green: "ci-bg-phoneIslandCall dark:ci-bg-phoneIslandCallDark hover:ci-bg-phoneIslandCallHover dark:hover:ci-bg-phoneIslandCallHoverDark focus:ci-ring-green-500 ci-text-white dark:ci-text-gray-950 ci-h-12 ci-w-12 ci-rounded-full",
3207
3250
  red: "ci-bg-phoneIslandClose dark:ci-bg-phoneIslandCloseDark hover:ci-bg-phoneIslandCloseHover dark:hover:ci-bg-phoneIslandCloseHoverDark focus:ci-ring-emerald-500 ci-text-white dark:ci-text-gray-950 ci-h-12 ci-w-12 ci-rounded-full",
@@ -3214,22 +3257,18 @@ function Z({ variant: e, className: t = "", children: n, ...r }) {
3214
3257
  return /* @__PURE__ */ d("button", {
3215
3258
  type: "button",
3216
3259
  "aria-label": r["aria-label"] ?? r.title,
3217
- className: `${Gn} ${Kn[e]} ${t}`,
3260
+ className: `${Kn} ${qn[e]} ${t}`,
3218
3261
  ...r,
3219
3262
  children: n
3220
3263
  });
3221
3264
  }
3222
3265
  var Q = {
3223
3266
  chat: /* @__PURE__ */ d("svg", {
3224
- width: "22",
3225
- height: "22",
3226
- viewBox: "0 0 24 24",
3227
- fill: "none",
3228
- stroke: "currentColor",
3229
- strokeWidth: "2",
3230
- strokeLinecap: "round",
3231
- strokeLinejoin: "round",
3232
- children: /* @__PURE__ */ d("path", { d: "M21 15a2 2 0 0 1-2 2H7l-4 4V5a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2z" })
3267
+ width: "20",
3268
+ height: "20",
3269
+ viewBox: "0 0 512 512",
3270
+ fill: "currentColor",
3271
+ children: /* @__PURE__ */ d("path", { d: "M0 240c0 54.4 19.3 104.6 51.9 144.9L3.1 474.3c-2 3.7-3.1 7.9-3.1 12.2 0 14.1 11.4 25.5 25.5 25.5 4 0 7.8-.6 11.5-2.1L153.4 460c31.4 12.9 66.1 20 102.6 20 141.4 0 256-107.5 256-240S397.4 0 256 0 0 107.5 0 240zM94 407.9c9.3-17.1 7.4-38.1-4.8-53.2-26.1-32.3-41.2-71.9-41.2-114.7 0-103.2 90.2-192 208-192s208 88.8 208 192-90.2 192-208 192c-30.2 0-58.7-5.9-84.3-16.4-11.9-4.9-25.3-4.8-37.1 .3L76 440.9 94 407.9zM144 272a32 32 0 1 0 0-64 32 32 0 1 0 0 64zm144-32a32 32 0 1 0 -64 0 32 32 0 1 0 64 0zm80 32a32 32 0 1 0 0-64 32 32 0 1 0 0 64z" })
3233
3272
  }),
3234
3273
  bell: /* @__PURE__ */ d("svg", {
3235
3274
  width: "18",
@@ -3312,6 +3351,17 @@ var Q = {
3312
3351
  strokeLinejoin: "round",
3313
3352
  children: /* @__PURE__ */ d("path", { d: "M3 6h18M8 6V4h8v2M19 6l-1 14H6L5 6M10 11v6M14 11v6" })
3314
3353
  }),
3354
+ reply: /* @__PURE__ */ f("svg", {
3355
+ width: "16",
3356
+ height: "16",
3357
+ viewBox: "0 0 24 24",
3358
+ fill: "none",
3359
+ stroke: "currentColor",
3360
+ strokeWidth: "2",
3361
+ strokeLinecap: "round",
3362
+ strokeLinejoin: "round",
3363
+ children: [/* @__PURE__ */ d("path", { d: "M9 17l-5-5 5-5" }), /* @__PURE__ */ d("path", { d: "M20 18v-2a4 4 0 0 0-4-4H4" })]
3364
+ }),
3315
3365
  minus: /* @__PURE__ */ d("svg", {
3316
3366
  width: "16",
3317
3367
  height: "16",
@@ -3375,7 +3425,7 @@ var Q = {
3375
3425
  };
3376
3426
  //#endregion
3377
3427
  //#region src/components/Dock.tsx
3378
- function qn({ onDragStart: e, pushButton: t = !0 }) {
3428
+ function Jn({ onDragStart: e, pushButton: t = !0 }) {
3379
3429
  let { order: n, open: r, conversations: i, contacts: a, online: o, mobile: s, openChat: c, removeHead: l, picker: p, setPicker: m, status: h, push: g, enablePush: _, newChatButton: v } = J(w((e) => ({
3380
3430
  order: e.order,
3381
3431
  open: e.open,
@@ -3405,15 +3455,15 @@ function qn({ onDragStart: e, pushButton: t = !0 }) {
3405
3455
  title: t?.kind === "group" ? t.name ?? e : a[e]?.name ?? e,
3406
3456
  onClick: () => n ? J.getState().closeChat() : c(e),
3407
3457
  className: `ci-relative ci-rounded-full ci-shadow-lg ci-transition-transform hover:ci-scale-105 ci-ring-2 ci-border-0 ci-p-0 ci-bg-transparent ${n ? "ci-ring-iconSecondary dark:ci-ring-iconSecondaryDark" : "ci-ring-gray-50 dark:ci-ring-gray-950"}`,
3408
- children: [t?.kind === "group" ? /* @__PURE__ */ d(Wn, {
3458
+ children: [t?.kind === "group" ? /* @__PURE__ */ d(Gn, {
3409
3459
  name: t.name ?? e,
3410
3460
  size: 48,
3411
3461
  avatar: t.avatar
3412
- }) : /* @__PURE__ */ f(u, { children: [/* @__PURE__ */ d(Hn, {
3462
+ }) : /* @__PURE__ */ f(u, { children: [/* @__PURE__ */ d(Un, {
3413
3463
  contact: a[e],
3414
3464
  username: e,
3415
3465
  size: 48
3416
- }), /* @__PURE__ */ d(Un, {
3466
+ }), /* @__PURE__ */ d(Wn, {
3417
3467
  online: o[e],
3418
3468
  presence: a[e]?.presence,
3419
3469
  mobile: s[e]
@@ -3449,7 +3499,7 @@ function qn({ onDragStart: e, pushButton: t = !0 }) {
3449
3499
  }
3450
3500
  //#endregion
3451
3501
  //#region src/shortcodes.ts
3452
- var Jn = {
3502
+ var Yn = {
3453
3503
  "+1": "👍",
3454
3504
  thumbsup: "👍",
3455
3505
  "-1": "👎",
@@ -3643,13 +3693,13 @@ var Jn = {
3643
3693
  zzz: "💤",
3644
3694
  sweat_drops: "💦",
3645
3695
  dash: "💨"
3646
- }, Yn = /(```[\s\S]*?(?:```|$)|`[^`\n]*`?)/g, Xn = /:([a-z0-9_+-]+):/g, Zn = (e) => e.replace(Xn, (e, t) => Jn[t] ?? e);
3696
+ }, Xn = /(```[\s\S]*?(?:```|$)|`[^`\n]*`?)/g, Zn = /:([a-z0-9_+-]+):/g, Qn = (e) => e.replace(Zn, (e, t) => Yn[t] ?? e);
3647
3697
  function $(e) {
3648
- return e.includes(":") ? e.split(Yn).map((e, t) => t % 2 ? e : Zn(e)).join("") : e;
3698
+ return e.includes(":") ? e.split(Xn).map((e, t) => t % 2 ? e : Qn(e)).join("") : e;
3649
3699
  }
3650
3700
  //#endregion
3651
3701
  //#region src/components/EmojiPicker.tsx
3652
- var Qn = [
3702
+ var $n = [
3653
3703
  {
3654
3704
  label: "Smileys",
3655
3705
  icon: "😀",
@@ -3680,7 +3730,7 @@ var Qn = [
3680
3730
  icon: "☕",
3681
3731
  emojis: "☕ 🍵 🥤 🍕 🍔 🍟 🌭 🥪 🌮 🍝 🍣 🍩 🍪 🍫 🍎 🍌 🍓 🥐 🚗 🚕 🚌 🚆 ✈️ 🚀 🏠 🏢 🏖️ 🌍 ☀️ 🌤️ 🌧️ ⛈️ ❄️ ⚡ 🌈 🌙"
3682
3732
  }
3683
- ], $n = [
3733
+ ], er = [
3684
3734
  "👍",
3685
3735
  "❤️",
3686
3736
  "😂",
@@ -3688,7 +3738,7 @@ var Qn = [
3688
3738
  "😢",
3689
3739
  "🙏"
3690
3740
  ];
3691
- function er({ onPick: e, onClose: t, className: n = "" }) {
3741
+ function tr({ onPick: e, onClose: t, className: n = "" }) {
3692
3742
  let [r, a] = c(0), o = s(null);
3693
3743
  return i(() => {
3694
3744
  let e = (e) => o.current && !o.current.contains(e.target) && t(), n = (e) => {
@@ -3704,7 +3754,7 @@ function er({ onPick: e, onClose: t, className: n = "" }) {
3704
3754
  className: `ci-z-30 ci-w-[21rem] ci-max-w-full ci-rounded-2xl ci-bg-gray-50 dark:ci-bg-gray-950 ci-shadow-2xl ci-ring-1 ci-ring-gray-300 dark:ci-ring-gray-700 ci-select-none ${n}`,
3705
3755
  children: [/* @__PURE__ */ d("div", {
3706
3756
  className: "ci-flex ci-gap-1 ci-px-2 ci-pt-2 ci-border-b ci-border-gray-300 dark:ci-border-gray-700",
3707
- children: Qn.map((e, t) => /* @__PURE__ */ d("button", {
3757
+ children: $n.map((e, t) => /* @__PURE__ */ d("button", {
3708
3758
  type: "button",
3709
3759
  title: e.label,
3710
3760
  "aria-label": e.label,
@@ -3718,7 +3768,7 @@ function er({ onPick: e, onClose: t, className: n = "" }) {
3718
3768
  }, e.label))
3719
3769
  }), /* @__PURE__ */ d("div", {
3720
3770
  className: "ci-grid ci-grid-cols-7 ci-gap-1 ci-p-2 ci-h-64 ci-overflow-y-auto",
3721
- children: Qn[r].emojis.split(" ").map((t) => /* @__PURE__ */ d("button", {
3771
+ children: $n[r].emojis.split(" ").map((t) => /* @__PURE__ */ d("button", {
3722
3772
  type: "button",
3723
3773
  onClick: () => e(t),
3724
3774
  style: {
@@ -3733,27 +3783,27 @@ function er({ onPick: e, onClose: t, className: n = "" }) {
3733
3783
  }
3734
3784
  //#endregion
3735
3785
  //#region src/components/MessageList.tsx
3736
- var tr = (e) => /\.(png|jpe?g|gif|webp|avif|svg)(\?|$)/i.test(e), nr = (e) => /\.(webm|ogg|oga|opus|mp3|m4a|wav)(\?|$)/i.test(e), rr = (e) => {
3786
+ var nr = (e) => /\.(png|jpe?g|gif|webp|avif|svg)(\?|$)/i.test(e), rr = (e) => /\.(webm|ogg|oga|opus|mp3|m4a|wav)(\?|$)/i.test(e), ir = (e) => {
3737
3787
  let t = e.split("/").pop() || "file";
3738
3788
  try {
3739
3789
  return decodeURIComponent(t);
3740
3790
  } catch {
3741
3791
  return t;
3742
3792
  }
3743
- }, ir = (e) => {
3793
+ }, ar = (e) => {
3744
3794
  try {
3745
3795
  return new URL(e).protocol === "https:";
3746
3796
  } catch {
3747
3797
  return !1;
3748
3798
  }
3749
- }, ar = (e) => new Date(e).toLocaleTimeString([], {
3799
+ }, or = (e) => new Date(e).toLocaleTimeString([], {
3750
3800
  hour: "2-digit",
3751
3801
  minute: "2-digit"
3752
- }), or = (e) => new Date(e).toLocaleDateString([], {
3802
+ }), sr = (e) => new Date(e).toLocaleDateString([], {
3753
3803
  weekday: "short",
3754
3804
  day: "numeric",
3755
3805
  month: "short"
3756
- }), sr = (e, t) => new Date(e).toDateString() === new Date(t).toDateString(), cr = (e) => {
3806
+ }), cr = (e, t) => new Date(e).toDateString() === new Date(t).toDateString(), lr = (e) => {
3757
3807
  if (!e.startsWith("{\"")) return null;
3758
3808
  try {
3759
3809
  let t = JSON.parse(e);
@@ -3764,17 +3814,17 @@ var tr = (e) => /\.(png|jpe?g|gif|webp|avif|svg)(\?|$)/i.test(e), nr = (e) => /\
3764
3814
  } catch {
3765
3815
  return null;
3766
3816
  }
3767
- }, lr = n(function({ url: e }) {
3768
- return ir(e) ? tr(e) ? /* @__PURE__ */ d("a", {
3817
+ }, ur = n(function({ url: e }) {
3818
+ return ar(e) ? nr(e) ? /* @__PURE__ */ d("a", {
3769
3819
  href: e,
3770
3820
  target: "_blank",
3771
3821
  rel: "noreferrer",
3772
3822
  children: /* @__PURE__ */ d("img", {
3773
3823
  src: e,
3774
- alt: rr(e),
3824
+ alt: ir(e),
3775
3825
  className: "ci-max-w-full ci-max-h-60 ci-rounded-2xl ci-block"
3776
3826
  })
3777
- }) : nr(e) ? /* @__PURE__ */ d("audio", {
3827
+ }) : rr(e) ? /* @__PURE__ */ d("audio", {
3778
3828
  controls: !0,
3779
3829
  src: e,
3780
3830
  className: "ci-max-w-full"
@@ -3791,15 +3841,15 @@ var tr = (e) => /\.(png|jpe?g|gif|webp|avif|svg)(\?|$)/i.test(e), nr = (e) => /\
3791
3841
  stroke: "currentColor",
3792
3842
  strokeWidth: "2",
3793
3843
  children: /* @__PURE__ */ d("path", { d: "M21.44 11.05l-9.19 9.19a6 6 0 0 1-8.49-8.49l9.19-9.19a4 4 0 0 1 5.66 5.66l-9.2 9.19a2 2 0 0 1-2.83-2.83l8.49-8.48" })
3794
- }), rr(e)]
3844
+ }), ir(e)]
3795
3845
  }) : /* @__PURE__ */ d("span", {
3796
3846
  className: "ci-break-all",
3797
3847
  children: e
3798
3848
  });
3799
- }), ur = /(`[^`\n]+`)|(\*\*[^*\n]+\*\*|__[^_\n]+__)|(~~[^~\n]+~~)|(\*[^*\s][^*\n]*\*|_[^_\s][^_\n]*_)|\[([^\]\n]+)\]\((https?:\/\/[^\s)]+)\)|(https?:\/\/[^\s<]+)/g;
3800
- function dr({ text: e }) {
3849
+ }), dr = /(`[^`\n]+`)|(\*\*[^*\n]+\*\*|__[^_\n]+__)|(~~[^~\n]+~~)|(\*[^*\s][^*\n]*\*|_[^_\s][^_\n]*_)|\[([^\]\n]+)\]\((https?:\/\/[^\s)]+)\)|(https?:\/\/[^\s<]+)/g;
3850
+ function fr({ text: e }) {
3801
3851
  let t = [], n = 0;
3802
- for (let r of e.matchAll(ur)) {
3852
+ for (let r of e.matchAll(dr)) {
3803
3853
  let i = r[0], a = r.index ?? 0;
3804
3854
  a > n && t.push($(e.slice(n, a))), r[1] ? t.push(/* @__PURE__ */ d("code", {
3805
3855
  className: "ci-px-1 ci-py-0.5 ci-rounded ci-bg-black/10 dark:ci-bg-white/10 ci-font-mono ci-text-[0.85em]",
@@ -3820,17 +3870,17 @@ function dr({ text: e }) {
3820
3870
  }
3821
3871
  return n < e.length && t.push($(e.slice(n))), /* @__PURE__ */ d(u, { children: t });
3822
3872
  }
3823
- var fr = n(function({ text: e }) {
3873
+ var pr = n(function({ text: e }) {
3824
3874
  let t = e.split(/```[^\n]*\n?([\s\S]*?)```/g);
3825
3875
  return /* @__PURE__ */ d("span", {
3826
3876
  className: "ci-whitespace-pre-wrap ci-break-words",
3827
3877
  children: t.map((e, t) => t % 2 ? /* @__PURE__ */ d("pre", {
3828
3878
  className: "ci-my-1 ci-p-2 ci-rounded-xl ci-bg-black/10 dark:ci-bg-white/10 ci-font-mono ci-text-xs ci-overflow-x-auto ci-whitespace-pre",
3829
3879
  children: e.replace(/\n$/, "")
3830
- }, t) : /* @__PURE__ */ d(dr, { text: e.replace(/^(\s*)[-*] (?=\S)/gm, "$1• ") }, t))
3880
+ }, t) : /* @__PURE__ */ d(fr, { text: e.replace(/^(\s*)[-*] (?=\S)/gm, "$1• ") }, t))
3831
3881
  });
3832
3882
  });
3833
- function pr({ text: e, count: t }) {
3883
+ function mr({ text: e, count: t }) {
3834
3884
  return /* @__PURE__ */ f("span", {
3835
3885
  className: "ci-italic ci-opacity-80",
3836
3886
  children: [
@@ -3843,7 +3893,7 @@ function pr({ text: e, count: t }) {
3843
3893
  ]
3844
3894
  });
3845
3895
  }
3846
- function mr({ forMsg: e, me: t, onReact: n, nameOf: r, mine: i }) {
3896
+ function hr({ forMsg: e, me: t, onReact: n, nameOf: r, mine: i }) {
3847
3897
  if (!e) return null;
3848
3898
  let a = /* @__PURE__ */ new Map();
3849
3899
  for (let [t, n] of Object.entries(e)) for (let e of n) a.set(e, [...a.get(e) ?? [], t]);
@@ -3868,33 +3918,57 @@ function mr({ forMsg: e, me: t, onReact: n, nameOf: r, mine: i }) {
3868
3918
  })
3869
3919
  }) : null;
3870
3920
  }
3871
- function hr({ messages: e, typing: t, onLoadOlder: n, hasOlder: r, group: a, reactions: o, me: l = "", onReact: u }) {
3872
- let p = J((e) => e.contacts), m = s(null), h = s(!0), [g, _] = c(null), [v, y] = c(null), b = (e) => p[e]?.name ?? e;
3921
+ function gr({ reply: e, messages: t, mine: n, name: r }) {
3922
+ let i = t.find((t) => t.oid === e.id), a = i ? i.oob ? "Attachment" : i.body : e.quote?.replace(/^[^:]*: /, "") ?? "", o = (t) => {
3923
+ t.stopPropagation();
3924
+ let n = document.querySelector(`.chat-island-root [data-oid="${CSS.escape(e.id)}"]`);
3925
+ n && (n.scrollIntoView({
3926
+ block: "center",
3927
+ behavior: "smooth"
3928
+ }), n.animate([{ opacity: .4 }, { opacity: 1 }], { duration: 900 }));
3929
+ };
3930
+ return /* @__PURE__ */ f("div", {
3931
+ role: "button",
3932
+ tabIndex: 0,
3933
+ onClick: o,
3934
+ onKeyDown: (e) => e.key === "Enter" && o(e),
3935
+ className: `ci-mb-1.5 ci-px-2.5 ci-py-1 ci-rounded-xl ci-cursor-pointer ci-border-0 ci-border-l-4 ci-border-solid ci-text-xs ${n ? "ci-bg-black/20 dark:ci-bg-black/10 ci-border-gray-400 dark:ci-border-gray-600" : "ci-bg-black/5 dark:ci-bg-white/10 ci-border-iconSecondary dark:ci-border-iconSecondaryDark"}`,
3936
+ children: [/* @__PURE__ */ d("div", {
3937
+ className: "ci-font-medium",
3938
+ children: r(e.author)
3939
+ }), /* @__PURE__ */ d("div", {
3940
+ className: "ci-line-clamp-2 ci-break-words ci-opacity-80",
3941
+ children: a
3942
+ })]
3943
+ });
3944
+ }
3945
+ function _r({ messages: e, typing: t, onLoadOlder: n, hasOlder: r, group: a, reactions: o, me: l = "", onReact: u, onReply: p }) {
3946
+ let m = J((e) => e.contacts), h = s(null), g = s(!0), [_, v] = c(null), [y, b] = c(null), x = (e) => m[e]?.name ?? e;
3873
3947
  i(() => {
3874
- let e = m.current;
3875
- e && h.current && (e.scrollTop = e.scrollHeight);
3948
+ let e = h.current;
3949
+ e && g.current && (e.scrollTop = e.scrollHeight);
3876
3950
  }, [
3877
3951
  e.length,
3878
3952
  t,
3879
3953
  o
3880
3954
  ]), i(() => {
3881
- if (!g) return;
3882
- let e = () => _(null), t = window.setTimeout(() => document.addEventListener("click", e, { once: !0 }), 0);
3955
+ if (!_) return;
3956
+ let e = () => v(null), t = window.setTimeout(() => document.addEventListener("click", e, { once: !0 }), 0);
3883
3957
  return () => {
3884
3958
  window.clearTimeout(t), document.removeEventListener("click", e);
3885
3959
  };
3886
- }, [g]);
3887
- let x = () => {
3888
- let e = m.current;
3889
- e && (h.current = e.scrollHeight - e.scrollTop - e.clientHeight < 40, e.scrollTop < 30 && r && n());
3890
- }, S = (e, t) => {
3891
- _(null), y(null), u?.(e, t);
3960
+ }, [_]);
3961
+ let S = () => {
3962
+ let e = h.current;
3963
+ e && (g.current = e.scrollHeight - e.scrollTop - e.clientHeight < 40, e.scrollTop < 30 && r && n());
3964
+ }, C = (e, t) => {
3965
+ v(null), b(null), u?.(e, t);
3892
3966
  };
3893
3967
  return /* @__PURE__ */ f("div", {
3894
3968
  className: "ci-relative ci-flex-1 ci-min-h-0 ci-flex ci-flex-col",
3895
3969
  children: [/* @__PURE__ */ f("div", {
3896
- ref: m,
3897
- onScroll: x,
3970
+ ref: h,
3971
+ onScroll: S,
3898
3972
  className: "ci-flex-1 ci-overflow-y-auto ci-px-4 ci-py-2 ci-space-y-1",
3899
3973
  children: [
3900
3974
  r && /* @__PURE__ */ d("div", {
@@ -3902,90 +3976,110 @@ function hr({ messages: e, typing: t, onLoadOlder: n, hasOlder: r, group: a, rea
3902
3976
  children: "Scroll up for older messages"
3903
3977
  }),
3904
3978
  e.map((t, n) => {
3905
- let r = e[n - 1], i = !r || !sr(r.ts, t.ts), s = r && !i && r.mine === t.mine && r.nick === t.nick && t.ts - r.ts < 12e4, c = a && !t.mine && t.nick ? b(t.nick) : null, m = t.oid, h = !!u && !!m && !t.pending, v = h && /* @__PURE__ */ d("button", {
3979
+ let r = e[n - 1], i = !r || !cr(r.ts, t.ts), s = r && !i && r.mine === t.mine && r.nick === t.nick && t.ts - r.ts < 12e4, c = a && !t.mine && t.nick ? x(t.nick) : null, h = t.oid, g = !!u && !!h && !t.pending, y = g && /* @__PURE__ */ d("button", {
3906
3980
  type: "button",
3907
3981
  title: "React",
3908
3982
  "aria-label": "React to this message",
3909
3983
  onClick: (e) => {
3910
- e.stopPropagation(), _(g === m ? null : m);
3984
+ e.stopPropagation(), v(_ === h ? null : h);
3911
3985
  },
3912
- className: `ci-self-center ci-h-7 ci-w-7 ci-shrink-0 ci-flex ci-items-center ci-justify-center ci-rounded-full ci-border-0 ci-bg-transparent ci-text-gray-500 dark:ci-text-gray-400 hover:ci-bg-gray-200 dark:hover:ci-bg-gray-800 focus:ci-opacity-100 ${g === m ? "ci-opacity-100" : "ci-opacity-0 group-hover:ci-opacity-100"}`,
3986
+ className: `ci-self-center ci-h-7 ci-w-7 ci-shrink-0 ci-flex ci-items-center ci-justify-center ci-rounded-full ci-border-0 ci-bg-transparent ci-text-gray-500 dark:ci-text-gray-400 hover:ci-bg-gray-200 dark:hover:ci-bg-gray-800 focus:ci-opacity-100 ${_ === h ? "ci-opacity-100" : "ci-opacity-0 group-hover:ci-opacity-100"}`,
3913
3987
  children: Q.react
3988
+ }), S = !!p && !!h && !t.pending && /* @__PURE__ */ d("button", {
3989
+ type: "button",
3990
+ title: "Reply",
3991
+ "aria-label": "Reply to this message",
3992
+ onClick: (e) => {
3993
+ e.stopPropagation(), p(t);
3994
+ },
3995
+ className: "ci-self-center ci-h-7 ci-w-7 ci-shrink-0 ci-flex ci-items-center ci-justify-center ci-rounded-full ci-border-0 ci-bg-transparent ci-text-gray-500 dark:ci-text-gray-400 hover:ci-bg-gray-200 dark:hover:ci-bg-gray-800 focus:ci-opacity-100 ci-opacity-0 group-hover:ci-opacity-100",
3996
+ children: Q.reply
3914
3997
  });
3915
- return /* @__PURE__ */ f("div", { children: [i && /* @__PURE__ */ d("div", {
3916
- className: "ci-text-center ci-text-xs ci-text-gray-500 dark:ci-text-gray-400 ci-py-2",
3917
- children: or(t.ts)
3918
- }), /* @__PURE__ */ f("div", {
3919
- className: `ci-group ci-flex ci-items-start ci-gap-1.5 ${t.mine ? "ci-justify-end" : "ci-justify-start"} ${s ? "ci-mt-0.5" : "ci-mt-2"}`,
3920
- children: [
3921
- c && /* @__PURE__ */ d("span", {
3922
- className: "ci-w-7 ci-shrink-0",
3923
- title: c,
3924
- children: !s && /* @__PURE__ */ d(Hn, {
3925
- contact: p[t.nick],
3926
- username: t.nick,
3927
- size: 28
3928
- })
3929
- }),
3930
- t.mine && v,
3931
- /* @__PURE__ */ f("div", {
3932
- className: `ci-relative ci-flex ci-flex-col ci-max-w-[80%] ${t.mine ? "ci-items-end" : "ci-items-start"}`,
3933
- children: [
3934
- g === m && m && /* @__PURE__ */ f("div", {
3935
- role: "menu",
3936
- onClick: (e) => e.stopPropagation(),
3937
- className: `ci-absolute ci-bottom-full ci-mb-1 ci-z-20 ci-flex ci-items-center ci-gap-0.5 ci-p-1 ci-rounded-full ci-bg-gray-50 dark:ci-bg-gray-950 ci-shadow-xl ci-ring-1 ci-ring-gray-300 dark:ci-ring-gray-700 ${t.mine ? "ci-right-0" : "ci-left-0"}`,
3938
- children: [$n.map((e) => /* @__PURE__ */ d("button", {
3939
- type: "button",
3940
- role: "menuitem",
3941
- "aria-label": e,
3942
- onClick: () => S(m, e),
3943
- style: {
3944
- fontSize: 22,
3945
- lineHeight: "32px"
3946
- },
3947
- className: `ci-h-9 ci-w-9 ci-flex ci-items-center ci-justify-center ci-rounded-full ci-border-0 hover:ci-scale-125 ci-transition-transform ${o?.[m]?.[l]?.includes(e) ? "ci-bg-gray-200 dark:ci-bg-gray-800" : "ci-bg-transparent"}`,
3948
- children: e
3949
- }, e)), /* @__PURE__ */ d("button", {
3950
- type: "button",
3951
- role: "menuitem",
3952
- title: "More emojis",
3953
- "aria-label": "More emojis",
3954
- onClick: () => {
3955
- _(null), y(m);
3956
- },
3957
- className: "ci-h-8 ci-w-8 ci-flex ci-items-center ci-justify-center ci-rounded-full ci-border-0 ci-bg-gray-200 dark:ci-bg-gray-800 ci-text-gray-700 dark:ci-text-gray-200 ci-text-lg",
3958
- children: "+"
3959
- })]
3960
- }),
3961
- /* @__PURE__ */ f("div", {
3962
- title: ar(t.ts),
3963
- onDoubleClick: () => h && S(m, $n[0]),
3964
- className: `ci-px-3.5 ci-py-2 ci-rounded-3xl ci-text-sm ci-select-text ci-cursor-text ${t.mine ? "ci-bg-gray-700 ci-text-gray-50 dark:ci-bg-gray-300 dark:ci-text-gray-900 ci-rounded-br-lg" : "ci-bg-elevationL2 ci-text-gray-900 dark:ci-bg-elevationL2Dark dark:ci-text-white ci-rounded-bl-lg"} ${t.pending ? "ci-opacity-60" : ""}`,
3965
- children: [
3966
- t.oob ? /* @__PURE__ */ d(lr, { url: t.oob }) : cr(t.body) ? /* @__PURE__ */ d(pr, { ...cr(t.body) }) : /* @__PURE__ */ d(fr, { text: t.body }),
3967
- t.oob && t.body && t.body !== t.oob && t.body !== rr(t.oob) && /* @__PURE__ */ d("div", {
3968
- className: "ci-text-xs ci-opacity-80 ci-mt-1",
3969
- children: t.body
3970
- }),
3971
- /* @__PURE__ */ d("span", {
3972
- className: "ci-block ci-text-right ci-text-[10px] ci-leading-none ci-opacity-60 ci-mt-1",
3973
- children: ar(t.ts)
3974
- })
3975
- ]
3976
- }),
3977
- m && /* @__PURE__ */ d(mr, {
3978
- forMsg: o?.[m],
3979
- me: l,
3980
- mine: t.mine,
3981
- nameOf: b,
3982
- onReact: (e) => h && S(m, e)
3998
+ return /* @__PURE__ */ f("div", {
3999
+ "data-oid": t.oid,
4000
+ children: [i && /* @__PURE__ */ d("div", {
4001
+ className: "ci-text-center ci-text-xs ci-text-gray-500 dark:ci-text-gray-400 ci-py-2",
4002
+ children: sr(t.ts)
4003
+ }), /* @__PURE__ */ f("div", {
4004
+ className: `ci-group ci-flex ci-items-start ci-gap-1.5 ${t.mine ? "ci-justify-end" : "ci-justify-start"} ${s ? "ci-mt-0.5" : "ci-mt-2"}`,
4005
+ children: [
4006
+ c && /* @__PURE__ */ d("span", {
4007
+ className: "ci-w-7 ci-shrink-0",
4008
+ title: c,
4009
+ children: !s && /* @__PURE__ */ d(Un, {
4010
+ contact: m[t.nick],
4011
+ username: t.nick,
4012
+ size: 28
3983
4013
  })
3984
- ]
3985
- }),
3986
- !t.mine && v
3987
- ]
3988
- })] }, t.id);
4014
+ }),
4015
+ t.mine && S,
4016
+ t.mine && y,
4017
+ /* @__PURE__ */ f("div", {
4018
+ className: `ci-relative ci-flex ci-flex-col ci-max-w-[80%] ${t.mine ? "ci-items-end" : "ci-items-start"}`,
4019
+ children: [
4020
+ _ === h && h && /* @__PURE__ */ f("div", {
4021
+ role: "menu",
4022
+ onClick: (e) => e.stopPropagation(),
4023
+ className: `ci-absolute ci-bottom-full ci-mb-1 ci-z-20 ci-flex ci-items-center ci-gap-0.5 ci-p-1 ci-rounded-full ci-bg-gray-50 dark:ci-bg-gray-950 ci-shadow-xl ci-ring-1 ci-ring-gray-300 dark:ci-ring-gray-700 ${t.mine ? "ci-right-0" : "ci-left-0"}`,
4024
+ children: [er.map((e) => /* @__PURE__ */ d("button", {
4025
+ type: "button",
4026
+ role: "menuitem",
4027
+ "aria-label": e,
4028
+ onClick: () => C(h, e),
4029
+ style: {
4030
+ fontSize: 22,
4031
+ lineHeight: "32px"
4032
+ },
4033
+ className: `ci-h-9 ci-w-9 ci-flex ci-items-center ci-justify-center ci-rounded-full ci-border-0 hover:ci-scale-125 ci-transition-transform ${o?.[h]?.[l]?.includes(e) ? "ci-bg-gray-200 dark:ci-bg-gray-800" : "ci-bg-transparent"}`,
4034
+ children: e
4035
+ }, e)), /* @__PURE__ */ d("button", {
4036
+ type: "button",
4037
+ role: "menuitem",
4038
+ title: "More emojis",
4039
+ "aria-label": "More emojis",
4040
+ onClick: () => {
4041
+ v(null), b(h);
4042
+ },
4043
+ className: "ci-h-8 ci-w-8 ci-flex ci-items-center ci-justify-center ci-rounded-full ci-border-0 ci-bg-gray-200 dark:ci-bg-gray-800 ci-text-gray-700 dark:ci-text-gray-200 ci-text-lg",
4044
+ children: "+"
4045
+ })]
4046
+ }),
4047
+ /* @__PURE__ */ f("div", {
4048
+ title: or(t.ts),
4049
+ onDoubleClick: () => g && C(h, er[0]),
4050
+ className: `ci-px-3.5 ci-py-2 ci-rounded-3xl ci-text-sm ci-select-text ci-cursor-text ${t.mine ? "ci-bg-gray-700 ci-text-gray-50 dark:ci-bg-gray-300 dark:ci-text-gray-900 ci-rounded-br-lg" : "ci-bg-elevationL2 ci-text-gray-900 dark:ci-bg-elevationL2Dark dark:ci-text-white ci-rounded-bl-lg"} ${t.pending ? "ci-opacity-60" : ""}`,
4051
+ children: [
4052
+ t.reply && /* @__PURE__ */ d(gr, {
4053
+ reply: t.reply,
4054
+ messages: e,
4055
+ mine: t.mine,
4056
+ name: (e) => e === l ? "You" : x(e)
4057
+ }),
4058
+ t.oob ? /* @__PURE__ */ d(ur, { url: t.oob }) : lr(t.body) ? /* @__PURE__ */ d(mr, { ...lr(t.body) }) : /* @__PURE__ */ d(pr, { text: t.body }),
4059
+ t.oob && t.body && t.body !== t.oob && t.body !== ir(t.oob) && /* @__PURE__ */ d("div", {
4060
+ className: "ci-text-xs ci-opacity-80 ci-mt-1",
4061
+ children: t.body
4062
+ }),
4063
+ /* @__PURE__ */ d("span", {
4064
+ className: "ci-block ci-text-right ci-text-[10px] ci-leading-none ci-opacity-60 ci-mt-1",
4065
+ children: or(t.ts)
4066
+ })
4067
+ ]
4068
+ }),
4069
+ h && /* @__PURE__ */ d(hr, {
4070
+ forMsg: o?.[h],
4071
+ me: l,
4072
+ mine: t.mine,
4073
+ nameOf: x,
4074
+ onReact: (e) => g && C(h, e)
4075
+ })
4076
+ ]
4077
+ }),
4078
+ !t.mine && y,
4079
+ !t.mine && S
4080
+ ]
4081
+ })]
4082
+ }, t.id);
3989
4083
  }),
3990
4084
  t && /* @__PURE__ */ d("div", {
3991
4085
  className: "ci-flex ci-justify-start ci-mt-2",
@@ -3995,16 +4089,16 @@ function hr({ messages: e, typing: t, onLoadOlder: n, hasOlder: r, group: a, rea
3995
4089
  })
3996
4090
  })
3997
4091
  ]
3998
- }), v && /* @__PURE__ */ d(er, {
4092
+ }), y && /* @__PURE__ */ d(tr, {
3999
4093
  className: "ci-absolute ci-bottom-2 ci-left-1/2 ci--translate-x-1/2",
4000
- onPick: (e) => S(v, e),
4001
- onClose: () => y(null)
4094
+ onPick: (e) => C(y, e),
4095
+ onClose: () => b(null)
4002
4096
  })]
4003
4097
  });
4004
4098
  }
4005
4099
  //#endregion
4006
4100
  //#region src/ogg.ts
4007
- function gr(e, t, n) {
4101
+ function vr(e, t, n) {
4008
4102
  let r = e[t];
4009
4103
  if (r === void 0) return null;
4010
4104
  let i = 1;
@@ -4018,7 +4112,7 @@ function gr(e, t, n) {
4018
4112
  unknown: !n && o
4019
4113
  };
4020
4114
  }
4021
- var _r = /* @__PURE__ */ new Set([
4115
+ var yr = /* @__PURE__ */ new Set([
4022
4116
  408125543,
4023
4117
  524531317,
4024
4118
  374648427,
@@ -4026,18 +4120,18 @@ var _r = /* @__PURE__ */ new Set([
4026
4120
  225,
4027
4121
  160
4028
4122
  ]);
4029
- function vr(e) {
4123
+ function br(e) {
4030
4124
  let t = {
4031
4125
  channels: 1,
4032
4126
  packets: []
4033
4127
  }, n = 0;
4034
4128
  for (; n < e.length;) {
4035
- let r = gr(e, n, !0);
4129
+ let r = vr(e, n, !0);
4036
4130
  if (!r) break;
4037
- let i = gr(e, n + r.len, !1);
4131
+ let i = vr(e, n + r.len, !1);
4038
4132
  if (!i) break;
4039
4133
  let a = n + r.len + i.len;
4040
- if (_r.has(r.value)) {
4134
+ if (yr.has(r.value)) {
4041
4135
  n = a;
4042
4136
  continue;
4043
4137
  }
@@ -4046,14 +4140,14 @@ function vr(e) {
4046
4140
  if (r.value === 25506) t.head = e.slice(a, o);
4047
4141
  else if (r.value === 159) t.channels = e[a] || 1;
4048
4142
  else if (r.value === 163 || r.value === 161) {
4049
- let n = gr(e, a, !1);
4143
+ let n = vr(e, a, !1);
4050
4144
  n && (e[a + n.len + 2] >> 1 & 3 || t.packets.push(e.slice(a + n.len + 3, o)));
4051
4145
  }
4052
4146
  n = o;
4053
4147
  }
4054
4148
  return t;
4055
4149
  }
4056
- function yr(e) {
4150
+ function xr(e) {
4057
4151
  if (!e.length) return 0;
4058
4152
  let t = e[0], n = t >> 3, r;
4059
4153
  r = n < 12 ? [
@@ -4070,7 +4164,7 @@ function yr(e) {
4070
4164
  let i = t & 3, a = i === 0 ? 1 : i === 3 ? (e[1] ?? 0) & 63 : 2;
4071
4165
  return Math.round(a * r * 48);
4072
4166
  }
4073
- var br = (() => {
4167
+ var Sr = (() => {
4074
4168
  let e = /* @__PURE__ */ new Uint32Array(256);
4075
4169
  for (let t = 0; t < 256; t++) {
4076
4170
  let n = t << 24;
@@ -4079,12 +4173,12 @@ var br = (() => {
4079
4173
  }
4080
4174
  return e;
4081
4175
  })();
4082
- function xr(e) {
4176
+ function Cr(e) {
4083
4177
  let t = 0;
4084
- for (let n = 0; n < e.length; n++) t = (t << 8 ^ br[(t >>> 24 ^ e[n]) & 255]) >>> 0;
4178
+ for (let n = 0; n < e.length; n++) t = (t << 8 ^ Sr[(t >>> 24 ^ e[n]) & 255]) >>> 0;
4085
4179
  return t;
4086
4180
  }
4087
- function Sr(e, t, n, r, i) {
4181
+ function wr(e, t, n, r, i) {
4088
4182
  let a = [];
4089
4183
  for (let t of e) {
4090
4184
  let e = t.length;
@@ -4100,29 +4194,29 @@ function Sr(e, t, n, r, i) {
4100
4194
  ], 0), s[5] = i, c.setUint32(6, t % 4294967296, !0), c.setUint32(10, Math.floor(t / 4294967296), !0), c.setUint32(14, n, !0), c.setUint32(18, r, !0), s[26] = a.length, s.set(a, 27);
4101
4195
  let l = 27 + a.length;
4102
4196
  for (let t of e) s.set(t, l), l += t.length;
4103
- return c.setUint32(22, xr(s), !0), s;
4197
+ return c.setUint32(22, Cr(s), !0), s;
4104
4198
  }
4105
- function Cr(e) {
4199
+ function Tr(e) {
4106
4200
  let t = /* @__PURE__ */ new Uint8Array(19), n = new DataView(t.buffer);
4107
4201
  return t.set(new TextEncoder().encode("OpusHead"), 0), t[8] = 1, t[9] = e, n.setUint16(10, 312, !0), n.setUint32(12, 48e3, !0), t;
4108
4202
  }
4109
- function wr() {
4203
+ function Er() {
4110
4204
  let e = new TextEncoder().encode("chat-island"), t = new Uint8Array(12 + e.length + 4);
4111
4205
  return t.set(new TextEncoder().encode("OpusTags"), 0), new DataView(t.buffer).setUint32(8, e.length, !0), t.set(e, 12), t;
4112
4206
  }
4113
- function Tr(e) {
4114
- let { head: t, channels: n, packets: r } = vr(e);
4207
+ function Dr(e) {
4208
+ let { head: t, channels: n, packets: r } = br(e);
4115
4209
  if (!r.length) return null;
4116
- let i = t && t.length >= 19 && new TextDecoder().decode(t.slice(0, 8)) === "OpusHead", a = Math.random() * 4294967295 >>> 0, o = [Sr([i ? t : Cr(n)], 0, a, 0, 2), Sr([wr()], 0, a, 1, 0)], s = 0, c = 2;
4210
+ let i = t && t.length >= 19 && new TextDecoder().decode(t.slice(0, 8)) === "OpusHead", a = Math.random() * 4294967295 >>> 0, o = [wr([i ? t : Tr(n)], 0, a, 0, 2), wr([Er()], 0, a, 1, 0)], s = 0, c = 2;
4117
4211
  for (let e = 0; e < r.length;) {
4118
4212
  let t = [], n = 0;
4119
4213
  for (; e < r.length && t.length < 50;) {
4120
4214
  let i = Math.floor(r[e].length / 255) + 1;
4121
4215
  if (n + i > 255) break;
4122
- t.push(r[e]), n += i, s += yr(r[e]), e++;
4216
+ t.push(r[e]), n += i, s += xr(r[e]), e++;
4123
4217
  }
4124
4218
  if (!t.length) return null;
4125
- o.push(Sr(t, s, a, c++, e >= r.length ? 4 : 0));
4219
+ o.push(wr(t, s, a, c++, e >= r.length ? 4 : 0));
4126
4220
  }
4127
4221
  let l = o.reduce((e, t) => e + t.length, 0), u = new Uint8Array(l), d = 0;
4128
4222
  for (let e of o) u.set(e, d), d += e.length;
@@ -4130,98 +4224,100 @@ function Tr(e) {
4130
4224
  }
4131
4225
  //#endregion
4132
4226
  //#region src/components/Composer.tsx
4133
- var Er = [
4227
+ var Or = [
4134
4228
  "audio/ogg;codecs=opus",
4135
4229
  "audio/webm;codecs=opus",
4136
4230
  "audio/mp4",
4137
4231
  "audio/webm"
4138
4232
  ];
4139
- async function Dr(e, t) {
4233
+ async function kr(e, t) {
4140
4234
  let n = Date.now();
4141
4235
  if (/webm/.test(t) && /opus/.test(t)) try {
4142
- let t = Tr(new Uint8Array(await new Blob(e).arrayBuffer()));
4236
+ let t = Dr(new Uint8Array(await new Blob(e).arrayBuffer()));
4143
4237
  if (t) return new File([t], `voice-${n}.ogg`, { type: "audio/ogg" });
4144
4238
  } catch {}
4145
- return new File(e, `voice-${n}.${Or(t)}`, { type: t.split(";")[0] });
4239
+ return new File(e, `voice-${n}.${Ar(t)}`, { type: t.split(";")[0] });
4146
4240
  }
4147
- var Or = (e) => /mp4/.test(e) ? "m4a" : /ogg/.test(e) ? "ogg" : "webm", kr = (e) => `${Math.floor(e / 6e4)}:${String(Math.floor(e % 6e4 / 1e3)).padStart(2, "0")}`;
4148
- function Ar({ onSend: e, onTyping: t, onFile: n, disabled: r }) {
4149
- let [o, l] = c(""), [u, p] = c(!1), m = s(null), h = s(null), g = s(null), _ = s(), v = s(!1), [y, b] = c(null), [x, S] = c(0), C = s(!1), w = s(!1), T = s(!1), E = s({});
4150
- i(() => g.current?.focus(), []), i(() => () => {
4151
- T.current = !0, C.current = !0, window.clearTimeout(_.current);
4241
+ var Ar = (e) => /mp4/.test(e) ? "m4a" : /ogg/.test(e) ? "ogg" : "webm", jr = (e) => `${Math.floor(e / 6e4)}:${String(Math.floor(e % 6e4 / 1e3)).padStart(2, "0")}`;
4242
+ function Mr({ onSend: e, onTyping: t, onFile: n, disabled: r, focusKey: o }) {
4243
+ let [l, u] = c(""), [p, m] = c(!1), h = s(null), g = s(null), _ = s(null), v = s(), y = s(!1), [b, x] = c(null), [S, C] = c(0), w = s(!1), T = s(!1), ee = s(!1), E = s({});
4244
+ i(() => _.current?.focus(), []), i(() => () => {
4245
+ ee.current = !0, w.current = !0, window.clearTimeout(v.current);
4152
4246
  let { r: e, stream: t } = E.current;
4153
4247
  e && e.state !== "inactive" && e.stop(), t?.getTracks().forEach((e) => e.stop()), E.current = {};
4154
4248
  }, []), i(() => {
4155
- if (!y) return;
4156
- let e = window.setInterval(() => S(Date.now() - y.since), 250);
4249
+ if (!b) return;
4250
+ let e = window.setInterval(() => C(Date.now() - b.since), 250);
4157
4251
  return () => window.clearInterval(e);
4158
- }, [y]);
4252
+ }, [b]), i(() => {
4253
+ o && _.current?.focus();
4254
+ }, [o]);
4159
4255
  let D = (e) => {
4160
- v.current !== e && (v.current = e, t(e));
4256
+ y.current !== e && (y.current = e, t(e));
4161
4257
  }, O = (e) => {
4162
4258
  let t = e.includes(":") ? $(e) : e;
4163
- t !== e && (m.current = Math.max(0, (g.current?.selectionStart ?? e.length) - (e.length - t.length))), l(t), t ? (D(!0), window.clearTimeout(_.current), _.current = window.setTimeout(() => D(!1), 4e3)) : D(!1);
4259
+ t !== e && (h.current = Math.max(0, (_.current?.selectionStart ?? e.length) - (e.length - t.length))), u(t), t ? (D(!0), window.clearTimeout(v.current), v.current = window.setTimeout(() => D(!1), 4e3)) : D(!1);
4164
4260
  };
4165
4261
  a(() => {
4166
- m.current !== null && (g.current?.setSelectionRange(m.current, m.current), m.current = null);
4167
- }, [o]);
4168
- let ee = (e) => {
4169
- let t = g.current, n = t?.selectionStart ?? o.length, r = t?.selectionEnd ?? n;
4170
- O(o.slice(0, n) + e + o.slice(r)), requestAnimationFrame(() => {
4262
+ h.current !== null && (_.current?.setSelectionRange(h.current, h.current), h.current = null);
4263
+ }, [l]);
4264
+ let k = (e) => {
4265
+ let t = _.current, n = t?.selectionStart ?? l.length, r = t?.selectionEnd ?? n;
4266
+ O(l.slice(0, n) + e + l.slice(r)), requestAnimationFrame(() => {
4171
4267
  t?.focus(), t?.setSelectionRange(n + e.length, n + e.length);
4172
4268
  });
4173
- }, k = () => {
4174
- let t = o.trim();
4175
- t && (l(""), Promise.resolve(e(t)).catch(() => l((e) => e || t)), window.clearTimeout(_.current), v.current = !1);
4176
- }, te = async () => {
4177
- if (w.current || y) return;
4178
- w.current = !0;
4269
+ }, te = () => {
4270
+ let t = l.trim();
4271
+ t && (u(""), Promise.resolve(e(t)).catch(() => u((e) => e || t)), window.clearTimeout(v.current), y.current = !1);
4272
+ }, A = async () => {
4273
+ if (T.current || b) return;
4274
+ T.current = !0;
4179
4275
  let e;
4180
4276
  try {
4181
4277
  e = await navigator.mediaDevices.getUserMedia({ audio: !0 });
4182
4278
  let t = e;
4183
- if (T.current) {
4279
+ if (ee.current) {
4184
4280
  t.getTracks().forEach((e) => e.stop());
4185
4281
  return;
4186
4282
  }
4187
- let r = Er.find((e) => MediaRecorder.isTypeSupported(e)), i = new MediaRecorder(e, r ? { mimeType: r } : void 0), a = [];
4283
+ let r = Or.find((e) => MediaRecorder.isTypeSupported(e)), i = new MediaRecorder(e, r ? { mimeType: r } : void 0), a = [];
4188
4284
  i.ondataavailable = (e) => e.data.size && a.push(e.data), i.onstop = () => {
4189
- t.getTracks().forEach((e) => e.stop()), E.current = {}, b(null), !C.current && a.length && Dr(a, i.mimeType || r || "").then(n);
4190
- }, C.current = !1, i.start(), E.current = {
4285
+ t.getTracks().forEach((e) => e.stop()), E.current = {}, x(null), !w.current && a.length && kr(a, i.mimeType || r || "").then(n);
4286
+ }, w.current = !1, i.start(), E.current = {
4191
4287
  r: i,
4192
4288
  stream: t
4193
- }, S(0), b({
4289
+ }, C(0), x({
4194
4290
  r: i,
4195
4291
  since: Date.now()
4196
4292
  });
4197
4293
  } catch {
4198
4294
  e?.getTracks().forEach((e) => e.stop());
4199
4295
  } finally {
4200
- w.current = !1;
4296
+ T.current = !1;
4201
4297
  }
4202
- }, A = (e) => {
4203
- C.current = e, y?.r.stop();
4298
+ }, j = (e) => {
4299
+ w.current = e, b?.r.stop();
4204
4300
  };
4205
- return y ? /* @__PURE__ */ f("div", {
4301
+ return b ? /* @__PURE__ */ f("div", {
4206
4302
  className: "ci-flex ci-items-center ci-gap-2 ci-px-3 ci-py-3",
4207
4303
  children: [
4208
4304
  /* @__PURE__ */ d(Z, {
4209
4305
  variant: "transparent",
4210
4306
  title: "Discard",
4211
4307
  "aria-label": "Discard",
4212
- onClick: () => A(!0),
4308
+ onClick: () => j(!0),
4213
4309
  className: "ci-h-10 ci-w-10",
4214
4310
  children: Q.close
4215
4311
  }),
4216
4312
  /* @__PURE__ */ f("div", {
4217
4313
  className: "ci-flex-1 ci-flex ci-items-center ci-gap-2 ci-px-4 ci-py-2.5 ci-rounded-3xl ci-bg-elevationL2 dark:ci-bg-elevationL2Dark ci-text-sm",
4218
- children: [/* @__PURE__ */ d("span", { className: "ci-w-2.5 ci-h-2.5 ci-rounded-full ci-bg-phoneIslandClose dark:ci-bg-phoneIslandCloseDark ci-animate-pulse" }), /* @__PURE__ */ f("span", { children: ["Recording ", kr(x)] })]
4314
+ children: [/* @__PURE__ */ d("span", { className: "ci-w-2.5 ci-h-2.5 ci-rounded-full ci-bg-phoneIslandClose dark:ci-bg-phoneIslandCloseDark ci-animate-pulse" }), /* @__PURE__ */ f("span", { children: ["Recording ", jr(S)] })]
4219
4315
  }),
4220
4316
  /* @__PURE__ */ d(Z, {
4221
4317
  variant: "green",
4222
4318
  title: "Send voice note",
4223
4319
  "aria-label": "Send voice note",
4224
- onClick: () => A(!1),
4320
+ onClick: () => j(!1),
4225
4321
  className: "ci-h-10 ci-w-10",
4226
4322
  children: Q.send
4227
4323
  })
@@ -4229,13 +4325,13 @@ function Ar({ onSend: e, onTyping: t, onFile: n, disabled: r }) {
4229
4325
  }) : /* @__PURE__ */ f("div", {
4230
4326
  className: "ci-relative ci-flex ci-items-center ci-gap-2 ci-px-3 ci-py-3",
4231
4327
  children: [
4232
- u && /* @__PURE__ */ d(er, {
4328
+ p && /* @__PURE__ */ d(tr, {
4233
4329
  className: "ci-absolute ci-bottom-full ci-left-3 ci-mb-1",
4234
- onPick: ee,
4235
- onClose: () => p(!1)
4330
+ onPick: k,
4331
+ onClose: () => m(!1)
4236
4332
  }),
4237
4333
  /* @__PURE__ */ d("input", {
4238
- ref: h,
4334
+ ref: g,
4239
4335
  type: "file",
4240
4336
  hidden: !0,
4241
4337
  onChange: (e) => e.target.files?.[0] && (n(e.target.files[0]), e.target.value = "")
@@ -4244,7 +4340,7 @@ function Ar({ onSend: e, onTyping: t, onFile: n, disabled: r }) {
4244
4340
  variant: "transparent",
4245
4341
  disabled: r,
4246
4342
  title: "Attach a file",
4247
- onClick: () => h.current?.click(),
4343
+ onClick: () => g.current?.click(),
4248
4344
  className: "ci-h-10 ci-w-10",
4249
4345
  children: Q.clip
4250
4346
  }),
@@ -4255,36 +4351,36 @@ function Ar({ onSend: e, onTyping: t, onFile: n, disabled: r }) {
4255
4351
  disabled: r,
4256
4352
  title: "Emoji",
4257
4353
  "aria-label": "Emoji",
4258
- "aria-expanded": u,
4259
- onClick: () => p((e) => !e),
4354
+ "aria-expanded": p,
4355
+ onClick: () => m((e) => !e),
4260
4356
  className: "ci-absolute ci-left-2 ci-bottom-1 ci-z-10 ci-h-8 ci-w-8 ci-flex ci-items-center ci-justify-center ci-rounded-full ci-border-0 ci-bg-transparent ci-text-secondaryNeutral dark:ci-text-secondaryNeutralDark hover:ci-bg-gray-300/70 dark:hover:ci-bg-gray-700/30 disabled:ci-opacity-40",
4261
4357
  children: Q.smile
4262
4358
  }), /* @__PURE__ */ d("textarea", {
4263
- ref: g,
4264
- value: o,
4359
+ ref: _,
4360
+ value: l,
4265
4361
  disabled: r,
4266
4362
  rows: 1,
4267
4363
  placeholder: r ? "Connecting…" : "Write a message",
4268
4364
  onChange: (e) => O(e.target.value),
4269
4365
  onKeyDown: (e) => {
4270
- let t = (o.match(/```/g) ?? []).length % 2 == 1;
4271
- e.key === "Enter" && !e.shiftKey && !t && (e.preventDefault(), k());
4366
+ let t = (l.match(/```/g) ?? []).length % 2 == 1;
4367
+ e.key === "Enter" && !e.shiftKey && !t && (e.preventDefault(), te());
4272
4368
  },
4273
4369
  className: "ci-block ci-w-full ci-resize-none ci-max-h-32 ci-pl-11 ci-pr-4 ci-py-2.5 ci-rounded-3xl ci-border-0 ci-bg-elevationL2 dark:ci-bg-elevationL2Dark ci-text-gray-900 dark:ci-text-white placeholder:ci-text-gray-500 dark:placeholder:ci-text-gray-400 ci-outline-none focus:ci-ring-2 focus:ci-ring-gray-400 dark:focus:ci-ring-gray-500 ci-text-sm",
4274
- style: { height: Math.min(128, 40 + 20 * (o.split("\n").length - 1)) }
4370
+ style: { height: Math.min(128, 40 + 20 * (l.split("\n").length - 1)) }
4275
4371
  })]
4276
4372
  }),
4277
- o.trim() ? /* @__PURE__ */ d(Z, {
4373
+ l.trim() ? /* @__PURE__ */ d(Z, {
4278
4374
  variant: "default",
4279
4375
  disabled: r,
4280
- onClick: k,
4376
+ onClick: te,
4281
4377
  title: "Send",
4282
4378
  className: "ci-h-10 ci-w-10",
4283
4379
  children: Q.send
4284
4380
  }) : /* @__PURE__ */ d(Z, {
4285
4381
  variant: "default",
4286
4382
  disabled: r || typeof MediaRecorder > "u",
4287
- onClick: te,
4383
+ onClick: A,
4288
4384
  title: "Record a voice note",
4289
4385
  "aria-label": "Record a voice note",
4290
4386
  className: "ci-h-10 ci-w-10",
@@ -4295,14 +4391,14 @@ function Ar({ onSend: e, onTyping: t, onFile: n, disabled: r }) {
4295
4391
  }
4296
4392
  //#endregion
4297
4393
  //#region src/components/ChatWindow.tsx
4298
- var jr = (e) => !!e && ![
4394
+ var Nr = (e) => !!e && ![
4299
4395
  "offline",
4300
4396
  "dnd",
4301
4397
  "busy",
4302
4398
  "ringing",
4303
4399
  "onhold"
4304
4400
  ].includes(e);
4305
- function Mr({ peer: e, actions: t, onDragStart: n }) {
4401
+ function Pr({ peer: e, actions: t, onDragStart: n }) {
4306
4402
  let { c: r, contacts: a, online: o, mobile: s, status: l, closeChat: p, openChat: m, markRead: h, order: g, me: _ } = J(w((t) => ({
4307
4403
  c: t.conversations[e],
4308
4404
  contacts: t.contacts,
@@ -4314,16 +4410,28 @@ function Mr({ peer: e, actions: t, onDragStart: n }) {
4314
4410
  markRead: t.markRead,
4315
4411
  order: t.order,
4316
4412
  me: t.me
4317
- }))), v = Math.max(0, g.indexOf(e)), y = a[e], [b, x] = c(!1), S = (e) => e === _ ? "You" : a[e]?.name ?? e, C = [...r?.members ?? []].sort((e, t) => Number(e === _) - Number(t === _));
4318
- return i(() => {
4413
+ }))), v = Math.max(0, g.indexOf(e)), y = a[e], [b, x] = c(!1), [S, C] = c(null), [T, ee] = c(0), E = (e) => e === _ ? "You" : a[e]?.name ?? e, D = [...r?.members ?? []].sort((e, t) => Number(e === _) - Number(t === _));
4414
+ i(() => {
4319
4415
  r && !r.loaded && t.loadOlder(e);
4320
4416
  }, [e, r?.loaded]), i(() => {
4321
4417
  h(e);
4322
- }, [e, r?.messages.length]), i(() => x(!1), [e]), r ? /* @__PURE__ */ f("div", {
4418
+ }, [e, r?.messages.length]), i(() => {
4419
+ x(!1), C(null);
4420
+ }, [e]);
4421
+ let O = (t) => {
4422
+ if (!t.oid) return;
4423
+ let n = r?.kind === "group" ? t.nick ?? "" : t.mine ? _ : e, i = t.oob ? "Attachment" : t.body.replace(/```/g, "").replace(/\s+/g, " ").trim().slice(0, 100), o = n === _ ? J.getState().myName || _ : a[n]?.name ?? n;
4424
+ C({
4425
+ id: t.oid,
4426
+ author: n,
4427
+ quote: `${o}: ${i}`
4428
+ }), ee((e) => e + 1);
4429
+ };
4430
+ return r ? /* @__PURE__ */ f("div", {
4323
4431
  role: "dialog",
4324
4432
  "aria-label": r.kind === "group" ? r.name ?? e : y?.name ?? e,
4325
4433
  onKeyDown: (e) => {
4326
- e.key === "Escape" && (e.stopPropagation(), b ? x(!1) : p());
4434
+ e.key === "Escape" && (e.stopPropagation(), S ? C(null) : b ? x(!1) : p());
4327
4435
  },
4328
4436
  className: "ci-relative ci-w-[22rem] ci-h-[30rem] ci-flex ci-flex-col ci-rounded-3xl ci-shadow-2xl ci-bg-gray-50 dark:ci-bg-gray-950 ci-text-gray-900 dark:ci-text-white",
4329
4437
  children: [
@@ -4336,17 +4444,17 @@ function Mr({ peer: e, actions: t, onDragStart: n }) {
4336
4444
  className: `ci-flex ci-items-center ci-gap-3 ci-px-4 ci-py-3 ci-rounded-t-3xl ${n ? "ci-cursor-grab active:ci-cursor-grabbing ci-touch-none" : ""}`,
4337
4445
  onPointerDown: n,
4338
4446
  children: [
4339
- r.kind === "group" ? /* @__PURE__ */ d(Wn, {
4447
+ r.kind === "group" ? /* @__PURE__ */ d(Gn, {
4340
4448
  name: r.name ?? e,
4341
4449
  size: 36,
4342
4450
  avatar: r.avatar
4343
4451
  }) : /* @__PURE__ */ f("span", {
4344
4452
  className: "ci-relative",
4345
- children: [/* @__PURE__ */ d(Hn, {
4453
+ children: [/* @__PURE__ */ d(Un, {
4346
4454
  contact: y,
4347
4455
  username: e,
4348
4456
  size: 36
4349
- }), /* @__PURE__ */ d(Un, {
4457
+ }), /* @__PURE__ */ d(Wn, {
4350
4458
  online: o[e],
4351
4459
  presence: y?.presence,
4352
4460
  mobile: s[e]
@@ -4366,10 +4474,10 @@ function Mr({ peer: e, actions: t, onDragStart: n }) {
4366
4474
  children: r.kind === "group" ? r.name ?? e : y?.name ?? e
4367
4475
  }), /* @__PURE__ */ d("div", {
4368
4476
  className: "ci-text-xs ci-text-gray-500 dark:ci-text-gray-400 ci-truncate",
4369
- children: l === "online" ? r.kind === "group" ? C.map(S).join(", ") : r.typing ? "typing…" : o[e] ? "online" : s[e] ? "Mobile" : "offline" : l
4477
+ children: l === "online" ? r.kind === "group" ? D.map(E).join(", ") : r.typing ? "typing…" : o[e] ? "online" : s[e] ? "Mobile" : "offline" : l
4370
4478
  })]
4371
4479
  }),
4372
- r.kind !== "group" && y?.number && jr(y.presence) && /* @__PURE__ */ d(Z, {
4480
+ r.kind !== "group" && y?.number && Nr(y.presence) && /* @__PURE__ */ d(Z, {
4373
4481
  variant: "call",
4374
4482
  title: `Call ${y.number}`,
4375
4483
  "aria-label": "Call",
@@ -4382,24 +4490,25 @@ function Mr({ peer: e, actions: t, onDragStart: n }) {
4382
4490
  /* @__PURE__ */ d(Z, {
4383
4491
  variant: "small",
4384
4492
  onClick: () => p(),
4385
- "aria-label": "Close",
4386
- children: Q.close
4493
+ "aria-label": "Minimize",
4494
+ title: "Minimize",
4495
+ children: Q.minus
4387
4496
  })
4388
4497
  ]
4389
4498
  }),
4390
4499
  /* @__PURE__ */ d("div", { className: "ci-border-t ci-border-gray-300 dark:ci-border-gray-700" }),
4391
4500
  b && r.kind === "group" && /* @__PURE__ */ d("div", {
4392
4501
  className: "ci-absolute ci-left-3 ci-right-3 ci-top-16 ci-z-10 ci-max-h-64 ci-overflow-y-auto ci-rounded-2xl ci-bg-gray-50 dark:ci-bg-gray-950 ci-shadow-2xl ci-ring-1 ci-ring-gray-300 dark:ci-ring-gray-700 ci-p-2",
4393
- children: C.map((e) => /* @__PURE__ */ f("div", {
4502
+ children: D.map((e) => /* @__PURE__ */ f("div", {
4394
4503
  className: "ci-flex ci-items-center ci-gap-3 ci-px-2 ci-py-1.5 ci-text-sm",
4395
4504
  children: [
4396
4505
  /* @__PURE__ */ f("span", {
4397
4506
  className: "ci-relative",
4398
- children: [/* @__PURE__ */ d(Hn, {
4507
+ children: [/* @__PURE__ */ d(Un, {
4399
4508
  contact: a[e],
4400
4509
  username: e,
4401
4510
  size: 28
4402
- }), e !== _ && /* @__PURE__ */ d(Un, {
4511
+ }), e !== _ && /* @__PURE__ */ d(Wn, {
4403
4512
  online: o[e],
4404
4513
  presence: a[e]?.presence,
4405
4514
  mobile: s[e]
@@ -4407,7 +4516,7 @@ function Mr({ peer: e, actions: t, onDragStart: n }) {
4407
4516
  }),
4408
4517
  /* @__PURE__ */ d("span", {
4409
4518
  className: "ci-truncate ci-flex-1",
4410
- children: S(e)
4519
+ children: E(e)
4411
4520
  }),
4412
4521
  e !== _ && /* @__PURE__ */ f(u, { children: [/* @__PURE__ */ d(Z, {
4413
4522
  variant: "small",
@@ -4415,7 +4524,7 @@ function Mr({ peer: e, actions: t, onDragStart: n }) {
4415
4524
  "aria-label": "Chat",
4416
4525
  onClick: () => m(e),
4417
4526
  children: Q.chat
4418
- }), a[e]?.number && jr(a[e]?.presence) && /* @__PURE__ */ d(Z, {
4527
+ }), a[e]?.number && Nr(a[e]?.presence) && /* @__PURE__ */ d(Z, {
4419
4528
  variant: "call",
4420
4529
  title: `Call ${a[e]?.number}`,
4421
4530
  "aria-label": "Call",
@@ -4430,32 +4539,56 @@ function Mr({ peer: e, actions: t, onDragStart: n }) {
4430
4539
  }),
4431
4540
  /* @__PURE__ */ f("div", {
4432
4541
  className: "ci-flex-1 ci-min-h-0 ci-flex ci-flex-col ci-overflow-hidden ci-rounded-b-3xl",
4433
- children: [/* @__PURE__ */ d(hr, {
4434
- messages: r.messages,
4435
- typing: r.typing,
4436
- group: r.kind === "group",
4437
- hasOlder: r.loaded && !r.complete,
4438
- onLoadOlder: () => t.loadOlder(e),
4439
- reactions: r.reactions,
4440
- me: _,
4441
- onReact: (n, r) => t.react(e, n, r)
4442
- }), /* @__PURE__ */ d(Ar, {
4443
- disabled: l !== "online",
4444
- onSend: (n) => t.send(e, n),
4445
- onTyping: (n) => t.typing(e, n),
4446
- onFile: (n) => t.upload(e, n)
4447
- }, e)]
4542
+ children: [
4543
+ /* @__PURE__ */ d(_r, {
4544
+ messages: r.messages,
4545
+ typing: r.typing,
4546
+ group: r.kind === "group",
4547
+ hasOlder: r.loaded && !r.complete,
4548
+ onLoadOlder: () => t.loadOlder(e),
4549
+ reactions: r.reactions,
4550
+ me: _,
4551
+ onReact: (n, r) => t.react(e, n, r),
4552
+ onReply: O
4553
+ }),
4554
+ S && /* @__PURE__ */ f("div", {
4555
+ className: "ci-mx-3 ci-mt-1 ci-flex ci-items-center ci-gap-2 ci-pl-3 ci-pr-1 ci-py-1.5 ci-rounded-2xl ci-bg-elevationL2 dark:ci-bg-elevationL2Dark ci-border-0 ci-border-l-4 ci-border-solid ci-border-iconSecondary dark:ci-border-iconSecondaryDark",
4556
+ children: [/* @__PURE__ */ f("div", {
4557
+ className: "ci-flex-1 ci-min-w-0 ci-text-xs",
4558
+ children: [/* @__PURE__ */ d("div", {
4559
+ className: "ci-font-medium ci-text-gray-900 dark:ci-text-white",
4560
+ children: S.author === _ ? "You" : a[S.author]?.name ?? S.author
4561
+ }), /* @__PURE__ */ d("div", {
4562
+ className: "ci-truncate ci-text-gray-500 dark:ci-text-gray-400",
4563
+ children: S.quote?.replace(/^[^:]*: /, "")
4564
+ })]
4565
+ }), /* @__PURE__ */ d(Z, {
4566
+ variant: "small",
4567
+ onClick: () => C(null),
4568
+ "aria-label": "Cancel reply",
4569
+ title: "Cancel reply",
4570
+ children: Q.close
4571
+ })]
4572
+ }),
4573
+ /* @__PURE__ */ d(Mr, {
4574
+ focusKey: T,
4575
+ disabled: l !== "online",
4576
+ onSend: (n) => t.send(e, n, S ?? void 0).then(() => C(null)),
4577
+ onTyping: (n) => t.typing(e, n),
4578
+ onFile: (n) => t.upload(e, n)
4579
+ }, e)
4580
+ ]
4448
4581
  })
4449
4582
  ]
4450
4583
  }) : null;
4451
4584
  }
4452
4585
  //#endregion
4453
4586
  //#region src/components/NewChat.tsx
4454
- async function Nr(e) {
4587
+ async function Fr(e) {
4455
4588
  let t = await createImageBitmap(e), n = Math.min(t.width, t.height), r = document.createElement("canvas");
4456
4589
  return r.width = r.height = 128, r.getContext("2d")?.drawImage(t, (t.width - n) / 2, (t.height - n) / 2, n, n, 0, 0, 128, 128), r.toDataURL("image/jpeg", .8);
4457
4590
  }
4458
- function Pr({ onOpen: e, onCreateGroup: t }) {
4591
+ function Ir({ onOpen: e, onCreateGroup: t }) {
4459
4592
  let { contacts: n, online: r, mobile: i, setPicker: a } = J(), [l, p] = c(""), [m, h] = c([]), [g, _] = c(""), [v, y] = c(!1), [b, x] = c(), S = s(null), C = o(() => {
4460
4593
  let e = Object.values(n), t = l.trim().toLowerCase();
4461
4594
  return t ? e.filter((e) => (e.name ?? "").toLowerCase().includes(t) || e.username.includes(t)) : e;
@@ -4512,11 +4645,11 @@ function Pr({ onOpen: e, onCreateGroup: t }) {
4512
4645
  children: [
4513
4646
  /* @__PURE__ */ f("span", {
4514
4647
  className: "ci-relative",
4515
- children: [/* @__PURE__ */ d(Hn, {
4648
+ children: [/* @__PURE__ */ d(Un, {
4516
4649
  contact: e,
4517
4650
  username: e.username,
4518
4651
  size: 36
4519
- }), /* @__PURE__ */ d(Un, {
4652
+ }), /* @__PURE__ */ d(Wn, {
4520
4653
  online: r[e.username],
4521
4654
  presence: e.presence,
4522
4655
  mobile: i[e.username]
@@ -4563,7 +4696,7 @@ function Pr({ onOpen: e, onCreateGroup: t }) {
4563
4696
  type: "file",
4564
4697
  accept: "image/*",
4565
4698
  hidden: !0,
4566
- onChange: (e) => e.target.files?.[0] && Nr(e.target.files[0]).then(x).catch(() => {})
4699
+ onChange: (e) => e.target.files?.[0] && Fr(e.target.files[0]).then(x).catch(() => {})
4567
4700
  }),
4568
4701
  /* @__PURE__ */ d("button", {
4569
4702
  type: "button",
@@ -4598,22 +4731,22 @@ function Pr({ onOpen: e, onCreateGroup: t }) {
4598
4731
  }
4599
4732
  //#endregion
4600
4733
  //#region src/theme.ts
4601
- var Fr = "chat-island-theme", Ir = () => {
4734
+ var Lr = "chat-island-theme", Rr = () => {
4602
4735
  try {
4603
- let e = localStorage.getItem(Fr);
4736
+ let e = localStorage.getItem(Lr);
4604
4737
  return e === "light" || e === "dark" || e === "system" ? e : void 0;
4605
4738
  } catch {
4606
4739
  return;
4607
4740
  }
4608
4741
  };
4609
- function Lr(e) {
4610
- let [t, n] = c(() => e ?? Ir()), [r, a] = c(!1);
4611
- return i(() => n(e ?? Ir()), [e]), i(() => {
4742
+ function zr(e) {
4743
+ let [t, n] = c(() => e ?? Rr()), [r, a] = c(!1);
4744
+ return i(() => n(e ?? Rr()), [e]), i(() => {
4612
4745
  let e = (e) => {
4613
4746
  let t = e.detail?.theme;
4614
4747
  if (t === "light" || t === "dark" || t === "system") {
4615
4748
  try {
4616
- localStorage.setItem(Fr, t);
4749
+ localStorage.setItem(Lr, t);
4617
4750
  } catch {}
4618
4751
  n(t);
4619
4752
  }
@@ -4639,7 +4772,7 @@ function Lr(e) {
4639
4772
  }
4640
4773
  //#endregion
4641
4774
  //#region src/ChatIsland.tsx
4642
- function Rr() {
4775
+ function Br() {
4643
4776
  let e = J.getState();
4644
4777
  return Object.values(e.conversations).map((t) => {
4645
4778
  let n = t.messages[t.messages.length - 1], r = e.contacts[t.peer];
@@ -4654,7 +4787,7 @@ function Rr() {
4654
4787
  unread: t.unread,
4655
4788
  members: t.members,
4656
4789
  last: n ? {
4657
- body: Vr(n.body),
4790
+ body: Ur(n.body),
4658
4791
  ts: n.ts,
4659
4792
  mine: n.mine,
4660
4793
  oob: n.oob,
@@ -4663,7 +4796,7 @@ function Rr() {
4663
4796
  };
4664
4797
  }).filter((e) => e.last || e.kind === "group").sort((e, t) => (t.last?.ts ?? 0) - (e.last?.ts ?? 0));
4665
4798
  }
4666
- var zr = class extends t {
4799
+ var Vr = class extends t {
4667
4800
  state = { failed: !1 };
4668
4801
  failures = [];
4669
4802
  static getDerivedStateFromError() {
@@ -4681,7 +4814,7 @@ var zr = class extends t {
4681
4814
  return this.state.failed ? null : this.props.children;
4682
4815
  }
4683
4816
  };
4684
- function Br(e) {
4817
+ function Hr(e) {
4685
4818
  try {
4686
4819
  let [t, n, r] = atob(e).split(":");
4687
4820
  return t && n && r ? {
@@ -4693,9 +4826,9 @@ function Br(e) {
4693
4826
  return null;
4694
4827
  }
4695
4828
  }
4696
- var Vr = (e) => (cr(e) ? "Attachment" : $(e)).replace(/```[^\n]*\n?/g, "").replace(/(\*\*|__|~~|`)/g, "").replace(/(^|\s)[*_](\S[^*_]*)[*_]/g, "$1$2").replace(/\s+/g, " ").trim();
4697
- function Hr({ dataConfig: e, position: t = "bottom-right", theme: n, serviceWorker: r, maxHeads: a = 5, newChatButton: l = !0, notifications: u = "click", sound: p = !0, drag: m = !0, onDragStart: h }) {
4698
- let g = o(() => Br(e), [e]), _ = Lr(n), v = s(g), y = s(p), b = s(u);
4829
+ var Ur = (e) => (lr(e) ? "Attachment" : $(e)).replace(/```[^\n]*\n?/g, "").replace(/(\*\*|__|~~|`)/g, "").replace(/(^|\s)[*_](\S[^*_]*)[*_]/g, "$1$2").replace(/\s+/g, " ").trim();
4830
+ function Wr({ dataConfig: e, position: t = "bottom-right", theme: n, serviceWorker: r, maxHeads: a = 5, newChatButton: l = !0, notifications: u = "click", sound: p = !0, drag: m = !0, onDragStart: h }) {
4831
+ let g = o(() => Hr(e), [e]), _ = zr(n), v = s(g), y = s(p), b = s(u);
4699
4832
  i(() => {
4700
4833
  v.current = g, y.current = p, b.current = u;
4701
4834
  }, [
@@ -4711,16 +4844,16 @@ function Hr({ dataConfig: e, position: t = "bottom-right", theme: n, serviceWork
4711
4844
  let e = (e) => e.persisted && S((e) => e + 1);
4712
4845
  return window.addEventListener("pageshow", e), () => window.removeEventListener("pageshow", e);
4713
4846
  }, []);
4714
- let C = s(null), T = s(/* @__PURE__ */ new Set()), D = s(!1), O = s(null), ee = s(null), k = E(ee, `chat-island-pos:${g?.host ?? ""}:${g?.username ?? ""}`), { open: te, picker: A, status: j } = J(w((e) => ({
4847
+ let C = s(null), T = s(/* @__PURE__ */ new Set()), E = s(!1), D = s(null), O = s(null), k = ee(O, `chat-island-pos:${g?.host ?? ""}:${g?.username ?? ""}`), { open: te, picker: A, status: j } = J(w((e) => ({
4715
4848
  open: e.open,
4716
4849
  picker: e.picker,
4717
4850
  status: e.status
4718
- }))), ne = o(() => ({
4719
- send: async (e, t) => {
4720
- let n = C.current;
4721
- if (!n) throw Error("not connected");
4851
+ }))), M = o(() => ({
4852
+ send: async (e, t, n) => {
4853
+ let r = C.current;
4854
+ if (!r) throw Error("not connected");
4722
4855
  try {
4723
- J.getState().addMessage(e, await n.send(e, $(t)));
4856
+ J.getState().addMessage(e, await r.send(e, $(t), void 0, n));
4724
4857
  } catch (e) {
4725
4858
  throw Y("chat-island-error", {
4726
4859
  scope: "send",
@@ -4758,7 +4891,7 @@ function Hr({ dataConfig: e, position: t = "bottom-right", theme: n, serviceWork
4758
4891
  if (!t || !n) return;
4759
4892
  let r = J.getState().conversations[e];
4760
4893
  try {
4761
- r?.kind === "group" && await t.leaveGroup(e, !!r.owner).catch(() => {}), await In(n.host, n.token, e), J.getState().removeConversation(e);
4894
+ r?.kind === "group" && await t.leaveGroup(e, !!r.owner).catch(() => {}), await Ln(n.host, n.token, e), J.getState().removeConversation(e);
4762
4895
  } catch (e) {
4763
4896
  Y("chat-island-error", {
4764
4897
  scope: "delete",
@@ -4816,7 +4949,7 @@ function Hr({ dataConfig: e, position: t = "bottom-right", theme: n, serviceWork
4816
4949
  if (e.setStatus(n, a), Y("chat-island-status", {
4817
4950
  status: n,
4818
4951
  error: a
4819
- }), n === "online" && r && !D.current && typeof Notification < "u") {
4952
+ }), n === "online" && r && !E.current && typeof Notification < "u") {
4820
4953
  let e = Notification.permission;
4821
4954
  (e === "granted" || b.current === "auto" && e === "default") && i();
4822
4955
  }
@@ -4836,7 +4969,7 @@ function Hr({ dataConfig: e, position: t = "bottom-right", theme: n, serviceWork
4836
4969
  }).catch(() => {});
4837
4970
  },
4838
4971
  message: (r) => {
4839
- let i = jn(r);
4972
+ let i = Mn(r);
4840
4973
  r.room && !J.getState().conversations[r.room]?.name && t.groupInfo(r.room).then((t) => e.setGroup(t.peer, t.name, t.members, t.avatar, t.owner)).catch(() => {}), e.addMessage(i, r, { live: !0 }), Y("chat-island-message", {
4841
4974
  ...r,
4842
4975
  peer: i
@@ -4846,7 +4979,7 @@ function Hr({ dataConfig: e, position: t = "bottom-right", theme: n, serviceWork
4846
4979
  let n = J.getState(), r = document.visibilityState === "visible";
4847
4980
  if (r && n.open === e) return;
4848
4981
  let i = n.conversations[e], a = i?.kind === "group" ? i.name ?? e : n.contacts[e]?.name ?? e, o = t.oob ? "Attachment" : $(t.body), s = i?.kind === "group", c = s && t.nick ? n.contacts[t.nick]?.name ?? t.nick : a, l = s && t.nick ? `${c}: ${o}` : o;
4849
- y.current && Sn();
4982
+ y.current && Cn();
4850
4983
  let u = s ? i?.avatar : n.contacts[e]?.avatar;
4851
4984
  if (Y("chat-island-notify", {
4852
4985
  peer: e,
@@ -4870,16 +5003,16 @@ function Hr({ dataConfig: e, position: t = "bottom-right", theme: n, serviceWork
4870
5003
  };
4871
5004
  C.current = t;
4872
5005
  let i = () => {
4873
- r && !D.current && (D.current = !0, Bn(g, r).then((e) => {
5006
+ r && !E.current && (E.current = !0, Vn(g, r).then((e) => {
4874
5007
  if (!e) {
4875
- D.current = !1, J.setState({ push: Notification.permission === "denied" ? "denied" : "ask" });
5008
+ E.current = !1, J.setState({ push: Notification.permission === "denied" ? "denied" : "ask" });
4876
5009
  return;
4877
5010
  }
4878
5011
  return t.enablePush(e.service, e.node).then(() => {
4879
- O.current = e, J.setState({ push: "enabled" }), Y("chat-island-push", { enabled: !0 });
5012
+ D.current = e, J.setState({ push: "enabled" }), Y("chat-island-push", { enabled: !0 });
4880
5013
  });
4881
5014
  }).catch((e) => {
4882
- D.current = !1, Y("chat-island-error", {
5015
+ E.current = !1, Y("chat-island-error", {
4883
5016
  scope: "push",
4884
5017
  message: e.message
4885
5018
  });
@@ -4891,51 +5024,51 @@ function Hr({ dataConfig: e, position: t = "bottom-right", theme: n, serviceWork
4891
5024
  });
4892
5025
  let s = () => t.stop();
4893
5026
  window.addEventListener("pagehide", s), t.start();
4894
- let c = () => Fn(g.host, g.token).then(e.setMobile).catch(() => {});
5027
+ let c = () => In(g.host, g.token).then(e.setMobile).catch(() => {});
4895
5028
  c();
4896
5029
  let u = window.setInterval(c, 12e4);
4897
- Pn(g.host, g.token, g.username).then(e.setContacts).catch((e) => Y("chat-island-error", {
5030
+ Fn(g.host, g.token, g.username, (e) => J.setState({ myName: e })).then(e.setContacts).catch((e) => Y("chat-island-error", {
4898
5031
  scope: "contacts",
4899
5032
  message: e.message
4900
5033
  }));
4901
- let d = X("chat-island-open", ({ username: t }) => t && e.openChat(t)), f = X("chat-island-close", () => e.closeChat()), p = X("chat-island-new", () => e.setPicker(!0)), m = X("chat-island-delete", ({ username: e }) => e && ne.remove(e)), h = X("chat-island-contacts", ({ contacts: t }) => t && e.setContacts(t)), _ = X("chat-island-conversations-request", () => Y("chat-island-conversations", { conversations: Rr() }));
5034
+ let d = X("chat-island-open", ({ username: t }) => t && e.openChat(t)), f = X("chat-island-close", () => e.closeChat()), p = X("chat-island-new", () => e.setPicker(!0)), m = X("chat-island-delete", ({ username: e }) => e && M.remove(e)), h = X("chat-island-contacts", ({ contacts: t }) => t && e.setContacts(t)), _ = X("chat-island-conversations-request", () => Y("chat-island-conversations", { conversations: Br() }));
4902
5035
  return () => {
4903
- window.removeEventListener("pagehide", s), window.clearInterval(u), _(), p(), m(), d(), f(), h(), O.current && t.disablePush(O.current.service, O.current.node).catch(() => {}), O.current = null, t.stop(), C.current = null, D.current = !1;
5036
+ window.removeEventListener("pagehide", s), window.clearInterval(u), _(), p(), m(), d(), f(), h(), D.current && t.disablePush(D.current.service, D.current.node).catch(() => {}), D.current = null, t.stop(), C.current = null, E.current = !1;
4904
5037
  };
4905
5038
  }, [
4906
5039
  g,
4907
5040
  r,
4908
5041
  x
4909
5042
  ]);
4910
- let M = J((e) => Object.keys(e.contacts).join(","));
5043
+ let N = J((e) => Object.keys(e.contacts).join(","));
4911
5044
  i(() => {
4912
- j === "online" && M && C.current?.announce(M.split(","));
4913
- }, [j, M]);
4914
- let re = J((e) => Object.values(e.conversations).map((e) => `${e.peer}:${e.kind}:${e.name ?? ""}:${(e.members ?? []).length}:${e.unread}:${e.messages[e.messages.length - 1]?.id ?? ""}`).join("|") + "#" + Object.keys(e.contacts).length + "#" + Object.values(e.online).filter(Boolean).length);
4915
- i(() => Y("chat-island-conversations", { conversations: Rr() }), [re]);
4916
- let ie = J((e) => Object.values(e.conversations).reduce((e, t) => e + t.unread, 0));
4917
- if (i(() => Y("chat-island-unread", { total: ie }), [ie]), !g) return null;
4918
- let ae = m && !h && k.anchor ? {
5045
+ j === "online" && N && C.current?.announce(N.split(","));
5046
+ }, [j, N]);
5047
+ let ne = J((e) => Object.values(e.conversations).map((e) => `${e.peer}:${e.kind}:${e.name ?? ""}:${(e.members ?? []).length}:${e.unread}:${e.messages[e.messages.length - 1]?.id ?? ""}`).join("|") + "#" + Object.keys(e.contacts).length + "#" + Object.values(e.online).filter(Boolean).length);
5048
+ i(() => Y("chat-island-conversations", { conversations: Br() }), [ne]);
5049
+ let re = J((e) => Object.values(e.conversations).reduce((e, t) => e + t.unread, 0));
5050
+ if (i(() => Y("chat-island-unread", { total: re }), [re]), !g) return null;
5051
+ let ie = m && !h && k.anchor ? {
4919
5052
  right: k.anchor.right,
4920
5053
  bottom: k.anchor.bottom
4921
- } : void 0, oe = ae ? "" : t === "bottom-left" ? "ci-left-4 ci-bottom-5" : "ci-right-4 ci-bottom-5";
5054
+ } : void 0, ae = ie ? "" : t === "bottom-left" ? "ci-left-4 ci-bottom-5" : "ci-right-4 ci-bottom-5";
4922
5055
  return /* @__PURE__ */ d("div", {
4923
- ref: ee,
4924
- style: ae,
5056
+ ref: O,
5057
+ style: ie,
4925
5058
  onClickCapture: k.onClickCapture,
4926
- className: `chat-island-root ${_ ? "ci-dark" : ""} ci-fixed ${oe} ci-z-[9999] ci-flex ci-items-end ci-gap-3 ci-font-sans ci-select-none`,
5059
+ className: `chat-island-root ${_ ? "ci-dark" : ""} ci-fixed ${ae} ci-z-[9999] ci-flex ci-items-end ci-gap-3 ci-font-sans ci-select-none`,
4927
5060
  "data-status": j,
4928
- children: /* @__PURE__ */ f(zr, { children: [
4929
- te && /* @__PURE__ */ d(Mr, {
5061
+ children: /* @__PURE__ */ f(Vr, { children: [
5062
+ te && /* @__PURE__ */ d(Pr, {
4930
5063
  peer: te,
4931
- actions: ne,
5064
+ actions: M,
4932
5065
  onDragStart: h ?? (m ? k.start : void 0)
4933
5066
  }),
4934
- A && /* @__PURE__ */ d(Pr, {
5067
+ A && /* @__PURE__ */ d(Ir, {
4935
5068
  onOpen: (e) => J.getState().openChat(e),
4936
- onCreateGroup: ne.createGroup
5069
+ onCreateGroup: M.createGroup
4937
5070
  }),
4938
- /* @__PURE__ */ d(qn, {
5071
+ /* @__PURE__ */ d(Jn, {
4939
5072
  onDragStart: h ?? (m ? k.start : void 0),
4940
5073
  pushButton: u !== "auto"
4941
5074
  })
@@ -4943,4 +5076,4 @@ function Hr({ dataConfig: e, position: t = "bottom-right", theme: n, serviceWork
4943
5076
  });
4944
5077
  }
4945
5078
  //#endregion
4946
- export { Hr as ChatIsland };
5079
+ export { Wr as ChatIsland };