"use strict";(()=>{var e={};e.id=50,e.ids=[50],e.modules={399:e=>{e.exports=require("next/dist/compiled/next-server/app-page.runtime.prod.js")},517:e=>{e.exports=require("next/dist/compiled/next-server/app-route.runtime.prod.js")},2048:e=>{e.exports=require("fs")},5315:e=>{e.exports=require("path")},3169:(e,t,r)=>{r.r(t),r.d(t,{originalPathname:()=>f,patchFetch:()=>w,requestAsyncStorage:()=>l,routeModule:()=>p,serverHooks:()=>m,staticGenerationAsyncStorage:()=>d});var i={};r.r(i),r.d(i,{POST:()=>c});var n=r(3278),s=r(5002),a=r(4877),o=r(1309),u=r(1610);async function c(e){try{let t=await e.json(),r=Array.isArray(t.productIds)?t.productIds:[];if(!r.length)return o.NextResponse.json({error:"S\xe9lection vide"},{status:400});let i=await (0,u.p5)({title:String(t.title||"S\xe9lection cadeaux").slice(0,120),intro:t.intro?String(t.intro).slice(0,500):void 0,productIds:r.slice(0,400),meta:t.meta??{}});return o.NextResponse.json({id:i.id})}catch(e){return o.NextResponse.json({error:"Requ\xeate invalide"},{status:400})}}let p=new n.AppRouteRouteModule({definition:{kind:s.x.APP_ROUTE,page:"/api/selections/route",pathname:"/api/selections",filename:"route",bundlePath:"app/api/selections/route"},resolvedPagePath:"C:\\Users\\ERP 07\\Documents\\AppliTK\\app\\api\\selections\\route.ts",nextConfigOutput:"standalone",userland:i}),{requestAsyncStorage:l,staticGenerationAsyncStorage:d,serverHooks:m}=p,f="/api/selections/route";function w(){return(0,a.patchFetch)({serverHooks:m,staticGenerationAsyncStorage:d})}},1610:(e,t,r)=>{r.d(t,{RG:()=>w,p5:()=>m,Mf:()=>f,n3:()=>y});var i=r(2048),n=r(5315),s=r.n(n);let a=require("crypto");var o=r.n(a);let u=s().join(process.cwd(),".data"),c=s().join(u,"selections"),p=s().join(u,"submissions");async function l(){await i.promises.mkdir(c,{recursive:!0}),await i.promises.mkdir(p,{recursive:!0})}function d(){return o().randomBytes(5).toString("hex")}async function m(e){await l();let t={...e,id:d(),createdAt:new Date().toISOString()};return await i.promises.writeFile(s().join(c,`${t.id}.json`),JSON.stringify(t,null,2)),t}async function f(e){try{let t=await i.promises.readFile(s().join(c,`${j(e)}.json`),"utf-8");return JSON.parse(t)}catch{return null}}async function w(e){await l();let t={...e,id:d(),createdAt:new Date().toISOString()};return await i.promises.writeFile(s().join(p,`${t.selectionId}__${t.id}.json`),JSON.stringify(t,null,2)),t}async function y(e){try{let t=(await i.promises.readdir(p)).filter(t=>t.startsWith(`${j(e)}__`));return(await Promise.all(t.map(async e=>JSON.parse(await i.promises.readFile(s().join(p,e),"utf-8"))))).sort((e,t)=>t.createdAt.localeCompare(e.createdAt))}catch{return[]}}function j(e){return e.replace(/[^a-zA-Z0-9_-]/g,"")}}};var t=require("../../../webpack-runtime.js");t.C(e);var r=e=>t(t.s=e),i=t.X(0,[787,833],()=>r(3169));module.exports=i})();