import{jsx as e,jsxs as t}from"react/jsx-runtime";import{useState as r,useRef as o,useEffect as a}from"react";import{isMobile as i,isIOS as s}from"react-device-detect";import{styled as n}from"styled-components";import{C as l}from"./CopyToClipboard-DSTf_eKU.mjs";import{L as c}from"./useActiveWallet-BEfvREjE.mjs";import{O as m}from"./OpenLink-DZHy38vr.mjs";import{Q as p}from"./QrCode-CvO4k-hN.mjs";import{u as d,r as u}from"./context-BKnOUECq.mjs";import{u as g}from"./internal-context-dfitw7Ot.mjs";import{u as h}from"./modal-context-DBwfUxD-.mjs";import{S as f}from"./ScreenLayout-Caq5mGD8.mjs";import{F as v}from"./farcaster-DPlSjvF5.mjs";import"viem/utils";import"./wallet-connect-58EobR5U.mjs";import"./errors-Dd6zfYtp.mjs";import"ofetch";import"./getPublicClient-D4yNgeGy.mjs";import"viem";import"viem/chains";import"@privy-io/js-sdk-core";import"eventemitter3";import"./events-context-BJ75xIIf.mjs";import"./privy-context-Bi6vqCPc.mjs";import"@privy-io/are-addresses-equal";import"./index-BtwxknTg.mjs";import"zustand";import"./get-entropy-details-for-user-BIWg0YxF.mjs";import"./user-D5cqJNp9.mjs";import"qrcode";import"tinycolor2";import"./ModalHeader-DffkxvO4.mjs";import"@heroicons/react/24/outline/ArrowLeftIcon";import"@heroicons/react/24/outline/ArrowRightIcon";import"@heroicons/react/24/outline/QuestionMarkCircleIcon";import"@heroicons/react/24/outline/XMarkIcon";import"./Screen-D8KNyGVj.mjs";import"./index-Dq_xe9dz.mjs";let y="#8a63d2";const j=({appName:r,loading:o,success:a,errorMessage:n,connectUri:d,onBack:u,onClose:g,onOpenFarcaster:h})=>/*#__PURE__*/e(f,i||o?s?{title:n?n.message:"Add a signer to Farcaster",subtitle:n?n.detail:`This will allow ${r} to add casts, likes, follows, and more on your behalf.`,icon:v,iconVariant:"loading",iconLoadingStatus:{success:a,fail:!!n},primaryCta:d&&h?{label:"Open Farcaster app",onClick:h}:void 0,onBack:u,onClose:g,watermark:!0}:{title:n?n.message:"Requesting signer from Farcaster",subtitle:n?n.detail:"This should only take a moment",icon:v,iconVariant:"loading",iconLoadingStatus:{success:a,fail:!!n},onBack:u,onClose:g,watermark:!0,children:d&&i&&/*#__PURE__*/e(x,{children:/*#__PURE__*/e(m,{text:"Take me to Farcaster",url:d,color:y})})}:{title:"Add a signer to Farcaster",subtitle:`This will allow ${r} to add casts, likes, follows, and more on your behalf.`,onBack:u,onClose:g,watermark:!0,children:/*#__PURE__*/t(k,{children:[/*#__PURE__*/e(w,{children:d?/*#__PURE__*/e(p,{url:d,size:275,squareLogoElement:v}):/*#__PURE__*/e(b,{children:/*#__PURE__*/e(c,{})})}),/*#__PURE__*/t(C,{children:[/*#__PURE__*/e(S,{children:"Or copy this link and paste it into a phone browser to open the Farcaster app."}),d&&/*#__PURE__*/e(l,{text:d,itemName:"link",color:y})]})]})});let x=n.div`
  margin-top: 24px;
`,k=n.div`
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 24px;
`,w=n.div`
  padding: 24px;
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 275px;
`,C=n.div`
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
`,S=n.div`
  font-size: 0.875rem;
  text-align: center;
  color: var(--privy-color-foreground-2);
`,b=n.div`
  position: relative;
  width: 82px;
  height: 82px;
`;const T={component:()=>{let{lastScreen:t,navigateBack:i,data:s}=h(),n=d(),{requestFarcasterSignerStatus:l,closePrivyModal:c}=g(),[m,p]=r(void 0),[f,v]=r(!1),[y,x]=r(!1),k=o([]),w=s?.farcasterSigner;a((()=>{let e=Date.now(),t=setInterval((async()=>{if(!w?.public_key)return clearInterval(t),void p({retryable:!0,message:"Connect failed",detail:"Something went wrong. Please try again."});"approved"===w.status&&(clearInterval(t),v(!1),x(!0),k.current.push(setTimeout((()=>c({shouldCallAuthOnSuccess:!1,isSuccess:!0})),u)));let r=await l(w?.public_key),o=Date.now()-e;"approved"===r.status?(clearInterval(t),v(!1),x(!0),k.current.push(setTimeout((()=>c({shouldCallAuthOnSuccess:!1,isSuccess:!0})),u))):o>3e5?(clearInterval(t),p({retryable:!0,message:"Connect failed",detail:"The request timed out. Try again."})):"revoked"===r.status&&(clearInterval(t),p({retryable:!0,message:"Request rejected",detail:"The request was rejected. Please try again."}))}),2e3);return()=>{clearInterval(t),k.current.forEach((e=>clearTimeout(e)))}}),[]);let C="pending_approval"===w?.status?w.signer_approval_url:void 0;/*#__PURE__*/return e(j,{appName:n.name,loading:f,success:y,errorMessage:m,connectUri:C,onBack:t?i:void 0,onClose:c,onOpenFarcaster:()=>{C&&(window.location.href=C)}})}};export{T as FarcasterSignerStatusScreen,j as FarcasterSignerStatusView,T as default};
//# sourceMappingURL=FarcasterSignerStatusScreen-e4KIeEcJ.mjs.map
