module.exports=[968438,e=>{"use strict";e.s(["BACKOFF_CONFIG",0,{base:2e3,max:3e5,maxLevel:15},"DEFAULT_ERROR_MESSAGES",0,{400:"Bad request",401:"Invalid API key provided",402:"Payment required",403:"You exceeded your current quota",404:"Model not found",406:"Model not supported",429:"Rate limit exceeded",500:"Internal server error",502:"Bad gateway - upstream provider error",503:"Service temporarily unavailable",504:"Gateway timeout"},"ERROR_RULES",0,[{text:"no credentials",cooldownMs:12e4},{text:"request not allowed",cooldownMs:5e3},{text:"improperly formed request",cooldownMs:12e4},{text:"rate limit",backoff:!0},{text:"too many requests",backoff:!0},{text:"quota exceeded",backoff:!0},{text:"capacity",backoff:!0},{text:"overloaded",backoff:!0},{status:401,cooldownMs:12e4},{status:402,cooldownMs:12e4},{status:403,cooldownMs:12e4},{status:404,cooldownMs:12e4},{status:429,backoff:!0}],"ERROR_TYPES",0,{400:{type:"invalid_request_error",code:"bad_request"},401:{type:"authentication_error",code:"invalid_api_key"},402:{type:"billing_error",code:"payment_required"},403:{type:"permission_error",code:"insufficient_quota"},404:{type:"invalid_request_error",code:"model_not_found"},406:{type:"invalid_request_error",code:"model_not_supported"},429:{type:"rate_limit_error",code:"rate_limit_exceeded"},500:{type:"server_error",code:"internal_server_error"},502:{type:"server_error",code:"bad_gateway"},503:{type:"server_error",code:"service_unavailable"},504:{type:"server_error",code:"gateway_timeout"}},"MAX_RATE_LIMIT_COOLDOWN_MS",0,18e5,"TRANSIENT_COOLDOWN_MS",0,3e4])},33253,e=>{"use strict";var r=e.i(968438);function t(e,t){let o;return new Response(JSON.stringify((o=r.ERROR_TYPES[e]||(e>=500?{type:"server_error",code:"internal_server_error"}:{type:"invalid_request_error",code:""}),{error:{message:t||r.DEFAULT_ERROR_MESSAGES[e]||"An error occurred",type:o.type,code:o.code}})),{status:e,headers:{"Content-Type":"application/json","Access-Control-Allow-Origin":"*"}})}async function o(e,t=null){let s="";try{s=await e.text()}catch{s=""}if(t&&"function"==typeof t.parseError)try{let o=t.parseError(e,s);if(o&&"object"==typeof o){let t=o.message||r.DEFAULT_ERROR_MESSAGES[e.status]||`Upstream error: ${e.status}`;return{statusCode:o.status||e.status,message:t,resetsAtMs:o.resetsAtMs}}}catch{}let a="";try{let e=JSON.parse(s);a=e.error?.message||e.message||e.error||s}catch{a=s}let n=("string"==typeof a?a:JSON.stringify(a))||r.DEFAULT_ERROR_MESSAGES[e.status]||`Upstream error: ${e.status}`;return{statusCode:e.status,message:n}}e.s(["createErrorResult",0,function(e,r,o){return{success:!1,status:e,error:r,resetsAtMs:o,response:t(e,r)}},"errorResponse",0,t,"formatProviderError",0,function(e,r,t,o){let s=o||e.code||"FETCH_FAILED",a=e.message||"Unknown error",n=e.cause?.code,i=e.cause?.message,c=n||i?` (cause: ${[n,i].filter(Boolean).join(": ")})`:"";return`[${s}]: ${a}${c}`},"parseUpstreamError",0,o,"unavailableResponse",0,function(e,r,t,o){let s=Math.max(Math.ceil((new Date(t).getTime()-Date.now())/1e3),1);return new Response(JSON.stringify({error:{message:`${r} (${o})`}}),{status:e,headers:{"Content-Type":"application/json","Retry-After":String(s)}})}])},574207,e=>{"use strict";var r=e.i(254799);function t(e=32){return r.default.randomBytes(e).toString("base64url")}function o(e){return r.default.createHash("sha256").update(e).digest("base64url")}function s(){return r.default.randomBytes(32).toString("base64url")}e.s(["generateCodeChallenge",0,o,"generateCodeVerifier",0,t,"generatePKCE",0,function(e=32){let r=t(e),a=o(r);return{codeVerifier:r,codeChallenge:a,state:s()}},"generateState",0,s])},472385,e=>{"use strict";let r="https://auth.x.ai",t="/oauth2/authorize",o="/oauth2/token",s="/.well-known/openid-configuration",a="/callback",n={clientId:"b1a00492-073a-47ea-816f-4c329264a828",issuer:r,authEndpointPath:t,tokenEndpointPath:o,discoveryPath:s,authorizeUrl:`${r}${t}`,tokenUrl:`${r}${o}`,discoveryUrl:`${r}${s}`,scope:"openid profile email offline_access grok-cli:access api:access",apiBaseUrl:"https://api.x.ai/v1",redirectUri:`http://127.0.0.1:56121${a}`,loopbackPort:56121,callbackPath:a,pkceVerifierBytes:96,refreshLeadSeconds:300,userAgent:"grok-cli/kentutai",codeChallengeMethod:"S256"};e.s(["XAI_CONFIG",0,n,"XAI_PKCE_VERIFIER_BYTES",0,96])},323970,e=>{e.v(r=>Promise.all(["server/chunks/[externals]_fs_0eo4gmu._.js"].map(r=>e.l(r))).then(()=>r(522734)))},589793,e=>{e.v(e=>Promise.resolve().then(()=>e(814747)))},901259,e=>{e.v(r=>Promise.all(["server/chunks/[externals]_http2_0j-h654._.js"].map(r=>e.l(r))).then(()=>r(925328)))},62724,e=>{e.v(r=>Promise.all(["server/chunks/src_lib_localDb_04ymbk7.js"].map(r=>e.l(r))).then(()=>r(626753)))}];

//# sourceMappingURL=%5Broot-of-the-server%5D__05z0bgh._.js.map