diff --git a/.vscode/settings.json b/.vscode/settings.json deleted file mode 100644 index 0baf83e..0000000 --- a/.vscode/settings.json +++ /dev/null @@ -1,4 +0,0 @@ -{ - "python-envs.defaultEnvManager": "ms-python.python:system", - "python-envs.pythonProjects": [] -} \ No newline at end of file diff --git a/2/scratch.html b/2/scratch.html deleted file mode 100644 index e69de29..0000000 diff --git a/Recovery.txt b/Recovery.txt index 72251e2..6088b7d 100644 --- a/Recovery.txt +++ b/Recovery.txt @@ -1,370 +1,13 @@ - + + - - - BarnyWarp - Organizza. Programma. Inventa. - - - - - - - - - - - - - - - -
-
-

Recent Commits

- -
-

Welcome to the page of BarnyWarp.

-
- - - - - - - - - \ No newline at end of file + + + + + Redirect + \ No newline at end of file diff --git a/devposts/01-12-25-barnywarp-s-first-anniversary/index.html b/devposts/01-12-25-barnywarp-s-first-anniversary/index.html new file mode 100644 index 0000000..6e9267e --- /dev/null +++ b/devposts/01-12-25-barnywarp-s-first-anniversary/index.html @@ -0,0 +1,259 @@ + + + + + + BarnyWarp - Organizza. Programma. Inventa. + + + + +

Will be launched a few days before BarnyWarp's First anniversary. Please stay tuned.

