maplibre-gl-components 0.20.6 → 0.22.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +47 -1
- package/dist/ControlGrid-BBOB4hcq.cjs +16851 -0
- package/dist/ControlGrid-CXnEfoxn.js +102866 -0
- package/dist/{DuckDBConverter-G6cWy2IS.js → DuckDBConverter-BmkTmy9v.js} +27 -27
- package/dist/{DuckDBConverter-4zGbThM1.cjs → DuckDBConverter-CY3p1iVn.cjs} +1 -1
- package/dist/{ShapefileConverter-BefhyBOj.js → ShapefileConverter-Bgv06LK7.js} +1 -1
- package/dist/{ShapefileConverter-Dk_BW4ca.cjs → ShapefileConverter-D3wQtYHO.cjs} +1 -1
- package/dist/{geotiff-BsSRJ-4E.js → geotiff-BFWKZ7Ej.js} +10 -11
- package/dist/{geotiff-GFm9cPD1.cjs → geotiff-DvXk5w3O.cjs} +2 -2
- package/dist/{globals-BKIWameS.js → globals-Da065JQj.js} +55 -33
- package/dist/index.cjs +1 -1
- package/dist/index.mjs +138 -136
- package/dist/{lerc-IUhdhKhj.js → lerc-CwzT0cMz.js} +9 -10
- package/dist/{lerc-CPfGdIIh.cjs → lerc-cUMeQO-8.cjs} +1 -1
- package/dist/{maplibre-geoman.es-BC6M2gop.cjs → maplibre-geoman.es-DqoIAudd.cjs} +1 -1
- package/dist/maplibre-gl-components.css +1 -1
- package/dist/react.cjs +1 -1
- package/dist/react.mjs +10 -10
- package/dist/types/lib/core/BookmarkControl.d.ts +34 -1
- package/dist/types/lib/core/BookmarkControl.d.ts.map +1 -1
- package/dist/types/lib/core/types.d.ts +46 -1
- package/dist/types/lib/core/types.d.ts.map +1 -1
- package/package.json +2 -2
- package/dist/ControlGrid-BmxIgQg5.js +0 -150653
- package/dist/ControlGrid-ChGLgBGL.cjs +0 -17280
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { f as R } from "./globals-Da065JQj.js";
|
|
2
2
|
var G = /* @__PURE__ */ R({
|
|
3
3
|
DuckDBConverter: () => O,
|
|
4
4
|
getDuckDBConverter: () => A
|
|
@@ -47,13 +47,13 @@ var O = class {
|
|
|
47
47
|
percent: 30,
|
|
48
48
|
message: "Selecting DuckDB bundle..."
|
|
49
49
|
});
|
|
50
|
-
let
|
|
50
|
+
let o;
|
|
51
51
|
if (this._duckdb.getJsDelivrBundles) {
|
|
52
52
|
const e = this._duckdb.getJsDelivrBundles();
|
|
53
|
-
|
|
53
|
+
o = await this._duckdb.selectBundle(e);
|
|
54
54
|
} else {
|
|
55
55
|
const e = this._getJsDelivrBundles();
|
|
56
|
-
|
|
56
|
+
o = await this._duckdb.selectBundle(e);
|
|
57
57
|
}
|
|
58
58
|
t?.({
|
|
59
59
|
stage: "initializing",
|
|
@@ -63,14 +63,14 @@ var O = class {
|
|
|
63
63
|
const h = new this._duckdb.ConsoleLogger(4);
|
|
64
64
|
let l, i = null;
|
|
65
65
|
try {
|
|
66
|
-
i = URL.createObjectURL(new Blob([`importScripts("${
|
|
66
|
+
i = URL.createObjectURL(new Blob([`importScripts("${o.mainWorker}");`], { type: "text/javascript" })), l = new Worker(i);
|
|
67
67
|
} catch (e) {
|
|
68
68
|
throw i && URL.revokeObjectURL(i), new Error(`Failed to create DuckDB worker: ${e instanceof Error ? e.message : "Unknown error"}`);
|
|
69
69
|
}
|
|
70
70
|
this._worker = l;
|
|
71
71
|
const p = new this._duckdb.AsyncDuckDB(h, l);
|
|
72
72
|
try {
|
|
73
|
-
await p.instantiate(
|
|
73
|
+
await p.instantiate(o.mainModule, o.pthreadWorker);
|
|
74
74
|
} catch (e) {
|
|
75
75
|
throw new Error(`Failed to instantiate DuckDB: ${e instanceof Error ? e.message : "Unknown error"}`);
|
|
76
76
|
}
|
|
@@ -115,10 +115,10 @@ var O = class {
|
|
|
115
115
|
}
|
|
116
116
|
};
|
|
117
117
|
}
|
|
118
|
-
async convert(t, r,
|
|
118
|
+
async convert(t, r, o) {
|
|
119
119
|
const h = performance.now(), l = this._detectFormat(r);
|
|
120
|
-
if (this.isReady() || await this.initialize(
|
|
121
|
-
|
|
120
|
+
if (this.isReady() || await this.initialize(o), !this._db) throw new Error("DuckDB not initialized");
|
|
121
|
+
o?.({
|
|
122
122
|
stage: "loading",
|
|
123
123
|
percent: 0,
|
|
124
124
|
message: `Loading ${r}...`
|
|
@@ -127,7 +127,7 @@ var O = class {
|
|
|
127
127
|
await this._db.registerFileBuffer(r, i);
|
|
128
128
|
const p = await this._db.connect();
|
|
129
129
|
try {
|
|
130
|
-
|
|
130
|
+
o?.({
|
|
131
131
|
stage: "converting",
|
|
132
132
|
percent: 30,
|
|
133
133
|
message: "Reading spatial data..."
|
|
@@ -160,8 +160,8 @@ var O = class {
|
|
|
160
160
|
"geometry_wkt"
|
|
161
161
|
];
|
|
162
162
|
for (const m of e) {
|
|
163
|
-
const
|
|
164
|
-
z || N || j ? c || (c =
|
|
163
|
+
const n = m.column_name, E = m.column_type?.toUpperCase() || "", _ = n.toLowerCase(), z = E.includes("GEOMETRY"), N = _ === "geom" || _ === "geometry" || _ === "wkb_geometry" || _ === "the_geom" || _ === "shape", j = E.includes("BLOB") && N;
|
|
164
|
+
z || N || j ? c || (c = n, f = E) : S.includes(_) && !g ? (g = n, d.push(n)) : $.includes(_) && !u ? (u = n, d.push(n)) : w.includes(_) && !a ? a = n : d.push(n);
|
|
165
165
|
}
|
|
166
166
|
let y = !1, T = !1;
|
|
167
167
|
if (!c) if (a) T = !0;
|
|
@@ -169,10 +169,10 @@ var O = class {
|
|
|
169
169
|
y = !0;
|
|
170
170
|
const m = d.indexOf(g);
|
|
171
171
|
m > -1 && d.splice(m, 1);
|
|
172
|
-
const
|
|
173
|
-
|
|
172
|
+
const n = d.indexOf(u);
|
|
173
|
+
n > -1 && d.splice(n, 1);
|
|
174
174
|
} else throw new Error("No geometry column found in the file. For CSV/Excel files, include a geometry column, WKT column, or lat/lon columns.");
|
|
175
|
-
|
|
175
|
+
o?.({
|
|
176
176
|
stage: "converting",
|
|
177
177
|
percent: 50,
|
|
178
178
|
message: "Converting to GeoJSON..."
|
|
@@ -189,17 +189,17 @@ var O = class {
|
|
|
189
189
|
FROM ${s}
|
|
190
190
|
WHERE ${b}
|
|
191
191
|
`)).toArray();
|
|
192
|
-
|
|
192
|
+
o?.({
|
|
193
193
|
stage: "converting",
|
|
194
194
|
percent: 80,
|
|
195
195
|
message: "Building feature collection..."
|
|
196
196
|
});
|
|
197
197
|
const D = [], L = /* @__PURE__ */ new Set();
|
|
198
198
|
for (const m of x) if (m.feature) try {
|
|
199
|
-
const
|
|
200
|
-
D.push(
|
|
201
|
-
} catch (
|
|
202
|
-
console.warn("Failed to parse feature:",
|
|
199
|
+
const n = typeof m.feature == "string" ? JSON.parse(m.feature) : m.feature;
|
|
200
|
+
D.push(n), n.geometry?.type && L.add(n.geometry.type);
|
|
201
|
+
} catch (n) {
|
|
202
|
+
console.warn("Failed to parse feature:", n);
|
|
203
203
|
}
|
|
204
204
|
const C = {
|
|
205
205
|
type: "FeatureCollection",
|
|
@@ -211,7 +211,7 @@ var O = class {
|
|
|
211
211
|
fileSize: t.byteLength,
|
|
212
212
|
conversionTimeMs: Math.round(F - h)
|
|
213
213
|
};
|
|
214
|
-
return
|
|
214
|
+
return o?.({
|
|
215
215
|
stage: "complete",
|
|
216
216
|
percent: 100,
|
|
217
217
|
message: `Converted ${D.length} features`
|
|
@@ -221,7 +221,7 @@ var O = class {
|
|
|
221
221
|
metadata: U
|
|
222
222
|
};
|
|
223
223
|
} catch (s) {
|
|
224
|
-
throw
|
|
224
|
+
throw o?.({
|
|
225
225
|
stage: "error",
|
|
226
226
|
message: `Failed to convert: ${s instanceof Error ? s.message : "Unknown error"}`
|
|
227
227
|
}), s;
|
|
@@ -276,7 +276,7 @@ var O = class {
|
|
|
276
276
|
if (!this._db) throw new Error("DuckDB not initialized");
|
|
277
277
|
const r = await this._db.connect();
|
|
278
278
|
try {
|
|
279
|
-
const
|
|
279
|
+
const o = (await r.query(`DESCRIBE SELECT * FROM read_parquet('${t}')`)).toArray(), h = o.map((e) => ({
|
|
280
280
|
name: e.column_name,
|
|
281
281
|
type: e.column_type
|
|
282
282
|
}));
|
|
@@ -288,7 +288,7 @@ var O = class {
|
|
|
288
288
|
"the_geom",
|
|
289
289
|
"shape"
|
|
290
290
|
];
|
|
291
|
-
for (const e of
|
|
291
|
+
for (const e of o) {
|
|
292
292
|
const c = e.column_name, f = e.column_type?.toUpperCase() || "", g = c.toLowerCase(), u = f.includes("GEOMETRY"), a = s.includes(g), d = f.includes("BLOB") && a;
|
|
293
293
|
(u || a || d) && !l ? (l = c, i = f) : p.push(c);
|
|
294
294
|
}
|
|
@@ -302,13 +302,13 @@ var O = class {
|
|
|
302
302
|
await r.close();
|
|
303
303
|
}
|
|
304
304
|
}
|
|
305
|
-
async queryByBounds(t, r,
|
|
305
|
+
async queryByBounds(t, r, o, h, l) {
|
|
306
306
|
if (!this._db) throw new Error("DuckDB not initialized");
|
|
307
307
|
const i = await this._db.connect(), [p, s, e, c] = r;
|
|
308
308
|
try {
|
|
309
309
|
const f = h.length > 0 ? `json_object(${h.map((w) => `'${w}', "${w}"`).join(", ")})` : "'{}'::JSON", g = (l?.toUpperCase() || "").includes("BLOB");
|
|
310
310
|
let u, a;
|
|
311
|
-
g ? (u = `ST_AsGeoJSON(ST_GeomFromWKB("${
|
|
311
|
+
g ? (u = `ST_AsGeoJSON(ST_GeomFromWKB("${o}"))`, a = `ST_GeomFromWKB("${o}")`) : (u = `ST_AsGeoJSON("${o}")`, a = `"${o}"`);
|
|
312
312
|
const d = `
|
|
313
313
|
SELECT json_object(
|
|
314
314
|
'type', 'Feature',
|
|
@@ -316,7 +316,7 @@ var O = class {
|
|
|
316
316
|
'properties', ${f}
|
|
317
317
|
) as feature
|
|
318
318
|
FROM read_parquet('${t}')
|
|
319
|
-
WHERE "${
|
|
319
|
+
WHERE "${o}" IS NOT NULL
|
|
320
320
|
AND ST_Intersects(
|
|
321
321
|
${a},
|
|
322
322
|
ST_MakeEnvelope(${p}, ${s}, ${e}, ${c})
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
var q=Object.create;var v=Object.defineProperty;var G=Object.getOwnPropertyDescriptor;var J=Object.getOwnPropertyNames;var W=Object.getPrototypeOf,I=Object.prototype.hasOwnProperty;var M=(e,t,r,p)=>{if(t&&typeof t=="object"||typeof t=="function")for(let o of J(t))!I.call(e,o)&&o!==r&&v(e,o,{get:()=>t[o],enumerable:!(p=G(t,o))||p.enumerable});return e};var K=(e,t,r)=>(r=e!=null?q(W(e)):{},M(t||!e||!e.__esModule?v(r,"default",{value:e,enumerable:!0}):r,e));const H=require("./ControlGrid-
|
|
1
|
+
var q=Object.create;var v=Object.defineProperty;var G=Object.getOwnPropertyDescriptor;var J=Object.getOwnPropertyNames;var W=Object.getPrototypeOf,I=Object.prototype.hasOwnProperty;var M=(e,t,r,p)=>{if(t&&typeof t=="object"||typeof t=="function")for(let o of J(t))!I.call(e,o)&&o!==r&&v(e,o,{get:()=>t[o],enumerable:!(p=G(t,o))||p.enumerable});return e};var K=(e,t,r)=>(r=e!=null?q(W(e)):{},M(t||!e||!e.__esModule?v(r,"default",{value:e,enumerable:!0}):r,e));const H=require("./ControlGrid-BBOB4hcq.cjs");var Y=H.__exportAll({DuckDBConverter:()=>T,getDuckDBConverter:()=>C}),D=null;function C(){return D||(D=new T),D}var T=class{_duckdb=null;_db=null;_worker=null;_initialized=!1;_initializing=!1;_bundleUrl;constructor(e){this._bundleUrl=e}isReady(){return this._initialized&&this._db!==null}async initialize(e){if(!this._initialized){if(this._initializing){for(;this._initializing;)await new Promise(t=>setTimeout(t,50));return}this._initializing=!0;try{e?.({stage:"initializing",percent:0,message:"Loading DuckDB WASM..."});let t;try{const n=await import("@duckdb/duckdb-wasm");t=n.default||n}catch(n){throw new Error(`DuckDB WASM is not installed or failed to load. Install it with: npm install @duckdb/duckdb-wasm. Error: ${n instanceof Error?n.message:"Unknown error"}`)}this._duckdb=t,e?.({stage:"initializing",percent:30,message:"Selecting DuckDB bundle..."});let r;if(this._duckdb.getJsDelivrBundles){const n=this._duckdb.getJsDelivrBundles();r=await this._duckdb.selectBundle(n)}else{const n=this._getJsDelivrBundles();r=await this._duckdb.selectBundle(n)}e?.({stage:"initializing",percent:50,message:"Instantiating DuckDB..."});const p=new this._duckdb.ConsoleLogger(4);let o,a=null;try{a=URL.createObjectURL(new Blob([`importScripts("${r.mainWorker}");`],{type:"text/javascript"})),o=new Worker(a)}catch(n){throw a&&URL.revokeObjectURL(a),new Error(`Failed to create DuckDB worker: ${n instanceof Error?n.message:"Unknown error"}`)}this._worker=o;const g=new this._duckdb.AsyncDuckDB(p,o);try{await g.instantiate(r.mainModule,r.pthreadWorker)}catch(n){throw new Error(`Failed to instantiate DuckDB: ${n instanceof Error?n.message:"Unknown error"}`)}a&&URL.revokeObjectURL(a),this._db=g,e?.({stage:"initializing",percent:70,message:"Loading spatial extension..."});const s=await this._db.connect();try{await s.query("INSTALL spatial"),await s.query("LOAD spatial")}catch(n){console.warn("Failed to load spatial extension, some features may not work:",n)}finally{await s.close()}this._initialized=!0,e?.({stage:"initializing",percent:100,message:"DuckDB ready"})}catch(t){throw e?.({stage:"error",message:`Failed to initialize DuckDB: ${t instanceof Error?t.message:"Unknown error"}`}),t}finally{this._initializing=!1}}}_getJsDelivrBundles(){const e=this._bundleUrl||"https://cdn.jsdelivr.net/npm/@duckdb/duckdb-wasm@latest/dist";return{mvp:{mainModule:`${e}/duckdb-mvp.wasm`,mainWorker:`${e}/duckdb-browser-mvp.worker.js`},eh:{mainModule:`${e}/duckdb-eh.wasm`,mainWorker:`${e}/duckdb-browser-eh.worker.js`}}}async convert(e,t,r){const p=performance.now(),o=this._detectFormat(t);if(this.isReady()||await this.initialize(r),!this._db)throw new Error("DuckDB not initialized");r?.({stage:"loading",percent:0,message:`Loading ${t}...`});const a=new Uint8Array(e);await this._db.registerFileBuffer(t,a);const g=await this._db.connect();try{r?.({stage:"converting",percent:30,message:"Reading spatial data..."});let s;o==="geoparquet"||o==="parquet"?s=`read_parquet('${t}')`:s=`ST_Read('${t}')`;const n=(await g.query(`
|
|
2
2
|
DESCRIBE SELECT * FROM ${s}
|
|
3
3
|
`)).toArray();let c=null,h="",f=null,u=null,l=null;const d=[],S=["lat","latitude","y","lat_y","point_y"],B=["lon","lng","long","longitude","x","lon_x","long_x","point_x"],w=["wkt","wkt_geom","wkt_geometry","geometry_wkt"];for(const m of n){const i=m.column_name,E=m.column_type?.toUpperCase()||"",_=i.toLowerCase(),R=E.includes("GEOMETRY"),O=_==="geom"||_==="geometry"||_==="wkb_geometry"||_==="the_geom"||_==="shape",A=E.includes("BLOB")&&O;R||O||A?c||(c=i,h=E):S.includes(_)&&!f?(f=i,d.push(i)):B.includes(_)&&!u?(u=i,d.push(i)):w.includes(_)&&!l?l=i:d.push(i)}let y=!1,L=!1;if(!c)if(l)L=!0;else if(f&&u){y=!0;const m=d.indexOf(f);m>-1&&d.splice(m,1);const i=d.indexOf(u);i>-1&&d.splice(i,1)}else throw new Error("No geometry column found in the file. For CSV/Excel files, include a geometry column, WKT column, or lat/lon columns.");r?.({stage:"converting",percent:50,message:"Converting to GeoJSON..."});const x=d.length>0?`json_object(${d.map(m=>`'${m}', "${m}"`).join(", ")})`:"'{}'::JSON";let k,b;y&&f&&u?(k=`ST_AsGeoJSON(ST_Point("${u}", "${f}"))`,b=`"${f}" IS NOT NULL AND "${u}" IS NOT NULL`):L&&l?(k=`ST_AsGeoJSON(ST_GeomFromText("${l}"))`,b=`"${l}" IS NOT NULL AND "${l}" != ''`):h.includes("BLOB")?(k=`ST_AsGeoJSON(ST_GeomFromWKB("${c}"))`,b=`"${c}" IS NOT NULL`):(k=`ST_AsGeoJSON("${c}")`,b=`"${c}" IS NOT NULL`);const F=(await g.query(`
|
|
4
4
|
SELECT json_object(
|
|
@@ -1 +1 @@
|
|
|
1
|
-
var g=Object.create;var f=Object.defineProperty;var y=Object.getOwnPropertyDescriptor;var m=Object.getOwnPropertyNames;var d=Object.getPrototypeOf,v=Object.prototype.hasOwnProperty;var C=(t,i,r,n)=>{if(i&&typeof i=="object"||typeof i=="function")for(let e of m(i))!v.call(t,e)&&e!==r&&f(t,e,{get:()=>i[e],enumerable:!(n=y(i,e))||n.enumerable});return t};var _=(t,i,r)=>(r=t!=null?g(d(t)):{},C(i||!t||!t.__esModule?f(r,"default",{value:t,enumerable:!0}):r,t));const j=require("./ControlGrid-
|
|
1
|
+
var g=Object.create;var f=Object.defineProperty;var y=Object.getOwnPropertyDescriptor;var m=Object.getOwnPropertyNames;var d=Object.getPrototypeOf,v=Object.prototype.hasOwnProperty;var C=(t,i,r,n)=>{if(i&&typeof i=="object"||typeof i=="function")for(let e of m(i))!v.call(t,e)&&e!==r&&f(t,e,{get:()=>i[e],enumerable:!(n=y(i,e))||n.enumerable});return t};var _=(t,i,r)=>(r=t!=null?g(d(t)):{},C(i||!t||!t.__esModule?f(r,"default",{value:t,enumerable:!0}):r,t));const j=require("./ControlGrid-BBOB4hcq.cjs");var w=j.__exportAll({ShapefileConverter:()=>o,getShapefileConverter:()=>u}),o=class{_shpjs=null;_initialized=!1;isReady(){return this._initialized&&this._shpjs!==null}async initialize(t){if(!this._initialized){t?.({stage:"initializing",percent:0,message:"Loading shapefile parser..."});try{this._shpjs=await import("shpjs"),this._initialized=!0,t?.({stage:"initializing",percent:100,message:"Shapefile parser ready"})}catch{throw new Error("shpjs is not installed. Install it with: npm install shpjs")}}}async convert(t,i,r){const n=performance.now();this.isReady()||await this.initialize(r),r?.({stage:"loading",percent:10,message:`Loading ${i}...`});try{r?.({stage:"converting",percent:30,message:"Parsing shapefile..."});const e=await(this._shpjs.default||this._shpjs)(t);r?.({stage:"converting",percent:80,message:"Building feature collection..."});let a;Array.isArray(e)?a={type:"FeatureCollection",features:e.flatMap(s=>s.features||[])}:e.type==="FeatureCollection"?a=e:e.type==="Feature"?a={type:"FeatureCollection",features:[e]}:a={type:"FeatureCollection",features:[{type:"Feature",properties:{},geometry:e}]};const p=new Set;for(const s of a.features)s.geometry&&p.add(s.geometry.type);const c=performance.now(),h={originalFormat:"shapefile",featureCount:a.features.length,geometryTypes:Array.from(p),fileSize:t.byteLength,conversionTimeMs:Math.round(c-n)};return r?.({stage:"complete",percent:100,message:`Converted ${a.features.length} features`}),{geojson:a,warnings:[],metadata:h}}catch(e){throw r?.({stage:"error",message:`Failed to parse shapefile: ${e instanceof Error?e.message:"Unknown error"}`}),e}}dispose(){this._shpjs=null,this._initialized=!1}},l=null;function u(){return l||(l=new o),l}Object.defineProperty(exports,"ShapefileConverter",{enumerable:!0,get:function(){return o}});Object.defineProperty(exports,"ShapefileConverter_exports",{enumerable:!0,get:function(){return w}});Object.defineProperty(exports,"getShapefileConverter",{enumerable:!0,get:function(){return u}});
|
|
@@ -1,6 +1,5 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { a as it, d as at, i as y, l as Q, o as G, p as nt, s as x, t as ot, u as te } from "./globals-Da065JQj.js";
|
|
2
2
|
import "./basedecoder-BliCKuUS.js";
|
|
3
|
-
import { a as nt, i as y, l as Q, o as G, s as x, t as ot, u as te } from "./globals-BKIWameS.js";
|
|
4
3
|
var lt = "Cannot convert undefined or null to object";
|
|
5
4
|
function A(e) {
|
|
6
5
|
return (t, ...r) => ct(e, t, r);
|
|
@@ -8,7 +7,7 @@ function A(e) {
|
|
|
8
7
|
function B(e, t) {
|
|
9
8
|
return A(ge(e, t).get);
|
|
10
9
|
}
|
|
11
|
-
var { apply: ct, construct:
|
|
10
|
+
var { apply: ct, construct: Ur, defineProperty: Nr, get: Lr, getOwnPropertyDescriptor: ge, getPrototypeOf: se, has: Cr, ownKeys: ht, set: zr, setPrototypeOf: Gr } = Reflect, { EPSILON: ft, MAX_SAFE_INTEGER: qr, isFinite: jr, isNaN: Hr } = Number, { iterator: Y, species: Yr, toStringTag: ut, for: $r } = Symbol, ie = Object, { create: ye, defineProperty: dt, freeze: Xr, is: Kr } = ie, fe = ie.prototype, Zr = fe.__lookupGetter__ ? A(fe.__lookupGetter__) : (e, t) => {
|
|
12
11
|
if (e == null) throw It(lt);
|
|
13
12
|
let r = ie(e);
|
|
14
13
|
do {
|
|
@@ -16,8 +15,8 @@ var { apply: ct, construct: Nr, defineProperty: Lr, get: Cr, getOwnPropertyDescr
|
|
|
16
15
|
if (s !== void 0)
|
|
17
16
|
return gt(s, "get") ? s.get : void 0;
|
|
18
17
|
} while ((r = se(r)) !== null);
|
|
19
|
-
}, gt = ie.hasOwn || A(fe.hasOwnProperty), De = Array,
|
|
20
|
-
})().next), bt = se(q), Ue = DataView.prototype, vt = A(Ue.getUint16),
|
|
18
|
+
}, gt = ie.hasOwn || A(fe.hasOwnProperty), De = Array, Jr = De.isArray, ae = De.prototype, Qr = A(ae.join), Wr = A(ae.push), es = A(ae.toLocaleString), Oe = ae[Y], yt = A(Oe), { abs: ts, trunc: rs } = Math, pe = ArrayBuffer, ss = pe.isView, Re = pe.prototype, is = A(Re.slice), as = B(Re, "byteLength"), xe = typeof SharedArrayBuffer < "u" ? SharedArrayBuffer : null, ns = xe && B(xe.prototype, "byteLength"), Me = se(Uint8Array), os = Me.from, E = Me.prototype, ls = E[Y], cs = A(E.keys), hs = A(E.values), fs = A(E.entries), us = A(E.set), ds = A(E.reverse), gs = A(E.fill), ys = A(E.copyWithin), ps = A(E.sort), ws = A(E.slice), ms = A(E.subarray), bs = B(E, "buffer"), vs = B(E, "byteOffset"), Is = B(E, "length"), As = B(E, ut), pt = Uint8Array, Be = Uint16Array, we = Uint32Array, wt = Float32Array, q = se([][Y]()), Ve = A(q.next), mt = A((function* () {
|
|
19
|
+
})().next), bt = se(q), Ue = DataView.prototype, vt = A(Ue.getUint16), Ts = A(Ue.setUint16), It = TypeError, At = WeakSet, Ne = At.prototype, Ss = A(Ne.add), Es = A(Ne.has), me = WeakMap, be = me.prototype, Le = A(be.get), _s = A(be.has), Tt = A(be.set), Ce = new me(), St = ye(null, {
|
|
21
20
|
next: { value: function() {
|
|
22
21
|
return Ve(Le(Ce, this));
|
|
23
22
|
} },
|
|
@@ -39,7 +38,7 @@ var _t = new me(), xt = ye(bt, { next: {
|
|
|
39
38
|
} });
|
|
40
39
|
for (const e of ht(q))
|
|
41
40
|
e !== "next" && dt(xt, e, ge(q, e));
|
|
42
|
-
var kt = 1 / ft, Pt = 6103515625e-14, ze = 9765625e-10,
|
|
41
|
+
var kt = 1 / ft, Pt = 6103515625e-14, ze = 9765625e-10, xs = ze * Pt, ks = ze * kt, Ge = new pe(4), Ft = new wt(Ge), Dt = new we(Ge), F = new Be(512), D = new pt(512);
|
|
43
42
|
for (let e = 0; e < 256; ++e) {
|
|
44
43
|
const t = e - 127;
|
|
45
44
|
t < -24 ? (F[e] = 0, F[e | 256] = 32768, D[e] = 24, D[e | 256] = 24) : t < -14 ? (F[e] = 1024 >> -t - 14, F[e | 256] = 1024 >> -t - 14 | 32768, D[e] = -t - 1, D[e | 256] = -t - 1) : t <= 15 ? (F[e] = t + 15 << 10, F[e | 256] = t + 15 << 10 | 32768, D[e] = 13, D[e | 256] = 13) : t < 128 ? (F[e] = 31744, F[e | 256] = 64512, D[e] = 24, D[e | 256] = 24) : (F[e] = 31744, F[e | 256] = 64512, D[e] = 13, D[e | 256] = 13);
|
|
@@ -241,7 +240,7 @@ var Xt = [
|
|
|
241
240
|
},
|
|
242
241
|
{
|
|
243
242
|
cases: 34887,
|
|
244
|
-
importFn: () => import("./lerc-
|
|
243
|
+
importFn: () => import("./lerc-CwzT0cMz.js").then(async (e) => (await e.zstd.init(), e)).then((e) => e.default),
|
|
245
244
|
decoderParameterFn: async (e) => ({
|
|
246
245
|
...await ee(e),
|
|
247
246
|
LercParameters: await e.loadValue("LercParameters")
|
|
@@ -1313,7 +1312,7 @@ var H = class $e extends Error {
|
|
|
1313
1312
|
}
|
|
1314
1313
|
}, Ir = /* @__PURE__ */ at(((e, t) => {
|
|
1315
1314
|
t.exports = {};
|
|
1316
|
-
})), ce = /* @__PURE__ */
|
|
1315
|
+
})), ce = /* @__PURE__ */ nt(Ir(), 1), Ar = class extends Ie {
|
|
1317
1316
|
constructor(e, t) {
|
|
1318
1317
|
super(), this.response = e, this.dataPromise = t;
|
|
1319
1318
|
}
|
|
@@ -1614,7 +1613,7 @@ var kr = class {
|
|
|
1614
1613
|
if (!e) return null;
|
|
1615
1614
|
const t = {};
|
|
1616
1615
|
for (let r = 4; r <= e[3] * 4; r += 4) {
|
|
1617
|
-
const s =
|
|
1616
|
+
const s = it[e[r]], i = e[r + 1] || null, a = e[r + 2], o = e[r + 3];
|
|
1618
1617
|
let n = null;
|
|
1619
1618
|
if (!i) n = o;
|
|
1620
1619
|
else {
|
|
@@ -1874,9 +1873,9 @@ var W = class extends Error {
|
|
|
1874
1873
|
return typeof this.source.close == "function" ? this.source.close() : !1;
|
|
1875
1874
|
}
|
|
1876
1875
|
};
|
|
1877
|
-
async function
|
|
1876
|
+
async function Ps(e, t = {}, r) {
|
|
1878
1877
|
return Or.fromSource(xr(e, t), void 0, r);
|
|
1879
1878
|
}
|
|
1880
1879
|
export {
|
|
1881
|
-
|
|
1880
|
+
Ps as fromUrl
|
|
1882
1881
|
};
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
const Pe=require("./ControlGrid-
|
|
1
|
+
const Pe=require("./ControlGrid-BBOB4hcq.cjs"),Pr=require("./basedecoder-Zw0CbD9L.cjs"),d=require("./globals-B4iCNAg9.cjs");var tt="Cannot convert undefined or null to object";function I(e){return(t,...r)=>rt(e,t,r)}function M(e,t){return I(he(e,t).get)}var{apply:rt,construct:xr,defineProperty:Fr,get:kr,getOwnPropertyDescriptor:he,getPrototypeOf:W,has:Dr,ownKeys:st,set:Or,setPrototypeOf:Rr}=Reflect,{EPSILON:it,MAX_SAFE_INTEGER:Mr,isFinite:Br,isNaN:Vr}=Number,{iterator:j,species:Ur,toStringTag:nt,for:Nr}=Symbol,ee=Object,{create:fe,defineProperty:at,freeze:Lr,is:Cr}=ee,oe=ee.prototype,zr=oe.__lookupGetter__?I(oe.__lookupGetter__):(e,t)=>{if(e==null)throw gt(tt);let r=ee(e);do{const s=he(r,t);if(s!==void 0)return ot(s,"get")?s.get:void 0}while((r=W(r))!==null)},ot=ee.hasOwn||I(oe.hasOwnProperty),xe=Array,qr=xe.isArray,te=xe.prototype,Gr=I(te.join),jr=I(te.push),Hr=I(te.toLocaleString),Fe=te[j],lt=I(Fe),{abs:Yr,trunc:$r}=Math,ue=ArrayBuffer,Xr=ue.isView,ke=ue.prototype,Kr=I(ke.slice),Zr=M(ke,"byteLength"),Ae=typeof SharedArrayBuffer<"u"?SharedArrayBuffer:null,Jr=Ae&&M(Ae.prototype,"byteLength"),De=W(Uint8Array),Qr=De.from,E=De.prototype,Wr=E[j],es=I(E.keys),ts=I(E.values),rs=I(E.entries),ss=I(E.set),is=I(E.reverse),ns=I(E.fill),as=I(E.copyWithin),os=I(E.sort),ls=I(E.slice),cs=I(E.subarray),hs=M(E,"buffer"),fs=M(E,"byteOffset"),us=M(E,"length"),ds=M(E,nt),ct=Uint8Array,Oe=Uint16Array,de=Uint32Array,ht=Float32Array,z=W([][j]()),Re=I(z.next),ft=I((function*(){})().next),ut=W(z),Me=DataView.prototype,dt=I(Me.getUint16),gs=I(Me.setUint16),gt=TypeError,yt=WeakSet,Be=yt.prototype,ys=I(Be.add),ps=I(Be.has),ge=WeakMap,ye=ge.prototype,Ve=I(ye.get),ws=I(ye.has),pt=I(ye.set),Ue=new ge,wt=fe(null,{next:{value:function(){return Re(Ve(Ue,this))}},[j]:{value:function(){return this}}});function mt(e){if(e[j]===Fe&&z.next===Re)return e;const t=fe(wt);return pt(Ue,t,lt(e)),t}var bt=new ge,Tt=fe(ut,{next:{value:function(){return ft(Ve(bt,this))},writable:!0,configurable:!0}});for(const e of st(z))e!=="next"&&at(Tt,e,he(z,e));var vt=1/it,It=6103515625e-14,Ne=.0009765625,ms=Ne*It,bs=Ne*vt,Le=new ue(4),At=new ht(Le),St=new de(Le),F=new Oe(512),k=new ct(512);for(let e=0;e<256;++e){const t=e-127;t<-24?(F[e]=0,F[e|256]=32768,k[e]=24,k[e|256]=24):t<-14?(F[e]=1024>>-t-14,F[e|256]=1024>>-t-14|32768,k[e]=-t-1,k[e|256]=-t-1):t<=15?(F[e]=t+15<<10,F[e|256]=t+15<<10|32768,k[e]=13,k[e|256]=13):t<128?(F[e]=31744,F[e|256]=64512,k[e]=24,k[e|256]=24):(F[e]=31744,F[e|256]=64512,k[e]=13,k[e|256]=13)}var pe=new de(2048);for(let e=1;e<1024;++e){let t=e<<13,r=0;for(;(t&8388608)===0;)t<<=1,r-=8388608;t&=-8388609,r+=947912704,pe[e]=t|r}for(let e=1024;e<2048;++e)pe[e]=939524096+(e-1024<<13);var B=new de(64);for(let e=1;e<31;++e)B[e]=e<<23;B[31]=1199570944;B[32]=2147483648;for(let e=33;e<63;++e)B[e]=2147483648+(e-32<<23);B[63]=3347054592;var Ce=new Oe(64);for(let e=1;e<64;++e)e!==32&&(Ce[e]=1024);function Et(e){const t=e>>10;return St[0]=pe[Ce[t]+(e&1023)]+B[t],At[0]}function ze(e,t,...r){return Et(dt(e,t,...mt(r)))}function ie(e,t,r){const s=r&&r.debug||!1;s&&console.log("[xml-utils] getting "+t+" in "+e);const i=typeof e=="object"?e.outer:e,n=i.slice(0,i.indexOf(">")+1),o=['"',"'"];for(let a=0;a<o.length;a++){const f=o[a],l=t+"\\="+f+"([^"+f+"]*)"+f;s&&console.log("[xml-utils] pattern:",l);const c=new RegExp(l).exec(n);if(s&&console.log("[xml-utils] match:",c),c)return c[1]}}function _t(e,t,r){const s=new RegExp(t).exec(e.slice(r));return s?r+s.index:-1}function Se(e,t,r){const s=new RegExp(t).exec(e.slice(r));return s?r+s.index+s[0].length-1:-1}function Ee(e,t){const r=new RegExp(t,"g"),s=e.match(r);return s?s.length:0}function Pt(e,t,r){const s=r&&r.debug||!1,i=r&&r.startIndex||0;s&&console.log("[xml-utils] starting findTagByName with",t," and ",r);const n=_t(e,`<${t}[
|
|
2
2
|
>/]`,i);if(s&&console.log("[xml-utils] start:",n),n===-1)return;const o=e.slice(n+t.length);let a=Se(o,"^[^<]*[ /]>",0);const f=a!==-1&&o[a-1]==="/";if(s&&console.log("[xml-utils] selfClosing:",f),f===!1){let g=0,u=1,y=0;for(;(a=Se(o,"[ /]"+t+">",g))!==-1;){const p=o.substring(g,a+1);if(u+=Ee(p,"<"+t+`[
|
|
3
|
-
>]`),y+=Ee(p,"</"+t+">"),y>=u)break;g=a}}const l=n+t.length+a+1;if(s&&console.log("[xml-utils] end:",l),l===-1)return;const c=e.slice(n,l);let h;return f?h=null:h=c.slice(c.indexOf(">")+1,c.lastIndexOf("<")),{inner:h,outer:c,start:n,end:l}}function xt(e,t,r){const s=[],i=r&&r.debug||!1,n=r&&typeof r.nested=="boolean"?r.nested:!0;let o=r&&r.startIndex||0,a;for(;a=Pt(e,t,{debug:i,startIndex:o});)n?o=a.start+1+t.length:o=a.end,s.push(a);return i&&console.log("findTagsByName found",s.length,"tags"),s}function Ft(e,t){const{width:r,height:s}=e,i=new Uint8Array(r*s*3);let n;for(let o=0,a=0;o<e.length;++o,a+=3)n=256-e[o]/t*256,i[a]=n,i[a+1]=n,i[a+2]=n;return i}function kt(e,t){const{width:r,height:s}=e,i=new Uint8Array(r*s*3);let n;for(let o=0,a=0;o<e.length;++o,a+=3)n=e[o]/t*256,i[a]=n,i[a+1]=n,i[a+2]=n;return i}function Dt(e,t){const{width:r,height:s}=e,i=new Uint8Array(r*s*3),n=t.length/3,o=t.length/3*2;for(let a=0,f=0;a<e.length;++a,f+=3){const l=e[a];i[f]=t[l]/65536*256,i[f+1]=t[l+n]/65536*256,i[f+2]=t[l+o]/65536*256}return i}function Ot(e){const{width:t,height:r}=e,s=new Uint8Array(t*r*3);for(let i=0,n=0;i<e.length;i+=4,n+=3){const o=e[i],a=e[i+1],f=e[i+2],l=e[i+3];s[n]=255*((255-o)/256)*((255-l)/256),s[n+1]=255*((255-a)/256)*((255-l)/256),s[n+2]=255*((255-f)/256)*((255-l)/256)}return s}function Rt(e){const{width:t,height:r}=e,s=new Uint8ClampedArray(t*r*3);for(let i=0,n=0;i<e.length;i+=3,n+=3){const o=e[i],a=e[i+1],f=e[i+2];s[n]=o+1.402*(f-128),s[n+1]=o-.34414*(a-128)-.71414*(f-128),s[n+2]=o+1.772*(a-128)}return s}var Mt=.95047,Bt=1,Vt=1.08883;function Ut(e){const{width:t,height:r}=e,s=new Uint8Array(t*r*3);for(let i=0,n=0;i<e.length;i+=3,n+=3){const o=e[i+0],a=e[i+1]<<24>>24,f=e[i+2]<<24>>24;let l=(o+16)/116,c=a/500+l,h=l-f/200,g,u,y;c=Mt*(c*c*c>.008856?c*c*c:(c-16/116)/7.787),l=Bt*(l*l*l>.008856?l*l*l:(l-16/116)/7.787),h=Vt*(h*h*h>.008856?h*h*h:(h-16/116)/7.787),g=c*3.2406+l*-1.5372+h*-.4986,u=c*-.9689+l*1.8758+h*.0415,y=c*.0557+l*-.204+h*1.057,g=g>.0031308?1.055*g**(1/2.4)-.055:12.92*g,u=u>.0031308?1.055*u**(1/2.4)-.055:12.92*u,y=y>.0031308?1.055*y**(1/2.4)-.055:12.92*y,s[n]=Math.max(0,Math.min(1,g))*255,s[n+1]=Math.max(0,Math.min(1,u))*255,s[n+2]=Math.max(0,Math.min(1,y))*255}return s}var q=new Map;async function J(e){const t=!e.hasTag("StripOffsets");return{tileWidth:t?await e.loadValue("TileWidth"):await e.loadValue("ImageWidth"),tileHeight:t?await e.loadValue("TileLength"):await e.loadValue("RowsPerStrip")||await e.loadValue("ImageLength"),planarConfiguration:await e.loadValue("PlanarConfiguration"),bitsPerSample:await e.loadValue("BitsPerSample"),predictor:await e.loadValue("Predictor")||1}}function Nt(e,t,r=J,s=!0){Array.isArray(e)||(e=[e]),e.forEach(i=>{q.set(i,{importFn:t,decoderParameterFn:r,preferWorker:s})})}async function Lt(e,t){if(!q.has(e))throw new Error(`Unknown compression method identifier: ${e}`);const{decoderParameterFn:r}=q.get(e);return r(t)}async function Ct(e,t){if(!q.has(e))throw new Error(`Unknown compression method identifier: ${e}`);const{importFn:r}=q.get(e);return new(await r())(t)}var zt=[{cases:[void 0,1],importFn:()=>Promise.resolve().then(()=>require("./raw-C-CSxCoU.cjs")).then(e=>e.default),preferWorker:!1},{cases:5,importFn:()=>Promise.resolve().then(()=>require("./lzw-1HaU0PJK.cjs")).then(e=>e.default)},{cases:6,importFn:()=>{throw new Error("old style JPEG compression is not supported.")}},{cases:7,importFn:()=>Promise.resolve().then(()=>require("./jpeg-B6Sg6W8k.cjs")).then(e=>e.default),decoderParameterFn:async e=>({...await J(e),JPEGTables:await e.loadValue("JPEGTables")})},{cases:[8,32946],importFn:()=>Promise.resolve().then(()=>require("./deflate-DNeBKDsy.cjs")).then(e=>e.default)},{cases:32773,importFn:()=>Promise.resolve().then(()=>require("./packbits-D5Zovac7.cjs")).then(e=>e.default)},{cases:34887,importFn:()=>Promise.resolve().then(()=>require("./lerc-CPfGdIIh.cjs")).then(async e=>(await e.zstd.init(),e)).then(e=>e.default),decoderParameterFn:async e=>({...await J(e),LercParameters:await e.loadValue("LercParameters")})},{cases:5e4,importFn:()=>Promise.resolve().then(()=>require("./zstd-B3Xa90HD.cjs")).then(async e=>(await e.zstd.init(),e)).then(e=>e.default)},{cases:50001,importFn:()=>Promise.resolve().then(()=>require("./webimage-Bh2pNwjN.cjs")).then(e=>e.default),decoderParameterFn:async e=>({...await J(e),samplesPerPixel:Number(await e.loadValue("SamplesPerPixel"))||4}),preferWorker:!1}];for(const e of zt){const{cases:t,importFn:r,decoderParameterFn:s,preferWorker:i}=e;Nt(t,r,s,i)}function re(e,t,r,s=1){return new(Object.getPrototypeOf(e)).constructor(t*r*s)}function qt(e,t,r,s,i){const n=t/s,o=r/i;return e.map(a=>{const f=re(a,s,i);for(let l=0;l<i;++l){const c=Math.min(Math.round(o*l),r-1);for(let h=0;h<s;++h){const g=Math.min(Math.round(n*h),t-1),u=a[c*t+g];f[l*s+h]=u}}return f})}function R(e,t,r){return(1-r)*e+r*t}function Gt(e,t,r,s,i){const n=t/s,o=r/i;return e.map(a=>{const f=re(a,s,i);for(let l=0;l<i;++l){const c=o*l,h=Math.floor(c),g=Math.min(Math.ceil(c),r-1);for(let u=0;u<s;++u){const y=n*u,p=y%1,w=Math.floor(y),m=Math.min(Math.ceil(y),t-1),b=a[h*t+w],v=a[h*t+m],S=a[g*t+w],T=a[g*t+m],A=R(R(b,v,p),R(S,T,p),c%1);f[l*s+u]=A}}return f})}function jt(e,t,r,s,i,n="nearest"){switch(n.toLowerCase()){case"nearest":return qt(e,t,r,s,i);case"bilinear":case"linear":return Gt(e,t,r,s,i);default:throw new Error(`Unsupported resampling method: '${n}'`)}}function Ht(e,t,r,s,i,n){const o=t/s,a=r/i,f=re(e,s,i,n);for(let l=0;l<i;++l){const c=Math.min(Math.round(a*l),r-1);for(let h=0;h<s;++h){const g=Math.min(Math.round(o*h),t-1);for(let u=0;u<n;++u){const y=e[c*t*n+g*n+u];f[l*s*n+h*n+u]=y}}}return f}function Yt(e,t,r,s,i,n){const o=t/s,a=r/i,f=re(e,s,i,n);for(let l=0;l<i;++l){const c=a*l,h=Math.floor(c),g=Math.min(Math.ceil(c),r-1);for(let u=0;u<s;++u){const y=o*u,p=y%1,w=Math.floor(y),m=Math.min(Math.ceil(y),t-1);for(let b=0;b<n;++b){const v=e[h*t*n+w*n+b],S=e[h*t*n+m*n+b],T=e[g*t*n+w*n+b],A=e[g*t*n+m*n+b],P=R(R(v,S,p),R(T,A,p),c%1);f[l*s*n+u*n+b]=P}}}return f}function $t(e,t,r,s,i,n,o="nearest"){switch(o.toLowerCase()){case"nearest":return Ht(e,t,r,s,i,n);case"bilinear":case"linear":return Yt(e,t,r,s,i,n);default:throw new Error(`Unsupported resampling method: '${o}'`)}}function Xt(e,t,r){let s=0;for(let i=t;i<r;++i)s+=e[i];return s}function le(e,t,r){let s;switch(e){case 1:t<=8?s=Uint8Array:t<=16?s=Uint16Array:t<=32&&(s=Uint32Array);break;case 2:t===8?s=Int8Array:t===16?s=Int16Array:t===32&&(s=Int32Array);break;case 3:switch(t){case 16:case 32:s=Float32Array;break;case 64:s=Float64Array;break;default:break}break;default:break}if(s){if(typeof r=="number")return new s(r);if(r instanceof ArrayBuffer)return new s(r)}throw Error("Unsupported data format/bitsPerSample")}function Kt(e,t){return(e===1||e===2)&&t<=32&&t%8===0?!1:!(e===3&&(t===16||t===32||t===64))}function Zt(e,t,r,s,i,n,o){const a=new DataView(e),f=r===2?o*n:o*n*s,l=r===2?1:s,c=le(t,i,f),h=parseInt("1".repeat(i),2);if(t===1){let g;r===1?g=s*i:g=i;let u=n*g;(u&7)!==0&&(u=u+7&-8);for(let y=0;y<o;++y){const p=y*u;for(let w=0;w<n;++w){const m=p+w*l*i;for(let b=0;b<l;++b){const v=m+b*i,S=(y*n+w)*l+b,T=Math.floor(v/8),A=v%8;A+i<=8?c[S]=a.getUint8(T)>>8-i-A&h:A+i<=16?c[S]=a.getUint16(T)>>16-i-A&h:A+i<=24?c[S]=(a.getUint16(T)<<8|a.getUint8(T+2))>>24-i-A&h:c[S]=a.getUint32(T)>>32-i-A&h}}}}return c.buffer}var Jt=class{constructor(e,t,r,s){this.fileDirectory=e,this.littleEndian=t,this.tiles=r?[]:null,this.isTiled=!e.hasTag("StripOffsets");const i=e.getValue("PlanarConfiguration")??1;if(i!==1&&i!==2)throw new Error("Invalid planar configuration.");this.planarConfiguration=i,this.source=s}getFileDirectory(){return this.fileDirectory}getGeoKeys(){return this.fileDirectory.parseGeoKeyDirectory()}getWidth(){return this.fileDirectory.getValue("ImageWidth")||0}getHeight(){return this.fileDirectory.getValue("ImageLength")||0}getSamplesPerPixel(){return this.fileDirectory.getValue("SamplesPerPixel")??1}getTileWidth(){return this.isTiled?this.fileDirectory.getValue("TileWidth")||0:this.getWidth()}getTileHeight(){if(this.isTiled)return this.fileDirectory.getValue("TileLength")||0;const e=this.fileDirectory.hasTag("RowsPerStrip")&&this.fileDirectory.getValue("RowsPerStrip");return e?Math.min(e,this.getHeight()):this.getHeight()}getBlockWidth(){return this.getTileWidth()}getBlockHeight(e){return this.isTiled||(e+1)*this.getTileHeight()<=this.getHeight()?this.getTileHeight():this.getHeight()-e*this.getTileHeight()}getBytesPerPixel(){let e=0;const t=this.fileDirectory.getValue("BitsPerSample")||[];for(let r=0;r<t.length;++r)e+=this.getSampleByteSize(r);return e}getSampleByteSize(e){const t=this.fileDirectory.getValue("BitsPerSample")||[];if(e>=t.length)throw new RangeError(`Sample index ${e} is out of range.`);return Math.ceil(t[e]/8)}getReaderForSample(e){const t=this.fileDirectory.getValue("SampleFormat"),r=t?t[e]:1,s=(this.fileDirectory.getValue("BitsPerSample")||[])[e];switch(r){case 1:if(s<=8)return DataView.prototype.getUint8;if(s<=16)return DataView.prototype.getUint16;if(s<=32)return DataView.prototype.getUint32;break;case 2:if(s<=8)return DataView.prototype.getInt8;if(s<=16)return DataView.prototype.getInt16;if(s<=32)return DataView.prototype.getInt32;break;case 3:switch(s){case 16:return function(i,n){return ze(this,i,n)};case 32:return DataView.prototype.getFloat32;case 64:return DataView.prototype.getFloat64;default:break}break;default:break}throw Error("Unsupported data format/bitsPerSample")}getSampleFormat(e=0){const t=this.fileDirectory.getValue("SampleFormat");return t?t[e]:1}getBitsPerSample(e=0){const t=this.fileDirectory.getValue("BitsPerSample");return t?t[e]:0}getArrayForSample(e,t){return le(this.getSampleFormat(e),this.getBitsPerSample(e),t)}async getTileOrStrip(e,t,r,s,i){const n=Math.ceil(this.getWidth()/this.getTileWidth()),o=Math.ceil(this.getHeight()/this.getTileHeight());let a;const{tiles:f}=this;if(this.planarConfiguration===1?a=t*n+e:this.planarConfiguration===2&&(a=r*n*o+t*n+e),a===void 0)throw new Error("Could not determine tile or strip index.");let l,c;if(this.isTiled?(l=Number(await this.fileDirectory.loadValueIndexed("TileOffsets",a)),c=Number(await this.fileDirectory.loadValueIndexed("TileByteCounts",a))):(l=Number(await this.fileDirectory.loadValueIndexed("StripOffsets",a)),c=Number(await this.fileDirectory.loadValueIndexed("StripByteCounts",a))),c===0){const u=this.getBlockHeight(t)*this.getTileWidth(),y=this.planarConfiguration===2?this.getSampleByteSize(r):this.getBytesPerPixel(),p=new ArrayBuffer(u*y);return this.getArrayForSample(r,p).fill(this.getGDALNoData()||0),{x:e,y:t,sample:r,data:p}}const h=(await this.source.fetch([{offset:l,length:c}],i))[0];let g;return f===null||!f[a]?(g=(async()=>{let u=await s.decode(h);const y=this.getSampleFormat(),p=this.getBitsPerSample();return Kt(y,p)&&(u=Zt(u,y,this.planarConfiguration,this.getSamplesPerPixel(),p,this.getTileWidth(),this.getBlockHeight(t))),u})(),f!==null&&(f[a]=g)):g=f[a],{x:e,y:t,sample:r,data:await g}}async _readRaster(e,t,r,s,i,n,o,a,f){const l=this.getTileWidth(),c=this.getTileHeight(),h=this.getWidth(),g=this.getHeight(),u=Math.max(Math.floor(e[0]/l),0),y=Math.min(Math.ceil(e[2]/l),Math.ceil(h/l)),p=Math.max(Math.floor(e[1]/c),0),w=Math.min(Math.ceil(e[3]/c),Math.ceil(g/c)),m=e[2]-e[0];let b=this.getBytesPerPixel();const v=[],S=[];for(let _=0;_<t.length;++_){if(this.planarConfiguration===1){const x=await this.fileDirectory.loadValue("BitsPerSample");if(typeof x!="object")throw new Error("Expected BitsPerSample to be an array or typed array.");v.push(Xt(x,0,t[_])/8)}else v.push(0);S.push(this.getReaderForSample(t[_]))}const T=[],{littleEndian:A}=this;for(let _=p;_<w;++_)for(let x=u;x<y;++x){let H;this.planarConfiguration===1&&(H=this.getTileOrStrip(x,_,0,i,f));for(let Y=0;Y<t.length;++Y){const $=Y,ve=t[Y];if(this.planarConfiguration===2&&(b=this.getSampleByteSize(ve),H=this.getTileOrStrip(x,_,ve,i,f)),!H)throw new Error("Could not get tile or strip data.");const Ye=H.then(V=>{const $e=V.data,Xe=new DataView($e),se=this.getBlockHeight(V.y),U=V.y*c,X=V.x*l,Ke=U+se,Ze=(V.x+1)*l,Je=S[$],Qe=Math.min(se,se-(Ke-e[3]),g-U),We=Math.min(l,l-(Ze-e[2]),h-X);for(let N=Math.max(0,e[1]-U);N<Qe;++N)for(let L=Math.max(0,e[0]-X);L<We;++L){const et=(N*l+L)*b,Ie=Je.call(Xe,et+v[$],A);let K;s?(K=(N+U-e[1])*m*t.length+(L+X-e[0])*t.length+$,r[K]=Ie):(K=(N+U-e[1])*m+L+X-e[0],r[$][K]=Ie)}});T.push(Ye)}}if(await Promise.all(T),n&&e[2]-e[0]!==n||o&&e[3]-e[1]!==o){let _;s?_=$t(r,e[2]-e[0],e[3]-e[1],n,o,t.length,a):_=jt(r,e[2]-e[0],e[3]-e[1],n,o,a);const x=_;return x.width=n??e[2]-e[0],x.height=o??e[3]-e[1],x}const P=r;return P.width=n||e[2]-e[0],P.height=o||e[3]-e[1],P}async readRasters(e={}){const{window:t,samples:r=[],pool:s=null,width:i,height:n,resampleMethod:o,fillValue:a,signal:f}=e,l="interleave"in e&&e.interleave,c=t||[0,0,this.getWidth(),this.getHeight()];if(c[0]>c[2]||c[1]>c[3])throw new Error("Invalid subsets");const h=(c[2]-c[0])*(c[3]-c[1]),g=this.getSamplesPerPixel();if(!r||!r.length)for(let m=0;m<g;++m)r.push(m);else for(let m=0;m<r.length;++m)if(r[m]>=g)return Promise.reject(new RangeError(`Invalid sample index '${r[m]}'.`));let u;if(l){const{fileDirectory:m}=this,b=m.getValue("SampleFormat"),v=b?Math.max.apply(null,Array.from(b)):1;if(v!==1&&v!==2&&v!==3)throw new Error("Unsupported sample format for interleaved data. Must be 1, 2, or 3.");const S=m.getValue("BitsPerSample");if(u=le(v,S?Math.max.apply(null,Array.from(S)):8,h*r.length),a){if(Array.isArray(a))throw new Error("When reading interleaved data, fillValue must be a single number.");u.fill(a)}}else{u=[];for(let m=0;m<r.length;++m){const b=this.getArrayForSample(r[m],h);Array.isArray(a)&&m<a.length?b.fill(a[m]):a&&!Array.isArray(a)&&b.fill(a),u.push(b)}}const y=this.fileDirectory.getValue("Compression")||1,p=await Lt(y,this.fileDirectory),w=s?s.bindParameters(y,p):await Ct(y,p);return await this._readRaster(c,r,u,l,w,i,n,o,f)}async readRGB(e={}){const{window:t,pool:r=null,width:s,height:i,resampleMethod:n,enableAlpha:o=!1,signal:a}=e,f=("interleave"in e&&e.interleave)??!1,l=t||[0,0,this.getWidth(),this.getHeight()];if(l[0]>l[2]||l[1]>l[3])throw new Error("Invalid subsets");const c=this.fileDirectory.getValue("PhotometricInterpretation");if(c===d.photometricInterpretations.RGB){let b=[0,1,2];const v=this.fileDirectory.getValue("ExtraSamples");if(v&&v[0]!==d.ExtraSamplesValues.Unspecified&&o){b=[];const S=this.fileDirectory.getValue("BitsPerSample")||[];for(let T=0;T<S.length;T+=1)b.push(T)}return this.readRasters({window:t,interleave:f,samples:b,pool:r,width:s,height:i,resampleMethod:n,signal:a})}let h;switch(c){case d.photometricInterpretations.WhiteIsZero:case d.photometricInterpretations.BlackIsZero:case d.photometricInterpretations.Palette:h=[0];break;case d.photometricInterpretations.CMYK:h=[0,1,2,3];break;case d.photometricInterpretations.YCbCr:case d.photometricInterpretations.CIELab:h=[0,1,2];break;default:throw new Error("Invalid or unsupported photometric interpretation.")}const g={window:l,interleave:!0,samples:h,pool:r,width:s,height:i,resampleMethod:n,signal:a},{fileDirectory:u}=this,y=await this.readRasters(g),p=2**this.getBitsPerSample(0);let w;switch(c){case d.photometricInterpretations.WhiteIsZero:w=Ft(y,p);break;case d.photometricInterpretations.BlackIsZero:w=kt(y,p);break;case d.photometricInterpretations.Palette:w=Dt(y,await u.loadValue("ColorMap"));break;case d.photometricInterpretations.CMYK:w=Ot(y);break;case d.photometricInterpretations.YCbCr:w=Rt(y);break;case d.photometricInterpretations.CIELab:w=Ut(y);break;default:throw new Error("Unsupported photometric interpretation.")}if(!f){const b=new Uint8Array(w.length/3),v=new Uint8Array(w.length/3),S=new Uint8Array(w.length/3);for(let T=0,A=0;T<w.length;T+=3,++A)b[A]=w[T],v[A]=w[T+1],S[A]=w[T+2];w=[b,v,S]}const m=w;return m.width=y.width,m.height=y.height,m}async getTiePoints(){if(!this.fileDirectory.hasTag("ModelTiepoint"))return[];const e=await this.fileDirectory.loadValue("ModelTiepoint");if(typeof e!="object")throw new Error("Expected ModelTiepoint to be an array or typed array.");const t=[];for(let r=0;r<e.length;r+=6)t.push({i:e[r],j:e[r+1],k:e[r+2],x:e[r+3],y:e[r+4],z:e[r+5]});return t}async getGDALMetadata(e=null){const t={};if(!this.fileDirectory.hasTag("GDAL_METADATA"))return null;let r=xt(await this.fileDirectory.loadValue("GDAL_METADATA"),"Item");e===null?r=r.filter(s=>ie(s,"sample")===void 0):r=r.filter(s=>Number(ie(s,"sample"))===e);for(let s=0;s<r.length;++s){const i=r[s];t[ie(i,"name")]=i.inner}return t}getGDALNoData(){const e=this.fileDirectory.hasTag("GDAL_NODATA")&&this.fileDirectory.getValue("GDAL_NODATA");return e?Number(e.substring(0,e.length-1)):null}getOrigin(){const e=this.fileDirectory.getValue("ModelTiepoint"),t=this.fileDirectory.getValue("ModelTransformation");if(e&&e.length===6)return[e[3],e[4],e[5]];if(t)return[t[3],t[7],t[11]];throw new Error("The image does not have an affine transformation.")}getResolution(e=null){const t=this.fileDirectory.getValue("ModelPixelScale"),r=this.fileDirectory.getValue("ModelTransformation");if(t)return[t[0],-t[1],t[2]];if(r)return r[1]===0&&r[4]===0?[r[0],-r[5],r[10]]:[Math.sqrt(r[0]*r[0]+r[4]*r[4]),-Math.sqrt(r[1]*r[1]+r[5]*r[5]),r[10]];if(e){const[s,i,n]=e.getResolution();return[s*e.getWidth()/this.getWidth(),i*e.getHeight()/this.getHeight(),n*e.getWidth()/this.getWidth()]}throw new Error("The image does not have an affine transformation.")}pixelIsArea(){return this.getGeoKeys()?.GTRasterTypeGeoKey===1}getBoundingBox(e=!1){const t=this.getHeight(),r=this.getWidth(),s=this.fileDirectory.getValue("ModelTransformation");if(s&&!e){const[i,n,,o,a,f,,l]=s,c=[[0,0],[0,t],[r,0],[r,t]].map(([u,y])=>[o+i*u+n*y,l+a*u+f*y]),h=c.map(u=>u[0]),g=c.map(u=>u[1]);return[Math.min(...h),Math.min(...g),Math.max(...h),Math.max(...g)]}else{const i=this.getOrigin(),n=this.getResolution(),o=i[0],a=i[1],f=o+n[0]*r,l=a+n[1]*t;return[Math.min(o,f),Math.min(a,l),Math.max(o,f),Math.max(a,l)]}}},Qt=class{constructor(e){this._dataView=new DataView(e)}get buffer(){return this._dataView.buffer}getUint64(e,t){const r=this.getUint32(e,t),s=this.getUint32(e+4,t);let i;if(t){if(i=r+2**32*s,!Number.isSafeInteger(i))throw new Error(`${i} exceeds MAX_SAFE_INTEGER. Precision may be lost. Please report if you get this message to https://github.com/geotiffjs/geotiff.js/issues`);return i}if(i=2**32*r+s,!Number.isSafeInteger(i))throw new Error(`${i} exceeds MAX_SAFE_INTEGER. Precision may be lost. Please report if you get this message to https://github.com/geotiffjs/geotiff.js/issues`);return i}getInt64(e,t){let r=0;const s=(this._dataView.getUint8(e+(t?7:0))&128)>0;let i=!0;for(let n=0;n<8;n++){let o=this._dataView.getUint8(e+(t?n:7-n));s&&(i?o!==0&&(o=~(o-1)&255,i=!1):o=~o&255),r+=o*256**n}return s&&(r=-r),r}getUint8(e){return this._dataView.getUint8(e)}getInt8(e){return this._dataView.getInt8(e)}getUint16(e,t){return this._dataView.getUint16(e,t)}getInt16(e,t){return this._dataView.getInt16(e,t)}getUint32(e,t){return this._dataView.getUint32(e,t)}getInt32(e,t){return this._dataView.getInt32(e,t)}getFloat16(e,t){return ze(this._dataView,e,t)}getFloat32(e,t){return this._dataView.getFloat32(e,t)}getFloat64(e,t){return this._dataView.getFloat64(e,t)}},Q=class{constructor(e,t,r,s){this._dataView=new DataView(e),this._sliceOffset=t,this._littleEndian=r,this._bigTiff=s}get sliceOffset(){return this._sliceOffset}get sliceTop(){return this._sliceOffset+this.buffer.byteLength}get littleEndian(){return this._littleEndian}get bigTiff(){return this._bigTiff}get buffer(){return this._dataView.buffer}covers(e,t){return this.sliceOffset<=e&&this.sliceTop>=e+t}readUint8(e){return this._dataView.getUint8(e-this._sliceOffset)}readInt8(e){return this._dataView.getInt8(e-this._sliceOffset)}readUint16(e){return this._dataView.getUint16(e-this._sliceOffset,this._littleEndian)}readInt16(e){return this._dataView.getInt16(e-this._sliceOffset,this._littleEndian)}readUint32(e){return this._dataView.getUint32(e-this._sliceOffset,this._littleEndian)}readInt32(e){return this._dataView.getInt32(e-this._sliceOffset,this._littleEndian)}readFloat32(e){return this._dataView.getFloat32(e-this._sliceOffset,this._littleEndian)}readFloat64(e){return this._dataView.getFloat64(e-this._sliceOffset,this._littleEndian)}readUint64(e){const t=this.readUint32(e),r=this.readUint32(e+4);let s;if(this._littleEndian){if(s=t+2**32*r,!Number.isSafeInteger(s))throw new Error(`${s} exceeds MAX_SAFE_INTEGER. Precision may be lost. Please report if you get this message to https://github.com/geotiffjs/geotiff.js/issues`);return s}if(s=2**32*t+r,!Number.isSafeInteger(s))throw new Error(`${s} exceeds MAX_SAFE_INTEGER. Precision may be lost. Please report if you get this message to https://github.com/geotiffjs/geotiff.js/issues`);return s}readInt64(e){let t=0;const r=(this._dataView.getUint8(e+(this._littleEndian?7:0))&128)>0;let s=!0;for(let i=0;i<8;i++){let n=this._dataView.getUint8(e+(this._littleEndian?i:7-i));r&&(s?n!==0&&(n=~(n-1)&255,s=!1):n=~n&255),t+=n*256**i}return r&&(t=-t),t}readOffset(e){return this._bigTiff?this.readUint64(e):this.readUint32(e)}},Wt=`\r
|
|
3
|
+
>]`),y+=Ee(p,"</"+t+">"),y>=u)break;g=a}}const l=n+t.length+a+1;if(s&&console.log("[xml-utils] end:",l),l===-1)return;const c=e.slice(n,l);let h;return f?h=null:h=c.slice(c.indexOf(">")+1,c.lastIndexOf("<")),{inner:h,outer:c,start:n,end:l}}function xt(e,t,r){const s=[],i=r&&r.debug||!1,n=r&&typeof r.nested=="boolean"?r.nested:!0;let o=r&&r.startIndex||0,a;for(;a=Pt(e,t,{debug:i,startIndex:o});)n?o=a.start+1+t.length:o=a.end,s.push(a);return i&&console.log("findTagsByName found",s.length,"tags"),s}function Ft(e,t){const{width:r,height:s}=e,i=new Uint8Array(r*s*3);let n;for(let o=0,a=0;o<e.length;++o,a+=3)n=256-e[o]/t*256,i[a]=n,i[a+1]=n,i[a+2]=n;return i}function kt(e,t){const{width:r,height:s}=e,i=new Uint8Array(r*s*3);let n;for(let o=0,a=0;o<e.length;++o,a+=3)n=e[o]/t*256,i[a]=n,i[a+1]=n,i[a+2]=n;return i}function Dt(e,t){const{width:r,height:s}=e,i=new Uint8Array(r*s*3),n=t.length/3,o=t.length/3*2;for(let a=0,f=0;a<e.length;++a,f+=3){const l=e[a];i[f]=t[l]/65536*256,i[f+1]=t[l+n]/65536*256,i[f+2]=t[l+o]/65536*256}return i}function Ot(e){const{width:t,height:r}=e,s=new Uint8Array(t*r*3);for(let i=0,n=0;i<e.length;i+=4,n+=3){const o=e[i],a=e[i+1],f=e[i+2],l=e[i+3];s[n]=255*((255-o)/256)*((255-l)/256),s[n+1]=255*((255-a)/256)*((255-l)/256),s[n+2]=255*((255-f)/256)*((255-l)/256)}return s}function Rt(e){const{width:t,height:r}=e,s=new Uint8ClampedArray(t*r*3);for(let i=0,n=0;i<e.length;i+=3,n+=3){const o=e[i],a=e[i+1],f=e[i+2];s[n]=o+1.402*(f-128),s[n+1]=o-.34414*(a-128)-.71414*(f-128),s[n+2]=o+1.772*(a-128)}return s}var Mt=.95047,Bt=1,Vt=1.08883;function Ut(e){const{width:t,height:r}=e,s=new Uint8Array(t*r*3);for(let i=0,n=0;i<e.length;i+=3,n+=3){const o=e[i+0],a=e[i+1]<<24>>24,f=e[i+2]<<24>>24;let l=(o+16)/116,c=a/500+l,h=l-f/200,g,u,y;c=Mt*(c*c*c>.008856?c*c*c:(c-16/116)/7.787),l=Bt*(l*l*l>.008856?l*l*l:(l-16/116)/7.787),h=Vt*(h*h*h>.008856?h*h*h:(h-16/116)/7.787),g=c*3.2406+l*-1.5372+h*-.4986,u=c*-.9689+l*1.8758+h*.0415,y=c*.0557+l*-.204+h*1.057,g=g>.0031308?1.055*g**(1/2.4)-.055:12.92*g,u=u>.0031308?1.055*u**(1/2.4)-.055:12.92*u,y=y>.0031308?1.055*y**(1/2.4)-.055:12.92*y,s[n]=Math.max(0,Math.min(1,g))*255,s[n+1]=Math.max(0,Math.min(1,u))*255,s[n+2]=Math.max(0,Math.min(1,y))*255}return s}var q=new Map;async function J(e){const t=!e.hasTag("StripOffsets");return{tileWidth:t?await e.loadValue("TileWidth"):await e.loadValue("ImageWidth"),tileHeight:t?await e.loadValue("TileLength"):await e.loadValue("RowsPerStrip")||await e.loadValue("ImageLength"),planarConfiguration:await e.loadValue("PlanarConfiguration"),bitsPerSample:await e.loadValue("BitsPerSample"),predictor:await e.loadValue("Predictor")||1}}function Nt(e,t,r=J,s=!0){Array.isArray(e)||(e=[e]),e.forEach(i=>{q.set(i,{importFn:t,decoderParameterFn:r,preferWorker:s})})}async function Lt(e,t){if(!q.has(e))throw new Error(`Unknown compression method identifier: ${e}`);const{decoderParameterFn:r}=q.get(e);return r(t)}async function Ct(e,t){if(!q.has(e))throw new Error(`Unknown compression method identifier: ${e}`);const{importFn:r}=q.get(e);return new(await r())(t)}var zt=[{cases:[void 0,1],importFn:()=>Promise.resolve().then(()=>require("./raw-C-CSxCoU.cjs")).then(e=>e.default),preferWorker:!1},{cases:5,importFn:()=>Promise.resolve().then(()=>require("./lzw-1HaU0PJK.cjs")).then(e=>e.default)},{cases:6,importFn:()=>{throw new Error("old style JPEG compression is not supported.")}},{cases:7,importFn:()=>Promise.resolve().then(()=>require("./jpeg-B6Sg6W8k.cjs")).then(e=>e.default),decoderParameterFn:async e=>({...await J(e),JPEGTables:await e.loadValue("JPEGTables")})},{cases:[8,32946],importFn:()=>Promise.resolve().then(()=>require("./deflate-DNeBKDsy.cjs")).then(e=>e.default)},{cases:32773,importFn:()=>Promise.resolve().then(()=>require("./packbits-D5Zovac7.cjs")).then(e=>e.default)},{cases:34887,importFn:()=>Promise.resolve().then(()=>require("./lerc-cUMeQO-8.cjs")).then(async e=>(await e.zstd.init(),e)).then(e=>e.default),decoderParameterFn:async e=>({...await J(e),LercParameters:await e.loadValue("LercParameters")})},{cases:5e4,importFn:()=>Promise.resolve().then(()=>require("./zstd-B3Xa90HD.cjs")).then(async e=>(await e.zstd.init(),e)).then(e=>e.default)},{cases:50001,importFn:()=>Promise.resolve().then(()=>require("./webimage-Bh2pNwjN.cjs")).then(e=>e.default),decoderParameterFn:async e=>({...await J(e),samplesPerPixel:Number(await e.loadValue("SamplesPerPixel"))||4}),preferWorker:!1}];for(const e of zt){const{cases:t,importFn:r,decoderParameterFn:s,preferWorker:i}=e;Nt(t,r,s,i)}function re(e,t,r,s=1){return new(Object.getPrototypeOf(e)).constructor(t*r*s)}function qt(e,t,r,s,i){const n=t/s,o=r/i;return e.map(a=>{const f=re(a,s,i);for(let l=0;l<i;++l){const c=Math.min(Math.round(o*l),r-1);for(let h=0;h<s;++h){const g=Math.min(Math.round(n*h),t-1),u=a[c*t+g];f[l*s+h]=u}}return f})}function R(e,t,r){return(1-r)*e+r*t}function Gt(e,t,r,s,i){const n=t/s,o=r/i;return e.map(a=>{const f=re(a,s,i);for(let l=0;l<i;++l){const c=o*l,h=Math.floor(c),g=Math.min(Math.ceil(c),r-1);for(let u=0;u<s;++u){const y=n*u,p=y%1,w=Math.floor(y),m=Math.min(Math.ceil(y),t-1),b=a[h*t+w],v=a[h*t+m],S=a[g*t+w],T=a[g*t+m],A=R(R(b,v,p),R(S,T,p),c%1);f[l*s+u]=A}}return f})}function jt(e,t,r,s,i,n="nearest"){switch(n.toLowerCase()){case"nearest":return qt(e,t,r,s,i);case"bilinear":case"linear":return Gt(e,t,r,s,i);default:throw new Error(`Unsupported resampling method: '${n}'`)}}function Ht(e,t,r,s,i,n){const o=t/s,a=r/i,f=re(e,s,i,n);for(let l=0;l<i;++l){const c=Math.min(Math.round(a*l),r-1);for(let h=0;h<s;++h){const g=Math.min(Math.round(o*h),t-1);for(let u=0;u<n;++u){const y=e[c*t*n+g*n+u];f[l*s*n+h*n+u]=y}}}return f}function Yt(e,t,r,s,i,n){const o=t/s,a=r/i,f=re(e,s,i,n);for(let l=0;l<i;++l){const c=a*l,h=Math.floor(c),g=Math.min(Math.ceil(c),r-1);for(let u=0;u<s;++u){const y=o*u,p=y%1,w=Math.floor(y),m=Math.min(Math.ceil(y),t-1);for(let b=0;b<n;++b){const v=e[h*t*n+w*n+b],S=e[h*t*n+m*n+b],T=e[g*t*n+w*n+b],A=e[g*t*n+m*n+b],P=R(R(v,S,p),R(T,A,p),c%1);f[l*s*n+u*n+b]=P}}}return f}function $t(e,t,r,s,i,n,o="nearest"){switch(o.toLowerCase()){case"nearest":return Ht(e,t,r,s,i,n);case"bilinear":case"linear":return Yt(e,t,r,s,i,n);default:throw new Error(`Unsupported resampling method: '${o}'`)}}function Xt(e,t,r){let s=0;for(let i=t;i<r;++i)s+=e[i];return s}function le(e,t,r){let s;switch(e){case 1:t<=8?s=Uint8Array:t<=16?s=Uint16Array:t<=32&&(s=Uint32Array);break;case 2:t===8?s=Int8Array:t===16?s=Int16Array:t===32&&(s=Int32Array);break;case 3:switch(t){case 16:case 32:s=Float32Array;break;case 64:s=Float64Array;break;default:break}break;default:break}if(s){if(typeof r=="number")return new s(r);if(r instanceof ArrayBuffer)return new s(r)}throw Error("Unsupported data format/bitsPerSample")}function Kt(e,t){return(e===1||e===2)&&t<=32&&t%8===0?!1:!(e===3&&(t===16||t===32||t===64))}function Zt(e,t,r,s,i,n,o){const a=new DataView(e),f=r===2?o*n:o*n*s,l=r===2?1:s,c=le(t,i,f),h=parseInt("1".repeat(i),2);if(t===1){let g;r===1?g=s*i:g=i;let u=n*g;(u&7)!==0&&(u=u+7&-8);for(let y=0;y<o;++y){const p=y*u;for(let w=0;w<n;++w){const m=p+w*l*i;for(let b=0;b<l;++b){const v=m+b*i,S=(y*n+w)*l+b,T=Math.floor(v/8),A=v%8;A+i<=8?c[S]=a.getUint8(T)>>8-i-A&h:A+i<=16?c[S]=a.getUint16(T)>>16-i-A&h:A+i<=24?c[S]=(a.getUint16(T)<<8|a.getUint8(T+2))>>24-i-A&h:c[S]=a.getUint32(T)>>32-i-A&h}}}}return c.buffer}var Jt=class{constructor(e,t,r,s){this.fileDirectory=e,this.littleEndian=t,this.tiles=r?[]:null,this.isTiled=!e.hasTag("StripOffsets");const i=e.getValue("PlanarConfiguration")??1;if(i!==1&&i!==2)throw new Error("Invalid planar configuration.");this.planarConfiguration=i,this.source=s}getFileDirectory(){return this.fileDirectory}getGeoKeys(){return this.fileDirectory.parseGeoKeyDirectory()}getWidth(){return this.fileDirectory.getValue("ImageWidth")||0}getHeight(){return this.fileDirectory.getValue("ImageLength")||0}getSamplesPerPixel(){return this.fileDirectory.getValue("SamplesPerPixel")??1}getTileWidth(){return this.isTiled?this.fileDirectory.getValue("TileWidth")||0:this.getWidth()}getTileHeight(){if(this.isTiled)return this.fileDirectory.getValue("TileLength")||0;const e=this.fileDirectory.hasTag("RowsPerStrip")&&this.fileDirectory.getValue("RowsPerStrip");return e?Math.min(e,this.getHeight()):this.getHeight()}getBlockWidth(){return this.getTileWidth()}getBlockHeight(e){return this.isTiled||(e+1)*this.getTileHeight()<=this.getHeight()?this.getTileHeight():this.getHeight()-e*this.getTileHeight()}getBytesPerPixel(){let e=0;const t=this.fileDirectory.getValue("BitsPerSample")||[];for(let r=0;r<t.length;++r)e+=this.getSampleByteSize(r);return e}getSampleByteSize(e){const t=this.fileDirectory.getValue("BitsPerSample")||[];if(e>=t.length)throw new RangeError(`Sample index ${e} is out of range.`);return Math.ceil(t[e]/8)}getReaderForSample(e){const t=this.fileDirectory.getValue("SampleFormat"),r=t?t[e]:1,s=(this.fileDirectory.getValue("BitsPerSample")||[])[e];switch(r){case 1:if(s<=8)return DataView.prototype.getUint8;if(s<=16)return DataView.prototype.getUint16;if(s<=32)return DataView.prototype.getUint32;break;case 2:if(s<=8)return DataView.prototype.getInt8;if(s<=16)return DataView.prototype.getInt16;if(s<=32)return DataView.prototype.getInt32;break;case 3:switch(s){case 16:return function(i,n){return ze(this,i,n)};case 32:return DataView.prototype.getFloat32;case 64:return DataView.prototype.getFloat64;default:break}break;default:break}throw Error("Unsupported data format/bitsPerSample")}getSampleFormat(e=0){const t=this.fileDirectory.getValue("SampleFormat");return t?t[e]:1}getBitsPerSample(e=0){const t=this.fileDirectory.getValue("BitsPerSample");return t?t[e]:0}getArrayForSample(e,t){return le(this.getSampleFormat(e),this.getBitsPerSample(e),t)}async getTileOrStrip(e,t,r,s,i){const n=Math.ceil(this.getWidth()/this.getTileWidth()),o=Math.ceil(this.getHeight()/this.getTileHeight());let a;const{tiles:f}=this;if(this.planarConfiguration===1?a=t*n+e:this.planarConfiguration===2&&(a=r*n*o+t*n+e),a===void 0)throw new Error("Could not determine tile or strip index.");let l,c;if(this.isTiled?(l=Number(await this.fileDirectory.loadValueIndexed("TileOffsets",a)),c=Number(await this.fileDirectory.loadValueIndexed("TileByteCounts",a))):(l=Number(await this.fileDirectory.loadValueIndexed("StripOffsets",a)),c=Number(await this.fileDirectory.loadValueIndexed("StripByteCounts",a))),c===0){const u=this.getBlockHeight(t)*this.getTileWidth(),y=this.planarConfiguration===2?this.getSampleByteSize(r):this.getBytesPerPixel(),p=new ArrayBuffer(u*y);return this.getArrayForSample(r,p).fill(this.getGDALNoData()||0),{x:e,y:t,sample:r,data:p}}const h=(await this.source.fetch([{offset:l,length:c}],i))[0];let g;return f===null||!f[a]?(g=(async()=>{let u=await s.decode(h);const y=this.getSampleFormat(),p=this.getBitsPerSample();return Kt(y,p)&&(u=Zt(u,y,this.planarConfiguration,this.getSamplesPerPixel(),p,this.getTileWidth(),this.getBlockHeight(t))),u})(),f!==null&&(f[a]=g)):g=f[a],{x:e,y:t,sample:r,data:await g}}async _readRaster(e,t,r,s,i,n,o,a,f){const l=this.getTileWidth(),c=this.getTileHeight(),h=this.getWidth(),g=this.getHeight(),u=Math.max(Math.floor(e[0]/l),0),y=Math.min(Math.ceil(e[2]/l),Math.ceil(h/l)),p=Math.max(Math.floor(e[1]/c),0),w=Math.min(Math.ceil(e[3]/c),Math.ceil(g/c)),m=e[2]-e[0];let b=this.getBytesPerPixel();const v=[],S=[];for(let _=0;_<t.length;++_){if(this.planarConfiguration===1){const x=await this.fileDirectory.loadValue("BitsPerSample");if(typeof x!="object")throw new Error("Expected BitsPerSample to be an array or typed array.");v.push(Xt(x,0,t[_])/8)}else v.push(0);S.push(this.getReaderForSample(t[_]))}const T=[],{littleEndian:A}=this;for(let _=p;_<w;++_)for(let x=u;x<y;++x){let H;this.planarConfiguration===1&&(H=this.getTileOrStrip(x,_,0,i,f));for(let Y=0;Y<t.length;++Y){const $=Y,ve=t[Y];if(this.planarConfiguration===2&&(b=this.getSampleByteSize(ve),H=this.getTileOrStrip(x,_,ve,i,f)),!H)throw new Error("Could not get tile or strip data.");const Ye=H.then(V=>{const $e=V.data,Xe=new DataView($e),se=this.getBlockHeight(V.y),U=V.y*c,X=V.x*l,Ke=U+se,Ze=(V.x+1)*l,Je=S[$],Qe=Math.min(se,se-(Ke-e[3]),g-U),We=Math.min(l,l-(Ze-e[2]),h-X);for(let N=Math.max(0,e[1]-U);N<Qe;++N)for(let L=Math.max(0,e[0]-X);L<We;++L){const et=(N*l+L)*b,Ie=Je.call(Xe,et+v[$],A);let K;s?(K=(N+U-e[1])*m*t.length+(L+X-e[0])*t.length+$,r[K]=Ie):(K=(N+U-e[1])*m+L+X-e[0],r[$][K]=Ie)}});T.push(Ye)}}if(await Promise.all(T),n&&e[2]-e[0]!==n||o&&e[3]-e[1]!==o){let _;s?_=$t(r,e[2]-e[0],e[3]-e[1],n,o,t.length,a):_=jt(r,e[2]-e[0],e[3]-e[1],n,o,a);const x=_;return x.width=n??e[2]-e[0],x.height=o??e[3]-e[1],x}const P=r;return P.width=n||e[2]-e[0],P.height=o||e[3]-e[1],P}async readRasters(e={}){const{window:t,samples:r=[],pool:s=null,width:i,height:n,resampleMethod:o,fillValue:a,signal:f}=e,l="interleave"in e&&e.interleave,c=t||[0,0,this.getWidth(),this.getHeight()];if(c[0]>c[2]||c[1]>c[3])throw new Error("Invalid subsets");const h=(c[2]-c[0])*(c[3]-c[1]),g=this.getSamplesPerPixel();if(!r||!r.length)for(let m=0;m<g;++m)r.push(m);else for(let m=0;m<r.length;++m)if(r[m]>=g)return Promise.reject(new RangeError(`Invalid sample index '${r[m]}'.`));let u;if(l){const{fileDirectory:m}=this,b=m.getValue("SampleFormat"),v=b?Math.max.apply(null,Array.from(b)):1;if(v!==1&&v!==2&&v!==3)throw new Error("Unsupported sample format for interleaved data. Must be 1, 2, or 3.");const S=m.getValue("BitsPerSample");if(u=le(v,S?Math.max.apply(null,Array.from(S)):8,h*r.length),a){if(Array.isArray(a))throw new Error("When reading interleaved data, fillValue must be a single number.");u.fill(a)}}else{u=[];for(let m=0;m<r.length;++m){const b=this.getArrayForSample(r[m],h);Array.isArray(a)&&m<a.length?b.fill(a[m]):a&&!Array.isArray(a)&&b.fill(a),u.push(b)}}const y=this.fileDirectory.getValue("Compression")||1,p=await Lt(y,this.fileDirectory),w=s?s.bindParameters(y,p):await Ct(y,p);return await this._readRaster(c,r,u,l,w,i,n,o,f)}async readRGB(e={}){const{window:t,pool:r=null,width:s,height:i,resampleMethod:n,enableAlpha:o=!1,signal:a}=e,f=("interleave"in e&&e.interleave)??!1,l=t||[0,0,this.getWidth(),this.getHeight()];if(l[0]>l[2]||l[1]>l[3])throw new Error("Invalid subsets");const c=this.fileDirectory.getValue("PhotometricInterpretation");if(c===d.photometricInterpretations.RGB){let b=[0,1,2];const v=this.fileDirectory.getValue("ExtraSamples");if(v&&v[0]!==d.ExtraSamplesValues.Unspecified&&o){b=[];const S=this.fileDirectory.getValue("BitsPerSample")||[];for(let T=0;T<S.length;T+=1)b.push(T)}return this.readRasters({window:t,interleave:f,samples:b,pool:r,width:s,height:i,resampleMethod:n,signal:a})}let h;switch(c){case d.photometricInterpretations.WhiteIsZero:case d.photometricInterpretations.BlackIsZero:case d.photometricInterpretations.Palette:h=[0];break;case d.photometricInterpretations.CMYK:h=[0,1,2,3];break;case d.photometricInterpretations.YCbCr:case d.photometricInterpretations.CIELab:h=[0,1,2];break;default:throw new Error("Invalid or unsupported photometric interpretation.")}const g={window:l,interleave:!0,samples:h,pool:r,width:s,height:i,resampleMethod:n,signal:a},{fileDirectory:u}=this,y=await this.readRasters(g),p=2**this.getBitsPerSample(0);let w;switch(c){case d.photometricInterpretations.WhiteIsZero:w=Ft(y,p);break;case d.photometricInterpretations.BlackIsZero:w=kt(y,p);break;case d.photometricInterpretations.Palette:w=Dt(y,await u.loadValue("ColorMap"));break;case d.photometricInterpretations.CMYK:w=Ot(y);break;case d.photometricInterpretations.YCbCr:w=Rt(y);break;case d.photometricInterpretations.CIELab:w=Ut(y);break;default:throw new Error("Unsupported photometric interpretation.")}if(!f){const b=new Uint8Array(w.length/3),v=new Uint8Array(w.length/3),S=new Uint8Array(w.length/3);for(let T=0,A=0;T<w.length;T+=3,++A)b[A]=w[T],v[A]=w[T+1],S[A]=w[T+2];w=[b,v,S]}const m=w;return m.width=y.width,m.height=y.height,m}async getTiePoints(){if(!this.fileDirectory.hasTag("ModelTiepoint"))return[];const e=await this.fileDirectory.loadValue("ModelTiepoint");if(typeof e!="object")throw new Error("Expected ModelTiepoint to be an array or typed array.");const t=[];for(let r=0;r<e.length;r+=6)t.push({i:e[r],j:e[r+1],k:e[r+2],x:e[r+3],y:e[r+4],z:e[r+5]});return t}async getGDALMetadata(e=null){const t={};if(!this.fileDirectory.hasTag("GDAL_METADATA"))return null;let r=xt(await this.fileDirectory.loadValue("GDAL_METADATA"),"Item");e===null?r=r.filter(s=>ie(s,"sample")===void 0):r=r.filter(s=>Number(ie(s,"sample"))===e);for(let s=0;s<r.length;++s){const i=r[s];t[ie(i,"name")]=i.inner}return t}getGDALNoData(){const e=this.fileDirectory.hasTag("GDAL_NODATA")&&this.fileDirectory.getValue("GDAL_NODATA");return e?Number(e.substring(0,e.length-1)):null}getOrigin(){const e=this.fileDirectory.getValue("ModelTiepoint"),t=this.fileDirectory.getValue("ModelTransformation");if(e&&e.length===6)return[e[3],e[4],e[5]];if(t)return[t[3],t[7],t[11]];throw new Error("The image does not have an affine transformation.")}getResolution(e=null){const t=this.fileDirectory.getValue("ModelPixelScale"),r=this.fileDirectory.getValue("ModelTransformation");if(t)return[t[0],-t[1],t[2]];if(r)return r[1]===0&&r[4]===0?[r[0],-r[5],r[10]]:[Math.sqrt(r[0]*r[0]+r[4]*r[4]),-Math.sqrt(r[1]*r[1]+r[5]*r[5]),r[10]];if(e){const[s,i,n]=e.getResolution();return[s*e.getWidth()/this.getWidth(),i*e.getHeight()/this.getHeight(),n*e.getWidth()/this.getWidth()]}throw new Error("The image does not have an affine transformation.")}pixelIsArea(){return this.getGeoKeys()?.GTRasterTypeGeoKey===1}getBoundingBox(e=!1){const t=this.getHeight(),r=this.getWidth(),s=this.fileDirectory.getValue("ModelTransformation");if(s&&!e){const[i,n,,o,a,f,,l]=s,c=[[0,0],[0,t],[r,0],[r,t]].map(([u,y])=>[o+i*u+n*y,l+a*u+f*y]),h=c.map(u=>u[0]),g=c.map(u=>u[1]);return[Math.min(...h),Math.min(...g),Math.max(...h),Math.max(...g)]}else{const i=this.getOrigin(),n=this.getResolution(),o=i[0],a=i[1],f=o+n[0]*r,l=a+n[1]*t;return[Math.min(o,f),Math.min(a,l),Math.max(o,f),Math.max(a,l)]}}},Qt=class{constructor(e){this._dataView=new DataView(e)}get buffer(){return this._dataView.buffer}getUint64(e,t){const r=this.getUint32(e,t),s=this.getUint32(e+4,t);let i;if(t){if(i=r+2**32*s,!Number.isSafeInteger(i))throw new Error(`${i} exceeds MAX_SAFE_INTEGER. Precision may be lost. Please report if you get this message to https://github.com/geotiffjs/geotiff.js/issues`);return i}if(i=2**32*r+s,!Number.isSafeInteger(i))throw new Error(`${i} exceeds MAX_SAFE_INTEGER. Precision may be lost. Please report if you get this message to https://github.com/geotiffjs/geotiff.js/issues`);return i}getInt64(e,t){let r=0;const s=(this._dataView.getUint8(e+(t?7:0))&128)>0;let i=!0;for(let n=0;n<8;n++){let o=this._dataView.getUint8(e+(t?n:7-n));s&&(i?o!==0&&(o=~(o-1)&255,i=!1):o=~o&255),r+=o*256**n}return s&&(r=-r),r}getUint8(e){return this._dataView.getUint8(e)}getInt8(e){return this._dataView.getInt8(e)}getUint16(e,t){return this._dataView.getUint16(e,t)}getInt16(e,t){return this._dataView.getInt16(e,t)}getUint32(e,t){return this._dataView.getUint32(e,t)}getInt32(e,t){return this._dataView.getInt32(e,t)}getFloat16(e,t){return ze(this._dataView,e,t)}getFloat32(e,t){return this._dataView.getFloat32(e,t)}getFloat64(e,t){return this._dataView.getFloat64(e,t)}},Q=class{constructor(e,t,r,s){this._dataView=new DataView(e),this._sliceOffset=t,this._littleEndian=r,this._bigTiff=s}get sliceOffset(){return this._sliceOffset}get sliceTop(){return this._sliceOffset+this.buffer.byteLength}get littleEndian(){return this._littleEndian}get bigTiff(){return this._bigTiff}get buffer(){return this._dataView.buffer}covers(e,t){return this.sliceOffset<=e&&this.sliceTop>=e+t}readUint8(e){return this._dataView.getUint8(e-this._sliceOffset)}readInt8(e){return this._dataView.getInt8(e-this._sliceOffset)}readUint16(e){return this._dataView.getUint16(e-this._sliceOffset,this._littleEndian)}readInt16(e){return this._dataView.getInt16(e-this._sliceOffset,this._littleEndian)}readUint32(e){return this._dataView.getUint32(e-this._sliceOffset,this._littleEndian)}readInt32(e){return this._dataView.getInt32(e-this._sliceOffset,this._littleEndian)}readFloat32(e){return this._dataView.getFloat32(e-this._sliceOffset,this._littleEndian)}readFloat64(e){return this._dataView.getFloat64(e-this._sliceOffset,this._littleEndian)}readUint64(e){const t=this.readUint32(e),r=this.readUint32(e+4);let s;if(this._littleEndian){if(s=t+2**32*r,!Number.isSafeInteger(s))throw new Error(`${s} exceeds MAX_SAFE_INTEGER. Precision may be lost. Please report if you get this message to https://github.com/geotiffjs/geotiff.js/issues`);return s}if(s=2**32*t+r,!Number.isSafeInteger(s))throw new Error(`${s} exceeds MAX_SAFE_INTEGER. Precision may be lost. Please report if you get this message to https://github.com/geotiffjs/geotiff.js/issues`);return s}readInt64(e){let t=0;const r=(this._dataView.getUint8(e+(this._littleEndian?7:0))&128)>0;let s=!0;for(let i=0;i<8;i++){let n=this._dataView.getUint8(e+(this._littleEndian?i:7-i));r&&(s?n!==0&&(n=~(n-1)&255,s=!1):n=~n&255),t+=n*256**i}return r&&(t=-t),t}readOffset(e){return this._bigTiff?this.readUint64(e):this.readUint32(e)}},Wt=`\r
|
|
4
4
|
\r
|
|
5
5
|
`;function qe(e){if(typeof Object.fromEntries<"u")return Object.fromEntries(e);const t={};for(const[r,s]of e)t[r.toLowerCase()]=s;return t}function er(e){return qe(e.split(`\r
|
|
6
6
|
`).map(t=>{const r=t.split(":").map(s=>s.trim());return r[0]=r[0].toLowerCase(),r}))}function tr(e){if(!e)return{type:null,params:{}};const[t,...r]=e.split(";").map(s=>s.trim());return{type:t,params:qe(r.map(s=>s.split("=")))}}function ce(e){let t=NaN,r=NaN,s=NaN;return e&&([,t,r,s]=(e.match(/bytes (\d+)-(\d+)\/(\d+)/)||[]).map(Number)),{start:t,end:r,total:s}}function rr(e,t){let r=-1;const s=new TextDecoder("ascii"),i=[],n=`--${t}`,o=`${n}--`;for(let a=0;a<10;++a)s.decode(new Uint8Array(e,a,n.length))===n&&(r=a);if(r===-1)throw new Error("Could not find initial boundary");for(;r<e.byteLength;){const a=s.decode(new Uint8Array(e,r,Math.min(n.length+1024,e.byteLength-r)));if(a.length===0||a.startsWith(o))break;if(!a.startsWith(n))throw new Error("Part does not start with boundary");const f=a.substr(n.length+2);if(f.length===0)break;const l=f.indexOf(Wt),c=er(f.substr(0,l)),{start:h,end:g,total:u}=ce(c["content-range"]),y=r+n.length+l+4,p=g+1-h;i.push({headers:c,data:e.slice(y,y+p),offset:h,length:p,fileSize:u}),r=y+p+4}return i}var Ge=class{async fetch(e,t){return Promise.all(e.map(async r=>(await this.fetchSlice(r,t)).data))}async fetchSlice(e,t){throw new Error(`fetching of slice ${e} not possible, not implemented`)}get fileSize(){return null}async close(){}},sr=class extends Map{constructor(e={}){if(super(),!(e.maxSize&&e.maxSize>0))throw new TypeError("`maxSize` must be a number greater than 0");if(typeof e.maxAge=="number"&&e.maxAge===0)throw new TypeError("`maxAge` must be a number greater than 0");this.maxSize=e.maxSize,this.maxAge=e.maxAge||Number.POSITIVE_INFINITY,this.onEviction=e.onEviction,this.cache=new Map,this.oldCache=new Map,this._size=0}_emitEvictions(e){if(typeof this.onEviction=="function")for(const[t,r]of e)this.onEviction(t,r.value)}_deleteIfExpired(e,t){return typeof t.expiry=="number"&&t.expiry<=Date.now()?(typeof this.onEviction=="function"&&this.onEviction(e,t.value),this.delete(e)):!1}_getOrDeleteIfExpired(e,t){if(this._deleteIfExpired(e,t)===!1)return t.value}_getItemValue(e,t){return t.expiry?this._getOrDeleteIfExpired(e,t):t.value}_peek(e,t){const r=t.get(e);return this._getItemValue(e,r)}_set(e,t){this.cache.set(e,t),this._size++,this._size>=this.maxSize&&(this._size=0,this._emitEvictions(this.oldCache),this.oldCache=this.cache,this.cache=new Map)}_moveToRecent(e,t){this.oldCache.delete(e),this._set(e,t)}*_entriesAscending(){for(const e of this.oldCache){const[t,r]=e;this.cache.has(t)||this._deleteIfExpired(t,r)===!1&&(yield e)}for(const e of this.cache){const[t,r]=e;this._deleteIfExpired(t,r)===!1&&(yield e)}}get(e){if(this.cache.has(e)){const t=this.cache.get(e);return this._getItemValue(e,t)}if(this.oldCache.has(e)){const t=this.oldCache.get(e);if(this._deleteIfExpired(e,t)===!1)return this._moveToRecent(e,t),t.value}}set(e,t,{maxAge:r=this.maxAge}={}){const s=typeof r=="number"&&r!==Number.POSITIVE_INFINITY?Date.now()+r:void 0;return this.cache.has(e)?this.cache.set(e,{value:t,expiry:s}):this._set(e,{value:t,expiry:s}),this}has(e){return this.cache.has(e)?!this._deleteIfExpired(e,this.cache.get(e)):this.oldCache.has(e)?!this._deleteIfExpired(e,this.oldCache.get(e)):!1}peek(e){if(this.cache.has(e))return this._peek(e,this.cache);if(this.oldCache.has(e))return this._peek(e,this.oldCache)}delete(e){const t=this.cache.delete(e);return t&&this._size--,this.oldCache.delete(e)||t}clear(){this.cache.clear(),this.oldCache.clear(),this._size=0}resize(e){if(!(e&&e>0))throw new TypeError("`maxSize` must be a number greater than 0");const t=[...this._entriesAscending()],r=t.length-e;r<0?(this.cache=new Map(t),this.oldCache=new Map,this._size=t.length):(r>0&&this._emitEvictions(t.slice(0,r)),this.oldCache=new Map(t.slice(r)),this.cache=new Map,this._size=0),this.maxSize=e}*keys(){for(const[e]of this)yield e}*values(){for(const[,e]of this)yield e}*[Symbol.iterator](){for(const e of this.cache){const[t,r]=e;this._deleteIfExpired(t,r)===!1&&(yield[t,r.value])}for(const e of this.oldCache){const[t,r]=e;this.cache.has(t)||this._deleteIfExpired(t,r)===!1&&(yield[t,r.value])}}*entriesDescending(){let e=[...this.cache];for(let t=e.length-1;t>=0;--t){const[r,s]=e[t];this._deleteIfExpired(r,s)===!1&&(yield[r,s.value])}e=[...this.oldCache];for(let t=e.length-1;t>=0;--t){const[r,s]=e[t];this.cache.has(r)||this._deleteIfExpired(r,s)===!1&&(yield[r,s.value])}}*entriesAscending(){for(const[e,t]of this._entriesAscending())yield[e,t.value]}get size(){if(!this._size)return this.oldCache.size;let e=0;for(const t of this.oldCache.keys())this.cache.has(t)||e++;return Math.min(this._size+e,this.maxSize)}entries(){return this.entriesAscending()}forEach(e,t=this){for(const[r,s]of this.entriesAscending())e.call(t,s,r,this)}get[Symbol.toStringTag](){return JSON.stringify([...this.entriesAscending()])}};async function ir(e){return new Promise(t=>setTimeout(t,e))}function nr(e,t){const r=Array.isArray(e)?e:Array.from(e),s=Array.isArray(t)?t:Array.from(t);return r.map((i,n)=>[i,s[n]])}var G=class je extends Error{constructor(...t){super(...t),Error.captureStackTrace&&Error.captureStackTrace(this,je),this.name="AbortError",this.signal=void 0}},ar=class extends Error{constructor(e,t){super(t),this.errors=e,this.message=t,this.name="AggregateError"}},or=ar,lr=class{constructor(e,t,r){this.offset=e,this.length=t,this.data=r}get top(){return this.offset+this.length}},_e=class{constructor(e,t,r){this.offset=e,this.length=t,this.blockIds=r}},cr=class extends Ge{constructor(e,{blockSize:t=65536,cacheSize:r=100}={}){super(),this.source=e,this.blockSize=t,this.blockCache=new sr({maxSize:r,onEviction:(s,i)=>{this.evictedBlocks.set(s,i)}}),this.evictedBlocks=new Map,this.blockRequests=new Map,this.blockIdsToFetch=new Set,this.abortedBlockIds=new Set}get fileSize(){return this.source.fileSize}async fetch(e,t){const r=[],s=[],i=[];this.evictedBlocks.clear();for(const{offset:h,length:g}of e){let u=h+g;const{fileSize:y}=this;y!==null&&(u=Math.min(u,y));const p=Math.floor(h/this.blockSize)*this.blockSize;for(let w=p;w<u;w+=this.blockSize){const m=Math.floor(w/this.blockSize);!this.blockCache.has(m)&&!this.blockRequests.has(m)&&(this.blockIdsToFetch.add(m),s.push(m)),this.blockRequests.has(m)&&r.push(this.blockRequests.get(m)),i.push(m)}}await ir(),this.fetchBlocks(t);const n=[];for(const h of s)this.blockRequests.has(h)&&n.push(this.blockRequests.get(h));await Promise.allSettled(r),await Promise.allSettled(n);const o=[],a=i.filter(h=>this.abortedBlockIds.has(h)||!this.blockCache.has(h));if(a.forEach(h=>this.blockIdsToFetch.add(h)),a.length>0&&t&&!t.aborted){this.fetchBlocks();for(const h of a){const g=this.blockRequests.get(h);if(!g)throw new Error(`Block ${h} is not in the block requests`);o.push(g)}await Promise.allSettled(o)}if(t&&t.aborted)throw new G("Request was aborted");const f=i.map(h=>this.blockCache.get(h)||this.evictedBlocks.get(h)),l=f.filter(h=>!h);if(l.length)throw new or(l,"Request failed");const c=new Map(nr(i,f));return this.readSliceData(e,c)}fetchBlocks(e){if(this.blockIdsToFetch.size>0){const t=this.groupBlocks(this.blockIdsToFetch),r=t.map(async s=>({...s,...await this.source.fetchSlice(s,e)}));for(let s=0;s<t.length;++s){const i=t[s];for(const n of i.blockIds)this.blockRequests.set(n,(async()=>{try{const o=(await Promise.all(r))[s],a=n*this.blockSize,f=a-o.offset,l=Math.min(f+this.blockSize,o.data.byteLength),c=o.data.slice(f,l),h=new lr(a,c.byteLength,c);this.blockCache.set(n,h),this.abortedBlockIds.delete(n)}catch(o){if(o instanceof G&&o.name==="AbortError")o.signal=e,this.blockCache.delete(n),this.abortedBlockIds.add(n);else throw o}finally{this.blockRequests.delete(n)}})())}this.blockIdsToFetch.clear()}}groupBlocks(e){const t=Array.from(e).sort((n,o)=>n-o);if(t.length===0)return[];let r=[],s=null;const i=[];for(const n of t)s===null||s+1===n?(r.push(n),s=n):(i.push(new _e(r[0]*this.blockSize,r.length*this.blockSize,r)),r=[n],s=n);return i.push(new _e(r[0]*this.blockSize,r.length*this.blockSize,r)),i}readSliceData(e,t){return e.map(r=>{let s=r.offset+r.length;this.fileSize!==null&&(s=Math.min(this.fileSize,s));const i=Math.floor(r.offset/this.blockSize),n=Math.floor((s-1)/this.blockSize),o=new ArrayBuffer(r.length),a=new Uint8Array(o);for(let f=i;f<=n;++f){const l=t.get(f);if(!l)continue;const c=l.offset-r.offset,h=l.top-s;let g=0,u=0,y;c<0?g=-c:c>0&&(u=c),h<0?y=l.length-g:y=s-l.offset-g;const p=new Uint8Array(l.data,g,y);a.set(p,u)}return o})}},we=class{get ok(){return this.status>=200&&this.status<=299}get status(){throw new Error("not implemented")}getHeader(e){throw new Error("not implemented")}async getData(){throw new Error("not implemented")}},me=class{constructor(e){this.url=e}async request(e){throw new Error("request is not implemented")}},hr=class extends we{constructor(e){super(),this.response=e}get status(){return this.response.status}getHeader(e){return this.response.headers.get(e)||void 0}async getData(){return this.response.arrayBuffer?await this.response.arrayBuffer():(await this.response.buffer()).buffer}},fr=class extends me{constructor(e,t){super(e),this.credentials=t}async request({headers:e,signal:t}={}){return new hr(await fetch(this.url,{headers:e,credentials:this.credentials,signal:t}))}},ur=class extends we{constructor(e,t){super(),this.xhr=e,this.data=t}get status(){return this.xhr.status}getHeader(e){return this.xhr.getResponseHeader(e)||void 0}async getData(){return this.data}},dr=class extends me{constructRequest(e,t){return new Promise((r,s)=>{const i=new XMLHttpRequest;i.open("GET",this.url),i.responseType="arraybuffer";for(const[n,o]of Object.entries(e))i.setRequestHeader(n,o);i.onload=()=>{const n=i.response;r(new ur(i,n))},i.onerror=s,i.onabort=()=>s(new G("Request aborted")),i.send(),t&&(t.aborted&&i.abort(),t.addEventListener("abort",()=>i.abort()))})}async request({headers:e={},signal:t=void 0}={}){return await this.constructRequest(e,t)}},gr=Pe.__commonJSMin(((e,t)=>{t.exports={}})),ne=Pe.__toESM(gr(),1),yr=class extends we{constructor(e,t){super(),this.response=e,this.dataPromise=t}get status(){return this.response.statusCode}getHeader(e){const t=this.response.headers[e];return Array.isArray(t)?t.join(", "):t}async getData(){return await this.dataPromise}},pr=class extends me{constructor(e){super(e),this.parsedUrl=ne.default.parse(this.url),this.httpApi=(this.parsedUrl.protocol==="http:",ne.default)}constructRequest(e,t){return new Promise((r,s)=>{const i=this.httpApi.get({...this.parsedUrl,headers:e},n=>{r(new yr(n,new Promise(o=>{const a=[];n.on("data",f=>{a.push(f)}),n.on("end",()=>{const f=Buffer.concat(a).buffer;o(f)}),n.on("error",s)})))});i.on("error",s),t&&(t.aborted&&i.destroy(new G("Request aborted")),t.addEventListener("abort",()=>i.destroy(new G("Request aborted"))))})}async request({headers:e={},signal:t=void 0}={}){return await this.constructRequest(e,t)}},be=class extends Ge{constructor(e,{headers:t,maxRanges:r=0,allowFullFile:s}={}){super(),this.client=e,this.headers=t,this.maxRanges=r,this.allowFullFile=s,this._fileSize=null}async fetch(e,t){return this.maxRanges>=e.length?this.fetchSlices(e,t).then(r=>r.map(s=>s.data)):(this.maxRanges>0&&e.length>1,Promise.all(e.map(async r=>(await this.fetchSlice(r,t)).data)))}async fetchSlices(e,t){const r=await this.client.request({headers:{...this.headers,Range:`bytes=${e.map(({offset:s,length:i})=>`${s}-${s+i-1}`).join(",")}`},signal:t});if(r.ok)if(r.status===206){const{type:s,params:i}=tr(r.getHeader("content-type"));if(s==="multipart/byteranges"){const c=rr(await r.getData(),i.boundary);return this._fileSize=c[0].fileSize||null,c}const n=await r.getData(),{start:o,end:a,total:f}=ce(r.getHeader("content-range"));this._fileSize=f||null;const l=[{data:n,offset:o,length:a+1-o}];if(e.length>1){const c=await Promise.all(e.slice(1).map(h=>this.fetchSlice(h,t)));return l.concat(c)}return l}else{if(!this.allowFullFile)throw new Error("Server responded with full file");const s=await r.getData();return this._fileSize=s.byteLength,[{data:s,offset:0,length:s.byteLength}]}else throw new Error("Error fetching data.")}async fetchSlice(e,t){const{offset:r,length:s}=e,i=await this.client.request({headers:{...this.headers,Range:`bytes=${r}-${r+s-1}`},signal:t});if(i.ok)if(i.status===206){const n=await i.getData(),{total:o}=ce(i.getHeader("content-range"));return this._fileSize=o||null,{data:n,offset:r,length:s}}else{if(!this.allowFullFile)throw new Error("Server responded with full file");const n=await i.getData();return this._fileSize=n.byteLength,{data:n,offset:0,length:n.byteLength}}else throw new Error("Error fetching data.")}get fileSize(){return this._fileSize}};function Te(e,{blockSize:t,cacheSize:r}){return t===void 0?e:new cr(e,{blockSize:t,cacheSize:r})}function wr(e,{headers:t={},credentials:r,maxRanges:s=0,allowFullFile:i=!1,...n}={}){return Te(new be(new fr(e,r),{headers:t,maxRanges:s,allowFullFile:i}),n)}function mr(e,{headers:t={},maxRanges:r=0,allowFullFile:s=!1,...i}={}){return Te(new be(new dr(e),{headers:t,maxRanges:r,allowFullFile:s}),i)}function br(e,{headers:t={},maxRanges:r=0,allowFullFile:s=!1,...i}={}){return Te(new be(new pr(e),{headers:t,maxRanges:r,allowFullFile:s}),i)}function Tr(e,{forceXHR:t=!1,...r}={}){return typeof fetch=="function"&&!t?wr(e,r):typeof XMLHttpRequest<"u"?mr(e,r):br(e,r)}function D(e,t){switch(e){case d.fieldTypes.BYTE:case d.fieldTypes.ASCII:case d.fieldTypes.UNDEFINED:return new Uint8Array(t);case d.fieldTypes.SBYTE:return new Int8Array(t);case d.fieldTypes.SHORT:return new Uint16Array(t);case d.fieldTypes.SSHORT:return new Int16Array(t);case d.fieldTypes.LONG:case d.fieldTypes.IFD:return new Uint32Array(t);case d.fieldTypes.SLONG:return new Int32Array(t);case d.fieldTypes.LONG8:case d.fieldTypes.IFD8:return new Array(t);case d.fieldTypes.SLONG8:return new Array(t);case d.fieldTypes.RATIONAL:return new Uint32Array(t*2);case d.fieldTypes.SRATIONAL:return new Int32Array(t*2);case d.fieldTypes.FLOAT:return new Float32Array(t);case d.fieldTypes.DOUBLE:return new Float64Array(t);default:throw new RangeError(`Invalid field type: ${e}`)}}function O(e,t){switch(t){case d.fieldTypes.BYTE:case d.fieldTypes.ASCII:case d.fieldTypes.UNDEFINED:return e.readUint8;case d.fieldTypes.SBYTE:return e.readInt8;case d.fieldTypes.SHORT:return e.readUint16;case d.fieldTypes.SSHORT:return e.readInt16;case d.fieldTypes.LONG:case d.fieldTypes.IFD:return e.readUint32;case d.fieldTypes.SLONG:return e.readInt32;case d.fieldTypes.LONG8:case d.fieldTypes.IFD8:return e.readUint64;case d.fieldTypes.SLONG8:return e.readInt64;case d.fieldTypes.RATIONAL:return e.readUint32;case d.fieldTypes.SRATIONAL:return e.readInt32;case d.fieldTypes.FLOAT:return e.readFloat32;case d.fieldTypes.DOUBLE:return e.readFloat64;default:throw new RangeError(`Invalid field type: ${t}`)}}function C(e=null,t,r,s,i,n,o=!1){const a=d.getFieldTypeSize(s),f=e||D(s,i),l=s===d.fieldTypes.RATIONAL||s===d.fieldTypes.SRATIONAL;if(l)for(let c=0;c<i;c+=2)f[c]=t.call(r,n+c*a),f[c+1]=t.call(r,n+(c*a+4));else for(let c=0;c<i;++c)f[c]=t.call(r,n+c*a);return s===d.fieldTypes.ASCII?new TextDecoder("utf-8").decode(f):i===1&&!o&&!l?f[0]:f}var vr=class{constructor(e,t,r,s,i){this.source=e,this.arrayOffset=t,this.littleEndian=r,this.fieldType=s,this.length=i,this.data=D(s,i),this.itemSize=d.getFieldTypeSize(s),this.maskBitmap=new Uint8Array(Math.ceil(i/8)),this.fetchIndexPromises=new Map,this.fullFetchPromise=null}async loadAll(){return this.fullFetchPromise||(this.fullFetchPromise=this.source.fetch([{offset:this.arrayOffset,length:this.itemSize*this.length}]).then(e=>{const t=new Q(e[0],this.arrayOffset,!0,!1),r=C(this.data,O(t,this.fieldType),t,this.fieldType,this.length,this.arrayOffset,!0);return this.maskBitmap.fill(255),this.fetchIndexPromises.clear(),r})),this.fullFetchPromise}async get(e){if(e<0||e>=this.data.length)throw new RangeError(`Index ${e} out of bounds for length ${this.data.length}`);const t=Math.floor(e/8),r=1<<e%8,s=this.arrayOffset+e*this.itemSize;if((this.maskBitmap[t]&r)===0){if(!this.fetchIndexPromises.has(e)){const i=this.source.fetch([{offset:s,length:this.itemSize}]).then(n=>{const o=new Q(n[0],this.arrayOffset+e*this.itemSize,!0,!1),a=O(o,this.fieldType).call(o,s);return this.data[e]=a,this.maskBitmap[t]|=r,this.fetchIndexPromises.delete(e),a});this.fetchIndexPromises.set(e,i)}return this.fetchIndexPromises.get(e)}return this.data[e]}},Ir=class{constructor(e,t,r,s){this.actualizedFields=e,this.deferredFields=t,this.deferredFieldsBeingResolved=new Map,this.deferredArrays=r,this.nextIFDByteOffset=s}hasTag(e){const t=d.resolveTag(e);return this.actualizedFields.has(t)||this.deferredFields.has(t)||this.deferredArrays.has(t)}getValue(e){const t=d.resolveTag(e);if(this.deferredFields.has(t)||this.deferredArrays.has(t)){const r=d.tagDefinitions[t]?.name||`Tag${t}`;throw new Error(`Field '${r}' (${t}) is deferred. Use loadValue() to load it asynchronously.`)}if(this.actualizedFields.has(t))return this.actualizedFields.get(t)}async loadValue(e){const t=d.resolveTag(e);if(this.actualizedFields.has(t))return this.actualizedFields.get(t);if(this.deferredFieldsBeingResolved.has(t))return this.deferredFieldsBeingResolved.get(t);const r=this.deferredFields.get(t);if(r){this.deferredFields.delete(t);const i=(async()=>{try{const n=await r();return this.actualizedFields.set(t,n),n}finally{this.deferredFieldsBeingResolved.delete(t)}})();return this.deferredFieldsBeingResolved.set(t,i),i}const s=this.deferredArrays.get(t);if(s)return s.loadAll()}async loadValueIndexed(e,t){const r=d.resolveTag(e);if(this.actualizedFields.has(r))return this.actualizedFields.get(r)[t];if(this.deferredArrays.has(r))return this.deferredArrays.get(r).get(t);if(this.hasTag(r)){const s=await this.loadValue(r);if(s&&typeof s!="number")return s[t]}}parseGeoKeyDirectory(){const e=this.getValue("GeoKeyDirectory");if(!e)return null;const t={};for(let r=4;r<=e[3]*4;r+=4){const s=d.geoKeyNames[e[r]],i=e[r+1]||null,n=e[r+2],o=e[r+3];let a=null;if(!i)a=o;else{if(a=this.getValue(i),typeof a>"u"||a===null)throw new Error(`Could not get value of geoKey '${s}'.`);typeof a=="string"?a=a.substring(o,o+n-1):a.subarray&&(a=a.subarray(o,o+n),n===1&&(a=a[0]))}t[s]=a}return t}toObject(){const e={};for(const[t,r]of this.actualizedFields.entries()){const s=typeof t=="number"?d.tagDefinitions[t]:void 0,i=s?s.name:`Tag${t}`;e[i]=r}return e}},Ar=class{constructor(e,t,r,s=!1){this.source=e,this.littleEndian=t,this.bigTiff=r,this.eager=s}async getSlice(e,t){const r=this.bigTiff?4048:1024;return new Q((await this.source.fetch([{offset:e,length:typeof t<"u"?t:r}]))[0],e,this.littleEndian,this.bigTiff)}async parseFileDirectoryAt(e){const t=this.bigTiff?20:12,r=this.bigTiff?8:2;let s=await this.getSlice(e);const i=this.bigTiff?s.readUint64(e):s.readUint16(e),n=i*(t+(this.bigTiff?16:6));s.covers(e,n)||(s=await this.getSlice(e,n));const o=new Map,a=new Map,f=new Map;let l=e+(this.bigTiff?8:2);for(let c=0;c<i;l+=t,++c){const h=s.readUint16(l),g=s.readUint16(l+2),u=this.bigTiff?s.readUint64(l+4):s.readUint32(l+4);let y=null,p=null,w=null;const m=d.getFieldTypeSize(g),b=l+(this.bigTiff?12:8),v=d.tagDefinitions[h]?.isArray,S=d.tagDefinitions[h]?.eager||this.eager;if(m*u<=(this.bigTiff?8:4))y=C(D(g,u),O(s,g),s,g,u,b,v);else{const T=s.readOffset(b),A=d.getFieldTypeSize(g)*u;if(s.covers(T,A))y=C(D(g,u),O(s,g),s,g,u,T,v);else if(S){const P=await this.getSlice(T,A);y=C(D(g,u),O(P,g),P,g,u,T,v)}else v?w=new vr(this.source,T,this.littleEndian,g,u):p=async()=>{const P=await this.getSlice(T,A);return C(D(g,u),O(P,g),P,g,u,T,v)}}y!==null?o.set(h,y):p!==null?a.set(h,p):w!==null&&f.set(h,w)}return new Ir(o,a,f,s.readOffset(e+r+t*i))}};function ae(e,t,r,s){let i=null,n=null;const o=d.getFieldTypeSize(t);switch(t){case d.fieldTypes.BYTE:case d.fieldTypes.ASCII:case d.fieldTypes.UNDEFINED:i=new Uint8Array(r),n=e.readUint8;break;case d.fieldTypes.SBYTE:i=new Int8Array(r),n=e.readInt8;break;case d.fieldTypes.SHORT:i=new Uint16Array(r),n=e.readUint16;break;case d.fieldTypes.SSHORT:i=new Int16Array(r),n=e.readInt16;break;case d.fieldTypes.LONG:case d.fieldTypes.IFD:i=new Uint32Array(r),n=e.readUint32;break;case d.fieldTypes.SLONG:i=new Int32Array(r),n=e.readInt32;break;case d.fieldTypes.LONG8:case d.fieldTypes.IFD8:i=new Array(r),n=e.readUint64;break;case d.fieldTypes.SLONG8:i=new Array(r),n=e.readInt64;break;case d.fieldTypes.RATIONAL:i=new Uint32Array(r*2),n=e.readUint32;break;case d.fieldTypes.SRATIONAL:i=new Int32Array(r*2),n=e.readInt32;break;case d.fieldTypes.FLOAT:i=new Float32Array(r),n=e.readFloat32;break;case d.fieldTypes.DOUBLE:i=new Float64Array(r),n=e.readFloat64;break;default:}if(i===null||n===null)throw new RangeError(`Invalid field type: ${t}`);if(t===d.fieldTypes.RATIONAL||t===d.fieldTypes.SRATIONAL)for(let a=0;a<r;a+=2)i[a]=n.call(e,s+a*o),i[a+1]=n.call(e,s+(a*o+4));else for(let a=0;a<r;++a)i[a]=n.call(e,s+a*o);return t===d.fieldTypes.ASCII?new TextDecoder("utf-8").decode(i):i}var Z=class extends Error{constructor(e){super(`No image at index ${e}`),this.index=e}},Sr=class{async getImage(e=0){throw new Error("Not implemented")}async getImageCount(){throw new Error("Not implemented")}async readRasters(e={}){const{window:t,width:r,height:s}=e;let{resX:i,resY:n,bbox:o}=e;const a=await this.getImage();let f=a;const l=await this.getImageCount(),c=a.getBoundingBox();if(t&&o)throw new Error('Both "bbox" and "window" passed.');if(r||s){if(t){const[u,y]=a.getOrigin(),[p,w]=a.getResolution();o=[u+t[0]*p,y+t[1]*w,u+t[2]*p,y+t[3]*w]}const g=o||c;if(r){if(i)throw new Error("Both width and resX passed");i=(g[2]-g[0])/r}if(s){if(n)throw new Error("Both width and resY passed");n=(g[3]-g[1])/s}}if(i||n){const g=[];for(let u=0;u<l;++u){const y=await this.getImage(u),p=y.fileDirectory.getValue("SubfileType"),w=y.fileDirectory.getValue("NewSubfileType");(u===0||p===2||(w||0)&1)&&g.push(y)}g.sort((u,y)=>u.getWidth()-y.getWidth());for(let u=0;u<g.length;++u){const y=g[u],p=(c[2]-c[0])/y.getWidth(),w=(c[3]-c[1])/y.getHeight();if(f=y,i&&i>p||n&&n>w)break}}let h=t;if(o){const[g,u]=a.getOrigin(),[y,p]=f.getResolution(a);h=[Math.round((o[0]-g)/y),Math.round((o[1]-u)/p),Math.round((o[2]-g)/y),Math.round((o[3]-u)/p)],h=[Math.min(h[0],h[2]),Math.min(h[1],h[3]),Math.max(h[0],h[2]),Math.max(h[1],h[3])]}return f.readRasters({...e,window:h})}},Er=class He extends Sr{constructor(t,r,s,i,n={}){super(),this.source=t,this.parser=new Ar(t,r,s,!1),this.littleEndian=r,this.bigTiff=s,this.firstIFDOffset=i,this.cache=n.cache||!1,this.ifdRequests=[],this.ghostValues=null}async getSlice(t,r){const s=this.bigTiff?4048:1024;return new Q((await this.source.fetch([{offset:t,length:typeof r<"u"?r:s}]))[0],t,this.littleEndian,this.bigTiff)}async requestIFD(t){if(this.ifdRequests[t])return this.ifdRequests[t];if(t===0)return this.ifdRequests[t]=this.parser.parseFileDirectoryAt(this.firstIFDOffset),this.ifdRequests[t];if(!this.ifdRequests[t-1])try{this.ifdRequests[t-1]=this.requestIFD(t-1)}catch(r){throw r instanceof Z?new Z(t):r}return this.ifdRequests[t]=(async()=>{const r=this.ifdRequests[t-1];if(!r)throw new Error("Previous IFD request missing");const s=await r;if(s.nextIFDByteOffset===0)throw new Z(t);return this.parser.parseFileDirectoryAt(s.nextIFDByteOffset)})(),this.ifdRequests[t]}async getImage(t=0){return new Jt(await this.requestIFD(t),this.littleEndian,this.cache,this.source)}async getImageCount(){let t=0,r=!0;for(;r;)try{await this.requestIFD(t),++t}catch(s){if(s instanceof Z)r=!1;else throw s}return t}async getGhostValues(){const t=this.bigTiff?16:8;if(this.ghostValues!==null)return this.ghostValues;const r="GDAL_STRUCTURAL_METADATA_SIZE=",s=130;let i=await this.getSlice(t,s);if(r===ae(i,d.fieldTypes.ASCII,30,t)){const n=ae(i,d.fieldTypes.ASCII,s,t).split(`
|
|
@@ -1,4 +1,23 @@
|
|
|
1
|
-
var
|
|
1
|
+
var l = Object.create, y = Object.defineProperty, O = Object.getOwnPropertyDescriptor, S = Object.getOwnPropertyNames, G = Object.getPrototypeOf, T = Object.prototype.hasOwnProperty, N = (t, r) => () => (r || (t((r = { exports: {} }).exports, r), t = null), r.exports), m = (t, r) => {
|
|
2
|
+
let a = {};
|
|
3
|
+
for (var o in t)
|
|
4
|
+
y(a, o, {
|
|
5
|
+
get: t[o],
|
|
6
|
+
enumerable: !0
|
|
7
|
+
});
|
|
8
|
+
return r || y(a, Symbol.toStringTag, { value: "Module" }), a;
|
|
9
|
+
}, A = (t, r, a, o) => {
|
|
10
|
+
if (r && typeof r == "object" || typeof r == "function")
|
|
11
|
+
for (var g = S(r), s = 0, p = g.length, i; s < p; s++)
|
|
12
|
+
i = g[s], !T.call(t, i) && i !== a && y(t, i, {
|
|
13
|
+
get: ((u) => r[u]).bind(null, i),
|
|
14
|
+
enumerable: !(o = O(r, i)) || o.enumerable
|
|
15
|
+
});
|
|
16
|
+
return t;
|
|
17
|
+
}, f = (t, r, a) => (a = t != null ? l(G(t)) : {}, A(r || !t || !t.__esModule ? y(a, "default", {
|
|
18
|
+
value: t,
|
|
19
|
+
enumerable: !0
|
|
20
|
+
}) : a, t)), e = {
|
|
2
21
|
BYTE: 1,
|
|
3
22
|
ASCII: 2,
|
|
4
23
|
SHORT: 3,
|
|
@@ -15,7 +34,7 @@ var e = {
|
|
|
15
34
|
LONG8: 16,
|
|
16
35
|
SLONG8: 17,
|
|
17
36
|
IFD8: 18
|
|
18
|
-
},
|
|
37
|
+
}, P = {
|
|
19
38
|
[e.BYTE]: 1,
|
|
20
39
|
[e.ASCII]: 1,
|
|
21
40
|
[e.SBYTE]: 1,
|
|
@@ -33,12 +52,12 @@ var e = {
|
|
|
33
52
|
[e.SLONG8]: 8,
|
|
34
53
|
[e.IFD8]: 8
|
|
35
54
|
};
|
|
36
|
-
function
|
|
37
|
-
const
|
|
38
|
-
if (
|
|
39
|
-
return
|
|
55
|
+
function K(t) {
|
|
56
|
+
const r = P[t];
|
|
57
|
+
if (r === void 0) throw new RangeError(`Invalid field type: ${t}`);
|
|
58
|
+
return r;
|
|
40
59
|
}
|
|
41
|
-
var
|
|
60
|
+
var I = {
|
|
42
61
|
NewSubfileType: {
|
|
43
62
|
tag: 254,
|
|
44
63
|
type: e.LONG,
|
|
@@ -470,24 +489,24 @@ var s = {
|
|
|
470
489
|
tag: 50674,
|
|
471
490
|
eager: !0
|
|
472
491
|
}
|
|
473
|
-
},
|
|
474
|
-
function
|
|
475
|
-
|
|
492
|
+
}, n = {}, C = {};
|
|
493
|
+
function L(t, r, a, o = !1, g = !1) {
|
|
494
|
+
n[r] = t, C[t] = {
|
|
476
495
|
tag: t,
|
|
477
|
-
name:
|
|
478
|
-
type: typeof
|
|
496
|
+
name: r,
|
|
497
|
+
type: typeof a == "string" ? e[a] : a,
|
|
479
498
|
isArray: o,
|
|
480
499
|
eager: g
|
|
481
500
|
};
|
|
482
501
|
}
|
|
483
|
-
for (const [t,
|
|
484
|
-
const
|
|
485
|
-
|
|
502
|
+
for (const [t, r] of Object.entries(I)) {
|
|
503
|
+
const a = r;
|
|
504
|
+
L(a.tag, a.name || t, a.type, a.isArray, a.eager);
|
|
486
505
|
}
|
|
487
|
-
function
|
|
488
|
-
return typeof t == "number" ? t :
|
|
506
|
+
function H(t) {
|
|
507
|
+
return typeof t == "number" ? t : n[t];
|
|
489
508
|
}
|
|
490
|
-
var
|
|
509
|
+
var D = {
|
|
491
510
|
WhiteIsZero: 0,
|
|
492
511
|
BlackIsZero: 1,
|
|
493
512
|
RGB: 2,
|
|
@@ -497,18 +516,18 @@ var O = {
|
|
|
497
516
|
YCbCr: 6,
|
|
498
517
|
CIELab: 8,
|
|
499
518
|
ICCLab: 9
|
|
500
|
-
},
|
|
519
|
+
}, h = {
|
|
501
520
|
Unspecified: 0,
|
|
502
521
|
Assocalpha: 1,
|
|
503
522
|
Unassalpha: 2
|
|
504
|
-
},
|
|
523
|
+
}, E = {
|
|
505
524
|
Version: 0,
|
|
506
525
|
AddCompression: 1
|
|
507
|
-
},
|
|
526
|
+
}, d = {
|
|
508
527
|
None: 0,
|
|
509
528
|
Deflate: 1,
|
|
510
529
|
Zstandard: 2
|
|
511
|
-
},
|
|
530
|
+
}, R = {
|
|
512
531
|
1024: "GTModelTypeGeoKey",
|
|
513
532
|
1025: "GTRasterTypeGeoKey",
|
|
514
533
|
1026: "GTCitationGeoKey",
|
|
@@ -556,17 +575,20 @@ var O = {
|
|
|
556
575
|
4097: "VerticalCitationGeoKey",
|
|
557
576
|
4098: "VerticalDatumGeoKey",
|
|
558
577
|
4099: "VerticalUnitsGeoKey"
|
|
559
|
-
},
|
|
560
|
-
for (const [t,
|
|
578
|
+
}, c = {};
|
|
579
|
+
for (const [t, r] of Object.entries(R)) c[r] = parseInt(t, 10);
|
|
561
580
|
export {
|
|
562
|
-
|
|
563
|
-
|
|
581
|
+
R as a,
|
|
582
|
+
L as c,
|
|
583
|
+
N as d,
|
|
584
|
+
m as f,
|
|
564
585
|
e as i,
|
|
565
|
-
l,
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
|
|
586
|
+
H as l,
|
|
587
|
+
d as n,
|
|
588
|
+
K as o,
|
|
589
|
+
f as p,
|
|
590
|
+
E as r,
|
|
591
|
+
D as s,
|
|
592
|
+
h as t,
|
|
593
|
+
C as u
|
|
572
594
|
};
|