e57-js 1.0.6 → 1.0.8
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 +71 -38
- package/dist/index.browser.mjs +1 -0
- package/dist/index.mjs +15 -14
- package/dist/libe57-js.js +24 -5
- package/dist/libe57-js.wasm +0 -0
- package/package.json +3 -3
package/README.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# e57-js
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
JavaScript library for reading and writing **E57 point cloud files**, compatible with **Node.js** and the **browser**.
|
|
4
4
|
|
|
5
5
|
> **What is a point cloud?** A point cloud is a collection of 3D points in space, typically captured by a laser scanner (LiDAR). Each point has X, Y, Z coordinates and optionally colour, intensity, and other data. E57 is the standard file format for storing them.
|
|
6
6
|
|
|
@@ -12,7 +12,9 @@ Node.js library for reading and writing **E57 point cloud files**.
|
|
|
12
12
|
npm install e57-js
|
|
13
13
|
```
|
|
14
14
|
|
|
15
|
-
Requires **Node.js 18 or higher
|
|
15
|
+
Requires **Node.js 18 or higher**, or any modern browser with WebAssembly support.
|
|
16
|
+
|
|
17
|
+
In the browser, file-system access is not available — use `E57Reader.FromBuffer(buffer)` to read from a `Uint8Array` and `E57Writer.ToBuffer()` to write to one.
|
|
16
18
|
|
|
17
19
|
---
|
|
18
20
|
|
|
@@ -21,7 +23,7 @@ Requires **Node.js 18 or higher**.
|
|
|
21
23
|
Before doing anything, call `E57.Init()` once and wait for it to finish. This loads the underlying WebAssembly module.
|
|
22
24
|
|
|
23
25
|
```js
|
|
24
|
-
import { E57, E57Reader, E57Writer } from 'e57-js'
|
|
26
|
+
import { E57, E57Reader, E57Writer, E57WriterScan, E57WriterImage } from 'e57-js'
|
|
25
27
|
|
|
26
28
|
await E57.Init()
|
|
27
29
|
|
|
@@ -35,8 +37,12 @@ await E57.Init()
|
|
|
35
37
|
### Open the file
|
|
36
38
|
|
|
37
39
|
```js
|
|
40
|
+
// From a file path (Node.js)
|
|
38
41
|
const reader = new E57Reader('scan.e57')
|
|
39
42
|
|
|
43
|
+
// From a buffer (browser or Node.js)
|
|
44
|
+
const reader = E57Reader.FromBuffer(buffer) // buffer is a Uint8Array
|
|
45
|
+
|
|
40
46
|
console.log(reader.GetData3DCount()) // number of 3D scans
|
|
41
47
|
console.log(reader.GetImage2DCount()) // number of embedded images
|
|
42
48
|
```
|
|
@@ -56,6 +62,9 @@ for (let i = 0; i < points.size(); i++) {
|
|
|
56
62
|
const pt = points.get(i)
|
|
57
63
|
console.log(pt.cartesianX, pt.cartesianY, pt.cartesianZ)
|
|
58
64
|
}
|
|
65
|
+
|
|
66
|
+
// free WASM memory when done
|
|
67
|
+
points.delete()
|
|
59
68
|
```
|
|
60
69
|
|
|
61
70
|
### Read in chunks (better for large files)
|
|
@@ -68,6 +77,7 @@ await scan.ScanPoints(1000, (chunk) => {
|
|
|
68
77
|
const pt = chunk.get(i)
|
|
69
78
|
// process pt...
|
|
70
79
|
}
|
|
80
|
+
// chunk is freed after this callback returns — do not hold references to it outside
|
|
71
81
|
})
|
|
72
82
|
```
|
|
73
83
|
|
|
@@ -91,8 +101,10 @@ console.log(header.width, header.height)
|
|
|
91
101
|
|
|
92
102
|
// Get the image as a byte buffer
|
|
93
103
|
const bytes = await image.ReadImage() // Uint8Array
|
|
104
|
+
// use bytes...
|
|
105
|
+
image.Release(bytes) // free WASM memory when done
|
|
94
106
|
|
|
95
|
-
// Or save it directly to disk (extension is auto-detected)
|
|
107
|
+
// Or save it directly to disk (extension is auto-detected — memory is freed automatically)
|
|
96
108
|
await image.Save('output') // writes output.jpeg or output.png
|
|
97
109
|
```
|
|
98
110
|
|
|
@@ -105,6 +117,8 @@ const points = scan.ReadScanSync()
|
|
|
105
117
|
const bytes = image.ReadImageSync()
|
|
106
118
|
```
|
|
107
119
|
|
|
120
|
+
> **Exception:** `AddImage` has no sync version.
|
|
121
|
+
|
|
108
122
|
---
|
|
109
123
|
|
|
110
124
|
## Writing a file
|
|
@@ -112,52 +126,54 @@ const bytes = image.ReadImageSync()
|
|
|
112
126
|
### Create the file
|
|
113
127
|
|
|
114
128
|
```js
|
|
129
|
+
// To a file path (Node.js)
|
|
115
130
|
const writer = new E57Writer('output.e57')
|
|
131
|
+
|
|
132
|
+
// To a buffer (browser or Node.js) — Close() returns a Uint8Array
|
|
133
|
+
const writer = E57Writer.ToBuffer()
|
|
116
134
|
```
|
|
117
135
|
|
|
118
136
|
### Write a 3D scan
|
|
119
137
|
|
|
120
|
-
First, describe what fields your points will have (the header), then pass your array of points:
|
|
121
|
-
|
|
122
138
|
```js
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
const points = []
|
|
139
|
+
import { E57WriterScan } from 'e57-js'
|
|
140
|
+
|
|
141
|
+
const scan = new E57WriterScan()
|
|
142
|
+
scan.GetHeader().guid = 'my-unique-scan-id'
|
|
143
|
+
scan.GetHeader().pointFields.cartesianXField = true
|
|
144
|
+
scan.GetHeader().pointFields.cartesianYField = true
|
|
145
|
+
scan.GetHeader().pointFields.cartesianZField = true
|
|
146
|
+
|
|
132
147
|
for (let i = 0; i < 100; i++) {
|
|
133
148
|
const pt = new E57.LibE57.Point()
|
|
134
149
|
pt.cartesianX = i * 0.1
|
|
135
150
|
pt.cartesianY = 0
|
|
136
151
|
pt.cartesianZ = 0
|
|
137
|
-
|
|
152
|
+
scan.AddPoint(pt)
|
|
138
153
|
}
|
|
139
154
|
|
|
140
|
-
|
|
141
|
-
|
|
155
|
+
const scanIndex = await writer.AddScan(scan)
|
|
156
|
+
scan.Destroy()
|
|
142
157
|
```
|
|
143
158
|
|
|
144
159
|
### Write a scan with colour
|
|
145
160
|
|
|
146
161
|
```js
|
|
147
|
-
const
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
162
|
+
const scan = new E57WriterScan()
|
|
163
|
+
scan.GetHeader().pointFields.cartesianXField = true
|
|
164
|
+
scan.GetHeader().pointFields.cartesianYField = true
|
|
165
|
+
scan.GetHeader().pointFields.cartesianZField = true
|
|
166
|
+
scan.GetHeader().pointFields.colorRedField = true
|
|
167
|
+
scan.GetHeader().pointFields.colorGreenField = true
|
|
168
|
+
scan.GetHeader().pointFields.colorBlueField = true
|
|
169
|
+
scan.GetHeader().colorLimits.colorRedMaximum = 255
|
|
170
|
+
scan.GetHeader().colorLimits.colorGreenMaximum = 255
|
|
171
|
+
scan.GetHeader().colorLimits.colorBlueMaximum = 255
|
|
157
172
|
|
|
158
173
|
const pt = new E57.LibE57.Point()
|
|
159
174
|
pt.cartesianX = 1.0; pt.cartesianY = 2.0; pt.cartesianZ = 3.0
|
|
160
|
-
pt.colorRed = 255; pt.colorGreen = 0; pt.colorBlue = 0
|
|
175
|
+
pt.colorRed = 255; pt.colorGreen = 0; pt.colorBlue = 0
|
|
176
|
+
scan.AddPoint(pt)
|
|
161
177
|
```
|
|
162
178
|
|
|
163
179
|
### Set the scanner position (pose)
|
|
@@ -165,13 +181,13 @@ pt.colorRed = 255; pt.colorGreen = 0; pt.colorBlue = 0 // red point
|
|
|
165
181
|
If you know where the scanner was placed, you can store that as a pose. Use an identity quaternion `(w=1, x=0, y=0, z=0)` if there is no rotation:
|
|
166
182
|
|
|
167
183
|
```js
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
184
|
+
scan.GetHeader().pose.rotation.w = 1.0
|
|
185
|
+
scan.GetHeader().pose.rotation.x = 0.0
|
|
186
|
+
scan.GetHeader().pose.rotation.y = 0.0
|
|
187
|
+
scan.GetHeader().pose.rotation.z = 0.0
|
|
188
|
+
scan.GetHeader().pose.translation.x = 10.0 // scanner was 10 m east
|
|
189
|
+
scan.GetHeader().pose.translation.y = 20.0 // 20 m north
|
|
190
|
+
scan.GetHeader().pose.translation.z = 1.5 // 1.5 m above ground
|
|
175
191
|
```
|
|
176
192
|
|
|
177
193
|
### Write an image
|
|
@@ -179,14 +195,31 @@ header.pose.translation.z = 1.5 // 1.5 m above ground
|
|
|
179
195
|
```js
|
|
180
196
|
import { E57WriterImage } from 'e57-js'
|
|
181
197
|
|
|
198
|
+
// From a file path (Node.js)
|
|
182
199
|
const image = new E57WriterImage(
|
|
183
200
|
'photo.jpg',
|
|
184
201
|
E57.LibE57.Image2DType.ImageJPEG,
|
|
185
202
|
E57.LibE57.Image2DProjection.ProjectionVisual
|
|
186
203
|
)
|
|
187
|
-
image.
|
|
204
|
+
image.SetName('Front camera')
|
|
205
|
+
|
|
206
|
+
await writer.AddImage(image)
|
|
207
|
+
image.Destroy()
|
|
208
|
+
```
|
|
209
|
+
|
|
210
|
+
In the browser, use `E57WriterImage.FromBuffer` instead:
|
|
211
|
+
|
|
212
|
+
```js
|
|
213
|
+
// From a Uint8Array (browser or Node.js)
|
|
214
|
+
const image = E57WriterImage.FromBuffer(
|
|
215
|
+
buffer, // Uint8Array
|
|
216
|
+
E57.LibE57.Image2DType.ImageJPEG,
|
|
217
|
+
E57.LibE57.Image2DProjection.ProjectionVisual
|
|
218
|
+
)
|
|
219
|
+
image.SetName('Front camera')
|
|
188
220
|
|
|
189
221
|
await writer.AddImage(image)
|
|
222
|
+
image.Destroy()
|
|
190
223
|
```
|
|
191
224
|
|
|
192
225
|
### Close the file
|
|
@@ -194,7 +227,7 @@ await writer.AddImage(image)
|
|
|
194
227
|
Always call `Close()` when you are done. This finalises the file — skipping it will produce a corrupt file.
|
|
195
228
|
|
|
196
229
|
```js
|
|
197
|
-
writer.Close()
|
|
230
|
+
writer.Close() // returns a Uint8Array only when the writer was created with E57Writer.ToBuffer()
|
|
198
231
|
```
|
|
199
232
|
|
|
200
233
|
---
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import G from"./libe57-js.js";var s=class a{static LibE57=null;static RootDir="/root ";static Init(){let e=typeof window<"u";return a.LibE57!==null?Promise.resolve():G().then(function(t){e||(t.FS.mkdir(a.RootDir),t.FS.mount(t.FS.filesystems.NODEFS,{root:"/"},a.RootDir)),a.LibE57=t})}};var o=()=>{throw new Error("path is not available in the browser")};var u=()=>{throw new Error("fs is not available in the browser")};var m=class{constructor(e,t){this.e57Reader=e,this.scanIdx=t,this._header=null}GetHeader(){return this._header||(this._header=this.e57Reader.GetData3DHeader(this.scanIdx)),this._header}Destroy(){this._header&&this._header.delete()}ReadScan(e=!0){return this.ReadPoints(Number(this.GetHeader().pointCount),e)}ReadScanSync(e=!0){let t=Number(this.GetHeader().pointCount);return this.ReadPointsSync(t,e)}ReadPoints(e,t=!0){return this.e57Reader.ReadScan(this.scanIdx,e,t)}ReadPointsSync(e,t=!0){return this.e57Reader.ReadScanSync(this.scanIdx,e,t)}ScanPoints(e,t,r=!0){let i=Number(this.GetHeader().pointCount),h=Math.ceil(i/e);if(t){for(let n=0;n<h;n++){let l=this.ReadPointsSync(e,r);t(l),l.delete()}return}let d=[];for(let n=0;n<h;n++)d.push(this.ReadPointsSync(e,r));return d}},_=class{constructor(e,t){this._e57Reader=e,this._imageIdx=t,this._header=null}GetHeader(){return this._header||(this._header=this._e57Reader.GetImage2DHeader(this._imageIdx)),this._header}Destroy(){this._header&&this._header.delete()}ReadImage(){return this._e57Reader.ReadImage(this._imageIdx)}ReadImageSync(){return this._e57Reader.ReadImageSync(this._imageIdx)}Release(e){e&&typeof e.free=="function"&&e.free()}ToBase64(){return this.ReadImage().then(e=>{let t=Buffer.from(e).toString("base64");return this.Release(e),t})}Extension(){switch(this.GetHeader().imageType){case s.LibE57.Image2DType.ImageJPEG:return".jpeg";case s.LibE57.Image2DType.ImagePNG:return".png";case s.LibE57.Image2DType.ImageMaskPNG:return".png";case s.LibE57.Image2DType.E57_JPEG_IMAGE:return".jpeg";case s.LibE57.Image2DType.E57_PNG_IMAGE:return".png";case s.LibE57.Image2DType.E57_PNG_IMAGE_MASK:return".png";default:return".jpg"}}Save(e){if(typeof window<"u")throw new Error("Save() is not available in the browser \u2014 use ReadImage() to get a Uint8Array instead");let t=this.Extension(),r=e.replace(o.extname(e),t);return this.ReadImage().then(i=>u.promises.writeFile(r,i).then(()=>{this.Release(i)}))}},c=class a{constructor(e,t=!1){let r=t?e:o.join(s.RootDir,o.resolve(e));this._reader=new s.LibE57.E57Reader(r);var i=this.GetData3DCount();this.scans=new Array(i);for(var h=0;h<i;h++)this.scans[h]=new m(this._reader,h);var d=this.GetImage2DCount();this.images=new Array(d);for(var n=0;n<d;n++)this.images[n]=new _(this._reader,n)}static FromBuffer(e){let t="/"+crypto.randomUUID()+".e57";s.LibE57.FS.writeFile(t,e);let r=new a(t,!0);return r._memFsFilePath=t,r}GetHeader(){return this._reader.GetHeader()}GetData3DCount(){return Number(this._reader.GetData3DCount())}GetImage2DCount(){return Number(this._reader.GetImage2DCount())}GetScan(e){return this.scans[e]}GetImage(e){return this.images[e]}Close(){for(let e of this.scans)e.Destroy();for(let e of this.images)e.Destroy();this._reader&&(this._reader.Close(),this._reader.delete()),this._memFsFilePath&&s.LibE57.FS.unlink(this._memFsFilePath),this.scans=null,this.images=null}};var f=()=>{throw new Error("sharp is not available in the browser")};var g=class a{constructor(e,t,r){this._imgPath=e,this._imgType=t,this._imgProjection=r,this._imageHeader=new s.LibE57.ImageHeader}static FromBuffer(e,t,r){let i=new a(null,t,r);return i._buffer=e,i._width=null,i._height=null,i}GetPath(){return this._imgPath}SetPath(e){this._imgPath=e}GetType(){return this._imgType}SetType(e){this._imgType=e}GetProjection(){return this._imgProjection}SetProjection(e){this._imgProjection=e}_resolveMetadata(){return this._width!=null&&this._height!=null?Promise.resolve({width:this._width,height:this._height}):this._metadataPromise?this._metadataPromise:(typeof window<"u"?this._metadataPromise=this.GetBuffer().then(e=>{let t=new Blob([e]);return createImageBitmap(t).then(r=>{let i={width:r.width,height:r.height};return r.close(),this._width=i.width,this._height=i.height,i})}):this._metadataPromise=this.GetBuffer().then(e=>f(e).metadata()).then(e=>(this._width=e.width,this._height=e.height,e)),this._metadataPromise)}GetMetadata(){return this._resolveMetadata()}GetDimensions(){return this._resolveMetadata().then(e=>[e.width,e.height])}GetWidth(){return this._resolveMetadata().then(e=>e.width)}GetHeight(){return this._resolveMetadata().then(e=>e.height)}GetPose(){return this._imageHeader.pose}SetPose(e){this._imageHeader.pose=e}GetName(){return this._imageHeader.name}SetName(e){this._imageHeader.name=e}GetGuid(){return this._imageHeader.guid}SetGuid(e){this._imageHeader.guid=e}GetHeader(){return this._imageHeader}SetHeader(e){this._imageHeader.delete(),this._imageHeader=e}GetBufferSync(){return this._buffer?this._buffer:new Uint8Array(u.readFileSync(this.GetPath()))}GetBuffer(){return this._buffer?Promise.resolve(this._buffer):u.promises.readFile(this.GetPath()).then(e=>new Uint8Array(e))}SetTranslation(e,t,r){this._imageHeader.pose.translation.x=e,this._imageHeader.pose.translation.y=t,this._imageHeader.pose.translation.z=r}SetRotation(e,t,r,i){this._imageHeader.pose.rotation.w=e,this._imageHeader.pose.rotation.x=t,this._imageHeader.pose.rotation.y=r,this._imageHeader.pose.rotation.z=i}Destroy(){this._imageHeader.delete(),this._imageHeader=null,this._buffer=null}},p=class{constructor(){this._header=new s.LibE57.Data3D,this._points=[]}GetHeader(){return this._header}SetHeader(e){this._header&&this._header.delete(),this._header=e}GetPoints(){return this._points}AddPoint(e){this._points&&this._points.push(e)}Destroy(){this._header&&(this._header.delete(),this._header=null);for(let e of this._points)e&&e.delete();this._points=[]}},w=class a{constructor(e,t=!1){let r=crypto.randomUUID();this._bufferFileMemFSFilePath="/"+r+".e57";let i=t?this._bufferFileMemFSFilePath:o.join(s.RootDir,o.resolve(e));this._writer=new s.LibE57.E57Writer(i),this._toBuffer=t}static ToBuffer(){return new a("",!0)}AddImage(e){return Promise.all([e.GetBuffer(),e.GetMetadata()]).then(([t,r])=>this._writer.AddImage(e.GetHeader(),e.GetType(),e.GetProjection(),0,t,t.length,r.width,r.height).then(Number))}AddScanSync(e){let t=e.GetHeader(),r=e.GetPoints();return Number(this._writer.AddScanSync(t,r))}AddScan(e){let t=e.GetHeader(),r=e.GetPoints();return this._writer.AddScan(t,r).then(Number)}Close(){if(this._writer&&(this._writer.Close(),this._writer.delete()),this._toBuffer){let e=s.LibE57.FS.readFile(this._bufferFileMemFSFilePath);return s.LibE57.FS.unlink(this._bufferFileMemFSFilePath),e}}};export{s as E57,c as E57Reader,_ as E57ReaderImage,m as E57ReaderScan,w as E57Writer,g as E57WriterImage,p as E57WriterScan};
|
package/dist/index.mjs
CHANGED
|
@@ -1,21 +1,22 @@
|
|
|
1
|
-
async function
|
|
2
|
-
`),
|
|
3
|
-
`)}var ge=
|
|
4
|
-
`)}else console.warn(...e)}(()=>{var e=new Int16Array(1),r=new Int8Array(e.buffer);e[0]=25459,(r[0]!==115||r[1]!==99)&&q("Runtime error: expected the system to be little-endian! (Run with -sSUPPORT_BIG_ENDIAN to bypass)")})();function ar(e){Object.getOwnPropertyDescriptor(f,e)||Object.defineProperty(f,e,{configurable:!0,set(){q(`Attempt to set \`Module.${e}\` after it has already been processed. This can happen, for example, when code is injected via '--post-js' rather than '--pre-js'`)}})}function $(e){return()=>_(!1,`call to '${e}' via reference taken before Wasm module initialization`)}function Se(e){Object.getOwnPropertyDescriptor(f,e)&&q(`\`Module.${e}\` was supplied but \`${e}\` not included in INCOMING_MODULE_JS_API`)}function gi(e){return e==="FS_createPath"||e==="FS_createDataFile"||e==="FS_createPreloadedFile"||e==="FS_preloadFile"||e==="FS_unlink"||e==="addRunDependency"||e==="FS_createLazyFile"||e==="FS_createDevice"||e==="removeRunDependency"}function yi(e){kt(e)}function kt(e){w||Object.getOwnPropertyDescriptor(f,e)||Object.defineProperty(f,e,{configurable:!0,get(){var r=`'${e}' was not exported. add it to EXPORTED_RUNTIME_METHODS (see the Emscripten FAQ)`;gi(e)&&(r+=". Alternatively, forcing filesystem support (-sFORCE_FILESYSTEM) can export this for you"),q(r)}})}function wi(){function e(){var t=0;return Ne&&typeof Re<"u"&&(t=Re()),`w:${Ft},t:${we(t)}:`}var r=Dr;Dr=(...t)=>r(e(),...t)}wi();function d(){fe.buffer!=H.buffer&&or()}var Ir,$r;if(C&&w){globalThis.self=globalThis;var Tt=rr.parentPort;globalThis.postMessage||(Tt.on("message",e=>globalThis.onmessage?.({data:e})),globalThis.postMessage=e=>Tt.postMessage(e)),process.on("uncaughtException",e=>{postMessage({cmd:"uncaughtException",error:e}),process.exit(1)})}var Ft=0,Pt;if(w){let e=function(r){try{var t=r.data,n=t.cmd;if(n==="load"){Ft=t.workerID;let i=[];self.onmessage=a=>i.push(a),Pt=()=>{postMessage({cmd:"loaded"});for(let a of i)e(a);self.onmessage=e};for(let a of t.handlers)(!f[a]||f[a].proxy)&&(f[a]=(...s)=>{postMessage({cmd:"callHandler",handler:a,args:s})},a=="print"&&(ge=f[a]),a=="printErr"&&(A=f[a]));fe=t.wasmMemory,or(),be=t.wasmModule,Ot(),Cr()}else if(n==="run"){_(t.pthread_ptr),Di(t.pthread_ptr),st(t.pthread_ptr,0,0,1,0,0),P.threadInitTLS(),it(t.pthread_ptr),Nr||(qn(),Nr=!0);try{Ii(t.start_routine,t.arg)}catch(i){if(i!="unwind")throw i}}else t.target==="setimmediate"||(n==="checkMailbox"?Nr&&Tr():n&&(A(`worker: received unknown command ${n}`),A(t)))}catch(i){throw A(`worker: onmessage() captured an uncaught exception: ${i}`),i?.stack&&A(i.stack),Yn(),i}};var Nr=!1;self.onunhandledrejection=r=>{throw r.reason||r},self.onmessage=e}var Ne=!1;function or(){var e=fe.buffer;H=new Int8Array(e),te=new Int16Array(e),f.HEAPU8=Q=new Uint8Array(e),ke=new Uint16Array(e),S=new Int32Array(e),y=new Uint32Array(e),sr=new Float32Array(e),Me=new Float64Array(e),Z=new BigInt64Array(e),Dt=new BigUint64Array(e)}function Ei(){if(!w){if(f.wasmMemory)fe=f.wasmMemory;else{var e=f.INITIAL_MEMORY||16777216;_(e>=65536,`INITIAL_MEMORY should be larger than STACK_SIZE, was ${e}! (STACK_SIZE=65536)`),fe=new WebAssembly.Memory({initial:e/65536,maximum:32768,shared:!0})}or()}}_(globalThis.Int32Array&&globalThis.Float64Array&&Int32Array.prototype.subarray&&Int32Array.prototype.set,"JS engine does not provide full typed array support");function bi(){if(_(!w),f.preRun)for(typeof f.preRun=="function"&&(f.preRun=[f.preRun]);f.preRun.length;)xt(f.preRun.shift());ar("preRun"),Nt(Mt)}function Ct(){if(_(!Ne),Ne=!0,w)return Pt();ze(),T.root=o.mount(T,{},null),!f.noFSInit&&!o.initialized&&o.init(),pe.init(),De.__wasm_call_ctors(),o.ignorePermissions=!1}function Si(){if(ze(),!w){if(f.postRun)for(typeof f.postRun=="function"&&(f.postRun=[f.postRun]);f.postRun.length;)Ri(f.postRun.shift());ar("postRun"),Nt(Ht)}}function q(e){f.onAbort?.(e),e=`Aborted(${e})`,A(e),Ie=!0;var r=new WebAssembly.RuntimeError(e);throw $r?.(r),r}function J(e,r){return(...t)=>{_(Ne,`native function \`${e}\` called before runtime initialization`);var n=De[e];return _(n,`exported native function \`${e}\` not found`),_(t.length<=r,`native function \`${e}\` called with ${t.length} args but expects ${r}`),n(...t)}}var Mr;function ki(){return f.locateFile?pi("libe57-js.wasm"):new URL("libe57-js.wasm",import.meta.url).href}function Ti(e){if(e==Mr&&Be)return new Uint8Array(Be);if(He)return He(e);throw"both async and sync fetching of the wasm failed"}async function Fi(e){if(!Be)try{var r=await nr(e);return new Uint8Array(r)}catch{}return Ti(e)}async function Pi(e,r){try{var t=await Fi(e),n=await WebAssembly.instantiate(t,r);return n}catch(i){A(`failed to asynchronously prepare wasm: ${i}`),ir(e)&&A(`warning: Loading from a file URI (${e}) is not supported in most browsers. See https://emscripten.org/docs/getting_started/FAQ.html#how-do-i-run-a-local-webserver-for-testing-why-does-my-program-stall-in-downloading-or-preparing`),q(i)}}async function Ci(e,r,t){if(!e&&!C)try{var n=fetch(r,{credentials:"same-origin"}),i=await WebAssembly.instantiateStreaming(n,t);return i}catch(a){A(`wasm streaming compile failed: ${a}`),A("falling back to ArrayBuffer instantiation")}return Pi(r,t)}function At(){Qo();var e={env:vt,wasi_snapshot_preview1:vt};return e}async function Ot(){function e(l,c){return De=l.exports,$i(De._emscripten_tls_init),Zo(De),be=c,De}var r=f;function t(l){return _(f===r,"the Module object should not be replaced during async compilation - perhaps the order of HTML elements is wrong?"),r=null,e(l.instance,l.module)}var n=At();if(f.instantiateWasm)return new Promise((l,c)=>{try{f.instantiateWasm(n,(u,v)=>{l(e(u,v))})}catch(u){A(`Module.instantiateWasm callback failed with error: ${u}`),c(u)}});if(w){_(be,"wasmModule should have been received via postMessage");var i=new WebAssembly.Instance(be,At());return e(i,be)}Mr??=ki();var a=await Ci(Be,Mr,n),s=t(a);return s}class Rt{name="ExitStatus";constructor(r){this.message=`Program terminated with exit(${r})`,this.status=r}}var te,S,Z,H,sr,Me,ke,y,Dt,Q,It=e=>{e.terminate(),e.onmessage=r=>{var t=r.data.cmd;A(`received "${t}" command from terminated worker: ${e.workerID}`)}},$t=e=>{_(!w,"cleanupThread() should only be called from the main thread"),_(e,"null pthread_ptr passed to cleanupThread");var r=P.pthreads[e];_(r),P.returnWorkerToPool(r)},Nt=e=>{for(;e.length>0;)e.shift()(f)},Mt=[],xt=e=>Mt.push(e),Te=0,Ge=null,xe={},ye=null,xr=e=>{if(Te--,f.monitorRunDependencies?.(Te),_(e,"removeRunDependency requires an ID"),_(xe[e]),delete xe[e],Te==0&&(ye!==null&&(clearInterval(ye),ye=null),Ge)){var r=Ge;Ge=null,r()}},Wr=e=>{Te++,f.monitorRunDependencies?.(Te),_(e,"addRunDependency requires an ID"),_(!xe[e]),xe[e]=1,ye===null&&globalThis.setInterval&&(ye=setInterval(()=>{if(Ie){clearInterval(ye),ye=null;return}var r=!1;for(var t in xe)r||(r=!0,A("still waiting on run dependencies:")),A(`dependency: ${t}`);r&&A("(end of list)")},1e4),ye.unref?.())},Wt=e=>{_(!w,"spawnThread() should only be called from the main thread"),_(e.pthread_ptr,"spawnThread called with null pthread ptr");var r=P.getNewWorker();if(!r)return 6;_(!r.pthread_ptr),P.runningWorkers.push(r),P.pthreads[e.pthread_ptr]=r,r.pthread_ptr=e.pthread_ptr;var t={cmd:"run",start_routine:e.startRoutine,arg:e.arg,pthread_ptr:e.pthread_ptr};return C&&r.unref(),r.postMessage(t,e.transferList),0},lr=0,cr=()=>Ur||lr>0,U=()=>ft(),M=e=>ni(e),Ai=e=>ii(e),K=(e,r,t,...n)=>{var i=8*n.length*2,a=U(),s=Ai(i),l=s>>3;for(var c of n)typeof c=="bigint"?((d(),Z)[l++]=1n,(d(),Z)[l++]=c):((d(),Z)[l++]=0n,(d(),Me)[l++]=c);var u=Zn(e,r,i,s,t);return M(a),u};function Lt(e){if(w)return K(0,0,1,e);$e=e,cr()||(P.terminateAllThreads(),f.onExit?.(e),Ie=!0),Or(e,new Rt(e))}function Ut(e){if(w)return K(1,0,0,e);Lr(e)}var Oi=(e,r)=>{if($e=e,As(),w)throw _(!r),Ut(e),"unwind";if(cr()&&!r){var t=`program exited (with status: ${e}), but keepRuntimeAlive() is set (counter=${lr}) due to an async operation, so halting execution but not exiting the runtime or preventing further async execution (you can use emscripten_force_exit, if you want to force a true shutdown)`;$r?.(t),A(t)}Lt(e)},Lr=Oi,jt=!Atomics.waitAsync||globalThis.navigator?.userAgent&&Number((navigator.userAgent.match(/Chrom(e|ium)\/([0-9]+)\./)||[])[2])<91;function we(e){return _(typeof e=="number",`ptrToString expects a number, got ${typeof e}`),e>>>=0,"0x"+e.toString(16).padStart(8,"0")}var P={unusedWorkers:[],runningWorkers:[],tlsInitFunctions:[],pthreads:{},nextWorkerID:1,init(){w||P.initMainThread()},initMainThread(){for(var e=2;e--;)P.allocateUnusedWorker();xt(async()=>{var r=P.loadWasmModuleToAllWorkers();Wr("loading-workers"),await r,xr("loading-workers")})},terminateAllThreads:()=>{_(!w,"terminateAllThreads() should only be called from the main thread");for(var e of P.runningWorkers)It(e);for(var e of P.unusedWorkers)It(e);P.unusedWorkers=[],P.runningWorkers=[],P.pthreads={}},terminateRuntime:()=>{_(!w,"terminateRuntime() should only be called from the main thread"),P.terminateAllThreads();var e=Re();Xn(0,0,0,1),jt||Atomics.notify((d(),S),e>>2)},returnWorkerToPool:e=>{var r=e.pthread_ptr;delete P.pthreads[r],P.unusedWorkers.push(e),P.runningWorkers.splice(P.runningWorkers.indexOf(e),1),e.pthread_ptr=0,Qn(r)},threadInitTLS(){P.tlsInitFunctions.forEach(e=>e())},loadWasmModuleToWorker:e=>new Promise(r=>{e.onmessage=a=>{var s=a.data,l=s.cmd;if(s.targetThread&&s.targetThread!=Re()){var c=P.pthreads[s.targetThread];c?c.postMessage(s,s.transferList):A(`worker sent message (${l}) to pthread (${s.targetThread}) that no longer exists`);return}l==="checkMailbox"?Tr():l==="spawnThread"?Wt(s):l==="cleanupThread"?$n(()=>$t(s.thread)):l==="loaded"?(e.loaded=!0,C&&!e.pthread_ptr&&e.unref(),r(e)):s.target==="setimmediate"?e.postMessage(s):l==="uncaughtException"?e.onerror(s.error):l==="callHandler"?f[s.handler](...s.args):l&&A(`worker sent an unknown command ${l}`)},e.onerror=a=>{var s="worker sent an error!";throw e.pthread_ptr&&(s=`Pthread ${we(e.pthread_ptr)} sent an error!`),A(`${s} ${a.filename}:${a.lineno}: ${a.message}`),a},C&&(e.on("message",a=>e.onmessage({data:a})),e.on("error",a=>e.onerror(a))),_(fe instanceof WebAssembly.Memory,"wasmMemory should have been loaded by now"),_(be instanceof WebAssembly.Module,"wasmModule should have been loaded by now");var t=[],n=["onExit","onAbort","print","printErr"];for(var i of n)f.propertyIsEnumerable(i)&&t.push(i);e.postMessage({cmd:"load",handlers:t,wasmMemory:fe,wasmModule:be,workerID:e.workerID})}),async loadWasmModuleToAllWorkers(){return w?void 0:Promise.all(P.unusedWorkers.map(P.loadWasmModuleToWorker))},allocateUnusedWorker(){var e;if(f.mainScriptUrlOrBlob){var r=f.mainScriptUrlOrBlob;typeof r!="string"&&(r=URL.createObjectURL(r)),e=new Worker(r,{type:"module",workerData:"em-pthread",name:"em-pthread-"+P.nextWorkerID})}else e=new Worker(new URL("libe57-js.js",import.meta.url),{type:"module",workerData:"em-pthread",name:"em-pthread-"+P.nextWorkerID});e.workerID=P.nextWorkerID++,P.unusedWorkers.push(e)},getNewWorker(){return P.unusedWorkers.length==0&&(C||A("Tried to spawn a new thread, but the thread pool is exhausted.\nThis might result in a deadlock unless some threads eventually exit or the code explicitly breaks out to the event loop.\nIf you want to increase the pool size, use setting `-sPTHREAD_POOL_SIZE=...`.\nIf you want to throw an explicit error instead of the risk of deadlocking in those cases, use setting `-sPTHREAD_POOL_SIZE_STRICT=2`."),P.allocateUnusedWorker(),P.loadWasmModuleToWorker(P.unusedWorkers[0])),P.unusedWorkers.pop()}},Ht=[],Ri=e=>Ht.push(e);function Di(e){var r=(d(),y)[e+48>>2],t=(d(),y)[e+52>>2],n=r-t;_(r!=0),_(n!=0),_(r>n,"stackHigh must be higher then stackLow"),ti(r,n),M(r),bt()}function Us(e,r="i8"){switch(r.endsWith("*")&&(r="*"),r){case"i1":return(d(),H)[e];case"i8":return(d(),H)[e];case"i16":return(d(),te)[e>>1];case"i32":return(d(),S)[e>>2];case"i64":return(d(),Z)[e>>3];case"float":return(d(),sr)[e>>2];case"double":return(d(),Me)[e>>3];case"*":return(d(),y)[e>>2];default:q(`invalid type for getValue: ${r}`)}}var Bt=[],x=e=>{var r=Bt[e];return r||(Bt[e]=r=_t.get(e)),_(_t.get(e)==r,"table mirror is out of date"),r},Ii=(e,r)=>{lr=0,Ur=0;var t=x(e)(r);ze();function n(i){if(cr()){$e=i;return}ut(i)}n(t)},Ur=!0,$i=e=>P.tlsInitFunctions.push(e);function js(e,r,t="i8"){switch(t.endsWith("*")&&(t="*"),t){case"i1":(d(),H)[e]=r;break;case"i8":(d(),H)[e]=r;break;case"i16":(d(),te)[e>>1]=r;break;case"i32":(d(),S)[e>>2]=r;break;case"i64":(d(),Z)[e>>3]=BigInt(r);break;case"float":(d(),sr)[e>>2]=r;break;case"double":(d(),Me)[e>>3]=r;break;case"*":(d(),y)[e>>2]=r;break;default:q(`invalid type for setValue: ${t}`)}}var Fe=e=>{Fe.shown||={},Fe.shown[e]||(Fe.shown[e]=1,C&&(e="warning: "+e),A(e))},fe,zt=globalThis.TextDecoder&&new TextDecoder,Gt=(e,r,t,n)=>{var i=r+t;if(n)return i;for(;e[r]&&!(r>=i);)++r;return r},We=(e,r=0,t,n)=>{var i=Gt(e,r,t,n);if(i-r>16&&e.buffer&&zt)return zt.decode(e.buffer instanceof ArrayBuffer?e.subarray(r,i):e.slice(r,i));for(var a="";r<i;){var s=e[r++];if(!(s&128)){a+=String.fromCharCode(s);continue}var l=e[r++]&63;if((s&224)==192){a+=String.fromCharCode((s&31)<<6|l);continue}var c=e[r++]&63;if((s&240)==224?s=(s&15)<<12|l<<6|c:((s&248)!=240&&Fe(`Invalid UTF-8 leading byte ${we(s)} encountered when deserializing a UTF-8 string in wasm memory to a JS string!`),s=(s&7)<<18|l<<12|c<<6|e[r++]&63),s<65536)a+=String.fromCharCode(s);else{var u=s-65536;a+=String.fromCharCode(55296|u>>10,56320|u&1023)}}return a},_e=(e,r,t)=>(_(typeof e=="number",`UTF8ToString expects a number (got ${typeof e})`),e?We((d(),Q),e,r,t):""),Ni=(e,r,t,n)=>q(`Assertion failed: ${_e(e)}, at: `+[r?_e(r):"unknown filename",t,n?_e(n):"unknown function"]),jr=[],Vt=0,Mi=e=>{var r=new qt(e);return r.get_caught()||(r.set_caught(!0),Vt--),r.set_rethrown(!1),jr.push(r),oi(e)},xi=()=>{W(0,0),_(jr.length>0);var e=jr.pop();ai(e.excPtr)},Hr=e=>(setTempRet0(0),0),Wi=()=>Hr([]),Li=e=>Hr([e]),Ui=(e,r)=>Hr([e,r]);class qt{constructor(r){this.excPtr=r,this.ptr=r-24}set_type(r){(d(),y)[this.ptr+4>>2]=r}get_type(){return(d(),y)[this.ptr+4>>2]}set_destructor(r){(d(),y)[this.ptr+8>>2]=r}get_destructor(){return(d(),y)[this.ptr+8>>2]}set_caught(r){r=r?1:0,(d(),H)[this.ptr+12]=r}get_caught(){return(d(),H)[this.ptr+12]!=0}set_rethrown(r){r=r?1:0,(d(),H)[this.ptr+13]=r}get_rethrown(){return(d(),H)[this.ptr+13]!=0}init(r,t){this.set_adjusted_ptr(0),this.set_type(r),this.set_destructor(t)}set_adjusted_ptr(r){(d(),y)[this.ptr+16>>2]=r}get_adjusted_ptr(){return(d(),y)[this.ptr+16>>2]}}var ji=(e,r,t)=>{var n=new qt(e);n.init(r,t),Vt++,_(!1,"Exception thrown, but exception catching is not enabled. Compile with -sNO_DISABLE_EXCEPTION_CATCHING or -sEXCEPTION_CATCHING_ALLOWED=[..] to catch.")};function Kt(e,r,t,n){return w?K(2,0,1,e,r,t,n):Xt(e,r,t,n)}var Hi=()=>!!globalThis.SharedArrayBuffer,Xt=(e,r,t,n)=>{if(!Hi())return Dr("pthread_create: environment does not support SharedArrayBuffer, pthreads are not available"),6;var i=[],a=0;if(w&&(i.length===0||a))return Kt(e,r,t,n);if(a)return a;var s={startRoutine:t,pthread_ptr:e,arg:n,transferList:i};return w?(s.cmd="spawnThread",postMessage(s,i),0):Wt(s)},Bi=e=>{_(!1,"Exception thrown, but exception catching is not enabled. Compile with -sNO_DISABLE_EXCEPTION_CATCHING or -sEXCEPTION_CATCHING_ALLOWED=[..] to catch.")},zi=()=>{if(C){var e=ue("node:crypto");return r=>e.randomFillSync(r)}return r=>(r.set(crypto.getRandomValues(new Uint8Array(r.byteLength))),0)},Br=e=>(Br=zi())(e),I={isAbs:e=>e.charAt(0)==="/",splitPath:e=>{var r=/^(\/?|)([\s\S]*?)((?:\.{1,2}|[^\/]+?|)(\.[^.\/]*|))(?:[\/]*)$/;return r.exec(e).slice(1)},normalizeArray:(e,r)=>{for(var t=0,n=e.length-1;n>=0;n--){var i=e[n];i==="."?e.splice(n,1):i===".."?(e.splice(n,1),t++):t&&(e.splice(n,1),t--)}if(r)for(;t;t--)e.unshift("..");return e},normalize:e=>{var r=I.isAbs(e),t=e.slice(-1)==="/";return e=I.normalizeArray(e.split("/").filter(n=>!!n),!r).join("/"),!e&&!r&&(e="."),e&&t&&(e+="/"),(r?"/":"")+e},dirname:e=>{var r=I.splitPath(e),t=r[0],n=r[1];return!t&&!n?".":(n&&(n=n.slice(0,-1)),t+n)},basename:e=>e&&e.match(/([^\/]+|\/)\/*$/)[1],join:(...e)=>I.normalize(e.join("/")),join2:(e,r)=>I.normalize(e+"/"+r)},Le={resolve:(...e)=>{for(var r="",t=!1,n=e.length-1;n>=-1&&!t;n--){var i=n>=0?e[n]:o.cwd();if(typeof i!="string")throw new TypeError("Arguments to path.resolve must be strings");if(!i)return"";r=i+"/"+r,t=I.isAbs(i)}return r=I.normalizeArray(r.split("/").filter(a=>!!a),!t).join("/"),(t?"/":"")+r||"."},relative:(e,r)=>{e=Le.resolve(e).slice(1),r=Le.resolve(r).slice(1);function t(u){for(var v=0;v<u.length&&u[v]==="";v++);for(var h=u.length-1;h>=0&&u[h]==="";h--);return v>h?[]:u.slice(v,h-v+1)}for(var n=t(e.split("/")),i=t(r.split("/")),a=Math.min(n.length,i.length),s=a,l=0;l<a;l++)if(n[l]!==i[l]){s=l;break}for(var c=[],l=s;l<n.length;l++)c.push("..");return c=c.concat(i.slice(s)),c.join("/")}},zr=[],Pe=e=>{for(var r=0,t=0;t<e.length;++t){var n=e.charCodeAt(t);n<=127?r++:n<=2047?r+=2:n>=55296&&n<=57343?(r+=4,++t):r+=3}return r},Yt=(e,r,t,n)=>{if(_(typeof e=="string",`stringToUTF8Array expects a string (got ${typeof e})`),!(n>0))return 0;for(var i=t,a=t+n-1,s=0;s<e.length;++s){var l=e.codePointAt(s);if(l<=127){if(t>=a)break;r[t++]=l}else if(l<=2047){if(t+1>=a)break;r[t++]=192|l>>6,r[t++]=128|l&63}else if(l<=65535){if(t+2>=a)break;r[t++]=224|l>>12,r[t++]=128|l>>6&63,r[t++]=128|l&63}else{if(t+3>=a)break;l>1114111&&Fe(`Invalid Unicode code point ${we(l)} encountered when serializing a JS string to a UTF-8 string in wasm memory! (Valid unicode code points should be in range 0-0x10FFFF).`),r[t++]=240|l>>18,r[t++]=128|l>>12&63,r[t++]=128|l>>6&63,r[t++]=128|l&63,s++}}return r[t]=0,t-i},Gr=(e,r,t)=>{var n=t>0?t:Pe(e)+1,i=new Array(n),a=Yt(e,i,0,i.length);return r&&(i.length=a),i},Gi=()=>{if(!zr.length){var e=null;if(C){var r=256,t=Buffer.alloc(r),n=0,i=process.stdin.fd;try{n=N.readSync(i,t,0,r)}catch(a){if(a.toString().includes("EOF"))n=0;else throw a}n>0&&(e=t.slice(0,n).toString("utf-8"))}if(!e)return null;zr=Gr(e,!0)}return zr.shift()},pe={ttys:[],init(){},shutdown(){},register(e,r){pe.ttys[e]={input:[],output:[],ops:r},o.registerDevice(e,pe.stream_ops)},stream_ops:{open(e){var r=pe.ttys[e.node.rdev];if(!r)throw new o.ErrnoError(43);e.tty=r,e.seekable=!1},close(e){e.tty.ops.fsync(e.tty)},fsync(e){e.tty.ops.fsync(e.tty)},read(e,r,t,n,i){if(!e.tty||!e.tty.ops.get_char)throw new o.ErrnoError(60);for(var a=0,s=0;s<n;s++){var l;try{l=e.tty.ops.get_char(e.tty)}catch{throw new o.ErrnoError(29)}if(l===void 0&&a===0)throw new o.ErrnoError(6);if(l==null)break;a++,r[t+s]=l}return a&&(e.node.atime=Date.now()),a},write(e,r,t,n,i){if(!e.tty||!e.tty.ops.put_char)throw new o.ErrnoError(60);try{for(var a=0;a<n;a++)e.tty.ops.put_char(e.tty,r[t+a])}catch{throw new o.ErrnoError(29)}return n&&(e.node.mtime=e.node.ctime=Date.now()),a}},default_tty_ops:{get_char(e){return Gi()},put_char(e,r){r===null||r===10?(ge(We(e.output)),e.output=[]):r!=0&&e.output.push(r)},fsync(e){e.output?.length>0&&(ge(We(e.output)),e.output=[])},ioctl_tcgets(e){return{c_iflag:25856,c_oflag:5,c_cflag:191,c_lflag:35387,c_cc:[3,28,127,21,4,0,1,0,17,19,26,0,18,15,23,22,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]}},ioctl_tcsets(e,r,t){return 0},ioctl_tiocgwinsz(e){return[24,80]}},default_tty1_ops:{put_char(e,r){r===null||r===10?(A(We(e.output)),e.output=[]):r!=0&&e.output.push(r)},fsync(e){e.output?.length>0&&(A(We(e.output)),e.output=[])}}},Vr=e=>{q("internal error: mmapAlloc called but `emscripten_builtin_memalign` native symbol not exported")},F={ops_table:null,mount(e){return F.createNode(null,"/",16895,0)},createNode(e,r,t,n){if(o.isBlkdev(t)||o.isFIFO(t))throw new o.ErrnoError(63);F.ops_table||={dir:{node:{getattr:F.node_ops.getattr,setattr:F.node_ops.setattr,lookup:F.node_ops.lookup,mknod:F.node_ops.mknod,rename:F.node_ops.rename,unlink:F.node_ops.unlink,rmdir:F.node_ops.rmdir,readdir:F.node_ops.readdir,symlink:F.node_ops.symlink},stream:{llseek:F.stream_ops.llseek}},file:{node:{getattr:F.node_ops.getattr,setattr:F.node_ops.setattr},stream:{llseek:F.stream_ops.llseek,read:F.stream_ops.read,write:F.stream_ops.write,mmap:F.stream_ops.mmap,msync:F.stream_ops.msync}},link:{node:{getattr:F.node_ops.getattr,setattr:F.node_ops.setattr,readlink:F.node_ops.readlink},stream:{}},chrdev:{node:{getattr:F.node_ops.getattr,setattr:F.node_ops.setattr},stream:o.chrdev_stream_ops}};var i=o.createNode(e,r,t,n);return o.isDir(i.mode)?(i.node_ops=F.ops_table.dir.node,i.stream_ops=F.ops_table.dir.stream,i.contents={}):o.isFile(i.mode)?(i.node_ops=F.ops_table.file.node,i.stream_ops=F.ops_table.file.stream,i.usedBytes=0,i.contents=F.emptyFileContents??=new Uint8Array(0)):o.isLink(i.mode)?(i.node_ops=F.ops_table.link.node,i.stream_ops=F.ops_table.link.stream):o.isChrdev(i.mode)&&(i.node_ops=F.ops_table.chrdev.node,i.stream_ops=F.ops_table.chrdev.stream),i.atime=i.mtime=i.ctime=Date.now(),e&&(e.contents[r]=i,e.atime=e.mtime=e.ctime=i.atime),i},getFileDataAsTypedArray(e){return _(o.isFile(e.mode),"getFileDataAsTypedArray called on non-file"),e.contents.subarray(0,e.usedBytes)},expandFileStorage(e,r){var t=e.contents.length;if(!(t>=r)){var n=1024*1024;r=Math.max(r,t*(t<n?2:1.125)>>>0),t&&(r=Math.max(r,256));var i=F.getFileDataAsTypedArray(e);e.contents=new Uint8Array(r),e.contents.set(i)}},resizeFileStorage(e,r){if(e.usedBytes!=r){var t=e.contents;e.contents=new Uint8Array(r),e.contents.set(t.subarray(0,Math.min(r,e.usedBytes))),e.usedBytes=r}},node_ops:{getattr(e){var r={};return r.dev=o.isChrdev(e.mode)?e.id:1,r.ino=e.id,r.mode=e.mode,r.nlink=1,r.uid=0,r.gid=0,r.rdev=e.rdev,o.isDir(e.mode)?r.size=4096:o.isFile(e.mode)?r.size=e.usedBytes:o.isLink(e.mode)?r.size=e.link.length:r.size=0,r.atime=new Date(e.atime),r.mtime=new Date(e.mtime),r.ctime=new Date(e.ctime),r.blksize=4096,r.blocks=Math.ceil(r.size/r.blksize),r},setattr(e,r){for(let t of["mode","atime","mtime","ctime"])r[t]!=null&&(e[t]=r[t]);r.size!==void 0&&F.resizeFileStorage(e,r.size)},lookup(e,r){throw new o.ErrnoError(44)},mknod(e,r,t,n){return F.createNode(e,r,t,n)},rename(e,r,t){var n;try{n=o.lookupNode(r,t)}catch{}if(n){if(o.isDir(e.mode))for(var i in n.contents)throw new o.ErrnoError(55);o.hashRemoveNode(n)}delete e.parent.contents[e.name],r.contents[t]=e,e.name=t,r.ctime=r.mtime=e.parent.ctime=e.parent.mtime=Date.now()},unlink(e,r){delete e.contents[r],e.ctime=e.mtime=Date.now()},rmdir(e,r){var t=o.lookupNode(e,r);for(var n in t.contents)throw new o.ErrnoError(55);delete e.contents[r],e.ctime=e.mtime=Date.now()},readdir(e){return[".","..",...Object.keys(e.contents)]},symlink(e,r,t){var n=F.createNode(e,r,41471,0);return n.link=t,n},readlink(e){if(!o.isLink(e.mode))throw new o.ErrnoError(28);return e.link}},stream_ops:{read(e,r,t,n,i){var a=e.node.contents;if(i>=e.node.usedBytes)return 0;var s=Math.min(e.node.usedBytes-i,n);return _(s>=0),r.set(a.subarray(i,i+s),t),s},write(e,r,t,n,i,a){if(_(r.subarray,"FS.write expects a TypedArray"),r.buffer===(d(),H).buffer&&(a=!1),!n)return 0;var s=e.node;return s.mtime=s.ctime=Date.now(),a?(_(i===0,"canOwn must imply no weird position inside the file"),s.contents=r.subarray(t,t+n),s.usedBytes=n):s.usedBytes===0&&i===0?(s.contents=r.slice(t,t+n),s.usedBytes=n):(F.expandFileStorage(s,i+n),s.contents.set(r.subarray(t,t+n),i),s.usedBytes=Math.max(s.usedBytes,i+n)),n},llseek(e,r,t){var n=r;if(t===1?n+=e.position:t===2&&o.isFile(e.node.mode)&&(n+=e.node.usedBytes),n<0)throw new o.ErrnoError(28);return n},mmap(e,r,t,n,i){if(!o.isFile(e.node.mode))throw new o.ErrnoError(43);var a,s,l=e.node.contents;if(!(i&2)&&l.buffer===(d(),H).buffer)s=!1,a=l.byteOffset;else{if(s=!0,a=Vr(r),!a)throw new o.ErrnoError(48);l&&((t>0||t+r<l.length)&&(l.subarray?l=l.subarray(t,t+r):l=Array.prototype.slice.call(l,t,t+r)),(d(),H).set(l,a))}return{ptr:a,allocated:s}},msync(e,r,t,n,i){return F.stream_ops.write(e,r,0,n,t,!1),0}}},Vi=e=>{if(typeof e!="string")return e;var r={r:0,"r+":2,w:577,"w+":578,a:1089,"a+":1090},t=r[e];if(typeof t>"u")throw new Error(`Unknown file open mode: ${e}`);return t},Jt=e=>(typeof e=="string"&&(e=Gr(e,!0)),e.subarray||(e=new Uint8Array(e)),e),qr=(e,r)=>{var t=0;return e&&(t|=365),r&&(t|=146),t},dr={EPERM:63,ENOENT:44,ESRCH:71,EINTR:27,EIO:29,ENXIO:60,E2BIG:1,ENOEXEC:45,EBADF:8,ECHILD:12,EAGAIN:6,EWOULDBLOCK:6,ENOMEM:48,EACCES:2,EFAULT:21,ENOTBLK:105,EBUSY:10,EEXIST:20,EXDEV:75,ENODEV:43,ENOTDIR:54,EISDIR:31,EINVAL:28,ENFILE:41,EMFILE:33,ENOTTY:59,ETXTBSY:74,EFBIG:22,ENOSPC:51,ESPIPE:70,EROFS:69,EMLINK:34,EPIPE:64,EDOM:18,ERANGE:68,ENOMSG:49,EIDRM:24,ECHRNG:106,EL2NSYNC:156,EL3HLT:107,EL3RST:108,ELNRNG:109,EUNATCH:110,ENOCSI:111,EL2HLT:112,EDEADLK:16,ENOLCK:46,EBADE:113,EBADR:114,EXFULL:115,ENOANO:104,EBADRQC:103,EBADSLT:102,EDEADLOCK:16,EBFONT:101,ENOSTR:100,ENODATA:116,ETIME:117,ENOSR:118,ENONET:119,ENOPKG:120,EREMOTE:121,ENOLINK:47,EADV:122,ESRMNT:123,ECOMM:124,EPROTO:65,EMULTIHOP:36,EDOTDOT:125,EBADMSG:9,ENOTUNIQ:126,EBADFD:127,EREMCHG:128,ELIBACC:129,ELIBBAD:130,ELIBSCN:131,ELIBMAX:132,ELIBEXEC:133,ENOSYS:52,ENOTEMPTY:55,ENAMETOOLONG:37,ELOOP:32,EOPNOTSUPP:138,EPFNOSUPPORT:139,ECONNRESET:15,ENOBUFS:42,EAFNOSUPPORT:5,EPROTOTYPE:67,ENOTSOCK:57,ENOPROTOOPT:50,ESHUTDOWN:140,ECONNREFUSED:14,EADDRINUSE:3,ECONNABORTED:13,ENETUNREACH:40,ENETDOWN:38,ETIMEDOUT:73,EHOSTDOWN:142,EHOSTUNREACH:23,EINPROGRESS:26,EALREADY:7,EDESTADDRREQ:17,EMSGSIZE:35,EPROTONOSUPPORT:66,ESOCKTNOSUPPORT:137,EADDRNOTAVAIL:4,ENETRESET:39,EISCONN:30,ENOTCONN:53,ETOOMANYREFS:141,EUSERS:136,EDQUOT:19,ESTALE:72,ENOTSUP:138,ENOMEDIUM:148,EILSEQ:25,EOVERFLOW:61,ECANCELED:11,ENOTRECOVERABLE:56,EOWNERDEAD:62,ESTRPIPE:135},b={isWindows:!1,staticInit(){b.isWindows=!!process.platform.match(/^win/);var e=process.binding("constants").fs;b.flagsForNodeMap={1024:e.O_APPEND,64:e.O_CREAT,128:e.O_EXCL,256:e.O_NOCTTY,0:e.O_RDONLY,2:e.O_RDWR,4096:e.O_SYNC,512:e.O_TRUNC,1:e.O_WRONLY,131072:e.O_NOFOLLOW},_(b.flagsForNodeMap[0]===0)},convertNodeCode(e){var r=e.code;return _(r in dr,`unexpected node error code: ${r} (${e})`),dr[r]},tryFSOperation(e){try{return e()}catch(r){throw r.code?r.code==="UNKNOWN"?new o.ErrnoError(28):new o.ErrnoError(b.convertNodeCode(r)):r}},mount(e){return _(C),b.createNode(null,"/",b.getMode(e.opts.root),0)},createNode(e,r,t,n){if(!o.isDir(t)&&!o.isFile(t)&&!o.isLink(t))throw new o.ErrnoError(28);var i=o.createNode(e,r,t);return i.node_ops=b.node_ops,i.stream_ops=b.stream_ops,i},getMode(e){return b.tryFSOperation(()=>{var r=N.lstatSync(e).mode;return b.isWindows&&(r|=(r&292)>>2),r})},realPath(e){for(var r=[];e.parent!==e;)r.push(e.name),e=e.parent;return r.push(e.mount.opts.root),r.reverse(),I.join(...r)},flagsForNode(e){e&=-2097153,e&=-2049,e&=-32769,e&=-524289,e&=-65537;var r=0;for(var t in b.flagsForNodeMap)e&t&&(r|=b.flagsForNodeMap[t],e^=t);if(e)throw new o.ErrnoError(28);return r},getattr(e,r){var t=b.tryFSOperation(e);return b.isWindows&&(t.blksize||(t.blksize=4096),t.blocks||(t.blocks=(t.size+t.blksize-1)/t.blksize|0),t.mode|=(t.mode&292)>>2),{dev:t.dev,ino:r.id,mode:t.mode,nlink:t.nlink,uid:t.uid,gid:t.gid,rdev:t.rdev,size:t.size,atime:t.atime,mtime:t.mtime,ctime:t.ctime,blksize:t.blksize,blocks:t.blocks}},setattr(e,r,t,n,i,a,s){b.tryFSOperation(()=>{if(t.mode!==void 0){var l=t.mode;b.isWindows&&(l&=384),n(e,l),r.mode=t.mode}if(typeof(t.atime??t.mtime)=="number"){var c=new Date(t.atime??s(e).atime),u=new Date(t.mtime??s(e).mtime);i(e,c,u)}t.size!==void 0&&a(e,t.size)})},node_ops:{getattr(e){var r=b.realPath(e);return b.getattr(()=>N.lstatSync(r),e)},setattr(e,r){var t=b.realPath(e);if(r.mode!=null&&r.dontFollow)throw new o.ErrnoError(52);b.setattr(t,e,r,N.chmodSync,N.utimesSync,N.truncateSync,N.lstatSync)},lookup(e,r){var t=I.join2(b.realPath(e),r),n=b.getMode(t);return b.createNode(e,r,n)},mknod(e,r,t,n){var i=b.createNode(e,r,t,n),a=b.realPath(i);return b.tryFSOperation(()=>{o.isDir(i.mode)?N.mkdirSync(a,i.mode):N.writeFileSync(a,"",{mode:i.mode})}),i},rename(e,r,t){var n=b.realPath(e),i=I.join2(b.realPath(r),t);try{o.unlink(i)}catch{}b.tryFSOperation(()=>N.renameSync(n,i)),e.name=t},unlink(e,r){var t=I.join2(b.realPath(e),r);b.tryFSOperation(()=>N.unlinkSync(t))},rmdir(e,r){var t=I.join2(b.realPath(e),r);b.tryFSOperation(()=>N.rmdirSync(t))},readdir(e){var r=b.realPath(e);return b.tryFSOperation(()=>N.readdirSync(r))},symlink(e,r,t){var n=I.join2(b.realPath(e),r);b.tryFSOperation(()=>N.symlinkSync(t,n))},readlink(e){var r=b.realPath(e);return b.tryFSOperation(()=>N.readlinkSync(r))},statfs(e){var r=b.tryFSOperation(()=>N.statfsSync(e));return r.frsize=r.bsize,r}},stream_ops:{getattr(e){return b.getattr(()=>N.fstatSync(e.nfd),e.node)},setattr(e,r){b.setattr(e.nfd,e.node,r,N.fchmodSync,N.futimesSync,N.ftruncateSync,N.fstatSync)},open(e){var r=b.realPath(e.node);b.tryFSOperation(()=>{e.shared.refcount=1,e.nfd=N.openSync(r,b.flagsForNode(e.flags))})},close(e){b.tryFSOperation(()=>{e.nfd&&--e.shared.refcount===0&&N.closeSync(e.nfd)})},dup(e){e.shared.refcount++},read(e,r,t,n,i){return b.tryFSOperation(()=>N.readSync(e.nfd,r,t,n,i))},write(e,r,t,n,i){return b.tryFSOperation(()=>N.writeSync(e.nfd,r,t,n,i))},llseek(e,r,t){var n=r;if(t===1?n+=e.position:t===2&&o.isFile(e.node.mode)&&b.tryFSOperation(()=>{var i=N.fstatSync(e.nfd);n+=i.size}),n<0)throw new o.ErrnoError(28);return n},mmap(e,r,t,n,i){if(!o.isFile(e.node.mode))throw new o.ErrnoError(43);var a=Vr(r);return b.stream_ops.read(e,(d(),H),a,r,t),{ptr:a,allocated:!0}},msync(e,r,t,n,i){return b.stream_ops.write(e,r,0,n,t,!1),0}}},qi=e=>_e(Kn(e)),Ki=async e=>{var r=await nr(e);return _(r,`Loading data file "${e}" failed (no arrayBuffer).`),new Uint8Array(r)},Zt=(...e)=>o.createDataFile(...e),Xi=e=>{for(var r=e;;){if(!xe[e])return e;e=r+Math.random()}},Qt=[],Yi=async(e,r)=>{typeof Browser<"u"&&Browser.init();for(var t of Qt)if(t.canHandle(r))return _(t.handle.constructor.name==="AsyncFunction","Filesystem plugin handlers must be async functions (See #24914)"),t.handle(e,r);return e},Kr=async(e,r,t,n,i,a,s,l)=>{var c=r?Le.resolve(I.join2(e,r)):e,u=Xi(`cp ${c}`);Wr(u);try{var v=t;typeof t=="string"&&(v=await Ki(t)),v=await Yi(v,c),l?.(),a||Zt(e,r,v,n,i,s)}finally{xr(u)}},Ji=(e,r,t,n,i,a,s,l,c,u)=>{Kr(e,r,t,n,i,l,c,u).then(a).catch(s)},o={root:null,mounts:[],devices:{},streams:[],nextInode:1,nameTable:null,currentPath:"/",initialized:!1,ignorePermissions:!0,filesystems:null,syncFSRequests:0,ErrnoError:class extends Error{name="ErrnoError";constructor(e){super(Ne?qi(e):""),this.errno=e;for(var r in dr)if(dr[r]===e){this.code=r;break}}},FSStream:class{shared={};get object(){return this.node}set object(e){this.node=e}get isRead(){return(this.flags&2097155)!==1}get isWrite(){return(this.flags&2097155)!==0}get isAppend(){return this.flags&1024}get flags(){return this.shared.flags}set flags(e){this.shared.flags=e}get position(){return this.shared.position}set position(e){this.shared.position=e}},FSNode:class{node_ops={};stream_ops={};readMode=365;writeMode=146;mounted=null;constructor(e,r,t,n){e||(e=this),this.parent=e,this.mount=e.mount,this.id=o.nextInode++,this.name=r,this.mode=t,this.rdev=n,this.atime=this.mtime=this.ctime=Date.now()}get read(){return(this.mode&this.readMode)===this.readMode}set read(e){e?this.mode|=this.readMode:this.mode&=~this.readMode}get write(){return(this.mode&this.writeMode)===this.writeMode}set write(e){e?this.mode|=this.writeMode:this.mode&=~this.writeMode}get isFolder(){return o.isDir(this.mode)}get isDevice(){return o.isChrdev(this.mode)}},lookupPath(e,r={}){if(!e)throw new o.ErrnoError(44);r.follow_mount??=!0,I.isAbs(e)||(e=o.cwd()+"/"+e);e:for(var t=0;t<40;t++){for(var n=e.split("/").filter(u=>!!u),i=o.root,a="/",s=0;s<n.length;s++){var l=s===n.length-1;if(l&&r.parent)break;if(n[s]!=="."){if(n[s]===".."){if(a=I.dirname(a),o.isRoot(i)){e=a+"/"+n.slice(s+1).join("/"),t--;continue e}else i=i.parent;continue}a=I.join2(a,n[s]);try{i=o.lookupNode(i,n[s])}catch(u){if(u?.errno===44&&l&&r.noent_okay)return{path:a};throw u}if(o.isMountpoint(i)&&(!l||r.follow_mount)&&(i=i.mounted.root),o.isLink(i.mode)&&(!l||r.follow)){if(!i.node_ops.readlink)throw new o.ErrnoError(52);var c=i.node_ops.readlink(i);I.isAbs(c)||(c=I.dirname(a)+"/"+c),e=c+"/"+n.slice(s+1).join("/");continue e}}}return{path:a,node:i}}throw new o.ErrnoError(32)},getPath(e){for(var r;;){if(o.isRoot(e)){var t=e.mount.mountpoint;return r?t[t.length-1]!=="/"?`${t}/${r}`:t+r:t}r=r?`${e.name}/${r}`:e.name,e=e.parent}},hashName(e,r){for(var t=0,n=0;n<r.length;n++)t=(t<<5)-t+r.charCodeAt(n)|0;return(e+t>>>0)%o.nameTable.length},hashAddNode(e){var r=o.hashName(e.parent.id,e.name);e.name_next=o.nameTable[r],o.nameTable[r]=e},hashRemoveNode(e){var r=o.hashName(e.parent.id,e.name);if(o.nameTable[r]===e)o.nameTable[r]=e.name_next;else for(var t=o.nameTable[r];t;){if(t.name_next===e){t.name_next=e.name_next;break}t=t.name_next}},lookupNode(e,r){var t=o.mayLookup(e);if(t)throw new o.ErrnoError(t);for(var n=o.hashName(e.id,r),i=o.nameTable[n];i;i=i.name_next){var a=i.name;if(i.parent.id===e.id&&a===r)return i}return o.lookup(e,r)},createNode(e,r,t,n){_(typeof e=="object");var i=new o.FSNode(e,r,t,n);return o.hashAddNode(i),i},destroyNode(e){o.hashRemoveNode(e)},isRoot(e){return e===e.parent},isMountpoint(e){return!!e.mounted},isFile(e){return(e&61440)===32768},isDir(e){return(e&61440)===16384},isLink(e){return(e&61440)===40960},isChrdev(e){return(e&61440)===8192},isBlkdev(e){return(e&61440)===24576},isFIFO(e){return(e&61440)===4096},isSocket(e){return(e&49152)===49152},flagsToPermissionString(e){var r=["r","w","rw"][e&3];return e&512&&(r+="w"),r},nodePermissions(e,r){return o.ignorePermissions?0:r.includes("r")&&!(e.mode&292)||r.includes("w")&&!(e.mode&146)||r.includes("x")&&!(e.mode&73)?2:0},mayLookup(e){if(!o.isDir(e.mode))return 54;var r=o.nodePermissions(e,"x");return r||(e.node_ops.lookup?0:2)},mayCreate(e,r){if(!o.isDir(e.mode))return 54;try{var t=o.lookupNode(e,r);return 20}catch{}return o.nodePermissions(e,"wx")},mayDelete(e,r,t){var n;try{n=o.lookupNode(e,r)}catch(a){return a.errno}var i=o.nodePermissions(e,"wx");if(i)return i;if(t){if(!o.isDir(n.mode))return 54;if(o.isRoot(n)||o.getPath(n)===o.cwd())return 10}else if(o.isDir(n.mode))return 31;return 0},mayOpen(e,r){if(!e)return 44;if(o.isLink(e.mode))return 32;var t=o.flagsToPermissionString(r);return o.isDir(e.mode)&&(t!=="r"||r&576)?31:o.nodePermissions(e,t)},checkOpExists(e,r){if(!e)throw new o.ErrnoError(r);return e},MAX_OPEN_FDS:4096,nextfd(){for(var e=0;e<=o.MAX_OPEN_FDS;e++)if(!o.streams[e])return e;throw new o.ErrnoError(33)},getStreamChecked(e){var r=o.getStream(e);if(!r)throw new o.ErrnoError(8);return r},getStream:e=>o.streams[e],createStream(e,r=-1){return _(r>=-1),e=Object.assign(new o.FSStream,e),r==-1&&(r=o.nextfd()),e.fd=r,o.streams[r]=e,e},closeStream(e){o.streams[e]=null},dupStream(e,r=-1){var t=o.createStream(e,r);return t.stream_ops?.dup?.(t),t},doSetAttr(e,r,t){var n=e?.stream_ops.setattr,i=n?e:r;n??=r.node_ops.setattr,o.checkOpExists(n,63);try{n(i,t)}catch(a){throw a instanceof RangeError?new o.ErrnoError(22):a}},chrdev_stream_ops:{open(e){var r=o.getDevice(e.node.rdev);e.stream_ops=r.stream_ops,e.stream_ops.open?.(e)},llseek(){throw new o.ErrnoError(70)}},major:e=>e>>8,minor:e=>e&255,makedev:(e,r)=>e<<8|r,registerDevice(e,r){o.devices[e]={stream_ops:r}},getDevice:e=>o.devices[e],getMounts(e){for(var r=[],t=[e];t.length;){var n=t.pop();r.push(n),t.push(...n.mounts)}return r},syncfs(e,r){typeof e=="function"&&(r=e,e=!1),o.syncFSRequests++,o.syncFSRequests>1&&A(`warning: ${o.syncFSRequests} FS.syncfs operations in flight at once, probably just doing extra work`);var t=o.getMounts(o.root.mount),n=0;function i(l){return _(o.syncFSRequests>0),o.syncFSRequests--,r(l)}function a(l){if(l)return a.errored?void 0:(a.errored=!0,i(l));++n>=t.length&&i(null)}for(var s of t)s.type.syncfs?s.type.syncfs(s,e,a):a(null)},mount(e,r,t){if(typeof e=="string")throw e;var n=t==="/",i=!t,a;if(n&&o.root)throw new o.ErrnoError(10);if(!n&&!i){var s=o.lookupPath(t,{follow_mount:!1});if(t=s.path,a=s.node,o.isMountpoint(a))throw new o.ErrnoError(10);if(!o.isDir(a.mode))throw new o.ErrnoError(54)}var l={type:e,opts:r,mountpoint:t,mounts:[]},c=e.mount(l);return c.mount=l,l.root=c,n?o.root=c:a&&(a.mounted=l,a.mount&&a.mount.mounts.push(l)),c},unmount(e){var r=o.lookupPath(e,{follow_mount:!1});if(!o.isMountpoint(r.node))throw new o.ErrnoError(28);var t=r.node,n=t.mounted,i=o.getMounts(n);for(var[a,s]of Object.entries(o.nameTable))for(;s;){var l=s.name_next;i.includes(s.mount)&&o.destroyNode(s),s=l}t.mounted=null;var c=t.mount.mounts.indexOf(n);_(c!==-1),t.mount.mounts.splice(c,1)},lookup(e,r){return e.node_ops.lookup(e,r)},mknod(e,r,t){var n=o.lookupPath(e,{parent:!0}),i=n.node,a=I.basename(e);if(!a)throw new o.ErrnoError(28);if(a==="."||a==="..")throw new o.ErrnoError(20);var s=o.mayCreate(i,a);if(s)throw new o.ErrnoError(s);if(!i.node_ops.mknod)throw new o.ErrnoError(63);return i.node_ops.mknod(i,a,r,t)},statfs(e){return o.statfsNode(o.lookupPath(e,{follow:!0}).node)},statfsStream(e){return o.statfsNode(e.node)},statfsNode(e){var r={bsize:4096,frsize:4096,blocks:1e6,bfree:5e5,bavail:5e5,files:o.nextInode,ffree:o.nextInode-1,fsid:42,flags:2,namelen:255};return e.node_ops.statfs&&Object.assign(r,e.node_ops.statfs(e.mount.opts.root)),r},create(e,r=438){return r&=4095,r|=32768,o.mknod(e,r,0)},mkdir(e,r=511){return r&=1023,r|=16384,o.mknod(e,r,0)},mkdirTree(e,r){var t=e.split("/"),n="";for(var i of t)if(i){(n||I.isAbs(e))&&(n+="/"),n+=i;try{o.mkdir(n,r)}catch(a){if(a.errno!=20)throw a}}},mkdev(e,r,t){return typeof t>"u"&&(t=r,r=438),r|=8192,o.mknod(e,r,t)},symlink(e,r){if(!Le.resolve(e))throw new o.ErrnoError(44);var t=o.lookupPath(r,{parent:!0}),n=t.node;if(!n)throw new o.ErrnoError(44);var i=I.basename(r),a=o.mayCreate(n,i);if(a)throw new o.ErrnoError(a);if(!n.node_ops.symlink)throw new o.ErrnoError(63);return n.node_ops.symlink(n,i,e)},rename(e,r){var t=I.dirname(e),n=I.dirname(r),i=I.basename(e),a=I.basename(r),s,l,c;if(s=o.lookupPath(e,{parent:!0}),l=s.node,s=o.lookupPath(r,{parent:!0}),c=s.node,!l||!c)throw new o.ErrnoError(44);if(l.mount!==c.mount)throw new o.ErrnoError(75);var u=o.lookupNode(l,i),v=Le.relative(e,n);if(v.charAt(0)!==".")throw new o.ErrnoError(28);if(v=Le.relative(r,t),v.charAt(0)!==".")throw new o.ErrnoError(55);var h;try{h=o.lookupNode(c,a)}catch{}if(u!==h){var p=o.isDir(u.mode),g=o.mayDelete(l,i,p);if(g)throw new o.ErrnoError(g);if(g=h?o.mayDelete(c,a,p):o.mayCreate(c,a),g)throw new o.ErrnoError(g);if(!l.node_ops.rename)throw new o.ErrnoError(63);if(o.isMountpoint(u)||h&&o.isMountpoint(h))throw new o.ErrnoError(10);if(c!==l&&(g=o.nodePermissions(l,"w"),g))throw new o.ErrnoError(g);o.hashRemoveNode(u);try{l.node_ops.rename(u,c,a),u.parent=c}catch(E){throw E}finally{o.hashAddNode(u)}}},rmdir(e){var r=o.lookupPath(e,{parent:!0}),t=r.node,n=I.basename(e),i=o.lookupNode(t,n),a=o.mayDelete(t,n,!0);if(a)throw new o.ErrnoError(a);if(!t.node_ops.rmdir)throw new o.ErrnoError(63);if(o.isMountpoint(i))throw new o.ErrnoError(10);t.node_ops.rmdir(t,n),o.destroyNode(i)},readdir(e){var r=o.lookupPath(e,{follow:!0}),t=r.node,n=o.checkOpExists(t.node_ops.readdir,54);return n(t)},unlink(e){var r=o.lookupPath(e,{parent:!0}),t=r.node;if(!t)throw new o.ErrnoError(44);var n=I.basename(e),i=o.lookupNode(t,n),a=o.mayDelete(t,n,!1);if(a)throw new o.ErrnoError(a);if(!t.node_ops.unlink)throw new o.ErrnoError(63);if(o.isMountpoint(i))throw new o.ErrnoError(10);t.node_ops.unlink(t,n),o.destroyNode(i)},readlink(e){var r=o.lookupPath(e),t=r.node;if(!t)throw new o.ErrnoError(44);if(!t.node_ops.readlink)throw new o.ErrnoError(28);return t.node_ops.readlink(t)},stat(e,r){var t=o.lookupPath(e,{follow:!r}),n=t.node,i=o.checkOpExists(n.node_ops.getattr,63);return i(n)},fstat(e){var r=o.getStreamChecked(e),t=r.node,n=r.stream_ops.getattr,i=n?r:t;return n??=t.node_ops.getattr,o.checkOpExists(n,63),n(i)},lstat(e){return o.stat(e,!0)},doChmod(e,r,t,n){o.doSetAttr(e,r,{mode:t&4095|r.mode&-4096,ctime:Date.now(),dontFollow:n})},chmod(e,r,t){var n;if(typeof e=="string"){var i=o.lookupPath(e,{follow:!t});n=i.node}else n=e;o.doChmod(null,n,r,t)},lchmod(e,r){o.chmod(e,r,!0)},fchmod(e,r){var t=o.getStreamChecked(e);o.doChmod(t,t.node,r,!1)},doChown(e,r,t){o.doSetAttr(e,r,{timestamp:Date.now(),dontFollow:t})},chown(e,r,t,n){var i;if(typeof e=="string"){var a=o.lookupPath(e,{follow:!n});i=a.node}else i=e;o.doChown(null,i,n)},lchown(e,r,t){o.chown(e,r,t,!0)},fchown(e,r,t){var n=o.getStreamChecked(e);o.doChown(n,n.node,!1)},doTruncate(e,r,t){if(o.isDir(r.mode))throw new o.ErrnoError(31);if(!o.isFile(r.mode))throw new o.ErrnoError(28);var n=o.nodePermissions(r,"w");if(n)throw new o.ErrnoError(n);o.doSetAttr(e,r,{size:t,timestamp:Date.now()})},truncate(e,r){if(r<0)throw new o.ErrnoError(28);var t;if(typeof e=="string"){var n=o.lookupPath(e,{follow:!0});t=n.node}else t=e;o.doTruncate(null,t,r)},ftruncate(e,r){var t=o.getStreamChecked(e);if(r<0||(t.flags&2097155)===0)throw new o.ErrnoError(28);o.doTruncate(t,t.node,r)},utime(e,r,t){var n=o.lookupPath(e,{follow:!0}),i=n.node,a=o.checkOpExists(i.node_ops.setattr,63);a(i,{atime:r,mtime:t})},open(e,r,t=438){if(e==="")throw new o.ErrnoError(44);r=Vi(r),r&64?t=t&4095|32768:t=0;var n,i;if(typeof e=="object")n=e;else{i=e.endsWith("/");var a=o.lookupPath(e,{follow:!(r&131072),noent_okay:!0});n=a.node,e=a.path}var s=!1;if(r&64)if(n){if(r&128)throw new o.ErrnoError(20)}else{if(i)throw new o.ErrnoError(31);n=o.mknod(e,t|511,0),s=!0}if(!n)throw new o.ErrnoError(44);if(o.isChrdev(n.mode)&&(r&=-513),r&65536&&!o.isDir(n.mode))throw new o.ErrnoError(54);if(!s){var l=o.mayOpen(n,r);if(l)throw new o.ErrnoError(l)}r&512&&!s&&o.truncate(n,0),r&=-131713;var c=o.createStream({node:n,path:o.getPath(n),flags:r,seekable:!0,position:0,stream_ops:n.stream_ops,ungotten:[],error:!1});return c.stream_ops.open&&c.stream_ops.open(c),s&&o.chmod(n,t&511),c},close(e){if(o.isClosed(e))throw new o.ErrnoError(8);e.getdents&&(e.getdents=null);try{e.stream_ops.close&&e.stream_ops.close(e)}catch(r){throw r}finally{o.closeStream(e.fd)}e.fd=null},isClosed(e){return e.fd===null},llseek(e,r,t){if(o.isClosed(e))throw new o.ErrnoError(8);if(!e.seekable||!e.stream_ops.llseek)throw new o.ErrnoError(70);if(t!=0&&t!=1&&t!=2)throw new o.ErrnoError(28);return e.position=e.stream_ops.llseek(e,r,t),e.ungotten=[],e.position},read(e,r,t,n,i){if(_(t>=0),n<0||i<0)throw new o.ErrnoError(28);if(o.isClosed(e))throw new o.ErrnoError(8);if((e.flags&2097155)===1)throw new o.ErrnoError(8);if(o.isDir(e.node.mode))throw new o.ErrnoError(31);if(!e.stream_ops.read)throw new o.ErrnoError(28);var a=typeof i<"u";if(!a)i=e.position;else if(!e.seekable)throw new o.ErrnoError(70);var s=e.stream_ops.read(e,r,t,n,i);return a||(e.position+=s),s},write(e,r,t,n,i,a){if(_(t>=0),_(r.subarray,"FS.write expects a TypedArray"),n<0||i<0)throw new o.ErrnoError(28);if(o.isClosed(e))throw new o.ErrnoError(8);if((e.flags&2097155)===0)throw new o.ErrnoError(8);if(o.isDir(e.node.mode))throw new o.ErrnoError(31);if(!e.stream_ops.write)throw new o.ErrnoError(28);e.seekable&&e.flags&1024&&o.llseek(e,0,2);var s=typeof i<"u";if(!s)i=e.position;else if(!e.seekable)throw new o.ErrnoError(70);var l=e.stream_ops.write(e,r,t,n,i,a);return s||(e.position+=l),l},mmap(e,r,t,n,i){if((n&2)!==0&&(i&2)===0&&(e.flags&2097155)!==2)throw new o.ErrnoError(2);if((e.flags&2097155)===1)throw new o.ErrnoError(2);if(!e.stream_ops.mmap)throw new o.ErrnoError(43);if(!r)throw new o.ErrnoError(28);return e.stream_ops.mmap(e,r,t,n,i)},msync(e,r,t,n,i){return _(t>=0),e.stream_ops.msync?e.stream_ops.msync(e,r,t,n,i):0},ioctl(e,r,t){if(!e.stream_ops.ioctl)throw new o.ErrnoError(59);return e.stream_ops.ioctl(e,r,t)},readFile(e,r={}){r.flags=r.flags||0,r.encoding=r.encoding||"binary",r.encoding!=="utf8"&&r.encoding!=="binary"&&q(`Invalid encoding type "${r.encoding}"`);var t=o.open(e,r.flags),n=o.stat(e),i=n.size,a=new Uint8Array(i);return o.read(t,a,0,i,0),r.encoding==="utf8"&&(a=We(a)),o.close(t),a},writeFile(e,r,t={}){t.flags=t.flags||577;var n=o.open(e,t.flags,t.mode);r=Jt(r),o.write(n,r,0,r.byteLength,void 0,t.canOwn),o.close(n)},cwd:()=>o.currentPath,chdir(e){var r=o.lookupPath(e,{follow:!0});if(r.node===null)throw new o.ErrnoError(44);if(!o.isDir(r.node.mode))throw new o.ErrnoError(54);var t=o.nodePermissions(r.node,"x");if(t)throw new o.ErrnoError(t);o.currentPath=r.path},createDefaultDirectories(){o.mkdir("/tmp"),o.mkdir("/home"),o.mkdir("/home/web_user")},createDefaultDevices(){o.mkdir("/dev"),o.registerDevice(o.makedev(1,3),{read:()=>0,write:(n,i,a,s,l)=>s,llseek:()=>0}),o.mkdev("/dev/null",o.makedev(1,3)),pe.register(o.makedev(5,0),pe.default_tty_ops),pe.register(o.makedev(6,0),pe.default_tty1_ops),o.mkdev("/dev/tty",o.makedev(5,0)),o.mkdev("/dev/tty1",o.makedev(6,0));var e=new Uint8Array(1024),r=0,t=()=>(r===0&&(Br(e),r=e.byteLength),e[--r]);o.createDevice("/dev","random",t),o.createDevice("/dev","urandom",t),o.mkdir("/dev/shm"),o.mkdir("/dev/shm/tmp")},createSpecialDirectories(){o.mkdir("/proc");var e=o.mkdir("/proc/self");o.mkdir("/proc/self/fd"),o.mount({mount(){var r=o.createNode(e,"fd",16895,73);return r.stream_ops={llseek:F.stream_ops.llseek},r.node_ops={lookup(t,n){var i=+n,a=o.getStreamChecked(i),s={parent:null,mount:{mountpoint:"fake"},node_ops:{readlink:()=>a.path},id:i+1};return s.parent=s,s},readdir(){return Array.from(o.streams.entries()).filter(([t,n])=>n).map(([t,n])=>t.toString())}},r}},{},"/proc/self/fd")},createStandardStreams(e,r,t){e?o.createDevice("/dev","stdin",e):o.symlink("/dev/tty","/dev/stdin"),r?o.createDevice("/dev","stdout",null,r):o.symlink("/dev/tty","/dev/stdout"),t?o.createDevice("/dev","stderr",null,t):o.symlink("/dev/tty1","/dev/stderr");var n=o.open("/dev/stdin",0),i=o.open("/dev/stdout",1),a=o.open("/dev/stderr",1);_(n.fd===0,`invalid handle for stdin (${n.fd})`),_(i.fd===1,`invalid handle for stdout (${i.fd})`),_(a.fd===2,`invalid handle for stderr (${a.fd})`)},staticInit(){o.nameTable=new Array(4096),o.mount(F,{},"/"),o.createDefaultDirectories(),o.createDefaultDevices(),o.createSpecialDirectories(),o.filesystems={MEMFS:F,NODEFS:b}},init(e,r,t){_(!o.initialized,"FS.init was previously called. If you want to initialize later with custom parameters, remove any earlier calls (note that one is automatically added to the generated code)"),o.initialized=!0,e??=f.stdin,r??=f.stdout,t??=f.stderr,o.createStandardStreams(e,r,t)},quit(){o.initialized=!1,lt(0);for(var e of o.streams)e&&o.close(e)},findObject(e,r){var t=o.analyzePath(e,r);return t.exists?t.object:null},analyzePath(e,r){try{var t=o.lookupPath(e,{follow:!r});e=t.path}catch{}var n={isRoot:!1,exists:!1,error:0,name:null,path:null,object:null,parentExists:!1,parentPath:null,parentObject:null};try{var t=o.lookupPath(e,{parent:!0});n.parentExists=!0,n.parentPath=t.path,n.parentObject=t.node,n.name=I.basename(e),t=o.lookupPath(e,{follow:!r}),n.exists=!0,n.path=t.path,n.object=t.node,n.name=t.node.name,n.isRoot=t.path==="/"}catch(i){n.error=i.errno}return n},createPath(e,r,t,n){e=typeof e=="string"?e:o.getPath(e);for(var i=r.split("/").reverse();i.length;){var a=i.pop();if(a){var s=I.join2(e,a);try{o.mkdir(s)}catch(l){if(l.errno!=20)throw l}e=s}}return s},createFile(e,r,t,n,i){var a=I.join2(typeof e=="string"?e:o.getPath(e),r),s=qr(n,i);return o.create(a,s)},createDataFile(e,r,t,n,i,a){var s=r;e&&(e=typeof e=="string"?e:o.getPath(e),s=r?I.join2(e,r):e);var l=qr(n,i),c=o.create(s,l);if(t){t=Jt(t),o.chmod(c,l|146);var u=o.open(c,577);o.write(u,t,0,t.length,0,a),o.close(u),o.chmod(c,l)}},createDevice(e,r,t,n){var i=I.join2(typeof e=="string"?e:o.getPath(e),r),a=qr(!!t,!!n);o.createDevice.major??=64;var s=o.makedev(o.createDevice.major++,0);return o.registerDevice(s,{open(l){l.seekable=!1},close(l){n?.buffer?.length&&n(10)},read(l,c,u,v,h){for(var p=0,g=0;g<v;g++){var E;try{E=t()}catch{throw new o.ErrnoError(29)}if(E===void 0&&p===0)throw new o.ErrnoError(6);if(E==null)break;p++,c[u+g]=E}return p&&(l.node.atime=Date.now()),p},write(l,c,u,v,h){for(var p=0;p<v;p++)try{n(c[u+p])}catch{throw new o.ErrnoError(29)}return v&&(l.node.mtime=l.node.ctime=Date.now()),p}}),o.mkdev(i,a,s)},forceLoadFile(e){if(e.isDevice||e.isFolder||e.link||e.contents)return!0;if(globalThis.XMLHttpRequest)q("Lazy loading should have been performed (contents set) in createLazyFile, but it was not. Lazy loading only works in web workers. Use --embed-file or --preload-file in emcc on the main thread.");else try{e.contents=He(e.url)}catch{throw new o.ErrnoError(29)}},createLazyFile(e,r,t,n,i){class a{lengthKnown=!1;chunks=[];get(p){if(!(p>this.length-1||p<0)){var g=p%this.chunkSize,E=p/this.chunkSize|0;return this.getter(E)[g]}}setDataGetter(p){this.getter=p}cacheLength(){var p=new XMLHttpRequest;p.open("HEAD",t,!1),p.send(null),p.status>=200&&p.status<300||p.status===304||q("Couldn't load "+t+". Status: "+p.status);var g=Number(p.getResponseHeader("Content-length")),E,k=(E=p.getResponseHeader("Accept-Ranges"))&&E==="bytes",R=(E=p.getResponseHeader("Content-Encoding"))&&E==="gzip",D=1024*1024;k||(D=g);var z=(ae,le)=>{ae>le&&q("invalid range ("+ae+", "+le+") or no bytes requested!"),le>g-1&&q("only "+g+" bytes available! programmer error!");var V=new XMLHttpRequest;return V.open("GET",t,!1),g!==D&&V.setRequestHeader("Range","bytes="+ae+"-"+le),V.responseType="arraybuffer",V.overrideMimeType&&V.overrideMimeType("text/plain; charset=x-user-defined"),V.send(null),V.status>=200&&V.status<300||V.status===304||q("Couldn't load "+t+". Status: "+V.status),V.response!==void 0?new Uint8Array(V.response||[]):Gr(V.responseText||"",!0)},G=this;G.setDataGetter(ae=>{var le=ae*D,V=(ae+1)*D-1;return V=Math.min(V,g-1),typeof G.chunks[ae]>"u"&&(G.chunks[ae]=z(le,V)),typeof G.chunks[ae]>"u"&&q("doXHR failed!"),G.chunks[ae]}),(R||!g)&&(D=g=1,g=this.getter(0).length,D=g,ge("LazyFiles on gzip forces download of the whole file when length is accessed")),this._length=g,this._chunkSize=D,this.lengthKnown=!0}get length(){return this.lengthKnown||this.cacheLength(),this._length}get chunkSize(){return this.lengthKnown||this.cacheLength(),this._chunkSize}}if(globalThis.XMLHttpRequest){B||q("Cannot do synchronous binary XHRs outside webworkers in modern browsers. Use --embed-file or --preload-file in emcc");var s=new a,l={isDevice:!1,contents:s}}else var l={isDevice:!1,url:t};var c=o.createFile(e,r,l,n,i);l.contents?c.contents=l.contents:l.url&&(c.contents=null,c.url=l.url),Object.defineProperties(c,{usedBytes:{get:function(){return this.contents.length}}});var u={};for(let[h,p]of Object.entries(c.stream_ops))u[h]=(...g)=>(o.forceLoadFile(c),p(...g));function v(h,p,g,E,k){var R=h.node.contents;if(k>=R.length)return 0;var D=Math.min(R.length-k,E);if(_(D>=0),R.slice)for(var z=0;z<D;z++)p[g+z]=R[k+z];else for(var z=0;z<D;z++)p[g+z]=R.get(k+z);return D}return u.read=(h,p,g,E,k)=>(o.forceLoadFile(c),v(h,p,g,E,k)),u.mmap=(h,p,g,E,k)=>{o.forceLoadFile(c);var R=Vr(p);if(!R)throw new o.ErrnoError(48);return v(h,(d(),H),R,p,g),{ptr:R,allocated:!0}},c.stream_ops=u,c}},T={websocketArgs:{},callbacks:{},on(e,r){T.callbacks[e]=r},emit(e,r){T.callbacks[e]?.(r)},mount(e){return T.websocketArgs=f.websocket||{},(f.websocket??={}).on=T.on,o.createNode(null,"/",16895,0)},createSocket(e,r,t){if(e!=2)throw new o.ErrnoError(5);if(r&=-526337,r!=1&&r!=2)throw new o.ErrnoError(28);var n=r==1;if(n&&t&&t!=6)throw new o.ErrnoError(66);var i={family:e,type:r,protocol:t,server:null,error:null,peers:{},pending:[],recv_queue:[],sock_ops:T.websocket_sock_ops},a=T.nextname(),s=o.createNode(T.root,a,49152,0);s.sock=i;var l=o.createStream({path:a,node:s,flags:2,seekable:!1,stream_ops:T.stream_ops});return i.stream=l,i},getSocket(e){var r=o.getStream(e);return!r||!o.isSocket(r.node.mode)?null:r.node.sock},stream_ops:{poll(e){var r=e.node.sock;return r.sock_ops.poll(r)},ioctl(e,r,t){var n=e.node.sock;return n.sock_ops.ioctl(n,r,t)},read(e,r,t,n,i){var a=e.node.sock,s=a.sock_ops.recvmsg(a,n);return s?(r.set(s.buffer,t),s.buffer.length):0},write(e,r,t,n,i){var a=e.node.sock;return a.sock_ops.sendmsg(a,r,t,n)},close(e){var r=e.node.sock;r.sock_ops.close(r)}},nextname(){return T.nextname.current||(T.nextname.current=0),`socket[${T.nextname.current++}]`},websocket_sock_ops:{createPeer(e,r,t){var n;if(typeof r=="object"&&(n=r,r=null,t=null),n)if(n._socket)r=n._socket.remoteAddress,t=n._socket.remotePort;else{var i=/ws[s]?:\/\/([^:]+):(\d+)/.exec(n.url);if(!i)throw new Error("WebSocket URL must be in the format ws(s)://address:port");r=i[1],t=parseInt(i[2],10)}else try{var a="ws://".replace("#","//"),s="binary",l=void 0;if(T.websocketArgs.url&&(a=T.websocketArgs.url),T.websocketArgs.subprotocol?s=T.websocketArgs.subprotocol:T.websocketArgs.subprotocol===null&&(s="null"),a==="ws://"||a==="wss://"){var c=r.split("/");a=a+c[0]+":"+t+"/"+c.slice(1).join("/")}s!=="null"&&(s=s.replace(/^ +| +$/g,"").split(/ *, */),l=s);var u;C?u=ue("ws"):u=WebSocket,n=new u(a,l),n.binaryType="arraybuffer"}catch{throw new o.ErrnoError(23)}var v={addr:r,port:t,socket:n,msg_send_queue:[]};return T.websocket_sock_ops.addPeer(e,v),T.websocket_sock_ops.handlePeerEvents(e,v),e.type===2&&typeof e.sport<"u"&&v.msg_send_queue.push(new Uint8Array([255,255,255,255,112,111,114,116,(e.sport&65280)>>8,e.sport&255])),v},getPeer(e,r,t){return e.peers[r+":"+t]},addPeer(e,r){e.peers[r.addr+":"+r.port]=r},removePeer(e,r){delete e.peers[r.addr+":"+r.port]},handlePeerEvents(e,r){var t=!0;function n(){e.connecting=!1,T.emit("open",e.stream.fd);try{for(var a=r.msg_send_queue.shift();a;)r.socket.send(a),a=r.msg_send_queue.shift()}catch{r.socket.close()}}function i(a){if(typeof a=="string"){var s=new TextEncoder;a=s.encode(a)}else{if(_(a.byteLength!==void 0),a.byteLength==0)return;a=new Uint8Array(a)}var l=t;if(t=!1,l&&a.length===10&&a[0]===255&&a[1]===255&&a[2]===255&&a[3]===255&&a[4]===112&&a[5]===111&&a[6]===114&&a[7]===116){var c=a[8]<<8|a[9];T.websocket_sock_ops.removePeer(e,r),r.port=c,T.websocket_sock_ops.addPeer(e,r);return}e.recv_queue.push({addr:r.addr,port:r.port,data:a}),T.emit("message",e.stream.fd)}if(C){r.socket.on("open",n),r.socket.on("message",(a,s)=>{s&&i(new Uint8Array(a).buffer)}),r.socket.on("close",()=>T.emit("close",e.stream.fd)),r.socket.on("error",a=>{e.error=14,T.emit("error",[e.stream.fd,e.error,"ECONNREFUSED: Connection refused"])});return}r.socket.onopen=n,r.socket.onclose=()=>T.emit("close",e.stream.fd),r.socket.onmessage=a=>i(a.data),r.socket.onerror=a=>{e.error=14,T.emit("error",[e.stream.fd,e.error,"ECONNREFUSED: Connection refused"])}},poll(e){if(e.type===1&&e.server)return e.pending.length?65:0;var r=0,t=e.type===1?T.websocket_sock_ops.getPeer(e,e.daddr,e.dport):null;return(e.recv_queue.length||!t||t&&t.socket.readyState===t.socket.CLOSING||t&&t.socket.readyState===t.socket.CLOSED)&&(r|=65),(!t||t&&t.socket.readyState===t.socket.OPEN)&&(r|=4),(t&&t.socket.readyState===t.socket.CLOSING||t&&t.socket.readyState===t.socket.CLOSED)&&(e.connecting?r|=4:r|=16),r},ioctl(e,r,t){switch(r){case 21531:var n=0;return e.recv_queue.length&&(n=e.recv_queue[0].data.length),(d(),S)[t>>2]=n,0;case 21537:var i=(d(),S)[t>>2];return i?e.stream.flags|=2048:e.stream.flags&=-2049,0;default:return 28}},close(e){if(e.server){try{e.server.close()}catch{}e.server=null}for(var r of Object.values(e.peers)){try{r.socket.close()}catch{}T.websocket_sock_ops.removePeer(e,r)}return 0},bind(e,r,t){if(typeof e.saddr<"u"||typeof e.sport<"u")throw new o.ErrnoError(28);if(e.saddr=r,e.sport=t,e.type===2){e.server&&(e.server.close(),e.server=null);try{e.sock_ops.listen(e,0)}catch(n){if(n.name!=="ErrnoError"||n.errno!==138)throw n}}},connect(e,r,t){if(e.server)throw new o.ErrnoError(138);if(typeof e.daddr<"u"&&typeof e.dport<"u"){var n=T.websocket_sock_ops.getPeer(e,e.daddr,e.dport);if(n)throw n.socket.readyState===n.socket.CONNECTING?new o.ErrnoError(7):new o.ErrnoError(30)}var i=T.websocket_sock_ops.createPeer(e,r,t);e.daddr=i.addr,e.dport=i.port,e.connecting=!0},listen(e,r){if(!C)throw new o.ErrnoError(138);if(e.server)throw new o.ErrnoError(28);var t=ue("ws").Server,n=e.saddr;e.server=new t({host:n,port:e.sport}),T.emit("listen",e.stream.fd),e.server.on("connection",i=>{if(e.type===1){var a=T.createSocket(e.family,e.type,e.protocol),s=T.websocket_sock_ops.createPeer(a,i);a.daddr=s.addr,a.dport=s.port,e.pending.push(a),T.emit("connection",a.stream.fd)}else T.websocket_sock_ops.createPeer(e,i),T.emit("connection",e.stream.fd)}),e.server.on("close",()=>{T.emit("close",e.stream.fd),e.server=null}),e.server.on("error",i=>{e.error=23,T.emit("error",[e.stream.fd,e.error,"EHOSTUNREACH: Host is unreachable"])})},accept(e){if(!e.server||!e.pending.length)throw new o.ErrnoError(28);var r=e.pending.shift();return r.stream.flags=e.stream.flags,r},getname(e,r){var t,n;if(r){if(e.daddr===void 0||e.dport===void 0)throw new o.ErrnoError(53);t=e.daddr,n=e.dport}else t=e.saddr||0,n=e.sport||0;return{addr:t,port:n}},sendmsg(e,r,t,n,i,a){if(e.type===2){if((i===void 0||a===void 0)&&(i=e.daddr,a=e.dport),i===void 0||a===void 0)throw new o.ErrnoError(17)}else i=e.daddr,a=e.dport;var s=T.websocket_sock_ops.getPeer(e,i,a);if(e.type===1&&(!s||s.socket.readyState===s.socket.CLOSING||s.socket.readyState===s.socket.CLOSED))throw new o.ErrnoError(53);ArrayBuffer.isView(r)&&(t+=r.byteOffset,r=r.buffer);var l=r.slice(t,t+n);if(l instanceof SharedArrayBuffer&&(l=new Uint8Array(new Uint8Array(l)).buffer),!s||s.socket.readyState!==s.socket.OPEN)return e.type===2&&(!s||s.socket.readyState===s.socket.CLOSING||s.socket.readyState===s.socket.CLOSED)&&(s=T.websocket_sock_ops.createPeer(e,i,a)),s.msg_send_queue.push(l),n;try{return s.socket.send(l),n}catch{throw new o.ErrnoError(28)}},recvmsg(e,r){if(e.type===1&&e.server)throw new o.ErrnoError(53);var t=e.recv_queue.shift();if(!t){if(e.type===1){var n=T.websocket_sock_ops.getPeer(e,e.daddr,e.dport);if(!n)throw new o.ErrnoError(53);if(n.socket.readyState===n.socket.CLOSING||n.socket.readyState===n.socket.CLOSED)return null;throw new o.ErrnoError(6)}throw new o.ErrnoError(6)}var i=t.data.byteLength||t.data.length,a=t.data.byteOffset||0,s=t.data.buffer||t.data,l=Math.min(r,i),c={buffer:new Uint8Array(s,a,l),addr:t.addr,port:t.port};if(e.type===1&&l<i){var u=i-l;t.data=new Uint8Array(s,a+l,u),e.recv_queue.unshift(t)}return c}}},Xr=e=>{var r=T.getSocket(e);if(!r)throw new o.ErrnoError(8);return r},Yr=e=>(e&255)+"."+(e>>8&255)+"."+(e>>16&255)+"."+(e>>24&255),en=e=>{var r="",t=0,n=0,i=0,a=0,s=0,l=0,c=[e[0]&65535,e[0]>>16,e[1]&65535,e[1]>>16,e[2]&65535,e[2]>>16,e[3]&65535,e[3]>>16],u=!0,v="";for(l=0;l<5;l++)if(c[l]!==0){u=!1;break}if(u){if(v=Yr(c[6]|c[7]<<16),c[5]===-1)return r="::ffff:",r+=v,r;if(c[5]===0)return r="::",v==="0.0.0.0"&&(v=""),v==="0.0.0.1"&&(v="1"),r+=v,r}for(t=0;t<8;t++)c[t]===0&&(t-i>1&&(s=0),i=t,s++),s>n&&(n=s,a=t-n+1);for(t=0;t<8;t++){if(n>1&&c[t]===0&&t>=a&&t<a+n){t===a&&(r+=":",a===0&&(r+=":"));continue}r+=Number(dt(c[t]&65535)).toString(16),r+=t<7?":":""}return r},Zi=(e,r)=>{var t=(d(),te)[e>>1],n=dt((d(),ke)[e+2>>1]),i;switch(t){case 2:if(r!==16)return{errno:28};i=(d(),S)[e+4>>2],i=Yr(i);break;case 10:if(r!==28)return{errno:28};i=[(d(),S)[e+8>>2],(d(),S)[e+12>>2],(d(),S)[e+16>>2],(d(),S)[e+20>>2]],i=en(i);break;default:return{errno:5}}return{family:t,addr:i,port:n}},ur=e=>{for(var r=e.split("."),t=0;t<4;t++){var n=Number(r[t]);if(isNaN(n))return null;r[t]=n}return(r[0]|r[1]<<8|r[2]<<16|r[3]<<24)>>>0},Jr=e=>{var r,t,n,i,a,s=/^((?=.*::)(?!.*::.+::)(::)?([\dA-F]{1,4}:(:|\b)|){5}|([\dA-F]{1,4}:){6})((([\dA-F]{1,4}((?!\3)::|:\b|$))|(?!\2\3)){2}|(((2[0-4]|1\d|[1-9])?\d|25[0-5])\.?\b){4})$/i,l=[];if(!s.test(e))return null;if(e==="::")return[0,0,0,0,0,0,0,0];for(e.startsWith("::")?e=e.replace("::","Z:"):e=e.replace("::",":Z:"),e.indexOf(".")>0?(e=e.replace(new RegExp("[.]","g"),":"),r=e.split(":"),r[r.length-4]=Number(r[r.length-4])+Number(r[r.length-3])*256,r[r.length-3]=Number(r[r.length-2])+Number(r[r.length-1])*256,r=r.slice(0,r.length-2)):r=e.split(":"),n=0,i=0,t=0;t<r.length;t++)if(typeof r[t]=="string")if(r[t]==="Z"){for(i=0;i<8-r.length+1;i++)l[t+i]=0;n=i-1}else l[t+n]=Pr(parseInt(r[t],16));else l[t+n]=r[t];return[l[1]<<16|l[0],l[3]<<16|l[2],l[5]<<16|l[4],l[7]<<16|l[6]]},ve={address_map:{id:1,addrs:{},names:{}},lookup_name(e){var r=ur(e);if(r!==null||(r=Jr(e),r!==null))return e;var t;if(ve.address_map.addrs[e])t=ve.address_map.addrs[e];else{var n=ve.address_map.id++;_(n<65535,"exceeded max address mappings of 65535"),t="172.29."+(n&255)+"."+(n&65280),ve.address_map.names[t]=e,ve.address_map.addrs[e]=t}return t},lookup_addr(e){return ve.address_map.names[e]?ve.address_map.names[e]:null}},rn=(e,r)=>{var t=Zi(e,r);if(t.errno)throw new o.ErrnoError(t.errno);return t.addr=ve.lookup_addr(t.addr)||t.addr,t};function tn(e,r,t,n,i,a){if(w)return K(3,0,1,e,r,t,n,i,a);try{var s=Xr(e),l=rn(r,t);return s.sock_ops.connect(s,l.addr,l.port),0}catch(c){if(typeof o>"u"||c.name!=="ErrnoError")throw c;return-c.errno}}var X={currentUmask:18,calculateAt(e,r,t){if(I.isAbs(r))return r;var n;if(e===-100)n=o.cwd();else{var i=X.getStreamFromFD(e);n=i.path}if(r.length==0){if(!t)throw new o.ErrnoError(44);return n}return n+"/"+r},writeStat(e,r){(d(),y)[e>>2]=r.dev,(d(),y)[e+4>>2]=r.mode,(d(),y)[e+8>>2]=r.nlink,(d(),y)[e+12>>2]=r.uid,(d(),y)[e+16>>2]=r.gid,(d(),y)[e+20>>2]=r.rdev,(d(),Z)[e+24>>3]=BigInt(r.size),(d(),S)[e+32>>2]=4096,(d(),S)[e+36>>2]=r.blocks;var t=r.atime.getTime(),n=r.mtime.getTime(),i=r.ctime.getTime();return(d(),Z)[e+40>>3]=BigInt(Math.floor(t/1e3)),(d(),y)[e+48>>2]=t%1e3*1e3*1e3,(d(),Z)[e+56>>3]=BigInt(Math.floor(n/1e3)),(d(),y)[e+64>>2]=n%1e3*1e3*1e3,(d(),Z)[e+72>>3]=BigInt(Math.floor(i/1e3)),(d(),y)[e+80>>2]=i%1e3*1e3*1e3,(d(),Z)[e+88>>3]=BigInt(r.ino),0},writeStatFs(e,r){(d(),y)[e+4>>2]=r.bsize,(d(),y)[e+60>>2]=r.bsize,(d(),Z)[e+8>>3]=BigInt(r.blocks),(d(),Z)[e+16>>3]=BigInt(r.bfree),(d(),Z)[e+24>>3]=BigInt(r.bavail),(d(),Z)[e+32>>3]=BigInt(r.files),(d(),Z)[e+40>>3]=BigInt(r.ffree),(d(),y)[e+48>>2]=r.fsid,(d(),y)[e+64>>2]=r.flags,(d(),y)[e+56>>2]=r.namelen},doMsync(e,r,t,n,i){if(!o.isFile(r.node.mode))throw new o.ErrnoError(43);if(n&2)return 0;var a=(d(),Q).slice(e,e+t);o.msync(r,a,i,t,n)},getStreamFromFD(e){var r=o.getStreamChecked(e);return r},varargs:void 0,getStr(e){var r=_e(e);return r}};function nn(e){if(w)return K(4,0,1,e);try{var r=X.getStreamFromFD(e);return o.dupStream(r).fd}catch(t){if(typeof o>"u"||t.name!=="ErrnoError")throw t;return-t.errno}}var fr=()=>{_(X.varargs!=null);var e=(d(),S)[+X.varargs>>2];return X.varargs+=4,e},Ue=fr;function an(e,r,t){if(w)return K(5,0,1,e,r,t);X.varargs=t;try{var n=X.getStreamFromFD(e);switch(r){case 0:{var i=fr();if(i<0)return-28;for(;o.streams[i];)i++;var a;return a=o.dupStream(n,i),a.fd}case 1:case 2:return 0;case 3:return n.flags;case 4:{var i=fr(),s=289792;return n.flags=n.flags&~s|i&s,0}case 12:{var i=Ue(),l=0;return(d(),te)[i+l>>1]=2,0}case 13:case 14:return 0}return-28}catch(c){if(typeof o>"u"||c.name!=="ErrnoError")throw c;return-c.errno}}var Ee=(e,r,t)=>(_(typeof t=="number","stringToUTF8 requires a third parameter that specifies the length of the output buffer"),Yt(e,(d(),Q),r,t));function on(e,r){if(w)return K(6,0,1,e,r);try{if(r===0)return-28;var t=o.cwd(),n=Pe(t)+1;return r<n?-68:(Ee(t,e,r),n)}catch(i){if(typeof o>"u"||i.name!=="ErrnoError")throw i;return-i.errno}}function sn(e,r,t){if(w)return K(7,0,1,e,r,t);X.varargs=t;try{var n=X.getStreamFromFD(e);switch(r){case 21509:return n.tty?0:-59;case 21505:{if(!n.tty)return-59;if(n.tty.ops.ioctl_tcgets){var i=n.tty.ops.ioctl_tcgets(n),a=Ue();(d(),S)[a>>2]=i.c_iflag||0,(d(),S)[a+4>>2]=i.c_oflag||0,(d(),S)[a+8>>2]=i.c_cflag||0,(d(),S)[a+12>>2]=i.c_lflag||0;for(var s=0;s<32;s++)(d(),H)[a+s+17]=i.c_cc[s]||0;return 0}return 0}case 21510:case 21511:case 21512:return n.tty?0:-59;case 21506:case 21507:case 21508:{if(!n.tty)return-59;if(n.tty.ops.ioctl_tcsets){for(var a=Ue(),l=(d(),S)[a>>2],c=(d(),S)[a+4>>2],u=(d(),S)[a+8>>2],v=(d(),S)[a+12>>2],h=[],s=0;s<32;s++)h.push((d(),H)[a+s+17]);return n.tty.ops.ioctl_tcsets(n.tty,r,{c_iflag:l,c_oflag:c,c_cflag:u,c_lflag:v,c_cc:h})}return 0}case 21519:{if(!n.tty)return-59;var a=Ue();return(d(),S)[a>>2]=0,0}case 21520:return n.tty?-28:-59;case 21537:case 21531:{var a=Ue();return o.ioctl(n,r,a)}case 21523:{if(!n.tty)return-59;if(n.tty.ops.ioctl_tiocgwinsz){var p=n.tty.ops.ioctl_tiocgwinsz(n.tty),a=Ue();(d(),te)[a>>1]=p[0],(d(),te)[a+2>>1]=p[1]}return 0}case 21524:return n.tty?0:-59;case 21515:return n.tty?0:-59;default:return-28}}catch(g){if(typeof o>"u"||g.name!=="ErrnoError")throw g;return-g.errno}}function ln(e,r,t,n){if(w)return K(8,0,1,e,r,t,n);X.varargs=n;try{r=X.getStr(r),r=X.calculateAt(e,r);var i=n?fr():0;return t&64&&(i&=~X.currentUmask),o.open(r,t,i).fd}catch(a){if(typeof o>"u"||a.name!=="ErrnoError")throw a;return-a.errno}}function cn(e,r,t,n){if(w)return K(9,0,1,e,r,t,n);try{if(r=X.getStr(r),r=X.calculateAt(e,r),n<=0)return-28;var i=o.readlink(r),a=Math.min(n,Pe(i)),s=(d(),H)[t+a];return Ee(i,t,n+1),(d(),H)[t+a]=s,a}catch(l){if(typeof o>"u"||l.name!=="ErrnoError")throw l;return-l.errno}}var dn=(e,r)=>(d(),Q).fill(0,e,e+r),un=(e,r,t,n,i)=>{switch(r){case 2:t=ur(t),dn(e,16),i&&((d(),S)[i>>2]=16),(d(),te)[e>>1]=r,(d(),S)[e+4>>2]=t,(d(),te)[e+2>>1]=Pr(n);break;case 10:t=Jr(t),dn(e,28),i&&((d(),S)[i>>2]=28),(d(),S)[e>>2]=r,(d(),S)[e+8>>2]=t[0],(d(),S)[e+12>>2]=t[1],(d(),S)[e+16>>2]=t[2],(d(),S)[e+20>>2]=t[3],(d(),te)[e+2>>1]=Pr(n);break;default:return 5}return 0};function fn(e,r,t,n,i,a){if(w)return K(10,0,1,e,r,t,n,i,a);try{var s=Xr(e),l=s.sock_ops.recvmsg(s,t);if(!l)return 0;if(i){var c=un(i,s.family,ve.lookup_name(l.addr),l.port,a);_(!c)}return(d(),Q).set(l.buffer,r),l.buffer.byteLength}catch(u){if(typeof o>"u"||u.name!=="ErrnoError")throw u;return-u.errno}}function _n(e){if(w)return K(11,0,1,e);try{return e=X.getStr(e),o.rmdir(e),0}catch(r){if(typeof o>"u"||r.name!=="ErrnoError")throw r;return-r.errno}}function vn(e,r,t,n,i,a){if(w)return K(12,0,1,e,r,t,n,i,a);try{var s=Xr(e);if(!i)return o.write(s.stream,(d(),H),r,t);var l=rn(i,a);return s.sock_ops.sendmsg(s,(d(),H),r,t,l.addr,l.port)}catch(c){if(typeof o>"u"||c.name!=="ErrnoError")throw c;return-c.errno}}function hn(e,r,t){if(w)return K(13,0,1,e,r,t);try{var n=T.createSocket(e,r,t);return _(n.stream.fd<64),n.stream.fd}catch(i){if(typeof o>"u"||i.name!=="ErrnoError")throw i;return-i.errno}}function pn(e,r,t){if(w)return K(14,0,1,e,r,t);try{if(r=X.getStr(r),r=X.calculateAt(e,r),!t)o.unlink(r);else if(t===512)o.rmdir(r);else return-28;return 0}catch(n){if(typeof o>"u"||n.name!=="ErrnoError")throw n;return-n.errno}}var Qi=()=>q("native code called abort()"),_r={},vr=e=>{for(;e.length;){var r=e.pop(),t=e.pop();t(r)}};function Ve(e){return this.fromWireType((d(),y)[e>>2])}var je={},Ce={},hr={},ea=class extends Error{constructor(r){super(r),this.name="InternalError"}},pr=e=>{throw new ea(e)},ce=(e,r,t)=>{e.forEach(l=>hr[l]=r);function n(l){var c=t(l);c.length!==e.length&&pr("Mismatched type converter count");for(var u=0;u<e.length;++u)ne(e[u],c[u])}var i=new Array(r.length),a=[],s=0;for(let[l,c]of r.entries())Ce.hasOwnProperty(c)?i[l]=Ce[c]:(a.push(c),je.hasOwnProperty(c)||(je[c]=[]),je[c].push(()=>{i[l]=Ce[c],++s,s===a.length&&n(i)}));a.length===0&&n(i)},ra=e=>{var r=_r[e];delete _r[e];var t=r.rawConstructor,n=r.rawDestructor,i=r.fields,a=i.map(s=>s.getterReturnType).concat(i.map(s=>s.setterArgumentType));ce([e],a,s=>{var l={};for(var[c,u]of i.entries()){let v=s[c],h=u.getter,p=u.getterContext,g=s[c+i.length],E=u.setter,k=u.setterContext;l[u.fieldName]={read:R=>v.fromWireType(h(p,R)),write:(R,D)=>{var z=[];E(k,R,g.toWireType(z,D)),vr(z)},optional:v.optional}}return[{name:r.name,fromWireType:v=>{var h={};for(var p in l)h[p]=l[p].read(v);return n(v),h},toWireType:(v,h)=>{for(var p in l)if(!(p in h)&&!l[p].optional)throw new TypeError(`Missing field: "${p}"`);var g=t();for(p in l)l[p].write(g,h[p]);return v!==null&&v.push(n,g),g},readValueFromPointer:Ve,destructorFunction:n}]})},Y=e=>{for(var r="";;){var t=(d(),Q)[e++];if(!t)return r;r+=String.fromCharCode(t)}},qe=class extends Error{constructor(r){super(r),this.name="BindingError"}},O=e=>{throw new qe(e)};function ta(e,r,t={}){var n=r.name;if(e||O(`type "${n}" must have a positive integer typeid pointer`),Ce.hasOwnProperty(e)){if(t.ignoreDuplicateRegistrations)return;O(`Cannot register type '${n}' twice`)}if(Ce[e]=r,delete hr[e],je.hasOwnProperty(e)){var i=je[e];delete je[e],i.forEach(a=>a())}}function ne(e,r,t={}){return ta(e,r,t)}var mn=(e,r,t)=>{switch(r){case 1:return t?n=>(d(),H)[n]:n=>(d(),Q)[n];case 2:return t?n=>(d(),te)[n>>1]:n=>(d(),ke)[n>>1];case 4:return t?n=>(d(),S)[n>>2]:n=>(d(),y)[n>>2];case 8:return t?n=>(d(),Z)[n>>3]:n=>(d(),Dt)[n>>3];default:throw new TypeError(`invalid integer width (${r}): ${e}`)}},Ae=e=>{if(e===null)return"null";var r=typeof e;return r==="object"||r==="array"||r==="function"?e.toString():""+e},gn=(e,r,t,n)=>{if(r<t||r>n)throw new TypeError(`Passing a number "${Ae(r)}" from JS side to C/C++ side to an argument of type "${e}", which is outside the valid range [${t}, ${n}]!`)},na=(e,r,t,n,i)=>{r=Y(r);let a=n===0n,s=l=>l;if(a){let l=t*8;s=c=>BigInt.asUintN(l,c),i=s(i)}ne(e,{name:r,fromWireType:s,toWireType:(l,c)=>{if(typeof c=="number")c=BigInt(c);else if(typeof c!="bigint")throw new TypeError(`Cannot convert "${Ae(c)}" to ${r}`);return gn(r,c,n,i),c},readValueFromPointer:mn(r,t,!a),destructorFunction:null})},ia=(e,r,t,n)=>{r=Y(r),ne(e,{name:r,fromWireType:function(i){return!!i},toWireType:function(i,a){return a?t:n},readValueFromPointer:function(i){return this.fromWireType((d(),Q)[i])},destructorFunction:null})},aa=e=>({count:e.count,deleteScheduled:e.deleteScheduled,preservePointerOnDelete:e.preservePointerOnDelete,ptr:e.ptr,ptrType:e.ptrType,smartPtr:e.smartPtr,smartPtrType:e.smartPtrType}),Zr=e=>{function r(t){return t.$$.ptrType.registeredClass.name}O(r(e)+" instance already deleted")},Qr=!1,yn=e=>{},oa=e=>{e.smartPtr?e.smartPtrType.rawDestructor(e.smartPtr):e.ptrType.registeredClass.rawDestructor(e.ptr)},wn=e=>{e.count.value-=1;var r=e.count.value===0;r&&oa(e)},En=(e,r,t)=>{if(r===t)return e;if(t.baseClass===void 0)return null;var n=En(e,r,t.baseClass);return n===null?null:t.downcast(n)},bn={},sa={},la=(e,r)=>{for(r===void 0&&O("ptr should not be undefined");e.baseClass;)r=e.upcast(r),e=e.baseClass;return r},ca=(e,r)=>(r=la(e,r),sa[r]),mr=(e,r)=>{(!r.ptrType||!r.ptr)&&pr("makeClassHandle requires ptr and ptrType");var t=!!r.smartPtrType,n=!!r.smartPtr;return t!==n&&pr("Both smartPtrType and smartPtr must be specified"),r.count={value:1},Ke(Object.create(e,{$$:{value:r,writable:!0}}))};function Sn(e){var r=this.getPointee(e);if(!r)return this.destructor(e),null;var t=ca(this.registeredClass,r);if(t!==void 0){if(t.$$.count.value===0)return t.$$.ptr=r,t.$$.smartPtr=e,t.clone();var n=t.clone();return this.destructor(e),n}function i(){return this.isSmartPointer?mr(this.registeredClass.instancePrototype,{ptrType:this.pointeeType,ptr:r,smartPtrType:this,smartPtr:e}):mr(this.registeredClass.instancePrototype,{ptrType:this,ptr:e})}var a=this.registeredClass.getActualType(r),s=bn[a];if(!s)return i.call(this);var l;this.isConst?l=s.constPointerType:l=s.pointerType;var c=En(r,this.registeredClass,l.registeredClass);return c===null?i.call(this):this.isSmartPointer?mr(l.registeredClass.instancePrototype,{ptrType:l,ptr:c,smartPtrType:this,smartPtr:e}):mr(l.registeredClass.instancePrototype,{ptrType:l,ptr:c})}var Ke=e=>globalThis.FinalizationRegistry?(Qr=new FinalizationRegistry(r=>{console.warn(r.leakWarning),wn(r.$$)}),Ke=r=>{var t=r.$$,n=!!t.smartPtr;if(n){var i={$$:t},a=t.ptrType.registeredClass,s=new Error(`Embind found a leaked C++ instance ${a.name} <${we(t.ptr)}>.
|
|
1
|
+
async function si(ee={}){var v;(function(){function e(d){d=d.split("-")[0];for(var u=d.split(".").slice(0,3);u.length<3;)u.push("00");return u=u.map((_,p,m)=>_.padStart(2,"0")),u.join("")}var r=d=>[d/1e4|0,(d/100|0)%100,d%100].join("."),t=2147483647,n=typeof process<"u"&&process.versions?.node?e(process.versions.node):t;if(n<180300)throw new Error(`This emscripten-generated code requires node v${r(180300)} (detected v${r(n)})`);var i=typeof navigator<"u"&&navigator.userAgent;if(i){var a=i.includes("Safari/")&&!i.includes("Chrome/")&&i.match(/Version\/(\d+\.?\d*\.?\d*)/)?e(i.match(/Version\/(\d+\.?\d*\.?\d*)/)[1]):t;if(a<15e4)throw new Error(`This emscripten-generated code requires Safari v${r(15e4)} (detected v${a})`);var s=i.match(/Firefox\/(\d+(?:\.\d+)?)/)?parseFloat(i.match(/Firefox\/(\d+(?:\.\d+)?)/)[1]):t;if(s<114)throw new Error(`This emscripten-generated code requires Firefox v114 (detected v${s})`);var l=i.match(/Chrome\/(\d+(?:\.\d+)?)/)?parseFloat(i.match(/Chrome\/(\d+(?:\.\d+)?)/)[1]):t;if(l<85)throw new Error(`This emscripten-generated code requires Chrome v85 (detected v${l})`)}})();var f=ee,O=!!globalThis.window,N=!!globalThis.WorkerGlobalScope,M=globalThis.process?.versions?.node&&globalThis.process?.type!="renderer",me=!O&&!M&&!N,w=N&&globalThis.name?.startsWith("em-pthread");if(w&&(h(!globalThis.moduleLoaded,"module should only be loaded once on each pthread worker"),globalThis.moduleLoaded=!0),M){let{createRequire:e}=await import("node:module");var le=e(import.meta.url),er=le("node:worker_threads");globalThis.Worker=er.Worker,N=!er.isMainThread,w=N&&er.workerData=="em-pthread"}var mt=[],Cr="./this.program",Ar=(e,r)=>{throw r},Or=import.meta.url,rr="";function pi(e){return f.locateFile?f.locateFile(e,rr):rr+e}var tr,Be;if(M){if(!(globalThis.process?.versions?.node&&globalThis.process?.type!="renderer"))throw new Error("not compiled for this environment (did you build to HTML and try to run it not on the web, or set ENVIRONMENT to something - like node - and run it someplace else - like on the web?)");var x=le("node:fs");Or.startsWith("file:")&&(rr=le("node:path").dirname(le("node:url").fileURLToPath(Or))+"/"),Be=r=>{r=nr(r)?new URL(r):r;var t=x.readFileSync(r);return h(Buffer.isBuffer(t)),t},tr=async(r,t=!0)=>{r=nr(r)?new URL(r):r;var n=x.readFileSync(r,t?void 0:"utf8");return h(t?Buffer.isBuffer(n):typeof n=="string"),n},process.argv.length>1&&(Cr=process.argv[1].replace(/\\/g,"/")),mt=process.argv.slice(2),Ar=(r,t)=>{throw process.exitCode=r,t}}else if(!me)if(O||N){try{rr=new URL(".",Or).href}catch{}if(!(globalThis.window||globalThis.WorkerGlobalScope))throw new Error("not compiled for this environment (did you build to HTML and try to run it not on the web, or set ENVIRONMENT to something - like node - and run it someplace else - like on the web?)");M||(N&&(Be=e=>{var r=new XMLHttpRequest;return r.open("GET",e,!1),r.responseType="arraybuffer",r.send(null),new Uint8Array(r.response)}),tr=async e=>{h(!nr(e),"readAsync does not work with file:// URLs");var r=await fetch(e,{credentials:"same-origin"});if(r.ok)return r.arrayBuffer();throw new Error(r.status+" : "+r.url)})}else throw new Error("environment detection error");var gt=console.log.bind(console),yt=console.error.bind(console);if(M){var mi=le("node:util"),wt=e=>typeof e=="object"?mi.inspect(e):e;gt=(...e)=>x.writeSync(1,e.map(wt).join(" ")+`
|
|
2
|
+
`),yt=(...e)=>x.writeSync(2,e.map(wt).join(" ")+`
|
|
3
|
+
`)}var ge=gt,C=yt,$s="IDBFS is no longer included by default; build with -lidbfs.js",Ns="PROXYFS is no longer included by default; build with -lproxyfs.js",Ms="WORKERFS is no longer included by default; build with -lworkerfs.js",xs="FETCHFS is no longer included by default; build with -lfetchfs.js",Ls="ICASEFS is no longer included by default; build with -licasefs.js",Ws="JSFILEFS is no longer included by default; build with -ljsfilefs.js",Us="OPFS is no longer included by default; build with -lopfs.js";h(O||N||M,"pthreads do not work in this environment yet (need Web Workers, or an alternative to them)"),h(!me,"shell environment detected but not enabled at build time (add `shell` to `-sENVIRONMENT` to enable)");var He;globalThis.WebAssembly||C("no native wasm support detected");var be,Ie=!1,$e;function h(e,r){e||q("Assertion failed"+(r?": "+r:""))}var nr=e=>e.startsWith("file://");function Et(){var e=lt();h((e&3)==0),e==0&&(e+=4),(c(),y)[e>>2]=34821223,(c(),y)[e+4>>2]=2310721022,(c(),y)[0]=1668509029}function Ge(){if(!Ie){var e=lt();e==0&&(e+=4);var r=(c(),y)[e>>2],t=(c(),y)[e+4>>2];(r!=34821223||t!=2310721022)&&q(`Stack overflow! Stack cookie has been overwritten at ${we(e)}, expected hex dwords 0x89BACDFE and 0x2135467, but received ${we(t)} ${we(r)}`),(c(),y)[0]!=1668509029&&q("Runtime error: The application has corrupted its heap memory area (address zero)!")}}class j{}class js extends j{}var bt=!0;function Dr(...e){if(!(!bt&&typeof bt<"u"))if(M){let n=function(i){switch(typeof i){case"object":return t.inspect(i);case"undefined":return"undefined"}return i};var r=le("node:fs"),t=le("node:util");r.writeSync(2,e.map(n).join(" ")+`
|
|
4
|
+
`)}else console.warn(...e)}(()=>{var e=new Int16Array(1),r=new Int8Array(e.buffer);e[0]=25459,(r[0]!==115||r[1]!==99)&&q("Runtime error: expected the system to be little-endian! (Run with -sSUPPORT_BIG_ENDIAN to bypass)")})();function ir(e){Object.getOwnPropertyDescriptor(f,e)||Object.defineProperty(f,e,{configurable:!0,set(){q(`Attempt to set \`Module.${e}\` after it has already been processed. This can happen, for example, when code is injected via '--post-js' rather than '--pre-js'`)}})}function $(e){return()=>h(!1,`call to '${e}' via reference taken before Wasm module initialization`)}function Se(e){Object.getOwnPropertyDescriptor(f,e)&&q(`\`Module.${e}\` was supplied but \`${e}\` not included in INCOMING_MODULE_JS_API`)}function gi(e){return e==="FS_createPath"||e==="FS_createDataFile"||e==="FS_createPreloadedFile"||e==="FS_preloadFile"||e==="FS_unlink"||e==="addRunDependency"||e==="FS_createLazyFile"||e==="FS_createDevice"||e==="removeRunDependency"}function yi(e){St(e)}function St(e){w||Object.getOwnPropertyDescriptor(f,e)||Object.defineProperty(f,e,{configurable:!0,get(){var r=`'${e}' was not exported. add it to EXPORTED_RUNTIME_METHODS (see the Emscripten FAQ)`;gi(e)&&(r+=". Alternatively, forcing filesystem support (-sFORCE_FILESYSTEM) can export this for you"),q(r)}})}function wi(){function e(){var t=0;return Ne&&typeof De<"u"&&(t=De()),`w:${Tt},t:${we(t)}:`}var r=Dr;Dr=(...t)=>r(e(),...t)}wi();function c(){fe.buffer!=H.buffer&&ar()}var Rr,Ir;if(M&&w){globalThis.self=globalThis;var kt=er.parentPort;globalThis.postMessage||(kt.on("message",e=>globalThis.onmessage?.({data:e})),globalThis.postMessage=e=>kt.postMessage(e)),process.on("uncaughtException",e=>{postMessage({cmd:"uncaughtException",error:e}),process.exit(1)})}var Tt=0,Ft;if(w){let e=function(r){try{var t=r.data,n=t.cmd;if(n==="load"){Tt=t.workerID;let i=[];self.onmessage=a=>i.push(a),Ft=()=>{postMessage({cmd:"loaded"});for(let a of i)e(a);self.onmessage=e};for(let a of t.handlers)(!f[a]||f[a].proxy)&&(f[a]=(...s)=>{postMessage({cmd:"callHandler",handler:a,args:s})},a=="print"&&(ge=f[a]),a=="printErr"&&(C=f[a]));fe=t.wasmMemory,ar(),be=t.wasmModule,At(),Pr()}else if(n==="run"){h(t.pthread_ptr),Ri(t.pthread_ptr),ot(t.pthread_ptr,0,0,1,0,0),P.threadInitTLS(),nt(t.pthread_ptr),$r||(Vn(),$r=!0);try{Ii(t.start_routine,t.arg)}catch(i){if(i!="unwind")throw i}}else t.target==="setimmediate"||(n==="checkMailbox"?$r&&kr():n&&(C(`worker: received unknown command ${n}`),C(t)))}catch(i){throw C(`worker: onmessage() captured an uncaught exception: ${i}`),i?.stack&&C(i.stack),Xn(),i}};var $r=!1;self.onunhandledrejection=r=>{throw r.reason||r},self.onmessage=e}var Ne=!1;function ar(){var e=fe.buffer;H=new Int8Array(e),ne=new Int16Array(e),f.HEAPU8=te=new Uint8Array(e),ke=new Uint16Array(e),S=new Int32Array(e),y=new Uint32Array(e),or=new Float32Array(e),Me=new Float64Array(e),Z=new BigInt64Array(e),Dt=new BigUint64Array(e)}function Ei(){if(!w){if(f.wasmMemory)fe=f.wasmMemory;else{var e=f.INITIAL_MEMORY||16777216;h(e>=65536,`INITIAL_MEMORY should be larger than STACK_SIZE, was ${e}! (STACK_SIZE=65536)`),fe=new WebAssembly.Memory({initial:e/65536,maximum:32768,shared:!0})}ar()}}h(globalThis.Int32Array&&globalThis.Float64Array&&Int32Array.prototype.subarray&&Int32Array.prototype.set,"JS engine does not provide full typed array support");function bi(){if(h(!w),f.preRun)for(typeof f.preRun=="function"&&(f.preRun=[f.preRun]);f.preRun.length;)Mt(f.preRun.shift());ir("preRun"),$t(Nt)}function Pt(){if(h(!Ne),Ne=!0,w)return Ft();Ge(),T.root=o.mount(T,{},null),!f.noFSInit&&!o.initialized&&o.init(),pe.init(),Re.__wasm_call_ctors(),o.ignorePermissions=!1}function Si(){if(Ge(),!w){if(f.postRun)for(typeof f.postRun=="function"&&(f.postRun=[f.postRun]);f.postRun.length;)Di(f.postRun.shift());ir("postRun"),$t(jt)}}function q(e){f.onAbort?.(e),e=`Aborted(${e})`,C(e),Ie=!0;var r=new WebAssembly.RuntimeError(e);throw Ir?.(r),r}function J(e,r){return(...t)=>{h(Ne,`native function \`${e}\` called before runtime initialization`);var n=Re[e];return h(n,`exported native function \`${e}\` not found`),h(t.length<=r,`native function \`${e}\` called with ${t.length} args but expects ${r}`),n(...t)}}var Nr;function ki(){return f.locateFile?pi("libe57-js.wasm"):new URL("libe57-js.wasm",import.meta.url).href}function Ti(e){if(e==Nr&&He)return new Uint8Array(He);if(Be)return Be(e);throw"both async and sync fetching of the wasm failed"}async function Fi(e){if(!He)try{var r=await tr(e);return new Uint8Array(r)}catch{}return Ti(e)}async function Pi(e,r){try{var t=await Fi(e),n=await WebAssembly.instantiate(t,r);return n}catch(i){C(`failed to asynchronously prepare wasm: ${i}`),nr(e)&&C(`warning: Loading from a file URI (${e}) is not supported in most browsers. See https://emscripten.org/docs/getting_started/FAQ.html#how-do-i-run-a-local-webserver-for-testing-why-does-my-program-stall-in-downloading-or-preparing`),q(i)}}async function Ci(e,r,t){if(!e&&!M)try{var n=fetch(r,{credentials:"same-origin"}),i=await WebAssembly.instantiateStreaming(n,t);return i}catch(a){C(`wasm streaming compile failed: ${a}`),C("falling back to ArrayBuffer instantiation")}return Pi(r,t)}function Ct(){es();var e={env:_t,wasi_snapshot_preview1:_t};return e}async function At(){function e(l,d){return Re=l.exports,$i(Re._emscripten_tls_init),Qo(Re),be=d,Re}var r=f;function t(l){return h(f===r,"the Module object should not be replaced during async compilation - perhaps the order of HTML elements is wrong?"),r=null,e(l.instance,l.module)}var n=Ct();if(f.instantiateWasm)return new Promise((l,d)=>{try{f.instantiateWasm(n,(u,_)=>{l(e(u,_))})}catch(u){C(`Module.instantiateWasm callback failed with error: ${u}`),d(u)}});if(w){h(be,"wasmModule should have been received via postMessage");var i=new WebAssembly.Instance(be,Ct());return e(i,be)}Nr??=ki();var a=await Ci(He,Nr,n),s=t(a);return s}class Ot{name="ExitStatus";constructor(r){this.message=`Program terminated with exit(${r})`,this.status=r}}var ne,S,Z,H,or,Me,ke,y,Dt,te,Rt=e=>{e.terminate(),e.onmessage=r=>{var t=r.data.cmd;C(`received "${t}" command from terminated worker: ${e.workerID}`)}},It=e=>{h(!w,"cleanupThread() should only be called from the main thread"),h(e,"null pthread_ptr passed to cleanupThread");var r=P.pthreads[e];h(r),P.returnWorkerToPool(r)},$t=e=>{for(;e.length>0;)e.shift()(f)},Nt=[],Mt=e=>Nt.push(e),Te=0,ze=null,xe={},ye=null,Mr=e=>{if(Te--,f.monitorRunDependencies?.(Te),h(e,"removeRunDependency requires an ID"),h(xe[e]),delete xe[e],Te==0&&(ye!==null&&(clearInterval(ye),ye=null),ze)){var r=ze;ze=null,r()}},xr=e=>{Te++,f.monitorRunDependencies?.(Te),h(e,"addRunDependency requires an ID"),h(!xe[e]),xe[e]=1,ye===null&&globalThis.setInterval&&(ye=setInterval(()=>{if(Ie){clearInterval(ye),ye=null;return}var r=!1;for(var t in xe)r||(r=!0,C("still waiting on run dependencies:")),C(`dependency: ${t}`);r&&C("(end of list)")},1e4),ye.unref?.())},xt=e=>{h(!w,"spawnThread() should only be called from the main thread"),h(e.pthread_ptr,"spawnThread called with null pthread ptr");var r=P.getNewWorker();if(!r)return 6;h(!r.pthread_ptr),P.runningWorkers.push(r),P.pthreads[e.pthread_ptr]=r,r.pthread_ptr=e.pthread_ptr;var t={cmd:"run",start_routine:e.startRoutine,arg:e.arg,pthread_ptr:e.pthread_ptr};return M&&r.unref(),r.postMessage(t,e.transferList),0},sr=0,lr=()=>Wr||sr>0,B=()=>ut(),L=e=>ti(e),Ai=e=>ni(e),K=(e,r,t,...n)=>{var i=8*n.length*2,a=B(),s=Ai(i),l=s>>3;for(var d of n)typeof d=="bigint"?((c(),Z)[l++]=1n,(c(),Z)[l++]=d):((c(),Z)[l++]=0n,(c(),Me)[l++]=d);var u=Jn(e,r,i,s,t);return L(a),u};function Lt(e){if(w)return K(0,0,1,e);$e=e,lr()||(P.terminateAllThreads(),f.onExit?.(e),Ie=!0),Ar(e,new Ot(e))}function Wt(e){if(w)return K(1,0,0,e);Lr(e)}var Oi=(e,r)=>{if($e=e,Os(),w)throw h(!r),Wt(e),"unwind";if(lr()&&!r){var t=`program exited (with status: ${e}), but keepRuntimeAlive() is set (counter=${sr}) due to an async operation, so halting execution but not exiting the runtime or preventing further async execution (you can use emscripten_force_exit, if you want to force a true shutdown)`;Ir?.(t),C(t)}Lt(e)},Lr=Oi,Ut=!Atomics.waitAsync||globalThis.navigator?.userAgent&&Number((navigator.userAgent.match(/Chrom(e|ium)\/([0-9]+)\./)||[])[2])<91;function we(e){return h(typeof e=="number",`ptrToString expects a number, got ${typeof e}`),e>>>=0,"0x"+e.toString(16).padStart(8,"0")}var P={unusedWorkers:[],runningWorkers:[],tlsInitFunctions:[],pthreads:{},nextWorkerID:1,init(){w||P.initMainThread()},initMainThread(){for(var e=2;e--;)P.allocateUnusedWorker();Mt(async()=>{var r=P.loadWasmModuleToAllWorkers();xr("loading-workers"),await r,Mr("loading-workers")})},terminateAllThreads:()=>{h(!w,"terminateAllThreads() should only be called from the main thread");for(var e of P.runningWorkers)Rt(e);for(var e of P.unusedWorkers)Rt(e);P.unusedWorkers=[],P.runningWorkers=[],P.pthreads={}},terminateRuntime:()=>{h(!w,"terminateRuntime() should only be called from the main thread"),P.terminateAllThreads();var e=De();Kn(0,0,0,1),Ut||Atomics.notify((c(),S),e>>2)},returnWorkerToPool:e=>{var r=e.pthread_ptr;delete P.pthreads[r],P.unusedWorkers.push(e),P.runningWorkers.splice(P.runningWorkers.indexOf(e),1),e.pthread_ptr=0,Zn(r)},threadInitTLS(){P.tlsInitFunctions.forEach(e=>e())},loadWasmModuleToWorker:e=>new Promise(r=>{e.onmessage=a=>{var s=a.data,l=s.cmd;if(s.targetThread&&s.targetThread!=De()){var d=P.pthreads[s.targetThread];d?d.postMessage(s,s.transferList):C(`worker sent message (${l}) to pthread (${s.targetThread}) that no longer exists`);return}l==="checkMailbox"?kr():l==="spawnThread"?xt(s):l==="cleanupThread"?In(()=>It(s.thread)):l==="loaded"?(e.loaded=!0,M&&!e.pthread_ptr&&e.unref(),r(e)):s.target==="setimmediate"?e.postMessage(s):l==="uncaughtException"?e.onerror(s.error):l==="callHandler"?f[s.handler](...s.args):l&&C(`worker sent an unknown command ${l}`)},e.onerror=a=>{var s="worker sent an error!";throw e.pthread_ptr&&(s=`Pthread ${we(e.pthread_ptr)} sent an error!`),C(`${s} ${a.filename}:${a.lineno}: ${a.message}`),a},M&&(e.on("message",a=>e.onmessage({data:a})),e.on("error",a=>e.onerror(a))),h(fe instanceof WebAssembly.Memory,"wasmMemory should have been loaded by now"),h(be instanceof WebAssembly.Module,"wasmModule should have been loaded by now");var t=[],n=["onExit","onAbort","print","printErr"];for(var i of n)f.propertyIsEnumerable(i)&&t.push(i);e.postMessage({cmd:"load",handlers:t,wasmMemory:fe,wasmModule:be,workerID:e.workerID})}),async loadWasmModuleToAllWorkers(){return w?void 0:Promise.all(P.unusedWorkers.map(P.loadWasmModuleToWorker))},allocateUnusedWorker(){var e;if(f.mainScriptUrlOrBlob){var r=f.mainScriptUrlOrBlob;typeof r!="string"&&(r=URL.createObjectURL(r)),e=new Worker(r,{type:"module",workerData:"em-pthread",name:"em-pthread-"+P.nextWorkerID})}else e=new Worker(new URL("libe57-js.js",import.meta.url),{type:"module",workerData:"em-pthread",name:"em-pthread-"+P.nextWorkerID});e.workerID=P.nextWorkerID++,P.unusedWorkers.push(e)},getNewWorker(){return P.unusedWorkers.length==0&&(M||C("Tried to spawn a new thread, but the thread pool is exhausted.\nThis might result in a deadlock unless some threads eventually exit or the code explicitly breaks out to the event loop.\nIf you want to increase the pool size, use setting `-sPTHREAD_POOL_SIZE=...`.\nIf you want to throw an explicit error instead of the risk of deadlocking in those cases, use setting `-sPTHREAD_POOL_SIZE_STRICT=2`."),P.allocateUnusedWorker(),P.loadWasmModuleToWorker(P.unusedWorkers[0])),P.unusedWorkers.pop()}},jt=[],Di=e=>jt.push(e);function Ri(e){var r=(c(),y)[e+48>>2],t=(c(),y)[e+52>>2],n=r-t;h(r!=0),h(n!=0),h(r>n,"stackHigh must be higher then stackLow"),ri(r,n),L(r),Et()}function Bs(e,r="i8"){switch(r.endsWith("*")&&(r="*"),r){case"i1":return(c(),H)[e];case"i8":return(c(),H)[e];case"i16":return(c(),ne)[e>>1];case"i32":return(c(),S)[e>>2];case"i64":return(c(),Z)[e>>3];case"float":return(c(),or)[e>>2];case"double":return(c(),Me)[e>>3];case"*":return(c(),y)[e>>2];default:q(`invalid type for getValue: ${r}`)}}var Bt=[],W=e=>{var r=Bt[e];return r||(Bt[e]=r=ft.get(e)),h(ft.get(e)==r,"table mirror is out of date"),r},Ii=(e,r)=>{sr=0,Wr=0;var t=W(e)(r);Ge();function n(i){if(lr()){$e=i;return}ct(i)}n(t)},Wr=!0,$i=e=>P.tlsInitFunctions.push(e);function Hs(e,r,t="i8"){switch(t.endsWith("*")&&(t="*"),t){case"i1":(c(),H)[e]=r;break;case"i8":(c(),H)[e]=r;break;case"i16":(c(),ne)[e>>1]=r;break;case"i32":(c(),S)[e>>2]=r;break;case"i64":(c(),Z)[e>>3]=BigInt(r);break;case"float":(c(),or)[e>>2]=r;break;case"double":(c(),Me)[e>>3]=r;break;case"*":(c(),y)[e>>2]=r;break;default:q(`invalid type for setValue: ${t}`)}}var Fe=e=>{Fe.shown||={},Fe.shown[e]||(Fe.shown[e]=1,M&&(e="warning: "+e),C(e))},fe,Ht=globalThis.TextDecoder&&new TextDecoder,Gt=(e,r,t,n)=>{var i=r+t;if(n)return i;for(;e[r]&&!(r>=i);)++r;return r},Le=(e,r=0,t,n)=>{var i=Gt(e,r,t,n);if(i-r>16&&e.buffer&&Ht)return Ht.decode(e.buffer instanceof ArrayBuffer?e.subarray(r,i):e.slice(r,i));for(var a="";r<i;){var s=e[r++];if(!(s&128)){a+=String.fromCharCode(s);continue}var l=e[r++]&63;if((s&224)==192){a+=String.fromCharCode((s&31)<<6|l);continue}var d=e[r++]&63;if((s&240)==224?s=(s&15)<<12|l<<6|d:((s&248)!=240&&Fe(`Invalid UTF-8 leading byte ${we(s)} encountered when deserializing a UTF-8 string in wasm memory to a JS string!`),s=(s&7)<<18|l<<12|d<<6|e[r++]&63),s<65536)a+=String.fromCharCode(s);else{var u=s-65536;a+=String.fromCharCode(55296|u>>10,56320|u&1023)}}return a},_e=(e,r,t)=>(h(typeof e=="number",`UTF8ToString expects a number (got ${typeof e})`),e?Le((c(),te),e,r,t):""),Ni=(e,r,t,n)=>q(`Assertion failed: ${_e(e)}, at: `+[r?_e(r):"unknown filename",t,n?_e(n):"unknown function"]),Ur=[],zt=0,Mi=e=>{var r=new Vt(e);return r.get_caught()||(r.set_caught(!0),zt--),r.set_rethrown(!1),Ur.push(r),ai(e)},xi=()=>{U(0,0),h(Ur.length>0);var e=Ur.pop();ii(e.excPtr)},jr=e=>(setTempRet0(0),0),Li=()=>jr([]),Wi=e=>jr([e]),Ui=(e,r)=>jr([e,r]);class Vt{constructor(r){this.excPtr=r,this.ptr=r-24}set_type(r){(c(),y)[this.ptr+4>>2]=r}get_type(){return(c(),y)[this.ptr+4>>2]}set_destructor(r){(c(),y)[this.ptr+8>>2]=r}get_destructor(){return(c(),y)[this.ptr+8>>2]}set_caught(r){r=r?1:0,(c(),H)[this.ptr+12]=r}get_caught(){return(c(),H)[this.ptr+12]!=0}set_rethrown(r){r=r?1:0,(c(),H)[this.ptr+13]=r}get_rethrown(){return(c(),H)[this.ptr+13]!=0}init(r,t){this.set_adjusted_ptr(0),this.set_type(r),this.set_destructor(t)}set_adjusted_ptr(r){(c(),y)[this.ptr+16>>2]=r}get_adjusted_ptr(){return(c(),y)[this.ptr+16>>2]}}var ji=(e,r,t)=>{var n=new Vt(e);n.init(r,t),zt++,h(!1,"Exception thrown, but exception catching is not enabled. Compile with -sNO_DISABLE_EXCEPTION_CATCHING or -sEXCEPTION_CATCHING_ALLOWED=[..] to catch.")};function qt(e,r,t,n){return w?K(2,0,1,e,r,t,n):Kt(e,r,t,n)}var Bi=()=>!!globalThis.SharedArrayBuffer,Kt=(e,r,t,n)=>{if(!Bi())return Dr("pthread_create: environment does not support SharedArrayBuffer, pthreads are not available"),6;var i=[],a=0;if(w&&(i.length===0||a))return qt(e,r,t,n);if(a)return a;var s={startRoutine:t,pthread_ptr:e,arg:n,transferList:i};return w?(s.cmd="spawnThread",postMessage(s,i),0):xt(s)},Hi=e=>{h(!1,"Exception thrown, but exception catching is not enabled. Compile with -sNO_DISABLE_EXCEPTION_CATCHING or -sEXCEPTION_CATCHING_ALLOWED=[..] to catch.")},Gi=()=>{if(M){var e=le("node:crypto");return r=>e.randomFillSync(r)}return r=>(r.set(crypto.getRandomValues(new Uint8Array(r.byteLength))),0)},Br=e=>(Br=Gi())(e),I={isAbs:e=>e.charAt(0)==="/",splitPath:e=>{var r=/^(\/?|)([\s\S]*?)((?:\.{1,2}|[^\/]+?|)(\.[^.\/]*|))(?:[\/]*)$/;return r.exec(e).slice(1)},normalizeArray:(e,r)=>{for(var t=0,n=e.length-1;n>=0;n--){var i=e[n];i==="."?e.splice(n,1):i===".."?(e.splice(n,1),t++):t&&(e.splice(n,1),t--)}if(r)for(;t;t--)e.unshift("..");return e},normalize:e=>{var r=I.isAbs(e),t=e.slice(-1)==="/";return e=I.normalizeArray(e.split("/").filter(n=>!!n),!r).join("/"),!e&&!r&&(e="."),e&&t&&(e+="/"),(r?"/":"")+e},dirname:e=>{var r=I.splitPath(e),t=r[0],n=r[1];return!t&&!n?".":(n&&(n=n.slice(0,-1)),t+n)},basename:e=>e&&e.match(/([^\/]+|\/)\/*$/)[1],join:(...e)=>I.normalize(e.join("/")),join2:(e,r)=>I.normalize(e+"/"+r)},We={resolve:(...e)=>{for(var r="",t=!1,n=e.length-1;n>=-1&&!t;n--){var i=n>=0?e[n]:o.cwd();if(typeof i!="string")throw new TypeError("Arguments to path.resolve must be strings");if(!i)return"";r=i+"/"+r,t=I.isAbs(i)}return r=I.normalizeArray(r.split("/").filter(a=>!!a),!t).join("/"),(t?"/":"")+r||"."},relative:(e,r)=>{e=We.resolve(e).slice(1),r=We.resolve(r).slice(1);function t(u){for(var _=0;_<u.length&&u[_]==="";_++);for(var p=u.length-1;p>=0&&u[p]==="";p--);return _>p?[]:u.slice(_,p-_+1)}for(var n=t(e.split("/")),i=t(r.split("/")),a=Math.min(n.length,i.length),s=a,l=0;l<a;l++)if(n[l]!==i[l]){s=l;break}for(var d=[],l=s;l<n.length;l++)d.push("..");return d=d.concat(i.slice(s)),d.join("/")}},Hr=[],Pe=e=>{for(var r=0,t=0;t<e.length;++t){var n=e.charCodeAt(t);n<=127?r++:n<=2047?r+=2:n>=55296&&n<=57343?(r+=4,++t):r+=3}return r},Xt=(e,r,t,n)=>{if(h(typeof e=="string",`stringToUTF8Array expects a string (got ${typeof e})`),!(n>0))return 0;for(var i=t,a=t+n-1,s=0;s<e.length;++s){var l=e.codePointAt(s);if(l<=127){if(t>=a)break;r[t++]=l}else if(l<=2047){if(t+1>=a)break;r[t++]=192|l>>6,r[t++]=128|l&63}else if(l<=65535){if(t+2>=a)break;r[t++]=224|l>>12,r[t++]=128|l>>6&63,r[t++]=128|l&63}else{if(t+3>=a)break;l>1114111&&Fe(`Invalid Unicode code point ${we(l)} encountered when serializing a JS string to a UTF-8 string in wasm memory! (Valid unicode code points should be in range 0-0x10FFFF).`),r[t++]=240|l>>18,r[t++]=128|l>>12&63,r[t++]=128|l>>6&63,r[t++]=128|l&63,s++}}return r[t]=0,t-i},Gr=(e,r,t)=>{var n=t>0?t:Pe(e)+1,i=new Array(n),a=Xt(e,i,0,i.length);return r&&(i.length=a),i},zi=()=>{if(!Hr.length){var e=null;if(M){var r=256,t=Buffer.alloc(r),n=0,i=process.stdin.fd;try{n=x.readSync(i,t,0,r)}catch(a){if(a.toString().includes("EOF"))n=0;else throw a}n>0&&(e=t.slice(0,n).toString("utf-8"))}else globalThis.window?.prompt&&(e=window.prompt("Input: "),e!==null&&(e+=`
|
|
5
|
+
`));if(!e)return null;Hr=Gr(e,!0)}return Hr.shift()},pe={ttys:[],init(){},shutdown(){},register(e,r){pe.ttys[e]={input:[],output:[],ops:r},o.registerDevice(e,pe.stream_ops)},stream_ops:{open(e){var r=pe.ttys[e.node.rdev];if(!r)throw new o.ErrnoError(43);e.tty=r,e.seekable=!1},close(e){e.tty.ops.fsync(e.tty)},fsync(e){e.tty.ops.fsync(e.tty)},read(e,r,t,n,i){if(!e.tty||!e.tty.ops.get_char)throw new o.ErrnoError(60);for(var a=0,s=0;s<n;s++){var l;try{l=e.tty.ops.get_char(e.tty)}catch{throw new o.ErrnoError(29)}if(l===void 0&&a===0)throw new o.ErrnoError(6);if(l==null)break;a++,r[t+s]=l}return a&&(e.node.atime=Date.now()),a},write(e,r,t,n,i){if(!e.tty||!e.tty.ops.put_char)throw new o.ErrnoError(60);try{for(var a=0;a<n;a++)e.tty.ops.put_char(e.tty,r[t+a])}catch{throw new o.ErrnoError(29)}return n&&(e.node.mtime=e.node.ctime=Date.now()),a}},default_tty_ops:{get_char(e){return zi()},put_char(e,r){r===null||r===10?(ge(Le(e.output)),e.output=[]):r!=0&&e.output.push(r)},fsync(e){e.output?.length>0&&(ge(Le(e.output)),e.output=[])},ioctl_tcgets(e){return{c_iflag:25856,c_oflag:5,c_cflag:191,c_lflag:35387,c_cc:[3,28,127,21,4,0,1,0,17,19,26,0,18,15,23,22,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]}},ioctl_tcsets(e,r,t){return 0},ioctl_tiocgwinsz(e){return[24,80]}},default_tty1_ops:{put_char(e,r){r===null||r===10?(C(Le(e.output)),e.output=[]):r!=0&&e.output.push(r)},fsync(e){e.output?.length>0&&(C(Le(e.output)),e.output=[])}}},zr=e=>{q("internal error: mmapAlloc called but `emscripten_builtin_memalign` native symbol not exported")},F={ops_table:null,mount(e){return F.createNode(null,"/",16895,0)},createNode(e,r,t,n){if(o.isBlkdev(t)||o.isFIFO(t))throw new o.ErrnoError(63);F.ops_table||={dir:{node:{getattr:F.node_ops.getattr,setattr:F.node_ops.setattr,lookup:F.node_ops.lookup,mknod:F.node_ops.mknod,rename:F.node_ops.rename,unlink:F.node_ops.unlink,rmdir:F.node_ops.rmdir,readdir:F.node_ops.readdir,symlink:F.node_ops.symlink},stream:{llseek:F.stream_ops.llseek}},file:{node:{getattr:F.node_ops.getattr,setattr:F.node_ops.setattr},stream:{llseek:F.stream_ops.llseek,read:F.stream_ops.read,write:F.stream_ops.write,mmap:F.stream_ops.mmap,msync:F.stream_ops.msync}},link:{node:{getattr:F.node_ops.getattr,setattr:F.node_ops.setattr,readlink:F.node_ops.readlink},stream:{}},chrdev:{node:{getattr:F.node_ops.getattr,setattr:F.node_ops.setattr},stream:o.chrdev_stream_ops}};var i=o.createNode(e,r,t,n);return o.isDir(i.mode)?(i.node_ops=F.ops_table.dir.node,i.stream_ops=F.ops_table.dir.stream,i.contents={}):o.isFile(i.mode)?(i.node_ops=F.ops_table.file.node,i.stream_ops=F.ops_table.file.stream,i.usedBytes=0,i.contents=F.emptyFileContents??=new Uint8Array(0)):o.isLink(i.mode)?(i.node_ops=F.ops_table.link.node,i.stream_ops=F.ops_table.link.stream):o.isChrdev(i.mode)&&(i.node_ops=F.ops_table.chrdev.node,i.stream_ops=F.ops_table.chrdev.stream),i.atime=i.mtime=i.ctime=Date.now(),e&&(e.contents[r]=i,e.atime=e.mtime=e.ctime=i.atime),i},getFileDataAsTypedArray(e){return h(o.isFile(e.mode),"getFileDataAsTypedArray called on non-file"),e.contents.subarray(0,e.usedBytes)},expandFileStorage(e,r){var t=e.contents.length;if(!(t>=r)){var n=1024*1024;r=Math.max(r,t*(t<n?2:1.125)>>>0),t&&(r=Math.max(r,256));var i=F.getFileDataAsTypedArray(e);e.contents=new Uint8Array(r),e.contents.set(i)}},resizeFileStorage(e,r){if(e.usedBytes!=r){var t=e.contents;e.contents=new Uint8Array(r),e.contents.set(t.subarray(0,Math.min(r,e.usedBytes))),e.usedBytes=r}},node_ops:{getattr(e){var r={};return r.dev=o.isChrdev(e.mode)?e.id:1,r.ino=e.id,r.mode=e.mode,r.nlink=1,r.uid=0,r.gid=0,r.rdev=e.rdev,o.isDir(e.mode)?r.size=4096:o.isFile(e.mode)?r.size=e.usedBytes:o.isLink(e.mode)?r.size=e.link.length:r.size=0,r.atime=new Date(e.atime),r.mtime=new Date(e.mtime),r.ctime=new Date(e.ctime),r.blksize=4096,r.blocks=Math.ceil(r.size/r.blksize),r},setattr(e,r){for(let t of["mode","atime","mtime","ctime"])r[t]!=null&&(e[t]=r[t]);r.size!==void 0&&F.resizeFileStorage(e,r.size)},lookup(e,r){throw new o.ErrnoError(44)},mknod(e,r,t,n){return F.createNode(e,r,t,n)},rename(e,r,t){var n;try{n=o.lookupNode(r,t)}catch{}if(n){if(o.isDir(e.mode))for(var i in n.contents)throw new o.ErrnoError(55);o.hashRemoveNode(n)}delete e.parent.contents[e.name],r.contents[t]=e,e.name=t,r.ctime=r.mtime=e.parent.ctime=e.parent.mtime=Date.now()},unlink(e,r){delete e.contents[r],e.ctime=e.mtime=Date.now()},rmdir(e,r){var t=o.lookupNode(e,r);for(var n in t.contents)throw new o.ErrnoError(55);delete e.contents[r],e.ctime=e.mtime=Date.now()},readdir(e){return[".","..",...Object.keys(e.contents)]},symlink(e,r,t){var n=F.createNode(e,r,41471,0);return n.link=t,n},readlink(e){if(!o.isLink(e.mode))throw new o.ErrnoError(28);return e.link}},stream_ops:{read(e,r,t,n,i){var a=e.node.contents;if(i>=e.node.usedBytes)return 0;var s=Math.min(e.node.usedBytes-i,n);return h(s>=0),r.set(a.subarray(i,i+s),t),s},write(e,r,t,n,i,a){if(h(r.subarray,"FS.write expects a TypedArray"),r.buffer===(c(),H).buffer&&(a=!1),!n)return 0;var s=e.node;return s.mtime=s.ctime=Date.now(),a?(h(i===0,"canOwn must imply no weird position inside the file"),s.contents=r.subarray(t,t+n),s.usedBytes=n):s.usedBytes===0&&i===0?(s.contents=r.slice(t,t+n),s.usedBytes=n):(F.expandFileStorage(s,i+n),s.contents.set(r.subarray(t,t+n),i),s.usedBytes=Math.max(s.usedBytes,i+n)),n},llseek(e,r,t){var n=r;if(t===1?n+=e.position:t===2&&o.isFile(e.node.mode)&&(n+=e.node.usedBytes),n<0)throw new o.ErrnoError(28);return n},mmap(e,r,t,n,i){if(!o.isFile(e.node.mode))throw new o.ErrnoError(43);var a,s,l=e.node.contents;if(!(i&2)&&l.buffer===(c(),H).buffer)s=!1,a=l.byteOffset;else{if(s=!0,a=zr(r),!a)throw new o.ErrnoError(48);l&&((t>0||t+r<l.length)&&(l.subarray?l=l.subarray(t,t+r):l=Array.prototype.slice.call(l,t,t+r)),(c(),H).set(l,a))}return{ptr:a,allocated:s}},msync(e,r,t,n,i){return F.stream_ops.write(e,r,0,n,t,!1),0}}},Vi=e=>{if(typeof e!="string")return e;var r={r:0,"r+":2,w:577,"w+":578,a:1089,"a+":1090},t=r[e];if(typeof t>"u")throw new Error(`Unknown file open mode: ${e}`);return t},Yt=e=>(typeof e=="string"&&(e=Gr(e,!0)),e.subarray||(e=new Uint8Array(e)),e),Vr=(e,r)=>{var t=0;return e&&(t|=365),r&&(t|=146),t},dr={EPERM:63,ENOENT:44,ESRCH:71,EINTR:27,EIO:29,ENXIO:60,E2BIG:1,ENOEXEC:45,EBADF:8,ECHILD:12,EAGAIN:6,EWOULDBLOCK:6,ENOMEM:48,EACCES:2,EFAULT:21,ENOTBLK:105,EBUSY:10,EEXIST:20,EXDEV:75,ENODEV:43,ENOTDIR:54,EISDIR:31,EINVAL:28,ENFILE:41,EMFILE:33,ENOTTY:59,ETXTBSY:74,EFBIG:22,ENOSPC:51,ESPIPE:70,EROFS:69,EMLINK:34,EPIPE:64,EDOM:18,ERANGE:68,ENOMSG:49,EIDRM:24,ECHRNG:106,EL2NSYNC:156,EL3HLT:107,EL3RST:108,ELNRNG:109,EUNATCH:110,ENOCSI:111,EL2HLT:112,EDEADLK:16,ENOLCK:46,EBADE:113,EBADR:114,EXFULL:115,ENOANO:104,EBADRQC:103,EBADSLT:102,EDEADLOCK:16,EBFONT:101,ENOSTR:100,ENODATA:116,ETIME:117,ENOSR:118,ENONET:119,ENOPKG:120,EREMOTE:121,ENOLINK:47,EADV:122,ESRMNT:123,ECOMM:124,EPROTO:65,EMULTIHOP:36,EDOTDOT:125,EBADMSG:9,ENOTUNIQ:126,EBADFD:127,EREMCHG:128,ELIBACC:129,ELIBBAD:130,ELIBSCN:131,ELIBMAX:132,ELIBEXEC:133,ENOSYS:52,ENOTEMPTY:55,ENAMETOOLONG:37,ELOOP:32,EOPNOTSUPP:138,EPFNOSUPPORT:139,ECONNRESET:15,ENOBUFS:42,EAFNOSUPPORT:5,EPROTOTYPE:67,ENOTSOCK:57,ENOPROTOOPT:50,ESHUTDOWN:140,ECONNREFUSED:14,EADDRINUSE:3,ECONNABORTED:13,ENETUNREACH:40,ENETDOWN:38,ETIMEDOUT:73,EHOSTDOWN:142,EHOSTUNREACH:23,EINPROGRESS:26,EALREADY:7,EDESTADDRREQ:17,EMSGSIZE:35,EPROTONOSUPPORT:66,ESOCKTNOSUPPORT:137,EADDRNOTAVAIL:4,ENETRESET:39,EISCONN:30,ENOTCONN:53,ETOOMANYREFS:141,EUSERS:136,EDQUOT:19,ESTALE:72,ENOTSUP:138,ENOMEDIUM:148,EILSEQ:25,EOVERFLOW:61,ECANCELED:11,ENOTRECOVERABLE:56,EOWNERDEAD:62,ESTRPIPE:135},b={isWindows:!1,staticInit(){b.isWindows=!!process.platform.match(/^win/);var e=process.binding("constants").fs;b.flagsForNodeMap={1024:e.O_APPEND,64:e.O_CREAT,128:e.O_EXCL,256:e.O_NOCTTY,0:e.O_RDONLY,2:e.O_RDWR,4096:e.O_SYNC,512:e.O_TRUNC,1:e.O_WRONLY,131072:e.O_NOFOLLOW},h(b.flagsForNodeMap[0]===0)},convertNodeCode(e){var r=e.code;return h(r in dr,`unexpected node error code: ${r} (${e})`),dr[r]},tryFSOperation(e){try{return e()}catch(r){throw r.code?r.code==="UNKNOWN"?new o.ErrnoError(28):new o.ErrnoError(b.convertNodeCode(r)):r}},mount(e){return h(M),b.createNode(null,"/",b.getMode(e.opts.root),0)},createNode(e,r,t,n){if(!o.isDir(t)&&!o.isFile(t)&&!o.isLink(t))throw new o.ErrnoError(28);var i=o.createNode(e,r,t);return i.node_ops=b.node_ops,i.stream_ops=b.stream_ops,i},getMode(e){return b.tryFSOperation(()=>{var r=x.lstatSync(e).mode;return b.isWindows&&(r|=(r&292)>>2),r})},realPath(e){for(var r=[];e.parent!==e;)r.push(e.name),e=e.parent;return r.push(e.mount.opts.root),r.reverse(),I.join(...r)},flagsForNode(e){e&=-2097153,e&=-2049,e&=-32769,e&=-524289,e&=-65537;var r=0;for(var t in b.flagsForNodeMap)e&t&&(r|=b.flagsForNodeMap[t],e^=t);if(e)throw new o.ErrnoError(28);return r},getattr(e,r){var t=b.tryFSOperation(e);return b.isWindows&&(t.blksize||(t.blksize=4096),t.blocks||(t.blocks=(t.size+t.blksize-1)/t.blksize|0),t.mode|=(t.mode&292)>>2),{dev:t.dev,ino:r.id,mode:t.mode,nlink:t.nlink,uid:t.uid,gid:t.gid,rdev:t.rdev,size:t.size,atime:t.atime,mtime:t.mtime,ctime:t.ctime,blksize:t.blksize,blocks:t.blocks}},setattr(e,r,t,n,i,a,s){b.tryFSOperation(()=>{if(t.mode!==void 0){var l=t.mode;b.isWindows&&(l&=384),n(e,l),r.mode=t.mode}if(typeof(t.atime??t.mtime)=="number"){var d=new Date(t.atime??s(e).atime),u=new Date(t.mtime??s(e).mtime);i(e,d,u)}t.size!==void 0&&a(e,t.size)})},node_ops:{getattr(e){var r=b.realPath(e);return b.getattr(()=>x.lstatSync(r),e)},setattr(e,r){var t=b.realPath(e);if(r.mode!=null&&r.dontFollow)throw new o.ErrnoError(52);b.setattr(t,e,r,x.chmodSync,x.utimesSync,x.truncateSync,x.lstatSync)},lookup(e,r){var t=I.join2(b.realPath(e),r),n=b.getMode(t);return b.createNode(e,r,n)},mknod(e,r,t,n){var i=b.createNode(e,r,t,n),a=b.realPath(i);return b.tryFSOperation(()=>{o.isDir(i.mode)?x.mkdirSync(a,i.mode):x.writeFileSync(a,"",{mode:i.mode})}),i},rename(e,r,t){var n=b.realPath(e),i=I.join2(b.realPath(r),t);try{o.unlink(i)}catch{}b.tryFSOperation(()=>x.renameSync(n,i)),e.name=t},unlink(e,r){var t=I.join2(b.realPath(e),r);b.tryFSOperation(()=>x.unlinkSync(t))},rmdir(e,r){var t=I.join2(b.realPath(e),r);b.tryFSOperation(()=>x.rmdirSync(t))},readdir(e){var r=b.realPath(e);return b.tryFSOperation(()=>x.readdirSync(r))},symlink(e,r,t){var n=I.join2(b.realPath(e),r);b.tryFSOperation(()=>x.symlinkSync(t,n))},readlink(e){var r=b.realPath(e);return b.tryFSOperation(()=>x.readlinkSync(r))},statfs(e){var r=b.tryFSOperation(()=>x.statfsSync(e));return r.frsize=r.bsize,r}},stream_ops:{getattr(e){return b.getattr(()=>x.fstatSync(e.nfd),e.node)},setattr(e,r){b.setattr(e.nfd,e.node,r,x.fchmodSync,x.futimesSync,x.ftruncateSync,x.fstatSync)},open(e){var r=b.realPath(e.node);b.tryFSOperation(()=>{e.shared.refcount=1,e.nfd=x.openSync(r,b.flagsForNode(e.flags))})},close(e){b.tryFSOperation(()=>{e.nfd&&--e.shared.refcount===0&&x.closeSync(e.nfd)})},dup(e){e.shared.refcount++},read(e,r,t,n,i){return b.tryFSOperation(()=>x.readSync(e.nfd,r,t,n,i))},write(e,r,t,n,i){return b.tryFSOperation(()=>x.writeSync(e.nfd,r,t,n,i))},llseek(e,r,t){var n=r;if(t===1?n+=e.position:t===2&&o.isFile(e.node.mode)&&b.tryFSOperation(()=>{var i=x.fstatSync(e.nfd);n+=i.size}),n<0)throw new o.ErrnoError(28);return n},mmap(e,r,t,n,i){if(!o.isFile(e.node.mode))throw new o.ErrnoError(43);var a=zr(r);return b.stream_ops.read(e,(c(),H),a,r,t),{ptr:a,allocated:!0}},msync(e,r,t,n,i){return b.stream_ops.write(e,r,0,n,t,!1),0}}},qi=e=>_e(qn(e)),Ki=async e=>{var r=await tr(e);return h(r,`Loading data file "${e}" failed (no arrayBuffer).`),new Uint8Array(r)},Jt=(...e)=>o.createDataFile(...e),Xi=e=>{for(var r=e;;){if(!xe[e])return e;e=r+Math.random()}},Zt=[],Yi=async(e,r)=>{typeof Browser<"u"&&Browser.init();for(var t of Zt)if(t.canHandle(r))return h(t.handle.constructor.name==="AsyncFunction","Filesystem plugin handlers must be async functions (See #24914)"),t.handle(e,r);return e},qr=async(e,r,t,n,i,a,s,l)=>{var d=r?We.resolve(I.join2(e,r)):e,u=Xi(`cp ${d}`);xr(u);try{var _=t;typeof t=="string"&&(_=await Ki(t)),_=await Yi(_,d),l?.(),a||Jt(e,r,_,n,i,s)}finally{Mr(u)}},Ji=(e,r,t,n,i,a,s,l,d,u)=>{qr(e,r,t,n,i,l,d,u).then(a).catch(s)},o={root:null,mounts:[],devices:{},streams:[],nextInode:1,nameTable:null,currentPath:"/",initialized:!1,ignorePermissions:!0,filesystems:null,syncFSRequests:0,ErrnoError:class extends Error{name="ErrnoError";constructor(e){super(Ne?qi(e):""),this.errno=e;for(var r in dr)if(dr[r]===e){this.code=r;break}}},FSStream:class{shared={};get object(){return this.node}set object(e){this.node=e}get isRead(){return(this.flags&2097155)!==1}get isWrite(){return(this.flags&2097155)!==0}get isAppend(){return this.flags&1024}get flags(){return this.shared.flags}set flags(e){this.shared.flags=e}get position(){return this.shared.position}set position(e){this.shared.position=e}},FSNode:class{node_ops={};stream_ops={};readMode=365;writeMode=146;mounted=null;constructor(e,r,t,n){e||(e=this),this.parent=e,this.mount=e.mount,this.id=o.nextInode++,this.name=r,this.mode=t,this.rdev=n,this.atime=this.mtime=this.ctime=Date.now()}get read(){return(this.mode&this.readMode)===this.readMode}set read(e){e?this.mode|=this.readMode:this.mode&=~this.readMode}get write(){return(this.mode&this.writeMode)===this.writeMode}set write(e){e?this.mode|=this.writeMode:this.mode&=~this.writeMode}get isFolder(){return o.isDir(this.mode)}get isDevice(){return o.isChrdev(this.mode)}},lookupPath(e,r={}){if(!e)throw new o.ErrnoError(44);r.follow_mount??=!0,I.isAbs(e)||(e=o.cwd()+"/"+e);e:for(var t=0;t<40;t++){for(var n=e.split("/").filter(u=>!!u),i=o.root,a="/",s=0;s<n.length;s++){var l=s===n.length-1;if(l&&r.parent)break;if(n[s]!=="."){if(n[s]===".."){if(a=I.dirname(a),o.isRoot(i)){e=a+"/"+n.slice(s+1).join("/"),t--;continue e}else i=i.parent;continue}a=I.join2(a,n[s]);try{i=o.lookupNode(i,n[s])}catch(u){if(u?.errno===44&&l&&r.noent_okay)return{path:a};throw u}if(o.isMountpoint(i)&&(!l||r.follow_mount)&&(i=i.mounted.root),o.isLink(i.mode)&&(!l||r.follow)){if(!i.node_ops.readlink)throw new o.ErrnoError(52);var d=i.node_ops.readlink(i);I.isAbs(d)||(d=I.dirname(a)+"/"+d),e=d+"/"+n.slice(s+1).join("/");continue e}}}return{path:a,node:i}}throw new o.ErrnoError(32)},getPath(e){for(var r;;){if(o.isRoot(e)){var t=e.mount.mountpoint;return r?t[t.length-1]!=="/"?`${t}/${r}`:t+r:t}r=r?`${e.name}/${r}`:e.name,e=e.parent}},hashName(e,r){for(var t=0,n=0;n<r.length;n++)t=(t<<5)-t+r.charCodeAt(n)|0;return(e+t>>>0)%o.nameTable.length},hashAddNode(e){var r=o.hashName(e.parent.id,e.name);e.name_next=o.nameTable[r],o.nameTable[r]=e},hashRemoveNode(e){var r=o.hashName(e.parent.id,e.name);if(o.nameTable[r]===e)o.nameTable[r]=e.name_next;else for(var t=o.nameTable[r];t;){if(t.name_next===e){t.name_next=e.name_next;break}t=t.name_next}},lookupNode(e,r){var t=o.mayLookup(e);if(t)throw new o.ErrnoError(t);for(var n=o.hashName(e.id,r),i=o.nameTable[n];i;i=i.name_next){var a=i.name;if(i.parent.id===e.id&&a===r)return i}return o.lookup(e,r)},createNode(e,r,t,n){h(typeof e=="object");var i=new o.FSNode(e,r,t,n);return o.hashAddNode(i),i},destroyNode(e){o.hashRemoveNode(e)},isRoot(e){return e===e.parent},isMountpoint(e){return!!e.mounted},isFile(e){return(e&61440)===32768},isDir(e){return(e&61440)===16384},isLink(e){return(e&61440)===40960},isChrdev(e){return(e&61440)===8192},isBlkdev(e){return(e&61440)===24576},isFIFO(e){return(e&61440)===4096},isSocket(e){return(e&49152)===49152},flagsToPermissionString(e){var r=["r","w","rw"][e&3];return e&512&&(r+="w"),r},nodePermissions(e,r){return o.ignorePermissions?0:r.includes("r")&&!(e.mode&292)||r.includes("w")&&!(e.mode&146)||r.includes("x")&&!(e.mode&73)?2:0},mayLookup(e){if(!o.isDir(e.mode))return 54;var r=o.nodePermissions(e,"x");return r||(e.node_ops.lookup?0:2)},mayCreate(e,r){if(!o.isDir(e.mode))return 54;try{var t=o.lookupNode(e,r);return 20}catch{}return o.nodePermissions(e,"wx")},mayDelete(e,r,t){var n;try{n=o.lookupNode(e,r)}catch(a){return a.errno}var i=o.nodePermissions(e,"wx");if(i)return i;if(t){if(!o.isDir(n.mode))return 54;if(o.isRoot(n)||o.getPath(n)===o.cwd())return 10}else if(o.isDir(n.mode))return 31;return 0},mayOpen(e,r){if(!e)return 44;if(o.isLink(e.mode))return 32;var t=o.flagsToPermissionString(r);return o.isDir(e.mode)&&(t!=="r"||r&576)?31:o.nodePermissions(e,t)},checkOpExists(e,r){if(!e)throw new o.ErrnoError(r);return e},MAX_OPEN_FDS:4096,nextfd(){for(var e=0;e<=o.MAX_OPEN_FDS;e++)if(!o.streams[e])return e;throw new o.ErrnoError(33)},getStreamChecked(e){var r=o.getStream(e);if(!r)throw new o.ErrnoError(8);return r},getStream:e=>o.streams[e],createStream(e,r=-1){return h(r>=-1),e=Object.assign(new o.FSStream,e),r==-1&&(r=o.nextfd()),e.fd=r,o.streams[r]=e,e},closeStream(e){o.streams[e]=null},dupStream(e,r=-1){var t=o.createStream(e,r);return t.stream_ops?.dup?.(t),t},doSetAttr(e,r,t){var n=e?.stream_ops.setattr,i=n?e:r;n??=r.node_ops.setattr,o.checkOpExists(n,63);try{n(i,t)}catch(a){throw a instanceof RangeError?new o.ErrnoError(22):a}},chrdev_stream_ops:{open(e){var r=o.getDevice(e.node.rdev);e.stream_ops=r.stream_ops,e.stream_ops.open?.(e)},llseek(){throw new o.ErrnoError(70)}},major:e=>e>>8,minor:e=>e&255,makedev:(e,r)=>e<<8|r,registerDevice(e,r){o.devices[e]={stream_ops:r}},getDevice:e=>o.devices[e],getMounts(e){for(var r=[],t=[e];t.length;){var n=t.pop();r.push(n),t.push(...n.mounts)}return r},syncfs(e,r){typeof e=="function"&&(r=e,e=!1),o.syncFSRequests++,o.syncFSRequests>1&&C(`warning: ${o.syncFSRequests} FS.syncfs operations in flight at once, probably just doing extra work`);var t=o.getMounts(o.root.mount),n=0;function i(l){return h(o.syncFSRequests>0),o.syncFSRequests--,r(l)}function a(l){if(l)return a.errored?void 0:(a.errored=!0,i(l));++n>=t.length&&i(null)}for(var s of t)s.type.syncfs?s.type.syncfs(s,e,a):a(null)},mount(e,r,t){if(typeof e=="string")throw e;var n=t==="/",i=!t,a;if(n&&o.root)throw new o.ErrnoError(10);if(!n&&!i){var s=o.lookupPath(t,{follow_mount:!1});if(t=s.path,a=s.node,o.isMountpoint(a))throw new o.ErrnoError(10);if(!o.isDir(a.mode))throw new o.ErrnoError(54)}var l={type:e,opts:r,mountpoint:t,mounts:[]},d=e.mount(l);return d.mount=l,l.root=d,n?o.root=d:a&&(a.mounted=l,a.mount&&a.mount.mounts.push(l)),d},unmount(e){var r=o.lookupPath(e,{follow_mount:!1});if(!o.isMountpoint(r.node))throw new o.ErrnoError(28);var t=r.node,n=t.mounted,i=o.getMounts(n);for(var[a,s]of Object.entries(o.nameTable))for(;s;){var l=s.name_next;i.includes(s.mount)&&o.destroyNode(s),s=l}t.mounted=null;var d=t.mount.mounts.indexOf(n);h(d!==-1),t.mount.mounts.splice(d,1)},lookup(e,r){return e.node_ops.lookup(e,r)},mknod(e,r,t){var n=o.lookupPath(e,{parent:!0}),i=n.node,a=I.basename(e);if(!a)throw new o.ErrnoError(28);if(a==="."||a==="..")throw new o.ErrnoError(20);var s=o.mayCreate(i,a);if(s)throw new o.ErrnoError(s);if(!i.node_ops.mknod)throw new o.ErrnoError(63);return i.node_ops.mknod(i,a,r,t)},statfs(e){return o.statfsNode(o.lookupPath(e,{follow:!0}).node)},statfsStream(e){return o.statfsNode(e.node)},statfsNode(e){var r={bsize:4096,frsize:4096,blocks:1e6,bfree:5e5,bavail:5e5,files:o.nextInode,ffree:o.nextInode-1,fsid:42,flags:2,namelen:255};return e.node_ops.statfs&&Object.assign(r,e.node_ops.statfs(e.mount.opts.root)),r},create(e,r=438){return r&=4095,r|=32768,o.mknod(e,r,0)},mkdir(e,r=511){return r&=1023,r|=16384,o.mknod(e,r,0)},mkdirTree(e,r){var t=e.split("/"),n="";for(var i of t)if(i){(n||I.isAbs(e))&&(n+="/"),n+=i;try{o.mkdir(n,r)}catch(a){if(a.errno!=20)throw a}}},mkdev(e,r,t){return typeof t>"u"&&(t=r,r=438),r|=8192,o.mknod(e,r,t)},symlink(e,r){if(!We.resolve(e))throw new o.ErrnoError(44);var t=o.lookupPath(r,{parent:!0}),n=t.node;if(!n)throw new o.ErrnoError(44);var i=I.basename(r),a=o.mayCreate(n,i);if(a)throw new o.ErrnoError(a);if(!n.node_ops.symlink)throw new o.ErrnoError(63);return n.node_ops.symlink(n,i,e)},rename(e,r){var t=I.dirname(e),n=I.dirname(r),i=I.basename(e),a=I.basename(r),s,l,d;if(s=o.lookupPath(e,{parent:!0}),l=s.node,s=o.lookupPath(r,{parent:!0}),d=s.node,!l||!d)throw new o.ErrnoError(44);if(l.mount!==d.mount)throw new o.ErrnoError(75);var u=o.lookupNode(l,i),_=We.relative(e,n);if(_.charAt(0)!==".")throw new o.ErrnoError(28);if(_=We.relative(r,t),_.charAt(0)!==".")throw new o.ErrnoError(55);var p;try{p=o.lookupNode(d,a)}catch{}if(u!==p){var m=o.isDir(u.mode),g=o.mayDelete(l,i,m);if(g)throw new o.ErrnoError(g);if(g=p?o.mayDelete(d,a,m):o.mayCreate(d,a),g)throw new o.ErrnoError(g);if(!l.node_ops.rename)throw new o.ErrnoError(63);if(o.isMountpoint(u)||p&&o.isMountpoint(p))throw new o.ErrnoError(10);if(d!==l&&(g=o.nodePermissions(l,"w"),g))throw new o.ErrnoError(g);o.hashRemoveNode(u);try{l.node_ops.rename(u,d,a),u.parent=d}catch(E){throw E}finally{o.hashAddNode(u)}}},rmdir(e){var r=o.lookupPath(e,{parent:!0}),t=r.node,n=I.basename(e),i=o.lookupNode(t,n),a=o.mayDelete(t,n,!0);if(a)throw new o.ErrnoError(a);if(!t.node_ops.rmdir)throw new o.ErrnoError(63);if(o.isMountpoint(i))throw new o.ErrnoError(10);t.node_ops.rmdir(t,n),o.destroyNode(i)},readdir(e){var r=o.lookupPath(e,{follow:!0}),t=r.node,n=o.checkOpExists(t.node_ops.readdir,54);return n(t)},unlink(e){var r=o.lookupPath(e,{parent:!0}),t=r.node;if(!t)throw new o.ErrnoError(44);var n=I.basename(e),i=o.lookupNode(t,n),a=o.mayDelete(t,n,!1);if(a)throw new o.ErrnoError(a);if(!t.node_ops.unlink)throw new o.ErrnoError(63);if(o.isMountpoint(i))throw new o.ErrnoError(10);t.node_ops.unlink(t,n),o.destroyNode(i)},readlink(e){var r=o.lookupPath(e),t=r.node;if(!t)throw new o.ErrnoError(44);if(!t.node_ops.readlink)throw new o.ErrnoError(28);return t.node_ops.readlink(t)},stat(e,r){var t=o.lookupPath(e,{follow:!r}),n=t.node,i=o.checkOpExists(n.node_ops.getattr,63);return i(n)},fstat(e){var r=o.getStreamChecked(e),t=r.node,n=r.stream_ops.getattr,i=n?r:t;return n??=t.node_ops.getattr,o.checkOpExists(n,63),n(i)},lstat(e){return o.stat(e,!0)},doChmod(e,r,t,n){o.doSetAttr(e,r,{mode:t&4095|r.mode&-4096,ctime:Date.now(),dontFollow:n})},chmod(e,r,t){var n;if(typeof e=="string"){var i=o.lookupPath(e,{follow:!t});n=i.node}else n=e;o.doChmod(null,n,r,t)},lchmod(e,r){o.chmod(e,r,!0)},fchmod(e,r){var t=o.getStreamChecked(e);o.doChmod(t,t.node,r,!1)},doChown(e,r,t){o.doSetAttr(e,r,{timestamp:Date.now(),dontFollow:t})},chown(e,r,t,n){var i;if(typeof e=="string"){var a=o.lookupPath(e,{follow:!n});i=a.node}else i=e;o.doChown(null,i,n)},lchown(e,r,t){o.chown(e,r,t,!0)},fchown(e,r,t){var n=o.getStreamChecked(e);o.doChown(n,n.node,!1)},doTruncate(e,r,t){if(o.isDir(r.mode))throw new o.ErrnoError(31);if(!o.isFile(r.mode))throw new o.ErrnoError(28);var n=o.nodePermissions(r,"w");if(n)throw new o.ErrnoError(n);o.doSetAttr(e,r,{size:t,timestamp:Date.now()})},truncate(e,r){if(r<0)throw new o.ErrnoError(28);var t;if(typeof e=="string"){var n=o.lookupPath(e,{follow:!0});t=n.node}else t=e;o.doTruncate(null,t,r)},ftruncate(e,r){var t=o.getStreamChecked(e);if(r<0||(t.flags&2097155)===0)throw new o.ErrnoError(28);o.doTruncate(t,t.node,r)},utime(e,r,t){var n=o.lookupPath(e,{follow:!0}),i=n.node,a=o.checkOpExists(i.node_ops.setattr,63);a(i,{atime:r,mtime:t})},open(e,r,t=438){if(e==="")throw new o.ErrnoError(44);r=Vi(r),r&64?t=t&4095|32768:t=0;var n,i;if(typeof e=="object")n=e;else{i=e.endsWith("/");var a=o.lookupPath(e,{follow:!(r&131072),noent_okay:!0});n=a.node,e=a.path}var s=!1;if(r&64)if(n){if(r&128)throw new o.ErrnoError(20)}else{if(i)throw new o.ErrnoError(31);n=o.mknod(e,t|511,0),s=!0}if(!n)throw new o.ErrnoError(44);if(o.isChrdev(n.mode)&&(r&=-513),r&65536&&!o.isDir(n.mode))throw new o.ErrnoError(54);if(!s){var l=o.mayOpen(n,r);if(l)throw new o.ErrnoError(l)}r&512&&!s&&o.truncate(n,0),r&=-131713;var d=o.createStream({node:n,path:o.getPath(n),flags:r,seekable:!0,position:0,stream_ops:n.stream_ops,ungotten:[],error:!1});return d.stream_ops.open&&d.stream_ops.open(d),s&&o.chmod(n,t&511),d},close(e){if(o.isClosed(e))throw new o.ErrnoError(8);e.getdents&&(e.getdents=null);try{e.stream_ops.close&&e.stream_ops.close(e)}catch(r){throw r}finally{o.closeStream(e.fd)}e.fd=null},isClosed(e){return e.fd===null},llseek(e,r,t){if(o.isClosed(e))throw new o.ErrnoError(8);if(!e.seekable||!e.stream_ops.llseek)throw new o.ErrnoError(70);if(t!=0&&t!=1&&t!=2)throw new o.ErrnoError(28);return e.position=e.stream_ops.llseek(e,r,t),e.ungotten=[],e.position},read(e,r,t,n,i){if(h(t>=0),n<0||i<0)throw new o.ErrnoError(28);if(o.isClosed(e))throw new o.ErrnoError(8);if((e.flags&2097155)===1)throw new o.ErrnoError(8);if(o.isDir(e.node.mode))throw new o.ErrnoError(31);if(!e.stream_ops.read)throw new o.ErrnoError(28);var a=typeof i<"u";if(!a)i=e.position;else if(!e.seekable)throw new o.ErrnoError(70);var s=e.stream_ops.read(e,r,t,n,i);return a||(e.position+=s),s},write(e,r,t,n,i,a){if(h(t>=0),h(r.subarray,"FS.write expects a TypedArray"),n<0||i<0)throw new o.ErrnoError(28);if(o.isClosed(e))throw new o.ErrnoError(8);if((e.flags&2097155)===0)throw new o.ErrnoError(8);if(o.isDir(e.node.mode))throw new o.ErrnoError(31);if(!e.stream_ops.write)throw new o.ErrnoError(28);e.seekable&&e.flags&1024&&o.llseek(e,0,2);var s=typeof i<"u";if(!s)i=e.position;else if(!e.seekable)throw new o.ErrnoError(70);var l=e.stream_ops.write(e,r,t,n,i,a);return s||(e.position+=l),l},mmap(e,r,t,n,i){if((n&2)!==0&&(i&2)===0&&(e.flags&2097155)!==2)throw new o.ErrnoError(2);if((e.flags&2097155)===1)throw new o.ErrnoError(2);if(!e.stream_ops.mmap)throw new o.ErrnoError(43);if(!r)throw new o.ErrnoError(28);return e.stream_ops.mmap(e,r,t,n,i)},msync(e,r,t,n,i){return h(t>=0),e.stream_ops.msync?e.stream_ops.msync(e,r,t,n,i):0},ioctl(e,r,t){if(!e.stream_ops.ioctl)throw new o.ErrnoError(59);return e.stream_ops.ioctl(e,r,t)},readFile(e,r={}){r.flags=r.flags||0,r.encoding=r.encoding||"binary",r.encoding!=="utf8"&&r.encoding!=="binary"&&q(`Invalid encoding type "${r.encoding}"`);var t=o.open(e,r.flags),n=o.stat(e),i=n.size,a=new Uint8Array(i);return o.read(t,a,0,i,0),r.encoding==="utf8"&&(a=Le(a)),o.close(t),a},writeFile(e,r,t={}){t.flags=t.flags||577;var n=o.open(e,t.flags,t.mode);r=Yt(r),o.write(n,r,0,r.byteLength,void 0,t.canOwn),o.close(n)},cwd:()=>o.currentPath,chdir(e){var r=o.lookupPath(e,{follow:!0});if(r.node===null)throw new o.ErrnoError(44);if(!o.isDir(r.node.mode))throw new o.ErrnoError(54);var t=o.nodePermissions(r.node,"x");if(t)throw new o.ErrnoError(t);o.currentPath=r.path},createDefaultDirectories(){o.mkdir("/tmp"),o.mkdir("/home"),o.mkdir("/home/web_user")},createDefaultDevices(){o.mkdir("/dev"),o.registerDevice(o.makedev(1,3),{read:()=>0,write:(n,i,a,s,l)=>s,llseek:()=>0}),o.mkdev("/dev/null",o.makedev(1,3)),pe.register(o.makedev(5,0),pe.default_tty_ops),pe.register(o.makedev(6,0),pe.default_tty1_ops),o.mkdev("/dev/tty",o.makedev(5,0)),o.mkdev("/dev/tty1",o.makedev(6,0));var e=new Uint8Array(1024),r=0,t=()=>(r===0&&(Br(e),r=e.byteLength),e[--r]);o.createDevice("/dev","random",t),o.createDevice("/dev","urandom",t),o.mkdir("/dev/shm"),o.mkdir("/dev/shm/tmp")},createSpecialDirectories(){o.mkdir("/proc");var e=o.mkdir("/proc/self");o.mkdir("/proc/self/fd"),o.mount({mount(){var r=o.createNode(e,"fd",16895,73);return r.stream_ops={llseek:F.stream_ops.llseek},r.node_ops={lookup(t,n){var i=+n,a=o.getStreamChecked(i),s={parent:null,mount:{mountpoint:"fake"},node_ops:{readlink:()=>a.path},id:i+1};return s.parent=s,s},readdir(){return Array.from(o.streams.entries()).filter(([t,n])=>n).map(([t,n])=>t.toString())}},r}},{},"/proc/self/fd")},createStandardStreams(e,r,t){e?o.createDevice("/dev","stdin",e):o.symlink("/dev/tty","/dev/stdin"),r?o.createDevice("/dev","stdout",null,r):o.symlink("/dev/tty","/dev/stdout"),t?o.createDevice("/dev","stderr",null,t):o.symlink("/dev/tty1","/dev/stderr");var n=o.open("/dev/stdin",0),i=o.open("/dev/stdout",1),a=o.open("/dev/stderr",1);h(n.fd===0,`invalid handle for stdin (${n.fd})`),h(i.fd===1,`invalid handle for stdout (${i.fd})`),h(a.fd===2,`invalid handle for stderr (${a.fd})`)},staticInit(){o.nameTable=new Array(4096),o.mount(F,{},"/"),o.createDefaultDirectories(),o.createDefaultDevices(),o.createSpecialDirectories(),o.filesystems={MEMFS:F,NODEFS:b}},init(e,r,t){h(!o.initialized,"FS.init was previously called. If you want to initialize later with custom parameters, remove any earlier calls (note that one is automatically added to the generated code)"),o.initialized=!0,e??=f.stdin,r??=f.stdout,t??=f.stderr,o.createStandardStreams(e,r,t)},quit(){o.initialized=!1,st(0);for(var e of o.streams)e&&o.close(e)},findObject(e,r){var t=o.analyzePath(e,r);return t.exists?t.object:null},analyzePath(e,r){try{var t=o.lookupPath(e,{follow:!r});e=t.path}catch{}var n={isRoot:!1,exists:!1,error:0,name:null,path:null,object:null,parentExists:!1,parentPath:null,parentObject:null};try{var t=o.lookupPath(e,{parent:!0});n.parentExists=!0,n.parentPath=t.path,n.parentObject=t.node,n.name=I.basename(e),t=o.lookupPath(e,{follow:!r}),n.exists=!0,n.path=t.path,n.object=t.node,n.name=t.node.name,n.isRoot=t.path==="/"}catch(i){n.error=i.errno}return n},createPath(e,r,t,n){e=typeof e=="string"?e:o.getPath(e);for(var i=r.split("/").reverse();i.length;){var a=i.pop();if(a){var s=I.join2(e,a);try{o.mkdir(s)}catch(l){if(l.errno!=20)throw l}e=s}}return s},createFile(e,r,t,n,i){var a=I.join2(typeof e=="string"?e:o.getPath(e),r),s=Vr(n,i);return o.create(a,s)},createDataFile(e,r,t,n,i,a){var s=r;e&&(e=typeof e=="string"?e:o.getPath(e),s=r?I.join2(e,r):e);var l=Vr(n,i),d=o.create(s,l);if(t){t=Yt(t),o.chmod(d,l|146);var u=o.open(d,577);o.write(u,t,0,t.length,0,a),o.close(u),o.chmod(d,l)}},createDevice(e,r,t,n){var i=I.join2(typeof e=="string"?e:o.getPath(e),r),a=Vr(!!t,!!n);o.createDevice.major??=64;var s=o.makedev(o.createDevice.major++,0);return o.registerDevice(s,{open(l){l.seekable=!1},close(l){n?.buffer?.length&&n(10)},read(l,d,u,_,p){for(var m=0,g=0;g<_;g++){var E;try{E=t()}catch{throw new o.ErrnoError(29)}if(E===void 0&&m===0)throw new o.ErrnoError(6);if(E==null)break;m++,d[u+g]=E}return m&&(l.node.atime=Date.now()),m},write(l,d,u,_,p){for(var m=0;m<_;m++)try{n(d[u+m])}catch{throw new o.ErrnoError(29)}return _&&(l.node.mtime=l.node.ctime=Date.now()),m}}),o.mkdev(i,a,s)},forceLoadFile(e){if(e.isDevice||e.isFolder||e.link||e.contents)return!0;if(globalThis.XMLHttpRequest)q("Lazy loading should have been performed (contents set) in createLazyFile, but it was not. Lazy loading only works in web workers. Use --embed-file or --preload-file in emcc on the main thread.");else try{e.contents=Be(e.url)}catch{throw new o.ErrnoError(29)}},createLazyFile(e,r,t,n,i){class a{lengthKnown=!1;chunks=[];get(m){if(!(m>this.length-1||m<0)){var g=m%this.chunkSize,E=m/this.chunkSize|0;return this.getter(E)[g]}}setDataGetter(m){this.getter=m}cacheLength(){var m=new XMLHttpRequest;m.open("HEAD",t,!1),m.send(null),m.status>=200&&m.status<300||m.status===304||q("Couldn't load "+t+". Status: "+m.status);var g=Number(m.getResponseHeader("Content-length")),E,k=(E=m.getResponseHeader("Accept-Ranges"))&&E==="bytes",D=(E=m.getResponseHeader("Content-Encoding"))&&E==="gzip",R=1024*1024;k||(R=g);var G=(oe,de)=>{oe>de&&q("invalid range ("+oe+", "+de+") or no bytes requested!"),de>g-1&&q("only "+g+" bytes available! programmer error!");var V=new XMLHttpRequest;return V.open("GET",t,!1),g!==R&&V.setRequestHeader("Range","bytes="+oe+"-"+de),V.responseType="arraybuffer",V.overrideMimeType&&V.overrideMimeType("text/plain; charset=x-user-defined"),V.send(null),V.status>=200&&V.status<300||V.status===304||q("Couldn't load "+t+". Status: "+V.status),V.response!==void 0?new Uint8Array(V.response||[]):Gr(V.responseText||"",!0)},z=this;z.setDataGetter(oe=>{var de=oe*R,V=(oe+1)*R-1;return V=Math.min(V,g-1),typeof z.chunks[oe]>"u"&&(z.chunks[oe]=G(de,V)),typeof z.chunks[oe]>"u"&&q("doXHR failed!"),z.chunks[oe]}),(D||!g)&&(R=g=1,g=this.getter(0).length,R=g,ge("LazyFiles on gzip forces download of the whole file when length is accessed")),this._length=g,this._chunkSize=R,this.lengthKnown=!0}get length(){return this.lengthKnown||this.cacheLength(),this._length}get chunkSize(){return this.lengthKnown||this.cacheLength(),this._chunkSize}}if(globalThis.XMLHttpRequest){N||q("Cannot do synchronous binary XHRs outside webworkers in modern browsers. Use --embed-file or --preload-file in emcc");var s=new a,l={isDevice:!1,contents:s}}else var l={isDevice:!1,url:t};var d=o.createFile(e,r,l,n,i);l.contents?d.contents=l.contents:l.url&&(d.contents=null,d.url=l.url),Object.defineProperties(d,{usedBytes:{get:function(){return this.contents.length}}});var u={};for(let[p,m]of Object.entries(d.stream_ops))u[p]=(...g)=>(o.forceLoadFile(d),m(...g));function _(p,m,g,E,k){var D=p.node.contents;if(k>=D.length)return 0;var R=Math.min(D.length-k,E);if(h(R>=0),D.slice)for(var G=0;G<R;G++)m[g+G]=D[k+G];else for(var G=0;G<R;G++)m[g+G]=D.get(k+G);return R}return u.read=(p,m,g,E,k)=>(o.forceLoadFile(d),_(p,m,g,E,k)),u.mmap=(p,m,g,E,k)=>{o.forceLoadFile(d);var D=zr(m);if(!D)throw new o.ErrnoError(48);return _(p,(c(),H),D,m,g),{ptr:D,allocated:!0}},d.stream_ops=u,d}},T={websocketArgs:{},callbacks:{},on(e,r){T.callbacks[e]=r},emit(e,r){T.callbacks[e]?.(r)},mount(e){return T.websocketArgs=f.websocket||{},(f.websocket??={}).on=T.on,o.createNode(null,"/",16895,0)},createSocket(e,r,t){if(e!=2)throw new o.ErrnoError(5);if(r&=-526337,r!=1&&r!=2)throw new o.ErrnoError(28);var n=r==1;if(n&&t&&t!=6)throw new o.ErrnoError(66);var i={family:e,type:r,protocol:t,server:null,error:null,peers:{},pending:[],recv_queue:[],sock_ops:T.websocket_sock_ops},a=T.nextname(),s=o.createNode(T.root,a,49152,0);s.sock=i;var l=o.createStream({path:a,node:s,flags:2,seekable:!1,stream_ops:T.stream_ops});return i.stream=l,i},getSocket(e){var r=o.getStream(e);return!r||!o.isSocket(r.node.mode)?null:r.node.sock},stream_ops:{poll(e){var r=e.node.sock;return r.sock_ops.poll(r)},ioctl(e,r,t){var n=e.node.sock;return n.sock_ops.ioctl(n,r,t)},read(e,r,t,n,i){var a=e.node.sock,s=a.sock_ops.recvmsg(a,n);return s?(r.set(s.buffer,t),s.buffer.length):0},write(e,r,t,n,i){var a=e.node.sock;return a.sock_ops.sendmsg(a,r,t,n)},close(e){var r=e.node.sock;r.sock_ops.close(r)}},nextname(){return T.nextname.current||(T.nextname.current=0),`socket[${T.nextname.current++}]`},websocket_sock_ops:{createPeer(e,r,t){var n;if(typeof r=="object"&&(n=r,r=null,t=null),n)if(n._socket)r=n._socket.remoteAddress,t=n._socket.remotePort;else{var i=/ws[s]?:\/\/([^:]+):(\d+)/.exec(n.url);if(!i)throw new Error("WebSocket URL must be in the format ws(s)://address:port");r=i[1],t=parseInt(i[2],10)}else try{var a="ws://".replace("#","//"),s="binary",l=void 0;if(T.websocketArgs.url&&(a=T.websocketArgs.url),T.websocketArgs.subprotocol?s=T.websocketArgs.subprotocol:T.websocketArgs.subprotocol===null&&(s="null"),a==="ws://"||a==="wss://"){var d=r.split("/");a=a+d[0]+":"+t+"/"+d.slice(1).join("/")}s!=="null"&&(s=s.replace(/^ +| +$/g,"").split(/ *, */),l=s);var u;M?u=le("ws"):u=WebSocket,n=new u(a,l),n.binaryType="arraybuffer"}catch{throw new o.ErrnoError(23)}var _={addr:r,port:t,socket:n,msg_send_queue:[]};return T.websocket_sock_ops.addPeer(e,_),T.websocket_sock_ops.handlePeerEvents(e,_),e.type===2&&typeof e.sport<"u"&&_.msg_send_queue.push(new Uint8Array([255,255,255,255,112,111,114,116,(e.sport&65280)>>8,e.sport&255])),_},getPeer(e,r,t){return e.peers[r+":"+t]},addPeer(e,r){e.peers[r.addr+":"+r.port]=r},removePeer(e,r){delete e.peers[r.addr+":"+r.port]},handlePeerEvents(e,r){var t=!0;function n(){e.connecting=!1,T.emit("open",e.stream.fd);try{for(var a=r.msg_send_queue.shift();a;)r.socket.send(a),a=r.msg_send_queue.shift()}catch{r.socket.close()}}function i(a){if(typeof a=="string"){var s=new TextEncoder;a=s.encode(a)}else{if(h(a.byteLength!==void 0),a.byteLength==0)return;a=new Uint8Array(a)}var l=t;if(t=!1,l&&a.length===10&&a[0]===255&&a[1]===255&&a[2]===255&&a[3]===255&&a[4]===112&&a[5]===111&&a[6]===114&&a[7]===116){var d=a[8]<<8|a[9];T.websocket_sock_ops.removePeer(e,r),r.port=d,T.websocket_sock_ops.addPeer(e,r);return}e.recv_queue.push({addr:r.addr,port:r.port,data:a}),T.emit("message",e.stream.fd)}if(M){r.socket.on("open",n),r.socket.on("message",(a,s)=>{s&&i(new Uint8Array(a).buffer)}),r.socket.on("close",()=>T.emit("close",e.stream.fd)),r.socket.on("error",a=>{e.error=14,T.emit("error",[e.stream.fd,e.error,"ECONNREFUSED: Connection refused"])});return}r.socket.onopen=n,r.socket.onclose=()=>T.emit("close",e.stream.fd),r.socket.onmessage=a=>i(a.data),r.socket.onerror=a=>{e.error=14,T.emit("error",[e.stream.fd,e.error,"ECONNREFUSED: Connection refused"])}},poll(e){if(e.type===1&&e.server)return e.pending.length?65:0;var r=0,t=e.type===1?T.websocket_sock_ops.getPeer(e,e.daddr,e.dport):null;return(e.recv_queue.length||!t||t&&t.socket.readyState===t.socket.CLOSING||t&&t.socket.readyState===t.socket.CLOSED)&&(r|=65),(!t||t&&t.socket.readyState===t.socket.OPEN)&&(r|=4),(t&&t.socket.readyState===t.socket.CLOSING||t&&t.socket.readyState===t.socket.CLOSED)&&(e.connecting?r|=4:r|=16),r},ioctl(e,r,t){switch(r){case 21531:var n=0;return e.recv_queue.length&&(n=e.recv_queue[0].data.length),(c(),S)[t>>2]=n,0;case 21537:var i=(c(),S)[t>>2];return i?e.stream.flags|=2048:e.stream.flags&=-2049,0;default:return 28}},close(e){if(e.server){try{e.server.close()}catch{}e.server=null}for(var r of Object.values(e.peers)){try{r.socket.close()}catch{}T.websocket_sock_ops.removePeer(e,r)}return 0},bind(e,r,t){if(typeof e.saddr<"u"||typeof e.sport<"u")throw new o.ErrnoError(28);if(e.saddr=r,e.sport=t,e.type===2){e.server&&(e.server.close(),e.server=null);try{e.sock_ops.listen(e,0)}catch(n){if(n.name!=="ErrnoError"||n.errno!==138)throw n}}},connect(e,r,t){if(e.server)throw new o.ErrnoError(138);if(typeof e.daddr<"u"&&typeof e.dport<"u"){var n=T.websocket_sock_ops.getPeer(e,e.daddr,e.dport);if(n)throw n.socket.readyState===n.socket.CONNECTING?new o.ErrnoError(7):new o.ErrnoError(30)}var i=T.websocket_sock_ops.createPeer(e,r,t);e.daddr=i.addr,e.dport=i.port,e.connecting=!0},listen(e,r){if(!M)throw new o.ErrnoError(138);if(e.server)throw new o.ErrnoError(28);var t=le("ws").Server,n=e.saddr;e.server=new t({host:n,port:e.sport}),T.emit("listen",e.stream.fd),e.server.on("connection",i=>{if(e.type===1){var a=T.createSocket(e.family,e.type,e.protocol),s=T.websocket_sock_ops.createPeer(a,i);a.daddr=s.addr,a.dport=s.port,e.pending.push(a),T.emit("connection",a.stream.fd)}else T.websocket_sock_ops.createPeer(e,i),T.emit("connection",e.stream.fd)}),e.server.on("close",()=>{T.emit("close",e.stream.fd),e.server=null}),e.server.on("error",i=>{e.error=23,T.emit("error",[e.stream.fd,e.error,"EHOSTUNREACH: Host is unreachable"])})},accept(e){if(!e.server||!e.pending.length)throw new o.ErrnoError(28);var r=e.pending.shift();return r.stream.flags=e.stream.flags,r},getname(e,r){var t,n;if(r){if(e.daddr===void 0||e.dport===void 0)throw new o.ErrnoError(53);t=e.daddr,n=e.dport}else t=e.saddr||0,n=e.sport||0;return{addr:t,port:n}},sendmsg(e,r,t,n,i,a){if(e.type===2){if((i===void 0||a===void 0)&&(i=e.daddr,a=e.dport),i===void 0||a===void 0)throw new o.ErrnoError(17)}else i=e.daddr,a=e.dport;var s=T.websocket_sock_ops.getPeer(e,i,a);if(e.type===1&&(!s||s.socket.readyState===s.socket.CLOSING||s.socket.readyState===s.socket.CLOSED))throw new o.ErrnoError(53);ArrayBuffer.isView(r)&&(t+=r.byteOffset,r=r.buffer);var l=r.slice(t,t+n);if(l instanceof SharedArrayBuffer&&(l=new Uint8Array(new Uint8Array(l)).buffer),!s||s.socket.readyState!==s.socket.OPEN)return e.type===2&&(!s||s.socket.readyState===s.socket.CLOSING||s.socket.readyState===s.socket.CLOSED)&&(s=T.websocket_sock_ops.createPeer(e,i,a)),s.msg_send_queue.push(l),n;try{return s.socket.send(l),n}catch{throw new o.ErrnoError(28)}},recvmsg(e,r){if(e.type===1&&e.server)throw new o.ErrnoError(53);var t=e.recv_queue.shift();if(!t){if(e.type===1){var n=T.websocket_sock_ops.getPeer(e,e.daddr,e.dport);if(!n)throw new o.ErrnoError(53);if(n.socket.readyState===n.socket.CLOSING||n.socket.readyState===n.socket.CLOSED)return null;throw new o.ErrnoError(6)}throw new o.ErrnoError(6)}var i=t.data.byteLength||t.data.length,a=t.data.byteOffset||0,s=t.data.buffer||t.data,l=Math.min(r,i),d={buffer:new Uint8Array(s,a,l),addr:t.addr,port:t.port};if(e.type===1&&l<i){var u=i-l;t.data=new Uint8Array(s,a+l,u),e.recv_queue.unshift(t)}return d}}},Kr=e=>{var r=T.getSocket(e);if(!r)throw new o.ErrnoError(8);return r},Xr=e=>(e&255)+"."+(e>>8&255)+"."+(e>>16&255)+"."+(e>>24&255),Qt=e=>{var r="",t=0,n=0,i=0,a=0,s=0,l=0,d=[e[0]&65535,e[0]>>16,e[1]&65535,e[1]>>16,e[2]&65535,e[2]>>16,e[3]&65535,e[3]>>16],u=!0,_="";for(l=0;l<5;l++)if(d[l]!==0){u=!1;break}if(u){if(_=Xr(d[6]|d[7]<<16),d[5]===-1)return r="::ffff:",r+=_,r;if(d[5]===0)return r="::",_==="0.0.0.0"&&(_=""),_==="0.0.0.1"&&(_="1"),r+=_,r}for(t=0;t<8;t++)d[t]===0&&(t-i>1&&(s=0),i=t,s++),s>n&&(n=s,a=t-n+1);for(t=0;t<8;t++){if(n>1&&d[t]===0&&t>=a&&t<a+n){t===a&&(r+=":",a===0&&(r+=":"));continue}r+=Number(dt(d[t]&65535)).toString(16),r+=t<7?":":""}return r},Zi=(e,r)=>{var t=(c(),ne)[e>>1],n=dt((c(),ke)[e+2>>1]),i;switch(t){case 2:if(r!==16)return{errno:28};i=(c(),S)[e+4>>2],i=Xr(i);break;case 10:if(r!==28)return{errno:28};i=[(c(),S)[e+8>>2],(c(),S)[e+12>>2],(c(),S)[e+16>>2],(c(),S)[e+20>>2]],i=Qt(i);break;default:return{errno:5}}return{family:t,addr:i,port:n}},cr=e=>{for(var r=e.split("."),t=0;t<4;t++){var n=Number(r[t]);if(isNaN(n))return null;r[t]=n}return(r[0]|r[1]<<8|r[2]<<16|r[3]<<24)>>>0},Yr=e=>{var r,t,n,i,a,s=/^((?=.*::)(?!.*::.+::)(::)?([\dA-F]{1,4}:(:|\b)|){5}|([\dA-F]{1,4}:){6})((([\dA-F]{1,4}((?!\3)::|:\b|$))|(?!\2\3)){2}|(((2[0-4]|1\d|[1-9])?\d|25[0-5])\.?\b){4})$/i,l=[];if(!s.test(e))return null;if(e==="::")return[0,0,0,0,0,0,0,0];for(e.startsWith("::")?e=e.replace("::","Z:"):e=e.replace("::",":Z:"),e.indexOf(".")>0?(e=e.replace(new RegExp("[.]","g"),":"),r=e.split(":"),r[r.length-4]=Number(r[r.length-4])+Number(r[r.length-3])*256,r[r.length-3]=Number(r[r.length-2])+Number(r[r.length-1])*256,r=r.slice(0,r.length-2)):r=e.split(":"),n=0,i=0,t=0;t<r.length;t++)if(typeof r[t]=="string")if(r[t]==="Z"){for(i=0;i<8-r.length+1;i++)l[t+i]=0;n=i-1}else l[t+n]=Fr(parseInt(r[t],16));else l[t+n]=r[t];return[l[1]<<16|l[0],l[3]<<16|l[2],l[5]<<16|l[4],l[7]<<16|l[6]]},he={address_map:{id:1,addrs:{},names:{}},lookup_name(e){var r=cr(e);if(r!==null||(r=Yr(e),r!==null))return e;var t;if(he.address_map.addrs[e])t=he.address_map.addrs[e];else{var n=he.address_map.id++;h(n<65535,"exceeded max address mappings of 65535"),t="172.29."+(n&255)+"."+(n&65280),he.address_map.names[t]=e,he.address_map.addrs[e]=t}return t},lookup_addr(e){return he.address_map.names[e]?he.address_map.names[e]:null}},en=(e,r)=>{var t=Zi(e,r);if(t.errno)throw new o.ErrnoError(t.errno);return t.addr=he.lookup_addr(t.addr)||t.addr,t};function rn(e,r,t,n,i,a){if(w)return K(3,0,1,e,r,t,n,i,a);try{var s=Kr(e),l=en(r,t);return s.sock_ops.connect(s,l.addr,l.port),0}catch(d){if(typeof o>"u"||d.name!=="ErrnoError")throw d;return-d.errno}}var X={currentUmask:18,calculateAt(e,r,t){if(I.isAbs(r))return r;var n;if(e===-100)n=o.cwd();else{var i=X.getStreamFromFD(e);n=i.path}if(r.length==0){if(!t)throw new o.ErrnoError(44);return n}return n+"/"+r},writeStat(e,r){(c(),y)[e>>2]=r.dev,(c(),y)[e+4>>2]=r.mode,(c(),y)[e+8>>2]=r.nlink,(c(),y)[e+12>>2]=r.uid,(c(),y)[e+16>>2]=r.gid,(c(),y)[e+20>>2]=r.rdev,(c(),Z)[e+24>>3]=BigInt(r.size),(c(),S)[e+32>>2]=4096,(c(),S)[e+36>>2]=r.blocks;var t=r.atime.getTime(),n=r.mtime.getTime(),i=r.ctime.getTime();return(c(),Z)[e+40>>3]=BigInt(Math.floor(t/1e3)),(c(),y)[e+48>>2]=t%1e3*1e3*1e3,(c(),Z)[e+56>>3]=BigInt(Math.floor(n/1e3)),(c(),y)[e+64>>2]=n%1e3*1e3*1e3,(c(),Z)[e+72>>3]=BigInt(Math.floor(i/1e3)),(c(),y)[e+80>>2]=i%1e3*1e3*1e3,(c(),Z)[e+88>>3]=BigInt(r.ino),0},writeStatFs(e,r){(c(),y)[e+4>>2]=r.bsize,(c(),y)[e+60>>2]=r.bsize,(c(),Z)[e+8>>3]=BigInt(r.blocks),(c(),Z)[e+16>>3]=BigInt(r.bfree),(c(),Z)[e+24>>3]=BigInt(r.bavail),(c(),Z)[e+32>>3]=BigInt(r.files),(c(),Z)[e+40>>3]=BigInt(r.ffree),(c(),y)[e+48>>2]=r.fsid,(c(),y)[e+64>>2]=r.flags,(c(),y)[e+56>>2]=r.namelen},doMsync(e,r,t,n,i){if(!o.isFile(r.node.mode))throw new o.ErrnoError(43);if(n&2)return 0;var a=(c(),te).slice(e,e+t);o.msync(r,a,i,t,n)},getStreamFromFD(e){var r=o.getStreamChecked(e);return r},varargs:void 0,getStr(e){var r=_e(e);return r}};function tn(e){if(w)return K(4,0,1,e);try{var r=X.getStreamFromFD(e);return o.dupStream(r).fd}catch(t){if(typeof o>"u"||t.name!=="ErrnoError")throw t;return-t.errno}}var ur=()=>{h(X.varargs!=null);var e=(c(),S)[+X.varargs>>2];return X.varargs+=4,e},Ue=ur;function nn(e,r,t){if(w)return K(5,0,1,e,r,t);X.varargs=t;try{var n=X.getStreamFromFD(e);switch(r){case 0:{var i=ur();if(i<0)return-28;for(;o.streams[i];)i++;var a;return a=o.dupStream(n,i),a.fd}case 1:case 2:return 0;case 3:return n.flags;case 4:{var i=ur(),s=289792;return n.flags=n.flags&~s|i&s,0}case 12:{var i=Ue(),l=0;return(c(),ne)[i+l>>1]=2,0}case 13:case 14:return 0}return-28}catch(d){if(typeof o>"u"||d.name!=="ErrnoError")throw d;return-d.errno}}var Ee=(e,r,t)=>(h(typeof t=="number","stringToUTF8 requires a third parameter that specifies the length of the output buffer"),Xt(e,(c(),te),r,t));function an(e,r){if(w)return K(6,0,1,e,r);try{if(r===0)return-28;var t=o.cwd(),n=Pe(t)+1;return r<n?-68:(Ee(t,e,r),n)}catch(i){if(typeof o>"u"||i.name!=="ErrnoError")throw i;return-i.errno}}function on(e,r,t){if(w)return K(7,0,1,e,r,t);X.varargs=t;try{var n=X.getStreamFromFD(e);switch(r){case 21509:return n.tty?0:-59;case 21505:{if(!n.tty)return-59;if(n.tty.ops.ioctl_tcgets){var i=n.tty.ops.ioctl_tcgets(n),a=Ue();(c(),S)[a>>2]=i.c_iflag||0,(c(),S)[a+4>>2]=i.c_oflag||0,(c(),S)[a+8>>2]=i.c_cflag||0,(c(),S)[a+12>>2]=i.c_lflag||0;for(var s=0;s<32;s++)(c(),H)[a+s+17]=i.c_cc[s]||0;return 0}return 0}case 21510:case 21511:case 21512:return n.tty?0:-59;case 21506:case 21507:case 21508:{if(!n.tty)return-59;if(n.tty.ops.ioctl_tcsets){for(var a=Ue(),l=(c(),S)[a>>2],d=(c(),S)[a+4>>2],u=(c(),S)[a+8>>2],_=(c(),S)[a+12>>2],p=[],s=0;s<32;s++)p.push((c(),H)[a+s+17]);return n.tty.ops.ioctl_tcsets(n.tty,r,{c_iflag:l,c_oflag:d,c_cflag:u,c_lflag:_,c_cc:p})}return 0}case 21519:{if(!n.tty)return-59;var a=Ue();return(c(),S)[a>>2]=0,0}case 21520:return n.tty?-28:-59;case 21537:case 21531:{var a=Ue();return o.ioctl(n,r,a)}case 21523:{if(!n.tty)return-59;if(n.tty.ops.ioctl_tiocgwinsz){var m=n.tty.ops.ioctl_tiocgwinsz(n.tty),a=Ue();(c(),ne)[a>>1]=m[0],(c(),ne)[a+2>>1]=m[1]}return 0}case 21524:return n.tty?0:-59;case 21515:return n.tty?0:-59;default:return-28}}catch(g){if(typeof o>"u"||g.name!=="ErrnoError")throw g;return-g.errno}}function sn(e,r,t,n){if(w)return K(8,0,1,e,r,t,n);X.varargs=n;try{r=X.getStr(r),r=X.calculateAt(e,r);var i=n?ur():0;return t&64&&(i&=~X.currentUmask),o.open(r,t,i).fd}catch(a){if(typeof o>"u"||a.name!=="ErrnoError")throw a;return-a.errno}}function ln(e,r,t,n){if(w)return K(9,0,1,e,r,t,n);try{if(r=X.getStr(r),r=X.calculateAt(e,r),n<=0)return-28;var i=o.readlink(r),a=Math.min(n,Pe(i)),s=(c(),H)[t+a];return Ee(i,t,n+1),(c(),H)[t+a]=s,a}catch(l){if(typeof o>"u"||l.name!=="ErrnoError")throw l;return-l.errno}}var dn=(e,r)=>(c(),te).fill(0,e,e+r),cn=(e,r,t,n,i)=>{switch(r){case 2:t=cr(t),dn(e,16),i&&((c(),S)[i>>2]=16),(c(),ne)[e>>1]=r,(c(),S)[e+4>>2]=t,(c(),ne)[e+2>>1]=Fr(n);break;case 10:t=Yr(t),dn(e,28),i&&((c(),S)[i>>2]=28),(c(),S)[e>>2]=r,(c(),S)[e+8>>2]=t[0],(c(),S)[e+12>>2]=t[1],(c(),S)[e+16>>2]=t[2],(c(),S)[e+20>>2]=t[3],(c(),ne)[e+2>>1]=Fr(n);break;default:return 5}return 0};function un(e,r,t,n,i,a){if(w)return K(10,0,1,e,r,t,n,i,a);try{var s=Kr(e),l=s.sock_ops.recvmsg(s,t);if(!l)return 0;if(i){var d=cn(i,s.family,he.lookup_name(l.addr),l.port,a);h(!d)}return(c(),te).set(l.buffer,r),l.buffer.byteLength}catch(u){if(typeof o>"u"||u.name!=="ErrnoError")throw u;return-u.errno}}function fn(e){if(w)return K(11,0,1,e);try{return e=X.getStr(e),o.rmdir(e),0}catch(r){if(typeof o>"u"||r.name!=="ErrnoError")throw r;return-r.errno}}function _n(e,r,t,n,i,a){if(w)return K(12,0,1,e,r,t,n,i,a);try{var s=Kr(e);if(!i)return o.write(s.stream,(c(),H),r,t);var l=en(i,a);return s.sock_ops.sendmsg(s,(c(),H),r,t,l.addr,l.port)}catch(d){if(typeof o>"u"||d.name!=="ErrnoError")throw d;return-d.errno}}function hn(e,r,t){if(w)return K(13,0,1,e,r,t);try{var n=T.createSocket(e,r,t);return h(n.stream.fd<64),n.stream.fd}catch(i){if(typeof o>"u"||i.name!=="ErrnoError")throw i;return-i.errno}}function vn(e,r,t){if(w)return K(14,0,1,e,r,t);try{if(r=X.getStr(r),r=X.calculateAt(e,r),!t)o.unlink(r);else if(t===512)o.rmdir(r);else return-28;return 0}catch(n){if(typeof o>"u"||n.name!=="ErrnoError")throw n;return-n.errno}}var Qi=()=>q("native code called abort()"),fr={},_r=e=>{for(;e.length;){var r=e.pop(),t=e.pop();t(r)}};function Ve(e){return this.fromWireType((c(),y)[e>>2])}var je={},Ce={},hr={},ea=class extends Error{constructor(r){super(r),this.name="InternalError"}},vr=e=>{throw new ea(e)},ce=(e,r,t)=>{e.forEach(l=>hr[l]=r);function n(l){var d=t(l);d.length!==e.length&&vr("Mismatched type converter count");for(var u=0;u<e.length;++u)ie(e[u],d[u])}var i=new Array(r.length),a=[],s=0;for(let[l,d]of r.entries())Ce.hasOwnProperty(d)?i[l]=Ce[d]:(a.push(d),je.hasOwnProperty(d)||(je[d]=[]),je[d].push(()=>{i[l]=Ce[d],++s,s===a.length&&n(i)}));a.length===0&&n(i)},ra=e=>{var r=fr[e];delete fr[e];var t=r.rawConstructor,n=r.rawDestructor,i=r.fields,a=i.map(s=>s.getterReturnType).concat(i.map(s=>s.setterArgumentType));ce([e],a,s=>{var l={};for(var[d,u]of i.entries()){let _=s[d],p=u.getter,m=u.getterContext,g=s[d+i.length],E=u.setter,k=u.setterContext;l[u.fieldName]={read:D=>_.fromWireType(p(m,D)),write:(D,R)=>{var G=[];E(k,D,g.toWireType(G,R)),_r(G)},optional:_.optional}}return[{name:r.name,fromWireType:_=>{var p={};for(var m in l)p[m]=l[m].read(_);return n(_),p},toWireType:(_,p)=>{for(var m in l)if(!(m in p)&&!l[m].optional)throw new TypeError(`Missing field: "${m}"`);var g=t();for(m in l)l[m].write(g,p[m]);return _!==null&&_.push(n,g),g},readValueFromPointer:Ve,destructorFunction:n}]})},Y=e=>{for(var r="";;){var t=(c(),te)[e++];if(!t)return r;r+=String.fromCharCode(t)}},qe=class extends Error{constructor(r){super(r),this.name="BindingError"}},A=e=>{throw new qe(e)};function ta(e,r,t={}){var n=r.name;if(e||A(`type "${n}" must have a positive integer typeid pointer`),Ce.hasOwnProperty(e)){if(t.ignoreDuplicateRegistrations)return;A(`Cannot register type '${n}' twice`)}if(Ce[e]=r,delete hr[e],je.hasOwnProperty(e)){var i=je[e];delete je[e],i.forEach(a=>a())}}function ie(e,r,t={}){return ta(e,r,t)}var pn=(e,r,t)=>{switch(r){case 1:return t?n=>(c(),H)[n]:n=>(c(),te)[n];case 2:return t?n=>(c(),ne)[n>>1]:n=>(c(),ke)[n>>1];case 4:return t?n=>(c(),S)[n>>2]:n=>(c(),y)[n>>2];case 8:return t?n=>(c(),Z)[n>>3]:n=>(c(),Dt)[n>>3];default:throw new TypeError(`invalid integer width (${r}): ${e}`)}},Ae=e=>{if(e===null)return"null";var r=typeof e;return r==="object"||r==="array"||r==="function"?e.toString():""+e},mn=(e,r,t,n)=>{if(r<t||r>n)throw new TypeError(`Passing a number "${Ae(r)}" from JS side to C/C++ side to an argument of type "${e}", which is outside the valid range [${t}, ${n}]!`)},na=(e,r,t,n,i)=>{r=Y(r);let a=n===0n,s=l=>l;if(a){let l=t*8;s=d=>BigInt.asUintN(l,d),i=s(i)}ie(e,{name:r,fromWireType:s,toWireType:(l,d)=>{if(typeof d=="number")d=BigInt(d);else if(typeof d!="bigint")throw new TypeError(`Cannot convert "${Ae(d)}" to ${r}`);return mn(r,d,n,i),d},readValueFromPointer:pn(r,t,!a),destructorFunction:null})},ia=(e,r,t,n)=>{r=Y(r),ie(e,{name:r,fromWireType:function(i){return!!i},toWireType:function(i,a){return a?t:n},readValueFromPointer:function(i){return this.fromWireType((c(),te)[i])},destructorFunction:null})},aa=e=>({count:e.count,deleteScheduled:e.deleteScheduled,preservePointerOnDelete:e.preservePointerOnDelete,ptr:e.ptr,ptrType:e.ptrType,smartPtr:e.smartPtr,smartPtrType:e.smartPtrType}),Jr=e=>{function r(t){return t.$$.ptrType.registeredClass.name}A(r(e)+" instance already deleted")},Zr=!1,gn=e=>{},oa=e=>{e.smartPtr?e.smartPtrType.rawDestructor(e.smartPtr):e.ptrType.registeredClass.rawDestructor(e.ptr)},yn=e=>{e.count.value-=1;var r=e.count.value===0;r&&oa(e)},wn=(e,r,t)=>{if(r===t)return e;if(t.baseClass===void 0)return null;var n=wn(e,r,t.baseClass);return n===null?null:t.downcast(n)},En={},sa={},la=(e,r)=>{for(r===void 0&&A("ptr should not be undefined");e.baseClass;)r=e.upcast(r),e=e.baseClass;return r},da=(e,r)=>(r=la(e,r),sa[r]),pr=(e,r)=>{(!r.ptrType||!r.ptr)&&vr("makeClassHandle requires ptr and ptrType");var t=!!r.smartPtrType,n=!!r.smartPtr;return t!==n&&vr("Both smartPtrType and smartPtr must be specified"),r.count={value:1},Ke(Object.create(e,{$$:{value:r,writable:!0}}))};function bn(e){var r=this.getPointee(e);if(!r)return this.destructor(e),null;var t=da(this.registeredClass,r);if(t!==void 0){if(t.$$.count.value===0)return t.$$.ptr=r,t.$$.smartPtr=e,t.clone();var n=t.clone();return this.destructor(e),n}function i(){return this.isSmartPointer?pr(this.registeredClass.instancePrototype,{ptrType:this.pointeeType,ptr:r,smartPtrType:this,smartPtr:e}):pr(this.registeredClass.instancePrototype,{ptrType:this,ptr:e})}var a=this.registeredClass.getActualType(r),s=En[a];if(!s)return i.call(this);var l;this.isConst?l=s.constPointerType:l=s.pointerType;var d=wn(r,this.registeredClass,l.registeredClass);return d===null?i.call(this):this.isSmartPointer?pr(l.registeredClass.instancePrototype,{ptrType:l,ptr:d,smartPtrType:this,smartPtr:e}):pr(l.registeredClass.instancePrototype,{ptrType:l,ptr:d})}var Ke=e=>globalThis.FinalizationRegistry?(Zr=new FinalizationRegistry(r=>{console.warn(r.leakWarning),yn(r.$$)}),Ke=r=>{var t=r.$$,n=!!t.smartPtr;if(n){var i={$$:t},a=t.ptrType.registeredClass,s=new Error(`Embind found a leaked C++ instance ${a.name} <${we(t.ptr)}>.
|
|
5
6
|
We'll free it automatically in this case, but this functionality is not reliable across various environments.
|
|
6
7
|
Make sure to invoke .delete() manually once you're done with the instance instead.
|
|
7
|
-
Originally allocated`);"captureStackTrace"in Error&&Error.captureStackTrace(s,
|
|
8
|
+
Originally allocated`);"captureStackTrace"in Error&&Error.captureStackTrace(s,bn),i.leakWarning=s.stack.replace(/^Error: /,""),Zr.register(r,i,r)}return r},gn=r=>Zr.unregister(r),Ke(e)):(Ke=r=>r,e),mr=[],ca=()=>{for(;mr.length;){var e=mr.pop();e.$$.deleteScheduled=!1,e.delete()}},Sn,ua=()=>{let e=gr.prototype;Object.assign(e,{isAliasOf(t){if(!(this instanceof gr)||!(t instanceof gr))return!1;var n=this.$$.ptrType.registeredClass,i=this.$$.ptr;t.$$=t.$$;for(var a=t.$$.ptrType.registeredClass,s=t.$$.ptr;n.baseClass;)i=n.upcast(i),n=n.baseClass;for(;a.baseClass;)s=a.upcast(s),a=a.baseClass;return n===a&&i===s},clone(){if(this.$$.ptr||Jr(this),this.$$.preservePointerOnDelete)return this.$$.count.value+=1,this;var t=Ke(Object.create(Object.getPrototypeOf(this),{$$:{value:aa(this.$$)}}));return t.$$.count.value+=1,t.$$.deleteScheduled=!1,t},delete(){this.$$.ptr||Jr(this),this.$$.deleteScheduled&&!this.$$.preservePointerOnDelete&&A("Object already scheduled for deletion"),gn(this),yn(this.$$),this.$$.preservePointerOnDelete||(this.$$.smartPtr=void 0,this.$$.ptr=void 0)},isDeleted(){return!this.$$.ptr},deleteLater(){return this.$$.ptr||Jr(this),this.$$.deleteScheduled&&!this.$$.preservePointerOnDelete&&A("Object already scheduled for deletion"),mr.push(this),mr.length===1&&Sn&&Sn(ca),this.$$.deleteScheduled=!0,this}});let r=Symbol.dispose;r&&(e[r]=e.delete)};function gr(){}var yr=(e,r)=>Object.defineProperty(r,"name",{value:e}),Qr=(e,r,t)=>{if(e[r].overloadTable===void 0){var n=e[r];e[r]=function(...i){return e[r].overloadTable.hasOwnProperty(i.length)||A(`Function '${t}' called with an invalid number of arguments (${i.length}) - expects one of (${e[r].overloadTable})!`),e[r].overloadTable[i.length].apply(this,i)},e[r].overloadTable=[],e[r].overloadTable[n.argCount]=n}},Xe=(e,r,t)=>{f.hasOwnProperty(e)?((t===void 0||f[e].overloadTable!==void 0&&f[e].overloadTable[t]!==void 0)&&A(`Cannot register public name '${e}' twice`),Qr(f,e,e),f[e].overloadTable.hasOwnProperty(t)&&A(`Cannot register multiple overloads of a function with the same number of arguments (${t})!`),f[e].overloadTable[t]=r):(f[e]=r,f[e].argCount=t)},fa=48,_a=57,ha=e=>{h(typeof e=="string"),e=e.replace(/[^a-zA-Z0-9_]/g,"$");var r=e.charCodeAt(0);return r>=fa&&r<=_a?`_${e}`:e};function va(e,r,t,n,i,a,s,l){this.name=e,this.constructor=r,this.instancePrototype=t,this.rawDestructor=n,this.baseClass=i,this.getActualType=a,this.upcast=s,this.downcast=l,this.pureVirtualFunctions=[]}var wr=(e,r,t)=>{for(;r!==t;)r.upcast||A(`Expected null or instance of ${t.name}, got an instance of ${r.name}`),e=r.upcast(e),r=r.baseClass;return e};function pa(e,r){if(r===null)return this.isReference&&A(`null is not a valid ${this.name}`),0;r.$$||A(`Cannot pass "${Ae(r)}" as a ${this.name}`),r.$$.ptr||A(`Cannot pass deleted object as a pointer of type ${this.name}`);var t=r.$$.ptrType.registeredClass,n=wr(r.$$.ptr,t,this.registeredClass);return n}function ma(e,r){var t;if(r===null)return this.isReference&&A(`null is not a valid ${this.name}`),this.isSmartPointer?(t=this.rawConstructor(),e!==null&&e.push(this.rawDestructor,t),t):0;(!r||!r.$$)&&A(`Cannot pass "${Ae(r)}" as a ${this.name}`),r.$$.ptr||A(`Cannot pass deleted object as a pointer of type ${this.name}`),!this.isConst&&r.$$.ptrType.isConst&&A(`Cannot convert argument of type ${r.$$.smartPtrType?r.$$.smartPtrType.name:r.$$.ptrType.name} to parameter type ${this.name}`);var n=r.$$.ptrType.registeredClass;if(t=wr(r.$$.ptr,n,this.registeredClass),this.isSmartPointer)switch(r.$$.smartPtr===void 0&&A("Passing raw pointer to smart pointer is illegal"),this.sharingPolicy){case 0:r.$$.smartPtrType===this?t=r.$$.smartPtr:A(`Cannot convert argument of type ${r.$$.smartPtrType?r.$$.smartPtrType.name:r.$$.ptrType.name} to parameter type ${this.name}`);break;case 1:t=r.$$.smartPtr;break;case 2:if(r.$$.smartPtrType===this)t=r.$$.smartPtr;else{var i=r.clone();t=this.rawShare(t,re.toHandle(()=>i.delete())),e!==null&&e.push(this.rawDestructor,t)}break;default:A("Unsupported sharing policy")}return t}function ga(e,r){if(r===null)return this.isReference&&A(`null is not a valid ${this.name}`),0;r.$$||A(`Cannot pass "${Ae(r)}" as a ${this.name}`),r.$$.ptr||A(`Cannot pass deleted object as a pointer of type ${this.name}`),r.$$.ptrType.isConst&&A(`Cannot convert argument of type ${r.$$.ptrType.name} to parameter type ${this.name}`);var t=r.$$.ptrType.registeredClass,n=wr(r.$$.ptr,t,this.registeredClass);return n}var ya=()=>{Object.assign(Er.prototype,{getPointee(e){return this.rawGetPointee&&(e=this.rawGetPointee(e)),e},destructor(e){this.rawDestructor?.(e)},readValueFromPointer:Ve,fromWireType:bn})};function Er(e,r,t,n,i,a,s,l,d,u,_){this.name=e,this.registeredClass=r,this.isReference=t,this.isConst=n,this.isSmartPointer=i,this.pointeeType=a,this.sharingPolicy=s,this.rawGetPointee=l,this.rawConstructor=d,this.rawShare=u,this.rawDestructor=_,!i&&r.baseClass===void 0?n?(this.toWireType=pa,this.destructorFunction=null):(this.toWireType=ga,this.destructorFunction=null):this.toWireType=ma}var kn=(e,r,t)=>{f.hasOwnProperty(e)||vr("Replacing nonexistent public symbol"),f[e].overloadTable!==void 0&&t!==void 0?f[e].overloadTable[t]=r:(f[e]=r,f[e].argCount=t)},ae=(e,r,t=!1)=>{h(!t,"async bindings are only supported with JSPI"),e=Y(e);function n(){var a=W(r);return a}var i=n();return typeof i!="function"&&A(`unknown function pointer with signature ${e}: ${r}`),i};class wa extends Error{}var Tn=e=>{var r=zn(e),t=Y(r);return ve(r),t},Oe=(e,r)=>{var t=[],n={};function i(a){if(!n[a]&&!Ce[a]){if(hr[a]){hr[a].forEach(i);return}t.push(a),n[a]=!0}}throw r.forEach(i),new wa(`${e}: `+t.map(Tn).join([", "]))},Ea=(e,r,t,n,i,a,s,l,d,u,_,p,m)=>{_=Y(_),a=ae(i,a),l&&=ae(s,l),u&&=ae(d,u),m=ae(p,m);var g=ha(_);Xe(g,function(){Oe(`Cannot construct ${_} due to unbound types`,[n])}),ce([e,r,t],n?[n]:[],E=>{E=E[0];var k,D;n?(k=E.registeredClass,D=k.instancePrototype):D=gr.prototype;var R=yr(_,function(...se){if(Object.getPrototypeOf(this)!==G)throw new qe(`Use 'new' to construct ${_}`);if(z.constructor_body===void 0)throw new qe(`${_} has no accessible constructor`);var Qe=z.constructor_body[se.length];if(Qe===void 0)throw new qe(`Tried to invoke ctor of ${_} with invalid number of parameters (${se.length}) - expected (${Object.keys(z.constructor_body).toString()}) parameters instead!`);return Qe.apply(this,se)}),G=Object.create(D,{constructor:{value:R}});R.prototype=G;var z=new va(_,R,G,m,k,a,l,u);z.baseClass&&(z.baseClass.__derivedClasses??=[],z.baseClass.__derivedClasses.push(z));var oe=new Er(_,z,!0,!1,!1),de=new Er(_+"*",z,!1,!1,!1),V=new Er(_+" const*",z,!1,!0,!1);return En[e]={pointerType:de,constPointerType:V},kn(g,R),[oe,de,V]})};function Fn(e){for(var r=1;r<e.length;++r)if(e[r]!==null&&e[r].destructorFunction===void 0)return!0;return!1}function ba(e,r,t,n,i){if(e<r||e>t){var a=r==t?r:`${r} to ${t}`;i(`function ${n} called with ${e} arguments, expected ${a}`)}}function Sa(e,r,t,n){var i=Fn(e),a=e.length-2,s=[],l=["fn"];r&&l.push("thisWired");for(var d=0;d<a;++d)s.push(`arg${d}`),l.push(`arg${d}Wired`);s=s.join(","),l=l.join(",");var u=`return function (${s}) {
|
|
8
9
|
`;u+=`checkArgCount(arguments.length, minArgs, maxArgs, humanName, throwBindingError);
|
|
9
10
|
`,i&&(u+=`var destructors = [];
|
|
10
|
-
`);var
|
|
11
|
-
`);for(var
|
|
12
|
-
`,
|
|
11
|
+
`);var _=i?"destructors":"null",p=["humanName","throwBindingError","invoker","fn","runDestructors","fromRetWire","toClassParamWire"];r&&(u+=`var thisWired = toClassParamWire(${_}, this);
|
|
12
|
+
`);for(var d=0;d<a;++d){var m=`toArg${d}Wire`;u+=`var arg${d}Wired = ${m}(${_}, arg${d});
|
|
13
|
+
`,p.push(m)}u+=(t||n?"var rv = ":"")+`invoker(${l});
|
|
13
14
|
`;var g=t?"rv":"";if(i)u+=`runDestructors(destructors);
|
|
14
|
-
`;else for(var
|
|
15
|
-
`,
|
|
15
|
+
`;else for(var d=r?1:2;d<e.length;++d){var E=d===1?"thisWired":"arg"+(d-2)+"Wired";e[d].destructorFunction!==null&&(u+=`${E}_dtor(${E});
|
|
16
|
+
`,p.push(`${E}_dtor`))}return t&&(u+=`var ret = fromRetWire(rv);
|
|
16
17
|
return ret;
|
|
17
18
|
`),u+=`}
|
|
18
|
-
`,
|
|
19
|
-
${u}`,new Function(h,u)}function ka(e){for(var r=e.length-2,t=e.length-1;t>=2&&e[t].optional;--t)r--;return r}function Sr(e,r,t,n,i,a){var s=r.length;s<2&&O("argTypes array size mismatch! Must at least get return value and 'this' types!"),_(!a,"async bindings are only supported with JSPI");for(var l=r[1]!==null&&t!==null,c=Pn(r),u=!r[0].isVoid,v=s-2,h=ka(r),p=r[0],g=r[1],E=[e,O,n,i,vr,p.fromWireType.bind(p),g?.toWireType.bind(g)],k=2;k<s;++k){var R=r[k];E.push(R.toWireType.bind(R))}if(!c)for(var k=l?1:2;k<r.length;++k)r[k].destructorFunction!==null&&E.push(r[k].destructorFunction);E.push(ba,h,v);var z=Sa(r,l,u,a)(...E);return wr(e,z)}var kr=(e,r)=>{for(var t=[],n=0;n<e;n++)t.push((d(),y)[r+n*4>>2]);return t},rt=e=>{e=e.trim();let r=e.indexOf("(");return r===-1?e:(_(e.endsWith(")"),"Parentheses for argument names should match."),e.slice(0,r))},Ta=(e,r,t,n,i,a,s,l,c)=>{var u=kr(t,n);r=Y(r),r=rt(r),a=ie(i,a,l),ce([],[e],v=>{v=v[0];var h=`${v.name}.${r}`;function p(){Oe(`Cannot call ${h} due to unbound types`,u)}r.startsWith("@@")&&(r=Symbol[r.substring(2)]);var g=v.registeredClass.constructor;return g[r]===void 0?(p.argCount=t-1,g[r]=p):(et(g,r,h),g[r].overloadTable[t-1]=p),ce([],u,E=>{var k=[E[0],null].concat(E.slice(1)),R=Sr(h,k,null,a,s,l);if(g[r].overloadTable===void 0?(R.argCount=t-1,g[r]=R):g[r].overloadTable[t-1]=R,v.registeredClass.__derivedClasses)for(let D of v.registeredClass.__derivedClasses)D.constructor.hasOwnProperty(r)||(D.constructor[r]=R);return[]}),[]})},Fa=(e,r,t,n,i,a)=>{_(r>0);var s=kr(r,t);i=ie(n,i);var l=[a],c=[];ce([],[e],u=>{u=u[0];var v=`constructor ${u.name}`;if(u.registeredClass.constructor_body===void 0&&(u.registeredClass.constructor_body=[]),u.registeredClass.constructor_body[r-1]!==void 0)throw new qe(`Cannot register multiple constructors with identical number of parameters (${r-1}) for class '${u.name}'! Overload resolution is currently only performed using the parameter count, not actual type info!`);return u.registeredClass.constructor_body[r-1]=()=>{Oe(`Cannot construct ${u.name} due to unbound types`,s)},ce([],s,h=>(h.splice(1,0,null),u.registeredClass.constructor_body[r-1]=Sr(v,h,null,i,a),[])),[]})},Pa=(e,r,t,n,i,a,s,l,c,u)=>{var v=kr(t,n);r=Y(r),r=rt(r),a=ie(i,a,c),ce([],[e],h=>{h=h[0];var p=`${h.name}.${r}`;r.startsWith("@@")&&(r=Symbol[r.substring(2)]),l&&h.registeredClass.pureVirtualFunctions.push(r);function g(){Oe(`Cannot call ${p} due to unbound types`,v)}var E=h.registeredClass.instancePrototype,k=E[r];return k===void 0||k.overloadTable===void 0&&k.className!==h.name&&k.argCount===t-2?(g.argCount=t-2,g.className=h.name,E[r]=g):(et(E,r,p),E[r].overloadTable[t-2]=g),ce([],v,R=>{var D=Sr(p,R,h,a,s,c);return E[r].overloadTable===void 0?(D.argCount=t-2,E[r]=D):E[r].overloadTable[t-2]=D,[]}),[]})},Cn=(e,r,t)=>(e instanceof Object||O(`${t} with invalid "this": ${e}`),e instanceof r.registeredClass.constructor||O(`${t} incompatible with "this" of type ${e.constructor.name}`),e.$$.ptr||O(`cannot call emscripten binding method ${t} on deleted object`),Er(e.$$.ptr,e.$$.ptrType.registeredClass,r.registeredClass)),Ca=(e,r,t,n,i,a,s,l,c,u)=>{r=Y(r),i=ie(n,i),ce([],[e],v=>{v=v[0];var h=`${v.name}.${r}`,p={get(){Oe(`Cannot access ${h} due to unbound types`,[t,s])},enumerable:!0,configurable:!0};return c?p.set=()=>Oe(`Cannot access ${h} due to unbound types`,[t,s]):p.set=g=>O(h+" is a read-only property"),Object.defineProperty(v.registeredClass.instancePrototype,r,p),ce([],c?[t,s]:[t],g=>{var E=g[0],k={get(){var D=Cn(this,v,h+" getter");return E.fromWireType(i(a,D))},enumerable:!0};if(c){c=ie(l,c);var R=g[1];k.set=function(D){var z=Cn(this,v,h+" setter"),G=[];c(u,z,R.toWireType(G,D)),vr(G)}}return Object.defineProperty(v.registeredClass.instancePrototype,r,k),[]}),[]})},An=[],de=[0,1,,1,null,1,!0,1,!1,1],tt=e=>{if(e>9&&--de[e+1]===0){_(de[e]!==void 0,"decref for unallocated handle");var r=de[e];de[e]=void 0,An.push(e)}},ee={toValue:e=>(e||O(`Cannot use deleted val. handle = ${e}`),_(e===2||de[e]!==void 0&&e%2===0,`invalid handle: ${e}`),de[e]),toHandle:e=>{switch(e){case void 0:return 2;case null:return 4;case!0:return 6;case!1:return 8;default:{let r=An.pop()||de.length;return de[r]=e,de[r+1]=1,r}}}},On={name:"emscripten::val",fromWireType:e=>{var r=ee.toValue(e);return tt(e),r},toWireType:(e,r)=>ee.toHandle(r),readValueFromPointer:Ve,destructorFunction:null},Aa=e=>ne(e,On),nt=(e,r,t)=>{switch(r){case 1:return t?function(n){return this.fromWireType((d(),H)[n])}:function(n){return this.fromWireType((d(),Q)[n])};case 2:return t?function(n){return this.fromWireType((d(),te)[n>>1])}:function(n){return this.fromWireType((d(),ke)[n>>1])};case 4:return t?function(n){return this.fromWireType((d(),S)[n>>2])}:function(n){return this.fromWireType((d(),y)[n>>2])};default:throw new TypeError(`invalid integer width (${r}): ${e}`)}};function Oa(e){return e===0?"object":e===1?"number":"string"}var Ra=(e,r,t,n,i)=>{r=Y(r);let a=Oa(i);switch(a){case"object":{let u=function(){};u.values={},ne(e,{name:r,constructor:u,valueType:a,fromWireType:function(v){return this.constructor.values[v]},toWireType:(v,h)=>h.value,readValueFromPointer:nt(r,t,n),destructorFunction:null}),Xe(r,u);break}case"number":{var s={};ne(e,{name:r,keysMap:s,valueType:a,fromWireType:u=>u,toWireType:(u,v)=>v,readValueFromPointer:nt(r,t,n),destructorFunction:null}),Xe(r,s),delete f[r].argCount;break}case"string":{var l={},c={},s={};ne(e,{name:r,valuesMap:l,reverseMap:c,keysMap:s,valueType:a,fromWireType:function(v){return this.reverseMap[v]},toWireType:function(v,h){return this.valuesMap[h]},readValueFromPointer:nt(r,t,n),destructorFunction:null}),Xe(r,s),delete f[r].argCount;break}}},Rn=(e,r)=>{var t=Ce[e];return t===void 0&&O(`${r} has unknown type ${Fn(e)}`),t},Da=(e,r,t)=>{var n=Rn(e,"enum");switch(r=Y(r),n.valueType){case"object":{var i=n.constructor,a=Object.create(n.constructor.prototype,{value:{value:t},constructor:{value:wr(`${n.name}_${r}`,function(){})}});i.values[t]=a,i[r]=a;break}case"number":{n.keysMap[r]=t;break}case"string":{n.valuesMap[r]=t,n.reverseMap[t]=r,n.keysMap[r]=r;break}}},Ia=(e,r)=>{switch(r){case 4:return function(t){return this.fromWireType((d(),sr)[t>>2])};case 8:return function(t){return this.fromWireType((d(),Me)[t>>3])};default:throw new TypeError(`invalid float width (${r}): ${e}`)}},$a=(e,r,t)=>{r=Y(r),ne(e,{name:r,fromWireType:n=>n,toWireType:(n,i)=>{if(typeof i!="number"&&typeof i!="boolean")throw new TypeError(`Cannot convert ${Ae(i)} to ${r}`);return i},readValueFromPointer:Ia(r,t),destructorFunction:null})},Na=(e,r,t,n,i,a,s,l)=>{var c=kr(r,t);e=Y(e),e=rt(e),i=ie(n,i,s),Xe(e,function(){Oe(`Cannot call ${e} due to unbound types`,c)},r-1),ce([],c,u=>{var v=[u[0],null].concat(u.slice(1));return Tn(e,Sr(e,v,null,i,a,s),r-1),[]})},Ma=(e,r,t,n,i)=>{r=Y(r);let a=n===0,s=c=>c;if(a){var l=32-8*t;s=c=>c<<l>>>l,i=s(i)}ne(e,{name:r,fromWireType:s,toWireType:(c,u)=>{if(typeof u!="number"&&typeof u!="boolean")throw new TypeError(`Cannot convert "${Ae(u)}" to ${r}`);return gn(r,u,n,i),u},readValueFromPointer:mn(r,t,n!==0),destructorFunction:null})},xa=(e,r,t)=>{let n=(i,a)=>{let s=0;return{next(){if(s>=i)return{done:!0};let l=s;return s++,{value:a(l),done:!1}},[Symbol.iterator](){return this}}};e[Symbol.iterator]||(e[Symbol.iterator]=function(){let i=this[r]();return n(i,a=>this[t](a))})},Wa=(e,r,t,n)=>{t=Y(t),n=Y(n),ce([],[e,r],i=>{let a=i[0];return xa(a.registeredClass.instancePrototype,t,n),[]})},La=(e,r,t)=>{var n=[Int8Array,Uint8Array,Int16Array,Uint16Array,Int32Array,Uint32Array,Float32Array,Float64Array,BigInt64Array,BigUint64Array],i=n[r];function a(s){var l=(d(),y)[s>>2],c=(d(),y)[s+4>>2];return new i((d(),H).buffer,c,l)}t=Y(t),ne(e,{name:t,fromWireType:a,readValueFromPointer:a},{ignoreDuplicateRegistrations:!0})},Ua=Object.assign({optional:!0},On),ja=(e,r)=>{ne(e,Ua)},Ha=(e,r)=>{r=Y(r);var t=!0;ne(e,{name:r,fromWireType(n){var i=(d(),y)[n>>2],a=n+4,s;if(t)s=_e(a,i,!0);else{s="";for(var l=0;l<i;++l)s+=String.fromCharCode((d(),Q)[a+l])}return he(n),s},toWireType(n,i){i instanceof ArrayBuffer&&(i=new Uint8Array(i));var a,s=typeof i=="string";s||ArrayBuffer.isView(i)&&i.BYTES_PER_ELEMENT==1||O("Cannot pass non-string to std::string"),t&&s?a=Pe(i):a=i.length;var l=Je(4+a+1),c=l+4;if((d(),y)[l>>2]=a,s)if(t)Ee(i,c,a+1);else for(var u=0;u<a;++u){var v=i.charCodeAt(u);v>255&&(he(l),O("String has UTF-16 code units that do not fit in 8 bits")),(d(),Q)[c+u]=v}else(d(),Q).set(i,c);return n!==null&&n.push(he,l),l},readValueFromPointer:Ve,destructorFunction(n){he(n)}})},Dn=globalThis.TextDecoder?new TextDecoder("utf-16le"):void 0,Ba=(e,r,t)=>{_(e%2==0,"pointer passed to UTF16ToString must be 2-byte aligned");var n=e>>1,i=Gt((d(),ke),n,r/2,t);if(i-n>16&&Dn)return Dn.decode((d(),ke).slice(n,i));for(var a="",s=n;s<i;++s){var l=(d(),ke)[s];a+=String.fromCharCode(l)}return a},za=(e,r,t)=>{if(_(r%2==0,"pointer passed to stringToUTF16 must be 2-byte aligned"),_(typeof t=="number","stringToUTF16 requires a third parameter that specifies the length of the output buffer"),t??=2147483647,t<2)return 0;t-=2;for(var n=r,i=t<e.length*2?t/2:e.length,a=0;a<i;++a){var s=e.charCodeAt(a);(d(),te)[r>>1]=s,r+=2}return(d(),te)[r>>1]=0,r-n},Ga=e=>e.length*2,Va=(e,r,t)=>{_(e%4==0,"pointer passed to UTF32ToString must be 2-byte aligned");for(var n="",i=e>>2,a=0;!(a>=r/4);a++){var s=(d(),y)[i+a];if(!s&&!t)break;n+=String.fromCodePoint(s)}return n},qa=(e,r,t)=>{if(_(r%4==0,"pointer passed to stringToUTF32 must be 4-byte aligned"),_(typeof t=="number","stringToUTF32 requires a third parameter that specifies the length of the output buffer"),t??=2147483647,t<4)return 0;for(var n=r,i=n+t-4,a=0;a<e.length;++a){var s=e.codePointAt(a);if(s>65535&&a++,(d(),S)[r>>2]=s,r+=4,r+4>i)break}return(d(),S)[r>>2]=0,r-n},Ka=e=>{for(var r=0,t=0;t<e.length;++t){var n=e.codePointAt(t);n>65535&&t++,r+=4}return r},Xa=(e,r,t)=>{t=Y(t);var n,i,a;r===2?(n=Ba,i=za,a=Ga):(_(r===4,"only 2-byte and 4-byte strings are currently supported"),n=Va,i=qa,a=Ka),ne(e,{name:t,fromWireType:s=>{var l=(d(),y)[s>>2],c=n(s+4,l*r,!0);return he(s),c},toWireType:(s,l)=>{typeof l!="string"&&O(`Cannot pass non-string to C++ string type ${t}`);var c=a(l),u=Je(4+c+r);return(d(),y)[u>>2]=c/r,i(l,u+4,c+r),s!==null&&s.push(he,u),u},readValueFromPointer:Ve,destructorFunction(s){he(s)}})},Ya=(e,r,t,n,i,a)=>{_r[e]={name:Y(r),rawConstructor:ie(t,n),rawDestructor:ie(i,a),fields:[]}},Ja=(e,r,t,n,i,a,s,l,c,u)=>{_r[e].fields.push({fieldName:Y(r),getterReturnType:t,getter:ie(n,i),getterContext:a,setterArgumentType:s,setter:ie(l,c),setterContext:u})},Za=(e,r)=>{r=Y(r),ne(e,{isVoid:!0,name:r,fromWireType:()=>{},toWireType:(t,n)=>{}})},Qa=e=>{st(e,!B,1,!j,65536,!1),P.threadInitTLS()},In=e=>{if(e instanceof Rt||e=="unwind")return $e;ze(),e instanceof WebAssembly.RuntimeError&&ft()<=0&&A("Stack overflow detected. You can try increasing -sSTACK_SIZE (currently set to 65536)"),Or(1,e)},eo=()=>{if(!cr())try{if(w){Re()&&ut($e);return}Lr($e)}catch(e){In(e)}},$n=e=>{if(Ie){A("user callback triggered after runtime exited or application aborted. Ignoring.");return}try{return e()}catch(r){In(r)}finally{eo()}},it=e=>{if(!jt){var r=Atomics.waitAsync((d(),S),e>>2,e);_(r.async),r.value.then(Tr);var t=e+120;Atomics.store((d(),S),t>>2,1)}},Tr=()=>{var e=Re();e&&$n(()=>{it(e),ei()})},ro=(e,r)=>{if(e==r)setTimeout(Tr);else if(w)postMessage({targetThread:e,cmd:"checkMailbox"});else{var t=P.pthreads[e];if(!t){A(`Cannot send message to thread with ID ${e}, unknown thread ID!`);return}t.postMessage({cmd:"checkMailbox"})}},Fr=[],to=(e,r,t,n,i,a,s)=>{Fr.length=0;for(var l=i>>3,c=i+n>>3;l<c;){var u;(d(),Z)[l++]?u=(d(),Z)[l++]:u=(d(),Me)[l++],Fr.push(u)}_(!r);var v=Ho[e];_(!(e&&r)),_(v.length==Fr.length,"Call args mismatch in _emscripten_receive_on_main_thread_js"),P.currentProxiedOperationCallerThread=t;var h=v(...Fr);if(P.currentProxiedOperationCallerThread=0,a){h.then(p=>Jn(a,s,p));return}return _(typeof h!="bigint"),h},no=e=>{w?postMessage({cmd:"cleanupThread",thread:e}):$t(e)},io=e=>{C&&P.pthreads[e].ref()},at=[],ao=e=>{var r=at.length;return at.push(e),r},oo=(e,r)=>{for(var t=new Array(e),n=0;n<e;++n)t[n]=Rn((d(),y)[r+n*4>>2],`parameter ${n}`);return t},so=(e,r,t)=>{var n=[],i=e(n,t);return n.length&&((d(),y)[r>>2]=ee.toHandle(n)),i},lo={},Nn=e=>{var r=lo[e];return r===void 0?Y(e):r},co=(e,r,t)=>{var n=8,[i,...a]=oo(e,r),s=i.toWireType.bind(i),l=a.map(g=>g.readValueFromPointer.bind(g));e--;var c={toValue:ee.toValue},u=l.map((g,E)=>{var k=`argFromPtr${E}`;return c[k]=g,`${k}(args${E?"+"+E*n:""})`}),v;switch(t){case 0:v="toValue(handle)";break;case 2:v="new (toValue(handle))";break;case 3:v="";break;case 1:c.getStringOrSymbol=Nn,v="toValue(handle)[getStringOrSymbol(methodName)]";break}v+=`(${u})`,i.isVoid||(c.toReturnWire=s,c.emval_returnValue=so,v=`return emval_returnValue(toReturnWire, destructorsRef, ${v})`),v=`return function (handle, methodName, destructorsRef, args) {
|
|
20
|
-
${
|
|
21
|
-
}`;var h=new Function(Object.keys(c),v)(...Object.values(c)),p=`methodCaller<(${a.map(g=>g.name)}) => ${i.name}>`;return ao(wr(p,h))},uo=(e,r)=>(e=ee.toValue(e),r=ee.toValue(r),ee.toHandle(e[r])),fo=e=>{e>9&&(de[e+1]+=1)},Mn=(e,r,t,n,i)=>at[e](r,t,n,i),_o=(e,r,t,n,i)=>Mn(e,r,t,n,i),vo=e=>ee.toHandle(Nn(e)),ho=e=>{var r=ee.toValue(e);vr(r),tt(e)},po=(e,r,t,n)=>{var i=new Date().getFullYear(),a=new Date(i,0,1),s=new Date(i,6,1),l=a.getTimezoneOffset(),c=s.getTimezoneOffset(),u=Math.max(l,c);(d(),y)[e>>2]=u*60,(d(),S)[r>>2]=+(l!=c);var v=g=>{var E=g>=0?"-":"+",k=Math.abs(g),R=String(Math.floor(k/60)).padStart(2,"0"),D=String(k%60).padStart(2,"0");return`UTC${E}${R}${D}`},h=v(l),p=v(c);_(h),_(p),_(Pe(h)<=16,`timezone name truncated to fit in TZNAME_MAX (${h})`),_(Pe(p)<=16,`timezone name truncated to fit in TZNAME_MAX (${p})`),c<l?(Ee(h,t,17),Ee(p,n,17)):(Ee(h,n,17),Ee(p,t,17))},xn=()=>performance.timeOrigin+performance.now(),mo=()=>Date.now(),go=1,yo=e=>e>=0&&e<=3,wo=9007199254740992,Eo=-9007199254740992,Wn=e=>e<Eo||e>wo?NaN:Number(e);function bo(e,r,t){if(r=Wn(r),!yo(e))return 28;var n;if(e===0)n=mo();else if(go)n=xn();else return 52;var i=Math.round(n*1e3*1e3);return(d(),Z)[t>>3]=BigInt(i),0}var So=()=>{C||B||Fe("Blocking on the main thread is very dangerous, see https://emscripten.org/docs/porting/pthreads.html#blocking-on-the-main-browser-thread")},ko=e=>A(_e(e)),To=()=>{lr+=1},Fo=()=>{throw To(),"unwind"},Po=()=>2147483648,Co=(e,r)=>(_(r,"alignment argument is required"),Math.ceil(e/r)*r),Ao=e=>{var r=fe.buffer.byteLength,t=(e-r+65535)/65536|0;try{return fe.grow(t),or(),1}catch(n){A(`growMemory: Attempted to grow heap from ${r} bytes to ${e} bytes, but got error: ${n}`)}},Oo=e=>{var r=(d(),Q).length;if(e>>>=0,e<=r)return!1;var t=Po();if(e>t)return A(`Cannot enlarge memory, requested ${e} bytes, but the limit is ${t} bytes!`),!1;for(var n=1;n<=4;n*=2){var i=r*(1+.2/n);i=Math.min(i,e+100663296);var a=Math.min(t,Co(Math.max(e,i),65536)),s=Ao(a);if(s)return!0}return A(`Failed to grow the heap from ${r} bytes to ${a} bytes, not enough memory!`),!1},ot={},Ro=()=>Ar||"./this.program",Ye=()=>{if(!Ye.strings){var e=(globalThis.navigator?.language??"C").replace("-","_")+".UTF-8",r={USER:"web_user",LOGNAME:"web_user",PATH:"/",PWD:"/",HOME:"/home/web_user",LANG:e,_:Ro()};for(var t in ot)ot[t]===void 0?delete r[t]:r[t]=ot[t];var n=[];for(var t in r)n.push(`${t}=${r[t]}`);Ye.strings=n}return Ye.strings};function Ln(e,r){if(w)return K(15,0,1,e,r);var t=0,n=0;for(var i of Ye()){var a=r+t;(d(),y)[e+n>>2]=a,t+=Ee(i,a,1/0)+1,n+=4}return 0}function Un(e,r){if(w)return K(16,0,1,e,r);var t=Ye();(d(),y)[e>>2]=t.length;var n=0;for(var i of t)n+=Pe(i)+1;return(d(),y)[r>>2]=n,0}function jn(e){if(w)return K(17,0,1,e);try{var r=X.getStreamFromFD(e);return o.close(r),0}catch(t){if(typeof o>"u"||t.name!=="ErrnoError")throw t;return t.errno}}var Do=(e,r,t,n)=>{for(var i=0,a=0;a<t;a++){var s=(d(),y)[r>>2],l=(d(),y)[r+4>>2];r+=8;var c=o.read(e,(d(),H),s,l,n);if(c<0)return-1;if(i+=c,c<l)break;typeof n<"u"&&(n+=c)}return i};function Hn(e,r,t,n){if(w)return K(18,0,1,e,r,t,n);try{var i=X.getStreamFromFD(e),a=Do(i,r,t);return(d(),y)[n>>2]=a,0}catch(s){if(typeof o>"u"||s.name!=="ErrnoError")throw s;return s.errno}}function Bn(e,r,t,n){if(w)return K(19,0,1,e,r,t,n);r=Wn(r);try{if(isNaN(r))return 22;var i=X.getStreamFromFD(e);return o.llseek(i,r,t),(d(),Z)[n>>3]=BigInt(i.position),i.getdents&&r===0&&t===0&&(i.getdents=null),0}catch(a){if(typeof o>"u"||a.name!=="ErrnoError")throw a;return a.errno}}var Io=(e,r,t,n)=>{for(var i=0,a=0;a<t;a++){var s=(d(),y)[r>>2],l=(d(),y)[r+4>>2];r+=8;var c=o.write(e,(d(),H),s,l,n);if(c<0)return-1;if(i+=c,c<l)break;typeof n<"u"&&(n+=c)}return i};function zn(e,r,t,n){if(w)return K(20,0,1,e,r,t,n);try{var i=X.getStreamFromFD(e),a=Io(i,r,t);return(d(),y)[n>>2]=a,0}catch(s){if(typeof o>"u"||s.name!=="ErrnoError")throw s;return s.errno}}function Gn(e,r,t,n){if(w)return K(21,0,1,e,r,t,n);var i=[],a=null,s=0,l=0,c=0,u=0,v=0,h=0,p,g;function E(k,R,D,z,G,ae){var le,V,oe,Qe;return V=k===10?28:16,G=k===10?en(G):Yr(G),le=Je(V),Qe=un(le,k,G,ae),_(!Qe),oe=Je(32),(d(),S)[oe+4>>2]=k,(d(),S)[oe+8>>2]=R,(d(),S)[oe+12>>2]=D,(d(),y)[oe+24>>2]=z,(d(),y)[oe+20>>2]=le,k===10?(d(),S)[oe+16>>2]=28:(d(),S)[oe+16>>2]=16,(d(),S)[oe+28>>2]=0,oe}if(t&&(c=(d(),S)[t>>2],u=(d(),S)[t+4>>2],v=(d(),S)[t+8>>2],h=(d(),S)[t+12>>2]),v&&!h&&(h=v===2?17:6),!v&&h&&(v=h===17?2:1),h===0&&(h=6),v===0&&(v=1),!e&&!r)return-2;if(c&-1088||t!==0&&(d(),S)[t>>2]&2&&!e)return-1;if(c&32)return-2;if(v!==0&&v!==1&&v!==2)return-7;if(u!==0&&u!==2&&u!==10)return-6;if(r&&(r=_e(r),l=parseInt(r,10),isNaN(l)))return c&1024?-2:-8;if(!e)return u===0&&(u=2),(c&1)===0&&(u===2?s=Ze(2130706433):s=[0,0,0,Ze(1)]),p=E(u,v,h,null,s,l),(d(),y)[n>>2]=p,0;if(e=_e(e),s=ur(e),s!==null)if(u===0||u===2)u=2;else if(u===10&&c&8)s=[0,0,Ze(65535),s],u=10;else return-2;else if(s=Jr(e),s!==null)if(u===0||u===10)u=10;else return-2;return s!=null?(p=E(u,v,h,e,s,l),(d(),y)[n>>2]=p,0):c&4?-2:(e=ve.lookup_name(e),s=ur(e),u===0?u=2:u===10&&(s=[0,0,Ze(65535),s]),p=E(u,v,h,null,s,l),(d(),y)[n>>2]=p,0)}var $o=e=>e,No=(e,r)=>Br((d(),Q).subarray(e,e+r)),Mo=(...e)=>o.createPath(...e),xo=(...e)=>o.unlink(...e),Wo=(...e)=>o.createLazyFile(...e),Lo=(...e)=>o.createDevice(...e);P.init(),o.createPreloadedFile=Ji,o.preloadFile=Kr,o.staticInit(),C&&b.staticInit(),ua(),ya(),_(de.length===10);{if(Ei(),f.noExitRuntime&&(Ur=f.noExitRuntime),f.preloadPlugins&&(Qt=f.preloadPlugins),f.print&&(ge=f.print),f.printErr&&(A=f.printErr),f.wasmBinary&&(Be=f.wasmBinary),Bo(),f.arguments&&(gt=f.arguments),f.thisProgram&&(Ar=f.thisProgram),_(typeof f.memoryInitializerPrefixURL>"u","Module.memoryInitializerPrefixURL option was removed, use Module.locateFile instead"),_(typeof f.pthreadMainPrefixURL>"u","Module.pthreadMainPrefixURL option was removed, use Module.locateFile instead"),_(typeof f.cdInitializerPrefixURL>"u","Module.cdInitializerPrefixURL option was removed, use Module.locateFile instead"),_(typeof f.filePackagePrefixURL>"u","Module.filePackagePrefixURL option was removed, use Module.locateFile instead"),_(typeof f.read>"u","Module.read option was removed"),_(typeof f.readAsync>"u","Module.readAsync option was removed (modify readAsync in JS)"),_(typeof f.readBinary>"u","Module.readBinary option was removed (modify readBinary in JS)"),_(typeof f.setWindowTitle>"u","Module.setWindowTitle option was removed (modify emscripten_set_window_title in JS)"),_(typeof f.TOTAL_MEMORY>"u","Module.TOTAL_MEMORY has been renamed Module.INITIAL_MEMORY"),_(typeof f.ENVIRONMENT>"u","Module.ENVIRONMENT has been deprecated. To force the environment, use the ENVIRONMENT compile-time option (for example, -sENVIRONMENT=web or -sENVIRONMENT=node)"),_(typeof f.STACK_SIZE>"u","STACK_SIZE can no longer be set at runtime. Use -sSTACK_SIZE at link time"),f.preInit)for(typeof f.preInit=="function"&&(f.preInit=[f.preInit]);f.preInit.length>0;)f.preInit.shift()();ar("preInit")}f.addRunDependency=Wr,f.removeRunDependency=xr,f.FS_preloadFile=Kr,f.FS_unlink=xo,f.FS_createPath=Mo,f.FS_createDevice=Lo,f.FS=o,f.FS_createDataFile=Zt,f.FS_createLazyFile=Wo;var Uo=["writeI53ToI64","writeI53ToI64Clamped","writeI53ToI64Signaling","writeI53ToU64Clamped","writeI53ToU64Signaling","readI53FromI64","readI53FromU64","convertI32PairToI53","convertI32PairToI53Checked","convertU32PairToI53","getTempRet0","setTempRet0","withStackSave","readEmAsmArgs","jstoi_q","autoResumeAudioContext","getDynCaller","dynCall","runtimeKeepalivePop","asmjsMangle","HandleAllocator","addOnInit","addOnPostCtor","addOnPreMain","addOnExit","STACK_SIZE","STACK_ALIGN","POINTER_SIZE","ASSERTIONS","ccall","cwrap","convertJsFunctionToWasm","getEmptyTableSlot","updateTableMap","getFunctionAddress","addFunction","removeFunction","intArrayToString","stringToAscii","stringToNewUTF8","stringToUTF8OnStack","writeArrayToMemory","registerKeyEventCallback","maybeCStringToJsString","findEventTarget","getBoundingClientRect","fillMouseEventData","registerMouseEventCallback","registerWheelEventCallback","registerUiEventCallback","registerFocusEventCallback","fillDeviceOrientationEventData","registerDeviceOrientationEventCallback","fillDeviceMotionEventData","registerDeviceMotionEventCallback","screenOrientation","fillOrientationChangeEventData","registerOrientationChangeEventCallback","fillFullscreenChangeEventData","registerFullscreenChangeEventCallback","JSEvents_requestFullscreen","JSEvents_resizeCanvasForFullscreen","registerRestoreOldStyle","hideEverythingExceptGivenElement","restoreHiddenElements","setLetterbox","softFullscreenResizeWebGLRenderTarget","doRequestFullscreen","fillPointerlockChangeEventData","registerPointerlockChangeEventCallback","registerPointerlockErrorEventCallback","requestPointerLock","fillVisibilityChangeEventData","registerVisibilityChangeEventCallback","registerTouchEventCallback","fillGamepadEventData","registerGamepadEventCallback","registerBeforeUnloadEventCallback","fillBatteryEventData","registerBatteryEventCallback","setCanvasElementSizeCallingThread","setCanvasElementSizeMainThread","setCanvasElementSize","getCanvasSizeCallingThread","getCanvasSizeMainThread","getCanvasElementSize","jsStackTrace","getCallstack","convertPCtoSourceLocation","wasiRightsToMuslOFlags","wasiOFlagsToMuslOFlags","safeSetTimeout","setImmediateWrapped","safeRequestAnimationFrame","clearImmediateWrapped","registerPostMainLoop","registerPreMainLoop","getPromise","makePromise","idsToPromises","makePromiseCallback","incrementUncaughtExceptionCount","decrementUncaughtExceptionCount","Browser_asyncPrepareDataCounter","isLeapYear","ydayFromDate","arraySum","addDays","FS_mkdirTree","_setNetworkCallback","heapObjectForWebGLType","toTypedArrayIndex","webgl_enable_ANGLE_instanced_arrays","webgl_enable_OES_vertex_array_object","webgl_enable_WEBGL_draw_buffers","webgl_enable_WEBGL_multi_draw","webgl_enable_EXT_polygon_offset_clamp","webgl_enable_EXT_clip_control","webgl_enable_WEBGL_polygon_mode","emscriptenWebGLGet","computeUnpackAlignedImageSize","colorChannelsInGlTextureFormat","emscriptenWebGLGetTexPixelData","emscriptenWebGLGetUniform","webglGetUniformLocation","webglPrepareUniformLocationsBeforeFirstUse","webglGetLeftBracePos","emscriptenWebGLGetVertexAttrib","__glGetActiveAttribOrUniform","writeGLArray","emscripten_webgl_destroy_context_before_on_calling_thread","registerWebGlEventCallback","runAndAbortIfError","ALLOC_NORMAL","ALLOC_STACK","allocate","writeStringToMemory","writeAsciiToMemory","allocateUTF8","allocateUTF8OnStack","demangle","stackTrace","getNativeTypeSize","getFunctionArgsName","createJsInvokerSignature","PureVirtualError","registerInheritedInstance","unregisterInheritedInstance","getInheritedInstanceCount","getLiveInheritedInstances","setDelayFunction","count_emval_handles"];Uo.forEach(yi);var jo=["run","out","err","callMain","abort","wasmExports","writeStackCookie","checkStackCookie","INT53_MAX","INT53_MIN","bigintToI53Checked","HEAP8","HEAP16","HEAPU16","HEAP32","HEAPU32","HEAPF32","HEAPF64","HEAP64","HEAPU64","stackSave","stackRestore","stackAlloc","createNamedFunction","ptrToString","zeroMemory","exitJS","getHeapMax","growMemory","ENV","ERRNO_CODES","strError","inetPton4","inetNtop4","inetPton6","inetNtop6","readSockaddr","writeSockaddr","DNS","Protocols","Sockets","timers","warnOnce","readEmAsmArgsArray","getExecutableName","handleException","keepRuntimeAlive","runtimeKeepalivePush","callUserCallback","maybeExit","asyncLoad","alignMemory","mmapAlloc","wasmTable","wasmMemory","getUniqueRunDependency","noExitRuntime","addOnPreRun","addOnPostRun","freeTableIndexes","functionsInTableMap","setValue","getValue","PATH","PATH_FS","UTF8Decoder","UTF8ArrayToString","UTF8ToString","stringToUTF8Array","stringToUTF8","lengthBytesUTF8","intArrayFromString","AsciiToString","UTF16Decoder","UTF16ToString","stringToUTF16","lengthBytesUTF16","UTF32ToString","stringToUTF32","lengthBytesUTF32","JSEvents","specialHTMLTargets","findCanvasEventTarget","currentFullscreenStrategy","restoreOldWindowedStyle","UNWIND_CACHE","ExitStatus","getEnvStrings","checkWasiClock","doReadv","doWritev","initRandomFill","randomFill","emSetImmediate","emClearImmediate_deps","emClearImmediate","promiseMap","uncaughtExceptionCount","exceptionCaught","ExceptionInfo","findMatchingCatch","Browser","requestFullscreen","requestFullScreen","setCanvasSize","getUserMedia","createContext","getPreloadedImageData__data","wget","MONTH_DAYS_REGULAR","MONTH_DAYS_LEAP","MONTH_DAYS_REGULAR_CUMULATIVE","MONTH_DAYS_LEAP_CUMULATIVE","SYSCALLS","getSocketFromFD","getSocketAddress","preloadPlugins","FS_createPreloadedFile","FS_modeStringToFlags","FS_getMode","FS_fileDataToTypedArray","FS_stdin_getChar_buffer","FS_stdin_getChar","FS_readFile","FS_root","FS_mounts","FS_devices","FS_streams","FS_nextInode","FS_nameTable","FS_currentPath","FS_initialized","FS_ignorePermissions","FS_filesystems","FS_syncFSRequests","FS_lookupPath","FS_getPath","FS_hashName","FS_hashAddNode","FS_hashRemoveNode","FS_lookupNode","FS_createNode","FS_destroyNode","FS_isRoot","FS_isMountpoint","FS_isFile","FS_isDir","FS_isLink","FS_isChrdev","FS_isBlkdev","FS_isFIFO","FS_isSocket","FS_flagsToPermissionString","FS_nodePermissions","FS_mayLookup","FS_mayCreate","FS_mayDelete","FS_mayOpen","FS_checkOpExists","FS_nextfd","FS_getStreamChecked","FS_getStream","FS_createStream","FS_closeStream","FS_dupStream","FS_doSetAttr","FS_chrdev_stream_ops","FS_major","FS_minor","FS_makedev","FS_registerDevice","FS_getDevice","FS_getMounts","FS_syncfs","FS_mount","FS_unmount","FS_lookup","FS_mknod","FS_statfs","FS_statfsStream","FS_statfsNode","FS_create","FS_mkdir","FS_mkdev","FS_symlink","FS_rename","FS_rmdir","FS_readdir","FS_readlink","FS_stat","FS_fstat","FS_lstat","FS_doChmod","FS_chmod","FS_lchmod","FS_fchmod","FS_doChown","FS_chown","FS_lchown","FS_fchown","FS_doTruncate","FS_truncate","FS_ftruncate","FS_utime","FS_open","FS_close","FS_isClosed","FS_llseek","FS_read","FS_write","FS_mmap","FS_msync","FS_ioctl","FS_writeFile","FS_cwd","FS_chdir","FS_createDefaultDirectories","FS_createDefaultDevices","FS_createSpecialDirectories","FS_createStandardStreams","FS_staticInit","FS_init","FS_quit","FS_findObject","FS_analyzePath","FS_createFile","FS_forceLoadFile","MEMFS","TTY","PIPEFS","SOCKFS","tempFixedLengthArray","miniTempWebGLFloatBuffers","miniTempWebGLIntBuffers","GL","AL","GLUT","EGL","GLEW","IDBStore","SDL","SDL_gfx","waitAsyncPolyfilled","print","printErr","jstoi_s","PThread","terminateWorker","cleanupThread","registerTLSInit","spawnThread","exitOnMainThread","proxyToMainThread","proxiedJSCallArgs","invokeEntryPoint","checkMailbox","InternalError","BindingError","throwInternalError","throwBindingError","registeredTypes","awaitingDependencies","typeDependencies","tupleRegistrations","structRegistrations","sharedRegisterType","whenDependentTypesAreResolved","getTypeName","getFunctionName","heap32VectorToArray","requireRegisteredType","usesDestructorStack","checkArgCount","getEnumValueType","getRequiredArgCount","createJsInvoker","UnboundTypeError","EmValType","EmValOptionalType","throwUnboundTypeError","ensureOverloadTable","exposePublicSymbol","replacePublicSymbol","embindRepr","registeredInstances","getBasestPointer","getInheritedInstance","registeredPointers","registerType","integerReadValueFromPointer","enumReadValueFromPointer","floatReadValueFromPointer","assertIntegerRange","readPointer","installIndexedIterator","runDestructors","craftInvokerFunction","embind__requireFunction","genericPointerToWireType","constNoSmartPtrRawPointerToWireType","nonConstNoSmartPtrRawPointerToWireType","init_RegisteredPointer","RegisteredPointer","RegisteredPointer_fromWireType","runDestructor","releaseClassHandle","finalizationRegistry","detachFinalizer_deps","detachFinalizer","attachFinalizer","makeClassHandle","init_ClassHandle","ClassHandle","throwInstanceAlreadyDeleted","deletionQueue","flushPendingDeletes","delayFunction","RegisteredClass","shallowCopyInternalPointer","downcastPointer","upcastPointer","validateThis","char_0","char_9","makeLegalFunctionName","emval_freelist","emval_handles","emval_symbols","getStringOrSymbol","Emval","emval_returnValue","emval_lookupTypes","emval_methodCallers","emval_addMethodCaller","NODEFS"];jo.forEach(kt);var Ho=[Lt,Ut,Kt,tn,nn,an,on,sn,ln,cn,fn,_n,vn,hn,pn,Ln,Un,jn,Hn,Bn,zn,Gn];function Bo(){Se("fetchSettings"),Se("logReadFiles"),Se("loadSplitModule"),Se("onMalloc"),Se("onRealloc"),Se("onFree"),Se("onSbrkGrow")}function zo(){var e,r,t=new Promise(function(n,i){e=n,r=i});return ee.toHandle({promise:t,resolve:e,reject:r})}function Go(e,r){ee.toValue(e)(ee.toValue(r))}function Vo(e,r){ee.toValue(e)(new Error(_e(r)))}function qo(e,r,t){var n=(d(),Q).subarray(e,e+r*t);return globalThis._e57Finalizer||(globalThis._e57Finalizer=new FinalizationRegistry(function(i){he(i)})),globalThis._e57Finalizer.register(n,e),ee.toHandle(n)}var Vn=$("___getTypeName"),qn=$("__embind_initialize_bindings"),Je=f._malloc=$("_malloc"),he=f._free=$("_free"),Re=$("_pthread_self"),Kn=$("_strerror"),Ko=$("__emscripten_tls_init"),st=$("__emscripten_thread_init"),Xn=$("___set_thread_state"),Yn=$("__emscripten_thread_crashed"),lt=$("_fflush"),Ze=$("_htonl"),Pr=$("_htons"),ct=$("_emscripten_stack_get_end"),Xo=$("_emscripten_stack_get_base"),dt=$("_ntohs"),Jn=$("__emscripten_run_js_on_main_thread_done"),Zn=$("__emscripten_run_js_on_main_thread"),Qn=$("__emscripten_thread_free_data"),ut=$("__emscripten_thread_exit"),ei=$("__emscripten_check_mailbox"),W=$("_setThrew"),ri=$("_emscripten_stack_init"),ti=$("_emscripten_stack_set_limits"),Yo=$("_emscripten_stack_get_free"),ni=$("__emscripten_stack_restore"),ii=$("__emscripten_stack_alloc"),ft=$("_emscripten_stack_get_current"),ai=$("___cxa_decrement_exception_refcount"),oi=$("___cxa_get_exception_ptr"),Jo=$("__indirect_function_table"),_t=$("wasmTable");function Zo(e){_(typeof e.__getTypeName<"u","missing Wasm export: __getTypeName"),_(typeof e._embind_initialize_bindings<"u","missing Wasm export: _embind_initialize_bindings"),_(typeof e.malloc<"u","missing Wasm export: malloc"),_(typeof e.free<"u","missing Wasm export: free"),_(typeof e.pthread_self<"u","missing Wasm export: pthread_self"),_(typeof e.strerror<"u","missing Wasm export: strerror"),_(typeof e._emscripten_tls_init<"u","missing Wasm export: _emscripten_tls_init"),_(typeof e._emscripten_thread_init<"u","missing Wasm export: _emscripten_thread_init"),_(typeof e.__set_thread_state<"u","missing Wasm export: __set_thread_state"),_(typeof e._emscripten_thread_crashed<"u","missing Wasm export: _emscripten_thread_crashed"),_(typeof e.fflush<"u","missing Wasm export: fflush"),_(typeof e.htonl<"u","missing Wasm export: htonl"),_(typeof e.htons<"u","missing Wasm export: htons"),_(typeof e.emscripten_stack_get_end<"u","missing Wasm export: emscripten_stack_get_end"),_(typeof e.emscripten_stack_get_base<"u","missing Wasm export: emscripten_stack_get_base"),_(typeof e.ntohs<"u","missing Wasm export: ntohs"),_(typeof e._emscripten_run_js_on_main_thread_done<"u","missing Wasm export: _emscripten_run_js_on_main_thread_done"),_(typeof e._emscripten_run_js_on_main_thread<"u","missing Wasm export: _emscripten_run_js_on_main_thread"),_(typeof e._emscripten_thread_free_data<"u","missing Wasm export: _emscripten_thread_free_data"),_(typeof e._emscripten_thread_exit<"u","missing Wasm export: _emscripten_thread_exit"),_(typeof e._emscripten_check_mailbox<"u","missing Wasm export: _emscripten_check_mailbox"),_(typeof e.setThrew<"u","missing Wasm export: setThrew"),_(typeof e.emscripten_stack_init<"u","missing Wasm export: emscripten_stack_init"),_(typeof e.emscripten_stack_set_limits<"u","missing Wasm export: emscripten_stack_set_limits"),_(typeof e.emscripten_stack_get_free<"u","missing Wasm export: emscripten_stack_get_free"),_(typeof e._emscripten_stack_restore<"u","missing Wasm export: _emscripten_stack_restore"),_(typeof e._emscripten_stack_alloc<"u","missing Wasm export: _emscripten_stack_alloc"),_(typeof e.emscripten_stack_get_current<"u","missing Wasm export: emscripten_stack_get_current"),_(typeof e.__cxa_decrement_exception_refcount<"u","missing Wasm export: __cxa_decrement_exception_refcount"),_(typeof e.__cxa_get_exception_ptr<"u","missing Wasm export: __cxa_get_exception_ptr"),_(typeof e.__indirect_function_table<"u","missing Wasm export: __indirect_function_table"),Vn=J("__getTypeName",1),qn=J("_embind_initialize_bindings",0),Je=f._malloc=J("malloc",1),he=f._free=J("free",1),Re=e.pthread_self,Kn=J("strerror",1),Ko=J("_emscripten_tls_init",0),st=J("_emscripten_thread_init",6),Xn=J("__set_thread_state",4),Yn=J("_emscripten_thread_crashed",0),lt=J("fflush",1),Ze=J("htonl",1),Pr=J("htons",1),ct=e.emscripten_stack_get_end,Xo=e.emscripten_stack_get_base,dt=J("ntohs",1),Jn=J("_emscripten_run_js_on_main_thread_done",3),Zn=J("_emscripten_run_js_on_main_thread",5),Qn=J("_emscripten_thread_free_data",1),ut=J("_emscripten_thread_exit",1),ei=J("_emscripten_check_mailbox",0),W=J("setThrew",2),ri=e.emscripten_stack_init,ti=e.emscripten_stack_set_limits,Yo=e.emscripten_stack_get_free,ni=e._emscripten_stack_restore,ii=e._emscripten_stack_alloc,ft=e.emscripten_stack_get_current,ai=J("__cxa_decrement_exception_refcount",1),oi=J("__cxa_get_exception_ptr",1),Jo=_t=e.__indirect_function_table}var vt;function Qo(){vt={__assert_fail:Ni,__cxa_begin_catch:Mi,__cxa_end_catch:xi,__cxa_find_matching_catch_2:Wi,__cxa_find_matching_catch_3:Li,__cxa_find_matching_catch_4:Ui,__cxa_throw:ji,__pthread_create_js:Xt,__resumeException:Bi,__syscall_connect:tn,__syscall_dup:nn,__syscall_fcntl64:an,__syscall_getcwd:on,__syscall_ioctl:sn,__syscall_openat:ln,__syscall_readlinkat:cn,__syscall_recvfrom:fn,__syscall_rmdir:_n,__syscall_sendto:vn,__syscall_socket:hn,__syscall_unlinkat:pn,_abort_js:Qi,_embind_finalize_value_object:ra,_embind_register_bigint:na,_embind_register_bool:ia,_embind_register_class:Ea,_embind_register_class_class_function:Ta,_embind_register_class_constructor:Fa,_embind_register_class_function:Pa,_embind_register_class_property:Ca,_embind_register_emval:Aa,_embind_register_enum:Ra,_embind_register_enum_value:Da,_embind_register_float:$a,_embind_register_function:Na,_embind_register_integer:Ma,_embind_register_iterable:Wa,_embind_register_memory_view:La,_embind_register_optional:ja,_embind_register_std_string:Ha,_embind_register_std_wstring:Xa,_embind_register_value_object:Ya,_embind_register_value_object_field:Ja,_embind_register_void:Za,_emjs_array_view:qo,_emjs_call_reject:Vo,_emjs_call_resolve:Go,_emjs_make_deferred:zo,_emscripten_init_main_thread_js:Qa,_emscripten_notify_mailbox_postmessage:ro,_emscripten_receive_on_main_thread_js:to,_emscripten_thread_cleanup:no,_emscripten_thread_mailbox_await:it,_emscripten_thread_set_strongref:io,_emval_create_invoker:co,_emval_decref:tt,_emval_get_property:uo,_emval_incref:fo,_emval_invoke:Mn,_emval_invoke_i64:_o,_emval_new_cstring:vo,_emval_run_destructors:ho,_tzset_js:po,clock_time_get:bo,emscripten_check_blocking_allowed:So,emscripten_err:ko,emscripten_exit_with_live_runtime:Fo,emscripten_get_now:xn,emscripten_resize_heap:Oo,environ_get:Ln,environ_sizes_get:Un,exit:Lr,fd_close:jn,fd_read:Hn,fd_seek:Bn,fd_write:zn,getaddrinfo:Gn,invoke_i:gs,invoke_ii:es,invoke_iii:rs,invoke_iiii:_s,invoke_iiiii:ms,invoke_iiij:cs,invoke_iiijjj:Ts,invoke_iij:os,invoke_iiji:ns,invoke_iijiiiiiii:as,invoke_ji:Es,invoke_jiii:Ss,invoke_jiiiijijii:Fs,invoke_v:ys,invoke_vi:ds,invoke_vii:ls,invoke_viii:ts,invoke_viiii:ps,invoke_viiiii:hs,invoke_viiiiii:ks,invoke_viiiiijijii:Ps,invoke_viiiijijii:ws,invoke_viij:bs,invoke_viijii:us,invoke_vij:is,invoke_viji:vs,invoke_vijj:ss,invoke_vijjii:fs,llvm_eh_typeid_for:$o,memory:fe,random_get:No}}function es(e,r){var t=U();try{return x(e)(r)}catch(n){if(M(t),!(n instanceof L))throw n;W(1,0)}}function rs(e,r,t){var n=U();try{return x(e)(r,t)}catch(i){if(M(n),!(i instanceof L))throw i;W(1,0)}}function ts(e,r,t,n){var i=U();try{x(e)(r,t,n)}catch(a){if(M(i),!(a instanceof L))throw a;W(1,0)}}function ns(e,r,t,n){var i=U();try{return x(e)(r,t,n)}catch(a){if(M(i),!(a instanceof L))throw a;W(1,0)}}function is(e,r,t){var n=U();try{x(e)(r,t)}catch(i){if(M(n),!(i instanceof L))throw i;W(1,0)}}function as(e,r,t,n,i,a,s,l,c,u){var v=U();try{return x(e)(r,t,n,i,a,s,l,c,u)}catch(h){if(M(v),!(h instanceof L))throw h;W(1,0)}}function os(e,r,t){var n=U();try{return x(e)(r,t)}catch(i){if(M(n),!(i instanceof L))throw i;W(1,0)}}function ss(e,r,t,n){var i=U();try{x(e)(r,t,n)}catch(a){if(M(i),!(a instanceof L))throw a;W(1,0)}}function ls(e,r,t){var n=U();try{x(e)(r,t)}catch(i){if(M(n),!(i instanceof L))throw i;W(1,0)}}function cs(e,r,t,n){var i=U();try{return x(e)(r,t,n)}catch(a){if(M(i),!(a instanceof L))throw a;W(1,0)}}function ds(e,r){var t=U();try{x(e)(r)}catch(n){if(M(t),!(n instanceof L))throw n;W(1,0)}}function us(e,r,t,n,i,a){var s=U();try{x(e)(r,t,n,i,a)}catch(l){if(M(s),!(l instanceof L))throw l;W(1,0)}}function fs(e,r,t,n,i,a){var s=U();try{x(e)(r,t,n,i,a)}catch(l){if(M(s),!(l instanceof L))throw l;W(1,0)}}function _s(e,r,t,n){var i=U();try{return x(e)(r,t,n)}catch(a){if(M(i),!(a instanceof L))throw a;W(1,0)}}function vs(e,r,t,n){var i=U();try{x(e)(r,t,n)}catch(a){if(M(i),!(a instanceof L))throw a;W(1,0)}}function hs(e,r,t,n,i,a){var s=U();try{x(e)(r,t,n,i,a)}catch(l){if(M(s),!(l instanceof L))throw l;W(1,0)}}function ps(e,r,t,n,i){var a=U();try{x(e)(r,t,n,i)}catch(s){if(M(a),!(s instanceof L))throw s;W(1,0)}}function ms(e,r,t,n,i){var a=U();try{return x(e)(r,t,n,i)}catch(s){if(M(a),!(s instanceof L))throw s;W(1,0)}}function gs(e){var r=U();try{return x(e)()}catch(t){if(M(r),!(t instanceof L))throw t;W(1,0)}}function ys(e){var r=U();try{x(e)()}catch(t){if(M(r),!(t instanceof L))throw t;W(1,0)}}function ws(e,r,t,n,i,a,s,l,c,u){var v=U();try{x(e)(r,t,n,i,a,s,l,c,u)}catch(h){if(M(v),!(h instanceof L))throw h;W(1,0)}}function Es(e,r){var t=U();try{return x(e)(r)}catch(n){if(M(t),!(n instanceof L))throw n;return W(1,0),0n}}function bs(e,r,t,n){var i=U();try{x(e)(r,t,n)}catch(a){if(M(i),!(a instanceof L))throw a;W(1,0)}}function Ss(e,r,t,n){var i=U();try{return x(e)(r,t,n)}catch(a){if(M(i),!(a instanceof L))throw a;return W(1,0),0n}}function ks(e,r,t,n,i,a,s){var l=U();try{x(e)(r,t,n,i,a,s)}catch(c){if(M(l),!(c instanceof L))throw c;W(1,0)}}function Ts(e,r,t,n,i,a){var s=U();try{return x(e)(r,t,n,i,a)}catch(l){if(M(s),!(l instanceof L))throw l;W(1,0)}}function Fs(e,r,t,n,i,a,s,l,c,u){var v=U();try{return x(e)(r,t,n,i,a,s,l,c,u)}catch(h){if(M(v),!(h instanceof L))throw h;return W(1,0),0n}}function Ps(e,r,t,n,i,a,s,l,c,u,v){var h=U();try{x(e)(r,t,n,i,a,s,l,c,u,v)}catch(p){if(M(h),!(p instanceof L))throw p;W(1,0)}}var si;function Cs(){_(!w),ri(),bt()}function Cr(){if(Te>0){Ge=Cr;return}if(w){Ir?.(f),Ct();return}if(Cs(),bi(),Te>0){Ge=Cr;return}function e(){_(!si),si=!0,f.calledRun=!0,!Ie&&(Ct(),Ir?.(f),f.onRuntimeInitialized?.(),ar("onRuntimeInitialized"),_(!f._main,'compiled without a main, but one is present. if you added it from JS, use Module["onRuntimeInitialized"]'),Si())}f.setStatus?(f.setStatus("Running..."),setTimeout(()=>{setTimeout(()=>f.setStatus(""),1),e()},1)):e(),ze()}function As(){var e=ge,r=A,t=!1;ge=A=c=>{t=!0};try{lt(0);for(var n of["stdout","stderr"]){var i=o.analyzePath("/dev/"+n);if(!i)return;var a=i.object,s=a.rdev,l=pe.ttys[s];l?.output?.length&&(t=!0)}}catch{}ge=e,A=r,t&&Fe("stdio streams had content in them that was not flushed. you should set EXIT_RUNTIME to 1 (see the Emscripten FAQ), or make sure to emit a newline when you printf etc.")}var De;w||(De=await Ot(),Cr()),Ne?m=f:m=new Promise((e,r)=>{Ir=e,$r=r});for(let e of Object.keys(f))e in se||Object.defineProperty(se,e,{configurable:!0,get(){q(`Access to module property ('${e}') is no longer possible via the module constructor argument; Instead, use the result of the module constructor.`)}});return m}var ci=li,di=globalThis.name?.startsWith("em-pthread"),Os=globalThis.process?.versions?.node&&globalThis.process?.type!="renderer";Os&&(di=(await import("node:worker_threads")).workerData==="em-pthread");di&&li();var re=class se{static LibE57=null;static RootDir="/root ";static Init(){return se.LibE57!==null?Promise.resolve():ci().then(function(m){m.FS.mkdir(se.RootDir),m.FS.mount(m.FS.filesystems.NODEFS,{root:"/"},se.RootDir),se.LibE57=m})}};import ht from"path";import Rs from"fs";var pt=class{constructor(m,f){this.e57Reader=m,this.scanIdx=f}GetHeader(){return this.e57Reader.GetData3DHeader(this.scanIdx)}ReadScan(m=!0){var f=this.GetHeader(),j=f.pointCount;return this.ReadPoints(j,m)}ReadScanSync(m=!0){let f=Number(this.GetHeader().pointCount);return this.ReadPointsSync(f,m)}ReadPoints(m,f=!0){return this.e57Reader.ReadScan(this.scanIdx,m,f)}ReadPointsSync(m,f=!0){return this.e57Reader.ReadScanSync(this.scanIdx,m,f)}ScanPoints(m,f,j=!0){let B=Number(this.GetHeader().pointCount),C=Math.ceil(B/m);if(f){for(let w=0;w<C;w++)f(this.ReadPointsSync(m,j));return}let me=[];for(let w=0;w<C;w++)me.push(this.ReadPointsSync(m,j));return me}},mt=class{constructor(m,f){this._e57Reader=m,this._imageIdx=f}GetHeader(){return this._e57Reader.GetImage2DHeader(this._imageIdx)}ReadImage(){return this._e57Reader.ReadImage(this._imageIdx)}ReadImageSync(){return this._e57Reader.ReadImageSync(this._imageIdx)}ToBase64(){return this.ReadImage().then(m=>Buffer.from(m).toString("base64"))}Extension(){switch(this.GetHeader().imageType){case re.LibE57.Image2DType.ImageJPEG:return".jpeg";case re.LibE57.Image2DType.ImagePNG:return".png";case re.LibE57.Image2DType.ImageMaskPNG:return".png";case re.LibE57.Image2DType.E57_JPEG_IMAGE:return".jpeg";case re.LibE57.Image2DType.E57_PNG_IMAGE:return".png";case re.LibE57.Image2DType.E57_PNG_IMAGE_MASK:return".png";default:return".jpg"}}Save(m){let f=this.Extension(),j=m.replace(ht.extname(m),f);return this.ReadImage().then(B=>Rs.writeFile(j,B,C=>{if(C)throw C}))}},ui=class{constructor(m){let f=ht.resolve(m),j=ht.join(re.RootDir,f);this.reader=new re.LibE57.E57Reader(j);var B=this.GetData3DCount();this.scans=new Array(B);for(var C=0;C<B;C++)this.scans[C]=new pt(this.reader,C);var me=this.GetImage2DCount();this.images=new Array(me);for(var w=0;w<me;w++)this.images[w]=new mt(this.reader,w)}GetHeader(){return this.reader.GetHeader()}GetData3DCount(){return Number(this.reader.GetData3DCount())}GetImage2DCount(){return Number(this.reader.GetImage2DCount())}GetScan(m){return this.scans[m]}GetImage(m){return this.images[m]}};import fi from"path";import hi from"fs";import er from"sharp";var _i=class{constructor(m,f,j){this._imgPath=m,this._imgType=f,this._imgProjection=j,this._imageHeader=new re.LibE57.ImageHeader}getPath(){return this._imgPath}setPath(m){this._imgPath=m}getType(){return this._imgType}setType(m){this._imgType=m}getProjection(){return this._imgProjection}setProjection(m){this._imgProjection=m}getMetadata(){return er(this._imgPath).metadata()}async getDimensions(){let m=await er(this._imgPath).metadata();return[m.width,m.height]}async getWidth(){return(await er(this._imgPath).metadata()).width}async getHeight(){return(await er(this._imgPath).metadata()).height}getPose(){return this._imageHeader.pose}setPose(m){this._imageHeader.pose=m}getName(){return this._imageHeader.name}setName(m){this._imageHeader.name=m}getGuid(){return this._imageHeader.guid}setGuid(m){this._imageHeader.guid=m}getHeader(){return this._imageHeader}setHeader(m){this._imageHeader=m}async getBuffer(){let m=await hi.promises.readFile(this.getPath());return new Uint8Array(m)}setTrasnlation(m,f,j){this._imageHeader.pose.translation.x=m,this._imageHeader.pose.translation.y=f,this._imageHeader.pose.translation.z=j}setRotation(m,f,j,B){this._imageHeader.pose.rotation.w=m,this._imageHeader.pose.rotation.x=f,this._imageHeader.pose.rotation.y=j,this._imageHeader.pose.rotation.z=B}},vi=class{constructor(m){let f=fi.resolve(m),j=fi.join(re.RootDir,f);this.writer=new re.LibE57.E57Writer(j)}AddImageSync(m,f,j){let B=hi.readFileSync(m.getPath()),C=new Uint8Array(B);return Number(this.writer.AddImageSync(m.getHeader(),m.getType(),m.getProjection(),0,C,C.length,f,j))}async AddImage(m){let[f,j]=await Promise.all([m.getBuffer(),er(m.getPath()).metadata()]),B=new Uint8Array(f);return this.writer.AddImage(m.getHeader(),m.getType(),m.getProjection(),0,B,B.length,j.width,j.height).then(Number)}AddScanSync(m,f){return Number(this.writer.AddScanSync(m,f))}AddScan(m,f){return this.writer.AddScan(m,f).then(Number)}Close(){this.writer.Close()}};export{re as E57,ui as E57Reader,mt as E57ReaderImage,pt as E57ReaderScan,vi as E57Writer,_i as E57WriterImage};
|
|
19
|
+
`,p.push("checkArgCount","minArgs","maxArgs"),u=`if (arguments.length !== ${p.length}){ throw new Error(humanName + "Expected ${p.length} closure arguments " + arguments.length + " given."); }
|
|
20
|
+
${u}`,new Function(p,u)}function ka(e){for(var r=e.length-2,t=e.length-1;t>=2&&e[t].optional;--t)r--;return r}function br(e,r,t,n,i,a){var s=r.length;s<2&&A("argTypes array size mismatch! Must at least get return value and 'this' types!"),h(!a,"async bindings are only supported with JSPI");for(var l=r[1]!==null&&t!==null,d=Fn(r),u=!r[0].isVoid,_=s-2,p=ka(r),m=r[0],g=r[1],E=[e,A,n,i,_r,m.fromWireType.bind(m),g?.toWireType.bind(g)],k=2;k<s;++k){var D=r[k];E.push(D.toWireType.bind(D))}if(!d)for(var k=l?1:2;k<r.length;++k)r[k].destructorFunction!==null&&E.push(r[k].destructorFunction);E.push(ba,p,_);var G=Sa(r,l,u,a)(...E);return yr(e,G)}var Sr=(e,r)=>{for(var t=[],n=0;n<e;n++)t.push((c(),y)[r+n*4>>2]);return t},et=e=>{e=e.trim();let r=e.indexOf("(");return r===-1?e:(h(e.endsWith(")"),"Parentheses for argument names should match."),e.slice(0,r))},Ta=(e,r,t,n,i,a,s,l,d)=>{var u=Sr(t,n);r=Y(r),r=et(r),a=ae(i,a,l),ce([],[e],_=>{_=_[0];var p=`${_.name}.${r}`;function m(){Oe(`Cannot call ${p} due to unbound types`,u)}r.startsWith("@@")&&(r=Symbol[r.substring(2)]);var g=_.registeredClass.constructor;return g[r]===void 0?(m.argCount=t-1,g[r]=m):(Qr(g,r,p),g[r].overloadTable[t-1]=m),ce([],u,E=>{var k=[E[0],null].concat(E.slice(1)),D=br(p,k,null,a,s,l);if(g[r].overloadTable===void 0?(D.argCount=t-1,g[r]=D):g[r].overloadTable[t-1]=D,_.registeredClass.__derivedClasses)for(let R of _.registeredClass.__derivedClasses)R.constructor.hasOwnProperty(r)||(R.constructor[r]=D);return[]}),[]})},Fa=(e,r,t,n,i,a)=>{h(r>0);var s=Sr(r,t);i=ae(n,i);var l=[a],d=[];ce([],[e],u=>{u=u[0];var _=`constructor ${u.name}`;if(u.registeredClass.constructor_body===void 0&&(u.registeredClass.constructor_body=[]),u.registeredClass.constructor_body[r-1]!==void 0)throw new qe(`Cannot register multiple constructors with identical number of parameters (${r-1}) for class '${u.name}'! Overload resolution is currently only performed using the parameter count, not actual type info!`);return u.registeredClass.constructor_body[r-1]=()=>{Oe(`Cannot construct ${u.name} due to unbound types`,s)},ce([],s,p=>(p.splice(1,0,null),u.registeredClass.constructor_body[r-1]=br(_,p,null,i,a),[])),[]})},Pa=(e,r,t,n,i,a,s,l,d,u)=>{var _=Sr(t,n);r=Y(r),r=et(r),a=ae(i,a,d),ce([],[e],p=>{p=p[0];var m=`${p.name}.${r}`;r.startsWith("@@")&&(r=Symbol[r.substring(2)]),l&&p.registeredClass.pureVirtualFunctions.push(r);function g(){Oe(`Cannot call ${m} due to unbound types`,_)}var E=p.registeredClass.instancePrototype,k=E[r];return k===void 0||k.overloadTable===void 0&&k.className!==p.name&&k.argCount===t-2?(g.argCount=t-2,g.className=p.name,E[r]=g):(Qr(E,r,m),E[r].overloadTable[t-2]=g),ce([],_,D=>{var R=br(m,D,p,a,s,d);return E[r].overloadTable===void 0?(R.argCount=t-2,E[r]=R):E[r].overloadTable[t-2]=R,[]}),[]})},Pn=(e,r,t)=>(e instanceof Object||A(`${t} with invalid "this": ${e}`),e instanceof r.registeredClass.constructor||A(`${t} incompatible with "this" of type ${e.constructor.name}`),e.$$.ptr||A(`cannot call emscripten binding method ${t} on deleted object`),wr(e.$$.ptr,e.$$.ptrType.registeredClass,r.registeredClass)),Ca=(e,r,t,n,i,a,s,l,d,u)=>{r=Y(r),i=ae(n,i),ce([],[e],_=>{_=_[0];var p=`${_.name}.${r}`,m={get(){Oe(`Cannot access ${p} due to unbound types`,[t,s])},enumerable:!0,configurable:!0};return d?m.set=()=>Oe(`Cannot access ${p} due to unbound types`,[t,s]):m.set=g=>A(p+" is a read-only property"),Object.defineProperty(_.registeredClass.instancePrototype,r,m),ce([],d?[t,s]:[t],g=>{var E=g[0],k={get(){var R=Pn(this,_,p+" getter");return E.fromWireType(i(a,R))},enumerable:!0};if(d){d=ae(l,d);var D=g[1];k.set=function(R){var G=Pn(this,_,p+" setter"),z=[];d(u,G,D.toWireType(z,R)),_r(z)}}return Object.defineProperty(_.registeredClass.instancePrototype,r,k),[]}),[]})},Cn=[],ue=[0,1,,1,null,1,!0,1,!1,1],rt=e=>{if(e>9&&--ue[e+1]===0){h(ue[e]!==void 0,"decref for unallocated handle");var r=ue[e];ue[e]=void 0,Cn.push(e)}},re={toValue:e=>(e||A(`Cannot use deleted val. handle = ${e}`),h(e===2||ue[e]!==void 0&&e%2===0,`invalid handle: ${e}`),ue[e]),toHandle:e=>{switch(e){case void 0:return 2;case null:return 4;case!0:return 6;case!1:return 8;default:{let r=Cn.pop()||ue.length;return ue[r]=e,ue[r+1]=1,r}}}},An={name:"emscripten::val",fromWireType:e=>{var r=re.toValue(e);return rt(e),r},toWireType:(e,r)=>re.toHandle(r),readValueFromPointer:Ve,destructorFunction:null},Aa=e=>ie(e,An),tt=(e,r,t)=>{switch(r){case 1:return t?function(n){return this.fromWireType((c(),H)[n])}:function(n){return this.fromWireType((c(),te)[n])};case 2:return t?function(n){return this.fromWireType((c(),ne)[n>>1])}:function(n){return this.fromWireType((c(),ke)[n>>1])};case 4:return t?function(n){return this.fromWireType((c(),S)[n>>2])}:function(n){return this.fromWireType((c(),y)[n>>2])};default:throw new TypeError(`invalid integer width (${r}): ${e}`)}};function Oa(e){return e===0?"object":e===1?"number":"string"}var Da=(e,r,t,n,i)=>{r=Y(r);let a=Oa(i);switch(a){case"object":{let u=function(){};u.values={},ie(e,{name:r,constructor:u,valueType:a,fromWireType:function(_){return this.constructor.values[_]},toWireType:(_,p)=>p.value,readValueFromPointer:tt(r,t,n),destructorFunction:null}),Xe(r,u);break}case"number":{var s={};ie(e,{name:r,keysMap:s,valueType:a,fromWireType:u=>u,toWireType:(u,_)=>_,readValueFromPointer:tt(r,t,n),destructorFunction:null}),Xe(r,s),delete f[r].argCount;break}case"string":{var l={},d={},s={};ie(e,{name:r,valuesMap:l,reverseMap:d,keysMap:s,valueType:a,fromWireType:function(_){return this.reverseMap[_]},toWireType:function(_,p){return this.valuesMap[p]},readValueFromPointer:tt(r,t,n),destructorFunction:null}),Xe(r,s),delete f[r].argCount;break}}},On=(e,r)=>{var t=Ce[e];return t===void 0&&A(`${r} has unknown type ${Tn(e)}`),t},Ra=(e,r,t)=>{var n=On(e,"enum");switch(r=Y(r),n.valueType){case"object":{var i=n.constructor,a=Object.create(n.constructor.prototype,{value:{value:t},constructor:{value:yr(`${n.name}_${r}`,function(){})}});i.values[t]=a,i[r]=a;break}case"number":{n.keysMap[r]=t;break}case"string":{n.valuesMap[r]=t,n.reverseMap[t]=r,n.keysMap[r]=r;break}}},Ia=(e,r)=>{switch(r){case 4:return function(t){return this.fromWireType((c(),or)[t>>2])};case 8:return function(t){return this.fromWireType((c(),Me)[t>>3])};default:throw new TypeError(`invalid float width (${r}): ${e}`)}},$a=(e,r,t)=>{r=Y(r),ie(e,{name:r,fromWireType:n=>n,toWireType:(n,i)=>{if(typeof i!="number"&&typeof i!="boolean")throw new TypeError(`Cannot convert ${Ae(i)} to ${r}`);return i},readValueFromPointer:Ia(r,t),destructorFunction:null})},Na=(e,r,t,n,i,a,s,l)=>{var d=Sr(r,t);e=Y(e),e=et(e),i=ae(n,i,s),Xe(e,function(){Oe(`Cannot call ${e} due to unbound types`,d)},r-1),ce([],d,u=>{var _=[u[0],null].concat(u.slice(1));return kn(e,br(e,_,null,i,a,s),r-1),[]})},Ma=(e,r,t,n,i)=>{r=Y(r);let a=n===0,s=d=>d;if(a){var l=32-8*t;s=d=>d<<l>>>l,i=s(i)}ie(e,{name:r,fromWireType:s,toWireType:(d,u)=>{if(typeof u!="number"&&typeof u!="boolean")throw new TypeError(`Cannot convert "${Ae(u)}" to ${r}`);return mn(r,u,n,i),u},readValueFromPointer:pn(r,t,n!==0),destructorFunction:null})},xa=(e,r,t)=>{let n=(i,a)=>{let s=0;return{next(){if(s>=i)return{done:!0};let l=s;return s++,{value:a(l),done:!1}},[Symbol.iterator](){return this}}};e[Symbol.iterator]||(e[Symbol.iterator]=function(){let i=this[r]();return n(i,a=>this[t](a))})},La=(e,r,t,n)=>{t=Y(t),n=Y(n),ce([],[e,r],i=>{let a=i[0];return xa(a.registeredClass.instancePrototype,t,n),[]})},Wa=(e,r,t)=>{var n=[Int8Array,Uint8Array,Int16Array,Uint16Array,Int32Array,Uint32Array,Float32Array,Float64Array,BigInt64Array,BigUint64Array],i=n[r];function a(s){var l=(c(),y)[s>>2],d=(c(),y)[s+4>>2];return new i((c(),H).buffer,d,l)}t=Y(t),ie(e,{name:t,fromWireType:a,readValueFromPointer:a},{ignoreDuplicateRegistrations:!0})},Ua=Object.assign({optional:!0},An),ja=(e,r)=>{ie(e,Ua)},Ba=(e,r)=>{r=Y(r);var t=!0;ie(e,{name:r,fromWireType(n){var i=(c(),y)[n>>2],a=n+4,s;if(t)s=_e(a,i,!0);else{s="";for(var l=0;l<i;++l)s+=String.fromCharCode((c(),te)[a+l])}return ve(n),s},toWireType(n,i){i instanceof ArrayBuffer&&(i=new Uint8Array(i));var a,s=typeof i=="string";s||ArrayBuffer.isView(i)&&i.BYTES_PER_ELEMENT==1||A("Cannot pass non-string to std::string"),t&&s?a=Pe(i):a=i.length;var l=Je(4+a+1),d=l+4;if((c(),y)[l>>2]=a,s)if(t)Ee(i,d,a+1);else for(var u=0;u<a;++u){var _=i.charCodeAt(u);_>255&&(ve(l),A("String has UTF-16 code units that do not fit in 8 bits")),(c(),te)[d+u]=_}else(c(),te).set(i,d);return n!==null&&n.push(ve,l),l},readValueFromPointer:Ve,destructorFunction(n){ve(n)}})},Dn=globalThis.TextDecoder?new TextDecoder("utf-16le"):void 0,Ha=(e,r,t)=>{h(e%2==0,"pointer passed to UTF16ToString must be 2-byte aligned");var n=e>>1,i=Gt((c(),ke),n,r/2,t);if(i-n>16&&Dn)return Dn.decode((c(),ke).slice(n,i));for(var a="",s=n;s<i;++s){var l=(c(),ke)[s];a+=String.fromCharCode(l)}return a},Ga=(e,r,t)=>{if(h(r%2==0,"pointer passed to stringToUTF16 must be 2-byte aligned"),h(typeof t=="number","stringToUTF16 requires a third parameter that specifies the length of the output buffer"),t??=2147483647,t<2)return 0;t-=2;for(var n=r,i=t<e.length*2?t/2:e.length,a=0;a<i;++a){var s=e.charCodeAt(a);(c(),ne)[r>>1]=s,r+=2}return(c(),ne)[r>>1]=0,r-n},za=e=>e.length*2,Va=(e,r,t)=>{h(e%4==0,"pointer passed to UTF32ToString must be 2-byte aligned");for(var n="",i=e>>2,a=0;!(a>=r/4);a++){var s=(c(),y)[i+a];if(!s&&!t)break;n+=String.fromCodePoint(s)}return n},qa=(e,r,t)=>{if(h(r%4==0,"pointer passed to stringToUTF32 must be 4-byte aligned"),h(typeof t=="number","stringToUTF32 requires a third parameter that specifies the length of the output buffer"),t??=2147483647,t<4)return 0;for(var n=r,i=n+t-4,a=0;a<e.length;++a){var s=e.codePointAt(a);if(s>65535&&a++,(c(),S)[r>>2]=s,r+=4,r+4>i)break}return(c(),S)[r>>2]=0,r-n},Ka=e=>{for(var r=0,t=0;t<e.length;++t){var n=e.codePointAt(t);n>65535&&t++,r+=4}return r},Xa=(e,r,t)=>{t=Y(t);var n,i,a;r===2?(n=Ha,i=Ga,a=za):(h(r===4,"only 2-byte and 4-byte strings are currently supported"),n=Va,i=qa,a=Ka),ie(e,{name:t,fromWireType:s=>{var l=(c(),y)[s>>2],d=n(s+4,l*r,!0);return ve(s),d},toWireType:(s,l)=>{typeof l!="string"&&A(`Cannot pass non-string to C++ string type ${t}`);var d=a(l),u=Je(4+d+r);return(c(),y)[u>>2]=d/r,i(l,u+4,d+r),s!==null&&s.push(ve,u),u},readValueFromPointer:Ve,destructorFunction(s){ve(s)}})},Ya=(e,r,t,n,i,a)=>{fr[e]={name:Y(r),rawConstructor:ae(t,n),rawDestructor:ae(i,a),fields:[]}},Ja=(e,r,t,n,i,a,s,l,d,u)=>{fr[e].fields.push({fieldName:Y(r),getterReturnType:t,getter:ae(n,i),getterContext:a,setterArgumentType:s,setter:ae(l,d),setterContext:u})},Za=(e,r)=>{r=Y(r),ie(e,{isVoid:!0,name:r,fromWireType:()=>{},toWireType:(t,n)=>{}})},Qa=e=>{ot(e,!N,1,!O,65536,!1),P.threadInitTLS()},Rn=e=>{if(e instanceof Ot||e=="unwind")return $e;Ge(),e instanceof WebAssembly.RuntimeError&&ut()<=0&&C("Stack overflow detected. You can try increasing -sSTACK_SIZE (currently set to 65536)"),Ar(1,e)},eo=()=>{if(!lr())try{if(w){De()&&ct($e);return}Lr($e)}catch(e){Rn(e)}},In=e=>{if(Ie){C("user callback triggered after runtime exited or application aborted. Ignoring.");return}try{return e()}catch(r){Rn(r)}finally{eo()}},nt=e=>{if(!Ut){var r=Atomics.waitAsync((c(),S),e>>2,e);h(r.async),r.value.then(kr);var t=e+120;Atomics.store((c(),S),t>>2,1)}},kr=()=>{var e=De();e&&In(()=>{nt(e),Qn()})},ro=(e,r)=>{if(e==r)setTimeout(kr);else if(w)postMessage({targetThread:e,cmd:"checkMailbox"});else{var t=P.pthreads[e];if(!t){C(`Cannot send message to thread with ID ${e}, unknown thread ID!`);return}t.postMessage({cmd:"checkMailbox"})}},Tr=[],to=(e,r,t,n,i,a,s)=>{Tr.length=0;for(var l=i>>3,d=i+n>>3;l<d;){var u;(c(),Z)[l++]?u=(c(),Z)[l++]:u=(c(),Me)[l++],Tr.push(u)}h(!r);var _=Ho[e];h(!(e&&r)),h(_.length==Tr.length,"Call args mismatch in _emscripten_receive_on_main_thread_js"),P.currentProxiedOperationCallerThread=t;var p=_(...Tr);if(P.currentProxiedOperationCallerThread=0,a){p.then(m=>Yn(a,s,m));return}return h(typeof p!="bigint"),p},no=e=>{w?postMessage({cmd:"cleanupThread",thread:e}):It(e)},io=e=>{M&&P.pthreads[e].ref()},ao=(e,r)=>{e=re.toValue(e),r=re.toValue(r),e.set(r)},it=[],oo=e=>{var r=it.length;return it.push(e),r},so=(e,r)=>{for(var t=new Array(e),n=0;n<e;++n)t[n]=On((c(),y)[r+n*4>>2],`parameter ${n}`);return t},lo=(e,r,t)=>{var n=[],i=e(n,t);return n.length&&((c(),y)[r>>2]=re.toHandle(n)),i},co={},$n=e=>{var r=co[e];return r===void 0?Y(e):r},uo=(e,r,t)=>{var n=8,[i,...a]=so(e,r),s=i.toWireType.bind(i),l=a.map(g=>g.readValueFromPointer.bind(g));e--;var d={toValue:re.toValue},u=l.map((g,E)=>{var k=`argFromPtr${E}`;return d[k]=g,`${k}(args${E?"+"+E*n:""})`}),_;switch(t){case 0:_="toValue(handle)";break;case 2:_="new (toValue(handle))";break;case 3:_="";break;case 1:d.getStringOrSymbol=$n,_="toValue(handle)[getStringOrSymbol(methodName)]";break}_+=`(${u})`,i.isVoid||(d.toReturnWire=s,d.emval_returnValue=lo,_=`return emval_returnValue(toReturnWire, destructorsRef, ${_})`),_=`return function (handle, methodName, destructorsRef, args) {
|
|
21
|
+
${_}
|
|
22
|
+
}`;var p=new Function(Object.keys(d),_)(...Object.values(d)),m=`methodCaller<(${a.map(g=>g.name)}) => ${i.name}>`;return oo(yr(m,p))},fo=(e,r)=>(e=re.toValue(e),r=re.toValue(r),re.toHandle(e[r])),_o=e=>{e>9&&(ue[e+1]+=1)},Nn=(e,r,t,n,i)=>it[e](r,t,n,i),ho=(e,r,t,n,i)=>Nn(e,r,t,n,i),vo=e=>re.toHandle($n(e)),po=e=>{var r=re.toValue(e);_r(r),rt(e)},mo=(e,r,t,n)=>{var i=new Date().getFullYear(),a=new Date(i,0,1),s=new Date(i,6,1),l=a.getTimezoneOffset(),d=s.getTimezoneOffset(),u=Math.max(l,d);(c(),y)[e>>2]=u*60,(c(),S)[r>>2]=+(l!=d);var _=g=>{var E=g>=0?"-":"+",k=Math.abs(g),D=String(Math.floor(k/60)).padStart(2,"0"),R=String(k%60).padStart(2,"0");return`UTC${E}${D}${R}`},p=_(l),m=_(d);h(p),h(m),h(Pe(p)<=16,`timezone name truncated to fit in TZNAME_MAX (${p})`),h(Pe(m)<=16,`timezone name truncated to fit in TZNAME_MAX (${m})`),d<l?(Ee(p,t,17),Ee(m,n,17)):(Ee(p,n,17),Ee(m,t,17))},Mn=()=>performance.timeOrigin+performance.now(),go=()=>Date.now(),yo=1,wo=e=>e>=0&&e<=3,Eo=9007199254740992,bo=-9007199254740992,xn=e=>e<bo||e>Eo?NaN:Number(e);function So(e,r,t){if(r=xn(r),!wo(e))return 28;var n;if(e===0)n=go();else if(yo)n=Mn();else return 52;var i=Math.round(n*1e3*1e3);return(c(),Z)[t>>3]=BigInt(i),0}var ko=()=>{M||N||Fe("Blocking on the main thread is very dangerous, see https://emscripten.org/docs/porting/pthreads.html#blocking-on-the-main-browser-thread")},To=e=>C(_e(e)),Fo=()=>{sr+=1},Po=()=>{throw Fo(),"unwind"},Co=()=>2147483648,Ao=(e,r)=>(h(r,"alignment argument is required"),Math.ceil(e/r)*r),Oo=e=>{var r=fe.buffer.byteLength,t=(e-r+65535)/65536|0;try{return fe.grow(t),ar(),1}catch(n){C(`growMemory: Attempted to grow heap from ${r} bytes to ${e} bytes, but got error: ${n}`)}},Do=e=>{var r=(c(),te).length;if(e>>>=0,e<=r)return!1;var t=Co();if(e>t)return C(`Cannot enlarge memory, requested ${e} bytes, but the limit is ${t} bytes!`),!1;for(var n=1;n<=4;n*=2){var i=r*(1+.2/n);i=Math.min(i,e+100663296);var a=Math.min(t,Ao(Math.max(e,i),65536)),s=Oo(a);if(s)return!0}return C(`Failed to grow the heap from ${r} bytes to ${a} bytes, not enough memory!`),!1},at={},Ro=()=>Cr||"./this.program",Ye=()=>{if(!Ye.strings){var e=(globalThis.navigator?.language??"C").replace("-","_")+".UTF-8",r={USER:"web_user",LOGNAME:"web_user",PATH:"/",PWD:"/",HOME:"/home/web_user",LANG:e,_:Ro()};for(var t in at)at[t]===void 0?delete r[t]:r[t]=at[t];var n=[];for(var t in r)n.push(`${t}=${r[t]}`);Ye.strings=n}return Ye.strings};function Ln(e,r){if(w)return K(15,0,1,e,r);var t=0,n=0;for(var i of Ye()){var a=r+t;(c(),y)[e+n>>2]=a,t+=Ee(i,a,1/0)+1,n+=4}return 0}function Wn(e,r){if(w)return K(16,0,1,e,r);var t=Ye();(c(),y)[e>>2]=t.length;var n=0;for(var i of t)n+=Pe(i)+1;return(c(),y)[r>>2]=n,0}function Un(e){if(w)return K(17,0,1,e);try{var r=X.getStreamFromFD(e);return o.close(r),0}catch(t){if(typeof o>"u"||t.name!=="ErrnoError")throw t;return t.errno}}var Io=(e,r,t,n)=>{for(var i=0,a=0;a<t;a++){var s=(c(),y)[r>>2],l=(c(),y)[r+4>>2];r+=8;var d=o.read(e,(c(),H),s,l,n);if(d<0)return-1;if(i+=d,d<l)break;typeof n<"u"&&(n+=d)}return i};function jn(e,r,t,n){if(w)return K(18,0,1,e,r,t,n);try{var i=X.getStreamFromFD(e),a=Io(i,r,t);return(c(),y)[n>>2]=a,0}catch(s){if(typeof o>"u"||s.name!=="ErrnoError")throw s;return s.errno}}function Bn(e,r,t,n){if(w)return K(19,0,1,e,r,t,n);r=xn(r);try{if(isNaN(r))return 22;var i=X.getStreamFromFD(e);return o.llseek(i,r,t),(c(),Z)[n>>3]=BigInt(i.position),i.getdents&&r===0&&t===0&&(i.getdents=null),0}catch(a){if(typeof o>"u"||a.name!=="ErrnoError")throw a;return a.errno}}var $o=(e,r,t,n)=>{for(var i=0,a=0;a<t;a++){var s=(c(),y)[r>>2],l=(c(),y)[r+4>>2];r+=8;var d=o.write(e,(c(),H),s,l,n);if(d<0)return-1;if(i+=d,d<l)break;typeof n<"u"&&(n+=d)}return i};function Hn(e,r,t,n){if(w)return K(20,0,1,e,r,t,n);try{var i=X.getStreamFromFD(e),a=$o(i,r,t);return(c(),y)[n>>2]=a,0}catch(s){if(typeof o>"u"||s.name!=="ErrnoError")throw s;return s.errno}}function Gn(e,r,t,n){if(w)return K(21,0,1,e,r,t,n);var i=[],a=null,s=0,l=0,d=0,u=0,_=0,p=0,m,g;function E(k,D,R,G,z,oe){var de,V,se,Qe;return V=k===10?28:16,z=k===10?Qt(z):Xr(z),de=Je(V),Qe=cn(de,k,z,oe),h(!Qe),se=Je(32),(c(),S)[se+4>>2]=k,(c(),S)[se+8>>2]=D,(c(),S)[se+12>>2]=R,(c(),y)[se+24>>2]=G,(c(),y)[se+20>>2]=de,k===10?(c(),S)[se+16>>2]=28:(c(),S)[se+16>>2]=16,(c(),S)[se+28>>2]=0,se}if(t&&(d=(c(),S)[t>>2],u=(c(),S)[t+4>>2],_=(c(),S)[t+8>>2],p=(c(),S)[t+12>>2]),_&&!p&&(p=_===2?17:6),!_&&p&&(_=p===17?2:1),p===0&&(p=6),_===0&&(_=1),!e&&!r)return-2;if(d&-1088||t!==0&&(c(),S)[t>>2]&2&&!e)return-1;if(d&32)return-2;if(_!==0&&_!==1&&_!==2)return-7;if(u!==0&&u!==2&&u!==10)return-6;if(r&&(r=_e(r),l=parseInt(r,10),isNaN(l)))return d&1024?-2:-8;if(!e)return u===0&&(u=2),(d&1)===0&&(u===2?s=Ze(2130706433):s=[0,0,0,Ze(1)]),m=E(u,_,p,null,s,l),(c(),y)[n>>2]=m,0;if(e=_e(e),s=cr(e),s!==null)if(u===0||u===2)u=2;else if(u===10&&d&8)s=[0,0,Ze(65535),s],u=10;else return-2;else if(s=Yr(e),s!==null)if(u===0||u===10)u=10;else return-2;return s!=null?(m=E(u,_,p,e,s,l),(c(),y)[n>>2]=m,0):d&4?-2:(e=he.lookup_name(e),s=cr(e),u===0?u=2:u===10&&(s=[0,0,Ze(65535),s]),m=E(u,_,p,null,s,l),(c(),y)[n>>2]=m,0)}var No=e=>e,Mo=(e,r)=>Br((c(),te).subarray(e,e+r)),xo=(...e)=>o.createPath(...e),Lo=(...e)=>o.unlink(...e),Wo=(...e)=>o.createLazyFile(...e),Uo=(...e)=>o.createDevice(...e);P.init(),o.createPreloadedFile=Ji,o.preloadFile=qr,o.staticInit(),M&&b.staticInit(),ua(),ya(),h(ue.length===10);{if(Ei(),f.noExitRuntime&&(Wr=f.noExitRuntime),f.preloadPlugins&&(Zt=f.preloadPlugins),f.print&&(ge=f.print),f.printErr&&(C=f.printErr),f.wasmBinary&&(He=f.wasmBinary),Go(),f.arguments&&(mt=f.arguments),f.thisProgram&&(Cr=f.thisProgram),h(typeof f.memoryInitializerPrefixURL>"u","Module.memoryInitializerPrefixURL option was removed, use Module.locateFile instead"),h(typeof f.pthreadMainPrefixURL>"u","Module.pthreadMainPrefixURL option was removed, use Module.locateFile instead"),h(typeof f.cdInitializerPrefixURL>"u","Module.cdInitializerPrefixURL option was removed, use Module.locateFile instead"),h(typeof f.filePackagePrefixURL>"u","Module.filePackagePrefixURL option was removed, use Module.locateFile instead"),h(typeof f.read>"u","Module.read option was removed"),h(typeof f.readAsync>"u","Module.readAsync option was removed (modify readAsync in JS)"),h(typeof f.readBinary>"u","Module.readBinary option was removed (modify readBinary in JS)"),h(typeof f.setWindowTitle>"u","Module.setWindowTitle option was removed (modify emscripten_set_window_title in JS)"),h(typeof f.TOTAL_MEMORY>"u","Module.TOTAL_MEMORY has been renamed Module.INITIAL_MEMORY"),h(typeof f.ENVIRONMENT>"u","Module.ENVIRONMENT has been deprecated. To force the environment, use the ENVIRONMENT compile-time option (for example, -sENVIRONMENT=web or -sENVIRONMENT=node)"),h(typeof f.STACK_SIZE>"u","STACK_SIZE can no longer be set at runtime. Use -sSTACK_SIZE at link time"),f.preInit)for(typeof f.preInit=="function"&&(f.preInit=[f.preInit]);f.preInit.length>0;)f.preInit.shift()();ir("preInit")}f.addRunDependency=xr,f.removeRunDependency=Mr,f.FS_preloadFile=qr,f.FS_unlink=Lo,f.FS_createPath=xo,f.FS_createDevice=Uo,f.FS=o,f.FS_createDataFile=Jt,f.FS_createLazyFile=Wo;var jo=["writeI53ToI64","writeI53ToI64Clamped","writeI53ToI64Signaling","writeI53ToU64Clamped","writeI53ToU64Signaling","readI53FromI64","readI53FromU64","convertI32PairToI53","convertI32PairToI53Checked","convertU32PairToI53","getTempRet0","setTempRet0","withStackSave","readEmAsmArgs","jstoi_q","autoResumeAudioContext","getDynCaller","dynCall","runtimeKeepalivePop","asmjsMangle","HandleAllocator","addOnInit","addOnPostCtor","addOnPreMain","addOnExit","STACK_SIZE","STACK_ALIGN","POINTER_SIZE","ASSERTIONS","ccall","cwrap","convertJsFunctionToWasm","getEmptyTableSlot","updateTableMap","getFunctionAddress","addFunction","removeFunction","intArrayToString","stringToAscii","stringToNewUTF8","stringToUTF8OnStack","writeArrayToMemory","registerKeyEventCallback","maybeCStringToJsString","findEventTarget","getBoundingClientRect","fillMouseEventData","registerMouseEventCallback","registerWheelEventCallback","registerUiEventCallback","registerFocusEventCallback","fillDeviceOrientationEventData","registerDeviceOrientationEventCallback","fillDeviceMotionEventData","registerDeviceMotionEventCallback","screenOrientation","fillOrientationChangeEventData","registerOrientationChangeEventCallback","fillFullscreenChangeEventData","registerFullscreenChangeEventCallback","JSEvents_requestFullscreen","JSEvents_resizeCanvasForFullscreen","registerRestoreOldStyle","hideEverythingExceptGivenElement","restoreHiddenElements","setLetterbox","softFullscreenResizeWebGLRenderTarget","doRequestFullscreen","fillPointerlockChangeEventData","registerPointerlockChangeEventCallback","registerPointerlockErrorEventCallback","requestPointerLock","fillVisibilityChangeEventData","registerVisibilityChangeEventCallback","registerTouchEventCallback","fillGamepadEventData","registerGamepadEventCallback","registerBeforeUnloadEventCallback","fillBatteryEventData","registerBatteryEventCallback","setCanvasElementSizeCallingThread","setCanvasElementSizeMainThread","setCanvasElementSize","getCanvasSizeCallingThread","getCanvasSizeMainThread","getCanvasElementSize","jsStackTrace","getCallstack","convertPCtoSourceLocation","wasiRightsToMuslOFlags","wasiOFlagsToMuslOFlags","safeSetTimeout","setImmediateWrapped","safeRequestAnimationFrame","clearImmediateWrapped","registerPostMainLoop","registerPreMainLoop","getPromise","makePromise","idsToPromises","makePromiseCallback","incrementUncaughtExceptionCount","decrementUncaughtExceptionCount","Browser_asyncPrepareDataCounter","isLeapYear","ydayFromDate","arraySum","addDays","FS_mkdirTree","_setNetworkCallback","heapObjectForWebGLType","toTypedArrayIndex","webgl_enable_ANGLE_instanced_arrays","webgl_enable_OES_vertex_array_object","webgl_enable_WEBGL_draw_buffers","webgl_enable_WEBGL_multi_draw","webgl_enable_EXT_polygon_offset_clamp","webgl_enable_EXT_clip_control","webgl_enable_WEBGL_polygon_mode","emscriptenWebGLGet","computeUnpackAlignedImageSize","colorChannelsInGlTextureFormat","emscriptenWebGLGetTexPixelData","emscriptenWebGLGetUniform","webglGetUniformLocation","webglPrepareUniformLocationsBeforeFirstUse","webglGetLeftBracePos","emscriptenWebGLGetVertexAttrib","__glGetActiveAttribOrUniform","writeGLArray","emscripten_webgl_destroy_context_before_on_calling_thread","registerWebGlEventCallback","runAndAbortIfError","ALLOC_NORMAL","ALLOC_STACK","allocate","writeStringToMemory","writeAsciiToMemory","allocateUTF8","allocateUTF8OnStack","demangle","stackTrace","getNativeTypeSize","getFunctionArgsName","createJsInvokerSignature","PureVirtualError","registerInheritedInstance","unregisterInheritedInstance","getInheritedInstanceCount","getLiveInheritedInstances","setDelayFunction","count_emval_handles"];jo.forEach(yi);var Bo=["run","out","err","callMain","abort","wasmExports","writeStackCookie","checkStackCookie","INT53_MAX","INT53_MIN","bigintToI53Checked","HEAP8","HEAP16","HEAPU16","HEAP32","HEAPU32","HEAPF32","HEAPF64","HEAP64","HEAPU64","stackSave","stackRestore","stackAlloc","createNamedFunction","ptrToString","zeroMemory","exitJS","getHeapMax","growMemory","ENV","ERRNO_CODES","strError","inetPton4","inetNtop4","inetPton6","inetNtop6","readSockaddr","writeSockaddr","DNS","Protocols","Sockets","timers","warnOnce","readEmAsmArgsArray","getExecutableName","handleException","keepRuntimeAlive","runtimeKeepalivePush","callUserCallback","maybeExit","asyncLoad","alignMemory","mmapAlloc","wasmTable","wasmMemory","getUniqueRunDependency","noExitRuntime","addOnPreRun","addOnPostRun","freeTableIndexes","functionsInTableMap","setValue","getValue","PATH","PATH_FS","UTF8Decoder","UTF8ArrayToString","UTF8ToString","stringToUTF8Array","stringToUTF8","lengthBytesUTF8","intArrayFromString","AsciiToString","UTF16Decoder","UTF16ToString","stringToUTF16","lengthBytesUTF16","UTF32ToString","stringToUTF32","lengthBytesUTF32","JSEvents","specialHTMLTargets","findCanvasEventTarget","currentFullscreenStrategy","restoreOldWindowedStyle","UNWIND_CACHE","ExitStatus","getEnvStrings","checkWasiClock","doReadv","doWritev","initRandomFill","randomFill","emSetImmediate","emClearImmediate_deps","emClearImmediate","promiseMap","uncaughtExceptionCount","exceptionCaught","ExceptionInfo","findMatchingCatch","Browser","requestFullscreen","requestFullScreen","setCanvasSize","getUserMedia","createContext","getPreloadedImageData__data","wget","MONTH_DAYS_REGULAR","MONTH_DAYS_LEAP","MONTH_DAYS_REGULAR_CUMULATIVE","MONTH_DAYS_LEAP_CUMULATIVE","SYSCALLS","getSocketFromFD","getSocketAddress","preloadPlugins","FS_createPreloadedFile","FS_modeStringToFlags","FS_getMode","FS_fileDataToTypedArray","FS_stdin_getChar_buffer","FS_stdin_getChar","FS_readFile","FS_root","FS_mounts","FS_devices","FS_streams","FS_nextInode","FS_nameTable","FS_currentPath","FS_initialized","FS_ignorePermissions","FS_filesystems","FS_syncFSRequests","FS_lookupPath","FS_getPath","FS_hashName","FS_hashAddNode","FS_hashRemoveNode","FS_lookupNode","FS_createNode","FS_destroyNode","FS_isRoot","FS_isMountpoint","FS_isFile","FS_isDir","FS_isLink","FS_isChrdev","FS_isBlkdev","FS_isFIFO","FS_isSocket","FS_flagsToPermissionString","FS_nodePermissions","FS_mayLookup","FS_mayCreate","FS_mayDelete","FS_mayOpen","FS_checkOpExists","FS_nextfd","FS_getStreamChecked","FS_getStream","FS_createStream","FS_closeStream","FS_dupStream","FS_doSetAttr","FS_chrdev_stream_ops","FS_major","FS_minor","FS_makedev","FS_registerDevice","FS_getDevice","FS_getMounts","FS_syncfs","FS_mount","FS_unmount","FS_lookup","FS_mknod","FS_statfs","FS_statfsStream","FS_statfsNode","FS_create","FS_mkdir","FS_mkdev","FS_symlink","FS_rename","FS_rmdir","FS_readdir","FS_readlink","FS_stat","FS_fstat","FS_lstat","FS_doChmod","FS_chmod","FS_lchmod","FS_fchmod","FS_doChown","FS_chown","FS_lchown","FS_fchown","FS_doTruncate","FS_truncate","FS_ftruncate","FS_utime","FS_open","FS_close","FS_isClosed","FS_llseek","FS_read","FS_write","FS_mmap","FS_msync","FS_ioctl","FS_writeFile","FS_cwd","FS_chdir","FS_createDefaultDirectories","FS_createDefaultDevices","FS_createSpecialDirectories","FS_createStandardStreams","FS_staticInit","FS_init","FS_quit","FS_findObject","FS_analyzePath","FS_createFile","FS_forceLoadFile","MEMFS","TTY","PIPEFS","SOCKFS","tempFixedLengthArray","miniTempWebGLFloatBuffers","miniTempWebGLIntBuffers","GL","AL","GLUT","EGL","GLEW","IDBStore","SDL","SDL_gfx","waitAsyncPolyfilled","print","printErr","jstoi_s","PThread","terminateWorker","cleanupThread","registerTLSInit","spawnThread","exitOnMainThread","proxyToMainThread","proxiedJSCallArgs","invokeEntryPoint","checkMailbox","InternalError","BindingError","throwInternalError","throwBindingError","registeredTypes","awaitingDependencies","typeDependencies","tupleRegistrations","structRegistrations","sharedRegisterType","whenDependentTypesAreResolved","getTypeName","getFunctionName","heap32VectorToArray","requireRegisteredType","usesDestructorStack","checkArgCount","getEnumValueType","getRequiredArgCount","createJsInvoker","UnboundTypeError","EmValType","EmValOptionalType","throwUnboundTypeError","ensureOverloadTable","exposePublicSymbol","replacePublicSymbol","embindRepr","registeredInstances","getBasestPointer","getInheritedInstance","registeredPointers","registerType","integerReadValueFromPointer","enumReadValueFromPointer","floatReadValueFromPointer","assertIntegerRange","readPointer","installIndexedIterator","runDestructors","craftInvokerFunction","embind__requireFunction","genericPointerToWireType","constNoSmartPtrRawPointerToWireType","nonConstNoSmartPtrRawPointerToWireType","init_RegisteredPointer","RegisteredPointer","RegisteredPointer_fromWireType","runDestructor","releaseClassHandle","finalizationRegistry","detachFinalizer_deps","detachFinalizer","attachFinalizer","makeClassHandle","init_ClassHandle","ClassHandle","throwInstanceAlreadyDeleted","deletionQueue","flushPendingDeletes","delayFunction","RegisteredClass","shallowCopyInternalPointer","downcastPointer","upcastPointer","validateThis","char_0","char_9","makeLegalFunctionName","emval_freelist","emval_handles","emval_symbols","getStringOrSymbol","Emval","emval_returnValue","emval_lookupTypes","emval_methodCallers","emval_addMethodCaller","NODEFS"];Bo.forEach(St);var Ho=[Lt,Wt,qt,rn,tn,nn,an,on,sn,ln,un,fn,_n,hn,vn,Ln,Wn,Un,jn,Bn,Hn,Gn];function Go(){Se("fetchSettings"),Se("logReadFiles"),Se("loadSplitModule"),Se("onMalloc"),Se("onRealloc"),Se("onFree"),Se("onSbrkGrow")}function zo(){var e,r,t=new Promise(function(n,i){e=n,r=i});return re.toHandle({promise:t,resolve:e,reject:r})}function Vo(e,r){re.toValue(e)(re.toValue(r))}function qo(e,r){re.toValue(e)(new Error(_e(r)))}function Ko(e,r,t){var n=(c(),te).subarray(e,e+r*t),i=!1;return n.free=function(){i||(i=!0,ve(e))},globalThis._e57Finalizer||(globalThis._e57Finalizer=new FinalizationRegistry(function(a){a()})),globalThis._e57Finalizer.register(n,n.free),re.toHandle(n)}var zn=$("___getTypeName"),Vn=$("__embind_initialize_bindings"),Je=f._malloc=$("_malloc"),ve=f._free=$("_free"),De=$("_pthread_self"),qn=$("_strerror"),Xo=$("__emscripten_tls_init"),ot=$("__emscripten_thread_init"),Kn=$("___set_thread_state"),Xn=$("__emscripten_thread_crashed"),st=$("_fflush"),Ze=$("_htonl"),Fr=$("_htons"),lt=$("_emscripten_stack_get_end"),Yo=$("_emscripten_stack_get_base"),dt=$("_ntohs"),Yn=$("__emscripten_run_js_on_main_thread_done"),Jn=$("__emscripten_run_js_on_main_thread"),Zn=$("__emscripten_thread_free_data"),ct=$("__emscripten_thread_exit"),Qn=$("__emscripten_check_mailbox"),U=$("_setThrew"),ei=$("_emscripten_stack_init"),ri=$("_emscripten_stack_set_limits"),Jo=$("_emscripten_stack_get_free"),ti=$("__emscripten_stack_restore"),ni=$("__emscripten_stack_alloc"),ut=$("_emscripten_stack_get_current"),ii=$("___cxa_decrement_exception_refcount"),ai=$("___cxa_get_exception_ptr"),Zo=$("__indirect_function_table"),ft=$("wasmTable");function Qo(e){h(typeof e.__getTypeName<"u","missing Wasm export: __getTypeName"),h(typeof e._embind_initialize_bindings<"u","missing Wasm export: _embind_initialize_bindings"),h(typeof e.malloc<"u","missing Wasm export: malloc"),h(typeof e.free<"u","missing Wasm export: free"),h(typeof e.pthread_self<"u","missing Wasm export: pthread_self"),h(typeof e.strerror<"u","missing Wasm export: strerror"),h(typeof e._emscripten_tls_init<"u","missing Wasm export: _emscripten_tls_init"),h(typeof e._emscripten_thread_init<"u","missing Wasm export: _emscripten_thread_init"),h(typeof e.__set_thread_state<"u","missing Wasm export: __set_thread_state"),h(typeof e._emscripten_thread_crashed<"u","missing Wasm export: _emscripten_thread_crashed"),h(typeof e.fflush<"u","missing Wasm export: fflush"),h(typeof e.htonl<"u","missing Wasm export: htonl"),h(typeof e.htons<"u","missing Wasm export: htons"),h(typeof e.emscripten_stack_get_end<"u","missing Wasm export: emscripten_stack_get_end"),h(typeof e.emscripten_stack_get_base<"u","missing Wasm export: emscripten_stack_get_base"),h(typeof e.ntohs<"u","missing Wasm export: ntohs"),h(typeof e._emscripten_run_js_on_main_thread_done<"u","missing Wasm export: _emscripten_run_js_on_main_thread_done"),h(typeof e._emscripten_run_js_on_main_thread<"u","missing Wasm export: _emscripten_run_js_on_main_thread"),h(typeof e._emscripten_thread_free_data<"u","missing Wasm export: _emscripten_thread_free_data"),h(typeof e._emscripten_thread_exit<"u","missing Wasm export: _emscripten_thread_exit"),h(typeof e._emscripten_check_mailbox<"u","missing Wasm export: _emscripten_check_mailbox"),h(typeof e.setThrew<"u","missing Wasm export: setThrew"),h(typeof e.emscripten_stack_init<"u","missing Wasm export: emscripten_stack_init"),h(typeof e.emscripten_stack_set_limits<"u","missing Wasm export: emscripten_stack_set_limits"),h(typeof e.emscripten_stack_get_free<"u","missing Wasm export: emscripten_stack_get_free"),h(typeof e._emscripten_stack_restore<"u","missing Wasm export: _emscripten_stack_restore"),h(typeof e._emscripten_stack_alloc<"u","missing Wasm export: _emscripten_stack_alloc"),h(typeof e.emscripten_stack_get_current<"u","missing Wasm export: emscripten_stack_get_current"),h(typeof e.__cxa_decrement_exception_refcount<"u","missing Wasm export: __cxa_decrement_exception_refcount"),h(typeof e.__cxa_get_exception_ptr<"u","missing Wasm export: __cxa_get_exception_ptr"),h(typeof e.__indirect_function_table<"u","missing Wasm export: __indirect_function_table"),zn=J("__getTypeName",1),Vn=J("_embind_initialize_bindings",0),Je=f._malloc=J("malloc",1),ve=f._free=J("free",1),De=e.pthread_self,qn=J("strerror",1),Xo=J("_emscripten_tls_init",0),ot=J("_emscripten_thread_init",6),Kn=J("__set_thread_state",4),Xn=J("_emscripten_thread_crashed",0),st=J("fflush",1),Ze=J("htonl",1),Fr=J("htons",1),lt=e.emscripten_stack_get_end,Yo=e.emscripten_stack_get_base,dt=J("ntohs",1),Yn=J("_emscripten_run_js_on_main_thread_done",3),Jn=J("_emscripten_run_js_on_main_thread",5),Zn=J("_emscripten_thread_free_data",1),ct=J("_emscripten_thread_exit",1),Qn=J("_emscripten_check_mailbox",0),U=J("setThrew",2),ei=e.emscripten_stack_init,ri=e.emscripten_stack_set_limits,Jo=e.emscripten_stack_get_free,ti=e._emscripten_stack_restore,ni=e._emscripten_stack_alloc,ut=e.emscripten_stack_get_current,ii=J("__cxa_decrement_exception_refcount",1),ai=J("__cxa_get_exception_ptr",1),Zo=ft=e.__indirect_function_table}var _t;function es(){_t={__assert_fail:Ni,__cxa_begin_catch:Mi,__cxa_end_catch:xi,__cxa_find_matching_catch_2:Li,__cxa_find_matching_catch_3:Wi,__cxa_find_matching_catch_4:Ui,__cxa_throw:ji,__pthread_create_js:Kt,__resumeException:Hi,__syscall_connect:rn,__syscall_dup:tn,__syscall_fcntl64:nn,__syscall_getcwd:an,__syscall_ioctl:on,__syscall_openat:sn,__syscall_readlinkat:ln,__syscall_recvfrom:un,__syscall_rmdir:fn,__syscall_sendto:_n,__syscall_socket:hn,__syscall_unlinkat:vn,_abort_js:Qi,_embind_finalize_value_object:ra,_embind_register_bigint:na,_embind_register_bool:ia,_embind_register_class:Ea,_embind_register_class_class_function:Ta,_embind_register_class_constructor:Fa,_embind_register_class_function:Pa,_embind_register_class_property:Ca,_embind_register_emval:Aa,_embind_register_enum:Da,_embind_register_enum_value:Ra,_embind_register_float:$a,_embind_register_function:Na,_embind_register_integer:Ma,_embind_register_iterable:La,_embind_register_memory_view:Wa,_embind_register_optional:ja,_embind_register_std_string:Ba,_embind_register_std_wstring:Xa,_embind_register_value_object:Ya,_embind_register_value_object_field:Ja,_embind_register_void:Za,_emjs_array_view:Ko,_emjs_call_reject:qo,_emjs_call_resolve:Vo,_emjs_make_deferred:zo,_emscripten_init_main_thread_js:Qa,_emscripten_notify_mailbox_postmessage:ro,_emscripten_receive_on_main_thread_js:to,_emscripten_thread_cleanup:no,_emscripten_thread_mailbox_await:nt,_emscripten_thread_set_strongref:io,_emval_array_to_memory_view:ao,_emval_create_invoker:uo,_emval_decref:rt,_emval_get_property:fo,_emval_incref:_o,_emval_invoke:Nn,_emval_invoke_i64:ho,_emval_new_cstring:vo,_emval_run_destructors:po,_tzset_js:mo,clock_time_get:So,emscripten_check_blocking_allowed:ko,emscripten_err:To,emscripten_exit_with_live_runtime:Po,emscripten_get_now:Mn,emscripten_resize_heap:Do,environ_get:Ln,environ_sizes_get:Wn,exit:Lr,fd_close:Un,fd_read:jn,fd_seek:Bn,fd_write:Hn,getaddrinfo:Gn,invoke_i:ys,invoke_ii:rs,invoke_iii:ts,invoke_iiii:hs,invoke_iiiii:gs,invoke_iiij:cs,invoke_iiijjj:Fs,invoke_iij:ss,invoke_iiji:is,invoke_iijiiiiiii:os,invoke_ji:bs,invoke_jiii:ks,invoke_jiiiijijii:Ps,invoke_v:ws,invoke_vi:us,invoke_vii:ds,invoke_viii:ns,invoke_viiii:ms,invoke_viiiii:ps,invoke_viiiiii:Ts,invoke_viiiiijijii:Cs,invoke_viiiijijii:Es,invoke_viij:Ss,invoke_viijii:fs,invoke_vij:as,invoke_viji:vs,invoke_vijj:ls,invoke_vijjii:_s,llvm_eh_typeid_for:No,memory:fe,random_get:Mo}}function rs(e,r){var t=B();try{return W(e)(r)}catch(n){if(L(t),!(n instanceof j))throw n;U(1,0)}}function ts(e,r,t){var n=B();try{return W(e)(r,t)}catch(i){if(L(n),!(i instanceof j))throw i;U(1,0)}}function ns(e,r,t,n){var i=B();try{W(e)(r,t,n)}catch(a){if(L(i),!(a instanceof j))throw a;U(1,0)}}function is(e,r,t,n){var i=B();try{return W(e)(r,t,n)}catch(a){if(L(i),!(a instanceof j))throw a;U(1,0)}}function as(e,r,t){var n=B();try{W(e)(r,t)}catch(i){if(L(n),!(i instanceof j))throw i;U(1,0)}}function os(e,r,t,n,i,a,s,l,d,u){var _=B();try{return W(e)(r,t,n,i,a,s,l,d,u)}catch(p){if(L(_),!(p instanceof j))throw p;U(1,0)}}function ss(e,r,t){var n=B();try{return W(e)(r,t)}catch(i){if(L(n),!(i instanceof j))throw i;U(1,0)}}function ls(e,r,t,n){var i=B();try{W(e)(r,t,n)}catch(a){if(L(i),!(a instanceof j))throw a;U(1,0)}}function ds(e,r,t){var n=B();try{W(e)(r,t)}catch(i){if(L(n),!(i instanceof j))throw i;U(1,0)}}function cs(e,r,t,n){var i=B();try{return W(e)(r,t,n)}catch(a){if(L(i),!(a instanceof j))throw a;U(1,0)}}function us(e,r){var t=B();try{W(e)(r)}catch(n){if(L(t),!(n instanceof j))throw n;U(1,0)}}function fs(e,r,t,n,i,a){var s=B();try{W(e)(r,t,n,i,a)}catch(l){if(L(s),!(l instanceof j))throw l;U(1,0)}}function _s(e,r,t,n,i,a){var s=B();try{W(e)(r,t,n,i,a)}catch(l){if(L(s),!(l instanceof j))throw l;U(1,0)}}function hs(e,r,t,n){var i=B();try{return W(e)(r,t,n)}catch(a){if(L(i),!(a instanceof j))throw a;U(1,0)}}function vs(e,r,t,n){var i=B();try{W(e)(r,t,n)}catch(a){if(L(i),!(a instanceof j))throw a;U(1,0)}}function ps(e,r,t,n,i,a){var s=B();try{W(e)(r,t,n,i,a)}catch(l){if(L(s),!(l instanceof j))throw l;U(1,0)}}function ms(e,r,t,n,i){var a=B();try{W(e)(r,t,n,i)}catch(s){if(L(a),!(s instanceof j))throw s;U(1,0)}}function gs(e,r,t,n,i){var a=B();try{return W(e)(r,t,n,i)}catch(s){if(L(a),!(s instanceof j))throw s;U(1,0)}}function ys(e){var r=B();try{return W(e)()}catch(t){if(L(r),!(t instanceof j))throw t;U(1,0)}}function ws(e){var r=B();try{W(e)()}catch(t){if(L(r),!(t instanceof j))throw t;U(1,0)}}function Es(e,r,t,n,i,a,s,l,d,u){var _=B();try{W(e)(r,t,n,i,a,s,l,d,u)}catch(p){if(L(_),!(p instanceof j))throw p;U(1,0)}}function bs(e,r){var t=B();try{return W(e)(r)}catch(n){if(L(t),!(n instanceof j))throw n;return U(1,0),0n}}function Ss(e,r,t,n){var i=B();try{W(e)(r,t,n)}catch(a){if(L(i),!(a instanceof j))throw a;U(1,0)}}function ks(e,r,t,n){var i=B();try{return W(e)(r,t,n)}catch(a){if(L(i),!(a instanceof j))throw a;return U(1,0),0n}}function Ts(e,r,t,n,i,a,s){var l=B();try{W(e)(r,t,n,i,a,s)}catch(d){if(L(l),!(d instanceof j))throw d;U(1,0)}}function Fs(e,r,t,n,i,a){var s=B();try{return W(e)(r,t,n,i,a)}catch(l){if(L(s),!(l instanceof j))throw l;U(1,0)}}function Ps(e,r,t,n,i,a,s,l,d,u){var _=B();try{return W(e)(r,t,n,i,a,s,l,d,u)}catch(p){if(L(_),!(p instanceof j))throw p;return U(1,0),0n}}function Cs(e,r,t,n,i,a,s,l,d,u,_){var p=B();try{W(e)(r,t,n,i,a,s,l,d,u,_)}catch(m){if(L(p),!(m instanceof j))throw m;U(1,0)}}var oi;function As(){h(!w),ei(),Et()}function Pr(){if(Te>0){ze=Pr;return}if(w){Rr?.(f),Pt();return}if(As(),bi(),Te>0){ze=Pr;return}function e(){h(!oi),oi=!0,f.calledRun=!0,!Ie&&(Pt(),Rr?.(f),f.onRuntimeInitialized?.(),ir("onRuntimeInitialized"),h(!f._main,'compiled without a main, but one is present. if you added it from JS, use Module["onRuntimeInitialized"]'),Si())}f.setStatus?(f.setStatus("Running..."),setTimeout(()=>{setTimeout(()=>f.setStatus(""),1),e()},1)):e(),Ge()}function Os(){var e=ge,r=C,t=!1;ge=C=d=>{t=!0};try{st(0);for(var n of["stdout","stderr"]){var i=o.analyzePath("/dev/"+n);if(!i)return;var a=i.object,s=a.rdev,l=pe.ttys[s];l?.output?.length&&(t=!0)}}catch{}ge=e,C=r,t&&Fe("stdio streams had content in them that was not flushed. you should set EXIT_RUNTIME to 1 (see the Emscripten FAQ), or make sure to emit a newline when you printf etc.")}var Re;w||(Re=await At(),Pr()),Ne?v=f:v=new Promise((e,r)=>{Rr=e,Ir=r});for(let e of Object.keys(f))e in ee||Object.defineProperty(ee,e,{configurable:!0,get(){q(`Access to module property ('${e}') is no longer possible via the module constructor argument; Instead, use the result of the module constructor.`)}});return v}var li=si,di=globalThis.name?.startsWith("em-pthread"),Ds=globalThis.process?.versions?.node&&globalThis.process?.type!="renderer";Ds&&(di=(await import("node:worker_threads")).workerData==="em-pthread");di&&si();var Q=class ee{static LibE57=null;static RootDir="/root ";static Init(){let v=typeof window<"u";return ee.LibE57!==null?Promise.resolve():li().then(function(f){v||(f.FS.mkdir(ee.RootDir),f.FS.mount(f.FS.filesystems.NODEFS,{root:"/"},ee.RootDir)),ee.LibE57=f})}};import ht from"path";import Rs from"fs";var vt=class{constructor(v,f){this.e57Reader=v,this.scanIdx=f,this._header=null}GetHeader(){return this._header||(this._header=this.e57Reader.GetData3DHeader(this.scanIdx)),this._header}Destroy(){this._header&&this._header.delete()}ReadScan(v=!0){return this.ReadPoints(Number(this.GetHeader().pointCount),v)}ReadScanSync(v=!0){let f=Number(this.GetHeader().pointCount);return this.ReadPointsSync(f,v)}ReadPoints(v,f=!0){return this.e57Reader.ReadScan(this.scanIdx,v,f)}ReadPointsSync(v,f=!0){return this.e57Reader.ReadScanSync(this.scanIdx,v,f)}ScanPoints(v,f,O=!0){let N=Number(this.GetHeader().pointCount),M=Math.ceil(N/v);if(f){for(let w=0;w<M;w++){let le=this.ReadPointsSync(v,O);f(le),le.delete()}return}let me=[];for(let w=0;w<M;w++)me.push(this.ReadPointsSync(v,O));return me}},pt=class{constructor(v,f){this._e57Reader=v,this._imageIdx=f,this._header=null}GetHeader(){return this._header||(this._header=this._e57Reader.GetImage2DHeader(this._imageIdx)),this._header}Destroy(){this._header&&this._header.delete()}ReadImage(){return this._e57Reader.ReadImage(this._imageIdx)}ReadImageSync(){return this._e57Reader.ReadImageSync(this._imageIdx)}Release(v){v&&typeof v.free=="function"&&v.free()}ToBase64(){return this.ReadImage().then(v=>{let f=Buffer.from(v).toString("base64");return this.Release(v),f})}Extension(){switch(this.GetHeader().imageType){case Q.LibE57.Image2DType.ImageJPEG:return".jpeg";case Q.LibE57.Image2DType.ImagePNG:return".png";case Q.LibE57.Image2DType.ImageMaskPNG:return".png";case Q.LibE57.Image2DType.E57_JPEG_IMAGE:return".jpeg";case Q.LibE57.Image2DType.E57_PNG_IMAGE:return".png";case Q.LibE57.Image2DType.E57_PNG_IMAGE_MASK:return".png";default:return".jpg"}}Save(v){if(typeof window<"u")throw new Error("Save() is not available in the browser \u2014 use ReadImage() to get a Uint8Array instead");let f=this.Extension(),O=v.replace(ht.extname(v),f);return this.ReadImage().then(N=>Rs.promises.writeFile(O,N).then(()=>{this.Release(N)}))}},ci=class ee{constructor(v,f=!1){let O=f?v:ht.join(Q.RootDir,ht.resolve(v));this._reader=new Q.LibE57.E57Reader(O);var N=this.GetData3DCount();this.scans=new Array(N);for(var M=0;M<N;M++)this.scans[M]=new vt(this._reader,M);var me=this.GetImage2DCount();this.images=new Array(me);for(var w=0;w<me;w++)this.images[w]=new pt(this._reader,w)}static FromBuffer(v){let f="/"+crypto.randomUUID()+".e57";Q.LibE57.FS.writeFile(f,v);let O=new ee(f,!0);return O._memFsFilePath=f,O}GetHeader(){return this._reader.GetHeader()}GetData3DCount(){return Number(this._reader.GetData3DCount())}GetImage2DCount(){return Number(this._reader.GetImage2DCount())}GetScan(v){return this.scans[v]}GetImage(v){return this.images[v]}Close(){for(let v of this.scans)v.Destroy();for(let v of this.images)v.Destroy();this._reader&&(this._reader.Close(),this._reader.delete()),this._memFsFilePath&&Q.LibE57.FS.unlink(this._memFsFilePath),this.scans=null,this.images=null}};import ui from"path";import fi from"fs";import Is from"sharp";var _i=class ee{constructor(v,f,O){this._imgPath=v,this._imgType=f,this._imgProjection=O,this._imageHeader=new Q.LibE57.ImageHeader}static FromBuffer(v,f,O){let N=new ee(null,f,O);return N._buffer=v,N._width=null,N._height=null,N}GetPath(){return this._imgPath}SetPath(v){this._imgPath=v}GetType(){return this._imgType}SetType(v){this._imgType=v}GetProjection(){return this._imgProjection}SetProjection(v){this._imgProjection=v}_resolveMetadata(){return this._width!=null&&this._height!=null?Promise.resolve({width:this._width,height:this._height}):this._metadataPromise?this._metadataPromise:(typeof window<"u"?this._metadataPromise=this.GetBuffer().then(v=>{let f=new Blob([v]);return createImageBitmap(f).then(O=>{let N={width:O.width,height:O.height};return O.close(),this._width=N.width,this._height=N.height,N})}):this._metadataPromise=this.GetBuffer().then(v=>Is(v).metadata()).then(v=>(this._width=v.width,this._height=v.height,v)),this._metadataPromise)}GetMetadata(){return this._resolveMetadata()}GetDimensions(){return this._resolveMetadata().then(v=>[v.width,v.height])}GetWidth(){return this._resolveMetadata().then(v=>v.width)}GetHeight(){return this._resolveMetadata().then(v=>v.height)}GetPose(){return this._imageHeader.pose}SetPose(v){this._imageHeader.pose=v}GetName(){return this._imageHeader.name}SetName(v){this._imageHeader.name=v}GetGuid(){return this._imageHeader.guid}SetGuid(v){this._imageHeader.guid=v}GetHeader(){return this._imageHeader}SetHeader(v){this._imageHeader.delete(),this._imageHeader=v}GetBufferSync(){return this._buffer?this._buffer:new Uint8Array(fi.readFileSync(this.GetPath()))}GetBuffer(){return this._buffer?Promise.resolve(this._buffer):fi.promises.readFile(this.GetPath()).then(v=>new Uint8Array(v))}SetTranslation(v,f,O){this._imageHeader.pose.translation.x=v,this._imageHeader.pose.translation.y=f,this._imageHeader.pose.translation.z=O}SetRotation(v,f,O,N){this._imageHeader.pose.rotation.w=v,this._imageHeader.pose.rotation.x=f,this._imageHeader.pose.rotation.y=O,this._imageHeader.pose.rotation.z=N}Destroy(){this._imageHeader.delete(),this._imageHeader=null,this._buffer=null}},hi=class{constructor(){this._header=new Q.LibE57.Data3D,this._points=[]}GetHeader(){return this._header}SetHeader(v){this._header&&this._header.delete(),this._header=v}GetPoints(){return this._points}AddPoint(v){this._points&&this._points.push(v)}Destroy(){this._header&&(this._header.delete(),this._header=null);for(let v of this._points)v&&v.delete();this._points=[]}},vi=class ee{constructor(v,f=!1){let O=crypto.randomUUID();this._bufferFileMemFSFilePath="/"+O+".e57";let N=f?this._bufferFileMemFSFilePath:ui.join(Q.RootDir,ui.resolve(v));this._writer=new Q.LibE57.E57Writer(N),this._toBuffer=f}static ToBuffer(){return new ee("",!0)}AddImage(v){return Promise.all([v.GetBuffer(),v.GetMetadata()]).then(([f,O])=>this._writer.AddImage(v.GetHeader(),v.GetType(),v.GetProjection(),0,f,f.length,O.width,O.height).then(Number))}AddScanSync(v){let f=v.GetHeader(),O=v.GetPoints();return Number(this._writer.AddScanSync(f,O))}AddScan(v){let f=v.GetHeader(),O=v.GetPoints();return this._writer.AddScan(f,O).then(Number)}Close(){if(this._writer&&(this._writer.Close(),this._writer.delete()),this._toBuffer){let v=Q.LibE57.FS.readFile(this._bufferFileMemFSFilePath);return Q.LibE57.FS.unlink(this._bufferFileMemFSFilePath),v}}};export{Q as E57,ci as E57Reader,pt as E57ReaderImage,vt as E57ReaderScan,vi as E57Writer,_i as E57WriterImage,hi as E57WriterScan};
|
package/dist/libe57-js.js
CHANGED
|
@@ -233,8 +233,6 @@ var OPFS = "OPFS is no longer included by default; build with -lopfs.js";
|
|
|
233
233
|
// if an assertion fails it cannot print the message
|
|
234
234
|
assert(ENVIRONMENT_IS_WEB || ENVIRONMENT_IS_WORKER || ENVIRONMENT_IS_NODE, "pthreads do not work in this environment yet (need Web Workers, or an alternative to them)");
|
|
235
235
|
|
|
236
|
-
assert(!ENVIRONMENT_IS_WEB, "web environment detected but not enabled at build time (add `web` to `-sENVIRONMENT` to enable)");
|
|
237
|
-
|
|
238
236
|
assert(!ENVIRONMENT_IS_SHELL, "shell environment detected but not enabled at build time (add `shell` to `-sENVIRONMENT` to enable)");
|
|
239
237
|
|
|
240
238
|
// end include: shell.js
|
|
@@ -1949,6 +1947,13 @@ var FS_stdin_getChar = () => {
|
|
|
1949
1947
|
if (bytesRead > 0) {
|
|
1950
1948
|
result = buf.slice(0, bytesRead).toString("utf-8");
|
|
1951
1949
|
}
|
|
1950
|
+
} else if (globalThis.window?.prompt) {
|
|
1951
|
+
// Browser.
|
|
1952
|
+
result = window.prompt("Input: ");
|
|
1953
|
+
// returns null on cancel
|
|
1954
|
+
if (result !== null) {
|
|
1955
|
+
result += "\n";
|
|
1956
|
+
}
|
|
1952
1957
|
} else {}
|
|
1953
1958
|
if (!result) {
|
|
1954
1959
|
return null;
|
|
@@ -7842,6 +7847,12 @@ var __emscripten_thread_set_strongref = thread => {
|
|
|
7842
7847
|
}
|
|
7843
7848
|
};
|
|
7844
7849
|
|
|
7850
|
+
var __emval_array_to_memory_view = (dst, src) => {
|
|
7851
|
+
dst = Emval.toValue(dst);
|
|
7852
|
+
src = Emval.toValue(src);
|
|
7853
|
+
dst.set(src);
|
|
7854
|
+
};
|
|
7855
|
+
|
|
7845
7856
|
var emval_methodCallers = [];
|
|
7846
7857
|
|
|
7847
7858
|
var emval_addMethodCaller = caller => {
|
|
@@ -8559,10 +8570,17 @@ function _emjs_call_reject(reject_fn, msg) {
|
|
|
8559
8570
|
|
|
8560
8571
|
function _emjs_array_view(ptr, size, elementSize) {
|
|
8561
8572
|
var arr = (growMemViews(), HEAPU8).subarray(ptr, ptr + size * elementSize);
|
|
8562
|
-
|
|
8563
|
-
|
|
8573
|
+
var freed = false;
|
|
8574
|
+
arr.free = function() {
|
|
8575
|
+
if (!freed) {
|
|
8576
|
+
freed = true;
|
|
8577
|
+
_free(ptr);
|
|
8578
|
+
}
|
|
8579
|
+
};
|
|
8580
|
+
if (!globalThis._e57Finalizer) globalThis._e57Finalizer = new FinalizationRegistry(function(freeWasmMemory) {
|
|
8581
|
+
freeWasmMemory();
|
|
8564
8582
|
});
|
|
8565
|
-
globalThis._e57Finalizer.register(arr,
|
|
8583
|
+
globalThis._e57Finalizer.register(arr, arr.free);
|
|
8566
8584
|
return Emval.toHandle(arr);
|
|
8567
8585
|
}
|
|
8568
8586
|
|
|
@@ -8754,6 +8772,7 @@ function assignWasmImports() {
|
|
|
8754
8772
|
/** @export */ _emscripten_thread_cleanup: __emscripten_thread_cleanup,
|
|
8755
8773
|
/** @export */ _emscripten_thread_mailbox_await: __emscripten_thread_mailbox_await,
|
|
8756
8774
|
/** @export */ _emscripten_thread_set_strongref: __emscripten_thread_set_strongref,
|
|
8775
|
+
/** @export */ _emval_array_to_memory_view: __emval_array_to_memory_view,
|
|
8757
8776
|
/** @export */ _emval_create_invoker: __emval_create_invoker,
|
|
8758
8777
|
/** @export */ _emval_decref: __emval_decref,
|
|
8759
8778
|
/** @export */ _emval_get_property: __emval_get_property,
|
package/dist/libe57-js.wasm
CHANGED
|
Binary file
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "e57-js",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "1.0.
|
|
4
|
+
"version": "1.0.8",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"keywords": [
|
|
7
7
|
"e57",
|
|
@@ -31,6 +31,7 @@
|
|
|
31
31
|
},
|
|
32
32
|
"exports": {
|
|
33
33
|
".": {
|
|
34
|
+
"browser": "./dist/index.browser.mjs",
|
|
34
35
|
"import": "./dist/index.mjs",
|
|
35
36
|
"require": "./dist/index.cjs"
|
|
36
37
|
}
|
|
@@ -39,8 +40,7 @@
|
|
|
39
40
|
"dist"
|
|
40
41
|
],
|
|
41
42
|
"scripts": {
|
|
42
|
-
"build": "docker compose up --build"
|
|
43
|
-
"test": "node --test --test-concurrency=1 --test-timeout=30000 tests/**/*.test.js"
|
|
43
|
+
"build": "docker compose up --build"
|
|
44
44
|
},
|
|
45
45
|
"dependencies": {
|
|
46
46
|
"fs-extra": "^11.3.4",
|