import{s as e}from"./chunk-Bj-mKKzh.js";import"./app-server-manager-signals-Yn0WSnoY.js";import{n as t}from"./jsx-runtime-CiQ1k8xo.js";import{f as n,lt as r}from"./vscode-api-DjORcpSo.js";import{r as i}from"./chunk-LFPYN7LY-PMGLV5Go.js";import{o as a}from"./statsig-BP9zNYqZ.js";import{n as o}from"./app-connect-oauth-BbS4dGUT.js";var s=r(),c=e(t(),1);function l(e){let t=(0,s.c)(16),n;t[0]===e?n=t[1]:(n=e===void 0?{}:e,t[0]=e,t[1]=n);let{hostId:r,onConnectStarted:l}=n,f=(0,c.useContext)(i),p=r??`local`,m=a(`2761268526`),{clearPendingAppConnect:h,isAppConnectPending:g,markAppConnectOAuthPending:_}=o(),[v,y]=(0,c.useState)(null),b=u,x;t[2]!==h||t[3]!==m||t[4]!==l?(x=async e=>{if(h({appId:e.id}),l?.(e),!m&&e.installUrl?.trim()){b(e.installUrl);return}y(e)},t[2]=h,t[3]=m,t[4]=l,t[5]=x):x=t[5];let S=x,C;t[6]===Symbol.for(`react.memo_cache_sentinel`)?(C=()=>{y(null)},t[6]=C):C=t[6];let w=C,T;t[7]!==p||t[8]!==f?.location||t[9]!==_?(T=e=>{let{app:t,redirectUrl:n}=e;_({app:t,hostId:p,redirectUrl:n,returnTo:d(f?.location)})},t[7]=p,t[8]=f?.location,t[9]=_,t[10]=T):T=t[10];let E=T,D;return t[11]!==v||t[12]!==E||t[13]!==S||t[14]!==g?(D={connectingApp:v,clearConnectingApp:w,handleAppConnectOAuthStarted:E,handleConnectApp:S,handleOpenAppUrl:b,isAppConnectPending:g},t[11]=v,t[12]=E,t[13]=S,t[14]=g,t[15]=D):D=t[15],D}function u(e){let t=e?.trim();t&&n.dispatchMessage(`open-in-browser`,{url:t})}function d(e){return e==null?`${window.location.pathname}${window.location.search}${window.location.hash}`:`${e.pathname}${e.search}${e.hash}`}export{l as t};
//# sourceMappingURL=use-app-connect-flow-BaOfBikQ.js.map