Files
appco_dist/.output/public/_nuxt/ErQpqvEb.js
T
2025-08-27 20:20:03 +03:30

2 lines
2.8 KiB
JavaScript

import{N as a,av as l,aw as p,H as u}from"./BAjARngS.js";const w=async(e=1,t=100)=>await l.post("/media/story",{page:e,limit:t}),_=async(e,t=1,i=100)=>await l.post(`/media/user-story/${e}`,{page:t,limit:i}),v=async(e,t=1,i=15)=>await l.post(`/media/user-posts/${e}`,{page:t,limit:i}),x=async(e,t)=>u().APP_TYPE==="single"?await l.post(`/media/store-posts/${e}`,t):await l.post("/media/store-posts",t),D=async(e,t)=>await l.post(`/media/user-highlight/${e}`,t),I=async(e,t=void 0)=>{let i=new Date(t);i=new Date(i.setDate(i.getDate()+1));const{data:o,error:g}=await a.from("media").insert({caption:"",is_story:!0,expires_at:i.toLocaleDateString("en-US")}).select().single();if(console.log("data ===>",o),console.log("error ===>",g),o.id)for(let n=0;n<e.length;n++){const{data:r,error:m}=await a.from("mediaitems").insert({media_type:f(e[n]),media_id:o.id,media_url:e[n]}).select().single();if(console.log("itemData ===>",r),console.log("erroritem ===>",m),!r.id)return!1}else if(g)return!1;return!0};function f(e){const t=e.split(".").pop().toLowerCase(),i=["jpg","jpeg","png","gif","bmp","webp"],o=["mp4","mkv","avi","mov","webm","flv"];return i.includes(t)?"image":o.includes(t)?"video":"unknown"}async function T(e,t){await a.from("storyviews").insert({user_id:e,media_id:t})}const d="story-seen",H=e=>{const t=localStorage.getItem(d);let i=[];t?.length&&(i=JSON.parse(t)),i.push(e),localStorage.setItem(d,JSON.stringify(i))},y=()=>{const e=localStorage.getItem(d);let t=[];return e?.length&&(t=JSON.parse(e)),t},b=e=>y().indexOf(e)>=0,L=()=>localStorage.setItem(d,JSON.stringify([]));async function O(e,t,i){return a.from("highlights").insert([{title:e,cover_media_url:i,user_id:t}]).select()}async function P(e,t,i){return p.fetch("highlights","update",{data:{title:t,cover_media_url:i},field:"id",value:e})}async function N(e,t){const{error:i}=await a.from("highlight_media").insert([{highlight_id:t,media_item_id:e,position:1}])}async function U(e,t){const i=e?.map((n,r)=>({media_item_id:n,highlight_id:t,position:r})),{data:o,error:g}=await a.from("highlight_media").insert(i);return o}async function A(e,t){const i=await p.fetch("highlight_media","select",{columns:"*",field:"highlight_id",value:t}),o=new Map(i?.map(s=>[s.media_item_id,s])),g=e.map((s,c)=>({media_item_id:s,highlight_id:t,position:c})),n=new Set(e),r=i.filter(s=>!n.has(s.media_item_id)),m=[],h=[];for(const s of g){const c=o.get(s.media_item_id);c?c.position!==s.position&&h.push({...s}):m.push(s)}if(r.length){const s=r.map(c=>c.id);await a.from("highlight_media").delete().in("id",s)}m.length&&await a.from("highlight_media").insert(m);for(const s of h)await a.from("highlight_media").update({position:s.position}).eq("highlight_id",t).eq("media_item_id",s.media_item_id);return!0}export{v as a,w as b,L as c,_ as d,N as e,D as f,x as g,I as h,b as i,O as j,U as k,P as l,A as m,H as s,T as u};