chunk-5JK4DCPE.js 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131
  1. import {
  2. o2 as o
  3. } from "./chunk-XNLG7T2T.js";
  4. import {
  5. t
  6. } from "./chunk-GZT4BVFP.js";
  7. // node_modules/@arcgis/core/views/support/screenshotUtils.js
  8. function r(t2, i, h) {
  9. const { ctx: e, canvas: n } = g(t2, h), o2 = e.getImageData(0, 0, t2.width, t2.height), a = c(n, i);
  10. return u(n), { dataUrl: a, data: o2 };
  11. }
  12. function l(t2, i) {
  13. const { ctx: h, canvas: e } = g(t2, i), n = h.getImageData(0, 0, t2.width, t2.height);
  14. return u(e), n;
  15. }
  16. function g(t2, i) {
  17. const h = f();
  18. i.premultipliedAlpha && E(t2), h.width = t2.width, h.height = t2.height;
  19. const e = h.getContext("2d");
  20. return e.putImageData(t2, 0, 0), i.flipY && B(e), { ctx: e, canvas: h };
  21. }
  22. function u(t2) {
  23. t2.width = 0, t2.height = 0;
  24. }
  25. function f() {
  26. return t(d) && (d = document.createElement("canvas")), d;
  27. }
  28. var d = null;
  29. function c(t2, i) {
  30. const h = R[i.format], e = i.quality / 100;
  31. return t2.toDataURL(h, e);
  32. }
  33. function s(i, h) {
  34. const e = k(i), n = W[e];
  35. return { format: e, quality: o(h != null ? h : n, 0, 100) };
  36. }
  37. function w(t2, i) {
  38. return i / Math.max(t2[0], t2[1]);
  39. }
  40. function m(t2, i, h) {
  41. if (!t2 || !i)
  42. throw new Error("Cannot construct image data without dimensions");
  43. if (j)
  44. try {
  45. return new ImageData(t2, i);
  46. } catch (e) {
  47. j = false;
  48. }
  49. return x(t2, i, h);
  50. }
  51. function M(t2, i, h, e) {
  52. if (!i || !h)
  53. throw new Error("Cannot construct image data without dimensions");
  54. if (j)
  55. try {
  56. return new ImageData(t2, i, h);
  57. } catch (o2) {
  58. j = false;
  59. }
  60. const n = x(i, h, e);
  61. return n.data.set(t2, 0), n;
  62. }
  63. function p(t2, i, h, e = 0, n = 0, o2 = t2.width - e, a = t2.height - n, r2 = false) {
  64. const { data: l2 } = t2, { width: g2, height: u2, data: f2 } = i, d2 = o2 / g2, c2 = a / u2, s2 = Math.ceil(d2 / 2), w2 = Math.ceil(c2 / 2), m2 = t2.width;
  65. for (let M2 = 0; M2 < u2; M2++)
  66. for (let t3 = 0; t3 < g2; t3++) {
  67. const i2 = 4 * (t3 + (r2 ? u2 - M2 - 1 : M2) * g2);
  68. let o3 = 0, a2 = 0, p2 = 0, y = 0, x2 = 0, b2 = 0;
  69. const j2 = (M2 + 0.5) * c2;
  70. for (let r3 = Math.floor(M2 * c2); r3 < (M2 + 1) * c2; r3++) {
  71. const i3 = Math.abs(j2 - (r3 + 0.5)) / w2, g3 = (t3 + 0.5) * d2, u3 = i3 * i3;
  72. for (let f3 = Math.floor(t3 * d2); f3 < (t3 + 1) * d2; f3++) {
  73. const t4 = Math.abs(g3 - (f3 + 0.5)) / s2, i4 = Math.sqrt(u3 + t4 * t4);
  74. if (i4 >= 1)
  75. continue;
  76. let d3 = 2 * i4 * i4 * i4 - 3 * i4 * i4 + 1;
  77. const c3 = 4 * (e + f3 + (n + r3) * m2);
  78. b2 += d3 * l2[c3 + 3], a2 += d3, !h && l2[c3 + 3] < 255 && (d3 = d3 * l2[c3 + 3] / 255), p2 += d3 * l2[c3], y += d3 * l2[c3 + 1], x2 += d3 * l2[c3 + 2], o3 += d3;
  79. }
  80. }
  81. f2[i2] = p2 / o3, f2[i2 + 1] = y / o3, f2[i2 + 2] = x2 / o3, f2[i2 + 3] = b2 / a2;
  82. }
  83. return i;
  84. }
  85. function x(t2, i, h) {
  86. return h || (h = D()), h.getContext("2d").createImageData(t2, i);
  87. }
  88. var b = null;
  89. var j = true;
  90. function D() {
  91. return b || (b = document.createElement("canvas"), b.width = 1, b.height = 1), b;
  92. }
  93. function k(t2) {
  94. switch (t2) {
  95. case "png":
  96. case "jpg":
  97. case "jpeg":
  98. return t2;
  99. default:
  100. return U;
  101. }
  102. }
  103. function B(t2) {
  104. t2.save(), t2.globalCompositeOperation = "copy", t2.scale(1, -1), t2.translate(0, -t2.canvas.height), t2.drawImage(t2.canvas, 0, 0), t2.restore();
  105. }
  106. function E(t2) {
  107. const i = t2.data, h = i.length;
  108. for (let e = 0; e < h; e += 4) {
  109. const t3 = i[e + 3];
  110. if (t3 !== 255 && t3 > 0) {
  111. const h2 = 255 / t3;
  112. i[e + 0] = i[e + 0] * h2, i[e + 1] = i[e + 1] * h2, i[e + 2] = i[e + 2] * h2;
  113. }
  114. }
  115. }
  116. var R = { png: "image/png", jpg: "image/jpeg", jpeg: "image/jpeg" };
  117. var H = 98;
  118. var U = "png";
  119. var W = { png: 100, jpg: H, jpeg: H };
  120. export {
  121. r,
  122. l,
  123. s,
  124. w,
  125. m,
  126. M,
  127. p
  128. };
  129. //# sourceMappingURL=chunk-5JK4DCPE.js.map