module.exports=[975409,634432,a=>{"use strict";var b=a.i(471506);function c(a){return a?{id:a.id,username:a.username,role:a.role,is_active:1===a.is_active||!0===a.is_active,is_approved:1===a.is_approved||!0===a.is_approved,created_at:a.created_at}:null}async function d(){return(await (0,b.getAdapter)()).all("SELECT * FROM users ORDER BY created_at ASC").map(c)}a.i(186274),a.i(815628),a.i(934678),a.i(595823),a.i(334696),a.i(489282),a.s(["listUsers",0,d],634432),a.i(108979);var e=a.i(427699);a.i(679652),a.g._pendingRequests||(a.g._pendingRequests={byModel:{},byAccount:{}}),a.g._lastErrorProvider||(a.g._lastErrorProvider={provider:"",ts:0}),a.g._statsEmitter||(a.g._statsEmitter=new e.EventEmitter,a.g._statsEmitter.setMaxListeners(50)),a.g._pendingTimers||(a.g._pendingTimers={}),a.g._recentRing||(a.g._recentRing={items:[],initialized:!1}),a.g._connectionMapCache||(a.g._connectionMapCache={map:{},ts:0}),a.g._pendingRequests,a.g._lastErrorProvider,a.g._pendingTimers,a.g._recentRing,a.g._connectionMapCache,a.g._statsEmitter;var f=a.i(638640);let g=null,h=0;async function i(){if(g&&Date.now()-h<5e3)return g;try{let{getSettings:b}=await a.A(904939),c=await b(),d="false"!==process.env.OBSERVABILITY_ENABLED;g={enabled:"boolean"==typeof c.enableObservability?c.enableObservability:d,maxRecords:c.observabilityMaxRecords||parseInt(process.env.OBSERVABILITY_MAX_RECORDS||String(200),10),batchSize:c.observabilityBatchSize||parseInt(process.env.OBSERVABILITY_BATCH_SIZE||String(20),10),flushIntervalMs:c.observabilityFlushIntervalMs||parseInt(process.env.OBSERVABILITY_FLUSH_INTERVAL_MS||String(5e3),10),maxJsonSize:1024*(c.observabilityMaxJsonSize||parseInt(process.env.OBSERVABILITY_MAX_JSON_SIZE||"5",10))}}catch{g={enabled:!1,maxRecords:200,batchSize:20,flushIntervalMs:5e3,maxJsonSize:5120}}return h=Date.now(),g}let j=[],k=null,l=!1;function m(a,b){let c=JSON.stringify(a||{});return c.length>b?{_truncated:!0,_originalSize:c.length,_preview:c.substring(0,200)}:a||{}}async function n(){if(!l&&0!==j.length){l=!0;try{for(;j.length>0;){let a=j.splice(0,j.length),c=await (0,b.getAdapter)(),d=await i();c.transaction(()=>{for(let b of a){b.id||(b.id=function(a){let b=new Date().toISOString(),c=Math.random().toString(36).substring(2,8),d=a?a.replace(/[^a-zA-Z0-9-]/g,"-"):"unknown";return`${b}-${c}-${d}`}(b.model)),b.timestamp||(b.timestamp=new Date().toISOString()),b.request?.headers&&(b.request.headers=function(a){if(!a||"object"!=typeof a)return{};let b=["authorization","x-api-key","cookie","token","api-key"],c={...a};for(let a of Object.keys(c))b.some(b=>a.toLowerCase().includes(b))&&delete c[a];return c}(b.request.headers));let a={id:b.id,provider:b.provider||null,model:b.model||null,connectionId:b.connectionId||null,timestamp:b.timestamp,status:b.status||null,latency:b.latency||{},tokens:b.tokens||{},request:m(b.request,d.maxJsonSize),providerRequest:m(b.providerRequest,d.maxJsonSize),providerResponse:m(b.providerResponse,d.maxJsonSize),response:m(b.response,d.maxJsonSize)};c.run("INSERT INTO requestDetails(id, timestamp, provider, model, connectionId, status, data) VALUES(?, ?, ?, ?, ?, ?, ?) ON CONFLICT(id) DO UPDATE SET timestamp = excluded.timestamp, provider = excluded.provider, model = excluded.model, connectionId = excluded.connectionId, status = excluded.status, data = excluded.data",[a.id,a.timestamp,a.provider,a.model,a.connectionId,a.status,(0,f.stringifyJson)(a)])}let b=c.get("SELECT COUNT(*) as c FROM requestDetails");b&&b.c>d.maxRecords&&c.run("DELETE FROM requestDetails WHERE id IN (SELECT id FROM requestDetails ORDER BY timestamp ASC LIMIT ?)",[b.c-d.maxRecords])})}}catch(a){console.error("[requestDetailsRepo] Batch write failed:",a)}finally{l=!1}}}let o=async()=>{k&&(clearTimeout(k),k=null),j.length>0&&await n()};process.off("beforeExit",o),process.off("SIGINT",o),process.off("SIGTERM",o),process.off("exit",o),process.on("beforeExit",o),process.on("SIGINT",o),process.on("SIGTERM",o),process.on("exit",o),a.s([],975409)}];

//# sourceMappingURL=src_lib_localDb_0.x9if6.js.map