(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[931],{1367:function(e,s,t){Promise.resolve().then(t.bind(t,88))},88:function(e,s,t){"use strict";t.r(s),t.d(s,{TipForm:function(){return y}});var a=t(3827),l=t(4090),n=t(1169),r=t(536),i=t(9311),c=t(3089),o=t(7206),d=t(83),m=t(4161),x=t(823),u=t(2280);async function h(e){try{var s,t,a;let l=await fetch("".concat(u.jY.BASE_URL).concat(u.jY.USERNAME_RESOLUTION,"/").concat(e)),n=await l.json();if(null===(a=n.result)||void 0===a?void 0:null===(t=a.user)||void 0===t?void 0:null===(s=t.verifications)||void 0===s?void 0:s[0])return n.result.user.verifications[0];return null}catch(e){return console.error("Error resolving Farcaster username:",e),null}}var p=t(4433),f=t(6796);function y(){let{connect:e,connectors:s}=(0,n.$)(),{disconnect:t}=(0,r.q)(),{isConnected:y,address:N,status:j}=(0,i.m)(),g=(0,c.x)(),{switchChain:v}=(0,o.o)(),{data:b,isLoading:w}=(0,d.K)({address:N,query:{refetchInterval:5e3,retry:3,retryDelay:1e3,enabled:y&&g===u.sz.id}}),[k,C]=(0,l.useState)(!1),[M,S]=(0,l.useState)(""),[E,D]=(0,l.useState)(""),[z,T]=(0,l.useState)(!1),[O,P]=(0,l.useState)(null),[A,L]=(0,l.useState)(!1),[R,B]=(0,l.useState)(null),[F,U]=(0,l.useState)(!1),[$,_]=(0,l.useState)(void 0),{sendTransaction:I,data:W,isPending:H}=(0,m.p)(),{isLoading:V}=(0,x.A)({hash:$}),q=g===u.sz.id;(0,l.useEffect)(()=>{"disconnected"===j&&U(!1)},[j]),(0,l.useEffect)(()=>{console.log("Connection status:",j),"disconnected"===j&&U(!1)},[j]),(0,l.useEffect)(()=>{if(R){let e=setTimeout(()=>{B(null)},5e3);return()=>clearTimeout(e)}},[R]),(0,l.useEffect)(()=>{!$||V||H||(B("Successfully sent ".concat(E," $MON to ").concat(M.slice(0,6),"...").concat(M.slice(-4))),S(""),D(""),C(!1),_(void 0))},[$,V,H,E,M]),(0,l.useEffect)(()=>{W&&(_(W),console.log("Transaction sent:",W))},[W]);let Y=async e=>{if(S(e),P(null),e.startsWith("@")){T(!0);try{await new Promise(e=>setTimeout(e,500));let s=await h(e.slice(1));console.log("Resolved address:",s),s?(0,p.U)(s)?(S(s),P(null)):P("Invalid address format for resolved username"):P("Could not find this Farcaster username. Please check the spelling and try again.")}catch(e){console.error("Error resolving username:",e),P("Having trouble finding this username. Please try again in a moment.")}finally{T(!1)}}else e&&!(0,p.U)(e)&&P("Please enter a valid Monad testnet address")},K=async()=>{if("connecting"!==j)try{U(!0),P(null);let t=s.find(e=>"injected"===e.id);if(!t)throw Error("No wallet detected. Please make sure you have a compatible wallet installed.");await e({connector:t,chainId:u.sz.id}),g!==u.sz.id&&await v({chainId:u.sz.id})}catch(e){console.error("Connection error:",e),e instanceof Error?e.message.includes("user rejected")?P("Connection was rejected. Please try again."):e.message.includes("wallet not detected")?P("No wallet detected. Please make sure you have a compatible wallet installed."):e.message.includes("already pending")?P("A connection request is already pending. Please wait or refresh the page."):P("Connection failed: ".concat(e.message)):P("Failed to connect wallet. Please try again.")}finally{U(!1)}},G=async()=>{try{P(null),await t(),U(!1),S(""),D(""),C(!1),B(null),_(void 0)}catch(e){console.error("Disconnect error:",e),P("Failed to disconnect wallet. Please try again.")}},J=async()=>{if(!y||!N){P("Please connect your wallet first");return}if(!M||!E){P("Please fill in all fields");return}if(!(0,p.U)(M)){P("Please enter a valid Monad testnet address");return}try{L(!0),P(null),B(null),q||await v({chainId:u.sz.id});let e=(0,f.f)(E);I({to:M,value:e})}catch(e){console.error("Error sending tip:",e),e instanceof Error&&e.message.includes("user rejected")?P("Transaction was rejected. Please try again."):P(e instanceof Error?e.message:"Failed to send tip"),_(void 0)}finally{L(!1)}},Q=()=>{C(!1),P(null),S(""),D("")};return y?w?(0,a.jsx)("div",{className:"min-h-[80vh] flex flex-col items-center justify-center p-8",children:(0,a.jsxs)("div",{className:"text-center space-y-4",children:[(0,a.jsx)("div",{className:"animate-spin rounded-full h-12 w-12 border-b-2 border-indigo-600 mx-auto"}),(0,a.jsx)("p",{className:"text-gray-600",children:"Loading wallet balance..."})]})}):(0,a.jsxs)("div",{className:"space-y-6",children:[R&&(0,a.jsx)("div",{className:"p-4 bg-green-50 border border-green-200 rounded-lg animate-fade-in",children:(0,a.jsxs)("div",{className:"flex items-center",children:[(0,a.jsx)("div",{className:"flex-shrink-0",children:(0,a.jsx)("svg",{className:"h-4 w-4 text-green-500",viewBox:"0 0 20 20",fill:"currentColor",children:(0,a.jsx)("path",{fillRule:"evenodd",d:"M10 18a8 8 0 100-16 8 8 0 000 16zm3.707-9.293a1 1 0 00-1.414-1.414L9 10.586 7.707 9.293a1 1 0 00-1.414 1.414l2 2a1 1 0 001.414 0l4-4z",clipRule:"evenodd"})})}),(0,a.jsx)("div",{className:"ml-3",children:(0,a.jsx)("p",{className:"text-sm font-medium text-green-800",children:R})})]})}),(0,a.jsx)("div",{className:"p-2 bg-yellow-50 border-l-4 border-yellow-400 rounded text-xs text-yellow-800 font-semibold",children:"$MON token is not real money and is for the purpose of testing the Monad testnet blockchain."}),(0,a.jsxs)("div",{className:"card bg-gradient-to-r from-pink-50 to-purple-50 p-6 rounded-xl border border-pink-100 shadow-sm",children:[(0,a.jsxs)("div",{className:"flex items-center space-x-2 mb-3",children:[(0,a.jsx)("span",{className:"text-2xl",children:"\uD83D\uDC9D"}),(0,a.jsx)("h3",{className:"text-lg font-semibold text-gray-800",children:"Spread Love on Farcaster!"}),(0,a.jsx)("span",{className:"text-2xl",children:"\uD83D\uDC9D"})]}),(0,a.jsx)("p",{className:"text-gray-700 leading-relaxed",children:"Ready to show some love to your favorite casters? \uD83D\uDC96 Simply type their username with @ (like @username) and send them a $MON tip! It's a beautiful way to support the amazing content creators in our community. Every tip is a little heart sent through the blockchain! \uD83D\uDCAB✨"})]}),(0,a.jsx)("div",{className:"glass rounded-xl p-4 border-l-4 border-yellow-400",children:(0,a.jsxs)("div",{className:"flex items-start",children:[(0,a.jsx)("div",{className:"flex-shrink-0 text-lg",children:"⚠️"}),(0,a.jsxs)("div",{className:"ml-3",children:[(0,a.jsx)("h3",{className:"text-sm font-medium text-yellow-800",children:"Testnet Only"}),(0,a.jsx)("p",{className:"text-sm text-yellow-700 mt-1",children:"This app only works on Monad Testnet Network. $MON tokens have no real value and are for testing purposes only."})]})]})}),(0,a.jsxs)("div",{className:"card",children:[(0,a.jsxs)("div",{className:"flex justify-between items-center mb-4",children:[(0,a.jsxs)("div",{className:"space-y-1",children:[(0,a.jsxs)("div",{className:"flex items-center space-x-2",children:[(0,a.jsx)("span",{className:"text-sm font-medium text-gray-900",children:"Connected:"}),(0,a.jsxs)("span",{className:"text-sm text-gray-600 font-mono",children:[null==N?void 0:N.slice(0,6),"...",null==N?void 0:N.slice(-4)]})]}),b&&(0,a.jsxs)("div",{className:"flex items-center space-x-2",children:[(0,a.jsx)("span",{className:"text-sm font-medium text-gray-900",children:"Balance:"}),(0,a.jsxs)("span",{className:"text-sm text-gray-600 font-mono",children:[Number(b.formatted).toFixed(4)," ",b.symbol]})]})]}),(0,a.jsx)("button",{onClick:G,className:"btn-secondary text-sm",disabled:F||H||A,children:"Disconnect"})]}),!q&&(0,a.jsx)("div",{className:"mt-4",children:(0,a.jsx)("button",{onClick:()=>v({chainId:u.sz.id}),className:"btn-primary w-full",disabled:F||H||A,children:"Switch to Monad Testnet"})})]}),q&&(0,a.jsx)("div",{className:"text-center",children:(0,a.jsx)("button",{onClick:()=>{C(!0),P(null),S(""),D("")},className:"btn-primary text-lg px-8 py-3 shadow-lg hover:shadow-xl transform hover:-translate-y-0.5 transition-all",disabled:H||A||V,children:H||A||V?(0,a.jsxs)("span",{className:"flex items-center justify-center",children:[(0,a.jsxs)("svg",{className:"animate-spin -ml-1 mr-2 h-4 w-4 text-white",fill:"none",viewBox:"0 0 24 24",children:[(0,a.jsx)("circle",{className:"opacity-25",cx:"12",cy:"12",r:"10",stroke:"currentColor",strokeWidth:"4"}),(0,a.jsx)("path",{className:"opacity-75",fill:"currentColor",d:"M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4zm2 5.291A7.962 7.962 0 014 12H0c0 3.042 1.135 5.824 3 7.938l3-2.647z"})]}),V?"Confirming...":"Sending..."]}):"Send $MON Tip"})}),k&&(0,a.jsx)("div",{className:"modal-backdrop",children:(0,a.jsxs)("div",{className:"modal-content",children:[(0,a.jsxs)("div",{className:"flex justify-between items-center mb-6",children:[(0,a.jsx)("h2",{className:"text-2xl font-semibold text-gray-900",children:"Send $MON Tip"}),(0,a.jsx)("button",{onClick:Q,className:"text-gray-400 hover:text-gray-500 transition-colors",children:(0,a.jsx)("svg",{className:"w-6 h-6",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,a.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})})})]}),(0,a.jsxs)("div",{className:"space-y-6",children:[(0,a.jsxs)("div",{children:[(0,a.jsx)("label",{className:"block text-sm font-medium text-gray-700 mb-2",children:"Recipient"}),(0,a.jsx)("input",{type:"text",value:M,onChange:e=>Y(e.target.value),placeholder:"@username or 0x...",className:"input-primary"}),z&&(0,a.jsxs)("p",{className:"mt-2 text-sm text-gray-500 flex items-center",children:[(0,a.jsxs)("svg",{className:"animate-spin -ml-1 mr-2 h-4 w-4 text-blue-500",fill:"none",viewBox:"0 0 24 24",children:[(0,a.jsx)("circle",{className:"opacity-25",cx:"12",cy:"12",r:"10",stroke:"currentColor",strokeWidth:"4"}),(0,a.jsx)("path",{className:"opacity-75",fill:"currentColor",d:"M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4zm2 5.291A7.962 7.962 0 014 12H0c0 3.042 1.135 5.824 3 7.938l3-2.647z"})]}),"Resolving username..."]})]}),(0,a.jsxs)("div",{children:[(0,a.jsx)("label",{className:"block text-sm font-medium text-gray-700 mb-2",children:"Amount ($MON)"}),(0,a.jsx)("input",{type:"number",value:E,onChange:e=>D(e.target.value),placeholder:"0.0",step:"0.0001",min:"0",className:"input-primary"})]}),O&&(0,a.jsx)("div",{className:"p-3 bg-red-50 border border-red-200 rounded-lg",children:(0,a.jsx)("p",{className:"text-sm text-red-600",children:O})}),(0,a.jsxs)("div",{className:"flex justify-end space-x-3 pt-4",children:[(0,a.jsx)("button",{onClick:Q,className:"btn-secondary",disabled:H||A,children:"Cancel"}),(0,a.jsx)("button",{onClick:J,disabled:H||A||!M||!E,className:"btn-primary",children:H||A?(0,a.jsxs)("span",{className:"flex items-center",children:[(0,a.jsxs)("svg",{className:"animate-spin -ml-1 mr-2 h-4 w-4 text-white",fill:"none",viewBox:"0 0 24 24",children:[(0,a.jsx)("circle",{className:"opacity-25",cx:"12",cy:"12",r:"10",stroke:"currentColor",strokeWidth:"4"}),(0,a.jsx)("path",{className:"opacity-75",fill:"currentColor",d:"M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4zm2 5.291A7.962 7.962 0 014 12H0c0 3.042 1.135 5.824 3 7.938l3-2.647z"})]}),"Sending..."]}):"Send Tip"})]})]})]})})]}):(0,a.jsx)("div",{className:"min-h-[80vh] flex flex-col items-center justify-center p-8",children:(0,a.jsxs)("div",{className:"max-w-2xl w-full space-y-8 text-center",children:[(0,a.jsxs)("div",{className:"space-y-4",children:[(0,a.jsx)("h1",{className:"text-4xl font-bold bg-gradient-to-r from-indigo-600 to-purple-600 bg-clip-text text-transparent",children:"Welcome to FarcasTip"}),(0,a.jsx)("p",{className:"text-xl text-gray-600",children:"Send $MON tips to your favorite Farcaster users on Monad Testnet"})]}),(0,a.jsxs)("div",{className:"grid grid-cols-1 md:grid-cols-3 gap-6 my-12",children:[(0,a.jsxs)("div",{className:"p-6 bg-white rounded-xl shadow-sm border border-gray-100",children:[(0,a.jsx)("div",{className:"text-3xl mb-4",children:"\uD83D\uDC9D"}),(0,a.jsx)("h3",{className:"text-lg font-semibold mb-2",children:"Show Appreciation"}),(0,a.jsx)("p",{className:"text-gray-600",children:"Support content creators you love with MON tokens"})]}),(0,a.jsxs)("div",{className:"p-6 bg-white rounded-xl shadow-sm border border-gray-100",children:[(0,a.jsx)("div",{className:"text-3xl mb-4",children:"⚡"}),(0,a.jsx)("h3",{className:"text-lg font-semibold mb-2",children:"Fast & Easy"}),(0,a.jsx)("p",{className:"text-gray-600",children:"Send tips with just a few clicks using @username"})]}),(0,a.jsxs)("div",{className:"p-6 bg-white rounded-xl shadow-sm border border-gray-100",children:[(0,a.jsx)("div",{className:"text-3xl mb-4",children:"\uD83D\uDD12"}),(0,a.jsx)("h3",{className:"text-lg font-semibold mb-2",children:"Secure"}),(0,a.jsx)("p",{className:"text-gray-600",children:"Built on Monad Testnet for safe testing"})]})]}),(0,a.jsx)("button",{onClick:K,className:"btn-primary text-lg px-8 py-4 w-full max-w-xs mx-auto transform hover:scale-105 transition-all duration-200 shadow-lg hover:shadow-xl",disabled:"connecting"===j,children:"connecting"===j?(0,a.jsxs)("span",{className:"flex items-center justify-center",children:[(0,a.jsxs)("svg",{className:"animate-spin -ml-1 mr-2 h-5 w-5 text-white",fill:"none",viewBox:"0 0 24 24",children:[(0,a.jsx)("circle",{className:"opacity-25",cx:"12",cy:"12",r:"10",stroke:"currentColor",strokeWidth:"4"}),(0,a.jsx)("path",{className:"opacity-75",fill:"currentColor",d:"M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4zm2 5.291A7.962 7.962 0 014 12H0c0 3.042 1.135 5.824 3 7.938l3-2.647z"})]}),"Connecting..."]}):"Connect Wallet"}),(0,a.jsx)("p",{className:"text-xs text-red-500 mt-4 font-semibold",children:"$MON token is not real money and is for testing purposes only on Monad Testnet."}),O&&(0,a.jsx)("div",{className:"p-4 bg-red-50 border border-red-200 rounded-lg mt-4 max-w-xs mx-auto",children:(0,a.jsx)("p",{className:"text-sm text-red-600",children:O})})]})})}},2280:function(e,s,t){"use strict";t.d(s,{jY:function(){return l},sz:function(){return a}});let a=(0,t(5597).a)({id:10143,name:"Monad Testnet",nativeCurrency:{name:"MON",symbol:"MON",decimals:18},rpcUrls:{default:{http:["https://testnet-rpc.monad.xyz"]},public:{http:["https://testnet-rpc.monad.xyz"]}},blockExplorers:{default:{name:"Monad Explorer",url:"https://testnet.monadexplorer.com"}}}),l={BASE_URL:"https://api.farcaster.xyz/v2",USERNAME_RESOLUTION:"/user-by-username"}}},function(e){e.O(0,[66,43,971,69,744],function(){return e(e.s=1367)}),_N_E=e.O()}]);