import{s as e}from"./chunk-Bj-mKKzh.js";import{Q as t}from"./src-BOCweS1p.js";import"./app-server-manager-signals-Yn0WSnoY.js";import{n,t as r}from"./jsx-runtime-CiQ1k8xo.js";import"./marked.esm-BR-H6018.js";import{F as i,h as a,lt as o}from"./vscode-api-DjORcpSo.js";import{c as s,o as c}from"./lib-MoKmYgcO.js";import{f as l,m as u,u as d}from"./chunk-LFPYN7LY-PMGLV5Go.js";import"./persisted-signal-CweW-bgN.js";import"./rpc-CJwVeoy_.js";import"./statsig-BP9zNYqZ.js";import"./request-CBZ5m5yv.js";import"./app-server-manager-hooks-Ps3s58Nc.js";import"./invalidate-queries-and-broadcast-CivBKbpC.js";import"./thread-context-inputs-C9hcxtXy.js";import"./config-queries-Br8rhpJn.js";import"./selectable-remote-connections-signal-db9FavQq.js";import"./remote-connection-visibility-h0xR_JfY.js";import"./sidebar-signals-b2zJ93fs.js";import"./use-is-copilot-api-available-Cju6TzB2.js";import"./use-global-state-baOKTuK6.js";import"./use-auth-CI-WraL2.js";import"./apps-queries-D95oCTjw.js";import"./startCase-CrZakAL6.js";import"./experimental-features-queries-DhyNRplU.js";import{r as f}from"./toast-signal-ifUptee5.js";import"./setting-storage-CwKZnsvR.js";import"./reduced-motion-preference-Bd5_3c7y.js";import{t as p}from"./spinner-BAEL5-Nn.js";import"./codex-api-error-C0Z_xLe-.js";import{n as m,r as h,t as g}from"./app-connect-oauth-BbS4dGUT.js";var _=o(),v=e(n(),1),y=r();function b(){let e=(0,_.c)(17),n=i(a),r=s(),o=u(),b=l(),S=h(),{getPendingAppConnectForCallbackUrl:C}=m(),w=(0,v.useRef)(null),T;e[0]!==S||e[1]!==r||e[2]!==n?(T=e=>{let{appId:t,appName:i,fullRedirectUrl:a,shouldShowPendingToast:o,shouldShowSuccessToast:s}=e,l=x(t);o&&a!=null&&a.length>0&&n.get(f).info((0,y.jsx)(`span`,{className:`loading-shimmer-pure-text`,children:(0,y.jsx)(c,{id:`apps.appConnectOAuthCallbackPage.pending`,defaultMessage:`Finishing {connector} setup`,description:`Toast shown when an app OAuth callback has returned and Codex is finishing setup`,values:{connector:i??r.formatMessage({id:`apps.appConnectOAuthCallbackPage.fallbackAppName`,defaultMessage:`App`,description:`Fallback app name used in app connect callback pending toasts`})}})}),{duration:0,id:l}),S({fullRedirectUrl:a??``}).then(e=>{bb21:switch(e.kind){case`missing-callback-data`:n.get(f).danger((0,y.jsx)(c,{id:`apps.appConnectOAuthCallbackPage.missingData`,defaultMessage:`Missing OAuth callback data.`,description:`Toast shown when an app connection OAuth callback is missing the redirect URL`}),{id:l});break bb21;case`request-failed`:{let t=e.message??r.formatMessage({id:`apps.appConnectOAuthCallbackPage.requestFailed`,defaultMessage:`Failed to finish connecting app.`,description:`Toast shown when finishing an app connection OAuth callback fails`});n.get(f).danger(t,{id:l});break bb21}case`success`:if(!s)break bb21;n.get(f).success((0,y.jsx)(c,{id:`apps.appConnectOAuthCallbackPage.success`,defaultMessage:`{appName} is now connected.`,description:`Toast shown when an app connection OAuth callback succeeds`,values:{appName:e.appName}}),{id:l})}})},e[0]=S,e[1]=r,e[2]=n,e[3]=T):T=e[3];let E=(0,v.useEffectEvent)(T),D;e[4]!==C||e[5]!==b.key||e[6]!==b.state||e[7]!==o||e[8]!==E?(D=()=>{if(w.current===b.key)return;w.current=b.key;let e=g(b.state),n=e?.fullRedirectUrl?.trim(),r=n!=null&&n.length>0?C(n):null,i=r?.returnTo??e?.returnTo??`/skills`,a=r?.resumeTarget.kind===`plugin-install`;if(E({appId:r?.appId,appName:r?.appName,fullRedirectUrl:n??null,shouldShowPendingToast:!1,shouldShowSuccessToast:!a}),d(t,i)!=null){o(i,{replace:!0});return}switch(r?.resumeTarget.kind){case`plugin-install`:o(i,{replace:!0,state:{initialHostId:r.hostId,initialTab:`plugins`}});return;case`apps-tab`:case void 0:o(i,{replace:!0,state:{connectAppId:r?.appId,initialHostId:r?.hostId,initialTab:`apps`}});return}},e[4]=C,e[5]=b.key,e[6]=b.state,e[7]=o,e[8]=E,e[9]=D):D=e[9];let O;e[10]!==C||e[11]!==r||e[12]!==b.key||e[13]!==b.state||e[14]!==o?(O=[C,r,b.key,b.state,o],e[10]=C,e[11]=r,e[12]=b.key,e[13]=b.state,e[14]=o,e[15]=O):O=e[15],(0,v.useEffect)(D,O);let k;return e[16]===Symbol.for(`react.memo_cache_sentinel`)?(k=(0,y.jsx)(`div`,{className:`flex h-full w-full items-center justify-center`,children:(0,y.jsx)(p,{className:`icon-sm`})}),e[16]=k):k=e[16],k}function x(e){return e==null?`app-connect-oauth-callback`:`app-connect-oauth-callback-${e}`}export{b as AppConnectOAuthCallbackPage};
//# sourceMappingURL=app-connect-oauth-callback-page-C085gAqM.js.map