"use strict";exports.id=8520,exports.ids=[8520],exports.modules={"./src/commands/auth-status-format.ts"(s,e,t){t.d(e,{$7:()=>o,Fg:()=>r,cq:()=>a});var n=t("../../../../var/folders/gy/wcfhjzc55d96bnvx1zv223lc0000gn/T/agent-cli-mac-macos-arm64-019f05f3-3295-4b3a-9ba3-f059e5af7ddc.hdp0NNww/pnpm-virtual-store/chalk@5.6.2/node_modules/chalk/source/index.js");function r(s){const{status:e,message:t,userInfo:r,loginUrl:a}=s;switch(e){case"starting":return"Starting login process...";case"in-progress":{const s=["Authenticating with Cursor..."];return t&&s.push(t),a&&s.push(n.Ay.dim(a)),s.join("\n")}case"success":{const s=(null==r?void 0:r.email)?`Logged in as ${r.email}`:(null==r?void 0:r.userId)?`Logged in as user id ${r.userId}`:"Login successful!",e=[`${n.Ay.green("✓")} ${s}`];return t&&e.push(t),e.join("\n")}case"error":return t?n.Ay.red(t):""}}function a(s){const{status:e,message:t}=s;switch(e){case"starting":return"Preparing to log out...";case"in-progress":return"Logging out...";case"success":{const s=[n.Ay.green("✓ Logout successful")];return t&&s.push(t),s.join("\n")}case"error":{const s=[n.Ay.red("✗ Logout failed")];return t&&s.push(n.Ay.red(t)),s.join("\n")}}}function o(s){const{status:e,message:t}=s;switch(e){case"starting":{const s=["MCP Login","Preparing login..."];return t&&s.push(t),s.join("\n")}case"in-progress":{const s=["Checking status..."];return t&&s.push(t),s.join("\n")}case"success":{const s=[n.Ay.green("✓ MCP login successful")];return t&&s.push(t),s.join("\n")}case"error":{const s=[n.Ay.red("✗ MCP login failed")];return t&&s.push(n.Ay.red(t)),s.join("\n")}}}},"./src/commands/login.ts"(s,e,t){t.r(e),t.d(e,{handleLogin:()=>l});var n=t("../cursor-config/dist/index.js"),r=t("../proto/dist/generated/aiserver/v1/dashboard_pb.js"),a=t("./src/console-io.ts"),o=t("./src/privacy.ts"),i=t("./src/statsig.ts"),c=t("./src/utils/open-browser.ts"),u=t("./src/commands/auth-status-format.ts");function l(s,e,t){return l=this,g=void 0,h=function*(){(0,a.OT)((0,u.Fg)({status:"starting"}));try{const l=new n.Pl,{metadata:g,loginUrl:d}=l.startLogin();if((0,c.g1)(d)){(0,a.OT)((0,u.Fg)({status:"in-progress",message:`Waiting for browser authentication...\nIf your browser didn't open, use this link:\n${d}`}));try{yield(0,c.ph)(d)}catch(s){}}else(0,a.OT)((0,u.Fg)({status:"in-progress",message:`Waiting for browser authentication...\nOpen a browser and navigate to this link: ${d}`}));const h=yield l.waitForResult(g);if(null==h?void 0:h.accessToken)try{let n;yield s.setAuthentication(h.accessToken,h.refreshToken),yield e.transform((s=>Object.assign(Object.assign({},s),{privacyCache:void 0}))),yield(0,i.yX)(),(0,o.H)({credentialManager:s,baseUrl:"https://api2.cursor.sh",configProvider:e});let c=!1;if(t)try{const a=yield t.getMe(new r.GetMeRequest({}));n=a.email;const o=e.get().channel,u=null==n?void 0:n.endsWith("@anysphere.co"),l=""!==a.authId?a.authId:void 0;yield e.transform((s=>{var e;return Object.assign(Object.assign(Object.assign({},s),{authInfo:{email:null!==(e=a.email)&&void 0!==e?e:"",displayName:[a.firstName,a.lastName].filter(Boolean).join(" "),teamId:a.teamId,teamName:a.teamName,userId:a.userId,authId:l}}),u&&"static"!==o&&"prod-stable-internal"!==o?{channel:"lab"}:{})})),(0,i.A3)(e,s,{endpoint:"https://api2.cursor.sh"}),u&&"lab"!==o&&"static"!==o&&"prod-stable-internal"!==o&&(c=!0)}catch(s){}(0,a.OT)((0,u.Fg)({status:"success",message:"Authentication tokens stored securely."+(c?" agent automatically configured to use nightly channel.":""),userInfo:n?{email:n}:void 0}))}catch(s){(0,a.p2)((0,u.Fg)({status:"error",message:"Failed to store authentication tokens. Please try again."}))}else(0,a.p2)((0,u.Fg)({status:"error",message:"Login failed or timed out. Please try again."})),process.exit(1)}catch(s){const e=s instanceof Error?s.message:"An unexpected error occurred";(0,a.p2)((0,u.Fg)({status:"error",message:`Login error: ${e}`})),process.exit(1)}process.exit(0)},new((d=void 0)||(d=Promise))((function(s,e){function t(s){try{r(h.next(s))}catch(s){e(s)}}function n(s){try{r(h.throw(s))}catch(s){e(s)}}function r(e){var r;e.done?s(e.value):(r=e.value,r instanceof d?r:new d((function(s){s(r)}))).then(t,n)}r((h=h.apply(l,g||[])).next())}));var l,g,d,h}}};