pica 10.0.0 → 10.0.2
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 +4 -0
- package/dist/pica.cjs.d.ts +2 -1
- package/dist/pica.es.d.ts +2 -1
- package/dist/pica.js +215 -300
- package/dist/pica.js.map +1 -1
- package/dist/pica.min.js +1 -1
- package/dist/pica.min.js.map +1 -1
- package/dist/pica.min.mjs +1 -1
- package/dist/pica.min.mjs.map +1 -1
- package/dist/pica.mjs +215 -300
- package/dist/pica.mjs.map +1 -1
- package/dist/pica_main.js +214 -299
- package/dist/pica_main.js.map +1 -1
- package/dist/pica_main.mjs +214 -299
- package/dist/pica_main.mjs.map +1 -1
- package/dist/pica_worker.js +209 -294
- package/dist/pica_worker.js.map +1 -1
- package/package.json +24 -5
package/dist/pica.js
CHANGED
|
@@ -7,183 +7,105 @@ https://github.com/nodeca/pica
|
|
|
7
7
|
(function(global, factory) {
|
|
8
8
|
typeof exports === "object" && typeof module !== "undefined" ? module.exports = factory() : typeof define === "function" && define.amd ? define([], factory) : (global = typeof globalThis !== "undefined" ? globalThis : global || self, global.pica = factory());
|
|
9
9
|
})(this, function() {
|
|
10
|
-
var
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
if (from && typeof from === "object" || typeof from === "function") for (var keys = __getOwnPropNames(from), i = 0, n = keys.length, key; i < n; i++) {
|
|
19
|
-
key = keys[i];
|
|
20
|
-
if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
|
|
21
|
-
get: ((k) => from[k]).bind(null, key),
|
|
22
|
-
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
|
|
23
|
-
});
|
|
24
|
-
}
|
|
25
|
-
return to;
|
|
26
|
-
};
|
|
27
|
-
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", {
|
|
28
|
-
value: mod,
|
|
29
|
-
enumerable: true
|
|
30
|
-
}) : target, mod));
|
|
31
|
-
/*
|
|
32
|
-
object-assign
|
|
33
|
-
(c) Sindre Sorhus
|
|
34
|
-
@license MIT
|
|
35
|
-
*/
|
|
36
|
-
var require_object_assign = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
37
|
-
var getOwnPropertySymbols = Object.getOwnPropertySymbols;
|
|
38
|
-
var hasOwnProperty = Object.prototype.hasOwnProperty;
|
|
39
|
-
var propIsEnumerable = Object.prototype.propertyIsEnumerable;
|
|
40
|
-
function toObject(val) {
|
|
41
|
-
if (val === null || val === void 0) throw new TypeError("Object.assign cannot be called with null or undefined");
|
|
42
|
-
return Object(val);
|
|
43
|
-
}
|
|
44
|
-
function shouldUseNative() {
|
|
45
|
-
try {
|
|
46
|
-
if (!Object.assign) return false;
|
|
47
|
-
var test1 = /* @__PURE__ */ new String("abc");
|
|
48
|
-
test1[5] = "de";
|
|
49
|
-
if (Object.getOwnPropertyNames(test1)[0] === "5") return false;
|
|
50
|
-
var test2 = {};
|
|
51
|
-
for (var i = 0; i < 10; i++) test2["_" + String.fromCharCode(i)] = i;
|
|
52
|
-
if (Object.getOwnPropertyNames(test2).map(function(n) {
|
|
53
|
-
return test2[n];
|
|
54
|
-
}).join("") !== "0123456789") return false;
|
|
55
|
-
var test3 = {};
|
|
56
|
-
"abcdefghijklmnopqrst".split("").forEach(function(letter) {
|
|
57
|
-
test3[letter] = letter;
|
|
58
|
-
});
|
|
59
|
-
if (Object.keys(Object.assign({}, test3)).join("") !== "abcdefghijklmnopqrst") return false;
|
|
60
|
-
return true;
|
|
61
|
-
} catch (err) {
|
|
62
|
-
return false;
|
|
63
|
-
}
|
|
64
|
-
}
|
|
65
|
-
module.exports = shouldUseNative() ? Object.assign : function(target, source) {
|
|
66
|
-
var from;
|
|
67
|
-
var to = toObject(target);
|
|
68
|
-
var symbols;
|
|
69
|
-
for (var s = 1; s < arguments.length; s++) {
|
|
70
|
-
from = Object(arguments[s]);
|
|
71
|
-
for (var key in from) if (hasOwnProperty.call(from, key)) to[key] = from[key];
|
|
72
|
-
if (getOwnPropertySymbols) {
|
|
73
|
-
symbols = getOwnPropertySymbols(from);
|
|
74
|
-
for (var i = 0; i < symbols.length; i++) if (propIsEnumerable.call(from, symbols[i])) to[symbols[i]] = from[symbols[i]];
|
|
75
|
-
}
|
|
76
|
-
}
|
|
77
|
-
return to;
|
|
78
|
-
};
|
|
79
|
-
}));
|
|
80
|
-
var require_base64decode = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
81
|
-
var BASE64_MAP = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
|
|
82
|
-
module.exports = function base64decode(str) {
|
|
83
|
-
var input = str.replace(/[\r\n=]/g, ""), max = input.length;
|
|
84
|
-
var out = new Uint8Array(max * 3 >> 2);
|
|
85
|
-
var bits = 0;
|
|
86
|
-
var ptr = 0;
|
|
87
|
-
for (var idx = 0; idx < max; idx++) {
|
|
88
|
-
if (idx % 4 === 0 && idx) {
|
|
89
|
-
out[ptr++] = bits >> 16 & 255;
|
|
90
|
-
out[ptr++] = bits >> 8 & 255;
|
|
91
|
-
out[ptr++] = bits & 255;
|
|
92
|
-
}
|
|
93
|
-
bits = bits << 6 | BASE64_MAP.indexOf(input.charAt(idx));
|
|
94
|
-
}
|
|
95
|
-
var tailbits = max % 4 * 6;
|
|
96
|
-
if (tailbits === 0) {
|
|
10
|
+
var BASE64_MAP = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
|
|
11
|
+
function base64decode(str) {
|
|
12
|
+
const input = str.replace(/[\r\n=]/g, ""), max = input.length;
|
|
13
|
+
const out = new Uint8Array(max * 3 >> 2);
|
|
14
|
+
let bits = 0;
|
|
15
|
+
let ptr = 0;
|
|
16
|
+
for (let idx = 0; idx < max; idx++) {
|
|
17
|
+
if (idx % 4 === 0 && idx) {
|
|
97
18
|
out[ptr++] = bits >> 16 & 255;
|
|
98
19
|
out[ptr++] = bits >> 8 & 255;
|
|
99
20
|
out[ptr++] = bits & 255;
|
|
100
|
-
}
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
21
|
+
}
|
|
22
|
+
bits = bits << 6 | BASE64_MAP.indexOf(input.charAt(idx));
|
|
23
|
+
}
|
|
24
|
+
const tailbits = max % 4 * 6;
|
|
25
|
+
if (tailbits === 0) {
|
|
26
|
+
out[ptr++] = bits >> 16 & 255;
|
|
27
|
+
out[ptr++] = bits >> 8 & 255;
|
|
28
|
+
out[ptr++] = bits & 255;
|
|
29
|
+
} else if (tailbits === 18) {
|
|
30
|
+
out[ptr++] = bits >> 10 & 255;
|
|
31
|
+
out[ptr++] = bits >> 2 & 255;
|
|
32
|
+
} else if (tailbits === 12) out[ptr++] = bits >> 4 & 255;
|
|
33
|
+
return out;
|
|
34
|
+
}
|
|
35
|
+
var wa;
|
|
36
|
+
function hasWebAssembly() {
|
|
37
|
+
if (typeof wa !== "undefined") return wa;
|
|
38
|
+
wa = false;
|
|
39
|
+
if (typeof WebAssembly === "undefined") return wa;
|
|
40
|
+
try {
|
|
41
|
+
const bin = new Uint8Array([
|
|
42
|
+
0,
|
|
43
|
+
97,
|
|
44
|
+
115,
|
|
45
|
+
109,
|
|
46
|
+
1,
|
|
47
|
+
0,
|
|
48
|
+
0,
|
|
49
|
+
0,
|
|
50
|
+
1,
|
|
51
|
+
6,
|
|
52
|
+
1,
|
|
53
|
+
96,
|
|
54
|
+
1,
|
|
55
|
+
127,
|
|
56
|
+
1,
|
|
57
|
+
127,
|
|
58
|
+
3,
|
|
59
|
+
2,
|
|
60
|
+
1,
|
|
61
|
+
0,
|
|
62
|
+
5,
|
|
63
|
+
3,
|
|
64
|
+
1,
|
|
65
|
+
0,
|
|
66
|
+
1,
|
|
67
|
+
7,
|
|
68
|
+
8,
|
|
69
|
+
1,
|
|
70
|
+
4,
|
|
71
|
+
116,
|
|
72
|
+
101,
|
|
73
|
+
115,
|
|
74
|
+
116,
|
|
75
|
+
0,
|
|
76
|
+
0,
|
|
77
|
+
10,
|
|
78
|
+
16,
|
|
79
|
+
1,
|
|
80
|
+
14,
|
|
81
|
+
0,
|
|
82
|
+
32,
|
|
83
|
+
0,
|
|
84
|
+
65,
|
|
85
|
+
1,
|
|
86
|
+
54,
|
|
87
|
+
2,
|
|
88
|
+
0,
|
|
89
|
+
32,
|
|
90
|
+
0,
|
|
91
|
+
40,
|
|
92
|
+
2,
|
|
93
|
+
0,
|
|
94
|
+
11
|
|
95
|
+
]);
|
|
96
|
+
const module = new WebAssembly.Module(bin);
|
|
97
|
+
if (new WebAssembly.Instance(module, {}).exports.test(4) !== 0) wa = true;
|
|
173
98
|
return wa;
|
|
174
|
-
}
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
function MultiMath(options) {
|
|
185
|
-
if (!(this instanceof MultiMath)) return new MultiMath(options);
|
|
186
|
-
var opts = assign({}, DEFAULT_OPTIONS, options || {});
|
|
99
|
+
} catch (__) {}
|
|
100
|
+
return wa;
|
|
101
|
+
}
|
|
102
|
+
var DEFAULT_OPTIONS = {
|
|
103
|
+
js: true,
|
|
104
|
+
wasm: true
|
|
105
|
+
};
|
|
106
|
+
var MultiMath = class {
|
|
107
|
+
constructor(options) {
|
|
108
|
+
const opts = Object.assign({}, DEFAULT_OPTIONS, options || {});
|
|
187
109
|
this.options = opts;
|
|
188
110
|
this.__cache = {};
|
|
189
111
|
this.__init_promise = null;
|
|
@@ -198,47 +120,45 @@ https://github.com/nodeca/pica
|
|
|
198
120
|
]).buffer)[0] === 1;
|
|
199
121
|
if (!this.options.js && !this.options.wasm) throw new Error("mathlib: at least \"js\" or \"wasm\" should be enabled");
|
|
200
122
|
}
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
123
|
+
has_wasm() {
|
|
124
|
+
return hasWebAssembly();
|
|
125
|
+
}
|
|
126
|
+
use(module) {
|
|
127
|
+
this.__modules[module.name] = module;
|
|
128
|
+
if (this.options.wasm && this.has_wasm() && module.wasm_fn) this[module.name] = module.wasm_fn;
|
|
129
|
+
else this[module.name] = module.fn;
|
|
206
130
|
return this;
|
|
207
|
-
}
|
|
208
|
-
|
|
131
|
+
}
|
|
132
|
+
init() {
|
|
209
133
|
if (this.__init_promise) return this.__init_promise;
|
|
210
134
|
if (!this.options.js && this.options.wasm && !this.has_wasm()) return Promise.reject(/* @__PURE__ */ new Error("mathlib: only \"wasm\" was enabled, but it's not supported"));
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
if (
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
self.__wasm[name] = m;
|
|
135
|
+
this.__init_promise = Promise.all(Object.keys(this.__modules).map((name) => {
|
|
136
|
+
const module = this.__modules[name];
|
|
137
|
+
if (!this.options.wasm || !this.has_wasm() || !module.wasm_fn) return null;
|
|
138
|
+
if (this.__wasm[name]) return null;
|
|
139
|
+
return WebAssembly.compile(base64decode(module.wasm_src)).then((m) => {
|
|
140
|
+
this.__wasm[name] = m;
|
|
218
141
|
});
|
|
219
|
-
})).then(
|
|
220
|
-
return self;
|
|
221
|
-
});
|
|
142
|
+
})).then(() => this);
|
|
222
143
|
return this.__init_promise;
|
|
223
|
-
}
|
|
224
|
-
|
|
225
|
-
MultiMath.prototype.__reallocate = function mem_grow_to(bytes) {
|
|
144
|
+
}
|
|
145
|
+
__reallocate(bytes) {
|
|
226
146
|
if (!this.__memory) {
|
|
227
147
|
this.__memory = new WebAssembly.Memory({ initial: Math.ceil(bytes / (64 * 1024)) });
|
|
228
148
|
return this.__memory;
|
|
229
149
|
}
|
|
230
|
-
|
|
150
|
+
const mem_size = this.__memory.buffer.byteLength;
|
|
231
151
|
if (mem_size < bytes) this.__memory.grow(Math.ceil((bytes - mem_size) / (64 * 1024)));
|
|
232
152
|
return this.__memory;
|
|
233
|
-
}
|
|
234
|
-
|
|
153
|
+
}
|
|
154
|
+
__instance(name, memsize, env_extra) {
|
|
235
155
|
if (memsize) this.__reallocate(memsize);
|
|
236
156
|
if (!this.__wasm[name]) {
|
|
237
|
-
|
|
238
|
-
this.__wasm[name] = new WebAssembly.Module(
|
|
157
|
+
const module = this.__modules[name];
|
|
158
|
+
this.__wasm[name] = new WebAssembly.Module(base64decode(module.wasm_src));
|
|
239
159
|
}
|
|
240
160
|
if (!this.__cache[name]) {
|
|
241
|
-
|
|
161
|
+
const env_base = {
|
|
242
162
|
memoryBase: 0,
|
|
243
163
|
memory: this.__memory,
|
|
244
164
|
tableBase: 0,
|
|
@@ -247,100 +167,93 @@ https://github.com/nodeca/pica
|
|
|
247
167
|
element: "anyfunc"
|
|
248
168
|
})
|
|
249
169
|
};
|
|
250
|
-
this.__cache[name] = new WebAssembly.Instance(this.__wasm[name], { env: assign(env_base, env_extra || {}) });
|
|
170
|
+
this.__cache[name] = new WebAssembly.Instance(this.__wasm[name], { env: Object.assign(env_base, env_extra || {}) });
|
|
251
171
|
}
|
|
252
172
|
return this.__cache[name];
|
|
253
|
-
}
|
|
254
|
-
|
|
173
|
+
}
|
|
174
|
+
__align(number, base) {
|
|
255
175
|
base = base || 8;
|
|
256
|
-
|
|
176
|
+
const reminder = number % base;
|
|
257
177
|
return number + (reminder ? base - reminder : 0);
|
|
258
|
-
};
|
|
259
|
-
module.exports = MultiMath;
|
|
260
|
-
}));
|
|
261
|
-
var require_mono16 = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
262
|
-
var a0, a1, a2, a3, b1, b2, left_corner, right_corner;
|
|
263
|
-
function gaussCoef(sigma) {
|
|
264
|
-
if (sigma < .5) sigma = .5;
|
|
265
|
-
var a = Math.exp(.726 * .726) / sigma, g1 = Math.exp(-a), g2 = Math.exp(-2 * a), k = (1 - g1) * (1 - g1) / (1 + 2 * a * g1 - g2);
|
|
266
|
-
a0 = k;
|
|
267
|
-
a1 = k * (a - 1) * g1;
|
|
268
|
-
a2 = k * (a + 1) * g1;
|
|
269
|
-
a3 = -k * g2;
|
|
270
|
-
b1 = 2 * g1;
|
|
271
|
-
b2 = -g2;
|
|
272
|
-
left_corner = (a0 + a1) / (1 - b1 - b2);
|
|
273
|
-
right_corner = (a2 + a3) / (1 - b1 - b2);
|
|
274
|
-
return new Float32Array([
|
|
275
|
-
a0,
|
|
276
|
-
a1,
|
|
277
|
-
a2,
|
|
278
|
-
a3,
|
|
279
|
-
b1,
|
|
280
|
-
b2,
|
|
281
|
-
left_corner,
|
|
282
|
-
right_corner
|
|
283
|
-
]);
|
|
284
178
|
}
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
179
|
+
};
|
|
180
|
+
function gaussCoef(sigma) {
|
|
181
|
+
if (sigma < .5) sigma = .5;
|
|
182
|
+
const a = Math.exp(.726 * .726) / sigma, g1 = Math.exp(-a), g2 = Math.exp(-2 * a), k = (1 - g1) * (1 - g1) / (1 + 2 * a * g1 - g2);
|
|
183
|
+
const a0 = k;
|
|
184
|
+
const a1 = k * (a - 1) * g1;
|
|
185
|
+
const a2 = k * (a + 1) * g1;
|
|
186
|
+
const a3 = -k * g2;
|
|
187
|
+
const b1 = 2 * g1;
|
|
188
|
+
const b2 = -g2;
|
|
189
|
+
const left_corner = (a0 + a1) / (1 - b1 - b2);
|
|
190
|
+
const right_corner = (a2 + a3) / (1 - b1 - b2);
|
|
191
|
+
return new Float32Array([
|
|
192
|
+
a0,
|
|
193
|
+
a1,
|
|
194
|
+
a2,
|
|
195
|
+
a3,
|
|
196
|
+
b1,
|
|
197
|
+
b2,
|
|
198
|
+
left_corner,
|
|
199
|
+
right_corner
|
|
200
|
+
]);
|
|
201
|
+
}
|
|
202
|
+
function convolveMono16(src, out, line, coeff, width, height) {
|
|
203
|
+
let prev_src, curr_src, curr_out, prev_out, prev_prev_out;
|
|
204
|
+
let src_index, out_index, line_index;
|
|
205
|
+
let i, j;
|
|
206
|
+
let coeff_a0, coeff_a1, coeff_b1, coeff_b2;
|
|
207
|
+
for (i = 0; i < height; i++) {
|
|
208
|
+
src_index = i * width;
|
|
209
|
+
out_index = i;
|
|
210
|
+
line_index = 0;
|
|
211
|
+
prev_src = src[src_index];
|
|
212
|
+
prev_prev_out = prev_src * coeff[6];
|
|
213
|
+
prev_out = prev_prev_out;
|
|
214
|
+
coeff_a0 = coeff[0];
|
|
215
|
+
coeff_a1 = coeff[1];
|
|
216
|
+
coeff_b1 = coeff[4];
|
|
217
|
+
coeff_b2 = coeff[5];
|
|
218
|
+
for (j = 0; j < width; j++) {
|
|
219
|
+
curr_src = src[src_index];
|
|
220
|
+
curr_out = curr_src * coeff_a0 + prev_src * coeff_a1 + prev_out * coeff_b1 + prev_prev_out * coeff_b2;
|
|
221
|
+
prev_prev_out = prev_out;
|
|
222
|
+
prev_out = curr_out;
|
|
223
|
+
prev_src = curr_src;
|
|
224
|
+
line[line_index] = prev_out;
|
|
225
|
+
line_index++;
|
|
226
|
+
src_index++;
|
|
227
|
+
}
|
|
228
|
+
src_index--;
|
|
229
|
+
line_index--;
|
|
230
|
+
out_index += height * (width - 1);
|
|
231
|
+
prev_src = src[src_index];
|
|
232
|
+
prev_prev_out = prev_src * coeff[7];
|
|
233
|
+
prev_out = prev_prev_out;
|
|
234
|
+
curr_src = prev_src;
|
|
235
|
+
coeff_a0 = coeff[2];
|
|
236
|
+
coeff_a1 = coeff[3];
|
|
237
|
+
for (j = width - 1; j >= 0; j--) {
|
|
238
|
+
curr_out = curr_src * coeff_a0 + prev_src * coeff_a1 + prev_out * coeff_b1 + prev_prev_out * coeff_b2;
|
|
239
|
+
prev_prev_out = prev_out;
|
|
240
|
+
prev_out = curr_out;
|
|
241
|
+
prev_src = curr_src;
|
|
242
|
+
curr_src = src[src_index];
|
|
243
|
+
out[out_index] = line[line_index] + prev_out;
|
|
311
244
|
src_index--;
|
|
312
245
|
line_index--;
|
|
313
|
-
out_index
|
|
314
|
-
prev_src = src[src_index];
|
|
315
|
-
prev_prev_out = prev_src * coeff[7];
|
|
316
|
-
prev_out = prev_prev_out;
|
|
317
|
-
curr_src = prev_src;
|
|
318
|
-
coeff_a0 = coeff[2];
|
|
319
|
-
coeff_a1 = coeff[3];
|
|
320
|
-
for (j = width - 1; j >= 0; j--) {
|
|
321
|
-
curr_out = curr_src * coeff_a0 + prev_src * coeff_a1 + prev_out * coeff_b1 + prev_prev_out * coeff_b2;
|
|
322
|
-
prev_prev_out = prev_out;
|
|
323
|
-
prev_out = curr_out;
|
|
324
|
-
prev_src = curr_src;
|
|
325
|
-
curr_src = src[src_index];
|
|
326
|
-
out[out_index] = line[line_index] + prev_out;
|
|
327
|
-
src_index--;
|
|
328
|
-
line_index--;
|
|
329
|
-
out_index -= height;
|
|
330
|
-
}
|
|
246
|
+
out_index -= height;
|
|
331
247
|
}
|
|
332
248
|
}
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
}));
|
|
342
|
-
var import_multimath = /* @__PURE__ */ __toESM(require_multimath());
|
|
343
|
-
var import_mono16 = /* @__PURE__ */ __toESM(require_mono16());
|
|
249
|
+
}
|
|
250
|
+
function blurMono16(src, width, height, radius) {
|
|
251
|
+
if (!radius) return;
|
|
252
|
+
const out = new Uint16Array(src.length), tmp_line = new Float32Array(Math.max(width, height));
|
|
253
|
+
const coeff = gaussCoef(radius);
|
|
254
|
+
convolveMono16(src, out, tmp_line, coeff, width, height, radius);
|
|
255
|
+
convolveMono16(out, src, tmp_line, coeff, height, width, radius);
|
|
256
|
+
}
|
|
344
257
|
function hsv_v16(img, width, height) {
|
|
345
258
|
const size = width * height;
|
|
346
259
|
const out = new Uint16Array(size);
|
|
@@ -361,7 +274,7 @@ https://github.com/nodeca/pica
|
|
|
361
274
|
if (radius > 2) radius = 2;
|
|
362
275
|
const brightness = hsv_v16(img, width, height);
|
|
363
276
|
const blured = new Uint16Array(brightness);
|
|
364
|
-
(
|
|
277
|
+
blurMono16(blured, width, height, radius);
|
|
365
278
|
const amountFp = amount / 100 * 4096 + .5 | 0;
|
|
366
279
|
const thresholdFp = threshold << 8;
|
|
367
280
|
const size = width * height;
|
|
@@ -788,7 +701,7 @@ https://github.com/nodeca/pica
|
|
|
788
701
|
wasm_fn: resize_wasm,
|
|
789
702
|
wasm_src: "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"
|
|
790
703
|
};
|
|
791
|
-
var MathLib = class extends
|
|
704
|
+
var MathLib = class extends MultiMath {
|
|
792
705
|
constructor(requested_features) {
|
|
793
706
|
const __requested_features = requested_features || [];
|
|
794
707
|
const features = {
|
|
@@ -1055,13 +968,14 @@ https://github.com/nodeca/pica
|
|
|
1055
968
|
};
|
|
1056
969
|
var checked = false;
|
|
1057
970
|
var checking = null;
|
|
971
|
+
var ctxOpts$1 = { willReadFrequently: true };
|
|
1058
972
|
function check_canvas() {
|
|
1059
973
|
if (typeof document === "undefined" || !document.createElement) return false;
|
|
1060
974
|
try {
|
|
1061
975
|
const canvas = document.createElement("canvas");
|
|
1062
976
|
canvas.width = 2;
|
|
1063
977
|
canvas.height = 1;
|
|
1064
|
-
const ctx = canvas.getContext("2d");
|
|
978
|
+
const ctx = canvas.getContext("2d", ctxOpts$1);
|
|
1065
979
|
let d = ctx.createImageData(2, 1);
|
|
1066
980
|
d.data[0] = 12;
|
|
1067
981
|
d.data[1] = 23;
|
|
@@ -1081,7 +995,7 @@ https://github.com/nodeca/pica
|
|
|
1081
995
|
function check_offscreen_canvas() {
|
|
1082
996
|
if (typeof OffscreenCanvas === "undefined") return false;
|
|
1083
997
|
try {
|
|
1084
|
-
const ctx = new OffscreenCanvas(2, 1).getContext("2d");
|
|
998
|
+
const ctx = new OffscreenCanvas(2, 1).getContext("2d", ctxOpts$1);
|
|
1085
999
|
let d = ctx.createImageData(2, 1);
|
|
1086
1000
|
d.data[0] = 12;
|
|
1087
1001
|
d.data[1] = 23;
|
|
@@ -1120,7 +1034,7 @@ https://github.com/nodeca/pica
|
|
|
1120
1034
|
return createImageBitmap(new Blob([bytes], { type: "image/jpeg" })).then((bitmap) => {
|
|
1121
1035
|
const canvas = new OffscreenCanvas(1, 1);
|
|
1122
1036
|
try {
|
|
1123
|
-
const ctx = canvas.getContext("2d");
|
|
1037
|
+
const ctx = canvas.getContext("2d", ctxOpts$1);
|
|
1124
1038
|
ctx.drawImage(bitmap, 1, 1, 1, 1, 0, 0, 1, 1);
|
|
1125
1039
|
return ctx.getImageData(0, 0, 1, 1).data[0] < 240;
|
|
1126
1040
|
} finally {
|
|
@@ -1135,7 +1049,7 @@ https://github.com/nodeca/pica
|
|
|
1135
1049
|
const canvas = document.createElement("canvas");
|
|
1136
1050
|
canvas.width = 1;
|
|
1137
1051
|
canvas.height = 1;
|
|
1138
|
-
const ctx = canvas.getContext("2d");
|
|
1052
|
+
const ctx = canvas.getContext("2d", ctxOpts$1);
|
|
1139
1053
|
ctx.drawImage(image, 1, 1, 1, 1, 0, 0, 1, 1);
|
|
1140
1054
|
resolve(ctx.getImageData(0, 0, 1, 1).data[0] < 240);
|
|
1141
1055
|
} catch (__) {
|
|
@@ -1167,7 +1081,7 @@ https://github.com/nodeca/pica
|
|
|
1167
1081
|
canvas.height = 1;
|
|
1168
1082
|
}
|
|
1169
1083
|
try {
|
|
1170
|
-
const ctx = canvas.getContext("2d");
|
|
1084
|
+
const ctx = canvas.getContext("2d", ctxOpts$1);
|
|
1171
1085
|
ctx.drawImage(bitmap, 0, 0);
|
|
1172
1086
|
return bitmap.width !== 1 || bitmap.height !== 1 || ctx.getImageData(0, 0, 1, 1).data[0] < 240;
|
|
1173
1087
|
} finally {
|
|
@@ -1192,7 +1106,7 @@ https://github.com/nodeca/pica
|
|
|
1192
1106
|
canvas.height = SRC_SIZE;
|
|
1193
1107
|
} else if (features.offscreen_canvas || check_offscreen_canvas()) {
|
|
1194
1108
|
canvas = new OffscreenCanvas(SRC_SIZE, SRC_SIZE);
|
|
1195
|
-
canvas.getContext("2d").clearRect(0, 0, SRC_SIZE, SRC_SIZE);
|
|
1109
|
+
canvas.getContext("2d", ctxOpts$1).clearRect(0, 0, SRC_SIZE, SRC_SIZE);
|
|
1196
1110
|
} else return false;
|
|
1197
1111
|
return createImageBitmap(canvas, 0, 0, SRC_SIZE, SRC_SIZE, {
|
|
1198
1112
|
resizeWidth: DST_SIZE,
|
|
@@ -1261,7 +1175,7 @@ https://github.com/nodeca/pica
|
|
|
1261
1175
|
});
|
|
1262
1176
|
};
|
|
1263
1177
|
}
|
|
1264
|
-
var WORKER_SRC = "/*!\n\npica\nhttps://github.com/nodeca/pica\n\n*/\n(function() {\n var __create = Object.create;\n var __defProp = Object.defineProperty;\n var __getOwnPropDesc = Object.getOwnPropertyDescriptor;\n var __getOwnPropNames = Object.getOwnPropertyNames;\n var __getProtoOf = Object.getPrototypeOf;\n var __hasOwnProp = Object.prototype.hasOwnProperty;\n var __commonJSMin = (cb, mod) => () => (mod || (cb((mod = { exports: {} }).exports, mod), cb = null), mod.exports);\n var __copyProps = (to, from, except, desc) => {\n if (from && typeof from === \"object\" || typeof from === \"function\") for (var keys = __getOwnPropNames(from), i = 0, n = keys.length, key; i < n; i++) {\n key = keys[i];\n if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {\n get: ((k) => from[k]).bind(null, key),\n enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable\n });\n }\n return to;\n };\n var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, \"default\", {\n value: mod,\n enumerable: true\n }) : target, mod));\n /*\n object-assign\n (c) Sindre Sorhus\n @license MIT\n */\n var require_object_assign = /* @__PURE__ */ __commonJSMin(((exports, module) => {\n var getOwnPropertySymbols = Object.getOwnPropertySymbols;\n var hasOwnProperty = Object.prototype.hasOwnProperty;\n var propIsEnumerable = Object.prototype.propertyIsEnumerable;\n function toObject(val) {\n if (val === null || val === void 0) throw new TypeError(\"Object.assign cannot be called with null or undefined\");\n return Object(val);\n }\n function shouldUseNative() {\n try {\n if (!Object.assign) return false;\n var test1 = /* @__PURE__ */ new String(\"abc\");\n test1[5] = \"de\";\n if (Object.getOwnPropertyNames(test1)[0] === \"5\") return false;\n var test2 = {};\n for (var i = 0; i < 10; i++) test2[\"_\" + String.fromCharCode(i)] = i;\n if (Object.getOwnPropertyNames(test2).map(function(n) {\n return test2[n];\n }).join(\"\") !== \"0123456789\") return false;\n var test3 = {};\n \"abcdefghijklmnopqrst\".split(\"\").forEach(function(letter) {\n test3[letter] = letter;\n });\n if (Object.keys(Object.assign({}, test3)).join(\"\") !== \"abcdefghijklmnopqrst\") return false;\n return true;\n } catch (err) {\n return false;\n }\n }\n module.exports = shouldUseNative() ? Object.assign : function(target, source) {\n var from;\n var to = toObject(target);\n var symbols;\n for (var s = 1; s < arguments.length; s++) {\n from = Object(arguments[s]);\n for (var key in from) if (hasOwnProperty.call(from, key)) to[key] = from[key];\n if (getOwnPropertySymbols) {\n symbols = getOwnPropertySymbols(from);\n for (var i = 0; i < symbols.length; i++) if (propIsEnumerable.call(from, symbols[i])) to[symbols[i]] = from[symbols[i]];\n }\n }\n return to;\n };\n }));\n var require_base64decode = /* @__PURE__ */ __commonJSMin(((exports, module) => {\n var BASE64_MAP = \"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/\";\n module.exports = function base64decode(str) {\n var input = str.replace(/[\\r\\n=]/g, \"\"), max = input.length;\n var out = new Uint8Array(max * 3 >> 2);\n var bits = 0;\n var ptr = 0;\n for (var idx = 0; idx < max; idx++) {\n if (idx % 4 === 0 && idx) {\n out[ptr++] = bits >> 16 & 255;\n out[ptr++] = bits >> 8 & 255;\n out[ptr++] = bits & 255;\n }\n bits = bits << 6 | BASE64_MAP.indexOf(input.charAt(idx));\n }\n var tailbits = max % 4 * 6;\n if (tailbits === 0) {\n out[ptr++] = bits >> 16 & 255;\n out[ptr++] = bits >> 8 & 255;\n out[ptr++] = bits & 255;\n } else if (tailbits === 18) {\n out[ptr++] = bits >> 10 & 255;\n out[ptr++] = bits >> 2 & 255;\n } else if (tailbits === 12) out[ptr++] = bits >> 4 & 255;\n return out;\n };\n }));\n var require_wa_detect = /* @__PURE__ */ __commonJSMin(((exports, module) => {\n var wa;\n module.exports = function hasWebAssembly() {\n if (typeof wa !== \"undefined\") return wa;\n wa = false;\n if (typeof WebAssembly === \"undefined\") return wa;\n try {\n var bin = new Uint8Array([\n 0,\n 97,\n 115,\n 109,\n 1,\n 0,\n 0,\n 0,\n 1,\n 6,\n 1,\n 96,\n 1,\n 127,\n 1,\n 127,\n 3,\n 2,\n 1,\n 0,\n 5,\n 3,\n 1,\n 0,\n 1,\n 7,\n 8,\n 1,\n 4,\n 116,\n 101,\n 115,\n 116,\n 0,\n 0,\n 10,\n 16,\n 1,\n 14,\n 0,\n 32,\n 0,\n 65,\n 1,\n 54,\n 2,\n 0,\n 32,\n 0,\n 40,\n 2,\n 0,\n 11\n ]);\n var module$4 = new WebAssembly.Module(bin);\n if (new WebAssembly.Instance(module$4, {}).exports.test(4) !== 0) wa = true;\n return wa;\n } catch (__) {}\n return wa;\n };\n }));\n var require_multimath = /* @__PURE__ */ __commonJSMin(((exports, module) => {\n var assign = require_object_assign();\n var base64decode = require_base64decode();\n var hasWebAssembly = require_wa_detect();\n var DEFAULT_OPTIONS = {\n js: true,\n wasm: true\n };\n function MultiMath(options) {\n if (!(this instanceof MultiMath)) return new MultiMath(options);\n var opts = assign({}, DEFAULT_OPTIONS, options || {});\n this.options = opts;\n this.__cache = {};\n this.__init_promise = null;\n this.__modules = opts.modules || {};\n this.__memory = null;\n this.__wasm = {};\n this.__isLE = new Uint32Array(new Uint8Array([\n 1,\n 0,\n 0,\n 0\n ]).buffer)[0] === 1;\n if (!this.options.js && !this.options.wasm) throw new Error(\"mathlib: at least \\\"js\\\" or \\\"wasm\\\" should be enabled\");\n }\n MultiMath.prototype.has_wasm = hasWebAssembly;\n MultiMath.prototype.use = function(module$1) {\n this.__modules[module$1.name] = module$1;\n if (this.options.wasm && this.has_wasm() && module$1.wasm_fn) this[module$1.name] = module$1.wasm_fn;\n else this[module$1.name] = module$1.fn;\n return this;\n };\n MultiMath.prototype.init = function() {\n if (this.__init_promise) return this.__init_promise;\n if (!this.options.js && this.options.wasm && !this.has_wasm()) return Promise.reject(/* @__PURE__ */ new Error(\"mathlib: only \\\"wasm\\\" was enabled, but it's not supported\"));\n var self = this;\n this.__init_promise = Promise.all(Object.keys(self.__modules).map(function(name) {\n var module$2 = self.__modules[name];\n if (!self.options.wasm || !self.has_wasm() || !module$2.wasm_fn) return null;\n if (self.__wasm[name]) return null;\n return WebAssembly.compile(self.__base64decode(module$2.wasm_src)).then(function(m) {\n self.__wasm[name] = m;\n });\n })).then(function() {\n return self;\n });\n return this.__init_promise;\n };\n MultiMath.prototype.__base64decode = base64decode;\n MultiMath.prototype.__reallocate = function mem_grow_to(bytes) {\n if (!this.__memory) {\n this.__memory = new WebAssembly.Memory({ initial: Math.ceil(bytes / (64 * 1024)) });\n return this.__memory;\n }\n var mem_size = this.__memory.buffer.byteLength;\n if (mem_size < bytes) this.__memory.grow(Math.ceil((bytes - mem_size) / (64 * 1024)));\n return this.__memory;\n };\n MultiMath.prototype.__instance = function instance(name, memsize, env_extra) {\n if (memsize) this.__reallocate(memsize);\n if (!this.__wasm[name]) {\n var module$3 = this.__modules[name];\n this.__wasm[name] = new WebAssembly.Module(this.__base64decode(module$3.wasm_src));\n }\n if (!this.__cache[name]) {\n var env_base = {\n memoryBase: 0,\n memory: this.__memory,\n tableBase: 0,\n table: new WebAssembly.Table({\n initial: 0,\n element: \"anyfunc\"\n })\n };\n this.__cache[name] = new WebAssembly.Instance(this.__wasm[name], { env: assign(env_base, env_extra || {}) });\n }\n return this.__cache[name];\n };\n MultiMath.prototype.__align = function align(number, base) {\n base = base || 8;\n var reminder = number % base;\n return number + (reminder ? base - reminder : 0);\n };\n module.exports = MultiMath;\n }));\n var require_mono16 = /* @__PURE__ */ __commonJSMin(((exports, module) => {\n var a0, a1, a2, a3, b1, b2, left_corner, right_corner;\n function gaussCoef(sigma) {\n if (sigma < .5) sigma = .5;\n var a = Math.exp(.726 * .726) / sigma, g1 = Math.exp(-a), g2 = Math.exp(-2 * a), k = (1 - g1) * (1 - g1) / (1 + 2 * a * g1 - g2);\n a0 = k;\n a1 = k * (a - 1) * g1;\n a2 = k * (a + 1) * g1;\n a3 = -k * g2;\n b1 = 2 * g1;\n b2 = -g2;\n left_corner = (a0 + a1) / (1 - b1 - b2);\n right_corner = (a2 + a3) / (1 - b1 - b2);\n return new Float32Array([\n a0,\n a1,\n a2,\n a3,\n b1,\n b2,\n left_corner,\n right_corner\n ]);\n }\n function convolveMono16(src, out, line, coeff, width, height) {\n var prev_src, curr_src, curr_out, prev_out, prev_prev_out;\n var src_index, out_index, line_index;\n var i, j;\n var coeff_a0, coeff_a1, coeff_b1, coeff_b2;\n for (i = 0; i < height; i++) {\n src_index = i * width;\n out_index = i;\n line_index = 0;\n prev_src = src[src_index];\n prev_prev_out = prev_src * coeff[6];\n prev_out = prev_prev_out;\n coeff_a0 = coeff[0];\n coeff_a1 = coeff[1];\n coeff_b1 = coeff[4];\n coeff_b2 = coeff[5];\n for (j = 0; j < width; j++) {\n curr_src = src[src_index];\n curr_out = curr_src * coeff_a0 + prev_src * coeff_a1 + prev_out * coeff_b1 + prev_prev_out * coeff_b2;\n prev_prev_out = prev_out;\n prev_out = curr_out;\n prev_src = curr_src;\n line[line_index] = prev_out;\n line_index++;\n src_index++;\n }\n src_index--;\n line_index--;\n out_index += height * (width - 1);\n prev_src = src[src_index];\n prev_prev_out = prev_src * coeff[7];\n prev_out = prev_prev_out;\n curr_src = prev_src;\n coeff_a0 = coeff[2];\n coeff_a1 = coeff[3];\n for (j = width - 1; j >= 0; j--) {\n curr_out = curr_src * coeff_a0 + prev_src * coeff_a1 + prev_out * coeff_b1 + prev_prev_out * coeff_b2;\n prev_prev_out = prev_out;\n prev_out = curr_out;\n prev_src = curr_src;\n curr_src = src[src_index];\n out[out_index] = line[line_index] + prev_out;\n src_index--;\n line_index--;\n out_index -= height;\n }\n }\n }\n function blurMono16(src, width, height, radius) {\n if (!radius) return;\n var out = new Uint16Array(src.length), tmp_line = new Float32Array(Math.max(width, height));\n var coeff = gaussCoef(radius);\n convolveMono16(src, out, tmp_line, coeff, width, height, radius);\n convolveMono16(out, src, tmp_line, coeff, height, width, radius);\n }\n module.exports = blurMono16;\n }));\n var import_multimath = /* @__PURE__ */ __toESM(require_multimath());\n var import_mono16 = /* @__PURE__ */ __toESM(require_mono16());\n function hsv_v16(img, width, height) {\n const size = width * height;\n const out = new Uint16Array(size);\n let r, g, b, max;\n for (let i = 0; i < size; i++) {\n r = img[4 * i];\n g = img[4 * i + 1];\n b = img[4 * i + 2];\n max = r >= g && r >= b ? r : g >= b && g >= r ? g : b;\n out[i] = max << 8;\n }\n return out;\n }\n function unsharp$1(img, width, height, amount, radius, threshold) {\n let v1, v2, vmul;\n let diff, iTimes4;\n if (amount === 0 || radius < .5) return;\n if (radius > 2) radius = 2;\n const brightness = hsv_v16(img, width, height);\n const blured = new Uint16Array(brightness);\n (0, import_mono16.default)(blured, width, height, radius);\n const amountFp = amount / 100 * 4096 + .5 | 0;\n const thresholdFp = threshold << 8;\n const size = width * height;\n for (let i = 0; i < size; i++) {\n v1 = brightness[i];\n diff = v1 - blured[i];\n if (Math.abs(diff) >= thresholdFp) {\n v2 = v1 + (amountFp * diff + 2048 >> 12);\n v2 = v2 > 65280 ? 65280 : v2;\n v2 = v2 < 0 ? 0 : v2;\n v1 = v1 !== 0 ? v1 : 1;\n vmul = (v2 << 12) / v1 | 0;\n iTimes4 = i * 4;\n img[iTimes4] = img[iTimes4] * vmul + 2048 >> 12;\n img[iTimes4 + 1] = img[iTimes4 + 1] * vmul + 2048 >> 12;\n img[iTimes4 + 2] = img[iTimes4 + 2] * vmul + 2048 >> 12;\n }\n }\n }\n function unsharp(img, width, height, amount, radius, threshold) {\n if (amount === 0 || radius < .5) return;\n if (radius > 2) radius = 2;\n const pixels = width * height;\n const img_bytes_cnt = pixels * 4;\n const hsv_bytes_cnt = pixels * 2;\n const blur_bytes_cnt = pixels * 2;\n const blur_line_byte_cnt = Math.max(width, height) * 4;\n const blur_coeffs_byte_cnt = 32;\n const img_offset = 0;\n const hsv_offset = img_bytes_cnt;\n const blur_offset = hsv_offset + hsv_bytes_cnt;\n const blur_tmp_offset = blur_offset + blur_bytes_cnt;\n const blur_line_offset = blur_tmp_offset + blur_bytes_cnt;\n const blur_coeffs_offset = blur_line_offset + blur_line_byte_cnt;\n const instance = this.__instance(\"unsharp_mask\", img_bytes_cnt + hsv_bytes_cnt + blur_bytes_cnt * 2 + blur_line_byte_cnt + blur_coeffs_byte_cnt, { exp: Math.exp });\n const img32 = new Uint32Array(img.buffer);\n new Uint32Array(this.__memory.buffer).set(img32);\n let fn = instance.exports.hsv_v16 || instance.exports._hsv_v16;\n if (!fn) throw new Error(\"WASM hsv_v16 function is not available\");\n fn(img_offset, hsv_offset, width, height);\n fn = instance.exports.blurMono16 || instance.exports._blurMono16;\n if (!fn) throw new Error(\"WASM blurMono16 function is not available\");\n fn(hsv_offset, blur_offset, blur_tmp_offset, blur_line_offset, blur_coeffs_offset, width, height, radius);\n fn = instance.exports.unsharp || instance.exports._unsharp;\n if (!fn) throw new Error(\"WASM unsharp function is not available\");\n fn(img_offset, img_offset, hsv_offset, blur_offset, width, height, amount, threshold);\n img32.set(new Uint32Array(this.__memory.buffer, 0, pixels));\n }\n var mm_unsharp_mask_default = {\n name: \"unsharp_mask\",\n fn: unsharp$1,\n wasm_fn: unsharp,\n wasm_src: \"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\"\n };\n var resize_filter_info_default = { filter: {\n box: {\n win: .5,\n fn(x) {\n if (x < 0) x = -x;\n return x < .5 ? 1 : 0;\n }\n },\n hamming: {\n win: 1,\n fn(x) {\n if (x < 0) x = -x;\n if (x >= 1) return 0;\n if (x < 1.1920929e-7) return 1;\n const xpi = x * Math.PI;\n return Math.sin(xpi) / xpi * (.54 + .46 * Math.cos(xpi / 1));\n }\n },\n lanczos2: {\n win: 2,\n fn(x) {\n if (x < 0) x = -x;\n if (x >= 2) return 0;\n if (x < 1.1920929e-7) return 1;\n const xpi = x * Math.PI;\n return Math.sin(xpi) / xpi * Math.sin(xpi / 2) / (xpi / 2);\n }\n },\n lanczos3: {\n win: 3,\n fn(x) {\n if (x < 0) x = -x;\n if (x >= 3) return 0;\n if (x < 1.1920929e-7) return 1;\n const xpi = x * Math.PI;\n return Math.sin(xpi) / xpi * Math.sin(xpi / 3) / (xpi / 3);\n }\n },\n mks2013: {\n win: 2.5,\n fn(x) {\n if (x < 0) x = -x;\n if (x >= 2.5) return 0;\n if (x >= 1.5) return -.125 * (x - 2.5) * (x - 2.5);\n if (x >= .5) return .25 * (4 * x * x - 11 * x + 7);\n return 1.0625 - 1.75 * x * x;\n }\n }\n } };\n var FIXED_FRAC_BITS = 14;\n function toFixedPoint(num) {\n return Math.round(num * ((1 << FIXED_FRAC_BITS) - 1));\n }\n function resizeFilterGen(filter, srcSize, destSize, scale, offset) {\n const filterFunction = resize_filter_info_default.filter[filter].fn;\n const scaleInverted = 1 / scale;\n const scaleClamped = Math.min(1, scale);\n const srcWindow = resize_filter_info_default.filter[filter].win / scaleClamped;\n let destPixel, srcPixel, srcFirst, srcLast, filterElementSize, floatFilter, fxpFilter, total, pxl, idx, floatVal, filterTotal, filterVal;\n let leftNotEmpty, rightNotEmpty, filterShift, filterSize;\n const maxFilterElementSize = Math.floor((srcWindow + 1) * 2);\n const packedFilter = new Int16Array((maxFilterElementSize + 2) * destSize);\n let packedFilterPtr = 0;\n const slowCopy = !packedFilter.subarray || !packedFilter.set;\n for (destPixel = 0; destPixel < destSize; destPixel++) {\n srcPixel = (destPixel + .5) * scaleInverted + offset;\n srcFirst = Math.max(0, Math.floor(srcPixel - srcWindow));\n srcLast = Math.min(srcSize - 1, Math.ceil(srcPixel + srcWindow));\n filterElementSize = srcLast - srcFirst + 1;\n floatFilter = new Float32Array(filterElementSize);\n fxpFilter = new Int16Array(filterElementSize);\n total = 0;\n for (pxl = srcFirst, idx = 0; pxl <= srcLast; pxl++, idx++) {\n floatVal = filterFunction((pxl + .5 - srcPixel) * scaleClamped);\n total += floatVal;\n floatFilter[idx] = floatVal;\n }\n filterTotal = 0;\n for (idx = 0; idx < floatFilter.length; idx++) {\n filterVal = floatFilter[idx] / total;\n filterTotal += filterVal;\n fxpFilter[idx] = toFixedPoint(filterVal);\n }\n fxpFilter[destSize >> 1] += toFixedPoint(1 - filterTotal);\n leftNotEmpty = 0;\n while (leftNotEmpty < fxpFilter.length && fxpFilter[leftNotEmpty] === 0) leftNotEmpty++;\n if (leftNotEmpty < fxpFilter.length) {\n rightNotEmpty = fxpFilter.length - 1;\n while (rightNotEmpty > 0 && fxpFilter[rightNotEmpty] === 0) rightNotEmpty--;\n filterShift = srcFirst + leftNotEmpty;\n filterSize = rightNotEmpty - leftNotEmpty + 1;\n packedFilter[packedFilterPtr++] = filterShift;\n packedFilter[packedFilterPtr++] = filterSize;\n if (!slowCopy) {\n packedFilter.set(fxpFilter.subarray(leftNotEmpty, rightNotEmpty + 1), packedFilterPtr);\n packedFilterPtr += filterSize;\n } else for (idx = leftNotEmpty; idx <= rightNotEmpty; idx++) packedFilter[packedFilterPtr++] = fxpFilter[idx];\n } else {\n packedFilter[packedFilterPtr++] = 0;\n packedFilter[packedFilterPtr++] = 0;\n }\n }\n return packedFilter;\n }\n function clampTo8(i) {\n return i < 0 ? 0 : i > 255 ? 255 : i;\n }\n function clampNegative(i) {\n return i >= 0 ? i : 0;\n }\n function convolveHor(src, dest, srcW, srcH, destW, filters) {\n let r, g, b, a;\n let filterPtr, filterShift, filterSize;\n let srcPtr, srcY, destX, filterVal;\n let srcOffset = 0, destOffset = 0;\n for (srcY = 0; srcY < srcH; srcY++) {\n filterPtr = 0;\n for (destX = 0; destX < destW; destX++) {\n filterShift = filters[filterPtr++];\n filterSize = filters[filterPtr++];\n srcPtr = srcOffset + filterShift * 4 | 0;\n r = g = b = a = 0;\n for (; filterSize > 0; filterSize--) {\n filterVal = filters[filterPtr++];\n a = a + filterVal * src[srcPtr + 3] | 0;\n b = b + filterVal * src[srcPtr + 2] | 0;\n g = g + filterVal * src[srcPtr + 1] | 0;\n r = r + filterVal * src[srcPtr] | 0;\n srcPtr = srcPtr + 4 | 0;\n }\n dest[destOffset + 3] = clampNegative(a >> 7);\n dest[destOffset + 2] = clampNegative(b >> 7);\n dest[destOffset + 1] = clampNegative(g >> 7);\n dest[destOffset] = clampNegative(r >> 7);\n destOffset = destOffset + srcH * 4 | 0;\n }\n destOffset = (srcY + 1) * 4 | 0;\n srcOffset = (srcY + 1) * srcW * 4 | 0;\n }\n }\n function convolveVert(src, dest, srcW, srcH, destW, filters) {\n let r, g, b, a;\n let filterPtr, filterShift, filterSize;\n let srcPtr, srcY, destX, filterVal;\n let srcOffset = 0, destOffset = 0;\n for (srcY = 0; srcY < srcH; srcY++) {\n filterPtr = 0;\n for (destX = 0; destX < destW; destX++) {\n filterShift = filters[filterPtr++];\n filterSize = filters[filterPtr++];\n srcPtr = srcOffset + filterShift * 4 | 0;\n r = g = b = a = 0;\n for (; filterSize > 0; filterSize--) {\n filterVal = filters[filterPtr++];\n a = a + filterVal * src[srcPtr + 3] | 0;\n b = b + filterVal * src[srcPtr + 2] | 0;\n g = g + filterVal * src[srcPtr + 1] | 0;\n r = r + filterVal * src[srcPtr] | 0;\n srcPtr = srcPtr + 4 | 0;\n }\n r >>= 7;\n g >>= 7;\n b >>= 7;\n a >>= 7;\n dest[destOffset + 3] = clampTo8(a + 8192 >> 14);\n dest[destOffset + 2] = clampTo8(b + 8192 >> 14);\n dest[destOffset + 1] = clampTo8(g + 8192 >> 14);\n dest[destOffset] = clampTo8(r + 8192 >> 14);\n destOffset = destOffset + srcH * 4 | 0;\n }\n destOffset = (srcY + 1) * 4 | 0;\n srcOffset = (srcY + 1) * srcW * 4 | 0;\n }\n }\n function convolveHorWithPre(src, dest, srcW, srcH, destW, filters) {\n let r, g, b, a, alpha;\n let filterPtr, filterShift, filterSize;\n let srcPtr, srcY, destX, filterVal;\n let srcOffset = 0, destOffset = 0;\n for (srcY = 0; srcY < srcH; srcY++) {\n filterPtr = 0;\n for (destX = 0; destX < destW; destX++) {\n filterShift = filters[filterPtr++];\n filterSize = filters[filterPtr++];\n srcPtr = srcOffset + filterShift * 4 | 0;\n r = g = b = a = 0;\n for (; filterSize > 0; filterSize--) {\n filterVal = filters[filterPtr++];\n alpha = src[srcPtr + 3];\n a = a + filterVal * alpha | 0;\n b = b + filterVal * src[srcPtr + 2] * alpha | 0;\n g = g + filterVal * src[srcPtr + 1] * alpha | 0;\n r = r + filterVal * src[srcPtr] * alpha | 0;\n srcPtr = srcPtr + 4 | 0;\n }\n b = b / 255 | 0;\n g = g / 255 | 0;\n r = r / 255 | 0;\n dest[destOffset + 3] = clampNegative(a >> 7);\n dest[destOffset + 2] = clampNegative(b >> 7);\n dest[destOffset + 1] = clampNegative(g >> 7);\n dest[destOffset] = clampNegative(r >> 7);\n destOffset = destOffset + srcH * 4 | 0;\n }\n destOffset = (srcY + 1) * 4 | 0;\n srcOffset = (srcY + 1) * srcW * 4 | 0;\n }\n }\n function convolveVertWithPre(src, dest, srcW, srcH, destW, filters) {\n let r, g, b, a;\n let filterPtr, filterShift, filterSize;\n let srcPtr, srcY, destX, filterVal;\n let srcOffset = 0, destOffset = 0;\n for (srcY = 0; srcY < srcH; srcY++) {\n filterPtr = 0;\n for (destX = 0; destX < destW; destX++) {\n filterShift = filters[filterPtr++];\n filterSize = filters[filterPtr++];\n srcPtr = srcOffset + filterShift * 4 | 0;\n r = g = b = a = 0;\n for (; filterSize > 0; filterSize--) {\n filterVal = filters[filterPtr++];\n a = a + filterVal * src[srcPtr + 3] | 0;\n b = b + filterVal * src[srcPtr + 2] | 0;\n g = g + filterVal * src[srcPtr + 1] | 0;\n r = r + filterVal * src[srcPtr] | 0;\n srcPtr = srcPtr + 4 | 0;\n }\n r >>= 7;\n g >>= 7;\n b >>= 7;\n a >>= 7;\n a = clampTo8(a + 8192 >> 14);\n if (a > 0) {\n r = r * 255 / a | 0;\n g = g * 255 / a | 0;\n b = b * 255 / a | 0;\n }\n dest[destOffset + 3] = a;\n dest[destOffset + 2] = clampTo8(b + 8192 >> 14);\n dest[destOffset + 1] = clampTo8(g + 8192 >> 14);\n dest[destOffset] = clampTo8(r + 8192 >> 14);\n destOffset = destOffset + srcH * 4 | 0;\n }\n destOffset = (srcY + 1) * 4 | 0;\n srcOffset = (srcY + 1) * srcW * 4 | 0;\n }\n }\n function hasAlpha$1(src, width, height) {\n let ptr = 3;\n const len = width * height * 4 | 0;\n while (ptr < len) {\n if (src[ptr] !== 255) return true;\n ptr = ptr + 4 | 0;\n }\n return false;\n }\n function resetAlpha$1(dst, width, height) {\n let ptr = 3;\n const len = width * height * 4 | 0;\n while (ptr < len) {\n dst[ptr] = 255;\n ptr = ptr + 4 | 0;\n }\n }\n function resize$1(options) {\n const src = options.src;\n const srcW = options.width;\n const srcH = options.height;\n const destW = options.toWidth;\n const destH = options.toHeight;\n const scaleX = options.scaleX || options.toWidth / options.width;\n const scaleY = options.scaleY || options.toHeight / options.height;\n const offsetX = options.offsetX || 0;\n const offsetY = options.offsetY || 0;\n const dest = options.dest || new Uint8Array(destW * destH * 4);\n const filter = typeof options.filter === \"undefined\" ? \"mks2013\" : options.filter;\n const filtersX = resizeFilterGen(filter, srcW, destW, scaleX, offsetX), filtersY = resizeFilterGen(filter, srcH, destH, scaleY, offsetY);\n const tmp = new Uint16Array(destW * srcH * 4);\n if (hasAlpha$1(src, srcW, srcH)) {\n convolveHorWithPre(src, tmp, srcW, srcH, destW, filtersX);\n convolveVertWithPre(tmp, dest, srcH, destW, destH, filtersY);\n } else {\n convolveHor(src, tmp, srcW, srcH, destW, filtersX);\n convolveVert(tmp, dest, srcH, destW, destH, filtersY);\n resetAlpha$1(dest, destW, destH);\n }\n return dest;\n }\n function hasAlpha(src, width, height) {\n let ptr = 3;\n const len = width * height * 4 | 0;\n while (ptr < len) {\n if (src[ptr] !== 255) return true;\n ptr = ptr + 4 | 0;\n }\n return false;\n }\n function resetAlpha(dst, width, height) {\n let ptr = 3;\n const len = width * height * 4 | 0;\n while (ptr < len) {\n dst[ptr] = 255;\n ptr = ptr + 4 | 0;\n }\n }\n function asUint8Array(src) {\n return new Uint8Array(src.buffer, 0, src.byteLength);\n }\n var IS_LE = true;\n try {\n IS_LE = new Uint32Array(new Uint8Array([\n 1,\n 0,\n 0,\n 0\n ]).buffer)[0] === 1;\n } catch (__) {}\n function copyInt16asLE(src, target, target_offset) {\n if (IS_LE) {\n target.set(asUint8Array(src), target_offset);\n return;\n }\n for (let ptr = target_offset, i = 0; i < src.length; i++) {\n const data = src[i];\n target[ptr++] = data & 255;\n target[ptr++] = data >> 8 & 255;\n }\n }\n function resize_wasm(options) {\n const src = options.src;\n const srcW = options.width;\n const srcH = options.height;\n const destW = options.toWidth;\n const destH = options.toHeight;\n const scaleX = options.scaleX || options.toWidth / options.width;\n const scaleY = options.scaleY || options.toHeight / options.height;\n const offsetX = options.offsetX || 0;\n const offsetY = options.offsetY || 0;\n const dest = options.dest || new Uint8Array(destW * destH * 4);\n const filter = typeof options.filter === \"undefined\" ? \"mks2013\" : options.filter;\n const filtersX = resizeFilterGen(filter, srcW, destW, scaleX, offsetX), filtersY = resizeFilterGen(filter, srcH, destH, scaleY, offsetY);\n const src_offset = 0;\n const src_size = Math.max(src.byteLength, dest.byteLength);\n const tmp_offset = this.__align(src_offset + src_size);\n const tmp_size = srcH * destW * 4 * 2;\n const filtersX_offset = this.__align(tmp_offset + tmp_size);\n const filtersY_offset = this.__align(filtersX_offset + filtersX.byteLength);\n const alloc_bytes = filtersY_offset + filtersY.byteLength;\n const instance = this.__instance(\"resize\", alloc_bytes);\n const mem = new Uint8Array(this.__memory.buffer);\n const mem32 = new Uint32Array(this.__memory.buffer);\n const src32 = new Uint32Array(src.buffer);\n mem32.set(src32);\n copyInt16asLE(filtersX, mem, filtersX_offset);\n copyInt16asLE(filtersY, mem, filtersY_offset);\n const fn = instance.exports.convolveHV || instance.exports._convolveHV;\n if (!fn) throw new Error(\"WASM resize function is not available\");\n if (hasAlpha(src, srcW, srcH)) fn(filtersX_offset, filtersY_offset, tmp_offset, srcW, srcH, destW, destH, 1);\n else {\n fn(filtersX_offset, filtersY_offset, tmp_offset, srcW, srcH, destW, destH, 0);\n resetAlpha(dest, destW, destH);\n }\n new Uint32Array(dest.buffer).set(new Uint32Array(this.__memory.buffer, 0, destH * destW));\n return dest;\n }\n var mm_resize_default = {\n name: \"resize\",\n fn: resize$1,\n wasm_fn: resize_wasm,\n wasm_src: \"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\"\n };\n var MathLib = class extends import_multimath.default {\n constructor(requested_features) {\n const __requested_features = requested_features || [];\n const features = {\n js: __requested_features.indexOf(\"js\") >= 0,\n wasm: __requested_features.indexOf(\"wasm\") >= 0\n };\n super(features);\n this.features = {\n js: features.js,\n wasm: features.wasm && this.has_wasm()\n };\n this.use(mm_unsharp_mask_default);\n this.use(mm_resize_default);\n }\n resizeAndUnsharp(options) {\n const result = this.resize(options);\n if (options.unsharpAmount) this.unsharp_mask(result, options.toWidth, options.toHeight, options.unsharpAmount, options.unsharpRadius, options.unsharpThreshold);\n return result;\n }\n };\n var ORIENTED_JPEG_BASE64 = \"/9j/4QAiRXhpZgAATU0AKgAAAAgAAQESAAMAAAABAAYAAAAAAAD/4AAQskZJRgABAQAAAQABAAD/2wBDAAMCAgICAgMCAgIDAwMDBAYEBAQEBAgGBgUGCQgKCgkICQkKDA8MCgsOCwkJDRENDg8QEBEQCgwSExIQEw8QEBD/wAALCAACAAMBAREA/8QAFAABAAAAAAAAAAAAAAAAAAAACf/EABsQAAMBAQADAAAAAAAAAAAAAAECAwQFABEx/9oACAEBAAA/AC06fW6va0ps7PT179E88MiV02arrCEkjGQZiSEnKc5ovxURVHoADz//2Q==\";\n var features = {\n canvas: false,\n offscreen_canvas: false,\n may_be_worker: false,\n create_image_bitmap: false,\n safari_put_image_data_fix: false,\n bug_canvas_orientation_region: true,\n bug_image_bitmap_orientation_region: true,\n cib_resize: false\n };\n var checked = false;\n var checking = null;\n function check_canvas() {\n if (typeof document === \"undefined\" || !document.createElement) return false;\n try {\n const canvas = document.createElement(\"canvas\");\n canvas.width = 2;\n canvas.height = 1;\n const ctx = canvas.getContext(\"2d\");\n let d = ctx.createImageData(2, 1);\n d.data[0] = 12;\n d.data[1] = 23;\n d.data[2] = 34;\n d.data[3] = 255;\n d.data[4] = 45;\n d.data[5] = 56;\n d.data[6] = 67;\n d.data[7] = 255;\n ctx.putImageData(d, 0, 0);\n d = ctx.getImageData(0, 0, 2, 1);\n return d.data[0] === 12 && d.data[1] === 23 && d.data[2] === 34 && d.data[3] === 255 && d.data[4] === 45 && d.data[5] === 56 && d.data[6] === 67 && d.data[7] === 255;\n } catch (__) {\n return false;\n }\n }\n function check_offscreen_canvas() {\n if (typeof OffscreenCanvas === \"undefined\") return false;\n try {\n const ctx = new OffscreenCanvas(2, 1).getContext(\"2d\");\n let d = ctx.createImageData(2, 1);\n d.data[0] = 12;\n d.data[1] = 23;\n d.data[2] = 34;\n d.data[3] = 255;\n d.data[4] = 45;\n d.data[5] = 56;\n d.data[6] = 67;\n d.data[7] = 255;\n ctx.putImageData(d, 0, 0);\n d = ctx.getImageData(0, 0, 2, 1);\n return d.data[0] === 12 && d.data[1] === 23 && d.data[2] === 34 && d.data[3] === 255 && d.data[4] === 45 && d.data[5] === 56 && d.data[6] === 67 && d.data[7] === 255;\n } catch (__) {\n return false;\n }\n }\n function check_create_image_bitmap() {\n return typeof createImageBitmap !== \"undefined\";\n }\n function check_may_be_worker() {\n return typeof Worker !== \"undefined\" && typeof URL !== \"undefined\" && !!URL.createObjectURL;\n }\n function check_safari_put_image_data_fix() {\n try {\n return !!(typeof navigator !== \"undefined\" && navigator.userAgent && navigator.userAgent.indexOf(\"Safari\") >= 0 && navigator.userAgent.indexOf(\"Chrome\") < 0);\n } catch (__) {\n return false;\n }\n }\n function check_bug_canvas_orientation_region_async() {\n return Promise.resolve().then(() => {\n if (check_offscreen_canvas() && check_create_image_bitmap() && typeof Blob !== \"undefined\" && typeof atob !== \"undefined\") {\n const binary = atob(ORIENTED_JPEG_BASE64);\n const bytes = new Uint8Array(binary.length);\n for (let i = 0; i < binary.length; i++) bytes[i] = binary.charCodeAt(i);\n return createImageBitmap(new Blob([bytes], { type: \"image/jpeg\" })).then((bitmap) => {\n const canvas = new OffscreenCanvas(1, 1);\n try {\n const ctx = canvas.getContext(\"2d\");\n ctx.drawImage(bitmap, 1, 1, 1, 1, 0, 0, 1, 1);\n return ctx.getImageData(0, 0, 1, 1).data[0] < 240;\n } finally {\n bitmap.close();\n }\n });\n }\n if (check_canvas() && typeof Image !== \"undefined\") return new Promise((resolve) => {\n const image = new Image();\n image.onload = () => {\n try {\n const canvas = document.createElement(\"canvas\");\n canvas.width = 1;\n canvas.height = 1;\n const ctx = canvas.getContext(\"2d\");\n ctx.drawImage(image, 1, 1, 1, 1, 0, 0, 1, 1);\n resolve(ctx.getImageData(0, 0, 1, 1).data[0] < 240);\n } catch (__) {\n resolve(true);\n }\n };\n image.onerror = () => resolve(true);\n image.src = `data:image/jpeg;base64,${ORIENTED_JPEG_BASE64}`;\n });\n return true;\n }).catch(() => true);\n }\n function check_bug_image_bitmap_orientation_region_async() {\n return Promise.resolve().then(() => {\n if (!features.create_image_bitmap && !check_create_image_bitmap()) return true;\n if (typeof Blob === \"undefined\" || typeof atob === \"undefined\") return true;\n const canOffscreenCanvas = check_offscreen_canvas();\n const canCanvas = check_canvas();\n if (!canOffscreenCanvas && !canCanvas) return true;\n const binary = atob(ORIENTED_JPEG_BASE64);\n const bytes = new Uint8Array(binary.length);\n for (let i = 0; i < binary.length; i++) bytes[i] = binary.charCodeAt(i);\n return createImageBitmap(new Blob([bytes], { type: \"image/jpeg\" })).then((imageBitmap) => createImageBitmap(imageBitmap, 1, 1, 1, 1).then((bitmap) => {\n let canvas;\n if (canOffscreenCanvas) canvas = new OffscreenCanvas(1, 1);\n else {\n canvas = document.createElement(\"canvas\");\n canvas.width = 1;\n canvas.height = 1;\n }\n try {\n const ctx = canvas.getContext(\"2d\");\n ctx.drawImage(bitmap, 0, 0);\n return bitmap.width !== 1 || bitmap.height !== 1 || ctx.getImageData(0, 0, 1, 1).data[0] < 240;\n } finally {\n imageBitmap.close();\n bitmap.close();\n }\n }, () => {\n imageBitmap.close();\n return true;\n }));\n }).catch(() => true);\n }\n function check_cib_resize_async() {\n return Promise.resolve().then(() => {\n if (!check_create_image_bitmap()) return false;\n const SRC_SIZE = 20;\n const DST_SIZE = 5;\n let canvas;\n if (features.canvas || check_canvas()) {\n canvas = document.createElement(\"canvas\");\n canvas.width = SRC_SIZE;\n canvas.height = SRC_SIZE;\n } else if (features.offscreen_canvas || check_offscreen_canvas()) {\n canvas = new OffscreenCanvas(SRC_SIZE, SRC_SIZE);\n canvas.getContext(\"2d\").clearRect(0, 0, SRC_SIZE, SRC_SIZE);\n } else return false;\n return createImageBitmap(canvas, 0, 0, SRC_SIZE, SRC_SIZE, {\n resizeWidth: DST_SIZE,\n resizeHeight: DST_SIZE,\n resizeQuality: \"high\"\n }).then((bitmap) => {\n const status = bitmap.width === DST_SIZE && !!bitmap.close;\n if (bitmap.close) bitmap.close();\n canvas = null;\n return status;\n });\n }).catch(() => false);\n }\n function get_supported_features() {\n if (checked) return Promise.resolve(Object.assign({}, features));\n if (checking) return checking.then(() => Object.assign({}, features));\n features.canvas = check_canvas();\n features.offscreen_canvas = check_offscreen_canvas();\n features.may_be_worker = check_may_be_worker();\n features.create_image_bitmap = check_create_image_bitmap();\n features.safari_put_image_data_fix = check_safari_put_image_data_fix();\n const bugCanvasOrientationRegion = check_bug_canvas_orientation_region_async().then((result) => {\n features.bug_canvas_orientation_region = result;\n }).catch(() => {});\n const bugImageBitmapOrientationRegion = check_bug_image_bitmap_orientation_region_async().then((result) => {\n features.bug_image_bitmap_orientation_region = result;\n }).catch(() => {});\n const cibResize = check_cib_resize_async().then((result) => {\n features.cib_resize = result;\n }).catch(() => {});\n checking = Promise.all([\n bugCanvasOrientationRegion,\n bugImageBitmapOrientationRegion,\n cibResize\n ]).then(() => {\n checked = true;\n checking = null;\n return Object.assign({}, features);\n }, (err) => {\n checking = null;\n throw err;\n });\n return checking;\n }\n var workerScope = self;\n var mathLib = null;\n function resize_math(data, tileJob) {\n if (!mathLib) mathLib = new MathLib(data.features);\n return mathLib.resizeAndUnsharp(tileJob);\n }\n function resizeBitmap(data, tileJob) {\n let srcCanvas = new OffscreenCanvas(tileJob.width, tileJob.height);\n const srcCtx = srcCanvas.getContext(\"2d\");\n srcCtx.drawImage(tileJob.src, 0, 0);\n const src = srcCtx.getImageData(0, 0, tileJob.width, tileJob.height).data;\n srcCanvas.width = srcCanvas.height = 0;\n srcCanvas = null;\n tileJob.src.close();\n const result = resize_math(data, {\n src,\n width: tileJob.width,\n height: tileJob.height,\n toWidth: tileJob.toWidth,\n toHeight: tileJob.toHeight,\n scaleX: tileJob.scaleX,\n scaleY: tileJob.scaleY,\n offsetX: tileJob.offsetX,\n offsetY: tileJob.offsetY,\n filter: tileJob.filter,\n unsharpAmount: tileJob.unsharpAmount,\n unsharpRadius: tileJob.unsharpRadius,\n unsharpThreshold: tileJob.unsharpThreshold\n });\n const canvas = new OffscreenCanvas(tileJob.toWidth, tileJob.toHeight);\n const ctx = canvas.getContext(\"2d\");\n const toImageData = ctx.createImageData(tileJob.toWidth, tileJob.toHeight);\n toImageData.data.set(result);\n ctx.putImageData(toImageData, 0, 0);\n const bitmap = canvas.transferToImageBitmap();\n workerScope.postMessage({\n kind: \"bitmap\",\n data: bitmap\n }, [bitmap]);\n }\n function resize(data) {\n if (data.job.kind === \"bitmap\") {\n resizeBitmap(data, data.job);\n return;\n }\n const result = resize_math(data, data.job);\n workerScope.postMessage({\n kind: \"array\",\n data: result\n }, [result.buffer]);\n }\n function handleMessage(data) {\n switch (data.method) {\n case \"get_supported_features\": return get_supported_features().then((result) => {\n workerScope.postMessage({ data: result });\n });\n case \"resize\":\n resize(data);\n return Promise.resolve();\n default: return Promise.reject(/* @__PURE__ */ new Error(`Unknown worker method: ${data.method}`));\n }\n }\n workerScope.onmessage = function(ev) {\n Promise.resolve().then(() => handleMessage(ev.data)).catch((err) => {\n workerScope.postMessage({ err });\n });\n };\n})();\n\n//# sourceURL=pica-inline-worker.js";
|
|
1178
|
+
var WORKER_SRC = "/*!\n\npica\nhttps://github.com/nodeca/pica\n\n*/\n!function(){var A;function t(A){const t=A.replace(/[\\r\\n=]/g,\"\"),e=t.length,n=new Uint8Array(3*e>>2);let a=0,i=0;for(let s=0;s<e;s++)s%4==0&&s&&(n[i++]=a>>16&255,n[i++]=a>>8&255,n[i++]=255&a),a=a<<6|\"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/\".indexOf(t.charAt(s));const r=e%4*6;return 0===r?(n[i++]=a>>16&255,n[i++]=a>>8&255,n[i++]=255&a):18===r?(n[i++]=a>>10&255,n[i++]=a>>2&255):12===r&&(n[i++]=a>>4&255),n}var e={js:!0,wasm:!0},n=class{constructor(A){const t=Object.assign({},e,A||{});if(this.options=t,this.__cache={},this.__init_promise=null,this.__modules=t.modules||{},this.__memory=null,this.__wasm={},this.__isLE=1===new Uint32Array(new Uint8Array([1,0,0,0]).buffer)[0],!this.options.js&&!this.options.wasm)throw new Error('mathlib: at least \"js\" or \"wasm\" should be enabled')}has_wasm(){return function(){if(void 0!==A)return A;if(A=!1,\"undefined\"==typeof WebAssembly)return A;try{const t=new Uint8Array([0,97,115,109,1,0,0,0,1,6,1,96,1,127,1,127,3,2,1,0,5,3,1,0,1,7,8,1,4,116,101,115,116,0,0,10,16,1,14,0,32,0,65,1,54,2,0,32,0,40,2,0,11]),e=new WebAssembly.Module(t);return 0!==new WebAssembly.Instance(e,{}).exports.test(4)&&(A=!0),A}catch(t){}return A}()}use(A){return this.__modules[A.name]=A,this.options.wasm&&this.has_wasm()&&A.wasm_fn?this[A.name]=A.wasm_fn:this[A.name]=A.fn,this}init(){return this.__init_promise?this.__init_promise:this.options.js||!this.options.wasm||this.has_wasm()?(this.__init_promise=Promise.all(Object.keys(this.__modules).map(A=>{const e=this.__modules[A];return this.options.wasm&&this.has_wasm()&&e.wasm_fn?this.__wasm[A]?null:WebAssembly.compile(t(e.wasm_src)).then(t=>{this.__wasm[A]=t}):null})).then(()=>this),this.__init_promise):Promise.reject(new Error('mathlib: only \"wasm\" was enabled, but it\\'s not supported'))}__reallocate(A){if(!this.__memory)return this.__memory=new WebAssembly.Memory({initial:Math.ceil(A/65536)}),this.__memory;const t=this.__memory.buffer.byteLength;return t<A&&this.__memory.grow(Math.ceil((A-t)/65536)),this.__memory}__instance(A,e,n){if(e&&this.__reallocate(e),!this.__wasm[A]){const e=this.__modules[A];this.__wasm[A]=new WebAssembly.Module(t(e.wasm_src))}if(!this.__cache[A]){const t={memoryBase:0,memory:this.__memory,tableBase:0,table:new WebAssembly.Table({initial:0,element:\"anyfunc\"})};this.__cache[A]=new WebAssembly.Instance(this.__wasm[A],{env:Object.assign(t,n||{})})}return this.__cache[A]}__align(A,t){const e=A%(t=t||8);return A+(e?t-e:0)}};function a(A,t,e,n,a,i){let r,s,o,g,I,h,B,Q,E,C,c,f,u,d;for(E=0;E<i;E++){for(h=E*a,B=E,Q=0,r=A[h],I=r*n[6],g=I,c=n[0],f=n[1],u=n[4],d=n[5],C=0;C<a;C++)s=A[h],o=s*c+r*f+g*u+I*d,I=g,g=o,r=s,e[Q]=g,Q++,h++;for(h--,Q--,B+=i*(a-1),r=A[h],I=r*n[7],g=I,s=r,c=n[2],f=n[3],C=a-1;C>=0;C--)o=s*c+r*f+g*u+I*d,I=g,g=o,r=s,s=A[h],t[B]=e[Q]+g,h--,Q--,B-=i}}function i(A,t,e,n){if(!n)return;const i=new Uint16Array(A.length),r=new Float32Array(Math.max(t,e)),s=function(A){A<.5&&(A=.5);const t=Math.exp(.527076)/A,e=Math.exp(-t),n=Math.exp(-2*t),a=(1-e)*(1-e)/(1+2*t*e-n),i=a*(t-1)*e,r=a*(t+1)*e,s=-a*n,o=2*e,g=-n;return new Float32Array([a,i,r,s,o,g,(a+i)/(1-o-g),(r+s)/(1-o-g)])}(n);a(A,i,r,s,t,e),a(i,A,r,s,e,t)}var r={name:\"unsharp_mask\",fn:function(A,t,e,n,a,r){let s,o,g,I,h;if(0===n||a<.5)return;a>2&&(a=2);const B=function(A,t,e){const n=t*e,a=new Uint16Array(n);let i,r,s,o;for(let g=0;g<n;g++)i=A[4*g],r=A[4*g+1],s=A[4*g+2],o=i>=r&&i>=s?i:r>=s&&r>=i?r:s,a[g]=o<<8;return a}(A,t,e),Q=new Uint16Array(B);i(Q,t,e,a);const E=n/100*4096+.5|0,C=r<<8,c=t*e;for(let i=0;i<c;i++)s=B[i],I=s-Q[i],Math.abs(I)>=C&&(o=s+(E*I+2048>>12),o=o>65280?65280:o,o=o<0?0:o,s=0!==s?s:1,g=(o<<12)/s|0,h=4*i,A[h]=A[h]*g+2048>>12,A[h+1]=A[h+1]*g+2048>>12,A[h+2]=A[h+2]*g+2048>>12)},wasm_fn:function(A,t,e,n,a,i){if(0===n||a<.5)return;a>2&&(a=2);const r=t*e,s=4*r,o=2*r,g=2*r,I=4*Math.max(t,e),h=s,B=h+o,Q=B+g,E=Q+g,C=E+I,c=this.__instance(\"unsharp_mask\",s+o+2*g+I+32,{exp:Math.exp}),f=new Uint32Array(A.buffer);new Uint32Array(this.__memory.buffer).set(f);let u=c.exports.hsv_v16||c.exports._hsv_v16;if(!u)throw new Error(\"WASM hsv_v16 function is not available\");if(u(0,h,t,e),u=c.exports.blurMono16||c.exports._blurMono16,!u)throw new Error(\"WASM blurMono16 function is not available\");if(u(h,B,Q,E,C,t,e,a),u=c.exports.unsharp||c.exports._unsharp,!u)throw new Error(\"WASM unsharp function is not available\");u(0,0,h,B,t,e,n,i),f.set(new Uint32Array(this.__memory.buffer,0,r))},wasm_src:\"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\"},s={filter:{box:{win:.5,fn:A=>(A<0&&(A=-A),A<.5?1:0)},hamming:{win:1,fn(A){if(A<0&&(A=-A),A>=1)return 0;if(A<1.1920929e-7)return 1;const t=A*Math.PI;return Math.sin(t)/t*(.54+.46*Math.cos(t/1))}},lanczos2:{win:2,fn(A){if(A<0&&(A=-A),A>=2)return 0;if(A<1.1920929e-7)return 1;const t=A*Math.PI;return Math.sin(t)/t*Math.sin(t/2)/(t/2)}},lanczos3:{win:3,fn(A){if(A<0&&(A=-A),A>=3)return 0;if(A<1.1920929e-7)return 1;const t=A*Math.PI;return Math.sin(t)/t*Math.sin(t/3)/(t/3)}},mks2013:{win:2.5,fn:A=>(A<0&&(A=-A),A>=2.5?0:A>=1.5?-.125*(A-2.5)*(A-2.5):A>=.5?.25*(4*A*A-11*A+7):1.0625-1.75*A*A)}}};function o(A){return Math.round(16383*A)}function g(A,t,e,n,a){const i=s.filter[A].fn,r=1/n,g=Math.min(1,n),I=s.filter[A].win/g;let h,B,Q,E,C,c,f,u,d,m,l,w,y,_,b,D,M;const p=Math.floor(2*(I+1)),G=new Int16Array((p+2)*e);let U=0;const F=!G.subarray||!G.set;for(h=0;h<e;h++){for(B=(h+.5)*r+a,Q=Math.max(0,Math.floor(B-I)),E=Math.min(t-1,Math.ceil(B+I)),C=E-Q+1,c=new Float32Array(C),f=new Int16Array(C),u=0,d=Q,m=0;d<=E;d++,m++)l=i((d+.5-B)*g),u+=l,c[m]=l;for(w=0,m=0;m<c.length;m++)y=c[m]/u,w+=y,f[m]=o(y);for(f[e>>1]+=o(1-w),_=0;_<f.length&&0===f[_];)_++;if(_<f.length){for(b=f.length-1;b>0&&0===f[b];)b--;if(D=Q+_,M=b-_+1,G[U++]=D,G[U++]=M,F)for(m=_;m<=b;m++)G[U++]=f[m];else G.set(f.subarray(_,b+1),U),U+=M}else G[U++]=0,G[U++]=0}return G}function I(A){return A<0?0:A>255?255:A}function h(A){return A>=0?A:0}var B=!0;try{B=1===new Uint32Array(new Uint8Array([1,0,0,0]).buffer)[0]}catch(G){}function Q(A,t,e){if(B)t.set(function(A){return new Uint8Array(A.buffer,0,A.byteLength)}(A),e);else for(let n=e,a=0;a<A.length;a++){const e=A[a];t[n++]=255&e,t[n++]=e>>8&255}}var E={name:\"resize\",fn:function(A){const t=A.src,e=A.width,n=A.height,a=A.toWidth,i=A.toHeight,r=A.scaleX||A.toWidth/A.width,s=A.scaleY||A.toHeight/A.height,o=A.offsetX||0,B=A.offsetY||0,Q=A.dest||new Uint8Array(a*i*4),E=void 0===A.filter?\"mks2013\":A.filter,C=g(E,e,a,r,o),c=g(E,n,i,s,B),f=new Uint16Array(a*n*4);return!function(A,t,e){let n=3;const a=t*e*4|0;for(;n<a;){if(255!==A[n])return!0;n=n+4|0}return!1}(t,e,n)?(function(A,t,e,n,a,i){let r,s,o,g,I,B,Q,E,C,c,f,u=0,d=0;for(C=0;C<n;C++){for(I=0,c=0;c<a;c++){for(B=i[I++],Q=i[I++],E=u+4*B|0,r=s=o=g=0;Q>0;Q--)f=i[I++],g=g+f*A[E+3]|0,o=o+f*A[E+2]|0,s=s+f*A[E+1]|0,r=r+f*A[E]|0,E=E+4|0;t[d+3]=h(g>>7),t[d+2]=h(o>>7),t[d+1]=h(s>>7),t[d]=h(r>>7),d=d+4*n|0}d=4*(C+1)|0,u=(C+1)*e*4|0}}(t,f,e,n,a,C),function(A,t,e,n,a,i){let r,s,o,g,h,B,Q,E,C,c,f,u=0,d=0;for(C=0;C<n;C++){for(h=0,c=0;c<a;c++){for(B=i[h++],Q=i[h++],E=u+4*B|0,r=s=o=g=0;Q>0;Q--)f=i[h++],g=g+f*A[E+3]|0,o=o+f*A[E+2]|0,s=s+f*A[E+1]|0,r=r+f*A[E]|0,E=E+4|0;r>>=7,s>>=7,o>>=7,g>>=7,t[d+3]=I(g+8192>>14),t[d+2]=I(o+8192>>14),t[d+1]=I(s+8192>>14),t[d]=I(r+8192>>14),d=d+4*n|0}d=4*(C+1)|0,u=(C+1)*e*4|0}}(f,Q,n,a,i,c),function(A,t,e){let n=3;const a=t*e*4|0;for(;n<a;)A[n]=255,n=n+4|0}(Q,a,i)):(function(A,t,e,n,a,i){let r,s,o,g,I,B,Q,E,C,c,f,u,d=0,m=0;for(c=0;c<n;c++){for(B=0,f=0;f<a;f++){for(Q=i[B++],E=i[B++],C=d+4*Q|0,r=s=o=g=0;E>0;E--)u=i[B++],I=A[C+3],g=g+u*I|0,o=o+u*A[C+2]*I|0,s=s+u*A[C+1]*I|0,r=r+u*A[C]*I|0,C=C+4|0;o=o/255|0,s=s/255|0,r=r/255|0,t[m+3]=h(g>>7),t[m+2]=h(o>>7),t[m+1]=h(s>>7),t[m]=h(r>>7),m=m+4*n|0}m=4*(c+1)|0,d=(c+1)*e*4|0}}(t,f,e,n,a,C),function(A,t,e,n,a,i){let r,s,o,g,h,B,Q,E,C,c,f,u=0,d=0;for(C=0;C<n;C++){for(h=0,c=0;c<a;c++){for(B=i[h++],Q=i[h++],E=u+4*B|0,r=s=o=g=0;Q>0;Q--)f=i[h++],g=g+f*A[E+3]|0,o=o+f*A[E+2]|0,s=s+f*A[E+1]|0,r=r+f*A[E]|0,E=E+4|0;r>>=7,s>>=7,o>>=7,g>>=7,g=I(g+8192>>14),g>0&&(r=255*r/g|0,s=255*s/g|0,o=255*o/g|0),t[d+3]=g,t[d+2]=I(o+8192>>14),t[d+1]=I(s+8192>>14),t[d]=I(r+8192>>14),d=d+4*n|0}d=4*(C+1)|0,u=(C+1)*e*4|0}}(f,Q,n,a,i,c)),Q},wasm_fn:function(A){const t=A.src,e=A.width,n=A.height,a=A.toWidth,i=A.toHeight,r=A.scaleX||A.toWidth/A.width,s=A.scaleY||A.toHeight/A.height,o=A.offsetX||0,I=A.offsetY||0,h=A.dest||new Uint8Array(a*i*4),B=void 0===A.filter?\"mks2013\":A.filter,E=g(B,e,a,r,o),C=g(B,n,i,s,I),c=Math.max(t.byteLength,h.byteLength),f=this.__align(0+c),u=n*a*4*2,d=this.__align(f+u),m=this.__align(d+E.byteLength),l=m+C.byteLength,w=this.__instance(\"resize\",l),y=new Uint8Array(this.__memory.buffer),_=new Uint32Array(this.__memory.buffer),b=new Uint32Array(t.buffer);_.set(b),Q(E,y,d),Q(C,y,m);const D=w.exports.convolveHV||w.exports._convolveHV;if(!D)throw new Error(\"WASM resize function is not available\");return!function(A,t,e){let n=3;const a=t*e*4|0;for(;n<a;){if(255!==A[n])return!0;n=n+4|0}return!1}(t,e,n)?(D(d,m,f,e,n,a,i,0),function(A,t,e){let n=3;const a=t*e*4|0;for(;n<a;)A[n]=255,n=n+4|0}(h,a,i)):D(d,m,f,e,n,a,i,1),new Uint32Array(h.buffer).set(new Uint32Array(this.__memory.buffer,0,i*a)),h},wasm_src:\"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\"},C=class extends n{constructor(A){const t=A||[],e={js:t.indexOf(\"js\")>=0,wasm:t.indexOf(\"wasm\")>=0};super(e),this.features={js:e.js,wasm:e.wasm&&this.has_wasm()},this.use(r),this.use(E)}resizeAndUnsharp(A){const t=this.resize(A);return A.unsharpAmount&&this.unsharp_mask(t,A.toWidth,A.toHeight,A.unsharpAmount,A.unsharpRadius,A.unsharpThreshold),t}},c=\"/9j/4QAiRXhpZgAATU0AKgAAAAgAAQESAAMAAAABAAYAAAAAAAD/4AAQskZJRgABAQAAAQABAAD/2wBDAAMCAgICAgMCAgIDAwMDBAYEBAQEBAgGBgUGCQgKCgkICQkKDA8MCgsOCwkJDRENDg8QEBEQCgwSExIQEw8QEBD/wAALCAACAAMBAREA/8QAFAABAAAAAAAAAAAAAAAAAAAACf/EABsQAAMBAQADAAAAAAAAAAAAAAECAwQFABEx/9oACAEBAAA/AC06fW6va0ps7PT179E88MiV02arrCEkjGQZiSEnKc5ovxURVHoADz//2Q==\",f={canvas:!1,offscreen_canvas:!1,may_be_worker:!1,create_image_bitmap:!1,safari_put_image_data_fix:!1,bug_canvas_orientation_region:!0,bug_image_bitmap_orientation_region:!0,cib_resize:!1},u=!1,d=null,m={willReadFrequently:!0};function l(){if(\"undefined\"==typeof document||!document.createElement)return!1;try{const A=document.createElement(\"canvas\");A.width=2,A.height=1;const t=A.getContext(\"2d\",m);let e=t.createImageData(2,1);return e.data[0]=12,e.data[1]=23,e.data[2]=34,e.data[3]=255,e.data[4]=45,e.data[5]=56,e.data[6]=67,e.data[7]=255,t.putImageData(e,0,0),e=t.getImageData(0,0,2,1),12===e.data[0]&&23===e.data[1]&&34===e.data[2]&&255===e.data[3]&&45===e.data[4]&&56===e.data[5]&&67===e.data[6]&&255===e.data[7]}catch(G){return!1}}function w(){if(\"undefined\"==typeof OffscreenCanvas)return!1;try{const A=new OffscreenCanvas(2,1).getContext(\"2d\",m);let t=A.createImageData(2,1);return t.data[0]=12,t.data[1]=23,t.data[2]=34,t.data[3]=255,t.data[4]=45,t.data[5]=56,t.data[6]=67,t.data[7]=255,A.putImageData(t,0,0),t=A.getImageData(0,0,2,1),12===t.data[0]&&23===t.data[1]&&34===t.data[2]&&255===t.data[3]&&45===t.data[4]&&56===t.data[5]&&67===t.data[6]&&255===t.data[7]}catch(G){return!1}}function y(){return\"undefined\"!=typeof createImageBitmap}function _(){if(u)return Promise.resolve(Object.assign({},f));if(d)return d.then(()=>Object.assign({},f));f.canvas=l(),f.offscreen_canvas=w(),f.may_be_worker=\"undefined\"!=typeof Worker&&\"undefined\"!=typeof URL&&!!URL.createObjectURL,f.create_image_bitmap=y(),f.safari_put_image_data_fix=function(){try{return!!(\"undefined\"!=typeof navigator&&navigator.userAgent&&navigator.userAgent.indexOf(\"Safari\")>=0&&navigator.userAgent.indexOf(\"Chrome\")<0)}catch(G){return!1}}();const A=Promise.resolve().then(()=>{if(w()&&y()&&\"undefined\"!=typeof Blob&&\"undefined\"!=typeof atob){const A=atob(c),t=new Uint8Array(A.length);for(let e=0;e<A.length;e++)t[e]=A.charCodeAt(e);return createImageBitmap(new Blob([t],{type:\"image/jpeg\"})).then(A=>{const t=new OffscreenCanvas(1,1);try{const e=t.getContext(\"2d\",m);return e.drawImage(A,1,1,1,1,0,0,1,1),e.getImageData(0,0,1,1).data[0]<240}finally{A.close()}})}return!l()||\"undefined\"==typeof Image||new Promise(A=>{const t=new Image;t.onload=()=>{try{const e=document.createElement(\"canvas\");e.width=1,e.height=1;const n=e.getContext(\"2d\",m);n.drawImage(t,1,1,1,1,0,0,1,1),A(n.getImageData(0,0,1,1).data[0]<240)}catch(G){A(!0)}},t.onerror=()=>A(!0),t.src=`data:image/jpeg;base64,${c}`})}).catch(()=>!0).then(A=>{f.bug_canvas_orientation_region=A}).catch(()=>{}),t=Promise.resolve().then(()=>{if(!f.create_image_bitmap&&!y())return!0;if(\"undefined\"==typeof Blob||\"undefined\"==typeof atob)return!0;const A=w(),t=l();if(!A&&!t)return!0;const e=atob(c),n=new Uint8Array(e.length);for(let a=0;a<e.length;a++)n[a]=e.charCodeAt(a);return createImageBitmap(new Blob([n],{type:\"image/jpeg\"})).then(t=>createImageBitmap(t,1,1,1,1).then(e=>{let n;A?n=new OffscreenCanvas(1,1):(n=document.createElement(\"canvas\"),n.width=1,n.height=1);try{const A=n.getContext(\"2d\",m);return A.drawImage(e,0,0),1!==e.width||1!==e.height||A.getImageData(0,0,1,1).data[0]<240}finally{t.close(),e.close()}},()=>(t.close(),!0)))}).catch(()=>!0).then(A=>{f.bug_image_bitmap_orientation_region=A}).catch(()=>{}),e=Promise.resolve().then(()=>{if(!y())return!1;const A=20;let t;if(f.canvas||l())t=document.createElement(\"canvas\"),t.width=A,t.height=A;else{if(!f.offscreen_canvas&&!w())return!1;t=new OffscreenCanvas(A,A),t.getContext(\"2d\",m).clearRect(0,0,A,A)}return createImageBitmap(t,0,0,A,A,{resizeWidth:5,resizeHeight:5,resizeQuality:\"high\"}).then(A=>{const e=5===A.width&&!!A.close;return A.close&&A.close(),t=null,e})}).catch(()=>!1).then(A=>{f.cib_resize=A}).catch(()=>{});return d=Promise.all([A,t,e]).then(()=>(u=!0,d=null,Object.assign({},f)),A=>{throw d=null,A})}var b=self,D=null;function M(A,t){return D||(D=new C(A.features)),D.resizeAndUnsharp(t)}function p(A){if(\"bitmap\"===A.job.kind)return void function(A,t){let e=new OffscreenCanvas(t.width,t.height);const n={willReadFrequently:!0},a=e.getContext(\"2d\",n);a.drawImage(t.src,0,0);const i=a.getImageData(0,0,t.width,t.height).data;e.width=e.height=0,e=null,t.src.close();const r=M(A,{src:i,width:t.width,height:t.height,toWidth:t.toWidth,toHeight:t.toHeight,scaleX:t.scaleX,scaleY:t.scaleY,offsetX:t.offsetX,offsetY:t.offsetY,filter:t.filter,unsharpAmount:t.unsharpAmount,unsharpRadius:t.unsharpRadius,unsharpThreshold:t.unsharpThreshold}),s=new OffscreenCanvas(t.toWidth,t.toHeight),o=s.getContext(\"2d\",n),g=o.createImageData(t.toWidth,t.toHeight);g.data.set(r),o.putImageData(g,0,0);const I=s.transferToImageBitmap();b.postMessage({kind:\"bitmap\",data:I},[I])}(A,A.job);const t=M(A,A.job);b.postMessage({kind:\"array\",data:t},[t.buffer])}b.onmessage=function(A){Promise.resolve().then(()=>function(A){switch(A.method){case\"get_supported_features\":return _().then(A=>{b.postMessage({data:A})});case\"resize\":return p(A),Promise.resolve();default:return Promise.reject(new Error(`Unknown worker method: ${A.method}`))}}(A.data)).catch(A=>{b.postMessage({err:A})})}}();\n//# sourceURL=pica-inline-worker.js";
|
|
1265
1179
|
var concurrency = 1;
|
|
1266
1180
|
if (typeof navigator !== "undefined") concurrency = Math.min(navigator.hardwareConcurrency || 1, 4);
|
|
1267
1181
|
var DEFAULT_PICA_OPTS = {
|
|
@@ -1280,6 +1194,7 @@ https://github.com/nodeca/pica
|
|
|
1280
1194
|
unsharpRadius: 0,
|
|
1281
1195
|
unsharpThreshold: 0
|
|
1282
1196
|
};
|
|
1197
|
+
var ctxOpts = { willReadFrequently: true };
|
|
1283
1198
|
var Pica = class {
|
|
1284
1199
|
constructor(options) {
|
|
1285
1200
|
_defineProperty(this, "options", void 0);
|
|
@@ -1438,7 +1353,7 @@ https://github.com/nodeca/pica
|
|
|
1438
1353
|
if (this.resize_features.ww && this.capabilities.ww_offscreen_canvas) {
|
|
1439
1354
|
this.debug("Create tile imageBitmap");
|
|
1440
1355
|
const tileCanvas = this.createCanvas(tile.width, tile.height, { preferOffscreen: true });
|
|
1441
|
-
tileCanvas.getContext("2d").drawImage(stageEnv.srcImageBitmap || from, tile.x, tile.y, tile.width, tile.height, 0, 0, tile.width, tile.height);
|
|
1356
|
+
tileCanvas.getContext("2d", ctxOpts).drawImage(stageEnv.srcImageBitmap || from, tile.x, tile.y, tile.width, tile.height, 0, 0, tile.width, tile.height);
|
|
1442
1357
|
if (!("transferToImageBitmap" in tileCanvas)) throw new Error("Pica: offscreen canvas is not available for worker transfer");
|
|
1443
1358
|
return Object.assign({}, extractTo, {
|
|
1444
1359
|
kind: "bitmap",
|
|
@@ -1446,7 +1361,7 @@ https://github.com/nodeca/pica
|
|
|
1446
1361
|
});
|
|
1447
1362
|
}
|
|
1448
1363
|
if (isCanvas(from)) {
|
|
1449
|
-
if (!stageEnv.srcCtx) stageEnv.srcCtx = from.getContext("2d");
|
|
1364
|
+
if (!stageEnv.srcCtx) stageEnv.srcCtx = from.getContext("2d", ctxOpts);
|
|
1450
1365
|
this.debug("Get tile pixel data");
|
|
1451
1366
|
return Object.assign({}, extractTo, {
|
|
1452
1367
|
kind: "array",
|
|
@@ -1455,7 +1370,7 @@ https://github.com/nodeca/pica
|
|
|
1455
1370
|
}
|
|
1456
1371
|
this.debug("Draw tile imageBitmap/image to temporary canvas");
|
|
1457
1372
|
const tmpCanvas = this.createCanvas(tile.width, tile.height, { preferOffscreen: true });
|
|
1458
|
-
const tmpCtx = tmpCanvas.getContext("2d");
|
|
1373
|
+
const tmpCtx = tmpCanvas.getContext("2d", ctxOpts);
|
|
1459
1374
|
tmpCtx.globalCompositeOperation = "copy";
|
|
1460
1375
|
tmpCtx.drawImage(stageEnv.srcImageBitmap || from, tile.x, tile.y, tile.width, tile.height, 0, 0, tile.width, tile.height);
|
|
1461
1376
|
this.debug("Get tile pixel data");
|
|
@@ -1512,7 +1427,7 @@ https://github.com/nodeca/pica
|
|
|
1512
1427
|
return _this3.__landTileData(tile, result, stageEnv);
|
|
1513
1428
|
}));
|
|
1514
1429
|
yield Promise.resolve();
|
|
1515
|
-
stageEnv.toCtx = to.getContext("2d");
|
|
1430
|
+
stageEnv.toCtx = to.getContext("2d", ctxOpts);
|
|
1516
1431
|
if (isCanvas(from)) {} else if (isImageBitmap(from)) {
|
|
1517
1432
|
stageEnv.srcImageBitmap = from;
|
|
1518
1433
|
stageEnv.isImageBitmapReused = true;
|
|
@@ -1592,7 +1507,7 @@ https://github.com/nodeca/pica
|
|
|
1592
1507
|
var _this5 = this;
|
|
1593
1508
|
return _asyncToGenerator(function* () {
|
|
1594
1509
|
var _utils$filter_to_cib_;
|
|
1595
|
-
let toCtx = to.getContext("2d");
|
|
1510
|
+
let toCtx = to.getContext("2d", ctxOpts);
|
|
1596
1511
|
_this5.debug("Resize via createImageBitmap()");
|
|
1597
1512
|
const imageBitmap = yield createImageBitmap(from, {
|
|
1598
1513
|
resizeWidth: resizeParams.toWidth,
|
|
@@ -1609,7 +1524,7 @@ https://github.com/nodeca/pica
|
|
|
1609
1524
|
}
|
|
1610
1525
|
_this5.debug("Unsharp result");
|
|
1611
1526
|
let tmpCanvas = _this5.createCanvas(resizeParams.toWidth, resizeParams.toHeight);
|
|
1612
|
-
let tmpCtx = tmpCanvas.getContext("2d");
|
|
1527
|
+
let tmpCtx = tmpCanvas.getContext("2d", ctxOpts);
|
|
1613
1528
|
tmpCtx.drawImage(imageBitmap, 0, 0);
|
|
1614
1529
|
imageBitmap.close();
|
|
1615
1530
|
let iData = tmpCtx.getImageData(0, 0, resizeParams.toWidth, resizeParams.toHeight);
|
|
@@ -1660,7 +1575,7 @@ https://github.com/nodeca/pica
|
|
|
1660
1575
|
if (ctx.canceled) return ctx.cancelToken;
|
|
1661
1576
|
if (_this6.capabilities.bug_image_bitmap_orientation_region && (isImage(from) || isImageBitmap(from))) {
|
|
1662
1577
|
const tmpCanvas = _this6.createCanvas(resizeParams.width, resizeParams.height);
|
|
1663
|
-
tmpCanvas.getContext("2d").drawImage(from, 0, 0);
|
|
1578
|
+
tmpCanvas.getContext("2d", ctxOpts).drawImage(from, 0, 0);
|
|
1664
1579
|
from = tmpCanvas;
|
|
1665
1580
|
}
|
|
1666
1581
|
if (_this6.resize_features.cib) {
|