@imtbl/orderbook 2.17.2-alpha.1 → 2.17.2-alpha.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,11 +1,11 @@
1
1
  import { track } from '@imtbl/metrics';
2
- import st from 'axios';
3
- import at from 'form-data';
2
+ import ot from 'axios';
3
+ import dt from 'form-data';
4
4
  import { zeroPadValue, FetchRequest, JsonRpcProvider, JsonRpcSigner, toBeHex, ZeroHash, TypedDataEncoder, keccak256, toUtf8Bytes, concat, ZeroAddress, AbiCoder } from 'ethers';
5
5
  import { MerkleTree } from 'merkletreejs';
6
6
  import { Environment } from '@imtbl/config';
7
7
  import { Seaport } from '@opensea/seaport-js';
8
8
 
9
- var re={},it=!1;function Jt(){if(it)return re;it=!0,re.byteLength=f,re.toByteArray=h,re.fromByteArray=y;for(var r=[],i=[],s=typeof Uint8Array<"u"?Uint8Array:Array,a="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",p=0,u=a.length;p<u;++p)r[p]=a[p],i[a.charCodeAt(p)]=p;i[45]=62,i[95]=63;function o(C){var I=C.length;if(I%4>0)throw new Error("Invalid string. Length must be a multiple of 4");var _=C.indexOf("=");_===-1&&(_=I);var S=_===I?0:4-_%4;return [_,S]}function f(C){var I=o(C),_=I[0],S=I[1];return (_+S)*3/4-S}function E(C,I,_){return (I+_)*3/4-_}function h(C){var I,_=o(C),S=_[0],F=_[1],P=new s(E(C,S,F)),v=0,H=F>0?S-4:S,k;for(k=0;k<H;k+=4)I=i[C.charCodeAt(k)]<<18|i[C.charCodeAt(k+1)]<<12|i[C.charCodeAt(k+2)]<<6|i[C.charCodeAt(k+3)],P[v++]=I>>16&255,P[v++]=I>>8&255,P[v++]=I&255;return F===2&&(I=i[C.charCodeAt(k)]<<2|i[C.charCodeAt(k+1)]>>4,P[v++]=I&255),F===1&&(I=i[C.charCodeAt(k)]<<10|i[C.charCodeAt(k+1)]<<4|i[C.charCodeAt(k+2)]>>2,P[v++]=I>>8&255,P[v++]=I&255),P}function g(C){return r[C>>18&63]+r[C>>12&63]+r[C>>6&63]+r[C&63]}function R(C,I,_){for(var S,F=[],P=I;P<_;P+=3)S=(C[P]<<16&16711680)+(C[P+1]<<8&65280)+(C[P+2]&255),F.push(g(S));return F.join("")}function y(C){for(var I,_=C.length,S=_%3,F=[],P=16383,v=0,H=_-S;v<H;v+=P)F.push(R(C,v,v+P>H?H:v+P));return S===1?(I=C[_-1],F.push(r[I>>2]+r[I<<4&63]+"==")):S===2&&(I=(C[_-2]<<8)+C[_-1],F.push(r[I>>10]+r[I>>4&63]+r[I<<2&63]+"=")),F.join("")}return re}var fe={},nt=!1;function Xt(){if(nt)return fe;nt=!0;return fe.read=function(r,i,s,a,p){var u,o,f=p*8-a-1,E=(1<<f)-1,h=E>>1,g=-7,R=s?p-1:0,y=s?-1:1,C=r[i+R];for(R+=y,u=C&(1<<-g)-1,C>>=-g,g+=f;g>0;u=u*256+r[i+R],R+=y,g-=8);for(o=u&(1<<-g)-1,u>>=-g,g+=a;g>0;o=o*256+r[i+R],R+=y,g-=8);if(u===0)u=1-h;else {if(u===E)return o?NaN:(C?-1:1)*(1/0);o=o+Math.pow(2,a),u=u-h;}return (C?-1:1)*o*Math.pow(2,u-a)},fe.write=function(r,i,s,a,p,u){var o,f,E,h=u*8-p-1,g=(1<<h)-1,R=g>>1,y=p===23?Math.pow(2,-24)-Math.pow(2,-77):0,C=a?0:u-1,I=a?1:-1,_=i<0||i===0&&1/i<0?1:0;for(i=Math.abs(i),isNaN(i)||i===1/0?(f=isNaN(i)?1:0,o=g):(o=Math.floor(Math.log(i)/Math.LN2),i*(E=Math.pow(2,-o))<1&&(o--,E*=2),o+R>=1?i+=y/E:i+=y*Math.pow(2,1-R),i*E>=2&&(o++,E/=2),o+R>=g?(f=0,o=g):o+R>=1?(f=(i*E-1)*Math.pow(2,p),o=o+R):(f=i*Math.pow(2,R-1)*Math.pow(2,p),o=0));p>=8;r[s+C]=f&255,C+=I,f/=256,p-=8);for(o=o<<p|f,h+=p;h>0;r[s+C]=o&255,C+=I,o/=256,h-=8);r[s+C-I]|=_*128;},fe}var j={},ot=!1;function Zt(){if(ot)return j;ot=!0;let r=Jt(),i=Xt(),s=typeof Symbol=="function"&&typeof Symbol.for=="function"?Symbol.for("nodejs.util.inspect.custom"):null;j.Buffer=o,j.SlowBuffer=F,j.INSPECT_MAX_BYTES=50;let a=2147483647;j.kMaxLength=a,o.TYPED_ARRAY_SUPPORT=p(),!o.TYPED_ARRAY_SUPPORT&&typeof console<"u"&&typeof console.error=="function"&&console.error("This browser lacks typed array (Uint8Array) support which is required by `buffer` v5.x. Use `buffer` v4.x if you require old browser support.");function p(){try{let n=new Uint8Array(1),e={foo:function(){return 42}};return Object.setPrototypeOf(e,Uint8Array.prototype),Object.setPrototypeOf(n,e),n.foo()===42}catch{return !1}}Object.defineProperty(o.prototype,"parent",{enumerable:!0,get:function(){if(o.isBuffer(this))return this.buffer}}),Object.defineProperty(o.prototype,"offset",{enumerable:!0,get:function(){if(o.isBuffer(this))return this.byteOffset}});function u(n){if(n>a)throw new RangeError('The value "'+n+'" is invalid for option "size"');let e=new Uint8Array(n);return Object.setPrototypeOf(e,o.prototype),e}function o(n,e,t){if(typeof n=="number"){if(typeof e=="string")throw new TypeError('The "string" argument must be of type string. Received type number');return g(n)}return f(n,e,t)}o.poolSize=8192;function f(n,e,t){if(typeof n=="string")return R(n,e);if(ArrayBuffer.isView(n))return C(n);if(n==null)throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof n);if(M(n,ArrayBuffer)||n&&M(n.buffer,ArrayBuffer)||typeof SharedArrayBuffer<"u"&&(M(n,SharedArrayBuffer)||n&&M(n.buffer,SharedArrayBuffer)))return I(n,e,t);if(typeof n=="number")throw new TypeError('The "value" argument must not be of type number. Received type number');let l=n.valueOf&&n.valueOf();if(l!=null&&l!==n)return o.from(l,e,t);let d=_(n);if(d)return d;if(typeof Symbol<"u"&&Symbol.toPrimitive!=null&&typeof n[Symbol.toPrimitive]=="function")return o.from(n[Symbol.toPrimitive]("string"),e,t);throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof n)}o.from=function(n,e,t){return f(n,e,t)},Object.setPrototypeOf(o.prototype,Uint8Array.prototype),Object.setPrototypeOf(o,Uint8Array);function E(n){if(typeof n!="number")throw new TypeError('"size" argument must be of type number');if(n<0)throw new RangeError('The value "'+n+'" is invalid for option "size"')}function h(n,e,t){return E(n),n<=0?u(n):e!==void 0?typeof t=="string"?u(n).fill(e,t):u(n).fill(e):u(n)}o.alloc=function(n,e,t){return h(n,e,t)};function g(n){return E(n),u(n<0?0:S(n)|0)}o.allocUnsafe=function(n){return g(n)},o.allocUnsafeSlow=function(n){return g(n)};function R(n,e){if((typeof e!="string"||e==="")&&(e="utf8"),!o.isEncoding(e))throw new TypeError("Unknown encoding: "+e);let t=P(n,e)|0,l=u(t),d=l.write(n,e);return d!==t&&(l=l.slice(0,d)),l}function y(n){let e=n.length<0?0:S(n.length)|0,t=u(e);for(let l=0;l<e;l+=1)t[l]=n[l]&255;return t}function C(n){if(M(n,Uint8Array)){let e=new Uint8Array(n);return I(e.buffer,e.byteOffset,e.byteLength)}return y(n)}function I(n,e,t){if(e<0||n.byteLength<e)throw new RangeError('"offset" is outside of buffer bounds');if(n.byteLength<e+(t||0))throw new RangeError('"length" is outside of buffer bounds');let l;return e===void 0&&t===void 0?l=new Uint8Array(n):t===void 0?l=new Uint8Array(n,e):l=new Uint8Array(n,e,t),Object.setPrototypeOf(l,o.prototype),l}function _(n){if(o.isBuffer(n)){let e=S(n.length)|0,t=u(e);return t.length===0||n.copy(t,0,0,e),t}if(n.length!==void 0)return typeof n.length!="number"||De(n.length)?u(0):y(n);if(n.type==="Buffer"&&Array.isArray(n.data))return y(n.data)}function S(n){if(n>=a)throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+a.toString(16)+" bytes");return n|0}function F(n){return +n!=n&&(n=0),o.alloc(+n)}o.isBuffer=function(e){return e!=null&&e._isBuffer===!0&&e!==o.prototype},o.compare=function(e,t){if(M(e,Uint8Array)&&(e=o.from(e,e.offset,e.byteLength)),M(t,Uint8Array)&&(t=o.from(t,t.offset,t.byteLength)),!o.isBuffer(e)||!o.isBuffer(t))throw new TypeError('The "buf1", "buf2" arguments must be one of type Buffer or Uint8Array');if(e===t)return 0;let l=e.length,d=t.length;for(let c=0,m=Math.min(l,d);c<m;++c)if(e[c]!==t[c]){l=e[c],d=t[c];break}return l<d?-1:d<l?1:0},o.isEncoding=function(e){switch(String(e).toLowerCase()){case"hex":case"utf8":case"utf-8":case"ascii":case"latin1":case"binary":case"base64":case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return !0;default:return !1}},o.concat=function(e,t){if(!Array.isArray(e))throw new TypeError('"list" argument must be an Array of Buffers');if(e.length===0)return o.alloc(0);let l;if(t===void 0)for(t=0,l=0;l<e.length;++l)t+=e[l].length;let d=o.allocUnsafe(t),c=0;for(l=0;l<e.length;++l){let m=e[l];if(M(m,Uint8Array))c+m.length>d.length?(o.isBuffer(m)||(m=o.from(m)),m.copy(d,c)):Uint8Array.prototype.set.call(d,m,c);else if(o.isBuffer(m))m.copy(d,c);else throw new TypeError('"list" argument must be an Array of Buffers');c+=m.length;}return d};function P(n,e){if(o.isBuffer(n))return n.length;if(ArrayBuffer.isView(n)||M(n,ArrayBuffer))return n.byteLength;if(typeof n!="string")throw new TypeError('The "string" argument must be one of type string, Buffer, or ArrayBuffer. Received type '+typeof n);let t=n.length,l=arguments.length>2&&arguments[2]===!0;if(!l&&t===0)return 0;let d=!1;for(;;)switch(e){case"ascii":case"latin1":case"binary":return t;case"utf8":case"utf-8":return ke(n).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return t*2;case"hex":return t>>>1;case"base64":return rt(n).length;default:if(d)return l?-1:ke(n).length;e=(""+e).toLowerCase(),d=!0;}}o.byteLength=P;function v(n,e,t){let l=!1;if((e===void 0||e<0)&&(e=0),e>this.length||((t===void 0||t>this.length)&&(t=this.length),t<=0)||(t>>>=0,e>>>=0,t<=e))return "";for(n||(n="utf8");;)switch(n){case"hex":return Mt(this,e,t);case"utf8":case"utf-8":return We(this,e,t);case"ascii":return Ut(this,e,t);case"latin1":case"binary":return Ht(this,e,t);case"base64":return vt(this,e,t);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return $t(this,e,t);default:if(l)throw new TypeError("Unknown encoding: "+n);n=(n+"").toLowerCase(),l=!0;}}o.prototype._isBuffer=!0;function H(n,e,t){let l=n[e];n[e]=n[t],n[t]=l;}o.prototype.swap16=function(){let e=this.length;if(e%2!==0)throw new RangeError("Buffer size must be a multiple of 16-bits");for(let t=0;t<e;t+=2)H(this,t,t+1);return this},o.prototype.swap32=function(){let e=this.length;if(e%4!==0)throw new RangeError("Buffer size must be a multiple of 32-bits");for(let t=0;t<e;t+=4)H(this,t,t+3),H(this,t+1,t+2);return this},o.prototype.swap64=function(){let e=this.length;if(e%8!==0)throw new RangeError("Buffer size must be a multiple of 64-bits");for(let t=0;t<e;t+=8)H(this,t,t+7),H(this,t+1,t+6),H(this,t+2,t+5),H(this,t+3,t+4);return this},o.prototype.toString=function(){let e=this.length;return e===0?"":arguments.length===0?We(this,0,e):v.apply(this,arguments)},o.prototype.toLocaleString=o.prototype.toString,o.prototype.equals=function(e){if(!o.isBuffer(e))throw new TypeError("Argument must be a Buffer");return this===e?!0:o.compare(this,e)===0},o.prototype.inspect=function(){let e="",t=j.INSPECT_MAX_BYTES;return e=this.toString("hex",0,t).replace(/(.{2})/g,"$1 ").trim(),this.length>t&&(e+=" ... "),"<Buffer "+e+">"},s&&(o.prototype[s]=o.prototype.inspect),o.prototype.compare=function(e,t,l,d,c){if(M(e,Uint8Array)&&(e=o.from(e,e.offset,e.byteLength)),!o.isBuffer(e))throw new TypeError('The "target" argument must be one of type Buffer or Uint8Array. Received type '+typeof e);if(t===void 0&&(t=0),l===void 0&&(l=e?e.length:0),d===void 0&&(d=0),c===void 0&&(c=this.length),t<0||l>e.length||d<0||c>this.length)throw new RangeError("out of range index");if(d>=c&&t>=l)return 0;if(d>=c)return -1;if(t>=l)return 1;if(t>>>=0,l>>>=0,d>>>=0,c>>>=0,this===e)return 0;let m=c-d,A=l-t,b=Math.min(m,A),w=this.slice(d,c),L=e.slice(t,l);for(let B=0;B<b;++B)if(w[B]!==L[B]){m=w[B],A=L[B];break}return m<A?-1:A<m?1:0};function k(n,e,t,l,d){if(n.length===0)return -1;if(typeof t=="string"?(l=t,t=0):t>2147483647?t=2147483647:t<-2147483648&&(t=-2147483648),t=+t,De(t)&&(t=d?0:n.length-1),t<0&&(t=n.length+t),t>=n.length){if(d)return -1;t=n.length-1;}else if(t<0)if(d)t=0;else return -1;if(typeof e=="string"&&(e=o.from(e,l)),o.isBuffer(e))return e.length===0?-1:je(n,e,t,l,d);if(typeof e=="number")return e=e&255,typeof Uint8Array.prototype.indexOf=="function"?d?Uint8Array.prototype.indexOf.call(n,e,t):Uint8Array.prototype.lastIndexOf.call(n,e,t):je(n,[e],t,l,d);throw new TypeError("val must be string, number or Buffer")}function je(n,e,t,l,d){let c=1,m=n.length,A=e.length;if(l!==void 0&&(l=String(l).toLowerCase(),l==="ucs2"||l==="ucs-2"||l==="utf16le"||l==="utf-16le")){if(n.length<2||e.length<2)return -1;c=2,m/=2,A/=2,t/=2;}function b(L,B){return c===1?L[B]:L.readUInt16BE(B*c)}let w;if(d){let L=-1;for(w=t;w<m;w++)if(b(n,w)===b(e,L===-1?0:w-L)){if(L===-1&&(L=w),w-L+1===A)return L*c}else L!==-1&&(w-=w-L),L=-1;}else for(t+A>m&&(t=m-A),w=t;w>=0;w--){let L=!0;for(let B=0;B<A;B++)if(b(n,w+B)!==b(e,B)){L=!1;break}if(L)return w}return -1}o.prototype.includes=function(e,t,l){return this.indexOf(e,t,l)!==-1},o.prototype.indexOf=function(e,t,l){return k(this,e,t,l,!0)},o.prototype.lastIndexOf=function(e,t,l){return k(this,e,t,l,!1)};function xt(n,e,t,l){t=Number(t)||0;let d=n.length-t;l?(l=Number(l),l>d&&(l=d)):l=d;let c=e.length;l>c/2&&(l=c/2);let m;for(m=0;m<l;++m){let A=parseInt(e.substr(m*2,2),16);if(De(A))return m;n[t+m]=A;}return m}function Nt(n,e,t,l){return me(ke(e,n.length-t),n,t,l)}function kt(n,e,t,l){return me(jt(e),n,t,l)}function Dt(n,e,t,l){return me(rt(e),n,t,l)}function Ft(n,e,t,l){return me(Wt(e,n.length-t),n,t,l)}o.prototype.write=function(e,t,l,d){if(t===void 0)d="utf8",l=this.length,t=0;else if(l===void 0&&typeof t=="string")d=t,l=this.length,t=0;else if(isFinite(t))t=t>>>0,isFinite(l)?(l=l>>>0,d===void 0&&(d="utf8")):(d=l,l=void 0);else throw new Error("Buffer.write(string, encoding, offset[, length]) is no longer supported");let c=this.length-t;if((l===void 0||l>c)&&(l=c),e.length>0&&(l<0||t<0)||t>this.length)throw new RangeError("Attempt to write outside buffer bounds");d||(d="utf8");let m=!1;for(;;)switch(d){case"hex":return xt(this,e,t,l);case"utf8":case"utf-8":return Nt(this,e,t,l);case"ascii":case"latin1":case"binary":return kt(this,e,t,l);case"base64":return Dt(this,e,t,l);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return Ft(this,e,t,l);default:if(m)throw new TypeError("Unknown encoding: "+d);d=(""+d).toLowerCase(),m=!0;}},o.prototype.toJSON=function(){return {type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};function vt(n,e,t){return e===0&&t===n.length?r.fromByteArray(n):r.fromByteArray(n.slice(e,t))}function We(n,e,t){t=Math.min(n.length,t);let l=[],d=e;for(;d<t;){let c=n[d],m=null,A=c>239?4:c>223?3:c>191?2:1;if(d+A<=t){let b,w,L,B;switch(A){case 1:c<128&&(m=c);break;case 2:b=n[d+1],(b&192)===128&&(B=(c&31)<<6|b&63,B>127&&(m=B));break;case 3:b=n[d+1],w=n[d+2],(b&192)===128&&(w&192)===128&&(B=(c&15)<<12|(b&63)<<6|w&63,B>2047&&(B<55296||B>57343)&&(m=B));break;case 4:b=n[d+1],w=n[d+2],L=n[d+3],(b&192)===128&&(w&192)===128&&(L&192)===128&&(B=(c&15)<<18|(b&63)<<12|(w&63)<<6|L&63,B>65535&&B<1114112&&(m=B));}}m===null?(m=65533,A=1):m>65535&&(m-=65536,l.push(m>>>10&1023|55296),m=56320|m&1023),l.push(m),d+=A;}return qt(l)}let Ye=4096;function qt(n){let e=n.length;if(e<=Ye)return String.fromCharCode.apply(String,n);let t="",l=0;for(;l<e;)t+=String.fromCharCode.apply(String,n.slice(l,l+=Ye));return t}function Ut(n,e,t){let l="";t=Math.min(n.length,t);for(let d=e;d<t;++d)l+=String.fromCharCode(n[d]&127);return l}function Ht(n,e,t){let l="";t=Math.min(n.length,t);for(let d=e;d<t;++d)l+=String.fromCharCode(n[d]);return l}function Mt(n,e,t){let l=n.length;(!e||e<0)&&(e=0),(!t||t<0||t>l)&&(t=l);let d="";for(let c=e;c<t;++c)d+=Yt[n[c]];return d}function $t(n,e,t){let l=n.slice(e,t),d="";for(let c=0;c<l.length-1;c+=2)d+=String.fromCharCode(l[c]+l[c+1]*256);return d}o.prototype.slice=function(e,t){let l=this.length;e=~~e,t=t===void 0?l:~~t,e<0?(e+=l,e<0&&(e=0)):e>l&&(e=l),t<0?(t+=l,t<0&&(t=0)):t>l&&(t=l),t<e&&(t=e);let d=this.subarray(e,t);return Object.setPrototypeOf(d,o.prototype),d};function x(n,e,t){if(n%1!==0||n<0)throw new RangeError("offset is not uint");if(n+e>t)throw new RangeError("Trying to access beyond buffer length")}o.prototype.readUintLE=o.prototype.readUIntLE=function(e,t,l){e=e>>>0,t=t>>>0,l||x(e,t,this.length);let d=this[e],c=1,m=0;for(;++m<t&&(c*=256);)d+=this[e+m]*c;return d},o.prototype.readUintBE=o.prototype.readUIntBE=function(e,t,l){e=e>>>0,t=t>>>0,l||x(e,t,this.length);let d=this[e+--t],c=1;for(;t>0&&(c*=256);)d+=this[e+--t]*c;return d},o.prototype.readUint8=o.prototype.readUInt8=function(e,t){return e=e>>>0,t||x(e,1,this.length),this[e]},o.prototype.readUint16LE=o.prototype.readUInt16LE=function(e,t){return e=e>>>0,t||x(e,2,this.length),this[e]|this[e+1]<<8},o.prototype.readUint16BE=o.prototype.readUInt16BE=function(e,t){return e=e>>>0,t||x(e,2,this.length),this[e]<<8|this[e+1]},o.prototype.readUint32LE=o.prototype.readUInt32LE=function(e,t){return e=e>>>0,t||x(e,4,this.length),(this[e]|this[e+1]<<8|this[e+2]<<16)+this[e+3]*16777216},o.prototype.readUint32BE=o.prototype.readUInt32BE=function(e,t){return e=e>>>0,t||x(e,4,this.length),this[e]*16777216+(this[e+1]<<16|this[e+2]<<8|this[e+3])},o.prototype.readBigUInt64LE=$(function(e){e=e>>>0,J(e,"offset");let t=this[e],l=this[e+7];(t===void 0||l===void 0)&&te(e,this.length-8);let d=t+this[++e]*2**8+this[++e]*2**16+this[++e]*2**24,c=this[++e]+this[++e]*2**8+this[++e]*2**16+l*2**24;return BigInt(d)+(BigInt(c)<<BigInt(32))}),o.prototype.readBigUInt64BE=$(function(e){e=e>>>0,J(e,"offset");let t=this[e],l=this[e+7];(t===void 0||l===void 0)&&te(e,this.length-8);let d=t*2**24+this[++e]*2**16+this[++e]*2**8+this[++e],c=this[++e]*2**24+this[++e]*2**16+this[++e]*2**8+l;return (BigInt(d)<<BigInt(32))+BigInt(c)}),o.prototype.readIntLE=function(e,t,l){e=e>>>0,t=t>>>0,l||x(e,t,this.length);let d=this[e],c=1,m=0;for(;++m<t&&(c*=256);)d+=this[e+m]*c;return c*=128,d>=c&&(d-=Math.pow(2,8*t)),d},o.prototype.readIntBE=function(e,t,l){e=e>>>0,t=t>>>0,l||x(e,t,this.length);let d=t,c=1,m=this[e+--d];for(;d>0&&(c*=256);)m+=this[e+--d]*c;return c*=128,m>=c&&(m-=Math.pow(2,8*t)),m},o.prototype.readInt8=function(e,t){return e=e>>>0,t||x(e,1,this.length),this[e]&128?(255-this[e]+1)*-1:this[e]},o.prototype.readInt16LE=function(e,t){e=e>>>0,t||x(e,2,this.length);let l=this[e]|this[e+1]<<8;return l&32768?l|4294901760:l},o.prototype.readInt16BE=function(e,t){e=e>>>0,t||x(e,2,this.length);let l=this[e+1]|this[e]<<8;return l&32768?l|4294901760:l},o.prototype.readInt32LE=function(e,t){return e=e>>>0,t||x(e,4,this.length),this[e]|this[e+1]<<8|this[e+2]<<16|this[e+3]<<24},o.prototype.readInt32BE=function(e,t){return e=e>>>0,t||x(e,4,this.length),this[e]<<24|this[e+1]<<16|this[e+2]<<8|this[e+3]},o.prototype.readBigInt64LE=$(function(e){e=e>>>0,J(e,"offset");let t=this[e],l=this[e+7];(t===void 0||l===void 0)&&te(e,this.length-8);let d=this[e+4]+this[e+5]*2**8+this[e+6]*2**16+(l<<24);return (BigInt(d)<<BigInt(32))+BigInt(t+this[++e]*2**8+this[++e]*2**16+this[++e]*2**24)}),o.prototype.readBigInt64BE=$(function(e){e=e>>>0,J(e,"offset");let t=this[e],l=this[e+7];(t===void 0||l===void 0)&&te(e,this.length-8);let d=(t<<24)+this[++e]*2**16+this[++e]*2**8+this[++e];return (BigInt(d)<<BigInt(32))+BigInt(this[++e]*2**24+this[++e]*2**16+this[++e]*2**8+l)}),o.prototype.readFloatLE=function(e,t){return e=e>>>0,t||x(e,4,this.length),i.read(this,e,!0,23,4)},o.prototype.readFloatBE=function(e,t){return e=e>>>0,t||x(e,4,this.length),i.read(this,e,!1,23,4)},o.prototype.readDoubleLE=function(e,t){return e=e>>>0,t||x(e,8,this.length),i.read(this,e,!0,52,8)},o.prototype.readDoubleBE=function(e,t){return e=e>>>0,t||x(e,8,this.length),i.read(this,e,!1,52,8)};function q(n,e,t,l,d,c){if(!o.isBuffer(n))throw new TypeError('"buffer" argument must be a Buffer instance');if(e>d||e<c)throw new RangeError('"value" argument is out of bounds');if(t+l>n.length)throw new RangeError("Index out of range")}o.prototype.writeUintLE=o.prototype.writeUIntLE=function(e,t,l,d){if(e=+e,t=t>>>0,l=l>>>0,!d){let A=Math.pow(2,8*l)-1;q(this,e,t,l,A,0);}let c=1,m=0;for(this[t]=e&255;++m<l&&(c*=256);)this[t+m]=e/c&255;return t+l},o.prototype.writeUintBE=o.prototype.writeUIntBE=function(e,t,l,d){if(e=+e,t=t>>>0,l=l>>>0,!d){let A=Math.pow(2,8*l)-1;q(this,e,t,l,A,0);}let c=l-1,m=1;for(this[t+c]=e&255;--c>=0&&(m*=256);)this[t+c]=e/m&255;return t+l},o.prototype.writeUint8=o.prototype.writeUInt8=function(e,t,l){return e=+e,t=t>>>0,l||q(this,e,t,1,255,0),this[t]=e&255,t+1},o.prototype.writeUint16LE=o.prototype.writeUInt16LE=function(e,t,l){return e=+e,t=t>>>0,l||q(this,e,t,2,65535,0),this[t]=e&255,this[t+1]=e>>>8,t+2},o.prototype.writeUint16BE=o.prototype.writeUInt16BE=function(e,t,l){return e=+e,t=t>>>0,l||q(this,e,t,2,65535,0),this[t]=e>>>8,this[t+1]=e&255,t+2},o.prototype.writeUint32LE=o.prototype.writeUInt32LE=function(e,t,l){return e=+e,t=t>>>0,l||q(this,e,t,4,4294967295,0),this[t+3]=e>>>24,this[t+2]=e>>>16,this[t+1]=e>>>8,this[t]=e&255,t+4},o.prototype.writeUint32BE=o.prototype.writeUInt32BE=function(e,t,l){return e=+e,t=t>>>0,l||q(this,e,t,4,4294967295,0),this[t]=e>>>24,this[t+1]=e>>>16,this[t+2]=e>>>8,this[t+3]=e&255,t+4};function Ke(n,e,t,l,d){tt(e,l,d,n,t,7);let c=Number(e&BigInt(4294967295));n[t++]=c,c=c>>8,n[t++]=c,c=c>>8,n[t++]=c,c=c>>8,n[t++]=c;let m=Number(e>>BigInt(32)&BigInt(4294967295));return n[t++]=m,m=m>>8,n[t++]=m,m=m>>8,n[t++]=m,m=m>>8,n[t++]=m,t}function Je(n,e,t,l,d){tt(e,l,d,n,t,7);let c=Number(e&BigInt(4294967295));n[t+7]=c,c=c>>8,n[t+6]=c,c=c>>8,n[t+5]=c,c=c>>8,n[t+4]=c;let m=Number(e>>BigInt(32)&BigInt(4294967295));return n[t+3]=m,m=m>>8,n[t+2]=m,m=m>>8,n[t+1]=m,m=m>>8,n[t]=m,t+8}o.prototype.writeBigUInt64LE=$(function(e,t=0){return Ke(this,e,t,BigInt(0),BigInt("0xffffffffffffffff"))}),o.prototype.writeBigUInt64BE=$(function(e,t=0){return Je(this,e,t,BigInt(0),BigInt("0xffffffffffffffff"))}),o.prototype.writeIntLE=function(e,t,l,d){if(e=+e,t=t>>>0,!d){let b=Math.pow(2,8*l-1);q(this,e,t,l,b-1,-b);}let c=0,m=1,A=0;for(this[t]=e&255;++c<l&&(m*=256);)e<0&&A===0&&this[t+c-1]!==0&&(A=1),this[t+c]=(e/m>>0)-A&255;return t+l},o.prototype.writeIntBE=function(e,t,l,d){if(e=+e,t=t>>>0,!d){let b=Math.pow(2,8*l-1);q(this,e,t,l,b-1,-b);}let c=l-1,m=1,A=0;for(this[t+c]=e&255;--c>=0&&(m*=256);)e<0&&A===0&&this[t+c+1]!==0&&(A=1),this[t+c]=(e/m>>0)-A&255;return t+l},o.prototype.writeInt8=function(e,t,l){return e=+e,t=t>>>0,l||q(this,e,t,1,127,-128),e<0&&(e=255+e+1),this[t]=e&255,t+1},o.prototype.writeInt16LE=function(e,t,l){return e=+e,t=t>>>0,l||q(this,e,t,2,32767,-32768),this[t]=e&255,this[t+1]=e>>>8,t+2},o.prototype.writeInt16BE=function(e,t,l){return e=+e,t=t>>>0,l||q(this,e,t,2,32767,-32768),this[t]=e>>>8,this[t+1]=e&255,t+2},o.prototype.writeInt32LE=function(e,t,l){return e=+e,t=t>>>0,l||q(this,e,t,4,2147483647,-2147483648),this[t]=e&255,this[t+1]=e>>>8,this[t+2]=e>>>16,this[t+3]=e>>>24,t+4},o.prototype.writeInt32BE=function(e,t,l){return e=+e,t=t>>>0,l||q(this,e,t,4,2147483647,-2147483648),e<0&&(e=4294967295+e+1),this[t]=e>>>24,this[t+1]=e>>>16,this[t+2]=e>>>8,this[t+3]=e&255,t+4},o.prototype.writeBigInt64LE=$(function(e,t=0){return Ke(this,e,t,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))}),o.prototype.writeBigInt64BE=$(function(e,t=0){return Je(this,e,t,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))});function Xe(n,e,t,l,d,c){if(t+l>n.length)throw new RangeError("Index out of range");if(t<0)throw new RangeError("Index out of range")}function Ze(n,e,t,l,d){return e=+e,t=t>>>0,d||Xe(n,e,t,4),i.write(n,e,t,l,23,4),t+4}o.prototype.writeFloatLE=function(e,t,l){return Ze(this,e,t,!0,l)},o.prototype.writeFloatBE=function(e,t,l){return Ze(this,e,t,!1,l)};function Qe(n,e,t,l,d){return e=+e,t=t>>>0,d||Xe(n,e,t,8),i.write(n,e,t,l,52,8),t+8}o.prototype.writeDoubleLE=function(e,t,l){return Qe(this,e,t,!0,l)},o.prototype.writeDoubleBE=function(e,t,l){return Qe(this,e,t,!1,l)},o.prototype.copy=function(e,t,l,d){if(!o.isBuffer(e))throw new TypeError("argument should be a Buffer");if(l||(l=0),!d&&d!==0&&(d=this.length),t>=e.length&&(t=e.length),t||(t=0),d>0&&d<l&&(d=l),d===l||e.length===0||this.length===0)return 0;if(t<0)throw new RangeError("targetStart out of bounds");if(l<0||l>=this.length)throw new RangeError("Index out of range");if(d<0)throw new RangeError("sourceEnd out of bounds");d>this.length&&(d=this.length),e.length-t<d-l&&(d=e.length-t+l);let c=d-l;return this===e&&typeof Uint8Array.prototype.copyWithin=="function"?this.copyWithin(t,l,d):Uint8Array.prototype.set.call(e,this.subarray(l,d),t),c},o.prototype.fill=function(e,t,l,d){if(typeof e=="string"){if(typeof t=="string"?(d=t,t=0,l=this.length):typeof l=="string"&&(d=l,l=this.length),d!==void 0&&typeof d!="string")throw new TypeError("encoding must be a string");if(typeof d=="string"&&!o.isEncoding(d))throw new TypeError("Unknown encoding: "+d);if(e.length===1){let m=e.charCodeAt(0);(d==="utf8"&&m<128||d==="latin1")&&(e=m);}}else typeof e=="number"?e=e&255:typeof e=="boolean"&&(e=Number(e));if(t<0||this.length<t||this.length<l)throw new RangeError("Out of range index");if(l<=t)return this;t=t>>>0,l=l===void 0?this.length:l>>>0,e||(e=0);let c;if(typeof e=="number")for(c=t;c<l;++c)this[c]=e;else {let m=o.isBuffer(e)?e:o.from(e,d),A=m.length;if(A===0)throw new TypeError('The value "'+e+'" is invalid for argument "value"');for(c=0;c<l-t;++c)this[c+t]=m[c%A];}return this};let K={};function Ne(n,e,t){K[n]=class extends t{constructor(){super(),Object.defineProperty(this,"message",{value:e.apply(this,arguments),writable:!0,configurable:!0}),this.name=`${this.name} [${n}]`,this.stack,delete this.name;}get code(){return n}set code(d){Object.defineProperty(this,"code",{configurable:!0,enumerable:!0,value:d,writable:!0});}toString(){return `${this.name} [${n}]: ${this.message}`}};}Ne("ERR_BUFFER_OUT_OF_BOUNDS",function(n){return n?`${n} is outside of buffer bounds`:"Attempt to access memory outside buffer bounds"},RangeError),Ne("ERR_INVALID_ARG_TYPE",function(n,e){return `The "${n}" argument must be of type number. Received type ${typeof e}`},TypeError),Ne("ERR_OUT_OF_RANGE",function(n,e,t){let l=`The value of "${n}" is out of range.`,d=t;return Number.isInteger(t)&&Math.abs(t)>2**32?d=et(String(t)):typeof t=="bigint"&&(d=String(t),(t>BigInt(2)**BigInt(32)||t<-(BigInt(2)**BigInt(32)))&&(d=et(d)),d+="n"),l+=` It must be ${e}. Received ${d}`,l},RangeError);function et(n){let e="",t=n.length,l=n[0]==="-"?1:0;for(;t>=l+4;t-=3)e=`_${n.slice(t-3,t)}${e}`;return `${n.slice(0,t)}${e}`}function Vt(n,e,t){J(e,"offset"),(n[e]===void 0||n[e+t]===void 0)&&te(e,n.length-(t+1));}function tt(n,e,t,l,d,c){if(n>t||n<e){let m=typeof e=="bigint"?"n":"",A;throw e===0||e===BigInt(0)?A=`>= 0${m} and < 2${m} ** ${(c+1)*8}${m}`:A=`>= -(2${m} ** ${(c+1)*8-1}${m}) and < 2 ** ${(c+1)*8-1}${m}`,new K.ERR_OUT_OF_RANGE("value",A,n)}Vt(l,d,c);}function J(n,e){if(typeof n!="number")throw new K.ERR_INVALID_ARG_TYPE(e,"number",n)}function te(n,e,t){throw Math.floor(n)!==n?(J(n,t),new K.ERR_OUT_OF_RANGE("offset","an integer",n)):e<0?new K.ERR_BUFFER_OUT_OF_BOUNDS:new K.ERR_OUT_OF_RANGE("offset",`>= ${0} and <= ${e}`,n)}let zt=/[^+/0-9A-Za-z-_]/g;function Gt(n){if(n=n.split("=")[0],n=n.trim().replace(zt,""),n.length<2)return "";for(;n.length%4!==0;)n=n+"=";return n}function ke(n,e){e=e||1/0;let t,l=n.length,d=null,c=[];for(let m=0;m<l;++m){if(t=n.charCodeAt(m),t>55295&&t<57344){if(!d){if(t>56319){(e-=3)>-1&&c.push(239,191,189);continue}else if(m+1===l){(e-=3)>-1&&c.push(239,191,189);continue}d=t;continue}if(t<56320){(e-=3)>-1&&c.push(239,191,189),d=t;continue}t=(d-55296<<10|t-56320)+65536;}else d&&(e-=3)>-1&&c.push(239,191,189);if(d=null,t<128){if((e-=1)<0)break;c.push(t);}else if(t<2048){if((e-=2)<0)break;c.push(t>>6|192,t&63|128);}else if(t<65536){if((e-=3)<0)break;c.push(t>>12|224,t>>6&63|128,t&63|128);}else if(t<1114112){if((e-=4)<0)break;c.push(t>>18|240,t>>12&63|128,t>>6&63|128,t&63|128);}else throw new Error("Invalid code point")}return c}function jt(n){let e=[];for(let t=0;t<n.length;++t)e.push(n.charCodeAt(t)&255);return e}function Wt(n,e){let t,l,d,c=[];for(let m=0;m<n.length&&!((e-=2)<0);++m)t=n.charCodeAt(m),l=t>>8,d=t%256,c.push(d),c.push(l);return c}function rt(n){return r.toByteArray(Gt(n))}function me(n,e,t,l){let d;for(d=0;d<l&&!(d+t>=e.length||d>=n.length);++d)e[d+t]=n[d];return d}function M(n,e){return n instanceof e||n!=null&&n.constructor!=null&&n.constructor.name!=null&&n.constructor.name===e.name}function De(n){return n!==n}let Yt=function(){let n="0123456789abcdef",e=new Array(256);for(let t=0;t<16;++t){let l=t*16;for(let d=0;d<16;++d)e[l+d]=n[t]+n[d];}return e}();function $(n){return typeof BigInt>"u"?Kt:n}function Kt(){throw new Error("BigInt not supported")}return j}var W=Zt();W.Buffer;W.SlowBuffer;W.INSPECT_MAX_BYTES;W.kMaxLength;var T=W.Buffer;W.INSPECT_MAX_BYTES;W.kMaxLength;var ie=class{constructor(i){this.config=i;}};var X=class extends Error{url;status;statusText;body;request;constructor(i,s,a){super(a),this.name="ApiError",this.url=s.url,this.status=s.status,this.statusText=s.statusText,this.body=s.body,this.request=i;}};var he=class extends Error{constructor(i){super(i),this.name="CancelError";}get isCancelled(){return !0}},ne=class{[Symbol.toStringTag];_isResolved;_isRejected;_isCancelled;_cancelHandlers;_promise;_resolve;_reject;constructor(i){this._isResolved=!1,this._isRejected=!1,this._isCancelled=!1,this._cancelHandlers=[],this._promise=new Promise((s,a)=>{this._resolve=s,this._reject=a;let p=f=>{this._isResolved||this._isRejected||this._isCancelled||(this._isResolved=!0,this._resolve?.(f));},u=f=>{this._isResolved||this._isRejected||this._isCancelled||(this._isRejected=!0,this._reject?.(f));},o=f=>{this._isResolved||this._isRejected||this._isCancelled||this._cancelHandlers.push(f);};return Object.defineProperty(o,"isResolved",{get:()=>this._isResolved}),Object.defineProperty(o,"isRejected",{get:()=>this._isRejected}),Object.defineProperty(o,"isCancelled",{get:()=>this._isCancelled}),i(p,u,o)});}then(i,s){return this._promise.then(i,s)}catch(i){return this._promise.catch(i)}finally(i){return this._promise.finally(i)}cancel(){if(!(this._isResolved||this._isRejected||this._isCancelled)){if(this._isCancelled=!0,this._cancelHandlers.length)try{for(let i of this._cancelHandlers)i();}catch(i){console.warn("Cancellation threw an error",i);return}this._cancelHandlers.length=0,this._reject?.(new he("Request aborted"));}}get isCancelled(){return this._isCancelled}};var ve=r=>r!=null,Ce=r=>typeof r=="string",Fe=r=>Ce(r)&&r!=="",lt=r=>typeof r=="object"&&typeof r.type=="string"&&typeof r.stream=="function"&&typeof r.arrayBuffer=="function"&&typeof r.constructor=="function"&&typeof r.constructor.name=="string"&&/^(Blob|File)$/.test(r.constructor.name)&&/^(Blob|File)$/.test(r[Symbol.toStringTag]),Qt=r=>r instanceof at,er=r=>r>=200&&r<300,tr=r=>{try{return btoa(r)}catch{return T.from(r).toString("base64")}},rr=r=>{let i=[],s=(p,u)=>{i.push(`${encodeURIComponent(p)}=${encodeURIComponent(String(u))}`);},a=(p,u)=>{ve(u)&&(Array.isArray(u)?u.forEach(o=>{a(p,o);}):typeof u=="object"?Object.entries(u).forEach(([o,f])=>{a(`${p}[${o}]`,f);}):s(p,u));};return Object.entries(r).forEach(([p,u])=>{a(p,u);}),i.length>0?`?${i.join("&")}`:""},ir=(r,i)=>{let s=r.ENCODE_PATH||encodeURI,a=i.url.replace("{api-version}",r.VERSION).replace(/{(.*?)}/g,(u,o)=>i.path?.hasOwnProperty(o)?s(String(i.path[o])):u),p=`${r.BASE}${a}`;return i.query?`${p}${rr(i.query)}`:p},nr=r=>{if(r.formData){let i=new at,s=(a,p)=>{Ce(p)||lt(p)?i.append(a,p):i.append(a,JSON.stringify(p));};return Object.entries(r.formData).filter(([a,p])=>ve(p)).forEach(([a,p])=>{Array.isArray(p)?p.forEach(u=>s(a,u)):s(a,p);}),i}},ye=async(r,i)=>typeof i=="function"?i(r):i,or=async(r,i,s)=>{let a=await ye(i,r.TOKEN),p=await ye(i,r.USERNAME),u=await ye(i,r.PASSWORD),o=await ye(i,r.HEADERS),f=typeof s?.getHeaders=="function"&&s?.getHeaders()||{},E=Object.entries({Accept:"application/json",...o,...i.headers,...f}).filter(([h,g])=>ve(g)).reduce((h,[g,R])=>({...h,[g]:String(R)}),{});if(Fe(a)&&(E.Authorization=`Bearer ${a}`),Fe(p)&&Fe(u)){let h=tr(`${p}:${u}`);E.Authorization=`Basic ${h}`;}return i.body&&(i.mediaType?E["Content-Type"]=i.mediaType:lt(i.body)?E["Content-Type"]=i.body.type||"application/octet-stream":Ce(i.body)?E["Content-Type"]="text/plain":Qt(i.body)||(E["Content-Type"]="application/json")),E},sr=r=>{if(r.body)return r.body},ar=async(r,i,s,a,p,u,o)=>{let f=st.CancelToken.source(),E={url:s,headers:u,data:a??p,method:i.method,withCredentials:r.WITH_CREDENTIALS,cancelToken:f.token};o(()=>f.cancel("The user aborted a request."));try{return await st.request(E)}catch(h){let g=h;if(g.response)return g.response;throw h}},lr=(r,i)=>{if(i){let s=r.headers[i];if(Ce(s))return s}},dr=r=>{if(r.status!==204)return r.data},ur=(r,i)=>{let a={400:"Bad Request",401:"Unauthorized",403:"Forbidden",404:"Not Found",500:"Internal Server Error",502:"Bad Gateway",503:"Service Unavailable",...r.errors}[i.status];if(a)throw new X(r,i,a);if(!i.ok)throw new X(r,i,"Generic Error")},dt=(r,i)=>new ne(async(s,a,p)=>{try{let u=ir(r,i),o=nr(i),f=sr(i),E=await or(r,i,o);if(!p.isCancelled){let h=await ar(r,i,u,f,o,E,p),g=dr(h),R=lr(h,i.responseHeader),y={url:u,ok:er(h.status),status:h.status,statusText:h.statusText,body:R??g};ur(i,y),s(y.body);}}catch(u){a(u);}});var Ee=class extends ie{constructor(i){super(i);}request(i){return dt(this.config,i)}};var oe=class{constructor(i){this.httpRequest=i;}cancelOrders({chainName:i,requestBody:s}){return this.httpRequest.request({method:"POST",url:"/v1/chains/{chain_name}/orders/cancel",path:{chain_name:i},body:s,mediaType:"application/json",errors:{400:"Bad Request (400)",401:"Unauthorised Request (401)",404:"The specified resource was not found (404)",429:"Too Many Requests (429)",500:"Internal Server Error (500)",501:"Not Implemented Error (501)"}})}listListings({chainName:i,status:s,sellItemContractAddress:a,buyItemType:p,buyItemContractAddress:u,accountAddress:o,sellItemMetadataId:f,sellItemTokenId:E,fromUpdatedAt:h,pageSize:g,sortBy:R,sortDirection:y,pageCursor:C}){return this.httpRequest.request({method:"GET",url:"/v1/chains/{chain_name}/orders/listings",path:{chain_name:i},query:{status:s,sell_item_contract_address:a,buy_item_type:p,buy_item_contract_address:u,account_address:o,sell_item_metadata_id:f,sell_item_token_id:E,from_updated_at:h,page_size:g,sort_by:R,sort_direction:y,page_cursor:C},errors:{400:"Bad Request (400)",404:"The specified resource was not found (404)",500:"Internal Server Error (500)"}})}createListing({chainName:i,requestBody:s}){return this.httpRequest.request({method:"POST",url:"/v1/chains/{chain_name}/orders/listings",path:{chain_name:i},body:s,mediaType:"application/json",errors:{400:"Bad Request (400)",404:"The specified resource was not found (404)",500:"Internal Server Error (500)"}})}listBids({chainName:i,status:s,buyItemContractAddress:a,sellItemContractAddress:p,accountAddress:u,buyItemMetadataId:o,buyItemTokenId:f,fromUpdatedAt:E,pageSize:h,sortBy:g,sortDirection:R,pageCursor:y}){return this.httpRequest.request({method:"GET",url:"/v1/chains/{chain_name}/orders/bids",path:{chain_name:i},query:{status:s,buy_item_contract_address:a,sell_item_contract_address:p,account_address:u,buy_item_metadata_id:o,buy_item_token_id:f,from_updated_at:E,page_size:h,sort_by:g,sort_direction:R,page_cursor:y},errors:{400:"Bad Request (400)",404:"The specified resource was not found (404)",500:"Internal Server Error (500)"}})}createBid({chainName:i,requestBody:s}){return this.httpRequest.request({method:"POST",url:"/v1/chains/{chain_name}/orders/bids",path:{chain_name:i},body:s,mediaType:"application/json",errors:{400:"Bad Request (400)",404:"The specified resource was not found (404)",500:"Internal Server Error (500)",501:"Not Implemented Error (501)"}})}listCollectionBids({chainName:i,status:s,buyItemContractAddress:a,sellItemContractAddress:p,accountAddress:u,fromUpdatedAt:o,pageSize:f,sortBy:E,sortDirection:h,pageCursor:g}){return this.httpRequest.request({method:"GET",url:"/v1/chains/{chain_name}/orders/collection-bids",path:{chain_name:i},query:{status:s,buy_item_contract_address:a,sell_item_contract_address:p,account_address:u,from_updated_at:o,page_size:f,sort_by:E,sort_direction:h,page_cursor:g},errors:{400:"Bad Request (400)",404:"The specified resource was not found (404)",500:"Internal Server Error (500)"}})}createCollectionBid({chainName:i,requestBody:s}){return this.httpRequest.request({method:"POST",url:"/v1/chains/{chain_name}/orders/collection-bids",path:{chain_name:i},body:s,mediaType:"application/json",errors:{400:"Bad Request (400)",404:"The specified resource was not found (404)",500:"Internal Server Error (500)",501:"Not Implemented Error (501)"}})}listTraitBids({chainName:i,status:s,buyItemContractAddress:a,sellItemContractAddress:p,accountAddress:u,fromUpdatedAt:o,pageSize:f,sortBy:E,sortDirection:h,pageCursor:g}){return this.httpRequest.request({method:"GET",url:"/v1/chains/{chain_name}/orders/trait-bids",path:{chain_name:i},query:{status:s,buy_item_contract_address:a,sell_item_contract_address:p,account_address:u,from_updated_at:o,page_size:f,sort_by:E,sort_direction:h,page_cursor:g},errors:{400:"Bad Request (400)",404:"The specified resource was not found (404)",500:"Internal Server Error (500)"}})}createTraitBid({chainName:i,requestBody:s}){return this.httpRequest.request({method:"POST",url:"/v1/chains/{chain_name}/orders/trait-bids",path:{chain_name:i},body:s,mediaType:"application/json",errors:{400:"Bad Request (400)",404:"The specified resource was not found (404)",500:"Internal Server Error (500)",501:"Not Implemented Error (501)"}})}getListing({chainName:i,listingId:s}){return this.httpRequest.request({method:"GET",url:"/v1/chains/{chain_name}/orders/listings/{listing_id}",path:{chain_name:i,listing_id:s},errors:{400:"Bad Request (400)",404:"The specified resource was not found (404)",500:"Internal Server Error (500)"}})}getBid({chainName:i,bidId:s}){return this.httpRequest.request({method:"GET",url:"/v1/chains/{chain_name}/orders/bids/{bid_id}",path:{chain_name:i,bid_id:s},errors:{400:"Bad Request (400)",404:"The specified resource was not found (404)",500:"Internal Server Error (500)"}})}getCollectionBid({chainName:i,collectionBidId:s}){return this.httpRequest.request({method:"GET",url:"/v1/chains/{chain_name}/orders/collection-bids/{collection_bid_id}",path:{chain_name:i,collection_bid_id:s},errors:{400:"Bad Request (400)",404:"The specified resource was not found (404)",500:"Internal Server Error (500)"}})}getTraitBid({chainName:i,traitBidId:s}){return this.httpRequest.request({method:"GET",url:"/v1/chains/{chain_name}/orders/trait-bids/{trait_bid_id}",path:{chain_name:i,trait_bid_id:s},errors:{400:"Bad Request (400)",404:"The specified resource was not found (404)",500:"Internal Server Error (500)"}})}fulfillmentData({chainName:i,requestBody:s}){return this.httpRequest.request({method:"POST",url:"/v1/chains/{chain_name}/orders/fulfillment-data",path:{chain_name:i},body:s,mediaType:"application/json",errors:{400:"Bad Request (400)",404:"The specified resource was not found (404)",500:"Internal Server Error (500)"}})}listTrades({chainName:i,accountAddress:s,sellItemContractAddress:a,fromIndexedAt:p,pageSize:u,sortBy:o,sortDirection:f,pageCursor:E}){return this.httpRequest.request({method:"GET",url:"/v1/chains/{chain_name}/trades",path:{chain_name:i},query:{account_address:s,sell_item_contract_address:a,from_indexed_at:p,page_size:u,sort_by:o,sort_direction:f,page_cursor:E},errors:{400:"Bad Request (400)",404:"The specified resource was not found (404)",500:"Internal Server Error (500)"}})}getTrade({chainName:i,tradeId:s}){return this.httpRequest.request({method:"GET",url:"/v1/chains/{chain_name}/trades/{trade_id}",path:{chain_name:i,trade_id:s},errors:{400:"Bad Request (400)",404:"The specified resource was not found (404)",500:"Internal Server Error (500)"}})}};var se=class{orders;request;constructor(i,s=Ee){this.request=new s({BASE:i?.BASE??"https://api.immutable.com",VERSION:i?.VERSION??"1.0.0",WITH_CREDENTIALS:i?.WITH_CREDENTIALS??!1,CREDENTIALS:i?.CREDENTIALS??"include",TOKEN:i?.TOKEN,USERNAME:i?.USERNAME,PASSWORD:i?.PASSWORD,HEADERS:i?.HEADERS,ENCODE_PATH:i?.ENCODE_PATH}),this.orders=new oe(this.request);}};var ut;(i=>{(u=>(u.ON_CHAIN="ON_CHAIN",u.OFF_CHAIN="OFF_CHAIN",u.UNDERFUNDED="UNDERFUNDED"))(i.cancellation_type||={});})(ut||={});var pt;(i=>{(a=>a.FILLED="FILLED")(i.reason_code||={});})(pt||={});var D;(i=>{(o=>(o.ROYALTY="ROYALTY",o.MAKER_ECOSYSTEM="MAKER_ECOSYSTEM",o.TAKER_ECOSYSTEM="TAKER_ECOSYSTEM",o.PROTOCOL="PROTOCOL"))(i.type||={});})(D||={});var N;(i=>{(o=>(o.LISTING="LISTING",o.BID="BID",o.COLLECTION_BID="COLLECTION_BID",o.TRAIT_BID="TRAIT_BID"))(i.type||={});})(N||={});var ge=(o=>(o.PENDING="PENDING",o.ACTIVE="ACTIVE",o.INACTIVE="INACTIVE",o.FILLED="FILLED",o.EXPIRED="EXPIRED",o.CANCELLED="CANCELLED",o))(ge||{});var V;(i=>{(p=>(p.FULL_RESTRICTED="FULL_RESTRICTED",p.PARTIAL_RESTRICTED="PARTIAL_RESTRICTED"))(i.order_type||={});})(V||={});function U(r){throw new Error("Unreachable")}function Y(r){if(r.type!==N.type.LISTING)throw new Error("Order type must be LISTING");let i=r.sell.map(a=>{if(a.type==="ERC721")return {type:"ERC721",contractAddress:a.contract_address,tokenId:a.token_id};if(a.type==="ERC1155")return {type:"ERC1155",contractAddress:a.contract_address,tokenId:a.token_id,amount:a.amount};throw new Error("Listing sell items must either ERC721 or ERC1155")}),s=r.buy.map(a=>{if(a.type==="NATIVE")return {type:"NATIVE",amount:a.amount};if(a.type==="ERC20")return {type:"ERC20",contractAddress:a.contract_address,amount:a.amount};throw new Error("Listing buy items must be either NATIVE or ERC20")});return {id:r.id,type:r.type,chain:r.chain,accountAddress:r.account_address,sell:i,buy:s,fees:r.fees.map(a=>({amount:a.amount,recipientAddress:a.recipient_address,type:a.type})),status:r.status,fillStatus:r.fill_status,startAt:r.start_at,endAt:r.end_at,salt:r.salt,signature:r.signature,orderHash:r.order_hash,protocolData:{orderType:r.protocol_data.order_type,counter:r.protocol_data.counter,seaportAddress:r.protocol_data.seaport_address,seaportVersion:r.protocol_data.seaport_version,zoneAddress:r.protocol_data.zone_address},createdAt:r.created_at,updatedAt:r.updated_at}}function ae(r){if(r.type!==N.type.BID)throw new Error("Order type must be BID");let i=r.sell.map(a=>{if(a.type==="ERC20")return {type:"ERC20",contractAddress:a.contract_address,amount:a.amount};throw new Error("Bid sell items must be ERC20")}),s=r.buy.map(a=>{if(a.type==="ERC721")return {type:"ERC721",contractAddress:a.contract_address,tokenId:a.token_id};if(a.type==="ERC1155")return {type:"ERC1155",contractAddress:a.contract_address,tokenId:a.token_id,amount:a.amount};throw new Error("Bid buy items must either ERC721 or ERC1155")});return {id:r.id,type:r.type,chain:r.chain,accountAddress:r.account_address,sell:i,buy:s,fees:r.fees.map(a=>({amount:a.amount,recipientAddress:a.recipient_address,type:a.type})),status:r.status,fillStatus:r.fill_status,startAt:r.start_at,endAt:r.end_at,salt:r.salt,signature:r.signature,orderHash:r.order_hash,protocolData:{orderType:r.protocol_data.order_type,counter:r.protocol_data.counter,seaportAddress:r.protocol_data.seaport_address,seaportVersion:r.protocol_data.seaport_version,zoneAddress:r.protocol_data.zone_address},createdAt:r.created_at,updatedAt:r.updated_at}}function pr(r){return r?.length?r.map(i=>({traitType:i.trait_type,values:[...i.values]})):[]}function le(r){if(r.type!==N.type.COLLECTION_BID)throw new Error("Order type must be COLLECTION_BID");let i=r.sell.map(a=>{if(a.type==="ERC20")return {type:"ERC20",contractAddress:a.contract_address,amount:a.amount};throw new Error("Collection bid sell items must be ERC20")}),s=r.buy.map(a=>{if(a.type==="ERC721_COLLECTION")return {type:"ERC721_COLLECTION",contractAddress:a.contract_address,amount:a.amount};if(a.type==="ERC1155_COLLECTION")return {type:"ERC1155_COLLECTION",contractAddress:a.contract_address,amount:a.amount};throw new Error("Collection bid buy items must either ERC721_COLLECTION or ERC1155_COLLECTION")});return {id:r.id,type:r.type,chain:r.chain,accountAddress:r.account_address,sell:i,buy:s,fees:r.fees.map(a=>({amount:a.amount,recipientAddress:a.recipient_address,type:a.type})),status:r.status,fillStatus:r.fill_status,startAt:r.start_at,endAt:r.end_at,salt:r.salt,signature:r.signature,orderHash:r.order_hash,protocolData:{orderType:r.protocol_data.order_type,counter:r.protocol_data.counter,seaportAddress:r.protocol_data.seaport_address,seaportVersion:r.protocol_data.seaport_version,zoneAddress:r.protocol_data.zone_address},createdAt:r.created_at,updatedAt:r.updated_at}}function de(r){if(r.type!==N.type.TRAIT_BID)throw new Error("Order type must be TRAIT_BID");let i=r.sell.map(a=>{if(a.type==="ERC20")return {type:"ERC20",contractAddress:a.contract_address,amount:a.amount};throw new Error("Trait bid sell items must be ERC20")}),s=r.buy.map(a=>{if(a.type==="ERC721_COLLECTION")return {type:"ERC721_COLLECTION",contractAddress:a.contract_address,amount:a.amount};if(a.type==="ERC1155_COLLECTION")return {type:"ERC1155_COLLECTION",contractAddress:a.contract_address,amount:a.amount};throw new Error("Trait bid buy items must either ERC721_COLLECTION or ERC1155_COLLECTION")});return {id:r.id,type:r.type,chain:r.chain,accountAddress:r.account_address,sell:i,buy:s,fees:r.fees.map(a=>({amount:a.amount,recipientAddress:a.recipient_address,type:a.type})),status:r.status,fillStatus:r.fill_status,startAt:r.start_at,endAt:r.end_at,salt:r.salt,signature:r.signature,orderHash:r.order_hash,protocolData:{orderType:r.protocol_data.order_type,counter:r.protocol_data.counter,seaportAddress:r.protocol_data.seaport_address,seaportVersion:r.protocol_data.seaport_version,zoneAddress:r.protocol_data.zone_address},createdAt:r.created_at,updatedAt:r.updated_at,traitCriteria:pr(r.trait_criteria)}}function ue(r){switch(r.type){case N.type.LISTING:return Y(r);case N.type.BID:return ae(r);case N.type.COLLECTION_BID:return le(r);case N.type.TRAIT_BID:return de(r);default:return U(r.type)}}function qe(r){let i=r.buy.map(a=>{if(a.type==="NATIVE")return {type:"NATIVE",amount:a.amount};if(a.type==="ERC20")return {type:"ERC20",contractAddress:a.contract_address,amount:a.amount};if(a.type==="ERC721")return {type:"ERC721",contractAddress:a.contract_address,tokenId:a.token_id};if(a.type==="ERC1155")return {type:"ERC1155",contractAddress:a.contract_address,tokenId:a.token_id,amount:a.amount};throw new Error("Buy items must be NATIVE, ERC20, ERC721 or ERC1155")}),s=r.sell.map(a=>{if(a.type==="ERC20")return {type:"ERC20",contractAddress:a.contract_address,amount:a.amount};if(a.type==="ERC721")return {type:"ERC721",contractAddress:a.contract_address,tokenId:a.token_id};if(a.type==="ERC1155")return {type:"ERC1155",contractAddress:a.contract_address,tokenId:a.token_id,amount:a.amount};throw new Error("Sell items must be ERC20, ERC721 or ERC1155")});return {id:r.id,orderId:r.order_id,buy:i,sell:s,buyerFees:r.buyer_fees.map(a=>({amount:a.amount,recipientAddress:a.recipient_address,type:a.type})),fees:r.fees.map(a=>({amount:a.amount,recipientAddress:a.recipient_address,type:a.type})),chain:r.chain,indexedAt:r.indexed_at,blockchainMetadata:{blockNumber:r.blockchain_metadata.block_number,logIndex:r.blockchain_metadata.log_index,transactionHash:r.blockchain_metadata.transaction_hash,transactionIndex:r.blockchain_metadata.transaction_index},buyerAddress:r.buyer_address,makerAddress:r.maker_address,sellerAddress:r.seller_address,takerAddress:r.taker_address}}function Z(r){return {nextCursor:r.next_cursor,previousCursor:r.previous_cursor}}var cr=(p=>(p[p.MAKER_ECOSYSTEM=D.type.MAKER_ECOSYSTEM]="MAKER_ECOSYSTEM",p[p.TAKER_ECOSYSTEM=D.type.TAKER_ECOSYSTEM]="TAKER_ECOSYSTEM",p[p.PROTOCOL=D.type.PROTOCOL]="PROTOCOL",p[p.ROYALTY=D.type.ROYALTY]="ROYALTY",p))(cr||{}),Ue=(s=>(s.TRANSACTION="TRANSACTION",s.SIGNABLE="SIGNABLE",s))(Ue||{}),ct=(a=>(a.APPROVAL="APPROVAL",a.FULFILL_ORDER="FULFILL_ORDER",a.CANCEL="CANCEL",a))(ct||{}),He=(a=>(a.CREATE_LISTING="CREATE_ORDER",a.CREATE_ORDER="CREATE_ORDER",a.OFF_CHAIN_CANCELLATION="OFF_CHAIN_CANCELLATION",a))(He||{});var Me="ImmutableSeaport",z="1.5",Re={OrderComponents:[{name:"offerer",type:"address"},{name:"zone",type:"address"},{name:"offer",type:"OfferItem[]"},{name:"consideration",type:"ConsiderationItem[]"},{name:"orderType",type:"uint8"},{name:"startTime",type:"uint256"},{name:"endTime",type:"uint256"},{name:"zoneHash",type:"bytes32"},{name:"salt",type:"uint256"},{name:"conduitKey",type:"bytes32"},{name:"counter",type:"uint256"}],OfferItem:[{name:"itemType",type:"uint8"},{name:"token",type:"address"},{name:"identifierOrCriteria",type:"uint256"},{name:"startAmount",type:"uint256"},{name:"endAmount",type:"uint256"}],ConsiderationItem:[{name:"itemType",type:"uint8"},{name:"token",type:"address"},{name:"identifierOrCriteria",type:"uint256"},{name:"startAmount",type:"uint256"},{name:"endAmount",type:"uint256"},{name:"recipient",type:"address"}]};var mr={integer:0,address:zeroPadValue("0x",20),bool:!1,bytes:"0x",string:""},$e=r=>r===void 0?!1:r!=null&&(["string","number"].includes(typeof r)&&BigInt(r)===0n||Array.isArray(r)&&r.every($e)||typeof r=="object"&&Object.values(r).every($e)||typeof r=="boolean"&&r===!1);function fr(r){let[,i]=r.match(/^bytes(\d+)$/)??[];return i?zeroPadValue("0x",parseInt(i)):(r.match(/^(u?)int(\d*)$/)&&(r="integer"),mr[r])}var Q=class r{constructor(i){this.types=i;for(let s in i){let a=this.getDefaultValue(s);if(this.defaultValues[s]=a,!$e(a))throw new Error(`Got non-empty value for type ${s} in default generator: ${a}`)}}defaultValues={};static from(i,s){let{defaultValues:a}=new r(i);return s?a[s]:a}getDefaultValue(i){if(this.defaultValues[i])return this.defaultValues[i];let s=fr(i);if(s!==void 0)return s;let a=i.match(/^(.*)(\x5b(\d*)\x5d)$/);if(a){let u=a[1],o=parseInt(a[3]);if(o>0){let f=this.getDefaultValue(u);return Array(o).fill(f)}return []}let p=this.types[i];if(p)return p.reduce((u,{name:o,type:f})=>({...u,[o]:this.getDefaultValue(f)}),{});throw new Error(`unknown type: ${i}`)}};var Er=(r,i)=>Array(r).fill(0).map((s,a)=>i(a)),Ve=(r,i)=>Er(Math.ceil(r.length/i),s=>r.slice(s*i,(s+1)*i)),ft=r=>toBeHex(r.toString("hex")),ee=r=>T.from(r.slice(2),"hex"),Ie=r=>ee(keccak256(r)),gr=r=>Ie(concat(r)),pe=(r,i,s)=>(i>r.length&&r.push(...Array(i-r.length).fill(s)),r),ht=(r,i=!0)=>{if(r.length===0)throw new Error("empty tree");let a=[r.map(p=>{let u=T.isBuffer(p)?p:ee(p);return i?Ie(u):u})];for(;a[a.length-1].length>1;)a.push(Rr(a[a.length-1]));return a[a.length-1][0]},Rr=r=>Ve(r,2).map(gr);var _r=(r,i)=>new MerkleTree(r.map(ee),Ie,{complete:!0,sort:!1,hashLeaves:!1,fillDefaultHash:ee(i)}),Br=(r,i,s=`0x${"ff".repeat(64)}`)=>concat([s,`0x${r.toString(16).padStart(6,"0")}`,AbiCoder.defaultAbiCoder().encode([`uint256[${i.length}]`],[i])]),Te=class{constructor(i,s,a,p,u){this.types=i;this.rootType=s;this.leafType=a;this.elements=p;this.depth=u;let o=TypedDataEncoder.from(i);this.encoder=o,this.leafHasher=f=>o.hashStruct(a,f),this.defaultNode=Q.from(i,a),this.defaultLeaf=this.leafHasher(this.defaultNode),this.tree=_r(this.getCompleteLeaves(),this.defaultLeaf);}tree;leafHasher;defaultNode;defaultLeaf;encoder;get completedSize(){return 2**this.depth}getCompleteElements(){let{elements:i}=this;return pe([...i],this.completedSize,this.defaultNode)}getCompleteLeaves(){let i=this.elements.map(this.leafHasher);return pe([...i],this.completedSize,this.defaultLeaf)}get root(){return this.tree.getHexRoot()}getProof(i){let a=this.getCompleteLeaves()[i],p=this.tree.getHexProof(a,i),u=this.tree.getHexRoot();return {leaf:a,proof:p,root:u}}getEncodedProofAndSignature(i,s){let{proof:a}=this.getProof(i);return Br(i,a,s)}getDataToSign(){let i=this.getCompleteElements();for(;i.length>2;)i=Ve(i,2);return i}add(i){this.elements.push(i);}getBulkOrderHash(){let i=this.encoder.hashStruct("BulkOrder",{tree:this.getDataToSign()}),s=this.getCompleteLeaves().map(ee),a=ft(ht(s,!1)),p=keccak256(toUtf8Bytes(this.encoder.types.BulkOrder[0].type));if(keccak256(concat([p,a]))!==i)throw new Error("expected derived bulk order hash to match");return i}};function wr(r){return {...Re,BulkOrder:[{name:"tree",type:`OrderComponents${"[2]".repeat(r)}`}]}}function br(r){return Math.max(Math.ceil(Math.log2(r)),1)}function Et(r,i=0,s=br(r.length+i)){let a=wr(s),p=Q.from(a,"OrderComponents"),u=[...r];return i>0&&(u=[...pe([],i,p),...r]),new Te(a,"BulkOrder","OrderComponents",u,s)}function It(r){if([0,1,2,3].includes(Number(r)))return Number(r);throw new Error(`Unknown order type ${r}`)}function Ae(r){if([0,1,2,3,4,5].includes(Number(r)))return Number(r);throw new Error(`Unknown item type ${r}`)}function Tt(r){let s=JSON.parse(r).message;return {...s,orderType:It(s.orderType),salt:toBeHex(BigInt(s.salt)),offer:s.offer.map(a=>({...a,itemType:Ae(a.itemType)})),consideration:s.consideration.map(a=>({...a,itemType:Ae(a.itemType)}))}}function At(r){let i=JSON.parse(r);return {components:i.message.tree.flat(1/0).filter(a=>a.offerer!=="0x0000000000000000000000000000000000000000").map(a=>({...a,orderType:It(a.orderType),salt:toBeHex(BigInt(a.salt)),offer:a.offer.map(p=>({...p,itemType:Ae(p.itemType)})),consideration:a.consideration.map(p=>({...p,itemType:Ae(p.itemType)}))})),types:i.types,value:i.message}}function Ot(r,i){let s=Et(i);return i.map((a,p)=>s.getEncodedProofAndSignature(p,r))}function Sr(r){switch(r.type){case"NATIVE":throw new Error("NATIVE items are not supported in the offer");case"ERC20":return {itemType:1 .valueOf(),token:r.contract_address,identifierOrCriteria:"0",startAmount:r.amount,endAmount:r.amount};case"ERC721":return {itemType:2 .valueOf(),token:r.contract_address,identifierOrCriteria:r.token_id,startAmount:"1",endAmount:"1"};case"ERC1155":return {itemType:3 .valueOf(),token:r.contract_address,identifierOrCriteria:r.token_id,startAmount:r.amount,endAmount:r.amount};case"ERC721_COLLECTION":throw new Error("ERC721_COLLECTION items are not supported in the offer");case"ERC1155_COLLECTION":throw new Error("ERC1155_COLLECTION items are not supported in the offer");default:return U()}}function Pr(r,i){switch(r.type){case"NATIVE":return {itemType:0 .valueOf(),startAmount:r.amount,endAmount:r.amount,token:ZeroAddress,identifierOrCriteria:"0",recipient:i};case"ERC20":return {itemType:1 .valueOf(),startAmount:r.amount,endAmount:r.amount,token:r.contract_address,identifierOrCriteria:"0",recipient:i};case"ERC721":return {itemType:2 .valueOf(),startAmount:"1",endAmount:"1",token:r.contract_address,identifierOrCriteria:r.token_id,recipient:i};case"ERC1155":return {itemType:3 .valueOf(),startAmount:r.amount,endAmount:r.amount,token:r.contract_address,identifierOrCriteria:r.token_id,recipient:i};case"ERC721_COLLECTION":return {itemType:4 .valueOf(),startAmount:r.amount,endAmount:r.amount,token:r.contract_address,identifierOrCriteria:"0",recipient:i};case"ERC1155_COLLECTION":return {itemType:5 .valueOf(),startAmount:r.amount,endAmount:r.amount,token:r.contract_address,identifierOrCriteria:"0",recipient:i};default:return U()}}function _e(r){let i=r.sell.map(Sr),s=r.buy.map(o=>Pr(o,r.account_address)),a=function(o){switch(o){case N.type.LISTING:return s[0];case N.type.BID:case N.type.COLLECTION_BID:case N.type.TRAIT_BID:return i[0];default:return U()}}(r.type),p=function(o){switch(o){case V.order_type.FULL_RESTRICTED:return 2;case V.order_type.PARTIAL_RESTRICTED:return 3;default:return U()}}(r.protocol_data.order_type),u=r.fees.map(o=>({amount:o.amount,itemType:a.itemType,recipient:o.recipient_address,token:a.token,identifierOrCriteria:a.identifierOrCriteria}));return {orderComponents:{offerer:r.account_address,zone:r.protocol_data.zone_address,offer:i,consideration:s,orderType:p.valueOf(),startTime:Math.round(new Date(r.start_at).getTime()/1e3).toString(),endTime:Math.round(new Date(r.end_at).getTime()/1e3).toString(),zoneHash:ZeroHash,salt:r.salt,conduitKey:ZeroHash,counter:r.protocol_data.counter,totalOriginalConsiderationItems:s.length},tips:u}}function G(r,i,s){return async()=>{let a=await r.buildTransaction(),p={to:a.to,from:s,type:a.type,maxFeePerGas:a.maxFeePerGas?BigInt(a.maxFeePerGas):void 0,maxPriorityFeePerGas:a.maxPriorityFeePerGas?BigInt(a.maxPriorityFeePerGas):void 0,value:a.value?BigInt(a.value):void 0,data:a.data,nonce:a.nonce,chainId:i};return p.gasLimit=BigInt(await r.estimateGas()),p.gasLimit+=p.gasLimit/BigInt(5),p}}function Bt(r){switch(r.type){case"ERC20":return {token:r.contractAddress,amount:r.amount};case"ERC721":return {itemType:2 .valueOf(),token:r.contractAddress,identifier:r.tokenId};case"ERC1155":return {itemType:3 .valueOf(),token:r.contractAddress,identifier:r.tokenId,amount:r.amount};default:return U()}}function wt(r,i){switch(r.type){case"NATIVE":return {amount:r.amount,recipient:i};case"ERC20":return {token:r.contractAddress,amount:r.amount,recipient:i};case"ERC721":return {itemType:2 .valueOf(),token:r.contractAddress,identifier:r.tokenId,recipient:i};case"ERC1155":return {itemType:3 .valueOf(),token:r.contractAddress,identifier:r.tokenId,amount:r.amount,recipient:i};case"ERC721_COLLECTION":return {itemType:2 .valueOf(),token:r.contractAddress,amount:r.amount,identifiers:[],recipient:i};case"ERC1155_COLLECTION":return {itemType:3 .valueOf(),token:r.contractAddress,amount:r.amount,identifiers:[],recipient:i};default:return U()}}var Be=class r{constructor(i,s,a,p,u){this.seaportLibFactory=i;this.provider=s;this.seaportContractAddress=a;this.zoneContractAddress=p;this.rateLimitingKey=u;}async prepareBulkSeaportOrders(i,s){let{actions:a}=await this.createSeaportOrders(i,s),p=a.filter(y=>y.type==="approval"),u=await this.provider.getNetwork(),o=p.map(y=>({type:"TRANSACTION",purpose:"APPROVAL",buildTransaction:G(y.transactionMethods,u.chainId,i)})),f=a.find(y=>y.type==="createBulk");if(!f)throw new Error("No create bulk order action found");let E=await f.getMessageToSign(),{components:h,types:g,value:R}=At(E);return o.push({type:"SIGNABLE",purpose:"CREATE_ORDER",message:await this.getTypedDataFromBulkOrderComponents(g,R)}),{actions:o,preparedOrders:h.map(y=>({orderComponents:y,orderHash:this.getSeaportLib().getOrderHash(y)}))}}async prepareSeaportOrder(i,s,a,p,u,o){let{actions:f}=await this.createSeaportOrder(i,s,a,p,u,o),E=[],h=f.find(C=>C.type==="approval");h&&E.push({type:"TRANSACTION",purpose:"APPROVAL",buildTransaction:G(h.transactionMethods,(await this.provider.getNetwork()).chainId,i)});let g=f.find(C=>C.type==="create");if(!g)throw new Error("No create order action found");let R=await g.getMessageToSign(),y=Tt(R);return E.push({type:"SIGNABLE",purpose:"CREATE_ORDER",message:await this.getTypedDataFromOrderComponents(y)}),{actions:E,orderComponents:y,orderHash:this.getSeaportLib().getOrderHash(y)}}async fulfillOrder(i,s,a,p,u){let{orderComponents:o,tips:f}=_e(i),E=this.getSeaportLib(i),h=(await this.provider.getNetwork()).chainId,g={order:{parameters:o,signature:i.signature},unitsToFill:p,extraData:a,tips:f};u&&(g.considerationCriteria=u);let{actions:R}=await E.fulfillOrders({accountAddress:s,fulfillOrderDetails:[g]}),y=[],C=R.filter(_=>_.type==="approval");C.length>0&&C.forEach(_=>{y.push({type:"TRANSACTION",buildTransaction:G(_.transactionMethods,h,s),purpose:"APPROVAL"});});let I=R.find(_=>_.type==="exchange");if(!I)throw new Error("No exchange action found");return y.push({type:"TRANSACTION",buildTransaction:G(I.transactionMethods,h,s),purpose:"FULFILL_ORDER"}),{actions:y,expiration:r.getExpirationISOTimeFromExtraData(a),order:ue(i)}}async fulfillBulkOrders(i,s){let a=i.map(h=>{let{orderComponents:g,tips:R}=_e(h.order),y={order:{parameters:g,signature:h.order.signature},unitsToFill:h.unitsToFill,extraData:h.extraData,tips:R};return h.considerationCriteria&&h.considerationCriteria.length>0&&(y.considerationCriteria=h.considerationCriteria),y}),{actions:p}=await this.getSeaportLib().fulfillOrders({fulfillOrderDetails:a,accountAddress:s}),u=[],o=p.filter(h=>h.type==="approval"),f=(await this.provider.getNetwork()).chainId;o.length>0&&o.forEach(h=>{u.push({type:"TRANSACTION",buildTransaction:G(h.transactionMethods,f,s),purpose:"APPROVAL"});});let E=p.find(h=>h.type==="exchange");if(!E)throw new Error("No exchange action found");return u.push({type:"TRANSACTION",buildTransaction:G(E.transactionMethods,(await this.provider.getNetwork()).chainId,s),purpose:"FULFILL_ORDER"}),{actions:u,expiration:a.map(h=>r.getExpirationISOTimeFromExtraData(h.extraData)).reduce((h,g)=>new Date(h)<new Date(g)?h:g)}}async cancelOrders(i,s){let a=i.map(o=>_e(o).orderComponents),u=await this.getSeaportLib(i[0]).cancelOrders(a,s);return {type:"TRANSACTION",buildTransaction:G(u,(await this.provider.getNetwork()).chainId,s),purpose:"CANCEL"}}createSeaportOrders(i,s){return this.getSeaportLib().createBulkOrders(s.map(p=>{let{offerItem:u,considerationItem:o,allowPartialFills:f,orderStart:E,orderExpiry:h}=p;return {allowPartialFills:f,offer:[Bt(u)],consideration:[wt(o,i)],startTime:(E.getTime()/1e3).toFixed(0),endTime:(h.getTime()/1e3).toFixed(0),zone:this.zoneContractAddress,restrictedByZone:!0}}),i)}createSeaportOrder(i,s,a,p,u,o){return this.getSeaportLib().createOrder({allowPartialFills:p,offer:[Bt(s)],consideration:[wt(a,i)],startTime:(u.getTime()/1e3).toFixed(0),endTime:(o.getTime()/1e3).toFixed(0),zone:this.zoneContractAddress,restrictedByZone:!0},i)}async getTypedDataFromBulkOrderComponents(i,s){delete i.EIP712Domain;let{chainId:a}=await this.provider.getNetwork();return {domain:{name:Me,version:z,chainId:a,verifyingContract:this.seaportContractAddress},types:i,value:s}}async getTypedDataFromOrderComponents(i){let{chainId:s}=await this.provider.getNetwork();return {domain:{name:Me,version:z,chainId:s,verifyingContract:this.seaportContractAddress},types:Re,value:i}}getSeaportLib(i){let s=i?.protocol_data?.seaport_address??this.seaportContractAddress;return this.seaportLibFactory.create(s)}static getExpirationISOTimeFromExtraData(i){let s=i.slice(44,60),a=parseInt(s,16);return new Date(a*1e3).toISOString()}};function we(r){switch(r.itemType){case 0:return {type:"NATIVE",amount:r.startAmount};case 1:return {type:"ERC20",contract_address:r.token,amount:r.startAmount};case 2:return {type:"ERC721",contract_address:r.token,token_id:r.identifierOrCriteria};case 3:return {type:"ERC1155",contract_address:r.token,token_id:r.identifierOrCriteria,amount:r.startAmount};case 4:return {type:"ERC721_COLLECTION",contract_address:r.token,amount:r.startAmount};case 5:return {type:"ERC1155_COLLECTION",contract_address:r.token,amount:r.startAmount};default:return U(r.itemType)}}function be(r){if(r.itemType!==1)throw new Error(`Expected ERC20 item, got ${r.itemType}`);return {type:"ERC20",contract_address:r.token,amount:r.startAmount}}function ze(r){switch(r.itemType){case 4:return {type:"ERC721_COLLECTION",contract_address:r.token,amount:r.startAmount};case 5:return {type:"ERC1155_COLLECTION",contract_address:r.token,amount:r.startAmount};case 1:case 0:case 2:case 3:throw new Error(`Unsupported item type ${r.itemType}`);default:return U(r.itemType)}}function ce(r){switch(r){case 2:return V.order_type.FULL_RESTRICTED;case 3:return V.order_type.PARTIAL_RESTRICTED;case 0:case 1:throw new Error(`Unsupported order type ${r}`);default:return U()}}var Le=class{constructor(i,s,a){this.orderbookService=i;this.chainName=s;this.seaportAddress=a;}async fulfillmentData(i){return this.orderbookService.fulfillmentData({chainName:this.chainName,requestBody:i})}async getListing(i){return this.orderbookService.getListing({chainName:this.chainName,listingId:i})}async getBid(i){return this.orderbookService.getBid({chainName:this.chainName,bidId:i})}async getCollectionBid(i){return this.orderbookService.getCollectionBid({chainName:this.chainName,collectionBidId:i})}async getTraitBid(i){return this.orderbookService.getTraitBid({chainName:this.chainName,traitBidId:i})}async getTrade(i){return this.orderbookService.getTrade({chainName:this.chainName,tradeId:i})}async listListings(i){return this.orderbookService.listListings({chainName:this.chainName,...i})}async listBids(i){return this.orderbookService.listBids({chainName:this.chainName,...i})}async listCollectionBids(i){return this.orderbookService.listCollectionBids({chainName:this.chainName,...i})}async listTraitBids(i){return this.orderbookService.listTraitBids({chainName:this.chainName,...i})}async listTrades(i){return this.orderbookService.listTrades({chainName:this.chainName,...i})}async cancelOrders(i,s,a){return this.orderbookService.cancelOrders({chainName:this.chainName,requestBody:{account_address:s,orders:i,signature:a}})}async createListing({orderHash:i,orderComponents:s,orderSignature:a,makerFees:p}){if(s.offer.length!==1)throw new Error("Only one item can be listed for a listing");if(s.consideration.length!==1)throw new Error("Only one item can be used as currency for a listing");if(![2,3].includes(s.offer[0].itemType))throw new Error("Only ERC721 / ERC1155 tokens can be listed");if(![0,1].includes(s.consideration[0].itemType))throw new Error("Only Native / ERC20 tokens can be used as currency items in a listing");return this.orderbookService.createListing({chainName:this.chainName,requestBody:{account_address:s.offerer,buy:s.consideration.map(we),fees:p.map(u=>({type:D.type.MAKER_ECOSYSTEM,amount:u.amount,recipient_address:u.recipientAddress})),end_at:new Date(parseInt(`${s.endTime.toString()}000`,10)).toISOString(),order_hash:i,protocol_data:{order_type:ce(s.orderType),zone_address:s.zone,seaport_address:this.seaportAddress,seaport_version:z,counter:s.counter.toString()},salt:s.salt,sell:s.offer.map(we),signature:a,start_at:new Date(parseInt(`${s.startTime.toString()}000`,10)).toISOString()}})}async createBid({orderHash:i,orderComponents:s,orderSignature:a,makerFees:p}){if(s.offer.length!==1)throw new Error("Only one item can be listed for a bid");if(s.consideration.length!==1)throw new Error("Only one item can be used as currency for a bid");if(1!==s.offer[0].itemType)throw new Error("Only ERC20 tokens can be used as the currency item in a bid");if(![2,3].includes(s.consideration[0].itemType))throw new Error("Only ERC721 / ERC1155 tokens can be bid against");return this.orderbookService.createBid({chainName:this.chainName,requestBody:{account_address:s.offerer,buy:s.consideration.map(we),fees:p.map(u=>({type:D.type.MAKER_ECOSYSTEM,amount:u.amount,recipient_address:u.recipientAddress})),end_at:new Date(parseInt(`${s.endTime.toString()}000`,10)).toISOString(),order_hash:i,protocol_data:{order_type:ce(s.orderType),zone_address:s.zone,seaport_address:this.seaportAddress,seaport_version:z,counter:s.counter.toString()},salt:s.salt,sell:s.offer.map(be),signature:a,start_at:new Date(parseInt(`${s.startTime.toString()}000`,10)).toISOString()}})}async createCollectionBid({orderHash:i,orderComponents:s,orderSignature:a,makerFees:p}){if(s.offer.length!==1)throw new Error("Only one item can be listed for a collection bid");if(s.consideration.length!==1)throw new Error("Only one item can be used as currency for a collection bid");if(1!==s.offer[0].itemType)throw new Error("Only ERC20 tokens can be used as the currency item in a collection bid");if(![4,5].includes(s.consideration[0].itemType))throw new Error("Only ERC721 / ERC1155 collection based tokens can be bid against");return this.orderbookService.createCollectionBid({chainName:this.chainName,requestBody:{account_address:s.offerer,buy:s.consideration.map(ze),fees:p.map(u=>({type:D.type.MAKER_ECOSYSTEM,amount:u.amount,recipient_address:u.recipientAddress})),end_at:new Date(parseInt(`${s.endTime.toString()}000`,10)).toISOString(),order_hash:i,protocol_data:{order_type:ce(s.orderType),zone_address:s.zone,seaport_address:this.seaportAddress,seaport_version:z,counter:s.counter.toString()},salt:s.salt,sell:s.offer.map(be),signature:a,start_at:new Date(parseInt(`${s.startTime.toString()}000`,10)).toISOString()}})}async createTraitBid({orderHash:i,orderComponents:s,orderSignature:a,makerFees:p,traitCriteria:u}){if(s.offer.length!==1)throw new Error("Only one item can be listed for a trait bid");if(s.consideration.length!==1)throw new Error("Only one item can be used as currency for a trait bid");if(1!==s.offer[0].itemType)throw new Error("Only ERC20 tokens can be used as the currency item in a trait bid");if(![4,5].includes(s.consideration[0].itemType))throw new Error("Only ERC721 / ERC1155 collection based tokens can be bid against");if(!u?.length)throw new Error("At least one trait criterion is required for a trait bid");return this.orderbookService.createTraitBid({chainName:this.chainName,requestBody:{account_address:s.offerer,buy:s.consideration.map(ze),fees:p.map(o=>({type:D.type.MAKER_ECOSYSTEM,amount:o.amount,recipient_address:o.recipientAddress})),end_at:new Date(parseInt(`${s.endTime.toString()}000`,10)).toISOString(),order_hash:i,protocol_data:{order_type:ce(s.orderType),zone_address:s.zone,seaport_address:this.seaportAddress,seaport_version:z,counter:s.counter.toString()},salt:s.salt,sell:s.offer.map(be),signature:a,start_at:new Date(parseInt(`${s.startTime.toString()}000`,10)).toISOString(),trait_criteria:u.map(o=>({trait_type:o.traitType,values:o.values}))}})}};var Se=class{constructor(i,s,a,p){this.chainName=s;this.seaportAddress=a;this.orderbookClient=new se({BASE:i,HEADERS:p?{"x-api-key":p}:void 0});}orderbookClient;create(){return new Le(this.orderbookClient.orders,this.chainName,this.seaportAddress)}};var kr="imtbl-zkevm-testnet",Dr="imtbl-zkevm-mainnet";function Pe(r,i){let s=new FetchRequest(r);return i&&s.setHeader("x-api-key",i),new JsonRpcProvider(s)}function Lt(r){switch(r.baseConfig.environment){case Environment.SANDBOX:return {seaportContractAddress:"0x7d117aA8BD6D31c4fa91722f246388f38ab1942c",zoneContractAddress:"0x1004f9615E79462c711Ff05a386BdbA91a7628C3",apiEndpoint:"https://api.sandbox.immutable.com",chainName:kr,provider:Pe("https://rpc.testnet.immutable.com",r.baseConfig.rateLimitingKey)};case Environment.PRODUCTION:return {seaportContractAddress:"0x6c12aD6F0bD274191075Eb2E78D7dA5ba6453424",zoneContractAddress:"0x1004f9615E79462c711Ff05a386BdbA91a7628C3",apiEndpoint:"https://api.immutable.com",chainName:Dr,provider:Pe("https://rpc.immutable.com",r.baseConfig.rateLimitingKey)};default:return null}}var xe=class{constructor(i,s){this.defaultSeaportContractAddress=i;this.provider=s;}create(i){let s=i??this.defaultSeaportContractAddress,a=this.provider;return a.getSigner=async function(u){u==null&&(u=0);let o=this.send("eth_accounts",[]);if(typeof u=="number"){let f=await o;if(u>=f.length)throw new Error("no such account");return new JsonRpcSigner(this,f[u])}return new JsonRpcSigner(this,u)},new Seaport(a,{balanceAndApprovalChecksOnOrderCreation:!0,overrides:{contractAddress:s}})}};var Ge=class r{apiClient;seaport;orderbookConfig;constructor(i){let a={...Lt(i),...i.overrides};if(i.overrides?.jsonRpcProviderUrl&&(a.provider=Pe(i.overrides?.jsonRpcProviderUrl,i.baseConfig.rateLimitingKey)),!a)throw new Error("Orderbook configuration not passed, please specify the environment under config.baseConfig.environment");this.orderbookConfig=a;let{apiEndpoint:p,chainName:u}=this.orderbookConfig;if(!p)throw new Error("API endpoint must be provided");this.apiClient=new Se(p,u,this.orderbookConfig.seaportContractAddress,i.baseConfig.rateLimitingKey).create();let o=new xe(this.orderbookConfig.seaportContractAddress,this.orderbookConfig.provider);this.seaport=new Be(o,this.orderbookConfig.provider,this.orderbookConfig.seaportContractAddress,this.orderbookConfig.zoneContractAddress,i.baseConfig.rateLimitingKey);}static defaultOrderExpiry(){return new Date(Date.now()+1e3*60*60*24*365*2)}config(){return this.orderbookConfig}async getListing(i){let s=await this.apiClient.getListing(i);return {result:Y(s.result)}}async getBid(i){let s=await this.apiClient.getBid(i);return {result:ae(s.result)}}async getCollectionBid(i){let s=await this.apiClient.getCollectionBid(i);return {result:le(s.result)}}async getTraitBid(i){let s=await this.apiClient.getTraitBid(i);return {result:de(s.result)}}async getTrade(i){let s=await this.apiClient.getTrade(i);return {result:qe(s.result)}}async listListings(i){let s=await this.apiClient.listListings(i);return {page:Z(s.page),result:s.result.map(Y)}}async listBids(i){let s=await this.apiClient.listBids(i);return {page:Z(s.page),result:s.result.map(ae)}}async listCollectionBids(i){let s=await this.apiClient.listCollectionBids(i);return {page:Z(s.page),result:s.result.map(le)}}async listTraitBids(i){let s=await this.apiClient.listTraitBids(i);return {page:Z(s.page),result:s.result.map(de)}}async listTrades(i){let s=await this.apiClient.listTrades(i);return {page:Z(s.page),result:s.result.map(qe)}}async prepareBulkListings({makerAddress:i,listingParams:s}){if(s.length>20)throw new Error("Bulk listing creation is limited to 20 orders");if(s.length===1){let o=await this.seaport.prepareSeaportOrder(i,s[0].sell,s[0].buy,s[0].sell.type==="ERC1155",s[0].orderStart||new Date,s[0].orderExpiry||r.defaultOrderExpiry());return {actions:o.actions,completeListings:async f=>{let E=await this.createListing({makerFees:s[0].makerFees,orderComponents:o.orderComponents,orderHash:o.orderHash,orderSignature:typeof f=="string"?f:f[0]});return {result:[{success:!0,orderHash:o.orderHash,order:E.result}]}}}}if(await this.orderbookConfig.provider.getCode(i)!=="0x"){track("orderbookmr","bulkListings",{walletType:"Passport",makerAddress:i,listingsCount:s.length});let o=await Promise.all(s.map(h=>this.seaport.prepareSeaportOrder(i,h.sell,h.buy,h.sell.type==="ERC1155",h.orderStart||new Date,h.orderExpiry||r.defaultOrderExpiry()))),f=[];return {actions:o.flatMap(h=>{let g=[];return h.actions.forEach(R=>{if(R.type==="TRANSACTION"){let y=h.orderComponents.offer[0].token;f.includes(y)||(f.push(y),g.push(R));}else g.push(R);}),g}),completeListings:async h=>{if(typeof h=="string")throw new Error("A signature per listing must be provided for smart contract wallets");return {result:(await Promise.all(o.map((y,C)=>{let I=h[C];return this.apiClient.createListing({makerFees:s[C].makerFees,orderComponents:y.orderComponents,orderHash:y.orderHash,orderSignature:I}).catch(()=>{})}))).map((y,C)=>({success:!!y,orderHash:o[C].orderHash,order:y?Y(y.result):void 0}))}}}}track("orderbookmr","bulkListings",{walletType:"EOA",makerAddress:i,listingsCount:s.length});let{actions:p,preparedOrders:u}=await this.seaport.prepareBulkSeaportOrders(i,s.map(o=>({offerItem:o.sell,considerationItem:o.buy,allowPartialFills:o.sell.type==="ERC1155",orderStart:o.orderStart||new Date,orderExpiry:o.orderExpiry||r.defaultOrderExpiry()})));return {actions:p,completeListings:async o=>{let f=typeof o=="object";if(f&&o.length!==1)throw new Error("Only a single signature is expected for bulk listing creation");let E=u.map(y=>y.orderComponents),h=f?o[0]:o,g=Ot(h,E);return {result:(await Promise.all(E.map((y,C)=>{let I=g[C],_=u[C],S=s[C];return this.apiClient.createListing({orderComponents:y,orderHash:_.orderHash,orderSignature:I,makerFees:S.makerFees}).catch(()=>{})}))).map((y,C)=>({success:!!y,orderHash:u[C].orderHash,order:y?Y(y.result):void 0}))}}}}async prepareListing({makerAddress:i,sell:s,buy:a,orderStart:p,orderExpiry:u}){return this.seaport.prepareSeaportOrder(i,s,a,s.type==="ERC1155",p||new Date,u||r.defaultOrderExpiry())}async createListing(i){let s=await this.apiClient.createListing(i);return {result:Y(s.result)}}async prepareBid({makerAddress:i,sell:s,buy:a,orderStart:p,orderExpiry:u}){return this.seaport.prepareSeaportOrder(i,s,a,a.type==="ERC1155",p||new Date,u||r.defaultOrderExpiry())}async createBid(i){let s=await this.apiClient.createBid(i);return {result:ae(s.result)}}async prepareCollectionBid({makerAddress:i,sell:s,buy:a,orderStart:p,orderExpiry:u}){return this.seaport.prepareSeaportOrder(i,s,a,!0,p||new Date,u||r.defaultOrderExpiry())}async createCollectionBid(i){let s=await this.apiClient.createCollectionBid(i);return {result:le(s.result)}}async prepareTraitBid({makerAddress:i,sell:s,buy:a,orderStart:p,orderExpiry:u}){return this.seaport.prepareSeaportOrder(i,s,a,!0,p||new Date,u||r.defaultOrderExpiry())}async createTraitBid(i){let s=await this.apiClient.createTraitBid(i);return {result:de(s.result)}}async fulfillOrder(i,s,a,p,u){let o={order_id:i,taker_address:s,fees:a.map(R=>({type:D.type.TAKER_ECOSYSTEM,amount:R.amount,recipient_address:R.recipientAddress}))},f=u?[{identifier:u,proof:[]}]:void 0;u&&(o.token_id=u);let E=await this.apiClient.fulfillmentData([o]);if(E.result.unfulfillable_orders?.length>0)throw new Error(`Unable to prepare fulfillment data: ${E.result.unfulfillable_orders[0].reason}`);if(E.result.fulfillable_orders?.length!==1)throw new Error("unexpected fulfillable order result length");let h=E.result.fulfillable_orders[0].extra_data,g=E.result.fulfillable_orders[0].order;if(g.status.name!=="ACTIVE")throw new Error(`Cannot fulfil order that is not active. Current status: ${g.status}`);return this.seaport.fulfillOrder(g,s,h,p,f)}async fulfillBulkOrders(i,s){let a=i.map(u=>{let o="listingId"in u;return {orderId:o?u.listingId:u.orderId,takerFees:u.takerFees,amountToFill:u.amountToFill,tokenId:o?void 0:u.tokenId}}),p=await this.apiClient.fulfillmentData(a.map(u=>({order_id:u.orderId,taker_address:s,fees:u.takerFees.map(o=>({type:D.type.TAKER_ECOSYSTEM,amount:o.amount,recipient_address:o.recipientAddress})),token_id:u?.tokenId})));try{let u=p.result.fulfillable_orders.map(o=>{let f=a.find(h=>h.orderId===o.order.id&&h.tokenId===o.token_id);if(!f){let h=`Could not find order for order ${o.order.id}`;throw o.token_id&&(h+=` and token ID ${o.token_id}`),new Error(h)}let E=[];return f.tokenId&&E.push({identifier:f.tokenId,proof:[]}),{extraData:o.extra_data,order:o.order,unitsToFill:f.amountToFill,considerationCriteria:E}});return {...await this.seaport.fulfillBulkOrders(u,s),fulfillableOrders:p.result.fulfillable_orders.map(o=>ue(o.order)),unfulfillableOrders:p.result.unfulfillable_orders.map(o=>({orderId:o.order_id,tokenId:o.token_id,reason:o.reason})),sufficientBalance:!0}}catch(u){if(String(u).includes("The fulfiller does not have the balances needed to fulfill."))return {fulfillableOrders:p.result.fulfillable_orders.map(o=>ue(o.order)),unfulfillableOrders:p.result.unfulfillable_orders.map(o=>({orderId:o.order_id,reason:o.reason})),sufficientBalance:!1};throw u}}async prepareOrderCancellations(i){let s=await this.orderbookConfig.provider.getNetwork(),a={name:"imtbl-order-book",chainId:Number(s.chainId),verifyingContract:this.orderbookConfig.seaportContractAddress},p={CancelPayload:[{name:"orders",type:"Order[]"}],Order:[{name:"id",type:"string"}]},u={orders:i.map(o=>({id:o}))};return {signableAction:{purpose:"OFF_CHAIN_CANCELLATION",type:"SIGNABLE",message:{domain:a,types:p,value:u}}}}async cancelOrders(i,s,a){return this.apiClient.cancelOrders(i,s,a)}async cancelOrdersOnChain(i,s){let a=Promise.all(i.map(R=>this.apiClient.getListing(R).catch(y=>{if(y.status!==404)throw y}))),p=Promise.all(i.map(R=>this.apiClient.getBid(R).catch(y=>{if(y.status!==404)throw y}))),u=Promise.all(i.map(R=>this.apiClient.getCollectionBid(R).catch(y=>{if(y.status!==404)throw y}))),o=Promise.all(i.map(R=>this.apiClient.getTraitBid(R).catch(y=>{if(y.status!==404)throw y}))),f=[await Promise.all([a,p,u,o])].flat(2).filter(R=>R!==void 0).map(R=>R.result);if(f.length!==i.length){let R=i.filter(y=>!f.some(C=>C.id===y));throw new Error(`Orders ${R} not found`)}for(let R of f)if(R.account_address!==s.toLowerCase())throw new Error(`Only account ${R.account_address} can cancel order ${R.id}`);let E=f.map(R=>R.protocol_data.seaport_address);if(new Set(E).size!==1)throw new Error("Cannot cancel multiple orders from different seaport contracts. Please group your orderIds accordingly");return {cancellationAction:await this.seaport.cancelOrders(f,s)}}};var vr={estimatedFulfillmentGasGwei:4e5};/*! ieee754. BSD-3-Clause License. Feross Aboukhadijeh <https://feross.org/opensource> */
9
+ var ie={},nt=!1;function Xt(){if(nt)return ie;nt=!0,ie.byteLength=f,ie.toByteArray=h,ie.fromByteArray=C;for(var r=[],i=[],s=typeof Uint8Array<"u"?Uint8Array:Array,a="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",p=0,u=a.length;p<u;++p)r[p]=a[p],i[a.charCodeAt(p)]=p;i[45]=62,i[95]=63;function o(y){var I=y.length;if(I%4>0)throw new Error("Invalid string. Length must be a multiple of 4");var O=y.indexOf("=");O===-1&&(O=I);var P=O===I?0:4-O%4;return [O,P]}function f(y){var I=o(y),O=I[0],P=I[1];return (O+P)*3/4-P}function E(y,I,O){return (I+O)*3/4-O}function h(y){var I,O=o(y),P=O[0],F=O[1],S=new s(E(y,P,F)),v=0,U=F>0?P-4:P,D;for(D=0;D<U;D+=4)I=i[y.charCodeAt(D)]<<18|i[y.charCodeAt(D+1)]<<12|i[y.charCodeAt(D+2)]<<6|i[y.charCodeAt(D+3)],S[v++]=I>>16&255,S[v++]=I>>8&255,S[v++]=I&255;return F===2&&(I=i[y.charCodeAt(D)]<<2|i[y.charCodeAt(D+1)]>>4,S[v++]=I&255),F===1&&(I=i[y.charCodeAt(D)]<<10|i[y.charCodeAt(D+1)]<<4|i[y.charCodeAt(D+2)]>>2,S[v++]=I>>8&255,S[v++]=I&255),S}function R(y){return r[y>>18&63]+r[y>>12&63]+r[y>>6&63]+r[y&63]}function g(y,I,O){for(var P,F=[],S=I;S<O;S+=3)P=(y[S]<<16&16711680)+(y[S+1]<<8&65280)+(y[S+2]&255),F.push(R(P));return F.join("")}function C(y){for(var I,O=y.length,P=O%3,F=[],S=16383,v=0,U=O-P;v<U;v+=S)F.push(g(y,v,v+S>U?U:v+S));return P===1?(I=y[O-1],F.push(r[I>>2]+r[I<<4&63]+"==")):P===2&&(I=(y[O-2]<<8)+y[O-1],F.push(r[I>>10]+r[I>>4&63]+r[I<<2&63]+"=")),F.join("")}return ie}var ye={},st=!1;function Zt(){if(st)return ye;st=!0;return ye.read=function(r,i,s,a,p){var u,o,f=p*8-a-1,E=(1<<f)-1,h=E>>1,R=-7,g=s?p-1:0,C=s?-1:1,y=r[i+g];for(g+=C,u=y&(1<<-R)-1,y>>=-R,R+=f;R>0;u=u*256+r[i+g],g+=C,R-=8);for(o=u&(1<<-R)-1,u>>=-R,R+=a;R>0;o=o*256+r[i+g],g+=C,R-=8);if(u===0)u=1-h;else {if(u===E)return o?NaN:(y?-1:1)*(1/0);o=o+Math.pow(2,a),u=u-h;}return (y?-1:1)*o*Math.pow(2,u-a)},ye.write=function(r,i,s,a,p,u){var o,f,E,h=u*8-p-1,R=(1<<h)-1,g=R>>1,C=p===23?Math.pow(2,-24)-Math.pow(2,-77):0,y=a?0:u-1,I=a?1:-1,O=i<0||i===0&&1/i<0?1:0;for(i=Math.abs(i),isNaN(i)||i===1/0?(f=isNaN(i)?1:0,o=R):(o=Math.floor(Math.log(i)/Math.LN2),i*(E=Math.pow(2,-o))<1&&(o--,E*=2),o+g>=1?i+=C/E:i+=C*Math.pow(2,1-g),i*E>=2&&(o++,E/=2),o+g>=R?(f=0,o=R):o+g>=1?(f=(i*E-1)*Math.pow(2,p),o=o+g):(f=i*Math.pow(2,g-1)*Math.pow(2,p),o=0));p>=8;r[s+y]=f&255,y+=I,f/=256,p-=8);for(o=o<<p|f,h+=p;h>0;r[s+y]=o&255,y+=I,o/=256,h-=8);r[s+y-I]|=O*128;},ye}var j={},at=!1;function Qt(){if(at)return j;at=!0;let r=Xt(),i=Zt(),s=typeof Symbol=="function"&&typeof Symbol.for=="function"?Symbol.for("nodejs.util.inspect.custom"):null;j.Buffer=o,j.SlowBuffer=F,j.INSPECT_MAX_BYTES=50;let a=2147483647;j.kMaxLength=a,o.TYPED_ARRAY_SUPPORT=p(),!o.TYPED_ARRAY_SUPPORT&&typeof console<"u"&&typeof console.error=="function"&&console.error("This browser lacks typed array (Uint8Array) support which is required by `buffer` v5.x. Use `buffer` v4.x if you require old browser support.");function p(){try{let n=new Uint8Array(1),e={foo:function(){return 42}};return Object.setPrototypeOf(e,Uint8Array.prototype),Object.setPrototypeOf(n,e),n.foo()===42}catch{return !1}}Object.defineProperty(o.prototype,"parent",{enumerable:!0,get:function(){if(o.isBuffer(this))return this.buffer}}),Object.defineProperty(o.prototype,"offset",{enumerable:!0,get:function(){if(o.isBuffer(this))return this.byteOffset}});function u(n){if(n>a)throw new RangeError('The value "'+n+'" is invalid for option "size"');let e=new Uint8Array(n);return Object.setPrototypeOf(e,o.prototype),e}function o(n,e,t){if(typeof n=="number"){if(typeof e=="string")throw new TypeError('The "string" argument must be of type string. Received type number');return R(n)}return f(n,e,t)}o.poolSize=8192;function f(n,e,t){if(typeof n=="string")return g(n,e);if(ArrayBuffer.isView(n))return y(n);if(n==null)throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof n);if(H(n,ArrayBuffer)||n&&H(n.buffer,ArrayBuffer)||typeof SharedArrayBuffer<"u"&&(H(n,SharedArrayBuffer)||n&&H(n.buffer,SharedArrayBuffer)))return I(n,e,t);if(typeof n=="number")throw new TypeError('The "value" argument must not be of type number. Received type number');let d=n.valueOf&&n.valueOf();if(d!=null&&d!==n)return o.from(d,e,t);let l=O(n);if(l)return l;if(typeof Symbol<"u"&&Symbol.toPrimitive!=null&&typeof n[Symbol.toPrimitive]=="function")return o.from(n[Symbol.toPrimitive]("string"),e,t);throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof n)}o.from=function(n,e,t){return f(n,e,t)},Object.setPrototypeOf(o.prototype,Uint8Array.prototype),Object.setPrototypeOf(o,Uint8Array);function E(n){if(typeof n!="number")throw new TypeError('"size" argument must be of type number');if(n<0)throw new RangeError('The value "'+n+'" is invalid for option "size"')}function h(n,e,t){return E(n),n<=0?u(n):e!==void 0?typeof t=="string"?u(n).fill(e,t):u(n).fill(e):u(n)}o.alloc=function(n,e,t){return h(n,e,t)};function R(n){return E(n),u(n<0?0:P(n)|0)}o.allocUnsafe=function(n){return R(n)},o.allocUnsafeSlow=function(n){return R(n)};function g(n,e){if((typeof e!="string"||e==="")&&(e="utf8"),!o.isEncoding(e))throw new TypeError("Unknown encoding: "+e);let t=S(n,e)|0,d=u(t),l=d.write(n,e);return l!==t&&(d=d.slice(0,l)),d}function C(n){let e=n.length<0?0:P(n.length)|0,t=u(e);for(let d=0;d<e;d+=1)t[d]=n[d]&255;return t}function y(n){if(H(n,Uint8Array)){let e=new Uint8Array(n);return I(e.buffer,e.byteOffset,e.byteLength)}return C(n)}function I(n,e,t){if(e<0||n.byteLength<e)throw new RangeError('"offset" is outside of buffer bounds');if(n.byteLength<e+(t||0))throw new RangeError('"length" is outside of buffer bounds');let d;return e===void 0&&t===void 0?d=new Uint8Array(n):t===void 0?d=new Uint8Array(n,e):d=new Uint8Array(n,e,t),Object.setPrototypeOf(d,o.prototype),d}function O(n){if(o.isBuffer(n)){let e=P(n.length)|0,t=u(e);return t.length===0||n.copy(t,0,0,e),t}if(n.length!==void 0)return typeof n.length!="number"||ve(n.length)?u(0):C(n);if(n.type==="Buffer"&&Array.isArray(n.data))return C(n.data)}function P(n){if(n>=a)throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+a.toString(16)+" bytes");return n|0}function F(n){return +n!=n&&(n=0),o.alloc(+n)}o.isBuffer=function(e){return e!=null&&e._isBuffer===!0&&e!==o.prototype},o.compare=function(e,t){if(H(e,Uint8Array)&&(e=o.from(e,e.offset,e.byteLength)),H(t,Uint8Array)&&(t=o.from(t,t.offset,t.byteLength)),!o.isBuffer(e)||!o.isBuffer(t))throw new TypeError('The "buf1", "buf2" arguments must be one of type Buffer or Uint8Array');if(e===t)return 0;let d=e.length,l=t.length;for(let c=0,m=Math.min(d,l);c<m;++c)if(e[c]!==t[c]){d=e[c],l=t[c];break}return d<l?-1:l<d?1:0},o.isEncoding=function(e){switch(String(e).toLowerCase()){case"hex":case"utf8":case"utf-8":case"ascii":case"latin1":case"binary":case"base64":case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return !0;default:return !1}},o.concat=function(e,t){if(!Array.isArray(e))throw new TypeError('"list" argument must be an Array of Buffers');if(e.length===0)return o.alloc(0);let d;if(t===void 0)for(t=0,d=0;d<e.length;++d)t+=e[d].length;let l=o.allocUnsafe(t),c=0;for(d=0;d<e.length;++d){let m=e[d];if(H(m,Uint8Array))c+m.length>l.length?(o.isBuffer(m)||(m=o.from(m)),m.copy(l,c)):Uint8Array.prototype.set.call(l,m,c);else if(o.isBuffer(m))m.copy(l,c);else throw new TypeError('"list" argument must be an Array of Buffers');c+=m.length;}return l};function S(n,e){if(o.isBuffer(n))return n.length;if(ArrayBuffer.isView(n)||H(n,ArrayBuffer))return n.byteLength;if(typeof n!="string")throw new TypeError('The "string" argument must be one of type string, Buffer, or ArrayBuffer. Received type '+typeof n);let t=n.length,d=arguments.length>2&&arguments[2]===!0;if(!d&&t===0)return 0;let l=!1;for(;;)switch(e){case"ascii":case"latin1":case"binary":return t;case"utf8":case"utf-8":return Fe(n).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return t*2;case"hex":return t>>>1;case"base64":return it(n).length;default:if(l)return d?-1:Fe(n).length;e=(""+e).toLowerCase(),l=!0;}}o.byteLength=S;function v(n,e,t){let d=!1;if((e===void 0||e<0)&&(e=0),e>this.length||((t===void 0||t>this.length)&&(t=this.length),t<=0)||(t>>>=0,e>>>=0,t<=e))return "";for(n||(n="utf8");;)switch(n){case"hex":return $t(this,e,t);case"utf8":case"utf-8":return Ye(this,e,t);case"ascii":return Ut(this,e,t);case"latin1":case"binary":return Ht(this,e,t);case"base64":return Mt(this,e,t);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return Vt(this,e,t);default:if(d)throw new TypeError("Unknown encoding: "+n);n=(n+"").toLowerCase(),d=!0;}}o.prototype._isBuffer=!0;function U(n,e,t){let d=n[e];n[e]=n[t],n[t]=d;}o.prototype.swap16=function(){let e=this.length;if(e%2!==0)throw new RangeError("Buffer size must be a multiple of 16-bits");for(let t=0;t<e;t+=2)U(this,t,t+1);return this},o.prototype.swap32=function(){let e=this.length;if(e%4!==0)throw new RangeError("Buffer size must be a multiple of 32-bits");for(let t=0;t<e;t+=4)U(this,t,t+3),U(this,t+1,t+2);return this},o.prototype.swap64=function(){let e=this.length;if(e%8!==0)throw new RangeError("Buffer size must be a multiple of 64-bits");for(let t=0;t<e;t+=8)U(this,t,t+7),U(this,t+1,t+6),U(this,t+2,t+5),U(this,t+3,t+4);return this},o.prototype.toString=function(){let e=this.length;return e===0?"":arguments.length===0?Ye(this,0,e):v.apply(this,arguments)},o.prototype.toLocaleString=o.prototype.toString,o.prototype.equals=function(e){if(!o.isBuffer(e))throw new TypeError("Argument must be a Buffer");return this===e?!0:o.compare(this,e)===0},o.prototype.inspect=function(){let e="",t=j.INSPECT_MAX_BYTES;return e=this.toString("hex",0,t).replace(/(.{2})/g,"$1 ").trim(),this.length>t&&(e+=" ... "),"<Buffer "+e+">"},s&&(o.prototype[s]=o.prototype.inspect),o.prototype.compare=function(e,t,d,l,c){if(H(e,Uint8Array)&&(e=o.from(e,e.offset,e.byteLength)),!o.isBuffer(e))throw new TypeError('The "target" argument must be one of type Buffer or Uint8Array. Received type '+typeof e);if(t===void 0&&(t=0),d===void 0&&(d=e?e.length:0),l===void 0&&(l=0),c===void 0&&(c=this.length),t<0||d>e.length||l<0||c>this.length)throw new RangeError("out of range index");if(l>=c&&t>=d)return 0;if(l>=c)return -1;if(t>=d)return 1;if(t>>>=0,d>>>=0,l>>>=0,c>>>=0,this===e)return 0;let m=c-l,A=d-t,w=Math.min(m,A),b=this.slice(l,c),L=e.slice(t,d);for(let B=0;B<w;++B)if(b[B]!==L[B]){m=b[B],A=L[B];break}return m<A?-1:A<m?1:0};function D(n,e,t,d,l){if(n.length===0)return -1;if(typeof t=="string"?(d=t,t=0):t>2147483647?t=2147483647:t<-2147483648&&(t=-2147483648),t=+t,ve(t)&&(t=l?0:n.length-1),t<0&&(t=n.length+t),t>=n.length){if(l)return -1;t=n.length-1;}else if(t<0)if(l)t=0;else return -1;if(typeof e=="string"&&(e=o.from(e,d)),o.isBuffer(e))return e.length===0?-1:We(n,e,t,d,l);if(typeof e=="number")return e=e&255,typeof Uint8Array.prototype.indexOf=="function"?l?Uint8Array.prototype.indexOf.call(n,e,t):Uint8Array.prototype.lastIndexOf.call(n,e,t):We(n,[e],t,d,l);throw new TypeError("val must be string, number or Buffer")}function We(n,e,t,d,l){let c=1,m=n.length,A=e.length;if(d!==void 0&&(d=String(d).toLowerCase(),d==="ucs2"||d==="ucs-2"||d==="utf16le"||d==="utf-16le")){if(n.length<2||e.length<2)return -1;c=2,m/=2,A/=2,t/=2;}function w(L,B){return c===1?L[B]:L.readUInt16BE(B*c)}let b;if(l){let L=-1;for(b=t;b<m;b++)if(w(n,b)===w(e,L===-1?0:b-L)){if(L===-1&&(L=b),b-L+1===A)return L*c}else L!==-1&&(b-=b-L),L=-1;}else for(t+A>m&&(t=m-A),b=t;b>=0;b--){let L=!0;for(let B=0;B<A;B++)if(w(n,b+B)!==w(e,B)){L=!1;break}if(L)return b}return -1}o.prototype.includes=function(e,t,d){return this.indexOf(e,t,d)!==-1},o.prototype.indexOf=function(e,t,d){return D(this,e,t,d,!0)},o.prototype.lastIndexOf=function(e,t,d){return D(this,e,t,d,!1)};function Nt(n,e,t,d){t=Number(t)||0;let l=n.length-t;d?(d=Number(d),d>l&&(d=l)):d=l;let c=e.length;d>c/2&&(d=c/2);let m;for(m=0;m<d;++m){let A=parseInt(e.substr(m*2,2),16);if(ve(A))return m;n[t+m]=A;}return m}function kt(n,e,t,d){return he(Fe(e,n.length-t),n,t,d)}function Dt(n,e,t,d){return he(Wt(e),n,t,d)}function Ft(n,e,t,d){return he(it(e),n,t,d)}function vt(n,e,t,d){return he(Yt(e,n.length-t),n,t,d)}o.prototype.write=function(e,t,d,l){if(t===void 0)l="utf8",d=this.length,t=0;else if(d===void 0&&typeof t=="string")l=t,d=this.length,t=0;else if(isFinite(t))t=t>>>0,isFinite(d)?(d=d>>>0,l===void 0&&(l="utf8")):(l=d,d=void 0);else throw new Error("Buffer.write(string, encoding, offset[, length]) is no longer supported");let c=this.length-t;if((d===void 0||d>c)&&(d=c),e.length>0&&(d<0||t<0)||t>this.length)throw new RangeError("Attempt to write outside buffer bounds");l||(l="utf8");let m=!1;for(;;)switch(l){case"hex":return Nt(this,e,t,d);case"utf8":case"utf-8":return kt(this,e,t,d);case"ascii":case"latin1":case"binary":return Dt(this,e,t,d);case"base64":return Ft(this,e,t,d);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return vt(this,e,t,d);default:if(m)throw new TypeError("Unknown encoding: "+l);l=(""+l).toLowerCase(),m=!0;}},o.prototype.toJSON=function(){return {type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};function Mt(n,e,t){return e===0&&t===n.length?r.fromByteArray(n):r.fromByteArray(n.slice(e,t))}function Ye(n,e,t){t=Math.min(n.length,t);let d=[],l=e;for(;l<t;){let c=n[l],m=null,A=c>239?4:c>223?3:c>191?2:1;if(l+A<=t){let w,b,L,B;switch(A){case 1:c<128&&(m=c);break;case 2:w=n[l+1],(w&192)===128&&(B=(c&31)<<6|w&63,B>127&&(m=B));break;case 3:w=n[l+1],b=n[l+2],(w&192)===128&&(b&192)===128&&(B=(c&15)<<12|(w&63)<<6|b&63,B>2047&&(B<55296||B>57343)&&(m=B));break;case 4:w=n[l+1],b=n[l+2],L=n[l+3],(w&192)===128&&(b&192)===128&&(L&192)===128&&(B=(c&15)<<18|(w&63)<<12|(b&63)<<6|L&63,B>65535&&B<1114112&&(m=B));}}m===null?(m=65533,A=1):m>65535&&(m-=65536,d.push(m>>>10&1023|55296),m=56320|m&1023),d.push(m),l+=A;}return qt(d)}let Ke=4096;function qt(n){let e=n.length;if(e<=Ke)return String.fromCharCode.apply(String,n);let t="",d=0;for(;d<e;)t+=String.fromCharCode.apply(String,n.slice(d,d+=Ke));return t}function Ut(n,e,t){let d="";t=Math.min(n.length,t);for(let l=e;l<t;++l)d+=String.fromCharCode(n[l]&127);return d}function Ht(n,e,t){let d="";t=Math.min(n.length,t);for(let l=e;l<t;++l)d+=String.fromCharCode(n[l]);return d}function $t(n,e,t){let d=n.length;(!e||e<0)&&(e=0),(!t||t<0||t>d)&&(t=d);let l="";for(let c=e;c<t;++c)l+=Kt[n[c]];return l}function Vt(n,e,t){let d=n.slice(e,t),l="";for(let c=0;c<d.length-1;c+=2)l+=String.fromCharCode(d[c]+d[c+1]*256);return l}o.prototype.slice=function(e,t){let d=this.length;e=~~e,t=t===void 0?d:~~t,e<0?(e+=d,e<0&&(e=0)):e>d&&(e=d),t<0?(t+=d,t<0&&(t=0)):t>d&&(t=d),t<e&&(t=e);let l=this.subarray(e,t);return Object.setPrototypeOf(l,o.prototype),l};function N(n,e,t){if(n%1!==0||n<0)throw new RangeError("offset is not uint");if(n+e>t)throw new RangeError("Trying to access beyond buffer length")}o.prototype.readUintLE=o.prototype.readUIntLE=function(e,t,d){e=e>>>0,t=t>>>0,d||N(e,t,this.length);let l=this[e],c=1,m=0;for(;++m<t&&(c*=256);)l+=this[e+m]*c;return l},o.prototype.readUintBE=o.prototype.readUIntBE=function(e,t,d){e=e>>>0,t=t>>>0,d||N(e,t,this.length);let l=this[e+--t],c=1;for(;t>0&&(c*=256);)l+=this[e+--t]*c;return l},o.prototype.readUint8=o.prototype.readUInt8=function(e,t){return e=e>>>0,t||N(e,1,this.length),this[e]},o.prototype.readUint16LE=o.prototype.readUInt16LE=function(e,t){return e=e>>>0,t||N(e,2,this.length),this[e]|this[e+1]<<8},o.prototype.readUint16BE=o.prototype.readUInt16BE=function(e,t){return e=e>>>0,t||N(e,2,this.length),this[e]<<8|this[e+1]},o.prototype.readUint32LE=o.prototype.readUInt32LE=function(e,t){return e=e>>>0,t||N(e,4,this.length),(this[e]|this[e+1]<<8|this[e+2]<<16)+this[e+3]*16777216},o.prototype.readUint32BE=o.prototype.readUInt32BE=function(e,t){return e=e>>>0,t||N(e,4,this.length),this[e]*16777216+(this[e+1]<<16|this[e+2]<<8|this[e+3])},o.prototype.readBigUInt64LE=V(function(e){e=e>>>0,X(e,"offset");let t=this[e],d=this[e+7];(t===void 0||d===void 0)&&re(e,this.length-8);let l=t+this[++e]*2**8+this[++e]*2**16+this[++e]*2**24,c=this[++e]+this[++e]*2**8+this[++e]*2**16+d*2**24;return BigInt(l)+(BigInt(c)<<BigInt(32))}),o.prototype.readBigUInt64BE=V(function(e){e=e>>>0,X(e,"offset");let t=this[e],d=this[e+7];(t===void 0||d===void 0)&&re(e,this.length-8);let l=t*2**24+this[++e]*2**16+this[++e]*2**8+this[++e],c=this[++e]*2**24+this[++e]*2**16+this[++e]*2**8+d;return (BigInt(l)<<BigInt(32))+BigInt(c)}),o.prototype.readIntLE=function(e,t,d){e=e>>>0,t=t>>>0,d||N(e,t,this.length);let l=this[e],c=1,m=0;for(;++m<t&&(c*=256);)l+=this[e+m]*c;return c*=128,l>=c&&(l-=Math.pow(2,8*t)),l},o.prototype.readIntBE=function(e,t,d){e=e>>>0,t=t>>>0,d||N(e,t,this.length);let l=t,c=1,m=this[e+--l];for(;l>0&&(c*=256);)m+=this[e+--l]*c;return c*=128,m>=c&&(m-=Math.pow(2,8*t)),m},o.prototype.readInt8=function(e,t){return e=e>>>0,t||N(e,1,this.length),this[e]&128?(255-this[e]+1)*-1:this[e]},o.prototype.readInt16LE=function(e,t){e=e>>>0,t||N(e,2,this.length);let d=this[e]|this[e+1]<<8;return d&32768?d|4294901760:d},o.prototype.readInt16BE=function(e,t){e=e>>>0,t||N(e,2,this.length);let d=this[e+1]|this[e]<<8;return d&32768?d|4294901760:d},o.prototype.readInt32LE=function(e,t){return e=e>>>0,t||N(e,4,this.length),this[e]|this[e+1]<<8|this[e+2]<<16|this[e+3]<<24},o.prototype.readInt32BE=function(e,t){return e=e>>>0,t||N(e,4,this.length),this[e]<<24|this[e+1]<<16|this[e+2]<<8|this[e+3]},o.prototype.readBigInt64LE=V(function(e){e=e>>>0,X(e,"offset");let t=this[e],d=this[e+7];(t===void 0||d===void 0)&&re(e,this.length-8);let l=this[e+4]+this[e+5]*2**8+this[e+6]*2**16+(d<<24);return (BigInt(l)<<BigInt(32))+BigInt(t+this[++e]*2**8+this[++e]*2**16+this[++e]*2**24)}),o.prototype.readBigInt64BE=V(function(e){e=e>>>0,X(e,"offset");let t=this[e],d=this[e+7];(t===void 0||d===void 0)&&re(e,this.length-8);let l=(t<<24)+this[++e]*2**16+this[++e]*2**8+this[++e];return (BigInt(l)<<BigInt(32))+BigInt(this[++e]*2**24+this[++e]*2**16+this[++e]*2**8+d)}),o.prototype.readFloatLE=function(e,t){return e=e>>>0,t||N(e,4,this.length),i.read(this,e,!0,23,4)},o.prototype.readFloatBE=function(e,t){return e=e>>>0,t||N(e,4,this.length),i.read(this,e,!1,23,4)},o.prototype.readDoubleLE=function(e,t){return e=e>>>0,t||N(e,8,this.length),i.read(this,e,!0,52,8)},o.prototype.readDoubleBE=function(e,t){return e=e>>>0,t||N(e,8,this.length),i.read(this,e,!1,52,8)};function M(n,e,t,d,l,c){if(!o.isBuffer(n))throw new TypeError('"buffer" argument must be a Buffer instance');if(e>l||e<c)throw new RangeError('"value" argument is out of bounds');if(t+d>n.length)throw new RangeError("Index out of range")}o.prototype.writeUintLE=o.prototype.writeUIntLE=function(e,t,d,l){if(e=+e,t=t>>>0,d=d>>>0,!l){let A=Math.pow(2,8*d)-1;M(this,e,t,d,A,0);}let c=1,m=0;for(this[t]=e&255;++m<d&&(c*=256);)this[t+m]=e/c&255;return t+d},o.prototype.writeUintBE=o.prototype.writeUIntBE=function(e,t,d,l){if(e=+e,t=t>>>0,d=d>>>0,!l){let A=Math.pow(2,8*d)-1;M(this,e,t,d,A,0);}let c=d-1,m=1;for(this[t+c]=e&255;--c>=0&&(m*=256);)this[t+c]=e/m&255;return t+d},o.prototype.writeUint8=o.prototype.writeUInt8=function(e,t,d){return e=+e,t=t>>>0,d||M(this,e,t,1,255,0),this[t]=e&255,t+1},o.prototype.writeUint16LE=o.prototype.writeUInt16LE=function(e,t,d){return e=+e,t=t>>>0,d||M(this,e,t,2,65535,0),this[t]=e&255,this[t+1]=e>>>8,t+2},o.prototype.writeUint16BE=o.prototype.writeUInt16BE=function(e,t,d){return e=+e,t=t>>>0,d||M(this,e,t,2,65535,0),this[t]=e>>>8,this[t+1]=e&255,t+2},o.prototype.writeUint32LE=o.prototype.writeUInt32LE=function(e,t,d){return e=+e,t=t>>>0,d||M(this,e,t,4,4294967295,0),this[t+3]=e>>>24,this[t+2]=e>>>16,this[t+1]=e>>>8,this[t]=e&255,t+4},o.prototype.writeUint32BE=o.prototype.writeUInt32BE=function(e,t,d){return e=+e,t=t>>>0,d||M(this,e,t,4,4294967295,0),this[t]=e>>>24,this[t+1]=e>>>16,this[t+2]=e>>>8,this[t+3]=e&255,t+4};function Je(n,e,t,d,l){rt(e,d,l,n,t,7);let c=Number(e&BigInt(4294967295));n[t++]=c,c=c>>8,n[t++]=c,c=c>>8,n[t++]=c,c=c>>8,n[t++]=c;let m=Number(e>>BigInt(32)&BigInt(4294967295));return n[t++]=m,m=m>>8,n[t++]=m,m=m>>8,n[t++]=m,m=m>>8,n[t++]=m,t}function Xe(n,e,t,d,l){rt(e,d,l,n,t,7);let c=Number(e&BigInt(4294967295));n[t+7]=c,c=c>>8,n[t+6]=c,c=c>>8,n[t+5]=c,c=c>>8,n[t+4]=c;let m=Number(e>>BigInt(32)&BigInt(4294967295));return n[t+3]=m,m=m>>8,n[t+2]=m,m=m>>8,n[t+1]=m,m=m>>8,n[t]=m,t+8}o.prototype.writeBigUInt64LE=V(function(e,t=0){return Je(this,e,t,BigInt(0),BigInt("0xffffffffffffffff"))}),o.prototype.writeBigUInt64BE=V(function(e,t=0){return Xe(this,e,t,BigInt(0),BigInt("0xffffffffffffffff"))}),o.prototype.writeIntLE=function(e,t,d,l){if(e=+e,t=t>>>0,!l){let w=Math.pow(2,8*d-1);M(this,e,t,d,w-1,-w);}let c=0,m=1,A=0;for(this[t]=e&255;++c<d&&(m*=256);)e<0&&A===0&&this[t+c-1]!==0&&(A=1),this[t+c]=(e/m>>0)-A&255;return t+d},o.prototype.writeIntBE=function(e,t,d,l){if(e=+e,t=t>>>0,!l){let w=Math.pow(2,8*d-1);M(this,e,t,d,w-1,-w);}let c=d-1,m=1,A=0;for(this[t+c]=e&255;--c>=0&&(m*=256);)e<0&&A===0&&this[t+c+1]!==0&&(A=1),this[t+c]=(e/m>>0)-A&255;return t+d},o.prototype.writeInt8=function(e,t,d){return e=+e,t=t>>>0,d||M(this,e,t,1,127,-128),e<0&&(e=255+e+1),this[t]=e&255,t+1},o.prototype.writeInt16LE=function(e,t,d){return e=+e,t=t>>>0,d||M(this,e,t,2,32767,-32768),this[t]=e&255,this[t+1]=e>>>8,t+2},o.prototype.writeInt16BE=function(e,t,d){return e=+e,t=t>>>0,d||M(this,e,t,2,32767,-32768),this[t]=e>>>8,this[t+1]=e&255,t+2},o.prototype.writeInt32LE=function(e,t,d){return e=+e,t=t>>>0,d||M(this,e,t,4,2147483647,-2147483648),this[t]=e&255,this[t+1]=e>>>8,this[t+2]=e>>>16,this[t+3]=e>>>24,t+4},o.prototype.writeInt32BE=function(e,t,d){return e=+e,t=t>>>0,d||M(this,e,t,4,2147483647,-2147483648),e<0&&(e=4294967295+e+1),this[t]=e>>>24,this[t+1]=e>>>16,this[t+2]=e>>>8,this[t+3]=e&255,t+4},o.prototype.writeBigInt64LE=V(function(e,t=0){return Je(this,e,t,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))}),o.prototype.writeBigInt64BE=V(function(e,t=0){return Xe(this,e,t,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))});function Ze(n,e,t,d,l,c){if(t+d>n.length)throw new RangeError("Index out of range");if(t<0)throw new RangeError("Index out of range")}function Qe(n,e,t,d,l){return e=+e,t=t>>>0,l||Ze(n,e,t,4),i.write(n,e,t,d,23,4),t+4}o.prototype.writeFloatLE=function(e,t,d){return Qe(this,e,t,!0,d)},o.prototype.writeFloatBE=function(e,t,d){return Qe(this,e,t,!1,d)};function et(n,e,t,d,l){return e=+e,t=t>>>0,l||Ze(n,e,t,8),i.write(n,e,t,d,52,8),t+8}o.prototype.writeDoubleLE=function(e,t,d){return et(this,e,t,!0,d)},o.prototype.writeDoubleBE=function(e,t,d){return et(this,e,t,!1,d)},o.prototype.copy=function(e,t,d,l){if(!o.isBuffer(e))throw new TypeError("argument should be a Buffer");if(d||(d=0),!l&&l!==0&&(l=this.length),t>=e.length&&(t=e.length),t||(t=0),l>0&&l<d&&(l=d),l===d||e.length===0||this.length===0)return 0;if(t<0)throw new RangeError("targetStart out of bounds");if(d<0||d>=this.length)throw new RangeError("Index out of range");if(l<0)throw new RangeError("sourceEnd out of bounds");l>this.length&&(l=this.length),e.length-t<l-d&&(l=e.length-t+d);let c=l-d;return this===e&&typeof Uint8Array.prototype.copyWithin=="function"?this.copyWithin(t,d,l):Uint8Array.prototype.set.call(e,this.subarray(d,l),t),c},o.prototype.fill=function(e,t,d,l){if(typeof e=="string"){if(typeof t=="string"?(l=t,t=0,d=this.length):typeof d=="string"&&(l=d,d=this.length),l!==void 0&&typeof l!="string")throw new TypeError("encoding must be a string");if(typeof l=="string"&&!o.isEncoding(l))throw new TypeError("Unknown encoding: "+l);if(e.length===1){let m=e.charCodeAt(0);(l==="utf8"&&m<128||l==="latin1")&&(e=m);}}else typeof e=="number"?e=e&255:typeof e=="boolean"&&(e=Number(e));if(t<0||this.length<t||this.length<d)throw new RangeError("Out of range index");if(d<=t)return this;t=t>>>0,d=d===void 0?this.length:d>>>0,e||(e=0);let c;if(typeof e=="number")for(c=t;c<d;++c)this[c]=e;else {let m=o.isBuffer(e)?e:o.from(e,l),A=m.length;if(A===0)throw new TypeError('The value "'+e+'" is invalid for argument "value"');for(c=0;c<d-t;++c)this[c+t]=m[c%A];}return this};let J={};function De(n,e,t){J[n]=class extends t{constructor(){super(),Object.defineProperty(this,"message",{value:e.apply(this,arguments),writable:!0,configurable:!0}),this.name=`${this.name} [${n}]`,this.stack,delete this.name;}get code(){return n}set code(l){Object.defineProperty(this,"code",{configurable:!0,enumerable:!0,value:l,writable:!0});}toString(){return `${this.name} [${n}]: ${this.message}`}};}De("ERR_BUFFER_OUT_OF_BOUNDS",function(n){return n?`${n} is outside of buffer bounds`:"Attempt to access memory outside buffer bounds"},RangeError),De("ERR_INVALID_ARG_TYPE",function(n,e){return `The "${n}" argument must be of type number. Received type ${typeof e}`},TypeError),De("ERR_OUT_OF_RANGE",function(n,e,t){let d=`The value of "${n}" is out of range.`,l=t;return Number.isInteger(t)&&Math.abs(t)>2**32?l=tt(String(t)):typeof t=="bigint"&&(l=String(t),(t>BigInt(2)**BigInt(32)||t<-(BigInt(2)**BigInt(32)))&&(l=tt(l)),l+="n"),d+=` It must be ${e}. Received ${l}`,d},RangeError);function tt(n){let e="",t=n.length,d=n[0]==="-"?1:0;for(;t>=d+4;t-=3)e=`_${n.slice(t-3,t)}${e}`;return `${n.slice(0,t)}${e}`}function zt(n,e,t){X(e,"offset"),(n[e]===void 0||n[e+t]===void 0)&&re(e,n.length-(t+1));}function rt(n,e,t,d,l,c){if(n>t||n<e){let m=typeof e=="bigint"?"n":"",A;throw e===0||e===BigInt(0)?A=`>= 0${m} and < 2${m} ** ${(c+1)*8}${m}`:A=`>= -(2${m} ** ${(c+1)*8-1}${m}) and < 2 ** ${(c+1)*8-1}${m}`,new J.ERR_OUT_OF_RANGE("value",A,n)}zt(d,l,c);}function X(n,e){if(typeof n!="number")throw new J.ERR_INVALID_ARG_TYPE(e,"number",n)}function re(n,e,t){throw Math.floor(n)!==n?(X(n,t),new J.ERR_OUT_OF_RANGE("offset","an integer",n)):e<0?new J.ERR_BUFFER_OUT_OF_BOUNDS:new J.ERR_OUT_OF_RANGE("offset",`>= ${0} and <= ${e}`,n)}let Gt=/[^+/0-9A-Za-z-_]/g;function jt(n){if(n=n.split("=")[0],n=n.trim().replace(Gt,""),n.length<2)return "";for(;n.length%4!==0;)n=n+"=";return n}function Fe(n,e){e=e||1/0;let t,d=n.length,l=null,c=[];for(let m=0;m<d;++m){if(t=n.charCodeAt(m),t>55295&&t<57344){if(!l){if(t>56319){(e-=3)>-1&&c.push(239,191,189);continue}else if(m+1===d){(e-=3)>-1&&c.push(239,191,189);continue}l=t;continue}if(t<56320){(e-=3)>-1&&c.push(239,191,189),l=t;continue}t=(l-55296<<10|t-56320)+65536;}else l&&(e-=3)>-1&&c.push(239,191,189);if(l=null,t<128){if((e-=1)<0)break;c.push(t);}else if(t<2048){if((e-=2)<0)break;c.push(t>>6|192,t&63|128);}else if(t<65536){if((e-=3)<0)break;c.push(t>>12|224,t>>6&63|128,t&63|128);}else if(t<1114112){if((e-=4)<0)break;c.push(t>>18|240,t>>12&63|128,t>>6&63|128,t&63|128);}else throw new Error("Invalid code point")}return c}function Wt(n){let e=[];for(let t=0;t<n.length;++t)e.push(n.charCodeAt(t)&255);return e}function Yt(n,e){let t,d,l,c=[];for(let m=0;m<n.length&&!((e-=2)<0);++m)t=n.charCodeAt(m),d=t>>8,l=t%256,c.push(l),c.push(d);return c}function it(n){return r.toByteArray(jt(n))}function he(n,e,t,d){let l;for(l=0;l<d&&!(l+t>=e.length||l>=n.length);++l)e[l+t]=n[l];return l}function H(n,e){return n instanceof e||n!=null&&n.constructor!=null&&n.constructor.name!=null&&n.constructor.name===e.name}function ve(n){return n!==n}let Kt=function(){let n="0123456789abcdef",e=new Array(256);for(let t=0;t<16;++t){let d=t*16;for(let l=0;l<16;++l)e[d+l]=n[t]+n[l];}return e}();function V(n){return typeof BigInt>"u"?Jt:n}function Jt(){throw new Error("BigInt not supported")}return j}var W=Qt();W.Buffer;W.SlowBuffer;W.INSPECT_MAX_BYTES;W.kMaxLength;var T=W.Buffer;W.INSPECT_MAX_BYTES;W.kMaxLength;var ne=class{constructor(i){this.config=i;}};var Z=class extends Error{url;status;statusText;body;request;constructor(i,s,a){super(a),this.name="ApiError",this.url=s.url,this.status=s.status,this.statusText=s.statusText,this.body=s.body,this.request=i;}};var Ce=class extends Error{constructor(i){super(i),this.name="CancelError";}get isCancelled(){return !0}},se=class{[Symbol.toStringTag];_isResolved;_isRejected;_isCancelled;_cancelHandlers;_promise;_resolve;_reject;constructor(i){this._isResolved=!1,this._isRejected=!1,this._isCancelled=!1,this._cancelHandlers=[],this._promise=new Promise((s,a)=>{this._resolve=s,this._reject=a;let p=f=>{this._isResolved||this._isRejected||this._isCancelled||(this._isResolved=!0,this._resolve?.(f));},u=f=>{this._isResolved||this._isRejected||this._isCancelled||(this._isRejected=!0,this._reject?.(f));},o=f=>{this._isResolved||this._isRejected||this._isCancelled||this._cancelHandlers.push(f);};return Object.defineProperty(o,"isResolved",{get:()=>this._isResolved}),Object.defineProperty(o,"isRejected",{get:()=>this._isRejected}),Object.defineProperty(o,"isCancelled",{get:()=>this._isCancelled}),i(p,u,o)});}then(i,s){return this._promise.then(i,s)}catch(i){return this._promise.catch(i)}finally(i){return this._promise.finally(i)}cancel(){if(!(this._isResolved||this._isRejected||this._isCancelled)){if(this._isCancelled=!0,this._cancelHandlers.length)try{for(let i of this._cancelHandlers)i();}catch(i){console.warn("Cancellation threw an error",i);return}this._cancelHandlers.length=0,this._reject?.(new Ce("Request aborted"));}}get isCancelled(){return this._isCancelled}};var qe=r=>r!=null,Re=r=>typeof r=="string",Me=r=>Re(r)&&r!=="",lt=r=>typeof r=="object"&&typeof r.type=="string"&&typeof r.stream=="function"&&typeof r.arrayBuffer=="function"&&typeof r.constructor=="function"&&typeof r.constructor.name=="string"&&/^(Blob|File)$/.test(r.constructor.name)&&/^(Blob|File)$/.test(r[Symbol.toStringTag]),er=r=>r instanceof dt,tr=r=>r>=200&&r<300,rr=r=>{try{return btoa(r)}catch{return T.from(r).toString("base64")}},ir=r=>{let i=[],s=(p,u)=>{i.push(`${encodeURIComponent(p)}=${encodeURIComponent(String(u))}`);},a=(p,u)=>{qe(u)&&(Array.isArray(u)?u.forEach(o=>{a(p,o);}):typeof u=="object"?Object.entries(u).forEach(([o,f])=>{a(`${p}[${o}]`,f);}):s(p,u));};return Object.entries(r).forEach(([p,u])=>{a(p,u);}),i.length>0?`?${i.join("&")}`:""},nr=(r,i)=>{let s=r.ENCODE_PATH||encodeURI,a=i.url.replace("{api-version}",r.VERSION).replace(/{(.*?)}/g,(u,o)=>i.path?.hasOwnProperty(o)?s(String(i.path[o])):u),p=`${r.BASE}${a}`;return i.query?`${p}${ir(i.query)}`:p},sr=r=>{if(r.formData){let i=new dt,s=(a,p)=>{Re(p)||lt(p)?i.append(a,p):i.append(a,JSON.stringify(p));};return Object.entries(r.formData).filter(([a,p])=>qe(p)).forEach(([a,p])=>{Array.isArray(p)?p.forEach(u=>s(a,u)):s(a,p);}),i}},Ee=async(r,i)=>typeof i=="function"?i(r):i,ar=async(r,i,s)=>{let a=await Ee(i,r.TOKEN),p=await Ee(i,r.USERNAME),u=await Ee(i,r.PASSWORD),o=await Ee(i,r.HEADERS),f=typeof s?.getHeaders=="function"&&s?.getHeaders()||{},E=Object.entries({Accept:"application/json",...o,...i.headers,...f}).filter(([h,R])=>qe(R)).reduce((h,[R,g])=>({...h,[R]:String(g)}),{});if(Me(a)&&(E.Authorization=`Bearer ${a}`),Me(p)&&Me(u)){let h=rr(`${p}:${u}`);E.Authorization=`Basic ${h}`;}return i.body&&(i.mediaType?E["Content-Type"]=i.mediaType:lt(i.body)?E["Content-Type"]=i.body.type||"application/octet-stream":Re(i.body)?E["Content-Type"]="text/plain":er(i.body)||(E["Content-Type"]="application/json")),E},or=r=>{if(r.body)return r.body},dr=async(r,i,s,a,p,u,o)=>{let f=ot.CancelToken.source(),E={url:s,headers:u,data:a??p,method:i.method,withCredentials:r.WITH_CREDENTIALS,cancelToken:f.token};o(()=>f.cancel("The user aborted a request."));try{return await ot.request(E)}catch(h){let R=h;if(R.response)return R.response;throw h}},lr=(r,i)=>{if(i){let s=r.headers[i];if(Re(s))return s}},ur=r=>{if(r.status!==204)return r.data},pr=(r,i)=>{let a={400:"Bad Request",401:"Unauthorized",403:"Forbidden",404:"Not Found",500:"Internal Server Error",502:"Bad Gateway",503:"Service Unavailable",...r.errors}[i.status];if(a)throw new Z(r,i,a);if(!i.ok)throw new Z(r,i,"Generic Error")},ut=(r,i)=>new se(async(s,a,p)=>{try{let u=nr(r,i),o=sr(i),f=or(i),E=await ar(r,i,o);if(!p.isCancelled){let h=await dr(r,i,u,f,o,E,p),R=ur(h),g=lr(h,i.responseHeader),C={url:u,ok:tr(h.status),status:h.status,statusText:h.statusText,body:g??R};pr(i,C),s(C.body);}}catch(u){a(u);}});var ge=class extends ne{constructor(i){super(i);}request(i){return ut(this.config,i)}};var ae=class{constructor(i){this.httpRequest=i;}cancelOrders({chainName:i,requestBody:s}){return this.httpRequest.request({method:"POST",url:"/v1/chains/{chain_name}/orders/cancel",path:{chain_name:i},body:s,mediaType:"application/json",errors:{400:"Bad Request (400)",401:"Unauthorised Request (401)",404:"The specified resource was not found (404)",429:"Too Many Requests (429)",500:"Internal Server Error (500)",501:"Not Implemented Error (501)"}})}listListings({chainName:i,status:s,sellItemContractAddress:a,buyItemType:p,buyItemContractAddress:u,accountAddress:o,sellItemMetadataId:f,sellItemTokenId:E,fromUpdatedAt:h,pageSize:R,sortBy:g,sortDirection:C,pageCursor:y}){return this.httpRequest.request({method:"GET",url:"/v1/chains/{chain_name}/orders/listings",path:{chain_name:i},query:{status:s,sell_item_contract_address:a,buy_item_type:p,buy_item_contract_address:u,account_address:o,sell_item_metadata_id:f,sell_item_token_id:E,from_updated_at:h,page_size:R,sort_by:g,sort_direction:C,page_cursor:y},errors:{400:"Bad Request (400)",404:"The specified resource was not found (404)",500:"Internal Server Error (500)"}})}createListing({chainName:i,requestBody:s}){return this.httpRequest.request({method:"POST",url:"/v1/chains/{chain_name}/orders/listings",path:{chain_name:i},body:s,mediaType:"application/json",errors:{400:"Bad Request (400)",404:"The specified resource was not found (404)",500:"Internal Server Error (500)"}})}listBids({chainName:i,status:s,buyItemContractAddress:a,sellItemContractAddress:p,accountAddress:u,buyItemMetadataId:o,buyItemTokenId:f,fromUpdatedAt:E,pageSize:h,sortBy:R,sortDirection:g,pageCursor:C}){return this.httpRequest.request({method:"GET",url:"/v1/chains/{chain_name}/orders/bids",path:{chain_name:i},query:{status:s,buy_item_contract_address:a,sell_item_contract_address:p,account_address:u,buy_item_metadata_id:o,buy_item_token_id:f,from_updated_at:E,page_size:h,sort_by:R,sort_direction:g,page_cursor:C},errors:{400:"Bad Request (400)",404:"The specified resource was not found (404)",500:"Internal Server Error (500)"}})}createBid({chainName:i,requestBody:s}){return this.httpRequest.request({method:"POST",url:"/v1/chains/{chain_name}/orders/bids",path:{chain_name:i},body:s,mediaType:"application/json",errors:{400:"Bad Request (400)",404:"The specified resource was not found (404)",500:"Internal Server Error (500)",501:"Not Implemented Error (501)"}})}listCollectionBids({chainName:i,status:s,buyItemContractAddress:a,sellItemContractAddress:p,accountAddress:u,fromUpdatedAt:o,pageSize:f,sortBy:E,sortDirection:h,pageCursor:R}){return this.httpRequest.request({method:"GET",url:"/v1/chains/{chain_name}/orders/collection-bids",path:{chain_name:i},query:{status:s,buy_item_contract_address:a,sell_item_contract_address:p,account_address:u,from_updated_at:o,page_size:f,sort_by:E,sort_direction:h,page_cursor:R},errors:{400:"Bad Request (400)",404:"The specified resource was not found (404)",500:"Internal Server Error (500)"}})}createCollectionBid({chainName:i,requestBody:s}){return this.httpRequest.request({method:"POST",url:"/v1/chains/{chain_name}/orders/collection-bids",path:{chain_name:i},body:s,mediaType:"application/json",errors:{400:"Bad Request (400)",404:"The specified resource was not found (404)",500:"Internal Server Error (500)",501:"Not Implemented Error (501)"}})}listTraitBids({chainName:i,status:s,buyItemContractAddress:a,sellItemContractAddress:p,accountAddress:u,fromUpdatedAt:o,pageSize:f,sortBy:E,sortDirection:h,pageCursor:R}){return this.httpRequest.request({method:"GET",url:"/v1/chains/{chain_name}/orders/trait-bids",path:{chain_name:i},query:{status:s,buy_item_contract_address:a,sell_item_contract_address:p,account_address:u,from_updated_at:o,page_size:f,sort_by:E,sort_direction:h,page_cursor:R},errors:{400:"Bad Request (400)",404:"The specified resource was not found (404)",500:"Internal Server Error (500)"}})}createTraitBid({chainName:i,requestBody:s}){return this.httpRequest.request({method:"POST",url:"/v1/chains/{chain_name}/orders/trait-bids",path:{chain_name:i},body:s,mediaType:"application/json",errors:{400:"Bad Request (400)",404:"The specified resource was not found (404)",500:"Internal Server Error (500)",501:"Not Implemented Error (501)"}})}listMetadataBids({chainName:i,status:s,buyItemContractAddress:a,sellItemContractAddress:p,accountAddress:u,metadataId:o,fromUpdatedAt:f,pageSize:E,sortBy:h,sortDirection:R,pageCursor:g}){return this.httpRequest.request({method:"GET",url:"/v1/chains/{chain_name}/orders/metadata-bids",path:{chain_name:i},query:{status:s,buy_item_contract_address:a,sell_item_contract_address:p,account_address:u,metadata_id:o,from_updated_at:f,page_size:E,sort_by:h,sort_direction:R,page_cursor:g},errors:{400:"Bad Request (400)",404:"The specified resource was not found (404)",500:"Internal Server Error (500)"}})}createMetadataBid({chainName:i,requestBody:s}){return this.httpRequest.request({method:"POST",url:"/v1/chains/{chain_name}/orders/metadata-bids",path:{chain_name:i},body:s,mediaType:"application/json",errors:{400:"Bad Request (400)",404:"The specified resource was not found (404)",500:"Internal Server Error (500)",501:"Not Implemented Error (501)"}})}getMetadataBid({chainName:i,metadataBidId:s}){return this.httpRequest.request({method:"GET",url:"/v1/chains/{chain_name}/orders/metadata-bids/{metadata_bid_id}",path:{chain_name:i,metadata_bid_id:s},errors:{400:"Bad Request (400)",404:"The specified resource was not found (404)",500:"Internal Server Error (500)"}})}getListing({chainName:i,listingId:s}){return this.httpRequest.request({method:"GET",url:"/v1/chains/{chain_name}/orders/listings/{listing_id}",path:{chain_name:i,listing_id:s},errors:{400:"Bad Request (400)",404:"The specified resource was not found (404)",500:"Internal Server Error (500)"}})}getBid({chainName:i,bidId:s}){return this.httpRequest.request({method:"GET",url:"/v1/chains/{chain_name}/orders/bids/{bid_id}",path:{chain_name:i,bid_id:s},errors:{400:"Bad Request (400)",404:"The specified resource was not found (404)",500:"Internal Server Error (500)"}})}getCollectionBid({chainName:i,collectionBidId:s}){return this.httpRequest.request({method:"GET",url:"/v1/chains/{chain_name}/orders/collection-bids/{collection_bid_id}",path:{chain_name:i,collection_bid_id:s},errors:{400:"Bad Request (400)",404:"The specified resource was not found (404)",500:"Internal Server Error (500)"}})}getTraitBid({chainName:i,traitBidId:s}){return this.httpRequest.request({method:"GET",url:"/v1/chains/{chain_name}/orders/trait-bids/{trait_bid_id}",path:{chain_name:i,trait_bid_id:s},errors:{400:"Bad Request (400)",404:"The specified resource was not found (404)",500:"Internal Server Error (500)"}})}fulfillmentData({chainName:i,requestBody:s}){return this.httpRequest.request({method:"POST",url:"/v1/chains/{chain_name}/orders/fulfillment-data",path:{chain_name:i},body:s,mediaType:"application/json",errors:{400:"Bad Request (400)",404:"The specified resource was not found (404)",500:"Internal Server Error (500)"}})}listTrades({chainName:i,accountAddress:s,sellItemContractAddress:a,fromIndexedAt:p,pageSize:u,sortBy:o,sortDirection:f,pageCursor:E}){return this.httpRequest.request({method:"GET",url:"/v1/chains/{chain_name}/trades",path:{chain_name:i},query:{account_address:s,sell_item_contract_address:a,from_indexed_at:p,page_size:u,sort_by:o,sort_direction:f,page_cursor:E},errors:{400:"Bad Request (400)",404:"The specified resource was not found (404)",500:"Internal Server Error (500)"}})}getTrade({chainName:i,tradeId:s}){return this.httpRequest.request({method:"GET",url:"/v1/chains/{chain_name}/trades/{trade_id}",path:{chain_name:i,trade_id:s},errors:{400:"Bad Request (400)",404:"The specified resource was not found (404)",500:"Internal Server Error (500)"}})}};var oe=class{orders;request;constructor(i,s=ge){this.request=new s({BASE:i?.BASE??"https://api.immutable.com",VERSION:i?.VERSION??"1.0.0",WITH_CREDENTIALS:i?.WITH_CREDENTIALS??!1,CREDENTIALS:i?.CREDENTIALS??"include",TOKEN:i?.TOKEN,USERNAME:i?.USERNAME,PASSWORD:i?.PASSWORD,HEADERS:i?.HEADERS,ENCODE_PATH:i?.ENCODE_PATH}),this.orders=new ae(this.request);}};var pt;(i=>{(u=>(u.ON_CHAIN="ON_CHAIN",u.OFF_CHAIN="OFF_CHAIN",u.UNDERFUNDED="UNDERFUNDED"))(i.cancellation_type||={});})(pt||={});var ct;(i=>{(a=>a.FILLED="FILLED")(i.reason_code||={});})(ct||={});var k;(i=>{(o=>(o.ROYALTY="ROYALTY",o.MAKER_ECOSYSTEM="MAKER_ECOSYSTEM",o.TAKER_ECOSYSTEM="TAKER_ECOSYSTEM",o.PROTOCOL="PROTOCOL"))(i.type||={});})(k||={});var x;(i=>{(f=>(f.LISTING="LISTING",f.BID="BID",f.COLLECTION_BID="COLLECTION_BID",f.TRAIT_BID="TRAIT_BID",f.METADATA_BID="METADATA_BID"))(i.type||={});})(x||={});var Ie=(o=>(o.PENDING="PENDING",o.ACTIVE="ACTIVE",o.INACTIVE="INACTIVE",o.FILLED="FILLED",o.EXPIRED="EXPIRED",o.CANCELLED="CANCELLED",o))(Ie||{});var z;(i=>{(p=>(p.FULL_RESTRICTED="FULL_RESTRICTED",p.PARTIAL_RESTRICTED="PARTIAL_RESTRICTED"))(i.order_type||={});})(z||={});function q(r){throw new Error("Unreachable")}function Y(r){if(r.type!==x.type.LISTING)throw new Error("Order type must be LISTING");let i=r.sell.map(a=>{if(a.type==="ERC721")return {type:"ERC721",contractAddress:a.contract_address,tokenId:a.token_id};if(a.type==="ERC1155")return {type:"ERC1155",contractAddress:a.contract_address,tokenId:a.token_id,amount:a.amount};throw new Error("Listing sell items must either ERC721 or ERC1155")}),s=r.buy.map(a=>{if(a.type==="NATIVE")return {type:"NATIVE",amount:a.amount};if(a.type==="ERC20")return {type:"ERC20",contractAddress:a.contract_address,amount:a.amount};throw new Error("Listing buy items must be either NATIVE or ERC20")});return {id:r.id,type:r.type,chain:r.chain,accountAddress:r.account_address,sell:i,buy:s,fees:r.fees.map(a=>({amount:a.amount,recipientAddress:a.recipient_address,type:a.type})),status:r.status,fillStatus:r.fill_status,startAt:r.start_at,endAt:r.end_at,salt:r.salt,signature:r.signature,orderHash:r.order_hash,protocolData:{orderType:r.protocol_data.order_type,counter:r.protocol_data.counter,seaportAddress:r.protocol_data.seaport_address,seaportVersion:r.protocol_data.seaport_version,zoneAddress:r.protocol_data.zone_address},createdAt:r.created_at,updatedAt:r.updated_at}}function de(r){if(r.type!==x.type.BID)throw new Error("Order type must be BID");let i=r.sell.map(a=>{if(a.type==="ERC20")return {type:"ERC20",contractAddress:a.contract_address,amount:a.amount};throw new Error("Bid sell items must be ERC20")}),s=r.buy.map(a=>{if(a.type==="ERC721")return {type:"ERC721",contractAddress:a.contract_address,tokenId:a.token_id};if(a.type==="ERC1155")return {type:"ERC1155",contractAddress:a.contract_address,tokenId:a.token_id,amount:a.amount};throw new Error("Bid buy items must either ERC721 or ERC1155")});return {id:r.id,type:r.type,chain:r.chain,accountAddress:r.account_address,sell:i,buy:s,fees:r.fees.map(a=>({amount:a.amount,recipientAddress:a.recipient_address,type:a.type})),status:r.status,fillStatus:r.fill_status,startAt:r.start_at,endAt:r.end_at,salt:r.salt,signature:r.signature,orderHash:r.order_hash,protocolData:{orderType:r.protocol_data.order_type,counter:r.protocol_data.counter,seaportAddress:r.protocol_data.seaport_address,seaportVersion:r.protocol_data.seaport_version,zoneAddress:r.protocol_data.zone_address},createdAt:r.created_at,updatedAt:r.updated_at}}function cr(r){return r?.length?r.map(i=>({traitType:i.trait_type,values:[...i.values]})):[]}function le(r){if(r.type!==x.type.COLLECTION_BID)throw new Error("Order type must be COLLECTION_BID");let i=r.sell.map(a=>{if(a.type==="ERC20")return {type:"ERC20",contractAddress:a.contract_address,amount:a.amount};throw new Error("Collection bid sell items must be ERC20")}),s=r.buy.map(a=>{if(a.type==="ERC721_COLLECTION")return {type:"ERC721_COLLECTION",contractAddress:a.contract_address,amount:a.amount};if(a.type==="ERC1155_COLLECTION")return {type:"ERC1155_COLLECTION",contractAddress:a.contract_address,amount:a.amount};throw new Error("Collection bid buy items must either ERC721_COLLECTION or ERC1155_COLLECTION")});return {id:r.id,type:r.type,chain:r.chain,accountAddress:r.account_address,sell:i,buy:s,fees:r.fees.map(a=>({amount:a.amount,recipientAddress:a.recipient_address,type:a.type})),status:r.status,fillStatus:r.fill_status,startAt:r.start_at,endAt:r.end_at,salt:r.salt,signature:r.signature,orderHash:r.order_hash,protocolData:{orderType:r.protocol_data.order_type,counter:r.protocol_data.counter,seaportAddress:r.protocol_data.seaport_address,seaportVersion:r.protocol_data.seaport_version,zoneAddress:r.protocol_data.zone_address},createdAt:r.created_at,updatedAt:r.updated_at}}function ue(r){if(r.type!==x.type.TRAIT_BID)throw new Error("Order type must be TRAIT_BID");let i=r.sell.map(a=>{if(a.type==="ERC20")return {type:"ERC20",contractAddress:a.contract_address,amount:a.amount};throw new Error("Trait bid sell items must be ERC20")}),s=r.buy.map(a=>{if(a.type==="ERC721_COLLECTION")return {type:"ERC721_COLLECTION",contractAddress:a.contract_address,amount:a.amount};if(a.type==="ERC1155_COLLECTION")return {type:"ERC1155_COLLECTION",contractAddress:a.contract_address,amount:a.amount};throw new Error("Trait bid buy items must either ERC721_COLLECTION or ERC1155_COLLECTION")});return {id:r.id,type:r.type,chain:r.chain,accountAddress:r.account_address,sell:i,buy:s,fees:r.fees.map(a=>({amount:a.amount,recipientAddress:a.recipient_address,type:a.type})),status:r.status,fillStatus:r.fill_status,startAt:r.start_at,endAt:r.end_at,salt:r.salt,signature:r.signature,orderHash:r.order_hash,protocolData:{orderType:r.protocol_data.order_type,counter:r.protocol_data.counter,seaportAddress:r.protocol_data.seaport_address,seaportVersion:r.protocol_data.seaport_version,zoneAddress:r.protocol_data.zone_address},createdAt:r.created_at,updatedAt:r.updated_at,traitCriteria:cr(r.trait_criteria)}}function pe(r){if(r.type!==x.type.METADATA_BID)throw new Error("Order type must be METADATA_BID");let i=r.sell.map(a=>{if(a.type==="ERC20")return {type:"ERC20",contractAddress:a.contract_address,amount:a.amount};throw new Error("Metadata bid sell items must be ERC20")}),s=r.buy.map(a=>{if(a.type==="ERC721_COLLECTION")return {type:"ERC721_COLLECTION",contractAddress:a.contract_address,amount:a.amount};if(a.type==="ERC1155_COLLECTION")return {type:"ERC1155_COLLECTION",contractAddress:a.contract_address,amount:a.amount};throw new Error("Metadata bid buy items must either ERC721_COLLECTION or ERC1155_COLLECTION")});return {id:r.id,type:r.type,chain:r.chain,accountAddress:r.account_address,sell:i,buy:s,fees:r.fees.map(a=>({amount:a.amount,recipientAddress:a.recipient_address,type:a.type})),status:r.status,fillStatus:r.fill_status,startAt:r.start_at,endAt:r.end_at,salt:r.salt,signature:r.signature,orderHash:r.order_hash,protocolData:{orderType:r.protocol_data.order_type,counter:r.protocol_data.counter,seaportAddress:r.protocol_data.seaport_address,seaportVersion:r.protocol_data.seaport_version,zoneAddress:r.protocol_data.zone_address},createdAt:r.created_at,updatedAt:r.updated_at,metadataId:r.metadata_id??""}}function ce(r){switch(r.type){case x.type.LISTING:return Y(r);case x.type.BID:return de(r);case x.type.COLLECTION_BID:return le(r);case x.type.TRAIT_BID:return ue(r);case x.type.METADATA_BID:return pe(r);default:return q(r.type)}}function Ue(r){let i=r.buy.map(a=>{if(a.type==="NATIVE")return {type:"NATIVE",amount:a.amount};if(a.type==="ERC20")return {type:"ERC20",contractAddress:a.contract_address,amount:a.amount};if(a.type==="ERC721")return {type:"ERC721",contractAddress:a.contract_address,tokenId:a.token_id};if(a.type==="ERC1155")return {type:"ERC1155",contractAddress:a.contract_address,tokenId:a.token_id,amount:a.amount};throw new Error("Buy items must be NATIVE, ERC20, ERC721 or ERC1155")}),s=r.sell.map(a=>{if(a.type==="ERC20")return {type:"ERC20",contractAddress:a.contract_address,amount:a.amount};if(a.type==="ERC721")return {type:"ERC721",contractAddress:a.contract_address,tokenId:a.token_id};if(a.type==="ERC1155")return {type:"ERC1155",contractAddress:a.contract_address,tokenId:a.token_id,amount:a.amount};throw new Error("Sell items must be ERC20, ERC721 or ERC1155")});return {id:r.id,orderId:r.order_id,buy:i,sell:s,buyerFees:r.buyer_fees.map(a=>({amount:a.amount,recipientAddress:a.recipient_address,type:a.type})),fees:r.fees.map(a=>({amount:a.amount,recipientAddress:a.recipient_address,type:a.type})),chain:r.chain,indexedAt:r.indexed_at,blockchainMetadata:{blockNumber:r.blockchain_metadata.block_number,logIndex:r.blockchain_metadata.log_index,transactionHash:r.blockchain_metadata.transaction_hash,transactionIndex:r.blockchain_metadata.transaction_index},buyerAddress:r.buyer_address,makerAddress:r.maker_address,sellerAddress:r.seller_address,takerAddress:r.taker_address}}function K(r){return {nextCursor:r.next_cursor,previousCursor:r.previous_cursor}}var mr=(p=>(p[p.MAKER_ECOSYSTEM=k.type.MAKER_ECOSYSTEM]="MAKER_ECOSYSTEM",p[p.TAKER_ECOSYSTEM=k.type.TAKER_ECOSYSTEM]="TAKER_ECOSYSTEM",p[p.PROTOCOL=k.type.PROTOCOL]="PROTOCOL",p[p.ROYALTY=k.type.ROYALTY]="ROYALTY",p))(mr||{}),He=(s=>(s.TRANSACTION="TRANSACTION",s.SIGNABLE="SIGNABLE",s))(He||{}),mt=(a=>(a.APPROVAL="APPROVAL",a.FULFILL_ORDER="FULFILL_ORDER",a.CANCEL="CANCEL",a))(mt||{}),$e=(a=>(a.CREATE_LISTING="CREATE_ORDER",a.CREATE_ORDER="CREATE_ORDER",a.OFF_CHAIN_CANCELLATION="OFF_CHAIN_CANCELLATION",a))($e||{});var Ve="ImmutableSeaport",$="1.5",Te={OrderComponents:[{name:"offerer",type:"address"},{name:"zone",type:"address"},{name:"offer",type:"OfferItem[]"},{name:"consideration",type:"ConsiderationItem[]"},{name:"orderType",type:"uint8"},{name:"startTime",type:"uint256"},{name:"endTime",type:"uint256"},{name:"zoneHash",type:"bytes32"},{name:"salt",type:"uint256"},{name:"conduitKey",type:"bytes32"},{name:"counter",type:"uint256"}],OfferItem:[{name:"itemType",type:"uint8"},{name:"token",type:"address"},{name:"identifierOrCriteria",type:"uint256"},{name:"startAmount",type:"uint256"},{name:"endAmount",type:"uint256"}],ConsiderationItem:[{name:"itemType",type:"uint8"},{name:"token",type:"address"},{name:"identifierOrCriteria",type:"uint256"},{name:"startAmount",type:"uint256"},{name:"endAmount",type:"uint256"},{name:"recipient",type:"address"}]};var fr={integer:0,address:zeroPadValue("0x",20),bool:!1,bytes:"0x",string:""},ze=r=>r===void 0?!1:r!=null&&(["string","number"].includes(typeof r)&&BigInt(r)===0n||Array.isArray(r)&&r.every(ze)||typeof r=="object"&&Object.values(r).every(ze)||typeof r=="boolean"&&r===!1);function hr(r){let[,i]=r.match(/^bytes(\d+)$/)??[];return i?zeroPadValue("0x",parseInt(i)):(r.match(/^(u?)int(\d*)$/)&&(r="integer"),fr[r])}var Q=class r{constructor(i){this.types=i;for(let s in i){let a=this.getDefaultValue(s);if(this.defaultValues[s]=a,!ze(a))throw new Error(`Got non-empty value for type ${s} in default generator: ${a}`)}}defaultValues={};static from(i,s){let{defaultValues:a}=new r(i);return s?a[s]:a}getDefaultValue(i){if(this.defaultValues[i])return this.defaultValues[i];let s=hr(i);if(s!==void 0)return s;let a=i.match(/^(.*)(\x5b(\d*)\x5d)$/);if(a){let u=a[1],o=parseInt(a[3]);if(o>0){let f=this.getDefaultValue(u);return Array(o).fill(f)}return []}let p=this.types[i];if(p)return p.reduce((u,{name:o,type:f})=>({...u,[o]:this.getDefaultValue(f)}),{});throw new Error(`unknown type: ${i}`)}};var Rr=(r,i)=>Array(r).fill(0).map((s,a)=>i(a)),Ge=(r,i)=>Rr(Math.ceil(r.length/i),s=>r.slice(s*i,(s+1)*i)),ht=r=>toBeHex(r.toString("hex")),ee=r=>T.from(r.slice(2),"hex"),Ae=r=>ee(keccak256(r)),gr=r=>Ae(concat(r)),me=(r,i,s)=>(i>r.length&&r.push(...Array(i-r.length).fill(s)),r),yt=(r,i=!0)=>{if(r.length===0)throw new Error("empty tree");let a=[r.map(p=>{let u=T.isBuffer(p)?p:ee(p);return i?Ae(u):u})];for(;a[a.length-1].length>1;)a.push(Ir(a[a.length-1]));return a[a.length-1][0]},Ir=r=>Ge(r,2).map(gr);var Br=(r,i)=>new MerkleTree(r.map(ee),Ae,{complete:!0,sort:!1,hashLeaves:!1,fillDefaultHash:ee(i)}),br=(r,i,s=`0x${"ff".repeat(64)}`)=>concat([s,`0x${r.toString(16).padStart(6,"0")}`,AbiCoder.defaultAbiCoder().encode([`uint256[${i.length}]`],[i])]),_e=class{constructor(i,s,a,p,u){this.types=i;this.rootType=s;this.leafType=a;this.elements=p;this.depth=u;let o=TypedDataEncoder.from(i);this.encoder=o,this.leafHasher=f=>o.hashStruct(a,f),this.defaultNode=Q.from(i,a),this.defaultLeaf=this.leafHasher(this.defaultNode),this.tree=Br(this.getCompleteLeaves(),this.defaultLeaf);}tree;leafHasher;defaultNode;defaultLeaf;encoder;get completedSize(){return 2**this.depth}getCompleteElements(){let{elements:i}=this;return me([...i],this.completedSize,this.defaultNode)}getCompleteLeaves(){let i=this.elements.map(this.leafHasher);return me([...i],this.completedSize,this.defaultLeaf)}get root(){return this.tree.getHexRoot()}getProof(i){let a=this.getCompleteLeaves()[i],p=this.tree.getHexProof(a,i),u=this.tree.getHexRoot();return {leaf:a,proof:p,root:u}}getEncodedProofAndSignature(i,s){let{proof:a}=this.getProof(i);return br(i,a,s)}getDataToSign(){let i=this.getCompleteElements();for(;i.length>2;)i=Ge(i,2);return i}add(i){this.elements.push(i);}getBulkOrderHash(){let i=this.encoder.hashStruct("BulkOrder",{tree:this.getDataToSign()}),s=this.getCompleteLeaves().map(ee),a=ht(yt(s,!1)),p=keccak256(toUtf8Bytes(this.encoder.types.BulkOrder[0].type));if(keccak256(concat([p,a]))!==i)throw new Error("expected derived bulk order hash to match");return i}};function wr(r){return {...Te,BulkOrder:[{name:"tree",type:`OrderComponents${"[2]".repeat(r)}`}]}}function Lr(r){return Math.max(Math.ceil(Math.log2(r)),1)}function Rt(r,i=0,s=Lr(r.length+i)){let a=wr(s),p=Q.from(a,"OrderComponents"),u=[...r];return i>0&&(u=[...me([],i,p),...r]),new _e(a,"BulkOrder","OrderComponents",u,s)}function Tt(r){if([0,1,2,3].includes(Number(r)))return Number(r);throw new Error(`Unknown order type ${r}`)}function Oe(r){if([0,1,2,3,4,5].includes(Number(r)))return Number(r);throw new Error(`Unknown item type ${r}`)}function At(r){let s=JSON.parse(r).message;return {...s,orderType:Tt(s.orderType),salt:toBeHex(BigInt(s.salt)),offer:s.offer.map(a=>({...a,itemType:Oe(a.itemType)})),consideration:s.consideration.map(a=>({...a,itemType:Oe(a.itemType)}))}}function _t(r){let i=JSON.parse(r);return {components:i.message.tree.flat(1/0).filter(a=>a.offerer!=="0x0000000000000000000000000000000000000000").map(a=>({...a,orderType:Tt(a.orderType),salt:toBeHex(BigInt(a.salt)),offer:a.offer.map(p=>({...p,itemType:Oe(p.itemType)})),consideration:a.consideration.map(p=>({...p,itemType:Oe(p.itemType)}))})),types:i.types,value:i.message}}function Ot(r,i){let s=Rt(i);return i.map((a,p)=>s.getEncodedProofAndSignature(p,r))}function Sr(r){switch(r.type){case"NATIVE":throw new Error("NATIVE items are not supported in the offer");case"ERC20":return {itemType:1 .valueOf(),token:r.contract_address,identifierOrCriteria:"0",startAmount:r.amount,endAmount:r.amount};case"ERC721":return {itemType:2 .valueOf(),token:r.contract_address,identifierOrCriteria:r.token_id,startAmount:"1",endAmount:"1"};case"ERC1155":return {itemType:3 .valueOf(),token:r.contract_address,identifierOrCriteria:r.token_id,startAmount:r.amount,endAmount:r.amount};case"ERC721_COLLECTION":throw new Error("ERC721_COLLECTION items are not supported in the offer");case"ERC1155_COLLECTION":throw new Error("ERC1155_COLLECTION items are not supported in the offer");default:return q()}}function xr(r,i){switch(r.type){case"NATIVE":return {itemType:0 .valueOf(),startAmount:r.amount,endAmount:r.amount,token:ZeroAddress,identifierOrCriteria:"0",recipient:i};case"ERC20":return {itemType:1 .valueOf(),startAmount:r.amount,endAmount:r.amount,token:r.contract_address,identifierOrCriteria:"0",recipient:i};case"ERC721":return {itemType:2 .valueOf(),startAmount:"1",endAmount:"1",token:r.contract_address,identifierOrCriteria:r.token_id,recipient:i};case"ERC1155":return {itemType:3 .valueOf(),startAmount:r.amount,endAmount:r.amount,token:r.contract_address,identifierOrCriteria:r.token_id,recipient:i};case"ERC721_COLLECTION":return {itemType:4 .valueOf(),startAmount:r.amount,endAmount:r.amount,token:r.contract_address,identifierOrCriteria:"0",recipient:i};case"ERC1155_COLLECTION":return {itemType:5 .valueOf(),startAmount:r.amount,endAmount:r.amount,token:r.contract_address,identifierOrCriteria:"0",recipient:i};default:return q()}}function be(r){let i=r.sell.map(Sr),s=r.buy.map(o=>xr(o,r.account_address)),a=function(o){switch(o){case x.type.LISTING:return s[0];case x.type.BID:case x.type.COLLECTION_BID:case x.type.TRAIT_BID:case x.type.METADATA_BID:return i[0];default:return q()}}(r.type),p=function(o){switch(o){case z.order_type.FULL_RESTRICTED:return 2;case z.order_type.PARTIAL_RESTRICTED:return 3;default:return q()}}(r.protocol_data.order_type),u=r.fees.map(o=>({amount:o.amount,itemType:a.itemType,recipient:o.recipient_address,token:a.token,identifierOrCriteria:a.identifierOrCriteria}));return {orderComponents:{offerer:r.account_address,zone:r.protocol_data.zone_address,offer:i,consideration:s,orderType:p.valueOf(),startTime:Math.round(new Date(r.start_at).getTime()/1e3).toString(),endTime:Math.round(new Date(r.end_at).getTime()/1e3).toString(),zoneHash:ZeroHash,salt:r.salt,conduitKey:ZeroHash,counter:r.protocol_data.counter,totalOriginalConsiderationItems:s.length},tips:u}}function G(r,i,s){return async()=>{let a=await r.buildTransaction(),p={to:a.to,from:s,type:a.type,maxFeePerGas:a.maxFeePerGas?BigInt(a.maxFeePerGas):void 0,maxPriorityFeePerGas:a.maxPriorityFeePerGas?BigInt(a.maxPriorityFeePerGas):void 0,value:a.value?BigInt(a.value):void 0,data:a.data,nonce:a.nonce,chainId:i};return p.gasLimit=BigInt(await r.estimateGas()),p.gasLimit+=p.gasLimit/BigInt(5),p}}function bt(r){switch(r.type){case"ERC20":return {token:r.contractAddress,amount:r.amount};case"ERC721":return {itemType:2 .valueOf(),token:r.contractAddress,identifier:r.tokenId};case"ERC1155":return {itemType:3 .valueOf(),token:r.contractAddress,identifier:r.tokenId,amount:r.amount};default:return q()}}function wt(r,i){switch(r.type){case"NATIVE":return {amount:r.amount,recipient:i};case"ERC20":return {token:r.contractAddress,amount:r.amount,recipient:i};case"ERC721":return {itemType:2 .valueOf(),token:r.contractAddress,identifier:r.tokenId,recipient:i};case"ERC1155":return {itemType:3 .valueOf(),token:r.contractAddress,identifier:r.tokenId,amount:r.amount,recipient:i};case"ERC721_COLLECTION":return {itemType:2 .valueOf(),token:r.contractAddress,amount:r.amount,identifiers:[],recipient:i};case"ERC1155_COLLECTION":return {itemType:3 .valueOf(),token:r.contractAddress,amount:r.amount,identifiers:[],recipient:i};default:return q()}}var we=class r{constructor(i,s,a,p,u){this.seaportLibFactory=i;this.provider=s;this.seaportContractAddress=a;this.zoneContractAddress=p;this.rateLimitingKey=u;}async prepareBulkSeaportOrders(i,s){let{actions:a}=await this.createSeaportOrders(i,s),p=a.filter(C=>C.type==="approval"),u=await this.provider.getNetwork(),o=p.map(C=>({type:"TRANSACTION",purpose:"APPROVAL",buildTransaction:G(C.transactionMethods,u.chainId,i)})),f=a.find(C=>C.type==="createBulk");if(!f)throw new Error("No create bulk order action found");let E=await f.getMessageToSign(),{components:h,types:R,value:g}=_t(E);return o.push({type:"SIGNABLE",purpose:"CREATE_ORDER",message:await this.getTypedDataFromBulkOrderComponents(R,g)}),{actions:o,preparedOrders:h.map(C=>({orderComponents:C,orderHash:this.getSeaportLib().getOrderHash(C)}))}}async prepareSeaportOrder(i,s,a,p,u,o){let{actions:f}=await this.createSeaportOrder(i,s,a,p,u,o),E=[],h=f.find(y=>y.type==="approval");h&&E.push({type:"TRANSACTION",purpose:"APPROVAL",buildTransaction:G(h.transactionMethods,(await this.provider.getNetwork()).chainId,i)});let R=f.find(y=>y.type==="create");if(!R)throw new Error("No create order action found");let g=await R.getMessageToSign(),C=At(g);return E.push({type:"SIGNABLE",purpose:"CREATE_ORDER",message:await this.getTypedDataFromOrderComponents(C)}),{actions:E,orderComponents:C,orderHash:this.getSeaportLib().getOrderHash(C)}}async fulfillOrder(i,s,a,p,u){let{orderComponents:o,tips:f}=be(i),E=this.getSeaportLib(i),h=(await this.provider.getNetwork()).chainId,R={order:{parameters:o,signature:i.signature},unitsToFill:p,extraData:a,tips:f};u&&(R.considerationCriteria=u);let{actions:g}=await E.fulfillOrders({accountAddress:s,fulfillOrderDetails:[R]}),C=[],y=g.filter(O=>O.type==="approval");y.length>0&&y.forEach(O=>{C.push({type:"TRANSACTION",buildTransaction:G(O.transactionMethods,h,s),purpose:"APPROVAL"});});let I=g.find(O=>O.type==="exchange");if(!I)throw new Error("No exchange action found");return C.push({type:"TRANSACTION",buildTransaction:G(I.transactionMethods,h,s),purpose:"FULFILL_ORDER"}),{actions:C,expiration:r.getExpirationISOTimeFromExtraData(a),order:ce(i)}}async fulfillBulkOrders(i,s){let a=i.map(h=>{let{orderComponents:R,tips:g}=be(h.order),C={order:{parameters:R,signature:h.order.signature},unitsToFill:h.unitsToFill,extraData:h.extraData,tips:g};return h.considerationCriteria&&h.considerationCriteria.length>0&&(C.considerationCriteria=h.considerationCriteria),C}),{actions:p}=await this.getSeaportLib().fulfillOrders({fulfillOrderDetails:a,accountAddress:s}),u=[],o=p.filter(h=>h.type==="approval"),f=(await this.provider.getNetwork()).chainId;o.length>0&&o.forEach(h=>{u.push({type:"TRANSACTION",buildTransaction:G(h.transactionMethods,f,s),purpose:"APPROVAL"});});let E=p.find(h=>h.type==="exchange");if(!E)throw new Error("No exchange action found");return u.push({type:"TRANSACTION",buildTransaction:G(E.transactionMethods,(await this.provider.getNetwork()).chainId,s),purpose:"FULFILL_ORDER"}),{actions:u,expiration:a.map(h=>r.getExpirationISOTimeFromExtraData(h.extraData)).reduce((h,R)=>new Date(h)<new Date(R)?h:R)}}async cancelOrders(i,s){let a=i.map(o=>be(o).orderComponents),u=await this.getSeaportLib(i[0]).cancelOrders(a,s);return {type:"TRANSACTION",buildTransaction:G(u,(await this.provider.getNetwork()).chainId,s),purpose:"CANCEL"}}createSeaportOrders(i,s){return this.getSeaportLib().createBulkOrders(s.map(p=>{let{offerItem:u,considerationItem:o,allowPartialFills:f,orderStart:E,orderExpiry:h}=p;return {allowPartialFills:f,offer:[bt(u)],consideration:[wt(o,i)],startTime:(E.getTime()/1e3).toFixed(0),endTime:(h.getTime()/1e3).toFixed(0),zone:this.zoneContractAddress,restrictedByZone:!0}}),i)}createSeaportOrder(i,s,a,p,u,o){return this.getSeaportLib().createOrder({allowPartialFills:p,offer:[bt(s)],consideration:[wt(a,i)],startTime:(u.getTime()/1e3).toFixed(0),endTime:(o.getTime()/1e3).toFixed(0),zone:this.zoneContractAddress,restrictedByZone:!0},i)}async getTypedDataFromBulkOrderComponents(i,s){delete i.EIP712Domain;let{chainId:a}=await this.provider.getNetwork();return {domain:{name:Ve,version:$,chainId:a,verifyingContract:this.seaportContractAddress},types:i,value:s}}async getTypedDataFromOrderComponents(i){let{chainId:s}=await this.provider.getNetwork();return {domain:{name:Ve,version:$,chainId:s,verifyingContract:this.seaportContractAddress},types:Te,value:i}}getSeaportLib(i){let s=i?.protocol_data?.seaport_address??this.seaportContractAddress;return this.seaportLibFactory.create(s)}static getExpirationISOTimeFromExtraData(i){let s=i.slice(44,60),a=parseInt(s,16);return new Date(a*1e3).toISOString()}};function Le(r){switch(r.itemType){case 0:return {type:"NATIVE",amount:r.startAmount};case 1:return {type:"ERC20",contract_address:r.token,amount:r.startAmount};case 2:return {type:"ERC721",contract_address:r.token,token_id:r.identifierOrCriteria};case 3:return {type:"ERC1155",contract_address:r.token,token_id:r.identifierOrCriteria,amount:r.startAmount};case 4:return {type:"ERC721_COLLECTION",contract_address:r.token,amount:r.startAmount};case 5:return {type:"ERC1155_COLLECTION",contract_address:r.token,amount:r.startAmount};default:return q(r.itemType)}}function fe(r){if(r.itemType!==1)throw new Error(`Expected ERC20 item, got ${r.itemType}`);return {type:"ERC20",contract_address:r.token,amount:r.startAmount}}function Pe(r){switch(r.itemType){case 4:return {type:"ERC721_COLLECTION",contract_address:r.token,amount:r.startAmount};case 5:return {type:"ERC1155_COLLECTION",contract_address:r.token,amount:r.startAmount};case 1:case 0:case 2:case 3:throw new Error(`Unsupported item type ${r.itemType}`);default:return q(r.itemType)}}function te(r){switch(r){case 2:return z.order_type.FULL_RESTRICTED;case 3:return z.order_type.PARTIAL_RESTRICTED;case 0:case 1:throw new Error(`Unsupported order type ${r}`);default:return q()}}var Se=class{constructor(i,s,a){this.orderbookService=i;this.chainName=s;this.seaportAddress=a;}async fulfillmentData(i){return this.orderbookService.fulfillmentData({chainName:this.chainName,requestBody:i})}async getListing(i){return this.orderbookService.getListing({chainName:this.chainName,listingId:i})}async getBid(i){return this.orderbookService.getBid({chainName:this.chainName,bidId:i})}async getCollectionBid(i){return this.orderbookService.getCollectionBid({chainName:this.chainName,collectionBidId:i})}async getTraitBid(i){return this.orderbookService.getTraitBid({chainName:this.chainName,traitBidId:i})}async getTrade(i){return this.orderbookService.getTrade({chainName:this.chainName,tradeId:i})}async listListings(i){return this.orderbookService.listListings({chainName:this.chainName,...i})}async listBids(i){return this.orderbookService.listBids({chainName:this.chainName,...i})}async listCollectionBids(i){return this.orderbookService.listCollectionBids({chainName:this.chainName,...i})}async listTraitBids(i){return this.orderbookService.listTraitBids({chainName:this.chainName,...i})}async getMetadataBid(i){return this.orderbookService.getMetadataBid({chainName:this.chainName,metadataBidId:i})}async listMetadataBids(i){return this.orderbookService.listMetadataBids({chainName:this.chainName,...i})}async listTrades(i){return this.orderbookService.listTrades({chainName:this.chainName,...i})}async cancelOrders(i,s,a){return this.orderbookService.cancelOrders({chainName:this.chainName,requestBody:{account_address:s,orders:i,signature:a}})}async createListing({orderHash:i,orderComponents:s,orderSignature:a,makerFees:p}){if(s.offer.length!==1)throw new Error("Only one item can be listed for a listing");if(s.consideration.length!==1)throw new Error("Only one item can be used as currency for a listing");if(![2,3].includes(s.offer[0].itemType))throw new Error("Only ERC721 / ERC1155 tokens can be listed");if(![0,1].includes(s.consideration[0].itemType))throw new Error("Only Native / ERC20 tokens can be used as currency items in a listing");return this.orderbookService.createListing({chainName:this.chainName,requestBody:{account_address:s.offerer,buy:s.consideration.map(Le),fees:p.map(u=>({type:k.type.MAKER_ECOSYSTEM,amount:u.amount,recipient_address:u.recipientAddress})),end_at:new Date(parseInt(`${s.endTime.toString()}000`,10)).toISOString(),order_hash:i,protocol_data:{order_type:te(s.orderType),zone_address:s.zone,seaport_address:this.seaportAddress,seaport_version:$,counter:s.counter.toString()},salt:s.salt,sell:s.offer.map(Le),signature:a,start_at:new Date(parseInt(`${s.startTime.toString()}000`,10)).toISOString()}})}async createBid({orderHash:i,orderComponents:s,orderSignature:a,makerFees:p}){if(s.offer.length!==1)throw new Error("Only one item can be listed for a bid");if(s.consideration.length!==1)throw new Error("Only one item can be used as currency for a bid");if(1!==s.offer[0].itemType)throw new Error("Only ERC20 tokens can be used as the currency item in a bid");if(![2,3].includes(s.consideration[0].itemType))throw new Error("Only ERC721 / ERC1155 tokens can be bid against");return this.orderbookService.createBid({chainName:this.chainName,requestBody:{account_address:s.offerer,buy:s.consideration.map(Le),fees:p.map(u=>({type:k.type.MAKER_ECOSYSTEM,amount:u.amount,recipient_address:u.recipientAddress})),end_at:new Date(parseInt(`${s.endTime.toString()}000`,10)).toISOString(),order_hash:i,protocol_data:{order_type:te(s.orderType),zone_address:s.zone,seaport_address:this.seaportAddress,seaport_version:$,counter:s.counter.toString()},salt:s.salt,sell:s.offer.map(fe),signature:a,start_at:new Date(parseInt(`${s.startTime.toString()}000`,10)).toISOString()}})}async createCollectionBid({orderHash:i,orderComponents:s,orderSignature:a,makerFees:p}){if(s.offer.length!==1)throw new Error("Only one item can be listed for a collection bid");if(s.consideration.length!==1)throw new Error("Only one item can be used as currency for a collection bid");if(1!==s.offer[0].itemType)throw new Error("Only ERC20 tokens can be used as the currency item in a collection bid");if(![4,5].includes(s.consideration[0].itemType))throw new Error("Only ERC721 / ERC1155 collection based tokens can be bid against");return this.orderbookService.createCollectionBid({chainName:this.chainName,requestBody:{account_address:s.offerer,buy:s.consideration.map(Pe),fees:p.map(u=>({type:k.type.MAKER_ECOSYSTEM,amount:u.amount,recipient_address:u.recipientAddress})),end_at:new Date(parseInt(`${s.endTime.toString()}000`,10)).toISOString(),order_hash:i,protocol_data:{order_type:te(s.orderType),zone_address:s.zone,seaport_address:this.seaportAddress,seaport_version:$,counter:s.counter.toString()},salt:s.salt,sell:s.offer.map(fe),signature:a,start_at:new Date(parseInt(`${s.startTime.toString()}000`,10)).toISOString()}})}async createMetadataBid({orderHash:i,orderComponents:s,orderSignature:a,makerFees:p,metadataId:u}){if(s.offer.length!==1)throw new Error("Only one item can be listed for a metadata bid");if(s.consideration.length!==1)throw new Error("Only one item can be used as currency for a metadata bid");if(1!==s.offer[0].itemType)throw new Error("Only ERC20 tokens can be used as the currency item in a metadata bid");if(![4,5].includes(s.consideration[0].itemType))throw new Error("Only ERC721 / ERC1155 collection based tokens can be bid against");if(!u)throw new Error("A metadata_id is required for a metadata bid");return this.orderbookService.createMetadataBid({chainName:this.chainName,requestBody:{account_address:s.offerer,buy:s.consideration.map(Pe),fees:p.map(o=>({type:k.type.MAKER_ECOSYSTEM,amount:o.amount,recipient_address:o.recipientAddress})),end_at:new Date(parseInt(`${s.endTime.toString()}000`,10)).toISOString(),order_hash:i,protocol_data:{order_type:te(s.orderType),zone_address:s.zone,seaport_address:this.seaportAddress,seaport_version:$,counter:s.counter.toString()},salt:s.salt,sell:s.offer.map(fe),signature:a,start_at:new Date(parseInt(`${s.startTime.toString()}000`,10)).toISOString(),metadata_id:u}})}async createTraitBid({orderHash:i,orderComponents:s,orderSignature:a,makerFees:p,traitCriteria:u}){if(s.offer.length!==1)throw new Error("Only one item can be listed for a trait bid");if(s.consideration.length!==1)throw new Error("Only one item can be used as currency for a trait bid");if(1!==s.offer[0].itemType)throw new Error("Only ERC20 tokens can be used as the currency item in a trait bid");if(![4,5].includes(s.consideration[0].itemType))throw new Error("Only ERC721 / ERC1155 collection based tokens can be bid against");if(!u?.length)throw new Error("At least one trait criterion is required for a trait bid");return this.orderbookService.createTraitBid({chainName:this.chainName,requestBody:{account_address:s.offerer,buy:s.consideration.map(Pe),fees:p.map(o=>({type:k.type.MAKER_ECOSYSTEM,amount:o.amount,recipient_address:o.recipientAddress})),end_at:new Date(parseInt(`${s.endTime.toString()}000`,10)).toISOString(),order_hash:i,protocol_data:{order_type:te(s.orderType),zone_address:s.zone,seaport_address:this.seaportAddress,seaport_version:$,counter:s.counter.toString()},salt:s.salt,sell:s.offer.map(fe),signature:a,start_at:new Date(parseInt(`${s.startTime.toString()}000`,10)).toISOString(),trait_criteria:u.map(o=>({trait_type:o.traitType,values:o.values}))}})}};var xe=class{constructor(i,s,a,p){this.chainName=s;this.seaportAddress=a;this.orderbookClient=new oe({BASE:i,HEADERS:p?{"x-api-key":p}:void 0});}orderbookClient;create(){return new Se(this.orderbookClient.orders,this.chainName,this.seaportAddress)}};var Dr="imtbl-zkevm-testnet",Fr="imtbl-zkevm-mainnet";function Ne(r,i){let s=new FetchRequest(r);return i&&s.setHeader("x-api-key",i),new JsonRpcProvider(s)}function Pt(r){switch(r.baseConfig.environment){case Environment.SANDBOX:return {seaportContractAddress:"0x7d117aA8BD6D31c4fa91722f246388f38ab1942c",zoneContractAddress:"0x1004f9615E79462c711Ff05a386BdbA91a7628C3",apiEndpoint:"https://api.sandbox.immutable.com",chainName:Dr,provider:Ne("https://rpc.testnet.immutable.com",r.baseConfig.rateLimitingKey)};case Environment.PRODUCTION:return {seaportContractAddress:"0x6c12aD6F0bD274191075Eb2E78D7dA5ba6453424",zoneContractAddress:"0x1004f9615E79462c711Ff05a386BdbA91a7628C3",apiEndpoint:"https://api.immutable.com",chainName:Fr,provider:Ne("https://rpc.immutable.com",r.baseConfig.rateLimitingKey)};default:return null}}var ke=class{constructor(i,s){this.defaultSeaportContractAddress=i;this.provider=s;}create(i){let s=i??this.defaultSeaportContractAddress,a=this.provider;return a.getSigner=async function(u){u==null&&(u=0);let o=this.send("eth_accounts",[]);if(typeof u=="number"){let f=await o;if(u>=f.length)throw new Error("no such account");return new JsonRpcSigner(this,f[u])}return new JsonRpcSigner(this,u)},new Seaport(a,{balanceAndApprovalChecksOnOrderCreation:!0,overrides:{contractAddress:s}})}};var je=class r{apiClient;seaport;orderbookConfig;constructor(i){let a={...Pt(i),...i.overrides};if(i.overrides?.jsonRpcProviderUrl&&(a.provider=Ne(i.overrides?.jsonRpcProviderUrl,i.baseConfig.rateLimitingKey)),!a)throw new Error("Orderbook configuration not passed, please specify the environment under config.baseConfig.environment");this.orderbookConfig=a;let{apiEndpoint:p,chainName:u}=this.orderbookConfig;if(!p)throw new Error("API endpoint must be provided");this.apiClient=new xe(p,u,this.orderbookConfig.seaportContractAddress,i.baseConfig.rateLimitingKey).create();let o=new ke(this.orderbookConfig.seaportContractAddress,this.orderbookConfig.provider);this.seaport=new we(o,this.orderbookConfig.provider,this.orderbookConfig.seaportContractAddress,this.orderbookConfig.zoneContractAddress,i.baseConfig.rateLimitingKey);}static defaultOrderExpiry(){return new Date(Date.now()+1e3*60*60*24*365*2)}config(){return this.orderbookConfig}async getListing(i){let s=await this.apiClient.getListing(i);return {result:Y(s.result)}}async getBid(i){let s=await this.apiClient.getBid(i);return {result:de(s.result)}}async getCollectionBid(i){let s=await this.apiClient.getCollectionBid(i);return {result:le(s.result)}}async getTraitBid(i){let s=await this.apiClient.getTraitBid(i);return {result:ue(s.result)}}async getMetadataBid(i){let s=await this.apiClient.getMetadataBid(i);return {result:pe(s.result)}}async getTrade(i){let s=await this.apiClient.getTrade(i);return {result:Ue(s.result)}}async listListings(i){let s=await this.apiClient.listListings(i);return {page:K(s.page),result:s.result.map(Y)}}async listBids(i){let s=await this.apiClient.listBids(i);return {page:K(s.page),result:s.result.map(de)}}async listCollectionBids(i){let s=await this.apiClient.listCollectionBids(i);return {page:K(s.page),result:s.result.map(le)}}async listTraitBids(i){let s=await this.apiClient.listTraitBids(i);return {page:K(s.page),result:s.result.map(ue)}}async listMetadataBids(i){let s=await this.apiClient.listMetadataBids(i);return {page:K(s.page),result:s.result.map(pe)}}async listTrades(i){let s=await this.apiClient.listTrades(i);return {page:K(s.page),result:s.result.map(Ue)}}async prepareBulkListings({makerAddress:i,listingParams:s}){if(s.length>20)throw new Error("Bulk listing creation is limited to 20 orders");if(s.length===1){let o=await this.seaport.prepareSeaportOrder(i,s[0].sell,s[0].buy,s[0].sell.type==="ERC1155",s[0].orderStart||new Date,s[0].orderExpiry||r.defaultOrderExpiry());return {actions:o.actions,completeListings:async f=>{let E=await this.createListing({makerFees:s[0].makerFees,orderComponents:o.orderComponents,orderHash:o.orderHash,orderSignature:typeof f=="string"?f:f[0]});return {result:[{success:!0,orderHash:o.orderHash,order:E.result}]}}}}if(await this.orderbookConfig.provider.getCode(i)!=="0x"){track("orderbookmr","bulkListings",{walletType:"Passport",makerAddress:i,listingsCount:s.length});let o=await Promise.all(s.map(h=>this.seaport.prepareSeaportOrder(i,h.sell,h.buy,h.sell.type==="ERC1155",h.orderStart||new Date,h.orderExpiry||r.defaultOrderExpiry()))),f=[];return {actions:o.flatMap(h=>{let R=[];return h.actions.forEach(g=>{if(g.type==="TRANSACTION"){let C=h.orderComponents.offer[0].token;f.includes(C)||(f.push(C),R.push(g));}else R.push(g);}),R}),completeListings:async h=>{if(typeof h=="string")throw new Error("A signature per listing must be provided for smart contract wallets");return {result:(await Promise.all(o.map((C,y)=>{let I=h[y];return this.apiClient.createListing({makerFees:s[y].makerFees,orderComponents:C.orderComponents,orderHash:C.orderHash,orderSignature:I}).catch(()=>{})}))).map((C,y)=>({success:!!C,orderHash:o[y].orderHash,order:C?Y(C.result):void 0}))}}}}track("orderbookmr","bulkListings",{walletType:"EOA",makerAddress:i,listingsCount:s.length});let{actions:p,preparedOrders:u}=await this.seaport.prepareBulkSeaportOrders(i,s.map(o=>({offerItem:o.sell,considerationItem:o.buy,allowPartialFills:o.sell.type==="ERC1155",orderStart:o.orderStart||new Date,orderExpiry:o.orderExpiry||r.defaultOrderExpiry()})));return {actions:p,completeListings:async o=>{let f=typeof o=="object";if(f&&o.length!==1)throw new Error("Only a single signature is expected for bulk listing creation");let E=u.map(C=>C.orderComponents),h=f?o[0]:o,R=Ot(h,E);return {result:(await Promise.all(E.map((C,y)=>{let I=R[y],O=u[y],P=s[y];return this.apiClient.createListing({orderComponents:C,orderHash:O.orderHash,orderSignature:I,makerFees:P.makerFees}).catch(()=>{})}))).map((C,y)=>({success:!!C,orderHash:u[y].orderHash,order:C?Y(C.result):void 0}))}}}}async prepareListing({makerAddress:i,sell:s,buy:a,orderStart:p,orderExpiry:u}){return this.seaport.prepareSeaportOrder(i,s,a,s.type==="ERC1155",p||new Date,u||r.defaultOrderExpiry())}async createListing(i){let s=await this.apiClient.createListing(i);return {result:Y(s.result)}}async prepareBid({makerAddress:i,sell:s,buy:a,orderStart:p,orderExpiry:u}){return this.seaport.prepareSeaportOrder(i,s,a,a.type==="ERC1155",p||new Date,u||r.defaultOrderExpiry())}async createBid(i){let s=await this.apiClient.createBid(i);return {result:de(s.result)}}async prepareCollectionBid({makerAddress:i,sell:s,buy:a,orderStart:p,orderExpiry:u}){return this.seaport.prepareSeaportOrder(i,s,a,!0,p||new Date,u||r.defaultOrderExpiry())}async createCollectionBid(i){let s=await this.apiClient.createCollectionBid(i);return {result:le(s.result)}}async prepareTraitBid({makerAddress:i,sell:s,buy:a,orderStart:p,orderExpiry:u}){return this.seaport.prepareSeaportOrder(i,s,a,!0,p||new Date,u||r.defaultOrderExpiry())}async createTraitBid(i){let s=await this.apiClient.createTraitBid(i);return {result:ue(s.result)}}async prepareMetadataBid({makerAddress:i,sell:s,buy:a,orderStart:p,orderExpiry:u}){return this.seaport.prepareSeaportOrder(i,s,a,!0,p||new Date,u||r.defaultOrderExpiry())}async createMetadataBid(i){let s=await this.apiClient.createMetadataBid(i);return {result:pe(s.result)}}async fulfillOrder(i,s,a,p,u){let o={order_id:i,taker_address:s,fees:a.map(g=>({type:k.type.TAKER_ECOSYSTEM,amount:g.amount,recipient_address:g.recipientAddress}))},f=u?[{identifier:u,proof:[]}]:void 0;u&&(o.token_id=u);let E=await this.apiClient.fulfillmentData([o]);if(E.result.unfulfillable_orders?.length>0)throw new Error(`Unable to prepare fulfillment data: ${E.result.unfulfillable_orders[0].reason}`);if(E.result.fulfillable_orders?.length!==1)throw new Error("unexpected fulfillable order result length");let h=E.result.fulfillable_orders[0].extra_data,R=E.result.fulfillable_orders[0].order;if(R.status.name!=="ACTIVE")throw new Error(`Cannot fulfil order that is not active. Current status: ${R.status}`);return this.seaport.fulfillOrder(R,s,h,p,f)}async fulfillBulkOrders(i,s){let a=i.map(u=>{let o="listingId"in u;return {orderId:o?u.listingId:u.orderId,takerFees:u.takerFees,amountToFill:u.amountToFill,tokenId:o?void 0:u.tokenId}}),p=await this.apiClient.fulfillmentData(a.map(u=>({order_id:u.orderId,taker_address:s,fees:u.takerFees.map(o=>({type:k.type.TAKER_ECOSYSTEM,amount:o.amount,recipient_address:o.recipientAddress})),token_id:u?.tokenId})));try{let u=p.result.fulfillable_orders.map(o=>{let f=a.find(h=>h.orderId===o.order.id&&h.tokenId===o.token_id);if(!f){let h=`Could not find order for order ${o.order.id}`;throw o.token_id&&(h+=` and token ID ${o.token_id}`),new Error(h)}let E=[];return f.tokenId&&E.push({identifier:f.tokenId,proof:[]}),{extraData:o.extra_data,order:o.order,unitsToFill:f.amountToFill,considerationCriteria:E}});return {...await this.seaport.fulfillBulkOrders(u,s),fulfillableOrders:p.result.fulfillable_orders.map(o=>ce(o.order)),unfulfillableOrders:p.result.unfulfillable_orders.map(o=>({orderId:o.order_id,tokenId:o.token_id,reason:o.reason})),sufficientBalance:!0}}catch(u){if(String(u).includes("The fulfiller does not have the balances needed to fulfill."))return {fulfillableOrders:p.result.fulfillable_orders.map(o=>ce(o.order)),unfulfillableOrders:p.result.unfulfillable_orders.map(o=>({orderId:o.order_id,reason:o.reason})),sufficientBalance:!1};throw u}}async prepareOrderCancellations(i){let s=await this.orderbookConfig.provider.getNetwork(),a={name:"imtbl-order-book",chainId:Number(s.chainId),verifyingContract:this.orderbookConfig.seaportContractAddress},p={CancelPayload:[{name:"orders",type:"Order[]"}],Order:[{name:"id",type:"string"}]},u={orders:i.map(o=>({id:o}))};return {signableAction:{purpose:"OFF_CHAIN_CANCELLATION",type:"SIGNABLE",message:{domain:a,types:p,value:u}}}}async cancelOrders(i,s,a){return this.apiClient.cancelOrders(i,s,a)}async cancelOrdersOnChain(i,s){let a=Promise.all(i.map(C=>this.apiClient.getListing(C).catch(y=>{if(y.status!==404)throw y}))),p=Promise.all(i.map(C=>this.apiClient.getBid(C).catch(y=>{if(y.status!==404)throw y}))),u=Promise.all(i.map(C=>this.apiClient.getCollectionBid(C).catch(y=>{if(y.status!==404)throw y}))),o=Promise.all(i.map(C=>this.apiClient.getTraitBid(C).catch(y=>{if(y.status!==404)throw y}))),f=Promise.all(i.map(C=>this.apiClient.getMetadataBid(C).catch(y=>{if(y.status!==404)throw y}))),E=[await Promise.all([a,p,u,o,f])].flat(2).filter(C=>C!==void 0).map(C=>C.result);if(E.length!==i.length){let C=i.filter(y=>!E.some(I=>I.id===y));throw new Error(`Orders ${C} not found`)}for(let C of E)if(C.account_address!==s.toLowerCase())throw new Error(`Only account ${C.account_address} can cancel order ${C.id}`);let h=E.map(C=>C.protocol_data.seaport_address);if(new Set(h).size!==1)throw new Error("Cannot cancel multiple orders from different seaport contracts. Please group your orderIds accordingly");return {cancellationAction:await this.seaport.cancelOrders(E,s)}}};var Mr={estimatedFulfillmentGasGwei:4e5};/*! ieee754. BSD-3-Clause License. Feross Aboukhadijeh <https://feross.org/opensource> */
10
10
 
11
- export { Ue as ActionType, cr as FeeType, ge as OrderStatusName, Ge as Orderbook, He as SignablePurpose, ct as TransactionPurpose, vr as constants };
11
+ export { He as ActionType, mr as FeeType, Ie as OrderStatusName, je as Orderbook, $e as SignablePurpose, mt as TransactionPurpose, Mr as constants };