import{s as e}from"./chunk-Bj-mKKzh.js";import{n as t}from"./jsx-runtime-CiQ1k8xo.js";import{I as n,lt as r}from"./vscode-api-DjORcpSo.js";import{n as i,r as a}from"./react-0SBwfqBm.js";import{n as o,s}from"./statsig-BP9zNYqZ.js";import{d as c}from"./thread-context-inputs-C9hcxtXy.js";import{y as l}from"./codex-api-BCmX_VRU.js";import{f as u,p as d}from"./onboarding-state-D2goG-J8.js";import{t as f}from"./use-is-remote-host-CH9dfL3P.js";import{c as p,d as m,i as h,l as g,o as _,r as v,s as y}from"./workspace-onboarding-experiment-DQAmyW2P.js";var b=r(),x=e(t(),1);function S({onboardingTarget:e,assignment:t,evaluateExperimentArm:n}){return t==null?e===`workspace`?n():`control`:t.arm}function C(){let e=(0,b.c)(5),t=a(d),n;e[0]===t?n=e[1]:(n=y(t)?t:null,e[0]=t,e[1]=n);let r=n,i=r?.arm??`control`,o;return e[2]!==i||e[3]!==r?(o={workspaceOnboardingExperimentAssignment:r,workspaceOnboardingExperimentArm:i},e[2]=i,e[3]=r,e[4]=o):o=e[4],o}function w(e){let t=(0,b.c)(17),{onboardingTarget:n}=e,[r,a]=i(d),o;t[0]===r?o=t[1]:(o=y(r)?r:null,t[0]=r,t[1]=o);let c=o,{client:l}=s(),u;t[2]===l?u=t[3]:(u=()=>_(l),t[2]=l,t[3]=u);let f;t[4]!==n||t[5]!==u||t[6]!==c?(f=S({onboardingTarget:n,assignment:c,evaluateExperimentArm:u}),t[4]=n,t[5]=u,t[6]=c,t[7]=f):f=t[7];let p=f,m,g;t[8]!==n||t[9]!==a||t[10]!==l||t[11]!==c?(m=()=>{n===`workspace`&&c==null&&a({arm:_(l),assignedAtMs:Date.now(),experimentName:h})},g=[n,a,l,c],t[8]=n,t[9]=a,t[10]=l,t[11]=c,t[12]=m,t[13]=g):(m=t[12],g=t[13]),(0,x.useEffect)(m,g);let v;return t[14]!==p||t[15]!==c?(v={workspaceOnboardingExperimentAssignment:c,workspaceOnboardingExperimentArm:p},t[14]=p,t[15]=c,t[16]=v):v=t[16],v}function T({onboardingTarget:e,arm:t,isRemoteHost:n}){return e===`workspace`&&!n&&g(t)}function E(e){let t=(0,b.c)(14),{enabled:n}=e,{client:r,isLoading:i}=s(),a;t[0]!==n||t[1]!==i||t[2]!==r?(a=n&&!i&&o(r,`1482884768`),t[0]=n,t[1]=i,t[2]=r,t[3]=a):a=t[3];let c=a,u;t[4]===c?u=t[5]:(u={enabled:c},t[4]=c,t[5]=u);let d=l(u),f=d.data?.age_status===`under_18`;if(!n){let e;return t[6]===Symbol.for(`react.memo_cache_sentinel`)?(e={isLoading:!1,shouldUseTeenOnboarding:!1},t[6]=e):e=t[6],e}let p=i||c&&d.isLoading,m;t[7]!==c||t[8]!==f||t[9]!==r?(m=c&&f&&o(r,`3150044490`),t[7]=c,t[8]=f,t[9]=r,t[10]=m):m=t[10];let h;return t[11]!==p||t[12]!==m?(h={isLoading:p,shouldUseTeenOnboarding:m},t[11]=p,t[12]=m,t[13]=h):h=t[13],h}function D({arm:e,isRemoteHost:t,isLoadingRoots:n,hasPersistedRoots:r,autoLaunchApplied:i}){return t||n||r||i?`none`:g(e)?`home_open_picker_or_create_default`:p(e)?`select_workspace_skip_to_playground`:`none`}function O(){let e=(0,b.c)(15),{workspaceOnboardingExperimentArm:t}=C(),r=f(),[a,o]=i(u),{data:s,isLoading:l}=n(c),d=(s?.roots?.length??0)>0,p;e[0]!==d||e[1]!==l||e[2]!==r||e[3]!==a||e[4]!==t?(p=D({arm:t,isRemoteHost:r,isLoadingRoots:l,hasPersistedRoots:d,autoLaunchApplied:a}),e[0]=d,e[1]=l,e[2]=r,e[3]=a,e[4]=t,e[5]=p):p=e[5];let m=p,h;return e[6]!==m||e[7]!==d||e[8]!==l||e[9]!==r||e[10]!==o||e[11]!==a||e[12]!==t||e[13]!==s?(h={workspaceOnboardingExperimentArm:t,isRemoteHost:r,workspaceOnboardingAutoLaunchApplied:a,setWorkspaceOnboardingAutoLaunchApplied:o,workspaceRootOptions:s,isLoadingWorkspaceRootOptions:l,hasPersistedRoots:d,autoLaunchAction:m},e[6]=m,e[7]=d,e[8]=l,e[9]=r,e[10]=o,e[11]=a,e[12]=t,e[13]=s,e[14]=h):h=e[14],h}function k(e){if(m(e))return v}export{w as a,O as i,T as n,E as r,k as t};
//# sourceMappingURL=workspace-onboarding-controller-BMr5jWDN.js.map