Files
appco_dist/.output/server/chunks/build/detail_message-DjFA2-8o.mjs
T
2025-07-27 10:51:22 +03:30

337 lines
13 KiB
JavaScript

import { defineComponent, ref, computed, unref, createVNode, mergeProps, Fragment, watch, useSSRContext } from 'vue';
import { ssrRenderComponent, ssrRenderAttrs, ssrRenderClass, ssrInterpolate, ssrRenderAttr, ssrRenderList } from 'vue/server-renderer';
import { t as truthProp, m as makeStringProp, n as numericProp, a as makeNumericProp, c as createNamespace, w as withInstall, b as addUnit, g as getSizeStyle } from './base-C_z4ndMf.mjs';
import { B as BasicIconOld } from './BasicIconOld-I4c2ShMu.mjs';
import { U as UserProfilePic } from './UserProfilePic-DXA233hi.mjs';
import { u as useRouter$1, a as useConfigStore, b as useUserStore, t as reactiveProjectName, a_ as markMessageAsRead, a$ as fetchChatMessages, s as supabase } from './server.mjs';
import { _ as _sfc_main$3 } from './BasicTextArea-Cj0DwXpZ.mjs';
import { _ as _export_sfc } from './_plugin-vue_export-helper-1tPrXgE0.mjs';
import './empty_user-BaUNCdgf.mjs';
import '../_/nitro.mjs';
import 'node:http';
import 'node:https';
import 'node:events';
import 'node:buffer';
import 'node:fs';
import 'node:url';
import 'consola';
import 'ipx';
import 'node:path';
import 'node:crypto';
import 'pinia';
import '@supabase/supabase-js';
import '@babel/runtime/helpers/esm/extends';
import '@babel/runtime/helpers/esm/objectSpread2';
import '@ant-design/colors';
import '@ctrl/tinycolor';
import 'stylis';
import 'vue-types';
import 'lodash-es';
import 'axios';
import '@ant-design/icons-vue';
import '../routes/renderer.mjs';
import 'vue-bundle-renderer/runtime';
import 'unhead/server';
import 'devalue';
import 'unhead/utils';
import 'unhead/plugins';
import './index--Q-kfs0Q.mjs';
import './FormItemContext-CDDW52IT.mjs';
import './statusUtils-C3ZNzkeD.mjs';
import './BaseInput-_gwhwanN.mjs';
import 'resize-observer-polyfill';
import './index-C1mihc8c.mjs';
import '../_/SearchOutlined.mjs';
import 'lodash-es/isPlainObject.js';
import './raf-ruCY1ktO.mjs';
const [name$3, bem$3] = createNamespace("skeleton-title");
const skeletonTitleProps = {
round: Boolean,
titleWidth: numericProp
};
var stdin_default$6 = defineComponent({
name: name$3,
props: skeletonTitleProps,
setup(props) {
return () => createVNode("h3", {
"class": bem$3([{
round: props.round
}]),
"style": {
width: addUnit(props.titleWidth)
}
}, null);
}
});
const SkeletonTitle = withInstall(stdin_default$6);
var stdin_default$5 = SkeletonTitle;
const [name$2, bem$2] = createNamespace("skeleton-avatar");
const skeletonAvatarProps = {
avatarSize: numericProp,
avatarShape: makeStringProp("round")
};
var stdin_default$4 = defineComponent({
name: name$2,
props: skeletonAvatarProps,
setup(props) {
return () => createVNode("div", {
"class": bem$2([props.avatarShape]),
"style": getSizeStyle(props.avatarSize)
}, null);
}
});
const SkeletonAvatar = withInstall(stdin_default$4);
var stdin_default$3 = SkeletonAvatar;
const DEFAULT_ROW_WIDTH = "100%";
const skeletonParagraphProps = {
round: Boolean,
rowWidth: {
type: numericProp,
default: DEFAULT_ROW_WIDTH
}
};
const [name$1, bem$1] = createNamespace("skeleton-paragraph");
var stdin_default$2 = defineComponent({
name: name$1,
props: skeletonParagraphProps,
setup(props) {
return () => createVNode("div", {
"class": bem$1([{
round: props.round
}]),
"style": {
width: props.rowWidth
}
}, null);
}
});
const SkeletonParagraph = withInstall(stdin_default$2);
var stdin_default$1 = SkeletonParagraph;
const [name, bem] = createNamespace("skeleton");
const DEFAULT_LAST_ROW_WIDTH = "60%";
const skeletonProps = {
row: makeNumericProp(0),
round: Boolean,
title: Boolean,
titleWidth: numericProp,
avatar: Boolean,
avatarSize: numericProp,
avatarShape: makeStringProp("round"),
loading: truthProp,
animate: truthProp,
rowWidth: {
type: [Number, String, Array],
default: DEFAULT_ROW_WIDTH
}
};
var stdin_default = defineComponent({
name,
inheritAttrs: false,
props: skeletonProps,
setup(props, {
slots,
attrs
}) {
const renderAvatar = () => {
if (props.avatar) {
return createVNode(stdin_default$3, {
"avatarShape": props.avatarShape,
"avatarSize": props.avatarSize
}, null);
}
};
const renderTitle = () => {
if (props.title) {
return createVNode(stdin_default$5, {
"round": props.round,
"titleWidth": props.titleWidth
}, null);
}
};
const getRowWidth = (index) => {
const {
rowWidth
} = props;
if (rowWidth === DEFAULT_ROW_WIDTH && index === +props.row - 1) {
return DEFAULT_LAST_ROW_WIDTH;
}
if (Array.isArray(rowWidth)) {
return rowWidth[index];
}
return rowWidth;
};
const renderRows = () => Array(+props.row).fill("").map((_, i) => createVNode(stdin_default$1, {
"key": i,
"round": props.round,
"rowWidth": addUnit(getRowWidth(i))
}, null));
const renderContents = () => {
if (slots.template) {
return slots.template();
}
return createVNode(Fragment, null, [renderAvatar(), createVNode("div", {
"class": bem("content")
}, [renderTitle(), renderRows()])]);
};
return () => {
var _a;
if (!props.loading) {
return (_a = slots.default) == null ? void 0 : _a.call(slots);
}
return createVNode("div", mergeProps({
"class": bem({
animate: props.animate,
round: props.round
})
}, attrs), [renderContents()]);
};
}
});
const _imports_0 = "data:image/svg+xml,%3csvg%20width='22'%20height='20'%20viewBox='0%200%2022%2020'%20fill='white'%20xmlns='http://www.w3.org/2000/svg'%3e%3cpath%20d='M21.0031%201H1.00311L8.50311%208.5M21.0031%201L10.5031%2018.5L8.50311%208.5M21.0031%201L8.50311%208.5'%20stroke='%23733af9'%20stroke-width='2'%20stroke-linejoin='round'/%3e%3c/svg%3e";
const _sfc_main$2 = /* @__PURE__ */ defineComponent({
__name: "Conversation",
__ssrInlineRender: true,
props: {
chatId: {}
},
setup(__props) {
useConfigStore();
const userStore = useUserStore();
ref(false);
const currentPage = ref(0);
const limit = ref(10);
const messages = ref([]);
const currentUser = computed(() => userStore.user);
const props = __props;
const formatTime = (isoTime) => {
const date = new Date(isoTime);
return date.toLocaleTimeString([], { hour: "2-digit", minute: "2-digit" });
};
const request = async () => {
if (props.chatId) {
const res = await fetchChatMessages(props.chatId, ++currentPage.value, limit.value);
console.log("res ===>", res);
messages.value = res;
}
};
const runChannel = () => {
supabase.channel("realtime:chat_messages").on(
"postgres_changes",
{ event: "INSERT", schema: "public", table: "chat_messages" },
(payload) => {
var _a;
if (((_a = payload.new) == null ? void 0 : _a.chat_id) == props.chatId)
messages.value.push(payload.new);
}
).subscribe();
};
watch(() => props.chatId, () => {
if (props.chatId) {
request();
runChannel();
markMessageAsRead(props.chatId, userStore.user.id);
}
}, { immediate: true });
return (_ctx, _push, _parent, _attrs) => {
_push(`<div${ssrRenderAttrs(mergeProps({ class: "chat-container" }, _attrs))} data-v-d14597e8><!--[-->`);
ssrRenderList(messages.value, (message) => {
_push(`<div class="${ssrRenderClass([{ "sent": message.sender_id === currentUser.value.id, "received": message.sender_id !== currentUser.value.id }, "message"])}" data-v-d14597e8><div class="message-bubble" data-v-d14597e8><p data-v-d14597e8>${ssrInterpolate(message.text)}</p><span class="time" data-v-d14597e8>${ssrInterpolate(formatTime(message.created_at))}</span></div></div>`);
});
_push(`<!--]--></div>`);
};
}
});
const _sfc_setup$2 = _sfc_main$2.setup;
_sfc_main$2.setup = (props, ctx) => {
const ssrContext = useSSRContext();
(ssrContext.modules || (ssrContext.modules = /* @__PURE__ */ new Set())).add("views/base/pages/direct/detail/components/Conversation.vue");
return _sfc_setup$2 ? _sfc_setup$2(props, ctx) : void 0;
};
const Conversation = /* @__PURE__ */ _export_sfc(_sfc_main$2, [["__scopeId", "data-v-d14597e8"]]);
const _sfc_main$1 = /* @__PURE__ */ defineComponent({
__name: "index",
__ssrInlineRender: true,
setup(__props) {
const router = useRouter$1();
const config = useConfigStore();
const userStore = useUserStore();
const message = ref("");
const userInfo = ref(void 0);
computed(() => {
var _a, _b, _c, _d;
return ((_b = (_a = config.sellerConfig) == null ? void 0 : _a.store) == null ? void 0 : _b.main) && userStore.user.id !== ((_d = (_c = config.sellerConfig) == null ? void 0 : _c.store) == null ? void 0 : _d.id);
});
const loading = ref(false);
ref(false);
const chatItem = ref(void 0);
return (_ctx, _push, _parent, _attrs) => {
var _a, _b, _c, _d, _e;
const _component_VanSkeleton = stdin_default;
_push(`<div${ssrRenderAttrs(_attrs)} data-v-026d121e><div class="${ssrRenderClass([unref(config).isNightStore ? "bg-black" : "bg-white", "fixed top-0 w-inherit right-0 left-0"])}" data-v-026d121e><div class="flex justify-between items-center w-full p4" data-v-026d121e><div class="flex items-center gap-5" data-v-026d121e>`);
_push(ssrRenderComponent(BasicIconOld, {
icon: unref(config).isRTL ? "vuesax-linear:arrow-right" : "vuesax-linear:arrow-left",
onClick: ($event) => unref(router).back()
}, null, _parent));
if ((_a = userInfo.value) == null ? void 0 : _a.id) {
_push(`<div class="flex gap-24px items-center" data-v-026d121e>`);
_push(ssrRenderComponent(UserProfilePic, {
width: "40",
src: (_b = userInfo.value) == null ? void 0 : _b.avatar,
justShowProfile: ""
}, null, _parent));
_push(`<div data-v-026d121e><div class="font-semibold flex items-center" data-v-026d121e>${ssrInterpolate((_c = userInfo.value) == null ? void 0 : _c.name)}</div><div class="flex font-200 text-xs items-center" data-v-026d121e>${ssrInterpolate((_d = userInfo.value) == null ? void 0 : _d.username)}</div></div></div>`);
} else {
_push(`<!---->`);
}
_push(`</div><div class="flex w-fit gap-4 h-1.3rem items-center" data-v-026d121e></div></div></div><div dir="ltr" class="h-96vh pt-8vh overflow-y-auto pb-20" data-v-026d121e>`);
if (loading.value) {
_push(ssrRenderComponent(_component_VanSkeleton, null, null, _parent));
} else {
_push(ssrRenderComponent(Conversation, {
chatId: (_e = chatItem.value) == null ? void 0 : _e.chat_id
}, null, _parent));
}
_push(`</div><div class="${ssrRenderClass([unref(config).isNightStore ? "bg-black" : "bg-white", "fixed bottom-0 w-inherit right-0 left-0 p-3"])}" data-v-026d121e><div class="${ssrRenderClass([unref(config).isNightStore ? "bg-gray-700" : "bg-gray-100", "flex items-center gap-5 rounded-full px-2"])}" data-v-026d121e>`);
_push(ssrRenderComponent(_sfc_main$3, {
value: message.value,
"onUpdate:value": ($event) => message.value = $event,
"place-holder": `${unref(config).useString("message")}...`,
class: "!rounded-full border-transparent !bg-transparent message-placeholder !py-3 flex-1",
rows: 1
}, null, _parent));
if (message.value === "") {
_push(ssrRenderComponent(BasicIconOld, { icon: "vuesax-linear:add-circle" }, null, _parent));
} else {
_push(`<div class="w-4rem h-2rem bg-#733af9 flex items-center rounded-full p-1 pt-2 text-white justify-center" data-v-026d121e><img${ssrRenderAttr("src", _imports_0)}${ssrRenderAttr("alt", unref(reactiveProjectName))} class="h-full rtl:-scale-x-100" data-v-026d121e></div>`);
}
_push(`</div></div></div>`);
};
}
});
const _sfc_setup$1 = _sfc_main$1.setup;
_sfc_main$1.setup = (props, ctx) => {
const ssrContext = useSSRContext();
(ssrContext.modules || (ssrContext.modules = /* @__PURE__ */ new Set())).add("views/base/pages/direct/detail/index.vue");
return _sfc_setup$1 ? _sfc_setup$1(props, ctx) : void 0;
};
const Index = /* @__PURE__ */ _export_sfc(_sfc_main$1, [["__scopeId", "data-v-026d121e"]]);
const _sfc_main = /* @__PURE__ */ defineComponent({
__name: "detail_message",
__ssrInlineRender: true,
setup(__props) {
return (_ctx, _push, _parent, _attrs) => {
_push(ssrRenderComponent(Index, _attrs, null, _parent));
};
}
});
const _sfc_setup = _sfc_main.setup;
_sfc_main.setup = (props, ctx) => {
const ssrContext = useSSRContext();
(ssrContext.modules || (ssrContext.modules = /* @__PURE__ */ new Set())).add("pages/message/detail_message.vue");
return _sfc_setup ? _sfc_setup(props, ctx) : void 0;
};
export { _sfc_main as default };
//# sourceMappingURL=detail_message-DjFA2-8o.mjs.map