"use strict";(globalThis.webpackChunk_clerk_clerk_js=globalThis.webpackChunk_clerk_clerk_js||[]).push([["279"],{3746:function(e,a,t){t.d(a,{offchainLookupSignature:()=>m,offchainLookup:()=>g});var s=t(2721),r=t(2222),n=t(2937),o=t(8308);class c extends n.C{constructor({callbackSelector:e,cause:a,data:t,extraData:s,sender:r,urls:n}){super(a.shortMessage||"An error occurred while fetching for an offchain result.",{cause:a,metaMessages:[...a.metaMessages||[],a.metaMessages?.length?"":[],"Offchain Gateway Call:",n&&["  Gateway URL(s):",...n.map(e=>`    ${(0,o.I)(e)}`)],`  Sender: ${r}`,`  Data: ${t}`,`  Callback selector: ${e}`,`  Extra data: ${s}`].flat(),name:"OffchainLookupError"})}}class i extends n.C{constructor({result:e,url:a}){super("Offchain gateway response is malformed. Response data must be a hex value.",{metaMessages:[`Gateway URL: ${(0,o.I)(a)}`,`Response: ${(0,r.A)(e)}`],name:"OffchainLookupResponseMalformedError"})}}class d extends n.C{constructor({sender:e,to:a}){super("Reverted sender address does not match target contract address (`to`).",{metaMessages:[`Contract address: ${a}`,`OffchainLookup sender address: ${e}`],name:"OffchainLookupSenderMismatchError"})}}var l=t(2652),u=t(995),f=t(8478),p=t(4366),h=t(3778),y=t(9681),w=t(1209);let m="0x556f1830",k={name:"OffchainLookup",type:"error",inputs:[{name:"sender",type:"address"},{name:"urls",type:"string[]"},{name:"callData",type:"bytes"},{name:"callbackFunction",type:"bytes4"},{name:"extraData",type:"bytes"}]};async function g(e,{blockNumber:a,blockTag:t,data:r,to:n}){let{args:o}=(0,u.W)({data:r,abi:[k]}),[i,l,y,m,g]=o,{ccipRead:C}=e,O=C&&"function"==typeof C?.request?C.request:b;try{if(!(0,p.h)(n,i))throw new d({sender:i,to:n});let r=l.includes(w.J)?await (0,w.X)({data:y,ccipRequest:O}):await O({data:y,sender:i,urls:l}),{data:o}=await (0,s.T)(e,{blockNumber:a,blockTag:t,data:(0,h.xW)([m,(0,f.h)([{type:"bytes"},{type:"bytes"}],[r,g])]),to:n});return o}catch(e){throw new c({callbackSelector:m,cause:e,data:r,extraData:g,sender:i,urls:l})}}async function b({data:e,sender:a,urls:t}){let s=Error("An unknown error occurred.");for(let n=0;n<t.length;n++){let o=t[n],c=o.includes("{data}")?"GET":"POST",d="POST"===c?{data:e,sender:a}:void 0,u="POST"===c?{"Content-Type":"application/json"}:{};try{let t,n=await fetch(o.replace("{sender}",a.toLowerCase()).replace("{data}",e),{body:JSON.stringify(d),headers:u,method:c});if(t=n.headers.get("Content-Type")?.startsWith("application/json")?(await n.json()).data:await n.text(),!n.ok){s=new l.Ci({body:d,details:t?.error?(0,r.A)(t.error):n.statusText,headers:n.headers,status:n.status,url:o});continue}if(!(0,y.q)(t)){s=new i({result:t,url:o});continue}return t}catch(e){s=new l.Ci({body:d,details:e.message,url:o})}}throw s}}}]);