import{o as e}from"./rolldown-runtime-iuO8RvI4.js";import{Vi as n}from"./shared-0-C4kdVF7Y.js";import{Mi as s,ki as t}from"./vendor-frame-CwiylG4Y.js";import{Am as a,Mh as r,Pm as o}from"./shared-1-3-6x7RKF.js";import{v as i}from"./shared-17-YFu3JFq7.js";import{in as d}from"./vendor-all-1-BfXMvJfI.js";import{nn as l,rn as u}from"./vendor-all-2-BJdkbLSj.js";import{hi as c}from"./shared-2-CMUBhYOn.js";import{in as m,on as g,sn as p}from"./shared-7-VxUxSmVa.js";import{St as b,X as f}from"./index-C9LAU4f-.js";var j=e(s()),h=t(),x=b.__built("desktop_dusty_gondola_home_nudge_main"),k={status:"idle",pairError:void 0,partnerName:void 0,abandoned:!1},v=d(e=>({...k,mountedCount:0,begin:n=>e({status:"connecting",pairError:void 0,partnerName:n,abandoned:!1}),settle:n=>e(e=>e.abandoned?k:n.paired?{status:"connected",pairError:void 0}:p(n.error)||0===e.mountedCount?k:{status:"error",pairError:n.error}),consume:()=>e(k),abandon:()=>e({abandoned:!0}),setMounted:n=>e(e=>{const s=e.mountedCount+(n?1:-1);return 0===s&&"error"===e.status?{...k,mountedCount:s}:{mountedCount:s}})})),_=(0,j.memo)(function({enabled:e,onDismiss:n,onAction:s}){const t=u(),{addError:a}=r(),d=c("desktop_dusty_gondola_home_nudge_main"),{partner:l}=i(),[p,b]=(0,j.useState)(l);null===p&&null!==l&&b(l);const f=v(e=>e.status),x="connecting"===f;(0,j.useEffect)(()=>{if(!e)return;const{setMounted:n}=v.getState();return n(!0),()=>n(!1)},[e]);const k=(0,j.useCallback)(()=>{const e=v.getState();if(!p||"idle"!==e.status)return;const n=m(p.partnerId,"home_nudge");n&&(e.begin(p.displayName),n.then(e=>v.getState().settle(e)).catch(()=>v.getState().settle({paired:!1})))},[p]);(0,j.useEffect)(()=>{if(!e)return;const n=v.getState();"connected"!==n.status&&"error"!==n.status||("error"!==n.status||d)&&(n.consume(),"connected"===n.status?s({cta:"connect"}):a(o({intl:t,id:g(n.pairError),dangerouslyVisiblePublicValues:{partnerName:n.partnerName??""}}),{messageForLogging:"Home credential nudge connect failed"}))},[e,f,d,s,a,t]);const _=(0,j.useCallback)(()=>{const e=v.getState();"connected"===e.status||"error"===e.status?e.consume():"connecting"===e.status&&e.abandon(),n()},[n]);return e&&p&&d?(0,h.jsx)(y,{partner:p,connecting:x,onConnect:k,onDismiss:_}):null}),y=(0,j.memo)(function({partner:e,connecting:s,onConnect:t,onDismiss:r}){const o={partnerName:e.displayName};return(0,h.jsx)(f,{variant:"always-visible",size:"large",onDismiss:r,onClick:t,media:(0,h.jsx)("div",{className:"h-full w-full bg-orange-500/20",children:(0,h.jsx)(j.Suspense,{fallback:null,children:(0,h.jsx)(x,{})})}),title:(0,h.jsxs)(h.Fragment,{children:[(0,h.jsx)(n,{variant:"accent",className:"mb-1",children:(0,h.jsx)(a,{id:"15yghke",dangerouslyVisiblePublicValues:o})}),(0,h.jsx)("span",{className:"block",children:(0,h.jsx)(a,{id:"168i84j",dangerouslyVisiblePublicValues:o})})]}),body:(0,h.jsx)(a,{id:"xfk2k7",dangerouslyVisiblePublicValues:o}),actionText:s?(0,h.jsx)(l,{defaultMessage:"Connecting\u2026",id:"YtxGgOZEIf"}):(0,h.jsx)(a,{id:"lp7nkr",dangerouslyVisiblePublicValues:o})})});export{_ as DustyGondolaHomeNudge};