+ diff --git a/devposts/index.html b/devposts/index.html new file mode 100644 index 0000000..2f7c106 --- /dev/null +++ b/devposts/index.html @@ -0,0 +1,261 @@ + + + + + + BarnyWarp - Organizza. Programma. Inventa. + + + + +
  • + +
  • + BarnyWarp's First Anniversary + diff --git a/editor/alt.html b/editor/alt.html new file mode 100644 index 0000000..ab06b69 --- /dev/null +++ b/editor/alt.html @@ -0,0 +1,195 @@ + + + + + + + + BarnyWarp - Editor + + + + + + + + + +
    + + + + + + + + diff --git a/editor.html b/editor/index.html similarity index 68% rename from editor.html rename to editor/index.html index e34f6a9..9c7e27b 100644 --- a/editor.html +++ b/editor/index.html @@ -6,7 +6,7 @@ - BarnyWarp 2.5 + BarnyWarp U6 ",A=A.replace(/]*>/,"$&".concat(e))}return A}},function(A,e,t){let i,n;"undefined"==typeof TextEncoder?(i=t(31).TextEncoder,n=t(31).TextDecoder):(i=TextEncoder,n=TextDecoder);const r=""),s=new RegExp("".concat(r,"rotationCenter:(-?[\\d\\.]+):(-?[\\d\\.]+)").concat(o,"$")),B=function(A){let e="";for(let t=0;t{const e=A.match(s);if(!e)return null;const t=+e[1],i=+e[2];return Number.isNaN(t)||Number.isNaN(i)?null:[t,i]},exportCostume:(A,e)=>{var t;const a=A.asset.data;if("svg"!==A.dataFormat)return a;let g=(new n).decode(a);g=g.replace(s,"");const c=A.rotationCenterX,Q=A.rotationCenterY,E="".concat(r,"rotationCenter:").concat(c,":").concat(Q).concat(o);if(g+=E,e&&null!==(t=vm)&&void 0!==t&&null!==(t=t.runtime)&&void 0!==t&&null!==(t=t.fontManager)&&void 0!==t&&t.fonts){const A=(A=>{let e="";for(const t of A){const A=B(t.asset.data);let i=t.asset.dataFormat.toLowerCase();"otf"===i&&(i="opentype"),"ttf"===i&&(i="truetype"),e+="@font-face {",e+='font-family: "'.concat(t.family,'";'),e+="src: url('data:font/".concat(i,";base64,").concat(A,"') format('").concat(i,"');"),e+="}"}return e})(vm.runtime.fontManager.fonts.filter(A=>!A.system).filter(A=>g.includes('font-family=""'.concat(A.family,"", ").concat(A.fallback,'"'))));if(A){const e='");g=g.replace(new RegExp("]*?>"),A=>"".concat(A).concat(e))}}return(new i).encode(g)}}},function(A,e,t){const i=t(9);A.exports=A=>{const e={};for(let t=0;ts.createAsset(s.AssetType.Sound,a,A,null,!0)).then(e=>{A.asset=e,A.assetId=e.assetId,A.md5="".concat(e.assetId,".").concat(e.dataFormat)})},deserializeCostume:function(A,e,t,r,o){const s=e.storage,B=A.assetId,a=r||"".concat(B,".").concat(A.dataFormat);if(!s)return n.warn("No storage module present; cannot load costume asset: ",a),Promise.resolve(null);if(A.asset)return Promise.resolve(s.createAsset(A.asset.assetType,A.asset.dataFormat,new Uint8Array(Object.keys(A.asset.data).map(e=>A.asset.data[e])),null,!0)).then(e=>{A.asset=e,A.assetId=e.assetId,A.md5="".concat(e.assetId,".").concat(e.dataFormat)});if(!t)return Promise.resolve(null);let g=t.file(a);if(!g){const A=new RegExp("^([^/]*/)?".concat(a,"$"));g=t.file(A)[0]}if(!g)return n.error("Could not find costume file associated with the ".concat(A.name," costume.")),Promise.resolve(null);let c=null;const Q=A.dataFormat.toLowerCase();if("svg"===Q?c=s.AssetType.ImageVector:["png","bmp","jpeg","jpg","gif"].indexOf(Q)>=0?c=s.AssetType.ImageBitmap:n.error("Unexpected file format for costume: ".concat(Q)),!i.support.uint8array)return n.error("JSZip uint8array is not supported in this browser."),Promise.resolve(null);let E;if(A.textLayerMD5){const e=t.file(o);if(!e)return n.error("Could not find text layer file associated with the ".concat(A.name," costume.")),Promise.resolve(null);E=e.async("uint8array").then(e=>s.createAsset(s.AssetType.ImageBitmap,"png",e,A.textLayerMD5)).then(e=>{A.textLayerAsset=e})}else E=Promise.resolve(null);return Promise.all([E,g.async("uint8array").then(A=>s.createAsset(c,Q,A,null,!0)).then(e=>{A.asset=e,A.assetId=e.assetId,A.md5="".concat(e.assetId,".").concat(e.dataFormat)})])}}},function(A,e,t){const i=t(23),n=t(69),r=t(72),o=t(8),s=t(5),B=t(9),a=t(10),g=t(6),c=t(446),Q=t(48),E=t(20),l=t(58),h=t(17),w=t(101),{loadCostume:C}=t(50),{loadSound:u}=t(49),{deserializeCostume:I,deserializeSound:M}=t(111),d=["argument","control","data","event","looks","math","motion","operator","procedures","sensing","sound"],D=/\u001f|\./,m=A=>{const[e,t]=A.split(D),i=w.generateExtensionId(e);return"".concat(i,"_").concat(t)},Y=function(A){const e=[{}];let t=0;const i=A.split(/(?=[^\\]%[nbs])/);for(let A=0;AA.inputName).filter(A=>A)},F=function(A){let e=[];for(let t=0;t"".concat(A,"-").concat(a.replaceUnsafeChars(e),"-").concat(t);return function(t,i){return i&&(A={}),function(n,r){return i?(A["".concat(n,"-").concat(r)]=e(t,n,r),A["".concat(n,"-").concat(r)]):A["".concat(n,"-").concat(r)]?A["".concat(n,"-").concat(r)]:e(t,n,r)}}}(),N=function(){let A={};const e=[],t=B();return function(i){return i&&(A={}),{broadcastMsgMapUpdater:function(i,n){return""===(i=i.toLowerCase())&&(i=t),A[i]="broadcastMsgId-".concat(a.replaceUnsafeChars(i)),e.push(n),A[i]},globalBroadcastMsgs:A,allBroadcastFields:e,emptyMsgName:t}}}(),y=(A,e,t,i)=>{if(!c[A.cmd])return void s.warn("Could not find monitor block with opcode: ".concat(A.cmd));const n=c[A.cmd].opcode,r=n.indexOf("_"),o=n.substring(0,r);if("videoSensing"===o)return;if(-1===d.indexOf(o)&&""!==o&&!i.extensionIDs.has(o)&&!A.visible)return;let B=null;if(!A.hasOwnProperty("target"))for(let e=0;e{const t=i.variables[e];return t.type===E.LIST_TYPE&&t.name===A.listName}).length>0&&(B=i,A.target=i.getName())}if(B=B||t.filter(e=>e.getName()===A.target)[0],!B)throw new Error("Cannot create monitor for target that cannot be found by name");const a=f(B.id,!1),[g,Q]=S([A.cmd,A.param],null,a,i,{},null,null);"getVar:"===A.cmd?g.id=a(A.param,E.SCALAR_TYPE):"contentsOfList:"===A.cmd?g.id=a(A.param,E.LIST_TYPE):e.monitorBlockInfo.hasOwnProperty(g.opcode)?g.id=e.monitorBlockInfo[g.opcode].getId(B.id,g.fields):g.id=g.opcode,g.targetId=B.isStage?null:B.id,g.isMonitored=A.visible;const h=e.monitorBlocks._blocks[g.id];if(h)h.isMonitored=A.visible,h.targetId=g.targetId;else{const A=F([g]);for(let t=0;tC(B.md5,B,e,2)))}const{soundBank:o,soundPromises:s}=n;if(A.hasOwnProperty("sounds"))for(let t=0;tu(r,e,o)))}const B=n.children;if(A.children)for(let t=0;t{const[e,t,i,n,r,o,s]=A,B=A[5]>=0,a=new Q(null,s,B?null:1.5*e,B?null:2.2*t,1.5*i,2.2*n,!r);return B&&(a.blockId=o,m.hasOwnProperty(o)?m[o].push(a):m[o]=[a]),a}).forEach(A=>{I.comments[A.id]=A})}A.hasOwnProperty("scripts")&&function(A,e,t,i,n,r){let o=0;for(let s=0;s{"number"==typeof A.blockId&&(A.blockId=null)})}if(a.updateTargetSpecificBlocks(o),A.hasOwnProperty("lists"))for(let e=0;e{c.costumes=A}),Promise.all(u).then(A=>{c.sounds=A,c.soundBank=C||null});const Y=[];if(A.children)for(let i=0;iPromise.all(Y).then(A=>{if(I.isStage){const A=d.globalBroadcastMsgs,e=d.allBroadcastFields,t=d.emptyMsgName;if(A[t]){let i=1;for(;A["message".concat(i)];)i+=1;const n="message".concat(i);A[n]=A[t],delete A[t];for(let A=0;A(A.layerOrder=e,A)).sort((A,e)=>A.targetPaneOrder-e.targetPaneOrder);return e.forEach(A=>{delete A.targetPaneOrder}),e},x=function(A){const e=A[0],t=e&&c[e];return t?"function"==typeof t?t(A):t:e&&(A=>D.test(A))(e)?(A=>{const e=A[0],t=A.length-1,i=[];for(let A=0;A{A.blockId=null,A.x=A.y=0}),[null,a+1];const Q=A[0],l=c.opcode.indexOf("_"),h=c.opcode.substring(0,l);-1===d.indexOf(h)&&""!==h&&i.extensionIDs.add(h);const w={id:B(),opcode:c.opcode,inputs:{},fields:{},next:null,shadow:!1,children:[]};g&&(w.comment=g[g.length-1].id,g.forEach(A=>{A.id===w.comment?A.blockId=w.id:(A.blockId=null,A.x=A.y=0)})),a++;const C=n.expectedArg;"call"===Q&&(c.argMap=Y(A[1]));for(let g=0;g0){let e=null;for(let t=0;tPromise.resolve(A)).then(r=>G(A,e,n,!t,i,r)).then(T).then(A=>({targets:A,extensions:n}))}}},function(A,e){class t{constructor(){this.left=-1/0,this.right=1/0,this.bottom=-1/0,this.top=1/0}initFromBounds(A,e,t,i){this.left=A,this.right=e,this.bottom=t,this.top=i}initFromPointsAABB(A){this.left=1/0,this.right=-1/0,this.top=-1/0,this.bottom=1/0;for(let e=0;ethis.right&&(this.right=t),i>this.top&&(this.top=i),i=A.bottom&&A.top>=this.bottom}contains(A){return A.left>this.left&&A.rightthis.bottom}clamp(A,e,t,i){this.left=Math.max(this.left,A),this.right=Math.min(this.right,e),this.bottom=Math.max(this.bottom,t),this.top=Math.min(this.top,i),this.left=Math.min(this.left,e),this.right=Math.max(this.right,A),this.bottom=Math.min(this.bottom,i),this.top=Math.max(this.top,t)}snapToInt(){this.left=Math.floor(this.left),this.right=Math.ceil(this.right),this.bottom=Math.floor(this.bottom),this.top=Math.ceil(this.top)}static intersect(A,e){let i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:new t;return i.left=Math.max(A.left,e.left),i.right=Math.min(A.right,e.right),i.top=Math.min(A.top,e.top),i.bottom=Math.max(A.bottom,e.bottom),i}static union(A,e){let i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:new t;return i.left=Math.min(A.left,e.left),i.right=Math.max(A.right,e.right),i.top=Math.max(A.top,e.top),i.bottom=Math.min(A.bottom,e.bottom),i}get width(){return Math.abs(this.left-this.right)}get height(){return Math.abs(this.top-this.bottom)}}A.exports=t},function(A,e,t){const i=t(18),{rgbToHsv:n,hsvToRgb:r}=t(463),o=t(40),s=[0,0,0];A.exports=class{static transformColor(A,e,t){if(0===e[3])return e;let i=A.enabledEffects;"number"==typeof t&&(i&=t);const B=A.getUniforms(),a=0!=(i&o.EFFECT_INFO.color.mask),g=0!=(i&o.EFFECT_INFO.saturation.mask),c=0!=(i&o.EFFECT_INFO.brightness.mask),Q=0!=(i&o.EFFECT_INFO.tintColor.mask);if(a||g||c||Q){const A=e[3]/255;if(e[0]/=A,e[1]/=A,e[2]/=A,a){const A=n(e,s);A[0]=B.u_color+A[0]+1,r(A,e)}if(g){const A=n(e,s);A[1]=B.u_saturation*A[1],r(A,e)}if(c){const A=255*B.u_brightness;e[0]+=A,e[1]+=A,e[2]+=A}if(Q){const A=(A=>{const e=A>>24&255;return{r:A>>16&255,g:A>>8&255,b:255&A,a:e>0?e:255}})(B.u_tintColor);e[0],A.r,e[1],A.g,e[2],A.b}e[0]*=A,e[1]*=A,e[2]*=A}return 0!=(i&o.EFFECT_INFO.ghost.mask)&&(e[0]*=B.u_ghost,e[1]*=B.u_ghost,e[2]*=B.u_ghost,e[3]*=B.u_ghost),e}static transformPoint(A,e,t){i.v3.copy(e,t);const n=A.enabledEffects,r=A.getUniforms();if(0!=(n&o.EFFECT_INFO.mosaic.mask)&&(t[0]=r.u_mosaic*t[0]%1,t[1]=r.u_mosaic*t[1]%1),0!=(n&o.EFFECT_INFO.pixelate.mask)){const e=A.skin.getUniforms(),i=e.u_skinSize[0]/r.u_pixelate,n=e.u_skinSize[1]/r.u_pixelate;t[0]=(Math.floor(t[0]*i)+.5)/i,t[1]=(Math.floor(t[1]*n)+.5)/n}if(0!=(n&o.EFFECT_INFO.whirl.mask)){const A=.5,e=t[0]-.5,i=t[1]-.5,n=Math.sqrt(Math.pow(e,2)+Math.pow(i,2)),o=Math.max(1-n/A,0),s=r.u_whirl*o*o,B=Math.sin(s),a=Math.cos(s),g=a,c=-B,Q=B,E=a;t[0]=g*e+Q*i+.5,t[1]=c*e+E*i+.5}if(0!=(n&o.EFFECT_INFO.fisheye.mask)){const A=(t[0]-.5)/.5,e=(t[1]-.5)/.5,i=Math.sqrt(A*A+e*e),n=Math.pow(Math.min(i,1),r.u_fisheye)*Math.max(1,i),o=A/i,s=e/i;t[0]=.5+n*o*.5,t[1]=.5+n*s*.5}return t}}},function(A,e,t){const i=t(54);i.enable(),A.exports=i("scratch-render")},function(A,e,t){const i=t(468),n=t(473);A.exports=class{constructor(A){this._measurementProvider=A,this._cache={}}wrapText(A,e){e=e.normalize();const t="".concat(A,"-").concat(e);if(this._cache[t])return this._cache[t];const r=this._measurementProvider.beginMeasurementSession(),o=new i(e);let s,B=0,a=null;const g=[];for(;s=o.nextBreak();){const t=e.slice(B,s.position).replace(/\n+$/,"");let i=(a||"").concat(t),r=this._measurementProvider.measureText(i);if(r>A){if(this._measurementProvider.measureText(t)>A){let e,o=0;for(;o!==(e=n.nextBreak(t,o));){const n=t.substring(o,e);i=(a||"").concat(n),r=this._measurementProvider.measureText(i),null===a||r<=A?a=i:(g.push(a),a=n),o=e}}else null!==a&&g.push(a),a=t}else a=i;s.required&&(null!==a&&g.push(a),a=null),B=s.position}return a=a||"",(a.length>0||0===g.length)&&g.push(a),this._cache[t]=g,this._measurementProvider.endMeasurementSession(r),g}}},function(A,e,t){var i,n;n=t(469),i=function(){function A(A){var e,t,i;(e="function"==typeof A.readUInt32BE&&"function"==typeof A.slice)||A instanceof Uint8Array?(e?(this.highStart=A.readUInt32BE(0),this.errorValue=A.readUInt32BE(4),t=A.readUInt32BE(8),A=A.slice(12)):(i=new DataView(A.buffer),this.highStart=i.getUint32(0),this.errorValue=i.getUint32(4),t=i.getUint32(8),A=A.subarray(12)),A=n(A,new Uint8Array(t)),A=n(A,new Uint8Array(t)),this.data=new Uint32Array(A.buffer)):(this.data=A.data,this.highStart=A.highStart,this.errorValue=A.errorValue)}return 11,5,6,32,64,63,2,32,31,2048,32,2080,2080,32,2112,4,A.prototype.get=function(A){var e;return A<0||A>1114111?this.errorValue:A<55296||A>56319&&A<=65535?(e=(this.data[A>>5]<<2)+(31&A),this.data[e]):A<=65535?(e=(this.data[2048+(A-55296>>5)]<<2)+(31&A),this.data[e]):A>11)],e=((e=this.data[e+(A>>5&63)])<<2)+(31&A),this.data[e]):this.data[this.data.length-4]},A}(),A.exports=i},function(A,e,t){const i=t(75),n={ImageBitmap:{contentType:"image/png",name:"ImageBitmap",runtimeFormat:i.PNG,immutable:!0},ImageVector:{contentType:"image/svg+xml",name:"ImageVector",runtimeFormat:i.SVG,immutable:!0},Project:{contentType:"application/json",name:"Project",runtimeFormat:i.JSON,immutable:!1},Sound:{contentType:"audio/x-wav",name:"Sound",runtimeFormat:i.WAV,immutable:!0},Sprite:{contentType:"application/json",name:"Sprite",runtimeFormat:i.JSON,immutable:!0},Font:{contentType:"font/ttf",name:"Font",runtimeFormat:i.TTF,immutable:!0},TextBubble:{contentType:"application/json",name:"TextBubbleProperties",runtimeFormat:i.JSON,immutable:!0},ExternalFile:{contentType:"text/plain",name:"ExternalFile",runtimeFormat:i.TXT,immutable:!1}};A.exports=n},function(A,e){A.exports=class{constructor(A){this.parent=A}load(A,e,t){return Promise.reject(new Error("No asset of type ".concat(A," for ID ").concat(e," with format ").concat(t)))}}},function(A,e,t){const i=t(77);A.exports=class extends i{get DEFAULT_VALUE(){return 100}get name(){return"volume"}initialize(){this.inputNode=this.audioEngine.audioContext.createGain(),this.outputNode=this.inputNode,this.initialized=!0}_set(A,e){this.value=A;const{gain:t}=this.outputNode,{currentTime:i,DECAY_DURATION:n}=this.audioEngine;"number"!=typeof e?t.linearRampToValueAtTime(A/100,i+n):t.linearRampToValueAtTime(A/100,i+(n+e))}dispose(){this.initialized&&(this.outputNode.disconnect(),this.inputNode=null,this.outputNode=null,this.target=null,this.initialized=!1)}}},function(A,e,t){const i=t(476);A.exports=i},function(A,e,t){"use strict";var i,n=function(){return void 0===i&&(i=Boolean(window&&document&&document.all&&!window.atob)),i},r=function(){var A={};return function(e){if(void 0===A[e]){var t=document.querySelector(e);if(window.HTMLIFrameElement&&t instanceof window.HTMLIFrameElement)try{t=t.contentDocument.head}catch(A){t=null}A[e]=t}return A[e]}}(),o=[];function s(A){for(var e=-1,t=0;t{const e={};return e._refreshExtensionPrimitives=A._refreshExtensionPrimitives.bind(A),e._registerExtensionPrimitives=A._registerExtensionPrimitives.bind(A),e._removeExtensionPrimitive=A._removeExtensionPrimitive.bind(A),e})(this.runtime)).catch(A=>{Q.error("Failed to register runtime service: ".concat(JSON.stringify(A)))}),this.editingTarget=null,this._dragTarget=null,this.runtime.on(l.SCRIPT_GLOW_ON,A=>{this.emit(l.SCRIPT_GLOW_ON,A)}),this.runtime.on(l.SCRIPT_GLOW_OFF,A=>{this.emit(l.SCRIPT_GLOW_OFF,A)}),this.runtime.on(l.BLOCK_GLOW_ON,A=>{this.emit(l.BLOCK_GLOW_ON,A)}),this.runtime.on(l.BLOCK_GLOW_OFF,A=>{this.emit(l.BLOCK_GLOW_OFF,A)}),this.runtime.on(l.PROJECT_START,()=>{this.emit(l.PROJECT_START)}),this.runtime.on(l.PROJECT_RUN_START,()=>{this.emit(l.PROJECT_RUN_START)}),this.runtime.on(l.PROJECT_RUN_STOP,()=>{this.emit(l.PROJECT_RUN_STOP)}),this.runtime.on(l.PROJECT_CHANGED,()=>{this.emit(l.PROJECT_CHANGED)}),this.runtime.on(l.VISUAL_REPORT,A=>{this.emit(l.VISUAL_REPORT,A)}),this.runtime.on(l.BLOCK_STACK_ERROR,A=>{this.emit(l.BLOCK_STACK_ERROR,A)}),this.runtime.on(l.TARGETS_UPDATE,A=>{this.emitTargetsUpdate(A)}),this.runtime.on(l.MONITORS_UPDATE,A=>{this.emit(l.MONITORS_UPDATE,A)}),this.runtime.on(l.BLOCK_DRAG_UPDATE,A=>{this.emit(l.BLOCK_DRAG_UPDATE,A)}),this.runtime.on(l.BLOCK_DRAG_END,(A,e)=>{this.emit(l.BLOCK_DRAG_END,A,e)}),this.runtime.on(l.EXTENSION_ADDED,A=>{this.emit(l.EXTENSION_ADDED,A)}),this.runtime.on(l.EXTENSION_REMOVED,()=>{this.emit(l.EXTENSION_REMOVED)}),this.runtime.on(l.EXTENSION_FIELD_ADDED,(A,e)=>{this.emit(l.EXTENSION_FIELD_ADDED,A,e)}),this.runtime.on(l.BLOCKSINFO_UPDATE,A=>{this.emit(l.BLOCKSINFO_UPDATE,A)}),this.runtime.on(l.BLOCKS_NEED_UPDATE,()=>{this.emitWorkspaceUpdate()}),this.runtime.on(l.TOOLBOX_EXTENSIONS_NEED_UPDATE,()=>{this.extensionManager.refreshBlocks()}),this.runtime.on(l.PERIPHERAL_LIST_UPDATE,A=>{this.emit(l.PERIPHERAL_LIST_UPDATE,A)}),this.runtime.on(l.USER_PICKED_PERIPHERAL,A=>{this.emit(l.USER_PICKED_PERIPHERAL,A)}),this.runtime.on(l.PERIPHERAL_CONNECTED,()=>this.emit(l.PERIPHERAL_CONNECTED)),this.runtime.on(l.PERIPHERAL_REQUEST_ERROR,()=>this.emit(l.PERIPHERAL_REQUEST_ERROR)),this.runtime.on(l.PERIPHERAL_DISCONNECTED,()=>this.emit(l.PERIPHERAL_DISCONNECTED)),this.runtime.on(l.PERIPHERAL_CONNECTION_LOST_ERROR,A=>this.emit(l.PERIPHERAL_CONNECTION_LOST_ERROR,A)),this.runtime.on(l.PERIPHERAL_SCAN_TIMEOUT,()=>this.emit(l.PERIPHERAL_SCAN_TIMEOUT)),this.runtime.on(l.MIC_LISTENING,A=>{this.emit(l.MIC_LISTENING,A)}),this.runtime.on(l.RUNTIME_STARTED,()=>{this.emit(l.RUNTIME_STARTED)}),this.runtime.on(l.RUNTIME_PAUSED,()=>{this.emit(l.RUNTIME_PAUSED)}),this.runtime.on(l.RUNTIME_UNPAUSED,()=>{this.emit(l.RUNTIME_UNPAUSED)}),this.runtime.on(l.RUNTIME_STOPPED,()=>{this.emit(l.RUNTIME_STOPPED)}),this.runtime.on(l.HAS_CLOUD_DATA_UPDATE,A=>{this.emit(l.HAS_CLOUD_DATA_UPDATE,A)}),this.runtime.on(l.RUNTIME_OPTIONS_CHANGED,A=>{this.emit(l.RUNTIME_OPTIONS_CHANGED,A)}),this.runtime.on(l.COMPILER_OPTIONS_CHANGED,A=>{this.emit(l.COMPILER_OPTIONS_CHANGED,A)}),this.runtime.on(l.FRAMERATE_CHANGED,A=>{this.emit(l.FRAMERATE_CHANGED,A)}),this.runtime.on(l.INTERPOLATION_CHANGED,A=>{this.emit(l.INTERPOLATION_CHANGED,A)}),this.runtime.on(l.BEFORE_INTERPOLATE,A=>{this.emit(l.BEFORE_INTERPOLATE,A)}),this.runtime.on(l.AFTER_INTERPOLATE,A=>{this.emit(l.AFTER_INTERPOLATE,A)}),this.runtime.on(l.STAGE_SIZE_CHANGED,(A,e)=>{this.emit(l.STAGE_SIZE_CHANGED,A,e)}),this.runtime.on(l.COMPILE_ERROR,(A,e)=>{this.emit(l.COMPILE_ERROR,A,e)}),this.runtime.on(l.TURBO_MODE_OFF,()=>{this.emit(l.TURBO_MODE_OFF)}),this.runtime.on(l.TURBO_MODE_ON,()=>{this.emit(l.TURBO_MODE_ON)}),this.extensionManager=new c(this),this.securityManager=this.extensionManager.securityManager,this.runtime.extensionManager=this.extensionManager,this.runtime.vm=this;for(const A of H)this.extensionManager.loadExtensionIdSync(A);this.blockListener=this.blockListener.bind(this),this.flyoutBlockListener=this.flyoutBlockListener.bind(this),this.monitorBlockListener=this.monitorBlockListener.bind(this),this.variableListener=this.variableListener.bind(this),this.addListener("workspaceUpdate",()=>{this.extensionManager.refreshDynamicCategorys()}),this.exports={Sprite:u,RenderedTarget:w,JSZip:B,JSGenerator:x,IRGenerator:T,jsexecute:S,loadCostume:p,loadSound:F,Blocks:I,Comment:M,StageLayering:C,Variable:m,Thread:t(37),execute:t(62),centralDispatch:g},this.exports.i_will_not_ask_for_help_when_these_break=()=>(console.info("Note on i_will_not_ask_for_help_when_these_break: this function is only included for compatibility with TurboWarp, and you should avoid using it when possible.\nAll indexes are able to be accessed from the regular vm.exports property. Below is a map of all elements here to their vm.exports counterpart:\nIRGenerator -> IRGenerator\nJSGenerator -> JSGenerator\nThread -> Thread\nexecute -> execute\nScriptTreeGenerator -> IRGenerator.exports.ScriptTreeGenerator"),{IRGenerator:T,JSGenerator:x,ScriptTreeGenerator:T.exports.ScriptTreeGenerator,Thread:this.exports.Thread,execute:this.exports.execute})}start(){this.runtime.start()}stop(){this.runtime.stop()}greenFlag(){this.runtime.greenFlag()}setTurboMode(A){this.runtime.turboMode=!!A,this.runtime.turboMode?this.emit(l.TURBO_MODE_ON):this.emit(l.TURBO_MODE_OFF)}setCompatibilityMode(A){this.runtime.setCompatibilityMode(!!A)}setFramerate(A){this.runtime.setFramerate(A)}setInterpolation(A){this.runtime.setInterpolation(A)}setRuntimeOptions(A){this.runtime.setRuntimeOptions(A)}setCompilerOptions(A){this.runtime.setCompilerOptions(A)}setStageSize(A,e){this.runtime.setStageSize(A,e)}setInEditor(A){this.runtime.setInEditor(A)}convertToPackagedRuntime(){this.runtime.convertToPackagedRuntime()}addAddonBlock(A){this.runtime.addAddonBlock(A)}getAddonBlock(A){return this.runtime.getAddonBlock(A)}storeProjectOptions(){this.runtime.storeProjectOptions(),this.editingTarget.isStage&&this.emitWorkspaceUpdate()}enableDebug(){return this.runtime.enableDebug(),"enabled debug mode"}stopAll(){this.runtime.stopAll()}clear(){this.runtime.dispose(),this.editingTarget=null,this.emitTargetsUpdate(!1)}getPlaygroundData(){const A=this,e=this.runtime.threads.filter(e=>e.target===A.editingTarget),t=JSON.stringify(e,(A,e)=>{if("target"!==A&&"blockContainer"!==A)return e},2);this.emit("playgroundData",{blocks:this.editingTarget.blocks,threads:t})}postIOData(A,e){this.runtime.ioDevices[A]&&this.runtime.ioDevices[A].postData(e)}setVideoProvider(A){this.runtime.ioDevices.video.setProvider(A)}setCloudProvider(A){this.runtime.ioDevices.cloud.setProvider(A)}scanForPeripheral(A){this.runtime.scanForPeripheral(A)}connectPeripheral(A,e){this.runtime.connectPeripheral(A,e)}disconnectPeripheral(A){this.runtime.disconnectPeripheral(A)}getPeripheralIsConnected(A){return this.runtime.getPeripheralIsConnected(A)}isSB2(A){return Array.isArray(A.children)&&!Array.isArray(A.targets)}loadProject(A){return new Promise(async(e,i)=>{try{const n=[...new Uint8Array(A).slice(0,7)].map(A=>String.fromCharCode(A)).join("");if("Scratch"===n){const{SB1File:i}=t(500),n=new i(A),r=n.json;return r.projectVersion=2,e([r,n.zip])}if("string"==typeof A&&(A=JSON.parse(A)),"[object Object]"===A.toString())return A.projectVersion=this.isSB2(A)?2:3,e([A,null]);if("PK"!==n.slice(0,2)){const t=new TextDecoder("UTF-8");if("string"==typeof(A=t.decode(A))&&(A=JSON.parse(A)),"[object Object]"===A.toString())return A.projectVersion=this.isSB2(A)?2:3,e([A,null])}const r=await B.loadAsync(A),o=r.file("project.json");if(!o)return i("No project.json file inside the given project");const s=JSON.parse(await o.async("string"));return s.projectVersion=this.isSB2(s)?2:3,this._projectZip=r,e([s,r])}catch(A){i(A.toString())}}).then(A=>this.deserializeProject(A[0],A[1])).then(()=>this.runtime.emitProjectLoaded()).catch(A=>(console.error(A),A.hasOwnProperty("validationError")?Promise.reject(JSON.stringify(A,null,4)):Promise.reject(A)))}downloadProjectId(A){const e=this.runtime.storage;if(!e)return void Q.error("No storage module present; cannot load project: ",A);const t=this;e.load(e.AssetType.Project,A).then(e=>e?t.loadProject(e.data):(Q.error("Failed to fetch project with id: ".concat(A)),null))}_saveProjectZip(){const A=this.toJSON(),e=new B;if(e.file("project.json",A),this._addFileDescsToZip(this.serializeAssets(),e),this._projectZip)try{e.files=n(n({},e.files),Object.fromEntries(Object.entries(this._projectZip.files).filter(A=>A[0].startsWith("extraAssets/"))))}catch(A){console.warn("unable to get extra assets",A)}const t=new Date(1591657163e3);for(const A of Object.values(e.files))A.date=t;const i=[".json",".svg",".wav",".ttf",".otf"];for(const A of Object.values(e.files))i.some(e=>A.name.endsWith(e))?A.options.compression="DEFLATE":A.options.compression="STORE";return e}saveProjectSb3(A){return this._saveProjectZip().generateAsync({type:A||"blob",mimeType:"application/x.scratch.sb3",compression:"DEFLATE"})}saveProjectSb3Stream(A){return this._saveProjectZip().generateInternalStream({type:A||"arraybuffer",mimeType:"application/x.scratch.sb3",compression:"DEFLATE"})}saveProjectSb3DontZip(){const A=this.toJSON(),e={"project.json":(new o).encode(A)};for(const A of this.serializeAssets())e[A.fileName]=A.fileContent;return e}get assets(){return[...this.runtime.targets.reduce((A,e)=>A.concat(e.sprite.sounds.map(A=>A.asset)).concat(e.sprite.costumes.map(A=>A.asset)),[]),...this.runtime.fontManager.serializeAssets()]}serializeAssets(A){return[...f(this.runtime,A),...U(this.runtime,A),...this.runtime.fontManager.serializeAssets().map(A=>({fileName:"".concat(A.assetId,".").concat(A.dataFormat),fileContent:A.data}))]}_addFileDescsToZip(A,e){for(let t=0;t{let{targets:e,extensions:t}=A;if("undefined"!=typeof performance){performance.mark("scratch-vm-deserialize-end");try{performance.measure("scratch-vm-deserialize","scratch-vm-deserialize-start","scratch-vm-deserialize-end")}catch(A){Q.error(A)}}return this.installTargets(e,t,!0)})}async _loadExtensions(A){let e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:new Map;const t=[];for(const i of A){const A=e.get(i);if(this.extensionManager.isExtensionLoaded(i));else if(A){if(!await this.securityManager.canLoadExtensionFromProject(A))throw new Error("Permission to load extension denied: ".concat(i));t.push(this.extensionManager.loadExtensionURL(A))}else{if(!this.extensionManager.isBuiltinExtension(i))throw new Error("Unknown extension: ".concat(i));this.extensionManager.loadExtensionIdSync(i)}}return Promise.all(t)}async installTargets(A,e,t){return await this.extensionManager.allAsyncExtensionsLoaded(),A=A.filter(A=>!!A),this._loadExtensions(e.extensionIDs,e.extensionURLs).then(()=>{const i={};for(const A of e.extensionIDs)e.extensionData[A]&&("ext_".concat(A)in this.runtime&&"function"==typeof this.runtime["ext_".concat(A)].deserialize?this.runtime["ext_".concat(A)].deserialize(e.extensionData[A]):i[A]=e.extensionData[A]);i&&(this.runtime.extensionStorage=D(i)),A.forEach(A=>{if(this.runtime.addTarget(A),A.updateAllDrawableProperties(),A.isSprite()&&this.renameSprite(A.id,A.getName()),!("extensionData"in A))return;const t={};for(const i of e.extensionIDs)i in A.extensionData&&("ext_".concat(i)in this.runtime&&"function"==typeof this.runtime["ext_".concat(i)].deserializeForTarget?this.runtime["ext_".concat(i)].deserializeForTarget(A.extensionData[i],A):t[i]=A.extensionData[i]);i&&(A.extensionStorage=D(t)),delete A.extensionData}),this.runtime.executableTargets.sort((A,e)=>A.layerOrder-e.layerOrder),A.forEach(A=>{delete A.layerOrder}),t&&A.length>1?this.editingTarget=A[1]:this.editingTarget=A[0],t||this.editingTarget.fixUpVariableReferences(),t&&this.runtime.parseProjectOptions(),this.emitTargetsUpdate(!1),this.emitWorkspaceUpdate(),this.runtime.setEditingTarget(this.editingTarget),this.runtime.ioDevices.cloud.setStage(this.runtime.getTargetForStage())})}addSprite(A){"object"!=typeof A||A instanceof ArrayBuffer||ArrayBuffer.isView(A)||(A=JSON.stringify(A));return new Promise((e,i)=>{t(447)(A,!0,(A,t)=>{if(A)return i(A);e(t)})}).then(A=>{const e=A[0].projectVersion;return 2===e?this._addSprite2(A[0],A[1]):3===e?this._addSprite3(A[0],A[1]):Promise.reject("".concat("Sprite Upload Error:"," Unable to verify sprite version."))}).then(()=>this.runtime.emitProjectChanged()).catch(A=>A.hasOwnProperty("validationError")?Promise.reject(JSON.stringify(A)):Promise.reject("".concat("Sprite Upload Error:"," ").concat(A)))}_addSprite2(A,e){return t(112).deserialize(A,this.runtime,!0,e).then(A=>{let{targets:e,extensions:t}=A;return this.installTargets(e,t,!1)})}_addSprite3(A,e){return t(39).deserialize(A,this.runtime,e,!0).then(A=>{let{targets:e,extensions:t}=A;return this.installTargets(e,t,!1)})}addCostume(A,e,t,i){const n=t?this.runtime.getTargetById(t):this.editingTarget;return n?!0===e.fromPenguinModLibrary?new Promise((A,t)=>{fetch("".concat(G,"files/").concat(e.libraryId)).then(A=>A.arrayBuffer()).then(t=>{const r=e.dataFormat,o=this.runtime.storage,s=new o.Asset(o.AssetType["svg"===r?"ImageVector":"ImageBitmap"],null,o.DataFormat[r.toUpperCase()],new Uint8Array(t),!0),B={md5:s.assetId+"."+s.dataFormat,asset:s,name:e.name};p(B.md5,B,this.runtime,i).then(e=>{n.addCostume(B),n.setCostume(n.getCostumes().length-1),this.runtime.emitProjectChanged(),A(e,B)})}).catch(t)}):p(A,e,this.runtime,i).then(A=>{n.addCostume(A),n.setCostume(n.getCostumes().length-1),this.runtime.emitProjectChanged()}):Promise.reject()}addCostumeFromLibrary(A,e){return this.editingTarget?this.addCostume(A,e,this.editingTarget.id,2):Promise.reject()}duplicateCostume(A){const e=this.editingTarget.getCostumes()[A],t=Object.assign({},e),i="".concat(t.assetId,".").concat(t.dataFormat);return p(i,t,this.runtime).then(()=>{this.editingTarget.addCostume(t,A+1),this.editingTarget.setCostume(A+1),this.emitTargetsUpdate()})}duplicateSound(A){const e=this.editingTarget.getSounds()[A],t=Object.assign({},e);return F(t,this.runtime,this.editingTarget.sprite.soundBank).then(()=>{this.editingTarget.addSound(t,A+1),this.emitTargetsUpdate()})}renameCostume(A,e){this.editingTarget.renameCostume(A,e),this.emitTargetsUpdate()}deleteCostume(A){const e=this.editingTarget.deleteCostume(A);if(e){const A=this.editingTarget;return this.runtime.emitProjectChanged(),()=>{A.addCostume(e),this.emitTargetsUpdate()}}return null}pause(){this.runtime.pause()}play(){this.runtime.play()}addSound(A,e){const t=e?this.runtime.getTargetById(e):this.editingTarget;return t?!0===A.fromPenguinModLibrary?new Promise((e,i)=>{fetch("".concat(G,"files/").concat(A.libraryId)).then(A=>A.arrayBuffer()).then(i=>{const n=this.runtime.storage,r=new n.Asset(n.AssetType.Sound,null,n.DataFormat.MP3,new Uint8Array(i),!0),o={md5:r.assetId+"."+r.dataFormat,asset:r,name:A.name};F(o,this.runtime,t.sprite.soundBank).then(A=>{t.addSound(o),this.emitTargetsUpdate(),e(A,o)})}).catch(i)}):F(A,this.runtime,t.sprite.soundBank).then(()=>{t.addSound(A),this.emitTargetsUpdate()}):Promise.reject(new Error("No target with ID: ".concat(e)))}renameSound(A,e){this.editingTarget.renameSound(A,e),this.emitTargetsUpdate()}getSoundBuffer(A){var e;const t=null===(e=this.editingTarget.sprite.sounds[A])||void 0===e?void 0:e.soundId;return t&&this.runtime&&this.runtime.audioEngine?this.editingTarget.sprite.soundBank.getSoundPlayer(t).buffer:null}updateSoundBuffer(A,e,t){const i=this.editingTarget.sprite.sounds[A];i&&i.broken&&delete i.broken;const n=i?i.soundId:null;if(n&&this.runtime&&this.runtime.audioEngine&&(this.editingTarget.sprite.soundBank.getSoundPlayer(n).buffer=e),t){i.format="";const A=this.runtime.storage;i.asset=A.createAsset(A.AssetType.Sound,A.DataFormat.WAV,t,null,!0),i.assetId=i.asset.assetId,i.dataFormat=A.DataFormat.WAV,i.md5="".concat(i.assetId,".").concat(i.dataFormat),i.sampleCount=e.length,i.rate=e.sampleRate}this.emitTargetsUpdate()}deleteSound(A){const e=this.editingTarget,t=this.editingTarget.deleteSound(A);if(t){this.runtime.emitProjectChanged();return()=>{e.addSound(t),this.emitTargetsUpdate()}}return null}getCostume(A){const e=this.editingTarget.getCostumes()[A].asset;if(!e||!this.runtime||!this.runtime.storage)return null;const t=e.dataFormat;return t===this.runtime.storage.DataFormat.SVG?e.decodeText():t===this.runtime.storage.DataFormat.PNG||t===this.runtime.storage.DataFormat.JPG?e.encodeDataURI():(Q.error("Unhandled format: ".concat(e.dataFormat)),null)}getExportedCostume(A,e){return N(A,e)}getExportedCostumeBase64(A,e){const t=this.getExportedCostume(A,e);return y.uint8ArrayToBase64(t)}updateBitmap(A,e,t,i,n){return this._updateBitmap(this.editingTarget.getCostumes()[A],e,t,i,n)}_updateBitmap(A,e,t,i,n){if(!(A&&this.runtime&&this.runtime.renderer))return;A&&A.broken&&delete A.broken,A.rotationCenterX=t,A.rotationCenterY=i;const r=0===e.sourceWidth?0:e.width,o=0===e.sourceHeight?0:e.height,s=document.createElement("canvas");s.width=r,s.height=o;s.getContext("2d").putImageData(e,0,0),this.runtime.renderer.updateBitmapSkin(A.skinId,s,n,[t/n,i/n]),s.toBlob(e=>{const t=new FileReader;t.addEventListener("loadend",()=>{const e=this.runtime.storage;A.dataFormat=e.DataFormat.PNG,A.bitmapResolution=n,A.size=[r,o],A.asset=e.createAsset(e.AssetType.ImageBitmap,A.dataFormat,a.from(t.result),null,!0),A.assetId=A.asset.assetId,A.md5="".concat(A.assetId,".").concat(A.dataFormat),this.emitTargetsUpdate()}),e&&t.readAsArrayBuffer(e)})}updateSvg(A,e,t,i){return this._updateSvg(this.editingTarget.getCostumes()[A],e,t,i)}_updateSvg(A,e,t,i){A&&A.broken&&delete A.broken,A&&this.runtime&&this.runtime.renderer&&(A.rotationCenterX=t,A.rotationCenterY=i,this.runtime.renderer.updateSVGSkin(A.skinId,e,[t,i]),A.size=this.runtime.renderer.getSkinSize(A.skinId));const n=this.runtime.storage;A.dataFormat=n.DataFormat.SVG,A.bitmapResolution=1,A.asset=n.createAsset(n.AssetType.ImageVector,A.dataFormat,(new o).encode(e),null,!0),A.assetId=A.asset.assetId,A.md5="".concat(A.assetId,".").concat(A.dataFormat),this.emitTargetsUpdate()}addBackdrop(A,e){return!0===e.fromPenguinModLibrary?new Promise((A,t)=>{fetch("".concat(G,"files/").concat(e.libraryId)).then(A=>A.arrayBuffer()).then(t=>{const i=e.dataFormat,n=this.runtime.storage,r=new n.Asset(n.AssetType["svg"===i?"ImageVector":"ImageBitmap"],null,n.DataFormat[i.toUpperCase()],new Uint8Array(t),!0),o={md5:r.assetId+"."+r.dataFormat,asset:r,name:e.name};p(o.md5,o,this.runtime).then(e=>{const t=this.runtime.getTargetForStage();t.addCostume(o),t.setCostume(t.getCostumes().length-1),this.runtime.emitProjectChanged(),A(e,o)})}).catch(t)}):p(A,e,this.runtime).then(()=>{const A=this.runtime.getTargetForStage();A.addCostume(e),A.setCostume(A.getCostumes().length-1),this.runtime.emitProjectChanged()})}renameSprite(A,e){const t=this.runtime.getTargetById(A);if(!t)throw new Error("No target with the provided id.");{if(!t.isSprite())throw new Error("Cannot rename non-sprite targets.");const A=t.sprite;if(!A)throw new Error("No sprite associated with this target.");if(e&&-1===R.indexOf(e)){const i=this.runtime.targets.filter(A=>A.isSprite()&&A.id!==t.id).map(A=>A.sprite.name),n=A.name,r=h.unusedName(e,i);if(A.name=r,n===r)return;const o=this.runtime.targets;for(let A=0;AA.id).indexOf(e.id);if(!e.isSprite())throw new Error("Cannot delete non-sprite targets.");const i=e.sprite;if(!i)throw new Error("No sprite associated with this target.");const n=this.exportSprite(A,"uint8array"),r=()=>n.then(A=>this.addSprite(A));e.deleteMonitors();const o=this.editingTarget;for(let A=0;A0?this.setEditingTarget(this.runtime.targets[A].id):this.editingTarget=null}}return this.emitTargetsUpdate(),r}throw new Error("No target with the provided id.")}deleteSpriteInternal(A){const e=this.runtime.getTargetById(A);if(e){const t=this.runtime.targets.map(A=>A.id).indexOf(e.id);if(!e.isSprite())throw new Error("Cannot delete non-sprite targets.");const i=e.sprite;if(!i)throw new Error("No sprite associated with this target.");const n=this.exportSprite(A,"uint8array"),r=()=>n.then(A=>this.addSprite(A));e.deleteMonitors();const o=this.editingTarget;for(let A=0;A0?this.setEditingTarget(this.runtime.targets[A].id):this.editingTarget=null}}return this.emitTargetsUpdate(),r}throw new Error("No target with the provided id.")}duplicateSprite(A){const e=this.runtime.getTargetById(A);if(!e)throw new Error("No target with the provided id.");if(!e.isSprite())throw new Error("Cannot duplicate non-sprite targets.");if(!e.sprite)throw new Error("No sprite associated with this target.");return e.duplicate().then(A=>{this.runtime.addTarget(A),A.goBehindOther(e),this.setEditingTarget(A.id)})}attachAudioEngine(A){this.runtime.attachAudioEngine(A)}attachRenderer(A){this.runtime.attachRenderer(A)}get renderer(){return this.runtime&&this.runtime.renderer}attachV2SVGAdapter(){}attachV2BitmapAdapter(A){this.runtime.attachV2BitmapAdapter(A)}attachStorage(A){this.runtime.attachStorage(A)}setLocale(A,e){return A!==d.setup().locale&&d.setup({locale:A,translations:{[A]:e}}),this.emit("LOCALE_CHANGED",A),this.extensionManager.refreshBlocks()}getLocale(){return d.setup().locale}blockListener(A){this.editingTarget&&this.editingTarget.blocks.blocklyListen(A)}flyoutBlockListener(A){this.runtime.flyoutBlocks.blocklyListen(A)}monitorBlockListener(A){-1!==["create","change"].indexOf(A.type)&&this.runtime.monitorBlocks.blocklyListen(A)}variableListener(A){-1!==["var_create","var_rename","var_delete"].indexOf(A.type)&&this.runtime.getTargetForStage().blocks.blocklyListen(A)}setEditingTarget(A){if(this.editingTarget&&A===this.editingTarget.id)return;const e=this.runtime.getTargetById(A);e&&(this.editingTarget=e,this.emitTargetsUpdate(!1),this.emitWorkspaceUpdate(),this.runtime.setEditingTarget(e))}exportStandaloneBlocks(A){return t(39).serializeStandaloneBlocks(A,this.runtime)}shareBlocksToTarget(A,e,i){const n=t(39),{blocks:r,extensionURLs:o}=n.deserializeStandaloneBlocks(A);Y(r);const s=this.runtime.getTargetById(e);if(i){this.runtime.getTargetById(i).resolveVariableSharingConflictsWithTarget(r,s)}const B=new Set(r.map(A=>n.getExtensionIdForOpcode(A.opcode)).filter(A=>!!A).filter(A=>!this.extensionManager.isExtensionLoaded(A)));return this._loadExtensions(B,o).then(()=>{r.forEach(A=>{s.blocks.createBlock(A)}),s.blocks.updateTargetSpecificBlocks(s.isStage)})}shareCostumeToTarget(A,e){const t=this.editingTarget.getCostumes()[A],i=Object.assign({},t),n="".concat(i.assetId,".").concat(i.dataFormat);return p(n,i,this.runtime).then(()=>{const A=this.runtime.getTargetById(e);A&&(A.addCostume(i),A.setCostume(A.getCostumes().length-1))})}shareSoundToTarget(A,e){const t=this.editingTarget.getSounds()[A],i=Object.assign({},t),n=this.runtime.getTargetById(e);return F(i,this.runtime,n.sprite.soundBank).then(()=>{n&&(n.addSound(i),this.emitTargetsUpdate())})}refreshWorkspace(){this.editingTarget&&(this.emitWorkspaceUpdate(),this.runtime.setEditingTarget(this.editingTarget),this.emitTargetsUpdate(!1))}emitTargetsUpdate(A){let e;void 0===A&&(A=!0);const t=()=>(e||(e=this.runtime.targets.filter(A=>!A.hasOwnProperty("isOriginal")||A.isOriginal).map(A=>A.toJSON())),e);this.emit("targetsUpdate",{get targetList(){return t()},editingTarget:this.editingTarget?this.editingTarget.id:null}),A&&this.runtime.emitProjectChanged()}emitWorkspaceUpdate(){const A=this.runtime.getTargetForStage().variables;let e=[];for(const t in A)A[t].type===m.BROADCAST_MESSAGE_TYPE&&e.push(t);for(let A=0;At[A]),r=Object.keys(i).map(A=>i[A]),o=Object.keys(this.editingTarget.comments).map(A=>this.editingTarget.comments[A]).filter(A=>null===A.blockId),s='\n \n '.concat(n.map(A=>A.toXML()).join(),"\n ").concat(r.map(A=>A.toXML(!0)).join(),"\n \n ").concat(o.map(A=>A.toXML()).join(),"\n ").concat(this.editingTarget.blocks.toXML(this.editingTarget.comments),"\n ");this.emit("workspaceUpdate",{xml:s})}getTargetIdForDrawableId(A){const e=this.runtime.getTargetByDrawableId(A);return e&&e.hasOwnProperty("id")&&e.hasOwnProperty("isStage")&&!e.isStage?e.id:null}reorderTarget(A,e){let t=this.runtime.targets;if((A=E.clamp(A,0,t.length-1))===(e=E.clamp(e,0,t.length-1)))return!1;const i=t[A];return t=t.slice(0,A).concat(t.slice(A+1)),t.splice(e,0,i),this.runtime.targets=t,this.emitTargetsUpdate(),!0}reorderCostume(A,e,t){const i=this.runtime.getTargetById(A);if(i){const A=i.reorderCostume(e,t);return A&&this.runtime.emitProjectChanged(),A}return!1}reorderSound(A,e,t){const i=this.runtime.getTargetById(A);if(i){const A=i.reorderSound(e,t);return A&&this.runtime.emitProjectChanged(),A}return!1}startDrag(A){const e=this.runtime.getTargetById(A);e&&(this._dragTarget=e,e.startDrag())}stopDrag(A){const e=this.runtime.getTargetById(A);e&&(this._dragTarget=null,e.stopDrag(),this.setEditingTarget(e.sprite&&e.sprite.clones[0]?e.sprite.clones[0].id:e.id))}postSpriteInfo(A){this._dragTarget?this._dragTarget.postSpriteInfo(A):this.editingTarget.postSpriteInfo(A),this.runtime.emitProjectChanged()}setVariableValue(A,e,t){const i=this.runtime.getTargetById(A);if(i){const A=i.lookupVariableById(e);if(A)return A.value=t,A.isCloud&&this.runtime.ioDevices.cloud.requestUpdateVariable(A.name,A.value),!0}return!1}getVariableValue(A,e){const t=this.runtime.getTargetById(A);if(t){const A=t.lookupVariableById(e);if(A)return A.value}return null}configureScratchLinkSocketFactory(A){this.runtime.configureScratchLinkSocketFactory(A)}}},function(A,e,t){"use strict";e.byteLength=function(A){var e=a(A),t=e[0],i=e[1];return 3*(t+i)/4-i},e.toByteArray=function(A){var e,t,i=a(A),o=i[0],s=i[1],B=new r(function(A,e,t){return 3*(e+t)/4-t}(0,o,s)),g=0,c=s>0?o-4:o;for(t=0;t>16&255,B[g++]=e>>8&255,B[g++]=255&e;2===s&&(e=n[A.charCodeAt(t)]<<2|n[A.charCodeAt(t+1)]>>4,B[g++]=255&e);1===s&&(e=n[A.charCodeAt(t)]<<10|n[A.charCodeAt(t+1)]<<4|n[A.charCodeAt(t+2)]>>2,B[g++]=e>>8&255,B[g++]=255&e);return B},e.fromByteArray=function(A){for(var e,t=A.length,n=t%3,r=[],o=0,s=t-n;os?s:o+16383));1===n?(e=A[t-1],r.push(i[e>>2]+i[e<<4&63]+"==")):2===n&&(e=(A[t-2]<<8)+A[t-1],r.push(i[e>>10]+i[e>>4&63]+i[e<<2&63]+"="));return r.join("")};for(var i=[],n=[],r="undefined"!=typeof Uint8Array?Uint8Array:Array,o="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",s=0,B=o.length;s0)throw new Error("Invalid string. Length must be a multiple of 4");var t=A.indexOf("=");return-1===t&&(t=e),[t,t===e?0:4-t%4]}function g(A,e,t){for(var n,r,o=[],s=e;s>18&63]+i[r>>12&63]+i[r>>6&63]+i[63&r]);return o.join("")}n["-".charCodeAt(0)]=62,n["_".charCodeAt(0)]=63},function(A,e){ +A.exports=function(){"use strict";function A(e){return(A="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(A){return typeof A}:function(A){return A&&"function"==typeof Symbol&&A.constructor===Symbol&&A!==Symbol.prototype?"symbol":typeof A})(e)}function e(A,t){return(e=Object.setPrototypeOf||function(A,e){return A.__proto__=e,A})(A,t)}function t(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(A){return!1}}function i(A,n,r){return(i=t()?Reflect.construct:function(A,t,i){var n=[null];n.push.apply(n,t);var r=new(Function.bind.apply(A,n));return i&&e(r,i.prototype),r}).apply(null,arguments)}function n(A){return function(A){if(Array.isArray(A))return r(A)}(A)||function(A){if("undefined"!=typeof Symbol&&null!=A[Symbol.iterator]||null!=A["@@iterator"])return Array.from(A)}(A)||function(A,e){if(A){if("string"==typeof A)return r(A,e);var t=Object.prototype.toString.call(A).slice(8,-1);return"Object"===t&&A.constructor&&(t=A.constructor.name),"Map"===t||"Set"===t?Array.from(A):"Arguments"===t||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t)?r(A,e):void 0}}(A)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function r(A,e){(null==e||e>A.length)&&(e=A.length);for(var t=0,i=new Array(e);t1?t-1:0),n=1;n/gm),W=E(/\${[\w\W]*}/gm),P=E(/^data-[\-\w.\u00B7-\uFFFF]+$/),K=E(/^aria-[\-\w]+$/),Z=E(/^(?:(?:(?:f|ht)tps?|mailto|tel|callto|cid|xmpp):|[^a-z]|[a-z+.\-]+(?:[^a-z+.\-:]|$))/i),X=E(/^(?:\w+script|data):/i),q=E(/[\u0000-\u0020\u00A0\u1680\u180E\u2000-\u2029\u205F\u3000]/g),_=E(/^html$/i),$=E(/^[a-z][.\w]*(-[.\w]+)+$/i),AA=function(){return"undefined"==typeof window?null:window},eA=function(e,t){if("object"!==A(e)||"function"!=typeof e.createPolicy)return null;var i=null;t.currentScript&&t.currentScript.hasAttribute("data-tt-policy-suffix")&&(i=t.currentScript.getAttribute("data-tt-policy-suffix"));var n="dompurify"+(i?"#"+i:"");try{return e.createPolicy(n,{createHTML:function(A){return A},createScriptURL:function(A){return A}})}catch(A){return console.warn("TrustedTypes policy "+n+" could not be created."),null}};return function e(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:AA(),i=function(A){return e(A)};if(i.version="2.5.8",i.removed=[],!t||!t.document||9!==t.document.nodeType)return i.isSupported=!1,i;var r=t.document,o=t.document,s=t.DocumentFragment,B=t.HTMLTemplateElement,a=t.Node,g=t.Element,E=t.NodeFilter,Q=t.NamedNodeMap,l=void 0===Q?t.NamedNodeMap||t.MozNamedAttrMap:Q,h=t.HTMLFormElement,w=t.DOMParser,u=t.trustedTypes,N=g.prototype,tA=G(N,"cloneNode"),iA=G(N,"nextSibling"),nA=G(N,"childNodes"),rA=G(N,"parentNode");if("function"==typeof B){var oA=o.createElement("template");oA.content&&oA.content.ownerDocument&&(o=oA.content.ownerDocument)}var sA=eA(u,r),BA=sA?sA.createHTML(""):"",aA=o,gA=aA.implementation,cA=aA.createNodeIterator,EA=aA.createDocumentFragment,QA=aA.getElementsByTagName,lA=r.importNode,hA={};try{hA=R(o).documentMode?o.documentMode:{}}catch(A){}var wA={};i.isSupported="function"==typeof rA&&gA&&void 0!==gA.createHTMLDocument&&9!==hA;var uA,CA,IA=L,MA=O,dA=W,DA=P,mA=K,YA=X,pA=q,FA=$,UA=Z,fA=null,NA=y({},[].concat(n(T),n(x),n(S),n(H),n(b))),yA=null,RA=y({},[].concat(n(j),n(v),n(z),n(V))),GA=Object.seal(Object.create(null,{tagNameCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},attributeNameCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},allowCustomizedBuiltInElements:{writable:!0,configurable:!1,enumerable:!0,value:!1}})),TA=null,xA=null,SA=!0,kA=!0,HA=!1,JA=!0,bA=!1,jA=!0,vA=!1,zA=!1,VA=!1,LA=!1,OA=!1,WA=!1,PA=!0,KA=!1,ZA="user-content-",XA=!0,qA=!1,_A={},$A=null,Ae=y({},["annotation-xml","audio","colgroup","desc","foreignobject","head","iframe","math","mi","mn","mo","ms","mtext","noembed","noframes","noscript","plaintext","script","style","svg","template","thead","title","video","xmp"]),ee=null,te=y({},["audio","video","img","source","image","track"]),ie=null,ne=y({},["alt","class","for","id","label","name","pattern","placeholder","role","summary","title","value","style","xmlns"]),re="http://www.w3.org/1998/Math/MathML",oe="http://www.w3.org/2000/svg",se="http://www.w3.org/1999/xhtml",Be=se,ae=!1,ge=null,ce=y({},[re,oe,se],D),Ee=["application/xhtml+xml","text/html"],Qe="text/html",le=null,he=o.createElement("form"),we=function(A){return A instanceof RegExp||A instanceof Function},ue=function(e){le&&le===e||(e&&"object"===A(e)||(e={}),e=R(e),uA=uA=-1===Ee.indexOf(e.PARSER_MEDIA_TYPE)?Qe:e.PARSER_MEDIA_TYPE,CA="application/xhtml+xml"===uA?D:d,fA="ALLOWED_TAGS"in e?y({},e.ALLOWED_TAGS,CA):NA,yA="ALLOWED_ATTR"in e?y({},e.ALLOWED_ATTR,CA):RA,ge="ALLOWED_NAMESPACES"in e?y({},e.ALLOWED_NAMESPACES,D):ce,ie="ADD_URI_SAFE_ATTR"in e?y(R(ne),e.ADD_URI_SAFE_ATTR,CA):ne,ee="ADD_DATA_URI_TAGS"in e?y(R(te),e.ADD_DATA_URI_TAGS,CA):te,$A="FORBID_CONTENTS"in e?y({},e.FORBID_CONTENTS,CA):Ae,TA="FORBID_TAGS"in e?y({},e.FORBID_TAGS,CA):{},xA="FORBID_ATTR"in e?y({},e.FORBID_ATTR,CA):{},_A="USE_PROFILES"in e&&e.USE_PROFILES,SA=!1!==e.ALLOW_ARIA_ATTR,kA=!1!==e.ALLOW_DATA_ATTR,HA=e.ALLOW_UNKNOWN_PROTOCOLS||!1,JA=!1!==e.ALLOW_SELF_CLOSE_IN_ATTR,bA=e.SAFE_FOR_TEMPLATES||!1,jA=!1!==e.SAFE_FOR_XML,vA=e.WHOLE_DOCUMENT||!1,LA=e.RETURN_DOM||!1,OA=e.RETURN_DOM_FRAGMENT||!1,WA=e.RETURN_TRUSTED_TYPE||!1,VA=e.FORCE_BODY||!1,PA=!1!==e.SANITIZE_DOM,KA=e.SANITIZE_NAMED_PROPS||!1,XA=!1!==e.KEEP_CONTENT,qA=e.IN_PLACE||!1,UA=e.ALLOWED_URI_REGEXP||UA,Be=e.NAMESPACE||se,GA=e.CUSTOM_ELEMENT_HANDLING||{},e.CUSTOM_ELEMENT_HANDLING&&we(e.CUSTOM_ELEMENT_HANDLING.tagNameCheck)&&(GA.tagNameCheck=e.CUSTOM_ELEMENT_HANDLING.tagNameCheck),e.CUSTOM_ELEMENT_HANDLING&&we(e.CUSTOM_ELEMENT_HANDLING.attributeNameCheck)&&(GA.attributeNameCheck=e.CUSTOM_ELEMENT_HANDLING.attributeNameCheck),e.CUSTOM_ELEMENT_HANDLING&&"boolean"==typeof e.CUSTOM_ELEMENT_HANDLING.allowCustomizedBuiltInElements&&(GA.allowCustomizedBuiltInElements=e.CUSTOM_ELEMENT_HANDLING.allowCustomizedBuiltInElements),bA&&(kA=!1),OA&&(LA=!0),_A&&(fA=y({},n(b)),yA=[],!0===_A.html&&(y(fA,T),y(yA,j)),!0===_A.svg&&(y(fA,x),y(yA,v),y(yA,V)),!0===_A.svgFilters&&(y(fA,S),y(yA,v),y(yA,V)),!0===_A.mathMl&&(y(fA,H),y(yA,z),y(yA,V))),e.ADD_TAGS&&(fA===NA&&(fA=R(fA)),y(fA,e.ADD_TAGS,CA)),e.ADD_ATTR&&(yA===RA&&(yA=R(yA)),y(yA,e.ADD_ATTR,CA)),e.ADD_URI_SAFE_ATTR&&y(ie,e.ADD_URI_SAFE_ATTR,CA),e.FORBID_CONTENTS&&($A===Ae&&($A=R($A)),y($A,e.FORBID_CONTENTS,CA)),XA&&(fA["#text"]=!0),vA&&y(fA,["html","head","body"]),fA.table&&(y(fA,["tbody"]),delete TA.tbody),c&&c(e),le=e)},Ce=y({},["mi","mo","mn","ms","mtext"]),Ie=y({},["annotation-xml"]),Me=y({},["title","style","font","a","script"]),de=y({},x);y(de,S),y(de,k);var De=y({},H);y(De,J);var me=function(A){var e=rA(A);e&&e.tagName||(e={namespaceURI:Be,tagName:"template"});var t=d(A.tagName),i=d(e.tagName);return!!ge[A.namespaceURI]&&(A.namespaceURI===oe?e.namespaceURI===se?"svg"===t:e.namespaceURI===re?"svg"===t&&("annotation-xml"===i||Ce[i]):Boolean(de[t]):A.namespaceURI===re?e.namespaceURI===se?"math"===t:e.namespaceURI===oe?"math"===t&&Ie[i]:Boolean(De[t]):A.namespaceURI===se?!(e.namespaceURI===oe&&!Ie[i])&&!(e.namespaceURI===re&&!Ce[i])&&!De[t]&&(Me[t]||!de[t]):!("application/xhtml+xml"!==uA||!ge[A.namespaceURI]))},Ye=function(A){M(i.removed,{element:A});try{A.parentNode.removeChild(A)}catch(e){try{A.outerHTML=BA}catch(e){A.remove()}}},pe=function(A,e){try{M(i.removed,{attribute:e.getAttributeNode(A),from:e})}catch(A){M(i.removed,{attribute:null,from:e})}if(e.removeAttribute(A),"is"===A&&!yA[A])if(LA||OA)try{Ye(e)}catch(A){}else try{e.setAttribute(A,"")}catch(A){}},Fe=function(A){var e,t;if(VA)A=""+A;else{var i=m(A,/^[\r\n\t ]+/);t=i&&i[0]}"application/xhtml+xml"===uA&&Be===se&&(A=''+A+"");var n=sA?sA.createHTML(A):A;if(Be===se)try{e=(new w).parseFromString(n,uA)}catch(A){}if(!e||!e.documentElement){e=gA.createDocument(Be,"template",null);try{e.documentElement.innerHTML=ae?BA:n}catch(A){}}var r=e.body||e.documentElement;return A&&t&&r.insertBefore(o.createTextNode(t),r.childNodes[0]||null),Be===se?QA.call(e,vA?"html":"body")[0]:vA?e.documentElement:r},Ue=function(A){return cA.call(A.ownerDocument||A,A,E.SHOW_ELEMENT|E.SHOW_COMMENT|E.SHOW_TEXT|E.SHOW_PROCESSING_INSTRUCTION|E.SHOW_CDATA_SECTION,null,!1)},fe=function(A){return A instanceof h&&("string"!=typeof A.nodeName||"string"!=typeof A.textContent||"function"!=typeof A.removeChild||!(A.attributes instanceof l)||"function"!=typeof A.removeAttribute||"function"!=typeof A.setAttribute||"string"!=typeof A.namespaceURI||"function"!=typeof A.insertBefore||"function"!=typeof A.hasChildNodes)},Ne=function(e){return"object"===A(a)?e instanceof a:e&&"object"===A(e)&&"number"==typeof e.nodeType&&"string"==typeof e.nodeName},ye=function(A,e,t){wA[A]&&C(wA[A],(function(A){A.call(i,e,t,le)}))},Re=function(A){var e;if(ye("beforeSanitizeElements",A,null),fe(A))return Ye(A),!0;if(U(/[\u0080-\uFFFF]/,A.nodeName))return Ye(A),!0;var t=CA(A.nodeName);if(ye("uponSanitizeElement",A,{tagName:t,allowedTags:fA}),A.hasChildNodes()&&!Ne(A.firstElementChild)&&(!Ne(A.content)||!Ne(A.content.firstElementChild))&&U(/<[/\w]/g,A.innerHTML)&&U(/<[/\w]/g,A.textContent))return Ye(A),!0;if("select"===t&&U(/