diff --git a/dist/app.min.js b/dist/app.min.js index 98877105de..a2015b46eb 100644 --- a/dist/app.min.js +++ b/dist/app.min.js @@ -1,77 +1,24 @@ /* @source http://purl.eligrey.com/github/FileSaver.js/blob/master/FileSaver.js */ -var $jscomp=$jscomp||{};$jscomp.scope={};$jscomp.arrayIteratorImpl=function(a){var b=0;return function(){return b>>0,$jscomp.propertyToPolyfillSymbol[e]=$jscomp.IS_SYMBOL_NATIVE? -$jscomp.global.Symbol(e):$jscomp.POLYFILL_PREFIX+c+"$"+e),$jscomp.defineProperty(d,$jscomp.propertyToPolyfillSymbol[e],{configurable:!0,writable:!0,value:b})))};$jscomp.initSymbol=function(){}; -$jscomp.polyfill("Symbol",function(a){if(a)return a;var b=function(f,g){this.$jscomp$symbol$id_=f;$jscomp.defineProperty(this,"description",{configurable:!0,writable:!0,value:g})};b.prototype.toString=function(){return this.$jscomp$symbol$id_};var c="jscomp_symbol_"+(1E9*Math.random()>>>0)+"_",d=0,e=function(f){if(this instanceof e)throw new TypeError("Symbol is not a constructor");return new b(c+(f||"")+"_"+d++,f)};return e},"es6","es3"); -$jscomp.polyfill("Symbol.iterator",function(a){if(a)return a;a=Symbol("Symbol.iterator");for(var b="Array Int8Array Uint8Array Uint8ClampedArray Int16Array Uint16Array Int32Array Uint32Array Float32Array Float64Array".split(" "),c=0;cc&&(c=Math.max(c+e,0));c=f}},"es6","es3"); -$jscomp.iteratorFromArray=function(a,b){a instanceof String&&(a+="");var c=0,d=!1,e={next:function(){if(!d&&cc&&(c=Math.max(0,e+c));if(null==d||d>e)d=e;d=Number(d);0>d&&(d=Math.max(0,e+d));for(c=Number(c||0);carguments.length)return arguments.length?Math.abs(arguments[0]):0;var c,d,e;for(c=e=0;ce){if(!e)return e;for(c=d=0;cb||1342177279>>=1)c+=c;return d}},"es6","es3");$jscomp.owns=function(a,b){return Object.prototype.hasOwnProperty.call(a,b)};$jscomp.polyfill("Object.entries",function(a){return a?a:function(b){var c=[],d;for(d in b)$jscomp.owns(b,d)&&c.push([d,b[d]]);return c}},"es8","es3"); -var LOGO_IMAGE="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAFUAAAAYCAYAAACLM7HoAAAABGdBTUEAALGPC/xhBQAAACBjSFJNAAB6JgAAgIQAAPoAAACA6AAAdTAAAOpgAAA6mAAAF3CculE8AAAABmJLR0QA/wD/AP+gvaeTAAAACXBIWXMAAAsTAAALEwEAmpwYAAAAB3RJTUUH5AgMEyUWOeB/0gAACLlJREFUWMPt2X+wXVV1B/DPOve+H0kTIRAwEMTyU4HXaXGwQxsqooCGmSq1gxRaKzJMq20damNL6bROlc6g+IPpOKUKGEqcUoogIJ1qaVLSaKIoMhYMkR8asBIJCSG/Hi/Jffes/rH3zXuJicMMndGZsN7cee+ds8/ee33Xd631Pfvysv2/W+x94Zbz5+538MV3bXzRYw5k6/6Ue7+EX8ZX8RT7BPN4nIFH8Q3kz9qhnwfbH6in4HMKk9+FazBhitk7sR7/iIMwikvxwM/aoZ8H2x+ox2KWAtpf4xMKkBRgn8G1OBKLFeBf5WVQsVdNnZbeh+CTeD3uwafRk7ufmMQ4FimAzsFCfId919WzL135k6sPisW0XfS17lv8Gy/ZsX2uh8wkQjM5IbszfmIzSxef8ZLX3h9TX18B+ht9z+RRzWTzX7u0F80YNTt6cX+vb1fCx3ArPoN3DkC95fy5ewD7pktWDP7sYJjcSbRtpGiINoaRQS9/SlneF1BLFy/Y9+AyTQgjaOrVdnzD+h2zDp83HdCDcDS+h95LRtQ0jkxj6ZG4C7cZiU/kWLfxQr4ZF2IebsDdsWZy+jzn4u9xCe5nT7aec+kqFazfw3uV0nGHTBgWcTW+iX/tRc+wEdn2iSky544tmtGDKc3xNPJOaWdqzZx5vImJH1R3UputJjoqWNdiBvoV3LV1r4/XqS8o+853SuM0UiuCQurQ70267/NnvmhQu3sBCn+EbdLn8tRux5a8QmHhA3hYaVAuvmvj9OeWYQU+iN9Xmtpua7Ov7U9Gpzt8Nk7FBZl5d0RMKqXmLfgaDLVdGa2234+m2+k20elltmJ0zoB+b8W5Mm8TjdCYmFgrs42IzlBmTjbRaevSJ+NX6r7W43B8BMOTk70/7HaHst5f/+5zFoz/070rRaQFxy+w6vGVQ8MzZ/R6Ezt0hocsfM/9elGIFNHUoO+pSAdZ090L0NPx27jc3OZ5W/KCCugX8UalgX0D/vnKeS6++pkBsP0a/c/gBDw0fd7FETrdodk4DjfhtIg4prLl1TW4j9bhHby16XbPx9zM9gmlpv8Q51W2D4vmI1gt3SGcF9F5Gw6OaF7ALfh3RcU8mdneE9FMVia/HQd1mkZmdiLitVh183+uMjIyateunWesemLVRSKO6E3s+F/8g8zHetEbJS7Bw5ntygroG3GytETYPvB3UGuOx4dxHZbbmktzXjOqNKFlNb1XVTadgMMGwOZJXXliVx7WPII/UOrxB+uc1QIxD4fiTjyLN9Sbr8UWrIsIIi5TFMe3FVl3Iq6S7RBeqMz+Gh7BWhHn4c+xsgb1q+hHNDCG7RHNSYWR+e5KjJuj6WREzMF8rIZdu3a+DZ/Ck0qZOwTXkq+I6OzAK/G3MmdVQD+KTdm247WU7U7/Dv5KqT8tnnV0p9U6oqbLGmzFMH61PjOCL2MXDtdxf2zJ8cqMRXgOv47fnVYKjquMXl0dP7vf27G4MzQ6hieHhkY293o7T8Yf40Nt237pkf9+sh0769gX8EkRh+KxupfP41t13mvwXGbeHhFbBo5ltrNqYA/Dx+ueT8SSzLw3CtOOqtcfJw8l/gI3EtfXUvMjfIE4JrP9H1yPs0VchdfhuqZpbu3nns21W2k0s7JlCF1twnYsUd6mvoU3K/q0qRu9Ek9gAd5lxLhd5mEzHsRpNRADUMfw48x8LiKW48LO0Ohr8Bo80OvtVNc4Ahc2TfOOsbOOhYPr3nbVObI6O7B/wxkRcY9S928lvkm+su7zCtxXfV2ID0fEF+oeT8RWmetEvKHi8KVpL4Z9RRH06/8/xr01qz8QTbOk3y+3lt40JcW6iua8Bh+oTLjFluQoG6Trpm1+dd1gt6bvghJhO7HJLqrjxyka9lpsWTrrSjte2G505qwxPBpN08tsHwnxHH6zpt9N09i8FH9XM0gFcTwiNmXmGJ7JzI2FaAEryPOJ19XMuJ5ciF+szz9U2U1RJkM1AweBXiuaCXJ+IVJuLXo8KK/pW/B0HX86zsH3MSszkfaWgYOa+qBSPz+GvxSOiUcmNbfvmD52DW6uzr4dy3Em7vZ8u83OnI/LcLXSUG6Hp4ZPNzpj1uyait+VKTTjBQzvwWxT8uZZzCM3iHgos/0uNmRaVxxwNLYHXaKLuTgyMzcQX8EdBekMpRRtqqAMk3Oqj5uxpm3bwEmFLDlg4Vzi1U1nmFLr34vb8LyiWj6ulJ4/xe/IHIto1Pq9B1On23qlmfwJFuUpXbFmUp60e1iLDTVSZ+FxYUmeOyKWTLy/OnCTaSK6Euqwmlqrp8hnKS6vcw2YcGsJVNwh8/sRzSh6Ea7AOnwdC0V8UWl423F5RPODoiq9Cp+e2Pb8uhmzDzmhBmFxWTB+oS68iHiqaZo5NSgP17VXVibf0La9tYoqWZGZ10fE8ZUsd2a/f6Om6UbEhbgss/0zEQMJN+Uze2jVNykq4BJVPmEA7G/VKKXy+npDPN3famueiRvxvgrWbvFf34JmT7HCeAV1hDgVEzIfTtmWiOdc4jSl827CGpk/VFDrRMQJSoN5inyOGFPq8CRWT7a9RxudbJrmFKVbD3zcTD5BbCnrx4hyEvcotlUvZxO/prx2P5aZD0VEv643P+WDQa9OOR9HpPwOJpct3rOm7m3LlcK+qKbn9t3wp+UVmI0mbYr1fTYnjRMUbXiffds25Y1peix3Tg9a1J9kI74y/eHBkUOUhvG9+hnYiuljO01Xlka7eiozpqyJRpvtYP29D4C2KY1oT8aVxvijvQ6fnzaVYXvY/g5UxhQmrlVkxG1Sa3YwGuxIxpP0DlxUAfus2hAO9IPq/Z38L1DAXKaUg/fV34ea0hujOBv/oQjh92PZgQ4o+z+l6imAH6LIpMl6bcIUqG299gpFEUx62bB/UL+NqxTJ9CGl6359H+O+rDSvj+7n/gFp+wO1j3+pn922jy/+7jWtsL9sxWJfF/f1benetfLFjDlQ7f8ADW9Ok5ZiUfUAAAAldEVYdGRhdGU6Y3JlYXRlADIwMTktMDktMDZUMjA6NDc6MTYrMDA6MDBF0XDEAAAAJXRFWHRkYXRlOm1vZGlmeQAyMDE5LTA5LTA2VDIwOjQ3OjE2KzAwOjAwNIzIeAAAAABJRU5ErkJggg=="; +const LOGO_IMAGE="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAFUAAAAYCAYAAACLM7HoAAAABGdBTUEAALGPC/xhBQAAACBjSFJNAAB6JgAAgIQAAPoAAACA6AAAdTAAAOpgAAA6mAAAF3CculE8AAAABmJLR0QA/wD/AP+gvaeTAAAACXBIWXMAAAsTAAALEwEAmpwYAAAAB3RJTUUH5AgMEyUWOeB/0gAACLlJREFUWMPt2X+wXVV1B/DPOve+H0kTIRAwEMTyU4HXaXGwQxsqooCGmSq1gxRaKzJMq20damNL6bROlc6g+IPpOKUKGEqcUoogIJ1qaVLSaKIoMhYMkR8asBIJCSG/Hi/Jffes/rH3zXuJicMMndGZsN7cee+ds8/ee33Xd631Pfvysv2/W+x94Zbz5+538MV3bXzRYw5k6/6Ue7+EX8ZX8RT7BPN4nIFH8Q3kz9qhnwfbH6in4HMKk9+FazBhitk7sR7/iIMwikvxwM/aoZ8H2x+ox2KWAtpf4xMKkBRgn8G1OBKLFeBf5WVQsVdNnZbeh+CTeD3uwafRk7ufmMQ4FimAzsFCfId919WzL135k6sPisW0XfS17lv8Gy/ZsX2uh8wkQjM5IbszfmIzSxef8ZLX3h9TX18B+ht9z+RRzWTzX7u0F80YNTt6cX+vb1fCx3ArPoN3DkC95fy5ewD7pktWDP7sYJjcSbRtpGiINoaRQS9/SlneF1BLFy/Y9+AyTQgjaOrVdnzD+h2zDp83HdCDcDS+h95LRtQ0jkxj6ZG4C7cZiU/kWLfxQr4ZF2IebsDdsWZy+jzn4u9xCe5nT7aec+kqFazfw3uV0nGHTBgWcTW+iX/tRc+wEdn2iSky544tmtGDKc3xNPJOaWdqzZx5vImJH1R3UputJjoqWNdiBvoV3LV1r4/XqS8o+853SuM0UiuCQurQ70267/NnvmhQu3sBCn+EbdLn8tRux5a8QmHhA3hYaVAuvmvj9OeWYQU+iN9Xmtpua7Ov7U9Gpzt8Nk7FBZl5d0RMKqXmLfgaDLVdGa2234+m2+k20elltmJ0zoB+b8W5Mm8TjdCYmFgrs42IzlBmTjbRaevSJ+NX6r7W43B8BMOTk70/7HaHst5f/+5zFoz/070rRaQFxy+w6vGVQ8MzZ/R6Ezt0hocsfM/9elGIFNHUoO+pSAdZ090L0NPx27jc3OZ5W/KCCugX8UalgX0D/vnKeS6++pkBsP0a/c/gBDw0fd7FETrdodk4DjfhtIg4prLl1TW4j9bhHby16XbPx9zM9gmlpv8Q51W2D4vmI1gt3SGcF9F5Gw6OaF7ALfh3RcU8mdneE9FMVia/HQd1mkZmdiLitVh183+uMjIyateunWesemLVRSKO6E3s+F/8g8zHetEbJS7Bw5ntygroG3GytETYPvB3UGuOx4dxHZbbmktzXjOqNKFlNb1XVTadgMMGwOZJXXliVx7WPII/UOrxB+uc1QIxD4fiTjyLN9Sbr8UWrIsIIi5TFMe3FVl3Iq6S7RBeqMz+Gh7BWhHn4c+xsgb1q+hHNDCG7RHNSYWR+e5KjJuj6WREzMF8rIZdu3a+DZ/Ck0qZOwTXkq+I6OzAK/G3MmdVQD+KTdm247WU7U7/Dv5KqT8tnnV0p9U6oqbLGmzFMH61PjOCL2MXDtdxf2zJ8cqMRXgOv47fnVYKjquMXl0dP7vf27G4MzQ6hieHhkY293o7T8Yf40Nt237pkf9+sh0769gX8EkRh+KxupfP41t13mvwXGbeHhFbBo5ltrNqYA/Dx+ueT8SSzLw3CtOOqtcfJw8l/gI3EtfXUvMjfIE4JrP9H1yPs0VchdfhuqZpbu3nns21W2k0s7JlCF1twnYsUd6mvoU3K/q0qRu9Ek9gAd5lxLhd5mEzHsRpNRADUMfw48x8LiKW48LO0Ohr8Bo80OvtVNc4Ahc2TfOOsbOOhYPr3nbVObI6O7B/wxkRcY9S928lvkm+su7zCtxXfV2ID0fEF+oeT8RWmetEvKHi8KVpL4Z9RRH06/8/xr01qz8QTbOk3y+3lt40JcW6iua8Bh+oTLjFluQoG6Trpm1+dd1gt6bvghJhO7HJLqrjxyka9lpsWTrrSjte2G505qwxPBpN08tsHwnxHH6zpt9N09i8FH9XM0gFcTwiNmXmGJ7JzI2FaAEryPOJ19XMuJ5ciF+szz9U2U1RJkM1AweBXiuaCXJ+IVJuLXo8KK/pW/B0HX86zsH3MSszkfaWgYOa+qBSPz+GvxSOiUcmNbfvmD52DW6uzr4dy3Em7vZ8u83OnI/LcLXSUG6Hp4ZPNzpj1uyait+VKTTjBQzvwWxT8uZZzCM3iHgos/0uNmRaVxxwNLYHXaKLuTgyMzcQX8EdBekMpRRtqqAMk3Oqj5uxpm3bwEmFLDlg4Vzi1U1nmFLr34vb8LyiWj6ulJ4/xe/IHIto1Pq9B1On23qlmfwJFuUpXbFmUp60e1iLDTVSZ+FxYUmeOyKWTLy/OnCTaSK6Euqwmlqrp8hnKS6vcw2YcGsJVNwh8/sRzSh6Ea7AOnwdC0V8UWl423F5RPODoiq9Cp+e2Pb8uhmzDzmhBmFxWTB+oS68iHiqaZo5NSgP17VXVibf0La9tYoqWZGZ10fE8ZUsd2a/f6Om6UbEhbgss/0zEQMJN+Uze2jVNykq4BJVPmEA7G/VKKXy+npDPN3famueiRvxvgrWbvFf34JmT7HCeAV1hDgVEzIfTtmWiOdc4jSl827CGpk/VFDrRMQJSoN5inyOGFPq8CRWT7a9RxudbJrmFKVbD3zcTD5BbCnrx4hyEvcotlUvZxO/prx2P5aZD0VEv643P+WDQa9OOR9HpPwOJpct3rOm7m3LlcK+qKbn9t3wp+UVmI0mbYr1fTYnjRMUbXiffds25Y1peix3Tg9a1J9kI74y/eHBkUOUhvG9+hnYiuljO01Xlka7eiozpqyJRpvtYP29D4C2KY1oT8aVxvijvQ6fnzaVYXvY/g5UxhQmrlVkxG1Sa3YwGuxIxpP0DlxUAfus2hAO9IPq/Z38L1DAXKaUg/fV34ea0hujOBv/oQjh92PZgQ4o+z+l6imAH6LIpMl6bcIUqG299gpFEUx62bB/UL+NqxTJ9CGl6359H+O+rDSvj+7n/gFp+wO1j3+pn922jy/+7jWtsL9sxWJfF/f1benetfLFjDlQ7f8ADW9Ok5ZiUfUAAAAldEVYdGRhdGU6Y3JlYXRlADIwMTktMDktMDZUMjA6NDc6MTYrMDA6MDBF0XDEAAAAJXRFWHRkYXRlOm1vZGlmeQAyMDE5LTA5LTA2VDIwOjQ3OjE2KzAwOjAwNIzIeAAAAABJRU5ErkJggg=="; "use strict"; -var utils={requestPromise:function(a,b){return new Promise(function(c,d){b&&a.setRequestHeader("Content-Type","application/json; charset=utf-8");a.send(JSON.stringify(b));a.onreadystatechange=function(){if(4===a.readyState)if(200<=a.status&&300>a.status)c(a);else{var e=Error(a.statusText||"Unsuccessful Xhr response");e.request=a;d(e)}}})},memoize:function(a){var b={};return function(){var c=JSON.stringify(arguments);if(b[c])return b[c];var d=a.apply(null,arguments);return b[c]=d}},getUrlSync:function(a,b){b= -void 0===b?function(d){return d}:b;a=ensureFullUrl(a);var c=new XMLHttpRequest;c.open("GET",a,!1);c.send();if(200===c.status)return b(c.responseText);throw Error("unable to retrieve "+a);}};utils.getUrlSyncCached=utils.memoize(utils.getUrlSync);utils.defer=function(){var a={};a.promise=new Promise(function(b,c){a.resolve=b;a.reject=c});return a};utils.sleep=function(a){a=void 0===a?0:a;return new Promise(function(b){return setTimeout(b,a)})};utils.isNetsBloxDomain=function(a){return!!a.match(/^(?:\w+:\/+)?[^/]*\bnetsblox\.org\b\/?/i)}; +var utils={requestPromise:function(a,b){return new Promise(function(c,d){b&&a.setRequestHeader("Content-Type","application/json; charset=utf-8");a.send(JSON.stringify(b));a.onreadystatechange=function(){if(4===a.readyState)if(200<=a.status&&300>a.status)c(a);else{var e=Error(a.statusText||"Unsuccessful Xhr response");e.request=a;d(e)}}})},memoize:function(a){var b={};return function(){var c=JSON.stringify(arguments);if(b[c])return b[c];var d=a.apply(null,arguments);return b[c]=d}},getUrlSync:function(a,b= +c=>c){a=ensureFullUrl(a);var c=new XMLHttpRequest;c.open("GET",a,!1);c.send();if(200===c.status)return b(c.responseText);throw Error("unable to retrieve "+a);}};utils.getUrlSyncCached=utils.memoize(utils.getUrlSync);utils.defer=function(){const a={};a.promise=new Promise((b,c)=>{a.resolve=b;a.reject=c});return a};utils.sleep=function(a=0){return new Promise(b=>setTimeout(b,a))};utils.isNetsBloxDomain=function(a){return!!a.match(/^(?:\w+:\/+)?[^/]*\bnetsblox\.org\b\/?/i)}; if("undefined"===typeof Map){var Map=function(){this._content={};this.size=0};Map.prototype.set=function(a,b){this._content.hasOwnProperty(a)||this.size++;this._content[a]=b};Map.prototype.get=function(a){return this._content[a]};Map.prototype.delete=function(a){this._content.hasOwnProperty(a)&&this.size--;delete this._content[a]}}Date.now||(Date.now=function(){return(new Date).getTime()}); !function(a,b){"object"==typeof exports&&"undefined"!=typeof module?b():"function"==typeof define&&define.amd?define(b):b()}(0,function(){function a(){}function b(m){if(!(this instanceof b))throw new TypeError("Promises must be constructed via new");if("function"!=typeof m)throw new TypeError("not a function");this._state=0;this._handled=!1;this._value=void 0;this._deferreds=[];g(m,this)}function c(m,n){for(;3===m._state;)m=m._value;0!==m._state?(m._handled=!0,b._immediateFn(function(){var p=1=== -m._state?n.onFulfilled:n.onRejected;if(null!==p){try{var r=p(m._value)}catch(q){return void e(n.promise,q)}d(n.promise,r)}else(1===m._state?d:e)(n.promise,m._value)})):m._deferreds.push(n)}function d(m,n){try{if(n===m)throw new TypeError("A promise cannot be resolved with itself.");if(n&&("object"==typeof n||"function"==typeof n)){var p=n.then;if(n instanceof b)return m._state=3,m._value=n,void f(m);if("function"==typeof p)return void g(function(r,q){return function(){r.apply(q,arguments)}}(p,n), -m)}m._state=1;m._value=n;f(m)}catch(r){e(m,r)}}function e(m,n){m._state=2;m._value=n;f(m)}function f(m){2===m._state&&0===m._deferreds.length&&b._immediateFn(function(){m._handled||b._unhandledRejectionFn(m._value)});for(var n=0,p=m._deferreds.length;p>n;n++)c(m,m._deferreds[n]);m._deferreds=null}function g(m,n){var p=!1;try{m(function(r){p||(p=!0,d(n,r))},function(r){p||(p=!0,e(n,r))})}catch(r){p||(p=!0,e(n,r))}}var h=function(m){var n=this.constructor;return this.then(function(p){return n.resolve(m()).then(function(){return p})}, -function(p){return n.resolve(m()).then(function(){return n.reject(p)})})},k=setTimeout;b.prototype["catch"]=function(m){return this.then(null,m)};b.prototype.then=function(m,n){var p=new this.constructor(a);return c(this,new function(r,q,t){this.onFulfilled="function"==typeof r?r:null;this.onRejected="function"==typeof q?q:null;this.promise=t}(m,n,p)),p};b.prototype["finally"]=h;b.all=function(m){return new b(function(n,p){function r(v,w){try{if(w&&("object"==typeof w||"function"==typeof w)){var y= -w.then;if("function"==typeof y)return void y.call(w,function(x){r(v,x)},p)}q[v]=w;0==--t&&n(q)}catch(x){p(x)}}if(!m||"undefined"==typeof m.length)throw new TypeError("Promise.all accepts an array");var q=Array.prototype.slice.call(m);if(0===q.length)return n([]);for(var t=q.length,u=0;q.length>u;u++)r(u,q[u])})};b.resolve=function(m){return m&&"object"==typeof m&&m.constructor===b?m:new b(function(n){n(m)})};b.reject=function(m){return new b(function(n,p){p(m)})};b.race=function(m){return new b(function(n, -p){for(var r=0,q=m.length;q>r;r++)m[r].then(n,p)})};b._immediateFn="function"==typeof setImmediate&&function(m){setImmediate(m)}||function(m){k(m,0)};b._unhandledRejectionFn=function(m){void 0!==console&&console&&console.warn("Possible Unhandled Promise Rejection:",m)};var l=function(){if("undefined"!=typeof self)return self;if("undefined"!=typeof window)return window;if("undefined"!=typeof global)return global;throw Error("unable to locate global object");}();l.Promise?l.Promise.prototype["finally"]|| +m._state?n.onFulfilled:n.onRejected;if(null!==p){try{var q=p(m._value)}catch(r){return void e(n.promise,r)}d(n.promise,q)}else(1===m._state?d:e)(n.promise,m._value)})):m._deferreds.push(n)}function d(m,n){try{if(n===m)throw new TypeError("A promise cannot be resolved with itself.");if(n&&("object"==typeof n||"function"==typeof n)){var p=n.then;if(n instanceof b)return m._state=3,m._value=n,void f(m);if("function"==typeof p)return void g(function(q,r){return function(){q.apply(r,arguments)}}(p,n), +m)}m._state=1;m._value=n;f(m)}catch(q){e(m,q)}}function e(m,n){m._state=2;m._value=n;f(m)}function f(m){2===m._state&&0===m._deferreds.length&&b._immediateFn(function(){m._handled||b._unhandledRejectionFn(m._value)});for(var n=0,p=m._deferreds.length;p>n;n++)c(m,m._deferreds[n]);m._deferreds=null}function g(m,n){var p=!1;try{m(function(q){p||(p=!0,d(n,q))},function(q){p||(p=!0,e(n,q))})}catch(q){p||(p=!0,e(n,q))}}var h=function(m){var n=this.constructor;return this.then(function(p){return n.resolve(m()).then(function(){return p})}, +function(p){return n.resolve(m()).then(function(){return n.reject(p)})})},k=setTimeout;b.prototype["catch"]=function(m){return this.then(null,m)};b.prototype.then=function(m,n){var p=new this.constructor(a);return c(this,new function(q,r,t){this.onFulfilled="function"==typeof q?q:null;this.onRejected="function"==typeof r?r:null;this.promise=t}(m,n,p)),p};b.prototype["finally"]=h;b.all=function(m){return new b(function(n,p){function q(v,w){try{if(w&&("object"==typeof w||"function"==typeof w)){var y= +w.then;if("function"==typeof y)return void y.call(w,function(x){q(v,x)},p)}r[v]=w;0==--t&&n(r)}catch(x){p(x)}}if(!m||"undefined"==typeof m.length)throw new TypeError("Promise.all accepts an array");var r=Array.prototype.slice.call(m);if(0===r.length)return n([]);for(var t=r.length,u=0;r.length>u;u++)q(u,r[u])})};b.resolve=function(m){return m&&"object"==typeof m&&m.constructor===b?m:new b(function(n){n(m)})};b.reject=function(m){return new b(function(n,p){p(m)})};b.race=function(m){return new b(function(n, +p){for(var q=0,r=m.length;r>q;q++)m[q].then(n,p)})};b._immediateFn="function"==typeof setImmediate&&function(m){setImmediate(m)}||function(m){k(m,0)};b._unhandledRejectionFn=function(m){void 0!==console&&console&&console.warn("Possible Unhandled Promise Rejection:",m)};var l=function(){if("undefined"!=typeof self)return self;if("undefined"!=typeof window)return window;if("undefined"!=typeof global)return global;throw Error("unable to locate global object");}();l.Promise?l.Promise.prototype["finally"]|| (l.Promise.prototype["finally"]=h):l.Promise=b});function ServicesRegistry(a){this.setServicesHosts(a)}ServicesRegistry.prototype.reset=function(){this.defaultHost=DEFAULT_SERVICES_HOST;this.auxServicesHosts=[]};ServicesRegistry.prototype.onInvalidHosts=function(a){console.error("Invalid services hosts detected:",a)}; -ServicesRegistry.prototype.fetchHosts=function(){var a=this;return fetch(SERVER_URL+"/api/v2/services-hosts/all/").then(function(b){return b.json()}).then(function(b){return a.setServicesHosts(b)}).catch(function(b){console.error("Unable to fetch hosts: "+b);a.reset()})}; -ServicesRegistry.prototype.setServicesHosts=function(a){var b=a.findIndex(function(c){return 0===c.categories.length});-1a.json()).then(a=>this.setServicesHosts(a)).catch(a=>{console.error("Unable to fetch hosts: "+a);this.reset()})}; +ServicesRegistry.prototype.setServicesHosts=function(a){const b=a.findIndex(c=>{({categories:c}=c);return 0===c.length});-1fetch(d.url).then(e=>e.json()).catch(()=>b.push(d)));Promise.allSettled(c).then(()=>{const d=this.allHosts().map(f=>f.url),e=b.filter(f=>d.includes(f.url));if(e.length)a.onInvalidHosts(e)})};ServicesRegistry.prototype.allHosts=function(){return[this.defaultHost].concat(this.auxServicesHosts)}; +ServicesRegistry.prototype.getServiceURL=async function(a){const b=[];var c=this.auxServicesHosts.map(async d=>{({url:d}=d);try{return(await (await fetch(d)).json()).map(e=>e.name).includes(a)}catch(e){b.push(d)}});c=(await Promise.all(c)).findIndex(d=>d);if(b.length){const d=`Could not fetch service metadata from "${b.join(",")}"`;console.error(d)}return(-1{const {url:c,categories:d}=b;try{const e=await (await fetch(c)).json();b!==this.defaultHost&&e.forEach(f=>f.url=c);d.length&&e.forEach(f=>{0===f.categories.length&&f.categories.push([]);f.categories.map(g=>g.unshift(d))});return e}catch(e){return console.error(`Unable to fetch services metadata for ${d}: ${c}`),[]}});return(await Promise.all(a)).flat()}; +ServicesRegistry.prototype.isRegisteredServiceURL=function(a){return!!this.allHosts().find(b=>a.startsWith(b.url))};const Services=new ServicesRegistry(SERVICES_HOSTS);var morphicVersion="2020-July-23",modules={},useBlurredShadows=!0;const ZERO=new Point,BLACK=new Color,WHITE=new Color(255,255,255),CLEAR=new Color(0,0,0,0);Object.freeze(ZERO);Object.freeze(BLACK);Object.freeze(WHITE); var standardSettings={minimumFontHeight:getMinimumFontHeight(),globalFontFamily:"",menuFontName:"sans-serif",menuFontSize:12,bubbleHelpFontSize:10,prompterFontName:"sans-serif",prompterFontSize:12,prompterSliderSize:10,handleSize:15,scrollBarSize:12,mouseScrollAmount:40,useSliderForInput:!1,isTouchDevice:!1,rasterizeSVGs:!1,isFlat:!1,grabThreshold:5,showHoles:!1},touchScreenSettings={minimumFontHeight:standardSettings.minimumFontHeight,globalFontFamily:"",menuFontName:"sans-serif",menuFontSize:24, bubbleHelpFontSize:18,prompterFontName:"sans-serif",prompterFontSize:24,prompterSliderSize:20,handleSize:26,scrollBarSize:24,mouseScrollAmount:40,useSliderForInput:!1,isTouchDevice:!0,rasterizeSVGs:!1,isFlat:!1,grabThreshold:5,showHoles:!1},MorphicPreferences=standardSettings;enableRetinaSupport();function nop(){return null}function localize(a){return a}function isNil(a){return void 0===a||null===a}function contains(a,b){return-1!==a.indexOf(b)} function detect(a,b){var c,d=a.length;for(c=0;c{g=f[g];return g.hasOwnProperty("configurable")&&!g.configurable})||(b._isRetinaEnabled=!0,b._bak=f,Object.defineProperty(b,"isRetinaEnabled",{get:function(){return this._isRetinaEnabled},set:function(g){var h=a(this),k=this.width,l=this.height;this._isRetinaEnabled=g;a(this)!= +h&&(this.width=k,this.height=l)},configurable:!0}),Object.defineProperty(b,"width",{get:function(){return f.width.get.call(this)/a(this)},set:function(g){try{var h=a(this);f.width.set.call(this,g*h);this.getContext("2d").scale(h,h)}catch(k){console.log("Retina Display Support Problem",k),f.width.set.call(this,g)}}}),Object.defineProperty(b,"height",{get:function(){return f.height.get.call(this)/a(this)},set:function(g){var h=a(this);f.height.set.call(this,g*h);this.getContext("2d").scale(h,h)}}), +e.drawImage=function(g){var h=a(g);switch(arguments.length){case 9:var k=arguments[1];var l=arguments[2];var m=arguments[3];var n=arguments[4];var p=arguments[5];var q=arguments[6];var r=arguments[7];var t=arguments[8];break;case 5:l=k=0;m=g.width;n=g.height;p=arguments[1];q=arguments[2];r=arguments[3];t=arguments[4];break;case 3:l=k=0;m=g.width;n=g.height;p=arguments[1];q=arguments[2];r=g.width;t=g.height;break;default:throw Error("Called drawImage() with "+arguments.length+" arguments");}f.drawImage.call(this, +g,k*h,l*h,m*h,n*h,p,q,r,t)},e.getImageData=function(g,h,k,l){var m=a(this.canvas);return f.getImageData.call(this,g*m,h*m,k*m,l*m)},Object.defineProperty(e,"shadowOffsetX",{get:function(){return f.shadowOffsetX.get.call(this)/a(this.canvas)},set:function(g){var h=a(this.canvas);f.shadowOffsetX.set.call(this,g*h)}}),Object.defineProperty(e,"shadowOffsetY",{get:function(){return f.shadowOffsetY.get.call(this)/a(this.canvas)},set:function(g){var h=a(this.canvas);f.shadowOffsetY.set.call(this,g*h)}}), Object.defineProperty(e,"shadowBlur",{get:function(){return f.shadowBlur.get.call(this)/a(this.canvas)},set:function(g){var h=a(this.canvas);f.shadowBlur.set.call(this,g*h)}}))} function isRetinaSupported(){var a=document.createElement("canvas").getContext("2d");a=a.webkitBackingStorePixelRatio||a.mozBackingStorePixelRatio||a.msBackingStorePixelRatio||a.oBackingStorePixelRatio||a.backingStorePixelRatio||1;var b=HTMLCanvasElement.prototype,c=CanvasRenderingContext2D.prototype,d={drawImage:c.drawImage,getImageData:c.getImageData,width:Object.getOwnPropertyDescriptor(b,"width"),height:Object.getOwnPropertyDescriptor(b,"height"),shadowOffsetX:Object.getOwnPropertyDescriptor(c, -"shadowOffsetX"),shadowOffsetY:Object.getOwnPropertyDescriptor(c,"shadowOffsetY"),shadowBlur:Object.getOwnPropertyDescriptor(c,"shadowBlur")};return a!==window.devicePixelRatio&&!Object.keys(d).some(function(e){e=d[e];return e.hasOwnProperty("configurable")&&!e.configurable})}function isRetinaEnabled(){return HTMLCanvasElement.prototype.hasOwnProperty("_isRetinaEnabled")} +"shadowOffsetX"),shadowOffsetY:Object.getOwnPropertyDescriptor(c,"shadowOffsetY"),shadowBlur:Object.getOwnPropertyDescriptor(c,"shadowBlur")};return a!==window.devicePixelRatio&&!Object.keys(d).some(e=>{e=d[e];return e.hasOwnProperty("configurable")&&!e.configurable})}function isRetinaEnabled(){return HTMLCanvasElement.prototype.hasOwnProperty("_isRetinaEnabled")} function disableRetinaSupport(){if(isRetinaEnabled()){var a=HTMLCanvasElement.prototype;var b=CanvasRenderingContext2D.prototype;var c=a._bak;Object.defineProperty(a,"width",c.width);Object.defineProperty(a,"height",c.height);b.drawImage=c.drawImage;b.getImageData=c.getImageData;Object.defineProperty(b,"shadowOffsetX",c.shadowOffsetX);Object.defineProperty(b,"shadowOffsetY",c.shadowOffsetY);Object.defineProperty(b,"shadowBlur",c.shadowBlur);delete a._isRetinaEnabled;delete a.isRetinaEnabled;delete a._bak}} function normalizeCanvas(a,b){if(!a.isRetinaEnabled)return a;var c=newCanvas(new Point(a.width,a.height),!0);c.getContext("2d").drawImage(a,0,0);if(b)return c;a.isRetinaEnabled=!1;a.width=c.width;a.height=c.height;a.getContext("2d").drawImage(c,0,0);return a} function Animation(a,b,c,d,e,f){this.setter=a;this.getter=b;this.delta=c||0;this.duration=d||0;this.easing=isString(e)?this.easings[e]||this.easings.sinusoidal:e||this.easings.sinusoidal;this.onComplete=f||null;this.destination=this.endTime=null;this.isActive=!1;this.start()} -Animation.prototype.easings={linear:function(a){return a},sinusoidal:function(a){return 1-Math.cos(radians(90*a))},quadratic:function(a){return.5>a?2*a*a:(4-2*a)*a-1},cubic:function(a){return.5>a?4*a*a*a:(a-1)*(2*a-2)*(2*a-2)+1},elastic:function(a){return 0>(a-=.5)?(.01+.01/a)*Math.sin(50*a):(.02-.01/a)*Math.sin(50*a)+1},sine_in:function(a){return 1-Math.sin(radians(90+90*a))},quad_in:function(a){return a*a},cubic_in:function(a){return a*a*a},elastic_in:function(a){return(.04-.04/a)*Math.sin(25*a)+ -1},sine_out:function(a){return Math.sin(radians(90*a))},quad_out:function(a){return a*(2-a)},elastic_out:function(a){return.04*a/--a*Math.sin(25*a)}};Animation.prototype.start=function(){this.endTime=Date.now()+this.duration;this.destination=this.getter.call(this)+this.delta;this.isActive=!0}; -Animation.prototype.step=function(){if(this.isActive){var a=Date.now();if(a>this.endTime){if(this.setter(this.destination),this.isActive=!1,this.onComplete)this.onComplete()}else this.setter(this.destination-this.delta*this.easing((this.endTime-a)/this.duration))}};function Color(a,b,c,d){this.r=a||0;this.g=b||0;this.b=c||0;this.a=d||(0===d?0:1)}Color.prototype.toString=function(){return"rgba("+Math.round(this.r)+","+Math.round(this.g)+","+Math.round(this.b)+","+this.a+")"}; -Color.prototype.toRGBstring=function(){return"rgb("+Math.round(this.r)+","+Math.round(this.g)+","+Math.round(this.b)+")"};Color.fromString=function(a){a=a.split(/[\(),]/).slice(1,5);return new Color(a[0],a[1],a[2],a[3])};Color.prototype.copy=function(){return new Color(this.r,this.g,this.b,this.a)};Color.prototype.eq=function(a,b){return a&&this.r===a.r&&this.g===a.g&&this.b===a.b&&(b?this.a===a.a:!0)}; -Color.prototype.isCloseTo=function(a,b,c){function d(e,f){e-=f;return 0>e?255+e:e}c=2.55*(c||10);return a&&d(this.r,a.r)a,sinusoidal:a=>1-Math.cos(radians(90*a)),quadratic:a=>.5>a?2*a*a:(4-2*a)*a-1,cubic:a=>.5>a?4*a*a*a:(a-1)*(2*a-2)*(2*a-2)+1,elastic:a=>0>(a-=.5)?(.01+.01/a)*Math.sin(50*a):(.02-.01/a)*Math.sin(50*a)+1,sine_in:a=>1-Math.sin(radians(90+90*a)),quad_in:a=>a*a,cubic_in:a=>a*a*a,elastic_in:a=>(.04-.04/a)*Math.sin(25*a)+1,sine_out:a=>Math.sin(radians(90*a)),quad_out:a=>a*(2-a),elastic_out:a=>.04*a/--a*Math.sin(25*a)}; +Animation.prototype.start=function(){this.endTime=Date.now()+this.duration;this.destination=this.getter.call(this)+this.delta;this.isActive=!0};Animation.prototype.step=function(){if(this.isActive){var a=Date.now();if(a>this.endTime){if(this.setter(this.destination),this.isActive=!1,this.onComplete)this.onComplete()}else this.setter(this.destination-this.delta*this.easing((this.endTime-a)/this.duration))}};function Color(a,b,c,d){this.r=a||0;this.g=b||0;this.b=c||0;this.a=d||(0===d?0:1)} +Color.prototype.toString=function(){return"rgba("+Math.round(this.r)+","+Math.round(this.g)+","+Math.round(this.b)+","+this.a+")"};Color.prototype.toRGBstring=function(){return"rgb("+Math.round(this.r)+","+Math.round(this.g)+","+Math.round(this.b)+")"};Color.fromString=function(a){a=a.split(/[\(),]/).slice(1,5);return new Color(a[0],a[1],a[2],a[3])};Color.prototype.copy=function(){return new Color(this.r,this.g,this.b,this.a)}; +Color.prototype.eq=function(a,b){return a&&this.r===a.r&&this.g===a.g&&this.b===a.b&&(b?this.a===a.a:!0)};Color.prototype.isCloseTo=function(a,b,c){function d(e,f){e-=f;return 0>e?255+e:e}c=2.55*(c||10);return a&&d(this.r,a.r)g&&(g+=1);1g?f:g<2/3?e+(f-e)*(2/3-g)*6:e}0==b?this.b=this.g=this.r=c:(b=.5>c?c*(1+b):c+b-c*b,c=2*c-b,this.r=d(c,b,a+1/3),this.g=d(c,b,a),this.b=d(c,b,a-1/3));this.r*=255;this.g*=255;this.b*=255};Color.prototype.mixed=function(a,b){a=Math.min(Math.max(a,0),1);var c=1-a;return new Color(this.r*a+b.r*c,this.g*a+b.g*c,this.b*a+b.b*c)}; @@ -121,57 +68,56 @@ Rectangle.prototype.regionsAround=function(a){var b=[];if(!this.intersects(a))re Rectangle.prototype.containsPoint=function(a){return this.origin.le(a)&&a.lt(this.corner)};Rectangle.prototype.containsRectangle=function(a){return a.origin.gt(this.origin)&&a.corner.lt(this.corner)};Rectangle.prototype.intersects=function(a){var b=a.origin;a=a.corner;return a.x>=this.origin.x&&a.y>=this.origin.y&&b.x<=this.corner.x&&b.y<=this.corner.y}; Rectangle.prototype.isNearTo=function(a,b){var c=a.origin;a=a.corner;b=b||0;return a.x+b>=this.origin.x&&a.y+b>=this.origin.y&&c.x-b<=this.corner.x&&c.y-b<=this.corner.y};Rectangle.prototype.scaleBy=function(a){var b=this.origin.multiplyBy(a);a=this.corner.multiplyBy(a);return new Rectangle(b.x,b.y,a.x,a.y)};Rectangle.prototype.translateBy=function(a){var b=this.origin.add(a);a=this.corner.add(a);return new Rectangle(b.x,b.y,a.x,a.y)}; Rectangle.prototype.asArray=function(){return[this.left(),this.top(),this.right(),this.bottom()]};Rectangle.prototype.asArray_xywh=function(){return[this.left(),this.top(),this.width(),this.height()]};function Node(a,b){this.init(a||null,b||[])}Node.prototype.init=function(a,b){this.parent=a||null;this.children=b||[]};Node.prototype.toString=function(){return"a Node["+this.children.length.toString()+"]"};Node.prototype.addChild=function(a){this.children.push(a);a.parent=this}; -Node.prototype.addChildFirst=function(a){this.children.splice(0,null,a);a.parent=this};Node.prototype.removeChild=function(a){a=this.children.indexOf(a);-1!==a&&this.children.splice(a,1)};Node.prototype.root=function(){return null===this.parent?this:this.parent.root()};Node.prototype.depth=function(){return null===this.parent?0:this.parent.depth()+1};Node.prototype.allChildren=function(){var a=[this];this.children.forEach(function(b){a=a.concat(b.allChildren())});return a}; -Node.prototype.forAllChildren=function(a){0{a=a.concat(b.allChildren())});return a}; +Node.prototype.forAllChildren=function(a){0b.forAllChildren(a));a.call(null,this)};Node.prototype.anyChild=function(a){var b;if(a.call(null,this))return!0;for(b=0;b{0===b.children.length&&a.push(b)});return a}; +Node.prototype.allParents=function(){var a=[this];null!==this.parent&&(a=a.concat(this.parent.allParents()));return a};Node.prototype.siblings=function(){return null===this.parent?[]:this.parent.children.filter(a=>a!==this)};Node.prototype.parentThatIsA=function(){var a;for(a=0;a(0(0c.stepFrame()))};Morph.prototype.nextSteps=function(a){var b=a||[],c=b.shift();c&&(this.onNextStep=()=>{c.call(this);this.nextSteps(b)})};Morph.prototype.step=nop;Morph.prototype.left=function(){return this.bounds.left()}; Morph.prototype.right=function(){return this.bounds.right()};Morph.prototype.top=function(){return this.bounds.top()};Morph.prototype.bottom=function(){return this.bounds.bottom()};Morph.prototype.center=function(){return this.bounds.center()};Morph.prototype.bottomCenter=function(){return this.bounds.bottomCenter()};Morph.prototype.bottomLeft=function(){return this.bounds.bottomLeft()};Morph.prototype.bottomRight=function(){return this.bounds.bottomRight()};Morph.prototype.boundingBox=function(){return this.bounds}; Morph.prototype.corners=function(){return this.bounds.corners()};Morph.prototype.leftCenter=function(){return this.bounds.leftCenter()};Morph.prototype.rightCenter=function(){return this.bounds.rightCenter()};Morph.prototype.topCenter=function(){return this.bounds.topCenter()};Morph.prototype.topLeft=function(){return this.bounds.topLeft()};Morph.prototype.topRight=function(){return this.bounds.topRight()};Morph.prototype.position=function(){return this.bounds.origin};Morph.prototype.extent=function(){return this.bounds.extent()}; -Morph.prototype.width=function(){return this.bounds.width()};Morph.prototype.height=function(){return this.bounds.height()};Morph.prototype.fullBounds=function(){var a=this.bounds;this.children.forEach(function(b){b.isVisible&&(a=a.merge(b.fullBounds()))});return a};Morph.prototype.fullBoundsNoShadow=function(){var a=this.bounds;this.children.forEach(function(b){b instanceof ShadowMorph||!b.isVisible||(a=a.merge(b.fullBounds()))});return a}; -Morph.prototype.visibleBounds=function(){var a=this.bounds;this.allParents().filter(function(b){return b instanceof FrameMorph}).forEach(function(b){return a=a.intersect(b.bounds)});return a};Morph.prototype.moveBy=function(a){var b=this.children,c=b.length;this.changed();this.bounds=this.bounds.translateBy(a);this.changed();for(c;0{b.isVisible&&(a=a.merge(b.fullBounds()))});return a};Morph.prototype.fullBoundsNoShadow=function(){var a=this.bounds;this.children.forEach(b=>{b instanceof ShadowMorph||!b.isVisible||(a=a.merge(b.fullBounds()))});return a}; +Morph.prototype.visibleBounds=function(){var a=this.bounds;this.allParents().filter(b=>b instanceof FrameMorph).forEach(b=>a=a.intersect(b.bounds));return a};Morph.prototype.moveBy=function(a){var b=this.children,c=b.length;this.changed();this.bounds=this.bounds.translateBy(a);this.changed();for(c;0b&&this.moveBy(new Point(-b,0));b=this.fullBounds().bottom()-a.bottom();0a&&this.moveBy(new Point(0,-a))}; Morph.prototype.scrollIntoView=function(){var a=this.parentThatIsA(ScrollFrameMorph);if(a){var b=Math.min(this.fullBounds().right()-a.right(),a.contents.right()-a.right());0b&&a.contents.moveBy(new Point(-b,0));b=this.fullBounds().top()-a.top();0>b&&a.contents.moveBy(new Point(0,-b));b=this.fullBounds().bottom()-a.bottom();0this.changed();this.cachedTexture.src=this.texture=a}; Morph.prototype.renderCachedTexture=function(a){var b=this.cachedTexture,c=Math.floor(this.width()/b.width),d=Math.floor(this.height()/b.height),e,f;a.save();a.globalAlpha=this.alpha;a.beginPath();a.rect(0,0,this.width(),this.height());a.clip();for(f=0;f<=d;f+=1)for(e=0;e<=c;e+=1)a.drawImage(b,e*b.width,f*b.height);a.restore()}; Morph.prototype.drawOn=function(a,b){var c=b.intersect(this.bounds),d=this.position();if(c.extent().gt(ZERO)){a.save();a.globalAlpha=this.alpha;if(this.isCachingImage){b=this.getImage();var e=c.translateBy(d.neg());var f=e.left();var g=e.top();var h=Math.min(e.width(),b.width-f);e=Math.min(e.height(),b.height-g);if(1>h||1>e)return;a.drawImage(b,f,g,h,e,c.left(),c.top(),h,e)}else a.beginPath(),a.rect(c.left(),c.top(),c.width(),c.height()),a.clip(),a.translate(d.x,d.y),this.render(a),MorphicPreferences.showHoles&& -(a.translate(-d.x,-d.y),a.globalAlpha=.25,a.fillStyle="white",this.holes.forEach(function(k){k=k.translateBy(d).intersect(c);a.fillRect(k.left(),k.top(),k.width(),k.height())}));a.restore()}};Morph.prototype.fullDrawOn=function(a,b){this.isVisible&&(this.drawOn(a,b),this.children.forEach(function(c){return c.fullDrawOn(a,b)}))};Morph.prototype.hide=function(){this.isVisible=!1;this.changed()};Morph.prototype.show=function(){this.isVisible=!0;this.changed()}; +(a.translate(-d.x,-d.y),a.globalAlpha=.25,a.fillStyle="white",this.holes.forEach(k=>{k=k.translateBy(d).intersect(c);a.fillRect(k.left(),k.top(),k.width(),k.height())}));a.restore()}};Morph.prototype.fullDrawOn=function(a,b){this.isVisible&&(this.drawOn(a,b),this.children.forEach(c=>c.fullDrawOn(a,b)))};Morph.prototype.hide=function(){this.isVisible=!1;this.changed()};Morph.prototype.show=function(){this.isVisible=!0;this.changed()}; Morph.prototype.toggleVisibility=function(){this.isVisible=!this.isVisible;this.changed()};Morph.prototype.fullImage=function(){var a=this.fullBounds(),b=newCanvas(a.extent()),c=b.getContext("2d");c.translate(-a.origin.x,-a.origin.y);this.fullDrawOn(c,a);return b}; Morph.prototype.shadowImage=function(a,b){var c=a||new Point(7,7);var d=b||new Color(0,0,0);if(this.fullShadowSource){b=this.fullBounds().extent();var e=this.fullImage()}else b=this.extent(),e=this.getImage();a=newCanvas(b);var f=a.getContext("2d");f.drawImage(e,0,0);f.globalCompositeOperation="destination-out";f.drawImage(e,-c.x,-c.y);c=newCanvas(b);f=c.getContext("2d");f.drawImage(a,0,0);f.globalCompositeOperation="source-atop";f.fillStyle=d.toString();f.fillRect(0,0,b.x,b.y);return c}; Morph.prototype.shadowImageBlurred=function(a,b){a=a||new Point(7,7);var c=this.shadowBlur,d=b||new Color(0,0,0);if(this.fullShadowSource){var e=this.fullBounds().extent().add(2*c);b=this.fullImage()}else e=this.extent().add(2*c),b=this.getImage();e=newCanvas(e);var f=e.getContext("2d");f.shadowOffsetX=a.x;f.shadowOffsetY=a.y;f.shadowBlur=c;f.shadowColor=d.toString();f.drawImage(b,c-a.x,c-a.y);f.shadowOffsetX=0;f.shadowOffsetY=0;f.shadowBlur=0;f.globalCompositeOperation="destination-out";f.drawImage(b, c-a.x,c-a.y);return e};Morph.prototype.shadow=function(a,b,c){var d=new ShadowMorph;a=a||new Point(7,7);b=b||(0===b?0:.2);var e=this.fullBounds();d.setExtent(e.extent().add(2*this.shadowBlur));useBlurredShadows?(d.cachedImage=this.shadowImageBlurred(a,c),d.alpha=b,d.setPosition(e.origin.add(a).subtract(this.shadowBlur))):(d.cachedImage=this.shadowImage(a,c),d.alpha=b,d.setPosition(e.origin.add(a)));d.shouldRerender=!1;return d}; -Morph.prototype.addShadow=function(a,b,c){a=a||new Point(7,7);b=this.shadow(a,b||(0===b?0:.2),c);this.addBack(b);this.fullChanged();return b};Morph.prototype.getShadow=function(){var a=this.children.slice(0).reverse().filter(function(b){return b instanceof ShadowMorph});return 0!==a.length?a[0]:null};Morph.prototype.removeShadow=function(){var a=this.getShadow();null!==a&&(this.fullChanged(),this.removeChild(a))};Morph.prototype.penTrails=function(){return this.getImage()}; +Morph.prototype.addShadow=function(a,b,c){a=a||new Point(7,7);b=this.shadow(a,b||(0===b?0:.2),c);this.addBack(b);this.fullChanged();return b};Morph.prototype.getShadow=function(){var a=this.children.slice(0).reverse().filter(b=>b instanceof ShadowMorph);return 0!==a.length?a[0]:null};Morph.prototype.removeShadow=function(){var a=this.getShadow();null!==a&&(this.fullChanged(),this.removeChild(a))};Morph.prototype.penTrails=function(){return this.getImage()}; Morph.prototype.rerender=function(){this.shouldRerender=!0;this.changed()};Morph.prototype.changed=function(){var a=this.root();a instanceof WorldMorph&&a.broken.push(this.visibleBounds().spread());this.parent&&this.parent.childChanged(this)};Morph.prototype.fullChanged=function(){var a=this.root();a instanceof WorldMorph&&a.broken.push(this.fullBounds().spread())};Morph.prototype.childChanged=function(){this.parent&&this.parent.childChanged(this)}; Morph.prototype.world=function(){var a=this.root();return a instanceof WorldMorph?a:a instanceof HandMorph?a.world:null};Morph.prototype.add=function(a){var b=a.parent;null!==b&&b.removeChild(a);this.addChild(a)};Morph.prototype.addBack=function(a){var b=a.parent;null!==b&&b.removeChild(a);this.addChildFirst(a)}; -Morph.prototype.topMorphAt=function(a){var b=this,c,d;if(!this.isVisible)return null;for(c=this.children.length-1;0<=c;--c)if(d=this.children[c].topMorphAt(a))return d;if(this.bounds.containsPoint(a)){if(this.holes.some(function(e){return e.translateBy(b.position()).containsPoint(a)}))return null;if(this.isFreeForm){if(!this.isTransparentAt(a))return this}else return this}return null}; -Morph.prototype.topMorphSuchThat=function(a){var b;return a.call(null,this)?(b=detect(this.children.slice(0).reverse(),a))?b.topMorphSuchThat(a):this:null};Morph.prototype.overlappedMorphs=function(){var a=this,b=this.world(),c=this.fullBounds(),d=this.allParents(),e=this.allChildren();return b.allChildren().filter(function(f){return f.isVisible&&f!==a&&f!==b&&!contains(d,f)&&!contains(e,f)&&f.fullBounds().intersects(c)})}; +Morph.prototype.topMorphAt=function(a){var b,c;if(!this.isVisible)return null;for(b=this.children.length-1;0<=b;--b)if(c=this.children[b].topMorphAt(a))return c;if(this.bounds.containsPoint(a)){if(this.holes.some(d=>d.translateBy(this.position()).containsPoint(a)))return null;if(this.isFreeForm){if(!this.isTransparentAt(a))return this}else return this}return null}; +Morph.prototype.topMorphSuchThat=function(a){var b;return a.call(null,this)?(b=detect(this.children.slice(0).reverse(),a))?b.topMorphSuchThat(a):this:null};Morph.prototype.overlappedMorphs=function(){var a=this.world(),b=this.fullBounds(),c=this.allParents(),d=this.allChildren();return a.allChildren().filter(e=>e.isVisible&&e!==this&&e!==a&&!contains(c,e)&&!contains(d,e)&&e.fullBounds().intersects(b))}; Morph.prototype.getPixelColor=function(a){a=a.subtract(this.bounds.origin);a=this.getImage().getContext("2d").getImageData(a.x,a.y,1,1);return new Color(a.data[0],a.data[1],a.data[2],a.data[3]/255)};Morph.prototype.isTransparentAt=function(a){if(this.bounds.containsPoint(a)){if(this.texture)return!1;a=a.subtract(this.bounds.origin);var b=this.getImage().getContext("2d");a=b.getImageData(Math.floor(a.x),Math.floor(a.y),1,1);return 0===a.data[3]}return!1}; -Morph.prototype.copy=function(){var a=copy(this);a.parent=null;a.children=[];a.bounds=this.bounds.copy();return a};Morph.prototype.fullCopy=function(){var a=new Map;var b=this.copyRecordingReferences(a);b.forAllChildren(function(c){return c.updateReferences(a)});return b};Morph.prototype.copyRecordingReferences=function(a){var b=this.copy();a.set(this,b);this.children.forEach(function(c){return b.add(c.copyRecordingReferences(a))});return b}; +Morph.prototype.copy=function(){var a=copy(this);a.parent=null;a.children=[];a.bounds=this.bounds.copy();return a};Morph.prototype.fullCopy=function(){var a=new Map;var b=this.copyRecordingReferences(a);b.forAllChildren(c=>c.updateReferences(a));return b};Morph.prototype.copyRecordingReferences=function(a){var b=this.copy();a.set(this,b);this.children.forEach(c=>b.add(c.copyRecordingReferences(a)));return b}; Morph.prototype.updateReferences=function(a){var b=Object.keys(this),c=b.length,d,e;for(e=0;e{a.origin.add(this);c&&c();this.justDropped&&this.justDropped();a.origin.reactToDropOf&&a.origin.reactToDropOf(this);d&&d()})}; +Morph.prototype.glideTo=function(a,b,c,d){var e=this.world(),f=new Animation(g=>this.setLeft(g),()=>this.left(),-(this.left()-a.x),b||100,c);e.animations.push(f);e.animations.push(new Animation(g=>this.setTop(g),()=>this.top(),-(this.top()-a.y),b||100,c,()=>{f.setter(f.destination);f.isActive=!1;d()}))}; +Morph.prototype.fadeTo=function(a,b,c,d){var e=this.world(),f=this.alpha;this.children.forEach(g=>g.fadeTo(a,b,c));e.animations.push(new Animation(g=>{this.alpha=g;this.changed()},()=>this.alpha,a-this.alpha,b||200,c,()=>{this.alpha=f;d&&d()}))};Morph.prototype.perish=function(a,b){this.fadeTo(0,a||100,null,()=>{this.destroy();b&&b()})};Morph.prototype.nop=nop;Morph.prototype.resize=function(){this.world().activeHandle=new HandleMorph(this)}; Morph.prototype.move=function(){this.world().activeHandle=new HandleMorph(this,null,null,null,null,"move")};Morph.prototype.moveCenter=function(){this.world().activeHandle=new HandleMorph(this,null,null,null,null,"moveCenter")};Morph.prototype.hint=function(a){var b;(b=a)?a.toString&&(b=a.toString()):b="NULL";a=new MenuMorph(this,b);a.isDraggable=!0;a.popUpCenteredAtHand(this.world())}; Morph.prototype.inform=function(a){var b;(b=a)?a.toString&&(b=a.toString()):b="NULL";a=new MenuMorph(this,b);a.addItem("Ok");a.isDraggable=!0;a.popUpCenteredAtHand(this.world())}; -Morph.prototype.prompt=function(a,b,c,d,e,f,g,h,k){k=void 0===k?nop:k;var l;g&&(l=!0);a=new MenuMorph(b||null,a||"",c||null);var m=new StringFieldMorph(d||"",e||100,MorphicPreferences.prompterFontSize,MorphicPreferences.prompterFontName,!1,!1,l);a.items.push(m);if(g||MorphicPreferences.useSliderForInput)e=new SliderMorph(f||0,g,parseFloat(d),Math.floor((g-f)/4),"horizontal"),e.alpha=1,e.color=new Color(225,225,225),e.button.color=a.borderColor,e.button.highlightColor=e.button.color.copy(),e.button.highlightColor.b+= -100,e.button.pressColor=e.button.color.copy(),e.button.pressColor.b+=150,e.setHeight(MorphicPreferences.prompterSliderSize),e.action=h?function(n){m.changed();m.text.text=Math.round(n).toString();m.text.fixLayout();m.text.changed();m.text.edit();k(Math.round(n))}:function(n){m.changed();m.text.text=n.toString();m.text.fixLayout();m.text.changed();k(n)},a.items.push(e);a.addLine(2);a.addItem("Ok",function(){return m.string()});a.addItem("Cancel",function(){k(d);return null});a.isDraggable=!0;a.popUpAtHand(this.world()); -m.text.edit()};Morph.prototype.pickColor=function(a,b,c,d){a=new MenuMorph(b||null,a||"",c||null);var e=new ColorPickerMorph(d);a.items.push(e);a.addLine(2);a.addItem("Ok",function(){return e.getChoice()});a.addItem("Cancel",function(){return null});a.isDraggable=!0;a.popUpAtHand(this.world())}; -Morph.prototype.inspect=function(a){var b=this.world instanceof Function?this.world():this.root()||this.world,c=this;a&&(c=a);a=new InspectorMorph(c);a.setPosition(b.hand.position());a.keepWithin(b);b.add(a);a.changed()}; +Morph.prototype.prompt=function(a,b,c,d,e,f,g,h,k=nop){var l;g&&(l=!0);a=new MenuMorph(b||null,a||"",c||null);var m=new StringFieldMorph(d||"",e||100,MorphicPreferences.prompterFontSize,MorphicPreferences.prompterFontName,!1,!1,l);a.items.push(m);if(g||MorphicPreferences.useSliderForInput)e=new SliderMorph(f||0,g,parseFloat(d),Math.floor((g-f)/4),"horizontal"),e.alpha=1,e.color=new Color(225,225,225),e.button.color=a.borderColor,e.button.highlightColor=e.button.color.copy(),e.button.highlightColor.b+= +100,e.button.pressColor=e.button.color.copy(),e.button.pressColor.b+=150,e.setHeight(MorphicPreferences.prompterSliderSize),e.action=h?n=>{m.changed();m.text.text=Math.round(n).toString();m.text.fixLayout();m.text.changed();m.text.edit();k(Math.round(n))}:n=>{m.changed();m.text.text=n.toString();m.text.fixLayout();m.text.changed();k(n)},a.items.push(e);a.addLine(2);a.addItem("Ok",()=>m.string());a.addItem("Cancel",()=>{k(d);return null});a.isDraggable=!0;a.popUpAtHand(this.world());m.text.edit()}; +Morph.prototype.pickColor=function(a,b,c,d){a=new MenuMorph(b||null,a||"",c||null);var e=new ColorPickerMorph(d);a.items.push(e);a.addLine(2);a.addItem("Ok",()=>e.getChoice());a.addItem("Cancel",()=>null);a.isDraggable=!0;a.popUpAtHand(this.world())};Morph.prototype.inspect=function(a){var b=this.world instanceof Function?this.world():this.root()||this.world,c=this;a&&(c=a);a=new InspectorMorph(c);a.setPosition(b.hand.position());a.keepWithin(b);b.add(a);a.changed()}; Morph.prototype.inspectKeyEvent=function(a){this.inform("Key pressed: "+String.fromCharCode(a.charCode)+"\n------------------------\ncharCode: "+a.charCode.toString()+"\nkeyCode: "+a.keyCode.toString()+"\nkey: "+a.key.toString()+"\nshiftKey: "+a.shiftKey.toString()+"\naltKey: "+a.altKey.toString()+"\nctrlKey: "+a.ctrlKey.toString()+"\ncmdKey: "+a.metaKey.toString())}; Morph.prototype.contextMenu=function(){var a;return this.customContextMenu?this.customContextMenu:(a=this.world instanceof Function?this.world():this.world)&&a.isDevMode?this.parent===a?this.developersMenu():this.hierarchyMenu():this.userMenu()||this.parent&&this.parent.userMenu()}; -Morph.prototype.hierarchyMenu=function(){var a=this.allParents(),b=this.world instanceof Function?this.world():this.world,c=new MenuMorph(this,null);a.forEach(function(d){d.developersMenu&&d!==b&&c.addMenu(d.toString().slice(0,50),d.developersMenu())});return c}; -Morph.prototype.developersMenu=function(){var a=this,b=this.world instanceof Function?this.world():this.world,c=this.userMenu()||this.parent&&this.parent.userMenu(),d=new MenuMorph(this,this.constructor.name||this.constructor.toString().split(" ")[1].split("(")[0]);c&&(d.addMenu("user features",c),d.addLine());d.addItem("color...",function(){a.pickColor(d.title+localize("\ncolor:"),a.setColor,a,a.color)},"choose another color \nfor this morph");d.addItem("transparency...",function(){a.prompt(d.title+ -localize("\nalpha\nvalue:"),a.setAlphaScaled,a,(100*a.alpha).toString(),null,1,100,!0)},"set this morph's\nalpha value");d.addItem("resize...","resize","show a handle\nwhich can be dragged\nto change this morph's extent");d.addLine();d.addItem("duplicate",function(){return a.fullCopy().pickUp(a.world())},"make a copy\nand pick it up");d.addItem("pick up","pickUp","detach and put \ninto the hand");d.addItem("attach...","attach","stick this morph\nto another one");d.addItem("move...","move","show a handle\nwhich can be dragged\nto move this morph"); -d.addItem("inspect...","inspect","open a window\non all properties");d.addItem("pic...",function(){return window.open(a.fullImage().toDataURL())},"open a new window\nwith a picture of this morph");d.addLine();this.isDraggable?d.addItem("lock","toggleIsDraggable","make this morph\nunmovable"):d.addItem("unlock","toggleIsDraggable","make this morph\nmovable");d.addItem("hide","hide");d.addItem("delete","destroy");this instanceof WorldMorph||(d.addLine(),d.addItem("World...",function(){return b.contextMenu().popUpAtHand(b)}, -"show the\nWorld's menu"));return d};Morph.prototype.userMenu=function(){return null};Morph.prototype.addToDemoMenu=function(a){WorldMorph.prototype.customMorphs.push(a)};Morph.prototype.setAlphaScaled=function(a){"number"===typeof a?this.alpha=Math.min(Math.max(a/100,0),1):(a=parseFloat(a),isNaN(a)||(this.alpha=Math.min(Math.max(a/100,0),1)));this.changed()}; -Morph.prototype.attach=function(){var a=this,b=this.overlappedMorphs(),c=new MenuMorph(this,"choose new parent:");b.forEach(function(d){c.addItem(d.toString().slice(0,50),function(){d.add(a);a.isDraggable=!1})});0a+1?b[a+1]:b[0]};Morph.prototype.previousEntryField=function(a){var b=this.allEntryFields();a=b.indexOf(a);return-1!==a?0{d.developersMenu&&d!==b&&c.addMenu(d.toString().slice(0,50),d.developersMenu())});return c}; +Morph.prototype.developersMenu=function(){var a=this.world instanceof Function?this.world():this.world,b=this.userMenu()||this.parent&&this.parent.userMenu(),c=new MenuMorph(this,this.constructor.name||this.constructor.toString().split(" ")[1].split("(")[0]);b&&(c.addMenu("user features",b),c.addLine());c.addItem("color...",()=>{this.pickColor(c.title+localize("\ncolor:"),this.setColor,this,this.color)},"choose another color \nfor this morph");c.addItem("transparency...",()=>{this.prompt(c.title+ +localize("\nalpha\nvalue:"),this.setAlphaScaled,this,(100*this.alpha).toString(),null,1,100,!0)},"set this morph's\nalpha value");c.addItem("resize...","resize","show a handle\nwhich can be dragged\nto change this morph's extent");c.addLine();c.addItem("duplicate",()=>this.fullCopy().pickUp(this.world()),"make a copy\nand pick it up");c.addItem("pick up","pickUp","detach and put \ninto the hand");c.addItem("attach...","attach","stick this morph\nto another one");c.addItem("move...","move","show a handle\nwhich can be dragged\nto move this morph"); +c.addItem("inspect...","inspect","open a window\non all properties");c.addItem("pic...",()=>window.open(this.fullImage().toDataURL()),"open a new window\nwith a picture of this morph");c.addLine();this.isDraggable?c.addItem("lock","toggleIsDraggable","make this morph\nunmovable"):c.addItem("unlock","toggleIsDraggable","make this morph\nmovable");c.addItem("hide","hide");c.addItem("delete","destroy");this instanceof WorldMorph||(c.addLine(),c.addItem("World...",()=>a.contextMenu().popUpAtHand(a),"show the\nWorld's menu")); +return c};Morph.prototype.userMenu=function(){return null};Morph.prototype.addToDemoMenu=function(a){WorldMorph.prototype.customMorphs.push(a)};Morph.prototype.setAlphaScaled=function(a){"number"===typeof a?this.alpha=Math.min(Math.max(a/100,0),1):(a=parseFloat(a),isNaN(a)||(this.alpha=Math.min(Math.max(a/100,0),1)));this.changed()}; +Morph.prototype.attach=function(){var a=this.overlappedMorphs(),b=new MenuMorph(this,"choose new parent:");a.forEach(c=>{b.addItem(c.toString().slice(0,50),()=>{c.add(this);this.isDraggable=!1})});0a.isEditable&&(a instanceof StringMorph||a instanceof TextMorph))};Morph.prototype.nextEntryField=function(a){var b=this.allEntryFields();a=b.indexOf(a);return-1!==a&&b.length>a+1?b[a+1]:b[0]};Morph.prototype.previousEntryField=function(a){var b=this.allEntryFields();a=b.indexOf(a);return-1!==a?0b.width()||1>b.height())return!1;c=this.fullImage();var d=a.fullImage();c.isRetinaEnabled!==d.isRetinaEnabled&&(c=normalizeCanvas(c,!0),d=normalizeCanvas(d,!0));return[c.getContext("2d").getImageData(b.left()-this.left(),b.top()-this.top(),b.width(),b.height()).data,d.getContext("2d").getImageData(b.left()-a.left(),b.top()-a.top(),b.width(),b.height()).data]};ShadowMorph.prototype=new Morph; ShadowMorph.prototype.constructor=ShadowMorph;ShadowMorph.uber=Morph.prototype;function ShadowMorph(){this.init()}ShadowMorph.prototype.init=function(){ShadowMorph.uber.init.call(this);this.isCachingImage=!0};ShadowMorph.prototype.topMorphAt=function(){return null};HandleMorph.prototype=new Morph;HandleMorph.prototype.constructor=HandleMorph;HandleMorph.uber=Morph.prototype;function HandleMorph(a,b,c,d,e,f){this.init(a,b,c,d,e,f)} @@ -181,15 +127,15 @@ HandleMorph.prototype.render=function(a){"movePivot"===this.type?this.isHighligh HandleMorph.prototype.renderCrosshairsOn=function(a,b){var c=this.width()/2;a.fillStyle="rgba(255, 255, 255, 0.5)";a.beginPath();a.arc(c,c,.9*c,radians(0),radians(360),!1);a.fill();a.strokeStyle="black";a.lineWidth=1;a.beginPath();a.arc(c,c,c*b,radians(0),radians(360),!1);a.stroke();a.moveTo(0,c);a.lineTo(this.width(),c);a.stroke();a.moveTo(c,0);a.lineTo(c,this.height());a.stroke()}; HandleMorph.prototype.renderHandleOn=function(a,b,c){var d=0===this.type.indexOf("move"),e=new Point(0,this.height()),f=new Point(this.width(),0),g;a.lineWidth=1;a.lineCap="round";a.strokeStyle=b.toString();if(d){b=e.copy();var h=f.copy();for(g=0;g<=this.height();g+=6)b.y=e.y-g,h.y=f.y-g,a.beginPath(),a.moveTo(b.x,b.y),a.lineTo(h.x,h.y),a.closePath(),a.stroke()}b=e.copy();h=f.copy();for(g=0;g<=this.width();g+=6)b.x=e.x+g,h.x=f.x+g,a.beginPath(),a.moveTo(b.x,b.y),a.lineTo(h.x,h.y),a.closePath(),a.stroke(); a.strokeStyle=c.toString();if(d)for(b=e.copy(),h=f.copy(),g=-2;g<=this.height();g+=6)b.y=e.y-g,h.y=f.y-g,a.beginPath(),a.moveTo(b.x,b.y),a.lineTo(h.x,h.y),a.closePath(),a.stroke();b=e.copy();h=f.copy();for(g=2;g<=this.width();g+=6)b.x=e.x+g,h.x=f.x+g,a.beginPath(),a.moveTo(b.x,b.y),a.lineTo(h.x,h.y),a.closePath(),a.stroke()};HandleMorph.prototype.step=null; -HandleMorph.prototype.mouseDownLeft=function(a){var b=this,c=this.root();if(!this.target)return null;var d=0===this.type.indexOf("move")?a.subtract(this.center()):a.subtract(this.bounds.origin);this.step=function(){if(c.hand.mouseButton){var e=c.hand.bounds.origin.copy().subtract(d);"resize"===b.type?(e=e.add(b.extent().add(b.inset)).subtract(b.target.bounds.origin),e=e.max(b.minExtent),b.target.setExtent(e),b.setPosition(b.target.bottomRight().subtract(b.extent().add(b.inset)))):"moveCenter"===b.type? -b.target.setCenter(e):"movePivot"===b.type?(b.target.setPivot(e),b.setCenter(b.target.rotationCenter())):b.target.setPosition(e.subtract(b.target.extent()).add(b.extent()))}else b.step=null};this.target.step||(this.target.step=nop)};HandleMorph.prototype.rootForGrab=function(){return this};HandleMorph.prototype.mouseEnter=function(){this.isHighlighted=!0;this.changed()};HandleMorph.prototype.mouseLeave=function(){this.isHighlighted=!1;this.changed()}; -HandleMorph.prototype.attach=function(){var a=this,b=this.overlappedMorphs(),c=new MenuMorph(this,"choose target:");b.forEach(function(d){c.addItem(d.toString().slice(0,50),function(){a.isDraggable=!1;a.target=d;a.fixLayout()})});0{if(b.hand.mouseButton){var d=b.hand.bounds.origin.copy().subtract(c);"resize"===this.type?(d=d.add(this.extent().add(this.inset)).subtract(this.target.bounds.origin),d=d.max(this.minExtent),this.target.setExtent(d),this.setPosition(this.target.bottomRight().subtract(this.extent().add(this.inset)))): +"moveCenter"===this.type?this.target.setCenter(d):"movePivot"===this.type?(this.target.setPivot(d),this.setCenter(this.target.rotationCenter())):this.target.setPosition(d.subtract(this.target.extent()).add(this.extent()))}else this.step=null};this.target.step||(this.target.step=nop)};HandleMorph.prototype.rootForGrab=function(){return this};HandleMorph.prototype.mouseEnter=function(){this.isHighlighted=!0;this.changed()};HandleMorph.prototype.mouseLeave=function(){this.isHighlighted=!1;this.changed()}; +HandleMorph.prototype.attach=function(){var a=this.overlappedMorphs(),b=new MenuMorph(this,"choose target:");a.forEach(c=>{b.addItem(c.toString().slice(0,50),()=>{this.isDraggable=!1;this.target=c;this.fixLayout()})});0b;b.target=this;b.action="setHeading";a.items.push(b);a.addLine();a.addItem("(90) right",()=>this.setHeading(90));a.addItem("(-90) left",()=>this.setHeading(-90));a.addItem("(0) up",()=>this.setHeading(0));a.addItem("(180) down",()=>this.setHeading(180));a.isDraggable=!0;a.popUpAtHand(this.world())}; +PenMorph.prototype.drawLine=function(a,b){var c=this.parent.penTrails().getContext("2d"),d=a.subtract(this.parent.bounds.origin),e=b.subtract(this.parent.bounds.origin);this.isDown&&(c.lineWidth=this.size,c.strokeStyle=this.color.toString(),c.lineCap="round",c.lineJoin="round",c.beginPath(),c.moveTo(d.x,d.y),c.lineTo(e.x,e.y),c.stroke(),!1===this.isWarped&&this.world().broken.push(a.rectangle(b).expandBy(Math.max(this.size/2,1)).intersect(this.parent.visibleBounds()).spread()))}; PenMorph.prototype.turn=function(a){this.setHeading(this.heading+parseFloat(a))};PenMorph.prototype.forward=function(a){var b=this.center();a=parseFloat(a);a=0<=a?this.position().distanceAngle(a,this.heading):this.position().distanceAngle(Math.abs(a),this.heading-180);this.setPosition(a);this.drawLine(b,this.center())};PenMorph.prototype.down=function(){this.isDown=!0};PenMorph.prototype.up=function(){this.isDown=!1};PenMorph.prototype.clear=function(){this.parent.rerender()}; PenMorph.prototype.startWarp=function(){this.isWarped=!0};PenMorph.prototype.endWarp=function(){this.isWarped=!1;this.parent.changed()};PenMorph.prototype.warp=function(a){this.startWarp();a.call(this);this.endWarp()};PenMorph.prototype.warpOp=function(a,b){this.startWarp();this[a].apply(this,b);this.endWarp()};PenMorph.prototype.warpSierpinski=function(a,b){this.warpOp("sierpinski",[a,b])}; PenMorph.prototype.sierpinski=function(a,b){var c;if(a>b)for(c=0;3>c;c+=1)this.sierpinski(.5*a,b),this.turn(120),this.forward(a)};PenMorph.prototype.warpTree=function(a,b,c){this.warpOp("tree",[a,b,c])};PenMorph.prototype.tree=function(a,b,c){0{b.addItem(c.toString().slice(0,50),()=>{this.target=c;this.setTargetSetter()})});1===a.length?(this.target=a[0],this.setTargetSetter()):0{b.addItem(c,()=>this.targetSetter=c)});1===a.length?this.targetSetter=a[0]:0c.destroy());this.children=[];this.feedback=new Morph;this.feedback.color=this.choice;this.feedback.setExtent(new Point(20,20));var a=new ColorPaletteMorph(this.feedback,new Point(this.width(),50));var b=new GrayPaletteMorph(this.feedback,new Point(this.width(),5));a.setPosition(this.bounds.origin);this.add(a);b.setPosition(a.bottomLeft());this.add(b);a=b.left()+Math.floor((b.width()-this.feedback.width())/2);b=b.bottom()+Math.floor((this.bottom()- +b.bottom()-this.feedback.height())/2);this.feedback.setPosition(new Point(a,b));this.add(this.feedback)};ColorPickerMorph.prototype.getChoice=function(){return this.feedback.color};ColorPickerMorph.prototype.rootForGrab=function(){return this};BlinkerMorph.prototype=new Morph;BlinkerMorph.prototype.constructor=BlinkerMorph;BlinkerMorph.uber=Morph.prototype;function BlinkerMorph(a){this.init(a)} BlinkerMorph.prototype.init=function(a){BlinkerMorph.uber.init.call(this);this.color=new Color(0,0,0);this.fps=a||2};BlinkerMorph.prototype.step=function(){this.toggleVisibility()};CursorMorph.prototype=new BlinkerMorph;CursorMorph.prototype.constructor=CursorMorph;CursorMorph.uber=BlinkerMorph.prototype;CursorMorph.prototype.viewPadding=1;function CursorMorph(a,b){this.init(a,b)} CursorMorph.prototype.init=function(a,b){this.keyDownEventUsed=!1;this.target=a;this.originalContents=this.target.text;this.originalAlignment=this.target.alignment;this.slot=this.target.text.length;this.textarea=b;CursorMorph.uber.init.call(this);a=fontHeight(this.target.fontSize);this.setExtent(new Point(Math.max(Math.floor(a/20),1),a));this.target instanceof TextMorph&&"left"!==this.target.alignment&&this.target.setAlignmentToLeft();this.textarea.value=this.target.text;this.textarea.style.fontSize= this.target.fontSize+"px";this.gotoSlot(this.slot);this.updateTextAreaPosition();this.syncTextareaSelectionWith(this.target)}; @@ -219,8 +165,8 @@ CursorMorph.prototype.cancel=function(){var a=this.root();this.undo();a&&a.stopE BoxMorph.prototype=new Morph;BoxMorph.prototype.constructor=BoxMorph;BoxMorph.uber=Morph.prototype;function BoxMorph(a,b,c){this.init(a,b,c)}BoxMorph.prototype.init=function(a,b,c){this.edge=a||4;this.border=b||(0===b?0:2);this.borderColor=c||BLACK;BoxMorph.uber.init.call(this)}; BoxMorph.prototype.render=function(a){0===this.edge&&0===this.border?BoxMorph.uber.render.call(this,a):(a.fillStyle=this.color.toString(),a.beginPath(),this.outlinePath(a,Math.max(this.edge-this.border,0),this.border),a.closePath(),a.fill(),0{this.prompt(a.title+"\nborder\nwidth:",this.setBorderWidth,this,this.border.toString(),null,0,100,!0)},"set the border's\nline size");a.addItem("border color...",()=>{this.pickColor(a.title+"\nborder color:",this.setBorderColor,this,this.borderColor)},"set the border's\nline color");a.addItem("corner size...",()=>{this.prompt(a.title+"\ncorner\nsize:",this.setCornerSize, +this,this.edge.toString(),null,0,100,!0)},"set the corner's\nradius");return a};BoxMorph.prototype.setBorderWidth=function(a){"number"===typeof a?this.border=Math.max(a,0):(a=parseFloat(a),isNaN(a)||(this.border=Math.max(a,0)));this.changed()};BoxMorph.prototype.setBorderColor=function(a){a&&(this.borderColor=a,this.changed())};BoxMorph.prototype.setCornerSize=function(a){"number"===typeof a?this.edge=Math.max(a,0):(a=parseFloat(a),isNaN(a)||(this.edge=Math.max(a,0)));this.changed()}; BoxMorph.prototype.colorSetters=function(){return["color","borderColor"]};BoxMorph.prototype.numericalSetters=function(){var a=BoxMorph.uber.numericalSetters.call(this);a.push("setBorderWidth","setCornerSize");return a};SpeechBubbleMorph.prototype=new BoxMorph;SpeechBubbleMorph.prototype.constructor=SpeechBubbleMorph;SpeechBubbleMorph.uber=BoxMorph.prototype;function SpeechBubbleMorph(a,b,c,d,e,f,g,h){this.init(a,b,c,d,e,f,g,h)} SpeechBubbleMorph.prototype.init=function(a,b,c,d,e,f,g,h){this.isPointingRight=!0;this.contents=a||"";this.padding=f||0;this.isThought=g||!1;this.isClickable=!1;SpeechBubbleMorph.uber.init.call(this,c||6,d||(0===d?0:1),e||new Color(140,140,140));this.hasShadow=!0!==h;this.noDropShadow=!0;this.fullShadowSource=!1;this.color=b||new Color(230,230,230);this.fixLayout()}; SpeechBubbleMorph.prototype.popUp=function(a,b,c){this.fixLayout();this.setPosition(b.subtract(new Point(0,this.height())));this.keepWithin(a);a.add(this);this.fullChanged();a.hand.destroyTemporaries();a.hand.temporaries.push(this);c?this.isClickable=!0:this.mouseEnter=this.destroy}; @@ -237,11 +183,11 @@ DialMorph.prototype.render=function(a){var b,c=this.color.lighter().toString(),d a.beginPath();a.arc(this.radius,this.radius,f,Math.PI/-2,k,!1);a.lineTo(this.radius,this.radius);a.closePath();a.fill();a.strokeStyle=(new Color(35,35,35)).toString();a.lineWidth=1;for(b=0;b{b.hand.mouseButton?this.setValue(this.getValueOf(b.hand.bounds.origin),16!==b.currentKey):this.step=null}}; DialMorph.prototype.developersMenu=function(){var a=DialMorph.uber.developersMenu.call(this);a.addLine();a.addItem("set target","setTarget","select another morph\nwhose numerical property\nwill be controlled by this one");return a}; -DialMorph.prototype.setTarget=function(){var a=this,b=this.overlappedMorphs(),c=new MenuMorph(this,"choose target:");b.push(this.world());b.forEach(function(d){c.addItem(d.toString().slice(0,50),function(){a.target=d;a.setTargetSetter()})});1===b.length?(this.target=b[0],this.setTargetSetter()):0this.width()?this.orientation="vertical":this.orientation="horizontal"}; +DialMorph.prototype.setTarget=function(){var a=this.overlappedMorphs(),b=new MenuMorph(this,"choose target:");a.push(this.world());a.forEach(c=>{b.addItem(c.toString().slice(0,50),()=>{this.target=c;this.setTargetSetter()})});1===a.length?(this.target=a[0],this.setTargetSetter()):0{b.addItem(c,()=>this.action=c)});1===a.length?this.action=a[0]:0this.width()?this.orientation="vertical":this.orientation="horizontal"}; CircleBoxMorph.prototype.render=function(a){var b=this.width(),c=this.height();this.autoOrient&&this.autoOrientation();if("vertical"===this.orientation){var d=b/2;a.beginPath();a.arc(d,d,d,radians(180),radians(0),!1);a.lineTo(b,c-d);a.arc(d,c-d,d,radians(0),radians(180),!1)}else d=c/2,a.beginPath(),a.arc(d,d,d,radians(90),radians(-90),!1),a.lineTo(b-d,0),a.arc(b-d,d,d,radians(-90),radians(90),!1);a.closePath();a.fillStyle=this.color.toString();a.fill()}; CircleBoxMorph.prototype.developersMenu=function(){var a=CircleBoxMorph.uber.developersMenu.call(this);a.addLine();"vertical"===this.orientation?a.addItem("horizontal...","toggleOrientation","toggle the\norientation"):a.addItem("vertical...","toggleOrientation","toggle the\norientation");return a}; CircleBoxMorph.prototype.toggleOrientation=function(){var a=this.center();this.changed();this.orientation="vertical"===this.orientation?"horizontal":"vertical";this.setExtent(new Point(this.height(),this.width()));this.setCenter(a)};SliderButtonMorph.prototype=new CircleBoxMorph;SliderButtonMorph.prototype.constructor=SliderButtonMorph;SliderButtonMorph.uber=CircleBoxMorph.prototype;function SliderButtonMorph(a){this.init(a)} @@ -259,52 +205,50 @@ SliderMorph.prototype.fixLayout=function(){this.button.orientation=this.orientat this.start)*this.unitSize()),this.width()-this.button.width()),0);this.button.setPosition((new Point(a,b)).add(this.bounds.origin));for(var c=this.tickMarks.length;c--;)a=this.tickMarks[c],"vertical"===this.orientation?(b=Math.min(Math.round((a.value-this.start)*this.unitSize(a.size)),this.height()-a.size-this.width()/2),b=Math.max(this.width()/2,b),a.setWidth(this.width()),a.setHeight(a.size),a.setPosition(new Point(this.left(),b+this.top()))):(b=Math.min(Math.round((a.value-this.start)*this.unitSize(a.size)), this.width()-a.size-this.height()/2),b=Math.max(this.height()/2,b),a.setWidth(a.size),a.setHeight(this.height()),a.setPosition(new Point(b+this.left(),this.top())))};SliderMorph.prototype.updateValue=function(){var a="vertical"===this.orientation?this.button.top()-this.top():this.button.left()-this.left();this.value=Math.round(a/this.unitSize()+this.start);this.updateTarget()}; SliderMorph.prototype.updateTarget=function(){if(this.action)if("function"===typeof this.action)this.action.call(this.target,this.value);else this.target[this.action](this.value)};SliderMorph.prototype.addTick=function(a,b,c){var d=new Morph;c=c||2;b=b||this.color.darker();d.value=a;d.color=b;d.size=c;this.addBack(d);this.tickMarks.push(d);return d};SliderMorph.prototype.clearTicks=function(){for(var a=this.tickMarks.length;a--;)this.tickMarks[a].destroy();this.tickMarks=[];this.changed()}; -SliderMorph.prototype.developersMenu=function(){var a=this,b=SliderMorph.uber.developersMenu.call(this);b.addItem("show value...","showValue","display a dialog box\nshowing the selected number");b.addItem("floor...",function(){a.prompt(b.title+"\nfloor:",a.setStart,a,a.start.toString(),null,0,a.stop-a.size,!0)},"set the minimum value\nwhich can be selected");b.addItem("ceiling...",function(){a.prompt(b.title+"\nceiling:",a.setStop,a,a.stop.toString(),null,a.start+a.size,100*a.size,!0)},"set the maximum value\nwhich can be selected"); -b.addItem("button size...",function(){a.prompt(b.title+"\nbutton size:",a.setSize,a,a.size.toString(),null,1,a.stop-a.start,!0)},"set the range\ncovered by\nthe slider button");b.addLine();b.addItem("set target","setTarget","select another morph\nwhose numerical property\nwill be controlled by this one");return b};SliderMorph.prototype.showValue=function(){this.inform(this.value)};SliderMorph.prototype.userSetStart=function(a){this.start=Math.max(a,this.stop)}; -SliderMorph.prototype.setStart=function(a,b){"number"===typeof a?this.start=Math.min(a,this.stop-this.size):(a=parseFloat(a),isNaN(a)||(this.start=Math.min(a,this.stop-this.size)));this.value=Math.max(this.value,this.start);b||this.updateTarget();this.fixLayout();this.rerender()}; +SliderMorph.prototype.developersMenu=function(){var a=SliderMorph.uber.developersMenu.call(this);a.addItem("show value...","showValue","display a dialog box\nshowing the selected number");a.addItem("floor...",()=>{this.prompt(a.title+"\nfloor:",this.setStart,this,this.start.toString(),null,0,this.stop-this.size,!0)},"set the minimum value\nwhich can be selected");a.addItem("ceiling...",()=>{this.prompt(a.title+"\nceiling:",this.setStop,this,this.stop.toString(),null,this.start+this.size,100*this.size, +!0)},"set the maximum value\nwhich can be selected");a.addItem("button size...",()=>{this.prompt(a.title+"\nbutton size:",this.setSize,this,this.size.toString(),null,1,this.stop-this.start,!0)},"set the range\ncovered by\nthe slider button");a.addLine();a.addItem("set target","setTarget","select another morph\nwhose numerical property\nwill be controlled by this one");return a};SliderMorph.prototype.showValue=function(){this.inform(this.value)}; +SliderMorph.prototype.userSetStart=function(a){this.start=Math.max(a,this.stop)};SliderMorph.prototype.setStart=function(a,b){"number"===typeof a?this.start=Math.min(a,this.stop-this.size):(a=parseFloat(a),isNaN(a)||(this.start=Math.min(a,this.stop-this.size)));this.value=Math.max(this.value,this.start);b||this.updateTarget();this.fixLayout();this.rerender()}; SliderMorph.prototype.setStop=function(a,b){"number"===typeof a?this.stop=Math.max(a,this.start+this.size):(a=parseFloat(a),isNaN(a)||(this.stop=Math.max(a,this.start+this.size)));this.value=Math.min(this.value,this.stop);b||this.updateTarget();this.fixLayout();this.rerender()}; SliderMorph.prototype.setSize=function(a,b){"number"===typeof a?this.size=Math.min(Math.max(a,1),this.stop-this.start):(a=parseFloat(a),isNaN(a)||(this.size=Math.min(Math.max(a,1),this.stop-this.start)));this.value=Math.min(this.value,this.stop-this.size);b||this.updateTarget();this.fixLayout();this.rerender()}; -SliderMorph.prototype.setTarget=function(){var a=this,b=this.overlappedMorphs(),c=new MenuMorph(this,"choose target:");b.push(this.world());b.forEach(function(d){c.addItem(d.toString().slice(0,50),function(){a.target=d;a.setTargetSetter()})});1===b.length?(this.target=b[0],this.setTargetSetter()):0a.alpha&&(a.alpha+=a.upStep):a.alpha>a.downStep?a.alpha-=a.downStep:(a.alpha=0,a.step=null);a.changed()})};MouseSensorMorph.prototype.unTouch=function(){this.isTouched=!1};MouseSensorMorph.prototype.mouseEnter=function(){this.touch()};MouseSensorMorph.prototype.mouseLeave=function(){this.unTouch()};MouseSensorMorph.prototype.mouseDownLeft=function(){this.touch()}; +SliderMorph.prototype.setTarget=function(){var a=this.overlappedMorphs(),b=new MenuMorph(this,"choose target:");a.push(this.world());a.forEach(c=>{b.addItem(c.toString().slice(0,50),()=>{this.target=c;this.setTargetSetter()})});1===a.length?(this.target=a[0],this.setTargetSetter()):0{b.addItem(c,()=>this.action=c)});1===a.length?this.action=a[0]:0{if(b.hand.mouseButton){var c=b.hand.bounds.origin;if("vertical"===this.orientation){var d=this.button.bounds.origin.x;var e=Math.max(Math.min(c.y-this.offset.y,this.bottom()-this.button.height()),this.top())}else e=this.button.bounds.origin.y,d=Math.max(Math.min(c.x-this.offset.x,this.right()-this.button.width()), +this.left());this.button.setPosition(new Point(d,e));this.updateValue()}else this.step=null}};MouseSensorMorph.prototype=new BoxMorph;MouseSensorMorph.prototype.constructor=MouseSensorMorph;MouseSensorMorph.uber=BoxMorph.prototype;function MouseSensorMorph(a,b,c){this.init(a,b,c)}MouseSensorMorph.prototype.init=function(a,b,c){MouseSensorMorph.uber.init.call(this);this.edge=a||4;this.border=b||2;this.color=WHITE;this.borderColor=c||BLACK;this.isTouched=!1;this.upStep=.05;this.downStep=.02}; +MouseSensorMorph.prototype.touch=function(){this.isTouched||(this.isTouched=!0,this.alpha=.6,this.step=()=>{this.isTouched?1>this.alpha&&(this.alpha+=this.upStep):this.alpha>this.downStep?this.alpha-=this.downStep:(this.alpha=0,this.step=null);this.changed()})};MouseSensorMorph.prototype.unTouch=function(){this.isTouched=!1};MouseSensorMorph.prototype.mouseEnter=function(){this.touch()};MouseSensorMorph.prototype.mouseLeave=function(){this.unTouch()};MouseSensorMorph.prototype.mouseDownLeft=function(){this.touch()}; MouseSensorMorph.prototype.mouseClickLeft=function(){this.unTouch()};InspectorMorph.prototype=new BoxMorph;InspectorMorph.prototype.constructor=InspectorMorph;InspectorMorph.uber=BoxMorph.prototype;function InspectorMorph(a){this.init(a)} InspectorMorph.prototype.init=function(a){this.target=a;this.currentProperty=null;this.showing="attributes";this.hasUserEditedDetails=this.markOwnProperties=!1;InspectorMorph.uber.init.call(this);this.isDraggable=!0;this.border=1;this.edge=MorphicPreferences.isFlat?1:5;this.color=new Color(60,60,60);this.borderColor=new Color(95,95,95);this.fps=25;this.resizer=this.buttonEdit=this.buttonSubset=this.buttonClose=this.buttonInspect=this.work=this.detail=this.list=this.label=null;this.target&&this.buildPanes(); this.setExtent(new Point(20*MorphicPreferences.handleSize,40*MorphicPreferences.handleSize/3))};InspectorMorph.prototype.setTarget=function(a){this.target=a;this.currentProperty=null;this.buildPanes()}; InspectorMorph.prototype.updateCurrentSelection=function(){var a=this.list.selected;var b=this.detail.contents.children[0];var c=this.root();c&&c.keyboardFocus instanceof CursorMorph&&c.keyboardFocus.target===b?this.hasUserEditedDetails=!0:isNil(a)||this.hasUserEditedDetails||(this.currentProperty=a=this.target[a],a=isNil(a)?"NULL":isString(a)?a:a.toString(),b.text!==a&&(b=new TextMorph(a),b.isEditable=!0,b.enableSelecting(),b.setReceiver(this.target),this.detail.setContents(b)))}; -InspectorMorph.prototype.buildPanes=function(){var a=this,b=[],c;this.children.forEach(function(d){d!==a.work&&d.destroy()});this.children=[];this.label=new TextMorph(this.target.toString());this.label.fontSize=MorphicPreferences.menuFontSize;this.label.isBold=!0;this.label.color=WHITE;this.add(this.label);for(c in this.target)c&&b.push(c);"attributes"===this.showing?b=b.filter(function(d){return"function"!==typeof a.target[d]}):"methods"===this.showing&&(b=b.filter(function(d){return"function"=== -typeof a.target[d]}));this.list=new ListMorph(this.target instanceof Array?b:b.sort(),null,this.markOwnProperties?[[new Color(0,0,180),function(d){return Object.prototype.hasOwnProperty.call(a.target,d)}]]:null,function(){if(isObject(a.currentProperty)){var d=a.world();var e=new InspectorMorph(a.currentProperty);e.setPosition(d.hand.position());e.keepWithin(d);d.add(e);e.changed()}});this.list.action=function(){a.hasUserEditedDetails=!1;a.updateCurrentSelection()};this.list.hBar.alpha=.6;this.list.vBar.alpha= -.6;this.list.contents.step=null;this.add(this.list);this.detail=new ScrollFrameMorph;this.detail.acceptsDrops=!1;this.detail.contents.acceptsDrops=!1;this.detail.isTextLineWrapping=!0;this.detail.color=WHITE;this.detail.hBar.alpha=.6;this.detail.vBar.alpha=.6;b=new TextMorph("");b.isEditable=!0;b.enableSelecting();b.setReceiver(this.target);this.detail.setContents(b);this.add(this.detail);null===this.work&&(this.work=new ScrollFrameMorph,this.work.acceptsDrops=!1,this.work.contents.acceptsDrops=!1, -this.work.isTextLineWrapping=!0,this.work.color=WHITE,this.work.hBar.alpha=.6,this.work.vBar.alpha=.6,b=new TextMorph(""),b.isEditable=!0,b.enableSelecting(),b.setReceiver(this.target),this.work.setContents(b));this.add(this.work);this.buttonSubset=new TriggerMorph;this.buttonSubset.labelString="show...";this.buttonSubset.createLabel();this.buttonSubset.action=function(){var d=new MenuMorph;d.addItem("attributes",function(){a.showing="attributes";a.buildPanes()});d.addItem("methods",function(){a.showing= -"methods";a.buildPanes()});d.addItem("all",function(){a.showing="all";a.buildPanes()});d.addLine();d.addItem(a.markOwnProperties?"un-mark own":"mark own",function(){a.markOwnProperties=!a.markOwnProperties;a.buildPanes()},"highlight\n'own' properties");d.popUpAtHand(a.world())};this.add(this.buttonSubset);this.buttonInspect=new TriggerMorph;this.buttonInspect.labelString="inspect...";this.buttonInspect.createLabel();this.buttonInspect.action=function(){var d,e;if(isObject(a.currentProperty)){var f= -new MenuMorph;f.addItem("in new inspector...",function(){d=a.world();e=new InspectorMorph(a.currentProperty);e.setPosition(d.hand.position());e.keepWithin(d);d.add(e);e.changed()});f.addItem("here...",function(){return a.setTarget(a.currentProperty)});f.popUpAtHand(a.world())}else a.inform((null===a.currentProperty?"null":typeof a.currentProperty)+"\nis not inspectable")};this.add(this.buttonInspect);this.buttonEdit=new TriggerMorph;this.buttonEdit.labelString="edit...";this.buttonEdit.createLabel(); -this.buttonEdit.action=function(){var d=new MenuMorph(a);d.addItem("save","save","accept changes");d.addLine();d.addItem("add property...","addProperty");d.addItem("rename...","renameProperty");d.addItem("remove...","removeProperty");d.popUpAtHand(a.world())};this.add(this.buttonEdit);this.buttonClose=new TriggerMorph;this.buttonClose.labelString="close";this.buttonClose.createLabel();this.buttonClose.action=function(){return a.destroy()};this.add(this.buttonClose);this.resizer=new HandleMorph(this, -150,100,this.edge,this.edge);this.fixLayout()}; +InspectorMorph.prototype.buildPanes=function(){var a=[],b;this.children.forEach(c=>{c!==this.work&&c.destroy()});this.children=[];this.label=new TextMorph(this.target.toString());this.label.fontSize=MorphicPreferences.menuFontSize;this.label.isBold=!0;this.label.color=WHITE;this.add(this.label);for(b in this.target)b&&a.push(b);"attributes"===this.showing?a=a.filter(c=>"function"!==typeof this.target[c]):"methods"===this.showing&&(a=a.filter(c=>"function"===typeof this.target[c]));this.list=new ListMorph(this.target instanceof +Array?a:a.sort(),null,this.markOwnProperties?[[new Color(0,0,180),c=>Object.prototype.hasOwnProperty.call(this.target,c)]]:null,()=>{if(isObject(this.currentProperty)){var c=this.world();var d=new InspectorMorph(this.currentProperty);d.setPosition(c.hand.position());d.keepWithin(c);c.add(d);d.changed()}});this.list.action=()=>{this.hasUserEditedDetails=!1;this.updateCurrentSelection()};this.list.hBar.alpha=.6;this.list.vBar.alpha=.6;this.list.contents.step=null;this.add(this.list);this.detail=new ScrollFrameMorph; +this.detail.acceptsDrops=!1;this.detail.contents.acceptsDrops=!1;this.detail.isTextLineWrapping=!0;this.detail.color=WHITE;this.detail.hBar.alpha=.6;this.detail.vBar.alpha=.6;a=new TextMorph("");a.isEditable=!0;a.enableSelecting();a.setReceiver(this.target);this.detail.setContents(a);this.add(this.detail);null===this.work&&(this.work=new ScrollFrameMorph,this.work.acceptsDrops=!1,this.work.contents.acceptsDrops=!1,this.work.isTextLineWrapping=!0,this.work.color=WHITE,this.work.hBar.alpha=.6,this.work.vBar.alpha= +.6,a=new TextMorph(""),a.isEditable=!0,a.enableSelecting(),a.setReceiver(this.target),this.work.setContents(a));this.add(this.work);this.buttonSubset=new TriggerMorph;this.buttonSubset.labelString="show...";this.buttonSubset.createLabel();this.buttonSubset.action=()=>{var c=new MenuMorph;c.addItem("attributes",()=>{this.showing="attributes";this.buildPanes()});c.addItem("methods",()=>{this.showing="methods";this.buildPanes()});c.addItem("all",()=>{this.showing="all";this.buildPanes()});c.addLine(); +c.addItem(this.markOwnProperties?"un-mark own":"mark own",()=>{this.markOwnProperties=!this.markOwnProperties;this.buildPanes()},"highlight\n'own' properties");c.popUpAtHand(this.world())};this.add(this.buttonSubset);this.buttonInspect=new TriggerMorph;this.buttonInspect.labelString="inspect...";this.buttonInspect.createLabel();this.buttonInspect.action=()=>{var c,d;if(isObject(this.currentProperty)){var e=new MenuMorph;e.addItem("in new inspector...",()=>{c=this.world();d=new InspectorMorph(this.currentProperty); +d.setPosition(c.hand.position());d.keepWithin(c);c.add(d);d.changed()});e.addItem("here...",()=>this.setTarget(this.currentProperty));e.popUpAtHand(this.world())}else this.inform((null===this.currentProperty?"null":typeof this.currentProperty)+"\nis not inspectable")};this.add(this.buttonInspect);this.buttonEdit=new TriggerMorph;this.buttonEdit.labelString="edit...";this.buttonEdit.createLabel();this.buttonEdit.action=()=>{var c=new MenuMorph(this);c.addItem("save","save","accept changes");c.addLine(); +c.addItem("add property...","addProperty");c.addItem("rename...","renameProperty");c.addItem("remove...","removeProperty");c.popUpAtHand(this.world())};this.add(this.buttonEdit);this.buttonClose=new TriggerMorph;this.buttonClose.labelString="close";this.buttonClose.createLabel();this.buttonClose.action=()=>this.destroy();this.add(this.buttonClose);this.resizer=new HandleMorph(this,150,100,this.edge,this.edge);this.fixLayout()}; InspectorMorph.prototype.fixLayout=function(){var a=this.left()+this.edge;var b=this.top()+this.edge;var c=this.right()-this.edge;c-=a;this.label.setPosition(new Point(a,b));this.label.setWidth(c);this.label.height()>this.height()-50&&this.bounds.setHeight(this.label.height()+50);b=this.label.bottom()+2;c=Math.min(Math.floor(this.width()/3),this.list.listContents.width());c-=this.edge;var d=this.bottom()-2*this.edge-MorphicPreferences.handleSize-b;this.list.setPosition(new Point(a,b));this.list.setExtent(new Point(c, d));a=this.list.right()+this.edge;c=this.right()-this.edge;c-=a;this.detail.setPosition(new Point(a,b));this.detail.setExtent(new Point(c,2*d/3-this.edge));b=this.detail.bottom()+this.edge;this.work.setPosition(new Point(a,b));this.work.setExtent(new Point(c,d/3));a=this.list.left();b=this.list.bottom()+this.edge;c=this.list.width();d=MorphicPreferences.handleSize;this.buttonSubset.setPosition(new Point(a,b));this.buttonSubset.setExtent(new Point(c,d));a=this.detail.left();c=this.detail.width()-this.edge- MorphicPreferences.handleSize;c=c/3-this.edge/3;this.buttonInspect.setPosition(new Point(a,b));this.buttonInspect.setExtent(new Point(c,d));a=this.buttonInspect.right()+this.edge;this.buttonEdit.setPosition(new Point(a,b));this.buttonEdit.setExtent(new Point(c,d));a=this.buttonEdit.right()+this.edge;c=this.detail.right()-this.edge-MorphicPreferences.handleSize;c-=a;this.buttonClose.setPosition(new Point(a,b));this.buttonClose.setExtent(new Point(c,d));this.resizer.fixLayout()}; -InspectorMorph.prototype.save=function(){var a=this.detail.contents.children[0].text.toString(),b=this.list.selected;try{this.target.evaluateString("this."+b+" = "+a),this.hasUserEditedDetails=!1,this.target.changed()}catch(c){this.inform(c)}};InspectorMorph.prototype.addProperty=function(){var a=this;this.prompt("new property name:",function(b){b&&(a.target[b]=null,a.buildPanes(),a.target.changed())},this,"property")}; -InspectorMorph.prototype.renameProperty=function(){var a=this,b=this.list.selected;this.prompt("property name:",function(c){try{delete a.target[b],a.target[c]=a.currentProperty}catch(d){a.inform(d)}a.buildPanes();a.target.changed()},this,b)};InspectorMorph.prototype.removeProperty=function(){var a=this.list.selected;try{delete this.target[a],this.currentProperty=null,this.buildPanes(),this.target.changed()}catch(b){this.inform(b)}}; +InspectorMorph.prototype.save=function(){var a=this.detail.contents.children[0].text.toString(),b=this.list.selected;try{this.target.evaluateString("this."+b+" = "+a),this.hasUserEditedDetails=!1,this.target.changed()}catch(c){this.inform(c)}};InspectorMorph.prototype.addProperty=function(){this.prompt("new property name:",a=>{a&&(this.target[a]=null,this.buildPanes(),this.target.changed())},this,"property")}; +InspectorMorph.prototype.renameProperty=function(){var a=this.list.selected;this.prompt("property name:",b=>{try{delete this.target[a],this.target[b]=this.currentProperty}catch(c){this.inform(c)}this.buildPanes();this.target.changed()},this,a)};InspectorMorph.prototype.removeProperty=function(){var a=this.list.selected;try{delete this.target[a],this.currentProperty=null,this.buildPanes(),this.target.changed()}catch(b){this.inform(b)}}; InspectorMorph.prototype.step=function(){this.updateCurrentSelection();var a=this.target.toString();this.label.text!==a&&(this.label.text=a,this.fixLayout())};InspectorMorph.prototype.updateReferences=function(a){var b=this.list.activeIndex();InspectorMorph.uber.updateReferences.call(this,a);this.buildPanes();this.list.activateIndex(b)};MenuMorph.prototype=new BoxMorph;MenuMorph.prototype.constructor=MenuMorph;MenuMorph.uber=BoxMorph.prototype;function MenuMorph(a,b,c,d){this.init(a,b,c,d)} MenuMorph.prototype.init=function(a,b,c,d){this.target=a;this.title=b||null;this.environment=c||null;this.fontSize=d||null;this.items=[];this.world=this.label=null;this.hasFocus=this.isListContents=!1;this.submenu=this.selection=null;MenuMorph.uber.init.call(this);this.isDraggable=!1;this.noDropShadow=!0;this.fullShadowSource=!1;this.edge=this.border=null};MenuMorph.prototype.addItem=function(a,b,c,d,e,f,g,h,k){this.items.push([k?a||"close":localize(a||"close"),b||nop,c,d,e||!1,f||!1,g,h,k])}; MenuMorph.prototype.addMenu=function(a,b,c,d){this.addPair(a,b,isNil(c)?"\u25ba":c,null,d)};MenuMorph.prototype.addPair=function(a,b,c,d,e){this.addItem(a,b,d,null,null,null,null,c,e)};MenuMorph.prototype.addLine=function(a){this.items.push([0,a||1])}; MenuMorph.prototype.createLabel=function(){null!==this.label&&this.label.destroy();var a=new TextMorph(localize(this.title),this.fontSize||MorphicPreferences.menuFontSize,MorphicPreferences.menuFontName,!0,!1,"center");a.alignment="center";a.color=WHITE;a.backgroundColor=this.borderColor;a.fixLayout();this.label=new BoxMorph(3,0);MorphicPreferences.isFlat&&(this.label.edge=0);this.label.color=this.borderColor;this.label.borderColor=this.borderColor;this.label.setExtent(a.extent().add(4));this.label.add(a); this.label.text=a}; -MenuMorph.prototype.createItems=function(){var a=this,b,c=!1;this.children.forEach(function(g){return g.destroy()});this.children=[];this.isListContents||(this.edge=MorphicPreferences.isFlat?0:5,this.border=MorphicPreferences.isFlat?1:2);this.color=WHITE;this.borderColor=new Color(60,60,60);this.setExtent(new Point(0,0));var d=2;var e=this.left()+4;this.isListContents||(this.title?(this.createLabel(),this.label.setPosition(this.bounds.origin.add(4)),this.add(this.label),d=this.label.bottom()):d=this.top()+ -4);d+=1;this.items.forEach(function(g){c=!1;g instanceof StringFieldMorph||g instanceof ColorPickerMorph||g instanceof SliderMorph||g instanceof DialMorph?b=g:0===g[0]?(c=!0,b=new Morph,b.color=a.borderColor,b.setHeight(g[1])):b=new MenuItemMorph(a.target,g[1],g[0],a.fontSize||MorphicPreferences.menuFontSize,MorphicPreferences.menuFontName,a.environment,g[2],g[3],g[4],g[5],g[6],g[7]);c&&(d+=1);b.setPosition(new Point(e,d));a.add(b);d+=b.height();c&&(d+=1)});var f=this.fullBounds();this.setExtent(f.extent().add(4)); -this.adjustWidths()}; -MenuMorph.prototype.maxWidth=function(){var a=0;this.parent instanceof FrameMorph&&this.parent.scrollFrame instanceof ScrollFrameMorph&&(a=this.parent.scrollFrame.width());this.children.forEach(function(b){if(b instanceof MenuItemMorph)a=Math.max(a,b.label.width()+8+(b.shortcut?b.shortcut.width()+4:0));else if(b instanceof StringFieldMorph||b instanceof ColorPickerMorph||b instanceof SliderMorph||b instanceof DialMorph)a=Math.max(a,b.width())});this.label&&(a=Math.max(a,this.label.width()));return a}; -MenuMorph.prototype.adjustWidths=function(){var a=this,b=this.maxWidth();this.children.forEach(function(c){c instanceof DialMorph||c.setWidth(b);c.fixLayout();c===a.label&&c.text.setPosition(c.center().subtract(c.text.extent().floorDivideBy(2)))})}; -MenuMorph.prototype.unselectAllItems=function(){this.children.forEach(function(a){a instanceof MenuItemMorph?"normal"!==a.userState&&(a.userState="normal",a.rerender()):a instanceof ScrollFrameMorph&&a.contents.children.forEach(function(b){b instanceof MenuItemMorph&&"normal"!==b.userState&&(b.userState="normal",b.rerender())})})}; +MenuMorph.prototype.createItems=function(){var a,b=!1;this.children.forEach(f=>f.destroy());this.children=[];this.isListContents||(this.edge=MorphicPreferences.isFlat?0:5,this.border=MorphicPreferences.isFlat?1:2);this.color=WHITE;this.borderColor=new Color(60,60,60);this.setExtent(new Point(0,0));var c=2;var d=this.left()+4;this.isListContents||(this.title?(this.createLabel(),this.label.setPosition(this.bounds.origin.add(4)),this.add(this.label),c=this.label.bottom()):c=this.top()+4);c+=1;this.items.forEach(f=> +{b=!1;f instanceof StringFieldMorph||f instanceof ColorPickerMorph||f instanceof SliderMorph||f instanceof DialMorph?a=f:0===f[0]?(b=!0,a=new Morph,a.color=this.borderColor,a.setHeight(f[1])):a=new MenuItemMorph(this.target,f[1],f[0],this.fontSize||MorphicPreferences.menuFontSize,MorphicPreferences.menuFontName,this.environment,f[2],f[3],f[4],f[5],f[6],f[7]);b&&(c+=1);a.setPosition(new Point(d,c));this.add(a);c+=a.height();b&&(c+=1)});var e=this.fullBounds();this.setExtent(e.extent().add(4));this.adjustWidths()}; +MenuMorph.prototype.maxWidth=function(){var a=0;this.parent instanceof FrameMorph&&this.parent.scrollFrame instanceof ScrollFrameMorph&&(a=this.parent.scrollFrame.width());this.children.forEach(b=>{if(b instanceof MenuItemMorph)a=Math.max(a,b.label.width()+8+(b.shortcut?b.shortcut.width()+4:0));else if(b instanceof StringFieldMorph||b instanceof ColorPickerMorph||b instanceof SliderMorph||b instanceof DialMorph)a=Math.max(a,b.width())});this.label&&(a=Math.max(a,this.label.width()));return a}; +MenuMorph.prototype.adjustWidths=function(){var a=this.maxWidth();this.children.forEach(b=>{b instanceof DialMorph||b.setWidth(a);b.fixLayout();b===this.label&&b.text.setPosition(b.center().subtract(b.text.extent().floorDivideBy(2)))})}; +MenuMorph.prototype.unselectAllItems=function(){this.children.forEach(a=>{a instanceof MenuItemMorph?"normal"!==a.userState&&(a.userState="normal",a.rerender()):a instanceof ScrollFrameMorph&&a.contents.children.forEach(b=>{b instanceof MenuItemMorph&&"normal"!==b.userState&&(b.userState="normal",b.rerender())})})}; MenuMorph.prototype.popup=function(a,b){this.createItems();this.setPosition(b);this.addShadow(new Point(2,2),80);this.keepWithin(a);this.bottom()>a.bottom()&&(this.removeShadow(),b=this.scroll(),this.bounds.corner.y=a.bottom()-2,this.addShadow(new Point(2,2),80),b.setHeight(a.bottom()-b.top()-6),b.adjustScrollBars());a.activeMenu&&a.activeMenu.destroy();1>this.items.length&&!this.title||(a.add(this),a.activeMenu=this,this.world=a,this.fullChanged())}; -MenuMorph.prototype.scroll=function(){var a=new ScrollFrameMorph,b=this.label?1:0,c=this.children[b];a.setPosition(c.position());this.children.slice(b).forEach(function(d){return a.addContents(d)});this.add(a);a.setWidth(c.width());return a};MenuMorph.prototype.popUpAtHand=function(a){a=a||this.world;this.popup(a,a.hand.position())};MenuMorph.prototype.popUpCenteredAtHand=function(a){a=a||this.world;this.fixLayout();this.popup(a,a.hand.position().subtract(this.extent().floorDivideBy(2)))}; -MenuMorph.prototype.popUpCenteredInWorld=function(a){a=a||this.world;this.fixLayout();this.popup(a,a.center().subtract(this.extent().floorDivideBy(2)))};MenuMorph.prototype.closeRootMenu=function(){this.parent instanceof MenuMorph?(this.destroy(),this.parent.closeRootMenu()):this.destroy()};MenuMorph.prototype.closeSubmenu=function(){if(this.submenu){var a=this.world.activeMenu===this.submenu;this.submenu.destroy();this.submenu=null;this.unselectAllItems();a&&(this.world.activeMenu=this)}}; +MenuMorph.prototype.scroll=function(){var a=new ScrollFrameMorph,b=this.label?1:0,c=this.children[b];a.setPosition(c.position());this.children.slice(b).forEach(d=>a.addContents(d));this.add(a);a.setWidth(c.width());return a};MenuMorph.prototype.popUpAtHand=function(a){a=a||this.world;this.popup(a,a.hand.position())};MenuMorph.prototype.popUpCenteredAtHand=function(a){a=a||this.world;this.fixLayout();this.popup(a,a.hand.position().subtract(this.extent().floorDivideBy(2)))}; +MenuMorph.prototype.popUpCenteredInWorld=function(a){a=a||this.world;this.fixLayout();this.popup(a,a.center().subtract(this.extent().floorDivideBy(2)))};MenuMorph.prototype.closeRootMenu=function(){this.parent instanceof MenuMorph?(this.destroy(),this.parent.closeRootMenu()):this.destroy()};MenuMorph.prototype.closeSubmenu=function(){if(this.submenu){const a=this.world.activeMenu===this.submenu;this.submenu.destroy();this.submenu=null;this.unselectAllItems();a&&(this.world.activeMenu=this)}}; MenuMorph.prototype.getFocus=function(){this.world.keyboardFocus=this;this.selection=null;this.selectFirst();this.hasFocus=!0};MenuMorph.prototype.processKeyDown=function(a){switch(a.keyCode){case 13:case 32:this.selection&&(this.selection.mouseClickLeft(),this.submenu&&this.submenu.getFocus());break;case 27:return this.destroy();case 37:return this.leaveSubmenu();case 38:return this.selectUp();case 39:return this.enterSubmenu();case 40:return this.selectDown();default:nop()}}; -MenuMorph.prototype.processKeyUp=function(a){nop(a)};MenuMorph.prototype.processKeyPress=function(a){nop(a)};MenuMorph.prototype.selectFirst=function(){var a;var b=(b=detect(this.children,function(c){return c instanceof ScrollFrameMorph}))?b.contents.children:this.children;for(a=0;ab&&(b=a.length-1);this.select(a[b])}else a.length&&this.select(a[0])}; -MenuMorph.prototype.selectDown=function(){var a=detect(this.children,function(c){return c instanceof ScrollFrameMorph});a=(a?a.contents.children:this.children).filter(function(c){return c instanceof MenuItemMorph});if(this.selection){var b=a.indexOf(this.selection)+1;b>=a.length&&(b=0);this.select(a[b])}else a.length&&this.select(a[0])};MenuMorph.prototype.enterSubmenu=function(){this.selection&&this.selection.action instanceof MenuMorph&&(this.selection.popUpSubmenu(),this.submenu&&this.submenu.getFocus())}; -MenuMorph.prototype.leaveSubmenu=function(){var a=this.world.activeMenu===this,b=this.parent;this.parent instanceof MenuMorph&&(b.submenu=null,b.hasFocus=!0,this.destroy(),a&&(b.world.keyboardFocus=b,b.world.activeMenu=b))};MenuMorph.prototype.select=function(a){this.unselectAllItems();a.userState="highlight";a.rerender();a.scrollIntoView();this.selection=a}; +MenuMorph.prototype.processKeyUp=function(a){nop(a)};MenuMorph.prototype.processKeyPress=function(a){nop(a)};MenuMorph.prototype.selectFirst=function(){var a;var b=(b=detect(this.children,c=>c instanceof ScrollFrameMorph))?b.contents.children:this.children;for(a=0;ac instanceof ScrollFrameMorph);a=(a?a.contents.children:this.children).filter(c=>c instanceof MenuItemMorph);if(this.selection){var b=a.indexOf(this.selection)-1;0>b&&(b=a.length-1);this.select(a[b])}else a.length&&this.select(a[0])}; +MenuMorph.prototype.selectDown=function(){var a=detect(this.children,c=>c instanceof ScrollFrameMorph);a=(a?a.contents.children:this.children).filter(c=>c instanceof MenuItemMorph);if(this.selection){var b=a.indexOf(this.selection)+1;b>=a.length&&(b=0);this.select(a[b])}else a.length&&this.select(a[0])};MenuMorph.prototype.enterSubmenu=function(){this.selection&&this.selection.action instanceof MenuMorph&&(this.selection.popUpSubmenu(),this.submenu&&this.submenu.getFocus())}; +MenuMorph.prototype.leaveSubmenu=function(){const a=this.world.activeMenu===this;var b=this.parent;this.parent instanceof MenuMorph&&(b.submenu=null,b.hasFocus=!0,this.destroy(),a&&(b.world.keyboardFocus=b,b.world.activeMenu=b))};MenuMorph.prototype.select=function(a){this.unselectAllItems();a.userState="highlight";a.rerender();a.scrollIntoView();this.selection=a}; MenuMorph.prototype.destroy=function(){this.hasFocus&&(this.world.keyboardFocus=null);this.isListContents||this.world.activeMenu!==this||(this.world.activeMenu=null);MenuMorph.uber.destroy.call(this)};StringMorph.prototype=new Morph;StringMorph.prototype.constructor=StringMorph;StringMorph.uber=Morph.prototype;StringMorph.prototype.measureCtx=newCanvas().getContext("2d");function StringMorph(a,b,c,d,e,f,g,h,k,l){this.init(a,b,c,d,e,f,g,h,k,l)} StringMorph.prototype.init=function(a,b,c,d,e,f,g,h,k,l){this.text=a||(""===a?"":"StringMorph");this.fontSize=b||12;this.fontName=l||MorphicPreferences.globalFontFamily;this.fontStyle=c||"sans-serif";this.isBold=d||!1;this.isItalic=e||!1;this.enableLinks=this.isEditable=!1;this.isNumeric=f||!1;this.isPassword=!1;this.shadowOffset=g||ZERO;this.shadowColor=h||null;this.isShowingBlanks=!1;this.blanksColor=new Color(180,140,140);this.isScrollable=!0;this.currentlySelecting=!1;this.endMark=this.startMark= 0;this.markedTextColor=WHITE;this.markedBackgroundColor=new Color(60,60,120);StringMorph.uber.init.call(this,!0);this.color=k||new Color(0,0,0);this.fixLayout()};StringMorph.prototype.toString=function(){return"a "+(this.constructor.name||this.constructor.toString().split(" ")[1].split("(")[0])+'("'+this.text.slice(0,30)+'...")'};StringMorph.prototype.password=function(a,b){var c="",d;for(d=0;d{k||(a.fillStyle=e,a.beginPath(),a.arc(h+d/2,f,d/2,radians(0),radians(360)),a.fill(),h+=d);k=!1;""!==l&&(a.fillStyle=this.getRenderColor().toString(),a.fillText(l,h,c),h+=a.measureText(l).width)})}; StringMorph.prototype.slotPosition=function(a){var b=this.isPassword?this.password("*",this.text.length):this.text;a=Math.min(Math.max(a,0),b.length);this.measureCtx.font=this.font();this.pos=a;return new Point(this.left()+this.measureCtx.measureText(b.slice(0,a)).width,this.top())}; StringMorph.prototype.slotAt=function(a){var b=this.isPassword?this.password("*",this.text.length):this.text,c=0,d=0;for(this.measureCtx.font=this.font();a.x-this.left()>d;)if(d+=this.measureCtx.measureText(b[c]).width,c+=1,c===b.length&&this.measureCtx.measureText(b).width-this.measureCtx.measureText(b[c-1]).width/2d-this.measureCtx.measureText(b[c-1]).width/2?c:c-1};StringMorph.prototype.upFrom=function(a){return a}; StringMorph.prototype.downFrom=function(a){return a};StringMorph.prototype.startOfLine=function(){return 0};StringMorph.prototype.endOfLine=function(){return this.text.length};StringMorph.prototype.previousWordFrom=function(a){for(--a;0{this.prompt(a.title+"\nfont\nsize:",this.setFontSize,this,this.fontSize.toString(),null,6,500,!0)},"set this String's\nfont point size");"serif"!==this.fontStyle&&a.addItem("serif","setSerif");"sans-serif"!==this.fontStyle&&a.addItem("sans-serif","setSansSerif");this.isBold?a.addItem("normal weight","toggleWeight"):a.addItem("bold","toggleWeight"); +this.isItalic?a.addItem("normal style","toggleItalic"):a.addItem("italic","toggleItalic");this.isShowingBlanks?a.addItem("hide blanks","toggleShowBlanks"):a.addItem("show blanks","toggleShowBlanks");this.isPassword?a.addItem("show characters","toggleIsPassword"):a.addItem("hide characters","toggleIsPassword");return a};StringMorph.prototype.toggleIsDraggable=function(){(this.isDraggable=!this.isDraggable)?this.disableSelecting():this.enableSelecting()}; StringMorph.prototype.toggleShowBlanks=function(){this.isShowingBlanks=!this.isShowingBlanks;this.changed();this.fixLayout();this.rerender()};StringMorph.prototype.toggleWeight=function(){this.isBold=!this.isBold;this.changed();this.fixLayout();this.rerender()};StringMorph.prototype.toggleItalic=function(){this.isItalic=!this.isItalic;this.changed();this.fixLayout();this.rerender()}; StringMorph.prototype.toggleIsPassword=function(){this.isPassword=!this.isPassword;this.changed();this.fixLayout();this.rerender()};StringMorph.prototype.setSerif=function(){this.fontStyle="serif";this.changed();this.fixLayout();this.rerender()};StringMorph.prototype.setSansSerif=function(){this.fontStyle="sans-serif";this.changed();this.fixLayout();this.rerender()}; StringMorph.prototype.setFontSize=function(a){"number"===typeof a?this.fontSize=Math.round(Math.min(Math.max(a,4),500)):(a=parseFloat(a),isNaN(a)||(this.fontSize=Math.round(Math.min(Math.max(a,4),500))));this.changed();this.fixLayout();this.rerender()};StringMorph.prototype.setText=function(a){this.text=Math.round(a).toString();this.changed();this.fixLayout();this.rerender()};StringMorph.prototype.numericalSetters=function(){return["setLeft","setTop","setAlphaScaled","setFontSize","setText"]}; @@ -334,8 +278,8 @@ StringMorph.prototype.enableSelecting=function(){this.mouseDownLeft=function(a){ function TextMorph(a,b,c,d,e,f,g,h,k,l){this.init(a,b,c,d,e,f,g,h,k,l)} TextMorph.prototype.init=function(a,b,c,d,e,f,g,h,k,l){this.text=a||(""===a?a:"TextMorph");this.words=[];this.lines=[];this.lineSlots=[];this.fontSize=b||12;this.fontName=h||MorphicPreferences.globalFontFamily;this.fontStyle=c||"sans-serif";this.isBold=d||!1;this.isItalic=e||!1;this.alignment=f||"left";this.shadowOffset=k||ZERO;this.shadowColor=l||null;this.maxWidth=g||0;this.maxLineWidth=0;this.backgroundColor=null;this.enableLinks=this.isEditable=!1;this.receiver=null;this.isScrollable=!0;this.currentlySelecting= !1;this.endMark=this.startMark=0;this.markedTextColor=WHITE;this.markedBackgroundColor=new Color(60,60,120);TextMorph.uber.init.call(this);this.color=new Color(0,0,0);this.fixLayout()};TextMorph.prototype.toString=function(){return'a TextMorph("'+this.text.slice(0,30)+'...")'};TextMorph.prototype.font=StringMorph.prototype.font; -TextMorph.prototype.parse=function(){var a=this,b=this.text.split("\n"),c=this.measureCtx,d="",e,f,g=0;c.font=this.font();this.maxLineWidth=0;this.lines=[];this.lineSlots=[0];this.words=[];b.forEach(function(h){a.words=a.words.concat(h.split(" "));a.words.push("\n")});this.words.forEach(function(h){"\n"===h?(a.lines.push(d),a.lineSlots.push(g),a.maxLineWidth=Math.max(a.maxLineWidth,c.measureText(d).width),d=""):(0a.maxWidth?(a.lines.push(d),a.lineSlots.push(g), -a.maxLineWidth=Math.max(a.maxLineWidth,c.measureText(d).width),d=h+" "):d=e):d=d+h+" ",g+=h.length+1)})};TextMorph.prototype.fixLayout=function(){this.parse();var a=Math.abs(this.shadowOffset.x);var b=Math.abs(this.shadowOffset.y);b=this.lines.length*(fontHeight(this.fontSize)+b);this.bounds=0===this.maxWidth?this.bounds.origin.extent(new Point(this.maxLineWidth+a,b)):this.bounds.origin.extent(new Point(this.maxWidth+a,b));this.parent&&this.parent.layoutChanged&&this.parent.layoutChanged()}; +TextMorph.prototype.parse=function(){var a=this.text.split("\n"),b=this.measureCtx,c="",d,e,f=0;b.font=this.font();this.maxLineWidth=0;this.lines=[];this.lineSlots=[0];this.words=[];a.forEach(g=>{this.words=this.words.concat(g.split(" "));this.words.push("\n")});this.words.forEach(g=>{"\n"===g?(this.lines.push(c),this.lineSlots.push(f),this.maxLineWidth=Math.max(this.maxLineWidth,b.measureText(c).width),c=""):(0this.maxWidth?(this.lines.push(c), +this.lineSlots.push(f),this.maxLineWidth=Math.max(this.maxLineWidth,b.measureText(c).width),c=g+" "):c=d):c=c+g+" ",f+=g.length+1)})};TextMorph.prototype.fixLayout=function(){this.parse();var a=Math.abs(this.shadowOffset.x);var b=Math.abs(this.shadowOffset.y);b=this.lines.length*(fontHeight(this.fontSize)+b);this.bounds=0===this.maxWidth?this.bounds.origin.extent(new Point(this.maxLineWidth+a,b)):this.bounds.origin.extent(new Point(this.maxWidth+a,b));this.parent&&this.parent.layoutChanged&&this.parent.layoutChanged()}; TextMorph.prototype.render=function(a){var b=Math.abs(this.shadowOffset.x),c=Math.abs(this.shadowOffset.y),d=this.getShadowRenderColor();a.font=this.font();a.textAlign="left";a.textBaseline="bottom";this.backgroundColor&&(a.fillStyle=this.backgroundColor.toString(),a.fillRect(0,0,this.width(),this.height()));if(d){var e=Math.max(this.shadowOffset.x,0);var f=Math.max(this.shadowOffset.y,0);a.fillStyle=d.toString();for(d=0;d{this.prompt(a.title+"\nfont\nsize:",this.setFontSize,this,this.fontSize.toString(),null,6,100,!0)},"set this Text's\nfont point size");"left"!==this.alignment&&a.addItem("align left","setAlignmentToLeft");"right"!==this.alignment&&a.addItem("align right","setAlignmentToRight");"center"!==this.alignment&&a.addItem("align center","setAlignmentToCenter"); +a.addLine();"serif"!==this.fontStyle&&a.addItem("serif","setSerif");"sans-serif"!==this.fontStyle&&a.addItem("sans-serif","setSansSerif");this.isBold?a.addItem("normal weight","toggleWeight"):a.addItem("bold","toggleWeight");this.isItalic?a.addItem("normal style","toggleItalic"):a.addItem("italic","toggleItalic");return a};TextMorph.prototype.setAlignmentToLeft=function(){this.alignment="left";this.rerender()};TextMorph.prototype.setAlignmentToRight=function(){this.alignment="right";this.rerender()}; TextMorph.prototype.setAlignmentToCenter=function(){this.alignment="center";this.rerender()};TextMorph.prototype.toggleIsDraggable=StringMorph.prototype.toggleIsDraggable;TextMorph.prototype.toggleWeight=StringMorph.prototype.toggleWeight;TextMorph.prototype.toggleItalic=StringMorph.prototype.toggleItalic;TextMorph.prototype.setSerif=StringMorph.prototype.setSerif;TextMorph.prototype.setSansSerif=StringMorph.prototype.setSansSerif;TextMorph.prototype.setText=StringMorph.prototype.setText; TextMorph.prototype.setFontSize=StringMorph.prototype.setFontSize;TextMorph.prototype.numericalSetters=StringMorph.prototype.numericalSetters; TextMorph.prototype.evaluationMenu=function(){var a=new MenuMorph(this,null);a.addItem("do it","doIt","evaluate the\nselected expression");a.addItem("show it","showIt","evaluate the\nselected expression\nand show the result");a.addItem("inspect it","inspectIt","evaluate the\nselected expression\nand inspect the result");a.addLine();a.addItem("select all","selectAllAndEdit");return a};TextMorph.prototype.setReceiver=function(a){this.receiver=a;this.customContextMenu=this.evaluationMenu()}; @@ -359,7 +303,7 @@ TriggerMorph.prototype.createLabel=function(){null!==this.label&&this.label.dest TriggerMorph.prototype.trigger=function(){this.schedule&&(this.schedule.isActive=!1);if("function"===typeof this.target)"function"===typeof this.action?this.target.call(this.environment,this.action.call(),this):this.target.call(this.environment,this.action,this);else if("function"===typeof this.action)this.action.call(this.target);else this.target[this.action]()}; TriggerMorph.prototype.triggerDoubleClick=function(){if(this.doubleClickAction)if(this.schedule&&(this.schedule.isActive=!1),"function"===typeof this.target)"function"===typeof this.doubleClickAction?this.target.call(this.environment,this.doubleClickAction.call(),this):this.target.call(this.environment,this.doubleClickAction,this);else if("function"===typeof this.doubleClickAction)this.doubleClickAction.call(this.target);else this.target[this.doubleClickAction]()}; TriggerMorph.prototype.mouseEnter=function(){var a=this.hint instanceof Function?this.hint():this.hint;this.userState="highlight";this.rerender();a&&this.bubbleHelp(a)};TriggerMorph.prototype.mouseLeave=function(){this.userState="normal";this.rerender();this.schedule&&(this.schedule.isActive=!1);this.hint&&this.world().hand.destroyTemporaries()};TriggerMorph.prototype.mouseDownLeft=function(){this.userState="pressed";this.rerender()}; -TriggerMorph.prototype.mouseClickLeft=function(){this.userState="highlight";this.rerender();this.trigger()};TriggerMorph.prototype.mouseDoubleClick=function(){this.triggerDoubleClick()};TriggerMorph.prototype.rootForGrab=function(){return this.isDraggable?TriggerMorph.uber.rootForGrab.call(this):null};TriggerMorph.prototype.bubbleHelp=function(a){var b=this,c=this.world();this.schedule=new Animation(nop,nop,0,500,nop,function(){return b.popUpbubbleHelp(a)});c.animations.push(this.schedule)}; +TriggerMorph.prototype.mouseClickLeft=function(){this.userState="highlight";this.rerender();this.trigger()};TriggerMorph.prototype.mouseDoubleClick=function(){this.triggerDoubleClick()};TriggerMorph.prototype.rootForGrab=function(){return this.isDraggable?TriggerMorph.uber.rootForGrab.call(this):null};TriggerMorph.prototype.bubbleHelp=function(a){var b=this.world();this.schedule=new Animation(nop,nop,0,500,nop,()=>this.popUpbubbleHelp(a));b.animations.push(this.schedule)}; TriggerMorph.prototype.popUpbubbleHelp=function(a){(new SpeechBubbleMorph(localize(a),null,null,1)).popUp(this.world(),this.rightCenter().add(new Point(-8,0)))};MenuItemMorph.prototype=new TriggerMorph;MenuItemMorph.prototype.constructor=MenuItemMorph;MenuItemMorph.uber=TriggerMorph.prototype;function MenuItemMorph(a,b,c,d,e,f,g,h,k,l,m,n){this.shortcutString=n||null;this.shortcut=null;this.init(a,b,c,d,e,f,g,h,k,l,m)} MenuItemMorph.prototype.createLabel=function(){this.label&&this.label.destroy();this.label=this.createLabelPart(this.labelString);this.add(this.label);var a=this.label.width();var b=this.label.height();this.shortcut&&this.shortcut.destroy();this.shortcutString&&(this.shortcut=this.createLabelPart(this.shortcutString),a+=this.shortcut.width()+4,b=Math.max(b,this.shortcut.height()),this.add(this.shortcut));this.setExtent(new Point(a+8,b))}; MenuItemMorph.prototype.fixLayout=function(){var a=this.center();this.label.setCenter(a);this.label.setLeft(this.left()+4);this.shortcut&&(this.shortcut.setCenter(a),this.shortcut.setRight(this.right()-4))}; @@ -368,39 +312,39 @@ MenuItemMorph.prototype.createIcon=function(a){if(a instanceof Morph)return a.fu MenuItemMorph.prototype.mouseEnter=function(){var a=this.parentThatIsA(MenuMorph);this.isShowingSubmenu()||(a&&a.closeSubmenu(),this.isListItem()||(this.userState="highlight",this.rerender()),this.action instanceof MenuMorph?this.delaySubmenu():this.hint&&this.bubbleHelp(this.hint))};MenuItemMorph.prototype.mouseLeave=function(){this.isListItem()||(this.isShowingSubmenu()?this.userState="highlight":this.userState="normal",this.rerender());this.schedule&&(this.schedule.isActive=!1);this.hint&&this.world().hand.destroyTemporaries()}; MenuItemMorph.prototype.mouseDownLeft=function(a){this.isListItem()&&(this.parentThatIsA(MenuMorph).unselectAllItems(),this.escalateEvent("mouseDownLeft",a));this.userState="pressed";this.rerender()};MenuItemMorph.prototype.mouseMove=function(){this.isListItem()&&this.escalateEvent("mouseMove")};MenuItemMorph.prototype.mouseClickLeft=function(){this.action instanceof MenuMorph?this.popUpSubmenu():(this.isListItem()||(this.parentThatIsA(MenuMorph).closeRootMenu(),this.world().activeMenu=null),this.trigger())}; MenuItemMorph.prototype.isListItem=function(){var a=this.parentThatIsA(MenuMorph);return a?a.isListContents:!1};MenuItemMorph.prototype.isSelectedListItem=function(){return this.isListItem()?"pressed"===this.userState:!1};MenuItemMorph.prototype.isShowingSubmenu=function(){var a=this.parentThatIsA(MenuMorph);return a&&this.action instanceof MenuMorph?a.submenu===this.action:!1}; -MenuItemMorph.prototype.delaySubmenu=function(){var a=this,b=this.world();this.schedule=new Animation(nop,nop,0,500,nop,function(){return a.popUpSubmenu()});b.animations.push(this.schedule)}; +MenuItemMorph.prototype.delaySubmenu=function(){var a=this.world();this.schedule=new Animation(nop,nop,0,500,nop,()=>this.popUpSubmenu());a.animations.push(this.schedule)}; MenuItemMorph.prototype.popUpSubmenu=function(){var a=this.parentThatIsA(MenuMorph),b=this.world();if(this.action instanceof MenuMorph&&(this.action.createItems(),this.action.setPosition(this.topRight().subtract(new Point(0,5))),this.action.addShadow(new Point(2,2),80),this.action.keepWithin(this.world()),!(1>this.action.items.length)||this.action.title)){if(this.action.bottom()>b.bottom()){this.action.removeShadow();var c=this.action.scroll();this.action.bounds.corner.y=b.bottom()-2;this.action.addShadow(new Point(2, 2),80);c.setHeight(b.bottom()-c.top()-6);c.adjustScrollBars()}a.add(this.action);a.submenu=this.action;a.submenu.world=a.world;this.action.fullChanged()}};FrameMorph.prototype=new Morph;FrameMorph.prototype.constructor=FrameMorph;FrameMorph.uber=Morph.prototype;function FrameMorph(a){this.init(a)}FrameMorph.prototype.init=function(a){this.scrollFrame=a||null;FrameMorph.uber.init.call(this);this.color=new Color(255,250,245);this.acceptsDrops=!0;this.scrollFrame&&(this.isDraggable=!1,this.alpha=0)}; -FrameMorph.prototype.fullBounds=function(){var a=this.getShadow();return null!==a?this.bounds.merge(a.bounds):this.bounds};FrameMorph.prototype.fullImage=function(){return this.getImage()};FrameMorph.prototype.fullDrawOn=function(a,b){var c;if(this.isVisible){var d=this.bounds.intersect(b);d.extent().gt(ZERO)&&(this.drawOn(a,d),this.children.forEach(function(e){e instanceof ShadowMorph?c=e:e.fullDrawOn(a,d)}),c&&c.drawOn(a,b))}}; -FrameMorph.prototype.topMorphAt=function(a){var b,c;if(!this.isVisible||!this.bounds.containsPoint(a))return null;for(b=this.children.length-1;0<=b;--b)if(c=this.children[b].topMorphAt(a))return c;return this.isFreeForm?this.isTransparentAt(a)?null:this:this};FrameMorph.prototype.submorphBounds=function(){var a=null;0{e instanceof ShadowMorph?c=e:e.fullDrawOn(a,d)}),c&&c.drawOn(a,b))}}; +FrameMorph.prototype.topMorphAt=function(a){var b,c;if(!this.isVisible||!this.bounds.containsPoint(a))return null;for(b=this.children.length-1;0<=b;--b)if(c=this.children[b].topMorphAt(a))return c;return this.isFreeForm?this.isTransparentAt(a)?null:this:this};FrameMorph.prototype.submorphBounds=function(){var a=null;0{a=a.merge(b.fullBounds())}));return a}; FrameMorph.prototype.keepInScrollFrame=function(){if(null===this.scrollFrame)return null;this.left()>this.scrollFrame.left()&&this.moveBy(new Point(this.scrollFrame.left()-this.left(),0));this.right()this.scrollFrame.top()&&this.moveBy(new Point(0,this.scrollFrame.top()-this.top()));this.bottom(){b instanceof TextMorph&&(b.setWidth(this.width()),this.setHeight(Math.max(b.height(),this.scrollFrame.height())))}); +this.scrollFrame.adjustScrollBars()}};FrameMorph.prototype.reactToDropOf=function(){this.adjustBounds()};FrameMorph.prototype.reactToGrabOf=function(){this.adjustBounds()};FrameMorph.prototype.developersMenu=function(){var a=FrameMorph.uber.developersMenu.call(this);0a.keepWithin(this))}; ScrollFrameMorph.prototype=new FrameMorph;ScrollFrameMorph.prototype.constructor=ScrollFrameMorph;ScrollFrameMorph.uber=FrameMorph.prototype;function ScrollFrameMorph(a,b,c){this.init(a,b,c)} -ScrollFrameMorph.prototype.init=function(a,b,c){var d=this;ScrollFrameMorph.uber.init.call(this);this.scrollBarSize=b||MorphicPreferences.scrollBarSize;this.autoScrollTrigger=null;this.hasVelocity=this.isScrollingByDragging=this.enableAutoScrolling=!0;this.growth=this.padding=0;this.isTextLineWrapping=!1;this.contents=a||new FrameMorph(this);this.add(this.contents);this.hBar=new SliderMorph(null,null,null,null,"horizontal",c);this.hBar.setHeight(this.scrollBarSize);this.hBar.action=function(e){d.contents.setPosition(new Point(d.left()- -e,d.contents.position().y))};this.hBar.isDraggable=!1;this.add(this.hBar);this.vBar=new SliderMorph(null,null,null,null,"vertical",c);this.vBar.setWidth(this.scrollBarSize);this.vBar.action=function(e){d.contents.setPosition(new Point(d.contents.position().x,d.top()-e))};this.vBar.isDraggable=!1;this.add(this.vBar);this.toolBar=null}; +ScrollFrameMorph.prototype.init=function(a,b,c){ScrollFrameMorph.uber.init.call(this);this.scrollBarSize=b||MorphicPreferences.scrollBarSize;this.autoScrollTrigger=null;this.hasVelocity=this.isScrollingByDragging=this.enableAutoScrolling=!0;this.growth=this.padding=0;this.isTextLineWrapping=!1;this.contents=a||new FrameMorph(this);this.add(this.contents);this.hBar=new SliderMorph(null,null,null,null,"horizontal",c);this.hBar.setHeight(this.scrollBarSize);this.hBar.action=d=>{this.contents.setPosition(new Point(this.left()- +d,this.contents.position().y))};this.hBar.isDraggable=!1;this.add(this.hBar);this.vBar=new SliderMorph(null,null,null,null,"vertical",c);this.vBar.setWidth(this.scrollBarSize);this.vBar.action=d=>{this.contents.setPosition(new Point(this.contents.position().x,this.top()-d))};this.vBar.isDraggable=!1;this.add(this.vBar);this.toolBar=null}; ScrollFrameMorph.prototype.adjustScrollBars=function(){var a=this.width()-this.scrollBarSize,b=this.height()-this.scrollBarSize;this.changed();this.contents.width()>this.width()?(this.hBar.show(),this.hBar.width()!==a&&this.hBar.setWidth(a),this.hBar.setPosition(new Point(this.left(),this.bottom()-this.hBar.height())),this.hBar.start=0,this.hBar.stop=this.contents.width()-this.width()+this.scrollBarSize,this.hBar.size=this.width()/this.contents.width()*this.hBar.stop,this.hBar.value=this.left()-this.contents.left(), this.hBar.fixLayout()):this.hBar.hide();this.contents.height()>this.height()?(this.vBar.show(),this.vBar.height()!==b&&this.vBar.setHeight(b),this.vBar.setPosition(new Point(this.right()-this.vBar.width(),this.top())),this.vBar.start=0,this.vBar.stop=this.contents.height()-this.height()+this.scrollBarSize,this.vBar.size=this.height()/this.contents.height()*this.vBar.stop,this.vBar.value=this.top()-this.contents.top(),this.vBar.fixLayout()):this.vBar.hide();this.adjustToolBar()}; -ScrollFrameMorph.prototype.adjustToolBar=function(){this.toolBar&&(this.toolBar.setTop(this.top()+3),this.toolBar.setRight((this.vBar.isVisible?this.vBar.left():this.right())-3))};ScrollFrameMorph.prototype.addContents=function(a){this.contents.add(a);this.contents.adjustBounds()};ScrollFrameMorph.prototype.setContents=function(a){this.contents.children.forEach(function(b){return b.destroy()});this.contents.children=[];a.setPosition(this.position().add(this.padding+2));this.addContents(a)}; +ScrollFrameMorph.prototype.adjustToolBar=function(){this.toolBar&&(this.toolBar.setTop(this.top()+3),this.toolBar.setRight((this.vBar.isVisible?this.vBar.left():this.right())-3))};ScrollFrameMorph.prototype.addContents=function(a){this.contents.add(a);this.contents.adjustBounds()};ScrollFrameMorph.prototype.setContents=function(a){this.contents.children.forEach(b=>b.destroy());this.contents.children=[];a.setPosition(this.position().add(this.padding+2));this.addContents(a)}; ScrollFrameMorph.prototype.setExtent=function(a){this.isTextLineWrapping&&this.contents.setPosition(this.position().copy());ScrollFrameMorph.uber.setExtent.call(this,a);this.contents.adjustBounds()};ScrollFrameMorph.prototype.scrollX=function(a){var b=this.contents.left(),c=this.left(),d=this.contents.width(),e=this.right();this.vBar.isVisible&&(e-=this.scrollBarSize);a=b+a;a+dc&&(a=c);a!==b&&this.contents.setLeft(a)}; ScrollFrameMorph.prototype.scrollY=function(a){var b=this.contents.top(),c=this.top(),d=this.contents.height(),e=this.bottom();this.hBar.isVisible&&(e-=this.scrollBarSize);a=b+a;a+dc&&(a=c);a!==b&&this.contents.setTop(a)};ScrollFrameMorph.prototype.step=nop; -ScrollFrameMorph.prototype.mouseDownLeft=function(a){var b=this;if(!this.isScrollingByDragging)return null;var c=this.root().hand,d=a,e=0,f=0;this.step=function(){if(c.mouseButton&&0===c.children.length&&b.bounds.containsPoint(c.bounds.origin)){if(c.grabPosition&&c.grabPosition.distanceTo(c.position())<=MorphicPreferences.grabThreshold)return null;var g=c.bounds.origin;e=g.x-d.x;0!==e&&b.scrollX(e);f=g.y-d.y;0!==f&&b.scrollY(f);d=g}else b.hasVelocity?.5>Math.abs(e)&&.5>Math.abs(f)?b.step=nop:(e*= -.8,b.scrollX(Math.round(e)),f*=.8,b.scrollY(Math.round(f))):b.step=nop;b.adjustScrollBars()}};ScrollFrameMorph.prototype.startAutoScrolling=function(){var a=this,b=3*MorphicPreferences.scrollBarSize,c=this.world(),d,e;if(!c)return null;var f=c.hand;this.autoScrollTrigger||(this.autoScrollTrigger=Date.now());this.step=function(){e=f.bounds.origin;d=a.bounds.insetBy(b);a.bounds.containsPoint(e)&&!d.containsPoint(e)&&0{if(b.mouseButton&&0===b.children.length&&this.bounds.containsPoint(b.bounds.origin)){if(b.grabPosition&&b.grabPosition.distanceTo(b.position())<=MorphicPreferences.grabThreshold)return null;var f=b.bounds.origin;d=f.x-c.x;0!==d&&this.scrollX(d);e=f.y-c.y;0!==e&&this.scrollY(e);c=f}else this.hasVelocity?.5>Math.abs(d)&&.5>Math.abs(e)?this.step=nop:(d*=.8, +this.scrollX(Math.round(d)),e*=.8,this.scrollY(Math.round(e))):this.step=nop;this.adjustScrollBars()}};ScrollFrameMorph.prototype.startAutoScrolling=function(){var a=3*MorphicPreferences.scrollBarSize,b=this.world(),c,d;if(!b)return null;var e=b.hand;this.autoScrollTrigger||(this.autoScrollTrigger=Date.now());this.step=()=>{d=e.bounds.origin;c=this.bounds.insetBy(a);this.bounds.containsPoint(d)&&!c.containsPoint(d)&&0Date.now()-this.autoScrollTrigger)return null;var b=3*MorphicPreferences.scrollBarSize;var c=this.topLeft().extent(new Point(this.width(),b));c.containsPoint(a)&&this.scrollY(b-(a.y-this.top()));c=this.topLeft().extent(new Point(b,this.height()));c.containsPoint(a)&&this.scrollX(b-(a.x-this.left()));c=(new Point(this.right()-b,this.top())).extent(new Point(b,this.height()));c.containsPoint(a)&&this.scrollX(-(b-(this.right()-a.x)));c=(new Point(this.left(), this.bottom()-b)).extent(new Point(this.width(),b));c.containsPoint(a)&&this.scrollY(-(b-(this.bottom()-a.y)));this.adjustScrollBars()}; ScrollFrameMorph.prototype.scrollCursorIntoView=function(a){var b=a.target,c=b.position().subtract(this.contents.position()),d=this.top()+this.padding,e=this.bottom()-this.padding;this.contents.setExtent(b.extent().add(c).add(this.padding));a.top()e&&(this.contents.setBottom(this.contents.bottom()+e-a.bottom()),a.setBottom(e));this.adjustScrollBars()}; ScrollFrameMorph.prototype.mouseScroll=function(a,b){a&&this.scrollY(a*MorphicPreferences.mouseScrollAmount);b&&this.scrollX(b*MorphicPreferences.mouseScrollAmount);this.adjustScrollBars()}; -ScrollFrameMorph.prototype.updateReferences=function(a){var b=this;ScrollFrameMorph.uber.updateReferences.call(this,a);this.hBar&&(this.hBar.action=function(c){b.contents.setPosition(new Point(b.left()-c,b.contents.position().y))});this.vBar&&(this.vBar.action=function(c){b.contents.setPosition(new Point(b.contents.position().x,b.top()-c))})}; +ScrollFrameMorph.prototype.updateReferences=function(a){ScrollFrameMorph.uber.updateReferences.call(this,a);this.hBar&&(this.hBar.action=b=>{this.contents.setPosition(new Point(this.left()-b,this.contents.position().y))});this.vBar&&(this.vBar.action=b=>{this.contents.setPosition(new Point(this.contents.position().x,this.top()-b))})}; ScrollFrameMorph.prototype.developersMenu=function(){var a=ScrollFrameMorph.uber.developersMenu.call(this);this.isTextLineWrapping?a.addItem("auto line wrap off...","toggleTextLineWrapping","turn automatic\nline wrapping\noff"):a.addItem("auto line wrap on...","toggleTextLineWrapping","enable automatic\nline wrapping");return a};ScrollFrameMorph.prototype.toggleTextLineWrapping=function(){this.isTextLineWrapping=!this.isTextLineWrapping};ListMorph.prototype=new ScrollFrameMorph; ListMorph.prototype.constructor=ListMorph;ListMorph.uber=ScrollFrameMorph.prototype;function ListMorph(a,b,c,d,e){this.init(a||[],b||function(f){return isString(f)?f:f.toSource?f.toSource():f.toString()},c||[],d,e)} ListMorph.prototype.init=function(a,b,c,d,e){ListMorph.uber.init.call(this);this.contents.acceptsDrops=!1;this.color=WHITE;this.hBar.alpha=.6;this.vBar.alpha=.6;this.elements=a||[];this.labelGetter=b;this.format=c;this.action=this.active=this.selected=this.listContents=null;this.doubleClickAction=d||null;this.separator=e||"";this.acceptsDrops=!1;this.buildListContents()}; -ListMorph.prototype.buildListContents=function(){var a=this;this.listContents&&this.listContents.destroy();this.listContents=new MenuMorph(this.select,null,this);0===this.elements.length&&(this.elements=["(empty)"]);this.elements.forEach(function(b){var c=null,d=!1,e=!1;a.format.forEach(function(g){g[1].call(null,b)&&("bold"===g[0]?d=!0:"italic"===g[0]?e=!0:c=g[0])});var f=a.labelGetter(b);f===a.separator?a.listContents.addLine():a.listContents.addItem(f,b,null,c,d,e,a.doubleClickAction)});this.listContents.isListContents= +ListMorph.prototype.buildListContents=function(){this.listContents&&this.listContents.destroy();this.listContents=new MenuMorph(this.select,null,this);0===this.elements.length&&(this.elements=["(empty)"]);this.elements.forEach(a=>{var b=null,c=!1,d=!1;this.format.forEach(f=>{f[1].call(null,a)&&("bold"===f[0]?c=!0:"italic"===f[0]?d=!0:b=f[0])});var e=this.labelGetter(a);e===this.separator?this.listContents.addLine():this.listContents.addItem(e,a,null,b,c,d,this.doubleClickAction)});this.listContents.isListContents= !0;this.listContents.createItems();this.listContents.setPosition(this.contents.position());this.addContents(this.listContents)};ListMorph.prototype.select=function(a,b){isNil(a)||(this.selected=a,this.active=b,this.action&&this.action.call(null,a))}; ListMorph.prototype.setExtent=function(a){var b=this.listContents.bounds,c=this.bounds.origin.copy().corner(this.bounds.origin.add(a));c.right()>b.right()&&c.width()<=b.width()&&this.listContents.setRight(c.right());c.bottom()>b.bottom()&&c.height()<=b.height()&&this.listContents.setBottom(c.bottom());ListMorph.uber.setExtent.call(this,a)};ListMorph.prototype.activeIndex=function(){return this.listContents.children.indexOf(this.active)}; ListMorph.prototype.activateIndex=function(a){if(a=this.listContents.children[a])a.userState="pressed",a.rerender(),a.trigger()};StringFieldMorph.prototype=new FrameMorph;StringFieldMorph.prototype.constructor=StringFieldMorph;StringFieldMorph.uber=FrameMorph.prototype;function StringFieldMorph(a,b,c,d,e,f,g){this.init(a||"",b||100,c||12,d||"sans-serif",e||!1,f||!1,g)} StringFieldMorph.prototype.init=function(a,b,c,d,e,f,g){this.defaultContents=a;this.minWidth=b;this.fontSize=c;this.fontStyle=d;this.isBold=e;this.isItalic=f;this.isNumeric=g||!1;this.text=null;StringFieldMorph.uber.init.call(this);this.color=WHITE;this.isEditable=!0;this.acceptsDrops=!1;this.createText()}; -StringFieldMorph.prototype.createText=function(){var a=this.text?this.string():this.defaultContents;this.text=null;this.children.forEach(function(b){return b.destroy()});this.children=[];this.text=new StringMorph(a,this.fontSize,this.fontStyle,this.isBold,this.isItalic,this.isNumeric);this.text.isNumeric=this.isNumeric;this.text.setPosition(this.bounds.origin.copy());this.text.isEditable=this.isEditable;this.text.isDraggable=!1;this.text.enableSelecting();this.setExtent(new Point(Math.max(this.width(), -this.minWidth),this.text.height()));this.add(this.text)};StringFieldMorph.prototype.string=function(){return this.text.text};StringFieldMorph.prototype.mouseClickLeft=function(a){this.isEditable?this.text.edit():this.escalateEvent("mouseClickLeft",a)};BouncerMorph.prototype=new Morph;BouncerMorph.prototype.constructor=BouncerMorph;BouncerMorph.uber=Morph.prototype;function BouncerMorph(){this.init()} +StringFieldMorph.prototype.createText=function(){var a=this.text?this.string():this.defaultContents;this.text=null;this.children.forEach(b=>b.destroy());this.children=[];this.text=new StringMorph(a,this.fontSize,this.fontStyle,this.isBold,this.isItalic,this.isNumeric);this.text.isNumeric=this.isNumeric;this.text.setPosition(this.bounds.origin.copy());this.text.isEditable=this.isEditable;this.text.isDraggable=!1;this.text.enableSelecting();this.setExtent(new Point(Math.max(this.width(),this.minWidth), +this.text.height()));this.add(this.text)};StringFieldMorph.prototype.string=function(){return this.text.text};StringFieldMorph.prototype.mouseClickLeft=function(a){this.isEditable?this.text.edit():this.escalateEvent("mouseClickLeft",a)};BouncerMorph.prototype=new Morph;BouncerMorph.prototype.constructor=BouncerMorph;BouncerMorph.uber=Morph.prototype;function BouncerMorph(){this.init()} BouncerMorph.prototype.init=function(a,b){BouncerMorph.uber.init.call(this);this.fps=50;this.isStopped=!1;this.type=a||"vertical";this.direction="vertical"===this.type?"down":"right";this.speed=b||1};BouncerMorph.prototype.moveUp=function(){this.moveBy(new Point(0,-this.speed))};BouncerMorph.prototype.moveDown=function(){this.moveBy(new Point(0,this.speed))};BouncerMorph.prototype.moveRight=function(){this.moveBy(new Point(this.speed,0))}; BouncerMorph.prototype.moveLeft=function(){this.moveBy(new Point(-this.speed,0))}; BouncerMorph.prototype.step=function(){this.isStopped||("vertical"===this.type?("down"===this.direction?this.moveDown():this.moveUp(),this.fullBounds().top()this.parent.bottom()&&"down"===this.direction&&(this.direction="up")):"horizontal"===this.type&&("right"===this.direction?this.moveRight():this.moveLeft(),this.fullBounds().left()this.parent.right()&&"right"===this.direction&&(this.d HandMorph.prototype.init=function(a){HandMorph.uber.init.call(this,!0);this.bounds=new Rectangle;this.world=a;this.mouseButton=null;this.mouseOverList=[];this.mouseOverBounds=[];this.grabOrigin=this.grabPosition=this.morphToGrab=null;this.temporaries=[];this.touchHoldTimeout=null;this.contextMenuEnabled=!1;this.cachedFullBounds=this.cachedFullImage=null};HandMorph.prototype.changed=function(){if(null!==this.world){var a=this.cachedFullBounds||this.fullBounds();a.extent().eq(ZERO)||this.world.broken.push(a.spread())}}; HandMorph.prototype.moveBy=function(a){var b=this.children,c=b.length;this.changed();this.bounds=this.bounds.translateBy(a);this.cachedFullBounds&&(this.cachedFullBounds=this.cachedFullBounds.translateBy(a));this.changed();for(c;0c||1>e||(a.drawImage(d,f,g,c,e,b.left(),b.top(),c,e),a.restore())}}else HandMorph.uber.fullDrawOn.call(this,a,b)}; -HandMorph.prototype.morphAtPointer=function(){return this.world.topMorphAt(this.bounds.origin)||this.world};HandMorph.prototype.allMorphsAtPointer=function(){var a=this;return this.world.allChildren().filter(function(b){return b.isVisible&&b.visibleBounds().containsPoint(a.bounds.origin)&&!b.holes.some(function(c){return c.translateBy(b.position()).containsPoint(a.bounds.origin)})})};HandMorph.prototype.dropTargetFor=function(a){for(var b=this.morphAtPointer();!b.wantsDropOf(a);)b=b.parent;return b}; +HandMorph.prototype.morphAtPointer=function(){return this.world.topMorphAt(this.bounds.origin)||this.world};HandMorph.prototype.allMorphsAtPointer=function(){return this.world.allChildren().filter(a=>a.isVisible&&a.visibleBounds().containsPoint(this.bounds.origin)&&!a.holes.some(b=>b.translateBy(a.position()).containsPoint(this.bounds.origin)))};HandMorph.prototype.dropTargetFor=function(a){for(var b=this.morphAtPointer();!b.wantsDropOf(a);)b=b.parent;return b}; HandMorph.prototype.grab=function(a){var b=a.parent;if(a instanceof WorldMorph)return null;0===this.children.length&&(this.world.stopEditing(),this.grabOrigin=a.situation(),a.noDropShadow||a.addShadow(),a.prepareToBeGrabbed&&a.prepareToBeGrabbed(this),this.add(a),this.cachedFullImage=a.fullImage(),this.cachedFullBounds=a.fullBounds(),this.changed(),b&&b.reactToGrabOf&&b.reactToGrabOf(a))}; HandMorph.prototype.drop=function(){this.alpha=1;if(0!==this.children.length){var a=this.children[0];var b=this.dropTargetFor(a);b=b.selectForEdit?b.selectForEdit():b;this.changed();b.add(a);a.changed();this.cachedFullBounds=this.cachedFullImage=null;a.noDropShadow||a.removeShadow();this.children=[];this.setExtent(new Point);a.justDropped&&a.justDropped(this);b.reactToDropOf&&b.reactToDropOf(a,this)}}; HandMorph.prototype.processMouseDown=function(a){var b=getDocumentPositionOf(this.world.worldCanvas);a.pageX&&this.setPosition(new Point(a.pageX-b.x,a.pageY-b.y));this.destroyTemporaries();this.contextMenuEnabled=!0;this.grabPosition=this.morphToGrab=null;if(0!==this.children.length)this.drop(),this.mouseButton=null;else{b=this.morphAtPointer();this.world.activeMenu&&(contains(b.allParents(),this.world.activeMenu)?clearInterval(this.touchHoldTimeout):this.world.activeMenu.destroy());this.world.activeHandle&& b!==this.world.activeHandle&&this.world.activeHandle.destroy();this.world.cursor&&b!==this.world.cursor.target&&this.world.stopEditing();b.mouseMove||(this.morphToGrab=b.rootForGrab(),this.grabPosition=this.bounds.origin.copy());2===a.button||a.ctrlKey?(this.mouseButton="right",a="mouseDownRight"):(this.mouseButton="left",a="mouseDownLeft");for(;!b[a];)b=b.parent;b[a](this.bounds.origin)}}; -HandMorph.prototype.processTouchStart=function(a){var b=this;MorphicPreferences.isTouchDevice=!0;clearInterval(this.touchHoldTimeout);1===a.touches.length&&(this.touchHoldTimeout=setInterval(function(){b.processMouseDown({button:2});b.processMouseUp({button:2});a.preventDefault();clearInterval(b.touchHoldTimeout)},400),this.processMouseMove(a.touches[0]),this.processMouseDown({button:0}),a.preventDefault())}; +HandMorph.prototype.processTouchStart=function(a){MorphicPreferences.isTouchDevice=!0;clearInterval(this.touchHoldTimeout);1===a.touches.length&&(this.touchHoldTimeout=setInterval(()=>{this.processMouseDown({button:2});this.processMouseUp({button:2});a.preventDefault();clearInterval(this.touchHoldTimeout)},400),this.processMouseMove(a.touches[0]),this.processMouseDown({button:0}),a.preventDefault())}; HandMorph.prototype.processTouchMove=function(a){MorphicPreferences.isTouchDevice=!0;1===a.touches.length&&(this.processMouseMove(a.touches[0]),clearInterval(this.touchHoldTimeout))};HandMorph.prototype.processTouchEnd=function(a){MorphicPreferences.isTouchDevice=!0;clearInterval(this.touchHoldTimeout);nop(a);this.processMouseUp({button:0})}; HandMorph.prototype.processMouseUp=function(){var a=this.morphAtPointer(),b;this.destroyTemporaries();if(0!==this.children.length)this.drop();else{if("left"===this.mouseButton)var c="mouseClickLeft";else if(c="mouseClickRight",this.mouseButton&&this.contextMenuEnabled){var d=a;for(b=d.contextMenu();!b&&d.parent;)d=d.parent,b=d.contextMenu();b&&b.popUpAtHand(this.world)}for(;!a[c];)a=a.parent;a[c](this.bounds.origin)}this.mouseButton=null}; HandMorph.prototype.processDoubleClick=function(){var a=this.morphAtPointer();this.destroyTemporaries();if(0!==this.children.length)this.drop();else{for(;a&&!a.mouseDoubleClick;)a=a.parent;a&&a.mouseDoubleClick(this.bounds.origin)}this.mouseButton=null}; -HandMorph.prototype.processMouseMove=function(a){var b=this,c=getDocumentPositionOf(this.world.worldCanvas);a=new Point(a.pageX-c.x,a.pageY-c.y);this.setPosition(a);var d=this.morphAtPointer().allParents();var e=d.filter(function(g){return g.isVisible&&g.visibleBounds().containsPoint(b.bounds.origin)&&!g.holes.some(function(h){return h.translateBy(g.position()).containsPoint(b.bounds.origin)})});if(!this.children.length&&this.mouseButton){var f=this.morphAtPointer();c=f.rootForGrab();f.mouseMove&& -(f.mouseMove(a,this.mouseButton),"right"===this.mouseButton&&(this.contextMenuEnabled=!1));"left"===this.mouseButton&&this.morphToGrab&&this.grabPosition.distanceTo(this.bounds.origin)>MorphicPreferences.grabThreshold&&(this.setPosition(this.grabPosition),this.morphToGrab.isDraggable?(c=this.morphToGrab.selectForEdit?this.morphToGrab.selectForEdit():this.morphToGrab,this.grab(c)):this.morphToGrab.isTemplate&&(this.world.stopEditing(),c=this.morphToGrab.fullCopy(),c.isTemplate=!1,c.isDraggable=!0, -c.reactToTemplateCopy&&c.reactToTemplateCopy(),this.grab(c),this.grabOrigin=this.morphToGrab.situation()),this.setPosition(a))}this.mouseOverBounds.forEach(function(g){contains(e,g)||g.mouseLeaveBounds&&g.mouseLeaveBounds(b.children[0])});e.forEach(function(g){contains(b.mouseOverBounds,g)||g.mouseEnterBounds&&g.mouseEnterBounds(b.children[0])});this.mouseOverList.forEach(function(g){contains(d,g)||(g.mouseLeave&&g.mouseLeave(),g.mouseLeaveDragging&&b.mouseButton&&g.mouseLeaveDragging(b.children[0]))}); -d.forEach(function(g){contains(b.mouseOverList,g)||(g.mouseEnter&&g.mouseEnter(),g.mouseEnterDragging&&b.mouseButton&&g.mouseEnterDragging(b.children[0]));0f.isVisible&&f.visibleBounds().containsPoint(this.bounds.origin)&&!f.holes.some(g=>g.translateBy(f.position()).containsPoint(this.bounds.origin)));if(!this.children.length&&this.mouseButton){var e=this.morphAtPointer();b=e.rootForGrab();e.mouseMove&&(e.mouseMove(a,this.mouseButton),"right"=== +this.mouseButton&&(this.contextMenuEnabled=!1));"left"===this.mouseButton&&this.morphToGrab&&this.grabPosition.distanceTo(this.bounds.origin)>MorphicPreferences.grabThreshold&&(this.setPosition(this.grabPosition),this.morphToGrab.isDraggable?(b=this.morphToGrab.selectForEdit?this.morphToGrab.selectForEdit():this.morphToGrab,this.grab(b)):this.morphToGrab.isTemplate&&(this.world.stopEditing(),b=this.morphToGrab.fullCopy(),b.isTemplate=!1,b.isDraggable=!0,b.reactToTemplateCopy&&b.reactToTemplateCopy(), +this.grab(b),this.grabOrigin=this.morphToGrab.situation()),this.setPosition(a))}this.mouseOverBounds.forEach(f=>{contains(d,f)||f.mouseLeaveBounds&&f.mouseLeaveBounds(this.children[0])});d.forEach(f=>{contains(this.mouseOverBounds,f)||f.mouseEnterBounds&&f.mouseEnterBounds(this.children[0])});this.mouseOverList.forEach(f=>{contains(c,f)||(f.mouseLeave&&f.mouseLeave(),f.mouseLeaveDragging&&this.mouseButton&&f.mouseLeaveDragging(this.children[0]))});c.forEach(f=>{contains(this.mouseOverList,f)||(f.mouseEnter&& +f.mouseEnter(),f.mouseEnterDragging&&this.mouseButton&&f.mouseEnterDragging(this.children[0]));0g.wantsDropOf(this.children[0]))&&(f.bounds.insetBy(3*MorphicPreferences.scrollBarSize).containsPoint(this.bounds.origin)||f.startAutoScrolling())});this.mouseOverList=c;this.mouseOverBounds=d}; HandMorph.prototype.processMouseScroll=function(a){for(var b=this.morphAtPointer();b&&!b.mouseScroll;)b=b.parent;b&&b.mouseScroll(a.detail/-3||(Object.prototype.hasOwnProperty.call(a,"wheelDeltaY")?a.wheelDeltaY/120:a.wheelDelta/120),a.wheelDeltaX/120||0)}; -HandMorph.prototype.processDrop=function(a){function b(q){for(var t=new Image,u=new FileReader;!n.droppedSVG;)n=n.parent;var v=new Promise(function(w){return t.onload=function(){return w(n.droppedSVG(t,q.name))}});u=new FileReader;u.onloadend=function(w){return t.src=w.target.result};u.readAsDataURL(q);return v}function c(q){for(var t=new Image,u=new FileReader;!n.droppedImage;)n=n.parent;var v=new Promise(function(w){t.onload=function(){r=newCanvas(new Point(t.width,t.height),!0);r.getContext("2d").drawImage(t, -0,0);w(n.droppedImage(r,q.name))}});u=new FileReader;u.onloadend=function(w){return t.src=w.target.result};u.readAsDataURL(q);return v}function d(q){for(var t=new Audio,u=new FileReader;!n.droppedAudio;)n=n.parent;u.onloadend=function(v){t.src=v.target.result;n.droppedAudio(t,q.name)};u.readAsDataURL(q)}function e(q){for(var t=new FileReader;!n.droppedText;)n=n.parent;t.onloadend=function(u){n.droppedText(u.target.result,q.name,q.type)};t.readAsText(q)}function f(q){for(var t=new FileReader;!n.droppedBinary;)n= -n.parent;t.onloadend=function(u){n.droppedBinary(u.target.result,q.name)};t.readAsArrayBuffer(q)}function g(q,t){var u=new XMLHttpRequest;u.open("GET",q);u.onreadystatechange=function(){if(4===u.readyState)if(u.responseText)t(u.responseText);else throw Error("unable to retrieve "+q);};u.send()}function h(q){var t="";var u=q.indexOf('t.onload=()=>w(n.droppedSVG(t,r.name)));u=new FileReader;u.onloadend=w=>t.src=w.target.result;u.readAsDataURL(r);return v}function c(r){for(var t=new Image,u=new FileReader;!n.droppedImage;)n=n.parent;const v=new Promise(w=>{t.onload=()=>{q=newCanvas(new Point(t.width,t.height),!0);q.getContext("2d").drawImage(t,0,0);w(n.droppedImage(q,r.name))}});u=new FileReader; +u.onloadend=w=>t.src=w.target.result;u.readAsDataURL(r);return v}function d(r){for(var t=new Audio,u=new FileReader;!n.droppedAudio;)n=n.parent;u.onloadend=v=>{t.src=v.target.result;n.droppedAudio(t,r.name)};u.readAsDataURL(r)}function e(r){for(var t=new FileReader;!n.droppedText;)n=n.parent;t.onloadend=u=>{n.droppedText(u.target.result,r.name,r.type)};t.readAsText(r)}function f(r){for(var t=new FileReader;!n.droppedBinary;)n=n.parent;t.onloadend=u=>{n.droppedBinary(u.target.result,r.name)};t.readAsArrayBuffer(r)} +function g(r,t){var u=new XMLHttpRequest;u.open("GET",r);u.onreadystatechange=()=>{if(4===u.readyState)if(u.responseText)t(u.responseText);else throw Error("unable to retrieve "+r);};u.send()}function h(r){var t="";var u=r.indexOf('r.then(()=>k(t),()=>k(t)),Promise.resolve());if(m)if(l=m.slice(m.lastIndexOf(".")+1).toLowerCase(), +contains(["gif","png","jpg","jpeg","bmp"],l)){for(;!n.droppedImage;)n=n.parent;p=new Image;p.onload=()=>{q=newCanvas(new Point(p.width,p.height),!0);q.getContext("2d").drawImage(p,0,0);n.droppedImage(q)};p.src=m}else{if("svg"===l&&!MorphicPreferences.rasterizeSVGs){for(;!n.droppedSVG;)n=n.parent;g(m,r=>{var t=new Image;t.onload=()=>{n.droppedSVG(t,m.slice(m.lastIndexOf("/")+1,m.lastIndexOf(".")))};t.src="data:image/svg+xml;utf8,"+encodeURIComponent(r)})}}else if(a){for(;!n.droppedImage;)n=n.parent; +p=new Image;p.onload=()=>{q=newCanvas(new Point(p.width,p.height),!0);q.getContext("2d").drawImage(p,0,0);n.droppedImage(q)};if(l=h(a))p.src=l}};HandMorph.prototype.destroyTemporaries=function(){this.temporaries.forEach(a=>{a.isClickable&&a.bounds.containsPoint(this.position())||(a.destroy(),this.temporaries.splice(this.temporaries.indexOf(a),1))})};WorldMorph.prototype=new FrameMorph;WorldMorph.prototype.constructor=WorldMorph;WorldMorph.uber=FrameMorph.prototype; +WorldMorph.prototype.customMorphs=[];function WorldMorph(a,b){this.init(a,b)} WorldMorph.prototype.init=function(a,b){WorldMorph.uber.init.call(this);this.color=new Color(205,205,205);this.alpha=1;this.bounds=new Rectangle(0,0,a.width,a.height);this.isVisible=!0;this.isDraggable=!1;this.currentKey=null;this.worldCanvas=a;for(this.stamp=Date.now();this.stamp===Date.now();)nop();this.stamp=Date.now();this.useFillPage=b;void 0===this.useFillPage&&(this.useFillPage=!0);this.isDevMode=!1;this.broken=[];this.animations=[];this.hand=new HandMorph(this);this.activeHandle=this.activeMenu= -this.lastEditedText=this.cursor=this.keyboardFocus=this.keyboardHandler=null;this.initKeyboardHandler();this.resetKeyboardHandler();this.initEventListeners()};WorldMorph.prototype.fullDrawOn=function(a,b){WorldMorph.uber.fullDrawOn.call(this,a,b);this.hand.fullDrawOn(a,b)};WorldMorph.prototype.updateBroken=function(){var a=this,b=this.worldCanvas.getContext("2d");this.condenseDamages();this.broken.forEach(function(c){c.extent().gt(ZERO)&&a.fullDrawOn(b,c)});this.broken=[]}; -WorldMorph.prototype.stepAnimations=function(){this.animations.forEach(function(a){return a.step()});this.animations=this.animations.filter(function(a){return a.isActive})}; -WorldMorph.prototype.condenseDamages=function(){function a(c){var d=[],e=c.length,f=function(l){return l.isNearTo(k,20)},g,h;for(h=0;h{b.extent().gt(ZERO)&&this.fullDrawOn(a,b)});this.broken=[]}; +WorldMorph.prototype.stepAnimations=function(){this.animations.forEach(a=>a.step());this.animations=this.animations.filter(a=>a.isActive)}; +WorldMorph.prototype.condenseDamages=function(){function a(c){var d=[],e=c.length,f=l=>l.isNearTo(k,20),g,h;for(h=0;h{c.reactToWorldResize&&c.reactToWorldResize(this.bounds.copy())})};WorldMorph.prototype.getGlobalPixelColor=function(a){a=this.worldCanvas.getContext("2d").getImageData(a.x,a.y,1,1).data;return new Color(a[0],a[1],a[2])}; +WorldMorph.prototype.initKeyboardHandler=function(){var a=document.getElementById("morphic_keyboard");a?this.keyboardHandler=a:(a=document.createElement("textarea"),a.setAttribute("id","morphic_keyboard"),a.setAttribute("style","caret-color:transparent;"),a.style.position="absolute",a.style.overflow="hidden",a.style.border="none",a.style.resize="none",a.wrap="off",a.world=this,a.style.zIndex=-1,a.autofocus=!0,document.body.appendChild(a),this.keyboardHandler=a,a.addEventListener("keydown",b=>{a.world.currentKey= +b.keyCode;a.world.activeMenu&&!a.world.activeMenu.hasFocus&&(a.world.stopEditing(),a.world.activeMenu.getFocus());a.world.keyboardFocus&&a.world.keyboardFocus.processKeyDown&&a.world.keyboardFocus.processKeyDown(b);9===b.keyCode&&(a.world.keyboardFocus&&a.world.keyboardFocus.processKeyPress&&a.world.keyboardFocus.processKeyPress(b),b.preventDefault());(b.ctrlKey||b.metaKey)&&"dfips".includes(b.key)&&b.preventDefault()},!0),a.addEventListener("keyup",b=>{a.world.currentKey=null;a.world.keyboardFocus&& +a.world.keyboardFocus.processKeyUp&&a.world.keyboardFocus.processKeyUp(b);b.preventDefault()},!1),a.addEventListener("keypress",b=>{a.world.keyboardFocus&&a.world.keyboardFocus.processKeyPress&&(a.world.keyboardFocus.processKeyPress(b),b.preventDefault())},!1),a.addEventListener("input",b=>{a.world.keyboardFocus&&a.world.keyboardFocus.processInput?(a.world.currentKey=null,a.world.keyboardFocus.processInput(b)):a.world.keyboardHandler.value="";b.preventDefault()},!1))}; WorldMorph.prototype.resetKeyboardHandler=function(a){var b=getDocumentPositionOf(this.worldCanvas);a||(this.keyboardHandler.value="");this.keyboardHandler.style.top=Math.ceil(b.y)+"px";this.keyboardHandler.style.left=Math.ceil(b.x)+"px"}; -WorldMorph.prototype.initEventListeners=function(){var a=this,b=this.worldCanvas;this.useFillPage?this.fillPage():this.changed();b.addEventListener("mousedown",function(c){c.preventDefault();a.keyboardHandler.world=a;a.resetKeyboardHandler(!0);a.onNextStep||(a.keyboardHandler.blur(),a.onNextStep=function(){return a.keyboardHandler.focus()});a.hand.processMouseDown(c)},!0);b.addEventListener("touchstart",function(c){return a.hand.processTouchStart(c)},!1);b.addEventListener("mouseup",function(c){c.preventDefault(); -a.hand.processMouseUp(c)},!1);b.addEventListener("dblclick",function(c){c.preventDefault();a.hand.processDoubleClick(c)},!1);b.addEventListener("touchend",function(c){return a.hand.processTouchEnd(c)},!1);b.addEventListener("mousemove",function(c){return a.hand.processMouseMove(c)},!1);b.addEventListener("touchmove",function(c){return a.hand.processTouchMove(c)},{passive:!0});b.addEventListener("contextmenu",function(c){return c.preventDefault()},!0);b.addEventListener("mousewheel",function(c){a.hand.processMouseScroll(c); -c.preventDefault()},!1);b.addEventListener("DOMMouseScroll",function(c){a.hand.processMouseScroll(c);c.preventDefault()},!1);window.addEventListener("dragover",function(c){return c.preventDefault()},!0);window.addEventListener("drop",function(c){a.hand.processDrop(c);c.preventDefault()},!1);window.addEventListener("resize",function(){a.useFillPage&&a.fillPage()},!1);window.onbeforeunload=function(c){if(c=c||window.event)c.returnValue="Are you sure you want to leave?";return"Are you sure you want to leave?"}}; -WorldMorph.prototype.mouseDownLeft=nop;WorldMorph.prototype.mouseClickLeft=nop;WorldMorph.prototype.mouseDownRight=nop;WorldMorph.prototype.mouseClickRight=nop;WorldMorph.prototype.wantsDropOf=function(){return this.acceptsDrops};WorldMorph.prototype.droppedImage=function(){return null};WorldMorph.prototype.droppedSVG=function(){return null};WorldMorph.prototype.nextTab=function(a){var b=this.nextEntryField(a);b&&(a.clearSelection(),b.selectAll(),b.edit())}; -WorldMorph.prototype.previousTab=function(a){var b=this.previousEntryField(a);b&&(a.clearSelection(),b.selectAll(),b.edit())}; -WorldMorph.prototype.contextMenu=function(){var a=this;var b=this.isDevMode?new MenuMorph(this,this.constructor.name||this.constructor.toString().split(" ")[1].split("(")[0]):new MenuMorph(this,"Morphic");this.isDevMode&&(b.addItem("demo...","userCreateMorph","sample morphs"),b.addLine(),b.addItem("hide all...","hideAll"),b.addItem("show all...","showAllHiddens"),b.addItem("move all inside...","keepAllSubmorphsWithin","keep all submorphs\nwithin and visible"),b.addItem("inspect...","inspect","open a window on\nall properties"), -b.addItem("screenshot...",function(){return window.open(a.fullImage().toDataURL())},"open a new window\nwith a picture of this morph"),b.addLine(),b.addItem("restore display","changed","redraw the\nscreen once"),b.addItem("fill page...","fillPage","let the World automatically\nadjust to browser resizing"),useBlurredShadows?b.addItem("sharp shadows...","toggleBlurredShadows","sharp drop shadows\nuse for old browsers"):b.addItem("blurred shadows...","toggleBlurredShadows","blurry shades,\n use for new browsers"), -b.addItem("color...",function(){a.pickColor(b.title+localize("\ncolor:"),a.setColor,a,a.color)},"choose the World's\nbackground color"),MorphicPreferences===standardSettings?b.addItem("touch screen settings","togglePreferences","bigger menu fonts\nand sliders"):b.addItem("standard settings","togglePreferences","smaller menu fonts\nand sliders"),MorphicPreferences.showHoles?b.addItem("hide holes","toggleHolesDisplay","debug untouchable regions"):b.addItem("show holes","toggleHolesDisplay","debug untouchable regions"), -b.addLine());this.isDevMode?b.addItem("user mode...","toggleDevMode","disable developers'\ncontext menus"):b.addItem("development mode...","toggleDevMode");b.addItem("about morphic.js...","about");return b}; -WorldMorph.prototype.userCreateMorph=function(){function a(f){f=f.fullCopy();f.isDraggable=!0;f.pickUp(c)}var b=this,c=this,d;var e=new MenuMorph(this,"make a morph");e.addItem("rectangle",function(){return a(new Morph)});e.addItem("box",function(){return a(new BoxMorph)});e.addItem("circle box",function(){return a(new CircleBoxMorph)});e.addLine();e.addItem("slider",function(){return a(new SliderMorph)});e.addItem("dial",function(){d=new DialMorph;d.pickUp(b)});e.addItem("frame",function(){d=new FrameMorph; -d.setExtent(new Point(350,250));a(d)});e.addItem("scroll frame",function(){d=new ScrollFrameMorph;d.contents.acceptsDrops=!0;d.contents.adjustBounds();d.setExtent(new Point(350,250));a(d)});e.addItem("handle",function(){return a(new HandleMorph)});e.addLine();e.addItem("string",function(){d=new StringMorph("Hello, World!");d.isEditable=!0;a(d)});e.addItem("text",function(){d=new TextMorph("Ich wei\u00df nicht, was soll es bedeuten, dass ich so traurig bin, ein M\u00e4rchen aus uralten Zeiten, das kommt mir nicht aus dem Sinn. Die Luft ist k\u00fchl und es dunkelt, und ruhig flie\u00dft der Rhein; der Gipfel des Berges funkelt im Abendsonnenschein. Die sch\u00f6nste Jungfrau sitzet dort oben wunderbar, ihr gold'nes Geschmeide blitzet, sie k\u00e4mmt ihr goldenes Haar, sie k\u00e4mmt es mit goldenem Kamme, und singt ein Lied dabei; das hat eine wundersame, gewalt'ge Melodei. Den Schiffer im kleinen Schiffe, ergreift es mit wildem Weh; er schaut nicht die Felsenriffe, er schaut nur hinauf in die H\u00f6h'. Ich glaube, die Wellen verschlingen am Ende Schiffer und Kahn, und das hat mit ihrem Singen, die Loreley getan."); -d.isEditable=!0;d.maxWidth=300;d.fixLayout();a(d)});e.addItem("speech bubble",function(){d=new SpeechBubbleMorph("Hello, World!");a(d)});e.addLine();e.addItem("gray scale palette",function(){return a(new GrayPaletteMorph)});e.addItem("color palette",function(){return a(new ColorPaletteMorph)});e.addItem("color picker",function(){return a(new ColorPickerMorph)});e.addLine();e.addItem("sensor demo",function(){d=new MouseSensorMorph;d.setColor(new Color(230,200,100));d.edge=35;d.border=15;d.borderColor= -new Color(200,100,50);d.alpha=.2;d.setExtent(new Point(100,100));a(d)});e.addItem("animation demo",function(){var f=new BouncerMorph;f.setPosition(new Point(50,20));f.setExtent(new Point(300,200));f.alpha=.9;f.speed=3;var g=new BouncerMorph;g.setColor(new Color(50,50,50));g.setPosition(new Point(80,80));g.setExtent(new Point(80,250));g.type="horizontal";g.direction="right";g.alpha=.9;g.speed=5;var h=new BouncerMorph;h.setColor(new Color(20,20,20));h.setPosition(new Point(90,140));h.setExtent(new Point(40, -30));h.type="horizontal";h.direction="right";h.speed=3;var k=new BouncerMorph;k.setColor(new Color(200,20,20));k.setPosition(new Point(90,140));k.setExtent(new Point(20,20));k.type="vertical";k.direction="up";k.speed=8;var l=new BouncerMorph;l.setColor(new Color(20,200,20));l.setPosition(new Point(120,140));l.setExtent(new Point(20,20));l.type="vertical";l.direction="down";l.speed=4;g.add(k);g.add(h);f.add(l);f.add(g);a(f)});e.addItem("pen",function(){return a(new PenMorph)});this.customMorphs.length&& -(e.addLine(),this.customMorphs.forEach(function(f){if(f instanceof Array){var g=new MenuMorph;f[1].forEach(function(h){return g.addItem(h,function(){return a(h instanceof Array?h[0]:h)})});e.addMenu(f[0],g)}else e.addItem(f.toString(),function(){return a(f)})}));e.popUpAtHand(this)};WorldMorph.prototype.toggleDevMode=function(){this.isDevMode=!this.isDevMode};WorldMorph.prototype.hideAll=function(){this.children.forEach(function(a){return a.hide()})}; -WorldMorph.prototype.showAllHiddens=function(){this.forAllChildren(function(a){a.isVisible||a.show()})};WorldMorph.prototype.about=function(){var a="",b;for(b in modules)Object.prototype.hasOwnProperty.call(modules,b)&&(a+="\n"+b+" ("+modules[b]+")");""!==a&&(a="\n\nmodules:\n\nmorphic ("+morphicVersion+")"+a);this.inform("morphic.js\n\na lively Web GUI\ninspired by Squeak\n"+morphicVersion+"\n\nwritten by Jens M\u00f6nig\njens@moenig.org"+a)}; +WorldMorph.prototype.initEventListeners=function(){var a=this.worldCanvas;this.useFillPage?this.fillPage():this.changed();a.addEventListener("mousedown",b=>{b.preventDefault();this.keyboardHandler.world=this;this.resetKeyboardHandler(!0);this.onNextStep||(this.keyboardHandler.blur(),this.onNextStep=()=>this.keyboardHandler.focus());this.hand.processMouseDown(b)},!0);a.addEventListener("touchstart",b=>this.hand.processTouchStart(b),!1);a.addEventListener("mouseup",b=>{b.preventDefault();this.hand.processMouseUp(b)}, +!1);a.addEventListener("dblclick",b=>{b.preventDefault();this.hand.processDoubleClick(b)},!1);a.addEventListener("touchend",b=>this.hand.processTouchEnd(b),!1);a.addEventListener("mousemove",b=>this.hand.processMouseMove(b),!1);a.addEventListener("touchmove",b=>this.hand.processTouchMove(b),{passive:!0});a.addEventListener("contextmenu",b=>b.preventDefault(),!0);a.addEventListener("mousewheel",b=>{this.hand.processMouseScroll(b);b.preventDefault()},!1);a.addEventListener("DOMMouseScroll",b=>{this.hand.processMouseScroll(b); +b.preventDefault()},!1);window.addEventListener("dragover",b=>b.preventDefault(),!0);window.addEventListener("drop",b=>{this.hand.processDrop(b);b.preventDefault()},!1);window.addEventListener("resize",()=>{this.useFillPage&&this.fillPage()},!1);window.onbeforeunload=b=>{if(b=b||window.event)b.returnValue="Are you sure you want to leave?";return"Are you sure you want to leave?"}};WorldMorph.prototype.mouseDownLeft=nop;WorldMorph.prototype.mouseClickLeft=nop;WorldMorph.prototype.mouseDownRight=nop; +WorldMorph.prototype.mouseClickRight=nop;WorldMorph.prototype.wantsDropOf=function(){return this.acceptsDrops};WorldMorph.prototype.droppedImage=function(){return null};WorldMorph.prototype.droppedSVG=function(){return null};WorldMorph.prototype.nextTab=function(a){var b=this.nextEntryField(a);b&&(a.clearSelection(),b.selectAll(),b.edit())};WorldMorph.prototype.previousTab=function(a){var b=this.previousEntryField(a);b&&(a.clearSelection(),b.selectAll(),b.edit())}; +WorldMorph.prototype.contextMenu=function(){var a=this.isDevMode?new MenuMorph(this,this.constructor.name||this.constructor.toString().split(" ")[1].split("(")[0]):new MenuMorph(this,"Morphic");this.isDevMode&&(a.addItem("demo...","userCreateMorph","sample morphs"),a.addLine(),a.addItem("hide all...","hideAll"),a.addItem("show all...","showAllHiddens"),a.addItem("move all inside...","keepAllSubmorphsWithin","keep all submorphs\nwithin and visible"),a.addItem("inspect...","inspect","open a window on\nall properties"), +a.addItem("screenshot...",()=>window.open(this.fullImage().toDataURL()),"open a new window\nwith a picture of this morph"),a.addLine(),a.addItem("restore display","changed","redraw the\nscreen once"),a.addItem("fill page...","fillPage","let the World automatically\nadjust to browser resizing"),useBlurredShadows?a.addItem("sharp shadows...","toggleBlurredShadows","sharp drop shadows\nuse for old browsers"):a.addItem("blurred shadows...","toggleBlurredShadows","blurry shades,\n use for new browsers"), +a.addItem("color...",()=>{this.pickColor(a.title+localize("\ncolor:"),this.setColor,this,this.color)},"choose the World's\nbackground color"),MorphicPreferences===standardSettings?a.addItem("touch screen settings","togglePreferences","bigger menu fonts\nand sliders"):a.addItem("standard settings","togglePreferences","smaller menu fonts\nand sliders"),MorphicPreferences.showHoles?a.addItem("hide holes","toggleHolesDisplay","debug untouchable regions"):a.addItem("show holes","toggleHolesDisplay","debug untouchable regions"), +a.addLine());this.isDevMode?a.addItem("user mode...","toggleDevMode","disable developers'\ncontext menus"):a.addItem("development mode...","toggleDevMode");a.addItem("about morphic.js...","about");return a}; +WorldMorph.prototype.userCreateMorph=function(){function a(e){e=e.fullCopy();e.isDraggable=!0;e.pickUp(b)}var b=this,c;var d=new MenuMorph(this,"make a morph");d.addItem("rectangle",()=>a(new Morph));d.addItem("box",()=>a(new BoxMorph));d.addItem("circle box",()=>a(new CircleBoxMorph));d.addLine();d.addItem("slider",()=>a(new SliderMorph));d.addItem("dial",()=>{c=new DialMorph;c.pickUp(this)});d.addItem("frame",()=>{c=new FrameMorph;c.setExtent(new Point(350,250));a(c)});d.addItem("scroll frame", +()=>{c=new ScrollFrameMorph;c.contents.acceptsDrops=!0;c.contents.adjustBounds();c.setExtent(new Point(350,250));a(c)});d.addItem("handle",()=>a(new HandleMorph));d.addLine();d.addItem("string",()=>{c=new StringMorph("Hello, World!");c.isEditable=!0;a(c)});d.addItem("text",()=>{c=new TextMorph("Ich wei\u00df nicht, was soll es bedeuten, dass ich so traurig bin, ein M\u00e4rchen aus uralten Zeiten, das kommt mir nicht aus dem Sinn. Die Luft ist k\u00fchl und es dunkelt, und ruhig flie\u00dft der Rhein; der Gipfel des Berges funkelt im Abendsonnenschein. Die sch\u00f6nste Jungfrau sitzet dort oben wunderbar, ihr gold'nes Geschmeide blitzet, sie k\u00e4mmt ihr goldenes Haar, sie k\u00e4mmt es mit goldenem Kamme, und singt ein Lied dabei; das hat eine wundersame, gewalt'ge Melodei. Den Schiffer im kleinen Schiffe, ergreift es mit wildem Weh; er schaut nicht die Felsenriffe, er schaut nur hinauf in die H\u00f6h'. Ich glaube, die Wellen verschlingen am Ende Schiffer und Kahn, und das hat mit ihrem Singen, die Loreley getan."); +c.isEditable=!0;c.maxWidth=300;c.fixLayout();a(c)});d.addItem("speech bubble",()=>{c=new SpeechBubbleMorph("Hello, World!");a(c)});d.addLine();d.addItem("gray scale palette",()=>a(new GrayPaletteMorph));d.addItem("color palette",()=>a(new ColorPaletteMorph));d.addItem("color picker",()=>a(new ColorPickerMorph));d.addLine();d.addItem("sensor demo",()=>{c=new MouseSensorMorph;c.setColor(new Color(230,200,100));c.edge=35;c.border=15;c.borderColor=new Color(200,100,50);c.alpha=.2;c.setExtent(new Point(100, +100));a(c)});d.addItem("animation demo",()=>{var e=new BouncerMorph;e.setPosition(new Point(50,20));e.setExtent(new Point(300,200));e.alpha=.9;e.speed=3;var f=new BouncerMorph;f.setColor(new Color(50,50,50));f.setPosition(new Point(80,80));f.setExtent(new Point(80,250));f.type="horizontal";f.direction="right";f.alpha=.9;f.speed=5;var g=new BouncerMorph;g.setColor(new Color(20,20,20));g.setPosition(new Point(90,140));g.setExtent(new Point(40,30));g.type="horizontal";g.direction="right";g.speed=3;var h= +new BouncerMorph;h.setColor(new Color(200,20,20));h.setPosition(new Point(90,140));h.setExtent(new Point(20,20));h.type="vertical";h.direction="up";h.speed=8;var k=new BouncerMorph;k.setColor(new Color(20,200,20));k.setPosition(new Point(120,140));k.setExtent(new Point(20,20));k.type="vertical";k.direction="down";k.speed=4;f.add(h);f.add(g);e.add(k);e.add(f);a(e)});d.addItem("pen",()=>a(new PenMorph));this.customMorphs.length&&(d.addLine(),this.customMorphs.forEach(e=>{if(e instanceof Array){var f= +new MenuMorph;e[1].forEach(g=>f.addItem(g,()=>a(g instanceof Array?g[0]:g)));d.addMenu(e[0],f)}else d.addItem(e.toString(),()=>a(e))}));d.popUpAtHand(this)};WorldMorph.prototype.toggleDevMode=function(){this.isDevMode=!this.isDevMode};WorldMorph.prototype.hideAll=function(){this.children.forEach(a=>a.hide())};WorldMorph.prototype.showAllHiddens=function(){this.forAllChildren(a=>{a.isVisible||a.show()})}; +WorldMorph.prototype.about=function(){var a="",b;for(b in modules)Object.prototype.hasOwnProperty.call(modules,b)&&(a+="\n"+b+" ("+modules[b]+")");""!==a&&(a="\n\nmodules:\n\nmorphic ("+morphicVersion+")"+a);this.inform("morphic.js\n\na lively Web GUI\ninspired by Squeak\n"+morphicVersion+"\n\nwritten by Jens M\u00f6nig\njens@moenig.org"+a)}; WorldMorph.prototype.edit=function(a){if(this.lastEditedText!==a){isNil(this.lastEditedText)||this.stopEditing();if(!a.isEditable)return null;this.cursor&&this.cursor.destroy();this.worldCanvas.focus();this.keyboardHandler.focus();this.keyboardFocus=this.cursor=new CursorMorph(a,this.keyboardHandler);a.parent.add(this.cursor);MorphicPreferences.useSliderForInput&&(a.parentThatIsA(MenuMorph)||this.slide(a));this.lastEditedText!==a&&a.escalateEvent("freshTextEdit",a);this.lastEditedText=a}}; -WorldMorph.prototype.slide=function(a){var b=parseFloat(a.text);isNaN(b)&&(b=0);var c=new MenuMorph;b=new SliderMorph(b-25,b+25,b,10,"horizontal");b.alpha=1;b.color=new Color(225,225,225);b.button.color=c.borderColor;b.button.highlightColor=b.button.color.copy();b.button.highlightColor.b+=100;b.button.pressColor=b.button.color.copy();b.button.pressColor.b+=150;b.setExtent(new Point(10*MorphicPreferences.scrollBarSize,MorphicPreferences.menuFontSize));b.action=function(d){a.changed();a.text=Math.round(d).toString(); +WorldMorph.prototype.slide=function(a){var b=parseFloat(a.text);isNaN(b)&&(b=0);var c=new MenuMorph;b=new SliderMorph(b-25,b+25,b,10,"horizontal");b.alpha=1;b.color=new Color(225,225,225);b.button.color=c.borderColor;b.button.highlightColor=b.button.color.copy();b.button.highlightColor.b+=100;b.button.pressColor=b.button.color.copy();b.button.pressColor.b+=150;b.setExtent(new Point(10*MorphicPreferences.scrollBarSize,MorphicPreferences.menuFontSize));b.action=d=>{a.changed();a.text=Math.round(d).toString(); a.fixLayout();a.rerender();a.escalateEvent("reactToSliderEdit",a)};c.items.push(b);c.popup(this,a.bottomLeft().add(new Point(0,5)))};WorldMorph.prototype.stopEditing=function(){this.cursor&&(this.cursor.target.escalateEvent("reactToEdit",this.cursor.target),this.cursor.target.clearSelection(),this.cursor.destroy(),this.cursor=null);this.keyboardFocus&&this.keyboardFocus.stopEditing&&this.keyboardFocus.stopEditing();this.lastEditedText=this.keyboardFocus=null}; WorldMorph.prototype.toggleBlurredShadows=function(){useBlurredShadows=!useBlurredShadows};WorldMorph.prototype.togglePreferences=function(){MorphicPreferences=MorphicPreferences===standardSettings?touchScreenSettings:standardSettings};WorldMorph.prototype.toggleHolesDisplay=function(){MorphicPreferences.showHoles=!MorphicPreferences.showHoles;this.rerender()}; -(function(a){function b(g){this.name=g}var c=function(){this.ide=null;this.registry=[];this.pendingExtensions=[]};c.prototype.initialize=function(g){var h=this;this.ide=g;this.pendingExtensions.forEach(function(k){return h.load(k)});this.pendingExtensions=[]};c.prototype.load=function(g){var h=this;g=new g(this.ide);if(!this.isLoaded(g.name)){try{this.validate(g)}catch(k){this.ide.showMessage('Unable to load extension "'+g.name+'": '+k.message);return}this.registry.push(g);this.ide.controlBar.extensionsButton.show(); -g.getCategories().forEach(function(k){return h.registerCategory(k)});this.ide.createCategories();this.ide.createCorralBar();this.ide.fixLayout();SpriteMorph.prototype.initBlocks()}};c.prototype.onNewProject=function(){this.registry.forEach(function(g){return g.onNewProject()})};c.prototype.onOpenRole=function(){this.registry.forEach(function(g){return g.onOpenRole()})};c.prototype.register=function(g){this.isReady()?this.load(g):this.pendingExtensions.push(g)};c.prototype.isReady=function(){return!!this.ide}; -c.prototype.validate=function(g){var h=this,k=g.getPalette();g.getBlocks().forEach(function(l){if(SpriteMorph.prototype[l.name]||StageMorph.prototype[l.name]||Process.prototype[l.name])throw Error('Cannot override existing "'+l.name+'" block');h.findWatcherReceivers(k,l.name).forEach(function(m){if(!l.receivers.includes(m))throw Error('Cannot add a watcher toggle for "'+l.spec+'" on '+m.name+'. Did you forget to add ".for('+(m.name+')" when defining the block?'));})})};c.prototype.isLoaded=function(g){return this.registry.find(function(h){return h.name=== -g})};c.prototype.getLabelPart=function(g){var h=this.registry.flatMap(function(k){return k.getLabelParts()}).find(function(k){return k.spec===g});if(h)return h.factory(g)};c.prototype.registerCategory=function(g){var h=g.name;g=g.color;SpriteMorph.prototype.categories.splice(SpriteMorph.prototype.categories.length-3,0,h);SpriteMorph.prototype.blockColor[h]=g};c.prototype.getPaletteContents=function(g,h){return this.registry.flatMap(function(k){return k.getPalette()}).filter(function(k){return k.isVisible(g, -h)}).flatMap(function(k){return k.contents})};c.prototype.findWatcherReceivers=function(g,h){return g.filter(function(k){return k.contents.find(function(l){return"watcher"===l.type&&l.name===h})}).map(function(k){return k.targetObject}).reduce(function(k,l){k.includes(l)||k.push(l);return k},[])};c.prototype.initBlocks=function(){var g=this,h=this.registry.flatMap(function(l){return l.getBlocks()}),k=this.registry.flatMap(function(l){return l.getPalette()});h.forEach(function(l){SpriteMorph.prototype.blocks[l.name]= -{type:l.type,category:l.category,spec:l.spec,defaults:l.defaults};var m=g.findWatcherReceivers(k,l.name);m.forEach(function(n){if(!l.receivers.includes(n))throw Error("Cannot add a watcher toggle for "+l.spec+" on "+n.name+'. Did you forget to add ".for('+(n.name+')" when defining the block?'));});0===m.length&&m.push(Process);m.forEach(function(n){return n.prototype[l.name]=l.impl})})};b.prototype.getMenu=function(){return null};b.prototype.getCategories=function(){return[]};b.prototype.getBlocks= -function(){return[]};b.prototype.getPalette=function(){return[]};b.prototype.getLabelParts=function(){return[]};b.prototype.onNewProject=b.prototype.onOpenRole=function(){};var d=function(g,h,k){this.category=g;this.contents=h;this.targetObject=k};d.prototype.isVisible=function(g,h){return this.category===h&&(!this.targetObject||g instanceof this.targetObject)};var e=function(g,h,k,l,m,n){m=void 0===m?[]:m;this.name=g;this.type=h;this.category=k;this.spec=l;this.defaults=m;this.impl=n;this.receivers= -[]};e.prototype.for=function(g){for(var h=[],k=0;kthis.load(l));this.pendingExtensions=[]}load(k){k=new k(this.ide);if(!this.isLoaded(k.name)){try{this.validate(k)}catch(l){this.ide.showMessage(`Unable to load extension "${k.name}": ${l.message}`);return}this.registry.push(k);this.ide.controlBar.extensionsButton.show();k.getCategories().forEach(l=>this.registerCategory(l)); +this.ide.createCategories();this.ide.createCorralBar();this.ide.fixLayout();SpriteMorph.prototype.initBlocks()}}onNewProject(){this.registry.forEach(k=>k.onNewProject())}onOpenRole(){this.registry.forEach(k=>k.onOpenRole())}register(k){this.isReady()?this.load(k):this.pendingExtensions.push(k)}isReady(){return!!this.ide}validate(k){const l=k.getPalette();k.getBlocks().forEach(m=>{if(SpriteMorph.prototype[m.name]||StageMorph.prototype[m.name]||Process.prototype[m.name])throw Error(`Cannot override existing "${m.name}" block`); +this.findWatcherReceivers(l,m.name).forEach(n=>{if(!m.receivers.includes(n))throw Error(`Cannot add a watcher toggle for "${m.spec}" on ${n.name}.`+` Did you forget to add ".for(${n.name})" when defining the block?`);})})}isLoaded(k){return this.registry.find(l=>l.name===k)}getLabelPart(k){const l=this.registry.flatMap(m=>m.getLabelParts()).find(m=>m.spec===k);if(l)return l.factory(k)}registerCategory(k){const {name:l,color:m}=k;SpriteMorph.prototype.categories.splice(SpriteMorph.prototype.categories.length- +3,0,l);SpriteMorph.prototype.blockColor[l]=m}getPaletteContents(k,l){return this.registry.flatMap(m=>m.getPalette()).filter(m=>m.isVisible(k,l)).flatMap(m=>m.contents)}findWatcherReceivers(k,l){return k.filter(m=>m.contents.find(n=>"watcher"===n.type&&n.name===l)).map(m=>m.targetObject).reduce((m,n)=>{m.includes(n)||m.push(n);return m},[])}initBlocks(){const k=this.registry.flatMap(m=>m.getBlocks()),l=this.registry.flatMap(m=>m.getPalette());k.forEach(m=>{SpriteMorph.prototype.blocks[m.name]={type:m.type, +category:m.category,spec:m.spec,defaults:m.defaults};const n=this.findWatcherReceivers(l,m.name);n.forEach(p=>{if(!m.receivers.includes(p))throw Error(`Cannot add a watcher toggle for ${m.spec} on ${p.name}.`+` Did you forget to add ".for(${p.name})" when defining the block?`);});0===n.length&&n.push(Process);n.forEach(p=>p.prototype[m.name]=m.impl)})}}b.prototype.getMenu=function(){return null};b.prototype.getCategories=function(){return[]};b.prototype.getBlocks=function(){return[]};b.prototype.getPalette= +function(){return[]};b.prototype.getLabelParts=function(){return[]};b.prototype.onNewProject=b.prototype.onOpenRole=function(){};class d{constructor(k,l){"%"!==k[0]&&(k="%"+k);this.spec=k;this.factory=l}}class e{constructor(k,l,m){this.category=k;this.contents=l;this.targetObject=m}isVisible(k,l){return this.category===l&&(!this.targetObject||k instanceof this.targetObject)}}class f{constructor(k,l,m,n,p=[],q){this.name=k;this.type=l;this.category=m;this.spec=n;this.defaults=p;this.impl=q;this.receivers= +[]}for(...k){this.receivers=k;return this}}class g{constructor(k,l=new Color(120,120,120)){this.name=k;this.color=l}}class h{constructor(k){this.name=k;this.type="block"}withWatcherToggle(){this.type="watcher";return this}}b.PaletteCategory=e;b.Palette={};b.Palette.Block=h;b.Palette.Space={name:"-",type:"space"};b.Palette.BigSpace={name:"=",type:"space"};b.Block=f;b.Category=g;b.LabelPart=d;a.Extension=b;a.ExtensionRegistry=c;a.NetsBloxExtensions=new c})(this);modules.locale="2020-August-05"; +var SnapTranslator=new Localizer;function localize(a){return SnapTranslator.translate(a)}function Localizer(a,b){this.language=a||"en";this.dict=b||{}}Localizer.prototype.translate=function(a){return Object.prototype.hasOwnProperty.call(this.dict[this.language],a)?this.dict[this.language][a]:a};Localizer.prototype.languages=function(){var a,b=[];for(a in this.dict)Object.prototype.hasOwnProperty.call(this.dict,a)&&b.push(a);return b.sort()}; +Localizer.prototype.languageName=function(a){return this.dict[a].language_name||a};Localizer.prototype.credits=function(){var a="";this.languages().forEach(b=>{a=a+"\n"+this.languageName(b)+" ("+b+") - "+this.dict[b].language_translator+" - "+this.dict[b].last_changed});return a}; +Localizer.prototype.unload=function(){var a,b=["language_name","language_translator","last_changed"];this.languages().forEach(c=>{var d;if("en"!==c)for(d in a=this.dict[c],a)Object.prototype.hasOwnProperty.call(a,d)&&!contains(b,d)&&delete a[d]})}; SnapTranslator.dict.en={language_name:"English",language_translator:"Jens M\u00f6nig","translator_e-mail":"jens@moenig.org",last_changed:"2020-07-09",__shout__go__:"green flag clicked",any:"random","length of %s":"length of text %s","file menu import hint":"load an exported project file\nor block library, a costume\nor a sound","settings menu prefer empty slots hint":"check to focus on empty slots\nwhen dragging & dropping reporters","costumes tab help":"import a picture from another web page or from\na file on your computer by dropping it here\n", "block deletion dialog text":"Are you sure you want to delete this\ncustom block and all its instances?","download to disk text":"This item could not be opened in a new tab.\nIt has been saved to your browser's downloads folder.","unable to export text":"This item could not be exported from Snap!.\nIt's likely that your project may contain a lot of media (sounds and images) or that you are using an older browser.Please try using a recent version of Chrome, Firefox, or Safari."}; SnapTranslator.dict.de={language_name:"Deutsch",language_translator:"Jens M\u00f6nig, Jadga H\u00fcgle","translator_e-mail":"jens@moenig.org, jadga.huegle@sap.com",last_changed:"2020-07-24"};SnapTranslator.dict.it={language_name:"Italiano",language_translator:"Stefano Federici, Alberto Firpo, Massimo Ghisalberti","translator_e-mail":"s_federici@yahoo.com, albertofirpo12@gmail.com, zairik@gmail.com",last_changed:"2016-05-10"}; @@ -575,15 +517,15 @@ SymbolMorph.prototype.renderSymbolGlobe=function(a,b,c){var d=this.symbolWidth() SymbolMorph.prototype.renderSymbolFlipHorizontal=function(a,b){var c=this.symbolWidth(),d=this.size,e=c/2,f=c/15;a.strokeStyle=b.toString();a.lineWidth=c/15;a.beginPath();a.moveTo(0+f,d-f/2);a.lineTo(e-1.2*f,d-f/2);a.lineTo(e-1.2*f,2*f);a.closePath();a.stroke();a.fillStyle=b.toString();a.lineWidth=c/15;a.beginPath();a.moveTo(c-f,d-f/2);a.lineTo(e+1.2*f,d-f/2);a.lineTo(e+1.2*f,2*f);a.closePath();a.stroke();a.fill()}; SymbolMorph.prototype.renderSymbolFlipVertical=function(a,b){a.translate(0,this.size);a.rotate(radians(-90));this.renderSymbolFlipHorizontal(a,b)}; SymbolMorph.prototype.renderSymbolNetsBloxLogo=function(a,b){var c=this.symbolWidth(),d=this.size,e=c/14,f=c-2*e;a.beginPath();a.arc(c/2,d/2,2*e,radians(180),radians(270));a.strokeStyle=b.toString();a.beginPath();a.arc(c/2,d/2,e,0,radians(360));a.stroke();a.beginPath();a.arc(c/2,d/2,2*e,0,radians(90));a.stroke();a.beginPath();a.arc(c/2,d/2,3*e,0,radians(90));a.stroke();a.beginPath();a.arc(c/2,d/2,2*e,radians(180),radians(270));a.stroke();a.beginPath();a.arc(c/2,d/2,3*e,radians(180),radians(270)); -a.stroke();b=-60;var g=e;d/=2;f/=2;for(c=f-2*e-c/48;300>b;){var h=g,k=d,l=radians(b),m=c*Math.cos(l),n=c*Math.sin(l),p=e*Math.cos(l)+h,r=e*Math.sin(l)+k;a.beginPath();a.arc(h,k,e,l,l+2*Math.PI);a.moveTo(p,r);a.lineTo(h+m,k+n);a.stroke();g+=f*Math.cos(radians(b));d+=f*Math.sin(radians(b));b+=60}}; +a.stroke();b=-60;let g=e;d/=2;f/=2;for(c=f-2*e-c/48;300>b;){var h=g,k=d,l=radians(b);const m=c*Math.cos(l),n=c*Math.sin(l),p=e*Math.cos(l)+h,q=e*Math.sin(l)+k;a.beginPath();a.arc(h,k,e,l,l+2*Math.PI);a.moveTo(p,q);a.lineTo(h+m,k+n);a.stroke();g+=f*Math.cos(radians(b));d+=f*Math.sin(radians(b));b+=60}}; SymbolMorph.prototype.renderSymbolQueue=function(a,b){var c=this.symbolWidth()/5,d=c/2,e=3*c,f=1*d+e/2,g=d;a.fillStyle=b.toString();var h=function(k){k+=c;var l=e/2;a.fillStyle=b.toString();a.beginPath();a.moveTo(k,f);a.lineTo(k+-1*c,f+l/2);a.lineTo(k+-1*c,f-l/2);a.fill()};h(g);g+=c+d;a.fillRect(g,d,c,e);g+=c+d;a.fillRect(g,d,c,e);h(g+(c+d))}; SymbolMorph.prototype.renderSymbolMail=function(a,b){var c=this.symbolWidth(),d=this.size;a.lineWidth=Math.max(c/12,1);a.fillStyle=b.toString();a.strokeStyle=b.darker(50).toString();a.fillRect(0,0,c,d);a.rect(0,0,c,d);a.moveTo(0,0);a.lineTo(c/2,2*d/3);a.lineTo(c,0);a.stroke()}; SymbolMorph.prototype.renderSymbolEncircledCircle=function(a,b){var c=this.symbolWidth(),d=Math.max(c/30,.5);a.strokeStyle=b.toString();a.fillStyle=b.toString();a.beginPath();a.arc(c/2,c/2,c/4,radians(0),radians(360),!1);a.fill();a.beginPath();a.lineWidth=2*d;a.arc(c/2,c/2,c/2-d,radians(0),radians(360),!1);a.stroke()}; SymbolMorph.prototype.renderSymbolJumpForward=function(a,b){var c=3/7*this.symbolWidth(),d=4/7*this.size,e=1.5/7*this.size,f=1/7*this.symbolWidth();a.fillStyle=b.toString();a.beginPath();a.moveTo(0,e);a.lineTo(c,e+Math.round(d/2));a.lineTo(0,e+d);a.lineTo(0,e);a.closePath();a.fill();a.beginPath();a.moveTo(c,e);a.lineTo(2*c,e+Math.round(d/2));a.lineTo(c,e+d);a.lineTo(c,e);a.closePath();a.fill();a.fillRect(2*c,e,f,d)}; SymbolMorph.prototype.renderSymbolJumpBackward=function(a,b){var c=3/7*this.symbolWidth(),d=4/7*this.size,e=1.5/7*this.size,f=1/7*this.symbolWidth();a.fillStyle=b.toString();a.beginPath();a.moveTo(f+c,e);a.lineTo(f,e+Math.round(d/2));a.lineTo(f+c,e+d);a.lineTo(f+c,e);a.closePath();a.fill();a.beginPath();a.moveTo(f+2*c,e);a.lineTo(f+c,e+Math.round(d/2));a.lineTo(f+2*c,e+d);a.lineTo(f+2*c,e);a.closePath();a.fill();a.fillRect(0,e,f,d)}; -SymbolMorph.prototype.renderSymbolStepForward=function(a,b){var c=this.symbolWidth(),d=this.size;a.fillStyle=b.toString();a.beginPath();a.moveTo(0,0);a.lineTo(.75*c,Math.round(d/2));a.lineTo(0,d);a.lineTo(0,0);a.closePath();a.fill();a.fillRect(.75*c,0,.25*c,d)}; -SymbolMorph.prototype.renderSymbolStepBackward=function(a,b){var c=this.symbolWidth(),d=this.size;a.fillStyle=b.toString();a.beginPath();a.moveTo(.25*c,Math.round(d/2));a.lineTo(c,0);a.lineTo(c,d);a.lineTo(.25*c,Math.round(d/2));a.closePath();a.fill();a.fillRect(0,0,.25*c,d)}; -SymbolMorph.prototype.renderSymbolPuzzlePiece=function(a,b){var c=this.symbolWidth(),d=this.size,e=c/8,f=Math.min(c,d)/6;a.fillStyle=b.toString();a.beginPath();b=c-f;c=(c-f)/2;var g=(d-f)/2+f;a.arc(e,e+f,e,Math.PI,1.5*Math.PI);a.arc(c,f,f,Math.PI,0);a.arc(b-e,f+e,e,1.5*Math.PI,0);a.arc(b,g,f,1.5*Math.PI,.5*Math.PI);a.arc(b-e,d-e,e,0,.5*Math.PI);a.arc(c,d,f,0,Math.PI,!0);a.arc(e,d-e,e,.5*Math.PI,Math.PI);a.arc(0,g,f,.5*Math.PI,3*Math.PI/2,!0);a.closePath();a.fill()};modules.widgets="2020-July-27"; +SymbolMorph.prototype.renderSymbolStepForward=function(a,b){const c=this.symbolWidth(),d=this.size;a.fillStyle=b.toString();a.beginPath();a.moveTo(0,0);a.lineTo(.75*c,Math.round(d/2));a.lineTo(0,d);a.lineTo(0,0);a.closePath();a.fill();a.fillRect(.75*c,0,.25*c,d)}; +SymbolMorph.prototype.renderSymbolStepBackward=function(a,b){const c=this.symbolWidth(),d=this.size;a.fillStyle=b.toString();a.beginPath();a.moveTo(.25*c,Math.round(d/2));a.lineTo(c,0);a.lineTo(c,d);a.lineTo(.25*c,Math.round(d/2));a.closePath();a.fill();a.fillRect(0,0,.25*c,d)}; +SymbolMorph.prototype.renderSymbolPuzzlePiece=function(a,b){var c=this.symbolWidth();const d=this.size,e=c/8,f=Math.min(c,d)/6;a.fillStyle=b.toString();a.beginPath();b=c-f;c=(c-f)/2;const g=(d-f)/2+f;a.arc(e,e+f,e,Math.PI,1.5*Math.PI);a.arc(c,f,f,Math.PI,0);a.arc(b-e,f+e,e,1.5*Math.PI,0);a.arc(b,g,f,1.5*Math.PI,.5*Math.PI);a.arc(b-e,d-e,e,0,.5*Math.PI);a.arc(c,d,f,0,Math.PI,!0);a.arc(e,d-e,e,.5*Math.PI,Math.PI);a.arc(0,g,f,.5*Math.PI,3*Math.PI/2,!0);a.closePath();a.fill()};modules.widgets="2020-July-27"; PushButtonMorph.prototype=new TriggerMorph;PushButtonMorph.prototype.constructor=PushButtonMorph;PushButtonMorph.uber=TriggerMorph.prototype;PushButtonMorph.prototype.fontSize=10;PushButtonMorph.prototype.fontStyle="sans-serif";PushButtonMorph.prototype.labelColor=BLACK;PushButtonMorph.prototype.disabledColor=new Color(75,75,75);PushButtonMorph.prototype.labelShadowColor=WHITE;PushButtonMorph.prototype.labelShadowOffset=new Point(1,1);PushButtonMorph.prototype.color=new Color(220,220,220); PushButtonMorph.prototype.pressColor=new Color(115,180,240);PushButtonMorph.prototype.highlightColor=PushButtonMorph.prototype.pressColor.lighter(50);PushButtonMorph.prototype.outlineColor=new Color(30,30,30);PushButtonMorph.prototype.outlineGradient=!1;PushButtonMorph.prototype.contrast=60;PushButtonMorph.prototype.edge=2;PushButtonMorph.prototype.corner=5;PushButtonMorph.prototype.outline=1;PushButtonMorph.prototype.padding=3;function PushButtonMorph(a,b,c,d,e){this.init(a,b,c,d,e)} PushButtonMorph.prototype.init=function(a,b,c,d,e){this.is3D=!1;this.target=a||null;this.action=b||null;this.environment=d||null;this.labelString=c||null;this.label=null;this.labelMinExtent=ZERO;this.hint=e||null;this.isDisabled=!1;TriggerMorph.uber.init.call(this);this.enabledColor=PushButtonMorph.prototype.labelColor;this.disabledColor=PushButtonMorph.prototype.disabledColor;this.color=PushButtonMorph.prototype.color;this.createLabel();this.fixLayout();this.rerender()}; @@ -600,9 +542,9 @@ Math.max(this.corner-this.outline-this.edge,0),f-this.corner,g-this.corner,Math. h;a.lineCap="round";a.lineWidth=this.edge;a.beginPath();a.moveTo(f-this.outline-this.edge/2,e);a.lineTo(f-this.outline-this.edge/2,g-e);a.stroke()}};PushButtonMorph.prototype.outlinePath=BoxMorph.prototype.outlinePath; PushButtonMorph.prototype.createLabel=function(){var a=!MorphicPreferences.isFlat||this.is3D;null!==this.label&&this.label.destroy();this.labelString instanceof SymbolMorph?(this.label=this.labelString.fullCopy(),a&&(this.label.shadowOffset=this.labelShadowOffset,this.label.shadowColor=this.labelShadowColor),this.label.color=this.labelColor):this.label=new StringMorph(localize(this.labelString),this.fontSize,this.fontStyle,!0,!1,!1,a?this.labelShadowOffset:null,this.labelShadowColor,this.labelColor); this.add(this.label)};PushButtonMorph.prototype.trigger=function(){this.isDisabled||PushButtonMorph.uber.trigger.call(this)};PushButtonMorph.prototype.mouseDownLeft=function(){this.isDisabled||PushButtonMorph.uber.mouseDownLeft.call(this)};PushButtonMorph.prototype.mouseClickLeft=function(){this.isDisabled||PushButtonMorph.uber.mouseClickLeft.call(this)};PushButtonMorph.prototype.isEnabled=function(){return!this.isDisabled}; -PushButtonMorph.prototype.updateLabelColors=function(){var a=!MorphicPreferences.isFlat||this.is3D;this.label&&(this.label.color=this.labelColor,this.label.fontSize=this.fontSize,a&&(this.label.shadowOffset=this.labelShadowOffset,this.label.shadowColor=this.labelShadowColor),this.label.fixLayout(!0))};PushButtonMorph.prototype.disable=function(){this.isDisabled=!0;this.forAllChildren(function(a){return a.alpha=.3});this.rerender()}; -PushButtonMorph.prototype.enable=function(){this.isDisabled=!1;this.forAllChildren(function(a){return a.alpha=1});this.rerender()};ToggleButtonMorph.prototype=new PushButtonMorph;ToggleButtonMorph.prototype.constructor=ToggleButtonMorph;ToggleButtonMorph.uber=PushButtonMorph.prototype;ToggleButtonMorph.prototype.contrast=30;ToggleButtonMorph.prototype.labelPressColor=null;function ToggleButtonMorph(a,b,c,d,e,f,g,h,k,l){this.init(a,b,c,d,e,f,g,h,k,l)} -ToggleButtonMorph.prototype.init=function(a,b,c,d,e,f,g,h,k,l){this.state=!1;this.query=e||function(){return!0};this.minWidth=h||null;this.hasPreview=k||!1;this.isPicture=l||!1;this.hasNeutralBackground=!1;this.trueStateLabel=null;ToggleButtonMorph.uber.init.call(this,b,c,d,f,g);a&&(this.color=a[0],this.highlightColor=a[1],this.pressColor=a[2]);this.refresh();this.rerender()}; +PushButtonMorph.prototype.updateLabelColors=function(){var a=!MorphicPreferences.isFlat||this.is3D;this.label&&(this.label.color=this.labelColor,this.label.fontSize=this.fontSize,a&&(this.label.shadowOffset=this.labelShadowOffset,this.label.shadowColor=this.labelShadowColor),this.label.fixLayout(!0))};PushButtonMorph.prototype.disable=function(){this.isDisabled=!0;this.forAllChildren(a=>a.alpha=.3);this.rerender()}; +PushButtonMorph.prototype.enable=function(){this.isDisabled=!1;this.forAllChildren(a=>a.alpha=1);this.rerender()};ToggleButtonMorph.prototype=new PushButtonMorph;ToggleButtonMorph.prototype.constructor=ToggleButtonMorph;ToggleButtonMorph.uber=PushButtonMorph.prototype;ToggleButtonMorph.prototype.contrast=30;ToggleButtonMorph.prototype.labelPressColor=null;function ToggleButtonMorph(a,b,c,d,e,f,g,h,k,l){this.init(a,b,c,d,e,f,g,h,k,l)} +ToggleButtonMorph.prototype.init=function(a,b,c,d,e,f,g,h,k,l){this.state=!1;this.query=e||(()=>!0);this.minWidth=h||null;this.hasPreview=k||!1;this.isPicture=l||!1;this.hasNeutralBackground=!1;this.trueStateLabel=null;ToggleButtonMorph.uber.init.call(this,b,c,d,f,g);a&&(this.color=a[0],this.highlightColor=a[1],this.pressColor=a[2]);this.refresh();this.rerender()}; ToggleButtonMorph.prototype.mouseEnter=function(){var a=this.hint instanceof Function?this.hint():this.hint;if(!this.state||this.hasNeutralBackground)this.userState="highlight",this.rerender();a&&this.bubbleHelp(a)};ToggleButtonMorph.prototype.mouseLeave=function(){if(!this.state||this.hasNeutralBackground)this.userState="normal",this.rerender();this.schedule&&(this.schedule.isActive=!1);this.hint&&this.world().hand.destroyTemporaries()}; ToggleButtonMorph.prototype.mouseDownLeft=function(){this.state||(this.userState="pressed",this.rerender())};ToggleButtonMorph.prototype.mouseClickLeft=function(){this.state||(this.userState="highlight",this.rerender());this.trigger()};ToggleButtonMorph.prototype.trigger=function(){ToggleButtonMorph.uber.trigger.call(this);this.refresh()}; ToggleButtonMorph.prototype.refresh=function(){(this.state="function"===typeof this.query?this.query.call(this.target):this.target[this.query]())?(this.userState="pressed",this.labelPressColor&&this.label.setColor(this.labelPressColor),this.trueStateLabel&&(this.label.hide(),this.trueStateLabel.show())):(this.userState="normal",this.labelPressColor&&this.label.setColor(this.labelColor),this.trueStateLabel&&(this.label.show(),this.trueStateLabel.hide()));this.rerender()}; @@ -621,7 +563,7 @@ function TabMorph(a,b,c,d,e,f,g){this.init(a,b,c,d,e,f,g)}TabMorph.prototype.fix TabMorph.prototype.drawBackground=function(a,b){var c=this.width(),d=this.height(),e=this.corner;a.fillStyle=b.toString();a.beginPath();a.moveTo(0,d);a.bezierCurveTo(e,d,e,0,2*e,0);a.lineTo(c-2*e,0);a.bezierCurveTo(c-e,0,c-e,d,c,d);a.closePath();a.fill()};TabMorph.prototype.drawOutline=function(){nop()}; TabMorph.prototype.drawEdges=function(a,b,c,d){if(!MorphicPreferences.isFlat||this.is3D){var e=this.width(),f=this.height(),g=this.corner,h=this.edge,k=h/2;nop(b);b=a.createLinearGradient(0,0,e,0);b.addColorStop(0,c.toString());b.addColorStop(1,d.toString());a.strokeStyle=b;a.lineCap="round";a.lineWidth=h;a.beginPath();a.moveTo(0,f+k);a.bezierCurveTo(g,f,g,0,2*g,k);a.lineTo(e-2*g,k);a.bezierCurveTo(e-g,0,e-g,f,e,f+k);a.stroke()}};ToggleMorph.prototype=new PushButtonMorph; ToggleMorph.prototype.constructor=ToggleMorph;ToggleMorph.uber=PushButtonMorph.prototype;function ToggleMorph(a,b,c,d,e,f,g,h,k){this.init(a,b,c,d,e,f,g,h,k)} -ToggleMorph.prototype.init=function(a,b,c,d,e,f,g,h,k){this.padding=1;a=a||"checkbox";this.corner="checkbox"===a?0:fontHeight(this.fontSize)/2+this.outline+this.padding;this.state=!1;this.query=e||function(){return!0};this.tick=null;this.captionString=d||null;this.labelAlignment="right";this.element=h||null;this.builder=k||null;this.toggleElement=null;ToggleMorph.uber.init.call(this,b,c,"checkbox"===a?"\u2713":"\u25cf",f,g);this.fixLayout();this.refresh()}; +ToggleMorph.prototype.init=function(a,b,c,d,e,f,g,h,k){this.padding=1;a=a||"checkbox";this.corner="checkbox"===a?0:fontHeight(this.fontSize)/2+this.outline+this.padding;this.state=!1;this.query=e||(()=>!0);this.tick=null;this.captionString=d||null;this.labelAlignment="right";this.element=h||null;this.builder=k||null;this.toggleElement=null;ToggleMorph.uber.init.call(this,b,c,"checkbox"===a?"\u2713":"\u25cf",f,g);this.fixLayout();this.refresh()}; ToggleMorph.prototype.fixLayout=function(){var a=2*this.padding+2*this.outline;null!==this.tick&&(this.bounds.setHeight(this.tick.rawHeight()+a),this.bounds.setWidth(this.tick.width()+a),this.bounds.setWidth(Math.max(this.width(),this.height())),this.bounds.setHeight(Math.max(this.width(),this.height())),this.tick.setCenter(this.center()));this.state?this.tick.show():this.tick.hide();if(this.toggleElement&&"right"===this.labelAlignment){var b=this.top()+(this.height()-this.toggleElement.height())/ 2;this.toggleElement.setPosition(new Point(this.right()+a,b))}null!==this.label&&(b=this.top()+(this.height()-this.label.height())/2,"right"===this.labelAlignment?this.label.setPosition(new Point(this.toggleElement?this.toggleElement instanceof ToggleElementMorph?this.toggleElement.right():this.toggleElement.right()+a:this.right()+a,b)):this.label.setPosition(new Point(this.left()-this.label.width()-a,b)))}; ToggleMorph.prototype.createLabel=function(){var a=!MorphicPreferences.isFlat||this.is3D;null===this.label&&this.captionString&&(this.label=new TextMorph(localize(this.captionString),this.fontSize,this.fontStyle,!0),this.add(this.label));null===this.tick&&(this.tick=new StringMorph(localize(this.labelString),this.fontSize,this.fontStyle,!0,!1,!1,a?new Point(1,1):null,new Color(240,240,240)),this.add(this.tick));null===this.toggleElement&&this.element&&(this.element instanceof Morph?this.toggleElement= @@ -629,9 +571,9 @@ new ToggleElementMorph(this.target,this.action,this.element,this.query,this.envi ToggleMorph.prototype.refresh=function(){(this.state="function"===typeof this.query?this.query.call(this.target):this.target[this.query]())?this.tick.show():this.tick.hide();this.toggleElement&&this.toggleElement.refresh&&this.toggleElement.refresh()};ToggleMorph.prototype.mouseDownLeft=function(){PushButtonMorph.uber.mouseDownLeft.call(this);this.tick&&this.tick.setCenter(this.center().add(1))}; ToggleMorph.prototype.mouseClickLeft=function(){PushButtonMorph.uber.mouseClickLeft.call(this);this.tick&&this.tick.setCenter(this.center())};ToggleMorph.prototype.mouseLeave=function(){PushButtonMorph.uber.mouseLeave.call(this);this.tick&&this.tick.setCenter(this.center())};ToggleElementMorph.prototype=new TriggerMorph;ToggleElementMorph.prototype.constructor=ToggleElementMorph;ToggleElementMorph.uber=TriggerMorph.prototype;ToggleElementMorph.prototype.contrast=50; ToggleElementMorph.prototype.shadowOffset=new Point(2,2);ToggleElementMorph.prototype.shadowAlpha=.6;ToggleElementMorph.prototype.fontSize=10;ToggleElementMorph.prototype.inactiveColor=new Color(180,180,180);function ToggleElementMorph(a,b,c,d,e,f,g,h){this.init(a,b,c,d,e,f,g,h)} -ToggleElementMorph.prototype.init=function(a,b,c,d,e,f,g,h){this.target=a||null;this.action=b||null;this.element=c;this.query=d||function(){return!0};this.environment=e||null;this.hint=f||null;this.builder=g||"nop";this.captionString=h||null;this.labelAlignment="right";this.state=!1;TriggerMorph.uber.init.call(this);this.color=c.color;this.createLabel()}; -ToggleElementMorph.prototype.render=function(a){var b=this,c=!MorphicPreferences.isFlat||this.is3D,d=function(){c&&b.element.addShadow(b.shadowOffset,"normal"===b.userState?0:b.shadowAlpha)};this.color=this.element.color;this.element.removeShadow();this.element[this.builder]();"pressed"!==this.userState&&(this.element.removeShadow(),this.element.setColor(this.inactiveColor),this.element[this.builder](this.contrast),"highlight"===this.userState&&(this.element.removeShadow(),this.element.setColor(this.color.lighter(this.contrast)), -this.element[this.builder](this.contrast)));this.element.doWithAlpha?a.drawImage(this.element.doWithAlpha(1,function(){d();return b.element.fullImage()}),0,0):(d(),a.drawImage(this.element.fullImage(),0,0));this.element.removeShadow();this.element.setColor(this.color);this.element[this.builder]()};ToggleElementMorph.prototype.setColor=function(a){this.element.setColor(a);this.fixLayout();this.refresh()}; +ToggleElementMorph.prototype.init=function(a,b,c,d,e,f,g,h){this.target=a||null;this.action=b||null;this.element=c;this.query=d||(()=>!0);this.environment=e||null;this.hint=f||null;this.builder=g||"nop";this.captionString=h||null;this.labelAlignment="right";this.state=!1;TriggerMorph.uber.init.call(this);this.color=c.color;this.createLabel()}; +ToggleElementMorph.prototype.render=function(a){var b=!MorphicPreferences.isFlat||this.is3D,c=()=>{b&&this.element.addShadow(this.shadowOffset,"normal"===this.userState?0:this.shadowAlpha)};this.color=this.element.color;this.element.removeShadow();this.element[this.builder]();"pressed"!==this.userState&&(this.element.removeShadow(),this.element.setColor(this.inactiveColor),this.element[this.builder](this.contrast),"highlight"===this.userState&&(this.element.removeShadow(),this.element.setColor(this.color.lighter(this.contrast)), +this.element[this.builder](this.contrast)));this.element.doWithAlpha?a.drawImage(this.element.doWithAlpha(1,()=>{c();return this.element.fullImage()}),0,0):(c(),a.drawImage(this.element.fullImage(),0,0));this.element.removeShadow();this.element.setColor(this.color);this.element[this.builder]()};ToggleElementMorph.prototype.setColor=function(a){this.element.setColor(a);this.fixLayout();this.refresh()}; ToggleElementMorph.prototype.fixLayout=function(){this.element.fixLayout();this.bounds.setExtent(this.element.fullBounds().extent().add(2*this.shadowBlur))}; ToggleElementMorph.prototype.createLabel=function(){if(this.captionString){this.label=new StringMorph(this.captionString,this.fontSize,this.fontStyle,!0);this.add(this.label);var a=this.top()+(this.height()-this.label.height())/2;"right"===this.labelAlignment?this.label.setPosition(new Point(this.right(),a)):this.label.setPosition(new Point(this.left()-this.label.width(),a))}};ToggleElementMorph.prototype.trigger=ToggleButtonMorph.prototype.trigger;ToggleElementMorph.prototype.refresh=ToggleButtonMorph.prototype.refresh; ToggleElementMorph.prototype.mouseEnter=ToggleButtonMorph.prototype.mouseEnter;ToggleElementMorph.prototype.mouseLeave=ToggleButtonMorph.prototype.mouseLeave;ToggleElementMorph.prototype.mouseDownLeft=ToggleButtonMorph.prototype.mouseDownLeft;ToggleElementMorph.prototype.mouseClickLeft=ToggleButtonMorph.prototype.mouseClickLeft;DialogBoxMorph.prototype=new Morph;DialogBoxMorph.prototype.constructor=DialogBoxMorph;DialogBoxMorph.uber=Morph.prototype;DialogBoxMorph.prototype.fontSize=12; @@ -640,27 +582,26 @@ DialogBoxMorph.prototype.buttonFontSize=12;DialogBoxMorph.prototype.buttonCorner DialogBoxMorph.prototype.init=function(a,b,c){this.is3D=!1;this.target=a||null;this.action=b||null;this.environment=c||null;this.buttons=this.body=this.head=this.label=this.labelString=this.key=null;DialogBoxMorph.uber.init.call(this);this.noDropShadow=this.isDraggable=!0;this.fullShadowSource=!1;this.color=PushButtonMorph.prototype.color;this.createLabel();this.createButtons();this.setExtent(new Point(300,150))}; DialogBoxMorph.prototype.inform=function(a,b,c,d){var e=new TextMorph(b,this.fontSize,this.fontStyle,!0,!1,"center",null,null,MorphicPreferences.isFlat?null:new Point(1,1),WHITE);this.key||(this.key="inform"+a+b);e.enableLinks=!0;this.labelString=a;this.createLabel();d&&this.setPicture(d);b&&this.addBody(e);this.addButton("ok","OK");this.fixLayout();this.popUp(c)}; DialogBoxMorph.prototype.askYesNo=function(a,b,c,d){var e=new TextMorph(b,this.fontSize,this.fontStyle,!0,!1,"center",null,null,MorphicPreferences.isFlat?null:new Point(1,1),WHITE);this.key||(this.key="decide"+a+b);this.labelString=a;this.createLabel();d&&this.setPicture(d);this.addBody(e);this.addButton("ok","Yes");this.addButton("cancel","No");this.fixLayout();this.popUp(c)}; -DialogBoxMorph.prototype.prompt=function(a,b,c,d,e,f,g,h,k,l,m){var n=Math.pow(10,void 0===m?2:m),p=new InputFieldMorph(b,g||!1,e||null,e?f||!1:!1);p.setWidth(250);if(g){if(d){var r=new AlignmentMorph("column",this.padding);d.setPosition(r.position());r.add(d)}if(!isNil(h)&&!isNil(k)){var q=new SliderMorph(h*n,k*n,parseFloat(b)*n,(k-h)/10*n,"horizontal");q.alpha=1;q.color=this.color.lighter(50);q.setHeight(.7*p.height());q.setWidth(p.width());q.action=function(t){l&&l(t/n);p.setContents(t/n);p.edit()}; -r||(r=new AlignmentMorph("column",this.padding));r.add(q)}r&&(r.fixLayout(),this.setPicture(r),r.fixLayout())}else d&&this.setPicture(d);this.reactToChoice=function(t){q&&(q.value=t*n,q.fixLayout(),q.rerender());l&&l(t)};p.reactToInput=function(){var t=p.getValue();q&&(t=Math.max(t,h),q.value=t*n,q.fixLayout(),q.rerender());l&&l(t)};this.labelString=a;this.createLabel();this.key||(this.key="prompt"+a+b);this.addBody(p);p.fixLayout();this.addButton("ok","OK");this.addButton("cancel","Cancel");this.fixLayout(); -this.popUp(c)}; -DialogBoxMorph.prototype.promptCode=function(a,b,c,d,e){var f=new ScrollFrameMorph,g=new TextMorph(b||""),h=new AlignmentMorph("column",this.padding),k=d?Math.max(d.width,400):400;this.getInput=function(){return g.text};f.padding=6;f.setWidth(k);f.acceptsDrops=!1;f.contents.acceptsDrops=!1;g.fontName="monospace";g.fontStyle="monospace";g.fontSize=11;g.setPosition(f.topLeft().add(f.padding));g.enableSelecting();g.isEditable=!0;f.setHeight(k/4);f.fixLayout=nop;f.edge=InputFieldMorph.prototype.edge;f.fontSize= -InputFieldMorph.prototype.fontSize;f.typeInPadding=InputFieldMorph.prototype.typeInPadding;f.contrast=InputFieldMorph.prototype.contrast;f.render=InputFieldMorph.prototype.render;f.drawRectBorder=InputFieldMorph.prototype.drawRectBorder;f.addContents(g);g.fixLayout();d&&this.setPicture(d);this.labelString=a;this.createLabel();this.key||(this.key="promptCode"+a+b);h.setColor(this.color);h.add(f);e&&h.add(new TextMorph(localize(e),10,null,!1,null,null,null,null,MorphicPreferences.isFlat?null:new Point(1, -1),WHITE));h.fixLayout();this.addBody(h);this.addButton("ok","OK");this.addButton("cancel","Cancel");this.fixLayout();this.popUp(c);g.edit()}; -DialogBoxMorph.prototype.promptVector=function(a,b,c,d,e,f,g,h){function k(t){return new TextMorph(localize(t),10,null,!1,null,null,null,null,MorphicPreferences.isFlat?null:new Point(1,1),WHITE)}var l=new AlignmentMorph("row",4),m=new InputFieldMorph(b.x.toString(),!0),n=new InputFieldMorph(b.y.toString(),!0);b=new AlignmentMorph("column",2);var p=new AlignmentMorph("column",2),r=new AlignmentMorph("column",2),q=new AlignmentMorph("column",this.padding);r.alignment="left";r.setColor(this.color);q.setColor(this.color); -b.alignment="left";b.setColor(this.color);p.alignment="left";p.setColor(this.color);b.add(k(d));b.add(m);p.add(k(e));p.add(n);l.add(b);l.add(p);r.add(l);h&&q.add(k(h));q.add(r);l.fixLayout();b.fixLayout();p.fixLayout();r.fixLayout();q.fixLayout();this.labelString=a;this.createLabel();g&&this.setPicture(g);this.addBody(q);this.addButton("ok","OK");c instanceof Point&&this.addButton(function(){m.setContents(c.x.toString());n.setContents(c.y.toString())},"Default");this.addButton("cancel","Cancel"); -this.fixLayout();this.edit=function(){m.edit()};this.getInput=function(){return new Point(m.getValue(),n.getValue())};this.key||(this.key="vector"+a);this.popUp(f)}; -DialogBoxMorph.prototype.promptCredentials=function(a,b,c,d,e,f,g,h,k,l){function m(H){return new TextMorph(localize(H),10,null,!1,null,null,null,null,MorphicPreferences.isFlat?null:new Point(1,1),WHITE)}function n(H,Q){H=new PushButtonMorph(F,function(){return window.open(Q)}," "+localize(H)+" ");H.fontSize=10;H.corner=F.buttonCorner;H.edge=F.buttonEdge;H.outline=F.buttonOutline;H.outlineColor=F.buttonOutlineColor;H.outlineGradient=F.buttonOutlineGradient;H.padding=F.buttonPadding;H.contrast=F.buttonContrast; -H.fixLayout();return H}function p(){function H(K,z){z=new SpeechBubbleMorph(localize(z));z.isPointingRight=!1;z.fixLayout();z.popUp(h,K.leftCenter().subtract(new Point(z.width()+2,0)));K.edit&&K.edit()}var Q=q.getValue();if("login"===b)var N=[r,t];else if("signup"===b)N=[r,G,O,q,t,u];else if("changePassword"===b)N=[v,t,u];else if("resetPassword"===b||"resendVerification"===b)N=[r];if(N=detect(N,function(K){return!K.getValue()}))return H(N,"please fill out\nthis field"),!1;if("signup"===b){if(-1r.getValue().length)return H(r,"User name must be four\ncharacters or longer"),!1;if(-1Q.length)return H(q,"please provide a valid\nemail address"),!1}if("changePassword"===b||"signup"===b){if(6>t.getValue().length)return H(t,"password must be six\ncharacters or longer"),!1;if(t.getValue()!==u.getValue())return H(u,"passwords do\nnot match"),!1}return"signup"!==b||w?!0:(H(R,"please agree to\nthe TOS"), -!1)}var r=new InputFieldMorph,q=new InputFieldMorph,t=new InputFieldMorph,u=new InputFieldMorph,v=new InputFieldMorph,w=!1,y=new AlignmentMorph("row",4),x=new AlignmentMorph("column",2),A=new AlignmentMorph("column",2),B=new AlignmentMorph("column",2),C=new AlignmentMorph("row",4),D=new AlignmentMorph("column",this.padding),E={},L=(new Date).getFullYear(),I=L-20,F=this;var G=new InputFieldMorph(null,!1,{January:["January"],February:["February"],March:["March"],April:["April"],May:["May"],June:["June"], -July:["July"],August:["August"],September:["September"],October:["October"],November:["November"],December:["December"]},!0);for(L;L>I;--L)E[L.toString()+" "]=L;E[I+" "+localize("or before")]="< "+L;var O=new InputFieldMorph(null,!1,E,!0);B.alignment="left";B.setColor(this.color);D.setColor(this.color);x.alignment="left";x.setColor(this.color);A.alignment="left";A.setColor(this.color);r.setWidth(200);G.setWidth(100);O.contents().minWidth=80;O.setWidth(80);q.setWidth(200);t.setWidth(200);u.setWidth(200); -v.setWidth(200);t.contents().text.toggleIsPassword();u.contents().text.toggleIsPassword();v.contents().text.toggleIsPassword();"login"===b&&(B.add(m("User name:")),B.add(r));if("signup"===b){B.add(m("User name:"));B.add(r);x.add(m("Birth date:"));x.add(G);A.add(m("year:"));A.add(O);y.add(x);y.add(A);B.add(y);var P=m("foo");B.add(P);B.add(q);B.add(m("Password:"));B.add(t);B.add(m("Repeat Password:"));B.add(u)}"login"===b&&(B.add(m("Password:")),B.add(t));"changePassword"===b&&(B.add(m("Old password:")), -B.add(v),B.add(m("New password:")),B.add(t),B.add(m("Repeat new password:")),B.add(u));if("resetPassword"===b||"resendVerification"===b)B.add(m("User name:")),B.add(r);l&&D.add(m(l));D.add(B);(c||e)&&D.add(C);c&&C.add(n(d,c));e&&C.add(n(f,e));if(g){var R=new ToggleMorph("checkbox",this,function(){return w=!w},g,function(){return w});R.edge=this.buttonEdge/2;R.outline=this.buttonOutline/2;R.outlineColor=this.buttonOutlineColor;R.outlineGradient=this.buttonOutlineGradient;R.contrast=this.buttonContrast; -R.fixLayout();D.add(R)}y.fixLayout();x.fixLayout();A.fixLayout();B.fixLayout();C.fixLayout();D.fixLayout();this.labelString=a;this.createLabel();k&&this.setPicture(k);this.addBody(D);this.addButton("ok","OK");this.addButton("cancel","Cancel");this.fixLayout();this.accept=function(){p()&&DialogBoxMorph.prototype.accept.call(F)};this.edit=function(){"changePassword"===b?v.edit():r.edit()};this.getInput=function(){return{username:r.getValue(),email:q.getValue(),oldpassword:v.getValue(),password:t.getValue(), -passwordRepeat:u.getValue(),choice:w}};this.reactToChoice=function(){if("signup"===b){P.changed();var H=P,Q=(new Date).getFullYear()+(new Date).getMonth()/12,N=+O.getValue()||0,K=G.getValue();K instanceof Array&&(K=K[0]);isNaN(N)&&(N=0);K="January February March April May June July August September October November December".split(" ").indexOf(K);isNaN(K)&&(K=0);H.text=13>=Q-(N+K/12)?"E-mail address of parent or guardian:":"E-mail address:";P.text=localize(P.text);P.fixLayout();P.rerender()}};this.reactToChoice(); -this.key||(this.key="credentials"+a+b);this.popUp(h)};DialogBoxMorph.prototype.accept=function(){if(this.action)if("function"===typeof this.target)"function"===typeof this.action?this.target.call(this.environment,this.action.call()):this.target.call(this.environment,this.action);else if("function"===typeof this.action)this.action.call(this.target,this.getInput());else this.target[this.action](this.getInput());this.destroy()};DialogBoxMorph.prototype.withKey=function(a){this.key=a;return this}; +DialogBoxMorph.prototype.prompt=function(a,b,c,d,e,f,g,h,k,l,m=2){var n=Math.pow(10,m),p=new InputFieldMorph(b,g||!1,e||null,e?f||!1:!1);p.setWidth(250);if(g){if(d){var q=new AlignmentMorph("column",this.padding);d.setPosition(q.position());q.add(d)}if(!isNil(h)&&!isNil(k)){var r=new SliderMorph(h*n,k*n,parseFloat(b)*n,(k-h)/10*n,"horizontal");r.alpha=1;r.color=this.color.lighter(50);r.setHeight(.7*p.height());r.setWidth(p.width());r.action=t=>{l&&l(t/n);p.setContents(t/n);p.edit()};q||=new AlignmentMorph("column", +this.padding);q.add(r)}q&&(q.fixLayout(),this.setPicture(q),q.fixLayout())}else d&&this.setPicture(d);this.reactToChoice=function(t){r&&(r.value=t*n,r.fixLayout(),r.rerender());l&&l(t)};p.reactToInput=function(){var t=p.getValue();r&&(t=Math.max(t,h),r.value=t*n,r.fixLayout(),r.rerender());l&&l(t)};this.labelString=a;this.createLabel();this.key||(this.key="prompt"+a+b);this.addBody(p);p.fixLayout();this.addButton("ok","OK");this.addButton("cancel","Cancel");this.fixLayout();this.popUp(c)}; +DialogBoxMorph.prototype.promptCode=function(a,b,c,d,e){var f=new ScrollFrameMorph,g=new TextMorph(b||""),h=new AlignmentMorph("column",this.padding),k=d?Math.max(d.width,400):400;this.getInput=function(){return g.text};f.padding=6;f.setWidth(k);f.acceptsDrops=!1;f.contents.acceptsDrops=!1;g.fontName="monospace";g.fontStyle="monospace";g.fontSize=11;g.setPosition(f.topLeft().add(f.padding));g.enableSelecting();g.isEditable=!0;f.setHeight(k/4);f.fixLayout=nop;f.edge=InputFieldMorph.prototype.edge; +f.fontSize=InputFieldMorph.prototype.fontSize;f.typeInPadding=InputFieldMorph.prototype.typeInPadding;f.contrast=InputFieldMorph.prototype.contrast;f.render=InputFieldMorph.prototype.render;f.drawRectBorder=InputFieldMorph.prototype.drawRectBorder;f.addContents(g);g.fixLayout();d&&this.setPicture(d);this.labelString=a;this.createLabel();this.key||(this.key="promptCode"+a+b);h.setColor(this.color);h.add(f);e&&h.add(new TextMorph(localize(e),10,null,!1,null,null,null,null,MorphicPreferences.isFlat? +null:new Point(1,1),WHITE));h.fixLayout();this.addBody(h);this.addButton("ok","OK");this.addButton("cancel","Cancel");this.fixLayout();this.popUp(c);g.edit()}; +DialogBoxMorph.prototype.promptVector=function(a,b,c,d,e,f,g,h){function k(t){return new TextMorph(localize(t),10,null,!1,null,null,null,null,MorphicPreferences.isFlat?null:new Point(1,1),WHITE)}var l=new AlignmentMorph("row",4),m=new InputFieldMorph(b.x.toString(),!0),n=new InputFieldMorph(b.y.toString(),!0);b=new AlignmentMorph("column",2);var p=new AlignmentMorph("column",2),q=new AlignmentMorph("column",2),r=new AlignmentMorph("column",this.padding);q.alignment="left";q.setColor(this.color);r.setColor(this.color); +b.alignment="left";b.setColor(this.color);p.alignment="left";p.setColor(this.color);b.add(k(d));b.add(m);p.add(k(e));p.add(n);l.add(b);l.add(p);q.add(l);h&&r.add(k(h));r.add(q);l.fixLayout();b.fixLayout();p.fixLayout();q.fixLayout();r.fixLayout();this.labelString=a;this.createLabel();g&&this.setPicture(g);this.addBody(r);this.addButton("ok","OK");c instanceof Point&&this.addButton(()=>{m.setContents(c.x.toString());n.setContents(c.y.toString())},"Default");this.addButton("cancel","Cancel");this.fixLayout(); +this.edit=function(){m.edit()};this.getInput=function(){return new Point(m.getValue(),n.getValue())};this.key||(this.key="vector"+a);this.popUp(f)}; +DialogBoxMorph.prototype.promptCredentials=function(a,b,c,d,e,f,g,h,k,l){function m(G){return new TextMorph(localize(G),10,null,!1,null,null,null,null,MorphicPreferences.isFlat?null:new Point(1,1),WHITE)}function n(G,S){G=new PushButtonMorph(D,()=>window.open(S)," "+localize(G)+" ");G.fontSize=10;G.corner=D.buttonCorner;G.edge=D.buttonEdge;G.outline=D.buttonOutline;G.outlineColor=D.buttonOutlineColor;G.outlineGradient=D.buttonOutlineGradient;G.padding=D.buttonPadding;G.contrast=D.buttonContrast; +G.fixLayout();return G}function p(){function G(J,M){M=new SpeechBubbleMorph(localize(M));M.isPointingRight=!1;M.fixLayout();M.popUp(h,J.leftCenter().subtract(new Point(M.width()+2,0)));J.edit&&J.edit()}var S=r.getValue();if("login"===b)var N=[q,t];else if("signup"===b)N=[q,E,O,r,t,u];else if("changePassword"===b)N=[v,t,u];else if("resetPassword"===b||"resendVerification"===b)N=[q];if(N=detect(N,J=>!J.getValue()))return G(N,"please fill out\nthis field"),!1;if("signup"===b){if(-1q.getValue().length)return G(q,"User name must be four\ncharacters or longer"),!1;if(-1S.length)return G(r,"please provide a valid\nemail address"),!1}if("changePassword"===b||"signup"===b){if(6>t.getValue().length)return G(t,"password must be six\ncharacters or longer"),!1;if(t.getValue()!==u.getValue())return G(u,"passwords do\nnot match"),!1}return"signup"!==b||w?!0:(G(T,"please agree to\nthe TOS"), +!1)}var q=new InputFieldMorph,r=new InputFieldMorph,t=new InputFieldMorph,u=new InputFieldMorph,v=new InputFieldMorph,w=!1,y=new AlignmentMorph("row",4),x=new AlignmentMorph("column",2),z=new AlignmentMorph("column",2),A=new AlignmentMorph("column",2),B=new AlignmentMorph("row",4),C=new AlignmentMorph("column",this.padding),F={},K=(new Date).getFullYear(),I=K-20,D=this;var E=new InputFieldMorph(null,!1,{January:["January"],February:["February"],March:["March"],April:["April"],May:["May"],June:["June"], +July:["July"],August:["August"],September:["September"],October:["October"],November:["November"],December:["December"]},!0);for(K;K>I;--K)F[K.toString()+" "]=K;F[I+" "+localize("or before")]="< "+K;var O=new InputFieldMorph(null,!1,F,!0);A.alignment="left";A.setColor(this.color);C.setColor(this.color);x.alignment="left";x.setColor(this.color);z.alignment="left";z.setColor(this.color);q.setWidth(200);E.setWidth(100);O.contents().minWidth=80;O.setWidth(80);r.setWidth(200);t.setWidth(200);u.setWidth(200); +v.setWidth(200);t.contents().text.toggleIsPassword();u.contents().text.toggleIsPassword();v.contents().text.toggleIsPassword();"login"===b&&(A.add(m("User name:")),A.add(q));if("signup"===b){A.add(m("User name:"));A.add(q);x.add(m("Birth date:"));x.add(E);z.add(m("year:"));z.add(O);y.add(x);y.add(z);A.add(y);var P=m("foo");A.add(P);A.add(r);A.add(m("Password:"));A.add(t);A.add(m("Repeat Password:"));A.add(u)}"login"===b&&(A.add(m("Password:")),A.add(t));"changePassword"===b&&(A.add(m("Old password:")), +A.add(v),A.add(m("New password:")),A.add(t),A.add(m("Repeat new password:")),A.add(u));if("resetPassword"===b||"resendVerification"===b)A.add(m("User name:")),A.add(q);l&&C.add(m(l));C.add(A);(c||e)&&C.add(B);c&&B.add(n(d,c));e&&B.add(n(f,e));if(g){var T=new ToggleMorph("checkbox",this,()=>w=!w,g,()=>w);T.edge=this.buttonEdge/2;T.outline=this.buttonOutline/2;T.outlineColor=this.buttonOutlineColor;T.outlineGradient=this.buttonOutlineGradient;T.contrast=this.buttonContrast;T.fixLayout();C.add(T)}y.fixLayout(); +x.fixLayout();z.fixLayout();A.fixLayout();B.fixLayout();C.fixLayout();this.labelString=a;this.createLabel();k&&this.setPicture(k);this.addBody(C);this.addButton("ok","OK");this.addButton("cancel","Cancel");this.fixLayout();this.accept=function(){p()&&DialogBoxMorph.prototype.accept.call(D)};this.edit=function(){"changePassword"===b?v.edit():q.edit()};this.getInput=function(){return{username:q.getValue(),email:r.getValue(),oldpassword:v.getValue(),password:t.getValue(),passwordRepeat:u.getValue(), +choice:w}};this.reactToChoice=function(){if("signup"===b){P.changed();var G=P,S=(new Date).getFullYear()+(new Date).getMonth()/12,N=+O.getValue()||0,J=E.getValue();J instanceof Array&&(J=J[0]);isNaN(N)&&(N=0);J="January February March April May June July August September October November December".split(" ").indexOf(J);isNaN(J)&&(J=0);G.text=13>=S-(N+J/12)?"E-mail address of parent or guardian:":"E-mail address:";P.text=localize(P.text);P.fixLayout();P.rerender()}};this.reactToChoice();this.key|| +(this.key="credentials"+a+b);this.popUp(h)};DialogBoxMorph.prototype.accept=function(){if(this.action)if("function"===typeof this.target)"function"===typeof this.action?this.target.call(this.environment,this.action.call()):this.target.call(this.environment,this.action);else if("function"===typeof this.action)this.action.call(this.target,this.getInput());else this.target[this.action](this.getInput());this.destroy()};DialogBoxMorph.prototype.withKey=function(a){this.key=a;return this}; DialogBoxMorph.prototype.popUp=function(a){a&&(this.key&&(this.instances[a.stamp]?this.instances[a.stamp][this.key]&&this.instances[a.stamp][this.key].destroy():this.instances[a.stamp]={},this.instances[a.stamp][this.key]=this),a.add(this),a.keyboardFocus=this,this.setCenter(a.center()),this.edit())};DialogBoxMorph.prototype.destroy=function(){DialogBoxMorph.uber.destroy.call(this);this.key&&delete this.instances[this.key]};DialogBoxMorph.prototype.ok=function(){this.accept()}; -DialogBoxMorph.prototype.cancel=function(){this.destroy()};DialogBoxMorph.prototype.edit=function(){this.children.forEach(function(a){a.edit&&a.edit()})};DialogBoxMorph.prototype.getInput=function(){return this.body instanceof InputFieldMorph?this.body.getValue():null};DialogBoxMorph.prototype.justDropped=function(a){a.world.keyboardFocus=this;this.edit()};DialogBoxMorph.prototype.destroy=function(){var a=this.world();a.keyboardFocus=null;a.hand.destroyTemporaries();DialogBoxMorph.uber.destroy.call(this)}; +DialogBoxMorph.prototype.cancel=function(){this.destroy()};DialogBoxMorph.prototype.edit=function(){this.children.forEach(a=>{a.edit&&a.edit()})};DialogBoxMorph.prototype.getInput=function(){return this.body instanceof InputFieldMorph?this.body.getValue():null};DialogBoxMorph.prototype.justDropped=function(a){a.world.keyboardFocus=this;this.edit()};DialogBoxMorph.prototype.destroy=function(){var a=this.world();a.keyboardFocus=null;a.hand.destroyTemporaries();DialogBoxMorph.uber.destroy.call(this)}; DialogBoxMorph.prototype.normalizeSpaces=function(a){var b="",c,d=!1;for(c=0;c{var d=c.fullBounds();if(c.isVisible||this.respectHiddens){if(a){var e=a.fullBounds();"row"===this.orientation?c.setPosition(e.topRight().add(new Point(this.padding,(e.height()-d.height())/2))):c.setPosition(e.bottomLeft().add(new Point("center"===this.alignment?(e.width()-d.width())/2:0,this.padding)));d=c.fullBounds();b=b.merge(d)}else b=d;a=c}});this.bounds=b}; InputFieldMorph.prototype=new Morph;InputFieldMorph.prototype.constructor=InputFieldMorph;InputFieldMorph.uber=Morph.prototype;InputFieldMorph.prototype.edge=2;InputFieldMorph.prototype.fontSize=12;InputFieldMorph.prototype.typeInPadding=2;InputFieldMorph.prototype.contrast=65;function InputFieldMorph(a,b,c,d){this.init(a,b,c,d)} InputFieldMorph.prototype.init=function(a,b,c,d){a=new StringFieldMorph(a||"",null,null,null,null,null,b||!1);var e=new ArrowMorph("down",0,Math.max(Math.floor(this.fontSize/6),1));this.choices=c||null;this.isReadOnly=d||!1;this.isNumeric=b||!1;a.alpha=0;a.fontSize=this.fontSize;a.fixLayout();this.oldContentsExtent=a.extent();InputFieldMorph.uber.init.call(this);this.color=WHITE;this.add(a);this.add(e);a.isDraggable=!1;this.fixLayout()}; -InputFieldMorph.prototype.contents=function(){return detect(this.children,function(a){return a instanceof StringFieldMorph})};InputFieldMorph.prototype.arrow=function(){return detect(this.children,function(a){return a instanceof ArrowMorph})};InputFieldMorph.prototype.setChoice=function(a){this.setContents(a);this.escalateEvent("reactToChoice",a)}; +InputFieldMorph.prototype.contents=function(){return detect(this.children,a=>a instanceof StringFieldMorph)};InputFieldMorph.prototype.arrow=function(){return detect(this.children,a=>a instanceof ArrowMorph)};InputFieldMorph.prototype.setChoice=function(a){this.setContents(a);this.escalateEvent("reactToChoice",a)}; InputFieldMorph.prototype.setContents=function(a){var b=this.contents();b.text.text=a;if(void 0===a)return null;null===a?b.text.text="":a.toString&&(b.text.text=a.toString());b.text.fixLayout();b.changed();b.fixLayout();b.rerender()};InputFieldMorph.prototype.edit=function(){var a=this.contents();a.text.edit();a.text.selectAll()}; InputFieldMorph.prototype.setIsNumeric=function(a){this.isNumeric=a;this.contents().isNumeric=a;this.contents().text.isNumeric=a;a=this.getValue();this.isNumeric&&(a=parseFloat(a),isNaN(a)&&(a=null));this.setContents(a)}; -InputFieldMorph.prototype.dropDownMenu=function(){var a=this.choices,b,c=new MenuMorph(this.setChoice,null,this,this.fontSize);a instanceof Function?a=a.call(this):isString(a)&&(a=this[a]());if(!a)return null;c.addItem(" ",null);if(a instanceof Array)a.forEach(function(d){return c.addItem(d[0],d[1])});else for(b in a)Object.prototype.hasOwnProperty.call(a,b)&&("~"===b[0]?c.addLine():c.addItem(b,a[b]));if(0c.addItem(d[0],d[1]));else for(b in a)Object.prototype.hasOwnProperty.call(a,b)&&("~"===b[0]?c.addLine():c.addItem(b,a[b]));if(0n.destroy());this.children=[];this.isListContents||(this.edge=MorphicPreferences.isFlat?0:5,this.border=MorphicPreferences.isFlat?1:2);this.color=WHITE;this.borderColor=new Color(60,60,60);this.bounds.setExtent(ZERO);var h=this.left()+1;var k=this.top()+1.5*this.fontSize+2;var l=new StringMorph("",this.fontSize);this.items.forEach(n=>{b=" "!==n[0][1];c=new BoxMorph(1,1);b?(d=BLACK,e=this.fontSize,f=2.5*this.fontSize, +g=new Point(h+2-2*this.fontSize,k)):(d=WHITE,e=1.5*this.fontSize,f=4*this.fontSize,g=new Point(h+1,k),h+=e-1);c.setColor(d);c.setWidth(e);c.setHeight(f);a=new PianoKeyMorph(this.target,n[1],[c,n[0]],this.fontSize||MorphicPreferences.menuFontSize,MorphicPreferences.menuFontName,this.environment,n[2],n[3],n[4],n[5],n[6],l);a.setPosition(g);this.add(a)});var m=this.fullBounds();l.setPosition(new Point(m.width()/2-this.fontSize,2));this.add(l);m=this.fullBounds();this.bounds.setExtent(m.extent().add(2))}; +PianoMenuMorph.prototype.select=function(a){this.unselectAllItems();a.mouseEnter();this.selection=a;this.world.keyboardFocus=this;this.hasFocus=!0};PianoMenuMorph.prototype.unselectAllItems=function(){this.children.forEach(a=>{a instanceof MenuItemMorph&&a.mouseLeave()});this.changed()};PianoMenuMorph.prototype.selectKey=function(a){var b;isNil(a)||((b=detect(this.children,c=>c.action===a))?this.select(b):this.selectKey(48))}; PianoMenuMorph.prototype.processKeyDown=function(a){switch(a.keyCode){case 13:case 32:this.selection&&this.selection.mouseClickLeft();break;case 27:return this.destroy();case 37:case 40:case 189:return this.selectDown();case 38:case 39:case 187:case 220:return this.selectUp();default:switch(a.key){case "C":return this.selectKey(48);case "c":return this.selectKey(60);case "D":return this.selectKey(50);case "d":return this.selectKey(62);case "E":return this.selectKey(52);case "e":return this.selectKey(64); case "F":return this.selectKey(53);case "f":return this.selectKey(65);case "G":return this.selectKey(55);case "g":return this.selectKey(67);case "A":return this.selectKey(57);case "a":return this.selectKey(69);case "B":case "H":return this.selectKey(59);case "b":case "h":return this.selectKey(71);default:nop()}}};PianoMenuMorph.prototype.selectUp=function(){var a=48;this.selection&&(a=this.selection.action+1,72a&&(a=72));this.selectKey(a)};PianoMenuMorph.prototype.destroy=function(){this.children.forEach(function(a){a.note&&a.note.stop()});PianoMenuMorph.uber.destroy.call(this)};PianoKeyMorph.prototype=new MenuItemMorph;PianoKeyMorph.prototype.constructor=PianoKeyMorph;PianoKeyMorph.uber=MenuItemMorph.prototype; -function PianoKeyMorph(a,b,c,d,e,f,g,h,k,l,m,n){this.init(a,b,c,d,e,f,g,h,k,l,m,n);this.feedback=n}PianoKeyMorph.prototype.init=function(a,b,c,d,e,f,g,h,k,l,m,n){this.note=new Note(b);PianoKeyMorph.uber.init.call(this,a,b,c,d,e,f,g,h,k,l,m,n)}; -PianoKeyMorph.prototype.createLabel=function(){null!==this.label&&this.label.destroy();this.label=new Morph;var a=this.createIcon(this.labelString[0]);this.label.add(a);this.bounds.setExtent(a.extent());this.label.bounds=this.position().extent(this.label.extent());this.label.bounds.setExtent(ZERO);this.add(this.label)}; -PianoKeyMorph.prototype.mouseEnter=function(){var a=this,b=this.parentThatIsA(PianoMenuMorph),c=b?b.soundType:1;b&&(b.unselectAllItems(),b.selection=this,b.world.keyboardFocus=b,b.hasFocus=!0);this.label.children[0].hide();this.userState="highlight";this.rerender();this.feedback.text=this.labelString[1];this.feedback.fixLayout();this.note.play(c);setTimeout(function(){return a.note.stop(!0)},400)}; +PianoMenuMorph.prototype.selectDown=function(){var a=48;this.selection&&(a=this.selection.action-1,48>a&&(a=72));this.selectKey(a)};PianoMenuMorph.prototype.destroy=function(){this.children.forEach(a=>{a.note&&a.note.stop()});PianoMenuMorph.uber.destroy.call(this)};PianoKeyMorph.prototype=new MenuItemMorph;PianoKeyMorph.prototype.constructor=PianoKeyMorph;PianoKeyMorph.uber=MenuItemMorph.prototype;function PianoKeyMorph(a,b,c,d,e,f,g,h,k,l,m,n){this.init(a,b,c,d,e,f,g,h,k,l,m,n);this.feedback=n} +PianoKeyMorph.prototype.init=function(a,b,c,d,e,f,g,h,k,l,m,n){this.note=new Note(b);PianoKeyMorph.uber.init.call(this,a,b,c,d,e,f,g,h,k,l,m,n)};PianoKeyMorph.prototype.createLabel=function(){null!==this.label&&this.label.destroy();this.label=new Morph;var a=this.createIcon(this.labelString[0]);this.label.add(a);this.bounds.setExtent(a.extent());this.label.bounds=this.position().extent(this.label.extent());this.label.bounds.setExtent(ZERO);this.add(this.label)}; +PianoKeyMorph.prototype.mouseEnter=function(){var a=this.parentThatIsA(PianoMenuMorph),b=a?a.soundType:1;a&&(a.unselectAllItems(),a.selection=this,a.world.keyboardFocus=a,a.hasFocus=!0);this.label.children[0].hide();this.userState="highlight";this.rerender();this.feedback.text=this.labelString[1];this.feedback.fixLayout();this.note.play(b);setTimeout(()=>this.note.stop(!0),400)}; PianoKeyMorph.prototype.mouseLeave=function(){this.note.stop(!0);this.label.children[0].show();this.userState="normal";this.rerender()};modules.blocks="2020-August-08";SyntaxElementMorph.prototype=new Morph;SyntaxElementMorph.prototype.constructor=SyntaxElementMorph;SyntaxElementMorph.uber=Morph.prototype;SyntaxElementMorph.prototype.contrast=65; SyntaxElementMorph.prototype.setScale=function(a){this.scale=a=Math.min(Math.max(a,1),25);this.corner=3*a;this.rounding=9*a;this.edge=a;this.flatEdge=.5*a;this.jag=5*a;this.inset=6*a;this.hatHeight=12*a;this.hatWidth=70*a;this.rfBorder=3*a;this.minWidth=0;this.dent=8*a;this.bottomPadding=3*a;this.cSlotPadding=4*a;this.typeInPadding=a;this.labelPadding=4*a;this.labelFontName="Verdana";this.labelFontStyle="sans-serif";this.fontSize=10*a;this.embossing=new Point(-1*Math.max(a/2,1),-1*Math.max(a/2,1)); this.labelWidth=450*a;this.dynamicInputLabels=this.labelWordWrap=!0;this.feedbackMinHeight=5;this.minSnapDistance=20;this.reporterDropFeedbackPadding=10*a;this.labelContrast=25;this.activeHighlight=new Color(153,255,213);this.errorHighlight=new Color(173,15,0);this.activeBlur=20;this.activeBorder=4;this.rfColor=new Color(120,120,120)};SyntaxElementMorph.prototype.setScale(1);SyntaxElementMorph.prototype.isCachingInputs=!1;SyntaxElementMorph.prototype.alpha=1; @@ -725,50 +665,50 @@ name:"list"},"%pause":{type:"symbol",name:"pause",color:new Color(255,220,0),tag spec:"%rr %ringparms"},"%predRing":{type:"ring",tags:"static",selector:"reifyPredicate",spec:"%rp %ringparms"},"%rc":{type:"ring slot",tags:"static",kind:"command"},"%rr":{type:"ring slot",tags:"static",kind:"reporter"},"%rp":{type:"ring slot",tags:"static",kind:"predicate"},"%t":{type:"template",label:"\u00a0"},"%upvar":{type:"template",label:"\u00a0"},"%clr":{type:"color",tags:"static"},"%br":{type:"break"},"%inputName":{type:"variable"},"%inputs":{type:"multi",slots:"%s",label:"with inputs",tags:"widget"}, "%send":{type:"multi",slots:["%msgSend","%s"],label:["and send","with data"],tags:"static",max:2},"%receive":{type:"multi",slots:["%rcv","%s"],label:["to","with data"],tags:"static",max:2},"%scriptVars":{type:"multi",slots:"%t",tags:"widget",min:1},"%blockVars":{type:"multi",slots:"%t",label:"block variables",tags:"widget"},"%message":{type:"multi",slots:"%t",tags:"widget",max:1},"%keyName":{type:"multi",slots:"%t",tags:"widget",max:1},"%parms":{type:"multi",slots:"%t",label:"Input Names:",tags:"widget"}, "%ringparms":{type:"multi",slots:"%t",label:"input names:"},"%words":{type:"multi",slots:"%s",defaults:2},"%lists":{type:"multi",slots:"%l",defaults:2},"%nums":{type:"multi",slots:"%n",defaults:2},"%exp":{type:"multi",slots:"%s",defaults:1,tags:"static widget"},"%sum":{type:"multi",slots:"%n",min:2,infix:"+",collapse:"sum"},"%product":{type:"multi",slots:"%n",min:2,infix:"\u00d7",collapse:"product"},"%min":{type:"multi",slots:"%n",min:2,infix:"min",collapse:"minimum"},"%max":{type:"multi",slots:"%n", -min:2,infix:"max",collapse:"maximum"}};function SyntaxElementMorph(){this.init()}SyntaxElementMorph.prototype.init=function(){this.cachedNormalColor=this.cachedClrDark=this.cachedClrBright=this.cachedClr=null;this.isStatic=!1;SyntaxElementMorph.uber.init.call(this);this.defaults=[];this.cachedInputs=null;delete this.alpha}; -SyntaxElementMorph.prototype.parts=function(){var a=null;this.nextBlock&&(a=this.nextBlock());return this.children.filter(function(b){return b!==a&&!(b instanceof ShadowMorph)&&!(b instanceof BlockHighlightMorph)})};SyntaxElementMorph.prototype.inputs=function(){if(isNil(this.cachedInputs)||!this.isCachingInputs)this.cachedInputs=this.parts().filter(function(a){return a instanceof SyntaxElementMorph});return this.cachedInputs}; -SyntaxElementMorph.prototype.debugCachedInputs=function(){var a,b;isNil(this.cachedInputs)||(a=this.parts().filter(function(c){return c instanceof SyntaxElementMorph}));if(this.cachedInputs.length!==a.length)throw Error("cached inputs size do not match: "+this.constructor.name);for(b=0;bb!==a&&!(b instanceof ShadowMorph)&&!(b instanceof BlockHighlightMorph))}; +SyntaxElementMorph.prototype.inputs=function(){if(isNil(this.cachedInputs)||!this.isCachingInputs)this.cachedInputs=this.parts().filter(a=>a instanceof SyntaxElementMorph);return this.cachedInputs}; +SyntaxElementMorph.prototype.debugCachedInputs=function(){var a,b;isNil(this.cachedInputs)||(a=this.parts().filter(c=>c instanceof SyntaxElementMorph));if(this.cachedInputs.length!==a.length)throw Error("cached inputs size do not match: "+this.constructor.name);for(b=0;b{b.isEmptySlot&&b.isEmptySlot()?a.push(b):b.allEmptySlots&&(a=a.concat(b.allEmptySlots()))});return a}; +SyntaxElementMorph.prototype.tagExitBlocks=function(a,b){"doReport"===this.selector?this.partOfCustomCommand=b:"doStopThis"===this.selector?this.exitTag=a:this instanceof RingMorph||this.children.forEach(c=>{c.tagExitBlocks&&c.tagExitBlocks(a,b)})}; +SyntaxElementMorph.prototype.replaceInput=function(a,b){var c=this.parentThatIsA(ScriptsMorph),d=b,e=this.children.indexOf(a),f=0;-1===e&&b instanceof MultiArgMorph&&this.children.forEach(g=>{g instanceof ArgLabelMorph&&g.argMorph()===a&&(e=f);f+=1});a.cachedSlotSpec&&(a.cachedSlotSpec=null);b.cachedSlotSpec&&(b.cachedSlotSpec=null);this.changed();b.parent&&b.parent.removeChild(b);a instanceof MultiArgMorph&&(a.inputs().forEach(g=>a.replaceInput(g,new InputSlotMorph)),(this.dynamicInputLabels||a.collapse)&& +b instanceof ReporterBlockMorph&&(d=new ArgLabelMorph(b,a.collapse)));d.parent=this;this.children[e]=d;a instanceof ReporterBlockMorph&&c&&!a.isPrototype&&(!(a instanceof RingMorph)||a instanceof RingMorph&&a.contents())&&(c.add(a),a.moveBy(d.extent()),a.fixBlockColor());d instanceof MultiArgMorph||d instanceof ArgLabelMorph||d.constructor===CommandSlotMorph?(d.fixLayout(),this.fixLabelColor&&this.fixLabelColor()):this.fixLayout();this.cachedInputs=null}; SyntaxElementMorph.prototype.revertToDefaultInput=function(a,b){var c=this.parts().indexOf(a),d=this.inputs().indexOf(a),e=new InputSlotMorph,f=this.parts().filter(function(g){return g instanceof StructInputSlotMorph}).reduce(function(g,h){return g+h.fields.length},0);c=-1!==c?c-f:c;-1!==c&&(this instanceof BlockMorph?(e=this.labelPart(this.parseSpec(this.blockSpec)[c]),this.isCustomBlock&&(c=this.isGlobal?this.definition:this.scriptTarget().getMethod(this.blockSpec),e instanceof InputSlotMorph&& e.setChoices.apply(e,c.inputOptionsOfIdx(d)),(e instanceof InputSlotMorph||e instanceof BooleanSlotMorph)&&e.setContents(c.defaultValueOfInputIdx(d)))):this instanceof MultiArgMorph?e=this.labelPart(this.slotSpec):this instanceof ReporterSlotMorph&&(e=this.emptySlot()));c=SnapActions.getFieldValue(this,d);void 0!==c?e.setContents(c):b||-1===d||(e instanceof MultiArgMorph?(e.setContents(this.defaults),e.defaults=this.defaults):isNil(this.defaults[d])||e.setContents(this.defaults[d]));(e.icon||e instanceof BooleanSlotMorph)&&e.fixLayout();this.replaceInput(a,e);e instanceof MultiArgMorph?e.refresh():e instanceof RingMorph&&e.fixBlockColor();this.cachedInputs=null};SyntaxElementMorph.prototype.isLocked=function(){return this.isStatic};SyntaxElementMorph.prototype.topBlock=function(){return this.parent&&this.parent.topBlock?this.parent.topBlock():this}; -SyntaxElementMorph.prototype.getVarNamesDict=function(){var a=this.parentThatIsA(BlockMorph),b=[],c=StageMorph.prototype.enableInheritance;if(!a)return{};var d=a.scriptTarget();a.allParents().forEach(function(f){f instanceof PrototypeHatBlockMorph?(b.push.apply(b,f.variableNames()),b.push.apply(b,f.inputs()[0].inputFragmentNames())):f instanceof BlockMorph&&f.inputs().forEach(function(g){g.allChildren().forEach(function(h){h instanceof TemplateSlotMorph?b.push(h.contents()):h instanceof MultiArgMorph&& -h.children.forEach(function(k){k instanceof TemplateSlotMorph&&b.push(k.contents())})})})});if(d){var e=d.variables.allNamesDict();b.forEach(function(f){return e[f]=f});"doSetVar"===a.selector&&(e["~"]=null,e.my=[{anchor:["anchor"],name:["name"],"temporary?":["temporary?"],"dangling?":["dangling?"],"draggable?":["draggable?"],"rotation style":["rotation style"],"rotation x":["rotation x"],"rotation y":["rotation y"]}],c&&(e.my[0].parent=["parent"]),16===this.world().currentKey&&(e.my[0]["~"]=null, -e.my[0]["microphone modifier"]=["microphone modifier"]));return e}return{}}; +SyntaxElementMorph.prototype.getVarNamesDict=function(){var a=this.parentThatIsA(BlockMorph),b=[],c=StageMorph.prototype.enableInheritance;if(!a)return{};var d=a.scriptTarget();a.allParents().forEach(f=>{f instanceof PrototypeHatBlockMorph?(b.push.apply(b,f.variableNames()),b.push.apply(b,f.inputs()[0].inputFragmentNames())):f instanceof BlockMorph&&f.inputs().forEach(g=>{g.allChildren().forEach(h=>{h instanceof TemplateSlotMorph?b.push(h.contents()):h instanceof MultiArgMorph&&h.children.forEach(k=> +{k instanceof TemplateSlotMorph&&b.push(k.contents())})})})});if(d){var e=d.variables.allNamesDict();b.forEach(f=>e[f]=f);"doSetVar"===a.selector&&(e["~"]=null,e.my=[{anchor:["anchor"],name:["name"],"temporary?":["temporary?"],"dangling?":["dangling?"],"draggable?":["draggable?"],"rotation style":["rotation style"],"rotation x":["rotation x"],"rotation y":["rotation y"]}],c&&(e.my[0].parent=["parent"]),16===this.world().currentKey&&(e.my[0]["~"]=null,e.my[0]["microphone modifier"]=["microphone modifier"])); +return e}return{}}; SyntaxElementMorph.prototype.refactorVarInStack=function(a,b,c){this instanceof RingMorph&&contains(this.inputNames(),a)||!c&&this.definesScriptVariable(a)||("reportGetVar"===this.selector&&this.blockSpec===a&&(this.setSpec(b),this.fullChanged(),this.fixLabelColor()),"getVarNamesDict"===this.choices&&this.contents().text===a&&this.setContents(b),this instanceof CustomCommandBlockMorph&&this.definition.body&&isNil(this.definition.declarations.get(a))&&!contains(this.definition.variableNames,a)&&this.definition.body.expression.refactorVarInStack(a, -b),this.inputs().forEach(function(d){return d.refactorVarInStack(a,b)}),this.nextBlock&&(c=this.nextBlock())&&c.refactorVarInStack(a,b))};SyntaxElementMorph.prototype.definesScriptVariable=function(a){return("doDeclareVariables"===this.selector||this.blockSpec&&this.blockSpec.match("%upvar"))&&detect(this.inputs()[0].allInputs(),function(b){return"reportGetVar"===b.selector&&b.blockSpec===a})}; -SyntaxElementMorph.prototype.selectForEdit=function(){var a=this.parentThatIsA(ScriptsMorph),b=this.parentThatIsA(IDE_Morph);b=b?b.currentSprite:null;return a&&b&&b.inheritsAttribute("scripts")?(this.selectionID=!0,b.shadowAttribute("scripts"),a=detect(b.scripts.allChildren(),function(c){return c.selectionID}),delete this.selectionID,delete a.selectionID,a):this}; -SyntaxElementMorph.prototype.reactToGrabOf=function(a){var b=this.topBlock();a instanceof CommandBlockMorph&&(a=this.parentThatIsA(CommandSlotMorph,ReporterSlotMorph))&&a.fixLayout();b&&(b.allComments().forEach(function(c){return c.align(b)}),b.getHighlight()&&b.addHighlight(b.removeHighlight()))};SyntaxElementMorph.prototype.bright=function(){return this.color.lighter(this.contrast).toString()};SyntaxElementMorph.prototype.dark=function(){return this.color.darker(this.contrast).toString()}; -SyntaxElementMorph.prototype.setColor=function(a){if(a&&!this.color.eq(a)){var b=this.parentThatIsA(BlockMorph);this.color=a;this.children.forEach(function(c){b&&(c instanceof StringMorph||c instanceof SymbolMorph)?(c.shadowColor=b.color.darker(b.labelContrast),c.rerender()):c instanceof CommandSlotMorph&&c.setColor(a)});this.rerender()}}; -SyntaxElementMorph.prototype.setLabelColor=function(a,b,c){this.children.forEach(function(d){var e=a;e.eq(WHITE)?e=d.overrideWhite||WHITE:e.eq(BLACK)&&(e=d.overrideBlack||BLACK);d instanceof StringMorph&&!d.isProtectedLabel?(d.shadowOffset=c||d.shadowOffset,d.shadowColor=b||d.shadowColor,d.setColor(e)):d instanceof MultiArgMorph||d instanceof ArgLabelMorph||d instanceof SymbolMorph&&!d.isProtectedLabel||d instanceof InputSlotMorph&&d.isReadOnly?d.setLabelColor(e,b,c):d.isLoop&&d.loop().setLabelColor(e, -b,c)})};SyntaxElementMorph.prototype.flash=function(){this.cachedNormalColor||(this.cachedNormalColor=this.color,this.setColor(this.activeHighlight))};SyntaxElementMorph.prototype.unflash=function(){if(this.cachedNormalColor){var a=this.cachedNormalColor;this.cachedNormalColor=null;this.setColor(a)}};SyntaxElementMorph.prototype.doWithAlpha=function(a,b){var c=SyntaxElementMorph.prototype.alpha;SyntaxElementMorph.prototype.alpha=a;a=b();SyntaxElementMorph.prototype.alpha=c;return a}; -SyntaxElementMorph.prototype.fixBlockColor=function(a,b){this.children.forEach(function(c){c instanceof SyntaxElementMorph&&c.fixBlockColor(a,b)})}; -SyntaxElementMorph.prototype.labelPart=function(a){var b=this,c;if("%"===a[0]&&1a.labelWidth||v.isBlockLabelBreak)&&0d.refactorVarInStack(a,b)),this.nextBlock&&(c=this.nextBlock())&&c.refactorVarInStack(a,b))};SyntaxElementMorph.prototype.definesScriptVariable=function(a){return("doDeclareVariables"===this.selector||this.blockSpec&&this.blockSpec.match("%upvar"))&&detect(this.inputs()[0].allInputs(),b=>"reportGetVar"===b.selector&&b.blockSpec===a)}; +SyntaxElementMorph.prototype.selectForEdit=function(){var a=this.parentThatIsA(ScriptsMorph),b=this.parentThatIsA(IDE_Morph);b=b?b.currentSprite:null;return a&&b&&b.inheritsAttribute("scripts")?(this.selectionID=!0,b.shadowAttribute("scripts"),a=detect(b.scripts.allChildren(),c=>c.selectionID),delete this.selectionID,delete a.selectionID,a):this}; +SyntaxElementMorph.prototype.reactToGrabOf=function(a){var b=this.topBlock();a instanceof CommandBlockMorph&&(a=this.parentThatIsA(CommandSlotMorph,ReporterSlotMorph))&&a.fixLayout();b&&(b.allComments().forEach(c=>c.align(b)),b.getHighlight()&&b.addHighlight(b.removeHighlight()))};SyntaxElementMorph.prototype.bright=function(){return this.color.lighter(this.contrast).toString()};SyntaxElementMorph.prototype.dark=function(){return this.color.darker(this.contrast).toString()}; +SyntaxElementMorph.prototype.setColor=function(a){if(a&&!this.color.eq(a)){var b=this.parentThatIsA(BlockMorph);this.color=a;this.children.forEach(c=>{b&&(c instanceof StringMorph||c instanceof SymbolMorph)?(c.shadowColor=b.color.darker(b.labelContrast),c.rerender()):c instanceof CommandSlotMorph&&c.setColor(a)});this.rerender()}}; +SyntaxElementMorph.prototype.setLabelColor=function(a,b,c){this.children.forEach(d=>{let e=a;e.eq(WHITE)?e=d.overrideWhite||WHITE:e.eq(BLACK)&&(e=d.overrideBlack||BLACK);d instanceof StringMorph&&!d.isProtectedLabel?(d.shadowOffset=c||d.shadowOffset,d.shadowColor=b||d.shadowColor,d.setColor(e)):d instanceof MultiArgMorph||d instanceof ArgLabelMorph||d instanceof SymbolMorph&&!d.isProtectedLabel||d instanceof InputSlotMorph&&d.isReadOnly?d.setLabelColor(e,b,c):d.isLoop&&d.loop().setLabelColor(e,b, +c)})};SyntaxElementMorph.prototype.flash=function(){this.cachedNormalColor||(this.cachedNormalColor=this.color,this.setColor(this.activeHighlight))};SyntaxElementMorph.prototype.unflash=function(){if(this.cachedNormalColor){var a=this.cachedNormalColor;this.cachedNormalColor=null;this.setColor(a)}};SyntaxElementMorph.prototype.doWithAlpha=function(a,b){var c=SyntaxElementMorph.prototype.alpha;SyntaxElementMorph.prototype.alpha=a;a=b();SyntaxElementMorph.prototype.alpha=c;return a}; +SyntaxElementMorph.prototype.fixBlockColor=function(a,b){this.children.forEach(c=>{c instanceof SyntaxElementMorph&&c.fixBlockColor(a,b)})}; +SyntaxElementMorph.prototype.labelPart=function(a){var b;if("%"===a[0]&&1"%br";break;case "variable":c=new TemplateSlotMorph(info.label);c=new ReporterBlockMorph;c.category="variables";c.color=SpriteMorph.prototype.blockColor.variables;c.setSpec(localize("Input name"));break;case "multi":c=new MultiArgMorph(info.slots,info.label,info.min||0,a,null,null,null,null,null,info.infix,info.collapse);c.maxInputs=info.max;d=info.defaults||0;for(a=0;a{if(e)switch(e){case "numeric":c.isNumeric=!0;break;case "read-only":c.isReadOnly=!0;MorphicPreferences.isFlat||(b=c.contents(),b.shadowOffset=new Point(1,1),b.fixLayout());break;case "unevaluated":c.isUnevaluated=!0;break;case "static":c.isStatic=!0;break;case "landscape":c.minWidth=1.7*c.height();break;case "monospace":c.contents().fontName="monospace";c.contents().fontStyle="monospace";break;case "fading":c.isFading=!0;break;case "protected":c.isProtectedLabel= +!0;break;case "loop":c.isLoop=!0;c.add(this.labelPart("%loopArrow"));break;case "lambda":c.isLambda=!0;break;case "widget":c.canBeEmpty=!1;break;default:throw Error('unknown label part tag: "'+e+'"');}}),c.fixLayout());isNil(info.value)||c.setContents(info.value)}else"$"===a[0]&&1{u instanceof CSlotMorph||"%cs"===u.slotSpec?0this.labelWidth||u.isBlockLabelBreak)&&0{n&&(p=!0,n=!1);d=this.left()+m+this.edge+this.labelPadding;if(this instanceof RingMorph)d=this.left()+l;else if(this.isPredicate)d=this.left()+m+this.rounding;else if(this instanceof MultiArgMorph||this instanceof ArgLabelMorph)d=this.left();q+=e;e=0;u.forEach(v=>{v.isLoop&&(n=!0);v instanceof CSlotMorph? +(d-=this.labelPadding,this.isPredicate&&(d=this.left()+m+this.rounding),v.setColor(this.color),v.setPosition(new Point(d,q)),e=v.height()):v instanceof MultiArgMorph&&"%cs"===v.slotSpec?(this.isPredicate&&(d+=this.corner),v.setPosition(new Point(d,q)),e=v.height()):(v.setPosition(new Point(d,q)),v.isBlockLabelBreak||("%c"===v.slotSpec||"%loop"===v.slotSpec?d+=v.width():v.isVisible&&(d+=v.fullBounds().width()+l)),f=Math.max(f,d),e=Math.max(e,v instanceof StringMorph?v.rawHeight():v.height()))});p&& +(d+=1.5*this.fontSize,f=Math.max(f,d),p=!1);u.forEach(v=>{v.moveBy(new Point(0,Math.floor((e-v.height())/2)))})});q+=e;if(this.children.some(u=>u instanceof CSlotMorph)){var r=this.bottomPadding;this instanceof ReporterBlockMorph&&!this.isPredicate&&(r=Math.max(this.bottomPadding,this.rounding-this.bottomPadding));q+=r}if(this instanceof CommandBlockMorph)var t=q-this.top()+2*this.corner;else if(this instanceof ReporterBlockMorph)t=q-this.top()+2*this.edge;else if(this instanceof MultiArgMorph||this instanceof +ArgLabelMorph)t=q-this.top();this.isPredicate?g=Math.max(g,f-this.left()+this.rounding):this instanceof MultiArgMorph&&"%cs"!==this.slotSpec||this instanceof ArgLabelMorph?g=Math.max(g,f-this.left()-l):(g=Math.max(g,f-this.left()+this.labelPadding-this.edge),b[b.length-1]instanceof MultiArgMorph&&1===k.length&&(g-=l),this instanceof HatBlockMorph&&(g=Math.max(g,1.5*this.hatWidth)));this.bounds.setWidth(g);this.bounds.setHeight(t);this.holes=[];b.forEach(u=>{var v=0;if(u instanceof CSlotMorph||"%cs"=== +u.slotSpec)this.isPredicate?(u.bounds.setWidth(g-m-this.rounding-this.inset-this.corner),v=this.corner):(u.bounds.setWidth(g-this.edge-m),v=this.corner+this.edge),u.fixLoopLayout&&u.fixLoopLayout();"%cs"===u.slotSpec&&u.inputs().forEach(w=>w.bounds.setWidth(u.right()-w.left()-v));u.fixHolesLayout();this.holes.push.apply(this.holes,u.holes.map(w=>w.translateBy(u.position().subtract(c))))});a&&a.setPosition(new Point(this.left(),this.bottom()-this.corner));if(this instanceof BlockMorph&&this.parent&& +this.parent.fixLayout&&(this.parent.fixLayout(),this.parent.changed(),this.parent instanceof SyntaxElementMorph))return;this.fixHighlight()};SyntaxElementMorph.prototype.fixHighlight=function(){var a=this.topBlock();a.getHighlight&&a.getHighlight()&&a.addHighlight(a.removeHighlight())};SyntaxElementMorph.prototype.methodIconExtent=function(){var a=1.2*this.fontSize;return this.hasLocationPin()?new Point(.66*a,a):new Point(0,0)};SyntaxElementMorph.prototype.evaluate=function(){return null}; SyntaxElementMorph.prototype.isEmptySlot=function(){return!1}; SyntaxElementMorph.prototype.showBubble=function(a,b,c){var d=!1,e=this.parentThatIsA(IDE_Morph),f=this,g=this.rightCenter().add(new Point(2,0)),h=this.parentThatIsA(ScrollFrameMorph),k=this.world();if(void 0===a||!k)return null;if(a instanceof ListWatcherMorph){var l=a;l.update(!0);l.step=a.update;l.isDraggable=!1;l.expand(this.parentThatIsA(ScrollFrameMorph).extent());d=!0}else if(a instanceof TableFrameMorph)l=a,l.isDraggable=!1,l.expand(this.parentThatIsA(ScrollFrameMorph).extent()),d=!0;else if(a instanceof Morph)if(isSnapObject(a)){var m=a.thumbnail(new Point(40,40));l=new Morph;l.isCachingImage=!0;l.bounds.setWidth(m.width);l.bounds.setHeight(m.height);l.cachedImage=m;l.version=a.version;l.step=function(){this.version!==a.version&&(this.cachedImage=m=a.thumbnail(new Point(40,40)),this.version=a.version,this.changed())}}else m=a.fullImage(),l=new Morph,l.isCachingImage=!0,l.bounds.setWidth(m.width),l.bounds.setHeight(m.height),l.cachedImage=m;else a instanceof Costume?(m=a.thumbnail(new Point(40,40)), l=new Morph,l=new Morph,l.isCachingImage=!0,l.bounds.setWidth(m.width),l.bounds.setHeight(m.height),l.cachedImage=m):a instanceof Sound?l=new SymbolMorph("notes",30):a instanceof Context?(m=a.image(),l=new Morph,l.isCachingImage=!0,l.bounds.setWidth(m.width),l.bounds.setHeight(m.height),l.cachedImage=m):"boolean"===typeof a?l=SpriteMorph.prototype.booleanMorph.call(null,a):isString(a)?(l=500!n.isTemporary)),f=detect(e.corral.frame.contents.children,n=>n.object===c)):c=e,g=f.center());l=new SpeechBubbleMorph(l,null,Math.max(this.rounding-2,6),0);l.popUp(k,g,d);b&&this.exportPictureWithResult(l);f instanceof SpriteIconMorph?l.keepWithin(e.corral):h&&l.keepWithin(h)}; +SyntaxElementMorph.prototype.exportPictureWithResult=function(a){var b=this.parentThatIsA(IDE_Morph)||this.parentThatIsA(BlockEditorMorph).target.parentThatIsA(IDE_Morph),c=this.fullImage();a=a.fullImage();var d=newCanvas(new Point(c.width+a.width+2,c.height+Math.max(0,a.height-c.height))),e=d.getContext("2d");e.drawImage(c,0,d.height-c.height);e.drawImage(a,c.width+2,0);b.saveCanvasAs(d,(b.projectName||localize("untitled"))+" "+localize("script pic"))}; SyntaxElementMorph.prototype.mappedCode=function(a){var b=this.evaluate();return b instanceof BlockMorph?b.mappedCode(a):b};BlockLabelMorph.prototype=new StringMorph;BlockLabelMorph.prototype.constructor=BlockLabelMorph;BlockLabelMorph.uber=StringMorph.prototype;function BlockLabelMorph(a,b,c,d,e,f,g,h,k,l){this.init(a,b,c,d,e,f,g,h,k,l)} BlockLabelMorph.prototype.getRenderColor=function(){var a=this.parentThatIsA(BlockMorph);return MorphicPreferences.isFlat?.5{"%"===e[0]&&1e.destroy()),this.isPrototype&&this.add(this.placeHolder()),this.parseSpec(a).forEach((e,f,g)=>{"%"===e[0]&&"%br"!==e&&(d+=1);c=this.labelPart(e);isNil(c)||(this.add(c),c instanceof CommandSlotMorph||c instanceof StringMorph||(c.fixLayout(),c.rerender()),c instanceof RingMorph&&c.fixBlockColor(),(c instanceof MultiArgMorph||c.constructor===CommandSlotMorph||c.constructor===RingCommandSlotMorph)&&c.fixLayout(),this.isPrototype&& +this.add(this.placeHolder()),c instanceof InputSlotMorph&&this.isCustomBlock&&c.setChoices.apply(c,(b||this.definition).inputOptionsOfIdx(d)))}),this.blockSpec=a,this.fixLayout(),this.rerender(),this.cachedInputs=null)};BlockMorph.prototype.userSetSpec=function(a){var b=this.topBlock();b.fullChanged();this.setSpec(a);b.fullChanged()}; +BlockMorph.prototype.buildSpec=function(){this.blockSpec="";this.parts().forEach(a=>{this.blockSpec=a instanceof StringMorph?this.blockSpec+a.text:a instanceof ArgMorph?this.blockSpec+a.getSpec():a.isBlockLabelBreak?this.blockSpec+a.getSpec():this.blockSpec+"[undefined]";this.blockSpec+=" "});this.blockSpec=this.blockSpec.trim()};BlockMorph.prototype.rebuild=function(a){this.setSpec(this.blockSpec);a&&this.inputs().forEach(b=>{b instanceof ReporterBlockMorph&&(b.setColor(b.color.lighter(a)),b.setSpec(b.blockSpec))})}; +BlockMorph.prototype.userMenu=function(){function a(p,q,r,t,u){c.addItem([r?new SymbolMorph("checkedBox",.75*MorphicPreferences.menuFontSize):new SymbolMorph("rectangle",.75*MorphicPreferences.menuFontSize),localize(p)],q,r?t:u)}function b(){var p=e.fullCopy();p.addShadow();(new DialogBoxMorph(e,function(q){SnapActions.setBlockSpec(this,q)},e)).prompt("Variable name",e.blockSpec,d,p.doWithAlpha(1,()=>p.fullImage()),InputSlotMorph.prototype.getVarNamesDict.call(e))}var c=new MenuMorph(this),d=this.world(), +e=this,f=16===d.currentKey,g=this.activeProcess(),h=this.topBlock(),k=g&&g.context&&g.context.outerContext?g.context.outerContext.variables.names():[],l;c.addItem("help...","showHelp");if(this.isTemplate){if(this.parent instanceof SyntaxElementMorph)"reportGetVar"===this.selector&&(c.addLine(),c.addItem("rename...",()=>this.refactorThisVar(!0),"rename only\nthis reporter"),c.addItem("rename all...","refactorThisVar","rename all blocks that\naccess this variable"));else{if("reportGetVar"===this.selector){var m= +this.scriptTarget();this.isInheritedVariable(!1)?a("inherited",()=>m.toggleInheritedVariable(this.blockSpec),!0,"uncheck to\ndisinherit",null):(this.isInheritedVariable(!0)&&a("inherited",()=>m.toggleInheritedVariable(this.blockSpec),!1,null,localize("check to inherit\nfrom")+" "+m.exemplar.name),a("transient","toggleTransientVariable",this.isTransientVariable(),"uncheck to save contents\nin the project","check to prevent contents\nfrom being saved"),c.addLine(),c.addItem("rename...",()=>this.refactorThisVar(!0), +"rename only\nthis reporter"),c.addItem("rename all...","refactorThisVar","rename all blocks that\naccess this variable"))}else"evaluateCustomBlock"!==this.selector&&c.addItem("hide","hidePrimitive");StageMorph.prototype.enableInheritance&&(m=this.scriptTarget(),(l={xPosition:"x position",yPosition:"y position",direction:"direction",getScale:"size",getCostumeIdx:"costume #",getVolume:"volume",getPan:"balance",reportShown:"shown?",getPenDown:"pen down?"}[this.selector])&&m&&m.exemplar&&(c.addLine(), +a("inherited",()=>m.toggleInheritanceForAttribute(l),m.inheritsAttribute(l),"uncheck to\ndisinherit",localize("check to inherit\nfrom")+" "+m.exemplar.name)));StageMorph.prototype.enableCodeMapping&&(c.addLine(),c.addItem("header mapping...","mapToHeader"),c.addItem("code mapping...","mapToCode"))}return c}c.addLine();if("reportGetVar"===this.selector)c.addItem("rename...",b,"rename only\nthis reporter");else if(SpriteMorph.prototype.blockAlternatives[this.selector])c.addItem("relabel...",()=>this.relabel(SpriteMorph.prototype.blockAlternatives[this.selector])); +else if(this.isCustomBlock&&this.alternatives){var n=this.alternatives();0this.relabel(n))}contains(["reportMap","reportKeep","reportFindFirst","reportCombine"],this.selector)?(n={reportMap:"reportAtomicMap",reportKeep:"reportAtomicKeep",reportFindFirst:"reportAtomicFindFirst",reportCombine:"reportAtomicCombine"},c.addItem("compile",()=>this.setSelector(n[this.selector]),"experimental!\nmake this reporter fast and uninterruptible\nCAUTION: Errors in the ring\ncan break your Snap! session!")): +contains(["reportAtomicMap","reportAtomicKeep","reportAtomicFindFirst","reportAtomicCombine"],this.selector)?(n={reportAtomicMap:"reportMap",reportAtomicKeep:"reportKeep",reportAtomicFindFirst:"reportFindFirst",reportAtomicCombine:"reportCombine"},c.addItem("uncompile",()=>this.setSelector(n[this.selector]))):contains(["reportPenTrailsAsCostume","reportPentrailsAsSVG"],this.selector)&&(n={reportPenTrailsAsCostume:"reportPentrailsAsSVG",reportPentrailsAsSVG:"reportPenTrailsAsCostume"},c.addItem(localize(SpriteMorph.prototype.blocks[n[this.selector]].spec), +()=>{this.setSelector(n[this.selector]);this.changed()}));c.addItem("duplicate",()=>{var p=this.fullCopy(),q=this.parentThatIsA(IDE_Morph),r=this.parentThatIsA(BlockEditorMorph);p.id=null;p.pickUp(d);!q&&r&&(q=r.target.parentThatIsA(IDE_Morph));q&&(d.hand.grabOrigin={origin:q.palette,position:q.palette.center()})},"make a copy\nand pick it up");this instanceof CommandBlockMorph&&this.nextBlock()&&c.addItem((g?this.fullCopy():this).thumbnail(.5,60),()=>{var p=this.fullCopy(),q=p.nextBlock(),r=this.parentThatIsA(IDE_Morph), +t=this.parentThatIsA(BlockEditorMorph);q&&q.destroy();p.id=null;p.pickUp(d);!r&&t&&(r=t.target.parentThatIsA(IDE_Morph));r&&(d.hand.grabOrigin={origin:r.palette,position:r.palette.center()})},"only duplicate this block");c.addItem("delete",function(){this.id?SnapActions.removeBlock(this,!0):this.userDestroy()});c.addItem("script pic...",()=>{var p=this.parentThatIsA(IDE_Morph)||this.parentThatIsA(BlockEditorMorph).target.parentThatIsA(IDE_Morph);p.saveCanvasAs(h.scriptPic(),(p.projectName||localize("untitled"))+ +" "+localize("script pic"))},"save a picture\nof this script");h instanceof ReporterBlockMorph&&c.addItem("result pic...",()=>h.exportResultPic(),"save a picture of both\nthis script and its result");f&&c.addItem("download script",()=>{var p=this.parentThatIsA(IDE_Morph),q=this.parentThatIsA(BlockEditorMorph);!p&&q&&(p=q.target.parentThatIsA(IDE_Morph));p&&p.saveXMLAs(p.serializer.serialize(this),this.selector+" script",!1)},"download this script\nas an XML file",new Color(100,0,0));if(g)return k.length&& +(c.addLine(),k.forEach(p=>c.addItem(p+"...",()=>g.doShowVar(p)))),g.homeContext.variables.names().forEach(p=>{contains(k,p)||c.addItem(p+"...",()=>g.doShowVar(p))}),c;if(this.parent.parentThatIsA(RingMorph))return c.addLine(),c.addItem("unringify",function(){SnapActions.unringify(this)}),h=this.topBlock(),!(this instanceof ReporterBlockMorph)&&h instanceof HatBlockMorph||c.addItem("ringify",function(){SnapActions.ringify(this)}),c;contains("doBroadcast doSend doBroadcastAndWait receiveMessage receiveOnClone receiveGo".split(" "), +this.selector)&&(c.addLine(),c.addItem(0===this.selector.indexOf("receive")?"senders...":"receivers...","showMessageUsers"));if(this.parent instanceof ReporterSlotMorph||this.parent instanceof CommandSlotMorph||this instanceof HatBlockMorph||this instanceof CommandBlockMorph&&h instanceof HatBlockMorph)return c;c.addLine();c.addItem("ringify",function(){SnapActions.ringify(this)});StageMorph.prototype.enableCodeMapping&&(c.addLine(),c.addItem("header mapping...","mapToHeader"),c.addItem("code mapping...", +"mapToCode"));return c}; +BlockMorph.prototype.showMessageUsers=function(){var a=this.parentThatIsA(IDE_Morph).corral,b=0===this.selector.indexOf("receive")?"allSendersOf":"allHatBlocksFor",c=this.inputs(),d;"receiveGo"===this.selector?d="__shout__go__":"receiveOnClone"===this.selector?d="__clone__init__":c[0]instanceof InputSlotMorph&&(d=c[0].evaluate());if("doSend"===this.selector&&c[1]instanceof InputSlotMorph)var e=this.inputs()[1].evaluate();else 0===this.selector.indexOf("receive")&&(e=this.scriptTarget().name);""!== +d&&a.frame.contents.children.concat(a.stageIcon).forEach(f=>{f.object&&("doSend"!==this.selector||e===f.object.name)&&0(new DialogBoxMorph(this,function(b){SnapActions.setBlockSpec(this,b)},this)).prompt(a.title+"\nspec",this.blockSpec,this.world()));return a}; BlockMorph.prototype.hidePrimitive=function(){var a=this.parentThatIsA(IDE_Morph);if(a){StageMorph.prototype.hiddenPrimitives[this.selector]=!0;var b={doWarp:"control",reifyScript:"operators",reifyReporter:"operators",reifyPredicate:"operators",doDeclareVariables:"variables"}[this.selector]||this.category;"lists"===b&&(b="variables");a.flushBlocksCache(b);a.refreshPalette()}}; BlockMorph.prototype.isInheritedVariable=function(a){return this.isTemplate&&"reportGetVar"===this.selector&&this.parent instanceof FrameMorph?contains(this.scriptTarget().inheritedVariableNames(a),this.blockSpec):!1};BlockMorph.prototype.isTransientVariable=function(){var a=this.scriptTarget().variables.silentFind(this.blockSpec);return a?a.vars[this.blockSpec].isTransient:!1}; BlockMorph.prototype.toggleTransientVariable=function(){var a=this.scriptTarget().variables.silentFind(this.blockSpec);a&&(a.vars[this.blockSpec].isTransient=!a.vars[this.blockSpec].isTransient)}; -BlockMorph.prototype.deleteBlock=function(){var a=this.parentThatIsA(ScriptsMorph),b=this.nextBlock?this.nextBlock():null,c,d;a&&(b&&a.add(b),this.inputs().forEach(function(e){e instanceof BlockMorph&&a.add(e)}));this instanceof ReporterBlockMorph&&(this.parent instanceof BlockMorph||this.parent instanceof MultiArgMorph||this.parent instanceof ReporterSlotMorph)?this.parent.revertToDefaultInput(this):this.parent&&this.parent.fixLayout?c=this.parentThatIsA(ArgMorph):d=!0;this.destroy();d&&(this.isCorpse= -!0);c&&c.fixLayout()}; +BlockMorph.prototype.deleteBlock=function(){var a=this.parentThatIsA(ScriptsMorph),b=this.nextBlock?this.nextBlock():null,c,d;a&&(b&&a.add(b),this.inputs().forEach(e=>{e instanceof BlockMorph&&a.add(e)}));this instanceof ReporterBlockMorph&&(this.parent instanceof BlockMorph||this.parent instanceof MultiArgMorph||this.parent instanceof ReporterSlotMorph)?this.parent.revertToDefaultInput(this):this.parent&&this.parent.fixLayout?c=this.parentThatIsA(ArgMorph):d=!0;this.destroy();d&&(this.isCorpse=!0); +c&&c.fixLayout()}; BlockMorph.prototype.ringify=function(){var a=this.selectForEdit();if(a!==this)return this.ringify.call(a);a=new RingMorph;var b=this.topBlock();var c=b.fullBounds().center();if(null===this.parent)return null;b.fullChanged();if(this.parent instanceof SyntaxElementMorph)if(this instanceof ReporterBlockMorph)this.parent.replaceInput(this,a,!0),a.embed(this,null,!0);else{if(b){if(b instanceof HatBlockMorph)return;b.parent.add(a);a.embed(b);a.setCenter(c)}}else this.parent.add(a),a.embed(this),a.setCenter(c); this.fixBlockColor(null,!0);b.fullChanged();return a}; BlockMorph.prototype.unringify=function(){var a=this.selectForEdit();if(a!==this)return this.unringify.call(a);a=this.parent.parentThatIsA(RingMorph);var b=this.topBlock();var c=this.parentThatIsA(ScriptsMorph);if(null===a)return null;var d=a.contents();var e=a.center();b.fullChanged();a.parent instanceof SyntaxElementMorph?d instanceof ReporterBlockMorph?a.parent.replaceInput(a,d):c&&(c.add(d),d.setFullCenter(e),d.moveBy(20),a.parent.revertToDefaultInput(a)):(a.parent.add(d),d.setFullCenter(e),a.destroy()); this.fixBlockColor(null,!0);b.fullChanged();return a}; -BlockMorph.prototype.relabel=function(a){var b=this,c=this.selectForEdit();if(c!==this)return this.relabel.call(c,a);var d=new MenuMorph(this);var e=this.inputs();a.forEach(function(f){if(f instanceof Array){var g=f[0];f=-f[1]}else g=f,f=0;var h=SpriteMorph.prototype.blockForSelector(g,!0);h.restoreInputs(e,f);h.fixBlockColor(null,!0);h.addShadow(new Point(3,3));d.addItem(h.doWithAlpha(1,function(){return h.fullImage()}),function(){return SnapActions.setSelector(b,g)})});d.popup(this.world(),this.bottomLeft().subtract(new Point(8, -this instanceof CommandBlockMorph?this.corner:0)))}; -BlockMorph.prototype.setSelector=function(a,b){b=void 0===b?0:b;var c=this.inputs(),d=this.parentThatIsA(ScriptsMorph);var e=SpriteMorph.prototype.blocks[a];this.setCategory(e.category);this.selector=a;this.setSpec(localize(e.spec));this.defaults=e.defaults||[];a=this.inputs();if(a[0]instanceof MultiArgMorph)a[0].setContents(this.defaults),a[0].defaults=this.defaults;else for(e=0;e{if(e instanceof Array){var f=e[0];e=-e[1]}else f=e,e=0;var g=SpriteMorph.prototype.blockForSelector(f,!0);g.restoreInputs(d,e);g.fixBlockColor(null,!0);g.addShadow(new Point(3,3));c.addItem(g.doWithAlpha(1,()=>g.fullImage()),()=>SnapActions.setSelector(this,f))});c.popup(this.world(),this.bottomLeft().subtract(new Point(8,this instanceof +CommandBlockMorph?this.corner:0)))}; +BlockMorph.prototype.setSelector=function(a,b=0){var c=this.inputs(),d=this.parentThatIsA(ScriptsMorph);var e=SpriteMorph.prototype.blocks[a];this.setCategory(e.category);this.selector=a;this.setSpec(localize(e.spec));this.defaults=e.defaults||[];a=this.inputs();if(a[0]instanceof MultiArgMorph)a[0].setContents(this.defaults),a[0].defaults=this.defaults;else for(e=0;e{f.moveBy(10);d.add(f)})}; +BlockMorph.prototype.restoreInputs=function(a,b=0){var c,d,e=this,f=this.inputs(),g=[];for(d=0;d{h=a[b];h instanceof ArgLabelMorph&&(h=h.argMorph());h instanceof RingMorph?h.contents()&&e.replaceInput(l,h.fullCopy()):h instanceof ReporterBlockMorph?l instanceof TemplateSlotMorph||l.isStatic?g.push(h):e.replaceInput(l,h.fullCopy()):h&&l instanceof InputSlotMorph?h.contents&&(l.setContents(h.contents().text),h.constant&& +(l.constant=h.constant)):h instanceof CSlotMorph&&l instanceof CSlotMorph?(c=h.nestedBlock())&&l.nestedBlock(c.fullCopy()):h instanceof MultiArgMorph&&l instanceof MultiArgMorph&&h.slotSpec===l.slotSpec&&h.infix===l.infix&&e.replaceInput(l,h.fullCopy());b+=1});for(b;b to reference the definition body's generated text code.":"Enter code that corresponds to the block's definition. Choose your own\nformal parameter names (ignoring the ones shown)."; -(new DialogBoxMorph(this,function(f){"evaluateCustomBlock"===b?a.definition.codeHeader=f:StageMorph.prototype.codeHeaders[b]=f},this)).promptCode("Header mapping","evaluateCustomBlock"===b?this.definition.codeHeader||"":StageMorph.prototype.codeHeaders[b]||"",this.world(),d,e)}; -BlockMorph.prototype.mapToCode=function(){var a=this,b="reify"===this.selector.substr(0,5)?"reify":this.selector,c=this.codeMappingHeader();c.addShadow(new Point(3,3));var d=c.doWithAlpha(1,function(){return c.fullImage()});(new DialogBoxMorph(this,function(e){"evaluateCustomBlock"===b?a.definition.codeMapping=e:StageMorph.prototype.codeMappings[b]=e},this)).promptCode("Code mapping","evaluateCustomBlock"===b?this.definition.codeMapping||"":StageMorph.prototype.codeMappings[b]||"",this.world(),d, -"Enter code that corresponds to the block's operation (usually a single\nfunction invocation). Use <#n> to reference actual arguments as shown.")};BlockMorph.prototype.mapHeader=function(a,b){b=b||"reify"===this.selector.substr(0,5)?"reify":this.selector;a&&(this.isCustomBlock?this.definition.codeHeader=a:StageMorph.prototype.codeHeaders[b]=a)}; -BlockMorph.prototype.mapCode=function(a,b){b=b||"reify"===this.selector.substr(0,5)?"reify":this.selector;a&&(this.isCustomBlock?this.definition.codeMapping=a:StageMorph.prototype.codeMappings[b]=a)}; +(c=this.isGlobal?this.definition:this.scriptTarget().getMethod(this.blockSpec),e=c.comment)){var h=c.blockInstance();h.refreshDefaults(c);e=e.fullCopy();e.contents.parse();var k="";e.contents.lines.forEach(l=>k=k+"\n"+l);(new DialogBoxMorph).inform("Help",k.substr(1),a.world(),h.doWithAlpha(1,()=>{h.addShadow();return h.fullImage()}));return}d.src=b.resourceURL("help",g+".png")}; +BlockMorph.prototype.mapToHeader=function(){var a="reify"===this.selector.substr(0,5)?"reify":this.selector,b=this.codeDefinitionHeader();b.addShadow(new Point(3,3));var c=b.doWithAlpha(1,()=>b.fullImage());var d=this.isCustomBlock?"Enter code that corresponds to the block's definition. Use the formal parameter\nnames as shown and to reference the definition body's generated text code.":"Enter code that corresponds to the block's definition. Choose your own\nformal parameter names (ignoring the ones shown)."; +(new DialogBoxMorph(this,e=>{"evaluateCustomBlock"===a?this.definition.codeHeader=e:StageMorph.prototype.codeHeaders[a]=e},this)).promptCode("Header mapping","evaluateCustomBlock"===a?this.definition.codeHeader||"":StageMorph.prototype.codeHeaders[a]||"",this.world(),c,d)}; +BlockMorph.prototype.mapToCode=function(){var a="reify"===this.selector.substr(0,5)?"reify":this.selector,b=this.codeMappingHeader();b.addShadow(new Point(3,3));var c=b.doWithAlpha(1,()=>b.fullImage());(new DialogBoxMorph(this,d=>{"evaluateCustomBlock"===a?this.definition.codeMapping=d:StageMorph.prototype.codeMappings[a]=d},this)).promptCode("Code mapping","evaluateCustomBlock"===a?this.definition.codeMapping||"":StageMorph.prototype.codeMappings[a]||"",this.world(),c,"Enter code that corresponds to the block's operation (usually a single\nfunction invocation). Use <#n> to reference actual arguments as shown.")}; +BlockMorph.prototype.mapHeader=function(a,b){b=b||"reify"===this.selector.substr(0,5)?"reify":this.selector;a&&(this.isCustomBlock?this.definition.codeHeader=a:StageMorph.prototype.codeHeaders[b]=a)};BlockMorph.prototype.mapCode=function(a,b){b=b||"reify"===this.selector.substr(0,5)?"reify":this.selector;a&&(this.isCustomBlock?this.definition.codeMapping=a:StageMorph.prototype.codeMappings[b]=a)}; BlockMorph.prototype.mappedCode=function(a){var b="reify"===this.selector.substr(0,5)?"reify":this.selector,c=1,d=this.isCustomBlock?this.definition.spec:b,e=a||{},f=[];var g="reportGetVar"===b?this.blockSpec:this.isCustomBlock?this.definition.codeMapping||"":StageMorph.prototype.codeMappings[b]||"";if("reportGetVar"!==b&&!e.hasOwnProperty(d))if(e[d]=null,this.isCustomBlock){b=this.definition.codeHeader||"";if(-1!==b.indexOf(""),k.join("\n"+q));l[r]=l[r].replace(RegExp("","g"),k.join("\n"))});b=l.join("\n")}e[d]=b}else e[d]=StageMorph.prototype.codeHeaders[d];var m=g.split("\n");this.inputs().forEach(function(p){return f.push(p.mappedCode(e).toString())});f.forEach(function(p){var r=p.split("\n"),q="<#"+c+">",t=new RegExp(q,"g");m.forEach(function(u, -v){var w="";0===u.trimLeft().indexOf(q)&&(w=u.indexOf(q),w=u.slice(0,w));m[v]=u.replace(new RegExp(q),r.join("\n"+w));m[v]=m[v].replace(t,r.join("\n"))});c+=1});g=m.join("\n");this.nextBlock&&this.nextBlock()&&(g+="\n"+this.nextBlock().mappedCode(e));if(!a){var n=[];Object.keys(e).forEach(function(p){e[p]&&n.push(e[p])});if(n.length)return n.join("\n\n")+"\n\n"+g}return g}; -BlockMorph.prototype.codeDefinitionHeader=function(){var a=this.isCustomBlock?new PrototypeHatBlockMorph(this.definition):SpriteMorph.prototype.blockForSelector(this.selector),b=new HatBlockMorph,c=1;if(this.isCustomBlock)return a;a.inputs().forEach(function(d){var e=new TemplateSlotMorph("#"+c);a.replaceInput(d,e);c+=1});a.isPrototype=!0;b.setCategory("control");b.setSpec("%s");b.replaceInput(b.inputs()[0],a);"control"===this.category&&b.alternateBlockColor();return b}; -BlockMorph.prototype.codeMappingHeader=function(){var a=this.isCustomBlock?this.definition.blockInstance():SpriteMorph.prototype.blockForSelector(this.selector),b=new HatBlockMorph,c=1;a.inputs().forEach(function(d){var e=new TemplateSlotMorph("<#"+c+">");a.replaceInput(d,e);c+=1});a.isPrototype=!0;b.setCategory("control");b.setSpec("%s");b.replaceInput(b.inputs()[0],a);"control"===this.category&&b.alternateBlockColor();return b}; +var k=h.split("\n");var l=b.split("\n");l.forEach((p,q)=>{var r="";0===p.trimLeft().indexOf(""),k.join("\n"+r));l[q]=l[q].replace(RegExp("","g"),k.join("\n"))});b=l.join("\n")}e[d]=b}else e[d]=StageMorph.prototype.codeHeaders[d];var m=g.split("\n");this.inputs().forEach(p=>f.push(p.mappedCode(e).toString()));f.forEach(p=>{var q=p.split("\n"),r="<#"+c+">",t=new RegExp(r,"g");m.forEach((u,v)=>{var w="";0===u.trimLeft().indexOf(r)&& +(w=u.indexOf(r),w=u.slice(0,w));m[v]=u.replace(new RegExp(r),q.join("\n"+w));m[v]=m[v].replace(t,q.join("\n"))});c+=1});g=m.join("\n");this.nextBlock&&this.nextBlock()&&(g+="\n"+this.nextBlock().mappedCode(e));if(!a){var n=[];Object.keys(e).forEach(p=>{e[p]&&n.push(e[p])});if(n.length)return n.join("\n\n")+"\n\n"+g}return g}; +BlockMorph.prototype.codeDefinitionHeader=function(){var a=this.isCustomBlock?new PrototypeHatBlockMorph(this.definition):SpriteMorph.prototype.blockForSelector(this.selector),b=new HatBlockMorph,c=1;if(this.isCustomBlock)return a;a.inputs().forEach(d=>{var e=new TemplateSlotMorph("#"+c);a.replaceInput(d,e);c+=1});a.isPrototype=!0;b.setCategory("control");b.setSpec("%s");b.replaceInput(b.inputs()[0],a);"control"===this.category&&b.alternateBlockColor();return b}; +BlockMorph.prototype.codeMappingHeader=function(){var a=this.isCustomBlock?this.definition.blockInstance():SpriteMorph.prototype.blockForSelector(this.selector),b=new HatBlockMorph,c=1;a.inputs().forEach(d=>{var e=new TemplateSlotMorph("<#"+c+">");a.replaceInput(d,e);c+=1});a.isPrototype=!0;b.setCategory("control");b.setSpec("%s");b.replaceInput(b.inputs()[0],a);"control"===this.category&&b.alternateBlockColor();return b}; BlockMorph.prototype.refactorThisVar=function(a){var b=this.scriptTarget(),c=this.instantiationSpec||this.blockSpec,d=this.fullCopy();d.addShadow();(new DialogBoxMorph(this,function(e){this.parent instanceof SyntaxElementMorph?this.parentThatIsA(BlockEditorMorph)?this.doRefactorBlockParameter(c,e,a):this.parentThatIsA(RingMorph)?this.doRefactorRingParameter(c,e,a):this.doRefactorScriptVar(c,e,a):b.hasSpriteVariable(c)?this.doRefactorSpriteVar(c,e,a):this.doRefactorGlobalVar(c,e,a)},this)).prompt("Variable name", -c,this.world(),d.doWithAlpha(1,function(){return d.fullImage()}),InputSlotMorph.prototype.getVarNamesDict.call(this))};BlockMorph.prototype.varExistsError=function(a,b){a.inform("Variable exists","A variable with this name already exists "+(b||"in this context")+".")}; -BlockMorph.prototype.doRefactorBlockParameter=function(a,b,c){var d=this.parentThatIsA(BlockInputFragmentMorph),e=d.fragment.copy(),f=d.parent,g=this.parentThatIsA(BlockEditorMorph),h=g.body.contents;f.anyChild(function(k){return k.blockSpec===b})?this.varExistsError(g.target.parentThatIsA(IDE_Morph)):(e.labelString=b,d.updateBlockLabel(e),c||h.children.forEach(function(k){return k.refactorVarInStack(a,b)}))}; +c,this.world(),d.doWithAlpha(1,()=>d.fullImage()),InputSlotMorph.prototype.getVarNamesDict.call(this))};BlockMorph.prototype.varExistsError=function(a,b){a.inform("Variable exists","A variable with this name already exists "+(b||"in this context")+".")}; +BlockMorph.prototype.doRefactorBlockParameter=function(a,b,c){var d=this.parentThatIsA(BlockInputFragmentMorph),e=d.fragment.copy(),f=d.parent,g=this.parentThatIsA(BlockEditorMorph),h=g.body.contents;f.anyChild(k=>k.blockSpec===b)?this.varExistsError(g.target.parentThatIsA(IDE_Morph)):(e.labelString=b,d.updateBlockLabel(e),c||h.children.forEach(k=>k.refactorVarInStack(a,b)))}; BlockMorph.prototype.doRefactorRingParameter=function(a,b,c){var d=this.parentThatIsA(RingMorph),e=d.contents(),f=this.topBlock();contains(d.inputNames(),b)?this.varExistsError(this.parentThatIsA(IDE_Morph)):(f.fullChanged(),this.setSpec(b),c||e&&e.refactorVarInStack(a,b),f.fullChanged())}; BlockMorph.prototype.doRefactorScriptVar=function(a,b,c){var d=this.parentThatIsA(CommandBlockMorph);d.definesScriptVariable(b)?(a=this.scriptTarget(),a=a.parentThatIsA(IDE_Morph),this.varExistsError(a)):(this.userSetSpec(b),c||d.refactorVarInStack(a,b,!0))}; -BlockMorph.prototype.doRefactorSpriteVar=function(a,b,c){var d=this.scriptTarget(),e=d.parentThatIsA(IDE_Morph),f=d.findVariableWatcher(a);if(d.hasSpriteVariable(b))this.varExistsError(e);else if(isNil(e.globalVariables.vars[b])){var g=d.variables.getVar(a);d.deleteVariable(a);d.addVariable(b,!1);d.variables.setVar(b,g);f&&f.isVisible&&(g=d.toggleVariableWatcher(b,!1),g.setPosition(f.position()));c||(d.refactorVariableInstances(a,b,!1),d.customBlocks.forEach(function(h){return h.body.expression.refactorVarInStack(a, -b)}));e.flushBlocksCache("variables");e.refreshPalette()}else this.varExistsError(e,"as a global variable")}; -BlockMorph.prototype.doRefactorGlobalVar=function(a,b,c){var d=this.scriptTarget(),e=d.parentThatIsA(IDE_Morph),f=e?e.stage:null,g=d.findVariableWatcher(a);if(isNil(e.globalVariables.vars[b]))if(detect(f.children,function(k){return k instanceof SpriteMorph&&k.hasSpriteVariable(b)}))this.varExistsError(e,"as a sprite local variable");else{var h=e.globalVariables.getVar(a);f.deleteVariable(a);f.addVariable(b,!0);e.globalVariables.setVar(b,h);g&&g.isVisible&&(d=d.toggleVariableWatcher(b,!0),d.setPosition(g.position())); -c||(f.refactorVariableInstances(a,b,!0),f.globalBlocks.forEach(function(k){k.body&&k.body.expression.refactorVarInStack(a,b)}),f.forAllChildren(function(k){k instanceof SpriteMorph&&(k.refactorVariableInstances(a,b,!0),k.customBlocks.forEach(function(l){return l.body.expression.refactorVarInStack(a,b)}))}));e.flushBlocksCache("variables");e.refreshPalette()}else this.varExistsError(e)}; +BlockMorph.prototype.doRefactorSpriteVar=function(a,b,c){var d=this.scriptTarget(),e=d.parentThatIsA(IDE_Morph),f=d.findVariableWatcher(a);if(d.hasSpriteVariable(b))this.varExistsError(e);else if(isNil(e.globalVariables.vars[b])){var g=d.variables.getVar(a);d.deleteVariable(a);d.addVariable(b,!1);d.variables.setVar(b,g);f&&f.isVisible&&(g=d.toggleVariableWatcher(b,!1),g.setPosition(f.position()));c||(d.refactorVariableInstances(a,b,!1),d.customBlocks.forEach(h=>h.body.expression.refactorVarInStack(a, +b)));e.flushBlocksCache("variables");e.refreshPalette()}else this.varExistsError(e,"as a global variable")}; +BlockMorph.prototype.doRefactorGlobalVar=function(a,b,c){var d=this.scriptTarget(),e=d.parentThatIsA(IDE_Morph),f=e?e.stage:null,g=d.findVariableWatcher(a);if(isNil(e.globalVariables.vars[b]))if(detect(f.children,k=>k instanceof SpriteMorph&&k.hasSpriteVariable(b)))this.varExistsError(e,"as a sprite local variable");else{var h=e.globalVariables.getVar(a);f.deleteVariable(a);f.addVariable(b,!0);e.globalVariables.setVar(b,h);g&&g.isVisible&&(d=d.toggleVariableWatcher(b,!0),d.setPosition(g.position())); +c||(f.refactorVariableInstances(a,b,!0),f.globalBlocks.forEach(k=>{k.body&&k.body.expression.refactorVarInStack(a,b)}),f.forAllChildren(k=>{k instanceof SpriteMorph&&(k.refactorVariableInstances(a,b,!0),k.customBlocks.forEach(l=>l.body.expression.refactorVarInStack(a,b)))}));e.flushBlocksCache("variables");e.refreshPalette()}else this.varExistsError(e)}; BlockMorph.prototype.thumbnail=function(a,b){var c=this.nextBlock();c&&(c.isVisible=!1);var d=this.fullBounds().extent();var e=newCanvas(new Point(b?Math.min(d.x*a,b):d.x*a,d.y*a));var f=e.getContext("2d");f.scale(a,a);f.drawImage(this.fullImage(),0,0);b&&d.x*a>b&&(b=f.createLinearGradient(e.width/a-12,0,e.width/a,0),b.addColorStop(0,"transparent"),b.addColorStop(1,"black"),f.globalCompositeOperation="destination-out",f.fillStyle=b,f.fillRect(e.width/a-12,0,e.width/a,e.height/a));c&&(c.isVisible= -!0);return e};BlockMorph.prototype.scriptPic=function(){var a=this.fullImage(),b=this.stackFullBounds(),c=newCanvas(b.extent()),d=c.getContext("2d");this.allComments().forEach(function(e){return d.drawImage(e.fullImage(),e.fullBounds().left()-b.left(),e.top()-b.top())});d.drawImage(a,0,0);return c}; -BlockMorph.prototype.fullImage=function(){var a=this;if(1===this.alpha)return BlockMorph.uber.fullImage.call(this);this.forAllChildren(function(f){f instanceof BlockMorph&&f.mouseLeaveBounds()});var b=BlockMorph.uber.fullImage.call(this);var c=this.doWithAlpha(1,function(){return BlockMorph.uber.fullImage.call(a)});var d=newCanvas(this.fullBounds().extent());var e=d.getContext("2d");e.fillStyle=ScriptsMorph.prototype.getRenderColor().toString();e.fillRect(0,0,d.width,d.height);e.globalCompositeOperation= -"destination-in";e.drawImage(c,0,0);e.globalCompositeOperation="source-over";e.drawImage(b,0,0);return d};BlockMorph.prototype.clearAlpha=function(){this.forAllChildren(function(a){a instanceof BlockMorph&&delete a.alpha})}; +!0);return e};BlockMorph.prototype.scriptPic=function(){var a=this.fullImage(),b=this.stackFullBounds(),c=newCanvas(b.extent()),d=c.getContext("2d");this.allComments().forEach(e=>d.drawImage(e.fullImage(),e.fullBounds().left()-b.left(),e.top()-b.top()));d.drawImage(a,0,0);return c}; +BlockMorph.prototype.fullImage=function(){if(1===this.alpha)return BlockMorph.uber.fullImage.call(this);this.forAllChildren(e=>{e instanceof BlockMorph&&e.mouseLeaveBounds()});var a=BlockMorph.uber.fullImage.call(this);var b=this.doWithAlpha(1,()=>BlockMorph.uber.fullImage.call(this));var c=newCanvas(this.fullBounds().extent());var d=c.getContext("2d");d.fillStyle=ScriptsMorph.prototype.getRenderColor().toString();d.fillRect(0,0,c.width,c.height);d.globalCompositeOperation="destination-in";d.drawImage(b, +0,0);d.globalCompositeOperation="source-over";d.drawImage(a,0,0);return c};BlockMorph.prototype.clearAlpha=function(){this.forAllChildren(a=>{a instanceof BlockMorph&&delete a.alpha})}; BlockMorph.prototype.render=function(a){this.cachedClr=this.color.toString();this.cachedClrBright=this.bright();this.cachedClrDark=this.dark();MorphicPreferences.isFlat?(a.fillStyle=this.cachedClrDark,a.beginPath(),this.outlinePath(a,0),a.closePath(),a.fill(),a.fillStyle=this.cachedClr,a.beginPath(),this.outlinePath(a,this.flatEdge),a.closePath(),a.fill()):(a.fillStyle=this.cachedClr,a.beginPath(),this.outlinePath(a,0),a.closePath(),a.fill(),this.drawEdges(a));this.hasLocationPin()&&this.drawMethodIcon(a)}; BlockMorph.prototype.drawMethodIcon=function(a){var b=this.methodIconExtent(),c=b.y;b=b.x/2;var d=this.edge+this.labelPadding,e=this.edge,f=this.color===SpriteMorph.prototype.blockColor[this.category];this.isPredicate&&(d=this.rounding);this instanceof CommandBlockMorph&&(e+=this.corner);a.fillStyle=f?this.cachedClrBright:this.cachedClrDark;a.beginPath();a.arc(d+b,e+b,b,radians(-210),radians(30),!1);a.lineTo(d+b,e+c);a.closePath();a.fill();a.fillStyle=this.cachedClr;a.beginPath();a.arc(d+b,e+b,.4* -b,radians(0),radians(360),!1);a.closePath();a.fill()};BlockMorph.prototype.cSlots=function(){var a=[];this.parts().forEach(function(b){b instanceof CSlotMorph?a.push(b):b instanceof MultiArgMorph&&b.parts().forEach(function(c){c instanceof CSlotMorph&&a.push(c)})});return a};BlockMorph.prototype.hasLocationPin=function(){return this.isCustomBlock&&!this.isGlobal||this.isLocalVarTemplate}; +b,radians(0),radians(360),!1);a.closePath();a.fill()};BlockMorph.prototype.cSlots=function(){var a=[];this.parts().forEach(b=>{b instanceof CSlotMorph?a.push(b):b instanceof MultiArgMorph&&b.parts().forEach(c=>{c instanceof CSlotMorph&&a.push(c)})});return a};BlockMorph.prototype.hasLocationPin=function(){return this.isCustomBlock&&!this.isGlobal||this.isLocalVarTemplate}; BlockMorph.prototype.addHighlight=function(a){var b=!this.isVisible;b&&this.show();1>SyntaxElementMorph.prototype.alpha&&this.clearAlpha();a=this.highlight(a?a.color:this.activeHighlight,this.activeBlur,this.activeBorder);this.addBack(a);this.fullChanged();b&&this.hide();return a}; BlockMorph.prototype.addErrorHighlight=function(){var a=!this.isVisible;a&&this.show();this.removeHighlight();var b=this.highlight(this.errorHighlight,this.activeBlur,this.activeBorder);this.addBack(b);this.fullChanged();a&&this.hide();return b};BlockMorph.prototype.removeHighlight=function(){var a=this.getHighlight();null!==a&&(this.fullChanged(),this.removeChild(a));return a};BlockMorph.prototype.toggleHighlight=function(){this.getHighlight()?this.removeHighlight():this.addHighlight()}; BlockMorph.prototype.highlight=function(a,b,c){var d=new BlockHighlightMorph,e=this.fullBounds(),f=useBlurredShadows&&!MorphicPreferences.isFlat?b:c;d.bounds.setExtent(e.extent().add(2*f));d.holes=[d.bounds];d.color=a;d.cachedImage=useBlurredShadows&&!MorphicPreferences.isFlat?this.highlightImageBlurred(a,b):this.highlightImage(a,c);d.setPosition(e.origin.subtract(new Point(f,f)));return d}; -BlockMorph.prototype.highlightImage=function(a,b){var c=this,d;var e=this.fullBounds().extent();this.doWithAlpha(1,function(){return d=c.fullImage()});var f=newCanvas(e.add(2*b));var g=f.getContext("2d");g.drawImage(d,0,0);g.drawImage(d,b,0);g.drawImage(d,2*b,0);g.drawImage(d,2*b,b);g.drawImage(d,2*b,2*b);g.drawImage(d,b,2*b);g.drawImage(d,0,2*b);g.drawImage(d,0,b);g.globalCompositeOperation="destination-out";g.drawImage(d,b,b);b=newCanvas(e.add(2*b));g=b.getContext("2d");g.drawImage(f,0,0);g.globalCompositeOperation= -"source-atop";g.fillStyle=a.toString();g.fillRect(0,0,b.width,b.height);return b};BlockMorph.prototype.highlightImageBlurred=function(a,b){var c=this,d;var e=this.fullBounds().extent();this.doWithAlpha(1,function(){return d=c.fullImage()});e=newCanvas(e.add(2*b));var f=e.getContext("2d");f.shadowBlur=b;f.shadowColor=a.toString();f.drawImage(d,b,b);f.shadowBlur=0;f.globalCompositeOperation="destination-out";f.drawImage(d,b,b);return e}; -BlockMorph.prototype.getHighlight=function(){var a=this.children.slice(0).reverse().filter(function(b){return b instanceof BlockHighlightMorph});return 0!==a.length?a[0]:null};BlockMorph.prototype.outline=function(a,b){var c=new BlockHighlightMorph,d=this.fullBounds();c.bounds.setExtent(d.extent().add(2*b));c.color=a;c.cachedImage=this.highlightImage(a,b);c.setPosition(d.origin.subtract(new Point(b,b)));return c}; -BlockMorph.prototype.getCategoryColor=function(a){return SpriteMorph.prototype.blockColor[a]||SpriteMorph.prototype.blockColor.other}; +BlockMorph.prototype.highlightImage=function(a,b){var c;var d=this.fullBounds().extent();this.doWithAlpha(1,()=>c=this.fullImage());var e=newCanvas(d.add(2*b));var f=e.getContext("2d");f.drawImage(c,0,0);f.drawImage(c,b,0);f.drawImage(c,2*b,0);f.drawImage(c,2*b,b);f.drawImage(c,2*b,2*b);f.drawImage(c,b,2*b);f.drawImage(c,0,2*b);f.drawImage(c,0,b);f.globalCompositeOperation="destination-out";f.drawImage(c,b,b);b=newCanvas(d.add(2*b));f=b.getContext("2d");f.drawImage(e,0,0);f.globalCompositeOperation= +"source-atop";f.fillStyle=a.toString();f.fillRect(0,0,b.width,b.height);return b};BlockMorph.prototype.highlightImageBlurred=function(a,b){var c;var d=this.fullBounds().extent();this.doWithAlpha(1,()=>c=this.fullImage());d=newCanvas(d.add(2*b));var e=d.getContext("2d");e.shadowBlur=b;e.shadowColor=a.toString();e.drawImage(c,b,b);e.shadowBlur=0;e.globalCompositeOperation="destination-out";e.drawImage(c,b,b);return d}; +BlockMorph.prototype.getHighlight=function(){var a=this.children.slice(0).reverse().filter(b=>b instanceof BlockHighlightMorph);return 0!==a.length?a[0]:null};BlockMorph.prototype.outline=function(a,b){var c=new BlockHighlightMorph,d=this.fullBounds();c.bounds.setExtent(d.extent().add(2*b));c.color=a;c.cachedImage=this.highlightImage(a,b);c.setPosition(d.origin.subtract(new Point(b,b)));return c};BlockMorph.prototype.getCategoryColor=function(a){return SpriteMorph.prototype.blockColor[a]||SpriteMorph.prototype.blockColor.other}; BlockMorph.prototype.fixBlockColor=function(a,b){var c;if(this.zebraContrast||b){if(!this.zebraContrast&&b)return this.forceNormalColoring(!0);!a&&this.parent&&(this.isPrototype?a=null:this instanceof ReporterBlockMorph?a=this.parent.parentThatIsA(BlockMorph):(c=this.parentThatIsA(CommandSlotMorph,ReporterSlotMorph))&&(a=c.parentThatIsA(BlockMorph)));a?a.category===this.category?a.color.eq(this.color)&&this.alternateBlockColor():this.category&&!this.color.eq(this.getCategoryColor(this.category))&& this.alternateBlockColor():(a=this.getCategoryColor(this.category),this.color.eq(a)||this.alternateBlockColor());b&&this.fixChildrensBlockColor(!0)}};BlockMorph.prototype.forceNormalColoring=function(){var a=this.getCategoryColor(this.category);this.setColor(a);this.setLabelColor(this.overrideWhite||WHITE,a.darker(this.labelContrast),MorphicPreferences.isFlat?ZERO:this.embossing);this.fixChildrensBlockColor(!0)}; BlockMorph.prototype.alternateBlockColor=function(){var a=this.getCategoryColor(this.category);this.color.eq(a)?this.setColor(0>this.zebraContrast?a.darker(Math.abs(this.zebraContrast)):a.lighter(this.zebraContrast),this.hasLabels()):this.setColor(a,this.hasLabels());this.fixLabelColor();this.fixChildrensBlockColor(!0)};BlockMorph.prototype.ghost=function(){this.setColor(this.getCategoryColor(this.category).lighter(35))}; BlockMorph.prototype.fixLabelColor=function(){if(0{b instanceof CommandBlockMorph?b.fixBlockColor(null,a):b instanceof SyntaxElementMorph&&(b.fixBlockColor(this,a),b instanceof BooleanSlotMorph&&b.fixLayout())})};BlockMorph.prototype.setCategory=function(a){this.category=a;this.fixBlockColor()};BlockMorph.prototype.hasLabels=function(){return this.children.some(a=>a instanceof StringMorph)}; BlockMorph.prototype.copy=function(){var a=BlockMorph.uber.copy.call(this);a.id=this.id;return a}; -BlockMorph.prototype.fullCopy=function(){var a=BlockMorph.uber.fullCopy.call(this);a.removeHighlight();a.isDraggable=!0;this.instantiationSpec&&a.setSpec(this.instantiationSpec);a.allChildren().filter(function(b){b instanceof SyntaxElementMorph&&(b.cachedInputs=null,b.isCustomBlock&&b.initializeVariables());return!isNil(b.comment)}).forEach(function(b){var c=b.comment.fullCopy();b.comment=c;c.block=b});a.cachedInputs=null;return a}; -BlockMorph.prototype.reactToTemplateCopy=function(){this.isLocalVarTemplate&&(this.isLocalVarTemplate=null,this.fixLayout());this.forceNormalColoring()};BlockMorph.prototype.hasBlockVars=function(){return this.anyChild(function(a){return a.isCustomBlock&&a.isGlobal&&a.definition.variableNames.length})};BlockMorph.prototype.pickUp=function(a){a=a||this.world();this.setPosition(a.hand.position().subtract(this.rounding));a.hand.grab(this)}; +BlockMorph.prototype.fullCopy=function(){var a=BlockMorph.uber.fullCopy.call(this);a.removeHighlight();a.isDraggable=!0;this.instantiationSpec&&a.setSpec(this.instantiationSpec);a.allChildren().filter(b=>{b instanceof SyntaxElementMorph&&(b.cachedInputs=null,b.isCustomBlock&&b.initializeVariables());return!isNil(b.comment)}).forEach(b=>{var c=b.comment.fullCopy();b.comment=c;c.block=b});a.cachedInputs=null;return a}; +BlockMorph.prototype.reactToTemplateCopy=function(){this.isLocalVarTemplate&&(this.isLocalVarTemplate=null,this.fixLayout());this.forceNormalColoring()};BlockMorph.prototype.hasBlockVars=function(){return this.anyChild(a=>a.isCustomBlock&&a.isGlobal&&a.definition.variableNames.length)};BlockMorph.prototype.pickUp=function(a){a=a||this.world();this.setPosition(a.hand.position().subtract(this.rounding));a.hand.grab(this)}; BlockMorph.prototype.mouseClickLeft=function(){var a=this.topBlock(),b=a.scriptTarget(),c;if(16===this.world().currentKey&&!this.isTemplate)return this.selectForEdit().focus();if(!(a instanceof PrototypeHatBlockMorph)&&b&&(c=b.parentThatIsA(StageMorph))){var d=c.threads.findProcess(a);if("receiveSocketMessage"!==a.selector||d)c.threads.toggleProcess(a,b),a.id&&SnapActions.startScript(a,d)}}; BlockMorph.prototype.focus=function(){var a=this.parentThatIsA(ScriptsMorph),b=this.world();if(a&&ScriptsMorph.prototype.enableKeyboard){a.focus&&a.focus.stopEditing();b.stopEditing();var c=new ScriptFocusMorph(a,this);a.focus=c;c.getFocus(b);this instanceof HatBlockMorph&&c.nextCommand()}};BlockMorph.prototype.activeProcess=function(){var a=this.topBlock(),b=a.scriptTarget(),c;return a instanceof PrototypeHatBlockMorph?null:b&&(c=b.parentThatIsA(StageMorph))?c.threads.findProcess(a,b):null}; BlockMorph.prototype.mouseEnterBounds=function(a){!a&&1>this.alpha&&(this.alpha=Math.min(this.alpha+.2,1),this.rerender())};BlockMorph.prototype.mouseLeaveBounds=function(a){1>SyntaxElementMorph.prototype.alpha&&(delete this.alpha,this.rerender())};BlockMorph.prototype.rootForGrab=function(){return this};BlockMorph.prototype.wantsDropOf=function(a){return(a instanceof ArgMorph||a instanceof StringMorph||a instanceof TextMorph)&&!this.isTemplate}; BlockMorph.prototype.reactToDropOf=function(a){a.isDraggable=!1;a.fixLayout();this.fixLayout();this.buildSpec()};BlockMorph.prototype.situation=function(){if(!(this.parent instanceof TemplateSlotMorph)){var a=this.parentThatIsA(ScriptsMorph);if(a)return{origin:this.parent,position:this.position().subtract(a.position())}}return BlockMorph.uber.situation.call(this)}; -BlockMorph.prototype.prepareToBeGrabbed=function(a){var b=this,c=a?a.world:this.world();this.allInputs().forEach(function(d){return delete d.bindingID});this.allComments().forEach(function(d){return d.startFollowing(b,c)})};BlockMorph.prototype.justDropped=function(){delete this.alpha;this.allComments().forEach(function(a){return a.stopFollowing()})};BlockMorph.prototype.allComments=function(){return this.allChildren().filter(function(a){return!isNil(a.comment)}).map(function(a){return a.comment})}; -BlockMorph.prototype.destroy=function(a){a?isNil(this.comment)||this.comment.destroy():this.allComments().forEach(function(b){return b.destroy()});BlockMorph.uber.destroy.call(this)};BlockMorph.prototype.stackHeight=function(){var a=this.fullBounds(),b=Math.max(this.allComments().map(function(c){return c.bottom()}))||this.bottom();return Math.max(a.bottom(),b)-a.top()}; -BlockMorph.prototype.stackFullBounds=function(){var a=this.fullBounds();this.allComments().forEach(function(b){return a.mergeWith(b.bounds)});return a};BlockMorph.prototype.stackWidth=function(){var a=this.fullBounds(),b=Math.max(this.allComments().map(function(c){return c.right()}))||this.right();return Math.max(a.right(),b)-a.left()};BlockMorph.prototype.snapTarget=function(){return null}; -BlockMorph.prototype.snap=function(){var a=this.topBlock(),b;a.allComments().forEach(function(c){return c.align(a)});this.getHighlight()&&this!==a&&this.removeHighlight();a.getHighlight()&&a.addHighlight(a.removeHighlight());"receiveCondition"===this.selector&&(b=a.scriptTarget())&&(b=b.parentThatIsA(StageMorph))&&(b.enableCustomHatBlocks=!0,b.threads.pauseCustomHatBlocks=!1,(b=b.parentThatIsA(IDE_Morph))&&b.controlBar.stopButton.refresh())};CommandBlockMorph.prototype=new BlockMorph; +BlockMorph.prototype.prepareToBeGrabbed=function(a){var b=a?a.world:this.world();this.allInputs().forEach(c=>delete c.bindingID);this.allComments().forEach(c=>c.startFollowing(this,b))};BlockMorph.prototype.justDropped=function(){delete this.alpha;this.allComments().forEach(a=>a.stopFollowing())};BlockMorph.prototype.allComments=function(){return this.allChildren().filter(a=>!isNil(a.comment)).map(a=>a.comment)}; +BlockMorph.prototype.destroy=function(a){a?isNil(this.comment)||this.comment.destroy():this.allComments().forEach(b=>b.destroy());BlockMorph.uber.destroy.call(this)};BlockMorph.prototype.stackHeight=function(){var a=this.fullBounds(),b=Math.max(this.allComments().map(c=>c.bottom()))||this.bottom();return Math.max(a.bottom(),b)-a.top()};BlockMorph.prototype.stackFullBounds=function(){var a=this.fullBounds();this.allComments().forEach(b=>a.mergeWith(b.bounds));return a}; +BlockMorph.prototype.stackWidth=function(){var a=this.fullBounds(),b=Math.max(this.allComments().map(c=>c.right()))||this.right();return Math.max(a.right(),b)-a.left()};BlockMorph.prototype.snapTarget=function(){return null}; +BlockMorph.prototype.snap=function(){var a=this.topBlock(),b;a.allComments().forEach(c=>c.align(a));this.getHighlight()&&this!==a&&this.removeHighlight();a.getHighlight()&&a.addHighlight(a.removeHighlight());"receiveCondition"===this.selector&&(b=a.scriptTarget())&&(b=b.parentThatIsA(StageMorph))&&(b.enableCustomHatBlocks=!0,b.threads.pauseCustomHatBlocks=!1,(b=b.parentThatIsA(IDE_Morph))&&b.controlBar.stopButton.refresh())};CommandBlockMorph.prototype=new BlockMorph; CommandBlockMorph.prototype.constructor=CommandBlockMorph;CommandBlockMorph.uber=BlockMorph.prototype;function CommandBlockMorph(){this.init()}CommandBlockMorph.prototype.init=function(){CommandBlockMorph.uber.init.call(this);this.bounds.setExtent((new Point(60,24)).multiplyBy(this.scale));this.fixLayout();this.rerender();this.partOfCustomCommand=!1;this.exitTag=null};CommandBlockMorph.prototype.blockSequence=function(){var a=this.nextBlock(),b=[this];a&&(b=b.concat(a.blockSequence()));return b}; -CommandBlockMorph.prototype.bottomBlock=function(){return this.nextBlock()?this.nextBlock().bottomBlock():this};CommandBlockMorph.prototype.nextBlock=function(a){if(a){var b=this.nextBlock(),c=this.parentThatIsA(CommandSlotMorph,ReporterSlotMorph);this.add(a);b&&a.bottomBlock().nextBlock(b);a.setPosition(new Point(this.left(),this.bottom()-this.corner));c&&c.fixLayout()}else return detect(this.children,function(d){return d instanceof CommandBlockMorph&&!d.isPrototype})}; -CommandBlockMorph.prototype.topAttachPoint=function(){return new Point(this.dentCenter(),this.top())};CommandBlockMorph.prototype.bottomAttachPoint=function(){return new Point(this.dentCenter(),this.bottom())};CommandBlockMorph.prototype.wrapAttachPoint=function(){var a=detect(this.inputs(),function(b){return b instanceof CSlotMorph});return a&&!a.nestedBlock()?new Point(a.left()+2*a.inset+a.corner,a.top()+2*a.corner):null}; -CommandBlockMorph.prototype.dentLeft=function(){return this.left()+this.corner+this.inset};CommandBlockMorph.prototype.dentCenter=function(){return this.dentLeft()+this.corner+.5*this.dent}; +CommandBlockMorph.prototype.bottomBlock=function(){return this.nextBlock()?this.nextBlock().bottomBlock():this};CommandBlockMorph.prototype.nextBlock=function(a){if(a){var b=this.nextBlock(),c=this.parentThatIsA(CommandSlotMorph,ReporterSlotMorph);this.add(a);b&&a.bottomBlock().nextBlock(b);a.setPosition(new Point(this.left(),this.bottom()-this.corner));c&&c.fixLayout()}else return detect(this.children,d=>d instanceof CommandBlockMorph&&!d.isPrototype)}; +CommandBlockMorph.prototype.topAttachPoint=function(){return new Point(this.dentCenter(),this.top())};CommandBlockMorph.prototype.bottomAttachPoint=function(){return new Point(this.dentCenter(),this.bottom())};CommandBlockMorph.prototype.wrapAttachPoint=function(){var a=detect(this.inputs(),b=>b instanceof CSlotMorph);return a&&!a.nestedBlock()?new Point(a.left()+2*a.inset+a.corner,a.top()+2*a.corner):null};CommandBlockMorph.prototype.dentLeft=function(){return this.left()+this.corner+this.inset}; +CommandBlockMorph.prototype.dentCenter=function(){return this.dentLeft()+this.corner+.5*this.dent}; CommandBlockMorph.prototype.attachTargets=function(){var a=[];if(!(this instanceof HatBlockMorph)){var b=this.topAttachPoint();this.parent instanceof SyntaxElementMorph||a.push({point:b,element:this,loc:"top",type:"block"});!ScriptsMorph.prototype.enableNestedAutoWrapping&&this.parentThatIsA(CommandSlotMorph)||a.push({point:b,element:this,loc:"wrap",type:"block"})}this.isStop()||a.push({point:this.bottomAttachPoint(),element:this,loc:"bottom",type:"block"});return a}; -CommandBlockMorph.prototype.allAttachTargets=function(a){var b=this,c=[];if(this instanceof HatBlockMorph&&a.rejectsHats)return c;(a||this.parent).children.filter(function(d){return d!==b&&d instanceof SyntaxElementMorph&&!d.isTemplate}).forEach(function(d){return d.forAllChildren(function(e){e.attachTargets&&e.attachTargets().forEach(function(f){return c.push(f)})})});return c}; -CommandBlockMorph.prototype.closestAttachTarget=function(a){a=a||this.parent;var b=this.bottomBlock(),c=null,d=Math.max(2*this.corner+this.dent,this.minSnapDistance),e,f=[],g=1E3,h;this instanceof HatBlockMorph||(f.push({point:this.topAttachPoint(),loc:"top"}),(h=this.wrapAttachPoint())&&f.push({point:h,loc:"wrap"}));b.isStop()||f.push({point:b.bottomAttachPoint(),loc:"bottom"});this.allAttachTargets(a).forEach(function(k){return f.forEach(function(l){if("wrap"===l.loc&&"wrap"===k.loc||l.loc!==k.loc&& -"wrap"!==l.loc&&"wrap"!==k.loc)e=l.point.distanceTo(k.point),ec!==this&&c instanceof SyntaxElementMorph&&!c.isTemplate).forEach(c=>c.forAllChildren(d=>{d.attachTargets&&d.attachTargets().forEach(e=>b.push(e))}));return b}; +CommandBlockMorph.prototype.closestAttachTarget=function(a){a=a||this.parent;var b=this.bottomBlock(),c=null,d=Math.max(2*this.corner+this.dent,this.minSnapDistance),e,f=[],g=1E3,h;this instanceof HatBlockMorph||(f.push({point:this.topAttachPoint(),loc:"top"}),(h=this.wrapAttachPoint())&&f.push({point:h,loc:"wrap"}));b.isStop()||f.push({point:b.bottomAttachPoint(),loc:"bottom"});this.allAttachTargets(a).forEach(k=>f.forEach(l=>{if("wrap"===l.loc&&"wrap"===k.loc||l.loc!==k.loc&&"wrap"!==l.loc&&"wrap"!== +k.loc)e=l.point.distanceTo(k.point),ed instanceof CSlotMorph);b=a.element.parent;this.moveBy(a.point.subtract(c.slotAttachPoint()));c.nestedBlock(a.element);b instanceof CommandBlockMorph?b.nextBlock(this):b instanceof CommandSlotMorph?b.nestedBlock(this):b instanceof RingReporterSlotMorph&&(b.add(this),b.fixLayout());a.element.blockSequence().forEach(d=> +d.fixBlockColor())}this.fixBlockColor();CommandBlockMorph.uber.snap.call(this);this.snapSound&&this.snapSound.play()}};CommandBlockMorph.prototype.prepareToBeGrabbed=function(a){var b=this.position();this.parent instanceof RingReporterSlotMorph&&(this.parent.revertToDefaultInput(this),this.setPosition(b));CommandBlockMorph.uber.prepareToBeGrabbed.call(this,a)}; CommandBlockMorph.prototype.isStop=function(){if("doStopThis"===this.selector){var a=this.inputs()[0].evaluate();return a instanceof Array&&12>a[0].length}return-1<["doForever","doReport","removeClone"].indexOf(this.selector)}; CommandBlockMorph.prototype.userDestroy=function(){var a=this.selectForEdit();if(a!==this)return this.userDestroy.call(a);if(this.nextBlock())this.userDestroyJustThis();else{a=this.parentThatIsA(IDE_Morph);var b=this.parentThatIsA(SyntaxElementMorph),c=this.parentThatIsA(CSlotMorph);this.prepareToBeGrabbed();a?a.removeBlock(this):this.destroy();c&&c.fixLayout();b&&b.reactToGrabOf(this)}}; CommandBlockMorph.prototype.userDestroyJustThis=function(){var a=this.parentThatIsA(ScriptsMorph),b=this.parentThatIsA(IDE_Morph),c=this.parentThatIsA(CommandSlotMorph,RingReporterSlotMorph),d,e=this.nextBlock(),f=this.parentThatIsA(SyntaxElementMorph),g=this.parentThatIsA(CSlotMorph,RingReporterSlotMorph);this.topBlock().fullChanged();this.parent&&(d=this.parent.parentThatIsA(CommandBlockMorph));if(d&&d.nextBlock()===this)var h=d;else c&&c.nestedBlock()===this&&(h=c,this.prepareToBeGrabbed());b? b.removeBlock(this,!0):this.destroy(!0);e?h instanceof CommandSlotMorph||h instanceof RingReporterSlotMorph?h.nestedBlock(e):h instanceof CommandBlockMorph?h.nextBlock(e):a.add(e):g&&g.fixLayout();f&&f.reactToGrabOf(this)}; CommandBlockMorph.prototype.outlinePath=function(a,b){var c=2*this.corner+this.inset,d=this.height()-this.corner,e=this.height()-2*this.corner,f=Math.max(this.corner-b,0),g=this.position();a.arc(this.corner,this.corner,f,radians(-180),radians(-90),!1);a.lineTo(this.corner+this.inset,b);a.lineTo(c,this.corner+b);a.lineTo(c+this.dent,this.corner+b);a.lineTo(3*this.corner+this.inset+this.dent,b);a.lineTo(this.width()-this.corner,b);a.arc(this.width()-this.corner,this.corner,f,radians(-90),radians(-0), -!1);this.cSlots().forEach(function(h){h.outlinePath(a,b,h.position().subtract(g))});a.arc(this.width()-this.corner,e,f,radians(0),radians(90),!1);this.isStop()||(a.lineTo(this.width()-this.corner,d-b),a.lineTo(3*this.corner+this.inset+this.dent,d-b),a.lineTo(c+this.dent,d+this.corner-b),a.lineTo(c,d+this.corner-b),a.lineTo(this.corner+this.inset,d-b));a.arc(this.corner,e,f,radians(90),radians(180),!1)}; +!1);this.cSlots().forEach(h=>{h.outlinePath(a,b,h.position().subtract(g))});a.arc(this.width()-this.corner,e,f,radians(0),radians(90),!1);this.isStop()||(a.lineTo(this.width()-this.corner,d-b),a.lineTo(3*this.corner+this.inset+this.dent,d-b),a.lineTo(c+this.dent,d+this.corner-b),a.lineTo(c,d+this.corner-b),a.lineTo(this.corner+this.inset,d-b));a.arc(this.corner,e,f,radians(90),radians(180),!1)}; CommandBlockMorph.prototype.drawEdges=function(a){this.drawTopDentEdge(a,0,0);this.drawBottomDentEdge(a,0,this.height()-this.corner);this.drawLeftEdge(a);this.drawRightEdge(a);this.drawTopLeftEdge(a);this.drawBottomRightEdge(a)}; CommandBlockMorph.prototype.drawTopDentEdge=function(a,b,c){var d=.5*this.edge,e=b+2*this.corner+this.inset;a.lineWidth=this.edge;a.lineJoin="round";a.lineCap="round";var f=a.createLinearGradient(0,c,0,c+this.edge);f.addColorStop(0,this.cachedClrBright);f.addColorStop(1,this.cachedClr);a.strokeStyle=f;a.beginPath();a.moveTo(this.corner,c+d);a.lineTo(b+this.corner+this.inset,c+d);a.stroke();a.strokeStyle=f;a.beginPath();a.moveTo(b+3*this.corner+this.inset+this.dent+d,c+d);a.lineTo(this.width()-this.corner, c+d);a.stroke();f=b+this.corner+this.inset;f=a.createLinearGradient(f-this.edge,c+this.edge,f,c);f.addColorStop(0,this.cachedClr);f.addColorStop(1,this.cachedClrBright);a.strokeStyle=f;a.beginPath();a.moveTo(b+this.corner+this.inset,c+d);a.lineTo(e,c+this.corner+d);a.stroke();b=a.createLinearGradient(0,c+this.corner,0,c+this.corner+this.edge);b.addColorStop(0,this.cachedClrBright);b.addColorStop(1,this.cachedClr);a.strokeStyle=b;a.beginPath();a.moveTo(e,c+this.corner+d);a.lineTo(e+this.dent,c+this.corner+ @@ -888,7 +825,7 @@ CommandBlockMorph.prototype.drawBottomDentEdge=function(a,b,c){var d=.5*this.edg this.corner-this.edge,0,c+this.corner);g.addColorStop(0,this.cachedClr);g.addColorStop(1,this.cachedClrDark);a.strokeStyle=g;a.beginPath();a.moveTo(e+d,c+this.corner-d);a.lineTo(e+this.dent,c+this.corner-d);a.stroke();g=a.createLinearGradient(b+e+this.dent-this.edge,c+this.corner-this.edge,b+e+this.dent,c+this.corner);g.addColorStop(0,this.cachedClr);g.addColorStop(1,this.cachedClrDark);a.strokeStyle=g;a.beginPath();a.moveTo(b+e+this.dent,c+this.corner-d);a.lineTo(b+3*this.corner+this.inset+this.dent, c-d);a.stroke();a.strokeStyle=f;a.beginPath();a.moveTo(b+3*this.corner+this.inset+this.dent,c-d);a.lineTo(this.width()-this.corner,c-d);a.stroke()};CommandBlockMorph.prototype.drawFlatBottomDentEdge=function(a){this.isStop()||(a.fillStyle=this.color.darker(this.contrast/2).toString(),a.beginPath(),this.drawDent(a,0,this.height()-this.corner),a.closePath(),a.fill())}; CommandBlockMorph.prototype.drawLeftEdge=function(a){var b=.5*this.edge,c=a.createLinearGradient(0,0,this.edge,0);c.addColorStop(0,this.cachedClrBright);c.addColorStop(1,this.cachedClr);a.lineWidth=this.edge;a.lineJoin="round";a.lineCap="round";a.strokeStyle=c;a.beginPath();a.moveTo(b,this.corner);a.lineTo(b,this.height()-2*this.corner-b);a.stroke()}; -CommandBlockMorph.prototype.drawRightEdge=function(a){var b=.5*this.edge,c=this.cSlots(),d=this.top(),e=this.width(),f;var g=a.createLinearGradient(e-this.edge,0,e,0);g.addColorStop(0,this.cachedClr);g.addColorStop(1,this.cachedClrDark);a.lineWidth=this.edge;a.lineJoin="round";a.lineCap="round";a.strokeStyle=g;c.length?(a.beginPath(),a.moveTo(e-b,this.corner+b),c.forEach(function(h){f=h.top()-d;a.lineTo(e-b,f);a.stroke();a.beginPath();a.moveTo(e-b,f+h.height())})):(a.beginPath(),a.moveTo(e-b,this.corner+ +CommandBlockMorph.prototype.drawRightEdge=function(a){var b=.5*this.edge,c=this.cSlots(),d=this.top(),e=this.width(),f;var g=a.createLinearGradient(e-this.edge,0,e,0);g.addColorStop(0,this.cachedClr);g.addColorStop(1,this.cachedClrDark);a.lineWidth=this.edge;a.lineJoin="round";a.lineCap="round";a.strokeStyle=g;c.length?(a.beginPath(),a.moveTo(e-b,this.corner+b),c.forEach(h=>{f=h.top()-d;a.lineTo(e-b,f);a.stroke();a.beginPath();a.moveTo(e-b,f+h.height())})):(a.beginPath(),a.moveTo(e-b,this.corner+ b));a.lineTo(e-b,this.height()-2*this.corner);a.stroke()};CommandBlockMorph.prototype.drawTopLeftEdge=function(a){var b=.5*this.edge;var c=a.createRadialGradient(this.corner,this.corner,this.corner,this.corner,this.corner,this.corner-this.edge);c.addColorStop(0,this.cachedClrBright);c.addColorStop(1,this.cachedClr);a.lineWidth=this.edge;a.lineJoin="round";a.lineCap="round";a.strokeStyle=c;a.beginPath();a.arc(this.corner,this.corner,this.corner-b,radians(-180),radians(-90),!1);a.stroke()}; CommandBlockMorph.prototype.drawBottomRightEdge=function(a){var b=.5*this.edge,c=this.width()-this.corner,d=this.height()-2*this.corner;var e=a.createRadialGradient(c,d,this.corner,c,d,this.corner-this.edge);e.addColorStop(0,this.cachedClrDark);e.addColorStop(1,this.cachedClr);a.lineWidth=this.edge;a.lineJoin="round";a.lineCap="round";a.strokeStyle=e;a.beginPath();a.arc(c,d,this.corner-b,radians(90),radians(0),!0);a.stroke()};HatBlockMorph.prototype=new CommandBlockMorph; HatBlockMorph.prototype.constructor=HatBlockMorph;HatBlockMorph.uber=CommandBlockMorph.prototype;function HatBlockMorph(){this.init()}HatBlockMorph.prototype.init=function(){HatBlockMorph.uber.init.call(this);this.bounds.setExtent((new Point(120,36)).multiplyBy(this.scale));this.fixLayout();this.rerender()};HatBlockMorph.prototype.readout=function(){return detect(this.children,function(a){return a instanceof SpeechBubbleMorph})}; @@ -905,30 +842,29 @@ ReporterBlockMorph.prototype.init=function(a){ReporterBlockMorph.uber.init.call( ReporterBlockMorph.prototype.snap=function(a){var b=this.parent,c;this.cachedSlotSpec=null;if(!(b instanceof ScriptsMorph))return null;null!==a&&(a instanceof CommandSlotMorph&&(c=a.nestedBlock())&&(c=c.fullCopy(),b.add(c),c.moveBy(c.extent()),c.fixBlockColor()),a.parent.replaceInput(a,this),this.snapSound&&this.snapSound.play());this.fixBlockColor();ReporterBlockMorph.uber.snap.call(this)}; ReporterBlockMorph.prototype.prepareToBeGrabbed=function(a){var b=this.position();if(this.parent instanceof BlockMorph||this.parent instanceof MultiArgMorph||this.parent instanceof ReporterSlotMorph)this.parent.revertToDefaultInput(this),this.setPosition(b);ReporterBlockMorph.uber.prepareToBeGrabbed.call(this,a);a&&(a.alpha=1>this.alpha?1:.85);this.cachedSlotSpec=null};ReporterBlockMorph.prototype.blockSequence=function(){return this}; ReporterBlockMorph.prototype.isUnevaluated=function(){var a=this.getSlotSpec();return"%anyUE"===a||"%boolUE"===a||"%f"===a};ReporterBlockMorph.prototype.isLocked=function(){return this.isStatic||"%t"===this.getSlotSpec()};ReporterBlockMorph.prototype.getSlotSpec=function(){this.cachedSlotSpec||(this.cachedSlotSpec=this.determineSlotSpec());return this.cachedSlotSpec}; -ReporterBlockMorph.prototype.determineSlotSpec=function(){if(this.parent instanceof BlockMorph){var a=this.parent.parts().filter(function(b){return!(b instanceof BlockHighlightMorph)});a=a.indexOf(this);if(-1!==a&&this.parent.blockSpec)return this.parseSpec(this.parent.blockSpec)[a]}return this.parent instanceof MultiArgMorph?this.parent.slotSpec:this.parent instanceof TemplateSlotMorph?this.parent.getSpec():null}; -ReporterBlockMorph.prototype.mouseClickLeft=function(a){if(this.parent instanceof BlockInputFragmentMorph)return this.parent.mouseClickLeft();if(this.parent instanceof TemplateSlotMorph){var b=this.parent.parent.parent;a=this.parent.parent&&this.parent.parent.parent&&this.parent.parent.parent instanceof RingMorph?"Input name":"%blockVars"===this.parent.parent.elementSpec?"Block variable name":"Script variable name";(new DialogBoxMorph(this,function(c){b.id?SnapActions.setBlockSpec(this,c):this.userSetSpec(c)}, +ReporterBlockMorph.prototype.determineSlotSpec=function(){if(this.parent instanceof BlockMorph){var a=this.parent.parts().filter(b=>!(b instanceof BlockHighlightMorph));a=a.indexOf(this);if(-1!==a&&this.parent.blockSpec)return this.parseSpec(this.parent.blockSpec)[a]}return this.parent instanceof MultiArgMorph?this.parent.slotSpec:this.parent instanceof TemplateSlotMorph?this.parent.getSpec():null}; +ReporterBlockMorph.prototype.mouseClickLeft=function(a){if(this.parent instanceof BlockInputFragmentMorph)return this.parent.mouseClickLeft();if(this.parent instanceof TemplateSlotMorph){const b=this.parent.parent.parent;a=this.parent.parent&&this.parent.parent.parent&&this.parent.parent.parent instanceof RingMorph?"Input name":"%blockVars"===this.parent.parent.elementSpec?"Block variable name":"Script variable name";(new DialogBoxMorph(this,function(c){b.id?SnapActions.setBlockSpec(this,c):this.userSetSpec(c)}, this)).prompt(a,this.blockSpec,this.world())}else ReporterBlockMorph.uber.mouseClickLeft.call(this,a)};ReporterBlockMorph.prototype.exportResultPic=function(){var a=this.topBlock(),b=a.scriptTarget(),c;a===this&&b&&(c=b.parentThatIsA(StageMorph))&&(c.threads.stopProcess(a),c.threads.startProcess(a,b,!1,!0))}; ReporterBlockMorph.prototype.userDestroy=function(){var a=this.selectForEdit();if(a!==this)return this.userDestroy.call(a);a=this.world();if(a)var b=a.hand;this.topBlock().fullChanged();this.prepareToBeGrabbed(b);this.destroy()};ReporterBlockMorph.prototype.outlinePath=function(a,b){this.isPredicate?this.outlinePathDiamond(a,b):this.outlinePathOval(a,b)}; -ReporterBlockMorph.prototype.outlinePathOval=function(a,b){var c=this.height(),d=Math.min(this.rounding,c/2),e=Math.max(d-b,0),f=this.width(),g=this.position();a.arc(d,d,e,radians(-180),radians(-90),!1);a.arc(f-d,d,e,radians(-90),radians(-0),!1);this.cSlots().forEach(function(h){h.outlinePath(a,b,h.position().subtract(g))});a.arc(f-d,c-d,e,radians(0),radians(90),!1);a.arc(d,c-d,e,radians(90),radians(180),!1);a.lineTo(d-e,d)}; -ReporterBlockMorph.prototype.outlinePathDiamond=function(a,b){var c=this.width(),d=this.height(),e=Math.floor(d/2),f=this.rounding,g=c-f,h=this.position(),k=this.cSlots();a.moveTo(b,e);a.lineTo(f,b);a.lineTo(g-b,b);k.length?this.cSlots().forEach(function(l){l.outlinePath(a,b,l.position().subtract(h))}):a.lineTo(c-b,e);a.lineTo(g-b,d-b);a.lineTo(f,d-b)};ReporterBlockMorph.prototype.drawEdges=function(a){this.isPredicate?this.drawEdgesDiamond(a):this.drawEdgesOval(a)}; +ReporterBlockMorph.prototype.outlinePathOval=function(a,b){var c=this.height(),d=Math.min(this.rounding,c/2),e=Math.max(d-b,0),f=this.width(),g=this.position();a.arc(d,d,e,radians(-180),radians(-90),!1);a.arc(f-d,d,e,radians(-90),radians(-0),!1);this.cSlots().forEach(h=>{h.outlinePath(a,b,h.position().subtract(g))});a.arc(f-d,c-d,e,radians(0),radians(90),!1);a.arc(d,c-d,e,radians(90),radians(180),!1);a.lineTo(d-e,d)}; +ReporterBlockMorph.prototype.outlinePathDiamond=function(a,b){var c=this.width(),d=this.height(),e=Math.floor(d/2),f=this.rounding,g=c-f,h=this.position(),k=this.cSlots();a.moveTo(b,e);a.lineTo(f,b);a.lineTo(g-b,b);k.length?this.cSlots().forEach(l=>{l.outlinePath(a,b,l.position().subtract(h))}):a.lineTo(c-b,e);a.lineTo(g-b,d-b);a.lineTo(f,d-b)};ReporterBlockMorph.prototype.drawEdges=function(a){this.isPredicate?this.drawEdgesDiamond(a):this.drawEdgesOval(a)}; ReporterBlockMorph.prototype.drawEdgesOval=function(a){var b=this.height(),c=Math.max(Math.min(this.rounding,b/2),this.edge),d=this.width(),e=this.edge/2,f,g=this.top(),h=this.cSlots();a.lineWidth=this.edge;a.lineJoin="round";a.lineCap="round";var k=a.createRadialGradient(c,b-c,c-this.edge,c,b-c,c+this.edge);k.addColorStop(0,this.cachedClr);k.addColorStop(1,this.cachedClrBright);a.strokeStyle=k;a.beginPath();a.arc(c,b-c,c-e,radians(90),radians(180),!1);a.stroke();k=a.createRadialGradient(d-c,c,c- this.edge,d-c,c,c+this.edge);k.addColorStop(0,this.cachedClr);k.addColorStop(1,this.cachedClrDark);a.strokeStyle=k;a.beginPath();a.arc(d-c,c,c-e,radians(-90),radians(0),!1);a.stroke();k=a.createLinearGradient(0,0,0,this.edge);k.addColorStop(0,this.cachedClrBright);k.addColorStop(1,this.cachedClr);a.strokeStyle=k;a.beginPath();a.moveTo(c-e,e);a.lineTo(d-c+e,e);a.stroke();k=a.createRadialGradient(c,c,c-this.edge,c,c,c);k.addColorStop(0,this.cachedClr);k.addColorStop(1,this.cachedClrBright);a.strokeStyle= k;a.beginPath();a.arc(c,c,c-e,radians(180),radians(270),!1);a.stroke();k=a.createRadialGradient(d-c,b-c,c-this.edge,d-c,b-c,c);k.addColorStop(0,this.cachedClr);k.addColorStop(1,this.cachedClrDark);a.strokeStyle=k;a.beginPath();a.arc(d-c,b-c,c-e,radians(0),radians(90),!1);a.stroke();k=a.createLinearGradient(0,b-this.edge,0,b);k.addColorStop(0,this.cachedClr);k.addColorStop(1,this.cachedClrDark);a.strokeStyle=k;a.beginPath();a.moveTo(c-e,b-e);a.lineTo(d-c+e,b-e);a.stroke();k=a.createLinearGradient(0, -0,this.edge,0);k.addColorStop(0,this.cachedClrBright);k.addColorStop(1,this.cachedClr);a.strokeStyle=k;a.beginPath();a.moveTo(e,c);a.lineTo(e,b-c);a.stroke();k=a.createLinearGradient(d-this.edge,0,d,0);k.addColorStop(0,this.cachedClr);k.addColorStop(1,this.cachedClrDark);a.strokeStyle=k;h.length?(a.beginPath(),a.moveTo(d-e,c+e),h.forEach(function(l){f=l.top()-g;a.lineTo(d-e,f);a.stroke();a.beginPath();a.moveTo(d-e,f+l.height())})):(a.beginPath(),a.moveTo(d-e,c+e));a.lineTo(d-e,b-c);a.stroke()}; +0,this.edge,0);k.addColorStop(0,this.cachedClrBright);k.addColorStop(1,this.cachedClr);a.strokeStyle=k;a.beginPath();a.moveTo(e,c);a.lineTo(e,b-c);a.stroke();k=a.createLinearGradient(d-this.edge,0,d,0);k.addColorStop(0,this.cachedClr);k.addColorStop(1,this.cachedClrDark);a.strokeStyle=k;h.length?(a.beginPath(),a.moveTo(d-e,c+e),h.forEach(l=>{f=l.top()-g;a.lineTo(d-e,f);a.stroke();a.beginPath();a.moveTo(d-e,f+l.height())})):(a.beginPath(),a.moveTo(d-e,c+e));a.lineTo(d-e,b-c);a.stroke()}; ReporterBlockMorph.prototype.drawEdgesDiamond=function(a){var b=this.width(),c=this.height(),d=Math.floor(c/2),e=this.rounding,f=this.edge/2,g=this.cSlots(),h=this.top(),k;a.lineWidth=this.edge;a.lineJoin="round";a.lineCap="round";var l=a.createLinearGradient(-e,0,e,0);l.addColorStop(1,this.cachedClr);l.addColorStop(0,this.cachedClrBright);a.strokeStyle=l;a.beginPath();a.moveTo(f,d);a.lineTo(e,c-f);a.closePath();a.stroke();l=a.createLinearGradient(0,0,e,0);l.addColorStop(0,this.cachedClrBright);l.addColorStop(1, this.cachedClr);a.strokeStyle=l;a.beginPath();a.moveTo(f,d);a.lineTo(e,f);a.closePath();a.stroke();l=a.createLinearGradient(0,0,0,this.edge);l.addColorStop(0,this.cachedClrBright);l.addColorStop(1,this.cachedClr);a.strokeStyle=l;a.beginPath();a.moveTo(e,f);g.length?(a.lineTo(b-e-f,f),a.closePath(),a.stroke(),l=a.createLinearGradient(b-e-this.edge,0,b-e,0),l.addColorStop(0,this.cachedClr),l.addColorStop(1,this.cachedClrDark),a.lineWidth=this.edge,a.lineJoin="round",a.lineCap="round",a.strokeStyle= -l,a.beginPath(),a.moveTo(b-e-f,this.edge+f),g.forEach(function(m){k=m.top()-h;a.lineTo(b-e-f,k);a.stroke();a.beginPath();a.moveTo(b-e-f,k+m.height())}),a.lineTo(b-e-f,c-f)):(a.lineTo(b-e,f),a.closePath(),a.stroke(),l=a.createLinearGradient(b-e,0,b+e,0),l.addColorStop(0,this.cachedClr),l.addColorStop(1,this.cachedClrDark),a.strokeStyle=l,a.beginPath(),a.moveTo(b-f,d),a.lineTo(b-e,f),a.closePath(),a.stroke(),l=a.createLinearGradient(b-e,0,b,0),l.addColorStop(0,this.cachedClr),l.addColorStop(1,this.cachedClrDark), +l,a.beginPath(),a.moveTo(b-e-f,this.edge+f),g.forEach(m=>{k=m.top()-h;a.lineTo(b-e-f,k);a.stroke();a.beginPath();a.moveTo(b-e-f,k+m.height())}),a.lineTo(b-e-f,c-f)):(a.lineTo(b-e,f),a.closePath(),a.stroke(),l=a.createLinearGradient(b-e,0,b+e,0),l.addColorStop(0,this.cachedClr),l.addColorStop(1,this.cachedClrDark),a.strokeStyle=l,a.beginPath(),a.moveTo(b-f,d),a.lineTo(b-e,f),a.closePath(),a.stroke(),l=a.createLinearGradient(b-e,0,b,0),l.addColorStop(0,this.cachedClr),l.addColorStop(1,this.cachedClrDark), a.strokeStyle=l,a.beginPath(),a.moveTo(b-e,c-f),a.lineTo(b-f,d),a.closePath());a.stroke();l=a.createLinearGradient(0,c-this.edge,0,c);l.addColorStop(0,this.cachedClr);l.addColorStop(1,this.cachedClrDark);a.strokeStyle=l;a.beginPath();a.moveTo(e+f,c-f);a.lineTo(b-e-f,c-f);a.closePath();a.stroke()};RingMorph.prototype=new ReporterBlockMorph;RingMorph.prototype.constructor=RingMorph;RingMorph.uber=ReporterBlockMorph.prototype;RingMorph.prototype.isCachingInputs=!1;function RingMorph(){this.init()} RingMorph.prototype.init=function(){RingMorph.uber.init.call(this);this.category="other";this.contrast=RingMorph.prototype.contrast;this.setExtent(new Point(200,80))}; RingMorph.prototype.render=function(a){var b=this.inputs()[0],c=this.position();this.cachedClr=this.color.toString();this.cachedClrBright=this.bright();this.cachedClrDark=this.dark();MorphicPreferences.isFlat?(a.fillStyle=this.cachedClrDark,a.beginPath(),this.outlinePath(a,0),b.outlinePath(a,b.position().subtract(c)),a.clip("evenodd"),a.fillRect(0,0,this.width(),this.height()),a.fillStyle=this.cachedClr,a.beginPath(),this.outlinePath(a,this.flatEdge),b.outlinePath(a,b.position().subtract(c)),a.clip("evenodd"), a.fillRect(0,0,this.width(),this.height())):(a.fillStyle=this.cachedClr,a.beginPath(),this.outlinePath(a,0),b.outlinePath(a,b.position().subtract(c)),a.clip("evenodd"),a.fillRect(0,0,this.width(),this.height()),this.drawEdges(a))};RingMorph.prototype.rootForGrab=function(){return this.isDraggable?this:BlockMorph.uber.rootForGrab.call(this)}; RingMorph.prototype.embed=function(a,b,c){this.color=SpriteMorph.prototype.blockColor.other;this.isDraggable=!0;if(a instanceof CommandBlockMorph){this.isStatic=!1;this.setSpec("%rc %ringparms");this.selector="reifyScript";var d=this.parts()[0];d.nestedBlock(a)}else a.isPredicate?(this.isStatic=!0,this.setSpec("%rp %ringparms"),this.selector="reifyPredicate",d=this.parts()[0],d.replaceInput(d.contents(),a)):a instanceof BooleanSlotMorph?(this.isStatic=!1,this.setSpec("%rp %ringparms"),this.selector= -"reifyPredicate",d=this.parts()[0],d.replaceInput(d.contents(),a)):(this.isStatic=!1,this.setSpec("%rr %ringparms"),this.selector="reifyReporter",d=this.parts()[0],d.replaceInput(d.contents(),a,c));d=this.parts()[1];b&&b.forEach(function(e){return d.addInput(e)});this.fixBlockColor(null,!0)}; +"reifyPredicate",d=this.parts()[0],d.replaceInput(d.contents(),a)):(this.isStatic=!1,this.setSpec("%rr %ringparms"),this.selector="reifyReporter",d=this.parts()[0],d.replaceInput(d.contents(),a,c));d=this.parts()[1];b&&b.forEach(e=>d.addInput(e));this.fixBlockColor(null,!0)}; RingMorph.prototype.vanishForSimilar=function(){var a=this.parts()[0].nestedBlock();if(!(a&&this.parent instanceof SyntaxElementMorph)||this.parent instanceof RingReporterSlotMorph||this.parent instanceof RingCommandSlotMorph)return null;("reportGetVar"===a.selector&&!contains(this.inputNames(),a.blockSpec)||"reportJSFunction"===a.selector||"reportAttributeOf"===a.selector||"reportCompiled"===a.selector||a instanceof RingMorph)&&this.parent.replaceInput(this,a)};RingMorph.prototype.contents=function(){return this.parts()[0].nestedBlock()}; RingMorph.prototype.inputNames=function(){return this.parts()[1].evaluate()};RingMorph.prototype.dataType=function(){switch(this.selector){case "reifyScript":return"command";case "reifyPredicate":return"predicate";default:return"reporter"}};RingMorph.prototype.fixBlockColor=function(a,b){var c=this.parts()[0];RingMorph.uber.fixBlockColor.call(this,a,b);c.fixLayout()};ScriptsMorph.prototype=new FrameMorph;ScriptsMorph.prototype.constructor=ScriptsMorph;ScriptsMorph.prototype.undoCategory="scripts"; ScriptsMorph.uber=FrameMorph.prototype;ScriptsMorph.prototype.cleanUpMargin=20;ScriptsMorph.prototype.cleanUpSpacing=15;ScriptsMorph.prototype.isPreferringEmptySlots=!0;ScriptsMorph.prototype.enableKeyboard=!0;ScriptsMorph.prototype.enableNestedAutoWrapping=!0;ScriptsMorph.prototype.feedbackColor=WHITE;function ScriptsMorph(){this.init()} -ScriptsMorph.prototype.init=function(){this.feedbackMorph=new BoxMorph;this.rejectsHats=!1;this.focus=null;ScriptsMorph.uber.init.call(this);this.setColor(new Color(70,70,70))}; -ScriptsMorph.prototype.fullCopy=function(){var a=new ScriptsMorph,b=this.position(),c;this.focus&&this.focus.stopEditing();this.children.forEach(function(d){d.block||(c=d.fullCopy(),a.add(c),c.setPosition(d.position().subtract(b)),c instanceof BlockMorph&&c.allComments().forEach(function(e){return e.align(c)}))});a.adjustBounds();return a}; +ScriptsMorph.prototype.init=function(){this.feedbackMorph=new BoxMorph;this.rejectsHats=!1;this.focus=null;ScriptsMorph.uber.init.call(this);this.setColor(new Color(70,70,70))};ScriptsMorph.prototype.fullCopy=function(){var a=new ScriptsMorph,b=this.position(),c;this.focus&&this.focus.stopEditing();this.children.forEach(d=>{d.block||(c=d.fullCopy(),a.add(c),c.setPosition(d.position().subtract(b)),c instanceof BlockMorph&&c.allComments().forEach(e=>e.align(c)))});a.adjustBounds();return a}; ScriptsMorph.prototype.render=function(a){a.fillStyle=this.getRenderColor().toString();a.fillRect(0,0,this.width(),this.height());this.cachedTexture?this.renderCachedTexture(a):this.texture&&this.renderTexture(this.texture,a)};ScriptsMorph.prototype.getRenderColor=function(){return MorphicPreferences.isFlat||.85k instanceof BlockMorph&&k.fullBounds().intersects(d)),f=a.allInputs();var g=[];e.forEach(k=>g=g.concat(k.allInputs()));if(0===g.length)return null;if(this.isPreferringEmptySlots){if(b){var h=b.position();if(e=detect(g,k=>(k instanceof InputSlotMorph||k instanceof ArgMorph&& +!(k instanceof CommandSlotMorph)&&!(k instanceof MultiArgMorph)||k instanceof RingMorph&&!k.contents()||k.isEmptySlot())&&!k.isLocked()&&k.bounds.containsPoint(h)&&!contains(f,k)))return e}if(e=detect(g,k=>(k instanceof InputSlotMorph||k instanceof ArgMorph||k instanceof RingMorph&&!k.contents()||k.isEmptySlot())&&!k.isLocked()&&k.bounds.intersects(d)&&!contains(f,k)&&c(k,h)))return e}return b&&(h=b.position(),e=detect(g,k=>k!==a&&!k.isLocked()&&k.bounds.containsPoint(h)&&!(k.parent instanceof PrototypeHatBlockMorph)&& +!contains(f,k)&&c(k,h)))?e:detect(g,k=>k!==a&&!k.isLocked()&&k.fullBounds().intersects(d)&&!(k.parent instanceof PrototypeHatBlockMorph)&&!contains(f,k)&&c(k))}; +ScriptsMorph.prototype.closestBlock=function(a,b){var c=a.bounds;a=this.children.filter(f=>f instanceof BlockMorph&&f.fullBounds().intersects(c));var d=[];a.forEach(f=>{d=d.concat(f.allChildren().slice(0).reverse().filter(g=>g instanceof BlockMorph&&!g.isTemplate))});if(0===d.length)return null;if(b){var e=b.position();if(b=detect(d,f=>!f.comment&&!f.isPrototype&&f.bounds.containsPoint(e)))return b}return detect(d,f=>!f.comment&&!f.isPrototype&&f.bounds.intersects(c))}; +ScriptsMorph.prototype.userMenu=function(){function a(f,g,h,k,l){b.addItem([h?new SymbolMorph("checkedBox",.75*MorphicPreferences.menuFontSize):new SymbolMorph("rectangle",.75*MorphicPreferences.menuFontSize),localize(f)],g,h?k:l)}var b=new MenuMorph(this),c=this.parentThatIsA(IDE_Morph),d,e=this.scriptTarget();c||(d=this.parentThatIsA(BlockEditorMorph))&&(c=d.target.parentThatIsA(IDE_Morph));SnapUndo.canUndo(e)&&b.addItem([new SymbolMorph("turnBack",MorphicPreferences.menuFontSize),localize("undo")], +function(){SnapUndo.undo(e)},localize("undo the last edit"));SnapUndo.canRedo(e)&&b.addItem([new SymbolMorph("turnForward",MorphicPreferences.menuFontSize),localize("redo")],function(){SnapUndo.redo(e)},localize("redo the last edit"));(SnapUndo.canUndo(e)||SnapUndo.canRedo(e))&&b.addLine();b.addItem("clean up","cleanUp","arrange scripts\nvertically");b.addItem("add comment","addComment");b.addItem("scripts pic...","exportScriptsPicture","save a picture\nof all scripts");c&&(b.addLine(),!d&&e.exemplar&& +a("inherited",()=>e.toggleInheritanceForAttribute("scripts"),e.inheritsAttribute("scripts"),"uncheck to\ndisinherit",localize("check to inherit\nfrom")+" "+e.exemplar.name),b.addItem("make a block...",()=>(new BlockDialogMorph(null,f=>{""!==f.spec&&SnapActions.addCustomBlock(f,e).then(function(g){(new BlockEditorMorph(g,e)).popUp()})},this)).prompt("Make a block",null,this.world())));return b}; +ScriptsMorph.prototype.cleanUp=function(){var a=this.selectForEdit(),b=a.topLeft(),c=a.cleanUpMargin;a.children.sort((f,g)=>f instanceof PrototypeHatBlockMorph?0:f.top()-g.top());const d=this.children.map(function(f){return f.id}),e=this.children.map(function(f){if(!(f instanceof CommentMorph&&f.block))return point=b.add(new Point(a.cleanUpMargin,c)),c+=f.stackHeight()+a.cleanUpSpacing,point});SnapActions.setBlocksPositions(d,e);a.parent&&a.setPosition(a.parent.topLeft());a.adjustBounds()}; ScriptsMorph.prototype.exportScriptsPicture=function(){var a=this.scriptsPicture(),b=this.world().children[0];a&&b.saveCanvasAs(a,(b.projectName||localize("untitled"))+" "+localize("script pic"))}; -ScriptsMorph.prototype.scriptsPicture=function(){if(0!==this.children.length){var a=this.children[0].fullBounds();this.children.forEach(function(d){d.isVisible&&(a=a.merge(d.fullBounds()))});var b=newCanvas(a.extent());var c=b.getContext("2d");this.children.forEach(function(d){var e=d.fullBounds().origin;d.isVisible&&c.drawImage(d.fullImage(),e.x-a.origin.x,e.y-a.origin.y)});return b}}; -ScriptsMorph.prototype.addComment=function(){var a=this.parentThatIsA(IDE_Morph),b=this.parentThatIsA(BlockEditorMorph),c=this.world();(new CommentMorph).pickUp(c);!a&&b&&(a=b.target.parentThatIsA(IDE_Morph));a&&(c.hand.grabOrigin={origin:a.palette,position:a.palette.center()})};ScriptsMorph.prototype.undoOwnerId=function(){try{var a=this.parentThatIsA(BlockEditorMorph);return(a?a.definition:this.scriptTarget()).id+"/"+this.undoCategory}catch(b){return null}}; -ScriptsMorph.prototype.addToolbar=function(){var a=this,b=new AlignmentMorph,c=new Color(140,140,140);b.respectHiddens=!0;b.undoButton=new PushButtonMorph(this,function(){SnapUndo.undo(this.undoOwnerId())},new SymbolMorph("turnBack",12));b.undoButton.alpha=.2;b.undoButton.padding=4;b.undoButton.labelShadowColor=c;b.undoButton.edge=0;b.undoButton.fixLayout();b.add(b.undoButton);b.redoButton=new PushButtonMorph(this,function(){return SnapUndo.redo(a.undoOwnerId())},new SymbolMorph("turnForward",12)); -b.redoButton.alpha=.2;b.redoButton.padding=4;b.redoButton.labelShadowColor=c;b.redoButton.edge=0;b.redoButton.fixLayout();b.add(b.redoButton);b.keyboardButton=new ToggleButtonMorph(null,this,"toggleKeyboardEntry",[new SymbolMorph("keyboard",12),new SymbolMorph("keyboardFilled",12)],function(){return!isNil(a.focus)});b.keyboardButton.alpha=.2;b.keyboardButton.padding=4;b.keyboardButton.edge=0;b.keyboardButton.hint="use the keyboard\nto enter blocks";b.keyboardButton.labelShadowColor=c;b.keyboardButton.fixLayout(); -b.add(b.keyboardButton);return b}; +ScriptsMorph.prototype.scriptsPicture=function(){if(0!==this.children.length){var a=this.children[0].fullBounds();this.children.forEach(d=>{d.isVisible&&(a=a.merge(d.fullBounds()))});var b=newCanvas(a.extent());var c=b.getContext("2d");this.children.forEach(d=>{var e=d.fullBounds().origin;d.isVisible&&c.drawImage(d.fullImage(),e.x-a.origin.x,e.y-a.origin.y)});return b}}; +ScriptsMorph.prototype.addComment=function(){var a=this.parentThatIsA(IDE_Morph),b=this.parentThatIsA(BlockEditorMorph),c=this.world();(new CommentMorph).pickUp(c);!a&&b&&(a=b.target.parentThatIsA(IDE_Morph));a&&(c.hand.grabOrigin={origin:a.palette,position:a.palette.center()})};ScriptsMorph.prototype.undoOwnerId=function(){try{const a=this.parentThatIsA(BlockEditorMorph);return(a?a.definition:this.scriptTarget()).id+"/"+this.undoCategory}catch(a){return null}}; +ScriptsMorph.prototype.addToolbar=function(){var a=new AlignmentMorph,b=new Color(140,140,140);a.respectHiddens=!0;a.undoButton=new PushButtonMorph(this,function(){SnapUndo.undo(this.undoOwnerId())},new SymbolMorph("turnBack",12));a.undoButton.alpha=.2;a.undoButton.padding=4;a.undoButton.labelShadowColor=b;a.undoButton.edge=0;a.undoButton.fixLayout();a.add(a.undoButton);a.redoButton=new PushButtonMorph(this,()=>SnapUndo.redo(this.undoOwnerId()),new SymbolMorph("turnForward",12));a.redoButton.alpha= +.2;a.redoButton.padding=4;a.redoButton.labelShadowColor=b;a.redoButton.edge=0;a.redoButton.fixLayout();a.add(a.redoButton);a.keyboardButton=new ToggleButtonMorph(null,this,"toggleKeyboardEntry",[new SymbolMorph("keyboard",12),new SymbolMorph("keyboardFilled",12)],()=>!isNil(this.focus));a.keyboardButton.alpha=.2;a.keyboardButton.padding=4;a.keyboardButton.edge=0;a.keyboardButton.hint="use the keyboard\nto enter blocks";a.keyboardButton.labelShadowColor=b;a.keyboardButton.fixLayout();a.add(a.keyboardButton); +return a}; ScriptsMorph.prototype.updateToolbar=function(){var a=this.parentThatIsA(ScrollFrameMorph),b=!1;if(a){var c=this.undoOwnerId();a.toolBar||(a.toolBar=this.addToolbar(),a.add(a.toolBar),b=!0);this.enableKeyboard?(a.toolBar.keyboardButton.show(),a.toolBar.keyboardButton.refresh()):a.toolBar.keyboardButton.hide();c&&SnapUndo.canUndo(c)?a.toolBar.undoButton.isEnabled()||(a.toolBar.undoButton.enable(),b=!0):a.toolBar.undoButton.isEnabled()&&(a.toolBar.undoButton.disable(),b=!0);c&&SnapUndo.canRedo(c)?a.toolBar.redoButton.isEnabled()|| (a.toolBar.redoButton.enable(),a.toolBar.undoButton.mouseLeave(),b=!0):a.toolBar.redoButton.isEnabled()&&(a.toolBar.redoButton.disable(),b=!0);a.toolBar.undoButton.isVisible&&a.toolBar.redoButton.isVisible||(a.toolBar.undoButton.show(),a.toolBar.redoButton.show(),b=!0);if(b||!a.toolBar.isVisible)a.toolBar.isVisible=!0,a.toolBar.fixLayout();a.adjustToolBar()}};ScriptsMorph.prototype.hideToolbar=function(){var a=this.parentThatIsA(ScrollFrameMorph);a&&a.toolBar&&(a.toolBar.isVisible=!1,a.toolBar.changed())}; -ScriptsMorph.prototype.sortedElements=function(){var a=this.children.filter(function(b){return b instanceof CommentMorph?!b.block:!0});a.sort(function(b,c){return b instanceof PrototypeHatBlockMorph?0:b.top()-c.top()});return a};ScriptsMorph.prototype.fixMultiArgs=function(){this.forAllChildren(function(a){a instanceof MultiArgMorph&&a.fixLayout()})};ScriptsMorph.prototype.wantsDropOf=function(a){return a instanceof HatBlockMorph?!this.rejectsHats:a instanceof SyntaxElementMorph||a instanceof CommentMorph}; -ScriptsMorph.prototype.reactToDropOf=function(a,b){if(a instanceof BlockMorph||a instanceof CommentMorph){var c=a.snapTarget(b);c?this.moveBlock(a,c,b):a.id?b&&this.setBlockPosition(a,b):this.addBlock(a)}this.adjustBounds()}; +ScriptsMorph.prototype.sortedElements=function(){var a=this.children.filter(b=>b instanceof CommentMorph?!b.block:!0);a.sort((b,c)=>b instanceof PrototypeHatBlockMorph?0:b.top()-c.top());return a};ScriptsMorph.prototype.fixMultiArgs=function(){this.forAllChildren(a=>{a instanceof MultiArgMorph&&a.fixLayout()})};ScriptsMorph.prototype.wantsDropOf=function(a){return a instanceof HatBlockMorph?!this.rejectsHats:a instanceof SyntaxElementMorph||a instanceof CommentMorph}; +ScriptsMorph.prototype.reactToDropOf=function(a,b){if(a instanceof BlockMorph||a instanceof CommentMorph){const c=a.snapTarget(b);c?this.moveBlock(a,c,b):a.id?b&&this.setBlockPosition(a,b):this.addBlock(a)}this.adjustBounds()}; ScriptsMorph.prototype.moveBlock=function(a,b,c){var d=c&&c.grabOrigin.origin,e=d&&c.grabOrigin.position.add(d.position());if(d!==this&&d instanceof ScriptsMorph)return d=a.fullCopy(),SnapActions.isCollaborating()&&a.setPosition(e),d.id=null,c.grabOrigin.origin.add(a),SnapActions.moveBlock(d,b,e).then(function(){a.setPosition(e);return SnapActions.removeBlock(a)});e=d instanceof ScriptsMorph?e:null;SnapActions.moveBlock(a,b,e)}; -ScriptsMorph.prototype.addBlock=function(a){var b=this.parentThatIsA(BlockEditorMorph)||this.scriptTarget();SnapActions.addBlock(a,b,a.position());a.destroy()}; +ScriptsMorph.prototype.addBlock=function(a){const b=this.parentThatIsA(BlockEditorMorph)||this.scriptTarget();SnapActions.addBlock(a,b,a.position());a.destroy()}; ScriptsMorph.prototype.setBlockPosition=function(a,b){var c=a.position();var d=b.grabOrigin.position.add(b.grabOrigin.origin.position());var e=function(){a.setPosition(d)};if(b){b=b.grabOrigin.origin.parentThatIsA(ScriptsMorph);if(b!==this)return b.add(a),e=a.fullCopy(),b=this.parentThatIsA(BlockEditorMorph)||this.scriptTarget(),SnapActions.addBlock(e,b,c).then(function(){return SnapActions.removeBlock(a)});SnapActions.isReadOnly()&&e()}return SnapActions.setBlockPosition(a,c).catch(e)}; ScriptsMorph.prototype.mouseClickLeft=function(a){if(16===this.world().currentKey)return this.edit(a);this.focus&&this.focus.stopEditing();this.escalateEvent("mouseClickLeft",a)};ScriptsMorph.prototype.selectForEdit=function(){var a=this.parentThatIsA(IDE_Morph);return(a=a?a.currentSprite:null)&&a.inheritsAttribute("scripts")?(this.feedbackMorph.destroy(),a.shadowAttribute("scripts"),a.scripts):this}; ScriptsMorph.prototype.edit=function(a){var b=this.world();this.focus&&this.focus.stopEditing();b.stopEditing();if(ScriptsMorph.prototype.enableKeyboard){var c=this.selectForEdit();c.focus=new ScriptFocusMorph(c,c,a);c.focus.getFocus(b)}}; @@ -970,11 +905,10 @@ ArgMorph.prototype.reactToSliderEdit=function(){var a,b;if(this.executeOnSliderE ArgMorph.prototype.createIcon=function(){switch(this.type){case "list":this.icon=this.labelPart("%list");this.add(this.icon);break;case "object":this.icon=this.labelPart("%turtle");this.add(this.icon);break;default:nop()}};ArgMorph.prototype.fixLayout=function(){this.icon?(this.icon.setPosition(this.position()),this.bounds.setExtent(this.icon.extent())):ArgMorph.uber.fixLayout.call(this)}; ArgMorph.prototype.render=function(a){var b;if(this.icon){if(b=this.parentThatIsA(BlockMorph))this.icon.shadowColor=b.color.darker(this.labelContrast);switch(this.type){case "list":this.color=new Color(255,140,0);break;default:return}}ArgMorph.uber.render.call(this,a)};ArgMorph.prototype.isEmptySlot=function(){return null!==this.type};CommandSlotMorph.prototype=new ArgMorph;CommandSlotMorph.prototype.constructor=CommandSlotMorph;CommandSlotMorph.uber=ArgMorph.prototype; function CommandSlotMorph(){this.init()}CommandSlotMorph.prototype.init=function(){CommandSlotMorph.uber.init.call(this);this.color=new Color(0,17,173);this.setExtent(new Point(230,4*this.corner+this.cSlotPadding))};CommandSlotMorph.prototype.getSpec=function(){return"%cmd"};CommandSlotMorph.prototype.topBlock=function(){return this.parent.topBlock?this.parent.topBlock():this.nestedBlock()}; -CommandSlotMorph.prototype.nestedBlock=function(a){if(a){var b=this.nestedBlock();this.add(a);b&&a.bottomBlock().nextBlock(b);this.fixLayout()}else return detect(this.children,function(c){return c instanceof CommandBlockMorph})};CommandSlotMorph.prototype.slotAttachPoint=function(){return new Point(this.dentCenter(),this.top()+2*this.corner)};CommandSlotMorph.prototype.dentLeft=function(){return this.left()+this.corner+2*this.inset}; +CommandSlotMorph.prototype.nestedBlock=function(a){if(a){var b=this.nestedBlock();this.add(a);b&&a.bottomBlock().nextBlock(b);this.fixLayout()}else return detect(this.children,c=>c instanceof CommandBlockMorph)};CommandSlotMorph.prototype.slotAttachPoint=function(){return new Point(this.dentCenter(),this.top()+2*this.corner)};CommandSlotMorph.prototype.dentLeft=function(){return this.left()+this.corner+2*this.inset}; CommandSlotMorph.prototype.dentCenter=function(){return this.dentLeft()+this.corner+.5*this.dent};CommandSlotMorph.prototype.attachTargets=function(){var a=[];a.push({point:this.slotAttachPoint(),element:this,loc:"bottom",type:"slot"});return a}; CommandSlotMorph.prototype.fixLayout=function(){var a=this.nestedBlock();this.parent&&(this.color.eq(this.parent.color)||this.setColor(this.parent.color));a?(a.setPosition(new Point(this.left()+this.edge+this.rfBorder,this.top()+this.edge+this.rfBorder)),this.bounds.setWidth(a.fullBounds().width()+2*(this.edge+this.rfBorder)),this.bounds.setHeight(a.fullBounds().height()+this.edge+2*this.rfBorder-(this.corner-this.edge))):(this.bounds.setHeight(4*this.corner),this.bounds.setWidth(4*this.corner+this.inset+ -this.dent));this.parent&&this.parent.fixLayout&&this.parent.fixLayout()};CommandSlotMorph.prototype.evaluate=function(){return this.nestedBlock()};CommandSlotMorph.prototype.isEmptySlot=function(){return!this.isStatic&&null===this.nestedBlock()}; -CommandSlotMorph.prototype.attach=function(){var a=this,b=this.overlappedMorphs(),c=new MenuMorph(this,"choose new parent:");b.forEach(function(d){return c.addItem(d.toString().slice(0,50),function(){d.add(a);a.isDraggable=!1;d.fixLayout&&d.fixLayout()})});0b.addItem(c.toString().slice(0,50),()=>{c.add(this);this.isDraggable=!1;c.fixLayout&&c.fixLayout()}));0").split("\n"),c=this.nestedBlock(),d=(c?c.mappedCode(a):"").toString().split("\n"),e=RegExp("<#1>","g");b.forEach(function(f,g){var h="";0===f.trimLeft().indexOf("<#1>")&&(h=f.indexOf("<#1>"),h=f.slice(0,h));b[g]=f.replace(RegExp("<#1>"),d.join("\n"+h));b[g]=b[g].replace(e,d.join("\n"))});return b.join("\n")}; +CSlotMorph.prototype.mappedCode=function(a){var b=(StageMorph.prototype.codeMappings.reify||"<#1>").split("\n"),c=this.nestedBlock(),d=(c?c.mappedCode(a):"").toString().split("\n"),e=RegExp("<#1>","g");b.forEach((f,g)=>{var h="";0===f.trimLeft().indexOf("<#1>")&&(h=f.indexOf("<#1>"),h=f.slice(0,h));b[g]=f.replace(RegExp("<#1>"),d.join("\n"+h));b[g]=b[g].replace(e,d.join("\n"))});return b.join("\n")}; CSlotMorph.prototype.fixLayout=function(){var a=this.nestedBlock();a?(a.setPosition(new Point(this.left()+this.inset,this.top()+this.corner)),this.bounds.setHeight(a.fullBounds().height()+this.corner),this.bounds.setWidth(a.fullBounds().width()+2*this.cSlotPadding)):(this.bounds.setHeight(4*this.corner+this.cSlotPadding),this.bounds.setWidth(4*this.corner+2*this.inset+this.dent+2*this.cSlotPadding));this.parent&&this.parent.fixLayout&&this.parent.fixLayout()}; -CSlotMorph.prototype.fixLoopLayout=function(){var a;this.isLoop&&(a=this.loop())&&(a.setRight(this.right()-this.corner),a.setBottom(this.bottom()+this.cSlotPadding+this.edge))};CSlotMorph.prototype.loop=function(){return this.isLoop?detect(this.children,function(a){return a instanceof SymbolMorph}):null};CSlotMorph.prototype.fixHolesLayout=function(){this.holes=[new Rectangle(this.inset,this.corner,this.width(),this.height()-this.corner)]}; +CSlotMorph.prototype.fixLoopLayout=function(){var a;this.isLoop&&(a=this.loop())&&(a.setRight(this.right()-this.corner),a.setBottom(this.bottom()+this.cSlotPadding+this.edge))};CSlotMorph.prototype.loop=function(){return this.isLoop?detect(this.children,a=>a instanceof SymbolMorph):null};CSlotMorph.prototype.fixHolesLayout=function(){this.holes=[new Rectangle(this.inset,this.corner,this.width(),this.height()-this.corner)]}; CSlotMorph.prototype.isLocked=function(){return this.isStatic||this.parent instanceof MultiArgMorph};CSlotMorph.prototype.render=function(a){MorphicPreferences.isFlat||(this.cachedClr=this.color.toString(),this.cachedClrBright=this.bright(),this.cachedClrDark=this.dark(),a.fillStyle=this.cachedClr,this.drawTopRightEdge(a),this.drawTopEdge(a,this.inset,this.corner),this.drawTopLeftEdge(a),this.drawBottomEdge(a),this.drawRightEdge(a))}; CSlotMorph.prototype.outlinePath=function(a,b,c){var d=c.x;c=c.y;var e=Math.max(this.corner-b,0);a.lineTo(this.width()+d-b,c);a.arc(this.width()-this.corner+d,c,e,radians(90),radians(0),!0);a.lineTo(this.width()-this.corner+d,this.corner+c-b);a.lineTo(2*this.inset+3*this.corner+this.dent+d,this.corner+c-b);a.lineTo(2*this.inset+2*this.corner+this.dent+d,2*this.corner+c-b);a.lineTo(2*this.inset+2*this.corner+d,2*this.corner+c-b);a.lineTo(2*this.inset+this.corner+d,this.corner+c-b);a.lineTo(this.inset+ this.corner+d,this.corner+c-b);a.arc(this.inset+this.corner+d,2*this.corner+c,this.corner+b,radians(270),radians(180),!0);a.lineTo(this.inset+d-b,this.height()-2*this.corner+c);a.arc(this.inset+this.corner+d,this.height()-2*this.corner+c,this.corner+b,radians(180),radians(90),!0);a.lineTo(this.width()-this.corner+d,this.height()-this.corner+c+b);a.arc(this.width()-this.corner+d,this.height()+c,e,radians(-90),radians(-0),!1)}; @@ -1004,32 +938,31 @@ CSlotMorph.prototype.drawBottomEdge=function(a){var b=.5*this.edge;a.lineWidth=t c=a.createLinearGradient(0,this.height()-this.corner,0,this.height()-this.corner+this.edge);c.addColorStop(0,this.cachedClrBright);c.addColorStop(1,this.cachedClr);a.strokeStyle=c;a.beginPath();a.moveTo(this.inset+this.corner,this.height()-this.corner+b);a.lineTo(this.width()-this.corner,this.height()-this.corner+b);a.stroke()};InputSlotMorph.prototype=new ArgMorph;InputSlotMorph.prototype.constructor=InputSlotMorph;InputSlotMorph.uber=ArgMorph.prototype; function InputSlotMorph(a,b,c,d){this.init(a,b,c,d)} InputSlotMorph.prototype.init=function(a,b,c,d){var e=new InputSlotStringMorph(""),f=new ArrowMorph("down",0,Math.max(Math.floor(this.fontSize/6),1),BLACK,!0);e.fontSize=this.fontSize;e.isShowingBlanks=!0;this.selectedBlock=null;this.isUnevaluated=!1;this.choices=c||null;this.oldContentsExtent=e.extent();this.isNumeric=b||!1;this.isReadOnly=d||!1;this.minWidth=0;this.constant=null;InputSlotMorph.uber.init.call(this,null,!0);this.color=this.overrideWhite||WHITE;this.add(e);this.add(f);e.isEditable= -!0;e.isDraggable=!1;e.enableSelecting();this.setContents(a)};InputSlotMorph.prototype.getSpec=function(){return this.isNumeric?"%n":"%s"};InputSlotMorph.prototype.contents=function(){return detect(this.children,function(a){return a instanceof StringMorph})};InputSlotMorph.prototype.arrow=function(){return detect(this.children,function(a){return a instanceof ArrowMorph})};InputSlotMorph.prototype.getConstantDisplayName=function(a){return"serviceNames"===this.choices?a.split("/").pop():a}; +!0;e.isDraggable=!1;e.enableSelecting();this.setContents(a)};InputSlotMorph.prototype.getSpec=function(){return this.isNumeric?"%n":"%s"};InputSlotMorph.prototype.contents=function(){return detect(this.children,a=>a instanceof StringMorph)};InputSlotMorph.prototype.arrow=function(){return detect(this.children,a=>a instanceof ArrowMorph)};InputSlotMorph.prototype.getConstantDisplayName=function(a){return"serviceNames"===this.choices?a.split("/").pop():a}; InputSlotMorph.prototype.setContents=function(a){var b=this.contents(),c=a,d=c instanceof Array;this.selectedBlock&&(this.selectedBlock=null);if(d)c=localize(this.getConstantDisplayName(c[0])),b.isItalic=!this.isReadOnly;else if(c instanceof BlockMorph)this.selectedBlock=c,c="";else if(b.isItalic=!1,!isNil(this.choices)&&this.choices[c]instanceof Array)return this.setContents(this.choices[c]);b.text=c;isNil(c)?b.text="":c.toString&&(b.text=c.toString());this.isReadOnly&&!MorphicPreferences.isFlat&& -(b.shadowOffset=new Point(1,1));b.fixLayout();this.constant=d?a:null;this.lastValue=a;this.isReadOnly&&this.parent instanceof BlockMorph&&this.parent.fixLabelColor()};InputSlotMorph.prototype.userSetContents=function(a){this.selectForEdit().updateFieldValue(a)}; -InputSlotMorph.prototype.dropDownMenu=function(a){var b=this,c,d;return $jscomp.asyncExecutePromiseGeneratorProgram(function(e){if(1==e.nextAddress)return c=b.world().hand.position(),e.yield(b.menuFromDict(b.choices,null,a),2);d=e.yieldResult;if(!d)return e.return();0k.fullImage()}var f,g=this,h=new MenuMorph(this.userSetContents,null,this,this.fontSize);if(a instanceof Function)a=await a.call(this);else if(isString(a)&&(a=await this[a](c),!a))return;b||h.addItem(" ",null);for(f in a)Object.prototype.hasOwnProperty.call(a,f)&&("~"===f[0]?h.addLine():0===f.indexOf("\u00a7_def")?h.addItem(this.doWithAlpha(1,e(a[f])),a[f]):0=== +f.indexOf("\u00a7_dir")?(b=new DialMorph,b.rootForGrab=function(){return this},b.target=this,b.action=d,b.fillColor=this.parent.color,b.setRadius(3*this.fontSize),b.setValue(+this.evaluate(),!1,!0),h.addLine(),h.items.push(b),h.addLine()):0===f.indexOf("\u00a7_")?16===this.world().currentKey&&h.addItem(f.slice(2),a[f],null,null,null,!0,null,null,!(a[f]instanceof Array)&&"function"!==typeof a[f]):"__shout__go__"===f?(b=new SymbolMorph("flag"),b.size=1.5*this.fontSize,b.setColor(new Color(0,200,0)), +b.fixLayout(),h.addItem(b,["__shout__go__"])):a[f]instanceof Object&&!(a[f]instanceof Array)&&"function"!==typeof a[f]?h.addMenu(f,await this.menuFromDict(a[f],!0),null,!0):a[f]instanceof Array&&a[f][0]instanceof Object&&"function"!==typeof a[f][0]?h.addMenu(f,await this.menuFromDict(a[f][0],!0),null,!1):h.addItem(f,a[f],null,null,null,null,null,null,!(a[f]instanceof Array)&&"function"!==typeof a[f]));return h}; InputSlotMorph.prototype.messageTypesMenu=function(){for(var a=this.parentThatIsA(BlockMorph).scriptTarget().parentThatIsA(StageMorph).messageTypes.names(),b={},c=a.length;c--;)b[a[c]]=a[c];return b};InputSlotMorph.prototype.messageTypes=function(){for(var a=this.parentThatIsA(IDE_Morph).stage.messageTypes.names(),b={},c=a.length;c--;)b[a[c]]=a[c];return b}; InputSlotMorph.prototype.roleNames=function(){for(var a=this.root().children[0],b=a.room.getRoleNames(),c={},d=b.length;d--;)a.projectName!==b[d]&&(c[b[d]]=b[d]);c["others in room"]=["others in room"];c["everyone in room"]=["everyone in room"];return c};InputSlotMorph.prototype.getURL=function(a){try{return utils.getUrlSync(a)}catch(b){return""}}; InputSlotMorph.prototype.rpcActions=function(){var a=this.parent.inputs()[0],b={},c;a&&(c=a.evaluate());if(c)for(a=Object.keys(JSON.parse(this.getURL("/rpc/"+c))),c=a.length;c--;)b[a[c]]=a[c];return b}; -InputSlotMorph.prototype.messagesMenu=function(){var a=this,b={},c=this.parentThatIsA(BlockMorph).scriptTarget().parentThatIsA(StageMorph),d=[];c.children.concat(c).forEach(function(e){isSnapObject(e)&&(d=d.concat(e.allMessageNames()))});d.sort().forEach(function(e){return b[e]=e});16===this.world().currentKey&&(b.__shout__go__=["__shout__go__"]);0{isSnapObject(d)&&(c=c.concat(d.allMessageNames()))});c.sort().forEach(d=>a[d]=d);16===this.world().currentKey&&(a.__shout__go__=["__shout__go__"]);0(new DialogBoxMorph(this,this.updateFieldValue,this)).prompt("Message name",null,this.world());return a}; +InputSlotMorph.prototype.messagesReceivedMenu=function(){var a={"any message":["any message"]},b=this.parentThatIsA(BlockMorph).scriptTarget().parentThatIsA(StageMorph),c=[];b.children.concat(b).forEach(d=>{isSnapObject(d)&&(c=c.concat(d.allMessageNames()))});c.sort().forEach(d=>{"__shout__go__"!==d&&(a[d]=d)});a["~"]=null;a["new..."]=()=>(new DialogBoxMorph(this,this.updateFieldValue,this)).prompt("Message name",null,this.world());return a}; +InputSlotMorph.prototype.collidablesMenu=function(){var a={"mouse-pointer":["mouse-pointer"],edge:["edge"],"pen trails":["pen trails"]},b=this.parentThatIsA(BlockMorph).scriptTarget(),c=[];b.parentThatIsA(StageMorph).children.forEach(d=>{d instanceof SpriteMorph&&!d.isTemporary&&d.name!==b.name&&(c=c.concat(d.name))});0a[d]=d));return a}; +InputSlotMorph.prototype.locationMenu=function(){var a={"mouse-pointer":["mouse-pointer"],myself:["myself"]},b=this.parentThatIsA(BlockMorph).scriptTarget(),c=[];b.parentThatIsA(StageMorph).children.forEach(d=>{d instanceof SpriteMorph&&!d.isTemporary&&d.name!==b.name&&(c=c.concat(d.name))});0a[d]=d));return a}; +InputSlotMorph.prototype.distancesMenu=function(){var a=this.parentThatIsA(BlockMorph),b={},c=this.parentThatIsA(BlockMorph).scriptTarget(),d=c.parentThatIsA(StageMorph),e=[];a&&"reportRelationTo"!==a.selector&&(b["random position"]=["random position"]);b["mouse-pointer"]=["mouse-pointer"];b.center=["center"];d.children.forEach(f=>{f instanceof SpriteMorph&&!f.isTemporary&&f.name!==c.name&&(e=e.concat(f.name))});0b[f]=f));return b}; +InputSlotMorph.prototype.clonablesMenu=function(){var a={},b=this.parentThatIsA(BlockMorph).scriptTarget(),c=b.parentThatIsA(StageMorph),d=[];b instanceof SpriteMorph&&(a.myself=["myself"]);c.children.forEach(e=>{e instanceof SpriteMorph&&!e.isTemporary&&(d=d.concat(e.name))});0a[e]=e));return a};InputSlotMorph.prototype.objectsMenuWithSelf=function(){return this.objectsMenu(!0)}; +InputSlotMorph.prototype.objectsMenu=function(a){var b=this.parentThatIsA(BlockMorph).scriptTarget().parentThatIsA(StageMorph),c={},d=[];a&&(c.myself=["myself"]);c[b.name]=b.name;b.children.forEach(e=>{e instanceof SpriteMorph&&!e.isTemporary&&d.push(e.name)});0c[e]=e));return c}; InputSlotMorph.prototype.typesMenu=function(){var a={number:["number"],text:["text"],Boolean:["Boolean"],list:["list"]};SpriteMorph.prototype.enableFirstClass&&(a.sprite=["sprite"]);a.costume=["costume"];a.sound=["sound"];a.command=["command"];a.reporter=["reporter"];a.predicate=["predicate"];return a}; InputSlotMorph.prototype.gettablesMenu=function(){var a={},b=SpriteMorph.prototype.enableNesting,c=StageMorph.prototype.enableInheritance;a.neighbors=["neighbors"];a.self=["self"];a["other sprites"]=["other sprites"];a.clones=["clones"];a["other clones"]=["other clones"];b&&(a.parts=["parts"],a.anchor=["anchor"]);a.stage=["stage"];c&&(a.children=["children"],a.parent=["parent"],a["temporary?"]=["temporary?"]);a.name=["name"];a.costume=["costume"];a.costumes=["costumes"];a.sounds=["sounds"];a["dangling?"]= ["dangling?"];a["draggable?"]=["draggable?"];a.width=["width"];a.height=["height"];a.left=["left"];a.right=["right"];a.top=["top"];a.bottom=["bottom"];a["rotation style"]=["rotation style"];a["rotation x"]=["rotation x"];a["rotation y"]=["rotation y"];a["center x"]=["center x"];a["center y"]=["center y"];return a}; -InputSlotMorph.prototype.attributesMenu=function(){var a=this.parentThatIsA(BlockMorph),b=a.inputs()[1].evaluate(),c=a.scriptTarget().parentThatIsA(StageMorph),d={};a=[];c=b===c.name?c:detect(c.children,function(e){return e.name===b});if(!c)return d;d=c instanceof SpriteMorph?{"x position":["x position"],"y position":["y position"],direction:["direction"],"costume #":["costume #"],"costume name":["costume name"],size:["size"],width:["width"],height:["height"],left:["left"],right:["right"],top:["top"], -bottom:["bottom"],volume:["volume"],balance:["balance"]}:{"costume #":["costume #"],"costume name":["costume name"],volume:["volume"],balance:["balance"],width:["width"],height:["height"],left:["left"],right:["right"],top:["top"],bottom:["bottom"]};a=c.variables.names();0e.name===b);if(!c)return d;d=c instanceof SpriteMorph?{"x position":["x position"],"y position":["y position"],direction:["direction"],"costume #":["costume #"],"costume name":["costume name"],size:["size"],width:["width"],height:["height"],left:["left"],right:["right"],top:["top"],bottom:["bottom"], +volume:["volume"],balance:["balance"]}:{"costume #":["costume #"],"costume name":["costume name"],volume:["volume"],balance:["balance"],width:["width"],height:["height"],left:["left"],right:["right"],top:["top"],bottom:["bottom"]};a=c.variables.names();0d[e]=e));c.allBlocks(!0).forEach((e,f)=>d["\u00a7_def"+f]=e.blockInstance(!0));return d}; +InputSlotMorph.prototype.costumesMenu=function(){var a=this.parentThatIsA(BlockMorph),b=a.scriptTarget(),c=[];var d=b instanceof SpriteMorph?{Turtle:["Turtle"]}:{Empty:["Empty"]};"doSwitchToCostume"!==a.selector&&(d.current=["current"]);b.costumes.asArray().forEach(e=>c=c.concat(e.name));0d[e]=e));return d}; +InputSlotMorph.prototype.soundsMenu=function(){var a=[],b={};this.parentThatIsA(BlockMorph).scriptTarget().sounds.asArray().forEach(c=>a=a.concat(c.name));0b[c]=c);return b}; +InputSlotMorph.prototype.shadowedVariablesMenu=function(){var a=this.parentThatIsA(BlockMorph),b={};if(!a)return b;var c=a.scriptTarget();this.parentThatIsA(RingMorph)||"receiveOnClone"===this.topBlock().selector?(a=c.variables.names(),a.forEach(d=>b[d]=d),a=c.attributes,a.forEach(d=>b[d]=[d])):c&&c.exemplar&&(a=c.inheritedVariableNames(!0),a.forEach(d=>b[d]=d),a=c.shadowedAttributes(),a.forEach(d=>b[d]=[d]));return b}; InputSlotMorph.prototype.pianoKeyboardMenu=function(){var a;if(a=this.parentThatIsA(BlockMorph))var b=a.scriptTarget().instrument;a=new PianoMenuMorph(this.setContents,this,this.fontSize,b);a.popup(this.world(),new Point(this.right()-a.width()/2,this.bottom()));a.selectKey(+this.evaluate())};InputSlotMorph.prototype.directionDialMenu=function(){return{"\u00a7_dir":null}}; InputSlotMorph.prototype.audioMenu=function(){var a={volume:["volume"],note:["note"],frequency:["frequency"],samples:["samples"],"sample rate":["sample rate"],spectrum:["spectrum"],resolution:["resolution"]};16===this.world().currentKey&&(a["~"]=null,a.modifier=["modifier"],a.output=["output"]);return a}; InputSlotMorph.prototype.setChoices=function(a,b){var c=this.contents();this.choices=a;this.isReadOnly=b||!1;this.parent instanceof BlockMorph&&(this.parent.fixLabelColor(),b||(c.shadowOffset=ZERO,c.shadowColor=null,c.setColor(this.overrideBlack||BLACK)));this.fixLayout()};InputSlotMorph.prototype.shadowedVariablesMenu=function(){var a=this.parentThatIsA(BlockMorph),b={};if(!a)return b;(a=a.receiver())&&a.inheritedVariableNames(!0).forEach(function(c){b[c]=c});return b}; @@ -1038,13 +971,13 @@ InputSlotMorph.prototype.fixLayout=function(){var a=this.contents(),b=this.arrow a.height()+2*this.edge,f=this.isNumeric?a.width()+Math.floor(.5*d)+e+2*this.typeInPadding:Math.max(a.width()+d+2*this.edge+2*this.typeInPadding,a.rawHeight?a.rawHeight()+d:fontHeight(a.fontSize)/1.3+d,this.minWidth);this.bounds.setExtent(new Point(f,e));this.isNumeric?a.setPosition((new Point(Math.floor(e/2),this.edge)).add(new Point(this.typeInPadding,0)).add(this.position())):a.setPosition((new Point(this.edge,this.edge)).add(new Point(this.typeInPadding,0)).add(this.position()));b.isVisible&&b.setPosition(new Point(this.right()- d-this.edge,a.top()));this.parent&&this.parent.fixLayout&&(c.fullChanged(),this.parent.fixLayout(),c.fullChanged())};InputSlotMorph.prototype.mouseDownLeft=function(a){this.isReadOnly||this.arrow().bounds.containsPoint(a)?this.escalateEvent("mouseDownLeft",a):this.selectForEdit().contents().edit()};InputSlotMorph.prototype.mouseClickLeft=function(a){this.arrow().bounds.containsPoint(a)?this.dropDownMenu():this.isReadOnly?this.dropDownMenu():this.contents().edit()}; InputSlotMorph.prototype.reactToKeystroke=function(){if(this.constant){var a=this.contents();this.constant=null;a.isItalic=!1;a.rerender()}};InputSlotMorph.prototype.updateFieldValue=function(a){var b=this.parentThatIsA(BlockMorph);a=void 0!==a?a:this.contents().text;if(b.id)return this.setContents(this.lastValue),SnapActions.setField(this,a)};InputSlotMorph.prototype.reactToEdit=function(){this.updateFieldValue();this.contents().clearSelection()}; -InputSlotMorph.prototype.freshTextEdit=function(a){this.onNextStep=function(){return a.selectAll()}};InputSlotMorph.prototype.userMenu=function(){var a=new MenuMorph(this);if(!StageMorph.prototype.enableCodeMapping)return this.parent.userMenu();this.isNumeric?a.addItem("code number mapping...","mapNumberToCode"):a.addItem("code string mapping...","mapStringToCode");return a}; -InputSlotMorph.prototype.mapStringToCode=function(){(new DialogBoxMorph(this,function(a){return StageMorph.prototype.codeMappings.string=a},this)).promptCode("Code mapping - String <#1>",StageMorph.prototype.codeMappings.string||"",this.world())};InputSlotMorph.prototype.mapNumberToCode=function(){(new DialogBoxMorph(this,function(a){return StageMorph.prototype.codeMappings.number=a},this)).promptCode("Code mapping - Number <#1>",StageMorph.prototype.codeMappings.number||"",this.world())}; +InputSlotMorph.prototype.freshTextEdit=function(a){this.onNextStep=()=>a.selectAll()};InputSlotMorph.prototype.userMenu=function(){var a=new MenuMorph(this);if(!StageMorph.prototype.enableCodeMapping)return this.parent.userMenu();this.isNumeric?a.addItem("code number mapping...","mapNumberToCode"):a.addItem("code string mapping...","mapStringToCode");return a}; +InputSlotMorph.prototype.mapStringToCode=function(){(new DialogBoxMorph(this,a=>StageMorph.prototype.codeMappings.string=a,this)).promptCode("Code mapping - String <#1>",StageMorph.prototype.codeMappings.string||"",this.world())};InputSlotMorph.prototype.mapNumberToCode=function(){(new DialogBoxMorph(this,a=>StageMorph.prototype.codeMappings.number=a,this)).promptCode("Code mapping - Number <#1>",StageMorph.prototype.codeMappings.number||"",this.world())}; InputSlotMorph.prototype.mappedCode=function(){var a=this.parentThatIsA(BlockMorph),b=this.evaluate();if(this.isNumeric)return a=StageMorph.prototype.codeMappings.number||"<#1>",a.replace(/<#1>/g,b);if(!isNaN(parseFloat(b))||!isString(b)||a&&contains(["doSetVar","doChangeVar","doShowVar","doHideVar"],a.selector))return b;a=StageMorph.prototype.codeMappings.string||"<#1>";return a.replace(/<#1>/g,b)}; InputSlotMorph.prototype.evaluate=function(){if(this.selectedBlock)return this.selectedBlock;if(this.constant)return this.constant;var a=this.contents();if(this.isNumeric){var b=parseFloat(a.text||"0");if(!isNaN(b))return b}return a.text};InputSlotMorph.prototype.isEmptySlot=function(){return""===this.contents().text&&!this.selectedBlock};InputSlotMorph.prototype.flash=function(){this.cachedNormalColor||(this.cachedNormalColor=this.color,this.color=this.activeHighlight,this.rerender())}; InputSlotMorph.prototype.unflash=function(){if(this.cachedNormalColor){var a=this.cachedNormalColor;this.cachedNormalColor=null;this.color=a;this.rerender()}}; -InputSlotMorph.prototype.render=function(a){var b=this;var c=this.cachedNormalColor?this.color:this.parent?this.parent.color:new Color(120,120,120);a.fillStyle=this.color.toString();this.isReadOnly&&!this.cachedNormalColor&&(a.fillStyle=c.darker().toString());this.cachedClr=c.toString();this.cachedClrBright=c.lighter(this.contrast).toString();this.cachedClrDark=c.darker(this.contrast).toString();this.isNumeric?(c=Math.max((this.height()-2*this.edge)/2,0),a.beginPath(),a.arc(c+this.edge,c+this.edge, -c,radians(90),radians(-90),!1),a.arc(this.width()-c-this.edge,c+this.edge,c,radians(-90),radians(90),!1),a.closePath(),a.fill(),MorphicPreferences.isFlat||this.drawRoundBorder(a)):(a.fillRect(this.edge,this.edge,this.width()-2*this.edge,this.height()-2*this.edge),MorphicPreferences.isFlat||this.drawRectBorder(a));this.selectedBlock&&a.drawImage(this.doWithAlpha(1,function(){return b.selectedBlock.fullImage()}),this.edge+this.typeInPadding,this.edge)}; +InputSlotMorph.prototype.render=function(a){var b=this.cachedNormalColor?this.color:this.parent?this.parent.color:new Color(120,120,120);a.fillStyle=this.color.toString();this.isReadOnly&&!this.cachedNormalColor&&(a.fillStyle=b.darker().toString());this.cachedClr=b.toString();this.cachedClrBright=b.lighter(this.contrast).toString();this.cachedClrDark=b.darker(this.contrast).toString();this.isNumeric?(b=Math.max((this.height()-2*this.edge)/2,0),a.beginPath(),a.arc(b+this.edge,b+this.edge,b,radians(90), +radians(-90),!1),a.arc(this.width()-b-this.edge,b+this.edge,b,radians(-90),radians(90),!1),a.closePath(),a.fill(),MorphicPreferences.isFlat||this.drawRoundBorder(a)):(a.fillRect(this.edge,this.edge,this.width()-2*this.edge,this.height()-2*this.edge),MorphicPreferences.isFlat||this.drawRectBorder(a));this.selectedBlock&&a.drawImage(this.doWithAlpha(1,()=>this.selectedBlock.fullImage()),this.edge+this.typeInPadding,this.edge)}; InputSlotMorph.prototype.drawRectBorder=function(a){var b=.5*this.edge;a.lineWidth=this.edge;a.lineJoin="round";a.lineCap="round";a.shadowOffsetY=b;a.shadowBlur=this.edge;a.shadowColor=this.color.darker(80).toString();var c=a.createLinearGradient(0,0,0,this.edge);c.addColorStop(0,this.cachedClr);c.addColorStop(1,this.cachedClrDark);a.strokeStyle=c;a.beginPath();a.moveTo(this.edge,b);a.lineTo(this.width()-this.edge-b,b);a.stroke();a.shadowOffsetY=0;c=a.createLinearGradient(0,0,this.edge,0);c.addColorStop(0, this.cachedClr);c.addColorStop(1,this.cachedClrDark);a.strokeStyle=c;a.beginPath();a.moveTo(b,this.edge);a.lineTo(b,this.height()-this.edge-b);a.stroke();a.shadowOffsetX=0;a.shadowOffsetY=0;a.shadowBlur=0;c=a.createLinearGradient(0,this.height()-this.edge,0,this.height());c.addColorStop(0,this.cachedClrBright);c.addColorStop(1,this.cachedClr);a.strokeStyle=c;a.beginPath();a.moveTo(this.edge,this.height()-b);a.lineTo(this.width()-this.edge,this.height()-b);a.stroke();c=a.createLinearGradient(this.width()- this.edge,0,this.width(),0);c.addColorStop(0,this.cachedClrBright);c.addColorStop(1,this.cachedClr);a.strokeStyle=c;a.beginPath();a.moveTo(this.width()-b,this.edge);a.lineTo(this.width()-b,this.height()-this.edge);a.stroke()}; @@ -1061,10 +994,10 @@ TemplateSlotMorph.prototype.render=function(a){this.parent instanceof Morph&&(th TemplateSlotMorph.prototype.cSlots=function(){return[]};TemplateSlotMorph.prototype.flash=function(){this.template().flash()};TemplateSlotMorph.prototype.unflash=function(){this.template().unflash()};BooleanSlotMorph.prototype=new ArgMorph;BooleanSlotMorph.prototype.constructor=BooleanSlotMorph;BooleanSlotMorph.uber=ArgMorph.prototype;BooleanSlotMorph.prototype.isTernary=!1;function BooleanSlotMorph(a){this.init(a)} BooleanSlotMorph.prototype.init=function(a){this.value="boolean"===typeof a?a:null;this.isUnevaluated=!1;this.progress=0;BooleanSlotMorph.uber.init.call(this);this.alpha=1;this.fixLayout()};BooleanSlotMorph.prototype.getSpec=function(){return this.isUnevaluated?"%boolUE":"%b"};BooleanSlotMorph.prototype.evaluate=function(){return this.value};BooleanSlotMorph.prototype.isEmptySlot=function(){return null===this.value}; BooleanSlotMorph.prototype.isBinary=function(){return!this.isTernary&&isNil(this.parentThatIsA(RingMorph))&&!isNil(this.parentThatIsA(ScriptsMorph))};BooleanSlotMorph.prototype.setContents=function(a){this.value="boolean"===typeof a?a:null;this.rerender()}; -BooleanSlotMorph.prototype.toggleValue=function(){var a=this,b=this.selectForEdit();if(b!==this)return this.toggleValue.call(b);b=this.parentThatIsA(IDE_Morph);this.value=this.nextValue();b&&!b.isAnimating?this.rerender():(this.progress=3,this.rerender(),this.nextSteps([function(){a.progress=2;a.rerender()},function(){a.progress=1;a.rerender()},function(){a.progress=0;a.rerender()}]))}; +BooleanSlotMorph.prototype.toggleValue=function(){var a=this.selectForEdit();if(a!==this)return this.toggleValue.call(a);a=this.parentThatIsA(IDE_Morph);this.value=this.nextValue();a&&!a.isAnimating?this.rerender():(this.progress=3,this.rerender(),this.nextSteps([()=>{this.progress=2;this.rerender()},()=>{this.progress=1;this.rerender()},()=>{this.progress=0;this.rerender()}]))}; BooleanSlotMorph.prototype.nextValue=function(){if(this.isStatic||this.isBinary())return!this.value;switch(this.value){case !0:return!1;case !1:return null;default:return!0}};BooleanSlotMorph.prototype.mouseClickLeft=function(){this.parentThatIsA(BlockMorph).id?SnapActions.toggleBoolean(this,this.value):this.toggleValue()};BooleanSlotMorph.prototype.mouseEnter=function(){this.isStatic||(null===this.nextValue()?this.progress=-1:this.progress=1,this.rerender())}; BooleanSlotMorph.prototype.mouseLeave=function(){this.isStatic||(this.progress=0,this.rerender())};BooleanSlotMorph.prototype.userMenu=function(){var a=new MenuMorph(this);if(!StageMorph.prototype.enableCodeMapping)return this.parent.userMenu();!0===this.evaluate()?a.addItem("code true mapping...","mapTrueToCode"):a.addItem("code false mapping...","mapFalseToCode");return a}; -BooleanSlotMorph.prototype.mapTrueToCode=function(){(new DialogBoxMorph(this,function(a){return StageMorph.prototype.codeMappings["true"]=a},this)).promptCode("Code mapping - true",StageMorph.prototype.codeMappings["true"]||"true",this.world())};BooleanSlotMorph.prototype.mapFalseToCode=function(){(new DialogBoxMorph(this,function(a){return StageMorph.prototype.codeMappings["false"]=a},this)).promptCode("Code mapping - false",StageMorph.prototype.codeMappings["false"]||"false",this.world())}; +BooleanSlotMorph.prototype.mapTrueToCode=function(){(new DialogBoxMorph(this,a=>StageMorph.prototype.codeMappings["true"]=a,this)).promptCode("Code mapping - true",StageMorph.prototype.codeMappings["true"]||"true",this.world())};BooleanSlotMorph.prototype.mapFalseToCode=function(){(new DialogBoxMorph(this,a=>StageMorph.prototype.codeMappings["false"]=a,this)).promptCode("Code mapping - false",StageMorph.prototype.codeMappings["false"]||"false",this.world())}; BooleanSlotMorph.prototype.mappedCode=function(){return!0===this.evaluate()?StageMorph.prototype.codeMappings.boolTrue||"true":StageMorph.prototype.codeMappings.boolFalse||"false"};BooleanSlotMorph.prototype.fixLayout=function(){if(this.isStatic){var a=this.textLabelExtent();var b=a.y+3*this.edge;this.bounds.setWidth(a.x+1.5*b+2*this.edge);this.bounds.setHeight(b)}else this.bounds.setWidth(2*(this.fontSize+2*this.edge)),this.bounds.setHeight(this.fontSize+2*this.edge)}; BooleanSlotMorph.prototype.render=function(a){this.cachedNormalColor||(this.color=this.parent?this.parent.color:new Color(200,200,200));this.cachedClr=this.color.toString();this.cachedClrBright=this.bright();this.cachedClrDark=this.dark();this.drawDiamond(a,this.progress);this.drawLabel(a);this.drawKnob(a,this.progress)}; BooleanSlotMorph.prototype.drawDiamond=function(a,b){var c=this.width(),d=this.height(),e=d/2,f=c/2,g=this.edge/2;if(this.cachedNormalColor)a.fillStyle=this.color.toString();else if(0>b)a.fillStyle=this.color.darker(25).toString();else switch(this.value){case !0:a.fillStyle="rgb(0, 200, 0)";break;case !1:a.fillStyle="rgb(200, 0, 0)";break;default:a.fillStyle=this.color.darker(25).toString()}0a instanceof TextMorph)};TextSlotMorph.prototype.layoutChanged=function(){this.fixLayout()}; SymbolMorph.prototype.drawSymbolQueue=function(a,b){var c=a.getContext("2d"),d=a.width/5,e=d/2,f=3*d,g=1*e+f/2,h=e;c.fillStyle=b.toString();var k=function(l){l+=d;var m=f/2;c.fillStyle=b.toString();c.beginPath();c.moveTo(l,g);c.lineTo(l+-1*d,g+m/2);c.lineTo(l+-1*d,g-m/2);c.fill()};k(h);h+=d+e;c.fillRect(h,e,d,f);h+=d+e;c.fillRect(h,e,d,f);k(h+(d+e));return a}; SymbolMorph.prototype.drawSymbolFootprints=function(a,b){var c=a.getContext("2d"),d=a.width,e=d/10,f=1.5*e;c.fillStyle=b.toString();c.beginPath();c.arc(f,f,f,radians(-200),radians(0),!1);c.lineTo(2*f,5.5*e);c.lineTo(e,6*e);c.closePath();c.fill();c.beginPath();c.arc(2.25*e,6.75*e,e,radians(-40),radians(-170),!1);c.closePath();c.fill();c.beginPath();c.arc(d-f,4.5*e,f,radians(-180),radians(20),!1);c.lineTo(d-e,8.5*e);c.lineTo(d-2*f,8*e);c.closePath();c.fill();c.beginPath();c.arc(d-2.25*e,9*e,e,radians(0), radians(-150),!1);c.closePath();c.fill();return a}; SymbolMorph.prototype.drawSymbolNetsBloxLogo=function(a,b){var c=a.getContext("2d"),d=a.width,e=a.height,f=d/14,g=d-2*f;c.beginPath();c.arc(d/2,e/2,2*f,radians(180),radians(270));c.strokeStyle=b.toString();c.beginPath();c.arc(d/2,e/2,f,0,radians(360));c.stroke();c.beginPath();c.arc(d/2,e/2,2*f,0,radians(90));c.stroke();c.beginPath();c.arc(d/2,e/2,3*f,0,radians(90));c.stroke();c.beginPath();c.arc(d/2,e/2,2*f,radians(180),radians(270));c.stroke();c.beginPath();c.arc(d/2,e/2,3*f,radians(180),radians(270)); -c.stroke();b=-60;var h=f;e/=2;g/=2;for(d=g-2*f-d/48;300>b;){var k=h,l=e,m=radians(b),n=d*Math.cos(m),p=d*Math.sin(m),r=f*Math.cos(m)+k,q=f*Math.sin(m)+l;c.beginPath();c.arc(k,l,f,m,m+2*Math.PI);c.moveTo(r,q);c.lineTo(k+n,l+p);c.stroke();h+=g*Math.cos(radians(b));e+=g*Math.sin(radians(b));b+=60}return a};ColorSlotMorph.prototype=new ArgMorph;ColorSlotMorph.prototype.constructor=ColorSlotMorph;ColorSlotMorph.uber=ArgMorph.prototype;function ColorSlotMorph(a){this.init(a)} +c.stroke();b=-60;let h=f;e/=2;g/=2;for(d=g-2*f-d/48;300>b;){var k=h,l=e,m=radians(b);const n=d*Math.cos(m),p=d*Math.sin(m),q=f*Math.cos(m)+k,r=f*Math.sin(m)+l;c.beginPath();c.arc(k,l,f,m,m+2*Math.PI);c.moveTo(q,r);c.lineTo(k+n,l+p);c.stroke();h+=g*Math.cos(radians(b));e+=g*Math.sin(radians(b));b+=60}return a};ColorSlotMorph.prototype=new ArgMorph;ColorSlotMorph.prototype.constructor=ColorSlotMorph;ColorSlotMorph.uber=ArgMorph.prototype;function ColorSlotMorph(a){this.init(a)} ColorSlotMorph.prototype.init=function(a){ColorSlotMorph.uber.init.call(this);this.alpha=1;this.setColor(a||new Color(145,26,68))};ColorSlotMorph.prototype.getSpec=function(){return"%clr"}; ColorSlotMorph.prototype.getUserColor=function(){var a=this,b=this.world(),c=b.hand,d=this.color,e=getDocumentPositionOf(b.worldCanvas),f=c.processMouseMove,g=c.processMouseDown,h=c.processMouseUp,k=new ColorPaletteMorph(null,new Point(16*this.fontSize,10*this.fontSize));b.add(k);k.setPosition(this.bottomLeft().add(new Point(0,this.edge)));c.processMouseMove=function(l){var m=b.getGlobalPixelColor(c.position());c.setPosition(new Point(l.pageX-e.x,l.pageY-e.y));m.a&&a.setColor(m)};c.processMouseDown= nop;c.processMouseUp=function(){a.parentThatIsA(ScriptsMorph)?SnapActions.setColorField(a,a.color).catch(function(){a.setColor(d)}):a.setColor(a.color);k.destroy();c.processMouseMove=f;c.processMouseDown=g;c.processMouseUp=h}};ColorSlotMorph.prototype.mouseClickLeft=function(){this.selectForEdit().getUserColor()};ColorSlotMorph.prototype.evaluate=function(){return this.color}; @@ -1096,14 +1029,13 @@ ColorSlotMorph.prototype.render=function(a){var b=this.parent?this.parent.color: BlockHighlightMorph.prototype=new Morph;BlockHighlightMorph.prototype.constructor=BlockHighlightMorph;BlockHighlightMorph.uber=Morph.prototype;function BlockHighlightMorph(){this.threadCount=0;this.init()}BlockHighlightMorph.prototype.init=function(){BlockHighlightMorph.uber.init.call(this);this.isCachingImage=!0};BlockHighlightMorph.prototype.readout=function(){return this.children.length?this.children[0]:null}; BlockHighlightMorph.prototype.updateReadout=function(){var a=this.readout(),b=useBlurredShadows&&!MorphicPreferences.isFlat?.4*SyntaxElementMorph.prototype.activeBlur:-2*SyntaxElementMorph.prototype.activeBorder;2>this.threadCount?a&&a.destroy():(a?(a.changed(),a.contents=this.threadCount.toString(),a.fixLayout(),a.rerender()):(a=new SpeechBubbleMorph(this.threadCount.toString(),this.color,null,null,this.color.darker(),null,1,!0),this.add(a)),a.setPosition(this.position().add(b)))}; MultiArgMorph.prototype=new ArgMorph;MultiArgMorph.prototype.constructor=MultiArgMorph;MultiArgMorph.uber=ArgMorph.prototype;function MultiArgMorph(a,b,c,d,e,f,g,h,k,l,m){this.init(a,b,c,d,e,f,g,h,k,l,m)} -MultiArgMorph.prototype.init=function(a,b,c,d,e,f,g,h,k,l,m){var n=new FrameMorph;this.slotSpec=a||"%s";this.labelText=b instanceof Array?b.map(function(p){return localize(p||"")}):localize(b||"");this.infix=l||"";this.collapse=m||"";this.minInputs=c||0;this.elementSpec=d||null;this.labelColor=f||null;this.shadowColor=g||null;this.shadowOffset=h||null;this.canBeEmpty=!0;MultiArgMorph.uber.init.call(this);this.alpha=!1===k?1:0;n.alpha=!1===k?1:0;if(this.labelText||"%cs"===this.slotSpec)a=this.labelPart(this.labelText instanceof +MultiArgMorph.prototype.init=function(a,b,c,d,e,f,g,h,k,l,m){var n=new FrameMorph;this.slotSpec=a||"%s";this.labelText=b instanceof Array?b.map(p=>localize(p||"")):localize(b||"");this.infix=l||"";this.collapse=m||"";this.minInputs=c||0;this.elementSpec=d||null;this.labelColor=f||null;this.shadowColor=g||null;this.shadowOffset=h||null;this.canBeEmpty=!0;MultiArgMorph.uber.init.call(this);this.alpha=!1===k?1:0;n.alpha=!1===k?1:0;if(this.labelText||"%cs"===this.slotSpec)a=this.labelPart(this.labelText instanceof Array?this.labelText[0]:this.labelText),this.add(a),a.hide();a=new ArrowMorph("left",this.fontSize,Math.max(Math.floor(this.fontSize/6),1),e,!0);e=new ArrowMorph("right",this.fontSize,Math.max(Math.floor(this.fontSize/6),1),e,!0);n.add(a);n.add(e);n.rerender();n.acceptsDrops=!1;this.add(n);for(n=0;na instanceof BlockLabelMorph)};MultiArgMorph.prototype.arrows=function(){return this.children[this.children.length-1]};MultiArgMorph.prototype.getSpec=function(){return"%mult"+this.slotSpec};MultiArgMorph.prototype.setContents=function(a){var b=this.inputs(),c;a instanceof Array||"%rcv"!==this.slotSpec||(a=[a]);for(c=0;c{a=this.shadowOffset||(d?d.shadowOffset:null);d.shadowColor.eq(c)||(d.shadowColor=c,d.shadowOffset=a,d.fixLayout(),d.rerender())})}}this.fixArrowsLayout();MultiArgMorph.uber.fixLayout.call(this);this.parent&&this.parent.fixLayout()}; MultiArgMorph.prototype.fixArrowsLayout=function(){var a=this.label(),b=this.arrows(),c=b.children[0],d=b.children[1],e=this.inputs().length,f=new Point(d.width()/2,d.height());c.show();d.show();ethis.maxInputs- -1&&(d.hide(),b.setExtent(f)));b.rerender()};MultiArgMorph.prototype.fixHolesLayout=function(){var a=this;this.holes=[];if("%cs"===this.slotSpec){var b=this.position();this.inputs().forEach(function(c){c instanceof CSlotMorph&&(c.fixHolesLayout(),a.holes.push(c.holes[0].translateBy(c.position().subtract(b))))})}};MultiArgMorph.prototype.refresh=function(){this.inputs().forEach(function(a){a.fixLayout();a.rerender()})}; +1&&(d.hide(),b.setExtent(f)));b.rerender()};MultiArgMorph.prototype.fixHolesLayout=function(){this.holes=[];if("%cs"===this.slotSpec){var a=this.position();this.inputs().forEach(b=>{b instanceof CSlotMorph&&(b.fixHolesLayout(),this.holes.push(b.holes[0].translateBy(b.position().subtract(a))))})}};MultiArgMorph.prototype.refresh=function(){this.inputs().forEach(a=>{a.fixLayout();a.rerender()})}; MultiArgMorph.prototype.deleteSlot=function(a){var b=this.inputs().length,c=this.children.indexOf(a);b<=this.minInputs||(""!==this.infix&&(c===this.children.length-2?this.removeChild(this.children[c-1]):this.removeChild(this.children[c+1])),this.removeChild(a),this.fixLayout())}; MultiArgMorph.prototype.insertNewInputBefore=function(a,b){a=this.children.indexOf(a);var c=this.labelPart(this.slotSpec);if(!(this.maxInputs&&this.inputs().length>=this.maxInputs))return b&&c.setContents(b),c.parent=this,""!==this.infix?(b=this.labelPart(this.infix),b.parent=this,this.children.splice(a,0,c,b)):this.children.splice(a,0,c),c.fixLayout(),this.parent instanceof BlockMorph&&this.parent.fixLabelColor(),this.fixLayout(),c}; MultiArgMorph.prototype.addInput=function(a){var b=this.labelPart(this.slotSpecFor(this.inputs().length));this.addInfix();var c=this.children.length-1;if(a)b.setContents(a);else if("%scriptVars"===this.elementSpec||"%blockVars"===this.elementSpec){var d="";a=c;for("%scriptVars"===this.elementSpec&&(a+=1);0c?b.setContents([localize("value"), @@ -1113,12 +1045,12 @@ MultiArgMorph.prototype.removeInput=function(){var a=this.inputs().length,b;0")};MultiArgMorph.prototype.mapCodeItem=function(a){this.mapToCode(a+"item","list item <#1>")};MultiArgMorph.prototype.mapToCode=function(a,b){(new DialogBoxMorph(this,function(c){return StageMorph.prototype.codeMappings[a]=c},this)).promptCode("Code mapping - "+b,StageMorph.prototype.codeMappings[a]||"",this.world())}; -MultiArgMorph.prototype.mappedCode=function(a){var b=this.parentThatIsA(BlockMorph),c="",d="",e=0,f=[];b&&(b instanceof RingMorph?c="parms_":"doDeclareVariables"===b.selector&&(c="tempvars_"));b=StageMorph.prototype.codeMappings[c+"list"]||"<#1>";var g=StageMorph.prototype.codeMappings[c+"item"]||"<#1>";var h=StageMorph.prototype.codeMappings[c+"delim"]||" ";this.inputs().forEach(function(k){return f.push(g.replace(/<#1>/g,k.mappedCode(a)))});f.forEach(function(k){e&&(d+=h);d+=k;e+=1});return b=b.replace(/<#1>/g, -d)};MultiArgMorph.prototype.evaluate=function(){var a=[];this.inputs().forEach(function(b){return a.push(b.evaluate())});return a};MultiArgMorph.prototype.isEmptySlot=function(){return this.canBeEmpty?0===this.inputs().length:!1};ArgLabelMorph.prototype=new ArgMorph;ArgLabelMorph.prototype.constructor=ArgLabelMorph;ArgLabelMorph.uber=ArgMorph.prototype;function ArgLabelMorph(a,b){this.init(a,b)} +MultiArgMorph.prototype.userMenu=function(){var a=new MenuMorph(this),b=this.parentThatIsA(BlockMorph),c="";if(!StageMorph.prototype.enableCodeMapping)return this.parent.userMenu();b&&(b instanceof RingMorph?c="parms_":"doDeclareVariables"===b.selector&&(c="tempvars_"));a.addItem("code list mapping...",()=>this.mapCodeList(c));a.addItem("code item mapping...",()=>this.mapCodeItem(c));a.addItem("code delimiter mapping...",()=>this.mapCodeDelimiter(c));return a}; +MultiArgMorph.prototype.mapCodeDelimiter=function(a){this.mapToCode(a+"delim","list item delimiter")};MultiArgMorph.prototype.mapCodeList=function(a){this.mapToCode(a+"list","list contents <#1>")};MultiArgMorph.prototype.mapCodeItem=function(a){this.mapToCode(a+"item","list item <#1>")};MultiArgMorph.prototype.mapToCode=function(a,b){(new DialogBoxMorph(this,c=>StageMorph.prototype.codeMappings[a]=c,this)).promptCode("Code mapping - "+b,StageMorph.prototype.codeMappings[a]||"",this.world())}; +MultiArgMorph.prototype.mappedCode=function(a){var b=this.parentThatIsA(BlockMorph),c="",d="",e=0,f=[];b&&(b instanceof RingMorph?c="parms_":"doDeclareVariables"===b.selector&&(c="tempvars_"));b=StageMorph.prototype.codeMappings[c+"list"]||"<#1>";var g=StageMorph.prototype.codeMappings[c+"item"]||"<#1>";var h=StageMorph.prototype.codeMappings[c+"delim"]||" ";this.inputs().forEach(k=>f.push(g.replace(/<#1>/g,k.mappedCode(a))));f.forEach(k=>{e&&(d+=h);d+=k;e+=1});return b=b.replace(/<#1>/g,d)}; +MultiArgMorph.prototype.evaluate=function(){var a=[];this.inputs().forEach(b=>a.push(b.evaluate()));return a};MultiArgMorph.prototype.isEmptySlot=function(){return this.canBeEmpty?0===this.inputs().length:!1};ArgLabelMorph.prototype=new ArgMorph;ArgLabelMorph.prototype.constructor=ArgLabelMorph;ArgLabelMorph.uber=ArgMorph.prototype;function ArgLabelMorph(a,b){this.init(a,b)} ArgLabelMorph.prototype.init=function(a,b){this.labelText=localize(b||"input list:");ArgLabelMorph.uber.init.call(this);this.isStatic=!0;this.alpha=0;b=this.labelPart(this.labelText);this.add(b);this.add(a)};ArgLabelMorph.prototype.label=function(){return this.children[0]};ArgLabelMorph.prototype.argMorph=function(){return this.children[1]}; -ArgLabelMorph.prototype.fixLayout=function(){var a=this.label();if(this.parent){this.color=this.parent.color;var b=a.shadowOffset||ZERO;var c=0>b.x?this.parent.color.darker(this.labelContrast):this.parent.color.lighter(this.labelContrast);""===this.labelText||a.shadowColor.eq(c)||(a.shadowColor=c,a.shadowOffset=b,a.rerender())}ArgLabelMorph.uber.fixLayout.call(this);this.parent&&this.parent.fixLayout()};ArgLabelMorph.prototype.refresh=function(){this.inputs().forEach(function(a){a.fixLayout();a.rerender()})}; +ArgLabelMorph.prototype.fixLayout=function(){var a=this.label();if(this.parent){this.color=this.parent.color;var b=a.shadowOffset||ZERO;var c=0>b.x?this.parent.color.darker(this.labelContrast):this.parent.color.lighter(this.labelContrast);""===this.labelText||a.shadowColor.eq(c)||(a.shadowColor=c,a.shadowOffset=b,a.rerender())}ArgLabelMorph.uber.fixLayout.call(this);this.parent&&this.parent.fixLayout()};ArgLabelMorph.prototype.refresh=function(){this.inputs().forEach(a=>{a.fixLayout();a.rerender()})}; ArgLabelMorph.prototype.setLabelColor=function(a,b,c){if(""!==this.labelText){var d=this.label();d.color=a;d.shadowColor=b;d.shadowOffset=c;d.rerender()}};ArgLabelMorph.prototype.reactToGrabOf=function(){this.parent instanceof SyntaxElementMorph&&this.parent.revertToDefaultInput(this)};ArgLabelMorph.prototype.evaluate=function(){return this.argMorph().evaluate()};ArgLabelMorph.prototype.isEmptySlot=function(){return!1};FunctionSlotMorph.prototype=new ArgMorph; FunctionSlotMorph.prototype.constructor=FunctionSlotMorph;FunctionSlotMorph.uber=ArgMorph.prototype;function FunctionSlotMorph(a){this.init(a)}FunctionSlotMorph.prototype.init=function(a){FunctionSlotMorph.uber.init.call(this);this.isPredicate=a||!1;this.color=this.rfColor};FunctionSlotMorph.prototype.getSpec=function(){return"%f"}; FunctionSlotMorph.prototype.render=function(a){var b=this.parent?this.parent.color:new Color(120,120,120);this.cachedClr=b.toString();this.cachedClrBright=b.lighter(this.contrast).toString();this.cachedClrDark=b.darker(this.contrast).toString();this.isPredicate?this.drawDiamond(a):this.drawRounded(a)}; @@ -1134,7 +1066,7 @@ ReporterSlotMorph.prototype.emptySlot=function(){var a=new ArgMorph,b=2*this.rfB ReporterSlotMorph.prototype.evaluate=function(){return this.nestedBlock()};ReporterSlotMorph.prototype.isEmptySlot=function(){return null===this.nestedBlock()};ReporterSlotMorph.prototype.fixLayout=function(){var a=this.contents();this.bounds.setExtent(a.extent().add(2*this.edge+2*this.rfBorder));a.setCenter(this.center());this.parent&&this.parent.fixLayout&&this.parent.fixLayout()};RingReporterSlotMorph.prototype=new ReporterSlotMorph;RingReporterSlotMorph.prototype.constructor=RingReporterSlotMorph; RingReporterSlotMorph.uber=ReporterSlotMorph.prototype;RingReporterSlotMorph.prototype.rfBorder=RingCommandSlotMorph.prototype.rfBorder;RingReporterSlotMorph.prototype.edge=RingCommandSlotMorph.prototype.edge;RingReporterSlotMorph.prototype.enableCommandDrops=!0;function RingReporterSlotMorph(a){this.init(a)}RingReporterSlotMorph.prototype.init=function(a){RingReporterSlotMorph.uber.init.call(this,a,!0);this.contrast=RingMorph.prototype.contrast};RingReporterSlotMorph.prototype.getSpec=function(){return"%rr"}; RingReporterSlotMorph.prototype.replaceInput=function(a,b,c){RingReporterSlotMorph.uber.replaceInput.call(this,a,b);this.parent instanceof RingMorph&&!c&&this.parent.vanishForSimilar()};RingReporterSlotMorph.prototype.slotAttachPoint=CommandSlotMorph.prototype.slotAttachPoint;RingReporterSlotMorph.prototype.dentLeft=CommandSlotMorph.prototype.dentLeft;RingReporterSlotMorph.prototype.dentCenter=CommandSlotMorph.prototype.dentCenter; -RingReporterSlotMorph.prototype.attachTargets=function(){return!RingReporterSlotMorph.prototype.enableCommandDrops||this.contents()instanceof ReporterBlockMorph?[]:CommandSlotMorph.prototype.attachTargets.call(this)};RingReporterSlotMorph.prototype.nestedBlock=function(a){if(a){var b=this.nestedBlock();this.replaceInput(this.children[0],a);b&&a.bottomBlock().nextBlock(b);this.fixLayout()}else return detect(this.children,function(c){return c instanceof BlockMorph})}; +RingReporterSlotMorph.prototype.attachTargets=function(){return!RingReporterSlotMorph.prototype.enableCommandDrops||this.contents()instanceof ReporterBlockMorph?[]:CommandSlotMorph.prototype.attachTargets.call(this)};RingReporterSlotMorph.prototype.nestedBlock=function(a){if(a){var b=this.nestedBlock();this.replaceInput(this.children[0],a);b&&a.bottomBlock().nextBlock(b);this.fixLayout()}else return detect(this.children,c=>c instanceof BlockMorph)}; RingReporterSlotMorph.prototype.fixLayout=function(){this.contents()instanceof CommandBlockMorph?CommandSlotMorph.prototype.fixLayout.call(this):RingReporterSlotMorph.uber.fixLayout.call(this)};RingReporterSlotMorph.prototype.render=function(a){MorphicPreferences.isFlat||(this.cachedClr=this.color.toString(),this.cachedClrBright=this.bright(),this.cachedClrDark=this.dark(),a.fillStyle=this.cachedClr,this.isPredicate?this.drawEdgesDiamond(a):this.drawEdgesOval(a))}; RingReporterSlotMorph.prototype.outlinePath=function(a,b){this.isPredicate?this.outlinePathDiamond(a,b):this.outlinePathOval(a,b)}; RingReporterSlotMorph.prototype.outlinePathOval=function(a,b){var c=b.x;b=b.y;var d=this.width(),e=this.height(),f=Math.min(this.rounding,e/2);a.arc(f+this.edge+c,f+this.edge+b,f,radians(-180),radians(-90),!1);a.arc(d-f-this.edge+c,f+this.edge+b,f,radians(-90),radians(-0),!1);a.arc(d-f-this.edge+c,e-f-this.edge+b,f,radians(0),radians(90),!1);a.arc(f+this.edge+c,e-f-this.edge+b,f,radians(90),radians(180),!1);a.lineTo(this.edge+c,f+this.edge+b)}; @@ -1147,35 +1079,35 @@ RingReporterSlotMorph.prototype.drawEdgesDiamond=function(a){var b=this.width(), 0,e,0);g.addColorStop(1,this.cachedClrDark);g.addColorStop(0,this.cachedClr);a.strokeStyle=g;a.beginPath();a.moveTo(f,d);a.lineTo(e,f);a.stroke();g=a.createLinearGradient(0,0,0,this.edge);g.addColorStop(1,this.cachedClrDark);g.addColorStop(0,this.cachedClr);a.strokeStyle=g;a.beginPath();a.moveTo(e,f);a.lineTo(b-e,f);a.stroke();a.shadowOffsetX=0;a.shadowOffsetY=0;a.shadowBlur=0;g=a.createLinearGradient(b-e,0,b,0);g.addColorStop(1,this.cachedClr);g.addColorStop(0,this.cachedClrBright);a.strokeStyle= g;a.beginPath();a.moveTo(b-e,c-f);a.lineTo(b-f,d);a.stroke();g=a.createLinearGradient(0,c-this.edge,0,c);g.addColorStop(1,this.cachedClr);g.addColorStop(0,this.cachedClrBright);a.strokeStyle=g;a.beginPath();a.moveTo(e+f,c-f);a.lineTo(b-e-f,c-f);a.stroke()};CommentMorph.prototype=new BoxMorph;CommentMorph.prototype.constructor=CommentMorph;CommentMorph.uber=BoxMorph.prototype; CommentMorph.prototype.refreshScale=function(){CommentMorph.prototype.fontSize=SyntaxElementMorph.prototype.fontSize;CommentMorph.prototype.padding=5*SyntaxElementMorph.prototype.scale;CommentMorph.prototype.rounding=8*SyntaxElementMorph.prototype.scale};CommentMorph.prototype.refreshScale();function CommentMorph(a){this.init(a)} -CommentMorph.prototype.init=function(a){var b=this,c=SyntaxElementMorph.prototype.scale;this.stickyOffset=this.block=null;this.isCollapsed=!1;this.titleBar=new BoxMorph(this.rounding,c,new Color(255,255,180));this.titleBar.color=new Color(255,255,180);this.titleBar.setHeight(fontHeight(this.fontSize)+this.padding);this.title=null;this.arrow=new ArrowMorph("down",this.fontSize);this.arrow.mouseClickLeft=function(){return b.toggleExpand()};this.contents=new TextMorph(a||localize("add comment here..."), -this.fontSize);this.lastValue=this.contents.text;this.contents.isEditable=!0;this.contents.enableSelecting();this.contents.maxWidth=90*c;this.contents.fixLayout();this.handle=new HandleMorph(this.contents,80,2*this.fontSize,-2,-2);this.handle.setExtent(new Point(11*c,11*c));this.anchor=null;CommentMorph.uber.init.call(this,this.rounding,c,new Color(255,255,180));this.color=new Color(255,255,220);this.isDraggable=!0;this.add(this.titleBar);this.add(this.arrow);this.add(this.contents);this.add(this.handle); -this.fixLayout()};CommentMorph.prototype.reactToEdit=function(a){a=a.text;a!==this.lastValue&&(this.contents.text=this.lastValue,this.contents.rerender(),this.contents.changed(),this.layoutChanged(),SnapActions.setCommentText(this,a))};CommentMorph.prototype.fullCopy=function(){var a=new CommentMorph(this.contents.text);a.isCollapsed=this.isCollapsed;a.setTextWidth(this.textWidth());a.id=this.id;this.selectionID&&(a.selectionID=!0);return a}; +CommentMorph.prototype.init=function(a){var b=SyntaxElementMorph.prototype.scale;this.stickyOffset=this.block=null;this.isCollapsed=!1;this.titleBar=new BoxMorph(this.rounding,b,new Color(255,255,180));this.titleBar.color=new Color(255,255,180);this.titleBar.setHeight(fontHeight(this.fontSize)+this.padding);this.title=null;this.arrow=new ArrowMorph("down",this.fontSize);this.arrow.mouseClickLeft=()=>this.toggleExpand();this.contents=new TextMorph(a||localize("add comment here..."),this.fontSize); +this.lastValue=this.contents.text;this.contents.isEditable=!0;this.contents.enableSelecting();this.contents.maxWidth=90*b;this.contents.fixLayout();this.handle=new HandleMorph(this.contents,80,2*this.fontSize,-2,-2);this.handle.setExtent(new Point(11*b,11*b));this.anchor=null;CommentMorph.uber.init.call(this,this.rounding,b,new Color(255,255,180));this.color=new Color(255,255,220);this.isDraggable=!0;this.add(this.titleBar);this.add(this.arrow);this.add(this.contents);this.add(this.handle);this.fixLayout()}; +CommentMorph.prototype.reactToEdit=function(a){a=a.text;a!==this.lastValue&&(this.contents.text=this.lastValue,this.contents.rerender(),this.contents.changed(),this.layoutChanged(),SnapActions.setCommentText(this,a))};CommentMorph.prototype.fullCopy=function(){var a=new CommentMorph(this.contents.text);a.isCollapsed=this.isCollapsed;a.setTextWidth(this.textWidth());a.id=this.id;this.selectionID&&(a.selectionID=!0);return a}; CommentMorph.prototype.setTextWidth=function(a){this.contents.maxWidth=a;this.contents.fixLayout();this.fixLayout()};CommentMorph.prototype.textWidth=function(){return this.contents.maxWidth};CommentMorph.prototype.text=function(){return this.contents.text};CommentMorph.prototype.toggleExpand=function(){this.isCollapsed=!this.isCollapsed;this.fixLayout();this.align();this.isCollapsed||this.comeToFront()};CommentMorph.prototype.comeToFront=function(){this.parent&&(this.parent.add(this),this.changed())}; CommentMorph.prototype.mouseClickLeft=function(){this.comeToFront()};CommentMorph.prototype.layoutChanged=function(){this.fixLayout();this.align();this.comeToFront()}; -CommentMorph.prototype.fixLayout=function(){var a=this,b=this.contents.width()+2*this.padding;this.title&&(this.title.destroy(),this.title=null);if(this.isCollapsed){this.contents.hide();this.title=new FrameMorph;this.title.alpha=0;this.title.acceptsDrops=!1;var c=new StringMorph(this.contents.text,this.fontSize,null,!0);c.rootForGrab=function(){return a};this.title.add(c);this.title.setHeight(c.height());this.title.setWidth(b-this.arrow.width()-2*this.padding-this.rounding);this.add(this.title)}else this.contents.show(); -this.titleBar.setWidth(b);this.contents.setLeft(this.titleBar.left()+this.padding);this.contents.setTop(this.titleBar.bottom()+this.padding);this.arrow.direction=this.isCollapsed?"right":"down";this.arrow.rerender();this.arrow.setCenter(this.titleBar.center());this.arrow.setLeft(this.titleBar.left()+this.padding);this.title&&this.title.setPosition(this.arrow.topRight().add(new Point(this.padding,0)));this.changed();this.bounds.setHeight(this.titleBar.height()+(this.isCollapsed?0:this.padding+this.contents.height()+ +CommentMorph.prototype.fixLayout=function(){var a=this.contents.width()+2*this.padding;this.title&&(this.title.destroy(),this.title=null);if(this.isCollapsed){this.contents.hide();this.title=new FrameMorph;this.title.alpha=0;this.title.acceptsDrops=!1;var b=new StringMorph(this.contents.text,this.fontSize,null,!0);b.rootForGrab=()=>this;this.title.add(b);this.title.setHeight(b.height());this.title.setWidth(a-this.arrow.width()-2*this.padding-this.rounding);this.add(this.title)}else this.contents.show(); +this.titleBar.setWidth(a);this.contents.setLeft(this.titleBar.left()+this.padding);this.contents.setTop(this.titleBar.bottom()+this.padding);this.arrow.direction=this.isCollapsed?"right":"down";this.arrow.rerender();this.arrow.setCenter(this.titleBar.center());this.arrow.setLeft(this.titleBar.left()+this.padding);this.title&&this.title.setPosition(this.arrow.topRight().add(new Point(this.padding,0)));this.changed();this.bounds.setHeight(this.titleBar.height()+(this.isCollapsed?0:this.padding+this.contents.height()+ this.padding));this.bounds.setWidth(this.titleBar.width());this.rerender();this.handle.fixLayout()}; -CommentMorph.prototype.userMenu=function(){var a=this,b=new MenuMorph(this);b.addItem("duplicate",function(){var c=a.fullCopy(),d=a.parentThatIsA(IDE_Morph),e=a.parentThatIsA(BlockEditorMorph),f=a.world();c.id=null;c.pickUp(f);!d&&e&&(d=e.target.parentThatIsA(IDE_Morph));d&&(f.hand.grabOrigin={origin:d.palette,position:d.palette.center()})},"make a copy\nand pick it up");b.addItem("delete",function(){this.id?SnapActions.removeBlock(this):this.destroy()});b.addItem("comment pic...",function(){var c= -a.parentThatIsA(IDE_Morph);c.saveCanvasAs(a.fullImage(),(c.projectName||localize("untitled"))+" "+localize("comment pic"))},"save a picture\nof this comment");return b};CommentMorph.prototype.userDestroy=function(){this.selectForEdit().destroy()};CommentMorph.prototype.hide=function(){this.isVisible=!1;this.changed()};CommentMorph.prototype.show=function(){this.isVisible=!0;this.changed()}; +CommentMorph.prototype.userMenu=function(){var a=new MenuMorph(this);a.addItem("duplicate",()=>{var b=this.fullCopy(),c=this.parentThatIsA(IDE_Morph),d=this.parentThatIsA(BlockEditorMorph),e=this.world();b.id=null;b.pickUp(e);!c&&d&&(c=d.target.parentThatIsA(IDE_Morph));c&&(e.hand.grabOrigin={origin:c.palette,position:c.palette.center()})},"make a copy\nand pick it up");a.addItem("delete",function(){this.id?SnapActions.removeBlock(this):this.destroy()});a.addItem("comment pic...",()=>{var b=this.parentThatIsA(IDE_Morph); +b.saveCanvasAs(this.fullImage(),(b.projectName||localize("untitled"))+" "+localize("comment pic"))},"save a picture\nof this comment");return a};CommentMorph.prototype.userDestroy=function(){this.selectForEdit().destroy()};CommentMorph.prototype.hide=function(){this.isVisible=!1;this.changed()};CommentMorph.prototype.show=function(){this.isVisible=!0;this.changed()}; CommentMorph.prototype.prepareToBeGrabbed=function(a){this.block&&(this.block=this.block.comment=null);this.anchor&&(this.anchor.destroy(),this.anchor=null,this.removeShadow(),this.addShadow())};CommentMorph.prototype.snapTarget=function(a){return this.parent.closestBlock(this,a)};CommentMorph.prototype.selectForEdit=SyntaxElementMorph.prototype.selectForEdit; CommentMorph.prototype.snap=function(a){if(!(this.parent instanceof ScriptsMorph))return null;null!==a&&(a.comment=this,this.block=a,this.snapSound&&this.snapSound.play());this.align()}; -CommentMorph.prototype.align=function(a,b){if(this.block){var c=a||this.block.topBlock();a=c.parentThatIsA(ScriptsMorph);this.setTop(this.block.top()+this.block.corner);var d=this.top();var e=this.bottom();c=c.allChildren().filter(function(f){return f instanceof BlockMorph&&f.bottom()>d&&f.top()f instanceof BlockMorph&&f.bottom()>d&&f.top()f.right()));this.setLeft(c+5);!b&&a&&a.addBack(this);this.anchor||(this.anchor=new Morph,this.anchor.color=this.titleBar.color);this.anchor.setPosition(new Point(this.block.right(),this.top()+ +this.edge));this.anchor.bounds.corner=new Point(this.left(),this.top()+this.edge+1);this.anchor.rerender();this.addBack(this.anchor)}};CommentMorph.prototype.startFollowing=function(a,b){this.align(a);b.add(this);this.addShadow();this.stickyOffset=this.position().subtract(this.block.position());this.step=()=>{this.block?this.setPosition(this.block.position().add(this.stickyOffset)):this.stopFollowing()}};CommentMorph.prototype.stopFollowing=function(){this.removeShadow();delete this.step}; CommentMorph.prototype.destroy=function(){this.block&&(this.block.comment=null);CommentMorph.uber.destroy.call(this)};CommentMorph.prototype.stackHeight=function(){return this.height()};ScriptFocusMorph.prototype=new BoxMorph;ScriptFocusMorph.prototype.constructor=ScriptFocusMorph;ScriptFocusMorph.uber=BoxMorph.prototype;function ScriptFocusMorph(a,b,c){this.init(a,b,c)} -ScriptFocusMorph.prototype.init=function(a,b,c){this.editor=a;this.element=b;this.atEnd=!1;ScriptFocusMorph.uber.init.call(this);this.element instanceof ScriptsMorph&&this.setPosition(c)};ScriptFocusMorph.prototype.getFocus=function(a){a||(a=this.world());a&&a.keyboardFocus!==this&&a.stopEditing();a.keyboardFocus=this;this.fixLayout();this.editor.updateToolbar()}; +ScriptFocusMorph.prototype.init=function(a,b,c){this.editor=a;this.element=b;this.atEnd=!1;ScriptFocusMorph.uber.init.call(this);this.element instanceof ScriptsMorph&&this.setPosition(c)};ScriptFocusMorph.prototype.getFocus=function(a){a||=this.world();a&&a.keyboardFocus!==this&&a.stopEditing();a.keyboardFocus=this;this.fixLayout();this.editor.updateToolbar()}; ScriptFocusMorph.prototype.fixLayout=function(){this.changed();this.element instanceof CommandBlockMorph||this.element instanceof CommandSlotMorph||this.element instanceof ScriptsMorph?this.manifestStatement():this.manifestExpression();this.editor.add(this);this.scrollIntoView();this.changed()}; ScriptFocusMorph.prototype.manifestStatement=function(){var a=this.element instanceof ScriptsMorph,b=this.element.top();this.edge=this.border=0;this.alpha=1;this.color=this.editor.feedbackColor;this.bounds.setExtent(new Point(a?SyntaxElementMorph.prototype.hatWidth:this.element.width(),Math.max(SyntaxElementMorph.prototype.corner,SyntaxElementMorph.prototype.feedbackMinHeight)));this.element instanceof CommandSlotMorph?b+=SyntaxElementMorph.prototype.corner:this.atEnd&&(b=this.element.bottom());a|| this.setPosition(new Point(this.element.left(),b));this.fps=2;this.show();this.step=function(){this.toggleVisibility()}}; ScriptFocusMorph.prototype.manifestExpression=function(){this.edge=SyntaxElementMorph.prototype.rounding;this.border=Math.max(SyntaxElementMorph.prototype.edge,3);this.color=this.editor.feedbackColor.copy();this.color.a=.5;this.borderColor=this.editor.feedbackColor;this.bounds=this.element.fullBounds().expandBy(Math.max(2*SyntaxElementMorph.prototype.edge,SyntaxElementMorph.prototype.reporterDropFeedbackPadding));this.rerender();delete this.fps;delete this.step;this.show()}; ScriptFocusMorph.prototype.trigger=function(){var a=this.element,b=this;if(a instanceof MultiArgMorph)a.arrows().children[1].isVisible&&SnapActions.addListInput(a).then(function(){b.fixLayout()});else if(a.parent instanceof TemplateSlotMorph)a.mouseClickLeft();else if(a instanceof BooleanSlotMorph)SnapActions.toggleBoolean(a,a.value);else if(a instanceof InputSlotMorph){var c=a.updateFieldValue;a.updateFieldValue=function(){var d=c.apply(this,arguments);d&&d.then(function(){b.fixLayout()});this.updateFieldValue= -c};a.isReadOnly?a.choices&&(a.dropDownMenu(!0),delete this.fps,delete this.step,this.hide()):(delete this.fps,delete this.step,this.hide(),this.world().onNextStep=function(){a.contents().edit();a.contents().selectAll()})}};ScriptFocusMorph.prototype.menu=function(){var a=this.element;a instanceof InputSlotMorph&&a.choices?(a.dropDownMenu(!0),delete this.fps,delete this.step,this.hide()):this.insertVariableGetter()}; +c};a.isReadOnly?a.choices&&(a.dropDownMenu(!0),delete this.fps,delete this.step,this.hide()):(delete this.fps,delete this.step,this.hide(),this.world().onNextStep=()=>{a.contents().edit();a.contents().selectAll()})}};ScriptFocusMorph.prototype.menu=function(){var a=this.element;a instanceof InputSlotMorph&&a.choices?(a.dropDownMenu(!0),delete this.fps,delete this.step,this.hide()):this.insertVariableGetter()}; ScriptFocusMorph.prototype.deleteLastElement=function(){var a=this.element,b=this,c;if(a.parent instanceof ScriptsMorph){if(this.atEnd||a instanceof ReporterBlockMorph){SnapActions.removeBlock(a).then(function(){b.element=b.editor;b.atEnd=!1;b.editor.adjustBounds();b.fixLayout()});return}}else if(a instanceof MultiArgMorph)a.arrows().children[0].isVisible&&(c=SnapActions.removeListInput(a));else if(a instanceof BooleanSlotMorph)a.isStatic||(c=SnapActions.toggleBoolean(a,!1));else if(a instanceof ReporterBlockMorph){if(!a.isTemplate){SnapActions.removeBlock(a).then(function(){b.lastElement(); b.editor.adjustBounds();b.fixLayout()});return}}else if(a instanceof CommandBlockMorph){if(this.atEnd){var d=a.parent;SnapActions.removeBlock(a,!0).then(function(){b.element=d;b.editor.adjustBounds();b.fixLayout()});return}a.parent instanceof CommandBlockMorph&&(c=SnapActions.removeBlock(a.parent,!0))}c&&c.then(function(){b.editor.adjustBounds();b.fixLayout()})}; -ScriptFocusMorph.prototype.insertBlock=ScriptFocusMorph.prototype.fillInBlock=function(a){var b=this,c,d,e;a.isTemplate=!1;a.isDraggable=!0;if(this.element instanceof ScriptsMorph){if(a instanceof CommandBlockMorph)if(a.isStop())var f=this.topLeft();else{f=new Point(this.left(),this.top()-a.height());var g=!0}else f=new Point(this.left(),this.center().y+a.height()/2);a=SnapActions.addBlock(a,this.editor.scriptTarget(),f)}else if(this.element instanceof CommandBlockMorph){if(this.atEnd)var h={point:this.element.bottomAttachPoint(), -element:this.element,loc:"bottom",type:"block"};else f=this.element.parent,f instanceof ScriptsMorph?h={point:this.element.topAttachPoint(),element:this.element,loc:"top",type:"block"}:f instanceof CommandSlotMorph?f.nestedBlock(a):f instanceof RingReporterSlotMorph?(a.nextBlock(f.nestedBlock()),f.add(a),f.fixLayout()):f instanceof CommandBlockMorph&&(h={point:f.bottomAttachPoint(),element:f,loc:"bottom",type:"block"});a=SnapActions.moveBlock(a,h)}else this.element instanceof CommandSlotMorph?(h= -{point:this.element.slotAttachPoint(),element:this.element,loc:"bottom",type:"slot"},g=!0,a=SnapActions.moveBlock(a,h)):(f=this.element.parent,f instanceof ScriptsMorph?a=SnapActions.replaceBlock(this.element,a):(g=!0,a=SnapActions.moveBlock(a,this.element)));a.then(function(k){g&&(b.atEnd=!0);"receiveCondition"===k.selector&&(e=b.editor.scriptTarget())&&(c=e.parentThatIsA(StageMorph))&&(c.enableCustomHatBlocks=!0,c.threads.pauseCustomHatBlocks=!1,(d=c.parentThatIsA(IDE_Morph))&&d.controlBar.stopButton.refresh()); -b.element=k;b.fixLayout();k.inputs&&k.inputs().length&&(b.element=k,b.atEnd=!1,b.nextElement())})}; -ScriptFocusMorph.prototype.insertVariableGetter=function(){var a=this,b=this.blockTypes(),c=new MenuMorph;b&&contains(b,"reporter")&&(b=InputSlotMorph.prototype.getVarNamesDict.call(this.element),Object.keys(b).forEach(function(d){var e=SpriteMorph.prototype.variableBlock(d);e.addShadow(new Point(3,3));c.addItem(e,function(){e.removeShadow();a.insertBlock(e)})}),0{f&&(this.atEnd=!0);"receiveCondition"===h.selector&&(d=this.editor.scriptTarget())&&(b=d.parentThatIsA(StageMorph))&&(b.enableCustomHatBlocks=!0,b.threads.pauseCustomHatBlocks=!1,(c=b.parentThatIsA(IDE_Morph))&&c.controlBar.stopButton.refresh()); +this.element=h;this.fixLayout();h.inputs&&h.inputs().length&&(this.element=h,this.atEnd=!1,this.nextElement())})}; +ScriptFocusMorph.prototype.insertVariableGetter=function(){var a=this.blockTypes(),b=new MenuMorph;a&&contains(a,"reporter")&&(a=InputSlotMorph.prototype.getVarNamesDict.call(this.element),Object.keys(a).forEach(c=>{var d=SpriteMorph.prototype.variableBlock(c);d.addShadow(new Point(3,3));b.addItem(d,()=>{d.removeShadow();this.insertBlock(d)})}),0b&&(b=a.length-1);this.element=a[b]}this.element instanceof CommandSlotMorph&&this.element.nestedBlock()?this.lastElement():this.element instanceof HatBlockMorph&&(1=a.length&&(b=0);this.atEnd=!1;this.element=a[b];if(this.element instanceof CommandSlotMorph){if(a=this.element.nestedBlock())this.element=a}else this.element instanceof HatBlockMorph&&(1===a.length?this.atEnd=!0:this.nextElement());this.fixLayout()}else this.shiftScript(new Point(50,0))}; @@ -1186,51 +1118,49 @@ this.element=b:(this.element=a,this.atEnd=!0);this.fixLayout()}};ScriptFocusMorp ScriptFocusMorph.prototype.lastScript=function(){var a=this.sortedScripts();if(!(1>a.length)){this.element instanceof ScriptsMorph&&(this.element=a[0]);var b=a.indexOf(this.element.topBlock())-1;0>b&&(b=a.length-1);this.element=a[b];this.element.scrollIntoView();this.atEnd=!1;if(this.element instanceof HatBlockMorph)return this.nextElement();this.fixLayout()}}; ScriptFocusMorph.prototype.shiftScript=function(a){var b=this,c;this.element instanceof ScriptsMorph?(this.moveBy(a),this.editor.adjustBounds(),this.fixLayout()):!(c=this.element.topBlock())||c instanceof PrototypeHatBlockMorph||(a=c.topLeft().add(a),SnapActions.setBlockPosition(c,a).then(function(){b.editor.adjustBounds();b.fixLayout()}))}; ScriptFocusMorph.prototype.newScript=function(){var a=this.position();this.element instanceof ScriptsMorph||(a=this.element.topBlock().fullBounds().bottomLeft().add(new Point(0,50)));this.setPosition(a);this.element=this.editor;this.editor.adjustBounds();this.fixLayout()};ScriptFocusMorph.prototype.runScript=function(){this.element instanceof ScriptsMorph||this.element.topBlock().mouseClickLeft()}; -ScriptFocusMorph.prototype.items=function(){return this.element instanceof ScriptsMorph?[]:this.element.topBlock().allChildren().filter(function(a){return a instanceof SyntaxElementMorph&&!(a instanceof TemplateSlotMorph)&&(!a.isStatic||a.choices||a instanceof BooleanSlotMorph||a instanceof RingMorph||a instanceof MultiArgMorph||a instanceof CommandSlotMorph)})}; -ScriptFocusMorph.prototype.sortedScripts=function(){var a=this.editor.children.filter(function(b){return b instanceof BlockMorph});a.sort(function(b,c){return b instanceof PrototypeHatBlockMorph?0:b.top()-c.top()});return a}; +ScriptFocusMorph.prototype.items=function(){return this.element instanceof ScriptsMorph?[]:this.element.topBlock().allChildren().filter(a=>a instanceof SyntaxElementMorph&&!(a instanceof TemplateSlotMorph)&&(!a.isStatic||a.choices||a instanceof BooleanSlotMorph||a instanceof RingMorph||a instanceof MultiArgMorph||a instanceof CommandSlotMorph))}; +ScriptFocusMorph.prototype.sortedScripts=function(){var a=this.editor.children.filter(b=>b instanceof BlockMorph);a.sort((b,c)=>b instanceof PrototypeHatBlockMorph?0:b.top()-c.top());return a}; ScriptFocusMorph.prototype.blockTypes=function(){return this.element.isTemplate?null:this.element instanceof ScriptsMorph?["hat","command","reporter","predicate","ring"]:this.element instanceof HatBlockMorph||this.element instanceof CommandSlotMorph?["command"]:this.element instanceof CommandBlockMorph?this.atEnd&&this.element.isStop()?null:this.element.parent instanceof ScriptsMorph?["hat","command"]:["command"]:this.element instanceof ReporterBlockMorph?"%n"===this.element.getSlotSpec()?["reporter"]: ["reporter","predicate","ring"]:"%n"===this.element.getSpec()?["reporter"]:this.element.isStatic?null:["reporter","predicate","ring"]};ScriptFocusMorph.prototype.processKeyDown=function(a){this.processKeyEvent(a,this.reactToKeyEvent)};ScriptFocusMorph.prototype.processKeyUp=function(a){nop(a)};ScriptFocusMorph.prototype.processKeyPress=function(a){nop(a)}; ScriptFocusMorph.prototype.processKeyEvent=function(a,b){this.world().hand.destroyTemporaries();switch(a.keyCode){case 8:var c="backspace";break;case 9:c="tab";break;case 13:c="enter";break;case 16:case 17:case 18:return;case 27:c="esc";break;case 32:c="space";break;case 37:c="left arrow";break;case 39:c="right arrow";break;case 38:c="up arrow";break;case 40:c="down arrow";break;default:c=String.fromCharCode(a.keyCode||a.charCode)}b.call(this,(a.ctrlKey||a.metaKey?"ctrl ":"")+(a.shiftKey?"shift ": "")+c)}; ScriptFocusMorph.prototype.reactToKeyEvent=function(a){var b;switch(a.toLowerCase()){case "esc":return this.stopEditing();case "enter":return this.trigger();case "shift enter":return this.newScript();case "ctrl shift enter":return this.runScript();case "space":return this.menu();case "left arrow":return this.lastElement();case "shift left arrow":return this.shiftScript(new Point(-50,0));case "right arrow":return this.nextElement();case "shift right arrow":return this.shiftScript(new Point(50,0)); case "up arrow":return this.lastCommand();case "shift up arrow":return this.shiftScript(new Point(0,-50));case "down arrow":return this.nextCommand();case "shift down arrow":return this.shiftScript(new Point(0,50));case "tab":return this.nextScript();case "shift tab":return this.lastScript();case "backspace":return this.deleteLastElement();case "ctrl z":return SnapUndo.undo(this.editor.owner);case "ctrl y":case "ctrl shift z":return SnapUndo.redo(this.editor.owner);case "ctrl [":break;default:var c= -this.blockTypes();this.element instanceof ScriptsMorph||!c||!contains(c,"reporter")||(b=Object.keys(this.element.getVarNamesDict()));c&&(delete this.fps,delete this.step,this.show(),this.editor.scriptTarget().searchBlocks(a,c,b,this))}};function getInputTypeMeta(){return utils.getUrlSyncCached(SERVER_URL+"/services/input-types",function(a){return JSON.parse(a)})} +this.blockTypes();this.element instanceof ScriptsMorph||!c||!contains(c,"reporter")||(b=Object.keys(this.element.getVarNamesDict()));c&&(delete this.fps,delete this.step,this.show(),this.editor.scriptTarget().searchBlocks(a,c,b,this))}};function getInputTypeMeta(){return utils.getUrlSyncCached(`${SERVER_URL}/services/input-types`,a=>JSON.parse(a))} function sortDict(a){for(var b=Object.keys(a).sort(),c={},d=0;df.description))a+=`\n${e.name}: ${e.description} ${e.optional?"[optional]":""}`;a+=`\n\nDocumentation can be found at:\n${SERVER_URL}/docs/services/${b}/${d.categories&& +d.categories.length?d.categories[0]:"index"}.html#${b}.${c}`}else a=d.description,a+=`\n\nDocumentation can be found at:\n${SERVER_URL}/docs/services/${b}/index.html`;a||="Description not available"}else d=await Services.getServicesMetadata(),a=d.slice(0,3).map(function(e){return e.name}),a="Get information from different providers, save information and more. \nTo get more help select one of the services: "+a.join(", ")+" ...";b=this.fullCopy();b instanceof CommandBlockMorph&&(c=b.nextBlock())&&c.destroy(); +b.inputs().slice(2).forEach(function(e){e instanceof HintInputSlotMorph?e.setContents(""):e.userDestroy()});b.addShadow();(new DialogBoxMorph).inform("Help",a,this.world(),b.fullImage())};BlockMorph.prototype.isServiceBlock=function(){return contains(["getJSFromRPCStruct","doRunRPC"],this.selector)};MultiHintArgMorph.prototype=new MultiArgMorph;MultiHintArgMorph.prototype.constructor=MultiHintArgMorph;MultiHintArgMorph.uber=MultiArgMorph.prototype;MultiHintArgMorph.prototype.executeOnSliderEdit=!1; +function MultiHintArgMorph(a,b,c,d,e,f,g,h,k){this.init(a,b,c,d,e,f,g,h,k)}MultiHintArgMorph.prototype.init=function(a,b,c,d,e,f,g,h,k){this.hintText=a||"";MultiHintArgMorph.uber.init.call(this,"%s",b,c,d,e,f,g,h,k);0===this.inputs().length&&this.addInput()};MultiHintArgMorph.prototype.addInput=function(){var a=this.labelPart("%hint"+this.hintText),b=this.children.length-1;a.parent=this;this.children.splice(b,0,a);a.rerender();this.fixLayout()}; MultiHintArgMorph.prototype.mouseClickLeft=function(a){var b=this.selectForEdit(),c=b.arrows(),d=c.children[0];c=c.children[1];var e=16===b.world().currentKey?3:1;if(c.bounds.containsPoint(a))for(a=0;a{if(!this.fieldsFor||!this.fieldsFor[b])if(this.methodSignature(),!this.fieldsFor){this.fieldsFor={};var c='Service "'+this.getServiceName()+'" is not available';world.children[0].showMessage&&world.children[0].showMessage(c)}if(this.fieldsFor[b])return this.fieldsFor[b].args};StructInputSlotMorph.call(this,null,!1,"methodSignature",b=>{if(b=a(b))return b.map(c=>c.name)},!0,a)} +RPCInputSlotMorph.prototype.getServiceInputSlot=function(){var a=this.parent.inputs();var b=a.indexOf(this);return a[b-1]};RPCInputSlotMorph.prototype.getServiceName=function(){var a=this.getServiceInputSlot();return a?a.constant?([a]=a.evaluate(),a.split("/").pop()):a.evaluate():null};RPCInputSlotMorph.prototype.getServiceMetadata=function(){var a=this.getServiceInputSlot();a=a.constant?a.evaluate()[0]:Services.defaultHost.url+"/"+a.evaluate();return Services.getServiceMetadataFromURLSync(a)}; +RPCInputSlotMorph.prototype.methodSignature=function(){function a(f,g){g.reduce((h,k)=>{h[k]||(h[k]={});return h[k]},b)[f]=f}var b={};const c=this.getServiceName();if(c){try{var d=this.getServiceMetadata();this.fieldsFor=d.rpcs;var e=Object.keys(this.fieldsFor);this.isCurrentRPCSupported=!0}catch(f){this.isCurrentRPCSupported=!1,e=this.parentThatIsA(BlockMorph),e.showBubble(localize('Service "'+c+'" is not available')),e=[]}e.forEach(f=>{const {deprecated:g,categories:h=[]}=this.fieldsFor[f];g||(h.length? +h.forEach(k=>a(f,k)):a(f,[]))})}return sortDict(b)};RPCInputSlotMorph.prototype.evaluate=function(){if(!this.isCurrentRPCSupported){var a=InputSlotMorph.prototype.evaluate.call(this);a=this.getFieldNames(a);this.isCurrentRPCSupported&&(this.fields=a)}return RPCInputSlotMorph.uber.evaluate.call(this)};HintInputSlotMorph.prototype=new InputSlotMorph;HintInputSlotMorph.prototype.constructor=HintInputSlotMorph;HintInputSlotMorph.uber=InputSlotMorph.prototype; +function HintInputSlotMorph(a,b,c,d,e){var f=this;this.hintText=b;this.empty=!0;InputSlotMorph.call(this,a,c,d,e);d||(this.contents().mouseClickLeft=function(){f.isEmptySlot()&&(this.text="");StringMorph.prototype.mouseClickLeft.apply(this,arguments)})}HintInputSlotMorph.prototype.evaluate=function(){return this.isEmptySlot()?"":InputSlotMorph.prototype.evaluate.call(this)};const WHITE_HINT=new Color(190,190,190),BLACK_HINT=new Color(100,100,100); +HintInputSlotMorph.prototype.setContents=function(a){const b=this.contents();let c;InputSlotMorph.prototype.setContents.apply(this,arguments);this.overrideBlack=this.overrideWhite=null;this.empty=!a||""===a;this.isEmptySlot()?(b.text=this.hintText,this.isReadOnly&&(this.overrideWhite=WHITE_HINT,this.overrideBlack=BLACK_HINT),c=this.isReadOnly?WHITE_HINT:BLACK_HINT):c=this.isReadOnly?WHITE:BLACK;b.fixLayout();b.color=c;b.rerender()};HintInputSlotMorph.prototype.changed=function(){return InputSlotMorph.prototype.changed.call(this)}; HintInputSlotMorph.prototype.isEmptySlot=function(){return this.empty};HintInputSlotMorph.prototype.updateFieldValue=function(a){var b=this.parentThatIsA(BlockMorph);a=void 0!==a?a:this.contents().text;if(b.id)return this.setContents(this.lastValue),SnapActions.setField(this,a);this.setContents(a)}; var addStructReplaceSupport=function(a){return function(b){for(var c,d=-1,e=this.inputs(),f=e.indexOf(b),g=e.length;g--;)e[g]instanceof StructInputSlotMorph&&(d=g,c=e[g]);c&&d=f-d?(d=f-d-1,c=c.getFieldValue(c.fields[d],null,c.fieldsMeta&&d=a;a+=1)NONNUMBERS.push(String.fromCharCode(a));NONNUMBERS.push(String.fromCharCode(160))})(); -function snapEquals(a,b){if(a instanceof List||b instanceof List)return a instanceof List&&b instanceof List?a.equalTo(b):!1;var c=+a,d=+b;if(isNaN(c)||isNaN(d)||[a,b].some(function(e){return contains(NONNUMBERS,e)||isString(e)&&-1=a;a+=1)NONNUMBERS.push(String.fromCharCode(a));NONNUMBERS.push(String.fromCharCode(160))})(); +function snapEquals(a,b){if(a instanceof List||b instanceof List)return a instanceof List&&b instanceof List?a.equalTo(b):!1;var c=+a,d=+b;if(isNaN(c)||isNaN(d)||[a,b].some(e=>contains(NONNUMBERS,e)||isString(e)&&-1d)throw Error(localize(e||"a synchronous Snap! script has timed out"));k.runStep(d)}return h?k.homeContext:k.homeContext.inputs[0]}function ThreadManager(){this.processes=[];this.wantsToPause=!1}ThreadManager.prototype.pauseCustomHatBlocks=!1; ThreadManager.prototype.toggleProcess=function(a,b){var c=this.findProcess(a,b);if(c)c.stop();else return this.startProcess(a,b,null,null,null,!0)}; -ThreadManager.prototype.startProcess=function(a,b,c,d,e,f,g,h,k){a=a.topBlock();var l=this.findProcess(a,b);if(l){if(c)return l;l.stop();l.canBroadcast=!0;this.removeTerminatedProcesses()}var m=new Process(a,b,e,f);m.exportResult=d;m.isClicked=f||!1;m.isAtomic=h||!1;k instanceof VariableFrame&&Object.keys(k.vars).forEach(function(n){return m.context.outerContext.variables.vars[n]=k.vars[n]});(b=a.getHighlight())?(b.threadCount=this.processesForBlock(a).length+1,b.updateReadout()):a.addHighlight(); -this.processes.push(m);g&&m.runStep();return m};ThreadManager.prototype.stopAll=function(a){this.processes.forEach(function(b){b!==a&&b.stop()})};ThreadManager.prototype.stopAllForReceiver=function(a,b){this.processes.forEach(function(c){c.homeContext.receiver===a&&c!==b&&(c.stop(),a.isTemporary&&(c.isDead=!0))})};ThreadManager.prototype.stopAllForBlock=function(a){this.processesForBlock(a,!0).forEach(function(b){return b.stop()})}; -ThreadManager.prototype.stopProcess=function(a,b){(a=this.findProcess(a,b))&&a.stop()};ThreadManager.prototype.pauseAll=function(a){this.processes.forEach(function(b){return b.pause()});a&&a.pauseAllActiveSounds()};ThreadManager.prototype.isPaused=function(){return null!==detect(this.processes,function(a){return a.isPaused})};ThreadManager.prototype.resumeAll=function(a){this.processes.forEach(function(b){return b.resume()});a&&a.resumeAllActiveSounds()}; -ThreadManager.prototype.step=function(){var a;if(Process.prototype.enableSingleStepping&&(this.processes.forEach(function(b){b.isInterrupted?(b.runStep(),a=!0):b.lastYield=Date.now()}),this.wantsToPause=.5m.context.outerContext.variables.vars[n]=k.vars[n]);(b=a.getHighlight())?(b.threadCount=this.processesForBlock(a).length+1,b.updateReadout()):a.addHighlight();this.processes.push(m); +g&&m.runStep();return m};ThreadManager.prototype.stopAll=function(a){this.processes.forEach(b=>{b!==a&&b.stop()})};ThreadManager.prototype.stopAllForReceiver=function(a,b){this.processes.forEach(c=>{c.homeContext.receiver===a&&c!==b&&(c.stop(),a.isTemporary&&(c.isDead=!0))})};ThreadManager.prototype.stopAllForBlock=function(a){this.processesForBlock(a,!0).forEach(b=>b.stop())};ThreadManager.prototype.stopProcess=function(a,b){(a=this.findProcess(a,b))&&a.stop()}; +ThreadManager.prototype.pauseAll=function(a){this.processes.forEach(b=>b.pause());a&&a.pauseAllActiveSounds()};ThreadManager.prototype.isPaused=function(){return null!==detect(this.processes,a=>a.isPaused)};ThreadManager.prototype.resumeAll=function(a){this.processes.forEach(b=>b.resume());a&&a.resumeAllActiveSounds()}; +ThreadManager.prototype.step=function(){var a;if(Process.prototype.enableSingleStepping&&(this.processes.forEach(b=>{b.isInterrupted?(b.runStep(),a=!0):b.lastYield=Date.now()}),this.wantsToPause=.5{b.homeContext.receiver.isPickedUp()||b.isDead||b.runStep()});this.removeTerminatedProcesses()}; +ThreadManager.prototype.removeTerminatedProcesses=function(){var a=[],b;this.processes.forEach(c=>{if(!c.isRunning()&&!c.errorFlag||c.isDead){if(c.topBlock instanceof BlockMorph)if(c.unflash(),b=this.processesForBlock(c.topBlock).length){var d=c.topBlock.getHighlight()||c.topBlock.addHighlight();d.threadCount=b;d.updateReadout()}else c.topBlock.removeHighlight();c.prompter&&(c.prompter.destroy(),c.homeContext.receiver.stopTalking&&c.homeContext.receiver.stopTalking());if(c.topBlock instanceof ReporterBlockMorph|| +c.isShowingResult)if(d=c.homeContext.inputs[0],c.onComplete instanceof Function)c.onComplete(d);else d instanceof List?c.topBlock.showBubble(d.isTable()?new TableFrameMorph(new TableMorph(d,10)):new ListWatcherMorph(d),c.exportResult,c.receiver):c.topBlock.showBubble(d,c.exportResult,c.receiver);else if(c.onComplete instanceof Function)c.onComplete()}else a.push(c)});this.processes=a}; +ThreadManager.prototype.findProcess=function(a,b){var c=a.topBlock();return detect(this.processes,d=>d.topBlock===c&&d.receiver===b)};ThreadManager.prototype.processesForBlock=function(a,b){var c=b?a:a.topBlock();return this.processes.filter(d=>d.topBlock===c&&d.isRunning()&&!d.isDead)}; ThreadManager.prototype.doWhen=function(a,b,c){if(!this.pauseCustomHatBlocks&&a&&!this.findProcess(a,b)){var d=a.inputs()[0],e;a.removeHighlight()&&(e=a.world())&&e.hand.destroyTemporaries();if(!c){try{var f=invoke(d,null,b,50,"the predicate takes\ntoo long for a\ncustom hat block",!0,null,!0)}catch(g){a.addErrorHighlight(),a.showBubble(g.name+"\n"+g.message)}(!0===f||f&&f.inputs&&!0===f.inputs[0])&&this.startProcess(a,b,null,null,null,null,!0,null,f.variables)}}}; -ThreadManager.prototype.toggleSingleStepping=function(){Process.prototype.enableSingleStepping=!Process.prototype.enableSingleStepping;Process.prototype.enableSingleStepping||this.processes.forEach(function(a){a.isPaused||a.unflash()})};Process.prototype={};Process.prototype.constructor=Process;Process.prototype.timeout=500;Process.prototype.isCatchingErrors=!0;Process.prototype.enableHyperOps=!0;Process.prototype.enableLiveCoding=!1;Process.prototype.enableSingleStepping=!1; +ThreadManager.prototype.toggleSingleStepping=function(){Process.prototype.enableSingleStepping=!Process.prototype.enableSingleStepping;Process.prototype.enableSingleStepping||this.processes.forEach(a=>{a.isPaused||a.unflash()})};Process.prototype={};Process.prototype.constructor=Process;Process.prototype.timeout=500;Process.prototype.isCatchingErrors=!0;Process.prototype.enableHyperOps=!0;Process.prototype.enableLiveCoding=!1;Process.prototype.enableSingleStepping=!1; Process.prototype.enableCompiling=!1;Process.prototype.flashTime=0; function Process(a,b,c,d){this.topBlock=a||null;this.instrument=(this.receiver=b||(a?a.scriptTarget():null))?this.receiver.instrument:null;this.errorFlag=this.isShowingResult=this.isClicked=this.isDead=this.readyToTerminate=this.readyToYield=!1;this.context=null;this.homeContext=new Context(null,null,null,this.receiver);this.lastYield=Date.now();this.isFirstStep=!0;this.isAtomic=!1;this.rpcRequest=this.httpRequest=this.prompter=null;this.isPaused=!1;this.pauseOffset=null;this.frameCount=0;this.exportResult= !1;this.onComplete=c||null;this.procedureCount=0;this.flashingContext=null;this.isInterrupted=!1;this.canBroadcast=!0;a&&(this.homeContext.variables.parentFrame=this.homeContext.receiver.variables,this.context=new Context(null,a.blockSequence(),this.homeContext),d&&this.pushContext("doYield"))}Process.prototype.isRunning=function(){return!this.readyToTerminate&&(this.context||this.isPaused)}; @@ -1249,8 +1179,8 @@ Process.prototype.evaluateInput=function(a){if(!this.flashContext()){if(a.bindin Process.prototype.evaluateSequence=function(a){var b=this.context.pc,c=this.context.outerContext,d=this.context.isCustomBlock;b===a.length-1?(this.context=new Context(this.context.parentContext,a[b],this.context.outerContext,this.context.receiver),this.context.isCustomBlock=d):b>=a.length?this.popContext():(this.context.pc+=1,this.pushContext(a[b],c))}; Process.prototype.evaluateNextInput=function(a){var b=this.context.inputs.length;a=a.inputs()[b];b=this.context.expression.selector;var c=this.context.outerContext;a.isUnevaluated?!0===a.isUnevaluated||a.isUnevaluated()?"reify"===b||"reportScript"===b?this.context.addInput(a):this.context.addInput(this.reify(a,new List)):this.pushContext(a,c):this.pushContext(a,c)};Process.prototype.doYield=function(){this.popContext();this.isAtomic||(this.readyToYield=!0)};Process.prototype.expectReport=function(){this.handleError(Error("reporter didn't report"))}; Process.prototype.handleError=function(a,b){var c=b;this.stop();this.errorFlag=!0;this.topBlock.addErrorHighlight();if(isNil(c)||isNil(c.world()))c=this.topBlock;c.showBubble((c===b?"":"Inside: ")+a.name+"\n"+a.message,this.exportResult,this.receiver)};Process.prototype.errorObsolete=function(){throw Error("a custom block definition is missing");}; -Process.prototype.reify=function(a,b,c){var d=new Context(null,null,this.context?this.context.outerContext:null),e=0;a?(d.expression=this.enableLiveCoding||this.enableSingleStepping?a:a.fullCopy(),d.expression.show(),c||b.length()||(d.expression.allEmptySlots().forEach(function(f){e+=1;f.bindingID=f instanceof MultiArgMorph?Symbol.for("arguments"):e}),d.emptySlots=e)):d.expression=this.enableLiveCoding||this.enableSingleStepping?[this.context.expression]:[this.context.expression.fullCopy()];d.inputs= -b.asArray();d.receiver=this.context?this.context.receiver:this.receiver;d.origin=d.receiver;return d};Process.prototype.reportScript=function(a,b){return this.reify(b,a)};Process.prototype.reifyScript=function(a,b){return this.reify(a,b)};Process.prototype.reifyReporter=function(a,b){return this.reify(a,b)};Process.prototype.reifyPredicate=function(a,b){return this.reify(a,b)};Process.prototype.reportJSFunction=function(a,b){return Function.apply(null,a.asArray().concat([b]))}; +Process.prototype.reify=function(a,b,c){var d=new Context(null,null,this.context?this.context.outerContext:null),e=0;a?(d.expression=this.enableLiveCoding||this.enableSingleStepping?a:a.fullCopy(),d.expression.show(),c||b.length()||(d.expression.allEmptySlots().forEach(f=>{e+=1;f.bindingID=f instanceof MultiArgMorph?Symbol.for("arguments"):e}),d.emptySlots=e)):d.expression=this.enableLiveCoding||this.enableSingleStepping?[this.context.expression]:[this.context.expression.fullCopy()];d.inputs=b.asArray(); +d.receiver=this.context?this.context.receiver:this.receiver;d.origin=d.receiver;return d};Process.prototype.reportScript=function(a,b){return this.reify(b,a)};Process.prototype.reifyScript=function(a,b){return this.reify(a,b)};Process.prototype.reifyReporter=function(a,b){return this.reify(a,b)};Process.prototype.reifyPredicate=function(a,b){return this.reify(a,b)};Process.prototype.reportJSFunction=function(a,b){return Function.apply(null,a.asArray().concat([b]))}; Process.prototype.doRun=function(a,b){return this.evaluate(a,b,!0)}; Process.prototype.evaluate=function(a,b,c){if(!a)return this.returnValueToParentContext(null);if(a instanceof Function)return a.apply(this.blockReceiver(),b.asArray().concat([this]));if(a.isContinuation)return this.runContinuation(a,b);if(!(a instanceof Context))throw Error("expecting a ring but getting "+a);var d=new Context(null,null,a.outerContext),e=this.context.parentContext,f=b.asArray();d.receiver||(d.receiver=a.receiver);var g=new Context(this.context.parentContext,a.expression,d,a.receiver); g.isCustomCommand=c;this.context.parentContext=g;a.expression instanceof ReporterBlockMorph&&(this.readyToYield=Date.now()-this.lastYield>this.timeout);d.variables.addVar(Symbol.for("arguments"),b);if(0 -this.timeout):(b.expression.tagExitBlocks(this.procedureCount,!0),a&&!a.tag&&(a.tag=this.procedureCount),!this.isAtomic&&c.isDirectlyRecursive()&&(this.readyToYield=!0));b.expression=b.expression.blockSequence()};Process.prototype.doDeclareVariables=function(a){var b=this.context.outerContext.variables;a.asArray().forEach(function(c){return b.addVar(c)})}; +this.timeout):(b.expression.tagExitBlocks(this.procedureCount,!0),a&&!a.tag&&(a.tag=this.procedureCount),!this.isAtomic&&c.isDirectlyRecursive()&&(this.readyToYield=!0));b.expression=b.expression.blockSequence()};Process.prototype.doDeclareVariables=function(a){var b=this.context.outerContext.variables;a.asArray().forEach(c=>b.addVar(c))}; Process.prototype.doSetVar=function(a,b){var c=this.context.variables;a instanceof Context?"reportGetVar"===a.expression.selector?a.variables.setVar(a.expression.blockSpec,b,this.blockReceiver()):this.doSet(a,b):a instanceof Array?this.doSet(a,b):c.setVar(a,b,this.blockReceiver())}; Process.prototype.doChangeVar=function(a,b){var c=this.context.variables;a instanceof Context&&"reportGetVar"===a.expression.selector?a.variables.changeVar(a.expression.blockSpec,b,this.blockReceiver()):c.changeVar(a,b,this.blockReceiver())};Process.prototype.reportGetVar=function(){return this.context.variables.getVar(this.context.expression.blockSpec)}; -Process.prototype.doShowVar=function(a){var b=(this.context||this.homeContext).variables,c,d,e=a;if(e instanceof Context)if("reportGetVar"===e.expression.selector)e=e.expression.blockSpec;else{this.doChangePrimitiveVisibility(e.expression,!1);return}if(this.homeContext.receiver&&(c=this.homeContext.receiver.parentThatIsA(StageMorph))&&(d=b.silentFind(e))){b=detect(c.children,function(g){return g instanceof WatcherMorph&&g.target===d&&g.getter===e});if(null!==b)b.show(),b.fixLayout();else{b=(b=contains(this.homeContext.receiver.globalVariables().names(), +Process.prototype.doShowVar=function(a){var b=(this.context||this.homeContext).variables,c,d,e=a;if(e instanceof Context)if("reportGetVar"===e.expression.selector)e=e.expression.blockSpec;else{this.doChangePrimitiveVisibility(e.expression,!1);return}if(this.homeContext.receiver&&(c=this.homeContext.receiver.parentThatIsA(StageMorph))&&(d=b.silentFind(e))){b=detect(c.children,g=>g instanceof WatcherMorph&&g.target===d&&g.getter===e);if(null!==b)b.show(),b.fixLayout();else{b=(b=contains(this.homeContext.receiver.globalVariables().names(), a))||d.owner?e:e+" "+localize("(temporary)");b=new WatcherMorph(b,SpriteMorph.prototype.blockColor.variables,d,e);b.setPosition(c.position().add(10));var f=c.watchers(b.left());0f instanceof WatcherMorph&&f.target===e&&f.getter===d);null!==b&&(b.isTemporary()?b.destroy():b.hide());c.refreshVariableWatcher(a)}}; +Process.prototype.doRemoveTemporaries=function(){var a;this.homeContext.receiver&&(a=this.homeContext.receiver.parentThatIsA(StageMorph))&&a.watchers().forEach(b=>{b.isTemporary()&&b.destroy()})}; Process.prototype.doChangePrimitiveVisibility=function(a,b){var c=this.homeContext.receiver.parentThatIsA(IDE_Morph);c&&"evaluateCustomBlock"!==a.selector&&(b?StageMorph.prototype.hiddenPrimitives[a.selector]=!0:delete StageMorph.prototype.hiddenPrimitives[a.selector],a={doWarp:"control",reifyScript:"operators",reifyReporter:"operators",reifyPredicate:"operators",doDeclareVariables:"variables"}[this.selector]||this.category,"lists"===a&&(a="variables"),c.flushBlocksCache(a),c.refreshPalette())}; Process.prototype.doDeleteAttr=function(a){var b=this.blockReceiver();if(a instanceof Context)if("reportGetVar"===a.expression.selector)a=a.expression.blockSpec;else{a={xPosition:"x position",yPosition:"y position",direction:"direction",getCostumeIdx:"costume #",size:"size"}[a.expression.selector];isNil(a)||b.inheritAttribute(a);return}if(a instanceof Array)return b.inheritAttribute(this.inputOption(a));contains(b.inheritedVariableNames(!0),a)&&b.deleteVariable(a)}; Process.prototype.doTellTo=function(a,b,c){this.doRun(this.reportAttributeOf(b,a),c)};Process.prototype.reportAskFor=function(a,b,c){this.evaluate(this.reportAttributeOf(b,a),c)};Process.prototype.reportNewList=function(a){return a};Process.prototype.reportCONS=function(a,b){this.assertType(b,"list");return(new List).cons(a,b)};Process.prototype.reportCDR=function(a){this.assertType(a,"list");return a.cdr()}; @@ -1280,14 +1210,14 @@ Process.prototype.reportTranspose=function(a){this.assertType(a,"list");return a Process.prototype.reportListAttribute=function(a,b){switch(this.inputOption(a)){case "length":return this.assertType(b,"list"),b.length();case "size":return this.assertType(b,"list"),b.size();case "rank":return b instanceof List?b.rank():0;case "dimensions":return b instanceof List?b.shape():new List;case "flatten":return b instanceof List?b.ravel():new List([b]);case "columns":return this.assertType(b,"list"),b.columns();case "transpose":return this.assertType(b,"list"),b.transpose();case "reverse":return this.assertType(b, "list"),b.reversed();case "lines":this.assertType(b,"list");if(b.canBeTXT())return b.asTXT();throw Error(localize("unable to convert to")+" "+localize("lines"));case "csv":this.assertType(b,"list");if(b.canBeCSV())return b.asCSV();throw Error(localize("unable to convert to")+" "+localize("CSV"));case "json":this.assertType(b,"list");if(b.canBeJSON())return b.asJSON();throw Error(localize("unable to convert to")+" "+localize("JSON"));default:return 0}}; Process.prototype.reportListLength=function(a){this.assertType(a,"list");return a.length()};Process.prototype.reportListIndex=function(a,b){this.assertType(b,"list");return b.indexOf(a)};Process.prototype.reportListContainsItem=function(a,b){this.assertType(a,"list");return a.contains(b)};Process.prototype.reportListIsEmpty=function(a){this.assertType(a,"list");return a.isEmpty()};Process.prototype.doShowTable=function(a){this.assertType(a,"list");(new TableDialogMorph(a)).popUp(this.blockReceiver().world())}; -Process.prototype.reportNumbers=function(a,b){var c=this;return this.enableHyperOps?this.hyperDyadic(function(d,e){return c.reportBasicNumbers(d,e)},a,b):this.reportLinkedNumbers(a,b)};Process.prototype.reportBasicNumbers=function(a,b){var c;a=+a;var d=+b;b=a;this.assertType(a,"number");this.assertType(d,"number");if(d>a)for(d=Math.floor(d-a),a=Array(d),c=0;c<=d;c+=1)a[c]=b,b+=1;else for(d=Math.floor(a-d),a=Array(d),c=0;c<=d;c+=1)a[c]=b,--b;return new List(a)}; +Process.prototype.reportNumbers=function(a,b){return this.enableHyperOps?this.hyperDyadic((c,d)=>this.reportBasicNumbers(c,d),a,b):this.reportLinkedNumbers(a,b)};Process.prototype.reportBasicNumbers=function(a,b){var c;a=+a;var d=+b;b=a;this.assertType(a,"number");this.assertType(d,"number");if(d>a)for(d=Math.floor(d-a),a=Array(d),c=0;c<=d;c+=1)a[c]=b,b+=1;else for(d=Math.floor(a-d),a=Array(d),c=0;c<=d;c+=1)a[c]=b,--b;return new List(a)}; Process.prototype.reportConcatenatedLists=function(a){var b,c;this.assertType(a,"list");if(a.isEmpty())return a;var d=a.at(1);this.assertType(d,"list");if(d.isLinked)return this.concatenateLinkedLists(a);d=[];var e=a.length();for(b=1;b<=e;b+=1){var f=a.at(b);this.assertType(f,"list");var g=f.length();for(c=1;c<=g;c+=1)d.push(f.at(c))}return new List(d)}; Process.prototype.concatenateLinkedLists=function(a){if(a.isEmpty())return a;var b=a.at(1);this.assertType(b,"list");return 1===a.length()?b:b.isEmpty()?this.concatenateLinkedLists(a.cdr()):a.cons(b.at(1),this.concatenateLinkedLists(a.cons(b.cdr(),a.cdr())))}; Process.prototype.reportLinkedNumbers=function(a,b){null===this.context.accumulator&&(this.assertType(a,"number"),this.assertType(b,"number"),this.context.accumulator={target:new List,end:null,idx:+a,step:+b>+a?1:-1},this.context.accumulator.target.isLinked=!0,this.context.accumulator.end=this.context.accumulator.target);a=this.context.accumulator;(1===a.step?a.idx>+b:a.idx<+b)?(a.end.rest=new List,this.returnValueToParentContext(a.target.cdr())):(a.end.rest=a.target.cons(a.idx),a.end=a.end.rest, a.idx+=a.step,this.pushContext())};Process.prototype.doIf=function(){var a=this.context.inputs,b=this.context.outerContext,c=this.context.isCustomBlock;this.popContext();a[0]&&a[1]&&(this.pushContext(a[1].blockSequence(),b),this.context.isCustomBlock=c);this.pushContext()}; Process.prototype.doIfElse=function(){var a=this.context.inputs,b=this.context.outerContext,c=this.context.isCustomBlock;this.popContext();a[0]?a[1]&&this.pushContext(a[1].blockSequence(),b):a[2]?this.pushContext(a[2].blockSequence(),b):this.pushContext("doYield");this.context&&(this.context.isCustomBlock=c);this.pushContext()}; Process.prototype.reportIfElse=function(a){var b=this.context.inputs;1>b.length?this.evaluateNextInput(a):1{b.stopTalking&&b.stopTalking()}),a.removeAllClones();if(a=a.parentThatIsA(IDE_Morph))a.controlBar.pauseButton.refresh(), a.controlBar.stopButton.refresh()}};Process.prototype.doStopThis=function(a){switch(this.inputOption(a)){case "all":this.doStopAll();break;case "this script":this.doStop();break;case "this block":this.doStopBlock();break;default:this.doStopOthers(a)}}; Process.prototype.doStopOthers=function(a){var b;if(this.homeContext.receiver&&(b=this.homeContext.receiver.parentThatIsA(StageMorph)))switch(this.inputOption(a)){case "all but this script":b.threads.stopAll(this);break;case "other scripts in sprite":b.threads.stopAllForReceiver(this.homeContext.receiver,this);break;default:nop()}}; Process.prototype.doWarp=function(a){var b=this.context.outerContext,c=this.context.isCustomBlock,d;this.popContext();a&&(this.homeContext.receiver&&(this.homeContext.receiver.startWarp&&this.homeContext.receiver.startWarp(),d=this.homeContext.receiver.parentThatIsA(StageMorph))&&(d.fps=0),this.pushContext("popContext"),this.context&&(this.context.isCustomBlock=c),this.isAtomic||this.pushContext("doStopWarping"),this.pushContext(a.blockSequence(),b),this.isAtomic=!0);this.pushContext()}; @@ -1299,7 +1229,7 @@ Process.prototype.doForever=function(a){this.context.inputs=[];this.pushContext( Process.prototype.doUntil=function(a,b){if(a)return this.popContext(),this.pushContext("doYield"),null;this.context.inputs=[];this.pushContext("doYield");b&&this.pushContext(b.blockSequence());this.pushContext()};Process.prototype.doWaitUntil=function(a){if(a)return this.popContext(),this.pushContext("doYield"),null;this.context.inputs=[];this.pushContext("doYield");this.pushContext()}; Process.prototype.doForEach=function(a,b,c){null===this.context.accumulator&&(this.assertType(b,"list"),this.context.accumulator={source:b,remaining:b.length(),idx:0});0!==this.context.accumulator.remaining&&(--this.context.accumulator.remaining,this.context.accumulator.source.isLinked?(b=this.context.accumulator.source.at(1),this.context.accumulator.source=this.context.accumulator.source.cdr()):(this.context.accumulator.idx+=1,b=this.context.accumulator.source.at(this.context.accumulator.idx)),this.pushContext("doYield"), this.pushContext(),this.context.outerContext.variables.addVar(a),this.context.outerContext.variables.setVar(a,b),this.evaluate(c,new List([]),!0))}; -Process.prototype.doFor=function(a,b,c,d){var e=this.context.outerContext.variables,f=this.context.accumulator;null===f?(this.assertType(b,"number"),this.assertType(c,"number"),f=this.context.accumulator={test:+b<+c?function(){return e.getVar(a)>+c}:function(){return e.getVar(a)<+c},step:+b<+c?1:-1,parms:new List},e.addVar(a),e.setVar(a,Math.floor(+b))):e.changeVar(a,f.step);f.test()||(this.pushContext("doYield"),this.pushContext(),this.evaluate(d,f.parms,!0))}; +Process.prototype.doFor=function(a,b,c,d){var e=this.context.outerContext.variables,f=this.context.accumulator;null===f?(this.assertType(b,"number"),this.assertType(c,"number"),f=this.context.accumulator={test:+b<+c?()=>e.getVar(a)>+c:()=>e.getVar(a)<+c,step:+b<+c?1:-1,parms:new List},e.addVar(a),e.setVar(a,Math.floor(+b))):e.changeVar(a,f.step);f.test()||(this.pushContext("doYield"),this.pushContext(),this.evaluate(d,f.parms,!0))}; Process.prototype.reportMap=function(a,b){if(b.isLinked){null===this.context.accumulator?(this.assertType(b,"list"),this.context.accumulator={source:b,idx:1,target:new List,end:null,remaining:b.length()},this.context.accumulator.target.isLinked=!0,this.context.accumulator.end=this.context.accumulator.target):2a.length()){this.returnValueToParentContext(a.length()?a.at(1):0);return}this.context.accumulator= {idx:1,target:a.at(1)}}else 2c.bindingID):2!==a.inputs.length?!1:b.every(c=>"reportGetVar"===c.selector&&contains(a.inputs,c.blockSpec))}; Process.prototype.doWait=function(a){this.context.startTime||(this.context.startTime=Date.now());if(Date.now()-this.context.startTime>=1E3*a)return this.isAtomic||0!==a||(this.readyToYield=!0),null;this.pushContext("doYield");this.pushContext()}; Process.prototype.doGlide=function(a,b,c){this.context.startTime||(this.context.startTime=Date.now(),this.context.startValue=new Point(this.blockReceiver().xPosition(),this.blockReceiver().yPosition()));if(Date.now()-this.context.startTime>=1E3*a)return this.blockReceiver().gotoXY(b,c),null;this.blockReceiver().glide(1E3*a,b,c,Date.now()-this.context.startTime,this.context.startValue);this.pushContext("doYield");this.pushContext()}; Process.prototype.doSayFor=function(a,b){this.context.startTime||(this.context.startTime=Date.now(),this.blockReceiver().bubble(a));if(Date.now()-this.context.startTime>=1E3*b)return this.blockReceiver().stopTalking(),null;this.pushContext("doYield");this.pushContext()}; Process.prototype.doThinkFor=function(a,b){this.context.startTime||(this.context.startTime=Date.now(),this.blockReceiver().doThink(a));if(Date.now()-this.context.startTime>=1E3*b)return this.blockReceiver().stopTalking(),null;this.pushContext("doYield");this.pushContext()};Process.prototype.blockReceiver=function(){return this.context?this.context.receiver||this.homeContext.receiver:this.homeContext.receiver||this.receiver}; Process.prototype.playSound=function(a){return a instanceof List?this.doPlaySoundAtRate(a,44100):this.blockReceiver().doPlaySound(a)};Process.prototype.doPlaySoundUntilDone=function(a){null===this.context.activeAudio&&(this.context.activeAudio=this.playSound(a));if(null===a||this.context.activeAudio.ended||this.context.activeAudio.terminated)return null;this.pushContext("doYield");this.pushContext()}; -Process.prototype.doStopAllSounds=function(){var a=this.homeContext.receiver.parentThatIsA(StageMorph);a&&(a.threads.processes.forEach(function(b){b.context&&(b.context.stopMusic(),b.context.activeAudio&&b.popContext())}),a.stopAllActiveSounds())}; -Process.prototype.doPlaySoundAtRate=function(a,b){if(a instanceof List)var c=a;else{c=a instanceof Sound?a:"number"===typeof a?this.blockReceiver().sounds.at(a):detect(this.blockReceiver().sounds.asArray(),function(k){return k.name===a.toString()});if(!c.audioBuffer){this.decodeSound(c);return}c=this.reportGetSoundAttribute("samples",c)}var d=this.blockReceiver();var e=d.audioContext();var f=d.getGainNode();var g=d.getPannerNode();var h=this.encodeSound(c,b);d.setVolume(d.volume);h.connect(f);g?(f.connect(g), -g.connect(e.destination),d.setPan(d.pan)):f.connect(e.destination);h.pause=h.stop;h.ended=!1;h.onended=function(){return h.ended=!0};h.start();d.parentThatIsA(StageMorph).activeSounds.push(h);return h}; -Process.prototype.reportGetSoundAttribute=function(a,b){var c=b instanceof Sound?b:"number"===typeof b?this.blockReceiver().sounds.at(b):b instanceof List?this.encodeSound(b):detect(this.blockReceiver().sounds.asArray(),function(d){return d.name===b.toString()});a=this.inputOption(a);if("name"===a)return c.name;if(c.audioBuffer)switch(a){case "samples":return c.cachedSamples||(c.cachedSamples=function(d,e){d=d.audioBuffer;var f;if(1{b.context&&(b.context.stopMusic(),b.context.activeAudio&&b.popContext())}),a.stopAllActiveSounds())}; +Process.prototype.doPlaySoundAtRate=function(a,b){if(a instanceof List)var c=a;else{c=a instanceof Sound?a:"number"===typeof a?this.blockReceiver().sounds.at(a):detect(this.blockReceiver().sounds.asArray(),k=>k.name===a.toString());if(!c.audioBuffer){this.decodeSound(c);return}c=this.reportGetSoundAttribute("samples",c)}var d=this.blockReceiver();var e=d.audioContext();var f=d.getGainNode();var g=d.getPannerNode();var h=this.encodeSound(c,b);d.setVolume(d.volume);h.connect(f);g?(f.connect(g),g.connect(e.destination), +d.setPan(d.pan)):f.connect(e.destination);h.pause=h.stop;h.ended=!1;h.onended=()=>h.ended=!0;h.start();d.parentThatIsA(StageMorph).activeSounds.push(h);return h}; +Process.prototype.reportGetSoundAttribute=function(a,b){var c=b instanceof Sound?b:"number"===typeof b?this.blockReceiver().sounds.at(b):b instanceof List?this.encodeSound(b):detect(this.blockReceiver().sounds.asArray(),d=>d.name===b.toString());a=this.inputOption(a);if("name"===a)return c.name;if(c.audioBuffer)switch(a){case "samples":return c.cachedSamples||(c.cachedSamples=function(d,e){d=d.audioBuffer;var f;if(1{a.audioBuffer=f;a.isDecoding=!1},f=>{a.isDecoding=!1;this.handleError(f)})}this.pushContext("doYield");this.pushContext()}; Process.prototype.encodeSound=function(a,b){var c=this.blockReceiver().audioContext(),d=a.at(1)instanceof List?a.length():1,e=1===d?a.length():a.at(1).length();b=c.createBuffer(d,e,+b||44100);var f;b.copyToChannel||(b.copyToChannel=function(g,h){h=this.getChannelData(h);for(f=0;f{c.src=d.result;this.context.accumulator.audio=c};d.readAsDataURL(a)}if(this.context.accumulator.audio)return new Sound(this.context.accumulator.audio,this.blockReceiver().newSoundName(localize("sound")));this.pushContext("doYield"); this.pushContext()};Process.prototype.audioBufferToWav=function(a,b){var c=a.numberOfChannels,d=a.sampleRate;b=(b||{}).float32?3:1;var e=3===b?32:16;if(2===c){var f=a.getChannelData(0);a=a.getChannelData(1);for(var g=f.length+a.length,h=new Float32Array(g),k=0,l=0;ku?32768*u:32767*u,!0)}}function h(p,r,q){for(var t=0;tu?32768*u:32767*u,!0)}}function h(p,q,r){for(var t=0;tb.scale?this.prompter.setWidth(b.width()-10):this.prompter.setWidth(b.dimensions.x-20),this.prompter.fixLayout(),this.prompter.setCenter(b.center()), +Process.prototype.doAsk=function(a){var b=this.homeContext.receiver.parentThatIsA(StageMorph),c=this.blockReceiver(),d=c instanceof StageMorph,e=c instanceof SpriteMorph&&!c.isVisible;b.keysPressed={};if(!this.prompter){var f=detect(b.children,g=>g instanceof StagePrompterMorph);f||(d||e||c.bubble(a,!1,!0),this.prompter=new StagePrompterMorph(d||e?a:null),1>b.scale?this.prompter.setWidth(b.width()-10):this.prompter.setWidth(b.dimensions.x-20),this.prompter.fixLayout(),this.prompter.setCenter(b.center()), this.prompter.setBottom(b.bottom()-this.prompter.border),b.add(this.prompter),this.prompter.inputField.edit(),b.changed())}else if(this.prompter.isDone)return b.lastAnswer=this.prompter.inputField.getValue(),this.prompter.destroy(),this.prompter=null,d||c.stopTalking(),null;this.pushContext("doYield");this.pushContext()};Process.prototype.reportLastAnswer=function(){return this.homeContext.receiver.parentThatIsA(StageMorph).lastAnswer}; Process.prototype.reportURL=function(a){if(!this.httpRequest){if(0>a.indexOf("//")||8this.getOtherObject(g,e,b));else return}else f=b.children.concat(b);""!==c&&(b.lastMessage=a,f.forEach(g=>{isSnapObject(g)&& +g.allHatBlocksFor(c).forEach(h=>{d.push(b.threads.startProcess(h,g,b.isThreadSafe))})}),(b.messageCallbacks[""]||[]).forEach(g=>g(c)),(b.messageCallbacks[c]||[]).forEach(g=>g()));return d}; +Process.prototype.doBroadcastAndWait=function(a){this.context.activeSends||(this.context.activeSends=this.doBroadcast(a),this.isRunning()&&this.context.activeSends.forEach(b=>b.runStep()));this.context.activeSends=this.context.activeSends.filter(b=>b.isRunning());if(0===this.context.activeSends.length)return null;this.pushContext("doYield");this.pushContext()}; Process.prototype.getLastMessage=function(){var a;return this.homeContext.receiver&&(a=this.homeContext.receiver.parentThatIsA(StageMorph))?a.getLastMessage():""};Process.prototype.doSend=function(a,b){var c=this.homeContext.receiver.parentThatIsA(StageMorph);this.doBroadcast(new List([a,b instanceof List?b:b===c.name?new List([c]):new List([b])]))};Process.prototype.reportIsA=function(a,b){return this.reportTypeOf(a)===this.inputOption(b)}; Process.prototype.assertType=function(a,b){a=this.reportTypeOf(a);if(a===b||b instanceof Array&&contains(b,a))return!0;throw Error("expecting "+b+" but getting "+a);};Process.prototype.assertAlive=function(a){if(a&&a.isCorpse)throw Error("cannot operate on a deleted sprite");}; Process.prototype.reportTypeOf=function(a){return null===a||void 0===a?"nothing":!0===a||!1===a?"Boolean":a instanceof List?"list":parseFloat(a)===+a?"number":isString(a)?"text":a instanceof SpriteMorph?"sprite":a instanceof StageMorph?"stage":a instanceof Costume?"costume":a instanceof Sound?"sound":a instanceof Context?a.expression instanceof RingMorph?a.expression.dataType():a.expression instanceof ReporterBlockMorph?a.expression.isPredicate?"predicate":"reporter":a.expression instanceof Array? (a=a.expression[a.pc||0],a.isPredicate?"predicate":a instanceof RingMorph?a.dataType():a instanceof ReporterBlockMorph?"reporter":a instanceof CommandBlockMorph?"command":"reporter"):a.expression instanceof CommandBlockMorph?"command":"reporter":"undefined"}; -Process.prototype.hyperDyadic=function(a,b,c){var d=this,e;if(this.enableHyperOps){if(this.isMatrix(b)){if(this.isMatrix(c)){b=b.asArray();c=c.asArray();var f=Math.min(b.length,c.length);var g=Array(f);for(e=0;ethis.hyperDyadic(a,g,c))}return this.isMatrix(c)?c.map(g=>this.hyperDyadic(a,b,g)):this.hyperZip(a,b,c)}return a(b,c)}; +Process.prototype.hyperZip=function(a,b,c){var d;if(b instanceof List){if(c instanceof List){b=b.asArray();c=c.asArray();var e=Math.min(b.length,c.length);var f=Array(e);for(d=0;dthis.hyperZip(a,g,c))}return c instanceof List?c.map(g=>this.hyperZip(a,b,g)):a(b,c)};Process.prototype.isMatrix=function(a){return a instanceof List&&a.at(1)instanceof List}; Process.prototype.rank=function(a){for(var b=0;a instanceof List;)b+=1,a=a.at(1);return b};Process.prototype.reportVariadicSum=function(a){this.assertType(a,"list");return this.reportListAggregation(a,"reportSum")};Process.prototype.reportSum=function(a,b){return this.hyperDyadic(this.reportBasicSum,a,b)};Process.prototype.reportBasicSum=function(a,b){return+a+ +b};Process.prototype.reportDifference=function(a,b){return this.hyperDyadic(this.reportBasicDifference,a,b)}; Process.prototype.reportBasicDifference=function(a,b){return+a-+b};Process.prototype.reportVariadicProduct=function(a){this.assertType(a,"list");return this.reportListAggregation(a,"reportProduct")};Process.prototype.reportProduct=function(a,b){return this.hyperDyadic(this.reportBasicProduct,a,b)};Process.prototype.reportBasicProduct=function(a,b){return+a*+b};Process.prototype.reportQuotient=function(a,b){return this.hyperDyadic(this.reportBasicQuotient,a,b)}; Process.prototype.reportBasicQuotient=function(a,b){return+a/+b};Process.prototype.reportPower=function(a,b){return this.hyperDyadic(this.reportBasicPower,a,b)};Process.prototype.reportBasicPower=function(a,b){return Math.pow(+a,+b)};Process.prototype.reportRandom=function(a,b){return this.hyperDyadic(this.reportBasicRandom,a,b)};Process.prototype.reportBasicRandom=function(a,b){a=+a;b=+b;return 0!==a%1||0!==b%1?Math.random()*(b-a)+a:Math.floor(Math.random()*(b-a+1))+a}; Process.prototype.reportModulus=function(a,b){return this.hyperDyadic(this.reportBasicModulus,a,b)};Process.prototype.reportBasicModulus=function(a,b){b=+b;return(+a%b+b)%b};Process.prototype.reportAtan2=function(a,b){return this.hyperDyadic(this.reportBasicAtan2,a,b)};Process.prototype.reportBasicAtan2=function(a,b){return degrees(Math.atan2(+a,+b))};Process.prototype.reportVariadicMin=function(a){this.assertType(a,"list");return this.reportListAggregation(a,"reportMin")}; Process.prototype.reportMin=function(a,b){return this.hyperDyadic(this.reportBasicMin,a,b)};Process.prototype.reportBasicMin=function(a,b){var c=+a,d=+b;if(isNaN(c)||isNaN(d))c=a,d=b;return cd?c:d};Process.prototype.reportLessThan=function(a,b){return this.hyperDyadic(this.reportBasicLessThan,a,b)};Process.prototype.reportLessThanOrEquals=function(a,b){var c=this;return this.hyperDyadic(function(d,e){return!c.reportBasicGreaterThan(d,e)},a,b)};Process.prototype.reportBasicLessThan=function(a,b){var c=+a,d=+b;if(isNaN(c)||isNaN(d))c=a,d=b;return cd};Process.prototype.reportEquals=function(a,b){return snapEquals(a,b)}; -Process.prototype.reportNotEquals=function(a,b){return!snapEquals(a,b)};Process.prototype.reportNot=function(a){var b=this;return this.enableHyperOps&&a instanceof List?a.map(function(c){return b.reportNot(c)}):!a}; -Process.prototype.reportIsIdentical=function(a,b){function c(){Object.prototype.hasOwnProperty.call(a,"idTag")&&delete a.idTag;Object.prototype.hasOwnProperty.call(b,"idTag")&&delete b.idTag}if(this.isImmutable(a)||this.isImmutable(b))return snapEquals(a,b);c();a.idTag=Date.now();if(b.idTag===a.idTag)return c(),!0;c();return!1};Process.prototype.isImmutable=function(a){a=this.reportTypeOf(a);return"nothing"===a||"Boolean"===a||"text"===a||"number"===a||"undefined"===a}; -Process.prototype.reportBoolean=function(a){return a};Process.prototype.reportRound=function(a){var b=this;return this.enableHyperOps&&a instanceof List?a.map(function(c){return b.reportRound(c)}):Math.round(+a)}; -Process.prototype.reportMonadic=function(a,b){var c=this;if(this.enableHyperOps&&b instanceof List)return b.map(function(f){return c.reportMonadic(a,f)});var d=+b,e=0;switch(this.inputOption(a)){case "abs":e=Math.abs(d);break;case "neg":e=-1*b;break;case "ceiling":e=Math.ceil(d);break;case "floor":e=Math.floor(d);break;case "sqrt":e=Math.sqrt(d);break;case "sin":e=Math.sin(radians(d));break;case "cos":e=Math.cos(radians(d));break;case "tan":e=Math.tan(radians(d));break;case "asin":e=degrees(Math.asin(d)); -break;case "acos":e=degrees(Math.acos(d));break;case "atan":e=degrees(Math.atan(d));break;case "ln":e=Math.log(d);break;case "log":e=Math.log10(d);break;case "lg":e=Math.log2(d);break;case "e^":e=Math.exp(d);break;case "10^":e=Math.pow(10,d);break;case "2^":e=Math.pow(2,d);break;case "id":return b;default:nop()}return e}; +Process.prototype.reportBasicMax=function(a,b){var c=+a,d=+b;if(isNaN(c)||isNaN(d))c=a,d=b;return c>d?c:d};Process.prototype.reportLessThan=function(a,b){return this.hyperDyadic(this.reportBasicLessThan,a,b)};Process.prototype.reportLessThanOrEquals=function(a,b){return this.hyperDyadic((c,d)=>!this.reportBasicGreaterThan(c,d),a,b)};Process.prototype.reportBasicLessThan=function(a,b){var c=+a,d=+b;if(isNaN(c)||isNaN(d))c=a,d=b;return c!this.reportBasicLessThan(c,d),a,b)};Process.prototype.reportBasicGreaterThan=function(a,b){var c=+a,d=+b;if(isNaN(c)||isNaN(d))c=a,d=b;return c>d};Process.prototype.reportEquals=function(a,b){return snapEquals(a,b)};Process.prototype.reportNotEquals=function(a,b){return!snapEquals(a,b)}; +Process.prototype.reportNot=function(a){return this.enableHyperOps&&a instanceof List?a.map(b=>this.reportNot(b)):!a};Process.prototype.reportIsIdentical=function(a,b){function c(){Object.prototype.hasOwnProperty.call(a,"idTag")&&delete a.idTag;Object.prototype.hasOwnProperty.call(b,"idTag")&&delete b.idTag}if(this.isImmutable(a)||this.isImmutable(b))return snapEquals(a,b);c();a.idTag=Date.now();if(b.idTag===a.idTag)return c(),!0;c();return!1}; +Process.prototype.isImmutable=function(a){a=this.reportTypeOf(a);return"nothing"===a||"Boolean"===a||"text"===a||"number"===a||"undefined"===a};Process.prototype.reportBoolean=function(a){return a};Process.prototype.reportRound=function(a){return this.enableHyperOps&&a instanceof List?a.map(b=>this.reportRound(b)):Math.round(+a)}; +Process.prototype.reportMonadic=function(a,b){if(this.enableHyperOps&&b instanceof List)return b.map(e=>this.reportMonadic(a,e));var c=+b,d=0;switch(this.inputOption(a)){case "abs":d=Math.abs(c);break;case "neg":d=-1*b;break;case "ceiling":d=Math.ceil(c);break;case "floor":d=Math.floor(c);break;case "sqrt":d=Math.sqrt(c);break;case "sin":d=Math.sin(radians(c));break;case "cos":d=Math.cos(radians(c));break;case "tan":d=Math.tan(radians(c));break;case "asin":d=degrees(Math.asin(c));break;case "acos":d= +degrees(Math.acos(c));break;case "atan":d=degrees(Math.atan(c));break;case "ln":d=Math.log(c);break;case "log":d=Math.log10(c);break;case "lg":d=Math.log2(c);break;case "e^":d=Math.exp(c);break;case "10^":d=Math.pow(10,c);break;case "2^":d=Math.pow(2,c);break;case "id":return b;default:nop()}return d}; Process.prototype.reportTextFunction=function(a,b){b=(isNil(b)?"":b).toString();var c="";switch(this.inputOption(a)){case "encode URI":c=encodeURI(b);break;case "decode URI":c=decodeURI(b);break;case "encode URI component":c=encodeURIComponent(b);break;case "decode URI component":c=decodeURIComponent(b);break;case "XML escape":c=(new XML_Element).escape(b);break;case "XML unescape":c=(new XML_Element).unescape(b);break;case "hex sha512 hash":c=hex_sha512(b);break;default:nop()}return c}; -Process.prototype.reportJoin=function(a,b){a=(isNil(a)?"":a).toString();b=(isNil(b)?"":b).toString();return a.concat(b)};Process.prototype.reportJoinWords=function(a){return a instanceof List?a.asText():(a||"").toString()};Process.prototype.reportLetter=function(a,b){var c=this;return this.hyperDyadic(function(d,e){return c.reportBasicLetter(d,e)},a,b)}; -Process.prototype.reportBasicLetter=function(a,b){b=isNil(b)?"":b.toString();"any"===this.inputOption(a)&&(a=this.reportBasicRandom(1,b.length));"last"===this.inputOption(a)&&(a=b.length);return b[+(a||0)-1]||""};Process.prototype.reportStringSize=function(a){var b=this;return this.enableHyperOps&&a instanceof List?a.map(function(c){return b.reportStringSize(c)}):a instanceof List?a.length():isNil(a)?0:a.toString().length}; -Process.prototype.reportUnicode=function(a){var b=this;if(this.enableHyperOps){if(a instanceof List)return a.map(function(c){return b.reportUnicode(c)});a=isNil(a)?"\x00":a.toString();if(1this.reportBasicLetter(c,d),a,b)}; +Process.prototype.reportBasicLetter=function(a,b){b=isNil(b)?"":b.toString();"any"===this.inputOption(a)&&(a=this.reportBasicRandom(1,b.length));"last"===this.inputOption(a)&&(a=b.length);return b[+(a||0)-1]||""};Process.prototype.reportStringSize=function(a){return this.enableHyperOps&&a instanceof List?a.map(b=>this.reportStringSize(b)):a instanceof List?a.length():isNil(a)?0:a.toString().length}; +Process.prototype.reportUnicode=function(a){if(this.enableHyperOps){if(a instanceof List)return a.map(b=>this.reportUnicode(b));a=isNil(a)?"\x00":a.toString();if(1this.reportUnicodeAsLetter(b));a=+(a||0);return String.fromCodePoint?String.fromCodePoint(a):String.fromCharCode(a)};Process.prototype.reportTextSplit=function(a,b){return this.hyperDyadic((c,d)=>this.reportBasicTextSplit(c,d),a,b)}; Process.prototype.reportBasicTextSplit=function(a,b){var c=["text","number"],d=this.reportTypeOf(a),e=this.reportTypeOf(this.inputOption(b));if(!contains(c,d))throw Error("expecting text instead of a "+d);if(!contains(c,e))throw Error("expecting a text delimiter instead of a "+e);c=isNil(a)?"":a.toString();switch(this.inputOption(b)){case "line":a=/\r\n|[\n\v\f\r\x85\u2028\u2029]/;break;case "tab":a="\t";break;case "cr":a="\r";break;case "word":case "whitespace":c=c.trim();a=/\s+/;break;case "letter":a= "";break;case "csv":return this.parseCSV(a);case "json":return this.parseJSON(a);default:a=isNil(b)?"":b.toString()}return new List(c.split(a))};Process.prototype.parseCSV=function(a){return this.rawParseCSV(a,this.guessDelimiterCSV(a))};Process.prototype.guessDelimiterCSV=function(a){var b=[",",";","|","\t"],c=b.length;a=a.split("\n")[0];var d;for(d=0;dnew List(n)));return 1===e.length()?e.at(1):e}; Process.prototype.parseJSON=function(a){function b(c){return c instanceof Array?new List(c.map(function(d){return b(d)})):c instanceof Object?new List(Object.keys(c).map(function(d){return new List([d,b(c[d])])})):c}return b(JSON.parse(a))};Process.prototype.alert=function(a){if(this.homeContext.receiver){var b=this.homeContext.receiver.world();b.isDevMode&&alert("Snap! "+a.asArray())}}; -Process.prototype.log=function(a){if(this.homeContext.receiver){var b=this.homeContext.receiver.world();b.isDevMode&&console.log("Snap! "+a.asArray())}};Process.prototype.getOtherObject=function(a,b,c){if(isSnapObject(a))return a;if("myself"===this.inputOption(a))return b;b=isNil(c)?b.parentThatIsA(StageMorph):c;c=null;b&&((c=detect(b.children,function(d){return d.name===a}))||(c=detect(b.world().hand.children,function(d){return d instanceof SpriteMorph&&d.name===a})));return c}; +Process.prototype.log=function(a){if(this.homeContext.receiver){var b=this.homeContext.receiver.world();b.isDevMode&&console.log("Snap! "+a.asArray())}};Process.prototype.getOtherObject=function(a,b,c){if(isSnapObject(a))return a;if("myself"===this.inputOption(a))return b;b=isNil(c)?b.parentThatIsA(StageMorph):c;c=null;b&&((c=detect(b.children,d=>d.name===a))||(c=detect(b.world().hand.children,d=>d instanceof SpriteMorph&&d.name===a)));return c}; Process.prototype.getObjectsNamed=function(a,b,c){function d(e){return e instanceof SpriteMorph&&e.isTemporary?e.cloneOriginName===a:e.name===a}b=isNil(c)?b.parentThatIsA(StageMorph):c;c=[];b&&(c=b.children.filter(d),c.length||(c=b.world().hand.children.filter(d)));return c};Process.prototype.setHeading=function(a){var b=this.blockReceiver();b&&("random"===this.inputOption(a)&&(a=this.reportBasicRandom(1,36E3)/100),b.setHeading(a))}; Process.prototype.doFaceTowards=function(a){var b=this.blockReceiver();b&&("center"===this.inputOption(a)?b.faceToXY(0,0):"mouse-pointer"===this.inputOption(a)?b.faceToXY(this.reportMouseX(),this.reportMouseY()):"random position"===this.inputOption(a)?b.setHeading(this.reportBasicRandom(1,36E3)/100):a instanceof List?b.faceToXY(a.at(1),a.at(2)):(a=this.getOtherObject(a,this.homeContext.receiver))&&b.faceToXY(a.xPosition(),a.yPosition()))}; Process.prototype.doGotoObject=function(a){var b=this.blockReceiver();b&&("center"===this.inputOption(a)?b.gotoXY(0,0):"mouse-pointer"===this.inputOption(a)?b.gotoXY(this.reportMouseX(),this.reportMouseY()):"random position"===this.inputOption(a)?(a=b.parentThatIsA(StageMorph))&&b.setCenter(new Point(this.reportBasicRandom(a.left(),a.right()),this.reportBasicRandom(a.top(),a.bottom()))):a instanceof List?b.gotoXY(a.at(1),a.at(2)):(a=this.getOtherObject(a,this.homeContext.receiver))&&b.gotoXY(a.xPosition(), a.yPosition()))};Process.prototype.goToLayer=function(a){a=this.inputOption(a);var b=this.blockReceiver();b instanceof SpriteMorph&&("front"===a?b.comeToFront():"back"===a&&b.goToBack())};Process.prototype.setHSVA=function(a,b){this.blockReceiver().setColorComponentHSVA(["hue","saturation","brightness","transparency"].indexOf(this.inputOption(a)),+b)}; Process.prototype.changeHSVA=function(a,b){this.blockReceiver().changeColorComponentHSVA(["hue","saturation","brightness","transparency"].indexOf(this.inputOption(a)),+b)};Process.prototype.setPenHSVA=Process.prototype.setHSVA;Process.prototype.changePenHSVA=Process.prototype.changeHSVA;Process.prototype.setBackgroundHSVA=Process.prototype.setHSVA;Process.prototype.changeBackgroundHSVA=Process.prototype.changeHSVA; -Process.prototype.doPasteOn=function(a,b,c){var d=this;b=b||this.blockReceiver();c=c||b.parentThatIsA(StageMorph);c.name===a&&(a=c);if(isSnapObject(a))return b.pasteOn(a);(a instanceof List?a.itemsArray():this.getObjectsNamed(a,b,c)).forEach(function(e){return d.doPasteOn(e,b,c)})};Process.prototype.createClone=function(a){var b=this.blockReceiver();a&&!this.readyToTerminate&&b&&("myself"===this.inputOption(a)?b.createClone(!this.isFirstStep):(a=this.getOtherObject(a,b))&&a.createClone(!this.isFirstStep))}; +Process.prototype.doPasteOn=function(a,b,c){b=b||this.blockReceiver();c=c||b.parentThatIsA(StageMorph);c.name===a&&(a=c);if(isSnapObject(a))return b.pasteOn(a);(a instanceof List?a.itemsArray():this.getObjectsNamed(a,b,c)).forEach(d=>this.doPasteOn(d,b,c))};Process.prototype.createClone=function(a){var b=this.blockReceiver();a&&!this.readyToTerminate&&b&&("myself"===this.inputOption(a)?b.createClone(!this.isFirstStep):(a=this.getOtherObject(a,b))&&a.createClone(!this.isFirstStep))}; Process.prototype.newClone=function(a){var b=this.blockReceiver();if(a&&b){if("myself"===this.inputOption(a))return b.newClone(!this.isFirstStep);if(a=this.getOtherObject(a,b))return a.newClone(!this.isFirstStep)}};Process.prototype.reportTouchingObject=function(a){var b=this.blockReceiver();return b?this.objectTouchingObject(b,a):!1}; -Process.prototype.objectTouchingObject=function(a,b){var c=this;if("mouse-pointer"===this.inputOption(b)){var d=a.world().hand.position();if(a.bounds.containsPoint(d)&&!a.isTransparentAt(d))return!0}else if(d=a.parentThatIsA(StageMorph)){if("edge"===this.inputOption(b)){var e=a.bounds;!a.costume&&a.penBounds&&(e=a.penBounds.translateBy(a.position()));if(!d.bounds.containsRectangle(e))return!0}if("pen trails"===this.inputOption(b)&&a.isTouching(d.penTrailsMorph()))return!0;if(isSnapObject(b))return b.isVisible&& -a.isTouching(b);d=b instanceof List?b.itemsArray():this.getObjectsNamed(b,a,d);if(d.some(function(f){return f.isVisible&&a.isTouching(f)}))return!0}return a.parts.some(function(f){return c.objectTouchingObject(f,b)})}; +Process.prototype.objectTouchingObject=function(a,b){if("mouse-pointer"===this.inputOption(b)){var c=a.world().hand.position();if(a.bounds.containsPoint(c)&&!a.isTransparentAt(c))return!0}else if(c=a.parentThatIsA(StageMorph)){if("edge"===this.inputOption(b)){var d=a.bounds;!a.costume&&a.penBounds&&(d=a.penBounds.translateBy(a.position()));if(!c.bounds.containsRectangle(d))return!0}if("pen trails"===this.inputOption(b)&&a.isTouching(c.penTrailsMorph()))return!0;if(isSnapObject(b))return b.isVisible&& +a.isTouching(b);c=b instanceof List?b.itemsArray():this.getObjectsNamed(b,a,c);if(c.some(e=>e.isVisible&&a.isTouching(e)))return!0}return a.parts.some(e=>this.objectTouchingObject(e,b))}; Process.prototype.reportAspect=function(a,b){a=this.inputOption(a);var c=this.inputOption(b);b=["hue","saturation","brightness","transparency"].indexOf(a);var d=this.blockReceiver(),e=d.parentThatIsA(StageMorph);var f=d.world();if("myself"===c){if("sprites"===a)return c=d instanceof StageMorph?d.center():d.rotationCenter(),this.spritesAtPoint(c,e);e=this.colorAtSprite(d)}else if("mouse-pointer"===c){if("sprites"===a)return this.spritesAtPoint(f.hand.position(),e);e=f.getGlobalPixelColor(f.hand.position())}else if(c instanceof List){c=new Point(c.at(1)*e.scale+e.center().x,e.center().y-c.at(2)*e.scale);if("sprites"===a)return this.spritesAtPoint(c,e);e=f.getGlobalPixelColor(c)}else if(c&&(f=this.getOtherObject(c,d,e))){if("sprites"===a)return c=f instanceof SpriteMorph?f.rotationCenter():f.center(),this.spritesAtPoint(c,e);e=this.colorAtSprite(f)}else return;if("r-g-b-a"===a)return new List([e.r,e.g,e.b,Math.round(255*e.a)]);if(!(0>b||3c instanceof SpriteMorph&&c.isVisible&&c.bounds.containsPoint(a)&&!c.isTransparentAt(a)))};Process.prototype.reportRelationTo=function(a,b){if(this.enableHyperOps&&b instanceof List&&!this.isCoordinate(b))return b.map(d=>this.reportRelationTo(a,d));var c=this.inputOption(a);return"distance"===c?this.reportDistanceTo(b):"ray length"===c?this.reportRayLengthTo(b):"direction"===c?this.reportDirectionTo(b):0}; Process.prototype.reportDistanceTo=function(a){var b=this.blockReceiver(),c;if(b){var d=c=b.rotationCenter();if("mouse-pointer"===this.inputOption(a))d=b.world().hand.position();else{if("center"===this.inputOption(a))return(new Point(b.xPosition(),b.yPosition())).distanceTo(ZERO);if(a instanceof List)return(new Point(b.xPosition(),b.yPosition())).distanceTo(new Point(a.at(1),a.at(2)))}var e=b.parentThatIsA(StageMorph);(a=this.getOtherObject(a,b,e))&&(d=a.rotationCenter());return c.distanceTo(d)/e.scale}return 0}; -Process.prototype.reportRayLengthTo=function(a){var b=this.blockReceiver(),c=[],d,e,f,g;var h=function(x){return Math.round(1E7*x)/1E7};var k=function(x){var A=radians(p);e=m.y-x;d=e*Math.tan(A);f=m.x+d;(h(f)===h(m.x)&&(180===p&&m.yx)||f>m.x&&0<=p&&180>p||h(f)p)&&f>=u&&f<=v&&c.push(new Point(f,x))};var l=function(x){var A=radians(360-p-90);e=m.x-x;d=e*Math.tan(A);g=m.y+d;(h(g)===h(m.y)&&(90===p&&m.xx)||g>m.y&&90<=p&&270>p||gp))&& -g>=q&&g<=t&&c.push(new Point(x,g))};if(!b)return-1;var m=b.rotationCenter();var n=b.parentThatIsA(StageMorph);a=this.getOtherObject(a,b,n);if(!(a instanceof SpriteMorph))return-1;var p=b.heading;var r=a.bounds;var q=r.top();var t=r.bottom();var u=r.left();var v=r.right();if(r.containsPoint(m)){if(c.push(m),k(q),k(t),l(u),l(v),2>c.length)return-1}else{k(q);k(t);l(u);l(v);if(2>c.length)return-1;90===p||Math.sign(m.x-c[0].x)===Math.sign(c[0].x-c[1].x)&&Math.sign(m.y-c[0].y)===Math.sign(c[0].y-c[1].y)|| -(b=c[0],c[0]=c[1],c[1]=b)}c=c.map(function(x){return x.subtract(r.origin).floorDivideBy(n.scale)});var w=Math.floor(r.width()/n.scale);var y=a.getImageData();b=function(x,A,B,C,D){for(var E=Math.abs(C-A),L=AI&&(G+=I,A+=L);OMath.round(1E7*x)/1E7;var k=x=>{var z=radians(p);e=m.y-x;d=e*Math.tan(z);f=m.x+d;(h(f)===h(m.x)&&(180===p&&m.yx)||f>m.x&&0<=p&&180>p||h(f)p)&&f>=u&&f<=v&&c.push(new Point(f,x))};var l=x=>{var z=radians(360-p-90);e=m.x-x;d=e*Math.tan(z);g=m.y+d;(h(g)===h(m.y)&&(90===p&&m.xx)||g>m.y&&90<=p&&270>p||gp))&&g>=r&&g<=t&&c.push(new Point(x, +g))};if(!b)return-1;var m=b.rotationCenter();var n=b.parentThatIsA(StageMorph);a=this.getOtherObject(a,b,n);if(!(a instanceof SpriteMorph))return-1;var p=b.heading;var q=a.bounds;var r=q.top();var t=q.bottom();var u=q.left();var v=q.right();if(q.containsPoint(m)){if(c.push(m),k(r),k(t),l(u),l(v),2>c.length)return-1}else{k(r);k(t);l(u);l(v);if(2>c.length)return-1;90===p||Math.sign(m.x-c[0].x)===Math.sign(c[0].x-c[1].x)&&Math.sign(m.y-c[0].y)===Math.sign(c[0].y-c[1].y)||(b=c[0],c[0]=c[1],c[1]=b)}c= +c.map(x=>x.subtract(q.origin).floorDivideBy(n.scale));var w=Math.floor(q.width()/n.scale);var y=a.getImageData();b=function(x,z,A,B,C){for(var F=Math.abs(B-z),K=zI&&(E+=I,z+=K);Oe instanceof SpriteMorph&&e!==b));case "parts":return new List((b.parts||[]).map(e=>e));case "anchor":return b.anchor||"";case "parent":return b.exemplar||"";case "children":return new List(b.specimens?b.specimens():[]);case "temporary?":return b.isTemporary||!1;case "clones":a=b.parentThatIsA(StageMorph); +var c=b.name||b.cloneOriginName;return new List(a.children.filter(e=>e.isTemporary&&e!==b&&e.cloneOriginName===c));case "other clones":return b.isTemporary?this.reportGet(["clones"]):new List;case "neighbors":a=b.parentThatIsA(StageMorph);var d=b.bounds.expandBy(new Point(b.width(),b.height()));return new List(a.children.filter(e=>e instanceof SpriteMorph&&e!==b&&e.bounds.intersects(d)));case "dangling?":return!b.rotatesWithAnchor;case "draggable?":return b.isDraggable;case "rotation style":return b.rotationStyle|| +0;case "rotation x":return b.xPosition();case "rotation y":return b.yPosition();case "center x":return b.xCenter();case "center y":return b.yCenter();case "left":return b.xLeft();case "right":return b.xRight();case "top":return b.yTop();case "bottom":return b.yBottom();case "name":return b.name;case "stage":return b.parentThatIsA(StageMorph);case "costume":return b.costume;case "costumes":return b.reportCostumes();case "sounds":return b.sounds;case "width":return b instanceof StageMorph?b.dimensions.x: +(a=b.parentThatIsA(StageMorph))?b.width()/a.scale:0;case "height":return b instanceof StageMorph?b.dimensions.y:(a=b.parentThatIsA(StageMorph))?b.height()/a.scale:0}return""};Process.prototype.reportObject=function(a){var b=this.blockReceiver();if(b){this.assertAlive(b);var c=b.parentThatIsA(StageMorph);(a=c.name===a?c:this.getOtherObject(a,b,c))&&this.assertAlive(a);return a}}; Process.prototype.doSet=function(a,b){var c=this.blockReceiver();this.assertAlive(c);if(!(a instanceof Context||a instanceof Array)||a instanceof Context&&"reportGet"!==a.expression.selector)throw Error(localize("unsupported attribute"));a=a instanceof Context?a.expression.inputs()[0].evaluate():a;a instanceof Array&&(a=a[0]);switch(a){case "anchor":this.assertType(c,"sprite");if(b instanceof SpriteMorph){if(!c.enableNesting||contains(c.allParts(),b))throw Error(localize("unable to nest\n(disabled or circular?)")); b.attachPart(c)}else c.detachFromAnchor();break;case "parent":this.assertType(c,"sprite");b=b instanceof SpriteMorph?b:null;c.setExemplar(b,!0);break;case "temporary?":this.assertType(c,"sprite");this.assertType(b,"Boolean");b?c.release():c.perpetuate();break;case "name":this.assertType(c,["sprite","stage"]);this.assertType(b,["text","number"]);if(a=c.parentThatIsA(IDE_Morph))c.setName(a.newSpriteName(b.toString(),c)),a.spriteBar.nameField.setContents(a.currentSprite.name.toString());break;case "dangling?":this.assertType(c, -"sprite");this.assertType(b,"Boolean");c.rotatesWithAnchor=!b;c.version=Date.now();break;case "draggable?":this.assertType(c,"sprite");this.assertType(b,"Boolean");c.isDraggable=b;(a=c.parentThatIsA(IDE_Morph))&&a.spriteBar.children.forEach(function(d){d.refresh&&d.refresh()});c.version=Date.now();break;case "rotation style":this.assertType(c,"sprite");this.assertType(+b,"number");if(!contains([0,1,2],+b))break;c.changed();c.rotationStyle=+b;c.fixLayout();c.rerender();(a=c.parentThatIsA(IDE_Morph))&& -a.spriteBar.children.forEach(function(d){d.refresh&&d.refresh()});c.version=Date.now();break;case "rotation x":this.assertType(c,"sprite");this.assertType(b,"number");c.setRotationX(b);break;case "rotation y":this.assertType(c,"sprite");this.assertType(b,"number");c.setRotationY(b);break;case "microphone modifier":this.setMicrophoneModifier(b);break;default:throw Error('"'+localize(a)+'" '+localize("is read-only"));}}; +"sprite");this.assertType(b,"Boolean");c.rotatesWithAnchor=!b;c.version=Date.now();break;case "draggable?":this.assertType(c,"sprite");this.assertType(b,"Boolean");c.isDraggable=b;(a=c.parentThatIsA(IDE_Morph))&&a.spriteBar.children.forEach(d=>{d.refresh&&d.refresh()});c.version=Date.now();break;case "rotation style":this.assertType(c,"sprite");this.assertType(+b,"number");if(!contains([0,1,2],+b))break;c.changed();c.rotationStyle=+b;c.fixLayout();c.rerender();(a=c.parentThatIsA(IDE_Morph))&&a.spriteBar.children.forEach(d=> +{d.refresh&&d.refresh()});c.version=Date.now();break;case "rotation x":this.assertType(c,"sprite");this.assertType(b,"number");c.setRotationX(b);break;case "rotation y":this.assertType(c,"sprite");this.assertType(b,"number");c.setRotationY(b);break;case "microphone modifier":this.setMicrophoneModifier(b);break;default:throw Error('"'+localize(a)+'" '+localize("is read-only"));}}; Process.prototype.reportContextFor=function(a,b){a=copy(a);a.receiver=b;if(a.outerContext)if(a.outerContext=copy(a.outerContext),a.outerContext.variables=copy(a.outerContext.variables),a.outerContext.receiver=b,a.outerContext.variables.parentFrame){var c=a.outerContext.variables.parentFrame;b=copy(b.variables);b.parentFrame=c;a.outerContext.variables.parentFrame=b}else a.outerContext.variables.parentFrame=b.variables;return a}; Process.prototype.reportMouseX=function(){var a,b;return this.homeContext.receiver&&(a=this.homeContext.receiver.parentThatIsA(StageMorph))&&(b=a.world())?(b.hand.position().x-a.center().x)/a.scale:0};Process.prototype.reportMouseY=function(){var a,b;return this.homeContext.receiver&&(a=this.homeContext.receiver.parentThatIsA(StageMorph))&&(b=a.world())?(a.center().y-b.hand.position().y)/a.scale:0}; Process.prototype.reportMouseDown=function(){var a;return this.homeContext.receiver&&(a=this.homeContext.receiver.world())?"left"===a.hand.mouseButton:!1};Process.prototype.reportKeyPressed=function(a){var b;return this.homeContext.receiver&&(b=this.homeContext.receiver.parentThatIsA(StageMorph))?"any key"===this.inputOption(a)?0=1E3*b)return this.context.activeNote&&(this.context.activeNote.stop(),this.context.activeNote=null),null;this.pushContext("doYield");this.pushContext()}; Process.prototype.doSetInstrument=function(a){this.instrument=+a;this.receiver.instrument=+a;this.receiver.freqPlayer&&this.receiver.freqPlayer.setInstrument(+a)};Process.prototype.reportGetImageAttribute=function(a,b){b=this.costumeNamed(b)||new Costume;switch(this.inputOption(a)){case "name":return b.name;case "width":return b.width();case "height":return b.height();case "pixels":return b.rasterized().pixels();default:return b}}; Process.prototype.reportNewCostumeStretched=function(a,b,c){if(a instanceof List)return this.reportNewCostume(a,b,c);a=this.costumeNamed(a);if(!a)return new Costume;if(!isFinite(+b*+c)||isNaN(+b*+c))throw Error("expecting a finite number\nbut getting Infinity or NaN");return a.stretched(Math.round(a.width()*+b/100),Math.round(a.height()*+c/100))}; -Process.prototype.costumeNamed=function(a){return a instanceof Costume?a:"number"===typeof a?this.blockReceiver().costumes.at(a):"current"===this.inputOption(a)?this.blockReceiver().costume:detect(this.blockReceiver().costumes.asArray(),function(b){return b.name===a.toString()})}; +Process.prototype.costumeNamed=function(a){return a instanceof Costume?a:"number"===typeof a?this.blockReceiver().costumes.at(a):"current"===this.inputOption(a)?this.blockReceiver().costume:detect(this.blockReceiver().costumes.asArray(),b=>b.name===a.toString())}; Process.prototype.reportNewCostume=function(a,b,c,d){var e;this.assertType(a,"list");if("current"===this.inputOption(b)){var f=this.blockReceiver();var g=f.parentThatIsA(StageMorph);b=f.costume?f.costume.width():g.dimensions.x}"current"===this.inputOption(c)&&(f=f||this.blockReceiver(),g=g||f.parentThatIsA(StageMorph),c=f.costume?f.costume.height():g.dimensions.y);b=Math.abs(Math.floor(+b));c=Math.abs(Math.floor(+c));if(0>=b||0>=c)return new Costume;if(!isFinite(b*c)||isNaN(b*c))throw Error("expecting a finite number\nbut getting Infinity or NaN"); g=newCanvas(new Point(b,c),!0);var h=g.getContext("2d");a=a.asArray();b=h.createImageData(b,c);for(c=0;ce;e+=1)b.data[4*c+e]=k[e]}h.putImageData(b,0,0);return new Costume(g,d||(f||this.blockReceiver()).newCostumeName(localize("costume")))}; -Process.prototype.reportPentrailsAsSVG=function(){if(!this.context.accumulator){var a=this.homeContext.receiver.parentThatIsA(StageMorph);if(!a.trailsLog.length)throw Error(localize("there are currently no\nvectorizable pen trail segments"));a=a.trailsLogAsSVG();this.context.accumulator={img:new Image,rot:a.rot,ready:!1};var b=this.context.accumulator;b.img.onload=function(){return b.ready=!0};b.img.src="data:image/svg+xml,"+a.src;b.img.rot=a.rotationShift}else if(this.context.accumulator.ready){var c= -ZERO;a=this.blockReceiver();a instanceof SpriteMorph&&(c=new Point(a.xPosition(),-a.yPosition()));this.returnValueToParentContext(new SVG_Costume(this.context.accumulator.img,this.blockReceiver().newCostumeName(localize("Costume")),this.context.accumulator.rot.translateBy(c)));return}this.pushContext()};Process.prototype.inputOption=function(a){return a instanceof Array?a[0]:a}; +Process.prototype.reportPentrailsAsSVG=function(){if(!this.context.accumulator){var a=this.homeContext.receiver.parentThatIsA(StageMorph);if(!a.trailsLog.length)throw Error(localize("there are currently no\nvectorizable pen trail segments"));a=a.trailsLogAsSVG();this.context.accumulator={img:new Image,rot:a.rot,ready:!1};var b=this.context.accumulator;b.img.onload=()=>b.ready=!0;b.img.src="data:image/svg+xml,"+a.src;b.img.rot=a.rotationShift}else if(this.context.accumulator.ready){var c=ZERO;a=this.blockReceiver(); +a instanceof SpriteMorph&&(c=new Point(a.xPosition(),-a.yPosition()));this.returnValueToParentContext(new SVG_Costume(this.context.accumulator.img,this.blockReceiver().newCostumeName(localize("Costume")),this.context.accumulator.rot.translateBy(c)));return}this.pushContext()};Process.prototype.inputOption=function(a){return a instanceof Array?a[0]:a}; Process.prototype.pushContext=function(a,b){this.context=new Context(this.context,a,b||(this.context?this.context.outerContext:null),this.context?this.context.receiver:this.homeContext.receiver)};Process.prototype.popContext=function(){this.context&&this.context.stopMusic();this.context=this.context?this.context.parentContext:null};Process.prototype.returnValueToParentContext=function(a){void 0!==a&&(this.context?this.context.parentContext||this.homeContext:this.homeContext).addInput(a)}; Process.prototype.reportStackSize=function(){return this.context?this.context.stackSize():0};Process.prototype.reportFrameCount=function(){return this.frameCount}; Process.prototype.flashContext=function(){var a=this.context.expression;return!(this.enableSingleStepping&&!this.isAtomic&&a instanceof SyntaxElementMorph)||a instanceof CommandSlotMorph||this.context.isFlashing||!a.world()||a instanceof ColorSlotMorph?!1:(this.unflash(),a.flash(),this.context.isFlashing=!0,this.flashingContext=this.context,0=this.flashTime?(this.pushContext("doIdle"),this.context.addInput(this.flashTime)):this.pushContext("doInterrupt"),!0)}; @@ -1436,29 +1364,28 @@ Process.prototype.reportAtomicMap=function(a,b){this.assertType(b,"list");var c= Process.prototype.reportAtomicKeep=function(a,b){this.assertType(b,"list");var c=[],d=b.asArray(),e=d.length,f=a.inputs.length,g;try{var h=this.reportCompiled(a,1)}catch(l){console.log(l.message),h=a}for(g=0;ginvoke(c,new List([d,e]),null,null,null,null,this.capture(b))?-1:1))}; +Process.prototype.reportAtomicGroup=function(a,b){this.assertType(a,"list");var c=[],d=new Map,e=a.asArray(),f=e.length,g;try{var h=this.reportCompiled(b,1)}catch(k){console.log(k.message),h=b}for(g=0;gc.push(new List([l,k.length,new List(k)])));return new List(c)}; function Context(a,b,c,d){this.outerContext=c||null;this.parentContext=a||null;this.expression=b||null;this.receiver=d||null;this.origin=d||null;this.variables=new VariableFrame;this.outerContext&&(this.variables.parentFrame=this.outerContext.variables,this.receiver=this.outerContext.receiver);this.inputs=[];this.pc=0;this.isContinuation=!1;this.activeNote=this.activeAudio=this.activeSends=this.startTime=null;this.isCustomBlock=!1;this.isCustomCommand=null;this.emptySlots=0;this.tag=null;this.isFlashing= !1;this.accumulator=null}Context.prototype.toString=function(){var a=this.expression;a instanceof Array&&0> "+a+" "+this.variables}; -Context.prototype.blockify=function(){var a=new RingMorph,b;if(this.expression instanceof Morph){var c=this.expression.fullCopy();this.isContinuation&&(b=detect(c.allInputs(),function(d){return 1===d.bindingID}))&&c.revertToDefaultInput(b,!0);a.embed(c,this.inputs);return a}if(this.expression instanceof Array){c=this.expression[this.pc].fullCopy();if(c instanceof RingMorph&&!c.contents())return c;a.embed(c,this.isContinuation?[]:this.inputs);return a}a.color=SpriteMorph.prototype.blockColor.other; -a.setSpec("%rc %ringparms");this.isContinuation||this.inputs.forEach(function(d){return a.parts()[1].addInput(d)});return a};Context.prototype.image=function(){var a=this.blockify();return a.doWithAlpha(1,function(){return a.fullImage()})}; -Context.prototype.continuation=function(a){if(this.expression instanceof Array)a=this;else if(this.parentContext)a=this.parentContext;else return a=new Context(null,a?"expectReport":"popContext"),a.isContinuation=!0,a;a=a.copyForContinuation();a.tag=null;a.isContinuation=!0;return a}; +Context.prototype.blockify=function(){var a=new RingMorph,b;if(this.expression instanceof Morph){var c=this.expression.fullCopy();this.isContinuation&&(b=detect(c.allInputs(),d=>1===d.bindingID))&&c.revertToDefaultInput(b,!0);a.embed(c,this.inputs);return a}if(this.expression instanceof Array){c=this.expression[this.pc].fullCopy();if(c instanceof RingMorph&&!c.contents())return c;a.embed(c,this.isContinuation?[]:this.inputs);return a}a.color=SpriteMorph.prototype.blockColor.other;a.setSpec("%rc %ringparms"); +this.isContinuation||this.inputs.forEach(d=>a.parts()[1].addInput(d));return a};Context.prototype.image=function(){const a=this.blockify();return a.doWithAlpha(1,()=>a.fullImage())};Context.prototype.continuation=function(a){if(this.expression instanceof Array)a=this;else if(this.parentContext)a=this.parentContext;else return a=new Context(null,a?"expectReport":"popContext"),a.isContinuation=!0,a;a=a.copyForContinuation();a.tag=null;a.isContinuation=!0;return a}; Context.prototype.copyForContinuation=function(){var a=copy(this),b=a;if(!(this.expression instanceof Array||isString(this.expression)))for(b.prepareContinuationForBinding();b.parentContext;)b.parentContext=copy(b.parentContext),b=b.parentContext,b.inputs=[];return a}; Context.prototype.copyForContinuationCall=function(){var a=copy(this),b=a;if(!(this.expression instanceof Array||isString(this.expression)))for(this.expression=this.expression.fullCopy(),this.inputs=[];b.parentContext;)b.parentContext=copy(b.parentContext),b=b.parentContext,b.inputs=[];return a};Context.prototype.prepareContinuationForBinding=function(){var a=this.inputs.length;this.expression=this.expression.fullCopy();if(a=this.expression.inputs()[a])this.inputs=[],this.emptySlots=a.bindingID=1}; Context.prototype.addInput=function(a){this.inputs.push(a)};Context.prototype.stopMusic=function(){this.activeNote&&(this.activeNote.stop(),this.activeNote=null)};Context.prototype.lastFlashable=function(){return this.expression instanceof SyntaxElementMorph&&!(this.expression instanceof CommandSlotMorph)?this:this.parentContext?this.parentContext.lastFlashable():null};Context.prototype.stackSize=function(){return this.parentContext?1+this.parentContext.stackSize():1}; function Variable(a,b){this.value=a;this.isTransient=b||!1}Variable.prototype.toString=function(){return"a "+(this.isTransient?"transient ":"")+"Variable ["+this.value+"]"};Variable.prototype.copy=function(){return new Variable(this.value,this.isTransient)};function VariableFrame(a,b){this.vars={};this.parentFrame=a||null;this.owner=b||null}VariableFrame.prototype.toString=function(){return"a VariableFrame {"+this.names()+"}"}; -VariableFrame.prototype.copy=function(){var a=this,b=new VariableFrame(this.parentFrame);this.names().forEach(function(c){return b.addVar(c,a.getVar(c))});return b};VariableFrame.prototype.fullCopy=function(){var a=this.parentFrame?new VariableFrame(this.parentFrame.fullCopy()):new VariableFrame;a.vars=copy(this.vars);return a};VariableFrame.prototype.root=function(){return this.parentFrame?this.parentFrame.root():this}; +VariableFrame.prototype.copy=function(){var a=new VariableFrame(this.parentFrame);this.names().forEach(b=>a.addVar(b,this.getVar(b)));return a};VariableFrame.prototype.fullCopy=function(){var a=this.parentFrame?new VariableFrame(this.parentFrame.fullCopy()):new VariableFrame;a.vars=copy(this.vars);return a};VariableFrame.prototype.root=function(){return this.parentFrame?this.parentFrame.root():this}; VariableFrame.prototype.find=function(a){var b=this.silentFind(a);if(b)return b;throw Error(localize("a variable of name '")+a+localize("'\ndoes not exist in this context"));};VariableFrame.prototype.silentFind=function(a){return this.vars[a]instanceof Variable?this:this.parentFrame?this.parentFrame.silentFind(a):null};VariableFrame.prototype.setVar=function(a,b,c){var d=this.find(a);d&&(c instanceof SpriteMorph&&d.owner instanceof SpriteMorph&&c!==d.owner?c.shadowVar(a,b):d.vars[a].value=b)}; VariableFrame.prototype.changeVar=function(a,b,c){var d=this.find(a);if(d){var e=parseFloat(d.vars[a].value);b=isNaN(e)?b:e+parseFloat(b);c instanceof SpriteMorph&&d.owner instanceof SpriteMorph&&c!==d.owner?c.shadowVar(a,b):d.vars[a].value=b}}; VariableFrame.prototype.getVar=function(a){var b=this.silentFind(a);if(b)return a=b.vars[a].value,0===a?0:!1===a?!1:""===a?"":a||0;if("number"===typeof a)return"";throw Error(localize("a variable of name '")+a+localize("'\ndoes not exist in this context"));};VariableFrame.prototype.addVar=function(a,b){this.vars[a]=new Variable(0===b?0:!1===b?!1:""===b?"":b||0)};VariableFrame.prototype.deleteVar=function(a){var b=this.find(a);b&&delete b.vars[a]}; VariableFrame.prototype.names=function(){var a,b=[];for(a in this.vars)Object.prototype.hasOwnProperty.call(this.vars,a)&&b.push(a);return b};VariableFrame.prototype.allNamesDict=function(a){for(var b={},c=this;c&&c!==a;){var d=void 0,e=c.vars,f=b;for(d in e)Object.prototype.hasOwnProperty.call(e,d)&&(f[d]=d);c=c.parentFrame}return b};VariableFrame.prototype.allNames=function(a){var b=[],c;a=this.allNamesDict(a);for(c in a)Object.prototype.hasOwnProperty.call(a,c)&&b.push(c);return b}; function JSCompiler(a){this.process=a;this.paramCount=this.implicitParams=this.gensyms=this.source=null}JSCompiler.prototype.toString=function(){return"a JSCompiler"}; -JSCompiler.prototype.compileFunction=function(a,b){var c=this,d=a.expression,e=a.inputs,f=[],g=!1;this.source=a;this.implicitParams=b||1;g=!isNil(detect(d.allChildren(),function(h){return h.isEmptySlot&&h.isEmptySlot()}));this.gensyms={};this.paramCount=0;if(e.length){if(g)throw Error("compiling does not yet support\nmixing explicit formal parameters\nwith empty input slots");e.forEach(function(h,k){k="p"+k;f.push(k);c.gensyms[h]=k})}else if(g)if(1g.isEmptySlot&&g.isEmptySlot()));this.gensyms={};this.paramCount=0;if(d.length){if(f)throw Error("compiling does not yet support\nmixing explicit formal parameters\nwith empty input slots");d.forEach((g,h)=>{h="p"+h;e.push(h);this.gensyms[g]=h})}else if(f)if(1{b+=this.compileExpression(c);b+=";\n"});return b};JSCompiler.prototype.compileInfix=function(a,b){return"("+this.compileInput(b[0])+" "+a+" "+this.compileInput(b[1])+")"}; +JSCompiler.prototype.compileInputs=function(a){var b="";a.forEach(c=>{b.length&&(b+=", ");b+=this.compileInput(c)});return b}; JSCompiler.prototype.compileInput=function(a){if(a.isEmptySlot&&a.isEmptySlot()){if(1c.push(f));b.inheritedAttributes=c;a?(b.exemplar=this,b.customBlocks=[],b.variables=new VariableFrame(null,b),b.variables.parentFrame=this.variables, +b.inheritedVariableNames().forEach(f=>b.shadowVar(f,b.variables.getVar(f))),this.addSpecimen(b),this.cachedPropagation=!1,["scripts","costumes","sounds"].forEach(f=>{contains(b.inheritedAttributes,f)||b.inheritedAttributes.push(f)})):(b.variables=this.variables.copy(),b.variables.owner=b,b.scripts=this.scripts.fullCopy(),b.customBlocks=[],this.customBlocks.forEach(f=>{d=f.copyAndBindTo(b);b.customBlocks.push(d);b.allBlockInstances(f).forEach(g=>g.definition=d)}),c=[],this.costumes.asArray().forEach(f=> +{var g=a?f:f.copy();c.push(g);f===this.costume&&(b.costume=g)}),b.costumes=new List(c),c=[],this.sounds.asArray().forEach(f=>{f=a?f:f.copy();c.push(f)}),b.sounds=new List(c),c=[]);b.nestingScale=1;b.rotatesWithAnchor=!0;b.anchor=null;b.parts=[];this.parts.forEach(f=>{var g=f.fullCopy(a);g.nestingScale=f.nestingScale;g.rotatesWithAnchor=f.rotatesWithAnchor;b.attachPart(g)});b.graphicsValues={};for(e in this.graphicsValues)this.graphicsValues.hasOwnProperty(e)&&(b.graphicsValues[e]=this.graphicsValues[e]); +return b};SpriteMorph.prototype.appearIn=function(a){this.isTemporary||(this.name=a.newSpriteName(this.name),a.corral.addSprite(this),a.sprites.add(this));a.stage.add(this);this.parts.forEach(b=>b.appearIn(a))};SpriteMorph.prototype.setName=function(a){this.name=a||this.name;this.version=Date.now()}; SpriteMorph.prototype.getImage=function(){if(this.shouldRerender||!this.cachedImage)this.cachedImage=newCanvas(this.costume?this.imageExtent:this.extent(),!isNil(this.costume),this.cachedImage),this.render(this.cachedImage.getContext("2d")),this.shouldRerender=!1;return this.cachedImage}; -SpriteMorph.prototype.fixLayout=function(){var a=this;var b=[];var c=this.center();b=this.costume&&"function"===typeof this.costume.loaded;var d=this.parent instanceof StageMorph?this.parent.scale:1;var e=this.rotationStyle?this.heading:90;if(2===this.rotationStyle&&(e=90,180this.heading||0>this.heading&&-180this.heading||0>this.heading&&-180k.rotateBy(radians(d-90),this.costume.center()));var f=a[0];var g=a[0]; +a.forEach(k=>{f=f.min(k);g=g.max(k)});var h=f.corner(g).extent().multiplyBy(this.scale*c);this.imageOffset=ZERO.rotateBy(radians(-(d-90)),e.center()).subtract(f);1===this.rotationStyle?(a=Math.sqrt(Math.pow(e.width(),2)+Math.pow(e.height(),2))*this.scale*c,this.imageExtent=new Point(a,a)):this.imageExtent=h;this.bounds.setExtent(h);this.setCenter(b,!0);this.rotationOffset=this.imageOffset.translateBy(e.rotationCenter).rotateBy(radians(-(d-90)),this.imageOffset).scaleBy(this.scale*c)}else d=e?-90: +d,c=Math.min(Math.max(this.normalExtent.x*this.scale*c,5),1E3),this.bounds.setWidth(c),this.bounds.setHeight(c),this.setCenter(b,!0),this.rotationOffset=this.extent().divideBy(2)}; SpriteMorph.prototype.render=function(a){var b=this;var c=this.costume&&"function"===typeof this.costume.loaded;var d=this.parent instanceof StageMorph?this.parent.scale:1;var e=this.rotationStyle?this.heading:90;if(2===this.rotationStyle&&(e=90,180this.heading||0>this.heading&&-180u.trim()).filter(u=>!!u);r.messageTypes.getMsgType(t)?m.inform("that name is already in use"):SnapActions.addMessageType(t,q)}var l=[],m=this;a=a||"motion";var n=this.inheritedVariableNames();if("motion"===a)l.push(b("forward")),l.push(b("turn")),l.push(b("turnLeft")),l.push("-"),l.push(b("setHeading")),l.push(b("doFaceTowards")),l.push("-"),l.push(b("gotoXY")),l.push(b("doGotoObject")),l.push(b("doGlide")),l.push("-"), +l.push(b("changeXPosition")),l.push(b("setXPosition")),l.push(b("changeYPosition")),l.push(b("setYPosition")),l.push("-"),l.push(b("bounceOffEdge")),l.push("-"),l.push(d("xPosition")),l.push(b("xPosition",this.inheritsAttribute("x position"))),l.push(d("yPosition")),l.push(b("yPosition",this.inheritsAttribute("y position"))),l.push(d("direction")),l.push(b("direction",this.inheritsAttribute("direction")));else if("looks"===a){if(l.push(b("doSwitchToCostume")),l.push(b("doWearNextCostume")),l.push(d("getCostumeIdx")), +l.push(b("getCostumeIdx",this.inheritsAttribute("costume #"))),l.push("-"),l.push(b("doSayFor")),l.push(b("bubble")),l.push(b("doThinkFor")),l.push(b("doThink")),l.push("-"),l.push(b("reportGetImageAttribute")),l.push(b("reportNewCostumeStretched")),l.push(b("reportNewCostume")),l.push("-"),l.push(b("changeEffect")),l.push(b("setEffect")),l.push(b("clearEffects")),l.push(b("getEffect")),l.push("-"),l.push(b("changeScale")),l.push(b("setScale")),l.push(d("getScale")),l.push(b("getScale",this.inheritsAttribute("size"))), +l.push("-"),l.push(b("show")),l.push(b("hide")),l.push(d("reportShown")),l.push(b("reportShown",this.inheritsAttribute("shown?"))),l.push("-"),l.push(b("goToLayer")),l.push(b("goBack")),this.world().isDevMode){l.push("-");var p=new TextMorph(localize("development mode \ndebugging primitives:"));p.fontSize=9;p.setColor(this.paletteTextColor);l.push(p);l.push("-");l.push(b("log"));l.push(b("alert"))}}else"sound"===a?(l.push(b("playSound")),l.push(b("doPlaySoundUntilDone")),l.push(b("doStopAllSounds")), +l.push("-"),l.push(b("doPlaySoundAtRate")),l.push(b("reportGetSoundAttribute")),l.push(b("reportNewSoundFromSamples")),l.push("-"),l.push(b("doRest")),l.push(b("doPlayNote")),l.push(b("doSetInstrument")),l.push("-"),l.push(b("doChangeTempo")),l.push(b("doSetTempo")),l.push(d("getTempo")),l.push(b("getTempo")),l.push("-"),l.push(b("changeVolume")),l.push(b("setVolume")),l.push(d("getVolume")),l.push(b("getVolume",this.inheritsAttribute("volume"))),l.push("-"),l.push(b("changePan")),l.push(b("setPan")), +l.push(d("getPan")),l.push(b("getPan",this.inheritsAttribute("balance"))),l.push("-"),l.push(b("playFreq")),l.push(b("stopFreq")),this.world().isDevMode&&(l.push("-"),p=new TextMorph(localize("development mode \ndebugging primitives:")),p.fontSize=9,p.setColor(this.paletteTextColor),l.push(p),l.push("-"),l.push(b("doPlayFrequency")))):"pen"===a?(l.push(b("clear")),l.push("-"),l.push(b("down")),l.push(b("up")),l.push(d("getPenDown")),l.push(b("getPenDown",this.inheritsAttribute("pen down?"))),l.push("-"), +l.push(b("setColor")),l.push(b("changePenHSVA")),l.push(b("setPenHSVA")),l.push(b("getPenAttribute")),l.push("-"),l.push(b("changeSize")),l.push(b("setSize")),l.push("-"),l.push(b("doStamp")),l.push(b("floodFill")),l.push(b("write")),l.push("-"),l.push(b("reportPenTrailsAsCostume")),l.push("-"),l.push(b("doPasteOn"))):"network"===a?(l.push(b("receiveSocketMessage")),l.push(b("doSocketMessage")),l.push("-"),l.push(b("doSocketRequest")),l.push(b("doSocketResponse")),l.push("-"),l.push(b("getJSFromRPCStruct")), +l.push(b("doRunRPC")),l.push(d("reportRPCError")),l.push(b("reportRPCError")),l.push("-"),l.push(b("getProjectIds")),l.push(b("getProjectId")),p=new PushButtonMorph(null,function(){(new MessageCreatorMorph(m,k)).popUp()},"Make a message type"),l.push(p),0q.addItem(r,r,null,null,null,null, +null,null,!0));q.popUpAtHand(m.world())},"Delete a variable"),p.userMenu=f,p.selector="deleteVariable",p.showHelp=BlockMorph.prototype.showHelp,l.push(p)),l.push("-"),p=this.reachableGlobalVariableNames(!0),0{l.push(e(q));l.push(c(q))}),l.push("-")),p=this.allLocalVariableNames(!0),0{l.push(e(q));l.push(c(q,!0))}),l.push("-")),l.push(b("doSetVar")),l.push(b("doChangeVar")),l.push(b("doShowVar")),l.push(b("doHideVar")),l.push(b("doDeclareVariables")), +StageMorph.prototype.enableInheritance&&(l.push("-"),l.push(b("doDeleteAttr"))),l.push("="),l.push(b("reportNewList")),l.push(b("reportNumbers")),l.push("-"),l.push(b("reportCONS")),l.push(b("reportListItem")),l.push(b("reportCDR")),l.push("-"),l.push(b("reportListAttribute")),l.push(b("reportListIndex")),l.push(b("reportListContainsItem")),l.push(b("reportListIsEmpty")),l.push("-"),l.push(b("reportMap")),l.push(b("reportKeep")),l.push(b("reportFindFirst")),l.push(b("reportCombine")),l.push("-"), +l.push(b("doForEach")),l.push("-"),l.push(b("doAddToList")),l.push(b("doDeleteFromList")),l.push(b("doInsertInList")),l.push(b("doReplaceInList")),l.push("-"),l.push(b("reportConcatenatedLists")),l.push(b("reportReshape")),l.push(b("reportCrossproduct")),this.world().isDevMode&&(l.push("-"),p=new TextMorph(localize("development mode \ndebugging primitives:")),p.fontSize=9,p.setColor(this.paletteTextColor),l.push(p),l.push("-"),l.push(b("doShowTable"))),StageMorph.prototype.enableCodeMapping&&(l.push("="), +l.push(b("doMapCodeOrHeader")),l.push(b("doMapValueCode")),l.push(b("doMapListCode")),l.push("-"),l.push(b("reportMappedCode"))));if(p=this.parentThatIsA(IDE_Morph))p=p.extensions.getPaletteContents(this,a).flatMap(q=>{switch(q.type){case "block":return b(q.name);case "watcher":return[d(q.name),b(q.name)];case "space":return q.name}return q}),l.push(...p);l.push("=");l.push(this.makeBlockButton(a));return l}; SpriteMorph.prototype.makeBlockButton=function(a){a=new PushButtonMorph(this,"makeBlock","Make a block");a.userMenu=function(){var b=new MenuMorph(this);b.addItem("help...","showHelp");return b};a.selector="addCustomBlock";a.showHelp=BlockMorph.prototype.showHelp;return a}; -SpriteMorph.prototype.makeBlock=function(){var a=this,b=this.parentThatIsA(IDE_Morph).currentCategory,c=SpriteMorph.prototype.blockColor[b];var d=new BlockDialogMorph(null,function(e){""!==e.spec&&SnapActions.addCustomBlock(e,a).then(function(f){(new BlockEditorMorph(f,a)).popUp()})},this);"variables"!==b&&(d.category=b,d.categories.children.forEach(function(e){return e.refresh()}),d.types.children.forEach(function(e){e.setColor(c);e.refresh()}));d.prompt("Make a block",null,this.world())}; +SpriteMorph.prototype.makeBlock=function(){var a=this.parentThatIsA(IDE_Morph).currentCategory,b=SpriteMorph.prototype.blockColor[a];var c=new BlockDialogMorph(null,d=>{""!==d.spec&&SnapActions.addCustomBlock(d,this).then(e=>{(new BlockEditorMorph(e,this)).popUp()})},this);"variables"!==a&&(c.category=a,c.categories.children.forEach(d=>d.refresh()),c.types.children.forEach(d=>{d.setColor(b);d.refresh()}));c.prompt("Make a block",null,this.world())}; SpriteMorph.prototype.palette=function(a){this.paletteCache[a]||(this.paletteCache[a]=this.freshPalette(a));return this.paletteCache[a]}; SpriteMorph.prototype.freshPalette=function(a){var b=new ScrollFrameMorph(null,null,this.sliderColor),c=SyntaxElementMorph.prototype.fontSize,d=0,e=5,f=0,g=!1,h=this.parentThatIsA(StageMorph);var k=new Color(140,140,140);b.owner=this;b.padding=c/2;b.color=this.paletteColor;b.growth=new Point(0,MorphicPreferences.scrollBarSize);b.toolBar=new AlignmentMorph("column");var l=new PushButtonMorph(this,"searchBlocks",new SymbolMorph("magnifierOutline",16));l.alpha=.2;l.padding=1;l.hint=localize("find blocks")+ -"...";l.labelShadowColor=k;l.edge=0;l.padding=3;l.fixLayout();b.toolBar.add(l);l=new PushButtonMorph(this,"makeBlock",new SymbolMorph("cross",16));l.alpha=.2;l.padding=1;l.hint=localize("Make a block")+"...";l.labelShadowColor=k;l.edge=0;l.padding=3;l.fixLayout();b.toolBar.add(l);b.toolBar.fixLayout();b.add(b.toolBar);b.userMenu=function(){var m=this,n=new MenuMorph,p=this.parentThatIsA(IDE_Morph),r={operators:["reifyScript","reifyReporter","reifyPredicate"],control:["doWarp"],variables:"doDeclareVariables reportNewList reportNumbers reportCONS reportListItem reportCDR reportListLength reportListIndex reportConcatenatedLists reportListContainsItem reportListIsEmpty doForEach reportMap reportKeep reportFindFirst reportCombine doAddToList doDeleteFromList doInsertInList doReplaceInList".split(" ")}; -n.addPair([new SymbolMorph("magnifyingGlass",MorphicPreferences.menuFontSize),localize("find blocks")+"..."],function(){return m.searchBlocks()},"^F");(function(){return b.contents.children.some(function(t){return contains(Object.keys(SpriteMorph.prototype.blocks),t.selector)})})()&&n.addItem("hide primitives",function(){var t=SpriteMorph.prototype.blocks;Object.keys(t).forEach(function(u){t[u].category===a&&(StageMorph.prototype.hiddenPrimitives[u]=!0)});(r[a]||[]).forEach(function(u){return StageMorph.prototype.hiddenPrimitives[u]= -!0});p.flushBlocksCache(a);p.refreshPalette()});(function(){var t=SpriteMorph.prototype.blocks;return Object.keys(StageMorph.prototype.hiddenPrimitives).some(function(u){return!isNil(t[u])&&(t[u].category===a||contains(r[a]||[],u))})})()&&n.addItem("show primitives",function(){var t=SpriteMorph.prototype.blocks;Object.keys(StageMorph.prototype.hiddenPrimitives).forEach(function(u){t[u]&&t[u].category===a&&delete StageMorph.prototype.hiddenPrimitives[u]});(r[a]||[]).forEach(function(u){return delete StageMorph.prototype.hiddenPrimitives[u]}); -p.flushBlocksCache(a);p.refreshPalette()});if(SnapUndo.canUndo("palette")){var q=p.serializer.parse(SnapUndo.eventHistory.palette[SnapUndo.eventHistory.palette.length-1].args[2]);n.addItem('restore "'+q.attributes.s+'"',function(){SnapUndo.undo("palette")})}return n};k=this.blocksCache[a];k||(k=this.blockTemplates(a),this.isCachingPrimitives&&(this.blocksCache[a]=k));k.forEach(function(m){null!==m&&("-"===m?g||(e+=.8*c,g=!0):"="===m?g||(e+=1.6*c,g=!0):"#"===m?(d=0,e=f):(g=!1,0===d&&(e+=.3*c),m.setPosition(new Point(d, -e)),b.addContents(m),m instanceof ToggleMorph||m instanceof RingMorph?(d=m.right()+c/2,f=m.bottom()):(d=0,e+=m.height())))});h&&(e+=1.6*c,h.globalBlocks.forEach(function(m){if("custom"===a||m.category===a)m=m.templateInstance(),e+=.3*c,m.setPosition(new Point(d,e)),b.addContents(m),d=0,e+=m.height()}));e+=1.6*c;this.customBlocks.forEach(function(m){if("custom"===a||m.category===a)m=m.templateInstance(),e+=.3*c,m.setPosition(new Point(d,e)),b.addContents(m),d=0,e+=m.height()});this.exemplar&&this.inheritedBlocks(!0).forEach(function(m){if(m.category=== -a||"variables"===a&&contains(["lists","other"],m.category))m=m.templateInstance(),e+=.3*c,m.setPosition(new Point(d,e)),b.addContents(m),m.ghost(),d=0,e+=m.height()});b.scrollX(b.padding);b.scrollY(b.padding);return b}; -SpriteMorph.prototype.blocksMatching=function(a,b,c,d){function e(n){return BlockMorph.prototype.parseSpec(n).filter(function(p){return 0!==p.indexOf("%")}).join(" ")}function f(n,p){n=" "+n;p=n.indexOf(p);if(-1===p)return-1;n=" "===n.charAt(p-1);if(b&&!n)return-1;for(p=String(p);4>p.length;)p="0"+p;return(n?"1":"2")+p}var g=this,h=[],k=a.toLowerCase(),l=this.parentThatIsA(StageMorph);c&&c.length||(c=["hat","command","reporter","predicate","ring"]);d||(d=[]);d.forEach(function(n){var p=f(e(n.toLowerCase()), -k);-1!==p&&h.push([g.variableBlock(n),p+"1"])});[this.customBlocks,l.globalBlocks].forEach(function(n){return n.forEach(function(p){if(contains(c,p.type)){var r=p.localizedSpec().toLowerCase();r=f(e(r),k);-1!==r&&h.push([p.templateInstance(),r+"2"])}})});var m=SpriteMorph.prototype.blocks;Object.keys(m).forEach(function(n){if(!StageMorph.prototype.hiddenPrimitives[n]&&contains(c,m[n].type)&&!m[n].deprecated){var p=m[n],r=localize(p.alias||p.spec).toLowerCase();r=f(e(r),k);-1===r||p.dev||p.only&&p.only!== -g.constructor||(p=h.push,n=SpriteMorph.prototype.blockForSelector(n,!0),n.isTemplate=!0,p.call(h,[n,r+"3"]))}});contains(c,"reporter")&&(a=this.reporterize(a))&&h.push([a,""]);h.sort(function(n,p){return n[1]t.length)){t=t.toLowerCase();console.log("searching with query:",t);t=k.findBlocks({specs:[t]});console.log("found",t.length,"blocks");if(t.length){var u={};t.map(function(w){return k.blockAddress(w).join(" => ")}).forEach(function(w){u[w]=void 0===u[w]?1:u[w]+1});t="";for(var v in u)1t&&(t=p.length- -1);r=p[t];e();break;case 40:if(!d||!r)break;t=p.indexOf(r)+1;t>=p.length&&(t=0);r=p[t];e();break;default:nop()}};n.reactToInput=function(t){t=m.getValue();t!==l&&(l=t,f(g.blocksMatching(t,2>t.length,b,c)))};m.cancel=function(){k.refreshPalette();k.palette.adjustScrollBars()};k.fixLayout("refreshPalette");m.edit();a&&n.reactToKeystroke()}; -SpriteMorph.prototype.reporterize=function(a){function b(e,f,g){function h(p){return p instanceof Array||isNaN(+p)?p:+p}function k(){for(var p=1,r="";m":case "&":case "|":if(f||l[0].length)if(f){if(l[1].length)return b(e.slice(m), +"...";l.labelShadowColor=k;l.edge=0;l.padding=3;l.fixLayout();b.toolBar.add(l);l=new PushButtonMorph(this,"makeBlock",new SymbolMorph("cross",16));l.alpha=.2;l.padding=1;l.hint=localize("Make a block")+"...";l.labelShadowColor=k;l.edge=0;l.padding=3;l.fixLayout();b.toolBar.add(l);b.toolBar.fixLayout();b.add(b.toolBar);b.userMenu=function(){var m=new MenuMorph,n=this.parentThatIsA(IDE_Morph),p={operators:["reifyScript","reifyReporter","reifyPredicate"],control:["doWarp"],variables:"doDeclareVariables reportNewList reportNumbers reportCONS reportListItem reportCDR reportListLength reportListIndex reportConcatenatedLists reportListContainsItem reportListIsEmpty doForEach reportMap reportKeep reportFindFirst reportCombine doAddToList doDeleteFromList doInsertInList doReplaceInList".split(" ")}; +m.addPair([new SymbolMorph("magnifyingGlass",MorphicPreferences.menuFontSize),localize("find blocks")+"..."],()=>this.searchBlocks(),"^F");(function(){return b.contents.children.some(r=>contains(Object.keys(SpriteMorph.prototype.blocks),r.selector))})()&&m.addItem("hide primitives",function(){var r=SpriteMorph.prototype.blocks;Object.keys(r).forEach(t=>{r[t].category===a&&(StageMorph.prototype.hiddenPrimitives[t]=!0)});(p[a]||[]).forEach(t=>StageMorph.prototype.hiddenPrimitives[t]=!0);n.flushBlocksCache(a); +n.refreshPalette()});(function(){var r=SpriteMorph.prototype.blocks;return Object.keys(StageMorph.prototype.hiddenPrimitives).some(t=>!isNil(r[t])&&(r[t].category===a||contains(p[a]||[],t)))})()&&m.addItem("show primitives",function(){var r=SpriteMorph.prototype.blocks;Object.keys(StageMorph.prototype.hiddenPrimitives).forEach(t=>{r[t]&&r[t].category===a&&delete StageMorph.prototype.hiddenPrimitives[t]});(p[a]||[]).forEach(t=>delete StageMorph.prototype.hiddenPrimitives[t]);n.flushBlocksCache(a); +n.refreshPalette()});if(SnapUndo.canUndo("palette")){var q=n.serializer.parse(SnapUndo.eventHistory.palette[SnapUndo.eventHistory.palette.length-1].args[2]);m.addItem('restore "'+q.attributes.s+'"',function(){SnapUndo.undo("palette")})}return m};k=this.blocksCache[a];k||(k=this.blockTemplates(a),this.isCachingPrimitives&&(this.blocksCache[a]=k));k.forEach(m=>{null!==m&&("-"===m?g||(e+=.8*c,g=!0):"="===m?g||(e+=1.6*c,g=!0):"#"===m?(d=0,e=f):(g=!1,0===d&&(e+=.3*c),m.setPosition(new Point(d,e)),b.addContents(m), +m instanceof ToggleMorph||m instanceof RingMorph?(d=m.right()+c/2,f=m.bottom()):(d=0,e+=m.height())))});h&&(e+=1.6*c,h.globalBlocks.forEach(function(m){if("custom"===a||m.category===a)m=m.templateInstance(),e+=.3*c,m.setPosition(new Point(d,e)),b.addContents(m),d=0,e+=m.height()}));e+=1.6*c;this.customBlocks.forEach(function(m){if("custom"===a||m.category===a)m=m.templateInstance(),e+=.3*c,m.setPosition(new Point(d,e)),b.addContents(m),d=0,e+=m.height()});this.exemplar&&this.inheritedBlocks(!0).forEach(m=> +{if(m.category===a||"variables"===a&&contains(["lists","other"],m.category))m=m.templateInstance(),e+=.3*c,m.setPosition(new Point(d,e)),b.addContents(m),m.ghost(),d=0,e+=m.height()});b.scrollX(b.padding);b.scrollY(b.padding);return b}; +SpriteMorph.prototype.blocksMatching=function(a,b,c,d){function e(m){return BlockMorph.prototype.parseSpec(m).filter(n=>0!==n.indexOf("%")).join(" ")}function f(m,n){m=" "+m;n=m.indexOf(n);if(-1===n)return-1;m=" "===m.charAt(n-1);if(b&&!m)return-1;for(n=String(n);4>n.length;)n="0"+n;return(m?"1":"2")+n}var g=[],h=a.toLowerCase(),k=this.parentThatIsA(StageMorph);c&&c.length||(c=["hat","command","reporter","predicate","ring"]);d||=[];d.forEach(m=>{var n=f(e(m.toLowerCase()),h);-1!==n&&g.push([this.variableBlock(m), +n+"1"])});[this.customBlocks,k.globalBlocks].forEach(m=>m.forEach(n=>{if(contains(c,n.type)){var p=n.localizedSpec().toLowerCase();p=f(e(p),h);-1!==p&&g.push([n.templateInstance(),p+"2"])}}));var l=SpriteMorph.prototype.blocks;Object.keys(l).forEach(m=>{if(!StageMorph.prototype.hiddenPrimitives[m]&&contains(c,l[m].type)&&!l[m].deprecated){var n=l[m],p=localize(n.alias||n.spec).toLowerCase();p=f(e(p),h);-1===p||n.dev||n.only&&n.only!==this.constructor||(n=g.push,m=SpriteMorph.prototype.blockForSelector(m, +!0),m.isTemplate=!0,n.call(g,[m,p+"3"]))}});contains(c,"reporter")&&(a=this.reporterize(a))&&g.push([a,""]);g.sort((m,n)=>m[1]m[0])}; +SpriteMorph.prototype.searchBlocks=function(a,b,c,d){function e(){r&&r.destroy();q&&d&&(r=q.outline(MorphicPreferences.isFlat?new Color(150,200,255):WHITE,2),n.contents.add(r),r.scrollIntoView())}function f(t){var u=n.contents.left()+5,v=m.bottom()+h;p=t;q=null;t.length&&d&&(q=t[0]);n.contents.children=[n.contents.children[0]];t.forEach(w=>{w.setPosition(new Point(u,v));n.addContents(w);v+=w.height();v+=.3*h});e();n.changed()}var g=this,h=SyntaxElementMorph.prototype.fontSize,k=this.parentThatIsA(IDE_Morph), +l="",m=new InputFieldMorph(a||""),n=k.createPalette("forSearch"),p=[],q,r;n.mouseClickLeft=function(){16===world.currentKey&&k.prompt("Search for used blocks",function(t){if(t&&!(3>t.length)){t=t.toLowerCase();console.log("searching with query:",t);t=k.findBlocks({specs:[t]});console.log("found",t.length,"blocks");if(t.length){var u={};t.map(function(w){return k.blockAddress(w).join(" => ")}).forEach(function(w){u[w]=void 0===u[w]?1:u[w]+1});t="";for(var v in u)1t&&(t=p.length- +1);q=p[t];e();break;case 40:if(!d||!q)break;t=p.indexOf(q)+1;t>=p.length&&(t=0);q=p[t];e();break;default:nop()}};n.reactToInput=function(t){t=m.getValue();t!==l&&(l=t,f(g.blocksMatching(t,2>t.length,b,c)))};m.cancel=function(){k.refreshPalette();k.palette.adjustScrollBars()};k.fixLayout("refreshPalette");m.edit();a&&n.reactToKeystroke()}; +SpriteMorph.prototype.reporterize=function(a){function b(e,f,g){function h(p){return p instanceof Array||isNaN(+p)?p:+p}function k(){for(var p=1,q="";m":case "&":case "|":if(f||l[0].length)if(f){if(l[1].length)return b(e.slice(m), n,[f,g,h(l[1])]);l[1]=n}else f=n,g=h(l[0]);else l[0]=n;break;default:l[f?1:0]+=n}return f?[f,g,h(l[1])]:h(l[0])}function c(e){var f=1,g={};var h={"+":"reportVariadicSum","-":"reportDifference","*":"reportVariadicProduct","/":"reportQuotient","%":"reportModulus","^":"reportPower","=":"reportEquals","<":"reportLessThan",">":"reportGreaterThan","&":"reportAnd","|":"reportOr",round:"reportRound",not:"reportNot"};var k="abs neg ceiling floor sqrt sin cos tan asin acos atan ln log lg id round not".split(" "); -k.concat(["true","false"]).forEach(function(m){return g[localize(m).toLowerCase()]=m});var l={ceil:"ceiling","!":"not"}[e[0]]||g[e[0].toLowerCase()]||e[0];contains(k,l)?(h=h[l])?(h=SpriteMorph.prototype.blockForSelector(h),k=h.inputs()):(h=SpriteMorph.prototype.blockForSelector("reportMonadic"),k=h.inputs(),k[0].setContents([l]),f=0):(h=SpriteMorph.prototype.blockForSelector(h[l]),k=h.inputs());for(l=1;lg[localize(m).toLowerCase()]=m);var l={ceil:"ceiling","!":"not"}[e[0]]||g[e[0].toLowerCase()]||e[0];contains(k,l)?(h=h[l])?(h=SpriteMorph.prototype.blockForSelector(h),k=h.inputs()):(h=SpriteMorph.prototype.blockForSelector("reportMonadic"),k=h.inputs(),k[0].setContents([l]),f=0):(h=SpriteMorph.prototype.blockForSelector(h[l]),k=h.inputs());for(l=1;l{f.cachedPropagation&&f.inheritsAttribute("costume #")&&(null===e?f.wearCostume(null, !0):-1===e?f.wearCostume(a,!0):f.doSwitchToCostume(e+1,!0))})};SpriteMorph.prototype.getCostumeIdx=function(){return this.inheritsAttribute("costume #")?this.exemplar.getCostumeIdx():this.costumes.asArray().indexOf(this.costume)+1};SpriteMorph.prototype.doWearNextCostume=function(){var a=this.costumes.asArray();if(1a.length-1&&(b=0),this.wearCostume(a[b]))}}; SpriteMorph.prototype.doWearPreviousCostume=function(){var a=this.costumes.asArray();if(1b&&(b=a.length-1),this.wearCostume(a[b]))}}; SpriteMorph.prototype.doSwitchToCostume=function(a,b){if(a instanceof List){if(this.costume){var c=this.costume.width();var d=this.costume.height()}else c=StageMorph.prototype.dimensions.x,d=StageMorph.prototype.dimensions.y;a=Process.prototype.reportNewCostume(a,c,d,this.newCostumeName(localize("snap")))}if(a instanceof Costume)this.wearCostume(a,b);else if(!(a instanceof Array&&"current"===a[0])){c=this.costumes.asArray();if(contains([localize("Turtle"),localize("Empty")],a instanceof Array?a[0]: -null))d=null;else{if(-1===a){this.doWearPreviousCostume();return}d=detect(c,function(e){return e.name===a});null===d&&(d=parseFloat(a),d=0===d?null:c[d-1]||null)}this.wearCostume(d,b)}};SpriteMorph.prototype.reportCostumes=function(){return this.costumes};SpriteMorph.prototype.addSound=function(a){this.shadowAttribute("sounds");this.sounds.add(a);return a}; -SpriteMorph.prototype.doPlaySound=function(a){var b=this.parentThatIsA(StageMorph),c=a instanceof Sound?a:"number"===typeof a?this.sounds.at(a):detect(this.sounds.asArray(),function(h){return h.name===a.toString()}),d=this.audioContext(),e=this.getGainNode(),f=this.getPannerNode();if(c){var g=document.createElement("audio");g.src=c.audio.src;d.resume();c=d.createMediaElementSource(g);c.connect(e);f?(e.connect(f),f.connect(d.destination),this.setPan(this.getPan())):e.connect(d.destination);this.setVolume(this.getVolume()); -g.play();b&&(b.activeSounds.push(g),b.activeSounds=b.activeSounds.filter(function(h){return!h.ended&&!h.terminated}));return g}};SpriteMorph.prototype.reportSounds=function(){return this.sounds}; -SpriteMorph.prototype.setVolume=function(a,b){this.volume=Math.max(Math.min(+a||0,100),0);this.getGainNode().gain.setValueAtTime(1/Math.pow(10,Math.log2(100/this.volume)),this.audioContext().currentTime);this instanceof StageMorph||(b||this.shadowAttribute("volume"),this.instances.forEach(function(c){c.cachedPropagation&&c.inheritsAttribute("volume")&&c.setVolume(a,!0)}))};SpriteMorph.prototype.changeVolume=function(a){this.setVolume(this.getVolume()+(+a||0))}; +null))d=null;else{if(-1===a){this.doWearPreviousCostume();return}d=detect(c,e=>e.name===a);null===d&&(d=parseFloat(a),d=0===d?null:c[d-1]||null)}this.wearCostume(d,b)}};SpriteMorph.prototype.reportCostumes=function(){return this.costumes};SpriteMorph.prototype.addSound=function(a){this.shadowAttribute("sounds");this.sounds.add(a);return a}; +SpriteMorph.prototype.doPlaySound=function(a){var b=this.parentThatIsA(StageMorph),c=a instanceof Sound?a:"number"===typeof a?this.sounds.at(a):detect(this.sounds.asArray(),h=>h.name===a.toString()),d=this.audioContext(),e=this.getGainNode(),f=this.getPannerNode();if(c){var g=document.createElement("audio");g.src=c.audio.src;d.resume();c=d.createMediaElementSource(g);c.connect(e);f?(e.connect(f),f.connect(d.destination),this.setPan(this.getPan())):e.connect(d.destination);this.setVolume(this.getVolume()); +g.play();b&&(b.activeSounds.push(g),b.activeSounds=b.activeSounds.filter(h=>!h.ended&&!h.terminated));return g}};SpriteMorph.prototype.reportSounds=function(){return this.sounds}; +SpriteMorph.prototype.setVolume=function(a,b){this.volume=Math.max(Math.min(+a||0,100),0);this.getGainNode().gain.setValueAtTime(1/Math.pow(10,Math.log2(100/this.volume)),this.audioContext().currentTime);this instanceof StageMorph||(b||this.shadowAttribute("volume"),this.instances.forEach(c=>{c.cachedPropagation&&c.inheritsAttribute("volume")&&c.setVolume(a,!0)}))};SpriteMorph.prototype.changeVolume=function(a){this.setVolume(this.getVolume()+(+a||0))}; SpriteMorph.prototype.getVolume=function(){return this.inheritsAttribute("volume")?this.exemplar.getVolume():this.volume};SpriteMorph.prototype.getGainNode=function(){this.gainNode||(this.gainNode=this.audioContext().createGain());return this.gainNode};SpriteMorph.prototype.audioContext=function(){return Note.prototype.getAudioContext()}; -SpriteMorph.prototype.setPan=function(a,b){var c=this.getPannerNode();c&&(this.pan=Math.max(Math.min(+a||0,100),-100),c.pan.setValueAtTime(this.pan/100,this.audioContext().currentTime),this instanceof StageMorph||(b||this.shadowAttribute("balance"),this.instances.forEach(function(d){d.cachedPropagation&&d.inheritsAttribute("balance")&&d.setPan(a,!0)})))};SpriteMorph.prototype.changePan=function(a){this.setPan(this.getPan()+(+a||0))}; +SpriteMorph.prototype.setPan=function(a,b){var c=this.getPannerNode();c&&(this.pan=Math.max(Math.min(+a||0,100),-100),c.pan.setValueAtTime(this.pan/100,this.audioContext().currentTime),this instanceof StageMorph||(b||this.shadowAttribute("balance"),this.instances.forEach(d=>{d.cachedPropagation&&d.inheritsAttribute("balance")&&d.setPan(a,!0)})))};SpriteMorph.prototype.changePan=function(a){this.setPan(this.getPan()+(+a||0))}; SpriteMorph.prototype.getPan=function(){return this.inheritsAttribute("balance")?this.exemplar.getPan():this.pan};SpriteMorph.prototype.getPannerNode=function(){if(!this.pannerNode){var a=this.audioContext();a.createStereoPanner&&(this.pannerNode=this.audioContext().createStereoPanner())}return this.pannerNode}; SpriteMorph.prototype.playFreq=function(a){var b=this.audioContext(),c=this.getGainNode(),d=this.getPannerNode(),e=this.parentThatIsA(StageMorph);this.freqPlayer||(this.freqPlayer=new Note);var f=this.freqPlayer;f.fader=b.createGain();f.oscillator?f.oscillator.frequency.value=a:(f.oscillator=b.createOscillator(),f.oscillator.start||(f.oscillator.start=f.oscillator.noteOn),f.oscillator.stop||(f.oscillator.stop=f.oscillator.noteOff),f.setInstrument(this.instrument),f.oscillator.frequency.value=a,this.setVolume(this.getVolume()), -f.oscillator.connect(f.fader),f.fader.connect(c),d?(c.connect(d),d.connect(b.destination),this.setPan(this.pan)):c.connect(b.destination),f.ended=!1,e&&(e.activeSounds.push(f),e.activeSounds=e.activeSounds.filter(function(g){return!g.ended&&!g.terminated})),f.fader.gain.setValueCurveAtTime(f.fadeIn,b.currentTime,f.fadeTime),f.oscillator.start(0))};SpriteMorph.prototype.stopFreq=function(){this.freqPlayer&&this.freqPlayer.stop()}; +f.oscillator.connect(f.fader),f.fader.connect(c),d?(c.connect(d),d.connect(b.destination),this.setPan(this.pan)):c.connect(b.destination),f.ended=!1,e&&(e.activeSounds.push(f),e.activeSounds=e.activeSounds.filter(g=>!g.ended&&!g.terminated)),f.fader.gain.setValueCurveAtTime(f.fadeIn,b.currentTime,f.fadeTime),f.oscillator.start(0))};SpriteMorph.prototype.stopFreq=function(){this.freqPlayer&&this.freqPlayer.stop()}; SpriteMorph.prototype.userMenu=function(){var a=this.parentThatIsA(IDE_Morph),b=new MenuMorph(this);if(a&&a.isAppMode)return b;this.isTemporary||(b.addItem("duplicate","duplicate"),StageMorph.prototype.enableInheritance&&(b.addItem("clone","instantiate"),b.addLine()));b.addItem("delete","remove");b.addItem("move","moveCenter");b.addItem("rotate","setRotation");this.costume&&b.addItem("pivot","moveRotationCenter","edit the costume's\nrotation center");this.isTemporary?StageMorph.prototype.enableInheritance&& -b.addItem("edit","perpetuateAndEdit","make permanent and\nshow in the sprite corral"):b.addItem("edit","edit");b.addLine();if(this.anchor)b.addItem(localize("detach from")+" "+this.anchor.name,function(){SnapActions.detachParts([this])});else{var c=this.allParts();a=this.parent.children.filter(function(d){return d instanceof SpriteMorph&&!contains(c,d)});a.length&&b.addMenu("stick to",this.anchorsMenu(a))}this.parts.length&&b.addItem("detach all parts",function(){SnapActions.detachParts(this.parts)}); -b.addItem("export...","exportSprite");return b};SpriteMorph.prototype.anchorsMenu=function(a){var b=new MenuMorph(this.attachTo,null,this);a.forEach(function(c){return b.addItem([c.thumbnail(new Point(24,24)),c.name],c)});return b};SpriteMorph.prototype.exportSprite=function(){if(!this.isTemporary){var a=this.parentThatIsA(IDE_Morph);a&&a.exportSprite(this)}};SpriteMorph.prototype.edit=function(){var a=this.parentThatIsA(IDE_Morph);a&&!a.isAppMode&&a.selectSprite(this)}; +b.addItem("edit","perpetuateAndEdit","make permanent and\nshow in the sprite corral"):b.addItem("edit","edit");b.addLine();if(this.anchor)b.addItem(localize("detach from")+" "+this.anchor.name,function(){SnapActions.detachParts([this])});else{var c=this.allParts();a=this.parent.children.filter(d=>d instanceof SpriteMorph&&!contains(c,d));a.length&&b.addMenu("stick to",this.anchorsMenu(a))}this.parts.length&&b.addItem("detach all parts",function(){SnapActions.detachParts(this.parts)});b.addItem("export...", +"exportSprite");return b};SpriteMorph.prototype.anchorsMenu=function(a){var b=new MenuMorph(this.attachTo,null,this);a.forEach(c=>b.addItem([c.thumbnail(new Point(24,24)),c.name],c));return b};SpriteMorph.prototype.exportSprite=function(){if(!this.isTemporary){var a=this.parentThatIsA(IDE_Morph);a&&a.exportSprite(this)}};SpriteMorph.prototype.edit=function(){var a=this.parentThatIsA(IDE_Morph);a&&!a.isAppMode&&a.selectSprite(this)}; SpriteMorph.prototype.showOnStage=function(){var a=this.parentThatIsA(StageMorph);a&&(this.keepWithin(a),a.add(this));this.show()};SpriteMorph.prototype.duplicate=function(){SnapActions.duplicateSprite(this)};SpriteMorph.prototype.instantiate=function(){var a=this.parentThatIsA(IDE_Morph);a&&a.instantiateSprite(this)};SpriteMorph.prototype.remove=function(){SnapActions.removeSprite(this)}; SpriteMorph.prototype.createClone=function(a){var b=this.parentThatIsA(StageMorph);if(b&&5E3>=b.cloneCount){var c=this.fullCopy(!0);c.clonify(b,a)}return c};SpriteMorph.prototype.newClone=function(a){a=this.createClone(a);if(isNil(a))throw Error("exceeding maximum number of clones");return a}; -SpriteMorph.prototype.clonify=function(a,b){var c=this;this.parts.forEach(function(d){return d.clonify(a)});a.cloneCount+=1;this.cloneOriginName=this.isTemporary?this.cloneOriginName:this.name;this.isTemporary=!0;this.name="";a.add(this);this.allHatBlocksFor("__clone__init__").forEach(function(d){return a.threads.startProcess(d,c,a.isThreadSafe,null,null,null,b)});this.endWarp()}; -SpriteMorph.prototype.initClone=function(a){var b=this,c=this.parentThatIsA(StageMorph);c&&(a.forEach(function(d){return c.threads.startProcess(d,b,c.isThreadSafe)}),this.endWarp())};SpriteMorph.prototype.removeClone=function(){var a=this,b=this.exemplar;this.isTemporary&&(this.parent.threads.stopAllForReceiver(this),this.parts.slice().forEach(function(c){a.detachPart(c);c.removeClone()}),this.corpsify(),this.instances.forEach(function(c){c.isTemporary&&c.setExemplar(b)}),this.destroy(),--this.parent.cloneCount)}; -SpriteMorph.prototype.perpetuate=function(){var a=this.parentThatIsA(StageMorph),b=this.parentThatIsA(IDE_Morph);this.exemplar&&this.exemplar.perpetuate();this.isTemporary&&a&&b&&(this.isTemporary=!1,this.name=b.newSpriteName(this.cloneOriginName),this.cloneOriginName="",--a.cloneCount,b.corral.addSprite(this),b.sprites.add(this),this.parts.forEach(function(c){return c.perpetuate()}))};SpriteMorph.prototype.perpetuateAndEdit=function(){var a=this.parentThatIsA(IDE_Morph);a&&(this.perpetuate(),a.selectSprite(this))}; -SpriteMorph.prototype.release=function(){var a=this,b=this.parentThatIsA(StageMorph),c=this.parentThatIsA(IDE_Morph);if(!this.isTemporary&&this.exemplar&&b&&c){this.parts.forEach(function(e){return e.release()});this.instances.forEach(function(e){return e.release()});this.isTemporary=!0;this.name="";this.cloneOriginName=this.exemplar.name;b.cloneCount+=1;var d=c.sprites.asArray().indexOf(this)+1;b.watchers().forEach(function(e){e.object()===a&&e.destroy()});0c.clonify(a));a.cloneCount+=1;this.cloneOriginName=this.isTemporary?this.cloneOriginName:this.name;this.isTemporary=!0;this.name="";a.add(this);this.allHatBlocksFor("__clone__init__").forEach(c=>a.threads.startProcess(c,this,a.isThreadSafe,null,null,null,b));this.endWarp()};SpriteMorph.prototype.initClone=function(a){var b=this.parentThatIsA(StageMorph);b&&(a.forEach(c=>b.threads.startProcess(c,this,b.isThreadSafe)),this.endWarp())}; +SpriteMorph.prototype.removeClone=function(){var a=this.exemplar;this.isTemporary&&(this.parent.threads.stopAllForReceiver(this),this.parts.slice().forEach(b=>{this.detachPart(b);b.removeClone()}),this.corpsify(),this.instances.forEach(b=>{b.isTemporary&&b.setExemplar(a)}),this.destroy(),--this.parent.cloneCount)}; +SpriteMorph.prototype.perpetuate=function(){var a=this.parentThatIsA(StageMorph),b=this.parentThatIsA(IDE_Morph);this.exemplar&&this.exemplar.perpetuate();this.isTemporary&&a&&b&&(this.isTemporary=!1,this.name=b.newSpriteName(this.cloneOriginName),this.cloneOriginName="",--a.cloneCount,b.corral.addSprite(this),b.sprites.add(this),this.parts.forEach(c=>c.perpetuate()))};SpriteMorph.prototype.perpetuateAndEdit=function(){var a=this.parentThatIsA(IDE_Morph);a&&(this.perpetuate(),a.selectSprite(this))}; +SpriteMorph.prototype.release=function(){var a=this.parentThatIsA(StageMorph),b=this.parentThatIsA(IDE_Morph);if(!this.isTemporary&&this.exemplar&&a&&b){this.parts.forEach(d=>d.release());this.instances.forEach(d=>d.release());this.isTemporary=!0;this.name="";this.cloneOriginName=this.exemplar.name;a.cloneCount+=1;var c=b.sprites.asArray().indexOf(this)+1;a.watchers().forEach(d=>{d.object()===this&&d.destroy()});0d instanceof SpriteMorph&&!d.isTemporary)||this.stage);b.selectSprite(b.currentSprite);b.isAppMode&&b.toggleAppMode(!0)}};SpriteMorph.prototype.corpsify=function(){this.isCorpse=!0;this.version=Date.now()};SpriteMorph.prototype.show=function(){this.setVisibility(!0)};SpriteMorph.prototype.hide=function(){this.setVisibility(!1)}; +SpriteMorph.prototype.setVisibility=function(a,b){var c=this.talkBubble();a?SpriteMorph.uber.show.call(this):SpriteMorph.uber.hide.call(this);c&&(a?c.show():c.hide());this.parts.forEach(d=>d.setVisibility(a));b||this.shadowAttribute("shown?");this.instances.forEach(d=>{d.cachedPropagation&&d.inheritsAttribute("shown?")&&d.setVisibility(a,!0)})};SpriteMorph.prototype.reportShown=function(){return this.inheritsAttribute("shown?")?this.exemplar.reportShown():this.isVisible}; SpriteMorph.prototype.setColorComponentHSVA=function(a,b){var c=this.xPosition(),d=this.yPosition();b=+b;a=+a;if(!(0>a||3b||100b?100:0)+b%100}else b=Math.min(100,Math.max(0,b));3===a?this.color.a=1-b/100:(this.cachedHSV[a]=b/100,this.color.set_hsv.apply(this.color,this.cachedHSV));this.costume||this.rerender();this.gotoXY(c,d)}};SpriteMorph.prototype.getColorComponentHSLA=function(a){a=+a;return 3===a?100*(1-this.color.a):100*(this.cachedHSV[a]||0)}; SpriteMorph.prototype.changeColorComponentHSVA=function(a,b){this.setColorComponentHSVA(a,this.getColorComponentHSLA(a)+(+b||0))};SpriteMorph.prototype.setColor=function(a){var b=this.xPosition(),c=this.yPosition();this.color.eq(a,!0)||(this.color=a.copy(),this.costume||(this.rerender(),this.silentGotoXY(b,c)),this.cachedHSV=this.color.hsv())};SpriteMorph.prototype.setBackgroundColor=SpriteMorph.prototype.setColor; SpriteMorph.prototype.getPenAttribute=function(a){a=a instanceof Array?a[0]:a.toString();return"size"===a?this.size||0:this.getColorComponentHSLA(["hue","saturation","brightness","transparency"].indexOf(a))};SpriteMorph.prototype.comeToFront=function(){this.parent&&(this.parent.add(this),this.changed())};SpriteMorph.prototype.goToBack=function(){this.parent&&(this.parent.addBack(this),this.changed())}; @@ -1616,36 +1543,36 @@ f.y);d.rotate(e);d.fillText(a,0,0);d.translate(-f.x,-f.y);d.restore();a=new Poin SpriteMorph.prototype.pasteOn=function(a){var b=1===this.rotationStyle?this.heading:90,c=1===a.rotationStyle?a.heading:90;if(this!==a&&this.costume&&a.costume){var d=this.costume;d instanceof SVG_Costume&&(d=d.rasterized());var e=a.costume instanceof SVG_Costume?a.costume.rasterized():a.costume.copy();if(a instanceof SpriteMorph)if(this instanceof SpriteMorph){var f=b-c;var g=this.scale/a.scale;c=this.parentThatIsA(StageMorph).scale;var h=a.center().distanceTo(this.center());var k=this.center().subtract(a.center()); k=Math.atan2(k.y,k.x);var l=(new Point(d.width(),d.height())).multiplyBy(.5*this.scale*c);var m=l.distanceTo(ZERO);l=Math.atan2(l.y,l.x);var n=(new Point(a.costume.width(),a.costume.height())).multiplyBy(.5*a.scale*c).rotateBy(radians(f));b=n.distanceAngle(h,degrees(k)-b+180);b=b.distanceAngle(m,degrees(l)-90);b=b.divideBy(c).divideBy(g).divideBy(a.scale)}else f=90-c,g=1/a.scale,h=a.center().distanceTo(this.position()),k=this.position().subtract(a.center()),k=Math.atan2(k.y,k.x),l=(new Point(a.costume.width(), a.costume.height())).multiplyBy(.5*a.scale).rotateBy(radians(90-c)),b=l.distanceAngle(h/this.scale,degrees(k)+90);else f=b-90,g=this.scale,l=this.center().subtract(a.position()).divideBy(this.scale*a.scale).rotateBy(radians(b-90)),b=l.subtract((new Point(d.width(),d.height())).multiplyBy(.5));c=e.contents.getContext("2d");c.rotate(radians(f));c.scale(g,g);c.globalCompositeOperation="source-atop";c.drawImage(d.contents,b.x,b.y);a.doSwitchToCostume(e)}};SpriteMorph.prototype.down=function(){this.setPenDown(!0)}; -SpriteMorph.prototype.up=function(){this.setPenDown(!1)};SpriteMorph.prototype.setPenDown=function(a,b){a?SpriteMorph.uber.down.call(this):SpriteMorph.uber.up.call(this);b||this.shadowAttribute("pen down?");this.instances.forEach(function(c){c.cachedPropagation&&c.inheritsAttribute("pen down?")&&c.setPenDown(a,!0)})};SpriteMorph.prototype.getPenDown=function(){return this.inheritsAttribute("pen down?")?this.exemplar.getPenDown():this.isDown}; +SpriteMorph.prototype.up=function(){this.setPenDown(!1)};SpriteMorph.prototype.setPenDown=function(a,b){a?SpriteMorph.uber.down.call(this):SpriteMorph.uber.up.call(this);b||this.shadowAttribute("pen down?");this.instances.forEach(c=>{c.cachedPropagation&&c.inheritsAttribute("pen down?")&&c.setPenDown(a,!0)})};SpriteMorph.prototype.getPenDown=function(){return this.inheritsAttribute("pen down?")?this.exemplar.getPenDown():this.isDown}; SpriteMorph.prototype.getScale=function(){return this.inheritsAttribute("size")?this.exemplar.getScale():100*this.scale}; -SpriteMorph.prototype.setScale=function(a,b){var c=this.xPosition(),d=this.yPosition();var e=(+a||0)/100;var f=e/this.nestingScale;this.nestingScale=e;this.scale=Math.max(e,.01);this.changed();this.fixLayout();this.rerender();this.silentGotoXY(c,d,!0);this.positionTalkBubble();this.parts.forEach(function(g){var h=g.xPosition()-c,k=g.yPosition()-d;g.setScale(100*g.scale*f);g.silentGotoXY(c+h*f,d+k*f)});b||this.shadowAttribute("size");this.instances.forEach(function(g){g.cachedPropagation&&g.inheritsAttribute("size")&& -g.setScale(a,!0)})};SpriteMorph.prototype.changeScale=function(a){this.setScale(this.getScale()+(+a||0))};SpriteMorph.prototype.graphicsChanged=function(){var a=this;return Object.keys(this.graphicsValues).some(function(b){return 0>a.graphicsValues[b]||0=E?(D=Math.atan2(D,C),C=Math.floor(A+E*Math.cos(D)*A),D=Math.floor(B+E*Math.sin(D)*B)):(C=t,D=u);E=4*(u*v+t);C=4*(D*v+C);x[E]=r[C];x[E+1]=r[C+1];x[E+2]=r[C+2];x[E+3]=r[C+3]}return y}function c(r,q){var t; -var u=r.width;var v=r.height;r=r.data;var w=p.createImageData(u,v);var y=w.data;var x=u/2;var A=v/2;var B=Math.min(x,A);if(uL&&(L+=360);C/=255;L=(L+360*q/200)%360; -x=Math.max(0,Math.min(x+t/100,1));C=Math.max(0,Math.min(C+u/100,1));A=Math.floor(L/60);E=L/60-A;B=C*(1-x);D=C*(1-x*E);x=C*(1-x*(1-E));if(0===A||6===A){var I=C;var F=x;var G=B}else 1===A?(I=D,F=C,G=B):2===A?(I=B,F=C,G=x):3===A?(I=B,F=D,G=C):4===A?(I=x,F=B,G=C):5===A&&(I=C,F=B,G=D);w[y]=255*I;w[y+1]=255*F;w[y+2]=255*G}return r}function h(r,q){var t;var u=r.data;var v=0;for(t=u.length;vw&&(u[v]-=q);u[v+1] -y&&(u[v+1]-=q);u[v+2]x&&(u[v+2]-=q)}return r}function k(r,q){var t;var u=r.data;var v=0;for(t=u.length;v{var h=g.xPosition()-c,k=g.yPosition()-d;g.setScale(100*g.scale*f);g.silentGotoXY(c+h*f,d+k*f)});b||this.shadowAttribute("size");this.instances.forEach(g=>{g.cachedPropagation&&g.inheritsAttribute("size")&& +g.setScale(a,!0)})};SpriteMorph.prototype.changeScale=function(a){this.setScale(this.getScale()+(+a||0))};SpriteMorph.prototype.graphicsChanged=function(){return Object.keys(this.graphicsValues).some(a=>0>this.graphicsValues[a]||0=F?(C=Math.atan2(C,B),B=Math.floor(z+F*Math.cos(C)*z),C=Math.floor(A+F*Math.sin(C)*A)):(B=t,C=u);F=4*(u*v+t);B=4*(C*v+B);x[F]=q[B];x[F+1]=q[B+1];x[F+2]=q[B+2];x[F+3]=q[B+3]}return y}function c(q,r){var t; +var u=q.width;var v=q.height;q=q.data;var w=p.createImageData(u,v);var y=w.data;var x=u/2;var z=v/2;var A=Math.min(x,z);if(uK&&(K+=360);B/=255;K=(K+360*r/200)%360; +x=Math.max(0,Math.min(x+t/100,1));B=Math.max(0,Math.min(B+u/100,1));z=Math.floor(K/60);F=K/60-z;A=B*(1-x);C=B*(1-x*F);x=B*(1-x*(1-F));if(0===z||6===z){var I=B;var D=x;var E=A}else 1===z?(I=C,D=B,E=A):2===z?(I=A,D=B,E=x):3===z?(I=A,D=C,E=B):4===z?(I=x,D=A,E=B):5===z&&(I=B,D=A,E=C);w[y]=255*I;w[y+1]=255*D;w[y+2]=255*E}return q}function h(q,r){var t;var u=q.data;var v=0;for(t=u.length;vw&&(u[v]-=r);u[v+1] +y&&(u[v+1]-=r);u[v+2]x&&(u[v+2]-=r)}return q}function k(q,r){var t;var u=q.data;var v=0;for(t=u.length;va instanceof SpeechBubbleMorph)}; SpriteMorph.prototype.positionTalkBubble=function(){var a=this.parentThatIsA(StageMorph),b=a?a.scale:1,c=this.talkBubble(),d=this.center().y;if(!c)return null;c.show();c.isPointingRight||(c.isPointingRight=!0,c.fixLayout(),c.rerender());c.setLeft(this.right());for(c.setBottom(this.top());!this.isTouching(c)&&c.bottom()a.right()&&(c.isPointingRight=!1,c.fixLayout(),c.rerender(),c.setRight(this.center().x));c.keepWithin(a)}; SpriteMorph.prototype.prepareToBeGrabbed=function(a){this.removeShadow();this.recordLayers();this.shadowAttribute("x position");this.shadowAttribute("y position");!this.bounds.containsPoint(a.position())&&this.isCorrectingOutsideDrag()&&this.setCenter(a.position());this.addShadow()};SpriteMorph.prototype.isCorrectingOutsideDrag=function(){return!this.parts.length}; -SpriteMorph.prototype.justDropped=function(){var a=this,b=this.parentThatIsA(StageMorph);b&&(SnapActions.setSpritePosition(this),b.enableCustomHatBlocks=!0);this.exemplar&&this.inheritedAttributes.forEach(function(c){contains(["direction","size","costume #"],c)&&a.refreshInheritedAttribute(c)});this.restoreLayers();this.positionTalkBubble();this.receiveUserInteraction("dropped")}; +SpriteMorph.prototype.justDropped=function(){var a=this.parentThatIsA(StageMorph);a&&(SnapActions.setSpritePosition(this),a.enableCustomHatBlocks=!0);this.exemplar&&this.inheritedAttributes.forEach(b=>{contains(["direction","size","costume #"],b)&&this.refreshInheritedAttribute(b)});this.restoreLayers();this.positionTalkBubble();this.receiveUserInteraction("dropped")}; SpriteMorph.prototype.drawLine=function(a,b){var c=this.parent.bounds.origin,d=this.parent.scale,e=this.parent.penTrails().getContext("2d"),f=a.subtract(c).divideBy(d),g=b.subtract(c).divideBy(d),h=f.multiplyBy(d).add(c);c=g.multiplyBy(d).add(c);d=h.rectangle(c).expandBy(Math.max(this.size*d/2,1)).intersect(this.parent.visibleBounds()).spread();this.isDown&&(StageMorph.prototype.enablePenLogging&&this.parent.trailsLog.push([this.snapPoint(a),this.snapPoint(b),this.color.copy(),this.size,this.useFlatLineEnds? "butt":"round"]),e.lineWidth=this.size,e.strokeStyle=this.color.toString(),this.useFlatLineEnds?(e.lineCap="butt",e.lineJoin="miter"):(e.lineCap="round",e.lineJoin="round"),e.beginPath(),e.moveTo(f.x,f.y),e.lineTo(g.x,g.y),e.stroke(),!1===this.isWarped&&this.world().broken.push(d),this.parent.cachedPenTrailsMorph=null)}; SpriteMorph.prototype.floodFill=function(){function a(m){m*=4;return[g[m],g[m+1],g[m+2],g[m+3]]}function b(m){return m[0]===k[0]&&m[1]===k[1]&&m[2]===k[2]&&m[3]===k[3]}if(this.parent.bounds.containsPoint(this.rotationCenter())){this.parent.cachedPenTrailsMorph=null;1d.moveBy(a)),this.instances.forEach(d=>{if(d.cachedPropagation){var e=d.inheritsAttribute("x position"),f=d.inheritsAttribute("y position");e&&f?d.moveBy(a):e?d.moveBy(new Point(a.x,0)):f&&d.moveBy(new Point(0,a.y))}}))}; +SpriteMorph.prototype.rootForGrab=function(){return this.anchor?this.anchor.rootForGrab():SpriteMorph.uber.rootForGrab.call(this)};SpriteMorph.prototype.setCenter=function(a,b){a=a.subtract(this.center());this.moveBy(a,b)};SpriteMorph.prototype.nestingBounds=function(){var a=this.bounds;!this.costume&&this.penBounds&&(a=this.penBounds.translateBy(this.position()));this.parts.forEach(b=>{b.isVisible&&(a=a.merge(b.nestingBounds()))});return a}; SpriteMorph.prototype.setPosition=function(a,b){a=a.subtract(this.topLeft());0===a.x&&0===a.y||this.moveBy(a,b)}; SpriteMorph.prototype.forward=function(a){a=a*this.parent.scale||0;0===a&&this.isDown?(this.isDown=!1,this.forward(-.05),this.isDown=!0,this.forward(.1),this.isDown=!1,this.forward(-.05),this.isDown=!0):(a=0<=a?this.position().distanceAngle(a,this.heading):this.position().distanceAngle(Math.abs(a),this.heading-180),this.shadowAttribute("x position"),this.shadowAttribute("y position"),this.setPosition(a),this.positionTalkBubble())}; -SpriteMorph.prototype.setHeading=function(a,b){var c=this.xPosition(),d=this.yPosition(),e=isFinite(a)?+a:0,f=e-this.heading;this.rotationStyle?(this.changed(),SpriteMorph.uber.setHeading.call(this,e),this.silentGotoXY(c,d,!0),this.positionTalkBubble()):this.heading=(+a%360+360)%360;this.parts.forEach(function(g){var h=(new Point(g.xPosition(),g.yPosition())).rotateBy(radians(f),new Point(c,d));g.rotatesWithAnchor&&g.turn(f);g.gotoXY(h.x,h.y)});b||this.shadowAttribute("direction");this.instances.forEach(function(g){g.cachedPropagation&& -g.inheritsAttribute("direction")&&g.setHeading(a,!0)})};SpriteMorph.prototype.faceToXY=function(a,b){this.setHeading(this.angleToXY(a,b))};SpriteMorph.prototype.angleToXY=function(a,b){a=(a-this.xPosition())*this.parent.scale;b=(b-this.yPosition())*this.parent.scale;return(.001>Math.abs(a)?0>b?90:270:Math.round((0<=a?0:180)-57.2957795131*Math.atan(b/a)))+90};SpriteMorph.prototype.turn=function(a){this.setHeading(this.heading+(+a||0))}; +SpriteMorph.prototype.setHeading=function(a,b){var c=this.xPosition(),d=this.yPosition(),e=isFinite(a)?+a:0,f=e-this.heading;this.rotationStyle?(this.changed(),SpriteMorph.uber.setHeading.call(this,e),this.silentGotoXY(c,d,!0),this.positionTalkBubble()):this.heading=(+a%360+360)%360;this.parts.forEach(g=>{var h=(new Point(g.xPosition(),g.yPosition())).rotateBy(radians(f),new Point(c,d));g.rotatesWithAnchor&&g.turn(f);g.gotoXY(h.x,h.y)});b||this.shadowAttribute("direction");this.instances.forEach(g=> +{g.cachedPropagation&&g.inheritsAttribute("direction")&&g.setHeading(a,!0)})};SpriteMorph.prototype.faceToXY=function(a,b){this.setHeading(this.angleToXY(a,b))};SpriteMorph.prototype.angleToXY=function(a,b){a=(a-this.xPosition())*this.parent.scale;b=(b-this.yPosition())*this.parent.scale;return(.001>Math.abs(a)?0>b?90:270:Math.round((0<=a?0:180)-57.2957795131*Math.atan(b/a)))+90};SpriteMorph.prototype.turn=function(a){this.setHeading(this.heading+(+a||0))}; SpriteMorph.prototype.turnLeft=function(a){this.setHeading(this.heading-(+a||0))};SpriteMorph.prototype.xPosition=function(){if(this.inheritsAttribute("x position"))return this.exemplar.xPosition();var a=this.parentThatIsA(StageMorph);!a&&this.parent.grabOrigin&&(a=this.parent.grabOrigin.origin);return a?(this.rotationCenter().x-a.center().x)/a.scale:this.rotationCenter().x}; SpriteMorph.prototype.yPosition=function(){if(this.inheritsAttribute("y position"))return this.exemplar.yPosition();var a=this.parentThatIsA(StageMorph);!a&&this.parent.grabOrigin&&(a=this.parent.grabOrigin.origin);return a?(a.center().y-this.rotationCenter().y)/a.scale:this.rotationCenter().y};SpriteMorph.prototype.direction=function(){return this.inheritsAttribute("direction")?this.exemplar.direction():this.heading};SpriteMorph.prototype.penSize=function(){return this.size}; SpriteMorph.prototype.gotoXY=function(a,b,c,d){var e=this.parentThatIsA(StageMorph);e&&(d||(this.shadowAttribute("x position"),this.shadowAttribute("y position")),a=isFinite(+a)?+a:0,b=isFinite(+b)?+b:0,a=e.center().x+a*e.scale,b=e.center().y-b*e.scale,b=this.costume?(new Point(a,b)).subtract(this.rotationOffset):(new Point(a,b)).subtract(this.extent().divideBy(2)),this.setPosition(b,c),this.positionTalkBubble())}; @@ -1658,73 +1585,71 @@ SpriteMorph.prototype.setPivot=function(a){var b=this.parentThatIsA(StageMorph); SpriteMorph.prototype.yCenter=function(){var a=this.parentThatIsA(StageMorph);!a&&this.parent.grabOrigin&&(a=this.parent.grabOrigin.origin);return a?(a.center().y-this.center().y)/a.scale:this.center().y};SpriteMorph.prototype.xLeft=function(){var a=this.parentThatIsA(StageMorph);!a&&this.parent.grabOrigin&&(a=this.parent.grabOrigin.origin);return a?(this.left()-a.center().x)/a.scale:this.left()}; SpriteMorph.prototype.xRight=function(){var a=this.parentThatIsA(StageMorph);!a&&this.parent.grabOrigin&&(a=this.parent.grabOrigin.origin);return a?(this.right()-a.center().x)/a.scale:this.right()};SpriteMorph.prototype.yTop=function(){var a=this.parentThatIsA(StageMorph);!a&&this.parent.grabOrigin&&(a=this.parent.grabOrigin.origin);return a?(a.center().y-this.top())/a.scale:this.top()}; SpriteMorph.prototype.yBottom=function(){var a=this.parentThatIsA(StageMorph);!a&&this.parent.grabOrigin&&(a=this.parent.grabOrigin.origin);return a?(a.center().y-this.bottom())/a.scale:this.bottom()}; -SpriteMorph.prototype.allMessageNames=function(){var a=[],b=this.scripts.children.slice();this.customBlocks.forEach(function(c){c.body&&b.push(c.body.expression);c.scripts.forEach(function(d){return b.push(d)})});this.globalBlocks&&this.globalBlocks.forEach(function(c){c.body&&b.push(c.body.expression);c.scripts.forEach(function(d){return b.push(d)})});b.forEach(function(c){c.allChildren().forEach(function(d){d instanceof InputSlotMorph&&d.choices&&contains(["messagesMenu","messagesReceivedMenu"], -d.choices)&&(d=d.evaluate(),isString(d)&&""!==d&&(contains(a,d)||a.push(d)))})});return a};SpriteMorph.prototype.allSendersOf=function(a,b){"number"===typeof a&&(a=a.toString());return this.scripts.allChildren().filter(function(c){var d;if(c.selector&&contains(["doBroadcast","doBroadcastAndWait","doSend"],c.selector)){var e=c.inputs()[0].evaluate();"doSend"===c.selector&&(d=c.inputs()[1].evaluate());return("doSend"!==c.selector||b===d)&&(e===a||a instanceof Array&&"any message"===a[0])}return!1})}; -SpriteMorph.prototype.allHatBlocksFor=function(a){"number"===typeof a&&(a=a.toString());return this.scripts.children.filter(function(b){if(b.selector){if("receiveMessage"===b.selector)return b=b.inputs()[0].evaluate(),b===a||b instanceof Array&&"__shout__go__"!==a&&"__clone__init__"!==a;if("receiveGo"===b.selector)return"__shout__go__"===a;if("receiveOnClone"===b.selector)return"__clone__init__"===a}return!1})}; -SpriteMorph.prototype.allHatBlocksForKey=function(a){return this.scripts.children.filter(function(b){return b.selector&&"receiveKey"===b.selector?(b=b.inputs()[0].evaluate()[0],b===a||"any key"===b):!1})};SpriteMorph.prototype.allHatBlocksForInteraction=function(a){return this.scripts.children.filter(function(b){return b.selector&&"receiveInteraction"===b.selector?b.inputs()[0].evaluate()[0]===a:!1})}; -SpriteMorph.prototype.allGenericHatBlocks=function(){return this.scripts.children.filter(function(a){return a.selector?"receiveCondition"===a.selector:!1})};SpriteMorph.prototype.mouseClickLeft=function(){return this.receiveUserInteraction("clicked")};SpriteMorph.prototype.mouseEnter=function(){return this.receiveUserInteraction("mouse-entered")};SpriteMorph.prototype.mouseDownLeft=function(){return this.receiveUserInteraction("pressed")}; -SpriteMorph.prototype.mouseScroll=function(a){return this.receiveUserInteraction("scrolled-"+(0{c.body&&b.push(c.body.expression);c.scripts.forEach(d=>b.push(d))});this.globalBlocks&&this.globalBlocks.forEach(c=>{c.body&&b.push(c.body.expression);c.scripts.forEach(d=>b.push(d))});b.forEach(c=>{c.allChildren().forEach(d=>{d instanceof InputSlotMorph&&d.choices&&contains(["messagesMenu","messagesReceivedMenu"],d.choices)&&(d=d.evaluate(),isString(d)&&""!==d&&(contains(a,d)|| +a.push(d)))})});return a};SpriteMorph.prototype.allSendersOf=function(a,b){"number"===typeof a&&(a=a.toString());return this.scripts.allChildren().filter(c=>{var d;if(c.selector&&contains(["doBroadcast","doBroadcastAndWait","doSend"],c.selector)){var e=c.inputs()[0].evaluate();"doSend"===c.selector&&(d=c.inputs()[1].evaluate());return("doSend"!==c.selector||b===d)&&(e===a||a instanceof Array&&"any message"===a[0])}return!1})}; +SpriteMorph.prototype.allHatBlocksFor=function(a){"number"===typeof a&&(a=a.toString());return this.scripts.children.filter(b=>{if(b.selector){if("receiveMessage"===b.selector)return b=b.inputs()[0].evaluate(),b===a||b instanceof Array&&"__shout__go__"!==a&&"__clone__init__"!==a;if("receiveGo"===b.selector)return"__shout__go__"===a;if("receiveOnClone"===b.selector)return"__clone__init__"===a}return!1})}; +SpriteMorph.prototype.allHatBlocksForKey=function(a){return this.scripts.children.filter(b=>b.selector&&"receiveKey"===b.selector?(b=b.inputs()[0].evaluate()[0],b===a||"any key"===b):!1)};SpriteMorph.prototype.allHatBlocksForInteraction=function(a){return this.scripts.children.filter(b=>b.selector&&"receiveInteraction"===b.selector?b.inputs()[0].evaluate()[0]===a:!1)}; +SpriteMorph.prototype.allGenericHatBlocks=function(){return this.scripts.children.filter(a=>a.selector?"receiveCondition"===a.selector:!1)};SpriteMorph.prototype.mouseClickLeft=function(){return this.receiveUserInteraction("clicked")};SpriteMorph.prototype.mouseEnter=function(){return this.receiveUserInteraction("mouse-entered")};SpriteMorph.prototype.mouseDownLeft=function(){return this.receiveUserInteraction("pressed")}; +SpriteMorph.prototype.mouseScroll=function(a){return this.receiveUserInteraction("scrolled-"+(0e.push(d.threads.startProcess(f,this,c||d.isThreadSafe,null,null,null,b,"stopped"===a))),e};SpriteMorph.prototype.mouseDoubleClick=function(){this.isTemporary||this.edit()}; SpriteMorph.prototype.getTimer=function(){var a=this.parentThatIsA(StageMorph);return a?a.getTimer():0};SpriteMorph.prototype.getTempo=function(){var a=this.parentThatIsA(StageMorph);return a?a.getTempo():0};SpriteMorph.prototype.getLastMessage=function(){var a=this.parentThatIsA(StageMorph);return a?a.getLastMessage():""};SpriteMorph.prototype.getLastAnswer=function(){return this.parentThatIsA(StageMorph).lastAnswer}; SpriteMorph.prototype.reportMouseX=function(){var a=this.parentThatIsA(StageMorph);return a?a.reportMouseX():0};SpriteMorph.prototype.reportMouseY=function(){var a=this.parentThatIsA(StageMorph);return a?a.reportMouseY():0};SpriteMorph.prototype.reportThreadCount=function(){var a=this.parentThatIsA(StageMorph);return a?a.threads.processes.length:0}; -SpriteMorph.prototype.refactorVariableInstances=function(a,b,c){c&&this.hasSpriteVariable(a)||this.scripts.children.forEach(function(d){d instanceof BlockMorph&&d.refactorVarInStack(a,b)})};SpriteMorph.prototype.findVariableWatcher=function(a){var b=this,c=this.parentThatIsA(StageMorph),d=this.globalVariables();return null===c?null:detect(c.children,function(e){return e instanceof WatcherMorph&&(e.target===b.variables||e.target===d)&&e.getter===a})}; +SpriteMorph.prototype.refactorVariableInstances=function(a,b,c){c&&this.hasSpriteVariable(a)||this.scripts.children.forEach(d=>{d instanceof BlockMorph&&d.refactorVarInStack(a,b)})};SpriteMorph.prototype.findVariableWatcher=function(a){var b=this.parentThatIsA(StageMorph),c=this.globalVariables();return null===b?null:detect(b.children,d=>d instanceof WatcherMorph&&(d.target===this.variables||d.target===c)&&d.getter===a)}; SpriteMorph.prototype.toggleVariableWatcher=function(a,b,c){var d=this.parentThatIsA(StageMorph),e=this.parentThatIsA(IDE_Morph),f=this.globalVariables();if(null===d)return null;isNil(b)&&(b=contains(f.names(),a));var g=this.findVariableWatcher(a);c||SnapActions.toggleVariableWatcher(a,b,g&&g.isVisible);if(null!==g)g.isVisible?g.hide():(g.show(),g.fixLayout(),g.keepWithin(d)),b&&(e.flushBlocksCache("variables"),e.refreshPalette()),this.refreshVariableWatcher(a);else return g=new WatcherMorph(a,this.blockColor.variables, -b?f:this.variables,a),g.setPosition(d.position().add(10)),b=d.watchers(g.left()),0c.palette("variables")).map(c=>this.findVariableWatcherToggle(a,c)).filter(c=>!!c).forEach(c=>c.refresh())};SpriteMorph.prototype.showingVariableWatcher=function(a){return null===this.parentThatIsA(StageMorph)?!1:(a=this.findVariableWatcher(a))?a.isVisible:!1}; SpriteMorph.prototype.deleteVariableWatcher=function(a){if(null===this.parentThatIsA(StageMorph))return null;a=this.findVariableWatcher(a);null!==a&&a.destroy()}; SpriteMorph.prototype.toggleWatcher=function(a,b,c){var d=this.parentThatIsA(StageMorph),e=this.parentThatIsA(IDE_Morph);if(d){var f=this.watcherFor(d,a);SnapActions.toggleWatcher(a,f&&f.isVisible);f?f.isVisible?f.hide():(f.show(),f.fixLayout(),f.keepWithin(d)):(f=new WatcherMorph(b,c,WatcherMorph.prototype.isGlobal(a)?d:this,a),f.setPosition(d.position().add(10)),b=d.watchers(f.left()),0c instanceof WatcherMorph&&c.getter===b&&c.target===(c.isGlobal(b)?a:this))}; +SpriteMorph.prototype.deleteAllBlockInstances=function(a){(a.isGlobal?this.allBlockInstances(a):this.allIndependentInvocationsOf(a.blockSpec())).forEach(b=>b.deleteBlock());if(a.isGlobal){if(a=this.parentThatIsA(StageMorph))a.globalBlocks.forEach(b=>b.purgeCorpses()),a.children.concat(a).forEach(b=>{b.isSnapObject&&b.customBlocks.forEach(c=>c.purgeCorpses())})}else this.allSpecimens().concat(this).forEach(b=>b.customBlocks.forEach(c=>c.purgeCorpses()))}; +SpriteMorph.prototype.allBlockInstances=function(a){var b=[];if(a.isGlobal){var c=this.parentThatIsA(StageMorph);var d=c.children.filter(f=>f instanceof SpriteMorph);d.push(c);d.forEach(f=>b=b.concat(f.allLocalBlockInstances(a)));var e=[];c.globalBlocks.forEach(f=>{f.scripts.forEach(g=>g.allChildren().forEach(h=>{h.isCustomBlock&&h.definition===a&&e.push(h)}));f.body&&f.body.expression.allChildren().forEach(g=>{g.isCustomBlock&&g.definition===a&&e.push(g)})});return b.concat(e)}return this.allLocalBlockInstances(a)}; +SpriteMorph.prototype.allIndependentInvocationsOf=function(a){if(this.exemplar&&this.exemplar.getMethod(a))return[];var b=this.allInvocationsOf(a);this.instances.forEach(c=>c.addAllInvocationsOf(a,b));return b};SpriteMorph.prototype.allDependentInvocationsOf=function(a){var b=this.allInvocationsOf(a);this.instances.forEach(c=>c.addAllInvocationsOf(a,b));return b}; +SpriteMorph.prototype.allInvocationsOf=function(a){var b=this.scripts.allChildren().filter(e=>e.isCustomBlock&&!e.isGlobal&&e.blockSpec===a);var c=[];this.customBlocks.forEach(e=>{e.scripts.forEach(f=>f.allChildren().forEach(g=>{g.isCustomBlock&&!g.isGlobal&&g.blockSpec===a&&c.push(g)}));e.body&&e.body.expression.allChildren().forEach(f=>{f.isCustomBlock&&!f.isGlobal&&f.blockSpec===a&&c.push(f)})});var d=this.allEditorBlockInstances(null,a);return b.concat(c).concat(d)}; +SpriteMorph.prototype.addAllInvocationsOf=function(a,b){this.getLocalMethod(a)||(this.allInvocationsOf(a).forEach(c=>b.push(c)),this.instances.forEach(c=>c.addAllInvocationsOf(a,b)))}; +SpriteMorph.prototype.allLocalBlockInstances=function(a){var b=this.scripts.allChildren().filter(f=>f.isCustomBlock&&f.definition===a);var c=[];this.customBlocks.forEach(f=>{f.body&&f.body.expression.allChildren().forEach(g=>{g.isCustomBlock&&g.definition===a&&c.push(g)})});var d=this.allEditorBlockInstances(a);var e=this.paletteBlockInstance(a);b=b.concat(c).concat(d);e&&b.push(e);return b}; +SpriteMorph.prototype.allEditorBlockInstances=function(a,b){var c=[];if(!this.world())return[];this.world().children.forEach(d=>{d instanceof BlockEditorMorph&&d.body.contents.allChildren().forEach(e=>{a?e.isPrototype||e instanceof PrototypeHatBlockMorph||e.definition!==a||c.push(e):!e.isCustomBlock||e.isGlobal||e.isPrototype||e instanceof PrototypeHatBlockMorph||e.blockSpec!==b||c.push(e)})});return c}; +SpriteMorph.prototype.paletteBlockInstance=function(a){var b=this.parentThatIsA(IDE_Morph);return b?detect(b.palette.contents.children,c=>c.isCustomBlock&&c.definition===a):null}; +SpriteMorph.prototype.usesBlockInstance=function(a,b,c,d){if(detect(this.scripts.allChildren(),f=>f.isCustomBlock&&f.definition===a))return!0;if(a.isGlobal&&!c){var e=[];this.parentThatIsA(StageMorph).globalBlocks.forEach(f=>{b&&a===f||d&&contains(d,f)||f.body&&f.body.expression.allChildren().forEach(g=>{g.isCustomBlock&&g.definition===a&&e.push(g)})});if(0{f.body&&f.body.expression.allChildren().forEach(g=>{g.isCustomBlock&&g.definition===a&&e.push(g)})}); +return 0e.blockSpec()===b&&f!==d)}; +SpriteMorph.prototype.replaceDoubleDefinitionsFor=function(a){var b=this.doubleDefinitionsFor(a);b.forEach(d=>this.allBlockInstances(d).forEach(e=>{e.definition=a;e.refresh()}));if(a.isGlobal){var c=this.parentThatIsA(StageMorph);c.globalBlocks=c.globalBlocks.filter(d=>!contains(b,d))}else this.customBlocks=this.customBlocks.filter(d=>!contains(b,d));if(c=this.parentThatIsA(IDE_Morph))c.flushPaletteCache(),c.refreshPalette()}; +SpriteMorph.prototype.chooseExemplar=function(){var a=this.parentThatIsA(StageMorph).children.filter(c=>c instanceof SpriteMorph&&!c.isTemporary&&!contains(c.allExemplars(),this));var b=new MenuMorph(c=>this.setExemplar(c),localize("current parent")+":\n"+(this.exemplar?this.exemplar.name:localize("none")));a.forEach(c=>b.addItem(c.name,c,null,null,null,null,null,null,!0));b.addLine();b.addItem(localize("none"),null);b.popUpAtHand(this.world())}; SpriteMorph.prototype.setExemplar=function(a,b){if(a instanceof SpriteMorph&&contains(a.allExemplars(),this)){if(b)throw Error(localize("unable to inherit\n(disabled or circular?)"));}else if(this.emancipate(),(this.exemplar=a)?(this.variables.parentFrame=a.variables,a.addSpecimen(this)):this.variables.parentFrame=this.globalVariables(),this.isTemporary)this.cloneOriginName=a.cloneOriginName||a.name;else if(a=this.parentThatIsA(IDE_Morph))a.flushBlocksCache(),a.refreshPalette()}; -SpriteMorph.prototype.prune=function(){this.instances.forEach(function(a){a.shadowAllAttributes();a.shadowAllMethods();a.shadowAllVars();a.exemplar=null});this.instances=[]};SpriteMorph.prototype.emancipate=function(){this.exemplar&&(this.isTemporary||(this.shadowAllAttributes(),this.shadowAllMethods(),this.shadowAllVars()),this.exemplar.removeSpecimen(this),this.exemplar=null)};SpriteMorph.prototype.allExemplars=function(){for(var a=[],b=this;!isNil(b);)a.push(b),b=b.exemplar;return a}; -SpriteMorph.prototype.specimens=function(){return this.instances};SpriteMorph.prototype.allSpecimens=function(){var a=this.instances.slice();this.instances.forEach(function(b){return a.push.apply(a,b.allSpecimens())});return a};SpriteMorph.prototype.addSpecimen=function(a){this.instances.push(a)};SpriteMorph.prototype.removeSpecimen=function(a){a=this.instances.indexOf(a);-1!==a&&this.instances.splice(a,1)}; -SpriteMorph.prototype.inheritsAttribute=function(a){return!isNil(this.exemplar)&&contains(this.inheritedAttributes,a)};SpriteMorph.prototype.updatePropagationCache=function(){var a=this;this.cachedPropagation=!isNil(this.exemplar)&&detect("x position;y position;direction;size;costume #;volume;balance;shown?;pen down?".split(";"),function(b){return contains(a.inheritedAttributes,b)})}; -SpriteMorph.prototype.shadowedAttributes=function(){var a=this.inheritedAttributes;return this.attributes.filter(function(b){return!contains(a,b)})};SpriteMorph.prototype.shadowAllAttributes=function(){var a=this;this.attributes.forEach(function(b){return a.shadowAttribute(b)})}; -SpriteMorph.prototype.shadowAttribute=function(a){var b=this;if(this.inheritsAttribute(a)){var c=this.parentThatIsA(IDE_Morph);this.inheritedAttributes=this.inheritedAttributes.filter(function(g){return g!==a});if("costumes"===a){var d=new List;this.costumes.asArray().forEach(function(g){var h=g.copy();d.add(h);g===b.costume&&b.wearCostume(h)});this.costumes=d;this.instances.forEach(function(g){g.inheritsAttribute("costumes")&&g.refreshInheritedAttribute("costumes")})}else if("sounds"===a){var e= -new List;this.sounds.asArray().forEach(function(g){return e.add(g.copy())});this.sounds=e;this.instances.forEach(function(g){g.inheritsAttribute("sounds")&&g.refreshInheritedAttribute("sounds")})}else if("scripts"===a){c.stage.threads.stopAllForReceiver(this);var f=this.scripts.position();this.scripts=this.exemplar.scripts.fullCopy();c&&contains(c.currentSprite.allExemplars(),this)&&(c.createSpriteEditor(),c.fixLayout("selectSprite"),this.scripts.fixMultiArgs(),this.scripts.setPosition(f),c.spriteEditor.adjustScrollBars()); -this.instances.forEach(function(g){g.inheritsAttribute("scripts")&&g.refreshInheritedAttribute("scripts")})}else this.updatePropagationCache(),c&&!this.isTemporary&&(c.flushBlocksCache(),c.refreshPalette())}};SpriteMorph.prototype.inheritAttribute=function(a){var b=this.parentThatIsA(IDE_Morph);this.exemplar&&contains(this.attributes,a)&&!this.inheritsAttribute(a)&&(this.inheritedAttributes.push(a),this.refreshInheritedAttribute(a),b&&(b.flushBlocksCache(),b.refreshPalette()))}; +SpriteMorph.prototype.prune=function(){this.instances.forEach(a=>{a.shadowAllAttributes();a.shadowAllMethods();a.shadowAllVars();a.exemplar=null});this.instances=[]};SpriteMorph.prototype.emancipate=function(){this.exemplar&&(this.isTemporary||(this.shadowAllAttributes(),this.shadowAllMethods(),this.shadowAllVars()),this.exemplar.removeSpecimen(this),this.exemplar=null)};SpriteMorph.prototype.allExemplars=function(){for(var a=[],b=this;!isNil(b);)a.push(b),b=b.exemplar;return a}; +SpriteMorph.prototype.specimens=function(){return this.instances};SpriteMorph.prototype.allSpecimens=function(){var a=this.instances.slice();this.instances.forEach(b=>a.push.apply(a,b.allSpecimens()));return a};SpriteMorph.prototype.addSpecimen=function(a){this.instances.push(a)};SpriteMorph.prototype.removeSpecimen=function(a){a=this.instances.indexOf(a);-1!==a&&this.instances.splice(a,1)}; +SpriteMorph.prototype.inheritsAttribute=function(a){return!isNil(this.exemplar)&&contains(this.inheritedAttributes,a)};SpriteMorph.prototype.updatePropagationCache=function(){this.cachedPropagation=!isNil(this.exemplar)&&detect("x position;y position;direction;size;costume #;volume;balance;shown?;pen down?".split(";"),a=>contains(this.inheritedAttributes,a))};SpriteMorph.prototype.shadowedAttributes=function(){var a=this.inheritedAttributes;return this.attributes.filter(b=>!contains(a,b))}; +SpriteMorph.prototype.shadowAllAttributes=function(){this.attributes.forEach(a=>this.shadowAttribute(a))}; +SpriteMorph.prototype.shadowAttribute=function(a){if(this.inheritsAttribute(a)){var b=this.parentThatIsA(IDE_Morph);this.inheritedAttributes=this.inheritedAttributes.filter(f=>f!==a);if("costumes"===a){var c=new List;this.costumes.asArray().forEach(f=>{var g=f.copy();c.add(g);f===this.costume&&this.wearCostume(g)});this.costumes=c;this.instances.forEach(f=>{f.inheritsAttribute("costumes")&&f.refreshInheritedAttribute("costumes")})}else if("sounds"===a){var d=new List;this.sounds.asArray().forEach(f=> +d.add(f.copy()));this.sounds=d;this.instances.forEach(f=>{f.inheritsAttribute("sounds")&&f.refreshInheritedAttribute("sounds")})}else if("scripts"===a){b.stage.threads.stopAllForReceiver(this);var e=this.scripts.position();this.scripts=this.exemplar.scripts.fullCopy();b&&contains(b.currentSprite.allExemplars(),this)&&(b.createSpriteEditor(),b.fixLayout("selectSprite"),this.scripts.fixMultiArgs(),this.scripts.setPosition(e),b.spriteEditor.adjustScrollBars());this.instances.forEach(f=>{f.inheritsAttribute("scripts")&& +f.refreshInheritedAttribute("scripts")})}else this.updatePropagationCache(),b&&!this.isTemporary&&(b.flushBlocksCache(),b.refreshPalette())}};SpriteMorph.prototype.inheritAttribute=function(a){var b=this.parentThatIsA(IDE_Morph);this.exemplar&&contains(this.attributes,a)&&!this.inheritsAttribute(a)&&(this.inheritedAttributes.push(a),this.refreshInheritedAttribute(a),b&&(b.flushBlocksCache(),b.refreshPalette()))}; SpriteMorph.prototype.refreshInheritedAttribute=function(a){switch(a){case "x position":case "y position":this.cachedPropagation=!0;this.gotoXY(this.xPosition(),this.yPosition(),!1,!0);break;case "direction":this.cachedPropagation=!0;this.setHeading(this.direction(),!0);break;case "size":this.cachedPropagation=!0;this.setScale(this.getScale(),!0);break;case "costume #":this.cachedPropagation=!0;this.inheritsAttribute("costumes")?this.wearCostume(this.exemplar.costume,!0):this.doSwitchToCostume(this.getCostumeIdx(), -!0);break;case "volume":this.cachedPropagation=!0;this.setVolume(this.getVolume(),!0);break;case "shown?":this.cachedPropagation=!0;this.setVisibility(this.reportShown(),!0);break;case "pen down?":this.cachedPropagation=!0;this.setPenDown(this.getPenDown(),!0);break;case "balance":this.cachedPropagation=!0;this.setPan(this.getPan(),!0);break;case "costumes":a=this.getCostumeIdx();this.costumes=this.exemplar.costumes;this.doSwitchToCostume(a,!0);this.instances.forEach(function(b){b.inheritsAttribute("costumes")&& -b.refreshInheritedAttribute("costumes")});break;case "sounds":this.sounds=this.exemplar.sounds;this.instances.forEach(function(b){b.inheritsAttribute("sounds")&&b.refreshInheritedAttribute("sounds")});break;case "scripts":this.scripts=this.exemplar.scripts;if(a=this.parentThatIsA(IDE_Morph))a.stage.threads.stopAllForReceiver(this),contains(a.currentSprite.allExemplars(),this)&&(a.createSpriteEditor(),a.fixLayout("selectSprite"));this.instances.forEach(function(b){b.inheritsAttribute("scripts")&&b.refreshInheritedAttribute("scripts")}); +!0);break;case "volume":this.cachedPropagation=!0;this.setVolume(this.getVolume(),!0);break;case "shown?":this.cachedPropagation=!0;this.setVisibility(this.reportShown(),!0);break;case "pen down?":this.cachedPropagation=!0;this.setPenDown(this.getPenDown(),!0);break;case "balance":this.cachedPropagation=!0;this.setPan(this.getPan(),!0);break;case "costumes":a=this.getCostumeIdx();this.costumes=this.exemplar.costumes;this.doSwitchToCostume(a,!0);this.instances.forEach(b=>{b.inheritsAttribute("costumes")&& +b.refreshInheritedAttribute("costumes")});break;case "sounds":this.sounds=this.exemplar.sounds;this.instances.forEach(b=>{b.inheritsAttribute("sounds")&&b.refreshInheritedAttribute("sounds")});break;case "scripts":this.scripts=this.exemplar.scripts;if(a=this.parentThatIsA(IDE_Morph))a.stage.threads.stopAllForReceiver(this),contains(a.currentSprite.allExemplars(),this)&&(a.createSpriteEditor(),a.fixLayout("selectSprite"));this.instances.forEach(b=>{b.inheritsAttribute("scripts")&&b.refreshInheritedAttribute("scripts")}); break;default:nop()}};SpriteMorph.prototype.toggleInheritanceForAttribute=function(a){this.inheritsAttribute(a)?this.shadowAttribute(a):this.inheritAttribute(a)};SpriteMorph.prototype.isVariableNameInUse=function(a,b){return b?contains(this.variables.allNames(),a):contains(this.variables.names(),a)?!0:contains(this.globalVariables().names(),a)};SpriteMorph.prototype.globalVariables=function(){for(var a=this.variables.parentFrame;a.owner;)a=a.parentFrame;return a}; -SpriteMorph.prototype.shadowAllVars=function(){var a=this;this.inheritedVariableNames().forEach(function(b){return a.shadowVar(b,a.variables.getVar(b))})};SpriteMorph.prototype.shadowVar=function(a,b){this.variables.addVar(a,b);!this.isTemporary&&(a=this.parentThatIsA(IDE_Morph))&&(a.flushBlocksCache("variables"),a.refreshPalette())}; -SpriteMorph.prototype.toggleInheritedVariable=function(a){contains(this.inheritedVariableNames(!0),a)?this.deleteVariable(a):contains(this.inheritedVariableNames(),a)&&this.shadowVar(a,this.variables.getVar(a))};SpriteMorph.prototype.inheritedVariableNames=function(a){function b(f){return a?contains(d,f):!contains(d,f)}for(var c=[],d=this.variables.names(),e=this.variables.parentFrame;e.owner instanceof SpriteMorph;)c.push.apply(c,e.names().filter(b)),e=e.parentFrame;return c}; -SpriteMorph.prototype.deletableVariableNames=function(){var a=this.variables.names(),b=this.inheritedVariableNames();return a.concat(this.globalVariables().names().filter(function(c){return!contains(a,c)&&!contains(b,c)}))};SpriteMorph.prototype.hasSpriteVariable=function(a){return contains(this.variables.names(),a)};SpriteMorph.prototype.allLocalVariableNames=function(a){function b(d,e){return d.toLowerCase()this.shadowVar(a,this.variables.getVar(a)))};SpriteMorph.prototype.shadowVar=function(a,b){this.variables.addVar(a,b);!this.isTemporary&&(a=this.parentThatIsA(IDE_Morph))&&(a.flushBlocksCache("variables"),a.refreshPalette())};SpriteMorph.prototype.toggleInheritedVariable=function(a){contains(this.inheritedVariableNames(!0),a)?this.deleteVariable(a):contains(this.inheritedVariableNames(),a)&&this.shadowVar(a,this.variables.getVar(a))}; +SpriteMorph.prototype.inheritedVariableNames=function(a){function b(f){return a?contains(d,f):!contains(d,f)}for(var c=[],d=this.variables.names(),e=this.variables.parentFrame;e.owner instanceof SpriteMorph;)c.push.apply(c,e.names().filter(b)),e=e.parentFrame;return c};SpriteMorph.prototype.deletableVariableNames=function(){var a=this.variables.names(),b=this.inheritedVariableNames();return a.concat(this.globalVariables().names().filter(c=>!contains(a,c)&&!contains(b,c)))}; +SpriteMorph.prototype.hasSpriteVariable=function(a){return contains(this.variables.names(),a)};SpriteMorph.prototype.allLocalVariableNames=function(a){function b(d,e){return d.toLowerCase()!contains(c,e));a&&d.sort(b);return d}; +SpriteMorph.prototype.getMethod=function(a){return this.allBlocks()[a]};SpriteMorph.prototype.getLocalMethod=function(a){return this.ownBlocks()[a]};SpriteMorph.prototype.ownBlocks=function(){var a={};this.customBlocks.forEach(b=>a[b.blockSpec()]=b);return a};SpriteMorph.prototype.allBlocks=function(a){var b={};this.allExemplars().reverse().forEach(c=>c.customBlocks.forEach(d=>b[d.blockSpec()]=d));return a?Object.keys(b).map(c=>b[c]):b}; +SpriteMorph.prototype.inheritedBlocks=function(a){var b={},c=Object.keys(this.ownBlocks()),d=this.allExemplars().reverse();d.pop();d.forEach(e=>e.customBlocks.forEach(f=>{var g=f.blockSpec();contains(c,g)||(b[g]=f)}));return a?Object.keys(b).map(e=>b[e]):b};SpriteMorph.prototype.shadowAllMethods=function(){var a;this.inheritedMethods().forEach(b=>this.customBlocks.push(b));!this.isTemporary&&(a=this.parentThatIsA(IDE_Morph))&&(a.flushPaletteCache(),a.refreshPalette())}; +SpriteMorph.prototype.inheritedMethods=function(){return this.inheritedBlocks(!0).map(a=>a.copyAndBindTo(this,!0))}; +SpriteMorph.prototype.thumbnail=function(a,b){function c(n,p,q){var r=Math.min(a.x,a.y)/10;m.strokeStyle=n;m.globalAlpha=p;m.compositeOperation="lighter";m.lineWidth=q||1;m.moveTo(r,r);m.lineTo(l.width-r,l.height-r);m.moveTo(r,l.height-r);m.lineTo(l.width-r,r);m.stroke()}var d=this.getImage(),e=this.width(),f=this.height(),g=Math.min(a.x/e,a.y/f),h=(a.x-e*g)/2,k=(a.y-f*g)/2,l=newCanvas(a,!1,b),m=l.getContext("2d");m.save();this.isCorpse&&(m.globalAlpha=.3);e&&f&&d.width&&d.height&&(m.scale(g,g),m.drawImage(d, Math.floor(h/g),Math.floor(k/g)));this.isCorpse&&(m.restore(),c("white",.8,6),c("black",.8,1));m.restore();return l};SpriteMorph.prototype.fullThumbnail=function(a,b){b=this.thumbnail(a,b);var c=b.getContext("2d"),d=a.divideBy(3),e;c.restore();this.anchor&&c.drawImage(this.anchor.thumbnail(d),0,0);for(e=0;3>e;e+=1)this.parts[e]&&c.drawImage(this.parts[e].thumbnail(d),e*d.x,a.y-d.y);return b};SpriteMorph.prototype.booleanMorph=function(a){a=new BooleanSlotMorph(a);a.isStatic=!0;a.fixLayout();return a}; -SpriteMorph.prototype.attachTo=function(a){a.attachPart(this)};SpriteMorph.prototype.attachPart=function(a){var b=Date.now();a.anchor&&a.anchor.detachPart(a);this.parts.push(a);this.version=b;a.anchor=this;this.allParts().forEach(function(c){return c.nestingScale=c.scale});a.version=b};SpriteMorph.prototype.detachPart=function(a){var b=this.parts.indexOf(a);if(-1!==b){var c=Date.now();this.parts.splice(b,1);this.version=c;a.anchor=null;a.version=c}}; -SpriteMorph.prototype.detachAllParts=function(){var a=Date.now();this.parts.forEach(function(b){b.anchor=null;b.version=a});this.parts=[];this.version=a};SpriteMorph.prototype.detachFromAnchor=function(){this.anchor&&this.anchor.detachPart(this)};SpriteMorph.prototype.allParts=function(){var a=[this];this.parts.forEach(function(b){return a=a.concat(b.allParts())});return a};SpriteMorph.prototype.allAnchors=function(){var a=[this];null!==this.anchor&&(a=a.concat(this.anchor.allAnchors()));return a}; -SpriteMorph.prototype.recordLayers=function(){var a=this.parentThatIsA(StageMorph);a?(this.layers=this.allParts(),this.layers.forEach(function(b){(b=b.talkBubble())&&b.hide()}),this.layers.sort(function(b,c){return a.children.indexOf(b)c.nestingScale=c.scale);a.version=b};SpriteMorph.prototype.detachPart=function(a){var b=this.parts.indexOf(a);if(-1!==b){var c=Date.now();this.parts.splice(b,1);this.version=c;a.anchor=null;a.version=c}}; +SpriteMorph.prototype.detachAllParts=function(){var a=Date.now();this.parts.forEach(b=>{b.anchor=null;b.version=a});this.parts=[];this.version=a};SpriteMorph.prototype.detachFromAnchor=function(){this.anchor&&this.anchor.detachPart(this)};SpriteMorph.prototype.allParts=function(){var a=[this];this.parts.forEach(b=>a=a.concat(b.allParts()));return a};SpriteMorph.prototype.allAnchors=function(){var a=[this];null!==this.anchor&&(a=a.concat(this.anchor.allAnchors()));return a}; +SpriteMorph.prototype.recordLayers=function(){var a=this.parentThatIsA(StageMorph);a?(this.layers=this.allParts(),this.layers.forEach(b=>{(b=b.talkBubble())&&b.hide()}),this.layers.sort((b,c)=>a.children.indexOf(b){a.comeToFront();a.positionTalkBubble()});this.layers=null}; +SpriteMorph.prototype.destroy=function(){this.anchor&&this.anchor.detachPart(this);this.emancipate();this.isTemporary||this.prune();SpriteMorph.uber.destroy.call(this)};SpriteMorph.prototype.flash=function(){var a=this.world();this.addHighlight();a.animations.push(new Animation(nop,nop,0,800,nop,()=>this.removeHighlight()))}; SpriteMorph.prototype.addHighlight=function(a){var b=!this.isVisible;b&&this.show();a=this.highlight(a?a.color:this.highlightColor,this.highlightBorder);this.addBack(a);this.fullChanged();b&&this.hide();return a};SpriteMorph.prototype.removeHighlight=function(){var a=this.getHighlight();null!==a&&(this.fullChanged(),this.removeChild(a));return a};SpriteMorph.prototype.toggleHighlight=function(){this.getHighlight()?this.removeHighlight():this.addHighlight()}; SpriteMorph.prototype.highlight=function(a,b){var c=new SpriteHighlightMorph,d=this.bounds;c.bounds.setExtent(d.extent().add(2*b));c.color=a;c.cachedImage=this.highlightImage(a,b);a=c.cachedImage.getContext("2d");a.drawImage(this.highlightImage(WHITE,4),b-4,b-4);a.drawImage(this.highlightImage(new Color(50,50,50),2),b-2,b-2);a.drawImage(this.highlightImage(WHITE,1),b-1,b-1);c.setPosition(d.origin.subtract(new Point(b,b)));return c}; SpriteMorph.prototype.highlightImage=function(a,b){var c=this.extent();var d=this.getImage();var e=newCanvas(c.add(2*b));var f=e.getContext("2d");f.drawImage(d,0,0);f.drawImage(d,b,0);f.drawImage(d,2*b,0);f.drawImage(d,2*b,b);f.drawImage(d,2*b,2*b);f.drawImage(d,b,2*b);f.drawImage(d,0,2*b);f.drawImage(d,0,b);f.globalCompositeOperation="destination-out";f.drawImage(d,b,b);b=newCanvas(c.add(2*b));f=b.getContext("2d");f.drawImage(e,0,0);f.globalCompositeOperation="source-atop";f.fillStyle=a.toString(); -f.fillRect(0,0,b.width,b.height);return b};SpriteMorph.prototype.getHighlight=function(){var a=this.children.slice(0).reverse().filter(function(b){return b instanceof SpriteHighlightMorph});return 0!==a.length?a[0]:null};SpriteMorph.prototype.mouseEnterDragging=function(){if(this.enableNesting){var a=this.world().hand.children[0];this.wantsDropOf(a)&&this.addHighlight()}};SpriteMorph.prototype.mouseLeave=function(){this.receiveUserInteraction("mouse-departed");this.enableNesting&&this.removeHighlight()}; +f.fillRect(0,0,b.width,b.height);return b};SpriteMorph.prototype.getHighlight=function(){var a=this.children.slice(0).reverse().filter(b=>b instanceof SpriteHighlightMorph);return 0!==a.length?a[0]:null};SpriteMorph.prototype.mouseEnterDragging=function(){if(this.enableNesting){var a=this.world().hand.children[0];this.wantsDropOf(a)&&this.addHighlight()}};SpriteMorph.prototype.mouseLeave=function(){this.receiveUserInteraction("mouse-departed");this.enableNesting&&this.removeHighlight()}; SpriteMorph.prototype.wantsDropOf=function(a){return this.enableNesting&&a instanceof SpriteIconMorph&&!contains(a.object.allParts(),this)};SpriteMorph.prototype.reactToDropOf=function(a,b){this.removeHighlight();SnapActions.attachParts(this,[a.object]);this.world().add(a);a.slideBackTo(b.grabOrigin)}; -SpriteMorph.prototype.newCostumeName=function(a,b){var c=a.indexOf("(");a=0>c?a:a.substring(0,c);c=1;for(var d=a,e=this.costumes.asArray().filter(function(f){return f!==b}).map(function(f){return f.name});contains(e,d);)c+=1,d=a+"("+c+")";return d}; -SpriteMorph.prototype.doScreenshot=function(a,b){var c=this.parentThatIsA(StageMorph);b=this.newCostumeName(b);if(void 0!==a[0]){if("pen trails"===a[0]){a=c.trailsCanvas;var d=(new Costume(a,b)).copy()}else"stage image"===a[0]&&(a=c.fullImage(),d=new Costume(a,b));this.addCostume(d)}}; -SpriteMorph.prototype.newSoundName=function(a,b){var c=a.indexOf("(");a=0>c?a:a.substring(0,c);c=1;for(var d=a,e=this.sounds.asArray().filter(function(f){return f!==b}).map(function(f){return f.name});contains(e,d);)c+=1,d=a+"("+c+")";return d};SpriteHighlightMorph.prototype=new Morph;SpriteHighlightMorph.prototype.constructor=SpriteHighlightMorph;SpriteHighlightMorph.uber=Morph.prototype;function SpriteHighlightMorph(){this.init()} +SpriteMorph.prototype.newCostumeName=function(a,b){var c=a.indexOf("(");a=0>c?a:a.substring(0,c);c=1;for(var d=a,e=this.costumes.asArray().filter(f=>f!==b).map(f=>f.name);contains(e,d);)c+=1,d=a+"("+c+")";return d};SpriteMorph.prototype.doScreenshot=function(a,b){var c=this.parentThatIsA(StageMorph);b=this.newCostumeName(b);if(void 0!==a[0]){if("pen trails"===a[0]){a=c.trailsCanvas;var d=(new Costume(a,b)).copy()}else"stage image"===a[0]&&(a=c.fullImage(),d=new Costume(a,b));this.addCostume(d)}}; +SpriteMorph.prototype.newSoundName=function(a,b){var c=a.indexOf("(");a=0>c?a:a.substring(0,c);c=1;for(var d=a,e=this.sounds.asArray().filter(f=>f!==b).map(f=>f.name);contains(e,d);)c+=1,d=a+"("+c+")";return d};SpriteHighlightMorph.prototype=new Morph;SpriteHighlightMorph.prototype.constructor=SpriteHighlightMorph;SpriteHighlightMorph.uber=Morph.prototype;function SpriteHighlightMorph(){this.init()} SpriteHighlightMorph.prototype.init=function(){SpriteHighlightMorph.uber.init.call(this);this.isCachingImage=!0};StageMorph.prototype=new FrameMorph;StageMorph.prototype.constructor=StageMorph;StageMorph.uber=FrameMorph.prototype;StageMorph.prototype.dimensions=new Point(480,360);StageMorph.prototype.frameRate=0;StageMorph.prototype.isCachingPrimitives=SpriteMorph.prototype.isCachingPrimitives;StageMorph.prototype.sliderColor=SpriteMorph.prototype.sliderColor; StageMorph.prototype.paletteTextColor=SpriteMorph.prototype.paletteTextColor;StageMorph.prototype.hiddenPrimitives={};StageMorph.prototype.codeMappings={};StageMorph.prototype.codeHeaders={};StageMorph.prototype.enableCodeMapping=!1;StageMorph.prototype.enableInheritance=!0;StageMorph.prototype.enableSublistIDs=!1;StageMorph.prototype.enablePenLogging=!1;function StageMorph(a){this.init(a)} StageMorph.prototype.init=function(a){this.name=localize("Stage");this.instrument=null;this.threads=new ThreadManager;this.variables=new VariableFrame(a||null,this);this.scripts=new ScriptsMorph;this.customBlocks=[];this.globalBlocks=[];this.costumes=new List;this.costume=null;this.sounds=new List;this.version=Date.now();this.isFastTracked=!1;this.enableCustomHatBlocks=!0;this.cloneCount=0;this.timerStart=Date.now();this.tempo=60;this.lastMessage="";this.volume=100;this.gainNode=null;this.pan=0;this.freqPlayer= this.pannerNode=null;this.watcherUpdateFrequency=2;this.lastWatcherUpdate=Date.now();this.scale=1;this.cachedHSV=[0,0,0];this.keysPressed={};this.blocksCache={};this.paletteCache={};this.lastAnswer="";this.activeSounds=[];this.trailsCanvas=null;this.trailsLog=[];this.isThreadSafe=!1;this.microphone=new Microphone;this.graphicsValues={color:0,fisheye:0,whirl:0,pixelate:0,mosaic:0,duplicate:0,negative:0,comic:0,confetti:0,saturation:0,brightness:0};this.stopProjectionSource=this.getProjectionImage= this.projectionSource=this.remixID=this.cachedPenTrailsMorph=null;this.continuousProjection=!1;this.projectionCanvas=null;this.projectionTransparency=50;this.mirrorVideo=!0;this.videoMotion=null;this.messageCallbacks={};StageMorph.uber.init.call(this);this.isCachingImage=!0;this.cachedHSV=this.color.hsv();this.acceptsDrops=!1;this.setColor(new Color(255,255,255));this.fps=this.frameRate}; -StageMorph.prototype.setScale=function(a){var b=this,c=a/this.scale,d=this.position(),e,f;1!==c&&(this.cachedPenTrailsMorph=null,this.scale=a,this.setExtent(this.dimensions.multiplyBy(a)),this.children.forEach(function(g){e=g.position().subtract(d);g.fixLayout();g.setPosition(e.multiplyBy(c).add(d),!0);if(g instanceof SpriteMorph){if(g.rerender(),f=g.talkBubble())f.setScale(a),g.positionTalkBubble()}else g instanceof StagePrompterMorph&&(1>b.scale?g.setWidth(b.width()-10):g.setWidth(b.dimensions.x- -20),g.setCenter(b.center()),g.setBottom(b.bottom()))}))};StageMorph.prototype.moveBy=function(a){var b=this.children,c=b.length;this.changed();this.bounds=this.bounds.translateBy(a);this.changed();for(c;0{d=f.position().subtract(c);f.fixLayout();f.setPosition(d.multiplyBy(b).add(c),!0);if(f instanceof SpriteMorph){if(f.rerender(),e=f.talkBubble())e.setScale(a),f.positionTalkBubble()}else f instanceof StagePrompterMorph&&(1>this.scale?f.setWidth(this.width()-10):f.setWidth(this.dimensions.x-20), +f.setCenter(this.center()),f.setBottom(this.bottom()))}))};StageMorph.prototype.moveBy=function(a){var b=this.children,c=b.length;this.changed();this.bounds=this.bounds.translateBy(a);this.changed();for(c;0a.stop());this.videoMotion=null}; StageMorph.prototype.stopProjection=function(){this.projectionSource&&(this.stopProjectionSource(),this.projectionSource.remove(),this.projectionSource=null,this.continuousProjection=!1);this.clearProjectionLayer()};StageMorph.prototype.projectionSnap=function(){var a=newCanvas(this.dimensions,!0);a.getContext("2d").drawImage(this.projectionLayer(),0,0);return new Costume(a,this.newCostumeName(localize("snap")))}; StageMorph.prototype.getPixelColor=function(a){if(this.trailsCanvas){var b=a.subtract(this.bounds.origin);var c=this.penTrailsMorph().getImage().getContext("2d");c=c.getImageData(b.x,b.y,1,1);return 0===c.data[3]?this.projectionCanvas?(b=b.divideBy(this.scale),c=this.projectionCanvas.getContext("2d"),c=c.getImageData(b.x,b.y,1,1),new Color(c.data[0],c.data[1],c.data[2],c.data[3]/255)):StageMorph.uber.getPixelColor.call(this,a):new Color(c.data[0],c.data[1],c.data[2],c.data[3]/255)}}; StageMorph.prototype.startVideo=function(){function a(){var c=new DialogBoxMorph;c.inform(localize("Camera not supported"),localize("Please make sure your web browser is up to date\nand your camera is properly configured."),this.world);c.fixLayout();c.rerender();b.projectionSource&&(b.projectionSource.remove(),b.projectionSource=null)}var b=this;this.projectionSource||(this.projectionSource=document.createElement("video"),this.projectionSource.width=this.dimensions.x,this.projectionSource.height= @@ -1740,47 +1665,47 @@ this.dimensions.y,this.projectionSource.hidden=!0,document.body.appendChild(this c}).catch(a))};StageMorph.prototype.getVideoImage=function(){return this.projectionSource};StageMorph.prototype.stopVideo=function(){this.projectionSource&&this.projectionSource.stream&&this.projectionSource.stream.getTracks().forEach(function(a){a.stop()});this.videoMotion=null};StageMorph.prototype.stopProjection=function(){this.projectionSource&&(this.stopProjectionSource(),this.projectionSource.remove(),this.projectionSource=null,this.continuousProjection=!1);this.clearProjectionLayer()}; StageMorph.prototype.projectionSnap=function(){var a=newCanvas(this.dimensions,!0);a.getContext("2d").drawImage(this.projectionLayer(),0,0);return new Costume(a,this.newCostumeName(localize("snap")))}; StageMorph.prototype.getPixelColor=function(a){if(this.trailsCanvas){var b=a.subtract(this.bounds.origin);var c=this.penTrailsMorph().image.getContext("2d");c=c.getImageData(b.x,b.y,1,1);return 0===c.data[3]?this.projectionCanvas?(b=b.divideBy(this.scale),c=this.projectionCanvas.getContext("2d"),c=c.getImageData(b.x,b.y,1,1),new Color(c.data[0],c.data[1],c.data[2],c.data[3]/255)):StageMorph.uber.getPixelColor.call(this,a):new Color(c.data[0],c.data[1],c.data[2],c.data[3]/255)}}; -StageMorph.prototype.watchers=function(a){return this.children.filter(function(b){return b instanceof WatcherMorph?a?b.left()===a:b.isVisible:!1})};StageMorph.prototype.resetTimer=function(){this.timerStart=Date.now()};StageMorph.prototype.getTimer=function(){return Math.floor((Date.now()-this.timerStart)/100)/10};StageMorph.prototype.setTempo=function(a){this.tempo=Math.max(20,+a||0)};StageMorph.prototype.changeTempo=function(a){this.setTempo(this.getTempo()+(+a||0))}; -StageMorph.prototype.getTempo=function(){return+this.tempo};StageMorph.prototype.getLastMessage=function(){return this.lastMessage||""};StageMorph.prototype.reportMouseX=function(){var a=this.world();return a?(a.hand.position().x-this.center().x)/this.scale:0};StageMorph.prototype.reportMouseY=function(){var a=this.world();return a?(this.center().y-a.hand.position().y)/this.scale:0}; -StageMorph.prototype.wantsDropOf=function(a){return a instanceof SpriteMorph||a instanceof WatcherMorph||a instanceof ListWatcherMorph||a instanceof SpriteIconMorph};StageMorph.prototype.reactToDropOf=function(a,b){a instanceof SpriteIconMorph&&(a.object.anchor&&SnapActions.detachParts([a.object]),this.world().add(a),a.slideBackTo(b.grabOrigin))}; +StageMorph.prototype.watchers=function(a){return this.children.filter(b=>b instanceof WatcherMorph?a?b.left()===a:b.isVisible:!1)};StageMorph.prototype.resetTimer=function(){this.timerStart=Date.now()};StageMorph.prototype.getTimer=function(){return Math.floor((Date.now()-this.timerStart)/100)/10};StageMorph.prototype.setTempo=function(a){this.tempo=Math.max(20,+a||0)};StageMorph.prototype.changeTempo=function(a){this.setTempo(this.getTempo()+(+a||0))};StageMorph.prototype.getTempo=function(){return+this.tempo}; +StageMorph.prototype.getLastMessage=function(){return this.lastMessage||""};StageMorph.prototype.reportMouseX=function(){var a=this.world();return a?(a.hand.position().x-this.center().x)/this.scale:0};StageMorph.prototype.reportMouseY=function(){var a=this.world();return a?(this.center().y-a.hand.position().y)/this.scale:0};StageMorph.prototype.wantsDropOf=function(a){return a instanceof SpriteMorph||a instanceof WatcherMorph||a instanceof ListWatcherMorph||a instanceof SpriteIconMorph}; +StageMorph.prototype.reactToDropOf=function(a,b){a instanceof SpriteIconMorph&&(a.object.anchor&&SnapActions.detachParts([a.object]),this.world().add(a),a.slideBackTo(b.grabOrigin))}; StageMorph.prototype.step=function(){var a=this.world();null===a.keyboardFocus&&(a.keyboardFocus=this);null===a.currentKey&&(this.keyPressed=null);this.enableCustomHatBlocks&&this.stepGenericConditions();if(this.isFastTracked&&this.threads.processes.length){for(;this.isFastTracked&&15>Date.now()-this.lastTime;)this.threads.step();this.changed()}else this.threads.step(),this.threads.wantsToPause&&(a=this.parentThatIsA(IDE_Morph))&&a.controlBar.pauseButton.refresh();a=Date.now()-this.lastWatcherUpdate; -1>1E3/this.watcherUpdateFrequency-a&&(this.watchers().forEach(function(b){return b.update()}),this.lastWatcherUpdate=Date.now());this.continuousProjection&&this.projectionSource&&this.updateProjection()}; +1>1E3/this.watcherUpdateFrequency-a&&(this.watchers().forEach(b=>b.update()),this.lastWatcherUpdate=Date.now());this.continuousProjection&&this.projectionSource&&this.updateProjection()}; StageMorph.prototype.updateProjection=function(){var a=this.projectionLayer().getContext("2d");a.save();this.mirrorVideo&&(a.translate(this.dimensions.x,0),a.scale(-1,1));a.drawImage(this.getProjectionImage(),0,0,this.projectionSource.width,this.projectionSource.height);this.videoMotion&&this.videoMotion.addFrame(a.getImageData(0,0,this.projectionSource.width,this.projectionSource.height).data);a.restore();this.changed()}; -StageMorph.prototype.stepGenericConditions=function(a){var b=this,c=0,d;this.children.concat(this).forEach(function(e){isSnapObject(e)&&e.allGenericHatBlocks().forEach(function(f){c+=1;b.threads.doWhen(f,e,a)})});c||(this.enableCustomHatBlocks=!1,(d=this.parentThatIsA(IDE_Morph))&&d.controlBar.stopButton.refresh())}; -StageMorph.prototype.developersMenu=function(){var a=this,b=StageMorph.uber.developersMenu.call(this);b.addItem("stop",function(){return a.threads.stopAll()},"terminate all running threads");return b};StageMorph.prototype.processKeyDown=function(a){this.processKeyEvent(a,this.fireKeyEvent)};StageMorph.prototype.processKeyUp=function(a){this.processKeyEvent(a,this.removePressedKey)}; +StageMorph.prototype.stepGenericConditions=function(a){var b=0,c;this.children.concat(this).forEach(d=>{isSnapObject(d)&&d.allGenericHatBlocks().forEach(e=>{b+=1;this.threads.doWhen(e,d,a)})});b||(this.enableCustomHatBlocks=!1,(c=this.parentThatIsA(IDE_Morph))&&c.controlBar.stopButton.refresh())};StageMorph.prototype.developersMenu=function(){var a=StageMorph.uber.developersMenu.call(this);a.addItem("stop",()=>this.threads.stopAll(),"terminate all running threads");return a}; +StageMorph.prototype.processKeyDown=function(a){this.processKeyEvent(a,this.fireKeyEvent)};StageMorph.prototype.processKeyUp=function(a){this.processKeyEvent(a,this.removePressedKey)}; StageMorph.prototype.processKeyEvent=function(a,b){switch(a.keyCode){case 13:var c="enter";a.ctrlKey||a.metaKey?c="ctrl enter":a.shiftKey&&(c="shift enter");break;case 27:c="esc";break;case 32:c="space";break;case 37:c="left arrow";break;case 39:c="right arrow";break;case 38:c="up arrow";break;case 40:c="down arrow";break;default:if(c=a.key||String.fromCharCode(a.keyCode||a.charCode),a.ctrlKey||a.metaKey)c="ctrl "+(a.shiftKey?"shift ":"")+c}switch(a.key){case "+":case "-":c=a.key}b.call(this,c)}; -StageMorph.prototype.fireKeyEvent=function(a){var b=this,c=a.toLowerCase(),d=[];a=this.parentThatIsA(IDE_Morph);this.keysPressed[c]=!0;if("ctrl enter"===c&&!a.isAppMode)return this.fireGreenFlagEvent();if("shift enter"===c)return this.editScripts();if("ctrl f"===c)a.isAppMode||a.currentSprite.searchBlocks();else if("ctrl z"===c)a.isAppMode||SnapUndo.undo(a.getActiveEntity());else if("ctrl shift z"===c||"ctrl y"===c)a.isAppMode||SnapUndo.redo(a.getActiveEntity());else if("ctrl n"===c)a.isAppMode|| -a.createNewProject();else if("ctrl o"===c)a.isAppMode||a.openProjectsBrowser();else if("ctrl s"===c)a.isAppMode||a.save();else if("ctrl shift s"===c){if(!a.isAppMode)return a.saveProjectsBrowser()}else{if("esc"===c&&!a.isAppMode)return this.fireStopAllEvent();this.children.concat(this).forEach(function(e){isSnapObject(e)&&e.allHatBlocksForKey(c).forEach(function(f){return d.push(b.threads.startProcess(f,e,!0))})});return d}};StageMorph.prototype.removePressedKey=function(a){delete this.keysPressed[a.toLowerCase()]}; -StageMorph.prototype.processKeyPress=function(a){nop(a)};StageMorph.prototype.inspectKeyEvent=CursorMorph.prototype.inspectKeyEvent;StageMorph.prototype.fireGreenFlagEvent=function(){var a=this,b=[],c=this.parentThatIsA(IDE_Morph);this.removeAllClones();this.children.concat(this).forEach(function(d){isSnapObject(d)&&d.allHatBlocksFor("__shout__go__").forEach(function(e){return b.push(a.threads.startProcess(e,d,a.isThreadSafe))})});c&&c.controlBar.pauseButton.refresh();return b}; -StageMorph.prototype.fireStopAllEvent=function(){var a=this,b=this.parentThatIsA(IDE_Morph);this.threads.resumeAll(this.stage);this.runStopScripts();this.keysPressed={};this.threads.stopAll();this.stopAllActiveSounds();this.children.forEach(function(c){c.stopTalking&&c.stopTalking()});this.removeAllClones();b&&b.nextSteps([nop,function(){return a.stopAllActiveSounds()},function(){return a.stopProjection()},function(){return b.controlBar.pauseButton.refresh()}])}; -StageMorph.prototype.runStopScripts=function(){this.receiveUserInteraction("stopped",!0,!0);this.children.forEach(function(a){a instanceof SpriteMorph&&a.receiveUserInteraction("stopped",!0,!0)})};StageMorph.prototype.removeAllClones=function(){var a=this;this.children.filter(function(b){return b instanceof SpriteMorph&&b.isTemporary}).forEach(function(b){a.threads.stopAllForReceiver(b);b.detachFromAnchor();b.corpsify();b.destroy()});this.cloneCount=0}; +StageMorph.prototype.fireKeyEvent=function(a){var b=a.toLowerCase(),c=[];a=this.parentThatIsA(IDE_Morph);this.keysPressed[b]=!0;if("ctrl enter"===b&&!a.isAppMode)return this.fireGreenFlagEvent();if("shift enter"===b)return this.editScripts();if("ctrl f"===b)a.isAppMode||a.currentSprite.searchBlocks();else if("ctrl z"===b)a.isAppMode||SnapUndo.undo(a.getActiveEntity());else if("ctrl shift z"===b||"ctrl y"===b)a.isAppMode||SnapUndo.redo(a.getActiveEntity());else if("ctrl n"===b)a.isAppMode||a.createNewProject(); +else if("ctrl o"===b)a.isAppMode||a.openProjectsBrowser();else if("ctrl s"===b)a.isAppMode||a.save();else if("ctrl shift s"===b){if(!a.isAppMode)return a.saveProjectsBrowser()}else{if("esc"===b&&!a.isAppMode)return this.fireStopAllEvent();this.children.concat(this).forEach(d=>{isSnapObject(d)&&d.allHatBlocksForKey(b).forEach(e=>c.push(this.threads.startProcess(e,d,!0)))});return c}};StageMorph.prototype.removePressedKey=function(a){delete this.keysPressed[a.toLowerCase()]}; +StageMorph.prototype.processKeyPress=function(a){nop(a)};StageMorph.prototype.inspectKeyEvent=CursorMorph.prototype.inspectKeyEvent;StageMorph.prototype.fireGreenFlagEvent=function(){var a=[],b=this.parentThatIsA(IDE_Morph);this.removeAllClones();this.children.concat(this).forEach(c=>{isSnapObject(c)&&c.allHatBlocksFor("__shout__go__").forEach(d=>a.push(this.threads.startProcess(d,c,this.isThreadSafe)))});b&&b.controlBar.pauseButton.refresh();return a}; +StageMorph.prototype.fireStopAllEvent=function(){var a=this.parentThatIsA(IDE_Morph);this.threads.resumeAll(this.stage);this.runStopScripts();this.keysPressed={};this.threads.stopAll();this.stopAllActiveSounds();this.children.forEach(b=>{b.stopTalking&&b.stopTalking()});this.removeAllClones();a&&a.nextSteps([nop,()=>this.stopAllActiveSounds(),()=>this.stopProjection(),()=>a.controlBar.pauseButton.refresh()])}; +StageMorph.prototype.runStopScripts=function(){this.receiveUserInteraction("stopped",!0,!0);this.children.forEach(a=>{a instanceof SpriteMorph&&a.receiveUserInteraction("stopped",!0,!0)})};StageMorph.prototype.removeAllClones=function(){this.children.filter(a=>a instanceof SpriteMorph&&a.isTemporary).forEach(a=>{this.threads.stopAllForReceiver(a);a.detachFromAnchor();a.corpsify();a.destroy()});this.cloneCount=0}; StageMorph.prototype.editScripts=function(){var a=this.parentThatIsA(IDE_Morph);if(!a.isAppMode&&ScriptsMorph.prototype.enableKeyboard){a=a.getActiveScripts().selectForEdit();a.edit(a.position());var b=a.focus.sortedScripts();b.length?(a.focus.element=b[0],a.focus.element instanceof HatBlockMorph&&a.focus.nextCommand()):a.focus.moveBy(new Point(50,50));a.focus.fixLayout()}}; StageMorph.prototype.blockTemplates=function(a){function b(n){if(l.hiddenPrimitives[n])return null;n=SpriteMorph.prototype.blockForSelector(n,!0);n.isTemplate=!0;return n}function c(n,p){n=SpriteMorph.prototype.variableBlock(n,p);n.isDraggable=!1;n.isTemplate=!0;return n}function d(n){if(l.hiddenPrimitives[n])return null;var p=SpriteMorph.prototype.blocks[n];return new ToggleMorph("checkbox",this,function(){l.toggleWatcher(n,localize(p.spec),l.blockColor[p.category])},null,function(){return l.showingWatcher(n)}, -null)}function e(n){return new ToggleMorph("checkbox",this,function(){l.toggleVariableWatcher(n)},null,function(){return l.showingVariableWatcher(n)},null)}function f(n){n&&(l.isVariableNameInUse(n[0])?l.inform("that name is already in use"):SnapActions.addVariable(n[0],n[1]||l.id))}function g(n){SnapActions.deleteVariable(n,l.id)}function h(n){var p=l.parentThatIsA(StageMorph),r=n.name.trim();n=n.fields.map(function(q){return q.trim()}).filter(function(q){return!!q});p.messageTypes.getMsgType(r)? -l.inform("that name is already in use"):SnapActions.addMessageType(r,n)}var k=[],l=this;a=a||"motion";if("motion"===a){var m=new TextMorph(localize("Stage selected:\nno motion primitives"));m.fontSize=9;m.setColor(this.paletteTextColor);k.push(m)}else"looks"===a?(k.push(b("doSwitchToCostume")),k.push(b("doWearNextCostume")),k.push(d("getCostumeIdx")),k.push(b("getCostumeIdx")),k.push("-"),k.push(b("reportGetImageAttribute")),k.push(b("reportNewCostumeStretched")),k.push(b("reportNewCostume")),k.push("-"), -k.push(b("changeEffect")),k.push(b("setEffect")),k.push(b("clearEffects")),k.push(b("getEffect")),k.push("-"),k.push(b("show")),k.push(b("hide")),k.push(d("reportShown")),k.push(b("reportShown")),this.world().isDevMode&&(k.push("-"),m=new TextMorph(localize("development mode \ndebugging primitives:")),m.fontSize=9,m.setColor(this.paletteTextColor),k.push(m),k.push("-"),k.push(b("log")),k.push(b("alert")))):"sound"===a?(k.push(b("playSound")),k.push(b("doPlaySoundUntilDone")),k.push(b("doStopAllSounds")), -k.push("-"),k.push(b("doPlaySoundAtRate")),k.push(b("reportGetSoundAttribute")),k.push(b("reportNewSoundFromSamples")),k.push("-"),k.push(b("doRest")),k.push(b("doPlayNote")),k.push(b("doSetInstrument")),k.push("-"),k.push(b("doChangeTempo")),k.push(b("doSetTempo")),k.push(d("getTempo")),k.push(b("getTempo")),k.push("-"),k.push(b("changeVolume")),k.push(b("setVolume")),k.push(d("getVolume")),k.push(b("getVolume")),k.push("-"),k.push(b("changePan")),k.push(b("setPan")),k.push(d("getPan")),k.push(b("getPan")), -k.push("-"),k.push(b("playFreq")),k.push(b("stopFreq")),this.world().isDevMode&&(k.push("-"),m=new TextMorph(localize("development mode \ndebugging primitives:")),m.fontSize=9,m.setColor(this.paletteTextColor),k.push(m),k.push("-"),k.push(b("doPlayFrequency")))):"pen"===a?(k.push(b("clear")),k.push("-"),k.push(b("setBackgroundColor")),k.push(b("changeBackgroundHSVA")),k.push(b("setBackgroundHSVA")),k.push("-"),k.push(b("reportPenTrailsAsCostume")),k.push("-"),k.push(b("doPasteOn"))):"network"===a? -(k.push(b("receiveSocketMessage")),k.push(b("doSocketMessage")),k.push("-"),k.push(b("doSocketRequest")),k.push(b("doSocketResponse")),k.push("-"),k.push(b("getJSFromRPCStruct")),k.push(b("doRunRPC")),k.push(d("reportRPCError")),k.push(b("reportRPCError")),k.push("-"),k.push(b("getProjectIds")),k.push(b("getProjectId")),m=new PushButtonMorph(null,function(){(new MessageCreatorMorph(l,h)).popUp()},"Make a message type"),k.push(m),0';k+="\x3c!-- Generated by Snap! - http://snap.berkeley.edu/ --\x3e"; -this.trailsLog.forEach(function(l){e=a.normalizePoint(l[0]).translateBy(h);f=a.normalizePoint(l[1]).translateBy(h);k+=''});k+="";return{src:k,rot:new Point(-g.origin.x,g.corner.y)}};StageMorph.prototype.normalizePoint=function(a){return new Point(a.x,-a.y)};StageMorph.prototype.hide=function(){this.isVisible=!1;this.changed()}; +null)}function e(n){return new ToggleMorph("checkbox",this,function(){l.toggleVariableWatcher(n)},null,function(){return l.showingVariableWatcher(n)},null)}function f(n){n&&(l.isVariableNameInUse(n[0])?l.inform("that name is already in use"):SnapActions.addVariable(n[0],n[1]||l.id))}function g(n){SnapActions.deleteVariable(n,l.id)}function h(n){const p=l.parentThatIsA(StageMorph),q=n.name.trim();n=n.fields.map(r=>r.trim()).filter(r=>!!r);p.messageTypes.getMsgType(q)?l.inform("that name is already in use"): +SnapActions.addMessageType(q,n)}var k=[],l=this;a=a||"motion";if("motion"===a){var m=new TextMorph(localize("Stage selected:\nno motion primitives"));m.fontSize=9;m.setColor(this.paletteTextColor);k.push(m)}else"looks"===a?(k.push(b("doSwitchToCostume")),k.push(b("doWearNextCostume")),k.push(d("getCostumeIdx")),k.push(b("getCostumeIdx")),k.push("-"),k.push(b("reportGetImageAttribute")),k.push(b("reportNewCostumeStretched")),k.push(b("reportNewCostume")),k.push("-"),k.push(b("changeEffect")),k.push(b("setEffect")), +k.push(b("clearEffects")),k.push(b("getEffect")),k.push("-"),k.push(b("show")),k.push(b("hide")),k.push(d("reportShown")),k.push(b("reportShown")),this.world().isDevMode&&(k.push("-"),m=new TextMorph(localize("development mode \ndebugging primitives:")),m.fontSize=9,m.setColor(this.paletteTextColor),k.push(m),k.push("-"),k.push(b("log")),k.push(b("alert")))):"sound"===a?(k.push(b("playSound")),k.push(b("doPlaySoundUntilDone")),k.push(b("doStopAllSounds")),k.push("-"),k.push(b("doPlaySoundAtRate")), +k.push(b("reportGetSoundAttribute")),k.push(b("reportNewSoundFromSamples")),k.push("-"),k.push(b("doRest")),k.push(b("doPlayNote")),k.push(b("doSetInstrument")),k.push("-"),k.push(b("doChangeTempo")),k.push(b("doSetTempo")),k.push(d("getTempo")),k.push(b("getTempo")),k.push("-"),k.push(b("changeVolume")),k.push(b("setVolume")),k.push(d("getVolume")),k.push(b("getVolume")),k.push("-"),k.push(b("changePan")),k.push(b("setPan")),k.push(d("getPan")),k.push(b("getPan")),k.push("-"),k.push(b("playFreq")), +k.push(b("stopFreq")),this.world().isDevMode&&(k.push("-"),m=new TextMorph(localize("development mode \ndebugging primitives:")),m.fontSize=9,m.setColor(this.paletteTextColor),k.push(m),k.push("-"),k.push(b("doPlayFrequency")))):"pen"===a?(k.push(b("clear")),k.push("-"),k.push(b("setBackgroundColor")),k.push(b("changeBackgroundHSVA")),k.push(b("setBackgroundHSVA")),k.push("-"),k.push(b("reportPenTrailsAsCostume")),k.push("-"),k.push(b("doPasteOn"))):"network"===a?(k.push(b("receiveSocketMessage")), +k.push(b("doSocketMessage")),k.push("-"),k.push(b("doSocketRequest")),k.push(b("doSocketResponse")),k.push("-"),k.push(b("getJSFromRPCStruct")),k.push(b("doRunRPC")),k.push(d("reportRPCError")),k.push(b("reportRPCError")),k.push("-"),k.push(b("getProjectIds")),k.push(b("getProjectId")),m=new PushButtonMorph(null,function(){(new MessageCreatorMorph(l,h)).popUp()},"Make a message type"),k.push(m),0n.addItem(p,p,null,null,null,null,null,null,!0));n.popUpAtHand(l.world())},"Delete a variable"),k.push(m)),k.push("-"),m=this.reachableGlobalVariableNames(!0),0{k.push(e(n));k.push(c(n))}), +k.push("-")),m=this.allLocalVariableNames(!0),0{k.push(e(n));k.push(c(n,!0))}),k.push("-")),k.push(b("doSetVar")),k.push(b("doChangeVar")),k.push(b("doShowVar")),k.push(b("doHideVar")),k.push(b("doDeclareVariables")),k.push("="),k.push(b("reportNewList")),k.push(b("reportNumbers")),k.push("-"),k.push(b("reportCONS")),k.push(b("reportListItem")),k.push(b("reportCDR")),k.push("-"),k.push(b("reportListAttribute")),k.push(b("reportListIndex")),k.push(b("reportListContainsItem")), +k.push(b("reportListIsEmpty")),k.push("-"),k.push(b("reportMap")),k.push(b("reportKeep")),k.push(b("reportFindFirst")),k.push(b("reportCombine")),k.push("-"),k.push(b("doForEach")),k.push("-"),k.push(b("doAddToList")),k.push(b("doDeleteFromList")),k.push(b("doInsertInList")),k.push(b("doReplaceInList")),k.push("-"),k.push(b("reportConcatenatedLists")),k.push(b("reportReshape")),k.push(b("reportCrossproduct")),this.world().isDevMode&&(k.push("-"),m=new TextMorph(localize("development mode \ndebugging primitives:")), +m.fontSize=9,m.setColor(this.paletteTextColor),k.push(m),k.push("-"),k.push(b("doShowTable"))),StageMorph.prototype.enableCodeMapping&&(k.push("="),k.push(b("doMapCodeOrHeader")),k.push(b("doMapValueCode")),k.push(b("doMapListCode")),k.push("-"),k.push(b("reportMappedCode"))));if(m=this.parentThatIsA(IDE_Morph))m=m.extensions.getPaletteContents(this,a).flatMap(n=>{switch(n.type){case "block":return b(n.name);case "watcher":return[d(n.name),b(n.name)];case "space":return n.name}return n}),k.push(...m); +k.push("=");k.push(this.makeBlockButton(a));return k};StageMorph.prototype.clear=function(){this.clearPenTrails()}; +StageMorph.prototype.userMenu=function(){var a=this.parentThatIsA(IDE_Morph),b=new MenuMorph(this);if(a&&a.isAppMode)return b;b.addItem("edit","edit");b.addItem("show all","showAll");b.addItem("pic...",()=>a.saveCanvasAs(this.fullImage(),this.name),"save a picture\nof the stage");b.addLine();b.addItem("pen trails",()=>{var c=a.currentSprite.reportPenTrailsAsCostume().copy();a.currentSprite.addCostume(c);a.currentSprite.wearCostume(c);a.hasChangedMedia=!0;a.spriteBar.tabBar.tabTo("costumes")},a.currentSprite instanceof +SpriteMorph?"turn all pen trails and stamps\ninto a new costume for the\ncurrently selected sprite":"turn all pen trails and stamps\ninto a new background for the stage");this.trailsLog.length&&b.addItem("svg...","exportTrailsLogAsSVG","export pen trails\nline segments as SVG");return b};StageMorph.prototype.showAll=function(){this.children.forEach(a=>{a instanceof SpriteMorph?a.anchor||(a.show(),a.keepWithin(this)):(a.show(),a.keepWithin(this),a.fixLayout&&a.fixLayout())})}; +StageMorph.prototype.edit=SpriteMorph.prototype.edit;StageMorph.prototype.fullImage=Morph.prototype.fullImage;StageMorph.prototype.thumbnail=function(a,b){return this.fancyThumbnail(a,null,!1,b)}; +StageMorph.prototype.fancyThumbnail=function(a,b,c,d){var e=this.getImage(),f=Math.min(a.x/e.width,a.y/e.height);a=newCanvas(a,c,d);var g=a.getContext("2d"),h,k;g.save();g.scale(f,f);g.drawImage(e,0,0);g.drawImage(this.penTrails(),0,0,this.dimensions.x*this.scale,this.dimensions.y*this.scale);this.projectionSource&&(g.save(),g.globalAlpha=1-this.projectionTransparency/100,g.drawImage(this.projectionLayer(),0,0,this.dimensions.x*this.scale,this.dimensions.y*this.scale),g.restore());this.children.forEach(l=> +{l.isVisible&&l!==b&&(h=l.fullBounds(),k=l.fullImage(),k.width&&k.height&&g.drawImage(l.fullImage(),h.origin.x-this.bounds.origin.x,h.origin.y-this.bounds.origin.y))});g.restore();return a};StageMorph.prototype.exportTrailsLogAsSVG=function(){var a=this.parentThatIsA(IDE_Morph);a.saveFileAs(this.trailsLogAsSVG().src,"image/svg",a.projectName||this.name)}; +StageMorph.prototype.trailsLogAsSVG=function(){var a=this.trailsLog[0][0],b=a,c=this.trailsLog[0][3],d,e;this.trailsLog.forEach(k=>{a=a.min(k[0]);a=a.min(k[1]);b=b.max(k[0]);b=b.max(k[1]);c=Math.max(c,k[3])});var f=a.corner(b).expandBy(c/2);var g=(new Point(-a.x,b.y)).translateBy(c/2);var h='';h+="\x3c!-- Generated by Snap! - http://snap.berkeley.edu/ --\x3e"; +this.trailsLog.forEach(k=>{d=this.normalizePoint(k[0]).translateBy(g);e=this.normalizePoint(k[1]).translateBy(g);h+=''});h+="";return{src:h,rot:new Point(-f.origin.x,f.corner.y)}};StageMorph.prototype.normalizePoint=function(a){return new Point(a.x,-a.y)};StageMorph.prototype.hide=function(){this.isVisible=!1;this.changed()}; StageMorph.prototype.show=function(){this.isVisible=!0;this.changed()};StageMorph.prototype.reportShown=SpriteMorph.prototype.reportShown;StageMorph.prototype.createClone=nop;StageMorph.prototype.newClone=nop;StageMorph.prototype.setColorComponentHSVA=function(a,b){b=+b;a=+a;if(!(0>a||3b||100b?100:0)+b%100}else b=Math.min(100,Math.max(0,b));3===a?this.color.a=1-b/100:(this.cachedHSV[a]=b/100,this.color.set_hsv.apply(this.color,this.cachedHSV));this.rerender()}}; StageMorph.prototype.getColorComponentHSLA=SpriteMorph.prototype.getColorComponentHSLA;StageMorph.prototype.changeColorComponentHSVA=SpriteMorph.prototype.changeColorComponentHSVA;StageMorph.prototype.setColor=function(a){this.color.eq(a,!0)||(this.color=a.copy(),this.rerender(),this.cachedHSV=this.color.hsv())};StageMorph.prototype.setBackgroundColor=StageMorph.prototype.setColor;StageMorph.prototype.getPenAttribute=SpriteMorph.prototype.getPenAttribute;StageMorph.prototype.pasteOn=SpriteMorph.prototype.pasteOn; StageMorph.prototype.categories=SpriteMorph.prototype.categories;StageMorph.prototype.blockColor=SpriteMorph.prototype.blockColor;StageMorph.prototype.paletteColor=SpriteMorph.prototype.paletteColor;StageMorph.prototype.setName=SpriteMorph.prototype.setName;StageMorph.prototype.makeBlockButton=SpriteMorph.prototype.makeBlockButton;StageMorph.prototype.makeBlock=SpriteMorph.prototype.makeBlock;StageMorph.prototype.palette=SpriteMorph.prototype.palette;StageMorph.prototype.freshPalette=SpriteMorph.prototype.freshPalette; @@ -1788,8 +1713,8 @@ StageMorph.prototype.blocksMatching=SpriteMorph.prototype.blocksMatching;StageMo StageMorph.prototype.blockForSelector=SpriteMorph.prototype.blockForSelector;StageMorph.prototype.findVariableWatcher=SpriteMorph.prototype.findVariableWatcher;StageMorph.prototype.toggleVariableWatcher=SpriteMorph.prototype.toggleVariableWatcher;StageMorph.prototype.findVariableWatcherToggle=SpriteMorph.prototype.findVariableWatcherToggle;StageMorph.prototype.refreshVariableWatcher=SpriteMorph.prototype.refreshVariableWatcher;StageMorph.prototype.showingVariableWatcher=SpriteMorph.prototype.showingVariableWatcher; StageMorph.prototype.deleteVariableWatcher=SpriteMorph.prototype.deleteVariableWatcher;StageMorph.prototype.addCostume=SpriteMorph.prototype.addCostume;StageMorph.prototype.wearCostume=SpriteMorph.prototype.wearCostume;StageMorph.prototype.getCostumeIdx=SpriteMorph.prototype.getCostumeIdx;StageMorph.prototype.doWearNextCostume=SpriteMorph.prototype.doWearNextCostume;StageMorph.prototype.doWearPreviousCostume=SpriteMorph.prototype.doWearPreviousCostume;StageMorph.prototype.doSwitchToCostume=SpriteMorph.prototype.doSwitchToCostume; StageMorph.prototype.reportCostumes=SpriteMorph.prototype.reportCostumes;StageMorph.prototype.graphicsChanged=SpriteMorph.prototype.graphicsChanged;StageMorph.prototype.applyGraphicsEffects=SpriteMorph.prototype.applyGraphicsEffects;StageMorph.prototype.setEffect=SpriteMorph.prototype.setEffect;StageMorph.prototype.getEffect=SpriteMorph.prototype.getEffect;StageMorph.prototype.getGhostEffect=SpriteMorph.prototype.getGhostEffect;StageMorph.prototype.changeEffect=SpriteMorph.prototype.changeEffect; -StageMorph.prototype.clearEffects=SpriteMorph.prototype.clearEffects;StageMorph.prototype.addSound=SpriteMorph.prototype.addSound;StageMorph.prototype.doPlaySound=SpriteMorph.prototype.doPlaySound;StageMorph.prototype.stopAllActiveSounds=function(){this.activeSounds.forEach(function(a){return a.pause()});this.activeSounds=[];this.microphone.modifier&&this.microphone.isReady&&this.microphone.stop()};StageMorph.prototype.pauseAllActiveSounds=function(){this.activeSounds.forEach(function(a){return a.pause()})}; -StageMorph.prototype.resumeAllActiveSounds=function(){this.activeSounds.forEach(function(a){return a.play()})};StageMorph.prototype.reportSounds=SpriteMorph.prototype.reportSounds;StageMorph.prototype.newSoundName=SpriteMorph.prototype.newSoundName;StageMorph.prototype.setVolume=SpriteMorph.prototype.setVolume;StageMorph.prototype.changeVolume=SpriteMorph.prototype.changeVolume;StageMorph.prototype.getVolume=SpriteMorph.prototype.getVolume;StageMorph.prototype.getGainNode=SpriteMorph.prototype.getGainNode; +StageMorph.prototype.clearEffects=SpriteMorph.prototype.clearEffects;StageMorph.prototype.addSound=SpriteMorph.prototype.addSound;StageMorph.prototype.doPlaySound=SpriteMorph.prototype.doPlaySound;StageMorph.prototype.stopAllActiveSounds=function(){this.activeSounds.forEach(a=>a.pause());this.activeSounds=[];this.microphone.modifier&&this.microphone.isReady&&this.microphone.stop()};StageMorph.prototype.pauseAllActiveSounds=function(){this.activeSounds.forEach(a=>a.pause())}; +StageMorph.prototype.resumeAllActiveSounds=function(){this.activeSounds.forEach(a=>a.play())};StageMorph.prototype.reportSounds=SpriteMorph.prototype.reportSounds;StageMorph.prototype.newSoundName=SpriteMorph.prototype.newSoundName;StageMorph.prototype.setVolume=SpriteMorph.prototype.setVolume;StageMorph.prototype.changeVolume=SpriteMorph.prototype.changeVolume;StageMorph.prototype.getVolume=SpriteMorph.prototype.getVolume;StageMorph.prototype.getGainNode=SpriteMorph.prototype.getGainNode; StageMorph.prototype.audioContext=SpriteMorph.prototype.audioContext;StageMorph.prototype.setPan=SpriteMorph.prototype.setPan;StageMorph.prototype.changePan=SpriteMorph.prototype.changePan;StageMorph.prototype.getPan=SpriteMorph.prototype.getPan;StageMorph.prototype.getPannerNode=SpriteMorph.prototype.getPannerNode;StageMorph.prototype.playFreq=SpriteMorph.prototype.playFreq;StageMorph.prototype.stopFreq=SpriteMorph.prototype.stopFreq;StageMorph.prototype.toggleWatcher=SpriteMorph.prototype.toggleWatcher; StageMorph.prototype.showingWatcher=SpriteMorph.prototype.showingWatcher;StageMorph.prototype.watcherFor=SpriteMorph.prototype.watcherFor;StageMorph.prototype.getLastAnswer=SpriteMorph.prototype.getLastAnswer;StageMorph.prototype.reportThreadCount=SpriteMorph.prototype.reportThreadCount;StageMorph.prototype.xCenter=function(){return 0};StageMorph.prototype.yCenter=function(){return 0};StageMorph.prototype.xLeft=function(){return-.5*this.dimensions.x}; StageMorph.prototype.xRight=function(){return this.dimensions.x/2};StageMorph.prototype.yTop=function(){return this.dimensions.y/2};StageMorph.prototype.yBottom=function(){return-.5*this.dimensions.y};StageMorph.prototype.allMessageNames=SpriteMorph.prototype.allMessageNames;StageMorph.prototype.allSendersOf=SpriteMorph.prototype.allSendersOf;StageMorph.prototype.allHatBlocksFor=SpriteMorph.prototype.allHatBlocksFor;StageMorph.prototype.allHatBlocksForKey=SpriteMorph.prototype.allHatBlocksForKey; @@ -1797,10 +1722,9 @@ StageMorph.prototype.allHatBlocksForInteraction=SpriteMorph.prototype.allHatBloc StageMorph.prototype.mouseScroll=SpriteMorph.prototype.mouseScroll;StageMorph.prototype.receiveUserInteraction=SpriteMorph.prototype.receiveUserInteraction;StageMorph.prototype.deleteAllBlockInstances=SpriteMorph.prototype.deleteAllBlockInstances;StageMorph.prototype.allBlockInstances=SpriteMorph.prototype.allBlockInstances;StageMorph.prototype.allLocalBlockInstances=SpriteMorph.prototype.allLocalBlockInstances;StageMorph.prototype.allEditorBlockInstances=SpriteMorph.prototype.allEditorBlockInstances; StageMorph.prototype.paletteBlockInstance=SpriteMorph.prototype.paletteBlockInstance;StageMorph.prototype.usesBlockInstance=SpriteMorph.prototype.usesBlockInstance;StageMorph.prototype.doubleDefinitionsFor=SpriteMorph.prototype.doubleDefinitionsFor;StageMorph.prototype.replaceDoubleDefinitionsFor=SpriteMorph.prototype.replaceDoubleDefinitionsFor;StageMorph.prototype.allInvocationsOf=SpriteMorph.prototype.allInvocationsOf;StageMorph.prototype.allIndependentInvocationsOf=SpriteMorph.prototype.allInvocationsOf; StageMorph.prototype.allDependentInvocationsOf=SpriteMorph.prototype.allInvocationsOf;StageMorph.prototype.specimens=function(){return[]};StageMorph.prototype.allSpecimens=function(){return[]};StageMorph.prototype.shadowAttribute=nop;StageMorph.prototype.inheritsAttribute=function(){return!1};StageMorph.prototype.isVariableNameInUse=SpriteMorph.prototype.isVariableNameInUse;StageMorph.prototype.globalVariables=SpriteMorph.prototype.globalVariables;StageMorph.prototype.inheritedVariableNames=function(){return[]}; -StageMorph.prototype.allLocalVariableNames=SpriteMorph.prototype.allLocalVariableNames;StageMorph.prototype.reachableGlobalVariableNames=SpriteMorph.prototype.reachableGlobalVariableNames;StageMorph.prototype.getMethod=SpriteMorph.prototype.getMethod;StageMorph.prototype.getLocalMethod=SpriteMorph.prototype.getLocalMethod;StageMorph.prototype.ownBlocks=SpriteMorph.prototype.ownBlocks; -StageMorph.prototype.allBlocks=function(a){var b=this.ownBlocks();return a?Object.keys(b).map(function(c){return b[c]}):b};StageMorph.prototype.inheritedBlocks=function(){return[]};StageMorph.prototype.hasSpriteVariable=SpriteMorph.prototype.hasSpriteVariable;StageMorph.prototype.refactorVariableInstances=SpriteMorph.prototype.refactorVariableInstances;StageMorph.prototype.reportPenTrailsAsCostume=function(){return new Costume(this.trailsCanvas,this.newCostumeName(localize("Background")))}; -SpriteBubbleMorph.prototype=new SpeechBubbleMorph;SpriteBubbleMorph.prototype.constructor=SpriteBubbleMorph;SpriteBubbleMorph.uber=SpeechBubbleMorph.prototype;function SpriteBubbleMorph(a,b,c,d){this.init(a,b,c,d)} -SpriteBubbleMorph.prototype.init=function(a,b,c,d){var e=SpriteMorph.prototype;this.scale=(this.stage=b)?b.scale:1;this.data=a;this.isQuestion=d;SpriteBubbleMorph.uber.init.call(this,this.data,e.bubbleColor,null,null,d?e.blockColor.sensing:e.bubbleBorderColor,null,c,!0);this.isCachingImage=!0;this.rerender()}; +StageMorph.prototype.allLocalVariableNames=SpriteMorph.prototype.allLocalVariableNames;StageMorph.prototype.reachableGlobalVariableNames=SpriteMorph.prototype.reachableGlobalVariableNames;StageMorph.prototype.getMethod=SpriteMorph.prototype.getMethod;StageMorph.prototype.getLocalMethod=SpriteMorph.prototype.getLocalMethod;StageMorph.prototype.ownBlocks=SpriteMorph.prototype.ownBlocks;StageMorph.prototype.allBlocks=function(a){var b=this.ownBlocks();return a?Object.keys(b).map(c=>b[c]):b}; +StageMorph.prototype.inheritedBlocks=function(){return[]};StageMorph.prototype.hasSpriteVariable=SpriteMorph.prototype.hasSpriteVariable;StageMorph.prototype.refactorVariableInstances=SpriteMorph.prototype.refactorVariableInstances;StageMorph.prototype.reportPenTrailsAsCostume=function(){return new Costume(this.trailsCanvas,this.newCostumeName(localize("Background")))};SpriteBubbleMorph.prototype=new SpeechBubbleMorph;SpriteBubbleMorph.prototype.constructor=SpriteBubbleMorph; +SpriteBubbleMorph.uber=SpeechBubbleMorph.prototype;function SpriteBubbleMorph(a,b,c,d){this.init(a,b,c,d)}SpriteBubbleMorph.prototype.init=function(a,b,c,d){var e=SpriteMorph.prototype;this.scale=(this.stage=b)?b.scale:1;this.data=a;this.isQuestion=d;SpriteBubbleMorph.uber.init.call(this,this.data,e.bubbleColor,null,null,d?e.blockColor.sensing:e.bubbleBorderColor,null,c,!0);this.isCachingImage=!0;this.rerender()}; SpriteBubbleMorph.prototype.dataAsMorph=function(a){var b=SpriteMorph.prototype;if(a instanceof Morph)if(isSnapObject(a)){var c=a.thumbnail(new Point(40,40));var d=new Morph;d.isCachingImage=!0;d.bounds.setWidth(c.width);d.bounds.setHeight(c.height);d.cachedImage=c;d.version=a.version;d.step=function(){this.version!==a.version&&(this.cachedImage=c=a.thumbnail(new Point(40,40),this.cachedImage),this.version=a.version,this.changed())}}else d=a;else if(isString(a)){var e=!0;d=new TextMorph(a,b.bubbleFontSize* this.scale,null,b.bubbleFontIsBold,!1,"center")}else"boolean"===typeof a?(c=b.booleanMorph(a).fullImage(),d=new Morph,d.isCachingImage=!0,d.bounds.setWidth(c.width),d.bounds.setHeight(c.height),d.cachedImage=c):a instanceof Costume?(c=a.thumbnail(new Point(40,40)),d=new Morph,d.isCachingImage=!0,d.bounds.setWidth(c.width),d.bounds.setHeight(c.height),d.cachedImage=c):a instanceof Sound?d=new SymbolMorph("notes",30):a instanceof HTMLCanvasElement?(c=a,d=new Morph,d.isCachingImage=!0,d.bounds.setWidth(c.width), d.bounds.setHeight(c.height),d.cachedImage=c):a instanceof List?(a.isTable()?d=new TableFrameMorph(new TableMorph(a,10)):(d=new ListWatcherMorph(a),d.update(!0),d.step=d.update),this.stage&&d.expand(this.stage.extent().translateBy(-2*(this.edge+this.border+this.padding))),d.isDraggable=!1):a instanceof Context?(c=a.image(),d=new Morph,d.isCachingImage=!0,d.bounds.setWidth(c.width),d.bounds.setHeight(c.height),d.cachedImage=c):d=new TextMorph(a.toString(),b.bubbleFontSize*this.scale,null,b.bubbleFontIsBold, @@ -1813,14 +1737,14 @@ Costume.prototype.canvasBoundingBox=function(a){var b,c,d=a.width,e=a.height,f=a Costume.prototype.boundingBox=function(){return this.canvasBoundingBox(this.contents)};Costume.prototype.copy=function(){var a=newCanvas(this.extent(),!0);a.getContext("2d").drawImage(this.contents,0,0);a=new Costume(a,this.name?copy(this.name):null);a.rotationCenter=this.rotationCenter.copy();return a}; Costume.prototype.flipped=function(){var a=newCanvas(this.extent(),!0),b=a.getContext("2d");b.translate(this.width(),0);b.scale(-1,1);b.drawImage(this.contents,0,0);return new Costume(a,this.name,new Point(this.width()-this.rotationCenter.x,this.rotationCenter.y))}; Costume.prototype.stretched=function(a,b){a=(Math.sign(a)||1)*Math.max(1,Math.abs(a));b=(Math.sign(b)||1)*Math.max(1,Math.abs(b));var c=newCanvas(new Point(Math.abs(a),Math.abs(b)),!0),d=c.getContext("2d"),e=a/this.width(),f=b/this.height(),g=this.rotationCenter.multiplyBy(new Point(e,f));0>e&&(g.x=c.width-Math.abs(g.x));0>f&&(g.y=c.height-Math.abs(g.y));d.translate(Math.abs(Math.min(a,0)),Math.abs(Math.min(b,0)));d.scale(e,f);d.drawImage(this.contents,0,0);return new Costume(c,this.name,g,!0)}; -Costume.prototype.edit=function(a,b,c,d,e){var f=this,g=new PaintEditorMorph;g.oncancel=d||nop;g.openIn(a,c?newCanvas(StageMorph.prototype.dimensions,!0):this.contents,c?null:this.rotationCenter,function(h,k){f.contents=h;f.rotationCenter=k;f.version=Date.now();a.changed();b&&(b.currentSprite instanceof SpriteMorph&&f.shrinkWrap(),b.currentSprite.wearCostume(f,!0),b.hasChangedMedia=!0);(e||nop)()},b)}; -Costume.prototype.editRotationPointOnly=function(a,b){var c=this,d=new CostumeEditorMorph(this);d.fixLayout();var e=new DialogBoxMorph(this,function(){d.accept();b&&b.call(c)});var f=new TextMorph(localize("click or drag crosshairs to move the rotation center"),e.fontSize,e.fontStyle,!0,!1,"center",null,null,new Point(1,1),WHITE);e.labelString="Costume Editor";e.createLabel();e.setPicture(d);e.addBody(f);e.addButton("ok","Ok");e.addButton("cancel","Cancel");e.fixLayout();e.popUp(a)}; +Costume.prototype.edit=function(a,b,c,d,e){var f=new PaintEditorMorph;f.oncancel=d||nop;f.openIn(a,c?newCanvas(StageMorph.prototype.dimensions,!0):this.contents,c?null:this.rotationCenter,(g,h)=>{this.contents=g;this.rotationCenter=h;this.version=Date.now();a.changed();b&&(b.currentSprite instanceof SpriteMorph&&this.shrinkWrap(),b.currentSprite.wearCostume(this,!0),b.hasChangedMedia=!0);(e||nop)()},b)}; +Costume.prototype.editRotationPointOnly=function(a,b){var c=new CostumeEditorMorph(this);c.fixLayout();var d=new DialogBoxMorph(this,()=>{c.accept();b&&b.call(this)});var e=new TextMorph(localize("click or drag crosshairs to move the rotation center"),d.fontSize,d.fontStyle,!0,!1,"center",null,null,new Point(1,1),WHITE);d.labelString="Costume Editor";d.createLabel();d.setPicture(c);d.addBody(e);d.addButton("ok","Ok");d.addButton("cancel","Cancel");d.fixLayout();d.popUp(a)}; Costume.prototype.shrinkToFit=function(a){if(a.xb.copy());return a};SVG_Costume.prototype.shrinkToFit=function(a){nop(a)}; +SVG_Costume.prototype.parseShapes=function(){var a=new XML_Element,b=this.contents.src.replace(/^data:image\/.*?, */,"");-1window[c.attributes.prototype].fromSVG(c)))}; +SVG_Costume.prototype.edit=function(a,b,c,d,e){var f=new VectorPaintEditorMorph,g=this;f.oncancel=d||nop;f.openIn(a,c?newCanvas(StageMorph.prototype.dimensions):this.contents,c?new Point(240,180):this.rotationCenter,(h,k,l)=>{g.contents=h;g.rotationCenter=k;g.shapes=l;g.version=Date.now();a.changed();b&&(c&&b.currentSprite.addCostume(g),b.currentSprite.wearCostume(g),b.hasChangedMedia=!0);(e||nop)()},b,this.shapes||[])}; SVG_Costume.prototype.rasterized=function(){var a=newCanvas(this.extent(),!0);a.getContext("2d").drawImage(this.contents,0,0);return new Costume(a,this.name,this.rotationCenter.copy())};CostumeEditorMorph.prototype=new Morph;CostumeEditorMorph.prototype.constructor=CostumeEditorMorph;CostumeEditorMorph.uber=Morph.prototype;CostumeEditorMorph.prototype.size=Costume.prototype.maxExtent();function CostumeEditorMorph(a){this.init(a)} CostumeEditorMorph.prototype.init=function(a){this.costume=a||new Costume;this.rotationCenter=this.costume.rotationCenter.copy();this.margin=ZERO;CostumeEditorMorph.uber.init.call(this)};CostumeEditorMorph.prototype.accept=function(){this.costume.rotationCenter=this.rotationCenter.copy();this.costume.version=Date.now()};CostumeEditorMorph.prototype.fixLayout=function(){this.bounds.setExtent(this.size)}; CostumeEditorMorph.prototype.render=function(a){this.margin=this.size.subtract(this.costume.extent()).divideBy(2);var b=this.rotationCenter.add(this.margin);this.cachedTexture||(this.cachedTexture=this.createTexture());this.renderCachedTexture(a);a.drawImage(this.costume.contents,this.margin.x,this.margin.y);a.globalAlpha=.5;a.fillStyle="white";a.beginPath();a.arc(b.x,b.y,20,radians(0),radians(360),!1);a.closePath();a.fill();a.stroke();a.beginPath();a.arc(b.x,b.y,10,radians(0),radians(360),!1);a.stroke(); @@ -1829,13 +1753,13 @@ CostumeEditorMorph.prototype.mouseDownLeft=function(a){this.rotationCenter=a.sub Sound.prototype.copy=function(){var a=document.createElement("audio");a.src=this.audio.src;return new Sound(a,this.name?copy(this.name):null)};Sound.prototype.toDataURL=function(){return this.audio.src};function Note(a){this.pitch=0===a?0:a||69;this.frequency=null;this.setupContext();this.fader=this.oscillator=null;this.ended=!1}Note.prototype.audioContext=null;Note.prototype.fadeIn=new Float32Array(2);Note.prototype.fadeIn[0]=[0];Note.prototype.fadeIn[1]=[.2];Note.prototype.fadeOut=new Float32Array(2); Note.prototype.fadeOut[0]=[.2];Note.prototype.fadeOut[1]=[0];Note.prototype.fadeTime=.01;Note.prototype.setupContext=function(){if(!this.audioContext){var a=window.AudioContext||window.mozAudioContext||window.msAudioContext||window.oAudioContext||window.webkitAudioContext;a.prototype.createGain||(a.prototype.createGain=a.prototype.createGainNode);if(!a)throw Error("Web Audio API is not supported\nin this browser");Note.prototype.audioContext=new a}}; Note.prototype.getAudioContext=function(){this.audioContext||this.setupContext();this.audioContext.resume();return this.audioContext}; -Note.prototype.play=function(a,b,c){b||(b=this.audioContext.createGain());this.fader=this.audioContext.createGain();this.oscillator=this.audioContext.createOscillator();this.oscillator.start||(this.oscillator.start=this.oscillator.noteOn);this.oscillator.stop||(this.oscillator.stop=this.oscillator.noteOff);this.setInstrument(a);this.oscillator.frequency.value=isNil(this.frequency)?440*Math.pow(2,(this.pitch-69)/12):this.frequency;this.oscillator.connect(this.fader);this.fader.connect(b);c?(b.connect(c), +Note.prototype.play=function(a,b,c){b||=this.audioContext.createGain();this.fader=this.audioContext.createGain();this.oscillator=this.audioContext.createOscillator();this.oscillator.start||(this.oscillator.start=this.oscillator.noteOn);this.oscillator.stop||(this.oscillator.stop=this.oscillator.noteOff);this.setInstrument(a);this.oscillator.frequency.value=isNil(this.frequency)?440*Math.pow(2,(this.pitch-69)/12):this.frequency;this.oscillator.connect(this.fader);this.fader.connect(b);c?(b.connect(c), c.connect(this.audioContext.destination)):b.connect(this.audioContext.destination);this.ended=!1;this.fader.gain.setValueCurveAtTime(this.fadeIn,this.audioContext.currentTime,this.fadeTime);this.oscillator.start(0)};Note.prototype.setInstrument=function(a){this.oscillator&&(this.oscillator.type=["sine","square","sawtooth","triangle"][(a||1)-1])}; Note.prototype.stop=function(a){var b=!a;if(a&&this.oscillator)this.oscillator.stop(0);else{if(this.fader)try{this.fader.gain.setValueCurveAtTime(this.fadeOut,this.audioContext.currentTime,this.fadeTime)}catch(c){b=!1}this.oscillator&&(this.oscillator.stop(b?this.audioContext.currentTime+this.fadeTime:0),this.oscillator=null);this.ended=!0}};Note.prototype.pause=function(){this.stop()}; function Microphone(){this.analyser=this.processor=this.sourceStream=this.audioContext=null;this.resolution=2;this.GOOD_ENOUGH_CORRELATION=.96;this.compilerProcess=this.compiledModifier=this.modifier=null;this.correlations=[];this.wrapper=new List([0]);this.outChannels=[];this.volume=0;this.signals=[];this.output=[];this.frequencies=[];this.pitch=-1;this.isReady=this.isStarted=!1;this.isAutoStop="file:"!==location.protocol;this.lastTime=Date.now()} Microphone.prototype.isOn=function(){if(this.isReady)return this.lastTime=Date.now(),!0;this.start();return!1};Microphone.prototype.binSizes=[256,512,1024,2048,4096];Microphone.prototype.binSize=function(){return this.binSizes[this.resolution-1]};Microphone.prototype.setResolution=function(a){contains([1,2,3,4],a)&&(this.isReady&&this.stop(),this.resolution=a)}; -Microphone.prototype.start=function(){var a=this;this.isStarted||(this.isStarted=!0,this.isReady=!1,this.audioContext=Note.prototype.getAudioContext(),navigator.mediaDevices.getUserMedia({audio:{mandatory:{googEchoCancellation:"false",googAutoGainControl:"false",googNoiseSuppression:"false",googHighpassFilter:"false"},optional:[]}}).then(function(b){return a.setupNodes(b)}).catch(nop))}; -Microphone.prototype.stop=function(){this.processor.onaudioprocess=null;this.sourceStream.getTracks().forEach(function(a){return a.stop()});this.processor.disconnect();this.analyser.disconnect();this.audioContext=this.analyser=this.processor=null;this.isStarted=this.isReady=!1}; +Microphone.prototype.start=function(){this.isStarted||(this.isStarted=!0,this.isReady=!1,this.audioContext=Note.prototype.getAudioContext(),navigator.mediaDevices.getUserMedia({audio:{mandatory:{googEchoCancellation:"false",googAutoGainControl:"false",googNoiseSuppression:"false",googHighpassFilter:"false"},optional:[]}}).then(a=>this.setupNodes(a)).catch(nop))}; +Microphone.prototype.stop=function(){this.processor.onaudioprocess=null;this.sourceStream.getTracks().forEach(a=>a.stop());this.processor.disconnect();this.analyser.disconnect();this.audioContext=this.analyser=this.processor=null;this.isStarted=this.isReady=!1}; Microphone.prototype.setupNodes=function(a){this.sourceStream=a;this.createProcessor();this.createAnalyser();this.analyser.connect(this.processor);this.processor.connect(this.audioContext.destination);this.audioContext.createMediaStreamSource(a).connect(this.analyser);this.lastTime=Date.now()}; Microphone.prototype.createAnalyser=function(){this.analyser=this.audioContext.createAnalyser();this.analyser.fftSize=this.binSizes[this.resolution];var a=this.analyser.frequencyBinCount;this.frequencies=new Uint8Array(a);this.correlations=Array(Math.floor(a/2))}; Microphone.prototype.createProcessor=function(){var a=this;this.processor=this.audioContext.createScriptProcessor(this.binSizes[this.resolution-1]);this.processor.onaudioprocess=function(b){a.stepAudio(b)};this.processor.clipping=!1;this.processor.lastClip=0;this.processor.clipLevel=.98;this.processor.averaging=.95;this.processor.clipLag=750}; @@ -1883,22 +1807,22 @@ this.color.darker(),this.sliderMorph.color=this.color.lighter(60),this.sliderMor 3,0))),this.labelMorph.setTop(this.cellMorph.top()+(this.cellMorph.height()-this.labelMorph.height())/2)),"slider"===this.style?(this.sliderMorph.setPosition(new Point(this.labelMorph.left(),this.cellMorph.bottom()+SyntaxElementMorph.prototype.typeInPadding)),this.sliderMorph.setWidth(this.cellMorph.right()-this.labelMorph.left()),this.bounds.setHeight(this.cellMorph.height()+this.sliderMorph.height()+2*this.border+3*SyntaxElementMorph.prototype.typeInPadding)):(this.sliderMorph.hide(),this.bounds.corner.y= this.cellMorph.bottom()+this.border+SyntaxElementMorph.prototype.typeInPadding),this.bounds.corner.x=Math.max(this.cellMorph.right(),this.labelMorph.right())+this.edge+SyntaxElementMorph.prototype.typeInPadding)};WatcherMorph.prototype.mouseDoubleClick=function(a){List.prototype.enableTables&&this.currentValue instanceof List?(new TableDialogMorph(this.currentValue)).popUp(this.world()):this.escalateEvent("mouseDoubleClick",a)}; WatcherMorph.prototype.rootForGrab=function(){var a=this.parentThatIsA(IDE_Morph);return a&&a.isAppMode?a:this}; -WatcherMorph.prototype.userMenu=function(){function a(g){var h=c.parentThatIsA(StageMorph),k=c.currentValue.outerContext.variables;f.addItem(g+"...",function(){var l=detect(h.children,function(n){return n instanceof WatcherMorph&&n.target===k&&n.getter===g});if(null!==l)l.show();else{l=new WatcherMorph(g+" "+localize("(temporary)"),SpriteMorph.prototype.blockColor.variables,k,g);l.setPosition(h.position().add(10));var m=h.watchers(l.left());0m instanceof WatcherMorph&&m.target===h&&m.getter===f);if(null!==k)k.show();else{k=new WatcherMorph(f+" "+localize("(temporary)"),SpriteMorph.prototype.blockColor.variables,h,f);k.setPosition(g.position().add(10));var l=g.watchers(k.left());0this.importData(!0),"import without attempting to\nparse or format data"),d&&(this.currentValue instanceof List&&this.currentValue.canBeCSV()&&e.addItem("export as CSV...",()=>{this.parentThatIsA(IDE_Morph).saveFileAs(this.currentValue.asCSV(),"text/csv;charset=utf-8",this.getter)},null,new Color(100,0,0)),this.currentValue instanceof List&&this.currentValue.canBeJSON()&&e.addItem("export as JSON...",()=> +{this.parentThatIsA(IDE_Morph).saveFileAs(this.currentValue.asJSON(!0),"text/json;charset=utf-8",this.getter)},null,new Color(100,0,0))),isString(this.currentValue)||!isNaN(+this.currentValue)?(d&&e.addItem("parse","parseTxt","try to convert\nraw data into a list",new Color(100,0,0)),e.addItem("export...",()=>{this.parentThatIsA(IDE_Morph).saveFileAs(this.currentValue.toString(),"text/plain;charset=utf-8",this.getter)})):this.currentValue instanceof List&&this.currentValue.canBeCSV()?e.addItem("export...", +()=>{this.parentThatIsA(IDE_Morph).saveFileAs(this.currentValue.asCSV(),"text/csv;charset=utf-8",this.getter)}):this.currentValue instanceof List&&this.currentValue.canBeJSON()?e.addItem("export...",()=>{this.parentThatIsA(IDE_Morph).saveFileAs(this.currentValue.asJSON(!0),"text/json;charset=utf-8",this.getter)}):this.currentValue instanceof List&&this.currentValue.canBeCSV()?e.addItem("export...",function(){b.parentThatIsA(IDE_Morph).saveFileAs(b.currentValue.asCSV(),"text/csv;charset=utf-8",b.getter)}): +this.currentValue instanceof List&&this.currentValue.canBeJSON()?e.addItem("export...",function(){b.parentThatIsA(IDE_Morph).saveFileAs(b.currentValue.asJSON(!0),"text/json;charset=utf-8",b.getter)}):this.currentValue instanceof Context&&(d=this.currentValue.outerContext.variables.names(),d.length&&(e.addLine(),d.forEach(f=>a(f)))),this.currentValue.blockify&&e.addItem("blockify",()=>{var f=c.world();this.currentValue.blockify().pickUp(f);f.hand.grabOrigin={origin:c.palette,position:c.palette.center()}}), +e.addItem("hide...",function(){const f=b.parentThatIsA(IDE_Morph),g=b.getter;b.isTemporary()?b.destroy():f.stage.toggleVariableWatcher(g)})),e}; WatcherMorph.prototype.importData=function(a){var b=document.createElement("input"),c=this.parentThatIsA(IDE_Morph),d=this;c.filePicker&&(document.body.removeChild(c.filePicker),c.filePicker=null);b.type="file";b.style.color="transparent";b.style.backgroundColor="transparent";b.style.border="none";b.style.outline="none";b.style.position="absolute";b.style.top="0px";b.style.left="0px";b.style.width="0px";b.style.height="0px";b.style.display="none";b.addEventListener("change",function(){function e(g, h){c.confirm(localize('Snap! can only import "text" files.\nYou selected a file of type "'+g+'".')+"\n\n"+localize("Open anyway?"),"Unable to import",h)}function f(g){function h(m,n){return-1!==m.type.indexOf(n)||l===n}var k=new FileReader,l=g.name.split(".").pop().toLowerCase();k.onloadend=function(m){!a&&h(g,"csv")?d.target.setVar(d.getter,Process.prototype.parseCSV(m.target.result)):!a&&h(g,"json")?d.target.setVar(d.getter,Process.prototype.parseJSON(m.target.result)):d.target.setVar(d.getter, -m.target.result)};a||-1!==g.type.indexOf("text")||contains(["txt","csv","xml","json","tsv"],l)?k.readAsText(g):e(g.type,function(){return k.readAsText(g)})}document.body.removeChild(b);c.filePicker=null;0k.readAsText(g))}document.body.removeChild(b);c.filePicker=null;0this.accept(),"\u2713");StagePrompterMorph.uber.init.call(this,SyntaxElementMorph.prototype.rounding,SpriteMorph.prototype.bubbleBorder,SpriteMorph.prototype.blockColor.sensing);this.color=WHITE;this.label&&this.add(this.label);this.add(this.inputField); +this.add(this.button);this.setWidth(StageMorph.prototype.dimensions.x-20);this.fixLayout()}; StagePrompterMorph.prototype.fixLayout=function(){var a=0;this.label&&(this.label.setPosition(new Point(this.left()+this.edge,this.top()+this.edge)),a=this.label.bottom()-this.top());this.inputField.setPosition(new Point(this.left()+this.edge,this.top()+a+this.edge));this.inputField.setWidth(this.width()-2*this.edge-this.button.width()-this.border);this.button.setCenter(this.inputField.center());this.button.setLeft(this.inputField.right()+this.border);this.setHeight(this.inputField.bottom()-this.top()+ this.edge)};StagePrompterMorph.prototype.mouseClickLeft=function(){this.inputField.edit()};StagePrompterMorph.prototype.accept=function(){this.isDone=!0};ReplayControls.prototype=new Morph;ReplayControls.prototype.buttonColor=new Color(200,200,200);ReplayControls.prototype.constructor=ReplayControls;ReplayControls.uber=Morph.prototype;function ReplayControls(){this.init()} ReplayControls.prototype.init=function(){var a=this;ReplayControls.uber.init.call(this);this.alpha=0;this.actions=null;this.actionIndex=-1;this.actionTime=0;this.isPlaying=this.isApplyingAction=!1;this.maxGapDuration=12E4;this.gapFolds=[];this.isShowingCaptions=!1;this.lastCaption=null;this.replaySpeed=1;this.maxInactiveDuration=0;this.playButton=new SymbolMorph("pointRight",40,this.buttonColor);this.playButton.mouseClickLeft=function(){a.play()};this.stepForwardButton=new SymbolMorph("stepForward", @@ -1906,8 +1830,8 @@ ReplayControls.prototype.init=function(){var a=this;ReplayControls.uber.init.cal this.displayTime=new TextMorph("0:00 / 1:00",1.5*PushButtonMorph.prototype.fontSize,PushButtonMorph.prototype.fontStyle,!0);this.displayTime.color=this.buttonColor;this.settingsButton=new SymbolMorph("gears",30,this.buttonColor);this.settingsButton.mouseClickLeft=function(){var d=this.world(),e=a.settingsMenu(),f=d.hand.position().subtract(e.extent());e.popup(d,f)};this.captionsButton=new SymbolMorph("speechBubble",30,this.buttonColor);this.captionsButton.mouseClickLeft=function(){a.toggleCaptions()}; this.slider=new SliderMorph(0,100,0,1,"horizontal");this.slider.start=0;this.slider.value=0;var b=this.slider.mouseDownLeft;this.slider.mouseDownLeft=function(d){a.pause();b.call(this,d)};var c=this.slider.updateValue;this.slider.updateValue=function(){c.apply(this,arguments);a.updateDisplayTime()};this.add(this.slider);this.add(this.playButton);this.add(this.stepForwardButton);this.add(this.jumpForwardButton);this.add(this.jumpBackwardButton);this.add(this.stepBackwardButton);this.add(this.displayTime); this.add(this.captionsButton);this.add(this.settingsButton);this.fixLayout();this.rerender();this.update()}; -ReplayControls.prototype.settingsMenu=function(){var a=this,b=new MenuMorph(this),c=new MenuMorph(this),d={slow:.5,normal:1,"slightly faster":3,fast:5,"really fast":10,"ludicrous speed":20},e={"1 minute":6E4,"2 minute":12E4,"5 minutes":3E5,"10 minutes":6E5,"20 minutes":12E5},f=function(g,h,k){var l=new MenuMorph(a),m=k.skip||[];Object.keys(g).forEach(function(n){var p=g[n],r=contains(m,n);delete g[n];n=r?localize(n):localize(n)+" ("+p+k.suffix+")";g[n]=p;l.addItem(r?n:p+k.suffix,function(){a[h]=p; -if(k.refresh){var q=a.getTimeFromPosition(a.slider.value);a.setActions(a.actions);a.slider.value=a.getSliderPositionFromTime(q);a.slider.rerender();a.updateDisplayTime()}},null,null,a[h]===p)});return l};b.addMenu("Max inactive duration...",f({"no acceleration":0,tiny:.5,small:1,medium:2,"long":5},"maxInactiveDuration",{suffix:"s",skip:["no acceleration"]}));c=f(d,"replaySpeed",{suffix:"x"});c.addItem("other...",function(){(new DialogBoxMorph(null,function(g){a.replaySpeed=Math.max(+g,0)||1})).withKey("replaySpeed").prompt("Replay Speed", +ReplayControls.prototype.settingsMenu=function(){var a=this,b=new MenuMorph(this),c=new MenuMorph(this),d={slow:.5,normal:1,"slightly faster":3,fast:5,"really fast":10,"ludicrous speed":20},e={"1 minute":6E4,"2 minute":12E4,"5 minutes":3E5,"10 minutes":6E5,"20 minutes":12E5},f=function(g,h,k){var l=new MenuMorph(a),m=k.skip||[];Object.keys(g).forEach(function(n){var p=g[n],q=contains(m,n);delete g[n];n=q?localize(n):localize(n)+" ("+p+k.suffix+")";g[n]=p;l.addItem(q?n:p+k.suffix,function(){a[h]=p; +if(k.refresh){var r=a.getTimeFromPosition(a.slider.value);a.setActions(a.actions);a.slider.value=a.getSliderPositionFromTime(r);a.slider.rerender();a.updateDisplayTime()}},null,null,a[h]===p)});return l};b.addMenu("Max inactive duration...",f({"no acceleration":0,tiny:.5,small:1,medium:2,"long":5},"maxInactiveDuration",{suffix:"s",skip:["no acceleration"]}));c=f(d,"replaySpeed",{suffix:"x"});c.addItem("other...",function(){(new DialogBoxMorph(null,function(g){a.replaySpeed=Math.max(+g,0)||1})).withKey("replaySpeed").prompt("Replay Speed", a.replaySpeed.toString(),a.world(),null,d,!1,!0)});b.addMenu("Replay speed...",c);b.addMenu("Auto-condense gap size...",f(e,"maxGapDuration",{skip:Object.keys(e),refresh:!0}));b.rerender();return b}; ReplayControls.prototype.toggleCaptions=function(){var a=this.parentThatIsA(IDE_Morph);var b=(this.isShowingCaptions=!this.isShowingCaptions)?new Color(98,194,19):this.buttonColor;a.showMessage(localize("captions "+(this.isShowingCaptions?"enabled":"disabled")),1);this.lastCaption&&(this.lastCaption.destroy(),this.lastCaption=null);this.captionsButton.color=b;this.captionsButton.rerender();this.captionsButton.changed()}; ReplayControls.prototype.jumpToBeginning=function(){this.slider.button.setLeft(this.getSliderLeftFromValue(this.slider.start));this.slider.updateValue()};ReplayControls.prototype.jumpToEnd=function(){this.slider.button.setLeft(this.getSliderLeftFromValue(this.slider.stop));this.slider.updateValue()};ReplayControls.prototype.stepForward=function(){this.pause();this.playNext()};ReplayControls.prototype.stepBackward=function(){this.pause();this.playNext(-1)}; @@ -1938,7 +1862,7 @@ this.toolbox=new BoxMorph;this.toolbox.color=SpriteMorph.prototype.paletteColor. this.addButton("ok","OK");this.addButton("cancel","Cancel");this.refreshToolButtons();this.fixLayout()}; PaintEditorMorph.prototype.buildToolbox=function(){var a={brush:"Paintbrush tool\n(free draw)",rectangle:"Stroked Rectangle\n(shift: square)",circle:"Stroked Ellipse\n(shift: circle)",eraser:"Eraser tool",crosshairs:"Set the rotation center",line:"Line tool\n(shift: vertical/horizontal)",rectangleSolid:"Filled Rectangle\n(shift: square)",circleSolid:"Filled Ellipse\n(shift: circle)",paintbucket:"Fill a region",pipette:"Pipette tool\n(pick a color anywhere)"},b=this,c=this.toolbox.left(),d=this.toolbox.top(), e=0,f=0;Object.keys(a).forEach(function(g){var h=b.toolButton(g,a[g]);h.setPosition(new Point(c+e,d+f));e+=h.width()+2;"crosshairs"===g&&(e=0,f+=h.height()+2,b.paper.drawcrosshair());b.toolbox[g]=h;b.toolbox.add(h)});this.toolbox.bounds=this.toolbox.fullBounds().expandBy(10)}; -PaintEditorMorph.prototype.buildEdits=function(){var a=this,b=this.paper;this.edits.add(this.pushButton("undo",function(){b.undo()}));this.edits.add(this.pushButton("clear",function(){b.clearCanvas()}));this.edits.add(this.pushButton("Vector",function(){0{setTimeout(()=>{a.switchToVector()})}):a.switchToVector()}));this.edits.fixLayout()}; PaintEditorMorph.prototype.buildScaleBox=function(){var a=this.paper;this.scaleBox.add(this.pushButton(new SymbolMorph("grow",18),function(){a.scale(.05,.05)},"grow"));this.scaleBox.add(this.pushButton(new SymbolMorph("shrink",18),function(){a.scale(-.05,-.05)},"shrink"));this.scaleBox.add(this.pushButton(new SymbolMorph("flipHorizontal",18),function(){a.scale(-2,0)},"flip horizontal"));this.scaleBox.add(this.pushButton(new SymbolMorph("flipVertical",18),function(){a.scale(0,-2)},"flip vertical")); this.scaleBox.fixLayout()}; PaintEditorMorph.prototype.openIn=function(a,b,c,d,e){var f=this;this.oldim=b;this.callback=d||nop;this.ide=e;this.processKeyUp=function(){f.shift=!1;f.propertiesControls.constrain.refresh()};this.processKeyDown=function(){f.shift=16===f.world().currentKey;f.propertiesControls.constrain.refresh()};this.oldim&&(this.paper.automaticCrosshairs=isNil(c),this.paper.centermerge(this.oldim,this.paper.paper),this.paper.rotationCenter=(c||new Point(0,0)).add(new Point((this.paper.paper.width-this.oldim.width)/ @@ -1977,30 +1901,28 @@ PaintCanvasMorph.prototype.drawNew=function(){var a=newCanvas(this.extent(),!0,t PaintCanvasMorph.prototype.drawFrame=function(){var a=this.cachedImage.getContext("2d");if(this.parent){this.color=this.parent.color.lighter(.75*this.contrast);var b=this.parent.color}else b=new Color(120,120,120);a.fillStyle=this.color.toString();this.cachedClr=b.toString();this.cachedClrBright=b.lighter(this.contrast).toString();this.cachedClrDark=b.darker(this.contrast).toString();this.drawRectBorder(a)};PaintCanvasMorph.prototype.drawRectBorder=InputFieldMorph.prototype.drawRectBorder; PaintCanvasMorph.prototype.edge=InputFieldMorph.prototype.edge;PaintCanvasMorph.prototype.fontSize=InputFieldMorph.prototype.fontSize;PaintCanvasMorph.prototype.typeInPadding=InputFieldMorph.prototype.typeInPadding;PaintCanvasMorph.prototype.contrast=InputFieldMorph.prototype.contrast;modules.cloud="2020-September-1";var SnapCloud=new Cloud(CLIENT_ID,SERVER_URL+"/api/"); function Cloud(a,b){this.clientId=a;this.password=this.username=this.roleId=null;this.url=b;this.api=this.route=this.limo=this.session=null}Cloud.prototype.clear=function(){this.api=this.route=this.limo=this.session=this.password=this.username=null};Cloud.prototype.hasProtocol=function(){return 0===this.url.toLowerCase().indexOf("http")};Cloud.prototype.setRoute=function(a){var b=0,c;for(c=0;cb?"0":"")+b}; -Cloud.prototype.getPublicProject=function(a){var b=this,c,d;return $jscomp.asyncExecutePromiseGeneratorProgram(function(e){c=utils.defer();d=new XMLHttpRequest;try{d.open("GET",(b.hasProtocol()?"":"http://")+b.url+"RawPublic?"+a,!0),d.setRequestHeader("Content-Type","application/x-www-form-urlencoded"),d.withCredentials=!0,d.onreadystatechange=function(){4===d.readyState&&(d.responseText?0===d.responseText.indexOf("ERROR")?c.reject(Error(d.responseText)):c.resolve(d.responseText):c.reject(Error(localize("could not connect to:")+ -b.url)))},d.send(null)}catch(f){c.reject(f)}return e.return(c.promise)})}; +Cloud.prototype.getPublicProject=async function(a){const b=utils.defer(),c=new XMLHttpRequest;try{c.open("GET",(this.hasProtocol()?"":"http://")+this.url+"RawPublic?"+a,!0),c.setRequestHeader("Content-Type","application/x-www-form-urlencoded"),c.withCredentials=!0,c.onreadystatechange=()=>{4===c.readyState&&(c.responseText?0===c.responseText.indexOf("ERROR")?b.reject(Error(c.responseText)):b.resolve(c.responseText):b.reject(Error(localize("could not connect to:")+this.url)))},c.send(null)}catch(d){b.reject(d)}return b.promise}; Cloud.prototype.resetPassword=function(a,b,c){var d=new XMLHttpRequest,e=this;try{d.open("GET",(this.hasProtocol()?"":"http://")+this.url+"ResetPW?Username="+encodeURIComponent(a),!0),d.setRequestHeader("Content-Type","application/x-www-form-urlencoded"),d.withCredentials=!0,d.onreadystatechange=function(){4===d.readyState&&(d.responseText?0===d.responseText.indexOf("ERROR")?c.call(this,d.responseText,"Reset Password"):b.call(null,d.responseText,"Reset Password"):c.call(null,e.url+"ResetPW",localize("could not connect to:")))}, d.send(null)}catch(f){c.call(this,f.toString(),"Snap!Cloud")}}; -Cloud.prototype.login=function(a,b,c,d){var e=this,f=utils.defer(),g=new XMLHttpRequest;c=JSON.stringify({projectId:this.projectId,__h:b,__u:a,remember:c,clientId:SnapCloud.clientId});this.setRoute(a);try{var h=(this.hasProtocol()?"":"http://")+this.url+"?SESSIONGLUE="+this.route;d&&(h+="&strategy="+d);g.open("POST",h,!0);g.setRequestHeader("Content-Type","application/json; charset=utf-8");g.setRequestHeader("SESSIONGLUE",this.route);g.withCredentials=!0;g.onreadystatechange=function(){var k;return $jscomp.asyncExecutePromiseGeneratorProgram(function(l){if(1== -l.nextAddress)return 4!==g.readyState?l.jumpTo(0):200!==g.status?403===g.status?l.return(f.reject(Error(localize(g.responseText||"wrong username or password")))):l.return(f.reject(Error(localize("could not connect to cloud.")))):l.yield(e.getUserData(),4);k=l.yieldResult;e.username=k.username;e.credentials={username:a,password:b,strategy:d};return l.return(f.resolve(k))})};g.send(c)}catch(k){f.reject(k)}return f.promise}; +Cloud.prototype.login=function(a,b,c,d){const e=utils.defer();var f=new XMLHttpRequest;c=JSON.stringify({projectId:this.projectId,__h:b,__u:a,remember:c,clientId:SnapCloud.clientId});this.setRoute(a);try{let g=(this.hasProtocol()?"":"http://")+this.url+"?SESSIONGLUE="+this.route;d&&(g+=`&strategy=${d}`);f.open("POST",g,!0);f.setRequestHeader("Content-Type","application/json; charset=utf-8");f.setRequestHeader("SESSIONGLUE",this.route);f.withCredentials=!0;f.onreadystatechange=async()=>{if(4===f.readyState){if(200=== +f.status){const h=await this.getUserData();this.username=h.username;this.credentials={username:a,password:b,strategy:d};return e.resolve(h)}return 403===f.status?e.reject(Error(localize(f.responseText||"wrong username or password"))):e.reject(Error(localize("could not connect to cloud.")))}};f.send(c)}catch(g){e.reject(g)}return e.promise}; Cloud.prototype.getProjectList=function(a,b){var c=this;this.reconnect(function(){c.callService("getProjectList",function(d,e){a.call(null,d,e);c.disconnect()},b)},b)};Cloud.prototype.getSharedProjectList=function(a,b){var c=this;this.reconnect(function(){c.callService("getSharedProjectList",function(d,e){a.call(null,d,e);c.disconnect()},b)},b)}; Cloud.prototype.changePassword=function(a,b,c,d){var e=this;this.reconnect(function(){e.callService("changePassword",function(f,g){c.call(null,f,g);e.disconnect()},d,[hex_sha512(a),hex_sha512(b)])},d)}; Cloud.prototype.callURL=function(a,b,c){var d=new XMLHttpRequest,e=this;try{var f=a+"&SESSIONGLUE="+this.route+"&_Limo="+this.limo;d.open("GET",f,!0);d.withCredentials=!0;d.setRequestHeader("Content-Type","application/x-www-form-urlencoded");d.setRequestHeader("MioCracker",this.session);d.setRequestHeader("SESSIONGLUE",this.route);d.onreadystatechange=function(){if(4===d.readyState)if(d.responseText){var g=e.parseResponse(d);b.call(null,g,a)}else c.call(null,a,"no response from:")};d.send(null)}catch(g){c.call(this, g.toString(),a)}};Cloud.prototype.supportsService=function(a){return!!this.api[a]};Cloud.prototype.parseAPI=function(a){var b={};a.split(" ").forEach(function(c){var d={},e;c.split("&").forEach(function(f){var g=f.split("=");f=decodeURIComponent(g[0]).toLowerCase();g=decodeURIComponent(g[1]);if("service"===f)b[g]=d;else if("parameters"===f){if(e=g.split(","),1!==e.length||e[0])d.parameters=e}else d[f]=g})});return b}; Cloud.prototype.parseResponse=function(a){var b=a.responseText;return-1{this.callService("getProjectByName",d=>{d=d[0];this.setLocalState(d.ProjectID,d.RoleID);c.resolve(d)},c.reject,[a,b])},c.reject);return c.promise}; +Cloud.prototype.getCollaboratorList=function(a,b){var c=this;this.reconnect(function(){c.callService("getCollaborators",a,b,[c.projectId])},b)};Cloud.prototype.deleteRole=function(a,b,c){var d=this;this.reconnect(function(){d.callService("deleteRole",b,c,[a,d.projectId])},c)};Cloud.prototype.evictUser=function(a,b,c){var d=this;this.reconnect(function(){d.callService("evictUser",b,c,[a,d.projectId])},c)}; Cloud.prototype.saveProject=function(a,b,c,d,e){var f=this,g=a.sockets.getSerializedProject();f.reconnect(function(){f.callService("saveProject",function(h,k){f.setLocalState(h.projectId,h.roleId);b.call(null,h,k)},c,[f.roleId,a.projectName,e||a.room.name,SnapCloud.projectId,a.room.ownerId,!0===d,g.SourceCode,g.Media])},c)}; Cloud.prototype.callService=function(a,b,c,d){var e=new XMLHttpRequest,f=this.api[a],g=this;if(this.api)if(f){if(d&&0e.status||399{this.callService("logout",a,b,[this.clientId]);this.clear()},b)}; Cloud.prototype.signup=function(a,b,c,d,e){var f=new XMLHttpRequest,g=this;a="Username="+encodeURIComponent(a)+"&Email="+encodeURIComponent(c)+"&Password="+encodeURIComponent(hex_sha512(b));try{f.open("POST",(this.hasProtocol()?"":"http://")+this.url+"SignUp",!0),f.setRequestHeader("Content-Type","application/x-www-form-urlencoded"),f.withCredentials=!0,f.onreadystatechange=function(){4===f.readyState&&(f.responseText?0===f.responseText.indexOf("ERROR")?e.call(this,f.responseText,"Signup"):d.call(null, f.responseText,"Signup"):e.call(null,g.url+"SignUp",localize("could not connect to:")))},f.send(a)}catch(h){e.call(this,h.toString(),"NetsBlox Cloud")}};Cloud.prototype.isProjectActive=function(a,b,c){var d=this;this.reconnect(function(){d.callService("isProjectActive",function(e){return b(e.active)},c,[d.clientId,a])},c)}; Cloud.prototype.hasConflictingStoredProject=function(a,b,c){var d=this;this.reconnect(function(){d.callService("hasConflictingStoredProject",function(e){return b("true"===e[0].hasConflicting)},c,[d.projectId,a])},c)};Cloud.prototype.saveProjectCopy=function(a,b){var c=this;this.reconnect(function(){c.callService("saveProjectCopy",function(d,e){c.setLocalState(d.projectId,c.roleId);a.call(null,d,e);c.disconnect()},b,[c.clientId,c.projectId])},b)}; @@ -2011,10 +1933,8 @@ Cloud.prototype.getClientState=function(){return{username:this.username,clientId Cloud.prototype.setClientState=function(a,b,c){var d=this;return(this.newProjectRequest||Promise.resolve()).then(function(){return d.request("/api/setClientState",{__u:d.username,__h:d.password,clientId:d.clientId,socketId:d.clientId,projectId:d.projectId,roleId:d.roleId,roomName:a,roleName:b,actionId:c})}).then(function(e){d.setLocalState(e.projectId,e.roleId);d.api||(d.api=e.api);return e}).catch(function(e){var f="Could not connect to "+d.url;throw Error(e.responseText||f);})}; Cloud.prototype.setProjectName=function(a){var b=this;return(this.newProjectRequest||Promise.resolve()).then(function(){return b.request("/api/setProjectName",{projectId:b.projectId,name:a})}).then(function(c){return c}).catch(function(c){var d="Could not connect to "+b.url;throw Error(c.responseText||d);})}; Cloud.prototype.importProject=function(a,b,c){var d=this;return this.request("/api/importProject",{projectId:this.projectId,clientId:this.clientId,name:a,role:b,roles:c}).then(function(e){d.setLocalState(e.projectId,e.roleId);return e.state}).catch(function(e){d.resetLocalState();throw Error(e.responseText);})};Cloud.prototype.getEntireProject=function(a,b,c){var d=this;this.reconnect(function(){d.callService("getEntireProject",function(e){b(e);d.disconnect()},c,[a])},c)}; -Cloud.prototype.linkAccount=function(a,b,c){var d=this;return $jscomp.asyncExecutePromiseGeneratorProgram(function(e){return e.yield(d.request("/api/linkAccount/"+c,{username:a,password:b}),0)})};Cloud.prototype.unlinkAccount=function(a){var b=this;return $jscomp.asyncExecutePromiseGeneratorProgram(function(c){return c.yield(b.request("/api/unlinkAccount",a),0)})}; -Cloud.prototype.exportProject=function(a){a=void 0===a?this.projectId:a;var b=this,c;return $jscomp.asyncExecutePromiseGeneratorProgram(function(d){return 1==d.nextAddress?d.yield(fetch("/api/v2/projects/"+a+"/latest?clientId="+b.clientId),2):3!=d.nextAddress?(c=d.yieldResult,d.yield(c.text(),3)):d.return(d.yieldResult)})}; -Cloud.prototype.exportRole=function(a,b){a=void 0===a?this.projectId:a;b=void 0===b?this.roleId:b;var c=this,d;return $jscomp.asyncExecutePromiseGeneratorProgram(function(e){return 1==e.nextAddress?e.yield(fetch("/api/v2/projects/"+a+"/"+b+"/latest?clientId="+c.clientId),2):3!=e.nextAddress?(d=e.yieldResult,e.yield(d.text(),3)):e.return(e.yieldResult)})};Cloud.prototype.message=function(a){alert(a)}; -var CloudError=function(a,b){b=Error.call(this,b);this.message=b.message;"stack"in b&&(this.stack=b.stack);this.label=a};$jscomp.inherits(CloudError,Error);modules.gui="2020-August-08";var SERVER_URL=SERVER_URL||window.location.origin,SERVER_ADDRESS=SERVER_URL.replace(/^.*\/\//,"");function ensureFullUrl(a){null===a.match(/^\w+:\/\//)&&(a="/"===a.substring(0,1)[0]?SERVER_URL+a:SERVER_URL+"/"+a);return a}IDE_Morph.prototype=new Morph;IDE_Morph.prototype.constructor=IDE_Morph;IDE_Morph.uber=Morph.prototype; +Cloud.prototype.linkAccount=async function(a,b,c){await this.request(`/api/linkAccount/${c}`,{username:a,password:b})};Cloud.prototype.unlinkAccount=async function(a){await this.request("/api/unlinkAccount",a)};Cloud.prototype.exportProject=async function(a=this.projectId){return await (await fetch(`/api/v2/projects/${a}/latest?clientId=${this.clientId}`)).text()};Cloud.prototype.exportRole=async function(a=this.projectId,b=this.roleId){return await (await fetch(`/api/v2/projects/${a}/${b}/latest?clientId=${this.clientId}`)).text()}; +Cloud.prototype.message=function(a){alert(a)};class CloudError extends Error{constructor(a,b){super(b);this.label=a}}modules.gui="2020-August-08";var SERVER_URL=SERVER_URL||window.location.origin,SERVER_ADDRESS=SERVER_URL.replace(/^.*\/\//,"");function ensureFullUrl(a){null===a.match(/^\w+:\/\//)&&(a="/"===a.substring(0,1)[0]?SERVER_URL+a:SERVER_URL+"/"+a);return a}IDE_Morph.prototype=new Morph;IDE_Morph.prototype.constructor=IDE_Morph;IDE_Morph.uber=Morph.prototype; IDE_Morph.prototype.setDefaultDesign=function(){MorphicPreferences.isFlat=!1;SpriteMorph.prototype.paletteColor=new Color(30,30,30);SpriteMorph.prototype.paletteTextColor=new Color(230,230,230);StageMorph.prototype.paletteTextColor=SpriteMorph.prototype.paletteTextColor;StageMorph.prototype.paletteColor=SpriteMorph.prototype.paletteColor;SpriteMorph.prototype.sliderColor=SpriteMorph.prototype.paletteColor.lighter(30);IDE_Morph.prototype.buttonContrast=30;IDE_Morph.prototype.backgroundColor=new Color(10, 10,10);IDE_Morph.prototype.frameColor=SpriteMorph.prototype.paletteColor;IDE_Morph.prototype.groupColor=SpriteMorph.prototype.paletteColor.lighter(5);IDE_Morph.prototype.sliderColor=SpriteMorph.prototype.sliderColor;IDE_Morph.prototype.buttonLabelColor=WHITE;IDE_Morph.prototype.tabColors=[IDE_Morph.prototype.groupColor.darker(50),IDE_Morph.prototype.groupColor.darker(25),IDE_Morph.prototype.groupColor];IDE_Morph.prototype.rotationStyleColors=IDE_Morph.prototype.tabColors;IDE_Morph.prototype.appModeColor= BLACK;IDE_Morph.prototype.scriptsPaneTexture=this.scriptsTexture();IDE_Morph.prototype.padding=1;SpriteIconMorph.prototype.labelColor=IDE_Morph.prototype.buttonLabelColor;CostumeIconMorph.prototype.labelColor=IDE_Morph.prototype.buttonLabelColor;SoundIconMorph.prototype.labelColor=IDE_Morph.prototype.buttonLabelColor;TurtleIconMorph.prototype.labelColor=IDE_Morph.prototype.buttonLabelColor;SyntaxElementMorph.prototype.contrast=65;ScriptsMorph.prototype.feedbackColor=WHITE}; @@ -2025,73 +1945,70 @@ IDE_Morph.prototype.scriptsTexture=function(){var a=newCanvas(new Point(100,100) IDE_Morph.prototype.init=function(a){MorphicPreferences.globalFontFamily="Helvetica, Arial";this.userLanguage=null;this.projectsInURLs=!1;this.allowMsgsWhileCollaborating=null;this.applySavedSettings();this.cloud=SnapCloud;this.cloudMsg=null;this.source="local";this.serializer=new SnapSerializer;this.globalVariables=new VariableFrame;this.currentSprite=new SpriteMorph(this.globalVariables);this.sprites=new List([this.currentSprite]);this.currentCategory="motion";this.currentTab="scripts";this.projectNotes= this.projectName="";this.embedOverlay=this.embedPlayButton=this.corral=this.corralBar=this.stageHandle=this.stage=this.spriteEditor=this.spriteBar=this.paletteHandle=this.palette=this.categories=this.controlBar=this.logo=null;this.isEmbedMode=!1;this.isAutoFill=void 0===a?!0:a;this.isReplayMode=this.isAppMode=!1;this.preReplayUndoState=null;this.isSmallStage=!1;this.filePicker=null;this.hasChangedMedia=!1;this.isAnimating=!0;this.paletteWidth=200;this.stageRatio=1;this.loadNewProject=this.wasSingleStepping= !1;this.shield=null;this.savingPreferences=!0;IDE_Morph.uber.init.call(this);this.color=this.backgroundColor;this.activeEditor=this;this.extensions=NetsBloxExtensions;this.events=new Events;this.hiddenCategories=[]}; -IDE_Morph.prototype.openIn=function(a){var b;this.projectName="myRole";localStorage&&(b=localStorage["-snap-user"])&&(b=SnapCloud.parseSnapResponse(b)[0])&&(SnapCloud.username=b.username||null,SnapCloud.password=b.password||null,SnapCloud.username&&(this.source="cloud"));this.buildPanes();SnapActions.configure(this);SnapActions.disableCollaboration();SnapUndo.reset();a.add(this);a.userMenu=this.userMenu;this.cloud.message=function(c){var d=new MenuMorph(null,c);d.popUpCenteredInWorld(a);var e=setInterval(function(){d.destroy(); -clearInterval(e)},2E3)};a.reactToDropOf=function(c){c instanceof DialogBoxMorph||c instanceof MenuMorph||(a.hand.grabOrigin?c.slideBackTo(a.hand.grabOrigin):a.hand.grab(c))};this.reactToWorldResize(a.bounds);if(this.userLanguage)this.loadNewProject=!0,this.setLanguage(this.userLanguage,this.onOpen);else this.onOpen();this.extensions.initialize(this);this.initializeEmbeddedAPI();window.dispatchEvent(new CustomEvent("ideLoaded"))}; +IDE_Morph.prototype.openIn=function(a){var b;this.projectName="myRole";localStorage&&(b=localStorage["-snap-user"])&&(b=SnapCloud.parseSnapResponse(b)[0])&&(SnapCloud.username=b.username||null,SnapCloud.password=b.password||null,SnapCloud.username&&(this.source="cloud"));this.buildPanes();SnapActions.configure(this);SnapActions.disableCollaboration();SnapUndo.reset();a.add(this);a.userMenu=this.userMenu;this.cloud.message=c=>{var d=new MenuMorph(null,c);d.popUpCenteredInWorld(a);var e=setInterval(()=> +{d.destroy();clearInterval(e)},2E3)};a.reactToDropOf=c=>{c instanceof DialogBoxMorph||c instanceof MenuMorph||(a.hand.grabOrigin?c.slideBackTo(a.hand.grabOrigin):a.hand.grab(c))};this.reactToWorldResize(a.bounds);if(this.userLanguage)this.loadNewProject=!0,this.setLanguage(this.userLanguage,this.onOpen);else this.onOpen();this.extensions.initialize(this);this.initializeEmbeddedAPI();window.dispatchEvent(new CustomEvent("ideLoaded"))}; IDE_Morph.prototype.onOpen=function(){var a=this,b=this.sockets.onConnect,c=!1;if(-1"===g.substr(0,8)?z.yield(SnapActions.openProject(g),42):z.yield(SnapActions.openProject(b(g)),42)}if("#present:"===a.hash.substr(0,9)||"present"===h.action)return d.shield=new Morph,d.shield.color=d.color,d.shield.setExtent(d.parent.extent()),d.parent.add(d.shield),e.showMessage("Fetching project\nfrom the cloud..."),"#present:"===a.hash.substr(0,9)&&(h=SnapCloud.parseDict(a.hash.substr(9))), -z.setCatchFinallyBlocks(37),z.yield(SnapCloud.getPublicProject(SnapCloud.encodeDict(h)),39);if("#cloud:"===a.hash.substr(0,7))return d.shield=new Morph,d.shield.alpha=0,d.shield.setExtent(d.parent.extent()),d.parent.add(d.shield),e.showMessage("Fetching project\nfrom the cloud..."),h=SnapCloud.parseDict(a.hash.substr(7)),h.Username=h.Username.toLowerCase(),z.setCatchFinallyBlocks(33),z.yield(SnapCloud.getPublicProject(SnapCloud.encodeDict(h)),35);if("#dl:"===a.hash.substr(0,4))return A=e.showMessage("Fetching project\nfrom the cloud..."), -h=SnapCloud.parseDict(a.hash.substr(4)),h.Username=h.Username.toLowerCase(),z.setCatchFinallyBlocks(30),z.yield(SnapCloud.getPublicProject(SnapCloud.encodeDict(h)),32);if("#lang:"===a.hash.substr(0,6)){f=a.hash.substr(6);d.setLanguage(f);d.loadNewProject=!0;z.jumpTo(7);break}if("#signup"===a.hash.substr(0,7)){d.createCloudAccount();z.jumpTo(7);break}if("#collaborate"===a.hash.substr(0,12)){p=a.hash.substr(13);SnapActions.enableCollaboration();SnapActions.joinSession(p,d.cloudError());z.jumpTo(7); -break}if("#example:"===a.hash.substr(0,9)||"example"===h.action)return w=h?h.ProjectName:a.hash.substr(9),d.shield=new Morph,d.shield.alpha=0,d.shield.setExtent(d.parent.extent()),d.parent.add(d.shield),y=d.getURL(e.resourceURL("Examples",w)),x=e.showMessage("Opening "+w+" example..."),z.yield(d.droppedText(y),29);if("#private:"===a.hash.substr(0,9)||"private"===h.action){r=h?h.ProjectName:a.hash.substr(9);q=null!==SnapCloud.username;if(!q)return e.showMessage("You are not logged in. Cannot open "+ -r),z.return();t=e.showMessage("Opening "+r+" example...");z.setCatchFinallyBlocks(25);return z.yield(SnapCloud.getProjectByName(SnapCloud.username,h.ProjectName),27)}if("#signup"===a.hash.substr(0,7)||"signup"===h.action){d.createCloudAccount();z.jumpTo(7);break}return z.yield(e.newProject(),7);case 27:return u=z.yieldResult,z.yield(e.rawLoadCloudProject(u),28);case 28:c(h);z.leaveTryBlock(26);break;case 25:v=z.enterCatchBlock(),d.cloudError()(v.message);case 26:t.destroy();z.jumpTo(7);break;case 29:e.hasChangedMedia= -!0;d.shield.destroy();d.shield=null;x.destroy();c(h);z.jumpTo(7);break;case 32:B=z.yieldResult;C=new Blob([B],{type:"text/xml"});D=URL.createObjectURL(C);E=document.createElement("a");E.href=D;E.download=h.ProjectName+".xml";document.body.appendChild(E);E.dispatchEvent(new MouseEvent("click",{bubbles:!0,cancelable:!0,view:window}));document.body.removeChild(E);URL.revokeObjectURL(D);A.destroy();z.leaveTryBlock(7);break;case 30:L=z.enterCatchBlock();d.cloudError()(L.message);z.jumpTo(7);break;case 35:return I= -z.yieldResult,F=d.showMessage(localize("Opening project...")),z.yield(SnapActions.openProject(I),36);case 36:d.hasChangedMedia=!0;d.shield.destroy();d.shield=null;F.destroy();d.toggleAppMode(!1);z.leaveTryBlock(7);break;case 33:G=z.enterCatchBlock();d.cloudError()(G.message);z.jumpTo(7);break;case 39:return O=z.yieldResult,P=e.showMessage("Opening project..."),z.yield(e.droppedText(O),40);case 40:e.hasChangedMedia=!0;e.shield.destroy();e.shield=null;P.destroy();c(h);z.leaveTryBlock(7);break;case 37:R= -z.enterCatchBlock();d.cloudError()(R.message);z.jumpTo(7);break;case 42:d.toggleAppMode(!0);d.runScripts();z.jumpTo(7);break;case 7:if(d.world().keyboardFocus=d.stage,d.warnAboutIE(),h.setVariable)if(H=$jscomp.makeIterator(h.setVariable.split("=")),Q=H.next().value,N=H.next().value,K=d.globalVariables.allNames().includes(Q))d.globalVariables.setVar(Q,N),z.jumpTo(0);else return z.yield(d.droppedText(N,Q,"text"),0);else z.jumpTo(0)}})}; +IDE_Morph.prototype.interpretUrlAnchors=async function(a){function b(h){try{return utils.getUrlSync(h)}catch(k){return d.showMessage("unable to retrieve project"),""}}function c(h){h.embedMode&&d.setEmbedMode();h.editMode?d.toggleAppMode(!1):d.toggleAppMode(!0);h.noRun||d.runScripts();h.hideControls&&(d.controlBar.hide(),window.onbeforeunload=nop);h.noExitWarning&&(window.onbeforeunload=nop);h.lang&&d.setLanguage(h.lang,null,!0);d.isEmbedMode||d.world().worldCanvas.focus()}var d=this;a=a||location; +var e={};-1this.loadExtension(k)))}catch(h){this.inform("Unable to load extensions","The following error occurred while trying to load extensions:\n\n"+h.message+"\n\nPerhaps the URL is malformed?")}if("#open:"===a.hash.substr(0,6)){var f=a.hash.substr(6);if("%"===f.charAt(0)||-1"===f.substr(0,8)?await SnapActions.openProject(f):await SnapActions.openProject(b(f));this.toggleAppMode(!0);this.runScripts()}else if("#present:"=== +a.hash.substr(0,9)||"present"===e.action){this.shield=new Morph;this.shield.color=this.color;this.shield.setExtent(this.parent.extent());this.parent.add(this.shield);d.showMessage("Fetching project\nfrom the cloud...");"#present:"===a.hash.substr(0,9)&&(e=SnapCloud.parseDict(a.hash.substr(9)));try{const h=await SnapCloud.getPublicProject(SnapCloud.encodeDict(e)),k=d.showMessage("Opening project...");await d.droppedText(h);d.hasChangedMedia=!0;d.shield.destroy();d.shield=null;k.destroy();c(e)}catch(h){this.cloudError()(h.message)}}else if("#cloud:"=== +a.hash.substr(0,7)){this.shield=new Morph;this.shield.alpha=0;this.shield.setExtent(this.parent.extent());this.parent.add(this.shield);d.showMessage("Fetching project\nfrom the cloud...");e=SnapCloud.parseDict(a.hash.substr(7));e.Username=e.Username.toLowerCase();try{const h=await SnapCloud.getPublicProject(SnapCloud.encodeDict(e)),k=this.showMessage(localize("Opening project..."));await SnapActions.openProject(h);this.hasChangedMedia=!0;this.shield.destroy();this.shield=null;k.destroy();this.toggleAppMode(!1)}catch(h){this.cloudError()(h.message)}}else if("#dl:"=== +a.hash.substr(0,4)){g=d.showMessage("Fetching project\nfrom the cloud...");e=SnapCloud.parseDict(a.hash.substr(4));e.Username=e.Username.toLowerCase();try{const h=await SnapCloud.getPublicProject(SnapCloud.encodeDict(e)),k=new Blob([h],{type:"text/xml"}),l=URL.createObjectURL(k),m=document.createElement("a");m.href=l;m.download=e.ProjectName+".xml";document.body.appendChild(m);m.dispatchEvent(new MouseEvent("click",{bubbles:!0,cancelable:!0,view:window}));document.body.removeChild(m);URL.revokeObjectURL(l); +g.destroy()}catch(h){this.cloudError()(h.message)}}else if("#lang:"===a.hash.substr(0,6))g=a.hash.substr(6),this.setLanguage(g),this.loadNewProject=!0;else if("#signup"===a.hash.substr(0,7))this.createCloudAccount();else if("#collaborate"===a.hash.substr(0,12))g=a.hash.substr(13),SnapActions.enableCollaboration(),SnapActions.joinSession(g,this.cloudError());else if("#example:"===a.hash.substr(0,9)||"example"===e.action)a=e?e.ProjectName:a.hash.substr(9),this.shield=new Morph,this.shield.alpha=0,this.shield.setExtent(this.parent.extent()), +this.parent.add(this.shield),g=this.getURL(d.resourceURL("Examples",a)),a=d.showMessage("Opening "+a+" example..."),await this.droppedText(g),d.hasChangedMedia=!0,this.shield.destroy(),this.shield=null,a.destroy(),c(e);else if("#private:"===a.hash.substr(0,9)||"private"===e.action){a=e?e.ProjectName:a.hash.substr(9);if(null===SnapCloud.username){d.showMessage("You are not logged in. Cannot open "+a);return}a=d.showMessage("Opening "+a+" example...");try{g=await SnapCloud.getProjectByName(SnapCloud.username, +e.ProjectName),await d.rawLoadCloudProject(g),c(e)}catch(h){this.cloudError()(h.message)}a.destroy()}else"#signup"===a.hash.substr(0,7)||"signup"===e.action?this.createCloudAccount():await d.newProject();this.world().keyboardFocus=this.stage;this.warnAboutIE();if(e.setVariable){const [h,k]=e.setVariable.split("=");this.globalVariables.allNames().includes(h)?this.globalVariables.setVar(h,k):await this.droppedText(k,h,"text")}}; IDE_Morph.prototype.buildPanes=function(){this.createLogo();this.createControlBar();this.createCategories();this.createPalette();this.createStage();this.createSpriteBar();this.createSpriteEditor();this.createCorralBar();this.createCorral();this.createReplayControls()}; IDE_Morph.prototype.createLogo=function(){var a=this;this.logo&&this.logo.destroy();this.logo=new Morph;this.logo.texture=LOGO_IMAGE;this.logo.render=function(b){var c=b.createLinearGradient(0,0,this.width(),0);c.addColorStop(0,"black");c.addColorStop(.5,a.frameColor.toString());b.fillStyle=MorphicPreferences.isFlat?a.frameColor.toString():c;b.fillRect(0,0,this.width(),this.height());this.cachedTexture?this.renderCachedTexture(b):this.texture&&this.renderTexture(this.texture,b)};this.logo.renderCachedTexture= function(b){b.drawImage(this.cachedTexture,5,Math.round((this.height()-this.cachedTexture.height)/2));this.changed()};this.logo.mouseClickLeft=function(){a.snapMenu()};this.logo.color=BLACK;this.logo.setExtent(new Point(200,28));this.add(this.logo)};IDE_Morph.prototype.mouseClickLeft=function(){this.setActiveEditor()};IDE_Morph.prototype.setActiveEditor=function(a){this.activeEditor!==a&&(this.activeEditor.onUnsetActive(),this.activeEditor=a||this,this.activeEditor.onSetActive())}; IDE_Morph.prototype.onSetActive=function(){this.isAppMode?this.spriteEditor.hide():"scripts"===this.currentTab?this.currentSprite.scripts.updateToolbar():this.spriteEditor.updateToolbar&&this.spriteEditor.updateToolbar()};IDE_Morph.prototype.onUnsetActive=function(){"scripts"===this.currentTab?this.currentSprite.scripts.hideToolbar():this.spriteEditor.hideToolbar&&this.spriteEditor.hideToolbar()}; IDE_Morph.prototype.getActiveScripts=function(){return this.activeEditor instanceof BlockEditorMorph?this.activeEditor.body.contents:this.currentSprite.scripts};IDE_Morph.prototype.getActiveEntity=function(){return this.activeEditor instanceof BlockEditorMorph?this.activeEditor.definition.id+"/scripts":this.currentSprite.id+"/"+this.currentTab}; -IDE_Morph.prototype.createControlBar=function(){var a=this,b,c=MorphicPreferences.isFlat?this.tabColors:[this.groupColor,this.frameColor.darker(50),this.frameColor.darker(50)],d=this;this.controlBar&&this.controlBar.destroy();this.controlBar=new Morph;this.controlBar.color=this.frameColor;this.controlBar.setHeight(this.logo.height());this.controlBar.mouseClickLeft=function(){this.world().fillPage()};this.add(this.controlBar);var e=new ToggleButtonMorph(null,this,"toggleStageSize",[new SymbolMorph("smallStage", -14),new SymbolMorph("normalStage",14)],function(){return a.isSmallStage});e.hasNeutralBackground=!0;e.corner=12;e.color=c[0];e.highlightColor=c[1];e.pressColor=c[0];e.labelMinExtent=new Point(36,18);e.padding=0;e.labelShadowOffset=new Point(-1,-1);e.labelShadowColor=c[1];e.labelColor=MorphicPreferences.isFlat?WHITE:this.buttonLabelColor;e.contrast=this.buttonContrast;e.fixLayout();e.refresh();var f=e;this.controlBar.add(f);this.controlBar.stageSizeButton=e;e=new ToggleButtonMorph(null,this,"toggleAppMode", -[new SymbolMorph("fullScreen",14),new SymbolMorph("normalScreen",14)],function(){return a.isAppMode});e.hasNeutralBackground=!0;e.corner=12;e.color=c[0];e.highlightColor=c[1];e.pressColor=c[0];e.labelMinExtent=new Point(36,18);e.padding=0;e.labelShadowOffset=new Point(-1,-1);e.labelShadowColor=c[1];e.labelColor=this.buttonLabelColor;e.contrast=this.buttonContrast;e.fixLayout();e.refresh();var g=e;this.controlBar.add(g);this.controlBar.appModeButton=g;e=new ToggleButtonMorph(null,this,"toggleSingleStepping", -[new SymbolMorph("footprints",16),new SymbolMorph("footprints",16)],function(){return Process.prototype.enableSingleStepping});e.corner=12;e.color=c[0];e.highlightColor=c[1];e.pressColor=new Color(153,255,213);e.labelMinExtent=new Point(36,18);e.padding=0;e.labelShadowOffset=new Point(-1,-1);e.labelShadowColor=c[1];e.labelColor=this.buttonLabelColor;e.contrast=this.buttonContrast;e.hint="Visible stepping";e.fixLayout();e.refresh();var h=e;this.controlBar.add(h);this.controlBar.steppingButton=h;e= -new ToggleButtonMorph(null,this,"stopAllScripts",[new SymbolMorph("octagon",14),new SymbolMorph("square",14)],function(){return a.stage?d.stage.enableCustomHatBlocks&&d.stage.threads.pauseCustomHatBlocks:!0});e.corner=12;e.color=c[0];e.highlightColor=c[1];e.pressColor=c[2];e.labelMinExtent=new Point(36,18);e.padding=0;e.labelShadowOffset=new Point(-1,-1);e.labelShadowColor=c[1];e.labelColor=new Color(MorphicPreferences.isFlat?128:200,0,0);e.contrast=this.buttonContrast;e.fixLayout();e.refresh();var k= -e;this.controlBar.add(k);this.controlBar.stopButton=k;e=new ToggleButtonMorph(null,this,"togglePauseResume",[new SymbolMorph("pause",12),new SymbolMorph("pointRight",14)],function(){return a.isPaused()});e.hasNeutralBackground=!0;e.corner=12;e.color=c[0];e.highlightColor=c[1];e.pressColor=c[0];e.labelMinExtent=new Point(36,18);e.padding=0;e.labelShadowOffset=new Point(-1,-1);e.labelShadowColor=c[1];e.labelColor=MorphicPreferences.isFlat?new Color(220,185,0):new Color(255,220,0);e.contrast=this.buttonContrast; -e.fixLayout();e.refresh();var l=e;this.controlBar.add(l);this.controlBar.pauseButton=l;e=new PushButtonMorph(this,"pressStart",new SymbolMorph("flag",14));e.corner=12;e.color=c[0];e.highlightColor=c[1];e.pressColor=c[2];e.labelMinExtent=new Point(36,18);e.padding=0;e.labelShadowOffset=new Point(-1,-1);e.labelShadowColor=c[1];e.labelColor=new Color(0,MorphicPreferences.isFlat?100:200,0);e.contrast=this.buttonContrast;e.fixLayout();var m=e;this.controlBar.add(m);this.controlBar.startButton=m;var n= -new SliderMorph(61,1,100*Process.prototype.flashTime+1,6,"horizontal");n.action=function(u){Process.prototype.flashTime=(u-1)/100;a.controlBar.refreshResumeSymbol()};n.color=new Color(153,255,213);n.alpha=.3;n.setExtent(new Point(50,14));this.controlBar.add(n);this.controlBar.steppingSlider=n;e=new PushButtonMorph(this,function(){var u=d.projectMenu(),v=d.controlBar.projectButton.bottomLeft(),w=d.world();u.popup(w,v)},new SymbolMorph("file",14));e.corner=12;e.color=c[0];e.highlightColor=c[1];e.pressColor= -c[2];e.labelMinExtent=new Point(36,18);e.padding=0;e.labelShadowOffset=new Point(-1,-1);e.labelShadowColor=c[1];e.labelColor=this.buttonLabelColor;e.contrast=this.buttonContrast;e.fixLayout();var p=e;this.controlBar.add(p);this.controlBar.projectButton=p;e=new PushButtonMorph(this,function(){var u=d.settingsMenu(),v=d.controlBar.settingsButton.bottomLeft();u.popup(d.world(),v)},new SymbolMorph("gears",14));e.corner=12;e.color=c[0];e.highlightColor=c[1];e.pressColor=c[2];e.labelMinExtent=new Point(36, -18);e.padding=0;e.labelShadowOffset=new Point(-1,-1);e.labelShadowColor=c[1];e.labelColor=this.buttonLabelColor;e.contrast=this.buttonContrast;e.fixLayout();var r=e;this.controlBar.add(r);this.controlBar.settingsButton=r;e=new PushButtonMorph(this,function(){var u=d.extensionsMenu(),v=d.controlBar.extensionsButton.bottomLeft();u.popup(d.world(),v)},new SymbolMorph("puzzlePiece",14));e.corner=12;e.color=c[0];e.highlightColor=c[1];e.pressColor=c[2];e.labelMinExtent=new Point(36,18);e.padding=0;e.labelShadowOffset= -new Point(-1,-1);e.labelShadowColor=c[1];e.labelColor=this.buttonLabelColor;e.contrast=this.buttonContrast;e.fixLayout();var q=e;this.controlBar.add(q);this.controlBar.extensionsButton=q;this.controlBar.extensionsButton.hide();e=new ToggleButtonMorph(null,this,function(){var u,v;return $jscomp.asyncExecutePromiseGeneratorProgram(function(w){if(1==w.nextAddress)return w.yield(a.cloudMenu(),2);u=w.yieldResult;v=a.controlBar.cloudButton.bottomLeft();u.popup(a.world(),v);w.jumpToEnd()})},[new SymbolMorph("cloudOutline", -11),new SymbolMorph("cloud",11)],function(){return!isNil(a.cloud.username)});e.hasNeutralBackground=!0;e.corner=12;e.color=c[0];e.highlightColor=c[1];e.pressColor=c[0];e.labelMinExtent=new Point(36,18);e.padding=0;e.labelShadowOffset=new Point(-1,-1);e.labelShadowColor=c[1];e.labelColor=this.buttonLabelColor;e.contrast=this.buttonContrast;e.fixLayout();var t=e;this.controlBar.add(t);this.controlBar.cloudButton=t;this.controlBar.fixLayout=function(){b=this.right()-5;[k,l,m].forEach(function(u){u.setCenter(d.controlBar.center()); -u.setRight(b);b-=u.width();b-=5});b=Math.min(m.left()-(15+2*f.width()),d.right()-StageMorph.prototype.dimensions.x*(d.isSmallStage?d.stageRatio:1));[f,g].forEach(function(u){b+=5;u.setCenter(d.controlBar.center());u.setLeft(b);b+=u.width()});n.setCenter(d.controlBar.center());n.setRight(f.left()-5);h.setCenter(d.controlBar.center());h.setRight(n.left()-5);q.setCenter(d.controlBar.center());q.setRight(h.left()-5);r.setCenter(d.controlBar.center());r.setLeft(this.left());t.setCenter(d.controlBar.center()); -t.setRight(r.left()-5);p.setCenter(d.controlBar.center());p.setRight(t.left()-5);this.refreshSlider();this.updateLabel()};this.controlBar.refreshSlider=function(){Process.prototype.enableSingleStepping&&!d.isAppMode?(n.fixLayout(),n.rerender(),n.show()):n.hide();this.refreshResumeSymbol()};this.controlBar.refreshResumeSymbol=function(){if(Process.prototype.enableSingleStepping&&.5=b.categories.children.length)){var f= -new MenuMorph(b);f.addItem("hide category",function(){this.hideCategory(c)},null,new Color(100,0,0));return f}};e.corner=8;e.padding=0;e.labelShadowOffset=new Point(-1,-1);e.labelShadowColor=d[1];e.labelColor=b.buttonLabelColor;MorphicPreferences.isFlat&&(e.labelPressColor=WHITE);e.fixLayout();e.refresh();b.categories.add(e);return e}var b=this;this.categories&&this.categories.destroy();contains(this.hiddenCategories,this.currentCategory)&&(this.currentCategory=SpriteMorph.prototype.categories.find(function(c){return!contains(["lists", -"other"],c)&&!contains(b.hiddenCategories,c)}),this.createPalette());this.categories=new Morph;this.categories.color=this.groupColor;this.categories.bounds.setWidth(this.paletteWidth);this.categories.userMenu=function(){if(!(16!==world.currentKey||0>=b.hiddenCategories.length)){var c=new MenuMorph(b);c.addItem("show hidden categories","showHiddenCategories",null,new Color(100,0,0));return c}};SpriteMorph.prototype.categories.forEach(function(c){contains(["lists","other"],c)||contains(b.hiddenCategories, -c)||a(c)});(function(){var c=b.categories.children[0].width(),d=b.categories.children[0].height(),e=Math.ceil(b.categories.children.length/2),f=(197-2*c)/3,g=b.categories.left(),h=b.categories.top(),k=0,l,m;b.categories.children.forEach(function(n){k+=1;l=Math.ceil(k/2);m=2-k%2;n.setPosition(new Point(g+(m*f+(m-1)*c),h+(2*l+(l-1)*d+3)))});b.categories.setHeight(2*(e+1)+e*d+6)})();this.add(this.categories)}; +IDE_Morph.prototype.createControlBar=function(){var a,b=MorphicPreferences.isFlat?this.tabColors:[this.groupColor,this.frameColor.darker(50),this.frameColor.darker(50)],c=this;this.controlBar&&this.controlBar.destroy();this.controlBar=new Morph;this.controlBar.color=this.frameColor;this.controlBar.setHeight(this.logo.height());this.controlBar.mouseClickLeft=function(){this.world().fillPage()};this.add(this.controlBar);var d=new ToggleButtonMorph(null,this,"toggleStageSize",[new SymbolMorph("smallStage", +14),new SymbolMorph("normalStage",14)],()=>this.isSmallStage);d.hasNeutralBackground=!0;d.corner=12;d.color=b[0];d.highlightColor=b[1];d.pressColor=b[0];d.labelMinExtent=new Point(36,18);d.padding=0;d.labelShadowOffset=new Point(-1,-1);d.labelShadowColor=b[1];d.labelColor=MorphicPreferences.isFlat?WHITE:this.buttonLabelColor;d.contrast=this.buttonContrast;d.fixLayout();d.refresh();var e=d;this.controlBar.add(e);this.controlBar.stageSizeButton=d;d=new ToggleButtonMorph(null,this,"toggleAppMode",[new SymbolMorph("fullScreen", +14),new SymbolMorph("normalScreen",14)],()=>this.isAppMode);d.hasNeutralBackground=!0;d.corner=12;d.color=b[0];d.highlightColor=b[1];d.pressColor=b[0];d.labelMinExtent=new Point(36,18);d.padding=0;d.labelShadowOffset=new Point(-1,-1);d.labelShadowColor=b[1];d.labelColor=this.buttonLabelColor;d.contrast=this.buttonContrast;d.fixLayout();d.refresh();var f=d;this.controlBar.add(f);this.controlBar.appModeButton=f;d=new ToggleButtonMorph(null,this,"toggleSingleStepping",[new SymbolMorph("footprints",16), +new SymbolMorph("footprints",16)],()=>Process.prototype.enableSingleStepping);d.corner=12;d.color=b[0];d.highlightColor=b[1];d.pressColor=new Color(153,255,213);d.labelMinExtent=new Point(36,18);d.padding=0;d.labelShadowOffset=new Point(-1,-1);d.labelShadowColor=b[1];d.labelColor=this.buttonLabelColor;d.contrast=this.buttonContrast;d.hint="Visible stepping";d.fixLayout();d.refresh();var g=d;this.controlBar.add(g);this.controlBar.steppingButton=g;d=new ToggleButtonMorph(null,this,"stopAllScripts", +[new SymbolMorph("octagon",14),new SymbolMorph("square",14)],()=>this.stage?c.stage.enableCustomHatBlocks&&c.stage.threads.pauseCustomHatBlocks:!0);d.corner=12;d.color=b[0];d.highlightColor=b[1];d.pressColor=b[2];d.labelMinExtent=new Point(36,18);d.padding=0;d.labelShadowOffset=new Point(-1,-1);d.labelShadowColor=b[1];d.labelColor=new Color(MorphicPreferences.isFlat?128:200,0,0);d.contrast=this.buttonContrast;d.fixLayout();d.refresh();var h=d;this.controlBar.add(h);this.controlBar.stopButton=h;d= +new ToggleButtonMorph(null,this,"togglePauseResume",[new SymbolMorph("pause",12),new SymbolMorph("pointRight",14)],()=>this.isPaused());d.hasNeutralBackground=!0;d.corner=12;d.color=b[0];d.highlightColor=b[1];d.pressColor=b[0];d.labelMinExtent=new Point(36,18);d.padding=0;d.labelShadowOffset=new Point(-1,-1);d.labelShadowColor=b[1];d.labelColor=MorphicPreferences.isFlat?new Color(220,185,0):new Color(255,220,0);d.contrast=this.buttonContrast;d.fixLayout();d.refresh();var k=d;this.controlBar.add(k); +this.controlBar.pauseButton=k;d=new PushButtonMorph(this,"pressStart",new SymbolMorph("flag",14));d.corner=12;d.color=b[0];d.highlightColor=b[1];d.pressColor=b[2];d.labelMinExtent=new Point(36,18);d.padding=0;d.labelShadowOffset=new Point(-1,-1);d.labelShadowColor=b[1];d.labelColor=new Color(0,MorphicPreferences.isFlat?100:200,0);d.contrast=this.buttonContrast;d.fixLayout();var l=d;this.controlBar.add(l);this.controlBar.startButton=l;var m=new SliderMorph(61,1,100*Process.prototype.flashTime+1,6, +"horizontal");m.action=t=>{Process.prototype.flashTime=(t-1)/100;this.controlBar.refreshResumeSymbol()};m.color=new Color(153,255,213);m.alpha=.3;m.setExtent(new Point(50,14));this.controlBar.add(m);this.controlBar.steppingSlider=m;d=new PushButtonMorph(this,function(){var t=c.projectMenu(),u=c.controlBar.projectButton.bottomLeft(),v=c.world();t.popup(v,u)},new SymbolMorph("file",14));d.corner=12;d.color=b[0];d.highlightColor=b[1];d.pressColor=b[2];d.labelMinExtent=new Point(36,18);d.padding=0;d.labelShadowOffset= +new Point(-1,-1);d.labelShadowColor=b[1];d.labelColor=this.buttonLabelColor;d.contrast=this.buttonContrast;d.fixLayout();var n=d;this.controlBar.add(n);this.controlBar.projectButton=n;d=new PushButtonMorph(this,function(){var t=c.settingsMenu(),u=c.controlBar.settingsButton.bottomLeft();t.popup(c.world(),u)},new SymbolMorph("gears",14));d.corner=12;d.color=b[0];d.highlightColor=b[1];d.pressColor=b[2];d.labelMinExtent=new Point(36,18);d.padding=0;d.labelShadowOffset=new Point(-1,-1);d.labelShadowColor= +b[1];d.labelColor=this.buttonLabelColor;d.contrast=this.buttonContrast;d.fixLayout();var p=d;this.controlBar.add(p);this.controlBar.settingsButton=p;d=new PushButtonMorph(this,function(){var t=c.extensionsMenu(),u=c.controlBar.extensionsButton.bottomLeft();t.popup(c.world(),u)},new SymbolMorph("puzzlePiece",14));d.corner=12;d.color=b[0];d.highlightColor=b[1];d.pressColor=b[2];d.labelMinExtent=new Point(36,18);d.padding=0;d.labelShadowOffset=new Point(-1,-1);d.labelShadowColor=b[1];d.labelColor=this.buttonLabelColor; +d.contrast=this.buttonContrast;d.fixLayout();const q=d;this.controlBar.add(q);this.controlBar.extensionsButton=q;this.controlBar.extensionsButton.hide();d=new ToggleButtonMorph(null,this,async()=>{var t=await this.cloudMenu(),u=this.controlBar.cloudButton.bottomLeft();t.popup(this.world(),u)},[new SymbolMorph("cloudOutline",11),new SymbolMorph("cloud",11)],()=>!isNil(this.cloud.username));d.hasNeutralBackground=!0;d.corner=12;d.color=b[0];d.highlightColor=b[1];d.pressColor=b[0];d.labelMinExtent=new Point(36, +18);d.padding=0;d.labelShadowOffset=new Point(-1,-1);d.labelShadowColor=b[1];d.labelColor=this.buttonLabelColor;d.contrast=this.buttonContrast;d.fixLayout();var r=d;this.controlBar.add(r);this.controlBar.cloudButton=r;this.controlBar.fixLayout=function(){a=this.right()-5;[h,k,l].forEach(t=>{t.setCenter(c.controlBar.center());t.setRight(a);a-=t.width();a-=5});a=Math.min(l.left()-(15+2*e.width()),c.right()-StageMorph.prototype.dimensions.x*(c.isSmallStage?c.stageRatio:1));[e,f].forEach(t=>{a+=5;t.setCenter(c.controlBar.center()); +t.setLeft(a);a+=t.width()});m.setCenter(c.controlBar.center());m.setRight(e.left()-5);g.setCenter(c.controlBar.center());g.setRight(m.left()-5);q.setCenter(c.controlBar.center());q.setRight(g.left()-5);p.setCenter(c.controlBar.center());p.setLeft(this.left());r.setCenter(c.controlBar.center());r.setRight(p.left()-5);n.setCenter(c.controlBar.center());n.setRight(r.left()-5);this.refreshSlider();this.updateLabel()};this.controlBar.refreshSlider=function(){Process.prototype.enableSingleStepping&&!c.isAppMode? +(m.fixLayout(),m.rerender(),m.show()):m.hide();this.refreshResumeSymbol()};this.controlBar.refreshResumeSymbol=function(){if(Process.prototype.enableSingleStepping&&.5{b.currentCategory=c;b.categories.children.forEach(f=>f.refresh());b.refreshPalette(!0)},c[0].toUpperCase().concat(c.slice(1)),()=>b.currentCategory===c,null,null,75,!0);e.userMenu=function(){if(!(16!==world.currentKey||1>=b.categories.children.length)){var f=new MenuMorph(b);f.addItem("hide category", +function(){this.hideCategory(c)},null,new Color(100,0,0));return f}};e.corner=8;e.padding=0;e.labelShadowOffset=new Point(-1,-1);e.labelShadowColor=d[1];e.labelColor=b.buttonLabelColor;MorphicPreferences.isFlat&&(e.labelPressColor=WHITE);e.fixLayout();e.refresh();b.categories.add(e);return e}var b=this;this.categories&&this.categories.destroy();contains(this.hiddenCategories,this.currentCategory)&&(this.currentCategory=SpriteMorph.prototype.categories.find(function(c){return!contains(["lists","other"], +c)&&!contains(b.hiddenCategories,c)}),this.createPalette());this.categories=new Morph;this.categories.color=this.groupColor;this.categories.bounds.setWidth(this.paletteWidth);this.categories.userMenu=function(){if(!(16!==world.currentKey||0>=b.hiddenCategories.length)){var c=new MenuMorph(b);c.addItem("show hidden categories","showHiddenCategories",null,new Color(100,0,0));return c}};SpriteMorph.prototype.categories.forEach(c=>{contains(["lists","other"],c)||contains(b.hiddenCategories,c)||a(c)}); +(function(){var c=b.categories.children[0].width(),d=b.categories.children[0].height(),e=Math.ceil(b.categories.children.length/2),f=(197-2*c)/3,g=b.categories.left(),h=b.categories.top(),k=0,l,m;b.categories.children.forEach(n=>{k+=1;l=Math.ceil(k/2);m=2-k%2;n.setPosition(new Point(g+(m*f+(m-1)*c),h+(2*l+(l-1)*d+3)))});b.categories.setHeight(2*(e+1)+e*d+6)})();this.add(this.categories)}; IDE_Morph.prototype.hideCategory=function(a){this.hiddenCategories.push(a);this.createCategories();this.createPaletteHandle();this.fixLayout()};IDE_Morph.prototype.showHiddenCategories=function(){this.hiddenCategories.length=0;this.createCategories();this.createPaletteHandle();this.fixLayout()}; -IDE_Morph.prototype.createPalette=function(a){var b=this;this.palette&&this.palette.destroy();this.palette=a?new ScrollFrameMorph(null,null,this.currentSprite.sliderColor):this.currentSprite.palette(this.currentCategory);this.palette.isDraggable=!1;this.palette.acceptsDrops=!0;this.palette.enableAutoScrolling=!1;this.palette.contents.acceptsDrops=!1;this.palette.reactToDropOf=function(c,d){c instanceof DialogBoxMorph?b.world().add(c):c instanceof SpriteMorph?SnapActions.removeSprite(c):c instanceof -SpriteIconMorph?(c.destroy(),SnapActions.removeSprite(c.object)):c instanceof CostumeIconMorph?(SnapActions.removeCostume(c.object),c.perish()):c instanceof SoundIconMorph?(SnapActions.removeSound(c.object),c.destroy()):c instanceof BlockMorph&&(b.stage.threads.stopAllForBlock(c),c.id&&SnapActions.removeBlock(c),c.perish())};this.palette.contents.reactToDropOf=function(c){c instanceof BlockMorph&&c.destroy()};this.palette.setWidth(this.logo.width());this.add(this.palette);this.isAppMode&&this.palette.hide(); -return this.palette};IDE_Morph.prototype.createPaletteHandle=function(){this.paletteHandle&&this.paletteHandle.destroy();this.paletteHandle=new PaletteHandleMorph(this.categories);this.add(this.paletteHandle);this.isAppMode&&this.paletteHandle.hide()}; +IDE_Morph.prototype.createPalette=function(a){this.palette&&this.palette.destroy();this.palette=a?new ScrollFrameMorph(null,null,this.currentSprite.sliderColor):this.currentSprite.palette(this.currentCategory);this.palette.isDraggable=!1;this.palette.acceptsDrops=!0;this.palette.enableAutoScrolling=!1;this.palette.contents.acceptsDrops=!1;this.palette.reactToDropOf=(b,c)=>{b instanceof DialogBoxMorph?this.world().add(b):b instanceof SpriteMorph?SnapActions.removeSprite(b):b instanceof SpriteIconMorph? +(b.destroy(),SnapActions.removeSprite(b.object)):b instanceof CostumeIconMorph?(SnapActions.removeCostume(b.object),b.perish()):b instanceof SoundIconMorph?(SnapActions.removeSound(b.object),b.destroy()):b instanceof BlockMorph&&(this.stage.threads.stopAllForBlock(b),b.id&&SnapActions.removeBlock(b),b.perish())};this.palette.contents.reactToDropOf=b=>{b instanceof BlockMorph&&b.destroy()};this.palette.setWidth(this.logo.width());this.add(this.palette);this.isAppMode&&this.palette.hide();return this.palette}; +IDE_Morph.prototype.createPaletteHandle=function(){this.paletteHandle&&this.paletteHandle.destroy();this.paletteHandle=new PaletteHandleMorph(this.categories);this.add(this.paletteHandle);this.isAppMode&&this.paletteHandle.hide()}; IDE_Morph.prototype.createStage=function(){this.stage&&this.stage.destroy();StageMorph.prototype.frameRate=0;this.stage=new StageMorph(this.globalVariables);this.stage.setExtent(this.stage.dimensions);this.currentSprite instanceof SpriteMorph&&(this.currentSprite.setPosition(this.stage.center().subtract(this.currentSprite.extent().divideBy(2))),this.stage.add(this.currentSprite));this.add(this.stage)}; IDE_Morph.prototype.createStageHandle=function(){this.stageHandle&&this.stageHandle.destroy();this.stageHandle=new StageHandleMorph(this.stage);this.add(this.stageHandle)}; -IDE_Morph.prototype.createSpriteBar=function(){function a(p){var r=k.rotationStyleColors;var q=new ToggleButtonMorph(r,k,function(){k.currentSprite instanceof SpriteMorph&&SnapActions.setRotationStyle(k.currentSprite,p)},g[p],function(){return k.currentSprite instanceof SpriteMorph&&k.currentSprite.rotationStyle===p},null,localize(h[p]));q.corner=8;q.labelMinExtent=new Point(11,11);q.padding=0;q.labelShadowOffset=new Point(-1,-1);q.labelShadowColor=r[1];q.labelColor=k.buttonLabelColor;q.fixLayout(); -q.refresh();c.push(q);q.setPosition(k.spriteBar.position().add(new Point(2,4)));q.setTop(q.top()+(c.length-1)*(q.height()+2));k.spriteBar.add(q);k.currentSprite instanceof StageMorph&&q.hide();return q}var b=this,c=[],d=new Point(45,45),e=this.tabColors,f=new AlignmentMorph("row",-30),g=[new SymbolMorph("arrowRightThin",10),new SymbolMorph("turnAround",10),new SymbolMorph("arrowLeftRightThin",10)],h=["don't rotate","can rotate","only face left/right"],k=this;this.spriteBar&&this.spriteBar.destroy(); -this.spriteBar=new Morph;this.spriteBar.color=this.frameColor;this.add(this.spriteBar);a(1);a(2);a(0);this.rotationStyleButtons=c;var l=new Morph;l.isCachingImage=!0;l.bounds.setExtent(d);l.cachedImage=this.currentSprite.thumbnail(d);l.setPosition(c[0].topRight().add(new Point(5,3)));this.spriteBar.add(l);l.fps=3;l.step=function(){l.version!==k.currentSprite.version&&(l.cachedImage=k.currentSprite.thumbnail(d,l.cachedImage),l.changed(),l.version=k.currentSprite.version)};var m=new InputFieldMorph(this.currentSprite.name); -m.setWidth(100);m.contrast=90;m.setPosition(l.topRight().add(new Point(10,3)));this.spriteBar.add(m);this.spriteBar.nameField=m;m.fixLayout();m.accept=function(){var p=m.getValue(),r=k.currentSprite.name;p=k.newSpriteName(p,k.currentSprite);if(p!==r)return SnapActions.renameSprite(k.currentSprite,p);m.setContents(p)};this.spriteBar.nameField=m;this.spriteBar.reactToEdit=m.accept;var n=new ToggleMorph("checkbox",null,function(){return SnapActions.toggleDraggable(k.currentSprite,!k.currentSprite.isDraggable)}, -localize("draggable"),function(){return b.currentSprite.isDraggable});n.label.isBold=!1;n.label.setColor(this.buttonLabelColor);n.color=e[2];n.highlightColor=e[0];n.pressColor=e[1];n.tick.shadowOffset=MorphicPreferences.isFlat?ZERO:new Point(-1,-1);n.tick.shadowColor=BLACK;n.tick.color=this.buttonLabelColor;n.tick.isBold=!1;n.tick.fixLayout();n.setPosition(m.bottomLeft().add(2));n.fixLayout();this.spriteBar.add(n);this.spriteBar.padlock=n;this.currentSprite instanceof StageMorph&&n.hide();f.tabTo= -function(p){var r;k.currentTab=p;this.children.forEach(function(q){q.refresh();q.state&&(r=q)});r.refresh();k.createSpriteEditor();k.fixLayout("tabEditor")};n=new TabMorph(e,null,function(){SnapActions.selectTab("scripts");f.tabTo("scripts")},localize("Scripts"),function(){return"scripts"===b.currentTab});n.padding=3;n.corner=15;n.edge=1;n.labelShadowOffset=new Point(-1,-1);n.labelShadowColor=e[1];n.labelColor=this.buttonLabelColor;n.getPressRenderColor=function(){return MorphicPreferences.isFlat|| -.85{h.currentSprite instanceof SpriteMorph&&SnapActions.setRotationStyle(h.currentSprite,n)},f[n],()=>h.currentSprite instanceof SpriteMorph&&h.currentSprite.rotationStyle===n,null,localize(g[n]));q.corner=8;q.labelMinExtent=new Point(11,11);q.padding=0;q.labelShadowOffset=new Point(-1,-1);q.labelShadowColor=p[1];q.labelColor=h.buttonLabelColor;q.fixLayout();q.refresh();b.push(q); +q.setPosition(h.spriteBar.position().add(new Point(2,4)));q.setTop(q.top()+(b.length-1)*(q.height()+2));h.spriteBar.add(q);h.currentSprite instanceof StageMorph&&q.hide();return q}var b=[],c=new Point(45,45),d=this.tabColors,e=new AlignmentMorph("row",-30),f=[new SymbolMorph("arrowRightThin",10),new SymbolMorph("turnAround",10),new SymbolMorph("arrowLeftRightThin",10)],g=["don't rotate","can rotate","only face left/right"],h=this;this.spriteBar&&this.spriteBar.destroy();this.spriteBar=new Morph;this.spriteBar.color= +this.frameColor;this.add(this.spriteBar);a(1);a(2);a(0);this.rotationStyleButtons=b;var k=new Morph;k.isCachingImage=!0;k.bounds.setExtent(c);k.cachedImage=this.currentSprite.thumbnail(c);k.setPosition(b[0].topRight().add(new Point(5,3)));this.spriteBar.add(k);k.fps=3;k.step=function(){k.version!==h.currentSprite.version&&(k.cachedImage=h.currentSprite.thumbnail(c,k.cachedImage),k.changed(),k.version=h.currentSprite.version)};var l=new InputFieldMorph(this.currentSprite.name);l.setWidth(100);l.contrast= +90;l.setPosition(k.topRight().add(new Point(10,3)));this.spriteBar.add(l);this.spriteBar.nameField=l;l.fixLayout();l.accept=function(){var n=l.getValue(),p=h.currentSprite.name;n=h.newSpriteName(n,h.currentSprite);if(n!==p)return SnapActions.renameSprite(h.currentSprite,n);l.setContents(n)};this.spriteBar.nameField=l;this.spriteBar.reactToEdit=l.accept;var m=new ToggleMorph("checkbox",null,()=>SnapActions.toggleDraggable(h.currentSprite,!h.currentSprite.isDraggable),localize("draggable"),()=>this.currentSprite.isDraggable); +m.label.isBold=!1;m.label.setColor(this.buttonLabelColor);m.color=d[2];m.highlightColor=d[0];m.pressColor=d[1];m.tick.shadowOffset=MorphicPreferences.isFlat?ZERO:new Point(-1,-1);m.tick.shadowColor=BLACK;m.tick.color=this.buttonLabelColor;m.tick.isBold=!1;m.tick.fixLayout();m.setPosition(l.bottomLeft().add(2));m.fixLayout();this.spriteBar.add(m);this.spriteBar.padlock=m;this.currentSprite instanceof StageMorph&&m.hide();e.tabTo=function(n){var p;h.currentTab=n;this.children.forEach(q=>{q.refresh(); +q.state&&(p=q)});p.refresh();h.createSpriteEditor();h.fixLayout("tabEditor")};m=new TabMorph(d,null,()=>{SnapActions.selectTab("scripts");e.tabTo("scripts")},localize("Scripts"),()=>"scripts"===this.currentTab);m.padding=3;m.corner=15;m.edge=1;m.labelShadowOffset=new Point(-1,-1);m.labelShadowColor=d[1];m.labelColor=this.buttonLabelColor;m.getPressRenderColor=function(){return MorphicPreferences.isFlat||.85{SnapActions.selectTab("costumes");e.tabTo("costumes")},localize(this.currentSprite instanceof SpriteMorph?"Costumes":"Backgrounds"),()=>"costumes"===this.currentTab);m.padding=3;m.corner=15;m.edge=1;m.labelShadowOffset=new Point(-1,-1);m.labelShadowColor=d[1];m.labelColor=this.buttonLabelColor;m.fixLayout();e.add(m);m=new TabMorph(d,null,()=>{SnapActions.selectTab("sounds");e.tabTo("sounds")},localize("Sounds"), +()=>"sounds"===this.currentTab);m.padding=3;m.corner=15;m.edge=1;m.labelShadowOffset=new Point(-1,-1);m.labelShadowColor=d[1];m.labelColor=this.buttonLabelColor;m.fixLayout();e.add(m);e.fixLayout();e.children.forEach(n=>n.refresh());this.spriteBar.tabBar=e;this.spriteBar.add(this.spriteBar.tabBar);this.spriteBar.fixLayout=function(){this.tabBar.setLeft(this.left());this.tabBar.setBottom(this.bottom()+h.padding)};this.isAppMode&&this.spriteBar.hide()}; +IDE_Morph.prototype.createSpriteEditor=function(){var a=this.currentSprite.scripts;this.spriteEditor&&this.spriteEditor.destroy();"scripts"===this.currentTab?(a.isDraggable=!1,a.color=this.groupColor,a.cachedTexture=this.scriptsPaneTexture,this.spriteEditor=new ScrollFrameMorph(a,null,this.sliderColor),this.spriteEditor.color=this.groupColor,this.spriteEditor.padding=10,this.spriteEditor.growth=50,this.spriteEditor.isDraggable=!1,this.spriteEditor.acceptsDrops=!1,this.spriteEditor.contents.acceptsDrops= +!0,a.scrollFrame=this.spriteEditor,a.updateToolbar(),this.add(this.spriteEditor),this.spriteEditor.scrollX(this.spriteEditor.padding),this.spriteEditor.scrollY(this.spriteEditor.padding)):"costumes"===this.currentTab?(this.spriteEditor=new WardrobeMorph(this.currentSprite,this.sliderColor),this.spriteEditor.color=this.groupColor,this.add(this.spriteEditor),this.spriteEditor.updateSelection(),this.spriteEditor.acceptsDrops=!1,this.spriteEditor.contents.acceptsDrops=!1,this.spriteEditor.contents.mouseEnterDragging= +b=>{b instanceof BlockMorph&&this.spriteBar.tabBar.tabTo("scripts")}):"sounds"===this.currentTab?(this.spriteEditor=new JukeboxMorph(this.currentSprite,this.sliderColor),this.spriteEditor.color=this.groupColor,this.add(this.spriteEditor),this.spriteEditor.updateSelection(),this.spriteEditor.acceptDrops=!1,this.spriteEditor.contents.acceptsDrops=!1,this.spriteEditor.contents.mouseEnterDragging=b=>{b instanceof BlockMorph&&this.spriteBar.tabBar.tabTo("scripts")}):(this.spriteEditor=new Morph,this.spriteEditor.color= +this.groupColor,this.spriteEditor.acceptsDrops=!0,this.spriteEditor.reactToDropOf=b=>{b instanceof DialogBoxMorph?this.world().add(b):b instanceof SpriteMorph?this.removeSprite(b):b.destroy()},this.add(this.spriteEditor));this.activeEditor.onSetActive()}; IDE_Morph.prototype.createCorralBar=function(){var a=MorphicPreferences.isFlat?this.tabColors:[this.groupColor,this.frameColor.darker(50),this.frameColor.darker(50)];this.corralBar&&this.corralBar.destroy();this.corralBar=new Morph;this.corralBar.color=this.frameColor;this.corralBar.setHeight(this.logo.height());this.add(this.corralBar);var b=new PushButtonMorph(this,"addNewSprite",new SymbolMorph("turtle",14));b.corner=12;b.color=a[0];b.highlightColor=a[1];b.pressColor=a[2];b.labelMinExtent=new Point(36, 18);b.padding=0;b.labelShadowOffset=new Point(-1,-1);b.labelShadowColor=a[1];b.labelColor=this.buttonLabelColor;b.contrast=this.buttonContrast;b.hint="add a new Turtle sprite";b.fixLayout();b.setCenter(this.corralBar.center());b.setLeft(this.corralBar.left()+5);this.corralBar.add(b);var c=new PushButtonMorph(this,"paintNewSprite",new SymbolMorph("brush",15));c.corner=12;c.color=a[0];c.highlightColor=a[1];c.pressColor=a[2];c.labelMinExtent=new Point(36,18);c.padding=0;c.labelShadowOffset=new Point(-1, -1);c.labelShadowColor=a[1];c.labelColor=this.buttonLabelColor;c.contrast=this.buttonContrast;c.hint="paint a new sprite";c.fixLayout();c.setCenter(this.corralBar.center());c.setLeft(this.corralBar.left()+5+b.width()+5);this.corralBar.add(c);if(CamSnapshotDialogMorph.prototype.enableCamera){var d=new PushButtonMorph(this,"newCamSprite",new SymbolMorph("camera",15));d.corner=12;d.color=a[0];d.highlightColor=a[1];d.pressColor=a[2];d.labelMinExtent=new Point(36,18);d.padding=0;d.labelShadowOffset=new Point(-1, --1);d.labelShadowColor=a[1];d.labelColor=this.buttonLabelColor;d.contrast=this.buttonContrast;d.hint="take a camera snapshot and\nimport it as a new sprite";d.fixLayout();d.setCenter(this.corralBar.center());d.setLeft(this.corralBar.left()+5+b.width()+5+c.width()+5);this.corralBar.add(d);document.addEventListener("cameraDisabled",function(e){d.disable();d.hint=CamSnapshotDialogMorph.prototype.notSupportedMessage})}}; -IDE_Morph.prototype.createCorral=function(){var a=this,b=this;this.createStageHandle();this.createPaletteHandle();this.corral&&this.corral.destroy();this.corral=new Morph;this.corral.color=this.groupColor;this.corral.getRenderColor=ScriptsMorph.prototype.getRenderColor;this.add(this.corral);this.corral.stageIcon=new SpriteIconMorph(this.stage);this.corral.stageIcon.isDraggable=!1;this.corral.add(this.corral.stageIcon);var c=new ScrollFrameMorph(null,null,this.sliderColor);c.acceptsDrops=!1;c.contents.acceptsDrops= -!1;c.contents.wantsDropOf=function(d){return d instanceof SpriteIconMorph};c.contents.reactToDropOf=function(d){return a.corral.reactToDropOf(d)};c.alpha=0;this.sprites.asArray().forEach(function(d){d.isTemporary||c.contents.add(new SpriteIconMorph(d))});this.corral.frame=c;this.corral.add(c);this.corral.fixLayout=function(){this.stageIcon.setCenter(this.center());this.stageIcon.setLeft(this.left()+5);this.frame.setLeft(this.stageIcon.right()+5);this.frame.setExtent(new Point(this.right()-this.frame.left(), -this.height()));this.arrangeIcons();this.refresh()};this.corral.arrangeIcons=function(){var d=this.frame.left(),e=this.frame.top(),f=this.frame.right(),g=this.frame.left();this.frame.contents.children.forEach(function(h){var k=h.width();d+k>f&&(d=g,e+=h.height());h.setPosition(new Point(d,e));d+=k});this.frame.contents.adjustBounds()};this.corral.addSprite=function(d){this.frame.contents.add(new SpriteIconMorph(d));this.fixLayout()};this.corral.refresh=function(){this.stageIcon.refresh();this.frame.contents.children.forEach(function(d){return d.refresh()})}; -this.corral.wantsDropOf=function(d){return d instanceof SpriteIconMorph};this.corral.reactToDropOf=function(d){var e=1,f=d.position(),g=!!SnapActions.getOwnerFromId(d.object.id);d.destroy();g&&(this.frame.contents.children.forEach(function(h){if(f.gt(h.position())||f.y>h.bottom())e+=1}),b.sprites.add(d.object,e),b.createCorral(),b.fixLayout())};this.corral.userMenu=function(){var d=new MenuMorph(this);if(SnapUndo.canUndo("corral")){var e=SnapUndo.eventHistory.corral.length;e=SnapUndo.eventHistory.corral[e- -1];e=b.serializer.parse(e.args[1]).childrenNamed("sprite")[0];d.addItem("restore "+e.attributes.name,function(){SnapUndo.undo("corral")})}return d};this.isAppMode&&this.corral.hide()};IDE_Morph.prototype.createReplayControls=function(){this.replayControls=new ReplayControls(this);this.add(this.replayControls);this.replayControls.hide()}; +-1);d.labelShadowColor=a[1];d.labelColor=this.buttonLabelColor;d.contrast=this.buttonContrast;d.hint="take a camera snapshot and\nimport it as a new sprite";d.fixLayout();d.setCenter(this.corralBar.center());d.setLeft(this.corralBar.left()+5+b.width()+5+c.width()+5);this.corralBar.add(d);document.addEventListener("cameraDisabled",e=>{d.disable();d.hint=CamSnapshotDialogMorph.prototype.notSupportedMessage})}}; +IDE_Morph.prototype.createCorral=function(){var a=this;this.createStageHandle();this.createPaletteHandle();this.corral&&this.corral.destroy();this.corral=new Morph;this.corral.color=this.groupColor;this.corral.getRenderColor=ScriptsMorph.prototype.getRenderColor;this.add(this.corral);this.corral.stageIcon=new SpriteIconMorph(this.stage);this.corral.stageIcon.isDraggable=!1;this.corral.add(this.corral.stageIcon);var b=new ScrollFrameMorph(null,null,this.sliderColor);b.acceptsDrops=!1;b.contents.acceptsDrops= +!1;b.contents.wantsDropOf=c=>c instanceof SpriteIconMorph;b.contents.reactToDropOf=c=>this.corral.reactToDropOf(c);b.alpha=0;this.sprites.asArray().forEach(c=>{c.isTemporary||b.contents.add(new SpriteIconMorph(c))});this.corral.frame=b;this.corral.add(b);this.corral.fixLayout=function(){this.stageIcon.setCenter(this.center());this.stageIcon.setLeft(this.left()+5);this.frame.setLeft(this.stageIcon.right()+5);this.frame.setExtent(new Point(this.right()-this.frame.left(),this.height()));this.arrangeIcons(); +this.refresh()};this.corral.arrangeIcons=function(){var c=this.frame.left(),d=this.frame.top(),e=this.frame.right(),f=this.frame.left();this.frame.contents.children.forEach(g=>{var h=g.width();c+h>e&&(c=f,d+=g.height());g.setPosition(new Point(c,d));c+=h});this.frame.contents.adjustBounds()};this.corral.addSprite=function(c){this.frame.contents.add(new SpriteIconMorph(c));this.fixLayout()};this.corral.refresh=function(){this.stageIcon.refresh();this.frame.contents.children.forEach(c=>c.refresh())}; +this.corral.wantsDropOf=c=>c instanceof SpriteIconMorph;this.corral.reactToDropOf=function(c){var d=1,e=c.position(),f=!!SnapActions.getOwnerFromId(c.object.id);c.destroy();f&&(this.frame.contents.children.forEach(function(g){if(e.gt(g.position())||e.y>g.bottom())d+=1}),a.sprites.add(c.object,d),a.createCorral(),a.fixLayout())};this.corral.userMenu=function(){var c=new MenuMorph(this);if(SnapUndo.canUndo("corral")){var d=SnapUndo.eventHistory.corral.length;d=SnapUndo.eventHistory.corral[d-1];d=a.serializer.parse(d.args[1]).childrenNamed("sprite")[0]; +c.addItem("restore "+d.attributes.name,function(){SnapUndo.undo("corral")})}return c};this.isAppMode&&this.corral.hide()};IDE_Morph.prototype.createReplayControls=function(){this.replayControls=new ReplayControls(this);this.add(this.replayControls);this.replayControls.hide()}; IDE_Morph.prototype.fixLayout=function(a){var b=this.padding;"refreshPalette"!==a&&(this.controlBar.setPosition(this.logo.topRight()),this.controlBar.setWidth(this.right()-this.controlBar.left()),this.controlBar.fixLayout(),this.categories.setLeft(this.logo.left()),this.categories.setTop(this.logo.bottom()),this.categories.setWidth(this.paletteWidth));this.palette.setLeft(this.logo.left());this.palette.setTop(this.categories.bottom());this.palette.setHeight(this.bottom()-this.palette.top());this.palette.setWidth(this.paletteWidth); if("refreshPalette"!==a){if(this.isEmbedMode){this.stage.setScale(Math.floor(100*Math.min(this.width()/this.stage.dimensions.x,this.height()/this.stage.dimensions.y))/100);var c=this.embedPlayButton.flag;c.size=Math.floor(Math.min(this.width(),this.height()))/5;c.fixLayout();this.embedPlayButton.size=1.6*c.size;this.embedPlayButton.fixLayout();this.embedOverlay&&this.embedOverlay.setExtent(this.extent());this.stage.setCenter(this.center());this.embedPlayButton.setCenter(this.stage.center());c.setCenter(this.embedPlayButton.center()); c.setLeft(c.left()+.1*c.size)}else if(this.isAppMode){if(this.isMobileDevice()){c=(this.width()-2*b)/this.stage.dimensions.x;var d=(this.height()-2*b)/this.stage.dimensions.y;c=Math.floor(1E3*Math.min(c,d))/1E3}else c=Math.floor(10*Math.min((this.width()-2*b)/this.stage.dimensions.x,(this.height()-2*this.controlBar.height()-2*b)/this.stage.dimensions.y))/10;this.stage.setScale(c);this.stage.setCenter(this.center())}else this.stage.setScale(this.isSmallStage?this.stageRatio:1),this.stage.setTop(this.logo.bottom()+ @@ -2104,11 +2021,11 @@ this.stage.dimensions.y),Math.max(3*SpriteIconMorph.prototype.thumbSize.x/this.s IDE_Morph.prototype.render=function(a){IDE_Morph.uber.render.call(this,a);if(this.isAppMode&&this.stage){var b=this.stage.bounds.translateBy(this.position().neg()).expandBy(2);a.strokeStyle=(MorphicPreferences.isFlat?this.backgroundColor:this.groupColor).toString();a.lineWidth=1;a.beginPath();a.moveTo(b.origin.x,b.origin.y);a.lineTo(b.corner.x,b.origin.y);a.lineTo(b.corner.x,b.corner.y);a.lineTo(b.origin.x,b.corner.y);a.closePath();a.stroke()}}; IDE_Morph.prototype.reactToWorldResize=function(a){this.isAutoFill&&(this.setPosition(a.origin),this.setExtent(a.extent()));this.filePicker&&(document.body.removeChild(this.filePicker),this.filePicker=null)}; IDE_Morph.prototype.droppedImage=function(a,b){a=new Costume(a,this.currentSprite.newCostumeName(b?b.split(".")[0]:""));a.isTainted()?this.inform("Unable to import this image","The picture you wish to import has been\ntainted by a restrictive cross-origin policy\nmaking it unusable for costumes in Snap!. \n\nTry downloading this picture first to your\ncomputer, and import it from there."):SnapActions.addCostume(a,this.currentSprite,!0)}; -IDE_Morph.prototype.droppedSVG=function(a,b){a=new SVG_Costume(a,b.split(".")[0]);SnapActions.addCostume(a,this.currentSprite,!0)};IDE_Morph.prototype.droppedAudio=function(a,b){var c=this,d,e;return $jscomp.asyncExecutePromiseGeneratorProgram(function(f){if(1==f.nextAddress)return d=a,f.yield(c.getAudioAsBase64(a.src),2);d.src=f.yieldResult;e=new Sound(a,b.split(".")[0]);SnapActions.addSound(e,c.currentSprite,!0).then(function(){return c.spriteBar.tabBar.tabTo("sounds")});f.jumpToEnd()})}; -IDE_Morph.prototype.getAudioAsBase64=function(a){var b=this;return $jscomp.asyncExecutePromiseGeneratorProgram(function(c){return 1==c.nextAddress?a.startsWith("data:audio")?c.return(a):c.yield(new Promise(function(d){return b.getURL(a,function(e){var f=new window.FileReader;f.readAsDataURL(e);f.onloadend=function(){var g=f.result;g="data:audio/ogg;base64,"+g.split(",")[1];d(g)}},"blob")}),3):c.return(c.yieldResult)})}; -IDE_Morph.prototype.droppedText=function(a,b,c){var d=this,e,f,g,h;return $jscomp.asyncExecutePromiseGeneratorProgram(function(k){if(1==k.nextAddress){e=b?b.split(".")[0]:"";f=b?b.slice(b.lastIndexOf(".")+1).toLowerCase():"";if(0===a.indexOf("this.spriteBar.tabBar.tabTo("sounds"))}; +IDE_Morph.prototype.getAudioAsBase64=async function(a){return a.startsWith("data:audio")?a:await new Promise(b=>this.getURL(a,c=>{var d=new window.FileReader;d.readAsDataURL(c);d.onloadend=()=>{var e=d.result;e="data:audio/ogg;base64,"+e.split(",")[1];b(e)}},"blob"))}; +IDE_Morph.prototype.droppedText=async function(a,b,c){var d=b?b.split(".")[0]:"";b=b?b.slice(b.lastIndexOf(".")+1).toLowerCase():"";if(0===a.indexOf("b instanceof BlockEditorMorph||b instanceof BlockDialogMorph))return this.currentSprite&&this.currentSprite.scripts.focus&&this.currentSprite.scripts.focus.stopEditing(),this.currentSprite=a,this.createPalette(),this.createSpriteBar(),this.createSpriteEditor(),this.corral.refresh(),this.fixLayout("selectSprite"),this.currentSprite.scripts.fixMultiArgs(),this.currentSprite}; IDE_Morph.prototype.toggleRetina=function(){isRetinaEnabled()?disableRetinaSupport():enableRetinaSupport();this.world().fillPage();MorphicPreferences.isFlat||(IDE_Morph.prototype.scriptsPaneTexture=this.scriptsTexture());this.stage.clearPenTrails();this.refreshIDE()};IDE_Morph.prototype.defaultDesign=function(){this.setDefaultDesign();this.refreshIDE();this.removeSetting("design")};IDE_Morph.prototype.flatDesign=function(){this.setFlatDesign();this.refreshIDE();this.saveSetting("design","flat")}; IDE_Morph.prototype.refreshIDE=function(){if(Process.prototype.isCatchingErrors)try{var a=this.serializer.serialize(this.stage)}catch(b){this.showMessage("Serialization failed: "+b)}else a=this.serializer.serialize(this.stage);SpriteMorph.prototype.initBlocks();this.buildPanes();this.fixLayout();this.loadNewProject?SnapActions.openProject():(SnapUndo.reset(),this.openProjectString(a))}; IDE_Morph.prototype.applySavedSettings=function(){var a=this.getSetting("design"),b=this.getSetting("zoom"),c=this.getSetting("fade"),d=this.getSetting("language"),e=this.getSetting("click"),f=this.getSetting("longform"),g=this.getSetting("longurls"),h=this.getSetting("plainprototype"),k=this.getSetting("keyboard"),l=this.getSetting("tables"),m=this.getSetting("tableLines"),n=this.getSetting("autowrapping");"flat"===a?this.setFlatDesign():this.setDefaultDesign();b&&(SyntaxElementMorph.prototype.setScale(Math.min(b, 12)),CommentMorph.prototype.refreshScale(),SpriteMorph.prototype.initBlocks());isNil(c)||this.setBlockTransparency(+c);this.userLanguage=d&&"en"!==d?d:null;e&&!BlockMorph.prototype.snapSound&&BlockMorph.prototype.toggleSnapSound();f&&(InputSlotDialogMorph.prototype.isLaunchingExpanded=!0);this.projectsInURLs=g?!0:!1;ScriptsMorph.prototype.enableKeyboard="false"===k?!1:!0;List.prototype.enableTables="false"===l?!1:!0;TableMorph.prototype.highContrast=m?!0:!1;ScriptsMorph.prototype.enableNestedAutoWrapping= "false"===n?!1:!0;h&&(BlockLabelPlaceHolderMorph.prototype.plainLabel=!0)};IDE_Morph.prototype.saveSetting=function(a,b){this.savingPreferences&&this.hasLocalStorage()&&(localStorage["-snap-setting-"+a]=b)};IDE_Morph.prototype.getSetting=function(a){return this.hasLocalStorage()?localStorage["-snap-setting-"+a]:null};IDE_Morph.prototype.removeSetting=function(a){this.hasLocalStorage()&&delete localStorage["-snap-setting-"+a]};IDE_Morph.prototype.hasLocalStorage=function(){try{return!isNil(localStorage)}catch(a){return!1}}; -IDE_Morph.prototype.addNewSprite=function(){var a=this,b=new SpriteMorph(this.globalVariables),c=Process.prototype.reportBasicRandom;b.name=this.newSpriteName(b.name);b.setCenter(this.stage.center());b.parent=this.stage;b.setColorComponentHSVA(0,c.call(this,0,100));b.setColorComponentHSVA(1,100);b.setColorComponentHSVA(2,c.call(this,50,100));b.setXPosition(c.call(this,-220,220));b.setYPosition(c.call(this,-160,160));16===this.world().currentKey&&b.turn(c.call(this,1,360));return SnapActions.addSprite(b).then(function(d){return a.selectSprite(d)})}; -IDE_Morph.prototype.paintNewSprite=function(){var a=this,b=new SpriteMorph(this.globalVariables),c=new Costume;c.edit(this.world(),null,!0,nop,function(){c.shrinkWrap();b.parent=a.stage;b.addCostume(c);b.wearCostume(c);b.gotoXY(0,0);SnapActions.addSprite(b)})}; -IDE_Morph.prototype.newCamSprite=function(){var a=this,b=new SpriteMorph(this.globalVariables);b.name=this.newSpriteName(b.name);b.setCenter(this.stage.center());b.parent=this.stage;var c=new CamSnapshotDialogMorph(this,b,nop,function(d){b.addCostume(d);b.wearCostume(d);c.close();SnapActions.addSprite(b).then(function(e){return a.selectSprite(e)})});c.popUp(this.world())}; -IDE_Morph.prototype.recordNewSound=function(){var a=this;var b=new SoundRecorderDialogMorph(function(c){c&&(c=a.currentSprite.addSound(c,a.newSoundName("recording")),a.makeSureRecordingIsMono(c),a.spriteBar.tabBar.tabTo("sounds"),a.hasChangedMedia=!0)});b.key="microphone";b.popUp(this.world())}; +IDE_Morph.prototype.addNewSprite=function(){var a=new SpriteMorph(this.globalVariables),b=Process.prototype.reportBasicRandom;a.name=this.newSpriteName(a.name);a.setCenter(this.stage.center());a.parent=this.stage;a.setColorComponentHSVA(0,b.call(this,0,100));a.setColorComponentHSVA(1,100);a.setColorComponentHSVA(2,b.call(this,50,100));a.setXPosition(b.call(this,-220,220));a.setYPosition(b.call(this,-160,160));16===this.world().currentKey&&a.turn(b.call(this,1,360));return SnapActions.addSprite(a).then(c=> +this.selectSprite(c))};IDE_Morph.prototype.paintNewSprite=function(){var a=new SpriteMorph(this.globalVariables),b=new Costume;b.edit(this.world(),null,!0,nop,()=>{b.shrinkWrap();a.parent=this.stage;a.addCostume(b);a.wearCostume(b);a.gotoXY(0,0);SnapActions.addSprite(a)})}; +IDE_Morph.prototype.newCamSprite=function(){var a=new SpriteMorph(this.globalVariables);a.name=this.newSpriteName(a.name);a.setCenter(this.stage.center());a.parent=this.stage;var b=new CamSnapshotDialogMorph(this,a,nop,c=>{a.addCostume(c);a.wearCostume(c);b.close();SnapActions.addSprite(a).then(d=>this.selectSprite(d))});b.popUp(this.world())}; +IDE_Morph.prototype.recordNewSound=function(){var a=new SoundRecorderDialogMorph(b=>{b&&(b=this.currentSprite.addSound(b,this.newSoundName("recording")),this.makeSureRecordingIsMono(b),this.spriteBar.tabBar.tabTo("sounds"),this.hasChangedMedia=!0)});a.key="microphone";a.popUp(this.world())}; IDE_Morph.prototype.makeSureRecordingIsMono=function(a){function b(e,f){var g=Note.prototype.getAudioContext();f=g.createBuffer(1,e.length,+f||44100);var h;f.copyToChannel||(f.copyToChannel=function(k,l){l=this.getChannelData(l);for(h=0;hx?32768*x:32767*x,!0)}}function n(u,v,w){for(var y=0;yx?32768*x:32767*x,!0)}}function n(u,v,w){for(var y=0;y{e.audioBuffer=m;return f(e)},m=>{throw m;})})(a,function(e){if(1!==e.audioBuffer.numberOfChannels){var f= +e.audioBuffer.getChannelData(0);var g=new Audio;f=new Blob([c(b(f,44100).audioBuffer)],{type:"audio/wav"});var h=new FileReader;h.onload=()=>{g.src=h.result;e.audio=g;e.audioBuffer=null;e.cachedSamples=null;e.isDecoding=!1};h.readAsDataURL(f)}})};IDE_Morph.prototype.duplicateSprite=function(a){a=a.fullCopy();a.appearIn(this);return a}; IDE_Morph.prototype.instantiateSprite=function(a){var b=a.fullCopy(!0),c=b.allHatBlocksFor("__clone__init__");b.isDown=!1;b.appearIn(this);c.length?b.initClone(c):(b.setPosition(this.world().hand.position()),b.keepWithin(this.stage));b.isDown=a.isDown;this.selectSprite(b)}; -IDE_Morph.prototype.removeSprite=function(a){var b=this;a.parts.slice().forEach(function(d){return b.removeSprite(d)});var c=this.sprites.asArray().indexOf(a)+1;this.stage.threads.stopAllForReceiver(a);a.corpsify();a.destroy();this.stage.watchers().forEach(function(d){d.object()===a&&d.destroy()});0c?a:a.substring(0,c);c=1;for(var d=a;contains(b,d);)c+=1,d=a+"("+c+")";return d};IDE_Morph.prototype.removeBlock=function(a,b){this.stage.threads.stopAllForBlock(a);a.destroy(b)};IDE_Morph.prototype.userMenu=function(){return new MenuMorph(this)}; +IDE_Morph.prototype.removeSprite=function(a){a.parts.slice().forEach(c=>this.removeSprite(c));var b=this.sprites.asArray().indexOf(a)+1;this.stage.threads.stopAllForReceiver(a);a.corpsify();a.destroy();this.stage.watchers().forEach(c=>{c.object()===a&&c.destroy()});0c instanceof SpriteMorph&&!c.isTemporary)||this.stage;this.selectSprite(this.currentSprite)}; +IDE_Morph.prototype.newSoundName=function(a){var b=this.currentSprite.sounds.at(this.currentSprite.sounds.length());return this.newName(a||b.name,this.currentSprite.sounds.asArray().map(c=>c.name))};IDE_Morph.prototype.newSpriteName=function(a,b){var c=this.sprites.asArray().concat(this.stage).filter(d=>d!==b).map(d=>d.name);return this.newName(a,c)};IDE_Morph.prototype.newName=function(a,b){var c=a.indexOf("(");a=0>c?a:a.substring(0,c);c=1;for(var d=a;contains(b,d);)c+=1,d=a+"("+c+")";return d}; +IDE_Morph.prototype.removeBlock=function(a,b){this.stage.threads.stopAllForBlock(a);a.destroy(b)};IDE_Morph.prototype.userMenu=function(){return new MenuMorph(this)}; IDE_Morph.prototype.snapMenu=function(){var a=this,b=this.world();var c=new MenuMorph(this);c.addItem("About...","aboutNetsBlox");c.addLine();c.addItem("NetsBlox website",function(){window.open("https://netsblox.org","NetsBloxWebsite")});c.addItem("Snap! manual",function(){var d=a.resourceURL("help","SnapManual.pdf");window.open(d,"SnapReferenceManual")});c.addItem("Source code",function(){window.open("https://github.com/netsblox/netsblox")});c.addLine();c.addItem("Report a bug","reportBug");16=== b.currentKey&&c.addItem("Load reported bug","loadBugReport",void 0,new Color(100,0,0));b.isDevMode?(c.addLine(),c.addItem("Switch back to user mode","switchToUserMode","disable deep-Morphic\ncontext menus\nand show user-friendly ones",new Color(0,100,0))):16===b.currentKey&&(c.addLine(),c.addItem("Switch to dev mode","switchToDevMode","enable Morphic\ncontext menus\nand inspectors,\nnot user-friendly!",new Color(100,0,0)));c.popup(b,this.logo.bottomLeft())}; -IDE_Morph.prototype.cloudMenu=function(){var a=this,b=16===this.world().currentKey;if("file:"!==location.protocol||b){var c=new MenuMorph(this);this.cloud.username?(c.addItem(localize("Logout")+" "+this.cloud.username,"logout"),c.addItem("Change Password...","changeCloudPassword")):(c.addItem("Login...","initializeCloud"),c.addItem("Login with Snap!...","initializeCloudWithSnap"),c.addItem("Signup...","createCloudAccount"),c.addItem("Reset Password...","resetCloudPassword"));b&&(c.addLine(),c.addItem("export project media only...", -function(){a.projectName?a.exportProjectMedia(a.projectName):a.prompt("Export Project As...",function(d){return a.exportProjectMedia(d)},null,"exportProject")},null,this.hasChangedMedia?new Color(100,0,0):new Color(0,100,0)),c.addItem("export project without media...",function(){a.projectName?a.exportProjectNoMedia(a.projectName):a.prompt("Export Project As...",function(d){return a.exportProjectNoMedia(d)},null,"exportProject")},null,new Color(100,0,0)),c.addLine(),c.addItem("open shared project from cloud...", -function(){a.prompt("Author name\u2026",function(d){a.prompt("Project name...",function(e){var f,g,h,k;return $jscomp.asyncExecutePromiseGeneratorProgram(function(l){switch(l.nextAddress){case 1:return f="Username="+encodeURIComponent(d.toLowerCase())+"&ProjectName="+encodeURIComponent(e),a.showMessage("Fetching project\nfrom the cloud..."),l.setCatchFinallyBlocks(2),l.yield(SnapCloud.getPublicProject(f),4);case 4:return g=l.yieldResult,Process.prototype.isCatchingErrors||window.open("data:text/xml,"+ -g),h=a.showMessage("Opening project..."),l.yield(SnapActions.openProject(g),5);case 5:h.destroy();l.leaveTryBlock(0);break;case 2:k=l.enterCatchBlock(),a.cloudError()(k.message),l.jumpToEnd()}})},null,"project")},null,"project")},null,new Color(100,0,0)));return c}this.showMessage("cloud unavailable without a web server.")}; -IDE_Morph.prototype.settingsMenu=function(){function a(h,k,l,m,n,p){p&&!d||g.addItem([l?e:f,localize(h)],k,l?m:n,p?new Color(100,0,0):null)}var b=this,c=this.stage,d=16===this.world().currentKey,e=new SymbolMorph("checkedBox",.75*MorphicPreferences.menuFontSize),f=new SymbolMorph("rectangle",.75*MorphicPreferences.menuFontSize);var g=new MenuMorph(this);g.addPair([new SymbolMorph("globe",MorphicPreferences.menuFontSize),localize("Language...")],"languageMenu");g.addItem("Zoom blocks...","userSetBlocksScale"); -g.addItem("Fade blocks...","userFadeBlocks");g.addItem("Stage size...","userSetStageSize");d&&g.addItem("Dragging threshold...","userSetDragThreshold","specify the distance the hand has to move\nbefore it picks up an object",new Color(100,0,0));g.addItem("Microphone resolution...","microphoneMenu");g.addLine();isRetinaSupported()&&a("Retina display support","toggleRetina",isRetinaEnabled(),"uncheck for lower resolution,\nsaves computing resources","check for higher resolution,\nuses more computing resources", +IDE_Morph.prototype.cloudMenu=function(){var a=16===this.world().currentKey;if("file:"!==location.protocol||a){var b=new MenuMorph(this);this.cloud.username?(b.addItem(localize("Logout")+" "+this.cloud.username,"logout"),b.addItem("Change Password...","changeCloudPassword")):(b.addItem("Login...","initializeCloud"),b.addItem("Login with Snap!...","initializeCloudWithSnap"),b.addItem("Signup...","createCloudAccount"),b.addItem("Reset Password...","resetCloudPassword"));a&&(b.addLine(),b.addItem("export project media only...", +()=>{this.projectName?this.exportProjectMedia(this.projectName):this.prompt("Export Project As...",c=>this.exportProjectMedia(c),null,"exportProject")},null,this.hasChangedMedia?new Color(100,0,0):new Color(0,100,0)),b.addItem("export project without media...",()=>{this.projectName?this.exportProjectNoMedia(this.projectName):this.prompt("Export Project As...",c=>this.exportProjectNoMedia(c),null,"exportProject")},null,new Color(100,0,0)),b.addLine(),b.addItem("open shared project from cloud...",()=> +{this.prompt("Author name\u2026",c=>{this.prompt("Project name...",async d=>{d="Username="+encodeURIComponent(c.toLowerCase())+"&ProjectName="+encodeURIComponent(d);this.showMessage("Fetching project\nfrom the cloud...");try{const e=await SnapCloud.getPublicProject(d);Process.prototype.isCatchingErrors||window.open("data:text/xml,"+e);const f=this.showMessage("Opening project...");await SnapActions.openProject(e);f.destroy()}catch(e){this.cloudError()(e.message)}},null,"project")},null,"project")}, +null,new Color(100,0,0)));return b}this.showMessage("cloud unavailable without a web server.")}; +IDE_Morph.prototype.settingsMenu=function(){function a(g,h,k,l,m,n){n&&!c||f.addItem([k?d:e,localize(g)],h,k?l:m,n?new Color(100,0,0):null)}var b=this.stage,c=16===this.world().currentKey,d=new SymbolMorph("checkedBox",.75*MorphicPreferences.menuFontSize),e=new SymbolMorph("rectangle",.75*MorphicPreferences.menuFontSize);var f=new MenuMorph(this);f.addPair([new SymbolMorph("globe",MorphicPreferences.menuFontSize),localize("Language...")],"languageMenu");f.addItem("Zoom blocks...","userSetBlocksScale"); +f.addItem("Fade blocks...","userFadeBlocks");f.addItem("Stage size...","userSetStageSize");c&&f.addItem("Dragging threshold...","userSetDragThreshold","specify the distance the hand has to move\nbefore it picks up an object",new Color(100,0,0));f.addItem("Microphone resolution...","microphoneMenu");f.addLine();isRetinaSupported()&&a("Retina display support","toggleRetina",isRetinaEnabled(),"uncheck for lower resolution,\nsaves computing resources","check for higher resolution,\nuses more computing resources", !0);a("Input sliders","toggleInputSliders",MorphicPreferences.useSliderForInput,"uncheck to disable\ninput sliders for\nentry fields","check to enable\ninput sliders for\nentry fields");MorphicPreferences.useSliderForInput&&a("Execute on slider change","toggleSliderExecute",ArgMorph.prototype.executeOnSliderEdit,"uncheck to suppress\nrunning scripts\nwhen moving the slider","check to run\nthe edited script\nwhen moving the slider");a("Turbo mode","toggleFastTracking",this.stage.isFastTracked,"uncheck to run scripts\nat normal speed", -"check to prioritize\nscript execution");a("Visible stepping","toggleSingleStepping",Process.prototype.enableSingleStepping,"uncheck to turn off\nvisible stepping","check to turn on\n visible stepping (slow)",!1);a("Log pen vectors",function(){return StageMorph.prototype.enablePenLogging=!StageMorph.prototype.enablePenLogging},StageMorph.prototype.enablePenLogging,"uncheck to turn off\nlogging pen vectors","check to turn on\nlogging pen vectors",!1);a("Ternary Boolean slots",function(){return BooleanSlotMorph.prototype.isTernary= -!BooleanSlotMorph.prototype.isTernary},BooleanSlotMorph.prototype.isTernary,"uncheck to limit\nBoolean slots to true / false","check to allow\nempty Boolean slots",!0);a("Camera support","toggleCameraSupport",CamSnapshotDialogMorph.prototype.enableCamera,"uncheck to disable\ncamera support","check to enable\ncamera support",!0);g.addLine();a("Blurred shadows","toggleBlurredShadows",useBlurredShadows,"uncheck to use solid drop\nshadows and highlights","check to use blurred drop\nshadows and highlights", +"check to prioritize\nscript execution");a("Visible stepping","toggleSingleStepping",Process.prototype.enableSingleStepping,"uncheck to turn off\nvisible stepping","check to turn on\n visible stepping (slow)",!1);a("Log pen vectors",()=>StageMorph.prototype.enablePenLogging=!StageMorph.prototype.enablePenLogging,StageMorph.prototype.enablePenLogging,"uncheck to turn off\nlogging pen vectors","check to turn on\nlogging pen vectors",!1);a("Ternary Boolean slots",()=>BooleanSlotMorph.prototype.isTernary= +!BooleanSlotMorph.prototype.isTernary,BooleanSlotMorph.prototype.isTernary,"uncheck to limit\nBoolean slots to true / false","check to allow\nempty Boolean slots",!0);a("Camera support","toggleCameraSupport",CamSnapshotDialogMorph.prototype.enableCamera,"uncheck to disable\ncamera support","check to enable\ncamera support",!0);f.addLine();a("Blurred shadows","toggleBlurredShadows",useBlurredShadows,"uncheck to use solid drop\nshadows and highlights","check to use blurred drop\nshadows and highlights", !0);a("Zebra coloring","toggleZebraColoring",BlockMorph.prototype.zebraContrast,"uncheck to disable alternating\ncolors for nested block","check to enable alternating\ncolors for nested blocks",!0);a("Dynamic input labels","toggleDynamicInputLabels",SyntaxElementMorph.prototype.dynamicInputLabels,"uncheck to disable dynamic\nlabels for variadic inputs","check to enable dynamic\nlabels for variadic inputs",!0);a("Prefer empty slot drops","togglePreferEmptySlotDrops",ScriptsMorph.prototype.isPreferringEmptySlots, "uncheck to allow dropped\nreporters to kick out others","settings menu prefer empty slots hint",!0);a("Long form input dialog","toggleLongFormInputDialog",InputSlotDialogMorph.prototype.isLaunchingExpanded,"uncheck to use the input\ndialog in short form","check to always show slot\ntypes in the input dialog");a("Plain prototype labels","togglePlainPrototypeLabels",BlockLabelPlaceHolderMorph.prototype.plainLabel,"uncheck to always show (+) symbols\nin block prototype labels","check to hide (+) symbols\nin block prototype labels"); -a("Virtual keyboard","toggleVirtualKeyboard",MorphicPreferences.useVirtualKeyboard,"uncheck to disable\nvirtual keyboard support\nfor mobile devices","check to enable\nvirtual keyboard support\nfor mobile devices",!0);a("Clicking sound",function(){BlockMorph.prototype.toggleSnapSound();BlockMorph.prototype.snapSound?b.saveSetting("click",!0):b.removeSetting("click")},BlockMorph.prototype.snapSound,"uncheck to turn\nblock clicking\nsound off","check to turn\nblock clicking\nsound on");a("Animations", -function(){return b.isAnimating=!b.isAnimating},this.isAnimating,"uncheck to disable\nIDE animations","check to enable\nIDE animations",!0);a("Cache Inputs",function(){BlockMorph.prototype.isCachingInputs=!BlockMorph.prototype.isCachingInputs},BlockMorph.prototype.isCachingInputs,"uncheck to stop caching\ninputs (for debugging the evaluator)","check to cache inputs\nboosts recursion",!0);a("Rasterize SVGs",function(){return MorphicPreferences.rasterizeSVGs=!MorphicPreferences.rasterizeSVGs},MorphicPreferences.rasterizeSVGs, -"uncheck for smooth\nscaling of vector costumes","check to rasterize\nSVGs on import",!0);a("Flat design",function(){if(MorphicPreferences.isFlat)return b.defaultDesign();b.flatDesign()},MorphicPreferences.isFlat,"uncheck for default\nGUI design","check for alternative\nGUI design",!1);a("Nested auto-wrapping",function(){ScriptsMorph.prototype.enableNestedAutoWrapping=!ScriptsMorph.prototype.enableNestedAutoWrapping;ScriptsMorph.prototype.enableNestedAutoWrapping?b.removeSetting("autowrapping"):b.saveSetting("autowrapping", -!1)},ScriptsMorph.prototype.enableNestedAutoWrapping,"uncheck to confine auto-wrapping\nto top-level block stacks","check to enable auto-wrapping\ninside nested block stacks",!0);a("Project URLs",function(){b.projectsInURLs=!b.projectsInURLs;b.projectsInURLs?b.saveSetting("longurls",!0):b.removeSetting("longurls")},this.projectsInURLs,"uncheck to disable\nproject data in URLs","check to enable\nproject data in URLs",!0);a("Sprite Nesting",function(){return SpriteMorph.prototype.enableNesting=!SpriteMorph.prototype.enableNesting}, -SpriteMorph.prototype.enableNesting,"uncheck to disable\nsprite composition","check to enable\nsprite composition",!0);a("First-Class Sprites",function(){SpriteMorph.prototype.enableFirstClass=!SpriteMorph.prototype.enableFirstClass;b.currentSprite.blocksCache.sensing=null;b.currentSprite.paletteCache.sensing=null;b.refreshPalette()},SpriteMorph.prototype.enableFirstClass,"uncheck to disable support\nfor first-class sprites","check to enable support\n for first-class sprite",!0);a("Keyboard Editing", -function(){ScriptsMorph.prototype.enableKeyboard=!ScriptsMorph.prototype.enableKeyboard;b.currentSprite.scripts.updateToolbar();ScriptsMorph.prototype.enableKeyboard?b.removeSetting("keyboard"):b.saveSetting("keyboard",!1)},ScriptsMorph.prototype.enableKeyboard,"uncheck to disable\nkeyboard editing support","check to enable\nkeyboard editing support",!0);a("Table support",function(){List.prototype.enableTables=!List.prototype.enableTables;List.prototype.enableTables?b.removeSetting("tables"):b.saveSetting("tables", -!1)},List.prototype.enableTables,"uncheck to disable\nmulti-column list views","check for multi-column\nlist view support",!0);List.prototype.enableTables&&a("Table lines",function(){TableMorph.prototype.highContrast=!TableMorph.prototype.highContrast;TableMorph.prototype.highContrast?b.saveSetting("tableLines",!0):b.removeSetting("tableLines")},TableMorph.prototype.highContrast,"uncheck for less contrast\nmulti-column list views","check for higher contrast\ntable views",!0);a("Live coding support", -function(){return Process.prototype.enableLiveCoding=!Process.prototype.enableLiveCoding},Process.prototype.enableLiveCoding,"EXPERIMENTAL! uncheck to disable live\ncustom control structures","EXPERIMENTAL! check to enable\n live custom control structures",!0);a("JIT compiler support",function(){Process.prototype.enableCompiling=!Process.prototype.enableCompiling;b.currentSprite.blocksCache.operators=null;b.currentSprite.paletteCache.operators=null;b.refreshPalette()},Process.prototype.enableCompiling, -"EXPERIMENTAL! uncheck to disable live\nsupport for compiling","EXPERIMENTAL! check to enable\nsupport for compiling",!0);!1!==SnapActions.supportsCollaboration&&a("Collaborative editing","toggleCollaborativeEditing",SnapActions.isCollaborating(),"uncheck to disable Google Docs-style collaboration","check to enable Google Docs-style collaboration",!1);a("Replay Mode",function(){if(b.isReplayMode){if(b.isPreviousVersion()){b.confirm("Exiting replay mode now will revert the project to\nthe current point in history (losing any unapplied changes)\n\nAre you sure you want to exit replay mode?", -"Exit Replay Mode?",function(){return b.exitReplayMode()});return}return b.exitReplayMode()}if(2>SnapUndo.allEvents.length)return b.showMessage("Nothing to replay!",2);SnapActions.isCollaborating()?b.confirm("Cannot enter replay mode while collaborating. \nWould you like to disable collaboration and enter replay mode?","Disable Collaboration?",function(){SnapActions.disableCollaboration();b.replayEvents()}):b.replayEvents()},this.isReplayMode,"uncheck to disable replay mode","check to enable replay mode", -!1);a("Save replay history",function(){SnapSerializer.prototype.isSavingHistory=!SnapSerializer.prototype.isSavingHistory},SnapSerializer.prototype.isSavingHistory,"uncheck to only save project","check to save replay with project",!1);a("Messaging while collaborating?",function(){var h,k,l;return $jscomp.asyncExecutePromiseGeneratorProgram(function(m){if(1==m.nextAddress){if(b.allowMsgsWhileCollaborating)return b.allowMsgsWhileCollaborating=!b.allowMsgsWhileCollaborating,m.jumpTo(0);h=localize("Send messages while collaborating?"); -k=localize("By default, message sending is disabled when collaborating because it can make\ndebugging distributed applications difficult.\n\n")+localize("When multiple users collaborate, each collaborating user may send his/her own response\nto a received message. ")+localize('This is problematic when using the "send msg and wait"\nblock as well as for applications like turn-based games.\n\n')+localize("Would you like to enable message sending while collaborating?");return m.yield(b.confirm(k,h), -3)}if(l=m.yieldResult)b.allowMsgsWhileCollaborating=!b.allowMsgsWhileCollaborating;m.jumpToEnd()})},this.allowMsgsWhileCollaborating,"uncheck to block message sending while multiple users occupy a single role","check to allow message sending while multiple users occupy a single role",!1);g.addLine();a("Thread safe scripts",function(){return c.isThreadSafe=!c.isThreadSafe},this.stage.isThreadSafe,"uncheck to allow\nscript reentrance","check to disallow\nscript reentrance");a("Prefer smooth animations", -"toggleVariableFrameRate",StageMorph.prototype.frameRate,"uncheck for greater speed\nat variable frame rates","check for smooth, predictable\nanimations across computers",!0);a("Flat line ends",function(){return SpriteMorph.prototype.useFlatLineEnds=!SpriteMorph.prototype.useFlatLineEnds},SpriteMorph.prototype.useFlatLineEnds,"uncheck for round ends of lines","check for flat ends of lines");a("Codification support",function(){StageMorph.prototype.enableCodeMapping=!StageMorph.prototype.enableCodeMapping; -b.currentSprite.blocksCache.variables=null;b.currentSprite.paletteCache.variables=null;b.refreshPalette()},StageMorph.prototype.enableCodeMapping,"uncheck to disable\nblock to text mapping features","check for block\nto text mapping features",!1);a("Hyper blocks support",function(){return Process.prototype.enableHyperOps=!Process.prototype.enableHyperOps},Process.prototype.enableHyperOps,"uncheck to disable\nusing operators on lists and tables","check to enable\nusing operators on lists and tables", -!1);a("Persist linked sublist IDs",function(){return StageMorph.prototype.enableSublistIDs=!StageMorph.prototype.enableSublistIDs},StageMorph.prototype.enableSublistIDs,"uncheck to disable\nsaving linked sublist identities","check to enable\nsaving linked sublist identities",!0);a("Enable command drops in all rings",function(){return RingReporterSlotMorph.prototype.enableCommandDrops=!RingReporterSlotMorph.prototype.enableCommandDrops},RingReporterSlotMorph.prototype.enableCommandDrops,"uncheck to disable\ndropping commands in reporter rings", -"check to enable\ndropping commands in all rings",!0);return g}; -IDE_Morph.prototype.loadExtension=function(a){var b=this,c;return $jscomp.asyncExecutePromiseGeneratorProgram(function(d){if(1==d.nextAddress)return d.yield(b.isTrustedExtension(a),2);d.yieldResult&&(c=document.createElement("script"),c.setAttribute("src",a),c.setAttribute("type","text/javascript"),c.onerror=function(){b.inform("Error Loading Extension","The extension at: \n\n"+a+"\n\ncould not be loaded.")},document.body.appendChild(c));d.jumpToEnd()})}; -IDE_Morph.prototype.isTrustedExtension=function(a){var b=this,c,d,e;return $jscomp.asyncExecutePromiseGeneratorProgram(function(f){if(1==f.nextAddress){c=["/",window.location.origin,"https://extensions.netsblox.org"];if(d=c.some(function(g){return a.startsWith(g)}))return f.return(!0);e="An untrusted third-party extension was encountered and\nrequires approval to load:\n\n"+a+"\n\nIf the above URL is not recognized or trusted, installation is not \nrecommended as third-party extensions could be malicious.\n\nWould you like to install this extension?"; -return f.yield(b.confirm(e,"Install Third-Party Extension?"),2)}return f.return(f.yieldResult)})}; -IDE_Morph.prototype.projectMenu=function(){var a=this;var b=this.world();var c=this.currentSprite instanceof SpriteMorph?"Costumes":"Backgrounds",d=16===b.currentKey;b=new MenuMorph(this);b.addItem("Project notes...","editProjectNotes");b.addLine();b.addPair("New","createNewProject","^N");b.addPair("Open...","openProjectsBrowser","^O");b.addPair("Save","save","^S");b.addItem("Save As...","saveAs");d&&b.addItem(localize("Replay events from file"),function(){var e=document.createElement("input");1< -SnapUndo.allEvents.length&&a.newProject();a.filePicker&&(document.body.removeChild(a.filePicker),a.filePicker=null);e.type="file";e.style.color="transparent";e.style.backgroundColor="transparent";e.style.border="none";e.style.outline="none";e.style.position="absolute";e.style.top="0px";e.style.left="0px";e.style.width="0px";e.style.height="0px";e.addEventListener("change",function(){var f=new FileReader;document.body.removeChild(e);this.filePicker=null;f.onloadend=function(g){return this.loadReplayFromXml(g.target.result)}; -f.readAsText(e.files[0])},!1);document.body.appendChild(e);a.filePicker=e;e.click()},"Load project replay from the beginning",new Color(100,0,0));b.addLine();b.addItem("Import...","importLocalFile","file menu import hint");d&&(b.addItem(localize("Export project...")+" "+localize("(in a new window)"),function(){a.projectName?a.exportProject(a.projectName,d):a.prompt("Export Project As...",function(e){return a.exportProject(e,!1)},null,"exportProject")},"show project data as XML\nin a new browser window", -new Color(100,0,0)),b.addItem(localize("Export project without history..."),function(){var e=a.serializer.isSavingHistory;a.projectName?(a.serializer.isSavingHistory=!1,a.exportProject(a.projectName,d),a.serializer.isSavingHistory=e):a.prompt("Export Project As...",function(f){this.serializer.isSavingHistory=!1;this.exportProject(f,d);this.serializer.isSavingHistory=e},null,"exportProject")},null,new Color(100,0,0)));b.addItem(d?"Export project as plain text...":"Export project...",function(){a.projectName? -a.exportProject(a.projectName,d):a.prompt("Export Project As...",function(e){return a.exportProject(e,d)},null,"exportProject")},"save project data as XML\nto your downloads folder",d?new Color(100,0,0):null);this.stage.globalBlocks.length&&(b.addItem("Export blocks...",function(){return a.exportGlobalBlocks()},"save global custom block\ndefinitions as XML"),SnapCloud.username&&b.addItem("Save blocks...","createLibrary","save custom blocks to the cloud as a library"),b.addItem("Unused blocks...", -function(){return a.removeUnusedBlocks()},"find unused global custom blocks\nand remove their definitions"));b.addItem("Export summary...",function(){return a.exportProjectSummary()},"save a summary\nof this project");d&&(b.addItem("Export summary with drop-shadows...",function(){return a.exportProjectSummary(!0)},"download and save\nwith a summary of this project\nwith drop-shadows on all pictures.\nnot supported by all browsers",new Color(100,0,0)),b.addItem("Export all scripts as pic...",function(){return a.exportScriptsPicture()}, -"show a picture of all scripts\nand block definitions",new Color(100,0,0)));b.addLine();b.addItem("Libraries...",function(){"file:"===location.protocol?a.importLocalFile():(new LibraryDialogMorph(a)).popUp(a.world())},"Select categories of additional blocks to add to this project.");b.addItem(localize(c)+"...",function(){"file:"===location.protocol?a.importLocalFile():a.importMedia(c)},"Select a costume from the media library");b.addItem(localize("Sounds")+"...",function(){"file:"===location.protocol? -a.importLocalFile():a.importMedia("Sounds")},"Select a sound from the media library");return b};IDE_Morph.prototype.replayEvents=function(a,b){b=!!b;a||(b=!0,a=JSON.parse(JSON.stringify(SnapUndo.allEvents)));this.replayControls.enable();this.replayControls.setActions(a,b);this.isReplayMode=!0;this.preReplayUndoState={};a=SnapUndo.allQueueIds();for(b=a.length;b--;)this.preReplayUndoState[a[b]]=SnapUndo.undoCount[a[b]]}; +a("Virtual keyboard","toggleVirtualKeyboard",MorphicPreferences.useVirtualKeyboard,"uncheck to disable\nvirtual keyboard support\nfor mobile devices","check to enable\nvirtual keyboard support\nfor mobile devices",!0);a("Clicking sound",()=>{BlockMorph.prototype.toggleSnapSound();BlockMorph.prototype.snapSound?this.saveSetting("click",!0):this.removeSetting("click")},BlockMorph.prototype.snapSound,"uncheck to turn\nblock clicking\nsound off","check to turn\nblock clicking\nsound on");a("Animations", +()=>this.isAnimating=!this.isAnimating,this.isAnimating,"uncheck to disable\nIDE animations","check to enable\nIDE animations",!0);a("Cache Inputs",()=>{BlockMorph.prototype.isCachingInputs=!BlockMorph.prototype.isCachingInputs},BlockMorph.prototype.isCachingInputs,"uncheck to stop caching\ninputs (for debugging the evaluator)","check to cache inputs\nboosts recursion",!0);a("Rasterize SVGs",()=>MorphicPreferences.rasterizeSVGs=!MorphicPreferences.rasterizeSVGs,MorphicPreferences.rasterizeSVGs,"uncheck for smooth\nscaling of vector costumes", +"check to rasterize\nSVGs on import",!0);a("Flat design",()=>{if(MorphicPreferences.isFlat)return this.defaultDesign();this.flatDesign()},MorphicPreferences.isFlat,"uncheck for default\nGUI design","check for alternative\nGUI design",!1);a("Nested auto-wrapping",()=>{ScriptsMorph.prototype.enableNestedAutoWrapping=!ScriptsMorph.prototype.enableNestedAutoWrapping;ScriptsMorph.prototype.enableNestedAutoWrapping?this.removeSetting("autowrapping"):this.saveSetting("autowrapping",!1)},ScriptsMorph.prototype.enableNestedAutoWrapping, +"uncheck to confine auto-wrapping\nto top-level block stacks","check to enable auto-wrapping\ninside nested block stacks",!0);a("Project URLs",()=>{(this.projectsInURLs=!this.projectsInURLs)?this.saveSetting("longurls",!0):this.removeSetting("longurls")},this.projectsInURLs,"uncheck to disable\nproject data in URLs","check to enable\nproject data in URLs",!0);a("Sprite Nesting",()=>SpriteMorph.prototype.enableNesting=!SpriteMorph.prototype.enableNesting,SpriteMorph.prototype.enableNesting,"uncheck to disable\nsprite composition", +"check to enable\nsprite composition",!0);a("First-Class Sprites",()=>{SpriteMorph.prototype.enableFirstClass=!SpriteMorph.prototype.enableFirstClass;this.currentSprite.blocksCache.sensing=null;this.currentSprite.paletteCache.sensing=null;this.refreshPalette()},SpriteMorph.prototype.enableFirstClass,"uncheck to disable support\nfor first-class sprites","check to enable support\n for first-class sprite",!0);a("Keyboard Editing",()=>{ScriptsMorph.prototype.enableKeyboard=!ScriptsMorph.prototype.enableKeyboard; +this.currentSprite.scripts.updateToolbar();ScriptsMorph.prototype.enableKeyboard?this.removeSetting("keyboard"):this.saveSetting("keyboard",!1)},ScriptsMorph.prototype.enableKeyboard,"uncheck to disable\nkeyboard editing support","check to enable\nkeyboard editing support",!0);a("Table support",()=>{List.prototype.enableTables=!List.prototype.enableTables;List.prototype.enableTables?this.removeSetting("tables"):this.saveSetting("tables",!1)},List.prototype.enableTables,"uncheck to disable\nmulti-column list views", +"check for multi-column\nlist view support",!0);List.prototype.enableTables&&a("Table lines",()=>{TableMorph.prototype.highContrast=!TableMorph.prototype.highContrast;TableMorph.prototype.highContrast?this.saveSetting("tableLines",!0):this.removeSetting("tableLines")},TableMorph.prototype.highContrast,"uncheck for less contrast\nmulti-column list views","check for higher contrast\ntable views",!0);a("Live coding support",()=>Process.prototype.enableLiveCoding=!Process.prototype.enableLiveCoding,Process.prototype.enableLiveCoding, +"EXPERIMENTAL! uncheck to disable live\ncustom control structures","EXPERIMENTAL! check to enable\n live custom control structures",!0);a("JIT compiler support",()=>{Process.prototype.enableCompiling=!Process.prototype.enableCompiling;this.currentSprite.blocksCache.operators=null;this.currentSprite.paletteCache.operators=null;this.refreshPalette()},Process.prototype.enableCompiling,"EXPERIMENTAL! uncheck to disable live\nsupport for compiling","EXPERIMENTAL! check to enable\nsupport for compiling", +!0);!1!==SnapActions.supportsCollaboration&&a("Collaborative editing","toggleCollaborativeEditing",SnapActions.isCollaborating(),"uncheck to disable Google Docs-style collaboration","check to enable Google Docs-style collaboration",!1);a("Replay Mode",()=>{if(this.isReplayMode){if(this.isPreviousVersion()){this.confirm("Exiting replay mode now will revert the project to\nthe current point in history (losing any unapplied changes)\n\nAre you sure you want to exit replay mode?","Exit Replay Mode?", +()=>this.exitReplayMode());return}return this.exitReplayMode()}if(2>SnapUndo.allEvents.length)return this.showMessage("Nothing to replay!",2);SnapActions.isCollaborating()?this.confirm("Cannot enter replay mode while collaborating. \nWould you like to disable collaboration and enter replay mode?","Disable Collaboration?",()=>{SnapActions.disableCollaboration();this.replayEvents()}):this.replayEvents()},this.isReplayMode,"uncheck to disable replay mode","check to enable replay mode",!1);a("Save replay history", +function(){SnapSerializer.prototype.isSavingHistory=!SnapSerializer.prototype.isSavingHistory},SnapSerializer.prototype.isSavingHistory,"uncheck to only save project","check to save replay with project",!1);a("Messaging while collaborating?",async()=>{if(this.allowMsgsWhileCollaborating)this.allowMsgsWhileCollaborating=!this.allowMsgsWhileCollaborating;else{const g=localize("Send messages while collaborating?"),h=localize("By default, message sending is disabled when collaborating because it can make\ndebugging distributed applications difficult.\n\n")+ +localize("When multiple users collaborate, each collaborating user may send his/her own response\nto a received message. ")+localize('This is problematic when using the "send msg and wait"\nblock as well as for applications like turn-based games.\n\n')+localize("Would you like to enable message sending while collaborating?");await this.confirm(h,g)&&(this.allowMsgsWhileCollaborating=!this.allowMsgsWhileCollaborating)}},this.allowMsgsWhileCollaborating,"uncheck to block message sending while multiple users occupy a single role", +"check to allow message sending while multiple users occupy a single role",!1);f.addLine();a("Thread safe scripts",()=>b.isThreadSafe=!b.isThreadSafe,this.stage.isThreadSafe,"uncheck to allow\nscript reentrance","check to disallow\nscript reentrance");a("Prefer smooth animations","toggleVariableFrameRate",StageMorph.prototype.frameRate,"uncheck for greater speed\nat variable frame rates","check for smooth, predictable\nanimations across computers",!0);a("Flat line ends",()=>SpriteMorph.prototype.useFlatLineEnds= +!SpriteMorph.prototype.useFlatLineEnds,SpriteMorph.prototype.useFlatLineEnds,"uncheck for round ends of lines","check for flat ends of lines");a("Codification support",()=>{StageMorph.prototype.enableCodeMapping=!StageMorph.prototype.enableCodeMapping;this.currentSprite.blocksCache.variables=null;this.currentSprite.paletteCache.variables=null;this.refreshPalette()},StageMorph.prototype.enableCodeMapping,"uncheck to disable\nblock to text mapping features","check for block\nto text mapping features", +!1);a("Hyper blocks support",()=>Process.prototype.enableHyperOps=!Process.prototype.enableHyperOps,Process.prototype.enableHyperOps,"uncheck to disable\nusing operators on lists and tables","check to enable\nusing operators on lists and tables",!1);a("Persist linked sublist IDs",()=>StageMorph.prototype.enableSublistIDs=!StageMorph.prototype.enableSublistIDs,StageMorph.prototype.enableSublistIDs,"uncheck to disable\nsaving linked sublist identities","check to enable\nsaving linked sublist identities", +!0);a("Enable command drops in all rings",()=>RingReporterSlotMorph.prototype.enableCommandDrops=!RingReporterSlotMorph.prototype.enableCommandDrops,RingReporterSlotMorph.prototype.enableCommandDrops,"uncheck to disable\ndropping commands in reporter rings","check to enable\ndropping commands in all rings",!0);return f}; +IDE_Morph.prototype.loadExtension=async function(a){if(await this.isTrustedExtension(a)){const b=document.createElement("script");b.setAttribute("src",a);b.setAttribute("type","text/javascript");b.onerror=()=>{this.inform("Error Loading Extension","The extension at: \n\n"+a+"\n\ncould not be loaded.")};document.body.appendChild(b)}}; +IDE_Morph.prototype.isTrustedExtension=async function(a){return["/",window.location.origin,"https://extensions.netsblox.org"].some(b=>a.startsWith(b))?!0:await this.confirm("An untrusted third-party extension was encountered and\nrequires approval to load:\n\n"+a+"\n\nIf the above URL is not recognized or trusted, installation is not \nrecommended as third-party extensions could be malicious.\n\nWould you like to install this extension?","Install Third-Party Extension?")}; +IDE_Morph.prototype.projectMenu=function(){var a=this.world();var b=this.currentSprite instanceof SpriteMorph?"Costumes":"Backgrounds",c=16===a.currentKey;a=new MenuMorph(this);a.addItem("Project notes...","editProjectNotes");a.addLine();a.addPair("New","createNewProject","^N");a.addPair("Open...","openProjectsBrowser","^O");a.addPair("Save","save","^S");a.addItem("Save As...","saveAs");c&&a.addItem(localize("Replay events from file"),()=>{var d=document.createElement("input");1{this.projectName?this.exportProject(this.projectName,c):this.prompt("Export Project As...",d=>this.exportProject(d,!1),null,"exportProject")},"show project data as XML\nin a new browser window", +new Color(100,0,0)),a.addItem(localize("Export project without history..."),()=>{var d=this.serializer.isSavingHistory;this.projectName?(this.serializer.isSavingHistory=!1,this.exportProject(this.projectName,c),this.serializer.isSavingHistory=d):this.prompt("Export Project As...",function(e){this.serializer.isSavingHistory=!1;this.exportProject(e,c);this.serializer.isSavingHistory=d},null,"exportProject")},null,new Color(100,0,0)));a.addItem(c?"Export project as plain text...":"Export project...", +()=>{this.projectName?this.exportProject(this.projectName,c):this.prompt("Export Project As...",d=>this.exportProject(d,c),null,"exportProject")},"save project data as XML\nto your downloads folder",c?new Color(100,0,0):null);this.stage.globalBlocks.length&&(a.addItem("Export blocks...",()=>this.exportGlobalBlocks(),"save global custom block\ndefinitions as XML"),SnapCloud.username&&a.addItem("Save blocks...","createLibrary","save custom blocks to the cloud as a library"),a.addItem("Unused blocks...", +()=>this.removeUnusedBlocks(),"find unused global custom blocks\nand remove their definitions"));a.addItem("Export summary...",()=>this.exportProjectSummary(),"save a summary\nof this project");c&&(a.addItem("Export summary with drop-shadows...",()=>this.exportProjectSummary(!0),"download and save\nwith a summary of this project\nwith drop-shadows on all pictures.\nnot supported by all browsers",new Color(100,0,0)),a.addItem("Export all scripts as pic...",()=>this.exportScriptsPicture(),"show a picture of all scripts\nand block definitions", +new Color(100,0,0)));a.addLine();a.addItem("Libraries...",()=>{"file:"===location.protocol?this.importLocalFile():(new LibraryDialogMorph(this)).popUp(this.world())},"Select categories of additional blocks to add to this project.");a.addItem(localize(b)+"...",()=>{"file:"===location.protocol?this.importLocalFile():this.importMedia(b)},"Select a costume from the media library");a.addItem(localize("Sounds")+"...",()=>{"file:"===location.protocol?this.importLocalFile():this.importMedia("Sounds")},"Select a sound from the media library"); +return a};IDE_Morph.prototype.replayEvents=function(a,b){b=!!b;a||(b=!0,a=JSON.parse(JSON.stringify(SnapUndo.allEvents)));this.replayControls.enable();this.replayControls.setActions(a,b);this.isReplayMode=!0;this.preReplayUndoState={};a=SnapUndo.allQueueIds();for(b=a.length;b--;)this.preReplayUndoState[a[b]]=SnapUndo.undoCount[a[b]]}; IDE_Morph.prototype.exitReplayMode=function(){if(this.isReplayMode){this.isReplayMode=!1;var a=this;SnapUndo.allQueueIds().filter(function(b){return a.preReplayUndoState[b]!==SnapUndo.undoCount[b]}).forEach(function(b){SnapUndo.trim(b)});SnapUndo.allEvents=this.replayControls.getCurrentHistory();this.activeEditor.onSetActive();this.replayControls.disable()}};IDE_Morph.prototype.resourceURL=function(){return Array.prototype.slice.call(arguments,0).join("/")}; -IDE_Morph.prototype.getMediaListFromURL=function(a,b){function c(e,f){return e.name.toLowerCase()b.length||c.push({fileName:b[0],name:b[1],description:2r&&(m=0,n+=q.height())});e.contents.adjustBounds();this.label.setCenter(this.center());this.label.setTop(this.top()+(l-this.label.height())/2);this.buttons.setCenter(this.center());this.buttons.setBottom(this.bottom()-this.padding);this.removeShadow();this.addShadow()};b.forEach(function(l){var m=c.resourceURL(a,l.fileName),n=new Image,p=m.slice(m.lastIndexOf(".")+1).toLowerCase(),r="svg"===p&&!MorphicPreferences.rasterizeSVGs;p=contains(["wav","mp3"],p);var q=p?new SoundIconMorph(new Sound(new Audio, -l.name)):new CostumeIconMorph(new Costume(g.getImage(),l.name));q.isDraggable=!1;q.userMenu=nop;q.action=function(){if(f!==q){var t=f;f=q;t&&t.refresh()}};q.doubleClickAction=d.ok;q.query=function(){return q===f};e.addContents(q);p?(q.object.audio.onloadeddata=function(){q.createThumbnail();q.fixLayout();q.refresh()},q.object.audio.src=m,q.object.audio.load()):r?(n.onload=function(){q.object=new SVG_Costume(n,l.name);q.refresh()},c.getURL(m,function(t){return n.src="data:image/svg+xml;base64,"+window.btoa(t)})): -(n.onload=function(){var t=newCanvas(new Point(n.width,n.height),!0);t.getContext("2d").drawImage(n,0,0);q.object=new Costume(t,l.name);q.refresh()},n.src=m)});d.popUp(k);d.setExtent(new Point(400,300));d.setCenter(k.center());new HandleMorph(d,300,280,d.corner,d.corner)}; -IDE_Morph.prototype.aboutSnap=function(){function a(q){q=new TextMorph(q,h.fontSize,h.fontStyle,!0,!1,"center",null,null,MorphicPreferences.isFlat?null:new Point(1,1),WHITE);var t=d.height()-10*h.titleFontSize;if(q.height()>t){var u=new ScrollFrameMorph;u.acceptsDrops=!1;u.contents.acceptsDrops=!1;u.bounds.setWidth(q.width());u.bounds.setHeight(t);u.addContents(q);u.color=new Color(0,0,0,0);return u}return q}var b="",c,d=this.world();var e=localize("License")+"\n\nSnap! is free software: you can redistribute it and/or modify\nit under the terms of the GNU Affero General Public License as\npublished by the Free Software Foundation, either version 3 of\nthe License, or (at your option) any later version.\n\nThis program is distributed in the hope that it will be useful,\nbut WITHOUT ANY WARRANTY; without even the implied warranty of\nMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\nGNU Affero General Public License for more details.\n\nYou should have received a copy of the\nGNU Affero General Public License along with this program.\nIf not, see http://www.gnu.org/licenses/\n\nWant to use Snap! but scared by the open-source license?\nGet in touch with us, we'll make it work."; +IDE_Morph.prototype.getMediaListFromURL=function(a,b){function c(d,e){return d.name.toLowerCase(){d=this.parseResourceFile(d);d.sort(c);b.call(this,d)});else return a=this.parseResourceFile(this.getURL(a)),a.sort(c),a};IDE_Morph.prototype.getMediaList=function(a,b){a=this.resourceURL(a,a.toUpperCase());return this.getMediaListFromURL.call(this,a,b)}; +IDE_Morph.prototype.parseResourceFile=function(a){var b,c=[];a.split("\n").map(d=>d.trim()).filter(d=>0{b=d.split("\t").map(e=>e.trim());2>b.length||c.push({fileName:b[0],name:b[1],description:2{document.body.removeChild(a);this.filePicker= +null;b.hand.processDrop(a.files)},!1);document.body.appendChild(a);this.filePicker=a;a.click()};IDE_Morph.prototype.importMedia=function(a){var b=this.showMessage("Opening "+a+"...");this.getMediaList(a,c=>{b.destroy();this.popupMediaImportDialog(a,c)})}; +IDE_Morph.prototype.popupMediaImportDialog=function(a,b){var c=(new DialogBoxMorph).withKey("import"+a),d=new ScrollFrameMorph,e=null,f=new SymbolMorph("turtle",60),g=this,h=this.world();d.acceptsDrops=!1;d.contents.acceptsDrops=!1;d.color=g.groupColor;d.fixLayout=nop;c.labelString=a;c.createLabel();c.addBody(d);c.addButton("ok","Import");c.addButton("cancel","Close");c.ok=function(){e&&(e.object instanceof Sound?g.droppedAudio(e.object.copy().audio,e.labelString):e.object instanceof SVG_Costume? +g.droppedSVG(e.object.contents,e.labelString):g.droppedImage(e.object.contents,e.labelString))};c.fixLayout=function(){var k=fontHeight(this.titleFontSize)+2*this.titlePadding,l=0,m=0;this.buttons.fixLayout();this.body.setPosition(this.position().add(new Point(this.padding,k+this.padding)));this.body.setExtent(new Point(this.width()-2*this.padding,this.height()-3*this.padding-k-this.buttons.height()));var n=this.body.position();var p=this.body.width();d.contents.children.forEach(function(q){q.setPosition(n.add(new Point(l, +m)));l+=q.width();l+q.width()>p&&(l=0,m+=q.height())});d.contents.adjustBounds();this.label.setCenter(this.center());this.label.setTop(this.top()+(k-this.label.height())/2);this.buttons.setCenter(this.center());this.buttons.setBottom(this.bottom()-this.padding);this.removeShadow();this.addShadow()};b.forEach(k=>{var l=this.resourceURL(a,k.fileName),m=new Image,n=l.slice(l.lastIndexOf(".")+1).toLowerCase(),p="svg"===n&&!MorphicPreferences.rasterizeSVGs;n=contains(["wav","mp3"],n);var q=n?new SoundIconMorph(new Sound(new Audio, +k.name)):new CostumeIconMorph(new Costume(f.getImage(),k.name));q.isDraggable=!1;q.userMenu=nop;q.action=function(){if(e!==q){var r=e;e=q;r&&r.refresh()}};q.doubleClickAction=c.ok;q.query=function(){return q===e};d.addContents(q);n?(q.object.audio.onloadeddata=function(){q.createThumbnail();q.fixLayout();q.refresh()},q.object.audio.src=l,q.object.audio.load()):p?(m.onload=function(){q.object=new SVG_Costume(m,k.name);q.refresh()},this.getURL(l,r=>m.src="data:image/svg+xml;base64,"+window.btoa(r))): +(m.onload=function(){var r=newCanvas(new Point(m.width,m.height),!0);r.getContext("2d").drawImage(m,0,0);q.object=new Costume(r,k.name);q.refresh()},m.src=l)});c.popUp(h);c.setExtent(new Point(400,300));c.setCenter(h.center());new HandleMorph(c,300,280,c.corner,c.corner)}; +IDE_Morph.prototype.aboutSnap=function(){function a(r){r=new TextMorph(r,h.fontSize,h.fontStyle,!0,!1,"center",null,null,MorphicPreferences.isFlat?null:new Point(1,1),WHITE);var t=d.height()-10*h.titleFontSize;if(r.height()>t){var u=new ScrollFrameMorph;u.acceptsDrops=!1;u.contents.acceptsDrops=!1;u.bounds.setWidth(r.width());u.bounds.setHeight(t);u.addContents(r);u.color=new Color(0,0,0,0);return u}return r}var b="",c,d=this.world();var e=localize("License")+"\n\nSnap! is free software: you can redistribute it and/or modify\nit under the terms of the GNU Affero General Public License as\npublished by the Free Software Foundation, either version 3 of\nthe License, or (at your option) any later version.\n\nThis program is distributed in the hope that it will be useful,\nbut WITHOUT ANY WARRANTY; without even the implied warranty of\nMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\nGNU Affero General Public License for more details.\n\nYou should have received a copy of the\nGNU Affero General Public License along with this program.\nIf not, see http://www.gnu.org/licenses/\n\nWant to use Snap! but scared by the open-source license?\nGet in touch with us, we'll make it work."; var f=localize("Contributors")+'\n\nNathan Dinsmore: Saving/Loading, Snap-Logo Design, \ncountless bugfixes and optimizations\nMichael Ball: Time/Date UI, Library Import Dialog,\ncountless bugfixes and optimizations\nBernat Romagosa: Countless contributions\nBartosz Leper: Retina Display Support\nZhenlei Jia and Dariusz Doro\u017calski: IME text editing\nKen Kahn: IME support and countless other contributions\nJosep Ferr\u00e0ndiz: Video Motion Detection\nJoan Guill\u00e9n: Countless contributions\nKartik Chandra: Paint Editor\nCarles Paredes: Initial Vector Paint Editor\n"Ava" Yuan Yuan, Dylan Servilla: Graphic Effects\nKyle Hotchkiss: Block search design\nBrian Broll: Many bugfixes and optimizations\nIan Reynolds: UI Design, Event Bindings, Sound primitives\nJadga H\u00fcgle: Icons and countless other contributions\nIvan Motyashov: Initial Squeak Porting\nLucas Karahadian: Piano Keyboard Design\nDavide Della Casa: Morphic Optimizations\nAchal Dave: Web Audio\nJoe Otto: Morphic Testing and Debugging'; for(c in modules)Object.prototype.hasOwnProperty.call(modules,c)&&(b+="\n"+c+" ("+modules[c]+")");""!==b&&(b=localize("current module versions:")+" \n\nmorphic ("+morphicVersion+")"+b);var g=localize("Translations")+"\n"+SnapTranslator.credits();var h=new DialogBoxMorph;h.inform("About Snap","Snap! 6.2.0 - dev -\nBuild Your Own Blocks\n\nCopyright \u24b8 2008-2020 Jens M\u00f6nig and Brian Harvey\njens@moenig.org, bh@cs.berkeley.edu\n\n Snap! is developed by the University of California, Berkeley and SAP \nwith support from the National Science Foundation (NSF),\nMIOsoft and YC Research.\nThe design of Snap! is influenced and inspired by Scratch,\nfrom the Lifelong Kindergarten group at the MIT Media Lab\n\nfor more information see https://snap.berkeley.edu", -d,this.logo.cachedTexture);var k=h.buttons.children[0];var l=h.addButton(function(){h.addBody(a(g));h.body.fixLayout();k.show();m.show();p.hide();r.hide();n.hide();l.hide();h.fixLayout();h.setCenter(d.center())},"Translators...");var m=h.addButton(function(){h.addBody(a("Snap! 6.2.0 - dev -\nBuild Your Own Blocks\n\nCopyright \u24b8 2008-2020 Jens M\u00f6nig and Brian Harvey\njens@moenig.org, bh@cs.berkeley.edu\n\n Snap! is developed by the University of California, Berkeley and SAP \nwith support from the National Science Foundation (NSF),\nMIOsoft and YC Research.\nThe design of Snap! is influenced and inspired by Scratch,\nfrom the Lifelong Kindergarten group at the MIT Media Lab\n\nfor more information see https://snap.berkeley.edu")); -h.body.fixLayout();k.show();m.hide();p.show();r.show();n.show();l.hide();h.fixLayout();h.setCenter(d.center())},"Back...");m.hide();var n=h.addButton(function(){h.addBody(a(e));h.body.fixLayout();k.show();m.show();p.hide();r.hide();n.hide();l.hide();h.fixLayout();h.setCenter(d.center())},"License...");var p=h.addButton(function(){h.addBody(a(b));h.body.fixLayout();k.show();m.show();p.hide();r.hide();n.hide();l.hide();h.fixLayout();h.setCenter(d.center())},"Modules...");var r=h.addButton(function(){h.addBody(a(f)); -h.body.fixLayout();k.show();m.show();l.show();p.hide();r.hide();n.hide();h.fixLayout();h.setCenter(d.center())},"Credits...");l.hide();h.fixLayout()}; -IDE_Morph.prototype.editProjectNotes=function(){var a=this,b=(new DialogBoxMorph).withKey("projectNotes"),c=new ScrollFrameMorph,d=new TextMorph(this.projectNotes||""),e=this.world();c.padding=6;c.setWidth(250);c.acceptsDrops=!1;c.contents.acceptsDrops=!1;d.setWidth(250-2*c.padding);d.setPosition(c.topLeft().add(c.padding));d.enableSelecting();d.isEditable=!0;c.setHeight(250);c.fixLayout=nop;c.edge=InputFieldMorph.prototype.edge;c.fontSize=InputFieldMorph.prototype.fontSize;c.typeInPadding=InputFieldMorph.prototype.typeInPadding; -c.contrast=InputFieldMorph.prototype.contrast;c.render=InputFieldMorph.prototype.render;c.drawRectBorder=InputFieldMorph.prototype.drawRectBorder;c.addContents(d);b.getInput=function(){return d.text};b.target=this;b.action=function(f){return a.projectNotes=f};b.justDropped=function(){return d.edit()};b.labelString="Project Notes";b.createLabel();b.addBody(c);b.addButton("ok","OK");b.addButton("cancel","Cancel");b.fixLayout();b.popUp(e);b.setCenter(e.center());d.edit()}; +d,this.logo.cachedTexture);var k=h.buttons.children[0];var l=h.addButton(()=>{h.addBody(a(g));h.body.fixLayout();k.show();m.show();p.hide();q.hide();n.hide();l.hide();h.fixLayout();h.setCenter(d.center())},"Translators...");var m=h.addButton(()=>{h.addBody(a("Snap! 6.2.0 - dev -\nBuild Your Own Blocks\n\nCopyright \u24b8 2008-2020 Jens M\u00f6nig and Brian Harvey\njens@moenig.org, bh@cs.berkeley.edu\n\n Snap! is developed by the University of California, Berkeley and SAP \nwith support from the National Science Foundation (NSF),\nMIOsoft and YC Research.\nThe design of Snap! is influenced and inspired by Scratch,\nfrom the Lifelong Kindergarten group at the MIT Media Lab\n\nfor more information see https://snap.berkeley.edu")); +h.body.fixLayout();k.show();m.hide();p.show();q.show();n.show();l.hide();h.fixLayout();h.setCenter(d.center())},"Back...");m.hide();var n=h.addButton(()=>{h.addBody(a(e));h.body.fixLayout();k.show();m.show();p.hide();q.hide();n.hide();l.hide();h.fixLayout();h.setCenter(d.center())},"License...");var p=h.addButton(()=>{h.addBody(a(b));h.body.fixLayout();k.show();m.show();p.hide();q.hide();n.hide();l.hide();h.fixLayout();h.setCenter(d.center())},"Modules...");var q=h.addButton(()=>{h.addBody(a(f)); +h.body.fixLayout();k.show();m.show();l.show();p.hide();q.hide();n.hide();h.fixLayout();h.setCenter(d.center())},"Credits...");l.hide();h.fixLayout()}; +IDE_Morph.prototype.editProjectNotes=function(){var a=(new DialogBoxMorph).withKey("projectNotes"),b=new ScrollFrameMorph,c=new TextMorph(this.projectNotes||""),d=this.world();b.padding=6;b.setWidth(250);b.acceptsDrops=!1;b.contents.acceptsDrops=!1;c.setWidth(250-2*b.padding);c.setPosition(b.topLeft().add(b.padding));c.enableSelecting();c.isEditable=!0;b.setHeight(250);b.fixLayout=nop;b.edge=InputFieldMorph.prototype.edge;b.fontSize=InputFieldMorph.prototype.fontSize;b.typeInPadding=InputFieldMorph.prototype.typeInPadding; +b.contrast=InputFieldMorph.prototype.contrast;b.render=InputFieldMorph.prototype.render;b.drawRectBorder=InputFieldMorph.prototype.drawRectBorder;b.addContents(c);a.getInput=()=>c.text;a.target=this;a.action=e=>this.projectNotes=e;a.justDropped=()=>c.edit();a.labelString="Project Notes";a.createLabel();a.addBody(b);a.addButton("ok","OK");a.addButton("cancel","Cancel");a.fixLayout();a.popUp(d);a.setCenter(d.center());c.edit()}; IDE_Morph.prototype.newProject=function(){this.source=this.cloud.username?"cloud":null;this.stage&&this.stage.destroy();"#lang:"!==location.hash.substr(0,6)&&(location.hash="");this.globalVariables=new VariableFrame;this.currentSprite=new SpriteMorph(this.globalVariables);this.sprites=new List([this.currentSprite]);StageMorph.prototype.dimensions=new Point(480,360);StageMorph.prototype.hiddenPrimitives={};StageMorph.prototype.codeMappings={};StageMorph.prototype.codeHeaders={};StageMorph.prototype.enableCodeMapping= !1;StageMorph.prototype.enableInheritance=!0;StageMorph.prototype.enableSublistIDs=!1;StageMorph.prototype.enablePenLogging=!1;SpriteMorph.prototype.useFlatLineEnds=!1;Process.prototype.enableLiveCoding=!1;Process.prototype.enableHyperOps=!0;this.setProjectName("");this.projectNotes="";this.createStage();this.add(this.stage);this.createCorral();this.selectSprite(this.stage.children[0]);this.fixLayout()}; IDE_Morph.prototype.isPreviousVersion=function(){if(!this.isReplayMode)return!1;var a=this.replayControls.actionIndex+1;return 0this.exportProject(a,!1),null,"exportProject"):this.room.name?"local"===this.source?this.saveProject(this.room.name):this.saveProjectToCloud(this.room.name):this.saveProjectsBrowser()}; +IDE_Morph.prototype.saveProject=function(a){this.nextSteps([()=>this.showMessage("Saving..."),()=>this.rawSaveProject(a)])}; IDE_Morph.prototype.rawSaveProject=function(a){var b;if(a)if(this.setProjectName(a),Process.prototype.isCatchingErrors)try{localStorage["-snap-project-"+a]=b=this.serializer.serialize(this.stage),this.setURL("#open:"+b),this.showMessage("Saved!",1)}catch(c){this.showMessage("Save failed: "+c)}else localStorage["-snap-project-"+a]=b=this.serializer.serialize(this.stage),this.setURL("#open:"+b),this.showMessage("Saved!",1)}; IDE_Morph.prototype.exportProject=function(a,b){if(a){var c=this.projectName;this.silentSetProjectName(a);b="data:text/"+b?"plain,":"xml,";try{var d=this.showMessage("Exporting");var e=this.serializer.serialize(this.stage);this.setURL("#open:"+b+encodeURIComponent(e));this.saveXMLAs(e,a);d.destroy();this.showMessage("Exported!",1)}catch(f){if(Process.prototype.isCatchingErrors)this.showMessage("Export failed: "+f);else throw f;}this.silentSetProjectName(c)}}; -IDE_Morph.prototype.exportGlobalBlocks=function(){var a=this;0this.saveXMLAs(a,b))).popUp(this.world()):this.inform("Export blocks/msg types","this project doesn't have any\ncustom global blocks or message types yet")}; +IDE_Morph.prototype.createLibrary=function(){if(0{const d=await this.promptLibraryNotes();(new LibraryDialogMorph(this,c,b,d)).popUp(this.world())});a.labelString="Save blocks / message types";a.createLabel();a.fixLayout();a.popUp(this.world())}else this.inform("Export blocks/msg types","this project doesn't have any\ncustom global blocks or message types yet")}; +IDE_Morph.prototype.promptLibraryNotes=function(){const a=utils.defer();var b=(new DialogBoxMorph).withKey("libraryNotes"),c=new ScrollFrameMorph,d=new TextMorph(""),e=b.ok,f=this.world();c.padding=6;c.setWidth(250);c.acceptsDrops=!1;c.contents.acceptsDrops=!1;d.setWidth(250-2*c.padding);d.setPosition(c.topLeft().add(c.padding));d.enableSelecting();d.isEditable=!0;c.setHeight(250);c.fixLayout=nop;c.edge=InputFieldMorph.prototype.edge;c.fontSize=InputFieldMorph.prototype.fontSize;c.typeInPadding=InputFieldMorph.prototype.typeInPadding; +c.contrast=InputFieldMorph.prototype.contrast;c.render=InputFieldMorph.prototype.render;c.drawRectBorder=InputFieldMorph.prototype.drawRectBorder;c.addContents(d);b.ok=function(){a.resolve(d.text);e.call(this)};b.justDropped=()=>d.edit();b.labelString="Library Notes";b.createLabel();b.addBody(c);b.addButton("ok","OK");b.addButton("cancel","Cancel");b.fixLayout();b.popUp(f);b.setCenter(f.center());d.edit();return a.promise}; +IDE_Morph.prototype.removeUnusedBlocks=function(){function a(){return c.filter(g=>contains(d,g)?!1:b.every((h,k)=>!h.usesBlockInstance(g,!0,k,d)))}for(var b=this.sprites.asArray().concat([this.stage]),c=this.stage.globalBlocks,d=[],e=!1,f;!e;)f=a(),f.length?d=d.concat(f):e=!0;0'+c+"";this.saveXMLAs(c,a.name)}; -IDE_Morph.prototype.exportScriptsPicture=function(){var a=[],b=0,c=0,d=0;this.sprites.asArray().forEach(function(g){a.push(g.getImage());a.push(g.scripts.scriptsPicture());g.customBlocks.forEach(function(h){return a.push(h.scriptsPicture())})});a.push(this.stage.getImage());a.push(this.stage.scripts.scriptsPicture());this.stage.customBlocks.forEach(function(g){return a.push(g.scriptsPicture())});this.stage.globalBlocks.forEach(function(g){return a.push(g.scriptsPicture())});a=a.filter(function(g){return!isNil(g)}); -a.forEach(function(g){b=Math.max(b,g.width);c+=g.height;c+=20});c-=20;var e=newCanvas(new Point(b,c));var f=e.getContext("2d");a.forEach(function(g){f.drawImage(g,0,d);d+=20;d+=g.height});this.saveCanvasAs(e,this.projectName||localize("Untitled"))}; -IDE_Morph.prototype.exportProjectSummary=function(a){function b(p,r,q){r||(r=m);return new XML_Element(p,q,r)}function c(p,r,q){r||(r="p");q||(q=m);return new XML_Element(r,p,q)}function d(p,r,q){r||(r=m);q=q?null:b("p",r);r=b("img",q||r);r.attributes.src=p.toDataURL();return r}function e(p){var r=p.names().sort(),q=!0,t;r.length&&(c(localize("Variables"),"h3"),r.forEach(function(u){q&&(t=b("ul"),q=!1);var v=b("li",t);u=new WatcherMorph(u,SpriteMorph.prototype.blockColor.variables,p,u);var w=u.cellMorph.contentsMorph; -w instanceof ListWatcherMorph&&w.expand();d(u.fullImage(),v).attributes.class="script"}))}function f(p){p.length&&(c(localize("Blocks"),"h3"),SpriteMorph.prototype.categories.forEach(function(r){var q=!0,t;p.forEach(function(u){if(u.category===r){q&&(c(localize(r[0].toUpperCase().concat(r.slice(1))),"h4"),t=b("ul"),q=!1);var v=b("li",t);var w=d(u.templateInstance().scriptPic(),v);w.attributes.class="script";u.sortedElements().forEach(function(y){d(y instanceof BlockMorph?y.scriptPic():y.fullImage(), -v).attributes.class="script"})}})}))}var g=this.stage;var h=this.projectName||localize("untitled");var k=new XML_Element("html");k.attributes.lang=SnapTranslator.language;var l=b("head",k);b("meta",l).attributes.charset="UTF-8";b("style",l,a?"img {vertical-align: top;filter: drop-shadow(2px 2px 4px rgba(0,0,0,0.5));-webkit-filter: drop-shadow(2px 2px 4px rgba(0,0,0,0.5));-ms-filter: drop-shadow(2px 2px 4px rgba(0,0,0,0.5));}.toc {vertical-align: middle;padding: 2px 1em 2px 1em;}":"img {vertical-align: top;}.toc {vertical-align: middle;padding: 2px 1em 2px 1em;}.sprite {border: 1px solid lightgray;}"); -c(h,"title",l);var m=b("body",k);c(h,"h1");0===location.hash.indexOf("#present:")?(c(location.toString(),"a",m).attributes.href=location.toString(),d(g.thumbnail(g.dimensions)).attributes.class="sprite",c(this.serializer.app,"h4")):(c(this.serializer.app,"h4"),d(g.thumbnail(g.dimensions)).attributes.class="sprite");Process.prototype.reportTextSplit(this.projectNotes,"line").asArray().forEach(function(p){return c(p)});c(localize("Contents"),"h4");var n=b("ul");this.sprites.asArray().concat([g]).forEach(function(p){var r= -b("li",n),q=p.scripts.sortedElements(),t=p.costumes.length();b("hr");d(p.thumbnail(new Point(40,40)),r,!0).attributes.class="toc";c(p.name,"a",r).attributes.href="#"+p.name;c(p.name,"h2").attributes.id=p.name;d(p.thumbnail(p.extent().divideBy(g.scale))).attributes.class="sprite";if(p instanceof SpriteMorph&&(p.exemplar&&(d(p.exemplar.thumbnail(new Point(40,40)),c(localize("Kind of")+" "+p.exemplar.name),!0).attributes.class="toc"),p.anchor&&(d(p.anchor.thumbnail(new Point(40,40)),c(localize("Part of")+ -" "+p.anchor.name),!0).attributes.class="toc"),p.parts.length)){c(localize("Parts"),"h3");var u=b("ul");p.parts.forEach(function(v){var w=b("li",u,v.name);d(v.thumbnail(new Point(40,40)),w,!0).attributes.class="toc"})}if(1"+k.toString(),"text/html;charset=utf-8",h)}; -IDE_Morph.prototype.openProjectString=function(a){var b=this,c;this.exitReplayMode();this.nextSteps([function(){return c=b.showMessage("Opening project...")},function(){return SnapActions.openProject(a).then(function(){return c.destroy()})}])}; -IDE_Morph.prototype.rawOpenProjectString=function(a){var b=this,c,d,e,f,g,h;return $jscomp.asyncExecutePromiseGeneratorProgram(function(k){switch(k.nextAddress){case 1:b.toggleAppMode(!1);b.spriteBar.tabBar.tabTo("scripts");StageMorph.prototype.hiddenPrimitives={};StageMorph.prototype.codeMappings={};StageMorph.prototype.codeHeaders={};StageMorph.prototype.enableCodeMapping=!1;StageMorph.prototype.enableInheritance=!0;StageMorph.prototype.enableSublistIDs=!1;StageMorph.prototype.enablePenLogging= -!1;Process.prototype.enableLiveCoding=!1;if(Process.prototype.isCatchingErrors)return k.setCatchFinallyBlocks(5),f=b.serializer,g=f.openProject,k.yield(b.serializer.load(a,b),7);d=b.serializer;e=d.openProject;return k.yield(b.serializer.load(a,b),4);case 4:c=e.call(d,k.yieldResult,b);k.jumpTo(3);break;case 7:c=g.call(f,k.yieldResult,b);k.leaveTryBlock(3);break;case 5:h=k.enterCatchBlock(),b.showMessage("Load failed: "+h);case 3:return b.stopFastTracking(),k.return(c)}})}; -IDE_Morph.prototype.openCloudDataString=function(a){var b=Math.round(a.length/1024);this.exitReplayMode();var c=this.showMessage("Opening project\n"+b+" KB...");return SnapActions.openProject(a).then(function(){return c.destroy()})}; -IDE_Morph.prototype.rawOpenCloudDataString=function(a,b){var c=this,d,e,f,g;return $jscomp.asyncExecutePromiseGeneratorProgram(function(h){switch(h.nextAddress){case 1:StageMorph.prototype.hiddenPrimitives={};StageMorph.prototype.codeMappings={};StageMorph.prototype.codeHeaders={};StageMorph.prototype.enableCodeMapping=!1;StageMorph.prototype.enableInheritance=!1;StageMorph.prototype.enableSublistIDs=!1;Process.prototype.enableLiveCoding=!1;Process.prototype.enablePenLogging=!1;SnapActions.disableCollaboration(); -SnapUndo.reset();if(Process.prototype.isCatchingErrors)return h.setCatchFinallyBlocks(5),a=b?a:c.serializer.parse(a),c.serializer.loadMediaModel(a.childNamed("media")),h.yield(c.serializer.loadProjectModel(a.childNamed("project"),c,a.attributes.remixID),7);a=b?a:c.serializer.parse(a);c.serializer.loadMediaModel(a.childNamed("media"));return h.yield(c.serializer.loadProjectModel(a.childNamed("project"),c,a.attributes.remixID),4);case 4:e=h.yieldResult;d=c.serializer.openProject(e,c);h.jumpTo(3);break; -case 7:f=h.yieldResult;d=c.serializer.openProject(f,c);h.leaveTryBlock(3);break;case 5:g=h.enterCatchBlock(),c.showMessage("Load failed: "+g);case 3:return c.stopFastTracking(),h.return(d)}})};IDE_Morph.prototype.uniqueIdForImport=function(a,b,c){var d=this;this.nextSteps([function(){nop()},function(){for(var e=d.serializer.parse(a),f=e.allChildren(),g=f.length;g--;)f[g].attributes&&(f[g].attributes.collabId=SnapActions.newId());c(e.toString())}])}; -IDE_Morph.prototype.openBlocksString=function(a,b,c){var d=this,e;this.nextSteps([function(){return e=d.showMessage("Opening blocks...")},function(){d.rawOpenBlocksString(a,b,c);e.destroy()}])}; +IDE_Morph.prototype.exportScriptsPicture=function(){var a=[],b=0,c=0,d=0;this.sprites.asArray().forEach(g=>{a.push(g.getImage());a.push(g.scripts.scriptsPicture());g.customBlocks.forEach(h=>a.push(h.scriptsPicture()))});a.push(this.stage.getImage());a.push(this.stage.scripts.scriptsPicture());this.stage.customBlocks.forEach(g=>a.push(g.scriptsPicture()));this.stage.globalBlocks.forEach(g=>a.push(g.scriptsPicture()));a=a.filter(g=>!isNil(g));a.forEach(g=>{b=Math.max(b,g.width);c+=g.height;c+=20}); +c-=20;var e=newCanvas(new Point(b,c));var f=e.getContext("2d");a.forEach(g=>{f.drawImage(g,0,d);d+=20;d+=g.height});this.saveCanvasAs(e,this.projectName||localize("Untitled"))}; +IDE_Morph.prototype.exportProjectSummary=function(a){function b(p,q,r){q||=m;return new XML_Element(p,r,q)}function c(p,q,r){q||="p";r||=m;return new XML_Element(q,p,r)}function d(p,q,r){q||=m;r=r?null:b("p",q);q=b("img",r||q);q.attributes.src=p.toDataURL();return q}function e(p){var q=p.names().sort(),r=!0,t;q.length&&(c(localize("Variables"),"h3"),q.forEach(u=>{r&&(t=b("ul"),r=!1);var v=b("li",t);u=new WatcherMorph(u,SpriteMorph.prototype.blockColor.variables,p,u);var w=u.cellMorph.contentsMorph; +w instanceof ListWatcherMorph&&w.expand();d(u.fullImage(),v).attributes.class="script"}))}function f(p){p.length&&(c(localize("Blocks"),"h3"),SpriteMorph.prototype.categories.forEach(q=>{var r=!0,t;p.forEach(u=>{if(u.category===q){r&&(c(localize(q[0].toUpperCase().concat(q.slice(1))),"h4"),t=b("ul"),r=!1);var v=b("li",t);var w=d(u.templateInstance().scriptPic(),v);w.attributes.class="script";u.sortedElements().forEach(y=>{d(y instanceof BlockMorph?y.scriptPic():y.fullImage(),v).attributes.class="script"})}})}))} +var g=this.stage;var h=this.projectName||localize("untitled");var k=new XML_Element("html");k.attributes.lang=SnapTranslator.language;var l=b("head",k);b("meta",l).attributes.charset="UTF-8";b("style",l,a?"img {vertical-align: top;filter: drop-shadow(2px 2px 4px rgba(0,0,0,0.5));-webkit-filter: drop-shadow(2px 2px 4px rgba(0,0,0,0.5));-ms-filter: drop-shadow(2px 2px 4px rgba(0,0,0,0.5));}.toc {vertical-align: middle;padding: 2px 1em 2px 1em;}":"img {vertical-align: top;}.toc {vertical-align: middle;padding: 2px 1em 2px 1em;}.sprite {border: 1px solid lightgray;}"); +c(h,"title",l);var m=b("body",k);c(h,"h1");0===location.hash.indexOf("#present:")?(c(location.toString(),"a",m).attributes.href=location.toString(),d(g.thumbnail(g.dimensions)).attributes.class="sprite",c(this.serializer.app,"h4")):(c(this.serializer.app,"h4"),d(g.thumbnail(g.dimensions)).attributes.class="sprite");Process.prototype.reportTextSplit(this.projectNotes,"line").asArray().forEach(p=>c(p));c(localize("Contents"),"h4");var n=b("ul");this.sprites.asArray().concat([g]).forEach(p=>{var q=b("li", +n),r=p.scripts.sortedElements(),t=p.costumes.length();b("hr");d(p.thumbnail(new Point(40,40)),q,!0).attributes.class="toc";c(p.name,"a",q).attributes.href="#"+p.name;c(p.name,"h2").attributes.id=p.name;d(p.thumbnail(p.extent().divideBy(g.scale))).attributes.class="sprite";if(p instanceof SpriteMorph&&(p.exemplar&&(d(p.exemplar.thumbnail(new Point(40,40)),c(localize("Kind of")+" "+p.exemplar.name),!0).attributes.class="toc"),p.anchor&&(d(p.anchor.thumbnail(new Point(40,40)),c(localize("Part of")+" "+ +p.anchor.name),!0).attributes.class="toc"),p.parts.length)){c(localize("Parts"),"h3");var u=b("ul");p.parts.forEach(v=>{var w=b("li",u,v.name);d(v.thumbnail(new Point(40,40)),w,!0).attributes.class="toc"})}if(1{var w=b("li",u,v.name);d(v.thumbnail(new Point(40,40)),w,!0).attributes.class="toc"});p.sounds.length()&&(c(localize("Sounds"),"h3"),u=b("ol"),p.sounds.asArray().forEach(v=>c(v.name,"li",u)));e(p.variables); +r.length&&(c(localize("Scripts"),"h3"),r.forEach(v=>{d(v instanceof BlockMorph?v.scriptPic():v.fullImage()).attributes.class="script"}));f(p.customBlocks)});a=g.globalVariables();if(Object.keys(a.vars).length||g.globalBlocks.length)b("hr"),c(localize("For all Sprites"),"a",b("li",n)).attributes.href="#global",c(localize("For all Sprites"),"h2").attributes.id="global",e(a),f(g.globalBlocks);this.saveFileAs(""+k.toString(),"text/html;charset=utf-8",h)}; +IDE_Morph.prototype.openProjectString=function(a){var b;this.exitReplayMode();this.nextSteps([()=>b=this.showMessage("Opening project..."),()=>SnapActions.openProject(a).then(()=>b.destroy())])}; +IDE_Morph.prototype.rawOpenProjectString=async function(a){this.toggleAppMode(!1);this.spriteBar.tabBar.tabTo("scripts");StageMorph.prototype.hiddenPrimitives={};StageMorph.prototype.codeMappings={};StageMorph.prototype.codeHeaders={};StageMorph.prototype.enableCodeMapping=!1;StageMorph.prototype.enableInheritance=!0;StageMorph.prototype.enableSublistIDs=!1;StageMorph.prototype.enablePenLogging=!1;Process.prototype.enableLiveCoding=!1;if(Process.prototype.isCatchingErrors)try{var b=this.serializer.openProject(await this.serializer.load(a, +this),this)}catch(c){this.showMessage("Load failed: "+c)}else b=this.serializer.openProject(await this.serializer.load(a,this),this);this.stopFastTracking();return b};IDE_Morph.prototype.openCloudDataString=function(a){const b=Math.round(a.length/1024);this.exitReplayMode();const c=this.showMessage("Opening project\n"+b+" KB...");return SnapActions.openProject(a).then(()=>c.destroy())}; +IDE_Morph.prototype.rawOpenCloudDataString=async function(a,b){StageMorph.prototype.hiddenPrimitives={};StageMorph.prototype.codeMappings={};StageMorph.prototype.codeHeaders={};StageMorph.prototype.enableCodeMapping=!1;StageMorph.prototype.enableInheritance=!1;StageMorph.prototype.enableSublistIDs=!1;Process.prototype.enableLiveCoding=!1;Process.prototype.enablePenLogging=!1;SnapActions.disableCollaboration();SnapUndo.reset();if(Process.prototype.isCatchingErrors)try{a=b?a:this.serializer.parse(a); +this.serializer.loadMediaModel(a.childNamed("media"));const d=await this.serializer.loadProjectModel(a.childNamed("project"),this,a.attributes.remixID);var c=this.serializer.openProject(d,this)}catch(d){this.showMessage("Load failed: "+d)}else a=b?a:this.serializer.parse(a),this.serializer.loadMediaModel(a.childNamed("media")),a=await this.serializer.loadProjectModel(a.childNamed("project"),this,a.attributes.remixID),c=this.serializer.openProject(a,this);this.stopFastTracking();return c}; +IDE_Morph.prototype.uniqueIdForImport=function(a,b,c){var d=this;this.nextSteps([function(){nop()},function(){for(var e=d.serializer.parse(a),f=e.allChildren(),g=f.length;g--;)f[g].attributes&&(f[g].attributes.collabId=SnapActions.newId());c(e.toString())}])};IDE_Morph.prototype.openBlocksString=function(a,b,c){var d;this.nextSteps([()=>d=this.showMessage("Opening blocks..."),()=>{this.rawOpenBlocksString(a,b,c);d.destroy()}])}; IDE_Morph.prototype.rawOpenBlocksString=function(a,b,c){if(Process.prototype.isCatchingErrors)try{var d=this.serializer.loadBlocks(a,this.stage)}catch(e){this.showMessage("Load failed: "+e)}else d=this.serializer.loadBlocks(a,this.stage);c?this.importCustomBlocks(d,b):(new BlockImportDialogMorph(d,this.stage,b)).popUp();return d}; -IDE_Morph.prototype.importCustomBlocks=function(a,b){var c=this;a.forEach(function(d){d.receiver=c.stage;c.stage.globalBlocks.push(d);c.stage.replaceDoubleDefinitionsFor(d)});this.flushPaletteCache();this.refreshPalette();this.showMessage("Imported Blocks Module"+(b?": "+b:"")+".",2);SnapActions.loadCustomBlocks(a)};IDE_Morph.prototype.openSpritesString=function(a){var b=this,c;this.nextSteps([function(){return c=b.showMessage("Opening sprite...")},function(){b.rawOpenSpritesString(a);c.destroy()}])}; +IDE_Morph.prototype.importCustomBlocks=function(a,b){var c=this;a.forEach(function(d){d.receiver=c.stage;c.stage.globalBlocks.push(d);c.stage.replaceDoubleDefinitionsFor(d)});this.flushPaletteCache();this.refreshPalette();this.showMessage("Imported Blocks Module"+(b?": "+b:"")+".",2);SnapActions.loadCustomBlocks(a)};IDE_Morph.prototype.openSpritesString=function(a){var b;this.nextSteps([()=>b=this.showMessage("Opening sprite..."),()=>{this.rawOpenSpritesString(a);b.destroy()}])}; IDE_Morph.prototype.rawOpenSpritesString=function(a){if(Process.prototype.isCatchingErrors)try{this.serializer.loadSprites(a,this)}catch(b){this.showMessage("Load failed: "+b)}else this.serializer.loadSprites(a,this)};IDE_Morph.prototype.openMediaString=function(a){if(Process.prototype.isCatchingErrors)try{this.serializer.loadMedia(a)}catch(b){this.showMessage("Load failed: "+b)}else this.serializer.loadMedia(a);this.showMessage("Imported Media Module.",2)}; -IDE_Morph.prototype.openScriptString=function(a){var b=this,c;return new Promise(function(d){b.nextSteps([function(){return c=b.showMessage("Opening script...")},function(){var e=b.rawOpenScriptString(a);c.destroy();d(e)}])})}; +IDE_Morph.prototype.openScriptString=function(a){var b;return new Promise(c=>{this.nextSteps([()=>b=this.showMessage("Opening script..."),()=>{const d=this.rawOpenScriptString(a);b.destroy();c(d)}])})}; IDE_Morph.prototype.rawOpenScriptString=function(a){if(Process.prototype.isCatchingErrors)try{var b=this.serializer.parse(a,this.currentSprite);var c=this.serializer.loadScript(b,this.currentSprite)}catch(d){this.showMessage("Load failed: "+d)}else b=this.serializer.loadScript(a,this.currentSprite),c=this.serializer.loadScript(b,this.currentSprite);return c}; -IDE_Morph.prototype.openDataString=function(a,b,c){var d=this,e;return $jscomp.asyncExecutePromiseGeneratorProgram(function(f){if(1==f.nextAddress)return e=d.showMessage(localize("Opening data...")),f.yield(utils.sleep(),2);if(3!=f.nextAddress)return f.yield(d.rawOpenDataString(a,b,c),3);e.destroy();f.jumpToEnd()})}; -IDE_Morph.prototype.rawOpenDataString=function(a,b,c){var d=this,e,f=this.currentSprite.globalVariables();switch(c){case "csv":var g=Process.prototype.parseCSV(a);break;case "json":g=Process.prototype.parseJSON(a);break;default:g=a}var h=function(k){var l=f.names(),m=k.indexOf("(");k=0>m?k:k.substring(0,m);m=1;for(var n=k;contains(l,n);)m+=1,n=k+"("+m+")";return n}(b||"data");return SnapActions.addVariable(h,!0).then(function(){f.setVar(h,g);d.currentSprite.toggleVariableWatcher(h,!0);d.flushBlocksCache("variables"); -d.currentCategory="variables";d.categories.children.forEach(function(k){k.refresh()});d.refreshPalette(!0);g instanceof List&&(e=new TableDialogMorph(g),e.labelString=localize(e.labelString)+": "+h,e.createLabel(),e.popUp(d.world()))})};IDE_Morph.prototype.openProject=function(a){a&&(this.showMessage("opening project\n"+a),this.setProjectName(a),a=localStorage["-snap-project-"+a],SnapActions.disableCollaboration(),SnapUndo.reset(),this.openProjectString(a),this.setURL("#open:"+a))}; +IDE_Morph.prototype.openDataString=async function(a,b,c){const d=this.showMessage(localize("Opening data..."));await utils.sleep();await this.rawOpenDataString(a,b,c);d.destroy()}; +IDE_Morph.prototype.rawOpenDataString=function(a,b,c){var d,e=this.currentSprite.globalVariables();switch(c){case "csv":var f=Process.prototype.parseCSV(a);break;case "json":f=Process.prototype.parseJSON(a);break;default:f=a}var g=function(h){var k=e.names(),l=h.indexOf("(");h=0>l?h:h.substring(0,l);l=1;for(var m=h;contains(k,m);)l+=1,m=h+"("+l+")";return m}(b||"data");return SnapActions.addVariable(g,!0).then(()=>{e.setVar(g,f);this.currentSprite.toggleVariableWatcher(g,!0);this.flushBlocksCache("variables"); +this.currentCategory="variables";this.categories.children.forEach(function(h){h.refresh()});this.refreshPalette(!0);f instanceof List&&(d=new TableDialogMorph(f),d.labelString=localize(d.labelString)+": "+g,d.createLabel(),d.popUp(this.world()))})};IDE_Morph.prototype.openProject=function(a){a&&(this.showMessage("opening project\n"+a),this.setProjectName(a),a=localStorage["-snap-project-"+a],SnapActions.disableCollaboration(),SnapUndo.reset(),this.openProjectString(a),this.setURL("#open:"+a))}; IDE_Morph.prototype.setURL=function(a){location.hash=this.projectsInURLs?a:""}; IDE_Morph.prototype.saveFileAs=function(a,b,c){var d=!1,e=this.world();var f=b.split("/")[1].split(";")[0];f="."+("plain"===f?"txt":f);try{d=!!new Blob}catch(h){}if(d){if(!(a instanceof Blob)){a=e=a;d=e.split(",");var g=0===e.indexOf("data:");if(g&&-1{b instanceof DialogBoxMorph?a.add(b):b.destroy()});this.flushBlocksCache();this.refreshPalette();a.reactToDropOf=b=>{b instanceof DialogBoxMorph||b instanceof MenuMorph||(a.hand.grabOrigin?b.slideBackTo(a.hand.grabOrigin):a.hand.grab(b))};this.showMessage("entering user mode", +1)};IDE_Morph.prototype.switchToDevMode=function(){var a=this.world();a.isDevMode=!0;Process.prototype.isCatchingErrors=!1;this.controlBar.updateLabel();this.isAutoFill=!1;this.isDraggable=!0;this.setExtent(a.extent().subtract(100));this.setPosition(a.position().add(20));this.flushBlocksCache();this.refreshPalette();delete a.reactToDropOf;this.showMessage("entering development mode.\n\nerror catching is turned off,\nuse the browser's web console\nto see error messages.")}; +IDE_Morph.prototype.flushBlocksCache=function(a){a?(this.stage.blocksCache[a]=null,this.stage.children.forEach(b=>{b instanceof SpriteMorph&&(b.blocksCache[a]=null)})):(this.stage.blocksCache={},this.stage.children.forEach(b=>{b instanceof SpriteMorph&&(b.blocksCache={})}));this.flushPaletteCache(a)}; +IDE_Morph.prototype.flushPaletteCache=function(a){a?(this.stage.paletteCache[a]=null,this.stage.children.forEach(b=>{b instanceof SpriteMorph&&(b.paletteCache[a]=null)})):(this.stage.paletteCache={},this.stage.children.forEach(b=>{b instanceof SpriteMorph&&(b.paletteCache={})}))}; +IDE_Morph.prototype.toggleZebraColoring=function(){var a=[];BlockMorph.prototype.zebraContrast=BlockMorph.prototype.zebraContrast?0:40;this.stage.children.concat(this.stage).forEach(b=>{isSnapObject(b)&&(a=a.concat(b.scripts.children.filter(c=>c instanceof BlockMorph)))});a.forEach(b=>b.fixBlockColor(null,!0))}; IDE_Morph.prototype.toggleDynamicInputLabels=function(){SyntaxElementMorph.prototype.dynamicInputLabels=!SyntaxElementMorph.prototype.dynamicInputLabels;if(Process.prototype.isCatchingErrors)try{var a=this.serializer.serialize(this.stage)}catch(b){this.showMessage("Serialization failed: "+b)}else a=this.serializer.serialize(this.stage);SpriteMorph.prototype.initBlocks();this.spriteBar.tabBar.tabTo("scripts");this.createCategories();this.createCorralBar();SnapUndo.reset();this.openProjectString(a)}; IDE_Morph.prototype.toggleBlurredShadows=function(){window.useBlurredShadows=!useBlurredShadows};IDE_Morph.prototype.toggleLongFormInputDialog=function(){InputSlotDialogMorph.prototype.isLaunchingExpanded=!InputSlotDialogMorph.prototype.isLaunchingExpanded;InputSlotDialogMorph.prototype.isLaunchingExpanded?this.saveSetting("longform",!0):this.removeSetting("longform")}; IDE_Morph.prototype.togglePlainPrototypeLabels=function(){BlockLabelPlaceHolderMorph.prototype.plainLabel=!BlockLabelPlaceHolderMorph.prototype.plainLabel;BlockLabelPlaceHolderMorph.prototype.plainLabel?this.saveSetting("plainprototype",!0):this.removeSetting("plainprototype")};IDE_Morph.prototype.togglePreferEmptySlotDrops=function(){ScriptsMorph.prototype.isPreferringEmptySlots=!ScriptsMorph.prototype.isPreferringEmptySlots}; @@ -2249,81 +2161,80 @@ IDE_Morph.prototype.toggleVirtualKeyboard=function(){MorphicPreferences.useVirtu IDE_Morph.prototype.setEmbedMode=function(){var a=this;this.isEmbedMode=!0;this.appModeColor=new Color(243,238,235);this.embedOverlay=new Morph;this.embedOverlay.color=new Color(128,128,128);this.embedOverlay.alpha=.5;this.embedPlayButton=new SymbolMorph("circleSolid");this.embedPlayButton.color=new Color(64,128,64);this.embedPlayButton.alpha=.75;this.embedPlayButton.flag=new SymbolMorph("flag");this.embedPlayButton.flag.color=new Color(128,255,128);this.embedPlayButton.flag.alpha=.75;this.embedPlayButton.add(this.embedPlayButton.flag); this.embedPlayButton.mouseClickLeft=function(){a.runScripts();a.embedOverlay.destroy();this.destroy()};this.controlBar.hide();this.add(this.embedOverlay);this.add(this.embedPlayButton);this.fixLayout()}; IDE_Morph.prototype.toggleAppMode=function(a){var b=this.world(),c=[this.logo,this.controlBar.cloudButton,this.controlBar.projectButton,this.controlBar.settingsButton,this.controlBar.steppingButton,this.controlBar.stageSizeButton,this.paletteHandle,this.stageHandle,this.corral,this.corralBar,this.spriteEditor,this.spriteBar,this.palette,this.categories];(this.isAppMode=isNil(a)?!this.isAppMode:a)?((this.wasSingleStepping=Process.prototype.enableSingleStepping)&&this.toggleSingleStepping(),this.setColor(this.appModeColor), -this.controlBar.setColor(this.color),this.controlBar.appModeButton.refresh(),c.forEach(function(d){return d.hide()}),b.children.forEach(function(d){d instanceof DialogBoxMorph&&d.hide()}),b.keyboardFocus instanceof ScriptFocusMorph&&b.keyboardFocus.stopEditing()):(this.wasSingleStepping&&!Process.prototype.enableSingleStepping&&this.toggleSingleStepping(),this.setColor(this.backgroundColor),this.controlBar.setColor(this.frameColor),c.forEach(function(d){return d.show()}),this.stage.setScale(1),b.children.forEach(function(d){d instanceof -DialogBoxMorph&&d.show()}),b.allChildren().filter(function(d){return d instanceof ScrollFrameMorph}).forEach(function(d){return d.adjustScrollBars()}),this.currentSprite===this.stage&&this.spriteBar.children.forEach(function(d){d instanceof PushButtonMorph&&d.hide()}),this.currentSprite.scripts.updateToolbar());this.setExtent(this.world().extent());this.isMobileDevice()&&this.isAppMode&&this.mobileMode.init()}; -IDE_Morph.prototype.toggleStageSize=function(a,b){function c(){e.isSmallStage=isNil(a)?!e.isSmallStage:a}function d(k){e.isSmallStage=!0;g.animations.push(new Animation(function(l){e.stageRatio=l;e.setExtent(g.extent())},function(){return e.stageRatio},k-e.stageRatio,f,null,function(){e.isSmallStage=1!==k;e.controlBar.stageSizeButton.refresh()}))}var e=this;b=b||.5;var f=this.isAnimating?100:0,g=this.world(),h=18===g.currentKey;16===g.currentKey?(b=3*SpriteIconMorph.prototype.thumbSize.x/this.stage.dimensions.x, -this.isSmallStage&&b!==this.stageRatio||c()):h?(b=this.width()/2/this.stage.dimensions.x,this.isSmallStage&&b!==this.stageRatio||c()):c();this.isSmallStage?d(b):d(1)};IDE_Morph.prototype.setPaletteWidth=function(a){var b=this,c=this.isAnimating?100:0,d=this.world();d.animations.push(new Animation(function(e){b.paletteWidth=e;b.setExtent(d.extent())},function(){return b.paletteWidth},a-this.paletteWidth,c))}; -IDE_Morph.prototype.createNewProject=function(){var a=this;this.confirm("Replace the current project with a new one?","New Project",function(){a.exitReplayMode();SnapActions.disableCollaboration();SnapUndo.reset();a.newProject()})};IDE_Morph.prototype.openProjectsBrowser=function(){"file:"===location.protocol?this.importLocalFile():(new ProjectDialogMorph(this,"open")).popUp(this.world())}; -IDE_Morph.prototype.saveProjectsBrowser=function(){var a=this;"file:"===location.protocol?this.prompt("Export Project As...",function(b){return a.exportProject(b,!1)},null,"exportProject"):("examples"===this.source&&(this.source=null),(new ProjectDialogMorph(this,"save")).popUp(this.world()))}; -IDE_Morph.prototype.microphoneMenu=function(){var a=new MenuMorph(this),b=this.world(),c=this.controlBar.settingsButton.bottomLeft(),d=this.stage.microphone,e=new SymbolMorph("tick",.75*MorphicPreferences.menuFontSize),f=new SymbolMorph("checkedBox",.75*MorphicPreferences.menuFontSize),g=e.fullCopy();g.render=nop;d.isReady&&(a.addItem([f,localize("Microphone")],function(){return d.stop()}),a.addLine());["low","normal","high","max"].forEach(function(h,k){a.addItem([d.resolution===k+1?e:g,localize(h)], -function(){return d.setResolution(k+1)})});a.popup(b,c)};IDE_Morph.prototype.languageMenu=function(){var a=this,b=new MenuMorph(this),c=this.world(),d=this.controlBar.settingsButton.bottomLeft(),e=new SymbolMorph("tick",.75*MorphicPreferences.menuFontSize),f=e.fullCopy();f.render=nop;SnapTranslator.languages().forEach(function(g){return b.addItem([SnapTranslator.language===g?e:f,SnapTranslator.languageName(g)],function(){a.loadNewProject=!1;a.setLanguage(g)})});b.popup(c,d)}; -IDE_Morph.prototype.setLanguage=function(a,b,c){var d=this,e=document.getElementById("language"),f=this.resourceURL("locale","lang-"+a+".js");SnapTranslator.unload();e&&document.head.removeChild(e);if("en"===a)return this.reflectLanguage("en",b,c);e=document.createElement("script");e.id="language";e.onload=function(){return d.reflectLanguage(a,b,c)};document.head.appendChild(e);e.src=f}; +this.controlBar.setColor(this.color),this.controlBar.appModeButton.refresh(),c.forEach(d=>d.hide()),b.children.forEach(d=>{d instanceof DialogBoxMorph&&d.hide()}),b.keyboardFocus instanceof ScriptFocusMorph&&b.keyboardFocus.stopEditing()):(this.wasSingleStepping&&!Process.prototype.enableSingleStepping&&this.toggleSingleStepping(),this.setColor(this.backgroundColor),this.controlBar.setColor(this.frameColor),c.forEach(d=>d.show()),this.stage.setScale(1),b.children.forEach(d=>{d instanceof DialogBoxMorph&& +d.show()}),b.allChildren().filter(d=>d instanceof ScrollFrameMorph).forEach(d=>d.adjustScrollBars()),this.currentSprite===this.stage&&this.spriteBar.children.forEach(d=>{d instanceof PushButtonMorph&&d.hide()}),this.currentSprite.scripts.updateToolbar());this.setExtent(this.world().extent());this.isMobileDevice()&&this.isAppMode&&this.mobileMode.init()}; +IDE_Morph.prototype.toggleStageSize=function(a,b){function c(){e.isSmallStage=isNil(a)?!e.isSmallStage:a}function d(k){e.isSmallStage=!0;g.animations.push(new Animation(l=>{e.stageRatio=l;e.setExtent(g.extent())},()=>e.stageRatio,k-e.stageRatio,f,null,()=>{e.isSmallStage=1!==k;e.controlBar.stageSizeButton.refresh()}))}var e=this;b=b||.5;var f=this.isAnimating?100:0,g=this.world(),h=18===g.currentKey;16===g.currentKey?(b=3*SpriteIconMorph.prototype.thumbSize.x/this.stage.dimensions.x,this.isSmallStage&& +b!==this.stageRatio||c()):h?(b=this.width()/2/this.stage.dimensions.x,this.isSmallStage&&b!==this.stageRatio||c()):c();this.isSmallStage?d(b):d(1)};IDE_Morph.prototype.setPaletteWidth=function(a){var b=this.isAnimating?100:0,c=this.world();c.animations.push(new Animation(d=>{this.paletteWidth=d;this.setExtent(c.extent())},()=>this.paletteWidth,a-this.paletteWidth,b))}; +IDE_Morph.prototype.createNewProject=function(){this.confirm("Replace the current project with a new one?","New Project",()=>{this.exitReplayMode();SnapActions.disableCollaboration();SnapUndo.reset();this.newProject()})};IDE_Morph.prototype.openProjectsBrowser=function(){"file:"===location.protocol?this.importLocalFile():(new ProjectDialogMorph(this,"open")).popUp(this.world())}; +IDE_Morph.prototype.saveProjectsBrowser=function(){"file:"===location.protocol?this.prompt("Export Project As...",a=>this.exportProject(a,!1),null,"exportProject"):("examples"===this.source&&(this.source=null),(new ProjectDialogMorph(this,"save")).popUp(this.world()))}; +IDE_Morph.prototype.microphoneMenu=function(){var a=new MenuMorph(this),b=this.world(),c=this.controlBar.settingsButton.bottomLeft(),d=this.stage.microphone,e=new SymbolMorph("tick",.75*MorphicPreferences.menuFontSize),f=new SymbolMorph("checkedBox",.75*MorphicPreferences.menuFontSize),g=e.fullCopy();g.render=nop;d.isReady&&(a.addItem([f,localize("Microphone")],()=>d.stop()),a.addLine());["low","normal","high","max"].forEach((h,k)=>{a.addItem([d.resolution===k+1?e:g,localize(h)],()=>d.setResolution(k+ +1))});a.popup(b,c)};IDE_Morph.prototype.languageMenu=function(){var a=new MenuMorph(this),b=this.world(),c=this.controlBar.settingsButton.bottomLeft(),d=new SymbolMorph("tick",.75*MorphicPreferences.menuFontSize),e=d.fullCopy();e.render=nop;SnapTranslator.languages().forEach(f=>a.addItem([SnapTranslator.language===f?d:e,SnapTranslator.languageName(f)],()=>{this.loadNewProject=!1;this.setLanguage(f)}));a.popup(b,c)}; +IDE_Morph.prototype.setLanguage=function(a,b,c){var d=document.getElementById("language"),e=this.resourceURL("locale","lang-"+a+".js");SnapTranslator.unload();d&&document.head.removeChild(d);if("en"===a)return this.reflectLanguage("en",b,c);d=document.createElement("script");d.id="language";d.onload=()=>this.reflectLanguage(a,b,c);document.head.appendChild(d);d.src=e}; IDE_Morph.prototype.reflectLanguage=function(a,b,c){var d=location.hash;SnapTranslator.language=a;if(!this.loadNewProject)if(Process.prototype.isCatchingErrors)try{var e=this.serializer.serialize(this.stage)}catch(f){this.showMessage("Serialization failed: "+f)}else e=this.serializer.serialize(this.stage);SpriteMorph.prototype.initBlocks();this.spriteBar.tabBar.tabTo("scripts");this.createCategories();this.createCorralBar();this.fixLayout();this.loadNewProject?(this.newProject(),location.hash=d): (SnapUndo.reset(),this.openProjectString(e));c||this.saveSetting("language",a);b&&b.call(this)}; -IDE_Morph.prototype.userSetBlocksScale=function(){var a=this;var b=new CommandBlockMorph;b.color=SpriteMorph.prototype.blockColor.motion;b.setSpec(localize("build"));var c=new CommandBlockMorph;c.color=SpriteMorph.prototype.blockColor.sound;c.setSpec(localize("your own"));b.nextBlock(c);c=new CommandBlockMorph;c.color=SpriteMorph.prototype.blockColor.operators;c.setSpec(localize("blocks"));b.bottomBlock().nextBlock(c);c=new FrameMorph;c.acceptsDrops=!1;c.color=IDE_Morph.prototype.groupColor;.8this.setBlocksScale(Math.min(d,12)))).withKey("zoomBlocks");MorphicPreferences.isTouchDevice&&(c.isDraggable=!1);c.prompt("Zoom blocks",SyntaxElementMorph.prototype.scale.toString(),this.world(),b,{"normal (1x)":1,"demo (1.2x)":1.2,"presentation (1.4x)":1.4,"big (2x)":2, +"huge (4x)":4,"giant (8x)":8,"monstrous (10x)":10},!1,!0,1,5,d=>{a.blockSequence().forEach(e=>{e.setScale(d);e.setSpec(e.blockSpec)});a.fullChanged()})}; IDE_Morph.prototype.setBlocksScale=function(a){if(Process.prototype.isCatchingErrors)try{var b=this.serializer.serialize(this.stage)}catch(c){this.showMessage("Serialization failed: "+c)}else b=this.serializer.serialize(this.stage);SyntaxElementMorph.prototype.setScale(a);CommentMorph.prototype.refreshScale();SpriteMorph.prototype.initBlocks();this.spriteBar.tabBar.tabTo("scripts");this.createCategories();this.createCorralBar();this.fixLayout();this.openProjectString(b);this.saveSetting("zoom",a)}; -IDE_Morph.prototype.userFadeBlocks=function(){var a=this,b=100-100*SyntaxElementMorph.prototype.alpha;var c=(new DialogBoxMorph(null,function(d){return a.setBlockTransparency(d,!0)})).withKey("fadeBlocks");MorphicPreferences.isTouchDevice&&(c.isDraggable=!1);c.cancel=function(){a.setBlockTransparency(b);c.destroy()};c.prompt("Fade blocks",b.toString(),this.world(),null,{"block-solid (0)":0,"medium (50)":50,"light (70)":70,"shimmering (80)":80,"elegant (90)":90,"subtle (95)":95,"text-only (100)":100}, -!1,!0,0,100,function(d){return a.setBlockTransparency(d)},0)};IDE_Morph.prototype.setBlockTransparency=function(a,b){SyntaxElementMorph.prototype.setAlphaScaled(100-a);this.changed();b&&(0===a?this.removeSetting("fade"):this.saveSetting("fade",a))};IDE_Morph.prototype.userSetStageSize=function(){(new DialogBoxMorph(this,function(a){SnapActions.setStageSize(a.x,a.y)},this)).promptVector("Stage size",StageMorph.prototype.dimensions,new Point(480,360),"Stage width","Stage height",this.world(),null,null)}; +IDE_Morph.prototype.userFadeBlocks=function(){var a=100-100*SyntaxElementMorph.prototype.alpha;var b=(new DialogBoxMorph(null,c=>this.setBlockTransparency(c,!0))).withKey("fadeBlocks");MorphicPreferences.isTouchDevice&&(b.isDraggable=!1);b.cancel=()=>{this.setBlockTransparency(a);b.destroy()};b.prompt("Fade blocks",a.toString(),this.world(),null,{"block-solid (0)":0,"medium (50)":50,"light (70)":70,"shimmering (80)":80,"elegant (90)":90,"subtle (95)":95,"text-only (100)":100},!1,!0,0,100,c=>this.setBlockTransparency(c), +0)};IDE_Morph.prototype.setBlockTransparency=function(a,b){SyntaxElementMorph.prototype.setAlphaScaled(100-a);this.changed();b&&(0===a?this.removeSetting("fade"):this.saveSetting("fade",a))};IDE_Morph.prototype.userSetStageSize=function(){(new DialogBoxMorph(this,function(a){SnapActions.setStageSize(a.x,a.y)},this)).promptVector("Stage size",StageMorph.prototype.dimensions,new Point(480,360),"Stage width","Stage height",this.world(),null,null)}; IDE_Morph.prototype.setStageExtent=function(a){function b(){c.step=function(){var f=e.subtract(StageMorph.prototype.dimensions).divideBy(2);f.abs().lt(new Point(5,5))?(StageMorph.prototype.dimensions=e,delete c.step):StageMorph.prototype.dimensions=StageMorph.prototype.dimensions.add(f);c.stage.setExtent(StageMorph.prototype.dimensions);c.stage.clearPenTrails();c.fixLayout();this.setExtent(d.extent())}}var c=this,d=this.world(),e=a.max(new Point(240,180));this.stageRatio=1;this.isSmallStage=!1;this.controlBar.stageSizeButton.refresh(); -this.stage.stopVideo();this.setExtent(d.extent());this.isAnimating?b():(StageMorph.prototype.dimensions=e,this.stage.setExtent(StageMorph.prototype.dimensions),this.stage.clearPenTrails(),this.fixLayout(),this.setExtent(d.extent()))};IDE_Morph.prototype.userSetDragThreshold=function(){(new DialogBoxMorph(this,function(a){return MorphicPreferences.grabThreshold=Math.min(Math.max(+a,0),200)},this)).prompt("Dragging threshold",MorphicPreferences.grabThreshold.toString(),this.world(),null,null,null,!0)}; -IDE_Morph.prototype.initializeCloudWithSnap=function(){var a=this,b=this.world();(new DialogBoxMorph(null,function(c){var d,e,f,g,h;return $jscomp.asyncExecutePromiseGeneratorProgram(function(k){if(1==k.nextAddress)return k.setCatchFinallyBlocks(2),k.yield(a.cloud.login(c.username.toLowerCase(),c.password,c.choice,"Snap!"),4);if(2!=k.nextAddress)return a.controlBar.cloudButton.refresh(),a.source="cloud",d=a.cloud,e=d.username,f=d.strategy,g=localize("Logged in as ")+e,f&&(g+=" (using "+f+")"),a.showMessage(g, -2),k.leaveTryBlock(0);h=k.enterCatchBlock();a.cloudError()(h.message);k.jumpToEnd()})})).withKey("cloudlogin").promptCredentials("Sign in with Snap!","login",null,null,null,null,"stay signed in on this computer\nuntil logging out",b,this.cloudIcon(),this.cloudMsg)}; -IDE_Morph.prototype.initializeCloud=function(){var a=this,b=this.world();(new DialogBoxMorph(null,function(c){var d,e,f,g,h;return $jscomp.asyncExecutePromiseGeneratorProgram(function(k){if(1==k.nextAddress)return k.setCatchFinallyBlocks(2),d=hex_sha512(c.password),k.yield(a.cloud.login(c.username,d,c.choice),4);if(2!=k.nextAddress)return e=a.cloud,f=e.username,sessionStorage.username=f,a.controlBar.cloudButton.refresh(),a.source="cloud",Services.fetchHosts(),g=localize("Logged in as ")+f,a.showMessage(g, -2),k.leaveTryBlock(0);h=k.enterCatchBlock();a.cloudError()(h.message);k.jumpToEnd()})})).withKey("cloudlogin").promptCredentials("Sign in","login",null,null,null,null,"stay signed in on this computer\nuntil logging out",b,this.cloudIcon(),this.cloudMsg)}; -IDE_Morph.prototype.createCloudAccount=function(){var a=this,b=this.world();(new DialogBoxMorph(null,function(c){a.cloud.signup(c.username,c.password,c.email,function(d,e){var f=c.password?"You can now log in.":"An e-mail with your password\nhas been sent to the address provided";(new DialogBoxMorph).inform(e,d+".\n\n"+f,b,a.cloudIcon(null,new Color(0,180,0)))},a.cloudError())})).withKey("cloudsignup").promptCredentials("Sign up","signup","/tos.html","Terms of Service...","/privacy.html","Privacy...", -"I have read and agree\nto the Terms of Service",b,this.cloudIcon(),this.cloudMsg)};IDE_Morph.prototype.promptExitReplay=function(a){var b=this;this.confirm("The given action cannot be applied while in replay mode. \nWould you like to exit replay mode?","Exit Replay?",function(){b.exitReplayMode();a()})}; -IDE_Morph.prototype.resetCloudPassword=function(){var a=this,b=this.world();(new DialogBoxMorph(null,function(c){return a.cloud.resetPassword(c.username,function(d,e){return(new DialogBoxMorph).inform(e,d+"\n\nAn e-mail with a link to\nreset your password\nhas been sent to the address provided",b,a.cloudIcon(null,new Color(0,180,0)))},a.cloudError())})).withKey("cloudresetpassword").promptCredentials("Reset password","resetPassword",null,null,null,null,null,b,this.cloudIcon(),this.cloudMsg)}; -IDE_Morph.prototype.resendVerification=function(){var a=this,b=this.world();(new DialogBoxMorph(null,function(c){return a.cloud.resendVerification(c.username,function(d,e){return(new DialogBoxMorph).inform(e,d,b,a.cloudIcon(null,new Color(0,180,0)))},a.cloudError())})).withKey("cloudresendverification").promptCredentials("Resend verification email","resendVerification",null,null,null,null,null,b,this.cloudIcon(),this.cloudMsg)}; -IDE_Morph.prototype.changeCloudPassword=function(){var a=this,b=this.world();(new DialogBoxMorph(null,function(c){return a.cloud.changePassword(c.oldpassword,c.password,function(){return a.showMessage("password has been changed.",2)},a.cloudError())})).withKey("cloudpassword").promptCredentials("Change Password","changePassword",null,null,null,null,null,b,this.cloudIcon(),this.cloudMsg)}; -IDE_Morph.prototype.logout=function(){var a=this;this.cloud.logout(function(){delete sessionStorage.username;a.controlBar.cloudButton.refresh();a.showMessage("disconnected.",2)},function(){delete sessionStorage.username;a.controlBar.cloudButton.refresh();a.showMessage("disconnected.",2)})}; +this.stage.stopVideo();this.setExtent(d.extent());this.isAnimating?b():(StageMorph.prototype.dimensions=e,this.stage.setExtent(StageMorph.prototype.dimensions),this.stage.clearPenTrails(),this.fixLayout(),this.setExtent(d.extent()))};IDE_Morph.prototype.userSetDragThreshold=function(){(new DialogBoxMorph(this,a=>MorphicPreferences.grabThreshold=Math.min(Math.max(+a,0),200),this)).prompt("Dragging threshold",MorphicPreferences.grabThreshold.toString(),this.world(),null,null,null,!0)}; +IDE_Morph.prototype.initializeCloudWithSnap=function(){var a=this.world();(new DialogBoxMorph(null,async b=>{try{await this.cloud.login(b.username.toLowerCase(),b.password,b.choice,"Snap!");this.controlBar.cloudButton.refresh();this.source="cloud";const {username:c,strategy:d}=this.cloud;let e=localize("Logged in as ")+c;d&&(e+=` (using ${d})`);this.showMessage(e,2)}catch(c){this.cloudError()(c.message)}})).withKey("cloudlogin").promptCredentials("Sign in with Snap!","login",null,null,null,null,"stay signed in on this computer\nuntil logging out", +a,this.cloudIcon(),this.cloudMsg)}; +IDE_Morph.prototype.initializeCloud=function(){var a=this.world();(new DialogBoxMorph(null,async b=>{try{const c=hex_sha512(b.password);await this.cloud.login(b.username,c,b.choice);const {username:d}=this.cloud;sessionStorage.username=d;this.controlBar.cloudButton.refresh();this.source="cloud";Services.fetchHosts();let e=localize("Logged in as ")+d;this.showMessage(e,2)}catch(c){this.cloudError()(c.message)}})).withKey("cloudlogin").promptCredentials("Sign in","login",null,null,null,null,"stay signed in on this computer\nuntil logging out", +a,this.cloudIcon(),this.cloudMsg)}; +IDE_Morph.prototype.createCloudAccount=function(){var a=this.world();(new DialogBoxMorph(null,b=>{this.cloud.signup(b.username,b.password,b.email,(c,d)=>{const e=b.password?"You can now log in.":"An e-mail with your password\nhas been sent to the address provided";(new DialogBoxMorph).inform(d,c+".\n\n"+e,a,this.cloudIcon(null,new Color(0,180,0)))},this.cloudError())})).withKey("cloudsignup").promptCredentials("Sign up","signup","/tos.html","Terms of Service...","/privacy.html","Privacy...","I have read and agree\nto the Terms of Service", +a,this.cloudIcon(),this.cloudMsg)};IDE_Morph.prototype.promptExitReplay=function(a){var b=this;this.confirm("The given action cannot be applied while in replay mode. \nWould you like to exit replay mode?","Exit Replay?",function(){b.exitReplayMode();a()})}; +IDE_Morph.prototype.resetCloudPassword=function(){var a=this.world();(new DialogBoxMorph(null,b=>this.cloud.resetPassword(b.username,(c,d)=>(new DialogBoxMorph).inform(d,c+"\n\nAn e-mail with a link to\nreset your password\nhas been sent to the address provided",a,this.cloudIcon(null,new Color(0,180,0))),this.cloudError()))).withKey("cloudresetpassword").promptCredentials("Reset password","resetPassword",null,null,null,null,null,a,this.cloudIcon(),this.cloudMsg)}; +IDE_Morph.prototype.resendVerification=function(){var a=this.world();(new DialogBoxMorph(null,b=>this.cloud.resendVerification(b.username,(c,d)=>(new DialogBoxMorph).inform(d,c,a,this.cloudIcon(null,new Color(0,180,0))),this.cloudError()))).withKey("cloudresendverification").promptCredentials("Resend verification email","resendVerification",null,null,null,null,null,a,this.cloudIcon(),this.cloudMsg)}; +IDE_Morph.prototype.changeCloudPassword=function(){var a=this.world();(new DialogBoxMorph(null,b=>this.cloud.changePassword(b.oldpassword,b.password,()=>this.showMessage("password has been changed.",2),this.cloudError()))).withKey("cloudpassword").promptCredentials("Change Password","changePassword",null,null,null,null,null,a,this.cloudIcon(),this.cloudMsg)}; +IDE_Morph.prototype.logout=function(){this.cloud.logout(()=>{delete sessionStorage.username;this.controlBar.cloudButton.refresh();this.showMessage("disconnected.",2)},()=>{delete sessionStorage.username;this.controlBar.cloudButton.refresh();this.showMessage("disconnected.",2)})}; IDE_Morph.prototype.buildProjectRequest=function(){var a=this.serializer.serialize(this.stage),b=normalizeCanvas(this.stage.thumbnail(SnapSerializer.prototype.thumbnailSize)).toDataURL();this.serializer.isCollectingMedia=!0;a={notes:this.projectNotes,xml:a,media:this.hasChangedMedia?this.serializer.mediaXML(this.projectName):null,thumbnail:b,remixID:this.stage.remixID};this.serializer.isCollectingMedia=!1;this.serializer.flushMedia();return a}; IDE_Morph.prototype.verifyProject=function(a){var b=JSON.stringify(a);if(b.length>Cloud.MAX_FILE_SIZE)return(new DialogBoxMorph).inform("Snap!Cloud - Cannot Save Project","The media inside this project exceeds 10 MB.\nPlease reduce the size of costumes or sounds.\n",this.world(),this.cloudIcon(null,new Color(180,0,0))),!1;try{this.serializer.parse(a.xml)}catch(c){return this.showMessage("Serialization of program data failed:\n"+c),!1}if(null!==a.media)try{this.serializer.parse(a.media)}catch(c){return this.showMessage("Serialization of media failed:\n"+ -c),!1}this.serializer.isCollectingMedia=!1;this.serializer.flushMedia();return b.length};IDE_Morph.prototype.saveProjectToCloud=function(a){var b=this,c=this.room.hasMultipleRoles()?this.room.getCurrentRoleName():this.room.name;a&&(this.showMessage("Saving "+c+"\nto the cloud..."),this.room.name=a,SnapCloud.saveProject(this,function(d){d.name&&b.room.silentSetRoomName(d.name);b.showMessage("Saved "+c+" to the cloud!",2)},this.cloudSaveError()))}; +c),!1}this.serializer.isCollectingMedia=!1;this.serializer.flushMedia();return b.length};IDE_Morph.prototype.saveProjectToCloud=function(a){const b=this.room.hasMultipleRoles()?this.room.getCurrentRoleName():this.room.name;a&&(this.showMessage("Saving "+b+"\nto the cloud..."),this.room.name=a,SnapCloud.saveProject(this,c=>{c.name&&this.room.silentSetRoomName(c.name);this.showMessage("Saved "+b+" to the cloud!",2)},this.cloudSaveError()))}; IDE_Morph.prototype.exportProjectMedia=function(a){this.serializer.isCollectingMedia=!0;if(a){this.setProjectName(a);try{var b=this.showMessage("Exporting");var c=this.serializer.mediaXML(a);this.saveXMLAs(c,this.projectName+" media");b.destroy();this.showMessage("Exported!",1)}catch(d){if(Process.prototype.isCatchingErrors)this.serializer.isCollectingMedia=!1,this.showMessage("Export failed: "+d);else throw d;}}this.serializer.isCollectingMedia=!1;this.serializer.flushMedia()}; IDE_Morph.prototype.exportProjectNoMedia=function(a){this.serializer.isCollectingMedia=!0;if(a)if(this.setProjectName(a),Process.prototype.isCatchingErrors)try{var b=this.showMessage("Exporting");var c=this.serializer.serialize(this.stage);this.saveXMLAs(c,this.projectName);b.destroy();this.showMessage("Exported!",1)}catch(d){this.serializer.isCollectingMedia=!1,this.showMessage("Export failed: "+d)}else b=this.showMessage("Exporting"),c=this.serializer.serialize(this.stage),this.saveXMLAs(c,this.projectName), b.destroy(),this.showMessage("Exported!",1);this.serializer.isCollectingMedia=!1;this.serializer.flushMedia()}; IDE_Morph.prototype.exportProjectAsCloudData=function(a){this.serializer.isCollectingMedia=!0;if(a)if(this.setProjectName(a),Process.prototype.isCatchingErrors)try{var b=this.showMessage("Exporting");var c=this.serializer.serialize(this.stage);this.serializer.mediaXML(a);this.serializer.replayHistory();this.saveXMLAs(c,this.projectName);b.destroy();this.showMessage("Exported!",1)}catch(d){this.serializer.isCollectingMedia=!1,this.showMessage("Export failed: "+d)}else b=this.showMessage("Exporting"), -c=this.serializer.serialize(this.stage),this.serializer.mediaXML(a),this.serializer.replayHistory(),this.saveXMLAs(c,this.projectName),b.destroy(),this.showMessage("Exported!",1);this.serializer.isCollectingMedia=!1;this.serializer.flushMedia()};IDE_Morph.prototype.cloudAcknowledge=function(){var a=this;return function(b,c){nop(b);(new DialogBoxMorph).inform("Cloud Connection","Successfully connected to:\nhttp://"+c,a.world(),a.cloudIcon(null,new Color(0,180,0)))}}; -IDE_Morph.prototype.cloudResponse=function(){var a=this;return function(b,c){50{nop(a);(new DialogBoxMorph).inform("Cloud Connection","Successfully connected to:\nhttp://"+b,this.world(),this.cloudIcon(null,new Color(0,180,0)))}}; +IDE_Morph.prototype.cloudResponse=function(){return(a,b)=>{50{this.shield&&(this.shield.destroy(),this.shield=null);(new DialogBoxMorph).inform("NetsBlox Cloud",(b?b+"\n":"")+a,this.world(),this.cloudIcon(null,new Color(180,0,0)))}}; IDE_Morph.prototype.cloudIcon=function(a,b){b=b||DialogBoxMorph.prototype.titleBarColor;var c=MorphicPreferences.isFlat;a=new SymbolMorph(c?"cloud":"cloudGradient",a||50,b,c?null:new Point(-1,-1),b.darker(50));c||a.addShadow(new Point(1,1),1,b.lighter(95));return a}; -IDE_Morph.prototype.setCloudURL=function(){var a=this;(new DialogBoxMorph(null,function(b){a.cloud.url=b;a.cloud.checkCredentials(function(){return a.controlBar.cloudButton.refresh()},function(){return a.controlBar.cloudButton.refresh()})})).withKey("cloudURL").prompt("Cloud URL",this.cloud.url,this.world(),null,this.cloud.knownDomains)};IDE_Morph.prototype.urlParameters=function(){var a=location.hash.slice(location.hash.indexOf(":")+1);return this.cloud.parseDict(a)}; +IDE_Morph.prototype.setCloudURL=function(){(new DialogBoxMorph(null,a=>{this.cloud.url=a;this.cloud.checkCredentials(()=>this.controlBar.cloudButton.refresh(),()=>this.controlBar.cloudButton.refresh())})).withKey("cloudURL").prompt("Cloud URL",this.cloud.url,this.world(),null,this.cloud.knownDomains)};IDE_Morph.prototype.urlParameters=function(){var a=location.hash.slice(location.hash.indexOf(":")+1);return this.cloud.parseDict(a)}; IDE_Morph.prototype.hasCloudProject=function(){var a=this.urlParameters();return a.hasOwnProperty("Username")&&a.hasOwnProperty("ProjectName")}; -IDE_Morph.prototype.getURL=function(a,b,c){var d=this,e=new XMLHttpRequest,f=b instanceof Function;f&&(e.responseType=c||"text");var g=f&&"text"!==e.responseType?"response":"responseText";try{if(e.open("GET",a,f),f&&(e.onreadystatechange=function(){if(4===e.readyState)if(e[g])b.call(d,e[g]);else throw d.showMessage("unable to retrieve "+a),Error("unable to retrieve "+a);}),e.send(),!f){if(200===e.status)return e[g];throw Error("unable to retrieve "+a);}}catch(h){if(this.showMessage(h.toString()), -f)b.call(this);else return e[g]}};IDE_Morph.prototype.showMessage=function(a,b){var c=new MenuMorph(null,a),d;c.popUpCenteredInWorld(this.world());b&&(d=setInterval(function(){c.destroy();clearInterval(d)},1E3*b));return c};IDE_Morph.prototype.inform=function(a,b){(new DialogBoxMorph).inform(a,localize(b),this.world())}; -IDE_Morph.prototype.confirm=function(a,b,c){var d=!c;if(d){var e=utils.defer();c=e.resolve.bind(null,!0)}var f=new DialogBoxMorph(null,c);f.askYesNo(b,localize(a),this.world());if(d)return f.cancel=function(){e.resolve(!1);f.destroy()},e.promise};IDE_Morph.prototype.prompt=function(a,b,c,d){(new DialogBoxMorph(null,b)).withKey(d).prompt(a,"",this.world(),null,c)}; +IDE_Morph.prototype.getURL=function(a,b,c){var d=new XMLHttpRequest,e=b instanceof Function;e&&(d.responseType=c||"text");var f=e&&"text"!==d.responseType?"response":"responseText";try{if(d.open("GET",a,e),e&&(d.onreadystatechange=()=>{if(4===d.readyState)if(d[f])b.call(this,d[f]);else throw this.showMessage("unable to retrieve "+a),Error("unable to retrieve "+a);}),d.send(),!e){if(200===d.status)return d[f];throw Error("unable to retrieve "+a);}}catch(g){if(this.showMessage(g.toString()),e)b.call(this); +else return d[f]}};IDE_Morph.prototype.showMessage=function(a,b){var c=new MenuMorph(null,a),d;c.popUpCenteredInWorld(this.world());b&&(d=setInterval(()=>{c.destroy();clearInterval(d)},1E3*b));return c};IDE_Morph.prototype.inform=function(a,b){(new DialogBoxMorph).inform(a,localize(b),this.world())}; +IDE_Morph.prototype.confirm=function(a,b,c){var d=!c;if(d){var e=utils.defer();c=e.resolve.bind(null,!0)}const f=new DialogBoxMorph(null,c);f.askYesNo(b,localize(a),this.world());if(d)return f.cancel=()=>{e.resolve(!1);f.destroy()},e.promise};IDE_Morph.prototype.prompt=function(a,b,c,d){(new DialogBoxMorph(null,b)).withKey(d).prompt(a,"",this.world(),null,c)}; IDE_Morph.prototype.warnAboutIE=function(){if(this.isIE()){var a=new DialogBoxMorph;var b=new TextMorph("Please do not use Internet Explorer.\nSnap! runs best in a web-standards\ncompliant browser",a.fontSize,a.fontStyle,!0,!1,"center",null,null,MorphicPreferences.isFlat?null:new Point(1,1),WHITE);a.key="IE-Warning";a.labelString="Internet Explorer";a.createLabel();a.addBody(b);a.fixLayout();a.popUp(this.world())}}; IDE_Morph.prototype.isIE=function(){var a=navigator.userAgent;return-1g.can(this.task));this.source=d||this.sources[0];this.itemsList=[];this.itemName=b;this.recoverButton=this.unpublishButton=this.publishButton=this.unshareButton=this.shareButton=this.deleteButton=this.notesField=this.notesText=this.preview=this.listField=this.magnifyingGlass=this.filterField=this.nameField=this.srcBar=this.handle=null;SaveOpenDialogMorph.uber.init.call(this,this,null,null); +this.labelString="save"===this.task?"Save "+b:"Open "+b;this.createLabel();this.key=a+b;this.buildContents(e);this.onNextStep=function(){f.setSource(f.source)}}; +SaveOpenDialogMorph.prototype.buildContents=function(a){var b=new Point(455,146);this.addBody(new Morph);this.body.color=this.color;this.srcBar=new AlignmentMorph("column",this.padding/2);this.sources.forEach(c=>{c=this.addSourceButton(c);b.y+=c.height()});b.y=Math.max(b.y,335);"open"===this.task&&this.buildFilterField();this.srcBar.fixLayout();this.body.add(this.srcBar);if("save"===this.task){const {name:c}=a;this.nameField=new InputFieldMorph(c);this.body.add(this.nameField)}this.listField=new ListMorph([]); this.fixListFieldItemColors();this.listField.fixLayout=nop;this.listField.edge=InputFieldMorph.prototype.edge;this.listField.fontSize=InputFieldMorph.prototype.fontSize;this.listField.typeInPadding=InputFieldMorph.prototype.typeInPadding;this.listField.contrast=InputFieldMorph.prototype.contrast;this.listField.render=InputFieldMorph.prototype.render;this.listField.drawRectBorder=InputFieldMorph.prototype.drawRectBorder;this.body.add(this.listField);this.initPreview();this.notesField=new ScrollFrameMorph; this.notesField.fixLayout=nop;this.notesField.edge=InputFieldMorph.prototype.edge;this.notesField.fontSize=InputFieldMorph.prototype.fontSize;this.notesField.typeInPadding=InputFieldMorph.prototype.typeInPadding;this.notesField.contrast=InputFieldMorph.prototype.contrast;this.notesField.render=InputFieldMorph.prototype.render;this.notesField.drawRectBorder=InputFieldMorph.prototype.drawRectBorder;this.notesField.acceptsDrops=!1;this.notesField.contents.acceptsDrops=!1;"open"===this.task?this.notesText= -new TextMorph(""):(this.notesText=new TextMorph(a.notes),this.notesText.isEditable=!0,this.notesText.enableSelecting());this.notesField.isTextLineWrapping=!0;this.notesField.padding=3;this.notesField.setContents(this.notesText);this.notesField.setWidth(this.preview.width());this.body.add(this.notesField);"open"===this.task?(this.addButton("openItem","Open"),this.action="openItem"):(this.addButton("trySaveItem","Save"),this.action="trySaveItem");this.shareButton=this.addButton("shareItem","Share"); -this.unshareButton=this.addButton("unshareItem","Unshare");this.shareButton.hide();this.unshareButton.hide();this.deleteButton=this.addButton("deleteItem","Delete");this.addButton("cancel","Cancel");this.setExtent(c);this.fixLayout()}; -SaveOpenDialogMorph.prototype.deleteItem=function(){var a=this,b,c;return $jscomp.asyncExecutePromiseGeneratorProgram(function(d){if(1==d.nextAddress)return(b=a.listField.selected)?d.yield(a.ide.confirm(localize("Are you sure you want to delete")+'\n"'+b.name+'"?',"Delete "+a.itemName),3):d.jumpTo(0);if(5!=d.nextAddress)return(c=d.yieldResult)?d.yield(a.source.delete(b),5):d.jumpTo(0);a.setSource(a.source);return d.return(b)})}; -SaveOpenDialogMorph.prototype.shareItem=function(){var a=this,b,c,d,e;return $jscomp.asyncExecutePromiseGeneratorProgram(function(f){switch(f.nextAddress){case 1:b=a.listField.selected;c=a.listField.active;if(!b){f.jumpTo(0);break}return f.yield(a.ide.confirm(localize("Are you sure you want to publish")+'\n"'+b.name+'"?',"Share "+a.itemName),3);case 3:d=f.yieldResult;if(!d){f.jumpTo(0);break}a.ide.showMessage("sharing\n"+a.itemName.toLowerCase()+"...");f.setCatchFinallyBlocks(5);return f.yield(a.source.publish(b), -7);case 7:return b.public=!0,a.unshareButton.show(),a.shareButton.hide(),c.label.isBold=!0,c.label.rerender(),a.buttons.fixLayout(),a.rerender(),a.ide.showMessage("shared.",2),f.return(b);case 5:e=f.enterCatchBlock(),a.ide.cloudError().call(null,e.label,e.message),f.jumpToEnd()}})}; -SaveOpenDialogMorph.prototype.unshareItem=function(){var a=this,b,c,d;return $jscomp.asyncExecutePromiseGeneratorProgram(function(e){if(1==e.nextAddress)return b=a.listField.selected,c=a.listField.active,b?e.yield(a.ide.confirm(localize("Are you sure you want to unpublish")+'\n"'+b.name+'"?',"Unshare "+a.itemName),3):e.jumpTo(0);if(5!=e.nextAddress){d=e.yieldResult;if(!d)return e.jumpTo(0);a.ide.showMessage("unsharing\n"+a.itemName.toLowerCase()+"...");return e.yield(a.source.publish(b,!0),5)}b.public= -!1;a.shareButton.show();a.unshareButton.hide();c.label.isBold=!1;c.label.rerender();a.buttons.fixLayout();a.rerender();a.ide.showMessage("unshared.",2);return e.return(b)})};SaveOpenDialogMorph.prototype.openItem=function(){var a=this,b;return $jscomp.asyncExecutePromiseGeneratorProgram(function(c){if(1==c.nextAddress)return(b=a.listField.selected)?c.yield(a.source.open(b),3):c.jumpTo(0);a.destroy();c.jumpToEnd()})}; -SaveOpenDialogMorph.prototype.trySaveItem=function(){var a=this,b,c,d,e,f,g,h;return $jscomp.asyncExecutePromiseGeneratorProgram(function(k){switch(k.nextAddress){case 1:b={name:a.nameField.contents().text.text,notes:a.notesText.text};c=detect(a.itemsList,function(l){return l.name===b.name});d=localize(a.source.name.toLowerCase());e=localize("Saving "+a.itemName.toLowerCase()+"\nto the ")+d+"...";f=localize("Saved to the ")+d+"!";g=!0;if(!c){k.jumpTo(2);break}a.ide.showMessage(e);return k.yield(a.ide.confirm(localize("Are you sure you want to replace")+ -'\n"'+b.name+'"?',"Replace "+a.itemName),3);case 3:g=k.yieldResult;case 2:if(!g){k.jumpTo(0);break}k.setCatchFinallyBlocks(5);a.ide.showMessage(e);return k.yield(a.saveItem(b),7);case 7:a.ide.showMessage(f,2);a.destroy();k.leaveTryBlock(6);break;case 5:h=k.enterCatchBlock(),a.ide.cloudError().call(null,h.label,h.message);case 6:return k.return(b)}})}; -SaveOpenDialogMorph.prototype.saveItem=function(a){var b=this;return $jscomp.asyncExecutePromiseGeneratorProgram(function(c){return c.yield(b.source.save(a),0)})};SaveOpenDialogMorph.prototype.initPreview=function(){throw Error("Action not supported!");}; -SaveOpenDialogMorph.prototype.addSourceButton=function(a){var b=this,c=localize(a.name),d=a.icon,e=new StringMorph(c,10,null,!0,null,null,new Point(1,1),WHITE);c=new StringMorph(c,10,null,!0,null,null,new Point(-1,-1),this.titleBarColor.darker(50),WHITE);var f=new Morph,g=new Morph;e.add(new SymbolMorph(d,24,this.titleBarColor.darker(20),new Point(1,1),this.titleBarColor.darker(50)));e.children[0].setCenter(e.center());e.children[0].setBottom(e.top()-this.padding/2);f.isCachingImage=!0;f.cachedImage= -e.fullImage();f.bounds=e.fullBounds();c.add(new SymbolMorph(d,24,WHITE,new Point(-1,-1),this.titleBarColor.darker(50)));c.children[0].setCenter(c.center());c.children[0].setBottom(c.top()-this.padding/2);g.isCachingImage=!0;g.cachedImage=c.fullImage();g.bounds=c.fullBounds();d=new ToggleButtonMorph(null,this,function(){return b.setSource(a)},[f,g],function(){return b.source===a});d.corner=this.buttonCorner;d.edge=this.buttonEdge;d.outline=this.buttonOutline;d.outlineColor=this.buttonOutlineColor; -d.outlineGradient=this.buttonOutlineGradient;d.labelMinExtent=new Point(60,0);d.padding=this.buttonPadding;d.contrast=this.buttonContrast;d.pressColor=this.titleBarColor.darker(20);d.fixLayout();d.refresh();this.srcBar.add(d);return d};SaveOpenDialogMorph.prototype.fixListFieldItemColors=function(){var a=this;this.listField.contents.children[0].alpha=0;this.listField.contents.children[0].children.forEach(function(b){b.pressColor=a.titleBarColor.darker(20);b.color=new Color(0,0,0,0)})}; -SaveOpenDialogMorph.prototype.buildFilterField=function(){var a=this;this.filterField=new InputFieldMorph("");this.magnifyingGlass=new SymbolMorph("magnifyingGlass",this.filterField.height(),this.titleBarColor.darker(50));this.body.add(this.magnifyingGlass);this.body.add(this.filterField);this.filterField.reactToInput=function(b){var c=this.getValue();a.listField.elements=a.itemsList.filter(function(d){var e=d.notes||"";return-1this.setSource(a),[e,f],()=>this.source===a);c.corner=this.buttonCorner;c.edge=this.buttonEdge;c.outline=this.buttonOutline;c.outlineColor=this.buttonOutlineColor;c.outlineGradient=this.buttonOutlineGradient; +c.labelMinExtent=new Point(60,0);c.padding=this.buttonPadding;c.contrast=this.buttonContrast;c.pressColor=this.titleBarColor.darker(20);c.fixLayout();c.refresh();this.srcBar.add(c);return c};SaveOpenDialogMorph.prototype.fixListFieldItemColors=function(){this.listField.contents.children[0].alpha=0;this.listField.contents.children[0].children.forEach(a=>{a.pressColor=this.titleBarColor.darker(20);a.color=new Color(0,0,0,0)})}; +SaveOpenDialogMorph.prototype.buildFilterField=function(){var a=this;this.filterField=new InputFieldMorph("");this.magnifyingGlass=new SymbolMorph("magnifyingGlass",this.filterField.height(),this.titleBarColor.darker(50));this.body.add(this.magnifyingGlass);this.body.add(this.filterField);this.filterField.reactToInput=function(b){var c=this.getValue();a.listField.elements=a.itemsList.filter(d=>{const e=d.notes||"";return-1this.ok());this.fixListFieldItemColors();this.listField.fixLayout=nop;this.listField.edge=InputFieldMorph.prototype.edge;this.listField.fontSize=InputFieldMorph.prototype.fontSize;this.listField.typeInPadding=InputFieldMorph.prototype.typeInPadding;this.listField.contrast=InputFieldMorph.prototype.contrast;this.listField.render=InputFieldMorph.prototype.render; +this.listField.drawRectBorder=InputFieldMorph.prototype.drawRectBorder;this.listField.action=async c=>{void 0!==c&&(this.nameField&&this.nameField.setContents(c.name||""),"open"===this.task&&await this.setPreview(c),this.source.canPublish()?c.public?(this.shareButton.hide(),this.unshareButton.show()):(this.unshareButton.hide(),this.shareButton.show()):(this.unshareButton.hide(),this.shareButton.hide()),this.buttons.fixLayout(),this.fixLayout(),this.edit())};this.body.add(this.listField);this.source.canPublish()? +this.shareButton.show():this.shareButton.hide();this.unshareButton.hide();this.source.canDelete()?this.deleteButton.show():this.deleteButton.hide();this.buttons.fixLayout();this.fixLayout();"open"===this.task&&this.clearPreview()}; +SaveOpenDialogMorph.prototype.setPreview=async function(a){a=await this.source.getPreview(a);this.notesText.text=a.notes||"";this.notesText.rerender();this.notesField.contents.adjustBounds();this.preview.texture=a.thumbnail||null;this.preview.cachedTexture=null;this.preview.rerender();a.details&&(new SpeechBubbleMorph(new TextMorph(a.details,null,null,null,null,"center"))).popUp(this.world(),this.preview.rightCenter().add(new Point(2,0)))}; +SaveOpenDialogMorph.prototype.clearPreview=function(){this.notesText.text="";this.notesText.rerender();this.notesField.contents.adjustBounds();this.preview.texture=null;this.preview.cachedTexture=null;this.preview.rerender()};SaveOpenDialogMorph.prototype.edit=function(){this.nameField?this.nameField.edit():this.filterField&&this.filterField.edit()}; SaveOpenDialogMorph.prototype.fixLayout=function(){var a=fontHeight(this.titleFontSize)+2*this.titlePadding,b=this.padding/2,c=this.nameField||this.filterField;this.buttons&&0{if(void 0!==a){var b=detect(this.versions,c=>c.lastupdated===a);this.notesText.text=b.notes||"";this.notesText.rerender();this.notesField.contents.adjustBounds();this.preview.texture=b.thumbnail;this.preview.cachedTexture=null;this.preview.rerender()}};this.ide.cloud.getProjectVersionMetadata(this.projectName,a=>{var b=new Date,c=new Date;c.setDate(b.getDate()-1);this.versions=a;this.versions.forEach(d=>{var e=new Date((new Date).getTime()-1E3*d.lastupdated);e.toDateString()=== +b.toDateString()?d.lastupdated=localize("Today, ")+e.toLocaleTimeString():e.toDateString()===c.toDateString()?d.lastupdated=localize("Yesterday, ")+e.toLocaleTimeString():d.lastupdated=e.toLocaleString()});this.listField.elements=this.versions.map(d=>d.lastupdated);this.clearDetails();this.listField.buildListContents();this.fixListFieldItemColors();this.listField.adjustScrollBars();this.listField.scrollY(this.listField.top());this.fixLayout()},this.ide.cloudError());this.body.add(this.listField)}; +ProjectRecoveryDialogMorph.prototype.cancel=function(){this.browser.show();this.browser.listField.select(detect(this.browser.projectList,a=>a.projectname===this.projectName));ProjectRecoveryDialogMorph.uber.cancel.call(this)};ProjectRecoveryDialogMorph.prototype.recoverProject=function(){var a=this.listField.selected,b=detect(this.versions,c=>c.lastupdated===a);this.browser.openCloudProject({projectname:this.projectName},b.delta);this.destroy()}; ProjectRecoveryDialogMorph.prototype.popUp=function(){var a=this.ide.world();a&&(ProjectRecoveryDialogMorph.uber.popUp.call(this,a),this.handle=new HandleMorph(this,300,300,this.corner,this.corner))};ProjectRecoveryDialogMorph.prototype.fixListFieldItemColors=ProjectDialogMorph.prototype.fixListFieldItemColors;ProjectRecoveryDialogMorph.prototype.clearDetails=ProjectDialogMorph.prototype.clearDetails; ProjectRecoveryDialogMorph.prototype.fixLayout=function(){var a=fontHeight(this.titleFontSize)+2*this.titlePadding,b=this.padding/2;this.body&&(this.body.setPosition(this.position().add(new Point(this.padding,a+this.padding))),this.body.setExtent(new Point(this.width()-2*this.padding,this.height()-3*this.padding-a-this.buttons.height())),this.listField.setWidth(this.body.width()-this.preview.width()-this.padding),this.listField.contents.children[0].adjustWidths(),this.listField.setPosition(this.body.position()), this.listField.setHeight(this.body.height()),this.preview.setRight(this.body.right()),this.preview.setTop(this.listField.top()),this.notesField.setTop(this.preview.bottom()+b),this.notesField.setLeft(this.preview.left()),this.notesField.setHeight(this.body.bottom()-this.preview.bottom()-b));this.label&&(this.label.setCenter(this.center()),this.label.setTop(this.top()+(a-this.label.height())/2));this.buttons&&(this.buttons.fixLayout(),this.buttons.setCenter(this.center()),this.buttons.setBottom(this.bottom()- this.padding));this.removeShadow();this.addShadow()};SaveOpenDialogMorph.prototype.popUp=function(a){a&&(SaveOpenDialogMorph.uber.popUp.call(this,a),this.handle=new HandleMorph(this,350,300,this.corner,this.corner))};ProjectsDialogSource.prototype=Object.create(SaveOpenDialogMorphSource.prototype);ProjectsDialogSource.prototype.constructor=ProjectsDialogSource;ProjectsDialogSource.uber=SaveOpenDialogMorphSource.prototype;function ProjectsDialogSource(a){this.init(a)} -ProjectsDialogSource.prototype.init=function(a,b,c,d){ProjectsDialogSource.uber.init.call(this,b,c,d);this.ide=a};ProjectsDialogSource.prototype.getPreview=function(a){var b=this,c,d,e;return $jscomp.asyncExecutePromiseGeneratorProgram(function(f){if(1==f.nextAddress)return f.yield(b.getContent(a),2);c=f.yieldResult;d=b.ide.serializer.parse(c);e=d.children[0].children[0];return f.return({thumbnail:e.childNamed("thumbnail").contents,notes:e.childNamed("notes").contents||""})})}; -ProjectsDialogSource.prototype.open=function(a){var b=this,c,d;return $jscomp.asyncExecutePromiseGeneratorProgram(function(e){return 1==e.nextAddress?(c=b.ide,d=c.droppedText,e.yield(b.getContent(a),2)):e.return(d.call(c,e.yieldResult))})};CloudProjectsSource.prototype=Object.create(ProjectsDialogSource.prototype);CloudProjectsSource.prototype.constructor=CloudProjectsSource;CloudProjectsSource.uber=ProjectsDialogSource.prototype;function CloudProjectsSource(a){this.init(a,"Cloud","cloud")} -CloudProjectsSource.prototype.publish=function(a,b){var c=this,d=(b=void 0===b?!1:b)?"unpublishProject":"publishProject",e=this,f=this.ide.cloud;f.reconnect(function(){f.callService(d,function(){return f.disconnect()},c.ide.cloudError(),[a.name]);if(!b&&a.name===e.ide.projectName){var g="Username="+encodeURIComponent(SnapCloud.username.toLowerCase())+"&ProjectName="+encodeURIComponent(a.name);location.hash="present:"+g}},this.ide.cloudError())}; -CloudProjectsSource.prototype.open=function(a){var b=this,c;return $jscomp.asyncExecutePromiseGeneratorProgram(function(d){c=utils.defer();SnapCloud.getProject(a.ID,function(e){return $jscomp.asyncExecutePromiseGeneratorProgram(function(f){if(1==f.nextAddress)return f.yield(b.ide.rawLoadCloudProject(e,a.public),2);c.resolve(e);f.jumpToEnd()})},function(e,f){e=new CloudError(f,e);c.reject(e)});return d.return(c.promise)})}; -CloudProjectsSource.prototype.list=function(){var a=utils.defer();SnapCloud.getProjectList(function(b){b.forEach(function(c){c.name=c.ProjectName;c.public="true"===c.Public});a.resolve(b)},function(b,c){b=new CloudError(c,b);a.reject(b)});return a.promise};CloudProjectsSource.prototype.getPreview=function(a){return{thumbnail:a.Thumbnail,notes:a.notes,details:localize("last changed")+"\n"+a.Updated}}; -CloudProjectsSource.prototype.save=function(a){var b=utils.defer(),c=a.name!==this.ide.room.name,d=this;SnapCloud.saveProject(this.ide,function(e){e.name&&d.ide.room.silentSetRoomName(e.name);c&&d.ide.updateUrlQueryString();b.resolve()},function(e,f){e=new CloudError(f,e);b.reject(e)},!0,a.name);return b.promise}; -CloudProjectsSource.prototype.delete=function(a){var b=this;SnapCloud.reconnect(function(){SnapCloud.callService("deleteProject",function(){SnapCloud.disconnect();b.ide.hasChangedMedia=!0},b.ide.cloudError(),[a.name])},this.ide.cloudError())};SharedCloudProjectsSource.prototype=Object.create(ProjectsDialogSource.prototype);SharedCloudProjectsSource.prototype.constructor=SharedCloudProjectsSource;SharedCloudProjectsSource.uber=ProjectsDialogSource.prototype; -function SharedCloudProjectsSource(a){this.init(a,"Shared with me","cloud","cloud-shared")}SharedCloudProjectsSource.prototype.list=function(){var a=utils.defer();SnapCloud.getSharedProjectList(function(b){b.forEach(function(c){c.name=c.ProjectName});a.resolve(b)},function(b,c){b=new CloudError(c,b);a.reject(b)});return a.promise};SharedCloudProjectsSource.prototype.delete=function(a){SnapCloud.evictCollaborator(SnapCloud.username,a.ID)}; -SharedCloudProjectsSource.prototype.open=function(a){var b=this;SnapCloud.joinActiveProject(a.ID,function(c){return $jscomp.asyncExecutePromiseGeneratorProgram(function(d){b.ide.rawLoadCloudProject(c,a.public);d.jumpToEnd()})},this.ide.cloudError())};BrowserProjectsSource.prototype=Object.create(ProjectsDialogSource.prototype);BrowserProjectsSource.prototype.constructor=BrowserProjectsSource;BrowserProjectsSource.uber=ProjectsDialogSource.prototype; -function BrowserProjectsSource(a){this.init(a,"Browser","storage","local")}BrowserProjectsSource.prototype.getContent=function(a){return localStorage["-snap-project-"+a.name]};BrowserProjectsSource.prototype.list=function(){var a,b=[];for(a in localStorage)if(Object.prototype.hasOwnProperty.call(localStorage,a)&&"-snap-project-"===a.substr(0,14)){var c=a.substr(14);c={name:c};b.push(c)}return b};BrowserProjectsSource.prototype.save=function(a){this.ide.room.name=a.name;this.ide.saveProject(name)}; -BrowserProjectsSource.prototype.delete=function(a){delete localStorage["-snap-project-"+a.name]};CloudProjectExamples.prototype=Object.create(ProjectsDialogSource.prototype);CloudProjectExamples.prototype.constructor=CloudProjectExamples;CloudProjectExamples.uber=ProjectsDialogSource.prototype;function CloudProjectExamples(a){this.init(a,"Examples","poster")}CloudProjectExamples.prototype.getContent=function(a){return this.ide.getURL(this.ide.resourceURL("Examples",a.fileName))}; -CloudProjectExamples.prototype.open=function(a){var b=this,c;return $jscomp.asyncExecutePromiseGeneratorProgram(function(d){if(1==d.nextAddress)return d.yield(b.getContent(a),2);if(3!=d.nextAddress)return c=d.yieldResult,d.yield(b.ide.droppedText(c),3);b.ide.updateUrlQueryString(a.name,!1,!0);d.jumpToEnd()})};CloudProjectExamples.prototype.list=function(){return this.ide.getMediaList("Examples").map(function(a){return{name:a.name,fileName:a.fileName,notes:a.description}})}; -ProjectDialogMorph.prototype=new SaveOpenDialogMorph;ProjectDialogMorph.prototype.constructor=ProjectDialogMorph;ProjectDialogMorph.uber=SaveOpenDialogMorph.prototype;function ProjectDialogMorph(a,b){this.init(a,b)} -ProjectDialogMorph.prototype.init=function(a,b){this.ide=a;var c=[new CloudProjectsSource(a),new SharedCloudProjectsSource(a),new BrowserProjectsSource(a),new CloudProjectExamples(a)],d=a.source||"local",e=c.find(function(f){return f.id===d});ProjectDialogMorph.uber.init.call(this,b,"Project",c,e,{name:a.room.name,notes:a.projectNotes})}; -ProjectDialogMorph.prototype.initPreview=function(){this.preview=new Morph;this.preview.fixLayout=nop;this.preview.edge=InputFieldMorph.prototype.edge;this.preview.fontSize=InputFieldMorph.prototype.fontSize;this.preview.typeInPadding=InputFieldMorph.prototype.typeInPadding;this.preview.contrast=InputFieldMorph.prototype.contrast;this.preview.render=function(b){InputFieldMorph.prototype.render.call(this,b);this.cachedTexture?this.renderCachedTexture(b):this.texture&&this.renderTexture(this.texture, -b)};this.preview.renderCachedTexture=function(b){if(this.cachedTexture){var c=Math.min(this.width()/this.cachedTexture.width,this.height()/this.cachedTexture.height);b.drawImage(this.cachedTexture,this.edge,this.edge,c*this.cachedTexture.width,c*this.cachedTexture.height)}};this.preview.drawRectBorder=InputFieldMorph.prototype.drawRectBorder;this.preview.setExtent(this.ide.serializer.thumbnailSize.divideBy(4).add(2*this.preview.edge));this.body.add(this.preview);if("save"===this.task){var a=this.ide.stage.thumbnail(SnapSerializer.prototype.thumbnailSize); +ProjectsDialogSource.prototype.init=function(a,b,c,d){ProjectsDialogSource.uber.init.call(this,b,c,d);this.ide=a};ProjectsDialogSource.prototype.getPreview=async function(a){a=await this.getContent(a);a=this.ide.serializer.parse(a).children[0].children[0];return{thumbnail:a.childNamed("thumbnail").contents,notes:a.childNamed("notes").contents||""}};ProjectsDialogSource.prototype.open=async function(a){return this.ide.droppedText(await this.getContent(a))};CloudProjectsSource.prototype=Object.create(ProjectsDialogSource.prototype); +CloudProjectsSource.prototype.constructor=CloudProjectsSource;CloudProjectsSource.uber=ProjectsDialogSource.prototype;function CloudProjectsSource(a){this.init(a,"Cloud","cloud")} +CloudProjectsSource.prototype.publish=function(a,b=!1){const c=b?"unpublishProject":"publishProject",d=this,e=this.ide.cloud;e.reconnect(()=>{e.callService(c,()=>e.disconnect(),this.ide.cloudError(),[a.name]);if(!b&&a.name===d.ide.projectName){var f="Username="+encodeURIComponent(SnapCloud.username.toLowerCase())+"&ProjectName="+encodeURIComponent(a.name);location.hash="present:"+f}},this.ide.cloudError())}; +CloudProjectsSource.prototype.open=async function(a){const b=utils.defer();SnapCloud.getProject(a.ID,async c=>{await this.ide.rawLoadCloudProject(c,a.public);b.resolve(c)},function(c,d){c=new CloudError(d,c);b.reject(c)});return b.promise};CloudProjectsSource.prototype.list=function(){const a=utils.defer();SnapCloud.getProjectList(function(b){b.forEach(c=>{c.name=c.ProjectName;c.public="true"===c.Public});a.resolve(b)},function(b,c){b=new CloudError(c,b);a.reject(b)});return a.promise}; +CloudProjectsSource.prototype.getPreview=function(a){return{thumbnail:a.Thumbnail,notes:a.notes,details:localize("last changed")+"\n"+a.Updated}};CloudProjectsSource.prototype.save=function(a){const b=utils.defer(),c=a.name!==this.ide.room.name,d=this;SnapCloud.saveProject(this.ide,function(e){e.name&&d.ide.room.silentSetRoomName(e.name);c&&d.ide.updateUrlQueryString();b.resolve()},function(e,f){e=new CloudError(f,e);b.reject(e)},!0,a.name);return b.promise}; +CloudProjectsSource.prototype.delete=function(a){SnapCloud.reconnect(()=>{SnapCloud.callService("deleteProject",()=>{SnapCloud.disconnect();this.ide.hasChangedMedia=!0},this.ide.cloudError(),[a.name])},this.ide.cloudError())};SharedCloudProjectsSource.prototype=Object.create(ProjectsDialogSource.prototype);SharedCloudProjectsSource.prototype.constructor=SharedCloudProjectsSource;SharedCloudProjectsSource.uber=ProjectsDialogSource.prototype; +function SharedCloudProjectsSource(a){this.init(a,"Shared with me","cloud","cloud-shared")}SharedCloudProjectsSource.prototype.list=function(){const a=utils.defer();SnapCloud.getSharedProjectList(function(b){b.forEach(c=>{c.name=c.ProjectName});a.resolve(b)},function(b,c){b=new CloudError(c,b);a.reject(b)});return a.promise};SharedCloudProjectsSource.prototype.delete=function(a){SnapCloud.evictCollaborator(SnapCloud.username,a.ID)}; +SharedCloudProjectsSource.prototype.open=function(a){SnapCloud.joinActiveProject(a.ID,async b=>{this.ide.rawLoadCloudProject(b,a.public)},this.ide.cloudError())};BrowserProjectsSource.prototype=Object.create(ProjectsDialogSource.prototype);BrowserProjectsSource.prototype.constructor=BrowserProjectsSource;BrowserProjectsSource.uber=ProjectsDialogSource.prototype;function BrowserProjectsSource(a){this.init(a,"Browser","storage","local")} +BrowserProjectsSource.prototype.getContent=function(a){return localStorage["-snap-project-"+a.name]};BrowserProjectsSource.prototype.list=function(){var a,b=[];for(a in localStorage)if(Object.prototype.hasOwnProperty.call(localStorage,a)&&"-snap-project-"===a.substr(0,14)){var c=a.substr(14);c={name:c};b.push(c)}return b};BrowserProjectsSource.prototype.save=function(a){this.ide.room.name=a.name;this.ide.saveProject(name)}; +BrowserProjectsSource.prototype.delete=function(a){delete localStorage["-snap-project-"+a.name]};CloudProjectExamples.prototype=Object.create(ProjectsDialogSource.prototype);CloudProjectExamples.prototype.constructor=CloudProjectExamples;CloudProjectExamples.uber=ProjectsDialogSource.prototype;function CloudProjectExamples(a){this.init(a,"Examples","poster")}CloudProjectExamples.prototype.getContent=function(a){({fileName:a}=a);return this.ide.getURL(this.ide.resourceURL("Examples",a))}; +CloudProjectExamples.prototype.open=async function(a){const b=await this.getContent(a);await this.ide.droppedText(b);this.ide.updateUrlQueryString(a.name,!1,!0)};CloudProjectExamples.prototype.list=function(){return this.ide.getMediaList("Examples").map(a=>({name:a.name,fileName:a.fileName,notes:a.description}))};ProjectDialogMorph.prototype=new SaveOpenDialogMorph;ProjectDialogMorph.prototype.constructor=ProjectDialogMorph;ProjectDialogMorph.uber=SaveOpenDialogMorph.prototype; +function ProjectDialogMorph(a,b){this.init(a,b)}ProjectDialogMorph.prototype.init=function(a,b){this.ide=a;const c=[new CloudProjectsSource(a),new SharedCloudProjectsSource(a),new BrowserProjectsSource(a),new CloudProjectExamples(a)],d=a.source||"local",e=c.find(f=>f.id===d);ProjectDialogMorph.uber.init.call(this,b,"Project",c,e,{name:a.room.name,notes:a.projectNotes})}; +ProjectDialogMorph.prototype.initPreview=function(){this.preview=new Morph;this.preview.fixLayout=nop;this.preview.edge=InputFieldMorph.prototype.edge;this.preview.fontSize=InputFieldMorph.prototype.fontSize;this.preview.typeInPadding=InputFieldMorph.prototype.typeInPadding;this.preview.contrast=InputFieldMorph.prototype.contrast;this.preview.render=function(a){InputFieldMorph.prototype.render.call(this,a);this.cachedTexture?this.renderCachedTexture(a):this.texture&&this.renderTexture(this.texture, +a)};this.preview.renderCachedTexture=function(a){if(this.cachedTexture){const b=Math.min(this.width()/this.cachedTexture.width,this.height()/this.cachedTexture.height);a.drawImage(this.cachedTexture,this.edge,this.edge,b*this.cachedTexture.width,b*this.cachedTexture.height)}};this.preview.drawRectBorder=InputFieldMorph.prototype.drawRectBorder;this.preview.setExtent(this.ide.serializer.thumbnailSize.divideBy(4).add(2*this.preview.edge));this.body.add(this.preview);if("save"===this.task){const a=this.ide.stage.thumbnail(SnapSerializer.prototype.thumbnailSize); this.preview.texture=null;this.preview.cachedTexture=a;this.preview.rerender()}};ProjectDialogMorph.prototype.trySaveItem=function(){var a=this.nameField.contents().text.text,b=this.notesText.text;this.ide.projectNotes=b||this.ide.projectNotes;/[\.@]+/.test(a)?this.ide.inform("Invalid Project Name","Could not save project because\nthe provided name contains illegal characters.",this.world()):ProjectDialogMorph.uber.trySaveItem.call(this,{name:a,notes:b})}; ProjectDialogMorph.prototype.saveItem=function(a){ProjectDialogMorph.uber.saveItem.call(this,a);this.ide.source=this.source.id};ProjectDialogMorph.prototype.saveCloudProject=function(a){var b=this;this.ide.showMessage("Saving project\nto the cloud...");SnapCloud.saveProject(this.ide,function(c){c.name&&b.ide.room.silentSetRoomName(c.name);b.ide.source="cloud";b.ide.showMessage("Saved to cloud!",2)},this.ide.cloudError(),!0,a);this.destroy()}; -ProjectDialogMorph.prototype.shareItem=function(){var a=this,b;return $jscomp.asyncExecutePromiseGeneratorProgram(function(c){if(1==c.nextAddress)return c.yield(ProjectDialogMorph.uber.shareItem.call(a),2);(b=c.yieldResult)&&a.isCurrentProject(b)&&a.ide.updateUrlQueryString(b.name,!0);c.jumpToEnd()})};ProjectDialogMorph.prototype.isCurrentProject=function(a){return a.ID===SnapCloud.projectId}; -ProjectDialogMorph.prototype.unshareItem=function(){var a=this,b;return $jscomp.asyncExecutePromiseGeneratorProgram(function(c){if(1==c.nextAddress)return c.yield(ProjectDialogMorph.uber.unshareItem.call(a),2);(b=c.yieldResult)&&a.isCurrentProject(b)&&a.ide.updateUrlQueryString();c.jumpToEnd()})};SpriteIconMorph.prototype=new ToggleButtonMorph;SpriteIconMorph.prototype.constructor=SpriteIconMorph;SpriteIconMorph.uber=ToggleButtonMorph.prototype;SpriteIconMorph.prototype.thumbSize=new Point(40,40); -SpriteIconMorph.prototype.labelShadowOffset=null;SpriteIconMorph.prototype.labelShadowColor=null;SpriteIconMorph.prototype.labelColor=WHITE;SpriteIconMorph.prototype.fontSize=9;function SpriteIconMorph(a){this.init(a)} -SpriteIconMorph.prototype.init=function(a){var b=this;var c=[IDE_Morph.prototype.groupColor,IDE_Morph.prototype.frameColor,IDE_Morph.prototype.frameColor];this.object=a||new SpriteMorph;this.version=this.object.version;this.rotationButton=this.thumbnail=null;SpriteIconMorph.uber.init.call(this,c,null,function(){var d=b.parentThatIsA(IDE_Morph);d&&(SnapActions.selectSprite(b.object),d.selectSprite(b.object))},this.object.name,function(){var d=b.parentThatIsA(IDE_Morph);return d?d.currentSprite===b.object: -!1},null,function(){return a.exemplar?localize("parent")+":\n"+a.exemplar.name:null});this.isDraggable=!0;this.createThumbnail();this.padding=2;this.corner=8;this.fixLayout();this.fps=1}; +ProjectDialogMorph.prototype.shareItem=async function(){const a=await ProjectDialogMorph.uber.shareItem.call(this);a&&this.isCurrentProject(a)&&this.ide.updateUrlQueryString(a.name,!0)};ProjectDialogMorph.prototype.isCurrentProject=function(a){return a.ID===SnapCloud.projectId};ProjectDialogMorph.prototype.unshareItem=async function(){const a=await ProjectDialogMorph.uber.unshareItem.call(this);a&&this.isCurrentProject(a)&&this.ide.updateUrlQueryString()};SpriteIconMorph.prototype=new ToggleButtonMorph; +SpriteIconMorph.prototype.constructor=SpriteIconMorph;SpriteIconMorph.uber=ToggleButtonMorph.prototype;SpriteIconMorph.prototype.thumbSize=new Point(40,40);SpriteIconMorph.prototype.labelShadowOffset=null;SpriteIconMorph.prototype.labelShadowColor=null;SpriteIconMorph.prototype.labelColor=WHITE;SpriteIconMorph.prototype.fontSize=9;function SpriteIconMorph(a){this.init(a)} +SpriteIconMorph.prototype.init=function(a){var b=[IDE_Morph.prototype.groupColor,IDE_Morph.prototype.frameColor,IDE_Morph.prototype.frameColor];this.object=a||new SpriteMorph;this.version=this.object.version;this.rotationButton=this.thumbnail=null;SpriteIconMorph.uber.init.call(this,b,null,()=>{var c=this.parentThatIsA(IDE_Morph);c&&(SnapActions.selectSprite(this.object),c.selectSprite(this.object))},this.object.name,()=>{var c=this.parentThatIsA(IDE_Morph);return c?c.currentSprite===this.object: +!1},null,()=>a.exemplar?localize("parent")+":\n"+a.exemplar.name:null);this.isDraggable=!0;this.createThumbnail();this.padding=2;this.corner=8;this.fixLayout();this.fps=1}; SpriteIconMorph.prototype.createThumbnail=function(){this.thumbnail&&this.thumbnail.destroy();this.thumbnail=new Morph;this.thumbnail.isCachingImage=!0;this.thumbnail.bounds.setExtent(this.thumbSize);this.object instanceof SpriteMorph?(this.thumbnail.cachedImage=this.object.fullThumbnail(this.thumbSize,this.thumbnail.cachedImage),this.add(this.thumbnail),this.createRotationButton()):(this.thumbnail.cachedImage=this.object.thumbnail(this.thumbSize,this.thumbnail.cachedImage),this.add(this.thumbnail))}; SpriteIconMorph.prototype.createLabel=function(){this.label&&this.label.destroy();var a=new StringMorph(this.object.name,this.fontSize,this.fontStyle,!0,!1,!1,this.labelShadowOffset,this.labelShadowColor,this.labelColor);this.label=new FrameMorph;this.label.acceptsDrops=!1;this.label.alpha=0;this.label.setExtent(a.extent());a.setPosition(this.label.position());this.label.add(a);this.add(this.label)}; -SpriteIconMorph.prototype.createRotationButton=function(){var a=this;this.rotationButton&&(this.rotationButton.destroy(),this.rotationButton=null);if(this.object.anchor){var b=new ToggleButtonMorph(null,null,function(){return a.object.rotatesWithAnchor=!a.object.rotatesWithAnchor},["\u2192","\u21bb"],function(){return a.object.rotatesWithAnchor});b.corner=8;b.labelMinExtent=new Point(11,11);b.padding=0;b.pressColor=b.color;b.fixLayout();b.refresh();this.rotationButton=b;this.add(this.rotationButton)}}; +SpriteIconMorph.prototype.createRotationButton=function(){this.rotationButton&&(this.rotationButton.destroy(),this.rotationButton=null);if(this.object.anchor){var a=new ToggleButtonMorph(null,null,()=>this.object.rotatesWithAnchor=!this.object.rotatesWithAnchor,["\u2192","\u21bb"],()=>this.object.rotatesWithAnchor);a.corner=8;a.labelMinExtent=new Point(11,11);a.padding=0;a.pressColor=a.color;a.fixLayout();a.refresh();this.rotationButton=a;this.add(this.rotationButton)}}; SpriteIconMorph.prototype.step=function(){this.version!==this.object.version&&(this.createThumbnail(),this.createLabel(),this.fixLayout(),this.version=this.object.version,this.refresh())}; SpriteIconMorph.prototype.fixLayout=function(){if(!this.thumbnail||!this.label)return null;this.bounds.setWidth(this.thumbnail.width()+2*this.outline+2*this.edge+2*this.padding);this.bounds.setHeight(this.thumbnail.height()+2*this.outline+2*this.edge+3*this.padding+this.label.height());this.thumbnail.setCenter(this.center());this.thumbnail.setTop(this.top()+this.outline+this.edge+this.padding);this.rotationButton&&(this.rotationButton.setTop(this.top()),this.rotationButton.setRight(this.right())); this.label.setWidth(Math.min(this.label.children[0].width(),this.thumbnail.width()));this.label.setCenter(this.center());this.label.setTop(this.thumbnail.bottom()+this.padding)}; -SpriteIconMorph.prototype.userMenu=function(){var a=this,b=new MenuMorph(this);if(this.object instanceof StageMorph)return b.addItem("pic...",function(){a.parentThatIsA(IDE_Morph).saveCanvasAs(a.object.fullImage(),a.object.name)},"save a picture\nof the stage"),this.object.trailsLog.length&&b.addItem("svg...",function(){return a.object.exportTrailsLogAsSVG()},"export pen trails\nline segments as SVG"),b;if(!(this.object instanceof SpriteMorph))return null;b.addItem("show","showSpriteOnStage");b.addLine(); -b.addItem("duplicate",function(){var c=a.world().hand.position();SnapActions.duplicateSprite(a.object,c)});b.addItem("delete",function(){return SnapActions.removeSprite(a.object)});b.addLine();this.object.anchor&&b.addItem(localize("detach from")+" "+this.object.anchor.name,function(){return SnapActions.detachParts([a.object])});this.object.parts.length&&b.addItem("detach all parts",function(){return SnapActions.detachParts(a.object.parts)});b.addItem("export...","exportSprite");return b}; +SpriteIconMorph.prototype.userMenu=function(){var a=new MenuMorph(this);if(this.object instanceof StageMorph)return a.addItem("pic...",()=>{this.parentThatIsA(IDE_Morph).saveCanvasAs(this.object.fullImage(),this.object.name)},"save a picture\nof the stage"),this.object.trailsLog.length&&a.addItem("svg...",()=>this.object.exportTrailsLogAsSVG(),"export pen trails\nline segments as SVG"),a;if(!(this.object instanceof SpriteMorph))return null;a.addItem("show","showSpriteOnStage");a.addLine();a.addItem("duplicate", +()=>{var b=this.world().hand.position();SnapActions.duplicateSprite(this.object,b)});a.addItem("delete",()=>SnapActions.removeSprite(this.object));a.addLine();this.object.anchor&&a.addItem(localize("detach from")+" "+this.object.anchor.name,()=>SnapActions.detachParts([this.object]));this.object.parts.length&&a.addItem("detach all parts",()=>SnapActions.detachParts(this.object.parts));a.addItem("export...","exportSprite");return a}; SpriteIconMorph.prototype.instantiateSprite=function(){var a=this.parentThatIsA(IDE_Morph);a&&a.instantiateSprite(this.object)};SpriteIconMorph.prototype.exportSprite=function(){this.object.exportSprite()};SpriteIconMorph.prototype.chooseExemplar=function(){this.object.chooseExemplar()};SpriteIconMorph.prototype.releaseSprite=function(){this.object.release()};SpriteIconMorph.prototype.showSpriteOnStage=function(){this.object.showOnStage()}; SpriteIconMorph.prototype.mouseDoubleClick=function(){this.object instanceof SpriteMorph&&this.object.flash()};SpriteIconMorph.prototype.render=function(a){switch(this.userState){case "highlight":this.drawBackground(a,this.highlightColor);break;case "pressed":this.drawOutline(a);this.drawBackground(a,this.pressColor);this.drawEdges(a,this.pressColor,this.pressColor.lighter(40),this.pressColor.darker(40));break;default:this.drawBackground(a,this.getRenderColor())}}; SpriteIconMorph.prototype.getRenderColor=ScriptsMorph.prototype.getRenderColor;SpriteIconMorph.prototype.prepareToBeGrabbed=function(){var a=this.parentThatIsA(IDE_Morph);this.mouseClickLeft();this.alpha=.85;if(a){var b=a.sprites.asArray().indexOf(this.object);a.sprites.remove(b+1);a.createCorral();a.fixLayout()}};SpriteIconMorph.prototype.justDropped=function(){this.alpha=1}; SpriteIconMorph.prototype.wantsDropOf=function(a){return a instanceof BlockMorph||a instanceof CostumeIconMorph||a instanceof SoundIconMorph};SpriteIconMorph.prototype.reactToDropOf=function(a,b){if(a instanceof BlockMorph){if(a instanceof ReporterBlockMorph&&a.forMsg){a.slideBackTo(b.grabOrigin);return}this.copyStack(a)}else a instanceof CostumeIconMorph?this.copyCostume(a.object):a instanceof SoundIconMorph&&this.copySound(a.object);this.world().add(a);a.slideBackTo(b.grabOrigin)}; -SpriteIconMorph.prototype.copyStack=function(a){var b=this,c,d,e,f;return $jscomp.asyncExecutePromiseGeneratorProgram(function(g){if(1==g.nextAddress)return c=b.object,d=a.id?a.fullCopy():a,e=Math.max(c.scripts.children.map(function(h){return h.fullBounds().bottom()}).concat([c.scripts.top()])),f=new Point(b.object.scripts.left()+20,e+20),d.allComments().forEach(function(h){return h.align(d)}),d.allChildren().forEach(function(h){!h.isCustomBlock||h.isGlobal||c.getMethod(h.blockSpec)||h.deleteBlock()}), -d.id=null,g.yield(SnapActions.addBlock(d,c,f),2);c.scripts.adjustBounds();g.jumpToEnd()})};SpriteIconMorph.prototype.copyCostume=function(a){a=a.copy();a.name=this.object.newCostumeName(a.name);SnapActions.addCostume(a,this.object)};SpriteIconMorph.prototype.copySound=function(a){SnapActions.addSound(a,this.object)}; -SpriteIconMorph.prototype.flash=function(){var a=this,b=this.world(),c=MorphicPreferences.isFlat,d=SpriteMorph.prototype.highlightColor,e=c?this.pressColor:this.outlineColor,f=this.outline,g=this.userState;c?this.pressColor=d:(this.outlineColor=d,this.outline=2);this.userState="pressed";this.rerender();b.animations.push(new Animation(nop,nop,0,800,nop,function(){c?a.pressColor=e:(a.outlineColor=e,a.outline=f);a.userState=g;a.rerender()}))};CostumeIconMorph.prototype=new ToggleButtonMorph; +SpriteIconMorph.prototype.copyStack=async function(a){var b=this.object,c=a.id?a.fullCopy():a;a=Math.max(b.scripts.children.map(d=>d.fullBounds().bottom()).concat([b.scripts.top()]));a=new Point(this.object.scripts.left()+20,a+20);c.allComments().forEach(d=>d.align(c));c.allChildren().forEach(d=>{!d.isCustomBlock||d.isGlobal||b.getMethod(d.blockSpec)||d.deleteBlock()});c.id=null;await SnapActions.addBlock(c,b,a);b.scripts.adjustBounds()}; +SpriteIconMorph.prototype.copyCostume=function(a){a=a.copy();a.name=this.object.newCostumeName(a.name);SnapActions.addCostume(a,this.object)};SpriteIconMorph.prototype.copySound=function(a){SnapActions.addSound(a,this.object)}; +SpriteIconMorph.prototype.flash=function(){var a=this.world(),b=MorphicPreferences.isFlat,c=SpriteMorph.prototype.highlightColor,d=b?this.pressColor:this.outlineColor,e=this.outline,f=this.userState;b?this.pressColor=c:(this.outlineColor=c,this.outline=2);this.userState="pressed";this.rerender();a.animations.push(new Animation(nop,nop,0,800,nop,()=>{b?this.pressColor=d:(this.outlineColor=d,this.outline=e);this.userState=f;this.rerender()}))};CostumeIconMorph.prototype=new ToggleButtonMorph; CostumeIconMorph.prototype.constructor=CostumeIconMorph;CostumeIconMorph.uber=ToggleButtonMorph.prototype;CostumeIconMorph.prototype.thumbSize=new Point(80,60);CostumeIconMorph.prototype.labelShadowOffset=null;CostumeIconMorph.prototype.labelShadowColor=null;CostumeIconMorph.prototype.labelColor=WHITE;CostumeIconMorph.prototype.fontSize=9;function CostumeIconMorph(a){this.init(a)} -CostumeIconMorph.prototype.init=function(a){var b=this;var c=[IDE_Morph.prototype.groupColor,IDE_Morph.prototype.frameColor,IDE_Morph.prototype.frameColor];this.object=a||new Costume;this.version=this.object.version;this.thumbnail=null;CostumeIconMorph.uber.init.call(this,c,null,function(){var d=b.parentThatIsA(IDE_Morph),e=b.parentThatIsA(WardrobeMorph);d&&d.currentSprite.wearCostume(b.object);e&&e.updateSelection()},this.object.name,function(){var d=b.parentThatIsA(IDE_Morph);return d?d.currentSprite.costume=== -b.object:!1},null,null);this.isDraggable=!0;this.createThumbnail();this.padding=2;this.corner=8;this.fixLayout();this.fps=1};CostumeIconMorph.prototype.createThumbnail=function(){SpriteIconMorph.prototype.createThumbnail.call(this);if(this.object instanceof SVG_Costume){var a=new StringMorph("svg",.8*this.fontSize,this.fontStyle,!1,!1,!1,this.labelShadowOffset,this.labelShadowColor,this.labelColor);a.setBottom(this.thumbnail.bottom());this.thumbnail.add(a)}}; +CostumeIconMorph.prototype.init=function(a){var b=[IDE_Morph.prototype.groupColor,IDE_Morph.prototype.frameColor,IDE_Morph.prototype.frameColor];this.object=a||new Costume;this.version=this.object.version;this.thumbnail=null;CostumeIconMorph.uber.init.call(this,b,null,()=>{var c=this.parentThatIsA(IDE_Morph),d=this.parentThatIsA(WardrobeMorph);c&&c.currentSprite.wearCostume(this.object);d&&d.updateSelection()},this.object.name,()=>{var c=this.parentThatIsA(IDE_Morph);return c?c.currentSprite.costume=== +this.object:!1},null,null);this.isDraggable=!0;this.createThumbnail();this.padding=2;this.corner=8;this.fixLayout();this.fps=1};CostumeIconMorph.prototype.createThumbnail=function(){SpriteIconMorph.prototype.createThumbnail.call(this);if(this.object instanceof SVG_Costume){var a=new StringMorph("svg",.8*this.fontSize,this.fontStyle,!1,!1,!1,this.labelShadowOffset,this.labelShadowColor,this.labelColor);a.setBottom(this.thumbnail.bottom());this.thumbnail.add(a)}}; CostumeIconMorph.prototype.createLabel=SpriteIconMorph.prototype.createLabel;CostumeIconMorph.prototype.step=SpriteIconMorph.prototype.step;CostumeIconMorph.prototype.fixLayout=SpriteIconMorph.prototype.fixLayout; CostumeIconMorph.prototype.userMenu=function(){var a=new MenuMorph(this);if(!(this.object instanceof Costume))return null;a.addItem("edit","editCostume");16===this.world().currentKey&&a.addItem("edit rotation point only...","editRotationPointOnly",null,new Color(100,0,0));a.addItem("rename","renameCostume");a.addLine();a.addItem("duplicate","duplicateCostume");a.addItem("delete","removeCostume");a.addLine();a.addItem("export","exportCostume");return a}; -CostumeIconMorph.prototype.editCostume=function(){var a=this,b=this.object.copy();this.disinherit();if(this.object instanceof SVG_Costume&&0===this.object.shapes.length)try{this.object.parseShapes()}catch(c){this.editRotationPointOnly();return}this.object.edit(this.world(),this.parentThatIsA(IDE_Morph),!1,null,function(){return SnapActions.updateCostume(b,a.object)})}; +CostumeIconMorph.prototype.editCostume=function(){var a=this.object.copy();this.disinherit();if(this.object instanceof SVG_Costume&&0===this.object.shapes.length)try{this.object.parseShapes()}catch(b){this.editRotationPointOnly();return}this.object.edit(this.world(),this.parentThatIsA(IDE_Morph),!1,null,()=>SnapActions.updateCostume(a,this.object))}; CostumeIconMorph.prototype.editRotationPointOnly=function(){var a=this.parentThatIsA(IDE_Morph);this.object.editRotationPointOnly(this.world());a.hasChangedMedia=!0}; -CostumeIconMorph.prototype.renameCostume=function(){this.disinherit();var a=this.object,b=this.parentThatIsA(WardrobeMorph);this.parentThatIsA(IDE_Morph);(new DialogBoxMorph(null,function(c){c&&c!==a.name&&(c=b.sprite.newCostumeName(c,a),SnapActions.renameCostume(a,c))})).prompt(this.currentSprite instanceof SpriteMorph?"rename costume":"rename background",a.name,this.world())}; +CostumeIconMorph.prototype.renameCostume=function(){this.disinherit();var a=this.object,b=this.parentThatIsA(WardrobeMorph);this.parentThatIsA(IDE_Morph);(new DialogBoxMorph(null,c=>{c&&c!==a.name&&(c=b.sprite.newCostumeName(c,a),SnapActions.renameCostume(a,c))})).prompt(this.currentSprite instanceof SpriteMorph?"rename costume":"rename background",a.name,this.world())}; CostumeIconMorph.prototype.duplicateCostume=function(){var a=this.parentThatIsA(WardrobeMorph);this.parentThatIsA(IDE_Morph);var b=this.object.copy();b.name=a.sprite.newCostumeName(b.name);SnapActions.addCostume(b,a.sprite)};CostumeIconMorph.prototype.removeCostume=function(){SnapActions.removeCostume(this.object)}; CostumeIconMorph.prototype.exportCostume=function(){var a=this.parentThatIsA(IDE_Morph);this.object instanceof SVG_Costume?a.saveFileAs(this.object.contents.src,"text/svg",this.object.name):a.saveCanvasAs(this.object.contents,this.object.name)};CostumeIconMorph.prototype.render=SpriteIconMorph.prototype.render; CostumeIconMorph.prototype.disinherit=function(){var a=this.parentThatIsA(WardrobeMorph),b=this.parent.children.indexOf(this);a.sprite.inheritsAttribute("costumes")&&(a.sprite.shadowAttribute("costumes"),this.object=a.sprite.costumes.at(b-3))};CostumeIconMorph.prototype.prepareToBeGrabbed=function(){this.disinherit();this.mouseClickLeft();this.localRemoveCostume()}; CostumeIconMorph.prototype.localRemoveCostume=function(){var a=this.parentThatIsA(WardrobeMorph),b=this.parent.children.indexOf(this),c=this.parentThatIsA(IDE_Morph);a.removeCostumeAt(b-2);c.currentSprite.costume===this.object&&c.currentSprite.wearCostume(null)};TurtleIconMorph.prototype=new ToggleButtonMorph;TurtleIconMorph.prototype.constructor=TurtleIconMorph;TurtleIconMorph.uber=ToggleButtonMorph.prototype;TurtleIconMorph.prototype.thumbSize=new Point(80,60); TurtleIconMorph.prototype.labelShadowOffset=null;TurtleIconMorph.prototype.labelShadowColor=null;TurtleIconMorph.prototype.labelColor=WHITE;TurtleIconMorph.prototype.fontSize=9;function TurtleIconMorph(a){this.init(a)} -TurtleIconMorph.prototype.init=function(a){var b=this;var c=[IDE_Morph.prototype.groupColor,IDE_Morph.prototype.frameColor,IDE_Morph.prototype.frameColor];this.object=a;this.version=this.object.version;this.thumbnail=null;TurtleIconMorph.uber.init.call(this,c,null,function(){var d=b.parentThatIsA(IDE_Morph),e=b.parentThatIsA(WardrobeMorph);d&&d.currentSprite.wearCostume(null);e&&e.updateSelection()},"default",function(){var d=b.parentThatIsA(IDE_Morph);return d?null===d.currentSprite.costume:!1}, -null,null);this.isDraggable=!1;this.createThumbnail();this.padding=2;this.corner=8;this.fixLayout()};TurtleIconMorph.prototype.createThumbnail=function(){var a=MorphicPreferences.isFlat;this.thumbnail&&this.thumbnail.destroy();this.thumbnail=this.object instanceof SpriteMorph?new SymbolMorph("turtle",this.thumbSize.y,this.labelColor,a?null:new Point(-1,-1),new Color(0,0,0)):new SymbolMorph("stage",this.thumbSize.y,this.labelColor,a?null:new Point(-1,-1),new Color(0,0,0));this.add(this.thumbnail)}; +TurtleIconMorph.prototype.init=function(a){var b=[IDE_Morph.prototype.groupColor,IDE_Morph.prototype.frameColor,IDE_Morph.prototype.frameColor];this.object=a;this.version=this.object.version;this.thumbnail=null;TurtleIconMorph.uber.init.call(this,b,null,()=>{var c=this.parentThatIsA(IDE_Morph),d=this.parentThatIsA(WardrobeMorph);c&&c.currentSprite.wearCostume(null);d&&d.updateSelection()},"default",()=>{var c=this.parentThatIsA(IDE_Morph);return c?null===c.currentSprite.costume:!1},null,null);this.isDraggable= +!1;this.createThumbnail();this.padding=2;this.corner=8;this.fixLayout()};TurtleIconMorph.prototype.createThumbnail=function(){var a=MorphicPreferences.isFlat;this.thumbnail&&this.thumbnail.destroy();this.thumbnail=this.object instanceof SpriteMorph?new SymbolMorph("turtle",this.thumbSize.y,this.labelColor,a?null:new Point(-1,-1),new Color(0,0,0)):new SymbolMorph("stage",this.thumbSize.y,this.labelColor,a?null:new Point(-1,-1),new Color(0,0,0));this.add(this.thumbnail)}; TurtleIconMorph.prototype.createLabel=function(){this.label&&this.label.destroy();var a=new StringMorph(localize(this.object instanceof SpriteMorph?"Turtle":"Empty"),this.fontSize,this.fontStyle,!0,!1,!1,this.labelShadowOffset,this.labelShadowColor,this.labelColor);this.label=new FrameMorph;this.label.acceptsDrops=!1;this.label.alpha=0;this.label.setExtent(a.extent());a.setPosition(this.label.position());this.label.add(a);this.add(this.label)};TurtleIconMorph.prototype.fixLayout=SpriteIconMorph.prototype.fixLayout; TurtleIconMorph.prototype.render=SpriteIconMorph.prototype.render; -TurtleIconMorph.prototype.userMenu=function(){var a=this,b=new MenuMorph(this,"pen");if(this.object instanceof StageMorph)return null;b.addItem(("tip"===this.object.penPoint?"\u25cf":"\u25cb")+" "+localize("tip"),function(){a.object.penPoint="tip";a.object.changed();a.object.fixLayout();a.object.rerender()});b.addItem(("middle"===this.object.penPoint?"\u25cf":"\u25cb")+" "+localize("middle"),function(){a.object.penPoint="middle";a.object.changed();a.object.fixLayout();a.object.rerender()});return b}; +TurtleIconMorph.prototype.userMenu=function(){var a=new MenuMorph(this,"pen");if(this.object instanceof StageMorph)return null;a.addItem(("tip"===this.object.penPoint?"\u25cf":"\u25cb")+" "+localize("tip"),()=>{this.object.penPoint="tip";this.object.changed();this.object.fixLayout();this.object.rerender()});a.addItem(("middle"===this.object.penPoint?"\u25cf":"\u25cb")+" "+localize("middle"),()=>{this.object.penPoint="middle";this.object.changed();this.object.fixLayout();this.object.rerender()});return a}; WardrobeMorph.prototype=new ScrollFrameMorph;WardrobeMorph.prototype.undoCategory="costumes";WardrobeMorph.prototype.constructor=WardrobeMorph;WardrobeMorph.uber=ScrollFrameMorph.prototype;function WardrobeMorph(a,b){this.init(a,b)}WardrobeMorph.prototype.init=function(a,b){this.sprite=a||new SpriteMorph;this.spriteVersion=this.costumesVersion=null;WardrobeMorph.uber.init.call(this,null,null,b);this.fps=2;this.updateList()}; -WardrobeMorph.prototype.updateList=function(){var a=this,b=this.left()+5,c=this.top()+5,d=this.contents.position();this.changed();this.contents.destroy();this.contents=new FrameMorph(this);this.contents.acceptsDrops=!1;this.contents.reactToDropOf=function(h){a.reactToDropOf(h)};this.addBack(this.contents);var e=new TurtleIconMorph(this.sprite);e.setPosition(new Point(b,c));this.addContents(e);c=e.bottom()+4;var f=new PushButtonMorph(this,"paintNew",new SymbolMorph("brush",15));f.padding=0;f.corner= -12;f.color=IDE_Morph.prototype.groupColor;f.highlightColor=IDE_Morph.prototype.frameColor.darker(50);f.pressColor=f.highlightColor;f.labelMinExtent=new Point(36,18);f.labelShadowOffset=new Point(-1,-1);f.labelShadowColor=f.highlightColor;f.labelColor=TurtleIconMorph.prototype.labelColor;f.contrast=this.buttonContrast;f.hint="Paint a new costume";f.setPosition(new Point(b,c));f.fixLayout();f.setCenter(e.center());f.setLeft(e.right()+16);this.addContents(f);if(CamSnapshotDialogMorph.prototype.enableCamera){var g= -new PushButtonMorph(this,"newFromCam",new SymbolMorph("camera",15));g.padding=0;g.corner=12;g.color=IDE_Morph.prototype.groupColor;g.highlightColor=IDE_Morph.prototype.frameColor.darker(50);g.pressColor=f.highlightColor;g.labelMinExtent=new Point(36,18);g.labelShadowOffset=new Point(-1,-1);g.labelShadowColor=f.highlightColor;g.labelColor=TurtleIconMorph.prototype.labelColor;g.contrast=this.buttonContrast;g.hint="Import a new costume from your webcam";g.setPosition(new Point(b,c));g.fixLayout();g.setCenter(f.center()); -g.setLeft(f.right()+5);this.addContents(g);CamSnapshotDialogMorph.prototype.enabled||(g.disable(),g.hint=CamSnapshotDialogMorph.prototype.notSupportedMessage);document.addEventListener("cameraDisabled",function(){g.disable();g.hint=CamSnapshotDialogMorph.prototype.notSupportedMessage})}f=new TextMorph(localize("costumes tab help"));f.fontSize=9;f.setColor(SpriteMorph.prototype.paletteTextColor);f.setPosition(new Point(b,c));this.addContents(f);c=f.bottom()+4;this.sprite.costumes.asArray().forEach(function(h){e= -new CostumeIconMorph(h);e.setPosition(new Point(b,c));a.addContents(e);c=e.bottom()+4});this.costumesVersion=this.sprite.costumes.lastChanged;this.contents.setPosition(d);this.adjustScrollBars();this.changed();this.updateSelection();this.onNextStep=this.updateToolbar};WardrobeMorph.prototype.updateSelection=function(){this.contents.children.forEach(function(a){a.refresh&&a.refresh()});this.spriteVersion=this.sprite.version}; +WardrobeMorph.prototype.updateList=function(){var a=this.left()+5,b=this.top()+5,c=this.contents.position();this.changed();this.contents.destroy();this.contents=new FrameMorph(this);this.contents.acceptsDrops=!1;this.contents.reactToDropOf=g=>{this.reactToDropOf(g)};this.addBack(this.contents);var d=new TurtleIconMorph(this.sprite);d.setPosition(new Point(a,b));this.addContents(d);b=d.bottom()+4;var e=new PushButtonMorph(this,"paintNew",new SymbolMorph("brush",15));e.padding=0;e.corner=12;e.color= +IDE_Morph.prototype.groupColor;e.highlightColor=IDE_Morph.prototype.frameColor.darker(50);e.pressColor=e.highlightColor;e.labelMinExtent=new Point(36,18);e.labelShadowOffset=new Point(-1,-1);e.labelShadowColor=e.highlightColor;e.labelColor=TurtleIconMorph.prototype.labelColor;e.contrast=this.buttonContrast;e.hint="Paint a new costume";e.setPosition(new Point(a,b));e.fixLayout();e.setCenter(d.center());e.setLeft(d.right()+16);this.addContents(e);if(CamSnapshotDialogMorph.prototype.enableCamera){var f= +new PushButtonMorph(this,"newFromCam",new SymbolMorph("camera",15));f.padding=0;f.corner=12;f.color=IDE_Morph.prototype.groupColor;f.highlightColor=IDE_Morph.prototype.frameColor.darker(50);f.pressColor=e.highlightColor;f.labelMinExtent=new Point(36,18);f.labelShadowOffset=new Point(-1,-1);f.labelShadowColor=e.highlightColor;f.labelColor=TurtleIconMorph.prototype.labelColor;f.contrast=this.buttonContrast;f.hint="Import a new costume from your webcam";f.setPosition(new Point(a,b));f.fixLayout();f.setCenter(e.center()); +f.setLeft(e.right()+5);this.addContents(f);CamSnapshotDialogMorph.prototype.enabled||(f.disable(),f.hint=CamSnapshotDialogMorph.prototype.notSupportedMessage);document.addEventListener("cameraDisabled",()=>{f.disable();f.hint=CamSnapshotDialogMorph.prototype.notSupportedMessage})}e=new TextMorph(localize("costumes tab help"));e.fontSize=9;e.setColor(SpriteMorph.prototype.paletteTextColor);e.setPosition(new Point(a,b));this.addContents(e);b=e.bottom()+4;this.sprite.costumes.asArray().forEach(g=>{d= +new CostumeIconMorph(g);d.setPosition(new Point(a,b));this.addContents(d);b=d.bottom()+4});this.costumesVersion=this.sprite.costumes.lastChanged;this.contents.setPosition(c);this.adjustScrollBars();this.changed();this.updateSelection();this.onNextStep=this.updateToolbar};WardrobeMorph.prototype.updateSelection=function(){this.contents.children.forEach(function(a){a.refresh&&a.refresh()});this.spriteVersion=this.sprite.version}; WardrobeMorph.prototype.step=function(){this.costumesVersion!==this.sprite.costumes.lastChanged&&this.updateList();this.spriteVersion!==this.sprite.version&&this.updateSelection()};WardrobeMorph.prototype.removeCostumeAt=function(a){this.sprite.shadowAttribute("costumes");this.sprite.costumes.remove(a);this.updateList()}; -WardrobeMorph.prototype.paintNew=function(){var a=this,b=this.sprite.newCostumeName(localize("untitled")),c=this.parentThatIsA(IDE_Morph),d=new Costume(newCanvas(null,!0),b);d.edit(this.world(),c,!0,null,function(){return SnapActions.addCostume(d,a.sprite)})};WardrobeMorph.prototype.newFromCam=function(){var a=this.parentThatIsA(IDE_Morph);var b=this.sprite;a=new CamSnapshotDialogMorph(a,b,nop,function(c){SnapActions.addCostume(c,b).then(function(d){return b.wearCostume(d)})});a.key="camera";a.popUp(this.world())}; -WardrobeMorph.prototype.wantsDropOf=function(a){return a instanceof CostumeIconMorph};WardrobeMorph.prototype.reactToDropOf=function(a){var b=0,c=a.object,d=a.top();a.destroy();this.contents.children.forEach(function(e){e instanceof CostumeIconMorph&&e.top()SnapActions.addCostume(c,this.sprite))};WardrobeMorph.prototype.newFromCam=function(){var a=this.parentThatIsA(IDE_Morph);var b=this.sprite;a=new CamSnapshotDialogMorph(a,b,nop,c=>{SnapActions.addCostume(c,b).then(d=>b.wearCostume(d))});a.key="camera";a.popUp(this.world())}; +WardrobeMorph.prototype.wantsDropOf=function(a){return a instanceof CostumeIconMorph};WardrobeMorph.prototype.reactToDropOf=function(a){var b=0,c=a.object,d=a.top();a.destroy();this.contents.children.forEach(e=>{e instanceof CostumeIconMorph&&e.top()!1,null,null);this.isDraggable=!0;this.createThumbnail();this.padding=2;this.corner=8;this.fixLayout();this.fps=1}; SoundIconMorph.prototype.createThumbnail=function(){this.thumbnail&&this.thumbnail.destroy();this.thumbnail=new Morph;this.thumbnail.bounds.setExtent(this.thumbSize);this.add(this.thumbnail);var a=new StringMorph(this.createInfo(),"16","",!0,!1,!1,this.labelShadowOffset,this.labelShadowColor,new Color(200,200,200));this.thumbnail.add(a);a.setCenter(new Point(40,15));this.button=new PushButtonMorph(this,"toggleAudioPlaying",this.object.previewAudio?"Stop":"Play");this.button.hint="Play sound";this.button.fixLayout(); this.thumbnail.add(this.button);this.button.setCenter(new Point(40,40))};SoundIconMorph.prototype.createInfo=function(){var a=Math.round(this.object.audio.duration||0),b=a%60;return Math.floor(a/60).toString()+":"+(10>b?"0":"")+b.toString()}; -SoundIconMorph.prototype.toggleAudioPlaying=function(){var a=this;this.object.previewAudio?(this.button.labelString="Play",this.button.hint="Play sound",this.object.previewAudio.pause(),this.object.previewAudio.terminated=!0,this.object.previewAudio=null):(this.button.labelString="Stop",this.button.hint="Stop sound",this.object.previewAudio=this.object.play(),this.object.previewAudio.addEventListener("ended",function(){return a.audioHasEnded()},!1));this.button.createLabel()}; +SoundIconMorph.prototype.toggleAudioPlaying=function(){this.object.previewAudio?(this.button.labelString="Play",this.button.hint="Play sound",this.object.previewAudio.pause(),this.object.previewAudio.terminated=!0,this.object.previewAudio=null):(this.button.labelString="Stop",this.button.hint="Stop sound",this.object.previewAudio=this.object.play(),this.object.previewAudio.addEventListener("ended",()=>this.audioHasEnded(),!1));this.button.createLabel()}; SoundIconMorph.prototype.audioHasEnded=function(){this.button.trigger();this.button.mouseLeave()};SoundIconMorph.prototype.createLabel=SpriteIconMorph.prototype.createLabel;SoundIconMorph.prototype.fixLayout=SpriteIconMorph.prototype.fixLayout;SoundIconMorph.prototype.userMenu=function(){var a=new MenuMorph(this);if(!(this.object instanceof Sound))return null;a.addItem("rename","renameSound");a.addItem("delete","removeSound");a.addLine();a.addItem("export","exportSound");return a}; -SoundIconMorph.prototype.renameSound=function(){var a=this.object;this.parentThatIsA(IDE_Morph);this.disinherit();(new DialogBoxMorph(null,function(b){b&&b!==a.name&&SnapActions.renameSound(a,b)})).prompt("rename sound",a.name,this.world())};SoundIconMorph.prototype.removeSound=function(){SnapActions.removeSound(this.object)};SoundIconMorph.prototype.localRemoveSound=function(){var a=this.parentThatIsA(JukeboxMorph),b=this.parent.children.indexOf(this)-1;a.removeSound(b)}; +SoundIconMorph.prototype.renameSound=function(){var a=this.object;this.parentThatIsA(IDE_Morph);this.disinherit();(new DialogBoxMorph(null,b=>{b&&b!==a.name&&SnapActions.renameSound(a,b)})).prompt("rename sound",a.name,this.world())};SoundIconMorph.prototype.removeSound=function(){SnapActions.removeSound(this.object)};SoundIconMorph.prototype.localRemoveSound=function(){var a=this.parentThatIsA(JukeboxMorph),b=this.parent.children.indexOf(this)-1;a.removeSound(b)}; SoundIconMorph.prototype.exportSound=function(){this.parentThatIsA(IDE_Morph).saveAudioAs(this.object.audio,this.object.name)};SoundIconMorph.prototype.render=SpriteIconMorph.prototype.render;SoundIconMorph.prototype.createLabel=SpriteIconMorph.prototype.createLabel;SoundIconMorph.prototype.disinherit=function(){var a=this.parentThatIsA(JukeboxMorph),b=this.parent.children.indexOf(this);a.sprite.inheritsAttribute("sounds")&&(a.sprite.shadowAttribute("sounds"),this.object=a.sprite.sounds.at(b-1))}; SoundIconMorph.prototype.prepareToBeGrabbed=function(){this.disinherit();this.userState="pressed";this.state=!0;this.rerender();this.localRemoveSound()};JukeboxMorph.prototype=new ScrollFrameMorph;JukeboxMorph.prototype.undoCategory="sounds";JukeboxMorph.prototype.constructor=JukeboxMorph;JukeboxMorph.uber=ScrollFrameMorph.prototype;function JukeboxMorph(a,b){this.init(a,b)} JukeboxMorph.prototype.init=function(a,b){this.sprite=a||new SpriteMorph;this.spriteVersion=this.soundsVersion=null;JukeboxMorph.uber.init.call(this,null,null,b);this.acceptsDrops=!1;this.fps=2;this.updateList()}; -JukeboxMorph.prototype.updateList=function(){var a=this,b=this.left()+5,c=this.top()+5,d,e=this.sprite.parentThatIsA(IDE_Morph);this.changed();this.contents.destroy();this.contents=new FrameMorph(this);this.contents.acceptsDrops=!1;this.contents.reactToDropOf=function(g){return a.reactToDropOf(g)};this.addBack(this.contents);var f=new TextMorph(localize("import a sound from your computer\nby dragging it into here"));f.fontSize=9;f.setColor(SpriteMorph.prototype.paletteTextColor);f.setPosition(new Point(b, -c));this.addContents(f);e=new PushButtonMorph(e,"recordNewSound",new SymbolMorph("circleSolid",15));e.padding=0;e.corner=12;e.color=IDE_Morph.prototype.groupColor;e.highlightColor=IDE_Morph.prototype.frameColor.darker(50);e.pressColor=e.highlightColor;e.labelMinExtent=new Point(36,18);e.labelShadowOffset=new Point(-1,-1);e.labelShadowColor=e.highlightColor;e.labelColor=TurtleIconMorph.prototype.labelColor;e.contrast=this.buttonContrast;e.hint="Record a new sound";e.fixLayout();e.label.setColor(new Color(255, -20,20));e.setPosition(f.bottomLeft().add(new Point(0,8)));this.addContents(e);c=e.bottom()+4;this.sprite.sounds.asArray().forEach(function(g){d=new SoundIconMorph(g);d.setPosition(new Point(b,c));a.addContents(d);c=d.bottom()+4});this.soundsVersion=this.sprite.sounds.lastChanged;this.changed();this.updateSelection();this.onNextStep=this.updateToolbar};JukeboxMorph.prototype.updateSelection=function(){this.contents.children.forEach(function(a){a.refresh&&a.refresh()});this.spriteVersion=this.sprite.version}; +JukeboxMorph.prototype.updateList=function(){var a=this.left()+5,b=this.top()+5,c,d=this.sprite.parentThatIsA(IDE_Morph);this.changed();this.contents.destroy();this.contents=new FrameMorph(this);this.contents.acceptsDrops=!1;this.contents.reactToDropOf=f=>this.reactToDropOf(f);this.addBack(this.contents);var e=new TextMorph(localize("import a sound from your computer\nby dragging it into here"));e.fontSize=9;e.setColor(SpriteMorph.prototype.paletteTextColor);e.setPosition(new Point(a,b));this.addContents(e); +d=new PushButtonMorph(d,"recordNewSound",new SymbolMorph("circleSolid",15));d.padding=0;d.corner=12;d.color=IDE_Morph.prototype.groupColor;d.highlightColor=IDE_Morph.prototype.frameColor.darker(50);d.pressColor=d.highlightColor;d.labelMinExtent=new Point(36,18);d.labelShadowOffset=new Point(-1,-1);d.labelShadowColor=d.highlightColor;d.labelColor=TurtleIconMorph.prototype.labelColor;d.contrast=this.buttonContrast;d.hint="Record a new sound";d.fixLayout();d.label.setColor(new Color(255,20,20));d.setPosition(e.bottomLeft().add(new Point(0, +8)));this.addContents(d);b=d.bottom()+4;this.sprite.sounds.asArray().forEach(f=>{c=new SoundIconMorph(f);c.setPosition(new Point(a,b));this.addContents(c);b=c.bottom()+4});this.soundsVersion=this.sprite.sounds.lastChanged;this.changed();this.updateSelection();this.onNextStep=this.updateToolbar};JukeboxMorph.prototype.updateSelection=function(){this.contents.children.forEach(a=>{a.refresh&&a.refresh()});this.spriteVersion=this.sprite.version}; JukeboxMorph.prototype.step=function(){this.soundsVersion!==this.sprite.sounds.lastChanged&&this.updateList();this.spriteVersion!==this.sprite.version&&this.updateSelection()};JukeboxMorph.prototype.removeSound=function(a){this.sprite.sounds.remove(a);this.updateList()};JukeboxMorph.prototype.wantsDropOf=function(a){return a instanceof SoundIconMorph}; -JukeboxMorph.prototype.reactToDropOf=function(a){var b=0,c=a.object,d=a.top();a.destroy();this.contents.children.forEach(function(e){e instanceof SoundIconMorph&&e.top(){e instanceof SoundIconMorph&&e.top()g;g+=1)0g;g+=1)0h/k){var l=h/k*f;g=h}else l=g,g=g/f*k;e.drawImage(c.videoElement,0,0,l,g,-1*this.left(),this.top(),f,k);e.restore()}};this.videoView.step=function(){this.changed()};this.addBody(new AlignmentMorph("column",this.padding/2));this.body.add(this.videoView);this.body.fixLayout();this.addButton("ok","Save");this.addButton("cancel","Cancel");this.fixLayout();this.rerender()};CamSnapshotDialogMorph.prototype.ok=function(){this.accept((new Costume(this.videoView.fullImage(),this.sprite.newCostumeName("camera"))).flipped())}; +CamSnapshotDialogMorph.prototype.buildContents=function(){function a(){b.disable();b.ide.inform("Camera not supported",CamSnapshotDialogMorph.prototype.notSupportedMessage);b.videoElement&&b.videoElement.remove();b.cancel()}var b=this,c=this.sprite.parentThatIsA(StageMorph);this.videoElement=document.createElement("video");this.videoElement.hidden=!0;this.videoElement.width=c.dimensions.x;this.videoElement.height=c.dimensions.y;document.body.appendChild(this.videoElement);navigator.mediaDevices&& +navigator.mediaDevices.getUserMedia&&navigator.mediaDevices.getUserMedia({video:!0}).then(d=>{this.videoElement.srcObject=d;this.videoElement.play().catch(a);this.videoElement.stream=d}).catch(a);this.videoView.setExtent(c.dimensions);this.videoView.cachedImage=newCanvas(c.dimensions,!0,this.videoView.cachedImage);this.videoView.drawOn=function(d,e){var f=b.videoElement.videoWidth,g=b.videoElement.videoHeight;e=c.dimensions.x;var h=c.dimensions.y;if(f){d.save();d.translate(e,0);d.scale(-1,1);if(f/ +e>g/h){var k=g/h*e;f=g}else k=f,f=f/e*h;d.drawImage(b.videoElement,0,0,k,f,-1*this.left(),this.top(),e,h);d.restore()}};this.videoView.step=function(){this.changed()};this.addBody(new AlignmentMorph("column",this.padding/2));this.body.add(this.videoView);this.body.fixLayout();this.addButton("ok","Save");this.addButton("cancel","Cancel");this.fixLayout();this.rerender()};CamSnapshotDialogMorph.prototype.ok=function(){this.accept((new Costume(this.videoView.fullImage(),this.sprite.newCostumeName("camera"))).flipped())}; CamSnapshotDialogMorph.prototype.disable=function(){CamSnapshotDialogMorph.prototype.enabled=!1;document.dispatchEvent(new Event("cameraDisabled"))};CamSnapshotDialogMorph.prototype.destroy=function(){this.oncancel.call(this);this.close()};CamSnapshotDialogMorph.prototype.close=function(){this.videoElement&&this.videoElement.stream&&(this.videoElement.stream.getTracks()[0].stop(),this.videoElement.remove());CamSnapshotDialogMorph.uber.destroy.call(this)};SoundRecorderDialogMorph.prototype=new DialogBoxMorph; SoundRecorderDialogMorph.prototype.constructor=SoundRecorderDialogMorph;SoundRecorderDialogMorph.uber=DialogBoxMorph.prototype;function SoundRecorderDialogMorph(a){this.init(a)} SoundRecorderDialogMorph.prototype.init=function(a){var b=this;this.padding=10;this.accept=a;this.mediaRecorder=null;this.audioElement=document.createElement("audio");this.audioElement.hidden=!0;this.audioElement.onended=function(c){b.stop()};document.body.appendChild(this.audioElement);this.playButton=this.stopButton=this.recordButton=null;this.progressBar=new BoxMorph;SoundRecorderDialogMorph.uber.init.call(this);this.labelString="Sound Recorder";this.createLabel();this.buildContents()}; -SoundRecorderDialogMorph.prototype.buildContents=function(){var a=this,b=[];this.recordButton=new PushButtonMorph(this,"record",new SymbolMorph("circleSolid",10));this.stopButton=new PushButtonMorph(this,"stop",new SymbolMorph("rectangleSolid",10));this.playButton=new PushButtonMorph(this,"play",new SymbolMorph("pointRight",10));this.buildProgressBar();this.addBody(new AlignmentMorph("row",this.padding));this.body.add(this.recordButton);this.body.add(this.stopButton);this.body.add(this.playButton); -this.body.add(this.progressBar);this.body.fixLayout();navigator.mediaDevices&&navigator.mediaDevices.getUserMedia&&navigator.mediaDevices.getUserMedia({audio:{channelCount:1}}).then(function(c){a.mediaRecorder=new MediaRecorder(c);a.mediaRecorder.ondataavailable=function(d){b.push(d.data)};a.mediaRecorder.onstop=function(d){d=new Blob(b);var e=new window.FileReader;e.readAsDataURL(d);e.onloadend=function(){var f=e.result;f="data:audio/ogg;base64,"+f.split(",")[1];a.audioElement.src=f;a.audioElement.load(); -b=[]}}});this.addButton("ok","Save");this.addButton("cancel","Cancel");this.fixLayout();this.rerender()}; +SoundRecorderDialogMorph.prototype.buildContents=function(){var a=[];this.recordButton=new PushButtonMorph(this,"record",new SymbolMorph("circleSolid",10));this.stopButton=new PushButtonMorph(this,"stop",new SymbolMorph("rectangleSolid",10));this.playButton=new PushButtonMorph(this,"play",new SymbolMorph("pointRight",10));this.buildProgressBar();this.addBody(new AlignmentMorph("row",this.padding));this.body.add(this.recordButton);this.body.add(this.stopButton);this.body.add(this.playButton);this.body.add(this.progressBar); +this.body.fixLayout();navigator.mediaDevices&&navigator.mediaDevices.getUserMedia&&navigator.mediaDevices.getUserMedia({audio:{channelCount:1}}).then(b=>{this.mediaRecorder=new MediaRecorder(b);this.mediaRecorder.ondataavailable=c=>{a.push(c.data)};this.mediaRecorder.onstop=c=>{c=new Blob(a);var d=new window.FileReader;d.readAsDataURL(c);d.onloadend=()=>{var e=d.result;e="data:audio/ogg;base64,"+e.split(",")[1];this.audioElement.src=e;this.audioElement.load();a=[]}}});this.addButton("ok","Save"); +this.addButton("cancel","Cancel");this.fixLayout();this.rerender()}; SoundRecorderDialogMorph.prototype.buildProgressBar=function(){var a=new Morph,b=this;this.progressBar.setExtent(new Point(150,20));this.progressBar.setColor(new Color(200,200,200));this.progressBar.setBorderWidth(1);this.progressBar.setBorderColor(new Color(150,150,150));a.setExtent(new Point(130,2));a.setColor(new Color(50,50,50));a.setCenter(this.progressBar.center());this.progressBar.add(a);this.progressBar.indicator=new Morph;this.progressBar.indicator.setExtent(new Point(5,15));this.progressBar.indicator.setColor(new Color(50, 200,50));this.progressBar.indicator.setCenter(a.leftCenter());this.progressBar.add(this.progressBar.indicator);this.progressBar.setPercentage=function(c){this.indicator.setLeft(a.left()+a.width()/100*c-this.indicator.width()/2)};this.progressBar.step=function(){b.audioElement.duration?this.setPercentage(b.audioElement.currentTime/b.audioElement.duration*100):this.setPercentage(0)}}; SoundRecorderDialogMorph.prototype.record=function(){this.mediaRecorder&&"inactive"!==this.mediaRecorder.state?this.stop():(this.mediaRecorder.start(),this.recordButton.label.setColor(new Color(255,0,0)),this.playButton.label.setColor(new Color(0,0,0)))}; SoundRecorderDialogMorph.prototype.stop=function(){this.mediaRecorder&&"inactive"!==this.mediaRecorder.state&&this.mediaRecorder.stop();this.audioElement.pause();this.audioElement.currentTime=0;this.recordButton.label.setColor(new Color(0,0,0));this.playButton.label.setColor(new Color(0,0,0))};SoundRecorderDialogMorph.prototype.play=function(){this.stop();this.audioElement.oncanplaythrough=function(){this.play();this.oncanplaythrough=nop};this.playButton.label.setColor(new Color(0,255,0))}; -SoundRecorderDialogMorph.prototype.ok=function(){var a=this;this.stop();this.audioElement.oncanplaythrough=function(){this.duration&&Infinity!==this.duration?(a.accept(this),this.oncanplaythrough=nop,a.destroy()):(a.buttons.children.forEach(function(b){return b.disable()}),this.play())}};SoundRecorderDialogMorph.prototype.destroy=function(){this.stop();this.audioElement.remove();this.mediaRecorder&&this.mediaRecorder.stream&&this.mediaRecorder.stream.getTracks()[0].stop();SoundRecorderDialogMorph.uber.destroy.call(this)}; +SoundRecorderDialogMorph.prototype.ok=function(){var a=this;this.stop();this.audioElement.oncanplaythrough=function(){this.duration&&Infinity!==this.duration?(a.accept(this),this.oncanplaythrough=nop,a.destroy()):(a.buttons.children.forEach(b=>b.disable()),this.play())}};SoundRecorderDialogMorph.prototype.destroy=function(){this.stop();this.audioElement.remove();this.mediaRecorder&&this.mediaRecorder.stream&&this.mediaRecorder.stream.getTracks()[0].stop();SoundRecorderDialogMorph.uber.destroy.call(this)}; modules.paint="2020-July-13";PaintEditorMorph.prototype=new DialogBoxMorph;PaintEditorMorph.prototype.constructor=PaintEditorMorph;PaintEditorMorph.uber=DialogBoxMorph.prototype;PaintEditorMorph.prototype.padding=10;function PaintEditorMorph(){this.init()}PaintEditorMorph.prototype.init=function(){this.oncancel=this.paper=null;PaintEditorMorph.uber.init.call(this);this.labelString="Paint Editor";this.createLabel();this.buildContents()}; PaintEditorMorph.prototype.buildContents=function(){var a=this;this.paper=new PaintCanvasMorph(function(){return a.shift});this.paper.setExtent(StageMorph.prototype.dimensions);this.addBody(new AlignmentMorph("row",this.padding));this.controls=new AlignmentMorph("column",this.padding/2);this.controls.alignment="center";this.edits=new AlignmentMorph("row",this.padding/2);this.buildEdits();this.controls.add(this.edits);this.body.color=this.color;this.body.add(this.controls);this.body.add(this.paper); this.toolbox=new BoxMorph;this.toolbox.color=SpriteMorph.prototype.paletteColor.lighter(8);this.toolbox.borderColor=this.toolbox.color.lighter(40);MorphicPreferences.isFlat&&(this.toolbox.edge=0);this.buildToolbox();this.controls.add(this.toolbox);this.scaleBox=new AlignmentMorph("row",this.padding/2);this.buildScaleBox();this.controls.add(this.scaleBox);this.propertiesControls={colorpicker:null,penSizeSlider:null,penSizeField:null,primaryColorButton:null,primaryColorViewer:null,constrain:null};this.populatePropertiesMenu(); this.addButton("ok","OK");this.addButton("cancel","Cancel");this.refreshToolButtons();this.fixLayout()}; PaintEditorMorph.prototype.buildToolbox=function(){var a={brush:"Paintbrush tool\n(free draw)",rectangle:"Stroked Rectangle\n(shift: square)",circle:"Stroked Ellipse\n(shift: circle)",eraser:"Eraser tool",crosshairs:"Set the rotation center",line:"Line tool\n(shift: vertical/horizontal)",rectangleSolid:"Filled Rectangle\n(shift: square)",circleSolid:"Filled Ellipse\n(shift: circle)",paintbucket:"Fill a region",pipette:"Pipette tool\n(pick a color anywhere)"},b=this,c=this.toolbox.left(),d=this.toolbox.top(), e=0,f=0;Object.keys(a).forEach(function(g){var h=b.toolButton(g,a[g]);h.setPosition(new Point(c+e,d+f));e+=h.width()+2;"crosshairs"===g&&(e=0,f+=h.height()+2,b.paper.drawcrosshair());b.toolbox[g]=h;b.toolbox.add(h)});this.toolbox.bounds=this.toolbox.fullBounds().expandBy(10)}; -PaintEditorMorph.prototype.buildEdits=function(){var a=this,b=this.paper;this.edits.add(this.pushButton("undo",function(){b.undo()}));this.edits.add(this.pushButton("clear",function(){b.clearCanvas()}));this.edits.add(this.pushButton("Vector",function(){0{setTimeout(()=>{a.switchToVector()})}):a.switchToVector()}));this.edits.fixLayout()}; PaintEditorMorph.prototype.buildScaleBox=function(){var a=this.paper;this.scaleBox.add(this.pushButton(new SymbolMorph("grow",18),function(){a.scale(.05,.05)},"grow"));this.scaleBox.add(this.pushButton(new SymbolMorph("shrink",18),function(){a.scale(-.05,-.05)},"shrink"));this.scaleBox.add(this.pushButton(new SymbolMorph("flipHorizontal",18),function(){a.scale(-2,0)},"flip horizontal"));this.scaleBox.add(this.pushButton(new SymbolMorph("flipVertical",18),function(){a.scale(0,-2)},"flip vertical")); this.scaleBox.fixLayout()}; PaintEditorMorph.prototype.openIn=function(a,b,c,d,e){var f=this;this.oldim=b;this.callback=d||nop;this.ide=e;this.processKeyUp=function(){f.shift=!1;f.propertiesControls.constrain.refresh()};this.processKeyDown=function(){f.shift=16===f.world().currentKey;f.propertiesControls.constrain.refresh()};this.oldim&&(this.paper.automaticCrosshairs=isNil(c),this.paper.centermerge(this.oldim,this.paper.paper),this.paper.rotationCenter=(c||new Point(0,0)).add(new Point((this.paper.paper.width-this.oldim.width)/ @@ -2493,12 +2401,12 @@ PaintCanvasMorph.prototype.edge=InputFieldMorph.prototype.edge;PaintCanvasMorph. function VideoMotion(a,b){this.width=a;this.height=b;this.frameNumber=0;this.winSize=8;this.motionDirection=this.motionAmount=this.lastAnalyzedFrame=0;this.imageBuffer=new ArrayBuffer(this.width*this.height*2);this.curr=new Uint8ClampedArray(this.imageBuffer,0,this.width*this.height);this.prev=new Uint8ClampedArray(this.imageBuffer,this.width*this.height,this.width*this.height);this.threshold=30;this.amountScale=100;this.toDegree=180/Math.PI} VideoMotion.prototype.reset=function(a,b){this.width=a;this.height=b;this.lastAnalyzedFrame=this.frameNumber=0;this.imageBuffer=new ArrayBuffer(this.width*this.height*2);this.curr=new Uint8ClampedArray(this.imageBuffer,0,this.width*this.height);this.prev=new Uint8ClampedArray(this.imageBuffer,this.width*this.height,this.width*this.height)}; VideoMotion.prototype.addFrame=function(a){var b=this.prev;a=new Uint32Array(a.buffer.slice(0));this.frameNumber++;this.prev=this.curr;this.curr=b;for(b=0;bthis.threshold&&(this.motionDirection=((Math.atan2(b,a)*this.toDegree+270)%360-180).toFixed(2))}}; +VideoMotion.prototype.getStageMotion=function(){var a=0,b=0,c=0,d,e,f,g=2*this.winSize+1,h=this.width-this.winSize-1,k=this.height-this.winSize-1,l,m,n,p;if(!this.curr||!this.prev)this.motionAmount=this.motionDirection=-1;else if(this.lastAnalyzedFrame!==this.frameNumber){this.lastAnalyzedFrame=this.frameNumber;for(d=this.winSize+1;dthis.threshold&&(this.motionDirection=((Math.atan2(b,a)*this.toDegree+270)%360-180).toFixed(2))}}; VideoMotion.prototype.getMotionVector=function(a,b,c,d,e){var f=b*b-a*c;var g={u:0,v:0};f?(f=8/f,g.u=-(e*b-d*c)*f,g.v=-(b*d-a*e)*f):(f=(b+a)*(b+a)+(c+b)*(c+b))?(f=8/f,g.u=(b+a)*-(e+d)*f,g.v=(c+b)*-(e+d)*f):(g.u=0,g.v=0);return g}; -VideoMotion.prototype.getLocalMotion=function(a){var b=a.parentThatIsA(StageMorph),c=0,d=Math.floor(a.width()/b.scale),e=this.winSize,f=0,g=0,h=0,k=0,l=0,m=this.threshold/3,n=2E-4*this.amountScale,p=0,r;if(!this.curr||!this.prev)a.motionAmount=a.motionDirection=-1;else if(a.frameNumber!==this.frameNumber){var q=a.getImageData();var t=a.parentThatIsA(StageMorph);var u=t.scale;var v=r=0;var w=Math.floor(a.extent().x/u);var y=Math.floor(a.extent().y/u);a.left()t.right()&&(w=Math.max(Math.floor((t.right()-a.left())/u),0));a.top()t.bottom()&&(y=Math.max(Math.floor((t.bottom()-a.top())/u),0));t=Math.max(Math.floor((a.left()-b.left())/b.scale),0);var x=Math.max(Math.floor((a.top()-b.top())/b.scale),0);u=Math.min(w+t,b.dimensions.x);b=Math.min(y+x,b.dimensions.y-1);r=v*d+r;for(v=x;v>24&255)){var A=v*this.width+x;y=this.prev[A]-this.curr[A];var B=this.curr[A-1]-this.curr[A+1];A=this.curr[A-this.width]-this.curr[A+this.width];f+=B*B;g+=B*A;h+=A*A;l+=B*y;k+=A*y;p++}d=this.getMotionVector(f,g,h,l,k);p&&(c=p,p/=4*e*e,d.u/=p,d.v/=p);a.motionAmount=Math.round(n*c*Math.hypot(d.u,d.v));100m&&(a.motionDirection=((Math.atan2(d.v,d.u)*this.toDegree+270)%360-180).toFixed(2)); +VideoMotion.prototype.getLocalMotion=function(a){var b=a.parentThatIsA(StageMorph),c=0,d=Math.floor(a.width()/b.scale),e=this.winSize,f=0,g=0,h=0,k=0,l=0,m=this.threshold/3,n=2E-4*this.amountScale,p=0,q;if(!this.curr||!this.prev)a.motionAmount=a.motionDirection=-1;else if(a.frameNumber!==this.frameNumber){var r=a.getImageData();var t=a.parentThatIsA(StageMorph);var u=t.scale;var v=q=0;var w=Math.floor(a.extent().x/u);var y=Math.floor(a.extent().y/u);a.left()t.right()&&(w=Math.max(Math.floor((t.right()-a.left())/u),0));a.top()t.bottom()&&(y=Math.max(Math.floor((t.bottom()-a.top())/u),0));t=Math.max(Math.floor((a.left()-b.left())/b.scale),0);var x=Math.max(Math.floor((a.top()-b.top())/b.scale),0);u=Math.min(w+t,b.dimensions.x);b=Math.min(y+x,b.dimensions.y-1);q=v*d+q;for(v=x;v>24&255)){var z=v*this.width+x;y=this.prev[z]-this.curr[z];var A=this.curr[z-1]-this.curr[z+1];z=this.curr[z-this.width]-this.curr[z+this.width];f+=A*A;g+=A*z;h+=z*z;l+=A*y;k+=z*y;p++}d=this.getMotionVector(f,g,h,l,k);p&&(c=p,p/=4*e*e,d.u/=p,d.v/=p);a.motionAmount=Math.round(n*c*Math.hypot(d.u,d.v));100m&&(a.motionDirection=((Math.atan2(d.v,d.u)*this.toDegree+270)%360-180).toFixed(2)); a.frameNumber=this.frameNumber}};modules.sketch="2020-July-13";VectorShape.prototype={};VectorShape.prototype.constructor=VectorShape;VectorShape.uber=Object.prototype;function VectorShape(a,b,c){this.init(a,b,c)}VectorShape.prototype.init=function(a,b,c){this.borderWidth=b&&b.a?a:0;this.borderColor=b||new Color(0,0,0,0);this.fillColor=c||new Color(0,0,0,0);this.image=newCanvas();this.isCrosshair=this.isSelection=this.isPolygon=!1;this.origin=new Point;this.destination=new Point}; VectorShape.prototype.toString=function(){return"a "+(this.constructor.name||this.constructor.toString().split(" ")[1].split("(")[0])}; VectorShape.prototype.asSVG=function(a){a=new XML_Element(a);this.borderColor&&this.borderColor.a?(a.attributes.stroke=this.borderColor.toRGBstring(),a.attributes["stroke-linejoin"]="miter",a.attributes["stroke-width"]=this.borderWidth):a.attributes.stroke="none";a.attributes.fill=this.fillColor&&this.fillColor.a?this.fillColor.toRGBstring():"none";a.attributes.prototype=this.constructor.name;return a}; @@ -2537,9 +2445,9 @@ VectorSelection.prototype.drawOn=function(a){function b(h,k){g.beginPath();g.arc Crosshair.prototype.constructor=Crosshair;Crosshair.uber=VectorShape.prototype;function Crosshair(a,b){this.init(a,b)}Crosshair.prototype.init=function(a,b){this.center=a;this.paper=b;this.image=newCanvas();this.isCrosshair=!0};Crosshair.prototype.update=function(a){this.center=a.subtract(this.paper.position())};Crosshair.prototype.moveBy=function(a){this.center=this.center.add(a)}; Crosshair.prototype.drawOn=function(a){this.image=newCanvas(a.extent());a.rotationCenter=this.center.copy();a.drawcrosshair(this.image.getContext("2d"));a.redraw=!0};VectorPaintEditorMorph.prototype=new PaintEditorMorph;VectorPaintEditorMorph.prototype.constructor=VectorPaintEditorMorph;VectorPaintEditorMorph.uber=PaintEditorMorph.prototype;function VectorPaintEditorMorph(){this.init()} VectorPaintEditorMorph.prototype.init=function(){this.paper=null;this.shapes=[];this.selection=[];this.selecting=!1;this.originalSelection=null;this.resizing=this.moving=!1;this.lastDragPosition=null;this.history=[];this.clipboard=[];this.currentShape=null;VectorPaintEditorMorph.uber.init.call(this);this.labelString="Vector Paint Editor";this.createLabel();this.fixLayout()}; -VectorPaintEditorMorph.prototype.buildEdits=function(){var a=this;this.edits.add(this.pushButton("undo",function(){a.undo()}));this.edits.add(this.pushButton("clear",function(){a.paper.clearCanvas()}));this.edits.add(this.pushButton("Bitmap",function(){0{setTimeout(()=>{a.convertToBitmap()})}): a.convertToBitmap()}));this.edits.fixLayout()}; -VectorPaintEditorMorph.prototype.convertToBitmap=function(){var a=newCanvas(StageMorph.prototype.dimensions),b=this;this.object=new Costume;this.shapes.forEach(function(c){a.getContext("2d").drawImage(c.image,0,0)});this.object.rotationCenter=this.paper.rotationCenter.copy();this.object.contents=a;this.object.edit(this.world(),this.ide,!1,null,function(){b.ide.currentSprite.shadowAttribute("costumes");b.ide.currentSprite.addCostume(b.object);b.ide.spriteEditor.updateList();b.ide&&b.ide.currentSprite.wearCostume(b.object)})}; +VectorPaintEditorMorph.prototype.convertToBitmap=function(){var a=newCanvas(StageMorph.prototype.dimensions),b=this;this.object=new Costume;this.shapes.forEach(function(c){a.getContext("2d").drawImage(c.image,0,0)});this.object.rotationCenter=this.paper.rotationCenter.copy();this.object.contents=a;this.object.edit(this.world(),this.ide,!1,null,()=>{b.ide.currentSprite.shadowAttribute("costumes");b.ide.currentSprite.addCostume(b.object);b.ide.spriteEditor.updateList();b.ide&&b.ide.currentSprite.wearCostume(b.object)})}; VectorPaintEditorMorph.prototype.buildScaleBox=function(){var a=this;["Top","Bottom","Up","Down"].forEach(function(b){a.scaleBox.add(a.pushButton(b,function(){a.changeSelectionLayer(b.toLowerCase())}))});this.scaleBox.fixLayout()}; VectorPaintEditorMorph.prototype.openIn=function(a,b,c,d,e,f){var g=this;b=isNil(f)||0===f.length;VectorPaintEditorMorph.uber.openIn.call(this,a,null,c,d,e);this.ide=e;this.paper.drawNew();this.paper.changed();f.forEach(function(h){h.drawOn(g.paper)});this.shapes=f.map(function(h){return h.copy()});this.shapes.forEach(function(h){h.drawOn(g.paper)});c&&!b?(this.paper.automaticCrosshairs=!1,this.paper.rotationCenter=this.getBounds(this.shapes).origin.subtract(this.paper.bounds.origin).add(c)):this.paper.automaticCrosshairs= !0;this.updateHistory();this.processKeyUp=function(){g.shift=!1;g.ctrl=!1;g.propertiesControls.constrain.refresh()};this.processKeyDown=function(h){g.shift=16===g.world().currentKey;g.ctrl=h.ctrlKey;switch(g.world().currentKey){case 46:case 8:g.sortSelection();g.selection.slice().reverse().forEach(function(k){g.shapes.splice(g.shapes.indexOf(k),1)});g.clearSelection();g.updateHistory();break;case 13:g.currentShape&&g.currentShape.isPolygon&&(g.currentShape.close(),g.currentShape.drawOn(g.paper),g.shapes.push(g.currentShape), @@ -2554,7 +2462,7 @@ c.secondaryColorViewer=new Morph;c.secondaryColorViewer.color=new Color(0,0,0);c c.penSizeField.contents().minWidth=20;c.penSizeField.setWidth(25);c.penSizeField.accept=function(h){var k=parseFloat(c.penSizeField.getValue());c.penSizeSlider.value=k;c.penSizeSlider.updateValue();this.setContents(k);b.paper.settings.lineWidth=k;this.world().keyboardFocus=b;b.selection.forEach(function(l){l.setBorderWidth(h);l.drawOn(b.paper);b.paper.updateSelection()});b.updateHistory()};d.add(c.penSizeSlider);d.add(c.penSizeField);d.color=b.color;d.fixLayout();c.constrain=new ToggleMorph("checkbox", this,function(){b.shift=!b.shift},"Constrain proportions of shapes?\n(you can also hold shift)",function(){return b.shift});c.constrain.label.isBold=!1;e.add(c.secondaryColorViewer);e.add(c.primaryColorViewer);e.fixLayout();f.add(new TextMorph(localize("Edge color\n(left click)"),10,null,null,null,"center",85));f.add(new TextMorph(localize("Fill color\n(right click)"),10,null,null,null,"center",85));f.fixLayout();a.add(c.colorpicker);a.add(f);a.add(e);g.add(new StringMorph(localize("Brush size")+ ":",10,null,!0));g.add(d);g.add(c.constrain);g.fixLayout();a.add(g)};VectorPaintEditorMorph.prototype.selectColor=function(a,b){var c=this,d=this.paper.isShiftPressed()?!1:b;b=(d?"secondary":"primary")+"Color";this.paper.settings[b]=a;this.selection.length&&(this.selection.forEach(function(e){e.setColor(a,d);e.drawOn(c.paper)}),this.updateHistory());this.propertiesControls[b+"Viewer"].rerender()}; -VectorPaintEditorMorph.prototype.renderColorSelection=function(a,b){b=void 0===b?"transparent":b;var c;if("transparent"===b||0===b.a)for(b=0;180>b;b+=5)for(c=0;15>c;c+=5)a.fillStyle=0===(c+b)/5%2?"rgba(0, 0, 0, 0.2)":"rgba(0, 0, 0, 0.5)",a.fillRect(b,c,5,5);else a.fillStyle=b.toString(),a.fillRect(0,0,180,15)}; +VectorPaintEditorMorph.prototype.renderColorSelection=function(a,b="transparent"){var c;if("transparent"===b||0===b.a)for(b=0;180>b;b+=5)for(c=0;15>c;c+=5)a.fillStyle=0===(c+b)/5%2?"rgba(0, 0, 0, 0.2)":"rgba(0, 0, 0, 0.5)",a.fillRect(b,c,5,5);else a.fillStyle=b.toString(),a.fillRect(0,0,180,15)}; VectorPaintEditorMorph.prototype.changeSelectionLayer=function(a){var b=this;this.sortSelection();switch(a){case "top":this.selection.forEach(function(c){b.shapes.splice(b.shapes.indexOf(c),1);b.shapes.push(c)});break;case "bottom":this.selection.slice().reverse().forEach(function(c){b.shapes.splice(b.shapes.indexOf(c),1);b.shapes.splice(0,0,c)});break;case "up":this.selection.forEach(function(c){var d=b.shapes.indexOf(c);b.shapes.splice(d,1);b.shapes.splice(d+b.selection.length,0,c)});break;case "down":this.shapes[0]!== this.selection[0]&&this.selection.forEach(function(c){var d=b.shapes.indexOf(c);b.shapes.splice(d,1);b.shapes.splice(d-1,0,c)})}this.updateHistory();this.paper.redraw=!0}; VectorPaintEditorMorph.prototype.dragSelection=function(a){if(this.lastDragPosition)if(this.moving){var b=a.subtract(this.lastDragPosition);this.moveSelectionBy(b)}else this.resizing&&(this.shift&&(b=this.originalSelection.origin,a=Math.max((a.x-b.x)/(this.originalSelection.destination.x-b.x),(a.y-b.y)/(this.originalSelection.destination.y-b.y)),a=this.originalSelection.destination.subtract(b).multiplyBy(a).add(b)),b=a.subtract(this.currentShape.origin).divideBy(this.lastDragPosition.subtract(this.currentShape.origin)), @@ -2586,91 +2494,88 @@ VectorPaintCanvasMorph.prototype.pasteAt=function(a){var b=this.parentThatIsA(Ve VectorPaintCanvasMorph.prototype.floodfill=function(a){var b=this.parentThatIsA(VectorPaintEditorMorph);if(a=this.shapeAt(a.add(this.position())))a.setColor(b.shift?this.settings.secondaryColor:this.settings.primaryColor,b.shift),a.drawOn(this)};modules.lists="2020-July-01";function List(a){this.type=null;this.contents=a||[];this.rest=this.first=null;this.isLinked=!1;this.lastChanged=Date.now()}List.prototype.enableTables=!0;List.prototype.toString=function(){return"a List ["+this.length()+" elements]"}; List.prototype.changed=function(){this.lastChanged=Date.now()};List.prototype.cons=function(a,b){var c=new List;if(!(b instanceof List||isNil(b)))throw Error("cdr isn't a list: "+b);c.first=isNil(a)?null:a;c.rest=b||null;c.isLinked=!0;return c};List.prototype.cdr=function(){var a;if(this.isLinked)return this.rest||new List;if(2>this.contents.length)return new List;var b=new List;for(a=this.contents.length;1b instanceof List?b.deepMap(a):a(b))};List.prototype.length=function(){if(this.isLinked){for(var a=this,b=0;a&&a.isLinked;)b+=1,a=a.rest;return b+(a?a.contents.length:0)}return this.contents.length};List.prototype.at=function(a){a=+a;for(var b=this;b.isLinked;)if(1snapEquals(c,a))};List.prototype.isEmpty=function(){return this.isLinked?isNil(this.first):!this.contents.length};List.prototype.indexOf=function(a){for(var b=this,c=1,d,e;b.isLinked;){if(snapEquals(b.first,a))return c;b=b.rest;c+=1}e=b.contents.length;for(d=0;dthis.rows()?null:this.rowName(b):[this.length()];if(!b)return 1===this.cols()?localize("items"):this.colName(a);var c=this.at(b);if(c instanceof List){b=c.length();var d=this.cols();return a>b?null:1===d&&1=d&&b>d?new Variable(c.at(a)):c.at(a)}return 1===a&&b<=this.rows()?[c]:null};List.prototype.rows=function(){return this.length()}; List.prototype.cols=function(){var a=Math.min(10,this.length()),b=1,c;for(c=1;c<=a;c+=1){var d=this.at(c);d instanceof List&&(b=Math.max(b,d.length()))}return b};List.prototype.colName=function(a){return a>this.cols()?null:String.fromCharCode(64+(a%26||26)).repeat(Math.floor((a-1)/26)+1)};List.prototype.rowName=function(a){return a};List.prototype.columnNames=function(){return[]}; List.prototype.version=function(a,b,c,d){b=Math.min(a+b,this.length());var e=this.lastChanged,f;for(f=a;f<=b;f+=1)a=this.at(f),e=a instanceof Costume?Math.max(e,a.version):a instanceof List?Math.max(e,a.version(c,d)):Math.max(e,a.lastChanged?a.lastChanged:0);return e}; -List.prototype.query=function(a){var b=this;if(a.isEmpty())return this.map(function(d){return d});if(1===a.rank())return a.map(function(d){return b.at(d)});var c=a.at(1);return(c instanceof List?c.isEmpty()?this.range(1,this.length()):c:new List([c])).map(function(d){return b.at(d)}).map(function(d){return d instanceof List?d.query(a.cdr()):d})}; -List.prototype.slice=function(a){var b=this;if(a.isEmpty())return this.map(function(d){return d});if(1===a.rank())return this.rangify(a).map(function(d){return b.at(d)});var c=a.at(1);return(c instanceof List?c.isEmpty()?this.range(1,this.length()):this.rangify(c):this.rangify(new List([c]))).map(function(d){return b.at(d)}).map(function(d){return d instanceof List?d.slice(a.cdr()):d})}; -List.prototype.rangify=function(a){var b=this,c=[],d=this.length(),e=0,f,g;a.itemsArray().forEach(function(h){h=+h;0a?new List:1===a?this.map(function(b){return b}):2===a?new List(this.itemsArray().filter(function(b){return b instanceof List})):new List(this.getDimension(a-1).flatten().itemsArray().filter(function(b){return b instanceof List}))};List.prototype.width=function(){var a,b=0,c=this.length();for(a=1;a<=c;a+=1){var d=this.at(a);b=Math.max(b,d instanceof List?d.length():0)}return b}; -List.prototype.flatten=function(){var a=[];this.itemsArray().forEach(function(b){b instanceof List?b.itemsArray().forEach(function(c){return a.push(c)}):a.push(b)});return new List(a)};List.prototype.transpose=function(){return 2b.length&&2=b.length&&(c=0),e.push(b[c]),c+=1}return(new List(e)).folded(a)}; -List.prototype.folded=function(a){var b=a.length(),c=this;if(2>b)return this.map(function(d){return d});for(;1c);if(1===a.rank())return a.map(c=>this.at(c));var b=a.at(1);return(b instanceof List?b.isEmpty()?this.range(1,this.length()):b:new List([b])).map(c=>this.at(c)).map(c=>c instanceof List?c.query(a.cdr()):c)}; +List.prototype.slice=function(a){if(a.isEmpty())return this.map(c=>c);if(1===a.rank())return this.rangify(a).map(c=>this.at(c));var b=a.at(1);return(b instanceof List?b.isEmpty()?this.range(1,this.length()):this.rangify(b):this.rangify(new List([b]))).map(c=>this.at(c)).map(c=>c instanceof List?c.slice(a.cdr()):c)}; +List.prototype.rangify=function(a){var b=[],c=this.length(),d=0,e,f;a.itemsArray().forEach(g=>{g=+g;0b.push(h))))});return new List(b)};List.prototype.range=function(a,b){return new List([...Array(Math.abs(b-a)+1)].map((c,d)=>ae(g)):d.map(g=>e(f.at(g)))}}return b(this.rank(),a.cdr(),function(d){return function(e){return d.isEmpty()?e.map(f=>f):d.map(f=>e.at(f))}}(a.at(1)))(this)};List.prototype.size=function(){var a=0;this.deepMap(()=>a+=1);return a};List.prototype.ravel=function(){var a=[];this.deepMap(b=>a.push(b));return new List(a)}; +List.prototype.rank=function(){var a=1,b=this.length(),c;for(c=1;c<=b;c+=1){var d=this.at(c);d instanceof List&&(a=Math.max(a,1+d.rank()))}return a};List.prototype.shape=function(){var a,b=this.rank(),c=new List([this.length()]),d;for(a=2;a<=b;a+=1){var e=0;var f=this.getDimension(a);var g=f.length();for(d=1;d<=g;d+=1)e=Math.max(e,f.at(d).length());c.add(e)}return c}; +List.prototype.getDimension=function(a=0){return 1>a?new List:1===a?this.map(b=>b):2===a?new List(this.itemsArray().filter(b=>b instanceof List)):new List(this.getDimension(a-1).flatten().itemsArray().filter(b=>b instanceof List))};List.prototype.width=function(){var a,b=0,c=this.length();for(a=1;a<=c;a+=1){var d=this.at(a);b=Math.max(b,d instanceof List?d.length():0)}return b}; +List.prototype.flatten=function(){var a=[];this.itemsArray().forEach(b=>{b instanceof List?b.itemsArray().forEach(c=>a.push(c)):a.push(b)});return new List(a)};List.prototype.transpose=function(){return 2f instanceof List?f:new List(Array(b).fill(f)));var e=(f,g)=>f.map(h=>h.at(g));for(a=1;a<=b;a+=1)c.push(e(d,a));return new List(c)}; +List.prototype.reshape=function(a){var b=this.ravel().itemsArray(),c=0;if(a.isEmpty())return b[0];var d=a.itemsArray().reduce((f,g)=>f*g);if(db.length&&2=b.length&&(c=0),e.push(b[c]),c+=1}return(new List(e)).folded(a)};List.prototype.folded=function(a){var b=a.length(),c=this;if(2>b)return this.map(d=>d);for(;1k.length()),d=c.itemsArray().reduce((k,l)=>k*l),e,f,g;if(1E6f.length()})){var e=d.map(function(f){return f.at(1)});return e.every(function(f){var g;if(g=isString(f))g=e.indexOf(f)===e.lastIndexOf(f);return g})}}return JSON.stringify(b(this,a))}; -List.prototype.canBeTXT=function(){return this.itemsArray().every(function(a){return isString(a)||"number"===typeof a})};List.prototype.asTXT=function(){return this.itemsArray().join("\n")}; +List.prototype.asCSV=function(){function a(d){d=isNil(d)?"":d.toString();if(-1===d.indexOf('"')&&-1===d.indexOf("\n")&&-1===d.indexOf(","))return d;var e=['"'];d.split("").forEach(f=>{e.push(f);'"'===f&&e.push(f)});e.push('"');return e.join("")}var b=this.itemsArray(),c=[];return b.some(d=>d instanceof List)?(b.forEach(d=>{d instanceof List?c.push(d.itemsArray().map(a).join(",")):c.push(a(d))}),c.join("\n")):b.map(a).join(",")}; +List.prototype.asJSON=function(a){function b(d,e){d=d.itemsArray();var f={};return c(d)?(d.forEach(g=>{var h=2===g.length()?g.at(2):void 0;f[g.at(1)]=h instanceof List?b(h,e):h}),f):d.map(g=>g instanceof List?b(g,e):g)}function c(d){if(d.every(f=>f instanceof List&&3>f.length())){var e=d.map(f=>f.at(1));return e.every(f=>{var g;if(g=isString(f))g=e.indexOf(f)===e.lastIndexOf(f);return g})}}return JSON.stringify(b(this,a))}; +List.prototype.canBeTXT=function(){return this.itemsArray().every(a=>isString(a)||"number"===typeof a)};List.prototype.asTXT=function(){return this.itemsArray().join("\n")}; List.prototype.equalTo=function(a){var b=this,c=a,d,e;if(!(a instanceof List))return!1;for(;b.isLinked&&c.isLinked;){if(!snapEquals(b.first,c.first))return!1;b=b.rest;c=c.rest}c.isLinked&&(a=c,c=b,b=a);for(d=0;b.isLinked;){if(!snapEquals(b.first,c.contents[d]))return!1;b=b.rest;d+=1}a=0;if(b.contents.length!==c.contents.length-d)return!1;for(e=b.contents.length;0!isNaN(+a)&&"boolean"!==typeof a||isString(a)||a instanceof List&&a.hasOnlyAtomicData())};List.prototype.canBeJSON=function(){return this.itemsArray().every(a=>!isNaN(+a)||isString(a)||!0===a||!1===a||a instanceof List&&a.canBeJSON())};List.prototype.hasOnlyAtomicData=function(){return this.itemsArray().every(a=>!isNaN(+a)&&"boolean"!==typeof a||isString(a))}; +List.prototype.blockify=function(a=500,b=[0]){var c=SpriteMorph.prototype.blockForSelector("reportNewList"),d=c.inputs()[0],e=this.length(),f;c.isDraggable=!0;d.removeInput();for(f=0;fa;)this.frame.contents.children[a].destroy(); +ListWatcherMorph.prototype.update=function(a){this.frame.contents.children.forEach(k=>{k instanceof CellMorph&&(k.contentsMorph instanceof ListWatcherMorph?k.contentsMorph.update():(isSnapObject(k.contents)||k.contents instanceof Costume)&&k.update())});if(this.lastUpdated===this.list.lastChanged&&!a)return null;this.updateLength(!0);this.start=Math.max(Math.min(this.start,Math.floor((this.list.length()-1)/this.range)*this.range+1),1);var b=Math.min(this.start+this.range-1,this.list.length());var c= +Math.min(3*(b-this.start+1),this.frame.contents.children.length);for(a=0;aa;)this.frame.contents.children[a].destroy(); c=a;a=this.frame.contents.children.length;h=Date.now();if(c>a+1)for(a;athis.setStartIndex(e),null,this);c.addItem("1...",1);for(a=1;a{var b=this.world(),c=detect(b.children,d=>d instanceof IDE_Morph);this.list.blockify().pickUp(b);b.hand.grabOrigin={origin:c.palette,position:c.palette.center()}});a.addLine();a.addItem("open in dialog...",()=>(new TableDialogMorph(this.list)).popUp(this.world()));return a}; +ListWatcherMorph.prototype.showTableView=function(){var a=this.parentThatIsA(SpriteBubbleMorph,SpeechBubbleMorph,CellMorph);a&&(a instanceof SpriteBubbleMorph?(a.contentsMorph.destroy(),a.contentsMorph=new TableFrameMorph(new TableMorph(this.list,10)),a.contentsMorph.expand(this.extent()),a.parent.positionTalkBubble()):a instanceof SpeechBubbleMorph?(a.contents=new TableFrameMorph(new TableMorph(this.list,10)),a.contents.expand(this.extent())):(a.changed(),a.contentsMorph.destroy(),a.contentsMorph= +new TableFrameMorph(new TableMorph(this.list,10)),a.add(a.contentsMorph),a.contentsMorph.setPosition(this.position()),a.contentsMorph.expand(this.extent())),a.fixLayout(),a.rerender())};ListWatcherMorph.prototype.mouseDoubleClick=function(a){List.prototype.enableTables?(new TableDialogMorph(this.list)).popUp(this.world()):this.escalateEvent("mouseDoubleClick",a)};ListWatcherMorph.prototype.show=function(){ListWatcherMorph.uber.show.call(this);this.frame.contents.adjustBounds()}; +ListWatcherMorph.prototype.render=WatcherMorph.prototype.render;modules.byob="2020-July-24";function CustomBlockDefinition(a,b){this.body=null;this.scripts=[];this.category=null;this.isGlobal=!1;this.type="command";this.spec=a||"";this.declarations=new Map;this.variableNames=[];this.codeHeader=this.codeMapping=this.comment=null;this.translations={};this.receiver=b||null;this.storedSemanticSpec=this.cachedTranslation=this.cachedIsRecursive=this.editorDimensions=null} CustomBlockDefinition.prototype.blockInstance=function(a){var b="command"===this.type?new CustomCommandBlockMorph(this):new CustomReporterBlockMorph(this,"predicate"===this.type);b.isDraggable=!0;a&&(b.storedTranslations=this.translationsAsText());return b};CustomBlockDefinition.prototype.templateInstance=function(){var a=this.blockInstance();a.refreshDefaults(this);a.isDraggable=!1;a.isTemplate=!0;return a}; -CustomBlockDefinition.prototype.prototypeInstance=function(){var a=this,b;var c="command"===this.type?new CustomCommandBlockMorph(this,!0):new CustomReporterBlockMorph(this,"predicate"===this.type,!0);c.parts().forEach(function(d){d instanceof BlockInputFragmentMorph&&(b=a.declarations.get(d.fragment.labelString))&&(d.fragment.type=b[0],d.fragment.defaultValue=b[1],d.fragment.options=b[2],d.fragment.isReadOnly=b[3]||!1)});return c}; -CustomBlockDefinition.prototype.copyAndBindTo=function(a,b){var c=copy(this);delete c[XML_Serializer.prototype.idProperty];c.receiver=a;c.declarations=new Map;a=$jscomp.makeIterator(this.declarations);for(var d=a.next();!d.done;d=a.next()){var e=$jscomp.makeIterator(d.value);d=e.next().value;e=e.next().value;c.declarations.set(d,e)}if(b)return c.body=null,c;c.body&&(c.body=Process.prototype.reify.call(null,this.body.expression,new List(this.inputNames())),c.body.outerContext=null);return c}; -CustomBlockDefinition.prototype.blockSpec=function(){var a=this;if(this.storedSemanticSpec)return this.storedSemanticSpec;var b=[],c;this.parseSpec(this.spec).forEach(function(d){c="%"===d[0]&&1{c instanceof BlockInputFragmentMorph&&(a=this.declarations.get(c.fragment.labelString))&&(c.fragment.type=a[0],c.fragment.defaultValue=a[1],c.fragment.options=a[2],c.fragment.isReadOnly=a[3]||!1)});return b}; +CustomBlockDefinition.prototype.copyAndBindTo=function(a,b){var c=copy(this);delete c[XML_Serializer.prototype.idProperty];c.receiver=a;c.declarations=new Map;var d,e;for([d,e]of this.declarations)c.declarations.set(d,e);if(b)return c.body=null,c;c.body&&(c.body=Process.prototype.reify.call(null,this.body.expression,new List(this.inputNames())),c.body.outerContext=null);return c}; +CustomBlockDefinition.prototype.blockSpec=function(){if(this.storedSemanticSpec)return this.storedSemanticSpec;var a=[],b;this.parseSpec(this.spec).forEach(c=>{b="%"===c[0]&&1{"%"!==b[0]&&a.push(b)});return"".concat.apply("",a).replace(/\?/g,"")}; CustomBlockDefinition.prototype.typeOf=function(a){return this.declarations.has(a)?this.declarations.get(a)[0]:"%s"};CustomBlockDefinition.prototype.defaultValueOf=function(a){return this.declarations.has(a)?this.declarations.get(a)[1]:""};CustomBlockDefinition.prototype.defaultValueOfInputIdx=function(a){a=this.inputNames()[a];return this.defaultValueOf(a)};CustomBlockDefinition.prototype.dropDownMenuOfInputIdx=function(a){a=this.inputNames()[a];return this.dropDownMenuOf(a)}; CustomBlockDefinition.prototype.isReadOnlyInputIdx=function(a){a=this.inputNames()[a];return this.isReadOnlyInput(a)};CustomBlockDefinition.prototype.inputOptionsOfIdx=function(a){a=this.inputNames()[a];return this.inputOptionsOf(a)}; CustomBlockDefinition.prototype.dropDownMenuOf=function(a){if(this.declarations.has(a)&&this.declarations.get(a)[2]){if(0===this.declarations.get(a)[2].indexOf("\u00a7_")){var b=this.declarations.get(a)[2].slice(2);if(contains("messagesMenu messagesReceivedMenu objectsMenu costumesMenu soundsMenu getVarNamesDict pianoKeyboardMenu directionDialMenu".split(" "),b))return b}return this.parseChoices(this.declarations.get(a)[2])}return null}; -CustomBlockDefinition.prototype.parseChoices=function(a){var b={},c=[b];if(a.match(/^function\s*\(.*\)\s*{.*\n/)){var d=a.match(/^function\s*\((.*)\)/)[1].split(",");a=a.split("\n").slice(1,-1).join("\n");return Function.apply(null,d.concat([a]))}a.split("\n").forEach(function(e){e=e.split("=");"}"===e[0]?(c.pop(),b=c[c.length-1]):"{"===e[1]?(b={},c[c.length-1][e[0]]=b,c.push(b)):b[e[0]]=isNil(e[1])?e[0]:e[1]});return b}; -CustomBlockDefinition.prototype.isReadOnlyInput=function(a){return this.declarations.has(a)&&!0===this.declarations.get(a)[3]};CustomBlockDefinition.prototype.inputOptionsOf=function(a){return[this.dropDownMenuOf(a),this.isReadOnlyInput(a)]};CustomBlockDefinition.prototype.inputNames=function(){var a=[];this.parseSpec(this.spec).forEach(function(b){"%"===b[0]&&1{e=e.split("=");"}"===e[0]?(c.pop(),b=c[c.length-1]):"{"===e[1]?(b={},c[c.length-1][e[0]]=b,c.push(b)):b[e[0]]=isNil(e[1])?e[0]:e[1]});return b}; +CustomBlockDefinition.prototype.isReadOnlyInput=function(a){return this.declarations.has(a)&&!0===this.declarations.get(a)[3]};CustomBlockDefinition.prototype.inputOptionsOf=function(a){return[this.dropDownMenuOf(a),this.isReadOnlyInput(a)]};CustomBlockDefinition.prototype.inputNames=function(){var a=[];this.parseSpec(this.spec).forEach(b=>{"%"===b[0]&&111"_"===e).length!==d.length?this.cachedTranslation=b:(a=a.map(e=>"_"===e?(c+=1,d[c]):e),this.cachedTranslation=a.join(" "));return this.cachedTranslation}; +CustomBlockDefinition.prototype.abstractBlockSpec=function(){return BlockMorph.prototype.parseSpec(this.blockSpec()).map(a=>1a+=b+":"+this.translations[b]+"\n");return a}; +CustomBlockDefinition.prototype.updateTranslations=function(a){a=a.split("\n").filter(b=>b.length);this.translations={};a.forEach(b=>{var c=b.indexOf(":"),d=b.slice(0,c).trim();b=b.slice(c+1).trim();c&&(this.translations[d]=b)})};CustomBlockDefinition.prototype.scriptsPicture=function(){return this.scriptsModel().scriptsPicture()};CustomBlockDefinition.prototype.sortedElements=function(){return this.scriptsModel().sortedElements()}; +CustomBlockDefinition.prototype.scriptsModel=function(){var a;var b=new ScriptsMorph;b.cleanUpMargin=10;var c=new PrototypeHatBlockMorph(this);c.setPosition(b.position().add(10));if(null!==this.comment){var d=this.comment.fullCopy();c.comment=d;d.block=c}null!==this.body&&c.nextBlock(this.body.expression.fullCopy());b.add(c);c.fixBlockColor(null,!0);this.scripts.forEach(e=>{a=e.fullCopy();a.setPosition(b.position().add(e.position()));b.add(a);a instanceof BlockMorph&&a.allComments().forEach(f=>f.align(a))}); +c.allComments().forEach(e=>e.align(c));d=c.parts()[0];d.fixLayout();d.forceNormalColoring();d.fixBlockColor(c,!0);b.fixMultiArgs();return b};CustomBlockDefinition.prototype.purgeCorpses=function(){this.body&&this.body.expression.isCorpse&&(this.body=null);this.scripts=this.scripts.filter(a=>!a.isCorpse)};CustomCommandBlockMorph.prototype=new CommandBlockMorph;CustomCommandBlockMorph.prototype.constructor=CustomCommandBlockMorph;CustomCommandBlockMorph.uber=CommandBlockMorph.prototype; CustomCommandBlockMorph.prototype.isCustomBlock=!0;function CustomCommandBlockMorph(a,b){this.init(a,b)}CustomCommandBlockMorph.prototype.init=function(a,b){this.definition=a;this.semanticSpec="";this.isGlobal=a?a.isGlobal:!1;this.isPrototype=b||!1;CustomCommandBlockMorph.uber.init.call(this);this.category=a.category;this.selector="evaluateCustomBlock";this.storedTranslations=this.variables=null;this.initializeVariables();a&&this.refresh()}; -CustomCommandBlockMorph.prototype.initializeVariables=function(a){var b=this;this.variables=new VariableFrame;this.isGlobal&&this.definition.variableNames.forEach(function(c){var d=a?a[c]:null;b.variables.addVar(c,d instanceof Variable?d.value:null)})}; -CustomCommandBlockMorph.prototype.refresh=function(a){var b=a||this.definition;a=this.isPrototype?b.spec:b.localizedSpec();this.semanticSpec=b.blockSpec();this.setCategory(b.category);if(this.blockSpec!==a){var c=this.inputs();this.zebraContrast?this.fixBlockColor():this.forceNormalColoring();this.setSpec(a,b);this.fixLabelColor();this.restoreInputs(c)}else this.inputs().forEach(function(d,e){d instanceof InputSlotMorph&&d.setChoices.apply(d,b.inputOptionsOfIdx(e))});this.cachedInputs=null;this.inputs().forEach(function(d, -e){d instanceof TemplateSlotMorph&&"\u2191"===d.contents()&&d.setContents(b.inputNames()[e])});this.isGlobal&&this.initializeVariables(this.variables.vars);this.forceNormalColoring();this.fixBlockColor(null,!0)}; -CustomCommandBlockMorph.prototype.restoreInputs=function(a){var b=this,c=0,d;this.isPrototype||(this.cachedInputs=null,this.inputs().forEach(function(e){d=a[c];d instanceof ReporterBlockMorph&&!(e instanceof TemplateSlotMorph)?b.replaceInput(e,d.fullCopy()):d instanceof InputSlotMorph&&e instanceof InputSlotMorph?d.isEmptySlot()?e.setContents(""):e.setContents(d.evaluate()):d instanceof BooleanSlotMorph&&e instanceof BooleanSlotMorph?e.setContents(d.evaluate()):d instanceof TemplateSlotMorph&&e instanceof -TemplateSlotMorph?e.setContents(d.evaluate()):d instanceof CSlotMorph&&e instanceof CSlotMorph&&e.nestedBlock(d.evaluate());c+=1}),this.cachedInputs=null)};CustomCommandBlockMorph.prototype.refreshDefaults=function(a){var b=this,c=0;this.inputs().forEach(function(d){(d instanceof InputSlotMorph||d instanceof BooleanSlotMorph)&&d.setContents((a||b.definition).defaultValueOfInputIdx(c));c+=1});this.cachedInputs=null}; -CustomCommandBlockMorph.prototype.refreshPrototype=function(){var a=[],b=this,c,d,e=0;if(!this.isPrototype)return null;var f=this.parentThatIsA(PrototypeHatBlockMorph);this.parts().forEach(function(h){h.fragment.isDeleted||(h.fragment.type?a.push(h.fragment):(c=b.definition.parseSpec(h.fragment.labelString),c.forEach(function(k){d=h.fragment.copy();d.labelString=k;a.push(d)})))});var g=this.specFromFragments()||this.blockSpec;this instanceof CustomCommandBlockMorph&&("reporter"===f.type||"predicate"=== -f.type)?(b=new CustomReporterBlockMorph(this.definition,"predicate"===f.type,!0),f.replaceInput(this,b)):this instanceof CustomReporterBlockMorph&&("command"===f.type?(b=new CustomCommandBlockMorph(this.definition,!0),f.replaceInput(this,b)):(this.isPredicate="predicate"===f.type,this.fixLayout(),this.rerender()));b.setCategory(f.blockCategory||"other");f.fixBlockColor();b.setSpec(g);b.parts().forEach(function(h){h instanceof BlockLabelPlaceHolderMorph||(a[e]&&(h.fragment=a[e]),e+=1)});this.refreshPrototypeSlotTypes(); -f.fixLayout()};CustomCommandBlockMorph.prototype.refreshPrototypeSlotTypes=function(){this.parts().forEach(function(a){a instanceof BlockInputFragmentMorph&&(a.template().instantiationSpec=a.contents(),a.setContents(a.fragment.defTemplateSpecFragment()))});this.fixBlockColor(null,!0)};CustomCommandBlockMorph.prototype.inputFragmentNames=function(){var a=[];this.parts().forEach(function(b){!b.fragment.isDeleted&&b.fragment.type&&a.push(b.fragment.labelString)});return a}; -CustomCommandBlockMorph.prototype.upvarFragmentNames=function(){var a=[];this.parts().forEach(function(b){b.fragment.isDeleted||"%upvar"!==b.fragment.type||a.push(b.fragment.labelString)});return a};CustomCommandBlockMorph.prototype.upvarFragmentName=function(a){return this.upvarFragmentNames()[a]||"\u2191"};CustomCommandBlockMorph.prototype.specFromFragments=function(){var a="";this.parts().forEach(function(b){b.fragment.isDeleted||(a=a+b.fragment.defSpecFragment()+" ")});return a.trim()}; -CustomCommandBlockMorph.prototype.blockSpecFromFragments=function(){var a="";this.parts().forEach(function(b){b.fragment.isDeleted||(a=a+b.fragment.blockSpecFragment()+" ")});return a.trim()};CustomCommandBlockMorph.prototype.declarationsFromFragments=function(){var a=new Map;this.parts().forEach(function(b){b instanceof BlockInputFragmentMorph&&a.set(b.fragment.labelString,[b.fragment.type,b.fragment.defaultValue,b.fragment.options,b.fragment.isReadOnly])});return a}; +CustomCommandBlockMorph.prototype.initializeVariables=function(a){this.variables=new VariableFrame;this.isGlobal&&this.definition.variableNames.forEach(b=>{var c=a?a[b]:null;this.variables.addVar(b,c instanceof Variable?c.value:null)})}; +CustomCommandBlockMorph.prototype.refresh=function(a){var b=a||this.definition;a=this.isPrototype?b.spec:b.localizedSpec();this.semanticSpec=b.blockSpec();this.setCategory(b.category);if(this.blockSpec!==a){var c=this.inputs();this.zebraContrast?this.fixBlockColor():this.forceNormalColoring();this.setSpec(a,b);this.fixLabelColor();this.restoreInputs(c)}else this.inputs().forEach((d,e)=>{d instanceof InputSlotMorph&&d.setChoices.apply(d,b.inputOptionsOfIdx(e))});this.cachedInputs=null;this.inputs().forEach((d, +e)=>{d instanceof TemplateSlotMorph&&"\u2191"===d.contents()&&d.setContents(b.inputNames()[e])});this.isGlobal&&this.initializeVariables(this.variables.vars);this.forceNormalColoring();this.fixBlockColor(null,!0)}; +CustomCommandBlockMorph.prototype.restoreInputs=function(a){var b=0,c;this.isPrototype||(this.cachedInputs=null,this.inputs().forEach(d=>{c=a[b];c instanceof ReporterBlockMorph&&!(d instanceof TemplateSlotMorph)?this.replaceInput(d,c.fullCopy()):c instanceof InputSlotMorph&&d instanceof InputSlotMorph?c.isEmptySlot()?d.setContents(""):d.setContents(c.evaluate()):c instanceof BooleanSlotMorph&&d instanceof BooleanSlotMorph?d.setContents(c.evaluate()):c instanceof TemplateSlotMorph&&d instanceof TemplateSlotMorph? +d.setContents(c.evaluate()):c instanceof CSlotMorph&&d instanceof CSlotMorph&&d.nestedBlock(c.evaluate());b+=1}),this.cachedInputs=null)};CustomCommandBlockMorph.prototype.refreshDefaults=function(a){var b=0;this.inputs().forEach(c=>{(c instanceof InputSlotMorph||c instanceof BooleanSlotMorph)&&c.setContents((a||this.definition).defaultValueOfInputIdx(b));b+=1});this.cachedInputs=null}; +CustomCommandBlockMorph.prototype.refreshPrototype=function(){var a=[],b=this,c,d,e=0;if(!this.isPrototype)return null;var f=this.parentThatIsA(PrototypeHatBlockMorph);this.parts().forEach(h=>{h.fragment.isDeleted||(h.fragment.type?a.push(h.fragment):(c=b.definition.parseSpec(h.fragment.labelString),c.forEach(k=>{d=h.fragment.copy();d.labelString=k;a.push(d)})))});var g=this.specFromFragments()||this.blockSpec;this instanceof CustomCommandBlockMorph&&("reporter"===f.type||"predicate"===f.type)?(b= +new CustomReporterBlockMorph(this.definition,"predicate"===f.type,!0),f.replaceInput(this,b)):this instanceof CustomReporterBlockMorph&&("command"===f.type?(b=new CustomCommandBlockMorph(this.definition,!0),f.replaceInput(this,b)):(this.isPredicate="predicate"===f.type,this.fixLayout(),this.rerender()));b.setCategory(f.blockCategory||"other");f.fixBlockColor();b.setSpec(g);b.parts().forEach(h=>{h instanceof BlockLabelPlaceHolderMorph||(a[e]&&(h.fragment=a[e]),e+=1)});this.refreshPrototypeSlotTypes(); +f.fixLayout()};CustomCommandBlockMorph.prototype.refreshPrototypeSlotTypes=function(){this.parts().forEach(a=>{a instanceof BlockInputFragmentMorph&&(a.template().instantiationSpec=a.contents(),a.setContents(a.fragment.defTemplateSpecFragment()))});this.fixBlockColor(null,!0)};CustomCommandBlockMorph.prototype.inputFragmentNames=function(){var a=[];this.parts().forEach(b=>{!b.fragment.isDeleted&&b.fragment.type&&a.push(b.fragment.labelString)});return a}; +CustomCommandBlockMorph.prototype.upvarFragmentNames=function(){var a=[];this.parts().forEach(b=>{b.fragment.isDeleted||"%upvar"!==b.fragment.type||a.push(b.fragment.labelString)});return a};CustomCommandBlockMorph.prototype.upvarFragmentName=function(a){return this.upvarFragmentNames()[a]||"\u2191"};CustomCommandBlockMorph.prototype.specFromFragments=function(){var a="";this.parts().forEach(b=>{b.fragment.isDeleted||(a=a+b.fragment.defSpecFragment()+" ")});return a.trim()}; +CustomCommandBlockMorph.prototype.blockSpecFromFragments=function(){var a="";this.parts().forEach(b=>{b.fragment.isDeleted||(a=a+b.fragment.blockSpecFragment()+" ")});return a.trim()};CustomCommandBlockMorph.prototype.declarationsFromFragments=function(){var a=new Map;this.parts().forEach(b=>{b instanceof BlockInputFragmentMorph&&a.set(b.fragment.labelString,[b.fragment.type,b.fragment.defaultValue,b.fragment.options,b.fragment.isReadOnly])});return a}; CustomCommandBlockMorph.prototype.parseSpec=function(a){return this.isPrototype?CustomBlockDefinition.prototype.parseSpec(a):CustomCommandBlockMorph.uber.parseSpec.call(this,a)};CustomCommandBlockMorph.prototype.mouseClickLeft=function(){if(!this.isPrototype)return CustomCommandBlockMorph.uber.mouseClickLeft.call(this);this.edit()}; -CustomCommandBlockMorph.prototype.edit=function(){var a=this,b=this.definition;if(this.isPrototype){var c=this.definition.blockInstance();c.addShadow();b=this.parentThatIsA(PrototypeHatBlockMorph);(new BlockDialogMorph(null,function(e){e&&SnapActions.setCustomBlockType(a.definition,e.category,e.type)},this)).openForChange("Change block",b.blockCategory,b.type,this.world(),c.doWithAlpha(1,function(){return c.fullImage()}),this.isInUse())}else{var d=this.scriptTarget();if(!this.isGlobal){if(contains(Object.keys(d.inheritedBlocks()), -this.blockSpec)){this.duplicateBlockDefinition();return}b=d.getMethod(this.semanticSpec)}b=new BlockEditorMorph(b,d);b.popUp();b.changed()}}; +CustomCommandBlockMorph.prototype.edit=function(){var a=this.definition;if(this.isPrototype){var b=this.definition.blockInstance();b.addShadow();a=this.parentThatIsA(PrototypeHatBlockMorph);(new BlockDialogMorph(null,d=>{d&&SnapActions.setCustomBlockType(this.definition,d.category,d.type)},this)).openForChange("Change block",a.blockCategory,a.type,this.world(),b.doWithAlpha(1,()=>b.fullImage()),this.isInUse())}else{var c=this.scriptTarget();if(!this.isGlobal){if(contains(Object.keys(c.inheritedBlocks()), +this.blockSpec)){this.duplicateBlockDefinition();return}a=c.getMethod(this.semanticSpec)}a=new BlockEditorMorph(a,c);a.popUp();a.changed()}}; CustomCommandBlockMorph.prototype.labelPart=function(a){if(!this.isPrototype)return CustomCommandBlockMorph.uber.labelPart.call(this,a);"%"===a[0]&&1d.usesBlockInstance(a,!1,e)):0c.inputs().length?f.addItem("block variables...",function(){c.enableBlockVars()},"experimental -\nunder construction"):f.addItem("remove block variables...",function(){c.enableBlockVars(!1)},"experimental -\nunder construction"))}else(f=this.constructor.uber.userMenu.call(this))?f.addLine():f=new MenuMorph(this),this.isTemplate?(this.isGlobal?f.addItem("delete block definition...","deleteBlockDefinition"):contains(Object.keys(d.inheritedBlocks()), this.blockSpec)?a("inherited",function(){var g=e.parentThatIsA(IDE_Morph);d.customBlocks.push(d.getMethod(e.blockSpec).copyAndBindTo(d));g&&(g.flushPaletteCache(),g.refreshPalette())},!0,"uncheck to\ndisinherit",null):d.exemplar&&d.exemplar.getMethod(this.blockSpec)?a("inherited","deleteBlockDefinition",!1,null,localize("check to inherit\nfrom")+" "+d.exemplar.name):f.addItem("delete block definition...","deleteBlockDefinition"),f.addItem("duplicate block definition...","duplicateBlockDefinition")): -(this.isGlobal||contains(Object.keys(d.ownBlocks()),this.blockSpec))&&f.addItem("delete block definition...","deleteBlockDefinition"),this.variables.names().forEach(function(g){return b(g)});f.addItem("edit...","edit");return f};CustomCommandBlockMorph.prototype.exportBlockDefinition=function(){var a=(new SnapSerializer).serialize(this.definition);this.parentThatIsA(IDE_Morph).saveXMLAs(a,this.spec)}; -CustomCommandBlockMorph.prototype.duplicateBlockDefinition=function(){var a=this,b,c,d,e;return $jscomp.asyncExecutePromiseGeneratorProgram(function(f){if(1==f.nextAddress)return b=a.scriptTarget(),c=a.isGlobal?a.definition:b.getMethod(a.blockSpec),d=c.copyAndBindTo(b),f.yield(SnapActions.addCustomBlock(d,b),2);e=f.yieldResult;(new BlockEditorMorph(e,b)).popUp();return f.return(e)})}; -CustomCommandBlockMorph.prototype.deleteBlockDefinition=function(){var a=this,b=this.scriptTarget();if(this.isPrototype)return null;var c=(this.isGlobal?this.definition:b.getLocalMethod(this.blockSpec)).blockInstance();(new DialogBoxMorph(this,function(){return SnapActions.deleteCustomBlock(a.definition)},this)).askYesNo("Delete Custom Block",localize("block deletion dialog text"),this.world(),c.doWithAlpha(1,function(){c.addShadow();return c.fullImage()}))}; -CustomCommandBlockMorph.prototype.relabel=function(a){var b=this,c=new MenuMorph(this),d=this.inputs().map(function(e){return e.fullCopy()});a.forEach(function(e){var f=e.blockInstance();f.restoreInputs(d);f.fixBlockColor(null,!0);f.addShadow(new Point(3,3));c.addItem(f.doWithAlpha(1,function(){return f.fullImage()}),function(){b.definition=e;b.refresh()})});c.popup(this.world(),this.bottomLeft().subtract(new Point(8,this instanceof CommandBlockMorph?this.corner:0)))}; -CustomCommandBlockMorph.prototype.alternatives=function(){var a=this,b=this.scriptTarget(),c=b.parentThatIsA(StageMorph);b=b.customBlocks.concat(c.globalBlocks);var d=this instanceof CommandBlockMorph?"command":this.isPredicate?"predicate":"reporter";return b.filter(function(e){return e!==a.definition&&e.type===d})};CustomReporterBlockMorph.prototype=new ReporterBlockMorph;CustomReporterBlockMorph.prototype.constructor=CustomReporterBlockMorph;CustomReporterBlockMorph.uber=ReporterBlockMorph.prototype; +(this.isGlobal||contains(Object.keys(d.ownBlocks()),this.blockSpec))&&f.addItem("delete block definition...","deleteBlockDefinition"),this.variables.names().forEach(g=>b(g));f.addItem("edit...","edit");return f};CustomCommandBlockMorph.prototype.exportBlockDefinition=function(){var a=(new SnapSerializer).serialize(this.definition);this.parentThatIsA(IDE_Morph).saveXMLAs(a,this.spec)}; +CustomCommandBlockMorph.prototype.duplicateBlockDefinition=async function(){var a=this.scriptTarget(),b=(this.isGlobal?this.definition:a.getMethod(this.blockSpec)).copyAndBindTo(a);b=await SnapActions.addCustomBlock(b,a);(new BlockEditorMorph(b,a)).popUp();return b}; +CustomCommandBlockMorph.prototype.deleteBlockDefinition=function(){var a=this.scriptTarget();if(this.isPrototype)return null;const b=(this.isGlobal?this.definition:a.getLocalMethod(this.blockSpec)).blockInstance();(new DialogBoxMorph(this,()=>SnapActions.deleteCustomBlock(this.definition),this)).askYesNo("Delete Custom Block",localize("block deletion dialog text"),this.world(),b.doWithAlpha(1,()=>{b.addShadow();return b.fullImage()}))}; +CustomCommandBlockMorph.prototype.relabel=function(a){var b=new MenuMorph(this),c=this.inputs().map(d=>d.fullCopy());a.forEach(d=>{var e=d.blockInstance();e.restoreInputs(c);e.fixBlockColor(null,!0);e.addShadow(new Point(3,3));b.addItem(e.doWithAlpha(1,()=>e.fullImage()),()=>{this.definition=d;this.refresh()})});b.popup(this.world(),this.bottomLeft().subtract(new Point(8,this instanceof CommandBlockMorph?this.corner:0)))}; +CustomCommandBlockMorph.prototype.alternatives=function(){var a=this.scriptTarget(),b=a.parentThatIsA(StageMorph);a=a.customBlocks.concat(b.globalBlocks);var c=this instanceof CommandBlockMorph?"command":this.isPredicate?"predicate":"reporter";return a.filter(d=>d!==this.definition&&d.type===c)};CustomReporterBlockMorph.prototype=new ReporterBlockMorph;CustomReporterBlockMorph.prototype.constructor=CustomReporterBlockMorph;CustomReporterBlockMorph.uber=ReporterBlockMorph.prototype; CustomReporterBlockMorph.prototype.isCustomBlock=!0;function CustomReporterBlockMorph(a,b,c){this.init(a,b,c)}CustomReporterBlockMorph.prototype.init=function(a,b,c){this.definition=a;this.semanticSpec="";this.isGlobal=a?a.isGlobal:!1;this.isPrototype=c||!1;CustomReporterBlockMorph.uber.init.call(this,b,!0);this.category=a.category;this.storedTranslations=null;this.variables=new VariableFrame;this.initializeVariables();this.selector="evaluateCustomBlock";a&&this.refresh()}; CustomReporterBlockMorph.prototype.initializeVariables=CustomCommandBlockMorph.prototype.initializeVariables;CustomReporterBlockMorph.prototype.refresh=function(a){var b=a||this.definition;CustomCommandBlockMorph.prototype.refresh.call(this,a,!0);this.isPrototype||(this.isPredicate="predicate"===b.type);this.parent instanceof SyntaxElementMorph&&(this.parent.cachedInputs=null);this.fixLayout()}; CustomReporterBlockMorph.prototype.mouseClickLeft=function(){if(!this.isPrototype)return CustomReporterBlockMorph.uber.mouseClickLeft.call(this);this.edit()};CustomReporterBlockMorph.prototype.placeHolder=CustomCommandBlockMorph.prototype.placeHolder;CustomReporterBlockMorph.prototype.parseSpec=CustomCommandBlockMorph.prototype.parseSpec;CustomReporterBlockMorph.prototype.edit=CustomCommandBlockMorph.prototype.edit;CustomReporterBlockMorph.prototype.labelPart=CustomCommandBlockMorph.prototype.labelPart; @@ -2679,50 +2584,49 @@ CustomReporterBlockMorph.prototype.declarationsFromFragments=CustomCommandBlockM CustomReporterBlockMorph.prototype.isInUse=CustomCommandBlockMorph.prototype.isInUse;CustomReporterBlockMorph.prototype.userMenu=CustomCommandBlockMorph.prototype.userMenu;CustomReporterBlockMorph.prototype.duplicateBlockDefinition=CustomCommandBlockMorph.prototype.duplicateBlockDefinition;CustomReporterBlockMorph.prototype.deleteBlockDefinition=CustomCommandBlockMorph.prototype.deleteBlockDefinition;CustomReporterBlockMorph.prototype.bubbleHelp=CustomCommandBlockMorph.prototype.bubbleHelp; CustomReporterBlockMorph.prototype.popUpbubbleHelp=CustomCommandBlockMorph.prototype.popUpbubbleHelp;CustomReporterBlockMorph.prototype.relabel=CustomCommandBlockMorph.prototype.relabel;CustomReporterBlockMorph.prototype.alternatives=CustomCommandBlockMorph.prototype.alternatives;JaggedBlockMorph.prototype=new ReporterBlockMorph;JaggedBlockMorph.prototype.constructor=JaggedBlockMorph;JaggedBlockMorph.uber=ReporterBlockMorph.prototype;function JaggedBlockMorph(a){this.init(a)} JaggedBlockMorph.prototype.init=function(a){JaggedBlockMorph.uber.init.call(this);a&&this.setSpec(a);if("%cs"===a||"%ca"===a)this.minWidth=25,this.fixLayout()}; -JaggedBlockMorph.prototype.outlinePath=function(a,b){var c=this.width(),d=this.position(),e=0;a.moveTo(b,b);a.lineTo(c-b,b);this.cSlots().forEach(function(k){k.outlinePath(a,b,k.position().subtract(d));e+=k.height()});var f=this.height()-e-b;var g=Math.round(f/this.jag);var h=f/g;for(f=0;f{k.outlinePath(a,b,k.position().subtract(d));e+=k.height()});var f=this.height()-e-b;var g=Math.round(f/this.jag);var h=f/g;for(f=0;fh.refresh());this.types.children.forEach(h=>{h.setColor(g);h.refresh()});this.labelString=a;this.createLabel();e&&this.setPicture(e);this.addButton("ok","OK");this.addButton("cancel","Cancel");f&&(this.types.destroy(),this.types=null);this.scopes.destroy();this.scopes=null;this.fixLayout();this.rerender(); +this.popUp(d)};BlockDialogMorph.prototype.createCategoryButtons=function(){SpriteMorph.prototype.categories.forEach(a=>this.addCategoryButton(a))}; +BlockDialogMorph.prototype.addCategoryButton=function(a){var b=[IDE_Morph.prototype.frameColor,IDE_Morph.prototype.frameColor.darker(MorphicPreferences.isFlat?5:50),SpriteMorph.prototype.blockColor[a]];var c=new ToggleButtonMorph(b,this,()=>{this.category=a;this.categories.children.forEach(d=>d.refresh());this.types&&this.types.children.forEach(d=>d.setColor(b[2]));this.edit()},a[0].toUpperCase().concat(a.slice(1)),()=>this.category===a,null,null,75,!0);c.corner=8;c.padding=0;c.labelShadowOffset= +new Point(-1,-1);c.labelShadowColor=b[1];c.labelColor=IDE_Morph.prototype.buttonLabelColor;MorphicPreferences.isFlat&&(c.labelPressColor=WHITE);c.contrast=this.buttonContrast;c.fixLayout();c.refresh();this.categories.add(c);return c}; +BlockDialogMorph.prototype.fixCategoriesLayout=function(){var a=this.categories.children[0].width(),b=this.categories.children[0].height(),c=Math.ceil(this.categories.children.length/2),d=this.categories.left(),e=this.categories.top(),f=0,g,h;this.categories.children.forEach(k=>{f+=1;g=Math.ceil(f/2);h=2-f%2;k.setPosition(new Point(d+(15*h+(h-1)*a),e+(2*g+(g-1)*b+10)))});MorphicPreferences.isFlat&&(this.categories.corner=0,this.categories.border=0,this.categories.edge=0);this.categories.setExtent(new Point(45+ 2*a,2*(c+1)+c*b+20))}; -BlockDialogMorph.prototype.createTypeButtons=function(){var a=this,b=SpriteMorph.prototype.blockColor[this.category];var c=new CommandBlockMorph;c.setColor(b);c.setSpec(localize("Command"));this.addBlockTypeButton(function(){return a.setType("command")},c,function(){return"command"===a.blockType});c=new ReporterBlockMorph;c.setColor(b);c.setSpec(localize("Reporter"));this.addBlockTypeButton(function(){return a.setType("reporter")},c,function(){return"reporter"===a.blockType});c=new ReporterBlockMorph(!0); -c.setColor(b);c.setSpec(localize("Predicate"));this.addBlockTypeButton(function(){return a.setType("predicate")},c,function(){return"predicate"===a.blockType})};BlockDialogMorph.prototype.addBlockTypeButton=function(a,b,c){a=new ToggleElementMorph(this,a,b,c,null,null,"rebuild");a.refresh();a.fixLayout();this.types.add(a);return a}; -BlockDialogMorph.prototype.addTypeButton=function(a,b,c){a=new ToggleMorph("radiobutton",this,a,b,c);a.edge=this.buttonEdge/2;a.outline=this.buttonOutline/2;a.outlineColor=this.buttonOutlineColor;a.outlineGradient=this.buttonOutlineGradient;a.contrast=this.buttonContrast;a.fixLayout();this.types.add(a);return a};BlockDialogMorph.prototype.setType=function(a){this.blockType=a||this.blockType;this.types.children.forEach(function(b){return b.refresh()});this.edit()}; -BlockDialogMorph.prototype.createScopeButtons=function(){var a=this;this.addScopeButton(function(){return a.setScope("global")},"for all sprites",function(){return a.isGlobal});this.addScopeButton(function(){return a.setScope("local")},"for this sprite only",function(){return!a.isGlobal})}; -BlockDialogMorph.prototype.addScopeButton=function(a,b,c){a=new ToggleMorph("radiobutton",this,a,b,c);a.edge=this.buttonEdge/2;a.outline=this.buttonOutline/2;a.outlineColor=this.buttonOutlineColor;a.outlineGradient=this.buttonOutlineGradient;a.contrast=this.buttonContrast;a.fixLayout();this.scopes.add(a);return a};BlockDialogMorph.prototype.setScope=function(a){this.isGlobal="global"===a;this.scopes.children.forEach(function(b){return b.refresh()});this.edit()}; +BlockDialogMorph.prototype.createTypeButtons=function(){var a=SpriteMorph.prototype.blockColor[this.category];var b=new CommandBlockMorph;b.setColor(a);b.setSpec(localize("Command"));this.addBlockTypeButton(()=>this.setType("command"),b,()=>"command"===this.blockType);b=new ReporterBlockMorph;b.setColor(a);b.setSpec(localize("Reporter"));this.addBlockTypeButton(()=>this.setType("reporter"),b,()=>"reporter"===this.blockType);b=new ReporterBlockMorph(!0);b.setColor(a);b.setSpec(localize("Predicate"));this.addBlockTypeButton(()=> +this.setType("predicate"),b,()=>"predicate"===this.blockType)};BlockDialogMorph.prototype.addBlockTypeButton=function(a,b,c){a=new ToggleElementMorph(this,a,b,c,null,null,"rebuild");a.refresh();a.fixLayout();this.types.add(a);return a}; +BlockDialogMorph.prototype.addTypeButton=function(a,b,c){a=new ToggleMorph("radiobutton",this,a,b,c);a.edge=this.buttonEdge/2;a.outline=this.buttonOutline/2;a.outlineColor=this.buttonOutlineColor;a.outlineGradient=this.buttonOutlineGradient;a.contrast=this.buttonContrast;a.fixLayout();this.types.add(a);return a};BlockDialogMorph.prototype.setType=function(a){this.blockType=a||this.blockType;this.types.children.forEach(b=>b.refresh());this.edit()}; +BlockDialogMorph.prototype.createScopeButtons=function(){this.addScopeButton(()=>this.setScope("global"),"for all sprites",()=>this.isGlobal);this.addScopeButton(()=>this.setScope("local"),"for this sprite only",()=>!this.isGlobal)}; +BlockDialogMorph.prototype.addScopeButton=function(a,b,c){a=new ToggleMorph("radiobutton",this,a,b,c);a.edge=this.buttonEdge/2;a.outline=this.buttonOutline/2;a.outlineColor=this.buttonOutlineColor;a.outlineGradient=this.buttonOutlineGradient;a.contrast=this.buttonContrast;a.fixLayout();this.scopes.add(a);return a};BlockDialogMorph.prototype.setScope=function(a){this.isGlobal="global"===a;this.scopes.children.forEach(b=>b.refresh());this.edit()}; BlockDialogMorph.prototype.getInput=function(){var a;this.body instanceof InputFieldMorph&&(a=this.normalizeSpaces(this.body.getValue()));a=new CustomBlockDefinition(a);a.type=this.blockType;a.category=this.category;a.isGlobal=this.isGlobal;if("reporter"===a.type||"predicate"===a.type){var b=Process.prototype.reify.call(null,SpriteMorph.prototype.blockForSelector("doReport"),new List,!0);b.outerContext=null;a.body=b}return a}; BlockDialogMorph.prototype.fixLayout=function(){var a=fontHeight(this.titleFontSize)+2*this.titlePadding;this.body?(this.body.setPosition(this.position().add(new Point(this.padding,a+this.padding))),this.bounds.setWidth(this.body.width()+2*this.padding),this.bounds.setHeight(this.body.height()+2*this.padding+a),this.categories&&(this.categories.setCenter(this.body.center()),this.categories.setTop(this.body.top()),this.body.setTop(this.categories.bottom()+this.padding),this.bounds.setHeight(this.height()+ this.categories.height()+this.padding))):this.head&&(this.types?(this.types.fixLayout(),this.bounds.setWidth(Math.max(this.types.width(),this.head.width())+2*this.padding)):this.bounds.setWidth(Math.max(this.categories.width(),this.head.width())+2*this.padding),this.head.setCenter(this.center()),this.head.setTop(a+this.padding),this.bounds.setHeight(this.head.height()+2*this.padding+a),this.categories&&(this.categories.setCenter(this.center()),this.categories.setTop(this.head.bottom()+this.padding), this.bounds.setHeight(this.height()+this.categories.height()+this.padding)));this.label&&(this.label.setCenter(this.center()),this.label.setTop(this.top()+(a-this.label.height())/2));this.types&&(this.types.fixLayout(),this.bounds.setHeight(this.height()+this.types.height()+this.padding),this.bounds.setWidth(Math.max(this.width(),this.types.width()+2*this.padding)),this.types.setCenter(this.center()),this.body?this.types.setTop(this.body.bottom()+this.padding):this.categories&&this.types.setTop(this.categories.bottom()+ this.padding));this.scopes&&(this.scopes.fixLayout(),this.bounds.setHeight(this.height()+this.scopes.height()+this.padding/3),this.bounds.setWidth(Math.max(this.width(),this.scopes.width()+2*this.padding)),this.scopes.setCenter(this.center()),this.types&&this.scopes.setTop(this.types.bottom()+this.padding/3));this.buttons&&0this.updateDefinition(),b);this.key="editBlock"+a.spec;this.labelString=this.definition.isGlobal?"Block Editor":"Method Editor";this.createLabel();var d=new ScriptsMorph;d.rejectsHats=!0;d.isDraggable=!1;d.color=IDE_Morph.prototype.groupColor;d.cachedTexture= +IDE_Morph.prototype.scriptsPaneTexture;d.cleanUpMargin=10;var e=new PrototypeHatBlockMorph(this.definition);e.setPosition(d.position().add(10));null!==a.comment&&(b=a.comment.fullCopy(),e.comment=b,b.block=e);null!==a.body&&e.nextBlock(c?a.body.expression:a.body.expression.fullCopy());d.add(e);e.fixBlockColor(null,!0);this.definition.scripts.forEach(g=>{f=g.fullCopy();f.setPosition(d.position().add(g.position()));d.add(f);f instanceof BlockMorph&&f.allComments().forEach(h=>h.align(f))});e.allComments().forEach(g=> +g.align(e));a=new ScrollFrameMorph(d);a.padding=10;a.growth=50;a.isDraggable=!1;a.acceptsDrops=!1;a.contents.acceptsDrops=!0;d.scrollFrame=a;d.updateToolbar();this.addBody(a);this.addButton("ok","Done");this.setExtent(new Point(375,300));this.fixLayout();d.fixMultiArgs();var f=e.parts()[0];f.forceNormalColoring();f.fixBlockColor(e,!0)};BlockEditorMorph.prototype.mouseClickLeft=function(){this.target.parentThatIsA(IDE_Morph).setActiveEditor(this)};BlockEditorMorph.prototype.onSetActive=function(){this.body.contents.updateToolbar()}; +BlockEditorMorph.prototype.onUnsetActive=function(){this.body.contents.hideToolbar()};BlockEditorMorph.prototype.popUp=function(a){var b=this.target.world();if(b){BlockEditorMorph.uber.popUp.call(this,b);this.setInitialDimensions(a);this.handle=new HandleMorph(this,280,220,this.corner,this.corner);b.keyboardReceiver=null;var c=this.target.parentThatIsA(IDE_Morph);a||c.setActiveEditor(this);b.keyboardFocus=null}};BlockEditorMorph.prototype.justDropped=function(){nop()}; BlockEditorMorph.prototype.accept=function(a){if(!(a instanceof CursorMorph)){if(this.action)if("function"===typeof this.target)"function"===typeof this.action?this.target.call(this.environment,this.action.call()):this.target.call(this.environment,this.action);else if("function"===typeof this.action)this.action.call(this.target,this.getInput());else this.target[this.action](this.getInput());(a=this.target.parentThatIsA(IDE_Morph))&&a.activeEditor===this&&a.setActiveEditor();this.close()}}; BlockEditorMorph.prototype.cancel=function(a){a instanceof CursorMorph||this.close()}; -BlockEditorMorph.prototype.close=function(){var a;if(this.definition.isGlobal&&(a=detect(this.body.contents.allChildren(),function(c){return c.isCustomBlock&&!c.isGlobal}))){a=a.scriptTarget().getMethod(a.semanticSpec).blockInstance();a.addShadow();(new DialogBoxMorph).inform("Local Block(s) in Global Definition","This global block definition contains one or more\nlocal custom blocks which must be removed first.",this.world(),a.doWithAlpha(1,function(){return a.fullImage()}));return}var b=this.target.doubleDefinitionsFor(this.definition); -0c.isCustomBlock&&!c.isGlobal))){a=a.scriptTarget().getMethod(a.semanticSpec).blockInstance();a.addShadow();(new DialogBoxMorph).inform("Local Block(s) in Global Definition","This global block definition contains one or more\nlocal custom blocks which must be removed first.",this.world(),a.doWithAlpha(1,()=>a.fullImage()));return}var b=this.target.doubleDefinitionsFor(this.definition); +0a.fullImage()))):this.destroy()};BlockEditorMorph.prototype.consolidateDoubles=function(){this.target.replaceDoubleDefinitionsFor(this.definition);this.destroy()}; +BlockEditorMorph.prototype.refreshAllBlockInstances=function(a){var b=this.definition,c=this.target.paletteBlockInstance(b);this.definition.isGlobal?this.target.allBlockInstances(this.definition).reverse().forEach(d=>d.refresh()):this.target.allDependentInvocationsOf(a).reverse().forEach(d=>d.refresh(b));c&&c.refreshDefaults()}; +BlockEditorMorph.prototype.updateDefinition=function(){var a;var b=this.definition.blockSpec();var c=this.body.contents.position(),d=1,e;this.definition.receiver=this.target;this.definition.spec=this.prototypeSpec();this.definition.declarations=this.prototypeSlots();this.definition.variableNames=this.variableNames();this.definition.scripts=[];this.definition.updateTranslations(this.translations);this.definition.cachedTranslation=null;this.definition.editorDimensions=this.bounds.copy();this.definition.cachedIsRecursive= +null;this.body.contents.children.forEach(f=>{if(f instanceof PrototypeHatBlockMorph)a=f;else if(f instanceof BlockMorph||f instanceof CommentMorph&&!f.block)e=f.fullCopy(),e.parent=null,e.setPosition(f.position().subtract(c)),this.definition.scripts.push(e)});a&&(this.definition.category!==a.blockCategory&&this.target.shadowAttribute("scripts"),this.definition.category=a.blockCategory,this.definition.type=a.type,a.comment?(this.definition.comment=a.comment.fullCopy(),this.definition.comment.block= +!0):this.definition.comment=null);for(this.definition.body=this.context(a);0b instanceof PrototypeHatBlockMorph)).nextBlock();if(null===a)return null;a.allChildren().forEach(b=>{b instanceof BlockMorph&&(b.cachedInputs=null)});a=Process.prototype.reify.call(null,a,new List(this.definition.inputNames()),!0);a.outerContext=null;return a};BlockEditorMorph.prototype.prototypeSpec=function(){return detect(this.body.contents.children,a=>a instanceof PrototypeHatBlockMorph).parts()[0].specFromFragments()}; +BlockEditorMorph.prototype.prototypeSlots=function(){return detect(this.body.contents.children,a=>a instanceof PrototypeHatBlockMorph).parts()[0].declarationsFromFragments()};BlockEditorMorph.prototype.variableNames=function(){return detect(this.body.contents.children,a=>a instanceof PrototypeHatBlockMorph).variableNames()}; +BlockEditorMorph.prototype.editTranslations=function(){var a=this.definition.blockInstance();a.addShadow(new Point(3,3));(new DialogBoxMorph(this,b=>this.translations=b,this)).promptCode("Custom Block Translations",this.translations,this.world(),a.doWithAlpha(1,()=>a.fullImage()),this.definition.abstractBlockSpec()+"\n\n"+localize('Enter one translation per line. use colon (":") as lang/spec delimiter\nand underscore ("_") as placeholder for an input, e.g.:\n\nen:say _ for _ secs'))}; BlockEditorMorph.prototype.setInitialDimensions=function(){var a=this.world(),b=a.extent().subtract(new Point(this.padding,this.padding)),c=fontHeight(this.titleFontSize)+2*this.titlePadding,d=this.buttons.height();this.definition.editorDimensions?(this.setPosition(this.definition.editorDimensions.origin),this.setExtent(this.definition.editorDimensions.extent().min(b)),this.keepWithin(a)):(this.setExtent(this.body.contents.extent().add(new Point(this.padding,this.padding+c+d)).min(b)),this.setCenter(this.world().center()))}; BlockEditorMorph.prototype.fixLayout=function(){var a=fontHeight(this.titleFontSize)+2*this.titlePadding;this.buttons&&0c.addInput(d))}b.refreshPrototypeSlotTypes();this.fixLayout();b.fixBlockColor(this,!0);this.id= +this.definition.id};PrototypeHatBlockMorph.prototype.mouseClickLeft=function(){if(16===this.world().currentKey)return this.focus();this.parts()[0].mouseClickLeft()};PrototypeHatBlockMorph.prototype.userMenu=function(){return this.parts()[0].userMenu()}; PrototypeHatBlockMorph.prototype.fixBlockColor=function(a,b){a=this.parts()[0]||a;if(this.zebraContrast||b){if(!this.zebraContrast&&b)return this.forceNormalColoring();a.category===this.category?a.color.eq(this.color)&&this.alternateBlockColor():this.category&&!this.color.eq(SpriteMorph.prototype.blockColor[this.category])&&this.alternateBlockColor();b&&this.fixChildrensBlockColor(!0)}};PrototypeHatBlockMorph.prototype.variableNames=function(a){a=this.parts();return 3>a.length?[]:a[2].evaluate()}; PrototypeHatBlockMorph.prototype.enableBlockVars=function(a){var b=this.parts()[0];!1===a?this.setSpec("%s",!0):this.setSpec("%s %br %blockVars",!0);this.replaceInput(this.parts()[0],b);this.spec=null};function BlockLabelFragment(a){this.labelString=a||"";this.type="%s";this.options=this.defaultValue="";this.isDeleted=this.isReadOnly=!1}BlockLabelFragment.prototype.defSpecFragment=function(){var a=this.type?"%'":"";return this.isDeleted?"":a+this.labelString+(this.type?"'":"")}; BlockLabelFragment.prototype.defTemplateSpecFragment=function(){var a="";if(!this.type)return this.defSpecFragment();this.isUpvar()?a=" \u2191":this.isMultipleInput()?a="...":"%cs"===this.type||"%ca"===this.type?a=" \u03bb":"%b"===this.type?a=" ?":"%l"===this.type?a=" \ufe19":"%obj"===this.type?a=" %turtleOutline":contains(["%cmdRing","%repRing","%predRing","%anyUE","%boolUE"],this.type)?a=" \u03bb":this.defaultValue?a="%n"===this.type?" # = "+this.defaultValue.toString():contains(["%mlt","%code"], @@ -2733,10 +2637,10 @@ BlockLabelFragment.prototype.setToMultipleInput=function(){if(!this.type)return BlockLabelFragment.prototype.setSingleInputType=function(a){this.type&&this.isMultipleInput()?this.type="%mult".concat(a):this.type=a};BlockLabelFragmentMorph.prototype=new StringMorph;BlockLabelFragmentMorph.prototype.constructor=BlockLabelFragmentMorph;BlockLabelFragmentMorph.uber=StringMorph.prototype;function BlockLabelFragmentMorph(a){this.init(a)} BlockLabelFragmentMorph.prototype.init=function(a){this.fragment=new BlockLabelFragment(a);this.sO=this.fragment.type=null;BlockLabelFragmentMorph.uber.init.call(this,a,null,SyntaxElementMorph.prototype.labelFontStyle,null,null,null,null,null,null,SyntaxElementMorph.prototype.labelFontName)};BlockLabelFragmentMorph.prototype.mouseEnter=function(){this.sO=this.shadowOffset;this.shadowOffset=this.sO.neg();this.fixLayout();this.rerender()}; BlockLabelFragmentMorph.prototype.mouseLeave=function(){this.shadowOffset=this.sO;this.fixLayout();this.rerender()}; -BlockLabelFragmentMorph.prototype.mouseClickLeft=function(){var a=this,b=this.fragment.copy(),c=this instanceof BlockLabelPlaceHolderMorph,d=2>this.parent.parseSpec(this.parent.blockSpec).length;(new InputSlotDialogMorph(b,null,function(){b.isDeleted?SnapActions.deleteBlockLabel(a.parent.definition,a):b.labelString&&SnapActions.updateBlockLabel(a.parent.definition,a,b)},this,this.parent.definition.category)).open(this instanceof BlockLabelFragmentMorph?"Edit label fragment":c?"Create input name": -"Edit input name",b.labelString,this.world(),null,c||d)};BlockLabelFragmentMorph.prototype.updateBlockLabel=function(a){var b=this.parentThatIsA(BlockMorph);this.fragment=a;b&&b.refreshPrototype()}; -BlockLabelFragmentMorph.prototype.userMenu=function(){var a=this,b=new Color(100,100,130),c=new MenuMorph(function(d){var e=a.text.split("-");a.changed();e[0]="$"+d;a.text=e.join("-");a.fragment.labelString=a.text;a.parent.parent.changed();a.fixLayout();a.parent.parent.fixLayout();a.parent.parent.changed()},null,this,this.fontSize);SymbolMorph.prototype.names.forEach(function(d){return c.addItem([new SymbolMorph(d,c.fontSize,b),localize(d)],d)});c.addLine();c.addItem("\u23ce "+localize("new line"), -"nl");return c};BlockLabelPlaceHolderMorph.prototype=new StringMorph;BlockLabelPlaceHolderMorph.prototype.constructor=BlockLabelPlaceHolderMorph;BlockLabelPlaceHolderMorph.uber=StringMorph.prototype;BlockLabelPlaceHolderMorph.prototype.plainLabel=!1;function BlockLabelPlaceHolderMorph(){this.init()} +BlockLabelFragmentMorph.prototype.mouseClickLeft=function(){var a=this.fragment.copy(),b=this instanceof BlockLabelPlaceHolderMorph,c=2>this.parent.parseSpec(this.parent.blockSpec).length;(new InputSlotDialogMorph(a,null,()=>{a.isDeleted?SnapActions.deleteBlockLabel(this.parent.definition,this):a.labelString&&SnapActions.updateBlockLabel(this.parent.definition,this,a)},this,this.parent.definition.category)).open(this instanceof BlockLabelFragmentMorph?"Edit label fragment":b?"Create input name":"Edit input name", +a.labelString,this.world(),null,b||c)};BlockLabelFragmentMorph.prototype.updateBlockLabel=function(a){var b=this.parentThatIsA(BlockMorph);this.fragment=a;b&&b.refreshPrototype()}; +BlockLabelFragmentMorph.prototype.userMenu=function(){var a=new Color(100,100,130),b=new MenuMorph(c=>{var d=this.text.split("-");this.changed();d[0]="$"+c;this.text=d.join("-");this.fragment.labelString=this.text;this.parent.parent.changed();this.fixLayout();this.parent.parent.fixLayout();this.parent.parent.changed()},null,this,this.fontSize);SymbolMorph.prototype.names.forEach(c=>b.addItem([new SymbolMorph(c,b.fontSize,a),localize(c)],c));b.addLine();b.addItem("\u23ce "+localize("new line"),"nl"); +return b};BlockLabelPlaceHolderMorph.prototype=new StringMorph;BlockLabelPlaceHolderMorph.prototype.constructor=BlockLabelPlaceHolderMorph;BlockLabelPlaceHolderMorph.uber=StringMorph.prototype;BlockLabelPlaceHolderMorph.prototype.plainLabel=!1;function BlockLabelPlaceHolderMorph(){this.init()} BlockLabelPlaceHolderMorph.prototype.init=function(){this.fragment=new BlockLabelFragment("");this.fragment.type="%s";this.fragment.isDeleted=!0;this.isHighlighted=!1;this.isProtectedLabel=!0;BlockLabelFragmentMorph.uber.init.call(this,"+")}; BlockLabelPlaceHolderMorph.prototype.fixLayout=function(){this.plainLabel&&(this.text=this.isHighlighted?" + ":"");this.measureCtx.font=this.font();this.bounds.corner=this.bounds.origin.add(new Point(Math.max(this.measureCtx.measureText(this.text).width,SyntaxElementMorph.prototype.scale),fontHeight(this.fontSize)));this.parent&&(this.parent.fixLayout&&this.parent.fixLayout(),this.parent.parent instanceof PrototypeHatBlockMorph&&this.parent.parent.fixLayout())}; BlockLabelPlaceHolderMorph.prototype.render=function(a){if(this.isHighlighted){var b=this.width()/2;var c=this.height()/2;a.fillStyle=this.color.toString();a.beginPath();a.arc(b,1.2*c,Math.min(b,c),radians(0),radians(360),!1);a.closePath();a.fill()}a.font=this.font();a.textAlign="left";a.textBaseline="bottom";a.fillStyle=this.isHighlighted?"white":this.color.toString();a.fillText(this.text,0,fontHeight(this.fontSize))}; @@ -2746,58 +2650,56 @@ BlockInputFragmentMorph.prototype.init=function(a){this.fragment=new BlockLabelF InputSlotDialogMorph.uber=DialogBoxMorph.prototype;InputSlotDialogMorph.prototype.isLaunchingExpanded=!1;function InputSlotDialogMorph(a,b,c,d,e){this.init(a,b,c,d,e)} InputSlotDialogMorph.prototype.init=function(a,b,c,d,e){var f=SyntaxElementMorph.prototype.scale,g=fontHeight(10)/1.2*f;this.fragment=a||new BlockLabelFragment;this.slots=this.types=this.textfield=null;this.isExpanded=!1;this.category=e||"other";this.noDelete=!1;BlockDialogMorph.uber.init.call(this,b,c,d);this.types=new AlignmentMorph("row",this.padding);this.types.respectHiddens=!0;this.add(this.types);this.slots=new BoxMorph;this.slots.color=new Color(55,55,55);this.slots.borderColor=this.slots.color.lighter(50); this.slots.setExtent(new Point(24*(g+10),10.4*(g+10*f)));this.add(this.slots);this.createSlotTypeButtons();this.fixSlotsLayout();this.addSlotsMenu();this.createTypeButtons();this.fixLayout()}; -InputSlotDialogMorph.prototype.createTypeButtons=function(){var a=this,b=SpriteMorph.prototype.blockColor[this.category];var c=new JaggedBlockMorph(localize("Title text"));c.setColor(b);this.addBlockTypeButton(function(){return a.setType(null)},c,function(){return null===a.fragment.type});c=new JaggedBlockMorph("%inputName");c.setColor(b);this.addBlockTypeButton(function(){return a.setType("%s")},c,function(){return null!==a.fragment.type});var d=new ArrowMorph("right",PushButtonMorph.prototype.fontSize+ -4,2);d.noticesTransparentClick=!0;this.types.add(d);this.types.fixLayout();d.refresh=function(){null===a.fragment.type?(a.isExpanded=!1,d.hide()):(d.show(),d.direction=a.isExpanded?"down":"right",d.fixLayout(),d.rerender())};d.mouseClickLeft=function(){d.isVisible&&(a.isExpanded=!a.isExpanded,a.types.children.forEach(function(e){return e.refresh()}),a.changed(),a.fixLayout(),a.rerender(),a.edit())};d.refresh()};InputSlotDialogMorph.prototype.addTypeButton=BlockDialogMorph.prototype.addTypeButton; -InputSlotDialogMorph.prototype.addBlockTypeButton=BlockDialogMorph.prototype.addBlockTypeButton; -InputSlotDialogMorph.prototype.setType=function(a){this.textfield.choices=a?null:this.symbolMenu;this.textfield.fixLayout();this.fragment.type=a||null;this.types.children.forEach(function(b){return b.refresh()});this.slots.children.forEach(function(b){return b.refresh()});isNil(a)&&(this.isExpanded=!1,this.types.children.forEach(function(b){return b.refresh()}),this.changed(),this.fixLayout(),this.rerender());this.edit()}; +InputSlotDialogMorph.prototype.createTypeButtons=function(){var a=SpriteMorph.prototype.blockColor[this.category];var b=new JaggedBlockMorph(localize("Title text"));b.setColor(a);this.addBlockTypeButton(()=>this.setType(null),b,()=>null===this.fragment.type);b=new JaggedBlockMorph("%inputName");b.setColor(a);this.addBlockTypeButton(()=>this.setType("%s"),b,()=>null!==this.fragment.type);var c=new ArrowMorph("right",PushButtonMorph.prototype.fontSize+4,2);c.noticesTransparentClick=!0;this.types.add(c); +this.types.fixLayout();c.refresh=()=>{null===this.fragment.type?(this.isExpanded=!1,c.hide()):(c.show(),c.direction=this.isExpanded?"down":"right",c.fixLayout(),c.rerender())};c.mouseClickLeft=()=>{c.isVisible&&(this.isExpanded=!this.isExpanded,this.types.children.forEach(d=>d.refresh()),this.changed(),this.fixLayout(),this.rerender(),this.edit())};c.refresh()};InputSlotDialogMorph.prototype.addTypeButton=BlockDialogMorph.prototype.addTypeButton;InputSlotDialogMorph.prototype.addBlockTypeButton=BlockDialogMorph.prototype.addBlockTypeButton; +InputSlotDialogMorph.prototype.setType=function(a){this.textfield.choices=a?null:this.symbolMenu;this.textfield.fixLayout();this.fragment.type=a||null;this.types.children.forEach(b=>b.refresh());this.slots.children.forEach(b=>b.refresh());isNil(a)&&(this.isExpanded=!1,this.types.children.forEach(b=>b.refresh()),this.changed(),this.fixLayout(),this.rerender());this.edit()}; InputSlotDialogMorph.prototype.getInput=function(){var a;this.body instanceof InputFieldMorph&&(a=this.normalizeSpaces(this.body.getValue()));if(a)return this.fragment.labelString=a,contains(["%b","%boolUE"],this.fragment.type)?this.fragment.defaultValue=this.slots.defaultSwitch.evaluate():this.fragment.defaultValue=this.slots.defaultInputField.getValue(),a;this.fragment.isDeleted=!0;return null}; InputSlotDialogMorph.prototype.fixLayout=function(){var a=this.left(),b=fontHeight(this.titleFontSize)+2*this.titlePadding;if(!this.isExpanded)return this.slots&&this.slots.hide(),BlockDialogMorph.prototype.fixLayout.call(this);this.slots.show();var c=this.slots.width();this.body.setPosition(this.position().add(new Point(this.padding+(c-this.body.width())/2,b+this.padding)));this.label.setLeft(a+this.padding+(c-this.label.width())/2);this.label.setTop(this.top()+(b-this.label.height())/2);this.types.fixLayout(); -this.types.setTop(this.body.bottom()+this.padding);this.types.setLeft(a+this.padding+(c-this.types.width())/2);this.slots.setPosition(new Point(this.left()+this.padding,this.types.bottom()+this.padding));this.slots.children.forEach(function(d){return d.refresh()});this.buttons.fixLayout();this.buttons.setTop(this.slots.bottom()+this.padding);this.buttons.setLeft(a+this.padding+(c-this.buttons.width())/2);this.bounds.setHeight(this.buttons.bottom()-this.top()+this.padding);this.bounds.setWidth(this.slots.right()- -this.left()+this.padding);this.removeShadow();this.addShadow()}; +this.types.setTop(this.body.bottom()+this.padding);this.types.setLeft(a+this.padding+(c-this.types.width())/2);this.slots.setPosition(new Point(this.left()+this.padding,this.types.bottom()+this.padding));this.slots.children.forEach(d=>d.refresh());this.buttons.fixLayout();this.buttons.setTop(this.slots.bottom()+this.padding);this.buttons.setLeft(a+this.padding+(c-this.buttons.width())/2);this.bounds.setHeight(this.buttons.bottom()-this.top()+this.padding);this.bounds.setWidth(this.slots.right()-this.left()+ +this.padding);this.removeShadow();this.addShadow()}; InputSlotDialogMorph.prototype.open=function(a,b,c,d,e){b=new InputFieldMorph(b);this.fragment.type||(b.choices=this.symbolMenu);this.isExpanded=this.isLaunchingExpanded;b.setWidth(250);this.labelString=a;this.createLabel();d&&this.setPicture(d);this.addBody(b);this.textfield=b;this.addButton("ok","OK");e?this.noDelete=!0:this.addButton("deleteFragment","Delete");this.addButton("cancel","Cancel");this.fixLayout();this.popUp(c);this.add(this.types);this.changed()}; -InputSlotDialogMorph.prototype.symbolMenu=function(){var a=this,b=[],c=new Color(100,100,130);SymbolMorph.prototype.names.forEach(function(d){return b.push([[new SymbolMorph(d,a.fontSize,c),localize(d)],"$"+d])});b.push(["\u23ce "+localize("new line"),"$nl"]);return b};InputSlotDialogMorph.prototype.deleteFragment=function(){this.fragment.isDeleted=!0;this.accept()}; -InputSlotDialogMorph.prototype.createSlotTypeButtons=function(){var a=this;this.addSlotTypeButton("Object","%obj");this.addSlotTypeButton("Text","%txt");this.addSlotTypeButton("List","%l");this.addSlotTypeButton("Number","%n");this.addSlotTypeButton("Any type","%s");this.addSlotTypeButton("Boolean (T/F)","%b");this.addSlotTypeButton("Command\n(inline)","%cmdRing");this.addSlotTypeButton("Reporter","%repRing");this.addSlotTypeButton("Predicate","%predRing");this.addSlotTypeButton("Command\n(C-shape)", -["%cs","%ca"]);this.addSlotTypeButton("Any\n(unevaluated)","%anyUE");this.addSlotTypeButton("Boolean\n(unevaluated)","%boolUE");this.slots.radioButtonSingle=this.addSlotArityButton(function(){return a.setSlotArity("single")},"Single input.",function(){return a.fragment.isSingleInput()});this.addSlotArityButton(function(){return a.setSlotArity("multiple")},"Multiple inputs (value is list of inputs)",function(){return a.fragment.isMultipleInput()});this.addSlotArityButton(function(){return a.setSlotArity("upvar")}, -"Upvar - make internal variable visible to caller",function(){return a.fragment.isUpvar()});var b=new StringMorph(localize("Default Value:"));b.fontSize=this.slots.radioButtonSingle.fontSize;b.setColor(WHITE);b.refresh=function(){a.isExpanded&&contains("%s %n %txt %anyUE %b %boolUE %mlt %code".split(" "),a.fragment.type)?b.show():b.hide()};this.slots.defaultInputLabel=b;this.slots.add(b);var c=new InputFieldMorph(this.fragment.defaultValue);c.contents().fontSize=b.fontSize;c.contrast=90;c.setWidth(50); -c.refresh=function(){a.isExpanded&&contains("%s %n %txt %anyUE %mlt %code".split(" "),a.fragment.type)?(c.show(),"%n"===a.fragment.type?c.setIsNumeric(!0):c.setIsNumeric(!1)):c.hide()};this.slots.defaultInputField=c;this.slots.add(c);var d=new BooleanSlotMorph(this.fragment.defaultValue);d.refresh=function(){a.isExpanded&&contains(["%b","%boolUE"],a.fragment.type)?d.show():d.hide()};this.slots.defaultSwitch=d;this.slots.add(d);var e=new ToggleMorph("checkbox",this,function(){"%ca"===a.fragment.type? -a.setType("%cs"):a.setType("%ca")},null,function(){return"%ca"===a.fragment.type},null,null,new SymbolMorph("loop",.7*this.fontSize,WHITE),null);e.refresh=function(){ToggleMorph.prototype.refresh.call(e);a.isExpanded&&contains(["%cs","%ca"],a.fragment.type)?e.show():e.hide()};this.slots.loopArrow=e;this.slots.add(e)};InputSlotDialogMorph.prototype.setSlotType=function(a){this.fragment.setSingleInputType(a);this.slots.children.forEach(function(b){return b.refresh()});this.edit()}; -InputSlotDialogMorph.prototype.setSlotArity=function(a){"single"===a?this.fragment.setToSingleInput():"multiple"===a?this.fragment.setToMultipleInput():"upvar"===a&&this.fragment.setToUpvar();this.slots.children.forEach(function(b){return b.refresh()});this.edit()};InputSlotDialogMorph.prototype.setSlotOptions=function(a){this.fragment.options=a}; -InputSlotDialogMorph.prototype.addSlotTypeButton=function(a,b){var c=this,d=new JaggedBlockMorph(b instanceof Array?b[0]:b);d.setCategory(this.category);d.rebuild();a=new ToggleMorph("radiobutton",this,function(){c.setSlotType(b instanceof Array?b[0]:b)},a,function(){return b instanceof Array?contains(b,c.fragment.singleInputType()):c.fragment.singleInputType()===b},null,null,d.doWithAlpha(1,function(){return d.fullImage()}),"rebuild");a.edge=this.buttonEdge/2;a.outline=this.buttonOutline/2;a.outlineColor= -this.buttonOutlineColor;a.outlineGradient=this.buttonOutlineGradient;a.fixLayout();a.label.isBold=!1;a.label.setColor(WHITE);this.slots.add(a);return a};InputSlotDialogMorph.prototype.addSlotArityButton=function(a,b,c){a=new ToggleMorph("radiobutton",this,a,b,c,null,null);a.edge=this.buttonEdge/2;a.outline=this.buttonOutline/2;a.outlineColor=this.buttonOutlineColor;a.outlineGradient=this.buttonOutlineGradient;a.fixLayout();a.label.setColor(WHITE);this.slots.add(a);return a}; +InputSlotDialogMorph.prototype.symbolMenu=function(){var a=[],b=new Color(100,100,130);SymbolMorph.prototype.names.forEach(c=>a.push([[new SymbolMorph(c,this.fontSize,b),localize(c)],"$"+c]));a.push(["\u23ce "+localize("new line"),"$nl"]);return a};InputSlotDialogMorph.prototype.deleteFragment=function(){this.fragment.isDeleted=!0;this.accept()}; +InputSlotDialogMorph.prototype.createSlotTypeButtons=function(){this.addSlotTypeButton("Object","%obj");this.addSlotTypeButton("Text","%txt");this.addSlotTypeButton("List","%l");this.addSlotTypeButton("Number","%n");this.addSlotTypeButton("Any type","%s");this.addSlotTypeButton("Boolean (T/F)","%b");this.addSlotTypeButton("Command\n(inline)","%cmdRing");this.addSlotTypeButton("Reporter","%repRing");this.addSlotTypeButton("Predicate","%predRing");this.addSlotTypeButton("Command\n(C-shape)",["%cs", +"%ca"]);this.addSlotTypeButton("Any\n(unevaluated)","%anyUE");this.addSlotTypeButton("Boolean\n(unevaluated)","%boolUE");this.slots.radioButtonSingle=this.addSlotArityButton(()=>this.setSlotArity("single"),"Single input.",()=>this.fragment.isSingleInput());this.addSlotArityButton(()=>this.setSlotArity("multiple"),"Multiple inputs (value is list of inputs)",()=>this.fragment.isMultipleInput());this.addSlotArityButton(()=>this.setSlotArity("upvar"),"Upvar - make internal variable visible to caller", +()=>this.fragment.isUpvar());var a=new StringMorph(localize("Default Value:"));a.fontSize=this.slots.radioButtonSingle.fontSize;a.setColor(WHITE);a.refresh=()=>{this.isExpanded&&contains("%s %n %txt %anyUE %b %boolUE %mlt %code".split(" "),this.fragment.type)?a.show():a.hide()};this.slots.defaultInputLabel=a;this.slots.add(a);var b=new InputFieldMorph(this.fragment.defaultValue);b.contents().fontSize=a.fontSize;b.contrast=90;b.setWidth(50);b.refresh=()=>{this.isExpanded&&contains("%s %n %txt %anyUE %mlt %code".split(" "), +this.fragment.type)?(b.show(),"%n"===this.fragment.type?b.setIsNumeric(!0):b.setIsNumeric(!1)):b.hide()};this.slots.defaultInputField=b;this.slots.add(b);var c=new BooleanSlotMorph(this.fragment.defaultValue);c.refresh=()=>{this.isExpanded&&contains(["%b","%boolUE"],this.fragment.type)?c.show():c.hide()};this.slots.defaultSwitch=c;this.slots.add(c);var d=new ToggleMorph("checkbox",this,()=>{"%ca"===this.fragment.type?this.setType("%cs"):this.setType("%ca")},null,()=>"%ca"===this.fragment.type,null, +null,new SymbolMorph("loop",.7*this.fontSize,WHITE),null);d.refresh=()=>{ToggleMorph.prototype.refresh.call(d);this.isExpanded&&contains(["%cs","%ca"],this.fragment.type)?d.show():d.hide()};this.slots.loopArrow=d;this.slots.add(d)};InputSlotDialogMorph.prototype.setSlotType=function(a){this.fragment.setSingleInputType(a);this.slots.children.forEach(b=>b.refresh());this.edit()}; +InputSlotDialogMorph.prototype.setSlotArity=function(a){"single"===a?this.fragment.setToSingleInput():"multiple"===a?this.fragment.setToMultipleInput():"upvar"===a&&this.fragment.setToUpvar();this.slots.children.forEach(b=>b.refresh());this.edit()};InputSlotDialogMorph.prototype.setSlotOptions=function(a){this.fragment.options=a}; +InputSlotDialogMorph.prototype.addSlotTypeButton=function(a,b){var c=new JaggedBlockMorph(b instanceof Array?b[0]:b);c.setCategory(this.category);c.rebuild();a=new ToggleMorph("radiobutton",this,()=>{this.setSlotType(b instanceof Array?b[0]:b)},a,()=>b instanceof Array?contains(b,this.fragment.singleInputType()):this.fragment.singleInputType()===b,null,null,c.doWithAlpha(1,()=>c.fullImage()),"rebuild");a.edge=this.buttonEdge/2;a.outline=this.buttonOutline/2;a.outlineColor=this.buttonOutlineColor; +a.outlineGradient=this.buttonOutlineGradient;a.fixLayout();a.label.isBold=!1;a.label.setColor(WHITE);this.slots.add(a);return a};InputSlotDialogMorph.prototype.addSlotArityButton=function(a,b,c){a=new ToggleMorph("radiobutton",this,a,b,c,null,null);a.edge=this.buttonEdge/2;a.outline=this.buttonOutline/2;a.outlineColor=this.buttonOutlineColor;a.outlineGradient=this.buttonOutlineGradient;a.fixLayout();a.label.setColor(WHITE);this.slots.add(a);return a}; InputSlotDialogMorph.prototype.fixSlotsLayout=function(){var a=this.slots,b=SyntaxElementMorph.prototype.scale,c=10*b,d=14*b,e=(fontHeight(10)/1.2+15)*b;b*=fontHeight(10)/1.2+10;c=[a.left()+c,a.left()+a.width()/3,a.left()+2*a.width()/3];d=[a.top()+d,a.top()+d+e,a.top()+d+2*e,a.top()+d+3*e,a.top()+d+4*e,a.top()+d+5*e,a.top()+d+5*e+b,a.top()+d+5*e+2*b];b=-1;for(e=0;12>e;e+=1){var f=e%3;0===e%3&&(b+=1);a.children[e].setPosition(new Point(c[f],d[b]))}f=0;b=5;for(e=12;15>e;e+=1)a.children[e].setPosition(new Point(c[f], d[b+e-12]));this.slots.defaultInputLabel.setPosition(this.slots.radioButtonSingle.label.topRight().add(new Point(5,0)));this.slots.defaultInputField.setCenter(this.slots.defaultInputLabel.center().add(new Point(this.slots.defaultInputField.width()/2+this.slots.defaultInputLabel.width()/2+5,0)));this.slots.defaultSwitch.setCenter(this.slots.defaultInputLabel.center().add(new Point(this.slots.defaultSwitch.width()/2+this.slots.defaultInputLabel.width()/2+5,0)));this.slots.loopArrow.setPosition(this.slots.defaultInputLabel.position()); this.slots.changed()}; -InputSlotDialogMorph.prototype.addSlotsMenu=function(){var a=this;this.slots.userMenu=function(){if(contains("%s %n %txt %anyUE %mlt %code".split(" "),a.fragment.type)){var b=new MenuMorph(a);b.addItem((a.fragment.hasOptions()?"\u2611 ":"\u2610 ")+localize("options")+"...","editSlotOptions");b.addItem((a.fragment.isReadOnly?"\u2611 ":"\u2610 ")+localize("read-only"),function(){return a.fragment.isReadOnly=!a.fragment.isReadOnly});b.addLine();b.addMenu((a.fragment.hasSpecialMenu()?"\u2611 ":"\u2610 ")+ -localize("menu"),a.specialOptionsMenu());b.addMenu((contains(["%mlt","%code"],a.fragment.type)?"\u2611 ":"\u2610 ")+localize("special"),a.specialSlotsMenu());return b}return a.specialSlotsMenu()}};InputSlotDialogMorph.prototype.editSlotOptions=function(){var a=this;(new DialogBoxMorph(this,function(b){return a.fragment.options=b.trim()},this)).promptCode("Input Slot Options",this.fragment.options,this.world(),null,localize('Enter one option per line.\nOptionally use "=" as key/value delimiter and {} for submenus. e.g.\n the answer=42'))}; +InputSlotDialogMorph.prototype.addSlotsMenu=function(){this.slots.userMenu=()=>{if(contains("%s %n %txt %anyUE %mlt %code".split(" "),this.fragment.type)){var a=new MenuMorph(this);a.addItem((this.fragment.hasOptions()?"\u2611 ":"\u2610 ")+localize("options")+"...","editSlotOptions");a.addItem((this.fragment.isReadOnly?"\u2611 ":"\u2610 ")+localize("read-only"),()=>this.fragment.isReadOnly=!this.fragment.isReadOnly);a.addLine();a.addMenu((this.fragment.hasSpecialMenu()?"\u2611 ":"\u2610 ")+localize("menu"), +this.specialOptionsMenu());a.addMenu((contains(["%mlt","%code"],this.fragment.type)?"\u2611 ":"\u2610 ")+localize("special"),this.specialSlotsMenu());return a}return this.specialSlotsMenu()}};InputSlotDialogMorph.prototype.editSlotOptions=function(){(new DialogBoxMorph(this,a=>this.fragment.options=a.trim(),this)).promptCode("Input Slot Options",this.fragment.options,this.world(),null,localize('Enter one option per line.\nOptionally use "=" as key/value delimiter and {} for submenus. e.g.\n the answer=42'))}; InputSlotDialogMorph.prototype.specialSlotsMenu=function(){var a=new MenuMorph(this.setSlotType,null,this);a.addItem(("%mlt"===this.fragment.type?"\u26ab ":"\u26aa ")+localize("multi-line"),"%mlt");a.addItem(("%code"===this.fragment.type?"\u26ab ":"\u26aa ")+localize("code"),"%code");return a}; InputSlotDialogMorph.prototype.specialOptionsMenu=function(){function a(d,e){b.addItem((c.fragment.options===e?"\u26ab ":"\u26aa ")+localize(d),e)}var b=new MenuMorph(this.setSlotOptions,null,this),c=this;a("(none)","");a("messages","\u00a7_messagesMenu");a("objects","\u00a7_objectsMenu");a("costumes","\u00a7_costumesMenu");a("sounds","\u00a7_soundsMenu");a("variables","\u00a7_getVarNamesDict");a("piano keyboard","\u00a7_pianoKeyboardMenu");a("360\u00b0 dial","\u00a7_directionDialMenu");return b}; InputSlotDialogMorph.prototype.hide=function(){this.isVisible=!1;this.changed()};InputSlotDialogMorph.prototype.show=function(){this.isVisible=!0;this.changed()};VariableDialogMorph.prototype=new DialogBoxMorph;VariableDialogMorph.prototype.constructor=VariableDialogMorph;VariableDialogMorph.uber=DialogBoxMorph.prototype;function VariableDialogMorph(a,b,c){this.init(a,b,c)} -VariableDialogMorph.prototype.init=function(a,b,c){this.types=null;this.isGlobal=!0;BlockDialogMorph.uber.init.call(this,a,b,c);this.types=new AlignmentMorph("row",this.padding);this.add(this.types);this.createTypeButtons()};VariableDialogMorph.prototype.createTypeButtons=function(){var a=this;this.addTypeButton(function(){return a.setType("global")},"for all sprites",function(){return a.isGlobal});this.addTypeButton(function(){return a.setType("local")},"for this sprite only",function(){return!a.isGlobal})}; -VariableDialogMorph.prototype.addTypeButton=BlockDialogMorph.prototype.addTypeButton;VariableDialogMorph.prototype.setType=function(a){this.isGlobal="global"===a;this.types.children.forEach(function(b){return b.refresh()});this.edit()};VariableDialogMorph.prototype.getInput=function(){var a=this.normalizeSpaces(this.body.getValue());return a?[a,this.isGlobal]:null}; +VariableDialogMorph.prototype.init=function(a,b,c){this.types=null;this.isGlobal=!0;BlockDialogMorph.uber.init.call(this,a,b,c);this.types=new AlignmentMorph("row",this.padding);this.add(this.types);this.createTypeButtons()};VariableDialogMorph.prototype.createTypeButtons=function(){this.addTypeButton(()=>this.setType("global"),"for all sprites",()=>this.isGlobal);this.addTypeButton(()=>this.setType("local"),"for this sprite only",()=>!this.isGlobal)};VariableDialogMorph.prototype.addTypeButton=BlockDialogMorph.prototype.addTypeButton; +VariableDialogMorph.prototype.setType=function(a){this.isGlobal="global"===a;this.types.children.forEach(b=>b.refresh());this.edit()};VariableDialogMorph.prototype.getInput=function(){var a=this.normalizeSpaces(this.body.getValue());return a?[a,this.isGlobal]:null}; VariableDialogMorph.prototype.fixLayout=function(){var a=fontHeight(this.titleFontSize)+2*this.titlePadding;this.body&&(this.body.setPosition(this.position().add(new Point(this.padding,a+this.padding))),this.bounds.setWidth(this.body.width()+2*this.padding),this.bounds.setHeight(this.body.height()+2*this.padding+a));this.label&&(this.label.setCenter(this.center()),this.label.setTop(this.top()+(a-this.label.height())/2));this.types&&(this.types.fixLayout(),this.bounds.setHeight(this.height()+this.types.height()+ this.padding),this.bounds.setWidth(Math.max(this.width(),this.types.width()+2*this.padding)),this.types.setCenter(this.center()),this.body?this.types.setTop(this.body.bottom()+this.padding):this.categories&&this.types.setTop(this.categories.bottom()+this.padding));this.buttons&&0this.exportBlocks(d),null);this.labelString="Export blocks / message types";this.createLabel();this.buildContents()}; +BlockExportDialogMorph.prototype.buildContents=function(){var a,b,c,d=this.target;var e=new ScrollFrameMorph(null,null,SpriteMorph.prototype.sliderColor);e.color=SpriteMorph.prototype.paletteColor;e.padding=4;e.isDraggable=!1;e.acceptsDrops=!1;e.contents.acceptsDrops=!1;var f=e.left()+4;var g=e.top()+4;SpriteMorph.prototype.categories.forEach(l=>{this.blocks.forEach(m=>{m.category===l&&(c&&l!==c&&(g+=4),c=l,a=m.templateInstance(),b=new ToggleMorph("checkbox",this,()=>{var n=this.blocks.indexOf(m); +-1contains(this.blocks,m),null,null,a.fullImage()),b.setPosition(new Point(f,g+(b.top()-b.toggleElement.top()))),e.addContents(b),g+=b.fullBounds().height()+4)})});this.msgs=[];for(var h=0;h{b=new ToggleMorph("checkbox",this,()=>{this.msgs.includes(l)?this.msgs.splice(this.msgs.indexOf(l), +1):this.msgs.push(l)},null,()=>this.msgs.includes(l),null,null,l.fullImage());b.setPosition(new Point(f,g+(b.top()-b.toggleElement.top())));e.addContents(b);g+=b.fullBounds().height()+4});e.scrollX(4);e.scrollY(4);this.addBody(e);this.addButton("ok","OK");this.addButton("cancel","Cancel");this.setExtent(new Point(220,300));this.fixLayout()}; +BlockExportDialogMorph.prototype.popUp=function(a){if(a=a||this.target.world())BlockExportDialogMorph.uber.popUp.call(this,a),this.handle=new HandleMorph(this,200,220,this.corner,this.corner)};BlockExportDialogMorph.prototype.userMenu=function(){var a=new MenuMorph(this,"select");a.addItem("all","selectAll");a.addItem("none","selectNone");return a};BlockExportDialogMorph.prototype.selectAll=function(){this.body.contents.children.forEach(a=>{a.state||a.trigger()})}; +BlockExportDialogMorph.prototype.selectNone=function(){this.blocks=[];this.body.contents.children.forEach(a=>{a.refresh()})}; BlockExportDialogMorph.prototype.exportBlocks=function(a){var b=this.serializer.serialize(this.blocks,!0),c=this.world().children[0],d=c.stage,e="";c=c.room.name||localize("untitled");for(var f=0;f"+d.messageTypes.getMsgType(this.msgs[f].blockSpec).toXML(this.serializer)+"";0'+b+e+"",a(b,c+" "+localize("blocks"))):(new DialogBoxMorph).inform("Export blocks / message types", "no blocks or message types were selected",this.world())};BlockExportDialogMorph.prototype.fixLayout=BlockEditorMorph.prototype.fixLayout;BlockImportDialogMorph.prototype=new DialogBoxMorph;BlockImportDialogMorph.prototype.constructor=BlockImportDialogMorph;BlockImportDialogMorph.uber=DialogBoxMorph.prototype;BlockImportDialogMorph.prototype.key="blockImport";function BlockImportDialogMorph(a,b,c){this.init(a,b,c)} -BlockImportDialogMorph.prototype.init=function(a,b,c){var d=this;this.blocks=a.slice(0);this.handle=null;BlockExportDialogMorph.uber.init.call(this,b,function(){return d.importBlocks(c)},null);this.labelString=localize("Import blocks")+(c?": ":"")+c||"";this.createLabel();this.buildContents()};BlockImportDialogMorph.prototype.buildContents=BlockExportDialogMorph.prototype.buildContents;BlockImportDialogMorph.prototype.popUp=BlockExportDialogMorph.prototype.popUp; -BlockImportDialogMorph.prototype.userMenu=BlockExportDialogMorph.prototype.userMenu;BlockImportDialogMorph.prototype.selectAll=BlockExportDialogMorph.prototype.selectAll;BlockImportDialogMorph.prototype.selectNone=BlockExportDialogMorph.prototype.selectNone;BlockImportDialogMorph.prototype.importBlocks=function(a){(a=this.target.parentThatIsA(IDE_Morph))&&(0this.colCount||b>this.rowCount?null:(this.contents[b-1]||[])[a-1]:this.colName(a):b?this.rowName(b):[this.rowCount]};Table.prototype.row=function(a){return this.contents[a-1]};Table.prototype.col=function(a){var b=[];--a;var c;for(c=0;cthis.colCount)return null;var b=this.colNames[a-1];return void 0!==b?b:String.fromCharCode(64+(a%26||26)).repeat(Math.floor((a-1)/26)+1)};Table.prototype.rowName=function(a){return a>this.rowCount?null:this.rowNames[a-1]||a};Table.prototype.rows=function(){return this.rowCount};Table.prototype.cols=function(){return this.colCount};Table.prototype.columnNames=function(){return this.colNames};Table.prototype.set=function(a,b,c){this.contents[c-1][b-1]=a;this.changed()}; -Table.prototype.setRows=function(a,b,c){this.contents=a;b&&(this.colNames=b);c&&(this.rowNames=c);this.changed()};Table.prototype.setCols=function(a,b,c){var d,e;for(e=0;ethis.importBlocks(c),null);this.labelString=localize("Import blocks")+(c?": ":"")+c||"";this.createLabel();this.buildContents()};BlockImportDialogMorph.prototype.buildContents=BlockExportDialogMorph.prototype.buildContents;BlockImportDialogMorph.prototype.popUp=BlockExportDialogMorph.prototype.popUp;BlockImportDialogMorph.prototype.userMenu=BlockExportDialogMorph.prototype.userMenu; +BlockImportDialogMorph.prototype.selectAll=BlockExportDialogMorph.prototype.selectAll;BlockImportDialogMorph.prototype.selectNone=BlockExportDialogMorph.prototype.selectNone;BlockImportDialogMorph.prototype.importBlocks=function(a){(a=this.target.parentThatIsA(IDE_Morph))&&(0this.removeBlocks(),null);this.labelString=localize("Remove unused blocks")+(name?": ":"")+name||"";this.createLabel();this.buildContents()};BlockRemovalDialogMorph.prototype.buildContents=BlockExportDialogMorph.prototype.buildContents;BlockRemovalDialogMorph.prototype.popUp=BlockExportDialogMorph.prototype.popUp;BlockRemovalDialogMorph.prototype.userMenu=BlockExportDialogMorph.prototype.userMenu; +BlockRemovalDialogMorph.prototype.selectAll=BlockExportDialogMorph.prototype.selectAll;BlockRemovalDialogMorph.prototype.selectNone=BlockExportDialogMorph.prototype.selectNone; +BlockRemovalDialogMorph.prototype.removeBlocks=async function(){var a=this.target.parentThatIsA(IDE_Morph);a&&(0this.colCount||b>this.rowCount?null:(this.contents[b-1]||[])[a-1]:this.colName(a):b?this.rowName(b):[this.rowCount]}; +Table.prototype.row=function(a){return this.contents[a-1]};Table.prototype.col=function(a){var b=[];--a;var c;for(c=0;cthis.colCount)return null;var b=this.colNames[a-1];return void 0!==b?b:String.fromCharCode(64+(a%26||26)).repeat(Math.floor((a-1)/26)+1)};Table.prototype.rowName=function(a){return a>this.rowCount?null:this.rowNames[a-1]||a};Table.prototype.rows=function(){return this.rowCount}; +Table.prototype.cols=function(){return this.colCount};Table.prototype.columnNames=function(){return this.colNames};Table.prototype.set=function(a,b,c){this.contents[c-1][b-1]=a;this.changed()};Table.prototype.setRows=function(a,b,c){this.contents=a;b&&(this.colNames=b);c&&(this.rowNames=c);this.changed()};Table.prototype.setCols=function(a,b,c){var d,e;for(e=0;enew List(a)))};Table.prototype.fillWithTestData=function(){var a,b;for(a=1;a<=this.colCount;a+=1)for(b=1;b<=this.rowCount;b+=1)this.set(this.colName(a)+this.rowName(b),a,b)};TableCellMorph.prototype=new Morph;TableCellMorph.prototype.constructor=TableCellMorph; +TableCellMorph.uber=Morph.prototype;TableCellMorph.prototype.cachedListSymbol=null;TableCellMorph.prototype.listSymbol=function(){this.cachedListSymbol&&this.cachedListSymbol.height()===SyntaxElementMorph.prototype.fontSize||(this.cachedListSymbol=new SymbolMorph("list",SyntaxElementMorph.prototype.fontSize,SpriteMorph.prototype.blockColor.lists.darker(50)));return this.cachedListSymbol.getImage()};function TableCellMorph(a,b,c){this.init(a,b,c)} TableCellMorph.prototype.init=function(a,b,c){this.data=a;this.isLabel=c||!1;this.labelString=null;TableCellMorph.uber.init.call(this,!0);b&&this.bounds.setExtent(b);this.fixLayout()};TableCellMorph.prototype.setData=function(a,b){this.data=a;b&&!b.eq(this.extent())&&this.bounds.setExtent(b);this.rerender()};TableCellMorph.prototype.getData=function(){return this.data instanceof Array?this.data[0]:this.data}; TableCellMorph.prototype.render=function(a){var b=this.labelString||this.dataRepresentation(this.data),c=SyntaxElementMorph.prototype.fontSize,d=TableMorph.prototype.highContrast?"rgb(220, 220, 220)":"transparent",e=(this.isLabel?this.data instanceof Array?"italic":"":this.shouldBeList()?"bold":"")+" "+c+"px Helvetica, Arial, sans-serif",f=this.labelString?"rgb(220, 220, 250)":this.isLabel?d:this.shouldBeList()?"rgb(217, 77, 17)":this.isOvershooting()?"white":isNil(this.data)?d:"white",g=!this.isLabel&& this.shouldBeList()?"white":"black",h=this.width();d=this.height();a.fillStyle=f;this.shouldBeList()?(BoxMorph.prototype.outlinePath.call(this,a,SyntaxElementMorph.prototype.corner+1,0),a.fill()):this.isOvershooting()?(this.raggedBoxPath(a),a.fill()):a.fillRect(0,0,h,d);b&&(b instanceof HTMLCanvasElement?(g=Math.max((h-b.width)/2,0),d=Math.max((d-b.height)/2,0),a.shadowOffsetX=4,a.shadowOffsetY=4,a.shadowBlur=4,a.shadowColor="lightgray",a.drawImage(b,g,d)):(a.font=e,a.textAlign="left",a.textBaseline= @@ -2819,7 +2721,7 @@ TableMorph.prototype.scroll=function(a,b){this.showData(Math.min(this.maxStartCo TableMorph.prototype.showData=function(a,b,c){a=a||this.startCol;b=b||this.startRow;a===this.startCol?b!==this.startRow&&(this.startRow=b,this.rows=this.visibleRows(),this.drawData(c)):(this.startCol=a,this.startRow=b,this.rows=this.visibleRows(),this.colWidths.length?(this.columns=this.columnsLayout(),this.buildCells()):this.drawData(c))}; TableMorph.prototype.step=function(){this.dragAnchor?this.shiftCells(this.world().hand.position()):this.resizeAnchor&&this.resizeCells(this.world().hand.position());this.update()}; TableMorph.prototype.update=function(){var a=this.table instanceof List?this.table.version(this.startRow,this.rows,this.startCol,this.columns.length):this.table.lastChanged;if(this.tableVersion!==a||this.wantsUpdate){this.wantsUpdate=!1;if(this.table instanceof List){var b=this.columns.length;var c=this.rows;this.rowLabelWidth=this.rowLabelsWidth();this.columns=this.columnsLayout();this.rows=this.visibleRows();this.columns.length!==b||this.rows!==c?this.buildCells():this.drawData()}else this.drawData(); -this.tableVersion=a}};TableMorph.prototype.rowLabelsWidth=function(){var a=StringMorph.prototype.measureCtx;a.font="italic "+SyntaxElementMorph.prototype.fontSize+"px Helvetica, Arial, sans-serif";return Math.max(0,Math.max.apply(null,this.table.columnNames().map(function(b){return b?a.measureText(b).width:0})))||a.measureText(this.table.rows().toString()).width+6*SyntaxElementMorph.prototype.scale}; +this.tableVersion=a}};TableMorph.prototype.rowLabelsWidth=function(){var a=StringMorph.prototype.measureCtx;a.font="italic "+SyntaxElementMorph.prototype.fontSize+"px Helvetica, Arial, sans-serif";return Math.max(0,Math.max.apply(null,this.table.columnNames().map(b=>b?a.measureText(b).width:0)))||a.measureText(this.table.rows().toString()).width+6*SyntaxElementMorph.prototype.scale}; TableMorph.prototype.columnsLayout=function(){var a=[],b=2*this.padding+this.rowLabelWidth,c;var d=this.table.cols();for(c=b;ca)return 0;a=Math.ceil(a/(this.rowHeight+this.padding));this.maxStartRow=Math.max(1,this.table.rows()-a+2);this.startRow=Math.min(this.startRow,this.maxStartRow);return Math.min(this.table.rows(),a)}; TableMorph.prototype.globalExtent=function(){var a,b=this.rowLabelsWidth()+2,c=this.table.cols();for(a=0;athis.columns[b];)b+=1;return b+this.startCol-1}; -TableMorph.prototype.userMenu=function(){var a=this,b=new MenuMorph(this);if(this.parentThatIsA(TableDialogMorph))return this.colWidths.length&&(b.addItem("reset columns","resetColumns"),b.addLine()),this.table instanceof List&&this.table.canBeJSON()&&b.addItem("blockify",function(){var c=a.world(),d=detect(c.children,function(e){return e instanceof IDE_Morph});a.table.blockify().pickUp(c);c.hand.grabOrigin={origin:d.palette,position:d.palette.center()}}),b.addItem("open in another dialog...","openInDialog"), -b;this.colWidths.length&&b.addItem("reset columns","resetColumns");b.addItem("list view...","showListView");this.table instanceof List&&this.table.canBeJSON()&&b.addItem("blockify",function(){var c=a.world(),d=detect(c.children,function(e){return e instanceof IDE_Morph});a.table.blockify().pickUp(c);c.hand.grabOrigin={origin:d.palette,position:d.palette.center()}});b.addLine();b.addItem("open in dialog...","openInDialog");return b}; +TableMorph.prototype.userMenu=function(){var a=new MenuMorph(this);if(this.parentThatIsA(TableDialogMorph))return this.colWidths.length&&(a.addItem("reset columns","resetColumns"),a.addLine()),this.table instanceof List&&this.table.canBeJSON()&&a.addItem("blockify",()=>{var b=this.world(),c=detect(b.children,d=>d instanceof IDE_Morph);this.table.blockify().pickUp(b);b.hand.grabOrigin={origin:c.palette,position:c.palette.center()}}),a.addItem("open in another dialog...","openInDialog"),a;this.colWidths.length&& +a.addItem("reset columns","resetColumns");a.addItem("list view...","showListView");this.table instanceof List&&this.table.canBeJSON()&&a.addItem("blockify",()=>{var b=this.world(),c=detect(b.children,d=>d instanceof IDE_Morph);this.table.blockify().pickUp(b);b.hand.grabOrigin={origin:c.palette,position:c.palette.center()}});a.addLine();a.addItem("open in dialog...","openInDialog");return a}; TableMorph.prototype.resetColumns=function(){this.colWidths=[];this.rowLabelWidth=this.rowLabelsWidth();this.columns=this.columnsLayout();this.rows=this.visibleRows();this.buildCells();this.changed()};TableMorph.prototype.openInDialog=function(){(new TableDialogMorph(this.table,this.globalColWidth,this.colWidths,this.rowHeight)).popUp(this.world())}; TableMorph.prototype.showListView=function(){var a=this.parentThatIsA(SpriteBubbleMorph,SpeechBubbleMorph,CellMorph);a&&(a instanceof SpriteBubbleMorph?(a.changed(),a.contentsMorph.destroy(),a.contentsMorph=new ListWatcherMorph(this.table),a.contentsMorph.step=a.contents.update,a.contentsMorph.expand(this.extent()),a.parent.positionTalkBubble()):a instanceof SpeechBubbleMorph?(a.contents=new ListWatcherMorph(this.table),a.contents.step=a.contents.update,a.contents.expand(this.extent())):(a.changed(), a.contentsMorph.destroy(),a.contentsMorph=new ListWatcherMorph(this.table),a.add(a.contentsMorph),a.contentsMorph.setPosition(this.position()),a.contentsMorph.expand(this.extent())),a.fixLayout(),a.rerender())};TableMorph.prototype.show=function(){TableMorph.uber.show.call(this);this.updateScrollBars()};TableFrameMorph.prototype=new Morph;TableFrameMorph.prototype.constructor=TableFrameMorph;TableFrameMorph.uber=Morph.prototype;function TableFrameMorph(a,b){this.init(a,b)} @@ -2841,87 +2743,87 @@ TableDialogMorph.prototype.popUp=function(a){a&&(TableDialogMorph.uber.popUp.cal ReadStream.prototype.next=function(a){if(void 0===a)return a=this.contents[this.index],this.index+=1,a;var b=this.index;this.index+=a;return this.contents.slice(b,this.index)};ReadStream.prototype.peek=function(){return this.contents[this.index]};ReadStream.prototype.skip=function(a){this.index+=a||1};ReadStream.prototype.atEnd=function(){return this.index>this.contents.length-1}; ReadStream.prototype.upTo=function(a){a=this.contents.indexOf(a,this.index);return-1===a?"":this.contents.slice(this.index,this.index=a)};ReadStream.prototype.peekUpTo=function(a){a=this.contents.indexOf(a,this.index);return-1===a?"":this.contents.slice(this.index,a)};ReadStream.prototype.skipSpace=function(){this.nonSpace.lastIndex=this.index;var a=this.nonSpace.exec(this.contents);a&&(this.index=a.index)}; ReadStream.prototype.word=function(){this.nonWord.lastIndex=this.index;var a=this.nonWord.exec(this.contents);return a?this.contents.slice(this.index,this.index=a.index):""};XML_Element.prototype=Object.create(Node.prototype);XML_Element.prototype.constructor=XML_Element;XML_Element.uber=Node.prototype;XML_Element.prototype.indentation=" ";function XML_Element(a,b,c){this.init(a,b,c)} -XML_Element.prototype.init=function(a,b,c){this.tag=a||"unnamed";this.attributes={};this.contents=b||"";XML_Element.uber.init.call(this);c&&c.addChild(this)};XML_Element.prototype.require=function(a,b){var c=this.childNamed(a);if(!c){if(b instanceof Function)return b();if(!isNil(b))return b;throw Error("Missing required element <"+a+">!");}return c};XML_Element.prototype.childNamed=function(a){return detect(this.children,function(b){return b.tag===a})}; -XML_Element.prototype.childrenNamed=function(a){return this.children.filter(function(b){return b.tag===a})};XML_Element.prototype.parentNamed=function(a){return this.tag===a?this:this.parent?this.parent.parentNamed(a):null}; -XML_Element.prototype.toString=function(a,b){var c="",d="",e=b||0,f;if(a){for(b=0;b"):c+="/>";return c};XML_Element.prototype.escape=function(a,b){a=isNil(a)?"":a.toString();var c="",d;for(d=0;d":c+=">";break;case "&":c+="&";break;case "\n":c+=" ";break;case "~":c+="~";break;default:c+=e}}return c}; -XML_Element.prototype.unescape=function(a){return a.replace(/&(amp|apos|quot|lt|gt|#xD|#126);/g,function(b,c){switch(c){case "amp":return"&";case "apos":return"'";case "quot":return'"';case "lt":return"<";case "gt":return">";case "#xD":return"\n";case "#126":return"~";default:console.warn("unreachable")}})};XML_Element.prototype.parseString=function(a){a=new ReadStream(a);a.upTo("<");a.skip();this.parseStream(a)}; +XML_Element.prototype.init=function(a,b,c){this.tag=a||"unnamed";this.attributes={};this.contents=b||"";XML_Element.uber.init.call(this);c&&c.addChild(this)};XML_Element.prototype.require=function(a,b){var c=this.childNamed(a);if(!c){if(b instanceof Function)return b();if(!isNil(b))return b;throw Error("Missing required element <"+a+">!");}return c};XML_Element.prototype.childNamed=function(a){return detect(this.children,b=>b.tag===a)}; +XML_Element.prototype.childrenNamed=function(a){return this.children.filter(b=>b.tag===a)};XML_Element.prototype.parentNamed=function(a){return this.tag===a?this:this.parent?this.parent.parentNamed(a):null}; +XML_Element.prototype.toString=function(a,b){var c="",d="",e=b||0,f;if(a){for(b=0;b{a&&(c+="\n");c+=g.toString(a,e+1)}),a&&this.children.length&& +(c+="\n"+d),c+=""):c+="/>";return c};XML_Element.prototype.escape=function(a,b){a=isNil(a)?"":a.toString();var c="",d;for(d=0;d":c+=">";break;case "&":c+="&";break;case "\n":c+=" ";break;case "~":c+="~";break;default:c+=e}}return c}; +XML_Element.prototype.unescape=function(a){return a.replace(/&(amp|apos|quot|lt|gt|#xD|#126);/g,(b,c)=>{switch(c){case "amp":return"&";case "apos":return"'";case "quot":return'"';case "lt":return"<";case "gt":return">";case "#xD":return"\n";case "#126":return"~";default:console.warn("unreachable")}})};XML_Element.prototype.parseString=function(a){a=new ReadStream(a);a.upTo("<");a.skip();this.parseStream(a)}; XML_Element.prototype.parseStream=function(a){var b;this.tag=a.word();if(0===this.tag.indexOf("![CDATA["))this.contents=this.tag.slice(8)+a.upTo("]]\x3e"),this.tag="CDATA",a.skip(3);else{a.skipSpace();for(b=a.peek();">"!==b&&"/"!==b;){var c=a.word();a.skipSpace();if("="!==a.next())throw Error('Expected "=" after attribute name');a.skipSpace();b=a.next();if('"'!==b&&"'"!==b)throw Error("Expected single- or double-quoted attribute value");b=a.upTo(b);a.skip(1);a.skipSpace();this.attributes[c]=this.unescape(b); b=a.peek()}if("/"===b){if(a.skip(),">"!==a.next())throw Error('Expected ">" after "/" in empty tag');}else{if(">"!==a.next())throw Error('Expected ">" after tag name and attributes');for(;!a.atEnd();)if(b=a.next(),"<"===b){if("/"===a.peek()){a.skip();if(a.word()!==this.tag)throw Error("Expected to close "+this.tag);a.upTo(">");a.skip();this.contents=this.unescape(this.contents);break}c=new XML_Element(null,null,this);c.parseStream(a)}else this.contents+=b}}};modules.store="2020-July-08"; -function XML_Serializer(){this.instanceCount+=1;this.contents=[];this.media=[];this.isCollectingMedia=!1;this.dependencies=null;this.isExportingBlocksLibrary=!1;this.idProperty="serializationID_"+this.instanceCount;this.mediaIdProperty="serializationMediaID_"+this.instanceCount}XML_Serializer.prototype.instanceCount=0;XML_Serializer.prototype.idProperty="serializationID";XML_Serializer.prototype.mediaIdProperty="serializationMediaID";XML_Serializer.prototype.mediaDetectionProperty="isMedia"; +function XML_Serializer(){this.instanceCount+=1;this.contents=[];this.media=[];this.isCollectingMedia=!1;this.dependencies=null;this.isExportingBlocksLibrary=!1;this.idProperty=`serializationID_${this.instanceCount}`;this.mediaIdProperty=`serializationMediaID_${this.instanceCount}`}XML_Serializer.prototype.instanceCount=0;XML_Serializer.prototype.idProperty="serializationID";XML_Serializer.prototype.mediaIdProperty="serializationMediaID";XML_Serializer.prototype.mediaDetectionProperty="isMedia"; XML_Serializer.prototype.version=1;XML_Serializer.prototype.serialize=function(a,b){this.flush();this.flushMedia();this.isExportingBlocksLibrary=b;a=this.store(a);this.flush();return a}; XML_Serializer.prototype.store=function(a,b){if(isNil(a)||!a.toXML)return"";if(this.isCollectingMedia&&a[this.mediaDetectionProperty])return this.addMedia(a,b),this.format('',a[this.mediaIdProperty]);if(a[this.idProperty])return this.format('',a[this.idProperty]);this.add(a);return this.isSavingPortable&&a.toPortableXML?a.toPortableXML(this,b).replace("~",this.format('id="@"',a[this.idProperty])):a.toXML(this,b).replace("~",this.format('id="@"',a[this.idProperty]))}; -XML_Serializer.prototype.mediaXML=function(){var a=this,b="";this.media.forEach(function(c){c=c.toXML(a).replace("~",a.format('mediaID="@"',c[a.mediaIdProperty]));b+=c});return b+""};XML_Serializer.prototype.undoQueueXML=function(a){return this.format('%',a,SnapUndo.undoCount[a],this.undoEventsXML(SnapUndo.eventHistory[a]||[]))}; +XML_Serializer.prototype.mediaXML=function(){var a="";this.media.forEach(b=>{b=b.toXML(this).replace("~",this.format('mediaID="@"',b[this.mediaIdProperty]));a+=b});return a+""};XML_Serializer.prototype.undoQueueXML=function(a){return this.format('%',a,SnapUndo.undoCount[a],this.undoEventsXML(SnapUndo.eventHistory[a]||[]))}; XML_Serializer.prototype.undoEventsXML=function(a,b){for(var c=[],d,e,f=a.length;f--;){d=a[f];e=[];for(var g=d.args.length;g--;)e.unshift(this.getArgumentXML("arg",d.args[g]));e=e.join("");d=b?this.format('%',d.id,d.type,d.replayType||0,d.time,d.user,d.username||"",d.isUserAction||!1,e):this.format('',d.id);c.unshift(d)}return c.join("")}; XML_Serializer.prototype.getArgumentXML=function(a,b){var c=this,d=b;b instanceof Object?d=Object.keys(b).map(function(e){return b[e]instanceof Array?b[e].map(function(f){return c.getArgumentXML("_"+e,f)}).join(""):/^[^a-zA-Z].*/.test(e)?c.getArgumentXML("_"+e,b[e]):c.getArgumentXML(e,b[e])}).join(""):"string"===typeof b&&-1",d,""].join("")}; XML_Serializer.prototype.loadEventArg=function(a){var b=-1;if(a.children.length){if("CDATA"===a.children[0].tag)return a.children[0].contents.replace(/&ncdata;]>/g,"]]\x3e");var c={};var d=!0;for(var e=a.children.length;e--;){var f=a.children[e];var g="_"===f.tag[0]?f.tag.slice(1):f.tag;isNaN(+g)&&(d=!1);c[g]instanceof Array?c[g].unshift(this.loadEventArg(f)):c[g]=c[g]?[this.loadEventArg(f),c[g]]:this.loadEventArg(f);d&&(b=Math.max(b,+g))}d&&(c.length=b+1,c=Array.prototype.slice.call(c));return c}return a.contents}; XML_Serializer.prototype.historyXML=function(a){var b=this,c=a&&a+"/";return SnapUndo.allQueueIds().filter(function(d){return c?0===d.indexOf(c):-1===d.indexOf("/")}).map(function(d){return b.undoQueueXML(d)}).join("")};XML_Serializer.prototype.replayHistory=function(){return this.undoEventsXML(SnapUndo.allEvents,!0)};XML_Serializer.prototype.add=function(a){if(a[this.idProperty])return-1;this.contents.push(a);return a[this.idProperty]=this.contents.length}; -XML_Serializer.prototype.addMedia=function(a,b){if(a[this.mediaIdProperty])return-1;this.media.push(a);a[this.mediaIdProperty]=b?b+"_"+a.name:this.media.length;return this.media.length};XML_Serializer.prototype.at=function(a){return this.contents[a-1]};XML_Serializer.prototype.flush=function(){var a=this;this.contents.forEach(function(b){return delete b[a.idProperty]});this.contents=[];this.dependencies=null}; -XML_Serializer.prototype.flushMedia=function(){var a=this;this.media instanceof Array&&this.media.forEach(function(b){return delete b[a.mediaIdProperty]});this.media=[];this.isExportingBlocksLibrary=!1};XML_Serializer.prototype.escape=XML_Element.prototype.escape;XML_Serializer.prototype.unescape=XML_Element.prototype.unescape; -XML_Serializer.prototype.format=function(a){var b=this,c=-1,d=arguments,e;return a.replace(/[@$%]([\d]+)?/g,function(f,g){g=parseInt(g,10);isNaN(g)?(c+=1,e=d[c+1]):e=d[g+1];return"@"===f?b.escape(e):"$"===f?b.escape(e,!0):e})};XML_Serializer.prototype.load=function(a){nop(a);throw Error("loading should be implemented in heir of XML_Serializer");};XML_Serializer.prototype.parse=function(a){var b=new XML_Element;b.parseString(a);return b};SnapSerializer.prototype=new XML_Serializer; +XML_Serializer.prototype.addMedia=function(a,b){if(a[this.mediaIdProperty])return-1;this.media.push(a);a[this.mediaIdProperty]=b?b+"_"+a.name:this.media.length;return this.media.length};XML_Serializer.prototype.at=function(a){return this.contents[a-1]};XML_Serializer.prototype.flush=function(){this.contents.forEach(a=>delete a[this.idProperty]);this.contents=[];this.dependencies=null}; +XML_Serializer.prototype.flushMedia=function(){this.media instanceof Array&&this.media.forEach(a=>delete a[this.mediaIdProperty]);this.media=[];this.isExportingBlocksLibrary=!1};XML_Serializer.prototype.escape=XML_Element.prototype.escape;XML_Serializer.prototype.unescape=XML_Element.prototype.unescape; +XML_Serializer.prototype.format=function(a){var b=-1,c=arguments,d;return a.replace(/[@$%]([\d]+)?/g,(e,f)=>{f=parseInt(f,10);isNaN(f)?(b+=1,d=c[b+1]):d=c[f+1];return"@"===e?this.escape(d):"$"===e?this.escape(d,!0):d})};XML_Serializer.prototype.load=function(a){nop(a);throw Error("loading should be implemented in heir of XML_Serializer");};XML_Serializer.prototype.parse=function(a){var b=new XML_Element;b.parseString(a);return b};SnapSerializer.prototype=new XML_Serializer; SnapSerializer.prototype.constructor=SnapSerializer;SnapSerializer.uber=XML_Serializer.prototype;SnapSerializer.prototype.app="Snap! 6, https://snap.berkeley.edu";SnapSerializer.prototype.thumbnailSize=new Point(640,480);SnapSerializer.prototype.isSavingHistory=!1; SnapSerializer.prototype.watcherLabels={reportRPCError:"error",xPosition:"x position",yPosition:"y position",direction:"direction",getScale:"size",reportShown:"shown?",getTempo:"tempo",getVolume:"volume",getPan:"balance",getPenDown:"pen down?",getLastAnswer:"answer",getLastMessage:"message",getTimer:"timer",getCostumeIdx:"costume #",reportMouseX:"mouse x",reportMouseY:"mouse y",reportThreadCount:"processes"};function SnapSerializer(){this.init()} -SnapSerializer.prototype.init=function(){this.project={};this.objects={};this.mediaDict={};this.isSavingCustomBlockOwners=!0};XML_Serializer.prototype.mediaXML=function(a){var b=this,c='';this.media.forEach(function(d){d=d.toXML(b).replace("~",b.format('mediaID="@"',d[b.mediaIdProperty]));c+=d});return c+""};SnapSerializer.prototype.load=function(a,b){return this.loadProjectModel(this.parse(a),b)}; +SnapSerializer.prototype.init=function(){this.project={};this.objects={};this.mediaDict={};this.isSavingCustomBlockOwners=!0};XML_Serializer.prototype.mediaXML=function(a){var b='';this.media.forEach(c=>{c=c.toXML(this).replace("~",this.format('mediaID="@"',c[this.mediaIdProperty]));b+=c});return b+""};SnapSerializer.prototype.load=function(a,b){return this.loadProjectModel(this.parse(a),b)}; SnapSerializer.prototype.getPortableXML=function(a){var b=this.isSavingPortable,c=this.isSavingHistory;this.isSavingPortable=!0;this.isSavingHistory=!1;a.getPortableDependencies&&(this.dependencies=a.getPortableDependencies());a=this.store(a);this.isSavingPortable=b;this.isSavingHistory=c;this.dependencies=null;return a}; SnapSerializer.prototype.loadProjectModelSync=function(a,b,c){var d=a.attributes.app;d=d?d.split(" ")[0]:null;b&&d&&d!==this.app.split(" ")[0]&&b.inform(d+" Project","This project has been created by a different app:\n\n"+d+"\n\nand may be incompatible or fail to load here.");a=this.rawLoadProjectModel(a,c);this.objects={};return a}; -SnapSerializer.prototype.loadProjectModel=function(a,b,c){function d(g,h){var k=g[h];if(k){var l=utils.defer();g[h]=function(){k.apply(null,arguments);l.resolve()};return l.promise}}var e=this,f;return $jscomp.asyncExecutePromiseGeneratorProgram(function(g){return 1==g.nextAddress?(f=e.loadProjectModelSync(a,b,c),f.pentrails?g.yield(d(f.pentrails,"onload"),2):g.jumpTo(2)):g.return(f)})}; -SnapSerializer.prototype.rawLoadProjectModel=function(a,b){var c,d,e=this,f={sprites:{},undo:{allEvents:[],eventHistory:{},undoCount:{}}};this.project=f;var g=d=d=d=d=d=d=g=c=c=void 0;if(+a.attributes.version>this.version)throw"Project uses newer version of Serializer";this.objects={};f.name=a.attributes.name;if(!f.name){for(c=1;Object.prototype.hasOwnProperty.call(localStorage,"-snap-project-Untitled "+c);)c+=1;f.name="Untitled "+c}if(c=a.childNamed("notes"))f.notes=c.contents;c=a.childNamed("variables"); -f.globalVariables=new VariableFrame;f.collabStartIndex=+(a.attributes.collabStartIndex||0);f.undo.allEvents=this.loadReplayHistory(a.childNamed("replay"));g=a.require("stage");StageMorph.prototype.frameRate=0;f.stage=new StageMorph(f.globalVariables);f.stage.remixID=b;Object.prototype.hasOwnProperty.call(g.attributes,"id")&&(this.objects[g.attributes.id]=f.stage);g.attributes.name&&(f.stage.name=g.attributes.name);g.attributes.color&&(f.stage.color=this.loadColor(g.attributes.color),f.stage.cachedHSV= -f.stage.color.hsv());"true"===g.attributes.scheduled&&(f.stage.fps=30,StageMorph.prototype.frameRate=30);g.attributes.volume&&(f.stage.volume=+g.attributes.volume);g.attributes.pan&&(f.stage.pan=+g.attributes.pan);g.attributes.penlog&&(StageMorph.prototype.enablePenLogging="true"===g.attributes.penlog);if(d=g.childNamed("pentrails"))f.pentrails=new Image,f.pentrails.onload=function(){f.stage.trailsCanvas&&(normalizeCanvas(f.stage.trailsCanvas),f.stage.trailsCanvas.getContext("2d").drawImage(f.pentrails, -0,0),f.stage.changed())},f.pentrails.src=d.contents;f.stage.setTempo(g.attributes.tempo);StageMorph.prototype.dimensions=new Point(480,360);g.attributes.width&&(StageMorph.prototype.dimensions.x=Math.max(+g.attributes.width,240));g.attributes.height&&(StageMorph.prototype.dimensions.y=Math.max(+g.attributes.height,180));f.stage.id=g.attributes.collabId||null;f.stage.setExtent(StageMorph.prototype.dimensions);SpriteMorph.prototype.useFlatLineEnds="flat"===g.attributes.lines;BooleanSlotMorph.prototype.isTernary= -"false"!==g.attributes.ternary;Process.prototype.enableHyperOps="false"!==g.attributes.hyperops;f.stage.isThreadSafe="true"===g.attributes.threadsafe;StageMorph.prototype.enableCodeMapping="true"===g.attributes.codify;StageMorph.prototype.enableInheritance="false"!==g.attributes.inheritance;StageMorph.prototype.enableSublistIDs="true"===g.attributes.sublistIDs;(d=a.childNamed("hidden"))&&d.contents.split(" ").forEach(function(h){h&&(StageMorph.prototype.hiddenPrimitives[h]=!0)});(d=a.childNamed("headers"))&& -d.children.forEach(function(h){return StageMorph.prototype.codeHeaders[h.tag]=h.contents});(d=a.childNamed("code"))&&d.children.forEach(function(h){return StageMorph.prototype.codeMappings[h.tag]=h.contents});(d=g.childNamed("messageTypes"))&&d.children.forEach(this.loadMessageType.bind(this,f.stage));if(d=a.childNamed("blocks"))this.loadCustomBlocks(f.stage,d,!0),this.populateCustomBlocks(f.stage,d,!0);this.loadObject(f.stage,g);this.loadHistory(a.childNamed("history"));g=g.require("sprites");f.sprites[f.stage.name]= -f.stage;g.childrenNamed("sprite").forEach(function(h){return e.loadValue(h)});this.project.stage.children.forEach(function(h){var k;h.inheritanceInfo&&((k=e.project.sprites[h.inheritanceInfo.exemplar])&&h.setExemplar(k),h.inheritedAttributes=h.inheritanceInfo.delegated||[],h.updatePropagationCache());h.nestingInfo&&((k=e.project.sprites[h.nestingInfo.anchor])&&k.attachPart(h),h.rotatesWithAnchor="true"===h.nestingInfo.synch)});this.project.stage.children.forEach(function(h){var k;h.nestingInfo&&(h.nestingScale= -+(h.nestingInfo.scale||h.scale),delete h.nestingInfo);["scripts","costumes","sounds"].forEach(function(l){h.inheritsAttribute(l)&&h.refreshInheritedAttribute(l)});h.inheritsAttribute("costumes")&&(k=h.inheritsAttribute("costume #")?h.exemplar.costume:h.costumes.asArray()[h.inheritanceInfo.costumeNumber-1])&&(k.loaded?h.wearCostume(k,!0):k.loaded=function(){this.loaded=!0;h.wearCostume(k,!0)});delete h.inheritanceInfo});c&&this.loadVariables(f.globalVariables,c);g.childrenNamed("watcher").forEach(function(h){var k= -e.loadColor(h.attributes.color);var l=Object.prototype.hasOwnProperty.call(h.attributes,"scope")?f.sprites[h.attributes.scope]:null;var m=Object.prototype.hasOwnProperty.call(h.attributes,"hidden")&&"false"!==h.attributes.hidden;k=Object.prototype.hasOwnProperty.call(h.attributes,"var")?new WatcherMorph(h.attributes["var"],k,isNil(l)?f.globalVariables:l.variables,h.attributes["var"],m):new WatcherMorph(localize(e.watcherLabels[h.attributes.s]),k,l,h.attributes.s,m);k.setStyle(h.attributes.style|| -"normal");"slider"===k.style&&(k.setSliderMin(h.attributes.min||"1",!0),k.setSliderMax(h.attributes.max||"100",!0));k.setPosition(f.stage.topLeft().add(new Point(+h.attributes.x||0,+h.attributes.y||0)));f.stage.add(k);k.onNextStep=function(){this.currentValue=null};k.currentValue instanceof List&&k.cellMorph.contentsMorph&&((l=h.attributes.extX)&&k.cellMorph.contentsMorph.setWidth(+l),(h=h.attributes.extY)&&k.cellMorph.contentsMorph.setHeight(+h),k.cellMorph.contentsMorph.handle.fixLayout())});this.project.stage.children.forEach(function(h){return h.inheritedMethodsCache= -[]});this.objects={};return f};SnapSerializer.prototype.loadReplayHistory=function(a){a=a?a.children:[];for(var b=[],c,d=a.length;d--;)c=this.parseEvent(null,a[d],!0),b.unshift(c);return b}; +SnapSerializer.prototype.loadProjectModel=async function(a,b,c){function d(e,f){const g=e[f];if(g){var h=utils.defer();e[f]=function(){g(...arguments);h.resolve()};return h.promise}}a=this.loadProjectModelSync(a,b,c);a.pentrails&&await d(a.pentrails,"onload");return a}; +SnapSerializer.prototype.rawLoadProjectModel=function(a,b){var c,d,e={sprites:{},undo:{allEvents:[],eventHistory:{},undoCount:{}}};this.project=e;var f=d=d=d=d=d=d=f=c=c=void 0;if(+a.attributes.version>this.version)throw"Project uses newer version of Serializer";this.objects={};e.name=a.attributes.name;if(!e.name){for(c=1;Object.prototype.hasOwnProperty.call(localStorage,"-snap-project-Untitled "+c);)c+=1;e.name="Untitled "+c}if(c=a.childNamed("notes"))e.notes=c.contents;c=a.childNamed("variables"); +e.globalVariables=new VariableFrame;e.collabStartIndex=+(a.attributes.collabStartIndex||0);e.undo.allEvents=this.loadReplayHistory(a.childNamed("replay"));f=a.require("stage");StageMorph.prototype.frameRate=0;e.stage=new StageMorph(e.globalVariables);e.stage.remixID=b;Object.prototype.hasOwnProperty.call(f.attributes,"id")&&(this.objects[f.attributes.id]=e.stage);f.attributes.name&&(e.stage.name=f.attributes.name);f.attributes.color&&(e.stage.color=this.loadColor(f.attributes.color),e.stage.cachedHSV= +e.stage.color.hsv());"true"===f.attributes.scheduled&&(e.stage.fps=30,StageMorph.prototype.frameRate=30);f.attributes.volume&&(e.stage.volume=+f.attributes.volume);f.attributes.pan&&(e.stage.pan=+f.attributes.pan);f.attributes.penlog&&(StageMorph.prototype.enablePenLogging="true"===f.attributes.penlog);if(d=f.childNamed("pentrails"))e.pentrails=new Image,e.pentrails.onload=function(){e.stage.trailsCanvas&&(normalizeCanvas(e.stage.trailsCanvas),e.stage.trailsCanvas.getContext("2d").drawImage(e.pentrails, +0,0),e.stage.changed())},e.pentrails.src=d.contents;e.stage.setTempo(f.attributes.tempo);StageMorph.prototype.dimensions=new Point(480,360);f.attributes.width&&(StageMorph.prototype.dimensions.x=Math.max(+f.attributes.width,240));f.attributes.height&&(StageMorph.prototype.dimensions.y=Math.max(+f.attributes.height,180));e.stage.id=f.attributes.collabId||null;e.stage.setExtent(StageMorph.prototype.dimensions);SpriteMorph.prototype.useFlatLineEnds="flat"===f.attributes.lines;BooleanSlotMorph.prototype.isTernary= +"false"!==f.attributes.ternary;Process.prototype.enableHyperOps="false"!==f.attributes.hyperops;e.stage.isThreadSafe="true"===f.attributes.threadsafe;StageMorph.prototype.enableCodeMapping="true"===f.attributes.codify;StageMorph.prototype.enableInheritance="false"!==f.attributes.inheritance;StageMorph.prototype.enableSublistIDs="true"===f.attributes.sublistIDs;(d=a.childNamed("hidden"))&&d.contents.split(" ").forEach(g=>{g&&(StageMorph.prototype.hiddenPrimitives[g]=!0)});(d=a.childNamed("headers"))&& +d.children.forEach(g=>StageMorph.prototype.codeHeaders[g.tag]=g.contents);(d=a.childNamed("code"))&&d.children.forEach(g=>StageMorph.prototype.codeMappings[g.tag]=g.contents);(d=f.childNamed("messageTypes"))&&d.children.forEach(this.loadMessageType.bind(this,e.stage));if(d=a.childNamed("blocks"))this.loadCustomBlocks(e.stage,d,!0),this.populateCustomBlocks(e.stage,d,!0);this.loadObject(e.stage,f);this.loadHistory(a.childNamed("history"));f=f.require("sprites");e.sprites[e.stage.name]=e.stage;f.childrenNamed("sprite").forEach(g=> +this.loadValue(g));this.project.stage.children.forEach(g=>{var h;g.inheritanceInfo&&((h=this.project.sprites[g.inheritanceInfo.exemplar])&&g.setExemplar(h),g.inheritedAttributes=g.inheritanceInfo.delegated||[],g.updatePropagationCache());g.nestingInfo&&((h=this.project.sprites[g.nestingInfo.anchor])&&h.attachPart(g),g.rotatesWithAnchor="true"===g.nestingInfo.synch)});this.project.stage.children.forEach(g=>{var h;g.nestingInfo&&(g.nestingScale=+(g.nestingInfo.scale||g.scale),delete g.nestingInfo); +["scripts","costumes","sounds"].forEach(k=>{g.inheritsAttribute(k)&&g.refreshInheritedAttribute(k)});g.inheritsAttribute("costumes")&&(h=g.inheritsAttribute("costume #")?g.exemplar.costume:g.costumes.asArray()[g.inheritanceInfo.costumeNumber-1])&&(h.loaded?g.wearCostume(h,!0):h.loaded=function(){this.loaded=!0;g.wearCostume(h,!0)});delete g.inheritanceInfo});c&&this.loadVariables(e.globalVariables,c);f.childrenNamed("watcher").forEach(g=>{var h=this.loadColor(g.attributes.color);var k=Object.prototype.hasOwnProperty.call(g.attributes, +"scope")?e.sprites[g.attributes.scope]:null;var l=Object.prototype.hasOwnProperty.call(g.attributes,"hidden")&&"false"!==g.attributes.hidden;h=Object.prototype.hasOwnProperty.call(g.attributes,"var")?new WatcherMorph(g.attributes["var"],h,isNil(k)?e.globalVariables:k.variables,g.attributes["var"],l):new WatcherMorph(localize(this.watcherLabels[g.attributes.s]),h,k,g.attributes.s,l);h.setStyle(g.attributes.style||"normal");"slider"===h.style&&(h.setSliderMin(g.attributes.min||"1",!0),h.setSliderMax(g.attributes.max|| +"100",!0));h.setPosition(e.stage.topLeft().add(new Point(+g.attributes.x||0,+g.attributes.y||0)));e.stage.add(h);h.onNextStep=function(){this.currentValue=null};h.currentValue instanceof List&&h.cellMorph.contentsMorph&&((k=g.attributes.extX)&&h.cellMorph.contentsMorph.setWidth(+k),(g=g.attributes.extY)&&h.cellMorph.contentsMorph.setHeight(+g),h.cellMorph.contentsMorph.handle.fixLayout())});this.project.stage.children.forEach(g=>g.inheritedMethodsCache=[]);this.objects={};return e}; +SnapSerializer.prototype.loadReplayHistory=function(a){a=a?a.children:[];for(var b=[],c,d=a.length;d--;)c=this.parseEvent(null,a[d],!0),b.unshift(c);return b}; SnapSerializer.prototype.loadHistory=function(a){a=a?a.children:[];for(var b,c=this.project.undo,d,e,f,g=a.length;g--;){e=a[g].attributes.id;f=c.allEvents.length-1;c.undoCount[e]=+a[g].attributes["undo-count"]||0;c.eventHistory[e]=[];b=a[g].children;for(var h=b.length;h--;){for(d=+b[h].attributes.id;0<=f&&c.allEvents[f].id!==d;)f--;0<=f?(d=c.allEvents[f],d.owner=e,c.eventHistory[e].unshift(d)):console.error("Could not load historical event from replay:",b[h])}}}; SnapSerializer.prototype.parseEvent=function(a,b){for(var c=[],d=b.children.length;d--;)c.unshift(this.loadEventArg(b.children[d]));return{id:+b.attributes.id,owner:a,type:b.attributes.type,replayType:+b.attributes.replayType,time:+b.attributes.time,user:b.attributes.user,username:b.attributes.username||void 0,isUserAction:"true"===b.attributes.isUserAction,args:c}}; -SnapSerializer.prototype.loadBlocks=function(a,b){var c=new StageMorph;this.project={stage:c,sprites:{},targetStage:b};a=this.parse(a);if(+a.attributes.version>this.version)throw"Module uses newer version of Serializer";this.loadCustomBlocks(c,a,!0);this.populateCustomBlocks(c,a,!0);this.objects={};c.globalBlocks.forEach(function(d){return d.receiver=null});this.objects={};this.project={};this.mediaDict={};return c.globalBlocks}; -SnapSerializer.prototype.loadSprites=function(a,b){var c=this;var d=this.project={globalVariables:b.globalVariables,stage:b.stage,sprites:{}};d.sprites[d.stage.name]=d.stage;a=this.parse(a);if(+a.attributes.version>this.version)throw"Module uses newer version of Serializer";a.childrenNamed("sprite").forEach(function(e){var f=new SpriteMorph(d.globalVariables);e.attributes.id&&(c.objects[e.attributes.id]=f);e.attributes.name&&(f.name=b.newSpriteName(e.attributes.name),d.sprites[f.name]=f);e.attributes.color&& -(f.color=c.loadColor(e.attributes.color),f.cachedHSV=f.color.hsv());e.attributes.pen&&(f.penPoint=e.attributes.pen);e.attributes.collabId&&(f.id=e.attributes.collabId);e.attributes.volume&&(f.volume=+e.attributes.volume);e.attributes.pan&&(f.pan=+e.attributes.pan);d.stage.add(f);b.sprites.add(f);f.scale=parseFloat(e.attributes.scale||"1");f.rotationStyle=parseFloat(e.attributes.rotation||"1");f.isDraggable="false"!==e.attributes.draggable;f.isVisible="true"!==e.attributes.hidden;f.heading=parseFloat(e.attributes.heading)|| -0;f.gotoXY(+e.attributes.x||0,+e.attributes.y||0);c.loadObject(f,e);SnapActions.loadOwner(f);f.fixLayout()});d.stage.children.forEach(function(e){var f;e.inheritanceInfo&&(f=d.sprites[e.inheritanceInfo.exemplar])&&e.setExemplar(f);e.nestingInfo&&((f=d.sprites[e.nestingInfo.anchor])&&f.attachPart(e),e.rotatesWithAnchor="true"===e.nestingInfo.synch)});d.stage.children.forEach(function(e){delete e.inheritanceInfo;e.nestingInfo&&(e.nestingScale=+(e.nestingInfo.scale||e.scale),delete e.nestingInfo)}); -this.objects={};this.project={};this.mediaDict={};b.stage.fixLayout();b.stage.rerender();b.createCorral();b.fixLayout();return d.stage.children};SnapSerializer.prototype.loadMedia=function(a){return this.loadMediaModel(this.parse(a))};SnapSerializer.prototype.loadMediaModel=function(a){var b=this;this.mediaDict={};if(+a.attributes.version>this.version)throw"Module uses newer version of Serializer";a.children.forEach(function(c){return b.loadValue(c)});return this.mediaDict}; +SnapSerializer.prototype.loadBlocks=function(a,b){var c=new StageMorph;this.project={stage:c,sprites:{},targetStage:b};a=this.parse(a);if(+a.attributes.version>this.version)throw"Module uses newer version of Serializer";this.loadCustomBlocks(c,a,!0);this.populateCustomBlocks(c,a,!0);this.objects={};c.globalBlocks.forEach(d=>d.receiver=null);this.objects={};this.project={};this.mediaDict={};return c.globalBlocks}; +SnapSerializer.prototype.loadSprites=function(a,b){var c=this.project={globalVariables:b.globalVariables,stage:b.stage,sprites:{}};c.sprites[c.stage.name]=c.stage;a=this.parse(a);if(+a.attributes.version>this.version)throw"Module uses newer version of Serializer";a.childrenNamed("sprite").forEach(d=>{var e=new SpriteMorph(c.globalVariables);d.attributes.id&&(this.objects[d.attributes.id]=e);d.attributes.name&&(e.name=b.newSpriteName(d.attributes.name),c.sprites[e.name]=e);d.attributes.color&&(e.color= +this.loadColor(d.attributes.color),e.cachedHSV=e.color.hsv());d.attributes.pen&&(e.penPoint=d.attributes.pen);d.attributes.collabId&&(e.id=d.attributes.collabId);d.attributes.volume&&(e.volume=+d.attributes.volume);d.attributes.pan&&(e.pan=+d.attributes.pan);c.stage.add(e);b.sprites.add(e);e.scale=parseFloat(d.attributes.scale||"1");e.rotationStyle=parseFloat(d.attributes.rotation||"1");e.isDraggable="false"!==d.attributes.draggable;e.isVisible="true"!==d.attributes.hidden;e.heading=parseFloat(d.attributes.heading)|| +0;e.gotoXY(+d.attributes.x||0,+d.attributes.y||0);this.loadObject(e,d);SnapActions.loadOwner(e);e.fixLayout()});c.stage.children.forEach(d=>{var e;d.inheritanceInfo&&(e=c.sprites[d.inheritanceInfo.exemplar])&&d.setExemplar(e);d.nestingInfo&&((e=c.sprites[d.nestingInfo.anchor])&&e.attachPart(d),d.rotatesWithAnchor="true"===d.nestingInfo.synch)});c.stage.children.forEach(d=>{delete d.inheritanceInfo;d.nestingInfo&&(d.nestingScale=+(d.nestingInfo.scale||d.scale),delete d.nestingInfo)});this.objects= +{};this.project={};this.mediaDict={};b.stage.fixLayout();b.stage.rerender();b.createCorral();b.fixLayout();return c.stage.children};SnapSerializer.prototype.loadMedia=function(a){return this.loadMediaModel(this.parse(a))};SnapSerializer.prototype.loadMediaModel=function(a){this.mediaDict={};if(+a.attributes.version>this.version)throw"Module uses newer version of Serializer";a.children.forEach(b=>this.loadValue(b));return this.mediaDict}; SnapSerializer.prototype.loadObject=function(a,b){var c=b.require("blocks"),d=b.childNamed("dispatches"),e;b.attributes.instrument&&(a.instrument=+b.attributes.instrument);this.loadInheritanceInfo(a,b);this.loadNestingInfo(a,b);if(e=b.childNamed("wear"))if(e=e.childNamed("costume")||e.childNamed("ref")){var f=this.loadValue(e,a);f.loaded?a.wearCostume(f,!0):f.loaded=function(){this.loaded=!0;a.wearCostume(f,!0)}}else console.log(a.name+": missing costume to wear");a.inheritanceInfo&&a.inheritanceInfo.delegated instanceof Array&&contains(a.inheritanceInfo.delegated,"costumes")||this.loadCostumes(a,b);a.inheritanceInfo&&a.inheritanceInfo.delegated instanceof Array&&contains(a.inheritanceInfo.delegated,"sounds")||this.loadSounds(a,b);this.loadCustomBlocks(a,c);d&&this.loadCustomBlocks(a,d,!1,!0);this.populateCustomBlocks(a,c);this.loadVariables(a.variables,b.require("variables"),a);a.inheritanceInfo&&a.inheritanceInfo.delegated instanceof Array&&contains(a.inheritanceInfo.delegated,"scripts")||this.loadScripts(a,a.scripts, b.require("scripts"))};SnapSerializer.prototype.loadInheritanceInfo=function(a,b){var c=b.childNamed("inherit");if(c){a.inheritanceInfo=c.attributes;if(c=c.childNamed("list"))a.inheritanceInfo.delegated=this.loadValue(c).asArray();a.inheritanceInfo.costumeNumber=b.attributes.costume}};SnapSerializer.prototype.loadNestingInfo=function(a,b){if(b=b.childNamed("nest"))a.nestingInfo=b.attributes}; SnapSerializer.prototype.loadCostumes=function(a,b){var c=b.childNamed("costumes"),d;c&&(a.costumes=this.loadValue(c.require("list",function(){console.log(a.name+": missing required costumes list, improvising...");return new XML_Element("list")})),a.costumes.type="costume");Object.prototype.hasOwnProperty.call(b.attributes,"costume")&&(d=a.costumes.asArray()[b.attributes.costume-1])&&(d.loaded?a.wearCostume(d,!0):d.loaded=function(){this.loaded=!0;a.wearCostume(d,!0)})}; SnapSerializer.prototype.loadSounds=function(a,b){if(b=b.childNamed("sounds"))a.sounds=this.loadValue(b.require("list",function(){console.log(a.name+": missing required sounds list, improvising...");return new XML_Element("list")})),a.sounds.type="sound"}; -SnapSerializer.prototype.loadVariables=function(a,b,c){var d=this;b.children.forEach(function(e){if("variable"===e.tag){var f=e.children[0];var g=new Variable;g.isTransient="true"===e.attributes.transient;g.value=g.isTransient||!f?0:d.loadValue(f,c);a.vars[e.attributes.name]=g}})}; -SnapSerializer.prototype.loadCustomBlock=function(a,b){var c=new CustomBlockDefinition(a.attributes.s||"");c.category=a.attributes.category||"other";c.type=a.attributes.type||"command";c.isGlobal=!0===b;c.id=a.attributes.collabId;var d=c.parseSpec(c.spec).filter(function(f){return"%"===f.charAt(0)&&1{if("variable"===d.tag){var e=d.children[0];var f=new Variable;f.isTransient="true"===d.attributes.transient;f.value=f.isTransient||!e?0:this.loadValue(e,c);a.vars[d.attributes.name]=f}})}; +SnapSerializer.prototype.loadCustomBlock=function(a,b){var c=new CustomBlockDefinition(a.attributes.s||"");c.category=a.attributes.category||"other";c.type=a.attributes.type||"command";c.isGlobal=!0===b;c.id=a.attributes.collabId;var d=c.parseSpec(c.spec).filter(f=>"%"===f.charAt(0)&&1f.substr(1));c.names=d;if(b=a.childNamed("inputs")){var e=-1;b.children.forEach(function(f){var g=f.childNamed("options");"input"===f.tag&&(e+=1,c.declarations.set(d[e],[f.attributes.type,contains(["%b", +"%boolUE"],f.attributes.type)?f.contents?"true"===f.contents:null:f.contents,g?g.contents:void 0,"true"===f.attributes.readonly]))})}if(b=a.childNamed("variables"))c.variableNames=this.loadValue(b.require("list")).asArray();if(b=a.childNamed("header"))c.codeHeader=b.contents;if(b=a.childNamed("code"))c.codeMapping=b.contents;(b=a.childNamed("translations"))&&c.updateTranslations(b.contents);if(a=a.childNamed("comment"))c.comment=this.loadComment(a);return c}; +SnapSerializer.prototype.loadCustomBlocks=function(a,b,c,d){b.children.forEach(e=>{"block-definition"===e.tag&&(e=this.loadCustomBlock(e,c),e.receiver=a,d?a.inheritedMethodsCache.push(e):e.isGlobal?a.globalBlocks.push(e):a.customBlocks.push(e))})}; +SnapSerializer.prototype.populateCustomBlocks=function(a,b,c){b.children.forEach((d,e)=>{var f;if("block-definition"===d.tag){e=c?a.globalBlocks[e]:a.customBlocks[e];if(f=d.childNamed("script"))e.body=new Context(null,f?this.loadScript(f,a):null,null,a),e.body.inputs=e.names.slice(0);if(d=d.childNamed("scripts"))e.scripts=this.loadScriptsArray(d,a);delete e.names}})}; +SnapSerializer.prototype.loadScripts=function(a,b,c){var d=SyntaxElementMorph.prototype.scale;b.cachedTexture=IDE_Morph.prototype.scriptsPaneTexture;c.children.forEach(e=>{var f;if("script"===e.tag){if(f=this.loadScript(e,a))f.setPosition((new Point((+e.attributes.x||0)*d,(+e.attributes.y||0)*d)).add(b.topLeft())),b.add(f),f.fixBlockColor(null,!0),f.allComments().forEach(g=>g.align(f))}else"comment"===e.tag&&(f=this.loadComment(e))&&(f.setPosition((new Point((+e.attributes.x||0)*d,(+e.attributes.y|| +0)*d)).add(b.topLeft())),b.add(f))})};SnapSerializer.prototype.loadScriptsArray=function(a,b){var c=SyntaxElementMorph.prototype.scale,d=[];a.children.forEach(e=>{var f;if("script"===e.tag){if(f=this.loadScript(e,b))f.setPosition(new Point((+e.attributes.x||0)*c,(+e.attributes.y||0)*c)),d.push(f),f.fixBlockColor(null,!0)}else"comment"===e.tag&&(f=this.loadComment(e))&&(f.setPosition(new Point((+e.attributes.x||0)*c,(+e.attributes.y||0)*c)),d.push(f))});return d}; +SnapSerializer.prototype.loadScript=function(a,b){var c,d,e;this.project.stage||(this.project.stage=b.parentThatIsA(StageMorph),this.project.targetStage=this.project.stage);a.children.forEach(f=>{if(e=this.loadBlock(f,!1,b)){if(d)if(d.nextBlock&&e instanceof CommandBlockMorph)d.nextBlock(e);else return console.log("SNAP: expecting a command but getting a reporter:\n "+d.blockSpec+"\n "+e.blockSpec),c;else c=e;d=e}});return c}; SnapSerializer.prototype.loadComment=function(a){var b=new CommentMorph(a.contents),c=SyntaxElementMorph.prototype.scale;b.isCollapsed="true"===a.attributes.collapsed;b.setTextWidth(+a.attributes.w*c);b.id=a.attributes.collabId;return b}; -SnapSerializer.prototype.loadBlock=function(a,b,c){var d=this,e,f=0;if("block"===a.tag){if(Object.prototype.hasOwnProperty.call(a.attributes,"var")){var g=SpriteMorph.prototype.variableBlock(a.attributes["var"]);g.id=a.attributes.collabId;return g}g=SpriteMorph.prototype.blockForSelector(a.attributes.s);if(e=SpriteMorph.prototype.blockMigrations[a.attributes.s])f=e.offset}else if("custom-block"===a.tag){var h=(e=a.attributes.scope?!1:!0)?this.project.stage:c;var k=a.childNamed("receiver");k&&k.children[0]&& -"project"!==k.children[0].tag&&(h=this.loadValue(a.childNamed("receiver").children[0]));if(!h){if(e)return g=this.obsoleteBlock(b),g.id=a.attributes.collabId,g;h=this.project.stage}e?(e=detect(h.globalBlocks,function(r){return r.blockSpec()===a.attributes.s}),!e&&this.project.targetStage&&(e=detect(this.project.targetStage.globalBlocks,function(r){return r.blockSpec()===a.attributes.s}))):e=detect(h.customBlocks,function(r){return r.blockSpec()===a.attributes.s})||(h.inheritedMethodsCache?detect(h.inheritedMethodsCache, -function(r){return r.blockSpec()===a.attributes.s}):null);if(!e||!contains(SpriteMorph.prototype.categories,e.category))return g=this.obsoleteBlock(b),g.id=a.attributes.collabId,g;g="command"===e.type?new CustomCommandBlockMorph(e,!1):new CustomReporterBlockMorph(e,"predicate"===e.type,!1)}null===g&&(g=this.obsoleteBlock(b));g.isDraggable=!0;g.id=a.attributes.collabId;var l=g.inputs();e=a.children.filter(function(r){return"comment"!==r.tag}).length;h=l.length;if(hp.blockSpec()===a.attributes.s),!d&&this.project.targetStage&&(d=detect(this.project.targetStage.globalBlocks,p=>p.blockSpec()===a.attributes.s))):d=detect(g.customBlocks,p=>p.blockSpec()===a.attributes.s)||(g.inheritedMethodsCache?detect(g.inheritedMethodsCache,p=>p.blockSpec()===a.attributes.s): +null);if(!d||!contains(SpriteMorph.prototype.categories,d.category))return f=this.obsoleteBlock(b),f.id=a.attributes.collabId,f;f="command"===d.type?new CustomCommandBlockMorph(d,!1):new CustomReporterBlockMorph(d,"predicate"===d.type,!1)}null===f&&(f=this.obsoleteBlock(b));f.isDraggable=!0;f.id=a.attributes.collabId;var h=f.inputs();d=a.children.filter(n=>"comment"!==n.tag).length;g=h.length;if(g{"variables"===n.tag?this.loadVariables(f.variables,n,c):"comment"===n.tag?(f.comment=this.loadComment(n),f.comment.block=f):"receiver"===n.tag?nop():this.loadInput(n,h[p+e],f,c)});f.cachedInputs=null;k&&m&&(k instanceof MessageInputSlotMorph?(b=this.project.stage.messageTypes.getMsgType(m[0]), +k.setContents(m[0],m.slice(1),b)):k.setContents(m[0],m.slice(1)));return f};SnapSerializer.prototype.obsoleteBlock=function(a){a=a?new ReporterBlockMorph:new CommandBlockMorph;a.selector="errorObsolete";a.color=new Color(200,0,20);a.setSpec("Obsolete!");a.isDraggable=!0;return a}; +SnapSerializer.prototype.loadInput=function(a,b,c,d){if(!isNil(b))if("script"===a.tag){if(a=this.loadScript(a,d))"reifyReporter"===c.selector||"reifyPredicate"===c.selector?b.replaceInput(b.children[0],a):b.add(a),b.fixLayout()}else if("autolambda"===a.tag&&a.children[0]){if(a=this.loadBlock(a.children[0],!0,d))b.replaceInput(b.children[0],a),b.fixLayout()}else if("list"===a.tag){for(;0{b.addInput();this.loadInput(e,b.children[b.children.length- 2],b,d)});b.fixLayout()}else"block"===a.tag||"custom-block"===a.tag?c.replaceInput(b,this.loadBlock(a,!0,d)):"color"===a.tag?b.setColor(this.loadColor(a.contents)):(c=this.loadValue(a),isNil(c)||isNil(b)||!b.setContents||(b instanceof MessageInputSlotMorph?(a=this.loadValue(a),c=this.project.stage.messageTypes.getMsgType(a),b.setContents(a,null,c)):b.setContents(this.loadValue(a))))}; -SnapSerializer.prototype.loadValue=function(a,b){function c(){Object.prototype.hasOwnProperty.call(a.attributes,"id")&&(g.objects[a.attributes.id]=h);Object.prototype.hasOwnProperty.call(a.attributes,"mediaID")&&(g.mediaDict[a.attributes.mediaID]=h)}var d=this,e,f,g=this;switch(a.tag){case "ref":if(Object.prototype.hasOwnProperty.call(a.attributes,"id"))return this.objects[a.attributes.id];if(Object.prototype.hasOwnProperty.call(a.attributes,"mediaID"))return this.mediaDict[a.attributes.mediaID]; -if(Object.prototype.hasOwnProperty.call(a.attributes,"actionID"))return SnapActions.getOwnerFromId(a.attributes.actionID);throw Error("expecting a reference id");case "l":return(e=a.childNamed("option"))?[e.contents]:(f=a.childNamed("bool"))?this.loadValue(f):(e=a.childNamed("wish"))?this.loadValue(e):a.contents;case "bool":return"true"===a.contents;case "list":if(a.attributes.hasOwnProperty("linked")){if("atomic"===a.attributes.struct){var h=Process.prototype.parseCSV(a.contents);h.becomeLinked(); -c();return h}h=new List;h.isLinked=!0;c();e=h;var k=a.childrenNamed("item");k.forEach(function(p,r){p=p.children[0];h.first=p?d.loadValue(p,b):0;(p=a.childNamed("list")||a.childNamed("ref"))?h.rest=d.loadValue(p,b):r{n=n.children[0];g.first=n?this.loadValue(n,b):0;(n=a.childNamed("list")||a.childNamed("ref"))?g.rest=this.loadValue(n,b):p(n=n.children[0])?this.loadValue(n,b):0);return g;case "sprite":return g=new SpriteMorph(this.project.globalVariables),a.attributes.id&& +(this.objects[a.attributes.id]=g),a.attributes.name&&(g.name=a.attributes.name,this.project.sprites[a.attributes.name]=g),a.attributes.idx&&(g.idx=+a.attributes.idx),a.attributes.color&&(g.color=this.loadColor(a.attributes.color),g.cachedHSV=g.color.hsv()),a.attributes.pen&&(g.penPoint=a.attributes.pen),a.attributes.collabId&&(g.id=a.attributes.collabId),a.attributes.volume&&(g.volume=+a.attributes.volume),a.attributes.pan&&(g.pan=+a.attributes.pan),this.project.stage.add(g),g.scale=parseFloat(a.attributes.scale|| +"1"),g.rotationStyle=parseFloat(a.attributes.rotation||"1"),g.isDraggable="false"!==a.attributes.draggable,g.isVisible="true"!==a.attributes.hidden,g.heading=parseFloat(a.attributes.heading)||0,g.gotoXY(+a.attributes.x||0,+a.attributes.y||0),this.loadObject(g,a),this.loadHistory(a.childNamed("history")),g.fixLayout(),(d=a.childNamed("messageTypes"))&&d.children.forEach(n=>this.loadMessageType(this.project.stage,n)),g;case "context":g=new Context(null);c();if(d=a.childNamed("origin"))if(d=d.childNamed("ref")|| +d.childNamed("sprite"))g.origin=this.loadValue(d);if(d=a.childNamed("receiver"))if(d=d.childNamed("ref")||d.childNamed("sprite"))g.receiver=this.loadValue(d);var k=g.origin||g.receiver||b;if(d=a.childNamed("script"))g.expression=this.loadScript(d,k);else if(d=a.childNamed("block")||a.childNamed("custom-block"))g.expression=this.loadBlock(d,null,k);else if(d=a.childNamed("l"))e=d.childNamed("bool"),g.expression=e?new BooleanSlotMorph(this.loadValue(e)):new InputSlotMorph(d.contents);if(g.expression instanceof +BlockMorph){var l=0;g.expression.allEmptySlots().forEach(n=>{l+=1;n.bindingID=n instanceof MultiArgMorph?["arguments"]:l});g.emptySlots=l}(d=a.childNamed("inputs"))&&d.children.forEach(n=>{"input"===n.tag&&g.inputs.push(n.contents)});(d=a.childNamed("variables"))&&this.loadVariables(g.variables,d,k);if(d=a.childNamed("context"))g.outerContext=this.loadValue(d,k);g.outerContext&&g.receiver&&!g.outerContext.variables.parentFrame&&(g.outerContext.variables.parentFrame=g.receiver.variables);return g; +case "costume":d=new Point;Object.prototype.hasOwnProperty.call(a.attributes,"center-x")&&(d.x=parseFloat(a.attributes["center-x"]));Object.prototype.hasOwnProperty.call(a.attributes,"center-y")&&(d.y=parseFloat(a.attributes["center-y"]));Object.prototype.hasOwnProperty.call(a.attributes,"name")&&(e=a.attributes.name);if(Object.prototype.hasOwnProperty.call(a.attributes,"image")){var m=new Image;0!==a.attributes.image.indexOf("data:image/svg+xml")||MorphicPreferences.rasterizeSVGs?(g=new Costume(null, +e,d),m.onload=function(){var n=newCanvas(new Point(m.width,m.height),!0);n.getContext("2d").drawImage(m,0,0);g.contents=n;g.imageSrc=null;g.version=+new Date;"function"===typeof g.loaded?g.loaded():g.loaded=!0}):(g=new SVG_Costume(null,e,d),m.onload=function(){g.contents=m;g.imageSrc=null;g.version=+new Date;"function"===typeof g.loaded?g.loaded():g.loaded=!0});m.src=a.attributes.image;g.imageSrc=a.attributes.image}g.id=a.attributes.collabId;c();return g;case "sound":return d=new Audio,d.src=a.attributes.sound, +g=new Sound(d,a.attributes.name),Object.prototype.hasOwnProperty.call(a.attributes,"mediaID")&&(this.mediaDict[a.attributes.mediaID]=g),g.id=a.attributes.collabId,c(),g;case "wish":return d=new CustomBlockDefinition(a.attributes.s),d.type=a.attributes.type,d.category=a.attributes.category,d.storedSemanticSpec=a.attributes.s,d.updateTranslations(a.contents),d.blockInstance(!0)}}; SnapSerializer.prototype.loadColor=function(a){a=(a||"").split(",");return new Color(parseFloat(a[0]),parseFloat(a[1]),parseFloat(a[2]),parseFloat(a[3]))}; -SnapSerializer.prototype.openProject=function(a,b){var c=b.stage,d=[];if(a&&a.stage)return b.siblings().forEach(function(e){return e.destroy()}),b.projectName=a.name,b.projectNotes=a.notes||"",b.globalVariables&&(b.globalVariables=a.globalVariables),c&&c.destroy(),b.add(a.stage),b.stage=a.stage,d=b.stage.children.filter(function(e){return e instanceof SpriteMorph}),d.sort(function(e,f){return e.idx-f.idx}),b.sprites=new List(d),c=d[0]||a.stage,0"+XML_Element.prototype.escape(StageMorph.prototype[g][k])+""});return h}var c=normalizeCanvas(this.thumbnail(SnapSerializer.prototype.thumbnailSize),!0),d=this.getCostumeIdx(),e=this.parentThatIsA(IDE_Morph);if(!a.isSavingPortable){c=normalizeCanvas(this.thumbnail(SnapSerializer.prototype.thumbnailSize),!0);try{var f=c.toDataURL("image/png")}catch(g){f=null}}this.removeAllClones(); +SnapSerializer.prototype.openProject=function(a,b){var c=b.stage,d=[];if(a&&a.stage)return b.siblings().forEach(e=>e.destroy()),b.projectName=a.name,b.projectNotes=a.notes||"",b.globalVariables&&(b.globalVariables=a.globalVariables),c&&c.destroy(),b.add(a.stage),b.stage=a.stage,d=b.stage.children.filter(e=>e instanceof SpriteMorph),d.sort((e,f)=>e.idx-f.idx),b.sprites=new List(d),c=d[0]||a.stage,0b+a.store(c),"")}; +StageMorph.prototype.toXML=function(a){function b(g){var h="";Object.keys(StageMorph.prototype[g]).forEach(k=>{h+="<"+k+">"+XML_Element.prototype.escape(StageMorph.prototype[g][k])+""});return h}var c=normalizeCanvas(this.thumbnail(SnapSerializer.prototype.thumbnailSize),!0),d=this.getCostumeIdx(),e=this.parentThatIsA(IDE_Morph);if(!a.isSavingPortable){c=normalizeCanvas(this.thumbnail(SnapSerializer.prototype.thumbnailSize),!0);try{var f=c.toDataURL("image/png")}catch(g){f=null}}this.removeAllClones(); return a.format('$$$%%%%%%%\x3c/scripts>%$%%%%%%', SnapActions.lastSeen,e&&e.projectName?e.projectName:localize("Untitled"),a.app,a.version,e&&e.projectNotes?e.projectNotes:"",f,this.name,StageMorph.prototype.dimensions.x,StageMorph.prototype.dimensions.y,this.id,d,this.color.r,this.color.g,this.color.b,this.color.a,this.getTempo(),this.isThreadSafe,this.enablePenLogging,this.instrument?' instrument="'+parseInt(this.instrument)+'" ':"",this.volume,this.pan,SpriteMorph.prototype.useFlatLineEnds?"flat":"round",BooleanSlotMorph.prototype.isTernary,!0=== -Process.prototype.enableHyperOps,this.enableCodeMapping,this.enableInheritance,this.enableSublistIDs,0!==StageMorph.prototype.frameRate,normalizeCanvas(this.trailsCanvas,!0).toDataURL("image/png"),!d&&this.costume?""+a.store(this.costume)+"":"",a.store(this.costumes,this.name+"_cst"),a.store(this.sounds,this.name+"_snd"),a.store(this.variables),a.store(this.customBlocks),a.store(this.messageTypes),a.store(this.scripts),a.store(this.children),Object.keys(StageMorph.prototype.hiddenPrimitives).reduce(function(g, -h){return g+" "+h},""),b("codeHeaders"),b("codeMappings"),a.store(this.globalBlocks),e&&e.globalVariables?a.store(e.globalVariables):"",a.isSavingHistory?a.historyXML(this.id):"",a.isSavingHistory?a.replayHistory():"")}; +Process.prototype.enableHyperOps,this.enableCodeMapping,this.enableInheritance,this.enableSublistIDs,0!==StageMorph.prototype.frameRate,normalizeCanvas(this.trailsCanvas,!0).toDataURL("image/png"),!d&&this.costume?""+a.store(this.costume)+"":"",a.store(this.costumes,this.name+"_cst"),a.store(this.sounds,this.name+"_snd"),a.store(this.variables),a.store(this.customBlocks),a.store(this.messageTypes),a.store(this.scripts),a.store(this.children),Object.keys(StageMorph.prototype.hiddenPrimitives).reduce((g, +h)=>g+" "+h,""),b("codeHeaders"),b("codeMappings"),a.store(this.globalBlocks),e&&e.globalVariables?a.store(e.globalVariables):"",a.isSavingHistory?a.historyXML(this.id):"",a.isSavingHistory?a.replayHistory():"")}; StageMorph.prototype.toPortableXML=function(a,b){function c(f){var g="";Object.keys(StageMorph.prototype[f]).forEach(function(h){g+="<"+h+">"+XML_Element.prototype.escape(StageMorph.prototype[f][h])+""});return g}b=this.parentThatIsA(IDE_Morph);var d=this.customBlocks,e=this.globalBlocks;a.dependencies&&(d=d.filter(function(f){return a.dependencies.customBlocks.includes(f)}),e=e.filter(function(f){return a.dependencies.customBlocks.includes(f)}));this.removeAllClones();return a.format('$$$%%%%%%\x3c/scripts>%$%%%%%%', SnapActions.lastSeen,b&&b.projectName?b.projectName:localize("Untitled"),a.app,a.version,b&&b.projectNotes?b.projectNotes:"","",this.name,StageMorph.prototype.dimensions.x,StageMorph.prototype.dimensions.y,this.id,this.getCostumeIdx(),this.getTempo(),this.isThreadSafe,SpriteMorph.prototype.useFlatLineEnds?"flat":"round",this.enableCodeMapping,this.enableInheritance,this.enableSublistIDs,0!==StageMorph.prototype.frameRate,"",a.store(this.costumes,this.name+"_cst"),a.store(this.sounds,this.name+"_snd"), a.store(this.variables),a.store(d),a.store(this.messageTypes),a.dependencies?"":a.store(this.scripts),a.store(this.children),Object.keys(StageMorph.prototype.hiddenPrimitives).reduce(function(f,g){return f+" "+g},""),c("codeHeaders"),c("codeMappings"),a.store(e),b&&b.globalVariables?a.store(b.globalVariables):"","","")}; @@ -2929,52 +2831,52 @@ SpriteMorph.prototype.toXML=function(a){var b=this.parentThatIsA(StageMorph);b=( (e?"%":"%")+"%%"+(this.exemplar?"%":"%")+(f?"%":"%\x3c/scripts>")+"%",this.name,this.id,b,this.xPosition(),this.yPosition(),this.heading,this.scale,this.volume,this.pan,this.rotationStyle,this.instrument?' instrument="'+parseInt(this.instrument)+'" ':"",this.isDraggable,this.isVisible?"":' hidden="true"',c,this.color.r,this.color.g,this.color.b,this.color.a,this.penPoint,this.exemplar? ''+(this.inheritedAttributes.length?a.store(new List(this.inheritedAttributes)):"")+"":"",this.anchor?'':"",!c&&this.costume?""+a.store(this.costume)+"":"",d?"":a.store(this.costumes,this.name+"_cst"),e?"":a.store(this.sounds,this.name+"_snd"),this.customBlocks?a.store(this.customBlocks):"",a.store(this.variables), this.exemplar?a.store(this.inheritedMethods()):"",f?"":a.store(this.scripts),a.isSavingHistory?a.historyXML(this.id):"")}; -SpriteMorph.prototype.toPortableXML=function(a){var b=this.parentThatIsA(StageMorph);b=(b=b?b.parentThatIsA(IDE_Morph):null)?b.sprites.asArray().indexOf(this)+1:0;var c=this.customBlocks||[],d=new MessageFrame;a.dependencies&&(c=c.filter(function(e){return a.dependencies.customBlocks.includes(e)}),a.dependencies.messageTypes.forEach(function(e){return d.addMsgType(e)}));return a.format('%%%%%%%%\x3c/scripts>',this.name, +SpriteMorph.prototype.toPortableXML=function(a){var b=this.parentThatIsA(StageMorph);b=(b=b?b.parentThatIsA(IDE_Morph):null)?b.sprites.asArray().indexOf(this)+1:0;var c=this.customBlocks||[],d=new MessageFrame;a.dependencies&&(c=c.filter(function(e){return a.dependencies.customBlocks.includes(e)}),a.dependencies.messageTypes.forEach(e=>d.addMsgType(e)));return a.format('%%%%%%%%\x3c/scripts>',this.name, this.id,b,this.xPosition(),this.yPosition(),this.heading,this.scale,this.rotationStyle,this.isDraggable,this.isVisible?"":' hidden="true"',this.getCostumeIdx(),this.color.r,this.color.g,this.color.b,this.penPoint,this.exemplar?'':"",this.anchor?'':"",a.dependencies?a.store(new List):a.store(this.costumes,this.name+"_cst"), a.store(this.sounds,this.name+"_snd"),a.store(this.variables),a.store(d),this.customBlocks?a.store(c):"",a.dependencies?"":a.store(this.scripts))};Costume.prototype[XML_Serializer.prototype.mediaDetectionProperty]=!0; -Costume.prototype.toXML=function(a){var b=this.imageSrc;b||(b=this instanceof SVG_Costume?this.contents.src:normalizeCanvas(this.contents).toDataURL("image/png"));return a.format('',this.name,this.id,this.rotationCenter.x,this.rotationCenter.y,b)};Sound.prototype[XML_Serializer.prototype.mediaDetectionProperty]=!0;Sound.prototype.toXML=function(a){return a.format('',this.id,this.name,this.toDataURL())}; -VariableFrame.prototype.toXML=function(a){var b=this;return Object.keys(this.vars).reduce(function(c,d){var e=b.vars[d].value;d=b.vars[d].isTransient?a.format('',d):void 0===e||null===e?a.format('',d):a.format('%',d,"object"===typeof e?isSnapObject(e)?"":a.store(e):"boolean"===typeof e?a.format("$",e):a.format("$",e));return c+d},"")}; -VariableFrame.prototype.toPortableXML=function(a){var b=this,c=Object.keys(this.vars);a.dependencies&&(c=c.filter(function(d){return a.dependencies.variables.includes(d)}));return c.reduce(function(d,e){var f=b.vars[e].value;e=b.vars[e].isTransient?a.format('',e):void 0===f||null===f?a.format('',e):a.format('%',e,"object"===typeof f?isSnapObject(f)?"":a.store(f):"boolean"===typeof f?a.format("$",f): -a.format("$",f));return d+e},"")}; +Costume.prototype.toXML=function(a){var b=this.imageSrc;b||=this instanceof SVG_Costume?this.contents.src:normalizeCanvas(this.contents).toDataURL("image/png");return a.format('',this.name,this.id,this.rotationCenter.x,this.rotationCenter.y,b)};Sound.prototype[XML_Serializer.prototype.mediaDetectionProperty]=!0;Sound.prototype.toXML=function(a){return a.format('',this.id,this.name,this.toDataURL())}; +VariableFrame.prototype.toXML=function(a){return Object.keys(this.vars).reduce((b,c)=>{var d=this.vars[c].value;c=this.vars[c].isTransient?a.format('',c):void 0===d||null===d?a.format('',c):a.format('%',c,"object"===typeof d?isSnapObject(d)?"":a.store(d):"boolean"===typeof d?a.format("$",d):a.format("$",d));return b+c},"")}; +VariableFrame.prototype.toPortableXML=function(a){var b=this,c=Object.keys(this.vars);a.dependencies&&(c=c.filter(d=>a.dependencies.variables.includes(d)));return c.reduce(function(d,e){var f=b.vars[e].value;e=b.vars[e].isTransient?a.format('',e):void 0===f||null===f?a.format('',e):a.format('%',e,"object"===typeof f?isSnapObject(f)?"":a.store(f):"boolean"===typeof f?a.format("$",f):a.format("$", +f));return d+e},"")}; WatcherMorph.prototype.toXML=function(a){var b=this.target instanceof VariableFrame,c=this.currentValue instanceof List,d=this.readoutColor,e=this.parent?this.topLeft().subtract(this.parent.topLeft()):this.topLeft();return this.isTemporary()?"":a.format('',b&&this.target.owner||!b&&this.target?a.format(' scope="@"',b?this.target.owner.name:this.target.name):"",a.format(b?'var="@"':'s="@"',this.getter),this.style,b&&"slider"===this.style?a.format(' min="@" max="@"', -this.sliderMorph.start,this.sliderMorph.stop):"",e.x,e.y,d.r,d.g,d.b,c?a.format(' extX="@" extY="@"',this.cellMorph.contentsMorph.width(),this.cellMorph.contentsMorph.height()):"",this.isVisible?"":' hidden="true"')};ScriptsMorph.prototype.toXML=function(a){return this.children.reduce(function(b,c){return c instanceof BlockMorph?b+c.toScriptXML(a,!0):c instanceof CommentMorph&&!c.block?b+c.toXML(a):b},"")}; +this.sliderMorph.start,this.sliderMorph.stop):"",e.x,e.y,d.r,d.g,d.b,c?a.format(' extX="@" extY="@"',this.cellMorph.contentsMorph.width(),this.cellMorph.contentsMorph.height()):"",this.isVisible?"":' hidden="true"')};ScriptsMorph.prototype.toXML=function(a){return this.children.reduce((b,c)=>c instanceof BlockMorph?b+c.toScriptXML(a,!0):c instanceof CommentMorph&&!c.block?b+c.toXML(a):b,"")}; BlockMorph.prototype.toXML=BlockMorph.prototype.toScriptXML=function(a,b){var c=SyntaxElementMorph.prototype.scale,d=this;var e=this.parent?this.topLeft().subtract(this.parent.topLeft()):this.topLeft();b=b?a.format(' {{ } else { }} - + {{ } }}