module.exports=[254799,(e,t,r)=>{t.exports=e.x("crypto",()=>require("crypto"))},626369,e=>{"use strict";let t="https://openapi.qoder.sh",r="https://api3.qoder.sh",i=`${t}/api/v1/deviceToken/poll`,o=`${t}/api/v1/userinfo`,n=`${r}/algo/api/v2/service/pro/sse/agent_chat_generation?FetchKeys=llm_model_result&AgentId=agent_common`,a=`${n}&Encode=1`,s=`${r}/algo/api/v2/model/list`,l=`-----BEGIN PUBLIC KEY-----
MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQDA8iMH5c02LilrsERw9t6Pv5Nc
4k6Pz1EaDicBMpdpxKduSZu5OANqUq8er4GM95omAGIOPOh+Nx0spthYA2BqGz+l
6HRkPJ7S236FZz73In/KVuLnwI8JJ2CbuJap8kvheCCZpmAWpb/cPx/3Vr/J6I17
XcW+ML9FoCI6AOvOzwIDAQAB
-----END PUBLIC KEY-----`;e.s(["QODER_CHAT_URL_ENCODED",0,a,"QODER_CLIENT_TYPE",0,"5","QODER_DATA_POLICY",0,"disagree","QODER_DEVICE_TOKEN_URL",0,i,"QODER_IDE_VERSION",0,"1.0.0","QODER_LOGIN_URL",0,"https://qoder.com/device/selectAccounts","QODER_LOGIN_VERSION",0,"v2","QODER_MACHINE_OS",0,"x86_64_windows","QODER_MACHINE_TYPE",0,"5","QODER_MODEL_LIST_URL",0,s,"QODER_MODEL_MAP",0,{auto:"auto",ultimate:"ultimate",performance:"performance",efficient:"efficient",lite:"lite",qmodel:"qmodel",dmodel:"dmodel",dfmodel:"dfmodel",gm51model:"gm51model",kmodel:"kmodel",mmodel:"mmodel"},"QODER_RSA_PUBLIC_KEY",0,l,"QODER_USERINFO_URL",0,o])},941178,e=>{"use strict";var t=e.i(626369),r=e.i(254799),i=e.i(689960);function o(e){return e.toString("base64").replace(/=/g,"").replace(/\+/g,"-").replace(/\//g,"_")}async function n(e,t={}){let r=new AbortController,i=setTimeout(()=>r.abort("timeout"),15e3);try{return await fetch(e,{...t,signal:r.signal})}finally{clearTimeout(i)}}class a{generatePkcePair(){let e=o(r.default.randomBytes(32)),t=o(r.default.createHash("sha256").update(e).digest());return{verifier:e,challenge:t}}initiateDeviceFlow(){let{verifier:e,challenge:r}=this.generatePkcePair(),o=(0,i.v4)(),n=(0,i.v4)(),a=new URLSearchParams({challenge:r,challenge_method:"S256",machine_id:n,nonce:o});return{verificationUriComplete:`${t.QODER_LOGIN_URL}?${a.toString()}`,codeVerifier:e,nonce:o,machineId:n}}async pollDeviceToken({nonce:e,codeVerifier:r}){let i;if(!e||!r)throw Error("pollDeviceToken: missing nonce or code verifier");let o=`${t.QODER_DEVICE_TOKEN_URL}?nonce=${encodeURIComponent(e)}&verifier=${encodeURIComponent(r)}&challenge_method=S256`,s=await n(o,{method:"GET",headers:{Accept:"application/json","User-Agent":"Go-http-client/2.0"}});if(202===s.status||404===s.status)return{status:"pending"};let l=await s.text();if(!s.ok){let e=`Qoder device token poll failed: HTTP ${s.status}`;try{let t=JSON.parse(l);t.message&&(e=`Qoder device token poll failed: ${t.message}`)}catch{}throw Error(e)}try{i=JSON.parse(l)}catch(e){throw Error(`Qoder device token poll: invalid JSON response (${e.message})`)}if(!i.token)throw Error("Qoder device token poll returned 200 but no token");let c=a.parseExpiry(i.expires_at,i.expires_in);return{status:"ok",accessToken:i.token,refreshToken:i.refresh_token||"",userId:i.user_id||"",expireTime:c,rawResponse:i}}async fetchUserInfo(e){try{let r=await n(t.QODER_USERINFO_URL,{method:"GET",headers:{Authorization:`Bearer ${e}`,Accept:"application/json","User-Agent":"Go-http-client/2.0"}});if(!r.ok)return{name:"",email:""};let i=await r.json();return{name:(i.name||i.username||"").trim(),email:(i.email||"").trim(),organizationId:(i.organization_id||"").trim()}}catch{return{name:"",email:""}}}static parseExpiry(e,t){if("number"==typeof e&&Number.isFinite(e)&&e>0)return e;let r="string"==typeof e?e.trim():"";if(r){if(/^\d+$/.test(r)){let e=Number.parseInt(r,10);if(Number.isFinite(e)&&e>0)return e}let e=Date.parse(r);if(!Number.isNaN(e))return e}return"number"==typeof t&&Number.isFinite(t)&&t>=0?Date.now()+1e3*t:Date.now()+2592e6}}e.s(["QoderService",0,a])}];

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