import{n as e,s as t}from"./rolldown-runtime-BG2f4sTM.js";import{$1 as n,Dvt as r,Mvt as i,Nvt as a,O_t as o,P_t as s,TU as c,Ylt as l,Zlt as u,_Z as d,bZ as f,c0 as p,c8 as m,cO as h,e0 as g,g0 as _,gZ as v,hZ as y,kU as b,l0 as x,l8 as S,lO as C,o0 as w,t0 as T,u0 as E,vZ as D,xZ as O}from"./app-initial-BHB6SClA.js";function k(e){let t=(0,L.c)(12),{conversationId:r}=e,i=s(n.activeTab$),a=s(T.activeTab$),o=s(n.tabs$),l=s(p),u=s(w),d,f;t[0]===u?(d=t[1],f=t[2]):(d=e=>u.on(`change`,e),f=()=>u.get(),t[0]=u,t[1]=d,t[2]=f);let m=(0,R.useSyncExternalStore)(d,f,M),h=s(T.tabs$),g=s(E),_=s(x),v,b;t[3]===_?(v=t[4],b=t[5]):(v=e=>_.on(`change`,e),b=()=>_.get(),t[3]=_,t[4]=v,t[5]=b);let S=(0,R.useSyncExternalStore)(v,b,j),C=c(r,{bottom:i,right:a},{bottom:l||m>0,right:g||S>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:C,panelTabs:[...h,...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=u(),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 s=o;if(s==null||!F(r,n))return null;let c;return t[3]!==n||t[4]!==r||t[5]!==s.adoptedWebContentsId||t[6]!==s.adoptionLease||t[7]!==s.initialUrl||t[8]!==i?(c=(0,z.jsx)(h,{adoptionLease:s.adoptionLease,adoptedWebContentsId:s.adoptedWebContentsId,bounds:null,browserTabId:n,conversationId:r,initialUrl:s.initialUrl,isVisible:!1,scale:1,shouldBootstrapWhenHidden:!0,shouldPaint:!1,webviewRef:a,windowZoom:i}),t[3]=n,t[4]=r,t[5]=s.adoptedWebContentsId,t[6]=s.adoptionLease,t[7]=s.initialUrl,t[8]=i,t[9]=c):c=t[9],c}function P({conversationId:e,mountedBrowserTabIds:t,panelTabs:n}){let r=new Set;for(let i of n){let n=m(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=D(e,t),r=f(e,t),i=d(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(),o(),R=t(a(),1),l(),g(),_(),b(),S(),v(),O(),C(),z=r()}))();export{k as HiddenBackgroundBrowserWebviewHost};
//# sourceMappingURL=browser-sidebar-hidden-background-webview-host-CqxUHvSC.js.map