Files
appco_dist/.output/public/_nuxt/Dc3SYjr6.js
T

2 lines
2.7 KiB
JavaScript

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