@taole/newgiftbar 0.0.5 → 0.0.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -562,8 +562,8 @@ const options = {
562
562
  */
563
563
  isChatTest: false,
564
564
  /**
565
- * 接口域名。lib 拼 URL 时按 key 取。
566
- * papi:列表/支付;yapi:充值页。未注入时按 isChatTest 拼测试/正式域。
565
+ * 接口域名。lib 拼 URL 时按 key 取,必须由宿主注入。
566
+ * papi:列表/支付;yapi:充值页。
567
567
  * @type {{ papi?: string, yapi?: string, api?: string }}
568
568
  */
569
569
  apiDomain: {},
@@ -628,8 +628,8 @@ const options = {
628
628
  */
629
629
  clickGiftItem: null,
630
630
  /**
631
- * 底部确认后的厅内独占执行。可能扣包裹 / 送给当前厅。
632
- * type 30/37 onlySendGift(teacherid=0)。特赦卡 type=29 在栏内 giveGift,不进这里。
631
+ * 底部确认后的厅内独占执行。type 30/37 已在栏内 giveGift,不再走这里。
632
+ * 特赦卡 type=29 也在栏内。目前新栏底部不再调用。
633
633
  * @type {(payload: { gift: object, tabId: number|string, count?: number, selectUser?: object }) => void|Promise<void>}
634
634
  */
635
635
  useGiftAsync: null,
@@ -640,1604 +640,2183 @@ const options = {
640
640
  */
641
641
  playGiftAnimation: null,
642
642
  /**
643
- * 点顶栏「贵族」:厅内打开 levelm iframe。
643
+ * 打开限额设置页。不注入时 `window.open(getLimitSettingsUrl())`。
644
644
  * @type {() => void}
645
645
  */
646
- onOpenNobility: null,
646
+ onOpenLimitSettings: null,
647
647
  /**
648
- * 打开限额设置页。不注入时 `window.open(getLimitSettingsUrl())`。
649
- * @type {() => void}
648
+ * 栏内改收礼人。厅内对标旧栏点 #divTeacherList 写 giftToTeacher,下次开栏带回。
649
+ * @type {(user: { uid: number|string, nickname: string, color?: string }) => void}
650
650
  */
651
- onOpenLimitSettings: null
651
+ onSelectUser: null
652
652
  };
653
- function get_each_context$a(ctx, list, i) {
654
- const child_ctx = ctx.slice();
655
- child_ctx[8] = list[i];
656
- return child_ctx;
657
- }
658
- function create_if_block_3$8(ctx) {
659
- let b;
660
- return {
661
- c() {
662
- b = element("b");
663
- attr(b, "class", "giftbar-tab-dot");
664
- },
665
- m(target, anchor) {
666
- insert(target, b, anchor);
667
- },
668
- d(detaching) {
669
- if (detaching) {
670
- detach(b);
653
+ const deferred = function() {
654
+ const defer = {};
655
+ defer.promise = new Promise((resolve, reject) => {
656
+ defer.resolve = resolve;
657
+ defer.reject = reject;
658
+ });
659
+ return defer;
660
+ };
661
+ function createModal(_Class, props = {}, target = document.body) {
662
+ const wrap = document.createElement("div");
663
+ wrap.setAttribute("data-modal-overlay", "");
664
+ wrap.setAttribute("data-giftbar-modal", "");
665
+ target.appendChild(wrap);
666
+ let modal = new _Class({ target: wrap, props: { closeModal, ...props } });
667
+ const defer = deferred();
668
+ function closeModal(err, result) {
669
+ try {
670
+ modal && modal.$destroy();
671
+ } finally {
672
+ modal = null;
673
+ if (wrap.parentNode) {
674
+ wrap.parentNode.removeChild(wrap);
671
675
  }
672
676
  }
673
- };
674
- }
675
- function create_each_block$a(key_1, ctx) {
676
- let div;
677
- let span;
678
- let t0_value = (
679
- /*item*/
680
- ctx[8].title + ""
681
- );
682
- let t0;
683
- let t1;
684
- let t2;
685
- let div_class_value;
686
- let mounted;
687
- let dispose;
688
- let if_block = (
689
- /*item*/
690
- ctx[8].is_new == 1 && create_if_block_3$8()
691
- );
692
- function click_handler() {
693
- return (
694
- /*click_handler*/
695
- ctx[7](
696
- /*item*/
697
- ctx[8]
698
- )
699
- );
700
- }
701
- return {
702
- key: key_1,
703
- first: null,
704
- c() {
705
- div = element("div");
706
- span = element("span");
707
- t0 = text(t0_value);
708
- t1 = space();
709
- if (if_block) if_block.c();
710
- t2 = space();
711
- attr(div, "class", div_class_value = "giftbar-tab " + /*item*/
712
- (ctx[8].id == /*tabId*/
713
- ctx[1] ? "giftbar-tab-on" : ""));
714
- attr(div, "role", "presentation");
715
- this.first = div;
716
- },
717
- m(target, anchor) {
718
- insert(target, div, anchor);
719
- append(div, span);
720
- append(span, t0);
721
- append(div, t1);
722
- if (if_block) if_block.m(div, null);
723
- append(div, t2);
724
- if (!mounted) {
725
- dispose = listen(div, "click", stop_propagation(click_handler));
726
- mounted = true;
727
- }
728
- },
729
- p(new_ctx, dirty) {
730
- ctx = new_ctx;
731
- if (dirty & /*tabs*/
732
- 1 && t0_value !== (t0_value = /*item*/
733
- ctx[8].title + "")) set_data(t0, t0_value);
734
- if (
735
- /*item*/
736
- ctx[8].is_new == 1
737
- ) {
738
- if (if_block) ;
739
- else {
740
- if_block = create_if_block_3$8();
741
- if_block.c();
742
- if_block.m(div, t2);
743
- }
744
- } else if (if_block) {
745
- if_block.d(1);
746
- if_block = null;
747
- }
748
- if (dirty & /*tabs, tabId*/
749
- 3 && div_class_value !== (div_class_value = "giftbar-tab " + /*item*/
750
- (ctx[8].id == /*tabId*/
751
- ctx[1] ? "giftbar-tab-on" : ""))) {
752
- attr(div, "class", div_class_value);
753
- }
754
- },
755
- d(detaching) {
756
- if (detaching) {
757
- detach(div);
758
- }
759
- if (if_block) if_block.d();
760
- mounted = false;
761
- dispose();
677
+ if (err) {
678
+ defer.reject(err);
679
+ } else {
680
+ defer.resolve(result);
762
681
  }
763
- };
682
+ }
683
+ return { modal, closeModal, promise: defer.promise };
764
684
  }
765
- function create_if_block_1$l(ctx) {
766
- let a;
767
- let t0;
768
- let t1_value = (
769
- /*tip*/
770
- ctx[2].text + ""
771
- );
772
- let t1;
773
- let a_href_value;
774
- let if_block = (
775
- /*tip*/
776
- ctx[2].img && create_if_block_2$c(ctx)
777
- );
778
- return {
779
- c() {
780
- a = element("a");
781
- if (if_block) if_block.c();
782
- t0 = space();
783
- t1 = text(t1_value);
784
- attr(a, "href", a_href_value = /*tip*/
785
- ctx[2].link);
786
- attr(a, "target", "_blank");
787
- attr(a, "rel", "noopener noreferrer");
788
- },
789
- m(target, anchor) {
790
- insert(target, a, anchor);
791
- if (if_block) if_block.m(a, null);
792
- append(a, t0);
793
- append(a, t1);
794
- },
795
- p(ctx2, dirty) {
796
- if (
797
- /*tip*/
798
- ctx2[2].img
799
- ) {
800
- if (if_block) {
801
- if_block.p(ctx2, dirty);
802
- } else {
803
- if_block = create_if_block_2$c(ctx2);
804
- if_block.c();
805
- if_block.m(a, t0);
806
- }
807
- } else if (if_block) {
808
- if_block.d(1);
809
- if_block = null;
810
- }
811
- if (dirty & /*tip*/
812
- 4 && t1_value !== (t1_value = /*tip*/
813
- ctx2[2].text + "")) set_data(t1, t1_value);
814
- if (dirty & /*tip*/
815
- 4 && a_href_value !== (a_href_value = /*tip*/
816
- ctx2[2].link)) {
817
- attr(a, "href", a_href_value);
818
- }
819
- },
820
- d(detaching) {
821
- if (detaching) {
822
- detach(a);
823
- }
824
- if (if_block) if_block.d();
825
- }
826
- };
685
+ function joinQuery(parts) {
686
+ return parts.filter((item) => item && item[1] !== void 0 && item[1] !== null).map(([key, value]) => key + "=" + value).join("&");
827
687
  }
828
- function create_if_block_2$c(ctx) {
829
- let img;
830
- let img_src_value;
831
- return {
832
- c() {
833
- img = element("img");
834
- if (!src_url_equal(img.src, img_src_value = /*tip*/
835
- ctx[2].img)) attr(img, "src", img_src_value);
836
- attr(img, "alt", "");
837
- },
838
- m(target, anchor) {
839
- insert(target, img, anchor);
840
- },
841
- p(ctx2, dirty) {
842
- if (dirty & /*tip*/
843
- 4 && !src_url_equal(img.src, img_src_value = /*tip*/
844
- ctx2[2].img)) {
845
- attr(img, "src", img_src_value);
846
- }
847
- },
848
- d(detaching) {
849
- if (detaching) {
850
- detach(img);
851
- }
688
+ function appendQuery(url, params) {
689
+ let next = url || "";
690
+ Object.keys(params || {}).forEach((key) => {
691
+ const value = params[key];
692
+ if (value === void 0 || value === null) {
693
+ return;
852
694
  }
853
- };
695
+ const re = new RegExp("([?&])" + key + "=[^&]*");
696
+ if (re.test(next)) {
697
+ next = next.replace(re, "$1" + key + "=" + value);
698
+ } else {
699
+ next += (next.indexOf("?") >= 0 ? "&" : "?") + key + "=" + value;
700
+ }
701
+ });
702
+ return next;
854
703
  }
855
- function create_if_block$o(ctx) {
856
- let div;
857
- let mounted;
858
- let dispose;
859
- return {
860
- c() {
861
- div = element("div");
862
- div.innerHTML = `<img src="https://asset.tuwan.com/officialsite/images/king.png" alt=""/> <span>贵族</span>`;
863
- attr(div, "class", "giftbar-nobility");
864
- attr(div, "role", "presentation");
865
- },
866
- m(target, anchor) {
867
- insert(target, div, anchor);
868
- if (!mounted) {
869
- dispose = listen(div, "click", stop_propagation(
870
- /*openNobility*/
871
- ctx[5]
872
- ));
873
- mounted = true;
874
- }
875
- },
876
- p: noop,
877
- d(detaching) {
878
- if (detaching) {
879
- detach(div);
880
- }
881
- mounted = false;
882
- dispose();
883
- }
884
- };
704
+ function stripSlash(domain) {
705
+ return domain ? String(domain).replace(/\/$/, "") : "";
885
706
  }
886
- function create_fragment$s(ctx) {
887
- let div2;
888
- let div0;
889
- let each_blocks = [];
890
- let each_1_lookup = /* @__PURE__ */ new Map();
891
- let t0;
892
- let div1;
893
- let t1;
894
- let each_value = ensure_array_like(
895
- /*tabs*/
896
- ctx[0]
897
- );
898
- const get_key = (ctx2) => (
899
- /*item*/
900
- ctx2[8].id
901
- );
902
- for (let i = 0; i < each_value.length; i += 1) {
903
- let child_ctx = get_each_context$a(ctx, each_value, i);
904
- let key = get_key(child_ctx);
905
- each_1_lookup.set(key, each_blocks[i] = create_each_block$a(key, child_ctx));
707
+ function resolveApiDomain(kind) {
708
+ const map = options.apiDomain || {};
709
+ const injected = map[kind];
710
+ if (injected) {
711
+ return stripSlash(injected);
906
712
  }
907
- let if_block0 = (
908
- /*tip*/
909
- ctx[2] && /*tip*/
910
- ctx[2].text && /*tip*/
911
- ctx[2].link && /*tip*/
912
- ctx[2].kind !== "hidden" && create_if_block_1$l(ctx)
913
- );
914
- let if_block1 = (
915
- /*showNobility*/
916
- ctx[3] && create_if_block$o(ctx)
917
- );
918
- return {
919
- c() {
920
- div2 = element("div");
921
- div0 = element("div");
922
- for (let i = 0; i < each_blocks.length; i += 1) {
923
- each_blocks[i].c();
924
- }
925
- t0 = space();
926
- div1 = element("div");
927
- if (if_block0) if_block0.c();
928
- t1 = space();
929
- if (if_block1) if_block1.c();
930
- attr(div0, "class", "giftbar-tabs");
931
- attr(div1, "class", "giftbar-tip");
932
- attr(div2, "class", "giftbar-head");
933
- },
934
- m(target, anchor) {
935
- insert(target, div2, anchor);
936
- append(div2, div0);
937
- for (let i = 0; i < each_blocks.length; i += 1) {
938
- if (each_blocks[i]) {
939
- each_blocks[i].m(div0, null);
940
- }
941
- }
942
- append(div2, t0);
943
- append(div2, div1);
944
- if (if_block0) if_block0.m(div1, null);
945
- append(div1, t1);
946
- if (if_block1) if_block1.m(div1, null);
947
- },
948
- p(ctx2, [dirty]) {
949
- if (dirty & /*tabs, tabId, switchTab*/
950
- 19) {
951
- each_value = ensure_array_like(
952
- /*tabs*/
953
- ctx2[0]
954
- );
955
- each_blocks = update_keyed_each(each_blocks, dirty, get_key, 1, ctx2, each_value, each_1_lookup, div0, destroy_block, create_each_block$a, null, get_each_context$a);
956
- }
957
- if (
958
- /*tip*/
959
- ctx2[2] && /*tip*/
960
- ctx2[2].text && /*tip*/
961
- ctx2[2].link && /*tip*/
962
- ctx2[2].kind !== "hidden"
963
- ) {
964
- if (if_block0) {
965
- if_block0.p(ctx2, dirty);
966
- } else {
967
- if_block0 = create_if_block_1$l(ctx2);
968
- if_block0.c();
969
- if_block0.m(div1, t1);
970
- }
971
- } else if (if_block0) {
972
- if_block0.d(1);
973
- if_block0 = null;
974
- }
975
- if (
976
- /*showNobility*/
977
- ctx2[3]
978
- ) {
979
- if (if_block1) {
980
- if_block1.p(ctx2, dirty);
981
- } else {
982
- if_block1 = create_if_block$o(ctx2);
983
- if_block1.c();
984
- if_block1.m(div1, null);
985
- }
986
- } else if (if_block1) {
987
- if_block1.d(1);
988
- if_block1 = null;
989
- }
990
- },
991
- i: noop,
992
- o: noop,
993
- d(detaching) {
994
- if (detaching) {
995
- detach(div2);
996
- }
997
- for (let i = 0; i < each_blocks.length; i += 1) {
998
- each_blocks[i].d();
999
- }
1000
- if (if_block0) if_block0.d();
1001
- if (if_block1) if_block1.d();
1002
- }
1003
- };
713
+ throw new Error("giftBarLib apiDomain." + kind + " is required");
1004
714
  }
1005
- function instance$s($$self, $$props, $$invalidate) {
1006
- let { tabs = [] } = $$props;
1007
- let { tabId = 0 } = $$props;
1008
- let { tip = {
1009
- kind: "magic",
1010
- text: "",
1011
- link: "",
1012
- img: ""
1013
- } } = $$props;
1014
- let { showNobility = true } = $$props;
1015
- let { onClickTab } = $$props;
1016
- function switchTab(item) {
1017
- onClickTab && onClickTab(item);
1018
- }
1019
- function openNobility(event) {
1020
- event && event.stopPropagation && event.stopPropagation();
1021
- if (typeof options.onOpenNobility === "function") {
1022
- options.onOpenNobility();
1023
- }
715
+ function assertSource(source) {
716
+ if (source !== "room" && source !== "im") {
717
+ throw new Error("giftBarLib source must be 'room' or 'im'");
1024
718
  }
1025
- const click_handler = (item) => switchTab(item);
1026
- $$self.$$set = ($$props2) => {
1027
- if ("tabs" in $$props2) $$invalidate(0, tabs = $$props2.tabs);
1028
- if ("tabId" in $$props2) $$invalidate(1, tabId = $$props2.tabId);
1029
- if ("tip" in $$props2) $$invalidate(2, tip = $$props2.tip);
1030
- if ("showNobility" in $$props2) $$invalidate(3, showNobility = $$props2.showNobility);
1031
- if ("onClickTab" in $$props2) $$invalidate(6, onClickTab = $$props2.onClickTab);
1032
- };
1033
- return [
1034
- tabs,
1035
- tabId,
1036
- tip,
1037
- showNobility,
1038
- switchTab,
1039
- openNobility,
1040
- onClickTab,
1041
- click_handler
1042
- ];
1043
719
  }
1044
- class GiftTabs extends SvelteComponent {
1045
- constructor(options2) {
1046
- super();
1047
- init(this, options2, instance$s, create_fragment$s, safe_not_equal, {
1048
- tabs: 0,
1049
- tabId: 1,
1050
- tip: 2,
1051
- showNobility: 3,
1052
- onClickTab: 6
1053
- });
720
+ function assertRoomPayContext(ctx) {
721
+ if (!ctx || ctx.cid === void 0 || ctx.cid === null || ctx.cid === "") {
722
+ throw new Error("source=room requires cid in getPayContext");
1054
723
  }
1055
- }
1056
- function giftHoverTip(node, html) {
1057
- let tip = null;
1058
- let currentHtml = html || "";
1059
- function hide() {
1060
- if (tip) {
1061
- tip.remove();
1062
- tip = null;
1063
- }
724
+ if (ctx.imuid !== void 0 || ctx.group_id !== void 0) {
725
+ throw new Error("source=room PayContext must not include imuid/group_id");
1064
726
  }
1065
- function show() {
1066
- hide();
1067
- if (!currentHtml) {
1068
- return;
1069
- }
1070
- tip = document.createElement("div");
1071
- tip.className = "giftbar-item-tooltip";
1072
- tip.innerHTML = '<div class="giftbar-item-tooltip-inner">' + currentHtml + '</div><div class="giftbar-item-tooltip-arrow"></div>';
1073
- document.body.appendChild(tip);
1074
- const rect = node.getBoundingClientRect();
1075
- tip.style.left = rect.left + rect.width / 2 + "px";
1076
- tip.style.top = rect.top + "px";
727
+ if (String(ctx.actid) === "101") {
728
+ throw new Error("source=room PayContext must not use actid=101");
1077
729
  }
1078
- node.addEventListener("mouseenter", show);
1079
- node.addEventListener("mouseleave", hide);
1080
- window.addEventListener("scroll", hide, true);
1081
- return {
1082
- update(nextHtml) {
1083
- currentHtml = nextHtml || "";
1084
- if (tip) {
1085
- if (!currentHtml) {
1086
- hide();
1087
- } else {
1088
- show();
1089
- }
1090
- }
1091
- },
1092
- destroy() {
1093
- hide();
1094
- node.removeEventListener("mouseenter", show);
1095
- node.removeEventListener("mouseleave", hide);
1096
- window.removeEventListener("scroll", hide, true);
1097
- }
1098
- };
1099
730
  }
1100
- const OSS_HOST_RE = /(^|\.)tuwandata\.com$|(^|\.)img\d*\.tuwan\.com$/i;
1101
- const PROCESS = "image/resize,m_fill,w_128,h_128/format,webp";
1102
- function giftListThumbUrl(src) {
1103
- if (!src || typeof src !== "string") {
1104
- return src || "";
1105
- }
1106
- if (/^(data:|blob:)/i.test(src)) {
1107
- return src;
731
+ function hasValue$3(value) {
732
+ return value !== void 0 && value !== null && value !== "";
733
+ }
734
+ function assertImPayContext(ctx) {
735
+ if (!ctx) {
736
+ throw new Error("source=im requires getPayContext");
1108
737
  }
1109
- if (/[?&]x-oss-process=/i.test(src)) {
1110
- return src;
738
+ if (!hasValue$3(ctx.imuid) && !hasValue$3(ctx.group_id)) {
739
+ throw new Error("source=im requires imuid or group_id in getPayContext");
1111
740
  }
1112
- try {
1113
- const url = new URL(src, typeof location !== "undefined" ? location.href : "https://www.tuwan.com");
1114
- if (!OSS_HOST_RE.test(url.hostname)) {
1115
- return src;
1116
- }
1117
- url.searchParams.set("x-oss-process", PROCESS);
1118
- return url.toString();
1119
- } catch (e) {
1120
- return src;
741
+ if (hasValue$3(ctx.cid)) {
742
+ throw new Error("source=im PayContext must not include cid");
743
+ }
744
+ if (ctx.is_whole_wheat !== void 0) {
745
+ throw new Error("source=im PayContext must not include is_whole_wheat");
1121
746
  }
1122
747
  }
1123
- const PRELOAD_MARGIN = "240px 0px";
1124
- const GIFT_IMG_PLACEHOLDER = "data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7";
1125
- function findGridRoot(node) {
1126
- return node.closest ? node.closest(".giftbar-grid") : null;
748
+ function getSource() {
749
+ return options.source;
1127
750
  }
1128
- function setSrc(node, src) {
1129
- if (node.getAttribute("src") === src) {
1130
- return;
751
+ function isImSource() {
752
+ return options.source === "im";
753
+ }
754
+ function papi() {
755
+ return resolveApiDomain("papi");
756
+ }
757
+ function yapi() {
758
+ return resolveApiDomain("yapi");
759
+ }
760
+ function hasValue$2(value) {
761
+ return value !== void 0 && value !== null && value !== "";
762
+ }
763
+ function sceneParts$1(ctx) {
764
+ if (hasValue$2(ctx && ctx.group_id)) {
765
+ return [["group_id", ctx.group_id]];
1131
766
  }
1132
- node.setAttribute("src", src);
767
+ return [["imuid", ctx && ctx.imuid]];
1133
768
  }
1134
- function lazyGiftImg(node, src) {
1135
- let currentSrc = src || "";
1136
- let observer = null;
1137
- function clearObserver() {
1138
- if (observer) {
1139
- observer.disconnect();
1140
- observer = null;
1141
- }
769
+ function openParts(giftId, num, paySure, ctx) {
770
+ return [
771
+ ["giftid", giftId],
772
+ ["num", num || 1],
773
+ ["pay_confirm", 1],
774
+ ["apiver", 1],
775
+ ["pay_sure", paySure || 0],
776
+ ["uids", ctx && ctx.selfUid],
777
+ ...sceneParts$1(ctx)
778
+ ];
779
+ }
780
+ function getRechargeUrl() {
781
+ return yapi() + "/activityapi/recharge";
782
+ }
783
+ function getLimitSettingsUrl() {
784
+ return "https://y" + (options.isChatTest ? "-test" : "") + ".tuwan.com/home/consume-check";
785
+ }
786
+ function giveUpConsumeLimitUrl() {
787
+ return yapi() + "/user/setGiftRemindSetting?format=jsonp";
788
+ }
789
+ function giftListsUrl(cid, navid) {
790
+ return papi() + "/Teacher/giftLists?format=jsonp&platform=0" + (hasValue$2(cid) ? "&cid=" + cid : "") + "&navid=" + navid + "&apiver=4";
791
+ }
792
+ function haveGiftUrl(cid, navid) {
793
+ return papi() + "/Teacher/haveGift?format=jsonp&mode=2" + (hasValue$2(cid) ? "&cid=" + cid : "") + "&navid=" + navid;
794
+ }
795
+ function getMoneyUrl() {
796
+ return papi() + "/Teacher/getMoney";
797
+ }
798
+ function diamondGiftMoreUrl(query) {
799
+ return papi() + "/Diamond/giftMore?" + query;
800
+ }
801
+ function giveGiftUrl(query) {
802
+ return papi() + "/Teacher/giveGift?" + query;
803
+ }
804
+ function giveGiftInfoUrl(cid, giftId) {
805
+ return yapi() + "/nobility/getGiveGiftInfo?cid=" + cid + "&id=" + giftId + "&freeCardTypeid=2&format=jsonp";
806
+ }
807
+ function treasureBuyUrl(query) {
808
+ return papi() + "/Treasure/buy?format=jsonp&" + query;
809
+ }
810
+ function blindBoxPayUrl(query) {
811
+ return papi() + "/treasure/blindBox?format=jsonp&" + query;
812
+ }
813
+ function blindBoxImgListUrl(giftId) {
814
+ return papi() + "/gift/blindBoxImgList?format=jsonp&gift_id=" + giftId;
815
+ }
816
+ function treasureGetInfoUrl(giftId) {
817
+ return papi() + "/TreasureV3/getInfo?giftid=" + giftId + "&apiver=1";
818
+ }
819
+ function treasureGetRecordUrl(giftId, page, step) {
820
+ return papi() + "/TreasureV3/getRecord?format=jsonp&giftid=" + giftId + "&page=" + page + "&step=" + (step || 10);
821
+ }
822
+ function treasureGoldUrl(giftId, cid, num, paySure, ctx) {
823
+ if (isImSource()) {
824
+ return papi() + "/TreasureV3/gold?" + joinQuery(openParts(giftId, num, paySure, ctx));
1142
825
  }
1143
- function applySrc() {
1144
- setSrc(node, currentSrc || GIFT_IMG_PLACEHOLDER);
826
+ return papi() + "/TreasureV3/gold?giftid=" + giftId + "&cid=" + cid + "&num=" + (num || 1) + "&pay_confirm=1&pay_sure=" + (paySure || 0);
827
+ }
828
+ function treasureV3BuyUrl(giftId, cid, num, paySure, ctx) {
829
+ if (isImSource()) {
830
+ return papi() + "/TreasureV3/buy?" + joinQuery(openParts(giftId, num, paySure, ctx));
1145
831
  }
1146
- function observe() {
1147
- clearObserver();
1148
- setSrc(node, GIFT_IMG_PLACEHOLDER);
1149
- if (!currentSrc) {
1150
- return;
1151
- }
1152
- if (typeof IntersectionObserver !== "function") {
1153
- applySrc();
1154
- return;
1155
- }
1156
- const root = findGridRoot(node);
1157
- observer = new IntersectionObserver(
1158
- (entries) => {
1159
- const hit = entries.some((item) => item.isIntersecting);
1160
- if (!hit) {
1161
- return;
1162
- }
1163
- applySrc();
1164
- clearObserver();
1165
- },
1166
- { root: root || null, rootMargin: PRELOAD_MARGIN, threshold: 0.01 }
1167
- );
1168
- observer.observe(node);
832
+ return papi() + "/TreasureV3/buy?giftid=" + giftId + "&cid=" + cid + "&num=" + (num || 1) + "&pay_confirm=1&pay_sure=" + (paySure || 0);
833
+ }
834
+ function modalBlindBoxPayUrl(giftId, cid, num, worth, isBuy, ctx) {
835
+ if (isImSource()) {
836
+ return papi() + "/treasure/blindBox?" + joinQuery([
837
+ ["anonymous", 0],
838
+ ["actid", 100],
839
+ ["platform", 0],
840
+ ["giftid", giftId],
841
+ ["num", num || 1],
842
+ ["pay_confirm", 1],
843
+ ["apiver", 1],
844
+ ["pay_sure", 0],
845
+ ["worth", worth || 0],
846
+ ["is_buy", isBuy || 0],
847
+ ["uids", ctx && ctx.selfUid],
848
+ ...sceneParts$1(ctx)
849
+ ]);
1169
850
  }
1170
- observe();
1171
- return {
1172
- update(nextSrc) {
1173
- const next = nextSrc || "";
1174
- if (next === currentSrc) {
1175
- return;
1176
- }
1177
- currentSrc = next;
1178
- observe();
1179
- },
1180
- destroy() {
1181
- clearObserver();
1182
- }
1183
- };
851
+ return papi() + "/treasure/blindBox?format=jsonp&giftid=" + giftId + "&cid=" + cid + "&num=" + (num || 1) + "&worth=" + (worth || 0) + "&is_buy=" + (isBuy || 0);
1184
852
  }
1185
- function get_each_context$9(ctx, list, i) {
1186
- const child_ctx = ctx.slice();
1187
- child_ctx[7] = list[i];
1188
- return child_ctx;
853
+ function diamondPrefixQuery(parts) {
854
+ return "anonymous=0&actid=" + (isImSource() ? 101 : 100) + "&platform=0&" + joinQuery(parts);
1189
855
  }
1190
- function create_if_block_5$5(ctx) {
1191
- let span;
1192
- let t_value = (
1193
- /*giftItem*/
1194
- ctx[7].tag + ""
1195
- );
1196
- let t;
1197
- return {
1198
- c() {
1199
- span = element("span");
1200
- t = text(t_value);
1201
- attr(span, "class", "giftbar-item-tag");
1202
- },
1203
- m(target, anchor) {
1204
- insert(target, span, anchor);
1205
- append(span, t);
1206
- },
1207
- p(ctx2, dirty) {
1208
- if (dirty & /*gifts*/
1209
- 1 && t_value !== (t_value = /*giftItem*/
1210
- ctx2[7].tag + "")) set_data(t, t_value);
1211
- },
1212
- d(detaching) {
1213
- if (detaching) {
1214
- detach(span);
1215
- }
1216
- }
1217
- };
856
+ function boxPrefixQuery(parts) {
857
+ return "anonymous=0&actid=100&platform=0&" + joinQuery(parts);
1218
858
  }
1219
- function create_if_block_3$7(ctx) {
1220
- let div;
1221
- let t0;
1222
- let t1_value = (
1223
- /*giftItem*/
1224
- ctx[7].unitText + ""
1225
- );
1226
- let t1;
1227
- let if_block = (
1228
- /*giftItem*/
1229
- ctx[7].picIcon && create_if_block_4$6(ctx)
1230
- );
1231
- return {
1232
- c() {
1233
- div = element("div");
1234
- if (if_block) if_block.c();
1235
- t0 = space();
1236
- t1 = text(t1_value);
1237
- attr(div, "class", "giftbar-item-unit");
1238
- },
1239
- m(target, anchor) {
1240
- insert(target, div, anchor);
1241
- if (if_block) if_block.m(div, null);
1242
- append(div, t0);
1243
- append(div, t1);
1244
- },
1245
- p(ctx2, dirty) {
1246
- if (
1247
- /*giftItem*/
1248
- ctx2[7].picIcon
1249
- ) {
1250
- if (if_block) {
1251
- if_block.p(ctx2, dirty);
1252
- } else {
1253
- if_block = create_if_block_4$6(ctx2);
1254
- if_block.c();
1255
- if_block.m(div, t0);
1256
- }
1257
- } else if (if_block) {
1258
- if_block.d(1);
1259
- if_block = null;
1260
- }
1261
- if (dirty & /*gifts*/
1262
- 1 && t1_value !== (t1_value = /*giftItem*/
1263
- ctx2[7].unitText + "")) set_data(t1, t1_value);
1264
- },
1265
- d(detaching) {
1266
- if (detaching) {
1267
- detach(div);
1268
- }
1269
- if (if_block) if_block.d();
1270
- }
1271
- };
859
+ function platformPrefixQuery(parts) {
860
+ return "platform=0&" + joinQuery(parts);
1272
861
  }
1273
- function create_if_block_4$6(ctx) {
1274
- let img;
1275
- let img_class_value;
1276
- let img_src_value;
1277
- return {
1278
- c() {
1279
- img = element("img");
1280
- attr(img, "class", img_class_value = /*giftItem*/
1281
- ctx[7].isCrystal ? "is-crystal" : "");
1282
- if (!src_url_equal(img.src, img_src_value = /*giftItem*/
1283
- ctx[7].picIcon)) attr(img, "src", img_src_value);
1284
- attr(img, "alt", "");
862
+ function getCrystalBlindBoxBaseUrl() {
863
+ if (options.isChatTest) {
864
+ return "https://act-test.tuwan.com/cdn/s1season-box.html";
865
+ }
866
+ const host = window.location.host || "";
867
+ const actHost = host.indexOf("diandiankaihei.com") > -1 ? "act.diandiankaihei.com" : "act.tuwan.com";
868
+ return "https://" + actHost + "/cdn/s1season-box.html";
869
+ }
870
+ function getCrystalBlindBoxUrl(cid, giftId, navid) {
871
+ const base = getCrystalBlindBoxBaseUrl();
872
+ if (isImSource()) {
873
+ return base + "?giftId=" + giftId + "&navid=" + navid;
874
+ }
875
+ return base + "?cid=" + cid + "&giftId=" + giftId;
876
+ }
877
+ const TAB_PACKAGE = 3;
878
+ const TAB_CRYSTAL = 7;
879
+ const PACKAGE_TAB_IDS = [TAB_PACKAGE, TAB_CRYSTAL];
880
+ const MAGIC_GIFT_IDS = [866, 873, 1583, 155, 156];
881
+ const NO_WHOLE_WHEAT_GIFT_IDS = [37, 9, 10, 55, 1293];
882
+ const CRYSTAL_IMG = "https://asset.tuwan.com/chatroom/images/icon_new_crystal.png";
883
+ const ZHUANSHI_IMG = "https://res.tuwan.com/templet/play/public/images/zuanshi.png";
884
+ const EMPTY_BAG_IMG = "https://asset.tuwan.com/images/chartRoomNoGift.png";
885
+ const DEFAULT_MAGIC_TIP_LINK = "https://y.tuwan.com/activities/900325Cdc25ee#/";
886
+ const DEFAULT_CRYSTAL_TIP_LINK = "https://y.tuwan.com/activity/340Cb43562?v=1703303588331#/";
887
+ const IM_DEFAULT_MAGIC_TIP_LINK = "https://y.tuwan.com/activity/36C33a2de?v=1656553263108#/";
888
+ function isPackageTab(tabId) {
889
+ return PACKAGE_TAB_IDS.indexOf(Number(tabId)) > -1;
890
+ }
891
+ function isHallGiveGift(gift) {
892
+ const type = Number(gift && gift.type);
893
+ return type === 30 || type === 37;
894
+ }
895
+ function isRoomHallGiveGift(gift) {
896
+ return !isImSource() && isHallGiveGift(gift);
897
+ }
898
+ function getVipLevelUrl() {
899
+ return "https://y" + (options.isChatTest ? "-test" : "") + ".tuwan.com/vip_level";
900
+ }
901
+ function getNobilityUrl() {
902
+ return "https://y" + (options.isChatTest ? "-test" : "") + ".tuwan.com/levelm";
903
+ }
904
+ function getEmptyBagImg() {
905
+ return EMPTY_BAG_IMG;
906
+ }
907
+ function nrTobr(desc) {
908
+ if (!desc || typeof desc !== "string") {
909
+ return "";
910
+ }
911
+ return desc.replace(/\r\n/g, "<br>").replace(/\n/g, "<br>");
912
+ }
913
+ function formatBoxtitle(text2) {
914
+ if (!text2 || typeof text2 !== "string") {
915
+ return "";
916
+ }
917
+ const arr = text2.split("有机会获得");
918
+ if (arr.length > 1) {
919
+ return '有机会获得<span style="color:#ff6691;">' + arr[1] + "</span>";
920
+ }
921
+ return "";
922
+ }
923
+ function formatMoney(money, location2) {
924
+ const value = money * 1;
925
+ if (isNaN(value)) {
926
+ return money == null ? "" : String(money);
927
+ }
928
+ if (location2) {
929
+ if (value >= 1e4) {
930
+ return (value / 1e4).toFixed(2) + "w";
931
+ }
932
+ const moneyStr = value.toFixed(2) + "";
933
+ if (moneyStr.indexOf(".") === 4) {
934
+ return parseInt(String(value), 10);
935
+ }
936
+ return value.toFixed(2);
937
+ }
938
+ return value >= 1e4 ? (value / 1e4).toFixed(2) + "w" : parseInt(String(value), 10);
939
+ }
940
+ function stripHonorName(nickname) {
941
+ if (!nickname || typeof nickname !== "string") {
942
+ return nickname || "";
943
+ }
944
+ const marks = ["♕", "♚", "♔", "☬"];
945
+ for (let i = 0; i < marks.length; i++) {
946
+ if (nickname.indexOf(marks[i]) > -1) {
947
+ const part = nickname.split(marks[i])[1] || "";
948
+ return part || nickname;
949
+ }
950
+ }
951
+ return nickname;
952
+ }
953
+ function isIframeBlindBox(gift, tabId) {
954
+ return Number(tabId) === TAB_CRYSTAL && Number(gift && gift.type) === 24 && Number(gift && gift.worth) === 3;
955
+ }
956
+ function isBlindBoxModalGift(gift, tabId) {
957
+ const navid = Number(tabId);
958
+ const type = Number(gift && gift.type);
959
+ const id = Number(gift && gift.id);
960
+ const worth = Number(gift && gift.worth);
961
+ if (type !== 24 || id <= 1218) {
962
+ return false;
963
+ }
964
+ if (isImSource()) {
965
+ if (navid !== TAB_PACKAGE && navid !== TAB_CRYSTAL) {
966
+ return false;
967
+ }
968
+ return worth !== 3;
969
+ }
970
+ return navid === TAB_PACKAGE;
971
+ }
972
+ function canSendToSelf(gift, tabId) {
973
+ return Number(tabId) === TAB_PACKAGE && Number(gift && gift.type) === 7 || Number(gift && gift.id) === 383;
974
+ }
975
+ function allowEmptyWheat(gift, tabId) {
976
+ const type = Number(gift && gift.type);
977
+ const navid = Number(tabId);
978
+ return navid === TAB_PACKAGE && type === 7 || navid === TAB_CRYSTAL && type === 7 || navid === TAB_PACKAGE && type === 24;
979
+ }
980
+ function getGiftButtonStatus(gift, tabId, isSend) {
981
+ const empty2 = { send: false, open: false, use: false, sendLabel: "赠送" };
982
+ if (!gift) {
983
+ return { send: true, open: false, use: false, sendLabel: "赠送" };
984
+ }
985
+ const id = Number(gift.id);
986
+ const type = Number(gift.type);
987
+ const worth = Number(gift.worth);
988
+ const touid = Number(gift.to_uid || 0);
989
+ const navid = Number(tabId);
990
+ if (type === 29) {
991
+ if (isImSource()) {
992
+ return { ...empty2, send: true };
993
+ }
994
+ return { ...empty2, use: true };
995
+ }
996
+ if (navid === TAB_PACKAGE || navid === TAB_CRYSTAL) {
997
+ if (isImSource() && type === 24 && worth === 3 && navid !== TAB_CRYSTAL) {
998
+ return { ...empty2, send: true };
999
+ }
1000
+ if (id === 383 || id === 873) {
1001
+ return { ...empty2, open: true };
1002
+ }
1003
+ if (id === 866 || id === 1583) {
1004
+ return { ...empty2, open: true, send: isImSource() ? false : Number(isSend) === 1 };
1005
+ }
1006
+ if (isImSource() && (id === 155 || id === 156)) {
1007
+ return { ...empty2, open: true };
1008
+ }
1009
+ if (id === 384 || id === 389) {
1010
+ return { ...empty2, use: true };
1011
+ }
1012
+ if (type === 7 || type === 24) {
1013
+ return { ...empty2, open: true };
1014
+ }
1015
+ if (type === 16) {
1016
+ return touid === 0 ? { ...empty2, use: true } : { ...empty2, send: true };
1017
+ }
1018
+ if (type === 37) {
1019
+ return { ...empty2, send: true, sendLabel: "使用" };
1020
+ }
1021
+ return { ...empty2, send: true };
1022
+ }
1023
+ if (type === 37) {
1024
+ return { ...empty2, send: true, sendLabel: "使用" };
1025
+ }
1026
+ return { ...empty2, send: true };
1027
+ }
1028
+ function getSelectUiState(gift, tabId, isSend) {
1029
+ const buttons = getGiftButtonStatus(gift, tabId, isSend);
1030
+ const effectiveIsSend = buttons.send && buttons.open ? isSend : buttons.send ? 1 : 0;
1031
+ const state = {
1032
+ countLocked: false,
1033
+ showCountArrow: true,
1034
+ recipient: "user",
1035
+ showSendLabel: true,
1036
+ boxTitleHtml: "",
1037
+ sendLabel: buttons.sendLabel,
1038
+ buttons
1039
+ };
1040
+ if (!gift) {
1041
+ return state;
1042
+ }
1043
+ const id = Number(gift.id);
1044
+ const type = Number(gift.type);
1045
+ const navid = Number(tabId);
1046
+ const touid = Number(gift.to_uid || 0);
1047
+ const worth = Number(gift.worth);
1048
+ if (type === 30) {
1049
+ state.recipient = "room";
1050
+ return state;
1051
+ }
1052
+ if (type === 37) {
1053
+ state.countLocked = true;
1054
+ state.showCountArrow = false;
1055
+ state.showSendLabel = false;
1056
+ state.recipient = "giftTitle";
1057
+ return state;
1058
+ }
1059
+ if (id === 866 || id === 1583) {
1060
+ if (Number(effectiveIsSend) === 1) {
1061
+ state.recipient = "user";
1062
+ } else {
1063
+ state.recipient = "box";
1064
+ state.boxTitleHtml = formatBoxtitle(gift.intro);
1065
+ }
1066
+ return state;
1067
+ }
1068
+ if (id === 368) {
1069
+ state.recipient = "none";
1070
+ return state;
1071
+ }
1072
+ if (id === 389) {
1073
+ state.recipient = "box";
1074
+ state.boxTitleHtml = '礼包价值:<span style="color:#ff6691;">' + gift.price / 100 + "点点币</span>";
1075
+ return state;
1076
+ }
1077
+ if (navid === TAB_CRYSTAL && type === 7 || navid === TAB_PACKAGE && type === 7 || id === 873) {
1078
+ state.recipient = "box";
1079
+ state.boxTitleHtml = formatBoxtitle(gift.intro);
1080
+ return state;
1081
+ }
1082
+ if (type === 16) {
1083
+ state.recipient = touid === 0 ? "none" : "user";
1084
+ return state;
1085
+ }
1086
+ if (navid === TAB_CRYSTAL && type === 24 && worth === 3) {
1087
+ state.recipient = "user";
1088
+ return state;
1089
+ }
1090
+ if (navid === TAB_PACKAGE && type === 24) {
1091
+ state.recipient = "box";
1092
+ state.boxTitleHtml = formatBoxtitle(gift.intro);
1093
+ return state;
1094
+ }
1095
+ return state;
1096
+ }
1097
+ function getTipState(gift, tabId) {
1098
+ const navid = Number(tabId);
1099
+ if (isImSource()) {
1100
+ if (!gift) {
1101
+ return { kind: "hidden", text: "", link: "", img: "" };
1102
+ }
1103
+ const type2 = Number(gift.type);
1104
+ const id = Number(gift.id);
1105
+ if (type2 === 24 && (id <= 1218 || gift.explain_url)) {
1106
+ return {
1107
+ kind: "box",
1108
+ text: "礼盒礼物说明",
1109
+ link: id > 1218 ? gift.explain_url : "https://y.tuwan.com/activity/575C87d860?giftId=" + gift.id,
1110
+ img: gift.pic || ""
1111
+ };
1112
+ }
1113
+ if (gift.explain_url) {
1114
+ return {
1115
+ kind: "magic",
1116
+ text: navid === TAB_CRYSTAL ? "紫晶魔法说明" : "魔法礼物说明",
1117
+ link: gift.explain_url,
1118
+ img: ""
1119
+ };
1120
+ }
1121
+ if (navid === TAB_CRYSTAL) {
1122
+ return {
1123
+ kind: "magic",
1124
+ text: "紫晶魔法说明",
1125
+ link: DEFAULT_CRYSTAL_TIP_LINK,
1126
+ img: ""
1127
+ };
1128
+ }
1129
+ return {
1130
+ kind: "magic",
1131
+ text: "魔法礼物说明",
1132
+ link: IM_DEFAULT_MAGIC_TIP_LINK,
1133
+ img: ""
1134
+ };
1135
+ }
1136
+ const tabDefault = navid === TAB_CRYSTAL ? { kind: "magic", text: "紫晶魔法说明", link: DEFAULT_CRYSTAL_TIP_LINK, img: "" } : { kind: "magic", text: "魔法礼物说明", link: DEFAULT_MAGIC_TIP_LINK, img: "" };
1137
+ if (!gift) {
1138
+ return tabDefault;
1139
+ }
1140
+ const type = Number(gift.type);
1141
+ const worth = Number(gift.worth);
1142
+ if (type === 30 || type === 31 || type === 32) {
1143
+ return { kind: "vip", text: "VIP财富等级", link: getVipLevelUrl(), img: "" };
1144
+ }
1145
+ if (type === 37) {
1146
+ return tabDefault;
1147
+ }
1148
+ if (type === 24 && worth === 3 && navid !== TAB_PACKAGE && navid !== TAB_CRYSTAL) {
1149
+ return {
1150
+ kind: "magic",
1151
+ text: "魔法礼物说明",
1152
+ link: gift.explain_url || DEFAULT_MAGIC_TIP_LINK,
1153
+ img: ""
1154
+ };
1155
+ }
1156
+ if (type === 24) {
1157
+ if (gift.explain_url) {
1158
+ return {
1159
+ kind: "box",
1160
+ text: "礼盒礼物说明",
1161
+ link: gift.explain_url,
1162
+ img: gift.pic || ""
1163
+ };
1164
+ }
1165
+ return {
1166
+ kind: "magic",
1167
+ text: "魔法礼物说明",
1168
+ link: DEFAULT_MAGIC_TIP_LINK,
1169
+ img: ""
1170
+ };
1171
+ }
1172
+ if (gift.explain_url) {
1173
+ return {
1174
+ kind: "magic",
1175
+ text: "魔法礼物说明",
1176
+ link: gift.explain_url,
1177
+ img: ""
1178
+ };
1179
+ }
1180
+ return tabDefault;
1181
+ }
1182
+ function isMagicGift(gift, tabId) {
1183
+ const id = Number(gift && gift.id);
1184
+ const navid = Number(tabId);
1185
+ if (isImSource()) {
1186
+ if (navid !== TAB_PACKAGE && navid !== TAB_CRYSTAL) {
1187
+ return false;
1188
+ }
1189
+ if (Number(gift && gift.type) === 24 && Number(gift && gift.worth) === 3) {
1190
+ return false;
1191
+ }
1192
+ if (Number(gift && gift.type) === 24 && id > 1218) {
1193
+ return false;
1194
+ }
1195
+ return MAGIC_GIFT_IDS.indexOf(id) > -1;
1196
+ }
1197
+ if (id === 866 || id === 873 || id === 1583) {
1198
+ return true;
1199
+ }
1200
+ return navid === TAB_PACKAGE && (id === 155 || id === 156);
1201
+ }
1202
+ function getSelectHostEffect(gift, tabId) {
1203
+ if (!gift) {
1204
+ return "";
1205
+ }
1206
+ const id = Number(gift.id);
1207
+ const type = Number(gift.type);
1208
+ if (id === 368 || id === 389) {
1209
+ return "click";
1210
+ }
1211
+ if (id === 383) {
1212
+ return "";
1213
+ }
1214
+ if (type === 16 && Number(gift.to_uid || 0) === 0) {
1215
+ return "click";
1216
+ }
1217
+ if (type === 1e4) {
1218
+ return "click";
1219
+ }
1220
+ if (type === 29) {
1221
+ if (isImSource()) {
1222
+ return "";
1223
+ }
1224
+ return "pardon";
1225
+ }
1226
+ return "";
1227
+ }
1228
+ function resolveFooterAction(action, gift, tabId, selectedUser) {
1229
+ if (!gift || !gift.id) {
1230
+ return { kind: "alert", message: "请选择一个礼物" };
1231
+ }
1232
+ const id = Number(gift.id);
1233
+ const type = Number(gift.type);
1234
+ const navid = Number(tabId);
1235
+ const touid = Number(gift.to_uid || 0);
1236
+ const uid = selectedUser ? Number(selectedUser.uid) : 0;
1237
+ if (action === "use") {
1238
+ if (type === 29) {
1239
+ if (isImSource()) {
1240
+ return { kind: "pay", payAction: "send" };
1241
+ }
1242
+ return { kind: "pardon" };
1243
+ }
1244
+ if (id === 389) {
1245
+ return { kind: "hostClick" };
1246
+ }
1247
+ if (type === 16 && touid === 0) {
1248
+ return { kind: "hostClick" };
1249
+ }
1250
+ return { kind: "pay", payAction: "send" };
1251
+ }
1252
+ if (action === "send") {
1253
+ if (Number(gift.question_gift) === 1) {
1254
+ return { kind: "question" };
1255
+ }
1256
+ if (id === 1293 && uid === 0) {
1257
+ return { kind: "alert", message: "该礼物不能赠送全麦" };
1258
+ }
1259
+ return { kind: "pay", payAction: "send" };
1260
+ }
1261
+ if (isIframeBlindBox(gift, navid)) {
1262
+ return { kind: "iframe" };
1263
+ }
1264
+ if (isBlindBoxModalGift(gift, navid)) {
1265
+ return { kind: "blindBox" };
1266
+ }
1267
+ if (isMagicGift(gift, navid)) {
1268
+ return { kind: "magic" };
1269
+ }
1270
+ if (id === 383) {
1271
+ return { kind: "hostClick" };
1272
+ }
1273
+ if (id === 368 || id === 389) {
1274
+ return { kind: "hostClick" };
1275
+ }
1276
+ if (type === 16 && touid === 0) {
1277
+ return { kind: "hostClick" };
1278
+ }
1279
+ return { kind: "pay", payAction: "open" };
1280
+ }
1281
+ let guidIdx = 0;
1282
+ function nextGuid(navid, id, index) {
1283
+ if (index !== void 0 && index !== null) {
1284
+ return "giftbar_" + navid + "_" + id + "_" + index;
1285
+ }
1286
+ guidIdx += 1;
1287
+ return "giftbar_" + navid + "_" + id + "_" + guidIdx;
1288
+ }
1289
+ function transformShopGift(navid, temp, index) {
1290
+ const worth = Number(temp.worth);
1291
+ temp.picIcon = worth === 3 ? CRYSTAL_IMG : ZHUANSHI_IMG;
1292
+ temp.isCrystal = worth === 3;
1293
+ temp.unitText = temp.diamond + (worth === 3 ? "紫晶" : "钻");
1294
+ temp.unitText2 = "";
1295
+ if (temp.worth === void 0) {
1296
+ temp.worth = 0;
1297
+ }
1298
+ temp.atitle = temp.intro && temp.intro !== " " ? nrTobr(temp.intro) : "";
1299
+ temp.guid = nextGuid(navid, temp.id, index);
1300
+ }
1301
+ function transformBagGift(navid, temp, index) {
1302
+ const type = Number(temp.type);
1303
+ const worth = Number(temp.worth);
1304
+ const id = Number(temp.id);
1305
+ const num = temp.num;
1306
+ const price = temp.price;
1307
+ const priority = Number(temp.priority_display) || 0;
1308
+ temp.picIcon = "";
1309
+ temp.unitText = "";
1310
+ temp.unitText2 = "";
1311
+ temp.isCrystal = false;
1312
+ if (type === 24 && worth === 3) {
1313
+ if (priority > 0) {
1314
+ temp.picIcon = CRYSTAL_IMG;
1315
+ temp.isCrystal = true;
1316
+ temp.unitText = String(price / 10);
1317
+ } else {
1318
+ temp.unitText2 = "x" + num;
1319
+ }
1320
+ } else if (Number(navid) === TAB_CRYSTAL && type === 7) {
1321
+ temp.picIcon = CRYSTAL_IMG;
1322
+ temp.isCrystal = true;
1323
+ temp.unitText = String(price / 10);
1324
+ } else {
1325
+ let giftNum = "";
1326
+ if (type === 7 || Number(navid) === TAB_PACKAGE && priority > 0) {
1327
+ giftNum = price / 10 + "钻";
1328
+ } else {
1329
+ giftNum = "x" + num;
1330
+ }
1331
+ if (Number(navid) === TAB_PACKAGE && priority > 0) {
1332
+ temp.picIcon = ZHUANSHI_IMG;
1333
+ temp.unitText = giftNum;
1334
+ } else if (id === 155 || id === 156) {
1335
+ temp.picIcon = ZHUANSHI_IMG;
1336
+ temp.unitText = giftNum;
1337
+ } else {
1338
+ temp.unitText2 = giftNum;
1339
+ }
1340
+ }
1341
+ if (temp.worth === void 0) {
1342
+ temp.worth = 0;
1343
+ }
1344
+ temp.atitle = temp.intro && temp.intro !== " " ? nrTobr(temp.intro) : "";
1345
+ temp.guid = nextGuid(navid, temp.id, index);
1346
+ }
1347
+ function create_fragment$s(ctx) {
1348
+ let div1;
1349
+ let div0;
1350
+ let iframe;
1351
+ let iframe_src_value;
1352
+ let mounted;
1353
+ let dispose;
1354
+ return {
1355
+ c() {
1356
+ div1 = element("div");
1357
+ div0 = element("div");
1358
+ iframe = element("iframe");
1359
+ attr(iframe, "title", "blind-box");
1360
+ if (!src_url_equal(iframe.src, iframe_src_value = /*url*/
1361
+ ctx[0])) attr(iframe, "src", iframe_src_value);
1362
+ attr(
1363
+ iframe,
1364
+ "width",
1365
+ /*width*/
1366
+ ctx[1]
1367
+ );
1368
+ attr(
1369
+ iframe,
1370
+ "height",
1371
+ /*height*/
1372
+ ctx[2]
1373
+ );
1374
+ attr(iframe, "frameborder", "0");
1375
+ attr(
1376
+ iframe,
1377
+ "allow",
1378
+ /*iframeAllow*/
1379
+ ctx[5]
1380
+ );
1381
+ attr(iframe, "class", "svelte-1ma5gxj");
1382
+ attr(div0, "role", "presentation");
1383
+ attr(div0, "class", "giftbar-iframe-wrap svelte-1ma5gxj");
1384
+ set_style(
1385
+ div0,
1386
+ "width",
1387
+ /*width*/
1388
+ ctx[1] + "px"
1389
+ );
1390
+ set_style(
1391
+ div0,
1392
+ "height",
1393
+ /*height*/
1394
+ ctx[2] + "px"
1395
+ );
1396
+ attr(
1397
+ div1,
1398
+ "id",
1399
+ /*iframeId*/
1400
+ ctx[3]
1401
+ );
1402
+ attr(div1, "class", "giftbar-iframe-mask svelte-1ma5gxj");
1403
+ attr(div1, "role", "presentation");
1285
1404
  },
1286
1405
  m(target, anchor) {
1287
- insert(target, img, anchor);
1406
+ insert(target, div1, anchor);
1407
+ append(div1, div0);
1408
+ append(div0, iframe);
1409
+ ctx[11](iframe);
1410
+ if (!mounted) {
1411
+ dispose = [
1412
+ listen(div0, "click", stop_propagation(
1413
+ /*click_handler*/
1414
+ ctx[10]
1415
+ )),
1416
+ listen(div1, "click", stop_propagation(
1417
+ /*onMaskClick*/
1418
+ ctx[6]
1419
+ ))
1420
+ ];
1421
+ mounted = true;
1422
+ }
1288
1423
  },
1289
- p(ctx2, dirty) {
1290
- if (dirty & /*gifts*/
1291
- 1 && img_class_value !== (img_class_value = /*giftItem*/
1292
- ctx2[7].isCrystal ? "is-crystal" : "")) {
1293
- attr(img, "class", img_class_value);
1424
+ p(ctx2, [dirty]) {
1425
+ if (dirty & /*url*/
1426
+ 1 && !src_url_equal(iframe.src, iframe_src_value = /*url*/
1427
+ ctx2[0])) {
1428
+ attr(iframe, "src", iframe_src_value);
1294
1429
  }
1295
- if (dirty & /*gifts*/
1296
- 1 && !src_url_equal(img.src, img_src_value = /*giftItem*/
1297
- ctx2[7].picIcon)) {
1298
- attr(img, "src", img_src_value);
1430
+ if (dirty & /*width*/
1431
+ 2) {
1432
+ attr(
1433
+ iframe,
1434
+ "width",
1435
+ /*width*/
1436
+ ctx2[1]
1437
+ );
1438
+ }
1439
+ if (dirty & /*height*/
1440
+ 4) {
1441
+ attr(
1442
+ iframe,
1443
+ "height",
1444
+ /*height*/
1445
+ ctx2[2]
1446
+ );
1447
+ }
1448
+ if (dirty & /*iframeAllow*/
1449
+ 32) {
1450
+ attr(
1451
+ iframe,
1452
+ "allow",
1453
+ /*iframeAllow*/
1454
+ ctx2[5]
1455
+ );
1456
+ }
1457
+ if (dirty & /*width*/
1458
+ 2) {
1459
+ set_style(
1460
+ div0,
1461
+ "width",
1462
+ /*width*/
1463
+ ctx2[1] + "px"
1464
+ );
1465
+ }
1466
+ if (dirty & /*height*/
1467
+ 4) {
1468
+ set_style(
1469
+ div0,
1470
+ "height",
1471
+ /*height*/
1472
+ ctx2[2] + "px"
1473
+ );
1474
+ }
1475
+ if (dirty & /*iframeId*/
1476
+ 8) {
1477
+ attr(
1478
+ div1,
1479
+ "id",
1480
+ /*iframeId*/
1481
+ ctx2[3]
1482
+ );
1299
1483
  }
1300
1484
  },
1485
+ i: noop,
1486
+ o: noop,
1301
1487
  d(detaching) {
1302
1488
  if (detaching) {
1303
- detach(img);
1489
+ detach(div1);
1490
+ }
1491
+ ctx[11](null);
1492
+ mounted = false;
1493
+ run_all(dispose);
1494
+ }
1495
+ };
1496
+ }
1497
+ function instance$s($$self, $$props, $$invalidate) {
1498
+ let iframeAllow;
1499
+ let { closeModal } = $$props;
1500
+ let { url = "" } = $$props;
1501
+ let { width = 400 } = $$props;
1502
+ let { height = 585 } = $$props;
1503
+ let { onRefreshHaveGift = null } = $$props;
1504
+ let { iframeId = "" } = $$props;
1505
+ let { closeOnMask = false } = $$props;
1506
+ let frameEl;
1507
+ let closed = false;
1508
+ function onMaskClick() {
1509
+ if (closeOnMask) {
1510
+ handleClose();
1511
+ return;
1512
+ }
1513
+ tryCloseIframe();
1514
+ }
1515
+ function tryCloseIframe() {
1516
+ if (!frameEl || !frameEl.contentWindow) {
1517
+ return;
1518
+ }
1519
+ frameEl.contentWindow.postMessage(
1520
+ {
1521
+ channel: "common_iframe",
1522
+ type: "tryClose",
1523
+ data: { iframeId }
1524
+ },
1525
+ "*"
1526
+ );
1527
+ }
1528
+ function handleClose() {
1529
+ if (closed) {
1530
+ return;
1531
+ }
1532
+ closed = true;
1533
+ onRefreshHaveGift && onRefreshHaveGift();
1534
+ closeModal && closeModal(null, true);
1535
+ }
1536
+ function onMessage(event) {
1537
+ const data = event.data;
1538
+ if (!data) {
1539
+ return;
1540
+ }
1541
+ if (data.closeIframe || data.channel === "common_iframe" && data.type === "closeIframe") {
1542
+ if (data.id && iframeId && String(data.id) !== String(iframeId)) {
1543
+ return;
1304
1544
  }
1545
+ handleClose();
1546
+ return;
1547
+ }
1548
+ if (data.channel === "common_iframe" && data.type === "refreshHaveGift") {
1549
+ onRefreshHaveGift && onRefreshHaveGift();
1305
1550
  }
1551
+ }
1552
+ onMount(() => {
1553
+ window.addEventListener("message", onMessage);
1554
+ });
1555
+ onDestroy(() => {
1556
+ window.removeEventListener("message", onMessage);
1557
+ });
1558
+ function click_handler(event) {
1559
+ bubble.call(this, $$self, event);
1560
+ }
1561
+ function iframe_binding($$value) {
1562
+ binding_callbacks[$$value ? "unshift" : "push"](() => {
1563
+ frameEl = $$value;
1564
+ $$invalidate(4, frameEl);
1565
+ });
1566
+ }
1567
+ $$self.$$set = ($$props2) => {
1568
+ if ("closeModal" in $$props2) $$invalidate(7, closeModal = $$props2.closeModal);
1569
+ if ("url" in $$props2) $$invalidate(0, url = $$props2.url);
1570
+ if ("width" in $$props2) $$invalidate(1, width = $$props2.width);
1571
+ if ("height" in $$props2) $$invalidate(2, height = $$props2.height);
1572
+ if ("onRefreshHaveGift" in $$props2) $$invalidate(8, onRefreshHaveGift = $$props2.onRefreshHaveGift);
1573
+ if ("iframeId" in $$props2) $$invalidate(3, iframeId = $$props2.iframeId);
1574
+ if ("closeOnMask" in $$props2) $$invalidate(9, closeOnMask = $$props2.closeOnMask);
1306
1575
  };
1576
+ $$invalidate(5, iframeAllow = options.isChatTest ? "local-network-access 'src'" : void 0);
1577
+ return [
1578
+ url,
1579
+ width,
1580
+ height,
1581
+ iframeId,
1582
+ frameEl,
1583
+ iframeAllow,
1584
+ onMaskClick,
1585
+ closeModal,
1586
+ onRefreshHaveGift,
1587
+ closeOnMask,
1588
+ click_handler,
1589
+ iframe_binding
1590
+ ];
1307
1591
  }
1308
- function create_if_block_2$b(ctx) {
1309
- let div;
1310
- let t_value = (
1311
- /*giftItem*/
1312
- ctx[7].unitText2 + ""
1592
+ class IframeModal extends SvelteComponent {
1593
+ constructor(options2) {
1594
+ super();
1595
+ init(this, options2, instance$s, create_fragment$s, safe_not_equal, {
1596
+ closeModal: 7,
1597
+ url: 0,
1598
+ width: 1,
1599
+ height: 2,
1600
+ onRefreshHaveGift: 8,
1601
+ iframeId: 3,
1602
+ closeOnMask: 9
1603
+ });
1604
+ }
1605
+ }
1606
+ function showExplainIframe(url) {
1607
+ if (!url) {
1608
+ return;
1609
+ }
1610
+ const iframeId = "iframe_" + Date.now();
1611
+ const joined = url + (url.indexOf("?") >= 0 ? "&" : "?") + "eleId=" + encodeURIComponent(iframeId);
1612
+ return createModal(
1613
+ IframeModal,
1614
+ {
1615
+ url: joined,
1616
+ iframeId,
1617
+ width: 375,
1618
+ height: 700,
1619
+ closeOnMask: true
1620
+ },
1621
+ document.body
1313
1622
  );
1314
- let t;
1623
+ }
1624
+ function showNobilityIframe() {
1625
+ return showExplainIframe(getNobilityUrl());
1626
+ }
1627
+ function showIframeBlindBox({ cid, giftId, navid, onRefreshHaveGift }) {
1628
+ const iframeId = "iframe_" + Date.now();
1629
+ const base = getCrystalBlindBoxUrl(cid, giftId, navid);
1630
+ const url = base + (base.indexOf("?") >= 0 ? "&" : "?") + "eleId=" + encodeURIComponent(iframeId);
1631
+ return createModal(
1632
+ IframeModal,
1633
+ {
1634
+ url,
1635
+ iframeId,
1636
+ width: 400,
1637
+ height: 585,
1638
+ onRefreshHaveGift
1639
+ },
1640
+ document.body
1641
+ );
1642
+ }
1643
+ function get_each_context$a(ctx, list, i) {
1644
+ const child_ctx = ctx.slice();
1645
+ child_ctx[8] = list[i];
1646
+ return child_ctx;
1647
+ }
1648
+ function create_if_block_3$8(ctx) {
1649
+ let b;
1315
1650
  return {
1316
1651
  c() {
1317
- div = element("div");
1318
- t = text(t_value);
1319
- attr(div, "class", "giftbar-item-unit");
1652
+ b = element("b");
1653
+ attr(b, "class", "giftbar-tab-dot");
1320
1654
  },
1321
1655
  m(target, anchor) {
1322
- insert(target, div, anchor);
1323
- append(div, t);
1324
- },
1325
- p(ctx2, dirty) {
1326
- if (dirty & /*gifts*/
1327
- 1 && t_value !== (t_value = /*giftItem*/
1328
- ctx2[7].unitText2 + "")) set_data(t, t_value);
1656
+ insert(target, b, anchor);
1329
1657
  },
1330
1658
  d(detaching) {
1331
1659
  if (detaching) {
1332
- detach(div);
1660
+ detach(b);
1333
1661
  }
1334
1662
  }
1335
1663
  };
1336
1664
  }
1337
- function create_each_block$9(key_1, ctx) {
1338
- let div2;
1339
- let div0;
1340
- let img;
1341
- let img_class_value;
1342
- let img_src_value;
1343
- let lazyGiftImg_action;
1665
+ function create_each_block$a(key_1, ctx) {
1666
+ let div;
1667
+ let span;
1668
+ let t0_value = (
1669
+ /*item*/
1670
+ ctx[8].title + ""
1671
+ );
1344
1672
  let t0;
1345
1673
  let t1;
1346
- let div1;
1347
- let t2_value = (
1348
- /*giftItem*/
1349
- ctx[7].title + ""
1350
- );
1351
1674
  let t2;
1352
- let t3;
1353
- let t4;
1354
- let div2_id_value;
1355
- let div2_class_value;
1356
- let giftHoverTip_action;
1675
+ let div_class_value;
1357
1676
  let mounted;
1358
1677
  let dispose;
1359
- let if_block0 = (
1360
- /*giftItem*/
1361
- ctx[7].tag && create_if_block_5$5(ctx)
1362
- );
1363
- let if_block1 = (
1364
- /*giftItem*/
1365
- ctx[7].unitText && create_if_block_3$7(ctx)
1366
- );
1367
- let if_block2 = (
1368
- /*giftItem*/
1369
- ctx[7].unitText2 && create_if_block_2$b(ctx)
1678
+ let if_block = (
1679
+ /*item*/
1680
+ ctx[8].is_new == 1 && create_if_block_3$8()
1370
1681
  );
1371
1682
  function click_handler() {
1372
1683
  return (
1373
1684
  /*click_handler*/
1374
- ctx[6](
1375
- /*giftItem*/
1376
- ctx[7]
1685
+ ctx[7](
1686
+ /*item*/
1687
+ ctx[8]
1377
1688
  )
1378
1689
  );
1379
- }
1380
- return {
1381
- key: key_1,
1382
- first: null,
1383
- c() {
1384
- div2 = element("div");
1385
- div0 = element("div");
1386
- img = element("img");
1387
- t0 = space();
1388
- if (if_block0) if_block0.c();
1389
- t1 = space();
1390
- div1 = element("div");
1391
- t2 = text(t2_value);
1392
- t3 = space();
1393
- if (if_block1) if_block1.c();
1394
- t4 = space();
1395
- if (if_block2) if_block2.c();
1396
- attr(img, "class", img_class_value = "giftbar-item-pic " + /*animGuid*/
1397
- (ctx[3] === /*giftItem*/
1398
- ctx[7].guid ? "gift-select-animation" : ""));
1399
- if (!src_url_equal(img.src, img_src_value = GIFT_IMG_PLACEHOLDER)) attr(img, "src", img_src_value);
1400
- attr(img, "alt", "");
1401
- attr(img, "decoding", "async");
1402
- attr(img, "loading", "lazy");
1403
- set_style(div0, "position", "relative");
1404
- attr(div1, "class", "giftbar-item-title");
1405
- attr(div2, "id", div2_id_value = /*giftItem*/
1406
- ctx[7].guid);
1407
- attr(div2, "class", div2_class_value = "giftbar-item " + /*selectGift*/
1408
- (ctx[1] === /*giftItem*/
1409
- ctx[7] ? "giftbar-item-on" : ""));
1410
- attr(div2, "role", "presentation");
1411
- this.first = div2;
1412
- },
1413
- m(target, anchor) {
1414
- insert(target, div2, anchor);
1415
- append(div2, div0);
1416
- append(div0, img);
1417
- append(div0, t0);
1418
- if (if_block0) if_block0.m(div0, null);
1419
- append(div2, t1);
1420
- append(div2, div1);
1421
- append(div1, t2);
1422
- append(div2, t3);
1423
- if (if_block1) if_block1.m(div2, null);
1424
- append(div2, t4);
1425
- if (if_block2) if_block2.m(div2, null);
1426
- if (!mounted) {
1427
- dispose = [
1428
- action_destroyer(lazyGiftImg_action = lazyGiftImg.call(null, img, giftListThumbUrl(
1429
- /*giftItem*/
1430
- ctx[7].pic
1431
- ))),
1432
- action_destroyer(giftHoverTip_action = giftHoverTip.call(
1433
- null,
1434
- div2,
1435
- /*giftItem*/
1436
- ctx[7].atitle || ""
1437
- )),
1438
- listen(div2, "click", stop_propagation(click_handler))
1439
- ];
1440
- mounted = true;
1441
- }
1442
- },
1443
- p(new_ctx, dirty) {
1444
- ctx = new_ctx;
1445
- if (dirty & /*animGuid, gifts*/
1446
- 9 && img_class_value !== (img_class_value = "giftbar-item-pic " + /*animGuid*/
1447
- (ctx[3] === /*giftItem*/
1448
- ctx[7].guid ? "gift-select-animation" : ""))) {
1449
- attr(img, "class", img_class_value);
1450
- }
1451
- if (lazyGiftImg_action && is_function(lazyGiftImg_action.update) && dirty & /*gifts*/
1452
- 1) lazyGiftImg_action.update.call(null, giftListThumbUrl(
1453
- /*giftItem*/
1454
- ctx[7].pic
1455
- ));
1456
- if (
1457
- /*giftItem*/
1458
- ctx[7].tag
1459
- ) {
1460
- if (if_block0) {
1461
- if_block0.p(ctx, dirty);
1462
- } else {
1463
- if_block0 = create_if_block_5$5(ctx);
1464
- if_block0.c();
1465
- if_block0.m(div0, null);
1466
- }
1467
- } else if (if_block0) {
1468
- if_block0.d(1);
1469
- if_block0 = null;
1470
- }
1471
- if (dirty & /*gifts*/
1472
- 1 && t2_value !== (t2_value = /*giftItem*/
1473
- ctx[7].title + "")) set_data(t2, t2_value);
1474
- if (
1475
- /*giftItem*/
1476
- ctx[7].unitText
1477
- ) {
1478
- if (if_block1) {
1479
- if_block1.p(ctx, dirty);
1480
- } else {
1481
- if_block1 = create_if_block_3$7(ctx);
1482
- if_block1.c();
1483
- if_block1.m(div2, t4);
1484
- }
1485
- } else if (if_block1) {
1486
- if_block1.d(1);
1487
- if_block1 = null;
1690
+ }
1691
+ return {
1692
+ key: key_1,
1693
+ first: null,
1694
+ c() {
1695
+ div = element("div");
1696
+ span = element("span");
1697
+ t0 = text(t0_value);
1698
+ t1 = space();
1699
+ if (if_block) if_block.c();
1700
+ t2 = space();
1701
+ attr(div, "class", div_class_value = "giftbar-tab " + /*item*/
1702
+ (ctx[8].id == /*tabId*/
1703
+ ctx[1] ? "giftbar-tab-on" : ""));
1704
+ attr(div, "role", "presentation");
1705
+ this.first = div;
1706
+ },
1707
+ m(target, anchor) {
1708
+ insert(target, div, anchor);
1709
+ append(div, span);
1710
+ append(span, t0);
1711
+ append(div, t1);
1712
+ if (if_block) if_block.m(div, null);
1713
+ append(div, t2);
1714
+ if (!mounted) {
1715
+ dispose = listen(div, "click", stop_propagation(click_handler));
1716
+ mounted = true;
1488
1717
  }
1718
+ },
1719
+ p(new_ctx, dirty) {
1720
+ ctx = new_ctx;
1721
+ if (dirty & /*tabs*/
1722
+ 1 && t0_value !== (t0_value = /*item*/
1723
+ ctx[8].title + "")) set_data(t0, t0_value);
1489
1724
  if (
1490
- /*giftItem*/
1491
- ctx[7].unitText2
1725
+ /*item*/
1726
+ ctx[8].is_new == 1
1492
1727
  ) {
1493
- if (if_block2) {
1494
- if_block2.p(ctx, dirty);
1495
- } else {
1496
- if_block2 = create_if_block_2$b(ctx);
1497
- if_block2.c();
1498
- if_block2.m(div2, null);
1728
+ if (if_block) ;
1729
+ else {
1730
+ if_block = create_if_block_3$8();
1731
+ if_block.c();
1732
+ if_block.m(div, t2);
1499
1733
  }
1500
- } else if (if_block2) {
1501
- if_block2.d(1);
1502
- if_block2 = null;
1503
- }
1504
- if (dirty & /*gifts*/
1505
- 1 && div2_id_value !== (div2_id_value = /*giftItem*/
1506
- ctx[7].guid)) {
1507
- attr(div2, "id", div2_id_value);
1734
+ } else if (if_block) {
1735
+ if_block.d(1);
1736
+ if_block = null;
1508
1737
  }
1509
- if (dirty & /*selectGift, gifts*/
1510
- 3 && div2_class_value !== (div2_class_value = "giftbar-item " + /*selectGift*/
1511
- (ctx[1] === /*giftItem*/
1512
- ctx[7] ? "giftbar-item-on" : ""))) {
1513
- attr(div2, "class", div2_class_value);
1738
+ if (dirty & /*tabs, tabId*/
1739
+ 3 && div_class_value !== (div_class_value = "giftbar-tab " + /*item*/
1740
+ (ctx[8].id == /*tabId*/
1741
+ ctx[1] ? "giftbar-tab-on" : ""))) {
1742
+ attr(div, "class", div_class_value);
1514
1743
  }
1515
- if (giftHoverTip_action && is_function(giftHoverTip_action.update) && dirty & /*gifts*/
1516
- 1) giftHoverTip_action.update.call(
1517
- null,
1518
- /*giftItem*/
1519
- ctx[7].atitle || ""
1520
- );
1521
1744
  },
1522
1745
  d(detaching) {
1523
1746
  if (detaching) {
1524
- detach(div2);
1747
+ detach(div);
1525
1748
  }
1526
- if (if_block0) if_block0.d();
1527
- if (if_block1) if_block1.d();
1528
- if (if_block2) if_block2.d();
1749
+ if (if_block) if_block.d();
1529
1750
  mounted = false;
1530
- run_all(dispose);
1751
+ dispose();
1531
1752
  }
1532
1753
  };
1533
1754
  }
1534
- function create_if_block$n(ctx) {
1535
- let if_block_anchor;
1536
- function select_block_type(ctx2, dirty) {
1537
- if (
1538
- /*emptyImg*/
1539
- ctx2[2]
1540
- ) return create_if_block_1$k;
1541
- return create_else_block$c;
1542
- }
1543
- let current_block_type = select_block_type(ctx);
1544
- let if_block = current_block_type(ctx);
1755
+ function create_if_block_1$l(ctx) {
1756
+ let a;
1757
+ let t0;
1758
+ let t1_value = (
1759
+ /*tip*/
1760
+ ctx[2].text + ""
1761
+ );
1762
+ let t1;
1763
+ let a_href_value;
1764
+ let if_block = (
1765
+ /*tip*/
1766
+ ctx[2].img && create_if_block_2$c(ctx)
1767
+ );
1545
1768
  return {
1546
1769
  c() {
1547
- if_block.c();
1548
- if_block_anchor = empty();
1770
+ a = element("a");
1771
+ if (if_block) if_block.c();
1772
+ t0 = space();
1773
+ t1 = text(t1_value);
1774
+ attr(a, "href", a_href_value = /*tip*/
1775
+ ctx[2].link);
1776
+ attr(a, "target", "_blank");
1777
+ attr(a, "rel", "noopener noreferrer");
1549
1778
  },
1550
1779
  m(target, anchor) {
1551
- if_block.m(target, anchor);
1552
- insert(target, if_block_anchor, anchor);
1780
+ insert(target, a, anchor);
1781
+ if (if_block) if_block.m(a, null);
1782
+ append(a, t0);
1783
+ append(a, t1);
1553
1784
  },
1554
1785
  p(ctx2, dirty) {
1555
- if (current_block_type === (current_block_type = select_block_type(ctx2)) && if_block) {
1556
- if_block.p(ctx2, dirty);
1557
- } else {
1558
- if_block.d(1);
1559
- if_block = current_block_type(ctx2);
1786
+ if (
1787
+ /*tip*/
1788
+ ctx2[2].img
1789
+ ) {
1560
1790
  if (if_block) {
1791
+ if_block.p(ctx2, dirty);
1792
+ } else {
1793
+ if_block = create_if_block_2$c(ctx2);
1561
1794
  if_block.c();
1562
- if_block.m(if_block_anchor.parentNode, if_block_anchor);
1795
+ if_block.m(a, t0);
1563
1796
  }
1797
+ } else if (if_block) {
1798
+ if_block.d(1);
1799
+ if_block = null;
1800
+ }
1801
+ if (dirty & /*tip*/
1802
+ 4 && t1_value !== (t1_value = /*tip*/
1803
+ ctx2[2].text + "")) set_data(t1, t1_value);
1804
+ if (dirty & /*tip*/
1805
+ 4 && a_href_value !== (a_href_value = /*tip*/
1806
+ ctx2[2].link)) {
1807
+ attr(a, "href", a_href_value);
1564
1808
  }
1565
1809
  },
1566
1810
  d(detaching) {
1567
1811
  if (detaching) {
1568
- detach(if_block_anchor);
1812
+ detach(a);
1569
1813
  }
1570
- if_block.d(detaching);
1814
+ if (if_block) if_block.d();
1571
1815
  }
1572
1816
  };
1573
1817
  }
1574
- function create_else_block$c(ctx) {
1575
- let div;
1818
+ function create_if_block_2$c(ctx) {
1819
+ let img;
1820
+ let img_src_value;
1576
1821
  return {
1577
1822
  c() {
1578
- div = element("div");
1579
- div.textContent = "还没有礼物哦~";
1580
- attr(div, "class", "giftbar-empty");
1823
+ img = element("img");
1824
+ if (!src_url_equal(img.src, img_src_value = /*tip*/
1825
+ ctx[2].img)) attr(img, "src", img_src_value);
1826
+ attr(img, "alt", "");
1581
1827
  },
1582
1828
  m(target, anchor) {
1583
- insert(target, div, anchor);
1829
+ insert(target, img, anchor);
1830
+ },
1831
+ p(ctx2, dirty) {
1832
+ if (dirty & /*tip*/
1833
+ 4 && !src_url_equal(img.src, img_src_value = /*tip*/
1834
+ ctx2[2].img)) {
1835
+ attr(img, "src", img_src_value);
1836
+ }
1584
1837
  },
1585
- p: noop,
1586
1838
  d(detaching) {
1587
1839
  if (detaching) {
1588
- detach(div);
1840
+ detach(img);
1589
1841
  }
1590
1842
  }
1591
1843
  };
1592
1844
  }
1593
- function create_if_block_1$k(ctx) {
1594
- let img;
1595
- let img_src_value;
1845
+ function create_if_block$o(ctx) {
1846
+ let div;
1847
+ let mounted;
1848
+ let dispose;
1596
1849
  return {
1597
1850
  c() {
1598
- img = element("img");
1599
- attr(img, "class", "giftbar-empty-img");
1600
- if (!src_url_equal(img.src, img_src_value = /*emptyImg*/
1601
- ctx[2])) attr(img, "src", img_src_value);
1602
- attr(img, "alt", "");
1851
+ div = element("div");
1852
+ div.innerHTML = `<img src="https://asset.tuwan.com/officialsite/images/king.png" alt=""/> <span>贵族</span>`;
1853
+ attr(div, "class", "giftbar-nobility");
1854
+ attr(div, "role", "presentation");
1603
1855
  },
1604
1856
  m(target, anchor) {
1605
- insert(target, img, anchor);
1606
- },
1607
- p(ctx2, dirty) {
1608
- if (dirty & /*emptyImg*/
1609
- 4 && !src_url_equal(img.src, img_src_value = /*emptyImg*/
1610
- ctx2[2])) {
1611
- attr(img, "src", img_src_value);
1857
+ insert(target, div, anchor);
1858
+ if (!mounted) {
1859
+ dispose = listen(div, "click", stop_propagation(
1860
+ /*openNobility*/
1861
+ ctx[5]
1862
+ ));
1863
+ mounted = true;
1612
1864
  }
1613
1865
  },
1866
+ p: noop,
1614
1867
  d(detaching) {
1615
1868
  if (detaching) {
1616
- detach(img);
1869
+ detach(div);
1617
1870
  }
1871
+ mounted = false;
1872
+ dispose();
1618
1873
  }
1619
1874
  };
1620
1875
  }
1621
1876
  function create_fragment$r(ctx) {
1622
- let div;
1877
+ let div2;
1878
+ let div0;
1623
1879
  let each_blocks = [];
1624
1880
  let each_1_lookup = /* @__PURE__ */ new Map();
1625
- let t;
1881
+ let t0;
1882
+ let div1;
1883
+ let t1;
1626
1884
  let each_value = ensure_array_like(
1627
- /*gifts*/
1885
+ /*tabs*/
1628
1886
  ctx[0]
1629
1887
  );
1630
1888
  const get_key = (ctx2) => (
1631
- /*giftItem*/
1632
- ctx2[7].guid || /*giftItem*/
1633
- ctx2[7].id
1889
+ /*item*/
1890
+ ctx2[8].id
1634
1891
  );
1635
1892
  for (let i = 0; i < each_value.length; i += 1) {
1636
- let child_ctx = get_each_context$9(ctx, each_value, i);
1893
+ let child_ctx = get_each_context$a(ctx, each_value, i);
1637
1894
  let key = get_key(child_ctx);
1638
- each_1_lookup.set(key, each_blocks[i] = create_each_block$9(key, child_ctx));
1895
+ each_1_lookup.set(key, each_blocks[i] = create_each_block$a(key, child_ctx));
1639
1896
  }
1640
- let if_block = (
1641
- /*gifts*/
1642
- ctx[0].length === 0 && create_if_block$n(ctx)
1897
+ let if_block0 = (
1898
+ /*tip*/
1899
+ ctx[2] && /*tip*/
1900
+ ctx[2].text && /*tip*/
1901
+ ctx[2].link && /*tip*/
1902
+ ctx[2].kind !== "hidden" && create_if_block_1$l(ctx)
1903
+ );
1904
+ let if_block1 = (
1905
+ /*showNobility*/
1906
+ ctx[3] && create_if_block$o(ctx)
1643
1907
  );
1644
1908
  return {
1645
1909
  c() {
1646
- div = element("div");
1910
+ div2 = element("div");
1911
+ div0 = element("div");
1647
1912
  for (let i = 0; i < each_blocks.length; i += 1) {
1648
1913
  each_blocks[i].c();
1649
1914
  }
1650
- t = space();
1651
- if (if_block) if_block.c();
1652
- attr(div, "class", "giftbar-grid");
1915
+ t0 = space();
1916
+ div1 = element("div");
1917
+ if (if_block0) if_block0.c();
1918
+ t1 = space();
1919
+ if (if_block1) if_block1.c();
1920
+ attr(div0, "class", "giftbar-tabs");
1921
+ attr(div1, "class", "giftbar-tip");
1922
+ attr(div2, "class", "giftbar-head");
1653
1923
  },
1654
1924
  m(target, anchor) {
1655
- insert(target, div, anchor);
1925
+ insert(target, div2, anchor);
1926
+ append(div2, div0);
1656
1927
  for (let i = 0; i < each_blocks.length; i += 1) {
1657
1928
  if (each_blocks[i]) {
1658
- each_blocks[i].m(div, null);
1929
+ each_blocks[i].m(div0, null);
1659
1930
  }
1660
- }
1661
- append(div, t);
1662
- if (if_block) if_block.m(div, null);
1931
+ }
1932
+ append(div2, t0);
1933
+ append(div2, div1);
1934
+ if (if_block0) if_block0.m(div1, null);
1935
+ append(div1, t1);
1936
+ if (if_block1) if_block1.m(div1, null);
1663
1937
  },
1664
1938
  p(ctx2, [dirty]) {
1665
- if (dirty & /*gifts, selectGift, choose, animGuid*/
1666
- 27) {
1939
+ if (dirty & /*tabs, tabId, switchTab*/
1940
+ 19) {
1667
1941
  each_value = ensure_array_like(
1668
- /*gifts*/
1942
+ /*tabs*/
1669
1943
  ctx2[0]
1670
1944
  );
1671
- each_blocks = update_keyed_each(each_blocks, dirty, get_key, 1, ctx2, each_value, each_1_lookup, div, destroy_block, create_each_block$9, t, get_each_context$9);
1945
+ each_blocks = update_keyed_each(each_blocks, dirty, get_key, 1, ctx2, each_value, each_1_lookup, div0, destroy_block, create_each_block$a, null, get_each_context$a);
1672
1946
  }
1673
1947
  if (
1674
- /*gifts*/
1675
- ctx2[0].length === 0
1948
+ /*tip*/
1949
+ ctx2[2] && /*tip*/
1950
+ ctx2[2].text && /*tip*/
1951
+ ctx2[2].link && /*tip*/
1952
+ ctx2[2].kind !== "hidden"
1676
1953
  ) {
1677
- if (if_block) {
1678
- if_block.p(ctx2, dirty);
1954
+ if (if_block0) {
1955
+ if_block0.p(ctx2, dirty);
1679
1956
  } else {
1680
- if_block = create_if_block$n(ctx2);
1681
- if_block.c();
1682
- if_block.m(div, null);
1957
+ if_block0 = create_if_block_1$l(ctx2);
1958
+ if_block0.c();
1959
+ if_block0.m(div1, t1);
1683
1960
  }
1684
- } else if (if_block) {
1685
- if_block.d(1);
1686
- if_block = null;
1687
- }
1688
- },
1689
- i: noop,
1690
- o: noop,
1691
- d(detaching) {
1692
- if (detaching) {
1693
- detach(div);
1694
- }
1695
- for (let i = 0; i < each_blocks.length; i += 1) {
1696
- each_blocks[i].d();
1961
+ } else if (if_block0) {
1962
+ if_block0.d(1);
1963
+ if_block0 = null;
1697
1964
  }
1698
- if (if_block) if_block.d();
1699
- }
1700
- };
1701
- }
1702
- function instance$r($$self, $$props, $$invalidate) {
1703
- let { gifts = [] } = $$props;
1704
- let { selectGift = null } = $$props;
1705
- let { emptyImg = "" } = $$props;
1706
- let { onClickItem } = $$props;
1707
- let animGuid = "";
1708
- function choose(item) {
1709
- $$invalidate(3, animGuid = item.guid);
1710
- onClickItem && onClickItem(item);
1711
- setTimeout(
1712
- () => {
1713
- if (animGuid === item.guid) {
1714
- $$invalidate(3, animGuid = "");
1715
- }
1716
- },
1717
- 300
1718
- );
1719
- }
1720
- const click_handler = (giftItem) => choose(giftItem);
1721
- $$self.$$set = ($$props2) => {
1722
- if ("gifts" in $$props2) $$invalidate(0, gifts = $$props2.gifts);
1723
- if ("selectGift" in $$props2) $$invalidate(1, selectGift = $$props2.selectGift);
1724
- if ("emptyImg" in $$props2) $$invalidate(2, emptyImg = $$props2.emptyImg);
1725
- if ("onClickItem" in $$props2) $$invalidate(5, onClickItem = $$props2.onClickItem);
1726
- };
1727
- return [gifts, selectGift, emptyImg, animGuid, choose, onClickItem, click_handler];
1728
- }
1729
- class GiftGrid extends SvelteComponent {
1730
- constructor(options2) {
1731
- super();
1732
- init(this, options2, instance$r, create_fragment$r, safe_not_equal, {
1733
- gifts: 0,
1734
- selectGift: 1,
1735
- emptyImg: 2,
1736
- onClickItem: 5
1737
- });
1738
- }
1739
- }
1740
- function assertSource(source) {
1741
- if (source !== "room" && source !== "im") {
1742
- throw new Error("giftBarLib source must be 'room' or 'im'");
1743
- }
1744
- }
1745
- function assertRoomPayContext(ctx) {
1746
- if (!ctx || ctx.cid === void 0 || ctx.cid === null || ctx.cid === "") {
1747
- throw new Error("source=room requires cid in getPayContext");
1748
- }
1749
- if (ctx.imuid !== void 0 || ctx.group_id !== void 0) {
1750
- throw new Error("source=room PayContext must not include imuid/group_id");
1751
- }
1752
- if (String(ctx.actid) === "101") {
1753
- throw new Error("source=room PayContext must not use actid=101");
1754
- }
1755
- }
1756
- function hasValue$3(value) {
1757
- return value !== void 0 && value !== null && value !== "";
1758
- }
1759
- function assertImPayContext(ctx) {
1760
- if (!ctx) {
1761
- throw new Error("source=im requires getPayContext");
1762
- }
1763
- if (!hasValue$3(ctx.imuid) && !hasValue$3(ctx.group_id)) {
1764
- throw new Error("source=im requires imuid or group_id in getPayContext");
1765
- }
1766
- if (hasValue$3(ctx.cid)) {
1767
- throw new Error("source=im PayContext must not include cid");
1768
- }
1769
- if (ctx.is_whole_wheat !== void 0) {
1770
- throw new Error("source=im PayContext must not include is_whole_wheat");
1771
- }
1772
- }
1773
- function getSource() {
1774
- return options.source;
1775
- }
1776
- function isImSource() {
1777
- return options.source === "im";
1778
- }
1779
- const TAB_PACKAGE = 3;
1780
- const TAB_CRYSTAL = 7;
1781
- const PACKAGE_TAB_IDS = [TAB_PACKAGE, TAB_CRYSTAL];
1782
- const MAGIC_GIFT_IDS = [866, 873, 1583, 155, 156];
1783
- const NO_WHOLE_WHEAT_GIFT_IDS = [37, 9, 10, 55, 1293];
1784
- const CRYSTAL_IMG = "https://asset.tuwan.com/chatroom/images/icon_new_crystal.png";
1785
- const ZHUANSHI_IMG = "https://res.tuwan.com/templet/play/public/images/zuanshi.png";
1786
- const EMPTY_BAG_IMG = "https://asset.tuwan.com/images/chartRoomNoGift.png";
1787
- const DEFAULT_MAGIC_TIP_LINK = "https://y.tuwan.com/activities/900325Cdc25ee#/";
1788
- const DEFAULT_CRYSTAL_TIP_LINK = "https://y.tuwan.com/activity/340Cb43562?v=1703303588331#/";
1789
- const IM_DEFAULT_MAGIC_TIP_LINK = "https://y.tuwan.com/activity/36C33a2de?v=1656553263108#/";
1790
- function isPackageTab(tabId) {
1791
- return PACKAGE_TAB_IDS.indexOf(Number(tabId)) > -1;
1792
- }
1793
- function getVipLevelUrl() {
1794
- return "https://y" + (options.isChatTest ? "-test" : "") + ".tuwan.com/vip_level";
1795
- }
1796
- function getEmptyBagImg() {
1797
- return EMPTY_BAG_IMG;
1798
- }
1799
- function nrTobr(desc) {
1800
- if (!desc || typeof desc !== "string") {
1801
- return "";
1802
- }
1803
- return desc.replace(/\r\n/g, "<br>").replace(/\n/g, "<br>");
1804
- }
1805
- function formatBoxtitle(text2) {
1806
- if (!text2 || typeof text2 !== "string") {
1807
- return "";
1808
- }
1809
- const arr = text2.split("有机会获得");
1810
- if (arr.length > 1) {
1811
- return '有机会获得<span style="color:#ff6691;">' + arr[1] + "</span>";
1812
- }
1813
- return "";
1814
- }
1815
- function formatMoney(money, location2) {
1816
- const value = money * 1;
1817
- if (isNaN(value)) {
1818
- return money == null ? "" : String(money);
1819
- }
1820
- if (location2) {
1821
- if (value >= 1e4) {
1822
- return (value / 1e4).toFixed(2) + "w";
1823
- }
1824
- const moneyStr = value.toFixed(2) + "";
1825
- if (moneyStr.indexOf(".") === 4) {
1826
- return parseInt(String(value), 10);
1827
- }
1828
- return value.toFixed(2);
1829
- }
1830
- return value >= 1e4 ? (value / 1e4).toFixed(2) + "w" : parseInt(String(value), 10);
1831
- }
1832
- function stripHonorName(nickname) {
1833
- if (!nickname || typeof nickname !== "string") {
1834
- return nickname || "";
1835
- }
1836
- const marks = ["♕", "♚", "♔", "☬"];
1837
- for (let i = 0; i < marks.length; i++) {
1838
- if (nickname.indexOf(marks[i]) > -1) {
1839
- const part = nickname.split(marks[i])[1] || "";
1840
- return part || nickname;
1841
- }
1842
- }
1843
- return nickname;
1844
- }
1845
- function isIframeBlindBox(gift, tabId) {
1846
- return Number(tabId) === TAB_CRYSTAL && Number(gift && gift.type) === 24 && Number(gift && gift.worth) === 3;
1847
- }
1848
- function isBlindBoxModalGift(gift, tabId) {
1849
- const navid = Number(tabId);
1850
- const type = Number(gift && gift.type);
1851
- const id = Number(gift && gift.id);
1852
- const worth = Number(gift && gift.worth);
1853
- if (type !== 24 || id <= 1218) {
1854
- return false;
1855
- }
1856
- if (isImSource()) {
1857
- if (navid !== TAB_PACKAGE && navid !== TAB_CRYSTAL) {
1858
- return false;
1859
- }
1860
- return worth !== 3;
1861
- }
1862
- return navid === TAB_PACKAGE;
1863
- }
1864
- function canSendToSelf(gift, tabId) {
1865
- return Number(tabId) === TAB_PACKAGE && Number(gift && gift.type) === 7 || Number(gift && gift.id) === 383;
1866
- }
1867
- function allowEmptyWheat(gift, tabId) {
1868
- const type = Number(gift && gift.type);
1869
- const navid = Number(tabId);
1870
- return navid === TAB_PACKAGE && type === 7 || navid === TAB_CRYSTAL && type === 7 || navid === TAB_PACKAGE && type === 24;
1871
- }
1872
- function getGiftButtonStatus(gift, tabId, isSend) {
1873
- const empty2 = { send: false, open: false, use: false, sendLabel: "赠送" };
1874
- if (!gift) {
1875
- return { send: true, open: false, use: false, sendLabel: "赠送" };
1876
- }
1877
- const id = Number(gift.id);
1878
- const type = Number(gift.type);
1879
- const worth = Number(gift.worth);
1880
- const touid = Number(gift.to_uid || 0);
1881
- const navid = Number(tabId);
1882
- if (type === 29) {
1883
- if (isImSource()) {
1884
- return { ...empty2, send: true };
1885
- }
1886
- return { ...empty2, use: true };
1887
- }
1888
- if (navid === TAB_PACKAGE || navid === TAB_CRYSTAL) {
1889
- if (isImSource() && type === 24 && worth === 3 && navid !== TAB_CRYSTAL) {
1890
- return { ...empty2, send: true };
1891
- }
1892
- if (id === 383 || id === 873) {
1893
- return { ...empty2, open: true };
1894
- }
1895
- if (id === 866 || id === 1583) {
1896
- return { ...empty2, open: true, send: isImSource() ? false : Number(isSend) === 1 };
1897
- }
1898
- if (isImSource() && (id === 155 || id === 156)) {
1899
- return { ...empty2, open: true };
1900
- }
1901
- if (id === 384 || id === 389) {
1902
- return { ...empty2, use: true };
1903
- }
1904
- if (type === 7 || type === 24) {
1905
- return { ...empty2, open: true };
1906
- }
1907
- if (type === 16) {
1908
- return touid === 0 ? { ...empty2, use: true } : { ...empty2, send: true };
1909
- }
1910
- if (type === 37) {
1911
- return { ...empty2, send: true, sendLabel: "使用" };
1965
+ if (
1966
+ /*showNobility*/
1967
+ ctx2[3]
1968
+ ) {
1969
+ if (if_block1) {
1970
+ if_block1.p(ctx2, dirty);
1971
+ } else {
1972
+ if_block1 = create_if_block$o(ctx2);
1973
+ if_block1.c();
1974
+ if_block1.m(div1, null);
1975
+ }
1976
+ } else if (if_block1) {
1977
+ if_block1.d(1);
1978
+ if_block1 = null;
1979
+ }
1980
+ },
1981
+ i: noop,
1982
+ o: noop,
1983
+ d(detaching) {
1984
+ if (detaching) {
1985
+ detach(div2);
1986
+ }
1987
+ for (let i = 0; i < each_blocks.length; i += 1) {
1988
+ each_blocks[i].d();
1989
+ }
1990
+ if (if_block0) if_block0.d();
1991
+ if (if_block1) if_block1.d();
1912
1992
  }
1913
- return { ...empty2, send: true };
1914
- }
1915
- if (type === 37) {
1916
- return { ...empty2, send: true, sendLabel: "使用" };
1917
- }
1918
- return { ...empty2, send: true };
1919
- }
1920
- function getSelectUiState(gift, tabId, isSend) {
1921
- const buttons = getGiftButtonStatus(gift, tabId, isSend);
1922
- const effectiveIsSend = buttons.send && buttons.open ? isSend : buttons.send ? 1 : 0;
1923
- const state = {
1924
- countLocked: false,
1925
- showCountArrow: true,
1926
- recipient: "user",
1927
- showSendLabel: true,
1928
- boxTitleHtml: "",
1929
- sendLabel: buttons.sendLabel,
1930
- buttons
1931
1993
  };
1932
- if (!gift) {
1933
- return state;
1934
- }
1935
- const id = Number(gift.id);
1936
- const type = Number(gift.type);
1937
- const navid = Number(tabId);
1938
- const touid = Number(gift.to_uid || 0);
1939
- const worth = Number(gift.worth);
1940
- if (type === 30) {
1941
- state.recipient = "room";
1942
- return state;
1943
- }
1944
- if (type === 37) {
1945
- state.countLocked = true;
1946
- state.showCountArrow = false;
1947
- state.showSendLabel = false;
1948
- state.recipient = "giftTitle";
1949
- return state;
1950
- }
1951
- if (id === 866 || id === 1583) {
1952
- if (Number(effectiveIsSend) === 1) {
1953
- state.recipient = "user";
1954
- } else {
1955
- state.recipient = "box";
1956
- state.boxTitleHtml = formatBoxtitle(gift.intro);
1957
- }
1958
- return state;
1959
- }
1960
- if (id === 368) {
1961
- state.recipient = "none";
1962
- return state;
1963
- }
1964
- if (id === 389) {
1965
- state.recipient = "box";
1966
- state.boxTitleHtml = '礼包价值:<span style="color:#ff6691;">' + gift.price / 100 + "点点币</span>";
1967
- return state;
1968
- }
1969
- if (navid === TAB_CRYSTAL && type === 7 || navid === TAB_PACKAGE && type === 7 || id === 873) {
1970
- state.recipient = "box";
1971
- state.boxTitleHtml = formatBoxtitle(gift.intro);
1972
- return state;
1973
- }
1974
- if (type === 16) {
1975
- state.recipient = touid === 0 ? "none" : "user";
1976
- return state;
1994
+ }
1995
+ function instance$r($$self, $$props, $$invalidate) {
1996
+ let { tabs = [] } = $$props;
1997
+ let { tabId = 0 } = $$props;
1998
+ let { tip = {
1999
+ kind: "magic",
2000
+ text: "",
2001
+ link: "",
2002
+ img: ""
2003
+ } } = $$props;
2004
+ let { showNobility = true } = $$props;
2005
+ let { onClickTab } = $$props;
2006
+ function switchTab(item) {
2007
+ onClickTab && onClickTab(item);
1977
2008
  }
1978
- if (navid === TAB_CRYSTAL && type === 24 && worth === 3) {
1979
- state.recipient = "user";
1980
- return state;
2009
+ function openNobility(event) {
2010
+ event && event.stopPropagation && event.stopPropagation();
2011
+ showNobilityIframe();
1981
2012
  }
1982
- if (navid === TAB_PACKAGE && type === 24) {
1983
- state.recipient = "box";
1984
- state.boxTitleHtml = formatBoxtitle(gift.intro);
1985
- return state;
2013
+ const click_handler = (item) => switchTab(item);
2014
+ $$self.$$set = ($$props2) => {
2015
+ if ("tabs" in $$props2) $$invalidate(0, tabs = $$props2.tabs);
2016
+ if ("tabId" in $$props2) $$invalidate(1, tabId = $$props2.tabId);
2017
+ if ("tip" in $$props2) $$invalidate(2, tip = $$props2.tip);
2018
+ if ("showNobility" in $$props2) $$invalidate(3, showNobility = $$props2.showNobility);
2019
+ if ("onClickTab" in $$props2) $$invalidate(6, onClickTab = $$props2.onClickTab);
2020
+ };
2021
+ return [
2022
+ tabs,
2023
+ tabId,
2024
+ tip,
2025
+ showNobility,
2026
+ switchTab,
2027
+ openNobility,
2028
+ onClickTab,
2029
+ click_handler
2030
+ ];
2031
+ }
2032
+ class GiftTabs extends SvelteComponent {
2033
+ constructor(options2) {
2034
+ super();
2035
+ init(this, options2, instance$r, create_fragment$r, safe_not_equal, {
2036
+ tabs: 0,
2037
+ tabId: 1,
2038
+ tip: 2,
2039
+ showNobility: 3,
2040
+ onClickTab: 6
2041
+ });
1986
2042
  }
1987
- return state;
1988
2043
  }
1989
- function getTipState(gift, tabId) {
1990
- const navid = Number(tabId);
1991
- if (isImSource()) {
1992
- if (!gift) {
1993
- return { kind: "hidden", text: "", link: "", img: "" };
1994
- }
1995
- const type2 = Number(gift.type);
1996
- const id = Number(gift.id);
1997
- if (type2 === 24 && (id <= 1218 || gift.explain_url)) {
1998
- return {
1999
- kind: "box",
2000
- text: "礼盒礼物说明",
2001
- link: id > 1218 ? gift.explain_url : "https://y.tuwan.com/activity/575C87d860?giftId=" + gift.id,
2002
- img: gift.pic || ""
2003
- };
2004
- }
2005
- if (gift.explain_url) {
2006
- return {
2007
- kind: "magic",
2008
- text: navid === TAB_CRYSTAL ? "紫晶魔法说明" : "魔法礼物说明",
2009
- link: gift.explain_url,
2010
- img: ""
2011
- };
2012
- }
2013
- if (navid === TAB_CRYSTAL) {
2014
- return {
2015
- kind: "magic",
2016
- text: "紫晶魔法说明",
2017
- link: DEFAULT_CRYSTAL_TIP_LINK,
2018
- img: ""
2019
- };
2044
+ function giftHoverTip(node, html) {
2045
+ let tip = null;
2046
+ let currentHtml = html || "";
2047
+ function hide() {
2048
+ if (tip) {
2049
+ tip.remove();
2050
+ tip = null;
2020
2051
  }
2021
- return {
2022
- kind: "magic",
2023
- text: "魔法礼物说明",
2024
- link: IM_DEFAULT_MAGIC_TIP_LINK,
2025
- img: ""
2026
- };
2027
2052
  }
2028
- const tabDefault = navid === TAB_CRYSTAL ? { kind: "magic", text: "紫晶魔法说明", link: DEFAULT_CRYSTAL_TIP_LINK, img: "" } : { kind: "magic", text: "魔法礼物说明", link: DEFAULT_MAGIC_TIP_LINK, img: "" };
2029
- if (!gift) {
2030
- return tabDefault;
2053
+ function show() {
2054
+ hide();
2055
+ if (!currentHtml) {
2056
+ return;
2057
+ }
2058
+ tip = document.createElement("div");
2059
+ tip.className = "giftbar-item-tooltip";
2060
+ tip.innerHTML = '<div class="giftbar-item-tooltip-inner">' + currentHtml + '</div><div class="giftbar-item-tooltip-arrow"></div>';
2061
+ document.body.appendChild(tip);
2062
+ const rect = node.getBoundingClientRect();
2063
+ tip.style.left = rect.left + rect.width / 2 + "px";
2064
+ tip.style.top = rect.top + "px";
2031
2065
  }
2032
- const type = Number(gift.type);
2033
- const worth = Number(gift.worth);
2034
- if (type === 30 || type === 31 || type === 32) {
2035
- return { kind: "vip", text: "VIP财富等级", link: getVipLevelUrl(), img: "" };
2066
+ node.addEventListener("mouseenter", show);
2067
+ node.addEventListener("mouseleave", hide);
2068
+ window.addEventListener("scroll", hide, true);
2069
+ return {
2070
+ update(nextHtml) {
2071
+ currentHtml = nextHtml || "";
2072
+ if (tip) {
2073
+ if (!currentHtml) {
2074
+ hide();
2075
+ } else {
2076
+ show();
2077
+ }
2078
+ }
2079
+ },
2080
+ destroy() {
2081
+ hide();
2082
+ node.removeEventListener("mouseenter", show);
2083
+ node.removeEventListener("mouseleave", hide);
2084
+ window.removeEventListener("scroll", hide, true);
2085
+ }
2086
+ };
2087
+ }
2088
+ const OSS_HOST_RE = /(^|\.)tuwandata\.com$|(^|\.)img\d*\.tuwan\.com$/i;
2089
+ const PROCESS = "image/resize,m_fill,w_128,h_128/format,webp";
2090
+ function giftListThumbUrl(src) {
2091
+ if (!src || typeof src !== "string") {
2092
+ return src || "";
2036
2093
  }
2037
- if (type === 37) {
2038
- return tabDefault;
2094
+ if (/^(data:|blob:)/i.test(src)) {
2095
+ return src;
2039
2096
  }
2040
- if (type === 24 && worth === 3 && navid !== TAB_PACKAGE && navid !== TAB_CRYSTAL) {
2041
- return {
2042
- kind: "magic",
2043
- text: "魔法礼物说明",
2044
- link: gift.explain_url || DEFAULT_MAGIC_TIP_LINK,
2045
- img: ""
2046
- };
2097
+ if (/[?&]x-oss-process=/i.test(src)) {
2098
+ return src;
2047
2099
  }
2048
- if (type === 24) {
2049
- if (gift.explain_url) {
2050
- return {
2051
- kind: "box",
2052
- text: "礼盒礼物说明",
2053
- link: gift.explain_url,
2054
- img: gift.pic || ""
2055
- };
2100
+ try {
2101
+ const url = new URL(src, typeof location !== "undefined" ? location.href : "https://www.tuwan.com");
2102
+ if (!OSS_HOST_RE.test(url.hostname)) {
2103
+ return src;
2056
2104
  }
2057
- return {
2058
- kind: "magic",
2059
- text: "魔法礼物说明",
2060
- link: DEFAULT_MAGIC_TIP_LINK,
2061
- img: ""
2062
- };
2105
+ url.searchParams.set("x-oss-process", PROCESS);
2106
+ return url.toString();
2107
+ } catch (e) {
2108
+ return src;
2063
2109
  }
2064
- if (gift.explain_url) {
2065
- return {
2066
- kind: "magic",
2067
- text: "魔法礼物说明",
2068
- link: gift.explain_url,
2069
- img: ""
2070
- };
2110
+ }
2111
+ const PRELOAD_MARGIN = "240px 0px";
2112
+ const GIFT_IMG_PLACEHOLDER = "data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7";
2113
+ function findGridRoot(node) {
2114
+ return node.closest ? node.closest(".giftbar-grid") : null;
2115
+ }
2116
+ function setSrc(node, src) {
2117
+ if (node.getAttribute("src") === src) {
2118
+ return;
2071
2119
  }
2072
- return tabDefault;
2120
+ node.setAttribute("src", src);
2073
2121
  }
2074
- function isMagicGift(gift, tabId) {
2075
- const id = Number(gift && gift.id);
2076
- const navid = Number(tabId);
2077
- if (isImSource()) {
2078
- if (navid !== TAB_PACKAGE && navid !== TAB_CRYSTAL) {
2079
- return false;
2122
+ function lazyGiftImg(node, src) {
2123
+ let currentSrc = src || "";
2124
+ let observer = null;
2125
+ function clearObserver() {
2126
+ if (observer) {
2127
+ observer.disconnect();
2128
+ observer = null;
2080
2129
  }
2081
- if (Number(gift && gift.type) === 24 && Number(gift && gift.worth) === 3) {
2082
- return false;
2130
+ }
2131
+ function applySrc() {
2132
+ setSrc(node, currentSrc || GIFT_IMG_PLACEHOLDER);
2133
+ }
2134
+ function observe() {
2135
+ clearObserver();
2136
+ setSrc(node, GIFT_IMG_PLACEHOLDER);
2137
+ if (!currentSrc) {
2138
+ return;
2083
2139
  }
2084
- if (Number(gift && gift.type) === 24 && id > 1218) {
2085
- return false;
2140
+ if (typeof IntersectionObserver !== "function") {
2141
+ applySrc();
2142
+ return;
2086
2143
  }
2087
- return MAGIC_GIFT_IDS.indexOf(id) > -1;
2144
+ const root = findGridRoot(node);
2145
+ observer = new IntersectionObserver(
2146
+ (entries) => {
2147
+ const hit = entries.some((item) => item.isIntersecting);
2148
+ if (!hit) {
2149
+ return;
2150
+ }
2151
+ applySrc();
2152
+ clearObserver();
2153
+ },
2154
+ { root: root || null, rootMargin: PRELOAD_MARGIN, threshold: 0.01 }
2155
+ );
2156
+ observer.observe(node);
2088
2157
  }
2089
- if (id === 866 || id === 873 || id === 1583) {
2090
- return true;
2158
+ observe();
2159
+ return {
2160
+ update(nextSrc) {
2161
+ const next = nextSrc || "";
2162
+ if (next === currentSrc) {
2163
+ return;
2164
+ }
2165
+ currentSrc = next;
2166
+ observe();
2167
+ },
2168
+ destroy() {
2169
+ clearObserver();
2170
+ }
2171
+ };
2172
+ }
2173
+ function get_each_context$9(ctx, list, i) {
2174
+ const child_ctx = ctx.slice();
2175
+ child_ctx[10] = list[i];
2176
+ return child_ctx;
2177
+ }
2178
+ function create_if_block_6$4(ctx) {
2179
+ let span;
2180
+ let t_value = (
2181
+ /*giftItem*/
2182
+ ctx[10].tag + ""
2183
+ );
2184
+ let t;
2185
+ return {
2186
+ c() {
2187
+ span = element("span");
2188
+ t = text(t_value);
2189
+ attr(span, "class", "giftbar-item-tag");
2190
+ },
2191
+ m(target, anchor) {
2192
+ insert(target, span, anchor);
2193
+ append(span, t);
2194
+ },
2195
+ p(ctx2, dirty) {
2196
+ if (dirty & /*gifts*/
2197
+ 1 && t_value !== (t_value = /*giftItem*/
2198
+ ctx2[10].tag + "")) set_data(t, t_value);
2199
+ },
2200
+ d(detaching) {
2201
+ if (detaching) {
2202
+ detach(span);
2203
+ }
2204
+ }
2205
+ };
2206
+ }
2207
+ function create_if_block_4$6(ctx) {
2208
+ let div;
2209
+ let t0;
2210
+ let t1_value = (
2211
+ /*giftItem*/
2212
+ ctx[10].unitText + ""
2213
+ );
2214
+ let t1;
2215
+ let if_block = (
2216
+ /*giftItem*/
2217
+ ctx[10].picIcon && create_if_block_5$5(ctx)
2218
+ );
2219
+ return {
2220
+ c() {
2221
+ div = element("div");
2222
+ if (if_block) if_block.c();
2223
+ t0 = space();
2224
+ t1 = text(t1_value);
2225
+ attr(div, "class", "giftbar-item-unit");
2226
+ },
2227
+ m(target, anchor) {
2228
+ insert(target, div, anchor);
2229
+ if (if_block) if_block.m(div, null);
2230
+ append(div, t0);
2231
+ append(div, t1);
2232
+ },
2233
+ p(ctx2, dirty) {
2234
+ if (
2235
+ /*giftItem*/
2236
+ ctx2[10].picIcon
2237
+ ) {
2238
+ if (if_block) {
2239
+ if_block.p(ctx2, dirty);
2240
+ } else {
2241
+ if_block = create_if_block_5$5(ctx2);
2242
+ if_block.c();
2243
+ if_block.m(div, t0);
2244
+ }
2245
+ } else if (if_block) {
2246
+ if_block.d(1);
2247
+ if_block = null;
2248
+ }
2249
+ if (dirty & /*gifts*/
2250
+ 1 && t1_value !== (t1_value = /*giftItem*/
2251
+ ctx2[10].unitText + "")) set_data(t1, t1_value);
2252
+ },
2253
+ d(detaching) {
2254
+ if (detaching) {
2255
+ detach(div);
2256
+ }
2257
+ if (if_block) if_block.d();
2258
+ }
2259
+ };
2260
+ }
2261
+ function create_if_block_5$5(ctx) {
2262
+ let img;
2263
+ let img_class_value;
2264
+ let img_src_value;
2265
+ return {
2266
+ c() {
2267
+ img = element("img");
2268
+ attr(img, "class", img_class_value = /*giftItem*/
2269
+ ctx[10].isCrystal ? "is-crystal" : "");
2270
+ if (!src_url_equal(img.src, img_src_value = /*giftItem*/
2271
+ ctx[10].picIcon)) attr(img, "src", img_src_value);
2272
+ attr(img, "alt", "");
2273
+ },
2274
+ m(target, anchor) {
2275
+ insert(target, img, anchor);
2276
+ },
2277
+ p(ctx2, dirty) {
2278
+ if (dirty & /*gifts*/
2279
+ 1 && img_class_value !== (img_class_value = /*giftItem*/
2280
+ ctx2[10].isCrystal ? "is-crystal" : "")) {
2281
+ attr(img, "class", img_class_value);
2282
+ }
2283
+ if (dirty & /*gifts*/
2284
+ 1 && !src_url_equal(img.src, img_src_value = /*giftItem*/
2285
+ ctx2[10].picIcon)) {
2286
+ attr(img, "src", img_src_value);
2287
+ }
2288
+ },
2289
+ d(detaching) {
2290
+ if (detaching) {
2291
+ detach(img);
2292
+ }
2293
+ }
2294
+ };
2295
+ }
2296
+ function create_if_block_3$7(ctx) {
2297
+ let div;
2298
+ let t_value = (
2299
+ /*giftItem*/
2300
+ ctx[10].unitText2 + ""
2301
+ );
2302
+ let t;
2303
+ return {
2304
+ c() {
2305
+ div = element("div");
2306
+ t = text(t_value);
2307
+ attr(div, "class", "giftbar-item-unit");
2308
+ },
2309
+ m(target, anchor) {
2310
+ insert(target, div, anchor);
2311
+ append(div, t);
2312
+ },
2313
+ p(ctx2, dirty) {
2314
+ if (dirty & /*gifts*/
2315
+ 1 && t_value !== (t_value = /*giftItem*/
2316
+ ctx2[10].unitText2 + "")) set_data(t, t_value);
2317
+ },
2318
+ d(detaching) {
2319
+ if (detaching) {
2320
+ detach(div);
2321
+ }
2322
+ }
2323
+ };
2324
+ }
2325
+ function create_if_block_2$b(ctx) {
2326
+ let div;
2327
+ let mounted;
2328
+ let dispose;
2329
+ function click_handler(...args) {
2330
+ return (
2331
+ /*click_handler*/
2332
+ ctx[8](
2333
+ /*giftItem*/
2334
+ ctx[10],
2335
+ ...args
2336
+ )
2337
+ );
2091
2338
  }
2092
- return navid === TAB_PACKAGE && (id === 155 || id === 156);
2339
+ return {
2340
+ c() {
2341
+ div = element("div");
2342
+ attr(div, "class", "giftbar-help-icon");
2343
+ attr(div, "role", "presentation");
2344
+ },
2345
+ m(target, anchor) {
2346
+ insert(target, div, anchor);
2347
+ if (!mounted) {
2348
+ dispose = listen(div, "click", stop_propagation(click_handler));
2349
+ mounted = true;
2350
+ }
2351
+ },
2352
+ p(new_ctx, dirty) {
2353
+ ctx = new_ctx;
2354
+ },
2355
+ d(detaching) {
2356
+ if (detaching) {
2357
+ detach(div);
2358
+ }
2359
+ mounted = false;
2360
+ dispose();
2361
+ }
2362
+ };
2093
2363
  }
2094
- function getSelectHostEffect(gift, tabId) {
2095
- if (!gift) {
2096
- return "";
2097
- }
2098
- const id = Number(gift.id);
2099
- const type = Number(gift.type);
2100
- if (id === 368 || id === 389) {
2101
- return "click";
2102
- }
2103
- if (id === 383) {
2104
- return "";
2105
- }
2106
- if (type === 16 && Number(gift.to_uid || 0) === 0) {
2107
- return "click";
2108
- }
2109
- if (type === 1e4) {
2110
- return "click";
2364
+ function create_each_block$9(key_1, ctx) {
2365
+ let div2;
2366
+ let div0;
2367
+ let img;
2368
+ let img_class_value;
2369
+ let img_src_value;
2370
+ let lazyGiftImg_action;
2371
+ let t0;
2372
+ let t1;
2373
+ let div1;
2374
+ let t2_value = (
2375
+ /*giftItem*/
2376
+ ctx[10].title + ""
2377
+ );
2378
+ let t2;
2379
+ let t3;
2380
+ let t4;
2381
+ let t5;
2382
+ let show_if = canShowHelp(
2383
+ /*giftItem*/
2384
+ ctx[10],
2385
+ /*selectGift*/
2386
+ ctx[1]
2387
+ );
2388
+ let div2_id_value;
2389
+ let div2_class_value;
2390
+ let giftHoverTip_action;
2391
+ let mounted;
2392
+ let dispose;
2393
+ let if_block0 = (
2394
+ /*giftItem*/
2395
+ ctx[10].tag && create_if_block_6$4(ctx)
2396
+ );
2397
+ let if_block1 = (
2398
+ /*giftItem*/
2399
+ ctx[10].unitText && create_if_block_4$6(ctx)
2400
+ );
2401
+ let if_block2 = (
2402
+ /*giftItem*/
2403
+ ctx[10].unitText2 && create_if_block_3$7(ctx)
2404
+ );
2405
+ let if_block3 = show_if && create_if_block_2$b(ctx);
2406
+ function click_handler_12() {
2407
+ return (
2408
+ /*click_handler_1*/
2409
+ ctx[9](
2410
+ /*giftItem*/
2411
+ ctx[10]
2412
+ )
2413
+ );
2111
2414
  }
2112
- if (type === 29) {
2113
- if (isImSource()) {
2114
- return "";
2415
+ return {
2416
+ key: key_1,
2417
+ first: null,
2418
+ c() {
2419
+ div2 = element("div");
2420
+ div0 = element("div");
2421
+ img = element("img");
2422
+ t0 = space();
2423
+ if (if_block0) if_block0.c();
2424
+ t1 = space();
2425
+ div1 = element("div");
2426
+ t2 = text(t2_value);
2427
+ t3 = space();
2428
+ if (if_block1) if_block1.c();
2429
+ t4 = space();
2430
+ if (if_block2) if_block2.c();
2431
+ t5 = space();
2432
+ if (if_block3) if_block3.c();
2433
+ attr(img, "class", img_class_value = "giftbar-item-pic " + /*animGuid*/
2434
+ (ctx[3] === /*giftItem*/
2435
+ ctx[10].guid ? "gift-select-animation" : ""));
2436
+ if (!src_url_equal(img.src, img_src_value = GIFT_IMG_PLACEHOLDER)) attr(img, "src", img_src_value);
2437
+ attr(img, "alt", "");
2438
+ attr(img, "decoding", "async");
2439
+ attr(img, "loading", "lazy");
2440
+ set_style(div0, "position", "relative");
2441
+ attr(div1, "class", "giftbar-item-title");
2442
+ attr(div2, "id", div2_id_value = /*giftItem*/
2443
+ ctx[10].guid);
2444
+ attr(div2, "class", div2_class_value = "giftbar-item " + /*selectGift*/
2445
+ (ctx[1] === /*giftItem*/
2446
+ ctx[10] ? "giftbar-item-on" : ""));
2447
+ attr(div2, "role", "presentation");
2448
+ this.first = div2;
2449
+ },
2450
+ m(target, anchor) {
2451
+ insert(target, div2, anchor);
2452
+ append(div2, div0);
2453
+ append(div0, img);
2454
+ append(div0, t0);
2455
+ if (if_block0) if_block0.m(div0, null);
2456
+ append(div2, t1);
2457
+ append(div2, div1);
2458
+ append(div1, t2);
2459
+ append(div2, t3);
2460
+ if (if_block1) if_block1.m(div2, null);
2461
+ append(div2, t4);
2462
+ if (if_block2) if_block2.m(div2, null);
2463
+ append(div2, t5);
2464
+ if (if_block3) if_block3.m(div2, null);
2465
+ if (!mounted) {
2466
+ dispose = [
2467
+ action_destroyer(lazyGiftImg_action = lazyGiftImg.call(null, img, giftListThumbUrl(
2468
+ /*giftItem*/
2469
+ ctx[10].pic
2470
+ ))),
2471
+ action_destroyer(giftHoverTip_action = giftHoverTip.call(
2472
+ null,
2473
+ div2,
2474
+ /*giftItem*/
2475
+ ctx[10].atitle || ""
2476
+ )),
2477
+ listen(div2, "click", stop_propagation(click_handler_12))
2478
+ ];
2479
+ mounted = true;
2480
+ }
2481
+ },
2482
+ p(new_ctx, dirty) {
2483
+ ctx = new_ctx;
2484
+ if (dirty & /*animGuid, gifts*/
2485
+ 9 && img_class_value !== (img_class_value = "giftbar-item-pic " + /*animGuid*/
2486
+ (ctx[3] === /*giftItem*/
2487
+ ctx[10].guid ? "gift-select-animation" : ""))) {
2488
+ attr(img, "class", img_class_value);
2489
+ }
2490
+ if (lazyGiftImg_action && is_function(lazyGiftImg_action.update) && dirty & /*gifts*/
2491
+ 1) lazyGiftImg_action.update.call(null, giftListThumbUrl(
2492
+ /*giftItem*/
2493
+ ctx[10].pic
2494
+ ));
2495
+ if (
2496
+ /*giftItem*/
2497
+ ctx[10].tag
2498
+ ) {
2499
+ if (if_block0) {
2500
+ if_block0.p(ctx, dirty);
2501
+ } else {
2502
+ if_block0 = create_if_block_6$4(ctx);
2503
+ if_block0.c();
2504
+ if_block0.m(div0, null);
2505
+ }
2506
+ } else if (if_block0) {
2507
+ if_block0.d(1);
2508
+ if_block0 = null;
2509
+ }
2510
+ if (dirty & /*gifts*/
2511
+ 1 && t2_value !== (t2_value = /*giftItem*/
2512
+ ctx[10].title + "")) set_data(t2, t2_value);
2513
+ if (
2514
+ /*giftItem*/
2515
+ ctx[10].unitText
2516
+ ) {
2517
+ if (if_block1) {
2518
+ if_block1.p(ctx, dirty);
2519
+ } else {
2520
+ if_block1 = create_if_block_4$6(ctx);
2521
+ if_block1.c();
2522
+ if_block1.m(div2, t4);
2523
+ }
2524
+ } else if (if_block1) {
2525
+ if_block1.d(1);
2526
+ if_block1 = null;
2527
+ }
2528
+ if (
2529
+ /*giftItem*/
2530
+ ctx[10].unitText2
2531
+ ) {
2532
+ if (if_block2) {
2533
+ if_block2.p(ctx, dirty);
2534
+ } else {
2535
+ if_block2 = create_if_block_3$7(ctx);
2536
+ if_block2.c();
2537
+ if_block2.m(div2, t5);
2538
+ }
2539
+ } else if (if_block2) {
2540
+ if_block2.d(1);
2541
+ if_block2 = null;
2542
+ }
2543
+ if (dirty & /*gifts, selectGift*/
2544
+ 3) show_if = canShowHelp(
2545
+ /*giftItem*/
2546
+ ctx[10],
2547
+ /*selectGift*/
2548
+ ctx[1]
2549
+ );
2550
+ if (show_if) {
2551
+ if (if_block3) {
2552
+ if_block3.p(ctx, dirty);
2553
+ } else {
2554
+ if_block3 = create_if_block_2$b(ctx);
2555
+ if_block3.c();
2556
+ if_block3.m(div2, null);
2557
+ }
2558
+ } else if (if_block3) {
2559
+ if_block3.d(1);
2560
+ if_block3 = null;
2561
+ }
2562
+ if (dirty & /*gifts*/
2563
+ 1 && div2_id_value !== (div2_id_value = /*giftItem*/
2564
+ ctx[10].guid)) {
2565
+ attr(div2, "id", div2_id_value);
2566
+ }
2567
+ if (dirty & /*selectGift, gifts*/
2568
+ 3 && div2_class_value !== (div2_class_value = "giftbar-item " + /*selectGift*/
2569
+ (ctx[1] === /*giftItem*/
2570
+ ctx[10] ? "giftbar-item-on" : ""))) {
2571
+ attr(div2, "class", div2_class_value);
2572
+ }
2573
+ if (giftHoverTip_action && is_function(giftHoverTip_action.update) && dirty & /*gifts*/
2574
+ 1) giftHoverTip_action.update.call(
2575
+ null,
2576
+ /*giftItem*/
2577
+ ctx[10].atitle || ""
2578
+ );
2579
+ },
2580
+ d(detaching) {
2581
+ if (detaching) {
2582
+ detach(div2);
2583
+ }
2584
+ if (if_block0) if_block0.d();
2585
+ if (if_block1) if_block1.d();
2586
+ if (if_block2) if_block2.d();
2587
+ if (if_block3) if_block3.d();
2588
+ mounted = false;
2589
+ run_all(dispose);
2115
2590
  }
2116
- return "pardon";
2117
- }
2118
- return "";
2591
+ };
2119
2592
  }
2120
- function resolveFooterAction(action, gift, tabId, selectedUser) {
2121
- if (!gift || !gift.id) {
2122
- return { kind: "alert", message: "请选择一个礼物" };
2593
+ function create_if_block$n(ctx) {
2594
+ let if_block_anchor;
2595
+ function select_block_type(ctx2, dirty) {
2596
+ if (
2597
+ /*emptyImg*/
2598
+ ctx2[2]
2599
+ ) return create_if_block_1$k;
2600
+ return create_else_block$c;
2123
2601
  }
2124
- const id = Number(gift.id);
2125
- const type = Number(gift.type);
2126
- const navid = Number(tabId);
2127
- const touid = Number(gift.to_uid || 0);
2128
- const uid = selectedUser ? Number(selectedUser.uid) : 0;
2129
- if (action === "use") {
2130
- if (type === 29) {
2131
- if (isImSource()) {
2132
- return { kind: "pay", payAction: "send" };
2602
+ let current_block_type = select_block_type(ctx);
2603
+ let if_block = current_block_type(ctx);
2604
+ return {
2605
+ c() {
2606
+ if_block.c();
2607
+ if_block_anchor = empty();
2608
+ },
2609
+ m(target, anchor) {
2610
+ if_block.m(target, anchor);
2611
+ insert(target, if_block_anchor, anchor);
2612
+ },
2613
+ p(ctx2, dirty) {
2614
+ if (current_block_type === (current_block_type = select_block_type(ctx2)) && if_block) {
2615
+ if_block.p(ctx2, dirty);
2616
+ } else {
2617
+ if_block.d(1);
2618
+ if_block = current_block_type(ctx2);
2619
+ if (if_block) {
2620
+ if_block.c();
2621
+ if_block.m(if_block_anchor.parentNode, if_block_anchor);
2622
+ }
2133
2623
  }
2134
- return { kind: "pardon" };
2624
+ },
2625
+ d(detaching) {
2626
+ if (detaching) {
2627
+ detach(if_block_anchor);
2628
+ }
2629
+ if_block.d(detaching);
2135
2630
  }
2136
- if (id === 389) {
2137
- return { kind: "hostClick" };
2631
+ };
2632
+ }
2633
+ function create_else_block$c(ctx) {
2634
+ let div;
2635
+ return {
2636
+ c() {
2637
+ div = element("div");
2638
+ div.textContent = "还没有礼物哦~";
2639
+ attr(div, "class", "giftbar-empty");
2640
+ },
2641
+ m(target, anchor) {
2642
+ insert(target, div, anchor);
2643
+ },
2644
+ p: noop,
2645
+ d(detaching) {
2646
+ if (detaching) {
2647
+ detach(div);
2648
+ }
2138
2649
  }
2139
- if (type === 16 && touid === 0) {
2140
- return { kind: "hostClick" };
2650
+ };
2651
+ }
2652
+ function create_if_block_1$k(ctx) {
2653
+ let img;
2654
+ let img_src_value;
2655
+ return {
2656
+ c() {
2657
+ img = element("img");
2658
+ attr(img, "class", "giftbar-empty-img");
2659
+ if (!src_url_equal(img.src, img_src_value = /*emptyImg*/
2660
+ ctx[2])) attr(img, "src", img_src_value);
2661
+ attr(img, "alt", "");
2662
+ },
2663
+ m(target, anchor) {
2664
+ insert(target, img, anchor);
2665
+ },
2666
+ p(ctx2, dirty) {
2667
+ if (dirty & /*emptyImg*/
2668
+ 4 && !src_url_equal(img.src, img_src_value = /*emptyImg*/
2669
+ ctx2[2])) {
2670
+ attr(img, "src", img_src_value);
2671
+ }
2672
+ },
2673
+ d(detaching) {
2674
+ if (detaching) {
2675
+ detach(img);
2676
+ }
2141
2677
  }
2142
- return { kind: "pay", payAction: "send" };
2678
+ };
2679
+ }
2680
+ function create_fragment$q(ctx) {
2681
+ let div;
2682
+ let each_blocks = [];
2683
+ let each_1_lookup = /* @__PURE__ */ new Map();
2684
+ let t;
2685
+ let each_value = ensure_array_like(
2686
+ /*gifts*/
2687
+ ctx[0]
2688
+ );
2689
+ const get_key = (ctx2) => (
2690
+ /*giftItem*/
2691
+ ctx2[10].guid || /*giftItem*/
2692
+ ctx2[10].id
2693
+ );
2694
+ for (let i = 0; i < each_value.length; i += 1) {
2695
+ let child_ctx = get_each_context$9(ctx, each_value, i);
2696
+ let key = get_key(child_ctx);
2697
+ each_1_lookup.set(key, each_blocks[i] = create_each_block$9(key, child_ctx));
2143
2698
  }
2144
- if (action === "send") {
2145
- if (Number(gift.question_gift) === 1) {
2146
- return { kind: "question" };
2147
- }
2148
- if (type === 30 || type === 37) {
2149
- return { kind: "hostUse" };
2150
- }
2151
- if (id === 1293 && uid === 0) {
2152
- return { kind: "alert", message: "该礼物不能赠送全麦" };
2699
+ let if_block = (
2700
+ /*gifts*/
2701
+ ctx[0].length === 0 && create_if_block$n(ctx)
2702
+ );
2703
+ return {
2704
+ c() {
2705
+ div = element("div");
2706
+ for (let i = 0; i < each_blocks.length; i += 1) {
2707
+ each_blocks[i].c();
2708
+ }
2709
+ t = space();
2710
+ if (if_block) if_block.c();
2711
+ attr(div, "class", "giftbar-grid");
2712
+ },
2713
+ m(target, anchor) {
2714
+ insert(target, div, anchor);
2715
+ for (let i = 0; i < each_blocks.length; i += 1) {
2716
+ if (each_blocks[i]) {
2717
+ each_blocks[i].m(div, null);
2718
+ }
2719
+ }
2720
+ append(div, t);
2721
+ if (if_block) if_block.m(div, null);
2722
+ },
2723
+ p(ctx2, [dirty]) {
2724
+ if (dirty & /*gifts, selectGift, choose, openHelp, canShowHelp, animGuid*/
2725
+ 59) {
2726
+ each_value = ensure_array_like(
2727
+ /*gifts*/
2728
+ ctx2[0]
2729
+ );
2730
+ each_blocks = update_keyed_each(each_blocks, dirty, get_key, 1, ctx2, each_value, each_1_lookup, div, destroy_block, create_each_block$9, t, get_each_context$9);
2731
+ }
2732
+ if (
2733
+ /*gifts*/
2734
+ ctx2[0].length === 0
2735
+ ) {
2736
+ if (if_block) {
2737
+ if_block.p(ctx2, dirty);
2738
+ } else {
2739
+ if_block = create_if_block$n(ctx2);
2740
+ if_block.c();
2741
+ if_block.m(div, null);
2742
+ }
2743
+ } else if (if_block) {
2744
+ if_block.d(1);
2745
+ if_block = null;
2746
+ }
2747
+ },
2748
+ i: noop,
2749
+ o: noop,
2750
+ d(detaching) {
2751
+ if (detaching) {
2752
+ detach(div);
2753
+ }
2754
+ for (let i = 0; i < each_blocks.length; i += 1) {
2755
+ each_blocks[i].d();
2756
+ }
2757
+ if (if_block) if_block.d();
2153
2758
  }
2154
- return { kind: "pay", payAction: "send" };
2155
- }
2156
- if (isIframeBlindBox(gift, navid)) {
2157
- return { kind: "iframe" };
2158
- }
2159
- if (isBlindBoxModalGift(gift, navid)) {
2160
- return { kind: "blindBox" };
2161
- }
2162
- if (isMagicGift(gift, navid)) {
2163
- return { kind: "magic" };
2164
- }
2165
- if (id === 383) {
2166
- return { kind: "hostClick" };
2167
- }
2168
- if (id === 368 || id === 389) {
2169
- return { kind: "hostClick" };
2170
- }
2171
- if (type === 16 && touid === 0) {
2172
- return { kind: "hostClick" };
2173
- }
2174
- return { kind: "pay", payAction: "open" };
2759
+ };
2175
2760
  }
2176
- let guidIdx = 0;
2177
- function nextGuid(navid, id, index) {
2178
- if (index !== void 0 && index !== null) {
2179
- return "giftbar_" + navid + "_" + id + "_" + index;
2180
- }
2181
- guidIdx += 1;
2182
- return "giftbar_" + navid + "_" + id + "_" + guidIdx;
2761
+ function canShowHelp(gift, selected) {
2762
+ return selected === gift && Number(gift && gift.is_multi_gift) === 1 && !!(gift && gift.explain_url);
2183
2763
  }
2184
- function transformShopGift(navid, temp, index) {
2185
- const worth = Number(temp.worth);
2186
- temp.picIcon = worth === 3 ? CRYSTAL_IMG : ZHUANSHI_IMG;
2187
- temp.isCrystal = worth === 3;
2188
- temp.unitText = temp.diamond + (worth === 3 ? "紫晶" : "钻");
2189
- temp.unitText2 = "";
2190
- if (temp.worth === void 0) {
2191
- temp.worth = 0;
2764
+ function instance$q($$self, $$props, $$invalidate) {
2765
+ let { gifts = [] } = $$props;
2766
+ let { selectGift = null } = $$props;
2767
+ let { emptyImg = "" } = $$props;
2768
+ let { onClickItem } = $$props;
2769
+ let { onOpenHelp } = $$props;
2770
+ let animGuid = "";
2771
+ function choose(item) {
2772
+ $$invalidate(3, animGuid = item.guid);
2773
+ onClickItem && onClickItem(item);
2774
+ setTimeout(
2775
+ () => {
2776
+ if (animGuid === item.guid) {
2777
+ $$invalidate(3, animGuid = "");
2778
+ }
2779
+ },
2780
+ 300
2781
+ );
2192
2782
  }
2193
- temp.atitle = temp.intro && temp.intro !== " " ? nrTobr(temp.intro) : "";
2194
- temp.guid = nextGuid(navid, temp.id, index);
2195
- }
2196
- function transformBagGift(navid, temp, index) {
2197
- const type = Number(temp.type);
2198
- const worth = Number(temp.worth);
2199
- const id = Number(temp.id);
2200
- const num = temp.num;
2201
- const price = temp.price;
2202
- const priority = Number(temp.priority_display) || 0;
2203
- temp.picIcon = "";
2204
- temp.unitText = "";
2205
- temp.unitText2 = "";
2206
- temp.isCrystal = false;
2207
- if (type === 24 && worth === 3) {
2208
- if (priority > 0) {
2209
- temp.picIcon = CRYSTAL_IMG;
2210
- temp.isCrystal = true;
2211
- temp.unitText = String(price / 10);
2212
- } else {
2213
- temp.unitText2 = "x" + num;
2214
- }
2215
- } else if (Number(navid) === TAB_CRYSTAL && type === 7) {
2216
- temp.picIcon = CRYSTAL_IMG;
2217
- temp.isCrystal = true;
2218
- temp.unitText = String(price / 10);
2219
- } else {
2220
- let giftNum = "";
2221
- if (type === 7 || Number(navid) === TAB_PACKAGE && priority > 0) {
2222
- giftNum = price / 10 + "钻";
2223
- } else {
2224
- giftNum = "x" + num;
2225
- }
2226
- if (Number(navid) === TAB_PACKAGE && priority > 0) {
2227
- temp.picIcon = ZHUANSHI_IMG;
2228
- temp.unitText = giftNum;
2229
- } else if (id === 155 || id === 156) {
2230
- temp.picIcon = ZHUANSHI_IMG;
2231
- temp.unitText = giftNum;
2232
- } else {
2233
- temp.unitText2 = giftNum;
2234
- }
2783
+ function openHelp(event, gift) {
2784
+ event && event.stopPropagation && event.stopPropagation();
2785
+ onOpenHelp && onOpenHelp(gift);
2235
2786
  }
2236
- if (temp.worth === void 0) {
2237
- temp.worth = 0;
2787
+ const click_handler = (giftItem, event) => openHelp(event, giftItem);
2788
+ const click_handler_12 = (giftItem) => choose(giftItem);
2789
+ $$self.$$set = ($$props2) => {
2790
+ if ("gifts" in $$props2) $$invalidate(0, gifts = $$props2.gifts);
2791
+ if ("selectGift" in $$props2) $$invalidate(1, selectGift = $$props2.selectGift);
2792
+ if ("emptyImg" in $$props2) $$invalidate(2, emptyImg = $$props2.emptyImg);
2793
+ if ("onClickItem" in $$props2) $$invalidate(6, onClickItem = $$props2.onClickItem);
2794
+ if ("onOpenHelp" in $$props2) $$invalidate(7, onOpenHelp = $$props2.onOpenHelp);
2795
+ };
2796
+ return [
2797
+ gifts,
2798
+ selectGift,
2799
+ emptyImg,
2800
+ animGuid,
2801
+ choose,
2802
+ openHelp,
2803
+ onClickItem,
2804
+ onOpenHelp,
2805
+ click_handler,
2806
+ click_handler_12
2807
+ ];
2808
+ }
2809
+ class GiftGrid extends SvelteComponent {
2810
+ constructor(options2) {
2811
+ super();
2812
+ init(this, options2, instance$q, create_fragment$q, safe_not_equal, {
2813
+ gifts: 0,
2814
+ selectGift: 1,
2815
+ emptyImg: 2,
2816
+ onClickItem: 6,
2817
+ onOpenHelp: 7
2818
+ });
2238
2819
  }
2239
- temp.atitle = temp.intro && temp.intro !== " " ? nrTobr(temp.intro) : "";
2240
- temp.guid = nextGuid(navid, temp.id, index);
2241
2820
  }
2242
2821
  function create_if_block_1$j(ctx) {
2243
2822
  let p;
@@ -2315,7 +2894,7 @@ function create_if_block$m(ctx) {
2315
2894
  }
2316
2895
  };
2317
2896
  }
2318
- function create_fragment$q(ctx) {
2897
+ function create_fragment$p(ctx) {
2319
2898
  let div1;
2320
2899
  let div0;
2321
2900
  let p;
@@ -2411,7 +2990,7 @@ function create_fragment$q(ctx) {
2411
2990
  }
2412
2991
  };
2413
2992
  }
2414
- function instance$q($$self, $$props, $$invalidate) {
2993
+ function instance$p($$self, $$props, $$invalidate) {
2415
2994
  let diamondText;
2416
2995
  let crystalText;
2417
2996
  let moneyText;
@@ -2458,172 +3037,8 @@ function instance$q($$self, $$props, $$invalidate) {
2458
3037
  class GiftBalance extends SvelteComponent {
2459
3038
  constructor(options2) {
2460
3039
  super();
2461
- init(this, options2, instance$q, create_fragment$q, safe_not_equal, { diamondInfo: 5, showMoney: 6 });
2462
- }
2463
- }
2464
- function joinQuery(parts) {
2465
- return parts.filter((item) => item && item[1] !== void 0 && item[1] !== null).map(([key, value]) => key + "=" + value).join("&");
2466
- }
2467
- function appendQuery(url, params) {
2468
- let next = url || "";
2469
- Object.keys(params || {}).forEach((key) => {
2470
- const value = params[key];
2471
- if (value === void 0 || value === null) {
2472
- return;
2473
- }
2474
- const re = new RegExp("([?&])" + key + "=[^&]*");
2475
- if (re.test(next)) {
2476
- next = next.replace(re, "$1" + key + "=" + value);
2477
- } else {
2478
- next += (next.indexOf("?") >= 0 ? "&" : "?") + key + "=" + value;
2479
- }
2480
- });
2481
- return next;
2482
- }
2483
- function stripSlash(domain) {
2484
- return domain ? String(domain).replace(/\/$/, "") : "";
2485
- }
2486
- function guessApiDomain(prefix) {
2487
- const host = window.location.host || "";
2488
- const main = host.split(".").slice(-2).join(".") || "tuwan.com";
2489
- if (options.isChatTest) {
2490
- return "https://" + prefix + "-test." + main;
2491
- }
2492
- return "https://" + prefix + "." + main;
2493
- }
2494
- function resolveApiDomain(kind) {
2495
- const map = options.apiDomain || {};
2496
- const injected = map[kind];
2497
- if (injected) {
2498
- return stripSlash(injected);
2499
- }
2500
- if (kind === "papi" || kind === "yapi") {
2501
- return guessApiDomain(kind);
2502
- }
2503
- throw new Error("giftBarLib apiDomain." + kind + " is required");
2504
- }
2505
- function papi() {
2506
- return resolveApiDomain("papi");
2507
- }
2508
- function yapi() {
2509
- return resolveApiDomain("yapi");
2510
- }
2511
- function hasValue$2(value) {
2512
- return value !== void 0 && value !== null && value !== "";
2513
- }
2514
- function sceneParts$1(ctx) {
2515
- if (hasValue$2(ctx && ctx.group_id)) {
2516
- return [["group_id", ctx.group_id]];
2517
- }
2518
- return [["imuid", ctx && ctx.imuid]];
2519
- }
2520
- function openParts(giftId, num, paySure, ctx) {
2521
- return [
2522
- ["giftid", giftId],
2523
- ["num", num || 1],
2524
- ["pay_confirm", 1],
2525
- ["apiver", 1],
2526
- ["pay_sure", paySure || 0],
2527
- ["uids", ctx && ctx.selfUid],
2528
- ...sceneParts$1(ctx)
2529
- ];
2530
- }
2531
- function getRechargeUrl() {
2532
- return yapi() + "/activityapi/recharge";
2533
- }
2534
- function getLimitSettingsUrl() {
2535
- return "https://y" + (options.isChatTest ? "-test" : "") + ".tuwan.com/home/consume-check";
2536
- }
2537
- function giveUpConsumeLimitUrl() {
2538
- return yapi() + "/user/setGiftRemindSetting?format=jsonp";
2539
- }
2540
- function giftListsUrl(cid, navid) {
2541
- return papi() + "/Teacher/giftLists?format=jsonp&platform=0" + (hasValue$2(cid) ? "&cid=" + cid : "") + "&navid=" + navid + "&apiver=4";
2542
- }
2543
- function haveGiftUrl(cid, navid) {
2544
- return papi() + "/Teacher/haveGift?format=jsonp&mode=2" + (hasValue$2(cid) ? "&cid=" + cid : "") + "&navid=" + navid;
2545
- }
2546
- function getMoneyUrl() {
2547
- return papi() + "/Teacher/getMoney";
2548
- }
2549
- function diamondGiftMoreUrl(query) {
2550
- return papi() + "/Diamond/giftMore?" + query;
2551
- }
2552
- function giveGiftUrl(query) {
2553
- return papi() + "/Teacher/giveGift?" + query;
2554
- }
2555
- function giveGiftInfoUrl(cid, giftId) {
2556
- return yapi() + "/nobility/getGiveGiftInfo?cid=" + cid + "&id=" + giftId + "&freeCardTypeid=2&format=jsonp";
2557
- }
2558
- function treasureBuyUrl(query) {
2559
- return papi() + "/Treasure/buy?format=jsonp&" + query;
2560
- }
2561
- function blindBoxPayUrl(query) {
2562
- return papi() + "/treasure/blindBox?format=jsonp&" + query;
2563
- }
2564
- function blindBoxImgListUrl(giftId) {
2565
- return papi() + "/gift/blindBoxImgList?format=jsonp&gift_id=" + giftId;
2566
- }
2567
- function treasureGetInfoUrl(giftId) {
2568
- return papi() + "/TreasureV3/getInfo?giftid=" + giftId + "&apiver=1";
2569
- }
2570
- function treasureGetRecordUrl(giftId, page, step) {
2571
- return papi() + "/TreasureV3/getRecord?format=jsonp&giftid=" + giftId + "&page=" + page + "&step=" + (step || 10);
2572
- }
2573
- function treasureGoldUrl(giftId, cid, num, paySure, ctx) {
2574
- if (isImSource()) {
2575
- return papi() + "/TreasureV3/gold?" + joinQuery(openParts(giftId, num, paySure, ctx));
2576
- }
2577
- return papi() + "/TreasureV3/gold?giftid=" + giftId + "&cid=" + cid + "&num=" + (num || 1) + "&pay_confirm=1&pay_sure=" + (paySure || 0);
2578
- }
2579
- function treasureV3BuyUrl(giftId, cid, num, paySure, ctx) {
2580
- if (isImSource()) {
2581
- return papi() + "/TreasureV3/buy?" + joinQuery(openParts(giftId, num, paySure, ctx));
2582
- }
2583
- return papi() + "/TreasureV3/buy?giftid=" + giftId + "&cid=" + cid + "&num=" + (num || 1) + "&pay_confirm=1&pay_sure=" + (paySure || 0);
2584
- }
2585
- function modalBlindBoxPayUrl(giftId, cid, num, worth, isBuy, ctx) {
2586
- if (isImSource()) {
2587
- return papi() + "/treasure/blindBox?" + joinQuery([
2588
- ["anonymous", 0],
2589
- ["actid", 100],
2590
- ["platform", 0],
2591
- ["giftid", giftId],
2592
- ["num", num || 1],
2593
- ["pay_confirm", 1],
2594
- ["apiver", 1],
2595
- ["pay_sure", 0],
2596
- ["worth", worth || 0],
2597
- ["is_buy", isBuy || 0],
2598
- ["uids", ctx && ctx.selfUid],
2599
- ...sceneParts$1(ctx)
2600
- ]);
2601
- }
2602
- return papi() + "/treasure/blindBox?format=jsonp&giftid=" + giftId + "&cid=" + cid + "&num=" + (num || 1) + "&worth=" + (worth || 0) + "&is_buy=" + (isBuy || 0);
2603
- }
2604
- function diamondPrefixQuery(parts) {
2605
- return "anonymous=0&actid=" + (isImSource() ? 101 : 100) + "&platform=0&" + joinQuery(parts);
2606
- }
2607
- function boxPrefixQuery(parts) {
2608
- return "anonymous=0&actid=100&platform=0&" + joinQuery(parts);
2609
- }
2610
- function platformPrefixQuery(parts) {
2611
- return "platform=0&" + joinQuery(parts);
2612
- }
2613
- function getCrystalBlindBoxBaseUrl() {
2614
- if (options.isChatTest) {
2615
- return "https://act-test.tuwan.com/cdn/s1season-box.html";
2616
- }
2617
- const host = window.location.host || "";
2618
- const actHost = host.indexOf("diandiankaihei.com") > -1 ? "act.diandiankaihei.com" : "act.tuwan.com";
2619
- return "https://" + actHost + "/cdn/s1season-box.html";
2620
- }
2621
- function getCrystalBlindBoxUrl(cid, giftId, navid) {
2622
- const base = getCrystalBlindBoxBaseUrl();
2623
- if (isImSource()) {
2624
- return base + "?giftId=" + giftId + "&navid=" + navid;
3040
+ init(this, options2, instance$p, create_fragment$p, safe_not_equal, { diamondInfo: 5, showMoney: 6 });
2625
3041
  }
2626
- return base + "?cid=" + cid + "&giftId=" + giftId;
2627
3042
  }
2628
3043
  function clickOutside(nodeOrSelector, callback) {
2629
3044
  const handleClick = (event) => {
@@ -3294,7 +3709,7 @@ function create_if_block$l(ctx) {
3294
3709
  }
3295
3710
  };
3296
3711
  }
3297
- function create_fragment$p(ctx) {
3712
+ function create_fragment$o(ctx) {
3298
3713
  let div3;
3299
3714
  let div0;
3300
3715
  let span0;
@@ -3406,7 +3821,6 @@ function create_fragment$p(ctx) {
3406
3821
  ctx[3].countLocked;
3407
3822
  attr(div0, "class", div0_class_value = "giftbar-count " + /*ui*/
3408
3823
  (ctx[3].countLocked ? "is-locked" : ""));
3409
- set_style(div0, "margin-left", "10px");
3410
3824
  attr(div1, "class", "giftbar-btns");
3411
3825
  attr(div2, "class", "giftbar-recharge");
3412
3826
  attr(div3, "class", "giftbar-footer");
@@ -3584,7 +3998,7 @@ function create_fragment$p(ctx) {
3584
3998
  }
3585
3999
  };
3586
4000
  }
3587
- function instance$p($$self, $$props, $$invalidate) {
4001
+ function instance$o($$self, $$props, $$invalidate) {
3588
4002
  let buttons;
3589
4003
  let { diamondInfo = {} } = $$props;
3590
4004
  let { showMoney = false } = $$props;
@@ -3717,8 +4131,8 @@ class GiftFooter extends SvelteComponent {
3717
4131
  init(
3718
4132
  this,
3719
4133
  options2,
3720
- instance$p,
3721
- create_fragment$p,
4134
+ instance$o,
4135
+ create_fragment$o,
3722
4136
  safe_not_equal,
3723
4137
  {
3724
4138
  diamondInfo: 1,
@@ -4048,7 +4462,7 @@ function create_if_block_1$h(ctx) {
4048
4462
  }
4049
4463
  };
4050
4464
  }
4051
- function create_fragment$o(ctx) {
4465
+ function create_fragment$n(ctx) {
4052
4466
  let div;
4053
4467
  function select_block_type(ctx2, dirty) {
4054
4468
  if (
@@ -4104,7 +4518,7 @@ function create_fragment$o(ctx) {
4104
4518
  }
4105
4519
  };
4106
4520
  }
4107
- function instance$o($$self, $$props, $$invalidate) {
4521
+ function instance$n($$self, $$props, $$invalidate) {
4108
4522
  let view;
4109
4523
  let roseUrl;
4110
4524
  let { data = null } = $$props;
@@ -4126,7 +4540,7 @@ function instance$o($$self, $$props, $$invalidate) {
4126
4540
  class JingpaiNotice extends SvelteComponent {
4127
4541
  constructor(options2) {
4128
4542
  super();
4129
- init(this, options2, instance$o, create_fragment$o, safe_not_equal, { data: 2 });
4543
+ init(this, options2, instance$n, create_fragment$n, safe_not_equal, { data: 2 });
4130
4544
  }
4131
4545
  }
4132
4546
  const GIFT_BAR_EXTRA = {
@@ -4141,38 +4555,6 @@ function giftBarLog(tag, extra) {
4141
4555
  } catch (_e) {
4142
4556
  }
4143
4557
  }
4144
- const deferred = function() {
4145
- const defer = {};
4146
- defer.promise = new Promise((resolve, reject) => {
4147
- defer.resolve = resolve;
4148
- defer.reject = reject;
4149
- });
4150
- return defer;
4151
- };
4152
- function createModal(_Class, props = {}, target = document.body) {
4153
- const wrap = document.createElement("div");
4154
- wrap.setAttribute("data-modal-overlay", "");
4155
- wrap.setAttribute("data-giftbar-modal", "");
4156
- target.appendChild(wrap);
4157
- let modal = new _Class({ target: wrap, props: { closeModal, ...props } });
4158
- const defer = deferred();
4159
- function closeModal(err, result) {
4160
- try {
4161
- modal && modal.$destroy();
4162
- } finally {
4163
- modal = null;
4164
- if (wrap.parentNode) {
4165
- wrap.parentNode.removeChild(wrap);
4166
- }
4167
- }
4168
- if (err) {
4169
- defer.reject(err);
4170
- } else {
4171
- defer.resolve(result);
4172
- }
4173
- }
4174
- return { modal, closeModal, promise: defer.promise };
4175
- }
4176
4558
  function hasValue$1(value) {
4177
4559
  return value !== void 0 && value !== null && value !== "";
4178
4560
  }
@@ -4203,6 +4585,22 @@ function buildPayUrl({ gift, tabId, count, action, ctx, extra }) {
4203
4585
  const paySure = extra && extra.pay_sure !== void 0 ? extra.pay_sure : 0;
4204
4586
  const question = extra && extra.question || "";
4205
4587
  const open = extra && extra.open || 0;
4588
+ if (isRoomHallGiveGift(gift)) {
4589
+ return giveGiftUrl(
4590
+ platformPrefixQuery([
4591
+ ["giftid", giftId],
4592
+ ["teacherid", 0],
4593
+ ["is_whole_wheat", 0],
4594
+ ["num", count],
4595
+ ["cid", ctx.cid],
4596
+ ["worth", worth],
4597
+ ["question_gift", 0],
4598
+ ["question", ""],
4599
+ ["open", 0],
4600
+ ...extraParts(ctx, extra)
4601
+ ])
4602
+ );
4603
+ }
4206
4604
  if (isPackageTab(navid)) {
4207
4605
  if (type === 7) {
4208
4606
  if (isImSource()) {
@@ -4348,7 +4746,7 @@ function mustHaveRequest() {
4348
4746
  throw new Error("giftBarLib requires host request(url)");
4349
4747
  }
4350
4748
  }
4351
- function create_fragment$n(ctx) {
4749
+ function create_fragment$m(ctx) {
4352
4750
  let div3;
4353
4751
  let div2;
4354
4752
  let div0;
@@ -4470,7 +4868,7 @@ function create_fragment$n(ctx) {
4470
4868
  }
4471
4869
  const defaultMessageText = "今日消费已超过最大限额,确定是否继续打赏?";
4472
4870
  const giveUpConfirmMessage = "是否放弃首次充值限额设置";
4473
- function instance$n($$self, $$props, $$invalidate) {
4871
+ function instance$m($$self, $$props, $$invalidate) {
4474
4872
  let isLimitSettingsError;
4475
4873
  let messageText;
4476
4874
  let cancelBtnText;
@@ -4564,7 +4962,7 @@ function instance$n($$self, $$props, $$invalidate) {
4564
4962
  class ConsumeCheck extends SvelteComponent {
4565
4963
  constructor(options2) {
4566
4964
  super();
4567
- init(this, options2, instance$n, create_fragment$n, safe_not_equal, { closeModal: 5, res: 6, url: 7 });
4965
+ init(this, options2, instance$m, create_fragment$m, safe_not_equal, { closeModal: 5, res: 6, url: 7 });
4568
4966
  }
4569
4967
  }
4570
4968
  function showConsumeCheck({ res, url }) {
@@ -4864,7 +5262,7 @@ function create_each_block$7(ctx) {
4864
5262
  }
4865
5263
  };
4866
5264
  }
4867
- function create_fragment$m(ctx) {
5265
+ function create_fragment$l(ctx) {
4868
5266
  let div5;
4869
5267
  let div4;
4870
5268
  let div0;
@@ -5017,7 +5415,7 @@ function create_fragment$m(ctx) {
5017
5415
  }
5018
5416
  const click_handler_1 = () => {
5019
5417
  };
5020
- function instance$m($$self, $$props, $$invalidate) {
5418
+ function instance$l($$self, $$props, $$invalidate) {
5021
5419
  let btnText;
5022
5420
  let { closeModal } = $$props;
5023
5421
  let { gift } = $$props;
@@ -5115,7 +5513,7 @@ function instance$m($$self, $$props, $$invalidate) {
5115
5513
  class PardonCard extends SvelteComponent {
5116
5514
  constructor(options2) {
5117
5515
  super();
5118
- init(this, options2, instance$m, create_fragment$m, safe_not_equal, { closeModal: 9, gift: 10, cid: 11 });
5516
+ init(this, options2, instance$l, create_fragment$l, safe_not_equal, { closeModal: 9, gift: 10, cid: 11 });
5119
5517
  }
5120
5518
  }
5121
5519
  let opening = false;
@@ -5152,7 +5550,7 @@ function create_if_block_1$f(ctx) {
5152
5550
  /*title*/
5153
5551
  ctx[0]
5154
5552
  );
5155
- attr(div, "class", "giftbar-confirm-title svelte-qctpdt");
5553
+ attr(div, "class", "giftbar-confirm-title svelte-1bi4u90");
5156
5554
  },
5157
5555
  m(target, anchor) {
5158
5556
  insert(target, div, anchor);
@@ -5177,6 +5575,7 @@ function create_if_block$i(ctx) {
5177
5575
  let div;
5178
5576
  let i;
5179
5577
  let t0;
5578
+ let span;
5180
5579
  let t1;
5181
5580
  let mounted;
5182
5581
  let dispose;
@@ -5185,12 +5584,13 @@ function create_if_block$i(ctx) {
5185
5584
  div = element("div");
5186
5585
  i = element("i");
5187
5586
  t0 = space();
5587
+ span = element("span");
5188
5588
  t1 = text(
5189
5589
  /*checkboxText*/
5190
5590
  ctx[4]
5191
5591
  );
5192
- attr(i, "class", "svelte-qctpdt");
5193
- attr(div, "class", "giftbar-confirm-choice svelte-qctpdt");
5592
+ attr(i, "class", "svelte-1bi4u90");
5593
+ attr(div, "class", "giftbar-confirm-choice svelte-1bi4u90");
5194
5594
  attr(div, "role", "presentation");
5195
5595
  toggle_class(
5196
5596
  div,
@@ -5203,7 +5603,8 @@ function create_if_block$i(ctx) {
5203
5603
  insert(target, div, anchor);
5204
5604
  append(div, i);
5205
5605
  append(div, t0);
5206
- append(div, t1);
5606
+ append(div, span);
5607
+ append(span, t1);
5207
5608
  if (!mounted) {
5208
5609
  dispose = listen(div, "click", stop_propagation(
5209
5610
  /*click_handler_1*/
@@ -5238,7 +5639,7 @@ function create_if_block$i(ctx) {
5238
5639
  }
5239
5640
  };
5240
5641
  }
5241
- function create_fragment$l(ctx) {
5642
+ function create_fragment$k(ctx) {
5242
5643
  let div3;
5243
5644
  let div2;
5244
5645
  let t0;
@@ -5283,15 +5684,15 @@ function create_fragment$l(ctx) {
5283
5684
  );
5284
5685
  t5 = space();
5285
5686
  if (if_block1) if_block1.c();
5286
- attr(div0, "class", "giftbar-confirm-body svelte-qctpdt");
5687
+ attr(div0, "class", "giftbar-confirm-body svelte-1bi4u90");
5287
5688
  attr(button0, "type", "button");
5288
- attr(button0, "class", "giftbar-confirm-btn giftbar-confirm-cancel svelte-qctpdt");
5689
+ attr(button0, "class", "giftbar-confirm-btn giftbar-confirm-cancel svelte-1bi4u90");
5289
5690
  attr(button1, "type", "button");
5290
- attr(button1, "class", "giftbar-confirm-btn giftbar-confirm-ok svelte-qctpdt");
5291
- attr(div1, "class", "giftbar-confirm-footer svelte-qctpdt");
5292
- attr(div2, "class", "giftbar-confirm-dialog svelte-qctpdt");
5691
+ attr(button1, "class", "giftbar-confirm-btn giftbar-confirm-ok svelte-1bi4u90");
5692
+ attr(div1, "class", "giftbar-confirm-footer svelte-1bi4u90");
5693
+ attr(div2, "class", "giftbar-confirm-dialog svelte-1bi4u90");
5293
5694
  attr(div2, "role", "presentation");
5294
- attr(div3, "class", "giftbar-confirm-mask svelte-qctpdt");
5695
+ attr(div3, "class", "giftbar-confirm-mask svelte-1bi4u90");
5295
5696
  attr(div3, "role", "presentation");
5296
5697
  },
5297
5698
  m(target, anchor) {
@@ -5313,18 +5714,14 @@ function create_fragment$l(ctx) {
5313
5714
  if (if_block1) if_block1.m(div2, null);
5314
5715
  if (!mounted) {
5315
5716
  dispose = [
5316
- listen(
5317
- button0,
5318
- "click",
5717
+ listen(button0, "click", stop_propagation(
5319
5718
  /*onCancel*/
5320
5719
  ctx[6]
5321
- ),
5322
- listen(
5323
- button1,
5324
- "click",
5720
+ )),
5721
+ listen(button1, "click", stop_propagation(
5325
5722
  /*onConfirm*/
5326
5723
  ctx[7]
5327
- ),
5724
+ )),
5328
5725
  listen(div2, "click", stop_propagation(
5329
5726
  /*click_handler*/
5330
5727
  ctx[9]
@@ -5397,7 +5794,7 @@ function create_fragment$l(ctx) {
5397
5794
  }
5398
5795
  };
5399
5796
  }
5400
- function instance$l($$self, $$props, $$invalidate) {
5797
+ function instance$k($$self, $$props, $$invalidate) {
5401
5798
  let { closeModal } = $$props;
5402
5799
  let { title = "温馨提示" } = $$props;
5403
5800
  let { message = "" } = $$props;
@@ -5405,11 +5802,20 @@ function instance$l($$self, $$props, $$invalidate) {
5405
5802
  let { confirmText = "确认" } = $$props;
5406
5803
  let { checkboxText = "" } = $$props;
5407
5804
  let checked = false;
5805
+ function finish(ok) {
5806
+ const payload = { ok, checked };
5807
+ setTimeout(
5808
+ () => {
5809
+ closeModal && closeModal(null, payload);
5810
+ },
5811
+ 0
5812
+ );
5813
+ }
5408
5814
  function onCancel() {
5409
- closeModal && closeModal(null, { ok: false, checked });
5815
+ finish(false);
5410
5816
  }
5411
5817
  function onConfirm() {
5412
- closeModal && closeModal(null, { ok: true, checked });
5818
+ finish(true);
5413
5819
  }
5414
5820
  function click_handler(event) {
5415
5821
  bubble.call(this, $$self, event);
@@ -5440,7 +5846,7 @@ function instance$l($$self, $$props, $$invalidate) {
5440
5846
  class ConfirmDialog extends SvelteComponent {
5441
5847
  constructor(options2) {
5442
5848
  super();
5443
- init(this, options2, instance$l, create_fragment$l, safe_not_equal, {
5849
+ init(this, options2, instance$k, create_fragment$k, safe_not_equal, {
5444
5850
  closeModal: 8,
5445
5851
  title: 0,
5446
5852
  message: 1,
@@ -5475,6 +5881,15 @@ function pickError(response, meta) {
5475
5881
  if (!response) {
5476
5882
  return -99;
5477
5883
  }
5884
+ if (isRoomHallGiveGift(meta && meta.gift)) {
5885
+ if (Object.prototype.hasOwnProperty.call(response, "error")) {
5886
+ return response.error;
5887
+ }
5888
+ if (Object.prototype.hasOwnProperty.call(response, "code")) {
5889
+ return response.code;
5890
+ }
5891
+ return -99;
5892
+ }
5478
5893
  if (isPackageOrdinaryGift(meta) && Object.prototype.hasOwnProperty.call(response, "code")) {
5479
5894
  return response.code;
5480
5895
  }
@@ -5511,9 +5926,18 @@ async function requestPay(url, meta) {
5511
5926
  const response = await options.request(url);
5512
5927
  const error = pickError(response, meta);
5513
5928
  if (error === 0) {
5929
+ if (isRoomHallGiveGift(meta && meta.gift) && String(response.code) === "9" && response.error_msg) {
5930
+ alertMsg(response.error_msg);
5931
+ }
5514
5932
  notifyPaySuccess(meta, response, url);
5515
5933
  return response;
5516
5934
  }
5935
+ if (error === 9 && isRoomHallGiveGift(meta && meta.gift)) {
5936
+ if (response.error_msg) {
5937
+ alertMsg(response.error_msg);
5938
+ }
5939
+ return response;
5940
+ }
5517
5941
  if (error === 199) {
5518
5942
  return response;
5519
5943
  }
@@ -5546,6 +5970,13 @@ async function requestPay(url, meta) {
5546
5970
  checkboxText: row && row.remark || "今日不再提示"
5547
5971
  });
5548
5972
  if (choice.ok) {
5973
+ if (isRoomHallGiveGift(meta && meta.gift)) {
5974
+ const remind = choice.checked ? 2 : 1;
5975
+ return requestPay(appendQuery(url, { remind }), {
5976
+ ...meta,
5977
+ extra: { ...meta.extra || {}, remind }
5978
+ });
5979
+ }
5549
5980
  return requestPay(appendQuery(url, { pay_sure: choice.checked ? 2 : 1 }), {
5550
5981
  ...meta,
5551
5982
  extra: { ...meta.extra || {}, pay_sure: choice.checked ? 2 : 1 }
@@ -5568,7 +5999,7 @@ async function requestPay(url, meta) {
5568
5999
  return response;
5569
6000
  }
5570
6001
  if (error === -2) {
5571
- if (isPackageOrdinaryGift(meta)) {
6002
+ if (isPackageOrdinaryGift(meta) || isRoomHallGiveGift(meta && meta.gift)) {
5572
6003
  alertMsg(response.error_msg || "赠送失败");
5573
6004
  return response;
5574
6005
  }
@@ -5619,7 +6050,7 @@ async function payGiftAction({ gift, tabId, count, selectedUser, action, extra }
5619
6050
  options.onQuestionGift({ gift, tabId, count, selectedUser, ctx });
5620
6051
  return null;
5621
6052
  }
5622
- if (source !== "im" && action === "send" && selectedUser) {
6053
+ if (source !== "im" && action === "send" && selectedUser && !isRoomHallGiveGift(gift)) {
5623
6054
  if (Number(selectedUser.uid) === Number(ctx.selfUid) && !canSendToSelf(gift, tabId)) {
5624
6055
  alertMsg("自己不能送给自己礼物");
5625
6056
  return null;
@@ -5654,252 +6085,20 @@ async function payGiftAction({ gift, tabId, count, selectedUser, action, extra }
5654
6085
  }
5655
6086
  }
5656
6087
  }
6088
+ const payExtra = {
6089
+ ...extra || {},
6090
+ // 对标 onlySendGift:成功不发 giftall,公屏靠服务端
6091
+ ...isRoomHallGiveGift(gift) ? { skipPaySuccess: true } : {}
6092
+ };
5657
6093
  const url = buildPayUrl({
5658
6094
  gift,
5659
6095
  tabId,
5660
6096
  count,
5661
6097
  action,
5662
6098
  ctx,
5663
- extra: extra || {}
5664
- });
5665
- return requestPay(url, { gift, tabId, count, selectedUser, action, ctx, extra: extra || {} });
5666
- }
5667
- function create_fragment$k(ctx) {
5668
- let div1;
5669
- let div0;
5670
- let iframe;
5671
- let iframe_src_value;
5672
- let mounted;
5673
- let dispose;
5674
- return {
5675
- c() {
5676
- div1 = element("div");
5677
- div0 = element("div");
5678
- iframe = element("iframe");
5679
- attr(iframe, "title", "blind-box");
5680
- if (!src_url_equal(iframe.src, iframe_src_value = /*url*/
5681
- ctx[0])) attr(iframe, "src", iframe_src_value);
5682
- attr(
5683
- iframe,
5684
- "width",
5685
- /*width*/
5686
- ctx[1]
5687
- );
5688
- attr(
5689
- iframe,
5690
- "height",
5691
- /*height*/
5692
- ctx[2]
5693
- );
5694
- attr(iframe, "frameborder", "0");
5695
- attr(
5696
- iframe,
5697
- "allow",
5698
- /*iframeAllow*/
5699
- ctx[4]
5700
- );
5701
- attr(iframe, "class", "svelte-1ma5gxj");
5702
- attr(div0, "role", "presentation");
5703
- attr(div0, "class", "giftbar-iframe-wrap svelte-1ma5gxj");
5704
- set_style(
5705
- div0,
5706
- "width",
5707
- /*width*/
5708
- ctx[1] + "px"
5709
- );
5710
- set_style(
5711
- div0,
5712
- "height",
5713
- /*height*/
5714
- ctx[2] + "px"
5715
- );
5716
- attr(
5717
- div1,
5718
- "id",
5719
- /*iframeId*/
5720
- ctx[3]
5721
- );
5722
- attr(div1, "class", "giftbar-iframe-mask svelte-1ma5gxj");
5723
- attr(div1, "role", "presentation");
5724
- },
5725
- m(target, anchor) {
5726
- insert(target, div1, anchor);
5727
- append(div1, div0);
5728
- append(div0, iframe);
5729
- if (!mounted) {
5730
- dispose = [
5731
- listen(div0, "click", stop_propagation(
5732
- /*click_handler*/
5733
- ctx[8]
5734
- )),
5735
- listen(div1, "click", stop_propagation(
5736
- /*handleClose*/
5737
- ctx[5]
5738
- ))
5739
- ];
5740
- mounted = true;
5741
- }
5742
- },
5743
- p(ctx2, [dirty]) {
5744
- if (dirty & /*url*/
5745
- 1 && !src_url_equal(iframe.src, iframe_src_value = /*url*/
5746
- ctx2[0])) {
5747
- attr(iframe, "src", iframe_src_value);
5748
- }
5749
- if (dirty & /*width*/
5750
- 2) {
5751
- attr(
5752
- iframe,
5753
- "width",
5754
- /*width*/
5755
- ctx2[1]
5756
- );
5757
- }
5758
- if (dirty & /*height*/
5759
- 4) {
5760
- attr(
5761
- iframe,
5762
- "height",
5763
- /*height*/
5764
- ctx2[2]
5765
- );
5766
- }
5767
- if (dirty & /*iframeAllow*/
5768
- 16) {
5769
- attr(
5770
- iframe,
5771
- "allow",
5772
- /*iframeAllow*/
5773
- ctx2[4]
5774
- );
5775
- }
5776
- if (dirty & /*width*/
5777
- 2) {
5778
- set_style(
5779
- div0,
5780
- "width",
5781
- /*width*/
5782
- ctx2[1] + "px"
5783
- );
5784
- }
5785
- if (dirty & /*height*/
5786
- 4) {
5787
- set_style(
5788
- div0,
5789
- "height",
5790
- /*height*/
5791
- ctx2[2] + "px"
5792
- );
5793
- }
5794
- if (dirty & /*iframeId*/
5795
- 8) {
5796
- attr(
5797
- div1,
5798
- "id",
5799
- /*iframeId*/
5800
- ctx2[3]
5801
- );
5802
- }
5803
- },
5804
- i: noop,
5805
- o: noop,
5806
- d(detaching) {
5807
- if (detaching) {
5808
- detach(div1);
5809
- }
5810
- mounted = false;
5811
- run_all(dispose);
5812
- }
5813
- };
5814
- }
5815
- function instance$k($$self, $$props, $$invalidate) {
5816
- let iframeAllow;
5817
- let { closeModal } = $$props;
5818
- let { url = "" } = $$props;
5819
- let { width = 400 } = $$props;
5820
- let { height = 585 } = $$props;
5821
- let { onRefreshHaveGift = null } = $$props;
5822
- let { iframeId = "" } = $$props;
5823
- let closed = false;
5824
- function handleClose() {
5825
- if (closed) {
5826
- return;
5827
- }
5828
- closed = true;
5829
- onRefreshHaveGift && onRefreshHaveGift();
5830
- closeModal && closeModal(null, true);
5831
- }
5832
- function onMessage(event) {
5833
- const data = event.data || {};
5834
- if (data.closeIframe) {
5835
- if (data.id && iframeId && String(data.id) !== String(iframeId)) {
5836
- return;
5837
- }
5838
- handleClose();
5839
- return;
5840
- }
5841
- if (data.channel === "common_iframe" && data.type === "refreshHaveGift") {
5842
- onRefreshHaveGift && onRefreshHaveGift();
5843
- }
5844
- }
5845
- onMount(() => {
5846
- window.addEventListener("message", onMessage);
5847
- });
5848
- onDestroy(() => {
5849
- window.removeEventListener("message", onMessage);
6099
+ extra: payExtra
5850
6100
  });
5851
- function click_handler(event) {
5852
- bubble.call(this, $$self, event);
5853
- }
5854
- $$self.$$set = ($$props2) => {
5855
- if ("closeModal" in $$props2) $$invalidate(6, closeModal = $$props2.closeModal);
5856
- if ("url" in $$props2) $$invalidate(0, url = $$props2.url);
5857
- if ("width" in $$props2) $$invalidate(1, width = $$props2.width);
5858
- if ("height" in $$props2) $$invalidate(2, height = $$props2.height);
5859
- if ("onRefreshHaveGift" in $$props2) $$invalidate(7, onRefreshHaveGift = $$props2.onRefreshHaveGift);
5860
- if ("iframeId" in $$props2) $$invalidate(3, iframeId = $$props2.iframeId);
5861
- };
5862
- $$invalidate(4, iframeAllow = options.isChatTest ? "local-network-access 'src'" : void 0);
5863
- return [
5864
- url,
5865
- width,
5866
- height,
5867
- iframeId,
5868
- iframeAllow,
5869
- handleClose,
5870
- closeModal,
5871
- onRefreshHaveGift,
5872
- click_handler
5873
- ];
5874
- }
5875
- class IframeModal extends SvelteComponent {
5876
- constructor(options2) {
5877
- super();
5878
- init(this, options2, instance$k, create_fragment$k, safe_not_equal, {
5879
- closeModal: 6,
5880
- url: 0,
5881
- width: 1,
5882
- height: 2,
5883
- onRefreshHaveGift: 7,
5884
- iframeId: 3
5885
- });
5886
- }
5887
- }
5888
- function showIframeBlindBox({ cid, giftId, navid, onRefreshHaveGift }) {
5889
- const iframeId = "iframe_" + Date.now();
5890
- const base = getCrystalBlindBoxUrl(cid, giftId, navid);
5891
- const url = base + (base.indexOf("?") >= 0 ? "&" : "?") + "eleId=" + encodeURIComponent(iframeId);
5892
- return createModal(
5893
- IframeModal,
5894
- {
5895
- url,
5896
- iframeId,
5897
- width: 400,
5898
- height: 585,
5899
- onRefreshHaveGift
5900
- },
5901
- document.body
5902
- );
6101
+ return requestPay(url, { gift, tabId, count, selectedUser, action, ctx, extra: payExtra });
5903
6102
  }
5904
6103
  class SvgaPlayer {
5905
6104
  constructor() {
@@ -18903,7 +19102,11 @@ function create_if_block(ctx) {
18903
19102
  ),
18904
19103
  onClickItem: (
18905
19104
  /*chooseGift*/
18906
- ctx[18]
19105
+ ctx[19]
19106
+ ),
19107
+ onOpenHelp: (
19108
+ /*openGiftHelp*/
19109
+ ctx[20]
18907
19110
  )
18908
19111
  }
18909
19112
  });
@@ -18943,16 +19146,16 @@ function create_if_block(ctx) {
18943
19146
  ctx[12]
18944
19147
  ),
18945
19148
  onSelectUser: (
18946
- /*func*/
18947
- ctx[29]
19149
+ /*chooseUser*/
19150
+ ctx[18]
18948
19151
  ),
18949
19152
  onCountChange: (
18950
- /*func_1*/
18951
- ctx[30]
19153
+ /*func*/
19154
+ ctx[31]
18952
19155
  ),
18953
19156
  onAction: (
18954
19157
  /*handleAction*/
18955
- ctx[19]
19158
+ ctx[21]
18956
19159
  )
18957
19160
  }
18958
19161
  });
@@ -18995,7 +19198,7 @@ function create_if_block(ctx) {
18995
19198
  if (!mounted) {
18996
19199
  dispose = listen(div1, "click", stop_propagation(
18997
19200
  /*click_handler*/
18998
- ctx[28]
19201
+ ctx[30]
18999
19202
  ));
19000
19203
  mounted = true;
19001
19204
  }
@@ -19087,12 +19290,9 @@ function create_if_block(ctx) {
19087
19290
  if (dirty[0] & /*selectNum*/
19088
19291
  4096) giftfooter_changes.selectNum = /*selectNum*/
19089
19292
  ctx2[12];
19090
- if (dirty[0] & /*selectUser*/
19091
- 256) giftfooter_changes.onSelectUser = /*func*/
19092
- ctx2[29];
19093
19293
  if (dirty[0] & /*selectNum*/
19094
- 4096) giftfooter_changes.onCountChange = /*func_1*/
19095
- ctx2[30];
19294
+ 4096) giftfooter_changes.onCountChange = /*func*/
19295
+ ctx2[31];
19096
19296
  giftfooter.$set(giftfooter_changes);
19097
19297
  if (!current || dirty[0] & /*isShow*/
19098
19298
  8) {
@@ -19339,7 +19539,7 @@ function instance($$self, $$props, $$invalidate) {
19339
19539
  }
19340
19540
  function applyUpdate(payload) {
19341
19541
  if (payload && payload.extras) {
19342
- $$invalidate(27, extras = payload.extras);
19542
+ $$invalidate(29, extras = payload.extras);
19343
19543
  }
19344
19544
  }
19345
19545
  onMount(() => {
@@ -19502,7 +19702,7 @@ function instance($$self, $$props, $$invalidate) {
19502
19702
  const response = await options.request(giftListsUrl(cid, 0));
19503
19703
  applyTabList(response);
19504
19704
  if (response && response.error === 0) {
19505
- $$invalidate(26, isSend = response.is_send);
19705
+ $$invalidate(28, isSend = response.is_send);
19506
19706
  applyBanner(response);
19507
19707
  }
19508
19708
  }
@@ -19521,7 +19721,7 @@ function instance($$self, $$props, $$invalidate) {
19521
19721
  const response = await options.request(giftListsUrl(cid, activeTabId));
19522
19722
  if (response && response.error === 0) {
19523
19723
  applyTabList(response);
19524
- $$invalidate(26, isSend = response.is_send);
19724
+ $$invalidate(28, isSend = response.is_send);
19525
19725
  const data = response.data || [];
19526
19726
  decorateShop(data);
19527
19727
  $$invalidate(6, giftList = data);
@@ -19578,6 +19778,12 @@ function instance($$self, $$props, $$invalidate) {
19578
19778
  updateBaoguo();
19579
19779
  }
19580
19780
  }
19781
+ function chooseUser(user) {
19782
+ $$invalidate(8, selectUser = user);
19783
+ if (typeof options.onSelectUser === "function") {
19784
+ options.onSelectUser(user);
19785
+ }
19786
+ }
19581
19787
  function chooseGift(giftItem) {
19582
19788
  resetCount();
19583
19789
  if (Number(giftItem && giftItem.type) === 37) {
@@ -19586,6 +19792,13 @@ function instance($$self, $$props, $$invalidate) {
19586
19792
  $$invalidate(1, selectGiftItem = giftItem);
19587
19793
  applySelectEffect(giftItem);
19588
19794
  }
19795
+ function openGiftHelp(gift) {
19796
+ const url = gift && gift.explain_url;
19797
+ if (!url) {
19798
+ return;
19799
+ }
19800
+ showExplainIframe(url);
19801
+ }
19589
19802
  async function openIframe(giftItem) {
19590
19803
  const ctx = await options.getPayContext({
19591
19804
  gift: giftItem,
@@ -19669,8 +19882,11 @@ function instance($$self, $$props, $$invalidate) {
19669
19882
  selectedUser: currentUser,
19670
19883
  action: cmd.payAction || "send"
19671
19884
  });
19672
- const ok = response && (response.error === 0 || response.code === 0);
19673
- if (ok && Number(selectGiftItem.type) === 24 && isPackageTab(activeTabId)) {
19885
+ const hallGive = isRoomHallGiveGift(selectGiftItem);
19886
+ const ok = response && (response.error === 0 || response.code === 0 || hallGive && (response.error === 9 || String(response.code) === "9"));
19887
+ if (ok && hallGive) {
19888
+ await updateView();
19889
+ } else if (ok && Number(selectGiftItem.type) === 24 && isPackageTab(activeTabId)) {
19674
19890
  setTimeout(() => getBaoguo(true), 1500);
19675
19891
  } else if (isPackageTab(activeTabId)) {
19676
19892
  getBaoguo(true);
@@ -19686,11 +19902,10 @@ function instance($$self, $$props, $$invalidate) {
19686
19902
  function click_handler(event) {
19687
19903
  bubble.call(this, $$self, event);
19688
19904
  }
19689
- const func = (user) => $$invalidate(8, selectUser = user);
19690
- const func_1 = (num) => $$invalidate(12, selectNum = num);
19905
+ const func = (num) => $$invalidate(12, selectNum = num);
19691
19906
  $$self.$$.update = () => {
19692
19907
  if ($$self.$$.dirty[0] & /*selectGiftItem, activeTabId, isSend*/
19693
- 67108867) {
19908
+ 268435459) {
19694
19909
  $$invalidate(2, ui = getSelectUiState(selectGiftItem, activeTabId, isSend));
19695
19910
  }
19696
19911
  if ($$self.$$.dirty[0] & /*selectGiftItem, activeTabId*/
@@ -19702,7 +19917,7 @@ function instance($$self, $$props, $$invalidate) {
19702
19917
  $$invalidate(15, emptyImg = isPackageTab(activeTabId) ? getEmptyBagImg() : "");
19703
19918
  }
19704
19919
  if ($$self.$$.dirty[0] & /*extras*/
19705
- 134217728) {
19920
+ 536870912) {
19706
19921
  $$invalidate(14, jingpai = extras[GIFT_BAR_EXTRA.JINGPAI]);
19707
19922
  }
19708
19923
  if ($$self.$$.dirty[0] & /*ui*/
@@ -19731,7 +19946,9 @@ function instance($$self, $$props, $$invalidate) {
19731
19946
  emptyImg,
19732
19947
  tip,
19733
19948
  switchTab,
19949
+ chooseUser,
19734
19950
  chooseGift,
19951
+ openGiftHelp,
19735
19952
  handleAction,
19736
19953
  show,
19737
19954
  hide,
@@ -19742,8 +19959,7 @@ function instance($$self, $$props, $$invalidate) {
19742
19959
  isSend,
19743
19960
  extras,
19744
19961
  click_handler,
19745
- func,
19746
- func_1
19962
+ func
19747
19963
  ];
19748
19964
  }
19749
19965
  class GiftPanel extends SvelteComponent {
@@ -19756,34 +19972,34 @@ class GiftPanel extends SvelteComponent {
19756
19972
  create_fragment,
19757
19973
  safe_not_equal,
19758
19974
  {
19759
- show: 20,
19760
- hide: 21,
19761
- reset: 22,
19762
- updateDiamond: 23,
19763
- updateBaoguo: 24,
19764
- isShowing: 25
19975
+ show: 22,
19976
+ hide: 23,
19977
+ reset: 24,
19978
+ updateDiamond: 25,
19979
+ updateBaoguo: 26,
19980
+ isShowing: 27
19765
19981
  },
19766
19982
  null,
19767
19983
  [-1, -1]
19768
19984
  );
19769
19985
  }
19770
19986
  get show() {
19771
- return this.$$.ctx[20];
19987
+ return this.$$.ctx[22];
19772
19988
  }
19773
19989
  get hide() {
19774
- return this.$$.ctx[21];
19990
+ return this.$$.ctx[23];
19775
19991
  }
19776
19992
  get reset() {
19777
- return this.$$.ctx[22];
19993
+ return this.$$.ctx[24];
19778
19994
  }
19779
19995
  get updateDiamond() {
19780
- return this.$$.ctx[23];
19996
+ return this.$$.ctx[25];
19781
19997
  }
19782
19998
  get updateBaoguo() {
19783
- return this.$$.ctx[24];
19999
+ return this.$$.ctx[26];
19784
20000
  }
19785
20001
  get isShowing() {
19786
- return this.$$.ctx[25];
20002
+ return this.$$.ctx[27];
19787
20003
  }
19788
20004
  }
19789
20005
  function merge(target, source) {