"use strict";(()=>{var e={};e.id=1235,e.ids=[1235],e.modules={85890:e=>{e.exports=require("better-sqlite3")},12408:e=>{e.exports=require("chokidar")},25606:e=>{e.exports=require("keytar")},20399:e=>{e.exports=require("next/dist/compiled/next-server/app-page.runtime.prod.js")},30517:e=>{e.exports=require("next/dist/compiled/next-server/app-route.runtime.prod.js")},78893:e=>{e.exports=require("buffer")},92048:e=>{e.exports=require("fs")},6005:e=>{e.exports=require("node:crypto")},87561:e=>{e.exports=require("node:fs")},93977:e=>{e.exports=require("node:fs/promises")},70612:e=>{e.exports=require("node:os")},49411:e=>{e.exports=require("node:path")},3965:(e,t,r)=>{r.r(t),r.d(t,{originalPathname:()=>N,patchFetch:()=>g,requestAsyncStorage:()=>v,routeModule:()=>q,serverHooks:()=>R,staticGenerationAsyncStorage:()=>b});var s={};r.r(s),r.d(s,{GET:()=>x,POST:()=>m,dynamic:()=>d});var i=r(7849),a=r(94966),n=r(79169),o=r(93977),u=r(70612),p=r(49411),c=r(1237),l=r(39708);let d="force-dynamic";async function f(e){let t=!1;try{t=(await (0,o.stat)(e)).isDirectory()}catch{t=!1}let r=null;if(t)try{r=(await (0,l.xw)(e)).topic.trim()||null}catch{r=null}return{path:e,topic:r,exists:t}}async function x(){let e=await (0,l.Eo)(),t=e.activeWiki??j(),[r,s]=await Promise.all([f(t),Promise.all(e.recentWikis.map(f))]);return c.NextResponse.json({active:r,recents:s})}async function m(e){let t;try{t=await e.json()}catch{return c.NextResponse.json({error:"expected JSON body"},{status:400})}switch(t.type){case"switch":return w(t);case"create":return h(t);case"remove":return y(t);default:return c.NextResponse.json({error:`unknown action: ${String(t.type)}`},{status:400})}}async function w(e){let t=k(e.path);if(!t)return c.NextResponse.json({error:"path is required and must be absolute"},{status:400});try{if(!(await (0,o.stat)(t)).isDirectory())return c.NextResponse.json({error:`not a directory: ${t}`},{status:400})}catch{return c.NextResponse.json({error:`path does not exist: ${t}. Use the Create action to make a new wiki here.`},{status:404})}return await (0,l.dY)(t),await (0,l.f7)(t),c.NextResponse.json({ok:!0,active:t})}async function h(e){let t=k(e.path);if(!t)return c.NextResponse.json({error:"path is required and must be absolute"},{status:400});let r="string"==typeof e.topic?e.topic.trim():"";if(!r)return c.NextResponse.json({error:"topic is required for a new wiki"},{status:400});if(await (0,l.dY)(t),e.templateId&&"blank"!==e.templateId&&l.K4.find(t=>t.id===e.templateId)){let s=(0,p.join)(t,l.vE.schema),i=(0,l.WN)(e.templateId).body.replace(/## Topic\n\n\([^)]*\)/,`## Topic

${r}`);await (0,o.writeFile)(s,i,"utf8")}let s=await (0,l.xw)(t);return await (0,l.FM)(t,{...l.eW,...s,topic:r}),await (0,l.f7)(t),c.NextResponse.json({ok:!0,active:t,topic:r,template:e.templateId??"blank"})}async function y(e){let t=k(e.path);if(!t)return c.NextResponse.json({error:"path is required and must be absolute"},{status:400});let r=await (0,l.pZ)(t);return c.NextResponse.json({ok:!0,active:r.activeWiki??j()})}function k(e){if("string"!=typeof e||0===e.length)return null;let t=e.startsWith("~")?(0,p.join)((0,u.homedir)(),e.slice(1).replace(/^[\\/]+/,"")):e;return(0,p.resolve)(t)}function j(){return(0,p.join)((0,u.homedir)(),"llm-wiki-default")}let q=new i.AppRouteRouteModule({definition:{kind:a.x.APP_ROUTE,page:"/api/wikis/route",pathname:"/api/wikis",filename:"route",bundlePath:"app/api/wikis/route"},resolvedPagePath:"/Users/ddsyasas/ProjectFiles/Dev Projects/Business dev/llm-wiki/apps/web/src/app/api/wikis/route.ts",nextConfigOutput:"standalone",userland:s}),{requestAsyncStorage:v,staticGenerationAsyncStorage:b,serverHooks:R}=q,N="/api/wikis/route";function g(){return(0,n.patchFetch)({serverHooks:R,staticGenerationAsyncStorage:b})}}};var t=require("../../../webpack-runtime.js");t.C(e);var r=e=>t(t.s=e),s=t.X(0,[6485,5444,9708],()=>r(3965));module.exports=s})();