import{logger as m}from"../../tools/notifiers/logger.js";import{reporter as f}from"../../tools/notifiers/reporter.js";import{enhanceContext as l}from"../../api-routes/helpers/enhance-context.js";import{KvService as u}from"../../persistence/kv/services/kv-service.js";import{envConfig as n}from"../../config/env-config.js";import{enhanceRequest as P}from"../../api-routes/helpers/enhance-request.js";async function _({route:r,ctx:t,staticData:p,serverPropsGetters:a,serverPropsUser:i,actions:s}){try{if(!a[r.fsPath]||!t)return;const e=a[r.fsPath];e||await f.panicOnBuild(`Invalid page props getter id: "${r.fsPath}" for route "${r.slug}"`);const o=async()=>u.getInstance({baseDbDir:s.serverOutDir,sqldRemoteDatabaseUrl:n.SQLD_REMOTE_DATABASE_URL,sqldRemoteDatabaseAuthToken:n.SQLD_REMOTE_DATABASE_AUTH_TOKEN}),g=l({honoCtx:t,ctx:{user:i,config:s.getConfig()},getKv:o}),c=await P(t);return await(await e()).default(p,c,g)}catch(e){const o=r.fsPath.replace(/\.(page\.tsx?|md)$/,".props.ts");return m.error(`Page prop getter error: ${e.message}`),{pagePropGetterError:{message:`${e.message||"An unknown error occurred"} in ${o}`,name:"ServerPropsGetterError",stack:e.stack}}}}export{_ as getServerPropsFromUserHandler};
