"use strict";var e=require("react/jsx-runtime"),r=require("react"),t=require("react-device-detect"),i=require("styled-components"),a=require("./CopyToClipboard-CC0DCGEH.js"),s=require("./useActiveWallet-dTc6deka.js"),o=require("./OpenLink-L5LZ-pEm.js"),n=require("./QrCode-ErbyIBDF.js"),l=require("./context-rs-ygOK2.js"),c=require("./internal-context-CdsQ3LEl.js"),u=require("./modal-context-BgeioxwT.js"),d=require("./ScreenLayout-DaFW0I3a.js"),p=require("./farcaster-CWHXGAib.js");require("viem/utils"),require("./wallet-connect-BuohfvHK.js"),require("./errors-CBapWvRs.js"),require("ofetch"),require("./getPublicClient-CFd_sHBk.js"),require("viem"),require("viem/chains"),require("@privy-io/js-sdk-core"),require("eventemitter3"),require("./events-context-Di6--rDg.js"),require("./privy-context-UTJouJ1x.js"),require("@privy-io/are-addresses-equal"),require("./index-Ub4KpwSY.js"),require("zustand"),require("./get-entropy-details-for-user-D63rM5_a.js"),require("./user-D2oPA-vS.js"),require("qrcode"),require("tinycolor2"),require("./ModalHeader-Cpls13mi.js"),require("@heroicons/react/24/outline/ArrowLeftIcon"),require("@heroicons/react/24/outline/ArrowRightIcon"),require("@heroicons/react/24/outline/QuestionMarkCircleIcon"),require("@heroicons/react/24/outline/XMarkIcon"),require("./Screen-8NusMFtu.js"),require("./index-ByFhjjzH.js");let g="#8a63d2";const q=({appName:r,loading:i,success:l,errorMessage:c,connectUri:u,onBack:q,onClose:S,onOpenFarcaster:f})=>t.isMobile||i?t.isIOS?/*#__PURE__*/e.jsx(d.ScreenLayout,{title:c?c.message:"Add a signer to Farcaster",subtitle:c?c.detail:`This will allow ${r} to add casts, likes, follows, and more on your behalf.`,icon:p.Farcaster,iconVariant:"loading",iconLoadingStatus:{success:l,fail:!!c},primaryCta:u&&f?{label:"Open Farcaster app",onClick:f}:void 0,onBack:q,onClose:S,watermark:!0}):/*#__PURE__*/e.jsx(d.ScreenLayout,{title:c?c.message:"Requesting signer from Farcaster",subtitle:c?c.detail:"This should only take a moment",icon:p.Farcaster,iconVariant:"loading",iconLoadingStatus:{success:l,fail:!!c},onBack:q,onClose:S,watermark:!0,children:u&&t.isMobile&&/*#__PURE__*/e.jsx(m,{children:/*#__PURE__*/e.jsx(o.OpenLinkButton,{text:"Take me to Farcaster",url:u,color:g})})}):
/*#__PURE__*/e.jsx(d.ScreenLayout,{title:"Add a signer to Farcaster",subtitle:`This will allow ${r} to add casts, likes, follows, and more on your behalf.`,onBack:q,onClose:S,watermark:!0,children:/*#__PURE__*/e.jsxs(v,{children:[/*#__PURE__*/e.jsx(h,{children:u?/*#__PURE__*/e.jsx(n.QrCode,{url:u,size:275,squareLogoElement:p.Farcaster}):/*#__PURE__*/e.jsx(y,{children:/*#__PURE__*/e.jsx(s.Loader,{})})}),/*#__PURE__*/e.jsxs(j,{children:[/*#__PURE__*/e.jsx(x,{children:"Or copy this link and paste it into a phone browser to open the Farcaster app."}),u&&/*#__PURE__*/e.jsx(a.CopytoClipboardButton,{text:u,itemName:"link",color:g})]})]})});let m=i.styled.div`
  margin-top: 24px;
`,v=i.styled.div`
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 24px;
`,h=i.styled.div`
  padding: 24px;
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 275px;
`,j=i.styled.div`
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
`,x=i.styled.div`
  font-size: 0.875rem;
  text-align: center;
  color: var(--privy-color-foreground-2);
`,y=i.styled.div`
  position: relative;
  width: 82px;
  height: 82px;
`;const S={component:()=>{let{lastScreen:t,navigateBack:i,data:a}=u.usePrivyModal(),s=l.useAppConfig(),{requestFarcasterSignerStatus:o,closePrivyModal:n}=c.usePrivyInternal(),[d,p]=r.useState(void 0),[g,m]=r.useState(!1),[v,h]=r.useState(!1),j=r.useRef([]),x=a?.farcasterSigner;r.useEffect((()=>{let e=Date.now(),r=setInterval((async()=>{if(!x?.public_key)return clearInterval(r),void p({retryable:!0,message:"Connect failed",detail:"Something went wrong. Please try again."});"approved"===x.status&&(clearInterval(r),m(!1),h(!0),j.current.push(setTimeout((()=>n({shouldCallAuthOnSuccess:!1,isSuccess:!0})),l.DEFAULT_SUCCESS_SCREEN_DURATION_MS)));let t=await o(x?.public_key),i=Date.now()-e;"approved"===t.status?(clearInterval(r),m(!1),h(!0),j.current.push(setTimeout((()=>n({shouldCallAuthOnSuccess:!1,isSuccess:!0})),l.DEFAULT_SUCCESS_SCREEN_DURATION_MS))):i>3e5?(clearInterval(r),p({retryable:!0,message:"Connect failed",detail:"The request timed out. Try again."})):"revoked"===t.status&&(clearInterval(r),p({retryable:!0,message:"Request rejected",detail:"The request was rejected. Please try again."}))}),2e3);return()=>{clearInterval(r),j.current.forEach((e=>clearTimeout(e)))}}),[]);let y="pending_approval"===x?.status?x.signer_approval_url:void 0;/*#__PURE__*/return e.jsx(q,{appName:s.name,loading:g,success:v,errorMessage:d,connectUri:y,onBack:t?i:void 0,onClose:n,onOpenFarcaster:()=>{y&&(window.location.href=y)}})}};exports.FarcasterSignerStatusScreen=S,exports.FarcasterSignerStatusView=q,exports.default=S;
//# sourceMappingURL=FarcasterSignerStatusScreen-pVPiIYkc.js.map
