@nethesis/chat-island 0.1.14 → 0.1.15
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -1
- package/dist/components/Button.d.ts +5 -0
- package/dist/components/ChatWindow.d.ts +3 -1
- package/dist/events.d.ts +3 -0
- package/dist/index.css +1 -1
- package/dist/index.js +938 -770
- package/dist/theme.d.ts +1 -1
- package/dist-widget/index.widget.css +1 -1
- package/dist-widget/index.widget.js +6 -6
- package/package.json +7 -2
package/dist/index.js
CHANGED
|
@@ -471,7 +471,7 @@ var D = /* @__PURE__ */ y(((e) => {
|
|
|
471
471
|
});
|
|
472
472
|
else throw TypeError("The \"emitter\" argument must be of type EventEmitter. Received type " + typeof e);
|
|
473
473
|
}
|
|
474
|
-
})),
|
|
474
|
+
})), j = /* @__PURE__ */ y(((e, t) => {
|
|
475
475
|
var n = A(), r = D(), 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() {
|
|
@@ -565,14 +565,14 @@ var D = /* @__PURE__ */ y(((e) => {
|
|
|
565
565
|
e && this.write(e), this.write = function() {};
|
|
566
566
|
}
|
|
567
567
|
};
|
|
568
|
-
})),
|
|
568
|
+
})), M = D(), N = /* @__PURE__ */ x(O(), 1), P = /* @__PURE__ */ x(k(), 1), F = A(), ee = /* @__PURE__ */ x(j(), 1), te = 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
|
|
575
|
+
function ne(e) {
|
|
576
576
|
let t, n = new Promise((n) => {
|
|
577
577
|
t = setTimeout(n, e);
|
|
578
578
|
});
|
|
@@ -580,32 +580,32 @@ function re(e) {
|
|
|
580
580
|
}
|
|
581
581
|
//#endregion
|
|
582
582
|
//#region node_modules/@xmpp/events/lib/timeout.js
|
|
583
|
-
function
|
|
584
|
-
let n =
|
|
583
|
+
function re(e, t) {
|
|
584
|
+
let n = ne(t);
|
|
585
585
|
function r() {
|
|
586
586
|
clearTimeout(n.timeout);
|
|
587
587
|
}
|
|
588
|
-
let i = new
|
|
588
|
+
let i = new te();
|
|
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
|
|
596
|
-
function
|
|
597
|
-
let t =
|
|
595
|
+
var ie = /* @__PURE__ */ new WeakMap();
|
|
596
|
+
function I(e) {
|
|
597
|
+
let t = ie.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
|
-
},
|
|
602
|
+
}, ie.set(e, t)), t;
|
|
603
603
|
}
|
|
604
604
|
//#endregion
|
|
605
605
|
//#region node_modules/@xmpp/events/lib/promise.js
|
|
606
|
-
function
|
|
606
|
+
function L(e, t, n = "error", r) {
|
|
607
607
|
return new Promise((i, a) => {
|
|
608
|
-
let o, { off: s, once: c } =
|
|
608
|
+
let o, { off: s, once: c } = I(e), l = () => {
|
|
609
609
|
clearTimeout(o), s(t, d), s(n, u);
|
|
610
610
|
};
|
|
611
611
|
function u(e) {
|
|
@@ -615,7 +615,7 @@ function F(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
|
|
618
|
+
let e = new te();
|
|
619
619
|
o = setTimeout(() => {
|
|
620
620
|
l(), a(e);
|
|
621
621
|
}, r);
|
|
@@ -624,14 +624,14 @@ function F(e, t, n = "error", r) {
|
|
|
624
624
|
}
|
|
625
625
|
//#endregion
|
|
626
626
|
//#region node_modules/@xmpp/events/lib/Deferred.js
|
|
627
|
-
function
|
|
627
|
+
function ae() {
|
|
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
|
|
634
|
+
function oe(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,38 +651,38 @@ function ce(e, t = null, n) {
|
|
|
651
651
|
}
|
|
652
652
|
//#endregion
|
|
653
653
|
//#region node_modules/@xmpp/events/lib/listeners.js
|
|
654
|
-
function
|
|
654
|
+
function se(e) {
|
|
655
655
|
return {
|
|
656
656
|
subscribe(t) {
|
|
657
|
-
let { on: n } =
|
|
657
|
+
let { on: n } = I(t);
|
|
658
658
|
for (let [t, r] of Object.entries(e)) n(t, r);
|
|
659
659
|
},
|
|
660
660
|
unsubscribe(t) {
|
|
661
|
-
let { off: n } =
|
|
661
|
+
let { off: n } = I(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
|
|
668
|
+
var ce = class extends Error {
|
|
669
669
|
constructor(...e) {
|
|
670
670
|
super(...e), this.name = "XMLError";
|
|
671
671
|
}
|
|
672
|
-
},
|
|
672
|
+
}, le = class extends F.EventEmitter {
|
|
673
673
|
constructor() {
|
|
674
674
|
super();
|
|
675
|
-
let e = new
|
|
675
|
+
let e = new ee.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) {
|
|
679
|
-
let n = new
|
|
679
|
+
let n = new N.default(e, t), { root: r, cursor: i } = this;
|
|
680
680
|
r ? i !== r && i.append(n) : (this.root = n, this.emit("start", n)), this.cursor = n;
|
|
681
681
|
}
|
|
682
682
|
onEndElement(e) {
|
|
683
683
|
let { root: t, cursor: n } = this;
|
|
684
684
|
if (e !== n.name) {
|
|
685
|
-
this.emit("error", new
|
|
685
|
+
this.emit("error", new ce(`${n.name} must be closed.`));
|
|
686
686
|
return;
|
|
687
687
|
}
|
|
688
688
|
if (n === t) {
|
|
@@ -698,7 +698,7 @@ var ue = class extends Error {
|
|
|
698
698
|
onText(e) {
|
|
699
699
|
let { cursor: t } = this;
|
|
700
700
|
if (!t) {
|
|
701
|
-
this.emit("error", new
|
|
701
|
+
this.emit("error", new ce(`${e} must be a child.`));
|
|
702
702
|
return;
|
|
703
703
|
}
|
|
704
704
|
t.t(e);
|
|
@@ -710,37 +710,37 @@ var ue = class extends Error {
|
|
|
710
710
|
e && this.parser.write(e);
|
|
711
711
|
}
|
|
712
712
|
};
|
|
713
|
-
|
|
713
|
+
le.XMLError = ce;
|
|
714
714
|
//#endregion
|
|
715
715
|
//#region node_modules/@xmpp/xml/index.js
|
|
716
|
-
function
|
|
717
|
-
return (0,
|
|
718
|
-
}
|
|
719
|
-
Object.assign(
|
|
720
|
-
Element:
|
|
721
|
-
createElement:
|
|
722
|
-
Parser:
|
|
723
|
-
escapeXML:
|
|
724
|
-
unescapeXML:
|
|
725
|
-
escapeXMLText:
|
|
726
|
-
unescapeXMLText:
|
|
727
|
-
XMLError:
|
|
728
|
-
xml:
|
|
716
|
+
function R(...e) {
|
|
717
|
+
return (0, P.default)(...e);
|
|
718
|
+
}
|
|
719
|
+
Object.assign(R, {
|
|
720
|
+
Element: N.default,
|
|
721
|
+
createElement: P.default,
|
|
722
|
+
Parser: le,
|
|
723
|
+
escapeXML: M.escapeXML,
|
|
724
|
+
unescapeXML: M.unescapeXML,
|
|
725
|
+
escapeXMLText: M.escapeXMLText,
|
|
726
|
+
unescapeXMLText: M.unescapeXMLText,
|
|
727
|
+
XMLError: ce,
|
|
728
|
+
xml: R
|
|
729
729
|
});
|
|
730
730
|
//#endregion
|
|
731
731
|
//#region node_modules/@xmpp/jid/lib/escaping.js
|
|
732
|
-
function
|
|
732
|
+
function ue(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
|
|
735
|
+
function de(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
|
|
738
|
+
function fe(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
|
|
743
|
+
var z = 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 L = 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 ||=
|
|
762
|
+
return t ||= ue(e), t && (e = de(e)), this._local = e && e.toLowerCase(), this;
|
|
763
763
|
}
|
|
764
764
|
getLocal(e = !1) {
|
|
765
765
|
let t = null;
|
|
766
|
-
return t = e ?
|
|
766
|
+
return t = e ? fe(this._local) : this._local, t;
|
|
767
767
|
}
|
|
768
768
|
setDomain(e) {
|
|
769
769
|
return this._domain = e.toLowerCase(), this;
|
|
@@ -778,37 +778,37 @@ var L = class e {
|
|
|
778
778
|
return this._resource;
|
|
779
779
|
}
|
|
780
780
|
};
|
|
781
|
-
Object.defineProperty(
|
|
782
|
-
get:
|
|
783
|
-
set:
|
|
784
|
-
}), Object.defineProperty(
|
|
785
|
-
get:
|
|
786
|
-
set:
|
|
787
|
-
}), Object.defineProperty(
|
|
788
|
-
get:
|
|
789
|
-
set:
|
|
781
|
+
Object.defineProperty(z.prototype, "local", {
|
|
782
|
+
get: z.prototype.getLocal,
|
|
783
|
+
set: z.prototype.setLocal
|
|
784
|
+
}), Object.defineProperty(z.prototype, "domain", {
|
|
785
|
+
get: z.prototype.getDomain,
|
|
786
|
+
set: z.prototype.setDomain
|
|
787
|
+
}), Object.defineProperty(z.prototype, "resource", {
|
|
788
|
+
get: z.prototype.getResource,
|
|
789
|
+
set: z.prototype.setResource
|
|
790
790
|
});
|
|
791
791
|
//#endregion
|
|
792
792
|
//#region node_modules/@xmpp/jid/lib/parse.js
|
|
793
|
-
function
|
|
793
|
+
function pe(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
|
|
797
|
+
return i !== -1 && (t = e.slice(0, i), e = e.slice(i + 1)), new z(t, e, n);
|
|
798
798
|
}
|
|
799
799
|
//#endregion
|
|
800
800
|
//#region node_modules/@xmpp/jid/index.js
|
|
801
|
-
function
|
|
801
|
+
function me(e, t) {
|
|
802
802
|
return e.equals(t);
|
|
803
803
|
}
|
|
804
|
-
function
|
|
805
|
-
return !e[1] && !e[2] ?
|
|
804
|
+
function he(...e) {
|
|
805
|
+
return !e[1] && !e[2] ? pe(...e) : new z(...e);
|
|
806
806
|
}
|
|
807
|
-
var
|
|
808
|
-
|
|
807
|
+
var B = he.bind();
|
|
808
|
+
B.jid = he, B.JID = z, B.parse = pe, B.equal = me, B.detectEscape = ue, B.escapeLocal = de, B.unescapeLocal = fe;
|
|
809
809
|
//#endregion
|
|
810
810
|
//#region node_modules/@xmpp/error/index.js
|
|
811
|
-
var
|
|
811
|
+
var ge = 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 ve = 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
|
-
},
|
|
821
|
+
}, _e = class extends ge {
|
|
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
|
|
828
|
+
function ve(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 be(e) {
|
|
|
833
833
|
protocol: r
|
|
834
834
|
};
|
|
835
835
|
}
|
|
836
|
-
function
|
|
837
|
-
let { port: t, hostname: n } =
|
|
836
|
+
function ye(e) {
|
|
837
|
+
let { port: t, hostname: n } = ve(`http://${e}`);
|
|
838
838
|
return {
|
|
839
839
|
port: t,
|
|
840
840
|
hostname: n
|
|
841
841
|
};
|
|
842
842
|
}
|
|
843
|
-
function
|
|
844
|
-
return e.includes("://") ?
|
|
843
|
+
function be(e) {
|
|
844
|
+
return e.includes("://") ? ve(e) : ye(e);
|
|
845
845
|
}
|
|
846
846
|
//#endregion
|
|
847
847
|
//#region node_modules/@xmpp/connection/index.js
|
|
848
|
-
var
|
|
848
|
+
var xe = "urn:ietf:params:xml:ns:xmpp-streams", Se = "http://etherx.jabber.org/streams", Ce = class extends F.EventEmitter {
|
|
849
849
|
#e = null;
|
|
850
850
|
#t = null;
|
|
851
851
|
constructor(e = {}) {
|
|
@@ -856,7 +856,7 @@ var Ce = "urn:ietf:params:xml:ns:xmpp-streams", we = "http://etherx.jabber.org/s
|
|
|
856
856
|
}
|
|
857
857
|
async _streamError(e, t) {
|
|
858
858
|
try {
|
|
859
|
-
await this.send(
|
|
859
|
+
await this.send(R("stream:error", {}, [R(e, { xmlns: xe }, t)]));
|
|
860
860
|
} catch {}
|
|
861
861
|
return this.disconnect();
|
|
862
862
|
}
|
|
@@ -880,7 +880,7 @@ var Ce = "urn:ietf:params:xml:ns:xmpp-streams", we = "http://etherx.jabber.org/s
|
|
|
880
880
|
});
|
|
881
881
|
}
|
|
882
882
|
_attachSocket(e) {
|
|
883
|
-
this.socket = e, this.#e ??=
|
|
883
|
+
this.socket = e, this.#e ??= se({
|
|
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 Ce = "urn:ietf:params:xml:ns:xmpp-streams", we = "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",
|
|
894
|
+
let t = e.is("error", Se);
|
|
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 =
|
|
898
|
+
let t = _e.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 } =
|
|
903
|
+
let { protocol: t } = be(this.options.service), n = e.element.getChildText("see-other-host"), { port: r } = ye(n), i;
|
|
904
904
|
i = r ? `${t || "xmpp:"}//${n}` : (t ? `${t}//` : "") + n;
|
|
905
905
|
try {
|
|
906
|
-
await
|
|
906
|
+
await L(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 Ce = "urn:ietf:params:xml:ns:xmpp-streams", we = "http://etherx.jabber.org/s
|
|
|
914
914
|
}
|
|
915
915
|
}
|
|
916
916
|
_attachParser(e) {
|
|
917
|
-
this.parser = e, this.#t ??=
|
|
917
|
+
this.parser = e, this.#t ??= se({
|
|
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 Ce = "urn:ietf:params:xml:ns:xmpp-streams", we = "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 =
|
|
928
|
+
return this.jid = B(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 Ce = "urn:ietf:params:xml:ns:xmpp-streams", we = "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 =
|
|
954
|
+
let r = L(this, "online");
|
|
955
955
|
return await this.open({
|
|
956
956
|
domain: t,
|
|
957
957
|
lang: n
|
|
@@ -960,15 +960,15 @@ var Ce = "urn:ietf:params:xml:ns:xmpp-streams", we = "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)),
|
|
963
|
+
return this._attachSocket(t), t.connect(this.socketParameters(e)), L(t, "connect");
|
|
964
964
|
}
|
|
965
965
|
async _closeSocket(e = this.timeout) {
|
|
966
|
-
this._status("disconnecting"), this.socket.end(), await
|
|
966
|
+
this._status("disconnecting"), this.socket.end(), await L(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)),
|
|
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)), L(this, "open", "error", this.timeout);
|
|
972
972
|
}
|
|
973
973
|
async stop() {
|
|
974
974
|
let e = await this.disconnect();
|
|
@@ -977,7 +977,7 @@ var Ce = "urn:ietf:params:xml:ns:xmpp-streams", we = "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"),
|
|
980
|
+
return await this.write(t), this._status("closing"), L(this.parser, "end", "error", e);
|
|
981
981
|
}
|
|
982
982
|
async restart() {
|
|
983
983
|
this._detachParser();
|
|
@@ -991,7 +991,7 @@ var Ce = "urn:ietf:params:xml:ns:xmpp-streams", we = "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),
|
|
994
|
+
return Promise.all([this.send(e), L(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 Ce = "urn:ietf:params:xml:ns:xmpp-streams", we = "http://etherx.jabber.org/s
|
|
|
1010
1010
|
return e.toString();
|
|
1011
1011
|
}
|
|
1012
1012
|
headerElement() {
|
|
1013
|
-
return new
|
|
1013
|
+
return new R.Element("", {
|
|
1014
1014
|
version: "1.0",
|
|
1015
1015
|
xmlns: this.NS
|
|
1016
1016
|
});
|
|
@@ -1045,10 +1045,10 @@ var Ce = "urn:ietf:params:xml:ns:xmpp-streams", we = "http://etherx.jabber.org/s
|
|
|
1045
1045
|
}));
|
|
1046
1046
|
}
|
|
1047
1047
|
};
|
|
1048
|
-
|
|
1048
|
+
Ce.prototype.NS = "", Ce.prototype.Socket = null, Ce.prototype.Parser = null;
|
|
1049
1049
|
//#endregion
|
|
1050
1050
|
//#region node_modules/@xmpp/client-core/lib/Client.js
|
|
1051
|
-
var
|
|
1051
|
+
var we = class extends Ce {
|
|
1052
1052
|
constructor(e) {
|
|
1053
1053
|
super(e), this.transports = [];
|
|
1054
1054
|
}
|
|
@@ -1089,10 +1089,10 @@ var Ee = class extends Te {
|
|
|
1089
1089
|
return this.Transport.prototype.footerElement(...e);
|
|
1090
1090
|
}
|
|
1091
1091
|
};
|
|
1092
|
-
|
|
1092
|
+
we.prototype.NS = "jabber:client";
|
|
1093
1093
|
//#endregion
|
|
1094
1094
|
//#region node_modules/@xmpp/reconnect/index.js
|
|
1095
|
-
var
|
|
1095
|
+
var Te = class extends F.EventEmitter {
|
|
1096
1096
|
constructor(e) {
|
|
1097
1097
|
super(), this.delay = 1e3, this.entity = e, this._timeout = null;
|
|
1098
1098
|
}
|
|
@@ -1125,36 +1125,36 @@ var De = class extends P.EventEmitter {
|
|
|
1125
1125
|
e.removeListener("disconnect", this.#e), clearTimeout(t);
|
|
1126
1126
|
}
|
|
1127
1127
|
};
|
|
1128
|
-
function
|
|
1129
|
-
let t = new
|
|
1128
|
+
function Ee({ entity: e }) {
|
|
1129
|
+
let t = new Te(e);
|
|
1130
1130
|
return t.start(), t;
|
|
1131
1131
|
}
|
|
1132
1132
|
//#endregion
|
|
1133
1133
|
//#region node_modules/@xmpp/websocket/lib/Socket.js
|
|
1134
|
-
var
|
|
1135
|
-
function
|
|
1136
|
-
let t =
|
|
1134
|
+
var De = "ECONNERROR";
|
|
1135
|
+
function Oe(e) {
|
|
1136
|
+
let t = ve(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
|
|
1143
|
+
var ke = class extends F.EventEmitter {
|
|
1144
1144
|
#e = null;
|
|
1145
1145
|
socket = null;
|
|
1146
1146
|
url = null;
|
|
1147
1147
|
secure = !1;
|
|
1148
1148
|
connect(e) {
|
|
1149
|
-
this.url = e, this.secure =
|
|
1149
|
+
this.url = e, this.secure = Oe(e), this._attachSocket(new WebSocket(e, ["xmpp"]));
|
|
1150
1150
|
}
|
|
1151
1151
|
_attachSocket(e) {
|
|
1152
|
-
this.socket = e, this.#e ??=
|
|
1152
|
+
this.socket = e, this.#e ??= se({
|
|
1153
1153
|
open: () => this.emit("connect"),
|
|
1154
1154
|
message: ({ data: e }) => this.emit("data", e),
|
|
1155
1155
|
error: (e) => {
|
|
1156
1156
|
let { url: t } = this, { error: n } = e;
|
|
1157
|
-
n || (n = Error(e.message || `WebSocket ${
|
|
1157
|
+
n || (n = Error(e.message || `WebSocket ${De} ${t}`), n.errno = De, n.code = De), n.event = e, n.url = t, this.emit("error", n);
|
|
1158
1158
|
},
|
|
1159
1159
|
close: (e) => {
|
|
1160
1160
|
this._detachSocket(), this.emit("close", !e.wasClean, e);
|
|
@@ -1179,15 +1179,15 @@ var je = class extends P.EventEmitter {
|
|
|
1179
1179
|
}
|
|
1180
1180
|
n();
|
|
1181
1181
|
}
|
|
1182
|
-
},
|
|
1182
|
+
}, Ae = class extends le {
|
|
1183
1183
|
onStartElement(e, t) {
|
|
1184
|
-
let n = new
|
|
1184
|
+
let n = new N.default(e, t), { cursor: r } = this;
|
|
1185
1185
|
r && r.append(n), this.cursor = n;
|
|
1186
1186
|
}
|
|
1187
1187
|
onEndElement(e) {
|
|
1188
1188
|
let { cursor: t } = this;
|
|
1189
1189
|
if (e !== t.name) {
|
|
1190
|
-
this.emit("error", new
|
|
1190
|
+
this.emit("error", new ce(`${t.name} must be closed.`));
|
|
1191
1191
|
return;
|
|
1192
1192
|
}
|
|
1193
1193
|
if (t.parent) {
|
|
@@ -1196,7 +1196,7 @@ var je = class extends P.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
|
-
},
|
|
1199
|
+
}, je = "urn:ietf:params:xml:ns:xmpp-framing", Me = class extends Ce {
|
|
1200
1200
|
send(e, ...t) {
|
|
1201
1201
|
return e.attrs.xmlns ??= this.NS, super.send(e, ...t);
|
|
1202
1202
|
}
|
|
@@ -1204,27 +1204,27 @@ var je = class extends P.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
|
|
1207
|
+
return new R.Element("close", { xmlns: je });
|
|
1208
1208
|
}
|
|
1209
1209
|
headerElement() {
|
|
1210
1210
|
let e = super.headerElement();
|
|
1211
|
-
return e.name = "open", e.attrs.xmlns =
|
|
1211
|
+
return e.name = "open", e.attrs.xmlns = je, e;
|
|
1212
1212
|
}
|
|
1213
1213
|
socketParameters(e) {
|
|
1214
1214
|
return /^wss?:\/\//.test(e) ? e : void 0;
|
|
1215
1215
|
}
|
|
1216
1216
|
};
|
|
1217
|
-
|
|
1217
|
+
Me.prototype.Socket = ke, Me.prototype.NS = "jabber:client", Me.prototype.Parser = Ae;
|
|
1218
1218
|
//#endregion
|
|
1219
1219
|
//#region node_modules/@xmpp/websocket/index.js
|
|
1220
|
-
function
|
|
1221
|
-
e.transports.push(
|
|
1220
|
+
function Ne({ entity: e }) {
|
|
1221
|
+
e.transports.push(Me);
|
|
1222
1222
|
}
|
|
1223
1223
|
//#endregion
|
|
1224
1224
|
//#region __vite-browser-external
|
|
1225
|
-
var
|
|
1225
|
+
var Pe = /* @__PURE__ */ y(((e, t) => {
|
|
1226
1226
|
t.exports = {};
|
|
1227
|
-
})),
|
|
1227
|
+
})), Fe = /* @__PURE__ */ y(((e, t) => {
|
|
1228
1228
|
t.exports = n;
|
|
1229
1229
|
function n(e) {
|
|
1230
1230
|
if (!Array.isArray(e)) throw TypeError("Middleware stack must be an array!");
|
|
@@ -1245,40 +1245,40 @@ var Ie = /* @__PURE__ */ y(((e, t) => {
|
|
|
1245
1245
|
}
|
|
1246
1246
|
};
|
|
1247
1247
|
}
|
|
1248
|
-
})),
|
|
1248
|
+
})), V = /* @__PURE__ */ x(Pe(), 1), Ie = /* @__PURE__ */ x(Fe(), 1), Le = class {
|
|
1249
1249
|
constructor(e, t) {
|
|
1250
1250
|
this.stanza = t, this.entity = e;
|
|
1251
1251
|
let { name: n, attrs: r } = t, { type: i, id: a } = r;
|
|
1252
1252
|
this.name = n, this.id = a || "", this.type = n === "message" ? i || "normal" : n === "presence" ? i || "available" : i || "", this.from = null, this.to = null, this.local = "", this.domain = "", this.resource = "";
|
|
1253
1253
|
}
|
|
1254
|
-
},
|
|
1254
|
+
}, Re = class extends Le {
|
|
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
|
|
1258
|
+
i && (this.to = new B(i)), a && (this.from = new B(a), this.local = this.from.local, this.domain = this.from.domain, this.resource = this.from.resource);
|
|
1259
1259
|
}
|
|
1260
|
-
},
|
|
1260
|
+
}, ze = class extends Le {
|
|
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
|
|
1264
|
+
i && (this.from = new B(i)), a && (this.to = new B(a), this.local = this.to.local, this.domain = this.to.domain, this.resource = this.to.resource);
|
|
1265
1265
|
}
|
|
1266
1266
|
};
|
|
1267
1267
|
//#endregion
|
|
1268
1268
|
//#region node_modules/@xmpp/middleware/index.js
|
|
1269
|
-
function
|
|
1269
|
+
function Be(e, t, n) {
|
|
1270
1270
|
return (r) => {
|
|
1271
1271
|
let i = new n(e, r);
|
|
1272
|
-
return (0,
|
|
1272
|
+
return (0, Ie.default)(t)(i);
|
|
1273
1273
|
};
|
|
1274
1274
|
}
|
|
1275
|
-
function
|
|
1275
|
+
function Ve(e) {
|
|
1276
1276
|
return (t, n) => {
|
|
1277
1277
|
n().then((t) => t && e.send(t)).catch((t) => e.emit("error", t));
|
|
1278
1278
|
};
|
|
1279
1279
|
}
|
|
1280
|
-
function
|
|
1281
|
-
let t = [
|
|
1280
|
+
function He({ entity: e }) {
|
|
1281
|
+
let t = [Ve(e)], n = [], r = Be(e, t, Re), i = Be(e, n, ze);
|
|
1282
1282
|
return e.on("element", r), e.on("send", i), {
|
|
1283
1283
|
use(e) {
|
|
1284
1284
|
return t.push(e), e;
|
|
@@ -1290,7 +1290,7 @@ function We({ entity: e }) {
|
|
|
1290
1290
|
}
|
|
1291
1291
|
//#endregion
|
|
1292
1292
|
//#region node_modules/@xmpp/stream-features/index.js
|
|
1293
|
-
function
|
|
1293
|
+
function Ue({ middleware: e }) {
|
|
1294
1294
|
function t(t, n, r) {
|
|
1295
1295
|
return e.use((e, i) => {
|
|
1296
1296
|
let { stanza: a } = e;
|
|
@@ -1303,14 +1303,14 @@ function Ge({ middleware: e }) {
|
|
|
1303
1303
|
}
|
|
1304
1304
|
//#endregion
|
|
1305
1305
|
//#region node_modules/@xmpp/id/index.js
|
|
1306
|
-
function
|
|
1306
|
+
function We() {
|
|
1307
1307
|
let e;
|
|
1308
1308
|
for (; !e;) e = Math.random().toString(36).slice(2, 12);
|
|
1309
1309
|
return e;
|
|
1310
1310
|
}
|
|
1311
1311
|
//#endregion
|
|
1312
1312
|
//#region node_modules/@xmpp/middleware/lib/StanzaError.js
|
|
1313
|
-
var
|
|
1313
|
+
var Ge = class extends ge {
|
|
1314
1314
|
constructor(e, t, n, r) {
|
|
1315
1315
|
super(e, t, n), this.type = r, this.name = "StanzaError";
|
|
1316
1316
|
}
|
|
@@ -1321,10 +1321,10 @@ var qe = class extends ve {
|
|
|
1321
1321
|
};
|
|
1322
1322
|
//#endregion
|
|
1323
1323
|
//#region node_modules/@xmpp/iq/caller.js
|
|
1324
|
-
function
|
|
1324
|
+
function Ke({ name: e, type: t }) {
|
|
1325
1325
|
return !(e !== "iq" || t !== "error" && t !== "result");
|
|
1326
1326
|
}
|
|
1327
|
-
var
|
|
1327
|
+
var qe = class {
|
|
1328
1328
|
constructor({ entity: e, middleware: t }) {
|
|
1329
1329
|
this.handlers = /* @__PURE__ */ new Map(), this.entity = e, this.middleware = t;
|
|
1330
1330
|
}
|
|
@@ -1332,20 +1332,20 @@ var Ye = class {
|
|
|
1332
1332
|
this.middleware.use(this._route.bind(this));
|
|
1333
1333
|
}
|
|
1334
1334
|
_route({ type: e, name: t, id: n, stanza: r }, i) {
|
|
1335
|
-
if (!
|
|
1335
|
+
if (!Ke({
|
|
1336
1336
|
name: t,
|
|
1337
1337
|
type: e
|
|
1338
1338
|
})) return i();
|
|
1339
1339
|
let a = this.handlers.get(n);
|
|
1340
1340
|
if (!a) return i();
|
|
1341
|
-
e === "error" ? a.reject(
|
|
1341
|
+
e === "error" ? a.reject(Ge.fromElement(r.getChild("error"))) : a.resolve(r), this.handlers.delete(n);
|
|
1342
1342
|
}
|
|
1343
1343
|
async request(e, t = 3e4) {
|
|
1344
|
-
e.attrs.id || (e.attrs.id =
|
|
1345
|
-
let n = new
|
|
1344
|
+
e.attrs.id || (e.attrs.id = We());
|
|
1345
|
+
let n = new ae();
|
|
1346
1346
|
this.handlers.set(e.attrs.id, n);
|
|
1347
1347
|
try {
|
|
1348
|
-
await this.entity.send(e), await
|
|
1348
|
+
await this.entity.send(e), await re(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(
|
|
1356
|
+
return this.request(R("iq", {
|
|
1357
1357
|
type: e,
|
|
1358
1358
|
to: n
|
|
1359
1359
|
}, t), ...r).then((e) => e.getChild(i, a));
|
|
@@ -1365,71 +1365,71 @@ var Ye = class {
|
|
|
1365
1365
|
return this._childRequest("set", ...e);
|
|
1366
1366
|
}
|
|
1367
1367
|
};
|
|
1368
|
-
function
|
|
1369
|
-
let t = new
|
|
1368
|
+
function Je(...e) {
|
|
1369
|
+
let t = new qe(...e);
|
|
1370
1370
|
return t.start(), t;
|
|
1371
1371
|
}
|
|
1372
1372
|
//#endregion
|
|
1373
1373
|
//#region node_modules/@xmpp/iq/callee.js
|
|
1374
|
-
var
|
|
1375
|
-
function
|
|
1374
|
+
var Ye = "urn:ietf:params:xml:ns:xmpp-stanzas";
|
|
1375
|
+
function Xe({ name: e, type: t }) {
|
|
1376
1376
|
return e === "iq" && t !== "error" && t !== "result";
|
|
1377
1377
|
}
|
|
1378
|
-
function
|
|
1378
|
+
function Ze({ type: e }, t, n) {
|
|
1379
1379
|
return !(e !== "get" && e !== "set" || t.length !== 1 || !n);
|
|
1380
1380
|
}
|
|
1381
|
-
function
|
|
1382
|
-
return
|
|
1381
|
+
function Qe({ stanza: e }) {
|
|
1382
|
+
return R("iq", {
|
|
1383
1383
|
to: e.attrs.from,
|
|
1384
1384
|
from: e.attrs.to,
|
|
1385
1385
|
id: e.attrs.id
|
|
1386
1386
|
});
|
|
1387
1387
|
}
|
|
1388
|
-
function
|
|
1389
|
-
let n =
|
|
1388
|
+
function $e(e, t) {
|
|
1389
|
+
let n = Qe(e);
|
|
1390
1390
|
return n.attrs.type = "result", t && n.append(t), n;
|
|
1391
1391
|
}
|
|
1392
|
-
function
|
|
1393
|
-
let r =
|
|
1392
|
+
function et(e, t, n) {
|
|
1393
|
+
let r = Qe(e);
|
|
1394
1394
|
return r.attrs.type = "error", n && r.append(n), r.append(t), r;
|
|
1395
1395
|
}
|
|
1396
|
-
function
|
|
1397
|
-
return
|
|
1396
|
+
function tt(e, t) {
|
|
1397
|
+
return R("error", { type: e }, R(t, Ye));
|
|
1398
1398
|
}
|
|
1399
|
-
function
|
|
1399
|
+
function nt(e) {
|
|
1400
1400
|
return async function(t, n) {
|
|
1401
|
-
if (!
|
|
1401
|
+
if (!Xe(t)) return n();
|
|
1402
1402
|
let { stanza: r } = t, i = r.getChildElements(), [a] = i;
|
|
1403
|
-
if (
|
|
1403
|
+
if (!Ze(t, i, a)) return et(t, tt("modify", "bad-request"), a);
|
|
1404
1404
|
t.element = a;
|
|
1405
1405
|
let o;
|
|
1406
1406
|
try {
|
|
1407
1407
|
o = await n();
|
|
1408
1408
|
} catch (t) {
|
|
1409
|
-
e.emit("error", t), o =
|
|
1409
|
+
e.emit("error", t), o = tt("cancel", "internal-server-error");
|
|
1410
1410
|
}
|
|
1411
|
-
return o ||=
|
|
1411
|
+
return o ||= tt("cancel", "service-unavailable"), o instanceof R.Element && o.is("error") ? et(t, o, a) : $e(t, o instanceof R.Element ? o : void 0);
|
|
1412
1412
|
};
|
|
1413
1413
|
}
|
|
1414
|
-
function
|
|
1414
|
+
function rt(e, t, n, r) {
|
|
1415
1415
|
return (i, a) => i.type !== e | !i.element || !i.element.is(n, t) ? a() : r(i, a);
|
|
1416
1416
|
}
|
|
1417
|
-
function
|
|
1418
|
-
return e.use(
|
|
1417
|
+
function it({ middleware: e, entity: t }) {
|
|
1418
|
+
return e.use(nt(t)), {
|
|
1419
1419
|
get(t, n, r) {
|
|
1420
|
-
e.use(
|
|
1420
|
+
e.use(rt("get", t, n, r));
|
|
1421
1421
|
},
|
|
1422
1422
|
set(t, n, r) {
|
|
1423
|
-
e.use(
|
|
1423
|
+
e.use(rt("set", t, n, r));
|
|
1424
1424
|
}
|
|
1425
1425
|
};
|
|
1426
1426
|
}
|
|
1427
1427
|
//#endregion
|
|
1428
1428
|
//#region node_modules/@xmpp/resolve/lib/dns.js
|
|
1429
|
-
var
|
|
1430
|
-
function
|
|
1429
|
+
var at = ["ENOTFOUND", "ENODATA"];
|
|
1430
|
+
function ot(e, t = {}) {
|
|
1431
1431
|
return t.all = !0, new Promise((n, r) => {
|
|
1432
|
-
|
|
1432
|
+
V.default.lookup(e, t, (e, t) => {
|
|
1433
1433
|
if (e) return r(e);
|
|
1434
1434
|
let i = [];
|
|
1435
1435
|
for (let { family: e, address: n } of t) {
|
|
@@ -1448,17 +1448,17 @@ function ct(e, t = {}) {
|
|
|
1448
1448
|
});
|
|
1449
1449
|
});
|
|
1450
1450
|
}
|
|
1451
|
-
function
|
|
1451
|
+
function st(e, { service: t, protocol: n }) {
|
|
1452
1452
|
return new Promise((r, i) => {
|
|
1453
|
-
|
|
1454
|
-
e &&
|
|
1453
|
+
V.default.resolveSrv(`_${t}._${n}.${e}`, (e, a) => {
|
|
1454
|
+
e && at.includes(e.code) ? r([]) : e ? i(e) : r(a.map((e) => Object.assign(e, {
|
|
1455
1455
|
service: t,
|
|
1456
1456
|
protocol: n
|
|
1457
1457
|
})));
|
|
1458
1458
|
});
|
|
1459
1459
|
});
|
|
1460
1460
|
}
|
|
1461
|
-
function
|
|
1461
|
+
function ct(e) {
|
|
1462
1462
|
return e.toSorted((e, t) => {
|
|
1463
1463
|
let n = e.priority - t.priority;
|
|
1464
1464
|
if (n !== 0) return n;
|
|
@@ -1466,10 +1466,10 @@ function ut(e) {
|
|
|
1466
1466
|
return r === 0 ? 0 : r;
|
|
1467
1467
|
});
|
|
1468
1468
|
}
|
|
1469
|
-
function
|
|
1469
|
+
function lt(e, t) {
|
|
1470
1470
|
let n = [];
|
|
1471
1471
|
return Promise.all(e.map(async (e) => {
|
|
1472
|
-
let r = await
|
|
1472
|
+
let r = await ot(e.name, t);
|
|
1473
1473
|
for (let t of r) {
|
|
1474
1474
|
let { port: r, service: i } = e, a = t.address;
|
|
1475
1475
|
n.push({
|
|
@@ -1480,7 +1480,7 @@ function dt(e, t) {
|
|
|
1480
1480
|
}
|
|
1481
1481
|
})).then(() => n);
|
|
1482
1482
|
}
|
|
1483
|
-
function
|
|
1483
|
+
function ut(e, t = {}) {
|
|
1484
1484
|
t.srv ||= [
|
|
1485
1485
|
{
|
|
1486
1486
|
service: "xmpps-client",
|
|
@@ -1524,15 +1524,15 @@ function ft(e, t = {}) {
|
|
|
1524
1524
|
}
|
|
1525
1525
|
];
|
|
1526
1526
|
let n = { options: t };
|
|
1527
|
-
return
|
|
1527
|
+
return ot(e, t).then((r) => Promise.all(t.srv.map((r) => st(e, {
|
|
1528
1528
|
...r,
|
|
1529
1529
|
family: n
|
|
1530
|
-
}).then((e) =>
|
|
1530
|
+
}).then((e) => lt(e, t)))).then((e) => [...ct(e.flat()), ...r]));
|
|
1531
1531
|
}
|
|
1532
1532
|
//#endregion
|
|
1533
1533
|
//#region node_modules/@xmpp/xml/lib/parse.js
|
|
1534
|
-
function
|
|
1535
|
-
let t = new
|
|
1534
|
+
function dt(e) {
|
|
1535
|
+
let t = new le(), n = null, r = null;
|
|
1536
1536
|
if (t.on("start", (e) => {
|
|
1537
1537
|
n = e;
|
|
1538
1538
|
}), t.on("element", (e) => {
|
|
@@ -1544,19 +1544,19 @@ function pt(e) {
|
|
|
1544
1544
|
}
|
|
1545
1545
|
//#endregion
|
|
1546
1546
|
//#region node_modules/@xmpp/resolve/lib/alt-connections.js
|
|
1547
|
-
function
|
|
1547
|
+
function ft(e) {
|
|
1548
1548
|
return e.startsWith("https") || e.startsWith("wss");
|
|
1549
1549
|
}
|
|
1550
|
-
function
|
|
1550
|
+
function pt(e, t) {
|
|
1551
1551
|
let n;
|
|
1552
|
-
if (n =
|
|
1552
|
+
if (n = ft(e.uri) && !ft(t.uri) ? -1 : !ft(e.uri) && ft(t.uri) ? 1 : 0, n !== 0) return n;
|
|
1553
1553
|
let r;
|
|
1554
1554
|
return r = e.method === t.method ? 0 : e.method === "websocket" ? -1 : t.method === "websocket" ? 1 : e.method === "xbosh" ? -1 : t.method === "xbosh" ? 1 : e.method === "httppoll" ? -1 : +(t.method === "httppoll"), r === 0 ? 0 : r;
|
|
1555
1555
|
}
|
|
1556
1556
|
//#endregion
|
|
1557
1557
|
//#region node_modules/@xmpp/resolve/lib/http.js
|
|
1558
|
-
function
|
|
1559
|
-
return fetch(`https://${e}/.well-known/host-meta`).then((e) => e.text()).then((e) =>
|
|
1558
|
+
function mt(e) {
|
|
1559
|
+
return fetch(`https://${e}/.well-known/host-meta`).then((e) => e.text()).then((e) => dt(e).getChildren("Link").filter((e) => [
|
|
1560
1560
|
"urn:xmpp:alt-connections:websocket",
|
|
1561
1561
|
"urn:xmpp:alt-connections:httppoll",
|
|
1562
1562
|
"urn:xmpp:alt-connections:xbosh"
|
|
@@ -1565,17 +1565,17 @@ function gt(e) {
|
|
|
1565
1565
|
href: e.href,
|
|
1566
1566
|
method: e.rel.split(":").pop(),
|
|
1567
1567
|
uri: e.href
|
|
1568
|
-
})).toSorted(
|
|
1568
|
+
})).toSorted(pt)).catch(() => []);
|
|
1569
1569
|
}
|
|
1570
1570
|
//#endregion
|
|
1571
1571
|
//#region node_modules/@xmpp/resolve/resolve.js
|
|
1572
|
-
function
|
|
1573
|
-
return Promise.all([
|
|
1572
|
+
function ht(...e) {
|
|
1573
|
+
return Promise.all([ut ? ut(...e) : Promise.resolve([]), mt(...e)]).then(([e, t]) => [...e, ...t]);
|
|
1574
1574
|
}
|
|
1575
1575
|
//#endregion
|
|
1576
1576
|
//#region node_modules/@xmpp/resolve/index.js
|
|
1577
|
-
async function
|
|
1578
|
-
let t = await
|
|
1577
|
+
async function gt(e) {
|
|
1578
|
+
let t = await ht(e, { srv: [{
|
|
1579
1579
|
service: "xmpps-client",
|
|
1580
1580
|
protocol: "tcp"
|
|
1581
1581
|
}, {
|
|
@@ -1584,30 +1584,30 @@ async function vt(e) {
|
|
|
1584
1584
|
}] });
|
|
1585
1585
|
return [...new Set(t.map((e) => e.uri))];
|
|
1586
1586
|
}
|
|
1587
|
-
function
|
|
1587
|
+
function _t(e, t) {
|
|
1588
1588
|
return t.filter((t) => e._findTransport(t));
|
|
1589
1589
|
}
|
|
1590
|
-
async function
|
|
1590
|
+
async function vt(e, t) {
|
|
1591
1591
|
if (t.length === 0) throw Error("Couldn't connect");
|
|
1592
1592
|
let n = t.shift(), r = e._findTransport(n);
|
|
1593
|
-
if (!r) return
|
|
1593
|
+
if (!r) return vt(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
|
|
1597
|
+
a.connect(i), await L(a, "connect");
|
|
1598
1598
|
} catch {
|
|
1599
|
-
return
|
|
1599
|
+
return vt(e, t);
|
|
1600
1600
|
}
|
|
1601
1601
|
e._attachSocket(a), a.emit("connect"), e.Transport = r, e.Socket = r.prototype.Socket, e.Parser = r.prototype.Parser;
|
|
1602
1602
|
}
|
|
1603
|
-
function
|
|
1603
|
+
function yt({ entity: e }) {
|
|
1604
1604
|
let t = e.connect;
|
|
1605
1605
|
e.connect = async function(n) {
|
|
1606
1606
|
if (!n || /:\/\//.test(n)) return t.call(this, n);
|
|
1607
|
-
let r =
|
|
1607
|
+
let r = _t(e, await gt(n));
|
|
1608
1608
|
if (r.length === 0) throw Error("No compatible transport found.");
|
|
1609
1609
|
try {
|
|
1610
|
-
await
|
|
1610
|
+
await vt(e, r);
|
|
1611
1611
|
} catch (t) {
|
|
1612
1612
|
throw await e.disconnect(), e._status("disconnect"), t;
|
|
1613
1613
|
}
|
|
@@ -1615,24 +1615,24 @@ function xt({ entity: e }) {
|
|
|
1615
1615
|
}
|
|
1616
1616
|
//#endregion
|
|
1617
1617
|
//#region node_modules/@xmpp/base64/index.js
|
|
1618
|
-
function
|
|
1618
|
+
function bt(e) {
|
|
1619
1619
|
return globalThis.btoa(e);
|
|
1620
1620
|
}
|
|
1621
|
-
function
|
|
1621
|
+
function xt(e) {
|
|
1622
1622
|
return globalThis.atob(e);
|
|
1623
1623
|
}
|
|
1624
1624
|
//#endregion
|
|
1625
1625
|
//#region node_modules/@xmpp/sasl/lib/SASLError.js
|
|
1626
|
-
var
|
|
1626
|
+
var St = class extends ge {
|
|
1627
1627
|
constructor(...e) {
|
|
1628
1628
|
super(...e), this.name = "SASLError";
|
|
1629
1629
|
}
|
|
1630
|
-
},
|
|
1631
|
-
function
|
|
1630
|
+
}, Ct = "urn:ietf:params:xml:ns:xmpp-sasl";
|
|
1631
|
+
function wt(e, t, n) {
|
|
1632
1632
|
let r = new Set(e.getChildren("mechanism", t).map((e) => e.text()));
|
|
1633
1633
|
return n._mechs.map(({ name: e }) => e).filter((e) => r.has(e));
|
|
1634
1634
|
}
|
|
1635
|
-
async function
|
|
1635
|
+
async function Tt({ saslFactory: e, entity: t, mechanism: n, credentials: r }) {
|
|
1636
1636
|
let i = e.create([n]);
|
|
1637
1637
|
if (!i) throw Error(`SASL: Mechanism ${n} not found.`);
|
|
1638
1638
|
let { domain: a } = t.options, o = {
|
|
@@ -1645,31 +1645,31 @@ async function Dt({ saslFactory: e, entity: t, mechanism: n, credentials: r }) {
|
|
|
1645
1645
|
serviceName: a,
|
|
1646
1646
|
...r
|
|
1647
1647
|
};
|
|
1648
|
-
await
|
|
1649
|
-
xmlns:
|
|
1648
|
+
await oe(t, i.clientFirst && R("auth", {
|
|
1649
|
+
xmlns: Ct,
|
|
1650
1650
|
mechanism: i.name
|
|
1651
|
-
},
|
|
1652
|
-
if (e.getNS() ===
|
|
1651
|
+
}, bt(await i.response(o))), async (e, n) => {
|
|
1652
|
+
if (e.getNS() === Ct) {
|
|
1653
1653
|
if (e.name === "challenge") {
|
|
1654
|
-
await i.challenge(
|
|
1654
|
+
await i.challenge(xt(e.text()));
|
|
1655
1655
|
let n = await i.response(o);
|
|
1656
|
-
await t.send(
|
|
1657
|
-
xmlns:
|
|
1656
|
+
await t.send(R("response", {
|
|
1657
|
+
xmlns: Ct,
|
|
1658
1658
|
mechanism: i.name
|
|
1659
|
-
}, typeof n == "string" ?
|
|
1659
|
+
}, typeof n == "string" ? bt(n) : ""));
|
|
1660
1660
|
return;
|
|
1661
1661
|
}
|
|
1662
|
-
if (e.name === "failure") throw
|
|
1662
|
+
if (e.name === "failure") throw St.fromElement(e);
|
|
1663
1663
|
if (e.name === "success") return n();
|
|
1664
1664
|
}
|
|
1665
1665
|
});
|
|
1666
1666
|
}
|
|
1667
|
-
function
|
|
1668
|
-
e.use("mechanisms",
|
|
1669
|
-
let a =
|
|
1670
|
-
if (a.length === 0) throw new
|
|
1667
|
+
function Et({ streamFeatures: e, saslFactory: t }, n) {
|
|
1668
|
+
e.use("mechanisms", Ct, async ({ entity: e }, r, i) => {
|
|
1669
|
+
let a = wt(i, Ct, t);
|
|
1670
|
+
if (a.length === 0) throw new St("SASL: No compatible mechanism available.");
|
|
1671
1671
|
async function o(n, r) {
|
|
1672
|
-
await
|
|
1672
|
+
await Tt({
|
|
1673
1673
|
saslFactory: t,
|
|
1674
1674
|
entity: e,
|
|
1675
1675
|
mechanism: r,
|
|
@@ -1681,8 +1681,8 @@ function Ot({ streamFeatures: e, saslFactory: t }, n) {
|
|
|
1681
1681
|
}
|
|
1682
1682
|
//#endregion
|
|
1683
1683
|
//#region node_modules/@xmpp/sasl2/index.js
|
|
1684
|
-
var
|
|
1685
|
-
async function
|
|
1684
|
+
var Dt = "urn:xmpp:sasl:2";
|
|
1685
|
+
async function Ot({ saslFactory: e, entity: t, mechanism: n, credentials: r, userAgent: i, streamFeatures: a, features: o }) {
|
|
1686
1686
|
let s = e.create([n]);
|
|
1687
1687
|
if (!s) throw Error(`SASL: Mechanism ${n} not found.`);
|
|
1688
1688
|
let { domain: c } = t.options, l = {
|
|
@@ -1695,29 +1695,29 @@ async function At({ saslFactory: e, entity: t, mechanism: n, credentials: r, use
|
|
|
1695
1695
|
serviceName: c,
|
|
1696
1696
|
...r
|
|
1697
1697
|
};
|
|
1698
|
-
await
|
|
1699
|
-
xmlns:
|
|
1698
|
+
await oe(t, R("authenticate", {
|
|
1699
|
+
xmlns: Dt,
|
|
1700
1700
|
mechanism: s.name
|
|
1701
1701
|
}, [
|
|
1702
|
-
s.clientFirst &&
|
|
1702
|
+
s.clientFirst && R("initial-response", {}, bt(await s.response(l))),
|
|
1703
1703
|
i,
|
|
1704
1704
|
...a
|
|
1705
1705
|
]), async (e, n) => {
|
|
1706
|
-
if (e.getNS() ===
|
|
1706
|
+
if (e.getNS() === Dt) {
|
|
1707
1707
|
if (e.name === "challenge") {
|
|
1708
|
-
await s.challenge(
|
|
1708
|
+
await s.challenge(xt(e.text()));
|
|
1709
1709
|
let n = await s.response(l);
|
|
1710
|
-
await t.send(
|
|
1711
|
-
xmlns:
|
|
1710
|
+
await t.send(R("response", {
|
|
1711
|
+
xmlns: Dt,
|
|
1712
1712
|
mechanism: s.name
|
|
1713
|
-
}, typeof n == "string" ?
|
|
1713
|
+
}, typeof n == "string" ? bt(n) : ""));
|
|
1714
1714
|
return;
|
|
1715
1715
|
}
|
|
1716
|
-
if (e.name === "failure") throw
|
|
1716
|
+
if (e.name === "failure") throw St.fromElement(e);
|
|
1717
1717
|
if (e.name === "continue") throw Error("SASL continue is not supported yet");
|
|
1718
1718
|
if (e.name === "success") {
|
|
1719
1719
|
let r = e.getChild("additional-data")?.text();
|
|
1720
|
-
r && s.final && await s.final(
|
|
1720
|
+
r && s.final && await s.final(xt(r));
|
|
1721
1721
|
let i = e.getChildText("authorization-identifier");
|
|
1722
1722
|
i && t._jid(i);
|
|
1723
1723
|
for (let t of e.getChildElements()) o.get(t.getNS())?.[1]?.(t);
|
|
@@ -1726,24 +1726,24 @@ async function At({ saslFactory: e, entity: t, mechanism: n, credentials: r, use
|
|
|
1726
1726
|
}
|
|
1727
1727
|
});
|
|
1728
1728
|
}
|
|
1729
|
-
function
|
|
1729
|
+
function kt({ streamFeatures: e, saslFactory: t }, n) {
|
|
1730
1730
|
let r = /* @__PURE__ */ new Map(), i;
|
|
1731
|
-
return e.use("authentication",
|
|
1732
|
-
let s =
|
|
1731
|
+
return e.use("authentication", Dt, async ({ entity: e }, a, o) => {
|
|
1732
|
+
let s = wt(o, Dt, t), c = await At({
|
|
1733
1733
|
element: o,
|
|
1734
1734
|
features: r
|
|
1735
1735
|
}), l = !!i?.mechanism;
|
|
1736
|
-
if (s.length === 0 && !l) throw new
|
|
1736
|
+
if (s.length === 0 && !l) throw new St("SASL: No compatible mechanism available.");
|
|
1737
1737
|
await n(u, s, l ? i : null, e);
|
|
1738
1738
|
async function u(n, a, o) {
|
|
1739
1739
|
await i.auth({
|
|
1740
|
-
authenticate:
|
|
1740
|
+
authenticate: Ot,
|
|
1741
1741
|
entity: e,
|
|
1742
1742
|
userAgent: o,
|
|
1743
1743
|
streamFeatures: c,
|
|
1744
1744
|
features: r,
|
|
1745
1745
|
credentials: n
|
|
1746
|
-
}) || await
|
|
1746
|
+
}) || await Ot({
|
|
1747
1747
|
entity: e,
|
|
1748
1748
|
userAgent: o,
|
|
1749
1749
|
streamFeatures: c,
|
|
@@ -1762,7 +1762,7 @@ function jt({ streamFeatures: e, saslFactory: t }, n) {
|
|
|
1762
1762
|
}
|
|
1763
1763
|
};
|
|
1764
1764
|
}
|
|
1765
|
-
async function
|
|
1765
|
+
async function At({ element: e, features: t }) {
|
|
1766
1766
|
let n = [], r = e.getChild("inline");
|
|
1767
1767
|
if (!r) return n;
|
|
1768
1768
|
for (let e of r.getChildElements()) {
|
|
@@ -1773,55 +1773,55 @@ async function Mt({ element: e, features: t }) {
|
|
|
1773
1773
|
}
|
|
1774
1774
|
//#endregion
|
|
1775
1775
|
//#region node_modules/@xmpp/resource-binding/index.js
|
|
1776
|
-
var
|
|
1777
|
-
function
|
|
1778
|
-
return
|
|
1776
|
+
var jt = "urn:ietf:params:xml:ns:xmpp-bind";
|
|
1777
|
+
function Mt(e) {
|
|
1778
|
+
return R("bind", { xmlns: jt }, e && R("resource", {}, e));
|
|
1779
1779
|
}
|
|
1780
|
-
async function
|
|
1781
|
-
let r = (await t.set(
|
|
1780
|
+
async function Nt(e, t, n) {
|
|
1781
|
+
let r = (await t.set(Mt(n))).getChildText("jid");
|
|
1782
1782
|
return e._jid(r), e._ready(!1), r;
|
|
1783
1783
|
}
|
|
1784
|
-
function
|
|
1784
|
+
function Pt({ iqCaller: e }, t) {
|
|
1785
1785
|
return async ({ entity: n }, r) => {
|
|
1786
|
-
t = typeof t == "function" ? await t() : t, await
|
|
1786
|
+
t = typeof t == "function" ? await t() : t, await Nt(n, e, t), r();
|
|
1787
1787
|
};
|
|
1788
1788
|
}
|
|
1789
|
-
function
|
|
1790
|
-
e.use("bind",
|
|
1789
|
+
function Ft({ streamFeatures: e, iqCaller: t }, n) {
|
|
1790
|
+
e.use("bind", jt, Pt({ iqCaller: t }, n));
|
|
1791
1791
|
}
|
|
1792
1792
|
//#endregion
|
|
1793
1793
|
//#region node_modules/@xmpp/time/index.js
|
|
1794
|
-
function
|
|
1794
|
+
function It(e = /* @__PURE__ */ new Date()) {
|
|
1795
1795
|
return typeof e == "string" && (e = new Date(e)), new Date(e).toISOString().split(".")[0] + "Z";
|
|
1796
1796
|
}
|
|
1797
1797
|
//#endregion
|
|
1798
1798
|
//#region node_modules/@xmpp/stream-management/bind2.js
|
|
1799
|
-
function
|
|
1800
|
-
e.use(
|
|
1799
|
+
function Lt({ bind2: e, sm: t, failed: n, enabled: r }) {
|
|
1800
|
+
e.use(H, (e) => Ht({ sm: t }), async (e) => {
|
|
1801
1801
|
e.is("enabled") ? r(e.attrs) : e.is("failed") && n();
|
|
1802
1802
|
});
|
|
1803
1803
|
}
|
|
1804
1804
|
//#endregion
|
|
1805
1805
|
//#region node_modules/@xmpp/stream-management/sasl2.js
|
|
1806
|
-
function
|
|
1807
|
-
e.use(
|
|
1808
|
-
if (e.is("sm") && t.id) return
|
|
1806
|
+
function Rt({ sasl2: e, sm: t, failed: n, resumed: r }) {
|
|
1807
|
+
e.use(H, (e) => {
|
|
1808
|
+
if (e.is("sm") && t.id) return Ut({ sm: t });
|
|
1809
1809
|
}, (e) => {
|
|
1810
1810
|
e.is("resumed") ? r(e) : e.is("failed") && n();
|
|
1811
1811
|
});
|
|
1812
1812
|
}
|
|
1813
1813
|
//#endregion
|
|
1814
1814
|
//#region node_modules/@xmpp/stream-management/stream-feature.js
|
|
1815
|
-
function
|
|
1816
|
-
e.use("sm",
|
|
1815
|
+
function zt({ streamFeatures: e, sm: t, entity: n, resumed: r, failed: i, enabled: a }) {
|
|
1816
|
+
e.use("sm", H, async (e, o) => {
|
|
1817
1817
|
if (t.id) try {
|
|
1818
|
-
await r(await
|
|
1818
|
+
await r(await Vt(n, t));
|
|
1819
1819
|
return;
|
|
1820
1820
|
} catch {
|
|
1821
1821
|
i();
|
|
1822
1822
|
}
|
|
1823
1823
|
await o();
|
|
1824
|
-
let s =
|
|
1824
|
+
let s = Bt(n, t);
|
|
1825
1825
|
if (t.outbound_q.length > 0) throw Error("Stream Management assertion failure, queue should be empty after enable");
|
|
1826
1826
|
t.outbound = 0;
|
|
1827
1827
|
try {
|
|
@@ -1831,37 +1831,37 @@ function Vt({ streamFeatures: e, sm: t, entity: n, resumed: r, failed: i, enable
|
|
|
1831
1831
|
}
|
|
1832
1832
|
});
|
|
1833
1833
|
}
|
|
1834
|
-
function
|
|
1835
|
-
return
|
|
1834
|
+
function Bt(e, t) {
|
|
1835
|
+
return oe(e, Ht({ 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
|
|
1837
|
+
if (e.is("failed", "urn:xmpp:sm:3")) throw ge.fromElement(e);
|
|
1838
1838
|
});
|
|
1839
1839
|
}
|
|
1840
|
-
async function
|
|
1841
|
-
return
|
|
1840
|
+
async function Vt(e, t) {
|
|
1841
|
+
return oe(e, Ut({ 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
|
|
1843
|
+
if (e.is("failed", "urn:xmpp:sm:3")) throw ge.fromElement(e);
|
|
1844
1844
|
});
|
|
1845
1845
|
}
|
|
1846
1846
|
//#endregion
|
|
1847
1847
|
//#region node_modules/@xmpp/stream-management/index.js
|
|
1848
|
-
var
|
|
1849
|
-
function
|
|
1850
|
-
return
|
|
1851
|
-
xmlns:
|
|
1848
|
+
var H = "urn:xmpp:sm:3";
|
|
1849
|
+
function Ht({ sm: e }) {
|
|
1850
|
+
return R("enable", {
|
|
1851
|
+
xmlns: H,
|
|
1852
1852
|
max: e.preferredMaximum,
|
|
1853
1853
|
resume: "true"
|
|
1854
1854
|
});
|
|
1855
1855
|
}
|
|
1856
|
-
function
|
|
1857
|
-
return
|
|
1858
|
-
xmlns:
|
|
1856
|
+
function Ut({ sm: e }) {
|
|
1857
|
+
return R("resume", {
|
|
1858
|
+
xmlns: H,
|
|
1859
1859
|
h: e.inbound,
|
|
1860
1860
|
previd: e.id
|
|
1861
1861
|
});
|
|
1862
1862
|
}
|
|
1863
|
-
function
|
|
1864
|
-
let a = null, o = null, s = null, c = new
|
|
1863
|
+
function Wt({ streamFeatures: e, entity: t, middleware: n, bind2: r, sasl2: i }) {
|
|
1864
|
+
let a = null, o = null, s = null, c = new F.EventEmitter();
|
|
1865
1865
|
Object.assign(c, {
|
|
1866
1866
|
preferredMaximum: null,
|
|
1867
1867
|
enabled: !1,
|
|
@@ -1877,8 +1877,8 @@ 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(
|
|
1881
|
-
xmlns:
|
|
1880
|
+
await t.send(R("a", {
|
|
1881
|
+
xmlns: H,
|
|
1882
1882
|
h: c.inbound
|
|
1883
1883
|
}));
|
|
1884
1884
|
} catch {}
|
|
@@ -1891,7 +1891,7 @@ function Kt({ streamFeatures: e, entity: t, middleware: n, bind2: r, sasl2: i })
|
|
|
1891
1891
|
async function u(e) {
|
|
1892
1892
|
c.enabled = !0, f(+e.attrs.h);
|
|
1893
1893
|
let n = c.outbound_q;
|
|
1894
|
-
c.outbound_q = [], await t.sendMany(n.map((e) =>
|
|
1894
|
+
c.outbound_q = [], await t.sendMany(n.map((e) => Gt({
|
|
1895
1895
|
entity: t,
|
|
1896
1896
|
item: e
|
|
1897
1897
|
}))), c.emit("resumed"), t._ready(!0), h();
|
|
@@ -1923,12 +1923,12 @@ function Kt({ streamFeatures: e, entity: t, middleware: n, bind2: r, sasl2: i })
|
|
|
1923
1923
|
"message",
|
|
1924
1924
|
"iq"
|
|
1925
1925
|
].includes(n.name) ? c.inbound += 1 : n.is("r", "urn:xmpp:sm:3") ? await l() : n.is("a", "urn:xmpp:sm:3") && f(+n.attrs.h), h(), t();
|
|
1926
|
-
}), r &&
|
|
1926
|
+
}), r && Lt({
|
|
1927
1927
|
bind2: r,
|
|
1928
1928
|
sm: c,
|
|
1929
1929
|
failed: d,
|
|
1930
1930
|
enabled: m
|
|
1931
|
-
}), i &&
|
|
1931
|
+
}), i && Rt({
|
|
1932
1932
|
sasl2: i,
|
|
1933
1933
|
sm: c,
|
|
1934
1934
|
failed: d,
|
|
@@ -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(
|
|
1943
|
+
}, c.timeout)), t.send(R("r", { xmlns: H })).catch(() => {}), h());
|
|
1944
1944
|
}
|
|
1945
1945
|
return n.filter((e, t) => {
|
|
1946
1946
|
let { stanza: n } = e;
|
|
@@ -1950,9 +1950,9 @@ function Kt({ streamFeatures: e, entity: t, middleware: n, bind2: r, sasl2: i })
|
|
|
1950
1950
|
"iq"
|
|
1951
1951
|
].includes(n.name) ? t() : (c.outbound_q.push({
|
|
1952
1952
|
stanza: n,
|
|
1953
|
-
stamp:
|
|
1953
|
+
stamp: It()
|
|
1954
1954
|
}), clearTimeout(o), clearTimeout(s), s = setTimeout(g, c.requestAckDebounce), t());
|
|
1955
|
-
}), e &&
|
|
1955
|
+
}), e && zt({
|
|
1956
1956
|
streamFeatures: e,
|
|
1957
1957
|
sm: c,
|
|
1958
1958
|
entity: t,
|
|
@@ -1961,9 +1961,9 @@ function Kt({ streamFeatures: e, entity: t, middleware: n, bind2: r, sasl2: i })
|
|
|
1961
1961
|
enabled: m
|
|
1962
1962
|
}), c;
|
|
1963
1963
|
}
|
|
1964
|
-
function
|
|
1964
|
+
function Gt({ 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(
|
|
1966
|
+
return n.name === "message" && !n.getChild("delay", "urn:xmpp:delay") && n.append(R("delay", {
|
|
1967
1967
|
xmlns: "urn:xmpp:delay",
|
|
1968
1968
|
from: e.jid.toString(),
|
|
1969
1969
|
stamp: r
|
|
@@ -1971,17 +1971,17 @@ function qt({ entity: e, item: t }) {
|
|
|
1971
1971
|
}
|
|
1972
1972
|
//#endregion
|
|
1973
1973
|
//#region node_modules/@xmpp/client-core/src/bind2/bind2.js
|
|
1974
|
-
var
|
|
1975
|
-
function
|
|
1974
|
+
var Kt = "urn:xmpp:bind:0";
|
|
1975
|
+
function qt({ sasl2: e, entity: t }, n) {
|
|
1976
1976
|
let r = /* @__PURE__ */ new Map();
|
|
1977
|
-
return e.use(
|
|
1978
|
-
if (!e.is("bind",
|
|
1977
|
+
return e.use(Kt, async (e) => {
|
|
1978
|
+
if (!e.is("bind", Kt)) return;
|
|
1979
1979
|
n = typeof n == "function" ? await n() : n;
|
|
1980
|
-
let t = await
|
|
1980
|
+
let t = await Jt({
|
|
1981
1981
|
element: e,
|
|
1982
1982
|
features: r
|
|
1983
1983
|
});
|
|
1984
|
-
return
|
|
1984
|
+
return R("bind", { xmlns: "urn:xmpp:bind:0" }, n && R("tag", null, n), ...t);
|
|
1985
1985
|
}, (e) => {
|
|
1986
1986
|
if (e.is("bound")) {
|
|
1987
1987
|
t._ready(!1);
|
|
@@ -1991,7 +1991,7 @@ function Yt({ sasl2: e, entity: t }, n) {
|
|
|
1991
1991
|
r.set(e, [t, n]);
|
|
1992
1992
|
} };
|
|
1993
1993
|
}
|
|
1994
|
-
function
|
|
1994
|
+
function Jt({ element: e, features: t }) {
|
|
1995
1995
|
let n = [], r = e.getChild("inline");
|
|
1996
1996
|
if (!r) return n;
|
|
1997
1997
|
for (let e of r.getChildElements()) {
|
|
@@ -2002,7 +2002,7 @@ function Xt({ element: e, features: t }) {
|
|
|
2002
2002
|
}
|
|
2003
2003
|
//#endregion
|
|
2004
2004
|
//#region node_modules/saslmechanisms/lib/factory.js
|
|
2005
|
-
var
|
|
2005
|
+
var Yt = /* @__PURE__ */ y(((e, t) => {
|
|
2006
2006
|
(function(n, r) {
|
|
2007
2007
|
typeof e == "object" ? r(e, t) : typeof define == "function" && define.amd && define(["exports", "module"], r);
|
|
2008
2008
|
})(e, function(e, t) {
|
|
@@ -2022,9 +2022,9 @@ var Zt = /* @__PURE__ */ y(((e, t) => {
|
|
|
2022
2022
|
return null;
|
|
2023
2023
|
}, e = t.exports = n;
|
|
2024
2024
|
});
|
|
2025
|
-
})),
|
|
2025
|
+
})), Xt = /* @__PURE__ */ x((/* @__PURE__ */ y(((e, t) => {
|
|
2026
2026
|
(function(n, r) {
|
|
2027
|
-
typeof e == "object" ? r(e, t,
|
|
2027
|
+
typeof e == "object" ? r(e, t, Yt()) : typeof define == "function" && define.amd && define([
|
|
2028
2028
|
"exports",
|
|
2029
2029
|
"module",
|
|
2030
2030
|
"./lib/factory"
|
|
@@ -2032,9 +2032,9 @@ var Zt = /* @__PURE__ */ y(((e, t) => {
|
|
|
2032
2032
|
})(e, function(e, t, n) {
|
|
2033
2033
|
e = t.exports = n, e.Factory = n;
|
|
2034
2034
|
});
|
|
2035
|
-
})))(), 1),
|
|
2036
|
-
function
|
|
2037
|
-
let n = new
|
|
2035
|
+
})))(), 1), Zt = "urn:xmpp:fast:0";
|
|
2036
|
+
function Qt({ sasl2: e, entity: t }) {
|
|
2037
|
+
let n = new Xt.default(), r, i = new F.EventEmitter();
|
|
2038
2038
|
Object.assign(i, {
|
|
2039
2039
|
mechanism: null,
|
|
2040
2040
|
mechanisms: [],
|
|
@@ -2072,7 +2072,7 @@ function $t({ sasl2: e, entity: t }) {
|
|
|
2072
2072
|
async auth({ authenticate: e, entity: t, userAgent: n, credentials: r, streamFeatures: o, features: s }) {
|
|
2073
2073
|
if (!i.mechanism) return !1;
|
|
2074
2074
|
let { token: c } = r;
|
|
2075
|
-
if (
|
|
2075
|
+
if (!$t(c, i.mechanisms)) return l();
|
|
2076
2076
|
try {
|
|
2077
2077
|
return await e({
|
|
2078
2078
|
saslFactory: i.saslFactory,
|
|
@@ -2081,13 +2081,13 @@ function $t({ sasl2: e, entity: t }) {
|
|
|
2081
2081
|
...r,
|
|
2082
2082
|
password: c.token
|
|
2083
2083
|
},
|
|
2084
|
-
streamFeatures: [...o,
|
|
2084
|
+
streamFeatures: [...o, R("fast", { xmlns: Zt })],
|
|
2085
2085
|
entity: t,
|
|
2086
2086
|
userAgent: n,
|
|
2087
2087
|
features: s
|
|
2088
2088
|
}), !0;
|
|
2089
2089
|
} catch (e) {
|
|
2090
|
-
return e instanceof
|
|
2090
|
+
return e instanceof St && ["not-authorized", "credentials-expired"].includes(e.condition) ? l() : (t.emit("error", e), !1);
|
|
2091
2091
|
}
|
|
2092
2092
|
async function l() {
|
|
2093
2093
|
return await i.delete(), a(o), !1;
|
|
@@ -2095,34 +2095,34 @@ function $t({ sasl2: e, entity: t }) {
|
|
|
2095
2095
|
}
|
|
2096
2096
|
});
|
|
2097
2097
|
function a(e) {
|
|
2098
|
-
e.push(
|
|
2099
|
-
xmlns:
|
|
2098
|
+
e.push(R("request-token", {
|
|
2099
|
+
xmlns: Zt,
|
|
2100
2100
|
mechanism: i.mechanism
|
|
2101
2101
|
}));
|
|
2102
2102
|
}
|
|
2103
2103
|
function o() {
|
|
2104
2104
|
i.mechanism = null, i.mechanisms = [];
|
|
2105
2105
|
}
|
|
2106
|
-
return o(), e.use(
|
|
2107
|
-
if (!e.is("fast",
|
|
2106
|
+
return o(), e.use(Zt, async (e) => {
|
|
2107
|
+
if (!e.is("fast", Zt)) return o();
|
|
2108
2108
|
i.available = !0;
|
|
2109
|
-
let t =
|
|
2109
|
+
let t = wt(e, Zt, n), r = t[0];
|
|
2110
2110
|
if (!r) return o();
|
|
2111
2111
|
i.mechanisms = t, i.mechanism = r;
|
|
2112
2112
|
}, async (e) => {
|
|
2113
|
-
e.is("token",
|
|
2113
|
+
e.is("token", Zt) && await i.save({
|
|
2114
2114
|
mechanism: i.mechanism,
|
|
2115
2115
|
token: e.attrs.token,
|
|
2116
2116
|
expiry: e.attrs.expiry
|
|
2117
2117
|
});
|
|
2118
2118
|
}), i;
|
|
2119
2119
|
}
|
|
2120
|
-
function
|
|
2120
|
+
function $t(e, t) {
|
|
2121
2121
|
return !(!e || !t.includes(e.mechanism) || new Date(e.expiry) <= /* @__PURE__ */ new Date());
|
|
2122
2122
|
}
|
|
2123
2123
|
//#endregion
|
|
2124
2124
|
//#region node_modules/sasl-plain/lib/mechanism.js
|
|
2125
|
-
var
|
|
2125
|
+
var en = /* @__PURE__ */ y(((e, t) => {
|
|
2126
2126
|
(function(n, r) {
|
|
2127
2127
|
typeof e == "object" ? r(e, t) : typeof define == "function" && define.amd && define(["exports", "module"], r);
|
|
2128
2128
|
})(e, function(e, t) {
|
|
@@ -2134,9 +2134,9 @@ var tn = /* @__PURE__ */ y(((e, t) => {
|
|
|
2134
2134
|
return this;
|
|
2135
2135
|
}, e = t.exports = n;
|
|
2136
2136
|
});
|
|
2137
|
-
})),
|
|
2137
|
+
})), tn = /* @__PURE__ */ x((/* @__PURE__ */ y(((e, t) => {
|
|
2138
2138
|
(function(n, r) {
|
|
2139
|
-
typeof e == "object" ? r(e, t,
|
|
2139
|
+
typeof e == "object" ? r(e, t, en()) : typeof define == "function" && define.amd && define([
|
|
2140
2140
|
"exports",
|
|
2141
2141
|
"module",
|
|
2142
2142
|
"./lib/mechanism"
|
|
@@ -2145,12 +2145,12 @@ var tn = /* @__PURE__ */ y(((e, t) => {
|
|
|
2145
2145
|
e = t.exports = n, e.Mechanism = n;
|
|
2146
2146
|
});
|
|
2147
2147
|
})))(), 1);
|
|
2148
|
-
function
|
|
2149
|
-
e.use(
|
|
2148
|
+
function nn(e) {
|
|
2149
|
+
e.use(tn.default);
|
|
2150
2150
|
}
|
|
2151
2151
|
//#endregion
|
|
2152
2152
|
//#region node_modules/sasl-anonymous/lib/mechanism.js
|
|
2153
|
-
var
|
|
2153
|
+
var rn = /* @__PURE__ */ y(((e, t) => {
|
|
2154
2154
|
(function(n, r) {
|
|
2155
2155
|
typeof e == "object" ? r(e, t) : typeof define == "function" && define.amd && define(["exports", "module"], r);
|
|
2156
2156
|
})(e, function(e, t) {
|
|
@@ -2159,9 +2159,9 @@ var an = /* @__PURE__ */ y(((e, t) => {
|
|
|
2159
2159
|
return e.trace || "";
|
|
2160
2160
|
}, n.prototype.challenge = function(e) {}, e = t.exports = n;
|
|
2161
2161
|
});
|
|
2162
|
-
})),
|
|
2162
|
+
})), an = /* @__PURE__ */ x((/* @__PURE__ */ y(((e, t) => {
|
|
2163
2163
|
(function(n, r) {
|
|
2164
|
-
typeof e == "object" ? r(e, t,
|
|
2164
|
+
typeof e == "object" ? r(e, t, rn()) : typeof define == "function" && define.amd && define([
|
|
2165
2165
|
"exports",
|
|
2166
2166
|
"module",
|
|
2167
2167
|
"./lib/mechanism"
|
|
@@ -2170,99 +2170,99 @@ var an = /* @__PURE__ */ y(((e, t) => {
|
|
|
2170
2170
|
e = t.exports = n, e.Mechanism = n;
|
|
2171
2171
|
});
|
|
2172
2172
|
})))(), 1);
|
|
2173
|
-
function
|
|
2174
|
-
e.use(
|
|
2173
|
+
function on(e) {
|
|
2174
|
+
e.use(an.default);
|
|
2175
2175
|
}
|
|
2176
2176
|
//#endregion
|
|
2177
2177
|
//#region node_modules/@xmpp/sasl-ht-sha-256-none/index.js
|
|
2178
|
-
function
|
|
2179
|
-
|
|
2178
|
+
function U() {}
|
|
2179
|
+
U.prototype.Mechanism = U, U.prototype.name = "HT-SHA-256-NONE", U.prototype.clientFirst = !0, U.prototype.response = async function({ username: e, password: t }) {
|
|
2180
2180
|
this.key = await crypto.subtle.importKey("raw", new TextEncoder().encode(t), {
|
|
2181
2181
|
name: "HMAC",
|
|
2182
2182
|
hash: "SHA-256"
|
|
2183
2183
|
}, !1, ["sign", "verify"]);
|
|
2184
2184
|
let n = await crypto.subtle.sign("HMAC", this.key, new TextEncoder().encode("Initiator"));
|
|
2185
2185
|
return `${e}\0${String.fromCodePoint(...new Uint8Array(n))}`;
|
|
2186
|
-
},
|
|
2186
|
+
}, U.prototype.final = async function(e) {
|
|
2187
2187
|
let t = Uint8Array.from(e, (e) => e.codePointAt(0));
|
|
2188
2188
|
if (await crypto.subtle.verify("HMAC", this.key, t, new TextEncoder().encode("Responder")) !== !0) throw Error("Responder message from server was wrong");
|
|
2189
2189
|
};
|
|
2190
|
-
function
|
|
2191
|
-
e.use(
|
|
2190
|
+
function sn(e) {
|
|
2191
|
+
e.use(U);
|
|
2192
2192
|
}
|
|
2193
2193
|
//#endregion
|
|
2194
2194
|
//#region node_modules/@xmpp/client/lib/createOnAuthenticate.js
|
|
2195
|
-
var
|
|
2196
|
-
function
|
|
2195
|
+
var cn = "ANONYMOUS", ln = "PLAIN";
|
|
2196
|
+
function un(e, t) {
|
|
2197
2197
|
return async function(...n) {
|
|
2198
2198
|
if (typeof e == "function") {
|
|
2199
2199
|
await e(...n);
|
|
2200
2200
|
return;
|
|
2201
2201
|
}
|
|
2202
2202
|
let [r, i, a, o] = n;
|
|
2203
|
-
e.token ??= await a?.fetch(), await r(e,
|
|
2203
|
+
e.token ??= await a?.fetch(), await r(e, dn({
|
|
2204
2204
|
mechanisms: i,
|
|
2205
2205
|
entity: o,
|
|
2206
2206
|
credentials: e
|
|
2207
2207
|
}), t);
|
|
2208
2208
|
};
|
|
2209
2209
|
}
|
|
2210
|
-
function
|
|
2211
|
-
return !n?.username && !n?.password && !n?.token && e.includes(
|
|
2210
|
+
function dn({ mechanisms: e, entity: t, credentials: n }) {
|
|
2211
|
+
return !n?.username && !n?.password && !n?.token && e.includes(cn) ? cn : t.isSecure() ? e[0] : e.find((e) => e !== ln);
|
|
2212
2212
|
}
|
|
2213
2213
|
//#endregion
|
|
2214
2214
|
//#region node_modules/@xmpp/client/lib/getDomain.js
|
|
2215
|
-
function
|
|
2215
|
+
function fn(e) {
|
|
2216
2216
|
return (e.split("://")[1] || e).split(":")[0].split("/")[0];
|
|
2217
2217
|
}
|
|
2218
2218
|
//#endregion
|
|
2219
2219
|
//#region node_modules/@xmpp/client/index.js
|
|
2220
|
-
function
|
|
2220
|
+
function pn(e = {}) {
|
|
2221
2221
|
let { resource: t, credentials: n, username: r, password: i, userAgent: a, ...o } = e, { domain: s, service: c } = o;
|
|
2222
|
-
!s && c && (o.domain =
|
|
2223
|
-
let l = new
|
|
2224
|
-
r && o.domain && (l.jid =
|
|
2225
|
-
let u =
|
|
2222
|
+
!s && c && (o.domain = fn(c));
|
|
2223
|
+
let l = new we(o);
|
|
2224
|
+
r && o.domain && (l.jid = B(r, o.domain));
|
|
2225
|
+
let u = Ee({ entity: l }), d = Ne({ entity: l }), f = mn(V.default, { entity: l }), p = mn(V.default, { entity: l }), m = He({ entity: l }), h = Ue({ middleware: m }), g = Je({
|
|
2226
2226
|
middleware: m,
|
|
2227
2227
|
entity: l
|
|
2228
|
-
}), _ =
|
|
2228
|
+
}), _ = it({
|
|
2229
2229
|
middleware: m,
|
|
2230
2230
|
entity: l
|
|
2231
|
-
}), v =
|
|
2232
|
-
...typeof
|
|
2233
|
-
plain:
|
|
2234
|
-
anonymous:
|
|
2231
|
+
}), v = yt({ entity: l }), y = new Xt.default(), b = Object.entries({
|
|
2232
|
+
...typeof V.default == "function" && { scramsha1: V.default },
|
|
2233
|
+
plain: nn,
|
|
2234
|
+
anonymous: on
|
|
2235
2235
|
}).map(([e, t]) => ({ [e]: t(y) }));
|
|
2236
|
-
a ??=
|
|
2237
|
-
let x =
|
|
2236
|
+
a ??= R("user-agent", { id: globalThis.crypto.randomUUID() });
|
|
2237
|
+
let x = mn(V.default, { streamFeatures: h }), S = kt({
|
|
2238
2238
|
streamFeatures: h,
|
|
2239
2239
|
saslFactory: y
|
|
2240
|
-
},
|
|
2240
|
+
}, un(n ?? {
|
|
2241
2241
|
username: r,
|
|
2242
2242
|
password: i
|
|
2243
|
-
}, a)), C =
|
|
2243
|
+
}, a)), C = Qt({
|
|
2244
2244
|
sasl2: S,
|
|
2245
2245
|
entity: l
|
|
2246
2246
|
});
|
|
2247
2247
|
S.setup({ fast: C });
|
|
2248
|
-
let w =
|
|
2248
|
+
let w = qt({
|
|
2249
2249
|
sasl2: S,
|
|
2250
2250
|
entity: l
|
|
2251
2251
|
}, t);
|
|
2252
|
-
|
|
2253
|
-
let T =
|
|
2252
|
+
sn(C.saslFactory);
|
|
2253
|
+
let T = Et({
|
|
2254
2254
|
streamFeatures: h,
|
|
2255
2255
|
saslFactory: y
|
|
2256
|
-
},
|
|
2256
|
+
}, un(n ?? {
|
|
2257
2257
|
username: r,
|
|
2258
2258
|
password: i
|
|
2259
|
-
}, a)), E =
|
|
2259
|
+
}, a)), E = Wt({
|
|
2260
2260
|
streamFeatures: h,
|
|
2261
2261
|
entity: l,
|
|
2262
2262
|
middleware: m,
|
|
2263
2263
|
bind2: w,
|
|
2264
2264
|
sasl2: S
|
|
2265
|
-
}), D =
|
|
2265
|
+
}), D = Ft({
|
|
2266
2266
|
iqCaller: g,
|
|
2267
2267
|
streamFeatures: h
|
|
2268
2268
|
}, t);
|
|
@@ -2288,12 +2288,12 @@ function mn(e = {}) {
|
|
|
2288
2288
|
fast: C
|
|
2289
2289
|
});
|
|
2290
2290
|
}
|
|
2291
|
-
function
|
|
2291
|
+
function mn(e, ...t) {
|
|
2292
2292
|
if (typeof e == "function") return e(...t);
|
|
2293
2293
|
}
|
|
2294
2294
|
//#endregion
|
|
2295
2295
|
//#region src/xmpp.ts
|
|
2296
|
-
var
|
|
2296
|
+
var hn = "chat.internal", W = {
|
|
2297
2297
|
carbons: "urn:xmpp:carbons:2",
|
|
2298
2298
|
forward: "urn:xmpp:forward:0",
|
|
2299
2299
|
mam: "urn:xmpp:mam:2",
|
|
@@ -2323,7 +2323,7 @@ var gn = "chat.internal", U = {
|
|
|
2323
2323
|
reactions: "urn:xmpp:reactions:0",
|
|
2324
2324
|
reply: "urn:xmpp:reply:0",
|
|
2325
2325
|
fallback: "urn:xmpp:fallback:0"
|
|
2326
|
-
},
|
|
2326
|
+
}, gn = 3e4, _n = class {
|
|
2327
2327
|
xmpp;
|
|
2328
2328
|
me;
|
|
2329
2329
|
domain;
|
|
@@ -2341,9 +2341,9 @@ var gn = "chat.internal", U = {
|
|
|
2341
2341
|
cfg;
|
|
2342
2342
|
h;
|
|
2343
2343
|
constructor(e, t) {
|
|
2344
|
-
this.cfg = e, this.h = t, this.domain =
|
|
2344
|
+
this.cfg = e, this.h = t, this.domain = hn, this.mucHost = `conference.${hn}`, this.me = `${e.username}@${hn}`, this.xmpp = pn({
|
|
2345
2345
|
service: `wss://${e.host}/xmpp-websocket`,
|
|
2346
|
-
domain:
|
|
2346
|
+
domain: hn,
|
|
2347
2347
|
username: e.username,
|
|
2348
2348
|
password: e.token,
|
|
2349
2349
|
resource: "chat-island." + Math.random().toString(36).slice(2, 8)
|
|
@@ -2351,7 +2351,7 @@ var gn = "chat.internal", U = {
|
|
|
2351
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());
|
|
2352
2352
|
}), this.xmpp.on("error", (e) => {
|
|
2353
2353
|
if (!this.stopped) {
|
|
2354
|
-
if (
|
|
2354
|
+
if (yn(e)) {
|
|
2355
2355
|
this.unauthorized = !0, window.clearTimeout(this.retryTimer), this.h.status("unauthorized", e.message);
|
|
2356
2356
|
return;
|
|
2357
2357
|
}
|
|
@@ -2364,14 +2364,14 @@ var gn = "chat.internal", U = {
|
|
|
2364
2364
|
}
|
|
2365
2365
|
this.attempt = 0, this.connected = !0;
|
|
2366
2366
|
try {
|
|
2367
|
-
await this.xmpp.send(
|
|
2367
|
+
await this.xmpp.send(R("iq", {
|
|
2368
2368
|
type: "set",
|
|
2369
2369
|
id: "carbons"
|
|
2370
|
-
},
|
|
2370
|
+
}, R("enable", { xmlns: W.carbons }))), await this.xmpp.send(R("presence"));
|
|
2371
2371
|
} catch {
|
|
2372
2372
|
return;
|
|
2373
2373
|
}
|
|
2374
|
-
window.clearInterval(this.pingTimer), this.pingTimer = window.setInterval(() => this.ping(),
|
|
2374
|
+
window.clearInterval(this.pingTimer), this.pingTimer = window.setInterval(() => this.ping(), gn), this.h.status("online");
|
|
2375
2375
|
}), this.xmpp.on("stanza", (e) => this.onStanza(e));
|
|
2376
2376
|
}
|
|
2377
2377
|
start() {
|
|
@@ -2393,10 +2393,10 @@ var gn = "chat.internal", U = {
|
|
|
2393
2393
|
document.visibilityState === "visible" && this.wake();
|
|
2394
2394
|
};
|
|
2395
2395
|
ping() {
|
|
2396
|
-
this.connected && this.xmpp.iqCaller.request(
|
|
2396
|
+
this.connected && this.xmpp.iqCaller.request(R("iq", {
|
|
2397
2397
|
type: "get",
|
|
2398
2398
|
to: this.domain
|
|
2399
|
-
},
|
|
2399
|
+
}, R("ping", { xmlns: W.ping })), 1e4).catch((e) => {
|
|
2400
2400
|
!this.stopped && this.connected && e.name !== "StanzaError" && this.xmpp.disconnect().catch(() => {});
|
|
2401
2401
|
});
|
|
2402
2402
|
}
|
|
@@ -2410,7 +2410,7 @@ var gn = "chat.internal", U = {
|
|
|
2410
2410
|
let e = this.xmpp;
|
|
2411
2411
|
(e.status === "offline" ? this.xmpp.start() : e.connect(e.options.service).then(() => e.open({ domain: e.options.domain }))).catch((e) => {
|
|
2412
2412
|
if (!this.stopped) {
|
|
2413
|
-
if (
|
|
2413
|
+
if (yn(e)) {
|
|
2414
2414
|
this.unauthorized = !0, this.h.status("unauthorized", e.message);
|
|
2415
2415
|
return;
|
|
2416
2416
|
}
|
|
@@ -2428,24 +2428,24 @@ var gn = "chat.internal", U = {
|
|
|
2428
2428
|
}
|
|
2429
2429
|
async send(e, t, n, r) {
|
|
2430
2430
|
let i = crypto.randomUUID(), a = this.isGroup(e), o = r ? `> ${r.quote ?? ""}\n` : "", s = [
|
|
2431
|
-
|
|
2432
|
-
|
|
2433
|
-
xmlns:
|
|
2431
|
+
R("body", {}, o + t),
|
|
2432
|
+
R("origin-id", {
|
|
2433
|
+
xmlns: W.sid,
|
|
2434
2434
|
id: i
|
|
2435
2435
|
}),
|
|
2436
|
-
|
|
2436
|
+
R("store", { xmlns: W.hints })
|
|
2437
2437
|
];
|
|
2438
|
-
return n && s.push(
|
|
2439
|
-
xmlns:
|
|
2438
|
+
return n && s.push(R("x", { xmlns: W.oob }, R("url", {}, n))), r && (s.push(R("reply", {
|
|
2439
|
+
xmlns: W.reply,
|
|
2440
2440
|
id: r.id,
|
|
2441
2441
|
to: a ? `${e}/${r.author}` : `${r.author}@${this.domain}`
|
|
2442
|
-
})), s.push(
|
|
2443
|
-
xmlns:
|
|
2444
|
-
for:
|
|
2445
|
-
},
|
|
2442
|
+
})), s.push(R("fallback", {
|
|
2443
|
+
xmlns: W.fallback,
|
|
2444
|
+
for: W.reply
|
|
2445
|
+
}, R("body", {
|
|
2446
2446
|
start: "0",
|
|
2447
2447
|
end: String([...o].length)
|
|
2448
|
-
})))), a ? (await this.xmpp.send(
|
|
2448
|
+
})))), a ? (await this.xmpp.send(R("message", {
|
|
2449
2449
|
to: e,
|
|
2450
2450
|
type: "groupchat",
|
|
2451
2451
|
id: i
|
|
@@ -2461,7 +2461,7 @@ var gn = "chat.internal", U = {
|
|
|
2461
2461
|
room: e,
|
|
2462
2462
|
nick: this.cfg.username,
|
|
2463
2463
|
reply: r
|
|
2464
|
-
}) : (s.push(
|
|
2464
|
+
}) : (s.push(R("active", { xmlns: W.chatstates })), await this.xmpp.send(R("message", {
|
|
2465
2465
|
to: `${e}@${this.domain}`,
|
|
2466
2466
|
type: "chat",
|
|
2467
2467
|
id: i
|
|
@@ -2478,35 +2478,35 @@ var gn = "chat.internal", U = {
|
|
|
2478
2478
|
});
|
|
2479
2479
|
}
|
|
2480
2480
|
async react(e, t, n) {
|
|
2481
|
-
let r = this.isGroup(e), i =
|
|
2482
|
-
xmlns:
|
|
2481
|
+
let r = this.isGroup(e), i = R("reactions", {
|
|
2482
|
+
xmlns: W.reactions,
|
|
2483
2483
|
id: t
|
|
2484
|
-
}, ...n.map((e) =>
|
|
2485
|
-
await this.xmpp.send(
|
|
2484
|
+
}, ...n.map((e) => R("reaction", {}, e)));
|
|
2485
|
+
await this.xmpp.send(R("message", {
|
|
2486
2486
|
to: r ? e : `${e}@${this.domain}`,
|
|
2487
2487
|
type: r ? "groupchat" : "chat",
|
|
2488
2488
|
id: crypto.randomUUID()
|
|
2489
|
-
}, i,
|
|
2489
|
+
}, i, R("store", { xmlns: W.hints })));
|
|
2490
2490
|
}
|
|
2491
2491
|
async announce(e) {
|
|
2492
|
-
for (let t of e) await this.xmpp.send(
|
|
2492
|
+
for (let t of e) await this.xmpp.send(R("presence", { to: `${t}@${this.domain}` }, R("x", { xmlns: W.hello }))).catch(() => {});
|
|
2493
2493
|
}
|
|
2494
2494
|
typing(e, t) {
|
|
2495
|
-
return this.isGroup(e) ? Promise.resolve() : this.xmpp.send(
|
|
2495
|
+
return this.isGroup(e) ? Promise.resolve() : this.xmpp.send(R("message", {
|
|
2496
2496
|
to: `${e}@${this.domain}`,
|
|
2497
2497
|
type: "chat"
|
|
2498
|
-
},
|
|
2498
|
+
}, R(t ? "composing" : "paused", { xmlns: W.chatstates })));
|
|
2499
2499
|
}
|
|
2500
2500
|
enablePush(e, t) {
|
|
2501
|
-
return this.xmpp.iqCaller.request(
|
|
2502
|
-
xmlns:
|
|
2501
|
+
return this.xmpp.iqCaller.request(R("iq", { type: "set" }, R("enable", {
|
|
2502
|
+
xmlns: W.push,
|
|
2503
2503
|
jid: e,
|
|
2504
2504
|
node: t
|
|
2505
2505
|
})), 15e3);
|
|
2506
2506
|
}
|
|
2507
2507
|
disablePush(e, t) {
|
|
2508
|
-
return this.xmpp.iqCaller.request(
|
|
2509
|
-
xmlns:
|
|
2508
|
+
return this.xmpp.iqCaller.request(R("iq", { type: "set" }, R("disable", {
|
|
2509
|
+
xmlns: W.push,
|
|
2510
2510
|
jid: e,
|
|
2511
2511
|
node: t
|
|
2512
2512
|
})), 5e3);
|
|
@@ -2520,27 +2520,27 @@ var gn = "chat.internal", U = {
|
|
|
2520
2520
|
async mam(e, t, n) {
|
|
2521
2521
|
let r = crypto.randomUUID();
|
|
2522
2522
|
this.mamQueries.set(r, []), this.mamReactions.set(r, []);
|
|
2523
|
-
let i =
|
|
2523
|
+
let i = R("set", { xmlns: W.rsm }, R("max", {}, String(n)), R("before", {}, t ?? "")), a = [R("field", {
|
|
2524
2524
|
var: "FORM_TYPE",
|
|
2525
2525
|
type: "hidden"
|
|
2526
|
-
},
|
|
2527
|
-
e && a.push(
|
|
2528
|
-
let o =
|
|
2529
|
-
xmlns:
|
|
2526
|
+
}, R("value", {}, W.mam))];
|
|
2527
|
+
e && a.push(R("field", { var: "with" }, R("value", {}, this.isGroup(e) ? e : `${e}@${this.domain}`)));
|
|
2528
|
+
let o = R("x", {
|
|
2529
|
+
xmlns: W.data,
|
|
2530
2530
|
type: "submit"
|
|
2531
2531
|
}, ...a), s, c, l;
|
|
2532
2532
|
try {
|
|
2533
|
-
s = await this.xmpp.iqCaller.request(
|
|
2533
|
+
s = await this.xmpp.iqCaller.request(R("iq", {
|
|
2534
2534
|
type: "set",
|
|
2535
2535
|
id: r
|
|
2536
|
-
},
|
|
2537
|
-
xmlns:
|
|
2536
|
+
}, R("query", {
|
|
2537
|
+
xmlns: W.mam,
|
|
2538
2538
|
queryid: r
|
|
2539
2539
|
}, o, i)), 3e4);
|
|
2540
2540
|
} finally {
|
|
2541
2541
|
c = this.mamQueries.get(r) ?? [], l = this.mamReactions.get(r) ?? [], this.mamQueries.delete(r), this.mamReactions.delete(r);
|
|
2542
2542
|
}
|
|
2543
|
-
let u = s.getChild("fin",
|
|
2543
|
+
let u = s.getChild("fin", W.mam), d = u?.getChild("set", W.rsm)?.getChildText("first") ?? void 0;
|
|
2544
2544
|
return {
|
|
2545
2545
|
messages: c,
|
|
2546
2546
|
reactions: l,
|
|
@@ -2549,103 +2549,103 @@ var gn = "chat.internal", U = {
|
|
|
2549
2549
|
};
|
|
2550
2550
|
}
|
|
2551
2551
|
async createGroup(e, t, n) {
|
|
2552
|
-
let r = `g-${Math.random().toString(36).slice(2, 10)}@${this.mucHost}`, i = this.cfg.username, a = this.waitFor((e) => e.is("presence") &&
|
|
2553
|
-
await this.xmpp.send(
|
|
2554
|
-
let o = (e, t) =>
|
|
2555
|
-
await this.xmpp.iqCaller.request(
|
|
2552
|
+
let r = `g-${Math.random().toString(36).slice(2, 10)}@${this.mucHost}`, i = this.cfg.username, a = this.waitFor((e) => e.is("presence") && G(e.attrs.from) === r, 1e4);
|
|
2553
|
+
await this.xmpp.send(R("presence", { to: `${r}/${i}` }, R("x", { xmlns: W.muc }))), await a;
|
|
2554
|
+
let o = (e, t) => R("field", { var: e }, R("value", {}, t));
|
|
2555
|
+
await this.xmpp.iqCaller.request(R("iq", {
|
|
2556
2556
|
type: "set",
|
|
2557
2557
|
to: r
|
|
2558
|
-
},
|
|
2559
|
-
xmlns:
|
|
2558
|
+
}, R("query", { xmlns: W.mucOwner }, R("x", {
|
|
2559
|
+
xmlns: W.data,
|
|
2560
2560
|
type: "submit"
|
|
2561
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(() => {});
|
|
2562
2562
|
let s = t.filter((e) => e && e !== this.cfg.username), c = Date.now();
|
|
2563
|
-
await this.xmpp.iqCaller.request(
|
|
2563
|
+
await this.xmpp.iqCaller.request(R("iq", {
|
|
2564
2564
|
type: "set",
|
|
2565
2565
|
to: r
|
|
2566
|
-
},
|
|
2566
|
+
}, R("query", { xmlns: W.mucAdmin }, ...s.map((e, t) => R("item", {
|
|
2567
2567
|
affiliation: "member",
|
|
2568
2568
|
jid: `${e}@${this.domain}`
|
|
2569
|
-
},
|
|
2570
|
-
for (let e of s) await this.xmpp.iqCaller.request(
|
|
2569
|
+
}, R("reason", {}, String(c + t)))))), 15e3);
|
|
2570
|
+
for (let e of s) await this.xmpp.iqCaller.request(R("iq", {
|
|
2571
2571
|
type: "set",
|
|
2572
2572
|
to: r
|
|
2573
|
-
},
|
|
2574
|
-
xmlns:
|
|
2573
|
+
}, R("subscribe", {
|
|
2574
|
+
xmlns: W.mucsub,
|
|
2575
2575
|
jid: `${e}@${this.domain}`,
|
|
2576
2576
|
nick: e
|
|
2577
|
-
},
|
|
2578
|
-
await this.xmpp.iqCaller.request(
|
|
2577
|
+
}, R("event", { node: W.mucsubMessages }), R("event", { node: W.mucsubConfig }))), 15e3).catch(() => {});
|
|
2578
|
+
await this.xmpp.iqCaller.request(R("iq", {
|
|
2579
2579
|
type: "set",
|
|
2580
2580
|
to: r
|
|
2581
|
-
},
|
|
2582
|
-
xmlns:
|
|
2581
|
+
}, R("subscribe", {
|
|
2582
|
+
xmlns: W.mucsub,
|
|
2583
2583
|
nick: i
|
|
2584
|
-
},
|
|
2584
|
+
}, R("event", { node: W.mucsubMessages }), R("event", { node: W.mucsubConfig }))), 15e3), await this.xmpp.send(R("presence", {
|
|
2585
2585
|
to: `${r}/${i}`,
|
|
2586
2586
|
type: "unavailable"
|
|
2587
2587
|
}));
|
|
2588
|
-
for (let t of s) await this.xmpp.send(
|
|
2589
|
-
xmlns:
|
|
2588
|
+
for (let t of s) await this.xmpp.send(R("message", { to: `${t}@${this.domain}` }, R("x", {
|
|
2589
|
+
xmlns: W.conference,
|
|
2590
2590
|
jid: r,
|
|
2591
2591
|
reason: e
|
|
2592
2592
|
}))).catch(() => {});
|
|
2593
2593
|
return r;
|
|
2594
2594
|
}
|
|
2595
2595
|
async leaveGroup(e, t) {
|
|
2596
|
-
t ? await this.xmpp.iqCaller.request(
|
|
2596
|
+
t ? await this.xmpp.iqCaller.request(R("iq", {
|
|
2597
2597
|
type: "set",
|
|
2598
2598
|
to: e
|
|
2599
|
-
},
|
|
2599
|
+
}, R("query", { xmlns: W.mucOwner }, R("destroy", {}))), 1e4) : await this.xmpp.iqCaller.request(R("iq", {
|
|
2600
2600
|
type: "set",
|
|
2601
2601
|
to: e
|
|
2602
|
-
},
|
|
2602
|
+
}, R("unsubscribe", { xmlns: W.mucsub })), 1e4);
|
|
2603
2603
|
}
|
|
2604
2604
|
async setGroupAvatar(e, t) {
|
|
2605
2605
|
let n = /^data:(image\/[a-z+]+);base64,(.+)$/i.exec(t);
|
|
2606
|
-
n && await this.xmpp.iqCaller.request(
|
|
2606
|
+
n && await this.xmpp.iqCaller.request(R("iq", {
|
|
2607
2607
|
type: "set",
|
|
2608
2608
|
to: e
|
|
2609
|
-
},
|
|
2609
|
+
}, R("vCard", { xmlns: W.vcard }, R("PHOTO", {}, R("TYPE", {}, n[1]), R("BINVAL", {}, n[2])))), 15e3);
|
|
2610
2610
|
}
|
|
2611
2611
|
async groupAvatar(e) {
|
|
2612
|
-
let t = (await this.xmpp.iqCaller.request(
|
|
2612
|
+
let t = (await this.xmpp.iqCaller.request(R("iq", {
|
|
2613
2613
|
type: "get",
|
|
2614
2614
|
to: e
|
|
2615
|
-
},
|
|
2615
|
+
}, R("vCard", { xmlns: W.vcard })), 1e4)).getChild("vCard", W.vcard)?.getChild("PHOTO"), n = t?.getChildText("BINVAL");
|
|
2616
2616
|
return n ? `data:${t?.getChildText("TYPE") || "image/jpeg"};base64,${n.replace(/\s+/g, "")}` : void 0;
|
|
2617
2617
|
}
|
|
2618
2618
|
async listGroups() {
|
|
2619
|
-
let e = ((await this.xmpp.iqCaller.request(
|
|
2619
|
+
let e = ((await this.xmpp.iqCaller.request(R("iq", {
|
|
2620
2620
|
type: "get",
|
|
2621
2621
|
to: this.mucHost
|
|
2622
|
-
},
|
|
2622
|
+
}, R("subscriptions", { xmlns: W.mucsub })), 15e3)).getChild("subscriptions", W.mucsub)?.getChildren("subscription") ?? []).map((e) => e.attrs.jid);
|
|
2623
2623
|
return Promise.all(e.map((e) => this.groupInfo(e)));
|
|
2624
2624
|
}
|
|
2625
2625
|
async subscribed(e) {
|
|
2626
|
-
return ((await this.xmpp.iqCaller.request(
|
|
2626
|
+
return ((await this.xmpp.iqCaller.request(R("iq", {
|
|
2627
2627
|
type: "get",
|
|
2628
2628
|
to: this.mucHost
|
|
2629
|
-
},
|
|
2629
|
+
}, R("subscriptions", { xmlns: W.mucsub })), 15e3)).getChild("subscriptions", W.mucsub)?.getChildren("subscription") ?? []).some((t) => G(t.attrs.jid) === e);
|
|
2630
2630
|
}
|
|
2631
2631
|
async groupInfo(e) {
|
|
2632
2632
|
let t = e.split("@")[0], n = [], r = !1;
|
|
2633
2633
|
try {
|
|
2634
|
-
t = (await this.xmpp.iqCaller.request(
|
|
2634
|
+
t = (await this.xmpp.iqCaller.request(R("iq", {
|
|
2635
2635
|
type: "get",
|
|
2636
2636
|
to: e
|
|
2637
|
-
},
|
|
2637
|
+
}, R("query", { xmlns: W.discoInfo })), 1e4)).getChild("query", W.discoInfo)?.getChild("identity")?.attrs.name || t;
|
|
2638
2638
|
} catch {}
|
|
2639
2639
|
try {
|
|
2640
|
-
n = ((await this.xmpp.iqCaller.request(
|
|
2640
|
+
n = ((await this.xmpp.iqCaller.request(R("iq", {
|
|
2641
2641
|
type: "get",
|
|
2642
2642
|
to: e
|
|
2643
|
-
},
|
|
2644
|
-
let t = await this.xmpp.iqCaller.request(
|
|
2643
|
+
}, R("query", { xmlns: W.mucAdmin }, R("item", { affiliation: "member" }))), 1e4)).getChild("query", W.mucAdmin)?.getChildren("item") ?? []).map((e) => K(e.attrs.jid));
|
|
2644
|
+
let t = await this.xmpp.iqCaller.request(R("iq", {
|
|
2645
2645
|
type: "get",
|
|
2646
2646
|
to: e
|
|
2647
|
-
},
|
|
2648
|
-
for (let e of t.getChild("query",
|
|
2647
|
+
}, R("query", { xmlns: W.mucAdmin }, R("item", { affiliation: "owner" }))), 1e4);
|
|
2648
|
+
for (let e of t.getChild("query", W.mucAdmin)?.getChildren("item") ?? []) n.push(K(e.attrs.jid)), K(e.attrs.jid) === this.cfg.username && (r = !0);
|
|
2649
2649
|
} catch {}
|
|
2650
2650
|
let i = await this.groupAvatar(e).catch(() => void 0);
|
|
2651
2651
|
return {
|
|
@@ -2657,15 +2657,15 @@ var gn = "chat.internal", U = {
|
|
|
2657
2657
|
};
|
|
2658
2658
|
}
|
|
2659
2659
|
async upload(e) {
|
|
2660
|
-
let t = await this.findUploadService(), n = (await this.xmpp.iqCaller.request(
|
|
2660
|
+
let t = await this.findUploadService(), n = (await this.xmpp.iqCaller.request(R("iq", {
|
|
2661
2661
|
type: "get",
|
|
2662
2662
|
to: t
|
|
2663
|
-
},
|
|
2664
|
-
xmlns:
|
|
2663
|
+
}, R("request", {
|
|
2664
|
+
xmlns: W.upload,
|
|
2665
2665
|
filename: e.name,
|
|
2666
2666
|
size: String(e.size),
|
|
2667
2667
|
"content-type": e.type || "application/octet-stream"
|
|
2668
|
-
})), 3e4)).getChild("slot",
|
|
2668
|
+
})), 3e4)).getChild("slot", W.upload), r = n?.getChild("put"), i = n?.getChild("get")?.attrs.url;
|
|
2669
2669
|
if (!r || !i) throw Error("upload: no slot");
|
|
2670
2670
|
let a = { "Content-Type": e.type || "application/octet-stream" };
|
|
2671
2671
|
for (let e of r.getChildren("header")) a[e.attrs.name] = e.text();
|
|
@@ -2681,20 +2681,20 @@ var gn = "chat.internal", U = {
|
|
|
2681
2681
|
if (this.uploadService) return this.uploadService;
|
|
2682
2682
|
let e = async (e) => {
|
|
2683
2683
|
try {
|
|
2684
|
-
return (await this.xmpp.iqCaller.request(
|
|
2684
|
+
return (await this.xmpp.iqCaller.request(R("iq", {
|
|
2685
2685
|
type: "get",
|
|
2686
2686
|
to: e
|
|
2687
|
-
},
|
|
2687
|
+
}, R("query", { xmlns: W.discoInfo })), 1e4)).getChild("query", W.discoInfo)?.getChildren("feature").some((e) => e.attrs.var === W.upload) ?? !1;
|
|
2688
2688
|
} catch {
|
|
2689
2689
|
return !1;
|
|
2690
2690
|
}
|
|
2691
2691
|
}, t = [`upload.${this.domain}`];
|
|
2692
2692
|
try {
|
|
2693
|
-
let e = await this.xmpp.iqCaller.request(
|
|
2693
|
+
let e = await this.xmpp.iqCaller.request(R("iq", {
|
|
2694
2694
|
type: "get",
|
|
2695
2695
|
to: this.domain
|
|
2696
|
-
},
|
|
2697
|
-
for (let n of e.getChild("query",
|
|
2696
|
+
}, R("query", { xmlns: W.disco })), 1e4);
|
|
2697
|
+
for (let n of e.getChild("query", W.disco)?.getChildren("item") ?? []) t.includes(n.attrs.jid) || t.push(n.attrs.jid);
|
|
2698
2698
|
} catch {}
|
|
2699
2699
|
for (let n of t) if (await e(n)) return this.uploadService = n, n;
|
|
2700
2700
|
throw Error("upload: service not found");
|
|
@@ -2715,46 +2715,46 @@ var gn = "chat.internal", U = {
|
|
|
2715
2715
|
onStanza(e) {
|
|
2716
2716
|
for (let t of [...this.waiters]) t.test(e) && (this.waiters.splice(this.waiters.indexOf(t), 1), t.resolve());
|
|
2717
2717
|
if (e.is("presence")) {
|
|
2718
|
-
let t = e.attrs.from ?? "", n =
|
|
2718
|
+
let t = e.attrs.from ?? "", n = G(t);
|
|
2719
2719
|
if (!n || n === this.me || n.endsWith("@" + this.mucHost) || e.attrs.type === "error" || e.attrs.type?.startsWith("subscribe")) return;
|
|
2720
|
-
let r =
|
|
2720
|
+
let r = K(n), i = this.online.get(r) ?? /* @__PURE__ */ new Set();
|
|
2721
2721
|
e.attrs.type === "unavailable" ? i.delete(t) : i.add(t), this.online.set(r, i), this.h.presence(r, i.size > 0);
|
|
2722
|
-
let a = e.getChild("x",
|
|
2723
|
-
a && !a.attrs.reply && e.attrs.type !== "unavailable" && this.xmpp.send(
|
|
2724
|
-
xmlns:
|
|
2722
|
+
let a = e.getChild("x", W.hello);
|
|
2723
|
+
a && !a.attrs.reply && e.attrs.type !== "unavailable" && this.xmpp.send(R("presence", { to: n }, R("x", {
|
|
2724
|
+
xmlns: W.hello,
|
|
2725
2725
|
reply: "1"
|
|
2726
2726
|
}))).catch(() => {});
|
|
2727
2727
|
return;
|
|
2728
2728
|
}
|
|
2729
2729
|
if (!e.is("message")) return;
|
|
2730
|
-
let t = !e.attrs.from ||
|
|
2730
|
+
let t = !e.attrs.from || G(e.attrs.from) === this.me, n = e.getChild("result", W.mam);
|
|
2731
2731
|
if (n) {
|
|
2732
2732
|
if (!t) return;
|
|
2733
|
-
let e = n.getChild("forwarded",
|
|
2733
|
+
let e = n.getChild("forwarded", W.forward)?.getChild("message"), r = this.mamQueries.get(n.attrs.queryid);
|
|
2734
2734
|
if (e && r) {
|
|
2735
2735
|
let t = this.reactionOf(e);
|
|
2736
2736
|
t && this.mamReactions.get(n.attrs.queryid)?.push(t);
|
|
2737
|
-
let i = t ? void 0 : this.toMessage(e, n.attrs.id,
|
|
2737
|
+
let i = t ? void 0 : this.toMessage(e, n.attrs.id, bn(n.getChild("forwarded", W.forward)));
|
|
2738
2738
|
i && r.push(i);
|
|
2739
2739
|
}
|
|
2740
2740
|
return;
|
|
2741
2741
|
}
|
|
2742
|
-
let r = e.getChild("received",
|
|
2742
|
+
let r = e.getChild("received", W.carbons) ?? e.getChild("sent", W.carbons);
|
|
2743
2743
|
if (r) {
|
|
2744
2744
|
if (!t) return;
|
|
2745
|
-
let e = r.getChild("forwarded",
|
|
2745
|
+
let e = r.getChild("forwarded", W.forward)?.getChild("message");
|
|
2746
2746
|
e && this.deliver(e);
|
|
2747
2747
|
return;
|
|
2748
2748
|
}
|
|
2749
|
-
let i = e.getChild("event",
|
|
2750
|
-
if (i?.getChild("items")?.attrs.node ===
|
|
2751
|
-
let t =
|
|
2752
|
-
this.isGroup(t) &&
|
|
2749
|
+
let i = e.getChild("event", W.pubsubEvent);
|
|
2750
|
+
if (i?.getChild("items")?.attrs.node === W.mucsubConfig) {
|
|
2751
|
+
let t = G(e.attrs.from);
|
|
2752
|
+
this.isGroup(t) && xn(i, "presence")?.getChild("x", W.mucUser)?.getChild("destroy") && this.h.groupDestroyed(t);
|
|
2753
2753
|
return;
|
|
2754
2754
|
}
|
|
2755
|
-
let a = e.getChild("x",
|
|
2755
|
+
let a = e.getChild("x", W.conference);
|
|
2756
2756
|
if (a) {
|
|
2757
|
-
let e =
|
|
2757
|
+
let e = G(a.attrs.jid);
|
|
2758
2758
|
this.isGroup(e) && this.h.groupInvite(e);
|
|
2759
2759
|
return;
|
|
2760
2760
|
}
|
|
@@ -2766,24 +2766,24 @@ var gn = "chat.internal", U = {
|
|
|
2766
2766
|
this.h.reaction(t);
|
|
2767
2767
|
return;
|
|
2768
2768
|
}
|
|
2769
|
-
let n = this.toMessage(e, e.getChild("stanza-id",
|
|
2769
|
+
let n = this.toMessage(e, e.getChild("stanza-id", W.sid)?.attrs.id, bn(e));
|
|
2770
2770
|
if (n) {
|
|
2771
2771
|
this.h.message(n);
|
|
2772
2772
|
return;
|
|
2773
2773
|
}
|
|
2774
2774
|
if (e.attrs.type !== "chat") return;
|
|
2775
|
-
let r =
|
|
2776
|
-
!e.getChild("body") && a && this.h.typing(
|
|
2775
|
+
let r = G(e.attrs.from), i = r === this.me ? G(e.attrs.to) : r, a = e.getChildByAttr("xmlns", W.chatstates);
|
|
2776
|
+
!e.getChild("body") && a && this.h.typing(K(i), a.name === "composing");
|
|
2777
2777
|
}
|
|
2778
2778
|
reactionOf(e) {
|
|
2779
|
-
let t = e.getChild("event",
|
|
2780
|
-
if (t && t.getChild("items")?.attrs.node ===
|
|
2781
|
-
r =
|
|
2782
|
-
let i =
|
|
2783
|
-
if (!this.isGroup(r) || !i ||
|
|
2779
|
+
let t = e.getChild("event", W.pubsubEvent), n = e, r;
|
|
2780
|
+
if (t && t.getChild("items")?.attrs.node === W.mucsubMessages) {
|
|
2781
|
+
r = G(e.attrs.from);
|
|
2782
|
+
let i = Sn(t);
|
|
2783
|
+
if (!this.isGroup(r) || !i || G(i.attrs.from) !== r) return;
|
|
2784
2784
|
n = i;
|
|
2785
|
-
} else if (e.attrs.type === "groupchat" && (r =
|
|
2786
|
-
let i = n.getChild("reactions",
|
|
2785
|
+
} else if (e.attrs.type === "groupchat" && (r = G(e.attrs.from), !this.isGroup(r))) return;
|
|
2786
|
+
let i = n.getChild("reactions", W.reactions), a = i?.attrs.id;
|
|
2787
2787
|
if (!i || !a) return;
|
|
2788
2788
|
let o = [...new Set(i.getChildren("reaction").map((e) => e.text().trim()).filter((e) => e && e.length <= 16))].slice(0, 5);
|
|
2789
2789
|
if (r) {
|
|
@@ -2796,11 +2796,11 @@ var gn = "chat.internal", U = {
|
|
|
2796
2796
|
} : void 0;
|
|
2797
2797
|
}
|
|
2798
2798
|
if (n.attrs.type !== "chat") return;
|
|
2799
|
-
let s =
|
|
2799
|
+
let s = G(n.attrs.from), c = s === this.me || !n.attrs.from, l = K(c ? G(n.attrs.to) : s);
|
|
2800
2800
|
return l ? {
|
|
2801
2801
|
peer: l,
|
|
2802
2802
|
target: a,
|
|
2803
|
-
user: c ? this.cfg.username :
|
|
2803
|
+
user: c ? this.cfg.username : K(s),
|
|
2804
2804
|
emojis: o
|
|
2805
2805
|
} : void 0;
|
|
2806
2806
|
}
|
|
@@ -2810,48 +2810,48 @@ var gn = "chat.internal", U = {
|
|
|
2810
2810
|
let e = this.uploadUrl(r.oob);
|
|
2811
2811
|
r.body = r.body === r.oob ? e : r.body, r.oob = e;
|
|
2812
2812
|
}
|
|
2813
|
-
return r &&
|
|
2813
|
+
return r && vn(r, xn(e, "reply") ? e.getChild("event", W.pubsubEvent) ? Sn(e.getChild("event", W.pubsubEvent)) : e : void 0);
|
|
2814
2814
|
}
|
|
2815
2815
|
uploadUrl(e) {
|
|
2816
2816
|
let t = e.indexOf("/upload/");
|
|
2817
2817
|
return /^https:\/\/[^/]+\/upload\//.test(e) ? `https://${this.cfg.host}${e.slice(t)}` : e;
|
|
2818
2818
|
}
|
|
2819
2819
|
parseMessage(e, t, n) {
|
|
2820
|
-
let r = e.getChild("event",
|
|
2821
|
-
if (r && r.getChild("items")?.attrs.node ===
|
|
2822
|
-
let i =
|
|
2820
|
+
let r = e.getChild("event", W.pubsubEvent);
|
|
2821
|
+
if (r && r.getChild("items")?.attrs.node === W.mucsubMessages) {
|
|
2822
|
+
let i = G(e.attrs.from);
|
|
2823
2823
|
if (!this.isGroup(i)) return;
|
|
2824
|
-
let a =
|
|
2825
|
-
if (!a ||
|
|
2824
|
+
let a = Sn(r);
|
|
2825
|
+
if (!a || G(a.attrs.from) !== i) return;
|
|
2826
2826
|
let o = (a.attrs.from ?? "").split("/")[1] ?? "", s = a.getChildText("body");
|
|
2827
2827
|
return s == null ? void 0 : {
|
|
2828
|
-
id: a.getChild("origin-id",
|
|
2829
|
-
oid: a.getChild("origin-id",
|
|
2828
|
+
id: a.getChild("origin-id", W.sid)?.attrs.id ?? t ?? a.getChild("stanza-id", W.sid)?.attrs.id ?? a.attrs.id ?? crypto.randomUUID(),
|
|
2829
|
+
oid: a.getChild("origin-id", W.sid)?.attrs.id ?? a.attrs.id,
|
|
2830
2830
|
from: i,
|
|
2831
2831
|
to: this.cfg.username,
|
|
2832
2832
|
body: s,
|
|
2833
|
-
ts:
|
|
2833
|
+
ts: bn(a) !== n && a.getChild("delay", W.delay) ? bn(a) : n,
|
|
2834
2834
|
mine: o === this.cfg.username,
|
|
2835
|
-
oob: a.getChild("x",
|
|
2835
|
+
oob: a.getChild("x", W.oob)?.getChildText("url") ?? void 0,
|
|
2836
2836
|
room: i,
|
|
2837
2837
|
nick: o
|
|
2838
2838
|
};
|
|
2839
2839
|
}
|
|
2840
2840
|
let i = e.getChildText("body");
|
|
2841
2841
|
if (i == null) return;
|
|
2842
|
-
let a =
|
|
2842
|
+
let a = G(e.attrs.from);
|
|
2843
2843
|
if (e.attrs.type === "groupchat") {
|
|
2844
2844
|
if (!this.isGroup(a)) return;
|
|
2845
2845
|
let r = (e.attrs.from ?? "").split("/")[1] ?? "";
|
|
2846
2846
|
return {
|
|
2847
|
-
id: t ?? e.getChild("origin-id",
|
|
2848
|
-
oid: e.getChild("origin-id",
|
|
2847
|
+
id: t ?? e.getChild("origin-id", W.sid)?.attrs.id ?? e.attrs.id ?? crypto.randomUUID(),
|
|
2848
|
+
oid: e.getChild("origin-id", W.sid)?.attrs.id ?? e.attrs.id,
|
|
2849
2849
|
from: a,
|
|
2850
2850
|
to: this.cfg.username,
|
|
2851
2851
|
body: i,
|
|
2852
2852
|
ts: n,
|
|
2853
2853
|
mine: r === this.cfg.username,
|
|
2854
|
-
oob: e.getChild("x",
|
|
2854
|
+
oob: e.getChild("x", W.oob)?.getChildText("url") ?? void 0,
|
|
2855
2855
|
room: a,
|
|
2856
2856
|
nick: r
|
|
2857
2857
|
};
|
|
@@ -2859,21 +2859,21 @@ var gn = "chat.internal", U = {
|
|
|
2859
2859
|
if (e.attrs.type !== "chat") return;
|
|
2860
2860
|
let o = a === this.me;
|
|
2861
2861
|
return {
|
|
2862
|
-
id: t ?? e.getChild("origin-id",
|
|
2863
|
-
oid: e.getChild("origin-id",
|
|
2864
|
-
from:
|
|
2865
|
-
to: G(
|
|
2862
|
+
id: t ?? e.getChild("origin-id", W.sid)?.attrs.id ?? e.attrs.id ?? crypto.randomUUID(),
|
|
2863
|
+
oid: e.getChild("origin-id", W.sid)?.attrs.id ?? e.attrs.id,
|
|
2864
|
+
from: K(a),
|
|
2865
|
+
to: K(G(e.attrs.to)),
|
|
2866
2866
|
body: i,
|
|
2867
2867
|
ts: n,
|
|
2868
2868
|
mine: o,
|
|
2869
|
-
oob: e.getChild("x",
|
|
2869
|
+
oob: e.getChild("x", W.oob)?.getChildText("url") ?? void 0
|
|
2870
2870
|
};
|
|
2871
2871
|
}
|
|
2872
|
-
},
|
|
2873
|
-
function
|
|
2874
|
-
let n = t?.getChild("reply",
|
|
2872
|
+
}, G = (e = "") => e.split("/")[0];
|
|
2873
|
+
function vn(e, t) {
|
|
2874
|
+
let n = t?.getChild("reply", W.reply);
|
|
2875
2875
|
if (!n?.attrs.id) return e;
|
|
2876
|
-
let r = n.attrs.to ?? "", i = e.room ? r.split("/")[1] ?? "" : G(
|
|
2876
|
+
let r = n.attrs.to ?? "", i = e.room ? r.split("/")[1] ?? "" : K(G(r)), a = t.getChildren("fallback", W.fallback).find((e) => e.attrs.for === W.reply)?.getChild("body"), o = [...e.body], s = Number(a?.attrs.start ?? 0), c = Number(a?.attrs.end ?? 0);
|
|
2877
2877
|
if (!a || !(c > s) || c > o.length) return {
|
|
2878
2878
|
...e,
|
|
2879
2879
|
reply: {
|
|
@@ -2892,23 +2892,23 @@ function yn(e, t) {
|
|
|
2892
2892
|
}
|
|
2893
2893
|
};
|
|
2894
2894
|
}
|
|
2895
|
-
var
|
|
2896
|
-
let t = e?.getChild("delay",
|
|
2895
|
+
var yn = (e) => e.name === "SASLError" || e.condition === "not-authorized", K = (e = "") => e.split("@")[0], bn = (e) => {
|
|
2896
|
+
let t = e?.getChild("delay", W.delay)?.attrs.stamp;
|
|
2897
2897
|
return t ? Date.parse(t) : Date.now();
|
|
2898
2898
|
};
|
|
2899
|
-
function
|
|
2899
|
+
function xn(e, t) {
|
|
2900
2900
|
for (let n of e.children) {
|
|
2901
2901
|
if (typeof n == "string") continue;
|
|
2902
2902
|
if (n.name === t) return n;
|
|
2903
|
-
let e =
|
|
2903
|
+
let e = xn(n, t);
|
|
2904
2904
|
if (e) return e;
|
|
2905
2905
|
}
|
|
2906
2906
|
}
|
|
2907
|
-
var
|
|
2908
|
-
function
|
|
2907
|
+
var Sn = (e) => xn(e, "message"), q;
|
|
2908
|
+
function Cn() {
|
|
2909
2909
|
try {
|
|
2910
|
-
|
|
2911
|
-
let e =
|
|
2910
|
+
q ??= new AudioContext(), q.state === "suspended" && q.resume();
|
|
2911
|
+
let e = q.currentTime;
|
|
2912
2912
|
for (let [t, n, r] of [[
|
|
2913
2913
|
880,
|
|
2914
2914
|
0,
|
|
@@ -2918,14 +2918,14 @@ function wn() {
|
|
|
2918
2918
|
.1,
|
|
2919
2919
|
.16
|
|
2920
2920
|
]]) {
|
|
2921
|
-
let i =
|
|
2922
|
-
i.type = "sine", i.frequency.value = t, a.gain.setValueAtTime(1e-4, e + n), a.gain.exponentialRampToValueAtTime(.12, e + n + .01), a.gain.exponentialRampToValueAtTime(1e-4, e + n + r), i.connect(a).connect(
|
|
2921
|
+
let i = q.createOscillator(), a = q.createGain();
|
|
2922
|
+
i.type = "sine", i.frequency.value = t, a.gain.setValueAtTime(1e-4, e + n), a.gain.exponentialRampToValueAtTime(.12, e + n + .01), a.gain.exponentialRampToValueAtTime(1e-4, e + n + r), i.connect(a).connect(q.destination), i.start(e + n), i.stop(e + n + r + .02);
|
|
2923
2923
|
}
|
|
2924
2924
|
} catch {}
|
|
2925
2925
|
}
|
|
2926
2926
|
//#endregion
|
|
2927
2927
|
//#region node_modules/zustand/esm/vanilla.mjs
|
|
2928
|
-
var
|
|
2928
|
+
var wn = (e) => {
|
|
2929
2929
|
let t, n = /* @__PURE__ */ new Set(), r = (e, r) => {
|
|
2930
2930
|
let i = typeof e == "function" ? e(t) : e;
|
|
2931
2931
|
if (!Object.is(i, t)) {
|
|
@@ -2942,15 +2942,15 @@ var Tn = (e) => {
|
|
|
2942
2942
|
}
|
|
2943
2943
|
}, o = t = e(r, i, a);
|
|
2944
2944
|
return a;
|
|
2945
|
-
},
|
|
2946
|
-
function
|
|
2947
|
-
let r =
|
|
2948
|
-
return
|
|
2945
|
+
}, Tn = (e) => e ? wn(e) : wn, { useDebugValue: En } = e, { useSyncExternalStoreWithSelector: Dn } = l, On = (e) => e;
|
|
2946
|
+
function kn(e, t = On, n) {
|
|
2947
|
+
let r = Dn(e.subscribe, e.getState, e.getServerState || e.getInitialState, t, n);
|
|
2948
|
+
return En(r), r;
|
|
2949
2949
|
}
|
|
2950
|
-
var
|
|
2951
|
-
let t = typeof e == "function" ?
|
|
2950
|
+
var An = (e) => {
|
|
2951
|
+
let t = typeof e == "function" ? Tn(e) : e, n = (e, n) => kn(t, e, n);
|
|
2952
2952
|
return Object.assign(n, t), n;
|
|
2953
|
-
},
|
|
2953
|
+
}, jn = (e) => e ? An(e) : An, Mn = (e) => e.room ?? (e.mine ? e.to : e.from), J = (e, t) => ({
|
|
2954
2954
|
peer: e,
|
|
2955
2955
|
kind: t && e.endsWith("@" + t) ? "group" : "chat",
|
|
2956
2956
|
messages: [],
|
|
@@ -2958,13 +2958,13 @@ var jn = (e) => {
|
|
|
2958
2958
|
typing: !1,
|
|
2959
2959
|
loaded: !1,
|
|
2960
2960
|
complete: !1
|
|
2961
|
-
}),
|
|
2961
|
+
}), Nn = (e, t, n, r) => {
|
|
2962
2962
|
if (e.includes(t)) return e;
|
|
2963
2963
|
let i = [t, ...e];
|
|
2964
2964
|
if (i.length <= n) return i;
|
|
2965
2965
|
let a = [...i].reverse().find((e) => e !== r);
|
|
2966
2966
|
return i.filter((e) => e !== a);
|
|
2967
|
-
},
|
|
2967
|
+
}, Pn = (e, t) => e.id === t.id || !!e.oid && e.oid === t.oid, Y = jn((e, t) => ({
|
|
2968
2968
|
me: "",
|
|
2969
2969
|
myName: "",
|
|
2970
2970
|
mucHost: "",
|
|
@@ -3010,14 +3010,14 @@ var jn = (e) => {
|
|
|
3010
3010
|
ensure: (n) => {
|
|
3011
3011
|
let r = t().conversations[n];
|
|
3012
3012
|
if (r) return r;
|
|
3013
|
-
let i =
|
|
3013
|
+
let i = J(n, t().mucHost);
|
|
3014
3014
|
return e((e) => ({ conversations: {
|
|
3015
3015
|
...e.conversations,
|
|
3016
3016
|
[n]: i
|
|
3017
3017
|
} })), i;
|
|
3018
3018
|
},
|
|
3019
3019
|
setGroup: (t, n, r, i, a) => e((e) => {
|
|
3020
|
-
let o = e.conversations[t] ??
|
|
3020
|
+
let o = e.conversations[t] ?? J(t, e.mucHost);
|
|
3021
3021
|
return { conversations: {
|
|
3022
3022
|
...e.conversations,
|
|
3023
3023
|
[t]: {
|
|
@@ -3033,10 +3033,10 @@ var jn = (e) => {
|
|
|
3033
3033
|
seed: (t, n) => e((e) => {
|
|
3034
3034
|
let r = { ...e.conversations };
|
|
3035
3035
|
for (let i of t) {
|
|
3036
|
-
let t =
|
|
3036
|
+
let t = Mn(i);
|
|
3037
3037
|
if (!t || t === n) continue;
|
|
3038
|
-
let a = r[t] ??
|
|
3039
|
-
if (a.messages.some((e) =>
|
|
3038
|
+
let a = r[t] ?? J(t, e.mucHost);
|
|
3039
|
+
if (a.messages.some((e) => Pn(e, i))) continue;
|
|
3040
3040
|
if (a.loaded) {
|
|
3041
3041
|
r[t] = {
|
|
3042
3042
|
...a,
|
|
@@ -3053,10 +3053,10 @@ var jn = (e) => {
|
|
|
3053
3053
|
return { conversations: r };
|
|
3054
3054
|
}),
|
|
3055
3055
|
addMessage: (t, n, r) => e((e) => {
|
|
3056
|
-
let i = e.conversations[t] ??
|
|
3056
|
+
let i = e.conversations[t] ?? J(t, e.mucHost), a = i.messages.filter((e) => !Pn(e, n) && !(e.pending && n.mine && e.body === n.body && e.oob === n.oob)), o = a.length;
|
|
3057
3057
|
for (; o > 0 && a[o - 1].ts > n.ts;) o--;
|
|
3058
3058
|
a.splice(o, 0, n);
|
|
3059
|
-
let s = e.open === t, c = r?.live && !n.mine && !s ? i.unread + 1 : i.unread, l =
|
|
3059
|
+
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);
|
|
3060
3060
|
return {
|
|
3061
3061
|
conversations: {
|
|
3062
3062
|
...e.conversations,
|
|
@@ -3071,7 +3071,7 @@ var jn = (e) => {
|
|
|
3071
3071
|
};
|
|
3072
3072
|
}),
|
|
3073
3073
|
prependHistory: (t, n, r, i) => e((e) => {
|
|
3074
|
-
let a = e.conversations[t] ??
|
|
3074
|
+
let a = e.conversations[t] ?? J(t, e.mucHost), o = [...n.filter((e) => !a.messages.some((t) => Pn(t, e))), ...a.messages].sort((e, t) => e.ts - t.ts);
|
|
3075
3075
|
return { conversations: {
|
|
3076
3076
|
...e.conversations,
|
|
3077
3077
|
[t]: {
|
|
@@ -3087,7 +3087,7 @@ var jn = (e) => {
|
|
|
3087
3087
|
if (!t.length) return {};
|
|
3088
3088
|
let n = { ...e.conversations };
|
|
3089
3089
|
for (let r of t) {
|
|
3090
|
-
let t = n[r.peer] ??
|
|
3090
|
+
let t = n[r.peer] ?? J(r.peer, e.mucHost), i = { ...t.reactions ?? {} }, a = { ...i[r.target] ?? {} };
|
|
3091
3091
|
r.emojis.length ? a[r.user] = r.emojis : delete a[r.user], i[r.target] = a, n[r.peer] = {
|
|
3092
3092
|
...t,
|
|
3093
3093
|
reactions: i
|
|
@@ -3105,9 +3105,9 @@ var jn = (e) => {
|
|
|
3105
3105
|
openChat: (t) => e((e) => ({
|
|
3106
3106
|
conversations: e.conversations[t] ? e.conversations : {
|
|
3107
3107
|
...e.conversations,
|
|
3108
|
-
[t]:
|
|
3108
|
+
[t]: J(t, e.mucHost)
|
|
3109
3109
|
},
|
|
3110
|
-
order:
|
|
3110
|
+
order: Nn(e.order, t, e.maxHeads, e.open),
|
|
3111
3111
|
open: t,
|
|
3112
3112
|
picker: !1
|
|
3113
3113
|
})),
|
|
@@ -3136,7 +3136,7 @@ var jn = (e) => {
|
|
|
3136
3136
|
}));
|
|
3137
3137
|
//#endregion
|
|
3138
3138
|
//#region src/contacts.ts
|
|
3139
|
-
function
|
|
3139
|
+
function Fn(e, t, n) {
|
|
3140
3140
|
return Object.values(e ?? {}).filter((e) => e?.username && e.username !== n).map((e) => ({
|
|
3141
3141
|
username: e.username,
|
|
3142
3142
|
name: e.name || e.username,
|
|
@@ -3147,31 +3147,31 @@ function In(e, t, n) {
|
|
|
3147
3147
|
}
|
|
3148
3148
|
//#endregion
|
|
3149
3149
|
//#region src/api.ts
|
|
3150
|
-
async function
|
|
3150
|
+
async function In(e, t, n) {
|
|
3151
3151
|
let r = await fetch(`https://${e}/api${n}`, { headers: { Authorization: `Bearer ${t}` } });
|
|
3152
3152
|
if (!r.ok) throw Error(`${n}: HTTP ${r.status}`);
|
|
3153
3153
|
return await r.json();
|
|
3154
3154
|
}
|
|
3155
|
-
async function
|
|
3156
|
-
let i = await
|
|
3155
|
+
async function Ln(e, t, n, r) {
|
|
3156
|
+
let i = await In(e, t, "/user/endpoints/all"), a = {};
|
|
3157
3157
|
try {
|
|
3158
|
-
a = await
|
|
3158
|
+
a = await In(e, t, "/user/all_avatars");
|
|
3159
3159
|
} catch {}
|
|
3160
3160
|
let o = Object.values(i).find((e) => e.username === n)?.name;
|
|
3161
|
-
return o && r?.(o),
|
|
3161
|
+
return o && r?.(o), Fn(i, a, n).sort((e, t) => e.name.localeCompare(t.name));
|
|
3162
3162
|
}
|
|
3163
|
-
async function
|
|
3163
|
+
async function Rn(e, t) {
|
|
3164
3164
|
let n = await fetch(`https://${e}/chat-gw/push/mobile`, { headers: { Authorization: `Bearer ${t}` } });
|
|
3165
3165
|
if (!n.ok) throw Error(`push/mobile: HTTP ${n.status}`);
|
|
3166
3166
|
return (await n.json()).users;
|
|
3167
3167
|
}
|
|
3168
|
-
async function
|
|
3168
|
+
async function zn(e, t) {
|
|
3169
3169
|
let n = await fetch(`https://${e}/chat-gw/users/inactive`, { headers: { Authorization: `Bearer ${t}` } });
|
|
3170
3170
|
if (!n.ok) throw Error(`users/inactive: HTTP ${n.status}`);
|
|
3171
3171
|
let { users: r } = await n.json();
|
|
3172
3172
|
return Object.fromEntries(r.map((e) => [e.username, e.name || e.username]));
|
|
3173
3173
|
}
|
|
3174
|
-
async function
|
|
3174
|
+
async function Bn(e, t, n) {
|
|
3175
3175
|
let r = await fetch(`https://${e}/chat-gw/conversations/${encodeURIComponent(n)}`, {
|
|
3176
3176
|
method: "DELETE",
|
|
3177
3177
|
headers: { Authorization: `Bearer ${t}` }
|
|
@@ -3180,16 +3180,16 @@ async function Vn(e, t, n) {
|
|
|
3180
3180
|
}
|
|
3181
3181
|
//#endregion
|
|
3182
3182
|
//#region src/push.ts
|
|
3183
|
-
var
|
|
3183
|
+
var Vn = (e) => {
|
|
3184
3184
|
let t = atob((e + "=".repeat((4 - e.length % 4) % 4)).replace(/-/g, "+").replace(/_/g, "/"));
|
|
3185
3185
|
return Uint8Array.from(t, (e) => e.charCodeAt(0));
|
|
3186
|
-
},
|
|
3187
|
-
function
|
|
3188
|
-
|
|
3186
|
+
}, Hn = !1;
|
|
3187
|
+
function Un() {
|
|
3188
|
+
Hn || (Hn = !0, navigator.serviceWorker.addEventListener("message", (e) => {
|
|
3189
3189
|
e.data?.type === "chat-island-open" && typeof e.data.username == "string" && window.dispatchEvent(new CustomEvent("chat-island-open", { detail: { username: e.data.username } }));
|
|
3190
3190
|
}));
|
|
3191
3191
|
}
|
|
3192
|
-
async function
|
|
3192
|
+
async function Wn(e, t) {
|
|
3193
3193
|
if (!("serviceWorker" in navigator) || !("PushManager" in window)) throw Error("push not supported by this browser");
|
|
3194
3194
|
if (Notification.permission === "denied" || Notification.permission !== "granted" && await Notification.requestPermission() !== "granted") return null;
|
|
3195
3195
|
let n = `https://${e.host}/chat-gw`, r = await fetch(`${n}/push/vapid`);
|
|
@@ -3198,7 +3198,7 @@ async function Gn(e, t) {
|
|
|
3198
3198
|
await navigator.serviceWorker.ready;
|
|
3199
3199
|
let o = await a.pushManager.getSubscription() ?? await a.pushManager.subscribe({
|
|
3200
3200
|
userVisibleOnly: !0,
|
|
3201
|
-
applicationServerKey:
|
|
3201
|
+
applicationServerKey: Vn(i.publicKey)
|
|
3202
3202
|
}), s = await fetch(`${n}/push/web`, {
|
|
3203
3203
|
method: "POST",
|
|
3204
3204
|
headers: {
|
|
@@ -3209,24 +3209,24 @@ async function Gn(e, t) {
|
|
|
3209
3209
|
});
|
|
3210
3210
|
if (!s.ok) throw Error(`push/web: HTTP ${s.status} ${(await s.text()).slice(0, 120)}`);
|
|
3211
3211
|
let c = await s.json();
|
|
3212
|
-
return
|
|
3212
|
+
return Un(), {
|
|
3213
3213
|
node: c.node,
|
|
3214
3214
|
service: c.service
|
|
3215
3215
|
};
|
|
3216
3216
|
}
|
|
3217
3217
|
//#endregion
|
|
3218
3218
|
//#region src/events.ts
|
|
3219
|
-
function
|
|
3219
|
+
function X(e, t) {
|
|
3220
3220
|
window.dispatchEvent(new CustomEvent(e, { detail: t }));
|
|
3221
3221
|
}
|
|
3222
|
-
function
|
|
3222
|
+
function Z(e, t) {
|
|
3223
3223
|
let n = (e) => t(e.detail);
|
|
3224
3224
|
return window.addEventListener(e, n), () => window.removeEventListener(e, n);
|
|
3225
3225
|
}
|
|
3226
3226
|
//#endregion
|
|
3227
3227
|
//#region src/components/Avatar.tsx
|
|
3228
|
-
var
|
|
3229
|
-
function
|
|
3228
|
+
var Gn = (e) => e.split(/\s+/).slice(0, 2).map((e) => e[0]?.toUpperCase() ?? "").join("");
|
|
3229
|
+
function Kn({ contact: e, username: t, size: n = 40 }) {
|
|
3230
3230
|
let r = e?.name || t, i = {
|
|
3231
3231
|
width: n,
|
|
3232
3232
|
height: n,
|
|
@@ -3241,13 +3241,13 @@ function qn({ contact: e, username: t, size: n = 40 }) {
|
|
|
3241
3241
|
}) : /* @__PURE__ */ d("div", {
|
|
3242
3242
|
style: i,
|
|
3243
3243
|
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",
|
|
3244
|
-
children:
|
|
3244
|
+
children: Gn(r)
|
|
3245
3245
|
});
|
|
3246
3246
|
}
|
|
3247
|
-
function
|
|
3247
|
+
function qn({ online: e, presence: t, mobile: n }) {
|
|
3248
3248
|
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"}` });
|
|
3249
3249
|
}
|
|
3250
|
-
function
|
|
3250
|
+
function Jn({ name: e, size: t = 40, avatar: n }) {
|
|
3251
3251
|
let r = {
|
|
3252
3252
|
width: t,
|
|
3253
3253
|
height: t,
|
|
@@ -3262,12 +3262,12 @@ function Yn({ name: e, size: t = 40, avatar: n }) {
|
|
|
3262
3262
|
}) : /* @__PURE__ */ d("div", {
|
|
3263
3263
|
style: r,
|
|
3264
3264
|
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",
|
|
3265
|
-
children:
|
|
3265
|
+
children: Gn(e || "G")
|
|
3266
3266
|
});
|
|
3267
3267
|
}
|
|
3268
3268
|
//#endregion
|
|
3269
3269
|
//#region src/components/Button.tsx
|
|
3270
|
-
var
|
|
3270
|
+
var Yn = "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", Xn = {
|
|
3271
3271
|
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",
|
|
3272
3272
|
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",
|
|
3273
3273
|
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",
|
|
@@ -3276,16 +3276,16 @@ var Xn = "ci-flex ci-content-center ci-items-center ci-justify-center ci-trackin
|
|
|
3276
3276
|
call: "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-8 ci-w-8 ci-rounded-full",
|
|
3277
3277
|
small: "ci-bg-transparent dark:hover:ci-bg-gray-600 hover:ci-bg-gray-300 focus:ci-ring-gray-400 dark:focus:ci-ring-gray-500 ci-text-gray-700 dark:ci-text-white ci-h-8 ci-w-8 ci-rounded"
|
|
3278
3278
|
};
|
|
3279
|
-
function
|
|
3279
|
+
function Q({ variant: e, className: t = "", children: n, ...r }) {
|
|
3280
3280
|
return /* @__PURE__ */ d("button", {
|
|
3281
3281
|
type: "button",
|
|
3282
3282
|
"aria-label": r["aria-label"] ?? r.title,
|
|
3283
|
-
className: `${
|
|
3283
|
+
className: `${Yn} ${Xn[e]} ${t}`,
|
|
3284
3284
|
...r,
|
|
3285
3285
|
children: n
|
|
3286
3286
|
});
|
|
3287
3287
|
}
|
|
3288
|
-
var
|
|
3288
|
+
var $ = {
|
|
3289
3289
|
chat: /* @__PURE__ */ d("svg", {
|
|
3290
3290
|
width: "20",
|
|
3291
3291
|
height: "20",
|
|
@@ -3385,6 +3385,82 @@ var Q = {
|
|
|
3385
3385
|
strokeLinejoin: "round",
|
|
3386
3386
|
children: [/* @__PURE__ */ d("path", { d: "M9 17l-5-5 5-5" }), /* @__PURE__ */ d("path", { d: "M20 18v-2a4 4 0 0 0-4-4H4" })]
|
|
3387
3387
|
}),
|
|
3388
|
+
dots: /* @__PURE__ */ f("svg", {
|
|
3389
|
+
width: "16",
|
|
3390
|
+
height: "16",
|
|
3391
|
+
viewBox: "0 0 24 24",
|
|
3392
|
+
fill: "currentColor",
|
|
3393
|
+
children: [
|
|
3394
|
+
/* @__PURE__ */ d("circle", {
|
|
3395
|
+
cx: "12",
|
|
3396
|
+
cy: "5",
|
|
3397
|
+
r: "2"
|
|
3398
|
+
}),
|
|
3399
|
+
/* @__PURE__ */ d("circle", {
|
|
3400
|
+
cx: "12",
|
|
3401
|
+
cy: "12",
|
|
3402
|
+
r: "2"
|
|
3403
|
+
}),
|
|
3404
|
+
/* @__PURE__ */ d("circle", {
|
|
3405
|
+
cx: "12",
|
|
3406
|
+
cy: "19",
|
|
3407
|
+
r: "2"
|
|
3408
|
+
})
|
|
3409
|
+
]
|
|
3410
|
+
}),
|
|
3411
|
+
sun: /* @__PURE__ */ f("svg", {
|
|
3412
|
+
width: "16",
|
|
3413
|
+
height: "16",
|
|
3414
|
+
viewBox: "0 0 24 24",
|
|
3415
|
+
fill: "none",
|
|
3416
|
+
stroke: "currentColor",
|
|
3417
|
+
strokeWidth: "2",
|
|
3418
|
+
strokeLinecap: "round",
|
|
3419
|
+
children: [/* @__PURE__ */ d("circle", {
|
|
3420
|
+
cx: "12",
|
|
3421
|
+
cy: "12",
|
|
3422
|
+
r: "4"
|
|
3423
|
+
}), /* @__PURE__ */ d("path", { d: "M12 2v2M12 20v2M4.93 4.93l1.41 1.41M17.66 17.66l1.41 1.41M2 12h2M20 12h2M4.93 19.07l1.41-1.41M17.66 6.34l1.41-1.41" })]
|
|
3424
|
+
}),
|
|
3425
|
+
moon: /* @__PURE__ */ d("svg", {
|
|
3426
|
+
width: "16",
|
|
3427
|
+
height: "16",
|
|
3428
|
+
viewBox: "0 0 24 24",
|
|
3429
|
+
fill: "none",
|
|
3430
|
+
stroke: "currentColor",
|
|
3431
|
+
strokeWidth: "2",
|
|
3432
|
+
strokeLinecap: "round",
|
|
3433
|
+
strokeLinejoin: "round",
|
|
3434
|
+
children: /* @__PURE__ */ d("path", { d: "M21 12.79A9 9 0 1 1 11.21 3 7 7 0 0 0 21 12.79z" })
|
|
3435
|
+
}),
|
|
3436
|
+
monitor: /* @__PURE__ */ f("svg", {
|
|
3437
|
+
width: "16",
|
|
3438
|
+
height: "16",
|
|
3439
|
+
viewBox: "0 0 24 24",
|
|
3440
|
+
fill: "none",
|
|
3441
|
+
stroke: "currentColor",
|
|
3442
|
+
strokeWidth: "2",
|
|
3443
|
+
strokeLinecap: "round",
|
|
3444
|
+
strokeLinejoin: "round",
|
|
3445
|
+
children: [/* @__PURE__ */ d("rect", {
|
|
3446
|
+
x: "2",
|
|
3447
|
+
y: "3",
|
|
3448
|
+
width: "20",
|
|
3449
|
+
height: "14",
|
|
3450
|
+
rx: "2"
|
|
3451
|
+
}), /* @__PURE__ */ d("path", { d: "M8 21h8M12 17v4" })]
|
|
3452
|
+
}),
|
|
3453
|
+
check: /* @__PURE__ */ d("svg", {
|
|
3454
|
+
width: "16",
|
|
3455
|
+
height: "16",
|
|
3456
|
+
viewBox: "0 0 24 24",
|
|
3457
|
+
fill: "none",
|
|
3458
|
+
stroke: "currentColor",
|
|
3459
|
+
strokeWidth: "2.5",
|
|
3460
|
+
strokeLinecap: "round",
|
|
3461
|
+
strokeLinejoin: "round",
|
|
3462
|
+
children: /* @__PURE__ */ d("path", { d: "M20 6L9 17l-5-5" })
|
|
3463
|
+
}),
|
|
3388
3464
|
minus: /* @__PURE__ */ d("svg", {
|
|
3389
3465
|
width: "16",
|
|
3390
3466
|
height: "16",
|
|
@@ -3448,8 +3524,8 @@ var Q = {
|
|
|
3448
3524
|
};
|
|
3449
3525
|
//#endregion
|
|
3450
3526
|
//#region src/components/Dock.tsx
|
|
3451
|
-
function
|
|
3452
|
-
let { order: n, open: r, conversations: i, contacts: a, inactive: o, online: s, mobile: c, openChat: l, removeHead: p, picker: m, setPicker: h, status: g, push: _, enablePush: v, newChatButton: y } =
|
|
3527
|
+
function Zn({ onDragStart: e, pushButton: t = !0 }) {
|
|
3528
|
+
let { order: n, open: r, conversations: i, contacts: a, inactive: o, online: s, mobile: c, openChat: l, removeHead: p, picker: m, setPicker: h, status: g, push: _, enablePush: v, newChatButton: y } = Y(w((e) => ({
|
|
3453
3529
|
order: e.order,
|
|
3454
3530
|
open: e.open,
|
|
3455
3531
|
conversations: e.conversations,
|
|
@@ -3477,17 +3553,17 @@ function Qn({ onDragStart: e, pushButton: t = !0 }) {
|
|
|
3477
3553
|
children: [/* @__PURE__ */ f("button", {
|
|
3478
3554
|
type: "button",
|
|
3479
3555
|
title: t?.kind === "group" ? t.name ?? e : a[e]?.name ?? o[e] ?? e,
|
|
3480
|
-
onClick: () => n ?
|
|
3556
|
+
onClick: () => n ? Y.getState().closeChat() : l(e),
|
|
3481
3557
|
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"}`,
|
|
3482
|
-
children: [t?.kind === "group" ? /* @__PURE__ */ d(
|
|
3558
|
+
children: [t?.kind === "group" ? /* @__PURE__ */ d(Jn, {
|
|
3483
3559
|
name: t.name ?? e,
|
|
3484
3560
|
size: 48,
|
|
3485
3561
|
avatar: t.avatar
|
|
3486
|
-
}) : /* @__PURE__ */ f(u, { children: [/* @__PURE__ */ d(
|
|
3562
|
+
}) : /* @__PURE__ */ f(u, { children: [/* @__PURE__ */ d(Kn, {
|
|
3487
3563
|
contact: a[e],
|
|
3488
3564
|
username: e,
|
|
3489
3565
|
size: 48
|
|
3490
|
-
}), /* @__PURE__ */ d(
|
|
3566
|
+
}), /* @__PURE__ */ d(qn, {
|
|
3491
3567
|
online: s[e],
|
|
3492
3568
|
presence: a[e]?.presence,
|
|
3493
3569
|
mobile: c[e]
|
|
@@ -3500,30 +3576,30 @@ function Qn({ onDragStart: e, pushButton: t = !0 }) {
|
|
|
3500
3576
|
"aria-label": `Remove ${t?.kind === "group" ? t.name ?? e : a[e]?.name ?? o[e] ?? e} from the dock`,
|
|
3501
3577
|
onClick: () => p(e),
|
|
3502
3578
|
className: "ci-absolute ci--top-1 ci--left-1 ci-hidden group-hover:ci-flex group-focus-within:ci-flex ci-w-5 ci-h-5 ci-rounded-full ci-border-0 ci-p-0 ci-bg-gray-700 dark:ci-bg-gray-300 ci-text-gray-50 dark:ci-text-gray-900 ci-items-center ci-justify-center",
|
|
3503
|
-
children:
|
|
3579
|
+
children: $.close
|
|
3504
3580
|
})]
|
|
3505
3581
|
}, e);
|
|
3506
3582
|
}),
|
|
3507
|
-
y && /* @__PURE__ */ f(
|
|
3583
|
+
y && /* @__PURE__ */ f(Q, {
|
|
3508
3584
|
variant: "default",
|
|
3509
3585
|
title: g === "online" ? "New chat" : `Chat ${g}`,
|
|
3510
3586
|
onClick: () => h(!m),
|
|
3511
3587
|
className: "ci-relative ci-shadow-lg",
|
|
3512
|
-
children: [
|
|
3588
|
+
children: [$.chat, g !== "online" && /* @__PURE__ */ d("span", { className: "ci-absolute ci-bottom-0 ci-right-0 ci-w-3 ci-h-3 ci-rounded-full ci-bg-phoneIslandClose dark:ci-bg-phoneIslandCloseDark ci-ring-2 ci-ring-gray-50 dark:ci-ring-gray-950" })]
|
|
3513
3589
|
}),
|
|
3514
|
-
t && _ === "ask" && g === "online" && /* @__PURE__ */ d(
|
|
3590
|
+
t && _ === "ask" && g === "online" && /* @__PURE__ */ d(Q, {
|
|
3515
3591
|
variant: "neutral",
|
|
3516
3592
|
title: "Enable notifications when the tab is closed",
|
|
3517
3593
|
onClick: v,
|
|
3518
3594
|
className: "ci-shadow-lg ci-bg-gray-50 dark:ci-bg-gray-950",
|
|
3519
|
-
children:
|
|
3595
|
+
children: $.bell
|
|
3520
3596
|
})
|
|
3521
3597
|
]
|
|
3522
3598
|
});
|
|
3523
3599
|
}
|
|
3524
3600
|
//#endregion
|
|
3525
3601
|
//#region src/shortcodes.ts
|
|
3526
|
-
var
|
|
3602
|
+
var Qn = {
|
|
3527
3603
|
"+1": "👍",
|
|
3528
3604
|
thumbsup: "👍",
|
|
3529
3605
|
"-1": "👎",
|
|
@@ -3717,9 +3793,9 @@ var $n = {
|
|
|
3717
3793
|
zzz: "💤",
|
|
3718
3794
|
sweat_drops: "💦",
|
|
3719
3795
|
dash: "💨"
|
|
3720
|
-
},
|
|
3721
|
-
function
|
|
3722
|
-
return e.includes(":") ? e.split(
|
|
3796
|
+
}, $n = /(```[\s\S]*?(?:```|$)|`[^`\n]*`?)/g, er = /:([a-z0-9_+-]+):/g, tr = (e) => e.replace(er, (e, t) => Qn[t] ?? e);
|
|
3797
|
+
function nr(e) {
|
|
3798
|
+
return e.includes(":") ? e.split($n).map((e, t) => t % 2 ? e : tr(e)).join("") : e;
|
|
3723
3799
|
}
|
|
3724
3800
|
//#endregion
|
|
3725
3801
|
//#region src/components/EmojiPicker.tsx
|
|
@@ -3875,7 +3951,7 @@ function gr({ text: e }) {
|
|
|
3875
3951
|
let t = [], n = 0;
|
|
3876
3952
|
for (let r of e.matchAll(hr)) {
|
|
3877
3953
|
let i = r[0], a = r.index ?? 0;
|
|
3878
|
-
a > n && t.push(
|
|
3954
|
+
a > n && t.push(nr(e.slice(n, a))), r[1] ? t.push(/* @__PURE__ */ d("code", {
|
|
3879
3955
|
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]",
|
|
3880
3956
|
children: i.slice(1, -1)
|
|
3881
3957
|
}, a)) : r[2] ? t.push(/* @__PURE__ */ d("strong", { children: i.slice(2, -2) }, a)) : r[3] ? t.push(/* @__PURE__ */ d("s", { children: i.slice(2, -2) }, a)) : r[4] ? t.push(/* @__PURE__ */ d("em", { children: i.slice(1, -1) }, a)) : r[5] ? t.push(/* @__PURE__ */ d("a", {
|
|
@@ -3892,7 +3968,7 @@ function gr({ text: e }) {
|
|
|
3892
3968
|
children: i
|
|
3893
3969
|
}, a)), n = a + i.length;
|
|
3894
3970
|
}
|
|
3895
|
-
return n < e.length && t.push(
|
|
3971
|
+
return n < e.length && t.push(nr(e.slice(n))), /* @__PURE__ */ d(u, { children: t });
|
|
3896
3972
|
}
|
|
3897
3973
|
var _r = n(function({ text: e }) {
|
|
3898
3974
|
let t = e.split(/```[^\n]*\n?([\s\S]*?)```/g);
|
|
@@ -3967,7 +4043,7 @@ function br({ reply: e, messages: t, mine: n, name: r }) {
|
|
|
3967
4043
|
});
|
|
3968
4044
|
}
|
|
3969
4045
|
function xr({ messages: e, typing: t, onLoadOlder: n, hasOlder: r, group: a, reactions: o, me: l = "", onReact: u, onReply: p }) {
|
|
3970
|
-
let m =
|
|
4046
|
+
let m = Y((e) => e.contacts), h = s(null), g = s(!0), [_, v] = c(null), [y, b] = c(null), x = (e) => m[e]?.name ?? e;
|
|
3971
4047
|
i(() => {
|
|
3972
4048
|
let e = h.current;
|
|
3973
4049
|
e && g.current && (e.scrollTop = e.scrollHeight);
|
|
@@ -4008,7 +4084,7 @@ function xr({ messages: e, typing: t, onLoadOlder: n, hasOlder: r, group: a, rea
|
|
|
4008
4084
|
e.stopPropagation(), v(_ === h ? null : h);
|
|
4009
4085
|
},
|
|
4010
4086
|
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"}`,
|
|
4011
|
-
children:
|
|
4087
|
+
children: $.react
|
|
4012
4088
|
}), S = !!p && !!h && !t.pending && /* @__PURE__ */ d("button", {
|
|
4013
4089
|
type: "button",
|
|
4014
4090
|
title: "Reply",
|
|
@@ -4017,7 +4093,7 @@ function xr({ messages: e, typing: t, onLoadOlder: n, hasOlder: r, group: a, rea
|
|
|
4017
4093
|
e.stopPropagation(), p(t);
|
|
4018
4094
|
},
|
|
4019
4095
|
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",
|
|
4020
|
-
children:
|
|
4096
|
+
children: $.reply
|
|
4021
4097
|
});
|
|
4022
4098
|
return /* @__PURE__ */ f("div", {
|
|
4023
4099
|
"data-oid": t.oid,
|
|
@@ -4030,7 +4106,7 @@ function xr({ messages: e, typing: t, onLoadOlder: n, hasOlder: r, group: a, rea
|
|
|
4030
4106
|
c && /* @__PURE__ */ d("span", {
|
|
4031
4107
|
className: "ci-w-7 ci-shrink-0",
|
|
4032
4108
|
title: c,
|
|
4033
|
-
children: !s && /* @__PURE__ */ d(
|
|
4109
|
+
children: !s && /* @__PURE__ */ d(Kn, {
|
|
4034
4110
|
contact: m[t.nick],
|
|
4035
4111
|
username: t.nick,
|
|
4036
4112
|
size: 28
|
|
@@ -4279,21 +4355,21 @@ function Ir({ onSend: e, onTyping: t, onFile: n, disabled: r, disabledText: o, f
|
|
|
4279
4355
|
let k = (e) => {
|
|
4280
4356
|
b.current !== e && (b.current = e, t(e));
|
|
4281
4357
|
}, A = (e) => {
|
|
4282
|
-
let t = e.includes(":") ?
|
|
4358
|
+
let t = e.includes(":") ? nr(e) : e;
|
|
4283
4359
|
t !== e && (g.current = Math.max(0, (v.current?.selectionStart ?? e.length) - (e.length - t.length))), p(t), t ? (k(!0), window.clearTimeout(y.current), y.current = window.setTimeout(() => k(!1), 4e3)) : k(!1);
|
|
4284
4360
|
};
|
|
4285
4361
|
a(() => {
|
|
4286
4362
|
g.current !== null && (v.current?.setSelectionRange(g.current, g.current), g.current = null);
|
|
4287
4363
|
}, [u]);
|
|
4288
|
-
let
|
|
4364
|
+
let j = (e) => {
|
|
4289
4365
|
let t = v.current, n = t?.selectionStart ?? u.length, r = t?.selectionEnd ?? n;
|
|
4290
4366
|
A(u.slice(0, n) + e + u.slice(r)), requestAnimationFrame(() => {
|
|
4291
4367
|
t?.focus(), t?.setSelectionRange(n + e.length, n + e.length);
|
|
4292
4368
|
});
|
|
4293
|
-
},
|
|
4369
|
+
}, M = () => {
|
|
4294
4370
|
let t = u.trim();
|
|
4295
4371
|
t && (p(""), Promise.resolve(e(t)).catch(() => p((e) => e || t)), window.clearTimeout(y.current), b.current = !1);
|
|
4296
|
-
},
|
|
4372
|
+
}, N = async () => {
|
|
4297
4373
|
if (E.current || x) return;
|
|
4298
4374
|
E.current = !0;
|
|
4299
4375
|
let e;
|
|
@@ -4319,31 +4395,31 @@ function Ir({ onSend: e, onTyping: t, onFile: n, disabled: r, disabledText: o, f
|
|
|
4319
4395
|
} finally {
|
|
4320
4396
|
E.current = !1;
|
|
4321
4397
|
}
|
|
4322
|
-
},
|
|
4398
|
+
}, P = (e) => {
|
|
4323
4399
|
T.current = e, x?.r.stop();
|
|
4324
4400
|
};
|
|
4325
4401
|
return x ? /* @__PURE__ */ f("div", {
|
|
4326
4402
|
className: "ci-flex ci-items-center ci-gap-2 ci-px-3 ci-py-3",
|
|
4327
4403
|
children: [
|
|
4328
|
-
/* @__PURE__ */ d(
|
|
4404
|
+
/* @__PURE__ */ d(Q, {
|
|
4329
4405
|
variant: "transparent",
|
|
4330
4406
|
title: "Discard",
|
|
4331
4407
|
"aria-label": "Discard",
|
|
4332
|
-
onClick: () =>
|
|
4408
|
+
onClick: () => P(!0),
|
|
4333
4409
|
className: "ci-h-10 ci-w-10",
|
|
4334
|
-
children:
|
|
4410
|
+
children: $.close
|
|
4335
4411
|
}),
|
|
4336
4412
|
/* @__PURE__ */ f("div", {
|
|
4337
4413
|
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",
|
|
4338
4414
|
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 ", Fr(C)] })]
|
|
4339
4415
|
}),
|
|
4340
|
-
/* @__PURE__ */ d(
|
|
4416
|
+
/* @__PURE__ */ d(Q, {
|
|
4341
4417
|
variant: "green",
|
|
4342
4418
|
title: "Send voice note",
|
|
4343
4419
|
"aria-label": "Send voice note",
|
|
4344
|
-
onClick: () =>
|
|
4420
|
+
onClick: () => P(!1),
|
|
4345
4421
|
className: "ci-h-10 ci-w-10",
|
|
4346
|
-
children:
|
|
4422
|
+
children: $.send
|
|
4347
4423
|
})
|
|
4348
4424
|
]
|
|
4349
4425
|
}) : /* @__PURE__ */ f("div", {
|
|
@@ -4351,7 +4427,7 @@ function Ir({ onSend: e, onTyping: t, onFile: n, disabled: r, disabledText: o, f
|
|
|
4351
4427
|
children: [
|
|
4352
4428
|
m && /* @__PURE__ */ d(ar, {
|
|
4353
4429
|
className: "ci-absolute ci-bottom-full ci-left-3 ci-mb-1",
|
|
4354
|
-
onPick:
|
|
4430
|
+
onPick: j,
|
|
4355
4431
|
onClose: () => h(!1)
|
|
4356
4432
|
}),
|
|
4357
4433
|
/* @__PURE__ */ d("input", {
|
|
@@ -4360,13 +4436,13 @@ function Ir({ onSend: e, onTyping: t, onFile: n, disabled: r, disabledText: o, f
|
|
|
4360
4436
|
hidden: !0,
|
|
4361
4437
|
onChange: (e) => e.target.files?.[0] && (n(e.target.files[0]), e.target.value = "")
|
|
4362
4438
|
}),
|
|
4363
|
-
/* @__PURE__ */ d(
|
|
4439
|
+
/* @__PURE__ */ d(Q, {
|
|
4364
4440
|
variant: "transparent",
|
|
4365
4441
|
disabled: r,
|
|
4366
4442
|
title: "Attach a file",
|
|
4367
4443
|
onClick: () => _.current?.click(),
|
|
4368
4444
|
className: "ci-h-10 ci-w-10",
|
|
4369
|
-
children:
|
|
4445
|
+
children: $.clip
|
|
4370
4446
|
}),
|
|
4371
4447
|
/* @__PURE__ */ f("div", {
|
|
4372
4448
|
className: "ci-relative ci-flex-1 ci-min-w-0",
|
|
@@ -4378,7 +4454,7 @@ function Ir({ onSend: e, onTyping: t, onFile: n, disabled: r, disabledText: o, f
|
|
|
4378
4454
|
"aria-expanded": m,
|
|
4379
4455
|
onClick: () => h((e) => !e),
|
|
4380
4456
|
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",
|
|
4381
|
-
children:
|
|
4457
|
+
children: $.smile
|
|
4382
4458
|
}), /* @__PURE__ */ d("textarea", {
|
|
4383
4459
|
ref: v,
|
|
4384
4460
|
value: u,
|
|
@@ -4388,27 +4464,27 @@ function Ir({ onSend: e, onTyping: t, onFile: n, disabled: r, disabledText: o, f
|
|
|
4388
4464
|
onChange: (e) => A(e.target.value),
|
|
4389
4465
|
onKeyDown: (e) => {
|
|
4390
4466
|
let t = (u.match(/```/g) ?? []).length % 2 == 1;
|
|
4391
|
-
e.key === "Enter" && !e.shiftKey && !t && (e.preventDefault(),
|
|
4467
|
+
e.key === "Enter" && !e.shiftKey && !t && (e.preventDefault(), M());
|
|
4392
4468
|
},
|
|
4393
4469
|
className: `${r ? "ci-overflow-hidden" : ""} 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`,
|
|
4394
4470
|
style: { height: Math.min(128, 40 + 20 * (u.split("\n").length - 1)) }
|
|
4395
4471
|
})]
|
|
4396
4472
|
}),
|
|
4397
|
-
u.trim() ? /* @__PURE__ */ d(
|
|
4473
|
+
u.trim() ? /* @__PURE__ */ d(Q, {
|
|
4398
4474
|
variant: "default",
|
|
4399
4475
|
disabled: r,
|
|
4400
|
-
onClick:
|
|
4476
|
+
onClick: M,
|
|
4401
4477
|
title: "Send",
|
|
4402
4478
|
className: "ci-h-10 ci-w-10",
|
|
4403
|
-
children:
|
|
4404
|
-
}) : /* @__PURE__ */ d(
|
|
4479
|
+
children: $.send
|
|
4480
|
+
}) : /* @__PURE__ */ d(Q, {
|
|
4405
4481
|
variant: "default",
|
|
4406
4482
|
disabled: r || typeof MediaRecorder > "u",
|
|
4407
|
-
onClick:
|
|
4483
|
+
onClick: N,
|
|
4408
4484
|
title: "Record a voice note",
|
|
4409
4485
|
"aria-label": "Record a voice note",
|
|
4410
4486
|
className: "ci-h-10 ci-w-10",
|
|
4411
|
-
children:
|
|
4487
|
+
children: $.mic
|
|
4412
4488
|
})
|
|
4413
4489
|
]
|
|
4414
4490
|
});
|
|
@@ -4422,8 +4498,8 @@ var Lr = (e) => !!e && ![
|
|
|
4422
4498
|
"ringing",
|
|
4423
4499
|
"onhold"
|
|
4424
4500
|
].includes(e);
|
|
4425
|
-
function Rr({ peer: e, actions: t,
|
|
4426
|
-
let { c:
|
|
4501
|
+
function Rr({ peer: e, actions: t, theme: n, onDragStart: r }) {
|
|
4502
|
+
let { c: a, contacts: o, online: s, mobile: l, inactive: p, status: m, closeChat: h, openChat: g, markRead: _, order: v, me: y } = Y(w((t) => ({
|
|
4427
4503
|
c: t.conversations[e],
|
|
4428
4504
|
contacts: t.contacts,
|
|
4429
4505
|
online: t.online,
|
|
@@ -4435,131 +4511,143 @@ function Rr({ peer: e, actions: t, onDragStart: n }) {
|
|
|
4435
4511
|
markRead: t.markRead,
|
|
4436
4512
|
order: t.order,
|
|
4437
4513
|
me: t.me
|
|
4438
|
-
}))),
|
|
4514
|
+
}))), b = Math.max(0, v.indexOf(e)), x = o[e], [S, C] = c(!1), [T, E] = c(!1), [D, O] = c(null), [k, A] = c(0), j = (e) => e === y ? "You" : o[e]?.name ?? e, M = [...a?.members ?? []].sort((e, t) => Number(e === y) - Number(t === y));
|
|
4439
4515
|
i(() => {
|
|
4440
|
-
|
|
4441
|
-
}, [e,
|
|
4442
|
-
|
|
4443
|
-
}, [e,
|
|
4444
|
-
|
|
4516
|
+
a && !a.loaded && t.loadOlder(e);
|
|
4517
|
+
}, [e, a?.loaded]), i(() => {
|
|
4518
|
+
_(e);
|
|
4519
|
+
}, [e, a?.messages.length]), i(() => {
|
|
4520
|
+
C(!1), E(!1), O(null);
|
|
4445
4521
|
}, [e]);
|
|
4446
|
-
let
|
|
4522
|
+
let N = (t) => {
|
|
4447
4523
|
if (!t.oid) return;
|
|
4448
|
-
let n =
|
|
4449
|
-
|
|
4524
|
+
let n = a?.kind === "group" ? t.nick ?? "" : t.mine ? y : e, r = t.oob ? "Attachment" : t.body.replace(/```/g, "").replace(/\s+/g, " ").trim().slice(0, 100), i = n === y ? Y.getState().myName || y : o[n]?.name ?? n;
|
|
4525
|
+
O({
|
|
4450
4526
|
id: t.oid,
|
|
4451
4527
|
author: n,
|
|
4452
|
-
quote: `${
|
|
4453
|
-
}),
|
|
4454
|
-
},
|
|
4455
|
-
e.key === "Escape" && (e.stopPropagation(),
|
|
4528
|
+
quote: `${i}: ${r}`
|
|
4529
|
+
}), A((e) => e + 1);
|
|
4530
|
+
}, P = (e) => {
|
|
4531
|
+
e.key === "Escape" && (e.stopPropagation(), T ? E(!1) : D ? O(null) : S ? C(!1) : h());
|
|
4456
4532
|
};
|
|
4457
|
-
if (!
|
|
4458
|
-
let
|
|
4533
|
+
if (!a) return null;
|
|
4534
|
+
let F = a.kind !== "group" && !!p[e];
|
|
4459
4535
|
return /* @__PURE__ */ f("div", {
|
|
4460
4536
|
role: "dialog",
|
|
4461
|
-
"aria-label":
|
|
4462
|
-
onKeyDown:
|
|
4537
|
+
"aria-label": a.kind === "group" ? a.name ?? e : x?.name ?? p[e] ?? e,
|
|
4538
|
+
onKeyDown: P,
|
|
4463
4539
|
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",
|
|
4464
4540
|
children: [
|
|
4465
4541
|
/* @__PURE__ */ d("span", {
|
|
4466
4542
|
className: "ci-absolute ci--right-1.5 ci-w-3 ci-h-3 ci-rotate-45 ci-bg-gray-50 dark:ci-bg-gray-950 ci-shadow-2xl ci-transition-all ci-duration-200",
|
|
4467
|
-
style: { bottom: `calc(1.875rem + ${
|
|
4543
|
+
style: { bottom: `calc(1.875rem + ${b} * 3.75rem)` },
|
|
4468
4544
|
"aria-hidden": "true"
|
|
4469
4545
|
}),
|
|
4470
4546
|
/* @__PURE__ */ f("div", {
|
|
4471
|
-
className: `ci-flex ci-items-center ci-gap-3 ci-px-4 ci-py-3 ci-rounded-t-3xl ${
|
|
4472
|
-
onPointerDown:
|
|
4547
|
+
className: `ci-flex ci-items-center ci-gap-3 ci-px-4 ci-py-3 ci-rounded-t-3xl ${r ? "ci-cursor-grab active:ci-cursor-grabbing ci-touch-none" : ""}`,
|
|
4548
|
+
onPointerDown: r,
|
|
4473
4549
|
children: [
|
|
4474
|
-
|
|
4475
|
-
name:
|
|
4550
|
+
a.kind === "group" ? /* @__PURE__ */ d(Jn, {
|
|
4551
|
+
name: a.name ?? e,
|
|
4476
4552
|
size: 36,
|
|
4477
|
-
avatar:
|
|
4553
|
+
avatar: a.avatar
|
|
4478
4554
|
}) : /* @__PURE__ */ f("span", {
|
|
4479
4555
|
className: "ci-relative",
|
|
4480
|
-
children: [/* @__PURE__ */ d(
|
|
4481
|
-
contact:
|
|
4556
|
+
children: [/* @__PURE__ */ d(Kn, {
|
|
4557
|
+
contact: x,
|
|
4482
4558
|
username: e,
|
|
4483
4559
|
size: 36
|
|
4484
|
-
}), /* @__PURE__ */ d(
|
|
4485
|
-
online:
|
|
4486
|
-
presence:
|
|
4487
|
-
mobile:
|
|
4560
|
+
}), /* @__PURE__ */ d(qn, {
|
|
4561
|
+
online: s[e],
|
|
4562
|
+
presence: x?.presence,
|
|
4563
|
+
mobile: l[e]
|
|
4488
4564
|
})]
|
|
4489
4565
|
}),
|
|
4490
4566
|
/* @__PURE__ */ f("div", {
|
|
4491
|
-
className: `ci-flex-1 ci-min-w-0 ${
|
|
4492
|
-
...
|
|
4567
|
+
className: `ci-flex-1 ci-min-w-0 ${a.kind === "group" ? "ci-cursor-pointer" : ""}`,
|
|
4568
|
+
...a.kind === "group" ? {
|
|
4493
4569
|
role: "button",
|
|
4494
4570
|
tabIndex: 0,
|
|
4495
|
-
"aria-expanded":
|
|
4496
|
-
onKeyDown: (e) => (e.key === "Enter" || e.key === " ") && (e.preventDefault(),
|
|
4571
|
+
"aria-expanded": S,
|
|
4572
|
+
onKeyDown: (e) => (e.key === "Enter" || e.key === " ") && (e.preventDefault(), C((e) => !e))
|
|
4497
4573
|
} : {},
|
|
4498
|
-
onClick: () =>
|
|
4574
|
+
onClick: () => a.kind === "group" && C((e) => !e),
|
|
4499
4575
|
children: [/* @__PURE__ */ d("div", {
|
|
4500
4576
|
className: "ci-font-medium ci-truncate ci-text-sm",
|
|
4501
|
-
children:
|
|
4577
|
+
children: a.kind === "group" ? a.name ?? e : x?.name ?? p[e] ?? e
|
|
4502
4578
|
}), /* @__PURE__ */ d("div", {
|
|
4503
4579
|
className: "ci-text-xs ci-text-gray-500 dark:ci-text-gray-400 ci-truncate",
|
|
4504
|
-
children:
|
|
4580
|
+
children: F ? "No longer active" : m === "online" ? a.kind === "group" ? M.map(j).join(", ") : a.typing ? "typing…" : s[e] ? "online" : l[e] ? "Mobile" : "offline" : m
|
|
4505
4581
|
})]
|
|
4506
4582
|
}),
|
|
4507
|
-
!
|
|
4583
|
+
!F && a.kind !== "group" && x?.number && Lr(x.presence) && /* @__PURE__ */ d(Q, {
|
|
4508
4584
|
variant: "call",
|
|
4509
|
-
title: `Call ${
|
|
4585
|
+
title: `Call ${x.number}`,
|
|
4510
4586
|
"aria-label": "Call",
|
|
4511
|
-
onClick: () =>
|
|
4587
|
+
onClick: () => X("chat-island-call", {
|
|
4512
4588
|
username: e,
|
|
4513
|
-
number:
|
|
4589
|
+
number: x.number
|
|
4514
4590
|
}),
|
|
4515
|
-
children:
|
|
4591
|
+
children: $.phone
|
|
4516
4592
|
}),
|
|
4517
|
-
/* @__PURE__ */ d(
|
|
4593
|
+
/* @__PURE__ */ d(Q, {
|
|
4518
4594
|
variant: "small",
|
|
4519
|
-
onClick: () =>
|
|
4595
|
+
onClick: () => h(),
|
|
4520
4596
|
"aria-label": "Minimize",
|
|
4521
4597
|
title: "Minimize",
|
|
4522
|
-
children:
|
|
4598
|
+
children: $.minus
|
|
4599
|
+
}),
|
|
4600
|
+
/* @__PURE__ */ d(Q, {
|
|
4601
|
+
variant: "small",
|
|
4602
|
+
onClick: () => E((e) => !e),
|
|
4603
|
+
"aria-label": "Menu",
|
|
4604
|
+
title: "Menu",
|
|
4605
|
+
"aria-expanded": T,
|
|
4606
|
+
children: $.dots
|
|
4523
4607
|
})
|
|
4524
4608
|
]
|
|
4525
4609
|
}),
|
|
4526
4610
|
/* @__PURE__ */ d("div", { className: "ci-border-t ci-border-gray-300 dark:ci-border-gray-700" }),
|
|
4527
|
-
|
|
4528
|
-
|
|
4529
|
-
|
|
4611
|
+
T && /* @__PURE__ */ d(Br, {
|
|
4612
|
+
theme: n,
|
|
4613
|
+
onClose: () => E(!1)
|
|
4614
|
+
}),
|
|
4615
|
+
S && a.kind === "group" && /* @__PURE__ */ d("div", {
|
|
4616
|
+
className: "ci-anim-drop 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",
|
|
4617
|
+
children: M.map((e) => /* @__PURE__ */ f("div", {
|
|
4530
4618
|
className: "ci-flex ci-items-center ci-gap-3 ci-px-2 ci-py-1.5 ci-text-sm",
|
|
4531
4619
|
children: [
|
|
4532
4620
|
/* @__PURE__ */ f("span", {
|
|
4533
4621
|
className: "ci-relative",
|
|
4534
|
-
children: [/* @__PURE__ */ d(
|
|
4535
|
-
contact:
|
|
4622
|
+
children: [/* @__PURE__ */ d(Kn, {
|
|
4623
|
+
contact: o[e],
|
|
4536
4624
|
username: e,
|
|
4537
4625
|
size: 28
|
|
4538
|
-
}), e !==
|
|
4539
|
-
online:
|
|
4540
|
-
presence:
|
|
4541
|
-
mobile:
|
|
4626
|
+
}), e !== y && /* @__PURE__ */ d(qn, {
|
|
4627
|
+
online: s[e],
|
|
4628
|
+
presence: o[e]?.presence,
|
|
4629
|
+
mobile: l[e]
|
|
4542
4630
|
})]
|
|
4543
4631
|
}),
|
|
4544
4632
|
/* @__PURE__ */ d("span", {
|
|
4545
4633
|
className: "ci-truncate ci-flex-1",
|
|
4546
|
-
children:
|
|
4634
|
+
children: j(e)
|
|
4547
4635
|
}),
|
|
4548
|
-
e !==
|
|
4636
|
+
e !== y && /* @__PURE__ */ f(u, { children: [/* @__PURE__ */ d(Q, {
|
|
4549
4637
|
variant: "small",
|
|
4550
4638
|
title: "Chat",
|
|
4551
4639
|
"aria-label": "Chat",
|
|
4552
|
-
onClick: () =>
|
|
4553
|
-
children:
|
|
4554
|
-
}),
|
|
4640
|
+
onClick: () => g(e),
|
|
4641
|
+
children: $.chat
|
|
4642
|
+
}), o[e]?.number && Lr(o[e]?.presence) && /* @__PURE__ */ d(Q, {
|
|
4555
4643
|
variant: "call",
|
|
4556
|
-
title: `Call ${
|
|
4644
|
+
title: `Call ${o[e]?.number}`,
|
|
4557
4645
|
"aria-label": "Call",
|
|
4558
|
-
onClick: () =>
|
|
4646
|
+
onClick: () => X("chat-island-call", {
|
|
4559
4647
|
username: e,
|
|
4560
|
-
number:
|
|
4648
|
+
number: o[e].number
|
|
4561
4649
|
}),
|
|
4562
|
-
children:
|
|
4650
|
+
children: $.phone
|
|
4563
4651
|
})] })
|
|
4564
4652
|
]
|
|
4565
4653
|
}, e))
|
|
@@ -4568,40 +4656,40 @@ function Rr({ peer: e, actions: t, onDragStart: n }) {
|
|
|
4568
4656
|
className: "ci-flex-1 ci-min-h-0 ci-flex ci-flex-col ci-overflow-hidden ci-rounded-b-3xl",
|
|
4569
4657
|
children: [
|
|
4570
4658
|
/* @__PURE__ */ d(xr, {
|
|
4571
|
-
messages:
|
|
4572
|
-
typing:
|
|
4573
|
-
group:
|
|
4574
|
-
hasOlder:
|
|
4659
|
+
messages: a.messages,
|
|
4660
|
+
typing: a.typing,
|
|
4661
|
+
group: a.kind === "group",
|
|
4662
|
+
hasOlder: a.loaded && !a.complete,
|
|
4575
4663
|
onLoadOlder: () => t.loadOlder(e),
|
|
4576
|
-
reactions:
|
|
4577
|
-
me:
|
|
4664
|
+
reactions: a.reactions,
|
|
4665
|
+
me: y,
|
|
4578
4666
|
onReact: (n, r) => t.react(e, n, r),
|
|
4579
|
-
onReply:
|
|
4667
|
+
onReply: N
|
|
4580
4668
|
}),
|
|
4581
|
-
|
|
4669
|
+
D && /* @__PURE__ */ f("div", {
|
|
4582
4670
|
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",
|
|
4583
4671
|
children: [/* @__PURE__ */ f("div", {
|
|
4584
4672
|
className: "ci-flex-1 ci-min-w-0 ci-text-xs",
|
|
4585
4673
|
children: [/* @__PURE__ */ d("div", {
|
|
4586
4674
|
className: "ci-font-medium ci-text-gray-900 dark:ci-text-white",
|
|
4587
|
-
children:
|
|
4675
|
+
children: D.author === y ? "You" : o[D.author]?.name ?? D.author
|
|
4588
4676
|
}), /* @__PURE__ */ d("div", {
|
|
4589
4677
|
className: "ci-truncate ci-text-gray-500 dark:ci-text-gray-400",
|
|
4590
|
-
children:
|
|
4678
|
+
children: D.quote?.replace(/^[^:]*: /, "")
|
|
4591
4679
|
})]
|
|
4592
|
-
}), /* @__PURE__ */ d(
|
|
4680
|
+
}), /* @__PURE__ */ d(Q, {
|
|
4593
4681
|
variant: "small",
|
|
4594
|
-
onClick: () =>
|
|
4682
|
+
onClick: () => O(null),
|
|
4595
4683
|
"aria-label": "Cancel reply",
|
|
4596
4684
|
title: "Cancel reply",
|
|
4597
|
-
children:
|
|
4685
|
+
children: $.close
|
|
4598
4686
|
})]
|
|
4599
4687
|
}),
|
|
4600
4688
|
/* @__PURE__ */ d(Ir, {
|
|
4601
|
-
focusKey:
|
|
4602
|
-
disabled:
|
|
4603
|
-
disabledText:
|
|
4604
|
-
onSend: (n) => t.send(e, n,
|
|
4689
|
+
focusKey: k,
|
|
4690
|
+
disabled: m !== "online" || F,
|
|
4691
|
+
disabledText: F ? "No longer active" : void 0,
|
|
4692
|
+
onSend: (n) => t.send(e, n, D ?? void 0).then(() => O(null)),
|
|
4605
4693
|
onTyping: (n) => t.typing(e, n),
|
|
4606
4694
|
onFile: (n) => t.upload(e, n)
|
|
4607
4695
|
}, e)
|
|
@@ -4610,14 +4698,65 @@ function Rr({ peer: e, actions: t, onDragStart: n }) {
|
|
|
4610
4698
|
]
|
|
4611
4699
|
});
|
|
4612
4700
|
}
|
|
4701
|
+
var zr = [
|
|
4702
|
+
{
|
|
4703
|
+
value: "light",
|
|
4704
|
+
label: "Light",
|
|
4705
|
+
icon: $.sun
|
|
4706
|
+
},
|
|
4707
|
+
{
|
|
4708
|
+
value: "dark",
|
|
4709
|
+
label: "Dark",
|
|
4710
|
+
icon: $.moon
|
|
4711
|
+
},
|
|
4712
|
+
{
|
|
4713
|
+
value: "system",
|
|
4714
|
+
label: "System",
|
|
4715
|
+
icon: $.monitor
|
|
4716
|
+
}
|
|
4717
|
+
];
|
|
4718
|
+
function Br({ theme: e, onClose: t }) {
|
|
4719
|
+
let n = s(null);
|
|
4720
|
+
return i(() => {
|
|
4721
|
+
let e = (e) => n.current && !n.current.contains(e.target) && !e.target.closest("[aria-label=\"Menu\"]") && t();
|
|
4722
|
+
return document.addEventListener("pointerdown", e, !0), () => document.removeEventListener("pointerdown", e, !0);
|
|
4723
|
+
}, [t]), /* @__PURE__ */ f("div", {
|
|
4724
|
+
ref: n,
|
|
4725
|
+
role: "menu",
|
|
4726
|
+
className: "ci-anim-drop ci-absolute ci-right-3 ci-top-14 ci-z-20 ci-w-44 ci-py-2 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-text-sm",
|
|
4727
|
+
children: [/* @__PURE__ */ d("div", {
|
|
4728
|
+
className: "ci-px-4 ci-py-1 ci-font-semibold ci-text-gray-600 dark:ci-text-gray-50",
|
|
4729
|
+
children: "Theme"
|
|
4730
|
+
}), zr.map((n) => /* @__PURE__ */ f("button", {
|
|
4731
|
+
type: "button",
|
|
4732
|
+
role: "menuitemradio",
|
|
4733
|
+
"aria-checked": e === n.value,
|
|
4734
|
+
onClick: () => {
|
|
4735
|
+
X("chat-island-theme-change", { theme: n.value }), t();
|
|
4736
|
+
},
|
|
4737
|
+
className: "ci-w-full ci-flex ci-items-center ci-gap-2 ci-px-3 ci-py-2 ci-border-0 ci-bg-transparent ci-text-left ci-text-gray-700 dark:ci-text-gray-50 hover:ci-bg-gray-200 dark:hover:ci-bg-gray-700",
|
|
4738
|
+
children: [
|
|
4739
|
+
/* @__PURE__ */ d("span", {
|
|
4740
|
+
className: "ci-w-4 ci-text-green-600 dark:ci-text-green-400",
|
|
4741
|
+
children: e === n.value && $.check
|
|
4742
|
+
}),
|
|
4743
|
+
/* @__PURE__ */ d("span", {
|
|
4744
|
+
className: "ci-text-gray-600 dark:ci-text-gray-100",
|
|
4745
|
+
children: n.icon
|
|
4746
|
+
}),
|
|
4747
|
+
n.label
|
|
4748
|
+
]
|
|
4749
|
+
}, n.value))]
|
|
4750
|
+
});
|
|
4751
|
+
}
|
|
4613
4752
|
//#endregion
|
|
4614
4753
|
//#region src/components/NewChat.tsx
|
|
4615
|
-
async function
|
|
4754
|
+
async function Vr(e) {
|
|
4616
4755
|
let t = await createImageBitmap(e), n = Math.min(t.width, t.height), r = document.createElement("canvas");
|
|
4617
4756
|
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);
|
|
4618
4757
|
}
|
|
4619
|
-
function
|
|
4620
|
-
let { contacts: r, online: i, mobile: a, setPicker: l } =
|
|
4758
|
+
function Hr({ onOpen: e, onCreateGroup: t, onDragStart: n }) {
|
|
4759
|
+
let { contacts: r, online: i, mobile: a, setPicker: l } = Y(), [p, m] = c(""), [h, g] = c([]), [_, v] = c(""), [y, b] = c(!1), [x, S] = c(), C = s(null), w = o(() => {
|
|
4621
4760
|
let e = Object.values(r), t = p.trim().toLowerCase();
|
|
4622
4761
|
return t ? e.filter((e) => (e.name ?? "").toLowerCase().includes(t) || e.username.includes(t)) : e;
|
|
4623
4762
|
}, [r, p]), T = (e) => g((t) => t.includes(e) ? t.filter((t) => t !== e) : [...t, e]), E = async () => {
|
|
@@ -4636,18 +4775,18 @@ function Br({ onOpen: e, onCreateGroup: t, onDragStart: n }) {
|
|
|
4636
4775
|
onPointerDown: (e) => !e.target.closest("input, button") && n?.(e),
|
|
4637
4776
|
children: [/* @__PURE__ */ f("div", {
|
|
4638
4777
|
className: "ci-flex-1 ci-flex ci-items-center ci-gap-2 ci-px-4 ci-py-2 ci-rounded-3xl ci-bg-elevationL2 dark:ci-bg-elevationL2Dark ci-text-gray-500 dark:ci-text-gray-400",
|
|
4639
|
-
children: [
|
|
4778
|
+
children: [$.search, /* @__PURE__ */ d("input", {
|
|
4640
4779
|
autoFocus: !0,
|
|
4641
4780
|
value: p,
|
|
4642
4781
|
onChange: (e) => m(e.target.value),
|
|
4643
4782
|
placeholder: "Search operators",
|
|
4644
4783
|
className: "ci-flex-1 ci-bg-transparent ci-border-0 ci-outline-none ci-text-sm ci-text-gray-900 dark:ci-text-white placeholder:ci-text-gray-500 dark:placeholder:ci-text-gray-400"
|
|
4645
4784
|
})]
|
|
4646
|
-
}), /* @__PURE__ */ d(
|
|
4785
|
+
}), /* @__PURE__ */ d(Q, {
|
|
4647
4786
|
variant: "small",
|
|
4648
4787
|
onClick: () => l(!1),
|
|
4649
4788
|
"aria-label": "Close",
|
|
4650
|
-
children:
|
|
4789
|
+
children: $.close
|
|
4651
4790
|
})]
|
|
4652
4791
|
}),
|
|
4653
4792
|
h.length > 0 && /* @__PURE__ */ d("div", {
|
|
@@ -4656,7 +4795,7 @@ function Br({ onOpen: e, onCreateGroup: t, onDragStart: n }) {
|
|
|
4656
4795
|
type: "button",
|
|
4657
4796
|
onClick: () => T(e),
|
|
4658
4797
|
className: "ci-flex ci-items-center ci-gap-1 ci-pl-2.5 ci-pr-1.5 ci-py-1 ci-rounded-full ci-text-xs ci-bg-gray-700 ci-text-gray-50 dark:ci-bg-gray-300 dark:ci-text-gray-900 ci-border-0",
|
|
4659
|
-
children: [r[e]?.name ?? e,
|
|
4798
|
+
children: [r[e]?.name ?? e, $.close]
|
|
4660
4799
|
}, e))
|
|
4661
4800
|
}),
|
|
4662
4801
|
/* @__PURE__ */ d("div", { className: "ci-border-t ci-border-gray-300 dark:ci-border-gray-700" }),
|
|
@@ -4674,11 +4813,11 @@ function Br({ onOpen: e, onCreateGroup: t, onDragStart: n }) {
|
|
|
4674
4813
|
children: [
|
|
4675
4814
|
/* @__PURE__ */ f("span", {
|
|
4676
4815
|
className: "ci-relative",
|
|
4677
|
-
children: [/* @__PURE__ */ d(
|
|
4816
|
+
children: [/* @__PURE__ */ d(Kn, {
|
|
4678
4817
|
contact: e,
|
|
4679
4818
|
username: e.username,
|
|
4680
4819
|
size: 36
|
|
4681
|
-
}), /* @__PURE__ */ d(
|
|
4820
|
+
}), /* @__PURE__ */ d(qn, {
|
|
4682
4821
|
online: i[e.username],
|
|
4683
4822
|
presence: e.presence,
|
|
4684
4823
|
mobile: a[e.username]
|
|
@@ -4714,7 +4853,7 @@ function Br({ onOpen: e, onCreateGroup: t, onDragStart: n }) {
|
|
|
4714
4853
|
}),
|
|
4715
4854
|
h.length > 0 && /* @__PURE__ */ d("div", {
|
|
4716
4855
|
className: "ci-border-t ci-border-gray-300 dark:ci-border-gray-700 ci-px-4 ci-py-3 ci-flex ci-items-center ci-gap-2",
|
|
4717
|
-
children: h.length === 1 ? /* @__PURE__ */ d(
|
|
4856
|
+
children: h.length === 1 ? /* @__PURE__ */ d(Q, {
|
|
4718
4857
|
variant: "default",
|
|
4719
4858
|
className: "ci-w-auto ci-h-10 ci-px-5",
|
|
4720
4859
|
onClick: () => e(h[0]),
|
|
@@ -4725,7 +4864,7 @@ function Br({ onOpen: e, onCreateGroup: t, onDragStart: n }) {
|
|
|
4725
4864
|
type: "file",
|
|
4726
4865
|
accept: "image/*",
|
|
4727
4866
|
hidden: !0,
|
|
4728
|
-
onChange: (e) => e.target.files?.[0] &&
|
|
4867
|
+
onChange: (e) => e.target.files?.[0] && Vr(e.target.files[0]).then(S).catch(() => {})
|
|
4729
4868
|
}),
|
|
4730
4869
|
/* @__PURE__ */ d("button", {
|
|
4731
4870
|
type: "button",
|
|
@@ -4737,7 +4876,7 @@ function Br({ onOpen: e, onCreateGroup: t, onDragStart: n }) {
|
|
|
4737
4876
|
alt: "",
|
|
4738
4877
|
draggable: !1,
|
|
4739
4878
|
className: "ci-w-full ci-h-full ci-object-cover"
|
|
4740
|
-
}) :
|
|
4879
|
+
}) : $.camera
|
|
4741
4880
|
}),
|
|
4742
4881
|
/* @__PURE__ */ d("input", {
|
|
4743
4882
|
value: _,
|
|
@@ -4746,7 +4885,7 @@ function Br({ onOpen: e, onCreateGroup: t, onDragStart: n }) {
|
|
|
4746
4885
|
onKeyDown: (e) => e.key === "Enter" && _.trim() && !y && E(),
|
|
4747
4886
|
className: "ci-flex-1 ci-min-w-0 ci-w-0 ci-px-4 ci-py-2 ci-rounded-3xl ci-border-0 ci-bg-elevationL2 dark:ci-bg-elevationL2Dark ci-text-sm 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"
|
|
4748
4887
|
}),
|
|
4749
|
-
/* @__PURE__ */ d(
|
|
4888
|
+
/* @__PURE__ */ d(Q, {
|
|
4750
4889
|
variant: "green",
|
|
4751
4890
|
className: "ci-w-auto ci-h-10 ci-px-4 ci-shrink-0 ci-whitespace-nowrap",
|
|
4752
4891
|
disabled: !_.trim() || y,
|
|
@@ -4760,22 +4899,22 @@ function Br({ onOpen: e, onCreateGroup: t, onDragStart: n }) {
|
|
|
4760
4899
|
}
|
|
4761
4900
|
//#endregion
|
|
4762
4901
|
//#region src/theme.ts
|
|
4763
|
-
var
|
|
4902
|
+
var Ur = "chat-island-theme", Wr = () => {
|
|
4764
4903
|
try {
|
|
4765
|
-
let e = localStorage.getItem(
|
|
4904
|
+
let e = localStorage.getItem(Ur);
|
|
4766
4905
|
return e === "light" || e === "dark" || e === "system" ? e : void 0;
|
|
4767
4906
|
} catch {
|
|
4768
4907
|
return;
|
|
4769
4908
|
}
|
|
4770
4909
|
};
|
|
4771
|
-
function
|
|
4772
|
-
let [t, n] = c(() => e ??
|
|
4773
|
-
return i(() => n(e ??
|
|
4910
|
+
function Gr(e) {
|
|
4911
|
+
let [t, n] = c(() => e ?? Wr()), [r, a] = c(!1);
|
|
4912
|
+
return i(() => n(e ?? Wr()), [e]), i(() => {
|
|
4774
4913
|
let e = (e) => {
|
|
4775
4914
|
let t = e.detail?.theme;
|
|
4776
4915
|
if (t === "light" || t === "dark" || t === "system") {
|
|
4777
4916
|
try {
|
|
4778
|
-
localStorage.setItem(
|
|
4917
|
+
localStorage.setItem(Ur, t);
|
|
4779
4918
|
} catch {}
|
|
4780
4919
|
n(t);
|
|
4781
4920
|
}
|
|
@@ -4797,12 +4936,12 @@ function Ur(e) {
|
|
|
4797
4936
|
attributes: !0,
|
|
4798
4937
|
attributeFilter: ["class"]
|
|
4799
4938
|
}), () => r.disconnect();
|
|
4800
|
-
}, [t]), r;
|
|
4939
|
+
}, [t]), [r, t];
|
|
4801
4940
|
}
|
|
4802
4941
|
//#endregion
|
|
4803
4942
|
//#region src/ChatIsland.tsx
|
|
4804
|
-
function
|
|
4805
|
-
let e =
|
|
4943
|
+
function Kr() {
|
|
4944
|
+
let e = Y.getState();
|
|
4806
4945
|
return Object.values(e.conversations).map((t) => {
|
|
4807
4946
|
let n = t.messages[t.messages.length - 1], r = e.contacts[t.peer];
|
|
4808
4947
|
return {
|
|
@@ -4817,7 +4956,7 @@ function Wr() {
|
|
|
4817
4956
|
unread: t.unread,
|
|
4818
4957
|
members: t.members,
|
|
4819
4958
|
last: n ? {
|
|
4820
|
-
body:
|
|
4959
|
+
body: Yr(n.body),
|
|
4821
4960
|
ts: n.ts,
|
|
4822
4961
|
mine: n.mine,
|
|
4823
4962
|
oob: n.oob,
|
|
@@ -4826,25 +4965,25 @@ function Wr() {
|
|
|
4826
4965
|
};
|
|
4827
4966
|
}).filter((e) => e.last || e.kind === "group").sort((e, t) => (t.last?.ts ?? 0) - (e.last?.ts ?? 0));
|
|
4828
4967
|
}
|
|
4829
|
-
var
|
|
4968
|
+
var qr = class extends t {
|
|
4830
4969
|
state = { failed: !1 };
|
|
4831
4970
|
failures = [];
|
|
4832
4971
|
static getDerivedStateFromError() {
|
|
4833
4972
|
return { failed: !0 };
|
|
4834
4973
|
}
|
|
4835
4974
|
componentDidCatch(e) {
|
|
4836
|
-
|
|
4975
|
+
X("chat-island-error", {
|
|
4837
4976
|
scope: "render",
|
|
4838
4977
|
message: e.message
|
|
4839
4978
|
});
|
|
4840
4979
|
let t = Date.now();
|
|
4841
|
-
this.failures = [...this.failures.filter((e) => t - e < 1e4), t], !(this.failures.length >= 3) && (
|
|
4980
|
+
this.failures = [...this.failures.filter((e) => t - e < 1e4), t], !(this.failures.length >= 3) && (Y.getState().closeChat(), window.setTimeout(() => this.setState({ failed: !1 }), 0));
|
|
4842
4981
|
}
|
|
4843
4982
|
render() {
|
|
4844
4983
|
return this.state.failed ? null : this.props.children;
|
|
4845
4984
|
}
|
|
4846
4985
|
};
|
|
4847
|
-
function
|
|
4986
|
+
function Jr(e) {
|
|
4848
4987
|
try {
|
|
4849
4988
|
let [t, n, r] = atob(e).split(":");
|
|
4850
4989
|
return t && n && r ? {
|
|
@@ -4856,135 +4995,147 @@ function Kr(e) {
|
|
|
4856
4995
|
return null;
|
|
4857
4996
|
}
|
|
4858
4997
|
}
|
|
4859
|
-
var
|
|
4860
|
-
function
|
|
4861
|
-
let
|
|
4998
|
+
var Yr = (e) => (pr(e) ? "Attachment" : nr(e)).replace(/```[^\n]*\n?/g, "").replace(/(\*\*|__|~~|`)/g, "").replace(/(^|\s)[*_](\S[^*_]*)[*_]/g, "$1$2").replace(/\s+/g, " ").trim();
|
|
4999
|
+
function Xr(e, t = !1) {
|
|
5000
|
+
let [n, r] = c(e);
|
|
5001
|
+
return i(() => {
|
|
5002
|
+
if (e || t) return r(e);
|
|
5003
|
+
let n = window.setTimeout(() => r(e), matchMedia("(prefers-reduced-motion: reduce)").matches ? 0 : 400);
|
|
5004
|
+
return () => window.clearTimeout(n);
|
|
5005
|
+
}, [e]), [
|
|
5006
|
+
e || (t ? e : n),
|
|
5007
|
+
!e && !t && !!n,
|
|
5008
|
+
(t) => !e && t.target === t.currentTarget && r(e)
|
|
5009
|
+
];
|
|
5010
|
+
}
|
|
5011
|
+
function Zr({ 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 }) {
|
|
5012
|
+
let g = o(() => Jr(e), [e]), [_, v] = Gr(n), y = s(g), b = s(p), x = s(u);
|
|
4862
5013
|
i(() => {
|
|
4863
|
-
|
|
5014
|
+
y.current = g, b.current = p, x.current = u;
|
|
4864
5015
|
}, [
|
|
4865
5016
|
g,
|
|
4866
5017
|
p,
|
|
4867
5018
|
u
|
|
4868
|
-
]), i(() =>
|
|
5019
|
+
]), i(() => Y.setState({
|
|
4869
5020
|
maxHeads: a,
|
|
4870
5021
|
newChatButton: l
|
|
4871
5022
|
}), [a, l]);
|
|
4872
|
-
let [
|
|
5023
|
+
let [S, C] = c(0);
|
|
4873
5024
|
i(() => {
|
|
4874
|
-
let e = (e) => e.persisted &&
|
|
5025
|
+
let e = (e) => e.persisted && C((e) => e + 1);
|
|
4875
5026
|
return window.addEventListener("pageshow", e), () => window.removeEventListener("pageshow", e);
|
|
4876
5027
|
}, []);
|
|
4877
|
-
let
|
|
5028
|
+
let T = s(null), D = s(/* @__PURE__ */ new Set()), O = s(!1), k = s(null), A = s(null), j = E(A, `chat-island-pos:${g?.host ?? ""}:${g?.username ?? ""}`), { open: M, picker: N, status: P } = Y(w((e) => ({
|
|
4878
5029
|
open: e.open,
|
|
4879
5030
|
picker: e.picker,
|
|
4880
5031
|
status: e.status
|
|
4881
|
-
}))),
|
|
5032
|
+
}))), F = o(() => ({
|
|
4882
5033
|
send: async (e, t, n) => {
|
|
4883
|
-
let r =
|
|
5034
|
+
let r = T.current;
|
|
4884
5035
|
if (!r) throw Error("not connected");
|
|
4885
5036
|
try {
|
|
4886
|
-
|
|
5037
|
+
Y.getState().addMessage(e, await r.send(e, nr(t), void 0, n));
|
|
4887
5038
|
} catch (e) {
|
|
4888
|
-
throw
|
|
5039
|
+
throw X("chat-island-error", {
|
|
4889
5040
|
scope: "send",
|
|
4890
5041
|
message: e.message
|
|
4891
5042
|
}), e;
|
|
4892
5043
|
}
|
|
4893
5044
|
},
|
|
4894
|
-
typing: (e, t) =>
|
|
5045
|
+
typing: (e, t) => Y.getState().online[e] && T.current?.typing(e, t).catch(() => {}),
|
|
4895
5046
|
upload: async (e, t) => {
|
|
4896
|
-
let n =
|
|
5047
|
+
let n = T.current;
|
|
4897
5048
|
if (n) try {
|
|
4898
5049
|
let r = await n.upload(t);
|
|
4899
|
-
|
|
5050
|
+
Y.getState().addMessage(e, await n.send(e, t.name, r));
|
|
4900
5051
|
} catch (e) {
|
|
4901
|
-
|
|
5052
|
+
X("chat-island-error", {
|
|
4902
5053
|
scope: "upload",
|
|
4903
5054
|
message: e.message
|
|
4904
5055
|
});
|
|
4905
5056
|
}
|
|
4906
5057
|
},
|
|
4907
5058
|
createGroup: async (e, t, n) => {
|
|
4908
|
-
let r =
|
|
5059
|
+
let r = T.current, i = y.current;
|
|
4909
5060
|
if (r && i) try {
|
|
4910
|
-
let a = await r.createGroup(e, t, n), o =
|
|
5061
|
+
let a = await r.createGroup(e, t, n), o = Y.getState();
|
|
4911
5062
|
o.setGroup(a, e, [...t, i.username], n), o.openChat(a);
|
|
4912
5063
|
} catch (e) {
|
|
4913
|
-
|
|
5064
|
+
X("chat-island-error", {
|
|
4914
5065
|
scope: "group",
|
|
4915
5066
|
message: e.message
|
|
4916
5067
|
});
|
|
4917
5068
|
}
|
|
4918
5069
|
},
|
|
4919
5070
|
remove: async (e) => {
|
|
4920
|
-
let t =
|
|
5071
|
+
let t = T.current, n = y.current;
|
|
4921
5072
|
if (!t || !n) return;
|
|
4922
|
-
let r =
|
|
5073
|
+
let r = Y.getState().conversations[e];
|
|
4923
5074
|
try {
|
|
4924
|
-
r?.kind === "group" && await t.leaveGroup(e, !!r.owner).catch(() => {}), await
|
|
5075
|
+
r?.kind === "group" && await t.leaveGroup(e, !!r.owner).catch(() => {}), await Bn(n.host, n.token, e), Y.getState().removeConversation(e);
|
|
4925
5076
|
} catch (e) {
|
|
4926
|
-
|
|
5077
|
+
X("chat-island-error", {
|
|
4927
5078
|
scope: "delete",
|
|
4928
5079
|
message: e.message
|
|
4929
5080
|
});
|
|
4930
5081
|
}
|
|
4931
5082
|
},
|
|
4932
5083
|
react: async (e, t, n) => {
|
|
4933
|
-
let r =
|
|
5084
|
+
let r = T.current, i = y.current?.username;
|
|
4934
5085
|
if (!r || !i) return;
|
|
4935
|
-
let a = (
|
|
5086
|
+
let a = (Y.getState().conversations[e]?.reactions?.[t]?.[i] ?? []).includes(n) ? [] : [n];
|
|
4936
5087
|
try {
|
|
4937
|
-
await r.react(e, t, a),
|
|
5088
|
+
await r.react(e, t, a), Y.getState().applyReactions([{
|
|
4938
5089
|
peer: e,
|
|
4939
5090
|
target: t,
|
|
4940
5091
|
user: i,
|
|
4941
5092
|
emojis: a
|
|
4942
5093
|
}]);
|
|
4943
5094
|
} catch (e) {
|
|
4944
|
-
|
|
5095
|
+
X("chat-island-error", {
|
|
4945
5096
|
scope: "reaction",
|
|
4946
5097
|
message: e.message
|
|
4947
5098
|
});
|
|
4948
5099
|
}
|
|
4949
5100
|
},
|
|
4950
5101
|
loadOlder: async (e) => {
|
|
4951
|
-
let t =
|
|
4952
|
-
if (!(!t || n.complete ||
|
|
4953
|
-
|
|
5102
|
+
let t = T.current, n = Y.getState().ensure(e);
|
|
5103
|
+
if (!(!t || n.complete || D.current.has(e))) {
|
|
5104
|
+
D.current.add(e);
|
|
4954
5105
|
try {
|
|
4955
5106
|
let r = await t.history(e, n.oldest);
|
|
4956
|
-
|
|
5107
|
+
Y.getState().prependHistory(e, r.messages, r.complete, r.first), Y.getState().applyReactions(r.reactions);
|
|
4957
5108
|
} catch (e) {
|
|
4958
|
-
|
|
5109
|
+
X("chat-island-error", {
|
|
4959
5110
|
scope: "history",
|
|
4960
5111
|
message: e.message
|
|
4961
5112
|
});
|
|
4962
5113
|
} finally {
|
|
4963
|
-
|
|
5114
|
+
D.current.delete(e);
|
|
4964
5115
|
}
|
|
4965
5116
|
}
|
|
4966
5117
|
}
|
|
4967
5118
|
}), []);
|
|
4968
5119
|
i(() => {
|
|
4969
5120
|
if (!g) return;
|
|
4970
|
-
let e =
|
|
4971
|
-
e.reset(),
|
|
5121
|
+
let e = Y.getState();
|
|
5122
|
+
e.reset(), Y.setState({
|
|
4972
5123
|
me: g.username,
|
|
4973
|
-
mucHost: `conference.${
|
|
5124
|
+
mucHost: `conference.${hn}`,
|
|
4974
5125
|
maxHeads: a,
|
|
4975
5126
|
newChatButton: l
|
|
4976
5127
|
});
|
|
4977
|
-
let t = new
|
|
5128
|
+
let t = new _n(g, {
|
|
4978
5129
|
status: (n, a) => {
|
|
4979
|
-
if (e.setStatus(n, a),
|
|
5130
|
+
if (e.setStatus(n, a), X("chat-island-status", {
|
|
4980
5131
|
status: n,
|
|
4981
5132
|
error: a
|
|
4982
|
-
}), n === "online" && r && !
|
|
5133
|
+
}), n === "online" && r && !O.current && typeof Notification < "u") {
|
|
4983
5134
|
let e = Notification.permission;
|
|
4984
|
-
(e === "granted" ||
|
|
5135
|
+
(e === "granted" || x.current === "auto" && e === "default") && i();
|
|
4985
5136
|
}
|
|
4986
5137
|
n === "online" && t.listGroups().then((t) => t.forEach((t) => e.setGroup(t.peer, t.name, t.members, t.avatar, t.owner))).catch(() => {}).then(() => t.recent()).then((e) => {
|
|
4987
|
-
e && (
|
|
5138
|
+
e && (Y.getState().seed(e.messages, g.username), Y.getState().applyReactions(e.reactions));
|
|
4988
5139
|
}).catch(() => {});
|
|
4989
5140
|
},
|
|
4990
5141
|
typing: (t, n) => e.setTyping(t, n),
|
|
@@ -4999,19 +5150,19 @@ function Jr({ dataConfig: e, position: t = "bottom-right", theme: n, serviceWork
|
|
|
4999
5150
|
}).catch(() => {});
|
|
5000
5151
|
},
|
|
5001
5152
|
message: (r) => {
|
|
5002
|
-
let i =
|
|
5003
|
-
r.room && !
|
|
5153
|
+
let i = Mn(r);
|
|
5154
|
+
r.room && !Y.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 }), X("chat-island-message", {
|
|
5004
5155
|
...r,
|
|
5005
5156
|
peer: i
|
|
5006
|
-
}),
|
|
5157
|
+
}), X("chat-island-unread", { total: Y.getState().totalUnread() }), r.mine || n(i, r);
|
|
5007
5158
|
}
|
|
5008
5159
|
}), n = (e, t) => {
|
|
5009
|
-
let n =
|
|
5160
|
+
let n = Y.getState(), r = document.visibilityState === "visible";
|
|
5010
5161
|
if (r && n.open === e) return;
|
|
5011
|
-
let i = n.conversations[e], a = i?.kind === "group" ? i.name ?? e : n.contacts[e]?.name ?? n.inactive[e] ?? e, o = t.oob ? "Attachment" :
|
|
5012
|
-
|
|
5162
|
+
let i = n.conversations[e], a = i?.kind === "group" ? i.name ?? e : n.contacts[e]?.name ?? n.inactive[e] ?? e, o = t.oob ? "Attachment" : nr(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;
|
|
5163
|
+
b.current && Cn();
|
|
5013
5164
|
let u = s ? i?.avatar : n.contacts[e]?.avatar;
|
|
5014
|
-
if (
|
|
5165
|
+
if (X("chat-island-notify", {
|
|
5015
5166
|
peer: e,
|
|
5016
5167
|
name: a,
|
|
5017
5168
|
body: l,
|
|
@@ -5027,86 +5178,103 @@ function Jr({ dataConfig: e, position: t = "bottom-right", theme: n, serviceWork
|
|
|
5027
5178
|
tag: `chat-${e}`
|
|
5028
5179
|
});
|
|
5029
5180
|
t.onclick = () => {
|
|
5030
|
-
window.focus(),
|
|
5181
|
+
window.focus(), Y.getState().openChat(e), t.close();
|
|
5031
5182
|
};
|
|
5032
5183
|
} catch {}
|
|
5033
5184
|
};
|
|
5034
|
-
|
|
5185
|
+
T.current = t;
|
|
5035
5186
|
let i = () => {
|
|
5036
|
-
r && !
|
|
5187
|
+
r && !O.current && (O.current = !0, Wn(g, r).then((e) => {
|
|
5037
5188
|
if (!e) {
|
|
5038
|
-
|
|
5189
|
+
O.current = !1, Y.setState({ push: Notification.permission === "denied" ? "denied" : "ask" });
|
|
5039
5190
|
return;
|
|
5040
5191
|
}
|
|
5041
5192
|
return t.enablePush(e.service, e.node).then(() => {
|
|
5042
|
-
|
|
5193
|
+
k.current = e, Y.setState({ push: "enabled" }), X("chat-island-push", { enabled: !0 });
|
|
5043
5194
|
});
|
|
5044
5195
|
}).catch((e) => {
|
|
5045
|
-
|
|
5196
|
+
O.current = !1, X("chat-island-error", {
|
|
5046
5197
|
scope: "push",
|
|
5047
5198
|
message: e.message
|
|
5048
5199
|
});
|
|
5049
5200
|
}));
|
|
5050
5201
|
}, o = !!r && "serviceWorker" in navigator && "PushManager" in window && typeof Notification < "u";
|
|
5051
|
-
|
|
5202
|
+
Y.setState({
|
|
5052
5203
|
push: o ? Notification.permission === "denied" ? "denied" : "ask" : "unavailable",
|
|
5053
5204
|
enablePush: i
|
|
5054
5205
|
});
|
|
5055
5206
|
let s = () => t.stop();
|
|
5056
5207
|
window.addEventListener("pagehide", s), t.start();
|
|
5057
5208
|
let c = () => {
|
|
5058
|
-
|
|
5209
|
+
Rn(g.host, g.token).then(e.setMobile).catch(() => {}), zn(g.host, g.token).then(e.setInactive).catch(() => {});
|
|
5059
5210
|
};
|
|
5060
5211
|
c();
|
|
5061
5212
|
let u = window.setInterval(c, 12e4);
|
|
5062
|
-
|
|
5213
|
+
Ln(g.host, g.token, g.username, (e) => Y.setState({ myName: e })).then(e.setContacts).catch((e) => X("chat-island-error", {
|
|
5063
5214
|
scope: "contacts",
|
|
5064
5215
|
message: e.message
|
|
5065
5216
|
}));
|
|
5066
|
-
let d =
|
|
5217
|
+
let d = Z("chat-island-open", ({ username: t }) => t && e.openChat(t)), f = Z("chat-island-close", () => e.closeChat()), p = Z("chat-island-new", () => e.setPicker(!0)), m = Z("chat-island-delete", ({ username: e }) => e && F.remove(e)), h = Z("chat-island-send", ({ username: e, text: t }) => e && t && F.send(e, t).catch(() => {})), _ = Z("chat-island-group-create", ({ name: e, members: t }) => e && t?.length && F.createGroup(e, t)), v = Z("chat-island-contacts", ({ contacts: t }) => t && e.setContacts(t)), y = Z("chat-island-conversations-request", () => X("chat-island-conversations", { conversations: Kr() }));
|
|
5067
5218
|
return () => {
|
|
5068
|
-
window.removeEventListener("pagehide", s), window.clearInterval(u),
|
|
5219
|
+
window.removeEventListener("pagehide", s), window.clearInterval(u), y(), p(), m(), h(), _(), d(), f(), v(), k.current && t.disablePush(k.current.service, k.current.node).catch(() => {}), k.current = null, t.stop(), T.current = null, O.current = !1;
|
|
5069
5220
|
};
|
|
5070
5221
|
}, [
|
|
5071
5222
|
g,
|
|
5072
5223
|
r,
|
|
5073
|
-
|
|
5224
|
+
S
|
|
5074
5225
|
]);
|
|
5075
|
-
let
|
|
5226
|
+
let ee = Y((e) => Object.keys(e.contacts).join(","));
|
|
5076
5227
|
i(() => {
|
|
5077
|
-
|
|
5078
|
-
}, [
|
|
5079
|
-
let te =
|
|
5080
|
-
i(() =>
|
|
5081
|
-
let ne =
|
|
5082
|
-
|
|
5083
|
-
let re =
|
|
5084
|
-
|
|
5085
|
-
|
|
5086
|
-
}
|
|
5228
|
+
P === "online" && ee && T.current?.announce(ee.split(","));
|
|
5229
|
+
}, [P, ee]);
|
|
5230
|
+
let te = Y((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 + "#" + Object.keys(e.inactive).length);
|
|
5231
|
+
i(() => X("chat-island-conversations", { conversations: Kr() }), [te]);
|
|
5232
|
+
let ne = Y((e) => Object.values(e.conversations).reduce((e, t) => e + t.unread, 0));
|
|
5233
|
+
i(() => X("chat-island-unread", { total: ne }), [ne]);
|
|
5234
|
+
let re = s(null), ie = s(M), I = s(null), L = !N && !!M && M !== ie.current && !!re.current;
|
|
5235
|
+
L && (I.current = re.current.offsetHeight), i(() => {
|
|
5236
|
+
ie.current = M, M || (I.current = null);
|
|
5237
|
+
}, [M]);
|
|
5238
|
+
let [ae, oe, se] = Xr(M), [ce, le, R] = Xr(N, L);
|
|
5239
|
+
if (!g) return null;
|
|
5240
|
+
let ue = m && !h && j.anchor ? {
|
|
5241
|
+
right: j.anchor.right,
|
|
5242
|
+
bottom: j.anchor.bottom
|
|
5243
|
+
} : void 0, de = ue ? "" : t === "bottom-left" ? "ci-left-4 ci-bottom-5" : "ci-right-4 ci-bottom-5";
|
|
5087
5244
|
return /* @__PURE__ */ d("div", {
|
|
5088
|
-
ref:
|
|
5089
|
-
style:
|
|
5090
|
-
onClickCapture:
|
|
5091
|
-
className: `chat-island-root ${_ ? "ci-dark" : ""} ci-fixed ${
|
|
5092
|
-
"data-status":
|
|
5093
|
-
children: /* @__PURE__ */ f(
|
|
5094
|
-
|
|
5095
|
-
|
|
5096
|
-
|
|
5097
|
-
|
|
5245
|
+
ref: A,
|
|
5246
|
+
style: ue,
|
|
5247
|
+
onClickCapture: j.onClickCapture,
|
|
5248
|
+
className: `chat-island-root ${_ ? "ci-dark" : ""} ci-fixed ${de} ci-z-[9999] ci-flex ci-items-end ci-gap-3 ci-font-sans ci-select-none`,
|
|
5249
|
+
"data-status": P,
|
|
5250
|
+
children: /* @__PURE__ */ f(qr, { children: [
|
|
5251
|
+
ae && /* @__PURE__ */ d("div", {
|
|
5252
|
+
className: oe ? "ci-anim-close" : I.current ? "ci-anim-morph" : "ci-anim-open",
|
|
5253
|
+
style: I.current ? { "--ci-from": `${I.current}px` } : void 0,
|
|
5254
|
+
onAnimationEnd: se,
|
|
5255
|
+
children: /* @__PURE__ */ d(Rr, {
|
|
5256
|
+
peer: ae,
|
|
5257
|
+
actions: F,
|
|
5258
|
+
theme: v,
|
|
5259
|
+
onDragStart: h ?? (m ? j.start : void 0)
|
|
5260
|
+
})
|
|
5098
5261
|
}),
|
|
5099
|
-
|
|
5100
|
-
|
|
5101
|
-
|
|
5102
|
-
|
|
5262
|
+
ce && /* @__PURE__ */ d("div", {
|
|
5263
|
+
ref: re,
|
|
5264
|
+
className: le ? "ci-anim-close" : "ci-anim-open",
|
|
5265
|
+
onAnimationEnd: R,
|
|
5266
|
+
children: /* @__PURE__ */ d(Hr, {
|
|
5267
|
+
onOpen: (e) => Y.getState().openChat(e),
|
|
5268
|
+
onCreateGroup: F.createGroup,
|
|
5269
|
+
onDragStart: h ?? (m ? j.start : void 0)
|
|
5270
|
+
})
|
|
5103
5271
|
}),
|
|
5104
|
-
/* @__PURE__ */ d(
|
|
5105
|
-
onDragStart: h ?? (m ?
|
|
5272
|
+
/* @__PURE__ */ d(Zn, {
|
|
5273
|
+
onDragStart: h ?? (m ? j.start : void 0),
|
|
5106
5274
|
pushButton: u !== "auto"
|
|
5107
5275
|
})
|
|
5108
5276
|
] })
|
|
5109
5277
|
});
|
|
5110
5278
|
}
|
|
5111
5279
|
//#endregion
|
|
5112
|
-
export {
|
|
5280
|
+
export { Zr as ChatIsland, Fn as contactsFromOperators };
|