text: import{S as t,i as s,s as a,D as e,l as o,h as n,H as r,d as l,m as p,f as c,z as i,A as m,j as u,k as h,n as g,e as d,w as f,c as $,a as b,x as P,b as k,y as w,B as j}from"./client.2b63acc1.js";import{d as v,a as x}from"./_api.5f596b86.js";import"./showdown.20a62d9b.js";import{L}from"./ListPagination.1c38e272.js";import{P as _}from"./PostList.d51b054b.js";function N(t){return{c:g,l:g,m:g,p:g,i:g,o:g,d:g}}function y(t){let s,a,e,n;const r=new _({props:{posts:t[10],username:t[3]}}),u=new L({props:{articlesCount:t[2],articlesPerPage:t[1].posts_per_page,objectPath:"/blog/"+t[3]+"/posts",page:t[4]}});return{c(){s=d("div"),f(r.$$.fragment),a=o(),e=d("div"),f(u.$$.fragment),this.h()},l(t){s=$(t,"DIV",{class:!0});var o=b(s);P(r.$$.fragment,o),o.forEach(l),a=p(t),e=$(t,"DIV",{class:!0});var n=b(e);P(u.$$.fragment,n),n.forEach(l),this.h()},h(){k(s,"class","row"),k(e,"class","row")},m(t,o){c(t,s,o),w(r,s,null),c(t,a,o),c(t,e,o),w(u,e,null),n=!0},p(t,s){const a={};1&s&&(a.posts=t[10]),8&s&&(a.username=t[3]),r.$set(a);const e={};4&s&&(e.articlesCount=t[2]),2&s&&(e.articlesPerPage=t[1].posts_per_page),8&s&&(e.objectPath="/blog/"+t[3]+"/posts"),16&s&&(e.page=t[4]),u.$set(e)},i(t){n||(i(r.$$.fragment,t),i(u.$$.fragment,t),n=!0)},o(t){m(r.$$.fragment,t),m(u.$$.fragment,t),n=!1},d(t){t&&l(s),j(r),t&&l(a),t&&l(e),j(u)}}}function D(t){return{c:g,l:g,m:g,p:g,i:g,o:g,d:g}}function E(t){let s,a,u,h,g={ctx:t,current:null,token:null,pending:D,then:y,catch:N,value:10,blocks:[,,,]};return e(u=t[0],g),{c(){s=o(),a=n(),g.block.c(),this.h()},l(t){r('[data-svelte="svelte-10h7psl"]',document.head).forEach(l),s=p(t),a=n(),g.block.l(t),this.h()},h(){document.title="Blog"},m(t,e){c(t,s,e),c(t,a,e),g.block.m(t,g.anchor=e),g.mount=(()=>a.parentNode),g.anchor=a,h=!0},p(s,[a]){if(t=s,g.ctx=t,1&a&&u!==(u=t[0])&&e(u,g));else{const s=t.slice();s[10]=g.resolved,g.block.p(s,a)}},i(t){h||(i(g.block),h=!0)},o(t){for(let t=0;t<3;t+=1){const s=g.blocks[t];m(s)}h=!1},d(t){t&&l(s),t&&l(a),g.block.d(t),g.token=null,g=null}}}async function I({host:t,path:s,params:a,query:e}){console.log("params in posts index",JSON.stringify(a));let o=parseInt(e.page);o||this.redirect(302,`${a.theuser}/posts?page=1`);let n=await v(a.theuser);o>0&&o--,console.log(n.length);let r=n.length;const l=await x(a.theuser);let p=l.posts_per_page||5,c=o*p,i=o*p+p;return{path:s,posts:n.slice(c,i),totalPostsLength:r,metadata:l}}function q(t,s,a){let e,{posts:o=[]}=s,{metadata:n}=s,{totalPostsLength:r}=s,{path:l}=s;const{preloading:p,page:c,session:i}=u();h(t,c,t=>a(7,e=t)),console.log("in posts index",e.params);let{username:m=e.params.theuser}=s,{pageNum:g=e.query.page}=s;return t.$set=(t=>{"posts"in t&&a(0,o=t.posts),"metadata"in t&&a(1,n=t.metadata),"totalPostsLength"in t&&a(2,r=t.totalPostsLength),"path"in t&&a(6,l=t.path),"username"in t&&a(3,m=t.username),"pageNum"in t&&a(4,g=t.pageNum)}),[o,n,r,m,g,c,l]}export default class extends t{constructor(t){super(),s(this,t,q,E,a,{posts:0,metadata:1,totalPostsLength:2,path:6,username:3,pageNum:4})}}export{I as preload};
  