New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

@loaders.gl/flatgeobuf

Package Overview
Dependencies
Maintainers
7
Versions
236
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@loaders.gl/flatgeobuf - npm Package Compare versions

Comparing version 3.0.0-alpha.21 to 3.0.0-beta.1

2

dist/dist.es5.min.js

@@ -1,2 +0,2 @@

!function(t){var e={};function r(i){if(e[i])return e[i].exports;var s=e[i]={i:i,l:!1,exports:{}};return t[i].call(s.exports,s,s.exports,r),s.l=!0,s.exports}r.m=t,r.c=e,r.d=function(t,e,i){r.o(t,e)||Object.defineProperty(t,e,{enumerable:!0,get:i})},r.r=function(t){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})},r.t=function(t,e){if(1&e&&(t=r(t)),8&e)return t;if(4&e&&"object"==typeof t&&t&&t.__esModule)return t;var i=Object.create(null);if(r.r(i),Object.defineProperty(i,"default",{enumerable:!0,value:t}),2&e&&"string"!=typeof t)for(var s in t)r.d(i,s,function(e){return t[e]}.bind(null,s));return i},r.n=function(t){var e=t&&t.__esModule?function(){return t.default}:function(){return t};return r.d(e,"a",e),e},r.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},r.p="",r(r.s=0)}([function(t,e,r){"use strict";(function(e){var i=r(2),s="undefined"==typeof window?e:window;s.loaders=s.loaders||{},t.exports=Object.assign(s.loaders,i)}).call(this,r(1))},function(t,e){var r;r=function(){return this}();try{r=r||new Function("return this")()}catch(t){"object"==typeof window&&(r=window)}t.exports=r},function(t,e,r){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),Object.defineProperty(e,"FlatGeobufLoader",{enumerable:!0,get:function(){return i.FlatGeobufLoader}});var i=r(3)},function(t,e,r){"use strict";function i(t){return(i="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t})(t)}Object.defineProperty(e,"__esModule",{value:!0}),e.FlatGeobufLoader=e.FlatGeobufWorkerLoader=void 0;var s=function(t,e){if(!e&&t&&t.__esModule)return t;if(null===t||"object"!==i(t)&&"function"!=typeof t)return{default:t};var r=n(e);if(r&&r.has(t))return r.get(t);var s={},o=Object.defineProperty&&Object.getOwnPropertyDescriptor;for(var a in t)if("default"!==a&&Object.prototype.hasOwnProperty.call(t,a)){var b=o?Object.getOwnPropertyDescriptor(t,a):null;b&&(b.get||b.set)?Object.defineProperty(s,a,b):s[a]=t[a]}s.default=t,r&&r.set(t,s);return s}(r(4));function n(t){if("function"!=typeof WeakMap)return null;var e=new WeakMap,r=new WeakMap;return(n=function(t){return t?r:e})(t)}function o(t,e,r,i,s,n,o){try{var a=t[n](o),b=a.value}catch(t){return void r(t)}a.done?e(b):Promise.resolve(b).then(i,s)}function a(t,e){var r=Object.keys(t);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(t);e&&(i=i.filter((function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable}))),r.push.apply(r,i)}return r}function b(t){for(var e=1;e<arguments.length;e++){var r=null!=arguments[e]?arguments[e]:{};e%2?a(Object(r),!0).forEach((function(e){d(t,e,r[e])})):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(r)):a(Object(r)).forEach((function(e){Object.defineProperty(t,e,Object.getOwnPropertyDescriptor(r,e))}))}return t}function d(t,e,r){return e in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}var u={id:"flatgeobuf",name:"FlatGeobuf",module:"flatgeobuf",version:"3.0.0-alpha.21",worker:!0,extensions:["fgb"],category:"geometry",options:{flatgeobuf:{}}};e.FlatGeobufWorkerLoader=u;var h,f,c=b(b({},u),{},{parse:(h=regeneratorRuntime.mark((function t(e,r){return regeneratorRuntime.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.abrupt("return",(0,s.default)(e,r));case 1:case"end":return t.stop()}}),t)})),f=function(){var t=this,e=arguments;return new Promise((function(r,i){var s=h.apply(t,e);function n(t){o(s,r,i,n,a,"next",t)}function a(t){o(s,r,i,n,a,"throw",t)}n(void 0)}))},function(t,e){return f.apply(this,arguments)}),parseSync:s.default,parseInBatchesFromStream:s.parseFlatGeobufInBatches,binary:!0});e.FlatGeobufLoader=c},function(t,e,r){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.default=function(t,e){if(0===t.byteLength)return[];var r=new Uint8Array(t);return(0,i.deserialize)(r).features},e.parseFlatGeobufInBatches=function(t,e){return(0,i.deserializeStream)(t)};var i=r(5)},function(t,e,r){!function(t){"use strict";class e{constructor(t,e,r,i,s,n,o,a,b,d){this.name=t,this.type=e,this.title=r,this.description=i,this.width=s,this.precision=n,this.scale=o,this.nullable=a,this.unique=b,this.primary_key=d}}var r,i,s,n,o={SIZEOF_SHORT:2,SIZEOF_INT:4,FILE_IDENTIFIER_LENGTH:4,SIZE_PREFIX_LENGTH:4,Encoding:{UTF8_BYTES:1,UTF16_STRING:2}};o.int32=new Int32Array(2),o.float32=new Float32Array(o.int32.buffer),o.float64=new Float64Array(o.int32.buffer),o.isLittleEndian=1===new Uint16Array(new Uint8Array([1,0]).buffer)[0],o.Long=function(t,e){this.low=0|t,this.high=0|e},o.Long.create=function(t,e){return 0==t&&0==e?o.Long.ZERO:new o.Long(t,e)},o.Long.prototype.toFloat64=function(){return(this.low>>>0)+4294967296*this.high},o.Long.prototype.equals=function(t){return this.low==t.low&&this.high==t.high},o.Long.ZERO=new o.Long(0,0),o.Builder=function(t){if(t)e=t;else var e=1024;this.bb=o.ByteBuffer.allocate(e),this.space=e,this.minalign=1,this.vtable=null,this.vtable_in_use=0,this.isNested=!1,this.object_start=0,this.vtables=[],this.vector_num_elems=0,this.force_defaults=!1},o.Builder.prototype.clear=function(){this.bb.clear(),this.space=this.bb.capacity(),this.minalign=1,this.vtable=null,this.vtable_in_use=0,this.isNested=!1,this.object_start=0,this.vtables=[],this.vector_num_elems=0,this.force_defaults=!1},o.Builder.prototype.forceDefaults=function(t){this.force_defaults=t},o.Builder.prototype.dataBuffer=function(){return this.bb},o.Builder.prototype.asUint8Array=function(){return this.bb.bytes().subarray(this.bb.position(),this.bb.position()+this.offset())},o.Builder.prototype.prep=function(t,e){t>this.minalign&&(this.minalign=t);for(var r=1+~(this.bb.capacity()-this.space+e)&t-1;this.space<r+t+e;){var i=this.bb.capacity();this.bb=o.Builder.growByteBuffer(this.bb),this.space+=this.bb.capacity()-i}this.pad(r)},o.Builder.prototype.pad=function(t){for(var e=0;e<t;e++)this.bb.writeInt8(--this.space,0)},o.Builder.prototype.writeInt8=function(t){this.bb.writeInt8(this.space-=1,t)},o.Builder.prototype.writeInt16=function(t){this.bb.writeInt16(this.space-=2,t)},o.Builder.prototype.writeInt32=function(t){this.bb.writeInt32(this.space-=4,t)},o.Builder.prototype.writeInt64=function(t){this.bb.writeInt64(this.space-=8,t)},o.Builder.prototype.writeFloat32=function(t){this.bb.writeFloat32(this.space-=4,t)},o.Builder.prototype.writeFloat64=function(t){this.bb.writeFloat64(this.space-=8,t)},o.Builder.prototype.addInt8=function(t){this.prep(1,0),this.writeInt8(t)},o.Builder.prototype.addInt16=function(t){this.prep(2,0),this.writeInt16(t)},o.Builder.prototype.addInt32=function(t){this.prep(4,0),this.writeInt32(t)},o.Builder.prototype.addInt64=function(t){this.prep(8,0),this.writeInt64(t)},o.Builder.prototype.addFloat32=function(t){this.prep(4,0),this.writeFloat32(t)},o.Builder.prototype.addFloat64=function(t){this.prep(8,0),this.writeFloat64(t)},o.Builder.prototype.addFieldInt8=function(t,e,r){(this.force_defaults||e!=r)&&(this.addInt8(e),this.slot(t))},o.Builder.prototype.addFieldInt16=function(t,e,r){(this.force_defaults||e!=r)&&(this.addInt16(e),this.slot(t))},o.Builder.prototype.addFieldInt32=function(t,e,r){(this.force_defaults||e!=r)&&(this.addInt32(e),this.slot(t))},o.Builder.prototype.addFieldInt64=function(t,e,r){!this.force_defaults&&e.equals(r)||(this.addInt64(e),this.slot(t))},o.Builder.prototype.addFieldFloat32=function(t,e,r){(this.force_defaults||e!=r)&&(this.addFloat32(e),this.slot(t))},o.Builder.prototype.addFieldFloat64=function(t,e,r){(this.force_defaults||e!=r)&&(this.addFloat64(e),this.slot(t))},o.Builder.prototype.addFieldOffset=function(t,e,r){(this.force_defaults||e!=r)&&(this.addOffset(e),this.slot(t))},o.Builder.prototype.addFieldStruct=function(t,e,r){e!=r&&(this.nested(e),this.slot(t))},o.Builder.prototype.nested=function(t){if(t!=this.offset())throw new Error("FlatBuffers: struct must be serialized inline.")},o.Builder.prototype.notNested=function(){if(this.isNested)throw new Error("FlatBuffers: object serialization must not be nested.")},o.Builder.prototype.slot=function(t){this.vtable[t]=this.offset()},o.Builder.prototype.offset=function(){return this.bb.capacity()-this.space},o.Builder.growByteBuffer=function(t){var e=t.capacity();if(3221225472&e)throw new Error("FlatBuffers: cannot grow buffer beyond 2 gigabytes.");var r=e<<1,i=o.ByteBuffer.allocate(r);return i.setPosition(r-e),i.bytes().set(t.bytes(),r-e),i},o.Builder.prototype.addOffset=function(t){this.prep(o.SIZEOF_INT,0),this.writeInt32(this.offset()-t+o.SIZEOF_INT)},o.Builder.prototype.startObject=function(t){this.notNested(),null==this.vtable&&(this.vtable=[]),this.vtable_in_use=t;for(var e=0;e<t;e++)this.vtable[e]=0;this.isNested=!0,this.object_start=this.offset()},o.Builder.prototype.endObject=function(){if(null==this.vtable||!this.isNested)throw new Error("FlatBuffers: endObject called without startObject");this.addInt32(0);for(var t=this.offset(),e=this.vtable_in_use-1;e>=0&&0==this.vtable[e];e--);for(var r=e+1;e>=0;e--)this.addInt16(0!=this.vtable[e]?t-this.vtable[e]:0);this.addInt16(t-this.object_start);var i=(r+2)*o.SIZEOF_SHORT;this.addInt16(i);var s=0,n=this.space;t:for(e=0;e<this.vtables.length;e++){var a=this.bb.capacity()-this.vtables[e];if(i==this.bb.readInt16(a)){for(var b=o.SIZEOF_SHORT;b<i;b+=o.SIZEOF_SHORT)if(this.bb.readInt16(n+b)!=this.bb.readInt16(a+b))continue t;s=this.vtables[e];break}}return s?(this.space=this.bb.capacity()-t,this.bb.writeInt32(this.space,s-t)):(this.vtables.push(this.offset()),this.bb.writeInt32(this.bb.capacity()-t,this.offset()-t)),this.isNested=!1,t},o.Builder.prototype.finish=function(t,e,r){var i=r?o.SIZE_PREFIX_LENGTH:0;if(e){var s=e;if(this.prep(this.minalign,o.SIZEOF_INT+o.FILE_IDENTIFIER_LENGTH+i),s.length!=o.FILE_IDENTIFIER_LENGTH)throw new Error("FlatBuffers: file identifier must be length "+o.FILE_IDENTIFIER_LENGTH);for(var n=o.FILE_IDENTIFIER_LENGTH-1;n>=0;n--)this.writeInt8(s.charCodeAt(n))}this.prep(this.minalign,o.SIZEOF_INT+i),this.addOffset(t),i&&this.addInt32(this.bb.capacity()-this.space),this.bb.setPosition(this.space)},o.Builder.prototype.finishSizePrefixed=function(t,e){this.finish(t,e,!0)},o.Builder.prototype.requiredField=function(t,e){var r=this.bb.capacity()-t,i=r-this.bb.readInt32(r);if(0==this.bb.readInt16(i+e))throw new Error("FlatBuffers: field "+e+" must be set")},o.Builder.prototype.startVector=function(t,e,r){this.notNested(),this.vector_num_elems=e,this.prep(o.SIZEOF_INT,t*e),this.prep(r,t*e)},o.Builder.prototype.endVector=function(){return this.writeInt32(this.vector_num_elems),this.offset()},o.Builder.prototype.createString=function(t){if(t instanceof Uint8Array)var e=t;else{e=[];for(var r=0;r<t.length;){var i,s=t.charCodeAt(r++);(i=s<55296||s>=56320?s:(s<<10)+t.charCodeAt(r++)+-56613888)<128?e.push(i):(i<2048?e.push(i>>6&31|192):(i<65536?e.push(i>>12&15|224):e.push(i>>18&7|240,i>>12&63|128),e.push(i>>6&63|128)),e.push(63&i|128))}}this.addInt8(0),this.startVector(1,e.length,1),this.bb.setPosition(this.space-=e.length),r=0;for(var n=this.space,o=this.bb.bytes();r<e.length;r++)o[n++]=e[r];return this.endVector()},o.Builder.prototype.createLong=function(t,e){return o.Long.create(t,e)},o.ByteBuffer=function(t){this.bytes_=t,this.position_=0},o.ByteBuffer.allocate=function(t){return new o.ByteBuffer(new Uint8Array(t))},o.ByteBuffer.prototype.clear=function(){this.position_=0},o.ByteBuffer.prototype.bytes=function(){return this.bytes_},o.ByteBuffer.prototype.position=function(){return this.position_},o.ByteBuffer.prototype.setPosition=function(t){this.position_=t},o.ByteBuffer.prototype.capacity=function(){return this.bytes_.length},o.ByteBuffer.prototype.readInt8=function(t){return this.readUint8(t)<<24>>24},o.ByteBuffer.prototype.readUint8=function(t){return this.bytes_[t]},o.ByteBuffer.prototype.readInt16=function(t){return this.readUint16(t)<<16>>16},o.ByteBuffer.prototype.readUint16=function(t){return this.bytes_[t]|this.bytes_[t+1]<<8},o.ByteBuffer.prototype.readInt32=function(t){return this.bytes_[t]|this.bytes_[t+1]<<8|this.bytes_[t+2]<<16|this.bytes_[t+3]<<24},o.ByteBuffer.prototype.readUint32=function(t){return this.readInt32(t)>>>0},o.ByteBuffer.prototype.readInt64=function(t){return new o.Long(this.readInt32(t),this.readInt32(t+4))},o.ByteBuffer.prototype.readUint64=function(t){return new o.Long(this.readUint32(t),this.readUint32(t+4))},o.ByteBuffer.prototype.readFloat32=function(t){return o.int32[0]=this.readInt32(t),o.float32[0]},o.ByteBuffer.prototype.readFloat64=function(t){return o.int32[o.isLittleEndian?0:1]=this.readInt32(t),o.int32[o.isLittleEndian?1:0]=this.readInt32(t+4),o.float64[0]},o.ByteBuffer.prototype.writeInt8=function(t,e){this.bytes_[t]=e},o.ByteBuffer.prototype.writeUint8=function(t,e){this.bytes_[t]=e},o.ByteBuffer.prototype.writeInt16=function(t,e){this.bytes_[t]=e,this.bytes_[t+1]=e>>8},o.ByteBuffer.prototype.writeUint16=function(t,e){this.bytes_[t]=e,this.bytes_[t+1]=e>>8},o.ByteBuffer.prototype.writeInt32=function(t,e){this.bytes_[t]=e,this.bytes_[t+1]=e>>8,this.bytes_[t+2]=e>>16,this.bytes_[t+3]=e>>24},o.ByteBuffer.prototype.writeUint32=function(t,e){this.bytes_[t]=e,this.bytes_[t+1]=e>>8,this.bytes_[t+2]=e>>16,this.bytes_[t+3]=e>>24},o.ByteBuffer.prototype.writeInt64=function(t,e){this.writeInt32(t,e.low),this.writeInt32(t+4,e.high)},o.ByteBuffer.prototype.writeUint64=function(t,e){this.writeUint32(t,e.low),this.writeUint32(t+4,e.high)},o.ByteBuffer.prototype.writeFloat32=function(t,e){o.float32[0]=e,this.writeInt32(t,o.int32[0])},o.ByteBuffer.prototype.writeFloat64=function(t,e){o.float64[0]=e,this.writeInt32(t,o.int32[o.isLittleEndian?0:1]),this.writeInt32(t+4,o.int32[o.isLittleEndian?1:0])},o.ByteBuffer.prototype.getBufferIdentifier=function(){if(this.bytes_.length<this.position_+o.SIZEOF_INT+o.FILE_IDENTIFIER_LENGTH)throw new Error("FlatBuffers: ByteBuffer is too short to contain an identifier.");for(var t="",e=0;e<o.FILE_IDENTIFIER_LENGTH;e++)t+=String.fromCharCode(this.readInt8(this.position_+o.SIZEOF_INT+e));return t},o.ByteBuffer.prototype.__offset=function(t,e){var r=t-this.readInt32(t);return e<this.readInt16(r)?this.readInt16(r+e):0},o.ByteBuffer.prototype.__union=function(t,e){return t.bb_pos=e+this.readInt32(e),t.bb=this,t},o.ByteBuffer.prototype.__string=function(t,e){t+=this.readInt32(t);var r=this.readInt32(t),i="",s=0;if(t+=o.SIZEOF_INT,e===o.Encoding.UTF8_BYTES)return this.bytes_.subarray(t,t+r);for(;s<r;){var n,a=this.readUint8(t+s++);if(a<192)n=a;else{var b=this.readUint8(t+s++);if(a<224)n=(31&a)<<6|63&b;else{var d=this.readUint8(t+s++);n=a<240?(15&a)<<12|(63&b)<<6|63&d:(7&a)<<18|(63&b)<<12|(63&d)<<6|63&this.readUint8(t+s++)}}n<65536?i+=String.fromCharCode(n):(n-=65536,i+=String.fromCharCode(55296+(n>>10),56320+(1023&n)))}return i},o.ByteBuffer.prototype.__indirect=function(t){return t+this.readInt32(t)},o.ByteBuffer.prototype.__vector=function(t){return t+this.readInt32(t)+o.SIZEOF_INT},o.ByteBuffer.prototype.__vector_len=function(t){return this.readInt32(t+this.readInt32(t))},o.ByteBuffer.prototype.__has_identifier=function(t){if(t.length!=o.FILE_IDENTIFIER_LENGTH)throw new Error("FlatBuffers: file identifier must be length "+o.FILE_IDENTIFIER_LENGTH);for(var e=0;e<o.FILE_IDENTIFIER_LENGTH;e++)if(t.charCodeAt(e)!=this.readInt8(this.position_+o.SIZEOF_INT+e))return!1;return!0},o.ByteBuffer.prototype.createLong=function(t,e){return o.Long.create(t,e)},function(t){t[t.Unknown=0]="Unknown",t[t.Point=1]="Point",t[t.LineString=2]="LineString",t[t.Polygon=3]="Polygon",t[t.MultiPoint=4]="MultiPoint",t[t.MultiLineString=5]="MultiLineString",t[t.MultiPolygon=6]="MultiPolygon",t[t.GeometryCollection=7]="GeometryCollection",t[t.CircularString=8]="CircularString",t[t.CompoundCurve=9]="CompoundCurve",t[t.CurvePolygon=10]="CurvePolygon",t[t.MultiCurve=11]="MultiCurve",t[t.MultiSurface=12]="MultiSurface",t[t.Curve=13]="Curve",t[t.Surface=14]="Surface",t[t.PolyhedralSurface=15]="PolyhedralSurface",t[t.TIN=16]="TIN",t[t.Triangle=17]="Triangle"}(r||(r={})),function(t){t[t.Byte=0]="Byte",t[t.UByte=1]="UByte",t[t.Bool=2]="Bool",t[t.Short=3]="Short",t[t.UShort=4]="UShort",t[t.Int=5]="Int",t[t.UInt=6]="UInt",t[t.Long=7]="Long",t[t.ULong=8]="ULong",t[t.Float=9]="Float",t[t.Double=10]="Double",t[t.String=11]="String",t[t.Json=12]="Json",t[t.DateTime=13]="DateTime",t[t.Binary=14]="Binary"}(i||(i={}));class a{constructor(){this.bb=null,this.bb_pos=0}__init(t,e){return this.bb_pos=t,this.bb=e,this}static getRoot(t,e){return(e||new a).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRoot(t,e){return t.setPosition(t.position()+o.SIZE_PREFIX_LENGTH),(e||new a).__init(t.readInt32(t.position())+t.position(),t)}name(t){var e=this.bb.__offset(this.bb_pos,4);return e?this.bb.__string(this.bb_pos+e,t):null}type(){var t=this.bb.__offset(this.bb_pos,6);return t?this.bb.readUint8(this.bb_pos+t):i.Byte}title(t){var e=this.bb.__offset(this.bb_pos,8);return e?this.bb.__string(this.bb_pos+e,t):null}description(t){var e=this.bb.__offset(this.bb_pos,10);return e?this.bb.__string(this.bb_pos+e,t):null}width(){var t=this.bb.__offset(this.bb_pos,12);return t?this.bb.readInt32(this.bb_pos+t):-1}precision(){var t=this.bb.__offset(this.bb_pos,14);return t?this.bb.readInt32(this.bb_pos+t):-1}scale(){var t=this.bb.__offset(this.bb_pos,16);return t?this.bb.readInt32(this.bb_pos+t):-1}nullable(){var t=this.bb.__offset(this.bb_pos,18);return!t||!!this.bb.readInt8(this.bb_pos+t)}unique(){var t=this.bb.__offset(this.bb_pos,20);return!!t&&!!this.bb.readInt8(this.bb_pos+t)}primaryKey(){var t=this.bb.__offset(this.bb_pos,22);return!!t&&!!this.bb.readInt8(this.bb_pos+t)}metadata(t){var e=this.bb.__offset(this.bb_pos,24);return e?this.bb.__string(this.bb_pos+e,t):null}static start(t){t.startObject(11)}static addName(t,e){t.addFieldOffset(0,e,0)}static addType(t,e){t.addFieldInt8(1,e,i.Byte)}static addTitle(t,e){t.addFieldOffset(2,e,0)}static addDescription(t,e){t.addFieldOffset(3,e,0)}static addWidth(t,e){t.addFieldInt32(4,e,-1)}static addPrecision(t,e){t.addFieldInt32(5,e,-1)}static addScale(t,e){t.addFieldInt32(6,e,-1)}static addNullable(t,e){t.addFieldInt8(7,+e,1)}static addUnique(t,e){t.addFieldInt8(8,+e,0)}static addPrimaryKey(t,e){t.addFieldInt8(9,+e,0)}static addMetadata(t,e){t.addFieldOffset(10,e,0)}static end(t){var e=t.endObject();return t.requiredField(e,4),e}static create(t,e,r,i,s,n,o,b,d,u,h,f){return a.start(t),a.addName(t,e),a.addType(t,r),a.addTitle(t,i),a.addDescription(t,s),a.addWidth(t,n),a.addPrecision(t,o),a.addScale(t,b),a.addNullable(t,d),a.addUnique(t,u),a.addPrimaryKey(t,h),a.addMetadata(t,f),a.end(t)}}class b{constructor(){this.bb=null,this.bb_pos=0}__init(t,e){return this.bb_pos=t,this.bb=e,this}static getRoot(t,e){return(e||new b).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRoot(t,e){return t.setPosition(t.position()+o.SIZE_PREFIX_LENGTH),(e||new b).__init(t.readInt32(t.position())+t.position(),t)}org(t){var e=this.bb.__offset(this.bb_pos,4);return e?this.bb.__string(this.bb_pos+e,t):null}code(){var t=this.bb.__offset(this.bb_pos,6);return t?this.bb.readInt32(this.bb_pos+t):0}name(t){var e=this.bb.__offset(this.bb_pos,8);return e?this.bb.__string(this.bb_pos+e,t):null}description(t){var e=this.bb.__offset(this.bb_pos,10);return e?this.bb.__string(this.bb_pos+e,t):null}wkt(t){var e=this.bb.__offset(this.bb_pos,12);return e?this.bb.__string(this.bb_pos+e,t):null}codeString(t){var e=this.bb.__offset(this.bb_pos,14);return e?this.bb.__string(this.bb_pos+e,t):null}static start(t){t.startObject(6)}static addOrg(t,e){t.addFieldOffset(0,e,0)}static addCode(t,e){t.addFieldInt32(1,e,0)}static addName(t,e){t.addFieldOffset(2,e,0)}static addDescription(t,e){t.addFieldOffset(3,e,0)}static addWkt(t,e){t.addFieldOffset(4,e,0)}static addCodeString(t,e){t.addFieldOffset(5,e,0)}static end(t){return t.endObject()}static create(t,e,r,i,s,n,o){return b.start(t),b.addOrg(t,e),b.addCode(t,r),b.addName(t,i),b.addDescription(t,s),b.addWkt(t,n),b.addCodeString(t,o),b.end(t)}}class d{constructor(){this.bb=null,this.bb_pos=0}__init(t,e){return this.bb_pos=t,this.bb=e,this}static getRoot(t,e){return(e||new d).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRoot(t,e){return t.setPosition(t.position()+o.SIZE_PREFIX_LENGTH),(e||new d).__init(t.readInt32(t.position())+t.position(),t)}name(t){var e=this.bb.__offset(this.bb_pos,4);return e?this.bb.__string(this.bb_pos+e,t):null}envelope(t){var e=this.bb.__offset(this.bb_pos,6);return e?this.bb.readFloat64(this.bb.__vector(this.bb_pos+e)+8*t):0}envelopeLength(){var t=this.bb.__offset(this.bb_pos,6);return t?this.bb.__vector_len(this.bb_pos+t):0}envelopeArray(){var t=this.bb.__offset(this.bb_pos,6);return t?new Float64Array(this.bb.bytes().buffer,this.bb.bytes().byteOffset+this.bb.__vector(this.bb_pos+t),this.bb.__vector_len(this.bb_pos+t)):null}geometryType(){var t=this.bb.__offset(this.bb_pos,8);return t?this.bb.readUint8(this.bb_pos+t):r.Unknown}hasZ(){var t=this.bb.__offset(this.bb_pos,10);return!!t&&!!this.bb.readInt8(this.bb_pos+t)}hasM(){var t=this.bb.__offset(this.bb_pos,12);return!!t&&!!this.bb.readInt8(this.bb_pos+t)}hasT(){var t=this.bb.__offset(this.bb_pos,14);return!!t&&!!this.bb.readInt8(this.bb_pos+t)}hasTM(){var t=this.bb.__offset(this.bb_pos,16);return!!t&&!!this.bb.readInt8(this.bb_pos+t)}columns(t,e){var r=this.bb.__offset(this.bb_pos,18);return r?(e||new a).__init(this.bb.__indirect(this.bb.__vector(this.bb_pos+r)+4*t),this.bb):null}columnsLength(){var t=this.bb.__offset(this.bb_pos,18);return t?this.bb.__vector_len(this.bb_pos+t):0}featuresCount(){var t=this.bb.__offset(this.bb_pos,20);return t?this.bb.readUint64(this.bb_pos+t):this.bb.createLong(0,0)}indexNodeSize(){var t=this.bb.__offset(this.bb_pos,22);return t?this.bb.readUint16(this.bb_pos+t):16}crs(t){var e=this.bb.__offset(this.bb_pos,24);return e?(t||new b).__init(this.bb.__indirect(this.bb_pos+e),this.bb):null}title(t){var e=this.bb.__offset(this.bb_pos,26);return e?this.bb.__string(this.bb_pos+e,t):null}description(t){var e=this.bb.__offset(this.bb_pos,28);return e?this.bb.__string(this.bb_pos+e,t):null}metadata(t){var e=this.bb.__offset(this.bb_pos,30);return e?this.bb.__string(this.bb_pos+e,t):null}static start(t){t.startObject(14)}static addName(t,e){t.addFieldOffset(0,e,0)}static addEnvelope(t,e){t.addFieldOffset(1,e,0)}static createEnvelopeVector(t,e){t.startVector(8,e.length,8);for(var r=e.length-1;r>=0;r--)t.addFloat64(e[r]);return t.endVector()}static startEnvelopeVector(t,e){t.startVector(8,e,8)}static addGeometryType(t,e){t.addFieldInt8(2,e,r.Unknown)}static addHasZ(t,e){t.addFieldInt8(3,+e,0)}static addHasM(t,e){t.addFieldInt8(4,+e,0)}static addHasT(t,e){t.addFieldInt8(5,+e,0)}static addHasTM(t,e){t.addFieldInt8(6,+e,0)}static addColumns(t,e){t.addFieldOffset(7,e,0)}static createColumnsVector(t,e){t.startVector(4,e.length,4);for(var r=e.length-1;r>=0;r--)t.addOffset(e[r]);return t.endVector()}static startColumnsVector(t,e){t.startVector(4,e,4)}static addFeaturesCount(t,e){t.addFieldInt64(8,e,t.createLong(0,0))}static addIndexNodeSize(t,e){t.addFieldInt16(9,e,16)}static addCrs(t,e){t.addFieldOffset(10,e,0)}static addTitle(t,e){t.addFieldOffset(11,e,0)}static addDescription(t,e){t.addFieldOffset(12,e,0)}static addMetadata(t,e){t.addFieldOffset(13,e,0)}static end(t){return t.endObject()}static finishBuffer(t,e){t.finish(e)}static finishSizePrefixedBuffer(t,e){t.finish(e,void 0,!0)}static create(t,e,r,i,s,n,o,a,b,u,h,f,c,l,_){return d.start(t),d.addName(t,e),d.addEnvelope(t,r),d.addGeometryType(t,i),d.addHasZ(t,s),d.addHasM(t,n),d.addHasT(t,o),d.addHasTM(t,a),d.addColumns(t,b),d.addFeaturesCount(t,u),d.addIndexNodeSize(t,h),d.addCrs(t,f),d.addTitle(t,c),d.addDescription(t,l),d.addMetadata(t,_),d.end(t)}}class u{constructor(t,e,r,i,s,n){this.org=t,this.code=e,this.name=r,this.description=i,this.wkt=s,this.code_string=n}}class h{constructor(t,e,r,i,s,n,o,a){this.geometryType=t,this.columns=e,this.featuresCount=r,this.indexNodeSize=i,this.crs=s,this.title=n,this.description=o,this.metadata=a}static fromByteBuffer(t){const r=d.getRoot(t),i=r.featuresCount().toFloat64(),s=r.indexNodeSize(),n=[];for(let t=0;t<r.columnsLength();t++){const i=r.columns(t);if(!i)throw new Error("Column unexpectedly missing");if(!i.name())throw new Error("Column name unexpectedly missing");n.push(new e(i.name(),i.type(),i.title(),i.description(),i.width(),i.precision(),i.scale(),i.nullable(),i.unique(),i.primaryKey()))}const o=r.crs(),a=o?new u(o.org(),o.code(),o.name(),o.description(),o.wkt(),o.codeString()):null;return new h(r.geometryType(),n,i,s,a,r.title(),r.description(),r.metadata())}}!function(t){t[t.Unknown=0]="Unknown",t[t.Point=1]="Point",t[t.LineString=2]="LineString",t[t.Polygon=3]="Polygon",t[t.MultiPoint=4]="MultiPoint",t[t.MultiLineString=5]="MultiLineString",t[t.MultiPolygon=6]="MultiPolygon",t[t.GeometryCollection=7]="GeometryCollection",t[t.CircularString=8]="CircularString",t[t.CompoundCurve=9]="CompoundCurve",t[t.CurvePolygon=10]="CurvePolygon",t[t.MultiCurve=11]="MultiCurve",t[t.MultiSurface=12]="MultiSurface",t[t.Curve=13]="Curve",t[t.Surface=14]="Surface",t[t.PolyhedralSurface=15]="PolyhedralSurface",t[t.TIN=16]="TIN",t[t.Triangle=17]="Triangle"}(s||(s={})),function(t){t[t.Byte=0]="Byte",t[t.UByte=1]="UByte",t[t.Bool=2]="Bool",t[t.Short=3]="Short",t[t.UShort=4]="UShort",t[t.Int=5]="Int",t[t.UInt=6]="UInt",t[t.Long=7]="Long",t[t.ULong=8]="ULong",t[t.Float=9]="Float",t[t.Double=10]="Double",t[t.String=11]="String",t[t.Json=12]="Json",t[t.DateTime=13]="DateTime",t[t.Binary=14]="Binary"}(n||(n={}));class f{constructor(){this.bb=null,this.bb_pos=0}__init(t,e){return this.bb_pos=t,this.bb=e,this}static getRoot(t,e){return(e||new f).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRoot(t,e){return t.setPosition(t.position()+o.SIZE_PREFIX_LENGTH),(e||new f).__init(t.readInt32(t.position())+t.position(),t)}name(t){var e=this.bb.__offset(this.bb_pos,4);return e?this.bb.__string(this.bb_pos+e,t):null}type(){var t=this.bb.__offset(this.bb_pos,6);return t?this.bb.readUint8(this.bb_pos+t):n.Byte}title(t){var e=this.bb.__offset(this.bb_pos,8);return e?this.bb.__string(this.bb_pos+e,t):null}description(t){var e=this.bb.__offset(this.bb_pos,10);return e?this.bb.__string(this.bb_pos+e,t):null}width(){var t=this.bb.__offset(this.bb_pos,12);return t?this.bb.readInt32(this.bb_pos+t):-1}precision(){var t=this.bb.__offset(this.bb_pos,14);return t?this.bb.readInt32(this.bb_pos+t):-1}scale(){var t=this.bb.__offset(this.bb_pos,16);return t?this.bb.readInt32(this.bb_pos+t):-1}nullable(){var t=this.bb.__offset(this.bb_pos,18);return!t||!!this.bb.readInt8(this.bb_pos+t)}unique(){var t=this.bb.__offset(this.bb_pos,20);return!!t&&!!this.bb.readInt8(this.bb_pos+t)}primaryKey(){var t=this.bb.__offset(this.bb_pos,22);return!!t&&!!this.bb.readInt8(this.bb_pos+t)}metadata(t){var e=this.bb.__offset(this.bb_pos,24);return e?this.bb.__string(this.bb_pos+e,t):null}static start(t){t.startObject(11)}static addName(t,e){t.addFieldOffset(0,e,0)}static addType(t,e){t.addFieldInt8(1,e,n.Byte)}static addTitle(t,e){t.addFieldOffset(2,e,0)}static addDescription(t,e){t.addFieldOffset(3,e,0)}static addWidth(t,e){t.addFieldInt32(4,e,-1)}static addPrecision(t,e){t.addFieldInt32(5,e,-1)}static addScale(t,e){t.addFieldInt32(6,e,-1)}static addNullable(t,e){t.addFieldInt8(7,+e,1)}static addUnique(t,e){t.addFieldInt8(8,+e,0)}static addPrimaryKey(t,e){t.addFieldInt8(9,+e,0)}static addMetadata(t,e){t.addFieldOffset(10,e,0)}static end(t){var e=t.endObject();return t.requiredField(e,4),e}static create(t,e,r,i,s,n,o,a,b,d,u,h){return f.start(t),f.addName(t,e),f.addType(t,r),f.addTitle(t,i),f.addDescription(t,s),f.addWidth(t,n),f.addPrecision(t,o),f.addScale(t,a),f.addNullable(t,b),f.addUnique(t,d),f.addPrimaryKey(t,u),f.addMetadata(t,h),f.end(t)}}class c{constructor(){this.bb=null,this.bb_pos=0}__init(t,e){return this.bb_pos=t,this.bb=e,this}static getRoot(t,e){return(e||new c).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRoot(t,e){return t.setPosition(t.position()+o.SIZE_PREFIX_LENGTH),(e||new c).__init(t.readInt32(t.position())+t.position(),t)}ends(t){var e=this.bb.__offset(this.bb_pos,4);return e?this.bb.readUint32(this.bb.__vector(this.bb_pos+e)+4*t):0}endsLength(){var t=this.bb.__offset(this.bb_pos,4);return t?this.bb.__vector_len(this.bb_pos+t):0}endsArray(){var t=this.bb.__offset(this.bb_pos,4);return t?new Uint32Array(this.bb.bytes().buffer,this.bb.bytes().byteOffset+this.bb.__vector(this.bb_pos+t),this.bb.__vector_len(this.bb_pos+t)):null}xy(t){var e=this.bb.__offset(this.bb_pos,6);return e?this.bb.readFloat64(this.bb.__vector(this.bb_pos+e)+8*t):0}xyLength(){var t=this.bb.__offset(this.bb_pos,6);return t?this.bb.__vector_len(this.bb_pos+t):0}xyArray(){var t=this.bb.__offset(this.bb_pos,6);return t?new Float64Array(this.bb.bytes().buffer,this.bb.bytes().byteOffset+this.bb.__vector(this.bb_pos+t),this.bb.__vector_len(this.bb_pos+t)):null}z(t){var e=this.bb.__offset(this.bb_pos,8);return e?this.bb.readFloat64(this.bb.__vector(this.bb_pos+e)+8*t):0}zLength(){var t=this.bb.__offset(this.bb_pos,8);return t?this.bb.__vector_len(this.bb_pos+t):0}zArray(){var t=this.bb.__offset(this.bb_pos,8);return t?new Float64Array(this.bb.bytes().buffer,this.bb.bytes().byteOffset+this.bb.__vector(this.bb_pos+t),this.bb.__vector_len(this.bb_pos+t)):null}m(t){var e=this.bb.__offset(this.bb_pos,10);return e?this.bb.readFloat64(this.bb.__vector(this.bb_pos+e)+8*t):0}mLength(){var t=this.bb.__offset(this.bb_pos,10);return t?this.bb.__vector_len(this.bb_pos+t):0}mArray(){var t=this.bb.__offset(this.bb_pos,10);return t?new Float64Array(this.bb.bytes().buffer,this.bb.bytes().byteOffset+this.bb.__vector(this.bb_pos+t),this.bb.__vector_len(this.bb_pos+t)):null}t(t){var e=this.bb.__offset(this.bb_pos,12);return e?this.bb.readFloat64(this.bb.__vector(this.bb_pos+e)+8*t):0}tLength(){var t=this.bb.__offset(this.bb_pos,12);return t?this.bb.__vector_len(this.bb_pos+t):0}tArray(){var t=this.bb.__offset(this.bb_pos,12);return t?new Float64Array(this.bb.bytes().buffer,this.bb.bytes().byteOffset+this.bb.__vector(this.bb_pos+t),this.bb.__vector_len(this.bb_pos+t)):null}tm(t){var e=this.bb.__offset(this.bb_pos,14);return e?this.bb.readUint64(this.bb.__vector(this.bb_pos+e)+8*t):this.bb.createLong(0,0)}tmLength(){var t=this.bb.__offset(this.bb_pos,14);return t?this.bb.__vector_len(this.bb_pos+t):0}type(){var t=this.bb.__offset(this.bb_pos,16);return t?this.bb.readUint8(this.bb_pos+t):s.Unknown}parts(t,e){var r=this.bb.__offset(this.bb_pos,18);return r?(e||new c).__init(this.bb.__indirect(this.bb.__vector(this.bb_pos+r)+4*t),this.bb):null}partsLength(){var t=this.bb.__offset(this.bb_pos,18);return t?this.bb.__vector_len(this.bb_pos+t):0}static start(t){t.startObject(8)}static addEnds(t,e){t.addFieldOffset(0,e,0)}static createEndsVector(t,e){t.startVector(4,e.length,4);for(var r=e.length-1;r>=0;r--)t.addInt32(e[r]);return t.endVector()}static startEndsVector(t,e){t.startVector(4,e,4)}static addXy(t,e){t.addFieldOffset(1,e,0)}static createXyVector(t,e){t.startVector(8,e.length,8);for(var r=e.length-1;r>=0;r--)t.addFloat64(e[r]);return t.endVector()}static startXyVector(t,e){t.startVector(8,e,8)}static addZ(t,e){t.addFieldOffset(2,e,0)}static createZVector(t,e){t.startVector(8,e.length,8);for(var r=e.length-1;r>=0;r--)t.addFloat64(e[r]);return t.endVector()}static startZVector(t,e){t.startVector(8,e,8)}static addM(t,e){t.addFieldOffset(3,e,0)}static createMVector(t,e){t.startVector(8,e.length,8);for(var r=e.length-1;r>=0;r--)t.addFloat64(e[r]);return t.endVector()}static startMVector(t,e){t.startVector(8,e,8)}static addT(t,e){t.addFieldOffset(4,e,0)}static createTVector(t,e){t.startVector(8,e.length,8);for(var r=e.length-1;r>=0;r--)t.addFloat64(e[r]);return t.endVector()}static startTVector(t,e){t.startVector(8,e,8)}static addTm(t,e){t.addFieldOffset(5,e,0)}static createTmVector(t,e){t.startVector(8,e.length,8);for(var r=e.length-1;r>=0;r--)t.addInt64(e[r]);return t.endVector()}static startTmVector(t,e){t.startVector(8,e,8)}static addType(t,e){t.addFieldInt8(6,e,s.Unknown)}static addParts(t,e){t.addFieldOffset(7,e,0)}static createPartsVector(t,e){t.startVector(4,e.length,4);for(var r=e.length-1;r>=0;r--)t.addOffset(e[r]);return t.endVector()}static startPartsVector(t,e){t.startVector(4,e,4)}static end(t){return t.endObject()}static create(t,e,r,i,s,n,o,a,b){return c.start(t),c.addEnds(t,e),c.addXy(t,r),c.addZ(t,i),c.addM(t,s),c.addT(t,n),c.addTm(t,o),c.addType(t,a),c.addParts(t,b),c.end(t)}}class l{constructor(){this.bb=null,this.bb_pos=0}__init(t,e){return this.bb_pos=t,this.bb=e,this}static getRoot(t,e){return(e||new l).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRoot(t,e){return t.setPosition(t.position()+o.SIZE_PREFIX_LENGTH),(e||new l).__init(t.readInt32(t.position())+t.position(),t)}geometry(t){var e=this.bb.__offset(this.bb_pos,4);return e?(t||new c).__init(this.bb.__indirect(this.bb_pos+e),this.bb):null}properties(t){var e=this.bb.__offset(this.bb_pos,6);return e?this.bb.readUint8(this.bb.__vector(this.bb_pos+e)+t):0}propertiesLength(){var t=this.bb.__offset(this.bb_pos,6);return t?this.bb.__vector_len(this.bb_pos+t):0}propertiesArray(){var t=this.bb.__offset(this.bb_pos,6);return t?new Uint8Array(this.bb.bytes().buffer,this.bb.bytes().byteOffset+this.bb.__vector(this.bb_pos+t),this.bb.__vector_len(this.bb_pos+t)):null}columns(t,e){var r=this.bb.__offset(this.bb_pos,8);return r?(e||new f).__init(this.bb.__indirect(this.bb.__vector(this.bb_pos+r)+4*t),this.bb):null}columnsLength(){var t=this.bb.__offset(this.bb_pos,8);return t?this.bb.__vector_len(this.bb_pos+t):0}static start(t){t.startObject(3)}static addGeometry(t,e){t.addFieldOffset(0,e,0)}static addProperties(t,e){t.addFieldOffset(1,e,0)}static createPropertiesVector(t,e){t.startVector(1,e.length,1);for(var r=e.length-1;r>=0;r--)t.addInt8(e[r]);return t.endVector()}static startPropertiesVector(t,e){t.startVector(1,e,1)}static addColumns(t,e){t.addFieldOffset(2,e,0)}static createColumnsVector(t,e){t.startVector(4,e.length,4);for(var r=e.length-1;r>=0;r--)t.addOffset(e[r]);return t.endVector()}static startColumnsVector(t,e){t.startVector(4,e,4)}static end(t){return t.endObject()}static finishBuffer(t,e){t.finish(e)}static finishSizePrefixedBuffer(t,e){t.finish(e,void 0,!0)}static create(t,e,r,i){return l.start(t),l.addGeometry(t,e),l.addProperties(t,r),l.addColumns(t,i),l.end(t)}}function _(t,e){const{xy:r,z:i,ends:s,parts:n,type:o}=e;if(n){const e=n.map(e=>_(t,e)),r=c.createPartsVector(t,e);return c.start(t),c.addParts(t,r),c.end(t)}const a=c.createXyVector(t,r);let b,d;return i&&(b=c.createZVector(t,i)),s&&(d=c.createEndsVector(t,s)),c.start(t),d&&c.addEnds(t,d),c.addXy(t,a),b&&c.addZ(t,b),c.addType(t,o),c.end(t)}function p(t,e,r){if(0!==t.length)if(Array.isArray(t[0]))for(const i of t)p(i,e,r);else 2===t.length?e.push(...t):(e.push(t[0],t[1]),r.push(t[2]))}function y(t,e){const r=[];for(let i=0;i<t.length;i+=2){const s=[t[i],t[i+1]];e&&s.push(e[i>>1]),r.push(s)}return r}function g(t){return t?r[t]:r.Unknown}function v(t){const e=t.coordinates,r=[],i=[];let s,n;const o=g(t.type);let a=0;switch(t.type){case"Point":p(e,r,i);break;case"MultiPoint":case"LineString":p(e,r,i);break;case"MultiLineString":case"Polygon":{const t=e;p(t,r,i),t.length>1&&(s=t.map(t=>a+=t.length));break}case"MultiPolygon":n=e.map(t=>({type:"Polygon",coordinates:t})).map(v);break;case"GeometryCollection":t.geometries&&(n=t.geometries.map(v))}return{xy:r,z:i.length>0?i:void 0,ends:s,type:o,parts:n}}function w(t,e){if(e===r.GeometryCollection){const i=[];for(let e=0;e<t.partsLength();e++){const r=t.parts(e),s=r.type();i.push(w(r,s))}return{type:r[e],geometries:i}}if(e===r.MultiPolygon){const i=[];for(let e=0;e<t.partsLength();e++)i.push(w(t.parts(e),r.Polygon));return{type:r[e],coordinates:i.map(t=>t.coordinates)}}const i=function(t,e){const i=t.xyArray(),s=t.zArray();switch(e){case r.Point:{const t=Array.from(i);return s&&t.push(s[0]),t}case r.MultiPoint:case r.LineString:return y(i,s);case r.MultiLineString:case r.Polygon:return function(t,e,r){if(!r||0===r.length)return[y(t,e)];let i=0;const s=Array.from(r).map(e=>t.slice(i,i=e<<1));let n;return e&&(i=0,n=Array.from(r).map(t=>e.slice(i,i=t))),s.map((t,e)=>y(t,n?n[e]:void 0))}(i,s,t.endsArray())}}(t,e);return{type:r[e],coordinates:i}}const I=new TextEncoder,B=new TextDecoder;function m(t,e,r){const s=r.columns,n=new o.Builder;let a=0,b=1024,d=new Uint8Array(b),u=new DataView(d.buffer);const h=function(t){if(a+t<b)return;b*=2;const e=new Uint8Array(b);e.set(d),d=e,u=new DataView(d.buffer,a)};if(s)for(let t=0;t<s.length;t++){const r=s[t],n=e[r.name];if(null!==n)switch(u.setUint16(a,t,!0),a+=2,r.type){case i.Bool:h(1),u.setUint8(a,n),a+=1;break;case i.Short:h(2),u.setInt16(a,n,!0),a+=2;break;case i.UShort:h(2),u.setUint16(a,n,!0),a+=2;break;case i.Int:h(4),u.setInt32(a,n,!0),a+=4;break;case i.UInt:h(4),u.setUint32(a,n,!0),a+=4;break;case i.Long:h(8),u.setBigInt64(a,BigInt(n),!0),a+=8;break;case i.Double:h(8),u.setFloat64(a,n,!0),a+=8;break;case i.DateTime:case i.String:{const t=I.encode(n);h(4),u.setUint32(a,t.length,!0),a+=4,h(t.length),d.set(t,a),a+=t.length;break}default:throw new Error("Unknown type "+r.type)}}let f=null;a>0&&(f=l.createPropertiesVector(n,d.slice(0,a)));const c=_(n,t);l.start(n),l.addGeometry(n,c),f&&l.addProperties(n,f);const p=l.end(n);return n.finishSizePrefixed(p),n.asUint8Array()}function F(t,e){const r=e.columns,s={type:"Feature",geometry:w(t.geometry(),e.geometryType)};return r&&r.length>0&&(s.properties=function(t,e){const r={};if(!e||0===e.length)return r;const s=t.propertiesArray();if(!s)return r;const n=new DataView(s.buffer,s.byteOffset),o=t.propertiesLength();let a=0;for(;a<o;){const t=n.getUint16(a,!0);a+=2;const o=e[t],b=o.name;switch(o.type){case i.Bool:r[b]=!!n.getUint8(a),a+=1;break;case i.Byte:r[b]=n.getInt8(a),a+=1;break;case i.UByte:r[b]=n.getUint8(a),a+=1;break;case i.Short:r[b]=n.getInt16(a,!0),a+=2;break;case i.UShort:r[b]=n.getUint16(a,!0),a+=2;break;case i.Int:r[b]=n.getInt32(a,!0),a+=4;break;case i.UInt:r[b]=n.getUint32(a,!0),a+=4;break;case i.Long:r[b]=Number(n.getBigInt64(a,!0)),a+=8;break;case i.ULong:r[b]=Number(n.getBigUint64(a,!0)),a+=8;break;case i.Double:r[b]=n.getFloat64(a,!0),a+=8;break;case i.DateTime:case i.String:{const t=n.getUint32(a,!0);a+=4,r[b]=B.decode(s.subarray(a,a+t)),a+=t;break}default:throw new Error("Unknown type "+o.type)}}return r}(t,r)),s}var E,S=new Uint8Array(0);function O(t,e){if(!t.length)return e;if(!e.length)return t;var r=new Uint8Array(t.length+e.length);return r.set(t),r.set(e,t.length),r}function U(t){this._source=t,this._array=S,this._index=0}U.prototype.read=function(){var t=this,e=t._array.subarray(t._index);return t._source.read().then((function(r){return t._array=S,t._index=0,r.done?e.length>0?{done:!1,value:e}:{done:!0,value:void 0}:{done:!1,value:O(e,r.value)}}))},U.prototype.slice=function(t){if((t|=0)<0)throw new Error("invalid length");var e=this,r=this._array.length-this._index;if(this._index+t<=this._array.length)return Promise.resolve(this._array.subarray(this._index,this._index+=t));var i=new Uint8Array(t);return i.set(this._array.subarray(this._index)),function s(){return e._source.read().then((function(n){return n.done?(e._array=S,e._index=0,r>0?i.subarray(0,r):null):r+n.value.length>=t?(e._array=n.value,e._index=t-r,i.set(n.value.subarray(0,t-r),r),i):(i.set(n.value,r),r+=n.value.length,s())}))}()},U.prototype.cancel=function(){return this._source.cancel()},function(t){t[t.Debug=0]="Debug",t[t.Info=1]="Info",t[t.Warn=2]="Warn",t[t.Error=3]="Error"}(E||(E={}));class P{static debug(...t){this.log(E.Debug,...t)}static info(...t){this.log(E.Info,...t)}static warn(...t){this.log(E.Warn,...t)}static error(...t){this.log(E.Error,...t)}static log(t,...e){if(!(this.logLevel>t))switch(t){case E.Debug:console.debug(...e);break;case E.Info:console.info(...e);break;case E.Warn:console.warn(...e);break;case E.Error:console.error(...e)}}}function L(t,e){e=Math.min(Math.max(+e,2),65535);let r=t,i=r;do{r=Math.ceil(r/e),i+=r}while(1!==r);return 40*i}function T(t,e){if(0!=(4293918720&t))throw Error("integer is too large to be safely represented");return e+t*2**32}P.logLevel=E.Info;const N=new Uint8Array([102,103,98,3,102,103,98,0]);class C{constructor(t,e,r,i){this.headerClient=t,this.header=e,this.headerLength=r,this.indexLength=i}static async open(t){let e=new V(t);const r=(()=>{let t,e=0;for(t=0;t<3;t++)e+=16**t*40;return e})(),i=2024+r;P.debug(`fetching header. minReqLength: ${i} (assumedHeaderLength: 2024, assumedIndexLength: ${r})`);{let t=new Uint8Array(await e.getRange(0,8,i,"header"));if(!t.every((t,e)=>N[e]===t))throw P.error(`bytes: ${t} != ${N}`),new Error("Not a FlatGeobuf file");P.debug("magic bytes look good")}let s;{let t=await e.getRange(8,4,i,"header");if(s=new DataView(t).getUint32(0,!0),s>10485760||s<8)throw new Error("Invalid header size");P.debug("headerLength: "+s)}const n=await e.getRange(12,s,i,"header"),a=new o.ByteBuffer(new Uint8Array(n)),b=h.fromByteBuffer(a),d=L(b.featuresCount,b.indexNodeSize);return P.debug("completed: opening http reader"),new C(e,b,s,d)}async*selectBbox(t){const e=this.lengthBeforeTree();let r=this.headerClient;P.debug("starting: selectBbox, traversing index. lengthBeforeTree: "+e),yield*async function*(t,e,r,i){class s{constructor(t,e){this._level=e,this.nodes=t}level(){return this._level}startNode(){return this.nodes[0]}endNode(){return this.nodes[1]}extendEndNodeToNewOffset(t){console.assert(t>this.nodes[1]),this.nodes[1]=t}toString(){return`[NodeRange level: ${this._level}, nodes: ${this.nodes[0]}-${this.nodes[1]}]`}}const{minX:n,minY:o,maxX:a,maxY:b}=r,d=function(t,e){if(e<2)throw new Error("Node size must be at least 2");if(0===t)throw new Error("Number of items must be greater than 0");let r=t,i=r;const s=[r];do{r=Math.ceil(r/e),i+=r,s.push(r)}while(1!==r);const n=[];r=i;for(const t of s)n.push(r-t),r-=t;n.reverse(),s.reverse();const o=[];for(let t=0;t<s.length;t++)o.push([n[t],n[t]+s[t]]);return o.reverse(),o}(t,e),u=d[0][0],h=[(()=>{const t=d.length-1;return new s([0,1],t)})()];for(P.debug(`starting stream search with queue: ${h}, numItems: ${t}, nodeSize: ${e}, levelBounds: ${d}`);0!=h.length;){const t=h.shift();P.debug(`popped node: ${t}, queueLength: ${h.length}`);let r=t.startNode();const f=r>=u,[,c]=d[t.level()],l=Math.min(t.endNode()+e,c),_=l-r,p=await i(40*r,40*_),y=new Float64Array(p),g=new Uint32Array(p);for(let e=r;e<l;e++){const i=5*(e-r);if(a<y[i+0])continue;if(b<y[i+1])continue;if(n>y[i+2])continue;if(o>y[i+3])continue;const d=g[8+(i<<1)],c=T(g[9+(i<<1)],d);if(f){P.debug("yielding feature"),yield[c,e-u];continue}const l=6553.6,_=h[h.length-1];if(void 0!==_&&_.level()==t.level()-1&&c<_.endNode()+l){P.debug(`Extending existing node: ${_}, newOffset: ${_.endNode()} -> ${c}`),_.extendEndNodeToNewOffset(c);continue}let p=(()=>{let e=t.level()-1;return new s([c,c+1],e)})();void 0!==_&&_.level()==t.level()-1?P.debug(`pushing new node at offset: ${c} rather than merging with distant ${_}`):P.debug(`pushing new level for ${p} onto queue with tail: ${_}`),h.push(p)}}}(this.header.featuresCount,this.header.indexNodeSize,t,(async function(t,i){return r.getRange(e+t,i,0,"index")}))}lengthBeforeTree(){return N.length+4+this.headerLength}lengthBeforeFeatures(){return this.lengthBeforeTree()+this.indexLength}featureClient(){return void 0===this._featureClient&&(this._featureClient=this.headerClient.clone()),this._featureClient}async readFeature(t){const e=131072;let r,i=t+this.lengthBeforeFeatures();{const t=await this.featureClient().getRange(i,4,e,"feature length");r=new DataView(t).getUint32(0,!0)}P.debug(`featureOffset: ${i}, featureLength: ${r}`);let s=await this.featureClient().getRange(i+4,r,e,"feature data"),n=new Uint8Array(s);const a=new Uint8Array(r+4);a.set(n,4);const b=new o.ByteBuffer(a);return b.setPosition(4),l.getRoot(b)}}class V{constructor(t){this.buffer=new ArrayBuffer(0),this.head=0,this.httpClient="string"==typeof t?new x(t):t}clone(){let t=new V(this.httpClient);return t.buffer=this.buffer.slice(0),t.head=this.head,t}async getRange(t,e,r,i){P.debug(`need Range: ${t}-${t+e-1}`);const s=t-this.head,n=s+e;if(s>=0&&n<this.buffer.byteLength)return P.debug(`slicing existing Range: ${s}-${n-1}`),this.buffer.slice(s,n);let o=Math.max(e,r);return this.buffer=await this.httpClient.getRange(t,o,i),this.head=t,this.buffer.slice(0,e)}}class x{constructor(t){this.requestsEverMade=0,this.bytesEverRequested=0,this.url=t}async getRange(t,e,r){this.requestsEverMade+=1,this.bytesEverRequested+=e;let i=`bytes=${t}-${t+e-1}`;return P.debug(`request: #${this.requestsEverMade}, purpose: ${r}), bytes: (this_request: ${e}, ever: ${this.bytesEverRequested}), Range: ${i}`),(await fetch(this.url,{headers:{Range:i}})).arrayBuffer()}}async function M(t,e,r){let i=new Uint8Array(await t(4,"feature length"));if(0===i.byteLength)return;let s=new o.ByteBuffer(i);const n=s.readUint32(0);i=new Uint8Array(await t(n,"feature data"));const a=new Uint8Array(n+4);return a.set(i,4),s=new o.ByteBuffer(a),s.setPosition(4),r(l.getRoot(s),e)}function R(t){const e=new o.Builder;let r=null;t.columns&&(r=d.createColumnsVector(e,t.columns.map(t=>function(t,e){const r=t.createString(e.name);return a.start(t),a.addName(t,r),a.addType(t,e.type),a.end(t)}(e,t))));const i=e.createString("L1");d.start(e),d.addFeaturesCount(e,new o.Long(t.featuresCount,0)),d.addGeometryType(e,t.geometryType),d.addIndexNodeSize(e,0),r&&d.addColumns(e,r),d.addName(e,i);const s=d.end(e);return e.finishSizePrefixed(s),e.asUint8Array()}t.deserialize=function(t,e,r){return t instanceof Uint8Array?function(t,e){return{type:"FeatureCollection",features:function(t,e,r){if(!t.subarray(0,7).every((t,e)=>N[e]===t))throw new Error("Not a FlatGeobuf file");const i=new o.ByteBuffer(t),s=i.readUint32(N.length);i.setPosition(N.length+4);const n=h.fromByteBuffer(i);r&&r(n);let a=N.length+4+s;const{indexNodeSize:b,featuresCount:d}=n;b>0&&(a+=L(d,b));const u=[];for(;a<i.capacity();){const t=i.readUint32(a);i.setPosition(a+4);const r=l.getRoot(i);u.push(e(r,n)),a+=4+t}return u}(t,F,e)}}(t,r):t instanceof ReadableStream?function(t,e){return async function*(t,e,r){const i="function"==typeof(s=t).slice?s:new U("function"==typeof s.read?s:s.getReader());var s;const n=async t=>await i.slice(t);let a=new Uint8Array(await n(8));if(!a.every((t,e)=>N[e]===t))throw new Error("Not a FlatGeobuf file");a=new Uint8Array(await n(4));let b=new o.ByteBuffer(a);const d=b.readUint32(0);a=new Uint8Array(await n(d)),b=new o.ByteBuffer(a);const u=h.fromByteBuffer(b);r&&r(u);const{indexNodeSize:f,featuresCount:c}=u;if(f>0){const t=L(c,f);await n(t)}let l;for(;l=await M(n,u,e);)yield l}(t,F,e)}(t,r):function(t,e,r){return async function*(t,e,r,i){const s=await C.open(t);P.debug("opened reader"),i&&i(s.header);for await(let t of s.selectBbox(e)){let e=await s.readFeature(t[0]);yield r(e,s.header)}}(t,e,F,r)}(t,e,r)},t.serialize=function(t){return function(t){const r=function(t){const r=t.features[0],s=r.properties;let n=null;return s&&(n=Object.keys(s).map(t=>new e(t,function(t){if("boolean"==typeof t)return i.Bool;if("number"==typeof t)return t%1==0?i.Int:i.Double;if("string"==typeof t)return i.String;if(null===t)return i.String;throw new Error(`Unknown type (value '${t}')`)}(s[t]),null,null,-1,-1,-1,!0,!1,!1))),new h(g(r.geometry.type),n,t.features.length,0,null,null,null,null)}(t),s=R(r),n=t.features.map(t=>m(v(t.geometry),t.properties,r)),o=n.map(t=>t.length).reduce((t,e)=>t+e),a=new Uint8Array(N.length+s.length+o);a.set(s,N.length);let b=N.length+s.length;for(const t of n)a.set(t,b),b+=t.length;return a.set(N),a}(t)},Object.defineProperty(t,"__esModule",{value:!0})}(e)}]);
!function(t){var e={};function s(r){if(e[r])return e[r].exports;var i=e[r]={i:r,l:!1,exports:{}};return t[r].call(i.exports,i,i.exports,s),i.l=!0,i.exports}s.m=t,s.c=e,s.d=function(t,e,r){s.o(t,e)||Object.defineProperty(t,e,{enumerable:!0,get:r})},s.r=function(t){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})},s.t=function(t,e){if(1&e&&(t=s(t)),8&e)return t;if(4&e&&"object"==typeof t&&t&&t.__esModule)return t;var r=Object.create(null);if(s.r(r),Object.defineProperty(r,"default",{enumerable:!0,value:t}),2&e&&"string"!=typeof t)for(var i in t)s.d(r,i,function(e){return t[e]}.bind(null,i));return r},s.n=function(t){var e=t&&t.__esModule?function(){return t.default}:function(){return t};return s.d(e,"a",e),e},s.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},s.p="",s(s.s=0)}([function(t,e,s){"use strict";(function(e){var r=s(2),i="undefined"==typeof window?e:window;i.loaders=i.loaders||{},t.exports=Object.assign(i.loaders,r)}).call(this,s(1))},function(t,e){var s;s=function(){return this}();try{s=s||new Function("return this")()}catch(t){"object"==typeof window&&(s=window)}t.exports=s},function(t,e,s){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),Object.defineProperty(e,"FlatGeobufLoader",{enumerable:!0,get:function(){return r.FlatGeobufLoader}});var r=s(3)},function(t,e,s){"use strict";function r(t){return(r="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t})(t)}Object.defineProperty(e,"__esModule",{value:!0}),e.FlatGeobufLoader=e.FlatGeobufWorkerLoader=void 0;var i=function(t,e){if(!e&&t&&t.__esModule)return t;if(null===t||"object"!==r(t)&&"function"!=typeof t)return{default:t};var s=n(e);if(s&&s.has(t))return s.get(t);var i={},o=Object.defineProperty&&Object.getOwnPropertyDescriptor;for(var a in t)if("default"!==a&&Object.prototype.hasOwnProperty.call(t,a)){var b=o?Object.getOwnPropertyDescriptor(t,a):null;b&&(b.get||b.set)?Object.defineProperty(i,a,b):i[a]=t[a]}i.default=t,s&&s.set(t,i);return i}(s(4));function n(t){if("function"!=typeof WeakMap)return null;var e=new WeakMap,s=new WeakMap;return(n=function(t){return t?s:e})(t)}function o(t,e,s,r,i,n,o){try{var a=t[n](o),b=a.value}catch(t){return void s(t)}a.done?e(b):Promise.resolve(b).then(r,i)}function a(t,e){var s=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter((function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable}))),s.push.apply(s,r)}return s}function b(t){for(var e=1;e<arguments.length;e++){var s=null!=arguments[e]?arguments[e]:{};e%2?a(Object(s),!0).forEach((function(e){h(t,e,s[e])})):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(s)):a(Object(s)).forEach((function(e){Object.defineProperty(t,e,Object.getOwnPropertyDescriptor(s,e))}))}return t}function h(t,e,s){return e in t?Object.defineProperty(t,e,{value:s,enumerable:!0,configurable:!0,writable:!0}):t[e]=s,t}var c={id:"flatgeobuf",name:"FlatGeobuf",module:"flatgeobuf",version:"3.0.0-beta.1",worker:!0,extensions:["fgb"],category:"geometry",options:{flatgeobuf:{}}};e.FlatGeobufWorkerLoader=c;var d,u,l=b(b({},c),{},{parse:(d=regeneratorRuntime.mark((function t(e,s){return regeneratorRuntime.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.abrupt("return",(0,i.default)(e,s));case 1:case"end":return t.stop()}}),t)})),u=function(){var t=this,e=arguments;return new Promise((function(s,r){var i=d.apply(t,e);function n(t){o(i,s,r,n,a,"next",t)}function a(t){o(i,s,r,n,a,"throw",t)}n(void 0)}))},function(t,e){return u.apply(this,arguments)}),parseSync:i.default,parseInBatchesFromStream:i.parseFlatGeobufInBatches,binary:!0});e.FlatGeobufLoader=l},function(t,e,s){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.default=function(t,e){if(0===t.byteLength)return[];var s=new Uint8Array(t);return(0,r.deserialize)(s).features},e.parseFlatGeobufInBatches=function(t,e){return(0,r.deserializeStream)(t)};var r=s(5)},function(t,e,s){!function(t){"use strict";class e{constructor(t,e,s,r,i,n,o,a,b,h){this.name=t,this.type=e,this.title=s,this.description=r,this.width=i,this.precision=n,this.scale=o,this.nullable=a,this.unique=b,this.primary_key=h}}var s;!function(t){t[t.Byte=0]="Byte",t[t.UByte=1]="UByte",t[t.Bool=2]="Bool",t[t.Short=3]="Short",t[t.UShort=4]="UShort",t[t.Int=5]="Int",t[t.UInt=6]="UInt",t[t.Long=7]="Long",t[t.ULong=8]="ULong",t[t.Float=9]="Float",t[t.Double=10]="Double",t[t.String=11]="String",t[t.Json=12]="Json",t[t.DateTime=13]="DateTime",t[t.Binary=14]="Binary"}(s||(s={}));class r{constructor(t,e,s,r,i,n){this.org=t,this.code=e,this.name=s,this.description=r,this.wkt=i,this.code_string=n}}const i=new Int32Array(2),n=new Float32Array(i.buffer),o=new Float64Array(i.buffer),a=1===new Uint16Array(new Uint8Array([1,0]).buffer)[0];class b{constructor(t,e){this.low=0|t,this.high=0|e}static create(t,e){return 0==t&&0==e?b.ZERO:new b(t,e)}toFloat64(){return(this.low>>>0)+4294967296*this.high}equals(t){return this.low==t.low&&this.high==t.high}}var h,c;b.ZERO=new b(0,0),function(t){t[t.UTF8_BYTES=1]="UTF8_BYTES",t[t.UTF16_STRING=2]="UTF16_STRING"}(h||(h={}));class d{constructor(t){this.bytes_=t,this.position_=0}static allocate(t){return new d(new Uint8Array(t))}clear(){this.position_=0}bytes(){return this.bytes_}position(){return this.position_}setPosition(t){this.position_=t}capacity(){return this.bytes_.length}readInt8(t){return this.readUint8(t)<<24>>24}readUint8(t){return this.bytes_[t]}readInt16(t){return this.readUint16(t)<<16>>16}readUint16(t){return this.bytes_[t]|this.bytes_[t+1]<<8}readInt32(t){return this.bytes_[t]|this.bytes_[t+1]<<8|this.bytes_[t+2]<<16|this.bytes_[t+3]<<24}readUint32(t){return this.readInt32(t)>>>0}readInt64(t){return new b(this.readInt32(t),this.readInt32(t+4))}readUint64(t){return new b(this.readUint32(t),this.readUint32(t+4))}readFloat32(t){return i[0]=this.readInt32(t),n[0]}readFloat64(t){return i[a?0:1]=this.readInt32(t),i[a?1:0]=this.readInt32(t+4),o[0]}writeInt8(t,e){this.bytes_[t]=e}writeUint8(t,e){this.bytes_[t]=e}writeInt16(t,e){this.bytes_[t]=e,this.bytes_[t+1]=e>>8}writeUint16(t,e){this.bytes_[t]=e,this.bytes_[t+1]=e>>8}writeInt32(t,e){this.bytes_[t]=e,this.bytes_[t+1]=e>>8,this.bytes_[t+2]=e>>16,this.bytes_[t+3]=e>>24}writeUint32(t,e){this.bytes_[t]=e,this.bytes_[t+1]=e>>8,this.bytes_[t+2]=e>>16,this.bytes_[t+3]=e>>24}writeInt64(t,e){this.writeInt32(t,e.low),this.writeInt32(t+4,e.high)}writeUint64(t,e){this.writeUint32(t,e.low),this.writeUint32(t+4,e.high)}writeFloat32(t,e){n[0]=e,this.writeInt32(t,i[0])}writeFloat64(t,e){o[0]=e,this.writeInt32(t,i[a?0:1]),this.writeInt32(t+4,i[a?1:0])}getBufferIdentifier(){if(this.bytes_.length<this.position_+4+4)throw new Error("FlatBuffers: ByteBuffer is too short to contain an identifier.");let t="";for(let e=0;e<4;e++)t+=String.fromCharCode(this.readInt8(this.position_+4+e));return t}__offset(t,e){const s=t-this.readInt32(t);return e<this.readInt16(s)?this.readInt16(s+e):0}__union(t,e){return t.bb_pos=e+this.readInt32(e),t.bb=this,t}__string(t,e){t+=this.readInt32(t);const s=this.readInt32(t);let r="",i=0;if(t+=4,e===h.UTF8_BYTES)return this.bytes_.subarray(t,t+s);for(;i<s;){let e;const s=this.readUint8(t+i++);if(s<192)e=s;else{const r=this.readUint8(t+i++);if(s<224)e=(31&s)<<6|63&r;else{const n=this.readUint8(t+i++);e=s<240?(15&s)<<12|(63&r)<<6|63&n:(7&s)<<18|(63&r)<<12|(63&n)<<6|63&this.readUint8(t+i++)}}e<65536?r+=String.fromCharCode(e):(e-=65536,r+=String.fromCharCode(55296+(e>>10),56320+(1023&e)))}return r}__union_with_string(t,e){return"string"==typeof t?this.__string(e):this.__union(t,e)}__indirect(t){return t+this.readInt32(t)}__vector(t){return t+this.readInt32(t)+4}__vector_len(t){return this.readInt32(t+this.readInt32(t))}__has_identifier(t){if(4!=t.length)throw new Error("FlatBuffers: file identifier must be length 4");for(let e=0;e<4;e++)if(t.charCodeAt(e)!=this.readInt8(this.position()+4+e))return!1;return!0}createLong(t,e){return b.create(t,e)}createScalarList(t,e){const s=[];for(let r=0;r<e;++r)null!==t(r)&&s.push(t(r));return s}createObjList(t,e){const s=[];for(let r=0;r<e;++r){const e=t(r);null!==e&&s.push(e.unpack())}return s}}class u{constructor(t){let e;this.minalign=1,this.vtable=null,this.vtable_in_use=0,this.isNested=!1,this.object_start=0,this.vtables=[],this.vector_num_elems=0,this.force_defaults=!1,this.string_maps=null,e=t||1024,this.bb=d.allocate(e),this.space=e}clear(){this.bb.clear(),this.space=this.bb.capacity(),this.minalign=1,this.vtable=null,this.vtable_in_use=0,this.isNested=!1,this.object_start=0,this.vtables=[],this.vector_num_elems=0,this.force_defaults=!1,this.string_maps=null}forceDefaults(t){this.force_defaults=t}dataBuffer(){return this.bb}asUint8Array(){return this.bb.bytes().subarray(this.bb.position(),this.bb.position()+this.offset())}prep(t,e){t>this.minalign&&(this.minalign=t);const s=1+~(this.bb.capacity()-this.space+e)&t-1;for(;this.space<s+t+e;){const t=this.bb.capacity();this.bb=u.growByteBuffer(this.bb),this.space+=this.bb.capacity()-t}this.pad(s)}pad(t){for(let e=0;e<t;e++)this.bb.writeInt8(--this.space,0)}writeInt8(t){this.bb.writeInt8(this.space-=1,t)}writeInt16(t){this.bb.writeInt16(this.space-=2,t)}writeInt32(t){this.bb.writeInt32(this.space-=4,t)}writeInt64(t){this.bb.writeInt64(this.space-=8,t)}writeFloat32(t){this.bb.writeFloat32(this.space-=4,t)}writeFloat64(t){this.bb.writeFloat64(this.space-=8,t)}addInt8(t){this.prep(1,0),this.writeInt8(t)}addInt16(t){this.prep(2,0),this.writeInt16(t)}addInt32(t){this.prep(4,0),this.writeInt32(t)}addInt64(t){this.prep(8,0),this.writeInt64(t)}addFloat32(t){this.prep(4,0),this.writeFloat32(t)}addFloat64(t){this.prep(8,0),this.writeFloat64(t)}addFieldInt8(t,e,s){(this.force_defaults||e!=s)&&(this.addInt8(e),this.slot(t))}addFieldInt16(t,e,s){(this.force_defaults||e!=s)&&(this.addInt16(e),this.slot(t))}addFieldInt32(t,e,s){(this.force_defaults||e!=s)&&(this.addInt32(e),this.slot(t))}addFieldInt64(t,e,s){!this.force_defaults&&e.equals(s)||(this.addInt64(e),this.slot(t))}addFieldFloat32(t,e,s){(this.force_defaults||e!=s)&&(this.addFloat32(e),this.slot(t))}addFieldFloat64(t,e,s){(this.force_defaults||e!=s)&&(this.addFloat64(e),this.slot(t))}addFieldOffset(t,e,s){(this.force_defaults||e!=s)&&(this.addOffset(e),this.slot(t))}addFieldStruct(t,e,s){e!=s&&(this.nested(e),this.slot(t))}nested(t){if(t!=this.offset())throw new Error("FlatBuffers: struct must be serialized inline.")}notNested(){if(this.isNested)throw new Error("FlatBuffers: object serialization must not be nested.")}slot(t){null!==this.vtable&&(this.vtable[t]=this.offset())}offset(){return this.bb.capacity()-this.space}static growByteBuffer(t){const e=t.capacity();if(3221225472&e)throw new Error("FlatBuffers: cannot grow buffer beyond 2 gigabytes.");const s=e<<1,r=d.allocate(s);return r.setPosition(s-e),r.bytes().set(t.bytes(),s-e),r}addOffset(t){this.prep(4,0),this.writeInt32(this.offset()-t+4)}startObject(t){this.notNested(),null==this.vtable&&(this.vtable=[]),this.vtable_in_use=t;for(let e=0;e<t;e++)this.vtable[e]=0;this.isNested=!0,this.object_start=this.offset()}endObject(){if(null==this.vtable||!this.isNested)throw new Error("FlatBuffers: endObject called without startObject");this.addInt32(0);const t=this.offset();let e=this.vtable_in_use-1;for(;e>=0&&0==this.vtable[e];e--);const s=e+1;for(;e>=0;e--)this.addInt16(0!=this.vtable[e]?t-this.vtable[e]:0);this.addInt16(t-this.object_start);const r=2*(s+2);this.addInt16(r);let i=0;const n=this.space;t:for(e=0;e<this.vtables.length;e++){const t=this.bb.capacity()-this.vtables[e];if(r==this.bb.readInt16(t)){for(let e=2;e<r;e+=2)if(this.bb.readInt16(n+e)!=this.bb.readInt16(t+e))continue t;i=this.vtables[e];break}}return i?(this.space=this.bb.capacity()-t,this.bb.writeInt32(this.space,i-t)):(this.vtables.push(this.offset()),this.bb.writeInt32(this.bb.capacity()-t,this.offset()-t)),this.isNested=!1,t}finish(t,e,s){const r=s?4:0;if(e){const t=e;if(this.prep(this.minalign,8+r),4!=t.length)throw new Error("FlatBuffers: file identifier must be length 4");for(let e=3;e>=0;e--)this.writeInt8(t.charCodeAt(e))}this.prep(this.minalign,4+r),this.addOffset(t),r&&this.addInt32(this.bb.capacity()-this.space),this.bb.setPosition(this.space)}finishSizePrefixed(t,e){this.finish(t,e,!0)}requiredField(t,e){const s=this.bb.capacity()-t,r=s-this.bb.readInt32(s);if(0==this.bb.readInt16(r+e))throw new Error("FlatBuffers: field "+e+" must be set")}startVector(t,e,s){this.notNested(),this.vector_num_elems=e,this.prep(4,t*e),this.prep(s,t*e)}endVector(){return this.writeInt32(this.vector_num_elems),this.offset()}createSharedString(t){if(!t)return 0;if(this.string_maps||(this.string_maps=new Map),this.string_maps.has(t))return this.string_maps.get(t);const e=this.createString(t);return this.string_maps.set(t,e),e}createString(t){if(!t)return 0;let e;if(t instanceof Uint8Array)e=t;else{e=[];let s=0;for(;s<t.length;){let r;const i=t.charCodeAt(s++);r=i<55296||i>=56320?i:(i<<10)+t.charCodeAt(s++)+-56613888,r<128?e.push(r):(r<2048?e.push(r>>6&31|192):(r<65536?e.push(r>>12&15|224):e.push(r>>18&7|240,r>>12&63|128),e.push(r>>6&63|128)),e.push(63&r|128))}}this.addInt8(0),this.startVector(1,e.length,1),this.bb.setPosition(this.space-=e.length);for(let t=0,s=this.space,r=this.bb.bytes();t<e.length;t++)r[s++]=e[t];return this.endVector()}createLong(t,e){return b.create(t,e)}createObjectOffset(t){return null===t?0:"string"==typeof t?this.createString(t):t.pack(this)}createObjectOffsetList(t){const e=[];for(let s=0;s<t.length;++s){const r=t[s];if(null===r)throw new Error("FlatBuffers: Argument for createObjectOffsetList cannot contain null.");e.push(this.createObjectOffset(r))}return e}createStructOffsetList(t,e){return e(this,t.length),this.createObjectOffsetList(t),this.endVector()}}class l{constructor(){this.bb=null,this.bb_pos=0}__init(t,e){return this.bb_pos=t,this.bb=e,this}static getRootAsColumn(t,e){return(e||new l).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsColumn(t,e){return t.setPosition(t.position()+4),(e||new l).__init(t.readInt32(t.position())+t.position(),t)}name(t){const e=this.bb.__offset(this.bb_pos,4);return e?this.bb.__string(this.bb_pos+e,t):null}type(){const t=this.bb.__offset(this.bb_pos,6);return t?this.bb.readUint8(this.bb_pos+t):s.Byte}title(t){const e=this.bb.__offset(this.bb_pos,8);return e?this.bb.__string(this.bb_pos+e,t):null}description(t){const e=this.bb.__offset(this.bb_pos,10);return e?this.bb.__string(this.bb_pos+e,t):null}width(){const t=this.bb.__offset(this.bb_pos,12);return t?this.bb.readInt32(this.bb_pos+t):-1}precision(){const t=this.bb.__offset(this.bb_pos,14);return t?this.bb.readInt32(this.bb_pos+t):-1}scale(){const t=this.bb.__offset(this.bb_pos,16);return t?this.bb.readInt32(this.bb_pos+t):-1}nullable(){const t=this.bb.__offset(this.bb_pos,18);return!t||!!this.bb.readInt8(this.bb_pos+t)}unique(){const t=this.bb.__offset(this.bb_pos,20);return!!t&&!!this.bb.readInt8(this.bb_pos+t)}primaryKey(){const t=this.bb.__offset(this.bb_pos,22);return!!t&&!!this.bb.readInt8(this.bb_pos+t)}metadata(t){const e=this.bb.__offset(this.bb_pos,24);return e?this.bb.__string(this.bb_pos+e,t):null}static startColumn(t){t.startObject(11)}static addName(t,e){t.addFieldOffset(0,e,0)}static addType(t,e){t.addFieldInt8(1,e,s.Byte)}static addTitle(t,e){t.addFieldOffset(2,e,0)}static addDescription(t,e){t.addFieldOffset(3,e,0)}static addWidth(t,e){t.addFieldInt32(4,e,-1)}static addPrecision(t,e){t.addFieldInt32(5,e,-1)}static addScale(t,e){t.addFieldInt32(6,e,-1)}static addNullable(t,e){t.addFieldInt8(7,+e,1)}static addUnique(t,e){t.addFieldInt8(8,+e,0)}static addPrimaryKey(t,e){t.addFieldInt8(9,+e,0)}static addMetadata(t,e){t.addFieldOffset(10,e,0)}static endColumn(t){const e=t.endObject();return t.requiredField(e,4),e}static createColumn(t,e,s,r,i,n,o,a,b,h,c,d){return l.startColumn(t),l.addName(t,e),l.addType(t,s),l.addTitle(t,r),l.addDescription(t,i),l.addWidth(t,n),l.addPrecision(t,o),l.addScale(t,a),l.addNullable(t,b),l.addUnique(t,h),l.addPrimaryKey(t,c),l.addMetadata(t,d),l.endColumn(t)}}class f{constructor(){this.bb=null,this.bb_pos=0}__init(t,e){return this.bb_pos=t,this.bb=e,this}static getRootAsCrs(t,e){return(e||new f).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsCrs(t,e){return t.setPosition(t.position()+4),(e||new f).__init(t.readInt32(t.position())+t.position(),t)}org(t){const e=this.bb.__offset(this.bb_pos,4);return e?this.bb.__string(this.bb_pos+e,t):null}code(){const t=this.bb.__offset(this.bb_pos,6);return t?this.bb.readInt32(this.bb_pos+t):0}name(t){const e=this.bb.__offset(this.bb_pos,8);return e?this.bb.__string(this.bb_pos+e,t):null}description(t){const e=this.bb.__offset(this.bb_pos,10);return e?this.bb.__string(this.bb_pos+e,t):null}wkt(t){const e=this.bb.__offset(this.bb_pos,12);return e?this.bb.__string(this.bb_pos+e,t):null}codeString(t){const e=this.bb.__offset(this.bb_pos,14);return e?this.bb.__string(this.bb_pos+e,t):null}static startCrs(t){t.startObject(6)}static addOrg(t,e){t.addFieldOffset(0,e,0)}static addCode(t,e){t.addFieldInt32(1,e,0)}static addName(t,e){t.addFieldOffset(2,e,0)}static addDescription(t,e){t.addFieldOffset(3,e,0)}static addWkt(t,e){t.addFieldOffset(4,e,0)}static addCodeString(t,e){t.addFieldOffset(5,e,0)}static endCrs(t){return t.endObject()}static createCrs(t,e,s,r,i,n,o){return f.startCrs(t),f.addOrg(t,e),f.addCode(t,s),f.addName(t,r),f.addDescription(t,i),f.addWkt(t,n),f.addCodeString(t,o),f.endCrs(t)}}!function(t){t[t.Unknown=0]="Unknown",t[t.Point=1]="Point",t[t.LineString=2]="LineString",t[t.Polygon=3]="Polygon",t[t.MultiPoint=4]="MultiPoint",t[t.MultiLineString=5]="MultiLineString",t[t.MultiPolygon=6]="MultiPolygon",t[t.GeometryCollection=7]="GeometryCollection",t[t.CircularString=8]="CircularString",t[t.CompoundCurve=9]="CompoundCurve",t[t.CurvePolygon=10]="CurvePolygon",t[t.MultiCurve=11]="MultiCurve",t[t.MultiSurface=12]="MultiSurface",t[t.Curve=13]="Curve",t[t.Surface=14]="Surface",t[t.PolyhedralSurface=15]="PolyhedralSurface",t[t.TIN=16]="TIN",t[t.Triangle=17]="Triangle"}(c||(c={}));class _{constructor(){this.bb=null,this.bb_pos=0}__init(t,e){return this.bb_pos=t,this.bb=e,this}static getRootAsHeader(t,e){return(e||new _).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsHeader(t,e){return t.setPosition(t.position()+4),(e||new _).__init(t.readInt32(t.position())+t.position(),t)}name(t){const e=this.bb.__offset(this.bb_pos,4);return e?this.bb.__string(this.bb_pos+e,t):null}envelope(t){const e=this.bb.__offset(this.bb_pos,6);return e?this.bb.readFloat64(this.bb.__vector(this.bb_pos+e)+8*t):0}envelopeLength(){const t=this.bb.__offset(this.bb_pos,6);return t?this.bb.__vector_len(this.bb_pos+t):0}envelopeArray(){const t=this.bb.__offset(this.bb_pos,6);return t?new Float64Array(this.bb.bytes().buffer,this.bb.bytes().byteOffset+this.bb.__vector(this.bb_pos+t),this.bb.__vector_len(this.bb_pos+t)):null}geometryType(){const t=this.bb.__offset(this.bb_pos,8);return t?this.bb.readUint8(this.bb_pos+t):c.Unknown}hasZ(){const t=this.bb.__offset(this.bb_pos,10);return!!t&&!!this.bb.readInt8(this.bb_pos+t)}hasM(){const t=this.bb.__offset(this.bb_pos,12);return!!t&&!!this.bb.readInt8(this.bb_pos+t)}hasT(){const t=this.bb.__offset(this.bb_pos,14);return!!t&&!!this.bb.readInt8(this.bb_pos+t)}hasTm(){const t=this.bb.__offset(this.bb_pos,16);return!!t&&!!this.bb.readInt8(this.bb_pos+t)}columns(t,e){const s=this.bb.__offset(this.bb_pos,18);return s?(e||new l).__init(this.bb.__indirect(this.bb.__vector(this.bb_pos+s)+4*t),this.bb):null}columnsLength(){const t=this.bb.__offset(this.bb_pos,18);return t?this.bb.__vector_len(this.bb_pos+t):0}featuresCount(){const t=this.bb.__offset(this.bb_pos,20);return t?this.bb.readUint64(this.bb_pos+t):this.bb.createLong(0,0)}indexNodeSize(){const t=this.bb.__offset(this.bb_pos,22);return t?this.bb.readUint16(this.bb_pos+t):16}crs(t){const e=this.bb.__offset(this.bb_pos,24);return e?(t||new f).__init(this.bb.__indirect(this.bb_pos+e),this.bb):null}title(t){const e=this.bb.__offset(this.bb_pos,26);return e?this.bb.__string(this.bb_pos+e,t):null}description(t){const e=this.bb.__offset(this.bb_pos,28);return e?this.bb.__string(this.bb_pos+e,t):null}metadata(t){const e=this.bb.__offset(this.bb_pos,30);return e?this.bb.__string(this.bb_pos+e,t):null}static startHeader(t){t.startObject(14)}static addName(t,e){t.addFieldOffset(0,e,0)}static addEnvelope(t,e){t.addFieldOffset(1,e,0)}static createEnvelopeVector(t,e){t.startVector(8,e.length,8);for(let s=e.length-1;s>=0;s--)t.addFloat64(e[s]);return t.endVector()}static startEnvelopeVector(t,e){t.startVector(8,e,8)}static addGeometryType(t,e){t.addFieldInt8(2,e,c.Unknown)}static addHasZ(t,e){t.addFieldInt8(3,+e,0)}static addHasM(t,e){t.addFieldInt8(4,+e,0)}static addHasT(t,e){t.addFieldInt8(5,+e,0)}static addHasTm(t,e){t.addFieldInt8(6,+e,0)}static addColumns(t,e){t.addFieldOffset(7,e,0)}static createColumnsVector(t,e){t.startVector(4,e.length,4);for(let s=e.length-1;s>=0;s--)t.addOffset(e[s]);return t.endVector()}static startColumnsVector(t,e){t.startVector(4,e,4)}static addFeaturesCount(t,e){t.addFieldInt64(8,e,t.createLong(0,0))}static addIndexNodeSize(t,e){t.addFieldInt16(9,e,16)}static addCrs(t,e){t.addFieldOffset(10,e,0)}static addTitle(t,e){t.addFieldOffset(11,e,0)}static addDescription(t,e){t.addFieldOffset(12,e,0)}static addMetadata(t,e){t.addFieldOffset(13,e,0)}static endHeader(t){return t.endObject()}static finishHeaderBuffer(t,e){t.finish(e)}static finishSizePrefixedHeaderBuffer(t,e){t.finish(e,void 0,!0)}}class p{constructor(t,e,s,r,i,n,o,a){this.geometryType=t,this.columns=e,this.featuresCount=s,this.indexNodeSize=r,this.crs=i,this.title=n,this.description=o,this.metadata=a}static fromByteBuffer(t){const s=_.getRootAsHeader(t),i=s.featuresCount().toFloat64(),n=s.indexNodeSize(),o=[];for(let t=0;t<s.columnsLength();t++){const r=s.columns(t);if(!r)throw new Error("Column unexpectedly missing");if(!r.name())throw new Error("Column name unexpectedly missing");o.push(new e(r.name(),r.type(),r.title(),r.description(),r.width(),r.precision(),r.scale(),r.nullable(),r.unique(),r.primaryKey()))}const a=s.crs(),b=a?new r(a.org(),a.code(),a.name(),a.description(),a.wkt(),a.codeString()):null;return new p(s.geometryType(),o,i,n,b,s.title(),s.description(),s.metadata())}}class g{constructor(){this.bb=null,this.bb_pos=0}__init(t,e){return this.bb_pos=t,this.bb=e,this}static getRootAsGeometry(t,e){return(e||new g).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsGeometry(t,e){return t.setPosition(t.position()+4),(e||new g).__init(t.readInt32(t.position())+t.position(),t)}ends(t){const e=this.bb.__offset(this.bb_pos,4);return e?this.bb.readUint32(this.bb.__vector(this.bb_pos+e)+4*t):0}endsLength(){const t=this.bb.__offset(this.bb_pos,4);return t?this.bb.__vector_len(this.bb_pos+t):0}endsArray(){const t=this.bb.__offset(this.bb_pos,4);return t?new Uint32Array(this.bb.bytes().buffer,this.bb.bytes().byteOffset+this.bb.__vector(this.bb_pos+t),this.bb.__vector_len(this.bb_pos+t)):null}xy(t){const e=this.bb.__offset(this.bb_pos,6);return e?this.bb.readFloat64(this.bb.__vector(this.bb_pos+e)+8*t):0}xyLength(){const t=this.bb.__offset(this.bb_pos,6);return t?this.bb.__vector_len(this.bb_pos+t):0}xyArray(){const t=this.bb.__offset(this.bb_pos,6);return t?new Float64Array(this.bb.bytes().buffer,this.bb.bytes().byteOffset+this.bb.__vector(this.bb_pos+t),this.bb.__vector_len(this.bb_pos+t)):null}z(t){const e=this.bb.__offset(this.bb_pos,8);return e?this.bb.readFloat64(this.bb.__vector(this.bb_pos+e)+8*t):0}zLength(){const t=this.bb.__offset(this.bb_pos,8);return t?this.bb.__vector_len(this.bb_pos+t):0}zArray(){const t=this.bb.__offset(this.bb_pos,8);return t?new Float64Array(this.bb.bytes().buffer,this.bb.bytes().byteOffset+this.bb.__vector(this.bb_pos+t),this.bb.__vector_len(this.bb_pos+t)):null}m(t){const e=this.bb.__offset(this.bb_pos,10);return e?this.bb.readFloat64(this.bb.__vector(this.bb_pos+e)+8*t):0}mLength(){const t=this.bb.__offset(this.bb_pos,10);return t?this.bb.__vector_len(this.bb_pos+t):0}mArray(){const t=this.bb.__offset(this.bb_pos,10);return t?new Float64Array(this.bb.bytes().buffer,this.bb.bytes().byteOffset+this.bb.__vector(this.bb_pos+t),this.bb.__vector_len(this.bb_pos+t)):null}t(t){const e=this.bb.__offset(this.bb_pos,12);return e?this.bb.readFloat64(this.bb.__vector(this.bb_pos+e)+8*t):0}tLength(){const t=this.bb.__offset(this.bb_pos,12);return t?this.bb.__vector_len(this.bb_pos+t):0}tArray(){const t=this.bb.__offset(this.bb_pos,12);return t?new Float64Array(this.bb.bytes().buffer,this.bb.bytes().byteOffset+this.bb.__vector(this.bb_pos+t),this.bb.__vector_len(this.bb_pos+t)):null}tm(t){const e=this.bb.__offset(this.bb_pos,14);return e?this.bb.readUint64(this.bb.__vector(this.bb_pos+e)+8*t):this.bb.createLong(0,0)}tmLength(){const t=this.bb.__offset(this.bb_pos,14);return t?this.bb.__vector_len(this.bb_pos+t):0}type(){const t=this.bb.__offset(this.bb_pos,16);return t?this.bb.readUint8(this.bb_pos+t):c.Unknown}parts(t,e){const s=this.bb.__offset(this.bb_pos,18);return s?(e||new g).__init(this.bb.__indirect(this.bb.__vector(this.bb_pos+s)+4*t),this.bb):null}partsLength(){const t=this.bb.__offset(this.bb_pos,18);return t?this.bb.__vector_len(this.bb_pos+t):0}static startGeometry(t){t.startObject(8)}static addEnds(t,e){t.addFieldOffset(0,e,0)}static createEndsVector(t,e){t.startVector(4,e.length,4);for(let s=e.length-1;s>=0;s--)t.addInt32(e[s]);return t.endVector()}static startEndsVector(t,e){t.startVector(4,e,4)}static addXy(t,e){t.addFieldOffset(1,e,0)}static createXyVector(t,e){t.startVector(8,e.length,8);for(let s=e.length-1;s>=0;s--)t.addFloat64(e[s]);return t.endVector()}static startXyVector(t,e){t.startVector(8,e,8)}static addZ(t,e){t.addFieldOffset(2,e,0)}static createZVector(t,e){t.startVector(8,e.length,8);for(let s=e.length-1;s>=0;s--)t.addFloat64(e[s]);return t.endVector()}static startZVector(t,e){t.startVector(8,e,8)}static addM(t,e){t.addFieldOffset(3,e,0)}static createMVector(t,e){t.startVector(8,e.length,8);for(let s=e.length-1;s>=0;s--)t.addFloat64(e[s]);return t.endVector()}static startMVector(t,e){t.startVector(8,e,8)}static addT(t,e){t.addFieldOffset(4,e,0)}static createTVector(t,e){t.startVector(8,e.length,8);for(let s=e.length-1;s>=0;s--)t.addFloat64(e[s]);return t.endVector()}static startTVector(t,e){t.startVector(8,e,8)}static addTm(t,e){t.addFieldOffset(5,e,0)}static createTmVector(t,e){t.startVector(8,e.length,8);for(let s=e.length-1;s>=0;s--)t.addInt64(e[s]);return t.endVector()}static startTmVector(t,e){t.startVector(8,e,8)}static addType(t,e){t.addFieldInt8(6,e,c.Unknown)}static addParts(t,e){t.addFieldOffset(7,e,0)}static createPartsVector(t,e){t.startVector(4,e.length,4);for(let s=e.length-1;s>=0;s--)t.addOffset(e[s]);return t.endVector()}static startPartsVector(t,e){t.startVector(4,e,4)}static endGeometry(t){return t.endObject()}static createGeometry(t,e,s,r,i,n,o,a,b){return g.startGeometry(t),g.addEnds(t,e),g.addXy(t,s),g.addZ(t,r),g.addM(t,i),g.addT(t,n),g.addTm(t,o),g.addType(t,a),g.addParts(t,b),g.endGeometry(t)}}function y(t,e,s){if(0!==t.length)if(Array.isArray(t[0]))for(const r of t)y(r,e,s);else 2===t.length?e.push(...t):(e.push(t[0],t[1]),s.push(t[2]))}function w(t,e){const s=[];for(let r=0;r<t.length;r+=2){const i=[t[r],t[r+1]];e&&i.push(e[r>>1]),s.push(i)}return s}function m(t){return t?c[t]:c.Unknown}function v(t){const e=t.coordinates,s=[],r=[];let i,n;const o=m(t.type);let a=0;switch(t.type){case"Point":y(e,s,r);break;case"MultiPoint":case"LineString":y(e,s,r);break;case"MultiLineString":case"Polygon":{const t=e;y(t,s,r),t.length>1&&(i=t.map(t=>a+=t.length));break}case"MultiPolygon":n=e.map(t=>({type:"Polygon",coordinates:t})).map(v);break;case"GeometryCollection":t.geometries&&(n=t.geometries.map(v))}return{xy:s,z:r.length>0?r:void 0,ends:i,type:o,parts:n}}function I(t,e){if(e===c.GeometryCollection){const s=[];for(let e=0;e<t.partsLength();e++){const r=t.parts(e),i=r.type();s.push(I(r,i))}return{type:c[e],geometries:s}}if(e===c.MultiPolygon){const s=[];for(let e=0;e<t.partsLength();e++)s.push(I(t.parts(e),c.Polygon));return{type:c[e],coordinates:s.map(t=>t.coordinates)}}const s=function(t,e){const s=t.xyArray(),r=t.zArray();switch(e){case c.Point:{const t=Array.from(s);return r&&t.push(r[0]),t}case c.MultiPoint:case c.LineString:return w(s,r);case c.MultiLineString:case c.Polygon:return function(t,e,s){if(!s||0===s.length)return[w(t,e)];let r=0;const i=Array.from(s).map(e=>t.slice(r,r=e<<1));let n;return e&&(r=0,n=Array.from(s).map(t=>e.slice(r,r=t))),i.map((t,e)=>w(t,n?n[e]:void 0))}(s,r,t.endsArray())}}(t,e);return{type:c[e],coordinates:s}}class F{constructor(){this.bb=null,this.bb_pos=0}__init(t,e){return this.bb_pos=t,this.bb=e,this}static getRootAsFeature(t,e){return(e||new F).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsFeature(t,e){return t.setPosition(t.position()+4),(e||new F).__init(t.readInt32(t.position())+t.position(),t)}geometry(t){const e=this.bb.__offset(this.bb_pos,4);return e?(t||new g).__init(this.bb.__indirect(this.bb_pos+e),this.bb):null}properties(t){const e=this.bb.__offset(this.bb_pos,6);return e?this.bb.readUint8(this.bb.__vector(this.bb_pos+e)+t):0}propertiesLength(){const t=this.bb.__offset(this.bb_pos,6);return t?this.bb.__vector_len(this.bb_pos+t):0}propertiesArray(){const t=this.bb.__offset(this.bb_pos,6);return t?new Uint8Array(this.bb.bytes().buffer,this.bb.bytes().byteOffset+this.bb.__vector(this.bb_pos+t),this.bb.__vector_len(this.bb_pos+t)):null}columns(t,e){const s=this.bb.__offset(this.bb_pos,8);return s?(e||new l).__init(this.bb.__indirect(this.bb.__vector(this.bb_pos+s)+4*t),this.bb):null}columnsLength(){const t=this.bb.__offset(this.bb_pos,8);return t?this.bb.__vector_len(this.bb_pos+t):0}static startFeature(t){t.startObject(3)}static addGeometry(t,e){t.addFieldOffset(0,e,0)}static addProperties(t,e){t.addFieldOffset(1,e,0)}static createPropertiesVector(t,e){t.startVector(1,e.length,1);for(let s=e.length-1;s>=0;s--)t.addInt8(e[s]);return t.endVector()}static startPropertiesVector(t,e){t.startVector(1,e,1)}static addColumns(t,e){t.addFieldOffset(2,e,0)}static createColumnsVector(t,e){t.startVector(4,e.length,4);for(let s=e.length-1;s>=0;s--)t.addOffset(e[s]);return t.endVector()}static startColumnsVector(t,e){t.startVector(4,e,4)}static endFeature(t){return t.endObject()}static finishFeatureBuffer(t,e){t.finish(e)}static finishSizePrefixedFeatureBuffer(t,e){t.finish(e,void 0,!0)}static createFeature(t,e,s,r){return F.startFeature(t),F.addGeometry(t,e),F.addProperties(t,s),F.addColumns(t,r),F.endFeature(t)}}const O=new TextEncoder,U=new TextDecoder;function S(t,e,r){const i=r.columns,n=new u;let o=0,a=1024,b=new Uint8Array(a),h=new DataView(b.buffer);const c=function(t){if(o+t<a)return;a*=2;const e=new Uint8Array(a);e.set(b),b=e,h=new DataView(b.buffer,o)};if(i)for(let t=0;t<i.length;t++){const r=i[t],n=e[r.name];if(null!==n)switch(h.setUint16(o,t,!0),o+=2,r.type){case s.Bool:c(1),h.setUint8(o,n),o+=1;break;case s.Short:c(2),h.setInt16(o,n,!0),o+=2;break;case s.UShort:c(2),h.setUint16(o,n,!0),o+=2;break;case s.Int:c(4),h.setInt32(o,n,!0),o+=4;break;case s.UInt:c(4),h.setUint32(o,n,!0),o+=4;break;case s.Long:c(8),h.setBigInt64(o,BigInt(n),!0),o+=8;break;case s.Double:c(8),h.setFloat64(o,n,!0),o+=8;break;case s.DateTime:case s.String:{const t=O.encode(n);c(4),h.setUint32(o,t.length,!0),o+=4,c(t.length),b.set(t,o),o+=t.length;break}default:throw new Error("Unknown type "+r.type)}}let d=null;o>0&&(d=F.createPropertiesVector(n,b.slice(0,o)));const l=function t(e,s){const{xy:r,z:i,ends:n,parts:o,type:a}=s;if(o){const s=o.map(s=>t(e,s)),r=g.createPartsVector(e,s);return g.startGeometry(e),g.addParts(e,r),g.endGeometry(e)}const b=g.createXyVector(e,r);let h,c;return i&&(h=g.createZVector(e,i)),n&&(c=g.createEndsVector(e,n)),g.startGeometry(e),c&&g.addEnds(e,c),g.addXy(e,b),h&&g.addZ(e,h),g.addType(e,a),g.endGeometry(e)}(n,t);F.startFeature(n),F.addGeometry(n,l),d&&F.addProperties(n,d);const f=F.endFeature(n);return n.finishSizePrefixed(f),n.asUint8Array()}function P(t,e){const r=e.columns,i={type:"Feature",geometry:I(t.geometry(),e.geometryType)};return r&&r.length>0&&(i.properties=function(t,e){const r={};if(!e||0===e.length)return r;const i=t.propertiesArray();if(!i)return r;const n=new DataView(i.buffer,i.byteOffset),o=t.propertiesLength();let a=0;for(;a<o;){const t=n.getUint16(a,!0);a+=2;const o=e[t],b=o.name;switch(o.type){case s.Bool:r[b]=!!n.getUint8(a),a+=1;break;case s.Byte:r[b]=n.getInt8(a),a+=1;break;case s.UByte:r[b]=n.getUint8(a),a+=1;break;case s.Short:r[b]=n.getInt16(a,!0),a+=2;break;case s.UShort:r[b]=n.getUint16(a,!0),a+=2;break;case s.Int:r[b]=n.getInt32(a,!0),a+=4;break;case s.UInt:r[b]=n.getUint32(a,!0),a+=4;break;case s.Long:r[b]=Number(n.getBigInt64(a,!0)),a+=8;break;case s.ULong:r[b]=Number(n.getBigUint64(a,!0)),a+=8;break;case s.Double:r[b]=n.getFloat64(a,!0),a+=8;break;case s.DateTime:case s.String:{const t=n.getUint32(a,!0);a+=4,r[b]=U.decode(i.subarray(a,a+t)),a+=t;break}default:throw new Error("Unknown type "+o.type)}}return r}(t,r)),i}var C,A=new Uint8Array(0);function V(t,e){if(!t.length)return e;if(!e.length)return t;var s=new Uint8Array(t.length+e.length);return s.set(t),s.set(e,t.length),s}function B(t){this._source=t,this._array=A,this._index=0}B.prototype.read=function(){var t=this,e=t._array.subarray(t._index);return t._source.read().then((function(s){return t._array=A,t._index=0,s.done?e.length>0?{done:!1,value:e}:{done:!0,value:void 0}:{done:!1,value:V(e,s.value)}}))},B.prototype.slice=function(t){if((t|=0)<0)throw new Error("invalid length");var e=this,s=this._array.length-this._index;if(this._index+t<=this._array.length)return Promise.resolve(this._array.subarray(this._index,this._index+=t));var r=new Uint8Array(t);return r.set(this._array.subarray(this._index)),function i(){return e._source.read().then((function(n){return n.done?(e._array=A,e._index=0,s>0?r.subarray(0,s):null):s+n.value.length>=t?(e._array=n.value,e._index=t-s,r.set(n.value.subarray(0,t-s),s),r):(r.set(n.value,s),s+=n.value.length,i())}))}()},B.prototype.cancel=function(){return this._source.cancel()},function(t){t[t.Debug=0]="Debug",t[t.Info=1]="Info",t[t.Warn=2]="Warn",t[t.Error=3]="Error"}(C||(C={}));class x{static debug(...t){this.log(C.Debug,...t)}static info(...t){this.log(C.Info,...t)}static warn(...t){this.log(C.Warn,...t)}static error(...t){this.log(C.Error,...t)}static log(t,...e){if(!(this.logLevel>t))switch(t){case C.Debug:console.debug(...e);break;case C.Info:console.info(...e);break;case C.Warn:console.warn(...e);break;case C.Error:console.error(...e)}}}function L(t,e){e=Math.min(Math.max(+e,2),65535);let s=t,r=s;do{s=Math.ceil(s/e),r+=s}while(1!==s);return 40*r}function j(t,e){if(0!=(4293918720&t))throw Error("integer is too large to be safely represented");return e+t*2**32}x.logLevel=C.Info;const T=new Uint8Array([102,103,98,3,102,103,98,0]);class k{constructor(t,e,s,r){this.headerClient=t,this.header=e,this.headerLength=s,this.indexLength=r}static async open(t){const e=new E(t),s=(()=>{let t,e=0;for(t=0;t<3;t++)e+=16**t*40;return e})(),r=2024+s;x.debug(`fetching header. minReqLength: ${r} (assumedHeaderLength: 2024, assumedIndexLength: ${s})`);{const t=new Uint8Array(await e.getRange(0,8,r,"header"));if(!t.every((t,e)=>T[e]===t))throw x.error(`bytes: ${t} != ${T}`),new Error("Not a FlatGeobuf file");x.debug("magic bytes look good")}let i;{const t=await e.getRange(8,4,r,"header");if(i=new DataView(t).getUint32(0,!0),i>10485760||i<8)throw new Error("Invalid header size");x.debug("headerLength: "+i)}const n=await e.getRange(12,i,r,"header"),o=new d(new Uint8Array(n)),a=p.fromByteBuffer(o),b=L(a.featuresCount,a.indexNodeSize);return x.debug("completed: opening http reader"),new k(e,a,i,b)}async*selectBbox(t){const e=this.lengthBeforeTree(),s=this.headerClient;x.debug("starting: selectBbox, traversing index. lengthBeforeTree: "+e),yield*async function*(t,e,s,r){class i{constructor(t,e){this._level=e,this.nodes=t}level(){return this._level}startNode(){return this.nodes[0]}endNode(){return this.nodes[1]}extendEndNodeToNewOffset(t){console.assert(t>this.nodes[1]),this.nodes[1]=t}toString(){return`[NodeRange level: ${this._level}, nodes: ${this.nodes[0]}-${this.nodes[1]}]`}}const{minX:n,minY:o,maxX:a,maxY:b}=s,h=function(t,e){if(e<2)throw new Error("Node size must be at least 2");if(0===t)throw new Error("Number of items must be greater than 0");let s=t,r=s;const i=[s];do{s=Math.ceil(s/e),r+=s,i.push(s)}while(1!==s);const n=[];s=r;for(const t of i)n.push(s-t),s-=t;n.reverse(),i.reverse();const o=[];for(let t=0;t<i.length;t++)o.push([n[t],n[t]+i[t]]);return o.reverse(),o}(t,e),c=h[0][0],d=[(()=>{const t=h.length-1;return new i([0,1],t)})()];for(x.debug(`starting stream search with queue: ${d}, numItems: ${t}, nodeSize: ${e}, levelBounds: ${h}`);0!=d.length;){const t=d.shift();x.debug(`popped node: ${t}, queueLength: ${d.length}`);let s=t.startNode();const u=s>=c,[,l]=h[t.level()],f=Math.min(t.endNode()+e,l),_=f-s,p=await r(40*s,40*_),g=new Float64Array(p),y=new Uint32Array(p);for(let e=s;e<f;e++){const r=5*(e-s);if(a<g[r+0])continue;if(b<g[r+1])continue;if(n>g[r+2])continue;if(o>g[r+3])continue;const h=y[8+(r<<1)],l=j(y[9+(r<<1)],h);if(u){x.debug("yielding feature"),yield[l,e-c];continue}const f=6553.6,_=d[d.length-1];if(void 0!==_&&_.level()==t.level()-1&&l<_.endNode()+f){x.debug(`Merging "nodeRange" request into existing range: ${_}, newOffset: ${_.endNode()} -> ${l}`),_.extendEndNodeToNewOffset(l);continue}let p=(()=>{let e=t.level()-1;return new i([l,l+1],e)})();void 0!==_&&_.level()==p.level()?x.debug(`Same level, but too far away. Pushing new request at offset: ${l} rather than merging with distant ${_}`):x.debug(`Pushing new level for ${p} onto queue with nearestNodeRange: ${_} since there's not already a range for this level.`),d.push(p)}}}(this.header.featuresCount,this.header.indexNodeSize,t,(async function(t,r){return s.getRange(e+t,r,0,"index")}))}lengthBeforeTree(){return T.length+4+this.headerLength}lengthBeforeFeatures(){return this.lengthBeforeTree()+this.indexLength}featureClient(){return void 0===this._featureClient&&(this._featureClient=this.headerClient.clone()),this._featureClient}async readFeature(t){const e=131072,s=t+this.lengthBeforeFeatures();let r;{const t=await this.featureClient().getRange(s,4,e,"feature length");r=new DataView(t).getUint32(0,!0)}x.debug(`featureOffset: ${s}, featureLength: ${r}`);const i=await this.featureClient().getRange(s+4,r,e,"feature data"),n=new Uint8Array(i),o=new Uint8Array(r+4);o.set(n,4);const a=new d(o);return a.setPosition(4),F.getRootAsFeature(a)}}class E{constructor(t){this.buffer=new ArrayBuffer(0),this.head=0,this.httpClient="string"==typeof t?new N(t):t}clone(){const t=new E(this.httpClient);return t.buffer=this.buffer.slice(0),t.head=this.head,t}async getRange(t,e,s,r){x.debug(`need Range: ${t}-${t+e-1}`);const i=t-this.head,n=i+e;if(i>=0&&n<this.buffer.byteLength)return x.debug(`slicing existing Range: ${i}-${n-1}`),this.buffer.slice(i,n);const o=Math.max(e,s);return this.buffer=await this.httpClient.getRange(t,o,r),this.head=t,this.buffer.slice(0,e)}}class N{constructor(t){this.requestsEverMade=0,this.bytesEverRequested=0,this.url=t}async getRange(t,e,s){this.requestsEverMade+=1,this.bytesEverRequested+=e;const r=`bytes=${t}-${t+e-1}`;return x.debug(`request: #${this.requestsEverMade}, purpose: ${s}), bytes: (this_request: ${e}, ever: ${this.bytesEverRequested}), Range: ${r}`),(await fetch(this.url,{headers:{Range:r}})).arrayBuffer()}}async function M(t,e,s){let r=new Uint8Array(await t(4,"feature length"));if(0===r.byteLength)return;let i=new d(r);const n=i.readUint32(0);r=new Uint8Array(await t(n,"feature data"));const o=new Uint8Array(n+4);return o.set(r,4),i=new d(o),i.setPosition(4),s(F.getRootAsFeature(i),e)}function R(t){const e=new u;let s=null;t.columns&&(s=_.createColumnsVector(e,t.columns.map(t=>function(t,e){const s=t.createString(e.name);return l.startColumn(t),l.addName(t,s),l.addType(t,e.type),l.endColumn(t)}(e,t))));const r=e.createString("L1");_.startHeader(e),_.addFeaturesCount(e,new b(t.featuresCount,0)),_.addGeometryType(e,t.geometryType),_.addIndexNodeSize(e,0),s&&_.addColumns(e,s),_.addName(e,r);const i=_.endHeader(e);return e.finishSizePrefixed(i),e.asUint8Array()}t.deserialize=function(t,e,s){return t instanceof Uint8Array?function(t,e){return{type:"FeatureCollection",features:function(t,e,s){if(!t.subarray(0,7).every((t,e)=>T[e]===t))throw new Error("Not a FlatGeobuf file");const r=new d(t),i=r.readUint32(T.length);r.setPosition(T.length+4);const n=p.fromByteBuffer(r);s&&s(n);let o=T.length+4+i;const{indexNodeSize:a,featuresCount:b}=n;a>0&&(o+=L(b,a));const h=[];for(;o<r.capacity();){const t=r.readUint32(o);r.setPosition(o+4);const s=F.getRootAsFeature(r);h.push(e(s,n)),o+=4+t}return h}(t,P,e)}}(t,s):t instanceof ReadableStream?function(t,e){return async function*(t,e,s){const r="function"==typeof(i=t).slice?i:new B("function"==typeof i.read?i:i.getReader());var i;const n=async t=>await r.slice(t);let o=new Uint8Array(await n(8));if(!o.every((t,e)=>T[e]===t))throw new Error("Not a FlatGeobuf file");o=new Uint8Array(await n(4));let a=new d(o);const b=a.readUint32(0);o=new Uint8Array(await n(b)),a=new d(o);const h=p.fromByteBuffer(a);s&&s(h);const{indexNodeSize:c,featuresCount:u}=h;if(c>0){const t=L(u,c);await n(t)}let l;for(;l=await M(n,h,e);)yield l}(t,P,e)}(t,s):function(t,e,s){return async function*(t,e,s,r){const i=await k.open(t);x.debug("opened reader"),r&&r(i.header);for await(const t of i.selectBbox(e)){const e=await i.readFeature(t[0]);yield s(e,i.header)}}(t,e,P,s)}(t,e,s)},t.serialize=function(t){return function(t){const r=function(t){const r=t.features[0],i=r.properties;let n=null;return i&&(n=Object.keys(i).map(t=>new e(t,function(t){if("boolean"==typeof t)return s.Bool;if("number"==typeof t)return t%1==0?s.Int:s.Double;if("string"==typeof t)return s.String;if(null===t)return s.String;throw new Error(`Unknown type (value '${t}')`)}(i[t]),null,null,-1,-1,-1,!0,!1,!1))),new p(m(r.geometry.type),n,t.features.length,0,null,null,null,null)}(t),i=R(r),n=t.features.map(t=>S(v(t.geometry),t.properties,r)),o=n.map(t=>t.length).reduce((t,e)=>t+e),a=new Uint8Array(T.length+i.length+o);a.set(i,T.length);let b=T.length+i.length;for(const t of n)a.set(t,b),b+=t.length;return a.set(T),a}(t)},Object.defineProperty(t,"__esModule",{value:!0})}(e)}]);
//# sourceMappingURL=dist.es5.min.js.map

@@ -1,2 +0,2 @@

!function(t,e){if("object"==typeof exports&&"object"==typeof module)module.exports=e();else if("function"==typeof define&&define.amd)define([],e);else{var i=e();for(var r in i)("object"==typeof exports?exports:t)[r]=i[r]}}(window,(function(){return function(t){var e={};function i(r){if(e[r])return e[r].exports;var s=e[r]={i:r,l:!1,exports:{}};return t[r].call(s.exports,s,s.exports,i),s.l=!0,s.exports}return i.m=t,i.c=e,i.d=function(t,e,r){i.o(t,e)||Object.defineProperty(t,e,{enumerable:!0,get:r})},i.r=function(t){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})},i.t=function(t,e){if(1&e&&(t=i(t)),8&e)return t;if(4&e&&"object"==typeof t&&t&&t.__esModule)return t;var r=Object.create(null);if(i.r(r),Object.defineProperty(r,"default",{enumerable:!0,value:t}),2&e&&"string"!=typeof t)for(var s in t)i.d(r,s,function(e){return t[e]}.bind(null,s));return r},i.n=function(t){var e=t&&t.__esModule?function(){return t.default}:function(){return t};return i.d(e,"a",e),e},i.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},i.p="",i(i.s=1)}([function(t,e,i){!function(t){"use strict";class e{constructor(t,e,i,r,s,n,o,a,b,d){this.name=t,this.type=e,this.title=i,this.description=r,this.width=s,this.precision=n,this.scale=o,this.nullable=a,this.unique=b,this.primary_key=d}}var i,r,s,n,o={SIZEOF_SHORT:2,SIZEOF_INT:4,FILE_IDENTIFIER_LENGTH:4,SIZE_PREFIX_LENGTH:4,Encoding:{UTF8_BYTES:1,UTF16_STRING:2}};o.int32=new Int32Array(2),o.float32=new Float32Array(o.int32.buffer),o.float64=new Float64Array(o.int32.buffer),o.isLittleEndian=1===new Uint16Array(new Uint8Array([1,0]).buffer)[0],o.Long=function(t,e){this.low=0|t,this.high=0|e},o.Long.create=function(t,e){return 0==t&&0==e?o.Long.ZERO:new o.Long(t,e)},o.Long.prototype.toFloat64=function(){return(this.low>>>0)+4294967296*this.high},o.Long.prototype.equals=function(t){return this.low==t.low&&this.high==t.high},o.Long.ZERO=new o.Long(0,0),o.Builder=function(t){if(t)e=t;else var e=1024;this.bb=o.ByteBuffer.allocate(e),this.space=e,this.minalign=1,this.vtable=null,this.vtable_in_use=0,this.isNested=!1,this.object_start=0,this.vtables=[],this.vector_num_elems=0,this.force_defaults=!1},o.Builder.prototype.clear=function(){this.bb.clear(),this.space=this.bb.capacity(),this.minalign=1,this.vtable=null,this.vtable_in_use=0,this.isNested=!1,this.object_start=0,this.vtables=[],this.vector_num_elems=0,this.force_defaults=!1},o.Builder.prototype.forceDefaults=function(t){this.force_defaults=t},o.Builder.prototype.dataBuffer=function(){return this.bb},o.Builder.prototype.asUint8Array=function(){return this.bb.bytes().subarray(this.bb.position(),this.bb.position()+this.offset())},o.Builder.prototype.prep=function(t,e){t>this.minalign&&(this.minalign=t);for(var i=1+~(this.bb.capacity()-this.space+e)&t-1;this.space<i+t+e;){var r=this.bb.capacity();this.bb=o.Builder.growByteBuffer(this.bb),this.space+=this.bb.capacity()-r}this.pad(i)},o.Builder.prototype.pad=function(t){for(var e=0;e<t;e++)this.bb.writeInt8(--this.space,0)},o.Builder.prototype.writeInt8=function(t){this.bb.writeInt8(this.space-=1,t)},o.Builder.prototype.writeInt16=function(t){this.bb.writeInt16(this.space-=2,t)},o.Builder.prototype.writeInt32=function(t){this.bb.writeInt32(this.space-=4,t)},o.Builder.prototype.writeInt64=function(t){this.bb.writeInt64(this.space-=8,t)},o.Builder.prototype.writeFloat32=function(t){this.bb.writeFloat32(this.space-=4,t)},o.Builder.prototype.writeFloat64=function(t){this.bb.writeFloat64(this.space-=8,t)},o.Builder.prototype.addInt8=function(t){this.prep(1,0),this.writeInt8(t)},o.Builder.prototype.addInt16=function(t){this.prep(2,0),this.writeInt16(t)},o.Builder.prototype.addInt32=function(t){this.prep(4,0),this.writeInt32(t)},o.Builder.prototype.addInt64=function(t){this.prep(8,0),this.writeInt64(t)},o.Builder.prototype.addFloat32=function(t){this.prep(4,0),this.writeFloat32(t)},o.Builder.prototype.addFloat64=function(t){this.prep(8,0),this.writeFloat64(t)},o.Builder.prototype.addFieldInt8=function(t,e,i){(this.force_defaults||e!=i)&&(this.addInt8(e),this.slot(t))},o.Builder.prototype.addFieldInt16=function(t,e,i){(this.force_defaults||e!=i)&&(this.addInt16(e),this.slot(t))},o.Builder.prototype.addFieldInt32=function(t,e,i){(this.force_defaults||e!=i)&&(this.addInt32(e),this.slot(t))},o.Builder.prototype.addFieldInt64=function(t,e,i){!this.force_defaults&&e.equals(i)||(this.addInt64(e),this.slot(t))},o.Builder.prototype.addFieldFloat32=function(t,e,i){(this.force_defaults||e!=i)&&(this.addFloat32(e),this.slot(t))},o.Builder.prototype.addFieldFloat64=function(t,e,i){(this.force_defaults||e!=i)&&(this.addFloat64(e),this.slot(t))},o.Builder.prototype.addFieldOffset=function(t,e,i){(this.force_defaults||e!=i)&&(this.addOffset(e),this.slot(t))},o.Builder.prototype.addFieldStruct=function(t,e,i){e!=i&&(this.nested(e),this.slot(t))},o.Builder.prototype.nested=function(t){if(t!=this.offset())throw new Error("FlatBuffers: struct must be serialized inline.")},o.Builder.prototype.notNested=function(){if(this.isNested)throw new Error("FlatBuffers: object serialization must not be nested.")},o.Builder.prototype.slot=function(t){this.vtable[t]=this.offset()},o.Builder.prototype.offset=function(){return this.bb.capacity()-this.space},o.Builder.growByteBuffer=function(t){var e=t.capacity();if(3221225472&e)throw new Error("FlatBuffers: cannot grow buffer beyond 2 gigabytes.");var i=e<<1,r=o.ByteBuffer.allocate(i);return r.setPosition(i-e),r.bytes().set(t.bytes(),i-e),r},o.Builder.prototype.addOffset=function(t){this.prep(o.SIZEOF_INT,0),this.writeInt32(this.offset()-t+o.SIZEOF_INT)},o.Builder.prototype.startObject=function(t){this.notNested(),null==this.vtable&&(this.vtable=[]),this.vtable_in_use=t;for(var e=0;e<t;e++)this.vtable[e]=0;this.isNested=!0,this.object_start=this.offset()},o.Builder.prototype.endObject=function(){if(null==this.vtable||!this.isNested)throw new Error("FlatBuffers: endObject called without startObject");this.addInt32(0);for(var t=this.offset(),e=this.vtable_in_use-1;e>=0&&0==this.vtable[e];e--);for(var i=e+1;e>=0;e--)this.addInt16(0!=this.vtable[e]?t-this.vtable[e]:0);this.addInt16(t-this.object_start);var r=(i+2)*o.SIZEOF_SHORT;this.addInt16(r);var s=0,n=this.space;t:for(e=0;e<this.vtables.length;e++){var a=this.bb.capacity()-this.vtables[e];if(r==this.bb.readInt16(a)){for(var b=o.SIZEOF_SHORT;b<r;b+=o.SIZEOF_SHORT)if(this.bb.readInt16(n+b)!=this.bb.readInt16(a+b))continue t;s=this.vtables[e];break}}return s?(this.space=this.bb.capacity()-t,this.bb.writeInt32(this.space,s-t)):(this.vtables.push(this.offset()),this.bb.writeInt32(this.bb.capacity()-t,this.offset()-t)),this.isNested=!1,t},o.Builder.prototype.finish=function(t,e,i){var r=i?o.SIZE_PREFIX_LENGTH:0;if(e){var s=e;if(this.prep(this.minalign,o.SIZEOF_INT+o.FILE_IDENTIFIER_LENGTH+r),s.length!=o.FILE_IDENTIFIER_LENGTH)throw new Error("FlatBuffers: file identifier must be length "+o.FILE_IDENTIFIER_LENGTH);for(var n=o.FILE_IDENTIFIER_LENGTH-1;n>=0;n--)this.writeInt8(s.charCodeAt(n))}this.prep(this.minalign,o.SIZEOF_INT+r),this.addOffset(t),r&&this.addInt32(this.bb.capacity()-this.space),this.bb.setPosition(this.space)},o.Builder.prototype.finishSizePrefixed=function(t,e){this.finish(t,e,!0)},o.Builder.prototype.requiredField=function(t,e){var i=this.bb.capacity()-t,r=i-this.bb.readInt32(i);if(0==this.bb.readInt16(r+e))throw new Error("FlatBuffers: field "+e+" must be set")},o.Builder.prototype.startVector=function(t,e,i){this.notNested(),this.vector_num_elems=e,this.prep(o.SIZEOF_INT,t*e),this.prep(i,t*e)},o.Builder.prototype.endVector=function(){return this.writeInt32(this.vector_num_elems),this.offset()},o.Builder.prototype.createString=function(t){if(t instanceof Uint8Array)var e=t;else{e=[];for(var i=0;i<t.length;){var r,s=t.charCodeAt(i++);(r=s<55296||s>=56320?s:(s<<10)+t.charCodeAt(i++)+-56613888)<128?e.push(r):(r<2048?e.push(r>>6&31|192):(r<65536?e.push(r>>12&15|224):e.push(r>>18&7|240,r>>12&63|128),e.push(r>>6&63|128)),e.push(63&r|128))}}this.addInt8(0),this.startVector(1,e.length,1),this.bb.setPosition(this.space-=e.length),i=0;for(var n=this.space,o=this.bb.bytes();i<e.length;i++)o[n++]=e[i];return this.endVector()},o.Builder.prototype.createLong=function(t,e){return o.Long.create(t,e)},o.ByteBuffer=function(t){this.bytes_=t,this.position_=0},o.ByteBuffer.allocate=function(t){return new o.ByteBuffer(new Uint8Array(t))},o.ByteBuffer.prototype.clear=function(){this.position_=0},o.ByteBuffer.prototype.bytes=function(){return this.bytes_},o.ByteBuffer.prototype.position=function(){return this.position_},o.ByteBuffer.prototype.setPosition=function(t){this.position_=t},o.ByteBuffer.prototype.capacity=function(){return this.bytes_.length},o.ByteBuffer.prototype.readInt8=function(t){return this.readUint8(t)<<24>>24},o.ByteBuffer.prototype.readUint8=function(t){return this.bytes_[t]},o.ByteBuffer.prototype.readInt16=function(t){return this.readUint16(t)<<16>>16},o.ByteBuffer.prototype.readUint16=function(t){return this.bytes_[t]|this.bytes_[t+1]<<8},o.ByteBuffer.prototype.readInt32=function(t){return this.bytes_[t]|this.bytes_[t+1]<<8|this.bytes_[t+2]<<16|this.bytes_[t+3]<<24},o.ByteBuffer.prototype.readUint32=function(t){return this.readInt32(t)>>>0},o.ByteBuffer.prototype.readInt64=function(t){return new o.Long(this.readInt32(t),this.readInt32(t+4))},o.ByteBuffer.prototype.readUint64=function(t){return new o.Long(this.readUint32(t),this.readUint32(t+4))},o.ByteBuffer.prototype.readFloat32=function(t){return o.int32[0]=this.readInt32(t),o.float32[0]},o.ByteBuffer.prototype.readFloat64=function(t){return o.int32[o.isLittleEndian?0:1]=this.readInt32(t),o.int32[o.isLittleEndian?1:0]=this.readInt32(t+4),o.float64[0]},o.ByteBuffer.prototype.writeInt8=function(t,e){this.bytes_[t]=e},o.ByteBuffer.prototype.writeUint8=function(t,e){this.bytes_[t]=e},o.ByteBuffer.prototype.writeInt16=function(t,e){this.bytes_[t]=e,this.bytes_[t+1]=e>>8},o.ByteBuffer.prototype.writeUint16=function(t,e){this.bytes_[t]=e,this.bytes_[t+1]=e>>8},o.ByteBuffer.prototype.writeInt32=function(t,e){this.bytes_[t]=e,this.bytes_[t+1]=e>>8,this.bytes_[t+2]=e>>16,this.bytes_[t+3]=e>>24},o.ByteBuffer.prototype.writeUint32=function(t,e){this.bytes_[t]=e,this.bytes_[t+1]=e>>8,this.bytes_[t+2]=e>>16,this.bytes_[t+3]=e>>24},o.ByteBuffer.prototype.writeInt64=function(t,e){this.writeInt32(t,e.low),this.writeInt32(t+4,e.high)},o.ByteBuffer.prototype.writeUint64=function(t,e){this.writeUint32(t,e.low),this.writeUint32(t+4,e.high)},o.ByteBuffer.prototype.writeFloat32=function(t,e){o.float32[0]=e,this.writeInt32(t,o.int32[0])},o.ByteBuffer.prototype.writeFloat64=function(t,e){o.float64[0]=e,this.writeInt32(t,o.int32[o.isLittleEndian?0:1]),this.writeInt32(t+4,o.int32[o.isLittleEndian?1:0])},o.ByteBuffer.prototype.getBufferIdentifier=function(){if(this.bytes_.length<this.position_+o.SIZEOF_INT+o.FILE_IDENTIFIER_LENGTH)throw new Error("FlatBuffers: ByteBuffer is too short to contain an identifier.");for(var t="",e=0;e<o.FILE_IDENTIFIER_LENGTH;e++)t+=String.fromCharCode(this.readInt8(this.position_+o.SIZEOF_INT+e));return t},o.ByteBuffer.prototype.__offset=function(t,e){var i=t-this.readInt32(t);return e<this.readInt16(i)?this.readInt16(i+e):0},o.ByteBuffer.prototype.__union=function(t,e){return t.bb_pos=e+this.readInt32(e),t.bb=this,t},o.ByteBuffer.prototype.__string=function(t,e){t+=this.readInt32(t);var i=this.readInt32(t),r="",s=0;if(t+=o.SIZEOF_INT,e===o.Encoding.UTF8_BYTES)return this.bytes_.subarray(t,t+i);for(;s<i;){var n,a=this.readUint8(t+s++);if(a<192)n=a;else{var b=this.readUint8(t+s++);if(a<224)n=(31&a)<<6|63&b;else{var d=this.readUint8(t+s++);n=a<240?(15&a)<<12|(63&b)<<6|63&d:(7&a)<<18|(63&b)<<12|(63&d)<<6|63&this.readUint8(t+s++)}}n<65536?r+=String.fromCharCode(n):(n-=65536,r+=String.fromCharCode(55296+(n>>10),56320+(1023&n)))}return r},o.ByteBuffer.prototype.__indirect=function(t){return t+this.readInt32(t)},o.ByteBuffer.prototype.__vector=function(t){return t+this.readInt32(t)+o.SIZEOF_INT},o.ByteBuffer.prototype.__vector_len=function(t){return this.readInt32(t+this.readInt32(t))},o.ByteBuffer.prototype.__has_identifier=function(t){if(t.length!=o.FILE_IDENTIFIER_LENGTH)throw new Error("FlatBuffers: file identifier must be length "+o.FILE_IDENTIFIER_LENGTH);for(var e=0;e<o.FILE_IDENTIFIER_LENGTH;e++)if(t.charCodeAt(e)!=this.readInt8(this.position_+o.SIZEOF_INT+e))return!1;return!0},o.ByteBuffer.prototype.createLong=function(t,e){return o.Long.create(t,e)},function(t){t[t.Unknown=0]="Unknown",t[t.Point=1]="Point",t[t.LineString=2]="LineString",t[t.Polygon=3]="Polygon",t[t.MultiPoint=4]="MultiPoint",t[t.MultiLineString=5]="MultiLineString",t[t.MultiPolygon=6]="MultiPolygon",t[t.GeometryCollection=7]="GeometryCollection",t[t.CircularString=8]="CircularString",t[t.CompoundCurve=9]="CompoundCurve",t[t.CurvePolygon=10]="CurvePolygon",t[t.MultiCurve=11]="MultiCurve",t[t.MultiSurface=12]="MultiSurface",t[t.Curve=13]="Curve",t[t.Surface=14]="Surface",t[t.PolyhedralSurface=15]="PolyhedralSurface",t[t.TIN=16]="TIN",t[t.Triangle=17]="Triangle"}(i||(i={})),function(t){t[t.Byte=0]="Byte",t[t.UByte=1]="UByte",t[t.Bool=2]="Bool",t[t.Short=3]="Short",t[t.UShort=4]="UShort",t[t.Int=5]="Int",t[t.UInt=6]="UInt",t[t.Long=7]="Long",t[t.ULong=8]="ULong",t[t.Float=9]="Float",t[t.Double=10]="Double",t[t.String=11]="String",t[t.Json=12]="Json",t[t.DateTime=13]="DateTime",t[t.Binary=14]="Binary"}(r||(r={}));class a{constructor(){this.bb=null,this.bb_pos=0}__init(t,e){return this.bb_pos=t,this.bb=e,this}static getRoot(t,e){return(e||new a).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRoot(t,e){return t.setPosition(t.position()+o.SIZE_PREFIX_LENGTH),(e||new a).__init(t.readInt32(t.position())+t.position(),t)}name(t){var e=this.bb.__offset(this.bb_pos,4);return e?this.bb.__string(this.bb_pos+e,t):null}type(){var t=this.bb.__offset(this.bb_pos,6);return t?this.bb.readUint8(this.bb_pos+t):r.Byte}title(t){var e=this.bb.__offset(this.bb_pos,8);return e?this.bb.__string(this.bb_pos+e,t):null}description(t){var e=this.bb.__offset(this.bb_pos,10);return e?this.bb.__string(this.bb_pos+e,t):null}width(){var t=this.bb.__offset(this.bb_pos,12);return t?this.bb.readInt32(this.bb_pos+t):-1}precision(){var t=this.bb.__offset(this.bb_pos,14);return t?this.bb.readInt32(this.bb_pos+t):-1}scale(){var t=this.bb.__offset(this.bb_pos,16);return t?this.bb.readInt32(this.bb_pos+t):-1}nullable(){var t=this.bb.__offset(this.bb_pos,18);return!t||!!this.bb.readInt8(this.bb_pos+t)}unique(){var t=this.bb.__offset(this.bb_pos,20);return!!t&&!!this.bb.readInt8(this.bb_pos+t)}primaryKey(){var t=this.bb.__offset(this.bb_pos,22);return!!t&&!!this.bb.readInt8(this.bb_pos+t)}metadata(t){var e=this.bb.__offset(this.bb_pos,24);return e?this.bb.__string(this.bb_pos+e,t):null}static start(t){t.startObject(11)}static addName(t,e){t.addFieldOffset(0,e,0)}static addType(t,e){t.addFieldInt8(1,e,r.Byte)}static addTitle(t,e){t.addFieldOffset(2,e,0)}static addDescription(t,e){t.addFieldOffset(3,e,0)}static addWidth(t,e){t.addFieldInt32(4,e,-1)}static addPrecision(t,e){t.addFieldInt32(5,e,-1)}static addScale(t,e){t.addFieldInt32(6,e,-1)}static addNullable(t,e){t.addFieldInt8(7,+e,1)}static addUnique(t,e){t.addFieldInt8(8,+e,0)}static addPrimaryKey(t,e){t.addFieldInt8(9,+e,0)}static addMetadata(t,e){t.addFieldOffset(10,e,0)}static end(t){var e=t.endObject();return t.requiredField(e,4),e}static create(t,e,i,r,s,n,o,b,d,h,u,f){return a.start(t),a.addName(t,e),a.addType(t,i),a.addTitle(t,r),a.addDescription(t,s),a.addWidth(t,n),a.addPrecision(t,o),a.addScale(t,b),a.addNullable(t,d),a.addUnique(t,h),a.addPrimaryKey(t,u),a.addMetadata(t,f),a.end(t)}}class b{constructor(){this.bb=null,this.bb_pos=0}__init(t,e){return this.bb_pos=t,this.bb=e,this}static getRoot(t,e){return(e||new b).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRoot(t,e){return t.setPosition(t.position()+o.SIZE_PREFIX_LENGTH),(e||new b).__init(t.readInt32(t.position())+t.position(),t)}org(t){var e=this.bb.__offset(this.bb_pos,4);return e?this.bb.__string(this.bb_pos+e,t):null}code(){var t=this.bb.__offset(this.bb_pos,6);return t?this.bb.readInt32(this.bb_pos+t):0}name(t){var e=this.bb.__offset(this.bb_pos,8);return e?this.bb.__string(this.bb_pos+e,t):null}description(t){var e=this.bb.__offset(this.bb_pos,10);return e?this.bb.__string(this.bb_pos+e,t):null}wkt(t){var e=this.bb.__offset(this.bb_pos,12);return e?this.bb.__string(this.bb_pos+e,t):null}codeString(t){var e=this.bb.__offset(this.bb_pos,14);return e?this.bb.__string(this.bb_pos+e,t):null}static start(t){t.startObject(6)}static addOrg(t,e){t.addFieldOffset(0,e,0)}static addCode(t,e){t.addFieldInt32(1,e,0)}static addName(t,e){t.addFieldOffset(2,e,0)}static addDescription(t,e){t.addFieldOffset(3,e,0)}static addWkt(t,e){t.addFieldOffset(4,e,0)}static addCodeString(t,e){t.addFieldOffset(5,e,0)}static end(t){return t.endObject()}static create(t,e,i,r,s,n,o){return b.start(t),b.addOrg(t,e),b.addCode(t,i),b.addName(t,r),b.addDescription(t,s),b.addWkt(t,n),b.addCodeString(t,o),b.end(t)}}class d{constructor(){this.bb=null,this.bb_pos=0}__init(t,e){return this.bb_pos=t,this.bb=e,this}static getRoot(t,e){return(e||new d).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRoot(t,e){return t.setPosition(t.position()+o.SIZE_PREFIX_LENGTH),(e||new d).__init(t.readInt32(t.position())+t.position(),t)}name(t){var e=this.bb.__offset(this.bb_pos,4);return e?this.bb.__string(this.bb_pos+e,t):null}envelope(t){var e=this.bb.__offset(this.bb_pos,6);return e?this.bb.readFloat64(this.bb.__vector(this.bb_pos+e)+8*t):0}envelopeLength(){var t=this.bb.__offset(this.bb_pos,6);return t?this.bb.__vector_len(this.bb_pos+t):0}envelopeArray(){var t=this.bb.__offset(this.bb_pos,6);return t?new Float64Array(this.bb.bytes().buffer,this.bb.bytes().byteOffset+this.bb.__vector(this.bb_pos+t),this.bb.__vector_len(this.bb_pos+t)):null}geometryType(){var t=this.bb.__offset(this.bb_pos,8);return t?this.bb.readUint8(this.bb_pos+t):i.Unknown}hasZ(){var t=this.bb.__offset(this.bb_pos,10);return!!t&&!!this.bb.readInt8(this.bb_pos+t)}hasM(){var t=this.bb.__offset(this.bb_pos,12);return!!t&&!!this.bb.readInt8(this.bb_pos+t)}hasT(){var t=this.bb.__offset(this.bb_pos,14);return!!t&&!!this.bb.readInt8(this.bb_pos+t)}hasTM(){var t=this.bb.__offset(this.bb_pos,16);return!!t&&!!this.bb.readInt8(this.bb_pos+t)}columns(t,e){var i=this.bb.__offset(this.bb_pos,18);return i?(e||new a).__init(this.bb.__indirect(this.bb.__vector(this.bb_pos+i)+4*t),this.bb):null}columnsLength(){var t=this.bb.__offset(this.bb_pos,18);return t?this.bb.__vector_len(this.bb_pos+t):0}featuresCount(){var t=this.bb.__offset(this.bb_pos,20);return t?this.bb.readUint64(this.bb_pos+t):this.bb.createLong(0,0)}indexNodeSize(){var t=this.bb.__offset(this.bb_pos,22);return t?this.bb.readUint16(this.bb_pos+t):16}crs(t){var e=this.bb.__offset(this.bb_pos,24);return e?(t||new b).__init(this.bb.__indirect(this.bb_pos+e),this.bb):null}title(t){var e=this.bb.__offset(this.bb_pos,26);return e?this.bb.__string(this.bb_pos+e,t):null}description(t){var e=this.bb.__offset(this.bb_pos,28);return e?this.bb.__string(this.bb_pos+e,t):null}metadata(t){var e=this.bb.__offset(this.bb_pos,30);return e?this.bb.__string(this.bb_pos+e,t):null}static start(t){t.startObject(14)}static addName(t,e){t.addFieldOffset(0,e,0)}static addEnvelope(t,e){t.addFieldOffset(1,e,0)}static createEnvelopeVector(t,e){t.startVector(8,e.length,8);for(var i=e.length-1;i>=0;i--)t.addFloat64(e[i]);return t.endVector()}static startEnvelopeVector(t,e){t.startVector(8,e,8)}static addGeometryType(t,e){t.addFieldInt8(2,e,i.Unknown)}static addHasZ(t,e){t.addFieldInt8(3,+e,0)}static addHasM(t,e){t.addFieldInt8(4,+e,0)}static addHasT(t,e){t.addFieldInt8(5,+e,0)}static addHasTM(t,e){t.addFieldInt8(6,+e,0)}static addColumns(t,e){t.addFieldOffset(7,e,0)}static createColumnsVector(t,e){t.startVector(4,e.length,4);for(var i=e.length-1;i>=0;i--)t.addOffset(e[i]);return t.endVector()}static startColumnsVector(t,e){t.startVector(4,e,4)}static addFeaturesCount(t,e){t.addFieldInt64(8,e,t.createLong(0,0))}static addIndexNodeSize(t,e){t.addFieldInt16(9,e,16)}static addCrs(t,e){t.addFieldOffset(10,e,0)}static addTitle(t,e){t.addFieldOffset(11,e,0)}static addDescription(t,e){t.addFieldOffset(12,e,0)}static addMetadata(t,e){t.addFieldOffset(13,e,0)}static end(t){return t.endObject()}static finishBuffer(t,e){t.finish(e)}static finishSizePrefixedBuffer(t,e){t.finish(e,void 0,!0)}static create(t,e,i,r,s,n,o,a,b,h,u,f,c,l,_){return d.start(t),d.addName(t,e),d.addEnvelope(t,i),d.addGeometryType(t,r),d.addHasZ(t,s),d.addHasM(t,n),d.addHasT(t,o),d.addHasTM(t,a),d.addColumns(t,b),d.addFeaturesCount(t,h),d.addIndexNodeSize(t,u),d.addCrs(t,f),d.addTitle(t,c),d.addDescription(t,l),d.addMetadata(t,_),d.end(t)}}class h{constructor(t,e,i,r,s,n){this.org=t,this.code=e,this.name=i,this.description=r,this.wkt=s,this.code_string=n}}class u{constructor(t,e,i,r,s,n,o,a){this.geometryType=t,this.columns=e,this.featuresCount=i,this.indexNodeSize=r,this.crs=s,this.title=n,this.description=o,this.metadata=a}static fromByteBuffer(t){const i=d.getRoot(t),r=i.featuresCount().toFloat64(),s=i.indexNodeSize(),n=[];for(let t=0;t<i.columnsLength();t++){const r=i.columns(t);if(!r)throw new Error("Column unexpectedly missing");if(!r.name())throw new Error("Column name unexpectedly missing");n.push(new e(r.name(),r.type(),r.title(),r.description(),r.width(),r.precision(),r.scale(),r.nullable(),r.unique(),r.primaryKey()))}const o=i.crs(),a=o?new h(o.org(),o.code(),o.name(),o.description(),o.wkt(),o.codeString()):null;return new u(i.geometryType(),n,r,s,a,i.title(),i.description(),i.metadata())}}!function(t){t[t.Unknown=0]="Unknown",t[t.Point=1]="Point",t[t.LineString=2]="LineString",t[t.Polygon=3]="Polygon",t[t.MultiPoint=4]="MultiPoint",t[t.MultiLineString=5]="MultiLineString",t[t.MultiPolygon=6]="MultiPolygon",t[t.GeometryCollection=7]="GeometryCollection",t[t.CircularString=8]="CircularString",t[t.CompoundCurve=9]="CompoundCurve",t[t.CurvePolygon=10]="CurvePolygon",t[t.MultiCurve=11]="MultiCurve",t[t.MultiSurface=12]="MultiSurface",t[t.Curve=13]="Curve",t[t.Surface=14]="Surface",t[t.PolyhedralSurface=15]="PolyhedralSurface",t[t.TIN=16]="TIN",t[t.Triangle=17]="Triangle"}(s||(s={})),function(t){t[t.Byte=0]="Byte",t[t.UByte=1]="UByte",t[t.Bool=2]="Bool",t[t.Short=3]="Short",t[t.UShort=4]="UShort",t[t.Int=5]="Int",t[t.UInt=6]="UInt",t[t.Long=7]="Long",t[t.ULong=8]="ULong",t[t.Float=9]="Float",t[t.Double=10]="Double",t[t.String=11]="String",t[t.Json=12]="Json",t[t.DateTime=13]="DateTime",t[t.Binary=14]="Binary"}(n||(n={}));class f{constructor(){this.bb=null,this.bb_pos=0}__init(t,e){return this.bb_pos=t,this.bb=e,this}static getRoot(t,e){return(e||new f).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRoot(t,e){return t.setPosition(t.position()+o.SIZE_PREFIX_LENGTH),(e||new f).__init(t.readInt32(t.position())+t.position(),t)}name(t){var e=this.bb.__offset(this.bb_pos,4);return e?this.bb.__string(this.bb_pos+e,t):null}type(){var t=this.bb.__offset(this.bb_pos,6);return t?this.bb.readUint8(this.bb_pos+t):n.Byte}title(t){var e=this.bb.__offset(this.bb_pos,8);return e?this.bb.__string(this.bb_pos+e,t):null}description(t){var e=this.bb.__offset(this.bb_pos,10);return e?this.bb.__string(this.bb_pos+e,t):null}width(){var t=this.bb.__offset(this.bb_pos,12);return t?this.bb.readInt32(this.bb_pos+t):-1}precision(){var t=this.bb.__offset(this.bb_pos,14);return t?this.bb.readInt32(this.bb_pos+t):-1}scale(){var t=this.bb.__offset(this.bb_pos,16);return t?this.bb.readInt32(this.bb_pos+t):-1}nullable(){var t=this.bb.__offset(this.bb_pos,18);return!t||!!this.bb.readInt8(this.bb_pos+t)}unique(){var t=this.bb.__offset(this.bb_pos,20);return!!t&&!!this.bb.readInt8(this.bb_pos+t)}primaryKey(){var t=this.bb.__offset(this.bb_pos,22);return!!t&&!!this.bb.readInt8(this.bb_pos+t)}metadata(t){var e=this.bb.__offset(this.bb_pos,24);return e?this.bb.__string(this.bb_pos+e,t):null}static start(t){t.startObject(11)}static addName(t,e){t.addFieldOffset(0,e,0)}static addType(t,e){t.addFieldInt8(1,e,n.Byte)}static addTitle(t,e){t.addFieldOffset(2,e,0)}static addDescription(t,e){t.addFieldOffset(3,e,0)}static addWidth(t,e){t.addFieldInt32(4,e,-1)}static addPrecision(t,e){t.addFieldInt32(5,e,-1)}static addScale(t,e){t.addFieldInt32(6,e,-1)}static addNullable(t,e){t.addFieldInt8(7,+e,1)}static addUnique(t,e){t.addFieldInt8(8,+e,0)}static addPrimaryKey(t,e){t.addFieldInt8(9,+e,0)}static addMetadata(t,e){t.addFieldOffset(10,e,0)}static end(t){var e=t.endObject();return t.requiredField(e,4),e}static create(t,e,i,r,s,n,o,a,b,d,h,u){return f.start(t),f.addName(t,e),f.addType(t,i),f.addTitle(t,r),f.addDescription(t,s),f.addWidth(t,n),f.addPrecision(t,o),f.addScale(t,a),f.addNullable(t,b),f.addUnique(t,d),f.addPrimaryKey(t,h),f.addMetadata(t,u),f.end(t)}}class c{constructor(){this.bb=null,this.bb_pos=0}__init(t,e){return this.bb_pos=t,this.bb=e,this}static getRoot(t,e){return(e||new c).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRoot(t,e){return t.setPosition(t.position()+o.SIZE_PREFIX_LENGTH),(e||new c).__init(t.readInt32(t.position())+t.position(),t)}ends(t){var e=this.bb.__offset(this.bb_pos,4);return e?this.bb.readUint32(this.bb.__vector(this.bb_pos+e)+4*t):0}endsLength(){var t=this.bb.__offset(this.bb_pos,4);return t?this.bb.__vector_len(this.bb_pos+t):0}endsArray(){var t=this.bb.__offset(this.bb_pos,4);return t?new Uint32Array(this.bb.bytes().buffer,this.bb.bytes().byteOffset+this.bb.__vector(this.bb_pos+t),this.bb.__vector_len(this.bb_pos+t)):null}xy(t){var e=this.bb.__offset(this.bb_pos,6);return e?this.bb.readFloat64(this.bb.__vector(this.bb_pos+e)+8*t):0}xyLength(){var t=this.bb.__offset(this.bb_pos,6);return t?this.bb.__vector_len(this.bb_pos+t):0}xyArray(){var t=this.bb.__offset(this.bb_pos,6);return t?new Float64Array(this.bb.bytes().buffer,this.bb.bytes().byteOffset+this.bb.__vector(this.bb_pos+t),this.bb.__vector_len(this.bb_pos+t)):null}z(t){var e=this.bb.__offset(this.bb_pos,8);return e?this.bb.readFloat64(this.bb.__vector(this.bb_pos+e)+8*t):0}zLength(){var t=this.bb.__offset(this.bb_pos,8);return t?this.bb.__vector_len(this.bb_pos+t):0}zArray(){var t=this.bb.__offset(this.bb_pos,8);return t?new Float64Array(this.bb.bytes().buffer,this.bb.bytes().byteOffset+this.bb.__vector(this.bb_pos+t),this.bb.__vector_len(this.bb_pos+t)):null}m(t){var e=this.bb.__offset(this.bb_pos,10);return e?this.bb.readFloat64(this.bb.__vector(this.bb_pos+e)+8*t):0}mLength(){var t=this.bb.__offset(this.bb_pos,10);return t?this.bb.__vector_len(this.bb_pos+t):0}mArray(){var t=this.bb.__offset(this.bb_pos,10);return t?new Float64Array(this.bb.bytes().buffer,this.bb.bytes().byteOffset+this.bb.__vector(this.bb_pos+t),this.bb.__vector_len(this.bb_pos+t)):null}t(t){var e=this.bb.__offset(this.bb_pos,12);return e?this.bb.readFloat64(this.bb.__vector(this.bb_pos+e)+8*t):0}tLength(){var t=this.bb.__offset(this.bb_pos,12);return t?this.bb.__vector_len(this.bb_pos+t):0}tArray(){var t=this.bb.__offset(this.bb_pos,12);return t?new Float64Array(this.bb.bytes().buffer,this.bb.bytes().byteOffset+this.bb.__vector(this.bb_pos+t),this.bb.__vector_len(this.bb_pos+t)):null}tm(t){var e=this.bb.__offset(this.bb_pos,14);return e?this.bb.readUint64(this.bb.__vector(this.bb_pos+e)+8*t):this.bb.createLong(0,0)}tmLength(){var t=this.bb.__offset(this.bb_pos,14);return t?this.bb.__vector_len(this.bb_pos+t):0}type(){var t=this.bb.__offset(this.bb_pos,16);return t?this.bb.readUint8(this.bb_pos+t):s.Unknown}parts(t,e){var i=this.bb.__offset(this.bb_pos,18);return i?(e||new c).__init(this.bb.__indirect(this.bb.__vector(this.bb_pos+i)+4*t),this.bb):null}partsLength(){var t=this.bb.__offset(this.bb_pos,18);return t?this.bb.__vector_len(this.bb_pos+t):0}static start(t){t.startObject(8)}static addEnds(t,e){t.addFieldOffset(0,e,0)}static createEndsVector(t,e){t.startVector(4,e.length,4);for(var i=e.length-1;i>=0;i--)t.addInt32(e[i]);return t.endVector()}static startEndsVector(t,e){t.startVector(4,e,4)}static addXy(t,e){t.addFieldOffset(1,e,0)}static createXyVector(t,e){t.startVector(8,e.length,8);for(var i=e.length-1;i>=0;i--)t.addFloat64(e[i]);return t.endVector()}static startXyVector(t,e){t.startVector(8,e,8)}static addZ(t,e){t.addFieldOffset(2,e,0)}static createZVector(t,e){t.startVector(8,e.length,8);for(var i=e.length-1;i>=0;i--)t.addFloat64(e[i]);return t.endVector()}static startZVector(t,e){t.startVector(8,e,8)}static addM(t,e){t.addFieldOffset(3,e,0)}static createMVector(t,e){t.startVector(8,e.length,8);for(var i=e.length-1;i>=0;i--)t.addFloat64(e[i]);return t.endVector()}static startMVector(t,e){t.startVector(8,e,8)}static addT(t,e){t.addFieldOffset(4,e,0)}static createTVector(t,e){t.startVector(8,e.length,8);for(var i=e.length-1;i>=0;i--)t.addFloat64(e[i]);return t.endVector()}static startTVector(t,e){t.startVector(8,e,8)}static addTm(t,e){t.addFieldOffset(5,e,0)}static createTmVector(t,e){t.startVector(8,e.length,8);for(var i=e.length-1;i>=0;i--)t.addInt64(e[i]);return t.endVector()}static startTmVector(t,e){t.startVector(8,e,8)}static addType(t,e){t.addFieldInt8(6,e,s.Unknown)}static addParts(t,e){t.addFieldOffset(7,e,0)}static createPartsVector(t,e){t.startVector(4,e.length,4);for(var i=e.length-1;i>=0;i--)t.addOffset(e[i]);return t.endVector()}static startPartsVector(t,e){t.startVector(4,e,4)}static end(t){return t.endObject()}static create(t,e,i,r,s,n,o,a,b){return c.start(t),c.addEnds(t,e),c.addXy(t,i),c.addZ(t,r),c.addM(t,s),c.addT(t,n),c.addTm(t,o),c.addType(t,a),c.addParts(t,b),c.end(t)}}class l{constructor(){this.bb=null,this.bb_pos=0}__init(t,e){return this.bb_pos=t,this.bb=e,this}static getRoot(t,e){return(e||new l).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRoot(t,e){return t.setPosition(t.position()+o.SIZE_PREFIX_LENGTH),(e||new l).__init(t.readInt32(t.position())+t.position(),t)}geometry(t){var e=this.bb.__offset(this.bb_pos,4);return e?(t||new c).__init(this.bb.__indirect(this.bb_pos+e),this.bb):null}properties(t){var e=this.bb.__offset(this.bb_pos,6);return e?this.bb.readUint8(this.bb.__vector(this.bb_pos+e)+t):0}propertiesLength(){var t=this.bb.__offset(this.bb_pos,6);return t?this.bb.__vector_len(this.bb_pos+t):0}propertiesArray(){var t=this.bb.__offset(this.bb_pos,6);return t?new Uint8Array(this.bb.bytes().buffer,this.bb.bytes().byteOffset+this.bb.__vector(this.bb_pos+t),this.bb.__vector_len(this.bb_pos+t)):null}columns(t,e){var i=this.bb.__offset(this.bb_pos,8);return i?(e||new f).__init(this.bb.__indirect(this.bb.__vector(this.bb_pos+i)+4*t),this.bb):null}columnsLength(){var t=this.bb.__offset(this.bb_pos,8);return t?this.bb.__vector_len(this.bb_pos+t):0}static start(t){t.startObject(3)}static addGeometry(t,e){t.addFieldOffset(0,e,0)}static addProperties(t,e){t.addFieldOffset(1,e,0)}static createPropertiesVector(t,e){t.startVector(1,e.length,1);for(var i=e.length-1;i>=0;i--)t.addInt8(e[i]);return t.endVector()}static startPropertiesVector(t,e){t.startVector(1,e,1)}static addColumns(t,e){t.addFieldOffset(2,e,0)}static createColumnsVector(t,e){t.startVector(4,e.length,4);for(var i=e.length-1;i>=0;i--)t.addOffset(e[i]);return t.endVector()}static startColumnsVector(t,e){t.startVector(4,e,4)}static end(t){return t.endObject()}static finishBuffer(t,e){t.finish(e)}static finishSizePrefixedBuffer(t,e){t.finish(e,void 0,!0)}static create(t,e,i,r){return l.start(t),l.addGeometry(t,e),l.addProperties(t,i),l.addColumns(t,r),l.end(t)}}function _(t,e){const{xy:i,z:r,ends:s,parts:n,type:o}=e;if(n){const e=n.map(e=>_(t,e)),i=c.createPartsVector(t,e);return c.start(t),c.addParts(t,i),c.end(t)}const a=c.createXyVector(t,i);let b,d;return r&&(b=c.createZVector(t,r)),s&&(d=c.createEndsVector(t,s)),c.start(t),d&&c.addEnds(t,d),c.addXy(t,a),b&&c.addZ(t,b),c.addType(t,o),c.end(t)}function p(t,e,i){if(0!==t.length)if(Array.isArray(t[0]))for(const r of t)p(r,e,i);else 2===t.length?e.push(...t):(e.push(t[0],t[1]),i.push(t[2]))}function y(t,e){const i=[];for(let r=0;r<t.length;r+=2){const s=[t[r],t[r+1]];e&&s.push(e[r>>1]),i.push(s)}return i}function g(t){return t?i[t]:i.Unknown}function v(t){const e=t.coordinates,i=[],r=[];let s,n;const o=g(t.type);let a=0;switch(t.type){case"Point":p(e,i,r);break;case"MultiPoint":case"LineString":p(e,i,r);break;case"MultiLineString":case"Polygon":{const t=e;p(t,i,r),t.length>1&&(s=t.map(t=>a+=t.length));break}case"MultiPolygon":n=e.map(t=>({type:"Polygon",coordinates:t})).map(v);break;case"GeometryCollection":t.geometries&&(n=t.geometries.map(v))}return{xy:i,z:r.length>0?r:void 0,ends:s,type:o,parts:n}}function w(t,e){if(e===i.GeometryCollection){const r=[];for(let e=0;e<t.partsLength();e++){const i=t.parts(e),s=i.type();r.push(w(i,s))}return{type:i[e],geometries:r}}if(e===i.MultiPolygon){const r=[];for(let e=0;e<t.partsLength();e++)r.push(w(t.parts(e),i.Polygon));return{type:i[e],coordinates:r.map(t=>t.coordinates)}}const r=function(t,e){const r=t.xyArray(),s=t.zArray();switch(e){case i.Point:{const t=Array.from(r);return s&&t.push(s[0]),t}case i.MultiPoint:case i.LineString:return y(r,s);case i.MultiLineString:case i.Polygon:return function(t,e,i){if(!i||0===i.length)return[y(t,e)];let r=0;const s=Array.from(i).map(e=>t.slice(r,r=e<<1));let n;return e&&(r=0,n=Array.from(i).map(t=>e.slice(r,r=t))),s.map((t,e)=>y(t,n?n[e]:void 0))}(r,s,t.endsArray())}}(t,e);return{type:i[e],coordinates:r}}const I=new TextEncoder,B=new TextDecoder;function m(t,e,i){const s=i.columns,n=new o.Builder;let a=0,b=1024,d=new Uint8Array(b),h=new DataView(d.buffer);const u=function(t){if(a+t<b)return;b*=2;const e=new Uint8Array(b);e.set(d),d=e,h=new DataView(d.buffer,a)};if(s)for(let t=0;t<s.length;t++){const i=s[t],n=e[i.name];if(null!==n)switch(h.setUint16(a,t,!0),a+=2,i.type){case r.Bool:u(1),h.setUint8(a,n),a+=1;break;case r.Short:u(2),h.setInt16(a,n,!0),a+=2;break;case r.UShort:u(2),h.setUint16(a,n,!0),a+=2;break;case r.Int:u(4),h.setInt32(a,n,!0),a+=4;break;case r.UInt:u(4),h.setUint32(a,n,!0),a+=4;break;case r.Long:u(8),h.setBigInt64(a,BigInt(n),!0),a+=8;break;case r.Double:u(8),h.setFloat64(a,n,!0),a+=8;break;case r.DateTime:case r.String:{const t=I.encode(n);u(4),h.setUint32(a,t.length,!0),a+=4,u(t.length),d.set(t,a),a+=t.length;break}default:throw new Error("Unknown type "+i.type)}}let f=null;a>0&&(f=l.createPropertiesVector(n,d.slice(0,a)));const c=_(n,t);l.start(n),l.addGeometry(n,c),f&&l.addProperties(n,f);const p=l.end(n);return n.finishSizePrefixed(p),n.asUint8Array()}function F(t,e){const i=e.columns,s={type:"Feature",geometry:w(t.geometry(),e.geometryType)};return i&&i.length>0&&(s.properties=function(t,e){const i={};if(!e||0===e.length)return i;const s=t.propertiesArray();if(!s)return i;const n=new DataView(s.buffer,s.byteOffset),o=t.propertiesLength();let a=0;for(;a<o;){const t=n.getUint16(a,!0);a+=2;const o=e[t],b=o.name;switch(o.type){case r.Bool:i[b]=!!n.getUint8(a),a+=1;break;case r.Byte:i[b]=n.getInt8(a),a+=1;break;case r.UByte:i[b]=n.getUint8(a),a+=1;break;case r.Short:i[b]=n.getInt16(a,!0),a+=2;break;case r.UShort:i[b]=n.getUint16(a,!0),a+=2;break;case r.Int:i[b]=n.getInt32(a,!0),a+=4;break;case r.UInt:i[b]=n.getUint32(a,!0),a+=4;break;case r.Long:i[b]=Number(n.getBigInt64(a,!0)),a+=8;break;case r.ULong:i[b]=Number(n.getBigUint64(a,!0)),a+=8;break;case r.Double:i[b]=n.getFloat64(a,!0),a+=8;break;case r.DateTime:case r.String:{const t=n.getUint32(a,!0);a+=4,i[b]=B.decode(s.subarray(a,a+t)),a+=t;break}default:throw new Error("Unknown type "+o.type)}}return i}(t,i)),s}var E,S=new Uint8Array(0);function U(t,e){if(!t.length)return e;if(!e.length)return t;var i=new Uint8Array(t.length+e.length);return i.set(t),i.set(e,t.length),i}function T(t){this._source=t,this._array=S,this._index=0}T.prototype.read=function(){var t=this,e=t._array.subarray(t._index);return t._source.read().then((function(i){return t._array=S,t._index=0,i.done?e.length>0?{done:!1,value:e}:{done:!0,value:void 0}:{done:!1,value:U(e,i.value)}}))},T.prototype.slice=function(t){if((t|=0)<0)throw new Error("invalid length");var e=this,i=this._array.length-this._index;if(this._index+t<=this._array.length)return Promise.resolve(this._array.subarray(this._index,this._index+=t));var r=new Uint8Array(t);return r.set(this._array.subarray(this._index)),function s(){return e._source.read().then((function(n){return n.done?(e._array=S,e._index=0,i>0?r.subarray(0,i):null):i+n.value.length>=t?(e._array=n.value,e._index=t-i,r.set(n.value.subarray(0,t-i),i),r):(r.set(n.value,i),i+=n.value.length,s())}))}()},T.prototype.cancel=function(){return this._source.cancel()},function(t){t[t.Debug=0]="Debug",t[t.Info=1]="Info",t[t.Warn=2]="Warn",t[t.Error=3]="Error"}(E||(E={}));class L{static debug(...t){this.log(E.Debug,...t)}static info(...t){this.log(E.Info,...t)}static warn(...t){this.log(E.Warn,...t)}static error(...t){this.log(E.Error,...t)}static log(t,...e){if(!(this.logLevel>t))switch(t){case E.Debug:console.debug(...e);break;case E.Info:console.info(...e);break;case E.Warn:console.warn(...e);break;case E.Error:console.error(...e)}}}function O(t,e){e=Math.min(Math.max(+e,2),65535);let i=t,r=i;do{i=Math.ceil(i/e),r+=i}while(1!==i);return 40*r}function N(t,e){if(0!=(4293918720&t))throw Error("integer is too large to be safely represented");return e+t*2**32}L.logLevel=E.Info;const P=new Uint8Array([102,103,98,3,102,103,98,0]);class C{constructor(t,e,i,r){this.headerClient=t,this.header=e,this.headerLength=i,this.indexLength=r}static async open(t){let e=new x(t);const i=(()=>{let t,e=0;for(t=0;t<3;t++)e+=16**t*40;return e})(),r=2024+i;L.debug(`fetching header. minReqLength: ${r} (assumedHeaderLength: 2024, assumedIndexLength: ${i})`);{let t=new Uint8Array(await e.getRange(0,8,r,"header"));if(!t.every((t,e)=>P[e]===t))throw L.error(`bytes: ${t} != ${P}`),new Error("Not a FlatGeobuf file");L.debug("magic bytes look good")}let s;{let t=await e.getRange(8,4,r,"header");if(s=new DataView(t).getUint32(0,!0),s>10485760||s<8)throw new Error("Invalid header size");L.debug("headerLength: "+s)}const n=await e.getRange(12,s,r,"header"),a=new o.ByteBuffer(new Uint8Array(n)),b=u.fromByteBuffer(a),d=O(b.featuresCount,b.indexNodeSize);return L.debug("completed: opening http reader"),new C(e,b,s,d)}async*selectBbox(t){const e=this.lengthBeforeTree();let i=this.headerClient;L.debug("starting: selectBbox, traversing index. lengthBeforeTree: "+e),yield*async function*(t,e,i,r){class s{constructor(t,e){this._level=e,this.nodes=t}level(){return this._level}startNode(){return this.nodes[0]}endNode(){return this.nodes[1]}extendEndNodeToNewOffset(t){console.assert(t>this.nodes[1]),this.nodes[1]=t}toString(){return`[NodeRange level: ${this._level}, nodes: ${this.nodes[0]}-${this.nodes[1]}]`}}const{minX:n,minY:o,maxX:a,maxY:b}=i,d=function(t,e){if(e<2)throw new Error("Node size must be at least 2");if(0===t)throw new Error("Number of items must be greater than 0");let i=t,r=i;const s=[i];do{i=Math.ceil(i/e),r+=i,s.push(i)}while(1!==i);const n=[];i=r;for(const t of s)n.push(i-t),i-=t;n.reverse(),s.reverse();const o=[];for(let t=0;t<s.length;t++)o.push([n[t],n[t]+s[t]]);return o.reverse(),o}(t,e),h=d[0][0],u=[(()=>{const t=d.length-1;return new s([0,1],t)})()];for(L.debug(`starting stream search with queue: ${u}, numItems: ${t}, nodeSize: ${e}, levelBounds: ${d}`);0!=u.length;){const t=u.shift();L.debug(`popped node: ${t}, queueLength: ${u.length}`);let i=t.startNode();const f=i>=h,[,c]=d[t.level()],l=Math.min(t.endNode()+e,c),_=l-i,p=await r(40*i,40*_),y=new Float64Array(p),g=new Uint32Array(p);for(let e=i;e<l;e++){const r=5*(e-i);if(a<y[r+0])continue;if(b<y[r+1])continue;if(n>y[r+2])continue;if(o>y[r+3])continue;const d=g[8+(r<<1)],c=N(g[9+(r<<1)],d);if(f){L.debug("yielding feature"),yield[c,e-h];continue}const l=6553.6,_=u[u.length-1];if(void 0!==_&&_.level()==t.level()-1&&c<_.endNode()+l){L.debug(`Extending existing node: ${_}, newOffset: ${_.endNode()} -> ${c}`),_.extendEndNodeToNewOffset(c);continue}let p=(()=>{let e=t.level()-1;return new s([c,c+1],e)})();void 0!==_&&_.level()==t.level()-1?L.debug(`pushing new node at offset: ${c} rather than merging with distant ${_}`):L.debug(`pushing new level for ${p} onto queue with tail: ${_}`),u.push(p)}}}(this.header.featuresCount,this.header.indexNodeSize,t,(async function(t,r){return i.getRange(e+t,r,0,"index")}))}lengthBeforeTree(){return P.length+4+this.headerLength}lengthBeforeFeatures(){return this.lengthBeforeTree()+this.indexLength}featureClient(){return void 0===this._featureClient&&(this._featureClient=this.headerClient.clone()),this._featureClient}async readFeature(t){const e=131072;let i,r=t+this.lengthBeforeFeatures();{const t=await this.featureClient().getRange(r,4,e,"feature length");i=new DataView(t).getUint32(0,!0)}L.debug(`featureOffset: ${r}, featureLength: ${i}`);let s=await this.featureClient().getRange(r+4,i,e,"feature data"),n=new Uint8Array(s);const a=new Uint8Array(i+4);a.set(n,4);const b=new o.ByteBuffer(a);return b.setPosition(4),l.getRoot(b)}}class x{constructor(t){this.buffer=new ArrayBuffer(0),this.head=0,this.httpClient="string"==typeof t?new V(t):t}clone(){let t=new x(this.httpClient);return t.buffer=this.buffer.slice(0),t.head=this.head,t}async getRange(t,e,i,r){L.debug(`need Range: ${t}-${t+e-1}`);const s=t-this.head,n=s+e;if(s>=0&&n<this.buffer.byteLength)return L.debug(`slicing existing Range: ${s}-${n-1}`),this.buffer.slice(s,n);let o=Math.max(e,i);return this.buffer=await this.httpClient.getRange(t,o,r),this.head=t,this.buffer.slice(0,e)}}class V{constructor(t){this.requestsEverMade=0,this.bytesEverRequested=0,this.url=t}async getRange(t,e,i){this.requestsEverMade+=1,this.bytesEverRequested+=e;let r=`bytes=${t}-${t+e-1}`;return L.debug(`request: #${this.requestsEverMade}, purpose: ${i}), bytes: (this_request: ${e}, ever: ${this.bytesEverRequested}), Range: ${r}`),(await fetch(this.url,{headers:{Range:r}})).arrayBuffer()}}async function R(t,e,i){let r=new Uint8Array(await t(4,"feature length"));if(0===r.byteLength)return;let s=new o.ByteBuffer(r);const n=s.readUint32(0);r=new Uint8Array(await t(n,"feature data"));const a=new Uint8Array(n+4);return a.set(r,4),s=new o.ByteBuffer(a),s.setPosition(4),i(l.getRoot(s),e)}function A(t){const e=new o.Builder;let i=null;t.columns&&(i=d.createColumnsVector(e,t.columns.map(t=>function(t,e){const i=t.createString(e.name);return a.start(t),a.addName(t,i),a.addType(t,e.type),a.end(t)}(e,t))));const r=e.createString("L1");d.start(e),d.addFeaturesCount(e,new o.Long(t.featuresCount,0)),d.addGeometryType(e,t.geometryType),d.addIndexNodeSize(e,0),i&&d.addColumns(e,i),d.addName(e,r);const s=d.end(e);return e.finishSizePrefixed(s),e.asUint8Array()}t.deserialize=function(t,e,i){return t instanceof Uint8Array?function(t,e){return{type:"FeatureCollection",features:function(t,e,i){if(!t.subarray(0,7).every((t,e)=>P[e]===t))throw new Error("Not a FlatGeobuf file");const r=new o.ByteBuffer(t),s=r.readUint32(P.length);r.setPosition(P.length+4);const n=u.fromByteBuffer(r);i&&i(n);let a=P.length+4+s;const{indexNodeSize:b,featuresCount:d}=n;b>0&&(a+=O(d,b));const h=[];for(;a<r.capacity();){const t=r.readUint32(a);r.setPosition(a+4);const i=l.getRoot(r);h.push(e(i,n)),a+=4+t}return h}(t,F,e)}}(t,i):t instanceof ReadableStream?function(t,e){return async function*(t,e,i){const r="function"==typeof(s=t).slice?s:new T("function"==typeof s.read?s:s.getReader());var s;const n=async t=>await r.slice(t);let a=new Uint8Array(await n(8));if(!a.every((t,e)=>P[e]===t))throw new Error("Not a FlatGeobuf file");a=new Uint8Array(await n(4));let b=new o.ByteBuffer(a);const d=b.readUint32(0);a=new Uint8Array(await n(d)),b=new o.ByteBuffer(a);const h=u.fromByteBuffer(b);i&&i(h);const{indexNodeSize:f,featuresCount:c}=h;if(f>0){const t=O(c,f);await n(t)}let l;for(;l=await R(n,h,e);)yield l}(t,F,e)}(t,i):function(t,e,i){return async function*(t,e,i,r){const s=await C.open(t);L.debug("opened reader"),r&&r(s.header);for await(let t of s.selectBbox(e)){let e=await s.readFeature(t[0]);yield i(e,s.header)}}(t,e,F,i)}(t,e,i)},t.serialize=function(t){return function(t){const i=function(t){const i=t.features[0],s=i.properties;let n=null;return s&&(n=Object.keys(s).map(t=>new e(t,function(t){if("boolean"==typeof t)return r.Bool;if("number"==typeof t)return t%1==0?r.Int:r.Double;if("string"==typeof t)return r.String;if(null===t)return r.String;throw new Error(`Unknown type (value '${t}')`)}(s[t]),null,null,-1,-1,-1,!0,!1,!1))),new u(g(i.geometry.type),n,t.features.length,0,null,null,null,null)}(t),s=A(i),n=t.features.map(t=>m(v(t.geometry),t.properties,i)),o=n.map(t=>t.length).reduce((t,e)=>t+e),a=new Uint8Array(P.length+s.length+o);a.set(s,P.length);let b=P.length+s.length;for(const t of n)a.set(t,b),b+=t.length;return a.set(P),a}(t)},Object.defineProperty(t,"__esModule",{value:!0})}(e)},function(t,e,i){(function(e){const r=i(3),s="undefined"==typeof window?e:window;s.loaders=s.loaders||{},t.exports=Object.assign(s.loaders,r)}).call(this,i(2))},function(t,e){var i;i=function(){return this}();try{i=i||new Function("return this")()}catch(t){"object"==typeof window&&(i=window)}t.exports=i},function(t,e,i){"use strict";i.r(e),i.d(e,"FlatGeobufLoader",(function(){return n}));var r=i(0);function s(t,e){if(0===t.byteLength)return[];const i=new Uint8Array(t),{features:s}=Object(r.deserialize)(i);return s}const n={...{id:"flatgeobuf",name:"FlatGeobuf",module:"flatgeobuf",version:"3.0.0-alpha.21",worker:!0,extensions:["fgb"],category:"geometry",options:{flatgeobuf:{}}},parse:async(t,e)=>s(t),parseSync:s,parseInBatchesFromStream:function(t,e){return Object(r.deserializeStream)(t)},binary:!0}}])}));
!function(t,e){if("object"==typeof exports&&"object"==typeof module)module.exports=e();else if("function"==typeof define&&define.amd)define([],e);else{var s=e();for(var i in s)("object"==typeof exports?exports:t)[i]=s[i]}}(window,(function(){return function(t){var e={};function s(i){if(e[i])return e[i].exports;var r=e[i]={i:i,l:!1,exports:{}};return t[i].call(r.exports,r,r.exports,s),r.l=!0,r.exports}return s.m=t,s.c=e,s.d=function(t,e,i){s.o(t,e)||Object.defineProperty(t,e,{enumerable:!0,get:i})},s.r=function(t){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})},s.t=function(t,e){if(1&e&&(t=s(t)),8&e)return t;if(4&e&&"object"==typeof t&&t&&t.__esModule)return t;var i=Object.create(null);if(s.r(i),Object.defineProperty(i,"default",{enumerable:!0,value:t}),2&e&&"string"!=typeof t)for(var r in t)s.d(i,r,function(e){return t[e]}.bind(null,r));return i},s.n=function(t){var e=t&&t.__esModule?function(){return t.default}:function(){return t};return s.d(e,"a",e),e},s.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},s.p="",s(s.s=1)}([function(t,e,s){!function(t){"use strict";class e{constructor(t,e,s,i,r,n,o,a,b,h){this.name=t,this.type=e,this.title=s,this.description=i,this.width=r,this.precision=n,this.scale=o,this.nullable=a,this.unique=b,this.primary_key=h}}var s;!function(t){t[t.Byte=0]="Byte",t[t.UByte=1]="UByte",t[t.Bool=2]="Bool",t[t.Short=3]="Short",t[t.UShort=4]="UShort",t[t.Int=5]="Int",t[t.UInt=6]="UInt",t[t.Long=7]="Long",t[t.ULong=8]="ULong",t[t.Float=9]="Float",t[t.Double=10]="Double",t[t.String=11]="String",t[t.Json=12]="Json",t[t.DateTime=13]="DateTime",t[t.Binary=14]="Binary"}(s||(s={}));class i{constructor(t,e,s,i,r,n){this.org=t,this.code=e,this.name=s,this.description=i,this.wkt=r,this.code_string=n}}const r=new Int32Array(2),n=new Float32Array(r.buffer),o=new Float64Array(r.buffer),a=1===new Uint16Array(new Uint8Array([1,0]).buffer)[0];class b{constructor(t,e){this.low=0|t,this.high=0|e}static create(t,e){return 0==t&&0==e?b.ZERO:new b(t,e)}toFloat64(){return(this.low>>>0)+4294967296*this.high}equals(t){return this.low==t.low&&this.high==t.high}}var h,c;b.ZERO=new b(0,0),function(t){t[t.UTF8_BYTES=1]="UTF8_BYTES",t[t.UTF16_STRING=2]="UTF16_STRING"}(h||(h={}));class d{constructor(t){this.bytes_=t,this.position_=0}static allocate(t){return new d(new Uint8Array(t))}clear(){this.position_=0}bytes(){return this.bytes_}position(){return this.position_}setPosition(t){this.position_=t}capacity(){return this.bytes_.length}readInt8(t){return this.readUint8(t)<<24>>24}readUint8(t){return this.bytes_[t]}readInt16(t){return this.readUint16(t)<<16>>16}readUint16(t){return this.bytes_[t]|this.bytes_[t+1]<<8}readInt32(t){return this.bytes_[t]|this.bytes_[t+1]<<8|this.bytes_[t+2]<<16|this.bytes_[t+3]<<24}readUint32(t){return this.readInt32(t)>>>0}readInt64(t){return new b(this.readInt32(t),this.readInt32(t+4))}readUint64(t){return new b(this.readUint32(t),this.readUint32(t+4))}readFloat32(t){return r[0]=this.readInt32(t),n[0]}readFloat64(t){return r[a?0:1]=this.readInt32(t),r[a?1:0]=this.readInt32(t+4),o[0]}writeInt8(t,e){this.bytes_[t]=e}writeUint8(t,e){this.bytes_[t]=e}writeInt16(t,e){this.bytes_[t]=e,this.bytes_[t+1]=e>>8}writeUint16(t,e){this.bytes_[t]=e,this.bytes_[t+1]=e>>8}writeInt32(t,e){this.bytes_[t]=e,this.bytes_[t+1]=e>>8,this.bytes_[t+2]=e>>16,this.bytes_[t+3]=e>>24}writeUint32(t,e){this.bytes_[t]=e,this.bytes_[t+1]=e>>8,this.bytes_[t+2]=e>>16,this.bytes_[t+3]=e>>24}writeInt64(t,e){this.writeInt32(t,e.low),this.writeInt32(t+4,e.high)}writeUint64(t,e){this.writeUint32(t,e.low),this.writeUint32(t+4,e.high)}writeFloat32(t,e){n[0]=e,this.writeInt32(t,r[0])}writeFloat64(t,e){o[0]=e,this.writeInt32(t,r[a?0:1]),this.writeInt32(t+4,r[a?1:0])}getBufferIdentifier(){if(this.bytes_.length<this.position_+4+4)throw new Error("FlatBuffers: ByteBuffer is too short to contain an identifier.");let t="";for(let e=0;e<4;e++)t+=String.fromCharCode(this.readInt8(this.position_+4+e));return t}__offset(t,e){const s=t-this.readInt32(t);return e<this.readInt16(s)?this.readInt16(s+e):0}__union(t,e){return t.bb_pos=e+this.readInt32(e),t.bb=this,t}__string(t,e){t+=this.readInt32(t);const s=this.readInt32(t);let i="",r=0;if(t+=4,e===h.UTF8_BYTES)return this.bytes_.subarray(t,t+s);for(;r<s;){let e;const s=this.readUint8(t+r++);if(s<192)e=s;else{const i=this.readUint8(t+r++);if(s<224)e=(31&s)<<6|63&i;else{const n=this.readUint8(t+r++);e=s<240?(15&s)<<12|(63&i)<<6|63&n:(7&s)<<18|(63&i)<<12|(63&n)<<6|63&this.readUint8(t+r++)}}e<65536?i+=String.fromCharCode(e):(e-=65536,i+=String.fromCharCode(55296+(e>>10),56320+(1023&e)))}return i}__union_with_string(t,e){return"string"==typeof t?this.__string(e):this.__union(t,e)}__indirect(t){return t+this.readInt32(t)}__vector(t){return t+this.readInt32(t)+4}__vector_len(t){return this.readInt32(t+this.readInt32(t))}__has_identifier(t){if(4!=t.length)throw new Error("FlatBuffers: file identifier must be length 4");for(let e=0;e<4;e++)if(t.charCodeAt(e)!=this.readInt8(this.position()+4+e))return!1;return!0}createLong(t,e){return b.create(t,e)}createScalarList(t,e){const s=[];for(let i=0;i<e;++i)null!==t(i)&&s.push(t(i));return s}createObjList(t,e){const s=[];for(let i=0;i<e;++i){const e=t(i);null!==e&&s.push(e.unpack())}return s}}class l{constructor(t){let e;this.minalign=1,this.vtable=null,this.vtable_in_use=0,this.isNested=!1,this.object_start=0,this.vtables=[],this.vector_num_elems=0,this.force_defaults=!1,this.string_maps=null,e=t||1024,this.bb=d.allocate(e),this.space=e}clear(){this.bb.clear(),this.space=this.bb.capacity(),this.minalign=1,this.vtable=null,this.vtable_in_use=0,this.isNested=!1,this.object_start=0,this.vtables=[],this.vector_num_elems=0,this.force_defaults=!1,this.string_maps=null}forceDefaults(t){this.force_defaults=t}dataBuffer(){return this.bb}asUint8Array(){return this.bb.bytes().subarray(this.bb.position(),this.bb.position()+this.offset())}prep(t,e){t>this.minalign&&(this.minalign=t);const s=1+~(this.bb.capacity()-this.space+e)&t-1;for(;this.space<s+t+e;){const t=this.bb.capacity();this.bb=l.growByteBuffer(this.bb),this.space+=this.bb.capacity()-t}this.pad(s)}pad(t){for(let e=0;e<t;e++)this.bb.writeInt8(--this.space,0)}writeInt8(t){this.bb.writeInt8(this.space-=1,t)}writeInt16(t){this.bb.writeInt16(this.space-=2,t)}writeInt32(t){this.bb.writeInt32(this.space-=4,t)}writeInt64(t){this.bb.writeInt64(this.space-=8,t)}writeFloat32(t){this.bb.writeFloat32(this.space-=4,t)}writeFloat64(t){this.bb.writeFloat64(this.space-=8,t)}addInt8(t){this.prep(1,0),this.writeInt8(t)}addInt16(t){this.prep(2,0),this.writeInt16(t)}addInt32(t){this.prep(4,0),this.writeInt32(t)}addInt64(t){this.prep(8,0),this.writeInt64(t)}addFloat32(t){this.prep(4,0),this.writeFloat32(t)}addFloat64(t){this.prep(8,0),this.writeFloat64(t)}addFieldInt8(t,e,s){(this.force_defaults||e!=s)&&(this.addInt8(e),this.slot(t))}addFieldInt16(t,e,s){(this.force_defaults||e!=s)&&(this.addInt16(e),this.slot(t))}addFieldInt32(t,e,s){(this.force_defaults||e!=s)&&(this.addInt32(e),this.slot(t))}addFieldInt64(t,e,s){!this.force_defaults&&e.equals(s)||(this.addInt64(e),this.slot(t))}addFieldFloat32(t,e,s){(this.force_defaults||e!=s)&&(this.addFloat32(e),this.slot(t))}addFieldFloat64(t,e,s){(this.force_defaults||e!=s)&&(this.addFloat64(e),this.slot(t))}addFieldOffset(t,e,s){(this.force_defaults||e!=s)&&(this.addOffset(e),this.slot(t))}addFieldStruct(t,e,s){e!=s&&(this.nested(e),this.slot(t))}nested(t){if(t!=this.offset())throw new Error("FlatBuffers: struct must be serialized inline.")}notNested(){if(this.isNested)throw new Error("FlatBuffers: object serialization must not be nested.")}slot(t){null!==this.vtable&&(this.vtable[t]=this.offset())}offset(){return this.bb.capacity()-this.space}static growByteBuffer(t){const e=t.capacity();if(3221225472&e)throw new Error("FlatBuffers: cannot grow buffer beyond 2 gigabytes.");const s=e<<1,i=d.allocate(s);return i.setPosition(s-e),i.bytes().set(t.bytes(),s-e),i}addOffset(t){this.prep(4,0),this.writeInt32(this.offset()-t+4)}startObject(t){this.notNested(),null==this.vtable&&(this.vtable=[]),this.vtable_in_use=t;for(let e=0;e<t;e++)this.vtable[e]=0;this.isNested=!0,this.object_start=this.offset()}endObject(){if(null==this.vtable||!this.isNested)throw new Error("FlatBuffers: endObject called without startObject");this.addInt32(0);const t=this.offset();let e=this.vtable_in_use-1;for(;e>=0&&0==this.vtable[e];e--);const s=e+1;for(;e>=0;e--)this.addInt16(0!=this.vtable[e]?t-this.vtable[e]:0);this.addInt16(t-this.object_start);const i=2*(s+2);this.addInt16(i);let r=0;const n=this.space;t:for(e=0;e<this.vtables.length;e++){const t=this.bb.capacity()-this.vtables[e];if(i==this.bb.readInt16(t)){for(let e=2;e<i;e+=2)if(this.bb.readInt16(n+e)!=this.bb.readInt16(t+e))continue t;r=this.vtables[e];break}}return r?(this.space=this.bb.capacity()-t,this.bb.writeInt32(this.space,r-t)):(this.vtables.push(this.offset()),this.bb.writeInt32(this.bb.capacity()-t,this.offset()-t)),this.isNested=!1,t}finish(t,e,s){const i=s?4:0;if(e){const t=e;if(this.prep(this.minalign,8+i),4!=t.length)throw new Error("FlatBuffers: file identifier must be length 4");for(let e=3;e>=0;e--)this.writeInt8(t.charCodeAt(e))}this.prep(this.minalign,4+i),this.addOffset(t),i&&this.addInt32(this.bb.capacity()-this.space),this.bb.setPosition(this.space)}finishSizePrefixed(t,e){this.finish(t,e,!0)}requiredField(t,e){const s=this.bb.capacity()-t,i=s-this.bb.readInt32(s);if(0==this.bb.readInt16(i+e))throw new Error("FlatBuffers: field "+e+" must be set")}startVector(t,e,s){this.notNested(),this.vector_num_elems=e,this.prep(4,t*e),this.prep(s,t*e)}endVector(){return this.writeInt32(this.vector_num_elems),this.offset()}createSharedString(t){if(!t)return 0;if(this.string_maps||(this.string_maps=new Map),this.string_maps.has(t))return this.string_maps.get(t);const e=this.createString(t);return this.string_maps.set(t,e),e}createString(t){if(!t)return 0;let e;if(t instanceof Uint8Array)e=t;else{e=[];let s=0;for(;s<t.length;){let i;const r=t.charCodeAt(s++);i=r<55296||r>=56320?r:(r<<10)+t.charCodeAt(s++)+-56613888,i<128?e.push(i):(i<2048?e.push(i>>6&31|192):(i<65536?e.push(i>>12&15|224):e.push(i>>18&7|240,i>>12&63|128),e.push(i>>6&63|128)),e.push(63&i|128))}}this.addInt8(0),this.startVector(1,e.length,1),this.bb.setPosition(this.space-=e.length);for(let t=0,s=this.space,i=this.bb.bytes();t<e.length;t++)i[s++]=e[t];return this.endVector()}createLong(t,e){return b.create(t,e)}createObjectOffset(t){return null===t?0:"string"==typeof t?this.createString(t):t.pack(this)}createObjectOffsetList(t){const e=[];for(let s=0;s<t.length;++s){const i=t[s];if(null===i)throw new Error("FlatBuffers: Argument for createObjectOffsetList cannot contain null.");e.push(this.createObjectOffset(i))}return e}createStructOffsetList(t,e){return e(this,t.length),this.createObjectOffsetList(t),this.endVector()}}class u{constructor(){this.bb=null,this.bb_pos=0}__init(t,e){return this.bb_pos=t,this.bb=e,this}static getRootAsColumn(t,e){return(e||new u).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsColumn(t,e){return t.setPosition(t.position()+4),(e||new u).__init(t.readInt32(t.position())+t.position(),t)}name(t){const e=this.bb.__offset(this.bb_pos,4);return e?this.bb.__string(this.bb_pos+e,t):null}type(){const t=this.bb.__offset(this.bb_pos,6);return t?this.bb.readUint8(this.bb_pos+t):s.Byte}title(t){const e=this.bb.__offset(this.bb_pos,8);return e?this.bb.__string(this.bb_pos+e,t):null}description(t){const e=this.bb.__offset(this.bb_pos,10);return e?this.bb.__string(this.bb_pos+e,t):null}width(){const t=this.bb.__offset(this.bb_pos,12);return t?this.bb.readInt32(this.bb_pos+t):-1}precision(){const t=this.bb.__offset(this.bb_pos,14);return t?this.bb.readInt32(this.bb_pos+t):-1}scale(){const t=this.bb.__offset(this.bb_pos,16);return t?this.bb.readInt32(this.bb_pos+t):-1}nullable(){const t=this.bb.__offset(this.bb_pos,18);return!t||!!this.bb.readInt8(this.bb_pos+t)}unique(){const t=this.bb.__offset(this.bb_pos,20);return!!t&&!!this.bb.readInt8(this.bb_pos+t)}primaryKey(){const t=this.bb.__offset(this.bb_pos,22);return!!t&&!!this.bb.readInt8(this.bb_pos+t)}metadata(t){const e=this.bb.__offset(this.bb_pos,24);return e?this.bb.__string(this.bb_pos+e,t):null}static startColumn(t){t.startObject(11)}static addName(t,e){t.addFieldOffset(0,e,0)}static addType(t,e){t.addFieldInt8(1,e,s.Byte)}static addTitle(t,e){t.addFieldOffset(2,e,0)}static addDescription(t,e){t.addFieldOffset(3,e,0)}static addWidth(t,e){t.addFieldInt32(4,e,-1)}static addPrecision(t,e){t.addFieldInt32(5,e,-1)}static addScale(t,e){t.addFieldInt32(6,e,-1)}static addNullable(t,e){t.addFieldInt8(7,+e,1)}static addUnique(t,e){t.addFieldInt8(8,+e,0)}static addPrimaryKey(t,e){t.addFieldInt8(9,+e,0)}static addMetadata(t,e){t.addFieldOffset(10,e,0)}static endColumn(t){const e=t.endObject();return t.requiredField(e,4),e}static createColumn(t,e,s,i,r,n,o,a,b,h,c,d){return u.startColumn(t),u.addName(t,e),u.addType(t,s),u.addTitle(t,i),u.addDescription(t,r),u.addWidth(t,n),u.addPrecision(t,o),u.addScale(t,a),u.addNullable(t,b),u.addUnique(t,h),u.addPrimaryKey(t,c),u.addMetadata(t,d),u.endColumn(t)}}class f{constructor(){this.bb=null,this.bb_pos=0}__init(t,e){return this.bb_pos=t,this.bb=e,this}static getRootAsCrs(t,e){return(e||new f).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsCrs(t,e){return t.setPosition(t.position()+4),(e||new f).__init(t.readInt32(t.position())+t.position(),t)}org(t){const e=this.bb.__offset(this.bb_pos,4);return e?this.bb.__string(this.bb_pos+e,t):null}code(){const t=this.bb.__offset(this.bb_pos,6);return t?this.bb.readInt32(this.bb_pos+t):0}name(t){const e=this.bb.__offset(this.bb_pos,8);return e?this.bb.__string(this.bb_pos+e,t):null}description(t){const e=this.bb.__offset(this.bb_pos,10);return e?this.bb.__string(this.bb_pos+e,t):null}wkt(t){const e=this.bb.__offset(this.bb_pos,12);return e?this.bb.__string(this.bb_pos+e,t):null}codeString(t){const e=this.bb.__offset(this.bb_pos,14);return e?this.bb.__string(this.bb_pos+e,t):null}static startCrs(t){t.startObject(6)}static addOrg(t,e){t.addFieldOffset(0,e,0)}static addCode(t,e){t.addFieldInt32(1,e,0)}static addName(t,e){t.addFieldOffset(2,e,0)}static addDescription(t,e){t.addFieldOffset(3,e,0)}static addWkt(t,e){t.addFieldOffset(4,e,0)}static addCodeString(t,e){t.addFieldOffset(5,e,0)}static endCrs(t){return t.endObject()}static createCrs(t,e,s,i,r,n,o){return f.startCrs(t),f.addOrg(t,e),f.addCode(t,s),f.addName(t,i),f.addDescription(t,r),f.addWkt(t,n),f.addCodeString(t,o),f.endCrs(t)}}!function(t){t[t.Unknown=0]="Unknown",t[t.Point=1]="Point",t[t.LineString=2]="LineString",t[t.Polygon=3]="Polygon",t[t.MultiPoint=4]="MultiPoint",t[t.MultiLineString=5]="MultiLineString",t[t.MultiPolygon=6]="MultiPolygon",t[t.GeometryCollection=7]="GeometryCollection",t[t.CircularString=8]="CircularString",t[t.CompoundCurve=9]="CompoundCurve",t[t.CurvePolygon=10]="CurvePolygon",t[t.MultiCurve=11]="MultiCurve",t[t.MultiSurface=12]="MultiSurface",t[t.Curve=13]="Curve",t[t.Surface=14]="Surface",t[t.PolyhedralSurface=15]="PolyhedralSurface",t[t.TIN=16]="TIN",t[t.Triangle=17]="Triangle"}(c||(c={}));class _{constructor(){this.bb=null,this.bb_pos=0}__init(t,e){return this.bb_pos=t,this.bb=e,this}static getRootAsHeader(t,e){return(e||new _).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsHeader(t,e){return t.setPosition(t.position()+4),(e||new _).__init(t.readInt32(t.position())+t.position(),t)}name(t){const e=this.bb.__offset(this.bb_pos,4);return e?this.bb.__string(this.bb_pos+e,t):null}envelope(t){const e=this.bb.__offset(this.bb_pos,6);return e?this.bb.readFloat64(this.bb.__vector(this.bb_pos+e)+8*t):0}envelopeLength(){const t=this.bb.__offset(this.bb_pos,6);return t?this.bb.__vector_len(this.bb_pos+t):0}envelopeArray(){const t=this.bb.__offset(this.bb_pos,6);return t?new Float64Array(this.bb.bytes().buffer,this.bb.bytes().byteOffset+this.bb.__vector(this.bb_pos+t),this.bb.__vector_len(this.bb_pos+t)):null}geometryType(){const t=this.bb.__offset(this.bb_pos,8);return t?this.bb.readUint8(this.bb_pos+t):c.Unknown}hasZ(){const t=this.bb.__offset(this.bb_pos,10);return!!t&&!!this.bb.readInt8(this.bb_pos+t)}hasM(){const t=this.bb.__offset(this.bb_pos,12);return!!t&&!!this.bb.readInt8(this.bb_pos+t)}hasT(){const t=this.bb.__offset(this.bb_pos,14);return!!t&&!!this.bb.readInt8(this.bb_pos+t)}hasTm(){const t=this.bb.__offset(this.bb_pos,16);return!!t&&!!this.bb.readInt8(this.bb_pos+t)}columns(t,e){const s=this.bb.__offset(this.bb_pos,18);return s?(e||new u).__init(this.bb.__indirect(this.bb.__vector(this.bb_pos+s)+4*t),this.bb):null}columnsLength(){const t=this.bb.__offset(this.bb_pos,18);return t?this.bb.__vector_len(this.bb_pos+t):0}featuresCount(){const t=this.bb.__offset(this.bb_pos,20);return t?this.bb.readUint64(this.bb_pos+t):this.bb.createLong(0,0)}indexNodeSize(){const t=this.bb.__offset(this.bb_pos,22);return t?this.bb.readUint16(this.bb_pos+t):16}crs(t){const e=this.bb.__offset(this.bb_pos,24);return e?(t||new f).__init(this.bb.__indirect(this.bb_pos+e),this.bb):null}title(t){const e=this.bb.__offset(this.bb_pos,26);return e?this.bb.__string(this.bb_pos+e,t):null}description(t){const e=this.bb.__offset(this.bb_pos,28);return e?this.bb.__string(this.bb_pos+e,t):null}metadata(t){const e=this.bb.__offset(this.bb_pos,30);return e?this.bb.__string(this.bb_pos+e,t):null}static startHeader(t){t.startObject(14)}static addName(t,e){t.addFieldOffset(0,e,0)}static addEnvelope(t,e){t.addFieldOffset(1,e,0)}static createEnvelopeVector(t,e){t.startVector(8,e.length,8);for(let s=e.length-1;s>=0;s--)t.addFloat64(e[s]);return t.endVector()}static startEnvelopeVector(t,e){t.startVector(8,e,8)}static addGeometryType(t,e){t.addFieldInt8(2,e,c.Unknown)}static addHasZ(t,e){t.addFieldInt8(3,+e,0)}static addHasM(t,e){t.addFieldInt8(4,+e,0)}static addHasT(t,e){t.addFieldInt8(5,+e,0)}static addHasTm(t,e){t.addFieldInt8(6,+e,0)}static addColumns(t,e){t.addFieldOffset(7,e,0)}static createColumnsVector(t,e){t.startVector(4,e.length,4);for(let s=e.length-1;s>=0;s--)t.addOffset(e[s]);return t.endVector()}static startColumnsVector(t,e){t.startVector(4,e,4)}static addFeaturesCount(t,e){t.addFieldInt64(8,e,t.createLong(0,0))}static addIndexNodeSize(t,e){t.addFieldInt16(9,e,16)}static addCrs(t,e){t.addFieldOffset(10,e,0)}static addTitle(t,e){t.addFieldOffset(11,e,0)}static addDescription(t,e){t.addFieldOffset(12,e,0)}static addMetadata(t,e){t.addFieldOffset(13,e,0)}static endHeader(t){return t.endObject()}static finishHeaderBuffer(t,e){t.finish(e)}static finishSizePrefixedHeaderBuffer(t,e){t.finish(e,void 0,!0)}}class p{constructor(t,e,s,i,r,n,o,a){this.geometryType=t,this.columns=e,this.featuresCount=s,this.indexNodeSize=i,this.crs=r,this.title=n,this.description=o,this.metadata=a}static fromByteBuffer(t){const s=_.getRootAsHeader(t),r=s.featuresCount().toFloat64(),n=s.indexNodeSize(),o=[];for(let t=0;t<s.columnsLength();t++){const i=s.columns(t);if(!i)throw new Error("Column unexpectedly missing");if(!i.name())throw new Error("Column name unexpectedly missing");o.push(new e(i.name(),i.type(),i.title(),i.description(),i.width(),i.precision(),i.scale(),i.nullable(),i.unique(),i.primaryKey()))}const a=s.crs(),b=a?new i(a.org(),a.code(),a.name(),a.description(),a.wkt(),a.codeString()):null;return new p(s.geometryType(),o,r,n,b,s.title(),s.description(),s.metadata())}}class g{constructor(){this.bb=null,this.bb_pos=0}__init(t,e){return this.bb_pos=t,this.bb=e,this}static getRootAsGeometry(t,e){return(e||new g).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsGeometry(t,e){return t.setPosition(t.position()+4),(e||new g).__init(t.readInt32(t.position())+t.position(),t)}ends(t){const e=this.bb.__offset(this.bb_pos,4);return e?this.bb.readUint32(this.bb.__vector(this.bb_pos+e)+4*t):0}endsLength(){const t=this.bb.__offset(this.bb_pos,4);return t?this.bb.__vector_len(this.bb_pos+t):0}endsArray(){const t=this.bb.__offset(this.bb_pos,4);return t?new Uint32Array(this.bb.bytes().buffer,this.bb.bytes().byteOffset+this.bb.__vector(this.bb_pos+t),this.bb.__vector_len(this.bb_pos+t)):null}xy(t){const e=this.bb.__offset(this.bb_pos,6);return e?this.bb.readFloat64(this.bb.__vector(this.bb_pos+e)+8*t):0}xyLength(){const t=this.bb.__offset(this.bb_pos,6);return t?this.bb.__vector_len(this.bb_pos+t):0}xyArray(){const t=this.bb.__offset(this.bb_pos,6);return t?new Float64Array(this.bb.bytes().buffer,this.bb.bytes().byteOffset+this.bb.__vector(this.bb_pos+t),this.bb.__vector_len(this.bb_pos+t)):null}z(t){const e=this.bb.__offset(this.bb_pos,8);return e?this.bb.readFloat64(this.bb.__vector(this.bb_pos+e)+8*t):0}zLength(){const t=this.bb.__offset(this.bb_pos,8);return t?this.bb.__vector_len(this.bb_pos+t):0}zArray(){const t=this.bb.__offset(this.bb_pos,8);return t?new Float64Array(this.bb.bytes().buffer,this.bb.bytes().byteOffset+this.bb.__vector(this.bb_pos+t),this.bb.__vector_len(this.bb_pos+t)):null}m(t){const e=this.bb.__offset(this.bb_pos,10);return e?this.bb.readFloat64(this.bb.__vector(this.bb_pos+e)+8*t):0}mLength(){const t=this.bb.__offset(this.bb_pos,10);return t?this.bb.__vector_len(this.bb_pos+t):0}mArray(){const t=this.bb.__offset(this.bb_pos,10);return t?new Float64Array(this.bb.bytes().buffer,this.bb.bytes().byteOffset+this.bb.__vector(this.bb_pos+t),this.bb.__vector_len(this.bb_pos+t)):null}t(t){const e=this.bb.__offset(this.bb_pos,12);return e?this.bb.readFloat64(this.bb.__vector(this.bb_pos+e)+8*t):0}tLength(){const t=this.bb.__offset(this.bb_pos,12);return t?this.bb.__vector_len(this.bb_pos+t):0}tArray(){const t=this.bb.__offset(this.bb_pos,12);return t?new Float64Array(this.bb.bytes().buffer,this.bb.bytes().byteOffset+this.bb.__vector(this.bb_pos+t),this.bb.__vector_len(this.bb_pos+t)):null}tm(t){const e=this.bb.__offset(this.bb_pos,14);return e?this.bb.readUint64(this.bb.__vector(this.bb_pos+e)+8*t):this.bb.createLong(0,0)}tmLength(){const t=this.bb.__offset(this.bb_pos,14);return t?this.bb.__vector_len(this.bb_pos+t):0}type(){const t=this.bb.__offset(this.bb_pos,16);return t?this.bb.readUint8(this.bb_pos+t):c.Unknown}parts(t,e){const s=this.bb.__offset(this.bb_pos,18);return s?(e||new g).__init(this.bb.__indirect(this.bb.__vector(this.bb_pos+s)+4*t),this.bb):null}partsLength(){const t=this.bb.__offset(this.bb_pos,18);return t?this.bb.__vector_len(this.bb_pos+t):0}static startGeometry(t){t.startObject(8)}static addEnds(t,e){t.addFieldOffset(0,e,0)}static createEndsVector(t,e){t.startVector(4,e.length,4);for(let s=e.length-1;s>=0;s--)t.addInt32(e[s]);return t.endVector()}static startEndsVector(t,e){t.startVector(4,e,4)}static addXy(t,e){t.addFieldOffset(1,e,0)}static createXyVector(t,e){t.startVector(8,e.length,8);for(let s=e.length-1;s>=0;s--)t.addFloat64(e[s]);return t.endVector()}static startXyVector(t,e){t.startVector(8,e,8)}static addZ(t,e){t.addFieldOffset(2,e,0)}static createZVector(t,e){t.startVector(8,e.length,8);for(let s=e.length-1;s>=0;s--)t.addFloat64(e[s]);return t.endVector()}static startZVector(t,e){t.startVector(8,e,8)}static addM(t,e){t.addFieldOffset(3,e,0)}static createMVector(t,e){t.startVector(8,e.length,8);for(let s=e.length-1;s>=0;s--)t.addFloat64(e[s]);return t.endVector()}static startMVector(t,e){t.startVector(8,e,8)}static addT(t,e){t.addFieldOffset(4,e,0)}static createTVector(t,e){t.startVector(8,e.length,8);for(let s=e.length-1;s>=0;s--)t.addFloat64(e[s]);return t.endVector()}static startTVector(t,e){t.startVector(8,e,8)}static addTm(t,e){t.addFieldOffset(5,e,0)}static createTmVector(t,e){t.startVector(8,e.length,8);for(let s=e.length-1;s>=0;s--)t.addInt64(e[s]);return t.endVector()}static startTmVector(t,e){t.startVector(8,e,8)}static addType(t,e){t.addFieldInt8(6,e,c.Unknown)}static addParts(t,e){t.addFieldOffset(7,e,0)}static createPartsVector(t,e){t.startVector(4,e.length,4);for(let s=e.length-1;s>=0;s--)t.addOffset(e[s]);return t.endVector()}static startPartsVector(t,e){t.startVector(4,e,4)}static endGeometry(t){return t.endObject()}static createGeometry(t,e,s,i,r,n,o,a,b){return g.startGeometry(t),g.addEnds(t,e),g.addXy(t,s),g.addZ(t,i),g.addM(t,r),g.addT(t,n),g.addTm(t,o),g.addType(t,a),g.addParts(t,b),g.endGeometry(t)}}function y(t,e,s){if(0!==t.length)if(Array.isArray(t[0]))for(const i of t)y(i,e,s);else 2===t.length?e.push(...t):(e.push(t[0],t[1]),s.push(t[2]))}function w(t,e){const s=[];for(let i=0;i<t.length;i+=2){const r=[t[i],t[i+1]];e&&r.push(e[i>>1]),s.push(r)}return s}function m(t){return t?c[t]:c.Unknown}function v(t){const e=t.coordinates,s=[],i=[];let r,n;const o=m(t.type);let a=0;switch(t.type){case"Point":y(e,s,i);break;case"MultiPoint":case"LineString":y(e,s,i);break;case"MultiLineString":case"Polygon":{const t=e;y(t,s,i),t.length>1&&(r=t.map(t=>a+=t.length));break}case"MultiPolygon":n=e.map(t=>({type:"Polygon",coordinates:t})).map(v);break;case"GeometryCollection":t.geometries&&(n=t.geometries.map(v))}return{xy:s,z:i.length>0?i:void 0,ends:r,type:o,parts:n}}function I(t,e){if(e===c.GeometryCollection){const s=[];for(let e=0;e<t.partsLength();e++){const i=t.parts(e),r=i.type();s.push(I(i,r))}return{type:c[e],geometries:s}}if(e===c.MultiPolygon){const s=[];for(let e=0;e<t.partsLength();e++)s.push(I(t.parts(e),c.Polygon));return{type:c[e],coordinates:s.map(t=>t.coordinates)}}const s=function(t,e){const s=t.xyArray(),i=t.zArray();switch(e){case c.Point:{const t=Array.from(s);return i&&t.push(i[0]),t}case c.MultiPoint:case c.LineString:return w(s,i);case c.MultiLineString:case c.Polygon:return function(t,e,s){if(!s||0===s.length)return[w(t,e)];let i=0;const r=Array.from(s).map(e=>t.slice(i,i=e<<1));let n;return e&&(i=0,n=Array.from(s).map(t=>e.slice(i,i=t))),r.map((t,e)=>w(t,n?n[e]:void 0))}(s,i,t.endsArray())}}(t,e);return{type:c[e],coordinates:s}}class F{constructor(){this.bb=null,this.bb_pos=0}__init(t,e){return this.bb_pos=t,this.bb=e,this}static getRootAsFeature(t,e){return(e||new F).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsFeature(t,e){return t.setPosition(t.position()+4),(e||new F).__init(t.readInt32(t.position())+t.position(),t)}geometry(t){const e=this.bb.__offset(this.bb_pos,4);return e?(t||new g).__init(this.bb.__indirect(this.bb_pos+e),this.bb):null}properties(t){const e=this.bb.__offset(this.bb_pos,6);return e?this.bb.readUint8(this.bb.__vector(this.bb_pos+e)+t):0}propertiesLength(){const t=this.bb.__offset(this.bb_pos,6);return t?this.bb.__vector_len(this.bb_pos+t):0}propertiesArray(){const t=this.bb.__offset(this.bb_pos,6);return t?new Uint8Array(this.bb.bytes().buffer,this.bb.bytes().byteOffset+this.bb.__vector(this.bb_pos+t),this.bb.__vector_len(this.bb_pos+t)):null}columns(t,e){const s=this.bb.__offset(this.bb_pos,8);return s?(e||new u).__init(this.bb.__indirect(this.bb.__vector(this.bb_pos+s)+4*t),this.bb):null}columnsLength(){const t=this.bb.__offset(this.bb_pos,8);return t?this.bb.__vector_len(this.bb_pos+t):0}static startFeature(t){t.startObject(3)}static addGeometry(t,e){t.addFieldOffset(0,e,0)}static addProperties(t,e){t.addFieldOffset(1,e,0)}static createPropertiesVector(t,e){t.startVector(1,e.length,1);for(let s=e.length-1;s>=0;s--)t.addInt8(e[s]);return t.endVector()}static startPropertiesVector(t,e){t.startVector(1,e,1)}static addColumns(t,e){t.addFieldOffset(2,e,0)}static createColumnsVector(t,e){t.startVector(4,e.length,4);for(let s=e.length-1;s>=0;s--)t.addOffset(e[s]);return t.endVector()}static startColumnsVector(t,e){t.startVector(4,e,4)}static endFeature(t){return t.endObject()}static finishFeatureBuffer(t,e){t.finish(e)}static finishSizePrefixedFeatureBuffer(t,e){t.finish(e,void 0,!0)}static createFeature(t,e,s,i){return F.startFeature(t),F.addGeometry(t,e),F.addProperties(t,s),F.addColumns(t,i),F.endFeature(t)}}const U=new TextEncoder,O=new TextDecoder;function S(t,e,i){const r=i.columns,n=new l;let o=0,a=1024,b=new Uint8Array(a),h=new DataView(b.buffer);const c=function(t){if(o+t<a)return;a*=2;const e=new Uint8Array(a);e.set(b),b=e,h=new DataView(b.buffer,o)};if(r)for(let t=0;t<r.length;t++){const i=r[t],n=e[i.name];if(null!==n)switch(h.setUint16(o,t,!0),o+=2,i.type){case s.Bool:c(1),h.setUint8(o,n),o+=1;break;case s.Short:c(2),h.setInt16(o,n,!0),o+=2;break;case s.UShort:c(2),h.setUint16(o,n,!0),o+=2;break;case s.Int:c(4),h.setInt32(o,n,!0),o+=4;break;case s.UInt:c(4),h.setUint32(o,n,!0),o+=4;break;case s.Long:c(8),h.setBigInt64(o,BigInt(n),!0),o+=8;break;case s.Double:c(8),h.setFloat64(o,n,!0),o+=8;break;case s.DateTime:case s.String:{const t=U.encode(n);c(4),h.setUint32(o,t.length,!0),o+=4,c(t.length),b.set(t,o),o+=t.length;break}default:throw new Error("Unknown type "+i.type)}}let d=null;o>0&&(d=F.createPropertiesVector(n,b.slice(0,o)));const u=function t(e,s){const{xy:i,z:r,ends:n,parts:o,type:a}=s;if(o){const s=o.map(s=>t(e,s)),i=g.createPartsVector(e,s);return g.startGeometry(e),g.addParts(e,i),g.endGeometry(e)}const b=g.createXyVector(e,i);let h,c;return r&&(h=g.createZVector(e,r)),n&&(c=g.createEndsVector(e,n)),g.startGeometry(e),c&&g.addEnds(e,c),g.addXy(e,b),h&&g.addZ(e,h),g.addType(e,a),g.endGeometry(e)}(n,t);F.startFeature(n),F.addGeometry(n,u),d&&F.addProperties(n,d);const f=F.endFeature(n);return n.finishSizePrefixed(f),n.asUint8Array()}function C(t,e){const i=e.columns,r={type:"Feature",geometry:I(t.geometry(),e.geometryType)};return i&&i.length>0&&(r.properties=function(t,e){const i={};if(!e||0===e.length)return i;const r=t.propertiesArray();if(!r)return i;const n=new DataView(r.buffer,r.byteOffset),o=t.propertiesLength();let a=0;for(;a<o;){const t=n.getUint16(a,!0);a+=2;const o=e[t],b=o.name;switch(o.type){case s.Bool:i[b]=!!n.getUint8(a),a+=1;break;case s.Byte:i[b]=n.getInt8(a),a+=1;break;case s.UByte:i[b]=n.getUint8(a),a+=1;break;case s.Short:i[b]=n.getInt16(a,!0),a+=2;break;case s.UShort:i[b]=n.getUint16(a,!0),a+=2;break;case s.Int:i[b]=n.getInt32(a,!0),a+=4;break;case s.UInt:i[b]=n.getUint32(a,!0),a+=4;break;case s.Long:i[b]=Number(n.getBigInt64(a,!0)),a+=8;break;case s.ULong:i[b]=Number(n.getBigUint64(a,!0)),a+=8;break;case s.Double:i[b]=n.getFloat64(a,!0),a+=8;break;case s.DateTime:case s.String:{const t=n.getUint32(a,!0);a+=4,i[b]=O.decode(r.subarray(a,a+t)),a+=t;break}default:throw new Error("Unknown type "+o.type)}}return i}(t,i)),r}var A,V=new Uint8Array(0);function P(t,e){if(!t.length)return e;if(!e.length)return t;var s=new Uint8Array(t.length+e.length);return s.set(t),s.set(e,t.length),s}function x(t){this._source=t,this._array=V,this._index=0}x.prototype.read=function(){var t=this,e=t._array.subarray(t._index);return t._source.read().then((function(s){return t._array=V,t._index=0,s.done?e.length>0?{done:!1,value:e}:{done:!0,value:void 0}:{done:!1,value:P(e,s.value)}}))},x.prototype.slice=function(t){if((t|=0)<0)throw new Error("invalid length");var e=this,s=this._array.length-this._index;if(this._index+t<=this._array.length)return Promise.resolve(this._array.subarray(this._index,this._index+=t));var i=new Uint8Array(t);return i.set(this._array.subarray(this._index)),function r(){return e._source.read().then((function(n){return n.done?(e._array=V,e._index=0,s>0?i.subarray(0,s):null):s+n.value.length>=t?(e._array=n.value,e._index=t-s,i.set(n.value.subarray(0,t-s),s),i):(i.set(n.value,s),s+=n.value.length,r())}))}()},x.prototype.cancel=function(){return this._source.cancel()},function(t){t[t.Debug=0]="Debug",t[t.Info=1]="Info",t[t.Warn=2]="Warn",t[t.Error=3]="Error"}(A||(A={}));class B{static debug(...t){this.log(A.Debug,...t)}static info(...t){this.log(A.Info,...t)}static warn(...t){this.log(A.Warn,...t)}static error(...t){this.log(A.Error,...t)}static log(t,...e){if(!(this.logLevel>t))switch(t){case A.Debug:console.debug(...e);break;case A.Info:console.info(...e);break;case A.Warn:console.warn(...e);break;case A.Error:console.error(...e)}}}function L(t,e){e=Math.min(Math.max(+e,2),65535);let s=t,i=s;do{s=Math.ceil(s/e),i+=s}while(1!==s);return 40*i}function T(t,e){if(0!=(4293918720&t))throw Error("integer is too large to be safely represented");return e+t*2**32}B.logLevel=A.Info;const N=new Uint8Array([102,103,98,3,102,103,98,0]);class E{constructor(t,e,s,i){this.headerClient=t,this.header=e,this.headerLength=s,this.indexLength=i}static async open(t){const e=new k(t),s=(()=>{let t,e=0;for(t=0;t<3;t++)e+=16**t*40;return e})(),i=2024+s;B.debug(`fetching header. minReqLength: ${i} (assumedHeaderLength: 2024, assumedIndexLength: ${s})`);{const t=new Uint8Array(await e.getRange(0,8,i,"header"));if(!t.every((t,e)=>N[e]===t))throw B.error(`bytes: ${t} != ${N}`),new Error("Not a FlatGeobuf file");B.debug("magic bytes look good")}let r;{const t=await e.getRange(8,4,i,"header");if(r=new DataView(t).getUint32(0,!0),r>10485760||r<8)throw new Error("Invalid header size");B.debug("headerLength: "+r)}const n=await e.getRange(12,r,i,"header"),o=new d(new Uint8Array(n)),a=p.fromByteBuffer(o),b=L(a.featuresCount,a.indexNodeSize);return B.debug("completed: opening http reader"),new E(e,a,r,b)}async*selectBbox(t){const e=this.lengthBeforeTree(),s=this.headerClient;B.debug("starting: selectBbox, traversing index. lengthBeforeTree: "+e),yield*async function*(t,e,s,i){class r{constructor(t,e){this._level=e,this.nodes=t}level(){return this._level}startNode(){return this.nodes[0]}endNode(){return this.nodes[1]}extendEndNodeToNewOffset(t){console.assert(t>this.nodes[1]),this.nodes[1]=t}toString(){return`[NodeRange level: ${this._level}, nodes: ${this.nodes[0]}-${this.nodes[1]}]`}}const{minX:n,minY:o,maxX:a,maxY:b}=s,h=function(t,e){if(e<2)throw new Error("Node size must be at least 2");if(0===t)throw new Error("Number of items must be greater than 0");let s=t,i=s;const r=[s];do{s=Math.ceil(s/e),i+=s,r.push(s)}while(1!==s);const n=[];s=i;for(const t of r)n.push(s-t),s-=t;n.reverse(),r.reverse();const o=[];for(let t=0;t<r.length;t++)o.push([n[t],n[t]+r[t]]);return o.reverse(),o}(t,e),c=h[0][0],d=[(()=>{const t=h.length-1;return new r([0,1],t)})()];for(B.debug(`starting stream search with queue: ${d}, numItems: ${t}, nodeSize: ${e}, levelBounds: ${h}`);0!=d.length;){const t=d.shift();B.debug(`popped node: ${t}, queueLength: ${d.length}`);let s=t.startNode();const l=s>=c,[,u]=h[t.level()],f=Math.min(t.endNode()+e,u),_=f-s,p=await i(40*s,40*_),g=new Float64Array(p),y=new Uint32Array(p);for(let e=s;e<f;e++){const i=5*(e-s);if(a<g[i+0])continue;if(b<g[i+1])continue;if(n>g[i+2])continue;if(o>g[i+3])continue;const h=y[8+(i<<1)],u=T(y[9+(i<<1)],h);if(l){B.debug("yielding feature"),yield[u,e-c];continue}const f=6553.6,_=d[d.length-1];if(void 0!==_&&_.level()==t.level()-1&&u<_.endNode()+f){B.debug(`Merging "nodeRange" request into existing range: ${_}, newOffset: ${_.endNode()} -> ${u}`),_.extendEndNodeToNewOffset(u);continue}let p=(()=>{let e=t.level()-1;return new r([u,u+1],e)})();void 0!==_&&_.level()==p.level()?B.debug(`Same level, but too far away. Pushing new request at offset: ${u} rather than merging with distant ${_}`):B.debug(`Pushing new level for ${p} onto queue with nearestNodeRange: ${_} since there's not already a range for this level.`),d.push(p)}}}(this.header.featuresCount,this.header.indexNodeSize,t,(async function(t,i){return s.getRange(e+t,i,0,"index")}))}lengthBeforeTree(){return N.length+4+this.headerLength}lengthBeforeFeatures(){return this.lengthBeforeTree()+this.indexLength}featureClient(){return void 0===this._featureClient&&(this._featureClient=this.headerClient.clone()),this._featureClient}async readFeature(t){const e=131072,s=t+this.lengthBeforeFeatures();let i;{const t=await this.featureClient().getRange(s,4,e,"feature length");i=new DataView(t).getUint32(0,!0)}B.debug(`featureOffset: ${s}, featureLength: ${i}`);const r=await this.featureClient().getRange(s+4,i,e,"feature data"),n=new Uint8Array(r),o=new Uint8Array(i+4);o.set(n,4);const a=new d(o);return a.setPosition(4),F.getRootAsFeature(a)}}class k{constructor(t){this.buffer=new ArrayBuffer(0),this.head=0,this.httpClient="string"==typeof t?new j(t):t}clone(){const t=new k(this.httpClient);return t.buffer=this.buffer.slice(0),t.head=this.head,t}async getRange(t,e,s,i){B.debug(`need Range: ${t}-${t+e-1}`);const r=t-this.head,n=r+e;if(r>=0&&n<this.buffer.byteLength)return B.debug(`slicing existing Range: ${r}-${n-1}`),this.buffer.slice(r,n);const o=Math.max(e,s);return this.buffer=await this.httpClient.getRange(t,o,i),this.head=t,this.buffer.slice(0,e)}}class j{constructor(t){this.requestsEverMade=0,this.bytesEverRequested=0,this.url=t}async getRange(t,e,s){this.requestsEverMade+=1,this.bytesEverRequested+=e;const i=`bytes=${t}-${t+e-1}`;return B.debug(`request: #${this.requestsEverMade}, purpose: ${s}), bytes: (this_request: ${e}, ever: ${this.bytesEverRequested}), Range: ${i}`),(await fetch(this.url,{headers:{Range:i}})).arrayBuffer()}}async function M(t,e,s){let i=new Uint8Array(await t(4,"feature length"));if(0===i.byteLength)return;let r=new d(i);const n=r.readUint32(0);i=new Uint8Array(await t(n,"feature data"));const o=new Uint8Array(n+4);return o.set(i,4),r=new d(o),r.setPosition(4),s(F.getRootAsFeature(r),e)}function R(t){const e=new l;let s=null;t.columns&&(s=_.createColumnsVector(e,t.columns.map(t=>function(t,e){const s=t.createString(e.name);return u.startColumn(t),u.addName(t,s),u.addType(t,e.type),u.endColumn(t)}(e,t))));const i=e.createString("L1");_.startHeader(e),_.addFeaturesCount(e,new b(t.featuresCount,0)),_.addGeometryType(e,t.geometryType),_.addIndexNodeSize(e,0),s&&_.addColumns(e,s),_.addName(e,i);const r=_.endHeader(e);return e.finishSizePrefixed(r),e.asUint8Array()}t.deserialize=function(t,e,s){return t instanceof Uint8Array?function(t,e){return{type:"FeatureCollection",features:function(t,e,s){if(!t.subarray(0,7).every((t,e)=>N[e]===t))throw new Error("Not a FlatGeobuf file");const i=new d(t),r=i.readUint32(N.length);i.setPosition(N.length+4);const n=p.fromByteBuffer(i);s&&s(n);let o=N.length+4+r;const{indexNodeSize:a,featuresCount:b}=n;a>0&&(o+=L(b,a));const h=[];for(;o<i.capacity();){const t=i.readUint32(o);i.setPosition(o+4);const s=F.getRootAsFeature(i);h.push(e(s,n)),o+=4+t}return h}(t,C,e)}}(t,s):t instanceof ReadableStream?function(t,e){return async function*(t,e,s){const i="function"==typeof(r=t).slice?r:new x("function"==typeof r.read?r:r.getReader());var r;const n=async t=>await i.slice(t);let o=new Uint8Array(await n(8));if(!o.every((t,e)=>N[e]===t))throw new Error("Not a FlatGeobuf file");o=new Uint8Array(await n(4));let a=new d(o);const b=a.readUint32(0);o=new Uint8Array(await n(b)),a=new d(o);const h=p.fromByteBuffer(a);s&&s(h);const{indexNodeSize:c,featuresCount:l}=h;if(c>0){const t=L(l,c);await n(t)}let u;for(;u=await M(n,h,e);)yield u}(t,C,e)}(t,s):function(t,e,s){return async function*(t,e,s,i){const r=await E.open(t);B.debug("opened reader"),i&&i(r.header);for await(const t of r.selectBbox(e)){const e=await r.readFeature(t[0]);yield s(e,r.header)}}(t,e,C,s)}(t,e,s)},t.serialize=function(t){return function(t){const i=function(t){const i=t.features[0],r=i.properties;let n=null;return r&&(n=Object.keys(r).map(t=>new e(t,function(t){if("boolean"==typeof t)return s.Bool;if("number"==typeof t)return t%1==0?s.Int:s.Double;if("string"==typeof t)return s.String;if(null===t)return s.String;throw new Error(`Unknown type (value '${t}')`)}(r[t]),null,null,-1,-1,-1,!0,!1,!1))),new p(m(i.geometry.type),n,t.features.length,0,null,null,null,null)}(t),r=R(i),n=t.features.map(t=>S(v(t.geometry),t.properties,i)),o=n.map(t=>t.length).reduce((t,e)=>t+e),a=new Uint8Array(N.length+r.length+o);a.set(r,N.length);let b=N.length+r.length;for(const t of n)a.set(t,b),b+=t.length;return a.set(N),a}(t)},Object.defineProperty(t,"__esModule",{value:!0})}(e)},function(t,e,s){(function(e){const i=s(3),r="undefined"==typeof window?e:window;r.loaders=r.loaders||{},t.exports=Object.assign(r.loaders,i)}).call(this,s(2))},function(t,e){var s;s=function(){return this}();try{s=s||new Function("return this")()}catch(t){"object"==typeof window&&(s=window)}t.exports=s},function(t,e,s){"use strict";s.r(e),s.d(e,"FlatGeobufLoader",(function(){return n}));var i=s(0);function r(t,e){if(0===t.byteLength)return[];const s=new Uint8Array(t),{features:r}=Object(i.deserialize)(s);return r}const n={...{id:"flatgeobuf",name:"FlatGeobuf",module:"flatgeobuf",version:"3.0.0-beta.1",worker:!0,extensions:["fgb"],category:"geometry",options:{flatgeobuf:{}}},parse:async(t,e)=>r(t),parseSync:r,parseInBatchesFromStream:function(t,e){return Object(i.deserializeStream)(t)},binary:!0}}])}));
//# sourceMappingURL=dist.min.js.map

@@ -28,3 +28,3 @@ "use strict";

var VERSION = typeof "3.0.0-alpha.21" !== 'undefined' ? "3.0.0-alpha.21" : 'latest';
var VERSION = typeof "3.0.0-beta.1" !== 'undefined' ? "3.0.0-beta.1" : 'latest';
var FlatGeobufWorkerLoader = {

@@ -31,0 +31,0 @@ id: 'flatgeobuf',

@@ -10,3 +10,3 @@ import _asyncToGenerator from "@babel/runtime/helpers/esm/asyncToGenerator";

import parseFlatGeobuf, { parseFlatGeobufInBatches } from './lib/parse-flatgeobuf';
var VERSION = typeof "3.0.0-alpha.21" !== 'undefined' ? "3.0.0-alpha.21" : 'latest';
var VERSION = typeof "3.0.0-beta.1" !== 'undefined' ? "3.0.0-beta.1" : 'latest';
export var FlatGeobufWorkerLoader = {

@@ -13,0 +13,0 @@ id: 'flatgeobuf',

{
"name": "@loaders.gl/flatgeobuf",
"description": "Loader for FlatGeobuf",
"version": "3.0.0-alpha.21",
"version": "3.0.0-beta.1",
"license": "MIT",

@@ -20,2 +20,3 @@ "publishConfig": {

],
"types": "src/index.ts",
"main": "dist/es5/index.js",

@@ -35,3 +36,3 @@ "module": "dist/esm/index.js",

"dependencies": {
"@loaders.gl/loader-utils": "3.0.0-alpha.21",
"@loaders.gl/loader-utils": "3.0.0-beta.1",
"flatgeobuf": "^3.1.0"

@@ -42,3 +43,3 @@ },

},
"gitHead": "c1f7d7bec911c704a190dbcf6b392a07a555771b"
"gitHead": "2fb06018114d18a86143d10a8a02341a0b9a01a9"
}

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc