Files
appco_dist/.output/public/_nuxt/DmhN7VA8.js
T
2025-08-24 13:00:31 +03:30

2 lines
5.1 KiB
JavaScript

import{d as Z,u as ee,H as te,K as ae,r as o,k as le,o as L,ap as se,F as B,z as p,D as E,A as a,aa as P,y as C,U as N,C as _,I as l,B as S,an as T,ar as A,aF as oe,bN as ie,ab as re,a5 as z,a6 as O,a7 as ne,bR as ue,bQ as ce,V as f,aL as de,bk as ve,bx as pe}from"./BYv1load.js";import{B as V}from"./D-ODqOh1.js";import{e as k}from"./DWEdiVkG.js";import{P as fe}from"./DTWNj_nu.js";import{g as me}from"./DW1VPVRq.js";import{l as ge,m as _e,d as he}from"./TddqdJQ4.js";import"./DyP0SJIC.js";import"./BSKJtx9z.js";import{S as ye}from"./VkUzHMTo.js";import"./DlAUqK2U.js";import"./120Hvi-x.js";import"./lbmh2w_Q.js";import"./BdncHQdI.js";import"./CSuAA5jZ.js";import"./866GWx42.js";import"./DyrRsFZC.js";import"./DpM3tgat.js";import"./B5LCnhpw.js";import"./BN-v4Lke.js";import"./11yttv_H.js";const xe={class:"w-full"},we={class:"flex w-full p-4 gap-8 justify-between items-center"},be={class:"flex gap-4 items-center"},Ce={class:"font-semibold text-lg"},Se={class:"flex flex-col items-center"},ke={class:"circle_highlight_edit"},Fe=["alt"],Re={class:"title_edit_highlight mx4 mt2"},Ue={class:"text-xs text-gray-4"},Be={key:0,class:"flex items-center h-90vh relative"},Ee={class:"w-full"},Pe={class:"flex justify-center absolute bottom-20 w-inherit w-full overflow-x-auto"},Ae=["onClick","alt"],He={class:"h-65vh w-full pb-10 overflow-y-auto grid grid-cols-3 gap-2px"},tt=Z({__name:"index",setup(Ie){const F=ee(),c=te(),{user:M}=ae(),n=o(!1),H=o("stories"),d=o(),m=o(),R=o(!0),i=o([]),h=o([]),I=o(null),U=o(!1),y=o(),j=o(),D=le(()=>F.currentRoute.value.params.id);function $(){I.value?.click()}function q(t,e){const s=t.split(","),u=s[0].match(/:(.*?);/)[1],v=atob(s[1]);let g=v.length;const w=new Uint8Array(g);for(;g--;)w[g]=v.charCodeAt(g);return new File([w],e,{type:u})}async function G(){if(n.value)j.value.crop(),n.value=!1,U.value=!0;else try{f.value=!0;let t;if(U.value){const s=q(m.value,"cover.jpg"),{data:u,error:v}=await ve(s,"stories");if(t=u?.fullPath,v)throw v}else t=m.value;console.log(t,"|",y.value,"|",i.value);const e=await ge(D.value,y.value,t);console.log(e.length>0),e.length>0&&await _e(i.value,e[0]?.id),F.back()}catch(t){console.log(t)}finally{f.value=!1}}function Q(t){d.value=h.value?.find(e=>e.id===i.value[t])?.media_url,R.value=!0}function J(t){m.value=t}function W(t){const e=t.target.files?.[0];if(e){const s=new FileReader;s.onload=u=>{d.value=u.target?.result,console.log(u.target.result)},s.readAsDataURL(e),R.value=!1}}async function X(){try{f.value=!0;const t=(await me(D.value))[0],e=t?.highlight_media?.flatMap(s=>s.mediaitems);i.value=e?.map(s=>s.id),d.value=e[0].media_url,m.value=t.cover_media_url,y.value=t.title}catch(t){console.log(t)}finally{f.value=!1}}const Y=async()=>{try{f.value=!0;const t=await he(M?.user_id);h.value=t?.flatMap(e=>e?.mediaitems)}catch{pe.error("error in fetching stories")}finally{f.value=!1}};return L(X),L(Y),(t,e)=>{const s=oe,u=ie,v=ce,g=ue,w=de,K=se("lazy");return p(),B(w,{spinning:l(f)},{default:E(()=>[a("div",xe,[a("div",we,[a("div",be,[_(V,{icon:l(c).isRTL?"vuesax-linear:arrow-right":"vuesax-linear:arrow-left",onClick:e[0]||(e[0]=r=>n.value?n.value=!1:l(F).back())},null,8,["icon"]),a("div",Ce,S(l(c).useString(n.value?"editCover":"edit")),1)]),a("div",{class:"text-primary text-sm fw-bold",onClick:G},S(l(c).useString("done")),1)]),P(a("div",null,[a("div",Se,[a("div",ke,[P(a("img",{class:"",alt:l(T)},null,8,Fe),[[K,{src:U.value?m.value:l(A)(m.value),loading:l(k),error:l(k)}]]),e[5]||(e[5]=a("svg",{viewBox:"0 0 100 100"},[a("circle",{cx:"50",cy:"50",r:"45"})],-1))]),a("div",{class:"text-primary text-xs mt1",onClick:e[1]||(e[1]=r=>n.value=!0)},S(l(c).useString("editCover")),1)]),a("div",Re,[a("div",Ue,S(l(c).useString("title")),1),_(s,{placeholder:l(c).useString("title"),class:"border-none focus:border-none",value:y.value,"onUpdate:value":e[2]||(e[2]=r=>y.value=r)},null,8,["placeholder","value"]),_(u,{class:"my0 px2"})])],512),[[re,!n.value]]),n.value?(p(),C("div",Be,[a("div",Ee,[d.value?(p(),B(fe,{key:0,ref_key:"cropper",ref:j,class:"h-90vh absolute top-0 w-inherit highlightCover",onOnCropped:J,src:R.value?l(A)(d.value):d.value},null,8,["src"])):N("",!0),a("div",Pe,[(p(!0),C(z,null,O(i.value,(r,x)=>P((p(),C("img",{class:ne(["w-2.5rem h-2.5rem",d.value===h.value.find(b=>b.id===i.value[x])?.media_url?"border-1.5px border-solid border-gray-8 p2px":""]),onClick:b=>Q(x),alt:l(T)},null,10,Ae)),[[K,{src:l(A)(h.value?.find(b=>b.id===i.value[x])?.media_url??""),loading:l(k),error:l(k)}]])),256)),a("div",{class:"flex items-center justify-center w-2.7rem h-2.5rem",onClick:$},[_(V,{icon:"vuesax-linear:gallery"}),a("input",{type:"file",accept:"image/*",ref_key:"fileInputRef",ref:I,class:"hidden h-full w-full",onChange:W},null,544)])])])])):N("",!0)]),a("div",null,[_(g,{activeKey:H.value,"onUpdate:activeKey":e[4]||(e[4]=r=>H.value=r),centered:"",class:"instaTab"},{default:E(()=>[_(v,{class:"!w-full",key:"stories",tab:l(c).useString("stories")},{default:E(()=>[a("div",He,[(p(!0),C(z,null,O(h.value,r=>(p(),B(ye,{key:r.id,story:r,selectedStory:i.value,"onUpdate:selectedStory":e[3]||(e[3]=x=>i.value=x)},null,8,["story","selectedStory"]))),128))])]),_:1},8,["tab"])]),_:1},8,["activeKey"])])]),_:1},8,["spinning"])}}});export{tt as default};