import{H as t}from"./p-b06e2bef.js";import{d as e}from"./p-2f569553.js";const{state:s,reset:a}=e({posts:[],postsLoading:!1,createPostLoading:!1,postIdLoading:null}),o={state:s,reset:a};class n{constructor(){}static getInstance(){return n.instance||(n.instance=new n),n.instance}async getAllPosts(){o.state.postsLoading=!0;let e=await t.http.get("api/v1/Feed/GetAll");return e&&(o.state.posts=e.Data,o.state.postsLoading=!1),e}async createPost(e){o.state.createPostLoading=!0;let s=await t.http.post("api/v1/Feed/PostFeed",e);return s&&(o.state.posts=[s.Data,...o.state.posts],o.state.createPostLoading=!1),s}async createPostComment(e){o.state.postIdLoading=e.PostId;let s=await t.http.post("api/v1/Feed/Comment",e);return s&&(o.state.posts=o.state.posts.map((t=>t.Id==s.Data.ClassFeedPostId?Object.assign(Object.assign({},t),{Comments:[...t.Comments,s.Data]}):t)),o.state.postIdLoading=null),s}}export{n as F,o as f}