@imtbl/orderbook 2.19.0 → 2.20.0
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.
- package/dist/browser/index.js +2 -2
- package/dist/node/index.cjs +3 -3
- package/dist/node/index.js +2 -2
- package/dist/types/api-client/api-client.d.ts +1 -1
- package/dist/types/openapi/sdk/index.d.ts +1 -0
- package/dist/types/openapi/sdk/models/CreateMetadataBidRequestBody.d.ts +9 -2
- package/dist/types/openapi/sdk/models/MetadataFieldFilter.d.ts +14 -0
- package/dist/types/openapi/sdk/models/Order.d.ts +9 -1
- package/dist/types/orderbook.d.ts +8 -2
- package/dist/types/types.d.ts +49 -3
- package/package.json +3 -3
package/dist/browser/index.js
CHANGED
|
@@ -6,6 +6,6 @@ import { MerkleTree } from 'merkletreejs';
|
|
|
6
6
|
import { Environment } from '@imtbl/config';
|
|
7
7
|
import { Seaport } from '@opensea/seaport-js';
|
|
8
8
|
|
|
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> */
|
|
9
|
+
var ie={},nt=!1;function Zt(){if(nt)return ie;nt=!0,ie.byteLength=f,ie.toByteArray=h,ie.fromByteArray=C;for(var r=[],i=[],a=typeof Uint8Array<"u"?Uint8Array:Array,s="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",p=0,u=s.length;p<u;++p)r[p]=s[p],i[s.charCodeAt(p)]=p;i[45]=62,i[95]=63;function o(y){var T=y.length;if(T%4>0)throw new Error("Invalid string. Length must be a multiple of 4");var O=y.indexOf("=");O===-1&&(O=T);var P=O===T?0:4-O%4;return [O,P]}function f(y){var T=o(y),O=T[0],P=T[1];return (O+P)*3/4-P}function E(y,T,O){return (T+O)*3/4-O}function h(y){var T,O=o(y),P=O[0],D=O[1],S=new a(E(y,P,D)),M=0,U=D>0?P-4:P,F;for(F=0;F<U;F+=4)T=i[y.charCodeAt(F)]<<18|i[y.charCodeAt(F+1)]<<12|i[y.charCodeAt(F+2)]<<6|i[y.charCodeAt(F+3)],S[M++]=T>>16&255,S[M++]=T>>8&255,S[M++]=T&255;return D===2&&(T=i[y.charCodeAt(F)]<<2|i[y.charCodeAt(F+1)]>>4,S[M++]=T&255),D===1&&(T=i[y.charCodeAt(F)]<<10|i[y.charCodeAt(F+1)]<<4|i[y.charCodeAt(F+2)]>>2,S[M++]=T>>8&255,S[M++]=T&255),S}function g(y){return r[y>>18&63]+r[y>>12&63]+r[y>>6&63]+r[y&63]}function R(y,T,O){for(var P,D=[],S=T;S<O;S+=3)P=(y[S]<<16&16711680)+(y[S+1]<<8&65280)+(y[S+2]&255),D.push(g(P));return D.join("")}function C(y){for(var T,O=y.length,P=O%3,D=[],S=16383,M=0,U=O-P;M<U;M+=S)D.push(R(y,M,M+S>U?U:M+S));return P===1?(T=y[O-1],D.push(r[T>>2]+r[T<<4&63]+"==")):P===2&&(T=(y[O-2]<<8)+y[O-1],D.push(r[T>>10]+r[T>>4&63]+r[T<<2&63]+"=")),D.join("")}return ie}var ye={},at=!1;function Qt(){if(at)return ye;at=!0;return ye.read=function(r,i,a,s,p){var u,o,f=p*8-s-1,E=(1<<f)-1,h=E>>1,g=-7,R=a?p-1:0,C=a?-1:1,y=r[i+R];for(R+=C,u=y&(1<<-g)-1,y>>=-g,g+=f;g>0;u=u*256+r[i+R],R+=C,g-=8);for(o=u&(1<<-g)-1,u>>=-g,g+=s;g>0;o=o*256+r[i+R],R+=C,g-=8);if(u===0)u=1-h;else {if(u===E)return o?NaN:(y?-1:1)*(1/0);o=o+Math.pow(2,s),u=u-h;}return (y?-1:1)*o*Math.pow(2,u-s)},ye.write=function(r,i,a,s,p,u){var o,f,E,h=u*8-p-1,g=(1<<h)-1,R=g>>1,C=p===23?Math.pow(2,-24)-Math.pow(2,-77):0,y=s?0:u-1,T=s?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=g):(o=Math.floor(Math.log(i)/Math.LN2),i*(E=Math.pow(2,-o))<1&&(o--,E*=2),o+R>=1?i+=C/E:i+=C*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[a+y]=f&255,y+=T,f/=256,p-=8);for(o=o<<p|f,h+=p;h>0;r[a+y]=o&255,y+=T,o/=256,h-=8);r[a+y-T]|=O*128;},ye}var j={},st=!1;function er(){if(st)return j;st=!0;let r=Zt(),i=Qt(),a=typeof Symbol=="function"&&typeof Symbol.for=="function"?Symbol.for("nodejs.util.inspect.custom"):null;j.Buffer=o,j.SlowBuffer=D,j.INSPECT_MAX_BYTES=50;let s=2147483647;j.kMaxLength=s,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>s)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 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 T(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 g(n){return E(n),u(n<0?0:P(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=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 T(e.buffer,e.byteOffset,e.byteLength)}return C(n)}function T(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"||Me(n.length)?u(0):C(n);if(n.type==="Buffer"&&Array.isArray(n.data))return C(n.data)}function P(n){if(n>=s)throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+s.toString(16)+" bytes");return n|0}function D(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 De(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:De(n).length;e=(""+e).toLowerCase(),l=!0;}}o.byteLength=S;function M(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 Vt(this,e,t);case"utf8":case"utf-8":return Ye(this,e,t);case"ascii":return Ht(this,e,t);case"latin1":case"binary":return $t(this,e,t);case"base64":return qt(this,e,t);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return zt(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):M.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+">"},a&&(o.prototype[a]=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 F(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,Me(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 F(this,e,t,d,!0)},o.prototype.lastIndexOf=function(e,t,d){return F(this,e,t,d,!1)};function kt(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(Me(A))return m;n[t+m]=A;}return m}function Ft(n,e,t,d){return he(De(e,n.length-t),n,t,d)}function Dt(n,e,t,d){return he(Yt(e),n,t,d)}function Mt(n,e,t,d){return he(it(e),n,t,d)}function vt(n,e,t,d){return he(Kt(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 kt(this,e,t,d);case"utf8":case"utf-8":return Ft(this,e,t,d);case"ascii":case"latin1":case"binary":return Dt(this,e,t,d);case"base64":return Mt(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 qt(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 Ut(d)}let Ke=4096;function Ut(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 Ht(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 $t(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 Vt(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+=Jt[n[c]];return l}function zt(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 v(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;v(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;v(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||v(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||v(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||v(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||v(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||v(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);v(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);v(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||v(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||v(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||v(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||v(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||v(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 Fe(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}`}};}Fe("ERR_BUFFER_OUT_OF_BOUNDS",function(n){return n?`${n} is outside of buffer bounds`:"Attempt to access memory outside buffer bounds"},RangeError),Fe("ERR_INVALID_ARG_TYPE",function(n,e){return `The "${n}" argument must be of type number. Received type ${typeof e}`},TypeError),Fe("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 Gt(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)}Gt(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 jt=/[^+/0-9A-Za-z-_]/g;function Wt(n){if(n=n.split("=")[0],n=n.trim().replace(jt,""),n.length<2)return "";for(;n.length%4!==0;)n=n+"=";return n}function De(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 Yt(n){let e=[];for(let t=0;t<n.length;++t)e.push(n.charCodeAt(t)&255);return e}function Kt(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(Wt(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 Me(n){return n!==n}let Jt=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"?Xt:n}function Xt(){throw new Error("BigInt not supported")}return j}var W=er();W.Buffer;W.SlowBuffer;W.INSPECT_MAX_BYTES;W.kMaxLength;var I=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,a,s){super(s),this.name="ApiError",this.url=a.url,this.status=a.status,this.statusText=a.statusText,this.body=a.body,this.request=i;}};var Ce=class extends Error{constructor(i){super(i),this.name="CancelError";}get isCancelled(){return !0}},ae=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((a,s)=>{this._resolve=a,this._reject=s;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,a){return this._promise.then(i,a)}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,ge=r=>typeof r=="string",ve=r=>ge(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]),tr=r=>r instanceof dt,rr=r=>r>=200&&r<300,ir=r=>{try{return btoa(r)}catch{return I.from(r).toString("base64")}},nr=r=>{let i=[],a=(p,u)=>{i.push(`${encodeURIComponent(p)}=${encodeURIComponent(String(u))}`);},s=(p,u)=>{qe(u)&&(Array.isArray(u)?u.forEach(o=>{s(p,o);}):typeof u=="object"?Object.entries(u).forEach(([o,f])=>{s(`${p}[${o}]`,f);}):a(p,u));};return Object.entries(r).forEach(([p,u])=>{s(p,u);}),i.length>0?`?${i.join("&")}`:""},ar=(r,i)=>{let a=r.ENCODE_PATH||encodeURI,s=i.url.replace("{api-version}",r.VERSION).replace(/{(.*?)}/g,(u,o)=>i.path?.hasOwnProperty(o)?a(String(i.path[o])):u),p=`${r.BASE}${s}`;return i.query?`${p}${nr(i.query)}`:p},sr=r=>{if(r.formData){let i=new dt,a=(s,p)=>{ge(p)||lt(p)?i.append(s,p):i.append(s,JSON.stringify(p));};return Object.entries(r.formData).filter(([s,p])=>qe(p)).forEach(([s,p])=>{Array.isArray(p)?p.forEach(u=>a(s,u)):a(s,p);}),i}},Ee=async(r,i)=>typeof i=="function"?i(r):i,or=async(r,i,a)=>{let s=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 a?.getHeaders=="function"&&a?.getHeaders()||{},E=Object.entries({Accept:"application/json",...o,...i.headers,...f}).filter(([h,g])=>qe(g)).reduce((h,[g,R])=>({...h,[g]:String(R)}),{});if(ve(s)&&(E.Authorization=`Bearer ${s}`),ve(p)&&ve(u)){let h=ir(`${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":ge(i.body)?E["Content-Type"]="text/plain":tr(i.body)||(E["Content-Type"]="application/json")),E},dr=r=>{if(r.body)return r.body},lr=async(r,i,a,s,p,u,o)=>{let f=ot.CancelToken.source(),E={url:a,headers:u,data:s??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 g=h;if(g.response)return g.response;throw h}},ur=(r,i)=>{if(i){let a=r.headers[i];if(ge(a))return a}},pr=r=>{if(r.status!==204)return r.data},cr=(r,i)=>{let s={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(s)throw new Z(r,i,s);if(!i.ok)throw new Z(r,i,"Generic Error")},ut=(r,i)=>new ae(async(a,s,p)=>{try{let u=ar(r,i),o=sr(i),f=dr(i),E=await or(r,i,o);if(!p.isCancelled){let h=await lr(r,i,u,f,o,E,p),g=pr(h),R=ur(h,i.responseHeader),C={url:u,ok:rr(h.status),status:h.status,statusText:h.statusText,body:R??g};cr(i,C),a(C.body);}}catch(u){s(u);}});var Re=class extends ne{constructor(i){super(i);}request(i){return ut(this.config,i)}};var se=class{constructor(i){this.httpRequest=i;}cancelOrders({chainName:i,requestBody:a}){return this.httpRequest.request({method:"POST",url:"/v1/chains/{chain_name}/orders/cancel",path:{chain_name:i},body:a,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:a,sellItemContractAddress:s,buyItemType:p,buyItemContractAddress:u,accountAddress:o,sellItemMetadataId:f,sellItemTokenId:E,fromUpdatedAt:h,pageSize:g,sortBy:R,sortDirection:C,pageCursor:y}){return this.httpRequest.request({method:"GET",url:"/v1/chains/{chain_name}/orders/listings",path:{chain_name:i},query:{status:a,sell_item_contract_address:s,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: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:a}){return this.httpRequest.request({method:"POST",url:"/v1/chains/{chain_name}/orders/listings",path:{chain_name:i},body:a,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:a,buyItemContractAddress:s,sellItemContractAddress:p,accountAddress:u,buyItemMetadataId:o,buyItemTokenId:f,fromUpdatedAt:E,pageSize:h,sortBy:g,sortDirection:R,pageCursor:C}){return this.httpRequest.request({method:"GET",url:"/v1/chains/{chain_name}/orders/bids",path:{chain_name:i},query:{status:a,buy_item_contract_address:s,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:C},errors:{400:"Bad Request (400)",404:"The specified resource was not found (404)",500:"Internal Server Error (500)"}})}createBid({chainName:i,requestBody:a}){return this.httpRequest.request({method:"POST",url:"/v1/chains/{chain_name}/orders/bids",path:{chain_name:i},body:a,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:a,buyItemContractAddress:s,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:a,buy_item_contract_address:s,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:a}){return this.httpRequest.request({method:"POST",url:"/v1/chains/{chain_name}/orders/collection-bids",path:{chain_name:i},body:a,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:a,buyItemContractAddress:s,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:a,buy_item_contract_address:s,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:a}){return this.httpRequest.request({method:"POST",url:"/v1/chains/{chain_name}/orders/trait-bids",path:{chain_name:i},body:a,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:a,buyItemContractAddress:s,sellItemContractAddress:p,accountAddress:u,metadataId:o,fromUpdatedAt:f,pageSize:E,sortBy:h,sortDirection:g,pageCursor:R}){return this.httpRequest.request({method:"GET",url:"/v1/chains/{chain_name}/orders/metadata-bids",path:{chain_name:i},query:{status:a,buy_item_contract_address:s,sell_item_contract_address:p,account_address:u,metadata_id:o,from_updated_at:f,page_size:E,sort_by:h,sort_direction:g,page_cursor:R},errors:{400:"Bad Request (400)",404:"The specified resource was not found (404)",500:"Internal Server Error (500)"}})}createMetadataBid({chainName:i,requestBody:a}){return this.httpRequest.request({method:"POST",url:"/v1/chains/{chain_name}/orders/metadata-bids",path:{chain_name:i},body:a,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:a}){return this.httpRequest.request({method:"GET",url:"/v1/chains/{chain_name}/orders/metadata-bids/{metadata_bid_id}",path:{chain_name:i,metadata_bid_id:a},errors:{400:"Bad Request (400)",404:"The specified resource was not found (404)",500:"Internal Server Error (500)"}})}getListing({chainName:i,listingId:a}){return this.httpRequest.request({method:"GET",url:"/v1/chains/{chain_name}/orders/listings/{listing_id}",path:{chain_name:i,listing_id:a},errors:{400:"Bad Request (400)",404:"The specified resource was not found (404)",500:"Internal Server Error (500)"}})}getBid({chainName:i,bidId:a}){return this.httpRequest.request({method:"GET",url:"/v1/chains/{chain_name}/orders/bids/{bid_id}",path:{chain_name:i,bid_id:a},errors:{400:"Bad Request (400)",404:"The specified resource was not found (404)",500:"Internal Server Error (500)"}})}getCollectionBid({chainName:i,collectionBidId:a}){return this.httpRequest.request({method:"GET",url:"/v1/chains/{chain_name}/orders/collection-bids/{collection_bid_id}",path:{chain_name:i,collection_bid_id:a},errors:{400:"Bad Request (400)",404:"The specified resource was not found (404)",500:"Internal Server Error (500)"}})}getTraitBid({chainName:i,traitBidId:a}){return this.httpRequest.request({method:"GET",url:"/v1/chains/{chain_name}/orders/trait-bids/{trait_bid_id}",path:{chain_name:i,trait_bid_id:a},errors:{400:"Bad Request (400)",404:"The specified resource was not found (404)",500:"Internal Server Error (500)"}})}fulfillmentData({chainName:i,requestBody:a}){return this.httpRequest.request({method:"POST",url:"/v1/chains/{chain_name}/orders/fulfillment-data",path:{chain_name:i},body:a,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:a,sellItemContractAddress:s,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:a,sell_item_contract_address:s,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:a}){return this.httpRequest.request({method:"GET",url:"/v1/chains/{chain_name}/trades/{trade_id}",path:{chain_name:i,trade_id:a},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,a=Re){this.request=new a({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 se(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=>{(s=>s.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 Te=(o=>(o.PENDING="PENDING",o.ACTIVE="ACTIVE",o.INACTIVE="INACTIVE",o.FILLED="FILLED",o.EXPIRED="EXPIRED",o.CANCELLED="CANCELLED",o))(Te||{});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(s=>{if(s.type==="ERC721")return {type:"ERC721",contractAddress:s.contract_address,tokenId:s.token_id};if(s.type==="ERC1155")return {type:"ERC1155",contractAddress:s.contract_address,tokenId:s.token_id,amount:s.amount};throw new Error("Listing sell items must either ERC721 or ERC1155")}),a=r.buy.map(s=>{if(s.type==="NATIVE")return {type:"NATIVE",amount:s.amount};if(s.type==="ERC20")return {type:"ERC20",contractAddress:s.contract_address,amount:s.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:a,fees:r.fees.map(s=>({amount:s.amount,recipientAddress:s.recipient_address,type:s.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(s=>{if(s.type==="ERC20")return {type:"ERC20",contractAddress:s.contract_address,amount:s.amount};throw new Error("Bid sell items must be ERC20")}),a=r.buy.map(s=>{if(s.type==="ERC721")return {type:"ERC721",contractAddress:s.contract_address,tokenId:s.token_id};if(s.type==="ERC1155")return {type:"ERC1155",contractAddress:s.contract_address,tokenId:s.token_id,amount:s.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:a,fees:r.fees.map(s=>({amount:s.amount,recipientAddress:s.recipient_address,type:s.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 mr(r){return r?.length?r.map(i=>({traitType:i.trait_type,values:[...i.values]})):[]}function fr(r){return r?.length?r.map(i=>({fieldName:i.field_name,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(s=>{if(s.type==="ERC20")return {type:"ERC20",contractAddress:s.contract_address,amount:s.amount};throw new Error("Collection bid sell items must be ERC20")}),a=r.buy.map(s=>{if(s.type==="ERC721_COLLECTION")return {type:"ERC721_COLLECTION",contractAddress:s.contract_address,amount:s.amount};if(s.type==="ERC1155_COLLECTION")return {type:"ERC1155_COLLECTION",contractAddress:s.contract_address,amount:s.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:a,fees:r.fees.map(s=>({amount:s.amount,recipientAddress:s.recipient_address,type:s.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(s=>{if(s.type==="ERC20")return {type:"ERC20",contractAddress:s.contract_address,amount:s.amount};throw new Error("Trait bid sell items must be ERC20")}),a=r.buy.map(s=>{if(s.type==="ERC721_COLLECTION")return {type:"ERC721_COLLECTION",contractAddress:s.contract_address,amount:s.amount};if(s.type==="ERC1155_COLLECTION")return {type:"ERC1155_COLLECTION",contractAddress:s.contract_address,amount:s.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:a,fees:r.fees.map(s=>({amount:s.amount,recipientAddress:s.recipient_address,type:s.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:mr(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(s=>{if(s.type==="ERC20")return {type:"ERC20",contractAddress:s.contract_address,amount:s.amount};throw new Error("Metadata bid sell items must be ERC20")}),a=r.buy.map(s=>{if(s.type==="ERC721_COLLECTION")return {type:"ERC721_COLLECTION",contractAddress:s.contract_address,amount:s.amount};if(s.type==="ERC1155_COLLECTION")return {type:"ERC1155_COLLECTION",contractAddress:s.contract_address,amount:s.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:a,fees:r.fees.map(s=>({amount:s.amount,recipientAddress:s.recipient_address,type:s.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,metadataCriteria:fr(r.metadata_criteria)}}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(s=>{if(s.type==="NATIVE")return {type:"NATIVE",amount:s.amount};if(s.type==="ERC20")return {type:"ERC20",contractAddress:s.contract_address,amount:s.amount};if(s.type==="ERC721")return {type:"ERC721",contractAddress:s.contract_address,tokenId:s.token_id};if(s.type==="ERC1155")return {type:"ERC1155",contractAddress:s.contract_address,tokenId:s.token_id,amount:s.amount};throw new Error("Buy items must be NATIVE, ERC20, ERC721 or ERC1155")}),a=r.sell.map(s=>{if(s.type==="ERC20")return {type:"ERC20",contractAddress:s.contract_address,amount:s.amount};if(s.type==="ERC721")return {type:"ERC721",contractAddress:s.contract_address,tokenId:s.token_id};if(s.type==="ERC1155")return {type:"ERC1155",contractAddress:s.contract_address,tokenId:s.token_id,amount:s.amount};throw new Error("Sell items must be ERC20, ERC721 or ERC1155")});return {id:r.id,orderId:r.order_id,buy:i,sell:a,buyerFees:r.buyer_fees.map(s=>({amount:s.amount,recipientAddress:s.recipient_address,type:s.type})),fees:r.fees.map(s=>({amount:s.amount,recipientAddress:s.recipient_address,type:s.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 hr=(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))(hr||{}),He=(a=>(a.TRANSACTION="TRANSACTION",a.SIGNABLE="SIGNABLE",a))(He||{}),mt=(s=>(s.APPROVAL="APPROVAL",s.FULFILL_ORDER="FULFILL_ORDER",s.CANCEL="CANCEL",s))(mt||{}),$e=(s=>(s.CREATE_LISTING="CREATE_ORDER",s.CREATE_ORDER="CREATE_ORDER",s.OFF_CHAIN_CANCELLATION="OFF_CHAIN_CANCELLATION",s))($e||{});var Ve="ImmutableSeaport",$="1.5",Ie={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 yr={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 Cr(r){let[,i]=r.match(/^bytes(\d+)$/)??[];return i?zeroPadValue("0x",parseInt(i)):(r.match(/^(u?)int(\d*)$/)&&(r="integer"),yr[r])}var Q=class r{constructor(i){this.types=i;for(let a in i){let s=this.getDefaultValue(a);if(this.defaultValues[a]=s,!ze(s))throw new Error(`Got non-empty value for type ${a} in default generator: ${s}`)}}defaultValues={};static from(i,a){let{defaultValues:s}=new r(i);return a?s[a]:s}getDefaultValue(i){if(this.defaultValues[i])return this.defaultValues[i];let a=Cr(i);if(a!==void 0)return a;let s=i.match(/^(.*)(\x5b(\d*)\x5d)$/);if(s){let u=s[1],o=parseInt(s[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 Tr=(r,i)=>Array(r).fill(0).map((a,s)=>i(s)),Ge=(r,i)=>Tr(Math.ceil(r.length/i),a=>r.slice(a*i,(a+1)*i)),ht=r=>toBeHex(r.toString("hex")),ee=r=>I.from(r.slice(2),"hex"),Ae=r=>ee(keccak256(r)),Ir=r=>Ae(concat(r)),me=(r,i,a)=>(i>r.length&&r.push(...Array(i-r.length).fill(a)),r),yt=(r,i=!0)=>{if(r.length===0)throw new Error("empty tree");let s=[r.map(p=>{let u=I.isBuffer(p)?p:ee(p);return i?Ae(u):u})];for(;s[s.length-1].length>1;)s.push(Ar(s[s.length-1]));return s[s.length-1][0]},Ar=r=>Ge(r,2).map(Ir);var wr=(r,i)=>new MerkleTree(r.map(ee),Ae,{complete:!0,sort:!1,hashLeaves:!1,fillDefaultHash:ee(i)}),Lr=(r,i,a=`0x${"ff".repeat(64)}`)=>concat([a,`0x${r.toString(16).padStart(6,"0")}`,AbiCoder.defaultAbiCoder().encode([`uint256[${i.length}]`],[i])]),_e=class{constructor(i,a,s,p,u){this.types=i;this.rootType=a;this.leafType=s;this.elements=p;this.depth=u;let o=TypedDataEncoder.from(i);this.encoder=o,this.leafHasher=f=>o.hashStruct(s,f),this.defaultNode=Q.from(i,s),this.defaultLeaf=this.leafHasher(this.defaultNode),this.tree=wr(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 s=this.getCompleteLeaves()[i],p=this.tree.getHexProof(s,i),u=this.tree.getHexRoot();return {leaf:s,proof:p,root:u}}getEncodedProofAndSignature(i,a){let{proof:s}=this.getProof(i);return Lr(i,s,a)}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()}),a=this.getCompleteLeaves().map(ee),s=ht(yt(a,!1)),p=keccak256(toUtf8Bytes(this.encoder.types.BulkOrder[0].type));if(keccak256(concat([p,s]))!==i)throw new Error("expected derived bulk order hash to match");return i}};function Pr(r){return {...Ie,BulkOrder:[{name:"tree",type:`OrderComponents${"[2]".repeat(r)}`}]}}function Sr(r){return Math.max(Math.ceil(Math.log2(r)),1)}function gt(r,i=0,a=Sr(r.length+i)){let s=Pr(a),p=Q.from(s,"OrderComponents"),u=[...r];return i>0&&(u=[...me([],i,p),...r]),new _e(s,"BulkOrder","OrderComponents",u,a)}function It(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 a=JSON.parse(r).message;return {...a,orderType:It(a.orderType),salt:toBeHex(BigInt(a.salt)),offer:a.offer.map(s=>({...s,itemType:Oe(s.itemType)})),consideration:a.consideration.map(s=>({...s,itemType:Oe(s.itemType)}))}}function _t(r){let i=JSON.parse(r);return {components:i.message.tree.flat(1/0).filter(s=>s.offerer!=="0x0000000000000000000000000000000000000000").map(s=>({...s,orderType:It(s.orderType),salt:toBeHex(BigInt(s.salt)),offer:s.offer.map(p=>({...p,itemType:Oe(p.itemType)})),consideration:s.consideration.map(p=>({...p,itemType:Oe(p.itemType)}))})),types:i.types,value:i.message}}function Ot(r,i){let a=gt(i);return i.map((s,p)=>a.getEncodedProofAndSignature(p,r))}function Nr(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 kr(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(Nr),a=r.buy.map(o=>kr(o,r.account_address)),s=function(o){switch(o){case x.type.LISTING:return a[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:s.itemType,recipient:o.recipient_address,token:s.token,identifierOrCriteria:s.identifierOrCriteria}));return {orderComponents:{offerer:r.account_address,zone:r.protocol_data.zone_address,offer:i,consideration:a,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:a.length},tips:u}}function G(r,i,a){return async()=>{let s=await r.buildTransaction(),p={to:s.to,from:a,type:s.type,maxFeePerGas:s.maxFeePerGas?BigInt(s.maxFeePerGas):void 0,maxPriorityFeePerGas:s.maxPriorityFeePerGas?BigInt(s.maxPriorityFeePerGas):void 0,value:s.value?BigInt(s.value):void 0,data:s.data,nonce:s.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,a,s,p,u){this.seaportLibFactory=i;this.provider=a;this.seaportContractAddress=s;this.zoneContractAddress=p;this.rateLimitingKey=u;}async prepareBulkSeaportOrders(i,a){let{actions:s}=await this.createSeaportOrders(i,a),p=s.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=s.find(C=>C.type==="createBulk");if(!f)throw new Error("No create bulk order action found");let E=await f.getMessageToSign(),{components:h,types:g,value:R}=_t(E);return o.push({type:"SIGNABLE",purpose:"CREATE_ORDER",message:await this.getTypedDataFromBulkOrderComponents(g,R)}),{actions:o,preparedOrders:h.map(C=>({orderComponents:C,orderHash:this.getSeaportLib().getOrderHash(C)}))}}async prepareSeaportOrder(i,a,s,p,u,o){let{actions:f}=await this.createSeaportOrder(i,a,s,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 g=f.find(y=>y.type==="create");if(!g)throw new Error("No create order action found");let R=await g.getMessageToSign(),C=At(R);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,a,s,p,u){let{orderComponents:o,tips:f}=be(i),E=this.getSeaportLib(i),h=(await this.provider.getNetwork()).chainId,g={order:{parameters:o,signature:i.signature},unitsToFill:p,extraData:s,tips:f};u&&(g.considerationCriteria=u);let{actions:R}=await E.fulfillOrders({accountAddress:a,fulfillOrderDetails:[g]}),C=[],y=R.filter(O=>O.type==="approval");y.length>0&&y.forEach(O=>{C.push({type:"TRANSACTION",buildTransaction:G(O.transactionMethods,h,a),purpose:"APPROVAL"});});let T=R.find(O=>O.type==="exchange");if(!T)throw new Error("No exchange action found");return C.push({type:"TRANSACTION",buildTransaction:G(T.transactionMethods,h,a),purpose:"FULFILL_ORDER"}),{actions:C,expiration:r.getExpirationISOTimeFromExtraData(s),order:ce(i)}}async fulfillBulkOrders(i,a){let s=i.map(h=>{let{orderComponents:g,tips:R}=be(h.order),C={order:{parameters:g,signature:h.order.signature},unitsToFill:h.unitsToFill,extraData:h.extraData,tips:R};return h.considerationCriteria&&h.considerationCriteria.length>0&&(C.considerationCriteria=h.considerationCriteria),C}),{actions:p}=await this.getSeaportLib().fulfillOrders({fulfillOrderDetails:s,accountAddress:a}),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,a),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,a),purpose:"FULFILL_ORDER"}),{actions:u,expiration:s.map(h=>r.getExpirationISOTimeFromExtraData(h.extraData)).reduce((h,g)=>new Date(h)<new Date(g)?h:g)}}async cancelOrders(i,a){let s=i.map(o=>be(o).orderComponents),u=await this.getSeaportLib(i[0]).cancelOrders(s,a);return {type:"TRANSACTION",buildTransaction:G(u,(await this.provider.getNetwork()).chainId,a),purpose:"CANCEL"}}createSeaportOrders(i,a){return this.getSeaportLib().createBulkOrders(a.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,a,s,p,u,o){return this.getSeaportLib().createOrder({allowPartialFills:p,offer:[bt(a)],consideration:[wt(s,i)],startTime:(u.getTime()/1e3).toFixed(0),endTime:(o.getTime()/1e3).toFixed(0),zone:this.zoneContractAddress,restrictedByZone:!0},i)}async getTypedDataFromBulkOrderComponents(i,a){delete i.EIP712Domain;let{chainId:s}=await this.provider.getNetwork();return {domain:{name:Ve,version:$,chainId:s,verifyingContract:this.seaportContractAddress},types:i,value:a}}async getTypedDataFromOrderComponents(i){let{chainId:a}=await this.provider.getNetwork();return {domain:{name:Ve,version:$,chainId:a,verifyingContract:this.seaportContractAddress},types:Ie,value:i}}getSeaportLib(i){let a=i?.protocol_data?.seaport_address??this.seaportContractAddress;return this.seaportLibFactory.create(a)}static getExpirationISOTimeFromExtraData(i){let a=i.slice(44,60),s=parseInt(a,16);return new Date(s*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 Fr=new Set(["name","image","description","animation_url","external_url","youtube_url"]),Lt="attribute:",Dr='name, image, description, animation_url, external_url, youtube_url, or "attribute:<trait_type>"';function Mr(r){return r.startsWith(Lt)&&r.length>Lt.length}function vr(r){return Fr.has(r)||Mr(r)}function qr(r){if(r.length===0)throw new Error("metadataCriteria must contain at least one filter");let i=new Set;r.forEach(a=>{if(!a.fieldName)throw new Error("metadataCriteria entries must have a non-empty fieldName");if(!vr(a.fieldName))throw new Error(`metadataCriteria fieldName "${a.fieldName}" must be one of ${Dr}`);if(!a.values||a.values.length===0)throw new Error(`metadataCriteria filter "${a.fieldName}" must have at least one value`);if(i.has(a.fieldName))throw new Error(`metadataCriteria contains duplicate fieldName "${a.fieldName}"; use a single filter per field with multiple values instead`);i.add(a.fieldName);});}var Se=class{constructor(i,a,s){this.orderbookService=i;this.chainName=a;this.seaportAddress=s;}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,a,s){return this.orderbookService.cancelOrders({chainName:this.chainName,requestBody:{account_address:a,orders:i,signature:s}})}async createListing({orderHash:i,orderComponents:a,orderSignature:s,makerFees:p}){if(a.offer.length!==1)throw new Error("Only one item can be listed for a listing");if(a.consideration.length!==1)throw new Error("Only one item can be used as currency for a listing");if(![2,3].includes(a.offer[0].itemType))throw new Error("Only ERC721 / ERC1155 tokens can be listed");if(![0,1].includes(a.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:a.offerer,buy:a.consideration.map(Le),fees:p.map(u=>({type:k.type.MAKER_ECOSYSTEM,amount:u.amount,recipient_address:u.recipientAddress})),end_at:new Date(parseInt(`${a.endTime.toString()}000`,10)).toISOString(),order_hash:i,protocol_data:{order_type:te(a.orderType),zone_address:a.zone,seaport_address:this.seaportAddress,seaport_version:$,counter:a.counter.toString()},salt:a.salt,sell:a.offer.map(Le),signature:s,start_at:new Date(parseInt(`${a.startTime.toString()}000`,10)).toISOString()}})}async createBid({orderHash:i,orderComponents:a,orderSignature:s,makerFees:p}){if(a.offer.length!==1)throw new Error("Only one item can be listed for a bid");if(a.consideration.length!==1)throw new Error("Only one item can be used as currency for a bid");if(1!==a.offer[0].itemType)throw new Error("Only ERC20 tokens can be used as the currency item in a bid");if(![2,3].includes(a.consideration[0].itemType))throw new Error("Only ERC721 / ERC1155 tokens can be bid against");return this.orderbookService.createBid({chainName:this.chainName,requestBody:{account_address:a.offerer,buy:a.consideration.map(Le),fees:p.map(u=>({type:k.type.MAKER_ECOSYSTEM,amount:u.amount,recipient_address:u.recipientAddress})),end_at:new Date(parseInt(`${a.endTime.toString()}000`,10)).toISOString(),order_hash:i,protocol_data:{order_type:te(a.orderType),zone_address:a.zone,seaport_address:this.seaportAddress,seaport_version:$,counter:a.counter.toString()},salt:a.salt,sell:a.offer.map(fe),signature:s,start_at:new Date(parseInt(`${a.startTime.toString()}000`,10)).toISOString()}})}async createCollectionBid({orderHash:i,orderComponents:a,orderSignature:s,makerFees:p}){if(a.offer.length!==1)throw new Error("Only one item can be listed for a collection bid");if(a.consideration.length!==1)throw new Error("Only one item can be used as currency for a collection bid");if(1!==a.offer[0].itemType)throw new Error("Only ERC20 tokens can be used as the currency item in a collection bid");if(![4,5].includes(a.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:a.offerer,buy:a.consideration.map(Pe),fees:p.map(u=>({type:k.type.MAKER_ECOSYSTEM,amount:u.amount,recipient_address:u.recipientAddress})),end_at:new Date(parseInt(`${a.endTime.toString()}000`,10)).toISOString(),order_hash:i,protocol_data:{order_type:te(a.orderType),zone_address:a.zone,seaport_address:this.seaportAddress,seaport_version:$,counter:a.counter.toString()},salt:a.salt,sell:a.offer.map(fe),signature:s,start_at:new Date(parseInt(`${a.startTime.toString()}000`,10)).toISOString()}})}async createMetadataBid(i){let{orderHash:a,orderComponents:s,orderSignature:p,makerFees:u,metadataId:o,metadataCriteria:f}=i;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");let E=!!o,h=!!f&&f.length>0;if(E&&h)throw new Error("Exactly one of metadataId or metadataCriteria must be provided, not both");if(!E&&!h)throw new Error("Exactly one of metadataId or metadataCriteria must be provided");return h&&qr(f),this.orderbookService.createMetadataBid({chainName:this.chainName,requestBody:{account_address:s.offerer,buy:s.consideration.map(Pe),fees:u.map(g=>({type:k.type.MAKER_ECOSYSTEM,amount:g.amount,recipient_address:g.recipientAddress})),end_at:new Date(parseInt(`${s.endTime.toString()}000`,10)).toISOString(),order_hash:a,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:p,start_at:new Date(parseInt(`${s.startTime.toString()}000`,10)).toISOString(),metadata_id:E?o:void 0,metadata_criteria:h?f.map(g=>({field_name:g.fieldName,values:g.values})):void 0}})}async createTraitBid({orderHash:i,orderComponents:a,orderSignature:s,makerFees:p,traitCriteria:u}){if(a.offer.length!==1)throw new Error("Only one item can be listed for a trait bid");if(a.consideration.length!==1)throw new Error("Only one item can be used as currency for a trait bid");if(1!==a.offer[0].itemType)throw new Error("Only ERC20 tokens can be used as the currency item in a trait bid");if(![4,5].includes(a.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:a.offerer,buy:a.consideration.map(Pe),fees:p.map(o=>({type:k.type.MAKER_ECOSYSTEM,amount:o.amount,recipient_address:o.recipientAddress})),end_at:new Date(parseInt(`${a.endTime.toString()}000`,10)).toISOString(),order_hash:i,protocol_data:{order_type:te(a.orderType),zone_address:a.zone,seaport_address:this.seaportAddress,seaport_version:$,counter:a.counter.toString()},salt:a.salt,sell:a.offer.map(fe),signature:s,start_at:new Date(parseInt(`${a.startTime.toString()}000`,10)).toISOString(),trait_criteria:u.map(o=>({trait_type:o.traitType,values:o.values}))}})}};var xe=class{constructor(i,a,s,p){this.chainName=a;this.seaportAddress=s;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 $r="imtbl-zkevm-testnet",Vr="imtbl-zkevm-mainnet";function Ne(r,i){let a=new FetchRequest(r);return i&&a.setHeader("x-api-key",i),new JsonRpcProvider(a)}function St(r){switch(r.baseConfig.environment){case Environment.SANDBOX:return {seaportContractAddress:"0x7d117aA8BD6D31c4fa91722f246388f38ab1942c",zoneContractAddress:"0x1004f9615E79462c711Ff05a386BdbA91a7628C3",apiEndpoint:"https://api.sandbox.immutable.com",chainName:$r,provider:Ne("https://rpc.testnet.immutable.com",r.baseConfig.rateLimitingKey)};case Environment.PRODUCTION:return {seaportContractAddress:"0x6c12aD6F0bD274191075Eb2E78D7dA5ba6453424",zoneContractAddress:"0x1004f9615E79462c711Ff05a386BdbA91a7628C3",apiEndpoint:"https://api.immutable.com",chainName:Vr,provider:Ne("https://rpc.immutable.com",r.baseConfig.rateLimitingKey)};default:return null}}var ke=class{constructor(i,a){this.defaultSeaportContractAddress=i;this.provider=a;}create(i){let a=i??this.defaultSeaportContractAddress,s=this.provider;return s.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(s,{balanceAndApprovalChecksOnOrderCreation:!0,overrides:{contractAddress:a}})}};var je=class r{apiClient;seaport;orderbookConfig;constructor(i){let s={...St(i),...i.overrides};if(i.overrides?.jsonRpcProviderUrl&&(s.provider=Ne(i.overrides?.jsonRpcProviderUrl,i.baseConfig.rateLimitingKey)),!s)throw new Error("Orderbook configuration not passed, please specify the environment under config.baseConfig.environment");this.orderbookConfig=s;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 a=await this.apiClient.getListing(i);return {result:Y(a.result)}}async getBid(i){let a=await this.apiClient.getBid(i);return {result:de(a.result)}}async getCollectionBid(i){let a=await this.apiClient.getCollectionBid(i);return {result:le(a.result)}}async getTraitBid(i){let a=await this.apiClient.getTraitBid(i);return {result:ue(a.result)}}async getMetadataBid(i){let a=await this.apiClient.getMetadataBid(i);return {result:pe(a.result)}}async getTrade(i){let a=await this.apiClient.getTrade(i);return {result:Ue(a.result)}}async listListings(i){let a=await this.apiClient.listListings(i);return {page:K(a.page),result:a.result.map(Y)}}async listBids(i){let a=await this.apiClient.listBids(i);return {page:K(a.page),result:a.result.map(de)}}async listCollectionBids(i){let a=await this.apiClient.listCollectionBids(i);return {page:K(a.page),result:a.result.map(le)}}async listTraitBids(i){let a=await this.apiClient.listTraitBids(i);return {page:K(a.page),result:a.result.map(ue)}}async listMetadataBids(i){let a=await this.apiClient.listMetadataBids(i);return {page:K(a.page),result:a.result.map(pe)}}async listTrades(i){let a=await this.apiClient.listTrades(i);return {page:K(a.page),result:a.result.map(Ue)}}async prepareBulkListings({makerAddress:i,listingParams:a}){if(a.length>20)throw new Error("Bulk listing creation is limited to 20 orders");if(a.length===1){let o=await this.seaport.prepareSeaportOrder(i,a[0].sell,a[0].buy,a[0].sell.type==="ERC1155",a[0].orderStart||new Date,a[0].orderExpiry||r.defaultOrderExpiry());return {actions:o.actions,completeListings:async f=>{let E=await this.createListing({makerFees:a[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:a.length});let o=await Promise.all(a.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 C=h.orderComponents.offer[0].token;f.includes(C)||(f.push(C),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((C,y)=>{let T=h[y];return this.apiClient.createListing({makerFees:a[y].makerFees,orderComponents:C.orderComponents,orderHash:C.orderHash,orderSignature:T}).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:a.length});let{actions:p,preparedOrders:u}=await this.seaport.prepareBulkSeaportOrders(i,a.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,g=Ot(h,E);return {result:(await Promise.all(E.map((C,y)=>{let T=g[y],O=u[y],P=a[y];return this.apiClient.createListing({orderComponents:C,orderHash:O.orderHash,orderSignature:T,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:a,buy:s,orderStart:p,orderExpiry:u}){return this.seaport.prepareSeaportOrder(i,a,s,a.type==="ERC1155",p||new Date,u||r.defaultOrderExpiry())}async createListing(i){let a=await this.apiClient.createListing(i);return {result:Y(a.result)}}async prepareBid({makerAddress:i,sell:a,buy:s,orderStart:p,orderExpiry:u}){return this.seaport.prepareSeaportOrder(i,a,s,s.type==="ERC1155",p||new Date,u||r.defaultOrderExpiry())}async createBid(i){let a=await this.apiClient.createBid(i);return {result:de(a.result)}}async prepareCollectionBid({makerAddress:i,sell:a,buy:s,orderStart:p,orderExpiry:u}){return this.seaport.prepareSeaportOrder(i,a,s,!0,p||new Date,u||r.defaultOrderExpiry())}async createCollectionBid(i){let a=await this.apiClient.createCollectionBid(i);return {result:le(a.result)}}async prepareTraitBid({makerAddress:i,sell:a,buy:s,orderStart:p,orderExpiry:u}){return this.seaport.prepareSeaportOrder(i,a,s,!0,p||new Date,u||r.defaultOrderExpiry())}async createTraitBid(i){let a=await this.apiClient.createTraitBid(i);return {result:ue(a.result)}}async prepareMetadataBid({makerAddress:i,sell:a,buy:s,orderStart:p,orderExpiry:u}){return this.seaport.prepareSeaportOrder(i,a,s,!0,p||new Date,u||r.defaultOrderExpiry())}async createMetadataBid(i){let a=await this.apiClient.createMetadataBid(i);return {result:pe(a.result)}}async fulfillOrder(i,a,s,p,u){let o={order_id:i,taker_address:a,fees:s.map(R=>({type:k.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,a,h,p,f)}async fulfillBulkOrders(i,a){let s=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(s.map(u=>({order_id:u.orderId,taker_address:a,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=s.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,a),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 a=await this.orderbookConfig.provider.getNetwork(),s={name:"imtbl-order-book",chainId:Number(a.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:s,types:p,value:u}}}}async cancelOrders(i,a,s){return this.apiClient.cancelOrders(i,a,s)}async cancelOrdersOnChain(i,a){let s=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([s,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(T=>T.id===y));throw new Error(`Orders ${C} not found`)}for(let C of E)if(C.account_address!==a.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,a)}}};var Gr={estimatedFulfillmentGasGwei:4e5};/*! ieee754. BSD-3-Clause License. Feross Aboukhadijeh <https://feross.org/opensource> */
|
|
10
10
|
|
|
11
|
-
export { He as ActionType,
|
|
11
|
+
export { He as ActionType, hr as FeeType, Te as OrderStatusName, je as Orderbook, $e as SignablePurpose, mt as TransactionPurpose, Gr as constants };
|