"use strict";(()=>{var e={};e.id=1296,e.ids=[1296],e.modules={30517:e=>{e.exports=require("next/dist/compiled/next-server/app-route.runtime.prod.js")},6113:e=>{e.exports=require("crypto")},57147:e=>{e.exports=require("fs")},71017:e=>{e.exports=require("path")},81462:(e,t,r)=>{r.r(t),r.d(t,{headerHooks:()=>g,originalPathname:()=>m,patchFetch:()=>S,requestAsyncStorage:()=>c,routeModule:()=>p,serverHooks:()=>h,staticGenerationAsyncStorage:()=>d,staticGenerationBailout:()=>$});var s={};r.r(s),r.d(s,{POST:()=>l});var n=r(95419),a=r(69108),o=r(99678),i=r(78070),u=r(34844);async function l(e){if((0,u.Ts)())return i.Z.json({error:"Already installed"},{status:403});let{service:t,apiKey:r}=await e.json();if("openrouter"===t)try{let e=await fetch("https://openrouter.ai/api/v1/models",{headers:{Authorization:`Bearer ${r}`}});if(e.ok)return i.Z.json({success:!0,message:"OpenRouter API key is valid"});return i.Z.json({success:!1,error:`OpenRouter returned ${e.status}`})}catch(e){return i.Z.json({success:!1,error:e.message})}if("unsplash"===t)try{let e=await fetch(`https://api.unsplash.com/search/photos?query=test&per_page=1&client_id=${r}`);if(e.ok)return i.Z.json({success:!0,message:"Unsplash key is valid"});return i.Z.json({success:!1,error:`Unsplash returned ${e.status}`})}catch(e){return i.Z.json({success:!1,error:e.message})}return i.Z.json({error:"Unknown service"},{status:400})}let p=new n.AppRouteRouteModule({definition:{kind:a.x.APP_ROUTE,page:"/api/install/test-api/route",pathname:"/api/install/test-api",filename:"route",bundlePath:"app/api/install/test-api/route"},resolvedPagePath:"C:\\test2\\pagecraft-ai\\src\\app\\api\\install\\test-api\\route.ts",nextConfigOutput:"standalone",userland:s}),{requestAsyncStorage:c,staticGenerationAsyncStorage:d,serverHooks:h,headerHooks:g,staticGenerationBailout:$}=p,m="/api/install/test-api/route";function S(){return(0,o.patchFetch)({serverHooks:h,staticGenerationAsyncStorage:d})}},34844:(e,t,r)=>{r.d(t,{Eg:()=>m,KK:()=>h,Ts:()=>d,gR:()=>S,r_:()=>g,yg:()=>$});var s=r(57147),n=r.n(s),a=r(71017),o=r.n(a),i=r(6113),u=r.n(i);let l=process.cwd(),p=o().join(l,"install.lock"),c=o().join(l,".env");function d(){return n().existsSync(p)}function h(){return u().randomBytes(32).toString("base64")}function g(e){let{type:t,host:r,port:s,database:n,username:a,password:o,ssl:i}=e,u=encodeURIComponent(o);return"postgresql"===t?`postgresql://${a}:${u}@${r}:${s}/${n}${i?"?sslmode=require":""}`:`mysql://${a}:${u}@${r}:${s}/${n}${i?"?ssl=true":""}`}function $(e){let t=`# Generated by PageCraft AI Installer
# ${new Date().toISOString()}

# Database
DATABASE_URL="${e.databaseUrl}"

# NextAuth
NEXTAUTH_SECRET="${e.nextAuthSecret}"
NEXTAUTH_URL="${e.nextAuthUrl}"

# Site URL (SEO, sitemap, OG tags)
NEXT_PUBLIC_SITE_URL="${e.siteUrl}"

# OpenRouter AI
OPENROUTER_API_KEY="${e.openRouterApiKey}"

# Unsplash (optional)
UNSPLASH_ACCESS_KEY="${e.unsplashAccessKey}"

# Google OAuth (optional)
GOOGLE_CLIENT_ID="${e.googleClientId}"
GOOGLE_CLIENT_SECRET="${e.googleClientSecret}"
`;n().writeFileSync(c,t,{encoding:"utf-8"})}function m(){let e=JSON.stringify({installedAt:new Date().toISOString(),version:"1.0.0"});n().writeFileSync(p,e,{encoding:"utf-8"})}function S(e){let t=o().join(l,`prisma/schema.${e}.prisma`),r=o().join(l,"prisma/schema.prisma");n().copyFileSync(t,r)}}};var t=require("../../../../webpack-runtime.js");t.C(e);var r=e=>t(t.s=e),s=t.X(0,[1638,6206],()=>r(81462));module.exports=s})();