chunk-EE6TL7XD.js 30 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718
  1. import {
  2. s as s3
  3. } from "./chunk-GCDJLKH4.js";
  4. import {
  5. d,
  6. e,
  7. l3 as l,
  8. n2 as n
  9. } from "./chunk-Y3WMVFTW.js";
  10. import {
  11. s,
  12. s3 as s2
  13. } from "./chunk-EMJ4ZSM2.js";
  14. import {
  15. m
  16. } from "./chunk-IKP3YN53.js";
  17. import {
  18. r,
  19. t
  20. } from "./chunk-GZT4BVFP.js";
  21. // node_modules/@arcgis/core/layers/support/PixelBlock.js
  22. var n2;
  23. var p = s.getLogger("esri.layers.support.PixelBlock");
  24. var c = n2 = class extends l {
  25. constructor(t2) {
  26. super(t2), this.width = null, this.height = null, this.pixelType = "f32", this.validPixelCount = null, this.mask = null, this.maskIsAlpha = false, this.pixels = null, this.statistics = null;
  27. }
  28. static createEmptyBand(t2, e2) {
  29. return new (n2.getPixelArrayConstructor(t2))(e2);
  30. }
  31. static getPixelArrayConstructor(t2) {
  32. let e2;
  33. switch (t2) {
  34. case "u1":
  35. case "u2":
  36. case "u4":
  37. case "u8":
  38. e2 = Uint8Array;
  39. break;
  40. case "u16":
  41. e2 = Uint16Array;
  42. break;
  43. case "u32":
  44. e2 = Uint32Array;
  45. break;
  46. case "s8":
  47. e2 = Int8Array;
  48. break;
  49. case "s16":
  50. e2 = Int16Array;
  51. break;
  52. case "s32":
  53. e2 = Int32Array;
  54. break;
  55. case "f32":
  56. case "c64":
  57. case "c128":
  58. case "unknown":
  59. e2 = Float32Array;
  60. break;
  61. case "f64":
  62. e2 = Float64Array;
  63. }
  64. return e2;
  65. }
  66. castPixelType(t2) {
  67. if (!t2)
  68. return "f32";
  69. let e2 = t2.toLowerCase();
  70. return ["u1", "u2", "u4"].includes(e2) ? e2 = "u8" : ["unknown", "u8", "s8", "u16", "s16", "u32", "s32", "f32", "f64"].includes(e2) || (e2 = "f32"), e2;
  71. }
  72. getPlaneCount() {
  73. return this.pixels && this.pixels.length;
  74. }
  75. addData(t2) {
  76. if (!t2.pixels || t2.pixels.length !== this.width * this.height)
  77. throw new s2("pixelblock:invalid-or-missing-pixels", "add data requires valid pixels array that has same length defined by pixel block width * height");
  78. this.pixels || (this.pixels = []), this.statistics || (this.statistics = []), this.pixels.push(t2.pixels), this.statistics.push(t2.statistics || { minValue: null, maxValue: null });
  79. }
  80. getAsRGBA() {
  81. const t2 = new ArrayBuffer(this.width * this.height * 4);
  82. switch (this.pixelType) {
  83. case "s8":
  84. case "s16":
  85. case "u16":
  86. case "s32":
  87. case "u32":
  88. case "f32":
  89. case "f64":
  90. this._fillFromNon8Bit(t2);
  91. break;
  92. default:
  93. this._fillFrom8Bit(t2);
  94. }
  95. return new Uint8ClampedArray(t2);
  96. }
  97. getAsRGBAFloat() {
  98. const t2 = new Float32Array(this.width * this.height * 4);
  99. return this._fillFrom32Bit(t2), t2;
  100. }
  101. updateStatistics() {
  102. this.statistics = this.pixels.map((t3) => this._calculateBandStatistics(t3, this.mask));
  103. const t2 = this.mask;
  104. let e2 = 0;
  105. if (t2)
  106. for (let s5 = 0; s5 < t2.length; s5++)
  107. t2[s5] && e2++;
  108. else
  109. e2 = this.width * this.height;
  110. this.validPixelCount = e2;
  111. }
  112. clamp(t2) {
  113. if (!t2 || t2 === "f64" || t2 === "f32")
  114. return;
  115. let e2;
  116. switch (t2) {
  117. case "u8":
  118. e2 = [0, 255];
  119. break;
  120. case "u16":
  121. e2 = [0, 65535];
  122. break;
  123. case "u32":
  124. e2 = [0, 4294967295];
  125. break;
  126. case "s8":
  127. e2 = [-128, 127];
  128. break;
  129. case "s16":
  130. e2 = [-32768, 32767];
  131. break;
  132. case "s32":
  133. e2 = [-2147483648, 2147483647];
  134. break;
  135. default:
  136. e2 = [-34e38, 34e38];
  137. }
  138. const [s5, i2] = e2, l3 = this.pixels, r3 = this.width * this.height, a2 = l3.length;
  139. let o2, h2, p3;
  140. const c3 = [];
  141. for (let u3 = 0; u3 < a2; u3++) {
  142. p3 = n2.createEmptyBand(t2, r3), o2 = l3[u3];
  143. for (let t3 = 0; t3 < r3; t3++)
  144. h2 = o2[t3], p3[t3] = h2 > i2 ? i2 : h2 < s5 ? s5 : h2;
  145. c3.push(p3);
  146. }
  147. this.pixels = c3, this.pixelType = t2;
  148. }
  149. extractBands(t2) {
  150. if (t(t2) || t2.length === 0 || this.pixels == null || this.pixels.length === 0)
  151. return this;
  152. const e2 = this.pixels.length, s5 = t2.some((t3) => t3 >= this.pixels.length), i2 = e2 === t2.length && !t2.some((t3, e3) => t3 !== e3);
  153. return s5 || i2 ? this : new n2({ pixelType: this.pixelType, width: this.width, height: this.height, mask: this.mask, validPixelCount: this.validPixelCount, maskIsAlpha: this.maskIsAlpha, pixels: t2.map((t3) => this.pixels[t3]), statistics: this.statistics && t2.map((t3) => this.statistics[t3]) });
  154. }
  155. clone() {
  156. const t2 = new n2({ width: this.width, height: this.height, pixelType: this.pixelType, maskIsAlpha: this.maskIsAlpha, validPixelCount: this.validPixelCount });
  157. let e2;
  158. this.mask && (this.mask instanceof Uint8Array ? t2.mask = new Uint8Array(this.mask) : t2.mask = this.mask.slice(0));
  159. const s5 = n2.getPixelArrayConstructor(this.pixelType);
  160. if (this.pixels && this.pixels.length > 0) {
  161. t2.pixels = [];
  162. const i2 = this.pixels[0].slice;
  163. for (e2 = 0; e2 < this.pixels.length; e2++)
  164. t2.pixels[e2] = i2 ? this.pixels[e2].slice(0, this.pixels[e2].length) : new s5(this.pixels[e2]);
  165. }
  166. if (this.statistics)
  167. for (t2.statistics = [], e2 = 0; e2 < this.statistics.length; e2++)
  168. t2.statistics[e2] = m(this.statistics[e2]);
  169. return t2;
  170. }
  171. _fillFrom8Bit(t2) {
  172. const { mask: e2, maskIsAlpha: s5, pixels: i2 } = this;
  173. if (!t2 || !i2 || !i2.length)
  174. return void p.error("getAsRGBA()", "Unable to convert to RGBA. The input pixel block is empty.");
  175. let l3, r3, a2, o2;
  176. l3 = r3 = a2 = i2[0], i2.length >= 3 ? (r3 = i2[1], a2 = i2[2]) : i2.length === 2 && (r3 = i2[1]);
  177. const h2 = new Uint32Array(t2), n3 = this.width * this.height;
  178. if (l3.length === n3)
  179. if (e2 && e2.length === n3)
  180. if (s5)
  181. for (o2 = 0; o2 < n3; o2++)
  182. e2[o2] && (h2[o2] = e2[o2] << 24 | a2[o2] << 16 | r3[o2] << 8 | l3[o2]);
  183. else
  184. for (o2 = 0; o2 < n3; o2++)
  185. e2[o2] && (h2[o2] = 255 << 24 | a2[o2] << 16 | r3[o2] << 8 | l3[o2]);
  186. else
  187. for (o2 = 0; o2 < n3; o2++)
  188. h2[o2] = 255 << 24 | a2[o2] << 16 | r3[o2] << 8 | l3[o2];
  189. else
  190. p.error("getAsRGBA()", "Unable to convert to RGBA. The pixelblock is invalid.");
  191. }
  192. _fillFromNon8Bit(t2) {
  193. const { pixels: e2, mask: s5, statistics: i2 } = this;
  194. if (!t2 || !e2 || !e2.length)
  195. return void p.error("getAsRGBA()", "Unable to convert to RGBA. The input pixel block is empty.");
  196. const l3 = this.pixelType;
  197. let r3 = 1, a2 = 0, o2 = 1;
  198. if (i2 && i2.length > 0)
  199. a2 = i2.map((t3) => t3.minValue).reduce((t3, e3) => Math.min(t3, e3)), o2 = i2.map((t3) => t3.maxValue - t3.minValue).reduce((t3, e3) => Math.max(t3, e3)), r3 = 255 / o2;
  200. else {
  201. let t3 = 255;
  202. l3 === "s8" ? (a2 = -128, t3 = 127) : l3 === "u16" ? t3 = 65535 : l3 === "s16" ? (a2 = -32768, t3 = 32767) : l3 === "u32" ? t3 = 4294967295 : l3 === "s32" ? (a2 = -2147483648, t3 = 2147483647) : l3 === "f32" ? (a2 = -34e38, t3 = 34e38) : l3 === "f64" && (a2 = -Number.MAX_VALUE, t3 = Number.MAX_VALUE), r3 = 255 / (t3 - a2);
  203. }
  204. const h2 = new Uint32Array(t2), n3 = this.width * this.height;
  205. let c3, u3, m3, x2, f2;
  206. if (c3 = u3 = m3 = e2[0], c3.length !== n3)
  207. return p.error("getAsRGBA()", "Unable to convert to RGBA. The pixelblock is invalid.");
  208. if (e2.length >= 2)
  209. if (u3 = e2[1], e2.length >= 3 && (m3 = e2[2]), s5 && s5.length === n3)
  210. for (x2 = 0; x2 < n3; x2++)
  211. s5[x2] && (h2[x2] = 255 << 24 | (m3[x2] - a2) * r3 << 16 | (u3[x2] - a2) * r3 << 8 | (c3[x2] - a2) * r3);
  212. else
  213. for (x2 = 0; x2 < n3; x2++)
  214. h2[x2] = 255 << 24 | (m3[x2] - a2) * r3 << 16 | (u3[x2] - a2) * r3 << 8 | (c3[x2] - a2) * r3;
  215. else if (s5 && s5.length === n3)
  216. for (x2 = 0; x2 < n3; x2++)
  217. f2 = (c3[x2] - a2) * r3, s5[x2] && (h2[x2] = 255 << 24 | f2 << 16 | f2 << 8 | f2);
  218. else
  219. for (x2 = 0; x2 < n3; x2++)
  220. f2 = (c3[x2] - a2) * r3, h2[x2] = 255 << 24 | f2 << 16 | f2 << 8 | f2;
  221. }
  222. _fillFrom32Bit(t2) {
  223. const { pixels: e2, mask: s5 } = this;
  224. if (!t2 || !e2 || !e2.length)
  225. return p.error("getAsRGBAFloat()", "Unable to convert to RGBA. The input pixel block is empty.");
  226. let i2, l3, r3, a2;
  227. i2 = l3 = r3 = e2[0], e2.length >= 3 ? (l3 = e2[1], r3 = e2[2]) : e2.length === 2 && (l3 = e2[1]);
  228. const o2 = this.width * this.height;
  229. if (i2.length !== o2)
  230. return p.error("getAsRGBAFloat()", "Unable to convert to RGBA. The pixelblock is invalid.");
  231. let h2 = 0;
  232. if (s5 && s5.length === o2)
  233. for (a2 = 0; a2 < o2; a2++)
  234. t2[h2++] = i2[a2], t2[h2++] = l3[a2], t2[h2++] = r3[a2], t2[h2++] = 1 & s5[a2];
  235. else
  236. for (a2 = 0; a2 < o2; a2++)
  237. t2[h2++] = i2[a2], t2[h2++] = l3[a2], t2[h2++] = r3[a2], t2[h2++] = 1;
  238. }
  239. _calculateBandStatistics(t2, e2) {
  240. let s5 = 1 / 0, i2 = -1 / 0;
  241. const l3 = t2.length;
  242. let r3, a2 = 0;
  243. if (e2)
  244. for (r3 = 0; r3 < l3; r3++)
  245. e2[r3] && (a2 = t2[r3], s5 = a2 < s5 ? a2 : s5, i2 = a2 > i2 ? a2 : i2);
  246. else
  247. for (r3 = 0; r3 < l3; r3++)
  248. a2 = t2[r3], s5 = a2 < s5 ? a2 : s5, i2 = a2 > i2 ? a2 : i2;
  249. return { minValue: s5, maxValue: i2 };
  250. }
  251. };
  252. e([d({ json: { write: true } })], c.prototype, "width", void 0), e([d({ json: { write: true } })], c.prototype, "height", void 0), e([d({ json: { write: true } })], c.prototype, "pixelType", void 0), e([s3("pixelType")], c.prototype, "castPixelType", null), e([d({ json: { write: true } })], c.prototype, "validPixelCount", void 0), e([d({ json: { write: true } })], c.prototype, "mask", void 0), e([d({ json: { write: true } })], c.prototype, "maskIsAlpha", void 0), e([d({ json: { write: true } })], c.prototype, "pixels", void 0), e([d({ json: { write: true } })], c.prototype, "statistics", void 0), c = n2 = e([n("esri.layers.support.PixelBlock")], c);
  253. var u = c;
  254. // node_modules/@arcgis/core/layers/support/rasterFunctions/pixelUtils.js
  255. function i(e2) {
  256. return r(e2) && e2.declaredClass === "esri.layers.support.PixelBlock" && e2.pixels && e2.pixels.length > 0;
  257. }
  258. function l2(t2, e2) {
  259. if (!e2?.length || !i(t2))
  260. return t2;
  261. const l3 = t2.pixels.length;
  262. return e2 && e2.some((t3) => t3 >= l3) || l3 === 1 && e2.length === 1 && e2[0] === 0 ? t2 : l3 !== e2.length || e2.some((t3, e3) => t3 !== e3) ? new u({ pixelType: t2.pixelType, width: t2.width, height: t2.height, mask: t2.mask, validPixelCount: t2.validPixelCount, maskIsAlpha: t2.maskIsAlpha, pixels: e2.map((e3) => t2.pixels[e3]), statistics: t2.statistics && e2.map((e3) => t2.statistics[e3]) }) : t2;
  263. }
  264. function o(t2) {
  265. if (!t2)
  266. return;
  267. const e2 = t2.colormap;
  268. if (!e2 || e2.length === 0)
  269. return;
  270. const n3 = e2.sort((t3, e3) => t3[0] - e3[0]);
  271. let i2 = 0;
  272. n3[0][0] < 0 && (i2 = n3[0][0]);
  273. const l3 = Math.max(256, n3[n3.length - 1][0] - i2 + 1), o2 = new Uint8Array(4 * l3), r3 = [];
  274. let s5, a2 = 0, h2 = 0;
  275. const f2 = n3[0].length === 5;
  276. if (l3 > 65536)
  277. return n3.forEach((t3) => {
  278. r3[t3[0] - i2] = f2 ? t3.slice(1) : t3.slice(1).concat([255]);
  279. }), { indexed2DColormap: r3, offset: i2, alphaSpecified: f2 };
  280. if (t2.fillUnspecified)
  281. for (s5 = n3[h2], a2 = s5[0] - i2; a2 < l3; a2++)
  282. o2[4 * a2] = s5[1], o2[4 * a2 + 1] = s5[2], o2[4 * a2 + 2] = s5[3], o2[4 * a2 + 3] = f2 ? s5[4] : 255, a2 === s5[0] - i2 && (s5 = h2 === n3.length - 1 ? s5 : n3[++h2]);
  283. else
  284. for (a2 = 0; a2 < n3.length; a2++)
  285. s5 = n3[a2], h2 = 4 * (s5[0] - i2), o2[h2] = s5[1], o2[h2 + 1] = s5[2], o2[h2 + 2] = s5[3], o2[h2 + 3] = f2 ? s5[4] : 255;
  286. return { indexedColormap: o2, offset: i2, alphaSpecified: f2 };
  287. }
  288. function r2(t2, e2) {
  289. if (!i(t2))
  290. return t2;
  291. if (!e2 && (e2.indexedColormap || e2.indexed2DColormap))
  292. return t2;
  293. const n3 = t2.clone(), l3 = n3.pixels;
  294. let o2 = n3.mask;
  295. const r3 = n3.width * n3.height;
  296. if (l3.length !== 1)
  297. return t2;
  298. const { indexedColormap: s5, indexed2DColormap: a2, offset: h2, alphaSpecified: f2 } = e2, c3 = s5.length - 1;
  299. let u3 = 0;
  300. const p3 = l3[0], x2 = new Uint8Array(p3.length), m3 = new Uint8Array(p3.length), d3 = new Uint8Array(p3.length);
  301. let y2, g2 = 0;
  302. if (s5)
  303. if (o2)
  304. for (u3 = 0; u3 < r3; u3++)
  305. o2[u3] && (g2 = 4 * (p3[u3] - h2), g2 < h2 || g2 > c3 ? o2[u3] = 0 : (x2[u3] = s5[g2], m3[u3] = s5[g2 + 1], d3[u3] = s5[g2 + 2], o2[u3] = s5[g2 + 3]));
  306. else {
  307. for (o2 = new Uint8Array(r3), u3 = 0; u3 < r3; u3++)
  308. g2 = 4 * (p3[u3] - h2), g2 < h2 || g2 > c3 ? o2[u3] = 0 : (x2[u3] = s5[g2], m3[u3] = s5[g2 + 1], d3[u3] = s5[g2 + 2], o2[u3] = s5[g2 + 3]);
  309. n3.mask = o2;
  310. }
  311. else if (o2)
  312. for (u3 = 0; u3 < r3; u3++)
  313. o2[u3] && (y2 = a2[p3[u3]], x2[u3] = y2[0], m3[u3] = y2[1], d3[u3] = y2[2], o2[u3] = y2[3]);
  314. else {
  315. for (o2 = new Uint8Array(r3), u3 = 0; u3 < r3; u3++)
  316. y2 = a2[p3[u3]], x2[u3] = y2[0], m3[u3] = y2[1], d3[u3] = y2[2], o2[u3] = y2[3];
  317. n3.mask = o2;
  318. }
  319. return n3.pixels = [x2, m3, d3], n3.statistics = null, n3.pixelType = "u8", n3.maskIsAlpha = f2, n3;
  320. }
  321. function s4(t2, e2) {
  322. if (!i(t2))
  323. return null;
  324. const { pixels: l3, mask: o2 } = t2, r3 = t2.width * t2.height, s5 = l3.length;
  325. let a2 = e2.lut;
  326. const { offset: h2 } = e2;
  327. let f2, c3;
  328. a2 && a2[0].length === 1 && (a2 = l3.map(() => a2));
  329. const u3 = [];
  330. let p3, x2, m3;
  331. if (h2)
  332. if (o2 == null)
  333. for (f2 = 0; f2 < s5; f2++) {
  334. for (p3 = l3[f2], x2 = a2[f2], m3 = new Uint8Array(r3), c3 = 0; c3 < r3; c3++)
  335. m3[c3] = x2[p3[c3] - h2];
  336. u3.push(m3);
  337. }
  338. else
  339. for (f2 = 0; f2 < s5; f2++) {
  340. for (p3 = l3[f2], x2 = a2[f2], m3 = new Uint8Array(r3), c3 = 0; c3 < r3; c3++)
  341. o2[c3] && (m3[c3] = x2[p3[c3] - h2]);
  342. u3.push(m3);
  343. }
  344. else if (o2 == null)
  345. for (f2 = 0; f2 < s5; f2++) {
  346. for (p3 = l3[f2], x2 = a2[f2], m3 = new Uint8Array(r3), c3 = 0; c3 < r3; c3++)
  347. m3[c3] = x2[p3[c3]];
  348. u3.push(m3);
  349. }
  350. else
  351. for (f2 = 0; f2 < s5; f2++) {
  352. for (p3 = l3[f2], x2 = a2[f2], m3 = new Uint8Array(r3), c3 = 0; c3 < r3; c3++)
  353. o2[c3] && (m3[c3] = x2[p3[c3]]);
  354. u3.push(m3);
  355. }
  356. const d3 = new u({ width: t2.width, height: t2.height, pixels: u3, mask: o2, pixelType: "u8" });
  357. return d3.updateStatistics(), d3;
  358. }
  359. function a(t2, e2) {
  360. if (!i(t2))
  361. return null;
  362. const n3 = t2.clone(), { pixels: l3 } = n3, o2 = n3.width * n3.height, r3 = e2.length, s5 = Math.floor(r3 / 2), a2 = e2[Math.floor(s5)], h2 = l3[0];
  363. let f2, c3, u3, p3, x2, m3, d3 = false;
  364. const y2 = new Uint8Array(o2), g2 = new Uint8Array(o2), w2 = new Uint8Array(o2);
  365. let k2 = n3.mask;
  366. const M2 = e2[0].mappedColor.length === 4;
  367. for (k2 || (k2 = new Uint8Array(o2), k2.fill(M2 ? 255 : 1), n3.mask = k2), x2 = 0; x2 < o2; x2++)
  368. if (k2[x2]) {
  369. for (f2 = h2[x2], d3 = false, m3 = s5, c3 = a2, u3 = 0, p3 = r3 - 1; p3 - u3 > 1; ) {
  370. if (f2 === c3.value) {
  371. d3 = true;
  372. break;
  373. }
  374. f2 > c3.value ? u3 = m3 : p3 = m3, m3 = Math.floor((u3 + p3) / 2), c3 = e2[Math.floor(m3)];
  375. }
  376. d3 || (f2 === e2[u3].value ? (c3 = e2[u3], d3 = true) : f2 === e2[p3].value ? (c3 = e2[p3], d3 = true) : f2 < e2[u3].value ? (d3 = false, c3 = null) : f2 > e2[u3].value && (f2 < e2[p3].value ? (c3 = e2[u3], d3 = true) : p3 === r3 - 1 ? (d3 = false, c3 = null) : (c3 = e2[p3], d3 = true))), d3 ? (y2[x2] = c3.mappedColor[0], g2[x2] = c3.mappedColor[1], w2[x2] = c3.mappedColor[2], k2[x2] = c3.mappedColor[3]) : y2[x2] = g2[x2] = w2[x2] = k2[x2] = 0;
  377. }
  378. return n3.pixels = [y2, g2, w2], n3.mask = k2, n3.pixelType = "u8", n3.maskIsAlpha = M2, n3;
  379. }
  380. function h(t2, e2, n3, i2, l3, o2, r3, s5) {
  381. return { xmin: l3 <= n3 * t2 ? 0 : l3 < n3 * t2 + t2 ? l3 - n3 * t2 : t2, ymin: o2 <= i2 * e2 ? 0 : o2 < i2 * e2 + e2 ? o2 - i2 * e2 : e2, xmax: l3 + r3 <= n3 * t2 ? 0 : l3 + r3 < n3 * t2 + t2 ? l3 + r3 - n3 * t2 : t2, ymax: o2 + s5 <= i2 * e2 ? 0 : o2 + s5 < i2 * e2 + e2 ? o2 + s5 - i2 * e2 : e2 };
  382. }
  383. function f(t2, n3) {
  384. if (!t2 || t2.length === 0)
  385. return null;
  386. const i2 = t2.find((t3) => t3.pixelBlock);
  387. if (!i2 || t(i2.pixelBlock))
  388. return null;
  389. const l3 = (i2.extent.xmax - i2.extent.xmin) / i2.pixelBlock.width, o2 = (i2.extent.ymax - i2.extent.ymin) / i2.pixelBlock.height, r3 = 0.01 * Math.min(l3, o2), s5 = t2.sort((t3, e2) => Math.abs(t3.extent.ymax - e2.extent.ymax) > r3 ? e2.extent.ymax - t3.extent.ymax : Math.abs(t3.extent.xmin - e2.extent.xmin) > r3 ? t3.extent.xmin - e2.extent.xmin : 0), a2 = Math.min.apply(null, s5.map((t3) => t3.extent.xmin)), h2 = Math.min.apply(null, s5.map((t3) => t3.extent.ymin)), f2 = Math.max.apply(null, s5.map((t3) => t3.extent.xmax)), c3 = Math.max.apply(null, s5.map((t3) => t3.extent.ymax)), p3 = { x: Math.round((n3.xmin - a2) / l3), y: Math.round((c3 - n3.ymax) / o2) }, x2 = { width: Math.round((f2 - a2) / l3), height: Math.round((c3 - h2) / o2) }, m3 = { width: Math.round((n3.xmax - n3.xmin) / l3), height: Math.round((n3.ymax - n3.ymin) / o2) };
  390. if (Math.round(x2.width / i2.pixelBlock.width) * Math.round(x2.height / i2.pixelBlock.height) !== s5.length || p3.x < 0 || p3.y < 0 || x2.width < m3.width || x2.height < m3.height)
  391. return null;
  392. return { extent: n3, pixelBlock: u2(s5.map((t3) => t3.pixelBlock), x2, { clipOffset: p3, clipSize: m3 }) };
  393. }
  394. function c2(t2, e2, n3, i2, l3, o2) {
  395. const { width: r3, height: s5 } = n3.block, { x: a2, y: f2 } = n3.offset, { width: c3, height: u3 } = n3.mosaic, p3 = h(r3, s5, i2, l3, a2, f2, c3, u3);
  396. let x2 = 0, m3 = 0;
  397. if (o2) {
  398. const t3 = o2.hasGCSSShiftTransform ? 360 : o2.halfWorldWidth, e3 = r3 * o2.resolutionX, n4 = o2.startX + i2 * e3, l4 = n4 + e3;
  399. n4 < t3 && l4 > t3 ? m3 = o2.rightPadding : n4 >= t3 && (x2 = o2.leftMargin - o2.rightPadding, m3 = 0);
  400. }
  401. if (p3.xmax -= m3, typeof e2 != "number")
  402. for (let h2 = p3.ymin; h2 < p3.ymax; h2++) {
  403. const n4 = (l3 * s5 + h2 - f2) * c3 + (i2 * r3 - a2) + x2, o3 = h2 * r3;
  404. for (let i3 = p3.xmin; i3 < p3.xmax; i3++)
  405. t2[n4 + i3] = e2[o3 + i3];
  406. }
  407. else
  408. for (let h2 = p3.ymin; h2 < p3.ymax; h2++) {
  409. const n4 = (l3 * s5 + h2 - f2) * c3 + (i2 * r3 - a2) + x2;
  410. for (let i3 = p3.xmin; i3 < p3.xmax; i3++)
  411. t2[n4 + i3] = e2;
  412. }
  413. }
  414. function u2(l3, o2, r3 = {}) {
  415. const { clipOffset: s5, clipSize: a2, alignmentInfo: h2, blockWidths: f2 } = r3;
  416. if (f2)
  417. return p2(l3, o2, { blockWidths: f2 });
  418. const u3 = l3.find((t2) => i(t2));
  419. if (t(u3))
  420. return null;
  421. const x2 = a2 ? a2.width : o2.width, m3 = a2 ? a2.height : o2.height, d3 = u3.width, y2 = u3.height, g2 = o2.width / d3, w2 = o2.height / y2, k2 = { offset: s5 || { x: 0, y: 0 }, mosaic: a2 || o2, block: { width: d3, height: y2 } }, M2 = u3.pixelType, A2 = u.getPixelArrayConstructor(M2), U2 = u3.pixels.length, C2 = [];
  422. let T, S;
  423. for (let t2 = 0; t2 < U2; t2++) {
  424. S = new A2(x2 * m3);
  425. for (let e2 = 0; e2 < w2; e2++)
  426. for (let n3 = 0; n3 < g2; n3++) {
  427. const o3 = l3[e2 * g2 + n3];
  428. i(o3) && (T = o3.pixels[t2], c2(S, T, k2, n3, e2, h2));
  429. }
  430. C2.push(S);
  431. }
  432. let B;
  433. if (l3.some((t2) => t(t2) || t2.mask && t2.mask.length > 0)) {
  434. B = new Uint8Array(x2 * m3);
  435. for (let e2 = 0; e2 < w2; e2++)
  436. for (let n3 = 0; n3 < g2; n3++) {
  437. const i2 = l3[e2 * g2 + n3], o3 = r(i2) ? i2.mask : null;
  438. c2(B, o3 || (i2 ? 1 : 0), k2, n3, e2, h2);
  439. }
  440. }
  441. const v = new u({ width: x2, height: m3, pixels: C2, pixelType: M2, mask: B });
  442. return v.updateStatistics(), v;
  443. }
  444. function p2(l3, o2, r3) {
  445. const s5 = l3.find((e2) => r(e2));
  446. if (t(s5))
  447. return null;
  448. const a2 = l3.some((e2) => !r(e2) || !!e2.mask), { width: h2, height: f2 } = o2, c3 = a2 ? new Uint8Array(h2 * f2) : null, { blockWidths: u3 } = r3, p3 = [], x2 = s5.getPlaneCount(), m3 = u.getPixelArrayConstructor(s5.pixelType);
  449. if (a2)
  450. for (let t2 = 0, e2 = 0; t2 < l3.length; e2 += u3[t2], t2++) {
  451. const n3 = l3[t2];
  452. if (!i(n3))
  453. continue;
  454. const o3 = n3.mask;
  455. for (let i2 = 0; i2 < f2; i2++)
  456. for (let l4 = 0; l4 < u3[t2]; l4++)
  457. c3[i2 * h2 + l4 + e2] = o3 == null ? 255 : o3[i2 * n3.width + l4];
  458. }
  459. for (let t2 = 0; t2 < x2; t2++) {
  460. const e2 = new m3(h2 * f2);
  461. for (let n3 = 0, o3 = 0; n3 < l3.length; o3 += u3[n3], n3++) {
  462. const r4 = l3[n3];
  463. if (!i(r4))
  464. continue;
  465. const s6 = r4.pixels[t2];
  466. if (s6 != null)
  467. for (let t3 = 0; t3 < f2; t3++)
  468. for (let i2 = 0; i2 < u3[n3]; i2++)
  469. e2[t3 * h2 + i2 + o3] = s6[t3 * r4.width + i2];
  470. }
  471. p3.push(e2);
  472. }
  473. const d3 = new u({ width: h2, height: f2, mask: c3, pixels: p3, pixelType: s5.pixelType });
  474. return d3.updateStatistics(), d3;
  475. }
  476. function x(t2, e2, n3) {
  477. if (!i(t2))
  478. return null;
  479. const { width: l3, height: o2 } = t2, r3 = e2.x, s5 = e2.y, a2 = n3.width + r3, h2 = n3.height + s5;
  480. if (r3 < 0 || s5 < 0 || a2 > l3 || h2 > o2)
  481. return t2;
  482. if (r3 === 0 && s5 === 0 && a2 === l3 && h2 === o2)
  483. return t2;
  484. t2.mask || (t2.mask = new Uint8Array(l3 * o2));
  485. const f2 = t2.mask;
  486. for (let i2 = 0; i2 < o2; i2++) {
  487. const t3 = i2 * l3;
  488. for (let e3 = 0; e3 < l3; e3++)
  489. f2[t3 + e3] = i2 < s5 || i2 >= h2 || e3 < r3 || e3 >= a2 ? 0 : 1;
  490. }
  491. return t2.updateStatistics(), t2;
  492. }
  493. function m2(t2) {
  494. if (!i(t2))
  495. return null;
  496. const e2 = t2.clone(), { width: n3, height: l3, pixels: o2, mask: r3 } = t2, s5 = o2[0], a2 = e2.pixels[0];
  497. for (let i2 = 2; i2 < l3 - 1; i2++) {
  498. const t3 = new Map();
  499. for (let l4 = i2 - 2; l4 < i2 + 2; l4++)
  500. for (let e4 = 0; e4 < 4; e4++) {
  501. const i3 = l4 * n3 + e4;
  502. g(t3, s5[i3], r3 ? r3[i3] : 1);
  503. }
  504. a2[i2 * n3] = d2(t3), a2[i2 * n3 + 1] = a2[i2 * n3 + 2] = a2[i2 * n3];
  505. let e3 = 3;
  506. for (; e3 < n3 - 1; e3++) {
  507. let l4 = (i2 - 2) * n3 + e3 + 1;
  508. g(t3, s5[l4], r3 ? r3[l4] : 1), l4 = (i2 - 1) * n3 + e3 + 1, g(t3, s5[l4], r3 ? r3[l4] : 1), l4 = i2 * n3 + e3 + 1, g(t3, s5[l4], r3 ? r3[l4] : 1), l4 = (i2 + 1) * n3 + e3 + 1, g(t3, s5[l4], r3 ? r3[l4] : 1), l4 = (i2 - 2) * n3 + e3 - 3, y(t3, s5[l4], r3 ? r3[l4] : 1), l4 = (i2 - 1) * n3 + e3 - 3, y(t3, s5[l4], r3 ? r3[l4] : 1), l4 = i2 * n3 + e3 - 3, y(t3, s5[l4], r3 ? r3[l4] : 1), l4 = (i2 + 1) * n3 + e3 - 3, y(t3, s5[l4], r3 ? r3[l4] : 1), a2[i2 * n3 + e3] = d2(t3);
  509. }
  510. a2[i2 * n3 + e3 + 1] = a2[i2 * n3 + e3];
  511. }
  512. for (let i2 = 0; i2 < n3; i2++)
  513. a2[i2] = a2[n3 + i2] = a2[2 * n3 + i2], a2[(l3 - 1) * n3 + i2] = a2[(l3 - 2) * n3 + i2];
  514. return e2.updateStatistics(), e2;
  515. }
  516. function d2(t2) {
  517. if (t2.size === 0)
  518. return 0;
  519. let e2 = 0, n3 = -1, i2 = 0;
  520. const l3 = t2.keys();
  521. let o2 = l3.next();
  522. for (; !o2.done; )
  523. i2 = t2.get(o2.value), i2 > e2 && (n3 = o2.value, e2 = i2), o2 = l3.next();
  524. return n3;
  525. }
  526. function y(t2, e2, n3) {
  527. if (n3 === 0)
  528. return;
  529. const i2 = t2.get(e2);
  530. i2 === 1 ? t2.delete(e2) : t2.set(e2, i2 - 1);
  531. }
  532. function g(t2, e2, n3) {
  533. n3 !== 0 && t2.set(e2, t2.has(e2) ? t2.get(e2) + 1 : 1);
  534. }
  535. function w(t2, e2, l3) {
  536. let { x: o2, y: r3 } = e2;
  537. const { width: s5, height: a2 } = l3;
  538. if (o2 === 0 && r3 === 0 && a2 === t2.height && s5 === t2.width)
  539. return t2;
  540. const { width: h2, height: f2 } = t2, c3 = Math.max(0, r3), u3 = Math.max(0, o2), p3 = Math.min(o2 + s5, h2), x2 = Math.min(r3 + a2, f2);
  541. if (p3 < 0 || x2 < 0 || !i(t2))
  542. return null;
  543. o2 = Math.max(0, -o2), r3 = Math.max(0, -r3);
  544. const { pixels: m3, mask: d3 } = t2, y2 = s5 * a2, g2 = m3.length, w2 = [];
  545. for (let i2 = 0; i2 < g2; i2++) {
  546. const e3 = m3[i2], l4 = u.createEmptyBand(t2.pixelType, y2);
  547. for (let t3 = c3; t3 < x2; t3++) {
  548. const n3 = t3 * h2;
  549. let i3 = (t3 + r3 - c3) * s5 + o2;
  550. for (let t4 = u3; t4 < p3; t4++)
  551. l4[i3++] = e3[n3 + t4];
  552. }
  553. w2.push(l4);
  554. }
  555. const k2 = new Uint8Array(y2);
  556. for (let n3 = c3; n3 < x2; n3++) {
  557. const t3 = n3 * h2;
  558. let e3 = (n3 + r3 - c3) * s5 + o2;
  559. for (let n4 = u3; n4 < p3; n4++)
  560. k2[e3++] = d3 ? d3[t3 + n4] : 1;
  561. }
  562. const M2 = new u({ width: l3.width, height: l3.height, pixelType: t2.pixelType, pixels: w2, mask: k2 });
  563. return M2.updateStatistics(), M2;
  564. }
  565. function k(t2, e2 = true) {
  566. if (!i(t2))
  567. return null;
  568. const { pixels: l3, width: o2, height: r3, mask: s5, pixelType: a2 } = t2, h2 = [], f2 = Math.round(o2 / 2), c3 = Math.round(r3 / 2), u3 = r3 - 1, p3 = o2 - 1;
  569. for (let i2 = 0; i2 < l3.length; i2++) {
  570. const t3 = l3[i2], s6 = u.createEmptyBand(a2, f2 * c3);
  571. let x3 = 0;
  572. for (let n3 = 0; n3 < r3; n3 += 2)
  573. for (let i3 = 0; i3 < o2; i3 += 2) {
  574. const l4 = t3[n3 * o2 + i3];
  575. if (e2) {
  576. const e3 = i3 === p3 ? l4 : t3[n3 * o2 + i3 + 1], r4 = n3 === u3 ? l4 : t3[n3 * o2 + i3 + o2], a3 = i3 === p3 ? r4 : n3 === u3 ? e3 : t3[n3 * o2 + i3 + o2 + 1];
  577. s6[x3++] = (l4 + e3 + r4 + a3) / 4;
  578. } else
  579. s6[x3++] = l4;
  580. }
  581. h2.push(s6);
  582. }
  583. let x2 = null;
  584. if (s5) {
  585. x2 = new Uint8Array(f2 * c3);
  586. let t3 = 0;
  587. for (let n3 = 0; n3 < r3; n3 += 2)
  588. for (let i2 = 0; i2 < o2; i2 += 2) {
  589. const l4 = s5[n3 * o2 + i2];
  590. if (e2) {
  591. const e3 = i2 === p3 ? l4 : s5[n3 * o2 + i2 + 1], r4 = n3 === u3 ? l4 : s5[n3 * o2 + i2 + o2], a3 = i2 === p3 ? r4 : n3 === u3 ? e3 : s5[n3 * o2 + i2 + o2 + 1];
  592. x2[t3++] = l4 * e3 * r4 * a3 ? 1 : 0;
  593. } else
  594. x2[t3++] = l4;
  595. }
  596. }
  597. return new u({ width: f2, height: c3, pixelType: a2, pixels: h2, mask: x2 });
  598. }
  599. function M(t2, e2, n3) {
  600. if (!i(t2))
  601. return null;
  602. const { width: l3, height: o2 } = e2;
  603. let { width: r3, height: s5 } = t2;
  604. const a2 = new Map(), h2 = { x: 0, y: 0 }, f2 = n3 == null ? 1 : 1 + n3;
  605. let c3 = t2;
  606. for (let i2 = 0; i2 < f2; i2++) {
  607. const t3 = Math.ceil(r3 / l3), n4 = Math.ceil(s5 / o2);
  608. for (let r4 = 0; r4 < n4; r4++) {
  609. h2.y = r4 * o2;
  610. for (let n5 = 0; n5 < t3; n5++) {
  611. h2.x = n5 * l3;
  612. const t4 = w(c3, h2, e2);
  613. a2.set(`${i2}/${r4}/${n5}`, t4);
  614. }
  615. }
  616. i2 < f2 - 1 && (c3 = k(c3)), r3 = Math.round(r3 / 2), s5 = Math.round(s5 / 2);
  617. }
  618. return a2;
  619. }
  620. function A(t2, e2, n3, i2, l3 = 0.5) {
  621. const { width: o2, height: r3 } = t2, { width: s5, height: a2 } = e2, h2 = i2.cols, f2 = i2.rows, c3 = Math.ceil(s5 / h2 - 0.1 / h2), u3 = Math.ceil(a2 / f2 - 0.1 / f2);
  622. let p3, x2, m3, d3, y2, g2, w2;
  623. const k2 = c3 * h2, M2 = k2 * u3 * f2, A2 = new Float32Array(M2), U2 = new Float32Array(M2), C2 = new Uint32Array(M2), T = new Uint32Array(M2);
  624. let S, B, v = 0;
  625. for (let P = 0; P < u3; P++)
  626. for (let t3 = 0; t3 < c3; t3++) {
  627. p3 = 12 * (P * c3 + t3), x2 = n3[p3], m3 = n3[p3 + 1], d3 = n3[p3 + 2], y2 = n3[p3 + 3], g2 = n3[p3 + 4], w2 = n3[p3 + 5];
  628. for (let e3 = 0; e3 < f2; e3++) {
  629. v = (P * f2 + e3) * k2 + t3 * h2, B = (e3 + 0.5) / f2;
  630. for (let t4 = 0; t4 < e3; t4++)
  631. S = (t4 + 0.5) / h2, A2[v + t4] = (x2 * S + m3 * B + d3) * o2 - l3, U2[v + t4] = (y2 * S + g2 * B + w2) * r3 - l3, C2[v + t4] = Math.round(A2[v + t4]), T[v + t4] = Math.round(U2[v + t4]);
  632. }
  633. p3 += 6, x2 = n3[p3], m3 = n3[p3 + 1], d3 = n3[p3 + 2], y2 = n3[p3 + 3], g2 = n3[p3 + 4], w2 = n3[p3 + 5];
  634. for (let e3 = 0; e3 < f2; e3++) {
  635. v = (P * f2 + e3) * k2 + t3 * h2, B = (e3 + 0.5) / f2;
  636. for (let t4 = e3; t4 < h2; t4++)
  637. S = (t4 + 0.5) / h2, A2[v + t4] = (x2 * S + m3 * B + d3) * o2 - l3, U2[v + t4] = (y2 * S + g2 * B + w2) * r3 - l3, C2[v + t4] = Math.round(A2[v + t4]), T[v + t4] = Math.round(U2[v + t4]);
  638. }
  639. }
  640. return { offsets_x: A2, offsets_y: U2, offsets_xi: C2, offsets_yi: T, gridWidth: k2 };
  641. }
  642. function U(t2, e2) {
  643. const { coefficients: n3, spacing: i2 } = e2, { offsets_x: l3, offsets_y: o2, gridWidth: r3 } = A(t2, t2, n3, { rows: i2[0], cols: i2[1] }, 0.5), { width: s5, height: a2 } = t2, h2 = new Float32Array(s5 * a2), f2 = 180 / Math.PI;
  644. for (let c3 = 0; c3 < a2; c3++)
  645. for (let t3 = 0; t3 < s5; t3++) {
  646. const e3 = c3 * r3 + t3, n4 = c3 === 0 ? e3 : e3 - r3, i3 = c3 === a2 - 1 ? e3 : e3 + r3, u3 = l3[n4] - l3[i3], p3 = o2[i3] - o2[n4];
  647. if (isNaN(u3) || isNaN(p3))
  648. h2[c3 * s5 + t3] = 90;
  649. else {
  650. let e4 = Math.atan2(p3, u3) * f2;
  651. e4 = (360 + e4) % 360, h2[c3 * s5 + t3] = e4;
  652. }
  653. }
  654. return h2;
  655. }
  656. function C(t2, e2, l3, o2, r3 = "nearest") {
  657. if (!i(t2))
  658. return null;
  659. r3 === "majority" && (t2 = m2(t2));
  660. const { pixels: s5, mask: a2, pixelType: h2 } = t2, f2 = t2.width, c3 = t2.height, u3 = u.getPixelArrayConstructor(h2), p3 = s5.length, { width: x2, height: d3 } = e2;
  661. let y2 = false;
  662. for (let n3 = 0; n3 < l3.length; n3 += 3)
  663. l3[n3] === -1 && l3[n3 + 1] === -1 && l3[n3 + 2] === -1 && (y2 = true);
  664. const { offsets_x: g2, offsets_y: w2, offsets_xi: k2, offsets_yi: M2, gridWidth: U2 } = A({ width: f2, height: c3 }, e2, l3, o2, r3 === "majority" ? 0 : 0.5);
  665. let C2;
  666. const T = (t3, e3, n3) => {
  667. const i2 = t3 instanceof Float32Array || t3 instanceof Float64Array ? 0 : 0.5;
  668. for (let l4 = 0; l4 < d3; l4++) {
  669. C2 = l4 * U2;
  670. for (let o3 = 0; o3 < x2; o3++) {
  671. if (g2[C2] < 0 || w2[C2] < 0)
  672. t3[l4 * x2 + o3] = 0;
  673. else if (n3)
  674. t3[l4 * x2 + o3] = e3[k2[C2] + M2[C2] * f2];
  675. else {
  676. const n4 = Math.floor(g2[C2]), r4 = Math.floor(w2[C2]), s6 = Math.ceil(g2[C2]), h3 = Math.ceil(w2[C2]), c4 = g2[C2] - n4, u4 = w2[C2] - r4;
  677. if (!a2 || a2[n4 + r4 * f2] && a2[n4 + r4 * f2] && a2[n4 + h3 * f2] && a2[s6 + h3 * f2]) {
  678. const a3 = (1 - c4) * e3[n4 + r4 * f2] + c4 * e3[s6 + r4 * f2], p4 = (1 - c4) * e3[n4 + h3 * f2] + c4 * e3[s6 + h3 * f2];
  679. t3[l4 * x2 + o3] = (1 - u4) * a3 + u4 * p4 + i2;
  680. } else
  681. t3[l4 * x2 + o3] = e3[k2[C2] + M2[C2] * f2];
  682. }
  683. C2++;
  684. }
  685. }
  686. }, S = [];
  687. let B;
  688. for (let n3 = 0; n3 < p3; n3++)
  689. B = new u3(x2 * d3), T(B, s5[n3], r3 === "nearest" || r3 === "majority"), S.push(B);
  690. const v = new u({ width: x2, height: d3, pixelType: h2, pixels: S });
  691. if (a2)
  692. v.mask = new Uint8Array(x2 * d3), T(v.mask, a2, true);
  693. else if (y2) {
  694. v.mask = new Uint8Array(x2 * d3);
  695. for (let t3 = 0; t3 < x2 * d3; t3++)
  696. v.mask[t3] = g2[t3] < 0 || w2[t3] < 0 ? 0 : 1;
  697. }
  698. return v.updateStatistics(), v;
  699. }
  700. export {
  701. u,
  702. i,
  703. l2 as l,
  704. o,
  705. r2 as r,
  706. s4 as s,
  707. a,
  708. f,
  709. u2,
  710. x,
  711. M,
  712. U,
  713. C
  714. };
  715. //# sourceMappingURL=chunk-EE6TL7XD.js.map