"use strict";exports.id=2956,exports.ids=[2956],exports.modules={62956:(e,a,t)=>{t.d(a,{offchainLookup:()=>w,offchainLookupSignature:()=>m});var r=t(53208),s=t(2045),n=t(38198),o=t(78891);class c extends n.G{constructor({callbackSelector:e,cause:a,data:t,extraData:r,sender:s,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.Gr)(e)}`)],`  Sender: ${s}`,`  Data: ${t}`,`  Callback selector: ${e}`,`  Extra data: ${r}`].flat()}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"OffchainLookupError"})}}class i extends n.G{constructor({result:e,url:a}){super("Offchain gateway response is malformed. Response data must be a hex value.",{metaMessages:[`Gateway URL: ${(0,o.Gr)(a)}`,`Response: ${(0,s.P)(e)}`]}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"OffchainLookupResponseMalformedError"})}}class d extends n.G{constructor({sender:e,to:a}){super("Reverted sender address does not match target contract address (`to`).",{metaMessages:[`Contract address: ${a}`,`OffchainLookup sender address: ${e}`]}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"OffchainLookupSenderMismatchError"})}}var l=t(57788),u=t(97684),f=t(57009),p=t(14574),h=t(42995),y=t(18349);let m="0x556f1830",b={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 w(e,{blockNumber:a,blockTag:t,data:s,to:n}){let{args:o}=(0,u.p)({data:s,abi:[b]}),[i,l,y,m,w]=o;try{if(!(0,p.E)(n,i))throw new d({sender:i,to:n});let s=await g({data:y,sender:i,urls:l}),{data:o}=await (0,r.R)(e,{blockNumber:a,blockTag:t,data:(0,h.zo)([m,(0,f.E)([{type:"bytes"},{type:"bytes"}],[s,w])]),to:n});return o}catch(e){throw new c({callbackSelector:m,cause:e,data:s,extraData:w,sender:i,urls:l})}}async function g({data:e,sender:a,urls:t}){let r=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;try{let t;let n=await fetch(o.replace("{sender}",a).replace("{data}",e),{body:JSON.stringify(d),method:c});if(t=n.headers.get("Content-Type")?.startsWith("application/json")?(await n.json()).data:await n.text(),!n.ok){r=new l.Gg({body:d,details:t?.error?(0,s.P)(t.error):n.statusText,headers:n.headers,status:n.status,url:o});continue}if(!(0,y.v)(t)){r=new i({result:t,url:o});continue}return t}catch(e){r=new l.Gg({body:d,details:e.message,url:o})}}throw r}}};