clipcc-sb1-converter 1.0.324
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/.nvmrc +1 -0
- package/LICENSE +12 -0
- package/README.md +9 -0
- package/TRADEMARK +1 -0
- package/index.js +2 -0
- package/package.json +39 -0
- package/playground/assets/index-Bvv1xdjK.js +7 -0
- package/playground/index.html +12 -0
- package/playground/main.js +5 -0
- package/src/coders/adler32.js +22 -0
- package/src/coders/byte-packets.js +116 -0
- package/src/coders/byte-primitives.js +372 -0
- package/src/coders/byte-stream.js +141 -0
- package/src/coders/crc32.js +32 -0
- package/src/coders/deflate-packets.js +33 -0
- package/src/coders/deflate-stream.js +78 -0
- package/src/coders/png-chunk-stream.js +34 -0
- package/src/coders/png-file.js +81 -0
- package/src/coders/png-packets.js +65 -0
- package/src/coders/proxy-stream.js +31 -0
- package/src/coders/squeak-image.js +200 -0
- package/src/coders/squeak-sound.js +114 -0
- package/src/coders/wav-file.js +58 -0
- package/src/coders/wav-packets.js +34 -0
- package/src/playground/array.js +84 -0
- package/src/playground/field-object.js +80 -0
- package/src/playground/field.js +29 -0
- package/src/playground/index.html +12 -0
- package/src/playground/index.js +67 -0
- package/src/playground/js-primitive.js +13 -0
- package/src/playground/object.js +28 -0
- package/src/playground/view.js +171 -0
- package/src/playground/viewable.js +17 -0
- package/src/sb1-file-packets.js +62 -0
- package/src/sb1-file.js +125 -0
- package/src/squeak/byte-primitives.js +208 -0
- package/src/squeak/byte-take-iterator.js +45 -0
- package/src/squeak/field-iterator.js +158 -0
- package/src/squeak/field-object.js +96 -0
- package/src/squeak/fields.js +174 -0
- package/src/squeak/ids.js +172 -0
- package/src/squeak/reference-fixer.js +39 -0
- package/src/squeak/type-iterator.js +53 -0
- package/src/squeak/types.js +518 -0
- package/src/to-sb2/fake-zip.js +73 -0
- package/src/to-sb2/json-generator.js +246 -0
- package/src/util/assert.js +23 -0
- package/src/util/log.js +3 -0
- package/tsconfig.json +8 -0
- package/vite.config.js +16 -0
- package/vite.lib.config.js +15 -0
package/.nvmrc
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
v24
|
package/LICENSE
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
Copyright (c) 2018, Code-to-Learn Foundation d/b/a Scratch Foundation
|
|
2
|
+
All rights reserved.
|
|
3
|
+
|
|
4
|
+
Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
|
|
5
|
+
|
|
6
|
+
1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
|
|
7
|
+
|
|
8
|
+
2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
|
|
9
|
+
|
|
10
|
+
3. Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.
|
|
11
|
+
|
|
12
|
+
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
package/README.md
ADDED
package/TRADEMARK
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
The Scratch trademarks, including the Scratch name, logo, the Scratch Cat, Gobo, Pico, Nano, Tera and Giga graphics (the "Marks"), are property of the Massachusetts Institute of Technology (MIT). Marks may not be used to endorse or promote products derived from this software without specific prior written permission.
|
package/index.js
ADDED
package/package.json
ADDED
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "clipcc-sb1-converter",
|
|
3
|
+
"version": "1.0.324",
|
|
4
|
+
"description": "Scratch 1 (.sb) to Scratch 2 (.sb2) conversion library for Scratch 3.0",
|
|
5
|
+
"author": "Clipteam",
|
|
6
|
+
"license": "BSD-3-Clause",
|
|
7
|
+
"homepage": "https://github.com/Clipteam/scratch-sb1-converter#readme",
|
|
8
|
+
"repository": {
|
|
9
|
+
"type": "git",
|
|
10
|
+
"url": "https://github.com/Clipteam/scratch-sb1-converter.git"
|
|
11
|
+
},
|
|
12
|
+
"main": "playground/main.js",
|
|
13
|
+
"browser": "index.js",
|
|
14
|
+
"dependencies": {
|
|
15
|
+
"fastestsmallesttextencoderdecoder": "^1.0.22",
|
|
16
|
+
"js-md5": "^0.8.3",
|
|
17
|
+
"@turbowarp/nanolog": "^1.0.1"
|
|
18
|
+
},
|
|
19
|
+
"devDependencies": {
|
|
20
|
+
"eslint": "8.57.1",
|
|
21
|
+
"eslint-config-scratch": "9.0.9",
|
|
22
|
+
"json": "^9.0.4",
|
|
23
|
+
"tap": "21.6.2",
|
|
24
|
+
"terser": "^5.46.0",
|
|
25
|
+
"vite": "^7.3.1"
|
|
26
|
+
},
|
|
27
|
+
"scripts": {
|
|
28
|
+
"build": "pnpm run build:playground && pnpm run build:lib",
|
|
29
|
+
"build:lib": "vite build -c vite.lib.config.js",
|
|
30
|
+
"build:playground": "vite build",
|
|
31
|
+
"lint": "eslint .",
|
|
32
|
+
"start": "vite",
|
|
33
|
+
"test:unit": "tap ./test/unit",
|
|
34
|
+
"test:integration": "tap ./test/integration",
|
|
35
|
+
"test:coverage": "tap ./test/{unit,integration}/*.js --coverage --coverage-report=lcov",
|
|
36
|
+
"test": "pnpm run lint && pnpm run test:unit && pnpm run test:integration",
|
|
37
|
+
"watch": "vite build --watch -c vite.lib.config.js"
|
|
38
|
+
}
|
|
39
|
+
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
(function(){const e=document.createElement("link").relList;if(e&&e.supports&&e.supports("modulepreload"))return;for(const o of document.querySelectorAll('link[rel="modulepreload"]'))n(o);new MutationObserver(o=>{for(const h of o)if(h.type==="childList")for(const F of h.addedNodes)F.tagName==="LINK"&&F.rel==="modulepreload"&&n(F)}).observe(document,{childList:!0,subtree:!0});function t(o){const h={};return o.integrity&&(h.integrity=o.integrity),o.referrerPolicy&&(h.referrerPolicy=o.referrerPolicy),o.crossOrigin==="use-credentials"?h.credentials="include":o.crossOrigin==="anonymous"?h.credentials="omit":h.credentials="same-origin",h}function n(o){if(o.ep)return;o.ep=!0;const h=t(o);fetch(o.href,h)}})();class yt extends Error{}class Mt extends yt{}const N=function(r,e){if(!r)throw new yt(e)};N.validate=function(r,e){if(!r)throw new Mt(e)};class Z{constructor(e,t=0){this.buffer=e,this.position=t,this.uint8a=new Uint8Array(this.buffer)}read(e){const t=e.read(this.uint8a,this.position);return e.size===0?this.position+=e.sizeOf(this.uint8a,this.position):this.position+=e.size,t}readStruct(e){const t=new e(this.uint8a,this.position);return this.position+=e.size,t}resize(e){if(this.buffer.byteLength<e){const t=this.uint8a,n=Math.pow(2,Math.ceil(Math.log(e)/Math.log(2)));this.buffer=new ArrayBuffer(n),this.uint8a=new Uint8Array(this.buffer),this.uint8a.set(t)}}write(e,t){return e.size===0?this.resize(this.position+e.writeSizeOf(t)):this.resize(this.position+e.size),e.write(this.uint8a,this.position,t),e.size===0?this.position+=e.writeSizeOf(this.uint8a,this.position):this.position+=e.size,t}writeStruct(e,t){this.resize(this.position+e.size);const n=Object.assign(new e(this.uint8a,this.position),t);return this.position+=e.size,n}writeBytes(e,t=0,n=e.length){N(e instanceof Uint8Array,"writeBytes must be passed an Uint8Array"),this.resize(this.position+(n-t));for(let o=t;o<n;o++)this.uint8a[this.position+o-t]=e[o];return this.position+=n-t,e}}class Xe{constructor(e,t=1/0){this.iter=e,this.maxPosition=t}[Symbol.iterator](){return this}next(){return this.iter.stream.position>=this.maxPosition?{value:null,done:!0}:this.iter.next()}}const Ke=()=>{throw new Error("Not implemented")},Q=(()=>{const r=new Uint16Array(1),e=new Uint8Array(r.buffer);return r[0]=43707,e[0]===187})();class B{constructor({size:e=0,sizeOf:t=()=>e,writeSizeOf:n=Ke,toBytes:o=new Uint8Array(1),read:h,write:F=Ke}){this.size=e,this.sizeOf=t,this.writeSizeOf=n,this.toBytes=o,this.bytes=new Uint8Array(o.buffer),this.read=h,this.write=F}asPropertyObject(e){const t=this;return{get(){return t.read(this.uint8a,e+this.offset)},set(n){return t.write(this.uint8a,e+this.offset,n)},enumerable:!0}}read(){return null}}const L=new B({size:1,read(r,e){return r[e]},write(r,e,t){return r[e]=t,t}}),gt={size:2,read(r,e){return this.bytes[1]=r[e+0],this.bytes[0]=r[e+1],this.toBytes[0]},write(r,e,t){return this.toBytes[0]=t,r[e+0]=this.bytes[1],r[e+1]=this.bytes[0],t}},Et={size:2,read(r,e){return this.bytes[0]=r[e+0],this.bytes[1]=r[e+1],this.toBytes[0]},write(r,e,t){return this.toBytes[0]=t,r[e+0]=this.bytes[0],r[e+1]=this.bytes[1],t}};let de;Q?de=gt:de=Et;new B(Object.assign({},de,{toBytes:new Uint16Array(1)}));const le=new B(Object.assign({},de,{toBytes:new Int16Array(1)})),wt={size:4,read(r,e){return this.bytes[3]=r[e+0],this.bytes[2]=r[e+1],this.bytes[1]=r[e+2],this.bytes[0]=r[e+3],this.toBytes[0]},write(r,e,t){return this.toBytes[0]=t,r[e+0]=this.bytes[3],r[e+1]=this.bytes[2],r[e+2]=this.bytes[1],r[e+3]=this.bytes[0],t}},St={size:4,read(r,e){return this.bytes[0]=r[e+0],this.bytes[1]=r[e+1],this.bytes[2]=r[e+2],this.bytes[3]=r[e+3],this.toBytes[0]},write(r,e,t){return this.toBytes[0]=t,r[e+0]=this.bytes[0],r[e+1]=this.bytes[1],r[e+2]=this.bytes[2],r[e+3]=this.bytes[3],t}};let xe;Q?xe=wt:xe=St;const k=new B(Object.assign({},xe,{toBytes:new Int32Array(1)})),b=new B(Object.assign({},xe,{toBytes:new Uint32Array(1)}));let Ie;Q?Ie=Et:Ie=gt;const X=new B(Object.assign({},Ie,{toBytes:new Uint16Array(1)}));let ve;Q?ve=St:ve=wt;const se=new B(Object.assign({},ve,{toBytes:new Uint32Array(1)})),Pt={size:8,read(r,e){return this.bytes[7]=r[e+0],this.bytes[6]=r[e+1],this.bytes[5]=r[e+2],this.bytes[4]=r[e+3],this.bytes[3]=r[e+4],this.bytes[2]=r[e+5],this.bytes[1]=r[e+6],this.bytes[0]=r[e+7],this.toBytes[0]}},Dt={size:8,read(r,e){return this.bytes[7]=r[e+0],this.bytes[6]=r[e+1],this.bytes[5]=r[e+2],this.bytes[4]=r[e+3],this.bytes[3]=r[e+4],this.bytes[2]=r[e+5],this.bytes[1]=r[e+6],this.bytes[0]=r[e+7],this.toBytes[0]}};let Re;Q?Re=Pt:Re=Dt;const Ut=new B(Object.assign({},Re,{toBytes:new Float64Array(1)}));class z extends B{constructor(e){super({size:e,read(t,n){let o="";for(let h=0;h<e;h++){const F=t[n+h];N(F<=127,"Non-ascii character in FixedAsciiString"),o+=String.fromCharCode(F)}return o},write(t,n,o){for(let h=0;h<e;h++){const F=o.charCodeAt(h);N(F<=127,"Non-ascii character in FixedAsciiString"),t[n+h]=F}return o}})}}var J=typeof global>"u"?typeof self>"u"?{}:self:global,Ze=String.fromCharCode,ge={}.toString,Qe=J.SharedArrayBuffer,zt=Qe?ge.call(Qe):"",V=J.Uint8Array,Ht=V?ge.call(ArrayBuffer.prototype):"",G=J.Buffer;try{!G&&J.require&&(G=J.require("Buffer"));var bt=G.prototype,jt=ge.call(bt)}catch{}var ce=G.allocUnsafe,et=!!V&&!G,S=new Uint16Array(32),Gt=!G||!!V&&V.prototype.isPrototypeOf(bt);function mt(){}function At(r){var e=r&&r.buffer||r,t=ge.call(e);if(t!==Ht&&t!==jt&&t!==zt&&t!=="[object ArrayBuffer]"&&r!==void 0)throw TypeError("Failed to execute 'decode' on 'TextDecoder': The provided value is not of type '(ArrayBuffer or ArrayBufferView)'");r=Gt?new V(e):e||[],t=e="";for(var n=0,o=r.length|0,h=o-32|0,F,d,w=0,x=0,y,g=0,I=-1;n<o;){for(F=n<=h?32:o-n|0;g<F;n=n+1|0,g=g+1|0){switch(d=r[n]&255,d>>4){case 15:if(y=r[n=n+1|0]&255,y>>6!==2||247<d){n=n-1|0;break}w=(d&7)<<6|y&63,x=5,d=256;case 14:y=r[n=n+1|0]&255,w<<=6,w|=(d&15)<<6|y&63,x=y>>6===2?x+4|0:24,d=d+256&768;case 13:case 12:y=r[n=n+1|0]&255,w<<=6,w|=(d&31)<<6|y&63,x=x+7|0,n<o&&y>>6===2&&w>>x&&1114112>w?(d=w,w=w-65536|0,0<=w&&(I=(w>>10)+55296|0,d=(w&1023)+56320|0,31>g?(S[g]=I,g=g+1|0,I=-1):(y=I,I=d,d=y))):(d>>=8,n=n-d-1|0,d=65533),w=x=0,F=n<=h?32:o-n|0;default:S[g]=d;continue;case 11:case 10:case 9:case 8:}S[g]=65533}if(t+=Ze(S[0],S[1],S[2],S[3],S[4],S[5],S[6],S[7],S[8],S[9],S[10],S[11],S[12],S[13],S[14],S[15],S[16],S[17],S[18],S[19],S[20],S[21],S[22],S[23],S[24],S[25],S[26],S[27],S[28],S[29],S[30],S[31]),32>g&&(t=t.slice(0,g-32|0)),n<o){if(S[0]=I,g=~I>>>31,I=-1,t.length<e.length)continue}else I!==-1&&(t+=Ze(I));e+=t,t=""}return e}mt.prototype.decode=At;function kt(r){r=r===void 0?"":""+r;var e=r.length|0,t=et?new V((e<<1)+8|0):ce?ce((e<<1)+8|0):new G((e<<1)+8|0),n,o=0,h=!1;for(n=0;n<e;n=n+1|0,o=o+1|0){var F=r.charCodeAt(n)|0;if(127>=F)t[o]=F;else{if(2047>=F)t[o]=192|F>>6;else{e:{if(55296<=F)if(56320>F){var d=r.charCodeAt(n=n+1|0)|0;if(56320<=d&&57343>=d){if(F=(F<<10)+d-56613888|0,65535<F){t[o]=240|F>>18,t[o=o+1|0]=128|F>>12&63,t[o=o+1|0]=128|F>>6&63,t[o=o+1|0]=128|F&63;continue}break e}F=65533}else 57343>=F&&(F=65533);!h&&n<<1<o&&n<<1<(o-7|0)&&(h=!0,d=et?new V(3*e):ce?ce(3*e):new G(3*e),d.set(t),t=d)}t[o]=224|F>>12,t[o=o+1|0]=128|F>>6&63}t[o=o+1|0]=128|F&63}}return t.subarray(0,o)}function Ot(r,e){var t=r[e];return function(){return t.apply(r,arguments)}}var _e=J.TextDecoder,tt=J.TextEncoder,Jt=_e||mt;_e&&Ot(new _e,"decode");tt&&Ot(new tt,"encode");const j=10*1024*1024;let Be;Q?Be=new B({size:3,read(r,e){return r[e+0]<<16|r[e+1]<<8|r[e+2]}}):Be=new B({size:3,read(r,e){return r[e+2]<<16|r[e+1]<<8|r[e+0]}});const rt=new B({sizeOf(r,e){const t=le.read(r,e);return le.size+t},read(r,e){let t=0,n=0;const o=le.read(r,e);for(let h=0;h<o;h++)t=t+n*L.read(r,e++),n*=256;return t}}),st=new B({sizeOf(r,e){const t=b.read(r,e);return b.size+t},read(r,e){const t=b.read(r,e);N(t<j,"asciiString too big"),e+=4;let n="";for(let o=0;o<t;o++)n+=String.fromCharCode(r[e++]);return n}}),Vt=new B({sizeOf(r,e){return b.size+b.read(r,e)},read(r,e){const t=b.read(r,e);return N(t<j,"bytes too big"),e+=b.size,N(t<j,"uint8a array too big"),new Uint8Array(r.buffer,e,t)}}),$t=new B({sizeOf(r,e){return b.size+b.read(r,e)*2},read(r,e){const t=b.read(r,e);N(t<j,"sound too big"),e+=b.size;const n=t*2;return N(n<j,"uint8a array too big"),new Uint8Array(r.buffer,e,n)}}),Yt=new B({sizeOf(r,e){return b.size+b.read(r,e)*b.size},read(r,e){const t=b.read(r,e);N(t<j,"bitmap too big"),e+=b.size,N(t<j,"uint8a array too big");const n=new Uint32Array(t);for(let o=0;o<t;o++)n[o]=b.read(r,e),e+=b.size;return n}});let Le;typeof TextDecoder>"u"?Le=new Jt:Le=new TextDecoder;const Wt=new B({sizeOf(r,e){return b.size+b.read(r,e)},read(r,e){const t=b.read(r,e);return N(t<j,"utf8 too big"),e+=b.size,N(t<j,"uint8a array too big"),Le.decode(new Uint8Array(r.buffer,e,t))}}),qt=new B({size:4,read(r,e){const t=b.read(r,e),n=255,o=t>>22&255,h=t>>12&255,F=t>>2&255;return(n<<24|o<<16|h<<8|F)>>>0}}),Xt=new B({size:5,read(r,e){const t=b.read(r,e),n=L.read(r,e),o=t>>22&255,h=t>>12&255,F=t>>2&255;return(n<<24|o<<16|h<<8|F)>>>0}}),p={NULL:1,TRUE:2,FALSE:3,SMALL_INT:4,SMALL_INT_16:5,LARGE_INT_POSITIVE:6,LARGE_INT_NEGATIVE:7,FLOATING:8,STRING:9,SYMBOL:10,BYTES:11,SOUND:12,BITMAP:13,UTF8:14,ARRAY:20,ORDERED_COLLECTION:21,SET:22,IDENTITY_SET:23,DICTIONARY:24,IDENTITY_DICTIONARY:25,COLOR:30,TRANSLUCENT_COLOR:31,POINT:32,RECTANGLE:33,FORM:34,SQUEAK:35,OBJECT_REF:99,MORPH:100,ALIGNMENT:104,STATIC_STRING:105,UPDATING_STRING:106,SAMPLED_SOUND:109,IMAGE_MORPH:110,SPRITE:124,STAGE:125,WATCHER:155,IMAGE_MEDIA:162,SOUND_MEDIA:164,MULTILINE_STRING:171,WATCHER_READOUT_FRAME:173,WATCHER_SLIDER:174,LIST_WATCHER:175},Tt=Object.entries(p).reduce((r,[e,t])=>(r[t]=e,r),{});class Ee{constructor(e,t){this.classId=e,this.position=t}}const Ne=r=>typeof r=="object"&&r?r.valueOf():r;class Me extends Ee{constructor(e,t,n){super(e,t),this.value=n}valueOf(){return this.value}toJSON(){return this.classId===p.TRANSLUCENT_COLOR||this.classId===p.COLOR?this.value&16777215:this.value}toString(){return this.value}}class U extends Ee{constructor(e,t,n){super(e,t),this.size=n}}class Je extends Ee{constructor(e,t,n){super(e,t),this.index=n}valueOf(){return`Ref(${this.index})`}}class Kt extends U{constructor(e,t){super(e,t,0)}}class It extends U{constructor(e,t,n,o){super(e,t,o),this.version=n}}class vt{constructor({type:e=Me,read:t,value:n=t?(o=>o.read(t)):null}){this.type=e,this.value=n}next(e,t,n){return{value:new this.type(t,n,this.value(e)),done:!1}}}const nt={[p.NULL]:{value:()=>null},[p.TRUE]:{value:()=>!0},[p.FALSE]:{value:()=>!1},[p.SMALL_INT]:{read:k},[p.SMALL_INT_16]:{read:le},[p.LARGE_INT_POSITIVE]:{read:rt},[p.LARGE_INT_NEGATIVE]:{read:rt},[p.FLOATING]:{read:Ut},[p.STRING]:{read:st},[p.SYMBOL]:{read:st},[p.BYTES]:{read:Vt},[p.SOUND]:{read:$t},[p.BITMAP]:{read:Yt},[p.UTF8]:{read:Wt},[p.ARRAY]:{type:U,read:k},[p.ORDERED_COLLECTION]:{type:U,read:k},[p.SET]:{type:U,read:k},[p.IDENTITY_SET]:{type:U,read:k},[p.DICTIONARY]:{type:U,value:r=>r.read(k)*2},[p.IDENTITY_DICTIONARY]:{type:U,value:r=>r.read(k)*2},[p.COLOR]:{read:qt},[p.TRANSLUCENT_COLOR]:{read:Xt},[p.POINT]:{type:U,value:()=>2},[p.RECTANGLE]:{type:U,value:()=>4},[p.FORM]:{type:U,value:()=>5},[p.SQUEAK]:{type:U,value:()=>6},[p.OBJECT_REF]:{type:Je,read:Be}},Zt=Array.from({length:256},(r,e)=>nt[e]?new vt(nt[e]):null),Qt=new vt({type:Kt,value:()=>null});class it{constructor(e,t){this.buffer=e,this.stream=new Z(e,t)}[Symbol.iterator](){return this}next(){if(this.stream.position>=this.stream.uint8a.length)return{value:null,done:!0};const e=this.stream.position,t=this.stream.read(L),n=Zt[t];if(n!==null)return n.next(this.stream,t,e);if(t<p.OBJECT_REF)return Qt.next(this.stream,t,e);const o=this.stream.read(L),h=this.stream.read(L);return{value:new It(t,e,o,h),done:!1}}}const er=r=>r.toLowerCase().replace(/_(\w)/g,([,e])=>e.toUpperCase());class R{constructor({classId:e,version:t,fields:n}){this.classId=e,this.version=t,this.fields=n}get FIELDS(){return[]}get RAW_FIELDS(){return this.fields}string(e){return String(this.fields[e])}number(e){return+this.fields[e]}boolean(e){return!!this.fields[e]}toString(){return this.constructor===R?`${this.constructor.name} ${this.classId} ${Tt[this.classId]}`:this.constructor.name}static define(e,t=R){class n extends t{get FIELDS(){return e}static get FIELDS(){return e}}return Object.keys(e).forEach(o=>{const h=e[o];Object.defineProperty(n.prototype,er(o),{get(){return this.fields[h]}})}),n}}class Ve{constructor(){this.bit=new Uint32Array(1),this.crc=0,this.c=0,this.table=[];let e;for(let t=0;t<256;t++){e=t;for(let n=0;n<8;n++)e=e&1?3988292384^e>>>1:e>>>1;this.table[t]=e>>>0}}update(e,t=0,n=e.length){let o=~this.crc>>>0;for(let h=0;h<n;h++)o=o>>>8^this.table[(o^e[t+h])&255];return this.crc=~o>>>0,this}get digest(){return this.crc}}const tr=[0,4278190080,4294967295,4286611584,4294901760,4278255360,4278190335,4278255615,4294967040,4294902015,4280295456,4282400832,4284506208,4288651167,4290756543,4292861919,4278716424,4279242768,4279769112,4280821800,4281348144,4281874488,4282927176,4283453520,4283979864,4285032552,4285558896,4286085240,4287072135,4287598479,4288124823,4289177511,4289703855,4290230199,4291282887,4291809231,4292335575,4293388263,4293914607,4294440951,4278190080,4278203136,4278216192,4278229248,4278242304,4278255360,4278190131,4278203187,4278216243,4278229299,4278242355,4278255411,4278190182,4278203238,4278216294,4278229350,4278242406,4278255462,4278190233,4278203289,4278216345,4278229401,4278242457,4278255513,4278190284,4278203340,4278216396,4278229452,4278242508,4278255564,4278190335,4278203391,4278216447,4278229503,4278242559,4278255615,4281532416,4281545472,4281558528,4281571584,4281584640,4281597696,4281532467,4281545523,4281558579,4281571635,4281584691,4281597747,4281532518,4281545574,4281558630,4281571686,4281584742,4281597798,4281532569,4281545625,4281558681,4281571737,4281584793,4281597849,4281532620,4281545676,4281558732,4281571788,4281584844,4281597900,4281532671,4281545727,4281558783,4281571839,4281584895,4281597951,4284874752,4284887808,4284900864,4284913920,4284926976,4284940032,4284874803,4284887859,4284900915,4284913971,4284927027,4284940083,4284874854,4284887910,4284900966,4284914022,4284927078,4284940134,4284874905,4284887961,4284901017,4284914073,4284927129,4284940185,4284874956,4284888012,4284901068,4284914124,4284927180,4284940236,4284875007,4284888063,4284901119,4284914175,4284927231,4284940287,4288217088,4288230144,4288243200,4288256256,4288269312,4288282368,4288217139,4288230195,4288243251,4288256307,4288269363,4288282419,4288217190,4288230246,4288243302,4288256358,4288269414,4288282470,4288217241,4288230297,4288243353,4288256409,4288269465,4288282521,4288217292,4288230348,4288243404,4288256460,4288269516,4288282572,4288217343,4288230399,4288243455,4288256511,4288269567,4288282623,4291559424,4291572480,4291585536,4291598592,4291611648,4291624704,4291559475,4291572531,4291585587,4291598643,4291611699,4291624755,4291559526,4291572582,4291585638,4291598694,4291611750,4291624806,4291559577,4291572633,4291585689,4291598745,4291611801,4291624857,4291559628,4291572684,4291585740,4291598796,4291611852,4291624908,4291559679,4291572735,4291585791,4291598847,4291611903,4291624959,4294901760,4294914816,4294927872,4294940928,4294953984,4294967040,4294901811,4294914867,4294927923,4294940979,4294954035,4294967091,4294901862,4294914918,4294927974,4294941030,4294954086,4294967142,4294901913,4294914969,4294928025,4294941081,4294954137,4294967193,4294901964,4294915020,4294928076,4294941132,4294954188,4294967244,4294902015,4294915071,4294928127,4294941183,4294954239,4294967295],rr=[4294967295,4278190080],ot=new B({sizeOf(r,e){const t=r[e];return t<=223?1:t<=254?2:5},read(r,e){const t=r[e];return t<=223?t:t<=254?(t-224)*256+r[e+1]:b.read(r,e+1)}});class sr{decode(e,t,n,o,h){const F=this.decodePixels(o,n===32);if(n<=8)return h||(h=n===1?rr:tr),this.unpackPixels(F,e,t,n,h);if(n===16)return this.raster16To32(F,e,t);if(n===32)return F;throw new Error("Unhandled Squeak Image depth.")}decodePixels(e,t){let n;if(Array.isArray(e)||e instanceof Uint32Array){if(n=new Uint32Array(e),t)for(let d=0;d<n.length;d++)n[d]!==0&&(n[d]=4278190080|n[d]);return n}const o=new Z(e.buffer,e.byteOffset),h=o.read(ot);n=new Uint32Array(h);let F=0;for(;F<h;){const d=o.read(ot),w=d>>2,x=d&3;let y;switch(x){case 0:F+=w;break;case 1:y=o.read(L),y=y<<24|y<<16|y<<8|y,t&&y!==0&&(y|=4278190080);for(let g=0;g<w;g++)n[F++]=y;break;case 2:y=o.read(b),t&&y!==0&&(y|=4278190080);for(let g=0;g<w;g++)n[F++]=y;break;case 3:for(let g=0;g<w;g++)y=o.read(b),t&&y!==0&&(y|=4278190080),n[F++]=y}}return n}unpackPixels(e,t,n,o,h){const F=new Uint32Array(t*n),d=(1<<o)-1,w=32/o;let x=0,y=0;for(let g=0;g<n;g++){let I,M=-1;for(let A=0;A<t;A++)M<0&&(M=o*(w-1),I=e[y++]),F[x++]=h[I>>M&d],M-=o}return F}raster16To32(e,t,n){const o=new Uint32Array(2*e.length);let h,F,d,w=0,x=0;for(let y=0;y<n;y++){h=-1;for(let g=0;g<t;g++){if(h<0&&(h=16,F=e[w++]),d=F>>h&65535,d!==0){const I=d>>7&248,M=d>>2&248,A=d<<3&248;d=4278190080|I<<16|M<<8|A}o[x++]=d,h-=16}}return o}buildCustomColormap(e,t,n){const o=new Uint32Array(1<<e);for(let h=0;h<t.length;h++)o[h]=n[t[h].index-1];return o}}const nr=[7,8,9,10,11,12,13,14,16,17,19,21,23,25,28,31,34,37,41,45,50,55,60,66,73,80,88,97,107,118,130,143,157,173,190,209,230,253,279,307,337,371,408,449,494,544,598,658,724,796,876,963,1060,1166,1282,1411,1552,1707,1878,2066,2272,2499,2749,3024,3327,3660,4026,4428,4871,5358,5894,6484,7132,7845,8630,9493,10442,11487,12635,13899,15289,16818,18500,20350,22385,24623,27086,29794,32767],ir={2:[-1,2,-1,2],3:[-1,-1,2,4,-1,-1,2,4],4:[-1,-1,-1,-1,2,4,6,8,-1,-1,-1,-1,2,4,6,8],5:[-1,-1,-1,-1,-1,-1,-1,-1,1,2,4,6,8,10,13,16,-1,-1,-1,-1,-1,-1,-1,-1,1,2,4,6,8,10,13,16]};class at{constructor(e){this.bitsPerSample=e,this.indexTable=ir[e],this.signMask=1<<e-1,this.valueMask=this.signMask-1,this.valueHighBit=this.signMask>>1,this.bitPosition=0,this.currentByte=0,this.stream=null,this.end=0}decode(e){this.bitPosition=0,this.currentByte=0,this.stream=new Z(e.buffer,e.byteOffset),this.end=e.byteOffset+e.length;const t=Math.floor(e.length*8/this.bitsPerSample),n=new Int16Array(t);let o=0,h=0;for(let F=0;F<t;F++){const d=this.nextCode();N(d>=0,"Ran out of bits in Squeak Sound");let w=nr[h],x=0;for(let y=this.valueHighBit;y>0;y=y>>1)(d&y)!==0&&(x+=w),w=w>>1;x+=w,o+=(d&this.signMask)===0?x:-x,h+=this.indexTable[d],h<0&&(h=0),h>88&&(h=88),o>32767&&(o=32767),o<-32768&&(o=-32768),n[F]=o}return n}nextCode(){let e=this.bitsPerSample,t=e-this.bitPosition,n=t<0?this.currentByte>>-t:this.currentByte<<t;for(;t>0;){if(e-=this.bitPosition,this.end-this.stream.position>0)this.currentByte=this.stream.read(L),this.bitPosition=8;else return this.currentByte=0,this.bitPosition=0,-1;t=e-this.bitPosition,n+=t<0?this.currentByte>>-t:this.currentByte<<t}return this.bitPosition-=e,this.currentByte=this.currentByte&255>>8-this.bitPosition,n}static samples(e,t){return t.length*8/e}}class m{constructor(e=new Uint8Array(this.size),t=0){this.uint8a=e,this.offset=t}equals(e){for(const t in e)if(this[t]!==e[t])return!1;return!0}view(){const e=this.constructor.name,t={toString(){return e}};for(const n in this.shape)t[n]=this[n];return t}static initConstructor(e){return e.size=e.prototype.size,e}static extend(e){const t=class extends m{get shape(){return e}};let n=0;return Object.keys(e).forEach(o=>{if(Object.defineProperty(t.prototype,o,e[o].asPropertyObject(n)),e[o].size===0)throw new Error("Packet cannot be defined with variable sized members.");n+=e[o].size}),t.prototype.size=n,t.size=n,t}}class re extends m.extend({riff:new z(4),length:se,wave:new z(4)}){}m.initConstructor(re);class H extends m.extend({chunkType:new z(4),length:se}){}m.initConstructor(H);class Fe extends m.extend({format:X,channels:X,sampleRate:se,bytesPerSec:se,blockAlignment:X,bitsPerSample:X}){}m.initConstructor(Fe);class we{encode(e,{channels:t=1,sampleRate:n=22050}={}){const o=new Uint8Array(e.buffer,e.byteOffset,e.byteLength),h=re.size+H.size+Fe.size+H.size+o.length,F=new Z(new ArrayBuffer(h));return F.writeStruct(re,{riff:"RIFF",length:h-8,wave:"WAVE"}),F.writeStruct(H,{chunkType:"fmt ",length:Fe.size}),F.writeStruct(Fe,{format:1,channels:t,sampleRate:n,bytesPerSec:n*2*t,blockAlignment:t*2,bitsPerSample:16}),F.writeStruct(H,{chunkType:"data",length:h-F.position-H.size}),F.writeBytes(o),F.uint8a}static encode(e,t){return new we().encode(e,t)}static samples(e){const t=new H(e,re.size).length;return new H(e,re.size+H.size+t).length/2}}var or=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function ar(r){return r&&r.__esModule&&Object.prototype.hasOwnProperty.call(r,"default")?r.default:r}function cr(r){if(Object.prototype.hasOwnProperty.call(r,"__esModule"))return r;var e=r.default;if(typeof e=="function"){var t=function n(){var o=!1;try{o=this instanceof n}catch{}return o?Reflect.construct(e,arguments,this.constructor):e.apply(this,arguments)};t.prototype=e.prototype}else t={};return Object.defineProperty(t,"__esModule",{value:!0}),Object.keys(r).forEach(function(n){var o=Object.getOwnPropertyDescriptor(r,n);Object.defineProperty(t,n,o.get?o:{enumerable:!0,get:function(){return r[n]}})}),t}var me={exports:{}};const hr={},lr=Object.freeze(Object.defineProperty({__proto__:null,default:hr},Symbol.toStringTag,{value:"Module"})),ct=cr(lr);var ht;function Fr(){return ht||(ht=1,(function(r){(function(){var e="input is invalid type",t="finalize already called",n=typeof window=="object",o=n?window:{};o.JS_MD5_NO_WINDOW&&(n=!1);var h=!n&&typeof self=="object",F=!o.JS_MD5_NO_NODE_JS&&typeof process=="object"&&process.versions&&process.versions.node;F?o=or:h&&(o=self);var d=!o.JS_MD5_NO_COMMON_JS&&!0&&r.exports,w=!o.JS_MD5_NO_ARRAY_BUFFER&&typeof ArrayBuffer<"u",x="0123456789abcdef".split(""),y=[128,32768,8388608,-2147483648],g=[0,8,16,24],I=["hex","array","digest","buffer","arrayBuffer","base64"],M="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/".split(""),A=[],ne;if(w){var ie=new ArrayBuffer(68);ne=new Uint8Array(ie),A=new Uint32Array(ie)}var $=Array.isArray;(o.JS_MD5_NO_NODE_JS||!$)&&($=function(s){return Object.prototype.toString.call(s)==="[object Array]"});var Y=ArrayBuffer.isView;w&&(o.JS_MD5_NO_ARRAY_BUFFER_IS_VIEW||!Y)&&(Y=function(s){return typeof s=="object"&&s.buffer&&s.buffer.constructor===ArrayBuffer});var f=function(s){var a=typeof s;if(a==="string")return[s,!0];if(a!=="object"||s===null)throw new Error(e);if(w&&s.constructor===ArrayBuffer)return[new Uint8Array(s),!1];if(!$(s)&&!Y(s))throw new Error(e);return[s,!1]},O=function(s){return function(a){return new v(!0).update(a)[s]()}},T=function(){var s=O("hex");F&&(s=P(s)),s.create=function(){return new v},s.update=function(i){return s.create().update(i)};for(var a=0;a<I.length;++a){var c=I[a];s[c]=O(c)}return s},P=function(s){var a=ct,c=ct.Buffer,i;c.from&&!o.JS_MD5_NO_BUFFER_FROM?i=c.from:i=function(u){return new c(u)};var C=function(u){if(typeof u=="string")return a.createHash("md5").update(u,"utf8").digest("hex");if(u==null)throw new Error(e);return u.constructor===ArrayBuffer&&(u=new Uint8Array(u)),$(u)||Y(u)||u.constructor===c?a.createHash("md5").update(i(u)).digest("hex"):s(u)};return C},oe=function(s){return function(a,c){return new ae(a,!0).update(c)[s]()}},be=function(){var s=oe("hex");s.create=function(i){return new ae(i)},s.update=function(i,C){return s.create(i).update(C)};for(var a=0;a<I.length;++a){var c=I[a];s[c]=oe(c)}return s};function v(s){if(s)A[0]=A[16]=A[1]=A[2]=A[3]=A[4]=A[5]=A[6]=A[7]=A[8]=A[9]=A[10]=A[11]=A[12]=A[13]=A[14]=A[15]=0,this.blocks=A,this.buffer8=ne;else if(w){var a=new ArrayBuffer(68);this.buffer8=new Uint8Array(a),this.blocks=new Uint32Array(a)}else this.blocks=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0];this.h0=this.h1=this.h2=this.h3=this.start=this.bytes=this.hBytes=0,this.finalized=this.hashed=!1,this.first=!0}v.prototype.update=function(s){if(this.finalized)throw new Error(t);var a=f(s);s=a[0];for(var c=a[1],i,C=0,u,l=s.length,E=this.blocks,D=this.buffer8;C<l;){if(this.hashed&&(this.hashed=!1,E[0]=E[16],E[16]=E[1]=E[2]=E[3]=E[4]=E[5]=E[6]=E[7]=E[8]=E[9]=E[10]=E[11]=E[12]=E[13]=E[14]=E[15]=0),c)if(w)for(u=this.start;C<l&&u<64;++C)i=s.charCodeAt(C),i<128?D[u++]=i:i<2048?(D[u++]=192|i>>>6,D[u++]=128|i&63):i<55296||i>=57344?(D[u++]=224|i>>>12,D[u++]=128|i>>>6&63,D[u++]=128|i&63):(i=65536+((i&1023)<<10|s.charCodeAt(++C)&1023),D[u++]=240|i>>>18,D[u++]=128|i>>>12&63,D[u++]=128|i>>>6&63,D[u++]=128|i&63);else for(u=this.start;C<l&&u<64;++C)i=s.charCodeAt(C),i<128?E[u>>>2]|=i<<g[u++&3]:i<2048?(E[u>>>2]|=(192|i>>>6)<<g[u++&3],E[u>>>2]|=(128|i&63)<<g[u++&3]):i<55296||i>=57344?(E[u>>>2]|=(224|i>>>12)<<g[u++&3],E[u>>>2]|=(128|i>>>6&63)<<g[u++&3],E[u>>>2]|=(128|i&63)<<g[u++&3]):(i=65536+((i&1023)<<10|s.charCodeAt(++C)&1023),E[u>>>2]|=(240|i>>>18)<<g[u++&3],E[u>>>2]|=(128|i>>>12&63)<<g[u++&3],E[u>>>2]|=(128|i>>>6&63)<<g[u++&3],E[u>>>2]|=(128|i&63)<<g[u++&3]);else if(w)for(u=this.start;C<l&&u<64;++C)D[u++]=s[C];else for(u=this.start;C<l&&u<64;++C)E[u>>>2]|=s[C]<<g[u++&3];this.lastByteIndex=u,this.bytes+=u-this.start,u>=64?(this.start=u-64,this.hash(),this.hashed=!0):this.start=u}return this.bytes>4294967295&&(this.hBytes+=this.bytes/4294967296<<0,this.bytes=this.bytes%4294967296),this},v.prototype.finalize=function(){if(!this.finalized){this.finalized=!0;var s=this.blocks,a=this.lastByteIndex;s[a>>>2]|=y[a&3],a>=56&&(this.hashed||this.hash(),s[0]=s[16],s[16]=s[1]=s[2]=s[3]=s[4]=s[5]=s[6]=s[7]=s[8]=s[9]=s[10]=s[11]=s[12]=s[13]=s[14]=s[15]=0),s[14]=this.bytes<<3,s[15]=this.hBytes<<3|this.bytes>>>29,this.hash()}},v.prototype.hash=function(){var s,a,c,i,C,u,l=this.blocks;this.first?(s=l[0]-680876937,s=(s<<7|s>>>25)-271733879<<0,i=(-1732584194^s&2004318071)+l[1]-117830708,i=(i<<12|i>>>20)+s<<0,c=(-271733879^i&(s^-271733879))+l[2]-1126478375,c=(c<<17|c>>>15)+i<<0,a=(s^c&(i^s))+l[3]-1316259209,a=(a<<22|a>>>10)+c<<0):(s=this.h0,a=this.h1,c=this.h2,i=this.h3,s+=(i^a&(c^i))+l[0]-680876936,s=(s<<7|s>>>25)+a<<0,i+=(c^s&(a^c))+l[1]-389564586,i=(i<<12|i>>>20)+s<<0,c+=(a^i&(s^a))+l[2]+606105819,c=(c<<17|c>>>15)+i<<0,a+=(s^c&(i^s))+l[3]-1044525330,a=(a<<22|a>>>10)+c<<0),s+=(i^a&(c^i))+l[4]-176418897,s=(s<<7|s>>>25)+a<<0,i+=(c^s&(a^c))+l[5]+1200080426,i=(i<<12|i>>>20)+s<<0,c+=(a^i&(s^a))+l[6]-1473231341,c=(c<<17|c>>>15)+i<<0,a+=(s^c&(i^s))+l[7]-45705983,a=(a<<22|a>>>10)+c<<0,s+=(i^a&(c^i))+l[8]+1770035416,s=(s<<7|s>>>25)+a<<0,i+=(c^s&(a^c))+l[9]-1958414417,i=(i<<12|i>>>20)+s<<0,c+=(a^i&(s^a))+l[10]-42063,c=(c<<17|c>>>15)+i<<0,a+=(s^c&(i^s))+l[11]-1990404162,a=(a<<22|a>>>10)+c<<0,s+=(i^a&(c^i))+l[12]+1804603682,s=(s<<7|s>>>25)+a<<0,i+=(c^s&(a^c))+l[13]-40341101,i=(i<<12|i>>>20)+s<<0,c+=(a^i&(s^a))+l[14]-1502002290,c=(c<<17|c>>>15)+i<<0,a+=(s^c&(i^s))+l[15]+1236535329,a=(a<<22|a>>>10)+c<<0,s+=(c^i&(a^c))+l[1]-165796510,s=(s<<5|s>>>27)+a<<0,i+=(a^c&(s^a))+l[6]-1069501632,i=(i<<9|i>>>23)+s<<0,c+=(s^a&(i^s))+l[11]+643717713,c=(c<<14|c>>>18)+i<<0,a+=(i^s&(c^i))+l[0]-373897302,a=(a<<20|a>>>12)+c<<0,s+=(c^i&(a^c))+l[5]-701558691,s=(s<<5|s>>>27)+a<<0,i+=(a^c&(s^a))+l[10]+38016083,i=(i<<9|i>>>23)+s<<0,c+=(s^a&(i^s))+l[15]-660478335,c=(c<<14|c>>>18)+i<<0,a+=(i^s&(c^i))+l[4]-405537848,a=(a<<20|a>>>12)+c<<0,s+=(c^i&(a^c))+l[9]+568446438,s=(s<<5|s>>>27)+a<<0,i+=(a^c&(s^a))+l[14]-1019803690,i=(i<<9|i>>>23)+s<<0,c+=(s^a&(i^s))+l[3]-187363961,c=(c<<14|c>>>18)+i<<0,a+=(i^s&(c^i))+l[8]+1163531501,a=(a<<20|a>>>12)+c<<0,s+=(c^i&(a^c))+l[13]-1444681467,s=(s<<5|s>>>27)+a<<0,i+=(a^c&(s^a))+l[2]-51403784,i=(i<<9|i>>>23)+s<<0,c+=(s^a&(i^s))+l[7]+1735328473,c=(c<<14|c>>>18)+i<<0,a+=(i^s&(c^i))+l[12]-1926607734,a=(a<<20|a>>>12)+c<<0,C=a^c,s+=(C^i)+l[5]-378558,s=(s<<4|s>>>28)+a<<0,i+=(C^s)+l[8]-2022574463,i=(i<<11|i>>>21)+s<<0,u=i^s,c+=(u^a)+l[11]+1839030562,c=(c<<16|c>>>16)+i<<0,a+=(u^c)+l[14]-35309556,a=(a<<23|a>>>9)+c<<0,C=a^c,s+=(C^i)+l[1]-1530992060,s=(s<<4|s>>>28)+a<<0,i+=(C^s)+l[4]+1272893353,i=(i<<11|i>>>21)+s<<0,u=i^s,c+=(u^a)+l[7]-155497632,c=(c<<16|c>>>16)+i<<0,a+=(u^c)+l[10]-1094730640,a=(a<<23|a>>>9)+c<<0,C=a^c,s+=(C^i)+l[13]+681279174,s=(s<<4|s>>>28)+a<<0,i+=(C^s)+l[0]-358537222,i=(i<<11|i>>>21)+s<<0,u=i^s,c+=(u^a)+l[3]-722521979,c=(c<<16|c>>>16)+i<<0,a+=(u^c)+l[6]+76029189,a=(a<<23|a>>>9)+c<<0,C=a^c,s+=(C^i)+l[9]-640364487,s=(s<<4|s>>>28)+a<<0,i+=(C^s)+l[12]-421815835,i=(i<<11|i>>>21)+s<<0,u=i^s,c+=(u^a)+l[15]+530742520,c=(c<<16|c>>>16)+i<<0,a+=(u^c)+l[2]-995338651,a=(a<<23|a>>>9)+c<<0,s+=(c^(a|~i))+l[0]-198630844,s=(s<<6|s>>>26)+a<<0,i+=(a^(s|~c))+l[7]+1126891415,i=(i<<10|i>>>22)+s<<0,c+=(s^(i|~a))+l[14]-1416354905,c=(c<<15|c>>>17)+i<<0,a+=(i^(c|~s))+l[5]-57434055,a=(a<<21|a>>>11)+c<<0,s+=(c^(a|~i))+l[12]+1700485571,s=(s<<6|s>>>26)+a<<0,i+=(a^(s|~c))+l[3]-1894986606,i=(i<<10|i>>>22)+s<<0,c+=(s^(i|~a))+l[10]-1051523,c=(c<<15|c>>>17)+i<<0,a+=(i^(c|~s))+l[1]-2054922799,a=(a<<21|a>>>11)+c<<0,s+=(c^(a|~i))+l[8]+1873313359,s=(s<<6|s>>>26)+a<<0,i+=(a^(s|~c))+l[15]-30611744,i=(i<<10|i>>>22)+s<<0,c+=(s^(i|~a))+l[6]-1560198380,c=(c<<15|c>>>17)+i<<0,a+=(i^(c|~s))+l[13]+1309151649,a=(a<<21|a>>>11)+c<<0,s+=(c^(a|~i))+l[4]-145523070,s=(s<<6|s>>>26)+a<<0,i+=(a^(s|~c))+l[11]-1120210379,i=(i<<10|i>>>22)+s<<0,c+=(s^(i|~a))+l[2]+718787259,c=(c<<15|c>>>17)+i<<0,a+=(i^(c|~s))+l[9]-343485551,a=(a<<21|a>>>11)+c<<0,this.first?(this.h0=s+1732584193<<0,this.h1=a-271733879<<0,this.h2=c-1732584194<<0,this.h3=i+271733878<<0,this.first=!1):(this.h0=this.h0+s<<0,this.h1=this.h1+a<<0,this.h2=this.h2+c<<0,this.h3=this.h3+i<<0)},v.prototype.hex=function(){this.finalize();var s=this.h0,a=this.h1,c=this.h2,i=this.h3;return x[s>>>4&15]+x[s&15]+x[s>>>12&15]+x[s>>>8&15]+x[s>>>20&15]+x[s>>>16&15]+x[s>>>28&15]+x[s>>>24&15]+x[a>>>4&15]+x[a&15]+x[a>>>12&15]+x[a>>>8&15]+x[a>>>20&15]+x[a>>>16&15]+x[a>>>28&15]+x[a>>>24&15]+x[c>>>4&15]+x[c&15]+x[c>>>12&15]+x[c>>>8&15]+x[c>>>20&15]+x[c>>>16&15]+x[c>>>28&15]+x[c>>>24&15]+x[i>>>4&15]+x[i&15]+x[i>>>12&15]+x[i>>>8&15]+x[i>>>20&15]+x[i>>>16&15]+x[i>>>28&15]+x[i>>>24&15]},v.prototype.toString=v.prototype.hex,v.prototype.digest=function(){this.finalize();var s=this.h0,a=this.h1,c=this.h2,i=this.h3;return[s&255,s>>>8&255,s>>>16&255,s>>>24&255,a&255,a>>>8&255,a>>>16&255,a>>>24&255,c&255,c>>>8&255,c>>>16&255,c>>>24&255,i&255,i>>>8&255,i>>>16&255,i>>>24&255]},v.prototype.array=v.prototype.digest,v.prototype.arrayBuffer=function(){this.finalize();var s=new ArrayBuffer(16),a=new Uint32Array(s);return a[0]=this.h0,a[1]=this.h1,a[2]=this.h2,a[3]=this.h3,s},v.prototype.buffer=v.prototype.arrayBuffer,v.prototype.base64=function(){for(var s,a,c,i="",C=this.array(),u=0;u<15;)s=C[u++],a=C[u++],c=C[u++],i+=M[s>>>2]+M[(s<<4|a>>>4)&63]+M[(a<<2|c>>>6)&63]+M[c&63];return s=C[u],i+=M[s>>>2]+M[s<<4&63]+"==",i};function ae(s,a){var c,i=f(s);if(s=i[0],i[1]){var C=[],u=s.length,l=0,E;for(c=0;c<u;++c)E=s.charCodeAt(c),E<128?C[l++]=E:E<2048?(C[l++]=192|E>>>6,C[l++]=128|E&63):E<55296||E>=57344?(C[l++]=224|E>>>12,C[l++]=128|E>>>6&63,C[l++]=128|E&63):(E=65536+((E&1023)<<10|s.charCodeAt(++c)&1023),C[l++]=240|E>>>18,C[l++]=128|E>>>12&63,C[l++]=128|E>>>6&63,C[l++]=128|E&63);s=C}s.length>64&&(s=new v(!0).update(s).array());var D=[],We=[];for(c=0;c<64;++c){var qe=s[c]||0;D[c]=92^qe,We[c]=54^qe}v.call(this,a),this.update(We),this.oKeyPad=D,this.inner=!0,this.sharedMemory=a}ae.prototype=new v,ae.prototype.finalize=function(){if(v.prototype.finalize.call(this),this.inner){this.inner=!1;var s=this.array();v.call(this,this.sharedMemory),this.update(this.oKeyPad),this.update(s),v.prototype.finalize.call(this)}};var ee=T();ee.md5=ee,ee.md5.hmac=be(),d?r.exports=ee:o.md5=ee})()})(me)),me.exports}var Rt=Fr();class ur extends R.define({X:0,Y:1}){}class fr extends R.define({X:0,Y:1,X2:2,Y2:3}){get width(){return this.x2-this.x}get height(){return this.y2-this.y}}const dr=r=>{for(let e=0;e<r.length;e+=4){const t=r[e+2],n=r[e+0];r[e+2]=n,r[e+0]=t}return r};class Ce extends R.define({WIDTH:0,HEIGHT:1,DEPTH:2,BYTES:4,COLORMAP:5}){get decoded(){return this._decoded||(this._decoded=dr(new Uint8Array(new sr().decode(this.width.value,this.height.value,this.depth.value,this.bytes.value,this.colormap&&this.colormap.map(e=>e.valueOf())).buffer))),this._decoded}get extension(){return"uncompressed"}}class _t extends R.define({STAGE_CONTENTS:2,OBJ_NAME:6,VARS:7,BLOCKS_BIN:8,IS_CLONE:9,MEDIA:10,CURRENT_COSTUME:11,ZOOM:12,H_PAN:13,V_PAN:14,OBSOLETE_SAVED_STATE:15,SPRITE_ORDER_IN_LIBRARY:16,VOLUME:17,TEMPO_BPM:18,SCENE_STATES:19,LISTS:20}){get spriteOrderInLibrary(){return this.fields[this.FIELDS.SPRITE_ORDER_IN_LIBRARY]||null}get tempoBPM(){return this.fields[this.FIELDS.TEMPO_BPM]||0}get lists(){return this.fields[this.FIELDS.LISTS]||[]}}class Pe extends R.define({BOX:0,PARENT:1,COLOR:3,VISIBLE:4,OBJ_NAME:6,VARS:7,BLOCKS_BIN:8,IS_CLONE:9,MEDIA:10,CURRENT_COSTUME:11,VISIBILITY:12,SCALE_POINT:13,ROTATION_DEGREES:14,ROTATION_STYLE:15,VOLUME:16,TEMPO_BPM:17,DRAGGABLE:18,SCENE_STATES:19,LISTS:20}){get scratchX(){return this.box.x+this.currentCostume.rotationCenter.x-240}get scratchY(){return 180-(this.box.y+this.currentCostume.rotationCenter.y)}get visible(){return(this.fields[this.FIELDS.VISIBLE]&1)===0}get tempoBPM(){return this.fields[this.FIELDS.TEMPO_BPM]||0}get lists(){return this.fields[this.FIELDS.LISTS]||[]}}class Wr extends R.define({RECTANGLE:0,FONT:8,COLOR:9,LINES:11}){}class pe extends R.define({COSTUME_NAME:0,BITMAP:1,ROTATION_CENTER:2,TEXT_DETAILS:3,BASE_LAYER_DATA:4,OLD_COMPOSITE:5}){get image(){return this.oldComposite instanceof Ce?this.oldComposite:this.baseLayerData.value?null:this.bitmap}get width(){return this.image===null?-1:this.image.width}get height(){return this.image===null?-1:this.image.height}get rawBytes(){return this.image===null?this.baseLayerData.value.slice():this.image.bytes.value}get decoded(){return this.image===null?this.baseLayerData.value.slice():this.image.decoded}get crc(){if(!this._crc){const e=new Ve().update(new Uint8Array(new Uint32Array([this.bitmap.width]).buffer)).update(new Uint8Array(new Uint32Array([this.bitmap.height]).buffer)).update(new Uint8Array(new Uint32Array([this.bitmap.depth]).buffer)).update(this.rawBytes);this._crc=e.digest}return this._crc}get extension(){return this.oldComposite instanceof Ce?"uncompressed":this.baseLayerData.value?"jpg":"uncompressed"}toString(){return`ImageMediaData "${this.costumeName}"`}}class xr extends R.define({DATA:3,RATE:4}){}const Cr=r=>{const e=new Uint8Array(r);for(let t=0;t<e.length;t+=2)e[t]=r[t+1],e[t+1]=r[t];return e};class ye extends R.define({NAME:0,UNCOMPRESSED:1,RATE:4,BITS_PER_SAMPLE:5,DATA:6}){get rate(){return this.uncompressed.data.value.length!==0?this.uncompressed.rate:this.fields[this.FIELDS.RATE]}get rawBytes(){return this.data&&this.data.value?this.data.value:this.uncompressed.data.value}get decoded(){return this._decoded||(this.data&&this.data.value?this._decoded=new at(this.bitsPerSample.value).decode(this.data.value):this._decoded=new Int16Array(Cr(this.uncompressed.data.value.slice()).buffer)),this._decoded}get crc(){return this._crc||(this._crc=new Ve().update(new Uint32Array([this.rate])).update(this.rawBytes).digest),this._crc}get sampleCount(){return this.data&&this.data.value?at.samples(this.bitsPerSample.value,this.data.value):this.uncompressed.data.value.length/2}get extension(){return"pcm"}get wavEncodedData(){return this._wavEncodedData||(this._wavEncodedData=new Uint8Array(we.encode(this.decoded,{sampleRate:this.rate&&this.rate.value}))),this._wavEncodedData}get md5(){return this._md5||(this._md5=Rt.md5(this.wavEncodedData)),this._md5}toString(){return`SoundMediaData "${this.name}"`}}class pr extends R.define({BOX:0,HIDDEN_WHEN_NULL:1,LIST_NAME:8,CONTENTS:9,TARGET:10}){get x(){return Ne(this.hiddenWhenNull)===null?5:this.box.x+1}get y(){return Ne(this.hiddenWhenNull)===null?5:this.box.y+1}get width(){return this.box.width-2}get height(){return this.box.height-2}}class yr extends R.define({BOX:0,PARENT:1,FRAMES:2,COLOR:3,DIRECTION:8,ALIGNMENT:9}){}class gr extends R.define({BOX:0,PARENT:1,COLOR:3}){}class Er extends R.define({BOX:0,COLOR:3,VALUE:8}){}class wr extends R.define({BOX:0,READOUT_FRAME:1,COLOR:3,FONT:6,VALUE:8,TARGET:10,CMD:11,PARAM:13}){}class Sr extends R.define({BOX:0}){}const Ae={NORMAL:1,LARGE:2,SLIDER:3};class br extends R.define({BOX:0,TARGET:1,SHAPE:2,READOUT:14,READOUT_FRAME:15,SLIDER:16,ALIGNMENT:17,SLIDER_MIN:20,SLIDER_MAX:21}){get x(){return this.box.x}get y(){return this.box.y}get mode(){return Ne(this.slider)===null?this.readoutFrame.box.height<=14?Ae.NORMAL:Ae.LARGE:Ae.SLIDER}get isDiscrete(){return Math.floor(this.sliderMin)===this.sliderMin&&Math.floor(this.sliderMax)===this.sliderMax&&Math.floor(this.readout.value)===this.readout.value}}const mr={[p.POINT]:ur,[p.RECTANGLE]:fr,[p.FORM]:Ce,[p.SQUEAK]:Ce,[p.SAMPLED_SOUND]:xr,[p.SPRITE]:Pe,[p.STAGE]:_t,[p.IMAGE_MEDIA]:pe,[p.SOUND_MEDIA]:ye,[p.ALIGNMENT]:yr,[p.MORPH]:gr,[p.WATCHER_READOUT_FRAME]:Sr,[p.STATIC_STRING]:Er,[p.UPDATING_STRING]:wr,[p.WATCHER]:br,[p.LIST_WATCHER]:pr},lt=Array.from({length:256},(r,e)=>mr[e]||null);class Ft{constructor(e){this.valueIterator=e}[Symbol.iterator](){return this}next(){const e=this.valueIterator.next();if(e.done)return e;const t=e.value,{classId:n}=t;let o=t;if(t instanceof U){o=[];for(let h=0;h<t.size;h++)o.push(this.next().value)}if(lt[n]!==null||t instanceof It){const h=lt[t.classId]||R;o=new h({classId:t.classId,version:t.version,fields:o})}return{value:o,done:!1}}}class ut{constructor(e){this.table=Array.from(e),this.fixed=this.fix(this.table)}fix(){const e=[];for(let t=0;t<this.table.length;t++)this.fixItem(this.table[t]),e.push(this.table[t]);return e}fixItem(e){if(typeof e.fields<"u"&&(e=e.fields),Array.isArray(e))for(let t=0;t<e.length;t++)e[t]=this.deref(e[t])}deref(e){return e instanceof Je?this.table[e.index-1]:e}}class De extends m.extend({support8Bit:L,png:new z(3),dosLineEnding:new z(2),dosEndOfFile:new z(1),unixLineEnding:new z(1)}){static validate(){N(this.equals({support8Bit:137,png:"PNG",dosLineEnding:`\r
|
|
2
|
+
`,dosEndOfFile:"",unixLineEnding:`
|
|
3
|
+
`}),"PNGSignature does not match the expected values")}}m.initConstructor(De);class Ue extends m.extend({length:b,chunkType:new z(4)}){}m.initConstructor(Ue);class ze extends m.extend({checksum:b}){}m.initConstructor(ze);class He extends m.extend({width:b,height:b,bitDepth:L,colorType:L,compressionMethod:L,filterMethod:L,interlaceMethod:L}){}m.initConstructor(He);class ue extends m.extend({method:L}){}m.initConstructor(ue);class Ar{constructor(){this.adler=1}update(e,t,n){let o=this.adler&65535,h=this.adler>>>16;for(let F=0;F<n;F++)o=(o+e[t+F])%65521,h=(h+o)%65521;return this.adler=h<<16|o,this}get digest(){return this.adler}}const Oe=65535;class je extends m.extend({cmf:L,flag:L}){}m.initConstructor(je);class fe extends m.extend({lastPacket:L,length:X,lengthCheck:X}){}m.initConstructor(fe);class Ge extends m.extend({checksum:se}){}m.initConstructor(Ge);class Bt{constructor(e){this.stream=e}get uint8a(){return this.stream.uint8a}set uint8a(e){this.stream.uint8a=e}get position(){return this.stream.position}set position(e){this.stream.position=e}writeStruct(e,t){return this.stream.writeStruct(e,t)}writeBytes(e,t=0,n=e.length){return this.stream.writeBytes(e,t,n)}}class ft extends Bt{constructor(e){super(e),this.stream.writeStruct(je,{cmf:8,flag:29}),this.adler=new Ar,this.chunk=this.stream.writeStruct(fe,{lastPacket:0,length:0,lengthCheck:65535})}get _deflateIndex(){return this.chunk.length}set _deflateIndex(e){this.chunk.length=e,this.chunk.lengthCheck=e^65535}writeStruct(e,t){this.writeBytes(Object.assign(new e,t).uint8a)}writeBytes(e,t=0,n=e.length){let o=t;for(;n-o>0;){this._deflateIndex===Oe&&(this.chunk=this.stream.writeStruct(fe,{lastPacket:0,length:0,lengthCheck:65535}));const h=Math.min(n-o,Oe-this._deflateIndex);this.stream.writeBytes(e,o,o+h),this._deflateIndex+=h,o+=h}this.adler.update(e,t,n-t)}finish(){this.chunk.lastPacket=1,this.stream.writeStruct(Ge,{checksum:this.adler.digest})}static estimateSize(e){const t=Math.ceil(e/Oe);return je.size+t*fe.size+Ge.size+e}}class W extends Bt{constructor(e,t="IHDR"){super(e),this.start=this.stream.writeStruct(Ue,{length:0,chunkType:t}),this.crc=new Ve}finish(){const e=this.start.offset+this.start.size,t=this.position-e;this.start.length=t,this.crc.update(this.stream.uint8a,e-b.size,t+b.size),this.stream.writeStruct(ze,{checksum:this.crc.digest})}static size(e){return Ue.size+e+ze.size}}class Se{encode(e,t,n){const o=e*4+ue.size,h=o*t,F=De.size+W.size(He.size)+W.size(ft.estimateSize(h))+W.size(0),d=new Z(new ArrayBuffer(F));d.writeStruct(De,{support8Bit:137,png:"PNG",dosLineEnding:`\r
|
|
4
|
+
`,dosEndOfFile:"",unixLineEnding:`
|
|
5
|
+
`});const w=new W(d,"IHDR");w.writeStruct(He,{width:e,height:t,bitDepth:8,colorType:6,compressionMethod:0,filterMethod:0,interlaceMethod:0}),w.finish();const x=new W(d,"IDAT"),y=new ft(x);let g=0;for(;g<n.length;){y.writeStruct(ue,{method:0});const M=Math.min(n.length-g,o-ue.size);y.writeBytes(n,g,g+M),g+=M}return y.finish(),x.finish(),new W(d,"IEND").finish(),d.buffer}static encode(e,t,n){return new Se().encode(e,t,n)}}class Or{constructor(e){this.file=e}async(e){return N(e==="uint8array","SB1FakeZipFile only supports uint8array"),Promise.resolve(this.file.bytes)}}class Tr{constructor(e){this.files=e}file(e){if(e in this.files)return new Or(this.files[e])}}const Ir=r=>r.extension==="uncompressed"?"png":"jpg",vr=r=>r.extension==="uncompressed"?new Uint8Array(Se.encode(r.width,r.height,r.decoded)):r.decoded,Rr=r=>r.wavEncodedData,_r=({images:r,sounds:e})=>{const t={};let n=0;for(const o of r)t[`${n++}.${Ir(o)}`]={bytes:vr(o)};n=0;for(const o of e)t[`${n++}.wav`]={bytes:Rr(o)};return new Tr(t)},te=r=>{const e=String(r[r.length-1]),t=r.length-1;return e==="mouse"?r[t]="_mouse_":e==="edge"?r[t]="_edge_":r[r.length-1]instanceof _t&&(r[t]="_stage_"),r},Br={getParam:([r,e,t,n])=>[r,e,t,n||"r"],changeVariable:r=>[r[2],r[1],r[3]],EventHatMorph:r=>String(r[1])==="Scratch-StartClicked"?["whenGreenFlag"]:["whenIReceive",r[1]],MouseClickEventHatMorph:()=>["whenClicked"],KeyEventHatMorph:r=>["whenKeyPressed",r[1]],stopScripts:r=>String(r[1])==="other scripts"?[r[0],"other scripts in sprite"]:r,abs:r=>["computeFunction:of:","abs",r[1]],sqrt:r=>["computeFunction:of:","sqrt",r[1]],"\\\\":r=>["%",...r.slice(1)],doReturn:()=>["stopScripts","this script"],stopAll:()=>["stopScripts","all"],"showBackground:":r=>["startScene",r[1]],nextBackground:()=>["nextScene"],doForeverIf:r=>["doForever",[["doIf",r[1],r[2]]]],"getAttribute:of:":te,"gotoSpriteOrMouse:":te,"distanceTo:":te,"pointTowards:":te,"touching:":te},Lr=r=>typeof r=="object"&&r?r.valueOf():r,Nr=r=>{const{info:e,stageData:t,images:n,sounds:o}=r,h=f=>{const O=[];for(let T=0;T<f.length;T+=2)O.push([f[T],f[T+1]]);return O},F=([f,O])=>({name:f,value:O,isPersistent:!1}),d=([,{listName:f,contents:O,x:T,y:P,width:oe,height:be,hiddenWhenNull:v}])=>({listName:f,contents:O,isPersistent:!1,x:T,y:P,width:oe,height:be,visible:Lr(v)!==null}),w=f=>{const O=o.findIndex(T=>T.crc===f.crc);return{soundName:f.name,soundID:O,md5:`${f.md5}.wav`,sampleCount:f.sampleCount,rate:f.rate,format:""}},x=f=>f.extension==="uncompressed"?"png":"jpg",y=f=>{const O=n.findIndex(T=>T.crc===f.crc);return{costumeName:f.costumeName,baseLayerID:O,baseLayerMD5:`${Rt.md5(f.rawBytes)}.${x(f)}`,bitmapResolution:1,rotationCenterX:f.rotationCenter.x,rotationCenterY:f.rotationCenter.y}},g=f=>{let O=f.map(M);const T=Br[O[0]];return T&&(O=T(O)),O},I=f=>f.map(g),M=f=>f instanceof Pe?f.objName:Array.isArray(f)?f.length===0||Array.isArray(f[0])?I(f):g(f):f,A=f=>[f[0].x,f[0].y,I(f[1])],ne=f=>{const O=f.media.filter(P=>P instanceof pe),T=f.media.filter(P=>P instanceof ye);return{objName:f.objName,variables:h(f.vars).map(F),lists:h(f.lists).map(d),scripts:f.blocksBin.map(A),costumes:O.map(y),currentCostumeIndex:O.findIndex(P=>P.crc===f.currentCostume.crc),sounds:T.map(w),scratchX:f.scratchX,scratchY:f.scratchY,scale:f.scalePoint.x,direction:Math.round(f.rotationDegrees*1e6)/1e6-270,rotationStyle:f.rotationStyle,isDraggable:f.draggable,indexInLibrary:t.spriteOrderInLibrary.indexOf(f),visible:f.visible,spriteInfo:{}}},ie=f=>f instanceof Pe?ne(f):null,$=f=>{const O=f.media.filter(P=>P instanceof pe),T=f.media.filter(P=>P instanceof ye);return{objName:f.objName,variables:h(f.vars).map(F),lists:h(f.lists).map(d),scripts:f.blocksBin.map(A),costumes:O.map(y),currentCostumeIndex:O.findIndex(P=>P.crc===f.currentCostume.crc),sounds:T.map(w),penLayerMD5:"5c81a336fab8be57adc039a8a2b33ca9.png",penLayerID:0,tempoBPM:f.tempoBPM,videoAlpha:.5,children:f.stageContents.map(ie).filter(Boolean).reverse()}},Y=f=>{const O={};for(let T=0;T<f.length;T+=2)String(f[T])!=="thumbnail"&&(O[String(f[T])]=String(f[T+1]));return O};return JSON.parse(JSON.stringify(Object.assign($(t),{info:Y(e)})))};class ke extends m.extend({version:new z(10),infoByteLength:b}){validate(){N.validate(this.equals({version:"ScratchV01"})||this.equals({version:"ScratchV02"}),"Invalid Scratch file signature.")}}m.initConstructor(ke);class q extends m.extend({ObjS:new z(4),ObjSValue:L,Stch:new z(4),StchValue:L,numObjects:b}){validate(){N.validate(this.equals({ObjS:"ObjS",ObjSValue:1,Stch:"Stch",StchValue:1}),"Invalid Scratch file info packet header.")}}m.initConstructor(q);class Mr{constructor(e){this.buffer=e,this.stream=new Z(e),this.signature=this.stream.readStruct(ke),this.signature.validate(),this.infoHeader=this.stream.readStruct(q),this.infoHeader.validate(),this.stream.position+=this.signature.infoByteLength-q.size,this.dataHeader=this.stream.readStruct(q),this.dataHeader.validate()}get json(){return Nr({info:this.info(),stageData:this.data(),images:this.images(),sounds:this.sounds()})}get zip(){return _r({images:this.images(),sounds:this.sounds()})}view(){return{signature:this.signature,infoHeader:this.infoHeader,dataHeader:this.dataHeader,toString(){return"SB1File"}}}infoRaw(){return new Xe(new it(this.buffer,this.infoHeader.offset+q.size),this.signature.infoByteLength+ke.size)}infoTable(){return new Ft(this.infoRaw())}info(){return this._info||(this._info=new ut(this.infoTable()).table[0]),this._info}dataRaw(){return new Xe(new it(this.buffer,this.dataHeader.offset+q.size),this.stream.uint8a.length)}dataTable(){return new Ft(this.dataRaw())}dataFixed(){return this._data||(this._data=new ut(this.dataTable()).table),this._data}data(){return this.dataFixed()[0]}images(){const e=new Set;return this.dataFixed().filter(t=>t instanceof pe?e.has(t.crc)?!1:(e.add(t.crc),!0):!1)}sounds(){const e=new Set;return this.dataFixed().filter(t=>t instanceof ye?e.has(t.crc)?!1:(e.add(t.crc),!0):!1)}}var Te,dt;function Pr(){if(dt)return Te;dt=1;const r=(e="")=>{const t=o=>r(e?`${e} ${o}`:o),n=e?[e]:[];return t.debug=t.log=console.debug.bind(console,...n,"debug"),t.info=console.log.bind(console,...n,"info"),t.warn=t.warning=console.warn.bind(console,...n,"warn"),t.error=console.error.bind(console,...n,"error"),t};return r.enable=r.disable=()=>{},Te=r,Te}var Dr=Pr();const Ur=ar(Dr),Lt=new Ur("sb1-converter"),xt={},Ct=[];class zr{static check(){return!0}render(e,t){e instanceof HTMLElement?t.content.appendChild(e):t.renderTitle(`Unknown Structure(${e?e.classId||e.constructor.name:""})`)}}class _{constructor(e,t="",n=t){this._elements={},this.element=document.createElement("div"),this.element.style.position="relative",this.element.style.top="0",this.element.style.left="0",this.content=this.element,this.data=e,this.prefix=t,this.path=n,this.expanded=!!xt[this.path],this.canExpand=!1,this.toggle=this.toggle.bind(this),this.element.addEventListener("click",this.toggle),this.renderer=_.createRenderer(this.data,this),this.render()}toggle(e){if(this.canExpand&&!(e.target!==this._elements.arrow&&e.target!==this._elements.title))return xt[this.path]=this.expanded=!this.expanded,this.render(),e.preventDefault(),e.stopPropagation(),!1}createElement(e,t){return this._elements[t]||(this._elements[t]=document.createElement(e)),this._elements[t].innerHTML="",this._elements[t]}child(e,t,n){return new _(e,t,`${this.path}${n}`)}renderClear(){for(this.canExpand=!1;this.element.children.length;)this.element.removeChild(this.element.children[0]);this.content=this.element}renderArrow(){this.canExpand=!0;const e=this.createElement("div","arrow");e.innerHTML="▶",e.style.position="absolute",e.style.left="0",e.style.width="1em",e.style.transform=this.expanded?"rotateZ(90deg)":"",e.style.transition="transform 3s",this.element.appendChild(e);const t=this.createElement("div","arrowContent");t.style.position="relative",t.style.left="1em",t.style.right="0",this.element.appendChild(t),this.content=t}renderTitle(e){const t=this.createElement("div","title"),n=(this.prefix?`${this.prefix}: `:"")+e;if([`
|
|
6
|
+
`,"\r","<br>"].some(o=>n.indexOf(o)!==-1)||n.length>80)if(this.renderArrow(),this.expanded)t.innerText=n;else{const o=Math.min(n.lastIndexOf(" ",80),[`
|
|
7
|
+
`,"\r","<br>"].reduce((h,F)=>n.indexOf(F)!==-1?Math.min(h,n.indexOf(F)):h,1/0));t.innerText=`${n.substring(0,o)} ...`}else t.innerText=n;return this.content.appendChild(t),t}expand(e,t){this.expanded?t():e()}renderExpand(e){if(this.expanded)try{const t=this.createElement("div","expanded");e.call(this,t).forEach(n=>this.content.appendChild(n.element))}catch(t){Lt.error(t);const n=this.createElement("div","expanded-error");n.innerText="Error rendering expanded area ...",this.content.appendChild(n)}}render(){this.renderClear(),this.renderer.render(this.data,this)}static register(e){Ct.push([e.check,e])}static findRenderer(e,t){return Ct.reduce((n,[o,h])=>o(e,t)?h:n,zr)}static createRenderer(e,t){const n=_.findRenderer(e,t);return new n(t)}}class K{constructor(e,t,n){this.array=e instanceof K?e.array:e,this.start=t,this.end=n}get length(){return this.end-this.start}get name(){throw new Error("Not implemented")}map(e){const t=[];for(let n=this.start;n<this.end;n++)t.push(e(this.array[n],n,this));return t}}class pt extends K{constructor(e){super(e,e.start||0,e.end||e.length)}get name(){return"all"}}class $e extends K{get name(){return`${this.start+1} - ${this.end}`}static views(e){if(e instanceof pt)return e;if(e.length>100){const n=Math.pow(10,Math.ceil(Math.log(e.length)/Math.log(10)))/10,o=[];for(let h=e.start||0;h<(e.end||e.length);h+=n)o.push(new $e(e,h,Math.min(h+n,e.end||e.length))),N(o.length<=10,"Too many subviews");return o.push(new pt(e)),o}return e}}class Hr{static check(e){return Array.isArray(e)||e instanceof K}render(e,t){e.length&&t.renderArrow(),t.renderTitle(`Array (${e.length})`),e.length&&t.renderExpand(()=>$e.views(e).map((n,o)=>t.child(n,n instanceof K?n.name:o+1,`[${o}]`)))}}class Ye{static check(e){return e&&e.constructor===Object}render(e,t){t.renderArrow(),t.renderTitle(String(e)==="[object Object]"?"Object":String(e)),t.renderExpand(()=>{const n=typeof e=="function"?e():e;return Object.keys(n).map(o=>{try{return typeof n[o]=="function"?null:t.child(n[o],o,`.${o}`)}catch(h){return Lt.error(h),t.child("An error occured rendering view data.",o,`.${o}`)}}).filter(Boolean)})}}const Nt=r=>r===null?{}:Object.assign(Nt(Object.getPrototypeOf(r)),Object.getOwnPropertyDescriptors(r));class jr{static check(e){return e instanceof R}addOptionalPreview(e){if(e.decoded){let t,n,o;e.extension==="uncompressed"?(t="image/png",n=new Image,o=new Uint8Array(Se.encode(e.width,e.height,e.decoded))):e.extension==="jpg"?(t="image/jpg",n=new Image,o=e.decoded):e.extension==="pcm"&&(t="audio/wav",n=new Audio,n.controls=!0,o=new Uint8Array(we.encode(e.decoded,{sampleRate:e.rate&&e.rate.value}))),n.src=URL.createObjectURL(new Blob([o.buffer],{type:t})),e.preview=n}return e}render(e,t){new Ye().render(Object.assign(()=>this.addOptionalPreview(Object.entries(Nt(Object.getPrototypeOf(e))).filter(([,n])=>n.get).reduce((n,[o])=>(Object.defineProperty(n,o,{enumerable:!0,get(){return e[o]}}),n),{})),{toString(){return e.toString()}}),t)}}class Gr{static check(e){return e instanceof Ee}render(e,t){e instanceof Je?t.renderTitle(`Reference { index: ${e.index} }`):e instanceof U?t.renderTitle(`Header { classId: ${e.classId} (${Tt[e.classId]}), size: ${e.size} }`):e instanceof Me&&(e.classId===p.COLOR||e.classId===p.TRANSLUCENT_COLOR)?t.renderTitle((+e).toString(16).padStart(8,"0")).style.fontFamily="monospace":e instanceof Me&&(e.value&&e.value.buffer?t.renderTitle(`${e.value.constructor.name} (${e.value.length})`):t.renderTitle(String(e)))}}const kr=["undefined","string","number","boolean"];class Jr{static check(e){return kr.includes(typeof e)||e===null}render(e,t){t.renderTitle(String(e))}}class Vr{static check(e){return e&&typeof e.view=="function"}render(e,t){new Ye().render(Object.assign(()=>e.view(),{toString(){return e.constructor.name}}),t)}}_.register(Hr);_.register(jr);_.register(Gr);_.register(Jr);_.register(Ye);_.register(Vr);const $r=(r,e,t)=>{const n=document.createElement("a");return n.download=r,n.href=URL.createObjectURL(new Blob([t],{type:e})),n.innerText=r,n};let he=null;const Yr=r=>{const e=new FileReader;e.onload=function(t){he&&he.forEach(document.body.removeChild,document.body);const n=new Mr(t.target.result);he=[new _(n,"file").element,new _(Array.from(n.infoRaw()),"raw - info").element,new _(Array.from(n.dataRaw()),"raw - data").element,new _(Array.from(n.infoTable()),"table - info").element,new _(Array.from(n.dataTable()),"table - data").element,new _(n.info(),"info").element,new _(n.data(),"data").element,new _(n.images(),"images").element,new _(n.sounds(),"sounds").element,new _(n.json,"json").element,$r(`${r.name}.json`,"application/json",JSON.stringify(n.json))],he.forEach(document.body.appendChild,document.body)},e.readAsArrayBuffer(r)};Array.from(document.getElementsByClassName("file")).forEach(r=>{r.addEventListener("change",()=>{Array.from(r.files).forEach(Yr)})});document.body.addEventListener("drop",r=>{r.preventDefault(),r.dataTransfer.dropEffect="copy",document.getElementsByClassName("file")[0].files=r.dataTransfer.files});document.body.addEventListener("dragover",r=>{r.preventDefault(),r.dataTransfer.dropEffect="copy"});
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
<!DOCTYPE html>
|
|
2
|
+
<html lang="en">
|
|
3
|
+
<head>
|
|
4
|
+
<meta charset="UTF-8">
|
|
5
|
+
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
6
|
+
<title>Scratch SB1 Converter Playground</title>
|
|
7
|
+
<script type="module" crossorigin src="./assets/index-Bvv1xdjK.js"></script>
|
|
8
|
+
</head>
|
|
9
|
+
<body>
|
|
10
|
+
<input type="file" class="file" />
|
|
11
|
+
</body>
|
|
12
|
+
</html>
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
(function(G,k){typeof exports=="object"&&typeof module<"u"?k(exports):typeof define=="function"&&define.amd?define(["exports"],k):(G=typeof globalThis<"u"?globalThis:G||self,k(G.sb1Converter={}))})(this,(function(G){"use strict";class k extends Error{}class jt extends k{}const N=function(r,t){if(!r)throw new k(t)};N.validate=function(r,t){if(!r)throw new jt(t)};class W{constructor(t,e=0){this.buffer=t,this.position=e,this.uint8a=new Uint8Array(this.buffer)}read(t){const e=t.read(this.uint8a,this.position);return t.size===0?this.position+=t.sizeOf(this.uint8a,this.position):this.position+=t.size,e}readStruct(t){const e=new t(this.uint8a,this.position);return this.position+=t.size,e}resize(t){if(this.buffer.byteLength<t){const e=this.uint8a,o=Math.pow(2,Math.ceil(Math.log(t)/Math.log(2)));this.buffer=new ArrayBuffer(o),this.uint8a=new Uint8Array(this.buffer),this.uint8a.set(e)}}write(t,e){return t.size===0?this.resize(this.position+t.writeSizeOf(e)):this.resize(this.position+t.size),t.write(this.uint8a,this.position,e),t.size===0?this.position+=t.writeSizeOf(this.uint8a,this.position):this.position+=t.size,e}writeStruct(t,e){this.resize(this.position+t.size);const o=Object.assign(new t(this.uint8a,this.position),e);return this.position+=t.size,o}writeBytes(t,e=0,o=t.length){N(t instanceof Uint8Array,"writeBytes must be passed an Uint8Array"),this.resize(this.position+(o-e));for(let F=e;F<o;F++)this.uint8a[this.position+F-e]=t[F];return this.position+=o-e,t}}class kt{constructor(t,e=1/0){this.iter=t,this.maxPosition=e}[Symbol.iterator](){return this}next(){return this.iter.stream.position>=this.maxPosition?{value:null,done:!0}:this.iter.next()}}const Vt=()=>{throw new Error("Not implemented")},X=(()=>{const r=new Uint16Array(1),t=new Uint8Array(r.buffer);return r[0]=43707,t[0]===187})();class B{constructor({size:t=0,sizeOf:e=()=>t,writeSizeOf:o=Vt,toBytes:F=new Uint8Array(1),read:c,write:l=Vt}){this.size=t,this.sizeOf=e,this.writeSizeOf=o,this.toBytes=F,this.bytes=new Uint8Array(F.buffer),this.read=c,this.write=l}asPropertyObject(t){const e=this;return{get(){return e.read(this.uint8a,t+this.offset)},set(o){return e.write(this.uint8a,t+this.offset,o)},enumerable:!0}}read(){return null}}const R=new B({size:1,read(r,t){return r[t]},write(r,t,e){return r[t]=e,e}}),Jt={size:2,read(r,t){return this.bytes[1]=r[t+0],this.bytes[0]=r[t+1],this.toBytes[0]},write(r,t,e){return this.toBytes[0]=e,r[t+0]=this.bytes[1],r[t+1]=this.bytes[0],e}},Yt={size:2,read(r,t){return this.bytes[0]=r[t+0],this.bytes[1]=r[t+1],this.toBytes[0]},write(r,t,e){return this.toBytes[0]=e,r[t+0]=this.bytes[0],r[t+1]=this.bytes[1],e}};let it;X?it=Jt:it=Yt,new B(Object.assign({},it,{toBytes:new Uint16Array(1)}));const nt=new B(Object.assign({},it,{toBytes:new Int16Array(1)})),Wt={size:4,read(r,t){return this.bytes[3]=r[t+0],this.bytes[2]=r[t+1],this.bytes[1]=r[t+2],this.bytes[0]=r[t+3],this.toBytes[0]},write(r,t,e){return this.toBytes[0]=e,r[t+0]=this.bytes[3],r[t+1]=this.bytes[2],r[t+2]=this.bytes[1],r[t+3]=this.bytes[0],e}},Xt={size:4,read(r,t){return this.bytes[0]=r[t+0],this.bytes[1]=r[t+1],this.bytes[2]=r[t+2],this.bytes[3]=r[t+3],this.toBytes[0]},write(r,t,e){return this.toBytes[0]=e,r[t+0]=this.bytes[0],r[t+1]=this.bytes[1],r[t+2]=this.bytes[2],r[t+3]=this.bytes[3],e}};let at;X?at=Wt:at=Xt;const V=new B(Object.assign({},at,{toBytes:new Int32Array(1)})),b=new B(Object.assign({},at,{toBytes:new Uint32Array(1)}));let St;X?St=Yt:St=Jt;const q=new B(Object.assign({},St,{toBytes:new Uint16Array(1)}));let pt;X?pt=Xt:pt=Wt;const tt=new B(Object.assign({},pt,{toBytes:new Uint32Array(1)})),be={size:8,read(r,t){return this.bytes[7]=r[t+0],this.bytes[6]=r[t+1],this.bytes[5]=r[t+2],this.bytes[4]=r[t+3],this.bytes[3]=r[t+4],this.bytes[2]=r[t+5],this.bytes[1]=r[t+6],this.bytes[0]=r[t+7],this.toBytes[0]}},ge={size:8,read(r,t){return this.bytes[7]=r[t+0],this.bytes[6]=r[t+1],this.bytes[5]=r[t+2],this.bytes[4]=r[t+3],this.bytes[3]=r[t+4],this.bytes[2]=r[t+5],this.bytes[1]=r[t+6],this.bytes[0]=r[t+7],this.toBytes[0]}};let wt;X?wt=be:wt=ge;const Oe=new B(Object.assign({},wt,{toBytes:new Float64Array(1)}));class U extends B{constructor(t){super({size:t,read(e,o){let F="";for(let c=0;c<t;c++){const l=e[o+c];N(l<=127,"Non-ascii character in FixedAsciiString"),F+=String.fromCharCode(l)}return F},write(e,o,F){for(let c=0;c<t;c++){const l=F.charCodeAt(c);N(l<=127,"Non-ascii character in FixedAsciiString"),e[o+c]=l}return F}})}}var J=typeof global>"u"?typeof self>"u"?{}:self:global,qt=String.fromCharCode,ot={}.toString,$t=J.SharedArrayBuffer,Te=$t?ot.call($t):"",Y=J.Uint8Array,Ie=Y?ot.call(ArrayBuffer.prototype):"",j=J.Buffer;try{!j&&J.require&&(j=J.require("Buffer"));var Kt=j.prototype,_e=ot.call(Kt)}catch{}var Ft=j.allocUnsafe,Zt=!!Y&&!j,A=new Uint16Array(32),ve=!j||!!Y&&Y.prototype.isPrototypeOf(Kt);function Qt(){}function te(r){var t=r&&r.buffer||r,e=ot.call(t);if(e!==Ie&&e!==_e&&e!==Te&&e!=="[object ArrayBuffer]"&&r!==void 0)throw TypeError("Failed to execute 'decode' on 'TextDecoder': The provided value is not of type '(ArrayBuffer or ArrayBufferView)'");r=ve?new Y(t):t||[],e=t="";for(var o=0,F=r.length|0,c=F-32|0,l,d,w=0,x=0,y,E=0,_=-1;o<F;){for(l=o<=c?32:F-o|0;E<l;o=o+1|0,E=E+1|0){switch(d=r[o]&255,d>>4){case 15:if(y=r[o=o+1|0]&255,y>>6!==2||247<d){o=o-1|0;break}w=(d&7)<<6|y&63,x=5,d=256;case 14:y=r[o=o+1|0]&255,w<<=6,w|=(d&15)<<6|y&63,x=y>>6===2?x+4|0:24,d=d+256&768;case 13:case 12:y=r[o=o+1|0]&255,w<<=6,w|=(d&31)<<6|y&63,x=x+7|0,o<F&&y>>6===2&&w>>x&&1114112>w?(d=w,w=w-65536|0,0<=w&&(_=(w>>10)+55296|0,d=(w&1023)+56320|0,31>E?(A[E]=_,E=E+1|0,_=-1):(y=_,_=d,d=y))):(d>>=8,o=o-d-1|0,d=65533),w=x=0,l=o<=c?32:F-o|0;default:A[E]=d;continue;case 11:case 10:case 9:case 8:}A[E]=65533}if(e+=qt(A[0],A[1],A[2],A[3],A[4],A[5],A[6],A[7],A[8],A[9],A[10],A[11],A[12],A[13],A[14],A[15],A[16],A[17],A[18],A[19],A[20],A[21],A[22],A[23],A[24],A[25],A[26],A[27],A[28],A[29],A[30],A[31]),32>E&&(e=e.slice(0,E-32|0)),o<F){if(A[0]=_,E=~_>>>31,_=-1,e.length<t.length)continue}else _!==-1&&(e+=qt(_));t+=e,e=""}return t}Qt.prototype.decode=te;function Be(r){r=r===void 0?"":""+r;var t=r.length|0,e=Zt?new Y((t<<1)+8|0):Ft?Ft((t<<1)+8|0):new j((t<<1)+8|0),o,F=0,c=!1;for(o=0;o<t;o=o+1|0,F=F+1|0){var l=r.charCodeAt(o)|0;if(127>=l)e[F]=l;else{if(2047>=l)e[F]=192|l>>6;else{t:{if(55296<=l)if(56320>l){var d=r.charCodeAt(o=o+1|0)|0;if(56320<=d&&57343>=d){if(l=(l<<10)+d-56613888|0,65535<l){e[F]=240|l>>18,e[F=F+1|0]=128|l>>12&63,e[F=F+1|0]=128|l>>6&63,e[F=F+1|0]=128|l&63;continue}break t}l=65533}else 57343>=l&&(l=65533);!c&&o<<1<F&&o<<1<(F-7|0)&&(c=!0,d=Zt?new Y(3*t):Ft?Ft(3*t):new j(3*t),d.set(e),e=d)}e[F]=224|l>>12,e[F=F+1|0]=128|l>>6&63}e[F=F+1|0]=128|l&63}}return e.subarray(0,F)}function ee(r,t){var e=r[t];return function(){return e.apply(r,arguments)}}var At=J.TextDecoder,re=J.TextEncoder,me=At||Qt;At&&ee(new At,"decode"),re&&ee(new re,"encode");const z=10*1024*1024;let bt;X?bt=new B({size:3,read(r,t){return r[t+0]<<16|r[t+1]<<8|r[t+2]}}):bt=new B({size:3,read(r,t){return r[t+2]<<16|r[t+1]<<8|r[t+0]}});const se=new B({sizeOf(r,t){const e=nt.read(r,t);return nt.size+e},read(r,t){let e=0,o=0;const F=nt.read(r,t);for(let c=0;c<F;c++)e=e+o*R.read(r,t++),o*=256;return e}}),ie=new B({sizeOf(r,t){const e=b.read(r,t);return b.size+e},read(r,t){const e=b.read(r,t);N(e<z,"asciiString too big"),t+=4;let o="";for(let F=0;F<e;F++)o+=String.fromCharCode(r[t++]);return o}}),Re=new B({sizeOf(r,t){return b.size+b.read(r,t)},read(r,t){const e=b.read(r,t);return N(e<z,"bytes too big"),t+=b.size,N(e<z,"uint8a array too big"),new Uint8Array(r.buffer,t,e)}}),Ne=new B({sizeOf(r,t){return b.size+b.read(r,t)*2},read(r,t){const e=b.read(r,t);N(e<z,"sound too big"),t+=b.size;const o=e*2;return N(o<z,"uint8a array too big"),new Uint8Array(r.buffer,t,o)}}),Le=new B({sizeOf(r,t){return b.size+b.read(r,t)*b.size},read(r,t){const e=b.read(r,t);N(e<z,"bitmap too big"),t+=b.size,N(e<z,"uint8a array too big");const o=new Uint32Array(e);for(let F=0;F<e;F++)o[F]=b.read(r,t),t+=b.size;return o}});let gt;typeof TextDecoder>"u"?gt=new me:gt=new TextDecoder;const Me=new B({sizeOf(r,t){return b.size+b.read(r,t)},read(r,t){const e=b.read(r,t);return N(e<z,"utf8 too big"),t+=b.size,N(e<z,"uint8a array too big"),gt.decode(new Uint8Array(r.buffer,t,e))}}),Pe=new B({size:4,read(r,t){const e=b.read(r,t),o=255,F=e>>22&255,c=e>>12&255,l=e>>2&255;return(o<<24|F<<16|c<<8|l)>>>0}}),De=new B({size:5,read(r,t){const e=b.read(r,t),o=R.read(r,t),F=e>>22&255,c=e>>12&255,l=e>>2&255;return(o<<24|F<<16|c<<8|l)>>>0}}),S={NULL:1,TRUE:2,FALSE:3,SMALL_INT:4,SMALL_INT_16:5,LARGE_INT_POSITIVE:6,LARGE_INT_NEGATIVE:7,FLOATING:8,STRING:9,SYMBOL:10,BYTES:11,SOUND:12,BITMAP:13,UTF8:14,ARRAY:20,ORDERED_COLLECTION:21,SET:22,IDENTITY_SET:23,DICTIONARY:24,IDENTITY_DICTIONARY:25,COLOR:30,TRANSLUCENT_COLOR:31,POINT:32,RECTANGLE:33,FORM:34,SQUEAK:35,OBJECT_REF:99,MORPH:100,ALIGNMENT:104,STATIC_STRING:105,UPDATING_STRING:106,SAMPLED_SOUND:109,IMAGE_MORPH:110,SPRITE:124,STAGE:125,WATCHER:155,IMAGE_MEDIA:162,SOUND_MEDIA:164,MULTILINE_STRING:171,WATCHER_READOUT_FRAME:173,WATCHER_SLIDER:174,LIST_WATCHER:175},Ue=Object.entries(S).reduce((r,[t,e])=>(r[e]=t,r),{});class Ot{constructor(t,e){this.classId=t,this.position=e}}const Tt=r=>typeof r=="object"&&r?r.valueOf():r;class ze extends Ot{constructor(t,e,o){super(t,e),this.value=o}valueOf(){return this.value}toJSON(){return this.classId===S.TRANSLUCENT_COLOR||this.classId===S.COLOR?this.value&16777215:this.value}toString(){return this.value}}class D extends Ot{constructor(t,e,o){super(t,e),this.size=o}}class ne extends Ot{constructor(t,e,o){super(t,e),this.index=o}valueOf(){return`Ref(${this.index})`}}class He extends D{constructor(t,e){super(t,e,0)}}class ae extends D{constructor(t,e,o,F){super(t,e,F),this.version=o}}class oe{constructor({type:t=ze,read:e,value:o=e?(F=>F.read(e)):null}){this.type=t,this.value=o}next(t,e,o){return{value:new this.type(e,o,this.value(t)),done:!1}}}const Fe={[S.NULL]:{value:()=>null},[S.TRUE]:{value:()=>!0},[S.FALSE]:{value:()=>!1},[S.SMALL_INT]:{read:V},[S.SMALL_INT_16]:{read:nt},[S.LARGE_INT_POSITIVE]:{read:se},[S.LARGE_INT_NEGATIVE]:{read:se},[S.FLOATING]:{read:Oe},[S.STRING]:{read:ie},[S.SYMBOL]:{read:ie},[S.BYTES]:{read:Re},[S.SOUND]:{read:Ne},[S.BITMAP]:{read:Le},[S.UTF8]:{read:Me},[S.ARRAY]:{type:D,read:V},[S.ORDERED_COLLECTION]:{type:D,read:V},[S.SET]:{type:D,read:V},[S.IDENTITY_SET]:{type:D,read:V},[S.DICTIONARY]:{type:D,value:r=>r.read(V)*2},[S.IDENTITY_DICTIONARY]:{type:D,value:r=>r.read(V)*2},[S.COLOR]:{read:Pe},[S.TRANSLUCENT_COLOR]:{read:De},[S.POINT]:{type:D,value:()=>2},[S.RECTANGLE]:{type:D,value:()=>4},[S.FORM]:{type:D,value:()=>5},[S.SQUEAK]:{type:D,value:()=>6},[S.OBJECT_REF]:{type:ne,read:bt}},Ge=Array.from({length:256},(r,t)=>Fe[t]?new oe(Fe[t]):null),je=new oe({type:He,value:()=>null});class he{constructor(t,e){this.buffer=t,this.stream=new W(t,e)}[Symbol.iterator](){return this}next(){if(this.stream.position>=this.stream.uint8a.length)return{value:null,done:!0};const t=this.stream.position,e=this.stream.read(R),o=Ge[e];if(o!==null)return o.next(this.stream,e,t);if(e<S.OBJECT_REF)return je.next(this.stream,e,t);const F=this.stream.read(R),c=this.stream.read(R);return{value:new ae(e,t,F,c),done:!1}}}const ke=r=>r.toLowerCase().replace(/_(\w)/g,([,t])=>t.toUpperCase());class m{constructor({classId:t,version:e,fields:o}){this.classId=t,this.version=e,this.fields=o}get FIELDS(){return[]}get RAW_FIELDS(){return this.fields}string(t){return String(this.fields[t])}number(t){return+this.fields[t]}boolean(t){return!!this.fields[t]}toString(){return this.constructor===m?`${this.constructor.name} ${this.classId} ${Ue[this.classId]}`:this.constructor.name}static define(t,e=m){class o extends e{get FIELDS(){return t}static get FIELDS(){return t}}return Object.keys(t).forEach(F=>{const c=t[F];Object.defineProperty(o.prototype,ke(F),{get(){return this.fields[c]}})}),o}}class It{constructor(){this.bit=new Uint32Array(1),this.crc=0,this.c=0,this.table=[];let t;for(let e=0;e<256;e++){t=e;for(let o=0;o<8;o++)t=t&1?3988292384^t>>>1:t>>>1;this.table[e]=t>>>0}}update(t,e=0,o=t.length){let F=~this.crc>>>0;for(let c=0;c<o;c++)F=F>>>8^this.table[(F^t[e+c])&255];return this.crc=~F>>>0,this}get digest(){return this.crc}}const Ve=[0,4278190080,4294967295,4286611584,4294901760,4278255360,4278190335,4278255615,4294967040,4294902015,4280295456,4282400832,4284506208,4288651167,4290756543,4292861919,4278716424,4279242768,4279769112,4280821800,4281348144,4281874488,4282927176,4283453520,4283979864,4285032552,4285558896,4286085240,4287072135,4287598479,4288124823,4289177511,4289703855,4290230199,4291282887,4291809231,4292335575,4293388263,4293914607,4294440951,4278190080,4278203136,4278216192,4278229248,4278242304,4278255360,4278190131,4278203187,4278216243,4278229299,4278242355,4278255411,4278190182,4278203238,4278216294,4278229350,4278242406,4278255462,4278190233,4278203289,4278216345,4278229401,4278242457,4278255513,4278190284,4278203340,4278216396,4278229452,4278242508,4278255564,4278190335,4278203391,4278216447,4278229503,4278242559,4278255615,4281532416,4281545472,4281558528,4281571584,4281584640,4281597696,4281532467,4281545523,4281558579,4281571635,4281584691,4281597747,4281532518,4281545574,4281558630,4281571686,4281584742,4281597798,4281532569,4281545625,4281558681,4281571737,4281584793,4281597849,4281532620,4281545676,4281558732,4281571788,4281584844,4281597900,4281532671,4281545727,4281558783,4281571839,4281584895,4281597951,4284874752,4284887808,4284900864,4284913920,4284926976,4284940032,4284874803,4284887859,4284900915,4284913971,4284927027,4284940083,4284874854,4284887910,4284900966,4284914022,4284927078,4284940134,4284874905,4284887961,4284901017,4284914073,4284927129,4284940185,4284874956,4284888012,4284901068,4284914124,4284927180,4284940236,4284875007,4284888063,4284901119,4284914175,4284927231,4284940287,4288217088,4288230144,4288243200,4288256256,4288269312,4288282368,4288217139,4288230195,4288243251,4288256307,4288269363,4288282419,4288217190,4288230246,4288243302,4288256358,4288269414,4288282470,4288217241,4288230297,4288243353,4288256409,4288269465,4288282521,4288217292,4288230348,4288243404,4288256460,4288269516,4288282572,4288217343,4288230399,4288243455,4288256511,4288269567,4288282623,4291559424,4291572480,4291585536,4291598592,4291611648,4291624704,4291559475,4291572531,4291585587,4291598643,4291611699,4291624755,4291559526,4291572582,4291585638,4291598694,4291611750,4291624806,4291559577,4291572633,4291585689,4291598745,4291611801,4291624857,4291559628,4291572684,4291585740,4291598796,4291611852,4291624908,4291559679,4291572735,4291585791,4291598847,4291611903,4291624959,4294901760,4294914816,4294927872,4294940928,4294953984,4294967040,4294901811,4294914867,4294927923,4294940979,4294954035,4294967091,4294901862,4294914918,4294927974,4294941030,4294954086,4294967142,4294901913,4294914969,4294928025,4294941081,4294954137,4294967193,4294901964,4294915020,4294928076,4294941132,4294954188,4294967244,4294902015,4294915071,4294928127,4294941183,4294954239,4294967295],Je=[4294967295,4278190080],ce=new B({sizeOf(r,t){const e=r[t];return e<=223?1:e<=254?2:5},read(r,t){const e=r[t];return e<=223?e:e<=254?(e-224)*256+r[t+1]:b.read(r,t+1)}});class Ye{decode(t,e,o,F,c){const l=this.decodePixels(F,o===32);if(o<=8)return c||(c=o===1?Je:Ve),this.unpackPixels(l,t,e,o,c);if(o===16)return this.raster16To32(l,t,e);if(o===32)return l;throw new Error("Unhandled Squeak Image depth.")}decodePixels(t,e){let o;if(Array.isArray(t)||t instanceof Uint32Array){if(o=new Uint32Array(t),e)for(let d=0;d<o.length;d++)o[d]!==0&&(o[d]=4278190080|o[d]);return o}const F=new W(t.buffer,t.byteOffset),c=F.read(ce);o=new Uint32Array(c);let l=0;for(;l<c;){const d=F.read(ce),w=d>>2,x=d&3;let y;switch(x){case 0:l+=w;break;case 1:y=F.read(R),y=y<<24|y<<16|y<<8|y,e&&y!==0&&(y|=4278190080);for(let E=0;E<w;E++)o[l++]=y;break;case 2:y=F.read(b),e&&y!==0&&(y|=4278190080);for(let E=0;E<w;E++)o[l++]=y;break;case 3:for(let E=0;E<w;E++)y=F.read(b),e&&y!==0&&(y|=4278190080),o[l++]=y}}return o}unpackPixels(t,e,o,F,c){const l=new Uint32Array(e*o),d=(1<<F)-1,w=32/F;let x=0,y=0;for(let E=0;E<o;E++){let _,L=-1;for(let O=0;O<e;O++)L<0&&(L=F*(w-1),_=t[y++]),l[x++]=c[_>>L&d],L-=F}return l}raster16To32(t,e,o){const F=new Uint32Array(2*t.length);let c,l,d,w=0,x=0;for(let y=0;y<o;y++){c=-1;for(let E=0;E<e;E++){if(c<0&&(c=16,l=t[w++]),d=l>>c&65535,d!==0){const _=d>>7&248,L=d>>2&248,O=d<<3&248;d=4278190080|_<<16|L<<8|O}F[x++]=d,c-=16}}return F}buildCustomColormap(t,e,o){const F=new Uint32Array(1<<t);for(let c=0;c<e.length;c++)F[c]=o[e[c].index-1];return F}}const We=[7,8,9,10,11,12,13,14,16,17,19,21,23,25,28,31,34,37,41,45,50,55,60,66,73,80,88,97,107,118,130,143,157,173,190,209,230,253,279,307,337,371,408,449,494,544,598,658,724,796,876,963,1060,1166,1282,1411,1552,1707,1878,2066,2272,2499,2749,3024,3327,3660,4026,4428,4871,5358,5894,6484,7132,7845,8630,9493,10442,11487,12635,13899,15289,16818,18500,20350,22385,24623,27086,29794,32767],Xe={2:[-1,2,-1,2],3:[-1,-1,2,4,-1,-1,2,4],4:[-1,-1,-1,-1,2,4,6,8,-1,-1,-1,-1,2,4,6,8],5:[-1,-1,-1,-1,-1,-1,-1,-1,1,2,4,6,8,10,13,16,-1,-1,-1,-1,-1,-1,-1,-1,1,2,4,6,8,10,13,16]};class ue{constructor(t){this.bitsPerSample=t,this.indexTable=Xe[t],this.signMask=1<<t-1,this.valueMask=this.signMask-1,this.valueHighBit=this.signMask>>1,this.bitPosition=0,this.currentByte=0,this.stream=null,this.end=0}decode(t){this.bitPosition=0,this.currentByte=0,this.stream=new W(t.buffer,t.byteOffset),this.end=t.byteOffset+t.length;const e=Math.floor(t.length*8/this.bitsPerSample),o=new Int16Array(e);let F=0,c=0;for(let l=0;l<e;l++){const d=this.nextCode();N(d>=0,"Ran out of bits in Squeak Sound");let w=We[c],x=0;for(let y=this.valueHighBit;y>0;y=y>>1)(d&y)!==0&&(x+=w),w=w>>1;x+=w,F+=(d&this.signMask)===0?x:-x,c+=this.indexTable[d],c<0&&(c=0),c>88&&(c=88),F>32767&&(F=32767),F<-32768&&(F=-32768),o[l]=F}return o}nextCode(){let t=this.bitsPerSample,e=t-this.bitPosition,o=e<0?this.currentByte>>-e:this.currentByte<<e;for(;e>0;){if(t-=this.bitPosition,this.end-this.stream.position>0)this.currentByte=this.stream.read(R),this.bitPosition=8;else return this.currentByte=0,this.bitPosition=0,-1;e=t-this.bitPosition,o+=e<0?this.currentByte>>-e:this.currentByte<<e}return this.bitPosition-=t,this.currentByte=this.currentByte&255>>8-this.bitPosition,o}static samples(t,e){return e.length*8/t}}class g{constructor(t=new Uint8Array(this.size),e=0){this.uint8a=t,this.offset=e}equals(t){for(const e in t)if(this[e]!==t[e])return!1;return!0}view(){const t=this.constructor.name,e={toString(){return t}};for(const o in this.shape)e[o]=this[o];return e}static initConstructor(t){return t.size=t.prototype.size,t}static extend(t){const e=class extends g{get shape(){return t}};let o=0;return Object.keys(t).forEach(F=>{if(Object.defineProperty(e.prototype,F,t[F].asPropertyObject(o)),t[F].size===0)throw new Error("Packet cannot be defined with variable sized members.");o+=t[F].size}),e.prototype.size=o,e.size=o,e}}class et extends g.extend({riff:new U(4),length:tt,wave:new U(4)}){}g.initConstructor(et);class H extends g.extend({chunkType:new U(4),length:tt}){}g.initConstructor(H);class ht extends g.extend({format:q,channels:q,sampleRate:tt,bytesPerSec:tt,blockAlignment:q,bitsPerSample:q}){}g.initConstructor(ht);class _t{encode(t,{channels:e=1,sampleRate:o=22050}={}){const F=new Uint8Array(t.buffer,t.byteOffset,t.byteLength),c=et.size+H.size+ht.size+H.size+F.length,l=new W(new ArrayBuffer(c));return l.writeStruct(et,{riff:"RIFF",length:c-8,wave:"WAVE"}),l.writeStruct(H,{chunkType:"fmt ",length:ht.size}),l.writeStruct(ht,{format:1,channels:e,sampleRate:o,bytesPerSec:o*2*e,blockAlignment:e*2,bitsPerSample:16}),l.writeStruct(H,{chunkType:"data",length:c-l.position-H.size}),l.writeBytes(F),l.uint8a}static encode(t,e){return new _t().encode(t,e)}static samples(t){const e=new H(t,et.size).length;return new H(t,et.size+H.size+e).length/2}}var qe=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function $e(r){if(Object.prototype.hasOwnProperty.call(r,"__esModule"))return r;var t=r.default;if(typeof t=="function"){var e=function o(){var F=!1;try{F=this instanceof o}catch{}return F?Reflect.construct(t,arguments,this.constructor):t.apply(this,arguments)};e.prototype=t.prototype}else e={};return Object.defineProperty(e,"__esModule",{value:!0}),Object.keys(r).forEach(function(o){var F=Object.getOwnPropertyDescriptor(r,o);Object.defineProperty(e,o,F.get?F:{enumerable:!0,get:function(){return r[o]}})}),e}var vt={exports:{}};const fe=$e(Object.freeze(Object.defineProperty({__proto__:null,default:{}},Symbol.toStringTag,{value:"Module"})));var le;function Ke(){return le||(le=1,(function(r){(function(){var t="input is invalid type",e="finalize already called",o=typeof window=="object",F=o?window:{};F.JS_MD5_NO_WINDOW&&(o=!1);var c=!o&&typeof self=="object",l=!F.JS_MD5_NO_NODE_JS&&typeof process=="object"&&process.versions&&process.versions.node;l?F=qe:c&&(F=self);var d=!F.JS_MD5_NO_COMMON_JS&&!0&&r.exports,w=!F.JS_MD5_NO_ARRAY_BUFFER&&typeof ArrayBuffer<"u",x="0123456789abcdef".split(""),y=[128,32768,8388608,-2147483648],E=[0,8,16,24],_=["hex","array","digest","buffer","arrayBuffer","base64"],L="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/".split(""),O=[],xt;if(w){var Ct=new ArrayBuffer(68);xt=new Uint8Array(Ct),O=new Uint32Array(Ct)}var Z=Array.isArray;(F.JS_MD5_NO_NODE_JS||!Z)&&(Z=function(s){return Object.prototype.toString.call(s)==="[object Array]"});var Q=ArrayBuffer.isView;w&&(F.JS_MD5_NO_ARRAY_BUFFER_IS_VIEW||!Q)&&(Q=function(s){return typeof s=="object"&&s.buffer&&s.buffer.constructor===ArrayBuffer});var f=function(s){var n=typeof s;if(n==="string")return[s,!0];if(n!=="object"||s===null)throw new Error(t);if(w&&s.constructor===ArrayBuffer)return[new Uint8Array(s),!1];if(!Z(s)&&!Q(s))throw new Error(t);return[s,!1]},T=function(s){return function(n){return new v(!0).update(n)[s]()}},I=function(){var s=T("hex");l&&(s=M(s)),s.create=function(){return new v},s.update=function(i){return s.create().update(i)};for(var n=0;n<_.length;++n){var a=_[n];s[a]=T(a)}return s},M=function(s){var n=fe,a=fe.Buffer,i;a.from&&!F.JS_MD5_NO_BUFFER_FROM?i=a.from:i=function(u){return new a(u)};var C=function(u){if(typeof u=="string")return n.createHash("md5").update(u,"utf8").digest("hex");if(u==null)throw new Error(t);return u.constructor===ArrayBuffer&&(u=new Uint8Array(u)),Z(u)||Q(u)||u.constructor===a?n.createHash("md5").update(i(u)).digest("hex"):s(u)};return C},yt=function(s){return function(n,a){return new Et(n,!0).update(a)[s]()}},Gt=function(){var s=yt("hex");s.create=function(i){return new Et(i)},s.update=function(i,C){return s.create(i).update(C)};for(var n=0;n<_.length;++n){var a=_[n];s[a]=yt(a)}return s};function v(s){if(s)O[0]=O[16]=O[1]=O[2]=O[3]=O[4]=O[5]=O[6]=O[7]=O[8]=O[9]=O[10]=O[11]=O[12]=O[13]=O[14]=O[15]=0,this.blocks=O,this.buffer8=xt;else if(w){var n=new ArrayBuffer(68);this.buffer8=new Uint8Array(n),this.blocks=new Uint32Array(n)}else this.blocks=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0];this.h0=this.h1=this.h2=this.h3=this.start=this.bytes=this.hBytes=0,this.finalized=this.hashed=!1,this.first=!0}v.prototype.update=function(s){if(this.finalized)throw new Error(e);var n=f(s);s=n[0];for(var a=n[1],i,C=0,u,h=s.length,p=this.blocks,P=this.buffer8;C<h;){if(this.hashed&&(this.hashed=!1,p[0]=p[16],p[16]=p[1]=p[2]=p[3]=p[4]=p[5]=p[6]=p[7]=p[8]=p[9]=p[10]=p[11]=p[12]=p[13]=p[14]=p[15]=0),a)if(w)for(u=this.start;C<h&&u<64;++C)i=s.charCodeAt(C),i<128?P[u++]=i:i<2048?(P[u++]=192|i>>>6,P[u++]=128|i&63):i<55296||i>=57344?(P[u++]=224|i>>>12,P[u++]=128|i>>>6&63,P[u++]=128|i&63):(i=65536+((i&1023)<<10|s.charCodeAt(++C)&1023),P[u++]=240|i>>>18,P[u++]=128|i>>>12&63,P[u++]=128|i>>>6&63,P[u++]=128|i&63);else for(u=this.start;C<h&&u<64;++C)i=s.charCodeAt(C),i<128?p[u>>>2]|=i<<E[u++&3]:i<2048?(p[u>>>2]|=(192|i>>>6)<<E[u++&3],p[u>>>2]|=(128|i&63)<<E[u++&3]):i<55296||i>=57344?(p[u>>>2]|=(224|i>>>12)<<E[u++&3],p[u>>>2]|=(128|i>>>6&63)<<E[u++&3],p[u>>>2]|=(128|i&63)<<E[u++&3]):(i=65536+((i&1023)<<10|s.charCodeAt(++C)&1023),p[u>>>2]|=(240|i>>>18)<<E[u++&3],p[u>>>2]|=(128|i>>>12&63)<<E[u++&3],p[u>>>2]|=(128|i>>>6&63)<<E[u++&3],p[u>>>2]|=(128|i&63)<<E[u++&3]);else if(w)for(u=this.start;C<h&&u<64;++C)P[u++]=s[C];else for(u=this.start;C<h&&u<64;++C)p[u>>>2]|=s[C]<<E[u++&3];this.lastByteIndex=u,this.bytes+=u-this.start,u>=64?(this.start=u-64,this.hash(),this.hashed=!0):this.start=u}return this.bytes>4294967295&&(this.hBytes+=this.bytes/4294967296<<0,this.bytes=this.bytes%4294967296),this},v.prototype.finalize=function(){if(!this.finalized){this.finalized=!0;var s=this.blocks,n=this.lastByteIndex;s[n>>>2]|=y[n&3],n>=56&&(this.hashed||this.hash(),s[0]=s[16],s[16]=s[1]=s[2]=s[3]=s[4]=s[5]=s[6]=s[7]=s[8]=s[9]=s[10]=s[11]=s[12]=s[13]=s[14]=s[15]=0),s[14]=this.bytes<<3,s[15]=this.hBytes<<3|this.bytes>>>29,this.hash()}},v.prototype.hash=function(){var s,n,a,i,C,u,h=this.blocks;this.first?(s=h[0]-680876937,s=(s<<7|s>>>25)-271733879<<0,i=(-1732584194^s&2004318071)+h[1]-117830708,i=(i<<12|i>>>20)+s<<0,a=(-271733879^i&(s^-271733879))+h[2]-1126478375,a=(a<<17|a>>>15)+i<<0,n=(s^a&(i^s))+h[3]-1316259209,n=(n<<22|n>>>10)+a<<0):(s=this.h0,n=this.h1,a=this.h2,i=this.h3,s+=(i^n&(a^i))+h[0]-680876936,s=(s<<7|s>>>25)+n<<0,i+=(a^s&(n^a))+h[1]-389564586,i=(i<<12|i>>>20)+s<<0,a+=(n^i&(s^n))+h[2]+606105819,a=(a<<17|a>>>15)+i<<0,n+=(s^a&(i^s))+h[3]-1044525330,n=(n<<22|n>>>10)+a<<0),s+=(i^n&(a^i))+h[4]-176418897,s=(s<<7|s>>>25)+n<<0,i+=(a^s&(n^a))+h[5]+1200080426,i=(i<<12|i>>>20)+s<<0,a+=(n^i&(s^n))+h[6]-1473231341,a=(a<<17|a>>>15)+i<<0,n+=(s^a&(i^s))+h[7]-45705983,n=(n<<22|n>>>10)+a<<0,s+=(i^n&(a^i))+h[8]+1770035416,s=(s<<7|s>>>25)+n<<0,i+=(a^s&(n^a))+h[9]-1958414417,i=(i<<12|i>>>20)+s<<0,a+=(n^i&(s^n))+h[10]-42063,a=(a<<17|a>>>15)+i<<0,n+=(s^a&(i^s))+h[11]-1990404162,n=(n<<22|n>>>10)+a<<0,s+=(i^n&(a^i))+h[12]+1804603682,s=(s<<7|s>>>25)+n<<0,i+=(a^s&(n^a))+h[13]-40341101,i=(i<<12|i>>>20)+s<<0,a+=(n^i&(s^n))+h[14]-1502002290,a=(a<<17|a>>>15)+i<<0,n+=(s^a&(i^s))+h[15]+1236535329,n=(n<<22|n>>>10)+a<<0,s+=(a^i&(n^a))+h[1]-165796510,s=(s<<5|s>>>27)+n<<0,i+=(n^a&(s^n))+h[6]-1069501632,i=(i<<9|i>>>23)+s<<0,a+=(s^n&(i^s))+h[11]+643717713,a=(a<<14|a>>>18)+i<<0,n+=(i^s&(a^i))+h[0]-373897302,n=(n<<20|n>>>12)+a<<0,s+=(a^i&(n^a))+h[5]-701558691,s=(s<<5|s>>>27)+n<<0,i+=(n^a&(s^n))+h[10]+38016083,i=(i<<9|i>>>23)+s<<0,a+=(s^n&(i^s))+h[15]-660478335,a=(a<<14|a>>>18)+i<<0,n+=(i^s&(a^i))+h[4]-405537848,n=(n<<20|n>>>12)+a<<0,s+=(a^i&(n^a))+h[9]+568446438,s=(s<<5|s>>>27)+n<<0,i+=(n^a&(s^n))+h[14]-1019803690,i=(i<<9|i>>>23)+s<<0,a+=(s^n&(i^s))+h[3]-187363961,a=(a<<14|a>>>18)+i<<0,n+=(i^s&(a^i))+h[8]+1163531501,n=(n<<20|n>>>12)+a<<0,s+=(a^i&(n^a))+h[13]-1444681467,s=(s<<5|s>>>27)+n<<0,i+=(n^a&(s^n))+h[2]-51403784,i=(i<<9|i>>>23)+s<<0,a+=(s^n&(i^s))+h[7]+1735328473,a=(a<<14|a>>>18)+i<<0,n+=(i^s&(a^i))+h[12]-1926607734,n=(n<<20|n>>>12)+a<<0,C=n^a,s+=(C^i)+h[5]-378558,s=(s<<4|s>>>28)+n<<0,i+=(C^s)+h[8]-2022574463,i=(i<<11|i>>>21)+s<<0,u=i^s,a+=(u^n)+h[11]+1839030562,a=(a<<16|a>>>16)+i<<0,n+=(u^a)+h[14]-35309556,n=(n<<23|n>>>9)+a<<0,C=n^a,s+=(C^i)+h[1]-1530992060,s=(s<<4|s>>>28)+n<<0,i+=(C^s)+h[4]+1272893353,i=(i<<11|i>>>21)+s<<0,u=i^s,a+=(u^n)+h[7]-155497632,a=(a<<16|a>>>16)+i<<0,n+=(u^a)+h[10]-1094730640,n=(n<<23|n>>>9)+a<<0,C=n^a,s+=(C^i)+h[13]+681279174,s=(s<<4|s>>>28)+n<<0,i+=(C^s)+h[0]-358537222,i=(i<<11|i>>>21)+s<<0,u=i^s,a+=(u^n)+h[3]-722521979,a=(a<<16|a>>>16)+i<<0,n+=(u^a)+h[6]+76029189,n=(n<<23|n>>>9)+a<<0,C=n^a,s+=(C^i)+h[9]-640364487,s=(s<<4|s>>>28)+n<<0,i+=(C^s)+h[12]-421815835,i=(i<<11|i>>>21)+s<<0,u=i^s,a+=(u^n)+h[15]+530742520,a=(a<<16|a>>>16)+i<<0,n+=(u^a)+h[2]-995338651,n=(n<<23|n>>>9)+a<<0,s+=(a^(n|~i))+h[0]-198630844,s=(s<<6|s>>>26)+n<<0,i+=(n^(s|~a))+h[7]+1126891415,i=(i<<10|i>>>22)+s<<0,a+=(s^(i|~n))+h[14]-1416354905,a=(a<<15|a>>>17)+i<<0,n+=(i^(a|~s))+h[5]-57434055,n=(n<<21|n>>>11)+a<<0,s+=(a^(n|~i))+h[12]+1700485571,s=(s<<6|s>>>26)+n<<0,i+=(n^(s|~a))+h[3]-1894986606,i=(i<<10|i>>>22)+s<<0,a+=(s^(i|~n))+h[10]-1051523,a=(a<<15|a>>>17)+i<<0,n+=(i^(a|~s))+h[1]-2054922799,n=(n<<21|n>>>11)+a<<0,s+=(a^(n|~i))+h[8]+1873313359,s=(s<<6|s>>>26)+n<<0,i+=(n^(s|~a))+h[15]-30611744,i=(i<<10|i>>>22)+s<<0,a+=(s^(i|~n))+h[6]-1560198380,a=(a<<15|a>>>17)+i<<0,n+=(i^(a|~s))+h[13]+1309151649,n=(n<<21|n>>>11)+a<<0,s+=(a^(n|~i))+h[4]-145523070,s=(s<<6|s>>>26)+n<<0,i+=(n^(s|~a))+h[11]-1120210379,i=(i<<10|i>>>22)+s<<0,a+=(s^(i|~n))+h[2]+718787259,a=(a<<15|a>>>17)+i<<0,n+=(i^(a|~s))+h[9]-343485551,n=(n<<21|n>>>11)+a<<0,this.first?(this.h0=s+1732584193<<0,this.h1=n-271733879<<0,this.h2=a-1732584194<<0,this.h3=i+271733878<<0,this.first=!1):(this.h0=this.h0+s<<0,this.h1=this.h1+n<<0,this.h2=this.h2+a<<0,this.h3=this.h3+i<<0)},v.prototype.hex=function(){this.finalize();var s=this.h0,n=this.h1,a=this.h2,i=this.h3;return x[s>>>4&15]+x[s&15]+x[s>>>12&15]+x[s>>>8&15]+x[s>>>20&15]+x[s>>>16&15]+x[s>>>28&15]+x[s>>>24&15]+x[n>>>4&15]+x[n&15]+x[n>>>12&15]+x[n>>>8&15]+x[n>>>20&15]+x[n>>>16&15]+x[n>>>28&15]+x[n>>>24&15]+x[a>>>4&15]+x[a&15]+x[a>>>12&15]+x[a>>>8&15]+x[a>>>20&15]+x[a>>>16&15]+x[a>>>28&15]+x[a>>>24&15]+x[i>>>4&15]+x[i&15]+x[i>>>12&15]+x[i>>>8&15]+x[i>>>20&15]+x[i>>>16&15]+x[i>>>28&15]+x[i>>>24&15]},v.prototype.toString=v.prototype.hex,v.prototype.digest=function(){this.finalize();var s=this.h0,n=this.h1,a=this.h2,i=this.h3;return[s&255,s>>>8&255,s>>>16&255,s>>>24&255,n&255,n>>>8&255,n>>>16&255,n>>>24&255,a&255,a>>>8&255,a>>>16&255,a>>>24&255,i&255,i>>>8&255,i>>>16&255,i>>>24&255]},v.prototype.array=v.prototype.digest,v.prototype.arrayBuffer=function(){this.finalize();var s=new ArrayBuffer(16),n=new Uint32Array(s);return n[0]=this.h0,n[1]=this.h1,n[2]=this.h2,n[3]=this.h3,s},v.prototype.buffer=v.prototype.arrayBuffer,v.prototype.base64=function(){for(var s,n,a,i="",C=this.array(),u=0;u<15;)s=C[u++],n=C[u++],a=C[u++],i+=L[s>>>2]+L[(s<<4|n>>>4)&63]+L[(n<<2|a>>>6)&63]+L[a&63];return s=C[u],i+=L[s>>>2]+L[s<<4&63]+"==",i};function Et(s,n){var a,i=f(s);if(s=i[0],i[1]){var C=[],u=s.length,h=0,p;for(a=0;a<u;++a)p=s.charCodeAt(a),p<128?C[h++]=p:p<2048?(C[h++]=192|p>>>6,C[h++]=128|p&63):p<55296||p>=57344?(C[h++]=224|p>>>12,C[h++]=128|p>>>6&63,C[h++]=128|p&63):(p=65536+((p&1023)<<10|s.charCodeAt(++a)&1023),C[h++]=240|p>>>18,C[h++]=128|p>>>12&63,C[h++]=128|p>>>6&63,C[h++]=128|p&63);s=C}s.length>64&&(s=new v(!0).update(s).array());var P=[],we=[];for(a=0;a<64;++a){var Ae=s[a]||0;P[a]=92^Ae,we[a]=54^Ae}v.call(this,n),this.update(we),this.oKeyPad=P,this.inner=!0,this.sharedMemory=n}Et.prototype=new v,Et.prototype.finalize=function(){if(v.prototype.finalize.call(this),this.inner){this.inner=!1;var s=this.array();v.call(this,this.sharedMemory),this.update(this.oKeyPad),this.update(s),v.prototype.finalize.call(this)}};var st=I();st.md5=st,st.md5.hmac=Gt(),d?r.exports=st:F.md5=st})()})(vt)),vt.exports}var de=Ke();class Ze extends m.define({X:0,Y:1}){}class Qe extends m.define({X:0,Y:1,X2:2,Y2:3}){get width(){return this.x2-this.x}get height(){return this.y2-this.y}}const tr=r=>{for(let t=0;t<r.length;t+=4){const e=r[t+2],o=r[t+0];r[t+2]=o,r[t+0]=e}return r};class ct extends m.define({WIDTH:0,HEIGHT:1,DEPTH:2,BYTES:4,COLORMAP:5}){get decoded(){return this._decoded||(this._decoded=tr(new Uint8Array(new Ye().decode(this.width.value,this.height.value,this.depth.value,this.bytes.value,this.colormap&&this.colormap.map(t=>t.valueOf())).buffer))),this._decoded}get extension(){return"uncompressed"}}class xe extends m.define({STAGE_CONTENTS:2,OBJ_NAME:6,VARS:7,BLOCKS_BIN:8,IS_CLONE:9,MEDIA:10,CURRENT_COSTUME:11,ZOOM:12,H_PAN:13,V_PAN:14,OBSOLETE_SAVED_STATE:15,SPRITE_ORDER_IN_LIBRARY:16,VOLUME:17,TEMPO_BPM:18,SCENE_STATES:19,LISTS:20}){get spriteOrderInLibrary(){return this.fields[this.FIELDS.SPRITE_ORDER_IN_LIBRARY]||null}get tempoBPM(){return this.fields[this.FIELDS.TEMPO_BPM]||0}get lists(){return this.fields[this.FIELDS.LISTS]||[]}}class Bt extends m.define({BOX:0,PARENT:1,COLOR:3,VISIBLE:4,OBJ_NAME:6,VARS:7,BLOCKS_BIN:8,IS_CLONE:9,MEDIA:10,CURRENT_COSTUME:11,VISIBILITY:12,SCALE_POINT:13,ROTATION_DEGREES:14,ROTATION_STYLE:15,VOLUME:16,TEMPO_BPM:17,DRAGGABLE:18,SCENE_STATES:19,LISTS:20}){get scratchX(){return this.box.x+this.currentCostume.rotationCenter.x-240}get scratchY(){return 180-(this.box.y+this.currentCostume.rotationCenter.y)}get visible(){return(this.fields[this.FIELDS.VISIBLE]&1)===0}get tempoBPM(){return this.fields[this.FIELDS.TEMPO_BPM]||0}get lists(){return this.fields[this.FIELDS.LISTS]||[]}}class gr extends m.define({RECTANGLE:0,FONT:8,COLOR:9,LINES:11}){}class ut extends m.define({COSTUME_NAME:0,BITMAP:1,ROTATION_CENTER:2,TEXT_DETAILS:3,BASE_LAYER_DATA:4,OLD_COMPOSITE:5}){get image(){return this.oldComposite instanceof ct?this.oldComposite:this.baseLayerData.value?null:this.bitmap}get width(){return this.image===null?-1:this.image.width}get height(){return this.image===null?-1:this.image.height}get rawBytes(){return this.image===null?this.baseLayerData.value.slice():this.image.bytes.value}get decoded(){return this.image===null?this.baseLayerData.value.slice():this.image.decoded}get crc(){if(!this._crc){const t=new It().update(new Uint8Array(new Uint32Array([this.bitmap.width]).buffer)).update(new Uint8Array(new Uint32Array([this.bitmap.height]).buffer)).update(new Uint8Array(new Uint32Array([this.bitmap.depth]).buffer)).update(this.rawBytes);this._crc=t.digest}return this._crc}get extension(){return this.oldComposite instanceof ct?"uncompressed":this.baseLayerData.value?"jpg":"uncompressed"}toString(){return`ImageMediaData "${this.costumeName}"`}}class er extends m.define({DATA:3,RATE:4}){}const rr=r=>{const t=new Uint8Array(r);for(let e=0;e<t.length;e+=2)t[e]=r[e+1],t[e+1]=r[e];return t};class ft extends m.define({NAME:0,UNCOMPRESSED:1,RATE:4,BITS_PER_SAMPLE:5,DATA:6}){get rate(){return this.uncompressed.data.value.length!==0?this.uncompressed.rate:this.fields[this.FIELDS.RATE]}get rawBytes(){return this.data&&this.data.value?this.data.value:this.uncompressed.data.value}get decoded(){return this._decoded||(this.data&&this.data.value?this._decoded=new ue(this.bitsPerSample.value).decode(this.data.value):this._decoded=new Int16Array(rr(this.uncompressed.data.value.slice()).buffer)),this._decoded}get crc(){return this._crc||(this._crc=new It().update(new Uint32Array([this.rate])).update(this.rawBytes).digest),this._crc}get sampleCount(){return this.data&&this.data.value?ue.samples(this.bitsPerSample.value,this.data.value):this.uncompressed.data.value.length/2}get extension(){return"pcm"}get wavEncodedData(){return this._wavEncodedData||(this._wavEncodedData=new Uint8Array(_t.encode(this.decoded,{sampleRate:this.rate&&this.rate.value}))),this._wavEncodedData}get md5(){return this._md5||(this._md5=de.md5(this.wavEncodedData)),this._md5}toString(){return`SoundMediaData "${this.name}"`}}class sr extends m.define({BOX:0,HIDDEN_WHEN_NULL:1,LIST_NAME:8,CONTENTS:9,TARGET:10}){get x(){return Tt(this.hiddenWhenNull)===null?5:this.box.x+1}get y(){return Tt(this.hiddenWhenNull)===null?5:this.box.y+1}get width(){return this.box.width-2}get height(){return this.box.height-2}}class ir extends m.define({BOX:0,PARENT:1,FRAMES:2,COLOR:3,DIRECTION:8,ALIGNMENT:9}){}class nr extends m.define({BOX:0,PARENT:1,COLOR:3}){}class ar extends m.define({BOX:0,COLOR:3,VALUE:8}){}class or extends m.define({BOX:0,READOUT_FRAME:1,COLOR:3,FONT:6,VALUE:8,TARGET:10,CMD:11,PARAM:13}){}class Fr extends m.define({BOX:0}){}const mt={NORMAL:1,LARGE:2,SLIDER:3};class hr extends m.define({BOX:0,TARGET:1,SHAPE:2,READOUT:14,READOUT_FRAME:15,SLIDER:16,ALIGNMENT:17,SLIDER_MIN:20,SLIDER_MAX:21}){get x(){return this.box.x}get y(){return this.box.y}get mode(){return Tt(this.slider)===null?this.readoutFrame.box.height<=14?mt.NORMAL:mt.LARGE:mt.SLIDER}get isDiscrete(){return Math.floor(this.sliderMin)===this.sliderMin&&Math.floor(this.sliderMax)===this.sliderMax&&Math.floor(this.readout.value)===this.readout.value}}const cr={[S.POINT]:Ze,[S.RECTANGLE]:Qe,[S.FORM]:ct,[S.SQUEAK]:ct,[S.SAMPLED_SOUND]:er,[S.SPRITE]:Bt,[S.STAGE]:xe,[S.IMAGE_MEDIA]:ut,[S.SOUND_MEDIA]:ft,[S.ALIGNMENT]:ir,[S.MORPH]:nr,[S.WATCHER_READOUT_FRAME]:Fr,[S.STATIC_STRING]:ar,[S.UPDATING_STRING]:or,[S.WATCHER]:hr,[S.LIST_WATCHER]:sr},Ce=Array.from({length:256},(r,t)=>cr[t]||null);class ye{constructor(t){this.valueIterator=t}[Symbol.iterator](){return this}next(){const t=this.valueIterator.next();if(t.done)return t;const e=t.value,{classId:o}=e;let F=e;if(e instanceof D){F=[];for(let c=0;c<e.size;c++)F.push(this.next().value)}if(Ce[o]!==null||e instanceof ae){const c=Ce[e.classId]||m;F=new c({classId:e.classId,version:e.version,fields:F})}return{value:F,done:!1}}}class Ee{constructor(t){this.table=Array.from(t),this.fixed=this.fix(this.table)}fix(){const t=[];for(let e=0;e<this.table.length;e++)this.fixItem(this.table[e]),t.push(this.table[e]);return t}fixItem(t){if(typeof t.fields<"u"&&(t=t.fields),Array.isArray(t))for(let e=0;e<t.length;e++)t[e]=this.deref(t[e])}deref(t){return t instanceof ne?this.table[t.index-1]:t}}class Rt extends g.extend({support8Bit:R,png:new U(3),dosLineEnding:new U(2),dosEndOfFile:new U(1),unixLineEnding:new U(1)}){static validate(){N(this.equals({support8Bit:137,png:"PNG",dosLineEnding:`\r
|
|
2
|
+
`,dosEndOfFile:"",unixLineEnding:`
|
|
3
|
+
`}),"PNGSignature does not match the expected values")}}g.initConstructor(Rt);class Nt extends g.extend({length:b,chunkType:new U(4)}){}g.initConstructor(Nt);class Lt extends g.extend({checksum:b}){}g.initConstructor(Lt);class Mt extends g.extend({width:b,height:b,bitDepth:R,colorType:R,compressionMethod:R,filterMethod:R,interlaceMethod:R}){}g.initConstructor(Mt);class lt extends g.extend({method:R}){}g.initConstructor(lt);class ur{constructor(){this.adler=1}update(t,e,o){let F=this.adler&65535,c=this.adler>>>16;for(let l=0;l<o;l++)F=(F+t[e+l])%65521,c=(c+F)%65521;return this.adler=c<<16|F,this}get digest(){return this.adler}}const Pt=65535;class Dt extends g.extend({cmf:R,flag:R}){}g.initConstructor(Dt);class dt extends g.extend({lastPacket:R,length:q,lengthCheck:q}){}g.initConstructor(dt);class Ut extends g.extend({checksum:tt}){}g.initConstructor(Ut);class Se{constructor(t){this.stream=t}get uint8a(){return this.stream.uint8a}set uint8a(t){this.stream.uint8a=t}get position(){return this.stream.position}set position(t){this.stream.position=t}writeStruct(t,e){return this.stream.writeStruct(t,e)}writeBytes(t,e=0,o=t.length){return this.stream.writeBytes(t,e,o)}}class pe extends Se{constructor(t){super(t),this.stream.writeStruct(Dt,{cmf:8,flag:29}),this.adler=new ur,this.chunk=this.stream.writeStruct(dt,{lastPacket:0,length:0,lengthCheck:65535})}get _deflateIndex(){return this.chunk.length}set _deflateIndex(t){this.chunk.length=t,this.chunk.lengthCheck=t^65535}writeStruct(t,e){this.writeBytes(Object.assign(new t,e).uint8a)}writeBytes(t,e=0,o=t.length){let F=e;for(;o-F>0;){this._deflateIndex===Pt&&(this.chunk=this.stream.writeStruct(dt,{lastPacket:0,length:0,lengthCheck:65535}));const c=Math.min(o-F,Pt-this._deflateIndex);this.stream.writeBytes(t,F,F+c),this._deflateIndex+=c,F+=c}this.adler.update(t,e,o-e)}finish(){this.chunk.lastPacket=1,this.stream.writeStruct(Ut,{checksum:this.adler.digest})}static estimateSize(t){const e=Math.ceil(t/Pt);return Dt.size+e*dt.size+Ut.size+t}}class $ extends Se{constructor(t,e="IHDR"){super(t),this.start=this.stream.writeStruct(Nt,{length:0,chunkType:e}),this.crc=new It}finish(){const t=this.start.offset+this.start.size,e=this.position-t;this.start.length=e,this.crc.update(this.stream.uint8a,t-b.size,e+b.size),this.stream.writeStruct(Lt,{checksum:this.crc.digest})}static size(t){return Nt.size+t+Lt.size}}class zt{encode(t,e,o){const F=t*4+lt.size,c=F*e,l=Rt.size+$.size(Mt.size)+$.size(pe.estimateSize(c))+$.size(0),d=new W(new ArrayBuffer(l));d.writeStruct(Rt,{support8Bit:137,png:"PNG",dosLineEnding:`\r
|
|
4
|
+
`,dosEndOfFile:"",unixLineEnding:`
|
|
5
|
+
`});const w=new $(d,"IHDR");w.writeStruct(Mt,{width:t,height:e,bitDepth:8,colorType:6,compressionMethod:0,filterMethod:0,interlaceMethod:0}),w.finish();const x=new $(d,"IDAT"),y=new pe(x);let E=0;for(;E<o.length;){y.writeStruct(lt,{method:0});const L=Math.min(o.length-E,F-lt.size);y.writeBytes(o,E,E+L),E+=L}return y.finish(),x.finish(),new $(d,"IEND").finish(),d.buffer}static encode(t,e,o){return new zt().encode(t,e,o)}}class fr{constructor(t){this.file=t}async(t){return N(t==="uint8array","SB1FakeZipFile only supports uint8array"),Promise.resolve(this.file.bytes)}}class lr{constructor(t){this.files=t}file(t){if(t in this.files)return new fr(this.files[t])}}const dr=r=>r.extension==="uncompressed"?"png":"jpg",xr=r=>r.extension==="uncompressed"?new Uint8Array(zt.encode(r.width,r.height,r.decoded)):r.decoded,Cr=r=>r.wavEncodedData,yr=({images:r,sounds:t})=>{const e={};let o=0;for(const F of r)e[`${o++}.${dr(F)}`]={bytes:xr(F)};o=0;for(const F of t)e[`${o++}.wav`]={bytes:Cr(F)};return new lr(e)},rt=r=>{const t=String(r[r.length-1]),e=r.length-1;return t==="mouse"?r[e]="_mouse_":t==="edge"?r[e]="_edge_":r[r.length-1]instanceof xe&&(r[e]="_stage_"),r},Er={getParam:([r,t,e,o])=>[r,t,e,o||"r"],changeVariable:r=>[r[2],r[1],r[3]],EventHatMorph:r=>String(r[1])==="Scratch-StartClicked"?["whenGreenFlag"]:["whenIReceive",r[1]],MouseClickEventHatMorph:()=>["whenClicked"],KeyEventHatMorph:r=>["whenKeyPressed",r[1]],stopScripts:r=>String(r[1])==="other scripts"?[r[0],"other scripts in sprite"]:r,abs:r=>["computeFunction:of:","abs",r[1]],sqrt:r=>["computeFunction:of:","sqrt",r[1]],"\\\\":r=>["%",...r.slice(1)],doReturn:()=>["stopScripts","this script"],stopAll:()=>["stopScripts","all"],"showBackground:":r=>["startScene",r[1]],nextBackground:()=>["nextScene"],doForeverIf:r=>["doForever",[["doIf",r[1],r[2]]]],"getAttribute:of:":rt,"gotoSpriteOrMouse:":rt,"distanceTo:":rt,"pointTowards:":rt,"touching:":rt},Sr=r=>typeof r=="object"&&r?r.valueOf():r,pr=r=>{const{info:t,stageData:e,images:o,sounds:F}=r,c=f=>{const T=[];for(let I=0;I<f.length;I+=2)T.push([f[I],f[I+1]]);return T},l=([f,T])=>({name:f,value:T,isPersistent:!1}),d=([,{listName:f,contents:T,x:I,y:M,width:yt,height:Gt,hiddenWhenNull:v}])=>({listName:f,contents:T,isPersistent:!1,x:I,y:M,width:yt,height:Gt,visible:Sr(v)!==null}),w=f=>{const T=F.findIndex(I=>I.crc===f.crc);return{soundName:f.name,soundID:T,md5:`${f.md5}.wav`,sampleCount:f.sampleCount,rate:f.rate,format:""}},x=f=>f.extension==="uncompressed"?"png":"jpg",y=f=>{const T=o.findIndex(I=>I.crc===f.crc);return{costumeName:f.costumeName,baseLayerID:T,baseLayerMD5:`${de.md5(f.rawBytes)}.${x(f)}`,bitmapResolution:1,rotationCenterX:f.rotationCenter.x,rotationCenterY:f.rotationCenter.y}},E=f=>{let T=f.map(L);const I=Er[T[0]];return I&&(T=I(T)),T},_=f=>f.map(E),L=f=>f instanceof Bt?f.objName:Array.isArray(f)?f.length===0||Array.isArray(f[0])?_(f):E(f):f,O=f=>[f[0].x,f[0].y,_(f[1])],xt=f=>{const T=f.media.filter(M=>M instanceof ut),I=f.media.filter(M=>M instanceof ft);return{objName:f.objName,variables:c(f.vars).map(l),lists:c(f.lists).map(d),scripts:f.blocksBin.map(O),costumes:T.map(y),currentCostumeIndex:T.findIndex(M=>M.crc===f.currentCostume.crc),sounds:I.map(w),scratchX:f.scratchX,scratchY:f.scratchY,scale:f.scalePoint.x,direction:Math.round(f.rotationDegrees*1e6)/1e6-270,rotationStyle:f.rotationStyle,isDraggable:f.draggable,indexInLibrary:e.spriteOrderInLibrary.indexOf(f),visible:f.visible,spriteInfo:{}}},Ct=f=>f instanceof Bt?xt(f):null,Z=f=>{const T=f.media.filter(M=>M instanceof ut),I=f.media.filter(M=>M instanceof ft);return{objName:f.objName,variables:c(f.vars).map(l),lists:c(f.lists).map(d),scripts:f.blocksBin.map(O),costumes:T.map(y),currentCostumeIndex:T.findIndex(M=>M.crc===f.currentCostume.crc),sounds:I.map(w),penLayerMD5:"5c81a336fab8be57adc039a8a2b33ca9.png",penLayerID:0,tempoBPM:f.tempoBPM,videoAlpha:.5,children:f.stageContents.map(Ct).filter(Boolean).reverse()}},Q=f=>{const T={};for(let I=0;I<f.length;I+=2)String(f[I])!=="thumbnail"&&(T[String(f[I])]=String(f[I+1]));return T};return JSON.parse(JSON.stringify(Object.assign(Z(e),{info:Q(t)})))};class Ht extends g.extend({version:new U(10),infoByteLength:b}){validate(){N.validate(this.equals({version:"ScratchV01"})||this.equals({version:"ScratchV02"}),"Invalid Scratch file signature.")}}g.initConstructor(Ht);class K extends g.extend({ObjS:new U(4),ObjSValue:R,Stch:new U(4),StchValue:R,numObjects:b}){validate(){N.validate(this.equals({ObjS:"ObjS",ObjSValue:1,Stch:"Stch",StchValue:1}),"Invalid Scratch file info packet header.")}}g.initConstructor(K);class wr{constructor(t){this.buffer=t,this.stream=new W(t),this.signature=this.stream.readStruct(Ht),this.signature.validate(),this.infoHeader=this.stream.readStruct(K),this.infoHeader.validate(),this.stream.position+=this.signature.infoByteLength-K.size,this.dataHeader=this.stream.readStruct(K),this.dataHeader.validate()}get json(){return pr({info:this.info(),stageData:this.data(),images:this.images(),sounds:this.sounds()})}get zip(){return yr({images:this.images(),sounds:this.sounds()})}view(){return{signature:this.signature,infoHeader:this.infoHeader,dataHeader:this.dataHeader,toString(){return"SB1File"}}}infoRaw(){return new kt(new he(this.buffer,this.infoHeader.offset+K.size),this.signature.infoByteLength+Ht.size)}infoTable(){return new ye(this.infoRaw())}info(){return this._info||(this._info=new Ee(this.infoTable()).table[0]),this._info}dataRaw(){return new kt(new he(this.buffer,this.dataHeader.offset+K.size),this.stream.uint8a.length)}dataTable(){return new ye(this.dataRaw())}dataFixed(){return this._data||(this._data=new Ee(this.dataTable()).table),this._data}data(){return this.dataFixed()[0]}images(){const t=new Set;return this.dataFixed().filter(e=>e instanceof ut?t.has(e.crc)?!1:(t.add(e.crc),!0):!1)}sounds(){const t=new Set;return this.dataFixed().filter(e=>e instanceof ft?t.has(e.crc)?!1:(t.add(e.crc),!0):!1)}}G.AssertionError=k,G.SB1File=wr,G.ValidationError=jt,Object.defineProperty(G,Symbol.toStringTag,{value:"Module"})}));
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
class Adler32 {
|
|
2
|
+
constructor () {
|
|
3
|
+
this.adler = 1;
|
|
4
|
+
}
|
|
5
|
+
|
|
6
|
+
update (uint8a, position, length) {
|
|
7
|
+
let a = this.adler & 0xffff;
|
|
8
|
+
let b = this.adler >>> 16;
|
|
9
|
+
for (let i = 0; i < length; i++) {
|
|
10
|
+
a = (a + uint8a[position + i]) % 65521;
|
|
11
|
+
b = (b + a) % 65521;
|
|
12
|
+
}
|
|
13
|
+
this.adler = (b << 16) | a;
|
|
14
|
+
return this;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
get digest () {
|
|
18
|
+
return this.adler;
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
export {Adler32};
|
|
@@ -0,0 +1,116 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @typedef {function} PacketConstructor
|
|
3
|
+
*/
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* A packet of bytes represented with getter/setter properties for decoding and
|
|
7
|
+
* encoding values mapped to names, located at known offsets.
|
|
8
|
+
*
|
|
9
|
+
* ```js
|
|
10
|
+
* // Defining a subclass:
|
|
11
|
+
* import {Packet} from '../coders/byte-packets';
|
|
12
|
+
* import {Uint8, Uint16LE} from '../coders/byte-primitives';
|
|
13
|
+
*
|
|
14
|
+
* class MyIdentifiedUint16 extends Packet.extend({
|
|
15
|
+
* binaryType: Uint8,
|
|
16
|
+
* value: Uint16LE
|
|
17
|
+
* }) {}
|
|
18
|
+
*
|
|
19
|
+
* Packet.initConstructor(MyIdentifiedUint16);
|
|
20
|
+
*
|
|
21
|
+
* // One way to use it:
|
|
22
|
+
* const indentifiedUint16 = new MyIdentifiedUint16(uint8a, position);
|
|
23
|
+
* indentifiedUint16.binaryType = IDENTIFIED_UINT_16;
|
|
24
|
+
* indentifiedUint16.value = value;
|
|
25
|
+
* ```
|
|
26
|
+
*/
|
|
27
|
+
class Packet {
|
|
28
|
+
/**
|
|
29
|
+
* @param {Uint8Array=} [uint8a=new Uint8Array(this.size)] - byte array to
|
|
30
|
+
* encode to and decode from
|
|
31
|
+
* @param {number=} offset - offset in addition to the member offsets to
|
|
32
|
+
* encode to and decode from
|
|
33
|
+
*/
|
|
34
|
+
constructor (uint8a = new Uint8Array(this.size), offset = 0) {
|
|
35
|
+
/**
|
|
36
|
+
* Byte array to encode to and decode from.
|
|
37
|
+
* @type {Uint8Array}
|
|
38
|
+
*/
|
|
39
|
+
this.uint8a = uint8a;
|
|
40
|
+
|
|
41
|
+
/**
|
|
42
|
+
* Offset in addition to the member offsets to encode to and decode
|
|
43
|
+
* from.
|
|
44
|
+
* @type {number}
|
|
45
|
+
*/
|
|
46
|
+
this.offset = offset;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
/**
|
|
50
|
+
* Check that the decoded values of this Packet match the values in other.
|
|
51
|
+
* @param {object} other - object to match against
|
|
52
|
+
* @returns {boolean} true if all keys in other match values in this packet
|
|
53
|
+
*/
|
|
54
|
+
equals (other) {
|
|
55
|
+
for (const key in other) {
|
|
56
|
+
if (this[key] !== other[key]) {
|
|
57
|
+
return false;
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
return true;
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
view () {
|
|
64
|
+
const className = this.constructor.name;
|
|
65
|
+
const obj = {
|
|
66
|
+
toString () {
|
|
67
|
+
return className;
|
|
68
|
+
}
|
|
69
|
+
};
|
|
70
|
+
for (const key in this.shape) {
|
|
71
|
+
obj[key] = this[key];
|
|
72
|
+
}
|
|
73
|
+
return obj;
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
/**
|
|
77
|
+
* Initialize the Packet subclass constructor for easy access to static
|
|
78
|
+
* members like size.
|
|
79
|
+
* @param {function} PacketConstructor - constuctor function for the Packet
|
|
80
|
+
* subclass
|
|
81
|
+
* @returns {function} initialized constructor
|
|
82
|
+
*/
|
|
83
|
+
static initConstructor (PacketConstructor) {
|
|
84
|
+
PacketConstructor.size = PacketConstructor.prototype.size;
|
|
85
|
+
return PacketConstructor;
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
/**
|
|
89
|
+
* Extend a subclass of Packet with given BytePrimitive members.
|
|
90
|
+
* @param {object} shape - shape of the packet defined with BytePrimitives
|
|
91
|
+
* @returns {function} Packet subclass constructor
|
|
92
|
+
*/
|
|
93
|
+
static extend (shape) {
|
|
94
|
+
const DefinedPacket = class extends Packet {
|
|
95
|
+
get shape () {
|
|
96
|
+
return shape;
|
|
97
|
+
}
|
|
98
|
+
};
|
|
99
|
+
|
|
100
|
+
let position = 0;
|
|
101
|
+
Object.keys(shape).forEach(key => {
|
|
102
|
+
Object.defineProperty(DefinedPacket.prototype, key, shape[key].asPropertyObject(position));
|
|
103
|
+
if (shape[key].size === 0) {
|
|
104
|
+
throw new Error('Packet cannot be defined with variable sized members.');
|
|
105
|
+
}
|
|
106
|
+
position += shape[key].size;
|
|
107
|
+
});
|
|
108
|
+
|
|
109
|
+
DefinedPacket.prototype.size = position;
|
|
110
|
+
DefinedPacket.size = position;
|
|
111
|
+
|
|
112
|
+
return DefinedPacket;
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
export {Packet};
|