import { l as loadGray, _ as __nuxt_component_0 } from './gray-wOBznZcb.mjs'; import { u as useRouter$1, a as useConfigStore, m as useIntersectionObserver, e as loading, b as useUserStore } from './server.mjs'; import { defineComponent, ref, resolveDirective, mergeProps, unref, useSSRContext } from 'vue'; import { ssrRenderAttrs, ssrRenderList, ssrGetDirectiveProps, ssrInterpolate, ssrRenderAttr, ssrRenderStyle, ssrRenderComponent } from 'vue/server-renderer'; import { defineStore } from 'pinia'; import { g as getUserSaved } from './save-3yOnAiJS.mjs'; const useSavedPostStore = defineStore("saved", () => { const savedPosts = ref([]); const endPage = ref(false); useConfigStore(); const currentPage = ref(0); const limit = ref(12); const total = ref(0); const user = useUserStore(); async function loadPosts() { try { if (!endPage.value) { loading.value = true; const res = await getUserSaved(user.user?.id, ++currentPage.value, limit.value); if (res?.data?.length < limit.value) endPage.value = true; const products = res?.data.map((x) => x.products); savedPosts.value.push(...products ?? []); total.value = res?.count ?? 0; } } catch (e) { console.log(e); } finally { loading.value = false; } } function reset() { currentPage.value = 0; savedPosts.value = []; total.value = 0; endPage.value = false; } return { loadPosts, savedPosts, reset }; }); const _sfc_main = /* @__PURE__ */ defineComponent({ __name: "SavedList", __ssrInlineRender: true, setup(__props) { useRouter$1(); const config = useConfigStore(); const userSavedPost = useSavedPostStore(); const videoThumbnails = ref({}); const observer = ref(); useIntersectionObserver(observer, ([{ isIntersecting }]) => { if (isIntersecting) { setTimeout(() => { userSavedPost.loadPosts(); }, 100); } }); return (_ctx, _push, _parent, _attrs) => { const _component_SquarePostSkeleton = __nuxt_component_0; const _directive_lazy = resolveDirective("lazy"); let _temp0; _push(` 0 ? "" : "justify-center"] }, _attrs))}>`); if (!("loading" in _ctx ? _ctx.loading : unref(loading))) { _push(`
`); ssrRenderList(unref(userSavedPost).savedPosts, (post, i) => { _push(`
`); if (post.files?.length) { _push(``); if (post.files[0]?.type === "image") { _push(`${"textContent" in _temp0 ? ssrInterpolate(_temp0.textContent) : _temp0.innerHTML ?? ""}`); } else if (post.files[0]?.type === "video") { _push(`
`); } else { _push(``); } _push(``); } else { _push(``); } _push(`
`); }); _push(`
load
`); if ("loading" in _ctx ? _ctx.loading : unref(loading)) { _push(ssrRenderComponent(_component_SquarePostSkeleton, null, null, _parent)); } else { _push(``); } _push(``); } else { _push(``); } _push(``); }; } }); const _sfc_setup = _sfc_main.setup; _sfc_main.setup = (props, ctx) => { const ssrContext = useSSRContext(); (ssrContext.modules || (ssrContext.modules = /* @__PURE__ */ new Set())).add("views/base/pages/statisticsList/components/SavedList.vue"); return _sfc_setup ? _sfc_setup(props, ctx) : void 0; }; export { _sfc_main as _ };