import{n as e,s as t}from"./rolldown-runtime-BG2f4sTM.js";import{O as n,dn as r,un as i,x as a,zt as o}from"./app-initial~avatarOverlayCompositionSurface~index-9fQ9wihu~index-BFCcxPM5~mapbox-gl-DVWlwqb~kppdhley-CabsBVhy.js";import{l as s,s as c}from"./app-initial~avatarOverlayCompositionSurface~artifact-tab-content.electron~notebook-preview-~cc80cam6-BCKQAAO_.js";import{gs as l,hs as u}from"./app-initial~artifact-tab-content.electron~notebook-preview-panel~app-main~business-checkout~oxnpxkxc-CRvN_72X.js";import{f as d,k as f,m as p,p as m,u as h}from"./app-initial~artifact-tab-content.electron~notebook-preview-panel~app-main~settings-command-~ktg7n5fh-BOWIP6mG.js";import{f as g,h as _,n as v,t as y,v as b,y as x}from"./app-initial~artifact-tab-content.electron~app-main~appgen-settings-page~page~pull-request-r~mxek7o2y-BBQn2C3N.js";import{_ as S,b as C,y as w}from"./app-initial~artifact-tab-content.electron~notebook-preview-panel~app-main~appgen-settings-p~gy16mplo-DrpCowyx.js";import{L as T,N as E}from"./app-initial~app-main~new-thread-panel-page~onboarding-page~projects-index-page~appgen-libra~im95otkx-C4rBbYfY.js";import{l as D,u as O}from"./app-initial~app-main~pull-request-route~onboarding-page~hotkey-window-thread-page~quick-cha~mo2avlln-BwSydWlc.js";function k(e){let t=(0,L.c)(12),{conversationId:r}=e,i=n(S.activeTab$),a=n(C.activeTab$),o=n(S.tabs$),s=n(d),c=n(h),l,u;t[0]===c?(l=t[1],u=t[2]):(l=e=>c.on(`change`,e),u=()=>c.get(),t[0]=c,t[1]=l,t[2]=u);let f=(0,R.useSyncExternalStore)(l,u,M),g=n(C.tabs$),_=n(p),v=n(m),b,x;t[3]===v?(b=t[4],x=t[5]):(b=e=>v.on(`change`,e),x=()=>v.get(),t[3]=v,t[4]=b,t[5]=x);let w=(0,R.useSyncExternalStore)(b,x,j),T=E(r,{bottom:i,right:a},{bottom:s||f>0,right:_||w>0}),D;t[6]===r?D=t[7]:(D=()=>y.getBrowserUseBrowserTabIdsKey(r),t[6]=r,t[7]=D),(0,R.useSyncExternalStore)(y.subscribe,D,A);let O=P({conversationId:r,mountedBrowserTabIds:T,panelTabs:[...g,...o]});if(O.length===0)return null;let k;t[8]===r?k=t[9]:(k=e=>(0,z.jsx)(N,{browserTabId:e,conversationId:r},e),t[8]=r,t[9]=k);let F=O.map(k),I;return t[10]===F?I=t[11]:(I=(0,z.jsx)(z.Fragment,{children:F}),t[10]=F,t[11]=I),I}function A(){return``}function j(){return 0}function M(){return 0}function N(e){let t=(0,L.c)(10),{browserTabId:n,conversationId:r}=e,i=s(),a=(0,R.useRef)(null),o;t[0]!==n||t[1]!==r?(o=I(r,n),t[0]=n,t[1]=r,t[2]=o):o=t[2];let c=o;if(c==null||!F(r,n))return null;let l;return t[3]!==n||t[4]!==r||t[5]!==c.adoptedWebContentsId||t[6]!==c.adoptionLease||t[7]!==c.initialUrl||t[8]!==i?(l=(0,z.jsx)(D,{adoptionLease:c.adoptionLease,adoptedWebContentsId:c.adoptedWebContentsId,bounds:null,browserTabId:n,conversationId:r,initialUrl:c.initialUrl,isVisible:!1,scale:1,shouldBootstrapWhenHidden:!0,shouldPaint:!1,webviewRef:a,windowZoom:i}),t[3]=n,t[4]=r,t[5]=c.adoptedWebContentsId,t[6]=c.adoptionLease,t[7]=c.initialUrl,t[8]=i,t[9]=l):l=t[9],l}function P({conversationId:e,mountedBrowserTabIds:t,panelTabs:n}){let r=new Set;for(let i of n){let n=u(i,e)??null;n==null||y.isBrowserUseTab(e,n)||t.includes(n)||F(e,n)&&r.add(n)}return Array.from(r)}function F(e,t){return y.isBrowserUseTab(e,t)?!1:I(e,t)!=null}function I(e,t){let n=_(e,t),r=b(e,t),i=g(e,t);return n==null&&(r==null||i==null)?null:{adoptedWebContentsId:i,adoptionLease:r,initialUrl:n??`about:blank`}}var L,R,z;e((()=>{L=i(),a(),R=t(r(),1),c(),w(),f(),T(),l(),v(),x(),O(),z=o()}))();export{k as HiddenBackgroundBrowserWebviewHost};
//# sourceMappingURL=browser-sidebar-hidden-background-webview-host-DJ30tjDS.js.map