/*

 Copyright The Closure Library Authors.
 Copyright The Closure Compiler Authors.
 SPDX-License-Identifier: Apache-2.0
*/
var COMPILED=!0,goog=goog||{};goog.global=this||self;goog.exportPath_=function(d,e,h,k){d=d.split(".");k=k||goog.global;d[0]in k||"undefined"==typeof k.execScript||k.execScript("var "+d[0]);for(var m;d.length&&(m=d.shift());)if(d.length||void 0===e)k=k[m]&&k[m]!==Object.prototype[m]?k[m]:k[m]={};else if(!h&&goog.isObject_(e)&&goog.isObject_(k[m]))for(var p in e)e.hasOwnProperty(p)&&(k[m][p]=e[p]);else k[m]=e};
goog.define=function(d,e){if(!COMPILED){var h=goog.global.CLOSURE_DEFINES;h&&void 0===h.nodeType&&Object.prototype.hasOwnProperty.call(h,d)&&(e=h[d])}return e};goog.FEATURESET_YEAR=2012;goog.DEBUG=!0;goog.LOCALE="en";goog.DISALLOW_TEST_ONLY_CODE=COMPILED&&!goog.DEBUG;goog.provide=function(d){if(goog.isInModuleLoader_())throw Error("goog.provide cannot be used within a module.");if(!COMPILED&&goog.isProvided_(d))throw Error('Namespace "'+d+'" already declared.');goog.constructNamespace_(d)};
goog.constructNamespace_=function(d,e,h){if(!COMPILED){delete goog.implicitNamespaces_[d];for(var k=d;(k=k.substring(0,k.lastIndexOf(".")))&&!goog.getObjectByName(k);)goog.implicitNamespaces_[k]=!0}goog.exportPath_(d,e,h)};goog.VALID_MODULE_RE_=/^[a-zA-Z_$][a-zA-Z0-9._$]*$/;
goog.module=function(d){if("string"!==typeof d||!d||-1==d.search(goog.VALID_MODULE_RE_))throw Error("Invalid module identifier");if(!goog.isInModuleLoader_())throw Error("Module "+d+" has been loaded incorrectly. Note, modules cannot be loaded as normal scripts. They require some kind of pre-processing step. You're likely trying to load a module via a script tag or as a part of a concatenated bundle without rewriting the module. For more info see: https://github.com/google/closure-library/wiki/goog.module:-an-ES6-module-like-alternative-to-goog.provide.");if(goog.moduleLoaderState_.moduleName)throw Error("goog.module may only be called once per module.");
goog.moduleLoaderState_.moduleName=d;if(!COMPILED){if(goog.isProvided_(d))throw Error('Namespace "'+d+'" already declared.');delete goog.implicitNamespaces_[d]}};goog.module.get=function(d){return goog.module.getInternal_(d)};goog.module.getInternal_=function(d){if(!COMPILED){if(d in goog.loadedModules_)return goog.loadedModules_[d];if(!goog.implicitNamespaces_[d])return d=goog.getObjectByName(d),null!=d?d:null}return null};goog.moduleLoaderState_=null;goog.isInModuleLoader_=function(){return!!goog.moduleLoaderState_};
goog.module.declareLegacyNamespace=function(){if(!COMPILED&&!goog.isInModuleLoader_())throw Error("goog.module.declareLegacyNamespace must be called from within a goog.module");if(!COMPILED&&!goog.moduleLoaderState_.moduleName)throw Error("goog.module must be called prior to goog.module.declareLegacyNamespace.");goog.moduleLoaderState_.declareLegacyNamespace=!0};goog.declareModuleId=function(d){if(!COMPILED)throw Error("goog.declareModuleId is not supported in uncompiled mode");};
goog.setTestOnly=function(d){if(goog.DISALLOW_TEST_ONLY_CODE)throw d=d||"",Error("Importing test-only code into non-debug environment"+(d?": "+d:"."));};goog.forwardDeclare=function(d){};COMPILED||(goog.isProvided_=function(d){return d in goog.loadedModules_||!goog.implicitNamespaces_[d]&&null!=goog.getObjectByName(d)},goog.implicitNamespaces_={"goog.module":!0});goog.getObjectByName=function(d,e){d=d.split(".");e=e||goog.global;for(var h=0;h<d.length;h++)if(e=e[d[h]],null==e)return null;return e};
goog.require=function(d){if(!COMPILED)return goog.isProvided_(d)?goog.module.getInternal_(d):null};goog.requireType=function(d){return{}};goog.SEAL_MODULE_EXPORTS=goog.DEBUG;goog.loadedModules_={};
goog.loadModule=function(d){var e=goog.moduleLoaderState_;try{goog.moduleLoaderState_={moduleName:"",declareLegacyNamespace:!1};var h={},k=h;if("function"===typeof d)k=d.call(void 0,k);else throw Error("Invalid module definition");var m=goog.moduleLoaderState_.moduleName;if("string"===typeof m&&m)goog.moduleLoaderState_.declareLegacyNamespace?goog.constructNamespace_(m,k,h!==k):goog.SEAL_MODULE_EXPORTS&&Object.seal&&"object"==typeof k&&null!=k&&Object.seal(k),goog.loadedModules_[m]=k;else throw Error('Invalid module name "'+
m+'"');}finally{goog.moduleLoaderState_=e}};goog.isObject_=function(d){var e=typeof d;return"object"==e&&null!=d||"function"==e};
goog.getCssName=function(d,e){if("."==String(d).charAt(0))throw Error('className passed in goog.getCssName must not start with ".". You passed: '+d);var h=function(m){return goog.cssNameMapping_[m]||m},k=function(m){m=m.split("-");for(var p=[],t=0;t<m.length;t++)p.push(h(m[t]));return p.join("-")};k=goog.cssNameMapping_?"BY_WHOLE"==goog.cssNameMappingStyle_?h:k:function(m){return m};d=e?d+"-"+k(e):k(d);return goog.global.CLOSURE_CSS_NAME_MAP_FN?goog.global.CLOSURE_CSS_NAME_MAP_FN(d):d};
goog.setCssNameMapping=function(d,e){goog.cssNameMapping_=d;goog.cssNameMappingStyle_=e};!COMPILED&&goog.global.CLOSURE_CSS_NAME_MAPPING&&(goog.cssNameMapping_=goog.global.CLOSURE_CSS_NAME_MAPPING);goog.GetMsgOptions=function(){};
goog.getMsg=function(d,e,h){h&&h.html&&(d=d.replace(/</g,"&lt;"));h&&h.unescapeHtmlEntities&&(d=d.replace(/&lt;/g,"<").replace(/&gt;/g,">").replace(/&apos;/g,"'").replace(/&quot;/g,'"').replace(/&amp;/g,"&"));e&&(d=d.replace(/\{\$([^}]+)}/g,function(k,m){return null!=e&&m in e?e[m]:k}));return d};goog.getMsgWithFallback=function(d,e){return d};goog.exportSymbol=function(d,e,h){goog.exportPath_(d,e,!0,h)};goog.exportProperty=function(d,e,h){d[e]=h};(function(d,e){"function"===typeof define&&define.amd?define([],e):"object"===typeof exports?module.exports=e():d.Blockly=e()})(this,function(){var d={};var e=function(a,b,f,g){if(!(a instanceof ba)&&"string"!==typeof a||""===`${a}`.trim())throw Error('Invalid type "'+a+'". The type must be a non-empty string or a Blockly.registry.Type.');a=`${a}`.toLowerCase();if("string"!==typeof b||""===b.trim())throw Error('Invalid name "'+b+'". The name must be a non-empty string.');const l=b.toLowerCase();if(!f)throw Error("Can not register a null value");
let n=lc[a],x=De[a];n||(n=lc[a]=Object.create(null),x=De[a]=Object.create(null));h(a,f);if(!g&&n[l]&&n[l]!==f)throw Error('Name "'+l+'" with type "'+a+'" already registered.');n[l]=f;x[l]=b};var h=function(a,b){switch(a){case String(ba.FIELD):if("function"!==typeof b.fromJson)throw Error('Type "'+a+'" must have a fromJson function');}};var k=function(a,b){a=`${a}`.toLowerCase();b=b.toLowerCase();const f=lc[a];f&&f[b]?(delete lc[a][b],delete De[a][b]):console.warn("Unable to unregister ["+b+"]["+a+
"] from the registry.")};var m=function(a,b,f){a=`${a}`.toLowerCase();b=b.toLowerCase();const g=lc[a];if(!g||!g[b]){b="Unable to find ["+b+"]["+a+"] in the registry.";if(f)throw Error(b+" You must require or register a "+a+" plugin.");console.warn(b);return null}return g[b]};var p=function(a,b){a=`${a}`.toLowerCase();b=b.toLowerCase();return(a=lc[a])?!!a[b]:!1};var t=function(a,b,f){return m(a,b,f)};var q=function(a,b,f){return m(a,b,f)};var y=function(a,b,f){a=`${a}`.toLowerCase();var g=lc[a];if(!g){g=
`Unable to find [${a}] in the registry.`;if(f)throw Error(`${g} You must require or register a ${a} plugin.`);console.warn(g);return null}if(!b)return g;a=De[a];f=Object.create(null);for(const l of Object.keys(g))f[a[l]]=g[l];return f};var I=function(a,b,f){b=b.plugins[String(a)]||Jb;return"function"===typeof b?b:t(a,b,f)};var L=function(a,b,f,g){a=a+" was deprecated in "+b+" and will be deleted in "+f+".";g&&(a+="\nUse "+g+" instead.");ii.has(a)||(ii.add(a),console.warn(a))};var Q=function(){return"blockly-"+
(ym++).toString(36)};var da=function(){return ji.genUid()};var N=function(a){return a.type===O.BLOCK_CREATE};var H=function(a){return a.type===O.BLOCK_DELETE};var K=function(a){return a.type===O.BLOCK_CHANGE};var C=function(a){return a.type===O.BLOCK_FIELD_INTERMEDIATE_CHANGE};var E=function(a){return a.type===O.BLOCK_MOVE};var F=function(a){return a.type===O.CLICK};var P=function(a){return a.type===O.BUBBLE_OPEN};var ha=function(a){return a.type===O.VIEWPORT_CHANGE};d.setRecordUndo$$module$build$src$core$events$utils=
function(a){Gd=a};var ea=function(){return Gd};var aa=function(a){ki.fireInternal(a)};var W=function(){const a=Z(Ub,!0);Ub.length=0;for(const b of a){if(!b.workspaceId)continue;let f;null==(f=ua(b.workspaceId))||f.fireChangeListener(b)}};var ka=function(a){if(K(a)&&"mutation"===a.element){let b;for(b=Ub.length;0<b;b--){const f=Ub[b-1];if(f.group!==a.group||f.workspaceId!==a.workspaceId||!E(f)||f.newParentId!==a.blockId)break}Ub.splice(b,0,a)}else Ub.push(a)};var Z=function(a,b=!0){b||(L("filter(queue, /*forward=*/false)",
"v11.2","v12"),a=a.slice().reverse());const f=[];for(const g of a)if(a=f[f.length-1],!g.isNull())if(a&&a.workspaceId===g.workspaceId&&a.group===g.group)if(E(g)&&E(a)&&g.blockId===a.blockId){if(a.newParentId=g.newParentId,a.newInputName=g.newInputName,a.newCoordinate=g.newCoordinate,a.reason||g.reason){let l,n;a.reason=Array.from(new Set((null!=(l=a.reason)?l:[]).concat(null!=(n=g.reason)?n:[])))}}else K(g)&&K(a)&&g.blockId===a.blockId&&g.element===a.element&&g.name===a.name?a.newValue=g.newValue:
ha(g)&&ha(a)?(a.viewTop=g.viewTop,a.viewLeft=g.viewLeft,a.scale=g.scale,a.oldScale=g.oldScale):F(g)&&P(a)||f.push(g);else f.push(g);a=f.filter(g=>!g.isNull());b||a.reverse();return a};var ca=function(){for(let a=0,b;b=Ub[a];a++)b.recordUndo=!1};d.disable$$module$build$src$core$events$utils=function(){Qf++};d.enable$$module$build$src$core$events$utils=function(){Qf--};var ia=function(){return 0===Qf};d.getGroup$$module$build$src$core$events$utils=function(){return li};d.setGroup$$module$build$src$core$events$utils=
function(a){ki.setGroupInternal(a)};var Da=function(a){const b=[];a=a.getDescendants(!1);for(let f=0,g;g=a[f];f++)b[f]=g.id;return b};var la=function(a){const b=t(ba.EVENT,a);if(!b)throw Error(`Event type ${a} not found in registry.`);return b};var ua=function(a){return Hd[a]||null};var va=function(){const a=[];for(const b in Hd)a.push(Hd[b]);return a};var u=function(a){Hd[a.id]=a};var w=function(a){delete Hd[a.id]};var z=function(){return mi};var M=function(a){mi=a};var U=function(){return Cc};d.setSelected$$module$build$src$core$common=
function(a){if(Cc!==a){var b,f,g,l,n,x,B=new (la(O.SELECTED))(null!=(g=null==(b=Cc)?void 0:b.id)?g:null,null!=(l=null==a?void 0:a.id)?l:null,null!=(x=null!=(n=null==a?void 0:a.workspace.id)?n:null==(f=Cc)?void 0:f.workspace.id)?x:"");aa(B);var V;null==(V=Cc)||V.unselect();Cc=a;var na;null==(na=Cc)||na.select()}};var r=function(){return ni};var v=function(a){ni=a};var A=function(a){for(;a.options.parentWorkspace;)a=a.options.parentWorkspace;const b=a.getParentSvg(),f=a.getCachedParentSvgSize();var g=
b.parentElement;if(g instanceof HTMLElement){var l=g.offsetWidth;g=g.offsetHeight;f.width!==l&&(b.setAttribute("width",l+"px"),a.setCachedParentSvgSize(l,null));f.height!==g&&(b.setAttribute("height",g+"px"),a.setCachedParentSvgSize(null,g));a.resize()}};var D=function(a,b){const f=Object.create(null),g=a.getDescendants(!0);b&&(a=a.getNextBlock())&&(a=g.indexOf(a),g.splice(a,g.length-a));for(let l=0,n;n=g[l];l++)f[n.type]?f[n.type]++:f[n.type]=1;return f};var S=function(a){return function(){this.jsonInit(a)}};
var ja=function(a){oi.defineBlocksWithJsonArrayInternal(a)};d.createBlockDefinitionsFromJsonArray$$module$build$src$core$common=function(a){const b={};for(let f=0;f<a.length;f++){const g=a[f];if(!g){console.warn(`Block definition #${f} in JSON array is ${g}. Skipping`);continue}const l=g.type;l?b[l]={init:S(g)}:console.warn(`Block definition #${f} in JSON array is missing a type attribute. `+"Skipping.")}return b};d.defineBlocks$$module$build$src$core$common=function(a){for(const b of Object.keys(a)){const f=
a[b];b in hb&&console.warn(`Block definition "${b}" overwrites previous definition.`);hb[b]=f}};var ra=function(a,b){wa();Ee=setTimeout(function(){b&&b.handleRightClick(a)},zm)};var wa=function(){Ee&&(clearTimeout(Ee),Ee=0)};var Ea=function(){Fe=null};var ub=function(a){return!a.type.startsWith("pointer")||a instanceof PointerEvent&&pi(a)};var Id=function(a){return`${a.pointerId}`};var pi=function(a){const b=Id(a);return Fe?Fe===b:"pointerdown"===a.type?(Fe=b,!0):!1};var ta=function(a,b,f,g,l){function n(B){if(l||
ub(B))f?g.call(f,B):g(B)}const x=[];if(b in Dc)for(let B=0;B<Dc[b].length;B++){const V=Dc[b][B];a.addEventListener(V,n,!1);x.push([a,V,n])}else a.addEventListener(b,n,!1),x.push([a,b,n]);return x};var lb=function(a,b,f,g){function l(x){f?g.call(f,x):g(x)}const n=[];if(b in Dc)for(let x=0;x<Dc[b].length;x++){const B=Dc[b][x];a.addEventListener(B,l,!1);n.push([a,B,l])}else a.addEventListener(b,l,!1),n.push([a,b,l]);return n};var Na=function(a){const b=a[a.length-1][2];for(;a.length;){const [f,g,l]=
a.pop();f.removeEventListener(g,l,!1)}return b};var Jd=function(a){if(a.target instanceof HTMLElement){if(a.target.isContentEditable||"true"===a.target.getAttribute("data-is-text-input"))return!0;if(a.target instanceof HTMLInputElement)return a=a.target,"text"===a.type||"number"===a.type||"email"===a.type||"password"===a.type||"search"===a.type||"tel"===a.type||"url"===a.type;if(a.target instanceof HTMLTextAreaElement)return!0}return!1};var Vb=function(a){return a.ctrlKey&&Rf?!0:2===a.button};var Kd=
function(a,b,f){const g=b.createSVGPoint();g.x=a.clientX;g.y=a.clientY;f||=b.getScreenCTM().inverse();return g.matrixTransform(f)};var Ge=function(a){switch(a.deltaMode){default:return{x:a.deltaX,y:a.deltaY};case 1:return{x:a.deltaX*qi,y:a.deltaY*qi};case 2:return{x:a.deltaX*ri,y:a.deltaY*ri}}};var mb=function(a,b){b=a.indexOf(b);if(-1===b)return!1;a.splice(b,1);return!0};var mc=function(a){if(Sf)throw Error("CSS already injected");Tf+="\n"+a};var si=function(a,b){Sf||(Sf=!0,a&&(a=b.replace(/[\\/]$/,
""),b=Tf.replace(/<<<PATH>>>/g,a),Tf="",a=document.createElement("style"),a.id="blockly-common-style",b=document.createTextNode(b),a.appendChild(b),document.head.insertBefore(a,document.head.firstChild)))};var T=function(a,b,f){a=document.createElementNS(Ld,`${a}`);for(const g in b)a.setAttribute(g,`${b[g]}`);f&&f.appendChild(a);return a};var sa=function(a,b){b=b.split(" ");if(b.every(f=>a.classList.contains(f)))return!1;a.classList.add(...b);return!0};var Uf=function(a,b){a.classList.remove(...b.split(" "))};
var Ma=function(a,b){b=b.split(" ");if(b.every(f=>!a.classList.contains(f)))return!1;a.classList.remove(...b);return!0};var Ia=function(a){return a&&a.parentNode?a.parentNode.removeChild(a):null};var ad=function(a,b){const f=b.nextSibling;b=b.parentNode;if(!b)throw Error("Reference node has no parent.");f?b.insertBefore(a,f):b.appendChild(a)};var Vf=function(a,b){a.style.transform=b;a.style["-webkit-transform"]=b};var cd=function(){Wf++;Kb||=Object.create(null)};var dd=function(){Wf--;Wf||(Kb=null)};
var ti=function(a){const b=a.textContent+"\n"+a.className.baseVal;let f;if(Kb&&(f=Kb[b]))return f;try{f=a.getComputedTextLength()}catch(g){return 8*a.textContent.length}Kb&&(Kb[b]=f);return f};var He=function(a,b,f,g){return Xf(a,b+"pt",f,g)};var Xf=function(a,b,f,g){const l=a.textContent;a=l+"\n"+a.className.baseVal;var n;if(Kb&&(n=Kb[a]))return n;Ie||(n=document.createElement("canvas"),n.className="blocklyComputeCanvas",document.body.appendChild(n),Ie=n.getContext("2d"));Ie.font=f+" "+b+" "+g;n=
l?Ie.measureText(l).width:0;Kb&&(Kb[a]=n);return n};var Yf=function(a,b,f,g){const l=document.createElement("span");l.style.font=f+" "+b+" "+g;l.textContent=a;a=document.createElement("div");a.style.width="1px";a.style.height="0";b=document.createElement("div");b.style.display="flex";b.style.position="fixed";b.style.top="0";b.style.left="0";b.appendChild(l);b.appendChild(a);document.body.appendChild(b);f={height:0,baseline:0};try{b.style.alignItems="baseline",f.baseline=a.offsetTop-l.offsetTop,b.style.alignItems=
"flex-end",f.height=a.offsetTop-l.offsetTop}finally{document.body.removeChild(b)}return f};var Je=function(a){return ui.getSizeInternal(a)};var vi=function(a){return new Aa(a.offsetWidth,a.offsetHeight)};var Wb=function(a,b){a=window.getComputedStyle(a);return a[b]||a.getPropertyValue(b)};var Ec=function(a){const b=new fa(0,0);a=a.getBoundingClientRect();var f=document.documentElement;f=new fa(window.pageXOffset||f.scrollLeft,window.pageYOffset||f.scrollTop);b.x=a.left+f.x;b.y=a.top+f.y;return b};
var wi=function(){const a=document.body,b=document.documentElement;return new fa(a.scrollLeft||b.scrollLeft,a.scrollTop||b.scrollTop)};var xi=function(a){const b=parseFloat(Wb(a,"borderLeftWidth")),f=parseFloat(Wb(a,"borderRightWidth")),g=parseFloat(Wb(a,"borderTopWidth"));a=parseFloat(Wb(a,"borderBottomWidth"));return new Ja(g,a,b,f)};var Zf=function(a,b,f){a=yi(a,b,f);b.scrollLeft=a.x;b.scrollTop=a.y};var yi=function(a,b,f){var g=Ec(a),l=Ec(b),n=xi(b);const x=g.x-l.x-n.left;g=g.y-l.y-n.top;l=vi(a);
a=b.clientWidth-l.width;l=b.clientHeight-l.height;n=b.scrollLeft;b=b.scrollTop;f?(n+=x-a/2,b+=g-l/2):(n+=Math.min(x,Math.max(x-a,0)),b+=Math.min(g,Math.max(g-l,0)));return new fa(n,b)};var Ke=function(a){const b=new fa(0,0);var f=a.x&&a.getAttribute("x");const g=a.y&&a.getAttribute("y");f&&(b.x=parseInt(f));g&&(b.y=parseInt(g));if(f=(f=a.getAttribute("transform"))&&f.match(zi))b.x+=Number(f[1]),f[3]&&(b.y+=Number(f[3]));(a=a.getAttribute("style"))&&a.includes("translate")&&(a=a.match(Ai))&&(b.x+=
Number(a[1]),a[3]&&(b.y+=Number(a[3])));return b};var $f=function(a){let b=0,f=0;for(;a;){const g=Ke(a);b+=g.x;f+=g.y;if((" "+(a.getAttribute("class")||"")+" ").includes(" injectionDiv "))break;a=a.parentNode}return new fa(b,f)};var Bi=function(){const a=wi();return new Ja(a.y,document.documentElement.clientHeight+a.y,a.x,document.documentElement.clientWidth+a.x)};var Ci=function(){const a=document.documentElement,b=window;return new fa(b.pageXOffset||a.scrollLeft,b.pageYOffset||a.scrollTop)};d.createElement$$module$build$src$core$utils$xml=
function(a){return Le.createElementNS(Di,a)};d.createTextNode$$module$build$src$core$utils$xml=function(a){return Le.createTextNode(a)};d.textToDom$$module$build$src$core$utils$xml=function(a){let b=Me.parseFromString(a,"text/xml");if(b&&b.documentElement&&!b.getElementsByTagName("parsererror").length)return b.documentElement;if((b=Me.parseFromString(a,"text/html"))&&b.body.firstChild&&"xml"===b.body.firstChild.nodeName.toLowerCase())return b.body.firstChild;throw Error(`DOMParser was unable to parse: ${a}`);
};var Md=function(a){return Am(ag.serializeToString(a))};var Am=function(a){return a.replace(Bm,b=>`&#${b.charCodeAt(0)};`)};var bg=function(a){if(!a)return null;if(a instanceof Element||"string"===typeof a)a=Ei(a),a=Cm(a);Dm(a);return a};var Dm=function(a){const b=a.kind;a=a.contents;if(b&&b!==Fi&&b!==cg)throw Error("Invalid toolbox kind "+b+". Please supply either "+Fi+" or "+cg);if(!a)throw Error("Toolbox must have a contents attribute.");};var Ne=function(a){return a?a.contents?a.contents:Array.isArray(a)&&
0<a.length&&!a[0].nodeType?a:dg(a):[]};var eg=function(a){return Gi.hasCategoriesInternal(a)};var fg=function(a){return a&&a.contents?!!a.contents.filter(function(b){return"CATEGORY"===b.kind.toUpperCase()}).length:!1};var Cm=function(a){const b={contents:dg(a)};a instanceof Node&&Hi(a,b);return b};var dg=function(a){const b=[];let f=a.childNodes;f||=a;for(let g=0,l;l=f[g];g++){if(!l.tagName)continue;a={};const n=l.tagName.toUpperCase();a.kind=n;"BLOCK"===n?a.blockxml=l:l.childNodes&&0<l.childNodes.length&&
(a.contents=dg(l));Hi(l,a);b.push(a)}return b};var Hi=function(a,b){for(let f=0;f<a.attributes.length;f++){const g=a.attributes[f];g.nodeName.includes("css-")?(b.cssconfig=b.cssconfig||{},b.cssconfig[g.nodeName.replace("css-","")]=g.value):b[g.nodeName]=g.value}};var Ei=function(a){let b=null;if(a)if("string"===typeof a){if(b=d.textToDom$$module$build$src$core$utils$xml(a),"xml"!==b.nodeName.toLowerCase())throw TypeError("Toolbox should be an <xml> document.");}else a instanceof Element&&(b=a);return b};
var gg=function(a,b,f,g,l,n){const x=n.scrollbar&&n.scrollbar.canScrollVertically();a.horizontal===Nd.LEFT?(f=l.absoluteMetrics.left+f,x&&n.RTL&&(f+=Sa.scrollbarThickness)):(f=l.absoluteMetrics.left+l.viewMetrics.width-b.width-f,x&&!n.RTL&&(f-=Sa.scrollbarThickness));a.vertical===nc.TOP?a=l.absoluteMetrics.top+g:(a=l.absoluteMetrics.top+l.viewMetrics.height-b.height-g,n.scrollbar&&n.scrollbar.canScrollHorizontally()&&(a-=Sa.scrollbarThickness));return new Ja(a,a+b.height,f,f+b.width)};var hg=function(a,
b){return{horizontal:b.toolboxMetrics.position===xa.LEFT||a.horizontalLayout&&!a.RTL?Nd.RIGHT:Nd.LEFT,vertical:b.toolboxMetrics.position===xa.BOTTOM?nc.TOP:nc.BOTTOM}};var ig=function(a,b,f,g){const l=a.left,n=a.right-a.left,x=a.bottom-a.top;for(let B=0;B<g.length;B++){const V=g[B];a.intersects(V)&&(a=f===Fc.UP?V.top-x-b:V.bottom+b,a=new Ja(a,a+x,l,l+n),B=-1)}return a};var Oe=function(a,b){e(ba.SERIALIZER,a,b)};var Od=function(a,{addCoordinates:b=!1,saveIds:f=!0}={}){const g=a.workspace,l=Object.create(null);
l.height=a.getSize().height;l.width=a.getSize().width;f&&(l.id=a.id);b&&(b=a.getRelativeToSurfaceXY(),l.x=g.RTL?g.getWidth()-b.x:b.x,l.y=b.y);a.getText()&&(l.text=a.getText());a.isCollapsed()&&(l.collapsed=!0);a.isOwnEditable()||(l.editable=!1);a.isOwnMovable()||(l.movable=!1);a.isOwnDeletable()||(l.deletable=!1);return l};var Pe=function(a,b,{recordUndo:f=!1}={}){const g=ea();d.setRecordUndo$$module$build$src$core$events$utils(f);f=b.newComment(a.id);void 0!==a.text&&f.setText(a.text);if(void 0!==
a.x||void 0!==a.y){const n=f.getRelativeToSurfaceXY();let x,B=null!=(x=a.x)?x:n.x;B=b.RTL?b.getWidth()-B:B;var l;b=null!=(l=a.y)?l:n.y;f.moveTo(new fa(B,b))}if(void 0!==a.width||a.height){l=f.getSize();let n,x;f.setSize(new Aa(null!=(n=a.width)?n:l.width,null!=(x=a.height)?x:l.height))}void 0!==a.collapsed&&f.setCollapsed(a.collapsed);void 0!==a.editable&&f.setEditable(a.editable);void 0!==a.movable&&f.setMovable(a.movable);void 0!==a.deletable&&f.setDeletable(a.deletable);d.setRecordUndo$$module$build$src$core$events$utils(g);
return f};var jg=function(a,b){e(ba.PASTER,a,b)};var Fm=function(a){const b=a.workspace,f=a.getRelativeToSurfaceXY(),g=new fa(0,0),l=b.getTopComments(!1).filter(n=>n.id!==a.id).map(n=>n.getRelativeToSurfaceXY());for(;Em(fa.sum(f,g),l);)g.translate(b.RTL?-30:30,30);a.moveTo(fa.sum(f,g))};var Em=function(a,b){return b.some(f=>1>=Math.abs(f.x-a.x)&&1>=Math.abs(f.y-a.y))};var Gc=function(a,b){a.setAttribute(Gm,b)};var bb=function(a,b,f){Array.isArray(f)&&(f=f.join(" "));a.setAttribute(Hm+b,`${f}`)};var Qe=
function(a){return void 0!==a.saveState&&void 0!==a.loadState};var Ki=function(a){Ii(a);if(Im())return kg(),Promise.resolve();Pd||=new Promise(b=>{lg=b;Ji=window.requestAnimationFrame(()=>{kg();b()})});return Pd};var Lb=function(){return Pd?Pd:Promise.resolve()};var oc=function(a){a||window.cancelAnimationFrame(Ji);kg(a);!a&&lg&&lg()};var Im=function(){return Li};var Ii=function(a){mg.add(a);ng.set(a,d.getGroup$$module$build$src$core$events$utils());const b=a.getParent();b?Ii(b):Re.add(a)};var kg=
function(a){const b=a?new Set([a]):new Set([...Re].map(n=>n.workspace)),f=[...Re].filter(Jm).filter(n=>b.has(n.workspace));for(var g of f)Mi(g);for(const n of b)n.resizeContents();for(var l of f)g=l.getRelativeToSurfaceXY(),l.updateComponentLocations(g);for(const n of f)l=d.getGroup$$module$build$src$core$events$utils(),(g=ng.get(n))&&d.setGroup$$module$build$src$core$events$utils(g),n.bumpNeighbours(),d.setGroup$$module$build$src$core$events$utils(l);for(const n of f)Ni(n);a||(Pd=null)};var Ni=function(a){Re.delete(a);
mg.delete(a);ng.delete(a);for(const b of a.getChildren(!1))Ni(b)};var Jm=function(a){return!a.isDisposed()&&!a.getParent()};var Mi=function(a){if(mg.has(a)&&a.initialized){for(const b of a.getChildren(!1))Mi(b);a.renderEfficiently()}};var Se=function(a,b){Oi(a,b)};var og=function(a,b){Pi.confirmInternal(a,b)};var pg=function(a,b,f){Qi(a,b,f)};var Qd=function(a){return void 0!==a.getProcedureDef};var Km=function(a){return void 0!==a.getProcedureCall&&void 0!==a.renameProcedure};var Ri=function(a){return void 0!==
a.getVariableModel};d.allUsedVarModels$$module$build$src$core$variables=function(a){a=a.getAllBlocks(!1);const b=new Set;for(let f=0;f<a.length;f++){const g=a[f].getVarModels();if(g)for(let l=0;l<g.length;l++){const n=g[l];n.getId()&&b.add(n)}}return Array.from(b.values())};d.allDeveloperVariables$$module$build$src$core$variables=function(a){a=a.getAllBlocks(!1);const b=new Set;for(let g=0,l;l=a[g];g++){var f=l.getDeveloperVariables;if(f){f=f();for(let n=0;n<f.length;n++)b.add(f[n])}}return Array.from(b.values())};
var qg=function(a){let b=[];const f=document.createElement("button");f.setAttribute("text","%{BKY_NEW_VARIABLE}");f.setAttribute("callbackKey","CREATE_VARIABLE");a.registerButtonCallback("CREATE_VARIABLE",function(g){Rd(g.getTargetWorkspace())});b.push(f);a=Si(a);return b=b.concat(a)};var Si=function(a){a=a.getVariablesOfType("");const b=[];if(0<a.length){var f=a[a.length-1];if(hb.variables_set){var g=d.createElement$$module$build$src$core$utils$xml("block");g.setAttribute("type","variables_set");
g.setAttribute("gap",hb.math_change?"8":"24");g.appendChild(ed(f));b.push(g)}hb.math_change&&(g=d.createElement$$module$build$src$core$utils$xml("block"),g.setAttribute("type","math_change"),g.setAttribute("gap",hb.variables_get?"20":"8"),g.appendChild(ed(f)),f=d.textToDom$$module$build$src$core$utils$xml('<value name="DELTA"><shadow type="math_number"><field name="NUM">1</field></shadow></value>'),g.appendChild(f),b.push(g));if(hb.variables_get){a.sort(Sd.compareByName);for(let l=0,n;n=a[l];l++)f=
d.createElement$$module$build$src$core$utils$xml("block"),f.setAttribute("type","variables_get"),f.setAttribute("gap","8"),f.appendChild(ed(n)),b.push(f)}}return b};var Ui=function(a){return Ti.generateUniqueNameInternal(a)};var sg=function(a,b){if(!b.length)return a;const f=rg;let g="",l=f.indexOf(a);for(;;){let n=!1;for(let x=0;x<b.length;x++)if(b[x].toLowerCase()===a){n=!0;break}if(!n)break;l++;l===f.length&&(l=0,g=`${Number(g)+1}`);a=f.charAt(l)+g}return a};var Rd=function(a,b,f){function g(n){tg(d.Msg$$module$build$src$core$msg.NEW_VARIABLE_TITLE,
n,function(x){if(x){var B=Vi(x,a);if(B){if(B.type===l)var V=d.Msg$$module$build$src$core$msg.VARIABLE_ALREADY_EXISTS.replace("%1",B.name);else V=d.Msg$$module$build$src$core$msg.VARIABLE_ALREADY_EXISTS_FOR_ANOTHER_TYPE,V=V.replace("%1",B.name).replace("%2",B.type);Se(V,function(){g(x)})}else a.createVariable(x,l),b&&b(x)}else b&&b(null)})}const l=f||"";g("")};d.renameVariable$$module$build$src$core$variables=function(a,b,f){function g(l){const n=d.Msg$$module$build$src$core$msg.RENAME_VARIABLE_TITLE.replace("%1",
b.name);tg(n,l,function(x){if(x){var B=Lm(x,b.type,a),V=Wi(b.name,x,a);if(B||V){var na="";B?na=d.Msg$$module$build$src$core$msg.VARIABLE_ALREADY_EXISTS_FOR_ANOTHER_TYPE.replace("%1",B.name).replace("%2",B.type):V&&(na=d.Msg$$module$build$src$core$msg.VARIABLE_ALREADY_EXISTS_FOR_A_PARAMETER.replace("%1",x).replace("%2",V));Se(na,function(){g(x)})}else a.renameVariableById(b.getId(),x),f&&f(x)}else f&&f(null)})}g("")};var tg=function(a,b,f){pg(a,b,function(g){g&&(g=g.replace(/[\s\xa0]+/g," ").trim(),
g===d.Msg$$module$build$src$core$msg.RENAME_VARIABLE||g===d.Msg$$module$build$src$core$msg.NEW_VARIABLE)&&(g=null);f(g)})};var Lm=function(a,b,f){f=f.getVariableMap().getAllVariables();a=a.toLowerCase();for(let g=0,l;l=f[g];g++)if(l.name.toLowerCase()===a&&l.type!==b)return l;return null};var Vi=function(a,b){b=b.getVariableMap().getAllVariables();a=a.toLowerCase();for(let f=0,g;g=b[f];f++)if(g.name.toLowerCase()===a)return g;return null};var Wi=function(a,b,f){return f.getProcedureMap().getProcedures().length?
Mm(a,b,f):Nm(a,b,f)};var Mm=function(a,b,f){a=a.toLowerCase();b=b.toLowerCase();f=f.getProcedureMap().getProcedures();for(const l of f){var g=l.getParameters().filter(Ri).map(n=>n.getVariableModel().name);if(g&&(f=g.some(n=>n.toLowerCase()===a),g=g.some(n=>n.toLowerCase()===b),f&&g))return l.getName()}return null};var Nm=function(a,b,f){a=a.toLowerCase();b=b.toLowerCase();f=f.getAllBlocks(!1);for(const l of f){if(!Qd(l))continue;f=l.getProcedureDef();var g=f[1];const n=g.some(x=>x.toLowerCase()===
a);g=g.some(x=>x.toLowerCase()===b);if(n&&g)return f[0]}return null};var ed=function(a){const b=d.createElement$$module$build$src$core$utils$xml("field");b.setAttribute("name","VAR");b.setAttribute("id",a.getId());b.setAttribute("variabletype",a.type);a=d.createTextNode$$module$build$src$core$utils$xml(a.name);b.appendChild(a);return b};d.getOrCreateVariablePackage$$module$build$src$core$variables=function(a,b,f,g){let l=d.getVariable$$module$build$src$core$variables(a,b,f,g);l||=Om(a,b,f,g);return l};
d.getVariable$$module$build$src$core$variables=function(a,b,f,g){const l=a.getPotentialVariableMap();let n=null;if(b&&(n=a.getVariableById(b),!n&&l&&(n=l.getVariableById(b)),n))return n;if(f){if(void 0===g)throw Error("Tried to look up a variable by name without a type");n=a.getVariable(f,g);!n&&l&&(n=l.getVariable(f,g))}return n};var Om=function(a,b,f,g){const l=a.getPotentialVariableMap();f||=Ui(a.isFlyout?a.targetWorkspace:a);return l?l.createVariable(f,g,b):a.createVariable(f,g,b)};var Te=function(a,
b){a=a.getAllVariables();const f=[];if(b.length!==a.length)for(let g=0;g<a.length;g++){const l=a[g];b.includes(l)||f.push(l)}return f};var vb=function(a,{addCoordinates:b=!1,addInputBlocks:f=!0,addNextBlocks:g=!0,doFullSerialization:l=!0,saveIds:n=!0}={}){if(a.isInsertionMarker())return null;const x={type:a.type,id:n?a.id:void 0};b&&Pm(a,x);Qm(a,x);Rm(a,x,l);Sm(a,x,l);Tm(a,x,l);f&&Um(a,x,l,n);g&&Vm(a,x,l,n);return x};var Qm=function(a,b){a.isCollapsed()&&(b.collapsed=!0);a.isEnabled()||(b.disabledReasons=
Array.from(a.getDisabledReasons()));a.isOwnDeletable()||(b.deletable=!1);a.isOwnMovable()||(b.movable=!1);a.isOwnEditable()||(b.editable=!1);void 0!==a.inputsInline&&a.inputsInline!==a.inputsInlineDefault&&(b.inline=a.inputsInline);a.data&&(b.data=a.data)};var Pm=function(a,b){const f=a.workspace;a=a.getRelativeToSurfaceXY();b.x=Math.round(f.RTL?f.getWidth()-a.x:a.x);b.y=Math.round(a.y)};var Rm=function(a,b,f){a.saveExtraState?(a=a.saveExtraState(f),null!==a&&(b.extraState=a)):a.mutationToDom&&(a=
a.mutationToDom(),null!==a&&(b.extraState=Xb(a).replace(' xmlns="https://developers.google.com/blockly/xml"',"")))};var Sm=function(a,b,f){const g=Object.create(null);for(const l of a.getIcons())Qe(l)&&(a=l.saveState(f))&&(g[l.getType().toString()]=a);Object.keys(g).length&&(b.icons=g)};var Tm=function(a,b,f){const g=Object.create(null);for(let l=0;l<a.inputList.length;l++){const n=a.inputList[l];for(let x=0;x<n.fieldRow.length;x++){const B=n.fieldRow[x];B.isSerializable()&&(g[B.name]=B.saveState(f))}}Object.keys(g).length&&
(b.fields=g)};var Um=function(a,b,f,g){const l=Object.create(null);for(let n=0;n<a.inputList.length;n++){const x=a.inputList[n];if(!x.connection)continue;const B=Xi(x.connection,f,g);B&&(l[x.name]=B)}Object.keys(l).length&&(b.inputs=l)};var Vm=function(a,b,f,g){a.nextConnection&&(a=Xi(a.nextConnection,f,g))&&(b.next=a)};var Xi=function(a,b,f){const g=a.getShadowState(!0);a=a.targetBlock();if(!g&&!a)return null;const l=Object.create(null);g&&(l.shadow=g);a&&!a.isShadow()&&(l.block=vb(a,{doFullSerialization:b,
saveIds:f}));return l};var pc=function(a,b,{recordUndo:f=!1}={}){a=Td(a,b,{recordUndo:f});b.rendered&&oc();return a};var Td=function(a,b,{parentConnection:f,isShadow:g=!1,recordUndo:l=!1}={}){const n=ea();d.setRecordUndo$$module$build$src$core$events$utils(l);(l=d.getGroup$$module$build$src$core$events$utils())||d.setGroup$$module$build$src$core$events$utils(!0);d.disable$$module$build$src$core$events$utils();const x=b.getAllVariables();let B;try{B=Yi(a,b,{parentConnection:f,isShadow:g})}finally{d.enable$$module$build$src$core$events$utils()}Wm(b,
x);ia()&&aa(new (la(O.BLOCK_CREATE))(B));d.setGroup$$module$build$src$core$events$utils(l);d.setRecordUndo$$module$build$src$core$events$utils(n);if(b.rendered){const V=B;setTimeout(()=>{V.disposed||V.setConnectionTracking(!0)},1)}return B};var Yi=function(a,b,{parentConnection:f,isShadow:g=!1}={}){if(!a.type)throw new Zi(a);const l=b.newBlock(a.type,a.id);l.setShadow(g);Xm(l,a);Ym(l,a);Zm(l,a);$m(f,l,a);an(l,a);bn(l,a);cn(l,a);dn(l,a);en(l,b.rendered);return l};var Wm=function(a,b){if(ia())for(a=
Te(a,b),b=0;b<a.length;b++){const f=a[b];aa(new (la(O.VAR_CREATE))(f))}};var Xm=function(a,b){let f=void 0===b.x?0:b.x;b=void 0===b.y?0:b.y;const g=a.workspace;f=g.RTL?g.getWidth()-f:f;a.moveBy(f,b)};var Ym=function(a,b){b.collapsed&&a.setCollapsed(!0);!1===b.deletable&&a.setDeletable(!1);!1===b.movable&&a.setMovable(!1);!1===b.editable&&a.setEditable(!1);!1===b.enabled&&a.setDisabledReason(!0,fb);if(Array.isArray(b.disabledReasons))for(const f of b.disabledReasons)a.setDisabledReason(!0,f);void 0!==
b.inline&&a.setInputsInline(b.inline);void 0!==b.data&&(a.data=b.data)};var Zm=function(a,b){b.extraState&&(a.loadExtraState?a.loadExtraState(b.extraState):a.domToMutation&&a.domToMutation(d.textToDom$$module$build$src$core$utils$xml(b.extraState)))};var $m=function(a,b,f){if(a){if(a.getSourceBlock().isShadow()&&!b.isShadow())throw new $i(f);if(a.type===d.inputTypes$$module$build$src$core$inputs$input_types.VALUE){var g=b.outputConnection;if(!g)throw new Ud("output",b,f);}else if(g=b.previousConnection,
!g)throw new Ud("previous",b,f);if(!a.connect(g)){const l=b.workspace.connectionChecker;throw new aj(l.getErrorMessage(l.canConnectWithReason(g,a,!1),g,a),a.type===d.inputTypes$$module$build$src$core$inputs$input_types.VALUE?"output connection":"previous connection",b,f);}}};var an=function(a,b){if(b.icons){var f=Object.keys(b.icons);for(const l of f){f=b.icons[l];var g=a.getIcon(l);if(!g){g=t(ba.ICON,l,!1);if(!g)throw new bj(l,a,b);g=new g(a);a.addIcon(g)}Qe(g)&&g.loadState(f)}}};var bn=function(a,
b){if(b.fields){var f=Object.keys(b.fields);for(let g=0;g<f.length;g++){const l=f[g],n=b.fields[l],x=a.getField(l);x?x.loadState(n):console.warn(`Ignoring non-existant field ${l} in block ${a.type}`)}}};var cn=function(a,b){if(b.inputs){var f=Object.keys(b.inputs);for(let g=0;g<f.length;g++){const l=f[g],n=a.getInput(l);if(!n||!n.connection)throw new Ud(l,a,b);cj(n.connection,b.inputs[l])}}};var dn=function(a,b){if(b.next){if(!a.nextConnection)throw new Ud("next",a,b);cj(a.nextConnection,b.next)}};
var cj=function(a,b){b.shadow&&a.setShadowState(b.shadow);b.block&&Yi(b.block,a.getSourceBlock().workspace,{parentConnection:a})};var en=function(a,b){if(b){a.setConnectionTracking(!1);a.initSvg();a.queueRender();for(const f of a.getIcons())f.onLocationChange(a.getRelativeToSurfaceXY())}else a.initModel()};var Vd=function(a){return void 0!==a.bubbleIsVisible&&void 0!==a.setBubbleVisible};var ug=function(a){return a*Math.PI/180};var Wd=function(a,b,f){if(f<a){const g=f;f=a;a=g}return Math.max(a,Math.min(b,
f))};var dj=function(){document.querySelector(".blocklyDropDownDiv")||(Ca=document.createElement("div"),Ca.className="blocklyDropDownDiv",(r()||document.body).appendChild(Ca),fd=document.createElement("div"),fd.className="blocklyDropDownContent",Ca.appendChild(fd),Hc=document.createElement("div"),Hc.className="blocklyDropDownArrow",Ca.appendChild(Hc),Ca.style.opacity="0",Ca.style.transition="transform "+Ue+"s, opacity "+Ue+"s",Ca.addEventListener("focusin",function(){sa(Ca,"blocklyFocused")}),Ca.addEventListener("focusout",
function(){Ma(Ca,"blocklyFocused")}))};var ej=function(a){vg=a};var fj=function(){return qc};var Ve=function(){return fd};var wg=function(){fd.textContent="";fd.style.width=""};var gj=function(a,b){Ca.style.backgroundColor=a;Ca.style.borderColor=b};var kj=function(a,b,f){hj=!0;return ij(jj(a),a,b,f)};var lj=function(a){var b=a.getSvgRoot();const f=a.workspace.scale,g=a.height*f;a=a.width*f;b=Ec(b);return new Ja(b.y,b.y+g,b.x,b.x+a)};var jj=function(a){a=a.getScaledBBox();return new Ja(a.top,a.bottom,
a.left,a.right)};var ij=function(a,b,f,g){const l=a.left+(a.right-a.left)/2,n=a.bottom;a=a.top;g&&(a+=g);g=b.getSourceBlock();let x=g.workspace;for(;x.options.parentWorkspace;)x=x.options.parentWorkspace;ej(x.getParentSvg().parentNode);return mj(b,g.RTL,l,n,l,a,f)};var mj=function(a,b,f,g,l,n,x){qc=a;Ic=x||null;Ca.style.direction=b?"rtl":"ltr";a=z();gd=a.getRenderer().getClassName();hd=a.getTheme().getClassName();gd&&sa(Ca,gd);hd&&sa(Ca,hd);return nj(f,g,l,n)};var oj=function(a,b,f,g){a=We(a,f.left,
f.right,g.width);return{initialX:a.divX,initialY:b,finalX:a.divX,finalY:b+xg,arrowX:a.arrowX,arrowY:-(Xd/2+yg),arrowAtTop:!0,arrowVisible:!0}};var pj=function(a,b,f,g){a=We(a,f.left,f.right,g.width);return{initialX:a.divX,initialY:b-g.height,finalX:a.divX,finalY:b-g.height-xg,arrowX:a.arrowX,arrowY:g.height-2*yg-Xd/2,arrowAtTop:!1,arrowVisible:!0}};var fn=function(a,b,f){a=We(a,b.left,b.right,f.width);return{initialX:a.divX,initialY:0,finalX:a.divX,finalY:0,arrowAtTop:null,arrowX:null,arrowY:null,
arrowVisible:!1}};var We=function(a,b,f,g){b=Wd(b,a-g/2,f-g);a=a-Xd/2-b;f=qj;a=Wd(f,a,g-f-Xd);return{arrowX:a,divX:b}};var rj=function(){return!!qc};var Ag=function(a,b){return qc===a?(b?Yb():zg(),!0):!1};var zg=function(){Ca.style.transform="translate(0, 0)";Ca.style.opacity="0";Bg=setTimeout(function(){Yb()},1E3*Ue);Ic&&(Ic(),Ic=null)};var Yb=function(){rj()&&(Bg&&clearTimeout(Bg),Ca.style.transform="",Ca.style.left="",Ca.style.top="",Ca.style.opacity="0",Ca.style.display="none",Ca.style.backgroundColor=
"",Ca.style.borderColor="",Ic&&(Ic(),Ic=null),wg(),qc=null,gd&&(Ma(Ca,gd),gd=""),hd&&(Ma(Ca,hd),hd=""),z().markFocused())};var nj=function(a,b,f,g){a=Cg.getPositionMetrics(a,b,f,g);a.arrowVisible?(Hc.style.display="",Hc.style.transform="translate("+a.arrowX+"px,"+a.arrowY+"px) rotate(45deg)",Hc.setAttribute("class",a.arrowAtTop?"blocklyDropDownArrow blocklyArrowTop":"blocklyDropDownArrow blocklyArrowBottom")):Hc.style.display="none";b=Math.floor(a.initialX);f=Math.floor(a.initialY);g=Math.floor(a.finalX);
const l=Math.floor(a.finalY);Ca.style.left=b+"px";Ca.style.top=f+"px";Ca.style.display="block";Ca.style.opacity="1";Ca.style.transform="translate("+(g-b)+"px,"+(l-f)+"px)";return!!a.arrowAtTop};var sj=function(){if(qc){var a=qc.getSourceBlock();a=hj?jj(qc):lj(a);const b=a.left+(a.right-a.left)/2;nj(b,a.bottom,b,a.top)}else zg()};var Xe=function(a){return a.length?a.reduce(function(b,f){return b.length<f.length?b:f}).length:0};var tj=function(a,b){if(!a.length)return 0;if(1===a.length)return a[0].length;
let f=0;b=b||Xe(a);let g;for(g=0;g<b;g++){for(var l=a[0][g],n=1;n<a.length;n++)if(l!==a[n][g])return f;" "===l&&(f=g+1)}for(l=1;l<a.length;l++)if((n=a[l][g])&&" "!==n)return f;return b};var uj=function(a,b){if(!a.length)return 0;if(1===a.length)return a[0].length;let f=0;b=b||Xe(a);let g;for(g=0;g<b;g++){for(var l=a[0].substr(-g-1,1),n=1;n<a.length;n++)if(l!==a[n].substr(-g-1,1))return f;" "===l&&(f=g+1)}for(l=1;l<a.length;l++)if((n=a[l].charAt(a[l].length-g-1))&&" "!==n)return f;return b};d.wrap$$module$build$src$core$utils$string=
function(a,b){a=a.split("\n");for(let f=0;f<a.length;f++)a[f]=gn(a[f],b);return a.join("\n")};var gn=function(a,b){if(a.length<=b)return a;const f=a.trim().split(/\s+/);for(var g=0;g<f.length;g++)f[g].length>b&&(b=f[g].length);var l=-Infinity;let n,x=1;do{g=l;n=a;a=[];l=f.length/x;let B=1;for(let V=0;V<f.length-1;V++)B<(V+1.5)/l?(B++,a[V]=!0):a[V]=!1;a=vj(f,a,b);l=Dg(f,a,b);a=hn(f,a);x++}while(l>g);return n};var Dg=function(a,b,f){const g=[0],l=[];for(var n=0;n<a.length;n++)g[g.length-1]+=a[n].length,
!0===b[n]?(g.push(0),l.push(a[n].charAt(a[n].length-1))):!1===b[n]&&g[g.length-1]++;a=Math.max(...g);for(n=b=0;n<g.length;n++)b-=2*Math.pow(Math.abs(f-g[n]),1.5),b-=Math.pow(a-g[n],1.5),".?!".includes(l[n])?b+=f/3:",;)]}".includes(l[n])&&(b+=f/4);1<g.length&&g[g.length-1]<=g[g.length-2]&&(b+=.5);return b};var vj=function(a,b,f){let g=Dg(a,b,f),l;for(let n=0;n<b.length-1;n++){if(b[n]===b[n+1])continue;const x=[].concat(b);x[n]=!x[n];x[n+1]=!x[n+1];const B=Dg(a,x,f);B>g&&(g=B,l=x)}return l?vj(a,l,f):
b};var hn=function(a,b){const f=[];for(let g=0;g<a.length;g++)f.push(a[g]),void 0!==b[g]&&f.push(b[g]?"\n":" ");return f.join("")};d.isNumber$$module$build$src$core$utils$string=function(a){return/^\s*-?\d+(\.\d+)?\s*$/.test(a)};var Yd=function(a){if(a=wj(a)){for(a=a.tooltip;"function"===typeof a;)a=a();if("string"!==typeof a)throw Error("Tooltip function must return a string.");return a}return""};var wj=function(a){for(;a&&a.tooltip;){if("string"===typeof a.tooltip||"function"===typeof a.tooltip)return a;
a=a.tooltip}return null};var xj=function(){document.querySelector(".blocklyTooltipDiv")||(Wa=document.createElement("div"),Wa.className="blocklyTooltipDiv",(r()||document.body).appendChild(Wa))};var Zd=function(a){a.mouseOverWrapper_=lb(a,"pointerover",null,jn);a.mouseOutWrapper_=lb(a,"pointerout",null,kn);a.addEventListener("pointermove",yj,!1)};var Eg=function(a){a&&(Na(a.mouseOverWrapper_),Na(a.mouseOutWrapper_),a.removeEventListener("pointermove",yj))};var jn=function(a){id||(a=wj(a.currentTarget),
wb!==a&&(rc(),$d=null,wb=a),clearTimeout(zj))};var kn=function(a){id||(zj=setTimeout(function(){$d=wb=null;rc()},1),clearTimeout(Jc),Jc=0)};var yj=function(a){if(wb&&wb.tooltip&&!id)if(ae){const b=Fg-a.pageX;a=Gg-a.pageY;Math.sqrt(b*b+a*a)>Aj&&rc()}else $d!==wb&&(clearTimeout(Jc),Fg=a.pageX,Gg=a.pageY,Jc=setTimeout(ln,Bj))};var Cj=function(){$d=wb=null;rc()};var rc=function(){ae&&(ae=!1,Wa&&(Wa.style.display="none"));Jc&&(clearTimeout(Jc),Jc=0)};var Dj=function(){rc();id=!0};var Ej=function(){id=
!1};var nn=function(){Wa&&wb&&("function"===typeof Ye?Ye(Wa,wb):mn())};var mn=function(){var a=Yd(wb);a=d.wrap$$module$build$src$core$utils$string(a,Fj);a=a.split("\n");for(let b=0;b<a.length;b++){const f=document.createElement("div");f.appendChild(document.createTextNode(a[b]));Wa.appendChild(f)}};var on=function(a){const b=document.documentElement.clientWidth,f=document.documentElement.clientHeight;let g=Fg;g=a?g-(Hg+Wa.offsetWidth):g+Hg;let l=Gg+Ig;l+Wa.offsetHeight>f+window.scrollY&&(l-=Wa.offsetHeight+
2*Ig);a?g=Math.max(Ze-window.scrollX,g):g+Wa.offsetWidth>b+window.scrollX-2*Ze&&(g=b-Wa.offsetWidth-2*Ze);return{x:g,y:l}};var ln=function(){if(!id&&($d=wb,Wa)){Wa.textContent="";nn();var a=wb.RTL;Wa.style.direction=a?"rtl":"ltr";Wa.style.display="block";ae=!0;var {x:b,y:f}=on(a);Wa.style.left=b+"px";Wa.style.top=f+"px"}};var Gj=function(){return Jg};var Hj=function(){return Kg};var jd=function(a){a=`${a}`.toLowerCase().trim();var b=Ij[a];if(b)return b;b="0x"===a.substring(0,2)?"#"+a.substring(2):
a;b="#"===b[0]?b:"#"+b;if(/^#[0-9a-f]{6}$/.test(b))return b;if(/^#[0-9a-f]{3}$/.test(b))return["#",b[1],b[1],b[2],b[2],b[3],b[3]].join("");var f=a.match(/^(?:rgb)?\s*\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*\)$/);return f&&(a=Number(f[1]),b=Number(f[2]),f=Number(f[3]),0<=a&&256>a&&0<=b&&256>b&&0<=f&&256>f)?$e(a,b,f):null};var $e=function(a,b,f){b=a<<16|b<<8|f;return 16>a?"#"+(16777216|b).toString(16).substr(1):"#"+b.toString(16)};var Lg=function(a){a=jd(a);if(!a)return[0,0,0];a=parseInt(a.substr(1),16);
return[a>>16,a>>8&255,a&255]};var Mg=function(a,b,f){let g=0,l=0,n=0;if(0===b)n=l=g=f;else{const x=Math.floor(a/60),B=a/60-x;a=f*(1-b);const V=f*(1-b*B);b=f*(1-b*(1-B));switch(x){case 1:g=V;l=f;n=a;break;case 2:g=a;l=f;n=b;break;case 3:g=a;l=V;n=f;break;case 4:g=b;l=a;n=f;break;case 5:g=f;l=a;n=V;break;case 6:case 0:g=f,l=b,n=a}}return $e(Math.floor(g),Math.floor(l),Math.floor(n))};var kd=function(a,b,f){a=jd(a);if(!a)return null;b=jd(b);if(!b)return null;a=Lg(a);b=Lg(b);return $e(Math.round(b[0]+
f*(a[0]-b[0])),Math.round(b[1]+f*(a[1]-b[1])),Math.round(b[2]+f*(a[2]-b[2])))};var Jj=function(a){return Mg(a,Jg,255*Kg)};var Ng=function(a,b,f){const g=[];var l=a.split("");l.push("");var n=0;a=[];let x=null;for(let V=0;V<l.length;V++){var B=l[V];if(0===n)if("%"===B)(n=a.join(""))&&g.push(n),a.length=0,n=1;else if(f&&"\n"===B){const na=a.join("");na&&g.push(na);a.length=0;g.push(B)}else a.push(B);else 1===n?"%"===B?(a.push(B),n=0):b&&"0"<=B&&"9">=B?(n=2,x=B,(B=a.join(""))&&g.push(B),a.length=0):
"{"===B?n=3:(a.push("%",B),n=0):2===n?"0"<=B&&"9">=B?x+=B:(n=void 0,g.push(parseInt(null!=(n=x)?n:"",10)),V--,n=0):3===n&&(""===B?(a.splice(0,0,"%{"),V--,n=0):"}"!==B?a.push(B):(n=a.join(""),/[A-Z]\w*/i.test(n)?(B=n.toUpperCase(),(B=B.startsWith("BKY_")?B.substring(4):null)&&B in d.Msg$$module$build$src$core$msg?(n=d.Msg$$module$build$src$core$msg[B],"string"===typeof n?Array.prototype.push.apply(g,Ng(n,b,f)):b?g.push(`${n}`):g.push(n)):g.push("%{"+n+"}")):g.push("%{"+n+"}"),n=a.length=0))}(b=a.join(""))&&
g.push(b);n=[];for(l=a.length=0;l<g.length;l++)"string"!==typeof g[l]||f&&"\n"===g[l]?((b=a.join(""))&&n.push(b),a.length=0,n.push(g[l])):a.push(g[l]);(b=a.join(""))&&n.push(b);a.length=0;return n};var Kj=function(a){return Ng(a,!0,!0)};var Ua=function(a){if("string"!==typeof a)return a;a=Ng(a,!1,!1);return a.length?String(a[0]):""};var be=function(a){const b="string"===typeof a?Ua(a):a;var f=Number(b);if(!isNaN(f)&&0<=f&&360>=f)return{hue:f,hex:Mg(f,Gj(),255*Hj())};if(f=jd(b))return{hue:null,hex:f};
f='Invalid colour: "'+b+'"';a!==b&&(f+=' (from "'+a+'")');throw Error(f);};var ld=function(){return Cb};var Lj=function(){const a=r()||document.body;document.querySelector("."+af)?Cb=document.querySelector("."+af):(Cb=document.createElement("div"),Cb.className=af);a.appendChild(Cb)};var Pg=function(a,b,f,g){ce();md=a;bf=f;if(f=Cb){f.style.direction=b?"rtl":"ltr";f.style.display="block";if(!g&&a instanceof Ka){let x;g=null==(x=a.getSourceBlock())?void 0:x.workspace}var l;Og=null!=(l=g)?l:null;var n;
a=null!=(n=g)?n:z();nd=a.getRenderer().getClassName();od=a.getTheme().getClassName();nd&&sa(f,nd);od&&sa(f,od)}};var ce=function(){if(Mj()){md=null;var a=Cb;a&&(a.style.display="none",a.style.left="",a.style.top="",bf&&bf(),bf=null,a.textContent="",nd&&(Ma(a,nd),nd=""),od&&(Ma(a,od),od=""),z().markFocused())}};var Mj=function(){return!!md};var pd=function(a){md===a&&ce()};var cf=function(a){null!==Og&&Og!==a||ce()};var Nj=function(a,b,f){Cb.style.left=a+"px";Cb.style.top=b+"px";Cb.style.height=f+
"px"};var Oj=function(a,b,f,g){const l=pn(a,b,f);a=qn(a,b,f,g);0>l?Nj(a,0,f.height+l):Nj(a,l,f.height)};var qn=function(a,b,f,g){return g?Math.min(Math.max(b.right-f.width,a.left),a.right-f.width):Math.max(Math.min(b.left,a.right-f.width),a.left)};var pn=function(a,b,f){return b.bottom+f.height>=a.bottom?b.top-f.height:b.bottom};var rn=function(a){return!(null==a||!a.repositionForWindowResize)};var Pj=function(){rn(md)&&md.repositionForWindowResize()||ce()};var Qj=function(a){df=a};var gf=function(a,
b,f,g){Pg(Rj,f,Sj,g);if(b.length){var l=sn(b,f,a);ef=l;tn(l,a,f);setTimeout(function(){l.focus()},1);df=null}else ff()};var sn=function(a,b,f){const g=new Qg;g.setRole(Mb.MENU);for(let l=0;l<a.length;l++){const n=a[l],x=new Rg(n.text);x.setRightToLeft(b);x.setRole(Mb.MENUITEM);g.addChild(x);x.setEnabled(n.enabled);if(n.enabled)x.onAction(function(){ff();requestAnimationFrame(()=>{setTimeout(()=>{n.callback(n.scope,f)},0)})},{})}return g};var tn=function(a,b,f){const g=Bi();b=new Ja(b.clientY+g.top,
b.clientY+g.top,b.clientX+g.left,b.clientX+g.left);un(a);const l=a.getSize();f&&(b.left+=l.width,b.right+=l.width,g.left+=l.width,g.right+=l.width);Oj(g,b,l,f);a.focus()};var un=function(a){var b=ld();if(!b)throw Error("Attempting to create a context menu when widget div is null");b=a.render(b);sa(b,"blocklyContextMenu");ta(b,"contextmenu",null,vn);a.focus()};var vn=function(a){a.preventDefault();a.stopPropagation()};var ff=function(){pd(Rj);df=null};var Sj=function(){ef&&(ef.dispose(),ef=null)};
d.callbackFactory$$module$build$src$core$contextmenu=function(a,b){return()=>{d.disable$$module$build$src$core$events$utils();let f;try{f=b instanceof Element?qd(b,a.workspace):Td(b,a.workspace);const g=a.getRelativeToSurfaceXY();g.x=a.RTL?g.x-d.config$$module$build$src$core$config.snapRadius:g.x+d.config$$module$build$src$core$config.snapRadius;g.y+=2*d.config$$module$build$src$core$config.snapRadius;f.moveBy(g.x,g.y)}finally{d.enable$$module$build$src$core$events$utils()}ia()&&!f.isShadow()&&aa(new (la(O.BLOCK_CREATE))(f));
d.setSelected$$module$build$src$core$common(f);return f}};var Tj=function(a,b){b=Kd(b,a.getParentSvg(),a.getInverseScreenCTM());b.x/=a.scale;b.y/=a.scale;return b};var Sg=function(a,b,f){b=Tj(a,b);Uj.set(a,fa.difference(f,b))};var Tg=function(a,b){b=Tj(a,b);a=Uj.get(a);if(!a)throw Error("Drag not initialized");return fa.sum(a,b)};var hf=function(a,b=!1){const f=d.createElement$$module$build$src$core$utils$xml("comment");b||f.setAttribute("id",a.id);b=a.workspace;const g=a.getRelativeToSurfaceXY();
g.x=b.RTL?b.getWidth()-g.x:g.x;f.setAttribute("x",`${g.x}`);f.setAttribute("y",`${g.y}`);f.setAttribute("w",`${a.getSize().width}`);f.setAttribute("h",`${a.getSize().height}`);a.getText()&&(f.textContent=a.getText());a.isCollapsed()&&f.setAttribute("collapsed","true");a.isOwnEditable()||f.setAttribute("editable","false");a.isOwnMovable()||f.setAttribute("movable","false");a.isOwnDeletable()||f.setAttribute("deletable","false");return f};var Vj=function(a){const b=d.createElement$$module$build$src$core$utils$xml("variables");
for(let f=0;f<a.length;f++){const g=a[f],l=d.createElement$$module$build$src$core$utils$xml("variable");l.appendChild(d.createTextNode$$module$build$src$core$utils$xml(g.name));g.type&&l.setAttribute("type",g.type);l.id=g.getId();b.appendChild(l)}return b};var jf=function(a,b){if(a.isInsertionMarker()&&(a=a.getChildren(!1)[0],!a))return new DocumentFragment;let f=0;a.workspace.RTL&&(f=a.workspace.getWidth());b=Kc(a,b);if(Wj(b)){const g=a.getRelativeToSurfaceXY();b.setAttribute("x",String(Math.round(a.workspace.RTL?
f-g.x:g.x)));b.setAttribute("y",String(Math.round(g.y)))}return b};var wn=function(a){if(a.isSerializable()){const b=d.createElement$$module$build$src$core$utils$xml("field");b.setAttribute("name",a.name||"");return a.toXml(b)}return null};var xn=function(a,b){for(let f=0;f<a.inputList.length;f++){const g=a.inputList[f];for(let l=0;l<g.fieldRow.length;l++){const n=wn(g.fieldRow[l]);n&&b.appendChild(n)}}};var Kc=function(a,b){if(a.isInsertionMarker())return(b=a.getChildren(!1)[0])?Kc(b):new DocumentFragment;
const f=d.createElement$$module$build$src$core$utils$xml(a.isShadow()?"shadow":"block");f.setAttribute("type",a.type);b||(f.id=a.id);if(a.mutationToDom){var g=a.mutationToDom();g&&(g.hasChildNodes()||g.hasAttributes())&&f.appendChild(g)}xn(a,f);if(g=a.getCommentText()){var l=a.getIcon(Xa.COMMENT),n=l.getBubbleSize();l=l.bubbleIsVisible();var x=d.createElement$$module$build$src$core$utils$xml("comment");x.appendChild(d.createTextNode$$module$build$src$core$utils$xml(g));x.setAttribute("pinned",`${l}`);
x.setAttribute("h",String(n.height));x.setAttribute("w",String(n.width));f.appendChild(x)}a.data&&(g=d.createElement$$module$build$src$core$utils$xml("data"),g.appendChild(d.createTextNode$$module$build$src$core$utils$xml(a.data)),f.appendChild(g));for(g=0;g<a.inputList.length;g++){n=a.inputList[g];var B=void 0;l=!0;if(n.type!==d.inputTypes$$module$build$src$core$inputs$input_types.DUMMY&&n.type!==d.inputTypes$$module$build$src$core$inputs$input_types.END_ROW){x=n.connection.targetBlock();n.type===
d.inputTypes$$module$build$src$core$inputs$input_types.VALUE?B=d.createElement$$module$build$src$core$utils$xml("value"):n.type===d.inputTypes$$module$build$src$core$inputs$input_types.STATEMENT&&(B=d.createElement$$module$build$src$core$utils$xml("statement"));const na=n.connection.getShadowDom();!na||x&&x.isShadow()||B.appendChild(Xj(na,b));x&&(x=Kc(x,b),x.nodeType===sc.ELEMENT_NODE&&(B.appendChild(x),l=!1));B.setAttribute("name",n.name);l||f.appendChild(B)}}void 0!==a.inputsInline&&a.inputsInline!==
a.inputsInlineDefault&&f.setAttribute("inline",String(a.inputsInline));a.isCollapsed()&&f.setAttribute("collapsed","true");a.isEnabled()||f.setAttribute("disabled-reasons",Array.from(a.getDisabledReasons()).map(encodeURIComponent).join(","));a.isOwnDeletable()||f.setAttribute("deletable","false");a.isOwnMovable()||f.setAttribute("movable","false");a.isOwnEditable()||f.setAttribute("editable","false");B=a.getNextBlock();let V;B&&(g=Kc(B,b),g.nodeType===sc.ELEMENT_NODE&&(V=d.createElement$$module$build$src$core$utils$xml("next"),
V.appendChild(g),f.appendChild(V)));a=a.nextConnection&&a.nextConnection.getShadowDom();!a||B&&B.isShadow()||V.appendChild(Xj(a,b));return f};var Xj=function(a,b){let f=a=a.cloneNode(!0),g;for(;f;)if(b&&"shadow"===f.nodeName&&f.removeAttribute("id"),f.firstChild)f=f.firstChild;else{for(;f&&!f.nextSibling;){g=f;f=f.parentNode;let l;g.nodeType===sc.TEXT_NODE&&""===g.data.trim()&&(null==(l=f)?void 0:l.firstChild)!==g&&Ia(g)}f&&(g=f,f=f.nextSibling,g.nodeType===sc.TEXT_NODE&&""===g.data.trim()&&Ia(g))}return a};
var Xb=function(a){return Md(a).replace(/<(\w+)([^<]*)\/>/g,"<$1$2></$1>")};d.domToWorkspace$$module$build$src$core$xml=function(a,b){let f=0;b.RTL&&(f=b.getWidth());const g=[];cd();const l=d.getGroup$$module$build$src$core$events$utils();l||d.setGroup$$module$build$src$core$events$utils(!0);b.setResizesEnabled&&b.setResizesEnabled(!1);let n=!0;try{for(let x=0,B;B=a.childNodes[x];x++){const V=B.nodeName.toLowerCase(),na=B;if("block"===V||"shadow"===V&&!ea()){const Pa=qd(na,b);g.push(Pa.id);let La;
const ib=parseInt(null!=(La=na.getAttribute("x"))?La:"10",10);let rd;const de=parseInt(null!=(rd=na.getAttribute("y"))?rd:"10",10);isNaN(ib)||isNaN(de)||Pa.moveBy(b.RTL?f-ib:ib,de,["create"]);n=!1}else{if("shadow"===V)throw TypeError("Shadow block cannot be a top-level block.");if("comment"===V)Yj(na,b);else if("variables"===V){if(n)Zj(na,b);else throw Error("'variables' tag must exist once before block and shadow tag elements in the workspace XML, but it was found in another location.");n=!1}}}}finally{d.setGroup$$module$build$src$core$events$utils(l),
b.setResizesEnabled&&b.setResizesEnabled(!0),b.rendered&&oc(),dd()}aa(new (la(O.FINISHED_LOADING))(b));return g};var Yj=function(a,b){var f;const g=null!=(f=a.getAttribute("id"))?f:void 0;f=b.rendered?new kf(b,g):new lf(b,g);var l;f.setText(null!=(l=a.textContent)?l:"");var n;l=parseInt(null!=(n=a.getAttribute("x"))?n:"",10);let x;n=parseInt(null!=(x=a.getAttribute("y"))?x:"",10);isNaN(l)||isNaN(n)||(l=b.RTL?b.getWidth()-l:l,f.moveTo(new fa(l,n)));var B;b=parseInt(null!=(B=a.getAttribute("w"))?B:
"",10);let V;B=parseInt(null!=(V=a.getAttribute("h"))?V:"",10);isNaN(b)||isNaN(B)||f.setSize(new Aa(b,B));"true"===a.getAttribute("collapsed")&&f.setCollapsed(!0);"false"===a.getAttribute("editable")&&f.setEditable(!1);"false"===a.getAttribute("movable")&&f.setMovable(!1);"false"===a.getAttribute("deletable")&&f.setDeletable(!1);return f};d.domToBlock$$module$build$src$core$xml=function(a,b){a=qd(a,b);b.rendered&&oc();return a};var qd=function(a,b){d.disable$$module$build$src$core$events$utils();
var f=b.getAllVariables();let g;try{if(g=Ug(a,b),b.rendered){const l=g,n=g.getDescendants(!1);l.setConnectionTracking(!1);for(let x=n.length-1;0<=x;x--)n[x].initSvg();for(let x=n.length-1;0<=x;x--)n[x].queueRender();setTimeout(function(){l.disposed||l.setConnectionTracking(!0)},1);b.resizeContents()}else{const l=g.getDescendants(!1);for(let n=l.length-1;0<=n;n--)l[n].initModel()}}finally{d.enable$$module$build$src$core$events$utils()}if(ia()){a=Te(b,f);for(b=0;b<a.length;b++)f=a[b],aa(new (la(O.VAR_CREATE))(f));
aa(new (la(O.BLOCK_CREATE))(g))}return g};var Zj=function(a,b){for(let g=0;g<a.children.length;g++){var f=a.children[g];const l=f.getAttribute("type"),n=f.getAttribute("id");f=f.textContent;if(!f)break;b.createVariable(f,l,n)}};var yn=function(a){const b={mutation:[],comment:[],data:[],field:[],input:[],next:[]};for(let f=0;f<a.children.length;f++){const g=a.children[f];if(g.nodeType!==sc.TEXT_NODE)switch(g.nodeName.toLowerCase()){case "mutation":b.mutation.push(g);break;case "comment":b.comment.push(g);
break;case "data":b.data.push(g);break;case "title":case "field":b.field.push(g);break;case "value":case "statement":b.input.push(g);break;case "next":b.next.push(g);break;default:console.warn("Ignoring unknown tag: "+g.nodeName)}}return b};var zn=function(a,b){let f=!1;for(let g=0;g<a.length;g++){const l=a[g];b.domToMutation&&(b.domToMutation(l),b.initSvg&&(f=!0))}return f};var An=function(a,b){for(let g=0;g<a.length;g++){var f=a[g];const l=f.textContent,n="true"===f.getAttribute("pinned");let x;
const B=parseInt(null!=(x=f.getAttribute("w"))?x:"50",10);let V;f=parseInt(null!=(V=f.getAttribute("h"))?V:"50",10);b.setCommentText(l);const na=b.getIcon(Xa.COMMENT);isNaN(B)||isNaN(f)||na.setBubbleSize(new Aa(B,f));na.setBubbleVisible(n);setTimeout(()=>na.setBubbleVisible(n),1)}};var Bn=function(a,b){for(let f=0;f<a.length;f++)b.data=a[f].textContent};var Dn=function(a,b){for(let f=0;f<a.length;f++){const g=a[f],l=g.getAttribute("name");l?Cn(b,l,g):console.warn(`Ignoring unnamed field in block ${b.type}`)}};
var ak=function(a){let b=null,f=null;for(let g=0;g<a.childNodes.length;g++){const l=a.childNodes[g];Wj(l)&&("block"===l.nodeName.toLowerCase()?b=l:"shadow"===l.nodeName.toLowerCase()&&(f=l))}return{childBlockElement:b,childShadowElement:f}};var En=function(a,b,f,g){for(let n=0;n<a.length;n++){var l=a[n];const x=l.getAttribute("name"),B=x?f.getInput(x):null;if(!B){console.warn("Ignoring non-existent input "+x+" in block "+g);break}l=ak(l);if(l.childBlockElement){if(!B.connection)throw TypeError("Input connection does not exist.");
Ug(l.childBlockElement,b,B.connection,!1)}if(l.childShadowElement){let V;null==(V=B.connection)||V.setShadowDom(l.childShadowElement)}}};var Fn=function(a,b,f){for(let g=0;g<a.length;g++){const l=ak(a[g]);if(l.childBlockElement){if(!f.nextConnection)throw TypeError("Next statement does not exist.");if(f.nextConnection.isConnected())throw TypeError("Next statement is already connected.");Ug(l.childBlockElement,b,f.nextConnection,!0)}l.childShadowElement&&f.nextConnection&&f.nextConnection.setShadowDom(l.childShadowElement)}};
var Ug=function(a,b,f,g){var l;const n=a.getAttribute("type");if(!n)throw TypeError("Block type unspecified: "+a.outerHTML);var x=null!=(l=a.getAttribute("id"))?l:void 0;l=b.newBlock(n,x);x=yn(a);const B=zn(x.mutation,l);An(x.comment,l);Bn(x.data,l);if(f)if(g)if(l.previousConnection)f.connect(l.previousConnection);else throw TypeError("Next block does not have previous statement.");else if(l.outputConnection)f.connect(l.outputConnection);else if(l.previousConnection)f.connect(l.previousConnection);
else throw TypeError("Child block does not have output or previous statement.");Dn(x.field,l);En(x.input,b,l,n);Fn(x.next,b,l);B&&l.initSvg();(b=a.getAttribute("inline"))&&l.setInputsInline("true"===b);(b=a.getAttribute("disabled"))&&l.setDisabledReason("true"===b||"disabled"===b,fb);b=a.getAttribute("disabled-reasons");if(null!==b)for(var V of b.split(","))l.setDisabledReason(!0,decodeURIComponent(V));(V=a.getAttribute("deletable"))&&l.setDeletable("true"===V);(V=a.getAttribute("movable"))&&l.setMovable("true"===
V);(V=a.getAttribute("editable"))&&l.setEditable("true"===V);(V=a.getAttribute("collapsed"))&&l.setCollapsed("true"===V);if("shadow"===a.nodeName.toLowerCase()){a=l.getChildren(!1);for(V=0;V<a.length;V++)if(!a[V].isShadow())throw TypeError("Shadow block not allowed non-shadow child.");l.setShadow(!0)}return l};var Cn=function(a,b,f){const g=a.getField(b);g?g.fromXml(f):console.warn("Ignoring non-existent field "+b+" in block "+a.type)};var Wj=function(a){return a.nodeType===sc.ELEMENT_NODE};var Vg=
function(a){if(!(100<a.getDescendants(!1).length)){var b=a.workspace,f=a.getSvgRoot();b.getAudioManager().play("delete");var g=a.getRelativeToSurfaceXY(),l=f.cloneNode(!0);l.setAttribute("transform","translate("+g.x+","+g.y+")");var n;null==(n=b.getLayerManager())||n.appendToAnimationLayer({getSvgRoot:()=>l});bk(l,{x:g.x,y:g.y,width:a.width,height:a.height},b.RTL,new Date)}};var bk=function(a,b,f,g){const l=((new Date).getTime()-g.getTime())/150;1<l?Ia(a):(a.setAttribute("transform","translate("+
(b.x+(f?-1:1)*b.width/2*l)+","+(b.y+b.height/2*l)+") scale("+(1-l)+")"),setTimeout(bk,10,a,b,f,g))};var Wg=function(a){var b=a.workspace;const f=b.scale;b.getAudioManager().play("click");if(!(1>f)){var g=b.getSvgXY(a.getSvgRoot());a.outputConnection?(g.x+=(a.RTL?3:-3)*f,g.y+=13*f):a.previousConnection&&(g.x+=(a.RTL?-23:23)*f,g.y+=3*f);var l=T(J.CIRCLE,{cx:g.x,cy:g.y,r:0,fill:"none",stroke:"#888","stroke-width":10},b.getParentSvg());a=T(J.ANIMATE,{id:"animationCircle",begin:"indefinite",attributeName:"r",
dur:"150ms",from:0,to:25*f},l);b=T(J.ANIMATE,{id:"animationOpacity",begin:"indefinite",attributeName:"opacity",dur:"150ms",from:1,to:0},l);a.beginElement();b.beginElement();setTimeout(()=>void Ia(l),150)}};var dk=function(a){ee();a.workspace.getAudioManager().play("disconnect");if(!(1>a.workspace.scale)){var b=a.getHeightWidth().height;b=Math.atan(10/b)/Math.PI*180;a.RTL||(b*=-1);fe=a;ck(a,b,new Date,0)}};var ck=function(a,b,f,g){const l=[.66,1,.66,0,-.66,-1,-.66,0];let n="";f.getTime()+200>(new Date).getTime()&&
(n=`skewX(${Math.round(l[g%l.length]*b)})`,mf=setTimeout(ck,15,a,b,f,g+1));a.getSvgRoot().setAttribute("transform",`${a.getTranslation()} ${n}`)};var ee=function(){fe&&(mf&&(clearTimeout(mf),mf=null),fe.getSvgRoot().setAttribute("transform",fe.getTranslation()),fe=null)};var sd=function(a){return void 0!==a.getRelativeToSurfaceXY&&void 0!==a.isMovable&&void 0!==a.startDrag&&void 0!==a.drag&&void 0!==a.endDrag&&void 0!==a.revertDrag};var tc=function(a,b){for(const f in b)a[f]=null!==b[f]&&"object"===
typeof b[f]?tc(a[f]||Object.create(null),b[f]):b[f];return a};var Zb=function(a,b){e(ba.FIELD,a,b)};d.fromJson$$module$build$src$core$field_registry=function(a){return ek.fromJsonInternal(a)};d.register$$module$build$src$core$extensions=function(a,b){if("string"!==typeof a||""===a.trim())throw Error('Error: Invalid extension name "'+a+'"');if(td[a])throw Error('Error: Extension "'+a+'" is already registered.');if("function"!==typeof b)throw Error('Error: Extension "'+a+'" must be a function');td[a]=
b};d.registerMixin$$module$build$src$core$extensions=function(a,b){if(!b||"object"!==typeof b)throw Error('Error: Mixin "'+a+'" must be a object');d.register$$module$build$src$core$extensions(a,function(){this.mixin(b)})};d.registerMutator$$module$build$src$core$extensions=function(a,b,f,g){const l='Error when registering mutator "'+a+'": ';fk(l,b);const n=gk(b,l);if(f&&"function"!==typeof f)throw Error(l+'Extension "'+a+'" is not a function');d.register$$module$build$src$core$extensions(a,function(){n&&
this.setMutator(new d.MutatorIcon$$module$build$src$core$icons$mutator_icon(g||[],this));this.mixin(b);f&&f.apply(this)})};var hk=function(a){return!!td[a]};var Yg=function(a,b,f){const g=td[a];if("function"!==typeof g)throw Error('Error: Extension "'+a+'" not found.');let l;f?Gn(a,b):l=Xg(b);g.apply(b);if(f)fk('Error after applying mutator "'+a+'": ',b);else if(!Hn(l,b))throw Error('Error when applying extension "'+a+'": mutation properties changed when applying a non-mutator extension.');};var Gn=
function(a,b){if(Xg(b).length)throw Error('Error: tried to apply mutation "'+a+'" to a block that already has mutator functions.  Block id: '+b.id);};var In=function(a,b){return Zg(a.mutationToDom,a.domToMutation,b+" mutationToDom/domToMutation")};var Jn=function(a,b){return Zg(a.saveExtraState,a.loadExtraState,b+" saveExtraState/loadExtraState")};var gk=function(a,b){return Zg(a.compose,a.decompose,b+" compose/decompose")};var Zg=function(a,b,f){if(a&&b){if("function"!==typeof a||"function"!==typeof b)throw Error(f+
" must be a function");return!0}if(!a&&!b)return!1;throw Error(f+"Must have both or neither functions");};var fk=function(a,b){const f=In(b,a),g=Jn(b,a);if(!f&&!g)throw Error(a+"Mutations must contain either XML hooks, or JSON hooks, or both");gk(b,a)};var Xg=function(a){const b=[];void 0!==a.domToMutation&&b.push(a.domToMutation);void 0!==a.mutationToDom&&b.push(a.mutationToDom);void 0!==a.saveExtraState&&b.push(a.saveExtraState);void 0!==a.loadExtraState&&b.push(a.loadExtraState);void 0!==a.compose&&
b.push(a.compose);void 0!==a.decompose&&b.push(a.decompose);return b};var Hn=function(a,b){b=Xg(b);if(b.length!==a.length)return!1;for(let f=0;f<b.length;f++)if(a[f]!==b[f])return!1;return!0};d.buildTooltipForDropdown$$module$build$src$core$extensions=function(a,b){const f=[];return function(){f.includes(this.type)||(Kn(this,a,b),f.push(this.type));this.setTooltip(function(){const g=String(this.getFieldValue(a));return Ua(b[g])}.bind(this))}};var Kn=function(a,b,f){var g=a.getField(b);if(g instanceof
jb&&!g.isOptionListDynamic()){g=g.getOptions();for(const [,l]of g)void 0===f[l]&&console.warn(`No tooltip mapping for value ${l} of field `+`${b} of block type ${a.type}.`)}};d.buildTooltipWithFieldText$$module$build$src$core$extensions=function(a,b){return function(){this.setTooltip(function(){const f=this.getField(b);return Ua(a).replace("%1",f?f.getText():"")}.bind(this))}};var qa=function(a,b){return" "+a+","+b+" "};var nb=function(a,b){return" "+a+b.join("")};var Za=function(a,b){return" M "+
a+","+b+" "};var Oa=function(a,b){return" m "+a+","+b+" "};var $b=function(a,b){return" l "+a+","+b+" "};var ge=function(a){return" l"+a.join("")};var pa=function(a,b){return" "+a+" "+b+" "};var Va=function(a,b,f,g){return a+" "+f+" "+f+" "+b+g};var ik=function(a,b){e(ba.ICON,a.toString(),b)};var Lc=function(a){return void 0!==a.getProcedureModel&&void 0!==a.doProcedureUpdate&&void 0!==a.isProcedureDef};var $g=function(a){return void 0!==a.startPublishing&&void 0!==a.stopPublishing};var ah=function(a){const b=
a.getProcedureMap().getProcedures().filter(g=>!g.getReturnTypes()).map(g=>[g.getName(),g.getParameters().map(l=>l.getName()),!1]);a.getBlocksByType("procedures_defnoreturn",!1).forEach(g=>{!Lc(g)&&Qd(g)&&b.push(g.getProcedureDef())});const f=a.getProcedureMap().getProcedures().filter(g=>!!g.getReturnTypes()).map(g=>[g.getName(),g.getParameters().map(l=>l.getName()),!0]);a.getBlocksByType("procedures_defreturn",!1).forEach(g=>{!Lc(g)&&Qd(g)&&f.push(g.getProcedureDef())});b.sort(jk);f.sort(jk);return[b,
f]};var jk=function(a,b){return a[0].localeCompare(b[0],void 0,{sensitivity:"base"})};d.findLegalName$$module$build$src$core$procedures=function(a,b){if(b.isInFlyout)return a;for(a=a||d.Msg$$module$build$src$core$msg.UNNAMED_KEY||"unnamed";!Ln(a,b.workspace,b);){const f=a.match(/^(.*?)(\d+)$/);a=f?f[1]+(parseInt(f[2])+1):a+"2"}return a};var Ln=function(a,b,f){return!kk(a,b,f)};var kk=function(a,b,f){for(const g of b.getAllBlocks(!1))if(g!==f&&Qd(g)&&d.Names$$module$build$src$core$names.equals(g.getProcedureDef()[0],
a))return!0;f=f&&Lc(f)?null==f?void 0:f.getProcedureModel():void 0;for(const g of b.getProcedureMap().getProcedures())if(g!==f&&d.Names$$module$build$src$core$names.equals(g.getName(),a))return!0;return!1};d.rename$$module$build$src$core$procedures=function(a){var b=this.getSourceBlock();if(!b)throw new Ta;a=a.trim();const f=d.findLegalName$$module$build$src$core$procedures(a,b);Lc(b)&&!b.isInsertionMarker()&&b.getProcedureModel().setName(f);const g=this.getValue();if(g!==a&&g!==f)for(a=b.workspace.getAllBlocks(!1),
b=0;b<a.length;b++){const l=a[b];l.renameProcedure&&l.renameProcedure(g,f)}return f};var bh=function(a){function b(n,x){for(let V=0;V<n.length;V++){var B=n[V][0];const na=n[V][1],Pa=d.createElement$$module$build$src$core$utils$xml("block");Pa.setAttribute("type",x);Pa.setAttribute("gap","16");const La=d.createElement$$module$build$src$core$utils$xml("mutation");La.setAttribute("name",B);Pa.appendChild(La);for(B=0;B<na.length;B++){const ib=d.createElement$$module$build$src$core$utils$xml("arg");ib.setAttribute("name",
na[B]);La.appendChild(ib)}f.push(Pa)}}const f=[];if(hb.procedures_defnoreturn){var g=d.createElement$$module$build$src$core$utils$xml("block");g.setAttribute("type","procedures_defnoreturn");g.setAttribute("gap","16");var l=d.createElement$$module$build$src$core$utils$xml("field");l.setAttribute("name","NAME");l.appendChild(d.createTextNode$$module$build$src$core$utils$xml(d.Msg$$module$build$src$core$msg.PROCEDURES_DEFNORETURN_PROCEDURE));g.appendChild(l);f.push(g)}hb.procedures_defreturn&&(g=d.createElement$$module$build$src$core$utils$xml("block"),
g.setAttribute("type","procedures_defreturn"),g.setAttribute("gap","16"),l=d.createElement$$module$build$src$core$utils$xml("field"),l.setAttribute("name","NAME"),l.appendChild(d.createTextNode$$module$build$src$core$utils$xml(d.Msg$$module$build$src$core$msg.PROCEDURES_DEFRETURN_PROCEDURE)),g.appendChild(l),f.push(g));hb.procedures_ifreturn&&(g=d.createElement$$module$build$src$core$utils$xml("block"),g.setAttribute("type","procedures_ifreturn"),g.setAttribute("gap","16"),f.push(g));f.length&&f[f.length-
1].setAttribute("gap","24");a=ah(a);b(a[0],"procedures_callnoreturn");b(a[1],"procedures_callreturn");return f};var lk=function(a){var b=[],f=a.getBlocksByType("procedures_mutatorarg",!1);for(let n=0,x;x=f[n];n++)b.push(x.getFieldValue("NAME"));f=d.createElement$$module$build$src$core$utils$xml("xml");const g=d.createElement$$module$build$src$core$utils$xml("block");g.setAttribute("type","procedures_mutatorarg");const l=d.createElement$$module$build$src$core$utils$xml("field");l.setAttribute("name",
"NAME");b=sg(d.DEFAULT_ARG$$module$build$src$core$procedures,b);b=d.createTextNode$$module$build$src$core$utils$xml(b);l.appendChild(b);g.appendChild(l);f.appendChild(g);a.updateToolbox(f)};var mk=function(a){if(P(a)&&"mutator"===a.bubbleType&&a.isOpen&&a.blockId){a=ua(a.workspaceId).getBlockById(a.blockId);var b=a.type;if("procedures_defnoreturn"===b||"procedures_defreturn"===b)a=a.getIcon(d.MutatorIcon$$module$build$src$core$icons$mutator_icon.TYPE).getWorkspace(),lk(a),a.addChangeListener(Mn)}};
var Mn=function(a){if(N(a)||H(a)||K(a)||C(a))a=ua(a.workspaceId),lk(a)};var nk=function(a,b){return b.getAllBlocks(!1).filter(f=>Nn(f,a)||Km(f)&&d.Names$$module$build$src$core$names.equals(f.getProcedureCall(),a))};var Nn=function(a,b){return Lc(a)&&!a.isProcedureDef()&&a.getProcedureModel()&&d.Names$$module$build$src$core$names.equals(a.getProcedureModel().getName(),b)};d.mutateCallers$$module$build$src$core$procedures=function(a){const b=ea();var f=a.getProcedureDef()[0];const g=a.mutationToDom(!0);
a=nk(f,a.workspace);for(let n=0,x;x=a[n];n++){f=(f=x.mutationToDom())&&Md(f);x.domToMutation&&x.domToMutation(g);var l=x.mutationToDom();l=l&&Md(l);f!==l&&(d.setRecordUndo$$module$build$src$core$events$utils(!1),aa(new (la(O.BLOCK_CHANGE))(x,"mutation",null,f,l)),d.setRecordUndo$$module$build$src$core$events$utils(b))}};d.getDefinition$$module$build$src$core$procedures=function(a,b){for(const f of b.getAllBlocks(!1))if(Lc(f)&&f.isProcedureDef()&&d.Names$$module$build$src$core$names.equals(f.getProcedureModel().getName(),
a)||Qd(f)&&d.Names$$module$build$src$core$names.equals(f.getProcedureDef()[0],a))return f;return null};var ch=function(a){return a.isDynamic};var On=function(a){return void 0!==a.pathDown&&void 0!==a.pathUp};var Pn=function(a){return void 0!==a.pathLeft&&void 0!==a.pathRight};var Qn=function(a,b){if(!a||!b)throw Error("Cannot connect null connections.");a.targetConnection=b;b.targetConnection=a};var Rn=function(a,b){let f=null;b=b.outputConnection;const g=null==b?void 0:b.getConnectionChecker();for(let l=
0,n;n=a.inputList[l];l++){const x=n.connection;let B;if(x&&(null==(B=g)?0:B.canConnect(b,x,!1))){if(f)return null;f=x}}return f};var Sn=function(a,b){let f;for(;f=Rn(a,b);)if(a=f.targetBlock(),!a||a.isShadow())return f;return null};var ok=function(a){return void 0!==a.getType&&void 0!==a.initView&&void 0!==a.dispose&&void 0!==a.getWeight&&void 0!==a.getSize&&void 0!==a.applyColour&&void 0!==a.hideForInsertionMarker&&void 0!==a.updateEditable&&void 0!==a.updateCollapsed&&void 0!==a.isShownWhenCollapsed&&
void 0!==a.setOffsetInBlock&&void 0!==a.onLocationChange&&void 0!==a.onClick};var Tn=function(a){return ok(a)&&Vd(a)&&Qe(a)&&void 0!==a.setText&&void 0!==a.getText&&void 0!==a.setBubbleSize&&void 0!==a.getBubbleSize&&a.getType()===Xa.COMMENT};var nf=function(a){let b=a.outputConnection;if(!b||a.previousConnection&&a.previousConnection.isConnected())b=a.previousConnection;return b};var of=function(a,b){e(ba.RENDERER,a,b)};var pk=function(a,b,f){a=new (t(ba.RENDERER,a))(a);a.init(b,f);return a};var qk=
function(a){Rd(a.getTargetWorkspace(),void 0,"String")};var rk=function(a){Rd(a.getTargetWorkspace(),void 0,"Number")};var sk=function(a){Rd(a.getTargetWorkspace(),void 0,"Colour")};var dh=function(a){let b=[],f=document.createElement("button");f.setAttribute("text",d.Msg$$module$build$src$core$msg.NEW_STRING_VARIABLE);f.setAttribute("callbackKey","CREATE_VARIABLE_STRING");b.push(f);f=document.createElement("button");f.setAttribute("text",d.Msg$$module$build$src$core$msg.NEW_NUMBER_VARIABLE);f.setAttribute("callbackKey",
"CREATE_VARIABLE_NUMBER");b.push(f);f=document.createElement("button");f.setAttribute("text",d.Msg$$module$build$src$core$msg.NEW_COLOUR_VARIABLE);f.setAttribute("callbackKey","CREATE_VARIABLE_COLOUR");b.push(f);a.registerButtonCallback("CREATE_VARIABLE_STRING",qk);a.registerButtonCallback("CREATE_VARIABLE_NUMBER",rk);a.registerButtonCallback("CREATE_VARIABLE_COLOUR",sk);a=tk(a);return b.concat(a)};var tk=function(a){a=a.getAllVariables();const b=[];if(0<a.length){if(hb.variables_set_dynamic){var f=
a[a.length-1];const g=d.createElement$$module$build$src$core$utils$xml("block");g.setAttribute("type","variables_set_dynamic");g.setAttribute("gap","24");g.appendChild(ed(f));b.push(g)}if(hb.variables_get_dynamic){a.sort(Sd.compareByName);for(let g=0,l;l=a[g];g++)f=d.createElement$$module$build$src$core$utils$xml("block"),f.setAttribute("type","variables_get_dynamic"),f.setAttribute("gap","8"),f.appendChild(ed(l)),b.push(f)}}return b};var Wn=function(a,b){const f=a.workspace,g=d.config$$module$build$src$core$config.snapRadius,
l=fa.difference(b,a.getRelativeToSurfaceXY()),n=new fa(0,0),x=f.getAllBlocks(!1).filter(B=>B.id!=a.id).map(B=>B.getRelativeToSurfaceXY());for(;Un(fa.sum(b,n),x)||Vn(a,fa.sum(l,n),g);)f.RTL?n.translate(-g,2*g):n.translate(g,2*g);a.moveTo(fa.sum(b,n))};var Un=function(a,b){return b.some(f=>1>=Math.abs(f.x-a.x)&&1>=Math.abs(f.y-a.y))};var Vn=function(a,b,f){return a.getConnections_(!1).some(g=>!!g.closest(f,b).connection)};var he=function(a,b,f){const g=f.getBoundingRectangle(),l=g.right-g.left,n=Wd(b.top,
g.top,b.top+b.height-(g.bottom-g.top))-g.top;let x=b.left;b=b.left+b.width-l;a.RTL?x=Math.min(b,x):b=Math.max(x,b);return(a=Wd(x,g.left,b)-g.left)||n?(f.moveBy(a,n,["inbounds"]),!0):!1};var vk=function(a){return b=>{var f=a.getMetricsManager();if(f.hasFixedEdges()&&!a.isDragging()){var g;if(uk.includes(null!=(g=b.type)?g:"")){g=f.getScrollMetrics(!0);const l=Xn(a,b);l&&(f=d.getGroup$$module$build$src$core$events$utils()||!1,d.setGroup$$module$build$src$core$events$utils(b.group),he(a,g,l)&&!b.group&&
console.warn("Moved object in bounds but there was no event group. This may break undo."),d.setGroup$$module$build$src$core$events$utils(f))}else ha(b)&&b.scale&&b.oldScale&&b.scale>b.oldScale&&eh(a)}}};var Xn=function(a,b){let f=null;switch(b.type){case O.BLOCK_CREATE:case O.BLOCK_MOVE:(f=a.getBlockById(b.blockId))&&(f=f.getRootBlock());break;case O.COMMENT_CREATE:case O.COMMENT_MOVE:case O.COMMENT_RESIZE:f=a.getCommentById(b.commentId)}return f};var eh=function(a){var b=a.getMetricsManager();if(b.hasFixedEdges()&&
!a.isDragging()){b=b.getScrollMetrics(!0);var f=a.getTopBoundedElements();for(let g=0,l;l=f[g];g++)he(a,b,l)}};var Db=function(a){return void 0!==a.isDeletable&&void 0!==a.dispose&&void 0!==a.setDeleteStyle};var Mc=function(a,b,f){return a&&b?wk(a,b,f):fh&&gh?wk(fh,gh):null};var wk=function(a,b,f){let g;b=b.isMutator?b:null!=(g=b.getRootWorkspace())?g:b;let l,n;return null!=(n=null==(l=q(ba.PASTER,a.paster,!1))?void 0:l.paste(a,b,f))?n:null};var pf=function(a){return void 0!==a.toCopyData};var xk=
function(){Fa.registry.register({name:ac.ESCAPE,preconditionFn(a){return!a.options.readOnly},callback(a){a.hideChaff();return!0},keyCodes:[ya.ESC]})};var yk=function(){Fa.registry.register({name:ac.DELETE,preconditionFn(a){const b=U();return!a.options.readOnly&&null!=b&&Db(b)&&b.isDeletable()&&!bc.inProgress()},callback(a,b){b.preventDefault();a=U();a instanceof xb?a.checkAndDelete():Db(a)&&a.isDeletable()&&(d.setGroup$$module$build$src$core$events$utils(!0),a.dispose(),d.setGroup$$module$build$src$core$events$utils(!1));
return!0},keyCodes:[ya.DELETE,ya.BACKSPACE]})};var zk=function(){const a=Fa.registry.createSerializedKey(ya.C,[ya.CTRL]),b=Fa.registry.createSerializedKey(ya.C,[ya.ALT]),f=Fa.registry.createSerializedKey(ya.C,[ya.META]);Fa.registry.register({name:ac.COPY,preconditionFn(g){const l=U();return!g.options.readOnly&&!bc.inProgress()&&null!=l&&Db(l)&&l.isDeletable()&&sd(l)&&l.isMovable()&&pf(l)},callback(g,l){l.preventDefault();g.hideChaff();l=U();if(!l||!pf(l))return!1;uc=l.toCopyData();vc=l.workspace instanceof
ob?l.workspace:g;ud=sd(l)?l.getRelativeToSurfaceXY():null;return!!uc},keyCodes:[a,b,f]})};var Ak=function(){const a=Fa.registry.createSerializedKey(ya.X,[ya.CTRL]),b=Fa.registry.createSerializedKey(ya.X,[ya.ALT]),f=Fa.registry.createSerializedKey(ya.X,[ya.META]);Fa.registry.register({name:ac.CUT,preconditionFn(g){const l=U();return!g.options.readOnly&&!bc.inProgress()&&null!=l&&Db(l)&&l.isDeletable()&&sd(l)&&l.isMovable()&&!l.workspace.isFlyout},callback(g){const l=U();return l instanceof xb?(uc=
l.toCopyData(),vc=g,ud=l.getRelativeToSurfaceXY(),l.checkAndDelete(),!0):Db(l)&&l.isDeletable()&&pf(l)?(uc=l.toCopyData(),vc=g,ud=sd(l)?l.getRelativeToSurfaceXY():null,l.dispose(),!0):!1},keyCodes:[a,b,f]})};var Bk=function(){const a=Fa.registry.createSerializedKey(ya.V,[ya.CTRL]),b=Fa.registry.createSerializedKey(ya.V,[ya.ALT]),f=Fa.registry.createSerializedKey(ya.V,[ya.META]);Fa.registry.register({name:ac.PASTE,preconditionFn(g){return!g.options.readOnly&&!bc.inProgress()},callback(){if(!uc||!vc)return!1;
if(!ud)return!!Mc(uc,vc);const {left:g,top:l,width:n,height:x}=vc.getMetricsManager().getViewMetrics(!0);if((new Ja(l,l+x,g,g+n)).contains(ud.x,ud.y))return!!Mc(uc,vc);const B=new fa(g+n/2,l+x/2);return!!Mc(uc,vc,B)},keyCodes:[a,b,f]})};var Ck=function(){const a=Fa.registry.createSerializedKey(ya.Z,[ya.CTRL]),b=Fa.registry.createSerializedKey(ya.Z,[ya.ALT]),f=Fa.registry.createSerializedKey(ya.Z,[ya.META]);Fa.registry.register({name:ac.UNDO,preconditionFn(g){return!g.options.readOnly&&!bc.inProgress()},
callback(g,l){g.hideChaff();g.undo(!1);l.preventDefault();return!0},keyCodes:[a,b,f]})};var Dk=function(){const a=Fa.registry.createSerializedKey(ya.Z,[ya.SHIFT,ya.CTRL]),b=Fa.registry.createSerializedKey(ya.Z,[ya.SHIFT,ya.ALT]),f=Fa.registry.createSerializedKey(ya.Z,[ya.SHIFT,ya.META]),g=Fa.registry.createSerializedKey(ya.Y,[ya.CTRL]);Fa.registry.register({name:ac.REDO,preconditionFn(l){return!bc.inProgress()&&!l.options.readOnly},callback(l,n){l.hideChaff();l.undo(!0);n.preventDefault();return!0},
keyCodes:[a,b,f,g]})};var Ek=function(){xk();yk();zk();Ak();Bk();Ck();Dk()};var Fk=function(a){const b=a.saveState();if(!a.getParameters().length)return b;b.parameters=a.getParameters().map(f=>f.saveState());return b};var Gk=function(a,b,f,g){a=a.loadState(f,g);if(!f.parameters)return a;for(const [l,n]of f.parameters.entries())a.insertParameter(b.loadState(n,g),l);return a};var Yn=function(a,b){a.setAttribute("dir","LTR");si(b.hasCss,b.pathToMedia);a=T(J.SVG,{xmlns:Ld,"xmlns:html":Nb,"xmlns:xlink":pb,
version:"1.1","class":"blocklySvg",tabindex:"0"},a);const f=T(J.DEFS,{},a),g=String(Math.random()).substring(2);b.gridPattern=hh.createDom(g,b.gridOptions,f);return a};var Zn=function(a,b,f){f.parentWorkspace=null;f=new ob(f);const g=f.options;f.scale=g.zoomOptions.startScale;b.appendChild(f.createDom("blocklyMainBackground",a));var l=f.getRenderer().getClassName();l&&sa(a,l);(l=f.getTheme().getClassName())&&sa(a,l);!g.hasCategories&&g.languageTree&&(a=f.addFlyout(J.SVG),ad(a,b));g.hasTrashcan&&f.addTrashcan();
g.zoomOptions&&g.zoomOptions.controls&&f.addZoomControls();f.getThemeManager().subscribe(b,"workspaceBackgroundColour","background-color");f.translate(0,0);f.addChangeListener(vk(f));A(f);Lj();dj();xj();return f};var bo=function(a){const b=a.options;var f=a.getParentSvg();ta(f.parentNode,"contextmenu",null,function(g){Jd(g)||g.preventDefault()});f=ta(window,"resize",null,function(){rc();a.hideComponents(!0);sj();Pj();A(a);eh(a)});a.setResizeHandlerWrapper(f);$n();if(b.languageTree){f=a.getToolbox();
const g=a.getFlyout(!0);f?f.init():g&&(g.init(a),g.show(b.languageTree),"function"===typeof g.scrollToStart&&g.scrollToStart())}b.hasTrashcan&&a.trashcan.init();b.zoomOptions&&b.zoomOptions.controls&&a.zoomControls_.init();b.moveOptions&&b.moveOptions.scrollbars?(a.scrollbar=new ih(a,!0===b.moveOptions.scrollbars||!!b.moveOptions.scrollbars.horizontal,!0===b.moveOptions.scrollbars||!!b.moveOptions.scrollbars.vertical,"blocklyMainWorkspaceScrollbar"),a.scrollbar.resize()):a.setMetrics({x:.5,y:.5});
b.hasSounds&&ao(b.pathToMedia,a)};var jh=function(a){const b=z();if(b&&!(Jd(a)||b.rendered&&!b.isVisible()))Fa.registry.onKeyDown(b,a)};var $n=function(){Hk||(ta(document,"scroll",null,function(){const a=va();for(let b=0,f;f=a[b];b++)f instanceof ob&&f.updateInverseScreenCTM()}),lb(document,"touchend",null,wa),lb(document,"touchcancel",null,wa));Hk=!0};var ao=function(a,b){function f(){for(;l.length;){const n=l.pop();n&&Na(n)}g.preload()}const g=b.getAudioManager();g.load([a+"click.mp3",a+"click.wav",
a+"click.ogg"],"click");g.load([a+"disconnect.wav",a+"disconnect.mp3",a+"disconnect.ogg"],"disconnect");g.load([a+"delete.mp3",a+"delete.ogg",a+"delete.wav"],"delete");const l=[];l.push(ta(document,"pointermove",null,f,!0));l.push(ta(document,"touchstart",null,f,!0))};var Ik=function(){za.registry.register({displayText(){return d.Msg$$module$build$src$core$msg.UNDO},preconditionFn(a){return 0<a.workspace.getUndoStack().length?"enabled":"disabled"},callback(a){a.workspace.undo(!1)},scopeType:za.ScopeType.WORKSPACE,
id:"undoWorkspace",weight:1})};var Jk=function(){za.registry.register({displayText(){return d.Msg$$module$build$src$core$msg.REDO},preconditionFn(a){return 0<a.workspace.getRedoStack().length?"enabled":"disabled"},callback(a){a.workspace.undo(!0)},scopeType:za.ScopeType.WORKSPACE,id:"redoWorkspace",weight:2})};var Kk=function(){za.registry.register({displayText(){return d.Msg$$module$build$src$core$msg.CLEAN_UP},preconditionFn(a){return a.workspace.isMovable()?1<a.workspace.getTopBlocks(!1).length?
"enabled":"disabled":"hidden"},callback(a){a.workspace.cleanUp()},scopeType:za.ScopeType.WORKSPACE,id:"cleanWorkspace",weight:3})};var Lk=function(a,b){function f(n){l--;n.setCollapsed(a);0===l&&d.setGroup$$module$build$src$core$events$utils(!1)}let g=0,l=0;d.setGroup$$module$build$src$core$events$utils(!0);for(let n=0;n<b.length;n++){let x=b[n];for(;x;)l++,setTimeout(f.bind(null,x),g),x=x.getNextBlock(),g+=10}};var Mk=function(){za.registry.register({displayText(){return d.Msg$$module$build$src$core$msg.COLLAPSE_ALL},
preconditionFn(a){if(a.workspace.options.collapse){a=a.workspace.getTopBlocks(!1);for(let b=0;b<a.length;b++){let f=a[b];for(;f;){if(!f.isCollapsed())return"enabled";f=f.getNextBlock()}}return"disabled"}return"hidden"},callback(a){Lk(!0,a.workspace.getTopBlocks(!0))},scopeType:za.ScopeType.WORKSPACE,id:"collapseWorkspace",weight:4})};var Nk=function(){za.registry.register({displayText(){return d.Msg$$module$build$src$core$msg.EXPAND_ALL},preconditionFn(a){if(a.workspace.options.collapse){a=a.workspace.getTopBlocks(!1);
for(let b=0;b<a.length;b++){let f=a[b];for(;f;){if(f.isCollapsed())return"enabled";f=f.getNextBlock()}}return"disabled"}return"hidden"},callback(a){Lk(!1,a.workspace.getTopBlocks(!0))},scopeType:za.ScopeType.WORKSPACE,id:"expandWorkspace",weight:5})};var Ok=function(a,b){if(a.isDeletable())Array.prototype.push.apply(b,a.getDescendants(!1));else{a=a.getChildren(!1);for(let f=0;f<a.length;f++)Ok(a[f],b)}};var kh=function(a){const b=[];a=a.getTopBlocks(!0);for(let f=0;f<a.length;f++)Ok(a[f],b);return b};
var qf=function(a,b){b?d.setGroup$$module$build$src$core$events$utils(b):(d.setGroup$$module$build$src$core$events$utils(!0),b=d.getGroup$$module$build$src$core$events$utils());const f=a.shift();f&&(f.isDeadOrDying()?qf(a,b):(f.dispose(!1,!0),setTimeout(qf,10,a,b)));d.setGroup$$module$build$src$core$events$utils(!1)};var Pk=function(){za.registry.register({displayText(a){if(!a.workspace)return"";a=kh(a.workspace).length;return 1===a?d.Msg$$module$build$src$core$msg.DELETE_BLOCK:d.Msg$$module$build$src$core$msg.DELETE_X_BLOCKS.replace("%1",
`${a}`)},preconditionFn(a){return a.workspace?0<kh(a.workspace).length?"enabled":"disabled":"disabled"},callback(a){if(a.workspace){a.workspace.cancelCurrentGesture();var b=kh(a.workspace);2>b.length?qf(b):og(d.Msg$$module$build$src$core$msg.DELETE_ALL_BLOCKS.replace("%1",String(b.length)),function(f){f&&qf(b)})}},scopeType:za.ScopeType.WORKSPACE,id:"workspaceDelete",weight:6})};var co=function(){Ik();Jk();Kk();Mk();Nk();Pk()};var Qk=function(){za.registry.register({displayText(){return d.Msg$$module$build$src$core$msg.DUPLICATE_BLOCK},
preconditionFn(a){a=a.block;return!a.isInFlyout&&a.isDeletable()&&a.isMovable()?a.isDuplicatable()?"enabled":"disabled":"hidden"},callback(a){if(a.block){var b=a.block.toCopyData();b&&Mc(b,a.block.workspace)}},scopeType:za.ScopeType.BLOCK,id:"blockDuplicate",weight:1})};var Rk=function(){za.registry.register({displayText(a){return a.block.hasIcon(cc.TYPE)?d.Msg$$module$build$src$core$msg.REMOVE_COMMENT:d.Msg$$module$build$src$core$msg.ADD_COMMENT},preconditionFn(a){a=a.block;return!a.isInFlyout&&
a.workspace.options.comments&&!a.isCollapsed()&&a.isEditable()?"enabled":"hidden"},callback(a){a=a.block;a.hasIcon(cc.TYPE)?a.setCommentText(null):a.setCommentText("")},scopeType:za.ScopeType.BLOCK,id:"blockComment",weight:2})};var Sk=function(){za.registry.register({displayText(a){return a.block.getInputsInline()?d.Msg$$module$build$src$core$msg.EXTERNAL_INPUTS:d.Msg$$module$build$src$core$msg.INLINE_INPUTS},preconditionFn(a){a=a.block;if(!a.isInFlyout&&a.isMovable()&&!a.isCollapsed())for(let b=
1;b<a.inputList.length;b++)if(!(a.inputList[b-1]instanceof rf||a.inputList[b]instanceof rf))return"enabled";return"hidden"},callback(a){a.block.setInputsInline(!a.block.getInputsInline())},scopeType:za.ScopeType.BLOCK,id:"blockInline",weight:3})};var Tk=function(){za.registry.register({displayText(a){return a.block.isCollapsed()?d.Msg$$module$build$src$core$msg.EXPAND_BLOCK:d.Msg$$module$build$src$core$msg.COLLAPSE_BLOCK},preconditionFn(a){a=a.block;return!a.isInFlyout&&a.isMovable()&&a.workspace.options.collapse?
"enabled":"hidden"},callback(a){a.block.setCollapsed(!a.block.isCollapsed())},scopeType:za.ScopeType.BLOCK,id:"blockCollapseExpand",weight:4})};var Uk=function(){za.registry.register({displayText(a){return a.block.hasDisabledReason(fb)?d.Msg$$module$build$src$core$msg.ENABLE_BLOCK:d.Msg$$module$build$src$core$msg.DISABLE_BLOCK},preconditionFn(a){a=a.block;if(!a.isInFlyout&&a.workspace.options.disable&&a.isEditable()){var b=a.getDisabledReasons();b=b.size>(b.has(fb)?1:0);return a.getInheritedDisabled()||
b?"disabled":"enabled"}return"hidden"},callback(a){a=a.block;const b=d.getGroup$$module$build$src$core$events$utils();b||d.setGroup$$module$build$src$core$events$utils(!0);a.setDisabledReason(!a.hasDisabledReason(fb),fb);d.setGroup$$module$build$src$core$events$utils(b)},scopeType:za.ScopeType.BLOCK,id:"blockDisable",weight:5})};var Vk=function(){za.registry.register({displayText(a){var b=a.block;a=b.getDescendants(!1).length;(b=b.getNextBlock())&&(a-=b.getDescendants(!1).length);return 1===a?d.Msg$$module$build$src$core$msg.DELETE_BLOCK:
d.Msg$$module$build$src$core$msg.DELETE_X_BLOCKS.replace("%1",`${a}`)},preconditionFn(a){return!a.block.isInFlyout&&a.block.isDeletable()?"enabled":"hidden"},callback(a){a.block&&a.block.checkAndDelete()},scopeType:za.ScopeType.BLOCK,id:"blockDelete",weight:6})};var Wk=function(){za.registry.register({displayText(){return d.Msg$$module$build$src$core$msg.HELP},preconditionFn(a){a=a.block;return("function"===typeof a.helpUrl?a.helpUrl():a.helpUrl)?"enabled":"hidden"},callback(a){a.block.showHelp()},
scopeType:za.ScopeType.BLOCK,id:"blockHelp",weight:7})};var Xk=function(){za.registry.register({displayText:()=>d.Msg$$module$build$src$core$msg.REMOVE_COMMENT,preconditionFn(a){let b;return(null==(b=a.comment)?0:b.isDeletable())?"enabled":"hidden"},callback(a){d.setGroup$$module$build$src$core$events$utils(!0);let b;null==(b=a.comment)||b.dispose();d.setGroup$$module$build$src$core$events$utils(!1)},scopeType:za.ScopeType.COMMENT,id:"commentDelete",weight:6})};var Yk=function(){za.registry.register({displayText:()=>
d.Msg$$module$build$src$core$msg.DUPLICATE_COMMENT,preconditionFn(a){let b;return(null==(b=a.comment)?0:b.isMovable())?"enabled":"hidden"},callback(a){if(a.comment){var b=a.comment.toCopyData();b&&Mc(b,a.comment.workspace)}},scopeType:za.ScopeType.COMMENT,id:"commentDuplicate",weight:1})};var Zk=function(){za.registry.register({displayText:()=>d.Msg$$module$build$src$core$msg.ADD_COMMENT,preconditionFn:a=>{let b;return(null==(b=a.workspace)?0:b.isMutator)?"hidden":"enabled"},callback:(a,b)=>{if(a=
a.workspace){d.setGroup$$module$build$src$core$events$utils(!0);var f=new kf(a);f.setText(d.Msg$$module$build$src$core$msg.WORKSPACE_COMMENT_DEFAULT_TEXT);f.moveTo(eo(new fa(b.clientX,b.clientY),a));d.setSelected$$module$build$src$core$common(f);d.setGroup$$module$build$src$core$events$utils(!1)}},scopeType:za.ScopeType.WORKSPACE,id:"commentCreate",weight:8})};var eo=function(a,b){var f=b.getInjectionDiv().getBoundingClientRect();a=new fa(a.x-f.left,a.y-f.top);f=b.getOriginOffsetInPixels();a=fa.difference(a,
f);a.scale(1/b.scale);return a};var fo=function(){Qk();Rk();Sk();Tk();Uk();Vk();Wk()};var $k=function(){co();fo()};var go=function(a){return a.isSelectable()};var Y=Y||{};Y.scope={};Y.ASSUME_ES5=!1;Y.ASSUME_NO_NATIVE_MAP=!1;Y.ASSUME_NO_NATIVE_SET=!1;Y.SIMPLE_FROUND_POLYFILL=!1;Y.ISOLATE_POLYFILLS=!1;Y.FORCE_POLYFILL_PROMISE=!1;Y.FORCE_POLYFILL_PROMISE_WHEN_NO_UNHANDLED_REJECTION=!1;Y.defineProperty=Y.ASSUME_ES5||"function"==typeof Object.defineProperties?Object.defineProperty:function(a,b,f){if(a==
Array.prototype||a==Object.prototype)return a;a[b]=f.value;return a};Y.getGlobal=function(a){a=["object"==typeof globalThis&&globalThis,a,"object"==typeof window&&window,"object"==typeof self&&self,"object"==typeof global&&global];for(var b=0;b<a.length;++b){var f=a[b];if(f&&f.Math==Math)return f}throw Error("Cannot find global object");};Y.global=Y.getGlobal(this);Y.IS_SYMBOL_NATIVE="function"===typeof Symbol&&"symbol"===typeof Symbol("x");Y.TRUST_ES6_POLYFILLS=!Y.ISOLATE_POLYFILLS||Y.IS_SYMBOL_NATIVE;
Y.polyfills={};Y.propertyToPolyfillSymbol={};Y.POLYFILL_PREFIX="$jscp$";Y.polyfill=function(a,b,f,g){b&&(Y.ISOLATE_POLYFILLS?Y.polyfillIsolated(a,b,f,g):Y.polyfillUnisolated(a,b,f,g))};Y.polyfillUnisolated=function(a,b,f,g){f=Y.global;a=a.split(".");for(g=0;g<a.length-1;g++){var l=a[g];if(!(l in f))return;f=f[l]}a=a[a.length-1];g=f[a];b=b(g);b!=g&&null!=b&&Y.defineProperty(f,a,{configurable:!0,writable:!0,value:b})};Y.polyfillIsolated=function(a,b,f,g){var l=a.split(".");a=1===l.length;g=l[0];g=!a&&
g in Y.polyfills?Y.polyfills:Y.global;for(var n=0;n<l.length-1;n++){var x=l[n];if(!(x in g))return;g=g[x]}l=l[l.length-1];f=Y.IS_SYMBOL_NATIVE&&"es6"===f?g[l]:null;b=b(f);null!=b&&(a?Y.defineProperty(Y.polyfills,l,{configurable:!0,writable:!0,value:b}):b!==f&&(void 0===Y.propertyToPolyfillSymbol[l]&&(f=1E9*Math.random()>>>0,Y.propertyToPolyfillSymbol[l]=Y.IS_SYMBOL_NATIVE?Y.global.Symbol(l):Y.POLYFILL_PREFIX+f+"$"+l),Y.defineProperty(g,Y.propertyToPolyfillSymbol[l],{configurable:!0,writable:!0,value:b})))};
Y.underscoreProtoCanBeSet=function(){var a={a:!0},b={};try{return b.__proto__=a,b.a}catch(f){}return!1};Y.setPrototypeOf=Y.TRUST_ES6_POLYFILLS&&"function"==typeof Object.setPrototypeOf?Object.setPrototypeOf:Y.underscoreProtoCanBeSet()?function(a,b){a.__proto__=b;if(a.__proto__!==b)throw new TypeError(a+" is not extensible");return a}:null;Y.arrayIteratorImpl=function(a){var b=0;return function(){return b<a.length?{done:!1,value:a[b++]}:{done:!0}}};Y.arrayIterator=function(a){return{next:Y.arrayIteratorImpl(a)}};
Y.makeIterator=function(a){var b="undefined"!=typeof Symbol&&Symbol.iterator&&a[Symbol.iterator];if(b)return b.call(a);if("number"==typeof a.length)return Y.arrayIterator(a);throw Error(String(a)+" is not an iterable or ArrayLike");};Y.generator={};Y.generator.ensureIteratorResultIsObject_=function(a){if(!(a instanceof Object))throw new TypeError("Iterator result "+a+" is not an object");};Y.generator.Context=function(){this.isRunning_=!1;this.yieldAllIterator_=null;this.yieldResult=void 0;this.nextAddress=
1;this.finallyAddress_=this.catchAddress_=0;this.finallyContexts_=this.abruptCompletion_=null};Y.generator.Context.prototype.start_=function(){if(this.isRunning_)throw new TypeError("Generator is already running");this.isRunning_=!0};Y.generator.Context.prototype.stop_=function(){this.isRunning_=!1};Y.generator.Context.prototype.jumpToErrorHandler_=function(){this.nextAddress=this.catchAddress_||this.finallyAddress_};Y.generator.Context.prototype.next_=function(a){this.yieldResult=a};Y.generator.Context.prototype.throw_=
function(a){this.abruptCompletion_={exception:a,isException:!0};this.jumpToErrorHandler_()};Y.generator.Context.prototype.return=function(a){this.abruptCompletion_={return:a};this.nextAddress=this.finallyAddress_};Y.generator.Context.prototype.jumpThroughFinallyBlocks=function(a){this.abruptCompletion_={jumpTo:a};this.nextAddress=this.finallyAddress_};Y.generator.Context.prototype.yield=function(a,b){this.nextAddress=b;return{value:a}};Y.generator.Context.prototype.yieldAll=function(a,b){a=Y.makeIterator(a);
var f=a.next();Y.generator.ensureIteratorResultIsObject_(f);if(f.done)this.yieldResult=f.value,this.nextAddress=b;else return this.yieldAllIterator_=a,this.yield(f.value,b)};Y.generator.Context.prototype.jumpTo=function(a){this.nextAddress=a};Y.generator.Context.prototype.jumpToEnd=function(){this.nextAddress=0};Y.generator.Context.prototype.setCatchFinallyBlocks=function(a,b){this.catchAddress_=a;void 0!=b&&(this.finallyAddress_=b)};Y.generator.Context.prototype.setFinallyBlock=function(a){this.catchAddress_=
0;this.finallyAddress_=a||0};Y.generator.Context.prototype.leaveTryBlock=function(a,b){this.nextAddress=a;this.catchAddress_=b||0};Y.generator.Context.prototype.enterCatchBlock=function(a){this.catchAddress_=a||0;a=this.abruptCompletion_.exception;this.abruptCompletion_=null;return a};Y.generator.Context.prototype.enterFinallyBlock=function(a,b,f){f?this.finallyContexts_[f]=this.abruptCompletion_:this.finallyContexts_=[this.abruptCompletion_];this.catchAddress_=a||0;this.finallyAddress_=b||0};Y.generator.Context.prototype.leaveFinallyBlock=
function(a,b){b=this.finallyContexts_.splice(b||0)[0];if(b=this.abruptCompletion_=this.abruptCompletion_||b){if(b.isException)return this.jumpToErrorHandler_();void 0!=b.jumpTo&&this.finallyAddress_<b.jumpTo?(this.nextAddress=b.jumpTo,this.abruptCompletion_=null):this.nextAddress=this.finallyAddress_}else this.nextAddress=a};Y.generator.Context.prototype.forIn=function(a){return new Y.generator.Context.PropertyIterator(a)};Y.generator.Context.PropertyIterator=function(a){this.object_=a;this.properties_=
[];for(var b in a)this.properties_.push(b);this.properties_.reverse()};Y.generator.Context.PropertyIterator.prototype.getNext=function(){for(;0<this.properties_.length;){var a=this.properties_.pop();if(a in this.object_)return a}return null};Y.generator.Engine_=function(a){this.context_=new Y.generator.Context;this.program_=a};Y.generator.Engine_.prototype.next_=function(a){this.context_.start_();if(this.context_.yieldAllIterator_)return this.yieldAllStep_(this.context_.yieldAllIterator_.next,a,this.context_.next_);
this.context_.next_(a);return this.nextStep_()};Y.generator.Engine_.prototype.return_=function(a){this.context_.start_();var b=this.context_.yieldAllIterator_;if(b)return this.yieldAllStep_("return"in b?b["return"]:function(f){return{value:f,done:!0}},a,this.context_.return);this.context_.return(a);return this.nextStep_()};Y.generator.Engine_.prototype.throw_=function(a){this.context_.start_();if(this.context_.yieldAllIterator_)return this.yieldAllStep_(this.context_.yieldAllIterator_["throw"],a,
this.context_.next_);this.context_.throw_(a);return this.nextStep_()};Y.generator.Engine_.prototype.yieldAllStep_=function(a,b,f){try{var g=a.call(this.context_.yieldAllIterator_,b);Y.generator.ensureIteratorResultIsObject_(g);if(!g.done)return this.context_.stop_(),g;var l=g.value}catch(n){return this.context_.yieldAllIterator_=null,this.context_.throw_(n),this.nextStep_()}this.context_.yieldAllIterator_=null;f.call(this.context_,l);return this.nextStep_()};Y.generator.Engine_.prototype.nextStep_=
function(){for(;this.context_.nextAddress;)try{var a=this.program_(this.context_);if(a)return this.context_.stop_(),{value:a.value,done:!1}}catch(b){this.context_.yieldResult=void 0,this.context_.throw_(b)}this.context_.stop_();if(this.context_.abruptCompletion_){a=this.context_.abruptCompletion_;this.context_.abruptCompletion_=null;if(a.isException)throw a.exception;return{value:a.return,done:!0}}return{value:void 0,done:!0}};Y.generator.Generator_=function(a){this.next=function(b){return a.next_(b)};
this.throw=function(b){return a.throw_(b)};this.return=function(b){return a.return_(b)};this[Symbol.iterator]=function(){return this}};Y.generator.createGenerator=function(a,b){b=new Y.generator.Generator_(new Y.generator.Engine_(b));Y.setPrototypeOf&&a.prototype&&Y.setPrototypeOf(b,a.prototype);return b};Y.asyncExecutePromiseGenerator=function(a){function b(g){return a.next(g)}function f(g){return a.throw(g)}return new Promise(function(g,l){function n(x){x.done?g(x.value):Promise.resolve(x.value).then(b,
f).then(n,l)}n(a.next())})};Y.asyncExecutePromiseGeneratorFunction=function(a){return Y.asyncExecutePromiseGenerator(a())};Y.asyncExecutePromiseGeneratorProgram=function(a){return Y.asyncExecutePromiseGenerator(new Y.generator.Generator_(new Y.generator.Engine_(a)))};Y.polyfill("globalThis",function(a){return a||Y.global},"es_2020","es3");Y.polyfill("Array.prototype.includes",function(a){return a?a:function(b,f){var g=this;g instanceof String&&(g=String(g));var l=g.length;f=f||0;for(0>f&&(f=Math.max(f+
l,0));f<l;f++){var n=g[f];if(n===b||Object.is(n,b))return!0}return!1}},"es7","es3");Y.initSymbol=function(){};Y.iteratorPrototype=function(a){a={next:a};a[Symbol.iterator]=function(){return this};return a};Y.iteratorFromArray=function(a,b){a instanceof String&&(a+="");var f=0,g=!1,l={next:function(){if(!g&&f<a.length){var n=f++;return{value:b(n,a[n]),done:!1}}g=!0;return{done:!0,value:void 0}}};l[Symbol.iterator]=function(){return l};return l};Y.polyfill("Array.prototype.values",function(a){return a?
a:function(){return Y.iteratorFromArray(this,function(b,f){return f})}},"es8","es3");Y.polyfill("Array.prototype.flat",function(a){return a?a:function(b){b=void 0===b?1:b;var f=[];Array.prototype.forEach.call(this,function(g){Array.isArray(g)&&0<b?(g=Array.prototype.flat.call(g,b-1),f.push.apply(f,g)):f.push(g)});return f}},"es9","es5");Y.polyfill("Array.prototype.flatMap",function(a){return a?a:function(b,f){var g=[];Array.prototype.forEach.call(this,function(l,n){l=b.call(f,l,n,this);Array.isArray(l)?
g.push.apply(g,l):g.push(l)});return g}},"es9","es5");Y.owns=function(a,b){return Object.prototype.hasOwnProperty.call(a,b)};Y.polyfill("Object.entries",function(a){return a?a:function(b){var f=[],g;for(g in b)Y.owns(b,g)&&f.push([g,b[g]]);return f}},"es8","es3");Y.polyfill("Object.values",function(a){return a?a:function(b){var f=[],g;for(g in b)Y.owns(b,g)&&f.push(b[g]);return f}},"es8","es3");var lc=Object.create(null),ho={typeMap:lc},De=Object.create(null),Jb="default",ba=class{constructor(a){this.name=
a}toString(){return this.name}};ba.CONNECTION_CHECKER=new ba("connectionChecker");ba.CONNECTION_PREVIEWER=new ba("connectionPreviewer");ba.CURSOR=new ba("cursor");ba.EVENT=new ba("event");ba.FIELD=new ba("field");ba.INPUT=new ba("input");ba.RENDERER=new ba("renderer");ba.TOOLBOX=new ba("toolbox");ba.THEME=new ba("theme");ba.TOOLBOX_ITEM=new ba("toolboxItem");ba.FLYOUTS_VERTICAL_TOOLBOX=new ba("flyoutsVerticalToolbox");ba.FLYOUTS_HORIZONTAL_TOOLBOX=new ba("flyoutsHorizontalToolbox");ba.METRICS_MANAGER=
new ba("metricsManager");ba.BLOCK_DRAGGER=new ba("blockDragger");ba.SERIALIZER=new ba("serializer");ba.ICON=new ba("icon");ba.PASTER=new ba("paster");var dc={DEFAULT:Jb,TEST_ONLY:ho};dc.Type=ba;dc.getAllItems=y;dc.getClass=t;dc.getClassFromOptions=I;dc.getObject=q;dc.hasItem=p;dc.register=e;dc.unregister=k;var hb=Object.create(null),O;(function(a){a.BLOCK_CREATE="create";a.BLOCK_DELETE="delete";a.BLOCK_CHANGE="change";a.BLOCK_FIELD_INTERMEDIATE_CHANGE="block_field_intermediate_change";a.BLOCK_MOVE=
"move";a.VAR_CREATE="var_create";a.VAR_DELETE="var_delete";a.VAR_RENAME="var_rename";a.UI="ui";a.BLOCK_DRAG="drag";a.SELECTED="selected";a.CLICK="click";a.MARKER_MOVE="marker_move";a.BUBBLE_OPEN="bubble_open";a.TRASHCAN_OPEN="trashcan_open";a.TOOLBOX_ITEM_SELECT="toolbox_item_select";a.THEME_CHANGE="theme_change";a.VIEWPORT_CHANGE="viewport_change";a.COMMENT_CREATE="comment_create";a.COMMENT_DELETE="comment_delete";a.COMMENT_CHANGE="comment_change";a.COMMENT_MOVE="comment_move";a.COMMENT_RESIZE="comment_resize";
a.COMMENT_DRAG="comment_drag";a.COMMENT_COLLAPSE="comment_collapse";a.FINISHED_LOADING="finished_loading"})(O||={});var uk=[O.BLOCK_CREATE,O.BLOCK_MOVE,O.COMMENT_CREATE,O.COMMENT_MOVE],ii=new Set,al={};al.warn=L;var ji={genUid:()=>{const a=[];for(let b=0;20>b;b++)a[b]="!#$%()*+,-./:;=?@[]^_`{|}~ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789".charAt(88*Math.random());return a.join("")}},ym=0,lh={TEST_ONLY:ji};lh.genUid=da;lh.getNextUniqueId=Q;var li="",Gd=!0,Qf=0,Ub=[],ki={FIRE_QUEUE:Ub,
enqueueEvent:ka,fireNow:W,fireInternal:function(a){if(ia()){if(!Ub.length)try{requestAnimationFrame(()=>{setTimeout(W,0)})}catch(b){setTimeout(W,0)}ka(a)}},setGroupInternal:function(a){li="boolean"===typeof a?a?da():"":a}},Hd=Object.create(null),mi,Cc=null,ni,ie=[],oi={defineBlocksWithJsonArrayInternal:function(a){d.defineBlocks$$module$build$src$core$common(d.createBlockDefinitionsFromJsonArray$$module$build$src$core$common(a))}},cb={TEST_ONLY:oi};cb.createBlockDefinitionsFromJsonArray=d.createBlockDefinitionsFromJsonArray$$module$build$src$core$common;
cb.defineBlocks=d.defineBlocks$$module$build$src$core$common;cb.defineBlocksWithJsonArray=ja;cb.draggingConnections=ie;cb.getAllWorkspaces=va;cb.getBlockTypeCounts=D;cb.getMainWorkspace=z;cb.getParentContainer=r;cb.getSelected=U;cb.getWorkspaceById=ua;cb.registerWorkspace=u;cb.setMainWorkspace=M;cb.setParentContainer=v;cb.setSelected=d.setSelected$$module$build$src$core$common;cb.svgResize=A;cb.unregisterWorkpace=w;var vd=class{constructor(){this.workspaceId=void 0;this.isUiEvent=!1;this.type="";
this.group=d.getGroup$$module$build$src$core$events$utils();this.recordUndo=ea()}toJson(){return{type:this.type,group:this.group}}static fromJson(a,b,f){f.isBlank=!1;f.group=a.group||"";f.workspaceId=b.id;return f}isNull(){return!1}run(a){}getEventWorkspace_(){let a;this.workspaceId&&(a=ua(this.workspaceId));if(!a)throw Error("Workspace is null. Event must have been generated from real Blockly events.");return a}},Eb=class extends vd{constructor(a){super();this.recordUndo=!1;this.isUiEvent=!0;this.isBlank=
"undefined"===typeof a;this.workspaceId=a?a:""}},mh=class extends Eb{constructor(a,b,f){b=a?a.workspace.id:b;null===b&&(b=void 0);super(b);this.type=O.CLICK;this.blockId=a?a.id:void 0;this.targetType=f}toJson(){const a=super.toJson();if(!this.targetType)throw Error("The click target type is undefined. Either pass a block to the constructor, or call fromJson");a.targetType=this.targetType;a.blockId=this.blockId;return a}static fromJson(a,b,f){b=super.fromJson(a,b,null!=f?f:new mh);b.targetType=a.targetType;
b.blockId=a.blockId;return b}},bl;(function(a){a.BLOCK="block";a.WORKSPACE="workspace";a.ZOOM_CONTROLS="zoom_controls"})(bl||={});e(ba.EVENT,O.CLICK,mh);var zm=750,cl="ontouchstart"in globalThis||!!(globalThis.document&&document.documentElement&&"ontouchstart"in document.documentElement)||!(!globalThis.navigator||!globalThis.navigator.maxTouchPoints&&!globalThis.navigator.msMaxTouchPoints),Fe=null,Dc={mousedown:["pointerdown"],mouseenter:["pointerenter"],mouseleave:["pointerleave"],mousemove:["pointermove"],
mouseout:["pointerout"],mouseover:["pointerover"],mouseup:["pointerup","pointercancel"],touchend:["pointerup"],touchcancel:["pointercancel"]},Ee=0,Nc={TOUCH_ENABLED:cl,TOUCH_MAP:Dc};Nc.checkTouchIdentifier=pi;Nc.clearTouchIdentifier=Ea;Nc.getTouchIdentifierFromEvent=Id;Nc.longStart=ra;Nc.longStop=wa;Nc.shouldHandleEvent=ub;var nh,dl,el,fl,sf,tf,oh,gl,hl,il;(function(a){function b(g){return f.includes(g.toUpperCase())}nh=a;const f=nh.toUpperCase();dl=b("JavaFX");el=b("WebKit");fl=b("Gecko")&&!el;sf=
b("Android");a=globalThis.navigator&&globalThis.navigator.maxTouchPoints;tf=b("iPad")||b("Macintosh")&&0<a;oh=b("iPhone")&&!tf;gl=b("Macintosh");hl=tf||sf&&!b("Mobile")||b("Silk");il=!hl&&(oh||sf)})(globalThis.navigator&&globalThis.navigator.userAgent||"");var Li=dl,jl=fl,ph=sf,uf=tf,kl=oh,Rf=gl,ll=il,io={ANDROID:ph,GECKO:jl,IPAD:uf,IPHONE:kl,JavaFx:Li,MAC:Rf,MOBILE:ll,raw:nh},qi=40,ri=125,ec={};ec.bind=lb;ec.conditionalBind=ta;ec.getScrollDeltaPixels=Ge;ec.isRightButton=Vb;ec.isTargetInput=Jd;ec.mouseToSvg=
Kd;ec.unbind=Na;var ml={};ml.removeElem=mb;var fc=class{constructor(a){this.name=a}toString(){return this.name}};fc.POSITIONABLE=new fc("positionable");fc.DRAG_TARGET=new fc("drag_target");fc.DELETE_AREA=new fc("delete_area");fc.AUTOHIDEABLE=new fc("autohideable");var Qa=class{constructor(){this.componentData=new Map;this.capabilityToComponentIds=new Map}addComponent(a,b){const f=a.component.id;if(!b&&this.componentData.has(f)){var g;throw Error('Plugin "'+f+'" with capabilities "'+(null==(g=this.componentData.get(f))?
void 0:g.capabilities)+'" already added.');}this.componentData.set(f,a);b=[];for(g=0;g<a.capabilities.length;g++){const l=String(a.capabilities[g]).toLowerCase();b.push(l);if(this.capabilityToComponentIds.has(l)){let n;null==(n=this.capabilityToComponentIds.get(l))||n.push(f)}else this.capabilityToComponentIds.set(l,[f])}this.componentData.get(f).capabilities=b}removeComponent(a){const b=this.componentData.get(a);if(b){for(let f=0;f<b.capabilities.length;f++){const g=String(b.capabilities[f]).toLowerCase();
mb(this.capabilityToComponentIds.get(g),a)}this.componentData.delete(a)}}addCapability(a,b){if(!this.getComponent(a))throw Error('Cannot add capability, "'+b+'". Plugin "'+a+'" has not been added to the ComponentManager');if(this.hasCapability(a,b))console.warn('Plugin "'+a+'already has capability "'+b+'"');else{b=`${b}`.toLowerCase();var f;null==(f=this.componentData.get(a))||f.capabilities.push(b);var g;null==(g=this.capabilityToComponentIds.get(b))||g.push(a)}}removeCapability(a,b){if(!this.getComponent(a))throw Error('Cannot remove capability, "'+
b+'". Plugin "'+a+'" has not been added to the ComponentManager');this.hasCapability(a,b)?(b=`${b}`.toLowerCase(),mb(this.componentData.get(a).capabilities,b),mb(this.capabilityToComponentIds.get(b),a)):console.warn('Plugin "'+a+"doesn't have capability \""+b+'" to remove')}hasCapability(a,b){b=`${b}`.toLowerCase();return this.componentData.has(a)&&this.componentData.get(a).capabilities.includes(b)}getComponent(a){let b;return null==(b=this.componentData.get(a))?void 0:b.component}getComponents(a,
b){a=`${a}`.toLowerCase();a=this.capabilityToComponentIds.get(a);if(!a)return[];const f=[];if(b){const g=[];a.forEach(l=>{g.push(this.componentData.get(l))});g.sort(function(l,n){return l.weight-n.weight});g.forEach(function(l){f.push(l.component)})}else a.forEach(g=>{f.push(this.componentData.get(g).component)});return f}};Qa.Capability=fc;(function(a){a=a.ComponentWeight||(a.ComponentWeight={});a[a.TOOLBOX_WEIGHT=0]="TOOLBOX_WEIGHT";a[a.FLYOUT_WEIGHT=1]="FLYOUT_WEIGHT";a[a.TRASHCAN_WEIGHT=2]="TRASHCAN_WEIGHT";
a[a.ZOOM_CONTROLS_WEIGHT=3]="ZOOM_CONTROLS_WEIGHT"})(Qa||={});var Sf=!1,Tf='\n.blocklySvg {\n  background-color: #fff;\n  outline: none;\n  overflow: hidden;  /* IE overflows by default. */\n  position: absolute;\n  display: block;\n}\n\n.blocklyWidgetDiv {\n  display: none;\n  position: absolute;\n  z-index: 99999;  /* big value for bootstrap3 compatibility */\n}\n\n.injectionDiv {\n  height: 100%;\n  position: relative;\n  overflow: hidden;  /* So blocks in drag surface disappear at edges */\n  touch-action: none;\n  user-select: none;\n  -webkit-user-select: none;\n}\n\n.blocklyNonSelectable {\n  user-select: none;\n  -ms-user-select: none;\n  -webkit-user-select: none;\n}\n\n.blocklyBlockCanvas.blocklyCanvasTransitioning,\n.blocklyBubbleCanvas.blocklyCanvasTransitioning {\n  transition: transform .5s;\n}\n\n.blocklyTooltipDiv {\n  background-color: #ffffc7;\n  border: 1px solid #ddc;\n  box-shadow: 4px 4px 20px 1px rgba(0,0,0,.15);\n  color: #000;\n  display: none;\n  font: 9pt sans-serif;\n  opacity: .9;\n  padding: 2px;\n  position: absolute;\n  z-index: 100000;  /* big value for bootstrap3 compatibility */\n}\n\n.blocklyDropDownDiv {\n  position: absolute;\n  left: 0;\n  top: 0;\n  z-index: 1000;\n  display: none;\n  border: 1px solid;\n  border-color: #dadce0;\n  background-color: #fff;\n  border-radius: 2px;\n  padding: 4px;\n  box-shadow: 0 0 3px 1px rgba(0,0,0,.3);\n}\n\n.blocklyDropDownDiv.blocklyFocused {\n  box-shadow: 0 0 6px 1px rgba(0,0,0,.3);\n}\n\n.blocklyDropDownContent {\n  max-height: 300px;  /* @todo: spec for maximum height. */\n  overflow: auto;\n  overflow-x: hidden;\n  position: relative;\n}\n\n.blocklyDropDownArrow {\n  position: absolute;\n  left: 0;\n  top: 0;\n  width: 16px;\n  height: 16px;\n  z-index: -1;\n  background-color: inherit;\n  border-color: inherit;\n}\n\n.blocklyDropDownButton {\n  display: inline-block;\n  float: left;\n  padding: 0;\n  margin: 4px;\n  border-radius: 4px;\n  outline: none;\n  border: 1px solid;\n  transition: box-shadow .1s;\n  cursor: pointer;\n}\n\n.blocklyArrowTop {\n  border-top: 1px solid;\n  border-left: 1px solid;\n  border-top-left-radius: 4px;\n  border-color: inherit;\n}\n\n.blocklyArrowBottom {\n  border-bottom: 1px solid;\n  border-right: 1px solid;\n  border-bottom-right-radius: 4px;\n  border-color: inherit;\n}\n\n.blocklyResizeSE {\n  cursor: se-resize;\n  fill: #aaa;\n}\n\n.blocklyResizeSW {\n  cursor: sw-resize;\n  fill: #aaa;\n}\n\n.blocklyResizeLine {\n  stroke: #515A5A;\n  stroke-width: 1;\n}\n\n.blocklyHighlightedConnectionPath {\n  fill: none;\n  stroke: #fc3;\n  stroke-width: 4px;\n}\n\n.blocklyPathLight {\n  fill: none;\n  stroke-linecap: round;\n  stroke-width: 1;\n}\n\n.blocklySelected>.blocklyPathLight {\n  display: none;\n}\n\n.blocklyDraggable {\n  cursor: grab;\n  cursor: -webkit-grab;\n}\n\n.blocklyDragging {\n  cursor: grabbing;\n  cursor: -webkit-grabbing;\n  /* Drag surface disables events to not block the toolbox, so we have to\n   * reenable them here for the cursor values to work. */\n  pointer-events: auto;\n}\n\n  /* Changes cursor on mouse down. Not effective in Firefox because of\n     https://bugzilla.mozilla.org/show_bug.cgi?id=771241 */\n.blocklyDraggable:active {\n  cursor: grabbing;\n  cursor: -webkit-grabbing;\n}\n\n.blocklyDragging.blocklyDraggingDelete {\n  cursor: url("<<<PATH>>>/handdelete.cur"), auto;\n}\n\n.blocklyDragging>.blocklyPath,\n.blocklyDragging>.blocklyPathLight {\n  fill-opacity: .8;\n  stroke-opacity: .8;\n}\n\n.blocklyDragging>.blocklyPathDark {\n  display: none;\n}\n\n.blocklyDisabled>.blocklyPath {\n  fill-opacity: .5;\n  stroke-opacity: .5;\n}\n\n.blocklyDisabled>.blocklyPathLight,\n.blocklyDisabled>.blocklyPathDark {\n  display: none;\n}\n\n.blocklyInsertionMarker>.blocklyPath,\n.blocklyInsertionMarker>.blocklyPathLight,\n.blocklyInsertionMarker>.blocklyPathDark {\n  fill-opacity: .2;\n  stroke: none;\n}\n\n.blocklyNonEditableText>text {\n  pointer-events: none;\n}\n\n.blocklyFlyout {\n  position: absolute;\n  z-index: 20;\n}\n\n.blocklyText text {\n  cursor: default;\n}\n\n.blocklyHidden {\n  display: none;\n}\n\n.blocklyFieldDropdown:not(.blocklyHidden) {\n  display: block;\n}\n\n.blocklyIconGroup {\n  cursor: default;\n}\n\n.blocklyIconGroup:not(:hover),\n.blocklyIconGroupReadonly {\n  opacity: .6;\n}\n\n.blocklyIconShape {\n  fill: #00f;\n  stroke: #fff;\n  stroke-width: 1px;\n}\n\n.blocklyIconSymbol {\n  fill: #fff;\n}\n\n.blocklyMinimalBody {\n  margin: 0;\n  padding: 0;\n  height: 100%;\n}\n\n.blocklyHtmlInput {\n  border: none;\n  border-radius: 4px;\n  height: 100%;\n  margin: 0;\n  outline: none;\n  padding: 0;\n  width: 100%;\n  text-align: center;\n  display: block;\n  box-sizing: border-box;\n}\n\n/* Remove the increase and decrease arrows on the field number editor */\ninput.blocklyHtmlInput[type=number]::-webkit-inner-spin-button,\ninput.blocklyHtmlInput[type=number]::-webkit-outer-spin-button {\n  -webkit-appearance: none;\n  margin: 0;\n}\n\ninput[type=number] {\n  -moz-appearance: textfield;\n}\n\n.blocklyMainBackground {\n  stroke-width: 1;\n  stroke: #c6c6c6;  /* Equates to #ddd due to border being off-pixel. */\n}\n\n.blocklyMutatorBackground {\n  fill: #fff;\n  stroke: #ddd;\n  stroke-width: 1;\n}\n\n.blocklyFlyoutBackground {\n  fill: #ddd;\n  fill-opacity: .8;\n}\n\n.blocklyMainWorkspaceScrollbar {\n  z-index: 20;\n}\n\n.blocklyFlyoutScrollbar {\n  z-index: 30;\n}\n\n.blocklyScrollbarHorizontal,\n.blocklyScrollbarVertical {\n  position: absolute;\n  outline: none;\n}\n\n.blocklyScrollbarBackground {\n  opacity: 0;\n  pointer-events: none;\n}\n\n.blocklyScrollbarHandle {\n  fill: #ccc;\n}\n\n.blocklyScrollbarBackground:hover+.blocklyScrollbarHandle,\n.blocklyScrollbarHandle:hover {\n  fill: #bbb;\n}\n\n/* Darken flyout scrollbars due to being on a grey background. */\n/* By contrast, workspace scrollbars are on a white background. */\n.blocklyFlyout .blocklyScrollbarHandle {\n  fill: #bbb;\n}\n\n.blocklyFlyout .blocklyScrollbarBackground:hover+.blocklyScrollbarHandle,\n.blocklyFlyout .blocklyScrollbarHandle:hover {\n  fill: #aaa;\n}\n\n.blocklyInvalidInput {\n  background: #faa;\n}\n\n.blocklyVerticalMarker {\n  stroke-width: 3px;\n  fill: rgba(255,255,255,.5);\n  pointer-events: none;\n}\n\n.blocklyComputeCanvas {\n  position: absolute;\n  width: 0;\n  height: 0;\n}\n\n.blocklyNoPointerEvents {\n  pointer-events: none;\n}\n\n.blocklyContextMenu {\n  border-radius: 4px;\n  max-height: 100%;\n}\n\n.blocklyDropdownMenu {\n  border-radius: 2px;\n  padding: 0 !important;\n}\n\n.blocklyDropdownMenu .blocklyMenuItem {\n  /* 28px on the left for icon or checkbox. */\n  padding-left: 28px;\n}\n\n/* BiDi override for the resting state. */\n.blocklyDropdownMenu .blocklyMenuItemRtl {\n  /* Flip left/right padding for BiDi. */\n  padding-left: 5px;\n  padding-right: 28px;\n}\n\n.blocklyWidgetDiv .blocklyMenu {\n  background: #fff;\n  border: 1px solid transparent;\n  box-shadow: 0 0 3px 1px rgba(0,0,0,.3);\n  font: normal 13px Arial, sans-serif;\n  margin: 0;\n  outline: none;\n  padding: 4px 0;\n  position: absolute;\n  overflow-y: auto;\n  overflow-x: hidden;\n  max-height: 100%;\n  z-index: 20000;  /* Arbitrary, but some apps depend on it... */\n}\n\n.blocklyWidgetDiv .blocklyMenu.blocklyFocused {\n  box-shadow: 0 0 6px 1px rgba(0,0,0,.3);\n}\n\n.blocklyDropDownDiv .blocklyMenu {\n  background: inherit;  /* Compatibility with gapi, reset from goog-menu */\n  border: inherit;  /* Compatibility with gapi, reset from goog-menu */\n  font: normal 13px "Helvetica Neue", Helvetica, sans-serif;\n  outline: none;\n  position: relative;  /* Compatibility with gapi, reset from goog-menu */\n  z-index: 20000;  /* Arbitrary, but some apps depend on it... */\n}\n\n/* State: resting. */\n.blocklyMenuItem {\n  border: none;\n  color: #000;\n  cursor: pointer;\n  list-style: none;\n  margin: 0;\n  /* 7em on the right for shortcut. */\n  min-width: 7em;\n  padding: 6px 15px;\n  white-space: nowrap;\n}\n\n/* State: disabled. */\n.blocklyMenuItemDisabled {\n  color: #ccc;\n  cursor: inherit;\n}\n\n/* State: hover. */\n.blocklyMenuItemHighlight {\n  background-color: rgba(0,0,0,.1);\n}\n\n/* State: selected/checked. */\n.blocklyMenuItemCheckbox {\n  height: 16px;\n  position: absolute;\n  width: 16px;\n}\n\n.blocklyMenuItemSelected .blocklyMenuItemCheckbox {\n  background: url(<<<PATH>>>/sprites.png) no-repeat -48px -16px;\n  float: left;\n  margin-left: -24px;\n  position: static;  /* Scroll with the menu. */\n}\n\n.blocklyMenuItemRtl .blocklyMenuItemCheckbox {\n  float: right;\n  margin-right: -24px;\n}\n\n.blocklyBlockDragSurface, .blocklyAnimationLayer {\n  position: absolute;\n  top: 0;\n  left: 0;\n  right: 0;\n  bottom: 0;\n  overflow: visible !important;\n  z-index: 80;\n  pointer-events: none;\n}\n',
qh={};qh.inject=si;qh.register=mc;var fa=class{constructor(a,b){this.x=a;this.y=b}clone(){return new fa(this.x,this.y)}scale(a){this.x*=a;this.y*=a;return this}translate(a,b){this.x+=a;this.y+=b;return this}static equals(a,b){return a===b?!0:a&&b?a.x===b.x&&a.y===b.y:!1}static distance(a,b){const f=a.x-b.x;a=a.y-b.y;return Math.sqrt(f*f+a*a)}static magnitude(a){return Math.sqrt(a.x*a.x+a.y*a.y)}static difference(a,b){return new fa(a.x-b.x,a.y-b.y)}static sum(a,b){return new fa(a.x+b.x,a.y+b.y)}},
Ld="http://www.w3.org/2000/svg",Nb="http://www.w3.org/1999/xhtml",pb="http://www.w3.org/1999/xlink",sc;(function(a){a[a.ELEMENT_NODE=1]="ELEMENT_NODE";a[a.TEXT_NODE=3]="TEXT_NODE";a[a.COMMENT_NODE=8]="COMMENT_NODE"})(sc||={});var Kb=null,Wf=0,Ie=null,$a={HTML_NS:Nb};$a.NodeType=sc;$a.SVG_NS=Ld;$a.XLINK_NS=pb;$a.addClass=sa;$a.createSvgElement=T;$a.getFastTextWidth=He;$a.getFastTextWidthWithSizeString=Xf;$a.getTextWidth=ti;$a.hasClass=function(a,b){return a.classList.contains(b)};$a.insertAfter=ad;
$a.measureFontMetrics=Yf;$a.removeClass=Ma;$a.removeClasses=Uf;$a.removeNode=Ia;$a.setCssTransform=Vf;$a.startTextWidthCache=cd;$a.stopTextWidthCache=dd;var J=class{constructor(a){this.tagName=a}toString(){return this.tagName}};J.ANIMATE=new J("animate");J.CIRCLE=new J("circle");J.CLIPPATH=new J("clipPath");J.DEFS=new J("defs");J.FECOMPOSITE=new J("feComposite");J.FECOMPONENTTRANSFER=new J("feComponentTransfer");J.FEFLOOD=new J("feFlood");J.FEFUNCA=new J("feFuncA");J.FEGAUSSIANBLUR=new J("feGaussianBlur");
J.FEPOINTLIGHT=new J("fePointLight");J.FESPECULARLIGHTING=new J("feSpecularLighting");J.FILTER=new J("filter");J.FOREIGNOBJECT=new J("foreignObject");J.G=new J("g");J.IMAGE=new J("image");J.LINE=new J("line");J.PATH=new J("path");J.PATTERN=new J("pattern");J.POLYGON=new J("polygon");J.RECT=new J("rect");J.SVG=new J("svg");J.TEXT=new J("text");J.TSPAN=new J("tspan");var Ja=class{constructor(a,b,f,g){this.top=a;this.bottom=b;this.left=f;this.right=g}clone(){return new Ja(this.top,this.bottom,this.left,
this.right)}getHeight(){return this.bottom-this.top}getWidth(){return this.right-this.left}contains(a,b){return a>=this.left&&a<=this.right&&b>=this.top&&b<=this.bottom}intersects(a){return this.left<=a.right&&this.right>=a.left&&this.bottom>=a.top&&this.top<=a.bottom}static equals(a,b){return a===b?!0:a&&b?a.top===b.top&&a.bottom===b.bottom&&a.left===b.left&&a.right===b.right:!1}static createFromPoint(a,b,f){const g=a.x;a=a.y;return new Ja(a,a+f,g,g+b)}},Aa=class{constructor(a,b){this.width=a;this.height=
b}static equals(a,b){return a===b?!0:a&&b?a.width===b.width&&a.height===b.height:!1}static max(a,b){return new Aa(Math.max(a.width,b.width),Math.max(a.height,b.height))}static min(a,b){return new Aa(Math.min(a.width,b.width),Math.min(a.height,b.height))}},ui={getSizeInternal:function(a){if("none"!==Wb(a,"display"))return vi(a);const b=a.style,f=b.display,g=b.visibility,l=b.position;b.visibility="hidden";b.position="absolute";b.display="inline";const n=a.offsetWidth;a=a.offsetHeight;b.display=f;b.position=
l;b.visibility=g;return new Aa(n,a)}},wc={TEST_ONLY:ui};wc.getBorderBox=xi;wc.getComputedStyle=Wb;wc.getContainerOffsetToScrollInto=yi;wc.getPageOffset=Ec;wc.getSize=Je;wc.getViewportPageOffset=wi;wc.scrollIntoContainerView=Zf;var zi=/translate\(\s*([-+\d.e]+)([ ,]\s*([-+\d.e]+)\s*)?/,Ai=/transform:\s*translate(?:3d)?\(\s*([-+\d.e]+)\s*px([ ,]\s*([-+\d.e]+)\s*px)?/,Oc={TEST_ONLY:{XY_REGEX:zi,XY_STYLE_REGEX:Ai}};Oc.getDocumentScroll=Ci;Oc.getInjectionDivXY=$f;Oc.getRelativeXY=Ke;Oc.getViewportBBox=
Bi;Oc.screenToWsCoordinates=function(a,b){var f=b.x;b=b.y;const g=a.getInjectionDiv().getBoundingClientRect();f=new fa(f-g.left,b-g.top);b=a.getOriginOffsetInPixels();return fa.difference(f,b).scale(1/a.scale)};Oc.wsToScreenCoordinates=function(a,b){var f=b.scale(a.scale);b=f.x;f=f.y;const g=a.getInjectionDiv().getBoundingClientRect();a=a.getOriginOffsetInPixels();return new fa(b+g.left+a.x,f+g.top+a.y)};var Sa=class{constructor(a,b,f,g,l){this.workspace=a;this.horizontal=b;this.oldHostMetrics=null;
this.ratio=1;this.origin=new fa(0,0);this.startDragHandle=this.handlePosition=this.handleLength=this.scrollbarLength=this.startDragMouse=0;this.containerVisible=this.isHandleVisible=!0;this.position=new fa(0,0);this.onMouseMoveWrapper_=this.onMouseUpWrapper_=null;this.pair=f||!1;this.margin=void 0!==l?l:Sa.DEFAULT_SCROLLBAR_MARGIN;a="blocklyScrollbar"+(this.horizontal?"Horizontal":"Vertical");g&&(a+=" "+g);this.outerSvg=T(J.SVG,{"class":a});g=T(J.G,{},this.outerSvg);this.svgBackground=T(J.RECT,{"class":"blocklyScrollbarBackground"},
g);a=Math.floor((Sa.scrollbarThickness-5)/2);this.svgHandle=T(J.RECT,{"class":"blocklyScrollbarHandle",rx:a,ry:a},g);this.workspace.getThemeManager().subscribe(this.svgHandle,"scrollbarColour","fill");this.workspace.getThemeManager().subscribe(this.svgHandle,"scrollbarOpacity","fill-opacity");ad(this.outerSvg,this.workspace.getParentSvg());this.setInitialThickness();b?(this.lengthAttribute_="width",this.positionAttribute_="x"):(this.lengthAttribute_="height",this.positionAttribute_="y");this.onMouseDownBarWrapper_=
ta(this.svgBackground,"pointerdown",this,this.onMouseDownBar);this.onMouseDownHandleWrapper_=ta(this.svgHandle,"pointerdown",this,this.onMouseDownHandle)}setInitialThickness(){const a=Sa.scrollbarThickness;this.horizontal?(this.svgBackground.setAttribute("height",String(a)),this.outerSvg.setAttribute("height",String(a)),this.svgHandle.setAttribute("height",String(a-5)),this.svgHandle.setAttribute("y","2.5")):(this.svgBackground.setAttribute("width",String(a)),this.outerSvg.setAttribute("width",String(a)),
this.svgHandle.setAttribute("width",String(a-5)),this.svgHandle.setAttribute("x","2.5"))}dispose(){this.cleanUp();Na(this.onMouseDownBarWrapper_);Na(this.onMouseDownHandleWrapper_);Ia(this.outerSvg);this.workspace.getThemeManager().unsubscribe(this.svgHandle)}constrainHandleLength(a){return 0>=a||isNaN(a)?0:Math.min(a,this.scrollbarLength)}setHandleLength(a){this.handleLength=a;this.svgHandle.setAttribute(this.lengthAttribute_,String(this.handleLength))}constrainHandlePosition(a){return 0>=a||isNaN(a)?
0:Math.min(a,this.scrollbarLength-this.handleLength)}setHandlePosition(a){this.handlePosition=a;this.svgHandle.setAttribute(this.positionAttribute_,String(this.handlePosition))}setScrollbarLength(a){this.scrollbarLength=a;this.outerSvg.setAttribute(this.lengthAttribute_,String(this.scrollbarLength));this.svgBackground.setAttribute(this.lengthAttribute_,String(this.scrollbarLength))}setPosition(a,b){this.position.x=a;this.position.y=b;Vf(this.outerSvg,"translate("+(this.position.x+this.origin.x)+"px,"+
(this.position.y+this.origin.y)+"px)")}resize(a){if(a||(a=this.workspace.getMetrics(),a))this.oldHostMetrics&&Sa.metricsAreEquivalent(a,this.oldHostMetrics)||(this.horizontal?this.resizeHorizontal(a):this.resizeVertical(a),this.oldHostMetrics=a,this.updateMetrics())}requiresViewResize(a){return this.oldHostMetrics?this.oldHostMetrics.viewWidth!==a.viewWidth||this.oldHostMetrics.viewHeight!==a.viewHeight||this.oldHostMetrics.absoluteLeft!==a.absoluteLeft||this.oldHostMetrics.absoluteTop!==a.absoluteTop:
!0}resizeHorizontal(a){this.requiresViewResize(a)?this.resizeViewHorizontal(a):this.resizeContentHorizontal(a)}resizeViewHorizontal(a){var b=a.viewWidth-2*this.margin;this.pair&&(b-=Sa.scrollbarThickness);this.setScrollbarLength(Math.max(0,b));b=a.absoluteLeft+this.margin;this.pair&&this.workspace.RTL&&(b+=Sa.scrollbarThickness);this.setPosition(b,a.absoluteTop+a.viewHeight-Sa.scrollbarThickness-this.margin);this.resizeContentHorizontal(a)}resizeContentHorizontal(a){if(a.viewWidth>=a.scrollWidth)this.setHandleLength(this.scrollbarLength),
this.setHandlePosition(0),this.pair||this.setVisible(!1);else{this.pair||this.setVisible(!0);var b=this.scrollbarLength*a.viewWidth/a.scrollWidth;b=this.constrainHandleLength(b);this.setHandleLength(b);b=a.scrollWidth-a.viewWidth;var f=this.scrollbarLength-this.handleLength;a=(a.viewLeft-a.scrollLeft)/b*f;a=this.constrainHandlePosition(a);this.setHandlePosition(a);this.ratio=f/b}}resizeVertical(a){this.requiresViewResize(a)?this.resizeViewVertical(a):this.resizeContentVertical(a)}resizeViewVertical(a){let b=
a.viewHeight-2*this.margin;this.pair&&(b-=Sa.scrollbarThickness);this.setScrollbarLength(Math.max(0,b));this.setPosition(this.workspace.RTL?a.absoluteLeft+this.margin:a.absoluteLeft+a.viewWidth-Sa.scrollbarThickness-this.margin,a.absoluteTop+this.margin);this.resizeContentVertical(a)}resizeContentVertical(a){if(a.viewHeight>=a.scrollHeight)this.setHandleLength(this.scrollbarLength),this.setHandlePosition(0),this.pair||this.setVisible(!1);else{this.pair||this.setVisible(!0);var b=this.scrollbarLength*
a.viewHeight/a.scrollHeight;b=this.constrainHandleLength(b);this.setHandleLength(b);b=a.scrollHeight-a.viewHeight;var f=this.scrollbarLength-this.handleLength;a=(a.viewTop-a.scrollTop)/b*f;a=this.constrainHandlePosition(a);this.setHandlePosition(a);this.ratio=f/b}}isVisible(){return this.isHandleVisible}setContainerVisible(a){const b=a!==this.containerVisible;this.containerVisible=a;b&&this.updateDisplay_()}setVisible(a){if(this.pair)throw Error("Unable to toggle visibility of paired scrollbars.");
this.setVisibleInternal(a)}setVisibleInternal(a){const b=a!==this.isVisible();this.isHandleVisible=a;b&&this.updateDisplay_()}updateDisplay_(){this.containerVisible&&this.isVisible()?this.outerSvg.setAttribute("display","block"):this.outerSvg.setAttribute("display","none")}onMouseDownBar(a){this.workspace.markFocused();Ea();this.cleanUp();if(Vb(a))a.stopPropagation();else{var b=Kd(a,this.workspace.getParentSvg(),this.workspace.getInverseScreenCTM());b=this.horizontal?b.x:b.y;var f=$f(this.svgHandle);
f=this.horizontal?f.x:f.y;var g=this.handlePosition,l=.95*this.handleLength;b<=f?g-=l:b>=f+this.handleLength&&(g+=l);this.setHandlePosition(this.constrainHandlePosition(g));this.updateMetrics();a.stopPropagation();a.preventDefault()}}onMouseDownHandle(a){this.workspace.markFocused();this.cleanUp();Vb(a)?a.stopPropagation():(this.startDragHandle=this.handlePosition,this.startDragMouse=this.horizontal?a.clientX:a.clientY,this.onMouseUpWrapper_=ta(document,"pointerup",this,this.onMouseUpHandle),this.onMouseMoveWrapper_=
ta(document,"pointermove",this,this.onMouseMoveHandle),a.stopPropagation(),a.preventDefault())}onMouseMoveHandle(a){this.setHandlePosition(this.constrainHandlePosition(this.startDragHandle+((this.horizontal?a.clientX:a.clientY)-this.startDragMouse)));this.updateMetrics()}onMouseUpHandle(){Ea();this.cleanUp()}cleanUp(){this.workspace.hideChaff(!0);this.onMouseUpWrapper_&&(Na(this.onMouseUpWrapper_),this.onMouseUpWrapper_=null);this.onMouseMoveWrapper_&&(Na(this.onMouseMoveWrapper_),this.onMouseMoveWrapper_=
null)}getRatio_(){let a=this.handlePosition/(this.scrollbarLength-this.handleLength);isNaN(a)&&(a=0);return a}updateMetrics(){const a=this.getRatio_();this.horizontal?this.workspace.setMetrics({x:a}):this.workspace.setMetrics({y:a})}set(a,b){this.setHandlePosition(this.constrainHandlePosition(a*this.ratio));(b||void 0===b)&&this.updateMetrics()}setOrigin(a,b){this.origin=new fa(a,b)}static metricsAreEquivalent(a,b){return a.viewWidth===b.viewWidth&&a.viewHeight===b.viewHeight&&a.viewLeft===b.viewLeft&&
a.viewTop===b.viewTop&&a.absoluteTop===b.absoluteTop&&a.absoluteLeft===b.absoluteLeft&&a.scrollWidth===b.scrollWidth&&a.scrollHeight===b.scrollHeight&&a.scrollLeft===b.scrollLeft&&a.scrollTop===b.scrollTop}};Sa.scrollbarThickness=cl?25:15;Sa.DEFAULT_SCROLLBAR_MARGIN=.5;var Me={parseFromString:function(){throw Error("DOMParser was not found in the global scope and was not properly injected using injectDependencies");}},ag={serializeToString:function(){throw Error("XMLSerializer was not foundin the global scope and was not properly injected using injectDependencies");
}},{document:Le,DOMParser:je,XMLSerializer:ke}=globalThis;je&&(Me=new je);ke&&(ag=new ke);var Di="https://developers.google.com/blockly/xml",Bm=/[\x00-\x09\x0B\x0C\x0E-\x1F]/g,wd={NAME_SPACE:Di};wd.createElement=d.createElement$$module$build$src$core$utils$xml;wd.createTextNode=d.createTextNode$$module$build$src$core$utils$xml;wd.domToText=Md;wd.injectDependencies=function(a){({document:Le=Le,DOMParser:je=je,XMLSerializer:ke=ke}=a);Me=new je;ag=new ke};wd.textToDom=d.textToDom$$module$build$src$core$utils$xml;
var cg="categoryToolbox",Fi="flyoutToolbox",xa;(function(a){a[a.TOP=0]="TOP";a[a.BOTTOM=1]="BOTTOM";a[a.LEFT=2]="LEFT";a[a.RIGHT=3]="RIGHT"})(xa||={});var Gi={hasCategoriesInternal:function(a){if(!a)return!1;const b=a.kind;return b?b===cg:!!a.contents.filter(f=>"CATEGORY"===f.kind.toUpperCase()).length}},xc={};xc.Position=xa;xc.TEST_ONLY=Gi;xc.convertFlyoutDefToJsonArray=Ne;xc.convertToolboxDefToJson=bg;xc.hasCategories=eg;xc.isCategoryCollapsible=fg;xc.parseToolboxTree=Ei;var nc;(function(a){a[a.TOP=
0]="TOP";a[a.BOTTOM=1]="BOTTOM"})(nc||={});var Nd;(function(a){a[a.LEFT=0]="LEFT";a[a.RIGHT=1]="RIGHT"})(Nd||={});var Fc;(function(a){a[a.UP=0]="UP";a[a.DOWN=1]="DOWN"})(Fc||={});var Pc={};Pc.bumpDirection=Fc;Pc.bumpPositionRect=ig;Pc.getCornerOppositeToolbox=hg;Pc.getStartPositionRect=gg;Pc.horizontalPosition=Nd;Pc.verticalPosition=nc;var nl=class{constructor(a){this.workspace=a;this.id="zoomControls";this.boundEvents=[];this.zoomResetGroup=this.zoomOutGroup=this.zoomInGroup=null;this.HEIGHT=this.WIDTH=
32;this.SMALL_SPACING=2;this.LARGE_SPACING=11;this.MARGIN_HORIZONTAL=this.MARGIN_VERTICAL=20;this.svgGroup=null;this.top=this.left=0;this.initialized=!1}createDom(){this.svgGroup=T(J.G,{});const a=String(Math.random()).substring(2);this.createZoomOutSvg(a);this.createZoomInSvg(a);this.workspace.isMovable()&&this.createZoomResetSvg(a);return this.svgGroup}init(){this.workspace.getComponentManager().addComponent({component:this,weight:Qa.ComponentWeight.ZOOM_CONTROLS_WEIGHT,capabilities:[Qa.Capability.POSITIONABLE]});
this.initialized=!0}dispose(){this.workspace.getComponentManager().removeComponent("zoomControls");this.svgGroup&&Ia(this.svgGroup);for(const a of this.boundEvents)Na(a);this.boundEvents.length=0}getBoundingRectangle(){let a=this.SMALL_SPACING+2*this.HEIGHT;this.zoomResetGroup&&(a+=this.LARGE_SPACING+this.HEIGHT);return new Ja(this.top,this.top+a,this.left,this.left+this.WIDTH)}position(a,b){if(this.initialized){var f=hg(this.workspace,a),g=this.SMALL_SPACING+2*this.HEIGHT;this.zoomResetGroup&&(g+=
this.LARGE_SPACING+this.HEIGHT);a=gg(f,new Aa(this.WIDTH,g),this.MARGIN_HORIZONTAL,this.MARGIN_VERTICAL,a,this.workspace);f=f.vertical;b=ig(a,this.MARGIN_VERTICAL,f===nc.TOP?Fc.DOWN:Fc.UP,b);if(f===nc.TOP){var l=this.SMALL_SPACING+this.HEIGHT,n;null==(n=this.zoomInGroup)||n.setAttribute("transform","translate(0, "+l+")");this.zoomResetGroup&&this.zoomResetGroup.setAttribute("transform","translate(0, "+(l+this.LARGE_SPACING+this.HEIGHT)+")")}else{n=this.zoomResetGroup?this.LARGE_SPACING+this.HEIGHT:
0;let B;null==(B=this.zoomInGroup)||B.setAttribute("transform","translate(0, "+n+")");n=n+this.SMALL_SPACING+this.HEIGHT;null==(l=this.zoomOutGroup)||l.setAttribute("transform","translate(0, "+n+")")}this.top=b.top;this.left=b.left;var x;null==(x=this.svgGroup)||x.setAttribute("transform","translate("+this.left+","+this.top+")")}}createZoomOutSvg(a){this.zoomOutGroup=T(J.G,{"class":"blocklyZoom blocklyZoomOut"},this.svgGroup);const b=T(J.CLIPPATH,{id:"blocklyZoomoutClipPath"+a},this.zoomOutGroup);
T(J.RECT,{width:32,height:32},b);T(J.IMAGE,{width:96,height:124,x:-64,y:-92,"clip-path":"url(#blocklyZoomoutClipPath"+a+")"},this.zoomOutGroup).setAttributeNS(pb,"xlink:href",this.workspace.options.pathToMedia+"sprites.png");this.boundEvents.push(ta(this.zoomOutGroup,"pointerdown",null,this.zoom.bind(this,-1)))}createZoomInSvg(a){this.zoomInGroup=T(J.G,{"class":"blocklyZoom blocklyZoomIn"},this.svgGroup);const b=T(J.CLIPPATH,{id:"blocklyZoominClipPath"+a},this.zoomInGroup);T(J.RECT,{width:32,height:32},
b);T(J.IMAGE,{width:96,height:124,x:-32,y:-92,"clip-path":"url(#blocklyZoominClipPath"+a+")"},this.zoomInGroup).setAttributeNS(pb,"xlink:href",this.workspace.options.pathToMedia+"sprites.png");this.boundEvents.push(ta(this.zoomInGroup,"pointerdown",null,this.zoom.bind(this,1)))}zoom(a,b){this.workspace.markFocused();this.workspace.zoomCenter(a);this.fireZoomEvent();Ea();b.stopPropagation();b.preventDefault()}createZoomResetSvg(a){this.zoomResetGroup=T(J.G,{"class":"blocklyZoom blocklyZoomReset"},
this.svgGroup);const b=T(J.CLIPPATH,{id:"blocklyZoomresetClipPath"+a},this.zoomResetGroup);T(J.RECT,{width:32,height:32},b);T(J.IMAGE,{width:96,height:124,y:-92,"clip-path":"url(#blocklyZoomresetClipPath"+a+")"},this.zoomResetGroup).setAttributeNS(pb,"xlink:href",this.workspace.options.pathToMedia+"sprites.png");this.boundEvents.push(ta(this.zoomResetGroup,"pointerdown",null,this.resetZoom.bind(this)))}resetZoom(a){this.workspace.markFocused();const b=Math.log(this.workspace.options.zoomOptions.startScale/
this.workspace.scale)/Math.log(this.workspace.options.zoomOptions.scaleSpeed);this.workspace.beginCanvasTransition();this.workspace.zoomCenter(b);this.workspace.scrollCenter();setTimeout(this.workspace.endCanvasTransition.bind(this.workspace),500);this.fireZoomEvent();Ea();a.stopPropagation();a.preventDefault()}fireZoomEvent(){const a=new (la(O.CLICK))(null,this.workspace.id,"zoom_controls");aa(a)}};mc("\n.blocklyZoom>image, .blocklyZoom>svg>image {\n  opacity: .4;\n}\n\n.blocklyZoom>image:hover, .blocklyZoom>svg>image:hover {\n  opacity: .6;\n}\n\n.blocklyZoom>image:active, .blocklyZoom>svg>image:active {\n  opacity: .8;\n}\n");
var rh={};rh.register=Oe;rh.unregister=function(a){k(ba.SERIALIZER,a)};var ol=class{constructor(){this.priority=25}save(a){const b=[];for(const f of a.getTopComments())(a=Od(f,{addCoordinates:!0,saveIds:!0}))&&b.push(a);return b.length?b:null}load(a,b){for(const f of a)Pe(f,b,{recordUndo:ea()})}clear(a){for(const b of a.getTopComments())b.dispose()}};Oe("workspaceComments",new ol);var vf={};vf.WorkspaceCommentSerializer=ol;vf.append=Pe;vf.save=Od;var sh={};sh.register=jg;sh.unregister=function(a){k(ba.PASTER,
a)};var wf=class{paste(a,b,f){a=a.commentState;f&&(a.x=f.x,a.y=f.y);d.disable$$module$build$src$core$events$utils();let g;try{g=Pe(a,b),Fm(g)}finally{d.enable$$module$build$src$core$events$utils()}if(!g)return null;ia()&&aa(new (la(O.COMMENT_CREATE))(g));d.setSelected$$module$build$src$core$common(g);return g}};wf.TYPE="workspace-comment";jg(wf.TYPE,new wf);d.config$$module$build$src$core$config={dragRadius:5,flyoutDragRadius:10,snapRadius:28,connectingSnapRadius:28,currentConnectionPreference:8,
bumpDelay:250};var Hm="aria-",Gm="role",Mb;(function(a){a.GRID="grid";a.GRIDCELL="gridcell";a.GROUP="group";a.LISTBOX="listbox";a.MENU="menu";a.MENUITEM="menuitem";a.MENUITEMCHECKBOX="menuitemcheckbox";a.OPTION="option";a.PRESENTATION="presentation";a.ROW="row";a.TREE="tree";a.TREEITEM="treeitem"})(Mb||={});var ab;(function(a){a.ACTIVEDESCENDANT="activedescendant";a.COLCOUNT="colcount";a.DISABLED="disabled";a.EXPANDED="expanded";a.INVALID="invalid";a.LABEL="label";a.LABELLEDBY="labelledby";a.LEVEL=
"level";a.ORIENTATION="orientation";a.POSINSET="posinset";a.ROWCOUNT="rowcount";a.SELECTED="selected";a.SETSIZE="setsize";a.VALUEMAX="valuemax";a.VALUEMIN="valuemin"})(ab||={});var le={};le.Role=Mb;le.State=ab;le.setRole=Gc;le.setState=bb;var Qg=class{constructor(){this.menuItems=[];this.roleName=this.element=this.onKeyDownHandler=this.pointerLeaveHandler=this.pointerEnterHandler=this.clickHandler=this.pointerMoveHandler=this.highlightedItem=this.openingCoords=null}addChild(a){this.menuItems.push(a)}render(a){const b=
document.createElement("div");b.className="blocklyMenu goog-menu blocklyNonSelectable";b.tabIndex=0;this.roleName&&Gc(b,this.roleName);this.element=b;for(let f=0,g;g=this.menuItems[f];f++)b.appendChild(g.createDom());this.pointerMoveHandler=ta(b,"pointermove",this,this.handlePointerMove,!0);this.clickHandler=ta(b,"pointerup",this,this.handleClick,!0);this.pointerEnterHandler=ta(b,"pointerenter",this,this.handlePointerEnter,!0);this.pointerLeaveHandler=ta(b,"pointerleave",this,this.handlePointerLeave,
!0);this.onKeyDownHandler=ta(b,"keydown",this,this.handleKeyEvent);a.appendChild(b);return b}getElement(){return this.element}focus(){const a=this.getElement();a&&(a.focus({preventScroll:!0}),sa(a,"blocklyFocused"))}blur(){const a=this.getElement();a&&(a.blur(),Ma(a,"blocklyFocused"))}setRole(a){this.roleName=a}dispose(){this.pointerMoveHandler&&(Na(this.pointerMoveHandler),this.pointerMoveHandler=null);this.clickHandler&&(Na(this.clickHandler),this.clickHandler=null);this.pointerEnterHandler&&(Na(this.pointerEnterHandler),
this.pointerEnterHandler=null);this.pointerLeaveHandler&&(Na(this.pointerLeaveHandler),this.pointerLeaveHandler=null);this.onKeyDownHandler&&(Na(this.onKeyDownHandler),this.onKeyDownHandler=null);for(let a=0,b;b=this.menuItems[a];a++)b.dispose();this.element=null}getMenuItem(a){const b=this.getElement();for(;a&&a!==b;){if(a.classList.contains("blocklyMenuItem"))for(let f=0,g;g=this.menuItems[f];f++)if(g.getElement()===a)return g;a=a.parentElement}return null}setHighlighted(a){var b=this.highlightedItem;
b&&(b.setHighlighted(!1),this.highlightedItem=null);if(a){a.setHighlighted(!0);this.highlightedItem=a;b=this.getElement();const f=null==b?void 0:b.parentElement,g=a.getElement();f&&g&&(Zf(g,f),bb(b,ab.ACTIVEDESCENDANT,a.getId()))}}highlightNext(){const a=this.highlightedItem?this.menuItems.indexOf(this.highlightedItem):-1;this.highlightHelper(a,1)}highlightPrevious(){const a=this.highlightedItem?this.menuItems.indexOf(this.highlightedItem):-1;this.highlightHelper(0>a?this.menuItems.length:a,-1)}highlightFirst(){this.highlightHelper(-1,
1)}highlightLast(){this.highlightHelper(this.menuItems.length,-1)}highlightHelper(a,b){a+=b;let f;for(;f=this.menuItems[a];){if(f.isEnabled()){this.setHighlighted(f);break}a+=b}}handlePointerMove(a){0!==Math.max(Math.abs(a.movementX),Math.abs(a.movementY))&&(a=this.getMenuItem(a.target))&&(a.isEnabled()?this.highlightedItem!==a&&this.setHighlighted(a):this.setHighlighted(null))}handleClick(a){const b=this.openingCoords;this.openingCoords=null;if(b&&"number"===typeof a.clientX){const f=new fa(a.clientX,
a.clientY);if(1>fa.distance(b,f))return}(a=this.getMenuItem(a.target))&&a.performAction()}handlePointerEnter(a){this.focus()}handlePointerLeave(a){this.getElement()&&this.setHighlighted(null)}handleKeyEvent(a){if(this.menuItems.length&&!(a.shiftKey||a.ctrlKey||a.metaKey||a.altKey)){var b=this.highlightedItem;switch(a.key){case "Enter":case " ":b&&b.performAction();break;case "ArrowUp":this.highlightPrevious();break;case "ArrowDown":this.highlightNext();break;case "PageUp":case "Home":this.highlightFirst();
break;case "PageDown":case "End":this.highlightLast();break;default:return}a.preventDefault();a.stopPropagation()}}getSize(){const a=this.getElement(),b=Je(a);b.height=a.scrollHeight;return b}},Rg=class{constructor(a,b){this.content=a;this.opt_value=b;this.enabled=!0;this.element=null;this.rightToLeft=!1;this.roleName=null;this.highlight=this.checked=this.checkable=!1;this.actionHandler=null}createDom(){const a=document.createElement("div");a.id=Q();this.element=a;a.className="blocklyMenuItem goog-menuitem "+
(this.enabled?"":"blocklyMenuItemDisabled goog-menuitem-disabled ")+(this.checked?"blocklyMenuItemSelected goog-option-selected ":"")+(this.highlight?"blocklyMenuItemHighlight goog-menuitem-highlight ":"")+(this.rightToLeft?"blocklyMenuItemRtl goog-menuitem-rtl ":"");const b=document.createElement("div");b.className="blocklyMenuItemContent goog-menuitem-content";if(this.checkable){var f=document.createElement("div");f.className="blocklyMenuItemCheckbox goog-menuitem-checkbox";b.appendChild(f)}f=this.content;
"string"===typeof this.content&&(f=document.createTextNode(this.content));b.appendChild(f);a.appendChild(b);this.roleName&&Gc(a,this.roleName);bb(a,ab.SELECTED,this.checkable&&this.checked||!1);bb(a,ab.DISABLED,!this.enabled);return a}dispose(){this.element=null}getElement(){return this.element}getId(){return this.element.id}getValue(){let a;return null!=(a=this.opt_value)?a:null}setRightToLeft(a){this.rightToLeft=a}setRole(a){this.roleName=a}setCheckable(a){this.checkable=a}setChecked(a){this.checked=
a}setHighlighted(a){this.highlight=a;const b=this.getElement();b&&this.isEnabled()&&(a?(sa(b,"blocklyMenuItemHighlight"),sa(b,"goog-menuitem-highlight")):(Ma(b,"blocklyMenuItemHighlight"),Ma(b,"goog-menuitem-highlight")))}isEnabled(){return this.enabled}setEnabled(a){this.enabled=a}performAction(){this.isEnabled()&&this.actionHandler&&this.actionHandler(this)}onAction(a,b){this.actionHandler=a.bind(b)}},fb="MANUALLY_DISABLED",jo={COLLAPSED_FIELD_NAME:"_TEMP_COLLAPSED_FIELD",COLLAPSED_INPUT_NAME:"_TEMP_COLLAPSED_INPUT",
MANUALLY_DISABLED:fb};(function(a){a[a.VALUE=1]="VALUE";a[a.STATEMENT=3]="STATEMENT";a[a.DUMMY=5]="DUMMY";a[a.CUSTOM=6]="CUSTOM";a[a.END_ROW=7]="END_ROW"})(d.inputTypes$$module$build$src$core$inputs$input_types||(d.inputTypes$$module$build$src$core$inputs$input_types={}));var Re=new Set,mg=new WeakSet,ng=new WeakMap,Pd=null,lg=null,Ji=0,xf={};xf.finishQueuedRenders=Lb;xf.queueRender=Ki;xf.triggerQueuedRenders=oc;var Oi=function(a,b){window.alert(a);b&&b()},pl=function(a,b){b(window.confirm(a))},Qi=
function(a,b,f){f(window.prompt(a,b))},Pi={confirmInternal:function(a,b){pl(a,b)}},Qc={TEST_ONLY:Pi};Qc.alert=Se;Qc.confirm=og;Qc.prompt=pg;Qc.setAlert=function(a){Oi=a};Qc.setConfirm=function(a){pl=a};Qc.setPrompt=function(a){Qi=a};d.Msg$$module$build$src$core$msg=Object.create(null);var ql=function(a){Object.keys(a).forEach(function(b){d.Msg$$module$build$src$core$msg[b]=a[b]})};var ko={Msg:d.Msg$$module$build$src$core$msg,setLocale:ql};var me=class extends vd{constructor(a){super();this.isBlank=
"undefined"===typeof a;a&&(this.varId=a.getId(),this.workspaceId=a.workspace.id)}toJson(){const a=super.toJson();if(!this.varId)throw Error("The var ID is undefined. Either pass a variable to the constructor, or call fromJson");a.varId=this.varId;return a}static fromJson(a,b,f){b=super.fromJson(a,b,null!=f?f:new me);b.varId=a.varId;return b}},th=class extends me{constructor(a){super(a);this.type=O.VAR_CREATE;a&&(this.varType=a.type,this.varName=a.name)}toJson(){const a=super.toJson();if(void 0===
this.varType)throw Error("The var type is undefined. Either pass a variable to the constructor, or call fromJson");if(!this.varName)throw Error("The var name is undefined. Either pass a variable to the constructor, or call fromJson");a.varType=this.varType;a.varName=this.varName;return a}static fromJson(a,b,f){b=super.fromJson(a,b,null!=f?f:new th);b.varType=a.varType;b.varName=a.varName;return b}run(a){const b=this.getEventWorkspace_();if(!this.varId)throw Error("The var ID is undefined. Either pass a variable to the constructor, or call fromJson");
if(!this.varName)throw Error("The var name is undefined. Either pass a variable to the constructor, or call fromJson");a?b.createVariable(this.varName,this.varType,this.varId):b.deleteVariableById(this.varId)}};e(ba.EVENT,O.VAR_CREATE,th);var Sd=class{constructor(a,b,f,g){this.workspace=a;this.name=b;this.type=f||"";this.id=g||da()}getId(){return this.id}static compareByName(a,b){return a.name.localeCompare(b.name,void 0,{sensitivity:"base"})}},rg="ijkmnopqrstuvwxyzabcdefgh",Ti={generateUniqueNameInternal:function(a){return sg(rg.charAt(0),
a.getAllVariableNames())}},db={CATEGORY_NAME:"VARIABLE",TEST_ONLY:Ti,VAR_LETTER_OPTIONS:rg};db.allDeveloperVariables=d.allDeveloperVariables$$module$build$src$core$variables;db.allUsedVarModels=d.allUsedVarModels$$module$build$src$core$variables;db.createVariableButtonHandler=Rd;db.flyoutCategory=qg;db.flyoutCategoryBlocks=Si;db.generateUniqueName=Ui;db.generateUniqueNameFromOptions=sg;db.generateVariableFieldDom=ed;db.getAddedVariables=Te;db.getOrCreateVariablePackage=d.getOrCreateVariablePackage$$module$build$src$core$variables;
db.getVariable=d.getVariable$$module$build$src$core$variables;db.nameUsedWithAnyType=Vi;db.nameUsedWithConflictingParam=Wi;db.promptName=tg;db.renameVariable=d.renameVariable$$module$build$src$core$variables;var xd=class extends Error{},Zi=class extends xd{constructor(a){super("Expected to find a 'type' property, defining the block type");this.state=a}},Ud=class extends xd{constructor(a,b,f){super(`The block ${b.toDevString()} is missing a(n) ${a}
connection`);this.block=b;this.state=f}},aj=class extends xd{constructor(a,b,f,g){super(`The block ${f.toDevString()} could not connect its
${b} to its parent, because: ${a}`);this.childBlock=f;this.childState=g}},$i=class extends xd{constructor(a){super("Encountered a real block which is defined as a child of a shadow\nblock. It is an invariant of Blockly that shadow blocks only have shadow\nchildren");this.state=a}},bj=class extends xd{constructor(a,b,f){super(`Cannot add an icon of type '${a}' to the block `+`${b.toDevString()}, because there is no icon registered with `+`type '${a}'. Make sure that all of your icons have been `+"registered.");
this.block=b;this.state=f}},Rc={};Rc.BadConnectionCheck=aj;Rc.DeserializationError=xd;Rc.MissingBlockType=Zi;Rc.MissingConnection=Ud;Rc.RealChildOfShadow=$i;Rc.UnregisteredIcon=bj;var rl=class{constructor(){this.priority=50}save(a){const b=[];for(const f of a.getTopBlocks(!1))(a=vb(f,{addCoordinates:!0,doFullSerialization:!1}))&&b.push(a);return b.length?{languageVersion:0,blocks:b}:null}load(a,b){a=a.blocks;for(const f of a)pc(f,b,{recordUndo:ea()})}clear(a){for(const b of a.getTopBlocks(!1))b.dispose(!1)}};
Oe("blocks",new rl);var ne={};ne.BlockSerializer=rl;ne.append=pc;ne.appendInternal=Td;ne.save=vb;var Xa=class{constructor(a){this.name=a}toString(){return this.name}equals(a){return this.name===a.toString()}};Xa.MUTATOR=new Xa("mutator");Xa.WARNING=new Xa("warning");Xa.COMMENT=new Xa("comment");var Sc=class extends vd{constructor(a){super();this.isBlank=!a;a&&(this.blockId=a.id,this.workspaceId=a.workspace.id)}toJson(){const a=super.toJson();if(!this.blockId)throw Error("The block ID is undefined. Either pass a block to the constructor, or call fromJson");
a.blockId=this.blockId;return a}static fromJson(a,b,f){b=super.fromJson(a,b,null!=f?f:new Sc);b.blockId=a.blockId;return b}},Tc=class extends Sc{constructor(a,b,f,g,l){super(a);this.type=O.BLOCK_CHANGE;a&&(this.element=b,this.name=f||void 0,this.oldValue=g,this.newValue=l)}toJson(){const a=super.toJson();if(!this.element)throw Error("The changed element is undefined. Either pass an element to the constructor, or call fromJson");a.element=this.element;a.name=this.name;a.oldValue=this.oldValue;a.newValue=
this.newValue;this.disabledReason&&(a.disabledReason=this.disabledReason);return a}static fromJson(a,b,f){b=super.fromJson(a,b,null!=f?f:new Tc);b.element=a.element;b.name=a.name;b.oldValue=a.oldValue;b.newValue=a.newValue;void 0!==a.disabledReason&&(b.disabledReason=a.disabledReason);return b}setDisabledReason(a){if("disabled"!==this.element)throw Error('Cannot set the disabled reason for a BlockChange event if the element is not "disabled".');this.disabledReason=a}isNull(){return this.oldValue===
this.newValue}run(a){var b=this.getEventWorkspace_();if(!this.blockId)throw Error("The block ID is undefined. Either pass a block to the constructor, or call fromJson");b=b.getBlockById(this.blockId);if(!b)throw Error("The associated block is undefined. Either pass a block to the constructor, or call fromJson");const f=b.getIcon(Xa.MUTATOR);f&&Vd(f)&&f.bubbleIsVisible()&&f.setBubbleVisible(!1);a=a?this.newValue:this.oldValue;switch(this.element){case "field":(b=b.getField(this.name))?b.setValue(a):
console.warn("Can't set non-existent field: "+this.name);break;case "comment":b.setCommentText(a||null);break;case "collapsed":b.setCollapsed(!!a);break;case "disabled":var g;b.setDisabledReason(!!a,null!=(g=this.disabledReason)?g:fb);break;case "inline":b.setInputsInline(!!a);break;case "mutation":g=Tc.getExtraBlockState_(b);b.loadExtraState?b.loadExtraState(JSON.parse(a||"{}")):b.domToMutation&&b.domToMutation(d.textToDom$$module$build$src$core$utils$xml(a||"<mutation/>"));aa(new Tc(b,"mutation",
null,g,a));break;default:console.warn("Unknown change type: "+this.element)}}static getExtraBlockState_(a){return a.saveExtraState?(a=a.saveExtraState(!0))?JSON.stringify(a):"":a.mutationToDom?(a=a.mutationToDom())?Xb(a):"":""}};e(ba.EVENT,O.BLOCK_CHANGE,Tc);var yf={};yf.clamp=Wd;yf.toDegrees=function(a){return 180*a/Math.PI};yf.toRadians=ug;var Xd=16,yg=1,qj=12,xg=16,Ue=.25,Bg=null,Ic=null,gd="",hd="",Ca,fd,Hc,vg=null,qc=null,hj=null,Cg={getBoundsInfo:function(){const a=Ec(vg),b=Je(vg);return{left:a.x,
right:a.x+b.width,top:a.y,bottom:a.y+b.height,width:b.width,height:b.height}},getPositionMetrics:function(a,b,f,g){const l=Cg.getBoundsInfo(),n=Je(Ca);return b+n.height<l.bottom?oj(a,b,l,n):g-n.height>l.top?pj(f,g,l,n):b+n.height<document.documentElement.clientHeight?oj(a,b,l,n):g-n.height>document.documentElement.clientTop?pj(f,g,l,n):fn(a,l,n)}},eb={ANIMATION_TIME:Ue,ARROW_HORIZONTAL_PADDING:qj,ARROW_SIZE:Xd,BORDER_SIZE:yg,PADDING_Y:xg,TEST_ONLY:Cg};eb.clearContent=wg;eb.createDom=dj;eb.getContentDiv=
Ve;eb.getOwner=fj;eb.getPositionX=We;eb.hide=zg;eb.hideIfOwner=Ag;eb.hideWithoutAnimation=Yb;eb.isVisible=rj;eb.repositionForWindowResize=sj;eb.setBoundsElement=ej;eb.setColour=gj;eb.show=mj;eb.showPositionedByBlock=function(a,b,f,g){return ij(lj(b),a,f,g)};eb.showPositionedByField=kj;var oe=class{constructor(a){this.workspace=a;this.cursorSvg=this.cursor=null;this.markers=new Map;this.markerSvg=null}registerMarker(a,b){this.markers.has(a)&&this.unregisterMarker(a);b.setDrawer(this.workspace.getRenderer().makeMarkerDrawer(this.workspace,
b));this.setMarkerSvg(b.getDrawer().createDom());this.markers.set(a,b)}unregisterMarker(a){const b=this.markers.get(a);if(b)b.dispose(),this.markers.delete(a);else throw Error("Marker with ID "+a+" does not exist. Can only unregister markers that exist.");}getCursor(){return this.cursor}getMarker(a){return this.markers.get(a)||null}setCursor(a){this.cursor&&this.cursor.getDrawer()&&this.cursor.getDrawer().dispose();if(this.cursor=a)a=this.workspace.getRenderer().makeMarkerDrawer(this.workspace,this.cursor),
this.cursor.setDrawer(a),this.setCursorSvg(this.cursor.getDrawer().createDom())}setCursorSvg(a){a?(this.workspace.getBlockCanvas().appendChild(a),this.cursorSvg=a):this.cursorSvg=null}setMarkerSvg(a){a?this.workspace.getBlockCanvas()&&(this.cursorSvg?this.workspace.getBlockCanvas().insertBefore(a,this.cursorSvg):this.workspace.getBlockCanvas().appendChild(a)):this.markerSvg=null}updateMarkers(){this.workspace.keyboardAccessibilityMode&&this.cursorSvg&&this.workspace.getCursor().draw()}dispose(){const a=
Object.keys(this.markers);for(let b=0,f;f=a[b];b++)this.unregisterMarker(f);this.markers.clear();this.cursor&&(this.cursor.dispose(),this.cursor=null)}};oe.LOCAL_MARKER="local_marker_1";var yd={};yd.commonWordPrefix=tj;yd.commonWordSuffix=uj;yd.isNumber=d.isNumber$$module$build$src$core$utils$string;yd.shortestStringLength=Xe;yd.wrap=d.wrap$$module$build$src$core$utils$string;var Ye=void 0,ae=!1,id=!1,Fj=50,zj=0,Jc=0,Fg=0,Gg=0,wb=null,$d=null,Hg=0,Ig=10,Aj=10,Bj=750,Ze=5,Wa=null,qb={HOVER_MS:Bj,LIMIT:Fj,
MARGINS:Ze,OFFSET_X:Hg,OFFSET_Y:Ig,RADIUS_OK:Aj};qb.bindMouseEvents=Zd;qb.block=Dj;qb.createDom=xj;qb.dispose=Cj;qb.getCustomTooltip=function(){return Ye};qb.getDiv=function(){return Wa};qb.getTooltipOfObject=Yd;qb.hide=rc;qb.isVisible=function(){return ae};qb.setCustomTooltip=function(a){Ye=a};qb.unbindMouseEvents=Eg;qb.unblock=Ej;var Jg=.45,Kg=.65,Ij={aqua:"#00ffff",black:"#000000",blue:"#0000ff",fuchsia:"#ff00ff",gray:"#808080",green:"#008000",lime:"#00ff00",maroon:"#800000",navy:"#000080",olive:"#808000",
purple:"#800080",red:"#ff0000",silver:"#c0c0c0",teal:"#008080",white:"#ffffff",yellow:"#ffff00"},yb={};yb.blend=kd;yb.getHsvSaturation=Gj;yb.getHsvValue=Hj;yb.hexToRgb=Lg;yb.hsvToHex=Mg;yb.hueToHex=Jj;yb.names=Ij;yb.parse=jd;yb.rgbToHex=$e;yb.setHsvSaturation=function(a){Jg=a};yb.setHsvValue=function(a){Kg=a};var zf={checkMessageReferences:function(a){let b=!0;const f=d.Msg$$module$build$src$core$msg,g=a.match(/%{BKY_[A-Z]\w*}/gi);if(g)for(let l=0;l<g.length;l++){const n=g[l].toUpperCase();void 0===
f[n.slice(6,-1)]&&(console.warn("No message string for "+g[l]+" in "+a),b=!1)}return b}};zf.parseBlockColour=be;zf.replaceMessageReferences=Ua;zf.tokenizeInterpolation=Kj;var Ka=class{constructor(a,b,f){this.DEFAULT_VALUE=null;this.name=void 0;this.constants_=this.mouseDownWrapper=this.textContent_=this.textElement_=this.borderRect_=this.fieldGroup_=this.markerSvg=this.cursorSvg=this.tooltip=this.validator_=null;this.disposed=!1;this.maxDisplayLength=50;this.sourceBlock_=null;this.enabled_=this.visible_=
this.isDirty_=!0;this.suffixField=this.prefixField=this.clickTarget_=null;this.EDITABLE=!0;this.SERIALIZABLE=!1;this.CURSOR="";this.value_="DEFAULT_VALUE"in new.target.prototype?new.target.prototype.DEFAULT_VALUE:this.DEFAULT_VALUE;this.size_=new Aa(0,0);a!==Ka.SKIP_SETUP&&(f&&this.configure_(f),this.setValue(a),b&&this.setValidator(b))}configure_(a){a.tooltip&&this.setTooltip(Ua(a.tooltip))}setSourceBlock(a){if(this.sourceBlock_)throw Error("Field already bound to a block");this.sourceBlock_=a}getConstants(){!this.constants_&&
this.sourceBlock_&&!this.sourceBlock_.isDeadOrDying()&&this.sourceBlock_.workspace.rendered&&(this.constants_=this.sourceBlock_.workspace.getRenderer().getConstants());return this.constants_}getSourceBlock(){return this.sourceBlock_}init(){this.fieldGroup_||(this.fieldGroup_=T(J.G,{}),this.isVisible()||(this.fieldGroup_.style.display="none"),this.sourceBlock_.getSvgRoot().appendChild(this.fieldGroup_),this.initView(),this.updateEditable(),this.setTooltip(this.tooltip),this.bindEvents_(),this.initModel(),
this.applyColour())}initView(){this.createBorderRect_();this.createTextElement_()}initModel(){}isFullBlockField(){return!this.borderRect_}createBorderRect_(){this.borderRect_=T(J.RECT,{rx:this.getConstants().FIELD_BORDER_RECT_RADIUS,ry:this.getConstants().FIELD_BORDER_RECT_RADIUS,x:0,y:0,height:this.size_.height,width:this.size_.width,"class":"blocklyFieldRect"},this.fieldGroup_)}createTextElement_(){this.textElement_=T(J.TEXT,{"class":"blocklyText"},this.fieldGroup_);this.getConstants().FIELD_TEXT_BASELINE_CENTER&&
this.textElement_.setAttribute("dominant-baseline","central");this.textContent_=document.createTextNode("");this.textElement_.appendChild(this.textContent_)}bindEvents_(){const a=this.getClickTarget_();if(!a)throw Error("A click target has not been set.");Zd(a);this.mouseDownWrapper=ta(a,"pointerdown",this,this.onMouseDown_)}fromXml(a){this.setValue(a.textContent)}toXml(a){a.textContent=this.getValue();return a}saveState(a){a=this.saveLegacyState(Ka);return null!==a?a:this.getValue()}loadState(a){this.loadLegacyState(Ka,
a)||this.setValue(a)}saveLegacyState(a){return a.prototype.saveState===this.saveState&&a.prototype.toXml!==this.toXml?(a=d.createElement$$module$build$src$core$utils$xml("field"),a.setAttribute("name",this.name||""),Md(this.toXml(a)).replace(' xmlns="https://developers.google.com/blockly/xml"',"")):null}loadLegacyState(a,b){return a.prototype.loadState===this.loadState&&a.prototype.fromXml!==this.fromXml?(this.fromXml(d.textToDom$$module$build$src$core$utils$xml(b)),!0):!1}dispose(){Ag(this);pd(this);
let a;(null==(a=this.getSourceBlock())?0:a.isDeadOrDying())||Ia(this.fieldGroup_);this.disposed=!0}updateEditable(){const a=this.fieldGroup_,b=this.getSourceBlock();this.EDITABLE&&a&&b&&(this.enabled_&&b.isEditable()?(sa(a,"blocklyEditableText"),Ma(a,"blocklyNonEditableText"),a.style.cursor=this.CURSOR):(sa(a,"blocklyNonEditableText"),Ma(a,"blocklyEditableText"),a.style.cursor=""))}setEnabled(a){this.enabled_=a;this.updateEditable()}isEnabled(){return this.enabled_}isClickable(){return this.enabled_&&
!!this.sourceBlock_&&this.sourceBlock_.isEditable()&&this.showEditor_!==Ka.prototype.showEditor_}isClickableInFlyout(a){return!a}isCurrentlyEditable(){return this.enabled_&&this.EDITABLE&&!!this.sourceBlock_&&this.sourceBlock_.isEditable()}isSerializable(){let a=!1;this.name&&(this.SERIALIZABLE?a=!0:this.EDITABLE&&(console.warn("Detected an editable field that was not serializable. Please define SERIALIZABLE property as true on all editable custom fields. Proceeding with serialization."),a=!0));return a}isVisible(){return this.visible_}setVisible(a){if(this.visible_!==
a){this.visible_=a;var b=this.fieldGroup_;b&&(b.style.display=a?"block":"none")}}setValidator(a){this.validator_=a}getValidator(){return this.validator_}getSvgRoot(){return this.fieldGroup_}getBorderRect(){if(!this.borderRect_)throw Error(`The border rectangle is ${this.borderRect_}.`);return this.borderRect_}getTextElement(){if(!this.textElement_)throw Error(`The text element is ${this.textElement_}.`);return this.textElement_}getTextContent(){if(!this.textContent_)throw Error(`The text content is ${this.textContent_}.`);
return this.textContent_}applyColour(){}render_(){this.textContent_&&(this.textContent_.nodeValue=this.getDisplayText_());this.updateSize_()}showEditor(a){this.isClickable()&&this.showEditor_(a)}showEditor_(a){}repositionForWindowResize(){return!1}updateSize_(a){const b=this.getConstants();a=void 0!==a?a:this.isFullBlockField()?0:this.getConstants().FIELD_BORDER_RECT_X_PADDING;let f=2*a,g=b.FIELD_TEXT_HEIGHT,l=0;this.textElement_&&(l=He(this.textElement_,b.FIELD_TEXT_FONTSIZE,b.FIELD_TEXT_FONTWEIGHT,
b.FIELD_TEXT_FONTFAMILY),f+=l);this.isFullBlockField()||(g=Math.max(g,b.FIELD_BORDER_RECT_HEIGHT));this.size_.height=g;this.size_.width=f;this.positionTextElement_(a,l);this.positionBorderRect_()}positionTextElement_(a,b){if(this.textElement_){var f=this.getConstants(),g=this.size_.height/2,l;this.textElement_.setAttribute("x",String((null==(l=this.getSourceBlock())?0:l.RTL)?this.size_.width-b-a:a));this.textElement_.setAttribute("y",String(f.FIELD_TEXT_BASELINE_CENTER?g:g-f.FIELD_TEXT_HEIGHT/2+f.FIELD_TEXT_BASELINE))}}positionBorderRect_(){this.borderRect_&&
(this.borderRect_.setAttribute("width",String(this.size_.width)),this.borderRect_.setAttribute("height",String(this.size_.height)),this.borderRect_.setAttribute("rx",String(this.getConstants().FIELD_BORDER_RECT_RADIUS)),this.borderRect_.setAttribute("ry",String(this.getConstants().FIELD_BORDER_RECT_RADIUS)))}getSize(){if(!this.isVisible())return new Aa(0,0);this.isDirty_?(this.render_(),this.isDirty_=!1):this.visible_&&0===this.size_.width&&(this.render_(),0!==this.size_.width&&console.warn("Deprecated use of setting size_.width to 0 to rerender a field. Set field.isDirty_ to true instead."));
return this.size_}getScaledBBox(){let a;var b=this.getSourceBlock();if(!b)throw new Ta;if(this.isFullBlockField()){var f=this.sourceBlock_.getHeightWidth();const g=b.workspace.scale;a=this.getAbsoluteXY_();b=(f.width+1)*g;f=(f.height+1)*g;jl?(a.x+=1.5*g,a.y+=1.5*g):(a.x-=.5*g,a.y-=.5*g)}else f=this.borderRect_.getBoundingClientRect(),a=Ec(this.borderRect_),b=f.width,f=f.height;return new Ja(a.y,a.y+f,a.x,a.x+b)}onLocationChange(a){}getDisplayText_(){let a=this.getText();if(!a)return Ka.NBSP;a.length>
this.maxDisplayLength&&(a=a.substring(0,this.maxDisplayLength-2)+"…");a=a.replace(/\s/g,Ka.NBSP);this.sourceBlock_&&this.sourceBlock_.RTL&&(a+="‏");return a}getText(){const a=this.getText_();return null!==a?String(a):String(this.getValue())}getText_(){return null}markDirty(){this.isDirty_=!0;this.constants_=null}forceRerender(){this.isDirty_=!0;this.sourceBlock_&&this.sourceBlock_.rendered&&this.sourceBlock_.queueRender()}setValue(a,b=!0){if(null!==a){var f=d.getGroup$$module$build$src$core$events$utils();
f||d.setGroup$$module$build$src$core$events$utils(!0);try{const V=this.doClassValidation_(a),na=this.processValidation(a,V,b);if(!(na instanceof Error)){var g,l=null==(g=this.getValidator())?void 0:g.call(this,na),n=this.processValidation(na,l,b);if(!(n instanceof Error)){var x=this.sourceBlock_;if(!x||!x.disposed){var B=this.getValue();B===n?this.doValueUpdate_(n):(this.doValueUpdate_(n),b&&x&&ia()&&aa(new (la(O.BLOCK_CHANGE))(x,"field",this.name||null,B,n)),this.isDirty_&&this.forceRerender())}}}}finally{d.setGroup$$module$build$src$core$events$utils(f)}}}processValidation(a,
b,f){return null===b?(this.doValueInvalid_(a,f),this.isDirty_&&this.forceRerender(),Error()):void 0===b?a:b}getValue(){return this.value_}doClassValidation_(a){return null===a||void 0===a?null:a}doValueUpdate_(a){this.value_=a;this.isDirty_=!0}doValueInvalid_(a,b){}onMouseDown_(a){this.sourceBlock_&&!this.sourceBlock_.isDeadOrDying()&&(a=this.sourceBlock_.workspace.getGesture(a))&&a.setStartField(this)}setTooltip(a){a||""===a||(a=this.sourceBlock_);const b=this.getClickTarget_();b?b.tooltip=a:this.tooltip=
a}getTooltip(){const a=this.getClickTarget_();return a?Yd(a):Yd({tooltip:this.tooltip})}getClickTarget_(){return this.clickTarget_||this.getSvgRoot()}getAbsoluteXY_(){return Ec(this.getClickTarget_())}referencesVariables(){return!1}refreshVariableName(){}getParentInput(){let a=null;const b=this.getSourceBlock();if(!b)throw new Ta;const f=b.inputList;for(let g=0;g<b.inputList.length;g++){const l=f[g],n=l.fieldRow;for(let x=0;x<n.length;x++)if(n[x]===this){a=l;break}}return a}getFlipRtl(){return!1}isTabNavigable(){return!1}onShortcut(a){return!1}setCursorSvg(a){if(a){if(!this.fieldGroup_)throw Error(`The field group is ${this.fieldGroup_}.`);
this.fieldGroup_.appendChild(a);this.cursorSvg=a}else this.cursorSvg=null}setMarkerSvg(a){if(a){if(!this.fieldGroup_)throw Error(`The field group is ${this.fieldGroup_}.`);this.fieldGroup_.appendChild(a);this.markerSvg=a}else this.markerSvg=null}updateMarkers_(){var a=this.getSourceBlock();if(!a)throw new Ta;a=a.workspace;a.keyboardAccessibilityMode&&this.cursorSvg&&a.getCursor().draw();a.keyboardAccessibilityMode&&this.markerSvg&&a.getMarker(oe.LOCAL_MARKER).draw()}static fromJson(a){throw Error("Attempted to instantiate a field from the registry that hasn't defined a 'fromJson' method.");
}};Ka.NBSP=" ";Ka.SKIP_SETUP=Symbol("SKIP_SETUP");var Ta=class extends Error{constructor(){super("The field has not yet been attached to its input. Call appendField to attach it.")}},md=null,Og=null,bf=null,af="blocklyWidgetDiv",nd="",od="",Cb,Fb={};Fb.createDom=Lj;Fb.getDiv=ld;Fb.hide=ce;Fb.hideIfOwner=pd;Fb.hideIfOwnerIsInWorkspace=cf;Fb.isVisible=Mj;Fb.positionWithAnchor=Oj;Fb.repositionForWindowResize=Pj;Fb.show=Pg;Fb.testOnly_setDiv=function(a){Cb=a;if(null===a){let b;null==(b=document.querySelector("."+
af))||b.remove()}};var df=null,Rj={},ef=null,Uc={};Uc.callbackFactory=d.callbackFactory$$module$build$src$core$contextmenu;Uc.dispose=Sj;Uc.getCurrentBlock=function(){return df};Uc.hide=ff;Uc.setCurrentBlock=Qj;Uc.show=gf;var za=class{constructor(){this.registeredItems=new Map;this.reset()}reset(){this.registeredItems.clear()}register(a){if(this.registeredItems.has(a.id))throw Error('Menu item with ID "'+a.id+'" is already registered.');this.registeredItems.set(a.id,a)}unregister(a){if(!this.registeredItems.has(a))throw Error('Menu item with ID "'+
a+'" not found.');this.registeredItems.delete(a)}getItem(a){let b;return null!=(b=this.registeredItems.get(a))?b:null}getContextMenuOptions(a,b){const f=[];for(const l of this.registeredItems.values())if(a===l.scopeType){var g=l.preconditionFn(b);"hidden"!==g&&(g={text:"function"===typeof l.displayText?l.displayText(b):l.displayText,enabled:"enabled"===g,callback:l.callback,scope:b,weight:l.weight},f.push(g))}f.sort(function(l,n){return l.weight-n.weight});return f}};(function(a){var b=a.ScopeType||
(a.ScopeType={});b.BLOCK="block";b.WORKSPACE="workspace";b.COMMENT="comment";a.registry=new a})(za||={});var sl=class{constructor(a){this.comment=a;this.startLoc=null;this.inGroup=!1;this.workspace=a.workspace}isMovable(){return this.comment.isOwnMovable()&&!this.comment.isDeadOrDying()&&!this.workspace.options.readOnly}startDrag(){(this.inGroup=!!d.getGroup$$module$build$src$core$events$utils())||d.setGroup$$module$build$src$core$events$utils(!0);this.fireDragStartEvent();this.startLoc=this.comment.getRelativeToSurfaceXY();
this.workspace.setResizesEnabled(!1);let a;null==(a=this.workspace.getLayerManager())||a.moveToDragLayer(this.comment);this.comment.setDragging(!0)}drag(a){this.comment.moveDuringDrag(a)}endDrag(){this.fireDragEndEvent();this.fireMoveEvent();let a;null==(a=this.workspace.getLayerManager())||a.moveOffDragLayer(this.comment,50);this.comment.setDragging(!1);this.comment.snapToGrid();this.workspace.setResizesEnabled(!0);this.inGroup||d.setGroup$$module$build$src$core$events$utils(!1)}fireDragStartEvent(){const a=
new (la(O.COMMENT_DRAG))(this.comment,!0);aa(a)}fireDragEndEvent(){const a=new (la(O.COMMENT_DRAG))(this.comment,!1);aa(a)}fireMoveEvent(){if(!this.comment.isDeadOrDying()){var a=new (la(O.COMMENT_MOVE))(this.comment);a.setReason(["drag"]);a.oldCoordinate_=this.startLoc;a.recordNew();aa(a)}}revertDrag(){this.startLoc&&this.comment.moveDuringDrag(this.startLoc)}},Uj=new WeakMap,tl=class{constructor(a){this.workspace=a;this.size=new Aa(120,100);this.collapsed=!1;this.editable=!0;this.location=new fa(0,
0);this.text="";this.textChangeListeners=[];this.sizeChangeListeners=[];this.disposeListeners=[];this.collapseChangeListeners=[];this.resizePointerMoveListener=this.resizePointerUpListener=null;this.disposed=this.disposing=!1;this.svgRoot=T(J.G,{"class":"blocklyComment blocklyEditable blocklyDraggable"});this.highlightRect=this.createHighlightRect(this.svgRoot);({topBarGroup:this.topBarGroup,topBarBackground:this.topBarBackground,deleteIcon:this.deleteIcon,foldoutIcon:this.foldoutIcon,textPreview:this.textPreview,
textPreviewNode:this.textPreviewNode}=this.createTopBar(this.svgRoot,a));({foreignObject:this.foreignObject,textArea:this.textArea}=this.createTextArea(this.svgRoot));this.resizeHandle=this.createResizeHandle(this.svgRoot,a);let b;null==(b=a.getLayerManager())||b.append(this,50);this.setSizeWithoutFiringEvents(this.size);this.moveTo(new fa(0,0))}createHighlightRect(a){return T(J.RECT,{"class":"blocklyCommentHighlight"},a)}createTopBar(a,b){a=T(J.G,{"class":"blocklyCommentTopbar"},a);const f=T(J.RECT,
{"class":"blocklyCommentTopbarBackground"},a),g=T(J.IMAGE,{"class":"blocklyDeleteIcon",href:`${b.options.pathToMedia}delete-icon.svg`},a);b=T(J.IMAGE,{"class":"blocklyFoldoutIcon",href:`${b.options.pathToMedia}foldout-icon.svg`},a);const l=T(J.TEXT,{"class":"blocklyCommentPreview blocklyCommentText blocklyText"},a),n=document.createTextNode("");l.appendChild(n);ta(b,"pointerdown",this,this.onFoldoutDown);ta(g,"pointerdown",this,this.onDeleteDown);return{topBarGroup:a,topBarBackground:f,deleteIcon:g,
foldoutIcon:b,textPreview:l,textPreviewNode:n}}createTextArea(a){a=T(J.FOREIGNOBJECT,{"class":"blocklyCommentForeignObject"},a);const b=document.createElementNS(Nb,"body");b.setAttribute("xmlns",Nb);b.className="blocklyMinimalBody";const f=document.createElementNS(Nb,"textarea");sa(f,"blocklyCommentText");sa(f,"blocklyTextarea");sa(f,"blocklyText");b.appendChild(f);a.appendChild(b);ta(f,"change",this,this.onTextChange);return{foreignObject:a,textArea:f}}createResizeHandle(a,b){a=T(J.IMAGE,{"class":"blocklyResizeHandle",
href:`${b.options.pathToMedia}resize-handle.svg`},a);ta(a,"pointerdown",this,this.onResizePointerDown);return a}getSvgRoot(){return this.svgRoot}getSize(){return this.collapsed?this.topBarBackground.getBBox():this.size}setSizeWithoutFiringEvents(a){const b=this.topBarBackground.getBBox(),f=this.deleteIcon.getBBox(),g=this.foldoutIcon.getBBox(),l=this.textPreview.getBBox(),n=this.resizeHandle.getBBox();this.size=a=Aa.max(a,this.calcMinSize(b,g,f));this.svgRoot.setAttribute("height",`${a.height}`);
this.svgRoot.setAttribute("width",`${a.width}`);this.updateHighlightRect(a);this.updateTopBarSize(a);this.updateTextAreaSize(a,b);this.updateDeleteIconPosition(a,b,f);this.updateFoldoutIconPosition(b,g);this.updateTextPreviewSize(a,b,l,f,n);this.updateResizeHandlePosition(a,n)}setSize(a){const b=this.preResizeSize||this.size;this.setSizeWithoutFiringEvents(a);this.onSizeChange(b,this.size)}calcMinSize(a,b,f){var g;this.updateTextPreview(null!=(g=this.textArea.value)?g:"");g=ti(this.textPreview);const l=
this.calcFoldoutMargin(a,b),n=this.calcDeleteMargin(a,f);let x=g;this.foldoutIcon.checkVisibility()?x+=b.width+2*l:g&&(x+=4);this.deleteIcon.checkVisibility()?x+=f.width+2*n:g&&(x+=4);return new Aa(x,a.height+20)}calcDeleteMargin(a,b){return(a.height-b.height)/2}calcFoldoutMargin(a,b){return(a.height-b.height)/2}updateHighlightRect(a){this.highlightRect.setAttribute("height",`${a.height}`);this.highlightRect.setAttribute("width",`${a.width}`);this.workspace.RTL&&this.highlightRect.setAttribute("x",
`${-a.width}`)}updateTopBarSize(a){this.topBarBackground.setAttribute("width",`${a.width}`)}updateTextAreaSize(a,b){this.foreignObject.setAttribute("height",`${a.height-b.height}`);this.foreignObject.setAttribute("width",`${a.width}`);this.foreignObject.setAttribute("y",`${b.height}`);this.workspace.RTL&&this.foreignObject.setAttribute("x",`${-a.width}`)}updateDeleteIconPosition(a,b,f){b=this.calcDeleteMargin(b,f);this.deleteIcon.setAttribute("y",`${b}`);this.deleteIcon.setAttribute("x",`${a.width-
f.width-b}`)}updateFoldoutIconPosition(a,b){a=this.calcFoldoutMargin(a,b);this.foldoutIcon.setAttribute("y",`${a}`);this.foldoutIcon.setAttribute("x",`${a}`)}updateTextPreviewSize(a,b,f,g,l){const n=(b.height-f.height)/2,x=this.calcDeleteMargin(b,g);b=this.calcFoldoutMargin(b,l);a=a.width-l.width-2*b-g.width-2*x;this.textPreview.setAttribute("x",`${l.width+2*b*(this.workspace.RTL?-1:1)}`);this.textPreview.setAttribute("y",`${n+f.height/2}`);this.textPreview.setAttribute("width",`${a}`)}updateResizeHandlePosition(a,
b){this.resizeHandle.setAttribute("y",`${a.height-b.height}`);this.resizeHandle.setAttribute("x",`${a.width-b.width}`)}onSizeChange(a,b){for(let f=this.sizeChangeListeners.length-1;0<=f;f--)this.sizeChangeListeners[f](a,b)}addSizeChangeListener(a){this.sizeChangeListeners.push(a)}removeSizeChangeListener(a){this.sizeChangeListeners.splice(this.sizeChangeListeners.indexOf(a),1)}onResizePointerDown(a){this.isEditable()&&(this.bringToFront(),Vb(a)||(this.preResizeSize=this.getSize(),Sg(this.workspace,
a,new fa(this.workspace.RTL?-this.getSize().width:this.getSize().width,this.getSize().height)),this.resizePointerUpListener=ta(document,"pointerup",this,this.onResizePointerUp),this.resizePointerMoveListener=ta(document,"pointermove",this,this.onResizePointerMove),this.workspace.hideChaff()),a.stopPropagation())}onResizePointerUp(a){Ea();this.resizePointerUpListener&&(Na(this.resizePointerUpListener),this.resizePointerUpListener=null);this.resizePointerMoveListener&&(Na(this.resizePointerMoveListener),
this.resizePointerMoveListener=null);this.setSize(this.size);this.preResizeSize=void 0}onResizePointerMove(a){a=Tg(this.workspace,a);this.setSizeWithoutFiringEvents(new Aa(this.workspace.RTL?-a.x:a.x,a.y))}isCollapsed(){return this.collapsed}setCollapsed(a){(this.collapsed=a)?sa(this.svgRoot,"blocklyCollapsed"):Ma(this.svgRoot,"blocklyCollapsed");this.setSizeWithoutFiringEvents(this.size);this.onCollapse()}onCollapse(){for(let a=this.collapseChangeListeners.length-1;0<=a;a--)this.collapseChangeListeners[a](this.collapsed)}addOnCollapseListener(a){this.collapseChangeListeners.push(a)}removeOnCollapseListener(a){this.collapseChangeListeners.splice(this.collapseChangeListeners.indexOf(a),
1)}onFoldoutDown(a){Ea();this.bringToFront();Vb(a)||(this.setCollapsed(!this.collapsed),this.workspace.hideChaff());a.stopPropagation()}isEditable(){return this.editable}setEditable(a){(this.editable=a)?(sa(this.svgRoot,"blocklyEditable"),Ma(this.svgRoot,"blocklyReadonly"),this.textArea.removeAttribute("readonly")):(Ma(this.svgRoot,"blocklyEditable"),sa(this.svgRoot,"blocklyReadonly"),this.textArea.setAttribute("readonly","true"))}getRelativeToSurfaceXY(){return this.location}moveTo(a){this.location=
a;this.svgRoot.setAttribute("transform",`translate(${a.x}, ${a.y})`)}getText(){return this.text}setText(a){this.textArea.value=a;this.onTextChange()}addTextChangeListener(a){this.textChangeListeners.push(a)}removeTextChangeListener(a){this.textChangeListeners.splice(this.textChangeListeners.indexOf(a),1)}onTextChange(){const a=this.text;this.text=this.textArea.value;this.updateTextPreview(this.text);this.setSize(this.size);for(let b=this.textChangeListeners.length-1;0<=b;b--)this.textChangeListeners[b](a,
this.text)}updateTextPreview(a){this.textPreviewNode.textContent=this.truncateText(a)}truncateText(a){return 12<=a.length?`${a.substring(0,9)}...`:a}bringToFront(){const a=this.svgRoot.parentNode,b=a.childNodes;b[b.length-1]!==this.svgRoot&&a.appendChild(this.svgRoot)}onDeleteDown(a){Ea();Vb(a)||this.dispose();a.stopPropagation()}dispose(){this.disposing=!0;Ia(this.svgRoot);for(let a=this.disposeListeners.length-1;0<=a;a--)this.disposeListeners[a]();this.disposed=!0}isDisposed(){return this.disposed}isDeadOrDying(){return this.disposing||
this.disposed}addDisposeListener(a){this.disposeListeners.push(a)}removeDisposeListener(a){this.disposeListeners.splice(this.disposeListeners.indexOf(a),1)}};mc("\n.injectionDiv {\n  --commentFillColour: #FFFCC7;\n  --commentBorderColour: #F2E49B;\n}\n\n.blocklyComment .blocklyTextarea {\n  background-color: var(--commentFillColour);\n  border: 1px solid var(--commentBorderColour);\n  box-sizing: border-box;\n  display: block;\n  outline: 0;\n  padding: 5px;\n  resize: none;\n  width: 100%;\n  height: 100%;\n}\n\n.blocklyReadonly.blocklyComment .blocklyTextarea {\n  cursor: inherit;\n}\n\n.blocklyDeleteIcon {\n  width: 20px;\n  height: 20px;\n  display: none;\n  cursor: pointer;\n}\n\n.blocklyFoldoutIcon {\n  width: 20px;\n  height: 20px;\n  transform-origin: 12px 12px;\n  cursor: pointer;\n}\n.blocklyResizeHandle {\n  width: 12px;\n  height: 12px;\n  cursor: se-resize;\n}\n.blocklyReadonly.blocklyComment .blocklyResizeHandle {\n  cursor: inherit;\n}\n\n.blocklyCommentTopbarBackground {\n  fill: var(--commentBorderColour);\n  height: 24px;\n}\n\n.blocklyComment .blocklyCommentPreview.blocklyText {\n  fill: #000;\n  dominant-baseline: middle;\n  visibility: hidden;\n}\n\n.blocklyCollapsed.blocklyComment .blocklyCommentPreview {\n  visibility: visible;\n}\n\n.blocklyCollapsed.blocklyComment .blocklyCommentForeignObject,\n.blocklyCollapsed.blocklyComment .blocklyResizeHandle {\n  display: none;\n}\n\n.blocklyCollapsed.blocklyComment .blocklyFoldoutIcon {\n  transform: rotate(-90deg);\n}\n\n.blocklyRTL .blocklyCommentTopbar {\n  transform: scale(-1, 1);\n}\n\n.blocklyRTL .blocklyCommentForeignObject {\n  direction: rtl;\n}\n\n.blocklyRTL .blocklyCommentPreview {\n  /* Revert the scale and control RTL using direction instead. */\n  transform: scale(-1, 1);\n  direction: rtl;\n}\n\n.blocklyRTL .blocklyResizeHandle {\n  transform: scale(-1, 1);\n  cursor: sw-resize;\n}\n\n.blocklyCommentHighlight {\n  fill: none;\n}\n\n.blocklySelected .blocklyCommentHighlight {\n  stroke: #fc3;\n  stroke-width: 3px;\n}\n\n.blocklyCollapsed.blocklySelected .blocklyCommentHighlight {\n  stroke: none;\n}\n\n.blocklyCollapsed.blocklySelected .blocklyCommentTopbarBackground {\n  stroke: #fc3;\n  stroke-width: 3px;\n}\n");
var lf=class{constructor(a,b){this.workspace=a;this.text="";this.size=new Aa(120,100);this.collapsed=!1;this.deletable=this.movable=this.editable=!0;this.location=new fa(0,0);this.disposing=this.disposed=!1;this.id=b&&!a.getCommentById(b)?b:da();a.addTopComment(this);this.fireCreateEvent()}fireCreateEvent(){ia()&&aa(new (la(O.COMMENT_CREATE))(this))}fireDeleteEvent(){ia()&&aa(new (la(O.COMMENT_DELETE))(this))}fireChangeEvent(a,b){ia()&&aa(new (la(O.COMMENT_CHANGE))(this,a,b))}fireCollapseEvent(a){ia()&&
aa(new (la(O.COMMENT_COLLAPSE))(this,a))}setText(a){const b=this.text;this.text=a;this.fireChangeEvent(b,a)}getText(){return this.text}setSize(a){const b=new (la(O.COMMENT_RESIZE))(this);this.size=a;b.recordCurrentSizeAsNewSize();aa(b)}getSize(){return this.size}setCollapsed(a){this.collapsed=a;this.fireCollapseEvent(a)}isCollapsed(){return this.collapsed}setEditable(a){this.editable=a}isEditable(){return this.isOwnEditable()&&!this.workspace.options.readOnly}isOwnEditable(){return this.editable}setMovable(a){this.movable=
a}isMovable(){return this.isOwnMovable()&&!this.workspace.options.readOnly}isOwnMovable(){return this.movable}setDeletable(a){this.deletable=a}isDeletable(){return this.isOwnDeletable()&&!this.isDeadOrDying()&&!this.workspace.options.readOnly}isOwnDeletable(){return this.deletable}moveTo(a,b){const f=new (la(O.COMMENT_MOVE))(this);b&&f.setReason(b);this.location=a;f.recordNew();aa(f)}getRelativeToSurfaceXY(){return this.location}dispose(){this.disposing=!0;this.fireDeleteEvent();this.workspace.removeTopComment(this);
this.disposed=!0}isDisposed(){return this.disposed}isDeadOrDying(){return this.disposing||this.disposed}},kf=class extends lf{constructor(a,b){super(a,b);this.dragStrategy=new sl(this);this.workspace=a;this.view=new tl(a);this.view.setSize(this.getSize());this.view.setEditable(this.isEditable());this.view.getSvgRoot().setAttribute("data-id",this.id);this.addModelUpdateBindings();ta(this.view.getSvgRoot(),"pointerdown",this,this.startGesture);ta(this.view.getSvgRoot(),"wheel",this,f=>{f.stopPropagation()})}addModelUpdateBindings(){this.view.addTextChangeListener((a,
b)=>void super.setText(b));this.view.addSizeChangeListener((a,b)=>void super.setSize(b));this.view.addOnCollapseListener(()=>void super.setCollapsed(this.view.isCollapsed()));this.view.addDisposeListener(()=>{this.isDeadOrDying()||this.dispose()})}setText(a){this.view.setText(a)}setSize(a){this.view.setSize(a)}setCollapsed(a){this.view.setCollapsed(a)}setEditable(a){super.setEditable(a);this.view.setEditable(this.isEditable())}getSvgRoot(){return this.view.getSvgRoot()}getSize(){return super.getSize()}getBoundingRectangle(){const a=
this.getRelativeToSurfaceXY();var b,f;const g=null!=(f=null==(b=this.view)?void 0:b.getSize())?f:this.getSize();this.workspace.RTL?(b=a.x-g.width,f=a.x):(b=a.x,f=a.x+g.width);return new Ja(a.y,a.y+g.height,b,f)}moveBy(a,b,f){const g=this.getRelativeToSurfaceXY();a=new fa(g.x+a,g.y+b);this.moveTo(a,f)}moveTo(a,b){super.moveTo(a,b);this.view.moveTo(a)}moveDuringDrag(a){this.location=a;this.view.moveTo(a)}setDragging(a){a?sa(this.getSvgRoot(),"blocklyDragging"):Ma(this.getSvgRoot(),"blocklyDragging")}dispose(){this.disposing=
!0;this.view.isDeadOrDying()||this.view.dispose();super.dispose()}startGesture(a){const b=this.workspace.getGesture(a);if(b){if(Jd(a))a.stopPropagation();else{b.handleCommentStart(a,this);let f;null==(f=this.workspace.getLayerManager())||f.append(this,50)}d.setSelected$$module$build$src$core$common(this)}}setDeleteStyle(a){a?sa(this.getSvgRoot(),"blocklyDraggingDelete"):Ma(this.getSvgRoot(),"blocklyDraggingDelete")}isMovable(){return this.dragStrategy.isMovable()}startDrag(){this.dragStrategy.startDrag()}drag(a){this.dragStrategy.drag(a)}endDrag(){this.dragStrategy.endDrag()}revertDrag(){this.dragStrategy.revertDrag()}select(){sa(this.getSvgRoot(),
"blocklySelected")}unselect(){Ma(this.getSvgRoot(),"blocklySelected")}toCopyData(){return{paster:wf.TYPE,commentState:Od(this,{addCoordinates:!0})}}showContextMenu(a){const b=za.registry.getContextMenuOptions(za.ScopeType.COMMENT,{comment:this});gf(a,b,this.workspace.RTL,this.workspace)}snapToGrid(){if(!this.isDeadOrDying()){var a=this.workspace.getGrid();if(null!=a&&a.shouldSnap()){var b=this.getRelativeToSurfaceXY();a=a.alignXY(b);a!==b&&this.moveTo(a,["snap"])}}}},gb={appendDomToWorkspace:function(a,
b){if(!b.getBlocksBoundingBox)return d.domToWorkspace$$module$build$src$core$xml(a,b);var f=b.getBlocksBoundingBox();a=d.domToWorkspace$$module$build$src$core$xml(a,b);if(f&&f.top!==f.bottom){var g=f.bottom;f=b.RTL?f.right:f.left;var l=Infinity;let n=-Infinity,x=Infinity;for(let B=0;B<a.length;B++){const V=b.getBlockById(a[B]).getRelativeToSurfaceXY();V.y<x&&(x=V.y);V.x<l&&(l=V.x);V.x>n&&(n=V.x)}g=g-x+10;f=b.RTL?f-n:f-l;for(l=0;l<a.length;l++)b.getBlockById(a[l]).moveBy(f,g,["create"])}return a}};
gb.blockToDom=Kc;gb.blockToDomWithXY=jf;gb.clearWorkspaceAndLoadFromXml=function(a,b){b.setResizesEnabled(!1);b.clear();a=d.domToWorkspace$$module$build$src$core$xml(a,b);b.setResizesEnabled(!0);return a};gb.deleteNext=function(a){for(let b=0;b<a.childNodes.length;b++){const f=a.childNodes[b];if("next"===f.nodeName.toLowerCase()){a.removeChild(f);break}}};gb.domToBlock=d.domToBlock$$module$build$src$core$xml;gb.domToBlockInternal=qd;gb.domToPrettyText=function(a){a=Xb(a).split("<");let b="";for(let f=
1;f<a.length;f++){const g=a[f];"/"===g[0]&&(b=b.substring(2));a[f]=b+"<"+g;"/"!==g[0]&&"/>"!==g.slice(-2)&&(b+="  ")}a=a.join("\n");a=a.replace(/(<(\w+)\b[^>]*>[^\n]*)\n *<\/\2>/g,"$1</$2>");return a.replace(/^\n/,"")};gb.domToText=Xb;gb.domToVariables=Zj;gb.domToWorkspace=d.domToWorkspace$$module$build$src$core$xml;gb.loadWorkspaceComment=Yj;gb.saveWorkspaceComment=hf;gb.variablesToDom=Vj;gb.workspaceToDom=function(a,b=!1){const f=d.createElement$$module$build$src$core$utils$xml("xml");var g=Vj(d.allUsedVarModels$$module$build$src$core$variables(a));
g.hasChildNodes()&&f.appendChild(g);for(const l of a.getTopComments())f.appendChild(hf(l,b));a=a.getTopBlocks(!0);for(g=0;g<a.length;g++)f.appendChild(jf(a[g],b));return f};var uh=class extends Sc{constructor(a){super(a);this.type=O.BLOCK_CREATE;a&&(a.isShadow()&&(this.recordUndo=!1),this.xml=jf(a),this.ids=Da(a),this.json=vb(a,{addCoordinates:!0}))}toJson(){const a=super.toJson();if(!this.xml)throw Error("The block XML is undefined. Either pass a block to the constructor, or call fromJson");if(!this.ids)throw Error("The block IDs are undefined. Either pass a block to the constructor, or call fromJson");
if(!this.json)throw Error("The block JSON is undefined. Either pass a block to the constructor, or call fromJson");a.xml=Xb(this.xml);a.ids=this.ids;a.json=this.json;this.recordUndo||(a.recordUndo=this.recordUndo);return a}static fromJson(a,b,f){b=super.fromJson(a,b,null!=f?f:new uh);b.xml=d.textToDom$$module$build$src$core$utils$xml(a.xml);b.ids=a.ids;b.json=a.json;void 0!==a.recordUndo&&(b.recordUndo=a.recordUndo);return b}run(a){const b=this.getEventWorkspace_();if(!this.json)throw Error("The block JSON is undefined. Either pass a block to the constructor, or call fromJson");
if(!this.ids)throw Error("The block IDs are undefined. Either pass a block to the constructor, or call fromJson");if(!lo(b,this.ids))if(a)pc(this.json,b);else for(a=0;a<this.ids.length;a++){const f=this.ids[a],g=b.getBlockById(f);g?g.dispose(!1):f===this.blockId&&console.warn("Can't uncreate non-existent block: "+f)}}},lo=function(a,b){return b.map(f=>a.getBlockById(f)).filter(f=>f&&f.isShadow()).length===b.length};e(ba.EVENT,O.BLOCK_CREATE,uh);var vh=class extends Eb{constructor(a,b){super(b);this.type=
O.THEME_CHANGE;this.themeName=a}toJson(){const a=super.toJson();if(!this.themeName)throw Error("The theme name is undefined. Either pass a theme name to the constructor, or call fromJson");a.themeName=this.themeName;return a}static fromJson(a,b,f){b=super.fromJson(a,b,null!=f?f:new vh);b.themeName=a.themeName;return b}};e(ba.EVENT,O.THEME_CHANGE,vh);var wh=class extends Eb{constructor(a,b,f,g,l){super(g);this.type=O.VIEWPORT_CHANGE;this.viewTop=a;this.viewLeft=b;this.scale=f;this.oldScale=l}toJson(){const a=
super.toJson();if(void 0===this.viewTop)throw Error("The view top is undefined. Either pass a value to the constructor, or call fromJson");if(void 0===this.viewLeft)throw Error("The view left is undefined. Either pass a value to the constructor, or call fromJson");if(void 0===this.scale)throw Error("The scale is undefined. Either pass a value to the constructor, or call fromJson");if(void 0===this.oldScale)throw Error("The old scale is undefined. Either pass a value to the constructor, or call fromJson");
a.viewTop=this.viewTop;a.viewLeft=this.viewLeft;a.scale=this.scale;a.oldScale=this.oldScale;return a}static fromJson(a,b,f){b=super.fromJson(a,b,null!=f?f:new wh);b.viewTop=a.viewTop;b.viewLeft=a.viewLeft;b.scale=a.scale;b.oldScale=a.oldScale;return b}};e(ba.EVENT,O.VIEWPORT_CHANGE,wh);var oa;(function(a){a[a.INPUT_VALUE=1]="INPUT_VALUE";a[a.OUTPUT_VALUE=2]="OUTPUT_VALUE";a[a.NEXT_STATEMENT=3]="NEXT_STATEMENT";a[a.PREVIOUS_STATEMENT=4]="PREVIOUS_STATEMENT"})(oa||={});var zd=class{constructor(a){this.connectionChecker=
a;this.connections=[]}addConnection(a,b){b=this.calculateIndexForYPos(b);this.connections.splice(b,0,a)}findIndexOfConnection(a,b){if(!this.connections.length)return-1;const f=this.calculateIndexForYPos(b);if(f>=this.connections.length)return-1;b=a.y;let g=f;for(;0<=g&&this.connections[g].y===b;){if(this.connections[g]===a)return g;g--}for(g=f;g<this.connections.length&&this.connections[g].y===b;){if(this.connections[g]===a)return g;g++}return-1}calculateIndexForYPos(a){if(!this.connections.length)return 0;
let b=0,f=this.connections.length;for(;b<f;){const g=Math.floor((b+f)/2);if(this.connections[g].y<a)b=g+1;else if(this.connections[g].y>a)f=g;else{b=g;break}}return b}removeConnection(a,b){a=this.findIndexOfConnection(a,b);if(-1===a)throw Error("Unable to find connection in connectionDB.");this.connections.splice(a,1)}getNeighbours(a,b){function f(na){const Pa=l-g[na].x,La=n-g[na].y;Math.sqrt(Pa*Pa+La*La)<=b&&V.push(g[na]);return La<b}const g=this.connections,l=a.x,n=a.y;a=0;let x=g.length-2,B=x;
for(;a<B;)g[B].y<n?a=B:x=B,B=Math.floor((a+x)/2);const V=[];x=a=B;if(g.length){for(;0<=a&&f(a);)a--;do x++;while(x<g.length&&f(x))}return V}isInYRange(a,b,f){return Math.abs(this.connections[a].y-b)<=f}searchForClosest(a,b,f){if(!this.connections.length)return{connection:null,radius:b};const g=a.y,l=a.x;a.x=l+f.x;a.y=g+f.y;var n=this.calculateIndexForYPos(a.y);f=null;let x=b,B,V=n-1;for(;0<=V&&this.isInYRange(V,a.y,b);)B=this.connections[V],this.connectionChecker.canConnect(a,B,!0,x)&&(f=B,x=B.distanceFrom(a)),
V--;for(;n<this.connections.length&&this.isInYRange(n,a.y,b);)B=this.connections[n],this.connectionChecker.canConnect(a,B,!0,x)&&(f=B,x=B.distanceFrom(a)),n++;a.x=l;a.y=g;return{connection:f,radius:x}}static init(a){const b=[];b[oa.INPUT_VALUE]=new zd(a);b[oa.OUTPUT_VALUE]=new zd(a);b[oa.NEXT_STATEMENT]=new zd(a);b[oa.PREVIOUS_STATEMENT]=new zd(a);return b}},mf=null,fe=null,pe={};pe.connectionUiEffect=Wg;pe.disconnectUiEffect=dk;pe.disconnectUiStop=ee;pe.disposeUiEffect=Vg;var ul=class{constructor(a){this.workspace=
a;this.horizontalScrollEnabled=this.workspace.isMovableHorizontally();this.verticalScrollEnabled=this.workspace.isMovableVertically();this.startScrollXY_=new fa(a.scrollX,a.scrollY)}dispose(){this.workspace=null}startDrag(){U()&&U().unselect()}endDrag(a){this.drag(a)}drag(a){a=fa.sum(this.startScrollXY_,a);if(this.horizontalScrollEnabled&&this.verticalScrollEnabled)this.workspace.scroll(a.x,a.y);else if(this.horizontalScrollEnabled)this.workspace.scroll(a.x,this.workspace.scrollY);else if(this.verticalScrollEnabled)this.workspace.scroll(this.workspace.scrollX,
a.y);else throw new TypeError("Invalid state.");}},bc=class{constructor(a,b){this.creatorWorkspace=b;this.mouseDownXY=new fa(0,0);this.startWorkspace_=this.targetBlock=this.startComment=this.startBlock=this.startIcon=this.startField=this.startBubble=null;this.hasExceededDragRadius=!1;this.boundEvents=[];this.workspaceDragger=this.dragger=null;this.dragging=!1;this.flyout=null;this.multiTouch=this.isEnding_=this.gestureHasStarted=this.calledUpdateIsDragging=!1;this.cachedPoints=new Map;this.startDistance=
this.previousScale=0;this.currentDropdownOwner=this.isPinchZoomEnabled=null;this.mostRecentEvent=a;this.currentDragDeltaXY=new fa(0,0)}dispose(){Ea();Ej();this.creatorWorkspace.clearGesture();for(const a of this.boundEvents)Na(a);this.boundEvents.length=0;this.workspaceDragger&&this.workspaceDragger.dispose()}updateFromEvent(a){const b=new fa(a.clientX,a.clientY);this.updateDragDelta(b)&&(this.updateIsDragging(a),wa());this.mostRecentEvent=a}updateDragDelta(a){this.currentDragDeltaXY=fa.difference(a,
this.mouseDownXY);return this.hasExceededDragRadius?!1:this.hasExceededDragRadius=fa.magnitude(this.currentDragDeltaXY)>(this.flyout?d.config$$module$build$src$core$config.flyoutDragRadius:d.config$$module$build$src$core$config.dragRadius)}updateIsDraggingFromFlyout(){let a;if(!this.targetBlock||null==(a=this.flyout)||!a.isBlockCreatable(this.targetBlock))return!1;if(!this.flyout.targetWorkspace)throw Error("Cannot update dragging from the flyout because the ' +\n          'flyout's target workspace is undefined");
return!this.flyout.isScrollable()||this.flyout.isDragTowardWorkspace(this.currentDragDeltaXY)?(this.startWorkspace_=this.flyout.targetWorkspace,this.startWorkspace_.updateScreenCalculationsIfScrolled(),d.getGroup$$module$build$src$core$events$utils()||d.setGroup$$module$build$src$core$events$utils(!0),this.startBlock=null,this.targetBlock=this.flyout.createBlock(this.targetBlock),d.setSelected$$module$build$src$core$common(this.targetBlock),!0):!1}updateIsDraggingWorkspace(){if(!this.startWorkspace_)throw Error("Cannot update dragging the workspace because the start workspace is undefined");
if(this.flyout?this.flyout.isScrollable():this.startWorkspace_&&this.startWorkspace_.isDraggable())this.dragging=!0,this.workspaceDragger=new ul(this.startWorkspace_),this.workspaceDragger.startDrag()}updateIsDragging(a){if(!this.startWorkspace_)throw Error("Cannot update dragging because the start workspace is undefined");if(this.calledUpdateIsDragging)throw Error("updateIsDragging_ should only be called once per gesture.");this.calledUpdateIsDragging=!0;this.flyout&&this.updateIsDraggingFromFlyout();
const b=U();b&&sd(b)&&b.isMovable()?(this.dragging=!0,this.dragger=this.createDragger(b,this.startWorkspace_),this.dragger.onDragStart(a),this.dragger.onDrag(a,this.currentDragDeltaXY)):this.updateIsDraggingWorkspace()}createDragger(a,b){return new (I(ba.BLOCK_DRAGGER,this.creatorWorkspace.options,!0))(a,b)}doStart(a){if(!this.startWorkspace_)throw Error("Cannot start the touch gesture becauase the start workspace is undefined");this.isPinchZoomEnabled=this.startWorkspace_.options.zoomOptions&&this.startWorkspace_.options.zoomOptions.pinch;
Jd(a)?this.cancel():(this.gestureHasStarted=!0,ee(),this.startWorkspace_.updateScreenCalculationsIfScrolled(),this.startWorkspace_.isMutator&&this.startWorkspace_.resize(),this.currentDropdownOwner=fj(),this.startWorkspace_.hideChaff(!!this.flyout),this.startWorkspace_.markFocused(),this.mostRecentEvent=a,Dj(),Vb(a)?this.handleRightClick(a):("pointerdown"===a.type.toLowerCase()&&"mouse"!==a.pointerType&&ra(a,this),this.mouseDownXY=new fa(a.clientX,a.clientY),this.bindMouseEvents(a),this.isEnding_||
this.handleTouchStart(a)))}bindMouseEvents(a){this.boundEvents.push(ta(document,"pointerdown",null,this.handleStart.bind(this),!0));this.boundEvents.push(ta(document,"pointermove",null,this.handleMove.bind(this),!0));this.boundEvents.push(ta(document,"pointerup",null,this.handleUp.bind(this),!0));a.preventDefault();a.stopPropagation()}handleStart(a){this.isDragging()||(this.handleTouchStart(a),this.isMultiTouch()&&wa())}handleMove(a){if(this.isDragging()&&ub(a)||!this.isMultiTouch()){this.updateFromEvent(a);
if(this.workspaceDragger)this.workspaceDragger.drag(this.currentDragDeltaXY);else if(this.dragger)this.dragger.onDrag(this.mostRecentEvent,this.currentDragDeltaXY);a.preventDefault();a.stopPropagation()}else this.isMultiTouch()&&(this.handleTouchMove(a),wa())}handleUp(a){this.isDragging()||this.handleTouchEnd(a);if(!this.isMultiTouch()||this.isDragging()){if(!ub(a))return;this.updateFromEvent(a);wa();if(this.isEnding_){console.log("Trying to end a gesture recursively.");return}this.isEnding_=!0;if(this.dragger)this.dragger.onDragEnd(a,
this.currentDragDeltaXY);else this.workspaceDragger?this.workspaceDragger.endDrag(this.currentDragDeltaXY):this.isBubbleClick()||this.isCommentClick()||(this.isFieldClick()?this.doFieldClick():this.isIconClick()?this.doIconClick():this.isBlockClick()?this.doBlockClick():this.isWorkspaceClick()&&this.doWorkspaceClick(a))}a.preventDefault();a.stopPropagation();this.dispose()}handleTouchStart(a){var b=Id(a);this.cachedPoints.set(b,this.getTouchPoint(a));var f=Array.from(this.cachedPoints.keys());2===
f.length&&(b=this.cachedPoints.get(f[0]),f=this.cachedPoints.get(f[1]),this.startDistance=fa.distance(b,f),this.multiTouch=!0,a.preventDefault())}handleTouchMove(a){const b=Id(a);this.cachedPoints.set(b,this.getTouchPoint(a));if(this.isPinchZoomEnabled&&2===this.cachedPoints.size)this.handlePinch(a);else{this.updateFromEvent(a);if(this.workspaceDragger)this.workspaceDragger.drag(this.currentDragDeltaXY);else if(this.dragger)this.dragger.onDrag(this.mostRecentEvent,this.currentDragDeltaXY);a.preventDefault();
a.stopPropagation()}}handlePinch(a){var b=Array.from(this.cachedPoints.keys()),f=this.cachedPoints.get(b[0]);b=this.cachedPoints.get(b[1]);f=fa.distance(f,b)/this.startDistance;if(0<this.previousScale&&Infinity>this.previousScale){b=f-this.previousScale;b=0<b?5*b:6*b;if(!this.startWorkspace_)throw Error("Cannot handle a pinch because the start workspace is undefined");const g=this.startWorkspace_,l=Kd(a,g.getParentSvg(),g.getInverseScreenCTM());g.zoom(l.x,l.y,b)}this.previousScale=f;a.preventDefault()}handleTouchEnd(a){a=
Id(a);this.cachedPoints.has(a)&&this.cachedPoints.delete(a);2>this.cachedPoints.size&&(this.cachedPoints.clear(),this.previousScale=0)}getTouchPoint(a){return this.startWorkspace_?new fa(a.pageX,a.pageY):null}isMultiTouch(){return this.multiTouch}cancel(){if(!this.isEnding_){wa();if(this.dragger)this.dragger.onDragEnd(this.mostRecentEvent,this.currentDragDeltaXY);else this.workspaceDragger&&this.workspaceDragger.endDrag(this.currentDragDeltaXY);this.dispose()}}handleRightClick(a){this.targetBlock?
(this.bringBlockToFront(),this.targetBlock.workspace.hideChaff(!!this.flyout),this.targetBlock.showContextMenu(a)):this.startBubble?this.startBubble.showContextMenu(a):this.startComment?(this.startComment.workspace.hideChaff(),this.startComment.showContextMenu(a)):this.startWorkspace_&&!this.flyout&&(this.startWorkspace_.hideChaff(),this.startWorkspace_.showContextMenu(a));a.preventDefault();a.stopPropagation();this.dispose()}handleWsStart(a,b){if(this.gestureHasStarted)throw Error("Tried to call gesture.handleWsStart, but the gesture had already been started.");
this.setStartWorkspace(b);this.mostRecentEvent=a;this.startBlock||this.startBubble||this.startComment||d.setSelected$$module$build$src$core$common(null);this.doStart(a)}fireWorkspaceClick(a){aa(new (la(O.CLICK))(null,a.id,"workspace"))}handleFlyoutStart(a,b){if(this.gestureHasStarted)throw Error("Tried to call gesture.handleFlyoutStart, but the gesture had already been started.");this.setStartFlyout(b);this.handleWsStart(a,b.getWorkspace())}handleBlockStart(a,b){if(this.gestureHasStarted)throw Error("Tried to call gesture.handleBlockStart, but the gesture had already been started.");
this.setStartBlock(b);this.mostRecentEvent=a}handleBubbleStart(a,b){if(this.gestureHasStarted)throw Error("Tried to call gesture.handleBubbleStart, but the gesture had already been started.");this.setStartBubble(b);this.mostRecentEvent=a}handleCommentStart(a,b){if(this.gestureHasStarted)throw Error("Tried to call gesture.handleCommentStart, but the gesture had already been started.");this.setStartComment(b);this.mostRecentEvent=a}doFieldClick(){if(!this.startField)throw Error("Cannot do a field click because the start field is undefined");
this.currentDropdownOwner!==this.startField&&this.startField.showEditor(this.mostRecentEvent);this.bringBlockToFront()}doIconClick(){if(!this.startIcon)throw Error("Cannot do an icon click because the start icon is undefined");this.bringBlockToFront();this.startIcon.onClick()}doBlockClick(){if(this.flyout&&this.flyout.autoClose){if(!this.targetBlock)throw Error("Cannot do a block click because the target block is undefined");if(this.targetBlock.isEnabled()){d.getGroup$$module$build$src$core$events$utils()||
d.setGroup$$module$build$src$core$events$utils(!0);var a=this.flyout.createBlock(this.targetBlock);a.snapToGrid();a.bumpNeighbours()}}else{if(!this.startWorkspace_)throw Error("Cannot do a block click because the start workspace is undefined");a=new (la(O.CLICK))(this.startBlock,this.startWorkspace_.id,"block");aa(a)}this.bringBlockToFront();d.setGroup$$module$build$src$core$events$utils(!1)}doWorkspaceClick(a){a=this.creatorWorkspace;U()&&U().unselect();this.fireWorkspaceClick(this.startWorkspace_||
a)}bringBlockToFront(){this.targetBlock&&!this.flyout&&this.targetBlock.bringToFront()}setStartField(a){if(this.gestureHasStarted)throw Error("Tried to call gesture.setStartField, but the gesture had already been started.");this.startField||(this.startField=a)}setStartIcon(a){if(this.gestureHasStarted)throw Error("Tried to call gesture.setStartIcon, but the gesture had already been started.");this.startIcon||(this.startIcon=a)}setStartBubble(a){this.startBubble||(this.startBubble=a)}setStartComment(a){this.startComment||
(this.startComment=a)}setStartBlock(a){this.startBlock||this.startBubble||(this.startBlock=a,d.setSelected$$module$build$src$core$common(this.startBlock),a.isInFlyout&&a!==a.getRootBlock()?this.setTargetBlock(a.getRootBlock()):this.setTargetBlock(a))}setTargetBlock(a){a.isShadow()?this.setTargetBlock(a.getParent()):this.targetBlock=a}setStartWorkspace(a){this.startWorkspace_||(this.startWorkspace_=a)}setStartFlyout(a){this.flyout||(this.flyout=a)}isBubbleClick(){return!!this.startBubble&&!this.hasExceededDragRadius}isCommentClick(){return!!this.startComment&&
!this.hasExceededDragRadius}isBlockClick(){return!!this.startBlock&&!this.hasExceededDragRadius&&!this.isFieldClick()&&!this.isIconClick()}isFieldClick(){return this.startField?this.startField.isClickable()&&!this.hasExceededDragRadius&&(!this.flyout||this.startField.isClickableInFlyout(this.flyout.autoClose)):!1}isIconClick(){if(!this.startIcon)return!1;const a=!this.flyout||!this.startIcon.isClickableInFlyout||this.startIcon.isClickableInFlyout(this.flyout.autoClose);return!this.hasExceededDragRadius&&
a}isWorkspaceClick(){return!this.startBlock&&!this.startBubble&&!this.startField&&!this.hasExceededDragRadius}getCurrentDragger(){let a,b;return null!=(b=null!=(a=this.workspaceDragger)?a:this.dragger)?b:null}isDragging(){return this.dragging}hasStarted(){return this.gestureHasStarted}static inProgress(){const a=va();for(let b=0,f;f=a[b];b++)if(f.currentGesture_)return!0;return!1}},hh=class{constructor(a,b){this.pattern=a;this.scale=1;let f;this.spacing=null!=(f=b.spacing)?f:0;let g;this.length=null!=
(g=b.length)?g:1;this.line2=(this.line1=a.firstChild)&&this.line1.nextSibling;let l;this.snapToGrid=null!=(l=b.snap)?l:!1}setSpacing(a){this.spacing=a;this.update(this.scale)}getSpacing(){return this.spacing}setLength(a){this.length=a;this.update(this.scale)}getLength(){return this.length}setSnapToGrid(a){this.snapToGrid=a}shouldSnap(){return this.snapToGrid}getPatternId(){return this.pattern.id}update(a){this.scale=a;var b=this.spacing*a;this.pattern.setAttribute("width",`${b}`);this.pattern.setAttribute("height",
`${b}`);b=Math.floor(this.spacing/2)+.5;let f=b-this.length/2,g=b+this.length/2;b*=a;f*=a;g*=a;this.setLineAttributes(this.line1,a,f,g,b,b);this.setLineAttributes(this.line2,a,b,b,f,g)}setLineAttributes(a,b,f,g,l,n){a&&(a.setAttribute("stroke-width",`${b}`),a.setAttribute("x1",`${f}`),a.setAttribute("y1",`${l}`),a.setAttribute("x2",`${g}`),a.setAttribute("y2",`${n}`))}moveTo(a,b){this.pattern.setAttribute("x",`${a}`);this.pattern.setAttribute("y",`${b}`)}alignXY(a){var b=this.getSpacing();const f=
b/2,g=Math.round(Math.round((a.x-f)/b)*b+f);b=Math.round(Math.round((a.y-f)/b)*b+f);return g===a.x&&b===a.y?a:new fa(g,b)}static createDom(a,b,f){a=T(J.PATTERN,{id:"blocklyGridPattern"+a,patternUnits:"userSpaceOnUse"},f);let g,l;if(0<(null!=(g=b.length)?g:1)&&0<(null!=(l=b.spacing)?l:0)){T(J.LINE,{stroke:b.colour},a);let n;null!=(n=b.length)&&n&&T(J.LINE,{stroke:b.colour},a)}else T(J.LINE,{},a);return a}},mo=class{constructor(a){this.workspace=a;this.layers=new Map;if(a=a.getInjectionDiv())this.dragLayer=
this.createDragLayer(a),this.animationLayer=this.createAnimationLayer(a);a=this.createLayer(50);sa(a,"blocklyBlockCanvas");a=this.createLayer(100);sa(a,"blocklyBubbleCanvas")}createDragLayer(a){const b=T(J.SVG,{"class":"blocklyBlockDragSurface",xmlns:Ld,"xmlns:html":Nb,"xmlns:xlink":pb,version:"1.1"});a.append(b);return T(J.G,{},b)}createAnimationLayer(a){const b=T(J.SVG,{"class":"blocklyAnimationLayer",xmlns:Ld,"xmlns:html":Nb,"xmlns:xlink":pb,version:"1.1"});a.append(b);return T(J.G,{},b)}appendToAnimationLayer(a){let b;
const f=null==(b=this.dragLayer)?void 0:b.getAttribute("transform");if(f){let l;null==(l=this.animationLayer)||l.setAttribute("transform",f)}let g;null==(g=this.animationLayer)||g.appendChild(a.getSvgRoot())}translateLayers(a,b){a=`translate(${a.x}, ${a.y}) scale(${b})`;let f;null==(f=this.dragLayer)||f.setAttribute("transform",a);for(const [,g]of this.layers)g.setAttribute("transform",a)}moveToDragLayer(a){let b;null==(b=this.dragLayer)||b.appendChild(a.getSvgRoot())}moveOffDragLayer(a,b){this.append(a,
b)}append(a,b){this.layers.has(b)||this.createLayer(b);let f;null==(f=this.layers.get(b))||f.appendChild(a.getSvgRoot())}createLayer(a){const b=this.workspace.getSvgGroup(),f=T(J.G,{});let g=!1;const l=[...this.layers].sort((n,x)=>n[0]-x[0]);for(const [n,x]of l)if(a<n){b.insertBefore(f,x);g=!0;break}g||b.appendChild(f);this.layers.set(a,f);return f}hasLayer(a){return a===this.dragLayer||(new Set(this.layers.values())).has(a)}getBlockLayer(){return this.layers.get(50)}getBubbleLayer(){return this.layers.get(100)}},
vl={};vl.deepMerge=tc;var Vc=class{constructor(a,b,f,g){this.name=a;this.startHats=!1;this.blockStyles=b||Object.create(null);this.categoryStyles=f||Object.create(null);this.componentStyles=g||Object.create(null);this.fontStyle=Object.create(null);e(ba.THEME,a,this,!0)}getClassName(){return this.name+"-theme"}setBlockStyle(a,b){this.blockStyles[a]=b}setCategoryStyle(a,b){this.categoryStyles[a]=b}getComponentStyle(a){a=this.componentStyles[a];if(!a)return null;if("string"===typeof a){const b=this.getComponentStyle(a);
if(b)return b}return`${a}`}setComponentStyle(a,b){this.componentStyles[a]=b}setFontStyle(a){this.fontStyle=a}setStartHats(a){this.startHats=a}static defineTheme(a,b){a=a.toLowerCase();const f=new Vc(a);let g=b.base;if(g){if("string"===typeof g){let l;g=null!=(l=q(ba.THEME,g))?l:void 0}g instanceof Vc&&(tc(f,g),f.name=a)}tc(f.blockStyles,b.blockStyles);tc(f.categoryStyles,b.categoryStyles);tc(f.componentStyles,b.componentStyles);tc(f.fontStyle,b.fontStyle);null!==b.startHats&&(f.startHats=b.startHats);
return f}},Af=new Vc("classic",{colour_blocks:{colourPrimary:"20"},list_blocks:{colourPrimary:"260"},logic_blocks:{colourPrimary:"210"},loop_blocks:{colourPrimary:"120"},math_blocks:{colourPrimary:"230"},procedure_blocks:{colourPrimary:"290"},text_blocks:{colourPrimary:"160"},variable_blocks:{colourPrimary:"330"},variable_dynamic_blocks:{colourPrimary:"310"},hat_blocks:{colourPrimary:"330",hat:"cap"}},{colour_category:{colour:"20"},list_category:{colour:"260"},logic_category:{colour:"210"},loop_category:{colour:"120"},
math_category:{colour:"230"},procedure_category:{colour:"290"},text_category:{colour:"160"},variable_category:{colour:"330"},variable_dynamic_category:{colour:"310"}}),zb=class{constructor(a){this.gridPattern=null;this.getMetrics=this.setMetrics=void 0;let b=null,f=!1;var g=!1,l=!1,n=!1,x=!1,B=!1;const V=!!a.readOnly;if(!V){var na;b=bg(null!=(na=a.toolbox)?na:null);f=eg(b);g=a.trashcan;g=void 0===g?f:g;l=a.collapse;l=void 0===l?f:l;n=a.comments;n=void 0===n?f:n;x=a.disable;x=void 0===x?f:x;B=a.sounds;
B=void 0===B?!0:B}na=a.maxTrashcanContents;g?void 0===na&&(na=32):na=0;const Pa=!!a.rtl;let La=a.horizontalLayout;void 0===La&&(La=!1);var ib="end"!==a.toolboxPosition;ib=La?ib?xa.TOP:xa.BOTTOM:ib===Pa?xa.RIGHT:xa.LEFT;let rd=a.css;void 0===rd&&(rd=!0);let de="https://blockly-demo.appspot.com/static/media/";a.media&&(de=a.media.endsWith("/")?a.media:a.media+"/");const wl=a.oneBasedIndex,no=a.renderer||"geras",oo=a.plugins||{};let xh=a.modalInputs;void 0===xh&&(xh=!0);this.RTL=Pa;this.oneBasedIndex=
void 0===wl?!0:wl;this.collapse=l;this.comments=n;this.disable=x;this.readOnly=V;this.maxBlocks=a.maxBlocks||Infinity;let xl;this.maxInstances=null!=(xl=a.maxInstances)?xl:null;this.modalInputs=xh;this.pathToMedia=de;this.hasCategories=f;this.moveOptions=zb.parseMoveOptions(a,f);this.hasScrollbars=!!this.moveOptions.scrollbars;this.hasTrashcan=g;this.maxTrashcanContents=na;this.hasSounds=B;this.hasCss=rd;this.horizontalLayout=La;this.languageTree=b;this.gridOptions=zb.parseGridOptions(a);this.zoomOptions=
zb.parseZoomOptions(a);this.toolboxPosition=ib;this.theme=zb.parseThemeOptions(a);this.renderer=no;let yl;this.rendererOverrides=null!=(yl=a.rendererOverrides)?yl:null;let zl;this.parentWorkspace=null!=(zl=a.parentWorkspace)?zl:null;this.plugins=oo}static parseMoveOptions(a,b){const f=a.move||{},g={};void 0===f.scrollbars&&void 0===a.scrollbars?g.scrollbars=b:"object"===typeof f.scrollbars?(g.scrollbars={horizontal:!!f.scrollbars.horizontal,vertical:!!f.scrollbars.vertical},g.scrollbars.horizontal&&
g.scrollbars.vertical?g.scrollbars=!0:g.scrollbars.horizontal||g.scrollbars.vertical||(g.scrollbars=!1)):g.scrollbars=!!f.scrollbars||!!a.scrollbars;g.wheel=g.scrollbars&&void 0!==f.wheel?!!f.wheel:"object"===typeof g.scrollbars;g.drag=g.scrollbars?void 0===f.drag?!0:!!f.drag:!1;return g}static parseZoomOptions(a){a=a.zoom||{};const b={};b.controls=void 0===a.controls?!1:!!a.controls;b.wheel=void 0===a.wheel?!1:!!a.wheel;b.startScale=void 0===a.startScale?1:Number(a.startScale);b.maxScale=void 0===
a.maxScale?3:Number(a.maxScale);b.minScale=void 0===a.minScale?.3:Number(a.minScale);b.scaleSpeed=void 0===a.scaleSpeed?1.2:Number(a.scaleSpeed);b.pinch=void 0===a.pinch?b.wheel||b.controls:!!a.pinch;return b}static parseGridOptions(a){a=a.grid||{};const b={};b.spacing=Number(a.spacing)||0;b.colour=a.colour||"#888";b.length=void 0===a.length?1:Number(a.length);b.snap=0<b.spacing&&!!a.snap;return b}static parseThemeOptions(a){a=a.theme||Af;return"string"===typeof a?q(ba.THEME,a):a instanceof Vc?a:
Vc.defineTheme(a.name||"builtin"+Q(),a)}},ek={fromJsonInternal:function(a){const b=q(ba.FIELD,a.type);return b?b.fromJson(a):(console.warn("Blockly could not create a field of type "+a.type+". The field is probably not being registered. This could be because the file is not loaded, the field does not register itself (Issue #1584), or the registration is not being reached."),null)}},Bf={TEST_ONLY:ek};Bf.fromJson=d.fromJson$$module$build$src$core$field_registry;Bf.register=Zb;Bf.unregister=function(a){k(ba.FIELD,
a)};var jb=class extends Ka{constructor(a,b,f){super(Ka.SKIP_SETUP);this.svgArrow=this.arrow=this.imageElement=this.menu_=this.selectedMenuItem=null;this.SERIALIZABLE=!0;this.CURSOR="default";this.clickTarget_=this.suffixField=this.prefixField=this.generatedOptions=null;a!==Ka.SKIP_SETUP&&(Array.isArray(a)?(this.validateOptions(a),a=this.trimOptions(a),this.menuGenerator_=a.options,this.prefixField=a.prefix||null,this.suffixField=a.suffix||null):this.menuGenerator_=a,this.selectedOption=this.getOptions(!1)[0],
f&&this.configure_(f),this.setValue(this.selectedOption[1]),b&&this.setValidator(b))}fromXml(a){this.isOptionListDynamic()&&this.getOptions(!1);this.setValue(a.textContent)}loadState(a){this.loadLegacyState(jb,a)||(this.isOptionListDynamic()&&this.getOptions(!1),this.setValue(a))}initView(){this.shouldAddBorderRect_()?this.createBorderRect_():this.clickTarget_=this.sourceBlock_.getSvgRoot();this.createTextElement_();this.imageElement=T(J.IMAGE,{},this.fieldGroup_);this.getConstants().FIELD_DROPDOWN_SVG_ARROW?
this.createSVGArrow_():this.createTextArrow_();this.borderRect_&&sa(this.borderRect_,"blocklyDropdownRect")}shouldAddBorderRect_(){let a;return!this.getConstants().FIELD_DROPDOWN_NO_BORDER_RECT_SHADOW||this.getConstants().FIELD_DROPDOWN_NO_BORDER_RECT_SHADOW&&!(null==(a=this.getSourceBlock())?0:a.isShadow())}createTextArrow_(){this.arrow=T(J.TSPAN,{},this.textElement_);let a;this.arrow.appendChild(document.createTextNode((null==(a=this.getSourceBlock())?0:a.RTL)?jb.ARROW_CHAR+" ":" "+jb.ARROW_CHAR));
this.getConstants().FIELD_TEXT_BASELINE_CENTER&&this.arrow.setAttribute("dominant-baseline","central");let b;(null==(b=this.getSourceBlock())?0:b.RTL)?this.getTextElement().insertBefore(this.arrow,this.textContent_):this.getTextElement().appendChild(this.arrow)}createSVGArrow_(){this.svgArrow=T(J.IMAGE,{height:this.getConstants().FIELD_DROPDOWN_SVG_ARROW_SIZE+"px",width:this.getConstants().FIELD_DROPDOWN_SVG_ARROW_SIZE+"px"},this.fieldGroup_);this.svgArrow.setAttributeNS(pb,"xlink:href",this.getConstants().FIELD_DROPDOWN_SVG_ARROW_DATAURI)}showEditor_(a){var b=
this.getSourceBlock();if(!b)throw new Ta;this.dropdownCreate();this.menu_.openingCoords=a&&"number"===typeof a.clientX?new fa(a.clientX,a.clientY):null;wg();a=this.menu_.render(Ve());sa(a,"blocklyDropdownMenu");this.getConstants().FIELD_DROPDOWN_COLOURED_DIV&&(b=b.getColour(),a=this.sourceBlock_.getColourTertiary(),gj(b,a));kj(this,this.dropdownDispose_.bind(this));this.menu_.focus();this.selectedMenuItem&&(this.menu_.setHighlighted(this.selectedMenuItem),Zf(this.selectedMenuItem.getElement(),Ve(),
!0));this.applyColour()}dropdownCreate(){const a=this.getSourceBlock();if(!a)throw new Ta;const b=new Qg;b.setRole(Mb.LISTBOX);this.menu_=b;const f=this.getOptions(!1);this.selectedMenuItem=null;for(let l=0;l<f.length;l++){const [n,x]=f[l];if("object"===typeof n){var g=new Image(n.width,n.height);g.src=n.src;g.alt=n.alt||""}else g=n;g=new Rg(g,x);g.setRole(Mb.OPTION);g.setRightToLeft(a.RTL);g.setCheckable(!0);b.addChild(g);g.setChecked(x===this.value_);x===this.value_&&(this.selectedMenuItem=g);g.onAction(this.handleMenuActionEvent,
this)}}dropdownDispose_(){this.menu_&&this.menu_.dispose();this.selectedMenuItem=this.menu_=null;this.applyColour()}handleMenuActionEvent(a){Ag(this,!0);this.onItemSelected_(this.menu_,a)}onItemSelected_(a,b){this.setValue(b.getValue())}isOptionListDynamic(){return"function"===typeof this.menuGenerator_}getOptions(a){if(!this.menuGenerator_)throw TypeError("A menu generator was never defined.");if(Array.isArray(this.menuGenerator_))return this.menuGenerator_;if(a&&this.generatedOptions)return this.generatedOptions;
this.generatedOptions=this.menuGenerator_();this.validateOptions(this.generatedOptions);return this.generatedOptions}doClassValidation_(a){return this.getOptions(!0).some(b=>b[1]===a)?a:(this.sourceBlock_&&console.warn("Cannot set the dropdown's value to an unavailable option. Block type: "+this.sourceBlock_.type+", Field name: "+this.name+", Value: "+a),null)}doValueUpdate_(a){super.doValueUpdate_(a);a=this.getOptions(!0);for(let b=0,f;f=a[b];b++)f[1]===this.value_&&(this.selectedOption=f)}applyColour(){const a=
this.sourceBlock_;this.borderRect_&&(this.borderRect_.setAttribute("stroke",a.getColourTertiary()),this.menu_?this.borderRect_.setAttribute("fill",a.getColourTertiary()):this.borderRect_.setAttribute("fill","transparent"));a&&this.arrow&&(a.isShadow()?this.arrow.style.fill=a.getColourSecondary():this.arrow.style.fill=a.getColour())}render_(){this.getTextContent().nodeValue="";this.imageElement.style.display="none";const a=this.selectedOption&&this.selectedOption[0];a&&"object"===typeof a?this.renderSelectedImage(a):
this.renderSelectedText();this.positionBorderRect_()}renderSelectedImage(a){const b=this.getSourceBlock();if(!b)throw new Ta;this.imageElement.style.display="";this.imageElement.setAttributeNS(pb,"xlink:href",a.src);this.imageElement.setAttribute("height",String(a.height));this.imageElement.setAttribute("width",String(a.width));const f=Number(a.height);a=Number(a.width);var g=!!this.borderRect_;const l=Math.max(g?this.getConstants().FIELD_DROPDOWN_BORDER_RECT_HEIGHT:0,f+jb.IMAGE_Y_PADDING);g=g?this.getConstants().FIELD_BORDER_RECT_X_PADDING:
0;let n;n=this.svgArrow?this.positionSVGArrow(a+g,l/2-this.getConstants().FIELD_DROPDOWN_SVG_ARROW_SIZE/2):He(this.arrow,this.getConstants().FIELD_TEXT_FONTSIZE,this.getConstants().FIELD_TEXT_FONTWEIGHT,this.getConstants().FIELD_TEXT_FONTFAMILY);this.size_.width=a+n+2*g;this.size_.height=l;let x=0;b.RTL?this.imageElement.setAttribute("x",`${g+n}`):(x=a+n,this.getTextElement().setAttribute("text-anchor","end"),this.imageElement.setAttribute("x",`${g}`));this.imageElement.setAttribute("y",String(l/
2-f/2));this.positionTextElement_(x+g,a+n)}renderSelectedText(){this.getTextContent().nodeValue=this.getDisplayText_();var a=this.getTextElement();sa(a,"blocklyDropdownText");a.setAttribute("text-anchor","start");var b=!!this.borderRect_;a=Math.max(b?this.getConstants().FIELD_DROPDOWN_BORDER_RECT_HEIGHT:0,this.getConstants().FIELD_TEXT_HEIGHT);const f=He(this.getTextElement(),this.getConstants().FIELD_TEXT_FONTSIZE,this.getConstants().FIELD_TEXT_FONTWEIGHT,this.getConstants().FIELD_TEXT_FONTFAMILY);
b=b?this.getConstants().FIELD_BORDER_RECT_X_PADDING:0;let g=0;this.svgArrow&&(g=this.positionSVGArrow(f+b,a/2-this.getConstants().FIELD_DROPDOWN_SVG_ARROW_SIZE/2));this.size_.width=f+g+2*b;this.size_.height=a;this.positionTextElement_(b,f)}positionSVGArrow(a,b){if(!this.svgArrow)return 0;const f=this.getSourceBlock();if(!f)throw new Ta;const g=this.borderRect_?this.getConstants().FIELD_BORDER_RECT_X_PADDING:0,l=this.getConstants().FIELD_DROPDOWN_SVG_ARROW_PADDING,n=this.getConstants().FIELD_DROPDOWN_SVG_ARROW_SIZE;
this.svgArrow.setAttribute("transform","translate("+(f.RTL?g:a+l)+","+b+")");return n+l}getText_(){if(!this.selectedOption)return null;const a=this.selectedOption[0];return"object"===typeof a?a.alt:a}static fromJson(a){if(!a.options)throw Error("options are required for the dropdown field. The options property must be assigned an array of [humanReadableValue, languageNeutralValue] tuples.");return new this(a.options,void 0,a)}trimOptions(a){let b=!1;const f=a.map(([x,B])=>{if("string"===typeof x)return[Ua(x),
B];b=!0;return[null!==x.alt?Object.assign({},x,{alt:Ua(x.alt)}):Object.assign({},x),B]});if(b||2>a.length)return{options:f};var g=f.map(([x])=>x),l=Xe(g);a=tj(g,l);const n=uj(g,l);if(!a&&!n||l<=a+n)return{options:f};l=a?g[0].substring(0,a-1):void 0;g=n?g[0].substr(1-n):void 0;return{options:this.applyTrim(f,a,n),prefix:l,suffix:g}}applyTrim(a,b,f){return a.map(([g,l])=>[g.substring(b,g.length-f),l])}validateOptions(a){if(!Array.isArray(a))throw TypeError("FieldDropdown options must be an array.");
if(!a.length)throw TypeError("FieldDropdown options must not be an empty array.");let b=!1;for(let f=0;f<a.length;f++){const g=a[f];Array.isArray(g)?"string"!==typeof g[1]?(b=!0,console.error(`Invalid option[${f}]: Each FieldDropdown option id must be a string. 
          Found ${g[1]} in: ${g}`)):g[0]&&"string"!==typeof g[0]&&"string"!==typeof g[0].src&&(b=!0,console.error(`Invalid option[${f}]: Each FieldDropdown option must have a string 
          label or image description. Found ${g[0]} in: ${g}`)):(b=!0,console.error(`Invalid option[${f}]: Each FieldDropdown option must be an array.
          Found: ${g}`))}if(b)throw TypeError("Found invalid FieldDropdown options.");}};jb.CHECKMARK_OVERHANG=25;jb.MAX_MENU_HEIGHT_VH=.45;jb.ARROW_CHAR="▾";jb.IMAGE_Y_OFFSET=5;jb.IMAGE_Y_PADDING=2*jb.IMAGE_Y_OFFSET;Zb("field_dropdown",jb);var Al=class{constructor(a,b){this.bubble=a;this.workspace=b;this.startLoc=null;this.inGroup=!1}isMovable(){return!0}startDrag(){(this.inGroup=!!d.getGroup$$module$build$src$core$events$utils())||d.setGroup$$module$build$src$core$events$utils(!0);this.startLoc=
this.bubble.getRelativeToSurfaceXY();this.workspace.setResizesEnabled(!1);let a;null==(a=this.workspace.getLayerManager())||a.moveToDragLayer(this.bubble);this.bubble.setDragging&&this.bubble.setDragging(!0)}drag(a){this.bubble.moveDuringDrag(a)}endDrag(){this.workspace.setResizesEnabled(!0);this.inGroup||d.setGroup$$module$build$src$core$events$utils(!1);let a;null==(a=this.workspace.getLayerManager())||a.moveOffDragLayer(this.bubble,100);this.bubble.setDragging(!1)}revertDrag(){this.startLoc&&this.bubble.moveDuringDrag(this.startLoc)}},
Ha=class{constructor(a,b,f){this.workspace=a;this.anchor=b;this.ownerRect=f;this.size=new Aa(0,0);this.colour="#ffffff";this.disposed=!1;this.relativeLeft=this.relativeTop=0;this.dragStrategy=new Al(this,this.workspace);this.id=Q();this.svgRoot=T(J.G,{"class":"blocklyBubble"},a.getBubbleCanvas());a=T(J.G,{filter:`url(#${this.workspace.getRenderer().getConstants().embossFilterId})`},this.svgRoot);this.tail=T(J.PATH,{"class":"blocklyBubbleTail"},a);this.background=T(J.RECT,{"class":"blocklyDraggable",
x:0,y:0,rx:Ab.BORDER_WIDTH,ry:Ab.BORDER_WIDTH},a);this.contentContainer=T(J.G,{},this.svgRoot);ta(this.background,"pointerdown",this,this.onMouseDown)}dispose(){Ia(this.svgRoot);this.disposed=!0}setAnchorLocation(a,b=!1){this.anchor=a;b?this.positionByRect(this.ownerRect):this.positionRelativeToAnchor();this.renderTail()}setPositionRelativeToAnchor(a,b){this.relativeLeft=a;this.relativeTop=b;this.positionRelativeToAnchor();this.renderTail()}getSize(){return this.size}setSize(a,b=!1){a.width=Math.max(a.width,
Ab.MIN_SIZE);a.height=Math.max(a.height,Ab.MIN_SIZE);this.size=a;this.background.setAttribute("width",`${a.width}`);this.background.setAttribute("height",`${a.height}`);b?this.positionByRect(this.ownerRect):this.positionRelativeToAnchor();this.renderTail()}getColour(){return this.colour}setColour(a){this.colour=a;this.tail.setAttribute("fill",a);this.background.setAttribute("fill",a)}onMouseDown(a){let b;null==(b=this.workspace.getGesture(a))||b.handleBubbleStart(a,this);this.bringToFront();d.setSelected$$module$build$src$core$common(this)}positionRelativeToAnchor(){let a=
this.anchor.x;a=this.workspace.RTL?a-(this.relativeLeft+this.size.width):a+this.relativeLeft;this.moveTo(a,this.relativeTop+this.anchor.y)}moveTo(a,b){this.svgRoot.setAttribute("transform",`translate(${a}, ${b})`)}positionByRect(a=new Ja(0,0,0,0)){var b=this.workspace.getMetricsManager().getViewMetrics(!0),f=this.getOptimalRelativeLeft(b),g=this.getOptimalRelativeTop(b);const l={x:f,y:-this.size.height-this.workspace.getRenderer().getConstants().MIN_BLOCK_HEIGHT},n={x:-this.size.width-30,y:g};g={x:a.getWidth(),
y:g};var x={x:f,y:a.getHeight()};f=a.getWidth()<a.getHeight()?g:x;a=a.getWidth()<a.getHeight()?x:g;g=this.getOverlap(l,b);x=this.getOverlap(n,b);const B=this.getOverlap(f,b);b=this.getOverlap(a,b);b=Math.max(g,x,B,b);g===b?(this.relativeLeft=l.x,this.relativeTop=l.y):x===b?(this.relativeLeft=n.x,this.relativeTop=n.y):B===b?(this.relativeLeft=f.x,this.relativeTop=f.y):(this.relativeLeft=a.x,this.relativeTop=a.y);this.positionRelativeToAnchor()}getOverlap(a,b){var f=this.workspace.RTL?this.anchor.x-
a.x-this.size.width:a.x+this.anchor.x;a=a.y+this.anchor.y;return Math.max(0,Math.min(1,(Math.min(f+this.size.width,b.left+b.width)-Math.max(f,b.left))*(Math.min(a+this.size.height,b.top+b.height)-Math.max(a,b.top))/(this.size.width*this.size.height)))}getOptimalRelativeLeft(a){let b=-this.size.width/4;if(this.size.width>a.width)return b;a=this.getWorkspaceViewRect(a);if(this.workspace.RTL){var f=this.anchor.x-b;f-this.size.width<a.left?b=-(a.left-this.anchor.x+this.size.width):f>a.right&&(b=-(a.right-
this.anchor.x))}else{f=b+this.anchor.x;const g=f+this.size.width;f<a.left?b=a.left-this.anchor.x:g>a.right&&(b=a.right-this.anchor.x-this.size.width)}return b}getOptimalRelativeTop(a){let b=-this.size.height/4;if(this.size.height>a.height)return b;const f=this.anchor.y+b,g=f+this.size.height;a=this.getWorkspaceViewRect(a);f<a.top?b=a.top-this.anchor.y:g>a.bottom&&(b=a.bottom-this.anchor.y-this.size.height);return b}getWorkspaceViewRect(a){const b=a.top;let f=a.top+a.height,g=a.left;a=a.left+a.width;
f-=this.getScrollbarThickness();this.workspace.RTL?g-=this.getScrollbarThickness():a-=this.getScrollbarThickness();return new Ja(b,f,g,a)}getScrollbarThickness(){return Sa.scrollbarThickness/this.workspace.scale}renderTail(){const a=[];var b=this.size.width/2,f=this.size.height/2,g=-this.relativeLeft,l=-this.relativeTop;if(b===g&&f===l)a.push("M "+b+","+f);else{l-=f;g-=b;this.workspace.RTL&&(g*=-1);var n=Math.sqrt(l*l+g*g),x=Math.acos(g/n);0>l&&(x=2*Math.PI-x);var B=x+Math.PI/2;B>2*Math.PI&&(B-=2*
Math.PI);var V=Math.sin(B);const Pa=Math.cos(B);let La=(this.size.width+this.size.height)/Ab.TAIL_THICKNESS;La=Math.min(La,this.size.width,this.size.height)/4;B=1-Ab.ANCHOR_RADIUS/n;g=b+B*g;l=f+B*l;B=b+La*Pa;const ib=f+La*V;b-=La*Pa;f-=La*V;V=ug(this.workspace.RTL?-Ab.TAIL_ANGLE:Ab.TAIL_ANGLE);V=x+V;V>2*Math.PI&&(V-=2*Math.PI);x=Math.sin(V)*n/Ab.TAIL_BEND;n=Math.cos(V)*n/Ab.TAIL_BEND;a.push("M"+B+","+ib);a.push("C"+(B+n)+","+(ib+x)+" "+g+","+l+" "+g+","+l);a.push("C"+g+","+l+" "+(b+n)+","+(f+x)+" "+
b+","+f)}a.push("z");let na;null==(na=this.tail)||na.setAttribute("d",a.join(" "))}bringToFront(){let a;const b=null==(a=this.svgRoot)?void 0:a.parentNode;return this.svgRoot&&(null==b?void 0:b.lastChild)!==this.svgRoot?(null==b||b.appendChild(this.svgRoot),!0):!1}getRelativeToSurfaceXY(){return new fa(this.workspace.RTL?-this.relativeLeft+this.anchor.x-this.size.width:this.anchor.x+this.relativeLeft,this.anchor.y+this.relativeTop)}getSvgRoot(){return this.svgRoot}moveDuringDrag(a){this.moveTo(a.x,
a.y);this.relativeLeft=this.workspace.RTL?this.anchor.x-a.x-this.size.width:a.x-this.anchor.x;this.relativeTop=a.y-this.anchor.y;this.renderTail()}setDragging(a){}setDeleteStyle(a){}isDeletable(){return!1}showContextMenu(a){}isMovable(){return!0}startDrag(){this.dragStrategy.startDrag()}drag(a){this.dragStrategy.drag(a)}endDrag(){this.dragStrategy.endDrag()}revertDrag(){this.dragStrategy.revertDrag()}select(){}unselect(){}};var Ab=Ha;Ha.BORDER_WIDTH=6;Ha.DOUBLE_BORDER=2*Ab.BORDER_WIDTH;Ha.MIN_SIZE=
Ab.DOUBLE_BORDER;Ha.TAIL_THICKNESS=1;Ha.TAIL_ANGLE=20;Ha.TAIL_BEND=4;Ha.ANCHOR_RADIUS=8;var gc=class extends Ha{constructor(a,b,f,g){super(b,f,g);this.workspace=b;this.anchor=f;this.ownerRect=g;this.autoLayout=!0;b=new zb(a);this.validateWorkspaceOptions(b);this.svgDialog=T(J.SVG,{x:Ha.BORDER_WIDTH,y:Ha.BORDER_WIDTH},this.contentContainer);a.parentWorkspace=this.workspace;this.miniWorkspace=this.newWorkspaceSvg(new zb(a));this.miniWorkspace.internalIsMutator=!0;a=this.miniWorkspace.createDom("blocklyMutatorBackground");
this.svgDialog.appendChild(a);b.languageTree&&(a.insertBefore(this.miniWorkspace.addFlyout(J.G),this.miniWorkspace.getCanvas()),a=this.miniWorkspace.getFlyout(),null==a||a.init(this.miniWorkspace),null==a||a.show(b.languageTree));this.miniWorkspace.addChangeListener(this.onWorkspaceChange.bind(this));let l,n;null==(l=this.miniWorkspace.getFlyout())||null==(n=l.getWorkspace())||n.addChangeListener(this.onWorkspaceChange.bind(this));this.updateBubbleSize()}dispose(){this.miniWorkspace.dispose();super.dispose()}getWorkspace(){return this.miniWorkspace}addWorkspaceChangeListener(a){this.miniWorkspace.addChangeListener(a)}validateWorkspaceOptions(a){if(a.hasCategories)throw Error("The miniworkspace bubble does not support toolboxes with categories");
if(a.hasTrashcan)throw Error("The miniworkspace bubble does not support trashcans");if(a.zoomOptions.controls||a.zoomOptions.wheel||a.zoomOptions.pinch)throw Error("The miniworkspace bubble does not support zooming");if(a.moveOptions.scrollbars||a.moveOptions.wheel||a.moveOptions.drag)throw Error("The miniworkspace bubble does not scrolling/moving the workspace");if(a.horizontalLayout)throw Error("The miniworkspace bubble does not support horizontal layouts");}onWorkspaceChange(){this.bumpBlocksIntoBounds();
this.updateBubbleSize()}bumpBlocksIntoBounds(){if(!this.miniWorkspace.isDragging())for(const a of this.miniWorkspace.getTopBlocks(!1)){const b=a.getRelativeToSurfaceXY();20>b.y&&a.moveBy(0,20-b.y);if(a.RTL){let f=-20;const g=this.miniWorkspace.getFlyout();g&&(f-=g.getWidth());b.x>f&&a.moveBy(f-b.x,0)}else 20>b.x&&a.moveBy(20-b.x,0)}}updateBubbleSize(){if(!this.miniWorkspace.isDragging()){var a=this.getSize(),b=this.calculateWorkspaceSize();Math.abs(a.width-b.width)<gc.MINIMUM_VIEW_CHANGE&&Math.abs(a.height-
b.height)<gc.MINIMUM_VIEW_CHANGE||(this.svgDialog.setAttribute("width",`${b.width}px`),this.svgDialog.setAttribute("height",`${b.height}px`),this.miniWorkspace.setCachedParentSvgSize(b.width,b.height),this.miniWorkspace.RTL&&this.miniWorkspace.getCanvas().setAttribute("transform",`translate(${b.width}, 0)`),this.setSize(new Aa(b.width+Ha.DOUBLE_BORDER,b.height+Ha.DOUBLE_BORDER),this.autoLayout),this.miniWorkspace.resize(),this.miniWorkspace.recordDragTargets())}}calculateWorkspaceSize(){var a=this.miniWorkspace.getCanvas().getBBox();
let b=a.width+gc.MARGIN;a=a.height+gc.MARGIN;const f=this.miniWorkspace.getFlyout();if(f){const g=f.getWorkspace().getMetricsManager().getScrollMetrics();a=Math.max(a,g.height+20);b+=f.getWidth()}return new Aa(b,a)}updateBlockStyles(){for(var a of this.miniWorkspace.getAllBlocks(!1))a.setStyle(a.getStyleName());let b;if(a=null==(b=this.miniWorkspace.getFlyout())?void 0:b.getWorkspace())for(const f of a.getAllBlocks(!1))f.setStyle(f.getStyleName())}moveDuringDrag(a){super.moveDuringDrag(a);this.autoLayout=
!1}moveTo(a,b){super.moveTo(a,b);this.miniWorkspace.recordDragTargets()}newWorkspaceSvg(a){throw Error("The implementation of newWorkspaceSvg should be monkey-patched in by blockly.ts");}};gc.MINIMUM_VIEW_CHANGE=10;gc.MARGIN=3*Ha.DOUBLE_BORDER;var Cf=class{constructor(a){this.sourceBlock=a;this.offsetInBlock=new fa(0,0);this.workspaceLocation=new fa(0,0);this.svgRoot=null;this.tooltip=a}getType(){throw Error("Icons must implement getType");}initView(a){if(!this.svgRoot){var b=this.sourceBlock;this.svgRoot=
T(J.G,{"class":"blocklyIconGroup"});b.getSvgRoot().appendChild(this.svgRoot);this.updateSvgRootOffset();ta(this.svgRoot,"pointerdown",this,a);this.svgRoot.tooltip=this;Zd(this.svgRoot)}}dispose(){Eg(this.svgRoot);Ia(this.svgRoot)}getWeight(){return-1}getSize(){return new Aa(0,0)}setTooltip(a){this.tooltip=null!=a?a:this.sourceBlock}getTooltip(){return this.tooltip}applyColour(){}updateEditable(){}updateCollapsed(){this.svgRoot&&(this.sourceBlock.isCollapsed()?this.svgRoot.style.display="none":this.svgRoot.style.display=
"block",Vd(this)&&this.setBubbleVisible(!1))}hideForInsertionMarker(){this.svgRoot&&(this.svgRoot.style.display="none")}isShownWhenCollapsed(){return!1}setOffsetInBlock(a){this.offsetInBlock=a;this.updateSvgRootOffset()}updateSvgRootOffset(){let a;null==(a=this.svgRoot)||a.setAttribute("transform",`translate(${this.offsetInBlock.x}, ${this.offsetInBlock.y})`)}onLocationChange(a){this.workspaceLocation=fa.sum(a,this.offsetInBlock)}onClick(){}isClickableInFlyout(a){return!0}};d.MutatorIcon$$module$build$src$core$icons$mutator_icon=
class extends Cf{constructor(a,b){super(b);this.flyoutBlockTypes=a;this.sourceBlock=b;this.saveConnectionsListener=this.updateWorkspacePid=this.rootBlock=this.miniWorkspaceBubble=null}getType(){return d.MutatorIcon$$module$build$src$core$icons$mutator_icon.TYPE}initView(a){this.svgRoot||(super.initView(a),T(J.RECT,{"class":"blocklyIconShape",rx:"4",ry:"4",height:"16",width:"16"},this.svgRoot),T(J.PATH,{"class":"blocklyIconSymbol",d:"m4.203,7.296 0,1.368 -0.92,0.677 -0.11,0.41 0.9,1.559 0.41,0.11 1.043,-0.457 1.187,0.683 0.127,1.134 0.3,0.3 1.8,0 0.3,-0.299 0.127,-1.138 1.185,-0.682 1.046,0.458 0.409,-0.11 0.9,-1.559 -0.11,-0.41 -0.92,-0.677 0,-1.366 0.92,-0.677 0.11,-0.41 -0.9,-1.559 -0.409,-0.109 -1.046,0.458 -1.185,-0.682 -0.127,-1.138 -0.3,-0.299 -1.8,0 -0.3,0.3 -0.126,1.135 -1.187,0.682 -1.043,-0.457 -0.41,0.11 -0.899,1.559 0.108,0.409z"},
this.svgRoot),T(J.CIRCLE,{"class":"blocklyIconShape",r:"2.7",cx:"8",cy:"8"},this.svgRoot),sa(this.svgRoot,"blockly-icon-mutator"))}dispose(){super.dispose();let a;null==(a=this.miniWorkspaceBubble)||a.dispose()}getWeight(){return d.MutatorIcon$$module$build$src$core$icons$mutator_icon.WEIGHT}getSize(){return new Aa(17,17)}applyColour(){super.applyColour();let a;null==(a=this.miniWorkspaceBubble)||a.setColour(this.sourceBlock.getColour());let b;null==(b=this.miniWorkspaceBubble)||b.updateBlockStyles()}updateCollapsed(){super.updateCollapsed();
this.sourceBlock.isCollapsed()&&this.setBubbleVisible(!1)}onLocationChange(a){super.onLocationChange(a);let b;null==(b=this.miniWorkspaceBubble)||b.setAnchorLocation(this.getAnchorLocation())}onClick(){super.onClick();this.sourceBlock.isEditable()&&this.setBubbleVisible(!this.bubbleIsVisible())}isClickableInFlyout(){return!1}bubbleIsVisible(){return!!this.miniWorkspaceBubble}setBubbleVisible(a){const b=this;return Y.asyncExecutePromiseGeneratorFunction(function*(){if(b.bubbleIsVisible()!==a){yield Lb();
if(a){b.miniWorkspaceBubble=new gc(b.getMiniWorkspaceConfig(),b.sourceBlock.workspace,b.getAnchorLocation(),b.getBubbleOwnerRect());b.applyColour();b.createRootBlock();b.addSaveConnectionsListener();let f;null==(f=b.miniWorkspaceBubble)||f.addWorkspaceChangeListener(b.createMiniWorkspaceChangeListener())}else{let f;null==(f=b.miniWorkspaceBubble)||f.dispose();b.miniWorkspaceBubble=null;b.saveConnectionsListener&&b.sourceBlock.workspace.removeChangeListener(b.saveConnectionsListener);b.saveConnectionsListener=
null}aa(new (la(O.BUBBLE_OPEN))(b.sourceBlock,a,"mutator"))}})}getMiniWorkspaceConfig(){let a;const b={disable:!1,media:this.sourceBlock.workspace.options.pathToMedia,rtl:this.sourceBlock.RTL,renderer:this.sourceBlock.workspace.options.renderer,rendererOverrides:null!=(a=this.sourceBlock.workspace.options.rendererOverrides)?a:void 0};this.flyoutBlockTypes.length&&(b.toolbox={kind:"flyoutToolbox",contents:this.flyoutBlockTypes.map(f=>({kind:"block",type:f}))});return b}getAnchorLocation(){return fa.sum(this.workspaceLocation,
new fa(8.5,8.5))}getBubbleOwnerRect(){const a=this.sourceBlock.getSvgRoot().getBBox();return new Ja(a.y,a.y+a.height,a.x,a.x+a.width)}createRootBlock(){if(!this.sourceBlock.decompose)throw Error("Blocks with mutator icons must include a decompose method");this.rootBlock=this.sourceBlock.decompose(this.miniWorkspaceBubble.getWorkspace());for(var a of this.rootBlock.getDescendants(!1))a.queueRender();this.rootBlock.setMovable(!1);this.rootBlock.setDeletable(!1);let b,f,g,l;a=null!=(l=null==(b=this.miniWorkspaceBubble)?
void 0:null==(f=b.getWorkspace())?void 0:null==(g=f.getFlyout())?void 0:g.getWidth())?l:0;this.rootBlock.moveBy(this.rootBlock.RTL?-(a+16):16,16)}addSaveConnectionsListener(){this.sourceBlock.saveConnections&&this.rootBlock&&(this.saveConnectionsListener=()=>{this.sourceBlock.saveConnections&&this.rootBlock&&this.sourceBlock.saveConnections(this.rootBlock)},this.saveConnectionsListener(),this.sourceBlock.workspace.addChangeListener(this.saveConnectionsListener))}createMiniWorkspaceChangeListener(){return a=>
{d.MutatorIcon$$module$build$src$core$icons$mutator_icon.isIgnorableMutatorEvent(a)||this.updateWorkspacePid||(this.updateWorkspacePid=setTimeout(()=>{this.updateWorkspacePid=null;this.recomposeSourceBlock()},0))}}static isIgnorableMutatorEvent(a){return a.isUiEvent||N(a)||K(a)&&"disabled"===a.element}recomposeSourceBlock(){if(this.rootBlock){if(!this.sourceBlock.compose)throw Error("Blocks with mutator icons must include a compose method");var a=d.getGroup$$module$build$src$core$events$utils();a||
d.setGroup$$module$build$src$core$events$utils(!0);var b=Tc.getExtraBlockState_(this.sourceBlock);this.sourceBlock.compose(this.rootBlock);var f=Tc.getExtraBlockState_(this.sourceBlock);b!==f&&aa(new (la(O.BLOCK_CHANGE))(this.sourceBlock,"mutation",null,b,f));d.setGroup$$module$build$src$core$events$utils(a)}}getWorkspace(){let a;return null==(a=this.miniWorkspaceBubble)?void 0:a.getWorkspace()}};d.MutatorIcon$$module$build$src$core$icons$mutator_icon.TYPE=Xa.MUTATOR;d.MutatorIcon$$module$build$src$core$icons$mutator_icon.WEIGHT=
1;var td=Object.create(null),po={allExtensions:td};d.register$$module$build$src$core$extensions("parent_tooltip_when_inline",function(){const a=this.tooltip;this.setTooltip(function(){const b=this.getParent();return b&&b.getInputsInline()&&b.tooltip||a}.bind(this))});var Gb={TEST_ONLY:po};Gb.apply=Yg;Gb.buildTooltipForDropdown=d.buildTooltipForDropdown$$module$build$src$core$extensions;Gb.buildTooltipWithFieldText=d.buildTooltipWithFieldText$$module$build$src$core$extensions;Gb.isRegistered=hk;Gb.register=
d.register$$module$build$src$core$extensions;Gb.registerMixin=d.registerMixin$$module$build$src$core$extensions;Gb.registerMutator=d.registerMutator$$module$build$src$core$extensions;Gb.runAfterPageLoad=function(a){if("object"!==typeof document)throw Error("runAfterPageLoad() requires browser document.");if("complete"===document.readyState)a();else{const b=setInterval(function(){"complete"===document.readyState&&(clearInterval(b),a())},10)}};Gb.unregister=function(a){hk(a)?delete td[a]:console.warn('No extension mapping for name "'+
a+'" found to unregister')};var ya;(function(a){a[a.WIN_KEY_FF_LINUX=0]="WIN_KEY_FF_LINUX";a[a.MAC_ENTER=3]="MAC_ENTER";a[a.BACKSPACE=8]="BACKSPACE";a[a.TAB=9]="TAB";a[a.NUM_CENTER=12]="NUM_CENTER";a[a.ENTER=13]="ENTER";a[a.SHIFT=16]="SHIFT";a[a.CTRL=17]="CTRL";a[a.ALT=18]="ALT";a[a.PAUSE=19]="PAUSE";a[a.CAPS_LOCK=20]="CAPS_LOCK";a[a.ESC=27]="ESC";a[a.SPACE=32]="SPACE";a[a.PAGE_UP=33]="PAGE_UP";a[a.PAGE_DOWN=34]="PAGE_DOWN";a[a.END=35]="END";a[a.HOME=36]="HOME";a[a.LEFT=37]="LEFT";a[a.UP=38]="UP";
a[a.RIGHT=39]="RIGHT";a[a.DOWN=40]="DOWN";a[a.PLUS_SIGN=43]="PLUS_SIGN";a[a.PRINT_SCREEN=44]="PRINT_SCREEN";a[a.INSERT=45]="INSERT";a[a.DELETE=46]="DELETE";a[a.ZERO=48]="ZERO";a[a.ONE=49]="ONE";a[a.TWO=50]="TWO";a[a.THREE=51]="THREE";a[a.FOUR=52]="FOUR";a[a.FIVE=53]="FIVE";a[a.SIX=54]="SIX";a[a.SEVEN=55]="SEVEN";a[a.EIGHT=56]="EIGHT";a[a.NINE=57]="NINE";a[a.FF_SEMICOLON=59]="FF_SEMICOLON";a[a.FF_EQUALS=61]="FF_EQUALS";a[a.FF_DASH=173]="FF_DASH";a[a.FF_HASH=163]="FF_HASH";a[a.QUESTION_MARK=63]="QUESTION_MARK";
a[a.AT_SIGN=64]="AT_SIGN";a[a.A=65]="A";a[a.B=66]="B";a[a.C=67]="C";a[a.D=68]="D";a[a.E=69]="E";a[a.F=70]="F";a[a.G=71]="G";a[a.H=72]="H";a[a.I=73]="I";a[a.J=74]="J";a[a.K=75]="K";a[a.L=76]="L";a[a.M=77]="M";a[a.N=78]="N";a[a.O=79]="O";a[a.P=80]="P";a[a.Q=81]="Q";a[a.R=82]="R";a[a.S=83]="S";a[a.T=84]="T";a[a.U=85]="U";a[a.V=86]="V";a[a.W=87]="W";a[a.X=88]="X";a[a.Y=89]="Y";a[a.Z=90]="Z";a[a.META=91]="META";a[a.WIN_KEY_RIGHT=92]="WIN_KEY_RIGHT";a[a.CONTEXT_MENU=93]="CONTEXT_MENU";a[a.NUM_ZERO=96]=
"NUM_ZERO";a[a.NUM_ONE=97]="NUM_ONE";a[a.NUM_TWO=98]="NUM_TWO";a[a.NUM_THREE=99]="NUM_THREE";a[a.NUM_FOUR=100]="NUM_FOUR";a[a.NUM_FIVE=101]="NUM_FIVE";a[a.NUM_SIX=102]="NUM_SIX";a[a.NUM_SEVEN=103]="NUM_SEVEN";a[a.NUM_EIGHT=104]="NUM_EIGHT";a[a.NUM_NINE=105]="NUM_NINE";a[a.NUM_MULTIPLY=106]="NUM_MULTIPLY";a[a.NUM_PLUS=107]="NUM_PLUS";a[a.NUM_MINUS=109]="NUM_MINUS";a[a.NUM_PERIOD=110]="NUM_PERIOD";a[a.NUM_DIVISION=111]="NUM_DIVISION";a[a.F1=112]="F1";a[a.F2=113]="F2";a[a.F3=114]="F3";a[a.F4=115]="F4";
a[a.F5=116]="F5";a[a.F6=117]="F6";a[a.F7=118]="F7";a[a.F8=119]="F8";a[a.F9=120]="F9";a[a.F10=121]="F10";a[a.F11=122]="F11";a[a.F12=123]="F12";a[a.NUMLOCK=144]="NUMLOCK";a[a.SCROLL_LOCK=145]="SCROLL_LOCK";a[a.FIRST_MEDIA_KEY=166]="FIRST_MEDIA_KEY";a[a.LAST_MEDIA_KEY=183]="LAST_MEDIA_KEY";a[a.SEMICOLON=186]="SEMICOLON";a[a.DASH=189]="DASH";a[a.EQUALS=187]="EQUALS";a[a.COMMA=188]="COMMA";a[a.PERIOD=190]="PERIOD";a[a.SLASH=191]="SLASH";a[a.APOSTROPHE=192]="APOSTROPHE";a[a.TILDE=192]="TILDE";a[a.SINGLE_QUOTE=
222]="SINGLE_QUOTE";a[a.OPEN_SQUARE_BRACKET=219]="OPEN_SQUARE_BRACKET";a[a.BACKSLASH=220]="BACKSLASH";a[a.CLOSE_SQUARE_BRACKET=221]="CLOSE_SQUARE_BRACKET";a[a.WIN_KEY=224]="WIN_KEY";a[a.MAC_FF_META=224]="MAC_FF_META";a[a.MAC_WK_CMD_LEFT=91]="MAC_WK_CMD_LEFT";a[a.MAC_WK_CMD_RIGHT=93]="MAC_WK_CMD_RIGHT";a[a.WIN_IME=229]="WIN_IME";a[a.VK_NONAME=252]="VK_NONAME";a[a.PHANTOM=255]="PHANTOM"})(ya||={});var hc={};hc.arc=Va;hc.curve=nb;hc.line=ge;hc.lineOnAxis=pa;hc.lineTo=$b;hc.moveBy=Oa;hc.moveTo=Za;hc.point=
qa;var Ra={};Ra.Coordinate=fa;Ra.KeyCodes=ya;Ra.Rect=Ja;Ra.Size=Aa;Ra.Svg=J;Ra.aria=le;Ra.array=ml;Ra.browserEvents=ec;Ra.colour=yb;Ra.deprecation=al;Ra.dom=$a;Ra.extensions=Gb;Ra.idGenerator=lh;Ra.math=yf;Ra.object=vl;Ra.parsing=zf;Ra.string=yd;Ra.style=wc;Ra.svgMath=Oc;Ra.svgPaths=hc;Ra.toolbox=xc;Ra.userAgent=io;Ra.xml=wd;var Bl=class extends Ha{constructor(a,b,f){super(a,b,f);this.workspace=a;this.anchor=b;this.ownerRect=f;this.resizePointerMoveListener=this.resizePointerUpListener=null;this.textChangeListeners=
[];this.sizeChangeListeners=[];this.text="";this.DEFAULT_SIZE=new Aa(160+Ha.DOUBLE_BORDER,80+Ha.DOUBLE_BORDER);this.MIN_SIZE=new Aa(45+Ha.DOUBLE_BORDER,20+Ha.DOUBLE_BORDER);this.editable=!0;sa(this.svgRoot,"blocklyTextInputBubble");({inputRoot:this.inputRoot,textArea:this.textArea}=this.createEditor(this.contentContainer));this.resizeGroup=this.createResizeHandle(this.svgRoot,a);this.setSize(this.DEFAULT_SIZE,!0)}getText(){return this.text}setText(a){this.text=a;this.textArea.value=a;this.onTextChange()}setEditable(a){(this.editable=
a)?this.textArea.removeAttribute("readonly"):this.textArea.setAttribute("readonly","")}isEditable(){return this.editable}addTextChangeListener(a){this.textChangeListeners.push(a)}addSizeChangeListener(a){this.sizeChangeListeners.push(a)}createEditor(a){a=T(J.FOREIGNOBJECT,{x:Ha.BORDER_WIDTH,y:Ha.BORDER_WIDTH},a);const b=document.createElementNS(Nb,"body");b.setAttribute("xmlns",Nb);b.className="blocklyMinimalBody";const f=document.createElementNS(Nb,"textarea");f.className="blocklyTextarea blocklyText";
f.setAttribute("dir",this.workspace.RTL?"RTL":"LTR");b.appendChild(f);a.appendChild(b);this.bindTextAreaEvents(f);setTimeout(()=>{f.focus()},0);return{inputRoot:a,textArea:f}}bindTextAreaEvents(a){ta(a,"wheel",this,b=>{b.stopPropagation()});ta(a,"focus",this,this.onStartEdit,!0);ta(a,"change",this,this.onTextChange)}createResizeHandle(a,b){a=T(J.IMAGE,{"class":"blocklyResizeHandle",href:`${b.options.pathToMedia}resize-handle.svg`},a);ta(a,"pointerdown",this,this.onResizePointerDown);return a}setSize(a,
b=!1){a.width=Math.max(a.width,this.MIN_SIZE.width);a.height=Math.max(a.height,this.MIN_SIZE.height);const f=a.width-Ha.DOUBLE_BORDER,g=a.height-Ha.DOUBLE_BORDER;this.inputRoot.setAttribute("width",`${f}`);this.inputRoot.setAttribute("height",`${g}`);this.resizeGroup.setAttribute("y",`${g}`);this.workspace.RTL?this.resizeGroup.setAttribute("x",`${-Ha.DOUBLE_BORDER}`):this.resizeGroup.setAttribute("x",`${f}`);super.setSize(a,b);this.onSizeChange()}getSize(){return super.getSize()}onResizePointerDown(a){this.bringToFront();
Vb(a)||(Sg(this.workspace,a,new fa(this.workspace.RTL?-this.getSize().width:this.getSize().width,this.getSize().height)),this.resizePointerUpListener=ta(document,"pointerup",this,this.onResizePointerUp),this.resizePointerMoveListener=ta(document,"pointermove",this,this.onResizePointerMove),this.workspace.hideChaff());a.stopPropagation()}onResizePointerUp(a){Ea();this.resizePointerUpListener&&(Na(this.resizePointerUpListener),this.resizePointerUpListener=null);this.resizePointerMoveListener&&(Na(this.resizePointerMoveListener),
this.resizePointerMoveListener=null)}onResizePointerMove(a){a=Tg(this.workspace,a);this.setSize(new Aa(this.workspace.RTL?-a.x:a.x,a.y),!1);this.onSizeChange()}onStartEdit(){this.bringToFront()&&this.textArea.focus()}onTextChange(){this.text=this.textArea.value;for(const a of this.textChangeListeners)a()}onSizeChange(){for(const a of this.sizeChangeListeners)a()}};mc("\n.blocklyTextInputBubble .blocklyTextarea {\n  background-color: var(--commentFillColour);\n  border: 0;\n  box-sizing: border-box;\n  display: block;\n  outline: 0;\n  padding: 5px;\n  resize: none;\n  width: 100%;\n  height: 100%;\n}\n");
var yh={};yh.register=ik;yh.unregister=function(a){k(ba.ICON,a)};var cc=class extends Cf{constructor(a){super(a);this.sourceBlock=a;this.textInputBubble=null;this.text="";this.bubbleSize=new Aa(160,80);this.bubbleVisiblity=!1}getType(){return cc.TYPE}initView(a){this.svgRoot||(super.initView(a),T(J.CIRCLE,{"class":"blocklyIconShape",r:"8",cx:"8",cy:"8"},this.svgRoot),T(J.PATH,{"class":"blocklyIconSymbol",d:"m6.8,10h2c0.003,-0.617 0.271,-0.962 0.633,-1.266 2.875,-2.4050.607,-5.534 -3.765,-3.874v1.7c3.12,-1.657 3.698,0.118 2.336,1.25-1.201,0.998 -1.201,1.528 -1.204,2.19z"},
this.svgRoot),T(J.RECT,{"class":"blocklyIconSymbol",x:"6.8",y:"10.78",height:"2",width:"2"},this.svgRoot),sa(this.svgRoot,"blockly-icon-comment"))}dispose(){super.dispose();let a;null==(a=this.textInputBubble)||a.dispose()}getWeight(){return cc.WEIGHT}getSize(){return new Aa(17,17)}applyColour(){super.applyColour();const a=this.sourceBlock.getColour();let b;null==(b=this.textInputBubble)||b.setColour(a)}updateEditable(){const a=this,b=()=>super.updateEditable;return Y.asyncExecutePromiseGeneratorFunction(function*(){b().call(a);
a.bubbleIsVisible()&&(yield a.setBubbleVisible(!1),yield a.setBubbleVisible(!0))})}onLocationChange(a){super.onLocationChange(a);a=this.getAnchorLocation();let b;null==(b=this.textInputBubble)||b.setAnchorLocation(a)}setText(a){const b=this.text;aa(new (la(O.BLOCK_CHANGE))(this.sourceBlock,"comment",null,b,a));this.text=a;let f;null==(f=this.textInputBubble)||f.setText(this.text)}getText(){return this.text}setBubbleSize(a){this.bubbleSize=a;let b;null==(b=this.textInputBubble)||b.setSize(this.bubbleSize,
!0)}getBubbleSize(){return this.bubbleSize}saveState(){return this.text?{text:this.text,pinned:this.bubbleIsVisible(),height:this.bubbleSize.height,width:this.bubbleSize.width}:null}loadState(a){let b;this.text=null!=(b=a.text)?b:"";let f,g;this.bubbleSize=new Aa(null!=(f=a.width)?f:160,null!=(g=a.height)?g:80);let l;this.bubbleVisiblity=null!=(l=a.pinned)?l:!1;this.setBubbleVisible(this.bubbleVisiblity)}onClick(){super.onClick();this.setBubbleVisible(!this.bubbleIsVisible())}isClickableInFlyout(){return!1}onTextChange(){if(this.textInputBubble){var a=
this.textInputBubble.getText();this.text!==a&&(aa(new (la(O.BLOCK_CHANGE))(this.sourceBlock,"comment",null,this.text,a)),this.text=a)}}onSizeChange(){this.textInputBubble&&(this.bubbleSize=this.textInputBubble.getSize())}bubbleIsVisible(){return this.bubbleVisiblity}setBubbleVisible(a){const b=this;return Y.asyncExecutePromiseGeneratorFunction(function*(){b.bubbleVisiblity!==a&&(b.bubbleVisiblity=a,yield Lb(),!b.sourceBlock.rendered||b.sourceBlock.isInFlyout||b.sourceBlock.isInsertionMarker()||(a?
(b.sourceBlock.isEditable()?b.showEditableBubble():b.showNonEditableBubble(),b.applyColour()):b.hideBubble(),aa(new (la(O.BUBBLE_OPEN))(b.sourceBlock,a,"comment"))))})}showEditableBubble(){this.createBubble();let a;null==(a=this.textInputBubble)||a.addTextChangeListener(()=>this.onTextChange());let b;null==(b=this.textInputBubble)||b.addSizeChangeListener(()=>this.onSizeChange())}showNonEditableBubble(){this.createBubble();let a;null==(a=this.textInputBubble)||a.setEditable(!1)}createBubble(){this.textInputBubble=
new Bl(this.sourceBlock.workspace,this.getAnchorLocation(),this.getBubbleOwnerRect());this.textInputBubble.setText(this.getText());this.textInputBubble.setSize(this.bubbleSize,!0)}hideBubble(){let a;null==(a=this.textInputBubble)||a.dispose();this.textInputBubble=null}getAnchorLocation(){return fa.sum(this.workspaceLocation,new fa(8.5,8.5))}getBubbleOwnerRect(){return this.sourceBlock.getBoundingRectangleWithoutChildren()}};cc.TYPE=Xa.COMMENT;cc.WEIGHT=3;ik(cc.TYPE,cc);var Cl=class extends Error{constructor(a){super(`Tried to append an icon of type ${a.getType()} when an icon of `+
"that type already exists on the block. Use getIcon to access the existing icon.");this.icon=a}},Dl={};Dl.DuplicateIconType=Cl;var El=class extends Ha{constructor(a,b,f,g){super(b,f,g);this.text=a;this.workspace=b;this.anchor=f;this.ownerRect=g;this.paragraph=this.stringToSvg(a,this.contentContainer);this.updateBubbleSize()}getText(){return this.text}setText(a){this.text=a;Ia(this.paragraph);this.paragraph=this.stringToSvg(a,this.contentContainer);this.updateBubbleSize()}stringToSvg(a,b){b=this.createParagraph(b);
a=this.createTextFragments(b,a);this.workspace.RTL&&this.rightAlignTextFragments(b.getBBox().width,a);return b}createParagraph(a){return T(J.G,{"class":"blocklyText blocklyBubbleText blocklyNoPointerEvents",transform:`translate(0,${Ha.BORDER_WIDTH})`,style:`direction: ${this.workspace.RTL?"rtl":"ltr"}`},a)}createTextFragments(a,b){let f=1;return b.split("\n").map(g=>{const l=T(J.TEXT,{y:`${f}em`,x:Ha.BORDER_WIDTH},a);g=document.createTextNode(g);l.appendChild(g);f+=1;return l})}rightAlignTextFragments(a,
b){for(const f of b)f.setAttribute("text-anchor","start"),f.setAttribute("x",`${a+Ha.BORDER_WIDTH}`)}updateBubbleSize(){const a=this.paragraph.getBBox();this.setSize(new Aa(a.width+2*Ha.BORDER_WIDTH,a.height+2*Ha.BORDER_WIDTH),!0)}},ic=class extends Cf{constructor(a){super(a);this.sourceBlock=a;this.textMap=new Map;this.textBubble=null}getType(){return ic.TYPE}initView(a){this.svgRoot||(super.initView(a),T(J.PATH,{"class":"blocklyIconShape",d:"M2,15Q-1,15 0.5,12L6.5,1.7Q8,-1 9.5,1.7L15.5,12Q17,15 14,15z"},
this.svgRoot),T(J.PATH,{"class":"blocklyIconSymbol",d:"m7,4.8v3.16l0.27,2.27h1.46l0.27,-2.27v-3.16z"},this.svgRoot),T(J.RECT,{"class":"blocklyIconSymbol",x:"7",y:"11",height:"2",width:"2"},this.svgRoot),sa(this.svgRoot,"blockly-icon-warning"))}dispose(){super.dispose();let a;null==(a=this.textBubble)||a.dispose()}getWeight(){return ic.WEIGHT}getSize(){return new Aa(17,17)}applyColour(){super.applyColour();let a;null==(a=this.textBubble)||a.setColour(this.sourceBlock.getColour())}updateCollapsed(){}isShownWhenCollapsed(){return!0}onLocationChange(a){super.onLocationChange(a);
let b;null==(b=this.textBubble)||b.setAnchorLocation(this.getAnchorLocation())}addMessage(a,b){if(this.textMap.get(b)===a)return this;a?this.textMap.set(b,a):this.textMap.delete(b);let f;null==(f=this.textBubble)||f.setText(this.getText());return this}getText(){return[...this.textMap.values()].join("\n")}onClick(){super.onClick();this.setBubbleVisible(!this.bubbleIsVisible())}isClickableInFlyout(){return!1}bubbleIsVisible(){return!!this.textBubble}setBubbleVisible(a){const b=this;return Y.asyncExecutePromiseGeneratorFunction(function*(){if(b.bubbleIsVisible()!==
a){yield Lb();if(a)b.textBubble=new El(b.getText(),b.sourceBlock.workspace,b.getAnchorLocation(),b.getBubbleOwnerRect()),b.applyColour();else{let f;null==(f=b.textBubble)||f.dispose();b.textBubble=null}aa(new (la(O.BUBBLE_OPEN))(b.sourceBlock,a,"warning"))}})}getAnchorLocation(){return fa.sum(this.workspaceLocation,new fa(8.5,8.5))}getBubbleOwnerRect(){const a=this.sourceBlock.getSvgRoot().getBBox();return new Ja(a.y,a.y+a.height,a.x,a.x+a.width)}};ic.TYPE=Xa.WARNING;ic.WEIGHT=2;var yc={};yc.CommentIcon=
cc;yc.Icon=Cf;yc.IconType=Xa;yc.MutatorIcon=d.MutatorIcon$$module$build$src$core$icons$mutator_icon;yc.WarningIcon=ic;yc.exceptions=Dl;yc.registry=yh;d.Names$$module$build$src$core$names=class{constructor(a,b){this.db=new Map;this.dbReverse=new Set;this.variableMap=null;this.variablePrefix=b||"";this.reservedWords=new Set(a?a.split(","):[])}reset(){this.db.clear();this.dbReverse.clear();this.variableMap=null}setVariableMap(a){this.variableMap=a}getNameForUserVariable(a){return this.variableMap?(a=
this.variableMap.getVariableById(a))?a.name:null:(console.warn("Deprecated call to Names.prototype.getName without defining a variable map. To fix, add the following code in your generator's init() function:\nBlockly.YourGeneratorName.nameDB_.setVariableMap(workspace.getVariableMap());"),null)}populateVariables(a){a=d.allUsedVarModels$$module$build$src$core$variables(a);for(let b=0;b<a.length;b++)this.getName(a[b].getId(),d.NameType$$module$build$src$core$names.VARIABLE)}populateProcedures(a){throw Error("The implementation of populateProcedures should be monkey-patched in by blockly.ts");
}getName(a,b){let f=a;b===d.NameType$$module$build$src$core$names.VARIABLE&&(a=this.getNameForUserVariable(a))&&(f=a);a=f.toLowerCase();const g=b===d.NameType$$module$build$src$core$names.VARIABLE||b===d.NameType$$module$build$src$core$names.DEVELOPER_VARIABLE?this.variablePrefix:"";this.db.has(b)||this.db.set(b,new Map);const l=this.db.get(b);if(l.has(a))return g+l.get(a);b=this.getDistinctName(f,b);l.set(a,b.substr(g.length));return b}getUserNames(a){let b;return(a=null==(b=this.db.get(a))?void 0:
b.keys())?Array.from(a):[]}getDistinctName(a,b){a=this.safeName(a);let f=null,g,l;for(;this.dbReverse.has(a+(null!=(g=f)?g:""))||this.reservedWords.has(a+(null!=(l=f)?l:""));)f=f?f+1:2;let n;a+=null!=(n=f)?n:"";this.dbReverse.add(a);return(b===d.NameType$$module$build$src$core$names.VARIABLE||b===d.NameType$$module$build$src$core$names.DEVELOPER_VARIABLE?this.variablePrefix:"")+a}safeName(a){a?(a=encodeURI(a.replace(/ /g,"_")).replace(/[^\w]/g,"_"),"0123456789".includes(a[0])&&(a="my_"+a)):a=d.Msg$$module$build$src$core$msg.UNNAMED_KEY||
"unnamed";return a}static equals(a,b){return a.toLowerCase()===b.toLowerCase()}};(function(a){a=a.NameType||(a.NameType={});a.DEVELOPER_VARIABLE="DEVELOPER_VARIABLE";a.VARIABLE="VARIABLE";a.PROCEDURE="PROCEDURE"})(d.Names$$module$build$src$core$names||(d.Names$$module$build$src$core$names={}));d.NameType$$module$build$src$core$names=d.Names$$module$build$src$core$names.NameType;d.Names$$module$build$src$core$names.DEVELOPER_VARIABLE_TYPE=d.NameType$$module$build$src$core$names.DEVELOPER_VARIABLE;
var Fl=class extends Map{constructor(){super()}set(a,b){if(this.get(a)===b)return this;super.set(a,b);$g(b)&&b.startPublishing();return this}delete(a){const b=this.get(a);a=super.delete(a);if(!a)return a;$g(b)&&b.stopPublishing();return a}clear(){if(this.size)for(const a of this.keys())this.delete(a)}add(a){return this.set(a.getId(),a)}getProcedures(){return[...this.values()]}};d.DEFAULT_ARG$$module$build$src$core$procedures="x";var kb={CATEGORY_NAME:"PROCEDURE",DEFAULT_ARG:d.DEFAULT_ARG$$module$build$src$core$procedures};
kb.ObservableProcedureMap=Fl;kb.allProcedures=ah;kb.findLegalName=d.findLegalName$$module$build$src$core$procedures;kb.flyoutCategory=bh;kb.getCallers=nk;kb.getDefinition=d.getDefinition$$module$build$src$core$procedures;kb.isNameUsed=kk;kb.isProcedureBlock=Lc;kb.mutateCallers=d.mutateCallers$$module$build$src$core$procedures;kb.mutatorOpenListener=mk;kb.rename=d.rename$$module$build$src$core$procedures;var G=new class{constructor(){this.NONE=0;this.FIELD=1;this.HAT=2;this.ICON=4;this.SPACER=8;this.BETWEEN_ROW_SPACER=
16;this.IN_ROW_SPACER=32;this.EXTERNAL_VALUE_INPUT=64;this.INPUT=128;this.INLINE_INPUT=256;this.STATEMENT_INPUT=512;this.CONNECTION=1024;this.PREVIOUS_CONNECTION=2048;this.NEXT_CONNECTION=4096;this.OUTPUT_CONNECTION=8192;this.CORNER=16384;this.LEFT_SQUARE_CORNER=32768;this.LEFT_ROUND_CORNER=65536;this.RIGHT_SQUARE_CORNER=131072;this.RIGHT_ROUND_CORNER=262144;this.JAGGED_EDGE=524288;this.ROW=1048576;this.TOP_ROW=2097152;this.BOTTOM_ROW=4194304;this.INPUT_ROW=8388608;this.LEFT_CORNER=this.LEFT_SQUARE_CORNER|
this.LEFT_ROUND_CORNER;this.RIGHT_CORNER=this.RIGHT_SQUARE_CORNER|this.RIGHT_ROUND_CORNER;this.nextTypeValue_=16777216}getType(a){Object.prototype.hasOwnProperty.call(this,a)||(this[a]=this.nextTypeValue_,this.nextTypeValue_<<=1);return this[a]}isField(a){return a.type&this.FIELD}isHat(a){return a.type&this.HAT}isIcon(a){return a.type&this.ICON}isSpacer(a){return a.type&this.SPACER}isInRowSpacer(a){return a.type&this.IN_ROW_SPACER}isInput(a){return a.type&this.INPUT}isExternalInput(a){return a.type&
this.EXTERNAL_VALUE_INPUT}isInlineInput(a){return a.type&this.INLINE_INPUT}isStatementInput(a){return a.type&this.STATEMENT_INPUT}isPreviousConnection(a){return a.type&this.PREVIOUS_CONNECTION}isNextConnection(a){return a.type&this.NEXT_CONNECTION}isPreviousOrNextConnection(a){return a.type&(this.PREVIOUS_CONNECTION|this.NEXT_CONNECTION)}isLeftRoundedCorner(a){return a.type&this.LEFT_ROUND_CORNER}isRightRoundedCorner(a){return a.type&this.RIGHT_ROUND_CORNER}isLeftSquareCorner(a){return a.type&this.LEFT_SQUARE_CORNER}isRightSquareCorner(a){return a.type&
this.RIGHT_SQUARE_CORNER}isCorner(a){return a.type&this.CORNER}isJaggedEdge(a){return a.type&this.JAGGED_EDGE}isRow(a){return a.type&this.ROW}isBetweenRowSpacer(a){return a.type&this.BETWEEN_ROW_SPACER}isTopRow(a){return a.type&this.TOP_ROW}isBottomRow(a){return a.type&this.BOTTOM_ROW}isTopOrBottomRow(a){return a.type&(this.TOP_ROW|this.BOTTOM_ROW)}isInputRow(a){return a.type&this.INPUT_ROW}},Ob=class{constructor(a){this.centerline=this.xPos=this.height=this.width=0;this.constants_=a;this.type=G.NONE;
this.notchOffset=this.constants_.NOTCH_OFFSET_LEFT}},qe=class{constructor(a){this.elements=[];this.xPos=this.yPos=this.widthWithConnectedBlocks=this.minWidth=this.minHeight=this.width=this.height=0;this.hasStatement=this.hasExternalInput=!1;this.statementEdge=0;this.hasJaggedEdge=this.hasDummyInput=this.hasInlineInput=!1;this.align=null;this.constants_=a;this.type=G.ROW;this.notchOffset=this.constants_.NOTCH_OFFSET_LEFT}getLastInput(){for(let a=this.elements.length-1;0<=a;a--){const b=this.elements[a];
if(G.isInput(b))return b}return null}measure(){throw Error("Unexpected attempt to measure a base Row.");}startsWithElemSpacer(){return!0}endsWithElemSpacer(){return!0}getFirstSpacer(){for(let a=0;a<this.elements.length;a++){const b=this.elements[a];if(G.isSpacer(b))return b}return null}getLastSpacer(){for(let a=this.elements.length-1;0<=a;a--){const b=this.elements[a];if(G.isSpacer(b))return b}return null}},zh=class extends qe{constructor(a){super(a);this.hasNextConnection=!1;this.connection=null;
this.baseline=this.descenderHeight=0;this.type|=G.BOTTOM_ROW}hasLeftSquareCorner(a){return!!a.outputConnection||!!a.getNextBlock()}hasRightSquareCorner(a){return!0}measure(){let a=0,b=0,f=0;for(let g=0;g<this.elements.length;g++){const l=this.elements[g];b+=l.width;G.isSpacer(l)||(G.isNextConnection(l)?f=Math.max(f,l.height):a=Math.max(a,l.height))}this.width=Math.max(this.minWidth,b);this.height=Math.max(this.minHeight,a)+f;this.descenderHeight=f;this.widthWithConnectedBlocks=this.width}startsWithElemSpacer(){return!1}endsWithElemSpacer(){return!1}},
jc=class extends Ob{constructor(a,b){super(a);this.connectionModel=b;this.type|=G.CONNECTION;this.shape=this.constants_.shapeFor(b);this.isDynamicShape="isDynamic"in this.shape&&this.shape.isDynamic;this.highlighted=b.isHighlighted()}},zc=class extends jc{constructor(a,b){super(a,b.connection);this.input=b;this.connectionOffsetY=this.connectionOffsetX=0;this.type|=G.INPUT;this.align=b.align;(this.connectedBlock=b.connection&&b.connection.targetBlock()?b.connection.targetBlock():null)?(a=this.connectedBlock.getHeightWidth(),
this.connectedBlockWidth=a.width,this.connectedBlockHeight=a.height):this.connectedBlockHeight=this.connectedBlockWidth=0}},Df=class extends zc{constructor(a,b){super(a,b);this.height=0;this.type|=G.EXTERNAL_VALUE_INPUT;this.height=this.connectedBlock?this.connectedBlockHeight-this.constants_.TAB_OFFSET_FROM_TOP-this.constants_.MEDIUM_PADDING:this.shape.height;this.width=this.shape.width+this.constants_.EXTERNAL_VALUE_INPUT_PADDING;this.connectionOffsetY=this.constants_.TAB_OFFSET_FROM_TOP;this.connectionHeight=
this.shape.height;this.connectionWidth=this.shape.width}},Ad=class extends Ob{constructor(a,b,f){super(a);this.field=b;this.parentInput=f;this.isEditable=b.EDITABLE;this.flipRtl=b.getFlipRtl();this.type|=G.FIELD;a=this.field.getSize();this.height=a.height;this.width=a.width}},Ah=class extends Ob{constructor(a){super(a);this.type|=G.HAT;this.height=this.constants_.START_HAT.height;this.width=this.constants_.START_HAT.width;this.ascenderHeight=this.height}},Gl=class extends Ob{constructor(a,b){super(a);
this.icon=b;this.flipRtl=!1;this.type|=G.ICON;a=b.getSize();this.height=a.height;this.width=a.width}},rb=class extends Ob{constructor(a,b){super(a);this.type=this.type|G.SPACER|G.IN_ROW_SPACER;this.width=b;this.height=this.constants_.SPACER_DEFAULT_HEIGHT}},Bh=class extends zc{constructor(a,b){super(a,b);this.type|=G.INLINE_INPUT;this.connectedBlock?(this.width=this.connectedBlockWidth,this.height=this.connectedBlockHeight):(this.height=this.constants_.EMPTY_INLINE_INPUT_HEIGHT,this.width=this.constants_.EMPTY_INLINE_INPUT_PADDING);
this.connectionHeight=this.isDynamicShape?this.shape.height(this.height):this.shape.height;this.connectionWidth=this.isDynamicShape?this.shape.width(this.height):this.shape.width;this.connectedBlock||(this.width+=this.connectionWidth*(this.isDynamicShape?2:1));this.connectionOffsetY="connectionOffsetY"in this.shape?this.shape.connectionOffsetY(this.connectionHeight):this.constants_.TAB_OFFSET_FROM_TOP;this.connectionOffsetX="connectionOffsetX"in this.shape?this.shape.connectionOffsetX(this.connectionWidth):
0}},re=class extends zc{constructor(a,b){super(a,b);this.type|=G.STATEMENT_INPUT;this.height=this.connectedBlock?this.connectedBlockHeight+this.constants_.STATEMENT_BOTTOM_SPACER:this.constants_.EMPTY_STATEMENT_INPUT_HEIGHT;this.width=this.constants_.STATEMENT_INPUT_NOTCH_OFFSET+this.shape.width}},Ch=class extends qe{constructor(a){super(a);this.connectedBlockWidths=0;this.type|=G.INPUT_ROW}measure(){this.width=this.minWidth;this.height=this.minHeight;let a=0;for(let b=0;b<this.elements.length;b++){const f=
this.elements[b];this.width+=f.width;G.isInput(f)&&f instanceof zc&&(G.isStatementInput(f)&&f instanceof re?a+=f.connectedBlockWidth:G.isExternalInput(f)&&f instanceof Df&&0!==f.connectedBlockWidth&&(a+=f.connectedBlockWidth-f.connectionWidth));G.isSpacer(f)||(this.height=Math.max(this.height,f.height))}this.connectedBlockWidths=a;this.widthWithConnectedBlocks=this.width+a}endsWithElemSpacer(){return!this.hasExternalInput&&!this.hasStatement}},Hl=class extends Ob{constructor(a){super(a);this.type|=
G.JAGGED_EDGE;this.height=this.constants_.JAGGED_TEETH.height;this.width=this.constants_.JAGGED_TEETH.width}},Il=class extends jc{constructor(a,b){super(a,b);this.type|=G.NEXT_CONNECTION;this.height=this.shape.height;this.width=this.shape.width}},Jl=class extends jc{constructor(a,b){super(a,b);this.connectionOffsetX=0;this.type|=G.OUTPUT_CONNECTION;this.height=this.isDynamicShape?0:this.shape.height;this.startX=this.width=this.isDynamicShape?0:this.shape.width;this.connectionOffsetY=this.constants_.TAB_OFFSET_FROM_TOP}},
Kl=class extends jc{constructor(a,b){super(a,b);this.type|=G.PREVIOUS_CONNECTION;this.height=this.shape.height;this.width=this.shape.width}},se=class extends Ob{constructor(a,b){super(a);this.type=(b&&"left"!==b?G.RIGHT_ROUND_CORNER:G.LEFT_ROUND_CORNER)|G.CORNER;this.width=this.constants_.CORNER_RADIUS;this.height=this.constants_.CORNER_RADIUS/2}},Dh=class extends qe{constructor(a,b,f){super(a);this.height=b;this.width=f;this.precedesStatement=this.followsStatement=!1;this.widthWithConnectedBlocks=
0;this.type=this.type|G.SPACER|G.BETWEEN_ROW_SPACER;this.elements=[new rb(this.constants_,f)]}measure(){}},te=class extends Ob{constructor(a,b){super(a);this.type=(b&&"left"!==b?G.RIGHT_SQUARE_CORNER:G.LEFT_SQUARE_CORNER)|G.CORNER;this.width=this.height=this.constants_.NO_PADDING}},Eh=class extends qe{constructor(a){super(a);this.ascenderHeight=this.capline=0;this.hasPreviousConnection=!1;this.connection=null;this.type|=G.TOP_ROW}hasLeftSquareCorner(a){const b=(a.hat?"cap"===a.hat:this.constants_.ADD_START_HATS)&&
!a.outputConnection&&!a.previousConnection,f=a.getPreviousBlock();return!!a.outputConnection||b||(f?f.getNextBlock()===a:!1)}hasRightSquareCorner(a){return!0}measure(){let a=0,b=0,f=0;for(let g=0;g<this.elements.length;g++){const l=this.elements[g];b+=l.width;G.isSpacer(l)||(G.isHat(l)&&l instanceof Ah?f=Math.max(f,l.ascenderHeight):a=Math.max(a,l.height))}this.width=Math.max(this.minWidth,b);this.height=Math.max(this.minHeight,a)+f;this.capline=this.ascenderHeight=f;this.widthWithConnectedBlocks=
this.width}startsWithElemSpacer(){return!1}endsWithElemSpacer(){return!1}},Ef=class{constructor(){this.NO_PADDING=0;this.SMALL_PADDING=3;this.MEDIUM_PADDING=5;this.MEDIUM_LARGE_PADDING=8;this.LARGE_PADDING=10;this.TAB_HEIGHT=15;this.TAB_OFFSET_FROM_TOP=5;this.TAB_VERTICAL_OVERLAP=2.5;this.TAB_WIDTH=8;this.NOTCH_WIDTH=15;this.NOTCH_HEIGHT=4;this.MIN_BLOCK_WIDTH=12;this.EMPTY_BLOCK_SPACER_HEIGHT=16;this.CORNER_RADIUS=8;this.NOTCH_OFFSET_LEFT=15;this.STATEMENT_BOTTOM_SPACER=0;this.STATEMENT_INPUT_PADDING_LEFT=
20;this.BETWEEN_STATEMENT_PADDING_Y=4;this.ADD_START_HATS=!1;this.START_HAT_HEIGHT=15;this.START_HAT_WIDTH=100;this.SPACER_DEFAULT_HEIGHT=15;this.MIN_BLOCK_HEIGHT=24;this.EMPTY_INLINE_INPUT_PADDING=14.5;this.EXTERNAL_VALUE_INPUT_PADDING=2;this.JAGGED_TEETH_HEIGHT=12;this.JAGGED_TEETH_WIDTH=6;this.FIELD_TEXT_FONTSIZE=11;this.FIELD_TEXT_FONTWEIGHT="normal";this.FIELD_TEXT_FONTFAMILY="sans-serif";this.FIELD_TEXT_BASELINE=this.FIELD_TEXT_HEIGHT=-1;this.FIELD_BORDER_RECT_RADIUS=4;this.FIELD_BORDER_RECT_HEIGHT=
16;this.FIELD_BORDER_RECT_X_PADDING=5;this.FIELD_BORDER_RECT_Y_PADDING=3;this.FIELD_BORDER_RECT_COLOUR="#fff";this.FIELD_DROPDOWN_SVG_ARROW=this.FIELD_DROPDOWN_COLOURED_DIV=this.FIELD_DROPDOWN_NO_BORDER_RECT_SHADOW=!1;this.FIELD_DROPDOWN_SVG_ARROW_SIZE=12;this.FIELD_COLOUR_FULL_BLOCK=this.FIELD_TEXTINPUT_BOX_SHADOW=!1;this.FIELD_COLOUR_DEFAULT_WIDTH=26;this.defs=null;this.embossFilterId="";this.embossFilter=null;this.disabledPatternId="";this.disabledPattern=null;this.debugFilterId="";this.cssNode=
this.debugFilter=null;this.CURSOR_COLOUR="#cc0a0a";this.MARKER_COLOUR="#4286f4";this.CURSOR_WS_WIDTH=100;this.WS_CURSOR_HEIGHT=5;this.CURSOR_STACK_PADDING=10;this.CURSOR_BLOCK_PADDING=2;this.CURSOR_STROKE_WIDTH=4;this.FULL_BLOCK_FIELDS=!1;this.INSERTION_MARKER_COLOUR="#000000";this.INSERTION_MARKER_OPACITY=.2;this.SHAPES={PUZZLE:1,NOTCH:2};this.TALL_INPUT_FIELD_OFFSET_Y=this.MEDIUM_PADDING;this.DUMMY_INPUT_SHADOW_MIN_HEIGHT=this.DUMMY_INPUT_MIN_HEIGHT=this.TAB_HEIGHT;this.STATEMENT_INPUT_NOTCH_OFFSET=
this.NOTCH_OFFSET_LEFT;this.TOP_ROW_MIN_HEIGHT=this.MEDIUM_PADDING;this.TOP_ROW_PRECEDES_STATEMENT_MIN_HEIGHT=this.LARGE_PADDING;this.BOTTOM_ROW_MIN_HEIGHT=this.MEDIUM_PADDING;this.BOTTOM_ROW_AFTER_STATEMENT_MIN_HEIGHT=this.LARGE_PADDING;this.EMPTY_INLINE_INPUT_HEIGHT=this.TAB_HEIGHT+11;this.EMPTY_STATEMENT_INPUT_HEIGHT=this.MIN_BLOCK_HEIGHT;this.START_POINT=Oa(0,0);this.FIELD_TEXT_BASELINE_CENTER=!0;this.FIELD_DROPDOWN_BORDER_RECT_HEIGHT=this.FIELD_BORDER_RECT_HEIGHT;this.FIELD_DROPDOWN_SVG_ARROW_PADDING=
this.FIELD_BORDER_RECT_X_PADDING;this.FIELD_DROPDOWN_SVG_ARROW_DATAURI="data:image/svg+xml;base64,PHN2ZyBpZD0iTGF5ZXJfMSIgZGF0YS1uYW1lPSJMYXllciAxIiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHdpZHRoPSIxMi43MSIgaGVpZ2h0PSI4Ljc5IiB2aWV3Qm94PSIwIDAgMTIuNzEgOC43OSI+PHRpdGxlPmRyb3Bkb3duLWFycm93PC90aXRsZT48ZyBvcGFjaXR5PSIwLjEiPjxwYXRoIGQ9Ik0xMi43MSwyLjQ0QTIuNDEsMi40MSwwLDAsMSwxMiw0LjE2TDguMDgsOC4wOGEyLjQ1LDIuNDUsMCwwLDEtMy40NSwwTDAuNzIsNC4xNkEyLjQyLDIuNDIsMCwwLDEsMCwyLjQ0LDIuNDgsMi40OCwwLDAsMSwuNzEuNzFDMSwwLjQ3LDEuNDMsMCw2LjM2LDBTMTEuNzUsMC40NiwxMiwuNzFBMi40NCwyLjQ0LDAsMCwxLDEyLjcxLDIuNDRaIiBmaWxsPSIjMjMxZjIwIi8+PC9nPjxwYXRoIGQ9Ik02LjM2LDcuNzlhMS40MywxLjQzLDAsMCwxLTEtLjQyTDEuNDIsMy40NWExLjQ0LDEuNDQsMCwwLDEsMC0yYzAuNTYtLjU2LDkuMzEtMC41Niw5Ljg3LDBhMS40NCwxLjQ0LDAsMCwxLDAsMkw3LjM3LDcuMzdBMS40MywxLjQzLDAsMCwxLDYuMzYsNy43OVoiIGZpbGw9IiNmZmYiLz48L3N2Zz4=";
this.FIELD_COLOUR_DEFAULT_HEIGHT=this.FIELD_BORDER_RECT_HEIGHT;this.FIELD_CHECKBOX_X_OFFSET=this.FIELD_BORDER_RECT_X_PADDING-3;this.randomIdentifier=String(Math.random()).substring(2)}init(){this.JAGGED_TEETH=this.makeJaggedTeeth();this.NOTCH=this.makeNotch();this.START_HAT=this.makeStartHat();this.PUZZLE_TAB=this.makePuzzleTab();this.INSIDE_CORNERS=this.makeInsideCorners();this.OUTSIDE_CORNERS=this.makeOutsideCorners()}setTheme(a){this.blockStyles=Object.create(null);const b=a.blockStyles;for(const f in b)this.blockStyles[f]=
this.validatedBlockStyle_(b[f]);this.setDynamicProperties_(a)}setDynamicProperties_(a){this.setFontConstants_(a);this.setComponentConstants_(a);this.ADD_START_HATS=void 0!==a.startHats?a.startHats:this.ADD_START_HATS}setFontConstants_(a){a.fontStyle&&a.fontStyle.family&&(this.FIELD_TEXT_FONTFAMILY=a.fontStyle.family);a.fontStyle&&a.fontStyle.weight&&(this.FIELD_TEXT_FONTWEIGHT=a.fontStyle.weight);a.fontStyle&&a.fontStyle.size&&(this.FIELD_TEXT_FONTSIZE=a.fontStyle.size);a=Yf("Hg",this.FIELD_TEXT_FONTSIZE+
"pt",this.FIELD_TEXT_FONTWEIGHT,this.FIELD_TEXT_FONTFAMILY);this.FIELD_TEXT_HEIGHT=a.height;this.FIELD_TEXT_BASELINE=a.baseline}setComponentConstants_(a){this.CURSOR_COLOUR=a.getComponentStyle("cursorColour")||this.CURSOR_COLOUR;this.MARKER_COLOUR=a.getComponentStyle("markerColour")||this.MARKER_COLOUR;this.INSERTION_MARKER_COLOUR=a.getComponentStyle("insertionMarkerColour")||this.INSERTION_MARKER_COLOUR;this.INSERTION_MARKER_OPACITY=Number(a.getComponentStyle("insertionMarkerOpacity"))||this.INSERTION_MARKER_OPACITY}getBlockStyleForColour(a){const b=
"auto_"+a;this.blockStyles[b]||(this.blockStyles[b]=this.createBlockStyle_(a));return{style:this.blockStyles[b],name:b}}getBlockStyle(a){return this.blockStyles[a||""]||(a&&a.startsWith("auto_")?this.getBlockStyleForColour(a.substring(5)).style:this.createBlockStyle_("#000000"))}createBlockStyle_(a){return this.validatedBlockStyle_({colourPrimary:a})}validatedBlockStyle_(a){const b={};a&&Object.assign(b,a);a=be(b.colourPrimary||"#000");b.colourPrimary=a.hex;b.colourSecondary=b.colourSecondary?be(b.colourSecondary).hex:
this.generateSecondaryColour_(b.colourPrimary);b.colourTertiary=b.colourTertiary?be(b.colourTertiary).hex:this.generateTertiaryColour_(b.colourPrimary);b.hat=b.hat||"";return b}generateSecondaryColour_(a){return kd("#fff",a,.6)||a}generateTertiaryColour_(a){return kd("#fff",a,.3)||a}dispose(){this.embossFilter&&Ia(this.embossFilter);this.disabledPattern&&Ia(this.disabledPattern);this.debugFilter&&Ia(this.debugFilter);this.cssNode=null}makeJaggedTeeth(){const a=this.JAGGED_TEETH_HEIGHT,b=this.JAGGED_TEETH_WIDTH,
f=ge([qa(b,a/4),qa(2*-b,a/2),qa(b,a/4)]);return{height:a,width:b,path:f}}makeStartHat(){const a=this.START_HAT_HEIGHT,b=this.START_HAT_WIDTH,f=nb("c",[qa(30,-a),qa(70,-a),qa(b,0)]);return{height:a,width:b,path:f}}makePuzzleTab(){function a(n){n=n?-1:1;const x=-n;var B=f/2;const V=B+2.5,na=B+.5,Pa=qa(-b,n*B);B=qa(b,n*B);return nb("c",[qa(0,n*V),qa(-b,x*na),Pa])+nb("s",[qa(b,2.5*x),B])}const b=this.TAB_WIDTH,f=this.TAB_HEIGHT,g=a(!0),l=a(!1);return{type:this.SHAPES.PUZZLE,width:b,height:f,pathDown:l,
pathUp:g}}makeNotch(){function a(x){return ge([qa(x*g,f),qa(3*x,0),qa(x*g,-f)])}const b=this.NOTCH_WIDTH,f=this.NOTCH_HEIGHT,g=(b-3)/2,l=a(1),n=a(-1);return{type:this.SHAPES.NOTCH,width:b,height:f,pathLeft:l,pathRight:n}}makeInsideCorners(){const a=this.CORNER_RADIUS,b=Va("a","0 0,0",a,qa(-a,a)),f=Va("a","0 0,0",a,qa(a,a));return{width:a,height:a,pathTop:b,pathBottom:f}}makeOutsideCorners(){const a=this.CORNER_RADIUS,b=Oa(0,a)+Va("a","0 0,1",a,qa(a,-a)),f=Va("a","0 0,1",a,qa(a,a)),g=Va("a","0 0,1",
a,qa(-a,-a)),l=Va("a","0 0,1",a,qa(-a,a));return{topLeft:b,topRight:f,bottomRight:l,bottomLeft:g,rightHeight:a}}shapeFor(a){switch(a.type){case oa.INPUT_VALUE:case oa.OUTPUT_VALUE:return this.PUZZLE_TAB;case oa.PREVIOUS_STATEMENT:case oa.NEXT_STATEMENT:return this.NOTCH;default:throw Error("Unknown connection type");}}createDom(a,b,f){this.injectCSS_(b,f);this.defs=T(J.DEFS,{},a);a=T(J.FILTER,{id:"blocklyEmbossFilter"+this.randomIdentifier},this.defs);T(J.FEGAUSSIANBLUR,{"in":"SourceAlpha",stdDeviation:1,
result:"blur"},a);b=T(J.FESPECULARLIGHTING,{"in":"blur",surfaceScale:1,specularConstant:.5,specularExponent:10,"lighting-color":"white",result:"specOut"},a);T(J.FEPOINTLIGHT,{x:-5E3,y:-1E4,z:2E4},b);T(J.FECOMPOSITE,{"in":"specOut",in2:"SourceAlpha",operator:"in",result:"specOut"},a);T(J.FECOMPOSITE,{"in":"SourceGraphic",in2:"specOut",operator:"arithmetic",k1:0,k2:1,k3:1,k4:0},a);this.embossFilterId=a.id;this.embossFilter=a;a=T(J.PATTERN,{id:"blocklyDisabledPattern"+this.randomIdentifier,patternUnits:"userSpaceOnUse",
width:10,height:10},this.defs);T(J.RECT,{width:10,height:10,fill:"#aaa"},a);T(J.PATH,{d:"M 0 0 L 10 10 M 10 0 L 0 10",stroke:"#cc0"},a);this.disabledPatternId=a.id;this.disabledPattern=a;this.createDebugFilter()}createDebugFilter(){if(!this.debugFilter){const a=T(J.FILTER,{id:"blocklyDebugFilter"+this.randomIdentifier,height:"160%",width:"180%",y:"-30%",x:"-40%"},this.defs),b=T(J.FECOMPONENTTRANSFER,{result:"outBlur"},a);T(J.FEFUNCA,{type:"table",tableValues:"0 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1"},b);
T(J.FEFLOOD,{"flood-color":"#ff0000","flood-opacity":.5,result:"outColor"},a);T(J.FECOMPOSITE,{"in":"outColor",in2:"outBlur",operator:"in",result:"outGlow"},a);this.debugFilterId=a.id;this.debugFilter=a}}injectCSS_(a,b){b=this.getCSS_(b);a="blockly-renderer-style-"+a;this.cssNode=document.getElementById(a);const f=b.join("\n");this.cssNode?this.cssNode.firstChild.textContent=f:(b=document.createElement("style"),b.id=a,a=document.createTextNode(f),b.appendChild(a),document.head.insertBefore(b,document.head.firstChild),
this.cssNode=b)}getCSS_(a){return[`${a} .blocklyText, `,`${a} .blocklyFlyoutLabelText {`,`font: ${this.FIELD_TEXT_FONTWEIGHT} `+`${this.FIELD_TEXT_FONTSIZE}pt ${this.FIELD_TEXT_FONTFAMILY};`,"}",`${a} .blocklyText {`,"fill: #fff;","}",`${a} .blocklyNonEditableText>rect,`,`${a} .blocklyEditableText>rect {`,`fill: ${this.FIELD_BORDER_RECT_COLOUR};`,"fill-opacity: .6;","stroke: none;","}",`${a} .blocklyNonEditableText>text,`,`${a} .blocklyEditableText>text {`,"fill: #000;","}",`${a} .blocklyFlyoutLabelText {`,
"fill: #000;","}",`${a} .blocklyText.blocklyBubbleText {`,"fill: #000;","}",`${a} .blocklyEditableText:not(.editing):hover>rect {`,"stroke: #fff;","stroke-width: 2;","}",`${a} .blocklyHtmlInput {`,`font-family: ${this.FIELD_TEXT_FONTFAMILY};`,`font-weight: ${this.FIELD_TEXT_FONTWEIGHT};`,"}",`${a} .blocklySelected>.blocklyPath {`,"stroke: #fc3;","stroke-width: 3px;","}",`${a} .blocklyHighlightedConnectionPath {`,"stroke: #fc3;","}",`${a} .blocklyReplaceable .blocklyPath {`,"fill-opacity: .5;","}",
`${a} .blocklyReplaceable .blocklyPathLight,`,`${a} .blocklyReplaceable .blocklyPathDark {`,"display: none;","}",`${a} .blocklyInsertionMarker>.blocklyPath {`,`fill-opacity: ${this.INSERTION_MARKER_OPACITY};`,"stroke: none;","}"]}},Ff=class{constructor(a,b){this.inlinePath_=this.outlinePath_="";this.block_=a;this.info_=b;this.topLeft_=a.getRelativeToSurfaceXY();this.constants_=b.getRenderer().getConstants()}draw(){this.drawOutline_();this.drawInternals_();this.updateConnectionHighlights();this.block_.pathObject.setPath(this.outlinePath_+
"\n"+this.inlinePath_);this.info_.RTL&&this.block_.pathObject.flipRTL();this.recordSizeOnBlock_()}recordSizeOnBlock_(){this.block_.height=this.info_.height;this.block_.width=this.info_.widthWithChildren;this.block_.childlessWidth=this.info_.width}drawOutline_(){this.drawTop_();for(let a=1;a<this.info_.rows.length-1;a++){const b=this.info_.rows[a];b.hasJaggedEdge?this.drawJaggedEdge_(b):b.hasStatement?this.drawStatementInput_(b):b.hasExternalInput?this.drawValueInput_(b):this.drawRightSideRow_(b)}this.drawBottom_();
this.drawLeft_()}drawTop_(){const a=this.info_.topRow,b=a.elements;this.positionPreviousConnection_();this.outlinePath_+=Oa(a.xPos,this.info_.startY);for(let f=0,g;g=b[f];f++)G.isLeftRoundedCorner(g)?this.outlinePath_+=this.constants_.OUTSIDE_CORNERS.topLeft:G.isRightRoundedCorner(g)?this.outlinePath_+=this.constants_.OUTSIDE_CORNERS.topRight:G.isPreviousConnection(g)&&g instanceof jc?this.outlinePath_+=g.shape.pathLeft:G.isHat(g)?this.outlinePath_+=this.constants_.START_HAT.path:G.isSpacer(g)&&(this.outlinePath_+=
pa("h",g.width));this.outlinePath_+=pa("v",a.height)}drawJaggedEdge_(a){this.outlinePath_+=this.constants_.JAGGED_TEETH.path+pa("v",a.height-this.constants_.JAGGED_TEETH.height)}drawValueInput_(a){const b=a.getLastInput();this.positionExternalValueConnection_(a);const f=ch(b.shape)?b.shape.pathDown(b.height):b.shape.pathDown;this.outlinePath_+=pa("H",b.xPos+b.width)+f+pa("v",a.height-b.connectionHeight)}drawStatementInput_(a){var b=a.getLastInput();if(b){var f=b.xPos+b.notchOffset+b.shape.width;b=
b.shape.pathRight+pa("h",-(b.notchOffset-this.constants_.INSIDE_CORNERS.width))+this.constants_.INSIDE_CORNERS.pathTop;var g=a.height-2*this.constants_.INSIDE_CORNERS.height;this.outlinePath_+=pa("H",f)+b+pa("v",g)+this.constants_.INSIDE_CORNERS.pathBottom+pa("H",a.xPos+a.width);this.positionStatementInputConnection_(a)}}drawRightSideRow_(a){this.outlinePath_+=pa("V",a.yPos+a.height)}drawBottom_(){const a=this.info_.bottomRow,b=a.elements;this.positionNextConnection_();let f=0,g="";for(let l=b.length-
1,n;n=b[l];l--)G.isNextConnection(n)&&n instanceof jc?g+=n.shape.pathRight:G.isLeftSquareCorner(n)?g+=pa("H",a.xPos):G.isLeftRoundedCorner(n)?g+=this.constants_.OUTSIDE_CORNERS.bottomLeft:G.isRightRoundedCorner(n)?(g+=this.constants_.OUTSIDE_CORNERS.bottomRight,f=this.constants_.OUTSIDE_CORNERS.rightHeight):G.isSpacer(n)&&(g+=pa("h",-1*n.width));this.outlinePath_+=pa("V",a.baseline-f);this.outlinePath_+=g}drawLeft_(){var a=this.info_.outputConnection;this.positionOutputConnection_();if(a){const b=
a.connectionOffsetY+a.height;a=ch(a.shape)?a.shape.pathUp(a.height):a.shape.pathUp;this.outlinePath_+=pa("V",b)+a}this.outlinePath_+="z"}drawInternals_(){for(let a=0,b;b=this.info_.rows[a];a++)for(let f=0,g;g=b.elements[f];f++)G.isInlineInput(g)?this.drawInlineInput_(g):(G.isIcon(g)||G.isField(g))&&this.layoutField_(g)}layoutField_(a){const b=a.centerline-a.height/2;let f=a.xPos;var g="";this.info_.RTL&&(f=-(f+a.width),a.flipRtl&&(f+=a.width,g="scale(-1 1)"));G.isIcon(a)?(g=a.icon,g.setOffsetInBlock(new fa(f,
b)),this.info_.isInsertionMarker&&g.hideForInsertionMarker()):(a=a.field.getSvgRoot(),a.setAttribute("transform","translate("+f+","+b+")"+g),this.info_.isInsertionMarker&&a.setAttribute("display","none"))}drawInlineInput_(a){const b=a.width,f=a.height,g=a.connectionOffsetY,l=a.connectionHeight+g;this.inlinePath_+=Za(a.xPos+a.connectionWidth,a.centerline-f/2)+pa("v",g)+a.shape.pathDown+pa("v",f-l)+pa("h",b-a.connectionWidth)+pa("v",-f)+"z";this.positionInlineInputConnection_(a)}positionInlineInputConnection_(a){const b=
a.centerline-a.height/2;if(a.connectionModel){let f=a.xPos+a.connectionWidth+a.connectionOffsetX;this.info_.RTL&&(f*=-1);a.connectionModel.setOffsetInBlock(f,b+a.connectionOffsetY)}}positionStatementInputConnection_(a){const b=a.getLastInput();if(null==b?0:b.connectionModel){let f=a.xPos+a.statementEdge+b.notchOffset;this.info_.RTL&&(f*=-1);b.connectionModel.setOffsetInBlock(f,a.yPos)}}positionExternalValueConnection_(a){const b=a.getLastInput();if(b&&b.connectionModel){let f=a.xPos+a.width;this.info_.RTL&&
(f*=-1);b.connectionModel.setOffsetInBlock(f,a.yPos)}}positionPreviousConnection_(){const a=this.info_.topRow;if(a.connection){const b=a.xPos+a.notchOffset;a.connection.connectionModel.setOffsetInBlock(this.info_.RTL?-b:b,0)}}positionNextConnection_(){const a=this.info_.bottomRow;if(a.connection){const b=a.connection,f=b.xPos;b.connectionModel.setOffsetInBlock(this.info_.RTL?-f:f,a.baseline)}}positionOutputConnection_(){if(this.info_.outputConnection){const a=this.info_.startX+this.info_.outputConnection.connectionOffsetX;
this.block_.outputConnection.setOffsetInBlock(this.info_.RTL?-a:a,this.info_.outputConnection.connectionOffsetY)}}updateConnectionHighlights(){for(const a of this.info_.rows)for(const b of a.elements)if(b instanceof jc)if(b.highlighted)this.drawConnectionHighlightPath(b);else{let f,g;null==(g=(f=this.block_.pathObject).removeConnectionHighlight)||g.call(f,b.connectionModel)}}drawConnectionHighlightPath(a){const b=a.connectionModel;a=b.type===oa.INPUT_VALUE||b.type===oa.OUTPUT_VALUE?this.getExpressionConnectionHighlightPath(a):
this.getStatementConnectionHighlightPath(a);const f=b.getSourceBlock();let g,l;null==(l=(g=f.pathObject).addConnectionHighlight)||l.call(g,b,a,b.getOffsetInBlock(),f.RTL)}getExpressionConnectionHighlightPath(a){let b="";ch(a.shape)?b=a.shape.pathDown(a.height):On(a.shape)&&(b=a.shape.pathDown);a=this.constants_.TAB_OFFSET_FROM_TOP;return Oa(0,-a)+pa("v",a)+b+pa("v",a)}getStatementConnectionHighlightPath(a){if(!Pn(a.shape))throw Error("Statement connections should have notch shapes");const b=this.constants_.NOTCH_OFFSET_LEFT-
this.constants_.CORNER_RADIUS;return Oa(-b,0)+pa("h",b)+a.shape.pathLeft+pa("h",b)}};(function(a){a[a.LEFT=-1]="LEFT";a[a.CENTRE=0]="CENTRE";a[a.RIGHT=1]="RIGHT"})(d.Align$$module$build$src$core$inputs$align||(d.Align$$module$build$src$core$inputs$align={}));var Wc=class extends Ka{constructor(a,b,f){super(Ka.SKIP_SETUP);this.class=null;this.EDITABLE=!1;this.maxDisplayLength=Infinity;a!==Ka.SKIP_SETUP&&(f?this.configure_(f):this.class=b||null,this.setValue(a))}configure_(a){super.configure_(a);a.class&&
(this.class=a.class)}initView(){this.createTextElement_();this.class&&sa(this.getTextElement(),this.class)}doClassValidation_(a){return null===a||void 0===a?null:`${a}`}setClass(a){this.textElement_&&(this.class&&Ma(this.textElement_,this.class),a&&sa(this.textElement_,a));this.class=a}static fromJson(a){return new this(Ua(a.text),void 0,a)}};Zb("field_label",Wc);Wc.prototype.DEFAULT_VALUE="";var Bd=class{constructor(a,b){this.name=a;this.sourceBlock=b;this.fieldRow=[];this.align=d.Align$$module$build$src$core$inputs$align.LEFT;
this.visible=!0;this.type=d.inputTypes$$module$build$src$core$inputs$input_types.CUSTOM;this.connection=null}getSourceBlock(){return this.sourceBlock}appendField(a,b){this.insertFieldAt(this.fieldRow.length,a,b);return this}insertFieldAt(a,b,f){if(0>a||a>this.fieldRow.length)throw Error("index "+a+" out of bounds.");if(!(b||""===b&&f))return a;"string"===typeof b&&(b=d.fromJson$$module$build$src$core$field_registry({type:"field_label",text:b}));b.setSourceBlock(this.sourceBlock);this.sourceBlock.initialized&&
this.initField(b);b.name=f;b.setVisible(this.isVisible());b.prefixField&&(a=this.insertFieldAt(a,b.prefixField));this.fieldRow.splice(a,0,b);a++;b.suffixField&&(a=this.insertFieldAt(a,b.suffixField));this.sourceBlock.rendered&&this.sourceBlock.queueRender();return a}removeField(a,b){for(let f=0,g;g=this.fieldRow[f];f++)if(g.name===a)return g.dispose(),this.fieldRow.splice(f,1),this.sourceBlock.rendered&&this.sourceBlock.queueRender(),!0;if(b)return!1;throw Error('Field "'+a+'" not found.');}isVisible(){return this.visible}setVisible(a){let b=
[];if(this.visible===a)return b;this.visible=a;for(let g=0,l;l=this.fieldRow[g];g++)l.setVisible(a);if(this.connection){var f=this.connection;a?b=f.startTrackingAll():f.stopTrackingAll();if(f=f.targetBlock())f.getSvgRoot().style.display=a?"block":"none"}return b}markDirty(){for(let a=0,b;b=this.fieldRow[a];a++)b.markDirty()}setCheck(a){if(!this.connection)throw Error("This input does not have a connection.");this.connection.setCheck(a);return this}setAlign(a){this.align=a;this.sourceBlock.rendered&&
this.sourceBlock.queueRender();return this}setShadowDom(a){if(!this.connection)throw Error("This input does not have a connection.");this.connection.setShadowDom(a);return this}getShadowDom(){if(!this.connection)throw Error("This input does not have a connection.");return this.connection.getShadowDom()}init(){for(const a of this.fieldRow)a.init()}initModel(){for(const a of this.fieldRow)a.initModel()}initField(a){this.sourceBlock.rendered?a.init():a.initModel()}dispose(){for(let a=0,b;b=this.fieldRow[a];a++)b.dispose();
this.connection&&this.connection.dispose()}makeConnection(a){return this.sourceBlock.makeConnection_(a)}},Pb=class extends Bd{constructor(a,b){super(a,b);this.name=a;this.type=d.inputTypes$$module$build$src$core$inputs$input_types.DUMMY}},kc=class extends Bd{constructor(a,b){super(a,b);this.name=a;this.type=d.inputTypes$$module$build$src$core$inputs$input_types.END_ROW}},sb=class extends Bd{constructor(a,b){if(!a)throw Error("Statement inputs must have a non-empty name");super(a,b);this.name=a;this.type=
d.inputTypes$$module$build$src$core$inputs$input_types.STATEMENT;this.connection=this.makeConnection(oa.NEXT_STATEMENT)}};d.ValueInput$$module$build$src$core$inputs$value_input=class extends Bd{constructor(a,b){if(!a)throw Error("Value inputs must have a non-empty name");super(a,b);this.name=a;this.type=d.inputTypes$$module$build$src$core$inputs$input_types.VALUE;this.connection=this.makeConnection(oa.INPUT_VALUE)}};var ue=class{constructor(a,b){this.statementEdge=this.width=this.widthWithChildren=
this.height=0;this.rows=[];this.inputRows=[];this.startY=this.startX=0;this.renderer_=a;this.block_=b;this.constants_=this.renderer_.getConstants();this.outputConnection=b.outputConnection?new Jl(this.constants_,b.outputConnection):null;this.isInline=b.getInputsInline()&&!b.isCollapsed();this.isCollapsed=b.isCollapsed();this.isInsertionMarker=b.isInsertionMarker();this.RTL=b.RTL;this.topRow=new Eh(this.constants_);this.bottomRow=new zh(this.constants_)}getRenderer(){return this.renderer_}measure(){this.createRows_();
this.addElemSpacing_();this.addRowSpacing_();this.computeBounds_();this.alignRowElements_();this.finalize_()}createRows_(){this.populateTopRow_();this.rows.push(this.topRow);let a=new Ch(this.constants_);this.inputRows.push(a);var b=this.block_.getIcons();for(let f=0,g;g=b[f];f++){const l=new Gl(this.constants_,g);this.isCollapsed&&!g.isShownWhenCollapsed()||a.elements.push(l)}b=void 0;for(let f=0,g;g=this.block_.inputList[f];f++)if(g.isVisible()){this.shouldStartNewRow_(g,b)&&(this.rows.push(a),
a=new Ch(this.constants_),this.inputRows.push(a));for(let l=0,n;n=g.fieldRow[l];l++)a.elements.push(new Ad(this.constants_,n,g));this.addInput_(g,a);b=g}this.isCollapsed&&(a.hasJaggedEdge=!0,a.elements.push(new Hl(this.constants_)));(a.elements.length||a.hasDummyInput)&&this.rows.push(a);this.populateBottomRow_();this.rows.push(this.bottomRow)}populateTopRow_(){var a=!!this.block_.previousConnection;const b=(this.block_.hat?"cap"===this.block_.hat:this.constants_.ADD_START_HATS)&&!this.outputConnection&&
!a;let f=this.topRow.hasLeftSquareCorner(this.block_)?te:se;this.topRow.elements.push(new f(this.constants_));b?(a=new Ah(this.constants_),this.topRow.elements.push(a),this.topRow.capline=a.ascenderHeight):a&&(this.topRow.hasPreviousConnection=!0,this.topRow.connection=new Kl(this.constants_,this.block_.previousConnection),this.topRow.elements.push(this.topRow.connection));this.block_.inputList.length&&this.block_.inputList[0]instanceof sb&&!this.block_.isCollapsed()?this.topRow.minHeight=this.constants_.TOP_ROW_PRECEDES_STATEMENT_MIN_HEIGHT:
this.topRow.minHeight=this.constants_.TOP_ROW_MIN_HEIGHT;f=this.topRow.hasRightSquareCorner(this.block_)?te:se;this.topRow.elements.push(new f(this.constants_,"right"))}populateBottomRow_(){this.bottomRow.hasNextConnection=!!this.block_.nextConnection;this.bottomRow.minHeight=this.block_.inputList.length&&this.block_.inputList[this.block_.inputList.length-1]instanceof sb?this.constants_.BOTTOM_ROW_AFTER_STATEMENT_MIN_HEIGHT:this.constants_.BOTTOM_ROW_MIN_HEIGHT;this.bottomRow.hasLeftSquareCorner(this.block_)?
this.bottomRow.elements.push(new te(this.constants_)):this.bottomRow.elements.push(new se(this.constants_));this.bottomRow.hasNextConnection&&(this.bottomRow.connection=new Il(this.constants_,this.block_.nextConnection),this.bottomRow.elements.push(this.bottomRow.connection));this.bottomRow.hasRightSquareCorner(this.block_)?this.bottomRow.elements.push(new te(this.constants_,"right")):this.bottomRow.elements.push(new se(this.constants_,"right"))}addInput_(a,b){if(this.isInline&&a instanceof d.ValueInput$$module$build$src$core$inputs$value_input)b.elements.push(new Bh(this.constants_,
a)),b.hasInlineInput=!0;else if(a instanceof sb)b.elements.push(new re(this.constants_,a)),b.hasStatement=!0;else if(a instanceof d.ValueInput$$module$build$src$core$inputs$value_input)b.elements.push(new Df(this.constants_,a)),b.hasExternalInput=!0;else if(a instanceof Pb||a instanceof kc)b.minHeight=Math.max(b.minHeight,a.getSourceBlock()&&a.getSourceBlock().isShadow()?this.constants_.DUMMY_INPUT_SHADOW_MIN_HEIGHT:this.constants_.DUMMY_INPUT_MIN_HEIGHT),b.hasDummyInput=!0;null===b.align&&(b.align=
a.align)}shouldStartNewRow_(a,b){return b?b instanceof kc||a instanceof sb||b instanceof sb?!0:a instanceof d.ValueInput$$module$build$src$core$inputs$value_input||a instanceof Pb||b instanceof d.ValueInput$$module$build$src$core$inputs$value_input?!this.isInline:!1:!1}addElemSpacing_(){for(let a=0,b;b=this.rows[a];a++){const f=b.elements;b.elements=[];b.startsWithElemSpacer()&&b.elements.push(new rb(this.constants_,this.getInRowSpacing_(null,f[0])));if(f.length){for(let g=0;g<f.length-1;g++){b.elements.push(f[g]);
const l=this.getInRowSpacing_(f[g],f[g+1]);b.elements.push(new rb(this.constants_,l))}b.elements.push(f[f.length-1]);b.endsWithElemSpacer()&&b.elements.push(new rb(this.constants_,this.getInRowSpacing_(f[f.length-1],null)))}}}getInRowSpacing_(a,b){if(!a&&b&&G.isStatementInput(b))return this.constants_.STATEMENT_INPUT_PADDING_LEFT;if(a&&G.isInput(a)&&!b){if(G.isExternalInput(a))return this.constants_.NO_PADDING;if(G.isInlineInput(a))return this.constants_.LARGE_PADDING;if(G.isStatementInput(a))return this.constants_.NO_PADDING}return a&&
G.isLeftSquareCorner(a)&&b&&(G.isPreviousConnection(b)||G.isNextConnection(b))?b.notchOffset:a&&G.isLeftRoundedCorner(a)&&b&&(G.isPreviousConnection(b)||G.isNextConnection(b))?b.notchOffset-this.constants_.CORNER_RADIUS:this.constants_.MEDIUM_PADDING}computeBounds_(){let a=0,b=0,f=0;for(let l=0,n;n=this.rows[l];l++){n.measure();b=Math.max(b,n.width);if(n.hasStatement){var g=n.getLastInput();let x,B;g=n.width-(null!=(B=null==(x=g)?void 0:x.width)?B:0);a=Math.max(a,g)}f=Math.max(f,n.widthWithConnectedBlocks)}this.statementEdge=
a;this.width=b;for(let l=0,n;n=this.rows[l];l++)n.hasStatement&&(n.statementEdge=this.statementEdge);this.widthWithChildren=Math.max(b,f);this.outputConnection&&(this.startX=this.outputConnection.width,this.width+=this.outputConnection.width,this.widthWithChildren+=this.outputConnection.width)}alignRowElements_(){for(let b=0,f;f=this.rows[b];b++)if(f.hasStatement)this.alignStatementRow_(f);else{var a=f.width;a=this.getDesiredRowWidth_(f)-a;0<a&&this.addAlignmentPadding_(f,a);G.isTopOrBottomRow(f)&&
(f.widthWithConnectedBlocks=f.width)}}getDesiredRowWidth_(a){return this.width-this.startX}addAlignmentPadding_(a,b){const f=a.getFirstSpacer(),g=a.getLastSpacer();if(a.hasExternalInput||a.hasStatement)a.widthWithConnectedBlocks+=b;if(a.align===d.Align$$module$build$src$core$inputs$align.LEFT&&g)g.width+=b;else if(a.align===d.Align$$module$build$src$core$inputs$align.CENTRE&&f&&g)f.width+=b/2,g.width+=b/2;else if(a.align===d.Align$$module$build$src$core$inputs$align.RIGHT&&f)f.width+=b;else if(g)g.width+=
b;else return;a.width+=b}alignStatementRow_(a){const b=a.getLastInput();if(b){var f=a.width-b.width,g=this.statementEdge;f=g-f;0<f&&this.addAlignmentPadding_(a,f);f=a.width;g=this.getDesiredRowWidth_(a);b.width+=g-f;b.height=Math.max(b.height,a.height);a.width+=g-f;a.widthWithConnectedBlocks=Math.max(a.width,this.statementEdge+a.connectedBlockWidths)}}addRowSpacing_(){const a=this.rows;this.rows=[];for(let b=0;b<a.length;b++)this.rows.push(a[b]),b!==a.length-1&&this.rows.push(this.makeSpacerRow_(a[b],
a[b+1]))}makeSpacerRow_(a,b){var f=this.getSpacerRowHeight_(a,b);const g=this.getSpacerRowWidth_(a,b);f=new Dh(this.constants_,f,g);a.hasStatement&&(f.followsStatement=!0);b.hasStatement&&(f.precedesStatement=!0);return f}getSpacerRowWidth_(a,b){return this.width-this.startX}getSpacerRowHeight_(a,b){return this.constants_.MEDIUM_PADDING}getElemCenterline_(a,b){return G.isSpacer(b)?a.yPos+b.height/2:G.isBottomRow(a)?(a=a.yPos+a.height-a.descenderHeight,G.isNextConnection(b)?a+b.height/2:a-b.height/
2):G.isTopRow(a)?G.isHat(b)?a.capline-b.height/2:a.capline+b.height/2:a.yPos+a.height/2}recordElemPositions_(a){let b=a.xPos;for(let f=0,g;g=a.elements[f];f++)G.isSpacer(g)&&(g.height=a.height),g.xPos=b,g.centerline=this.getElemCenterline_(a,g),b+=g.width}finalize_(){let a=0,b=0;for(let f=0,g;g=this.rows[f];f++)g.yPos=b,g.xPos=this.startX,b+=g.height,a=Math.max(a,g.widthWithConnectedBlocks),this.recordElemPositions_(g);if(this.outputConnection&&this.block_.nextConnection){const f=this.block_.nextConnection.targetBlock();
f&&(a=Math.max(a,f.getHeightWidth().width))}this.widthWithChildren=a+this.startX;this.height=b;this.startY=this.topRow.capline;this.bottomRow.baseline=b-this.bottomRow.descenderHeight}getMeasureableForConnection(a){let b;if((null==(b=this.outputConnection)?void 0:b.connectionModel)===a)return this.outputConnection;for(const f of this.rows)for(const g of f.elements)if(g instanceof jc&&g.connectionModel===a)return g;return null}},Fh=class extends Sc{constructor(a){super(a);this.type=O.BLOCK_DELETE;
if(a){if(a.getParent())throw Error("Connected blocks cannot be deleted.");a.isShadow()&&(this.recordUndo=!1);this.oldXml=jf(a);this.ids=Da(a);this.wasShadow=a.isShadow();this.oldJson=vb(a,{addCoordinates:!0})}}toJson(){const a=super.toJson();if(!this.oldXml)throw Error("The old block XML is undefined. Either pass a block to the constructor, or call fromJson");if(!this.ids)throw Error("The block IDs are undefined. Either pass a block to the constructor, or call fromJson");if(void 0===this.wasShadow)throw Error("Whether the block was a shadow is undefined. Either pass a block to the constructor, or call fromJson");
if(!this.oldJson)throw Error("The old block JSON is undefined. Either pass a block to the constructor, or call fromJson");a.oldXml=Xb(this.oldXml);a.ids=this.ids;a.wasShadow=this.wasShadow;a.oldJson=this.oldJson;this.recordUndo||(a.recordUndo=this.recordUndo);return a}static fromJson(a,b,f){b=super.fromJson(a,b,null!=f?f:new Fh);b.oldXml=d.textToDom$$module$build$src$core$utils$xml(a.oldXml);b.ids=a.ids;b.wasShadow=a.wasShadow||"shadow"===b.oldXml.tagName.toLowerCase();b.oldJson=a.oldJson;void 0!==
a.recordUndo&&(b.recordUndo=a.recordUndo);return b}run(a){const b=this.getEventWorkspace_();if(!this.ids)throw Error("The block IDs are undefined. Either pass a block to the constructor, or call fromJson");if(!this.oldJson)throw Error("The old block JSON is undefined. Either pass a block to the constructor, or call fromJson");if(a)for(a=0;a<this.ids.length;a++){const f=this.ids[a],g=b.getBlockById(f);g?g.dispose(!1):f===this.blockId&&console.warn("Can't delete non-existent block: "+f)}else pc(this.oldJson,
b)}};e(ba.EVENT,O.BLOCK_DELETE,Fh);var Ba=class{constructor(a,b){this.type=b;this.targetConnection=null;this.disposed=!1;this.shadowDom=this.check=null;this.y=this.x=0;this.shadowState=null;this.sourceBlock_=a}connect_(a){const b=oa.INPUT_VALUE,f=this.getSourceBlock();var g=a.getSourceBlock();a.isConnected()&&a.disconnectInternal(!1);let l;if(this.isConnected()){const x=this.stashShadowState(),B=this.targetBlock();B.isShadow()?B.dispose(!1):(this.disconnectInternal(),l=B);this.applyShadowState(x)}let n;
ia()&&(n=new (la(O.BLOCK_MOVE))(g),n.setReason(["connect"]));Qn(this,a);g.setParent(f);n&&(n.recordNew(),aa(n));if(l&&(a=this.type===b?l.outputConnection:l.previousConnection))if(g=Ba.getConnectionForOrphanedConnection(g,a))a.connect(g);else a.onFailedConnect(this)}dispose(){if(this.isConnected()){this.isSuperior()&&this.setShadowStateInternal();const a=this.targetBlock();a&&!a.isDeadOrDying()&&a.unplug()}this.disposed=!0}getSourceBlock(){return this.sourceBlock_}isSuperior(){return this.type===oa.INPUT_VALUE||
this.type===oa.NEXT_STATEMENT}isConnected(){return!!this.targetConnection}getConnectionChecker(){return this.sourceBlock_.workspace.connectionChecker}onFailedConnect(a){}connect(a){if(this.targetConnection===a)return!0;if(this.getConnectionChecker().canConnect(this,a,!1)){const b=d.getGroup$$module$build$src$core$events$utils();b||d.setGroup$$module$build$src$core$events$utils(!0);this.isSuperior()?this.connect_(a):a.connect_(this);d.setGroup$$module$build$src$core$events$utils(b)}return this.isConnected()}disconnect(){this.disconnectInternal()}disconnectInternal(a=
!0){const {parentConnection:b,childConnection:f}=this.getParentAndChildConnections();if(!b||!f)throw Error("Source connection not connected.");const g=d.getGroup$$module$build$src$core$events$utils();g||d.setGroup$$module$build$src$core$events$utils(!0);let l;ia()&&(l=new (la(O.BLOCK_MOVE))(f.getSourceBlock()),l.setReason(["disconnect"]));const n=this.targetConnection;n&&(n.targetConnection=null);this.targetConnection=null;a&&f.getSourceBlock().setParent(null);l&&(l.recordNew(),aa(l));f.getSourceBlock().isShadow()||
b.respawnShadow_();d.setGroup$$module$build$src$core$events$utils(g)}getParentAndChildConnections(){return this.targetConnection?this.isSuperior()?{parentConnection:this,childConnection:this.targetConnection}:{parentConnection:this.targetConnection,childConnection:this}:{}}respawnShadow_(){this.createShadowBlock(!0)}reconnect(a,b){if(this.getSourceBlock().isDeadOrDying())return!1;var f;b=null==(f=a.getInput(b))?void 0:f.connection;return(f=this.targetBlock())&&f!==a||!b||b.targetConnection===this?
!1:(b.isConnected()&&b.disconnect(),b.connect(this),!0)}targetBlock(){if(this.isConnected()){let a,b;return null!=(b=null==(a=this.targetConnection)?void 0:a.getSourceBlock())?b:null}return null}onCheckChanged_(){!this.isConnected()||this.targetConnection&&this.getConnectionChecker().canConnect(this,this.targetConnection,!1)||(this.isSuperior()?this.targetBlock():this.sourceBlock_).unplug()}setCheck(a){a?(Array.isArray(a)||(a=[a]),this.check=a,this.onCheckChanged_()):this.check=null;return this}getCheck(){return this.check}setShadowDom(a){this.setShadowStateInternal({shadowDom:a})}getShadowDom(a){return a&&
this.targetBlock().isShadow()?Kc(this.targetBlock()):this.shadowDom}setShadowState(a){this.setShadowStateInternal({shadowState:a})}getShadowState(a){return a&&this.targetBlock()&&this.targetBlock().isShadow()?vb(this.targetBlock()):this.shadowState}neighbours(a){return[]}getParentInput(){let a=null;const b=this.sourceBlock_.inputList;for(let f=0;f<b.length;f++)if(b[f].connection===this){a=b[f];break}return a}toString(){const a=this.sourceBlock_;if(!a)return"Orphan Connection";if(a.outputConnection===
this)var b="Output Connection of ";else if(a.previousConnection===this)b="Previous Connection of ";else if(a.nextConnection===this)b="Next Connection of ";else{b=null;for(let f=0,g;g=a.inputList[f];f++)if(g.connection===this){b=g;break}if(b)b='Input "'+b.name+'" connection on ';else return console.warn("Connection not actually connected to sourceBlock_"),"Orphan Connection"}return b+a.toDevString()}stashShadowState(){const a=this.getShadowDom(!0),b=this.getShadowState(!0);this.shadowState=this.shadowDom=
null;return{shadowDom:a,shadowState:b}}applyShadowState({shadowDom:a,shadowState:b}){this.shadowDom=a;this.shadowState=b}setShadowStateInternal({shadowDom:a=null,shadowState:b=null}={}){this.shadowDom=a;this.shadowState=b;this.getSourceBlock().isDeadOrDying()||((a=this.targetBlock())?a.isShadow()?(a.dispose(!1),this.respawnShadow_(),this.targetBlock()&&this.targetBlock().isShadow()&&this.serializeShadow(this.targetBlock())):(a=this.createShadowBlock(!1),this.serializeShadow(a),a&&a.dispose(!1)):(this.respawnShadow_(),
this.targetBlock()&&this.targetBlock().isShadow()&&this.serializeShadow(this.targetBlock())))}createShadowBlock(a){var b=this.getSourceBlock();const f=this.getShadowState(),g=this.getShadowDom();if(b.isDeadOrDying()||!f&&!g)return null;if(f)return Td(f,b.workspace,{parentConnection:a?this:void 0,isShadow:!0,recordUndo:!1});if(g){b=qd(g,b.workspace);if(a)if(this.type===oa.INPUT_VALUE){if(!b.outputConnection)throw Error("Shadow block is missing an output connection");if(!this.connect(b.outputConnection))throw Error("Could not connect shadow block to connection");
}else if(this.type===oa.NEXT_STATEMENT){if(!b.previousConnection)throw Error("Shadow block is missing previous connection");if(!this.connect(b.previousConnection))throw Error("Could not connect shadow block to connection");}else throw Error("Cannot connect a shadow block to a previous/output connection");return b}return null}serializeShadow(a){a&&(this.shadowDom=Kc(a),this.shadowState=vb(a))}static getConnectionForOrphanedConnection(a,b){if(b.type===oa.OUTPUT_VALUE)return Sn(a,b.getSourceBlock());
a=a.lastConnectionInStack(!0);const f=b.getConnectionChecker();return a&&f.canConnect(b,a,!1)?a:null}};Ba.CAN_CONNECT=0;Ba.REASON_SELF_CONNECTION=1;Ba.REASON_WRONG_TYPE=2;Ba.REASON_TARGET_NULL=3;Ba.REASON_CHECKS_FAILED=4;Ba.REASON_DIFFERENT_WORKSPACES=5;Ba.REASON_SHADOW_PARENT=6;Ba.REASON_DRAG_CHECKS_FAILED=7;Ba.REASON_PREVIOUS_AND_OUTPUT=8;var Ac=class{constructor(a,b,f){this.data=null;this.disposed=!1;this.hue=null;this.colour_="#000000";this.styleName_="";this.suppressPrefixSuffix=!1;this.previousConnection=
this.nextConnection=this.outputConnection=null;this.inputList=[];this.icons=[];this.disabledReasons=new Set;this.tooltip="";this.contextMenu=!0;this.parentBlock_=null;this.childBlocks_=[];this.editable=this.movable=this.deletable=!0;this.collapsed_=this.shadow=!1;this.outputShape_=null;this.rendered=this.isInsertionMarker_=this.initialized=this.disposing=!1;this.onchangeWrapper=this.helpUrl=null;this.statementInputCount=0;this.workspace=a;this.id=f&&!a.getBlockById(f)?f:da();a.setBlockById(this.id,
this);this.xy=new fa(0,0);this.isInFlyout=a.isFlyout;this.isInMutator=a.isMutator;this.RTL=a.RTL;if(b){this.type=b;f=hb[b];if(!f||"object"!==typeof f)throw TypeError("Invalid block definition for type: "+b);Object.assign(this,f)}a.addTopBlock(this);a.addTypedBlock(this);new.target===Ac&&this.doInit_()}doInit_(){const a=d.getGroup$$module$build$src$core$events$utils();a||d.setGroup$$module$build$src$core$events$utils(!0);const b=ea();try{"function"===typeof this.init&&(d.setRecordUndo$$module$build$src$core$events$utils(!1),
this.init(),d.setRecordUndo$$module$build$src$core$events$utils(b)),ia()&&aa(new (la(O.BLOCK_CREATE))(this))}finally{d.setGroup$$module$build$src$core$events$utils(a),d.setRecordUndo$$module$build$src$core$events$utils(b)}this.inputsInlineDefault=this.inputsInline;"function"===typeof this.onchange&&this.setOnChange(this.onchange)}dispose(a=!1){this.disposing=!0;this.onchangeWrapper&&this.workspace.removeChangeListener(this.onchangeWrapper);this.unplug(a);ia()&&aa(new (la(O.BLOCK_DELETE))(this));this.workspace.removeTopBlock(this);
this.disposeInternal()}disposeInternal(){this.disposing=!0;this.onchangeWrapper&&this.workspace.removeChangeListener(this.onchangeWrapper);this.workspace.removeTypedBlock(this);this.workspace.removeBlockById(this.id);"function"===typeof this.destroy&&this.destroy();this.childBlocks_.forEach(a=>a.disposeInternal());this.inputList.forEach(a=>a.dispose());this.inputList.length=0;this.getConnections_(!0).forEach(a=>a.dispose());this.disposed=!0}isDeadOrDying(){return this.disposing||this.disposed}initModel(){if(!this.initialized){for(const a of this.inputList)a.initModel();
this.initialized=!0}}unplug(a){this.outputConnection&&this.unplugFromRow(a);this.previousConnection&&this.unplugFromStack(a)}unplugFromRow(a){let b=null,f;if(null==(f=this.outputConnection)?0:f.isConnected())b=this.outputConnection.targetConnection,this.outputConnection.disconnect();b&&a&&(a=this.getOnlyValueConnection())&&a.isConnected()&&!a.targetBlock().isShadow()&&(a=a.targetConnection,null==a||a.disconnect(),this.workspace.connectionChecker.canConnect(a,b,!1)?b.connect(a):null==a||a.onFailedConnect(b))}getOnlyValueConnection(){let a=
null;for(let b=0;b<this.inputList.length;b++){const f=this.inputList[b].connection;if(f&&f.type===oa.INPUT_VALUE&&f.targetConnection){if(a)return null;a=f}}return a}unplugFromStack(a){let b=null;var f;if(null==(f=this.previousConnection)?0:f.isConnected())b=this.previousConnection.targetConnection,this.previousConnection.disconnect();f=this.getNextBlock();if(a&&f&&!f.isShadow()){let g,l;a=null!=(l=null==(g=this.nextConnection)?void 0:g.targetConnection)?l:null;null==a||a.disconnect();b&&this.workspace.connectionChecker.canConnect(b,
a,!1)&&b.connect(a)}}getConnections_(a){a=[];this.outputConnection&&a.push(this.outputConnection);this.previousConnection&&a.push(this.previousConnection);this.nextConnection&&a.push(this.nextConnection);for(let b=0,f;f=this.inputList[b];b++)f.connection&&a.push(f.connection);return a}lastConnectionInStack(a){let b=this.nextConnection;for(;b;){const f=b.targetBlock();if(!f||a&&f.isShadow())return b;b=f.nextConnection}return null}bumpNeighbours(){}getParent(){return this.parentBlock_}getInputWithBlock(a){for(let b=
0,f;f=this.inputList[b];b++)if(f.connection&&f.connection.targetBlock()===a)return f;return null}getSurroundParent(){let a=this,b;do if(b=a,a=a.getParent(),!a)return null;while(a.getNextBlock()===b);return a}getNextBlock(){return this.nextConnection&&this.nextConnection.targetBlock()}getPreviousBlock(){return this.previousConnection&&this.previousConnection.targetBlock()}getRootBlock(){let a,b=this;do a=b,b=a.parentBlock_;while(b);return a}getTopStackBlock(){let a=this,b;do b=a.getPreviousBlock();
while(b&&b.getNextBlock()===a&&(a=b));return a}getChildren(a){if(!a)return this.childBlocks_;a=[];for(let f=0,g;g=this.inputList[f];f++)if(g.connection){var b=g.connection.targetBlock();b&&a.push(b)}(b=this.getNextBlock())&&a.push(b);return a}setParent(a){if(a!==this.parentBlock_){var b=this.previousConnection&&this.previousConnection.targetBlock()||this.outputConnection&&this.outputConnection.targetBlock(),f=!!b;if(f&&a&&b!==a)throw Error("Block connected to superior one that is not new parent.");
if(!f&&a)throw Error("Block not connected to new parent.");if(f&&!a)throw Error("Cannot set parent to null while block is still connected to superior block.");this.parentBlock_?mb(this.parentBlock_.childBlocks_,this):this.workspace.removeTopBlock(this);(this.parentBlock_=a)?a.childBlocks_.push(this):this.workspace.addTopBlock(this)}}getDescendants(a){const b=[this],f=this.getChildren(a);for(let g,l=0;g=f[l];l++)b.push(...g.getDescendants(a));return b}isDeletable(){return this.deletable&&!this.shadow&&
!this.isDeadOrDying()&&!this.workspace.options.readOnly}isOwnDeletable(){return this.deletable}setDeletable(a){this.deletable=a}isMovable(){return this.movable&&!this.shadow&&!this.isDeadOrDying()&&!this.workspace.options.readOnly}isOwnMovable(){return this.movable}setMovable(a){this.movable=a}isDuplicatable(){return this.workspace.hasBlockLimits()?this.workspace.isCapacityAvailable(D(this,!0)):!0}isShadow(){return this.shadow}setShadow(a){this.shadow=a}isInsertionMarker(){return this.isInsertionMarker_}setInsertionMarker(a){this.isInsertionMarker_=
a}isEditable(){return this.editable&&!this.isDeadOrDying()&&!this.workspace.options.readOnly}isOwnEditable(){return this.editable}setEditable(a){this.editable=a;for(let b=0,f;f=this.inputList[b];b++)for(let g=0,l;l=f.fieldRow[g];g++)l.updateEditable()}isDisposed(){return this.disposed}isSimpleReporter(){if(!this.outputConnection)return!1;for(const a of this.inputList)if(a.connection||1<a.fieldRow.length)return!1;return!0}getMatchingConnection(a,b){const f=this.getConnections_(!0);a=a.getConnections_(!0);
if(f.length!==a.length)throw Error("Connection lists did not match in length.");for(let g=0;g<a.length;g++)if(a[g]===b)return f[g];return null}setHelpUrl(a){this.helpUrl=a}setTooltip(a){this.tooltip=a}getTooltip(){return Yd(this)}getColour(){return this.colour_}getStyleName(){return this.styleName_}getHue(){return this.hue}setColour(a){a=be(a);this.hue=a.hue;this.colour_=a.hex}setStyle(a){this.styleName_=a}setOnChange(a){if(a&&"function"!==typeof a)throw Error("onchange must be a function.");this.onchangeWrapper&&
this.workspace.removeChangeListener(this.onchangeWrapper);this.onchange=a;this.onchangeWrapper=a.bind(this);this.workspace.addChangeListener(this.onchangeWrapper)}getField(a){if("string"!==typeof a)throw TypeError("Block.prototype.getField expects a string with the field name but received "+(void 0===a?"nothing":a+" of type "+typeof a)+" instead");for(let b=0,f;f=this.inputList[b];b++)for(let g=0,l;l=f.fieldRow[g];g++)if(l.name===a)return l;return null}getVars(){const a=[];for(let b=0,f;f=this.inputList[b];b++)for(let g=
0,l;l=f.fieldRow[g];g++)l.referencesVariables()&&a.push(l.getValue());return a}getVarModels(){const a=[];for(let b=0,f;f=this.inputList[b];b++)for(let g=0,l;l=f.fieldRow[g];g++)if(l.referencesVariables()){const n=this.workspace.getVariableById(l.getValue());n&&a.push(n)}return a}updateVarName(a){for(let b=0,f;f=this.inputList[b];b++)for(let g=0,l;l=f.fieldRow[g];g++)l.referencesVariables()&&a.getId()===l.getValue()&&l.refreshVariableName()}renameVarById(a,b){for(let f=0,g;g=this.inputList[f];f++)for(let l=
0,n;n=g.fieldRow[l];l++)n.referencesVariables()&&a===n.getValue()&&n.setValue(b)}getFieldValue(a){return(a=this.getField(a))?a.getValue():null}setFieldValue(a,b){const f=this.getField(b);if(!f)throw Error('Field "'+b+'" not found.');f.setValue(a)}setPreviousStatement(a,b){if(a)void 0===b&&(b=null),this.previousConnection||(this.previousConnection=this.makeConnection_(oa.PREVIOUS_STATEMENT)),this.previousConnection.setCheck(b);else if(this.previousConnection){if(this.previousConnection.isConnected())throw Error("Must disconnect previous statement before removing connection.");
this.previousConnection.dispose();this.previousConnection=null}}setNextStatement(a,b){if(a)void 0===b&&(b=null),this.nextConnection||(this.nextConnection=this.makeConnection_(oa.NEXT_STATEMENT)),this.nextConnection.setCheck(b);else if(this.nextConnection){if(this.nextConnection.isConnected())throw Error("Must disconnect next statement before removing connection.");this.nextConnection.dispose();this.nextConnection=null}}setOutput(a,b){if(a)void 0===b&&(b=null),this.outputConnection||(this.outputConnection=
this.makeConnection_(oa.OUTPUT_VALUE)),this.outputConnection.setCheck(b);else if(this.outputConnection){if(this.outputConnection.isConnected())throw Error("Must disconnect output value before removing connection.");this.outputConnection.dispose();this.outputConnection=null}}setInputsInline(a){this.inputsInline!==a&&(aa(new (la(O.BLOCK_CHANGE))(this,"inline",null,this.inputsInline,a)),this.inputsInline=a)}getInputsInline(){if(void 0!==this.inputsInline)return this.inputsInline;for(var a=1;a<this.inputList.length;a++)if(this.inputList[a-
1]instanceof Pb&&this.inputList[a]instanceof Pb)return!1;for(a=1;a<this.inputList.length;a++)if(this.inputList[a-1]instanceof d.ValueInput$$module$build$src$core$inputs$value_input&&this.inputList[a]instanceof Pb)return!0;for(a=0;a<this.inputList.length;a++)if(this.inputList[a]instanceof kc)return!0;return!1}setOutputShape(a){this.outputShape_=a}getOutputShape(){return this.outputShape_}isEnabled(){return 0===this.disabledReasons.size}get disabled(){L("disabled","v11","v12","the isEnabled or hasDisabledReason methods of Block");
return this.hasDisabledReason(fb)}set disabled(a){L("disabled","v11","v12","the setDisabledReason method of Block");this.setDisabledReason(a,fb)}setEnabled(a){L("setEnabled","v11","v12","the setDisabledReason method of Block");this.setDisabledReason(!a,fb)}setDisabledReason(a,b){a||this.workspace.options.disable||!this.hasDisabledReason(fb)||b==fb||this.setDisabledReason(!1,fb);this.disabledReasons.has(b)!==a&&(a?this.disabledReasons.add(b):this.disabledReasons.delete(b),a=new (la(O.BLOCK_CHANGE))(this,
"disabled",null,!a,a),a.setDisabledReason(b),aa(a))}getInheritedDisabled(){let a=this.getSurroundParent();for(;a;){if(!a.isEnabled())return!0;a=a.getSurroundParent()}return!1}hasDisabledReason(a){return this.disabledReasons.has(a)}getDisabledReasons(){return this.disabledReasons}isCollapsed(){return this.collapsed_}setCollapsed(a){this.collapsed_!==a&&(aa(new (la(O.BLOCK_CHANGE))(this,"collapsed",null,this.collapsed_,a)),this.collapsed_=a)}toString(a,b){b=this.toTokens(b);for(let g=2;g<b.length;g++)"("===
b[g-2]&&")"===b[g]&&(b[g-2]=b[g-1],b.splice(g-1,2));let f="";b=b.reduce((g,l)=>{g=g+("("===f||")"===l?"":" ")+l;f=l[l.length-1];return g},"");b=b.trim()||"???";a&&b.length>a&&(b=b.substring(0,a-3)+"...");return b}toTokens(a="?"){const b=[];for(const g of this.inputList)if("_TEMP_COLLAPSED_INPUT"!=g.name){for(const l of g.fieldRow)b.push(l.getText());if(g.connection){const l=g.connection.targetBlock();if(l){var f=g.connection;let n=f.getCheck();!n&&f.targetConnection&&(n=f.targetConnection.getCheck());
(f=!!n&&(n.includes("Boolean")||n.includes("Number")))&&b.push("(");b.push(...l.toTokens(a));f&&b.push(")")}else b.push(a)}}return b}appendValueInput(a){return this.appendInput(new d.ValueInput$$module$build$src$core$inputs$value_input(a,this))}appendStatementInput(a){this.statementInputCount++;return this.appendInput(new sb(a,this))}appendDummyInput(a=""){return this.appendInput(new Pb(a,this))}appendEndRowInput(a=""){return this.appendInput(new kc(a,this))}appendInput(a){this.inputList.push(a);
return a}appendInputFromRegistry(a,b){return(a=t(ba.INPUT,a,!1))?this.appendInput(new a(b,this)):null}jsonInit(a){var b=a.type?'Block "'+a.type+'": ':"";if(a.output&&a.previousStatement)throw Error(b+"Must not have both an output and a previousStatement.");for(var f=0;a["args"+f];){if(void 0===a["message"+f])throw Error(b+`args${f} must have a corresponding message (message${f}).`);f++}a.style&&a.style.hat&&(this.hat=a.style.hat,a.style=null);if(a.style&&a.colour)throw Error(b+"Must not have both a colour and a style.");
a.style?this.jsonInitStyle(a,b):this.jsonInitColour(a,b);for(f=0;void 0!==a["message"+f];)this.interpolate(a["message"+f],a["args"+f]||[],a["implicitAlign"+f]||a["lastDummyAlign"+f],b),f++;void 0!==a.inputsInline&&(d.disable$$module$build$src$core$events$utils(),this.setInputsInline(a.inputsInline),d.enable$$module$build$src$core$events$utils());void 0!==a.output&&this.setOutput(!0,a.output);void 0!==a.outputShape&&this.setOutputShape(a.outputShape);void 0!==a.previousStatement&&this.setPreviousStatement(!0,
a.previousStatement);void 0!==a.nextStatement&&this.setNextStatement(!0,a.nextStatement);void 0!==a.tooltip&&(f=Ua(a.tooltip),this.setTooltip(f));void 0!==a.enableContextMenu&&(this.contextMenu=!!a.enableContextMenu);void 0!==a.suppressPrefixSuffix&&(this.suppressPrefixSuffix=!!a.suppressPrefixSuffix);void 0!==a.helpUrl&&(f=Ua(a.helpUrl),this.setHelpUrl(f));"string"===typeof a.extensions&&(console.warn(b+"JSON attribute 'extensions' should be an array of strings. Found raw string in JSON for '"+a.type+
"' block."),a.extensions=[a.extensions]);void 0!==a.mutator&&Yg(a.mutator,this,!0);a=a.extensions;if(Array.isArray(a))for(b=0;b<a.length;b++)Yg(a[b],this,!1)}jsonInitColour(a,b){if("colour"in a)if(void 0===a.colour)console.warn(b+"Undefined colour value.");else{a=a.colour;try{this.setColour(a)}catch(f){console.warn(b+"Illegal colour value: ",a)}}}jsonInitStyle(a,b){a=a.style;try{this.setStyle(a)}catch(f){console.warn(b+"Style does not exist: ",a)}}mixin(a,b){if(void 0!==b&&"boolean"!==typeof b)throw Error("opt_disableCheck must be a boolean if provided");
if(!b){b=[];for(const f in a)void 0!==this[f]&&b.push(f);if(b.length)throw Error("Mixin will overwrite block members: "+JSON.stringify(b));}Object.assign(this,a)}interpolate(a,b,f,g){a=Kj(a);this.validateTokens(a,b.length);b=this.interpolateArguments(a,b,f);f=[];for(let l=0,n;n=b[l];l++)if(this.isInputKeyword(n.type)){if(a=this.inputFromJson(n,g)){for(let x=0,B;B=f[x];x++)a.appendField(B[0],B[1]);f.length=0}}else(a=this.fieldFromJson(n))&&f.push([a,n.name])}validateTokens(a,b){const f=[];let g=0;
for(let l=0;l<a.length;l++){const n=a[l];if("number"===typeof n){if(1>n||n>b)throw Error('Block "'+this.type+'": Message index %'+n+" out of range.");if(f[n])throw Error('Block "'+this.type+'": Message index %'+n+" duplicated.");f[n]=!0;g++}}if(g!==b)throw Error('Block "'+this.type+'": Message does not reference all '+b+" arg(s).");}interpolateArguments(a,b,f){const g=[];for(let n=0;n<a.length;n++){var l=a[n];"number"===typeof l&&(l=b[l-1]);if("string"===typeof l)if("\n"===l)l={type:"input_end_row"},
f&&(l.align=f);else if(l=this.stringToFieldJson(l),!l)continue;g.push(l)}(a=g.length)&&!this.isInputKeyword(g[a-1].type)&&(a={type:"input_dummy"},f&&(a.align=f),g.push(a));return g}fieldFromJson(a){const b=d.fromJson$$module$build$src$core$field_registry(a);return!b&&a.alt?"string"===typeof a.alt?(a=this.stringToFieldJson(a.alt))?this.fieldFromJson(a):null:this.fieldFromJson(a.alt):b}inputFromJson(a,b){var f={LEFT:d.Align$$module$build$src$core$inputs$align.LEFT,RIGHT:d.Align$$module$build$src$core$inputs$align.RIGHT,
CENTRE:d.Align$$module$build$src$core$inputs$align.CENTRE,CENTER:d.Align$$module$build$src$core$inputs$align.CENTRE};let g;switch(a.type){case "input_value":g=this.appendValueInput(a.name);break;case "input_statement":g=this.appendStatementInput(a.name);break;case "input_dummy":g=this.appendDummyInput(a.name);break;case "input_end_row":g=this.appendEndRowInput(a.name);break;default:g=this.appendInputFromRegistry(a.type,a.name)}if(!g)return null;a.check&&g.setCheck(a.check);a.align&&(f=f[a.align.toUpperCase()],
void 0===f?console.warn(b+"Illegal align value: ",a.align):g.setAlign(f));return g}isInputKeyword(a){return"input_value"===a||"input_statement"===a||"input_dummy"===a||"input_end_row"===a||p(ba.INPUT,a)}stringToFieldJson(a){return(a=a.trim())?{type:"field_label",text:a}:null}moveInputBefore(a,b){if(a!==b){var f=-1,g=b?-1:this.inputList.length;for(let l=0,n;n=this.inputList[l];l++)if(n.name===a){if(f=l,-1!==g)break}else if(b&&n.name===b&&(g=l,-1!==f))break;if(-1===f)throw Error('Named input "'+a+'" not found.');
if(-1===g)throw Error('Reference input "'+b+'" not found.');this.moveNumberedInputBefore(f,g)}}moveNumberedInputBefore(a,b){if(a===b)throw Error("Can't move input to itself.");if(a>=this.inputList.length)throw RangeError("Input index "+a+" out of bounds.");if(b>this.inputList.length)throw RangeError("Reference input "+b+" out of bounds.");const f=this.inputList[a];this.inputList.splice(a,1);a<b&&b--;this.inputList.splice(b,0,f)}removeInput(a,b){for(let f=0,g;g=this.inputList[f];f++)if(g.name===a)return g instanceof
sb&&this.statementInputCount--,g.dispose(),this.inputList.splice(f,1),!0;if(b)return!1;throw Error("Input not found: "+a);}getInput(a){for(let b=0,f;f=this.inputList[b];b++)if(f.name===a)return f;return null}getInputTargetBlock(a){return(a=this.getInput(a))&&a.connection&&a.connection.targetBlock()}getCommentText(){let a,b;return null!=(b=null==(a=this.getIcon(Xa.COMMENT))?void 0:a.getText())?b:null}setCommentText(a){var b;let f;const g=null!=(f=null==(b=this.getIcon(Xa.COMMENT))?void 0:b.getText())?
f:null;if(g!==a){if(null!==a){b=this.getIcon(Xa.COMMENT);if(!b){b=t(ba.ICON,Xa.COMMENT.toString(),!1);if(!b)throw Error("No comment icon class is registered, so a comment cannot be set");b=new b(this);if(!Tn(b))throw Error("The class registered as a comment icon does not conform to the ICommentIcon interface");b=this.addIcon(b)}d.disable$$module$build$src$core$events$utils();b.setText(a);d.enable$$module$build$src$core$events$utils()}else this.removeIcon(Xa.COMMENT);aa(new (la(O.BLOCK_CHANGE))(this,
"comment",null,g,a))}}setWarningText(a,b){}setMutator(a){}addIcon(a){if(this.hasIcon(a.getType()))throw new Cl(a);this.icons.push(a);this.icons.sort((b,f)=>b.getWeight()-f.getWeight());return a}removeIcon(a){if(!this.hasIcon(a))return!1;let b;null==(b=this.getIcon(a))||b.dispose();this.icons=this.icons.filter(f=>!f.getType().equals(a));return!0}hasIcon(a){return this.icons.some(b=>b.getType().equals(a))}getIcon(a){return a instanceof Xa?this.icons.find(b=>b.getType().equals(a)):this.icons.find(b=>
b.getType().toString()===a)}getIcons(){return[...this.icons]}getRelativeToSurfaceXY(){return this.xy}moveBy(a,b,f){if(this.parentBlock_)throw Error("Block has parent");const g=new (la(O.BLOCK_MOVE))(this);f&&g.setReason(f);this.xy.translate(a,b);g.recordNew();aa(g)}makeConnection_(a){return new Ba(this,a)}allInputsFilled(a){void 0===a&&(a=!0);if(!a&&this.isShadow())return!1;for(let f=0,g;g=this.inputList[f];f++)if(g.connection){var b=g.connection.targetBlock();if(!b||!b.allInputsFilled(a))return!1}return(b=
this.getNextBlock())?b.allInputsFilled(a):!0}toDevString(){let a=this.type?'"'+this.type+'" block':"Block";this.id&&(a+=' (id="'+this.id+'")');return a}};Ac.COLLAPSED_INPUT_NAME="_TEMP_COLLAPSED_INPUT";Ac.COLLAPSED_FIELD_NAME="_TEMP_COLLAPSED_FIELD";var Bb=class{constructor(a,b,f,g){this.workspace=a;this.targetWorkspace=b;this.isFlyoutLabel=g;this.onMouseUpWrapper=null;this.height=this.width=0;this.cursorSvg=this.svgText=this.svgGroup=null;this.text=f.text;this.position=new fa(0,0);this.callbackKey=
f.callbackKey||f.callbackkey;this.cssClass=f["web-class"]||null;this.info=f}createDom(){var a=this.isFlyoutLabel?"blocklyFlyoutLabel":"blocklyFlyoutButton";this.cssClass&&(a+=" "+this.cssClass);this.svgGroup=T(J.G,{"class":a},this.workspace.getCanvas());let b;this.isFlyoutLabel||(b=T(J.RECT,{"class":"blocklyFlyoutButtonShadow",rx:Bb.BORDER_RADIUS,ry:Bb.BORDER_RADIUS,x:1,y:1},this.svgGroup));a=T(J.RECT,{"class":this.isFlyoutLabel?"blocklyFlyoutLabelBackground":"blocklyFlyoutButtonBackground",rx:Bb.BORDER_RADIUS,
ry:Bb.BORDER_RADIUS},this.svgGroup);const f=T(J.TEXT,{"class":this.isFlyoutLabel?"blocklyFlyoutLabelText":"blocklyText",x:0,y:0,"text-anchor":"middle"},this.svgGroup);var g=Ua(this.text);this.workspace.RTL&&(g+="‏");f.textContent=g;this.isFlyoutLabel&&(this.svgText=f,this.workspace.getThemeManager().subscribe(this.svgText,"flyoutForegroundColour","fill"));const l=Wb(f,"fontSize"),n=Wb(f,"fontWeight"),x=Wb(f,"fontFamily");this.width=Xf(f,l,n,x);g=Yf(g,l,n,x);this.height=g.height;if(!this.isFlyoutLabel){this.width+=
2*Bb.TEXT_MARGIN_X;this.height+=2*Bb.TEXT_MARGIN_Y;let B;null==(B=b)||B.setAttribute("width",String(this.width));let V;null==(V=b)||V.setAttribute("height",String(this.height))}a.setAttribute("width",String(this.width));a.setAttribute("height",String(this.height));f.setAttribute("x",String(this.width/2));f.setAttribute("y",String(this.height/2-g.height/2+g.baseline));this.updateTransform();this.onMouseUpWrapper=ta(this.svgGroup,"pointerup",this,this.onMouseUp);return this.svgGroup}show(){this.updateTransform();
this.svgGroup.setAttribute("display","block")}updateTransform(){this.svgGroup.setAttribute("transform","translate("+this.position.x+","+this.position.y+")")}moveTo(a,b){this.position.x=a;this.position.y=b;this.updateTransform()}isLabel(){return this.isFlyoutLabel}getPosition(){return this.position}getButtonText(){return this.text}getTargetWorkspace(){return this.targetWorkspace}getWorkspace(){return this.workspace}dispose(){this.onMouseUpWrapper&&Na(this.onMouseUpWrapper);this.svgGroup&&Ia(this.svgGroup);
this.svgText&&this.workspace.getThemeManager().unsubscribe(this.svgText)}setCursorSvg(a){a?this.svgGroup&&(this.svgGroup.appendChild(a),this.cursorSvg=a):this.cursorSvg=null}setMarkerSvg(){throw Error("Attempted to set a marker on a button.");}onMouseUp(a){(a=this.targetWorkspace.getGesture(a))&&a.cancel();this.isFlyoutLabel&&this.callbackKey?console.warn("Labels should not have callbacks. Label text: "+this.text):this.isFlyoutLabel||this.callbackKey&&this.targetWorkspace.getButtonCallback(this.callbackKey)?
this.isFlyoutLabel||(a=this.targetWorkspace.getButtonCallback(this.callbackKey))&&a(this):console.warn("Buttons should have callbacks. Button text: "+this.text)}};Bb.TEXT_MARGIN_X=5;Bb.TEXT_MARGIN_Y=2;Bb.BORDER_RADIUS=4;mc("\n.blocklyFlyoutButton {\n  fill: #888;\n  cursor: default;\n}\n\n.blocklyFlyoutButtonShadow {\n  fill: #666;\n}\n\n.blocklyFlyoutButton:hover {\n  fill: #aaa;\n}\n\n.blocklyFlyoutLabel {\n  cursor: default;\n}\n\n.blocklyFlyoutLabelBackground {\n  opacity: 0;\n}\n");var X=class{constructor(a,
b,f){this.wsCoordinate=null;if(!b)throw Error("Cannot create a node without a location.");this.type=a;this.isConnectionLocation=X.isConnectionType(a);this.location=b;this.processParams(f||null)}processParams(a){a&&a.wsCoordinate&&(this.wsCoordinate=a.wsCoordinate)}getLocation(){return this.location}getType(){return this.type}getWsCoordinate(){return this.wsCoordinate}isConnection(){return this.isConnectionLocation}findNextForInput(){var a=this.location.getParentInput();const b=a.getSourceBlock();
a=b.inputList.indexOf(a);for(a+=1;a<b.inputList.length;a++){const f=b.inputList[a],g=f.fieldRow;for(let l=0;l<g.length;l++){const n=g[l];if(n.isClickable()||X.NAVIGATE_ALL_FIELDS)return X.createFieldNode(n)}if(f.connection)return X.createInputNode(f)}return null}findNextForField(){var a=this.location,b=a.getParentInput();const f=a.getSourceBlock();if(!f)throw Error("The current AST location is not associated with a block");var g=f.inputList.indexOf(b);for(a=b.fieldRow.indexOf(a)+1;g<f.inputList.length;g++){b=
f.inputList[g];const l=b.fieldRow;for(;a<l.length;){if(l[a].isClickable()||X.NAVIGATE_ALL_FIELDS)return X.createFieldNode(l[a]);a++}a=0;if(b.connection)return X.createInputNode(b)}return null}findPrevForInput(){const a=this.location.getParentInput(),b=a.getSourceBlock();for(var f=b.inputList.indexOf(a);0<=f;f--){var g=b.inputList[f];if(g.connection&&g!==a)return X.createInputNode(g);g=g.fieldRow;for(let l=g.length-1;0<=l;l--){const n=g[l];if(n.isClickable()||X.NAVIGATE_ALL_FIELDS)return X.createFieldNode(n)}}return null}findPrevForField(){var a=
this.location;const b=a.getParentInput(),f=a.getSourceBlock();if(!f)throw Error("The current AST location is not associated with a block");var g=f.inputList.indexOf(b);for(a=b.fieldRow.indexOf(a)-1;0<=g;g--){var l=f.inputList[g];if(l.connection&&l!==b)return X.createInputNode(l);for(l=l.fieldRow;-1<a;){if(l[a].isClickable()||X.NAVIGATE_ALL_FIELDS)return X.createFieldNode(l[a]);a--}0<=g-1&&(a=f.inputList[g-1].fieldRow.length-1)}return null}navigateBetweenStacks(a){var b=this.getLocation();if(b.getSourceBlock){var f=
b.getSourceBlock();f&&(b=f)}if(!b||b.isDeadOrDying())return null;if(b.workspace.isFlyout)return this.navigateFlyoutContents(a);f=b.getRootBlock();b=f.workspace.getTopBlocks(!0);for(let g=0;g<b.length;g++)if(f.id===b[g].id)return a=g+(a?1:-1),-1===a||a===b.length?null:X.createStackNode(b[a]);throw Error("Couldn't find "+(a?"next":"previous")+" stack?!");}navigateFlyoutContents(a){let b;switch(this.getType()){case X.types.STACK:b=this.getLocation();var f=b.workspace.targetWorkspace;break;case X.types.BUTTON:b=
this.getLocation();f=b.getTargetWorkspace();break;default:return null}return(f=f.getFlyout())?(a=this.findNextLocationInFlyout(f.getContents(),b,a))?"button"===a.type&&a.button?X.createButtonNode(a.button):"block"===a.type&&a.block?X.createStackNode(a.block):null:null:null}findNextLocationInFlyout(a,b,f){const g=a.findIndex(l=>b instanceof Ac&&l.block===b||b instanceof Bb&&l.button===b?!0:!1);if(0>g)return null;f=f?g+1:g-1;return-1===f||f===a.length?null:a[f]}findTopASTNodeForBlock(a){const b=nf(a);
return b?X.createConnectionNode(b):X.createBlockNode(a)}getOutAstNodeForBlock(a){if(!a)return null;a=a.getTopStackBlock();const b=nf(a);return b&&b.targetConnection&&b.targetConnection.getParentInput()?X.createInputNode(b.targetConnection.getParentInput()):X.createStackNode(a)}findFirstFieldOrInput(a){a=a.inputList;for(let b=0;b<a.length;b++){const f=a[b],g=f.fieldRow;for(let l=0;l<g.length;l++){const n=g[l];if(n.isClickable()||X.NAVIGATE_ALL_FIELDS)return X.createFieldNode(n)}if(f.connection)return X.createInputNode(f)}return null}getSourceBlock(){return this.getType()===
X.types.BLOCK?this.getLocation():this.getType()===X.types.STACK?this.getLocation():this.getType()===X.types.WORKSPACE?null:this.getType()===X.types.BUTTON?null:this.getLocation().getSourceBlock()}next(){switch(this.type){case X.types.STACK:return this.navigateBetweenStacks(!0);case X.types.OUTPUT:return X.createBlockNode(this.location.getSourceBlock());case X.types.FIELD:return this.findNextForField();case X.types.INPUT:return this.findNextForInput();case X.types.BLOCK:const a=this.location.nextConnection;
if(!a)break;return X.createConnectionNode(a);case X.types.PREVIOUS:return X.createBlockNode(this.location.getSourceBlock());case X.types.NEXT:return X.createConnectionNode(this.location.targetConnection);case X.types.BUTTON:return this.navigateFlyoutContents(!0)}return null}in(){switch(this.type){case X.types.WORKSPACE:const a=this.location.getTopBlocks(!0);if(0<a.length)return X.createStackNode(a[0]);break;case X.types.STACK:return this.findTopASTNodeForBlock(this.location);case X.types.BLOCK:return this.findFirstFieldOrInput(this.location);
case X.types.INPUT:return X.createConnectionNode(this.location.targetConnection)}return null}prev(){switch(this.type){case X.types.STACK:return this.navigateBetweenStacks(!1);case X.types.FIELD:return this.findPrevForField();case X.types.INPUT:return this.findPrevForInput();case X.types.BLOCK:var a=nf(this.location);if(!a)break;return X.createConnectionNode(a);case X.types.PREVIOUS:if((a=this.location.targetConnection)&&!a.getParentInput())return X.createConnectionNode(a);break;case X.types.NEXT:return X.createBlockNode(this.location.getSourceBlock());
case X.types.BUTTON:return this.navigateFlyoutContents(!1)}return null}out(){switch(this.type){case X.types.STACK:var a=this.location,b=a.getRelativeToSurfaceXY();b=new fa(b.x,b.y+X.DEFAULT_OFFSET_Y);return X.createWorkspaceNode(a.workspace,b);case X.types.OUTPUT:return a=this.location,(b=a.targetConnection)?X.createConnectionNode(b):X.createStackNode(a.getSourceBlock());case X.types.FIELD:a=this.location.getSourceBlock();if(!a)throw Error("The current AST location is not associated with a block");
return X.createBlockNode(a);case X.types.INPUT:return X.createBlockNode(this.location.getSourceBlock());case X.types.BLOCK:return this.getOutAstNodeForBlock(this.location);case X.types.PREVIOUS:return this.getOutAstNodeForBlock(this.location.getSourceBlock());case X.types.NEXT:return this.getOutAstNodeForBlock(this.location.getSourceBlock())}return null}static isConnectionType(a){switch(a){case X.types.PREVIOUS:case X.types.NEXT:case X.types.INPUT:case X.types.OUTPUT:return!0}return!1}static createFieldNode(a){return a?
new X(X.types.FIELD,a):null}static createConnectionNode(a){if(!a)return null;const b=a.type;return b===oa.INPUT_VALUE||b===oa.NEXT_STATEMENT&&a.getParentInput()?X.createInputNode(a.getParentInput()):b===oa.NEXT_STATEMENT?new X(X.types.NEXT,a):b===oa.OUTPUT_VALUE?new X(X.types.OUTPUT,a):b===oa.PREVIOUS_STATEMENT?new X(X.types.PREVIOUS,a):null}static createInputNode(a){return a&&a.connection?new X(X.types.INPUT,a.connection):null}static createBlockNode(a){return a?new X(X.types.BLOCK,a):null}static createStackNode(a){return a?
new X(X.types.STACK,a):null}static createButtonNode(a){return a?new X(X.types.BUTTON,a):null}static createWorkspaceNode(a,b){return b&&a?new X(X.types.WORKSPACE,a,{wsCoordinate:b}):null}static createTopNode(a){const b=nf(a);return b?X.createConnectionNode(b):X.createBlockNode(a)}};X.NAVIGATE_ALL_FIELDS=!1;X.DEFAULT_OFFSET_Y=-20;(function(a){a=a.types||(a.types={});a.FIELD="field";a.BLOCK="block";a.INPUT="input";a.OUTPUT="output";a.NEXT="next";a.PREVIOUS="previous";a.STACK="stack";a.WORKSPACE="workspace";
a.BUTTON="button"})(X||={});var Gh=class extends Eb{constructor(a,b,f,g){let l=a?a.workspace.id:void 0;g&&g.getType()===X.types.WORKSPACE&&(l=g.getLocation().id);super(l);this.type=O.MARKER_MOVE;this.blockId=null==a?void 0:a.id;this.oldNode=f||void 0;this.newNode=g;this.isCursor=b}toJson(){const a=super.toJson();if(void 0===this.isCursor)throw Error("Whether this is a cursor event or not is undefined. Either pass a value to the constructor, or call fromJson");if(!this.newNode)throw Error("The new node is undefined. Either pass a node to the constructor, or call fromJson");
a.isCursor=this.isCursor;a.blockId=this.blockId;a.oldNode=this.oldNode;a.newNode=this.newNode;return a}static fromJson(a,b,f){b=super.fromJson(a,b,null!=f?f:new Gh);b.isCursor=a.isCursor;b.blockId=a.blockId;b.oldNode=a.oldNode;b.newNode=a.newNode;return b}};e(ba.EVENT,O.MARKER_MOVE,Gh);var Hh=class{constructor(a,b,f){this.workspace=a;this.marker=f;this.markerSvgRect_=this.markerSvgLine_=this.markerInput_=this.markerBlock_=this.svgGroup_=this.markerSvg_=this.currentMarkerSvg=this.parent=null;this.constants_=
b;a=this.isCursor()?this.constants_.CURSOR_COLOUR:this.constants_.MARKER_COLOUR;this.colour_=f.colour||a}getSvgRoot(){return this.svgGroup_}getMarker(){return this.marker}isCursor(){return"cursor"===this.marker.type}createDom(){const a=this.isCursor()?"blocklyCursor":"blocklyMarker";this.svgGroup_=T(J.G,{"class":a});this.createDomInternal_();return this.svgGroup_}setParent_(a){this.isCursor()?(this.parent&&this.parent.setCursorSvg(null),a.setCursorSvg(this.getSvgRoot())):(this.parent&&this.parent.setMarkerSvg(null),
a.setMarkerSvg(this.getSvgRoot()));this.parent=a}draw(a,b){if(b){this.constants_=this.workspace.getRenderer().getConstants();var f=this.isCursor()?this.constants_.CURSOR_COLOUR:this.constants_.MARKER_COLOUR;this.colour_=this.marker.colour||f;this.applyColour_(b);this.showAtLocation_(b);this.fireMarkerEvent(a,b);a=this.currentMarkerSvg.childNodes[0];void 0!==a&&a.beginElement&&a.beginElement()}else this.hide()}showAtLocation_(a){const b=a.getLocation().type;a.getType()===X.types.BLOCK?this.showWithBlock_(a):
a.getType()===X.types.OUTPUT?this.showWithOutput_(a):b===oa.INPUT_VALUE?this.showWithInput_(a):b===oa.NEXT_STATEMENT?this.showWithNext_(a):a.getType()===X.types.PREVIOUS?this.showWithPrevious_(a):a.getType()===X.types.FIELD?this.showWithField_(a):a.getType()===X.types.WORKSPACE?this.showWithCoordinates_(a):a.getType()===X.types.STACK?this.showWithStack_(a):a.getType()===X.types.BUTTON&&this.showWithButton_(a)}showWithBlockPrevOutput(a){a=a.getSourceBlock();const b=a.width;var f=a.height,g=.75*f;const l=
this.constants_.CURSOR_BLOCK_PADDING;a.previousConnection?(f=this.constants_.shapeFor(a.previousConnection),this.positionPrevious_(b,l,g,f)):a.outputConnection?(g=this.constants_.shapeFor(a.outputConnection),this.positionOutput_(b,f,g)):this.positionBlock_(b,l,g);this.setParent_(a);this.showCurrent_()}showWithBlock_(a){this.showWithBlockPrevOutput(a)}showWithPrevious_(a){this.showWithBlockPrevOutput(a)}showWithOutput_(a){this.showWithBlockPrevOutput(a)}showWithCoordinates_(a){var b=a.getWsCoordinate();
a=b.x;b=b.y;this.workspace.RTL&&(a-=this.constants_.CURSOR_WS_WIDTH);this.positionLine_(a,b,this.constants_.CURSOR_WS_WIDTH);this.setParent_(this.workspace);this.showCurrent_()}showWithField_(a){a=a.getLocation();const b=a.getSize().width,f=a.getSize().height;this.positionRect_(0,0,b,f);this.setParent_(a);this.showCurrent_()}showWithInput_(a){a=a.getLocation();const b=a.getSourceBlock();this.positionInput_(a);this.setParent_(b);this.showCurrent_()}showWithNext_(a){var b=a.getLocation();a=b.getSourceBlock();
let f=0;b=b.getOffsetInBlock().y;const g=a.getHeightWidth().width;this.workspace.RTL&&(f=-g);this.positionLine_(f,b,g);this.setParent_(a);this.showCurrent_()}showWithStack_(a){a=a.getLocation();var b=a.getHeightWidth();const f=b.width+this.constants_.CURSOR_STACK_PADDING;b=b.height+this.constants_.CURSOR_STACK_PADDING;const g=-this.constants_.CURSOR_STACK_PADDING/2,l=-this.constants_.CURSOR_STACK_PADDING/2;let n=g;this.workspace.RTL&&(n=-(f+g));this.positionRect_(n,l,f,b);this.setParent_(a);this.showCurrent_()}showWithButton_(a){a=
a.getLocation();const b=a.width+this.constants_.CURSOR_STACK_PADDING,f=a.height+this.constants_.CURSOR_STACK_PADDING,g=-this.constants_.CURSOR_STACK_PADDING/2,l=-this.constants_.CURSOR_STACK_PADDING/2;let n=g;this.workspace.RTL&&(n=-(b+g));this.positionRect_(n,l,b,f);this.setParent_(a);this.showCurrent_()}showCurrent_(){this.hide();this.currentMarkerSvg&&(this.currentMarkerSvg.style.display="")}positionBlock_(a,b,f){a=Oa(-b,f)+pa("V",-b)+pa("H",a+2*b)+pa("V",f);if(!this.markerBlock_)throw Error("createDom should be called before positioning the marker");
this.markerBlock_.setAttribute("d",a);this.workspace.RTL&&this.flipRtl(this.markerBlock_);this.currentMarkerSvg=this.markerBlock_}positionInput_(a){const b=a.getOffsetInBlock().x,f=a.getOffsetInBlock().y;a=Za(0,0)+this.constants_.shapeFor(a).pathDown;this.markerInput_.setAttribute("d",a);this.markerInput_.setAttribute("transform","translate("+b+","+f+")"+(this.workspace.RTL?" scale(-1 1)":""));this.currentMarkerSvg=this.markerInput_}positionLine_(a,b,f){if(!this.markerSvgLine_)throw Error("createDom should be called before positioning the line");
this.markerSvgLine_.setAttribute("x",`${a}`);this.markerSvgLine_.setAttribute("y",`${b}`);this.markerSvgLine_.setAttribute("width",`${f}`);this.currentMarkerSvg=this.markerSvgLine_}positionOutput_(a,b,f){if(!this.markerBlock_)throw Error("createDom should be called before positioning the output");a=Oa(a,0)+pa("h",-(a-f.width))+pa("v",this.constants_.TAB_OFFSET_FROM_TOP)+f.pathDown+pa("V",b)+pa("H",a);this.markerBlock_.setAttribute("d",a);this.workspace.RTL&&this.flipRtl(this.markerBlock_);this.currentMarkerSvg=
this.markerBlock_}positionPrevious_(a,b,f,g){if(!this.markerBlock_)throw Error("createDom should be called before positioning the previous connection marker");a=Oa(-b,f)+pa("V",-b)+pa("H",this.constants_.NOTCH_OFFSET_LEFT)+g.pathLeft+pa("H",a+2*b)+pa("V",f);this.markerBlock_.setAttribute("d",a);this.workspace.RTL&&this.flipRtl(this.markerBlock_);this.currentMarkerSvg=this.markerBlock_}positionRect_(a,b,f,g){if(!this.markerSvgRect_)throw Error("createDom should be called before positioning the rect");
this.markerSvgRect_.setAttribute("x",`${a}`);this.markerSvgRect_.setAttribute("y",`${b}`);this.markerSvgRect_.setAttribute("width",`${f}`);this.markerSvgRect_.setAttribute("height",`${g}`);this.currentMarkerSvg=this.markerSvgRect_}flipRtl(a){a.setAttribute("transform","scale(-1 1)")}hide(){if(!(this.markerSvgLine_&&this.markerSvgRect_&&this.markerInput_&&this.markerBlock_))throw Error("createDom should be called before hiding the marker");this.markerSvgLine_.style.display="none";this.markerSvgRect_.style.display=
"none";this.markerInput_.style.display="none";this.markerBlock_.style.display="none"}fireMarkerEvent(a,b){const f=b.getSourceBlock();a=new (la(O.MARKER_MOVE))(f,this.isCursor(),a,b);aa(a)}getBlinkProperties_(){return{attributeType:"XML",attributeName:"fill",dur:"1s",values:this.colour_+";transparent;transparent;",repeatCount:"indefinite"}}createDomInternal_(){this.markerSvg_=T(J.G,{width:this.constants_.CURSOR_WS_WIDTH,height:this.constants_.WS_CURSOR_HEIGHT},this.svgGroup_);this.markerSvgLine_=T(J.RECT,
{width:this.constants_.CURSOR_WS_WIDTH,height:this.constants_.WS_CURSOR_HEIGHT},this.markerSvg_);this.markerSvgRect_=T(J.RECT,{"class":"blocklyVerticalMarker",rx:10,ry:10},this.markerSvg_);this.markerInput_=T(J.PATH,{transform:""},this.markerSvg_);this.markerBlock_=T(J.PATH,{transform:"",fill:"none","stroke-width":this.constants_.CURSOR_STROKE_WIDTH},this.markerSvg_);this.hide();if(this.isCursor()){const a=this.getBlinkProperties_();T(J.ANIMATE,a,this.markerSvgLine_);T(J.ANIMATE,a,this.markerInput_);
T(J.ANIMATE,Object.assign({},a,{attributeName:"stroke"}),this.markerBlock_)}return this.markerSvg_}applyColour_(a){if(!(this.markerSvgLine_&&this.markerSvgRect_&&this.markerInput_&&this.markerBlock_))throw Error("createDom should be called before applying color to the markerj");this.markerSvgLine_.setAttribute("fill",this.colour_);this.markerSvgRect_.setAttribute("stroke",this.colour_);this.markerInput_.setAttribute("fill",this.colour_);this.markerBlock_.setAttribute("stroke",this.colour_);this.isCursor()&&
(a=this.colour_+";transparent;transparent;",this.markerSvgLine_.firstElementChild.setAttribute("values",a),this.markerInput_.firstElementChild.setAttribute("values",a),this.markerBlock_.firstElementChild.setAttribute("values",a))}dispose(){this.svgGroup_&&Ia(this.svgGroup_)}},Gf=class{constructor(a,b,f){this.markerSvg=this.cursorSvg=null;this.connectionHighlights=new WeakMap;this.highlightOffsets=new WeakMap;this.constants=f;this.style=b;this.svgRoot=a;this.svgPath=T(J.PATH,{"class":"blocklyPath"},
this.svgRoot)}setPath(a){this.svgPath.setAttribute("d",a)}flipRTL(){this.svgPath.setAttribute("transform","scale(-1 1)")}setCursorSvg(a){a?(this.svgRoot.appendChild(a),this.cursorSvg=a):this.cursorSvg=null}setMarkerSvg(a){a?(this.cursorSvg?this.svgRoot.insertBefore(a,this.cursorSvg):this.svgRoot.appendChild(a),this.markerSvg=a):this.markerSvg=null}applyColour(a){this.svgPath.setAttribute("stroke",this.style.colourTertiary);this.svgPath.setAttribute("fill",this.style.colourPrimary);this.updateShadow_(a.isShadow());
this.updateDisabled_(!a.isEnabled()||a.getInheritedDisabled())}setStyle(a){this.style=a}setClass_(a,b){a&&(b?sa(this.svgRoot,a):Ma(this.svgRoot,a))}updateHighlighted(a){a?this.svgPath.setAttribute("filter","url(#"+this.constants.embossFilterId+")"):this.svgPath.setAttribute("filter","none")}updateShadow_(a){a&&(this.svgPath.setAttribute("stroke","none"),this.svgPath.setAttribute("fill",this.style.colourSecondary))}updateDisabled_(a){this.setClass_("blocklyDisabled",a);a&&this.svgPath.setAttribute("fill",
"url(#"+this.constants.disabledPatternId+")")}updateSelected(a){this.setClass_("blocklySelected",a)}updateDraggingDelete(a){this.setClass_("blocklyDraggingDelete",a)}updateInsertionMarker(a){this.setClass_("blocklyInsertionMarker",a)}updateMovable(a){this.setClass_("blocklyDraggable",a)}updateReplacementFade(a){this.setClass_("blocklyReplaceable",a)}updateShapeForInputHighlight(a,b){}addConnectionHighlight(a,b,f,g){if(this.connectionHighlights.has(a)){if(this.currentHighlightMatchesNew(a,b,f))return;
this.removeConnectionHighlight(a)}b=T(J.PATH,{"class":"blocklyHighlightedConnectionPath",d:b,transform:`translate(${f.x}, ${f.y})`+(g?" scale(-1 1)":"")},this.svgRoot);this.connectionHighlights.set(a,b)}currentHighlightMatchesNew(a,b,f){let g;const l=null==(g=this.connectionHighlights.get(a))?void 0:g.getAttribute("d");a=this.highlightOffsets.get(a);return l===b&&fa.equals(a,f)}removeConnectionHighlight(a){const b=this.connectionHighlights.get(a);b&&(Ia(b),this.connectionHighlights.delete(a))}},Qb=
class{constructor(a){this.activeCandidate=this.lastMarker=this.lastOnStack=null;this.wouldDeleteBlock=!1;this.fadedBlock=this.highlightedBlock=this.markerConnection=null;d.setSelected$$module$build$src$core$common(a);this.topBlock=a;this.workspace=a.workspace;this.firstMarker=this.createMarkerBlock(this.topBlock);this.availableConnections=this.initAvailableConnections();this.lastOnStack&&(this.lastMarker=this.createMarkerBlock(this.lastOnStack.getSourceBlock()))}dispose(){this.availableConnections.length=
0;this.disposeInsertionMarker(this.firstMarker);this.disposeInsertionMarker(this.lastMarker)}updateAvailableConnections(){this.availableConnections=this.initAvailableConnections()}wouldConnectBlock(){return!!this.activeCandidate}applyConnections(){if(this.activeCandidate){d.disable$$module$build$src$core$events$utils();this.hidePreview();d.enable$$module$build$src$core$events$utils();var {local:a,closest:b}=this.activeCandidate;a.connect(b);var f=a.isSuperior()?b:a,g=this.topBlock.getRootBlock();
Lb().then(()=>{Wg(f.getSourceBlock());setTimeout(()=>{g.bringToFront()},0)})}}update(a,b){const f=this.getCandidate(a);if((this.wouldDeleteBlock=this.shouldDelete(!!f,b))||this.shouldUpdatePreviews(f,a))d.disable$$module$build$src$core$events$utils(),this.maybeHidePreview(f),this.maybeShowPreview(f),d.enable$$module$build$src$core$events$utils()}createMarkerBlock(a){d.disable$$module$build$src$core$events$utils();let b;try{const f=vb(a,{addCoordinates:!1,addInputBlocks:!1,addNextBlocks:!1,doFullSerialization:!1});
if(!f)throw Error(`Failed to serialize source block. ${a.toDevString()}`);b=pc(f,this.workspace);for(const g of b.getDescendants(!1))g.setInsertionMarker(!0);b.initSvg();b.getSvgRoot().setAttribute("visibility","hidden")}finally{d.enable$$module$build$src$core$events$utils()}return b}initAvailableConnections(){const a=this.topBlock.getConnections_(!1),b=this.topBlock.lastConnectionInStack(!0);b&&b!==this.topBlock.nextConnection&&(a.push(b),this.lastOnStack=b);return a}shouldUpdatePreviews(a,b){if(!a)return!!this.activeCandidate;
if(!this.activeCandidate)return!0;const {local:f,closest:g}=this.activeCandidate;if(g===a.closest&&f===a.local)return!1;const l=f.x+b.x-g.x;b=f.y+b.y-g.y;return a.radius<Math.sqrt(l*l+b*b)-d.config$$module$build$src$core$config.currentConnectionPreference}getCandidate(a){this.markerConnection&&this.markerConnection.isConnected()||this.updateAvailableConnections();let b=this.getStartRadius(),f=null;for(let g=0;g<this.availableConnections.length;g++){const l=this.availableConnections[g],n=l.closest(b,
a);n.connection&&(f={closest:n.connection,local:l,radius:n.radius},b=n.radius)}return f}getStartRadius(){return this.activeCandidate?d.config$$module$build$src$core$config.connectingSnapRadius:d.config$$module$build$src$core$config.snapRadius}shouldDelete(a,b){return b&&this.workspace.getComponentManager().hasCapability(b.id,Qa.Capability.DELETE_AREA)?b.wouldDelete(this.topBlock):!1}maybeShowPreview(a){if(!this.wouldDeleteBlock&&a){var b=a.closest,f;b===(null==(f=this.activeCandidate)?void 0:f.closest)||
b.getSourceBlock().isInsertionMarker()?console.log("Trying to connect to an insertion marker"):(this.activeCandidate=a,this.showPreview(this.activeCandidate))}}showPreview(a){const b=this.workspace.getRenderer();switch(b.getConnectionPreviewMethod(a.closest,a.local,this.topBlock)){case Qb.PREVIEW_TYPE.INPUT_OUTLINE:this.showInsertionInputOutline(a);break;case Qb.PREVIEW_TYPE.INSERTION_MARKER:this.showInsertionMarker(a);break;case Qb.PREVIEW_TYPE.REPLACEMENT_FADE:this.showReplacementFade(a)}b.shouldHighlightConnection(a.closest)&&
a.closest.highlight()}maybeHidePreview(a){if(!a)this.hidePreview();else if(this.activeCandidate){const b=this.activeCandidate.local!==a.local;(this.activeCandidate.closest!==a.closest||b||this.wouldDeleteBlock)&&this.hidePreview()}this.activeCandidate=this.markerConnection=null}hidePreview(){let a;const b=null==(a=this.activeCandidate)?void 0:a.closest;b&&b.targetBlock()&&this.workspace.getRenderer().shouldHighlightConnection(b)&&b.unhighlight();this.hideReplacementFade();this.hideInsertionInputOutline();
this.hideInsertionMarker()}showInsertionMarker(a){const {local:b,closest:f}=a;let g=(a=this.lastOnStack&&b===this.lastOnStack)?this.lastMarker:this.firstMarker;if(!g)throw Error("Cannot show the insertion marker because there is no insertion marker block");let l;try{l=g.getMatchingConnection(b.getSourceBlock(),b)}catch(V){a&&this.lastOnStack?(this.disposeInsertionMarker(this.lastMarker),g=this.lastMarker=this.createMarkerBlock(this.lastOnStack.getSourceBlock())):(this.disposeInsertionMarker(this.firstMarker),
g=this.firstMarker=this.createMarkerBlock(this.topBlock));if(!g)throw Error("Cannot show the insertion marker because there is no insertion marker block");l=g.getMatchingConnection(b.getSourceBlock(),b)}if(!l)throw Error("Cannot show the insertion marker because there is no associated connection");if(l===this.markerConnection)throw Error("Made it to showInsertionMarker_ even though the marker isn't changing");g.queueRender();oc();l.connect(f);const n={x:f.x-l.x,y:f.y-l.y},x=l.getOffsetInBlock().clone(),
B=l;Lb().then(()=>{let V;null==(V=g)||V.positionNearConnection(B,n,x);let na;null==(na=g)||na.getSvgRoot().setAttribute("visibility","visible")});this.markerConnection=l}hideInsertionMarker(){if(this.markerConnection){var a=this.markerConnection,b=a.getSourceBlock(),f=b.outputConnection,g;if((null==(g=b.previousConnection)?0:g.targetConnection)||(null==f?0:f.targetConnection))b.unplug(!0);else{let l;null==(l=a.targetBlock())||l.unplug(!1)}if(a.targetConnection)throw Error("markerConnection still connected at the end of disconnectInsertionMarker");
this.markerConnection=null;(a=b.getSvgRoot())&&a.setAttribute("visibility","hidden")}}showInsertionInputOutline(a){a=a.closest;this.highlightedBlock=a.getSourceBlock();this.highlightedBlock.highlightShapeForInput(a,!0)}hideInsertionInputOutline(){if(this.highlightedBlock){if(!this.activeCandidate)throw Error("Cannot hide the insertion marker outline because there is no active candidate");this.highlightedBlock.highlightShapeForInput(this.activeCandidate.closest,!1);this.highlightedBlock=null}}showReplacementFade(a){this.fadedBlock=
a.closest.targetBlock();if(!this.fadedBlock)throw Error("Cannot show the replacement fade because the closest connection does not have a target block");this.fadedBlock.fadeForReplacement(!0)}hideReplacementFade(){this.fadedBlock&&(this.fadedBlock.fadeForReplacement(!1),this.fadedBlock=null)}getInsertionMarkers(){const a=[];this.firstMarker&&a.push(this.firstMarker);this.lastMarker&&a.push(this.lastMarker);return a}disposeInsertionMarker(a){if(a){d.disable$$module$build$src$core$events$utils();try{a.dispose()}finally{d.enable$$module$build$src$core$events$utils()}}}};
(function(a){a=a.PREVIEW_TYPE||(a.PREVIEW_TYPE={});a[a.INSERTION_MARKER=0]="INSERTION_MARKER";a[a.INPUT_OUTLINE=1]="INPUT_OUTLINE";a[a.REPLACEMENT_FADE=2]="REPLACEMENT_FADE"})(Qb||={});var Hf=class{constructor(a){this.overrides=null;this.name=a}getClassName(){return this.name+"-renderer"}init(a,b){this.constants_=this.makeConstants_();b&&(this.overrides=b,Object.assign(this.constants_,b));this.constants_.setTheme(a);this.constants_.init()}createDom(a,b){this.constants_.createDom(a,this.name+"-"+b.name,
"."+this.getClassName()+"."+b.getClassName())}refreshDom(a,b){const f=this.getConstants();f.dispose();this.constants_=this.makeConstants_();this.overrides&&Object.assign(this.constants_,this.overrides);this.constants_.randomIdentifier=f.randomIdentifier;this.constants_.setTheme(b);this.constants_.init();this.createDom(a,b)}dispose(){this.constants_&&this.constants_.dispose()}makeConstants_(){return new Ef}makeRenderInfo_(a){return new ue(this,a)}makeDrawer_(a,b){return new Ff(a,b)}makeMarkerDrawer(a,
b){return new Hh(a,this.getConstants(),b)}makePathObject(a,b){return new Gf(a,b,this.constants_)}getConstants(){return this.constants_}shouldHighlightConnection(a){return!0}orphanCanConnectAtEnd(a,b,f){return!!Ba.getConnectionForOrphanedConnection(a,f===oa.OUTPUT_VALUE?b.outputConnection:b.previousConnection)}getConnectionPreviewMethod(a,b,f){L("getConnectionPreviewMethod","v10","v12","an IConnectionPreviewer, if it fulfills your use case.");return b.type===oa.OUTPUT_VALUE||b.type===oa.PREVIOUS_STATEMENT?
!a.isConnected()||this.orphanCanConnectAtEnd(f,a.targetBlock(),b.type)?Qb.PREVIEW_TYPE.INSERTION_MARKER:Qb.PREVIEW_TYPE.REPLACEMENT_FADE:Qb.PREVIEW_TYPE.INSERTION_MARKER}render(a){const b=this.makeRenderInfo_(a);b.measure();this.makeDrawer_(a,b).draw()}},Ga={};Ga.BottomRow=zh;Ga.Connection=jc;Ga.ConstantProvider=Ef;Ga.Drawer=Ff;Ga.ExternalValueInput=Df;Ga.Field=Ad;Ga.Hat=Ah;Ga.Icon=Gl;Ga.InRowSpacer=rb;Ga.InlineInput=Bh;Ga.InputConnection=zc;Ga.InputRow=Ch;Ga.JaggedEdge=Hl;Ga.MarkerSvg=Hh;Ga.Measurable=
Ob;Ga.NextConnection=Il;Ga.OutputConnection=Jl;Ga.PathObject=Gf;Ga.PreviousConnection=Kl;Ga.RenderInfo=ue;Ga.Renderer=Hf;Ga.RoundCorner=se;Ga.Row=qe;Ga.SpacerRow=Dh;Ga.SquareCorner=te;Ga.StatementInput=re;Ga.TopRow=Eh;Ga.Types=G;Ga.init=pk;Ga.register=of;Ga.unregister=function(a){k(ba.RENDERER,a)};var Ll=class{constructor(a,b){this.workspace=a;this.theme=b;this.subscribedWorkspaces=[];this.componentDB=new Map}getTheme(){return this.theme}setTheme(a){var b=this.theme;this.theme=a;if(a=this.workspace.getInjectionDiv())(b&&=
b.getClassName())&&Ma(a,b),(b=this.theme.getClassName())&&sa(a,b);for(let f=0,g;g=this.subscribedWorkspaces[f];f++)g.refreshTheme();for(const [f,g]of this.componentDB)for(const l of g){a=l.element;b=l.propertyName;const n=this.theme&&this.theme.getComponentStyle(f);a.style.setProperty(b,n||"")}for(const f of this.subscribedWorkspaces)f.hideChaff()}subscribeWorkspace(a){this.subscribedWorkspaces.push(a)}unsubscribeWorkspace(a){if(!mb(this.subscribedWorkspaces,a))throw Error("Cannot unsubscribe a workspace that hasn't been subscribed.");
}subscribe(a,b,f){this.componentDB.has(b)||this.componentDB.set(b,[]);this.componentDB.get(b).push({element:a,propertyName:f});b=this.theme&&this.theme.getComponentStyle(b);a.style.setProperty(f,b||"")}unsubscribe(a){if(a)for(const [b,f]of this.componentDB){for(let g=f.length-1;0<=g;g--)f[g].element===a&&f.splice(g,1);f.length||this.componentDB.delete(b)}}dispose(){this.subscribedWorkspaces.length=0;this.componentDB.clear()}},Xc={CATEGORY_NAME:"VARIABLE_DYNAMIC"};Xc.flyoutCategory=dh;Xc.flyoutCategoryBlocks=
tk;Xc.onCreateVariableButtonClick_Colour=sk;Xc.onCreateVariableButtonClick_Number=rk;Xc.onCreateVariableButtonClick_String=qk;var Yc=[];Yc[oa.INPUT_VALUE]=oa.OUTPUT_VALUE;Yc[oa.OUTPUT_VALUE]=oa.INPUT_VALUE;Yc[oa.NEXT_STATEMENT]=oa.PREVIOUS_STATEMENT;Yc[oa.PREVIOUS_STATEMENT]=oa.NEXT_STATEMENT;var Ml=class{canConnect(a,b,f,g){return this.canConnectWithReason(a,b,f,g)===Ba.CAN_CONNECT}canConnectWithReason(a,b,f,g){const l=this.doSafetyChecks(a,b);return l!==Ba.CAN_CONNECT?l:this.doTypeChecks(a,b)?f&&
!this.doDragChecks(a,b,g||0)?Ba.REASON_DRAG_CHECKS_FAILED:Ba.CAN_CONNECT:Ba.REASON_CHECKS_FAILED}getErrorMessage(a,b,f){switch(a){case Ba.REASON_SELF_CONNECTION:return"Attempted to connect a block to itself.";case Ba.REASON_DIFFERENT_WORKSPACES:return"Blocks not on same workspace.";case Ba.REASON_WRONG_TYPE:return"Attempt to connect incompatible types.";case Ba.REASON_TARGET_NULL:return"Target connection is null.";case Ba.REASON_CHECKS_FAILED:return"Connection checks failed. "+(b+" expected "+b.getCheck()+
", found "+f.getCheck());case Ba.REASON_SHADOW_PARENT:return"Connecting non-shadow to shadow block.";case Ba.REASON_DRAG_CHECKS_FAILED:return"Drag checks failed.";case Ba.REASON_PREVIOUS_AND_OUTPUT:return"Block would have an output and a previous connection.";default:return"Unknown connection failure: this should never happen!"}}doSafetyChecks(a,b){if(!a||!b)return Ba.REASON_TARGET_NULL;let f,g,l;a.isSuperior()?(f=a.getSourceBlock(),g=b.getSourceBlock(),l=b):(g=a.getSourceBlock(),f=b.getSourceBlock(),
l=a,a=b);return f===g?Ba.REASON_SELF_CONNECTION:l.type!==Yc[a.type]?Ba.REASON_WRONG_TYPE:f.workspace!==g.workspace?Ba.REASON_DIFFERENT_WORKSPACES:f.isShadow()&&!g.isShadow()?Ba.REASON_SHADOW_PARENT:l.type===oa.OUTPUT_VALUE&&g.previousConnection&&g.previousConnection.isConnected()||l.type===oa.PREVIOUS_STATEMENT&&g.outputConnection&&g.outputConnection.isConnected()?Ba.REASON_PREVIOUS_AND_OUTPUT:Ba.CAN_CONNECT}doTypeChecks(a,b){a=a.getCheck();b=b.getCheck();if(!a||!b)return!0;for(let f=0;f<a.length;f++)if(b.includes(a[f]))return!0;
return!1}doDragChecks(a,b,f){if(a.distanceFrom(b)>f||b.getSourceBlock().isInsertionMarker())return!1;switch(b.type){case oa.PREVIOUS_STATEMENT:return this.canConnectToPrevious_(a,b);case oa.OUTPUT_VALUE:if(b.isConnected()&&!b.targetBlock().isInsertionMarker()||a.isConnected())return!1;break;case oa.INPUT_VALUE:if(b.isConnected()&&!b.targetBlock().isMovable()&&!b.targetBlock().isShadow())return!1;break;case oa.NEXT_STATEMENT:if(b.isConnected()&&!a.getSourceBlock().nextConnection&&!b.targetBlock().isShadow()&&
b.targetBlock().nextConnection||b.targetBlock()&&!b.targetBlock().isMovable()&&!b.targetBlock().isShadow())return!1;break;default:return!1}return ie.includes(b)?!1:!0}canConnectToPrevious_(a,b){if(a.targetConnection||ie.includes(b))return!1;if(!b.targetConnection)return!0;a=b.targetBlock();return a.isInsertionMarker()?!a.getPreviousBlock():!1}};e(ba.CONNECTION_CHECKER,Jb,Ml);var Ih=class extends me{constructor(a){super(a);this.type=O.VAR_DELETE;a&&(this.varType=a.type,this.varName=a.name)}toJson(){const a=
super.toJson();if(void 0===this.varType)throw Error("The var type is undefined. Either pass a variable to the constructor, or call fromJson");if(!this.varName)throw Error("The var name is undefined. Either pass a variable to the constructor, or call fromJson");a.varType=this.varType;a.varName=this.varName;return a}static fromJson(a,b,f){b=super.fromJson(a,b,null!=f?f:new Ih);b.varType=a.varType;b.varName=a.varName;return b}run(a){const b=this.getEventWorkspace_();if(!this.varId)throw Error("The var ID is undefined. Either pass a variable to the constructor, or call fromJson");
if(!this.varName)throw Error("The var name is undefined. Either pass a variable to the constructor, or call fromJson");a?b.deleteVariableById(this.varId):b.createVariable(this.varName,this.varType,this.varId)}};e(ba.EVENT,O.VAR_DELETE,Ih);var Jh=class extends me{constructor(a,b){super(a);this.type=O.VAR_RENAME;a&&(this.oldName=a.name,this.newName="undefined"===typeof b?"":b)}toJson(){const a=super.toJson();if(!this.oldName)throw Error("The old var name is undefined. Either pass a variable to the constructor, or call fromJson");
if(!this.newName)throw Error("The new var name is undefined. Either pass a value to the constructor, or call fromJson");a.oldName=this.oldName;a.newName=this.newName;return a}static fromJson(a,b,f){b=super.fromJson(a,b,null!=f?f:new Jh);b.oldName=a.oldName;b.newName=a.newName;return b}run(a){const b=this.getEventWorkspace_();if(!this.varId)throw Error("The var ID is undefined. Either pass a variable to the constructor, or call fromJson");if(!this.oldName)throw Error("The old var name is undefined. Either pass a variable to the constructor, or call fromJson");
if(!this.newName)throw Error("The new var name is undefined. Either pass a value to the constructor, or call fromJson");a?b.renameVariableById(this.varId,this.newName):b.renameVariableById(this.varId,this.oldName)}};e(ba.EVENT,O.VAR_RENAME,Jh);var Kh=class{constructor(a){this.workspace=a;this.variableMap=new Map}clear(){for(const a of this.variableMap.values())for(;0<a.length;)this.deleteVariable(a[0]);if(0!==this.variableMap.size)throw Error("Non-empty variable map");}renameVariable(a,b){if(a.name!==
b){var f=this.getVariable(b,a.type),g=this.workspace.getAllBlocks(!1),l=d.getGroup$$module$build$src$core$events$utils();l||d.setGroup$$module$build$src$core$events$utils(!0);try{f&&f.getId()!==a.getId()?this.renameVariableWithConflict(a,b,f,g):this.renameVariableAndUses(a,b,g)}finally{d.setGroup$$module$build$src$core$events$utils(l)}}}renameVariableById(a,b){const f=this.getVariableById(a);if(!f)throw Error("Tried to rename a variable that didn't exist. ID: "+a);this.renameVariable(f,b)}renameVariableAndUses(a,
b,f){aa(new (la(O.VAR_RENAME))(a,b));a.name=b;for(b=0;b<f.length;b++)f[b].updateVarName(a)}renameVariableWithConflict(a,b,f,g){const l=a.type;b!==f.name&&this.renameVariableAndUses(f,b,g);for(b=0;b<g.length;b++)g[b].renameVarById(a.getId(),f.getId());aa(new (la(O.VAR_DELETE))(a));mb(this.variableMap.get(l),a)}createVariable(a,b,f){var g=this.getVariable(a,b);if(g){if(f&&g.getId()!==f)throw Error('Variable "'+a+'" is already in use and its id is "'+g.getId()+'" which conflicts with the passed in id, "'+
f+'".');return g}if(f&&this.getVariableById(f))throw Error('Variable id, "'+f+'", is already in use.');g=f||da();b=b||"";g=new Sd(this.workspace,a,b,g);a=this.variableMap.get(b)||[];a.push(g);this.variableMap.delete(b);this.variableMap.set(b,a);aa(new (la(O.VAR_CREATE))(g));return g}deleteVariable(a){const b=a.getId(),f=this.variableMap.get(a.type);if(f)for(let g=0;g<f.length;g++)if(f[g].getId()===b){f.splice(g,1);aa(new (la(O.VAR_DELETE))(a));0===f.length&&this.variableMap.delete(a.type);break}}deleteVariableById(a){const b=
this.getVariableById(a);if(b){var f=b.name;const g=this.getVariableUsesById(a);for(let l=0,n;n=g[l];l++)if("procedures_defnoreturn"===n.type||"procedures_defreturn"===n.type){a=String(n.getFieldValue("NAME"));f=d.Msg$$module$build$src$core$msg.CANNOT_DELETE_VARIABLE_PROCEDURE.replace("%1",f).replace("%2",a);Se(f);return}1<g.length?(f=d.Msg$$module$build$src$core$msg.DELETE_VARIABLE_CONFIRMATION.replace("%1",String(g.length)).replace("%2",f),og(f,l=>{l&&b&&this.deleteVariableInternal(b,g)})):this.deleteVariableInternal(b,
g)}else console.warn("Can't delete non-existent variable: "+a)}deleteVariableInternal(a,b){const f=d.getGroup$$module$build$src$core$events$utils();f||d.setGroup$$module$build$src$core$events$utils(!0);try{for(let g=0;g<b.length;g++)b[g].dispose(!0);this.deleteVariable(a)}finally{d.setGroup$$module$build$src$core$events$utils(f)}}getVariable(a,b){if(b=this.variableMap.get(b||""))for(let f=0,g;g=b[f];f++)if(d.Names$$module$build$src$core$names.equals(g.name,a))return g;return null}getVariableById(a){for(const b of this.variableMap.values())for(const f of b)if(f.getId()===
a)return f;return null}getVariablesOfType(a){return(a=this.variableMap.get(a||""))?a.slice():[]}getVariableTypes(a){const b=new Set(this.variableMap.keys());if(a&&a.getPotentialVariableMap())for(const f of a.getPotentialVariableMap().variableMap.keys())b.add(f);b.has("")||b.add("");return Array.from(b.values())}getAllVariables(){let a=[];for(const b of this.variableMap.values())a=a.concat(b);return a}getAllVariableNames(){return Array.from(this.variableMap.values()).flat().map(a=>a.name)}getVariableUsesById(a){const b=
[],f=this.workspace.getAllBlocks(!1);for(let g=0;g<f.length;g++){const l=f[g].getVarModels();if(l)for(let n=0;n<l.length;n++)l[n].getId()===a&&b.push(f[g])}return b}},Cd=class{get isFlyout(){return this.internalIsFlyout}get isMutator(){return this.internalIsMutator}constructor(a){this.isClearing=this.internalIsMutator=this.internalIsFlyout=this.rendered=!1;this.MAX_UNDO=1024;this.connectionDBList=[];this.topBlocks=[];this.topComments=[];this.commentDB=new Map;this.listeners=[];this.undoStack_=[];
this.redoStack_=[];this.blockDB=new Map;this.typedBlocksDB=new Map;this.procedureMap=new Fl;this.potentialVariableMap=null;this.id=da();u(this);this.options=a||new zb({});this.RTL=!!this.options.RTL;this.horizontalLayout=!!this.options.horizontalLayout;this.toolboxPosition=this.options.toolboxPosition;this.connectionChecker=new (I(ba.CONNECTION_CHECKER,this.options,!0))(this);this.variableMap=new Kh(this)}dispose(){this.listeners.length=0;this.clear();w(this)}sortObjects(a,b){const f=Math.sin(ug(Cd.SCAN_ANGLE))*
(this.RTL?-1:1);a=a.getRelativeToSurfaceXY();b=b.getRelativeToSurfaceXY();return a.y+f*a.x-(b.y+f*b.x)}addTopBlock(a){this.topBlocks.push(a)}removeTopBlock(a){if(!mb(this.topBlocks,a))throw Error("Block not present in workspace's list of top-most blocks.");}getTopBlocks(a=!1){const b=[].concat(this.topBlocks);a&&1<b.length&&b.sort(this.sortObjects.bind(this));return b}addTypedBlock(a){this.typedBlocksDB.has(a.type)||this.typedBlocksDB.set(a.type,[]);this.typedBlocksDB.get(a.type).push(a)}removeTypedBlock(a){mb(this.typedBlocksDB.get(a.type),
a);this.typedBlocksDB.get(a.type).length||this.typedBlocksDB.delete(a.type)}getBlocksByType(a,b=!1){if(!this.typedBlocksDB.has(a))return[];a=this.typedBlocksDB.get(a).slice(0);b&&a&&1<a.length&&a.sort(this.sortObjects.bind(this));return a.filter(f=>!f.isInsertionMarker())}addTopComment(a){this.topComments.push(a);this.commentDB.has(a.id)&&console.warn('Overriding an existing comment on this workspace, with id "'+a.id+'"');this.commentDB.set(a.id,a)}removeTopComment(a){if(!mb(this.topComments,a))throw Error("Comment not present in workspace's list of top-most comments.");
this.commentDB.delete(a.id)}getTopComments(a=!1){const b=[].concat(this.topComments);a&&1<b.length&&b.sort(this.sortObjects.bind(this));return b}getAllBlocks(a=!1){if(a){var b=this.getTopBlocks(!0);a=[];for(let f=0;f<b.length;f++)a.push(...b[f].getDescendants(!0))}else for(a=this.getTopBlocks(!1),b=0;b<a.length;b++)a.push(...a[b].getChildren(!1));return a.filter(f=>!f.isInsertionMarker())}clear(){this.isClearing=!0;try{const a=d.getGroup$$module$build$src$core$events$utils();for(a||d.setGroup$$module$build$src$core$events$utils(!0);this.topBlocks.length;)this.topBlocks[0].dispose(!1);
for(;this.topComments.length;)this.topComments[this.topComments.length-1].dispose();d.setGroup$$module$build$src$core$events$utils(a);this.variableMap.clear();this.potentialVariableMap&&this.potentialVariableMap.clear()}finally{this.isClearing=!1}}renameVariableById(a,b){this.variableMap.renameVariableById(a,b)}createVariable(a,b,f){return this.variableMap.createVariable(a,b,f)}getVariableUsesById(a){return this.variableMap.getVariableUsesById(a)}deleteVariableById(a){this.variableMap.deleteVariableById(a)}getVariable(a,
b){return this.variableMap.getVariable(a,b)}getVariableById(a){return this.variableMap.getVariableById(a)}getVariablesOfType(a){return this.variableMap.getVariablesOfType(a)}getVariableTypes(){return this.variableMap.getVariableTypes(this)}getAllVariables(){return this.variableMap.getAllVariables()}getAllVariableNames(){return this.variableMap.getAllVariableNames()}getWidth(){return 0}newBlock(a,b){throw Error("The implementation of newBlock should be monkey-patched in by blockly.ts");}newComment(a){throw Error("The implementation of newComment should be monkey-patched in by blockly.ts");
}remainingCapacity(){return isNaN(this.options.maxBlocks)?Infinity:this.options.maxBlocks-this.getAllBlocks(!1).length}remainingCapacityOfType(a){return this.options.maxInstances?(void 0!==this.options.maxInstances[a]?this.options.maxInstances[a]:Infinity)-this.getBlocksByType(a,!1).length:Infinity}isCapacityAvailable(a){if(!this.hasBlockLimits())return!0;let b=0;for(const f in a){if(a[f]>this.remainingCapacityOfType(f))return!1;b+=a[f]}return b>this.remainingCapacity()?!1:!0}hasBlockLimits(){return Infinity!==
this.options.maxBlocks||!!this.options.maxInstances}getUndoStack(){return this.undoStack_}getRedoStack(){return this.redoStack_}undo(a){var b=a?this.redoStack_:this.undoStack_,f=a?this.undoStack_:this.redoStack_;const g=b.pop();if(g){for(var l=[g];b.length&&g.group&&g.group===b[b.length-1].group;){const n=b.pop();n&&l.push(n)}for(b=0;b<l.length;b++)f.push(l[b]);d.setRecordUndo$$module$build$src$core$events$utils(!1);try{for(f=0;f<l.length;f++)l[f].run(a)}finally{d.setRecordUndo$$module$build$src$core$events$utils(!0)}}}clearUndo(){this.undoStack_.length=
0;this.redoStack_.length=0;ca()}addChangeListener(a){this.listeners.push(a);return a}removeChangeListener(a){mb(this.listeners,a)}fireChangeListener(a){if(a.recordUndo)for(this.undoStack_.push(a),this.redoStack_.length=0;this.undoStack_.length>this.MAX_UNDO&&0<=this.MAX_UNDO;)this.undoStack_.shift();for(let b=0;b<this.listeners.length;b++)(0,this.listeners[b])(a)}getBlockById(a){return this.blockDB.get(a)||null}setBlockById(a,b){this.blockDB.set(a,b)}removeBlockById(a){this.blockDB.delete(a)}getCommentById(a){let b;
return null!=(b=this.commentDB.get(a))?b:null}allInputsFilled(a){const b=this.getTopBlocks(!1);for(let f=0;f<b.length;f++)if(!b[f].allInputsFilled(a))return!1;return!0}getPotentialVariableMap(){return this.potentialVariableMap}createPotentialVariableMap(){this.potentialVariableMap=new Kh(this)}getVariableMap(){return this.variableMap}setVariableMap(a){this.variableMap=a}getProcedureMap(){return this.procedureMap}getRootWorkspace(){let a=null;const b=this.options.parentWorkspace;this.isFlyout?b&&b.options&&
(a=b.options.parentWorkspace):b&&(a=b);return a}static getById(a){return ua(a)}static getAll(){return va()}};Cd.SCAN_ANGLE=3;var Nl=class{constructor(a){this.parentWorkspace=a;this.sounds=new Map;this.lastSound=null;this.muted=!1}dispose(){this.sounds.clear()}load(a,b){if(a.length){try{var f=new globalThis.Audio}catch(l){return}for(let l=0;l<a.length;l++){const n=a[l],x=n.match(/\.(\w+)$/);if(x&&f.canPlayType("audio/"+x[1])){var g=new globalThis.Audio(n);break}}g&&this.sounds.set(b,g)}}preload(){for(const a of this.sounds.values()){a.volume=
.01;const b=a.play();void 0!==b?b.then(a.pause).catch(function(){}):a.pause();if(uf||kl)break}}play(a,b){if(!this.muted){var f=this.sounds.get(a);f?(a=new Date,null!==this.lastSound&&100>a.getTime()-this.lastSound.getTime()||(this.lastSound=a,f=uf||ph?f:f.cloneNode(),f.volume=void 0===b?1:b,f.play())):this.parentWorkspace&&this.parentWorkspace.getAudioManager().play(a,b)}}setMuted(a){this.muted=a}getMuted(){return this.muted}},ob=class extends Cd{constructor(a){super(a);this.resizeHandlerWrapper=
null;this.resizesEnabled=this.visible=this.rendered=!0;this.startScrollY=this.startScrollX=this.scrollY=this.scrollX=0;this.oldScale=this.scale=1;this.oldLeft=this.oldTop=0;this.inverseScreenCTM=this.targetWorkspace=this.dummyWheelListener=this.configureContextMenu=this.lastRecordedPageScroll=this.injectionDiv=this.currentGesture_=this.toolbox=this.flyout=this.scrollbar=this.trashcan=null;this.inverseScreenCTMDirty=!0;this.highlightedBlocks=[];this.toolboxCategoryCallbacks=new Map;this.flyoutButtonCallbacks=
new Map;this.cachedParentSvg=null;this.keyboardAccessibilityMode=!1;this.topBoundedElements=[];this.dragTargetAreas=[];this.zoomControls_=this.layerManager=null;this.metricsManager=new (I(ba.METRICS_MANAGER,a,!0))(this);this.getMetrics=a.getMetrics||this.metricsManager.getMetrics.bind(this.metricsManager);this.setMetrics=a.setMetrics||ob.setTopLevelWorkspaceMetrics;this.componentManager=new Qa;this.connectionDBList=zd.init(this.connectionChecker);this.audioManager=new Nl(a.parentWorkspace);this.grid=
this.options.gridPattern?new hh(this.options.gridPattern,a.gridOptions):null;this.markerManager=new oe(this);db&&qg&&this.registerToolboxCategoryCallback("VARIABLE",qg);Xc&&dh&&this.registerToolboxCategoryCallback("VARIABLE_DYNAMIC",dh);kb&&bh&&(this.registerToolboxCategoryCallback("PROCEDURE",bh),this.addChangeListener(mk));this.themeManager_=this.options.parentWorkspace?this.options.parentWorkspace.getThemeManager():new Ll(this,this.options.theme||Af);this.themeManager_.subscribeWorkspace(this);
let b;this.renderer=pk(this.options.renderer||"geras",this.getTheme(),null!=(b=this.options.rendererOverrides)?b:void 0);this.cachedParentSvgSize=new Aa(0,0)}getMarkerManager(){return this.markerManager}getMetricsManager(){return this.metricsManager}setMetricsManager(a){this.metricsManager=a;this.getMetrics=this.metricsManager.getMetrics.bind(this.metricsManager)}getComponentManager(){return this.componentManager}setCursorSvg(a){this.markerManager.setCursorSvg(a)}setMarkerSvg(a){this.markerManager.setMarkerSvg(a)}getMarker(a){return this.markerManager?
this.markerManager.getMarker(a):null}getCursor(){return this.markerManager?this.markerManager.getCursor():null}getRenderer(){return this.renderer}getThemeManager(){return this.themeManager_}getTheme(){return this.themeManager_.getTheme()}setTheme(a){a||=Af;this.themeManager_.setTheme(a)}refreshTheme(){this.svgGroup_&&this.renderer.refreshDom(this.svgGroup_,this.getTheme());this.updateBlockStyles(this.getAllBlocks(!1).filter(b=>!!b.getStyleName()));this.refreshToolboxSelection();this.toolbox&&this.toolbox.refreshTheme();
this.isVisible()&&this.setVisible(!0);const a=new (la(O.THEME_CHANGE))(this.getTheme().name,this.id);aa(a)}updateBlockStyles(a){for(let b=0,f;f=a[b];b++){const g=f.getStyleName();g&&f.setStyle(g)}}getInverseScreenCTM(){if(this.inverseScreenCTMDirty){const a=this.getParentSvg().getScreenCTM();a&&(this.inverseScreenCTM=a.inverse(),this.inverseScreenCTMDirty=!1)}return this.inverseScreenCTM}updateInverseScreenCTM(){this.inverseScreenCTMDirty=!0}isVisible(){return this.visible}getSvgXY(a){let b=0,f=0,
g=1;if(this.getCanvas().contains(a)||this.getBubbleCanvas().contains(a))g=this.scale;do{const l=Ke(a);if(a===this.getCanvas()||a===this.getBubbleCanvas())g=1;b+=l.x*g;f+=l.y*g;a=a.parentNode}while(a&&a!==this.getParentSvg()&&a!==this.getInjectionDiv());return new fa(b,f)}getCachedParentSvgSize(){const a=this.cachedParentSvgSize;return new Aa(a.width,a.height)}getOriginOffsetInPixels(){return $f(this.getCanvas())}getInjectionDiv(){if(!this.injectionDiv){let a=this.svgGroup_;for(;a;){if((" "+(a.getAttribute("class")||
"")+" ").includes(" injectionDiv ")){this.injectionDiv=a;break}a=a.parentNode}}return this.injectionDiv}getSvgGroup(){return this.svgGroup_}getBlockCanvas(){return this.getCanvas()}setResizeHandlerWrapper(a){this.resizeHandlerWrapper=a}createDom(a,b){this.injectionDiv||(this.injectionDiv=null!=b?b:null);this.svgGroup_=T(J.G,{"class":"blocklyWorkspace"});a&&(this.svgBackground_=T(J.RECT,{height:"100%",width:"100%","class":a},this.svgGroup_),"blocklyMainBackground"===a&&this.grid?this.svgBackground_.style.fill=
"url(#"+this.grid.getPatternId()+")":this.themeManager_.subscribe(this.svgBackground_,"workspaceBackgroundColour","fill"));this.layerManager=new mo(this);this.svgBlockCanvas_=this.layerManager.getBlockLayer();this.svgBubbleCanvas_=this.layerManager.getBubbleLayer();this.isFlyout||(ta(this.svgGroup_,"pointerdown",this,this.onMouseDown,!1),this.dummyWheelListener=()=>{},document.body.addEventListener("wheel",this.dummyWheelListener),ta(this.svgGroup_,"wheel",this,this.onMouseWheel));this.options.hasCategories&&
(this.toolbox=new (I(ba.TOOLBOX,this.options,!0))(this));this.grid&&this.grid.update(this.scale);this.recordDragTargets();(a=I(ba.CURSOR,this.options))&&this.markerManager.setCursor(new a);this.renderer.createDom(this.svgGroup_,this.getTheme());return this.svgGroup_}dispose(){this.rendered=!1;this.currentGesture_&&this.currentGesture_.cancel();this.svgGroup_&&Ia(this.svgGroup_);this.toolbox&&(this.toolbox.dispose(),this.toolbox=null);this.flyout&&(this.flyout.dispose(),this.flyout=null);this.trashcan&&
(this.trashcan.dispose(),this.trashcan=null);this.scrollbar&&(this.scrollbar.dispose(),this.scrollbar=null);this.zoomControls_&&this.zoomControls_.dispose();this.audioManager&&this.audioManager.dispose();this.grid&&(this.grid=null);this.renderer.dispose();this.markerManager&&this.markerManager.dispose();super.dispose();this.themeManager_&&(this.themeManager_.unsubscribeWorkspace(this),this.themeManager_.unsubscribe(this.svgBackground_),this.options.parentWorkspace||this.themeManager_.dispose());this.connectionDBList.length=
0;this.toolboxCategoryCallbacks.clear();this.flyoutButtonCallbacks.clear();if(!this.options.parentWorkspace){const a=this.getParentSvg();a&&a.parentNode&&Ia(a.parentNode)}this.resizeHandlerWrapper&&(Na(this.resizeHandlerWrapper),this.resizeHandlerWrapper=null);this.dummyWheelListener&&(document.body.removeEventListener("wheel",this.dummyWheelListener),this.dummyWheelListener=null)}addTrashcan(){this.trashcan=ob.newTrashcan(this);const a=this.trashcan.createDom();this.svgGroup_.insertBefore(a,this.getCanvas())}static newTrashcan(a){throw Error("The implementation of newTrashcan should be monkey-patched in by blockly.ts");
}addZoomControls(){this.zoomControls_=new nl(this);const a=this.zoomControls_.createDom();this.svgGroup_.appendChild(a)}addFlyout(a){const b=new zb({parentWorkspace:this,rtl:this.RTL,oneBasedIndex:this.options.oneBasedIndex,horizontalLayout:this.horizontalLayout,renderer:this.options.renderer,rendererOverrides:this.options.rendererOverrides,move:{scrollbars:!0}});b.toolboxPosition=this.options.toolboxPosition;this.flyout=this.horizontalLayout?new (I(ba.FLYOUTS_HORIZONTAL_TOOLBOX,this.options,!0))(b):
new (I(ba.FLYOUTS_VERTICAL_TOOLBOX,this.options,!0))(b);this.flyout.autoClose=!1;this.flyout.getWorkspace().setVisible(!0);return this.flyout.createDom(a)}getFlyout(a){return this.flyout||a?this.flyout:this.toolbox?this.toolbox.getFlyout():null}getToolbox(){return this.toolbox}updateScreenCalculations(){this.updateInverseScreenCTM();this.recordDragTargets()}resizeContents(){this.resizesEnabled&&this.rendered&&(this.scrollbar&&this.scrollbar.resize(),this.updateInverseScreenCTM())}resize(){this.toolbox&&
this.toolbox.position();this.flyout&&this.flyout.position();const a=this.componentManager.getComponents(Qa.Capability.POSITIONABLE,!0),b=this.getMetricsManager().getUiMetrics(),f=[];for(let g=0,l;l=a[g];g++){l.position(b,f);const n=l.getBoundingRectangle();n&&f.push(n)}this.scrollbar&&this.scrollbar.resize();this.updateScreenCalculations()}updateScreenCalculationsIfScrolled(){const a=Ci();fa.equals(this.lastRecordedPageScroll,a)||(this.lastRecordedPageScroll=a,this.updateScreenCalculations())}getLayerManager(){return this.layerManager}getCanvas(){return this.layerManager.getBlockLayer()}setCachedParentSvgSize(a,
b){const f=this.getParentSvg();null!=a&&(this.cachedParentSvgSize.width=a,f.setAttribute("data-cached-width",`${a}`));null!=b&&(this.cachedParentSvgSize.height=b,f.setAttribute("data-cached-height",`${b}`))}getBubbleCanvas(){return this.layerManager.getBubbleLayer()}getParentSvg(){if(!this.cachedParentSvg){let a=this.svgGroup_;for(;a;){if("svg"===a.tagName){this.cachedParentSvg=a;break}a=a.parentNode}}return this.cachedParentSvg}maybeFireViewportChangeEvent(){if(ia()){var a=this.scale,b=-this.scrollY,
f=-this.scrollX;if(!(a===this.oldScale&&1>Math.abs(b-this.oldTop)&&1>Math.abs(f-this.oldLeft))){var g=new (la(O.VIEWPORT_CHANGE))(b,f,a,this.id,this.oldScale);this.oldScale=a;this.oldTop=b;this.oldLeft=f;aa(g)}}}translate(a,b){let f;null==(f=this.layerManager)||f.translateLayers(new fa(a,b),this.scale);let g;null==(g=this.grid)||g.moveTo(a,b);this.maybeFireViewportChangeEvent()}getWidth(){const a=this.getMetrics();return a?a.viewWidth/this.scale:0}setVisible(a){this.visible=a;this.svgGroup_&&(this.scrollbar&&
this.scrollbar.setContainerVisible(a),this.getFlyout()&&this.getFlyout().setContainerVisible(a),this.getParentSvg().style.display=a?"block":"none",this.toolbox&&this.toolbox.setVisible(a),a||this.hideChaff(!0))}render(){const a=this.getAllBlocks(!1);for(let b=a.length-1;0<=b;b--)a[b].queueRender();this.getTopBlocks().flatMap(b=>b.getDescendants(!1)).filter(b=>b.isInsertionMarker()).forEach(b=>b.queueRender());Lb().then(()=>void this.markerManager.updateMarkers())}highlightBlock(a,b){if(void 0===b){for(let f=
0,g;g=this.highlightedBlocks[f];f++)g.setHighlighted(!1);this.highlightedBlocks.length=0}if(a=a?this.getBlockById(a):null)(b=void 0===b||b)?this.highlightedBlocks.includes(a)||this.highlightedBlocks.push(a):mb(this.highlightedBlocks,a),a.setHighlighted(b)}refreshToolboxSelection(){const a=this.isFlyout?this.targetWorkspace:this;a&&!a.currentGesture_&&a.toolbox&&a.toolbox.getFlyout()&&a.toolbox.refreshSelection()}renameVariableById(a,b){super.renameVariableById(a,b);this.refreshToolboxSelection()}deleteVariableById(a){super.deleteVariableById(a);
this.refreshToolboxSelection()}createVariable(a,b,f){a=super.createVariable(a,b,f);this.refreshToolboxSelection();return a}recordDragTargets(){const a=this.componentManager.getComponents(Qa.Capability.DRAG_TARGET,!0);this.dragTargetAreas=[];for(let b=0,f;f=a[b];b++){const g=f.getClientRect();g&&this.dragTargetAreas.push({component:f,clientRect:g})}}newBlock(a,b){throw Error("The implementation of newBlock should be monkey-patched in by blockly.ts");}newComment(a){throw Error("The implementation of newComment should be monkey-patched in by blockly.ts");
}getDragTarget(a){for(let b=0,f;f=this.dragTargetAreas[b];b++)if(f.clientRect.contains(a.clientX,a.clientY))return f.component;return null}onMouseDown(a){const b=this.getGesture(a);b&&b.handleWsStart(a,this)}startDrag(a,b){Sg(this,a,b)}moveDrag(a){return Tg(this,a)}isDragging(){return null!==this.currentGesture_&&this.currentGesture_.isDragging()}isDraggable(){return this.options.moveOptions&&this.options.moveOptions.drag}isMovable(){return this.options.moveOptions&&!!this.options.moveOptions.scrollbars||
this.options.moveOptions&&this.options.moveOptions.wheel||this.options.moveOptions&&this.options.moveOptions.drag||this.options.zoomOptions&&this.options.zoomOptions.wheel||this.options.zoomOptions&&this.options.zoomOptions.pinch}isMovableHorizontally(){const a=!!this.scrollbar;return this.isMovable()&&(!a||a&&this.scrollbar.canScrollHorizontally())}isMovableVertically(){const a=!!this.scrollbar;return this.isMovable()&&(!a||a&&this.scrollbar.canScrollVertically())}onMouseWheel(a){if(bc.inProgress())a.preventDefault(),
a.stopPropagation();else{var b=this.options.zoomOptions&&this.options.zoomOptions.wheel,f=this.options.moveOptions&&this.options.moveOptions.wheel;if(b||f){var g=Ge(a);if(Rf)var l=a.metaKey;b&&(a.ctrlKey||l||!f)?(g=-g.y/50,b=Kd(a,this.getParentSvg(),this.getInverseScreenCTM()),this.zoom(b.x,b.y,g)):(b=this.scrollX-g.x,f=this.scrollY-g.y,a.shiftKey&&!g.x&&(b=this.scrollX-g.y,f=this.scrollY),this.scroll(b,f));a.preventDefault()}}}getBlocksBoundingBox(){const a=this.getTopBoundedElements();if(!a.length)return new Ja(0,
0,0,0);const b=a[0].getBoundingRectangle();for(let g=1;g<a.length;g++){var f=a[g];f.isInsertionMarker&&f.isInsertionMarker()||(f=f.getBoundingRectangle(),f.top<b.top&&(b.top=f.top),f.bottom>b.bottom&&(b.bottom=f.bottom),f.left<b.left&&(b.left=f.left),f.right>b.right&&(b.right=f.right))}return b}cleanUp(){this.setResizesEnabled(!1);d.setGroup$$module$build$src$core$events$utils(!0);var a=this.getTopBlocks(!0),b=a.filter(n=>n.isMovable());const f=a.filter(n=>!n.isMovable()).map(n=>n.getBoundingRectangle());
a=function(n){for(const x of f)if(n.intersects(x))return x;return null};var g=0;const l=this.renderer.getConstants().MIN_BLOCK_HEIGHT;for(const n of b){b=n.getBoundingRectangle();n.moveBy(-b.left,g-b.top,["cleanup"]);n.snapToGrid();b=n.getBoundingRectangle();for(g=a(b);null!=g;)g=g.top+g.getHeight()+l,n.moveBy(0,g-b.top,["cleanup"]),n.snapToGrid(),b=n.getBoundingRectangle(),g=a(b);g=n.getRelativeToSurfaceXY().y+n.getHeightWidth().height+l}d.setGroup$$module$build$src$core$events$utils(!1);this.setResizesEnabled(!0)}showContextMenu(a){if(!this.options.readOnly&&
!this.isFlyout){var b=za.registry.getContextMenuOptions(za.ScopeType.WORKSPACE,{workspace:this});this.configureContextMenu&&this.configureContextMenu(b,a);gf(a,b,this.RTL,this)}}updateToolbox(a){if(a=bg(a)){if(!this.options.languageTree)throw Error("Existing toolbox is null.  Can't create new toolbox.");if(eg(a)){if(!this.toolbox)throw Error("Existing toolbox has no categories.  Can't change mode.");this.options.languageTree=a;this.toolbox.render(a)}else{if(!this.flyout)throw Error("Existing toolbox has categories.  Can't change mode.");
this.options.languageTree=a;this.flyout.show(a)}}else if(this.options.languageTree)throw Error("Can't nullify an existing toolbox.");}markFocused(){this.options.parentWorkspace?this.options.parentWorkspace.markFocused():(M(this),this.getParentSvg().focus({preventScroll:!0}))}zoom(a,b,f){f=Math.pow(this.options.zoomOptions.scaleSpeed,f);const g=this.scale*f;if(this.scale!==g){g>this.options.zoomOptions.maxScale?f=this.options.zoomOptions.maxScale/this.scale:g<this.options.zoomOptions.minScale&&(f=
this.options.zoomOptions.minScale/this.scale);var l=this.getCanvas().getCTM(),n=this.getParentSvg().createSVGPoint();n.x=a;n.y=b;n=n.matrixTransform(l.inverse());a=n.x;b=n.y;l=l.translate(a*(1-f),b*(1-f)).scale(f);this.scrollX=l.e;this.scrollY=l.f;this.setScale(g)}}zoomCenter(a){var b=this.getMetrics();let f;this.flyout?(f=b.svgWidth?b.svgWidth/2:0,b=b.svgHeight?b.svgHeight/2:0):(f=b.viewWidth/2+b.absoluteLeft,b=b.viewHeight/2+b.absoluteTop);this.zoom(f,b,a)}zoomToFit(){if(this.isMovable()){var a=
this.getMetrics(),b=a.viewWidth;a=a.viewHeight;var f=this.getBlocksBoundingBox(),g=f.right-f.left+40;f=f.bottom-f.top+40;if(g){this.flyout&&(this.horizontalLayout?(a+=this.flyout.getHeight(),f+=this.flyout.getHeight()/this.scale):(b+=this.flyout.getWidth(),g+=this.flyout.getWidth()/this.scale));b/=g;a/=f;d.disable$$module$build$src$core$events$utils();try{this.setScale(Math.min(b,a)),this.scrollCenter()}finally{d.enable$$module$build$src$core$events$utils()}this.maybeFireViewportChangeEvent()}}else console.warn("Tried to move a non-movable workspace. This could result in blocks becoming inaccessible.")}beginCanvasTransition(){sa(this.getCanvas(),
"blocklyCanvasTransitioning");sa(this.getBubbleCanvas(),"blocklyCanvasTransitioning")}endCanvasTransition(){Ma(this.getCanvas(),"blocklyCanvasTransitioning");Ma(this.getBubbleCanvas(),"blocklyCanvasTransitioning")}scrollCenter(){if(this.isMovable()){var a=this.getMetrics(),b=(a.scrollWidth-a.viewWidth)/2,f=(a.scrollHeight-a.viewHeight)/2;b=-b-a.scrollLeft;f=-f-a.scrollTop;this.scroll(b,f)}else console.warn("Tried to move a non-movable workspace. This could result in blocks becoming inaccessible.")}centerOnBlock(a,
b){if(this.isMovable()){var f=a?this.getBlockById(a):null;if(f){a=f.getRelativeToSurfaceXY();f=b?{height:f.height,width:f.width}:f.getHeightWidth();var g=this.scale;b=(a.x+(this.RTL?-1:1)*f.width/2)*g;a=(a.y+f.height/2)*g;f=this.getMetrics();this.scroll(-(b-f.viewWidth/2),-(a-f.viewHeight/2))}}else console.warn("Tried to move a non-movable workspace. This could result in blocks becoming inaccessible.")}setScale(a){this.options.zoomOptions.maxScale&&a>this.options.zoomOptions.maxScale?a=this.options.zoomOptions.maxScale:
this.options.zoomOptions.minScale&&a<this.options.zoomOptions.minScale&&(a=this.options.zoomOptions.minScale);this.scale=a;this.hideChaff(!1);(a=this.getFlyout(!1))&&a.isVisible()&&(a.reflow(),this.recordDragTargets());this.grid&&this.grid.update(this.scale);a=this.getMetrics();this.scrollX-=a.absoluteLeft;this.scrollY-=a.absoluteTop;a.viewLeft+=a.absoluteLeft;a.viewTop+=a.absoluteTop;this.scroll(this.scrollX,this.scrollY);this.scrollbar&&(this.flyout?this.scrollbar.resizeView(a):this.scrollbar.resizeContent(a))}getScale(){return this.options.parentWorkspace?
this.options.parentWorkspace.getScale():this.scale}scroll(a,b){this.hideChaff(!0);const f=this.getMetrics();a=Math.min(a,-f.scrollLeft);b=Math.min(b,-f.scrollTop);const g=f.scrollTop+Math.max(0,f.scrollHeight-f.viewHeight);a=Math.max(a,-(f.scrollLeft+Math.max(0,f.scrollWidth-f.viewWidth)));b=Math.max(b,-g);this.scrollX=a;this.scrollY=b;this.scrollbar&&this.scrollbar.set(-(a+f.scrollLeft),-(b+f.scrollTop),!1);a+=f.absoluteLeft;b+=f.absoluteTop;this.translate(a,b)}getBlockById(a){return super.getBlockById(a)}getAllBlocks(a=
!1){return super.getAllBlocks(a)}getTopBlocks(a=!1){return super.getTopBlocks(a)}addTopBlock(a){this.addTopBoundedElement(a);super.addTopBlock(a)}removeTopBlock(a){this.removeTopBoundedElement(a);super.removeTopBlock(a)}addTopComment(a){this.addTopBoundedElement(a);super.addTopComment(a)}removeTopComment(a){this.removeTopBoundedElement(a);super.removeTopComment(a)}getRootWorkspace(){return super.getRootWorkspace()}addTopBoundedElement(a){this.topBoundedElements.push(a)}removeTopBoundedElement(a){mb(this.topBoundedElements,
a)}getTopBoundedElements(){return[].concat(this.topBoundedElements)}setResizesEnabled(a){const b=!this.resizesEnabled&&a;this.resizesEnabled=a;b&&this.resizeContents()}clear(){this.setResizesEnabled(!1);super.clear();this.topBoundedElements=[];this.setResizesEnabled(!0)}registerButtonCallback(a,b){if("function"!==typeof b)throw TypeError("Button callbacks must be functions.");this.flyoutButtonCallbacks.set(a,b)}getButtonCallback(a){let b;return null!=(b=this.flyoutButtonCallbacks.get(a))?b:null}removeButtonCallback(a){this.flyoutButtonCallbacks.delete(a)}registerToolboxCategoryCallback(a,
b){if("function"!==typeof b)throw TypeError("Toolbox category callbacks must be functions.");this.toolboxCategoryCallbacks.set(a,b)}getToolboxCategoryCallback(a){return this.toolboxCategoryCallbacks.get(a)||null}removeToolboxCategoryCallback(a){this.toolboxCategoryCallbacks.delete(a)}getGesture(a){const b="pointerdown"===a.type,f=this.currentGesture_;return f?b&&f.hasStarted()?(console.warn("Tried to start the same gesture twice."),f.cancel(),null):f:b?this.currentGesture_=new bc(a,this):null}clearGesture(){this.currentGesture_=
null}cancelCurrentGesture(){this.currentGesture_&&this.currentGesture_.cancel()}getAudioManager(){return this.audioManager}getGrid(){return this.grid}hideChaff(a=!1){rc();cf(this);Yb();this.hideComponents(a)}hideComponents(a=!1){this.getComponentManager().getComponents(Qa.Capability.AUTOHIDEABLE,!0).forEach(b=>b.autoHide(a))}static setTopLevelWorkspaceMetrics(a){const b=this.getMetrics();"number"===typeof a.x&&(this.scrollX=-(b.scrollLeft+(b.scrollWidth-b.viewWidth)*a.x));"number"===typeof a.y&&(this.scrollY=
-(b.scrollTop+(b.scrollHeight-b.viewHeight)*a.y));this.translate(this.scrollX+b.absoluteLeft,this.scrollY+b.absoluteTop)}},Lh=class extends Eb{constructor(a,b,f){super(f);this.type=O.SELECTED;this.oldElementId=null!=a?a:void 0;this.newElementId=null!=b?b:void 0}toJson(){const a=super.toJson();a.oldElementId=this.oldElementId;a.newElementId=this.newElementId;return a}static fromJson(a,b,f){b=super.fromJson(a,b,null!=f?f:new Lh);b.oldElementId=a.oldElementId;b.newElementId=a.newElementId;return b}};
e(ba.EVENT,O.SELECTED,Lh);var ve=class{paste(a,b,f){if(!b.isCapacityAvailable(a.typeCounts))return null;f&&(a.blockState.x=f.x,a.blockState.y=f.y);f=f||new fa(a.blockState.x||0,a.blockState.y||0);d.disable$$module$build$src$core$events$utils();let g;try{g=pc(a.blockState,b),Wn(g,f)}finally{d.enable$$module$build$src$core$events$utils()}if(!g)return g;ia()&&!g.isShadow()&&aa(new (la(O.BLOCK_CREATE))(g));d.setSelected$$module$build$src$core$common(g);return g}};ve.TYPE="block";jg(ve.TYPE,new ve);var If=
{};If.bumpIntoBounds=he;If.bumpIntoBoundsHandler=vk;If.bumpTopObjectsIntoBounds=eh;var Ol=class{constructor(a){this.block=a;this.connectionPreviewer=this.connectionCandidate=this.startLoc=this.startChildConn=this.startParentConn=null;this.dragging=!1;this.dragOffset=new fa(0,0);this.inGroup=!1;this.workspace=a.workspace}isMovable(){if(this.block.isShadow()){let a,b;return null!=(b=null==(a=this.block.getParent())?void 0:a.isMovable())?b:!1}return this.block.isOwnMovable()&&!this.block.isDeadOrDying()&&
!this.workspace.options.readOnly&&!this.block.isInFlyout}startDrag(a){if(this.block.isShadow())this.startDraggingShadow(a);else{this.dragging=!0;(this.inGroup=!!d.getGroup$$module$build$src$core$events$utils())||d.setGroup$$module$build$src$core$events$utils(!0);this.fireDragStartEvent();this.startLoc=this.block.getRelativeToSurfaceXY();this.connectionCandidate=null;this.connectionPreviewer=new (I(ba.CONNECTION_PREVIEWER,this.workspace.options))(this.block);cd();this.workspace.setResizesEnabled(!1);
ee();a=!!a&&(a.altKey||a.ctrlKey||a.metaKey);this.shouldDisconnect(a)&&this.disconnectBlock(a);this.block.setDragging(!0);var b;null==(b=this.workspace.getLayerManager())||b.moveToDragLayer(this.block)}}startDraggingShadow(a){const b=this.block.getParent();if(!b)throw Error("Tried to drag a shadow block with no parent. Shadow blocks should always have parents.");this.dragOffset=fa.difference(b.getRelativeToSurfaceXY(),this.block.getRelativeToSurfaceXY());b.startDrag(a)}shouldDisconnect(a){return!!(this.block.getParent()||
a&&this.block.nextConnection&&this.block.nextConnection.targetBlock())}disconnectBlock(a){let b,f,g;this.startParentConn=null!=(g=null==(b=this.block.outputConnection)?void 0:b.targetConnection)?g:null==(f=this.block.previousConnection)?void 0:f.targetConnection;if(a){let l;this.startChildConn=null==(l=this.block.nextConnection)?void 0:l.targetConnection}this.block.unplug(a);dk(this.block)}fireDragStartEvent(){const a=new (la(O.BLOCK_DRAG))(this.block,!0,this.block.getDescendants(!1));aa(a)}fireDragEndEvent(){const a=
new (la(O.BLOCK_DRAG))(this.block,!1,this.block.getDescendants(!1));aa(a)}fireMoveEvent(){if(!this.block.isDeadOrDying()){var a=new (la(O.BLOCK_MOVE))(this.block);a.setReason(["drag"]);a.oldCoordinate=this.startLoc;a.recordNew();aa(a)}}drag(a){if(this.block.isShadow()){let b;null==(b=this.block.getParent())||b.drag(fa.sum(a,this.dragOffset))}else this.block.moveDuringDrag(a),this.updateConnectionPreview(this.block,fa.difference(a,this.startLoc))}updateConnectionPreview(a,b){var f=this.connectionCandidate;
const g=this.getConnectionCandidate(a,b);if(g){this.connectionCandidate=b=f&&this.currCandidateIsBetter(f,b,g)?f:g;var {local:l,neighbour:n}=b;b=l.type===oa.OUTPUT_VALUE||l.type===oa.PREVIOUS_STATEMENT;f=n.isConnected()&&!n.targetBlock().isInsertionMarker();b&&f&&!this.orphanCanConnectAtEnd(a,n.targetBlock(),l.type)?this.connectionPreviewer.previewReplacement(l,n,n.targetBlock()):this.connectionPreviewer.previewConnection(l,n)}else this.connectionPreviewer.hidePreview(),this.connectionCandidate=null}orphanCanConnectAtEnd(a,
b,f){return!!Ba.getConnectionForOrphanedConnection(a,f===oa.OUTPUT_VALUE?b.outputConnection:b.previousConnection)}currCandidateIsBetter(a,b,f){const {local:g,neighbour:l}=a;a=new fa(g.x,g.y);const n=new fa(l.x,l.y);b=fa.distance(fa.sum(a,b),n);return f.distance>b-d.config$$module$build$src$core$config.currentConnectionPreference}getConnectionCandidate(a,b){a=this.getLocalConnections(a);let f=this.connectionCandidate?d.config$$module$build$src$core$config.connectingSnapRadius:d.config$$module$build$src$core$config.snapRadius,
g=null;for(const l of a){const {connection:n,radius:x}=l.closest(f,b);n&&(g={local:l,neighbour:n,distance:x},f=x)}return g}getLocalConnections(a){const b=a.getConnections_(!1),f=a.lastConnectionInStack(!0);f&&f!==a.nextConnection&&b.push(f);return b}endDrag(a){if(this.block.isShadow()){let b;null==(b=this.block.getParent())||b.endDrag(a)}else{this.fireDragEndEvent();this.fireMoveEvent();dd();ee();this.connectionPreviewer.hidePreview();if(!this.block.isDeadOrDying()&&this.dragging){let b;null==(b=
this.workspace.getLayerManager())||b.moveOffDragLayer(this.block,50);this.block.setDragging(!1)}this.connectionCandidate?(this.applyConnections(this.connectionCandidate),this.disposeStep()):this.block.queueRender().then(()=>this.disposeStep());this.inGroup||d.setGroup$$module$build$src$core$events$utils(!1)}}disposeStep(){this.block.snapToGrid();this.connectionPreviewer.dispose();this.workspace.setResizesEnabled(!0)}applyConnections(a){const {local:b,neighbour:f}=a;b.connect(f);const g=b.isSuperior()?
f:b,l=this.block.getRootBlock();Lb().then(()=>{Wg(g.getSourceBlock());setTimeout(()=>{l.bringToFront()},0)})}revertDrag(){if(this.block.isShadow()){let b;null==(b=this.block.getParent())||b.revertDrag()}else{var a;null==(a=this.startChildConn)||a.connect(this.block.nextConnection);if(this.startParentConn)switch(this.startParentConn.type){case oa.INPUT_VALUE:this.startParentConn.connect(this.block.outputConnection);break;case oa.NEXT_STATEMENT:this.startParentConn.connect(this.block.previousConnection)}else{this.block.moveTo(this.startLoc,
["drag"]);let b;null==(b=this.workspace.getLayerManager())||b.moveOffDragLayer(this.block,50);he(this.workspace,this.workspace.getMetricsManager().getScrollMetrics(!0),this.block)}this.startParentConn=this.startChildConn=null;this.connectionPreviewer.hidePreview();this.connectionCandidate=null;this.block.setDragging(!1);this.dragging=!1}}},Pl=class{constructor(){this.drawer=this.curNode=this.colour=null;this.type="marker"}setDrawer(a){this.drawer=a}getDrawer(){return this.drawer}getCurNode(){return this.curNode}setCurNode(a){const b=
this.curNode;this.curNode=a;this.drawer&&this.drawer.draw(b,this.curNode)}draw(){this.drawer&&this.drawer.draw(this.curNode,this.curNode)}hide(){this.drawer&&this.drawer.hide()}dispose(){this.getDrawer()&&this.getDrawer().dispose()}},Mh=class extends Pl{constructor(){super();this.type="cursor"}next(){var a=this.getCurNode();if(!a)return null;for(a=a.next();a&&a.next()&&(a.getType()===X.types.NEXT||a.getType()===X.types.BLOCK);)a=a.next();a&&this.setCurNode(a);return a}in(){var a=this.getCurNode();
if(!a)return null;if(a.getType()===X.types.PREVIOUS||a.getType()===X.types.OUTPUT)a=a.next();let b,f;(a=null!=(f=null==(b=a)?void 0:b.in())?f:null)&&this.setCurNode(a);return a}prev(){var a=this.getCurNode();if(!a)return null;for(a=a.prev();a&&a.prev()&&(a.getType()===X.types.NEXT||a.getType()===X.types.BLOCK);)a=a.prev();a&&this.setCurNode(a);return a}out(){var a=this.getCurNode();if(!a)return null;(a=a.out())&&a.getType()===X.types.BLOCK&&(a=a.prev()||a);a&&this.setCurNode(a);return a}};e(ba.CURSOR,
Jb,Mh);var we=class extends Mh{constructor(){super()}next(){var a=this.getCurNode();if(!a)return null;(a=this.getNextNode_(a,this.validNode_))&&this.setCurNode(a);return a}in(){return this.next()}prev(){var a=this.getCurNode();if(!a)return null;(a=this.getPreviousNode_(a,this.validNode_))&&this.setCurNode(a);return a}out(){return this.prev()}getNextNode_(a,b){if(!a)return null;const f=a.in()||a.next();if(b(f))return f;if(f)return this.getNextNode_(f,b);a=this.findSiblingOrParent(a.out());return b(a)?
a:a?this.getNextNode_(a,b):null}getPreviousNode_(a,b){if(!a)return null;let f=a.prev();f=f?this.getRightMostChild(f):a.out();return b(f)?f:f?this.getPreviousNode_(f,b):null}validNode_(a){let b=!1;a=a&&a.getType();if(a===X.types.OUTPUT||a===X.types.INPUT||a===X.types.FIELD||a===X.types.NEXT||a===X.types.PREVIOUS||a===X.types.WORKSPACE)b=!0;return b}findSiblingOrParent(a){if(!a)return null;const b=a.next();return b?b:this.findSiblingOrParent(a.out())}getRightMostChild(a){if(!a.in())return a;for(a=a.in();a&&
a.next();)a=a.next();return this.getRightMostChild(a)}};we.registrationName="basicCursor";e(ba.CURSOR,we.registrationName,we);var Ql=class extends we{validNode_(a){let b=!1;const f=a&&a.getType();a&&(a=a.getLocation(),f===X.types.FIELD&&a&&a.isTabNavigable()&&a.isClickable()&&(b=!0));return b}},tb=class extends Ba{constructor(a,b){super(a,b);this.highlighted=!1;this.targetConnection=null;this.db=a.workspace.connectionDBList[b];this.dbOpposite=a.workspace.connectionDBList[Yc[b]];this.offsetInBlock=
new fa(0,0);this.trackedState=tb.TrackedState.WILL_TRACK}dispose(){super.dispose();this.trackedState===tb.TrackedState.TRACKED&&this.db.removeConnection(this,this.y);let a,b;null==(b=(a=this.sourceBlock_.pathObject).removeConnectionHighlight)||b.call(a,this)}getSourceBlock(){return super.getSourceBlock()}targetBlock(){return super.targetBlock()}distanceFrom(a){const b=this.x-a.x;a=this.y-a.y;return Math.sqrt(b*b+a*a)}bumpAwayFrom(a,b=!1){if(!this.sourceBlock_.workspace.isDragging()){var f=d.config$$module$build$src$core$config.snapRadius+
Math.floor(10*Math.random()),g=d.config$$module$build$src$core$config.snapRadius+Math.floor(10*Math.random()),l=a.sourceBlock_.getRootBlock(),n=this.sourceBlock_.getRootBlock();if(!l.isInFlyout&&!n.isInFlyout){var x=!0;if(n.isMovable())l.isMovable()&&b&&(g=-g);else if(l.isMovable())x=!1,f=-f,g=-g;else return;b=x?a:this;a=x?this:a;l=x?n:l;(n=U()===l)||l.addSelect();l.RTL&&(f=-f);l.moveBy(b.x+f-a.x,b.y+g-a.y,["bump"]);n||l.removeSelect()}}}moveTo(a,b){let f=!1;this.trackedState===tb.TrackedState.WILL_TRACK?
(this.db.addConnection(this,b),this.trackedState=tb.TrackedState.TRACKED,f=!0):this.trackedState===tb.TrackedState.TRACKED&&(this.db.removeConnection(this,this.y),this.db.addConnection(this,b),f=!0);this.x=a;this.y=b;return f}moveBy(a,b){return this.moveTo(this.x+a,this.y+b)}moveToOffset(a){return this.moveTo(a.x+this.offsetInBlock.x,a.y+this.offsetInBlock.y)}setOffsetInBlock(a,b){this.offsetInBlock.x=a;this.offsetInBlock.y=b}getOffsetInBlock(){return this.offsetInBlock}tightenEfficiently(){var a=
this.targetConnection;const b=this.targetBlock();a&&b&&(a=fa.difference(this.offsetInBlock,a.offsetInBlock),b.translate(a.x,a.y))}closest(a,b){return this.dbOpposite.searchForClosest(this,a,b)}highlight(){this.highlighted=!0;this.getSourceBlock().queueRender()}unhighlight(){this.highlighted=!1;this.getSourceBlock().queueRender()}isHighlighted(){return this.highlighted}setTracking(a){a&&this.trackedState===tb.TrackedState.TRACKED||!a&&this.trackedState===tb.TrackedState.UNTRACKED||this.sourceBlock_.isInFlyout||
(a?(this.db.addConnection(this,this.y),this.trackedState=tb.TrackedState.TRACKED):(this.trackedState===tb.TrackedState.TRACKED&&this.db.removeConnection(this,this.y),this.trackedState=tb.TrackedState.UNTRACKED))}stopTrackingAll(){this.setTracking(!1);if(this.targetConnection){const a=this.targetBlock().getDescendants(!1);for(let b=0;b<a.length;b++){const f=a[b],g=f.getConnections_(!0);for(let l=0;l<g.length;l++)g[l].setTracking(!1);for(const l of f.getIcons())Vd(l)&&l.setBubbleVisible(!1)}}}startTrackingAll(){this.setTracking(!0);
let a=[];if(this.type!==oa.INPUT_VALUE&&this.type!==oa.NEXT_STATEMENT)return a;const b=this.targetBlock();if(b){let f;b.isCollapsed()?(f=[],b.outputConnection&&f.push(b.outputConnection),b.nextConnection&&f.push(b.nextConnection),b.previousConnection&&f.push(b.previousConnection)):f=b.getConnections_(!0);for(let g=0;g<f.length;g++)a.push(...f[g].startTrackingAll());a.length||(a=[b])}return a}onFailedConnect(a){const b=this.getSourceBlock();if(ea()){const f=d.getGroup$$module$build$src$core$events$utils();
setTimeout(function(){b.isDisposed()||b.getParent()||(d.setGroup$$module$build$src$core$events$utils(f),this.bumpAwayFrom(a),d.setGroup$$module$build$src$core$events$utils(!1))}.bind(this),d.config$$module$build$src$core$config.bumpDelay)}}disconnectInternal(a=!0){const {parentConnection:b,childConnection:f}=this.getParentAndChildConnections();if(b&&f){var g=d.getGroup$$module$build$src$core$events$utils();g||d.setGroup$$module$build$src$core$events$utils(!0);var l=b.getSourceBlock(),n=f.getSourceBlock();
super.disconnectInternal(a);l.queueRender();n.updateDisabled();n.queueRender();n.getSvgRoot().style.display="block";d.setGroup$$module$build$src$core$events$utils(g)}}respawnShadow_(){super.respawnShadow_();const a=this.targetBlock();a&&(a.initSvg(),a.queueRender())}neighbours(a){return this.dbOpposite.getNeighbours(this,a)}connect_(a){super.connect_(a);var b=this.getSourceBlock();a=a.getSourceBlock();b.updateDisabled();a.updateDisabled();a.queueRender();var f=U();if(f=f===b&&b||f===a&&a)f.removeSelect(),
f.addSelect();if(b=b.getInputWithBlock(a))b=b.isVisible(),a.getSvgRoot().style.display=b?"block":"none"}onCheckChanged_(){!this.isConnected()||this.targetConnection&&this.getConnectionChecker().canConnect(this,this.targetConnection,!1)||(this.isSuperior()?this.targetBlock():this.sourceBlock_).unplug()}setCheck(a){super.setCheck(a);this.sourceBlock_.queueRender();return this}};(function(a){a=a.TrackedState||(a.TrackedState={});a[a.WILL_TRACK=-1]="WILL_TRACK";a[a.UNTRACKED=0]="UNTRACKED";a[a.TRACKED=
1]="TRACKED"})(tb||={});var xb=class extends Ac{constructor(a,b,f){super(a,b,f);this.childlessWidth=this.width=this.height=0;this.warningTextDb=new Map;this.mutator=null;this.rendered=!0;this.visuallyDisabled=!1;this.translation="";this.dragging=!1;this.relativeCoords=new fa(0,0);this.dragStrategy=new Ol(this);if(!a.rendered)throw TypeError("Cannot create a rendered block in a headless workspace");this.workspace=a;this.svgGroup=T(J.G,{});this.style=a.getRenderer().getConstants().getBlockStyle(null);
this.pathObject=a.getRenderer().makePathObject(this.svgGroup,this.style);a=this.pathObject.svgPath;a.tooltip=this;Zd(a);this.svgGroup.setAttribute("data-id",this.id);this.doInit_()}initSvg(){if(!this.initialized){for(var a of this.inputList)a.init();for(const b of this.getIcons())b.initView(this.createIconPointerDownListener(b)),b.updateEditable();this.applyColour();this.pathObject.updateMovable(this.isMovable()||this.isInFlyout);a=this.getSvgRoot();!this.workspace.options.readOnly&&a&&ta(a,"pointerdown",
this,this.onMouseDown);a.parentNode||this.workspace.getCanvas().appendChild(a);this.initialized=!0}}getColourSecondary(){return this.style.colourSecondary}getColourTertiary(){return this.style.colourTertiary}select(){if(this.isShadow()){let a;null==(a=this.getParent())||a.select()}else this.addSelect()}unselect(){if(this.isShadow()){let a;null==(a=this.getParent())||a.unselect()}else this.removeSelect()}setParent(a){const b=this.parentBlock_;if(a!==b){cd();super.setParent(a);dd();var f=this.getSvgRoot();
if(!this.workspace.isClearing&&f){var g=this.getRelativeToSurfaceXY();a?a.getSvgRoot().appendChild(f):b&&((a=this.workspace.getCanvas().querySelector(".blocklyDragging"))?this.workspace.getCanvas().insertBefore(f,a):this.workspace.getCanvas().appendChild(f),this.translate(g.x,g.y));this.applyColour()}}}getRelativeToSurfaceXY(){const a=this.workspace.getLayerManager();if(!a)throw Error("Cannot calculate position because the workspace has not been appended");let b=0,f=0,g=this.getSvgRoot();if(g){do{const l=
Ke(g);b+=l.x;f+=l.y;g=g.parentNode}while(g&&!a.hasLayer(g))}return new fa(b,f)}moveBy(a,b,f){if(this.parentBlock_)throw Error("Block has parent");const g=ia();let l=null;g&&(l=new (la(O.BLOCK_MOVE))(this),f&&l.setReason(f));a=new fa(a,b);b=this.getRelativeToSurfaceXY();a=fa.sum(b,a);this.translate(a.x,a.y);this.updateComponentLocations(a);g&&l&&(l.recordNew(),aa(l));this.workspace.resizeContents()}translate(a,b){this.translation=`translate(${a}, ${b})`;this.relativeCoords=new fa(a,b);this.getSvgRoot().setAttribute("transform",
this.getTranslation())}getTranslation(){return this.translation}moveTo(a,b){const f=this.getRelativeToSurfaceXY();this.moveBy(a.x-f.x,a.y-f.y,b)}moveDuringDrag(a){this.translate(a.x,a.y);this.getSvgRoot().setAttribute("transform",this.getTranslation());this.updateComponentLocations(a)}snapToGrid(){if(!this.isDeadOrDying()&&!this.getParent()&&!this.isInFlyout){var a=this.workspace.getGrid();if(null!=a&&a.shouldSnap()){var b=this.getRelativeToSurfaceXY();a=a.alignXY(b);a!==b&&this.moveTo(a,["snap"])}}}getBoundingRectangle(){return this.getBoundingRectangleWithDimensions(this.getHeightWidth())}getBoundingRectangleWithoutChildren(){return this.getBoundingRectangleWithDimensions({height:this.height,
width:this.childlessWidth})}getBoundingRectangleWithDimensions(a){const b=this.getRelativeToSurfaceXY();let f,g;this.RTL?(f=b.x-a.width,g=b.x):(f=b.x,g=b.x+a.width);return new Ja(b.y,b.y+a.height,f,g)}markDirty(){this.pathObject.constants=this.workspace.getRenderer().getConstants();for(let a=0,b;b=this.inputList[a];a++)b.markDirty()}setCollapsed(a){this.collapsed_!==a&&(super.setCollapsed(a),this.updateCollapsed())}updateCollapsed(){var a=this.isCollapsed();for(let f=0,g;g=this.inputList[f];f++)"_TEMP_COLLAPSED_INPUT"!==
g.name&&g.setVisible(!a);for(var b of this.getIcons())b.updateCollapsed();a?(a=this.toString(30),(b=this.getField("_TEMP_COLLAPSED_FIELD"))?b.setValue(a):(this.getInput("_TEMP_COLLAPSED_INPUT")||this.appendDummyInput("_TEMP_COLLAPSED_INPUT")).appendField(new Wc(a),"_TEMP_COLLAPSED_FIELD")):(this.updateDisabled(),this.removeInput("_TEMP_COLLAPSED_INPUT"))}tab(a,b){const f=new Ql;f.setCurNode(X.createFieldNode(a));a=f.getCurNode();b?f.next():f.prev();(b=f.getCurNode())&&b!==a&&(b.getLocation().showEditor(),
this.workspace.keyboardAccessibilityMode&&this.workspace.getCursor().setCurNode(b))}onMouseDown(a){const b=this.workspace.getGesture(a);b&&b.handleBlockStart(a,this)}showHelp(){const a="function"===typeof this.helpUrl?this.helpUrl():this.helpUrl;a&&window.open(a)}generateContextMenu(){if(this.workspace.options.readOnly||!this.contextMenu)return null;const a=za.registry.getContextMenuOptions(za.ScopeType.BLOCK,{block:this});this.customContextMenu&&this.customContextMenu(a);return a}showContextMenu(a){const b=
this.generateContextMenu();b&&b.length&&(gf(a,b,this.RTL,this.workspace),Qj(this))}updateComponentLocations(a){this.dragging||this.updateConnectionLocations(a);this.updateIconLocations(a);this.updateFieldLocations(a);for(const b of this.getChildren(!1))b.updateComponentLocations(fa.sum(a,b.relativeCoords))}updateConnectionLocations(a){for(const b of this.getConnections_(!1))b.moveToOffset(a)}updateIconLocations(a){for(const b of this.getIcons())b.onLocationChange(a)}updateFieldLocations(a){for(const b of this.inputList)for(const f of b.fieldRow)f.onLocationChange(a)}setDragging(a){(this.dragging=
a)?(this.translation="",ie.push(...this.getConnections_(!0)),sa(this.svgGroup,"blocklyDragging")):(ie.length=0,Ma(this.svgGroup,"blocklyDragging"));for(let b=0;b<this.childBlocks_.length;b++)this.childBlocks_[b].setDragging(a)}setMovable(a){super.setMovable(a);this.pathObject.updateMovable(a)}setEditable(a){super.setEditable(a);a=this.getIcons();for(let b=0;b<a.length;b++)a[b].updateEditable()}setShadow(a){super.setShadow(a);this.applyColour()}setInsertionMarker(a){this.isInsertionMarker_!==a&&(this.isInsertionMarker_=
a)&&(this.setColour(this.workspace.getRenderer().getConstants().INSERTION_MARKER_COLOUR),this.pathObject.updateInsertionMarker(!0))}getSvgRoot(){return this.svgGroup}dispose(a,b){this.disposing=!0;Cj();ff();b&&(this.unplug(a),Vg(this));b=U();if(b instanceof Ac){let f=b;for(;null!==f;)f===this&&b.unselect(),f=f.getParent()}super.dispose(!!a);Ia(this.svgGroup)}disposeInternal(){this.disposing=!0;super.disposeInternal();U()===this&&(this.unselect(),this.workspace.cancelCurrentGesture());[...this.warningTextDb.values()].forEach(a=>
clearTimeout(a));this.warningTextDb.clear();this.getIcons().forEach(a=>a.dispose())}checkAndDelete(){this.workspace.isFlyout||(d.setGroup$$module$build$src$core$events$utils(!0),this.workspace.hideChaff(),this.outputConnection?this.dispose(!1,!0):this.dispose(!0,!0),d.setGroup$$module$build$src$core$events$utils(!1))}toCopyData(){return this.isInsertionMarker_?null:{paster:ve.TYPE,blockState:vb(this,{addCoordinates:!0,addNextBlocks:!1}),typeCounts:D(this,!0)}}applyColour(){this.pathObject.applyColour(this);
const a=this.getIcons();for(let b=0;b<a.length;b++)a[b].applyColour();for(let b=0,f;f=this.inputList[b];b++)for(let g=0,l;l=f.fieldRow[g];g++)l.applyColour()}updateDisabled(){const a=!this.isEnabled()||this.getInheritedDisabled();if(this.visuallyDisabled===a){let b;null==(b=this.getNextBlock())||b.updateDisabled()}else{this.applyColour();this.visuallyDisabled=a;for(const b of this.getChildren(!1))b.updateDisabled()}}setWarningText(a,b=""){if(b)this.warningTextDb.has(b)&&(clearTimeout(this.warningTextDb.get(b)),
this.warningTextDb.delete(b));else{for(var f of this.warningTextDb.values())clearTimeout(f);this.warningTextDb.clear()}if(this.workspace.isDragging())this.warningTextDb.set(b,setTimeout(()=>{this.isDeadOrDying()||(this.warningTextDb.delete(b),this.setWarningText(a,b))},100));else if(this.isInFlyout&&(a=null),f=this.getIcon(ic.TYPE),a){let g=this.getSurroundParent(),l=null;for(;g;)g.isCollapsed()&&(l=g),g=g.getSurroundParent();l&&l.setWarningText(d.Msg$$module$build$src$core$msg.COLLAPSED_WARNINGS_WARNING,
xb.COLLAPSED_WARNING_ID);f?f.addMessage(a,b):this.addIcon((new ic(this)).addMessage(a,b))}else f&&(b?(f.addMessage("",b),f.getText()||this.removeIcon(ic.TYPE)):this.removeIcon(ic.TYPE))}setMutator(a){this.removeIcon(d.MutatorIcon$$module$build$src$core$icons$mutator_icon.TYPE);a&&this.addIcon(a)}addIcon(a){super.addIcon(a);a instanceof d.MutatorIcon$$module$build$src$core$icons$mutator_icon&&(this.mutator=a);a.initView(this.createIconPointerDownListener(a));a.applyColour();a.updateEditable();this.queueRender();
return a}createIconPointerDownListener(a){return b=>{this.isDeadOrDying()||(b=this.workspace.getGesture(b))&&b.setStartIcon(a)}}removeIcon(a){const b=super.removeIcon(a);a.equals(d.MutatorIcon$$module$build$src$core$icons$mutator_icon.TYPE)&&(this.mutator=null);this.queueRender();return b}setEnabled(a){L("setEnabled","v11","v12","the setDisabledReason method of BlockSvg");const b=this.isEnabled();super.setEnabled(a);this.isEnabled()===b||this.getInheritedDisabled()||this.updateDisabled()}setDisabledReason(a,
b){const f=this.isEnabled();super.setDisabledReason(a,b);this.isEnabled()===f||this.getInheritedDisabled()||this.updateDisabled()}setHighlighted(a){this.pathObject.updateHighlighted(a)}addSelect(){this.pathObject.updateSelected(!0)}removeSelect(){this.pathObject.updateSelected(!1)}setDeleteStyle(a){this.pathObject.updateDraggingDelete(a)}getColour(){return this.style.colourPrimary}setColour(a){super.setColour(a);a=this.workspace.getRenderer().getConstants().getBlockStyleForColour(this.colour_);this.pathObject.setStyle(a.style);
this.style=a.style;this.styleName_=a.name;this.applyColour()}setStyle(a){const b=this.workspace.getRenderer().getConstants().getBlockStyle(a);this.styleName_=a;if(b)this.hat=b.hat,this.pathObject.setStyle(b),this.colour_=b.colourPrimary,this.style=b,this.applyColour();else throw Error("Invalid style name: "+a);}getStyle(){return this.style}bringToFront(a=!1){let b=this;if(!b.isDeadOrDying()){do{const f=b.getSvgRoot(),g=f.parentNode,l=g.childNodes;l[l.length-1]!==f&&g.appendChild(f);if(a)break;b=b.getParent()}while(b)
}}setPreviousStatement(a,b){super.setPreviousStatement(a,b);this.queueRender()}setNextStatement(a,b){super.setNextStatement(a,b);this.queueRender()}setOutput(a,b){super.setOutput(a,b);this.queueRender()}setInputsInline(a){super.setInputsInline(a);this.queueRender()}removeInput(a,b){a=super.removeInput(a,b);this.queueRender();return a}moveNumberedInputBefore(a,b){super.moveNumberedInputBefore(a,b);this.queueRender()}appendInput(a){super.appendInput(a);this.queueRender();return a}setConnectionTracking(a){this.previousConnection&&
this.previousConnection.setTracking(a);this.outputConnection&&this.outputConnection.setTracking(a);if(this.nextConnection){this.nextConnection.setTracking(a);var b=this.nextConnection.targetBlock();b&&b.setConnectionTracking(a)}if(!this.collapsed_)for(b=0;b<this.inputList.length;b++){var f=this.inputList[b].connection;f&&(f.setTracking(a),(f=f.targetBlock())&&f.setConnectionTracking(a))}}getConnections_(a){const b=[];this.outputConnection&&b.push(this.outputConnection);this.previousConnection&&b.push(this.previousConnection);
this.nextConnection&&b.push(this.nextConnection);if(a||!this.collapsed_)for(let f=0,g;g=this.inputList[f];f++)g.connection&&b.push(g.connection);return b}lastConnectionInStack(a){return super.lastConnectionInStack(a)}getMatchingConnection(a,b){return super.getMatchingConnection(a,b)}makeConnection_(a){return new tb(this,a)}getNextBlock(){return super.getNextBlock()}getPreviousBlock(){return super.getPreviousBlock()}bumpNeighbours(){const a=this.getRootBlock();if(!(this.isDeadOrDying()||this.workspace.isDragging()||
a.isInFlyout))for(const b of this.getConnections_(!1)){if(b.isSuperior()){let f;null==(f=b.targetBlock())||f.bumpNeighbours()}for(const f of b.neighbours(d.config$$module$build$src$core$config.snapRadius))f.getSourceBlock().getRootBlock()!==a&&(b.isConnected()&&f.isConnected()||(b.isSuperior()?f.bumpAwayFrom(b,!1):b.bumpAwayFrom(f,!0)))}}scheduleSnapAndBump(){this.snapToGrid();this.bumpNeighbours()}positionNearConnection(a,b,f){if(a.type===oa.NEXT_STATEMENT||a.type===oa.INPUT_VALUE){let g=b.x;b=b.y;
g+=f.x-a.getOffsetInBlock().x;b+=f.y-a.getOffsetInBlock().y;this.moveBy(g,b)}}getChildren(a){return super.getChildren(a)}queueRender(){return Ki(this)}render(){this.queueRender();oc()}renderEfficiently(){cd();this.isCollapsed()&&this.updateCollapsed();this.isEnabled()||this.updateDisabled();this.workspace.getRenderer().render(this);this.tightenChildrenEfficiently();dd();this.updateMarkers_()}tightenChildrenEfficiently(){for(const a of this.inputList){const b=a.connection;b&&b.tightenEfficiently()}this.nextConnection&&
this.nextConnection.tightenEfficiently()}updateMarkers_(){this.workspace.keyboardAccessibilityMode&&this.pathObject.cursorSvg&&this.workspace.getCursor().draw();this.workspace.keyboardAccessibilityMode&&this.pathObject.markerSvg&&this.workspace.getMarker(oe.LOCAL_MARKER).draw();for(const a of this.inputList)for(const b of a.fieldRow)b.updateMarkers_()}setCursorSvg(a){this.pathObject.setCursorSvg(a)}setMarkerSvg(a){this.pathObject.setMarkerSvg(a)}getHeightWidth(){let a=this.height,b=this.width;var f=
this.getNextBlock();if(f){f=f.getHeightWidth();const g=this.workspace.getRenderer().getConstants().NOTCH_HEIGHT;a+=f.height-g;b=Math.max(b,f.width)}return{height:a,width:b}}fadeForReplacement(a){this.pathObject.updateReplacementFade(a)}highlightShapeForInput(a,b){this.pathObject.updateShapeForInputHighlight(a,b)}setDragStrategy(a){this.dragStrategy=a}isMovable(){return this.dragStrategy.isMovable()}startDrag(a){this.dragStrategy.startDrag(a)}drag(a,b){this.dragStrategy.drag(a,b)}endDrag(a){this.dragStrategy.endDrag(a)}revertDrag(){this.dragStrategy.revertDrag()}toFlyoutInfo(){const a=
Object.assign({},{kind:"BLOCK"},vb(this)),b=new Set(["id","height","width","pinned","enabled"]),f=function(g){for(const l in g)b.has(l)?delete g[l]:"object"===typeof g[l]&&f(g[l])};f(a);return[a]}};xb.INLINE=-1;xb.COLLAPSED_WARNING_ID="TEMP_COLLAPSED_WARNING_";var Rl=class{constructor(){}onDragEnter(a){}onDragOver(a){}onDragExit(a){}onDrop(a){}getClientRect(){return null}shouldPreventMove(a){return!1}},Jf=class extends Rl{constructor(){super();this.wouldDelete_=!1}wouldDelete(a){a instanceof xb?(a=
!a.getParent()&&a.isDeletable(),this.updateWouldDelete_(a)):this.updateWouldDelete_(Db(a)&&a.isDeletable());return this.wouldDelete_}updateWouldDelete_(a){this.wouldDelete_=a}},Nh=class extends Eb{constructor(a,b){super(b);this.type=O.TRASHCAN_OPEN;this.isOpen=a}toJson(){const a=super.toJson();if(void 0===this.isOpen)throw Error("Whether this is already open or not is undefined. Either pass a value to the constructor, or call fromJson");a.isOpen=this.isOpen;return a}static fromJson(a,b,f){b=super.fromJson(a,
b,null!=f?f:new Nh);b.isOpen=a.isOpen;return b}};e(ba.EVENT,O.TRASHCAN_OPEN,Nh);var Vl=class extends Jf{constructor(a){super();this.workspace=a;this.id="trashcan";this.contents=[];this.flyout=null;this.isLidOpen=!1;this.minOpenness=0;this.lidTask=this.svgLid=this.svgGroup=null;this.top=this.left=this.lidOpen=0;this.initialized=!1;0>=this.workspace.options.maxTrashcanContents||(a=new zb({scrollbars:!0,parentWorkspace:this.workspace,rtl:this.workspace.RTL,oneBasedIndex:this.workspace.options.oneBasedIndex,
renderer:this.workspace.options.renderer,rendererOverrides:this.workspace.options.rendererOverrides,move:{scrollbars:!0}}),this.workspace.horizontalLayout?(a.toolboxPosition=this.workspace.toolboxPosition===xa.TOP?xa.BOTTOM:xa.TOP,this.flyout=new (I(ba.FLYOUTS_HORIZONTAL_TOOLBOX,this.workspace.options,!0))(a)):(a.toolboxPosition=this.workspace.toolboxPosition===xa.RIGHT?xa.LEFT:xa.RIGHT,this.flyout=new (I(ba.FLYOUTS_VERTICAL_TOOLBOX,this.workspace.options,!0))(a)),this.workspace.addChangeListener(this.onDelete.bind(this)))}createDom(){this.svgGroup=
T(J.G,{"class":"blocklyTrash"});let a;const b=String(Math.random()).substring(2);a=T(J.CLIPPATH,{id:"blocklyTrashBodyClipPath"+b},this.svgGroup);T(J.RECT,{width:Dd,height:Kf,y:Ed},a);const f=T(J.IMAGE,{width:96,x:-Oh,height:124,y:-Ph,"clip-path":"url(#blocklyTrashBodyClipPath"+b+")"},this.svgGroup);f.setAttributeNS(pb,"xlink:href",this.workspace.options.pathToMedia+"sprites.png");a=T(J.CLIPPATH,{id:"blocklyTrashLidClipPath"+b},this.svgGroup);T(J.RECT,{width:Dd,height:Ed},a);this.svgLid=T(J.IMAGE,
{width:96,x:-Oh,height:124,y:-Ph,"clip-path":"url(#blocklyTrashLidClipPath"+b+")"},this.svgGroup);this.svgLid.setAttributeNS(pb,"xlink:href",this.workspace.options.pathToMedia+"sprites.png");lb(this.svgGroup,"pointerdown",this,this.blockMouseDownWhenOpenable);lb(this.svgGroup,"pointerup",this,this.click);lb(f,"pointerover",this,this.mouseOver);lb(f,"pointerout",this,this.mouseOut);this.animateLid();return this.svgGroup}init(){0<this.workspace.options.maxTrashcanContents&&(ad(this.flyout.createDom(J.SVG),
this.workspace.getParentSvg()),this.flyout.init(this.workspace));this.workspace.getComponentManager().addComponent({component:this,weight:Qa.ComponentWeight.TRASHCAN_WEIGHT,capabilities:[Qa.Capability.AUTOHIDEABLE,Qa.Capability.DELETE_AREA,Qa.Capability.DRAG_TARGET,Qa.Capability.POSITIONABLE]});this.initialized=!0;this.setLidOpen(!1)}dispose(){this.workspace.getComponentManager().removeComponent("trashcan");this.svgGroup&&Ia(this.svgGroup);this.lidTask&&clearTimeout(this.lidTask)}hasContents(){return!!this.contents.length}contentsIsOpen(){return!!this.flyout&&
this.flyout.isVisible()}openFlyout(){if(!this.contentsIsOpen()){var a=this.contents.map(function(f){return JSON.parse(f)}),b=this.workspace.getParentSvg().style;b.cursor="wait";setTimeout(()=>{let f;null==(f=this.flyout)||f.show(a);b.cursor="";let g;null==(g=this.workspace.scrollbar)||g.setVisible(!1)},10);this.fireUiEvent(!0)}}closeFlyout(){if(this.contentsIsOpen()){var a;null==(a=this.flyout)||a.hide();var b;null==(b=this.workspace.scrollbar)||b.setVisible(!0);this.fireUiEvent(!1);this.workspace.recordDragTargets()}}autoHide(a){!a&&
this.flyout&&this.closeFlyout()}emptyContents(){this.hasContents()&&(this.contents.length=0,this.setMinOpenness(0),this.closeFlyout())}position(a,b){if(this.initialized){var f=hg(this.workspace,a);a=gg(f,new Aa(Dd,Kf+Ed),qo,Sl,a,this.workspace);b=ig(a,Sl,f.vertical===nc.TOP?Fc.DOWN:Fc.UP,b);this.top=b.top;this.left=b.left;var g;null==(g=this.svgGroup)||g.setAttribute("transform","translate("+this.left+","+this.top+")");var l;null==(l=this.flyout)||l.position()}}getBoundingRectangle(){return new Ja(this.top,
this.top+Kf+Ed,this.left,this.left+Dd)}getClientRect(){if(!this.svgGroup)return null;var a=this.svgGroup.getBoundingClientRect();const b=a.top+Ph-Lf;a=a.left+Oh-Lf;return new Ja(b,b+Ed+Kf+2*Lf,a,a+Dd+2*Lf)}onDragOver(a){this.setLidOpen(this.wouldDelete_)}onDragExit(a){this.setLidOpen(!1)}onDrop(a){setTimeout(this.setLidOpen.bind(this,!1),100)}setLidOpen(a){this.isLidOpen!==a&&(this.lidTask&&clearTimeout(this.lidTask),this.isLidOpen=a,this.animateLid())}animateLid(){const a=ro;var b=1/(a+1);this.lidOpen+=
this.isLidOpen?b:-b;this.lidOpen=Math.min(Math.max(this.lidOpen,this.minOpenness),1);this.setLidAngle(this.lidOpen*Tl);b=Ul+this.lidOpen*(so-Ul);this.svgGroup&&(this.svgGroup.style.opacity=`${b}`);this.lidOpen>this.minOpenness&&1>this.lidOpen&&(this.lidTask=setTimeout(this.animateLid.bind(this),to/a))}setLidAngle(a){const b=this.workspace.toolboxPosition===xa.RIGHT||this.workspace.horizontalLayout&&this.workspace.RTL;let f;null==(f=this.svgLid)||f.setAttribute("transform","rotate("+(b?-a:a)+","+(b?
4:Dd-4)+","+(Ed-2)+")")}setMinOpenness(a){this.minOpenness=a;this.isLidOpen||this.setLidAngle(a*Tl)}closeLid(){this.setLidOpen(!1)}click(){this.hasContents()&&!this.workspace.isDragging()&&this.openFlyout()}fireUiEvent(a){a=new (la(O.TRASHCAN_OPEN))(a,this.workspace.id);aa(a)}blockMouseDownWhenOpenable(a){!this.contentsIsOpen()&&this.hasContents()&&a.stopPropagation()}mouseOver(){this.hasContents()&&this.setLidOpen(!0)}mouseOut(){this.setLidOpen(!1)}onDelete(a){if(!(0>=this.workspace.options.maxTrashcanContents||
!H(a)||a.wasShadow)){if(!a.oldJson)throw Error("Encountered a delete event without proper oldJson");a=JSON.stringify(this.cleanBlockJson(a.oldJson));if(!this.contents.includes(a)){for(this.contents.unshift(a);this.contents.length>this.workspace.options.maxTrashcanContents;)this.contents.pop();this.setMinOpenness(uo)}}}cleanBlockJson(a){function b(f){if(f){delete f.id;delete f.x;delete f.y;delete f.enabled;delete f.disabledReasons;if(f.icons&&f.icons.comment){var g=f.icons.comment;delete g.height;
delete g.width;delete g.pinned}g=f.inputs;for(var l in g){var n=g[l];const x=n.block;n=n.shadow;x&&b(x);n&&b(n)}f.next&&(l=f.next,f=l.block,l=l.shadow,f&&b(f),l&&b(l))}}a=JSON.parse(JSON.stringify(a));b(a);return Object.assign({},{kind:"BLOCK"},a)}},Dd=47,Kf=44,Ed=16,Sl=20,qo=20,Lf=10,Oh=0,Ph=32,uo=.1,to=80,ro=4,Ul=1,so=1,Tl=45,Fa=class{constructor(){this.shortcuts=new Map;this.keyMap=new Map;this.reset()}reset(){this.shortcuts.clear();this.keyMap.clear()}register(a,b){if(this.shortcuts.get(a.name)&&
!b)throw Error(`Shortcut named "${a.name}" already exists.`);this.shortcuts.set(a.name,a);b=a.keyCodes;if(null==b?0:b.length)for(const f of b)this.addKeyMapping(f,a.name,!!a.allowCollision)}unregister(a){if(!this.shortcuts.get(a))return console.warn(`Keyboard shortcut named "${a}" not found.`),!1;this.removeAllKeyMappings(a);this.shortcuts.delete(a);return!0}addKeyMapping(a,b,f){a=`${a}`;const g=this.keyMap.get(a);if(g&&!f)throw Error(`Shortcut named "${b}" collides with shortcuts "${g}"`);g&&f?g.unshift(b):
this.keyMap.set(a,[b])}removeKeyMapping(a,b,f){const g=this.keyMap.get(a);if(!g)return f||console.warn(`No keyboard shortcut named "${b}" registered with key code "${a}"`),!1;const l=g.indexOf(b);if(-1<l)return g.splice(l,1),0===g.length&&this.keyMap.delete(a),!0;f||console.warn(`No keyboard shortcut named "${b}" registered with key code "${a}"`);return!1}removeAllKeyMappings(a){for(const b of this.keyMap.keys())this.removeKeyMapping(b,a,!0)}setKeyMap(a){this.keyMap.clear();for(const b in a)this.keyMap.set(b,
a[b])}getKeyMap(){const a=Object.create(null);for(const [b,f]of this.keyMap)a[b]=f;return a}getRegistry(){const a=Object.create(null);for(const [b,f]of this.shortcuts)a[b]=f;return tc(Object.create(null),a)}onKeyDown(a,b){var f=this.serializeKeyEvent(b);f=this.getShortcutNamesByKeyCode(f);if(!f)return!1;for(const g of f){f=this.shortcuts.get(g);if(!f||f.preconditionFn&&!f.preconditionFn(a))continue;let l,n;if(null==(n=(l=f).callback)?0:n.call(l,a,b,f))return!0}return!1}getShortcutNamesByKeyCode(a){return this.keyMap.get(a)||
[]}getKeyCodesByShortcutName(a){const b=[];for(const [f,g]of this.keyMap)-1<g.indexOf(a)&&b.push(f);return b}serializeKeyEvent(a){let b="";for(const f in Fa.modifierKeys)a.getModifierState(f)&&(""!==b&&(b+="+"),b+=f);""!==b&&a.keyCode?b+="+"+a.keyCode:a.keyCode&&(b=String(a.keyCode));return b}checkModifiers(a){for(const b of a)if(!(b in Fa.modifierKeys))throw Error(b+" is not a valid modifier key.");}createSerializedKey(a,b){let f="";if(b){this.checkModifiers(b);for(const g in Fa.modifierKeys)b.includes(Fa.modifierKeys[g])&&
(""!==f&&(f+="+"),f+=g)}""!==f&&a?f+="+"+a:a&&(f=`${a}`);return f}};Fa.registry=new Fa;(function(a){a=a.modifierKeys||(a.modifierKeys={});a[a.Shift=16]="Shift";a[a.Control=17]="Control";a[a.Alt=18]="Alt";a[a.Meta=91]="Meta"})(Fa||={});var fh=null,gh=null,xe={};xe.BlockPaster=ve;xe.TEST_ONLY={duplicateInternal:function(a){const b=a.toCopyData();return b?Mc(b,a.workspace):null},copyInternal:function(a){const b=a.toCopyData();fh=b;let f;gh=null!=(f=a.workspace)?f:null;return b}};xe.paste=Mc;xe.registry=
sh;var ac;(function(a){a.ESCAPE="escape";a.DELETE="delete";a.COPY="copy";a.CUT="cut";a.PASTE="paste";a.UNDO="undo";a.REDO="redo"})(ac||={});var uc=null,vc=null,ud=null;Ek();var Rb={};Rb.names=ac;Rb.registerCopy=zk;Rb.registerCut=Ak;Rb.registerDefaultShortcuts=Ek;Rb.registerDelete=yk;Rb.registerEscape=xk;Rb.registerPaste=Bk;Rb.registerRedo=Dk;Rb.registerUndo=Ck;var Qh={ProcedureSerializer:class{constructor(a,b){this.procedureModelClass=a;this.parameterModelClass=b;this.priority=75}save(a){a=a.getProcedureMap().getProcedures().map(b=>
Fk(b));return a.length?a:null}load(a,b){const f=b.getProcedureMap();for(const g of a)f.add(Gk(this.procedureModelClass,this.parameterModelClass,g,b))}clear(a){a.getProcedureMap().clear()}}};Qh.loadProcedure=Gk;Qh.saveProcedure=Fk;var Wl=class{constructor(){this.priority=100}save(a){const b=[];for(const f of a.getAllVariables())a={name:f.name,id:f.getId()},f.type&&(a.type=f.type),b.push(a);return b.length?b:null}load(a,b){for(const f of a)b.createVariable(f.name,f.type,f.id)}clear(a){a.getVariableMap().clear()}};
Oe("variables",new Wl);var Xl={};Xl.VariableSerializer=Wl;var vo={blocks:ne,exceptions:Rc,priorities:{BLOCKS:50,PROCEDURES:75,VARIABLES:100,WORKSPACE_COMMENTS:25},procedures:Qh,registry:rh,variables:Xl,workspaceComments:vf,workspaces:{load:function(a,b,{recordUndo:f=!1}={}){var g=y(ba.SERIALIZER,!0);if(g){g=Object.entries(g).sort((n,x)=>x[1].priority-n[1].priority);var l=ea();d.setRecordUndo$$module$build$src$core$events$utils(f);(f=d.getGroup$$module$build$src$core$events$utils())||d.setGroup$$module$build$src$core$events$utils(!0);
cd();b instanceof ob&&b.setResizesEnabled(!1);for(const [,n]of g.reverse()){let x;null==(x=n)||x.clear(b)}for(const [n,x]of g.reverse())if(a[n]){let B;null==(B=x)||B.load(a[n],b)}b instanceof ob&&b.setResizesEnabled(!0);dd();aa(new (la(O.FINISHED_LOADING))(b));d.setGroup$$module$build$src$core$events$utils(f);d.setRecordUndo$$module$build$src$core$events$utils(l)}},save:function(a){const b=Object.create(null),f=y(ba.SERIALIZER,!0);for(const g in f){let l;const n=null==(l=f[g])?void 0:l.save(a);n&&
(b[g]=n)}return b}}},ih=class{constructor(a,b,f,g,l){this.workspace=a;this.oldHostMetrics=this.corner_=this.vScroll=this.hScroll=null;b=void 0===b?!0:b;f=void 0===f?!0:f;const n=b&&f;b&&(this.hScroll=new Sa(a,!0,n,g,l));f&&(this.vScroll=new Sa(a,!1,n,g,l));n&&(this.corner_=T(J.RECT,{height:Sa.scrollbarThickness,width:Sa.scrollbarThickness,"class":"blocklyScrollbarBackground"}),ad(this.corner_,a.getBubbleCanvas()))}dispose(){Ia(this.corner_);this.oldHostMetrics=this.corner_=null;this.hScroll&&(this.hScroll.dispose(),
this.hScroll=null);this.vScroll&&(this.vScroll.dispose(),this.vScroll=null)}resize(){const a=this.workspace.getMetrics();if(a){var b=!1,f=!1;this.oldHostMetrics&&this.oldHostMetrics.viewWidth===a.viewWidth&&this.oldHostMetrics.viewHeight===a.viewHeight&&this.oldHostMetrics.absoluteTop===a.absoluteTop&&this.oldHostMetrics.absoluteLeft===a.absoluteLeft?(this.oldHostMetrics&&this.oldHostMetrics.scrollWidth===a.scrollWidth&&this.oldHostMetrics.viewLeft===a.viewLeft&&this.oldHostMetrics.scrollLeft===a.scrollLeft||
(b=!0),this.oldHostMetrics&&this.oldHostMetrics.scrollHeight===a.scrollHeight&&this.oldHostMetrics.viewTop===a.viewTop&&this.oldHostMetrics.scrollTop===a.scrollTop||(f=!0)):f=b=!0;if(b||f){try{d.disable$$module$build$src$core$events$utils(),this.hScroll&&b&&this.hScroll.resize(a),this.vScroll&&f&&this.vScroll.resize(a)}finally{d.enable$$module$build$src$core$events$utils()}this.workspace.maybeFireViewportChangeEvent()}if(this.hScroll&&this.vScroll){if(!this.oldHostMetrics||this.oldHostMetrics.viewWidth!==
a.viewWidth||this.oldHostMetrics.absoluteLeft!==a.absoluteLeft){let g;null==(g=this.corner_)||g.setAttribute("x",String(this.vScroll.position.x))}if(!this.oldHostMetrics||this.oldHostMetrics.viewHeight!==a.viewHeight||this.oldHostMetrics.absoluteTop!==a.absoluteTop){let g;null==(g=this.corner_)||g.setAttribute("y",String(this.hScroll.position.y))}}this.oldHostMetrics=a}}canScrollHorizontally(){return!!this.hScroll}canScrollVertically(){return!!this.vScroll}setOrigin(a,b){this.hScroll&&this.hScroll.setOrigin(a,
b);this.vScroll&&this.vScroll.setOrigin(a,b)}set(a,b,f){this.hScroll&&this.hScroll.set(a,!1);this.vScroll&&this.vScroll.set(b,!1);if(f||void 0===f)a={},this.hScroll&&(a.x=this.hScroll.getRatio_()),this.vScroll&&(a.y=this.vScroll.getRatio_()),this.workspace.setMetrics(a)}setX(a){this.hScroll&&this.hScroll.set(a,!0)}setY(a){this.vScroll&&this.vScroll.set(a,!0)}setContainerVisible(a){this.hScroll&&this.hScroll.setContainerVisible(a);this.vScroll&&this.vScroll.setContainerVisible(a)}isVisible(){let a=
!1;this.hScroll&&(a=this.hScroll.isVisible());this.vScroll&&(a=a||this.vScroll.isVisible());return a}setVisible(a){this.hScroll&&this.hScroll.setVisibleInternal(a);this.vScroll&&this.vScroll.setVisibleInternal(a)}resizeContent(a){this.hScroll&&this.hScroll.resizeContentHorizontal(a);this.vScroll&&this.vScroll.resizeContentVertical(a)}resizeView(a){this.hScroll&&this.hScroll.resizeViewHorizontal(a);this.vScroll&&this.vScroll.resizeViewVertical(a)}},Rh=class{constructor(a){this.workspace_=a}getDimensionsPx_(a){let b=
0,f=0;a&&(b=a.getWidth(),f=a.getHeight());return new Aa(b,f)}getFlyoutMetrics(a){a=this.getDimensionsPx_(this.workspace_.getFlyout(a));return{width:a.width,height:a.height,position:this.workspace_.toolboxPosition}}getToolboxMetrics(){const a=this.getDimensionsPx_(this.workspace_.getToolbox());return{width:a.width,height:a.height,position:this.workspace_.toolboxPosition}}getSvgMetrics(){return this.workspace_.getCachedParentSvgSize()}getAbsoluteMetrics(){let a=0,b=0;const f=this.getToolboxMetrics(),
g=this.getFlyoutMetrics(),l=!!this.workspace_.getToolbox();var n;const x=!(null==(n=this.workspace_.getFlyout())?0:n.autoClose);n=l?f.position:g.position;const B=n===xa.TOP;n===xa.LEFT&&(l&&(a+=f.width),x&&(a+=g.width));B&&(l&&(b+=f.height),x&&(b+=g.height));return{top:b,left:a}}getViewMetrics(a){a=a?this.workspace_.scale:1;const b=this.getSvgMetrics(),f=this.getToolboxMetrics(),g=this.getFlyoutMetrics(),l=!!this.workspace_.getToolbox();var n;const x=!(null==(n=this.workspace_.getFlyout())?0:n.autoClose);
n=l?f.position:g.position;const B=n===xa.LEFT||n===xa.RIGHT;if(n===xa.TOP||n===xa.BOTTOM)l&&(b.height-=f.height),x&&(b.height-=g.height);B&&(l&&(b.width-=f.width),x&&(b.width-=g.width));return{height:b.height/a,width:b.width/a,top:-this.workspace_.scrollY/a,left:-this.workspace_.scrollX/a}}getContentMetrics(a){a=a?1:this.workspace_.scale;const b=this.workspace_.getBlocksBoundingBox();return{height:(b.bottom-b.top)*a,width:(b.right-b.left)*a,top:b.top*a,left:b.left*a}}hasFixedEdges(){return!this.workspace_.isMovableHorizontally()||
!this.workspace_.isMovableVertically()}getComputedFixedEdges_(a){if(!this.hasFixedEdges())return{};const b=this.workspace_.isMovableHorizontally(),f=this.workspace_.isMovableVertically();a=a||this.getViewMetrics(!1);const g={};f||(g.top=a.top,g.bottom=a.top+a.height);b||(g.left=a.left,g.right=a.left+a.width);return g}getPaddedContent_(a,b){const f=b.top+b.height,g=b.left+b.width,l=a.width;a=a.height;const n=l/2,x=a/2;return{top:Math.min(b.top-x,f-a),bottom:Math.max(f+x,b.top+a),left:Math.min(b.left-
n,g-l),right:Math.max(g+n,b.left+l)}}getScrollMetrics(a,b,f){a=a?this.workspace_.scale:1;b=b||this.getViewMetrics(!1);var g=f||this.getContentMetrics();f=this.getComputedFixedEdges_(b);b=this.getPaddedContent_(b,g);g=void 0!==f.top?f.top:b.top;const l=void 0!==f.left?f.left:b.left;return{top:g/a,left:l/a,width:((void 0!==f.right?f.right:b.right)-l)/a,height:((void 0!==f.bottom?f.bottom:b.bottom)-g)/a}}getUiMetrics(){return{viewMetrics:this.getViewMetrics(),absoluteMetrics:this.getAbsoluteMetrics(),
toolboxMetrics:this.getToolboxMetrics()}}getMetrics(){const a=this.getToolboxMetrics(),b=this.getFlyoutMetrics(!0),f=this.getSvgMetrics(),g=this.getAbsoluteMetrics(),l=this.getViewMetrics(),n=this.getContentMetrics(),x=this.getScrollMetrics(!1,l,n);return{contentHeight:n.height,contentWidth:n.width,contentTop:n.top,contentLeft:n.left,scrollHeight:x.height,scrollWidth:x.width,scrollTop:x.top,scrollLeft:x.left,viewHeight:l.height,viewWidth:l.width,viewTop:l.top,viewLeft:l.left,absoluteTop:g.top,absoluteLeft:g.left,
svgHeight:f.height,svgWidth:f.width,toolboxWidth:a.width,toolboxHeight:a.height,toolboxPosition:a.position,flyoutWidth:b.width,flyoutHeight:b.height}}};e(ba.METRICS_MANAGER,Jb,Rh);"Blockly"in globalThis||(globalThis.Blockly={Msg:ko});var Yl=class extends Ef{constructor(){super();this.GRID_UNIT=4;this.CURSOR_COLOUR="#ffa200";this.CURSOR_RADIUS=5;this.JAGGED_TEETH_WIDTH=this.JAGGED_TEETH_HEIGHT=0;this.START_HAT_HEIGHT=22;this.START_HAT_WIDTH=96;this.SHAPES={HEXAGONAL:1,ROUND:2,SQUARE:3,PUZZLE:4,NOTCH:5};
this.SHAPE_IN_SHAPE_PADDING={1:{0:5*this.GRID_UNIT,1:2*this.GRID_UNIT,2:5*this.GRID_UNIT,3:5*this.GRID_UNIT},2:{0:3*this.GRID_UNIT,1:3*this.GRID_UNIT,2:1*this.GRID_UNIT,3:2*this.GRID_UNIT},3:{0:2*this.GRID_UNIT,1:2*this.GRID_UNIT,2:2*this.GRID_UNIT,3:2*this.GRID_UNIT}};this.FULL_BLOCK_FIELDS=!0;this.FIELD_TEXT_FONTWEIGHT="bold";this.FIELD_TEXT_FONTFAMILY='"Helvetica Neue", "Segoe UI", Helvetica, sans-serif';this.FIELD_COLOUR_FULL_BLOCK=this.FIELD_TEXTINPUT_BOX_SHADOW=this.FIELD_DROPDOWN_SVG_ARROW=
this.FIELD_DROPDOWN_COLOURED_DIV=this.FIELD_DROPDOWN_NO_BORDER_RECT_SHADOW=!0;this.SELECTED_GLOW_COLOUR="#fff200";this.SELECTED_GLOW_SIZE=.5;this.REPLACEMENT_GLOW_COLOUR="#fff200";this.REPLACEMENT_GLOW_SIZE=2;this.selectedGlowFilterId="";this.selectedGlowFilter=null;this.replacementGlowFilterId="";this.SQUARED=this.ROUNDED=this.HEXAGONAL=this.replacementGlowFilter=null;this.SMALL_PADDING=this.GRID_UNIT;this.MEDIUM_PADDING=2*this.GRID_UNIT;this.MEDIUM_LARGE_PADDING=3*this.GRID_UNIT;this.LARGE_PADDING=
4*this.GRID_UNIT;this.CORNER_RADIUS=1*this.GRID_UNIT;this.NOTCH_WIDTH=9*this.GRID_UNIT;this.NOTCH_HEIGHT=2*this.GRID_UNIT;this.STATEMENT_INPUT_NOTCH_OFFSET=this.NOTCH_OFFSET_LEFT=3*this.GRID_UNIT;this.MIN_BLOCK_WIDTH=2*this.GRID_UNIT;this.MIN_BLOCK_HEIGHT=12*this.GRID_UNIT;this.EMPTY_STATEMENT_INPUT_HEIGHT=6*this.GRID_UNIT;this.TOP_ROW_MIN_HEIGHT=this.CORNER_RADIUS;this.TOP_ROW_PRECEDES_STATEMENT_MIN_HEIGHT=this.LARGE_PADDING;this.BOTTOM_ROW_MIN_HEIGHT=this.CORNER_RADIUS;this.BOTTOM_ROW_AFTER_STATEMENT_MIN_HEIGHT=
6*this.GRID_UNIT;this.STATEMENT_BOTTOM_SPACER=-this.NOTCH_HEIGHT;this.STATEMENT_INPUT_SPACER_MIN_WIDTH=40*this.GRID_UNIT;this.STATEMENT_INPUT_PADDING_LEFT=4*this.GRID_UNIT;this.EMPTY_INLINE_INPUT_PADDING=4*this.GRID_UNIT;this.EMPTY_INLINE_INPUT_HEIGHT=8*this.GRID_UNIT;this.DUMMY_INPUT_MIN_HEIGHT=8*this.GRID_UNIT;this.DUMMY_INPUT_SHADOW_MIN_HEIGHT=6*this.GRID_UNIT;this.CURSOR_WS_WIDTH=20*this.GRID_UNIT;this.FIELD_TEXT_FONTSIZE=3*this.GRID_UNIT;this.FIELD_BORDER_RECT_RADIUS=this.CORNER_RADIUS;this.FIELD_BORDER_RECT_X_PADDING=
2*this.GRID_UNIT;this.FIELD_BORDER_RECT_Y_PADDING=1.625*this.GRID_UNIT;this.FIELD_BORDER_RECT_HEIGHT=8*this.GRID_UNIT;this.FIELD_DROPDOWN_BORDER_RECT_HEIGHT=8*this.GRID_UNIT;this.FIELD_DROPDOWN_SVG_ARROW_PADDING=this.FIELD_BORDER_RECT_X_PADDING;this.FIELD_COLOUR_DEFAULT_WIDTH=6*this.GRID_UNIT;this.FIELD_COLOUR_DEFAULT_HEIGHT=8*this.GRID_UNIT;this.FIELD_CHECKBOX_X_OFFSET=1*this.GRID_UNIT;this.MAX_DYNAMIC_CONNECTION_SHAPE_WIDTH=12*this.GRID_UNIT}setFontConstants_(a){super.setFontConstants_(a);this.FIELD_DROPDOWN_BORDER_RECT_HEIGHT=
this.FIELD_BORDER_RECT_HEIGHT=this.FIELD_TEXT_HEIGHT+2*this.FIELD_BORDER_RECT_Y_PADDING}init(){super.init();this.HEXAGONAL=this.makeHexagonal();this.ROUNDED=this.makeRounded();this.SQUARED=this.makeSquared();this.STATEMENT_INPUT_NOTCH_OFFSET=this.NOTCH_OFFSET_LEFT+this.INSIDE_CORNERS.rightWidth}setDynamicProperties_(a){super.setDynamicProperties_(a);this.SELECTED_GLOW_COLOUR=a.getComponentStyle("selectedGlowColour")||this.SELECTED_GLOW_COLOUR;const b=Number(a.getComponentStyle("selectedGlowSize"));
this.SELECTED_GLOW_SIZE=b&&!isNaN(b)?b:this.SELECTED_GLOW_SIZE;this.REPLACEMENT_GLOW_COLOUR=a.getComponentStyle("replacementGlowColour")||this.REPLACEMENT_GLOW_COLOUR;this.REPLACEMENT_GLOW_SIZE=(a=Number(a.getComponentStyle("replacementGlowSize")))&&!isNaN(a)?a:this.REPLACEMENT_GLOW_SIZE}dispose(){super.dispose();this.selectedGlowFilter&&Ia(this.selectedGlowFilter);this.replacementGlowFilter&&Ia(this.replacementGlowFilter)}makeStartHat(){const a=this.START_HAT_HEIGHT,b=this.START_HAT_WIDTH,f=nb("c",
[qa(25,-a),qa(71,-a),qa(b,0)]);return{height:a,width:b,path:f}}makeHexagonal(){function a(f,g,l){var n=f/2;n=n>b?b:n;l=l?-1:1;f=(g?-1:1)*f/2;return $b(-l*n,f)+$b(l*n,f)}const b=this.MAX_DYNAMIC_CONNECTION_SHAPE_WIDTH;return{type:this.SHAPES.HEXAGONAL,isDynamic:!0,width(f){f/=2;return f>b?b:f},height(f){return f},connectionOffsetY(f){return f/2},connectionOffsetX(f){return-f},pathDown(f){return a(f,!1,!1)},pathUp(f){return a(f,!0,!1)},pathRightDown(f){return a(f,!1,!0)},pathRightUp(f){return a(f,!1,
!0)}}}makeRounded(){function a(g,l,n){const x=g>f?g-f:0;g=(g>f?f:g)/2;const B=n===l?"0":"1";return Va("a","0 0,"+B,g,qa((n?1:-1)*g,(l?-1:1)*g))+pa("v",(l?-1:1)*x)+Va("a","0 0,"+B,g,qa((n?-1:1)*g,(l?-1:1)*g))}const b=this.MAX_DYNAMIC_CONNECTION_SHAPE_WIDTH,f=2*b;return{type:this.SHAPES.ROUND,isDynamic:!0,width(g){g/=2;return g>b?b:g},height(g){return g},connectionOffsetY(g){return g/2},connectionOffsetX(g){return-g},pathDown(g){return a(g,!1,!1)},pathUp(g){return a(g,!0,!1)},pathRightDown(g){return a(g,
!1,!0)},pathRightUp(g){return a(g,!1,!0)}}}makeSquared(){function a(f,g,l){f-=2*b;const n=l===g?"0":"1";return Va("a","0 0,"+n,b,qa((l?1:-1)*b,(g?-1:1)*b))+pa("v",(g?-1:1)*f)+Va("a","0 0,"+n,b,qa((l?-1:1)*b,(g?-1:1)*b))}const b=this.CORNER_RADIUS;return{type:this.SHAPES.SQUARE,isDynamic:!0,width(f){return b},height(f){return f},connectionOffsetY(f){return f/2},connectionOffsetX(f){return-f},pathDown(f){return a(f,!1,!1)},pathUp(f){return a(f,!0,!1)},pathRightDown(f){return a(f,!1,!0)},pathRightUp(f){return a(f,
!1,!0)}}}shapeFor(a){let b=a.getCheck();!b&&a.targetConnection&&(b=a.targetConnection.getCheck());switch(a.type){case oa.INPUT_VALUE:case oa.OUTPUT_VALUE:a=a.getSourceBlock().getOutputShape();if(null!==a)switch(a){case this.SHAPES.HEXAGONAL:return this.HEXAGONAL;case this.SHAPES.ROUND:return this.ROUNDED;case this.SHAPES.SQUARE:return this.SQUARED}if(b&&b.includes("Boolean"))return this.HEXAGONAL;if(b&&b.includes("Number"))return this.ROUNDED;b&&b.includes("String");return this.ROUNDED;case oa.PREVIOUS_STATEMENT:case oa.NEXT_STATEMENT:return this.NOTCH;
default:throw Error("Unknown type");}}makeNotch(){function a(na){return nb("c",[qa(na*l/2,0),qa(na*l*3/4,x/2),qa(na*l,x)])+ge([qa(na*l,n)])+nb("c",[qa(na*l/4,x/2),qa(na*l/2,x),qa(na*l,x)])+pa("h",na*g)+nb("c",[qa(na*l/2,0),qa(na*l*3/4,-(x/2)),qa(na*l,-x)])+ge([qa(na*l,-n)])+nb("c",[qa(na*l/4,-(x/2)),qa(na*l/2,-x),qa(na*l,-x)])}const b=this.NOTCH_WIDTH,f=this.NOTCH_HEIGHT,g=b/3,l=g/3,n=f/2,x=n/2,B=a(1),V=a(-1);return{type:this.SHAPES.NOTCH,width:b,height:f,pathLeft:B,pathRight:V}}makeInsideCorners(){const a=
this.CORNER_RADIUS,b=Va("a","0 0,0",a,qa(-a,a)),f=Va("a","0 0,1",a,qa(-a,a)),g=Va("a","0 0,0",a,qa(a,a)),l=Va("a","0 0,1",a,qa(a,a));return{width:a,height:a,pathTop:b,pathBottom:g,rightWidth:a,rightHeight:a,pathTopRight:f,pathBottomRight:l}}generateSecondaryColour_(a){return kd("#000",a,.15)||a}generateTertiaryColour_(a){return kd("#000",a,.25)||a}createDom(a,b,f){super.createDom(a,b,f);a=T(J.DEFS,{},a);b=T(J.FILTER,{id:"blocklySelectedGlowFilter"+this.randomIdentifier,height:"160%",width:"180%",
y:"-30%",x:"-40%"},a);T(J.FEGAUSSIANBLUR,{"in":"SourceGraphic",stdDeviation:this.SELECTED_GLOW_SIZE},b);f=T(J.FECOMPONENTTRANSFER,{result:"outBlur"},b);T(J.FEFUNCA,{type:"table",tableValues:"0 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1"},f);T(J.FEFLOOD,{"flood-color":this.SELECTED_GLOW_COLOUR,"flood-opacity":1,result:"outColor"},b);T(J.FECOMPOSITE,{"in":"outColor",in2:"outBlur",operator:"in",result:"outGlow"},b);this.selectedGlowFilterId=b.id;this.selectedGlowFilter=b;a=T(J.FILTER,{id:"blocklyReplacementGlowFilter"+
this.randomIdentifier,height:"160%",width:"180%",y:"-30%",x:"-40%"},a);T(J.FEGAUSSIANBLUR,{"in":"SourceGraphic",stdDeviation:this.REPLACEMENT_GLOW_SIZE},a);b=T(J.FECOMPONENTTRANSFER,{result:"outBlur"},a);T(J.FEFUNCA,{type:"table",tableValues:"0 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1"},b);T(J.FEFLOOD,{"flood-color":this.REPLACEMENT_GLOW_COLOUR,"flood-opacity":1,result:"outColor"},a);T(J.FECOMPOSITE,{"in":"outColor",in2:"outBlur",operator:"in",result:"outGlow"},a);T(J.FECOMPOSITE,{"in":"SourceGraphic",in2:"outGlow",
operator:"over"},a);this.replacementGlowFilterId=a.id;this.replacementGlowFilter=a}getCSS_(a){return[`${a} .blocklyText,`,`${a} .blocklyFlyoutLabelText {`,`font: ${this.FIELD_TEXT_FONTWEIGHT} ${this.FIELD_TEXT_FONTSIZE}`+`pt ${this.FIELD_TEXT_FONTFAMILY};`,"}",`${a} .blocklyTextInputBubble textarea {`,"font-weight: normal;","}",`${a} .blocklyText {`,"fill: #fff;","}",`${a} .blocklyNonEditableText>rect:not(.blocklyDropdownRect),`,`${a} .blocklyEditableText>rect:not(.blocklyDropdownRect) {`,`fill: ${this.FIELD_BORDER_RECT_COLOUR};`,
"}",`${a} .blocklyNonEditableText>text,`,`${a} .blocklyEditableText>text,`,`${a} .blocklyNonEditableText>g>text,`,`${a} .blocklyEditableText>g>text {`,"fill: #575E75;","}",`${a} .blocklyFlyoutLabelText {`,"fill: #575E75;","}",`${a} .blocklyText.blocklyBubbleText {`,"fill: #575E75;","}",`${a} .blocklyDraggable:not(.blocklyDisabled)`," .blocklyEditableText:not(.editing):hover>rect,",`${a} .blocklyDraggable:not(.blocklyDisabled)`," .blocklyEditableText:not(.editing):hover>.blocklyPath {","stroke: #fff;",
"stroke-width: 2;","}",`${a} .blocklyHtmlInput {`,`font-family: ${this.FIELD_TEXT_FONTFAMILY};`,`font-weight: ${this.FIELD_TEXT_FONTWEIGHT};`,"color: #575E75;","}",`${a} .blocklyDropdownText {`,"fill: #fff !important;","}",`${a}.blocklyWidgetDiv .blocklyMenuItem,`,`${a}.blocklyDropDownDiv .blocklyMenuItem {`,`font-family: ${this.FIELD_TEXT_FONTFAMILY};`,"}",`${a}.blocklyDropDownDiv .blocklyMenuItemContent {`,"color: #fff;","}",`${a} .blocklyHighlightedConnectionPath {`,`stroke: ${this.SELECTED_GLOW_COLOUR};`,
"}",`${a} .blocklyDisabled > .blocklyOutlinePath {`,`fill: url(#blocklyDisabledPattern${this.randomIdentifier})`,"}",`${a} .blocklyInsertionMarker>.blocklyPath {`,`fill-opacity: ${this.INSERTION_MARKER_OPACITY};`,"stroke: none;","}"]}},Zl=class extends Ff{constructor(a,b){super(a,b)}draw(){const a=this.block_.pathObject;a.beginDrawing();this.drawOutline_();this.drawInternals_();this.updateConnectionHighlights();a.setPath(this.outlinePath_+"\n"+this.inlinePath_);this.info_.RTL&&a.flipRTL();this.recordSizeOnBlock_();
this.info_.outputConnection&&(a.outputShapeType=this.info_.outputConnection.shape.type);a.endDrawing()}drawOutline_(){this.info_.outputConnection&&this.info_.outputConnection.isDynamicShape&&!this.info_.hasStatementInput&&!this.info_.bottomRow.hasNextConnection?(this.drawFlatTop_(),this.drawRightDynamicConnection_(),this.drawFlatBottom_(),this.drawLeftDynamicConnection_()):super.drawOutline_()}drawLeft_(){this.info_.outputConnection&&this.info_.outputConnection.isDynamicShape?this.drawLeftDynamicConnection_():
super.drawLeft_()}drawRightSideRow_(a){if(!(0>=a.height)){if(G.isSpacer(a)){const g=a.precedesStatement;var b=a.followsStatement;if(g||b){const l=this.constants_.INSIDE_CORNERS;var f=l.rightHeight;f=a.height-(g?f:0);b=b?l.pathBottomRight:"";a=0<f?pa("V",a.yPos+f):"";this.outlinePath_+=b+a+(g?l.pathTopRight:"");return}}this.outlinePath_+=pa("V",a.yPos+a.height)}}drawRightDynamicConnection_(){if(!this.info_.outputConnection)throw Error("Cannot draw the output connection of a block that doesn't have one");
this.outlinePath_+=this.info_.outputConnection.shape.pathRightDown(this.info_.outputConnection.height)}drawLeftDynamicConnection_(){if(!this.info_.outputConnection)throw Error("Cannot draw the output connection of a block that doesn't have one");this.positionOutputConnection_();this.outlinePath_+=this.info_.outputConnection.shape.pathUp(this.info_.outputConnection.height);this.outlinePath_+="z"}drawFlatTop_(){const a=this.info_.topRow;this.positionPreviousConnection_();this.outlinePath_+=Oa(a.xPos,
this.info_.startY);this.outlinePath_+=pa("h",a.width)}drawFlatBottom_(){const a=this.info_.bottomRow;this.positionNextConnection_();this.outlinePath_+=pa("V",a.baseline);this.outlinePath_+=pa("h",-a.width)}drawInlineInput_(a){this.positionInlineInputConnection_(a);const b=a.input.name;a.connectedBlock||this.info_.isInsertionMarker||(a=Za(a.xPos+a.connectionWidth,a.centerline-a.height/2)+this.getInlineInputPath(a),this.block_.pathObject.setOutlinePath(b,a))}getInlineInputPath(a){const b=a.width-2*
a.connectionWidth,f=a.height;return pa("h",b)+a.shape.pathRightDown(f)+pa("h",-b)+a.shape.pathUp(f)+"z"}drawStatementInput_(a){var b=a.getLastInput();const f=b.xPos+b.notchOffset+b.shape.width,g=this.constants_.INSIDE_CORNERS,l=b.shape.pathRight+pa("h",-(b.notchOffset-g.width))+g.pathTop,n=a.height-2*g.height;b=g.pathBottom+pa("h",b.notchOffset-g.width)+(b.connectedBottomNextConnection?"":b.shape.pathLeft);this.outlinePath_+=pa("H",f)+l+pa("v",n)+b+pa("H",a.xPos+a.width);this.positionStatementInputConnection_(a)}drawConnectionHighlightPath(a){const b=
a.connectionModel;if(b.type===oa.NEXT_STATEMENT||b.type===oa.PREVIOUS_STATEMENT||b.type===oa.OUTPUT_VALUE&&!a.isDynamicShape)super.drawConnectionHighlightPath(a);else{a=b.type===oa.INPUT_VALUE?Za(a.connectionWidth,-a.height/2)+this.getInlineInputPath(a):Za(a.width,-a.height/2)+a.shape.pathDown(a.height);var f=b.getSourceBlock(),g,l;null==(l=(g=f.pathObject).addConnectionHighlight)||l.call(g,b,a,b.getOffsetInBlock(),f.RTL)}}},Zc=class extends Ka{constructor(a,b,f,g,l,n,x){super(Ka.SKIP_SETUP);this.imageElement=
this.clickHandler=null;this.flipRtl=this.isDirty_=this.EDITABLE=!1;this.altText="";f=Number(Ua(f));b=Number(Ua(b));if(isNaN(f)||isNaN(b))throw Error("Height and width values of an image field must cast to numbers.");if(0>=f||0>=b)throw Error("Height and width values of an image field must be greater than 0.");this.size_=new Aa(b,f+Zc.Y_PADDING);this.imageHeight=f;"function"===typeof l&&(this.clickHandler=l);a!==Ka.SKIP_SETUP&&(x?this.configure_(x):(this.flipRtl=!!n,this.altText=Ua(g)||""),this.setValue(Ua(a)))}configure_(a){super.configure_(a);
a.flipRtl&&(this.flipRtl=a.flipRtl);a.alt&&(this.altText=Ua(a.alt))}initView(){this.imageElement=T(J.IMAGE,{height:this.imageHeight+"px",width:this.size_.width+"px",alt:this.altText},this.fieldGroup_);this.imageElement.setAttributeNS(pb,"xlink:href",this.value_);this.clickHandler&&(this.imageElement.style.cursor="pointer")}updateSize_(){}doClassValidation_(a){return"string"!==typeof a?null:a}doValueUpdate_(a){this.value_=a;this.imageElement&&this.imageElement.setAttributeNS(pb,"xlink:href",this.value_)}getFlipRtl(){return this.flipRtl}setAlt(a){a!==
this.altText&&(this.altText=a||"",this.imageElement&&this.imageElement.setAttribute("alt",this.altText))}showEditor_(){this.clickHandler&&this.clickHandler(this)}setOnClickHandler(a){this.clickHandler=a}getText_(){return this.altText}static fromJson(a){if(!a.src||!a.width||!a.height)throw Error("src, width, and height values for an image field arerequired. The width and height must be non-zero.");return new this(a.src,a.width,a.height,void 0,void 0,void 0,a)}};Zc.Y_PADDING=1;Zb("field_image",Zc);
Zc.prototype.DEFAULT_VALUE="";var Mf=class extends Ka{constructor(a,b,f){super(Ka.SKIP_SETUP);this.spellcheck_=!0;this.htmlInput_=null;this.isTextValid_=this.isBeingEdited_=!1;this.onKeyInputWrapper=this.onKeyDownWrapper=this.valueWhenEditorWasOpened_=null;this.fullBlockClickTarget_=!1;this.workspace_=null;this.SERIALIZABLE=!0;this.CURSOR="text";a!==Ka.SKIP_SETUP&&(f&&this.configure_(f),this.setValue(a),b&&this.setValidator(b))}configure_(a){super.configure_(a);void 0!==a.spellcheck&&(this.spellcheck_=
a.spellcheck)}initView(){if(!this.getSourceBlock())throw new Ta;super.initView();this.isFullBlockField()&&(this.clickTarget_=this.sourceBlock_.getSvgRoot())}isFullBlockField(){const a=this.getSourceBlock();if(!a)throw new Ta;let b;return this.fullBlockClickTarget_=!(null==(b=this.getConstants())||!b.FULL_BLOCK_FIELDS)&&a.isSimpleReporter()}doValueInvalid_(a,b=!0){this.isBeingEdited_&&(this.isDirty_=!0,this.isTextValid_=!1,a=this.value_,this.value_=this.valueWhenEditorWasOpened_,this.sourceBlock_&&
ia()&&this.value_!==a&&b&&aa(new (la(O.BLOCK_CHANGE))(this.sourceBlock_,"field",this.name||null,a,this.value_)))}doValueUpdate_(a){this.isTextValid_=this.isDirty_=!0;this.value_=a}applyColour(){const a=this.getSourceBlock();if(!a)throw new Ta;this.getConstants().FULL_BLOCK_FIELDS&&this.fieldGroup_&&(!this.isFullBlockField()&&this.borderRect_?(this.borderRect_.style.display="block",this.borderRect_.setAttribute("stroke",a.getColourTertiary())):(this.borderRect_.style.display="none",a.pathObject.svgPath.setAttribute("fill",
this.getConstants().FIELD_BORDER_RECT_COLOUR)))}getSize(){let a;if(null==(a=this.getConstants())?0:a.FULL_BLOCK_FIELDS)this.render_(),this.isDirty_=!1;return super.getSize()}onLocationChange(){this.isBeingEdited_&&this.resizeEditor_()}render_(){super.render_();if(this.isBeingEdited_){var a=this.htmlInput_;this.isTextValid_?(Ma(a,"blocklyInvalidInput"),bb(a,ab.INVALID,!1)):(sa(a,"blocklyInvalidInput"),bb(a,ab.INVALID,!0))}a=this.getSourceBlock();if(!a)throw new Ta;this.getConstants().FULL_BLOCK_FIELDS&&
a.applyColour()}setSpellcheck(a){a!==this.spellcheck_&&(this.spellcheck_=a,this.htmlInput_&&this.htmlInput_.setAttribute("spellcheck",this.spellcheck_))}showEditor_(a,b=!1){this.workspace_=this.sourceBlock_.workspace;!b&&this.workspace_.options.modalInputs&&(ll||ph||uf)?this.showPromptEditor():this.showInlineEditor(b)}showPromptEditor(){pg(d.Msg$$module$build$src$core$msg.CHANGE_VALUE_TITLE,this.getText(),a=>{null!==a&&this.setValue(this.getValueFromEditorText_(a));this.onFinishEditing_(this.value_)})}showInlineEditor(a){const b=
this.getSourceBlock();if(!b)throw new Ta;Pg(this,b.RTL,this.widgetDispose_.bind(this),this.workspace_);this.htmlInput_=this.widgetCreate_();this.isBeingEdited_=!0;this.valueWhenEditorWasOpened_=this.value_;a||(this.htmlInput_.focus({preventScroll:!0}),this.htmlInput_.select())}widgetCreate_(){var a=this.getSourceBlock();if(!a)throw new Ta;d.setGroup$$module$build$src$core$events$utils(!0);const b=ld();var f=this.getClickTarget_();if(!f)throw Error("A click target has not been set.");sa(f,"editing");
f=document.createElement("input");f.className="blocklyHtmlInput";f.setAttribute("spellcheck",this.spellcheck_);const g=this.workspace_.getScale();var l=this.getConstants().FIELD_TEXT_FONTSIZE*g+"pt";b.style.fontSize=l;f.style.fontSize=l;l=Mf.BORDERRADIUS*g+"px";this.isFullBlockField()&&(l=this.getScaledBBox(),l=(l.bottom-l.top)/2+"px",a=a.getParent()?a.getParent().getColourTertiary():this.sourceBlock_.getColourTertiary(),f.style.border=1*g+"px solid "+a,b.style.borderRadius=l,b.style.transition="box-shadow 0.25s ease 0s",
this.getConstants().FIELD_TEXTINPUT_BOX_SHADOW&&(b.style.boxShadow="rgba(255, 255, 255, 0.3) 0 0 0 "+4*g+"px"));f.style.borderRadius=l;b.appendChild(f);f.value=f.defaultValue=this.getEditorText_(this.value_);f.setAttribute("data-untyped-default-value",String(this.value_));this.resizeEditor_();this.bindInputEvents_(f);return f}widgetDispose_(){this.isBeingEdited_=!1;this.isTextValid_=!0;this.forceRerender();this.onFinishEditing_(this.value_);this.sourceBlock_&&ia()&&null!==this.valueWhenEditorWasOpened_&&
this.valueWhenEditorWasOpened_!==this.value_&&(aa(new (la(O.BLOCK_CHANGE))(this.sourceBlock_,"field",this.name||null,this.valueWhenEditorWasOpened_,this.value_)),this.valueWhenEditorWasOpened_=null);d.setGroup$$module$build$src$core$events$utils(!1);this.unbindInputEvents_();var a=ld().style;a.width="auto";a.height="auto";a.fontSize="";a.transition="";a.boxShadow="";this.htmlInput_=null;a=this.getClickTarget_();if(!a)throw Error("A click target has not been set.");Ma(a,"editing")}onFinishEditing_(a){}bindInputEvents_(a){this.onKeyDownWrapper=
ta(a,"keydown",this,this.onHtmlInputKeyDown_);this.onKeyInputWrapper=ta(a,"input",this,this.onHtmlInputChange)}unbindInputEvents_(){this.onKeyDownWrapper&&(Na(this.onKeyDownWrapper),this.onKeyDownWrapper=null);this.onKeyInputWrapper&&(Na(this.onKeyInputWrapper),this.onKeyInputWrapper=null)}onHtmlInputKeyDown_(a){"Enter"===a.key?(pd(this),Yb()):"Escape"===a.key?(this.setValue(this.htmlInput_.getAttribute("data-untyped-default-value"),!1),pd(this),Yb()):"Tab"===a.key&&(pd(this),Yb(),this.sourceBlock_.tab(this,
!a.shiftKey),a.preventDefault())}onHtmlInputChange(a){a=this.value_;this.setValue(this.getValueFromEditorText_(this.htmlInput_.value),!1);this.sourceBlock_&&ia()&&this.value_!==a&&aa(new (la(O.BLOCK_FIELD_INTERMEDIATE_CHANGE))(this.sourceBlock_,this.name||null,a,this.value_))}setEditorValue_(a,b=!0){this.isDirty_=!0;this.isBeingEdited_&&(this.htmlInput_.value=this.getEditorText_(a));this.setValue(a,b)}resizeEditor_(){Lb().then(()=>{const a=this.getSourceBlock();if(!a)throw new Ta;const b=ld(),f=this.getScaledBBox();
b.style.width=f.right-f.left+"px";b.style.height=f.bottom-f.top+"px";const g=f.top;b.style.left=`${a.RTL?f.right-b.offsetWidth:f.left}px`;b.style.top=`${g}px`})}repositionForWindowResize(){let a;const b=null==(a=this.getSourceBlock())?void 0:a.getRootBlock();if(!(b instanceof xb))return!1;he(this.workspace_,this.workspace_.getMetricsManager().getViewMetrics(!0),b)||this.resizeEditor_();return!0}isTabNavigable(){return!0}getText_(){return this.isBeingEdited_&&this.htmlInput_?this.htmlInput_.value:
null}getEditorText_(a){return`${a}`}getValueFromEditorText_(a){return a}};Mf.BORDERRADIUS=4;var Nf=class extends Mf{constructor(a,b,f){super(a,b,f)}doClassValidation_(a){return void 0===a?null:`${a}`}static fromJson(a){return new this(Ua(a.text),void 0,a)}};Zb("field_input",Nf);Nf.prototype.DEFAULT_VALUE="";var $l=class extends zh{constructor(a){super(a)}endsWithElemSpacer(){return!1}hasLeftSquareCorner(a){return!!a.outputConnection}hasRightSquareCorner(a){return!!a.outputConnection&&!a.statementInputCount&&
!a.nextConnection}},rf=class extends re{constructor(a,b){super(a,b);this.connectedBottomNextConnection=!1;if(this.connectedBlock){for(a=this.connectedBlock;b=a.getNextBlock();)a=b;a.nextConnection||(this.height=this.connectedBlockHeight,this.connectedBottomNextConnection=!0)}}},am=class extends Ob{constructor(a){super(a);this.width=this.height=0;this.type|=G.getType("RIGHT_CONNECTION")}},bm=class extends Eh{constructor(a){super(a)}endsWithElemSpacer(){return!1}hasLeftSquareCorner(a){const b=(a.hat?
"cap"===a.hat:this.constants_.ADD_START_HATS)&&!a.outputConnection&&!a.previousConnection;return!!a.outputConnection||b}hasRightSquareCorner(a){return!!a.outputConnection&&!a.statementInputCount&&!a.nextConnection}},cm=class extends ue{constructor(a,b){super(a,b);this.isInline=!0;this.renderer_=a;this.constants_=this.renderer_.getConstants();this.topRow=new bm(this.constants_);this.bottomRow=new $l(this.constants_);this.isMultiRow=!b.getInputsInline()||b.isCollapsed();this.hasStatementInput=0<b.statementInputCount;
this.rightSide=this.outputConnection?new am(this.constants_):null;this.rightAlignedDummyInputs=new WeakMap}getRenderer(){return this.renderer_}measure(){this.createRows_();this.addElemSpacing_();this.addRowSpacing_();this.adjustXPosition_();this.computeBounds_();this.alignRowElements_();this.finalize_()}shouldStartNewRow_(a,b){return b?b instanceof kc||a instanceof sb||b instanceof sb?!0:a instanceof d.ValueInput$$module$build$src$core$inputs$value_input||a instanceof Pb||a instanceof kc?!this.isInline||
this.isMultiRow:!1:!1}getDesiredRowWidth_(a){return a.hasStatement?this.width-this.startX-(this.constants_.INSIDE_CORNERS.rightWidth||0):super.getDesiredRowWidth_(a)}getInRowSpacing_(a,b){return a&&b||!this.outputConnection||!this.outputConnection.isDynamicShape||this.hasStatementInput||this.bottomRow.hasNextConnection?!a&&b&&G.isStatementInput(b)?this.constants_.STATEMENT_INPUT_PADDING_LEFT:a&&G.isLeftRoundedCorner(a)&&b&&(G.isPreviousConnection(b)||G.isNextConnection(b))?b.notchOffset-this.constants_.CORNER_RADIUS:
a&&G.isLeftSquareCorner(a)&&b&&G.isHat(b)?this.constants_.NO_PADDING:this.constants_.MEDIUM_PADDING:this.constants_.NO_PADDING}getSpacerRowHeight_(a,b){if(G.isTopRow(a)&&G.isBottomRow(b))return this.constants_.EMPTY_BLOCK_SPACER_HEIGHT;const f=G.isInputRow(a)&&a.hasStatement,g=G.isInputRow(b)&&b.hasStatement;return g||f?(a=Math.max(this.constants_.NOTCH_HEIGHT,this.constants_.INSIDE_CORNERS.rightHeight||0),g&&f?Math.max(a,this.constants_.DUMMY_INPUT_MIN_HEIGHT):a):G.isTopRow(a)?a.hasPreviousConnection||
this.outputConnection&&!this.hasStatementInput?this.constants_.NO_PADDING:Math.abs(this.constants_.NOTCH_HEIGHT-this.constants_.CORNER_RADIUS):G.isBottomRow(b)?this.outputConnection?!b.hasNextConnection&&this.hasStatementInput?Math.abs(this.constants_.NOTCH_HEIGHT-this.constants_.CORNER_RADIUS):this.constants_.NO_PADDING:Math.max(this.topRow.minHeight,Math.max(this.constants_.NOTCH_HEIGHT,this.constants_.CORNER_RADIUS))-this.constants_.CORNER_RADIUS:this.constants_.MEDIUM_PADDING}getSpacerRowWidth_(a,
b){const f=this.width-this.startX;return G.isInputRow(a)&&a.hasStatement||G.isInputRow(b)&&b.hasStatement?Math.max(f,this.constants_.STATEMENT_INPUT_SPACER_MIN_WIDTH):f}getElemCenterline_(a,b){if(a.hasStatement&&!G.isSpacer(b)&&!G.isStatementInput(b))return a.yPos+this.constants_.EMPTY_STATEMENT_INPUT_HEIGHT/2;if(G.isInlineInput(b)&&b instanceof zc){const f=b.connectedBlock;if(f&&f.outputConnection&&f.nextConnection)return a.yPos+f.height/2}return super.getElemCenterline_(a,b)}addInput_(a,b){if((a instanceof
Pb||a instanceof kc)&&b.hasDummyInput&&b.align===d.Align$$module$build$src$core$inputs$align.LEFT&&a.align===d.Align$$module$build$src$core$inputs$align.RIGHT)this.rightAlignedDummyInputs.set(b,a);else if(a instanceof sb){b.elements.push(new rf(this.constants_,a));b.hasStatement=!0;null===b.align&&(b.align=a.align);return}super.addInput_(a,b)}addAlignmentPadding_(a,b){if(this.rightAlignedDummyInputs.get(a)){let f;for(let g=0;g<a.elements.length;g++){const l=a.elements[g];G.isSpacer(l)&&(f=l);if(G.isField(l)&&
l instanceof Ad&&l.parentInput===this.rightAlignedDummyInputs.get(a))break}if(f){f.width+=b;a.width+=b;return}}super.addAlignmentPadding_(a,b)}adjustXPosition_(){const a=this.constants_.NOTCH_OFFSET_LEFT+this.constants_.NOTCH_WIDTH;let b=a;for(let l=2;l<this.rows.length-1;l+=2){var f=this.rows[l-1];const n=this.rows[l];var g=this.rows[l+1];f=2===l?!!this.topRow.hasPreviousConnection:!!f.followsStatement;g=l+2>=this.rows.length-1?!!this.bottomRow.hasNextConnection:!!g.precedesStatement;if(G.isInputRow(n)&&
n.hasStatement){n.measure();let x,B;b=n.width-(null!=(B=null==(x=n.getLastInput())?void 0:x.width)?B:0)+a}else if(f&&(2===l||g)&&G.isInputRow(n)&&!n.hasStatement){g=n.xPos;f=null;for(let x=0;x<n.elements.length;x++){const B=n.elements[x];G.isSpacer(B)&&(f=B);f&&(G.isField(B)||G.isInput(B))&&g<b&&!(G.isField(B)&&B instanceof Ad&&(B.field instanceof Wc||B.field instanceof Zc))&&(f.width+=b-g);g+=B.width}}}}finalizeOutputConnection_(){if(this.outputConnection&&this.outputConnection.isDynamicShape){var a=
this.outputConnection.shape;if("isDynamic"in a&&a.isDynamic){for(var b=0,f=0;f<this.rows.length;f++){const g=this.rows[f];g.yPos=b;b+=g.height}this.height=b;f=this.bottomRow.hasNextConnection?this.height-this.bottomRow.descenderHeight:this.height;b=a.height(f);f=a.width(f);this.outputConnection.height=b;this.outputConnection.width=f;this.outputConnection.startX=f;this.outputConnection.connectionOffsetY=a.connectionOffsetY(b);this.outputConnection.connectionOffsetX=a.connectionOffsetX(f);a=0;this.hasStatementInput||
this.bottomRow.hasNextConnection||(a=f,this.rightSide.height=b,this.rightSide.width=a,this.rightSide.centerline=b/2,this.rightSide.xPos=this.width+a);this.startX=f;this.width+=f+a;this.widthWithChildren+=f+a}}}finalizeHorizontalAlignment_(){if(this.outputConnection&&!this.hasStatementInput&&!this.bottomRow.hasNextConnection){for(var a=0,b=0;b<this.rows.length;b++){var f=this.rows[b];if(!G.isInputRow(f))continue;a=f.elements[f.elements.length-2];let g=this.getNegativeSpacing_(f.elements[1]),l=this.getNegativeSpacing_(a);
a=g+l;const n=this.constants_.MIN_BLOCK_WIDTH+2*this.outputConnection.width;this.width-a<n&&(a=this.width-n,g=a/2,l=a/2);f.elements.unshift(new rb(this.constants_,-g));f.elements.push(new rb(this.constants_,-l))}if(a)for(this.width-=a,this.widthWithChildren-=a,this.rightSide.xPos-=a,b=0;b<this.rows.length;b++)f=this.rows[b],G.isTopOrBottomRow(f)&&(f.elements[1].width-=a),f.width-=a,f.widthWithConnectedBlocks-=a}}getNegativeSpacing_(a){if(!a||!this.outputConnection)return 0;const b=this.outputConnection.width;
var f=this.outputConnection.shape.type;const g=this.constants_;if(1<this.inputRows.length)switch(f){case g.SHAPES.ROUND:return f=this.constants_.MAX_DYNAMIC_CONNECTION_SHAPE_WIDTH,f=this.height/2>f?f:this.height/2,b-f*(1-Math.sin(Math.acos((f-this.constants_.SMALL_PADDING)/f)));default:return 0}if(G.isInlineInput(a)&&a instanceof zc){const l=a.connectedBlock;a=l?l.pathObject.outputShapeType:a.shape.type;return null==a||l&&l.outputConnection&&(l.statementInputCount||l.nextConnection)||f===g.SHAPES.HEXAGONAL&&
f!==a?0:b-this.constants_.SHAPE_IN_SHAPE_PADDING[f][a]}return G.isField(a)&&a instanceof Ad?f===g.SHAPES.ROUND&&a.field instanceof Nf?b-2.75*g.GRID_UNIT:b-this.constants_.SHAPE_IN_SHAPE_PADDING[f][0]:G.isIcon(a)?this.constants_.SMALL_PADDING:0}finalizeVerticalAlignment_(){if(!this.outputConnection)for(let g=2;g<this.rows.length-1;g+=2){const l=this.rows[g-1],n=this.rows[g],x=this.rows[g+1];var a=2===g,b=g+2>=this.rows.length-1?!!this.bottomRow.hasNextConnection:!!x.precedesStatement;if(a?this.topRow.hasPreviousConnection:
l.followsStatement){var f=n.elements[1];f=3===n.elements.length&&f instanceof Ad&&(f.field instanceof Wc||f.field instanceof Zc);if(!a&&f)l.height-=this.constants_.SMALL_PADDING,x.height-=this.constants_.SMALL_PADDING,n.height-=this.constants_.MEDIUM_PADDING;else if(!a&&!b)l.height+=this.constants_.SMALL_PADDING;else if(b){a=!1;for(b=0;b<n.elements.length;b++)if(f=n.elements[b],f instanceof zc&&G.isInlineInput(f)&&f.connectedBlock&&!f.connectedBlock.isShadow()&&40<=f.connectedBlock.getHeightWidth().height){a=
!0;break}a&&(l.height-=this.constants_.SMALL_PADDING,x.height-=this.constants_.SMALL_PADDING)}}}}finalize_(){this.finalizeOutputConnection_();this.finalizeHorizontalAlignment_();this.finalizeVerticalAlignment_();super.finalize_();this.rightSide&&(this.widthWithChildren+=this.rightSide.width)}},dm=class extends Hh{constructor(a,b,f){super(a,b,f);this.markerCircle=null}showWithInputOutput(a){const b=a.getSourceBlock();a=a.getLocation().getOffsetInBlock();this.positionCircle(a.x,a.y);this.setParent_(b);
this.showCurrent_()}showWithOutput_(a){this.showWithInputOutput(a)}showWithInput_(a){this.showWithInputOutput(a)}showWithBlock_(a){a=a.getLocation();const b=a.getHeightWidth();this.positionRect_(0,0,b.width,b.height);this.setParent_(a);this.showCurrent_()}positionCircle(a,b){let f;null==(f=this.markerCircle)||f.setAttribute("cx",`${a}`);let g;null==(g=this.markerCircle)||g.setAttribute("cy",`${b}`);this.currentMarkerSvg=this.markerCircle}hide(){super.hide();this.markerCircle&&(this.markerCircle.style.display=
"none")}createDomInternal_(){super.createDomInternal_();this.markerCircle=T(J.CIRCLE,{r:this.constants_.CURSOR_RADIUS,"stroke-width":this.constants_.CURSOR_STROKE_WIDTH},this.markerSvg_);this.hide();if(this.isCursor()){const a=this.getBlinkProperties_();T(J.ANIMATE,a,this.markerCircle)}return this.markerSvg_}applyColour_(a){super.applyColour_(a);let b;null==(b=this.markerCircle)||b.setAttribute("fill",this.colour_);let f;null==(f=this.markerCircle)||f.setAttribute("stroke",this.colour_);if(this.isCursor()){a=
this.colour_+";transparent;transparent;";let g;null==(g=this.markerCircle)||g.firstElementChild.setAttribute("values",a)}}},em=class extends Gf{constructor(a,b,f){super(a,b,f);this.svgPathSelected=null;this.outlines=new Map;this.remainingOutlines=new Set;this.outputShapeType=null;this.constants=f}setPath(a){super.setPath(a);this.svgPathSelected&&this.svgPathSelected.setAttribute("d",a)}applyColour(a){super.applyColour(a);const b=a.getParent();a.isShadow()&&b&&this.svgPath.setAttribute("stroke",b.getColourTertiary());
for(const f of this.outlines.values())f.setAttribute("fill",this.style.colourTertiary)}flipRTL(){super.flipRTL();for(const a of this.outlines.values())a.setAttribute("transform","scale(-1 1)")}updateSelected(a){this.setClass_("blocklySelected",a);a?this.svgPathSelected||(this.svgPathSelected=this.svgPath.cloneNode(!0),this.svgPathSelected.setAttribute("fill","none"),this.svgPathSelected.setAttribute("filter","url(#"+this.constants.selectedGlowFilterId+")"),this.svgRoot.appendChild(this.svgPathSelected)):
this.svgPathSelected&&(this.svgRoot.removeChild(this.svgPathSelected),this.svgPathSelected=null)}updateReplacementFade(a){this.setClass_("blocklyReplaceable",a);a?this.svgPath.setAttribute("filter","url(#"+this.constants.replacementGlowFilterId+")"):this.svgPath.removeAttribute("filter")}updateShapeForInputHighlight(a,b){a=a.getParentInput().name;(a=this.getOutlinePath(a))&&(b?a.setAttribute("filter","url(#"+this.constants.replacementGlowFilterId+")"):a.removeAttribute("filter"))}beginDrawing(){this.remainingOutlines.clear();
for(const a of this.outlines.keys())this.remainingOutlines.add(a)}endDrawing(){if(this.remainingOutlines.size)for(const a of this.remainingOutlines)this.removeOutlinePath(a);this.remainingOutlines.clear()}setOutlinePath(a,b){a=this.getOutlinePath(a);a.setAttribute("d",b);a.setAttribute("fill",this.style.colourTertiary)}getOutlinePath(a){this.outlines.has(a)||this.outlines.set(a,T(J.PATH,{"class":"blocklyOutlinePath",d:""},this.svgRoot));this.remainingOutlines.delete(a);return this.outlines.get(a)}removeOutlinePath(a){let b,
f;null==(b=this.outlines.get(a))||null==(f=b.parentNode)||f.removeChild(this.outlines.get(a));this.outlines.delete(a)}},Sh=class extends Hf{constructor(a){super(a)}makeConstants_(){return new Yl}makeRenderInfo_(a){return new cm(this,a)}makeDrawer_(a,b){return new Zl(a,b)}makeMarkerDrawer(a,b){return new dm(a,this.getConstants(),b)}makePathObject(a,b){return new em(a,b,this.getConstants())}getConstants(){return this.constants_}getConnectionPreviewMethod(a,b,f){L("getConnectionPreviewMethod","v10",
"v12","an IConnectionPreviewer, if it fulfills your use case.");return b.type===oa.OUTPUT_VALUE?a.isConnected()?Qb.PREVIEW_TYPE.REPLACEMENT_FADE:Qb.PREVIEW_TYPE.INPUT_OUTLINE:super.getConnectionPreviewMethod(a,b,f)}};of("zelos",Sh);var fm=class{constructor(a){this.staticConn=this.draggedConn=this.markerConn=this.fadedBlock=null;this.workspace=a.workspace}previewReplacement(a,b,f){d.disable$$module$build$src$core$events$utils();try{this.hidePreview(),this.fadedBlock=f,f.fadeForReplacement(!0),this.workspace.getRenderer().shouldHighlightConnection(b)&&
(b.highlight(),this.staticConn=b)}finally{d.enable$$module$build$src$core$events$utils()}}previewConnection(a,b){if(a!==this.draggedConn||b!==this.staticConn){d.disable$$module$build$src$core$events$utils();try{this.hidePreview(),this.shouldUseMarkerPreview(a,b)&&(this.markerConn=this.previewMarker(a,b)),this.workspace.getRenderer().shouldHighlightConnection(b)&&b.highlight(),this.draggedConn=a,this.staticConn=b}finally{d.enable$$module$build$src$core$events$utils()}}}shouldUseMarkerPreview(a,b){return b.type===
oa.PREVIOUS_STATEMENT||b.type===oa.NEXT_STATEMENT||!(this.workspace.getRenderer()instanceof Sh)}previewMarker(a,b){const f=a.getSourceBlock(),g=this.createInsertionMarker(f),l=this.getMatchingConnection(f,g,a);if(!l)return null;g.queueRender();oc();l.connect(b);const n={x:b.x-l.x,y:b.y-l.y},x=l.getOffsetInBlock().clone();Lb().then(()=>{if(!g.isDeadOrDying()){d.disable$$module$build$src$core$events$utils();try{null==g||g.positionNearConnection(l,n,x),null==g||g.getSvgRoot().setAttribute("visibility",
"visible")}finally{d.enable$$module$build$src$core$events$utils()}}});return l}createInsertionMarker(a){const b=vb(a,{addCoordinates:!1,addInputBlocks:!1,addNextBlocks:!1,doFullSerialization:!1});if(!b)throw Error(`Failed to serialize source block. ${a.toDevString()}`);a=pc(b,this.workspace);for(const f of a.getDescendants(!1))f.setInsertionMarker(!0);a.initSvg();a.getSvgRoot().setAttribute("visibility","hidden");return a}getMatchingConnection(a,b,f){a=a.getConnections_(!0);b=b.getConnections_(!0);
if(a.length!==b.length)return null;for(let g=0;g<a.length;g++)if(a[g]===f)return b[g];return null}hidePreview(){d.disable$$module$build$src$core$events$utils();try{this.staticConn&&(this.staticConn.unhighlight(),this.staticConn=null),this.fadedBlock&&(this.fadedBlock.fadeForReplacement(!1),this.fadedBlock=null),this.markerConn&&(this.hideInsertionMarker(this.markerConn),this.draggedConn=this.markerConn=null)}finally{d.enable$$module$build$src$core$events$utils()}}hideInsertionMarker(a){const b=a.getSourceBlock(),
f=b.outputConnection;let g;if((null==(g=b.previousConnection)?0:g.targetConnection)||(null==f?0:f.targetConnection))b.unplug(!0);else{let l;null==(l=a.targetBlock())||l.unplug(!1)}b.dispose()}dispose(){this.hidePreview()}};e(ba.CONNECTION_PREVIEWER,Jb,fm);var Bc={};Bc.Align=d.Align$$module$build$src$core$inputs$align;Bc.DummyInput=Pb;Bc.EndRowInput=kc;Bc.Input=Bd;Bc.StatementInput=sb;Bc.ValueInput=d.ValueInput$$module$build$src$core$inputs$value_input;Bc.inputTypes=d.inputTypes$$module$build$src$core$inputs$input_types;
var Hk=!1;d.CodeGenerator$$module$build$src$core$generator=class{constructor(a){this.forBlock=Object.create(null);this.FUNCTION_NAME_PLACEHOLDER_="{leCUI8hutHZI4480Dc}";this.STATEMENT_SUFFIX=this.STATEMENT_PREFIX=this.INFINITE_LOOP_TRAP=null;this.INDENT="  ";this.COMMENT_WRAP=60;this.ORDER_OVERRIDES=[];this.isInitialized=null;this.RESERVED_WORDS_="";this.definitions_=Object.create(null);this.functionNames_=Object.create(null);this.nameDB_=void 0;this.name_=a;this.FUNCTION_NAME_PLACEHOLDER_REGEXP_=
new RegExp(this.FUNCTION_NAME_PLACEHOLDER_,"g")}workspaceToCode(a){a||(console.warn("No workspace specified in workspaceToCode call.  Guessing."),a=z());var b=[];this.init(a);a=a.getTopBlocks(!0);for(let f=0,g;g=a[f];f++){let l=this.blockToCode(g);Array.isArray(l)&&(l=l[0]);l&&(g.outputConnection&&(l=this.scrubNakedValue(l),this.STATEMENT_PREFIX&&!g.suppressPrefixSuffix&&(l=this.injectId(this.STATEMENT_PREFIX,g)+l),this.STATEMENT_SUFFIX&&!g.suppressPrefixSuffix&&(l+=this.injectId(this.STATEMENT_SUFFIX,
g))),b.push(l))}b=b.join("\n");b=this.finish(b);b=b.replace(/^\s+\n/,"");b=b.replace(/\n\s+$/,"\n");return b.replace(/[ \t]+\n/g,"\n")}prefixLines(a,b){return b+a.replace(/(?!\n$)\n/g,"\n"+b)}allNestedComments(a){const b=[];a=a.getDescendants(!0);for(let f=0;f<a.length;f++){const g=a[f].getCommentText();g&&b.push(g)}b.length&&b.push("");return b.join("\n")}blockToCode(a,b){!1===this.isInitialized&&console.warn("CodeGenerator init was not called before blockToCode was called.");if(!a)return"";if(!a.isEnabled())return b?
"":this.blockToCode(a.getNextBlock());if(a.isInsertionMarker())return b?"":this.blockToCode(a.getChildren(!1)[0]);var f=this.forBlock[a.type];if("function"!==typeof f)throw Error(`${this.name_} generator does not know how to generate code `+`for block type "${a.type}".`);f=f.call(a,a,this);if(Array.isArray(f)){if(!a.outputConnection)throw TypeError("Expecting string from statement block: "+a.type);return[this.scrub_(a,f[0],b),f[1]]}if("string"===typeof f)return this.STATEMENT_PREFIX&&!a.suppressPrefixSuffix&&
(f=this.injectId(this.STATEMENT_PREFIX,a)+f),this.STATEMENT_SUFFIX&&!a.suppressPrefixSuffix&&(f+=this.injectId(this.STATEMENT_SUFFIX,a)),this.scrub_(a,f,b);if(null===f)return"";throw SyntaxError("Invalid code generated: "+f);}valueToCode(a,b,f){if(isNaN(f))throw TypeError("Expecting valid order from block: "+a.type);var g=a.getInputTargetBlock(b);if(!g&&!a.getInput(b))throw ReferenceError(`Input "${b}" doesn't exist on "${a.type}"`);if(!g)return"";b=this.blockToCode(g);if(""===b)return"";if(!Array.isArray(b))throw TypeError(`Expecting tuple from value block: ${g.type} See `+
"developers.google.com/blockly/guides/create-custom-blocks/generating-code for more information");a=b[0];b=b[1];if(isNaN(b))throw TypeError("Expecting valid order from value block: "+g.type);if(!a)return"";g=!1;var l=Math.floor(f);const n=Math.floor(b);if(l<=n&&(l!==n||0!==l&&99!==l))for(g=!0,l=0;l<this.ORDER_OVERRIDES.length;l++)if(this.ORDER_OVERRIDES[l][0]===f&&this.ORDER_OVERRIDES[l][1]===b){g=!1;break}g&&(a="("+a+")");return a}statementToCode(a,b){const f=a.getInputTargetBlock(b);if(!f&&!a.getInput(b))throw ReferenceError(`Input "${b}" doesn't exist on "${a.type}"`);
a=this.blockToCode(f);if("string"!==typeof a)throw TypeError("Expecting code from statement block: "+(f&&f.type));a&&=this.prefixLines(a,this.INDENT);return a}addLoopTrap(a,b){this.INFINITE_LOOP_TRAP&&(a=this.prefixLines(this.injectId(this.INFINITE_LOOP_TRAP,b),this.INDENT)+a);this.STATEMENT_SUFFIX&&!b.suppressPrefixSuffix&&(a=this.prefixLines(this.injectId(this.STATEMENT_SUFFIX,b),this.INDENT)+a);this.STATEMENT_PREFIX&&!b.suppressPrefixSuffix&&(a+=this.prefixLines(this.injectId(this.STATEMENT_PREFIX,
b),this.INDENT));return a}injectId(a,b){b=b.id.replace(/\$/g,"$$$$");return a.replace(/%1/g,"'"+b+"'")}addReservedWords(a){this.RESERVED_WORDS_+=a+","}provideFunction_(a,b){if(!this.definitions_[a]){const f=this.nameDB_.getDistinctName(a,d.NameType$$module$build$src$core$names.PROCEDURE);this.functionNames_[a]=f;Array.isArray(b)&&(b=b.join("\n"));b=b.trim().replace(this.FUNCTION_NAME_PLACEHOLDER_REGEXP_,f);let g;for(;g!==b;)g=b,b=b.replace(/^(( {2})*) {2}/gm,"$1\x00");b=b.replace(/\0/g,this.INDENT);
this.definitions_[a]=b}return this.functionNames_[a]}getVariableName(a){return this.getName(a,d.NameType$$module$build$src$core$names.VARIABLE)}getProcedureName(a){return this.getName(a,d.NameType$$module$build$src$core$names.PROCEDURE)}getName(a,b){if(!this.nameDB_)throw Error("Name database is not defined. You must initialize `nameDB_` in your generator class and call `init` first.");return this.nameDB_.getName(a,b)}init(a){this.definitions_=Object.create(null);this.functionNames_=Object.create(null)}scrub_(a,
b,f){return b}finish(a){this.definitions_=Object.create(null);this.functionNames_=Object.create(null);return a}scrubNakedValue(a){return a}};var gm=class extends Rh{constructor(a,b){super(a);this.flyout_=b}getBoundingBox(){let a;try{a=this.workspace_.getCanvas().getBBox()}catch(b){a={height:0,y:0,width:0,x:0}}return a}getContentMetrics(a){const b=this.getBoundingBox();a=a?1:this.workspace_.scale;return{height:b.height*a,width:b.width*a,top:b.y*a,left:b.x*a}}getScrollMetrics(a,b,f){b=f||this.getContentMetrics();
f=this.flyout_.MARGIN*this.workspace_.scale;a=a?this.workspace_.scale:1;return{height:(b.height+2*f)/a,width:(b.width+b.left+f)/a,top:0,left:0}}},ye;(function(a){a.BLOCK="block";a.BUTTON="button"})(ye||={});var Of=class extends Jf{constructor(a){super();this.horizontalLayout=!1;this.boundEvents=[];this.filterWrapper=this.reflowWrapper=null;this.mats=[];this.buttons_=[];this.contents=[];this.listeners=[];this.permanentlyDisabled=[];this.recycledBlocks=[];this.autoClose=!0;this.visible=!1;this.containerVisible=
!0;this.CORNER_RADIUS=8;this.SCROLLBAR_MARGIN=2.5;this.height_=this.width_=0;this.dragAngleRange_=70;this.svgGroup_=this.svgBackground_=null;a.setMetrics=this.setMetrics_.bind(this);this.workspace_=new ob(a);this.workspace_.setMetricsManager(new gm(this.workspace_,this));this.workspace_.internalIsFlyout=!0;this.workspace_.setVisible(this.visible);this.id=da();this.RTL=!!a.RTL;this.toolboxPosition_=a.toolboxPosition;this.tabWidth_=this.workspace_.getRenderer().getConstants().TAB_WIDTH;this.rectMap_=
new WeakMap;this.MARGIN=this.CORNER_RADIUS;this.GAP_X=3*this.MARGIN;this.GAP_Y=3*this.MARGIN}createDom(a){this.svgGroup_=T(a,{"class":"blocklyFlyout"});this.svgGroup_.style.display="none";this.svgBackground_=T(J.PATH,{"class":"blocklyFlyoutBackground"},this.svgGroup_);this.svgGroup_.appendChild(this.workspace_.createDom());this.workspace_.getThemeManager().subscribe(this.svgBackground_,"flyoutBackgroundColour","fill");this.workspace_.getThemeManager().subscribe(this.svgBackground_,"flyoutOpacity",
"fill-opacity");return this.svgGroup_}init(a){this.targetWorkspace=a;this.workspace_.targetWorkspace=a;this.workspace_.scrollbar=new ih(this.workspace_,this.horizontalLayout,!this.horizontalLayout,"blocklyFlyoutScrollbar",this.SCROLLBAR_MARGIN);this.hide();this.boundEvents.push(ta(this.svgGroup_,"wheel",this,this.wheel_));this.filterWrapper=this.filterForCapacity.bind(this);this.targetWorkspace.addChangeListener(this.filterWrapper);this.boundEvents.push(ta(this.svgBackground_,"pointerdown",this,this.onMouseDown));
this.workspace_.getGesture=this.targetWorkspace.getGesture.bind(this.targetWorkspace);this.workspace_.setVariableMap(this.targetWorkspace.getVariableMap());this.workspace_.createPotentialVariableMap();a.getComponentManager().addComponent({component:this,weight:Qa.ComponentWeight.FLYOUT_WEIGHT,capabilities:[Qa.Capability.AUTOHIDEABLE,Qa.Capability.DELETE_AREA,Qa.Capability.DRAG_TARGET]})}dispose(){this.hide();this.targetWorkspace.getComponentManager().removeComponent(this.id);for(const a of this.boundEvents)Na(a);
this.boundEvents.length=0;this.filterWrapper&&this.targetWorkspace.removeChangeListener(this.filterWrapper);this.workspace_&&(this.workspace_.getThemeManager().unsubscribe(this.svgBackground_),this.workspace_.dispose());this.svgGroup_&&Ia(this.svgGroup_)}getWidth(){return this.width_}getHeight(){return this.height_}getFlyoutScale(){return this.targetWorkspace.scale}getWorkspace(){return this.workspace_}setAutoClose(a){this.autoClose=a;this.targetWorkspace.recordDragTargets();this.targetWorkspace.resizeContents()}autoHide(a){!a&&
this.targetWorkspace.getFlyout(!0)===this&&this.autoClose&&this.hide()}getTargetWorkspace(){return this.targetWorkspace}isVisible(){return this.visible}setVisible(a){const b=a!==this.isVisible();this.visible=a;b&&(this.autoClose||this.targetWorkspace.recordDragTargets(),this.updateDisplay())}setContainerVisible(a){const b=a!==this.containerVisible;this.containerVisible=a;b&&this.updateDisplay()}getContents(){return this.contents}setContents(a){this.contents=a}updateDisplay(){let a;a=this.containerVisible?
this.isVisible():!1;this.svgGroup_&&(this.svgGroup_.style.display=a?"block":"none");let b;null==(b=this.workspace_.scrollbar)||b.setContainerVisible(a)}positionAt_(a,b,f,g){let l;null==(l=this.svgGroup_)||l.setAttribute("width",`${a}`);let n;null==(n=this.svgGroup_)||n.setAttribute("height",`${b}`);this.workspace_.setCachedParentSvgSize(a,b);this.svgGroup_&&Vf(this.svgGroup_,"translate("+f+"px,"+g+"px)");if(a=this.workspace_.scrollbar)a.setOrigin(f,g),a.resize(),a.hScroll&&a.hScroll.setPosition(a.hScroll.position.x,
a.hScroll.position.y),a.vScroll&&a.vScroll.setPosition(a.vScroll.position.x,a.vScroll.position.y)}hide(){if(this.isVisible()){this.setVisible(!1);for(const a of this.listeners)Na(a);this.listeners.length=0;this.reflowWrapper&&(this.workspace_.removeChangeListener(this.reflowWrapper),this.reflowWrapper=null)}}show(a){this.workspace_.setResizesEnabled(!1);this.hide();this.clearOldBlocks();"string"===typeof a&&(a=this.getDynamicCategoryContents(a));this.setVisible(!0);a=Ne(a);a=this.createFlyoutInfo(a);
oc(this.workspace_);this.setContents(a.contents);this.layout_(a.contents,a.gaps);this.horizontalLayout?this.height_=0:this.width_=0;this.workspace_.setResizesEnabled(!0);this.reflow();this.filterForCapacity();this.position();this.reflowWrapper=this.reflow.bind(this);this.workspace_.addChangeListener(this.reflowWrapper);this.emptyRecycledBlocks()}createFlyoutInfo(a){const b=[],f=[];this.permanentlyDisabled.length=0;const g=this.horizontalLayout?this.GAP_X:this.GAP_Y;for(const l of a){if("custom"in
l){a=this.getDynamicCategoryContents(l.custom);a=Ne(a);const {contents:n,gaps:x}=this.createFlyoutInfo(a);b.push(...n);f.push(...x)}switch(l.kind.toUpperCase()){case "BLOCK":a=l;const n=this.createFlyoutBlock(a);b.push({type:ye.BLOCK,block:n});this.addBlockGap(a,f,g);break;case "SEP":this.addSeparatorGap(l,f,g);break;case "LABEL":a=this.createButton(l,!0);b.push({type:ye.BUTTON,button:a});f.push(g);break;case "BUTTON":a=this.createButton(l,!1),b.push({type:ye.BUTTON,button:a}),f.push(g)}}return{contents:b,
gaps:f}}getDynamicCategoryContents(a){a=this.workspace_.targetWorkspace.getToolboxCategoryCallback(a);if("function"!==typeof a)throw TypeError("Couldn't find a callback function when opening a toolbox category.");return a(this.workspace_.targetWorkspace)}createButton(a,b){return new Bb(this.workspace_,this.targetWorkspace,a,b)}createFlyoutBlock(a){let b;a.blockxml?(a="string"===typeof a.blockxml?d.textToDom$$module$build$src$core$utils$xml(a.blockxml):a.blockxml,(b=this.getRecycledBlock(a.getAttribute("type")))||
(b=qd(a,this.workspace_))):(b=this.getRecycledBlock(a.type),b||(void 0===a.enabled&&(a.enabled="true"!==a.disabled&&!0!==a.disabled),void 0===a.disabledReasons&&!1===a.enabled&&(a.disabledReasons=[fb]),b=Td(a,this.workspace_)));b.isEnabled()||this.permanentlyDisabled.push(b);return b}getRecycledBlock(a){let b=-1;for(let f=0;f<this.recycledBlocks.length;f++)if(this.recycledBlocks[f].type===a){b=f;break}return-1===b?void 0:this.recycledBlocks.splice(b,1)[0]}addBlockGap(a,b,f){let g;a.gap?g=parseInt(String(a.gap)):
a.blockxml&&(a="string"===typeof a.blockxml?d.textToDom$$module$build$src$core$utils$xml(a.blockxml):a.blockxml,g=parseInt(a.getAttribute("gap")));b.push(!g||isNaN(g)?f:g)}addSeparatorGap(a,b,f){a=parseInt(String(a.gap));!isNaN(a)&&0<b.length?b[b.length-1]=a:b.push(f)}clearOldBlocks(){var a=this.workspace_.getTopBlocks(!1);for(let f=0,g;g=a[f];f++)this.blockIsRecyclable_(g)?this.recycleBlock(g):g.dispose(!1,!1);for(a=0;a<this.mats.length;a++){const f=this.mats[a];f&&(Eg(f),Ia(f))}this.mats.length=
0;for(let f=0,g;g=this.buttons_[f];f++)g.dispose();this.buttons_.length=0;let b;null==(b=this.workspace_.getPotentialVariableMap())||b.clear()}emptyRecycledBlocks(){for(let a=0;a<this.recycledBlocks.length;a++)this.recycledBlocks[a].dispose();this.recycledBlocks=[]}blockIsRecyclable_(a){return!1}recycleBlock(a){const b=a.getRelativeToSurfaceXY();a.moveBy(-b.x,-b.y);this.recycledBlocks.push(a)}addBlockListeners_(a,b,f){this.listeners.push(ta(a,"pointerdown",null,this.blockMouseDown(b)));this.listeners.push(ta(f,
"pointerdown",null,this.blockMouseDown(b)));this.listeners.push(lb(a,"pointerenter",b,()=>{this.targetWorkspace.isDragging()||b.addSelect()}));this.listeners.push(lb(a,"pointerleave",b,()=>{this.targetWorkspace.isDragging()||b.removeSelect()}));this.listeners.push(lb(f,"pointerenter",b,()=>{this.targetWorkspace.isDragging()||b.addSelect()}));this.listeners.push(lb(f,"pointerleave",b,()=>{this.targetWorkspace.isDragging()||b.removeSelect()}))}blockMouseDown(a){return b=>{const f=this.targetWorkspace.getGesture(b);
f&&(f.setStartBlock(a),f.handleFlyoutStart(b,this))}}onMouseDown(a){const b=this.targetWorkspace.getGesture(a);b&&b.handleFlyoutStart(a,this)}isBlockCreatable(a){return a.isEnabled()}createBlock(a){let b=null;d.disable$$module$build$src$core$events$utils();var f=this.targetWorkspace.getAllVariables();this.targetWorkspace.setResizesEnabled(!1);try{b=this.placeNewBlock(a)}finally{d.enable$$module$build$src$core$events$utils()}this.targetWorkspace.hideChaff();a=Te(this.targetWorkspace,f);if(ia()){d.setGroup$$module$build$src$core$events$utils(!0);
for(f=0;f<a.length;f++){const g=a[f];aa(new (la(O.VAR_CREATE))(g))}aa(new (la(O.BLOCK_CREATE))(b))}this.autoClose?this.hide():this.filterForCapacity();return b}initFlyoutButton_(a,b,f){const g=a.createDom();a.moveTo(b,f);a.show();this.listeners.push(ta(g,"pointerdown",this,this.onMouseDown));this.buttons_.push(a)}createRect_(a,b,f,g,l){b=T(J.RECT,{"fill-opacity":0,x:b,y:f,height:g.height,width:g.width});b.tooltip=a;Zd(b);this.workspace_.getCanvas().insertBefore(b,a.getSvgRoot());this.rectMap_.set(a,
b);return this.mats[l]=b}moveRectToBlock_(a,b){const f=b.getHeightWidth();a.setAttribute("width",String(f.width));a.setAttribute("height",String(f.height));b=b.getRelativeToSurfaceXY();a.setAttribute("y",String(b.y));a.setAttribute("x",String(this.RTL?b.x-f.width:b.x))}filterForCapacity(){const a=this.workspace_.getTopBlocks(!1);for(let b=0,f;f=a[b];b++)if(!this.permanentlyDisabled.includes(f)){const g=this.targetWorkspace.isCapacityAvailable(D(f));for(;f;)f.setDisabledReason(!g,"WORKSPACE_AT_BLOCK_CAPACITY"),
f=f.getNextBlock()}}reflow(){this.reflowWrapper&&this.workspace_.removeChangeListener(this.reflowWrapper);this.reflowInternal_();this.reflowWrapper&&this.workspace_.addChangeListener(this.reflowWrapper)}isScrollable(){return this.workspace_.scrollbar?this.workspace_.scrollbar.isVisible():!1}placeNewBlock(a){var b=this.targetWorkspace;if(!a.getSvgRoot())throw Error("oldBlock is not rendered");const f=this.serializeBlock(a);b.setResizesEnabled(!1);b=pc(f,b);this.positionNewBlock(a,b);return b}serializeBlock(a){return vb(a)}positionNewBlock(a,
b){const f=this.targetWorkspace;var g=f.getOriginOffsetInPixels(),l=this.workspace_.getOriginOffsetInPixels();a=a.getRelativeToSurfaceXY();a.scale(this.workspace_.scale);l=fa.sum(l,a);g=fa.difference(l,g);g.scale(1/f.scale);b.moveTo(new fa(g.x,g.y))}};Of.FlyoutItemType=ye;var Th=class extends Of{constructor(a){super(a)}setMetrics_(a){if(this.isVisible()){var b=this.workspace_.getMetricsManager(),f=b.getScrollMetrics(),g=b.getViewMetrics();b=b.getAbsoluteMetrics();"number"===typeof a.y&&(this.workspace_.scrollY=
-(f.top+(f.height-g.height)*a.y));this.workspace_.translate(this.workspace_.scrollX+b.left,this.workspace_.scrollY+b.top)}}getX(){if(!this.isVisible())return 0;var a=this.targetWorkspace.getMetricsManager();const b=a.getAbsoluteMetrics(),f=a.getViewMetrics();a=a.getToolboxMetrics();return this.targetWorkspace.toolboxPosition===this.toolboxPosition_?this.targetWorkspace.getToolbox()?this.toolboxPosition_===xa.LEFT?a.width:f.width-this.width_:this.toolboxPosition_===xa.LEFT?0:f.width:this.toolboxPosition_===
xa.LEFT?0:f.width+b.left-this.width_}getY(){return 0}position(){if(this.isVisible()&&this.targetWorkspace.isVisible()){var a=this.targetWorkspace.getMetricsManager().getViewMetrics();this.height_=a.height;this.setBackgroundPath(this.width_-this.CORNER_RADIUS,a.height-2*this.CORNER_RADIUS);a=this.getX();var b=this.getY();this.positionAt_(this.width_,this.height_,a,b)}}setBackgroundPath(a,b){const f=this.toolboxPosition_===xa.RIGHT;var g=a+this.CORNER_RADIUS;g=["M "+(f?g:0)+",0"];g.push("h",f?-a:a);
g.push("a",this.CORNER_RADIUS,this.CORNER_RADIUS,0,0,f?0:1,f?-this.CORNER_RADIUS:this.CORNER_RADIUS,this.CORNER_RADIUS);g.push("v",Math.max(0,b));g.push("a",this.CORNER_RADIUS,this.CORNER_RADIUS,0,0,f?0:1,f?this.CORNER_RADIUS:-this.CORNER_RADIUS,this.CORNER_RADIUS);g.push("h",f?a:-a);g.push("z");this.svgBackground_.setAttribute("d",g.join(" "))}scrollToStart(){let a;null==(a=this.workspace_.scrollbar)||a.setY(0)}wheel_(a){var b=Ge(a);if(b.y){const f=this.workspace_.getMetricsManager(),g=f.getScrollMetrics();
b=f.getViewMetrics().top-g.top+b.y;let l;null==(l=this.workspace_.scrollbar)||l.setY(b);cf(this.workspace_);Yb()}a.preventDefault();a.stopPropagation()}layout_(a,b){this.workspace_.scale=this.targetWorkspace.scale;var f=this.MARGIN;const g=this.RTL?f:f+this.tabWidth_;for(let B=0,V;V=a[B];B++)if("block"===V.type){var l=V.block;if(!l)continue;var n=l.getDescendants(!1);for(let Pa=0,La;La=n[Pa];Pa++)La.isInFlyout=!0;n=l.getSvgRoot();const na=l.getHeightWidth();var x=l.outputConnection?g-this.tabWidth_:
g;l.moveBy(x,f);x=this.createRect_(l,this.RTL?x-na.width:x,f,na,B);this.addBlockListeners_(n,l,x);f+=na.height+b[B]}else"button"===V.type&&(l=V.button,this.initFlyoutButton_(l,g,f),f+=l.height+b[B])}isDragTowardWorkspace(a){a=Math.atan2(a.y,a.x)/Math.PI*180;const b=this.dragAngleRange_;return a<b&&a>-b||a<-180+b||a>180-b?!0:!1}getClientRect(){if(!this.svgGroup_||this.autoClose||!this.isVisible())return null;const a=this.svgGroup_.getBoundingClientRect(),b=a.left;return this.toolboxPosition_===xa.LEFT?
new Ja(-1E9,1E9,-1E9,b+a.width):new Ja(-1E9,1E9,b,1E9)}reflowInternal_(){this.workspace_.scale=this.getFlyoutScale();let a=0;var b=this.workspace_.getTopBlocks(!1);for(let g=0,l;l=b[g];g++){var f=l.getHeightWidth().width;l.outputConnection&&(f-=this.tabWidth_);a=Math.max(a,f)}for(let g=0,l;l=this.buttons_[g];g++)a=Math.max(a,l.width);a+=1.5*this.MARGIN+this.tabWidth_;a*=this.workspace_.scale;a+=Sa.scrollbarThickness;if(this.width_!==a){for(let g=0,l;l=b[g];g++){if(this.RTL){f=l.getRelativeToSurfaceXY().x;
let n=a/this.workspace_.scale-this.MARGIN;l.outputConnection||(n-=this.tabWidth_);l.moveBy(n-f,0)}this.rectMap_.has(l)&&this.moveRectToBlock_(this.rectMap_.get(l),l)}if(this.RTL)for(let g=0,l;l=this.buttons_[g];g++)b=l.getPosition().y,l.moveTo(a/this.workspace_.scale-l.width-this.MARGIN-this.tabWidth_,b);this.targetWorkspace.scrollbar||this.autoClose||this.targetWorkspace.getFlyout()!==this||this.toolboxPosition_!==xa.LEFT||this.targetWorkspace.translate(this.targetWorkspace.scrollX+a,this.targetWorkspace.scrollY);
this.width_=a;this.position();this.targetWorkspace.resizeContents();this.targetWorkspace.recordDragTargets()}}};Th.registryName="verticalFlyout";e(ba.FLYOUTS_VERTICAL_TOOLBOX,Jb,Th);var hm=class extends Of{constructor(a){super(a);this.horizontalLayout=!0}setMetrics_(a){if(this.isVisible()){var b=this.workspace_.getMetricsManager(),f=b.getScrollMetrics(),g=b.getViewMetrics();b=b.getAbsoluteMetrics();"number"===typeof a.x&&(this.workspace_.scrollX=-(f.left+(f.width-g.width)*a.x));this.workspace_.translate(this.workspace_.scrollX+
b.left,this.workspace_.scrollY+b.top)}}getX(){return 0}getY(){if(!this.isVisible())return 0;var a=this.targetWorkspace.getMetricsManager();const b=a.getAbsoluteMetrics(),f=a.getViewMetrics();a=a.getToolboxMetrics();const g=this.toolboxPosition_===xa.TOP;return this.targetWorkspace.toolboxPosition===this.toolboxPosition_?this.targetWorkspace.getToolbox()?g?a.height:f.height-this.height_:g?0:f.height:g?0:f.height+b.top-this.height_}position(){if(this.isVisible()&&this.targetWorkspace.isVisible()){var a=
this.targetWorkspace.getMetricsManager().getViewMetrics();this.width_=a.width;this.setBackgroundPath(a.width-2*this.CORNER_RADIUS,this.height_-this.CORNER_RADIUS);a=this.getX();var b=this.getY();this.positionAt_(this.width_,this.height_,a,b)}}setBackgroundPath(a,b){const f=this.toolboxPosition_===xa.TOP,g=["M 0,"+(f?0:this.CORNER_RADIUS)];f?(g.push("h",a+2*this.CORNER_RADIUS),g.push("v",b),g.push("a",this.CORNER_RADIUS,this.CORNER_RADIUS,0,0,1,-this.CORNER_RADIUS,this.CORNER_RADIUS),g.push("h",-a),
g.push("a",this.CORNER_RADIUS,this.CORNER_RADIUS,0,0,1,-this.CORNER_RADIUS,-this.CORNER_RADIUS)):(g.push("a",this.CORNER_RADIUS,this.CORNER_RADIUS,0,0,1,this.CORNER_RADIUS,-this.CORNER_RADIUS),g.push("h",a),g.push("a",this.CORNER_RADIUS,this.CORNER_RADIUS,0,0,1,this.CORNER_RADIUS,this.CORNER_RADIUS),g.push("v",b),g.push("h",-a-2*this.CORNER_RADIUS));g.push("z");this.svgBackground_.setAttribute("d",g.join(" "))}scrollToStart(){let a;null==(a=this.workspace_.scrollbar)||a.setX(this.RTL?Infinity:0)}wheel_(a){var b=
Ge(a);if(b=b.x||b.y){const f=this.workspace_.getMetricsManager(),g=f.getScrollMetrics();b=f.getViewMetrics().left-g.left+b;let l;null==(l=this.workspace_.scrollbar)||l.setX(b);cf(this.workspace_);Yb()}a.preventDefault();a.stopPropagation()}layout_(a,b){this.workspace_.scale=this.targetWorkspace.scale;const f=this.MARGIN;let g=f+this.tabWidth_;this.RTL&&(a=a.reverse());for(let B=0,V;V=a[B];B++)if("block"===V.type){var l=V.block;if(void 0===l||null===l)continue;var n=l.getDescendants(!1);for(let Pa=
0,La;La=n[Pa];Pa++)La.isInFlyout=!0;n=l.getSvgRoot();const na=l.getHeightWidth();var x=l.outputConnection?this.tabWidth_:0;x=this.RTL?g+na.width:g-x;l.moveBy(x,f);x=this.createRect_(l,x,f,na,B);g+=na.width+b[B];this.addBlockListeners_(n,l,x)}else"button"===V.type&&(l=V.button,this.initFlyoutButton_(l,g,f),g+=l.width+b[B])}isDragTowardWorkspace(a){a=Math.atan2(a.y,a.x)/Math.PI*180;const b=this.dragAngleRange_;return a<90+b&&a>90-b||a>-90-b&&a<-90+b?!0:!1}getClientRect(){if(!this.svgGroup_||this.autoClose||
!this.isVisible())return null;const a=this.svgGroup_.getBoundingClientRect(),b=a.top;return this.toolboxPosition_===xa.TOP?new Ja(-1E9,b+a.height,-1E9,1E9):new Ja(b,1E9,-1E9,1E9)}reflowInternal_(){this.workspace_.scale=this.getFlyoutScale();let a=0;const b=this.workspace_.getTopBlocks(!1);for(let g=0,l;l=b[g];g++)a=Math.max(a,l.getHeightWidth().height);const f=this.buttons_;for(let g=0,l;l=f[g];g++)a=Math.max(a,l.height);a+=1.5*this.MARGIN;a*=this.workspace_.scale;a+=Sa.scrollbarThickness;if(this.height_!==
a){for(let g=0,l;l=b[g];g++)this.rectMap_.has(l)&&this.moveRectToBlock_(this.rectMap_.get(l),l);this.targetWorkspace.scrollbar||this.autoClose||this.targetWorkspace.getFlyout()!==this||this.toolboxPosition_!==xa.TOP||this.targetWorkspace.translate(this.targetWorkspace.scrollX,this.targetWorkspace.scrollY+a);this.height_=a;this.position();this.targetWorkspace.resizeContents();this.targetWorkspace.recordDragTargets()}}};e(ba.FLYOUTS_HORIZONTAL_TOOLBOX,Jb,hm);var ze=class extends jb{constructor(a,b,
f,g,l){super(Ka.SKIP_SETUP);this.defaultType="";this.variableTypes=[];this.variable=null;this.SERIALIZABLE=!0;this.menuGenerator_=ze.dropdownCreate;this.defaultVariableName="string"===typeof a?a:"";this.size_=new Aa(0,0);a!==Ka.SKIP_SETUP&&(l?this.configure_(l):this.setTypes(f,g),b&&this.setValidator(b))}configure_(a){super.configure_(a);this.setTypes(a.variableTypes,a.defaultType)}initModel(){var a=this.getSourceBlock();if(!a)throw new Ta;this.variable||(a=d.getOrCreateVariablePackage$$module$build$src$core$variables(a.workspace,
null,this.defaultVariableName,this.defaultType),this.doValueUpdate_(a.getId()))}shouldAddBorderRect_(){const a=this.getSourceBlock();if(!a)throw new Ta;return super.shouldAddBorderRect_()&&(!this.getConstants().FIELD_DROPDOWN_NO_BORDER_RECT_SHADOW||"variables_get"!==a.type)}fromXml(a){var b=this.getSourceBlock();if(!b)throw new Ta;const f=a.getAttribute("id"),g=a.textContent,l=a.getAttribute("variabletype")||a.getAttribute("variableType")||"";b=d.getOrCreateVariablePackage$$module$build$src$core$variables(b.workspace,
f,g,l);if(null!==l&&l!==b.type)throw Error("Serialized variable type with id '"+b.getId()+"' had type "+b.type+", and does not match variable field that references it: "+Xb(a)+".");this.setValue(b.getId())}toXml(a){this.initModel();a.id=this.variable.getId();a.textContent=this.variable.name;this.variable.type&&a.setAttribute("variabletype",this.variable.type);return a}saveState(a){var b=this.saveLegacyState(ze);if(null!==b)return b;this.initModel();b={id:this.variable.getId()};a&&(b.name=this.variable.name,
b.type=this.variable.type);return b}loadState(a){const b=this.getSourceBlock();if(!b)throw new Ta;this.loadLegacyState(ze,a)||(a=d.getOrCreateVariablePackage$$module$build$src$core$variables(b.workspace,a.id||null,a.name,a.type||""),this.setValue(a.getId()))}setSourceBlock(a){if(a.isShadow())throw Error("Variable fields are not allowed to exist on shadow blocks.");super.setSourceBlock(a)}getValue(){return this.variable?this.variable.getId():null}getText(){return this.variable?this.variable.name:""}getVariable(){return this.variable}getValidator(){return this.variable?
this.validator_:null}doClassValidation_(a){if(null===a)return null;var b=this.getSourceBlock();if(!b)throw new Ta;b=d.getVariable$$module$build$src$core$variables(b.workspace,a);if(!b)return console.warn("Variable id doesn't point to a real variable! ID was "+a),null;b=b.type;return this.typeIsAllowed(b)?a:(console.warn("Variable type doesn't match this field!  Type was "+b),null)}doValueUpdate_(a){const b=this.getSourceBlock();if(!b)throw new Ta;this.variable=d.getVariable$$module$build$src$core$variables(b.workspace,
a);super.doValueUpdate_(a)}typeIsAllowed(a){const b=this.getVariableTypes();if(!b)return!0;for(let f=0;f<b.length;f++)if(a===b[f])return!0;return!1}getVariableTypes(){var a=this.variableTypes;if(null===a&&this.sourceBlock_&&!this.sourceBlock_.isDeadOrDying())return this.sourceBlock_.workspace.getVariableTypes();a=a||[""];if(0===a.length)throw a=this.getText(),Error("'variableTypes' of field variable "+a+" was an empty list");return a}setTypes(a=null,b=""){if(Array.isArray(a)){let f=!1;for(let g=0;g<
a.length;g++)a[g]===b&&(f=!0);if(!f)throw Error("Invalid default type '"+b+"' in the definition of a FieldVariable");}else if(null!==a)throw Error("'variableTypes' was not an array in the definition of a FieldVariable");this.defaultType=b;this.variableTypes=a}refreshVariableName(){this.forceRerender()}onItemSelected_(a,b){a=b.getValue();if(this.sourceBlock_&&!this.sourceBlock_.isDeadOrDying()){if("RENAME_VARIABLE_ID"===a){d.renameVariable$$module$build$src$core$variables(this.sourceBlock_.workspace,
this.variable);return}if("DELETE_VARIABLE_ID"===a){this.sourceBlock_.workspace.deleteVariableById(this.variable.getId());return}}this.setValue(a)}referencesVariables(){return!0}static fromJson(a){return new this(Ua(a.variable),void 0,void 0,void 0,a)}static dropdownCreate(){if(!this.variable)throw Error("Tried to call dropdownCreate on a variable field with no variable selected.");const a=this.getText();let b=[];if(this.sourceBlock_&&!this.sourceBlock_.isDeadOrDying())for(var f=this.getVariableTypes(),
g=0;g<f.length;g++){const l=this.sourceBlock_.workspace.getVariablesOfType(f[g]);b=b.concat(l)}b.sort(Sd.compareByName);f=[];for(g=0;g<b.length;g++)f[g]=[b[g].name,b[g].getId()];f.push([d.Msg$$module$build$src$core$msg.RENAME_VARIABLE,"RENAME_VARIABLE_ID"]);d.Msg$$module$build$src$core$msg.DELETE_VARIABLE&&f.push([d.Msg$$module$build$src$core$msg.DELETE_VARIABLE.replace("%1",a),"DELETE_VARIABLE_ID"]);return f}};Zb("field_variable",ze);var Uh=class extends Mf{constructor(a,b,f,g,l,n){super(Ka.SKIP_SETUP);
this.min_=-Infinity;this.max_=Infinity;this.precision_=0;this.decimalPlaces=null;this.spellcheck_=!1;a!==Ka.SKIP_SETUP&&(n?this.configure_(n):this.setConstraints(b,f,g),this.setValue(a),l&&this.setValidator(l))}configure_(a){super.configure_(a);this.setMinInternal(a.min);this.setMaxInternal(a.max);this.setPrecisionInternal(a.precision)}setConstraints(a,b,f){this.setMinInternal(a);this.setMaxInternal(b);this.setPrecisionInternal(f);this.setValue(this.getValue())}setMin(a){this.setMinInternal(a);this.setValue(this.getValue())}setMinInternal(a){null==
a?this.min_=-Infinity:(a=Number(a),isNaN(a)||(this.min_=a))}getMin(){return this.min_}setMax(a){this.setMaxInternal(a);this.setValue(this.getValue())}setMaxInternal(a){null==a?this.max_=Infinity:(a=Number(a),isNaN(a)||(this.max_=a))}getMax(){return this.max_}setPrecision(a){this.setPrecisionInternal(a);this.setValue(this.getValue())}setPrecisionInternal(a){this.precision_=Number(a)||0;let b=String(this.precision_);b.includes("e")&&(b=this.precision_.toLocaleString("en-US",{maximumFractionDigits:20}));
const f=b.indexOf(".");this.decimalPlaces=-1===f?a?0:null:b.length-f-1}getPrecision(){return this.precision_}doClassValidation_(a){if(null===a)return null;a=`${a}`.replace(/O/gi,"0");a=a.replace(/,/g,"");a=a.replace(/infinity/i,"Infinity");a=Number(a||0);if(isNaN(a))return null;a=Math.min(Math.max(a,this.min_),this.max_);this.precision_&&isFinite(a)&&(a=Math.round(a/this.precision_)*this.precision_);null!==this.decimalPlaces&&(a=Number(a.toFixed(this.decimalPlaces)));return a}widgetCreate_(){const a=
super.widgetCreate_();-Infinity<this.min_&&(a.min=`${this.min_}`,bb(a,ab.VALUEMIN,this.min_));Infinity>this.max_&&(a.max=`${this.max_}`,bb(a,ab.VALUEMAX,this.max_));return a}static fromJson(a){return new this(a.value,void 0,void 0,void 0,void 0,a)}};Zb("field_number",Uh);Uh.prototype.DEFAULT_VALUE=0;var im=class extends Wc{constructor(a,b,f){super(String(null!=a?a:""),b,f);this.EDITABLE=!1;this.SERIALIZABLE=!0}static fromJson(a){return new this(Ua(a.text),void 0,a)}};Zb("field_label_serializable",
im);var $c=class extends Ka{constructor(a,b,f){super(Ka.SKIP_SETUP);this.SERIALIZABLE=!0;this.CURSOR="default";this.value_=this.value_;this.checkChar=$c.CHECK_CHAR;a!==Ka.SKIP_SETUP&&(f&&this.configure_(f),this.setValue(a),b&&this.setValidator(b))}configure_(a){super.configure_(a);a.checkCharacter&&(this.checkChar=a.checkCharacter)}saveState(){const a=this.saveLegacyState($c);return null!==a?a:this.getValueBoolean()}initView(){super.initView();const a=this.getTextElement();sa(a,"blocklyCheckbox");
a.style.display=this.value_?"block":"none"}render_(){this.textContent_&&(this.textContent_.nodeValue=this.getDisplayText_());this.updateSize_(this.getConstants().FIELD_CHECKBOX_X_OFFSET)}getDisplayText_(){return this.checkChar}setCheckCharacter(a){this.checkChar=a||$c.CHECK_CHAR;this.forceRerender()}showEditor_(){this.setValue(!this.value_)}doClassValidation_(a){return!0===a||"TRUE"===a?"TRUE":!1===a||"FALSE"===a?"FALSE":null}doValueUpdate_(a){this.value_=this.convertValueToBool(a);this.textElement_&&
(this.textElement_.style.display=this.value_?"block":"none")}getValue(){return this.value_?"TRUE":"FALSE"}getValueBoolean(){return this.value_}getText(){return String(this.convertValueToBool(this.value_))}convertValueToBool(a){return"string"===typeof a?"TRUE"===a:!!a}static fromJson(a){return new this(a.checked,void 0,a)}};$c.CHECK_CHAR="✓";Zb("field_checkbox",$c);$c.prototype.DEFAULT_VALUE=!1;var jm=class{constructor(a,b){this.draggable=a;this.workspace=b;this.dragTarget=null;this.startLoc=a.getRelativeToSurfaceXY()}onDragStart(a){this.draggable.startDrag(a)}onDrag(a,
b){this.moveDraggable(a,b);b=this.getRoot(this.draggable);Db(b)&&b.setDeleteStyle(this.wouldDeleteDraggable(a,b));this.updateDragTarget(a)}updateDragTarget(a){a=this.workspace.getDragTarget(a);const b=this.getRoot(this.draggable);if(this.dragTarget!==a){let f;null==(f=this.dragTarget)||f.onDragExit(b);null==a||a.onDragEnter(b)}null==a||a.onDragOver(b);this.dragTarget=a}moveDraggable(a,b){b=this.pixelsToWorkspaceUnits(b);b=fa.sum(this.startLoc,b);this.draggable.drag(b,a)}wouldDeleteDraggable(a,b){return(a=
this.workspace.getDragTarget(a))&&this.workspace.getComponentManager().hasCapability(a.id,Qa.Capability.DELETE_AREA)?a.wouldDelete(b):!1}onDragEnd(a){const b=d.getGroup$$module$build$src$core$events$utils();var f=this.workspace.getDragTarget(a);const g=this.getRoot(this.draggable);if(f){let l;null==(l=this.dragTarget)||l.onDrop(g)}this.shouldReturnToStart(a,g)&&this.draggable.revertDrag();(f=Db(g)&&this.wouldDeleteDraggable(a,g))&&this.draggable instanceof xb&&Vg(this.draggable.getRootBlock());this.draggable.endDrag(a);
f&&Db(g)&&(a=d.getGroup$$module$build$src$core$events$utils(),d.setGroup$$module$build$src$core$events$utils(b),g.dispose(),d.setGroup$$module$build$src$core$events$utils(a))}getRoot(a){return a instanceof xb?a.getRootBlock():a}shouldReturnToStart(a,b){return(a=this.workspace.getDragTarget(a))?a.shouldPreventMove(b):!1}pixelsToWorkspaceUnits(a){a=new fa(a.x/this.workspace.scale,a.y/this.workspace.scale);this.workspace.isMutator&&a.scale(1/this.workspace.options.parentWorkspace.scale);return a}};e(ba.BLOCK_DRAGGER,
Jb,jm);var Ae={};Ae.BlockDragStrategy=Ol;Ae.BubbleDragStrategy=Al;Ae.CommentDragStrategy=sl;Ae.Dragger=jm;var Vh=class extends Eb{constructor(a,b,f){super(a?a.workspace.id:void 0);this.type=O.BLOCK_DRAG;a&&(this.blockId=a.id,this.isStart=b,this.blocks=f)}toJson(){const a=super.toJson();if(void 0===this.isStart)throw Error("Whether this event is the start of a drag is undefined. Either pass the value to the constructor, or call fromJson");if(void 0===this.blockId)throw Error("The block ID is undefined. Either pass a block to the constructor, or call fromJson");
a.isStart=this.isStart;a.blockId=this.blockId;a.blocks=this.blocks;return a}static fromJson(a,b,f){b=super.fromJson(a,b,null!=f?f:new Vh);b.isStart=a.isStart;b.blockId=a.blockId;b.blocks=a.blocks;return b}};e(ba.EVENT,O.BLOCK_DRAG,Vh);var Wh=class extends Sc{constructor(a,b,f,g){super(a);this.type=O.BLOCK_FIELD_INTERMEDIATE_CHANGE;this.recordUndo=!1;a&&(this.name=b,this.oldValue=f,this.newValue=g)}toJson(){const a=super.toJson();if(!this.name)throw Error("The changed field name is undefined. Either pass a name to the constructor, or call fromJson.");
a.name=this.name;a.oldValue=this.oldValue;a.newValue=this.newValue;return a}static fromJson(a,b,f){b=super.fromJson(a,b,null!=f?f:new Wh);b.name=a.name;b.oldValue=a.oldValue;b.newValue=a.newValue;return b}isNull(){return this.oldValue===this.newValue}run(a){var b=this.getEventWorkspace_();if(!this.blockId)throw Error("The block ID is undefined. Either pass a block to the constructor, or call fromJson");b=b.getBlockById(this.blockId);if(!b)throw Error("The associated block is undefined. Either pass a block to the constructor, or call fromJson");
a=a?this.newValue:this.oldValue;(b=b.getField(this.name))?b.setValue(a):console.warn("Can't set non-existent field: "+this.name)}};e(ba.EVENT,O.BLOCK_FIELD_INTERMEDIATE_CHANGE,Wh);var Xh=class extends Sc{constructor(a){super(a);this.type=O.BLOCK_MOVE;a&&(a.isShadow()&&(this.recordUndo=!1),a=this.currentLocation(),this.oldParentId=a.parentId,this.oldInputName=a.inputName,this.oldCoordinate=a.coordinate)}toJson(){const a=super.toJson();a.oldParentId=this.oldParentId;a.oldInputName=this.oldInputName;
this.oldCoordinate&&(a.oldCoordinate=`${Math.round(this.oldCoordinate.x)}, `+`${Math.round(this.oldCoordinate.y)}`);a.newParentId=this.newParentId;a.newInputName=this.newInputName;this.newCoordinate&&(a.newCoordinate=`${Math.round(this.newCoordinate.x)}, `+`${Math.round(this.newCoordinate.y)}`);this.reason&&(a.reason=this.reason);this.recordUndo||(a.recordUndo=this.recordUndo);return a}static fromJson(a,b,f){b=super.fromJson(a,b,null!=f?f:new Xh);b.oldParentId=a.oldParentId;b.oldInputName=a.oldInputName;
a.oldCoordinate&&(f=a.oldCoordinate.split(","),b.oldCoordinate=new fa(Number(f[0]),Number(f[1])));b.newParentId=a.newParentId;b.newInputName=a.newInputName;a.newCoordinate&&(f=a.newCoordinate.split(","),b.newCoordinate=new fa(Number(f[0]),Number(f[1])));void 0!==a.reason&&(b.reason=a.reason);void 0!==a.recordUndo&&(b.recordUndo=a.recordUndo);return b}recordNew(){const a=this.currentLocation();this.newParentId=a.parentId;this.newInputName=a.inputName;this.newCoordinate=a.coordinate}setReason(a){this.reason=
a}currentLocation(){var a=this.getEventWorkspace_();if(!this.blockId)throw Error("The block ID is undefined. Either pass a block to the constructor, or call fromJson");var b=a.getBlockById(this.blockId);if(!b)throw Error("The block associated with the block move event could not be found");a={};const f=b.getParent();if(f){if(a.parentId=f.id,b=f.getInputWithBlock(b))a.inputName=b.name}else a.coordinate=b.getRelativeToSurfaceXY();return a}isNull(){return this.oldParentId===this.newParentId&&this.oldInputName===
this.newInputName&&fa.equals(this.oldCoordinate,this.newCoordinate)}run(a){var b=this.getEventWorkspace_();if(!this.blockId)throw Error("The block ID is undefined. Either pass a block to the constructor, or call fromJson");var f=b.getBlockById(this.blockId);if(f){var g=a?this.newParentId:this.oldParentId,l=a?this.newInputName:this.oldInputName;a=a?this.newCoordinate:this.oldCoordinate;if(g){var n=b.getBlockById(g);if(!n){console.warn("Can't connect to non-existent block: "+g);return}}f.getParent()&&
f.unplug();if(a)l=f.getRelativeToSurfaceXY(),f.moveBy(a.x-l.x,a.y-l.y,this.reason);else{b=f.outputConnection;if(!b||f.previousConnection&&f.previousConnection.isConnected())b=f.previousConnection;let x,B;f=null==(B=b)?void 0:B.type;if(l){if(f=n.getInput(l))x=f.connection}else f===oa.PREVIOUS_STATEMENT&&(x=n.nextConnection);x&&b?b.connect(x):console.warn("Can't connect to non-existent input: "+l)}}else console.warn("Can't move non-existent block: "+this.blockId)}};e(ba.EVENT,O.BLOCK_MOVE,Xh);var Yh=
class extends Eb{constructor(a,b,f){super(a?a.workspace.id:void 0);this.type=O.BUBBLE_OPEN;a&&(this.blockId=a.id,this.isOpen=b,this.bubbleType=f)}toJson(){const a=super.toJson();if(void 0===this.isOpen)throw Error("Whether this event is for opening the bubble is undefined. Either pass the value to the constructor, or call fromJson");if(!this.bubbleType)throw Error("The type of bubble is undefined. Either pass the value to the constructor, or call fromJson");a.isOpen=this.isOpen;a.bubbleType=this.bubbleType;
a.blockId=this.blockId||"";return a}static fromJson(a,b,f){b=super.fromJson(a,b,null!=f?f:new Yh);b.isOpen=a.isOpen;b.bubbleType=a.bubbleType;b.blockId=a.blockId;return b}},km;(function(a){a.MUTATOR="mutator";a.COMMENT="comment";a.WARNING="warning"})(km||={});e(ba.EVENT,O.BUBBLE_OPEN,Yh);var Sb=class extends vd{constructor(a){super();this.isBlank=!a;a&&(this.commentId=a.id,this.workspaceId=a.workspace.id,this.group=d.getGroup$$module$build$src$core$events$utils(),this.recordUndo=ea())}toJson(){const a=
super.toJson();if(!this.commentId)throw Error("The comment ID is undefined. Either pass a comment to the constructor, or call fromJson");a.commentId=this.commentId;return a}static fromJson(a,b,f){b=super.fromJson(a,b,null!=f?f:new Sb);b.commentId=a.commentId;return b}static CommentCreateDeleteHelper(a,b){const f=a.getEventWorkspace_();if(b){if(!a.json)throw Error("Encountered a comment event without proper json");Pe(a.json,f)}else{if(!a.commentId)throw Error("The comment ID is undefined. Either pass a comment to the constructor, or call fromJson");
(b=f.getCommentById(a.commentId))?b.dispose():console.warn("Can't delete non-existent comment: "+a.commentId)}}},Zh=class extends Sb{constructor(a,b,f){super(a);this.type=O.COMMENT_CHANGE;a&&(this.oldContents_="undefined"===typeof b?"":b,this.newContents_="undefined"===typeof f?"":f)}toJson(){const a=super.toJson();if(!this.oldContents_)throw Error("The old contents is undefined. Either pass a value to the constructor, or call fromJson");if(!this.newContents_)throw Error("The new contents is undefined. Either pass a value to the constructor, or call fromJson");
a.oldContents=this.oldContents_;a.newContents=this.newContents_;return a}static fromJson(a,b,f){b=super.fromJson(a,b,null!=f?f:new Zh);b.oldContents_=a.oldContents;b.newContents_=a.newContents;return b}isNull(){return this.oldContents_===this.newContents_}run(a){var b=this.getEventWorkspace_();if(!this.commentId)throw Error("The comment ID is undefined. Either pass a comment to the constructor, or call fromJson");if(b=b.getCommentById(this.commentId)){var f=a?this.newContents_:this.oldContents_;if(void 0===
f){if(a)throw Error("The new contents is undefined. Either pass a value to the constructor, or call fromJson");throw Error("The old contents is undefined. Either pass a value to the constructor, or call fromJson");}b.setText(f)}else console.warn("Can't change non-existent comment: "+this.commentId)}};e(ba.EVENT,O.COMMENT_CHANGE,Zh);var $h=class extends Sb{constructor(a,b){super(a);this.newCollapsed=b;this.type=O.COMMENT_COLLAPSE}toJson(){const a=super.toJson();if(void 0===this.newCollapsed)throw Error("The new collapse value undefined. Either call recordNew, or call fromJson");
a.newCollapsed=this.newCollapsed;return a}static fromJson(a,b,f){b=super.fromJson(a,b,null!=f?f:new $h);b.newCollapsed=a.newCollapsed;return b}run(a){var b=this.getEventWorkspace_();if(!this.commentId)throw Error("The comment ID is undefined. Either pass a comment to the constructor, or call fromJson");(b=b.getCommentById(this.commentId))?b.setCollapsed(a?!!this.newCollapsed:!this.newCollapsed):console.warn("Can't collapse or uncollapse non-existent comment: "+this.commentId)}};e(ba.EVENT,O.COMMENT_COLLAPSE,
$h);var ai=class extends Sb{constructor(a){super(a);this.type=O.COMMENT_CREATE;a&&(this.xml=hf(a),this.json=Od(a,{addCoordinates:!0}))}toJson(){const a=super.toJson();if(!this.xml)throw Error("The comment XML is undefined. Either pass a comment to the constructor, or call fromJson");if(!this.json)throw Error("The comment JSON is undefined. Either pass a block to the constructor, or call fromJson");a.xml=Xb(this.xml);a.json=this.json;return a}static fromJson(a,b,f){b=super.fromJson(a,b,null!=f?f:new ai);
b.xml=d.textToDom$$module$build$src$core$utils$xml(a.xml);b.json=a.json;return b}run(a){Sb.CommentCreateDeleteHelper(this,a)}};e(ba.EVENT,O.COMMENT_CREATE,ai);var bi=class extends Sb{constructor(a){super(a);this.type=O.COMMENT_DELETE;a&&(this.xml=hf(a),this.json=Od(a,{addCoordinates:!0}))}run(a){Sb.CommentCreateDeleteHelper(this,!a)}toJson(){const a=super.toJson();if(!this.xml)throw Error("The comment XML is undefined. Either pass a comment to the constructor, or call fromJson");if(!this.json)throw Error("The comment JSON is undefined. Either pass a block to the constructor, or call fromJson");
a.xml=Xb(this.xml);a.json=this.json;return a}static fromJson(a,b,f){b=super.fromJson(a,b,null!=f?f:new bi);b.xml=d.textToDom$$module$build$src$core$utils$xml(a.xml);b.json=a.json;return b}};e(ba.EVENT,O.COMMENT_DELETE,bi);var ci=class extends Eb{constructor(a,b){super(a?a.workspace.id:void 0);this.type=O.COMMENT_DRAG;a&&(this.commentId=a.id,this.isStart=b)}toJson(){const a=super.toJson();if(void 0===this.isStart)throw Error("Whether this event is the start of a drag is undefined. Either pass the value to the constructor, or call fromJson");
if(void 0===this.commentId)throw Error("The comment ID is undefined. Either pass a comment to the constructor, or call fromJson");a.isStart=this.isStart;a.commentId=this.commentId;return a}static fromJson(a,b,f){b=super.fromJson(a,b,null!=f?f:new ci);b.isStart=a.isStart;b.commentId=a.commentId;return b}};e(ba.EVENT,O.COMMENT_DRAG,ci);var di=class extends Sb{constructor(a){super(a);this.type=O.COMMENT_MOVE;a&&(this.comment_=a,this.oldCoordinate_=a.getRelativeToSurfaceXY())}recordNew(){if(this.newCoordinate_)throw Error("Tried to record the new position of a comment on the same event twice.");
if(!this.comment_)throw Error("The comment is undefined. Pass a comment to the constructor if you want to use the record functionality");this.newCoordinate_=this.comment_.getRelativeToSurfaceXY()}setReason(a){this.reason=a}setOldCoordinate(a){this.oldCoordinate_=a}toJson(){const a=super.toJson();if(!this.oldCoordinate_)throw Error("The old comment position is undefined. Either pass a comment to the constructor, or call fromJson");if(!this.newCoordinate_)throw Error("The new comment position is undefined. Either call recordNew, or call fromJson");
a.oldCoordinate=`${Math.round(this.oldCoordinate_.x)}, `+`${Math.round(this.oldCoordinate_.y)}`;a.newCoordinate=Math.round(this.newCoordinate_.x)+","+Math.round(this.newCoordinate_.y);return a}static fromJson(a,b,f){b=super.fromJson(a,b,null!=f?f:new di);f=a.oldCoordinate.split(",");b.oldCoordinate_=new fa(Number(f[0]),Number(f[1]));f=a.newCoordinate.split(",");b.newCoordinate_=new fa(Number(f[0]),Number(f[1]));return b}isNull(){return fa.equals(this.oldCoordinate_,this.newCoordinate_)}run(a){var b=
this.getEventWorkspace_();if(!this.commentId)throw Error("The comment ID is undefined. Either pass a comment to the constructor, or call fromJson");if(b=b.getCommentById(this.commentId)){a=a?this.newCoordinate_:this.oldCoordinate_;if(!a)throw Error("Either oldCoordinate_ or newCoordinate_ is undefined. Either pass a comment to the constructor and call recordNew, or call fromJson");b.moveTo(a)}else console.warn("Can't move non-existent comment: "+this.commentId)}};e(ba.EVENT,O.COMMENT_MOVE,di);var ei=
class extends Sb{constructor(a){super(a);this.type=O.COMMENT_RESIZE;a&&(this.oldSize=a.getSize())}recordCurrentSizeAsNewSize(){if(this.newSize)throw Error("Tried to record the new size of a comment on the same event twice.");var a=this.getEventWorkspace_();if(!this.commentId)throw Error("The comment ID is undefined. Either pass a comment to the constructor, or call fromJson");a=a.getCommentById(this.commentId);if(!a)throw Error("The comment associated with the comment resize event could not be found");
this.newSize=a.getSize()}toJson(){const a=super.toJson();if(!this.oldSize)throw Error("The old comment size is undefined. Either pass a comment to the constructor, or call fromJson");if(!this.newSize)throw Error("The new comment size is undefined. Either call recordCurrentSizeAsNewSize, or call fromJson");a.oldWidth=Math.round(this.oldSize.width);a.oldHeight=Math.round(this.oldSize.height);a.newWidth=Math.round(this.newSize.width);a.newHeight=Math.round(this.newSize.height);return a}static fromJson(a,
b,f){b=super.fromJson(a,b,null!=f?f:new ei);b.oldSize=new Aa(a.oldWidth,a.oldHeight);b.newSize=new Aa(a.newWidth,a.newHeight);return b}isNull(){return Aa.equals(this.oldSize,this.newSize)}run(a){var b=this.getEventWorkspace_();if(!this.commentId)throw Error("The comment ID is undefined. Either pass a comment to the constructor, or call fromJson");if(b=b.getCommentById(this.commentId)){a=a?this.newSize:this.oldSize;if(!a)throw Error("Either oldSize or newSize is undefined. Either pass a comment to the constructor and call recordCurrentSizeAsNewSize, or call fromJson");
b.setSize(a)}else console.warn("Can't resize non-existent comment: "+this.commentId)}};e(ba.EVENT,O.COMMENT_RESIZE,ei);var fi=class extends Eb{constructor(a,b,f){super(f);this.type=O.TOOLBOX_ITEM_SELECT;this.oldItem=null!=a?a:void 0;this.newItem=null!=b?b:void 0}toJson(){const a=super.toJson();a.oldItem=this.oldItem;a.newItem=this.newItem;return a}static fromJson(a,b,f){b=super.fromJson(a,b,null!=f?f:new fi);b.oldItem=a.oldItem;b.newItem=a.newItem;return b}};e(ba.EVENT,O.TOOLBOX_ITEM_SELECT,fi);var lm=
class extends vd{constructor(a){super();this.isBlank=!0;this.recordUndo=!1;this.type=O.FINISHED_LOADING;this.isBlank=!!a;a&&(this.workspaceId=a.id)}};e(ba.EVENT,O.FINISHED_LOADING,lm);d.BLOCK_CHANGE$$module$build$src$core$events$events=O.BLOCK_CHANGE;d.BLOCK_CREATE$$module$build$src$core$events$events=O.BLOCK_CREATE;d.BLOCK_DELETE$$module$build$src$core$events$events=O.BLOCK_DELETE;var wo=O.BLOCK_DRAG;d.BLOCK_MOVE$$module$build$src$core$events$events=O.BLOCK_MOVE;var xo=O.BLOCK_FIELD_INTERMEDIATE_CHANGE;
var yo=O.BUBBLE_OPEN;var zo=O.BLOCK_CHANGE;var Ao=O.CLICK;var Bo=O.COMMENT_CHANGE;var Co=O.COMMENT_CREATE;var Do=O.COMMENT_DELETE;var Eo=O.COMMENT_MOVE;var Fo=O.COMMENT_RESIZE;var Go=O.COMMENT_DRAG;var Ho=O.BLOCK_CREATE;var Io=O.BLOCK_DELETE;var Jo=O.FINISHED_LOADING;var Ko=O.MARKER_MOVE;var Lo=O.BLOCK_MOVE;var Mo=O.SELECTED;var No=O.THEME_CHANGE;var Oo=O.TOOLBOX_ITEM_SELECT;var Po=O.TRASHCAN_OPEN;var Qo=O.UI;var Ro=O.VAR_CREATE;var So=O.VAR_DELETE;var To=O.VAR_RENAME;var Uo=O.VIEWPORT_CHANGE;var ma=
{};ma.Abstract=vd;ma.BLOCK_CHANGE=d.BLOCK_CHANGE$$module$build$src$core$events$events;ma.BLOCK_CREATE=d.BLOCK_CREATE$$module$build$src$core$events$events;ma.BLOCK_DELETE=d.BLOCK_DELETE$$module$build$src$core$events$events;ma.BLOCK_DRAG=wo;ma.BLOCK_FIELD_INTERMEDIATE_CHANGE=xo;ma.BLOCK_MOVE=d.BLOCK_MOVE$$module$build$src$core$events$events;ma.BUBBLE_OPEN=yo;ma.BUMP_EVENTS=uk;ma.BlockBase=Sc;ma.BlockChange=Tc;ma.BlockCreate=uh;ma.BlockDelete=Fh;ma.BlockDrag=Vh;ma.BlockFieldIntermediateChange=Wh;ma.BlockMove=
Xh;ma.BubbleOpen=Yh;ma.BubbleType=km;ma.CHANGE=zo;ma.CLICK=Ao;ma.COMMENT_CHANGE=Bo;ma.COMMENT_CREATE=Co;ma.COMMENT_DELETE=Do;ma.COMMENT_DRAG=Go;ma.COMMENT_MOVE=Eo;ma.COMMENT_RESIZE=Fo;ma.CREATE=Ho;ma.Click=mh;ma.ClickTarget=bl;ma.CommentBase=Sb;ma.CommentChange=Zh;ma.CommentCollapse=$h;ma.CommentCreate=ai;ma.CommentDelete=bi;ma.CommentDrag=ci;ma.CommentMove=di;ma.CommentResize=ei;ma.DELETE=Io;ma.FINISHED_LOADING=Jo;ma.FinishedLoading=lm;ma.MARKER_MOVE=Ko;ma.MOVE=Lo;ma.MarkerMove=Gh;ma.SELECTED=Mo;
ma.Selected=Lh;ma.THEME_CHANGE=No;ma.TOOLBOX_ITEM_SELECT=Oo;ma.TRASHCAN_OPEN=Po;ma.ThemeChange=vh;ma.ToolboxItemSelect=fi;ma.TrashcanOpen=Nh;ma.UI=Qo;ma.UiBase=Eb;ma.VAR_CREATE=Ro;ma.VAR_DELETE=So;ma.VAR_RENAME=To;ma.VIEWPORT_CHANGE=Uo;ma.VarBase=me;ma.VarCreate=th;ma.VarDelete=Ih;ma.VarRename=Jh;ma.ViewportChange=wh;ma.clearPendingUndo=ca;ma.disable=d.disable$$module$build$src$core$events$utils;ma.disableOrphans=function(a){if((E(a)||N(a))&&a.workspaceId){var b=ua(a.workspaceId);if(!a.blockId)throw Error("Encountered a blockEvent without a proper blockId");
if(a=b.getBlockById(a.blockId)){const f=Gd;try{Gd=!1;const g=a.getParent();if(g&&!g.hasDisabledReason("ORPHANED_BLOCK")){const l=a.getDescendants(!1);for(let n=0,x;x=l[n];n++)x.setDisabledReason(!1,"ORPHANED_BLOCK")}else if((a.outputConnection||a.previousConnection)&&!b.isDragging()){do a.setDisabledReason(!0,"ORPHANED_BLOCK"),a=a.getNextBlock();while(a)}}finally{Gd=f}}}};ma.enable=d.enable$$module$build$src$core$events$utils;ma.filter=Z;ma.fire=aa;ma.fromJson=function(a,b){const f=la(a.type);if(!f)throw Error("Unknown event type.");
return f.fromJson(a,b)};ma.get=la;ma.getDescendantIds=Da;ma.getGroup=d.getGroup$$module$build$src$core$events$utils;ma.getRecordUndo=ea;ma.isEnabled=ia;ma.setGroup=d.setGroup$$module$build$src$core$events$utils;ma.setRecordUndo=d.setRecordUndo$$module$build$src$core$events$utils;var Hb={};Hb.BottomRow=$l;Hb.ConstantProvider=Yl;Hb.Drawer=Zl;Hb.MarkerSvg=dm;Hb.PathObject=em;Hb.RenderInfo=cm;Hb.Renderer=Sh;Hb.RightConnectionShape=am;Hb.StatementInput=rf;Hb.TopRow=bm;$k();var Ya={};Ya.registerCleanup=
Kk;Ya.registerCollapse=Mk;Ya.registerCollapseExpandBlock=Tk;Ya.registerComment=Rk;Ya.registerCommentCreate=Zk;Ya.registerCommentDelete=Xk;Ya.registerCommentDuplicate=Yk;Ya.registerCommentOptions=function(){Yk();Xk();Zk()};Ya.registerDefaultOptions=$k;Ya.registerDelete=Vk;Ya.registerDeleteAll=Pk;Ya.registerDisable=Uk;Ya.registerDuplicate=Qk;Ya.registerExpand=Nk;Ya.registerHelp=Wk;Ya.registerInline=Sk;Ya.registerRedo=Jk;Ya.registerUndo=Ik;var Pf={};Pf.CommentView=tl;Pf.RenderedWorkspaceComment=kf;Pf.WorkspaceComment=
lf;var Be={};Be.Bubble=Ha;Be.MiniWorkspaceBubble=gc;Be.TextBubble=El;Be.TextInputBubble=Bl;var mm=class extends Ef{constructor(){super();this.FIELD_TEXT_BASELINE_CENTER=!1;this.DARK_PATH_OFFSET=1;this.MAX_BOTTOM_WIDTH=30;this.STATEMENT_BOTTOM_SPACER=-this.NOTCH_HEIGHT/2}getCSS_(a){return super.getCSS_(a).concat([`${a} .blocklyInsertionMarker>.blocklyPathLight,`,`${a} .blocklyInsertionMarker>.blocklyPathDark {`,`fill-opacity: ${this.INSERTION_MARKER_OPACITY};`,"stroke: none;","}"])}},nm=class{constructor(a){this.inlineSteps_=
this.steps_="";this.info_=a;this.RTL_=this.info_.RTL;a=a.getRenderer();this.constants_=a.getConstants();this.highlightConstants_=a.getHighlightConstants();this.highlightOffset=this.highlightConstants_.OFFSET;this.outsideCornerPaths_=this.highlightConstants_.OUTSIDE_CORNER;this.insideCornerPaths_=this.highlightConstants_.INSIDE_CORNER;this.puzzleTabPaths_=this.highlightConstants_.PUZZLE_TAB;this.notchPaths_=this.highlightConstants_.NOTCH;this.startPaths_=this.highlightConstants_.START_HAT;this.jaggedTeethPaths_=
this.highlightConstants_.JAGGED_TEETH}getPath(){return this.steps_+"\n"+this.inlineSteps_}drawTopCorner(a){this.steps_+=Oa(a.xPos,this.info_.startY);for(let b=0,f;f=a.elements[b];b++)G.isLeftSquareCorner(f)?this.steps_+=this.highlightConstants_.START_POINT:G.isLeftRoundedCorner(f)?this.steps_+=this.outsideCornerPaths_.topLeft(this.RTL_):G.isPreviousConnection(f)?this.steps_+=this.notchPaths_.pathLeft:G.isHat(f)?this.steps_+=this.startPaths_.path(this.RTL_):G.isSpacer(f)&&0!==f.width&&(this.steps_+=
pa("H",f.xPos+f.width-this.highlightOffset));this.steps_+=pa("H",a.xPos+a.width-this.highlightOffset)}drawJaggedEdge_(a){this.info_.RTL&&(this.steps_+=this.jaggedTeethPaths_.pathLeft+pa("v",a.height-this.jaggedTeethPaths_.height-this.highlightOffset))}drawValueInput(a){const b=a.getLastInput();if(this.RTL_){const f=a.height-b.connectionHeight;this.steps_+=Za(b.xPos+b.width-this.highlightOffset,a.yPos)+this.puzzleTabPaths_.pathDown(this.RTL_)+pa("v",f)}else this.steps_+=Za(b.xPos+b.width,a.yPos)+this.puzzleTabPaths_.pathDown(this.RTL_)}drawStatementInput(a){const b=
a.getLastInput();if(b)if(this.RTL_){const f=a.height-2*this.insideCornerPaths_.height;this.steps_+=Za(b.xPos,a.yPos)+this.insideCornerPaths_.pathTop(this.RTL_)+pa("v",f)+this.insideCornerPaths_.pathBottom(this.RTL_)+$b(a.width-b.xPos-this.insideCornerPaths_.width,0)}else this.steps_+=Za(b.xPos,a.yPos+a.height)+this.insideCornerPaths_.pathBottom(this.RTL_)+$b(a.width-b.xPos-this.insideCornerPaths_.width,0)}drawRightSideRow(a){const b=a.xPos+a.width-this.highlightOffset;a instanceof Dh&&a.followsStatement&&
(this.steps_+=pa("H",b));this.RTL_&&(this.steps_+=pa("H",b),a.height>this.highlightOffset&&(this.steps_+=pa("V",a.yPos+a.height-this.highlightOffset)))}drawBottomRow(a){if(this.RTL_)this.steps_+=pa("V",a.baseline-this.highlightOffset);else{const b=this.info_.bottomRow.elements[0];G.isLeftSquareCorner(b)?this.steps_+=Za(a.xPos+this.highlightOffset,a.baseline-this.highlightOffset):G.isLeftRoundedCorner(b)&&(this.steps_+=Za(a.xPos,a.baseline),this.steps_+=this.outsideCornerPaths_.bottomLeft())}}drawLeft(){var a=
this.info_.outputConnection;a&&(a=a.connectionOffsetY+a.height,this.RTL_?this.steps_+=Za(this.info_.startX,a):(this.steps_+=Za(this.info_.startX+this.highlightOffset,this.info_.bottomRow.baseline-this.highlightOffset),this.steps_+=pa("V",a)),this.steps_+=this.puzzleTabPaths_.pathUp(this.RTL_));this.RTL_||(a=this.info_.topRow,G.isLeftRoundedCorner(a.elements[0])?this.steps_+=pa("V",this.outsideCornerPaths_.height):this.steps_+=pa("V",a.capline+this.highlightOffset))}drawInlineInput(a){const b=this.highlightOffset,
f=a.xPos+a.connectionWidth;var g=a.centerline-a.height/2;const l=a.width-a.connectionWidth,n=g+b;this.RTL_?(g=a.connectionOffsetY-b,a=a.height-(a.connectionOffsetY+a.connectionHeight)+b,this.inlineSteps_+=Za(f-b,n)+pa("v",g)+this.puzzleTabPaths_.pathDown(this.RTL_)+pa("v",a)+pa("h",l)):this.inlineSteps_+=Za(a.xPos+a.width+b,n)+pa("v",a.height)+pa("h",-l)+Za(f,g+a.connectionOffsetY)+this.puzzleTabPaths_.pathDown(this.RTL_)}},om=class extends Ff{constructor(a,b){super(a,b);this.highlighter_=new nm(b)}draw(){this.drawOutline_();
this.drawInternals_();this.updateConnectionHighlights();const a=this.block_.pathObject;a.setPath(this.outlinePath_+"\n"+this.inlinePath_);a.setHighlightPath(this.highlighter_.getPath());this.info_.RTL&&a.flipRTL();this.recordSizeOnBlock_()}drawTop_(){this.highlighter_.drawTopCorner(this.info_.topRow);this.highlighter_.drawRightSideRow(this.info_.topRow);super.drawTop_()}drawJaggedEdge_(a){this.highlighter_.drawJaggedEdge_(a);super.drawJaggedEdge_(a)}drawValueInput_(a){this.highlighter_.drawValueInput(a);
super.drawValueInput_(a)}drawStatementInput_(a){this.highlighter_.drawStatementInput(a);super.drawStatementInput_(a)}drawRightSideRow_(a){this.highlighter_.drawRightSideRow(a);this.outlinePath_+=pa("H",a.xPos+a.width)+pa("V",a.yPos+a.height)}drawBottom_(){this.highlighter_.drawBottomRow(this.info_.bottomRow);super.drawBottom_()}drawLeft_(){this.highlighter_.drawLeft();super.drawLeft_()}drawInlineInput_(a){this.highlighter_.drawInlineInput(a);super.drawInlineInput_(a)}positionInlineInputConnection_(a){const b=
a.centerline-a.height/2;if(a.connectionModel){let f=a.xPos+a.connectionWidth+this.constants_.DARK_PATH_OFFSET;this.info_.RTL&&(f*=-1);a.connectionModel.setOffsetInBlock(f,b+a.connectionOffsetY+this.constants_.DARK_PATH_OFFSET)}}positionStatementInputConnection_(a){const b=a.getLastInput();if(null==b?0:b.connectionModel){let f=a.xPos+a.statementEdge+b.notchOffset;f=this.info_.RTL?-1*f:f+this.constants_.DARK_PATH_OFFSET;b.connectionModel.setOffsetInBlock(f,a.yPos+this.constants_.DARK_PATH_OFFSET)}}positionExternalValueConnection_(a){const b=
a.getLastInput();if(b&&b.connectionModel){let f=a.xPos+a.width+this.constants_.DARK_PATH_OFFSET;this.info_.RTL&&(f*=-1);b.connectionModel.setOffsetInBlock(f,a.yPos)}}positionNextConnection_(){const a=this.info_.bottomRow;if(a.connection){const b=a.connection,f=b.xPos;b.connectionModel.setOffsetInBlock((this.info_.RTL?-f:f)+this.constants_.DARK_PATH_OFFSET/2,a.baseline+this.constants_.DARK_PATH_OFFSET)}}},pm=class{constructor(a){this.OFFSET=.5;this.constantProvider=a;this.START_POINT=Oa(this.OFFSET,
this.OFFSET)}init(){this.INSIDE_CORNER=this.makeInsideCorner();this.OUTSIDE_CORNER=this.makeOutsideCorner();this.PUZZLE_TAB=this.makePuzzleTab();this.NOTCH=this.makeNotch();this.JAGGED_TEETH=this.makeJaggedTeeth();this.START_HAT=this.makeStartHat()}makeInsideCorner(){const a=this.constantProvider.CORNER_RADIUS,b=this.OFFSET,f=(1-Math.SQRT1_2)*(a+b)-b,g=Oa(f,f)+Va("a","0 0,0",a,qa(-f-b,a-f)),l=Va("a","0 0,0",a+b,qa(a+b,a+b)),n=Oa(f,-f)+Va("a","0 0,0",a+b,qa(a-f,f+b));return{width:a+b,height:a,pathTop(x){return x?
g:""},pathBottom(x){return x?l:n}}}makeOutsideCorner(){const a=this.constantProvider.CORNER_RADIUS,b=this.OFFSET,f=(1-Math.SQRT1_2)*(a-b)+b,g=Oa(f,f)+Va("a","0 0,1",a-b,qa(a-f,-f+b)),l=Oa(b,a)+Va("a","0 0,1",a-b,qa(a,-a+b)),n=-f,x=Oa(f,n)+Va("a","0 0,1",a-b,qa(-f+b,-n-a));return{height:a,topLeft(B){return B?g:l},bottomLeft(){return x}}}makePuzzleTab(){const a=this.constantProvider.TAB_WIDTH,b=this.constantProvider.TAB_HEIGHT,f=Oa(-2,-b+3.4)+$b(-.45*a,-2.1),g=pa("v",2.5)+Oa(.97*-a,2.5)+nb("q",[qa(.05*
-a,10),qa(.3*a,9.5)])+Oa(.67*a,-1.9)+pa("v",2.5),l=pa("v",-1.5)+Oa(-.92*a,-.5)+nb("q",[qa(-.19*a,-5.5),qa(0,-11)])+Oa(.92*a,1),n=Oa(-5,b-.7)+$b(.46*a,-2.1);return{width:a,height:b,pathUp(x){return x?f:l},pathDown(x){return x?g:n}}}makeNotch(){return{pathLeft:pa("h",this.OFFSET)+this.constantProvider.NOTCH.pathLeft}}makeJaggedTeeth(){return{pathLeft:$b(5.1,2.6)+Oa(-10.2,6.8)+$b(5.1,2.6),height:12,width:10.2}}makeStartHat(){const a=this.constantProvider.START_HAT.height,b=Oa(25,-8.7)+nb("c",[qa(29.7,
-6.2),qa(57.2,-.5),qa(75,8.7)]),f=nb("c",[qa(17.8,-9.2),qa(45.3,-14.9),qa(75,-8.7)])+Za(100.5,a+.5);return{path(g){return g?b:f}}}},qm=class extends Bh{constructor(a,b){super(a,b);this.constants_=a;this.connectedBlock&&(this.width+=this.constants_.DARK_PATH_OFFSET,this.height+=this.constants_.DARK_PATH_OFFSET)}},rm=class extends re{constructor(a,b){super(a,b);this.constants_=a;this.connectedBlock&&(this.height+=this.constants_.DARK_PATH_OFFSET)}},sm=class extends ue{constructor(a,b){super(a,b);this.renderer_=
a}getRenderer(){return this.renderer_}populateBottomRow_(){super.populateBottomRow_();this.block_.inputList.length&&this.block_.inputList[this.block_.inputList.length-1]instanceof sb||(this.bottomRow.minHeight=this.constants_.MEDIUM_PADDING-this.constants_.DARK_PATH_OFFSET)}addInput_(a,b){if(this.isInline&&a instanceof d.ValueInput$$module$build$src$core$inputs$value_input)b.elements.push(new qm(this.constants_,a)),b.hasInlineInput=!0;else if(a instanceof sb)b.elements.push(new rm(this.constants_,
a)),b.hasStatement=!0;else if(a instanceof d.ValueInput$$module$build$src$core$inputs$value_input)b.elements.push(new Df(this.constants_,a)),b.hasExternalInput=!0;else if(a instanceof Pb||a instanceof kc)b.minHeight=Math.max(b.minHeight,this.constants_.DUMMY_INPUT_MIN_HEIGHT),b.hasDummyInput=!0;this.isInline||null!==b.align||(b.align=a.align)}addElemSpacing_(){let a=!1;for(let f=0,g;g=this.rows[f];f++)g.hasExternalInput&&(a=!0);for(let f=0,g;g=this.rows[f];f++){var b=g.elements;g.elements=[];g.startsWithElemSpacer()&&
g.elements.push(new rb(this.constants_,this.getInRowSpacing_(null,b[0])));if(b.length){for(let l=0;l<b.length-1;l++){g.elements.push(b[l]);const n=this.getInRowSpacing_(b[l],b[l+1]);g.elements.push(new rb(this.constants_,n))}g.elements.push(b[b.length-1]);g.endsWithElemSpacer()&&(b=this.getInRowSpacing_(b[b.length-1],null),a&&g.hasDummyInput&&(b+=this.constants_.TAB_WIDTH),g.elements.push(new rb(this.constants_,b)))}}}getInRowSpacing_(a,b){if(!a)return b&&G.isField(b)&&b.isEditable?this.constants_.MEDIUM_PADDING:
b&&G.isInlineInput(b)?this.constants_.MEDIUM_LARGE_PADDING:b&&G.isStatementInput(b)?this.constants_.STATEMENT_INPUT_PADDING_LEFT:this.constants_.LARGE_PADDING;if(!G.isInput(a)&&(!b||G.isStatementInput(b)))return G.isField(a)&&a.isEditable?this.constants_.MEDIUM_PADDING:G.isIcon(a)?2*this.constants_.LARGE_PADDING+1:G.isHat(a)?this.constants_.NO_PADDING:G.isPreviousOrNextConnection(a)?this.constants_.LARGE_PADDING:G.isLeftRoundedCorner(a)?this.constants_.MIN_BLOCK_WIDTH:G.isJaggedEdge(a)?this.constants_.NO_PADDING:
this.constants_.LARGE_PADDING;if(G.isInput(a)&&!b){if(G.isExternalInput(a))return this.constants_.NO_PADDING;if(G.isInlineInput(a))return this.constants_.LARGE_PADDING;if(G.isStatementInput(a))return this.constants_.NO_PADDING}if(!G.isInput(a)&&b&&G.isInput(b)){if(G.isField(a)&&a.isEditable){if(G.isInlineInput(b)||G.isExternalInput(b))return this.constants_.SMALL_PADDING}else{if(G.isInlineInput(b)||G.isExternalInput(b))return this.constants_.MEDIUM_LARGE_PADDING;if(G.isStatementInput(b))return this.constants_.LARGE_PADDING}return this.constants_.LARGE_PADDING-
1}if(G.isIcon(a)&&b&&!G.isInput(b))return this.constants_.LARGE_PADDING;if(G.isInlineInput(a)&&b&&G.isField(b))return b.isEditable?this.constants_.MEDIUM_PADDING:this.constants_.LARGE_PADDING;if(G.isLeftSquareCorner(a)&&b){if(G.isHat(b))return this.constants_.NO_PADDING;if(G.isPreviousConnection(b))return b.notchOffset;if(G.isNextConnection(b))return b.notchOffset+(this.RTL?1:-1)*this.constants_.DARK_PATH_OFFSET/2}if(G.isLeftRoundedCorner(a)&&b){if(G.isPreviousConnection(b))return b.notchOffset-this.constants_.CORNER_RADIUS;
if(G.isNextConnection(b))return b.notchOffset-this.constants_.CORNER_RADIUS+(this.RTL?1:-1)*this.constants_.DARK_PATH_OFFSET/2}return G.isField(a)&&b&&G.isField(b)&&a.isEditable===b.isEditable||b&&G.isJaggedEdge(b)?this.constants_.LARGE_PADDING:this.constants_.MEDIUM_PADDING}getSpacerRowHeight_(a,b){return G.isTopRow(a)&&G.isBottomRow(b)?this.constants_.EMPTY_BLOCK_SPACER_HEIGHT:G.isTopRow(a)||G.isBottomRow(b)?this.constants_.NO_PADDING:a.hasExternalInput&&b.hasExternalInput?this.constants_.LARGE_PADDING:
!a.hasStatement&&b.hasStatement?this.constants_.BETWEEN_STATEMENT_PADDING_Y:a.hasStatement&&b.hasStatement||!a.hasStatement&&b.hasDummyInput||a.hasDummyInput?this.constants_.LARGE_PADDING:this.constants_.MEDIUM_PADDING}getElemCenterline_(a,b){if(G.isSpacer(b))return a.yPos+b.height/2;if(G.isBottomRow(a))return a=a.yPos+a.height-a.descenderHeight,G.isNextConnection(b)?a+b.height/2:a-b.height/2;if(G.isTopRow(a))return G.isHat(b)?a.capline-b.height/2:a.capline+b.height/2;let f=a.yPos;G.isField(b)||G.isIcon(b)?
(f+=b.height/2,(a.hasInlineInput||a.hasStatement)&&b.height+this.constants_.TALL_INPUT_FIELD_OFFSET_Y<=a.height&&(f+=this.constants_.TALL_INPUT_FIELD_OFFSET_Y)):f=G.isInlineInput(b)?f+b.height/2:f+a.height/2;return f}alignRowElements_(){if(this.isInline){var a=0,b=new WeakMap,f=null;for(let g=this.rows.length-1,l;l=this.rows[g];g--)b.set(l,a),G.isInputRow(l)&&(l.hasStatement&&this.alignStatementRow_(l),f&&f.hasStatement&&l.width<f.width?b.set(l,f.width):a=l.hasStatement?l.width:Math.max(a,l.width),
f=l);a=0;for(let g=0,l;l=this.rows[g];g++)l.hasStatement?a=this.getDesiredRowWidth_(l):G.isSpacer(l)?l.width=Math.max(a,b.get(l)):(f=l.width,a=Math.max(a,b.get(l))-f,0<a&&this.addAlignmentPadding_(l,a),a=l.width)}else super.alignRowElements_()}getDesiredRowWidth_(a){return this.isInline&&a.hasStatement?this.statementEdge+this.constants_.MAX_BOTTOM_WIDTH+this.startX:super.getDesiredRowWidth_(a)}finalize_(){let a=0,b=0;for(let g=0,l;l=this.rows[g];g++){l.yPos=b;l.xPos=this.startX;b+=l.height;a=Math.max(a,
l.widthWithConnectedBlocks);var f=b-this.topRow.ascenderHeight;l===this.bottomRow&&f<this.constants_.MIN_BLOCK_HEIGHT&&(f=this.constants_.MIN_BLOCK_HEIGHT-f,this.bottomRow.height+=f,b+=f);this.recordElemPositions_(l)}this.outputConnection&&this.block_.nextConnection&&this.block_.nextConnection.isConnected()&&(f=this.block_.nextConnection.targetBlock())&&(a=Math.max(a,f.getHeightWidth().width-this.constants_.DARK_PATH_OFFSET));this.bottomRow.baseline=b-this.bottomRow.descenderHeight;this.widthWithChildren=
a+this.startX+this.constants_.DARK_PATH_OFFSET;this.width+=this.constants_.DARK_PATH_OFFSET;this.height=b+this.constants_.DARK_PATH_OFFSET;this.startY=this.topRow.capline}},tm=class extends Gf{constructor(a,b,f){super(a,b,f);this.constants=f;this.colourDark="#000000";this.svgPathDark=T(J.PATH,{"class":"blocklyPathDark",transform:"translate(1,1)"});this.svgRoot.insertBefore(this.svgPathDark,this.svgPath);this.svgPathLight=T(J.PATH,{"class":"blocklyPathLight"},this.svgRoot)}setPath(a){this.svgPath.setAttribute("d",
a);this.svgPathDark.setAttribute("d",a)}setHighlightPath(a){this.svgPathLight.setAttribute("d",a)}flipRTL(){this.svgPath.setAttribute("transform","scale(-1 1)");this.svgPathLight.setAttribute("transform","scale(-1 1)");this.svgPathDark.setAttribute("transform","translate(1,1) scale(-1 1)")}applyColour(a){this.svgPathLight.style.display="";this.svgPathDark.style.display="";if(!this.style.colourTertiary)throw Error("The renderer did not properly initialize the tertiary colour of the block style");this.svgPathLight.setAttribute("stroke",
this.style.colourTertiary);this.svgPathDark.setAttribute("fill",this.colourDark);super.applyColour(a);this.svgPath.setAttribute("stroke","none")}setStyle(a){this.style=a;this.colourDark=kd("#000",this.style.colourPrimary,.2)||this.colourDark}updateHighlighted(a){a?(this.svgPath.setAttribute("filter","url(#"+this.constants.embossFilterId+")"),this.svgPathLight.style.display="none"):(this.svgPath.setAttribute("filter","none"),this.svgPathLight.style.display="inline")}updateShadow_(a){if(a){this.svgPathLight.style.display=
"none";if(!this.style.colourSecondary)throw Error("The renderer did not properly initialize the secondary colour of the block style block style");this.svgPathDark.setAttribute("fill",this.style.colourSecondary);this.svgPath.setAttribute("stroke","none");this.svgPath.setAttribute("fill",this.style.colourSecondary)}}updateDisabled_(a){super.updateDisabled_(a);a&&this.svgPath.setAttribute("stroke","none")}},um=class extends Hf{constructor(a){super(a);this.highlightConstants=null}init(a,b){super.init(a,
b);this.highlightConstants=this.makeHighlightConstants_();this.highlightConstants.init()}refreshDom(a,b){super.refreshDom(a,b);this.getHighlightConstants().init()}makeConstants_(){return new mm}makeRenderInfo_(a){return new sm(this,a)}makeDrawer_(a,b){return new om(a,b)}makePathObject(a,b){return new tm(a,b,this.getConstants())}makeHighlightConstants_(){return new pm(this.getConstants())}getHighlightConstants(){if(!this.highlightConstants)throw Error("Cannot access the highlight constants because init has not been called");
return this.highlightConstants}};of("geras",um);var Tb={};Tb.ConstantProvider=mm;Tb.Drawer=om;Tb.HighlightConstantProvider=pm;Tb.Highlighter=nm;Tb.InlineInput=qm;Tb.PathObject=tm;Tb.RenderInfo=sm;Tb.Renderer=um;Tb.StatementInput=rm;var vm=class extends ue{constructor(a,b){super(a,b)}getRenderer(){return this.renderer_}addElemSpacing_(){let a=!1;for(var b=0;b<this.rows.length;b++)if(this.rows[b].hasExternalInput){a=!0;break}for(b=0;b<this.rows.length;b++){const g=this.rows[b];var f=g.elements;g.elements=
[];g.startsWithElemSpacer()&&g.elements.push(new rb(this.constants_,this.getInRowSpacing_(null,f[0])));if(f.length){for(let l=0;l<f.length-1;l++){g.elements.push(f[l]);const n=this.getInRowSpacing_(f[l],f[l+1]);g.elements.push(new rb(this.constants_,n))}g.elements.push(f[f.length-1]);g.endsWithElemSpacer()&&(f=this.getInRowSpacing_(f[f.length-1],null),a&&g.hasDummyInput&&(f+=this.constants_.TAB_WIDTH),g.elements.push(new rb(this.constants_,f)))}}}getInRowSpacing_(a,b){if(!a)return b&&G.isField(b)&&
b.isEditable?this.constants_.MEDIUM_PADDING:b&&G.isInlineInput(b)?this.constants_.MEDIUM_LARGE_PADDING:b&&G.isStatementInput(b)?this.constants_.STATEMENT_INPUT_PADDING_LEFT:this.constants_.LARGE_PADDING;if(!G.isInput(a)&&!b)return G.isField(a)&&a.isEditable?this.constants_.MEDIUM_PADDING:G.isIcon(a)?2*this.constants_.LARGE_PADDING+1:G.isHat(a)?this.constants_.NO_PADDING:G.isPreviousOrNextConnection(a)?this.constants_.LARGE_PADDING:G.isLeftRoundedCorner(a)?this.constants_.MIN_BLOCK_WIDTH:G.isJaggedEdge(a)?
this.constants_.NO_PADDING:this.constants_.LARGE_PADDING;if(G.isInput(a)&&!b){if(G.isExternalInput(a))return this.constants_.NO_PADDING;if(G.isInlineInput(a))return this.constants_.LARGE_PADDING;if(G.isStatementInput(a))return this.constants_.NO_PADDING}if(!G.isInput(a)&&b&&G.isInput(b)){if(G.isField(a)&&a.isEditable){if(G.isInlineInput(b)||G.isExternalInput(b))return this.constants_.SMALL_PADDING}else{if(G.isInlineInput(b)||G.isExternalInput(b))return this.constants_.MEDIUM_LARGE_PADDING;if(G.isStatementInput(b))return this.constants_.LARGE_PADDING}return this.constants_.LARGE_PADDING-
1}if(G.isIcon(a)&&b&&!G.isInput(b))return this.constants_.LARGE_PADDING;if(G.isInlineInput(a)&&b&&G.isField(b))return b.isEditable?this.constants_.MEDIUM_PADDING:this.constants_.LARGE_PADDING;if(G.isLeftSquareCorner(a)&&b){if(G.isHat(b))return this.constants_.NO_PADDING;if(G.isPreviousConnection(b)||G.isNextConnection(b))return b.notchOffset}return G.isLeftRoundedCorner(a)&&b?b.notchOffset-this.constants_.CORNER_RADIUS:G.isField(a)&&b&&G.isField(b)&&a.isEditable===b.isEditable||b&&G.isJaggedEdge(b)?
this.constants_.LARGE_PADDING:this.constants_.MEDIUM_PADDING}getSpacerRowHeight_(a,b){return G.isTopRow(a)&&G.isBottomRow(b)?this.constants_.EMPTY_BLOCK_SPACER_HEIGHT:G.isTopRow(a)||G.isBottomRow(b)?this.constants_.NO_PADDING:a.hasExternalInput&&b.hasExternalInput?this.constants_.LARGE_PADDING:!a.hasStatement&&b.hasStatement?this.constants_.BETWEEN_STATEMENT_PADDING_Y:a.hasStatement&&b.hasStatement||a.hasDummyInput||b.hasDummyInput?this.constants_.LARGE_PADDING:this.constants_.MEDIUM_PADDING}getElemCenterline_(a,
b){if(G.isSpacer(b))return a.yPos+b.height/2;if(G.isBottomRow(a))return a=a.yPos+a.height-a.descenderHeight,G.isNextConnection(b)?a+b.height/2:a-b.height/2;if(G.isTopRow(a))return G.isHat(b)?a.capline-b.height/2:a.capline+b.height/2;let f=a.yPos;return G.isField(b)&&a.hasStatement?f+(this.constants_.TALL_INPUT_FIELD_OFFSET_Y+b.height/2):f+a.height/2}finalize_(){let a=0,b=0;for(var f=0;f<this.rows.length;f++){const l=this.rows[f];l.yPos=b;l.xPos=this.startX;b+=l.height;a=Math.max(a,l.widthWithConnectedBlocks);
var g=b-this.topRow.ascenderHeight;l===this.bottomRow&&g<this.constants_.MIN_BLOCK_HEIGHT&&(g=this.constants_.MIN_BLOCK_HEIGHT-g,this.bottomRow.height+=g,b+=g);this.recordElemPositions_(l)}this.outputConnection&&this.block_.nextConnection&&this.block_.nextConnection.isConnected()&&(f=this.block_.nextConnection.targetBlock())&&(a=Math.max(a,f.getHeightWidth().width));this.bottomRow.baseline=b-this.bottomRow.descenderHeight;this.widthWithChildren=a+this.startX;this.height=b;this.startY=this.topRow.capline}},
wm=class extends Hf{constructor(a){super(a)}makeRenderInfo_(a){return new vm(this,a)}};of("thrasos",wm);var gi={};gi.RenderInfo=vm;gi.Renderer=wm;var Vo=new Vc("zelos",{colour_blocks:{colourPrimary:"#CF63CF",colourSecondary:"#C94FC9",colourTertiary:"#BD42BD"},list_blocks:{colourPrimary:"#9966FF",colourSecondary:"#855CD6",colourTertiary:"#774DCB"},logic_blocks:{colourPrimary:"#4C97FF",colourSecondary:"#4280D7",colourTertiary:"#3373CC"},loop_blocks:{colourPrimary:"#0fBD8C",colourSecondary:"#0DA57A",
colourTertiary:"#0B8E69"},math_blocks:{colourPrimary:"#59C059",colourSecondary:"#46B946",colourTertiary:"#389438"},procedure_blocks:{colourPrimary:"#FF6680",colourSecondary:"#FF4D6A",colourTertiary:"#FF3355"},text_blocks:{colourPrimary:"#FFBF00",colourSecondary:"#E6AC00",colourTertiary:"#CC9900"},variable_blocks:{colourPrimary:"#FF8C1A",colourSecondary:"#FF8000",colourTertiary:"#DB6E00"},variable_dynamic_blocks:{colourPrimary:"#FF8C1A",colourSecondary:"#FF8000",colourTertiary:"#DB6E00"},hat_blocks:{colourPrimary:"#4C97FF",
colourSecondary:"#4280D7",colourTertiary:"#3373CC",hat:"cap"}},{colour_category:{colour:"#CF63CF"},list_category:{colour:"#9966FF"},logic_category:{colour:"#4C97FF"},loop_category:{colour:"#0fBD8C"},math_category:{colour:"#59C059"},procedure_category:{colour:"#FF6680"},text_category:{colour:"#FFBF00"},variable_category:{colour:"#FF8C1A"},variable_dynamic_category:{colour:"#FF8C1A"}}),Wo={Classic:Af,Zelos:Vo},hi=class{constructor(a,b,f){this.id_=a.toolboxitemid||Q();this.level_=(this.parent_=f||null)?
this.parent_.getLevel()+1:0;this.toolboxItemDef_=a;this.parentToolbox_=b;this.workspace_=this.parentToolbox_.getWorkspace()}init(){}getDiv(){return null}getClickTarget(){return null}getId(){return this.id_}getParent(){return null}getLevel(){return this.level_}isSelectable(){return!1}isCollapsible(){return!1}dispose(){}setVisible_(a){}},Ib=class extends hi{constructor(a,b,f){super(a,b,f);this.colour_=this.name_="";this.labelDom_=this.iconDom_=this.rowContents_=this.rowDiv_=this.htmlDiv_=null;this.isDisabled_=
this.isHidden_=!1;this.flyoutItems_=[];this.cssConfig_=this.makeDefaultCssConfig_()}init(){this.parseCategoryDef_(this.toolboxItemDef_);this.parseContents_(this.toolboxItemDef_);this.createDom_();"true"===this.toolboxItemDef_.hidden&&this.hide()}makeDefaultCssConfig_(){return{container:"blocklyToolboxCategory",row:"blocklyTreeRow",rowcontentcontainer:"blocklyTreeRowContentContainer",icon:"blocklyTreeIcon",label:"blocklyTreeLabel",contents:"blocklyToolboxContents",selected:"blocklyTreeSelected",openicon:"blocklyTreeIconOpen",
closedicon:"blocklyTreeIconClosed"}}parseContents_(a){if("custom"in a)this.flyoutItems_=a.custom;else if(a=a.contents)for(let b=0;b<a.length;b++){const f=a[b];Array.isArray(this.flyoutItems_)&&this.flyoutItems_.push(f)}}parseCategoryDef_(a){this.name_="name"in a?Ua(a.name):"";this.colour_=this.getColour_(a);Object.assign(this.cssConfig_,a.cssconfig||a.cssConfig)}createDom_(){this.htmlDiv_=this.createContainer_();Gc(this.htmlDiv_,Mb.TREEITEM);bb(this.htmlDiv_,ab.SELECTED,!1);bb(this.htmlDiv_,ab.LEVEL,
this.level_+1);this.rowDiv_=this.createRowContainer_();this.rowDiv_.style.pointerEvents="auto";this.htmlDiv_.appendChild(this.rowDiv_);this.rowContents_=this.createRowContentsContainer_();this.rowContents_.style.pointerEvents="none";this.rowDiv_.appendChild(this.rowContents_);this.iconDom_=this.createIconDom_();Gc(this.iconDom_,Mb.PRESENTATION);this.rowContents_.appendChild(this.iconDom_);this.labelDom_=this.createLabelDom_(this.name_);this.rowContents_.appendChild(this.labelDom_);const a=this.labelDom_.getAttribute("id");
a&&bb(this.htmlDiv_,ab.LABELLEDBY,a);this.addColourBorder_(this.colour_);return this.htmlDiv_}createContainer_(){const a=document.createElement("div"),b=this.cssConfig_.container;b&&sa(a,b);return a}createRowContainer_(){const a=document.createElement("div");var b=this.cssConfig_.row;b&&sa(a,b);b=`${Ib.nestedPadding*this.getLevel()}px`;this.workspace_.RTL?a.style.paddingRight=b:a.style.paddingLeft=b;return a}createRowContentsContainer_(){const a=document.createElement("div"),b=this.cssConfig_.rowcontentcontainer;
b&&sa(a,b);return a}createIconDom_(){const a=document.createElement("span");if(!this.parentToolbox_.isHorizontal()){const b=this.cssConfig_.icon;b&&sa(a,b)}a.style.display="inline-block";return a}createLabelDom_(a){const b=document.createElement("span");b.setAttribute("id",this.getId()+".label");b.textContent=a;(a=this.cssConfig_.label)&&sa(b,a);return b}refreshTheme(){this.colour_=this.getColour_(this.toolboxItemDef_);this.addColourBorder_(this.colour_)}addColourBorder_(a){a&&(a=Ib.borderWidth+"px solid "+
(a||"#ddd"),this.workspace_.RTL?this.rowDiv_.style.borderRight=a:this.rowDiv_.style.borderLeft=a)}getColour_(a){const b=a.categorystyle||a.categoryStyle;if((a=a.colour)&&b)console.warn('Toolbox category "'+this.name_+'" must not have both a style and a colour');else{if(b)return this.getColourfromStyle(b);if(a)return this.parseColour(a)}return""}getColourfromStyle(a){var b=this.workspace_.getTheme();if(a&&b){if((b=b.categoryStyles[a])&&b.colour)return this.parseColour(b.colour);console.warn('Style "'+
a+'" must exist and contain a colour value')}return""}getClickTarget(){return this.rowDiv_}parseColour(a){a=Ua(a);if(null==a||""===a)return"";var b=Number(a);if(isNaN(b)){if(b=jd(a))return b;console.warn('Toolbox category "'+this.name_+'" has unrecognized colour attribute: '+a);return""}return Jj(b)}openIcon_(a){if(a){var b=this.cssConfig_.closedicon;b&&Uf(a,b);(b=this.cssConfig_.openicon)&&sa(a,b)}}closeIcon_(a){if(a){var b=this.cssConfig_.openicon;b&&Uf(a,b);(b=this.cssConfig_.closedicon)&&sa(a,
b)}}setVisible_(a){this.htmlDiv_.style.display=a?"block":"none";this.isHidden_=!a;this.parentToolbox_.getSelectedItem()===this&&this.parentToolbox_.clearSelection()}hide(){this.setVisible_(!1)}show(){this.setVisible_(!0)}isVisible(){return!this.isHidden_&&this.allAncestorsExpanded_()}allAncestorsExpanded_(){let a=this;for(;a.getParent();)if(a=a.getParent(),!a.isExpanded())return!1;return!0}isSelectable(){return this.isVisible()&&!this.isDisabled_}onClick(a){}setSelected(a){if(this.rowDiv_){var b=
this.cssConfig_.selected;if(a){const f=this.parseColour(Ib.defaultBackgroundColour);this.rowDiv_.style.backgroundColor=this.colour_||f;b&&sa(this.rowDiv_,b)}else this.rowDiv_.style.backgroundColor="",b&&Ma(this.rowDiv_,b);bb(this.htmlDiv_,ab.SELECTED,a)}}setDisabled(a){this.isDisabled_=a;this.getDiv().setAttribute("disabled",`${a}`);a?this.getDiv().setAttribute("disabled","true"):this.getDiv().removeAttribute("disabled")}getName(){return this.name_}getParent(){return this.parent_}getDiv(){return this.htmlDiv_}getContents(){return this.flyoutItems_}updateFlyoutContents(a){this.flyoutItems_=
[];this.toolboxItemDef_="string"===typeof a?{kind:this.toolboxItemDef_.kind,custom:a,id:this.toolboxItemDef_.id,categorystyle:this.toolboxItemDef_.categorystyle,colour:this.toolboxItemDef_.colour,cssconfig:this.toolboxItemDef_.cssconfig,hidden:this.toolboxItemDef_.hidden}:{kind:this.toolboxItemDef_.kind,name:"name"in this.toolboxItemDef_?this.toolboxItemDef_.name:"",contents:Ne(a),id:this.toolboxItemDef_.id,categorystyle:this.toolboxItemDef_.categorystyle,colour:this.toolboxItemDef_.colour,cssconfig:this.toolboxItemDef_.cssconfig,
hidden:this.toolboxItemDef_.hidden};this.parseContents_(this.toolboxItemDef_)}dispose(){Ia(this.htmlDiv_)}};Ib.registrationName="category";Ib.nestedPadding=19;Ib.borderWidth=8;Ib.defaultBackgroundColour="#57e";mc('\n.blocklyTreeRow:not(.blocklyTreeSelected):hover {\n  background-color: rgba(255, 255, 255, .2);\n}\n\n.blocklyToolboxDiv[layout="h"] .blocklyToolboxCategory {\n  margin: 1px 5px 1px 0;\n}\n\n.blocklyToolboxDiv[dir="RTL"][layout="h"] .blocklyToolboxCategory {\n  margin: 1px 0 1px 5px;\n}\n\n.blocklyTreeRow {\n  height: 22px;\n  line-height: 22px;\n  margin-bottom: 3px;\n  padding-right: 8px;\n  white-space: nowrap;\n}\n\n.blocklyToolboxDiv[dir="RTL"] .blocklyTreeRow {\n  margin-left: 8px;\n  padding-right: 0;\n}\n\n.blocklyTreeIcon {\n  background-image: url(<<<PATH>>>/sprites.png);\n  height: 16px;\n  vertical-align: middle;\n  visibility: hidden;\n  width: 16px;\n}\n\n.blocklyTreeIconClosed {\n  background-position: -32px -1px;\n}\n\n.blocklyToolboxDiv[dir="RTL"] .blocklyTreeIconClosed {\n  background-position: 0 -1px;\n}\n\n.blocklyTreeSelected>.blocklyTreeIconClosed {\n  background-position: -32px -17px;\n}\n\n.blocklyToolboxDiv[dir="RTL"] .blocklyTreeSelected>.blocklyTreeIconClosed {\n  background-position: 0 -17px;\n}\n\n.blocklyTreeIconOpen {\n  background-position: -16px -1px;\n}\n\n.blocklyTreeSelected>.blocklyTreeIconOpen {\n  background-position: -16px -17px;\n}\n\n.blocklyTreeLabel {\n  cursor: default;\n  font: 16px sans-serif;\n  padding: 0 3px;\n  vertical-align: middle;\n}\n\n.blocklyToolboxDelete .blocklyTreeLabel {\n  cursor: url("<<<PATH>>>/handdelete.cur"), auto;\n}\n\n.blocklyTreeSelected .blocklyTreeLabel {\n  color: #fff;\n}\n');
e(ba.TOOLBOX_ITEM,Ib.registrationName,Ib);var Ce=class extends hi{constructor(a,b){super(a,b);this.cssConfig_={container:"blocklyTreeSeparator"};this.htmlDiv=null;Object.assign(this.cssConfig_,a.cssconfig||a.cssConfig)}init(){this.createDom_()}createDom_(){const a=document.createElement("div"),b=this.cssConfig_.container;b&&sa(a,b);return this.htmlDiv=a}getDiv(){return this.htmlDiv}dispose(){Ia(this.htmlDiv)}};Ce.registrationName="sep";mc('\n.blocklyTreeSeparator {\n  border-bottom: solid #e5e5e5 1px;\n  height: 0;\n  margin: 5px 0;\n}\n\n.blocklyToolboxDiv[layout="h"] .blocklyTreeSeparator {\n  border-right: solid #e5e5e5 1px;\n  border-bottom: none;\n  height: auto;\n  margin: 0 5px 0 5px;\n  padding: 5px 0;\n  width: 0;\n}\n');
e(ba.TOOLBOX_ITEM,Ce.registrationName,Ce);var Fd=class extends Ib{constructor(a,b,f){super(a,b,f);this.subcategoriesDiv_=null;this.expanded_=!1;this.toolboxItems_=[]}makeDefaultCssConfig_(){const a=super.makeDefaultCssConfig_();a.contents="blocklyToolboxContents";return a}parseContents_(a){if("custom"in a)this.flyoutItems_=a.custom;else{const b=a.contents;if(b){this.flyoutItems_=[];a=!0;for(let f=0;f<b.length;f++){const g=b[f];!p(ba.TOOLBOX_ITEM,g.kind)||g.kind.toLowerCase()===Ce.registrationName&&
a?(this.flyoutItems_.push(g),a=!0):(this.createToolboxItem(g),a=!1)}}}}createToolboxItem(a){let b=a.kind;"CATEGORY"===b.toUpperCase()&&fg(a)&&(b=Fd.registrationName);a=new (t(ba.TOOLBOX_ITEM,b))(a,this.parentToolbox_,this);this.toolboxItems_.push(a)}init(){super.init();this.setExpanded("true"===this.toolboxItemDef_.expanded||!0===this.toolboxItemDef_.expanded)}createDom_(){super.createDom_();const a=this.getChildToolboxItems();this.subcategoriesDiv_=this.createSubCategoriesDom_(a);Gc(this.subcategoriesDiv_,
Mb.GROUP);this.htmlDiv_.appendChild(this.subcategoriesDiv_);this.closeIcon_(this.iconDom_);bb(this.htmlDiv_,ab.EXPANDED,!1);return this.htmlDiv_}createIconDom_(){const a=document.createElement("span");if(!this.parentToolbox_.isHorizontal()){const b=this.cssConfig_.icon;b&&sa(a,b);a.style.visibility="visible"}a.style.display="inline-block";return a}createSubCategoriesDom_(a){const b=document.createElement("div");b.style.display="none";var f=this.cssConfig_.contents;f&&sa(b,f);for(f=0;f<a.length;f++){const g=
a[f];g.init();const l=g.getDiv();b.appendChild(l);if(g.getClickTarget){let n;null==(n=g.getClickTarget())||n.setAttribute("id",g.getId())}}return b}setExpanded(a){if(this.expanded_!==a){if(this.expanded_=a)this.subcategoriesDiv_.style.display="block",this.openIcon_(this.iconDom_);else{let b;null==(b=this.parentToolbox_.getFlyout())||b.setVisible(!1);this.subcategoriesDiv_.style.display="none";this.closeIcon_(this.iconDom_)}bb(this.htmlDiv_,ab.EXPANDED,a);this.parentToolbox_.handleToolboxItemResize()}}setVisible_(a){this.htmlDiv_.style.display=
a?"block":"none";const b=this.getChildToolboxItems();for(let f=0;f<b.length;f++)b[f].setVisible_(a);this.isHidden_=!a;this.parentToolbox_.getSelectedItem()===this&&this.parentToolbox_.clearSelection()}isExpanded(){return this.expanded_}isCollapsible(){return!0}onClick(a){this.toggleExpanded()}toggleExpanded(){this.setExpanded(!this.expanded_)}getDiv(){return this.htmlDiv_}getChildToolboxItems(){return this.toolboxItems_}};Fd.registrationName="collapsibleCategory";e(ba.TOOLBOX_ITEM,Fd.registrationName,
Fd);var xm=class extends Jf{constructor(a){super();this.id="toolbox";this.contentsDiv_=this.HtmlDiv=null;this.isVisible_=!1;this.contents_=[];this.height_=this.width_=0;this.previouslySelectedItem_=this.selectedItem_=this.flyout=null;this.boundEvents_=[];this.workspace_=a;this.toolboxDef_=a.options.languageTree||{contents:[]};this.horizontalLayout=a.options.horizontalLayout;this.RTL=a.options.RTL;this.contentMap_=Object.create(null);this.toolboxPosition=a.options.toolboxPosition}onShortcut(a){return!1}init(){var a=
this.workspace_;const b=a.getParentSvg();this.flyout=this.createFlyout_();this.HtmlDiv=this.createDom_(this.workspace_);ad(this.flyout.createDom("svg"),b);this.setVisible(!0);this.flyout.init(a);this.render(this.toolboxDef_);a=a.getThemeManager();a.subscribe(this.HtmlDiv,"toolboxBackgroundColour","background-color");a.subscribe(this.HtmlDiv,"toolboxForegroundColour","color");this.workspace_.getComponentManager().addComponent({component:this,weight:Qa.ComponentWeight.TOOLBOX_WEIGHT,capabilities:[Qa.Capability.AUTOHIDEABLE,
Qa.Capability.DELETE_AREA,Qa.Capability.DRAG_TARGET]})}createDom_(a){a=a.getParentSvg();const b=this.createContainer_();this.contentsDiv_=this.createContentsContainer_();this.contentsDiv_.tabIndex=0;Gc(this.contentsDiv_,Mb.TREE);b.appendChild(this.contentsDiv_);a.parentNode.insertBefore(b,a);this.attachEvents_(b,this.contentsDiv_);return b}createContainer_(){const a=document.createElement("div");a.setAttribute("layout",this.isHorizontal()?"h":"v");sa(a,"blocklyToolboxDiv");a.setAttribute("dir",this.RTL?
"RTL":"LTR");return a}createContentsContainer_(){const a=document.createElement("div");sa(a,"blocklyToolboxContents");this.isHorizontal()&&(a.style.flexDirection="row");return a}attachEvents_(a,b){a=ta(a,"pointerdown",this,this.onClick_,!1);this.boundEvents_.push(a);b=ta(b,"keydown",this,this.onKeyDown_,!1);this.boundEvents_.push(b)}onClick_(a){if(Vb(a)||a.target===this.HtmlDiv)z().hideChaff(!1);else{var b=a.target.getAttribute("id");b&&(b=this.getToolboxItemById(b),b.isSelectable()&&(this.setSelectedItem(b),
b.onClick(a)));z().hideChaff(!0)}Ea()}onKeyDown_(a){let b=!1;switch(a.key){case "ArrowDown":b=this.selectNext();break;case "ArrowUp":b=this.selectPrevious();break;case "ArrowLeft":b=this.selectParent();break;case "ArrowRight":b=this.selectChild();break;case "Enter":case " ":this.selectedItem_&&this.selectedItem_.isCollapsible()&&(this.selectedItem_.toggleExpanded(),b=!0);break;default:b=!1}!b&&this.selectedItem_&&this.selectedItem_.onKeyDown&&(b=this.selectedItem_.onKeyDown(a));b&&a.preventDefault()}createFlyout_(){const a=
this.workspace_,b=new zb({parentWorkspace:a,rtl:a.RTL,oneBasedIndex:a.options.oneBasedIndex,horizontalLayout:a.horizontalLayout,renderer:a.options.renderer,rendererOverrides:a.options.rendererOverrides,move:{scrollbars:!0}});b.toolboxPosition=a.options.toolboxPosition;return new (a.horizontalLayout?I(ba.FLYOUTS_HORIZONTAL_TOOLBOX,a.options,!0):I(ba.FLYOUTS_VERTICAL_TOOLBOX,a.options,!0))(b)}render(a){this.toolboxDef_=a;for(let b=0;b<this.contents_.length;b++){const f=this.contents_[b];f&&f.dispose()}this.contents_=
[];this.contentMap_=Object.create(null);this.renderContents_(a.contents);this.position();this.handleToolboxItemResize()}renderContents_(a){const b=document.createDocumentFragment();for(let f=0;f<a.length;f++)this.createToolboxItem(a[f],b);this.contentsDiv_.appendChild(b)}createToolboxItem(a,b){var f=a.kind;"CATEGORY"===f.toUpperCase()&&fg(a)&&(f=Fd.registrationName);if(f=t(ba.TOOLBOX_ITEM,f.toLowerCase()))a=new f(a,this),a.init(),this.addToolboxItem_(a),(f=a.getDiv())&&b.appendChild(f),a.getClickTarget()&&
a.getClickTarget().setAttribute("id",a.getId())}addToolboxItem_(a){this.contents_.push(a);this.contentMap_[a.getId()]=a;if(a.isCollapsible()){a=a.getChildToolboxItems();for(let b=0;b<a.length;b++)this.addToolboxItem_(a[b])}}getToolboxItems(){return this.contents_}addStyle(a){a&&this.HtmlDiv&&sa(this.HtmlDiv,a)}removeStyle(a){a&&this.HtmlDiv&&Ma(this.HtmlDiv,a)}getClientRect(){if(!this.HtmlDiv||!this.isVisible_)return null;var a=this.HtmlDiv.getBoundingClientRect();const b=a.top,f=b+a.height,g=a.left;
a=g+a.width;return this.toolboxPosition===xa.TOP?new Ja(-1E7,f,-1E7,1E7):this.toolboxPosition===xa.BOTTOM?new Ja(b,1E7,-1E7,1E7):this.toolboxPosition===xa.LEFT?new Ja(-1E7,1E7,-1E7,a):new Ja(-1E7,1E7,g,1E7)}wouldDelete(a){a instanceof xb?this.updateWouldDelete_(!a.getParent()&&a.isDeletable()):this.updateWouldDelete_(Db(a)&&a.isDeletable());return this.wouldDelete_}onDragEnter(a){this.updateCursorDeleteStyle_(!0)}onDragExit(a){this.updateCursorDeleteStyle_(!1)}onDrop(a){this.updateCursorDeleteStyle_(!1)}updateWouldDelete_(a){a!==
this.wouldDelete_&&(this.updateCursorDeleteStyle_(!1),this.wouldDelete_=a,this.updateCursorDeleteStyle_(!0))}updateCursorDeleteStyle_(a){const b=this.wouldDelete_?"blocklyToolboxDelete":"blocklyToolboxGrab";a?this.addStyle(b):this.removeStyle(b)}getToolboxItemById(a){return this.contentMap_[a]||null}getWidth(){return this.width_}getHeight(){return this.height_}getFlyout(){return this.flyout}getWorkspace(){return this.workspace_}getSelectedItem(){return this.selectedItem_}getPreviouslySelectedItem(){return this.previouslySelectedItem_}isHorizontal(){return this.horizontalLayout}position(){const a=
this.workspace_.getMetrics(),b=this.HtmlDiv;b&&(this.horizontalLayout?(b.style.left="0",b.style.height="auto",b.style.width="100%",this.height_=b.offsetHeight,this.width_=a.viewWidth,this.toolboxPosition===xa.TOP?b.style.top="0":b.style.bottom="0"):(this.toolboxPosition===xa.RIGHT?b.style.right="0":b.style.left="0",b.style.height="100%",this.width_=b.offsetWidth,this.height_=a.viewHeight),this.flyout.position())}handleToolboxItemResize(){const a=this.workspace_,b=this.HtmlDiv.getBoundingClientRect();
a.translate(this.toolboxPosition===xa.LEFT?a.scrollX+b.width:a.scrollX,this.toolboxPosition===xa.TOP?a.scrollY+b.height:a.scrollY);A(a)}clearSelection(){this.setSelectedItem(null)}refreshTheme(){for(let a=0;a<this.contents_.length;a++){const b=this.contents_[a];b.refreshTheme&&b.refreshTheme()}}refreshSelection(){this.selectedItem_&&this.selectedItem_.isSelectable()&&this.selectedItem_.getContents().length&&this.flyout.show(this.selectedItem_.getContents())}setVisible(a){this.isVisible_!==a&&(this.HtmlDiv.style.display=
a?"block":"none",this.isVisible_=a,this.workspace_.recordDragTargets())}autoHide(a){!a&&this.flyout&&this.flyout.autoClose&&this.clearSelection()}setSelectedItem(a){const b=this.selectedItem_;!a&&!b||a&&!go(a)||(this.shouldDeselectItem_(b,a)&&null!==b&&this.deselectItem_(b),this.shouldSelectItem_(b,a)&&null!==a&&this.selectItem_(b,a),this.updateFlyout_(b,a),this.fireSelectEvent(b,a))}shouldDeselectItem_(a,b){return null!==a&&(!a.isCollapsible()||a!==b)}shouldSelectItem_(a,b){return null!==b&&b!==
a}deselectItem_(a){this.selectedItem_=null;this.previouslySelectedItem_=a;a.setSelected(!1);bb(this.contentsDiv_,ab.ACTIVEDESCENDANT,"")}selectItem_(a,b){this.selectedItem_=b;this.previouslySelectedItem_=a;b.setSelected(!0);bb(this.contentsDiv_,ab.ACTIVEDESCENDANT,b.getId())}selectItemByPosition(a){-1<a&&a<this.contents_.length&&(a=this.contents_[a],a.isSelectable()&&this.setSelectedItem(a))}updateFlyout_(a,b){b&&(a!==b||b.isCollapsible())&&b.getContents().length?(this.flyout.show(b.getContents()),
this.flyout.scrollToStart()):this.flyout.hide()}fireSelectEvent(a,b){const f=a&&a.getName();let g=b&&b.getName();a===b&&(g=null);a=new (la(O.TOOLBOX_ITEM_SELECT))(f,g,this.workspace_.id);aa(a)}selectParent(){return this.selectedItem_?this.selectedItem_.isCollapsible()&&this.selectedItem_.isExpanded()?(this.selectedItem_.toggleExpanded(),!0):this.selectedItem_.getParent()&&this.selectedItem_.getParent().isSelectable()?(this.setSelectedItem(this.selectedItem_.getParent()),!0):!1:!1}selectChild(){if(!this.selectedItem_||
!this.selectedItem_.isCollapsible())return!1;const a=this.selectedItem_;a.isExpanded()?this.selectNext():a.toggleExpanded();return!0}selectNext(){if(!this.selectedItem_)return!1;let a=this.contents_.indexOf(this.selectedItem_)+1;if(-1<a&&a<this.contents_.length){let b=this.contents_[a];for(;b&&!b.isSelectable();)b=this.contents_[++a];if(b&&b.isSelectable())return this.setSelectedItem(b),!0}return!1}selectPrevious(){if(!this.selectedItem_)return!1;let a=this.contents_.indexOf(this.selectedItem_)-1;
if(-1<a&&a<this.contents_.length){let b=this.contents_[a];for(;b&&!b.isSelectable();)b=this.contents_[--a];if(b&&b.isSelectable())return this.setSelectedItem(b),!0}return!1}dispose(){this.workspace_.getComponentManager().removeComponent("toolbox");this.flyout.dispose();for(var a=0;a<this.contents_.length;a++)this.contents_[a].dispose();for(a=0;a<this.boundEvents_.length;a++)Na(this.boundEvents_[a]);this.boundEvents_=[];this.contents_=[];this.HtmlDiv&&(this.workspace_.getThemeManager().unsubscribe(this.HtmlDiv),
Ia(this.HtmlDiv))}};mc('\n.blocklyToolboxDelete {\n  cursor: url("<<<PATH>>>/handdelete.cur"), auto;\n}\n\n.blocklyToolboxGrab {\n  cursor: url("<<<PATH>>>/handclosed.cur"), auto;\n  cursor: grabbing;\n  cursor: -webkit-grabbing;\n}\n\n/* Category tree in Toolbox. */\n.blocklyToolboxDiv {\n  background-color: #ddd;\n  overflow-x: visible;\n  overflow-y: auto;\n  padding: 4px 0 4px 0;\n  position: absolute;\n  z-index: 70;  /* so blocks go under toolbox when dragging */\n  -webkit-tap-highlight-color: transparent;  /* issue #1345 */\n}\n\n.blocklyToolboxContents {\n  display: flex;\n  flex-wrap: wrap;\n  flex-direction: column;\n}\n\n.blocklyToolboxContents:focus {\n  outline: none;\n}\n');
e(ba.TOOLBOX,Jb,xm);var Xo=oa.INPUT_VALUE,Yo=oa.OUTPUT_VALUE,Zo=oa.NEXT_STATEMENT,$o=oa.PREVIOUS_STATEMENT,ap=xa.TOP,bp=xa.BOTTOM,cp=xa.LEFT,dp=xa.RIGHT;Cd.prototype.newBlock=function(a,b){return new Ac(this,a,b)};ob.prototype.newBlock=function(a,b){return new xb(this,a,b)};Cd.prototype.newComment=function(a){return new lf(this,a)};ob.prototype.newComment=function(a){return new kf(this,a)};ob.newTrashcan=function(a){return new Vl(a)};gc.prototype.newWorkspaceSvg=function(a){return new ob(a)};d.Names$$module$build$src$core$names.prototype.populateProcedures=
function(a){a=ah(a);a=a[0].concat(a[1]);for(let b=0;b<a.length;b++)this.getName(a[b][0],d.Names$$module$build$src$core$names.NameType.PROCEDURE)};var R={};R.ASTNode=X;R.BasicCursor=we;R.Block=Ac;R.BlockSvg=xb;R.Blocks=hb;R.COLLAPSED_FIELD_NAME="_TEMP_COLLAPSED_FIELD";R.COLLAPSED_INPUT_NAME="_TEMP_COLLAPSED_INPUT";R.COLLAPSE_CHARS=30;R.CodeGenerator=d.CodeGenerator$$module$build$src$core$generator;R.CollapsibleToolboxCategory=Fd;R.ComponentManager=Qa;R.Connection=Ba;R.ConnectionChecker=Ml;R.ConnectionDB=
zd;R.ConnectionType=oa;R.ContextMenu=Uc;R.ContextMenuItems=Ya;R.ContextMenuRegistry=za;R.Css=qh;R.Cursor=Mh;R.DELETE_VARIABLE_ID="DELETE_VARIABLE_ID";R.DeleteArea=Jf;R.DragTarget=Rl;R.DropDownDiv=eb;R.Events=ma;R.Extensions=Gb;R.Field=Ka;R.FieldCheckbox=$c;R.FieldDropdown=jb;R.FieldImage=Zc;R.FieldLabel=Wc;R.FieldLabelSerializable=im;R.FieldNumber=Uh;R.FieldTextInput=Nf;R.FieldVariable=ze;R.Flyout=Of;R.FlyoutButton=Bb;R.FlyoutMetricsManager=gm;R.Generator=d.CodeGenerator$$module$build$src$core$generator;
R.Gesture=bc;R.Grid=hh;R.HorizontalFlyout=hm;R.INPUT_VALUE=Xo;R.Input=Bd;R.InsertionMarkerManager=Qb;R.InsertionMarkerPreviewer=fm;R.Marker=Pl;R.MarkerManager=oe;R.Menu=Qg;R.MenuItem=Rg;R.MetricsManager=Rh;R.Msg=d.Msg$$module$build$src$core$msg;R.NEXT_STATEMENT=Zo;R.Names=d.Names$$module$build$src$core$names;R.OPPOSITE_TYPE=Yc;R.OUTPUT_VALUE=Yo;R.Options=zb;R.PREVIOUS_STATEMENT=$o;R.PROCEDURE_CATEGORY_NAME="PROCEDURE";R.Procedures=kb;R.RENAME_VARIABLE_ID="RENAME_VARIABLE_ID";R.RenderedConnection=
tb;R.Scrollbar=Sa;R.ScrollbarPair=ih;R.ShortcutItems=Rb;R.ShortcutRegistry=Fa;R.TOOLBOX_AT_BOTTOM=bp;R.TOOLBOX_AT_LEFT=cp;R.TOOLBOX_AT_RIGHT=dp;R.TOOLBOX_AT_TOP=ap;R.TabNavigateCursor=Ql;R.Theme=Vc;R.ThemeManager=Ll;R.Themes=Wo;R.Toolbox=xm;R.ToolboxCategory=Ib;R.ToolboxItem=hi;R.ToolboxSeparator=Ce;R.Tooltip=qb;R.Touch=Nc;R.Trashcan=Vl;R.UnattachedFieldError=Ta;R.VARIABLE_CATEGORY_NAME="VARIABLE";R.VARIABLE_DYNAMIC_CATEGORY_NAME="VARIABLE_DYNAMIC";R.VERSION="11.2.2-mit-cml.1";R.VariableMap=Kh;R.VariableModel=
Sd;R.Variables=db;R.VariablesDynamic=Xc;R.VerticalFlyout=Th;R.WidgetDiv=Fb;R.Workspace=Cd;R.WorkspaceAudio=Nl;R.WorkspaceDragger=ul;R.WorkspaceSvg=ob;R.Xml=gb;R.ZoomControls=nl;R.blockAnimations=pe;R.blockRendering=Ga;R.browserEvents=ec;R.bubbles=Be;R.bumpObjects=If;R.clipboard=xe;R.comments=Pf;R.common=cb;R.config=d.config$$module$build$src$core$config;R.constants=jo;R.defineBlocksWithJsonArray=ja;R.dialog=Qc;R.dragging=Ae;R.fieldRegistry=Bf;R.geras=Tb;R.getMainWorkspace=z;R.getSelected=U;R.hasBubble=
Vd;R.hideChaff=function(a){z().hideChaff(a)};R.icons=yc;R.inject=function(a,b){let f=null;f="string"===typeof a?document.getElementById(a)||document.querySelector(a):a;var g;if(!document.contains(f)&&document!==(null==(g=f)?void 0:g.ownerDocument))throw Error("Error: container is not in current document");a=new zb(b||{});g=document.createElement("div");sa(g,"injectionDiv");(null==b?0:b.rtl)&&sa(g,"blocklyRTL");g.tabIndex=0;bb(g,ab.LABEL,d.Msg$$module$build$src$core$msg.WORKSPACE_ARIA_LABEL);f.appendChild(g);
b=Yn(g,a);const l=Zn(g,b,a);bo(l);M(l);A(l);g.addEventListener("focusin",function(){M(l)});ta(g,"keydown",null,jh);ta(Ve(),"keydown",null,jh);(b=ld())&&ta(b,"keydown",null,jh);return l};R.inputs=Bc;R.isCopyable=pf;R.isDeletable=Db;R.isDraggable=sd;R.isIcon=ok;R.isObservable=$g;R.isPaster=function(a){return void 0!==a.paste};R.isRenderedElement=function(a){return void 0!==a.getSvgRoot};R.isSelectable=function(a){return"string"===typeof a.id&&void 0!==a.workspace&&void 0!==a.select&&void 0!==a.unselect};
R.isSerializable=Qe;R.isVariableBackedParameterModel=Ri;R.layers={BLOCK:50,BUBBLE:100};R.procedures=kb;R.registry=dc;R.renderManagement=xf;R.serialization=vo;R.setLocale=ql;R.setParentContainer=v;R.svgResize=A;R.thrasos=gi;R.uiPosition=Pc;R.utils=Ra;R.zelos=Hb;R.__namespace__=d;return R});/*
 For license information please see index.js.LICENSE.txt */
!function(d,e){if("object"==typeof exports&&"object"==typeof module)module.exports=e(require("blockly/core"));else if("function"==typeof define&&define.amd)define(["blockly/core"],e);else{e="object"==typeof exports?e(require("blockly/core")):e(d.Blockly);for(var h in e)("object"==typeof exports?exports:d)[h]=e[h]}}(this,d=>(()=>{function e(p){var t=k[p];if(void 0!==t)return t.exports;t=k[p]={exports:{}};return h[p](t,t.exports,e),t.exports}var h={573:p=>{p.exports=d}},k={};e.d=(p,t)=>{for(var q in t)e.o(t,
q)&&!e.o(p,q)&&Object.defineProperty(p,q,{enumerable:!0,get:t[q]})};e.o=(p,t)=>Object.prototype.hasOwnProperty.call(p,t);e.r=p=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(p,Symbol.toStringTag,{value:"Module"});Object.defineProperty(p,"__esModule",{value:!0})};var m={};return(()=>{e.r(m);e.d(m,{LexicalVariablesPlugin:()=>U});var p={};e.r(p);e.d(p,{GLOBAL_KEYWORD:()=>"global",handlerParameterPrefix:()=>"input",localNamePrefix:()=>"local",loopParameterPrefix:()=>"item",loopRangeParameterPrefix:()=>
"counter",menuSeparator:()=>" ",possiblyPrefixGeneratedVarName:()=>N,possiblyPrefixMenuNameWith:()=>L,prefixGlobalMenuName:()=>Q,prefixSeparator:()=>"_",procedureParameterPrefix:()=>"input",showPrefixToUser:()=>!1,unprefixName:()=>da,usePrefixInCode:()=>!1});const t=document.createElement("style");document.head.appendChild(t);var q=e(573);q.Msg.LANG_VARIABLES_GLOBAL_DECLARATION_TITLE_INIT="initialize global";q.Msg.LANG_VARIABLES_GLOBAL_DECLARATION_NAME="name";q.Msg.LANG_VARIABLES_GLOBAL_DECLARATION_TO=
"to";q.Msg.LANG_VARIABLES_GLOBAL_DECLARATION_COLLAPSED_TEXT="global";q.Msg.LANG_VARIABLES_GLOBAL_DECLARATION_TOOLTIP="Creates a global variable and gives it the value of the attached blocks.";q.Msg.LANG_VARIABLES_GLOBAL_PREFIX="global";q.Msg.LANG_VARIABLES_GET_TITLE_GET="get";q.Msg.LANG_VARIABLES_GET_COLLAPSED_TEXT="get";q.Msg.LANG_VARIABLES_GET_TOOLTIP="Returns the value of this variable.";q.Msg.LANG_VARIABLES_SET_TITLE_SET="set";q.Msg.LANG_VARIABLES_SET_TITLE_TO="to";q.Msg.LANG_VARIABLES_SET_COLLAPSED_TEXT=
"set";q.Msg.LANG_VARIABLES_SET_TOOLTIP="Sets this variable to be equal to the input.";q.Msg.LANG_VARIABLES_VARIABLE=" variable";q.Msg.LANG_VARIABLES_LOCAL_DECLARATION_TITLE_INIT="initialize local";q.Msg.LANG_VARIABLES_LOCAL_DECLARATION_DEFAULT_NAME="name";q.Msg.LANG_VARIABLES_LOCAL_DECLARATION_INPUT_TO="to";q.Msg.LANG_VARIABLES_LOCAL_DECLARATION_IN_DO="in";q.Msg.LANG_VARIABLES_LOCAL_DECLARATION_COLLAPSED_TEXT="local";q.Msg.LANG_VARIABLES_LOCAL_DECLARATION_TOOLTIP="Allows you to create variables that are only accessible in the do part of this block.";
q.Msg.LANG_VARIABLES_LOCAL_DECLARATION_TRANSLATED_NAME="initialize local in do";q.Msg.LANG_VARIABLES_LOCAL_DECLARATION_EXPRESSION_IN_RETURN="in";q.Msg.LANG_VARIABLES_LOCAL_DECLARATION_EXPRESSION_COLLAPSED_TEXT="local";q.Msg.LANG_VARIABLES_LOCAL_DECLARATION_EXPRESSION_TOOLTIP="Allows you to create variables that are only accessible in the return part of this block.";q.Msg.LANG_VARIABLES_LOCAL_DECLARATION_EXPRESSION_TRANSLATED_NAME="initialize local in return";q.Msg.LANG_VARIABLES_LOCAL_MUTATOR_CONTAINER_TITLE_LOCAL_NAMES=
"local names";q.Msg.LANG_VARIABLES_LOCAL_MUTATOR_CONTAINER_TOOLTIP="";q.Msg.LANG_VARIABLES_LOCAL_MUTATOR_ARG_TITLE_NAME="name";q.Msg.LANG_VARIABLES_LOCAL_MUTATOR_ARG_DEFAULT_VARIABLE="x";q.Msg.LANG_PROCEDURES_DEFNORETURN_DEFINE="to";q.Msg.LANG_PROCEDURES_DEFNORETURN_PROCEDURE="procedure";q.Msg.LANG_PROCEDURES_DEFNORETURN_DO="do";q.Msg.LANG_PROCEDURES_DEFNORETURN_COLLAPSED_PREFIX="to ";q.Msg.LANG_PROCEDURES_DEFNORETURN_TOOLTIP="A procedure that does not return a value.";q.Msg.LANG_PROCEDURES_DOTHENRETURN_THEN_RETURN=
"result";q.Msg.LANG_PROCEDURES_DOTHENRETURN_DO="do";q.Msg.LANG_PROCEDURES_DOTHENRETURN_RETURN="result";q.Msg.LANG_PROCEDURES_DOTHENRETURN_TOOLTIP="Runs the blocks in 'do' and returns a statement. Useful if you need to run a procedure before returning a value to a variable.";q.Msg.LANG_PROCEDURES_DOTHENRETURN_COLLAPSED_TEXT="do/result";q.Msg.LANG_PROCEDURES_DEFRETURN_DEFINE="to";q.Msg.LANG_PROCEDURES_DEFRETURN_PROCEDURE="procedure";q.Msg.LANG_PROCEDURES_DEFRETURN_RETURN="result";q.Msg.LANG_PROCEDURES_DEFRETURN_COLLAPSED_PREFIX=
"to ";q.Msg.LANG_PROCEDURES_DEFRETURN_TOOLTIP="A procedure returning a result value.";q.Msg.LANG_PROCEDURES_DEF_DUPLICATE_WARNING="Warning:\nThis procedure has\nduplicate inputs.";q.Msg.LANG_PROCEDURES_CALLNORETURN_CALL="call ";q.Msg.LANG_PROCEDURES_CALLNORETURN_PROCEDURE="procedure";q.Msg.LANG_PROCEDURES_CALLNORETURN_COLLAPSED_PREFIX="call ";q.Msg.LANG_PROCEDURES_CALLNORETURN_TOOLTIP="Call a procedure with no return value.";q.Msg.LANG_PROCEDURES_CALLNORETURN_TRANSLATED_NAME="call no return";q.Msg.LANG_PROCEDURES_CALLRETURN_CALL=
"call ";q.Msg.LANG_PROCEDURES_CALLRETURN_PROCEDURE="procedure";q.Msg.LANG_PROCEDURES_CALLRETURN_COLLAPSED_PREFIX="call ";q.Msg.LANG_PROCEDURES_CALLRETURN_TOOLTIP="Call a procedure with a return value.";q.Msg.LANG_PROCEDURES_CALLRETURN_TRANSLATED_NAME="call return";q.Msg.LANG_PROCEDURES_MUTATORCONTAINER_TITLE="inputs";q.Msg.LANG_PROCEDURES_MUTATORARG_TITLE="input:";q.Msg.LANG_PROCEDURES_HIGHLIGHT_DEF="Highlight Procedure";q.Msg.LANG_PROCEDURES_MUTATORCONTAINER_TOOLTIP="";q.Msg.LANG_PROCEDURES_MUTATORARG_TOOLTIP=
"";q.Msg.LANG_CONTROLS_FOR_INPUT_WITH="count with";q.Msg.LANG_CONTROLS_FOR_INPUT_VAR="x";q.Msg.LANG_CONTROLS_FOR_INPUT_FROM="from";q.Msg.LANG_CONTROLS_FOR_INPUT_TO="to";q.Msg.LANG_CONTROLS_FOR_INPUT_DO="do";q.Msg.LANG_CONTROLS_FOR_TOOLTIP="Count from a start number to an end number.\nFor each count, set the current count number to\nvariable '%1', and then do some statements.";q.Msg.LANG_CONTROLS_FORRANGE_INPUT_ITEM="for each";q.Msg.LANG_CONTROLS_FORRANGE_INPUT_VAR="number";q.Msg.LANG_CONTROLS_FORRANGE_INPUT_START=
"from";q.Msg.LANG_CONTROLS_FORRANGE_INPUT_END="to";q.Msg.LANG_CONTROLS_FORRANGE_INPUT_STEP="by";q.Msg.LANG_CONTROLS_FORRANGE_INPUT_DO="do";q.Msg.LANG_CONTROLS_FORRANGE_INPUT_COLLAPSED_TEXT="for number in range";q.Msg.LANG_CONTROLS_FORRANGE_INPUT_COLLAPSED_PREFIX="for";q.Msg.LANG_CONTROLS_FORRANGE_INPUT_COLLAPSED_SUFFIX=" in range";q.Msg.LANG_CONTROLS_FORRANGE_TOOLTIP="Runs the blocks in the 'do' section for each numeric value in the range from start to end, stepping the value each time.  Use the given variable name to refer to the current value.";
q.Msg.LANG_CONTROLS_FOREACH_INPUT_ITEM="for each";q.Msg.LANG_CONTROLS_FOREACH_INPUT_VAR="item";q.Msg.LANG_CONTROLS_FOREACH_INPUT_INLIST="in list";q.Msg.LANG_CONTROLS_FOREACH_INPUT_DO="do";q.Msg.LANG_CONTROLS_FOREACH_INPUT_COLLAPSED_TEXT="for item in list";q.Msg.LANG_CONTROLS_FOREACH_INPUT_COLLAPSED_PREFIX="for ";q.Msg.LANG_CONTROLS_FOREACH_INPUT_COLLAPSED_SUFFIX=" in list";q.Msg.LANG_CONTROLS_FOREACH_TOOLTIP="Runs the blocks in the 'do'  section for each item in the list.  Use the given variable name to refer to the current list item.";
q.Msg.LANG_CONTROLS_FOREACH_DICT_INPUT="for each %1 with %2 in dictionary %3";q.Msg.LANG_CONTROLS_FOREACH_DICT_INPUT_DO="do";q.Msg.LANG_CONTROLS_FOREACH_DICT_INPUT_KEY="key";q.Msg.LANG_CONTROLS_FOREACH_DICT_INPUT_VALUE="value";q.Msg.LANG_CONTROLS_FOREACH_DICT_TITLE="for each in dictionary";q.Msg.LANG_CONTROLS_FOREACH_DICT_TOOLTIP="Runs the blocks in the 'do' section for each key-value entry in the dictionary. Use the given variable names to refer to the key/value of the current dictionary item.";
q.Msg.ERROR_SELECT_VALID_ITEM_FROM_DROPDOWN="Select a valid item in the drop down.";q.Msg.ERROR_BLOCK_CANNOT_BE_IN_DEFINITION="This block cannot be in a definition";q.Msg.HORIZONTAL_PARAMETERS="Arrange Parameters Horizontally";q.Msg.VERTICAL_PARAMETERS="Arrange Parameters Vertically";q.Msg.LANG_CONTROLS_DO_THEN_RETURN_INPUT_DO="do";q.Msg.LANG_CONTROLS_DO_THEN_RETURN_INPUT_RETURN="result";q.Msg.LANG_CONTROLS_DO_THEN_RETURN_TOOLTIP="Runs the blocks in 'do' and returns a statement. Useful if you need to run a procedure before returning a value to a variable.";
q.Msg.LANG_CONTROLS_DO_THEN_RETURN_COLLAPSED_TEXT="do/result";q.Msg.LANG_CONTROLS_DO_THEN_RETURN_TITLE="do result";q.Msg.PROCEDURES_DEFNORETURN_PROCEDURE=q.Msg.LANG_PROCEDURES_DEFNORETURN_PROCEDURE;q.Msg.PROCEDURES_DEFRETURN_PROCEDURE=q.Msg.LANG_PROCEDURES_DEFRETURN_PROCEDURE;q.Msg.LANG_VARIABLES_GLOBAL_DECLARATION_WARNING="Global declarations must be inside of a initialize global block.";q.Msg.LANG_VARIABLES_GLOBAL_DECLARATION_TITLE_INIT="initialize global variables";q.Msg.LANG_VARIABLES_GLOBAL_DECLARATION_TO_DO=
"to";q.Msg.LANG_VARIABLES_GLOBAL_DECLARATION_TOOLTIP="Allows you to create global variables that are accessible everywhere";q.Msg.LANG_VARIABLES_GLOBAL_DECLARATION_BLOCK_CHECK="Only global_declaration_entry blocks are allowed here.";class y{checkErrors(r){if(r.getSvgRoot&&!r.getSvgRoot()||r.readOnly)return r.hasWarning&&(r.hasWarning=!1),void(r.hasError&&(r.hasError=!1));r.errors||(r.errors=[]);r.warnings||(r.warnings=[]);var v=r.errors;const A=r.warnings;for(let D=0;D<v.length;D++)if(v[D].func&&
v[D].func.call(this,r,v[D]))return r.hasError||(r.hasError=!0),void(r.hasWarning&&(r.hasWarning=!1));r.hasError&&(r.hasError=!1);for(v=0;v<A.length;v++)if(A[v].func&&A[v].func.call(this,r,A[v]))return void(r.hasWarning||(r.hasWarning=!0));r.setWarningText(null,"warningHandler");r.hasWarning&&(r.hasWarning=!1)}setError(r,v){r.setWarningText(v,"warningHandler")}setWarning(r,v){r.setWarningText(v,"warningHandler")}}class I{static checkIsInDefinition(r){if("global_declaration"===r.getRootBlock().type){const v=
q.Msg.ERROR_BLOCK_CANNOT_BE_IN_DEFINITION;return r.workspace.getWarningHandler().setError(r,v),!0}return!1}static checkDropDownContainsValidValue(r,v){if(r.workspace.isDragging&&r.workspace.isDragging()||r.isInFlyout||!r.workspace||r.workspace.isFlyout||!r.rendered)return!1;for(let A=0;A<v.dropDowns.length;A++){const D=r.getField(v.dropDowns[A]),S=D.getOptions(!1),ja=D.getText(),ra=D.getValue();let wa=!1;D.updateMutation&&D.updateMutation();for(let Ea=0;Ea<S.length;Ea++)if(S[Ea][1]===ra&&" "!==ra){wa=
!0;S[Ea][0]!==ja&&D.setValue(S[Ea][0]);break}if(!wa)return v=q.Msg.ERROR_SELECT_VALID_ITEM_FROM_DROPDOWN,r.workspace.getWarningHandler().setError(r,v),r.workspace.disableInvalidBlocks&&r.setDisabledReason(!0,q.Msg.ERROR_SELECT_VALID_ITEM_FROM_DROPDOWN),!0}return!r.isEnabled()&&r.workspace.disableInvalidBlocks&&r.setDisabledReason(!1,q.Msg.ERROR_SELECT_VALID_ITEM_FROM_DROPDOWN),!1}}const L=function(r){return function(v){return""+v}},Q=function(r){return q.Msg.LANG_VARIABLES_GLOBAL_PREFIX+" "+r},da=
function(r){return 0===r.indexOf(q.Msg.LANG_VARIABLES_GLOBAL_PREFIX+" ")?[q.Msg.LANG_VARIABLES_GLOBAL_PREFIX,r.substring(q.Msg.LANG_VARIABLES_GLOBAL_PREFIX.length+1)]:0===r.indexOf("global ")?["global",r.substring(7)]:["",r]},N=function(r){return function(v){return""+v}},H=function(r){r||=[];this.elements={};for(let v,A=0;v=r[A];A++)this.elements[v]=!0};H.prototype.isMember=function(r){return!!this.elements[r]};H.prototype.isEmpty=function(){for(let r in this.elements)return!1;return!0};H.prototype.size=
function(){let r=0;for(let v in this.elements)r++;return r};H.prototype.toList=function(){const r=[];for(let v in this.elements)r.push(v);return r.sort()};H.prototype.toString=function(){return"NameSet{"+this.toList().join(",")+"}"};H.prototype.copy=function(){const r=new H;for(let v in this.elements)r.insert(v);return r};H.prototype.mirror=function(r){let v;for(v in this.elements)delete this.elements[v];for(v in r.elements)this.elements[v]=!0};H.prototype.insert=function(r){this.elements[r]=!0};
H.prototype.deleteName=function(r){delete this.elements[r]};H.prototype.unite=function(r){for(let v in r.elements)this.elements[v]=!0};H.prototype.intersect=function(r){for(let v in this.elements)r.elements[v]||delete this.elements[v]};H.prototype.subtract=function(r){for(let v in this.elements)r.elements[v]&&delete this.elements[v]};H.prototype.rename=function(r){this.mirror(this.renamed(r))};H.prototype.insertion=function(r){const v=this.copy();return v.insert(r),v};H.prototype.deletion=function(r){const v=
this.copy();return v.deleteName(r),v};H.prototype.union=function(r){const v=this.copy();return v.unite(r),v};H.prototype.intersection=function(r){const v=this.copy();return v.intersect(r),v};H.prototype.difference=function(r){const v=this.copy();return v.subtract(r),v};H.prototype.renamed=function(r){const v=new H;for(let A in this.elements){const D=r.apply(A);D?v.insert(D):v.insert(A)}return v};H.unionAll=function(r){const v=new H;for(let A,D=0;A=r[D];D++)v.unite(A);return v};H.intersectAll=function(r){if(0===
r.length)return new H;const v=r[0];for(let A,D=1;A=r[D];D++)v.intersect(A);return v};const K=function(r,v){if(this.bindings={},K.isAllStringsArray(v)&&K.isAllStringsArray(r)&&r.length===v.length)for(var A=0;A<r.length;A++)this.bindings[r[A]]=v[A];else if(!v&&K.isBindingsObject(r))for(A in this.bindings={},r)this.bindings[A]=r[A]};K.isAllStringsArray=function(r){if("object"!=typeof r||!r.length)return!1;for(var v=0;v<r.length;v++)if("string"!=typeof r[v])return!1;return!0};K.isBindingsObject=function(r){if("object"!=
typeof r)return!1;for(var v in r)if("string"!=typeof v||(r[v],0))return!1;return!0};K.simpleSubstitution=function(r,v){var A={};return A[r]=v,new K(A)};K.prototype.apply=function(r){return this.bindings[r]||r};K.prototype.map=function(r){const v=this;return r.map(function(A){return v.apply(A)})};K.prototype.toString=function(){var r=[],v;for(v in this.bindings)r.push(v+":"+this.bindings[v]);return"Substitution{"+r.sort().join(",")+"}"};K.prototype.copy=function(){var r=new K,v;for(v in this.bindings)r.bindings[v]=
this.bindings[v];return r};K.prototype.restrictDomain=function(r){for(var v=new K,A=0;A<r.length;A++){var D=this.bindings[r[A]];D&&(v.bindings[r[A]]=D)}return v};K.prototype.remove=function(r){var v=new K,A;for(A in this.bindings)-1==r.indexOf(A)&&(v.bindings[A]=this.bindings[A]);return v};K.prototype.extend=function(r){var v=this.copy(),A;for(A in r.bindings)v.bindings[A]=r.bindings[A];return v};K.prototype.domain=function(){var r=[],v;for(v in this.bindings)r.push(v);return r.sort()};K.prototype.getBindings=
function(){var r={},v;for(v in this.bindings)r[v]=this.bindings[v];return r};class C extends q.FieldDropdown{constructor(r,v){super(C.dropdownCreate);this.varname=r;this.translatedName=v;r?this.doValueUpdate_(r):this.doValueUpdate_(q.Variables.generateUniqueName())}setTranslatedValue(r,v){this.varname=v;this.translatedName=r;this.getOptions(!1);this.setValue(v);this.forceRerender()}}C.prototype.doClassValidation_=function(r){return r};C.getGlobalNames=function(r){var v=q.common.getMainWorkspace();
if(!v)return[];var A=v.getRootWorkspace()||v;if(A&&A.getWarningHandler&&A.getWarningHandler().cacheGlobalNames)return A.getWarningHandler().cachedGlobalNames;v=[];if(A&&!A.isFlyout){A=A.getTopBlocks();for(let D=0;D<A.length;D++){const S=A[D];S.getGlobalNames&&S!=r&&S.isEnabled()&&v.push(...S.getGlobalNames(r))}}return v};C.prototype.getNamesInScope=function(){return C.getNamesInScope(this.getSourceBlock())};C.getNamesInScope=function(r){let v=C.getGlobalNames();v=E.sortAndRemoveDuplicates(v);v=v.map(function(A){return[Q(A),
"global "+A]});r=C.getLexicalNamesInScope(r);return v.concat(r)};C.getLexicalNamesInScope=function(r){let v=[];const A={};let D,S;if(S=r,S&&(D=S.getParent(),D))for(;D;)D.withLexicalVarsAndPrefix&&D.withLexicalVarsAndPrefix(S,(ja,ra,wa)=>{wa=wa||ja;A[wa]||(A[wa]=ra);ra=L(A[wa])(wa);v.push([ra,ja])}),S=D,D=D.getParent();return E.sortAndRemoveDuplicates(v)};C.dropdownCreate=function(){const r=this.getNamesInScope();return 0<r.length?r:this.translatedName?[[this.translatedName,this.varname]]:[[" "," "]]};
C.prototype.doValueUpdate_=function(r){if(Object.getPrototypeOf(q.FieldDropdown).prototype.doValueUpdate_.call(this,r),r&&" "!==r){var v=r.split(" ");2==v.length&&"global"!==v[0]&&(r="global "+v[1])}this.value_=r;v=this.getOptions(!0,[[(A=r,A.startsWith("global ")?A.replace("global ",q.Msg.LANG_VARIABLES_GLOBAL_PREFIX+" "):A),r]]);var A;for(let D,S=0;D=v[S];S++)if(D[1]==this.value_){this.selectedOption=D;break}this.updateMutation();this.forceRerender()};C.prototype.updateMutation=function(){var r=
this.getText();if(this.getSourceBlock()&&this.getSourceBlock().getParent()){if(this.getSourceBlock().eventparam=void 0,0===r.indexOf(q.Msg.LANG_VARIABLES_GLOBAL_PREFIX+" "))return this.getSourceBlock().eventparam=null,this.translatedName=void 0,void(this.varname=void 0);let v,A=this.getSourceBlock().getParent();for(;A;){const D=A.declaredVariables?A.declaredVariables():[];for(v=0;v<D.length;v++)if(D[v]==r)return"component_event"==A.type?(r=A.getParameters()[v].name,this.getSourceBlock().eventparam=
r,this.translatedName=D[v],void(this.varname=r)):(this.getSourceBlock().eventparam=null,this.translatedName=void 0,void(this.varname=void 0));A=A.getParent()}}};C.prototype.getOptions=function(r,v){Array.isArray(r)&&(v=r);v=v||[];if(this.isOptionListDynamic()){if(!this.generatedOptions||!r){r=this.generatedOptions=this.menuGenerator_.call(this).concat(v);if(!Array.isArray(r))throw TypeError("FieldDropdown options must be an array.");if(!r.length)throw TypeError("FieldDropdown options must not be an empty array.");
let A=!1;for(let D=0;D<r.length;++D){const S=r[D];Array.isArray(S)?"string"!=typeof S[1]?(A=!0,console.error("Invalid option["+D+"]: Each FieldDropdown option id must be a string. Found "+S[1]+" in: ",S)):S[0]&&"string"!=typeof S[0]&&"string"!=typeof S[0].src&&(A=!0,console.error("Invalid option["+D+"]: Each FieldDropdown option must have a string label or image description. Found"+S[0]+" in: ",S)):(A=!0,console.error("Invalid option["+D+"]: Each FieldDropdown option must be an array. Found: ",S))}if(A)throw TypeError("Found invalid FieldDropdown options.");
}v=this.generatedOptions.concat(v)}else v=this.menuGenerator_;return v};C.dropdownChange=function(r){r&&(this.doValueUpdate_(r),r=this.getSourceBlock().workspace.getTopWorkspace(),r.getWarningHandler&&r.getWarningHandler().checkErrors(this.getSourceBlock()))};C.nameNotIn=function(r,v){var A=C.prefixSuffix(r);const D=A[0];A=A[1];let S=!1,ja=!1;const ra=[];for(let wa=0;wa<v.length;wa++){const Ea=C.prefixSuffix(v[wa]),ub=Ea[1];Ea[0]===D&&(ub===A&&(ja=!0),""===ub?S=!0:ra.push(ub))}if(ja){if(S){r=ra.map(function(wa,
Ea,ub){return parseInt(wa,10)});r.sort(function(wa,Ea){return wa-Ea});v=2;for(A=0;A<r.length&&!(v<r[A]);)v==r[A]?(v++,A++):A++;return D+v}return D}return r};C.prefixSuffix=function(r){const v=r.match(/^(.*?)(\d+)$/);return v?[v[1],v[2]]:[r,""]};C.fromJson=function(r){r=q.utils.replaceMessageReferences(r.name);return new C(r)};q.fieldRegistry.register("field_lexical_variable",C);const E={renameGlobal:function(r){const v=this.value_;r=E.makeLegalIdentifier(r);this.getSourceBlock().getField("NAME").doValueUpdate_(r);
var A=C.getGlobalNames(this.getSourceBlock());if(r=C.nameNotIn(r,A),this.getSourceBlock().rendered&&q.common.getMainWorkspace()){A=q.common.getMainWorkspace().getAllBlocks();for(let D=0;D<A.length;D++){const S=A[D],ja=S.renameLexicalVar;ja&&ja.call(S,"global "+v,"global "+r,q.Msg.LANG_VARIABLES_GLOBAL_PREFIX+" "+v,q.Msg.LANG_VARIABLES_GLOBAL_PREFIX+" "+r)}}return r},renameParam:function(r){var v=this.htmlInput_;v=this.getValue()||v&&v.defaultValue||this.getText();return r=E.makeLegalIdentifier(r),
E.renameParamFromTo(this.getSourceBlock(),v,r,!1)},renameParamFromTo:function(r,v,A,D){return r.mustNotRenameCapturables?E.renameParamWithoutRenamingCapturables(r,v,A,[]):D?(E.renameParamRenamingCapturables(r,v,A),A):E.renameParamWithoutRenamingCapturables(r,v,A,[])},renameParamRenamingCapturables:function(r,v,A){if(A!==v){var D=r.declaredNames?r.declaredNames():[];if(-1==D.indexOf(v))throw Error("LexicalVariable.renamingCapturables: oldName "+v+" is not in declarations {"+D.join(",")+"}");const S=
[];C.getNamesInScope(r).map(function(ja){ja[0]==ja[1]?S.push(ja[0]):S.push(ja[0],ja[1])});D=D.concat(S);if(-1!=D.indexOf(A))throw Error("LexicalVariable.renameParamRenamingCapturables: newName "+A+" is in existing declarations {"+D.join(",")+"}");if(!r.renameBound)throw Error("LexicalVariable.renameParamRenamingCapturables: block "+r.type+" is not a declaration block.");v=K.simpleSubstitution(v,A);A=new K;r.renameBound(v,A)}},renameFree:function(r,v){r&&(r.renameFree?r.renameFree(v):r.getChildren().map(function(A){E.renameFree(A,
v)}))},freeVariables:function(r){let v=[];r?r.freeVariables?v=r.freeVariables():(r=r.getChildren().map(function(A){return E.freeVariables(A)}),v=H.unionAll(r)):v=new H;return v},renameParamWithoutRenamingCapturables:function(r,v,A,D){if(v===A)return v;var S=E.renameParamWithoutRenamingCapturablesInfo(r,v,"");const ja=S[0];var ra=S[1];S=[];r.declaredNames&&(S=r.declaredNames(),r=S.indexOf(v),-1!=r&&S.splice(r,1),-1!=D.indexOf(A))&&(D=S.indexOf(A),-1!=D&&S.splice(D,1));D=E.sortAndRemoveDuplicates(ra.concat(S));
if((A=C.nameNotIn(A,D))!==v&&-1==S.indexOf(v))for(S=0;S<ja.length;S++)D=ja[S],(ra=D.renameLexicalVar)&&ra.call(D,L("")(v),L("")(A));return A},renameParamWithoutRenamingCapturablesInfo:function(r,v,A){var D=[];r.blocksInScope&&(D=r.blocksInScope());r=D.map(function(ja){return E.referenceResult(ja,v,A,[])});D=[];let S=[];for(let ja=0;ja<r.length;ja++)D=D.concat(r[ja][0]),S=S.concat(r[ja][1]);return S=E.sortAndRemoveDuplicates(S),[D,S]},checkIdentifier:function(r){r=r.trim().replace(/[\s\xa0]+/g,"_");
return{isLegal:0==r.search(RegExp("^[^-0-9!&%^/>=<`'\"#:;,\\\\*+.()|{}[\\] ][^-!&%^/>=<'\"#:;,\\\\*+.()|{}[\\] ]*$")),transformed:r}},makeLegalIdentifier:function(r){r=E.checkIdentifier(r);return r.isLegal?r.transformed:""===r.transformed?"_":"name"},referenceResult:function(r,v,A,D){if(!r)return[[],[]];r=r.referenceResults?r.referenceResults(v,A,D):r.getChildren().map(function(ra){return E.referenceResult(ra,v,A,D)});let S=[],ja=[];for(let ra=0;ra<r.length;ra++)S=S.concat(r[ra][0]),ja=ja.concat(r[ra][1]);
return[S,ja]},sortAndRemoveDuplicates:function(r){const v=r.sort((D,S)=>{if("string"==typeof D&&"string"==typeof S)return D.localeCompare(S);if(Array.isArray(D)&&Array.isArray(S))return D[1].localeCompare(S[1]);throw Error("LexicalVariable.sortAndRemoveDuplicates: arguments must be strings or arrays of strings");}),A=[];if(1<=r.length){r=v[0];A.push(r);for(let D=1;D<v.length;D++){let S=!1;const ja=v[D];(S=Array.isArray(ja)&&Array.isArray(r)?0===ja[1].localeCompare(r[1]):ja===r)||(r=ja,A.push(r))}}return A},
getNextTargetBlock:function(r){return r&&r.nextConnection&&r.nextConnection.targetBlock()?r.nextConnection.targetBlock():null},stringListsEqual:function(r,v){const A=r.length;if(A!==v.length)return!1;for(let D=0;D<A;D++)if(r[D]!==v[D])return!1;return!0}},F=["",""],P=function(r,v){v=(v||q.common.getMainWorkspace()).getTopBlocks();const A=[F];for(let D=0;D<v.length;D++){const S=v[D].getFieldValue("NAME");"procedures_defnoreturn"!=v[D].type||r?"procedures_defreturn"==v[D].type&&r&&A.push([S,S]):A.push([S,
S])}return 1<A.length&&A.splice(0,1),A},ha=function(r){if(this.getSourceBlock()&&this.getSourceBlock().isInFlyout)return r;const v=this.oldName_||this.getValue();var A=r;r=E.makeLegalIdentifier(r);var D=function(S){const ja=S.workspace.getTopBlocks(!1),ra=[];for(let wa=0;wa<ja.length;wa++)"procedures_defnoreturn"!==ja[wa].type&&"procedures_defreturn"!==ja[wa].type||ja[wa]!==S&&ra.push(ja[wa]);return ra}(this.getSourceBlock()).map(function(S){return S.getFieldValue("NAME")});(r=C.nameNotIn(r,D))!==
A&&this.doValueUpdate_(r);A=this.getSourceBlock().workspace.getAllBlocks();for(D=0;D<A.length;D++){const S=A[D].renameProcedure;S&&S.call(A[D],v,r)}return this.oldName_=r,r},ea=function(r){this.workspace_=r;this.procedures_={};this.returnProcedures_={};this.voidProcedures_={};this.voidProcedures=this.returnProcedures=this.length=0};ea.defaultValue=["","none"];ea.prototype.getNames=function(r){return P(r,this.workspace_).map(function(v){return v[0]})};ea.prototype.getMenuItems=function(r){return P(r,
this.workspace_)};ea.prototype.getDeclarationBlocks=function(r){return q.utils.object.values(r?this.returnProcedures_:this.voidProcedures_)};ea.prototype.getDeclarationsBlocksExcept=function(r){const v=[];return q.utils.values(this.procedures_).forEach(function(A){A!==r&&v.push(A)}),v};ea.prototype.getAllDeclarationNames=function(){return q.utils.values(this.procedures_).map(function(r){return r.getFieldValue("NAME")})};ea.prototype.addProcedure=function(r,v){if("procedures_defnoreturn"!=v.type&&
"procedures_defreturn"!=v.type)return console.warn("Attempt to addProcedure with block type "+v.type),!1;r=v.id;return!(r in this.procedures_)&&(this.procedures_[r]=v,this.length++,"procedures_defnoreturn"==v.type?(this.voidProcedures_[r]=v,this.voidProcedures++):(this.returnProcedures_[r]=v,this.returnProcedures++),!0)};ea.prototype.removeProcedure=function(r){return r in this.procedures_&&("procedures_defnoreturn"==this.procedures_[r].type?(delete this.voidProcedures_[r],this.voidProcedures--):
(delete this.returnProcedures_[r],this.returnProcedures--),delete this.procedures_[r],this.length--),!0};ea.prototype.renameProcedure=function(r,v,A){};ea.prototype.getProcedure=function(r){return this.procedures_[r]||this.getProcedureByName(r)};ea.prototype.getProcedureByName=function(r){for(const v in this.procedures_)if(this.procedures_[v].getFieldValue("NAME")===r)return this.procedures_[v]};ea.prototype.clear=function(){this.procedures_={};this.returnProcedures_={};this.voidProcedures_={};this.voidProcedures=
this.returnProcedures=this.length=0};q.Workspace.prototype.flydown_=q.Workspace.prototype.flydown_||null;q.Workspace.prototype.getFlydown=q.Workspace.prototype.getFlydown||function(){return this.flydown_};q.Workspace.prototype.getProcedureDatabase=q.Workspace.prototype.getProcedureDatabase||function(){return this.procedureDb_||(this.procedureDb_=new ea(this)),this.procedureDb_};q.Workspace.prototype.getTopWorkspace=q.Workspace.prototype.getTopWorkspace||function(){let r=this;for(;r.targetWorkspace;)r=
r.targetWorkspace;return r};q.Workspace.prototype.getWarningHandler=q.Workspace.prototype.getWarningHandler||function(){return this.warningHandler_||(this.warningHandler_=new y),this.warningHandler_};q.WorkspaceSvg.prototype.flydown_=q.WorkspaceSvg.prototype.flydown_||null;q.WorkspaceSvg.prototype.getFlydown=q.WorkspaceSvg.prototype.getFlydown||function(){return this.flydown_};q.WorkspaceSvg.prototype.getProcedureDatabase=q.WorkspaceSvg.prototype.getProcedureDatabase||function(){return this.procedureDb_||
(this.procedureDb_=new ea(this)),this.procedureDb_};q.WorkspaceSvg.prototype.getTopWorkspace=q.WorkspaceSvg.prototype.getTopWorkspace||function(){let r=this;for(;r.targetWorkspace;)r=r.targetWorkspace;return r};q.WorkspaceSvg.prototype.getWarningHandler=q.WorkspaceSvg.prototype.getWarningHandler||function(){return y};class aa extends q.inputs.ValueInput{constructor(r,v){super(r,v);this.connection=this.makeConnection(q.ConnectionType.INPUT_VALUE);this.type=q.inputs.inputTypes.VALUE}}q.registry.register(q.registry.Type.INPUT,
"indented_input",aa);class W extends q.FieldTextInput{static timeout=500;static showPid_=0;static openFieldFlydown_=null;static DISPLAY_BELOW="BELOW";static DISPLAY_RIGHT="RIGHT";static DISPLAY_LOCATION=W.DISPLAY_BELOW;constructor(r,v,A,D){super(r,D);this.EDITABLE=v;this.displayLocation=A||W.DISPLAY_RIGHT}showEditor_(){this.EDITABLE&&(W.showPid_&&(clearTimeout(W.showPid_),W.showPid_=0,q.common.getMainWorkspace().hideChaff()),super.showEditor_())}init(r){super.init(r);q.utils.dom.addClass(this.fieldGroup_,
this.fieldCSSClassName);this.mouseOverWrapper_=q.browserEvents.bind(this.fieldGroup_,"mouseover",this,this.onMouseOver_);this.mouseOutWrapper_=q.browserEvents.bind(this.fieldGroup_,"mouseout",this,this.onMouseOut_)}}W.prototype.fieldCSSClassName="blocklyFieldFlydownField";W.prototype.flyoutCSSClassName="blocklyFieldFlydownFlydown";W.prototype.onMouseOver_=function(r){this.getSourceBlock().isInFlyout||0!=W.showPid_||(W.showPid_=window.setTimeout(this.showFlydownMaker_(),W.timeout));r.stopPropagation()};
W.prototype.onMouseOut_=function(r){window.clearTimeout(W.showPid_);W.showPid_=0;r.stopPropagation()};W.prototype.showFlydownMaker_=function(){const r=this;return function(){if(0!==W.showPid_&&!r.getSourceBlock().workspace.isDragging()&&!this.htmlInput_)try{r.showFlydown_()}catch(v){console.error("Failed to show flydown",v)}W.showPid_=0}};W.prototype.showFlydown_=function(){q.common.getMainWorkspace().hideChaff();const r=q.common.getMainWorkspace().getFlydown();q.common.getMainWorkspace().getParentSvg().appendChild(r.svgGroup_);
const v=r.targetWorkspace.scale;r.workspace_.setScale(v);r.setCSSClass(this.flyoutCSSClassName);var A=this.flydownBlocksXML_();A=void 0!==(D=q.utils.xml.textToDom(A)).children?D.children:Array.prototype.filter.call(D.childNodes,function(ja){return ja.nodeType==q.utils.dom.NodeType.ELEMENT_NODE});var D;D=q.common.getMainWorkspace().getSvgXY(this.borderRect_);const S=this.borderRect_.getBBox();this.displayLocation===W.DISPLAY_BELOW?D.y+=S.height*v:D.x+=S.width*v;r.field_=this;r.showAt(A,D.x,D.y);W.openFieldFlydown_=
this};W.hide=function(){window.clearTimeout(W.showPid_);const r=q.common.getMainWorkspace().getFlydown();r&&r.hide()};W.prototype.onHtmlInputChange=function(r){r=this.htmlInput_;const v=r.value;if(v!==r.oldValue_){r.oldValue_=v;var A=!0;if(this.getSourceBlock()){A=r.value;var D=this.doClassValidation_(A);if(null===D)A=null;else if(void 0!==D&&(A=D),D=this.getValidator())D=D.call(this,A),null===D?A=null:void 0!==D&&(A=D)}null===A?q.utils.dom.addClass(r,"blocklyInvalidInput"):(q.utils.dom.removeClass(r,
"blocklyInvalidInput"),this.doValueUpdate_(A))}else q.utils.userAgent.WEBKIT&&this.getSourceBlock().render();this.textContent_.nodeValue=v;this.forceRerender();this.resizeEditor_();q.svgResize(this.getSourceBlock().workspace)};W.prototype.dispose=function(){W.openFieldFlydown_==this&&W.hide();q.FieldTextInput.prototype.dispose.call(this)};W.fromJson=function(r){const v=q.utils.replaceMessageReferences(r.name);return new W(v,r.is_editable)};q.fieldRegistry.register("field_flydown",W);class ka extends q.VerticalFlyout{constructor(r){super(r);
this.dragAngleRange_=360}}ka.prototype.previousCSSClassName_="";ka.prototype.VERTICAL_SEPARATION_FACTOR=1;ka.prototype.createDom=function(r){return this.previousCSSClassName_=r,this.svgGroup_=q.utils.dom.createSvgElement("g",{class:r},null),this.svgBackground_=q.utils.dom.createSvgElement("path",{},this.svgGroup_),this.svgGroup_.appendChild(this.workspace_.createDom()),this.svgGroup_};ka.prototype.setCSSClass=function(r){r!==this.previousCSSClassName_&&(q.utils.dom.removeClass(this.svgGroup_,this.previousCSSClassName_),
q.utils.dom.addClass(this.svgGroup_,r),this.previousCSSClassName_=r)};ka.prototype.init=function(r){q.Flyout.prototype.init.call(this,r,!1);this.workspace_.setTheme(r.getTheme());r.getComponentManager().addCapability(this.id,q.ComponentManager.Capability.AUTOHIDEABLE)};ka.prototype.position=function(){};ka.prototype.showAt=function(r,v,A){q.Events.disable();try{this.show(r)}finally{q.Events.enable()}r=this.CORNER_RADIUS*this.workspace_.scale;const D=this.width_-2*r,S=this.height_-2*r,ja=["M 0,"+r];
ja.push("a",r,r,0,0,1,r,-r);ja.push("h",D);ja.push("a",r,r,0,0,1,r,r);ja.push("v",S);ja.push("a",r,r,0,0,1,-r,r);ja.push("h",-D);ja.push("a",r,r,0,0,1,-r,-r);ja.push("z");this.svgBackground_.setAttribute("d",ja.join(" "));this.svgGroup_.setAttribute("transform","translate("+v+", "+A+")")};ka.prototype.reflow=function(){this.workspace_.scale=this.targetWorkspace.scale;const r=this.workspace_.scale;let v=0,A=0;const D=this.CORNER_RADIUS*r,S=this.workspace_.getTopBlocks(!1);for(let ra,wa=0;ra=S[wa];wa++){var ja=
ra.getHeightWidth();v=Math.max(v,ja.width*r);A+=ja.height*r}v+=2*D+this.tabWidth_*r;ja=this.workspace_.getRenderer().getConstants();if(A+=3*D+D*this.VERTICAL_SEPARATION_FACTOR*S.length+(ja.ADD_START_HATS?ja.START_HAT_HEIGHT:0)*r/2,this.width_!=v){for(let ra,wa=0;ra=S[wa];wa++){ja=ra.getHeightWidth();const Ea=ra.getRelativeToSurfaceXY();if(this.RTL){const ub=v-D-r*(this.tabWidth_-Ea.x);ra.moveBy(ub,0);Ea.x+=ub}ra.flyoutRect_&&(ra.flyoutRect_.setAttribute("width",ja.width),ra.flyoutRect_.setAttribute("height",
ja.height),ra.flyoutRect_.setAttribute("x",this.RTL?Ea.x-ja.width:Ea.x),ra.flyoutRect_.setAttribute("y",Ea.y))}this.width_=v;this.height_=A}};ka.prototype.onMouseMove_=function(r){};ka.prototype.placeNewBlock_=function(r){const v=this.targetWorkspace;var A=r.getSvgRoot();if(!A)throw Error("originBlock is not rendered.");A=this.workspace_.getSvgXY(A);var D=A.x;A.x+=D/v.scale-D;D=A.y;A.y+=D/v.scale-D;r=q.Xml.blockToDom(r);r=q.Xml.domToBlock(r,v);D=r.getSvgRoot();if(!D)throw Error("block is not rendered.");
D=v.getSvgXY(D);return D.x+=v.scrollX/v.scale-v.scrollX,D.y+=v.scrollY/v.scale-v.scrollY,v.getToolbox()&&!v.scrollbar&&(D.x+=v.getToolbox().getWidth()/v.scale,D.y+=v.getToolbox().getHeight()/v.scale),r.moveBy(A.x-D.x,A.y-D.y),r};ka.prototype.shouldHide=!0;ka.prototype.hide=function(){this.shouldHide&&(q.Flyout.prototype.hide.call(this),W.openFieldFlydown_=null);this.shouldHide=!0};ka.prototype.autoHide=function(){this.hide()};q.Blocks.lexical_variable_get={category:"Variables",helpUrl:q.Msg.LANG_VARIABLES_GET_HELPURL,
init:function(){this.setStyle("variable_blocks");this.fieldVar_=new C(" ");this.appendDummyInput().appendField(q.Msg.LANG_VARIABLES_GET_TITLE_GET).appendField(this.fieldVar_,"VAR");this.setOutput(!0,null);this.setTooltip(q.Msg.LANG_VARIABLES_GET_TOOLTIP);this.errors=[{func:I.checkIsInDefinition},{func:I.checkDropDownContainsValidValue,dropDowns:["VAR"]}];this.setOnChange(function(r){this.workspace.getWarningHandler().checkErrors(this)})},referenceResults:function(r,v,A){var D=this.getChildren().map(function(Ea){return E.referenceResult(Ea,
r,v,A)});let S=[],ja=[];for(var ra=0;ra<D.length;ra++)S=S.concat(D[ra][0]),ja=ja.concat(D[ra][1]);D=this.getField("VAR").getText();ra=da(D);D=ra[0];ra=ra[1];const wa=-1==A.indexOf(ra);D!==q.Msg.LANG_VARIABLES_GLOBAL_PREFIX&&(ra===r&&wa?(S.push(this),ja=ja.concat(A)):!wa||ja.push(ra));return[[S,ja]]},getDeclaredVars:function(){return[this.getFieldValue("VAR")]},renameLexicalVar:function(r,v,A,D){void 0===A?r===this.getFieldValue("VAR")&&this.setFieldValue(v,"VAR"):A&&A===this.fieldVar_.getText()&&
(this.fieldVar_.getOptions(!1),this.fieldVar_.setValue(v),r===v&&this.setFieldValue(v,"VAR"),this.fieldVar_.forceRerender())},renameFree:function(r){var v=da(this.getFieldValue("VAR"));v[0]!==q.Msg.LANG_VARIABLES_GLOBAL_PREFIX&&(v=v[1],r=r.apply(v),r!==v&&this.renameLexicalVar(v,r))},freeVariables:function(){const r=da(this.getFieldValue("VAR"));return r[0]!==q.Msg.LANG_VARIABLES_GLOBAL_PREFIX?new H([r[1]]):new H}};q.Blocks.lexical_variable_set={category:"Variables",helpUrl:q.Msg.LANG_VARIABLES_SET_HELPURL,
init:function(){this.setStyle("variable_blocks");this.fieldVar_=new C(" ");this.appendValueInput("VALUE").appendField(q.Msg.LANG_VARIABLES_SET_TITLE_SET).appendField(this.fieldVar_,"VAR").appendField(q.Msg.LANG_VARIABLES_SET_TITLE_TO);this.setPreviousStatement(!0);this.setNextStatement(!0);this.setTooltip(q.Msg.LANG_VARIABLES_SET_TOOLTIP);this.errors=[{func:I.checkIsInDefinition},{func:I.checkDropDownContainsValidValue,dropDowns:["VAR"]}];this.setOnChange(function(r){this.workspace.getWarningHandler().checkErrors(this)})},
referenceResults:q.Blocks.lexical_variable_get.referenceResults,getDeclaredVars:function(){return[this.getFieldValue("VAR")]},renameLexicalVar:q.Blocks.lexical_variable_get.renameLexicalVar,renameFree:function(r){var v=da(this.getFieldValue("VAR"));if(v[0]!==q.Msg.LANG_VARIABLES_GLOBAL_PREFIX){v=v[1];const A=r.apply(v);A!==v&&this.renameLexicalVar(v,A)}this.getChildren().map(function(A){E.renameFree(A,r)})},freeVariables:function(){var r=this.getChildren().map(function(A){return E.freeVariables(A)});
r=H.unionAll(r);const v=da(this.getFieldValue("VAR"));v[0]!==q.Msg.LANG_VARIABLES_GLOBAL_PREFIX&&r.insert(v[1]);return r}};class Z extends W{constructor(r,v){super(r,!0,v,E.renameGlobal)}}Z.prototype.fieldCSSClassName="blocklyFieldParameter";Z.prototype.flyoutCSSClassName="blocklyFieldParameterFlydown";Z.prototype.flydownBlocksXML_=function(){const r=q.Msg.LANG_VARIABLES_GLOBAL_PREFIX+" "+this.getText();return'<xml><block type="lexical_variable_get"><title name="VAR">'+r+'</title></block><block type="lexical_variable_set"><title name="VAR">'+
r+"</title></block></xml>"};Z.fromJson=function(r){r=q.utils.replaceMessageReferences(r.name);return new Z(r)};q.fieldRegistry.register("field_global_flydown",Z);class ca extends q.FieldDropdown{constructor(...r){super(...r)}}ca.prototype.doClassValidation_=function(r){let v=!1;const A=this.getOptions(!0);for(let D,S=0;D=A[S];S++)if(D[1]===r){v=!0;break}return v||this.generatedOptions.push([r,r]),r};ca.fromJson=function(r){return new ca(r.options,void 0,r)};q.fieldRegistry.register("field_nocheck_dropdown",
ca);class ia extends W{constructor(r,v,A,D){super(r,v,A,function(S){if(!ia.changeHandlerEnabled)return S;S=E.renameParam.call(this,S);return D&&D.call(this,S),S})}referencesVariables(){return!0}}ia.prototype.fieldCSSClassName="blocklyFieldParameter";ia.prototype.flyoutCSSClassName="blocklyFieldParameterFlydown";ia.changeHandlerEnabled=!0;ia.withChangeHanderDisabled=function(r){const v=ia.changeHandlerEnabled;ia.changeHandlerEnabled=!1;try{r()}finally{ia.changeHandlerEnabled=v}};ia.prototype.flydownBlocksXML_=
function(){const r=this.getText();return'<xml><block type="lexical_variable_get"><field name="VAR">'+r+'</field></block><block type="lexical_variable_set"><field name="VAR">'+r+"</field></block></xml>"};ia.addHorizontalVerticalOption=function(r,v){var A=0;if(!(r.getParameters&&(A=r.getParameters().length),r.isCollapsed()||0>=A)){A={enabled:!0,text:r.horizontalParameters?q.Msg.VERTICAL_PARAMETERS:q.Msg.HORIZONTAL_PARAMETERS,callback:function(){r.setParameterOrientation(!r.horizontalParameters)}};var D=
0;for(let S;(S=v[D])&&S.text!=q.Msg.COLLAPSE_BLOCK;D++);v.splice(D,0,A);for(let S,ja=0;S=v[ja];ja++)if(S.text==q.Msg.INLINE_INPUTS){v.splice(ja,1);break}}};ia.fromJson=function(r){const v=q.utils.replaceMessageReferences(r.name);return new ia(v,r.is_editable)};q.fieldRegistry.register("field_parameter_flydown",ia);class Da extends q.FieldTextInput{constructor(r){super(r,ha)}setValue(r){const v=this.getValue();if(this.oldName_=v,this.doValueUpdate_(r),super.setValue(r),!this.getSourceBlock()||!this.getSourceBlock().isInFlyout){if("string"==
typeof(r=this.getValue())&&this.getSourceBlock()){const A=this.getSourceBlock().workspace.getProcedureDatabase();A&&(A.getProcedure(this.getSourceBlock().id)?A.renameProcedure(this.getSourceBlock().id,v,r):A.addProcedure(r,this.getSourceBlock()))}this.oldName_=void 0}}}Da.fromJson=function(r){r=q.utils.replaceMessageReferences(r.name);return new Da(r)};q.fieldRegistry.register("field_procedurename",Da);class la extends q.blockRendering.ExternalValueInput{constructor(r,v){super(r,v);this.connectedBlock?
this.height=this.connectedBlockHeight:this.height=this.constants_.EMPTY_STATEMENT_INPUT_HEIGHT}}class ua extends q.geras.Highlighter{constructor(r){super(r)}drawIndentedInput(r){const v=r.getLastInput();if(this.RTL_){const A=r.height-v.connectionHeight-v.connectionOffsetY;this.steps_+=q.utils.svgPaths.moveTo(v.xPos+this.highlightOffset+v.connectionWidth-1,r.yPos)+q.utils.svgPaths.lineOnAxis("v",v.connectionOffsetY)+this.puzzleTabPaths_.pathDown(this.RTL_)+q.utils.svgPaths.lineOnAxis("v",A)}else this.steps_+=
q.utils.svgPaths.moveTo(v.xPos+v.connectionWidth,r.yPos+v.connectionOffsetY)+this.puzzleTabPaths_.pathDown(this.RTL_)+q.utils.svgPaths.moveTo(v.xPos+v.connectionWidth+1,r.yPos+v.height)}}class va extends q.geras.Drawer{constructor(r,v){super(r,v);this.highlighter_=new ua(v)}drawOutline_(){this.drawTop_();for(let r=1;r<this.info_.rows.length-1;r++){const v=this.info_.rows[r];v.getLastInput()instanceof la?this.drawIndentedInput_(v):v.hasJaggedEdge?this.drawJaggedEdge_(v):v.hasStatement?this.drawStatementInput_(v):
v.hasExternalInput?this.drawValueInput_(v):this.drawRightSideRow_(v)}this.drawBottom_();this.drawLeft_()}drawIndentedInput_(r){const v=r.getLastInput();this.positionIndentedValueConnection_(r);this.highlighter_.drawIndentedInput(r);const A="function"==typeof v.shape.pathDown?v.shape.pathDown(v.height):v.shape.pathDown;this.outlinePath_+=q.utils.svgPaths.lineOnAxis("H",v.xPos+v.connectionWidth)+q.utils.svgPaths.lineOnAxis("v",v.connectionOffsetY)+A+q.utils.svgPaths.lineOnAxis("v",r.height-v.connectionHeight-
v.connectionOffsetY)+q.utils.svgPaths.lineOnAxis("H",v.xPos+v.width)}positionIndentedValueConnection_=function(r){const v=r.getLastInput();if(v.connectionModel){let A=r.xPos+r.statementEdge+r.constants_.TAB_WIDTH;this.info_.RTL&&(A*=-1);v.connectionModel.setOffsetInBlock(A,r.yPos+v.connectionOffsetY)}};}class u extends q.geras.RenderInfo{addInput_(r,v){r instanceof aa?(v.elements.push(new la(this.constants_,r)),v.hasStatement=!0):super.addInput_(r,v)}}class w extends q.geras.Renderer{makeRenderInfo_(r){return new u(this,
r)}makeDrawer_(r,v){return new va(r,v)}}var z={referenceResults:function(r,v,A){const D=this;var S=D.getDeclaredVarFieldNamesAndPrefixes().map(([ra])=>D.getFieldValue(ra));const ja=A.concat(S);S=D.inputList.map(ra=>E.referenceResult(D.getInputTargetBlock(ra.name),r,v,ra.name===D.getScopedInputName()?ja:A));return D.nextConnection&&S.push(E.referenceResult(D.getNextBlock(),r,v,A)),S},withLexicalVarsAndPrefix:function(r,v){const A=this;r&&A.getInputTargetBlock(A.getScopedInputName())===r&&A.getDeclaredVarFieldNamesAndPrefixes().forEach(([D,
S])=>{D=A.getFieldValue(D);v(D,S)})},getDeclaredVars:function(){const r=this;return r.getDeclaredVarFieldNames().map(v=>r.getFieldValue(v))},blocksInScope:function(){const r=this.getInputTargetBlock(this.getScopedInputName());return r&&[r]||[]},declaredNames:function(){return this.getDeclaredVars()},renameVar:function(r,v){if(this.renameVars)this.renameVars(K.simpleSubstitution(r,v));else{const A=this;A.getDeclaredVarFieldNames().forEach(D=>{q.Names.equals(r,A.getFieldValue(D))&&A.setFieldValue(v,
D)})}},renameBound:function(r,v){const A=this;let D=v;if(A.inputList.forEach(S=>{S.name===A.getScopedInputName()?(A.getDeclaredVarFieldNames().forEach(ja=>{ja=A.getFieldValue(ja);const ra=r.apply(ja);ra!==ja?(A.renameVar(ja,ra),ja=K.simpleSubstitution(ja,ra),D=v.extend(ja)):D=v.remove([ja])}),E.renameFree(A.getInputTargetBlock(A.getScopedInputName()),D)):E.renameFree(A.getInputTargetBlock(S.name),v)}),A.nextConnection){const S=A.nextConnection.targetBlock();E.renameFree(S,v)}},renameFree:function(r){const v=
this,A=E.freeVariables(v.getInputTargetBlock(v.getScopedInputName())),D=new K;v.getDeclaredVarFieldNames().forEach(S=>{S=v.getFieldValue(S);A.deleteName(S);var ja=A.renamed(r);ja.isMember(S)&&(ja=C.nameNotIn(S,ja.toList()),S=K.simpleSubstitution(S,ja),D.extend(S))});v.renameBound(D,r)},freeVariables:function(){const r=this,v=E.freeVariables(r.getInputTargetBlock(r.getScopedInputName()));if(r.getDeclaredVarFieldNames().forEach(D=>{v.deleteName(r.getFieldValue(D))}),r.inputList.forEach(D=>{D.name!==
r.getScopedInputName()&&v.unite(E.freeVariables(r.getInputTargetBlock(D.name)))}),r.nextConnection){var A=r.nextConnection.targetBlock();v.unite(E.freeVariables(A))}return v}};const M={...z,getDeclaredVarFieldNamesAndPrefixes:function(){return this.getDeclaredVarFieldNames().map(r=>[r,void 0])}};z={...z,getDeclaredVarFieldNames:function(){return this.getDeclaredVarFieldNamesAndPrefixes().map(([r])=>r)}};q.Extensions.registerMixin("lexical_variable_scope_mixin",M);q.Extensions.registerMixin("prefixed_lexical_variable_scope_mixin",
z);class U{static init(r,v){var A=`.${r.getRenderer().getClassName()}.${r.getTheme().getClassName()}`;t.textContent=`\n  ${A}  .blocklyFieldParameter>rect {\n    fill: rgb(222, 143, 108);\n    fill-opacity: 1.0;\n    stroke-width: 2;\n    stroke: rgb(231, 175, 150);\n  }\n  ${A} .blocklyFieldParameter>text {\n    stroke-width: 1;\n    fill: #000;\n  }\n  ${A} .blocklyFieldParameter:hover>rect {\n    stroke-width: 2;\n    stroke: rgb(231,175,150);\n    fill: rgb(231,175,150);\n    fill-opacity: 1.0;\n  }\n  /*\n   * [lyn, 10/08/13] Control flydown with the getter/setter blocks.\n   */\n  ${A} .blocklyFieldParameterFlydown {\n    fill: rgb(231,175,150);\n    fill-opacity: 0.8;\n  }\n  /*\n   * [lyn, 10/08/13] Control parameter fields with flydown procedure\n   * caller block.\n   */\n  ${A} .blocklyFieldProcedure>rect {\n    fill: rgb(215,203,218);\n    fill-opacity: 1.0;\n    stroke-width: 0;\n    stroke: #000;\n  }\n  ${A} .blocklyFieldProcedure>text {\n    fill: #000;\n  }\n  ${A} .blocklyFieldProcedure:hover>rect {\n    stroke-width: 2;\n    stroke: #fff;\n    fill: rgb(215,203,218);\n    fill-opacity: 1.0;\n  }\n  /*\n   * [lyn, 10/08/13] Control flydown with the procedure caller block.\n   */\n  ${A} .blocklyFieldProcedureFlydown {\n    fill: rgb(215,203,218);\n    fill-opacity: 0.8;\n  }`;
A=new ka(new q.Options({scrollbars:!1,rtl:r.RTL,renderer:r.options.renderer,rendererOverrides:r.options.rendererOverrides,parentWorkspace:r}));r.flydown_=A;q.utils.dom.insertAfter(A.createDom("g"),r.svgBubbleCanvas_);A.init(r);A.autoClose=!0;r.disableInvalidBlocks=v?.disableInvalidBlocks||!1}static Flydown=ka;static FieldFlydown=W;static FieldGlobalFlydown=Z;static FieldParameterFlydown=ia;static lexicalVariableScopeMixin=M;static LexicalVariable=E;static FieldLexicalVariable=C;static FieldProcedureName=Da;static FieldNoCheckDropdown=ca;static NameSet=H;static Shared=p;static Substitution=K;}
q.blockRendering.register("geras2_renderer",w)})(),m})());!function(d,e){if("object"==typeof exports&&"object"==typeof module)module.exports=e(require("blockly/core"));else if("function"==typeof define&&define.amd)define(["blockly/core"],e);else{e="object"==typeof exports?e(require("blockly/core")):e(d.Blockly);for(var h in e)("object"==typeof exports?exports:d)[h]=e[h]}}(this,d=>(()=>{function e(u){var w=p[u];if(void 0!==w)return w.exports;w=p[u]={exports:{}};return m[u](w,w.exports,e),w.exports}function h(){return[new Q,new da,new N,new H,new K]}function k(u){return{blockType:u,
displayText:u}}var m={370:u=>{u.exports=d}},p={};e.d=(u,w)=>{for(var z in w)e.o(w,z)&&!e.o(u,z)&&Object.defineProperty(u,z,{enumerable:!0,get:w[z]})};e.o=(u,w)=>Object.prototype.hasOwnProperty.call(u,w);e.r=u=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(u,Symbol.toStringTag,{value:"Module"});Object.defineProperty(u,"__esModule",{value:!0})};var t={};e.r(t);e.d(t,{TypeBlocking:()=>va});var q=e(370);class y{constructor(u){this.workspace=u}setScopeAnalyzer(u){this.scopeAnalyzer=
u}generateOptions(){const u=[];u.push(...this.getBuiltinBlockOptions());u.push(...this.getVariableOptions());u.push(...this.getProcedureOptions());const w=new Set;return u.filter(z=>{z=`${z.blockType}:${z.displayText}`;return!w.has(z)&&(w.add(z),!0)})}getVariableOptions(){const u=[];var w=this.workspace.getVariablesOfType("");for(var z of w)w=z.name,u.push({blockType:`get ${w}`,displayText:`get ${w}`}),u.push({blockType:`set ${w} to`,displayText:`set ${w} to`});if(this.scopeAnalyzer){z=this.scopeAnalyzer.getLocalVariablesInScope();
console.log("Local variables in scope:",z);for(const M of z)u.push({blockType:`get ${M}`,displayText:`get ${M}`}),u.push({blockType:`set ${M} to`,displayText:`set ${M} to`})}return u}getProcedureOptions(){const u=[];var w=this.workspace.getAllBlocks(!1);for(const z of w)if(("procedures_defnoreturn"===z.type||"procedures_defreturn"===z.type)&&(w=z.getField("NAME"))&&(w=w.getValue())&&w.trim()){u.push({blockType:w,displayText:w});const M=this.getProcedureParameters(z);0<M.length&&(w=`${w}(${M.join(", ")})`,
u.push({blockType:w,displayText:w}))}return u}getBuiltinBlockOptions(){const u=[];for(const w in q.Blocks){const z=q.Blocks[w];this.shouldSkipBlock(w)||(z.typeblock?u.push({blockType:w,displayText:z.typeblock}):this.isValidBuiltinBlock(w)&&u.push({blockType:w,displayText:w.replace(/_/g," ")}))}return u}getProcedureParameters(u){const w=[];u.getVars&&(u=u.getVars(),w.push(...u));return w}shouldSkipBlock(u){return[/^procedures_/,/^variables_get$/,/^variables_set$/,/^_/].some(w=>w.test(u))}isValidBuiltinBlock(u){return q.Blocks[u]}}
class I{constructor(u={}){var w,z,M,U,r,v,A,D;this.patterns=[];this.detectionCache=new Map;this.config={enableNumberDetection:null===(w=u.enableNumberDetection)||void 0===w||w,enableTextDetection:null===(z=u.enableTextDetection)||void 0===z||z,enableBooleanDetection:null===(M=u.enableBooleanDetection)||void 0===M||M,enableMathExpressions:null===(U=u.enableMathExpressions)||void 0===U||U,enableVariableAssignments:null===(r=u.enableVariableAssignments)||void 0===r||r,customPatterns:null!==(v=u.customPatterns)&&
void 0!==v?v:[],patternPriorities:null!==(A=u.patternPriorities)&&void 0!==A?A:{},confidenceThreshold:null!==(D=u.confidenceThreshold)&&void 0!==D?D:.7};this.initializePatterns()}initializePatterns(){this.patterns.push(...this.config.customPatterns);this.sortPatterns()}registerBuiltinPatterns(u){u=u.filter(w=>this.isPatternEnabled(w));u.forEach(w=>{this.config.patternPriorities[w.name]&&(w.priority=this.config.patternPriorities[w.name])});this.patterns.push(...u);this.sortPatterns()}isPatternEnabled(u){switch(u.name){case "number":return this.config.enableNumberDetection;
case "text":return this.config.enableTextDetection;case "boolean":return this.config.enableBooleanDetection;case "math_expression":return this.config.enableMathExpressions;case "variable_assignment":return this.config.enableVariableAssignments;default:return!0}}sortPatterns(){this.patterns.sort((u,w)=>w.priority-u.priority)}detectPattern(u){if(this.detectionCache.has(u))return this.detectionCache.get(u);let w=null;for(const M of this.patterns){var z=u.match(M.pattern);if(z){const U=this.calculateConfidence(M,
z,u);if(U>=this.config.confidenceThreshold){z={pattern:M,match:z,confidence:U};if(.95<=U)return this.detectionCache.set(u,z),z;(!w||U>w.confidence)&&(w=z)}}}return this.detectionCache.set(u,w),w}calculateConfidence(u,w,z){let M=.8;return w[0]===z.trim()&&(M+=.15),u.isComplete&&u.isComplete(z)&&(M+=.05),M+=u.priority/1E3,Math.min(M,1)}getBlockInstructions(u){const w=this.detectPattern(u);if(!w)return null;try{const z=w.pattern.parseInput(w.match);return z&&console.debug(`Generated block instruction using pattern: ${w.pattern.name}`,
{input:u,confidence:w.confidence,blockType:z.blockType}),z}catch(z){return console.error(`Failed to generate instruction using pattern ${w.pattern.name}:`,z),null}}getSuggestions(u){const w=[];for(const M of this.patterns){if(M.generateSuggestions){var z=u.match(M.pattern);z&&(z=M.generateSuggestions(z),w.push(...z.map(U=>({text:U,description:M.description,example:this.getPatternExample(M),patternName:M.name}))))}this.isPartialMatch(u,M)&&w.push({text:this.getPatternExample(M),description:`${M.description} (example)`,
example:this.getPatternExample(M),patternName:M.name})}return w}isPartialMatch(u,w){u=u.trim();if(0===u.length)return!1;const z=' 0 1 true false " )'.split(" ");for(const M of z)if(w.pattern.test(u+M))return!0;return!1}getPatternExample(u){switch(u.name){case "number":return"42";case "text":return'"hello world"';case "boolean":return"true";case "math_expression":return"2 + 3";case "variable_assignment":return"set x to 5";default:return"example"}}isPatternMatch(u){return null!==this.detectPattern(u)}getPatterns(){return[...this.patterns]}clearCache(){this.detectionCache.clear()}updateConfig(u){this.config=
Object.assign(Object.assign({},this.config),u);this.patterns=[];this.clearCache();this.initializePatterns()}}class L{isComplete(u){return this.pattern.test(u.trim())}}class Q extends L{constructor(){super(...arguments);this.name="number";this.pattern=/^-?\d*\.?\d+$/;this.priority=100;this.description="Create number block from numeric input"}parseInput(u){u=u[0];const w=parseFloat(u);return isNaN(w)?null:{blockType:"math_number",fieldValues:{NUM:u}}}generateSuggestions(u){var w=u[0];u=[w];w=parseFloat(w);
return isNaN(w)||u.push(String(w+1),String(w-1),String(10*w),String(Math.abs(w))),u}}class da extends L{constructor(){super(...arguments);this.name="text";this.pattern=/^["'](.*)["']$/;this.priority=95;this.description="Create text block from quoted string"}parseInput(u){return{blockType:"text",fieldValues:{TEXT:u[1]}}}generateSuggestions(u){u=u[1];return[`"${u}"`,`'${u}'`,'"hello world"','"example text"']}}class N extends L{constructor(){super(...arguments);this.name="boolean";this.pattern=/^(true|false)$/i;
this.priority=90;this.description="Create boolean block from true/false"}parseInput(u){return{blockType:"logic_boolean",fieldValues:{BOOL:"true"===u[1].toLowerCase()?"TRUE":"FALSE"}}}generateSuggestions(){return["true","false"]}}class H extends L{constructor(){super(...arguments);this.name="math_expression";this.pattern=/^(\d+(?:\.\d+)?)\s*([+\-*/])\s*(\d+(?:\.\d+)?)$/;this.priority=80;this.description="Create arithmetic block from math expression";this.operatorMap={"+":"ADD","-":"MINUS","*":"MULTIPLY",
"/":"DIVIDE"}}parseInput(u){const [,w,z,M]=u;return this.operatorMap[z]?{blockType:"math_arithmetic",fieldValues:{OP:this.operatorMap[z]},children:[{input:"A",instruction:{blockType:"math_number",fieldValues:{NUM:w}}},{input:"B",instruction:{blockType:"math_number",fieldValues:{NUM:M}}}]}:null}generateSuggestions(u){const [,w,z,M]=u,U=parseFloat(w),r=parseFloat(M);u=[u[0]];for(const v of["+","-","*","/"])v!==z&&u.push(`${w} ${v} ${M}`);return u.push(`${U+1} ${z} ${M}`,`${w} ${z} ${r+1}`,`${10*U} ${z} ${M}`),
u}}class K extends L{constructor(){super(...arguments);this.name="variable_assignment";this.pattern=/^set\s+(\w+)\s+to\s+(.+)$/i;this.priority=85;this.description='Create variable assignment from "set var to value" syntax'}parseInput(u){const [,w,z]=u;return(u=this.parseValueInstruction(z.trim()))?{blockType:"variables_set",fieldValues:{VAR:w},children:[{input:"VALUE",instruction:u}]}:null}parseValueInstruction(u){if(/^-?\d*\.?\d+$/.test(u))return{blockType:"math_number",fieldValues:{NUM:u}};const w=
u.match(/^["'](.*)["']$/);return w?{blockType:"text",fieldValues:{TEXT:w[1]}}:/^(true|false)$/i.test(u)?{blockType:"logic_boolean",fieldValues:{BOOL:"true"===u.toLowerCase()?"TRUE":"FALSE"}}:/^\w+$/.test(u)?{blockType:"variables_get",fieldValues:{VAR:u}}:null}generateSuggestions(u){const [,w,z]=u;return[`set ${w} to ${z}`,`set ${w} to 0`,`set ${w} to "text"`,`set ${w} to true`,"set myVar to 42","set count to 0"]}}class C extends y{constructor(u,w){super(u);this.lastInput="";this.lastSuggestions=[];
this.patternManager=new I(w);this.patternManager.registerBuiltinPatterns(h())}generateOptionsForInput(u){if(u===this.lastInput&&0<this.lastSuggestions.length)return this.lastSuggestions;var w=u.trim(),z=this.generateOptions();const M=this.getPatternSuggestions(w);z=this.filterAndRankOptions(z,w);w=this.combineOptions(M,z,w);return this.lastInput=u,this.lastSuggestions=w,w}getPatternSuggestions(u){if(!u)return[];const w=[];var z=this.patternManager.detectPattern(u);console.debug("SmartOptionGenerator: Pattern detection for",
u,":",z);z&&(w.push(k(u)),console.debug("SmartOptionGenerator: Added pattern input as suggestion:",u));z=this.patternManager.getSuggestions(u);if(console.debug("SmartOptionGenerator: Pattern manager suggestions:",z),w.push(...z.map(U=>k(U.text))),this.isPartialPatternInput(u))u=this.getPatternExamples(u),console.debug("SmartOptionGenerator: Pattern examples:",u),w.push(...u.map(U=>k(U)));console.debug("SmartOptionGenerator: Final pattern suggestions:",w);const M=new Set;return w.filter(U=>{U=`${U.blockType}:${U.displayText}`;
return!M.has(U)&&(M.add(U),!0)})}isPartialPatternInput(u){return 0!==u.length&&[/^\d+$/,/^["']/,/^(true|false)$/i,/^\d+\s*[+\-*/]/,/^set\s+\w*/,/^get\s+/,/^when\s+/].some(w=>w.test(u))}getPatternExamples(u){const w=[];if(/^\d/.test(u)&&w.push("42","3.14",`${u} + 1`,`${u} * 2`),/^["']/.test(u)&&w.push('"hello world"',"'example text'"),/^(t|f)/i.test(u)&&w.push("true","false"),/^set/i.test(u)&&w.push("set x to 5",'set name to "hello"',"set flag to true"),/^get/i.test(u))u=this.workspace.getVariablesOfType(""),
w.push(...u.map(z=>`get ${z.name}`));return w}filterAndRankOptions(u,w){return w?u.map(z=>({option:z,score:this.calculateRelevanceScore(z.displayText,w)})).filter(z=>0<z.score).sort((z,M)=>M.score-z.score).map(z=>z.option):u}calculateRelevanceScore(u,w){const z=u.toLowerCase(),M=w.toLowerCase();let U=0;return z===M?100:(z.startsWith(M)&&(U+=50),z.includes(M)&&(U+=25),U+=this.getContextualBonus(u,w),3>w.length&&20<u.length&&(U-=10),Math.max(0,U))}getContextualBonus(u,w){let z=0;return/^\d/.test(w)&&
/math|number|arithmetic|calculate/.test(u.toLowerCase())&&(z+=15),/^["']/.test(w)&&/text|string|concat|join/.test(u.toLowerCase())&&(z+=15),/^(true|false)/i.test(w)&&/logic|boolean|compare|if/.test(u.toLowerCase())&&(z+=15),/set|get|var/i.test(w)&&/variable|var|get|set/.test(u.toLowerCase())&&(z+=15),z}combineOptions(u,w,z){const M=[],U=new Set;for(const v of u){const A=`${v.blockType}:${v.displayText}`;U.has(A)||(M.push(v),U.add(A))}u=Math.max(10,20-u.length);for(var r of w.slice(0,u))w=`${r.blockType}:${r.displayText}`,
U.has(w)||(M.push(r),U.add(w));if(5>M.length&&3>z.length){z="if;repeat;set variable;math;text;true;false".split(";");for(const v of z)z=k(v),r=`${z.blockType}:${z.displayText}`,!U.has(r)&&10>M.length&&(M.push(z),U.add(r))}return M}setScopeAnalyzer(u){super.setScopeAnalyzer(u)}}class E{constructor(u){this.workspace=u;this._needsReload=!0;this.eventListeners=[];this.setupEventListeners()}get needsReload(){return this._needsReload}invalidate(u){this._needsReload||(console.debug(`TypeBlocking options invalidated: ${u}`),
this._needsReload=!0)}markReloaded(){this._needsReload=!1}dispose(){this.eventListeners.forEach(u=>u());this.eventListeners=[]}setupEventListeners(){this.addEventHandler(q.Events.VAR_CREATE,"variable created");this.addEventHandler(q.Events.VAR_DELETE,"variable deleted");this.addEventHandler(q.Events.VAR_RENAME,"variable renamed");this.addEventHandler(q.Events.BLOCK_CREATE,u=>{this.handleBlockEvent(u)});this.addEventHandler(q.Events.BLOCK_DELETE,u=>{this.handleBlockEvent(u)});this.addEventHandler(q.Events.BLOCK_CHANGE,
u=>{this.handleBlockChangeEvent(u)});this.addEventHandler(q.Events.FINISHED_LOADING,"workspace loaded");this.addWorkspaceChangeListener()}addEventHandler(u,w){const z=M=>{M.workspaceId===this.workspace.id&&("string"==typeof w?this.invalidate(w):w(M))};this.workspace.addChangeListener(z);this.eventListeners.push(()=>{this.workspace.removeChangeListener(z)})}handleBlockEvent(u){(u=u.type)&&this.isProcedureBlock(u)&&this.invalidate(`procedure block ${u}`)}handleBlockChangeEvent(u){const w=this.workspace.getBlockById(u.blockId);
w&&this.isProcedureBlock(w.type)&&"field"===u.element&&"NAME"===u.name&&this.invalidate(`procedure name changed from ${u.oldValue} to ${u.newValue}`)}addWorkspaceChangeListener(){let u=null;const w=z=>{z.workspaceId===this.workspace.id&&(u&&clearTimeout(u),u=setTimeout(()=>{this.shouldInvalidateForGeneralChange(z)&&this.invalidate("workspace change");u=null},100))};this.workspace.addChangeListener(w);this.eventListeners.push(()=>{this.workspace.removeChangeListener(w);u&&clearTimeout(u)})}isProcedureBlock(u){return"procedures_defnoreturn"===
u||"procedures_defreturn"===u||"procedures_callnoreturn"===u||"procedures_callreturn"===u}shouldInvalidateForGeneralChange(u){return!["selected","click","theme_change","viewport_change"].includes(u.type)}}class F{constructor(u){this.workspace=u}getLocalVariablesInScope(){const u=this.getLocalVariablesFromSelection();return 0<u.length?(console.log("Using selection context for local variables:",u),u):(console.log("No selection context available, falling back to all procedure parameters."),this.getAllProcedureParameters())}getLocalVariablesFromSelection(){const u=
this.getEnclosingProcedureFromSelection();return u?this.getProcedureParameters(u):[]}getAllProcedureParameters(){const u=[],w=this.workspace.getAllBlocks(!1);for(const z of w)this.isProcedureDefinition(z)&&u.push(...this.getProcedureParameters(z));return[...(new Set(u))]}getEnclosingProcedureFromSelection(){const u=q.common.getSelected();return u&&u instanceof q.BlockSvg?this.findEnclosingProcedure(u):null}findEnclosingProcedure(u){for(;u;)if(this.isProcedureDefinition(u)||(u=u.getParent())&&this.isProcedureDefinition(u))return u;
return null}getProcedureParameters(u){const w=[];if(this.isProcedureDefinition(u)){if(u.getVars){const z=u.getVars();Array.isArray(z)&&w.push(...z)}u=u.inputList;for(const z of u)for(const M of z.fieldRow)M.name&&M.name.startsWith("ARG")&&(u=M.getValue())&&"string"==typeof u&&u.trim()&&w.push(u.trim())}return w}isProcedureDefinition(u){return"procedures_defnoreturn"===u.type||"procedures_defreturn"===u.type}}const P=(u,w)=>{const z=w.trim().toLowerCase();return z?u.filter(M=>M.displayText.toLowerCase().includes(z)):
u};class ha{constructor(u,w=""){this.highlighted=-1;this.suggestions=[];this.root=document.createElement("div");this.root.innerHTML='\n      <input type="text" spellcheck="false" class="fi-input" />\n      <ul class="fi-list" hidden></ul>\n    ';this.input=this.root.querySelector(".fi-input");this.list=this.root.querySelector(".fi-list");this.input.value=w;this.list.addEventListener("mousemove",z=>{if(z=z.target.closest("li"))z=parseInt(z.dataset.idx,10),z!==this.highlighted&&this.updateHighlight(z)});
this.list.addEventListener("mousedown",z=>{z.preventDefault();if(z=z.target.closest("li"))z=parseInt(z.dataset.idx,10),u(this.suggestions[z])})}focus(){this.input.focus();const u=this.input.value.length;this.input.setSelectionRange(u,u)}setSuggestions(u){this.suggestions=u;this.list.innerHTML="";u.forEach((w,z)=>{const M=document.createElement("li");M.dataset.idx=z.toString();M.textContent=w.displayText;this.list.appendChild(M)});0<u.length?this.updateHighlight(0):this.highlighted=-1;this.list.hidden=
0===u.length}onKey(u,w){const z=()=>0<=this.highlighted&&this.highlighted<this.suggestions.length&&(w(this.suggestions[this.highlighted]),!0);switch(u){case "ArrowDown":return this.updateHighlight(Math.min(this.highlighted+1,this.suggestions.length-1)),!0;case "ArrowUp":return this.updateHighlight(Math.max(this.highlighted-1,0)),!0;case "Enter":case "Tab":return z();default:return!1}}get query(){return this.input.value}get inputEl(){return this.input}updateHighlight(u){const w=Array.from(this.list.children);
0<=this.highlighted&&w[this.highlighted].classList.remove("fi-hl");this.highlighted=u;0<=this.highlighted&&(w[this.highlighted].classList.add("fi-hl"),w[this.highlighted].scrollIntoView({block:"nearest"}))}}class ea{constructor(u){this.workspace=u}createBlock(u,w,z){var M=this.createSpecialBlock(u);if(M)return M;M=u;if(!q.Blocks[M])for(const U in q.Blocks)if(q.Blocks[U].typeblock===u){M=U;break}if(!q.Blocks[M])return void console.warn(`No block registered for "${u}"`);u={type:M};if(w&&(u.extraState=
w),z){u.fields={};for(const [U,r]of Object.entries(z))u.fields[U]=r}return q.serialization.blocks.append(u,this.workspace,{recordUndo:!0})}createBlockFromInstruction(u){try{const w=this.workspace.newBlock(u.blockType);if(u.fieldValues)for(const [z,M]of Object.entries(u.fieldValues)){const U=w.getField(z);if(U)if("VAR"!==z||"variables_set"!==w.type&&"variables_get"!==w.type)U.setValue(M);else{let r=this.workspace.getVariable(M);r||=this.workspace.createVariable(M);U.setValue(r.getId())}}if(w.initSvg(),
w.render(),u.children)for(const z of u.children){const M=this.createBlockFromInstruction(z.instruction);if(M){const U=w.getInput(z.input);U&&M.outputConnection&&M.outputConnection.connect(U.connection)}}return w}catch(w){return void console.warn("Failed to create block from instruction:",w)}}createSpecialBlock(u){var w=u.match(/^get\s+(.+)$/);return w?this.createVariableGetter(w[1]):(w=u.match(/^set\s+(.+?)\s+to$/))?this.createVariableSetter(w[1]):(u=u.match(/^([^(]+)(?:\([^)]*\))?$/))&&this.isProcedureName(u[1].trim())?
this.createProcedureCall(u[1].trim()):void 0}createVariableGetter(u){var w;const z=this.workspace.getVariable(u);if(!z)return void console.warn(`Variable "${u}" not found`);u=this.workspace.newBlock("variables_get");return null===(w=u.getField("VAR"))||void 0===w||w.setValue(z.getId()),u.initSvg(),u.render(),u}createVariableSetter(u){var w;const z=this.workspace.getVariable(u);if(!z)return void console.warn(`Variable "${u}" not found`);u=this.workspace.newBlock("variables_set");return null===(w=u.getField("VAR"))||
void 0===w||w.setValue(z.getId()),u.initSvg(),u.render(),u}createProcedureCall(u){var w,z;const M=this.workspace.getAllBlocks(!1);let U=!1;for(const r of M)if(("procedures_defnoreturn"===r.type||"procedures_defreturn"===r.type)&&(null===(w=r.getField("NAME"))||void 0===w?void 0:w.getValue())===u){U="procedures_defreturn"===r.type;break}w=this.workspace.newBlock(U?"procedures_callreturn":"procedures_callnoreturn");return null===(z=w.getField("NAME"))||void 0===z||z.setValue(u),w.initSvg(),w.render(),
w}isProcedureName(u){var w;const z=this.workspace.getAllBlocks(!1);for(const M of z)if(("procedures_defnoreturn"===M.type||"procedures_defreturn"===M.type)&&(null===(w=M.getField("NAME"))||void 0===w?void 0:w.getValue())===u)return!0;return!1}}class aa{constructor(u){this.workspace=u;this.offsetCount=0}positionBlock(u,w,z){var M=this.workspace.getMetrics(),U=this.workspace.getInjectionDiv().getBoundingClientRect();w=null!=w?w:U.left+U.width/2;const r=null!=z?z:U.top+U.height/2;z=(w-U.left)/this.workspace.scale+
M.viewLeft;M=(r-U.top)/this.workspace.scale+M.viewTop;this.lastCreationX===w&&this.lastCreationY===r?(this.offsetCount++,U=this.offsetCount*aa.OFFSET_STEP/this.workspace.scale,z+=U,M+=U):(this.offsetCount=0,this.lastCreationX=w,this.lastCreationY=r);u.moveBy(z,M)}}aa.OFFSET_STEP=30;class W{areTypesCompatible(u,w){if(!u||!w)return!1;u=u.getCheck();const z=w.getCheck();return!u||!z||u.some(M=>z.includes(M))}isConnectionAvailable(u){return u&&!u.isConnected()}getWorkspaceScale(u){return u.scale||1}calculateDistance(u,
w){const z=u.x-w.x;u=u.y-w.y;return Math.sqrt(z*z+u*u)}}class ka extends W{constructor(){super(...arguments);this.priority=90;this.name="StatementSequence"}canConnect(u,w){u=u.previousConnection;if(!u)return!1;w=w.nextConnection;return!(!w||w.isConnected())&&this.areTypesCompatible(u,w)}connect(u,w){const z=u.previousConnection,M=w.nextConnection;if(!this.canConnect(u,w))return{success:!1,reason:"Blocks not compatible for statement sequence connection"};try{return z.connect(M),{success:!0,connectionType:"statement_sequence",
targetConnection:M}}catch(U){return{success:!1,reason:`Connection failed: ${U}`}}}}class Z extends W{constructor(){super(...arguments);this.priority=80;this.name="ValueInput"}canConnect(u,w){return!!u.outputConnection&&null!==this.findCompatibleInput(u,w)}connect(u,w){const z=u.outputConnection;if(!z)return{success:!1,reason:"New block has no output connection"};u=this.findCompatibleInput(u,w);if(!u)return{success:!1,reason:"No compatible input connection found"};try{return z.connect(u),{success:!0,
connectionType:"value_input",targetConnection:u}}catch(M){return{success:!1,reason:`Connection failed: ${M}`}}}findCompatibleInput(u,w){u=u.outputConnection;if(!u)return null;for(const z of w.inputList)if(z.connection&&this.isConnectionAvailable(z.connection)&&this.areTypesCompatible(u,z.connection))return z.connection;return null}}class ca extends W{constructor(){super(...arguments);this.priority=70;this.name="StatementInsertion"}canConnect(u,w){const z=u.nextConnection;u=u.previousConnection;if(!z||
!u)return!1;w=w.previousConnection;return!!w&&this.areTypesCompatible(z,w)&&this.areTypesCompatible(u,w)}connect(u,w){const z=u.nextConnection,M=u.previousConnection,U=w.previousConnection;if(!this.canConnect(u,w))return{success:!1,reason:"Blocks not compatible for statement insertion"};try{const r=U.targetConnection;return r&&(U.disconnect(),M.connect(r)),z.connect(U),{success:!0,connectionType:"statement_insertion",targetConnection:U}}catch(r){return{success:!1,reason:`Connection failed: ${r}`}}}}
class ia extends W{constructor(){super(...arguments);this.priority=60;this.name="Wrapper"}canConnect(u,w){u=this.getStatementInputs(u);if(0===u.length)return!1;w=w.previousConnection;return!!w&&this.areTypesCompatible(w,u[0])}connect(u,w){const z=this.getStatementInputs(u),M=w.previousConnection;if(!this.canConnect(u,w))return{success:!1,reason:"Blocks not compatible for wrapping"};try{const U=M.targetConnection;if(U){M.disconnect();const r=u.previousConnection;r&&this.areTypesCompatible(r,U)&&r.connect(U)}return M.connect(z[0]),
{success:!0,connectionType:"wrapper",targetConnection:z[0]}}catch(U){return{success:!1,reason:`Connection failed: ${U}`}}}getStatementInputs(u){const w=[];for(const z of u.inputList)z.type===q.inputs.inputTypes.STATEMENT&&z.connection&&w.push(z.connection);return w}}class Da{constructor(u,w={}){var z,M,U,r;this.workspace=u;this.config={enableAutoConnection:null===(z=w.enableAutoConnection)||void 0===z||z,connectionRadius:null!==(M=w.connectionRadius)&&void 0!==M?M:200,maxNearbyBlocks:null!==(U=w.maxNearbyBlocks)&&
void 0!==U?U:10,strategies:null!==(r=w.strategies)&&void 0!==r?r:this.getDefaultStrategies()};this.connectionStrategies=this.config.strategies.sort((v,A)=>A.priority-v.priority)}getDefaultStrategies(){return[new ka,new Z,new ca,new ia]}attemptConnection(u,w,z,M){if(!this.config.enableAutoConnection)return null;w=this.buildConnectionContext(u,w,z,M);return this.findAndMakeConnection(u,w)}buildConnectionContext(u,w,z,M){M=Object.assign({},M);if(!M.selectedBlock){const U=q.common.getSelected();U&&U instanceof
q.BlockSvg&&(M.selectedBlock=U)}return void 0!==w&&void 0!==z&&(M.cursorPosition={x:w,y:z}),M.nearbyBlocks||(M.nearbyBlocks=this.findNearbyBlocks(u,M.cursorPosition)),M}findAndMakeConnection(u,w){var z=this.getPriorizedTargetBlocks(u,w);for(const M of z)for(const U of this.connectionStrategies)if(U.canConnect(u,M,w)){console.debug(`Attempting connection with strategy: ${U.name}`);z=U.connect(u,M,w);if(z.success)return console.debug(`Successfully connected using strategy: ${U.name}`),z;console.debug(`Connection failed with strategy ${U.name}: ${z.reason}`)}return console.debug("No suitable connection found for new block"),
null}getPriorizedTargetBlocks(u,w){const z=[];if(w.selectedBlock&&z.push(w.selectedBlock),w.nearbyBlocks){const M=w.nearbyBlocks.filter(U=>U!==w.selectedBlock).sort((U,r)=>{var v=this.connectionStrategies.find(D=>"ValueInput"===D.name);if(!v)return 0;const A=v.canConnect(u,U,w);v=v.canConnect(u,r,w);return A&&!v?-1:!A&&v?1:A&&v&&(U=this.countConnectedInputs(U),r=this.countConnectedInputs(r),U!==r)?U-r:0});z.push(...M)}return[...(new Set(z))]}findNearbyBlocks(u,w){var z=u.getRelativeToSurfaceXY();
w=w?this.clientToWorkspaceCoordinates(w.x,w.y):z;var M=this.workspace.getAllBlocks(!1);z=[];for(const U of M)U!==u&&(M=U.getRelativeToSurfaceXY(),M=this.calculateDistance(w,M),M<=this.config.connectionRadius&&z.push({block:U,distance:M}));return z.sort((U,r)=>U.distance-r.distance),z.slice(0,this.config.maxNearbyBlocks).map(U=>U.block)}clientToWorkspaceCoordinates(u,w){const z=this.workspace.getMetrics(),M=this.workspace.getInjectionDiv().getBoundingClientRect();return{x:(u-M.left)/this.workspace.scale+
z.viewLeft,y:(w-M.top)/this.workspace.scale+z.viewTop}}calculateDistance(u,w){const z=u.x-w.x;u=u.y-w.y;return Math.sqrt(z*z+u*u)}getBlockDistance(u,w){u=u.getRelativeToSurfaceXY();w=w.cursorPosition?this.clientToWorkspaceCoordinates(w.cursorPosition.x,w.cursorPosition.y):u;return this.calculateDistance(w,u)}hasAvailableInputConnections(u){for(const w of u.inputList)if(w.connection&&!w.connection.isConnected())return!0;return!1}countConnectedInputs(u){let w=0;for(const z of u.inputList)z.connection&&
z.connection.isConnected()&&w++;return w}setConfig(u){this.config=Object.assign(Object.assign({},this.config),u);u.strategies&&(this.connectionStrategies=u.strategies.sort((w,z)=>z.priority-w.priority))}getConfig(){return Object.assign({},this.config)}}class la{constructor(u,w){var z,M,U,r,v;this.ws=u;this.lastY=this.lastX=0;this.pointerMoveListener=A=>{this.lastX=A.x;this.lastY=A.y};this.ws=u;this.options=w.options;this.matcher=null!==(z=w.matcher)&&void 0!==z?z:P;this.optionGenerator=w.optionGenerator;
this.inputPositioning={mode:null!==(U=null===(M=w.inputPositioning)||void 0===M?void 0:M.mode)&&void 0!==U?U:"mouse",fixedPosition:null!==(v=null===(r=w.inputPositioning)||void 0===r?void 0:r.fixedPosition)&&void 0!==v?v:{x:100,y:10}};this.blockFactory=new ea(u);this.blockPositioner=new aa(u);!1!==w.enablePatternRecognition&&(this.patternManager=new I(w.patternConfig),this.patternManager.registerBuiltinPatterns(h()));!1!==w.enableSmartConnection&&(this.connectionManager=new Da(u,w.connectionConfig));
u.getInjectionDiv().addEventListener("pointermove",this.pointerMoveListener)}dispose(){this.ws.getInjectionDiv().removeEventListener("pointermove",this.pointerMoveListener)}show(u=""){q.WidgetDiv.show({},this.ws.RTL,()=>this.ws.getInjectionDiv().focus(),this.ws);const w=new ha(z=>this.choose(z),u);q.WidgetDiv.getDiv().appendChild(w.root);this.positionWidgetDiv();u=()=>{var z=this.options;this.optionGenerator instanceof C?(console.debug("TypeBlocking: Using smart option generation for query:",w.query),
z=this.optionGenerator.generateOptionsForInput(w.query),console.debug("TypeBlocking: Generated",z.length,"options:",z.slice(0,5))):console.debug("TypeBlocking: Using static options, generator type:",typeof this.optionGenerator);z=this.matcher(z,w.query);console.debug("TypeBlocking: After matching, got",z.length,"options:",z.slice(0,5));w.setSuggestions(z)};w.inputEl.addEventListener("input",u);u();w.inputEl.addEventListener("keydown",z=>{w.onKey(z.key,M=>this.choose(M))?z.preventDefault():"Escape"===
z.key&&q.WidgetDiv.hide();z.stopPropagation()});w.inputEl.addEventListener("blur",()=>q.WidgetDiv.hide());setTimeout(()=>w.focus())}choose(u){let w;console.debug("TypeBlocking: Choosing option:",u);q.Events.setGroup(!0);try{if(this.patternManager){console.debug("TypeBlocking: Trying pattern recognition for:",u.blockType);const z=this.patternManager.getBlockInstructions(u.blockType);z&&(console.debug("TypeBlocking: Found pattern instruction:",z),w=this.blockFactory.createBlockFromInstruction(z),w&&
console.debug("TypeBlocking: Created block using pattern recognition:",w.type))}w||(console.debug("TypeBlocking: Falling back to regular block creation"),w=this.blockFactory.createBlock(u.blockType,u.extraState,u.fieldValues),w&&console.debug("TypeBlocking: Created block using regular method:",w.type));w?(this.blockPositioner.positionBlock(w,this.lastX,this.lastY),this.connectionManager&&this.connectionManager.attemptConnection(w,this.lastX,this.lastY),q.common.setSelected(w)):console.warn("TypeBlocking: Failed to create block for option:",
u)}finally{q.Events.setGroup(!1)}q.WidgetDiv.hide()}positionWidgetDiv(){const u=q.WidgetDiv.getDiv();let w;if("fixed"===this.inputPositioning.mode){var z=this.ws.getInjectionDiv().getBoundingClientRect();w=z.left+this.inputPositioning.fixedPosition.x;z=z.top+this.inputPositioning.fixedPosition.y}else(w=this.lastX,z=this.lastY,w||z)||(z=this.ws.getInjectionDiv().getBoundingClientRect(),w=z.left+z.width/2,z=z.top+z.height/2);Object.assign(u.style,{position:"fixed",left:`${w}px`,top:`${z}px`})}}class ua extends la{constructor(u,
w){var z;super(u,{options:w.options,matcher:null!==(z=w.matcher)&&void 0!==z?z:P,enableSmartConnection:w.enableSmartConnection,connectionConfig:w.connectionConfig,enablePatternRecognition:w.enablePatternRecognition,patternConfig:w.patternConfig,optionGenerator:w.optionGenerator,inputPositioning:w.inputPositioning});this.staticOptions=w.options;this.dynamicOptionGenerator=w.optionGenerator;this.stateTracker=w.stateTracker}getCurrentOptions(){return this.dynamicOptionGenerator&&this.stateTracker?(!this.stateTracker.needsReload&&
this.cachedOptions||this.lazyLoadOptions(),this.cachedOptions||this.staticOptions):this.staticOptions}lazyLoadOptions(){if(this.dynamicOptionGenerator&&this.stateTracker){console.debug("TypeBlocking: Regenerating options...");var u=performance.now();try{this.cachedOptions=this.dynamicOptionGenerator.generateOptions();"markReloaded"in this.stateTracker&&this.stateTracker.markReloaded();const w=performance.now()-u;console.debug(`TypeBlocking: Generated ${this.cachedOptions.length} options in ${w.toFixed(2)}ms`)}catch(w){console.error("TypeBlocking: Error generating options:",
w),this.cachedOptions=this.staticOptions}}}show(u=""){this.options=this.getCurrentOptions();super.show(u)}dispose(){this.stateTracker=this.dynamicOptionGenerator=this.cachedOptions=void 0;super.dispose()}}class va{constructor(u){this.workspace=u}init(u={}){const w=!1!==u.enableDynamicOptions;console.log("what am I enabling?",w);w?this.setupDynamicOptions(u):this.setupStaticOptions(u);console.info("Typeblocking initialized on workspace:",this.workspace.id)}setupDynamicOptions(u){var w;if(!1!==u.enablePatternRecognition?
this.optionGenerator=u.optionGenerator||new C(this.workspace,u.patternConfig):this.optionGenerator=u.optionGenerator||new y(this.workspace),this.optionGenerator instanceof y){const z=new F(this.workspace);this.optionGenerator.setScopeAnalyzer(z)}this.stateTracker=null!==(w=u.workspaceStateTracker)&&void 0!==w?w:new E(this.workspace);this.installFloatingInput({options:[],matcher:u.matcher,enableSmartConnection:u.enableSmartConnection,connectionConfig:u.connectionConfig,enablePatternRecognition:u.enablePatternRecognition,
patternConfig:u.patternConfig,inputPositioning:u.inputPositioning})}setupStaticOptions(u){const w=u.options||this.generateLegacyOptions();this.installFloatingInput({options:w,matcher:u.matcher,enableSmartConnection:u.enableSmartConnection,connectionConfig:u.connectionConfig,enablePatternRecognition:u.enablePatternRecognition,patternConfig:u.patternConfig,inputPositioning:u.inputPositioning})}generateLegacyOptions(){const u=[];q.Blocks.controls_if.typeblock=q.Msg.CONTROLS_IF_MSG_IF;for(const w in q.Blocks)1<
w.split("_").length&&(q.Blocks[w].typeblock||(q.Blocks[w].typeblock=w),u.push(q.Blocks[w].typeblock));return u}dispose(){if(this.workspace){var u=this.workspace.id;va.instancesByWorkspaceId.delete(u);this.stateTracker&&(this.stateTracker.dispose(),this.stateTracker=void 0);this.controller&&(this.controller.dispose(),this.controller=void 0);va.instancesByWorkspaceId.size||q.ShortcutRegistry.registry.unregister("floatInput");q.DropDownDiv.hideWithoutAnimation();this.optionGenerator=void 0;this.workspace=
null;console.info(`Typeblocking disposed from workspace ${u}`)}}installFloatingInput({options:u=[],matcher:w,enableSmartConnection:z,connectionConfig:M,enablePatternRecognition:U,patternConfig:r,inputPositioning:v}){if(this.controller=new ua(this.workspace,{options:u,matcher:w,optionGenerator:this.optionGenerator,stateTracker:this.stateTracker,enableSmartConnection:z,connectionConfig:M,enablePatternRecognition:U,patternConfig:r,inputPositioning:v}),va.instancesByWorkspaceId.set(this.workspace.id,
this),!q.ShortcutRegistry.registry.getRegistry().floatInput)for(q.ShortcutRegistry.registry.register({name:"floatInput",preconditionFn:A=>va.instancesByWorkspaceId.has(A.id)&&!q.FieldTextInput.activeField&&!q.WidgetDiv.isVisible(),callback:(A,D)=>(va.instancesByWorkspaceId.get(A.id).controller.show(1!==D.key.length||D.ctrlKey||D.metaKey||D.altKey?"":D.key),!0)},!0),u=new Set([8,9,13,16,17,18,19,20,27,33,34,35,36,37,38,39,40,45,46,91,112,113,114,115,116,117,118,119,120,121,122,123]),w=0;222>=w;++w)u.has(w)||
(q.ShortcutRegistry.registry.addKeyMapping(w,"floatInput",!0),q.ShortcutRegistry.registry.addKeyMapping(q.ShortcutRegistry.registry.createSerializedKey(w,[q.utils.KeyCodes.SHIFT]),"floatInput",!0))}}return va.instancesByWorkspaceId=new Map,t})());top.Blockly=Blockly;top.LexicalVariablesPlugin=LexicalVariablesPlugin;Object.keys(top.AI2.Msg).forEach(function(d){Blockly.Msg[d]=top.AI2.Msg[d]});/*

 @fileoverview Visual blocks editor for MIT App Inventor
 Color definitions for blocks

 @author mckinney@mit.edu (Andrew F. McKinney)
 @author ewpatton@mit.edu (Evan W. Patton)
*/
Blockly.utils.colour.setHsvSaturation(.7);Blockly.CONTROL_CATEGORY_HUE="#B18E35";Blockly.LOGIC_CATEGORY_HUE="#77AB41";Blockly.MATH_CATEGORY_HUE="#3F71B5";Blockly.TEXT_CATEGORY_HUE="#B32D5E";Blockly.LIST_CATEGORY_HUE="#49A6D4";Blockly.COLOR_CATEGORY_HUE="#7D7D7D";Blockly.VARIABLE_CATEGORY_HUE="#D05F2D";Blockly.PROCEDURE_CATEGORY_HUE="#7C5385";Blockly.DICTIONARY_CATEGORY_HUE="#2D1799";Blockly.MATRIX_CATEGORY_HUE="#008B8B";/*

 @fileoverview Visual blocks editor for App Inventor
 Methods to export blocks as a PNG from the block editor.

 @author shrutirijhwani@gmail.com (Shruti Rijhwani)
*/
var AI={Blockly:{}};AI.Blockly.ExportBlocksImage={};
(function(){var d="undefined"!=typeof exports&&exports||this;d.svgAsDataUri=function(e,h,k,m){k=k||{};k.scale=k.scale||1;for(var p=document.createElement("div"),t=document.getElementsByTagName("textarea"),q=0;q<t.length;q++)t[q].innerHTML=t[q].value;t=e.cloneNode(!0);if("svg"==e.tagName){var y=e.getBoundingClientRect();q=y.width||parseInt(t.getAttribute("width")||t.style.width||d.getComputedStyle(e).getPropertyValue("width"));var I=y.height||parseInt(t.getAttribute("height")||t.style.height||d.getComputedStyle(e).getPropertyValue("height"));
y=(parseFloat(h.contentLeft)-parseFloat(h.viewLeft)).toString();var L=(parseFloat(h.contentTop)-parseFloat(h.viewTop)).toString(),Q=parseFloat(h.contentWidth).toString();h=parseFloat(h.contentHeight).toString();t.setAttribute("viewBox",y+" "+L+" "+Q+" "+h)}else e.getScreenCTM(),t.setAttribute("transform",t.getAttribute("transform").replace(/translate\(.*?\)/,"").replace(/scale\(.*?\)/,"").trim()),y=e.getBBox(),q=y.width,I=y.height,h=document.createElementNS("http://www.w3.org/2000/svg","svg"),h.setAttribute("xmlns",
"http://www.w3.org/2000/svg"),h.appendChild(t),t=h,t.setAttribute("viewBox",y.x+" "+y.y+" "+q+" "+I);t.setAttribute("version","1.1");t.setAttribute("width",q);t.setAttribute("height",I);t.setAttribute("style","background-color: rgba(255, 255, 255, 0);");t.setAttribute("class","geras2_renderer-renderer classic-theme");p.appendChild(t);k=k.selectorRemap;h="";q=document.styleSheets;for(I=0;I<q.length;I++)if((y=q[I].href)&&0==y.lastIndexOf("http",0)&&-1==y.lastIndexOf(window.location.host))console.warn("Cannot include styles from other hosts: "+
q[I].href);else{y=null;try{y=q[I].cssRules}catch(N){console.warn("Skipping a potentially injected stylesheet",N);continue}if(null!=y)for(L=0;L<y.length;L++)if(Q=y[L],"undefined"!=typeof Q.style){var da=null;try{da=e.querySelector(Q.selectorText)}catch(N){console.warn('Invalid CSS selector "'+Q.selectorText+'"',N)}da&&-1==Q.selectorText.indexOf("blocklySelected")?(da=k?k(Q.selectorText):Q.selectorText,h+=da+" { "+Q.style.cssText+" }\n"):Q.cssText.match(/^@font-face/)&&(h+=Q.cssText+"\n")}}k=h;e=document.createElement("style");
e.setAttribute("type","text/css");e.innerHTML="<![CDATA[\n"+k+"\n]]\x3e";k=document.createElement("defs");k.appendChild(e);t.insertBefore(k,t.firstChild);e=t.getElementsByClassName("blocklyScrollbarHandle");for(q=0;q<e.length;q++)e[q].setAttribute("visibility","hidden");e=t.getElementsByClassName("blocklyScrollbarBackground");for(q=0;q<e.length;q++)e[q].setAttribute("visibility","hidden");e=t.querySelectorAll("image");for(q=0;q<e.length;q++)e[q].setAttribute("visibility","hidden");e=t.querySelectorAll(".blocklyMainBackground");
for(q=0;q<e.length;q++)e[q].parentElement.removeChild(e[q]);(e=t.getElementById("rectCorner"))&&e.setAttribute("visibility","hidden");(e=t.getElementById("indicatorWarning"))&&e.setAttribute("visibility","hidden");h='<?xml version="1.0" standalone="no"?><!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">'+p.innerHTML;h=h.replace(/&nbsp/g,"&#160");h=h.replace(/sans-serif/g,'Arial, Verdana, "Nimbus Sans L", Helvetica');p="data:image/svg+xml;base64,"+window.btoa(unescape(encodeURIComponent(h)));
m&&m(p)};d.saveSvgAsPng=function(e,h,k,m){m=m||{};d.svgAsDataUri(e,k,m,function(p){var t=new Image;t.src=p;t.onload=function(){var q=document.createElement("canvas");q.width=t.width;q.height=t.height;q.getContext("2d").drawImage(t,0,0);var y=document.createElement("a");y.download=h;y.target="_self";void 0===q.toBlob?(q=q.toDataURL("image/png"),y.href=q,document.body.appendChild(y),y.addEventListener("click",function(I){y.parentNode.removeChild(y)}),y.click()):q.toBlob(function(I){y.href=URL.createObjectURL(I);
document.body.appendChild(y);y.addEventListener("click",function(L){y.parentNode.removeChild(y)});y.click()})};t.onerror=function(q){console.log("Error",q)}})}})();AI.Blockly.ExportBlocksImage.onclickExportBlocks=function(d,e){saveSvgAsPng((e||Blockly.common.getMainWorkspace()).svgBlockCanvas_,"blocks.png",d)};
AI.Blockly.ExportBlocksImage.getUri=function(d,e){var h;e=e||Blockly.common.getMainWorkspace();var k=e.getMetrics();if(null==k||0==k.viewHeight)return null;svgAsDataUri(e.svgBlockCanvas_,k,{},function(m){var p=new Image;p.onload=function(){var t=document.createElement("canvas");t.width=p.width;t.height=p.height;t.getContext("2d").drawImage(p,0,0);try{h=t.toDataURL("image/png")}catch(q){console.warn("Error performing canvas.toDataURL");d("");return}d(h)};p.src=m})};
function makeCRCTable(){for(var d,e=[],h=0;256>h;h++){d=h;for(var k=0;8>k;k++)d=d&1?3988292384^d>>>1:d>>>1;e[h]=d}return e}function crc32(d){for(var e=window.crcTable||(window.crcTable=makeCRCTable()),h=-1,k=0;k<d.length;k++)h=h>>>8^e[(h^d[k])&255];return(h^-1)>>>0}var CODE_PNG_CHUNK="coDe";function PNG(){this.chunks=null}PNG.HEADER=[137,80,78,71,13,10,26,10];var pHY_data=[0,0,22,37,0,0,22,37,1];PNG.Chunk=function(d,e,h,k){this.length=d;this.type=e;this.data=h;this.crc=k};
PNG.prototype.readFromBlob=function(d,e){var h=new FileReader,k=this;h.addEventListener("loadend",function(){k.processData_(new Uint8Array(h.result));e instanceof Function&&e(k)});h.readAsArrayBuffer(d)};PNG.prototype.getCodeChunk=function(){if(!this.chunks)return null;for(var d=0;d<this.chunks.length;d++)if(this.chunks[d].type===CODE_PNG_CHUNK)return this.chunks[d];return null};
PNG.prototype.processData_=function(d){function e(){var y=d[k++];y=256*y+d[k++];y=256*y+d[k++];return y=256*y+d[k++]}function h(){for(var y="",I=0;4>I;I++,k++)y+=String.fromCharCode(d[k]);return y}var k=PNG.HEADER.length;for(this.chunks=[];k<d.length;){var m=e(),p=h(),t=d.slice(k,k+m);k+=m;var q=e();this.chunks.push(new PNG.Chunk(m,p,t,q))}};
PNG.prototype.setCodeChunk=function(d){d=(new TextEncoder).encode(CODE_PNG_CHUNK+d);var e=d.length-4,h=crc32(d);d=d.slice(4);for(var k=0,m;m=this.chunks[k];k++)if(m.type===CODE_PNG_CHUNK){m.length=e;m.data=d;m.crc=h;return}m=new PNG.Chunk(e,CODE_PNG_CHUNK,d,h);this.chunks.splice(this.chunks.length-1,0,m)};
PNG.prototype.toBlob=function(){function d(p){"string"===typeof p?(p=(new TextEncoder).encode(p),k.set(p,m),m+=p.length):(k[m+3]=p&255,p>>=8,k[m+2]=p&255,p>>=8,k[m+1]=p&255,k[m]=p>>8&255,m+=4)}function e(p){k.set(p,m);m+=p.length}var h=PNG.HEADER.length;this.chunks.forEach(function(p){h+=p.length+12});var k=new Uint8Array(h),m=0;e(PNG.HEADER);this.chunks.forEach(function(p){d(p.length);d(p.type);e(p.data);d(p.crc)});return new Blob([k],{type:"image/png"})};
Blockly.exportBlockAsPng=function(d){var e=document.createElement("xml");e.appendChild(Blockly.Xml.blockToDom(d,!0));var h=Blockly.Xml.domToText(e);svgAsDataUri(d.getSvgRoot(),d.workspace.getMetrics(),null,function(k){var m=new Image;m.src=k;m.onload=function(){function p(L){L.setCodeChunk(h);for(var Q=0;Q<L.chunks.length;Q++){var da=[112,72,89,115];if("pHYs"==L.chunks[Q].type){L.chunks.splice(Q,1,new PNG.Chunk(9,"pHYs",pHY_data,crc32(da.concat(pHY_data))));break}else if("IDAT"==L.chunks[Q].type){L.chunks.splice(Q,
0,new PNG.Chunk(9,"pHYs",pHY_data,crc32(da.concat(pHY_data))));break}}L=L.toBlob();var N=document.createElement("a");N.download=(0===d.getChildren().length?d.type:"blocks")+".png";N.target="_self";N.href=URL.createObjectURL(L);document.body.appendChild(N);N.addEventListener("click",function(H){N.parentNode.removeChild(N)});N.click()}var t=document.createElement("canvas");t.width=2*m.width;t.height=2*m.height;t.getContext("2d").drawImage(m,0,0,m.width,m.height,0,0,t.width,t.height);if(void 0===t.toBlob){t=
t.toDataURL("image/png").split(",")[1];t=window.atob(t);for(var q=t.length,y=new Uint8Array(new ArrayBuffer(q)),I=0;I<q;I++)y[I]=t.charCodeAt(I);t=new Blob([y],{type:"image/png"});(new PNG).readFromBlob(t,p)}else t.toBlob(function(L){(new PNG).readFromBlob(L,p)})}})};function extractBlockTypes(d){var e=[];d=d.getElementsByTagName("mutation");for(var h=0;h<d.length;h++){var k=d[h].getAttribute("component_type");k&&e.push(k)}return e}
function validateBlockTypes(d,e){if(!d||0===d.length)return[];e=e.getComponentDatabase();for(var h=[],k=0;k<d.length;k++){const m=e.getType(d[k]);m&&m.componentInfo&&m.componentInfo.name===d[k]||h.push(d[k])}0<h.length&&console.warn("Missing component types:",h.join(", "));return h}function showMissingExtensionDialog(d){d=d.filter(function(h){return void 0!==h&&null!==h});if(0<d.length){var e=Blockly.Msg.REQUIRED_EXTENSIONS_MISSING;e+=d.join("\n");alert(e)}}
Blockly.importPngAsBlock=function(d,e,h){(new PNG).readFromBlob(h,function(k){if(k=k.getCodeChunk())if(k=(new TextDecoder).decode(k.data),k=Blockly.utils.xml.textToDom(k)){var m=extractBlockTypes(k);m=validateBlockTypes(m,d);0<m.length?showMissingExtensionDialog(m):(k=k.firstElementChild,k=Blockly.Xml.domToBlock(k,d),k.moveBy(e.x,e.y),k.initSvg(),d.requestRender(k))}else alert(Blockly.Msg.ERROR_PARSING_XML),console.error("Failed to parse XML from PNG.")})};AI.NameSet={};AI.Substitution={};var lexVarPlugin=LexicalVariablesPlugin;AI.Blockly.Flydown={};Blockly.Flydown=lexVarPlugin.Flydown;AI.Blockly.FieldFlydown={};Blockly.FieldFlydown=lexVarPlugin.FieldFlydown;AI.Blockly.FieldGlobalFlydown={};Blockly.FieldGlobalFlydown=lexVarPlugin.FieldGlobalFlydown;AI.Blockly.FieldLexicalVariable={};Blockly.FieldLexicalVariable=lexVarPlugin.FieldLexicalVariable;AI.Blockly.FieldParameterFlydown={};Blockly.FieldParameterFlydown=lexVarPlugin.FieldParameterFlydown;
AI.Blockly.FieldProcedureName=lexVarPlugin.FieldProcedureName;Blockly.LexicalVariable=lexVarPlugin.LexicalVariable;AI.Blockly.ProcedureNameDropdown=lexVarPlugin.FieldNoCheckDropdown;AI.Blockly.FieldNoCheckDropdown=lexVarPlugin.FieldNoCheckDropdown;
Blockly.LexicalVariable.eventParamMutationToDom=function(d){d.eventparam||Blockly.LexicalVariable.getEventParam(d);if(!d.eventparam)return null;var e=document.createElement("mutation"),h=document.createElement("eventparam");h.setAttribute("name",d.eventparam);e.appendChild(h);return e};
Blockly.LexicalVariable.getEventParam=function(d){if(void 0!==d.eventparam)return d.eventparam;d.eventparam=null;var e=Blockly.unprefixName(d.getFieldValue("VAR"));if(e[0]!==Blockly.Msg.LANG_VARIABLES_GLOBAL_PREFIX){e=e[1];for(var h=d,k=d.getParent();k;){var m=k.type;if("component_event"===m){var p=d.getTopWorkspace().getComponentDatabase();h=k.getParameters().map(function(t){return t.name});e=h.map(function(t){return p.getInternationalizedParameterName(t)}).indexOf(e);-1!=e&&(d.eventparam=h[e]);
break}else if("local_declaration_expression"===m&&k.getInputTargetBlock("RETURN")==h||"local_declaration_statement"===m&&k.getInputTargetBlock("STACK")==h){if(-1!=k.getVars().indexOf(e))break}else if(("controls_forEach"===m||"controls_forRange"===m)&&k.getInputTargetBlock("DO")==h){if(k.getFieldValue("VAR")==e)break}else if("controls_for_each_dict"==m&&k.getInputTargetBlock("DO")==h&&-1!=k.getVars().indexOf(e))break;h=k;k=k.getParent()}return null}};
Blockly.LexicalVariable.eventParamDomToMutation=function(d,e){e=e.children;1==e.length&&(e=e[0],"eventparam"==e.nodeName.toLowerCase()&&(e=e.getAttribute("name"),d.eventparam=e))};Blockly.LexicalVariable.eventParameterDict=function(d){var e={};d=d.getDescendants();for(var h=0,k;k=d[h];h++)k.eventparam&&(e[k.eventparam]=k.getFieldValue("VAR"));return e};Blockly=Object.assign(Blockly,lexVarPlugin.Shared);Blockly.NameSet=lexVarPlugin.NameSet;Blockly.Substitution=lexVarPlugin.Substitution;
Blockly.prefixSeparator=Blockly.yailSeparator;Blockly.usePrefixInCode=Blockly.usePrefixInYail;Blockly.possiblyPrefixYailNameWith=Blockly.possiblyPrefixGeneratedVarName;/*

 @fileoverview Visual blocks editor for App Inventor
 Methods to handle converting apps from older versions to current

 @author wolber@usfca.edu (David Wolber)
 @author ewpatton@mit.edu (Evan W. Patton)

 [lyn, 2014/10/31] Completely overhauled blocks upgrading architecture.
 All the work is done in Blockly.Version.upgrade.
 As in Liz Looney's AI1 BlocksSaveFile upgraders, all upgrades are based on mismatches
 between component versions or language versions of the screen and those of the current system.
 Unlike Liz's system, in which conditionals based on version numbers are used to express AI1 upgrades,
 all AI2 upgrades are expressed via the dictionary structure in Blockly.Versioning.AllUpgradeMaps,
 which is defined at the end of this file. This is a more declarative approach for expressing upgrades.
*/
AI.Blockly.Versioning={};void 0===Blockly.Versioning&&(Blockly.Versioning={});Blockly.Versioning.loggingFlag=!0;Blockly.Versioning.setLogging=function(d){Blockly.Versioning.loggingFlag=d};Blockly.Versioning.log=function(d){Blockly.Versioning.loggingFlag&&console.log("Blockly.Versioning: "+d)};
Blockly.Versioning.upgradeComponentMethods=function(d){for(var e=d.querySelectorAll('block[type="component_method"]'),h=0;h<e.length;h++){var k=e[h],m=k.parentElement,p=k.querySelector("mutation");if(!p){console.warn("component_method without mutation",k);return}if(!m)return;p.setAttribute("shape",m.tagName.toLowerCase())}return d};
Blockly.Versioning.upgrade=function(d,e,h){function k(L,Q,da,N){"Form"==L&&(L="Screen");Blockly.Versioning.log("In Blockly.Versioning.upgrade, upgradeComponentType("+L+","+Q+","+da+","+N+")");if(!(Q>da)&&Q<da){Blockly.Versioning.log("upgrading component type "+L+" from version "+Q+" to version "+da);var H=Blockly.Versioning.AllUpgradeMaps[L];if(!H)throw"Blockly.Versioning.upgrade: no upgrade map for component type "+L;for(Q+=1;Q<=da;Q++){var K=H[Q];if(!K)throw"Blockly.Versioning.upgrade: no upgrader to upgrade component type "+
L+" to version "+Q;Blockly.Versioning.log("applying upgrader for upgrading component type "+L+" from version "+(Q-1)+" to version "+Q);N=Blockly.Versioning.applyUpgrader(K,N,h)}p=!0}return N}h=h||Blockly.common.getMainWorkspace();d=JSON.parse(d);var m=Blockly.utils.xml.textToDom(e);m=Blockly.Versioning.upgradeComponentMethods(m);var p=!1,t=top.BLOCKS_VERSION;e=top.YA_VERSION;var q=m.getElementsByTagName("yacodeblocks");if(0===q.length){Blockly.Versioning.v17_blocksOverhaul(m,h);var y=17}else{if(e==
parseInt(q[0].getAttribute("ya-version"),10)){Blockly.Versioning.ensureWorkspace(m,h);return}y=parseInt(q[0].getAttribute("language-version"),10)}m=k("Language",y,t,m);(0===q.length||217>=parseInt(q[0].getAttribute("ya-version"),10))&&218<=e&&(m=Blockly.Versioning.renameComponentType("GoogleSheets","Spreadsheet")(m));(0===q.length||227>=parseInt(q[0].getAttribute("ya-version"),10))&&228<=e&&(m=Blockly.Versioning.renameComponentType("LineOfBestFit","Trendline")(m));d=Blockly.Versioning.makeComponentVersionDict(d);
for(var I in d)d.hasOwnProperty(I)&&!Blockly.Versioning.isExternal(I,h)&&(e=d[I],"GoogleSheets"!=I&&(q=Blockly.Versioning.getSystemComponentVersion(I,h),m=k(I,e,q,m)));Blockly.Versioning.log("Blockly.Versioning.upgrade: Final conversion to Blockly.common.getMainWorkspace()");Blockly.Versioning.ensureWorkspace(m,h);return p};
Blockly.Versioning.checkUpgrader=function(d){var e=["noUpgrade","ai1CantDoUpgrade"];if("string"==typeof d){if(-1==e.indexOf(d))throw"Blockly.Versioning.checkUpgrader: upgrader is unrecognized special string: "+d;}else if("function"!=typeof d&&!Array.isArray(d))throw"Blockly.Versioning.checkUpgrader: upgrader is not a function, special string, or array of upgraders -- "+d;};Blockly.Versioning.isWorkspace=function(d){return d instanceof Blockly.Workspace};
Blockly.Versioning.isDom=function(d){try{return d instanceof Element||d instanceof HTMLElement||d instanceof HTMLUnknownElement||"XML"==d.tagName}catch(e){return!1}};
Blockly.Versioning.ensureDom=function(d){if(Blockly.Versioning.isDom(d))return d;if(Blockly.Versioning.isWorkspace(d))return Blockly.Versioning.log("Blockly.Versioning.ensureDom: converting Blockly.common.getMainWorkspace() to dom"),Blockly.Xml.workspaceToDom(d);throw"Blockly.Versioning.ensureDom: blocksRep is neither dom nor workspace -- "+d;};
Blockly.Versioning.getBlockChildren=function(d){var e=[];d=Array.prototype.filter.call(d.childNodes,function(m){return m.nodeType===Element.ELEMENT_NODE});for(var h=0,k;k=d[h];h++)e.push(k);return e};
Blockly.Versioning.ensureWorkspace=function(d,e){if(Blockly.Versioning.isWorkspace(d))return d;if(Blockly.Versioning.isDom(d)){e=e||Blockly.common.getMainWorkspace();Blockly.Versioning.log("Blockly.Versioning.ensureWorkspace: converting dom to Blockly.common.getMainWorkspace()");e.clear();Blockly.Xml.domToWorkspace(d,e);d=e.getTopBlocks();for(var h=0;h<d.length;h++){var k=d[h],m=k.getRelativeToSurfaceXY();m.x=k.x;m.y=k.y}return e}throw"Blockly.Versioning.ensureWorkspace: blocksRep is neither workspace nor dom -- "+
d;};Blockly.Versioning.applyUpgrader=function(d,e,h){h=h||Blockly.common.getMainWorkspace();h.getProcedureDatabase().clear();Blockly.Versioning.checkUpgrader(d);if("ai1CantDoUpgrade"==d)throw"Blockly.Versioning.applyUpgrader: cannot perform an AI Classic upgrade on "+e;return"function"==typeof d?d(e,h):Array.isArray(d)?(Blockly.Versioning.log("Blockly.Versioning.applyUpgrader: treating list as sequential composition of upgraders"),Blockly.Versioning.composeUpgraders(d)(e,h)):e};
Blockly.Versioning.composeUpgraders=function(d,e){e=e||Blockly.common.getMainWorkspace();return function(h){for(var k=0,m;m=d[k];k++)h=Blockly.Versioning.applyUpgrader(m,h,e);return h}};
Blockly.Versioning.makeComponentVersionDict=function(d){function e(k){for(var m=0,p;p=k[m];m+=1){var t=p.$Type,q=parseInt(p.$Version),y=h[t];if(y){if(y!=q)throw"Blockly.Versioning.makeComponentVersionDict: inconsistent versions for component of type"+t+"; ["+str(q)+", "+y+"]";}else h[t]=q;(p=p.$Components)&&e(p)}}var h={};e([d.Properties]);return h};
Blockly.Versioning.getSystemComponentVersion=function(d,e){if(e=e.getComponentDatabase().getType(d).componentInfo.version)return parseInt(e);throw"Blockly.Versioning.getSystemComponentVersion: No version for component type "+d;};Blockly.Versioning.isExternal=function(d,e){return(d=e.getComponentDatabase().getType(d))&&d.componentInfo?"true"===d.componentInfo.external:!1};
Blockly.Versioning.v17_blocksOverhaul=function(d,e){var h=0;d=d.getElementsByTagName("block");for(var k=0,m=d.length;k<m;k++){var p=d[k],t=p.getAttribute("type");if(null==Blockly.Blocks[t])if("procedures_do_then_return"==t)p.setAttribute("type","controls_do_then_return");else if("procedure_lexical_variable_get"==t)p.setAttribute("type","lexical_variable_get");else if("for_lexical_variable_get"==t)p.setAttribute("type","lexical_variable_get");else{var q=t.split("_");2<q.length&&(q=[q.slice(0,-1).join("_"),
q.pop()]);if("lexical"!=q[0])if("any"==q[1])Blockly.Versioning.v17_translateAnyMethod(p);else if(t=e.getComponentDatabase(),!t.hasType(q[0])||"setproperty"!=q[1]&&"getproperty"!=q[1]){var y=q[0],I=t.instanceNameToTypeName(y);I==y&&0===h&&(alert("Your app was created in an earlier version of App Inventor and may be loaded incorrectly. The problem is that it names a component instance the same as the component type, which is longer allowed."),h=1);q=q[1];"setproperty"==q||"getproperty"==q?Blockly.Versioning.v17_translateSetGetProperty(p,
e):"component"==q?Blockly.Versioning.v17_translateComponentGet(p,e):t.getEventForType(I,q)?Blockly.Versioning.v17_translateEvent(p,e):t.getMethodForType(I,q)&&Blockly.Versioning.v17_translateMethod(p,e)}else Blockly.Versioning.v17_translateComponentSetGetProperty(p,e)}}};
Blockly.Versioning.v17_translateEvent=function(d,e){var h=d.getAttribute("type").split("_");2<h.length&&(h=[h.slice(0,-1).join("_"),h.pop()]);var k=h[0];h=h[1];e=e.getComponentDatabase().instanceNameToTypeName(k);d.setAttribute("type","component_event");var m=d.ownerDocument.createElement("mutation");m.setAttribute("instance_name",k);m.setAttribute("event_name",h);m.setAttribute("component_type",e);d.insertBefore(m,d.firstChild)};
Blockly.Versioning.v17_translateMethod=function(d,e){var h=d.getAttribute("type").split("_");2<h.length&&(h=[h.slice(0,-1).join("_"),h.pop()]);var k=h[0];h=h[1];e=e.getComponentDatabase().instanceNameToTypeName(k);d.setAttribute("type","component_method");var m=d.ownerDocument.createElement("mutation");m.setAttribute("instance_name",k);m.setAttribute("method_name",h);m.setAttribute("component_type",e);m.setAttribute("is_generic","false");d.insertBefore(m,d.firstChild)};
Blockly.Versioning.v17_translateAnyMethod=function(d){var e=d.getAttribute("type").split("_");if(3<e.length){var h=e.slice(-2);e=[e.slice(0,-2).join("_"),h.pop(),h.pop()]}h=e[2];e=e[3];d.setAttribute("type","component_method");var k=d.ownerDocument.createElement("mutation");k.setAttribute("method_name",e);k.setAttribute("component_type",h);k.setAttribute("is_generic","true");d.insertBefore(k,d.firstChild)};
Blockly.Versioning.v17_translateComponentGet=function(d,e){var h=d.getAttribute("type").split("_");2<h.length&&(h=[h.slice(0,-1).join("_"),h.pop()]);h=h[0];e=e.getComponentDatabase().instanceNameToTypeName(h);d.setAttribute("type","component_component_block");var k=d.ownerDocument.createElement("mutation");k.setAttribute("instance_name",h);k.setAttribute("component_type",e);d.insertBefore(k,d.firstChild)};
Blockly.Versioning.v17_translateSetGetProperty=function(d,e){var h=d.getAttribute("type").split("_");2<h.length&&(h=[h.slice(0,-1).join("_"),h.pop()]);var k=h[0];h=h[1];e=e.getComponentDatabase().instanceNameToTypeName(k);for(var m=d.getElementsByTagName("title"),p="unknown",t=0,q=m.length;t<q;t++)if("PROP"==m[t].getAttribute("name")){p=m[t].textContent;break}d.setAttribute("type","component_set_get");d=d.getElementsByTagName("mutation")[0];d.setAttribute("instance_name",k);d.setAttribute("property_name",
p);"setproperty"==h?d.setAttribute("set_or_get","set"):d.setAttribute("set_or_get","get");d.setAttribute("component_type",e);d.setAttribute("is_generic","false");null!=d.getAttribute("yailtype")&&d.removeAttribute("yailtype")};
Blockly.Versioning.v17_translateComponentSetGetProperty=function(d){var e=d.getAttribute("type").split("_");2<e.length&&(e=[e.slice(0,-1).join("_"),e.pop()]);var h=e[1];e=e[0];for(var k=d.getElementsByTagName("title"),m="unknown",p=0,t=k.length;p<t;p++)if("PROP"==k[p].getAttribute("name")){m=k[p].textContent;break}d.setAttribute("type","component_set_get");d=d.getElementsByTagName("mutation")[0];d.setAttribute("property_name",m);"setproperty"==h?d.setAttribute("set_or_get","set"):d.setAttribute("set_or_get",
"get");d.setAttribute("component_type",e);d.setAttribute("is_generic","true");null!=d.getAttribute("yailtype")&&d.removeAttribute("yailtype")};
Blockly.Versioning.makeScreenNamesBeDropdowns=function(d,e){e=Blockly.Versioning.ensureDom(d).getElementsByTagName("block");for(var h=0,k;k=e[h];h++)if("controls_openAnotherScreen"==k.getAttribute("type")||"controls_openAnotherScreenWithStartValue"==k.getAttribute("type"))if(k=Blockly.Versioning.firstChildWithTagName(k,"value")){var m=k.getAttribute("name");"SCREENNAME"!=m&&"SCREEN"!=m||Blockly.Versioning.tryReplaceBlockWithScreen(k)}return d};
Blockly.Versioning.changeEventParameterName=function(d,e,h,k){return function(m){m=Blockly.Versioning.ensureWorkspace(m);for(var p=m.getAllBlocks(),t=0;t<p.length;t++){var q=p[t];if("event"===q.blockType&&q.eventName===e&&q.typeName===d){var y=Blockly.LexicalVariable.eventParameterDict(q)[h];if(y){for(var I=q.getDescendants(),L=0,Q;Q=I[L];L++)Q.eventparam&&Q.eventparam==h&&(Q.eventparam=k);I=m.getComponentDatabase().getInternationalizedParameterName(k);q=q.getChildren();for(L=0;Q=q[L];L++){var da=
new Blockly.Substitution([y],[I]);Blockly.LexicalVariable.renameFree(Q,da)}}}}return m}};Blockly.Versioning.renameBlockType=function(d,e){return function(h){h=Blockly.Versioning.ensureDom(h);for(var k=h.getElementsByTagName("block"),m=0,p=k.length;m<p;m++){var t=k[m];t.getAttribute("type")==d&&t.setAttribute("type",e)}return h}};
Blockly.Versioning.addDefaultMethodArgument=function(d,e,h,k){return function(m){m=Blockly.Versioning.ensureDom(m);for(var p=Blockly.Versioning.findAllMethodCalls(m,d,e),t=0,q;q=p[t];t++){for(var y=Array.prototype.filter.call(q,function(N){return N.nodeType===Element.ELEMENT_NODE}),I=null,L=0,Q;Q=y[L];L++)if("VALUE"==Q.tagName){var da=Q.getAttribute("name");if(0==da.indexOf("ARG"))if(da=parseInt(da.split("ARG")[1]),da==h)console.log("Already a child block at index  "+h+" in Blockly.Versioning.addDefaultMethodArgument("+
d+", "+e,NaN+h,NaN+k+")");else if(da>h){I=Q;break}}y=m.ownerDocument.createElement("value");y.setAttribute("name","ARG"+h);L=Blockly.Versioning.xmlBlockTextToDom(k);y.insertBefore(L,null);q.insertBefore(y,I)}return m}};Blockly.Versioning.changeEventName=function(d,e,h){return function(k){k=Blockly.Versioning.ensureDom(k);for(var m=Blockly.Versioning.findAllEventHandlers(k,d,e),p=0,t;t=m[p];p++)Blockly.Versioning.firstChildWithTagName(t,"mutation").setAttribute("event_name",h);return k}};
Blockly.Versioning.changeMethodName=function(d,e,h){return function(k){k=Blockly.Versioning.ensureDom(k);for(var m=Blockly.Versioning.findAllMethodCalls(k,d,e),p=0,t;t=m[p];p++)Blockly.Versioning.firstChildWithTagName(t,"mutation").setAttribute("method_name",h);return k}};
Blockly.Versioning.changePropertyName=function(d,e,h){return function(k){k=Blockly.Versioning.ensureDom(k);for(var m=Blockly.Versioning.findAllPropertyBlocks(k,d,e),p=0,t;t=m[p];p++){Blockly.Versioning.firstChildWithTagName(t,"mutation").setAttribute("property_name",h);t=k.ownerDocument.getChildren(t);for(var q=0,y;y=t[q];q++)"FIELD"==y.tagName.toUpperCase()&&"PROP"==y.getAttribute("name")&&y.textContent==e&&(y.textContent=h)}return k}};
Blockly.Versioning.makeMethodUseHelper=function(d,e,h,k){return function(m,p){m=Blockly.Versioning.ensureDom(m);for(var t=Blockly.Versioning.findAllMethodCalls(m,d,e),q=0,y;y=t[q];q++)for(var I=0,L;L=y.children[I];I++)if("value"==L.tagName&&L.getAttribute("name")=="ARG"+h){k(L,p);break}return m}};
Blockly.Versioning.makeMethodUseDropdown=function(d,e,h,k){return function(m,p){var t=Blockly.Versioning.getOptionListValueMap(p,k);return Blockly.Versioning.makeMethodUseHelper(d,e,h,function(q){Blockly.Versioning.tryReplaceBlockWithDropdown(q,t,k)})(m,p)}};
Blockly.Versioning.makeSetterUseHelper=function(d,e,h){return function(k,m){k=Blockly.Versioning.ensureDom(k);for(var p=Blockly.Versioning.findAllPropertyBlocks(k,d,e),t=0,q;q=p[t];t++)"set"==Blockly.Versioning.firstChildWithTagName(q,"mutation").getAttribute("set_or_get")&&h(Blockly.Versioning.firstChildWithTagName(q,"value"),m);return k}};
Blockly.Versioning.methodToSetterWithValue=function(d,e,h,k){return function(m){m=Blockly.Versioning.ensureDom(m);for(var p=Blockly.Versioning.findAllMethodCalls(m,d,e),t=0,q;q=p[t];t++){q.setAttribute("type","component_set_get");var y=Blockly.Versioning.firstChildWithTagName(q,"mutation");y.removeAttribute("method_name");y.setAttribute("property_name",h);y.setAttribute("set_or_get","set");y=isNaN(k)?'<value name="VALUE"><block type="text"><field name="TEXT">'+k+"</field></block></value>":'<value name="VALUE"><block type="math_number"><field name="NUM">'+
k+"</field></block></value>";y=Blockly.Versioning.xmlBlockTextToDom(y);q.appendChild(y)}return m}};Blockly.Versioning.makeSetterUseDropdown=function(d,e,h){return function(k,m){var p=Blockly.Versioning.getOptionListValueMap(m,h);return Blockly.Versioning.makeSetterUseHelper(d,e,function(t){Blockly.Versioning.tryReplaceBlockWithDropdown(t,p,h)})(k,m)}};
Blockly.Versioning.getOptionListValueMap=function(d,e){var h={};d=d.getComponentDatabase().getOptionList(e);e=0;for(var k;k=d.options[e];e++)h[k.value]=k.name,h[k.value.toLowerCase()]=k.name;return h};
Blockly.Versioning.tryReplaceBlockWithDropdown=function(d,e,h){if(d){var k=Blockly.Versioning.firstChildWithTagName(d,"block");if(k){var m=k.getAttribute("type");if("text"==m||"math_number"==m){(m=Blockly.Versioning.firstChildWithTagName(k,"field"))||(m=Blockly.Versioning.firstChildWithTagName(k,"title"));var p=m.textContent;if(e[p]){d.removeChild(k);k=document.createElement("block");k.setAttribute("type","helpers_dropdown");var t=document.createElement("mutation");t.setAttribute("key",h);m=document.createElement("field");
m.setAttribute("name","OPTION");e=document.createTextNode(e[p]);m.appendChild(e);k.appendChild(t);k.appendChild(m);d.appendChild(k)}}}}};
Blockly.Versioning.tryReplaceBlockWithScreen=function(d){if(d){var e=Blockly.Versioning.firstChildWithTagName(d,"block");if(e&&"text"==e.getAttribute("type")){var h=Blockly.Versioning.firstChildWithTagName(e,"field");h||=Blockly.Versioning.firstChildWithTagName(e,"title");var k=h.textContent;d.removeChild(e);e=document.createElement("block");e.setAttribute("type","helpers_screen_names");h=document.createElement("field");h.setAttribute("name","SCREEN");k=document.createTextNode(k);h.appendChild(k);
e.appendChild(h);d.appendChild(e)}}};
Blockly.Versioning.tryReplaceBlockWithAssets=function(d,e){if(d){var h=Blockly.Versioning.firstChildWithTagName(d,"block");if(h&&"text"==h.getAttribute("type")){var k=Blockly.Versioning.firstChildWithTagName(h,"field");k||=Blockly.Versioning.firstChildWithTagName(h,"title");var m=k.textContent;-1!=e.getAssetList().indexOf(m)&&(d.removeChild(h),e=document.createElement("block"),e.setAttribute("type","helpers_assets"),k=document.createElement("field"),k.setAttribute("name","ASSET"),m=document.createTextNode(m),
k.appendChild(m),e.appendChild(k),d.appendChild(e))}}};Blockly.Versioning.tryReplaceBlockWithPermissions=function(d,e){if(d){e=Blockly.Versioning.getOptionListValueMap(e,"Permission");for(var h=Object.entries(e),k=0,m;m=h[k];k++){var p=m[0];m=m[1];e.hasOwnProperty(p)&&(e["android.permission."+p]=m)}Blockly.Versioning.tryReplaceBlockWithDropdown(d,e,"Permission")}};
Blockly.Versioning.tryReplaceBlockWithHelper=function(d){return function(e,h){if(e){h=Blockly.Versioning.getOptionListValueMap(h,d);for(var k=Object.entries(h),m=0,p;p=k[m];m++){var t=p[0];p=p[1];h.hasOwnProperty(d)&&(h[t]=p)}Blockly.Versioning.tryReplaceBlockWithDropdown(e,h,d)}}};
Blockly.Versioning.findAllEventHandlers=function(d,e,h){for(var k=[],m=0;m<d.children.length;m++){var p=d.children[m];if("block"===p.tagName&&"component_event"===p.getAttribute("type")){var t=Blockly.Versioning.firstChildWithTagName(p,"mutation");if(t)t.getAttribute("component_type")===e&&t.getAttribute("event_name")===h&&k.push(p);else throw"Did not find expected mutation child in Blockly.Versioning.findAllEventHandlers with componentType = "+e+" and eventName = "+h;}}return k};
Blockly.Versioning.findAllMethodCalls=function(d,e,h){d=d.getElementsByTagName("block");for(var k=[],m=0,p;p=d[m];m++)if("component_method"==p.getAttribute("type")){var t=Blockly.Versioning.firstChildWithTagName(p,"mutation");if(t)t.getAttribute("component_type")==e&&t.getAttribute("method_name")==h&&k.push(p);else throw"Did not find expected mutation child in Blockly.Versioning.findAllMethodCalls with componentType = "+e+"and methodName = "+h;}return k};
Blockly.Versioning.findAllPropertyBlocks=function(d,e,h){d=d.getElementsByTagName("block");for(var k=[],m=0,p;p=d[m];m++)if("component_set_get"==p.getAttribute("type")){var t=Blockly.Versioning.firstChildWithTagName(p,"mutation");if(t)t.getAttribute("component_type")==e&&t.getAttribute("property_name")==h&&k.push(p);else throw"Did not find expected mutation child in Blockly.Versioning.findAllPropertyBlocks with componentType = "+e+"and propertyName = "+h;}return k};
Blockly.Versioning.renameComponentType=function(d,e){return function(h){h=Blockly.Versioning.ensureDom(h);for(var k=h.getElementsByTagName("block"),m=0,p;p=k[m];m++)(p=Blockly.Versioning.firstChildWithTagName(p,"mutation"))&&p.getAttribute("component_type")==d&&p.setAttribute("component_type",e);return h}};
Blockly.Versioning.firstChildWithTagName=function(d,e){e=e.toUpperCase();d=Array.prototype.filter.call(d.childNodes,function(m){return m.nodeType===Element.ELEMENT_NODE});for(var h=0,k;k=d[h];h++)if(k.tagName.toUpperCase()==e)return k;return null};
Blockly.Versioning.xmlBlockTextToDom=function(d){d=Blockly.utils.xml.textToDom("<xml>"+d+"</xml>");d=Array.prototype.filter.call(d.childNodes,function(e){return e.nodeType===Element.ELEMENT_NODE});if(1!=d.length)throw"Unexpected number of childred in Blockly.Versioning.xmlBlockTextToDom: "+d.length;return d[0]};
Blockly.Versioning.AllUpgradeMaps={AccelerometerSensor:{2:"noUpgrade",3:"noUpgrade",4:"noUpgrade",5:Blockly.Versioning.makeSetterUseDropdown("AccelerometerSensor","Sensitivity","Sensitivity")},ActivityStarter:{2:"noUpgrade",3:"ai1CantDoUpgrade",4:"noUpgrade",5:"noUpgrade",6:"noUpgrade"},AnomalyDetection:{2:"noUpgrade"},Ball:{2:"noUpgrade",3:"noUpgrade",4:"noUpgrade",5:"ai1CantDoUpgrade",6:"noUpgrade",7:"noUpgrade",8:Blockly.Versioning.makeMethodUseDropdown("Ball","Bounce",0,"Direction")},BarcodeScanner:{2:"noUpgrade"},
BluetoothClient:{2:"noUpgrade",3:"ai1CantDoUpgrade",4:"noUpgrade",5:"noUpgrade",6:"noUpgrade",7:"noUpgrade",8:"noUpgrade"},BluetoothServer:{2:"noUpgrade",3:"ai1CantDoUpgrade",4:"noUpgrade",5:"noUpgrade"},Button:{2:"ai1CantDoUpgrade",3:"noUpgrade",4:"noUpgrade",5:"noUpgrade",6:"noUpgrade",7:Blockly.Versioning.makeSetterUseHelper("Button","Image",Blockly.Versioning.tryReplaceBlockWithAssets)},Camcorder:{1:"noUpgrade"},Camera:{2:"noUpgrade",3:"noUpgrade"},Canvas:{2:"noUpgrade",3:"noUpgrade",4:"noUpgrade",
5:"noUpgrade",6:"noUpgrade",7:"ai1CantDoUpgrade",8:[Blockly.Versioning.changeEventParameterName("Canvas","Dragged","draggedSprite","draggedAnySprite"),Blockly.Versioning.changeEventParameterName("Canvas","Touched","touchedSprite","touchedAnySprite")],9:Blockly.Versioning.addDefaultMethodArgument("Canvas","DrawCircle",3,'<block type="logic_boolean">  <field name="BOOL">TRUE</field></block>'),10:"noUpgrade",11:"noUpgrade",12:"noUpgrade",13:"noUpgrade",14:"noUpgrade",15:Blockly.Versioning.makeSetterUseHelper("Canvas",
"BackgroundImage",Blockly.Versioning.tryReplaceBlockWithAssets)},Chart:{2:"noUpgrade",3:"noUpgrade",4:"noUpgrade"},ChartData2D:{2:"noUpgrade"},ChatBot:{1:"noUpgrade",2:"noUpgrade",3:"noUpgrade",4:"noUpgrade",5:"noUpgrade"},CheckBox:{2:"noUpgrade"},Clock:{1:"noUpgrade",2:[Blockly.Versioning.addDefaultMethodArgument("Clock","FormatDateTime",1,'<block type="text">  <field name="TEXT">MMM d, yyyy HH:mm:ss a</field></block>'),Blockly.Versioning.addDefaultMethodArgument("Clock","FormatDate",1,'<block type="text">  <field name="TEXT">MMM d, yyyy</field></block>')],
3:"noUpgrade",4:"noUpgrade"},CloudDB:{1:"noUpgrade",2:"noUpgrade"},ContactPicker:{2:"ai1CantDoUpgrade",3:"noUpgrade",4:"noUpgrade",5:"noUpgrade",6:"noUpgrade"},DataFile:{},DatePicker:{2:"noUpgrade",3:"noUpgrade",4:Blockly.Versioning.makeSetterUseHelper("DatePicker","Image",Blockly.Versioning.tryReplaceBlockWithAssets)},EmailPicker:{2:"ai1CantDoUpgrade",3:"noUpgrade",4:"noUpgrade",5:"noUpgrade",6:"noUpgrade",7:[Blockly.Versioning.changeMethodName("EmailPicker","SetCursorAt","MoveCursorTo"),Blockly.Versioning.changeMethodName("EmailPicker",
"SetCursorAtEnd","MoveCursorToEnd"),Blockly.Versioning.changeEventName("EmailPicker","OnTextChanged","TextChanged")]},FeatureCollection:{2:[Blockly.Versioning.changeEventName("FeatureCollection","GeoJSONError","LoadError"),Blockly.Versioning.changeEventName("FeatureCollection","GeoGeoJSON","GotFeatures"),Blockly.Versioning.changeEventName("FeatureCollection","ErrorLoadingFeatureCollection","LoadError"),Blockly.Versioning.changeEventName("FeatureCollection","LoadedFeatureCollection","GotFeatures")]},
File:{2:"noUpgrade",3:"noUpgrade",4:"noUpgrade"},FirebaseDB:{1:"noUpgrade",2:"noUpgrade",3:"noUpgrade"},FusiontablesControl:{2:"noUpgrade",3:"noUpgrade",4:"noUpgrade"},GameClient:{1:"noUpgrade"},GyroscopeSensor:{1:"noUpgrade"},HorizontalArrangement:{2:"noUpgrade",3:"noUpgrade",4:[Blockly.Versioning.makeSetterUseDropdown("HorizontalArrangement","AlignHorizontal","HorizontalAlignment"),Blockly.Versioning.makeSetterUseDropdown("HorizontalArrangement","AlignVertical","VerticalAlignment"),Blockly.Versioning.makeSetterUseHelper("HorizontalArrangement",
"Image",Blockly.Versioning.tryReplaceBlockWithAssets)]},HorizontalScrollArrangement:{1:"noUpgrade",2:[Blockly.Versioning.makeSetterUseDropdown("HorizontalScrollArrangement","AlignHorizontal","HorizontalAlignment"),Blockly.Versioning.makeSetterUseDropdown("HorizontalScrollArrangement","AlignVertical","VerticalAlignment"),Blockly.Versioning.makeSetterUseHelper("HorizontalScrollArrangement","Image",Blockly.Versioning.tryReplaceBlockWithAssets)]},Image:{1:"noUpgrade",2:"noUpgrade",3:"noUpgrade",4:"noUpgrade",
5:"noUpgrade",6:Blockly.Versioning.makeSetterUseHelper("Image","Picture",Blockly.Versioning.tryReplaceBlockWithAssets)},ImageBot:{1:"noUpgrade",2:"noUpgrade"},ImagePicker:{2:"ai1CantDoUpgrade",3:"noUpgrade",4:"noUpgrade",5:"noUpgrade"},ImageSprite:{2:"noUpgrade",3:"noUpgrade",4:"noUpgrade",5:"noUpgrade",6:"ai1CantDoUpgrade",7:"noUpgrade",8:[Blockly.Versioning.makeMethodUseDropdown("ImageSprite","Bounce",0,"Direction"),Blockly.Versioning.makeSetterUseHelper("ImageSprite","Picture",Blockly.Versioning.tryReplaceBlockWithAssets)],
9:"noUpgrade",10:"noUpgrade"},Label:{2:"ai1CantDoUpgrade",3:"noUpgrade",4:"noUpgrade",5:"noUpgrade"},Language:{2:"noUpgrade",3:"noUpgrade",4:"noUpgrade",5:"ai1CantDoUpgrade",6:"ai1CantDoUpgrade",7:"ai1CantDoUpgrade",8:"ai1CantDoUpgrade",9:"ai1CantDoUpgrade",10:"ai1CantDoUpgrade",11:"noUpgrade",12:"ai1CantDoUpgrade",13:"noUpgrade",14:"noUpgrade",15:"noUpgrade",16:"noUpgrade",17:"ai1CantDoUpgrade",18:"noUpgrade",19:"noUpgrade",20:Blockly.Versioning.renameBlockType("obsufcated_text","obfuscated_text"),
21:"noUpgrade",22:"noUpgrade",23:"noUpgrade",24:"noUpgrade",25:"noUpgrade",26:"noUpgrade",27:"noUpgrade",28:"noUpgrade",29:"noUpgrade",30:"noUpgrade",31:"noUpgrade",32:"noUpgrade",33:"noUpgrade",34:Blockly.Versioning.makeScreenNamesBeDropdowns,35:"noUpgrade",36:[Blockly.Versioning.renameBlockType("lists_minimum_number","lists_minimum_value"),Blockly.Versioning.renameBlockType("lists_maximum_number","lists_maximum_value")],37:"noUpgrade",38:"noUpgrade"},ListPicker:{2:"ai1CantDoUpgrade",3:"noUpgrade",
4:"noUpgrade",5:"noUpgrade",6:"noUpgrade",7:"noUpgrade",8:"noUpgrade",9:"noUpgrade"},ListView:{2:"noUpgrade",3:"noUpgrade",4:"noUpgrade",5:"noUpgrade",6:"noUpgrade",7:"noUpgrade",8:"noUpgrade",9:"noUpgrade",10:"noUpgrade"},LocationSensor:{2:"noUpgrade",3:"noUpgrade",4:"noUpgrade"},Map:{2:[Blockly.Versioning.changePropertyName("Map","Markers","Features"),Blockly.Versioning.changeMethodName("Map","LoadGeoJSONFromUrl","LoadFromURL"),Blockly.Versioning.changeMethodName("Map","FeatureFromGeoJSONDescription",
"FeatureFromDescription")],3:[Blockly.Versioning.changeEventName("Map","GotGeoJSON","GotFeatures"),Blockly.Versioning.changeEventName("Map","GeoJSONError","LoadError")],4:"noUpgrade",5:"noUpgrade",6:[Blockly.Versioning.makeSetterUseDropdown("Map","ScaleUnits","ScaleUnits"),Blockly.Versioning.makeSetterUseDropdown("Map","MapType","MapType")],7:"noUpgrade"},Circle:{2:"noUpgrade"},LineString:{2:"noUpgrade"},Marker:{2:"noUpgrade",3:"noUpgrade",4:[Blockly.Versioning.makeSetterUseDropdown("Marker","AnchorHorizontal",
"HorizontalAlignment"),Blockly.Versioning.makeSetterUseDropdown("Marker","AnchorVertical","VerticalAlignment"),Blockly.Versioning.makeSetterUseHelper("Marker","ImageAsset",Blockly.Versioning.tryReplaceBlockWithAssets)]},Polygon:{2:"noUpgrade"},Rectangle:{2:"noUpgrade"},Navigation:{1:"noUpgrade",2:[Blockly.Versioning.makeSetterUseDropdown("Navigation","TransportationMethod","TransportMethod")]},NearField:{1:"noUpgrade"},Notifier:{2:"ai1CantDoUpgrade",3:"noUpgrade",4:"noUpgrade",5:"noUpgrade",6:"noUpgrade"},
NxtColorSensor:{1:"noUpgrade"},NxtDirectCommands:{1:"noUpgrade",2:[Blockly.Versioning.makeMethodUseDropdown("NxtDirectCommands","SetOutputState",0,"NxtMotorPort"),Blockly.Versioning.makeMethodUseDropdown("NxtDirectCommands","SetOutputState",2,"NxtMotorMode"),Blockly.Versioning.makeMethodUseDropdown("NxtDirectCommands","SetOutputState",3,"NxtRegulationMode"),Blockly.Versioning.makeMethodUseDropdown("NxtDirectCommands","SetOutputState",5,"NxtRunState"),Blockly.Versioning.makeMethodUseDropdown("NxtDirectCommands",
"SetInputMode",0,"NxtSensorPort"),Blockly.Versioning.makeMethodUseDropdown("NxtDirectCommands","SetInputMode",1,"NxtSensorType"),Blockly.Versioning.makeMethodUseDropdown("NxtDirectCommands","SetInputMode",2,"NxtSensorMode"),Blockly.Versioning.makeMethodUseDropdown("NxtDirectCommands","GetOutputState",0,"NxtMotorPort"),Blockly.Versioning.makeMethodUseDropdown("NxtDirectCommands","GetInputValues",0,"NxtSensorPort"),Blockly.Versioning.makeMethodUseDropdown("NxtDirectCommands","ResetInputScaledValue",
0,"NxtSensorPort"),Blockly.Versioning.makeMethodUseDropdown("NxtDirectCommands","ResetMotorPosition",0,"NxtMotorPort"),Blockly.Versioning.makeMethodUseDropdown("NxtDirectCommands","LsGetStatus",0,"NxtSensorPort"),Blockly.Versioning.makeMethodUseDropdown("NxtDirectCommands","LsWrite",0,"NxtSensorPort"),Blockly.Versioning.makeMethodUseDropdown("NxtDirectCommands","LsRead",0,"NxtSensorPort"),Blockly.Versioning.makeMethodUseDropdown("NxtDirectCommands","MessageRead",0,"NxtMailbox"),Blockly.Versioning.makeMethodUseDropdown("NxtDirectCommands",
"MessageWrite",0,"NxtMailbox")]},NxtDrive:{1:"noUpgrade"},NxtLightSensor:{1:"noUpgrade"},NxtSoundSensor:{1:"noUpgrade"},NxtTouchSensor:{1:"noUpgrade"},NxtUltrasonicSensor:{1:"noUpgrade"},Ev3Motors:{1:"noUpgrade"},Ev3ColorSensor:{1:"noUpgrade",2:[Blockly.Versioning.methodToSetterWithValue("Ev3ColorSensor","SetAmbientMode","Mode","ambient"),Blockly.Versioning.methodToSetterWithValue("Ev3ColorSensor","SetColorMode","Mode","color"),Blockly.Versioning.methodToSetterWithValue("Ev3ColorSensor","SetReflectedMode",
"Mode","reflected"),Blockly.Versioning.makeSetterUseDropdown("Ev3ColorSensor","Mode","ColorSensorMode")]},Ev3GyroSensor:{1:"noUpgrade",2:[Blockly.Versioning.methodToSetterWithValue("Ev3GyroSensor","SetAngleMode","Mode","angle"),Blockly.Versioning.methodToSetterWithValue("Ev3GyroSensor","SetRateMode","Mode","rate"),Blockly.Versioning.makeSetterUseDropdown("Ev3GyroSensor","Mode","GyroSensorMode")]},Ev3TouchSensor:{1:"noUpgrade"},Ev3UltrasonicSensor:{1:"noUpgrade",2:[Blockly.Versioning.methodToSetterWithValue("Ev3UltrasonicSensor",
"SetCmUnit","Unit","cm"),Blockly.Versioning.methodToSetterWithValue("Ev3UltrasonicSensor","SetInchUnit","Unit","inch"),Blockly.Versioning.makeSetterUseDropdown("Ev3UltrasonicSensor","Unit","UltrasonicSensorUnit")]},Ev3Sound:{1:"noUpgrade"},Ev3UI:{1:"noUpgrade"},Ev3Commands:{1:"noUpgrade"},OrientationSensor:{2:"ai1CantDoUpgrade"},PasswordTextBox:{2:"ai1CantDoUpgrade",3:"noUpgrade",4:"noUpgrade",5:"noUpgrade",6:"noUpgrade",7:[Blockly.Versioning.changeMethodName("PasswordTextBox","SetCursorAt","MoveCursorTo"),
Blockly.Versioning.changeMethodName("PasswordTextBox","SetCursorAtEnd","MoveCursorToEnd"),Blockly.Versioning.changeEventName("PasswordTextBox","OnTextChanged","TextChanged")]},Pedometer:{1:"noUpgrade",2:"noUpgrade",3:"noUpgrade"},PhoneCall:{2:"noUpgrade",3:"noUpgrade"},PhoneNumberPicker:{2:"ai1CantDoUpgrade",3:"noUpgrade",4:"noUpgrade"},Player:{2:"noUpgrade",3:"ai1CantDoUpgrade",4:"noUpgrade",5:"ai1CantDoUpgrade",6:"noUpgrade",7:"noUpgrade"},ProximitySensor:{1:"noUpgrade"},Regression:{2:[Blockly.Versioning.makeMethodUseHelper("Regression",
"CalculateLineOfBestFitValue",2,Blockly.Versioning.tryReplaceBlockWithHelper("LOBFValues"))]},Screen:{2:"noUpgrade",3:"noUpgrade",4:"noUpgrade",5:"noUpgrade",6:"noUpgrade",7:"noUpgrade",8:"noUpgrade",9:"noUpgrade",10:"noUpgrade",11:"noUpgrade",12:"noUpgrade",13:"noUpgrade",14:"noUpgrade",15:"noUpgrade",16:"noUpgrade",17:"noUpgrade",18:"noUpgrade",19:"noUpgrade",20:"noUpgrade",21:"noUpgrade",22:"noUpgrade",23:"noUpgrade",24:"noUpgrade",25:"noUpgrade",26:"noUpgrade",27:"noUpgrade",28:"noUpgrade",29:[Blockly.Versioning.makeSetterUseDropdown("Form",
"OpenScreenAnimation","ScreenAnimation"),Blockly.Versioning.makeSetterUseDropdown("Form","CloseScreenAnimation","ScreenAnimation"),Blockly.Versioning.makeSetterUseDropdown("Form","AlignHorizontal","HorizontalAlignment"),Blockly.Versioning.makeSetterUseDropdown("Form","AlignVertical","VerticalAlignment"),Blockly.Versioning.makeSetterUseDropdown("Form","ScreenOrientation","ScreenOrientation"),Blockly.Versioning.makeSetterUseHelper("Form","BackgroundImage",Blockly.Versioning.tryReplaceBlockWithAssets),
Blockly.Versioning.makeMethodUseHelper("Form","AskForPermission",0,Blockly.Versioning.tryReplaceBlockWithPermissions)],30:"noUpgrade",31:"noUpgrade"},Sharing:{1:"noUpgrade"},Slider:{1:"noUpgrade",2:"noUpgrade",3:"noUpgrade"},Sound:{2:"noUpgrade",3:"ai1CantDoUpgrade",4:Blockly.Versioning.makeSetterUseHelper("Sound","Source",Blockly.Versioning.tryReplaceBlockWithAssets)},SoundRecorder:{1:"noUpgrade",2:"noUpgrade"},SpeechRecognizer:{1:"noUpgrade",2:"noUpgrade",3:"noUpgrade"},Spinner:{1:"noUpgrade",2:"noUpgrade"},
Spreadsheet:{2:[Blockly.Versioning.changeMethodName("Spreadsheet","ReadCol","ReadColumn"),Blockly.Versioning.changeMethodName("Spreadsheet","WriteCol","WriteColumn"),Blockly.Versioning.changeMethodName("Spreadsheet","AddCol","AddColumn"),Blockly.Versioning.changeMethodName("Spreadsheet","RemoveCol","RemoveColumn"),Blockly.Versioning.changeEventName("Spreadsheet","GotColData","GotColumnData"),Blockly.Versioning.changeEventName("Spreadsheet","FinishedWriteCol","FinishedWriteColumn"),Blockly.Versioning.changeEventName("Spreadsheet",
"FinishedAddCol","FinishedAddColumn"),Blockly.Versioning.changeEventName("Spreadsheet","FinishedRemoveCol","FinishedRemoveColumn"),Blockly.Versioning.changeEventParameterName("Spreadsheet","GotFilterResult","return_rows","returnRows"),Blockly.Versioning.changeEventParameterName("Spreadsheet","GotFilterResult","return_data","returnData"),Blockly.Versioning.changeEventParameterName("Spreadsheet","GotColumnData","colDataList","columnData")],3:"noUpgrade",4:"noUpgrade"},TableArrangement:{1:"noUpgrade"},
TextBox:{2:"noUpgrade",3:"ai1CantDoUpgrade",4:"noUpgrade",5:"noUpgrade",6:"noUpgrade",7:"noUpgrade",8:"noUpgrade",9:"noUpgrade",10:"noUpgrade",11:"noUpgrade",12:"noUpgrade",13:"noUpgrade",14:[Blockly.Versioning.changeMethodName("TextBox","SetCursorAt","MoveCursorTo"),Blockly.Versioning.changeMethodName("TextBox","SetCursorAtEnd","MoveCursorToEnd"),Blockly.Versioning.changeEventName("TextBox","OnTextChanged","TextChanged")]},Texting:{2:"noUpgrade",3:"ai1CantDoUpgrade",4:"noUpgrade",5:Blockly.Versioning.makeSetterUseDropdown("Texting",
"ReceivingEnabled","ReceivingState")},TextToSpeech:{2:"noUpgrade",3:"noUpgrade",4:"noUpgrade",5:"noUpgrade",6:"noUpgrade"},TimePicker:{2:"noUpgrade",3:"noUpgrade",4:Blockly.Versioning.makeSetterUseHelper("TimePicker","Image",Blockly.Versioning.tryReplaceBlockWithAssets)},TinyDB:{1:"noUpgrade",2:"noUpgrade",3:"noUpgrade"},TinyWebDB:{2:"ai1CantDoUpgrade"},Twitter:{2:"ai1CantDoUpgrade",3:"ai1CantDoUpgrade",4:"noUpgrade"},VerticalArrangement:{2:"noUpgrade",3:"noUpgrade",4:[Blockly.Versioning.makeSetterUseDropdown("VerticalArrangement",
"AlignHorizontal","HorizontalAlignment"),Blockly.Versioning.makeSetterUseDropdown("VerticalArrangement","AlignVertical","VerticalAlignment"),Blockly.Versioning.makeSetterUseHelper("VerticalArrangement","Image",Blockly.Versioning.tryReplaceBlockWithAssets)]},VerticalScrollArrangement:{1:"noUpgrade",2:[Blockly.Versioning.makeSetterUseDropdown("VerticalScrollArrangement","AlignHorizontal","HorizontalAlignment"),Blockly.Versioning.makeSetterUseDropdown("VerticalScrollArrangement","AlignVertical","VerticalAlignment"),
Blockly.Versioning.makeSetterUseHelper("VerticalScrollArrangement","Image",Blockly.Versioning.tryReplaceBlockWithAssets)]},VideoPlayer:{2:"noUpgrade",3:"ai1CantDoUpgrade",4:"noUpgrade",5:"noUpgrade",6:"noUpgrade",7:Blockly.Versioning.makeSetterUseHelper("VideoPlayer","Source",Blockly.Versioning.tryReplaceBlockWithAssets)},Voting:{1:"noUpgrade"},Web:{2:"ai1CantDoUpgrade",3:"ai1CantDoUpgrade",4:"noUpgrade",5:"noUpgrade",6:"noUpgrade",7:"noUpgrade",8:"noUpgrade",9:"noUpgrade"},WebViewer:{2:"noUpgrade",
3:"noUpgrade",4:"noUpgrade",5:"noUpgrade",6:"noUpgrade",7:"noUpgrade",8:"noUpgrade",9:"noUpgrade",10:"noUpgrade",11:"noUpgrade"},YandexTranslate:{1:"noUpgrade",2:"noUpgrade",3:[Blockly.Versioning.renameComponentType("YandexTranslate","Translator")]},Translator:{1:"noUpgrade"}};/*

 @fileoverview Visual blocks editor for App Inventor
 Methods to handle serialization of the blocks workspace

 @author sharon@google.com (Sharon Perl)
 @author ewpatton@mit.edu (Evan W. Patton)

 History:
 [lyn, 2014/10/31] Completely overhauled blocks upgrading architecture.
 All the work is done in Blockly.Version.upgrade.
*/
AI.Blockly.SaveFile={};void 0===Blockly.SaveFile&&(Blockly.SaveFile={});Blockly.SaveFile.load=function(d,e){try{Blockly.Events.disable();if(0!=e.length)try{Blockly.Block.isRenderingOn=!1,Blockly.Versioning.upgrade(d,e)}finally{Blockly.Block.isRenderingOn=!0}null!=Blockly.common.getMainWorkspace()&&null!=Blockly.common.getMainWorkspace().getCanvas()&&Blockly.common.getMainWorkspace().render()}finally{Blockly.Events.enable()}};
Blockly.SaveFile.get=function(d,e){e=e||Blockly.common.getMainWorkspace();e=Blockly.Xml.workspaceToDom(e,!1);var h=document.createElementNS("https://appinventor.mit.edu/ns/project/","yacodeblocks");h.setAttribute("ya-version",top.YA_VERSION);h.setAttribute("language-version",top.BLOCKS_VERSION);e.appendChild(h);return d?Blockly.Xml.domToPrettyText(e):Blockly.Xml.domToText(e)};AI.Blockly.Msg={};AI.Blockly.Msg.applyMessages=function(d){Object.keys(d).forEach(function(e){Blockly.Msg[e]=d[e]})};window.AI=AI;AI.BlockUtils={};AI.BlockUtils.InstantInTime=function(d,e){return d.getSourceBlock().rendered&&e.getSourceBlock().rendered?!e.getCheck()||e.getCheck().includes("InstantInTime"):(e.getCheck()&&!e.getCheck().includes("InstantInTime")&&e.getSourceBlock().badBlock(),!0)};
AI.BlockUtils.YailTypeToBlocklyTypeMap={number:{input:["Number"],output:["Number","String","Key"]},matrix:{input:["Matrix"],output:["Matrix","String","Array"]},text:{input:["String"],output:["Number","String","Key"]},"boolean":{input:["Boolean"],output:["Boolean","String"]},list:{input:["Array"],output:["Array","String"]},component:{input:["COMPONENT"],output:["COMPONENT","Key"]},InstantInTime:{input:["InstantInTime",AI.BlockUtils.InstantInTime],output:["InstantInTime",AI.BlockUtils.InstantInTime]},
procedure:{input:["YailProcedure"],output:["YailProcedure"]},any:{input:null,output:null},dictionary:{input:["Dictionary"],output:["Dictionary","String","Array"]},pair:{input:["Pair"],output:["Pair","String","Array"]},key:{input:["Key"],output:["String","Key"]},"enum":{input:null,output:["Key"]}};AI.BlockUtils.OUTPUT="output";AI.BlockUtils.INPUT="input";
AI.BlockUtils.YailTypeToBlocklyType=function(d,e){if(-1!=d.indexOf("Enum"))return d;e=AI.BlockUtils.YailTypeToBlocklyTypeMap[d][e];if(void 0===e)throw Error("Unknown Yail type: "+d+" -- YailTypeToBlocklyType");return e};AI.BlockUtils.helperKeyToBlocklyType=function(d,e){if(!d)return null;var h=AI.BlockUtils;switch(d.type){case "OPTION_LIST":return h.optionListKeyToBlocklyType(d.key,e);case "ASSET":return h.assetKeyToBlocklyType(d.key,e)}return null};
AI.BlockUtils.optionListKeyToBlocklyType=function(d,e){return e.getTopWorkspace().getComponentDatabase().getOptionList(d).className+"Enum"};AI.BlockUtils.assetKeyToBlocklyType=function(d,e){return e.getTopWorkspace().getComponentDatabase().getFilter(d)};AI.BlockUtils.setTooltip=function(d,e){d.setTooltip(AI.BlockUtils.wrapSentence(e,60))};
AI.BlockUtils.wrapSentence=function(d,e){d=d.trim();if(d.length<e)return d;var h=d.lastIndexOf(" ",e);return-1==h?d.substring(0,e).trim()+AI.BlockUtils.wrapSentence(d.substring(e),e):d.substring(0,h).trim()+"\n"+AI.BlockUtils.wrapSentence(d.substring(h),e)};AI.BlockUtils.MAX_COLLAPSE=4;AI.BlockUtils.times_symbol="×";AI.BlockUtils.NUMBER_REGEX=RegExp("^([-+]?[0-9]+)?(\\.[0-9]+)?([eE][-+]?[0-9]+)?$|^[-+]?[0-9]+(\\.[0-9]*)?([eE][-+]?[0-9]+)?$");/*

 @fileoverview Visual blocks editor for App Inventor
 Methods to handle warnings in the block editor.

 @author mckinney@mit.edu (Andrew F. McKinney)
*/
AI.Blockly.WarningHandler={};Blockly.WarningHandler=function(d){this.workspace=d;this.allBlockErrors=[{name:"checkReplErrors"}];this.allBlockWarnings=[{name:"checkBlockAtRoot"},{name:"checkEmptySockets"}];this.cachedGlobalNames=[];this.showWarningsToggle=!1;this.warningIdHash=Object.create(null);this.errorIdHash=Object.create(null);this.warningCollapseStack=[];this.errorCollapseStack=[];this.currentErrorBlockId=this.currentWarningBlockId=""};Blockly.WarningHandler.prototype.cacheGlobalNames=!1;
Blockly.WarningHandler.prototype.errorCount=0;Blockly.WarningHandler.prototype.warningCount=0;Blockly.WarningHandler.WarningState={NO_ERROR:0,WARNING:1,ERROR:2};Blockly.WarningHandler.prototype.currentWarning=-1;Blockly.WarningHandler.prototype.currentError=-1;Blockly.WarningHandler.prototype.updateWarningErrorCount=function(){var d=this.workspace.getWarningIndicator();d&&d.updateWarningAndErrorCount()};
Blockly.WarningHandler.prototype.updateCurrentWarningAndError=function(){var d=this.workspace.getWarningIndicator();d&&d.updateCurrentWarningAndError(this.currentWarning,this.currentError)};Blockly.WarningHandler.prototype.toggleWarning=function(){this.showWarningsToggle?(this.showWarningsToggle=!1,this.hideWarnings()):(this.showWarningsToggle=!0,this.checkAllBlocksForWarningsAndErrors());var d=this.workspace.getWarningIndicator();d&&d.updateWarningToggleText()};
Blockly.WarningHandler.prototype.hideWarnings=function(){for(var d=this.workspace.getAllBlocks(),e=0;e<d.length;e++)d[e].setWarningText(null)};
Blockly.WarningHandler.prototype.checkAllBlocksForWarningsAndErrors=function(){if(this.workspace.rendered){var d=this.workspace.getAllBlocks();try{this.cacheGlobalNames=!1;this.cachedGlobalNames=Blockly.FieldLexicalVariable.getGlobalNames();this.cacheGlobalNames=!0;for(var e=0;e<d.length;e++)this.checkErrors(d[e])}finally{this.cacheGlobalNames=!1,this.cachedGlobalNames=[]}}};
Blockly.WarningHandler.prototype.previousWarning=function(){var d=Object.keys(this.warningIdHash),e=d.length;e&&(this.currentWarningBlockId&&this.unHighlightBlock_(this.currentWarningBlockId,this.warningCollapseStack),0<this.currentWarning?this.currentWarning--:this.currentWarning=e-1,this.currentWarningBlockId=d[this.currentWarning],this.warningCollapseStack=this.highlightBlock_(this.currentWarningBlockId))};
Blockly.WarningHandler.prototype.nextWarning=function(){var d=Object.keys(this.warningIdHash),e=d.length;e&&(this.currentWarningBlockId&&this.unHighlightBlock_(this.currentWarningBlockId,this.warningCollapseStack),this.currentWarning<e-1?this.currentWarning++:this.currentWarning=0,this.currentWarningBlockId=d[this.currentWarning],this.warningCollapseStack=this.highlightBlock_(this.currentWarningBlockId))};
Blockly.WarningHandler.prototype.previousError=function(){var d=Object.keys(this.errorIdHash),e=d.length;e&&(this.currentErrorBlockId&&this.unHighlightBlock_(this.currentErrorBlockId,this.errorCollapseStack),0<this.currentError?this.currentError--:this.currentError=e-1,this.currentErrorBlockId=d[this.currentError],this.errorCollapseStack=this.highlightBlock_(this.currentErrorBlockId))};
Blockly.WarningHandler.prototype.nextError=function(){var d=Object.keys(this.errorIdHash),e=d.length;e&&(this.currentErrorBlockId&&this.unHighlightBlock_(this.currentErrorBlockId,this.errorCollapseStack),this.currentError<e-1?this.currentError++:this.currentError=0,this.currentErrorBlockId=d[this.currentError],this.errorCollapseStack=this.highlightBlock_(this.currentErrorBlockId))};
Blockly.WarningHandler.prototype.highlightBlock_=function(d){var e=this.workspace.getBlockById(d);e.setHighlighted(!0);var h=[];do e.isCollapsed()&&(h.push(e.id),e.setCollapsed(!1));while(e=e.getSurroundParent());this.workspace.centerOnBlock(d);this.updateCurrentWarningAndError();return h};Blockly.WarningHandler.prototype.unHighlightBlock_=function(d,e){var h=this.workspace;h.getBlockById(d).setHighlighted(!1);for(var k=0;d=e[k];k++)h.getBlockById(d).setCollapsed(!0)};
Blockly.WarningHandler.prototype.hideCurrentHighlight_=function(){this.currentErrorBlockId&&(this.unHighlightBlock_(this.currentErrorBlockId,this.errorCollapseStack),this.currentErrorBlockId="");this.currentWarningBlockId&&(this.unHighlightBlock_(this.currentWarningBlockId,this.warningCollapseStack),this.currentWarningBlockId="")};
Blockly.WarningHandler.prototype.checkErrors=function(d){this.hideCurrentHighlight_();this.updateWarningErrorCount();if(d.isInFlyout)return Blockly.WarningHandler.WarningState.NO_ERROR;if(!d.getSvgRoot()||d.readOnly)return d.hasWarning&&(d.hasWarning=!1,this.warningCount--,delete this.warningIdHash[d.id],this.updateWarningErrorCount()),d.hasError&&(d.hasError=!1,this.errorCount--,delete this.errorIdHash[d.id],this.updateWarningErrorCount()),Blockly.WarningHandler.WarningState.NO_ERROR;d.errors||(d.errors=
[]);d.warnings||(d.warnings=[]);for(var e=d.errors.concat(this.allBlockErrors),h=d.warnings.concat(this.allBlockWarnings),k=0;k<e.length;k++){let m=e[k];if((this[m.name]||m.func).call(this,d,m))return d.setWarningText(null),d.hasError||(d.hasError=!0,this.errorCount++,this.errorIdHash[d.id]=!0,this.updateWarningErrorCount()),d.hasWarning&&(d.hasWarning=!1,this.warningCount--,delete this.warningIdHash[d.id],this.updateWarningErrorCount()),Blockly.WarningHandler.WarningState.ERROR}d.error&&d.setErrorIconText(null);
d.hasError&&(d.hasError=!1,this.errorCount--,delete this.errorIdHash[d.id],this.updateWarningErrorCount());for(k=0;k<h.length;k++)if(e=h[k],(this[e.name]||e.func).call(this,d,e))return d.hasWarning||(d.hasWarning=!0,this.warningCount++,this.warningIdHash[d.id]=!0,this.updateWarningErrorCount()),Blockly.WarningHandler.WarningState.WARNING;d.setWarningText(null);d.hasWarning&&(d.hasWarning=!1,this.warningCount--,delete this.warningIdHash[d.id],this.updateWarningErrorCount());return Blockly.WarningHandler.WarningState.NO_ERROR};
Blockly.WarningHandler.prototype.checkIsInDefinition=function(d){if(("component_set_get"!==d.type||"get"!==d.setOrGet)&&"global_declaration"==d.getRootBlock().type){for(var e=d;e.getSurroundParent();)if(e=e.getSurroundParent(),"procedures_defanonnoreturn"==e.type||"procedures_defanonreturn"==e.type)return!1;d.setErrorIconText(Blockly.Msg.ERROR_BLOCK_CANNOT_BE_IN_DEFINTION);return!0}return!1};
Blockly.WarningHandler.prototype.checkIfUndefinedBlock=function(d){if(!0===d.isBadBlock()){var e=Blockly.Msg.ERROR_BLOCK_IS_NOT_DEFINED,h=!0;"component_event"==d.type&&(h=!1);d.isolate(h);d.setErrorIconText(e);return!0}return!1};
Blockly.WarningHandler.prototype.checkDropDownContainsValidValue=function(d,e){for(var h=0;h<e.dropDowns.length;h++){var k=d.getField(e.dropDowns[h]),m=k.getOptions(!1),p=k.getText(),t=k.getValue(),q=!1;k.updateMutation&&k.updateMutation();for(var y=0;y<m.length;y++)if(m[y][1]==t&&" "!=t){q=!0;m[y][0]!=p&&k.setValue(m[y][1]);break}if(!q)return d.setErrorIconText(Blockly.Msg.ERROR_SELECT_VALID_ITEM_FROM_DROPDOWN),!0}return!1};
Blockly.WarningHandler.prototype.checkInvalidNumber=function(d){if(d.outputConnection&&d.outputConnection.isConnected()){var e=d.outputConnection.targetConnection.getCheck(),h=d.getFieldValue("TEXT");return e&&-1==e.indexOf("String")&&0<=e.indexOf("Number")&&(""==h||!AI.BlockUtils.NUMBER_REGEX.test(h))?(d.setErrorIconText(Blockly.Msg.ERROR_INVALID_NUMBER_CONTENT),!0):!1}};
Blockly.WarningHandler.prototype.checkIsNotInLoop=function(d){if(Blockly_containedInLoop(d))return!1;d.setErrorIconText(Blockly.Msg.ERROR_BREAK_ONLY_IN_LOOP);return!0};Blockly_loopBlockTypes=["controls_forEach","controls_for_each_dict","controls_forRange","controls_while"];Blockly_containedInLoop=function(d){d=d.getSurroundParent();return null==d?!1:0<=Blockly_loopBlockTypes.indexOf(d.type)?!0:Blockly_containedInLoop(d)};
Blockly.WarningHandler.prototype.checkComponentNotExistsError=function(d){return 1==d.isGeneric?!1:-1==this.workspace.componentDb_.getInstanceNames().indexOf(d.instanceName)?(d.setErrorIconText(Blockly.Msg.ERROR_COMPONENT_DOES_NOT_EXIST),!0):!1};Blockly.WarningHandler.prototype.checkComponentTypeNotExistsError=function(d){return void 0==this.workspace.componentDb_.getType(d.typeName)?(d.setErrorIconText(Blockly.Msg.ERROR_COMPONENT_DOES_NOT_EXIST),!0):!1};
Blockly.WarningHandler.prototype.determineDuplicateComponentEventHandlers=function(){for(var d=this.workspace.getTopBlocks(!1),e=d.length,h={},k=0;k<e;k++){var m=d[k];if("component_event"==m.type&&!m.isInsertionMarker()){m.IAmADuplicate=!1;var p=m.typeName+":"+m.eventName+":"+m.instanceName+":"+m.disabled,t=h[p];t?(t.isDuplicate||(t.isDuplicate=!0,t.block.IAmADuplicate=!0),m.IAmADuplicate=!0):h[p]={block:m,isDuplicate:!1}}}};
Blockly.WarningHandler.prototype.checkIfIAmADuplicateEventHandler=function(d){return d.IAmADuplicate?(d.setErrorIconText(Blockly.Msg.ERROR_DUPLICATE_EVENT_HANDLER),!0):!1};Blockly.WarningHandler.prototype.setBlockError=function(d,e){d.setWarningText(null);d.hasWarning&&(d.hasWarning=!1,this.warningCount--,this.updateWarningErrorCount());d.hasError||(d.hasError=!0,this.errorCount++,this.updateWarningErrorCount());d.setErrorIconText(e)};
Blockly.WarningHandler.prototype.countChildBlocks=function(d){var e=0;d=d.getChildren();for(var h=0;h<d.length;h++){var k=d[h];k&&(console.log(`Found child block: ${k.type} (ID: ${k.id})`),e+=1,k=this.countChildBlocks(k),e+=k)}return e};
Blockly.WarningHandler.prototype.checkDisposedBlock=function(d){console.log(`Checking disposed block: ${d.type} (ID: ${d.id})`);d.hasWarning&&(d.hasWarning=!1,--this.warningCount,delete this.warningIdHash[d.id]);d.hasError&&(d.hasError=!1,--this.errorCount,delete this.errorIdHash[d.id]);d=d.getChildren();for(var e=0;e<d.length;e++)this.checkDisposedBlock(d[e]);this.updateWarningErrorCount()};
Blockly.WarningHandler.prototype.checkEmptySetterSocket=function(d){if("set"===d.setOrGet){var e=d.getInputTargetBlock("VALUE");if(!e||!e.isEnabled())return d.setErrorIconText(Blockly.Msg.ERROR_PROPERTY_SETTER_NEEDS_VALUE),!0}return!1};Blockly.WarningHandler.prototype.checkGenericComponentSocket=function(d){return d.isGeneric&&!d.getInputTargetBlock("COMPONENT")?(d.setErrorIconText(Blockly.Msg.ERROR_GENERIC_NEEDS_COMPONENT.replace(/%1/,d.genericComponentInput)),!0):!1};
Blockly.WarningHandler.prototype.checkEmptySockets=function(d){for(var e=!1,h=0;h<d.inputList.length;h++){var k=d.inputList[h].name;if(d.inputList[h].type==Blockly.inputs.inputTypes.VALUE&&d.inputList[h].connection&&!d.getInputTargetBlock(k)){e=!0;break}}return e?(this.showWarningsToggle&&d.setWarningText(Blockly.Msg.MISSING_SOCKETS_WARNINGS),!0):!1};
Blockly.WarningHandler.prototype.checkBlockAtRoot=function(d){var e=d.getRootBlock();return d==e&&"event"!=d.blockType&&"global_declaration"!=d.type&&"procedures_defnoreturn"!=d.type&&"procedures_defreturn"!=d.type?(this.showWarningsToggle&&d.setWarningText(Blockly.Msg.WRONG_TYPE_BLOCK_WARINGS),!0):!1};Blockly.WarningHandler.prototype.checkReplErrors=function(d){return d.replError?(d.setErrorIconText(d.replError),!0):!1};Blockly.WarningHandler.prototype.setError=function(d,e){d.setErrorIconText(e)};
Blockly.WarningHandler.prototype.setWarning=function(d,e){d.setWarningText(e)};/*

 @fileoverview Visual blocks editor for App Inventor
 Methods to handle warnings in the block editor.

 @author mckinney@mit.edu (Andrew F. McKinney)
 @author ewpatton@mit.edu (Evan W. Patton);
*/
AI.Blockly.WarningIndicator={};Blockly.WarningIndicator=class{constructor(d){this.workspace_=d}};Blockly.WarningIndicator.prototype.INDICATOR_HEIGHT_=40;Blockly.WarningIndicator.prototype.MARGIN_BOTTOM_=35;Blockly.WarningIndicator.prototype.MARGIN_SIDE_=35;Blockly.WarningIndicator.prototype.svgGroup_=null;Blockly.WarningIndicator.prototype.left_=0;Blockly.WarningIndicator.prototype.top_=0;
Blockly.WarningIndicator.prototype.createDom=function(){this.svgGroup_=Blockly.utils.dom.createSvgElement("g",{id:"indicatorWarning"},null);this.warningCount_=Blockly.utils.dom.createSvgElement("text",{fill:"black",transform:"translate(20,-1)"},this.svgGroup_);this.warningCount_.textContent="0";this.iconGroup_=Blockly.utils.dom.createSvgElement("g",{"class":"blocklyIconGroup",translate:"transform(0,-15)"},this.svgGroup_);Blockly.utils.dom.createSvgElement("path",{"class":"blocklyWarningIconShield",
d:"M 2,0 Q -1,0 0.5,-3 L 6.5,-13.3 Q 8,-16 9.5,-13.3 L 15.5,-3 Q 17,0 14,0 z"},this.iconGroup_);this.iconMark_=Blockly.utils.dom.createSvgElement("text",{"class":"blocklyWarningIconMark",x:AI.ErrorIcon.ICON_RADIUS,y:2*AI.ErrorIcon.ICON_RADIUS-18},this.iconGroup_);this.iconMark_.appendChild(document.createTextNode("!"));this.errorCount_=Blockly.utils.dom.createSvgElement("text",{fill:"black",transform:"translate(85,-1)"},this.svgGroup_);this.errorCount_.textContent="0";this.iconErrorGroup_=Blockly.utils.dom.createSvgElement("g",
{"class":"blocklyIconGroup",transform:"translate(65,0)"},this.svgGroup_);Blockly.utils.dom.createSvgElement("circle",{"class":"blocklyErrorIconOutline",r:AI.ErrorIcon.ICON_RADIUS,cx:AI.ErrorIcon.ICON_RADIUS,cy:AI.ErrorIcon.ICON_RADIUS-15},this.iconErrorGroup_);Blockly.utils.dom.createSvgElement("path",{"class":"blocklyErrorIconX",d:"M 4,-11 12,-3 8,-7 4,-3 12,-11"},this.iconErrorGroup_);this.warningToggleGroup_=Blockly.utils.dom.createSvgElement("g",{},this.svgGroup_);this.warningToggle_=Blockly.utils.dom.createSvgElement("rect",
{width:"120",height:"20",x:"-15",y:"20","class":"warningNav"},this.warningToggleGroup_);this.warningToggleText_=Blockly.utils.dom.createSvgElement("text",{fill:"black",transform:"translate(45,35)","text-anchor":"middle",style:"font-size:10pt;cursor:pointer;"},this.warningToggleGroup_);this.warningToggleText_.textContent=Blockly.Msg.SHOW_WARNINGS;this.warningNavPrevious_=Blockly.utils.dom.createSvgElement("path",{d:"M 0,7 L 10,17 L 20,7 Z","class":"warningNav"},this.svgGroup_);this.warningNavNext_=
Blockly.utils.dom.createSvgElement("path",{d:"M 10,-31 L 0,-21 L 20,-21 Z","class":"warningNav"},this.svgGroup_);this.errorNavPrevious_=Blockly.utils.dom.createSvgElement("path",{d:"M 67,7 L 77,17 L 87,7 Z","class":"warningNav"},this.svgGroup_);this.errorNavNext_=Blockly.utils.dom.createSvgElement("path",{d:"M 87,-21 L 67,-21 L 77,-31 Z","class":"warningNav"},this.svgGroup_);return this.svgGroup_};
Blockly.WarningIndicator.prototype.init=function(){this.workspace_.getComponentManager().addComponent({component:this,weight:2,capabilities:[Blockly.ComponentManager.Capability.POSITIONABLE]});Blockly.browserEvents.bind(this.warningToggleGroup_,"click",this,Blockly.WarningIndicator.prototype.onclickWarningToggle);Blockly.browserEvents.bind(this.warningNavPrevious_,"click",this,Blockly.WarningIndicator.prototype.onclickWarningNavPrevious);Blockly.browserEvents.bind(this.warningNavNext_,"click",this,
Blockly.WarningIndicator.prototype.onclickWarningNavNext);Blockly.browserEvents.bind(this.errorNavPrevious_,"click",this,Blockly.WarningIndicator.prototype.onclickErrorNavPrevious);Blockly.browserEvents.bind(this.errorNavNext_,"click",this,Blockly.WarningIndicator.prototype.onclickErrorNavNext);Blockly.browserEvents.bind(this.warningToggleGroup_,"mousedown",this,function(d){d.stopPropagation()});Blockly.browserEvents.bind(this.warningNavPrevious_,"mousedown",this,function(d){d.stopPropagation()});
Blockly.browserEvents.bind(this.warningNavNext_,"mousedown",this,function(d){d.stopPropagation()});Blockly.browserEvents.bind(this.errorNavPrevious_,"mousedown",this,function(d){d.stopPropagation()});Blockly.browserEvents.bind(this.errorNavNext_,"mousedown",this,function(d){d.stopPropagation()})};
Blockly.WarningIndicator.prototype.dispose=function(){this.svgGroup_&&(this.svgGroup_.parentNode&&this.svgGroup_.parentNode.removeChild(this.svgGroup_),this.svgGroup_=null);this.warningNavRightText_=this.warningNavNext_=this.warningNavLeftText_=this.warningNavPrevious_=this.warningToggleText_=this.warningToggle_=this.iconErrorMark_=this.iconErrorGroup_=this.errorCount_=this.iconMark_=this.iconGroup_=this.warningCount_=this.getMetrics_=null};
Blockly.WarningIndicator.prototype.position_=function(d){d&&(this.left_=Blockly.RTL?this.MARGIN_SIDE_:d.absoluteMetrics.left+this.MARGIN_SIDE_,this.top_=d.viewMetrics.height+d.absoluteMetrics.top-this.INDICATOR_HEIGHT_-this.MARGIN_BOTTOM_,this.svgGroup_.setAttribute("transform","translate("+this.left_+","+this.top_+")"))};
Blockly.WarningIndicator.prototype.updateWarningAndErrorCount=function(){this.errorCount_.textContent=this.workspace_.getWarningHandler().errorCount;this.warningCount_.textContent=this.workspace_.getWarningHandler().warningCount};Blockly.WarningIndicator.prototype.updateCurrentWarningAndError=function(d,e){var h=this.workspace_.getWarningHandler();e++;d++;this.errorCount_.textContent=e+"/"+h.errorCount;this.warningCount_.textContent=d+"/"+h.warningCount};
Blockly.WarningIndicator.prototype.updateWarningToggleText=function(){this.workspace_.getWarningHandler().showWarningsToggle?this.warningToggleText_.textContent=Blockly.Msg.HIDE_WARNINGS:this.warningToggleText_.textContent=Blockly.Msg.SHOW_WARNINGS};Blockly.WarningIndicator.prototype.onclickWarningToggle=function(){Blockly.hideChaff();window.parent.BlocklyPanel_callToggleWarning()};Blockly.WarningIndicator.prototype.onclickWarningNavPrevious=function(){Blockly.hideChaff();this.workspace_.getWarningHandler().previousWarning()};
Blockly.WarningIndicator.prototype.onclickWarningNavNext=function(){Blockly.hideChaff();this.workspace_.getWarningHandler().nextWarning()};Blockly.WarningIndicator.prototype.onclickErrorNavPrevious=function(){Blockly.hideChaff();this.workspace_.getWarningHandler().previousError()};Blockly.WarningIndicator.prototype.onclickErrorNavNext=function(){Blockly.hideChaff();this.workspace_.getWarningHandler().nextError()};Blockly.WarningIndicator.prototype.position=function(d,e){this.position_(d)};
Blockly.WarningIndicator.prototype.getBoundingRectangle=function(){return new Blockly.utils.Rect(this.left_,this.left_+120,this.top_,this.top_+this.INDICATOR_HEIGHT_)};/*

 @fileoverview Visual blocks editor for MIT App Inventor
 Instrumentation extensions to Blockly Workspace

 @author ewpatton@mit.edu (Evan W. Patton)
*/
AI.Blockly.Workspace={};Blockly.Workspace.prototype.arranged_type_=null;Blockly.Workspace.prototype.arranged_latest_position_=null;Blockly.Workspace.prototype.arranged_position_=null;Blockly.Workspace.prototype.resetArrangements=function(){this.arranged_position_=this.arranged_type_=null};Blockly.Workspace.prototype.warningIndicator_=null;Blockly.Workspace.prototype.getWarningIndicator=function(){return this.warningIndicator_};
Blockly.Workspace.prototype.setWarningIndicator=function(d){this.warningIndicator_=d};Blockly.Workspace.prototype.addTopBlock=function(d){if(d.isWrapped)return d;var e=function(h){h.workspace==Blockly.common.getMainWorkspace()&&Blockly.common.getMainWorkspace().resetArrangements();d.call(this,h);this.warningIndicator&&this.warningIndicator.updateWarningAndErrorCount()};e.isWrapped=!0;return e}(Blockly.Workspace.prototype.addTopBlock);
Blockly.Workspace.prototype.removeTopBlock=function(d){if(d.isWrapped)return d;var e=function(h){h.workspace==Blockly.common.getMainWorkspace()&&Blockly.common.getMainWorkspace().resetArrangements();d.call(this,h)};e.isWrapped=!0;return e}(Blockly.Workspace.prototype.removeTopBlock);Blockly.Workspace.prototype.dispose=function(d){if(d.isWrapped)return d;var e=function(){d.call(this);this.warningIndicator_&&(this.warningIndicator_.dispose(),this.warningIndicator_=null)};e.isWrapped=!0;return e}(Blockly.Workspace.prototype.dispose);/*

 @fileoverview Visual blocks editor for MIT App Inventor
 App Inventor extensions to Blockly's SVG Workspace

 @author ewpatton@mit.edu (Evan W. Patton)
*/
AI.Blockly.WorkspaceSvg={};Blockly.WorkspaceSvg.prototype.drawer_=null;Blockly.WorkspaceSvg.prototype.backpack_=null;Blockly.WorkspaceSvg.prototype.componentDb_=null;Blockly.WorkspaceSvg.prototype.typeBlock_=null;Blockly.WorkspaceSvg.prototype.flydown_=null;Blockly.WorkspaceSvg.prototype.blocksNeedingRendering=null;Blockly.WorkspaceSvg.prototype.chromeHidden=!1;
Blockly.WorkspaceSvg.prototype.createDom=function(d){if(d.isWrapped)return d;var e=function(){var h=this,k=d.apply(this,Array.prototype.slice.call(arguments));k.addEventListener("dragenter",function(m){if(0<=m.dataTransfer.types.indexOf("Files")||0<=m.dataTransfer.types.indexOf("text/uri-list"))h.svgBackground_.style.fill="rgba(0, 255, 0, 0.3)",m.dataTransfer.dropEffect="copy",m.preventDefault()},!0);k.addEventListener("dragover",function(m){if(0<=m.dataTransfer.types.indexOf("Files")||0<=m.dataTransfer.types.indexOf("text/uri-list"))h.svgBackground_.style.fill=
"rgba(0, 255, 0, 0.3)",m.dataTransfer.dropEffect="copy",m.preventDefault()},!0);k.addEventListener("dragleave",function(m){h.setGridSettings(h.options.gridOptions.enabled,h.getGrid().shouldSnap())},!0);k.addEventListener("dragexit",function(m){h.setGridSettings(h.options.gridOptions.enabled,h.getGrid().shouldSnap())},!0);k.addEventListener("drop",function(m){h.setGridSettings(h.options.gridOptions.enabled,h.getGrid().shouldSnap());if(0<=m.dataTransfer.types.indexOf("Files")){if("image/png"===m.dataTransfer.files.item(0).type){m.preventDefault();
var p=Blockly.common.getMainWorkspace().getMetrics(),t=Blockly.utils.browserEvents.mouseToSvg(m,h.getParentSvg(),h.getInverseScreenCTM());t.x=(t.x+p.viewLeft)/h.scale;t.y=(t.y+p.viewTop)/h.scale;Blockly.importPngAsBlock(h,t,m.dataTransfer.files.item(0))}}else if(0<=m.dataTransfer.types.indexOf("text/uri-list")&&(p=m.dataTransfer.getData("text/uri-list"),p.match(/\.png$/))){m.preventDefault();var q=new XMLHttpRequest;q.onreadystatechange=function(){if(4===q.readyState&&200===q.status){var y=Blockly.common.getMainWorkspace().getMetrics(),
I=Blockly.utils.browserEvents.mouseToSvg(m,h.getParentSvg(),h.getInverseScreenCTM());I.x=(I.x+y.viewLeft)/h.scale;I.y=(I.y+y.viewTop)/h.scale;Blockly.importPngAsBlock(h,I,q.response)}};q.responseType="blob";q.open("GET",p,!0);q.send()}});return k};e.isWrapper=!0;return e}(Blockly.WorkspaceSvg.prototype.createDom);Blockly.WorkspaceSvg.prototype.dispose=function(d){if(d.isWrapped)return d;var e=function(){d.call(this);if(this.backpack_)return this.backpack_.dispose(),null};e.isWrapped=!0;return e}(Blockly.WorkspaceSvg.prototype.dispose);
Blockly.WorkspaceSvg.prototype.addWarningHandler=function(){this.warningHandler_||(this.warningHandler_=new Blockly.WarningHandler(this))};Blockly.WorkspaceSvg.prototype.addWarningIndicator=function(){if(!this.options.readOnly&&null==this.warningIndicator_){this.warningHandler_||(this.warningHandler_=new Blockly.WarningHandler(this));this.warningIndicator_=new Blockly.WarningIndicator(this);var d=this.warningIndicator_.createDom();this.getSvgGroup().appendChild(d);this.warningIndicator_.init()}};
Blockly.WorkspaceSvg.prototype.addBackpack=function(){AI.Blockly.Backpack&&!this.options.readOnly&&(this.backpack_=new AI.Blockly.Backpack(this,{scrollbars:!0,media:"./assets/",disabledPatternId:this.options.disabledPatternId,renderer:"geras2_renderer"}),this.backpack_.init())};Blockly.WorkspaceSvg.prototype.setScale=function(d){if(d.isWrapped)return d;var e=function(h){d.call(this,h);this.backpack_&&this.backpack_.flyout_.reflow()};e.isWrapped=!0;return e}(Blockly.WorkspaceSvg.prototype.setScale);
Blockly.WorkspaceSvg.prototype.hideDrawer=function(){this.drawer_&&this.drawer_.hide();return this};Blockly.WorkspaceSvg.prototype.showBuiltin=function(d){this.drawer_&&this.drawer_.showBuiltin(d);return this};Blockly.WorkspaceSvg.prototype.showGeneric=function(d){this.drawer_&&this.drawer_.showGeneric(d);return this};Blockly.WorkspaceSvg.prototype.showComponent=function(d){this.drawer_&&this.drawer_.showComponent(d);return this};
Blockly.WorkspaceSvg.prototype.isDrawerShowing=function(){return this.drawer_?this.drawer_.isShowing():!1};Blockly.WorkspaceSvg.prototype.getComponentDatabase=function(){return this.targetWorkspace?this.targetWorkspace.getComponentDatabase():this.componentDb_};Blockly.WorkspaceSvg.prototype.getProcedureDatabase=function(){return this.targetWorkspace?this.targetWorkspace.getProcedureDatabase():this.procedureDb_};
Blockly.WorkspaceSvg.prototype.addScreen=function(d){if(this.targetWorkspace)return this.targetWorkspace.addScreen(d);-1==this.screenList_.indexOf(d)&&(this.screenList_.push(d),this.typeBlock_.needsReload.screens=!0)};Blockly.WorkspaceSvg.prototype.removeScreen=function(d){if(this.targetWorkspace)return this.targetWorkspace.removeScreen(d);d=this.screenList_.indexOf(d);-1!=d&&(this.screenList_.splice(d,1),this.typeBlock_.needsReload.screens=!0)};
Blockly.WorkspaceSvg.prototype.getScreenList=function(){return this.targetWorkspace?this.targetWorkspace.getScreenList():this.screenList_};Blockly.WorkspaceSvg.prototype.addAsset=function(d){if(this.targetWorkspace)return this.targetWorkspace.addAsset(d);this.assetList_.includes(d)||(this.assetList_.push(d),this.typeBlock_.needsReload.assets=!0)};
Blockly.WorkspaceSvg.prototype.removeAsset=function(d){if(this.targetWorkspace)return this.targetWorkspace.removeAsset(d);d=this.assetList_.indexOf(d);-1!=d&&(this.assetList_.splice(d,1),this.typeBlock_.needsReload.assets=!0)};Blockly.WorkspaceSvg.prototype.getAssetList=function(){return this.targetWorkspace?this.targetWorkspace.getAssetList():this.assetList_};
Blockly.WorkspaceSvg.prototype.getProviderModelList=function(){if(this.targetWorkspace)return this.targetWorkspace.getProviderModelList();if(!top.chatproxyinfo)return[];var d=top.chatproxyinfo.model;return d?Object.keys(d):[]};Blockly.WorkspaceSvg.prototype.getProviderList=function(){if(this.targetWorkspace)return this.targetWorkspace.getProviderList();if(!top.chatproxyinfo)return[];var d=top.chatproxyinfo.provider;return d?d:[]};
Blockly.WorkspaceSvg.prototype.addComponent=function(d,e,h){this.componentDb_.addInstance(d,e,h)&&(this.typeBlock_.needsReload.components=!0);return this};
Blockly.WorkspaceSvg.prototype.removeComponent=function(d){var e=this.componentDb_.getInstance(d);this.drawer_&&e.name===this.drawer_.lastComponent&&this.drawer_.hide();if(!this.componentDb_.removeInstance(d))return this;this.typeBlock_.needsReload.components=!0;d=this.getAllBlocks();for(var h=0,k;k=d[h];++h)"Component"==k.category&&k.getFieldValue("COMPONENT_SELECTOR")==e.name&&k.dispose(!0);Blockly.hideChaff();return this};
Blockly.WorkspaceSvg.prototype.renameComponent=function(d,e,h){if(!this.componentDb_.renameInstance(d,e,h))return console.log("Renaming: No such component instance "+e+"; aborting."),this;this.typeBlock_.needsReload.components=!0;d=this.getAllBlocks();for(var k=0,m;m=d[k];++k)"Component"==m.category&&m.rename(e,h)&&this.blocksNeedingRendering.push(m);Blockly.hideChaff();return this};
Blockly.WorkspaceSvg.prototype.populateComponentTypes=function(d,e){this.componentDb_.populateTypes(JSON.parse(d));this.componentDb_.populateTranslations(e)};
Blockly.WorkspaceSvg.prototype.loadBlocksFile=function(d,e){if(0!=e.length){try{Blockly.Events.disable();this.isClearing=this.isLoading=!0;if(Blockly.Versioning.upgrade(d,e,this)){var h=this;setTimeout(function(){h.fireChangeListener(new AI.Events.ForceSave(h))})}this.getAllBlocks().forEach(function(k){if(("lexical_variable_set"==k.type||"lexical_variable_get"==k.type)&&k.eventparam){var m=k.eventparam;k.fieldVar_.setValue(m);k.eventparam=m;k.workspace.requestErrorChecking(k)}})}finally{this.isClearing=
this.isLoading=!1,Blockly.Events.enable()}null!=this.getCanvas()&&this.render()}return this};Blockly.WorkspaceSvg.prototype.verifyAllBlocks=function(){for(var d=this.getAllBlocks(),e=0,h;h=d[e];++e)"Component"==h.category&&h.verify();return this};Blockly.WorkspaceSvg.prototype.saveBlocksFile=function(d){return Blockly.SaveFile.get(d,this)};Blockly.WorkspaceSvg.prototype.getFormYail=function(d,e,h){return AI.Yail.getFormYail(d,e,!!h,this)};
Blockly.WorkspaceSvg.prototype.getWarningHandler=function(){this.warningHandler_||(this.warningHandler_=new Blockly.WarningHandler(this));return this.warningHandler_};Blockly.WorkspaceSvg.prototype.getWarningIndicator=function(){return this.warningIndicator_};Blockly.WorkspaceSvg.prototype.exportBlocksImageToUri=function(d){AI.Blockly.ExportBlocksImage.getUri(d,this)};Blockly.WorkspaceSvg.prototype.getFlydown=function(){return this.flydown_};
Blockly.WorkspaceSvg.prototype.hideChaff=function(d){return function(e){this.flydown_&&this.flydown_.hide();e||this.backpack_&&this.backpack_.hide();this.scrollbar&&this.scrollbar.setContainerVisible(!0);d.apply(this,arguments)}}(Blockly.WorkspaceSvg.prototype.hideChaff);Blockly.WorkspaceSvg.prototype.markFocused=function(){this.options.parentWorkspace?this.options.parentWorkspace.markFocused():this.targetWorkspace?this.targetWorkspace.markFocused():(Blockly.common.setMainWorkspace(this),this.getParentSvg().focus({preventScroll:!0}))};
Blockly.WorkspaceSvg.prototype.resize=function(d){return function(){d.call(this);this.warningIndicator_&&this.warningIndicator_.position_&&this.warningIndicator_.position_();return this}}(Blockly.WorkspaceSvg.prototype.resize);
Blockly.WorkspaceSvg.prototype.recordDeleteAreas=function(){this.deleteAreaTrash_=this.trashcan?this.trashcan.getClientRect():null;this.isMutator?this.getFlyout(!0)?this.deleteAreaToolbox_=this.getFlyout(!0).getClientRect():this.getToolbox()?this.deleteAreaToolbox_=this.getToolbox().getClientRect():this.deleteAreaToolbox_=null:this.deleteAreaToolbox_=null};Blockly.WorkspaceSvg.prototype.getBackpack=function(){return this.backpack_};
Blockly.WorkspaceSvg.prototype.hasBackpack=function(){return null!=this.backpack_};
Blockly.WorkspaceSvg.prototype.onMouseWheel=function(d){this.cancelCurrentGesture();if(3==d.eventPhase){if(1==d.ctrlKey){if(0==d.deltaY){d.preventDefault();return}var e=0<d.deltaY?-1:1,h=Blockly.utils.browserEvents.mouseToSvg(d,this.getParentSvg(),this.getInverseScreenCTM());this.zoom(h.x,h.y,e)}else this.scrollX-=d.deltaX,this.scrollY-=d.deltaY,this.grid&&this.grid.update(this.scale),this.scrollbar?this.scrollbar.resize():this.translate(this.scrollX,this.scrollY);d.preventDefault()}};
Blockly.WorkspaceSvg.prototype.setGridSettings=function(d,e){this.options.gridOptions.enabled=d;this.getGrid().setSnapToGrid(d&&e);this.svgBackground_&&(this.options.gridOptions.enabled?this.svgBackground_.setAttribute("style","fill: url(#"+this.options.gridPattern.id+");"):(d=Blockly.common.getMainWorkspace().getTheme().componentStyles.workspaceBackgroundColour??"white",this.svgBackground_.setAttribute("style",`fill: ${d};`)))};
Blockly.WorkspaceSvg.prototype.buildComponentMap=function(d,e,h,k){d={components:{},globals:[]};e=this.getTopBlocks(!0);for(h=0;k=e[h];h++)if(k.category)if("procedures_defnoreturn"==k.type||"procedures_defreturn"==k.type||"global_declaration"==k.type)d.globals.push(k);else if("Component"==k.category){var m=k.instanceName;"event"==k.blockType&&(k.isGeneric?d.globals.push(k):(d.components[m]||(d.components[m]=[]),d.components[m].push(k)))}d.globals.sort(function(p,t){p="procedures_defnoreturn"==p.type||
"procedures_defreturn"==p.type;t="procedures_defnoreturn"==t.type||"procedures_defreturn"==t.type;return p&&!t?-1:!p&&t?1:0});return d};Blockly.WorkspaceSvg.prototype.getTopWorkspace=function(){for(var d=this;d.targetWorkspace;)d=d.targetWorkspace;return d};
Blockly.WorkspaceSvg.prototype.fireChangeListener=function(d){Blockly.Workspace.prototype.fireChangeListener.call(this,d);if(d instanceof Blockly.Events.BlockMove){var e=Blockly.Workspace.getById(d.workspaceId);d.group!==e.arrange_blocks_event_group_&&(e.arranged_latest_position_=null,e.arranged_position_=null,e.arranged_type_=null);e=this.blockDB.get(d.oldParentId);d=this.blockDB.get(d.blockId);e&&this.requestErrorChecking(e);d&&this.requestErrorChecking(d)}};
Blockly.WorkspaceSvg.prototype.requestRender=function(d){this.pendingRender||(this.needsRendering=[],this.pendingBlockIds={},this.pendingRenderFunc=function(){try{this.render(0===this.needsRendering.length?void 0:this.needsRendering)}finally{this.pendingRender=null}}.bind(this),"none"===this.getSvgGroup().parentElement.parentElement.parentElement.style.display?this.pendingRender=!0:this.pendingRender=setTimeout(this.pendingRenderFunc,0));if(d){for(;d.getParent();)d=d.getParent();d.id in this.pendingBlockIds||
(this.pendingBlockIds[d.id]=!0,this.needsRendering.push(d))}};
Blockly.WorkspaceSvg.prototype.requestErrorChecking=function(d){if(this.warningHandler_&&!this.checkAllBlocks)if(this.pendingErrorCheck||(this.needsErrorCheck=[],this.pendingErrorBlockIds={},this.checkAllBlocks=!!d,this.pendingErrorCheck=setTimeout(function(){try{var h=this.getWarningHandler();if(h)for(const k of this.checkAllBlocks?this.getAllBlocks():this.needsErrorCheck)h.checkErrors(k)}finally{this.pendingErrorCheck=null,this.checkAllBlocks=!1,this.pendingErrorBlockIds=this.needsErrorCheck=null}}.bind(this))),
!d||d.id in this.pendingErrorBlockIds)d||(this.checkAllBlocks=!0);else{for(;d.getParent();)d=d.getParent();for(var e=[d];0<e.length;)d=e.shift(),d.id in this.pendingErrorBlockIds||(this.pendingErrorBlockIds[d.id]=!0,this.needsErrorCheck.push(d)),Array.prototype.push.apply(e,d.getChildren())}};Blockly.WorkspaceSvg.prototype.refreshBackpack=function(){this.backpack_&&this.backpack_.resize()};/*

 @fileoverview Visual blocks editor for MIT App Inventor
 Add additional functions to Blockly namespace

 @author ewpatton@mit.edu (Evan W. Patton)
*/
AI.Blockly.BLKS_HORIZONTAL=0;AI.Blockly.BLKS_VERTICAL=1;AI.Blockly.BLKS_CATEGORY=2;Blockly.INDENTED_VALUE=6;Blockly.pathToBlockly="./";Blockly.hideChaff=function(d){if(d.isWrapped)return d;var e=function(){var h=Array.prototype.slice.call(arguments);d.apply(this,h);Blockly.WorkspaceSvg.prototype.hideChaff.call(Blockly.common.getMainWorkspace(),h)};e.isWrapped=!0;return e}(Blockly.hideChaff);
Blockly.confirmDeletion=function(d){var e=Blockly.common.getMainWorkspace().getAllBlocks().length;null!=Blockly.common.getSelected()&&(e=Blockly.common.getSelected().getDescendants().length,Blockly.common.getSelected().nextConnection&&Blockly.common.getSelected().nextConnection.targetConnection&&(e-=Blockly.common.getSelected().nextConnection.targetBlock().getDescendants().length));if(3<=e)if(Blockly.Util&&Blockly.Util.Dialog){e=Blockly.Msg.WARNING_DELETE_X_BLOCKS.replace("%1",String(e));var h=top.BlocklyPanel_getOdeMessage("cancelButton"),
k=top.BlocklyPanel_getOdeMessage("deleteButton"),m=new Blockly.Util.Dialog(Blockly.Msg.CONFIRM_DELETE,e,k,!0,h,0,function(p){m.hide();p==k?(Blockly.common.getMainWorkspace().getAudioManager().play("delete"),d(!0)):d(!1)})}else(e=confirm(Blockly.Msg.WARNING_DELETE_X_BLOCKS.replace("%1",String(e))))&&Blockly.common.getMainWorkspace().getAudioManager().play("delete"),d(e);else Blockly.common.getMainWorkspace().getAudioManager().play("delete"),d(!0)};AI.Blockly.BackpackFlyout=class extends Blockly.VerticalFlyout{constructor(d){super(d);this.toolboxPosition_=d.RTL?Blockly.utils.toolbox.Position.LEFT:Blockly.utils.toolbox.Position.RIGHT}};AI.Blockly.BackpackFlyout.prototype.createDom=function(d){Blockly.Flyout.prototype.createDom.call(this,d);this.svgBackground_.setAttribute("class","blocklybackpackFlyoutBackground");return this.svgGroup_};
AI.Blockly.BackpackFlyout.prototype.dispose=function(){this.hide();Blockly.browserEvents.unbind(this.eventWrappers_);this.eventWrappers_.length=0;this.scrollbar&&(this.scrollbar.dispose(),this.scrollbar=null);this.workspace_=null;this.svgGroup_&&(Blockly.utils.dom.removeNode(this.svgGroup_),this.svgGroup_=null);this.targetWorkspace=this.svgBackground_=null};AI.Blockly.BackpackFlyout.prototype.isBlockCreatable_=function(d){return!0};
AI.Blockly.BackpackFlyout.terminateDrag_=function(){AI.Blockly.BackpackFlyout.onMouseUpWrapper_&&(Blockly.browserEvents.unbind(AI.Blockly.BackpackFlyout.onMouseUpWrapper_),AI.Blockly.BackpackFlyout.onMouseUpWrapper_=null);AI.Blockly.BackpackFlyout.onMouseMoveWrapper_&&(Blockly.browserEvents.unbind(AI.Blockly.BackpackFlyout.onMouseMoveWrapper_),AI.Blockly.BackpackFlyout.onMouseMoveWrapper_=null);AI.Blockly.BackpackFlyout.startDownEvent_=null;AI.Blockly.BackpackFlyout.startBlock_=null;AI.Blockly.BackpackFlyout.startFlyout_=
null};/*

 @fileoverview Visual blocks editor for App Inventor
 Methods to handle warnings in the block editor.

 @author jis@mit.edu (Jeffrey I. Schiller)
*/
AI.Blockly.Util={};void 0===Blockly.Util&&(Blockly.Util={});Blockly.Util.Dialog=function(d,e,h,k,m,p,t){this.title=d;this.content=e;this.size=p;this.buttonName=h;this.destructive=k;this.cancelButtonName=m;this.callback=t;this.buttonName&&this.display()};
Blockly.Util.Dialog.prototype={display:function(){this._dialog=top.BlocklyPanel_createDialog(this.title,this.content,this.buttonName,this.destructive,this.cancelButtonName,this.size,this.callback)},hide:function(){this._dialog&&(top.BlocklyPanel_hideDialog(this._dialog),this._dialog=null)},setContent:function(d){this._dialog&&top.BlocklyPanel_setDialogContent(this._dialog,d)}};
Blockly.convertCoordinates=function(d,e,h,k){k&&(e-=window.scrollX||window.pageXOffset,h-=window.scrollY||window.pageYOffset);var m=d.getParentSvg();d=m.createSVGPoint();d.x=e;d.y=h;e=m.getScreenCTM();k&&(e=e.inverse());e=d.matrixTransform(e);k||(e.x+=window.scrollX||window.pageXOffset,e.y+=window.scrollY||window.pageYOffset);return e};Blockly.getAbsoluteXY_=function(d,e){d=e.getSvgXY(d);return Blockly.convertCoordinates(e,d.x,d.y,!1)};
Blockly.getRelativeXY_=function(d){var e={x:0,y:0},h=d.getAttribute("x");h&&(e.x=parseInt(h,10));if(h=d.getAttribute("y"))e.y=parseInt(h,10);if(d=(d=d.getAttribute("transform"))&&d.match(/translate\(\s*([-\d.]+)([ ,]\s*([-\d.]+)\s*\))?/))e.x+=parseInt(d[1],10),d[3]&&(e.y+=parseInt(d[3],10));return e};AI.Blockly.Backpack=class extends Blockly.DragTarget{BPACK_CLOSED_="static/media/backpack-closed.png";BPACK_EMPTY_="static/media/backpack-empty.png";BPACK_FULL_="static/media/backpack-full.png";WIDTH_=80;HEIGHT_=75;MARGIN_TOP_=10;MARGIN_SIDE_=20;isLarge=!1;isAdded=!1;svgGroup_=null;svgBody_=null;left_=0;top_=0;MARGIN_HORIZONTAL_=20;MARGIN_VERTICAL_=20;id="aibackpack";constructor(d,e){super();this.id="backpack";e instanceof Blockly.Options?this.options=e:(e=e||{},this.options=new Blockly.Options(e),
this.options.disabledPatternId=e.disabledPatternId);this.workspace_=d;this.flyout_=new AI.Blockly.BackpackFlyout(this.options);this.noAsync_=!1;this.registerContextMenuItems()}init(){this.initialized_?console.trace("Extra call to Backpack.init()"):(this.initialized_=!0,this.workspace_.getComponentManager().addComponent({component:this,weight:2,capabilities:[Blockly.ComponentManager.Capability.AUTOHIDEABLE,Blockly.ComponentManager.Capability.DRAG_TARGET,Blockly.ComponentManager.Capability.POSITIONABLE]}),
this.createDom(this.workspace_),Blockly.browserEvents.bind(this.svgGroup_,"mousedown",this,this.openBackpack),Blockly.browserEvents.bind(this.svgGroup_,"contextmenu",this,this.openBackpackMenu),this.initialized_=!0,this.workspace_.resize())}getFlyout(){return this.flyout_}registerContextMenuItems(){Blockly.ContextMenuRegistry.registry.getItem("remove_from_backpack")||Blockly.ContextMenuRegistry.registry.register({displayText:Blockly.Msg.REMOVE_FROM_BACKPACK,preconditionFn:function(d){d=d.block.workspace;
if(d.isFlyout&&d.targetWorkspace){const e=d.targetWorkspace.getComponentManager().getComponent("backpack");if(e&&e.getFlyout().getWorkspace().id===d.id)return"enabled"}return"hidden"},callback:function(d){d.block.workspace.targetWorkspace.getComponentManager().getComponent("backpack").removeFromBackpack([d.block.id])},scopeType:Blockly.ContextMenuRegistry.ScopeType.BLOCK,id:"remove_from_backpack",weight:6})}getClientRect(){if(!this.svgGroup_)return null;const d=this.svgGroup_.getBoundingClientRect();
return new Blockly.utils.Rect(d.top+this.MARGIN_TOP_,d.bottom+this.MARGIN_TOP_,d.left-this.MARGIN_SIDE_,d.right-this.MARGIN_SIDE_)}getBoundingRectangle(){return new Blockly.utils.Rect(this.top_,this.top_+this.HEIGHT_,this.left_,this.left_+this.WIDTH_)}position(d,e){if(this.initialized_){var h=this.workspace_.scrollbar&&this.workspace_.scrollbar.canScrollHorizontally(),k=this.workspace_.scrollbar&&this.workspace_.scrollbar.canScrollVertically();d.toolboxMetrics.position===Blockly.TOOLBOX_AT_LEFT||
this.workspace_.horizontalLayout&&!this.workspace_.RTL?(this.left_=d.absoluteMetrics.left+d.viewMetrics.width-this.WIDTH_-this.MARGIN_HORIZONTAL_,h&&!this.workspace_.RTL&&(this.left_-=Blockly.Scrollbar.scrollbarThickness)):(this.left_=this.MARGIN_HORIZONTAL_,h&&this.workspace_.RTL&&(this.left_+=Blockly.Scrollbar.scrollbarThickness));d.toolboxMetrics.position===Blockly.TOOLBOX_AT_BOTTOM?(this.top_=d.absoluteMetrics.top+d.viewMetrics.height-this.HEIGHT_-this.MARGIN_VERTICAL_,k&&(this.top_-=Blockly.Scrollbar.scrollbarThickness)):
this.top_=d.absoluteMetrics.top+this.MARGIN_VERTICAL_;d=this.getBoundingRectangle();e=Blockly.uiPosition.bumpPositionRect(d,this.MARGIN_VERTICAL_,Blockly.uiPosition.bumpDirection.DOWN,e);this.top_=e.top;this.left_=e.left;this.svgGroup_.setAttribute("transform","translate("+this.left_+","+this.top_+")")}}onDragEnter(d){(d instanceof Blockly.BlockSvg||void 0!==d.toFlyoutInfo)&&this.setOpen_(!0)}onDragExit(){this.setOpen_(!1)}onDrop(d){try{if(d instanceof Blockly.BlockSvg)this.addToBackpack(d,!0);else if(void 0!==
d.toFlyoutInfo){const e=new Blockly.Workspace;e.targetWorkspace=this.workspace_;try{for(const h of d.toFlyoutInfo()){const k=Blockly.serialization.blocks.append(h,e);this.addToBackpack(k,!0)}}finally{e.dispose()}}}finally{this.setOpen_(!1)}}shouldPreventMove(d){console.trace("Drag element is",d);return d instanceof Blockly.BlockSvg}createDom(d){d=d||Blockly.common.getMainWorkspace();let e=this.flyout_.createDom(Blockly.utils.Svg.SVG);this.flyout_.svgBackground_.setAttribute("class","blocklybackpackFlyoutBackground");
d.getParentSvg().parentNode.appendChild(e);this.flyout_.init(d);this.svgGroup_=Blockly.utils.dom.createSvgElement("g",{},null);this.svgBody_=Blockly.utils.dom.createSvgElement("image",{width:this.WIDTH_,height:this.HEIGHT_},this.svgGroup_);this.svgBody_.setAttributeNS("http://www.w3.org/1999/xlink","xlink:href",Blockly.pathToBlockly+this.BPACK_CLOSED_);this.svgBody_.setAttribute("class","blocklybackpackImage");Blockly.utils.dom.insertAfter(this.svgGroup_,this.workspace_.getBubbleCanvas())}autoHide(){this.flyout_.hide()}dispose(){this.svgGroup_&&
(this.svgGroup_.remove(),this.svgGroup_=null);this.flyout_.dispose();this.flyout_=null}pasteBackpack(){this.getContents().then(d=>{if(void 0!==d&&0!==d.length){var e=null,h=new Blockly.Workspace;h.targetWorkspace=this.workspace_;try{Blockly.Events.setGroup(!0);for(let k=0;k<d.length;k++){const m=Blockly.utils.xml.textToDom(d[k]).childNodes[0],p=[];this.checkValidBlockTypes(m,p);let t=!0;for(let q=0;q<p.length;q++){const y=p[q];if(!Blockly.Blocks[y]&&!this.workspace_.getComponentDatabase().hasType(y)){t=
!1;break}}if(t){const q=Blockly.Xml.domToBlock(m,h),y={paster:Blockly.clipboard.BlockPaster.TYPE,blockState:Blockly.serialization.blocks.save(q,{addNextBlocks:!1}),typeCounts:Blockly.common.getBlockTypeCounts(q,!0)},I=Blockly.clipboard.paste(y,this.workspace_);I&&(e=I)}else window.alert('Sorry. You cannot paste a block of type "'+type+"\" because it doesn't exist in this workspace.")}}finally{Blockly.Events.setGroup(!1),h.dispose()}e&&Blockly.common.setSelected(e)}})}checkValidBlockTypes(d,e){"block"===
d.nodeName&&e.push(d.getAttribute("type"));d=d.childNodes;for(let h=0;h<d.length;h++)this.checkValidBlockTypes(d[h],e)}addBlock(d){this.addToBackpack(d,!1);this.pendingSave_||(this.pendingSave_=!0,setTimeout(()=>{this.pendingSave_=!1;this.setContents(AI.Blockly.Backpack.contents,!0)},10))}addToBackpack(d,e){const h=Blockly.Xml.blockToDom(d);Blockly.Xml.deleteNext(h);d=d.getRelativeToSurfaceXY();h.setAttribute("x",this.workspace_.RTL?-d.x:d.x);h.setAttribute("y",d.y);this.getContents().then(k=>{k||=
[];k.push("<xml>"+Blockly.Xml.domToText(h)+"</xml>");this.setContents(k,e);this.grow();Blockly.common.getMainWorkspace().getAudioManager().play("backpack");this.flyout_.isVisible()&&(this.isAdded=!0,this.openBackpack(),this.isAdded=!1)})}addAllToBackpack(){const d=this.workspace_.getTopBlocks(!1);this.getContents().then(()=>{let e=this.noAsync_;try{this.noAsync_=!0;for(let h=0;h<d.length;h++)this.addToBackpack(d[h],!1)}finally{this.noAsync_=e}this.setContents(AI.Blockly.Backpack.contents,!0)})}removeFromBackpack(d){this.getContents().then(e=>
{if(e&&e.length){let h=this.flyout_.workspace_.getTopBlocks(!0).map(function(k){return k.id}).indexOf(d[0]);0<=h&&e.splice(h,1);this.setContents(e,!0);0===e.length&&this.shrink();this.flyout_.isVisible()&&(this.isAdded=!0,this.openBackpack(),this.isAdded=!1)}})}getContents(){return AI.Blockly.Backpack.backPackId&&!this.noAsync_?new Promise((d,e)=>{top.BlocklyPanel_getSharedBackpack(AI.Blockly.Backpack.backPackId,h=>{AI.Blockly.Backpack.contents=h?JSON.parse(h):[];this.resize();d(AI.Blockly.Backpack.contents)})}):
Promise.resolve(AI.Blockly.Backpack.contents)}setContents(d,e){AI.Blockly.Backpack.contents=d;e&&(AI.Blockly.Backpack.backPackId?top.BlocklyPanel_storeSharedBackpack(AI.Blockly.Backpack.backPackId,JSON.stringify(d)):top.BlocklyPanel_storeBackpack(JSON.stringify(d)))}resize(){0<AI.Blockly.Backpack.contents.length?this.grow():this.shrink()}hide(){this.flyout_.hide()}close(){this.setOpen_(!1)}clear(){this.confirmClear()&&(this.setContents([],!0),this.shrink())}confirmClear(){return confirm(Blockly.Msg.BACKPACK_CONFIRM_EMPTY)}getCount(){return AI.Blockly.Backpack.contents?
AI.Blockly.Backpack.contents.length:0}grow(){this.isLarge||(this.svgBody_.setAttributeNS("http://www.w3.org/1999/xlink","xlink:href",Blockly.pathToBlockly+this.BPACK_FULL_),this.svgBody_.setAttribute("transform","scale(1.2)"),this.MARGIN_SIDE_/=1.2,this.HEIGHT_*=1.2,this.WIDTH_*=1.2,this.isLarge=!0)}shrink(){this.isLarge&&(this.svgBody_.setAttributeNS("http://www.w3.org/1999/xlink","xlink:href",Blockly.pathToBlockly+this.BPACK_CLOSED_),this.svgBody_.setAttribute("transform","scale(1)"),this.HEIGHT_/=
1.2,this.WIDTH_/=1.2,this.MARGIN_SIDE_*=1.2,this.isLarge=!1)}animateBackpack_(){let d=this.svgBody_;this.isOpen?d.setAttributeNS("http://www.w3.org/1999/xlink","xlink:href",Blockly.pathToBlockly+this.BPACK_EMPTY_):this.isLarge?d.setAttributeNS("http://www.w3.org/1999/xlink","xlink:href",Blockly.pathToBlockly+this.BPACK_FULL_):d.setAttributeNS("http://www.w3.org/1999/xlink","xlink:href",Blockly.pathToBlockly+this.BPACK_CLOSED_)}setOpen_(d){this.isOpen!=d&&(this.isOpen=d,this.animateBackpack_())}containsBlock(d){return!1}};
AI.Blockly.Backpack.contents=[];AI.Blockly.Backpack.backPackId=!1;
AI.Blockly.Backpack.prototype.openBackpackMenu=function(d){var e=[],h={enabled:!0};h.text=Blockly.Msg.SHOW_BACKPACK_DOCUMENTATION;h.callback=function(){var k=new Blockly.Util.Dialog(Blockly.Msg.BACKPACK_DOC_TITLE,Blockly.Msg.BACKPACK_DOCUMENTATION,Blockly.Msg.REPL_OK,!1,null,0,function(){k.hide()})};e.push(h);h={enabled:!0};h.text=Blockly.Msg.BACKPACK_EMPTY;h.callback=function(){Blockly.common.getMainWorkspace().hasBackpack()&&Blockly.common.getMainWorkspace().getBackpack().clear()};e.push(h);Blockly.ContextMenu.show(d,
e,this.workspace_.RTL)};AI.Blockly.Backpack.prototype.openBackpack=function(d){if(d&&(d.stopPropagation(),2===d.button)){this.flyout_.hide();this.openBackpackMenu(d);return}!this.isAdded&&this.flyout_.isVisible()?this.flyout_.hide():this.getContents().then(e=>{const h=e.length,k=[];for(let m=0;m<h;m++)k[m]=Blockly.Versioning.upgradeComponentMethods(Blockly.utils.xml.textToDom(e[m]).firstChild);Blockly.hideChaff();this.flyout_.show(k)})};
AI.Blockly.Backpack.prototype.onMouseUp=function(d,e){d=Blockly.common.getSelected().getRelativeToSurfaceXY();e=Blockly.utils.Coordinate.difference(e,d);Blockly.common.getSelected().moveBy(e.x,e.y);Blockly.common.getMainWorkspace().render()};AI.Blockly.Backpack.prototype.onMouseMove=function(d){this.svgGroup_&&(d=this.mouseIsOver(d),this.isOpen!=d&&this.setOpen_(d))};
AI.Blockly.Backpack.prototype.mouseIsOver=function(d){var e=Blockly.convertCoordinates(Blockly.common.getMainWorkspace(),d.clientX,d.clientY,!0);d=e.x;e=e.y;return d>this.left_&&d<this.left_+this.WIDTH_&&e>this.top_&&e<this.top_+this.HEIGHT_};/*

 @fileoverview Visual blocks editor for MIT App Inventor
 Add additional "class methods" to Blockly.Block

 @author ewpatton@mit.edu (Evan W. Patton)
*/
AI.Blockly.Block={};Blockly.Block.mutationToDom=function(){var d=details.mutationToDomFunc?details.mutationToDomFunc():document.createElement("mutation");d.setAttribute("is_statement",this.isStatement||!1);return d};
Blockly.Block.prototype.interpolateMsg=function(d,e){function h(Q){if(Q instanceof Blockly.Field)this.appendField(Q);else{if(!Array.isArray(Q))throw Error("Field must be a Field or a tuple.");this.appendField(Q[1],Q[0])}}if("string"!==typeof d)throw Error("Message must be a string.");var k=arguments[arguments.length-1];if(k!==Blockly.inputs.Align.LEFT&&k!==Blockly.inputs.Align.CENTRE&&k!==Blockly.inputs.Align.RIGHT)throw Error(`Illegal final argument "${k}" is not an alignment.`);--arguments.length;
for(var m=d.split(this.interpolateMsg.SPLIT_REGEX_),p=[],t=0;t<m.length;t+=2){var q=m[t].trim(),y=void 0;q&&p.push(new Blockly.FieldLabel(q));if((q=m[t+1])&&"%"==q.charAt(0)){var I=parseInt(q.substring(1),10),L=arguments[I];if(!Array.isArray(L))throw Error(`Argument "${q}" is not a tuple.`);L[1]instanceof Blockly.Field?p.push([L[0],L[1]]):y=this.appendValueInput(L[0]).setCheck(L[1]).setAlign(L[2]);arguments[I]=null}else"\n"==q&&p.length&&(y=this.appendDummyInput());y&&p.length&&(p.forEach(h,y),p=
[])}p.length&&(y=this.appendDummyInput().setAlign(k),p.forEach(h,y));for(t=1;t<arguments.length-1;t++)if(null!==arguments[t])throw Error(`Input "%${t}" not used in message: "${d}"`);this.setInputsInline(!d.match(this.interpolateMsg.INLINE_REGEX_))};Blockly.Block.prototype.isolate=function(d){this.unplug(d);for(var e=this.childBlocks_.length-1;0<=e;e--)this.childBlocks_[e].unplug(d)};Blockly.Block.prototype.interpolateMsg.SPLIT_REGEX_=/(%\d+|\n)/;
Blockly.Block.prototype.interpolateMsg.INLINE_REGEX_=/%1\s*$/;Blockly.Block.prototype.walk=function(d){function e(h,k){d(h,k);h.inputList.forEach(function(m){(m.type===Blockly.inputs.inputTypes.VALUE||m.type===Blockly.inputs.inputTypes.STATEMENT)&&m.connection&&m.connection.targetBlock()&&e(m.connection.targetBlock(),k+1);h.nextConnection&&h.nextConnection.targetBlock()&&e(h.nextConnection.targetBlock(),k)})}e(this,0)};Blockly.Block.prototype.domToMutation=null;
Blockly.Block.prototype.mutationToDom=null;Blockly.Block.prototype.badBlock=function(){this.isBad=!0};Blockly.Block.prototype.notBadBlock=function(){this.isBad=!1};Blockly.Block.prototype.getTopWorkspace=function(){for(var d=this.workspace;d.targetWorkspace;)d=d.targetWorkspace;return d};/*

 @fileoverview Object representing a warning for MIT App Inventor.
 @author mckinney@mit.edu (Andrew F. McKinney)
 @author fraser@google.com (Neil Fraser)
 @author ewpatton@mit.edu (Evan W. Patton)
*/
AI.ErrorIcon=class extends Blockly.icons.Icon{constructor(d){super(d);this.text_={};this.textBubble=null;this.bubbleSize=new Blockly.utils.Size(160,80)}getType(){return AI.ErrorIcon.TYPE}initView(d){this.svgRoot||(super.initView(d),Blockly.utils.dom.createSvgElement("circle",{"class":"blocklyErrorIconOutline",r:AI.ErrorIcon.ICON_RADIUS,cx:AI.ErrorIcon.ICON_RADIUS,cy:AI.ErrorIcon.ICON_RADIUS},this.svgRoot),Blockly.utils.dom.createSvgElement("path",{"class":"blocklyErrorIconX",d:"M 4,4 12,12 8,8 4,12 12,4"},
this.svgRoot),Blockly.utils.dom.addClass(this.svgRoot,"blockly-icon-error"))}getSize(){return AI.ErrorIcon.SIZE}getWeight(){return 0}isShownWhenCollapsed(){return!1}updateCollapsed(){}isVisible(){return!!this.textBubble}setBubbleVisible(d){this.isBubbleVisible()!==d&&(d?(this.textBubble=new Blockly.bubbles.TextBubble(this.getText(),this.sourceBlock.workspace,this.getAnchorLocation(),this.getBubbleOwnerRect()),this.textBubble.setColour(this.sourceBlock.style.colourPrimary)):(this.textBubble.dispose(),
this.textBubble=null),Blockly.Events.fire(new (Blockly.Events.get(Blockly.Events.BUBBLE_OPEN))(this.sourceBlock,d,"error")))}getAnchorLocation(){var d=this.getSize();d=new Blockly.utils.Coordinate(d.width/2,d.height/2);return Blockly.utils.Coordinate.sum(this.workspaceLocation,d)}dispose(){super.dispose();this.textBubble&&this.textBubble.dispose()}onLocationChange(d){super.onLocationChange(d);this.textBubble&&this.textBubble.setAnchorLocation(this.getAnchorLocation())}isBubbleVisible(){return!!this.textBubble}onClick(){super.onClick();
this.setBubbleVisible(!this.isBubbleVisible())}getBubbleOwnerRect(){const d=this.sourceBlock.getSvgRoot().getBBox();return new Blockly.utils.Rect(d.y,d.y+d.height,d.x,d.x+d.width)}setText(d,e){this.text_[e]!==d&&(d?this.text_[e]=d:delete this.text_[e],this.isVisible()&&(this.setBubbleVisible(!1),this.setBubbleVisible(!0)))}getText(){const d=[];for(const e in this.text_)d.push(this.text_[e]);return d.join("\n")}};AI.ErrorIcon.ICON_RADIUS=8;AI.ErrorIcon.TYPE=new Blockly.icons.IconType("error");
AI.ErrorIcon.SIZE=new Blockly.utils.Size(2*AI.ErrorIcon.ICON_RADIUS,2*AI.ErrorIcon.ICON_RADIUS);Blockly.icons.registry.register(AI.ErrorIcon.TYPE,AI.ErrorIcon);/*

 @fileoverview Visual blocks editor for MIT App Inventor
 Instrumentation extensions to Blockly SVG

 @author ewpatton@mit.edu (Evan W. Patton)
*/
AI.Blockly.BlockSvg={};Blockly.BlockSvg.prototype.error=null;Blockly.BlockSvg.prototype.isBad=!1;Blockly.BlockSvg.prototype.setErrorIconText=function(d){if(!AI.ErrorIcon)throw"Warnings not supported.";if(!this.isDeadOrDying()){var e=!1;"string"===typeof d?(this.error||(this.error=new AI.ErrorIcon(this),this.addIcon(this.error),e=!0),this.error.setText(d)):this.error&&(this.removeIcon(this.error.getType()),this.error=null,e=!0);e&&this.workspace.requestRender(this)}};
Blockly.BlockSvg.isRenderingOn=!0;Blockly.BlockSvg.prototype.addBadBlock=function(){this.getSvgRoot()&&this.getSvgRoot().parentNode&&(Blockly.utils.dom.addClass(this.getSvgRoot(),"badBlock"),this.getSvgRoot().parentNode.appendChild(this.getSvgRoot()))};Blockly.BlockSvg.prototype.removeBadBlock=function(){this.getSvgRoot()&&this.getSvgRoot().parentNode&&(Blockly.utils.dom.removeClass(this.getSvgRoot(),"badBlock"),this.getSvgRoot().parentNode.appendChild(this.getSvgRoot()))};
Blockly.BlockSvg.prototype.isBadBlock=function(){return Blockly.utils.dom.hasClass(this.getSvgRoot(),"badBlock")};Blockly.BlockSvg.prototype.badBlock=function(){Object.getPrototypeOf(Blockly.BlockSvg.prototype).badBlock.call(this);if(this.workspace==Blockly.common.getMainWorkspace()){if("object"!=typeof this.getSvgRoot()||null==this.getSvgRoot())throw Error("Block is not rendered.");this.addBadBlock()}};
Blockly.BlockSvg.prototype.notBadBlock=function(){Object.getPrototypeOf(Blockly.BlockSvg.prototype).notBadBlock.call(this);if(this.workspace==Blockly.common.getMainWorkspace()){if("object"!=typeof this.getSvgRoot()||null==this.getSvgRoot())throw Error("Block is not rendered.");this.removeBadBlock()}};
Blockly.BlockSvg.prototype.dispose=function(d){if(d.isWrapped)return d;var e=function(h,k){var m=this.workspace;try{d.call(this,h,k)}finally{m&&m.getWarningHandler()&&m.getWarningHandler().checkDisposedBlock(this)}};e.isWrapped=!0;return e}(Blockly.BlockSvg.prototype.dispose);
Blockly.BlockSvg.prototype.showHelp=function(){var d="function"===typeof this.helpUrl?this.helpUrl():this.helpUrl;if(d){d=d.split("#");var e=top.location.href.match("[&?]locale=([a-zA-Z-]*)");e&&"en"!==e[1].toLowerCase()&&(d[0]+="?locale="+e[1]);window.open(d.join("#"))}};/*

 Copyright © 2016-2021 Massachusetts Institute of Technology. All rights reserved.
*/
AI.Blockly.ComponentDatabase={};Blockly.PROPERTY_READABLE=1;Blockly.PROPERTY_WRITEABLE=2;Blockly.PROPERTY_READWRITEABLE=3;ComponentInfo=function(){};HelperKey=function(){};ParameterDescriptor=function(){};EventDescriptor=function(){};MethodDescriptor=function(){};PropertyDescriptor=function(){};ComponentTypeDescriptor=function(){};ComponentInstanceDescriptor=function(){};Option=function(){};OptionList=function(){};
Blockly.ComponentDatabase=function(){this.instances_={};this.types_={};this.instanceNameUid_={};this.optionLists_={};this.filters_=[];this.i18nComponentTypes_={};this.i18nEventNames_={};this.i18nEventDescriptions_={};this.i18nMethodNames_={};this.i18nMethodDescriptions_={};this.i18nParamNames_={};this.i18nPropertyNames_={};this.i18nPropertyDescriptions_={};this.i18nOptionNames_={};this.i18nOptionListTags_={}};Blockly.ComponentDatabase.prototype.SUFFIX_REGEX=RegExp("^(.*?)([0-9]*)$");
Blockly.ComponentDatabase.prototype.addInstance=function(d,e,h){if(this.hasInstance(d))return!1;this.instances_[d]={uid:d,name:e,typeName:h};this.instanceNameUid_[e]=d;return!0};Blockly.ComponentDatabase.prototype.hasInstance=function(d){return d in this.instances_};Blockly.ComponentDatabase.prototype.getInstance=function(d){return this.instances_[d]||this.instances_[this.instanceNameUid_[d]]};
Blockly.ComponentDatabase.prototype.getContainer=function(d,e){d=this.getInstance(e);d=top.BlocklyPanel_getComponentContainerUuid(d.name);return this.getInstance(d)};Blockly.ComponentDatabase.prototype.renameInstance=function(d,e,h){if(!this.hasInstance(d)||e===h)return!1;this.instances_[d].name=h;delete this.instanceNameUid_[e];this.instanceNameUid_[h]=d;return!0};Blockly.ComponentDatabase.prototype.removeInstance=function(d){if(!this.hasInstance(d))return!1;delete this.instances_[d];return!0};
Blockly.ComponentDatabase.prototype.forEachInstance=function(d){for(const e in this.instances_)this.instances_.hasOwnProperty(e)&&d(this.instances_[e],e)};Blockly.ComponentDatabase.prototype.hasType=function(d){return d in this.types_};Blockly.ComponentDatabase.prototype.getType=function(d){return this.types_[d]};
Blockly.ComponentDatabase.prototype.getInstanceNames=function(){var d=[],e;for(e in this.instances_)this.instances_.hasOwnProperty(e)&&"object"==typeof this.instances_[e]&&d.push(this.instances_[e].name);return d};Blockly.ComponentDatabase.prototype.instanceNameToTypeName=function(d){return d in this.instanceNameUid_?this.instances_[this.instanceNameUid_[d]].typeName:!1};
Blockly.ComponentDatabase.prototype.getComponentUidNameMapByType=function(d){var e=[],h;for(h in this.instances_)this.instances_.hasOwnProperty(h)&&this.instances_[h].typeName==d&&e.push([this.instances_[h].name,h]);return e};
Blockly.ComponentDatabase.prototype.getComponentNamesByType=function(d){var e=[],h;for(h in this.instances_)if(this.instances_.hasOwnProperty(h)&&this.instances_[h].typeName==d){var k=this.instances_[h].name,m=k.match(this.SUFFIX_REGEX)||[k,"0"];e.push([k,k,m[1],parseInt(m[2]||"0",10)])}if(0==e.length)return[[" ","none"]];e.sort(function(p,t){return p[2]===t[2]?p[3]-t[3]:p[0]<t[0]?-1:p[0]>t[0]?1:0});return e};
Blockly.ComponentDatabase.prototype.getComponentTypes=function(){var d=[];const e=new Set;for(var h in this.instances_){var k=this.instances_[h].typeName;"Form"==k||e.has(k)||(e.add(k),d.push([this.i18nComponentTypes_[k],k]))}if(0==d.length)return[[" ","none"]];d.sort(function(m,p){return m[0]<p[0]?-1:m[0]>p[0]?1:0});return d};
Blockly.ComponentDatabase.prototype.populateTypes=function(d){for(var e,h,k,m=0,p;p=d[m];++m){var t=this.types_[p.name]={type:p.type,external:p.external,componentInfo:p,eventDictionary:{},methodDictionary:{},properties:{},setPropertyList:[],getPropertyList:[]};for(e=0;h=p.events[e];++e)"string"===typeof h.deprecated&&(h.deprecated=JSON.parse(h.deprecated)),void 0===h.parameters&&(h.parameters=this.processParameters(h.params),delete h.params),t.eventDictionary[h.name]=h;for(e=0;h=p.methods[e];++e)"string"===
typeof h.deprecated&&(h.deprecated=JSON.parse(h.deprecated)),void 0===h.parameters&&(h.parameters=this.processParameters(h.params),delete h.params),h.helper&&(h.returnHelperKey=this.processHelper(h.helper)),t.methodDictionary[h.name]=h;for(e=0;k=p.blockProperties[e];++e)t.properties[k.name]=k,"string"===typeof k.deprecated&&(k.deprecated=JSON.parse(k.deprecated)),k.helper&&(k.helperKey=this.processHelper(k.helper)),"read-write"==k.rw?(k.mutability=Blockly.PROPERTY_READWRITEABLE,t.getPropertyList.push(k.name),
t.setPropertyList.push(k.name)):"read-only"==k.rw?(k.mutability=Blockly.PROPERTY_READABLE,t.getPropertyList.push(k.name)):"write-only"==k.rw&&(k.mutability=Blockly.PROPERTY_WRITEABLE,t.setPropertyList.push(k.name));for(e=0;k=p.properties[e];++e){var q=t.properties[k.name];q&&Object.keys(k).forEach(function(y){q[y]=k[y]})}}};
Blockly.ComponentDatabase.prototype.processParameters=function(d){params=[];for(var e=0,h;h=d[e];e++){var k={};k.name=h.name;k.type=h.type;k.helperKey=this.processHelper(h.helper);params.push(k)}return params};Blockly.ComponentDatabase.prototype.processHelper=function(d){if(!d)return null;switch(d.type){case "OPTION_LIST":return this.processOptionList(d.data);case "ASSET":return this.processAssetHelper(d.data);case "PROVIDER_MODEL":return this.processProviderModelHelper(d.data);case "PROVIDER":return this.processProviderHelper(d.data)}return null};
Blockly.ComponentDatabase.prototype.processOptionList=function(d){if(!this.optionLists_[d.key]){for(var e=[],h=0,k;k=d.options[h];h++)e[h]=this.processOption(k);this.optionLists_[d.key]={className:d.className,tag:d.tag,defaultOpt:d.defaultOpt,underlyingType:d.underlyingType,options:e}}return{type:"OPTION_LIST",key:d.key}};Blockly.ComponentDatabase.prototype.processOption=function(d){return{name:d.name,value:d.value,description:d.description,deprecated:"true"==d.deprecated}};
Blockly.ComponentDatabase.prototype.processAssetHelper=function(d){var e=d.filter;if(!e||0==e.length)return{type:"ASSET",key:null};d=this.filters_.reduce(function(h,k,m){return-1!=h?h:k.every(function(p){return e.includes(p)})?m:-1},-1);-1==d&&(this.filters_.push(e),d=this.filters_.length-1);return{type:"ASSET",key:d}};Blockly.ComponentDatabase.prototype.processProviderModelHelper=function(d){d=d.filter;if(!d||0==d.length)return{type:"PROVIDER_MODEL",key:null}};
Blockly.ComponentDatabase.prototype.processProviderHelper=function(d){var e=d.filter;if(!e||0==e.length)return{type:"PROVIDER",key:null};d=this.filters_.reduce(function(h,k,m){return-1!=h?h:k.every(function(p){return e.includes(p)})?m:-1},-1);-1==d&&(this.filters_.push(e),d=this.filters_.length-1);return{type:"PROVIDER",key:d}};Blockly.ComponentDatabase.PROPDESC=/PropertyDescriptions$/;Blockly.ComponentDatabase.METHODDESC=/MethodDescrptions$/;Blockly.ComponentDatabase.EVENTDESC=/EventDescriptions$/;
Blockly.ComponentDatabase.prototype.populateTranslations=function(d){for(var e in d)if(d.hasOwnProperty(e)){var h=e.split("-",2),k=h[1],m=d[e];switch(h[0]){case "COMPONENT":this.i18nComponentTypes_[k]=m;break;case "PROPERTY":this.i18nPropertyNames_[k]=m;break;case "EVENT":this.i18nEventNames_[k]=m;break;case "METHOD":this.i18nMethodNames_[k]=m;break;case "PARAM":this.i18nParamNames_[k]=m;break;case "EVENTDESC":this.i18nEventDescriptions_[k]=m;break;case "METHODDESC":this.i18nMethodDescriptions_[k]=
m;break;case "PROPDESC":this.i18nPropertyDescriptions_[k]=m;break;case "OPTION":this.i18nOptionNames_[k]=m;break;case "OPTIONLIST":this.i18nOptionListTags_[k]=m}}};Blockly.ComponentDatabase.prototype.getEventForType=function(d,e){if(d in this.types_)return this.types_[d].eventDictionary[e]};Blockly.ComponentDatabase.prototype.forEventInType=function(d,e){if(d in this.types_){d=this.types_[d].eventDictionary;for(const [h,k]of Object.entries(d))k.deprecated||e(k,h)}};
Blockly.ComponentDatabase.prototype.getMethodForType=function(d,e){if(d in this.types_)return this.types_[d].methodDictionary[e]};Blockly.ComponentDatabase.prototype.forMethodInType=function(d,e){if(d in this.types_){d=this.types_[d].methodDictionary;for(const [h,k]of Object.entries(d))k.deprecated||e(k,h)}};Blockly.ComponentDatabase.prototype.getPropertyForType=function(d,e){return this.types_[d]&&this.types_[d].properties[e]?this.types_[d].properties[e]:null};
Blockly.ComponentDatabase.prototype.getSetterNamesForType=function(d){return d in this.types_?this.types_[d].setPropertyList:null};Blockly.ComponentDatabase.prototype.getGetterNamesForType=function(d){return d in this.types_?this.types_[d].getPropertyList:null};Blockly.ComponentDatabase.prototype.getOptionList=function(d){return this.optionLists_[d]};
Blockly.ComponentDatabase.prototype.forEachOptionList=function(d){for(const e in this.optionLists_)this.optionLists_.hasOwnProperty(e)&&d(this.optionLists_[e],e)};Blockly.ComponentDatabase.prototype.getFilter=function(d){return this.filters_[d]};Blockly.ComponentDatabase.prototype.getInternationalizedComponentType=function(d,e){return this.i18nComponentTypes_[d]||e||d};Blockly.ComponentDatabase.prototype.getInternationalizedEventName=function(d,e){return this.i18nEventNames_[d]||e||d};
Blockly.ComponentDatabase.prototype.getInternationalizedEventDescription=function(d,e,h){return this.i18nEventDescriptions_[d+"."+e+"EventDescriptions"]||this.i18nEventDescriptions_[e+"EventDescriptions"]||h||e};Blockly.ComponentDatabase.prototype.getInternationalizedMethodName=function(d,e){return this.i18nMethodNames_[d]||e||d};
Blockly.ComponentDatabase.prototype.getInternationalizedMethodDescription=function(d,e,h){return this.i18nMethodDescriptions_[d+"."+e+"MethodDescriptions"]||this.i18nMethodDescriptions_[e+"MethodDescriptions"]||h||e};Blockly.ComponentDatabase.prototype.getInternationalizedParameterName=function(d,e){return this.i18nParamNames_[d]||e||d};Blockly.ComponentDatabase.prototype.getInternationalizedPropertyName=function(d,e){return this.i18nPropertyNames_[d]||e||d};
Blockly.ComponentDatabase.prototype.getInternationalizedPropertyDescription=function(d,e,h){return this.i18nPropertyDescriptions_[d+"."+e+"PropertyDescriptions"]||this.i18nPropertyDescriptions_[e+"PropertyDescriptions"]||h||e};Blockly.ComponentDatabase.prototype.getInternationalizedOptionName=function(d,e){return this.i18nOptionNames_[d]||e};Blockly.ComponentDatabase.prototype.getInternationalizedOptionListTag=function(d,e){return this.i18nOptionListTags_[d]||e||d};AI.Blockly.CustomizableConnectionChecker={};class CustomizableConnectionChecker extends Blockly.ConnectionChecker{constructor(){super()}doTypeChecks(d,e){if(Blockly.getMainWorkspace().isLoading||super.doTypeChecks(d,e))return!0;for(let h=0;h<d.length;h++)if("function"==typeof d[h]&&d[h](e))return!0;for(d=0;d<e.length;d++)if("function"==typeof e[d]&&e[d](e))return!0;return!1}}const registrationType=Blockly.registry.Type.CONNECTION_CHECKER,registrationName="CustomizableConnectionChecker";
Blockly.registry.register(registrationType,registrationName,CustomizableConnectionChecker);AI.Blockly.Util.xml={};void 0===Blockly.Util&&(Blockly.Util={});Blockly.Util.xml={};Blockly.Util.xml.XMLToArray=function(d){var e=[];d=d.children;for(var h=0,k;k=d[h];h++)e.push(k);return e};Blockly.Util.xml.blockTypeToXML=function(d,e){d='<xml><block type="'+d+'">';e&&(d+=Blockly.Util.xml.mutatorAttributesXmlString(e));return Blockly.utils.xml.textToDom(d+"</block></xml>")};
Blockly.Util.xml.mutatorAttributesXmlString=function(d){var e="<mutation ",h;for(h in d)d.hasOwnProperty(h)&&(e+=h+'="'+d[h]+'" ');return e+"></mutation>"};
Blockly.Util.xml.procedureCallersXMLString=function(d,e){var h="<xml>";d=e.getProcedureDatabase().getDeclarationBlocks(d);d.sort(function(k,m){k=k.getFieldValue("NAME").toLocaleLowerCase();m=m.getFieldValue("NAME").toLocaleLowerCase();return k.localeCompare(m)});for(e=0;e<d.length;e++)h+=Blockly.Util.xml.procedureCallerBlockString(d[e]);return h+"</xml>"};
Blockly.Util.xml.procedureCallerBlockString=function(d){var e='<block type="'+("procedures_defreturn"==d.type?"procedures_callreturn":"procedures_callnoreturn")+'" inline="false">',h=d.getFieldValue("NAME");e+='<title name="PROCNAME">'+h+"</title>";d=d.mutationToDom();d.setAttribute("name",h);e+=Blockly.Xml.domToText(d);return e+"</block>"};Blockly.Util.xml.valueInputXml=function(d){return Blockly.utils.xml.textToDom('<xml><value name="'+d+'"></value></xml>')};
Blockly.Util.xml.helperKeyToXML=function(d){switch(d.type){case "OPTION_LIST":return this.blockTypeToXML("helpers_dropdown",{key:d.key});case "ASSET":return this.blockTypeToXML("helpers_assets");case "PROVIDER_MODEL":return this.blockTypeToXML("helpers_providermodel");case "PROVIDER":return this.blockTypeToXML("helpers_provider")}};Blockly.Util.xml.valueWithHelperXML=function(d,e){d=this.valueInputXml(d);e=this.helperKeyToXML(e);d.firstChild.appendChild(e.firstChild);return d};var bd={toolbox:{}};bd.toolbox.ctr={};bd.toolbox.ctr.blockInfoToBlockObject=function(d){var e={};if(d.input)for(var h in d.input){var k=bd.toolbox.ctr.blockInfoToBlockObject(d.input[h].blockInfo);e[h]={};e[h].inputType=d.input[h].inputType;e[h].blockObject=k}if(d.next)var m=bd.toolbox.ctr.blockInfoToBlockObject(d.next);return new bd.toolbox.ctr.blockObject(d.type,d.fieldNameToValue,e,d.mutatorNameToValue,m)};
bd.toolbox.ctr.blockObject=function(d,e,h,k,m){this.type=d;this.inputNameToInputTypeAndBlock="undefined"==typeof h?null:h;this.fieldNameToValue="undefined"==typeof e?null:e;this.mutatorNameToValue="undefined"==typeof k?null:k;this.next="undefined"==typeof m?null:m};
bd.toolbox.ctr.blockObjectToXML=function(d,e){var h=document.createElement("block");h.setAttribute("type",d.type);if(null!=d.mutatorNameToValue){var k=document.createElement("mutation");for(mutatorName in d.mutatorNameToValue)k.setAttribute(mutatorName,d.mutatorNameToValue[mutatorName]);h.appendChild(k)}if(null!=d.fieldNameToValue)for(var m in d.fieldNameToValue)k=document.createElement("field"),k.appendChild(document.createTextNode(d.fieldNameToValue[m])),k.setAttribute("name",m),h.appendChild(k);
if(null!=d.inputNameToInputTypeAndBlock)for(var p in d.inputNameToInputTypeAndBlock)m=d.inputNameToInputTypeAndBlock[p],k=document.createElement(m.inputType),k.appendChild(bd.toolbox.ctr.blockObjectToXML(m.blockObject)),k.setAttribute("name",p),h.appendChild(k);null!=d.next&&(k=document.createElement("next"),k.appendChild(bd.toolbox.ctr.blockObjectToXML(d.next)),h.appendChild(k));return"undefined"!=typeof e&&e?(d=document.createElement("xml"),d.setAttribute("id","toolbox"),d.appendChild(h),d):h};/*

 @fileoverview Visual blocks editor for App Inventor
 Set of drawers for holding factory blocks (blocks that create
 other blocks when dragged onto the workspace). The set of drawers
 includes the built-in drawers that we get from the blocks language, as
 well as a drawer per component instance that was added to this workspace.

 @author mckinney@mit.edu (Andrew F. McKinney)
 @author Sharon Perl (sharon@google.com)
 @author ewpatton@mit.edu (Evan W. Patton)
*/
AI.Blockly.Drawer={};Blockly.Drawer=function(d,e){e instanceof Blockly.Options?this.options=e:(e=e||{},this.options=new Blockly.Options(e));this.workspace_=d;this.flyout_=this.workspace_.getFlyout();this.flyout_.setAutoClose(!0);this.lastComponent=null};Blockly.Drawer.PREFIX_="cat_";Blockly.Drawer.PROCEDURE_PRIMARY_BLOCKS_=["procedures_defnoreturn","procedures_defreturn","procedures_callnoreturn","procedures_callreturn"];
Blockly.Drawer.buildTree_=function(){var d={},e=Blockly.common.getMainWorkspace().formName,h=e.substring(e.indexOf("_")+1);if(window.parent.BlocklyPanel_getComponentInstancePropertyValue&&(e=window.parent.BlocklyPanel_getComponentInstancePropertyValue(e,h,"BlocksToolkit"))&&(e=Blockly.Drawer.buildToolkitTree_(e),void 0!=e))return e;for(var k in Blockly.Blocks)e=Blockly.Blocks[k],e.category&&(e=Blockly.Drawer.PREFIX_+window.encodeURI(e.category),e in d?d[e].push(k):d[e]=[k]);return d};
Blockly.Drawer.buildToolkitTree_=function(d){var e={};d=JSON.parse(d).shownBlockTypes;try{for(var h in d)if("ComponentBlocks"!=h)for(var k="cat_"+h,m=d[h],p=0;p<m.length;p++){var t=m[p].type;k in e?e[k].push(t):e[k]=[t]}}catch(q){console.log(q);return}return e};
Blockly.Drawer.prototype.showBuiltin=function(d){d=Blockly.Drawer.PREFIX_+d;this.options.languageTree||(this.options.languageTree=Blockly.Drawer.buildTree_());var e=this.options.languageTree[d];if("cat_Procedures"==d)this.showProcedurePrimary_(e);else if("cat_ProceduresMore"==d)this.showProcedureMore_();else{if(!e)throw"no such drawer: "+d;Blockly.hideChaff();d=this.blockListToXMLArray(e);this.flyout_.show(d)}};
Blockly.Drawer.prototype.showProcedurePrimary_=function(d){if(!d)throw"no such drawer: cat_Procedures";Blockly.hideChaff();d=this.blockListToXMLArray(this.filterProcedureBlocks_(d,!0));this.flyout_.show(d)};
Blockly.Drawer.prototype.showProcedureMore_=function(){this.options.languageTree||(this.options.languageTree=Blockly.Drawer.buildTree_());var d=this.options.languageTree.cat_Procedures;if(!d)throw"no such drawer: cat_Procedures";Blockly.hideChaff();this.flyout_.show(this.blockListToXMLArray(this.filterProcedureBlocks_(d,!1)))};
Blockly.Drawer.prototype.filterProcedureBlocks_=function(d,e){for(var h=this.workspace_.getProcedureDatabase(),k=Blockly.Drawer.PROCEDURE_PRIMARY_BLOCKS_,m=[],p=0;p<d.length;p++){var t=d[p],q=-1!=k.indexOf(t);e!=q||"procedures_callnoreturn"==t&&0==h.voidProcedures||"procedures_callreturn"==t&&0==h.returnProcedures||m.push(t)}return m};
Blockly.Drawer.prototype.showComponent=function(d){var e=this.workspace_.getComponentDatabase().getInstance(d);e?(Blockly.hideChaff(),this.flyout_.show(this.instanceRecordToXMLArray(e)),this.lastComponent=d):console.log("Got call to Blockly.Drawer.showComponent("+d+") - unknown component name")};
Blockly.Drawer.prototype.showGeneric=function(d){this.workspace_.getComponentDatabase().hasType(d)?(Blockly.hideChaff(),d=this.componentTypeToXMLArray(d),this.flyout_.show(d)):console.log("Got call to Blockly.Drawer.showGeneric("+d+") - unknown component type name")};Blockly.Drawer.prototype.hide=function(){this.lastComponent=null;this.flyout_.hide()};Blockly.Drawer.prototype.isShowing=function(){return this.flyout_.isVisible()};
Blockly.Drawer.prototype.blockListToXMLArray=function(d){for(var e=[],h=0;h<d.length;h++)Array.prototype.push.apply(e,this.blockTypeToXMLArray(d[h],null));return e};
Blockly.Drawer.prototype.instanceRecordToXMLArray=function(d){var e=[],h=d.typeName,k=this.workspace_.getComponentDatabase().getType(h),m=Blockly.common.getMainWorkspace().formName,p=m.substring(m.indexOf("_")+1),t="";window.parent.BlocklyPanel_getComponentInstancePropertyValue&&(t=window.parent.BlocklyPanel_getComponentInstancePropertyValue(m,p,"BlocksToolkit"));if(0<t.length){if(k=JSON.parse(t).shownBlockTypes.ComponentBlocks[h],void 0!==k){for(m=0;m<k.length;m++)p=k[m],p.mutatorNameToValue.instance_name=
d.name,p.fieldNameToValue.COMPONENT_SELECTOR=d.name,console.log("added obj"),console.log(p),p=bd.toolbox.ctr.blockObjectToXML(bd.toolbox.ctr.blockInfoToBlockObject(p)),e.push(p);p={type:"component_component_block"};p.mutatorNameToValue={component_type:h,instance_name:d.name};p=bd.toolbox.ctr.blockObjectToXML(bd.toolbox.ctr.blockInfoToBlockObject(p));e.push(p)}}else e=this.createAllComponentBlocks(k,d);return e};
Blockly.Drawer.prototype.createAllComponentBlocks=function(d,e){function h(Q){Q.helperKey&&function(da){switch(da.type){case "OPTION_LIST":return!m.some(function(N){return N.key==da.key&&N.type==da.type});default:return!m.some(function(N){return N.type==da.type})}}(Q.helperKey)&&m.push(Q.helperKey)}var k=[],m=[],p=e.typeName;e=e.name;var t=Blockly.Util.xml,q=Blockly.common.getMainWorkspace().getComponentDatabase().getContainer(Blockly.common.getMainWorkspace().formName,e);q=q&&"AbsoluteArrangement"==
q.typeName;for(const [Q,da]of Object.entries(d.eventDictionary))if(!da.deprecated){var y=this.blockTypeToXMLArray("component_event",{component_type:p,instance_name:e,event_name:Q});Array.prototype.push.apply(k,y);da.parameters.forEach(h)}for(const [Q,da]of Object.entries(d.methodDictionary))if(!da.deprecated){var I=this.blockTypeToXML("component_method",{component_type:p,instance_name:e,method_name:Q});da.parameters.forEach(function(N,H){N.helperKey&&(h(N),N=t.valueWithHelperXML("ARG"+H,N.helperKey),
I.firstChild.appendChild(N.firstChild))});Array.prototype.push.apply(k,t.XMLToArray(I))}for(const [Q,da]of Object.entries(d.properties))if(!da.deprecated&&("Left"!=Q&&"Top"!=Q||q)){d={component_type:p,instance_name:e,property_name:Q};var L=Blockly.PROPERTY_READABLE;y=Blockly.PROPERTY_WRITEABLE;(da.mutability&L)==L&&(d.set_or_get="get",L=this.blockTypeToXMLArray("component_set_get",d),Array.prototype.push.apply(k,L));(da.mutability&y)==y&&(d.set_or_get="set",d=this.blockTypeToXML("component_set_get",
d),da.helperKey&&(y=t.valueWithHelperXML("VALUE",da.helperKey),d.firstChild.appendChild(y.firstChild)),Array.prototype.push.apply(k,t.XMLToArray(d)));h(da)}m.forEach(function(Q){Q=t.helperKeyToXML(Q);Array.prototype.push.apply(k,t.XMLToArray(Q))});p=this.blockTypeToXMLArray("component_component_block",{component_type:p,instance_name:e});Array.prototype.push.apply(k,p);return k};
Blockly.Drawer.prototype.componentTypeToXMLArray=function(d){function e(y){y.helperKey&&function(I){switch(I.type){case "OPTION_LIST":return!m.some(function(L){return L.key==I.key&&L.type==I.type});default:return!m.some(function(L){return L.type==I.type})}}(y.helperKey)&&m.push(y.helperKey)}var h=[],k=this.workspace_.getComponentDatabase().getType(d),m=[],p=Blockly.Util.xml;for(const [y,I]of Object.entries(k.eventDictionary))I.deprecated||(Array.prototype.push.apply(h,this.blockTypeToXMLArray("component_event",
{component_type:d,event_name:y,is_generic:"true"})),I.parameters.forEach(e));for(const [y,I]of Object.entries(k.methodDictionary))if(!I.deprecated){var t=this.blockTypeToXML("component_method",{component_type:d,method_name:y,is_generic:"true"});I.parameters.forEach(function(L,Q){L.helperKey&&(e(L),L=p.valueWithHelperXML("ARG"+Q,L.helperKey),t.firstChild.appendChild(L.firstChild))});Array.prototype.push.apply(h,p.XMLToArray(t))}for(const [y,I]of Object.entries(k.properties))if(!I.deprecated){k={component_type:d,
property_name:y};(I.mutability&Blockly.PROPERTY_READABLE)==Blockly.PROPERTY_READABLE&&(k.set_or_get="get",Array.prototype.push.apply(h,this.blockTypeToXMLArray("component_set_get",k)));if((I.mutability&Blockly.PROPERTY_WRITEABLE)==Blockly.PROPERTY_WRITEABLE){k.set_or_get="set";k=this.blockTypeToXML("component_set_get",k);if(I.helperKey){var q=p.valueWithHelperXML("VALUE",I.helperKey);k.firstChild.appendChild(q.firstChild)}Array.prototype.push.apply(h,p.XMLToArray(k))}e(I)}m.forEach(function(y){y=
p.helperKeyToXML(y);Array.prototype.push.apply(h,p.XMLToArray(y))});Array.prototype.push.apply(h,this.blockTypeToXMLArray("component_all_component_block",{component_type:d}));return h};Blockly.Drawer.prototype.blockTypeToXMLArray=function(d,e){return Blockly.Util.xml.XMLToArray(this.blockTypeToXML(d,e))};
Blockly.Drawer.prototype.blockTypeToXML=function(d,e){var h=Blockly.Util.xml;e&&void 0===e.is_generic&&(e.is_generic=!e.instance_name);switch(d){case "procedures_callnoreturn":return Blockly.utils.xml.textToDom(h.procedureCallersXMLString(!1,this.workspace_));case "procedures_callreturn":return Blockly.utils.xml.textToDom(h.procedureCallersXMLString(!0,this.workspace_));default:var k=Blockly.Drawer.getDefaultXMLString(d,e);return null!=k?Blockly.utils.xml.textToDom(k):h.blockTypeToXML(d,e)}};
Blockly.Drawer.getDefaultXMLString=function(d,e){if(null==Blockly.Drawer.defaultBlockXMLStrings[d])return null;if(null!=Blockly.Drawer.defaultBlockXMLStrings[d].xmlString)return Blockly.Drawer.defaultBlockXMLStrings[d].xmlString;if(null!=Blockly.Drawer.defaultBlockXMLStrings[d].length){d=Blockly.Drawer.defaultBlockXMLStrings[d];for(var h,k,m=0;m<d.length;m++)if(h=d[m].matchingMutatorAttributes){k=!0;for(var p in h)if(h.hasOwnProperty(p)&&e[p]!=h[p]){k=!1;break}if(k)return d[m].mutatorXMLStringFunction(e)}return null}};
Blockly.Drawer.defaultBlockXMLStrings={controls_if:{xmlString:'<xml><block type="controls_if"></block><block type="controls_if"><mutation else="1"></mutation></block><block type="controls_if"><mutation elseif="1" else="1"></mutation></block></xml>'},controls_forRange:{xmlString:'<xml><block type="controls_forRange"><value name="START"><block type="math_number"><title name="NUM">1</title></block></value><value name="END"><block type="math_number"><title name="NUM">5</title></block></value><value name="STEP"><block type="math_number"><title name="NUM">1</title></block></value></block></xml>'},
controls_openAnotherScreen:{xmlString:'<xml><block type="controls_openAnotherScreen"><value name="SCREEN"><block type="helpers_screen_names"></block></value></block></xml>'},controls_openAnotherScreenWithStartValue:{xmlString:'<xml><block type="controls_openAnotherScreenWithStartValue"><value name="SCREENNAME"><block type="helpers_screen_names"></block></value></block></xml>'},controls_run_in_background:{xmlString:'<xml><block type="controls_run_in_background"><value name="PROCEDURE"><block type="procedures_defanonreturn"></block></value><value name="CALLBACK"><block type="procedures_defanonnoreturn"><mutation><arg name="result"></arg></mutation><field name="VAR0">result</field></block></value></block></xml>'},
math_random_int:{xmlString:'<xml><block type="math_random_int"><value name="FROM"><block type="math_number"><title name="NUM">1</title></block></value><value name="TO"><block type="math_number"><title name="NUM">100</title></block></value></block></xml>'},color_make_color:{xmlString:'<xml><block type="color_make_color"><value name="COLORLIST"><block type="lists_create_with" inline="false"><mutation items="3"></mutation><value name="ADD0"><block type="math_number"><title name="NUM">255</title></block></value><value name="ADD1"><block type="math_number"><title name="NUM">0</title></block></value><value name="ADD2"><block type="math_number"><title name="NUM">0</title></block></value></block></value></block></xml>'},
lists_create_with:{xmlString:'<xml><block type="lists_create_with"><mutation items="0"></mutation></block><block type="lists_create_with"><mutation items="2"></mutation></block></xml>'},lists_lookup_in_pairs:{xmlString:'<xml><block type="lists_lookup_in_pairs"><value name="NOTFOUND"><block type="text"><title name="TEXT">not found</title></block></value></block></xml>'},lists_join_with_separator:{xmlString:'<xml><block type="lists_join_with_separator"><value name="SEPARATOR"><block type="text"><title name="TEXT"></title></block></value></block></xml>'},
dictionaries_create_with:{xmlString:'<xml><block type="dictionaries_create_with"><mutation items="0"></mutation></block><block type="dictionaries_create_with"><mutation items="2"></mutation><value name="ADD0"><block type="pair"></block></value><value name="ADD1"><block type="pair"></block></value></block></xml>'},dictionaries_lookup:{xmlString:'<xml><block type="dictionaries_lookup"><value name="NOTFOUND"><block type="text"><title name="TEXT">not found</title></block></value></block></xml>'},dictionaries_recursive_lookup:{xmlString:'<xml><block type="dictionaries_recursive_lookup"><value name="NOTFOUND"><block type="text"><title name="TEXT">not found</title></block></value></block></xml>'},
matrices_create:{xmlString:'<xml><block type="matrices_create"><value name="ROWS"><block type="math_number"><title name="NUM">2</title></block></value><value name="COLS"><block type="math_number"><title name="NUM">2</title></block></value></block></xml>'},component_method:[{matchingMutatorAttributes:{component_type:"TinyDB",method_name:"GetValue"},mutatorXMLStringFunction:function(d){return'<xml><block type="component_method">'+Blockly.Util.xml.mutatorAttributesXmlString(d)+'<value name="ARG1"><block type="text"><title name="TEXT"></title></block></value></block></xml>'}},
{matchingMutatorAttributes:{component_type:"FirebaseDB",method_name:"GetValue"},mutatorXMLStringFunction:function(d){return'<xml><block type="component_method">'+Blockly.Util.xml.mutatorAttributesXmlString(d)+'<value name="ARG1"><block type="text"><title name="TEXT"></title></block></value></block></xml>'}},{matchingMutatorAttributes:{component_type:"Notifier",method_name:"ShowTextDialog"},mutatorXMLStringFunction:function(d){return'<xml><block type="component_method">'+Blockly.Util.xml.mutatorAttributesXmlString(d)+
'<value name="ARG2"><block type="logic_boolean"><title name="BOOL">TRUE</title></block></value></block></xml>'}},{matchingMutatorAttributes:{component_type:"Notifier",method_name:"ShowChooseDialog"},mutatorXMLStringFunction:function(d){return'<xml><block type="component_method">'+Blockly.Util.xml.mutatorAttributesXmlString(d)+'<value name="ARG4"><block type="logic_boolean"><title name="BOOL">TRUE</title></block></value></block></xml>'}},{matchingMutatorAttributes:{component_type:"Canvas",method_name:"DrawCircle"},
mutatorXMLStringFunction:function(d){return'<xml><block type="component_method">'+Blockly.Util.xml.mutatorAttributesXmlString(d)+'<value name="ARG3"><block type="logic_boolean"><title name="BOOL">TRUE</title></block></value></block></xml>'}},{matchingMutatorAttributes:{component_type:"Canvas",method_name:"DrawShape"},mutatorXMLStringFunction:function(d){return'<xml><block type="component_method">'+Blockly.Util.xml.mutatorAttributesXmlString(d)+'<value name="ARG1"><block type="logic_boolean"><field name="BOOL">TRUE</field></block></value></block></xml>'}},
{matchingMutatorAttributes:{component_type:"Canvas",method_name:"DrawArc"},mutatorXMLStringFunction:function(d){return'<xml><block type="component_method">'+Blockly.Util.xml.mutatorAttributesXmlString(d)+'<value name="ARG6"><block type="logic_boolean"><field name="BOOL">FALSE</field></block></value><value name="ARG7"><block type="logic_boolean"><field name="BOOL">TRUE</field></block></value></block></xml>'}},{matchingMutatorAttributes:{component_type:"Clock",method_name:"FormatDate"},mutatorXMLStringFunction:function(d){return'<xml><block type="component_method">'+
Blockly.Util.xml.mutatorAttributesXmlString(d)+'<value name="ARG1"><block type="text"><field name="TEXT">MMM d, yyyy</field></block></value></block></xml>'}},{matchingMutatorAttributes:{component_type:"Clock",method_name:"FormatDateTime"},mutatorXMLStringFunction:function(d){return'<xml><block type="component_method">'+Blockly.Util.xml.mutatorAttributesXmlString(d)+'<value name="ARG1"><block type="text"><field name="TEXT">MM/dd/yyyy hh:mm:ss a</field></block></value></block></xml>'}},{matchingMutatorAttributes:{component_type:"Spreadsheet",
method_name:"ReadRow"},mutatorXMLStringFunction:function(d){return'<xml><block type="component_method">'+Blockly.Util.xml.mutatorAttributesXmlString(d)+'<value name="ARG0"><block type="text"><field name="TEXT">Sheet1</field></block></value></block></xml>'}},{matchingMutatorAttributes:{component_type:"Spreadsheet",method_name:"ReadCol"},mutatorXMLStringFunction:function(d){return'<xml><block type="component_method">'+Blockly.Util.xml.mutatorAttributesXmlString(d)+'<value name="ARG0"><block type="text"><field name="TEXT">Sheet1</field></block></value></block></xml>'}},
{matchingMutatorAttributes:{component_type:"Spreadsheet",method_name:"ReadCell"},mutatorXMLStringFunction:function(d){return'<xml><block type="component_method">'+Blockly.Util.xml.mutatorAttributesXmlString(d)+'<value name="ARG0"><block type="text"><field name="TEXT">Sheet1</field></block></value></block></xml>'}},{matchingMutatorAttributes:{component_type:"Spreadsheet",method_name:"ReadRange"},mutatorXMLStringFunction:function(d){return'<xml><block type="component_method">'+Blockly.Util.xml.mutatorAttributesXmlString(d)+
'<value name="ARG0"><block type="text"><field name="TEXT">Sheet1</field></block></value></block></xml>'}},{matchingMutatorAttributes:{component_type:"Spreadsheet",method_name:"ReadSheet"},mutatorXMLStringFunction:function(d){return'<xml><block type="component_method">'+Blockly.Util.xml.mutatorAttributesXmlString(d)+'<value name="ARG0"><block type="text"><field name="TEXT">Sheet1</field></block></value></block></xml>'}},{matchingMutatorAttributes:{component_type:"Spreadsheet",method_name:"ReadWithExactFilter"},
mutatorXMLStringFunction:function(d){return'<xml><block type="component_method">'+Blockly.Util.xml.mutatorAttributesXmlString(d)+'<value name="ARG0"><block type="text"><field name="TEXT">Sheet1</field></block></value><value name="ARG1"><block type="math_number"><title name="NUM">0</title></block></value></block></xml>'}},{matchingMutatorAttributes:{component_type:"Spreadsheet",method_name:"ReadWithPartialFilter"},mutatorXMLStringFunction:function(d){return'<xml><block type="component_method">'+Blockly.Util.xml.mutatorAttributesXmlString(d)+
'<value name="ARG0"><block type="text"><field name="TEXT">Sheet1</field></block></value><value name="ARG1"><block type="math_number"><title name="NUM">0</title></block></value></block></xml>'}},{matchingMutatorAttributes:{component_type:"Spreadsheet",method_name:"WriteRow"},mutatorXMLStringFunction:function(d){return'<xml><block type="component_method">'+Blockly.Util.xml.mutatorAttributesXmlString(d)+'<value name="ARG0"><block type="text"><field name="TEXT">Sheet1</field></block></value></block></xml>'}},
{matchingMutatorAttributes:{component_type:"Spreadsheet",method_name:"WriteCol"},mutatorXMLStringFunction:function(d){return'<xml><block type="component_method">'+Blockly.Util.xml.mutatorAttributesXmlString(d)+'<value name="ARG0"><block type="text"><field name="TEXT">Sheet1</field></block></value></block></xml>'}},{matchingMutatorAttributes:{component_type:"Spreadsheet",method_name:"WriteCell"},mutatorXMLStringFunction:function(d){return'<xml><block type="component_method">'+Blockly.Util.xml.mutatorAttributesXmlString(d)+
'<value name="ARG0"><block type="text"><field name="TEXT">Sheet1</field></block></value></block></xml>'}},{matchingMutatorAttributes:{component_type:"Spreadsheet",method_name:"WriteRange"},mutatorXMLStringFunction:function(d){return'<xml><block type="component_method">'+Blockly.Util.xml.mutatorAttributesXmlString(d)+'<value name="ARG0"><block type="text"><field name="TEXT">Sheet1</field></block></value></block></xml>'}},{matchingMutatorAttributes:{component_type:"Spreadsheet",method_name:"ClearRange"},
mutatorXMLStringFunction:function(d){return'<xml><block type="component_method">'+Blockly.Util.xml.mutatorAttributesXmlString(d)+'<value name="ARG0"><block type="text"><field name="TEXT">Sheet1</field></block></value></block></xml>'}},{matchingMutatorAttributes:{component_type:"Spreadsheet",method_name:"AddRow"},mutatorXMLStringFunction:function(d){return'<xml><block type="component_method">'+Blockly.Util.xml.mutatorAttributesXmlString(d)+'<value name="ARG0"><block type="text"><field name="TEXT">Sheet1</field></block></value></block></xml>'}},
{matchingMutatorAttributes:{component_type:"Spreadsheet",method_name:"AddCol"},mutatorXMLStringFunction:function(d){return'<xml><block type="component_method">'+Blockly.Util.xml.mutatorAttributesXmlString(d)+'<value name="ARG0"><block type="text"><field name="TEXT">Sheet1</field></block></value></block></xml>'}},{matchingMutatorAttributes:{component_type:"Spreadsheet",method_name:"RemoveRow"},mutatorXMLStringFunction:function(d){return'<xml><block type="component_method">'+Blockly.Util.xml.mutatorAttributesXmlString(d)+
'<value name="ARG0"><block type="text"><field name="TEXT">Sheet1</field></block></value></block></xml>'}},{matchingMutatorAttributes:{component_type:"AnomalyDetection",method_name:"DetectAnomalies"},mutatorXMLStringFunction:function(d){return'<xml><block type="component_method">'+Blockly.Util.xml.mutatorAttributesXmlString(d)+'<value name="ARG1"><block type="math_number"><title name="NUM">2</title></block></value></block></xml>'}},{matchingMutatorAttributes:{component_type:"Regression",method_name:"CalculateLineOfBestFitValue"},
mutatorXMLStringFunction:function(d){return'<xml><block type="component_method">'+Blockly.Util.xml.mutatorAttributesXmlString(d)+"</block></xml>"}},{matchingMutatorAttributes:{component_type:"Spreadsheet",method_name:"RemoveCol"},mutatorXMLStringFunction:function(d){return'<xml><block type="component_method">'+Blockly.Util.xml.mutatorAttributesXmlString(d)+'<value name="ARG0"><block type="text"><field name="TEXT">Sheet1</field></block></value></block></xml>'}}]};/*

 Copyright © 2016-2017 Massachusetts Institute of Technology. All rights reserved.
*/
AI.Blockly.ProcedureDatabase={};Blockly.ProcedureDatabase=function(d){this.workspace_=d;this.procedures_={};this.returnProcedures_={};this.voidProcedures_={};this.voidProcedures=this.returnProcedures=this.length=0};Blockly.ProcedureDatabase.defaultValue=["","none"];Blockly.ProcedureDatabase.prototype.getNames=function(d){return AI.Blockly.AIProcedure.getProcedureNames(d,this.workspace_).map(function(e){return e[0]})};
Blockly.ProcedureDatabase.prototype.getMenuItems=function(d){return AI.Blockly.AIProcedure.getProcedureNames(d,this.workspace_)};Blockly.ProcedureDatabase.prototype.getDeclarationBlocks=function(d){return Object.values(d?this.returnProcedures_:this.voidProcedures_)};Blockly.ProcedureDatabase.prototype.getDeclarationsBlocksExcept=function(d){var e=[];Object.values(this.procedures_).forEach(function(h){h!==d&&e.push(h)});return e};Blockly.ProcedureDatabase.prototype.getAllDeclarationNames=function(){return Object.values(this.procedures_).map(function(d){return d.getFieldValue("NAME")})};
Blockly.ProcedureDatabase.prototype.addProcedure=function(d,e){if("procedures_defnoreturn"!=e.type&&"procedures_defreturn"!=e.type)return console.warn("Attempt to addProcedure with block type "+e.type),!1;d=e.id;if(d in this.procedures_)return!1;this.procedures_[d]=e;this.length++;"procedures_defnoreturn"==e.type?(this.voidProcedures_[d]=e,this.voidProcedures++):(this.returnProcedures_[d]=e,this.returnProcedures++);return!0};
Blockly.ProcedureDatabase.prototype.removeProcedure=function(d){d in this.procedures_&&("procedures_defnoreturn"==this.procedures_[d].type?(delete this.voidProcedures_[d],this.voidProcedures--):(delete this.returnProcedures_[d],this.returnProcedures--),delete this.procedures_[d],this.length--);return!0};Blockly.ProcedureDatabase.prototype.renameProcedure=function(d,e,h){};Blockly.ProcedureDatabase.prototype.getProcedure=function(d){var e=this.procedures_[d];return e?e:this.getProcedureByName(d)};
Blockly.ProcedureDatabase.prototype.getProcedureByName=function(d){for(var e in this.procedures_)if(this.procedures_[e].getFieldValue("NAME")===d)return this.procedures_[e]};Blockly.ProcedureDatabase.prototype.clear=function(){this.procedures_={};this.returnProcedures_={};this.voidProcedures_={};this.voidProcedures=this.returnProcedures=this.length=0};/*

 Copyright The Closure Library Authors.
 SPDX-License-Identifier: Apache-2.0
*/
goog.crypt={};goog.crypt.Sha1=function(){this.blockSize=64;this.chain_=[];this.buf_=[];this.W_=[];this.pad_=[];this.pad_[0]=128;for(var d=1;d<this.blockSize;++d)this.pad_[d]=0;this.total_=this.inbuf_=0;this.reset()};goog.crypt.Sha1.prototype.reset=function(){this.chain_[0]=1732584193;this.chain_[1]=4023233417;this.chain_[2]=2562383102;this.chain_[3]=271733878;this.chain_[4]=3285377520;this.total_=this.inbuf_=0};
goog.crypt.Sha1.prototype.compress_=function(d,e){e||=0;var h=this.W_;if("string"===typeof d)for(var k=0;16>k;k++)h[k]=d.charCodeAt(e)<<24|d.charCodeAt(e+1)<<16|d.charCodeAt(e+2)<<8|d.charCodeAt(e+3),e+=4;else for(k=0;16>k;k++)h[k]=d[e]<<24|d[e+1]<<16|d[e+2]<<8|d[e+3],e+=4;for(k=16;80>k;k++){var m=h[k-3]^h[k-8]^h[k-14]^h[k-16];h[k]=(m<<1|m>>>31)&4294967295}d=this.chain_[0];e=this.chain_[1];var p=this.chain_[2],t=this.chain_[3],q=this.chain_[4];for(k=0;80>k;k++){if(40>k)if(20>k){m=t^e&(p^t);var y=
1518500249}else m=e^p^t,y=1859775393;else 60>k?(m=e&p|t&(e|p),y=2400959708):(m=e^p^t,y=3395469782);m=(d<<5|d>>>27)+m+q+y+h[k]&4294967295;q=t;t=p;p=(e<<30|e>>>2)&4294967295;e=d;d=m}this.chain_[0]=this.chain_[0]+d&4294967295;this.chain_[1]=this.chain_[1]+e&4294967295;this.chain_[2]=this.chain_[2]+p&4294967295;this.chain_[3]=this.chain_[3]+t&4294967295;this.chain_[4]=this.chain_[4]+q&4294967295};
goog.crypt.Sha1.prototype.update=function(d,e){if(null!=d){void 0===e&&(e=d.length);for(var h=e-this.blockSize,k=0,m=this.buf_,p=this.inbuf_;k<e;){if(0==p)for(;k<=h;)this.compress_(d,k),k+=this.blockSize;if("string"===typeof d)for(;k<e;){if(m[p]=d.charCodeAt(k),++p,++k,p==this.blockSize){this.compress_(m);p=0;break}}else for(;k<e;)if(m[p]=d[k],++p,++k,p==this.blockSize){this.compress_(m);p=0;break}}this.inbuf_=p;this.total_+=e}};
goog.crypt.Sha1.prototype.digest=function(){var d=[],e=8*this.total_;56>this.inbuf_?this.update(this.pad_,56-this.inbuf_):this.update(this.pad_,this.blockSize-(this.inbuf_-56));for(var h=this.blockSize-1;56<=h;h--)this.buf_[h]=e&255,e/=256;this.compress_(this.buf_);for(h=e=0;5>h;h++)for(var k=24;0<=k;k-=8)d[e]=this.chain_[h]>>k&255,++e;return d};goog.crypt.Hmac=function(d,e,h){this.hasher_=d;this.blockSize=h||d.blockSize||16;this.keyO_=Array(this.blockSize);this.keyI_=Array(this.blockSize);this.initialize_(e)};goog.crypt.Hmac.OPAD_=92;goog.crypt.Hmac.IPAD_=54;goog.crypt.Hmac.prototype.initialize_=function(d){d.length>this.blockSize&&(this.hasher_.update(d),d=this.hasher_.digest(),this.hasher_.reset());for(var e,h=0;h<this.blockSize;h++)e=h<d.length?d[h]:0,this.keyO_[h]=e^goog.crypt.Hmac.OPAD_,this.keyI_[h]=e^goog.crypt.Hmac.IPAD_;this.hasher_.update(this.keyI_)};
goog.crypt.Hmac.prototype.reset=function(){this.hasher_.reset();this.hasher_.update(this.keyI_)};goog.crypt.Hmac.prototype.update=function(d,e){this.hasher_.update(d,e)};goog.crypt.Hmac.prototype.digest=function(){var d=this.hasher_.digest();this.hasher_.reset();this.hasher_.update(this.keyO_);this.hasher_.update(d);return this.hasher_.digest()};goog.crypt.Hmac.prototype.getHmac=function(d){this.reset();this.update(d);return this.digest()};AI.Events={};AI.Events.COMPANION_CONNECT="companion.connect";AI.Events.COMPANION_DISCONNECT="companion.disconnect";AI.Events.SCREEN_SWITCH="screen.switch";AI.Events.SCREEN_PUSH="screen.push";AI.Events.SCREEN_POP="screen.pop";AI.Events.COMPONENT_ADD="component.add";AI.Events.COMPONENT_REMOVE="component.remove";AI.Events.COMPONENT_MOVE="component.move";AI.Events.COMPONENT_PROPERTY_CHANGE="property.change";AI.Events.BLOCKS_ARRANGE_START="blocks.arrange.start";AI.Events.BLOCKS_ARRANGE_END="blocks.arrange.end";
AI.Events.WORKSPACE_VIEWPORT_MOVE="blocks.workspace.move";AI.Events.FORCE_SAVE="blocks.save.force";AI.Events.Abstract=class{realtime=!1;isTransient=!1;projectId=null;userId=null;constructor(){this.group=Blockly.Events.getGroup();this.recordUndo=Blockly.Events.getRecordUndo()}isNull(){return!1}toJson(){let d={};d.type=this.type;d.group=this.group;d.recordUndo=this.recordUndo;return d}fromJson(d){this.type=d.type;this.group=d.group;this.recordUndo=d.recordUndo}};Blockly.Events.Abstract.prototype=new AI.Events.Abstract;
Blockly.Events.Abstract.prototype.realtime=!0;AI.Events.CompanionEvent=class extends AI.Events.Abstract{isTransient=!0;};AI.Events.CompanionConnect=class extends AI.Events.CompanionEvent{type=AI.Events.COMPANION_CONNECT;};AI.Events.CompanionDisconnect=class extends AI.Events.CompanionEvent{type=AI.Events.COMPANION_DISCONNECT;};AI.Events.ScreenEvent=class extends AI.Events.Abstract{isTransient=!0;constructor(d,e){super();this.projectId=d;this.screenName=e}};
AI.Events.ScreenSwitch=class extends AI.Events.ScreenEvent{type=AI.Events.SCREEN_SWITCH;constructor(d,e){super(d,e);this.recordUndo=!1}};AI.Events.ScreenPush=class extends AI.Events.ScreenEvent{type=AI.Events.SCREEN_PUSH;constructor(d,e){super(d,e)}};AI.Events.ScreenPop=class extends AI.Events.ScreenEvent{type=AI.Events.SCREEN_POP;constructor(d){super(d)}};AI.Events.ComponentEvent=class extends AI.Events.Abstract{realtime=!0;constructor(d,e){super();this.projectId=d;this.component=e}};
AI.Events.ComponentAdd=class extends AI.Events.ComponentEvent{type=AI.Events.COMPONENT_ADD;constructor(d,e){super(d,e)}};AI.Events.ComponentRemove=class extends AI.Events.ComponentEvent{type=AI.Events.COMPONENT_REMOVE;constructor(d,e){super(d,e)}};AI.Events.ComponentMove=class extends AI.Events.ComponentEvent{type=AI.Events.COMPONENT_MOVE;constructor(d,e){super(d,e);d=this.currentLocation();this.oldParentUuid=d.parentUuid;this.oldIndex=d.index}};
AI.Events.PropertyChange=class extends AI.Events.ComponentEvent{constructor(d,e,h,k,m){super(d,e);this.property=h;this.oldValue=k;this.newValue=m}};
AI.Events.StartArrangeBlocks=class extends Blockly.Events.Abstract{type=AI.Events.BLOCKS_ARRANGE_START;constructor(d){super(d);const e=Blockly.Workspace.getById(d);this.old_arranged_type=e.arranged_type_;this.old_arranged_position=e.arranged_position_;this.old_arranged_latest_position=e.arranged_latest_position_;this.recordUndo=Blockly.Events.getRecordUndo();this.workspaceId=d}toJson(){let d=super.toJson();d.old_arranged_type=this.old_arranged_type;d.old_arranged_position=this.old_arranged_position;
d.old_arranged_latest_position=this.old_arranged_latest_position;return d}fromJson(d){super.fromJson(d);this.old_arranged_type=d.old_arranged_type;this.old_arranged_position=d.old_arranged_position;this.old_arranged_latest_position=d.old_arranged_latest_position}run(d){d||setTimeout(function(){const e=Blockly.Workspace.getById(this.workspaceId);e.arranged_type_=this.old_arranged_type;e.arranged_position_=this.old_arranged_position;e.arranged_latest_position_=this.old_arranged_latest_position}.bind(this))}};
AI.Events.EndArrangeBlocks=class extends Blockly.Events.Abstract{type=AI.Events.BLOCKS_ARRANGE_END;constructor(d,e,h){super(d);this.new_type=e;this.new_layout=h;this.recordUndo=Blockly.Events.getRecordUndo();this.workspaceId=d}toJson(){let d=super.toJson();d.new_type=this.new_type;d.new_layout=this.new_layout;return d}fromJson(d){super.fromJson(d);this.new_type=d.new_type;this.new_layout=d.new_layout}run(d){d&&setTimeout(function(){const e=Blockly.Workspace.getById(this.workspaceId);e.arranged_type_=
this.new_type;e.arranged_position_=this.new_layout;e.arranged_latest_position_=this.new_layout}.bind(this),1E3)}};
AI.Events.WorkspaceMove=class extends AI.Events.Abstract{type=AI.Events.WORKSPACE_VIEWPORT_MOVE;isTransient=!0;constructor(d){super();this.workspaceId=d;d=Blockly.Workspace.getById(d).getMetrics();this.oldX=d.viewLeft-d.scrollLeft;this.oldY=d.viewTop-d.scrollTop;this.newY=this.newX=null}recordNew(){var d=Blockly.Workspace.getById(this.workspaceId).getMetrics();this.newX=d.viewLeft-d.scrollLeft;this.newY=d.viewTop-d.scrollTop}isNull(){return this.oldX===this.newX&&this.oldY===this.newY}toJson(){let d=
super.toJson();d.workspaceId=this.workspaceId;this.newX&&(d.newX=this.newX);this.newY&&(d.newY=this.newY);return d}fromJson(d){super.fromJson(d);this.workspaceId=d.workspaceId;this.newX=d.newX;this.newY=d.newY}run(d){Blockly.Workspace.getById(this.workspaceId).scrollbar.set(d?this.newX:this.oldX,d?this.newY:this.oldY,!0)}};
AI.Events.ForceSave=class extends AI.Events.Abstract{type=AI.Events.FORCE_SAVE;isTransient=!1;constructor(d){super();d&&(this.workspaceId=d.id);this.recordUndo=!1}toJson(){let d=super.toJson();d.workspaceId=this.workspaceId;return d}fromJson(d){super.fromJson(d);this.workspaceId=d.workspaceId}};AI.Yail=new Blockly.Generator("Yail");AI.Yail.RESERVED_WORDS_="";AI.Yail.ORDER_ATOMIC=0;AI.Yail.ORDER_NONE=99;AI.Yail.YAIL_ACTIVE_FORM="(SimpleForm:getActiveForm)";AI.Yail.YAIL_ADD_COMPONENT="(add-component ";AI.Yail.YAIL_ADD_TO_LIST="(add-to-list ";AI.Yail.YAIL_BEGIN="(begin ";AI.Yail.YAIL_BREAK="*yail-break*";AI.Yail.YAIL_CALL_COMPONENT_METHOD="(call-component-method ";AI.Yail.YAIL_CALL_COMPONENT_METHOD_BLOCKING="(call-component-method-with-blocking-continuation ";
AI.Yail.YAIL_CALL_COMPONENT_METHOD_CONTINUATION="(call-component-method-with-continuation ";AI.Yail.YAIL_CALL_COMPONENT_TYPE_METHOD="(call-component-type-method ";AI.Yail.YAIL_CALL_COMPONENT_TYPE_METHOD_BLOCKING="(call-component-type-method-with-blocking-continuation ";AI.Yail.YAIL_CALL_COMPONENT_TYPE_METHOD_CONTINUATION="(call-component-type-method-with-continuation ";AI.Yail.YAIL_CALL_YAIL_PRIMITIVE="(call-yail-primitive ";AI.Yail.YAIL_CLEAR_FORM="(clear-current-form)";
AI.Yail.YAIL_SET_FORM_NAME_BEGIN='(try-catch (let ((attempt (delay (set-form-name "';AI.Yail.YAIL_SET_FORM_NAME_END="\")))) (force attempt)) (exception java.lang.Throwable 'notfound))";AI.Yail.YAIL_CLOSE_COMBINATION=")";AI.Yail.YAIL_CLOSE_BLOCK=")\n";AI.Yail.YAIL_COMMENT_MAJOR=";;; ";AI.Yail.YAIL_COMPONENT_REMOVE="(remove-component ";AI.Yail.YAIL_COMPONENT_TYPE="component";AI.Yail.YAIL_CONSTANT_ALL="(static-field com.google.appinventor.components.runtime.util.YailDictionary 'ALL)";
AI.Yail.YAIL_DEFINE="(def ";AI.Yail.YAIL_DEFINE_EVENT="(define-event ";AI.Yail.YAIL_DEFINE_GENERIC_EVENT="(define-generic-event ";AI.Yail.YAIL_DEFINE_FORM="(define-form ";AI.Yail.YAIL_DO_AFTER_FORM_CREATION="(do-after-form-creation ";AI.Yail.YAIL_DOUBLE_QUOTE='"';AI.Yail.YAIL_FALSE="#f";AI.Yail.YAIL_FILTER="(filter_nondest ";AI.Yail.YAIL_FOREACH="(foreach ";AI.Yail.YAIL_FORRANGE="(forrange ";AI.Yail.YAIL_GET_COMPONENT="(get-component ";AI.Yail.YAIL_GET_ALL_COMPONENT="(get-all-components ";
AI.Yail.YAIL_GET_PROPERTY="(get-property ";AI.Yail.YAIL_GET_COMPONENT_TYPE_PROPERTY="(get-property-and-check  ";AI.Yail.YAIL_GET_VARIABLE="(get-var ";AI.Yail.YAIL_AND_DELAYED="(and-delayed ";AI.Yail.YAIL_OR_DELAYED="(or-delayed ";AI.Yail.YAIL_IF="(if ";AI.Yail.YAIL_INIT_RUNTIME="(init-runtime)";AI.Yail.YAIL_INITIALIZE_COMPONENTS="(call-Initialize-of-components";AI.Yail.YAIL_LAMBDA="(lambda ";AI.Yail.YAIL_LET="(let ";AI.Yail.YAIL_LEXICAL_VALUE="(lexical-value ";AI.Yail.YAIL_SET_LEXICAL_VALUE="(set-lexical! ";
AI.Yail.YAIL_LINE_FEED="\n";AI.Yail.YAIL_MAP="(map_nondest ";AI.Yail.YAIL_NULL="(get-var *the-null-value*)";AI.Yail.YAIL_EMPTY_LIST="'()";AI.Yail.YAIL_EMPTY_YAIL_LIST="'(*list*)";AI.Yail.YAIL_EMPTY_DICT="(make com.google.appinventor.components.runtime.util.YailDictionary)";AI.Yail.YAIL_OPEN_BLOCK="(";AI.Yail.YAIL_OPEN_COMBINATION="(";AI.Yail.YAIL_QUOTE="'";AI.Yail.YAIL_REDUCE="(reduceovereach ";AI.Yail.YAIL_RENAME_COMPONENT="(rename-component ";AI.Yail.YAIL_SET_AND_COERCE_PROPERTY="(set-and-coerce-property! ";
AI.Yail.YAIL_SET_AND_COERCE_COMPONENT_TYPE_PROPERTY="(set-and-coerce-property-and-check! ";AI.Yail.YAIL_SET_SUBFORM_LAYOUT_PROPERTY="(%set-subform-layout-property! ";AI.Yail.YAIL_SET_VARIABLE="(set-var! ";AI.Yail.YAIL_SET_THIS_FORM="(set-this-form)\n ";AI.Yail.YAIL_SPACER=" ";AI.Yail.YAIL_SORT_COMPARATOR_NONDEST="(sortcomparator_nondest ";AI.Yail.YAIL_SORT_KEY_NONDEST="(sortkey_nondest ";AI.Yail.YAIL_TRUE="#t";AI.Yail.YAIL_UNREGISTER="com.google.appinventor.components.runtime.EventDispatcher:unregisterEventForDelegation";
AI.Yail.YAIL_WHILE="(while ";AI.Yail.YAIL_LIST_CONSTRUCTOR="*list-for-runtime*";AI.Yail.SIMPLE_HEX_PREFIX="&H";AI.Yail.YAIL_HEX_PREFIX="#x";AI.Yail.INTEGER_REGEXP="^[\\s]*[-+]?[0-9]+[\\s]*$";AI.Yail.FLONUM_REGEXP="^[\\s]*[-+]?([0-9]*)((\\.[0-9]+)|[0-9]\\.)[\\s]*$";AI.Yail.getFormYail=function(d,e,h,k){var m=this.forRepl;try{this.forRepl=h;var p=AI.Yail.getFormYail_(d,e,h,k)}finally{this.forRepl=m}return p};
AI.Yail.getFormYail_=function(d,e,h,k){var m=JSON.parse(d),p=[],t=[],q=function(da){return da};if(m.Properties){d=m.Properties;var y=d.$Name}else throw"Cannot find form properties";if(!y)throw"Unable to determine form name";h||t.push(AI.Yail.getYailPrelude(e,y,"Classic"===m.Properties.Theme));e=k.buildComponentMap([],[],!1,!1);for(var I=e.globals,L=0,Q;Q=I[L];L++)t.push(AI.Yail.blockToCode(Q));if(d){m=m.Source;if("Form"==m)t=t.concat(AI.Yail.getComponentLines(y,d,null,e,!1,q,k.getComponentDatabase()));
else throw"Source type "+m+" is invalid.";p=AI.Yail.getDeepNames(d,p);p=p.filter(function(da,N){return p.indexOf(da)==N});t.push(AI.Yail.YAIL_INIT_RUNTIME);h&&(t=AI.Yail.wrapForRepl(y,t,p))}return t.join("\n")};AI.Yail.getDeepNames=function(d,e){if(d.$Components){d=d.$Components;for(var h=0,k;k=d[h];h++)e.push(k.$Name),e=AI.Yail.getDeepNames(k,e)}return e};
AI.Yail.getYailPrelude=function(d,e,h){return"#|\n$Source $Yail\n|#\n\n"+AI.Yail.YAIL_DEFINE_FORM+d+AI.Yail.YAIL_SPACER+e+AI.Yail.YAIL_SPACER+(h?"#t":"#f")+AI.Yail.YAIL_CLOSE_BLOCK+"(require <com.google.youngandroid.runtime>)\n"};
AI.Yail.wrapForRepl=function(d,e,h){var k=[];k.push(AI.Yail.YAIL_BEGIN);k.push(AI.Yail.YAIL_CLEAR_FORM);"Screen1"!=d&&k.push(AI.Yail.getComponentRenameString("Screen1",d));k=k.concat(e);k.push(AI.Yail.getComponentInitializationString(d,h));k.push(AI.Yail.YAIL_CLOSE_BLOCK);return k};AI.Yail.getComponentInitializationString=function(d,e){var h=AI.Yail.YAIL_INITIALIZE_COMPONENTS;h+=" "+AI.Yail.YAIL_QUOTE+d;for(var k=0,m;m=e[k];k++)m!=d&&(h=h+" "+AI.Yail.YAIL_QUOTE+m);return h+")"};
AI.Yail.getComponentLines=function(d,e,h,k,m,p,t){var q,y,I=e.$Name;h="Form"==e.$Type?AI.Yail.getFormPropertiesLines(d,e,!m,t,m):AI.Yail.getComponentPropertiesLines(d,e,h,!m,p,t,m);if(!m&&k.components&&k.components[I]){var L=k.components[I];for(q=0;y=L[q];q++)h.push(AI.Yail.blockToCode(y))}if(e.$Components)for(y=e.$Components,q=0;e=y[q];q++)h=h.concat(AI.Yail.getComponentLines(d,e,I,k,m,p,t));return h};
AI.Yail.getComponentPropertiesLines=function(d,e,h,k,m,p,t){d=[];var q=e.$Name,y=e.$Type;k&&d.push(AI.Yail.YAIL_COMMENT_MAJOR+q+AI.Yail.YAIL_LINE_FEED);d.push(AI.Yail.YAIL_ADD_COMPONENT+h+AI.Yail.YAIL_SPACER+m(p.getType(y).type)+AI.Yail.YAIL_SPACER+q+AI.Yail.YAIL_SPACER);d=d.concat(AI.Yail.getPropertySettersLines(e,q,p,t));d.push(AI.Yail.YAIL_CLOSE_BLOCK);return d};
AI.Yail.getFormPropertiesLines=function(d,e,h,k,m){var p=[];h&&p.push(AI.Yail.YAIL_COMMENT_MAJOR+d+AI.Yail.YAIL_LINE_FEED);d=AI.Yail.getPropertySettersLines(e,d,k,m);0<d.length&&p.push(AI.Yail.YAIL_DO_AFTER_FORM_CREATION+d.join(" ")+AI.Yail.YAIL_CLOSE_BLOCK);return p};
AI.Yail.getPropertySettersLines=function(d,e,h,k){var m=[],p=h.getType(d.$Type),t=Object.keys(d),q;for(q in p.properties){var y=p.properties[q];!y.alwaysSend||q in d||t.push(y.name)}t.sort();t.forEach(function(I){var L=p.properties[I];if("$"!==I.charAt(0)&&"Uuid"!==I&&"TutorialURL"!==I&&"BlocksToolkit"!==I||L&&L.alwaysSend){var Q=d[I];Q||""===Q||(Q=L.defaultValue);m.push(AI.Yail.getPropertySetterString(e,d.$Type,I,Q,h,k))}});return m};
AI.Yail.getPropertySetterString=function(d,e,h,k,m,p){d=AI.Yail.YAIL_SET_AND_COERCE_PROPERTY+AI.Yail.YAIL_QUOTE+d+AI.Yail.YAIL_SPACER+AI.Yail.YAIL_QUOTE+h+AI.Yail.YAIL_SPACER;e=m.getPropertyForType(e,h);e=AI.Yail.YAIL_QUOTE+(e?e.type:"any");h="ApiKey"!==h||p?AI.Yail.getPropertyValueString(k,e):AI.Yail.obfuscateProperty(k);return d=d.concat(h+AI.Yail.YAIL_SPACER+e+AI.Yail.YAIL_CLOSE_BLOCK)};
AI.Yail.obfuscateProperty=function(d){for(var e=Math.random().toString(36).replace(/[^a-z]+/g,"").substr(0,8),h=e,k=[];h.length<d.length;)h+=h;for(var m=0;m<d.length;m++){var p=(d.charCodeAt(m)^h.charCodeAt(m))&255;k.push(String.fromCharCode((((p>>8^m)&255)<<8|(p^d.length-m)&255)&255))}return"(text-deobfuscate "+[k.join(""),e].map(AI.Yail.quote_).join(" ")+")"};
AI.Yail.getPropertyValueString=function(d,e){if("'number"==e){if(d.match(AI.Yail.INTEGER_REGEXP)||d.match(AI.Yail.FLONUM_REGEXP))return d;if(d.match(AI.Yail.SIMPLE_HEX_PREFIX+"[0-9A-F]+"))return AI.Yail.YAIL_HEX_PREFIX+d.substring(AI.Yail.SIMPLE_HEX_PREFIX.length)}else if("'boolean"==e){if(-1!=d.indexOf("False"))return"#f";if(-1!=d.indexOf("True"))return"#t"}else if("'component"==e)return""==d?'""':AI.Yail.YAIL_GET_COMPONENT+d+")";return""==d||"null"==d?'""':AI.Yail.quotifyForREPL(d)};
AI.Yail.getComponentRenameString=function(d,e){return AI.Yail.YAIL_RENAME_COMPONENT+AI.Yail.quotifyForREPL(d)+AI.Yail.YAIL_SPACER+AI.Yail.quotifyForREPL(e)+AI.Yail.YAIL_CLOSE_BLOCK};
AI.Yail.quotifyForREPL=function(d){if(d){var e=[];e.push('"');for(var h=d.length,k=h-1,m=0;m<h;m++)if(c=d.charAt(m),"\\"==c)m==k||"n"!=d.charAt(m+1)&&"t"!=d.charAt(m+1)&&"r"!=d.charAt(m+1)?(e.push("\\"),e.push(c)):(e.push(c),e.push(d.charAt(m+1)),m+=1);else if('"'==c)e.push("\\"),e.push(c);else{var p=d.charCodeAt(m);32>p||126<p?(p="000"+p.toString(16),p=p.substring(p.length-4),e.push("\\u"+p)):e.push(c)}e.push('"');return e.join("")}return null};
AI.Yail.quote_=function(d){(d=AI.Yail.quotifyForREPL(d))||(d='""');return d};AI.Yail.scrubNakedValue=function(d){return d};AI.Yail.scrub_=function(d,e,h){if(null===e)return"";d=d.nextConnection&&d.nextConnection.targetBlock();h=h?"":this.blockToCode(d);return""+e+h};
AI.Yail.getDebuggingYail=function(){for(var d=[],e=Blockly.Component.buildComponentMap([],[],!1,!1).globals,h=0;h<e.length;h++)d.push(AI.Yail.blockToCode(e[h]));e=Blockly.common.getMainWorkspace().getTopBlocks(!0);h=0;for(var k;k=e[h];h++)k.category&&d.push(AI.Yail.blockToCode(k));return d.join("\n\n")};
AI.Yail.blockToCode1=function(d){if(!d)return"";var e=this.forBlock&&this.forBlock[d.type];if(!e)throw'Language "'+name+'" does not know how to generate code for block type "'+d.type+'".';e=e(d,this);if(e instanceof Array){if(d.disabled||d.isBadBlock())e[0]="";return[this.scrub_(d,e[0],!0),e[1]]}if(d.disabled||d.isBadBlock())e="";return this.scrub_(d,e,!0)};
AI.Yail.YailCallYialPrimitive=function(d,e,h,k){k||=d;"string"==typeof e&&(e=[e]);"string"==typeof h&&(h=[h]);return AI.Yail.YAIL_CALL_YAIL_PRIMITIVE+d+AI.Yail.YAIL_SPACER+AI.Yail.YAIL_OPEN_COMBINATION+AI.Yail.YAIL_LIST_CONSTRUCTOR+AI.Yail.YAIL_SPACER+e.join(" ")+AI.Yail.YAIL_CLOSE_COMBINATION+AI.Yail.YAIL_SPACER+AI.Yail.YAIL_QUOTE+AI.Yail.YAIL_OPEN_COMBINATION+h.join(" ")+AI.Yail.YAIL_CLOSE_COMBINATION+AI.Yail.YAIL_SPACER+AI.Yail.YAIL_DOUBLE_QUOTE+k+AI.Yail.YAIL_DOUBLE_QUOTE+AI.Yail.YAIL_CLOSE_COMBINATION};
AI.Yail.disabledEventBlockToCode=function(d){return AI.Yail.YAIL_OPEN_BLOCK+AI.Yail.YAIL_UNREGISTER+AI.Yail.YAIL_SPACER+AI.Yail.YAIL_ACTIVE_FORM+AI.Yail.YAIL_SPACER+AI.Yail.YAIL_QUOTE+d.getFieldValue("COMPONENT_SELECTOR")+AI.Yail.YAIL_SPACER+AI.Yail.YAIL_QUOTE+d.eventName+AI.Yail.YAIL_CLOSE_BLOCK};/*

 @fileoverview Color blocks yail generators for Blockly, modified for MIT App Inventor.
 @author mckinney@mit.edu (Andrew F. McKinney)
*/
AI.Yail.color=function(d){return[-1*(Math.pow(16,6)-window.parseInt("0x"+d.getFieldValue("COLOR").substr(1))),AI.Yail.ORDER_ATOMIC]};AI.Yail.forBlock.color_black=function(d,e){return AI.Yail.color(d)};AI.Yail.forBlock.color_blue=function(d,e){return AI.Yail.color(d)};AI.Yail.forBlock.color_cyan=function(d,e){return AI.Yail.color(d)};AI.Yail.forBlock.color_dark_gray=function(d,e){return AI.Yail.color(d)};AI.Yail.forBlock.color_gray=function(d,e){return AI.Yail.color(d)};
AI.Yail.forBlock.color_green=function(d,e){return AI.Yail.color(d)};AI.Yail.forBlock.color_light_gray=function(d,e){return AI.Yail.color(d)};AI.Yail.forBlock.color_magenta=function(d,e){return AI.Yail.color(d)};AI.Yail.forBlock.color_pink=function(d,e){return AI.Yail.color(d)};AI.Yail.forBlock.color_red=function(d,e){return AI.Yail.color(d)};AI.Yail.forBlock.color_white=function(d,e){return AI.Yail.color(d)};AI.Yail.forBlock.color_orange=function(d,e){return AI.Yail.color(d)};
AI.Yail.forBlock.color_yellow=function(d,e){return AI.Yail.color(d)};
AI.Yail.forBlock.color_make_color=function(d,e){d=e.valueToCode(d,"COLORLIST",AI.Yail.ORDER_NONE)||'(call-yail-primitive make-yail-list (*list-for-runtime* 0 0 0)  \'( any any any)  "make a list")';e=AI.Yail.YAIL_CALL_YAIL_PRIMITIVE+"make-color"+AI.Yail.YAIL_SPACER;e+=AI.Yail.YAIL_OPEN_COMBINATION+AI.Yail.YAIL_LIST_CONSTRUCTOR+AI.Yail.YAIL_SPACER+d+AI.Yail.YAIL_CLOSE_COMBINATION;e+=AI.Yail.YAIL_SPACER+AI.Yail.YAIL_QUOTE+AI.Yail.YAIL_OPEN_COMBINATION+"list"+AI.Yail.YAIL_CLOSE_COMBINATION+AI.Yail.YAIL_SPACER;
e+=AI.Yail.YAIL_DOUBLE_QUOTE+"make-color"+AI.Yail.YAIL_DOUBLE_QUOTE+AI.Yail.YAIL_CLOSE_COMBINATION;return[e,AI.Yail.ORDER_ATOMIC]};
AI.Yail.forBlock.color_split_color=function(d,e){d=e.valueToCode(d,"COLOR",AI.Yail.ORDER_NONE)||-1;e=AI.Yail.YAIL_CALL_YAIL_PRIMITIVE+"split-color"+AI.Yail.YAIL_SPACER;e+=AI.Yail.YAIL_OPEN_COMBINATION+AI.Yail.YAIL_LIST_CONSTRUCTOR+AI.Yail.YAIL_SPACER+d+AI.Yail.YAIL_CLOSE_COMBINATION;e+=AI.Yail.YAIL_SPACER+AI.Yail.YAIL_QUOTE+AI.Yail.YAIL_OPEN_COMBINATION+"number"+AI.Yail.YAIL_CLOSE_COMBINATION+AI.Yail.YAIL_SPACER;e+=AI.Yail.YAIL_DOUBLE_QUOTE+"split-color"+AI.Yail.YAIL_DOUBLE_QUOTE+AI.Yail.YAIL_CLOSE_COMBINATION;
return[e,AI.Yail.ORDER_ATOMIC]};/*

 @fileoverview Component blocks yail generators for Blockly, modified for MIT App Inventor.
 @author mckinney@mit.edu (Andrew F. McKinney)
*/
AI.Yail.componentblock={};
AI.Yail.forBlock.component_event=function(d,e){var h=d.isGeneric?AI.Yail.YAIL_DEFINE_GENERIC_EVENT+d.typeName+AI.Yail.YAIL_SPACER+d.eventName:AI.Yail.YAIL_DEFINE_EVENT+d.getFieldValue("COMPONENT_SELECTOR")+AI.Yail.YAIL_SPACER+d.eventName;e=e.statementToCode(d,"DO");""==e&&(e=AI.Yail.YAIL_NULL);return h+AI.Yail.YAIL_OPEN_COMBINATION+d.getParameters().map(function(k){return AI.Yail.YAIL_LOCAL_VAR_TAG+k.name}).join(" ")+AI.Yail.YAIL_CLOSE_COMBINATION+AI.Yail.YAIL_SET_THIS_FORM+AI.Yail.YAIL_SPACER+e+
AI.Yail.YAIL_CLOSE_COMBINATION};AI.Yail.forBlock.component_method=function(d,e){e=AI.Yail.methodHelper(d,d.isGeneric?d.typeName:d.instanceName,d.methodName,d.isGeneric);return d.getMethodTypeObject()&&d.getMethodTypeObject().returnType?[e,AI.Yail.ORDER_ATOMIC]:e};AI.Yail.methodWithReturn=function(d,e){return function(){return[AI.Yail.methodHelper(this,d,e,!1),AI.Yail.ORDER_ATOMIC]}};AI.Yail.methodNoReturn=function(d,e){return function(){return AI.Yail.methodHelper(this,d,e,!1)}};
AI.Yail.genericMethodWithReturn=function(d,e){return function(){return[AI.Yail.methodHelper(this,d,e,!0),AI.Yail.ORDER_ATOMIC]}};AI.Yail.genericMethodNoReturn=function(d,e){return function(){return AI.Yail.methodHelper(this,d,e,!0)}};
AI.Yail.methodHelper=function(d,e,h,k){var m=d.workspace.getComponentDatabase(),p=d.getMethodTypeObject(),t=p.continuation,q=p.parameters;p=q.length;var y=[];k&&y.push(AI.Yail.YAIL_COMPONENT_TYPE);for(var I=0;I<q.length;I++)y.push(q[I].type);k?(e=m.getType(e).type,k=t?AI.Yail.YAIL_CALL_COMPONENT_TYPE_METHOD_BLOCKING:AI.Yail.YAIL_CALL_COMPONENT_TYPE_METHOD+AI.Yail.valueToCode(d,"COMPONENT",AI.Yail.ORDER_NONE)+AI.Yail.YAIL_SPACER):(k=t?AI.Yail.YAIL_CALL_COMPONENT_METHOD_BLOCKING:AI.Yail.YAIL_CALL_COMPONENT_METHOD,
e=d.getFieldValue("COMPONENT_SELECTOR"),(m=d.getFieldValue("TIME_UNIT"))&&Blockly.ComponentBlock.isClockMethodName(h)&&(h="Add"+m));m=[];for(t=0;t<p;t++)m.push(AI.Yail.YAIL_SPACER+AI.Yail.valueToCode(d,"ARG"+t,AI.Yail.ORDER_NONE));return k+AI.Yail.YAIL_QUOTE+e+AI.Yail.YAIL_SPACER+AI.Yail.YAIL_QUOTE+h+AI.Yail.YAIL_SPACER+AI.Yail.YAIL_OPEN_COMBINATION+AI.Yail.YAIL_LIST_CONSTRUCTOR+m.join(" ")+AI.Yail.YAIL_CLOSE_COMBINATION+AI.Yail.YAIL_SPACER+AI.Yail.YAIL_QUOTE+AI.Yail.YAIL_OPEN_COMBINATION+y.join(" ")+
AI.Yail.YAIL_CLOSE_COMBINATION+AI.Yail.YAIL_CLOSE_COMBINATION};AI.Yail.forBlock.component_set_get=function(d,e){return"set"==d.setOrGet?d.isGeneric?AI.Yail.genericSetproperty.call(d):AI.Yail.setproperty.call(d):d.isGeneric?AI.Yail.genericGetproperty.call(d):AI.Yail.getproperty.call(d)};
AI.Yail.setproperty=function(){var d=this.getFieldValue("PROP"),e=this.getPropertyObject(d).type;d=AI.Yail.YAIL_QUOTE+this.getFieldValue("COMPONENT_SELECTOR")+AI.Yail.YAIL_SPACER+AI.Yail.YAIL_QUOTE+d;d=AI.Yail.YAIL_SET_AND_COERCE_PROPERTY+d+AI.Yail.YAIL_SPACER;d=d.concat(AI.Yail.valueToCode(this,"VALUE",AI.Yail.ORDER_NONE));return d=d.concat(AI.Yail.YAIL_SPACER+AI.Yail.YAIL_QUOTE+e+AI.Yail.YAIL_CLOSE_COMBINATION)};
AI.Yail.genericSetproperty=function(){var d=this.getFieldValue("PROP"),e=this.getPropertyObject(d).type;d=AI.Yail.YAIL_QUOTE+this.workspace.getComponentDatabase().getType(this.typeName).type+AI.Yail.YAIL_SPACER+AI.Yail.YAIL_QUOTE+d;d=AI.Yail.YAIL_SET_AND_COERCE_COMPONENT_TYPE_PROPERTY+AI.Yail.valueToCode(this,"COMPONENT",AI.Yail.ORDER_NONE)+AI.Yail.YAIL_SPACER+d+AI.Yail.YAIL_SPACER;d=d.concat(AI.Yail.valueToCode(this,"VALUE",AI.Yail.ORDER_NONE));return d=d.concat(AI.Yail.YAIL_SPACER+AI.Yail.YAIL_QUOTE+
e+AI.Yail.YAIL_CLOSE_COMBINATION)};AI.Yail.getproperty=function(d){d=this.getFieldValue("PROP");this.getPropertyObject(d);return[AI.Yail.YAIL_GET_PROPERTY+AI.Yail.YAIL_QUOTE+this.getFieldValue("COMPONENT_SELECTOR")+AI.Yail.YAIL_SPACER+AI.Yail.YAIL_QUOTE+d+AI.Yail.YAIL_CLOSE_COMBINATION,AI.Yail.ORDER_ATOMIC]};
AI.Yail.genericGetproperty=function(d){d=this.getFieldValue("PROP");this.getPropertyObject(d);return[AI.Yail.YAIL_GET_COMPONENT_TYPE_PROPERTY+AI.Yail.valueToCode(this,"COMPONENT",AI.Yail.ORDER_NONE)+AI.Yail.YAIL_SPACER+AI.Yail.YAIL_QUOTE+this.workspace.getComponentDatabase().getType(this.typeName).type+AI.Yail.YAIL_SPACER+AI.Yail.YAIL_QUOTE+d+AI.Yail.YAIL_CLOSE_COMBINATION,AI.Yail.ORDER_ATOMIC]};
AI.Yail.forBlock.component_component_block=function(d,e){return[AI.Yail.YAIL_GET_COMPONENT+d.getFieldValue("COMPONENT_SELECTOR")+AI.Yail.YAIL_CLOSE_COMBINATION,AI.Yail.ORDER_ATOMIC]};AI.Yail.forBlock.component_all_component_block=function(d,e){d=d.workspace.getComponentDatabase().getType(d.getFieldValue("COMPONENT_TYPE_SELECTOR")).componentInfo.type;return[AI.Yail.YAIL_GET_ALL_COMPONENT+d+AI.Yail.YAIL_CLOSE_COMBINATION,AI.Yail.ORDER_ATOMIC]};AI.Yail.control={};
AI.Yail.forBlock.controls_if=function(d,e){for(var h="",k=0;k<d.elseifCount_+1;k++){var m=e.valueToCode(d,"IF"+k,AI.Yail.ORDER_NONE)||AI.Yail.YAIL_FALSE,p=e.statementToCode(d,"DO"+k)||AI.Yail.YAIL_FALSE;0!=k&&(h+=AI.Yail.YAIL_SPACER+AI.Yail.YAIL_BEGIN);h+=AI.Yail.YAIL_IF+m+AI.Yail.YAIL_SPACER+AI.Yail.YAIL_BEGIN+p+AI.Yail.YAIL_CLOSE_COMBINATION}1==d.elseCount_&&(p=e.statementToCode(d,"ELSE")||AI.Yail.YAIL_FALSE,h+=AI.Yail.YAIL_SPACER+AI.Yail.YAIL_BEGIN+p+AI.Yail.YAIL_CLOSE_COMBINATION);for(k=0;k<d.elseifCount_;k++)h+=
AI.Yail.YAIL_CLOSE_COMBINATION+AI.Yail.YAIL_CLOSE_COMBINATION;return h+=AI.Yail.YAIL_CLOSE_COMBINATION};AI.Yail.forBlock.controls_choose=function(d,e){var h=e.valueToCode(d,"TEST",AI.Yail.ORDER_NONE)||AI.Yail.YAIL_FALSE,k=e.valueToCode(d,"THENRETURN",AI.Yail.ORDER_NONE)||AI.Yail.YAIL_FALSE;d=e.valueToCode(d,"ELSERETURN",AI.Yail.ORDER_NONE)||AI.Yail.YAIL_FALSE;return[AI.Yail.YAIL_IF+h+AI.Yail.YAIL_SPACER+k+AI.Yail.YAIL_SPACER+d+AI.Yail.YAIL_CLOSE_COMBINATION,AI.Yail.ORDER_ATOMIC]};
AI.Yail.forBlock.controls_forEach=function(d,e){var h=AI.Yail.YAIL_CALL_YAIL_PRIMITIVE+"make-yail-list"+AI.Yail.YAIL_SPACER;h+=AI.Yail.YAIL_OPEN_COMBINATION+AI.Yail.YAIL_LIST_CONSTRUCTOR+AI.Yail.YAIL_SPACER;h+=AI.Yail.YAIL_CLOSE_COMBINATION+AI.Yail.YAIL_SPACER+AI.Yail.YAIL_QUOTE+AI.Yail.YAIL_OPEN_COMBINATION;h+=AI.Yail.YAIL_CLOSE_COMBINATION;h+=AI.Yail.YAIL_SPACER+AI.Yail.YAIL_DOUBLE_QUOTE+"make a list"+AI.Yail.YAIL_DOUBLE_QUOTE+AI.Yail.YAIL_CLOSE_COMBINATION;var k=AI.Yail.YAIL_LOCAL_VAR_TAG+d.getFieldValue("VAR");
h=e.valueToCode(d,"LIST",AI.Yail.ORDER_NONE)||h;d=e.statementToCode(d,"DO")||AI.Yail.YAIL_FALSE;return AI.Yail.YAIL_FOREACH+k+AI.Yail.YAIL_SPACER+AI.Yail.YAIL_BEGIN+d+AI.Yail.YAIL_CLOSE_COMBINATION+AI.Yail.YAIL_SPACER+h+AI.Yail.YAIL_CLOSE_COMBINATION};
AI.Yail.forBlock.controls_for_each_dict=function(d,e){var h=AI.Yail,k=AI.Yail.forBlock.controls_for_each_dict,m=Blockly.usePrefixInYail?"local_":"",p=h.YAIL_LOCAL_VAR_TAG+m+d.getFieldValue("KEY"),t=h.YAIL_LOCAL_VAR_TAG+m+d.getFieldValue("VALUE"),q=h.getVariableCommandAndName("item");m=q[1];var y=q[0]+m+h.YAIL_CLOSE_COMBINATION;q=k.generateGetListItemCode(y,1);y=k.generateGetListItemCode(y,2);p=k.generateSetVarCode(p,q);k=k.generateSetVarCode(t,y);k=h.YAIL_LET+h.YAIL_OPEN_COMBINATION+h.YAIL_SPACER+
p+h.YAIL_SPACER+k+h.YAIL_CLOSE_COMBINATION;p=e.statementToCode(d,"DO")||h.YAIL_FALSE;d=e.valueToCode(d,"DICT",h.ORDER_NONE)||h.YAIL_EMPTY_DICT;return h.YAIL_FOREACH+m+h.YAIL_SPACER+k+p+h.YAIL_CLOSE_COMBINATION+h.YAIL_SPACER+d+h.YAIL_CLOSE_COMBINATION};
AI.Yail.forBlock.controls_for_each_dict.generateGetListItemCode=function(d,e){var h=AI.Yail;return h.YAIL_CALL_YAIL_PRIMITIVE+"yail-list-get-item"+h.YAIL_SPACER+h.YAIL_OPEN_COMBINATION+h.YAIL_LIST_CONSTRUCTOR+h.YAIL_SPACER+d+h.YAIL_SPACER+e.toString()+h.YAIL_CLOSE_COMBINATION+h.YAIL_SPACER+h.YAIL_QUOTE+h.YAIL_OPEN_COMBINATION+"list number"+h.YAIL_CLOSE_COMBINATION+h.YAIL_SPACER+h.YAIL_DOUBLE_QUOTE+"select list item"+h.YAIL_DOUBLE_QUOTE+h.YAIL_CLOSE_COMBINATION};
AI.Yail.forBlock.controls_for_each_dict.generateSetVarCode=function(d,e){var h=AI.Yail;return h.YAIL_OPEN_COMBINATION+d+h.YAIL_SPACER+e+h.YAIL_CLOSE_COMBINATION};AI.Yail.forBlock.controls_break=function(d,e){d=AI.Yail.YAIL_OPEN_COMBINATION+AI.Yail.YAIL_BREAK+AI.Yail.YAIL_SPACER;return d=d+AI.Yail.YAIL_FALSE+AI.Yail.YAIL_CLOSE_COMBINATION};
AI.Yail.forBlock.controls_forRange=function(d,e){var h=AI.Yail.YAIL_LOCAL_VAR_TAG+d.getFieldValue("VAR"),k=e.valueToCode(d,"START",AI.Yail.ORDER_NONE)||0,m=e.valueToCode(d,"END",AI.Yail.ORDER_NONE)||0,p=e.valueToCode(d,"STEP",AI.Yail.ORDER_NONE)||0;d=e.statementToCode(d,"DO")||AI.Yail.YAIL_FALSE;return AI.Yail.YAIL_FORRANGE+h+AI.Yail.YAIL_SPACER+AI.Yail.YAIL_BEGIN+d+AI.Yail.YAIL_CLOSE_COMBINATION+AI.Yail.YAIL_SPACER+k+AI.Yail.YAIL_SPACER+m+AI.Yail.YAIL_SPACER+p+AI.Yail.YAIL_CLOSE_COMBINATION};
AI.Yail.forBlock.for_lexical_variable_get=function(d,e){return AI.Yail.lexical_variable_get.call(d)};AI.Yail.forBlock.controls_while=function(d,e){var h=e.valueToCode(d,"TEST",AI.Yail.ORDER_NONE)||AI.Yail.YAIL_FALSE;d=e.statementToCode(d,"DO")||AI.Yail.YAIL_FALSE;return AI.Yail.YAIL_WHILE+h+AI.Yail.YAIL_SPACER+AI.Yail.YAIL_BEGIN+d+AI.Yail.YAIL_CLOSE_COMBINATION+AI.Yail.YAIL_CLOSE_COMBINATION};
AI.Yail.forBlock.controls_do_then_return=function(d,e){var h=e.statementToCode(d,"STM")||AI.Yail.YAIL_FALSE;d=e.valueToCode(d,"VALUE",AI.Yail.ORDER_NONE)||AI.Yail.YAIL_FALSE;return[AI.Yail.YAIL_BEGIN+h+AI.Yail.YAIL_SPACER+d+AI.Yail.YAIL_CLOSE_COMBINATION,AI.Yail.ORDER_ATOMIC]};
AI.Yail.forBlock.controls_run_in_background=function(d,e){var h=e.valueToCode(d,"PROCEDURE",AI.Yail.ORDER_NONE)||AI.Yail.YAIL_NULL;d=e.valueToCode(d,"CALLBACK",AI.Yail.ORDER_NONE)||AI.Yail.YAIL_NULL;return AI.Yail.YailCallYialPrimitive("run-in-background",[h,d],["any","any"],"run in background")};
AI.Yail.forBlock.controls_run_after_period=function(d,e){var h=e.valueToCode(d,"MILLIS",AI.Yail.ORDER_NONE)||AI.Yail.YAIL_NULL;d=e.valueToCode(d,"PROCEDURE",AI.Yail.ORDER_NONE)||AI.Yail.YAIL_NULL;return AI.Yail.YailCallYialPrimitive("run-after-period",[h,d],["any","any"],"run after period")};AI.Yail.forBlock.controls_eval_but_ignore=function(d,e){d=e.valueToCode(d,"VALUE",AI.Yail.ORDER_NONE)||AI.Yail.YAIL_FALSE;return AI.Yail.YAIL_BEGIN+d+AI.Yail.YAIL_SPACER+'"ignored"'+AI.Yail.YAIL_CLOSE_COMBINATION};
AI.Yail.forBlock.controls_nothing=function(d,e){return["*the-null-value*",AI.Yail.ORDER_NONE]};
AI.Yail.forBlock.controls_openAnotherScreen=function(d,e){d=e.valueToCode(d,"SCREEN",AI.Yail.ORDER_NONE)||null;e=AI.Yail.YAIL_CALL_YAIL_PRIMITIVE+"open-another-screen"+AI.Yail.YAIL_SPACER;e=e+AI.Yail.YAIL_OPEN_COMBINATION+AI.Yail.YAIL_LIST_CONSTRUCTOR+AI.Yail.YAIL_SPACER;e=e+d+AI.Yail.YAIL_CLOSE_COMBINATION;e=e+AI.Yail.YAIL_SPACER+AI.Yail.YAIL_QUOTE+AI.Yail.YAIL_OPEN_COMBINATION;e=e+"text"+AI.Yail.YAIL_CLOSE_COMBINATION+AI.Yail.YAIL_SPACER;return e=e+AI.Yail.YAIL_DOUBLE_QUOTE+"open another screen"+
AI.Yail.YAIL_DOUBLE_QUOTE+AI.Yail.YAIL_CLOSE_COMBINATION};
AI.Yail.forBlock.controls_openAnotherScreenWithStartValue=function(d,e){var h=e.valueToCode(d,"SCREENNAME",AI.Yail.ORDER_NONE)||null;d=e.valueToCode(d,"STARTVALUE",AI.Yail.ORDER_NONE)||null;e=AI.Yail.YAIL_CALL_YAIL_PRIMITIVE+"open-another-screen-with-start-value"+AI.Yail.YAIL_SPACER;e=e+AI.Yail.YAIL_OPEN_COMBINATION+AI.Yail.YAIL_LIST_CONSTRUCTOR+AI.Yail.YAIL_SPACER;e=e+h+AI.Yail.YAIL_SPACER+d+AI.Yail.YAIL_CLOSE_COMBINATION;e=e+AI.Yail.YAIL_SPACER+AI.Yail.YAIL_QUOTE+AI.Yail.YAIL_OPEN_COMBINATION;e=
e+"text any"+AI.Yail.YAIL_CLOSE_COMBINATION+AI.Yail.YAIL_SPACER;return e=e+AI.Yail.YAIL_DOUBLE_QUOTE+"open another screen with start value"+AI.Yail.YAIL_DOUBLE_QUOTE+AI.Yail.YAIL_CLOSE_COMBINATION};
AI.Yail.forBlock.controls_getStartValue=function(d,e){d=AI.Yail.YAIL_CALL_YAIL_PRIMITIVE+"get-start-value"+AI.Yail.YAIL_SPACER;d=d+AI.Yail.YAIL_OPEN_COMBINATION+AI.Yail.YAIL_LIST_CONSTRUCTOR+AI.Yail.YAIL_SPACER;d+=AI.Yail.YAIL_CLOSE_COMBINATION;d=d+AI.Yail.YAIL_SPACER+AI.Yail.YAIL_QUOTE+AI.Yail.YAIL_OPEN_COMBINATION;d=d+AI.Yail.YAIL_CLOSE_COMBINATION+AI.Yail.YAIL_SPACER;d=d+AI.Yail.YAIL_DOUBLE_QUOTE+"get start value"+AI.Yail.YAIL_DOUBLE_QUOTE+AI.Yail.YAIL_CLOSE_COMBINATION;return[d,AI.Yail.ORDER_ATOMIC]};
AI.Yail.forBlock.controls_closeScreen=function(d,e){d=AI.Yail.YAIL_CALL_YAIL_PRIMITIVE+"close-screen"+AI.Yail.YAIL_SPACER;d=d+AI.Yail.YAIL_OPEN_COMBINATION+AI.Yail.YAIL_LIST_CONSTRUCTOR+AI.Yail.YAIL_SPACER;d+=AI.Yail.YAIL_CLOSE_COMBINATION;d=d+AI.Yail.YAIL_SPACER+AI.Yail.YAIL_QUOTE+AI.Yail.YAIL_OPEN_COMBINATION;d=d+AI.Yail.YAIL_CLOSE_COMBINATION+AI.Yail.YAIL_SPACER;return d=d+AI.Yail.YAIL_DOUBLE_QUOTE+"close screen"+AI.Yail.YAIL_DOUBLE_QUOTE+AI.Yail.YAIL_CLOSE_COMBINATION};
AI.Yail.forBlock.controls_closeScreenWithValue=function(d,e){d=e.valueToCode(d,"SCREEN",AI.Yail.ORDER_NONE)||null;e=AI.Yail.YAIL_CALL_YAIL_PRIMITIVE+"close-screen-with-value"+AI.Yail.YAIL_SPACER;e=e+AI.Yail.YAIL_OPEN_COMBINATION+AI.Yail.YAIL_LIST_CONSTRUCTOR+AI.Yail.YAIL_SPACER;e=e+d+AI.Yail.YAIL_CLOSE_COMBINATION;e=e+AI.Yail.YAIL_SPACER+AI.Yail.YAIL_QUOTE+AI.Yail.YAIL_OPEN_COMBINATION;e=e+"any"+AI.Yail.YAIL_CLOSE_COMBINATION+AI.Yail.YAIL_SPACER;return e=e+AI.Yail.YAIL_DOUBLE_QUOTE+"close screen with value"+
AI.Yail.YAIL_DOUBLE_QUOTE+AI.Yail.YAIL_CLOSE_COMBINATION};
AI.Yail.forBlock.controls_closeApplication=function(d,e){d=AI.Yail.YAIL_CALL_YAIL_PRIMITIVE+"close-application"+AI.Yail.YAIL_SPACER;d=d+AI.Yail.YAIL_OPEN_COMBINATION+AI.Yail.YAIL_LIST_CONSTRUCTOR+AI.Yail.YAIL_SPACER;d+=AI.Yail.YAIL_CLOSE_COMBINATION;d=d+AI.Yail.YAIL_SPACER+AI.Yail.YAIL_QUOTE+AI.Yail.YAIL_OPEN_COMBINATION;d=d+AI.Yail.YAIL_CLOSE_COMBINATION+AI.Yail.YAIL_SPACER;return d=d+AI.Yail.YAIL_DOUBLE_QUOTE+"close application"+AI.Yail.YAIL_DOUBLE_QUOTE+AI.Yail.YAIL_CLOSE_COMBINATION};
AI.Yail.forBlock.controls_getPlainStartText=function(d,e){d=AI.Yail.YAIL_CALL_YAIL_PRIMITIVE+"get-plain-start-text"+AI.Yail.YAIL_SPACER;d=d+AI.Yail.YAIL_OPEN_COMBINATION+AI.Yail.YAIL_LIST_CONSTRUCTOR+AI.Yail.YAIL_SPACER;d+=AI.Yail.YAIL_CLOSE_COMBINATION;d=d+AI.Yail.YAIL_SPACER+AI.Yail.YAIL_QUOTE+AI.Yail.YAIL_OPEN_COMBINATION;d=d+AI.Yail.YAIL_CLOSE_COMBINATION+AI.Yail.YAIL_SPACER;d=d+AI.Yail.YAIL_DOUBLE_QUOTE+"get plain start text"+AI.Yail.YAIL_DOUBLE_QUOTE+AI.Yail.YAIL_CLOSE_COMBINATION;return[d,
AI.Yail.ORDER_ATOMIC]};
AI.Yail.forBlock.controls_closeScreenWithPlainText=function(d,e){d=e.valueToCode(d,"TEXT",AI.Yail.ORDER_NONE)||AI.Yail.YAIL_FALSE;e=AI.Yail.YAIL_CALL_YAIL_PRIMITIVE+"close-screen-with-plain-text"+AI.Yail.YAIL_SPACER;e=e+AI.Yail.YAIL_OPEN_COMBINATION+AI.Yail.YAIL_LIST_CONSTRUCTOR+AI.Yail.YAIL_SPACER;e=e+d+AI.Yail.YAIL_CLOSE_COMBINATION;e=e+AI.Yail.YAIL_SPACER+AI.Yail.YAIL_QUOTE+AI.Yail.YAIL_OPEN_COMBINATION;e=e+"text"+AI.Yail.YAIL_CLOSE_COMBINATION+AI.Yail.YAIL_SPACER;return e=e+AI.Yail.YAIL_DOUBLE_QUOTE+
"close screen with plain text"+AI.Yail.YAIL_DOUBLE_QUOTE+AI.Yail.YAIL_CLOSE_COMBINATION};/*

 @fileoverview Dictionaries blocks yail generators for Blockly, modified for MIT App Inventor.
 @author data1013@mit.edu (Danny Tang)
*/
AI.Yail.dictionaries={};
AI.Yail.forBlock.dictionaries_create_with=function(d,e){var h=AI.Yail.YAIL_CALL_YAIL_PRIMITIVE+"make-yail-dictionary"+AI.Yail.YAIL_SPACER;h+=AI.Yail.YAIL_OPEN_COMBINATION+AI.Yail.YAIL_LIST_CONSTRUCTOR+AI.Yail.YAIL_SPACER;for(var k=0,m=0;m<d.itemCount_;m++){var p=e.valueToCode(d,"ADD"+m,AI.Yail.ORDER_NONE)||AI.Yail.YAIL_NULL;null!=p&&(h+=p+AI.Yail.YAIL_SPACER,k++)}h+=AI.Yail.YAIL_CLOSE_COMBINATION+AI.Yail.YAIL_SPACER+AI.Yail.YAIL_QUOTE+AI.Yail.YAIL_OPEN_COMBINATION;for(m=0;m<k;m++)h+="pair"+AI.Yail.YAIL_SPACER;
h+=AI.Yail.YAIL_CLOSE_COMBINATION;h+=AI.Yail.YAIL_SPACER+AI.Yail.YAIL_DOUBLE_QUOTE+"make a dictionary"+AI.Yail.YAIL_DOUBLE_QUOTE+AI.Yail.YAIL_CLOSE_COMBINATION;return[h,AI.Yail.ORDER_ATOMIC]};
AI.Yail.forBlock.pair=function(d,e){var h=e.valueToCode(d,"KEY",AI.Yail.ORDER_NONE)||AI.Yail.YAIL_NULL;d=e.valueToCode(d,"VALUE",AI.Yail.ORDER_NONE)||AI.Yail.YAIL_NULL;e=AI.Yail.YAIL_CALL_YAIL_PRIMITIVE+"make-dictionary-pair"+AI.Yail.YAIL_SPACER;e=e+AI.Yail.YAIL_OPEN_COMBINATION+AI.Yail.YAIL_LIST_CONSTRUCTOR+AI.Yail.YAIL_SPACER;e=e+h+AI.Yail.YAIL_SPACER+d+AI.Yail.YAIL_SPACER+AI.Yail.YAIL_CLOSE_COMBINATION;e=e+AI.Yail.YAIL_SPACER+AI.Yail.YAIL_QUOTE+AI.Yail.YAIL_OPEN_COMBINATION;e=e+"key any"+AI.Yail.YAIL_CLOSE_COMBINATION+
AI.Yail.YAIL_SPACER;e=e+AI.Yail.YAIL_SPACER+AI.Yail.YAIL_DOUBLE_QUOTE+"make a pair"+AI.Yail.YAIL_DOUBLE_QUOTE+AI.Yail.YAIL_CLOSE_COMBINATION;return[e,AI.Yail.ORDER_ATOMIC]};
AI.Yail.forBlock.dictionaries_set_pair=function(d,e){var h=e.valueToCode(d,"KEY",AI.Yail.ORDER_NONE)||AI.Yail.YAIL_NULL,k=e.valueToCode(d,"DICT",AI.Yail.ORDER_NONE)||AI.Yail.YAIL_EMPTY_DICT;d=e.valueToCode(d,"VALUE",AI.Yail.ORDER_NONE)||AI.Yail.YAIL_NULL;e=AI.Yail.YAIL_CALL_YAIL_PRIMITIVE+"yail-dictionary-set-pair"+AI.Yail.YAIL_SPACER;e=e+AI.Yail.YAIL_OPEN_COMBINATION+AI.Yail.YAIL_LIST_CONSTRUCTOR+AI.Yail.YAIL_SPACER;e=e+h+AI.Yail.YAIL_SPACER+k+AI.Yail.YAIL_SPACER;e=e+d+AI.Yail.YAIL_CLOSE_COMBINATION;
e=e+AI.Yail.YAIL_SPACER+AI.Yail.YAIL_QUOTE+AI.Yail.YAIL_OPEN_COMBINATION;e=e+"key dictionary any"+AI.Yail.YAIL_CLOSE_COMBINATION+AI.Yail.YAIL_SPACER;return e=e+AI.Yail.YAIL_SPACER+AI.Yail.YAIL_DOUBLE_QUOTE+"set value for key in dictionary to value"+AI.Yail.YAIL_DOUBLE_QUOTE+AI.Yail.YAIL_CLOSE_COMBINATION};
AI.Yail.forBlock.dictionaries_delete_pair=function(d,e){var h=e.valueToCode(d,"DICT",AI.Yail.ORDER_NONE)||AI.Yail.YAIL_EMPTY_DICT;d=e.valueToCode(d,"KEY",AI.Yail.ORDER_NONE)||AI.Yail.YAIL_NULL;e=AI.Yail.YAIL_CALL_YAIL_PRIMITIVE+"yail-dictionary-delete-pair"+AI.Yail.YAIL_SPACER;e=e+AI.Yail.YAIL_OPEN_COMBINATION+AI.Yail.YAIL_LIST_CONSTRUCTOR+AI.Yail.YAIL_SPACER;e=e+h+AI.Yail.YAIL_SPACER+d+AI.Yail.YAIL_CLOSE_COMBINATION;e=e+AI.Yail.YAIL_SPACER+AI.Yail.YAIL_QUOTE+AI.Yail.YAIL_OPEN_COMBINATION;e=e+"dictionary key"+
AI.Yail.YAIL_CLOSE_COMBINATION+AI.Yail.YAIL_SPACER;return e=e+AI.Yail.YAIL_SPACER+AI.Yail.YAIL_DOUBLE_QUOTE+"delete dictionary pair"+AI.Yail.YAIL_DOUBLE_QUOTE+AI.Yail.YAIL_CLOSE_COMBINATION};
AI.Yail.forBlock.dictionaries_lookup=function(d,e){var h=e.valueToCode(d,"KEY",AI.Yail.ORDER_NONE)||AI.Yail.YAIL_FALSE,k=e.valueToCode(d,"DICT",AI.Yail.ORDER_NONE)||AI.Yail.YAIL_EMPTY_DICT;d=e.valueToCode(d,"NOTFOUND",AI.Yail.ORDER_NONE)||AI.Yail.YAIL_NULL;e=AI.Yail.YAIL_CALL_YAIL_PRIMITIVE+"yail-dictionary-lookup"+AI.Yail.YAIL_SPACER;e=e+AI.Yail.YAIL_OPEN_COMBINATION+AI.Yail.YAIL_LIST_CONSTRUCTOR+AI.Yail.YAIL_SPACER;e=e+h+AI.Yail.YAIL_SPACER+k+AI.Yail.YAIL_SPACER+d+AI.Yail.YAIL_CLOSE_COMBINATION;
e=e+AI.Yail.YAIL_SPACER+AI.Yail.YAIL_QUOTE+AI.Yail.YAIL_OPEN_COMBINATION;e=e+"key dictionary any"+AI.Yail.YAIL_CLOSE_COMBINATION+AI.Yail.YAIL_SPACER;e=e+AI.Yail.YAIL_SPACER+AI.Yail.YAIL_DOUBLE_QUOTE+"dictionary lookup"+AI.Yail.YAIL_DOUBLE_QUOTE+AI.Yail.YAIL_CLOSE_COMBINATION;return[e,AI.Yail.ORDER_ATOMIC]};
AI.Yail.forBlock.dictionaries_recursive_lookup=function(d,e){var h=e.valueToCode(d,"KEYS",AI.Yail.ORDER_NONE)||AI.Yail.YAIL_FALSE,k=e.valueToCode(d,"DICT",AI.Yail.ORDER_NONE)||AI.Yail.YAIL_EMPTY_DICT;d=e.valueToCode(d,"NOTFOUND",AI.Yail.ORDER_NONE)||AI.Yail.YAIL_NULL;e=AI.Yail.YAIL_CALL_YAIL_PRIMITIVE+"yail-dictionary-recursive-lookup"+AI.Yail.YAIL_SPACER;e=e+AI.Yail.YAIL_OPEN_COMBINATION+AI.Yail.YAIL_LIST_CONSTRUCTOR+AI.Yail.YAIL_SPACER;e=e+h+AI.Yail.YAIL_SPACER+k+AI.Yail.YAIL_SPACER+d+AI.Yail.YAIL_CLOSE_COMBINATION;
e=e+AI.Yail.YAIL_SPACER+AI.Yail.YAIL_QUOTE+AI.Yail.YAIL_OPEN_COMBINATION;e=e+"list dictionary any"+AI.Yail.YAIL_CLOSE_COMBINATION+AI.Yail.YAIL_SPACER;e=e+AI.Yail.YAIL_SPACER+AI.Yail.YAIL_DOUBLE_QUOTE+"dictionary recursive lookup"+AI.Yail.YAIL_DOUBLE_QUOTE+AI.Yail.YAIL_CLOSE_COMBINATION;return[e,AI.Yail.ORDER_ATOMIC]};
AI.Yail.forBlock.dictionaries_recursive_set=function(d,e){var h=e.valueToCode(d,"KEYS",AI.Yail.ORDER_NONE)||AI.Yail.YAIL_EMPTY_LIST,k=e.valueToCode(d,"DICT",AI.Yail.ORDER_NONE)||AI.Yail.YAIL_EMPTY_DICT;d=e.valueToCode(d,"VALUE",AI.Yail.ORDER_NONE)||AI.Yail.YAIL_FALSE;e=AI.Yail.YAIL_CALL_YAIL_PRIMITIVE+"yail-dictionary-recursive-set"+AI.Yail.YAIL_SPACER;e+=AI.Yail.YAIL_OPEN_COMBINATION+AI.Yail.YAIL_LIST_CONSTRUCTOR+AI.Yail.YAIL_SPACER;e+=h+AI.Yail.YAIL_SPACER+k+AI.Yail.YAIL_SPACER+d+AI.Yail.YAIL_CLOSE_COMBINATION;
e=e+AI.Yail.YAIL_SPACER+AI.Yail.YAIL_QUOTE+AI.Yail.YAIL_OPEN_COMBINATION;e=e+"list dictionary any"+AI.Yail.YAIL_CLOSE_COMBINATION+AI.Yail.YAIL_SPACER;return e=e+AI.Yail.YAIL_SPACER+AI.Yail.YAIL_DOUBLE_QUOTE+"dictionary recursive set"+AI.Yail.YAIL_DOUBLE_QUOTE+AI.Yail.YAIL_CLOSE_COMBINATION};
AI.Yail.forBlock.dictionaries_getters=function(d,e){var h=d.getFieldValue("OP"),k=AI.Yail.forBlock.dictionaries_getters.OPERATORS[h],m=k[0];h=k[1];d=e.valueToCode(d,"DICT",k[2])||AI.Yail.YAIL_EMPTY_DICT;e=AI.Yail.YAIL_CALL_YAIL_PRIMITIVE+m+AI.Yail.YAIL_SPACER;e=e+AI.Yail.YAIL_OPEN_COMBINATION+AI.Yail.YAIL_LIST_CONSTRUCTOR+AI.Yail.YAIL_SPACER+d+AI.Yail.YAIL_CLOSE_COMBINATION;e=e+AI.Yail.YAIL_SPACER+AI.Yail.YAIL_QUOTE+AI.Yail.YAIL_OPEN_COMBINATION+"dictionary"+AI.Yail.YAIL_CLOSE_COMBINATION+AI.Yail.YAIL_SPACER;
e=e+AI.Yail.YAIL_DOUBLE_QUOTE+h+AI.Yail.YAIL_DOUBLE_QUOTE+AI.Yail.YAIL_CLOSE_COMBINATION;return[e,AI.Yail.ORDER_ATOMIC]};AI.Yail.forBlock.dictionaries_getters.OPERATORS={KEYS:["yail-dictionary-get-keys","get a dictionary's keys",AI.Yail.ORDER_NONE],VALUES:["yail-dictionary-get-values","get a dictionary's values",AI.Yail.ORDER_NONE]};AI.Yail.forBlock.dictionaries_get_values=function(d,e){return AI.Yail.forBlock.dictionaries_getters(d,e)};
AI.Yail.forBlock.dictionaries_is_key_in=function(d,e){var h=e.valueToCode(d,"KEY",AI.Yail.ORDER_NONE)||AI.Yail.YAIL_FALSE;d=e.valueToCode(d,"DICT",AI.Yail.ORDER_NONE)||AI.Yail.YAIL_EMPTY_DICT;e=AI.Yail.YAIL_CALL_YAIL_PRIMITIVE+"yail-dictionary-is-key-in"+AI.Yail.YAIL_SPACER;e=e+AI.Yail.YAIL_OPEN_COMBINATION+AI.Yail.YAIL_LIST_CONSTRUCTOR+AI.Yail.YAIL_SPACER;e=e+h+AI.Yail.YAIL_SPACER+d+AI.Yail.YAIL_SPACER+AI.Yail.YAIL_CLOSE_COMBINATION;e=e+AI.Yail.YAIL_SPACER+AI.Yail.YAIL_QUOTE+AI.Yail.YAIL_OPEN_COMBINATION;
e=e+"key dictionary"+AI.Yail.YAIL_CLOSE_COMBINATION+AI.Yail.YAIL_SPACER;e=e+AI.Yail.YAIL_SPACER+AI.Yail.YAIL_DOUBLE_QUOTE+"is key in dict?"+AI.Yail.YAIL_DOUBLE_QUOTE+AI.Yail.YAIL_CLOSE_COMBINATION;return[e,AI.Yail.ORDER_ATOMIC]};
AI.Yail.forBlock.dictionaries_length=function(d,e){d=e.valueToCode(d,"DICT",AI.Yail.ORDER_NONE)||AI.Yail.YAIL_EMPTY_DICT;e=AI.Yail.YAIL_CALL_YAIL_PRIMITIVE+"yail-dictionary-length"+AI.Yail.YAIL_SPACER;e=e+AI.Yail.YAIL_OPEN_COMBINATION+AI.Yail.YAIL_LIST_CONSTRUCTOR+AI.Yail.YAIL_SPACER;e=e+d+AI.Yail.YAIL_SPACER+AI.Yail.YAIL_CLOSE_COMBINATION;e=e+AI.Yail.YAIL_SPACER+AI.Yail.YAIL_QUOTE+AI.Yail.YAIL_OPEN_COMBINATION;e=e+"dictionary"+AI.Yail.YAIL_CLOSE_COMBINATION+AI.Yail.YAIL_SPACER;e=e+AI.Yail.YAIL_SPACER+
AI.Yail.YAIL_DOUBLE_QUOTE+"get a dictionary's length"+AI.Yail.YAIL_DOUBLE_QUOTE+AI.Yail.YAIL_CLOSE_COMBINATION;return[e,AI.Yail.ORDER_ATOMIC]};
AI.Yail.forBlock.dictionaries_alist_to_dict=function(d,e){d=e.valueToCode(d,"PAIRS",AI.Yail.ORDER_NONE)||AI.Yail.YAIL_EMPTY_DICT;e=AI.Yail.YAIL_CALL_YAIL_PRIMITIVE+"yail-dictionary-alist-to-dict"+AI.Yail.YAIL_SPACER;e=e+AI.Yail.YAIL_OPEN_COMBINATION+AI.Yail.YAIL_LIST_CONSTRUCTOR+AI.Yail.YAIL_SPACER;e=e+d+AI.Yail.YAIL_SPACER+AI.Yail.YAIL_CLOSE_COMBINATION;e=e+AI.Yail.YAIL_SPACER+AI.Yail.YAIL_QUOTE+AI.Yail.YAIL_OPEN_COMBINATION;e=e+"list"+AI.Yail.YAIL_CLOSE_COMBINATION+AI.Yail.YAIL_SPACER;e=e+AI.Yail.YAIL_SPACER+
AI.Yail.YAIL_DOUBLE_QUOTE+"convert an alist to a dictionary"+AI.Yail.YAIL_DOUBLE_QUOTE+AI.Yail.YAIL_CLOSE_COMBINATION;return[e,AI.Yail.ORDER_ATOMIC]};
AI.Yail.forBlock.dictionaries_dict_to_alist=function(d,e){d=e.valueToCode(d,"DICT",AI.Yail.ORDER_NONE)||AI.Yail.YAIL_EMPTY_DICT;e=AI.Yail.YAIL_CALL_YAIL_PRIMITIVE+"yail-dictionary-dict-to-alist"+AI.Yail.YAIL_SPACER;e=e+AI.Yail.YAIL_OPEN_COMBINATION+AI.Yail.YAIL_LIST_CONSTRUCTOR+AI.Yail.YAIL_SPACER;e=e+d+AI.Yail.YAIL_SPACER+AI.Yail.YAIL_CLOSE_COMBINATION;e=e+AI.Yail.YAIL_SPACER+AI.Yail.YAIL_QUOTE+AI.Yail.YAIL_OPEN_COMBINATION;e=e+"dictionary"+AI.Yail.YAIL_CLOSE_COMBINATION+AI.Yail.YAIL_SPACER;e=e+
AI.Yail.YAIL_SPACER+AI.Yail.YAIL_DOUBLE_QUOTE+"convert a dictionary to an alist"+AI.Yail.YAIL_DOUBLE_QUOTE+AI.Yail.YAIL_CLOSE_COMBINATION;return[e,AI.Yail.ORDER_ATOMIC]};
AI.Yail.forBlock.dictionaries_copy=function(d,e){d=e.valueToCode(d,"DICT",AI.Yail.ORDER_NONE)||AI.Yail.YAIL_EMPTY_DICT;e=AI.Yail.YAIL_CALL_YAIL_PRIMITIVE+"yail-dictionary-copy"+AI.Yail.YAIL_SPACER;e=e+AI.Yail.YAIL_OPEN_COMBINATION+AI.Yail.YAIL_LIST_CONSTRUCTOR+AI.Yail.YAIL_SPACER;e=e+d+AI.Yail.YAIL_SPACER+AI.Yail.YAIL_CLOSE_COMBINATION;e=e+AI.Yail.YAIL_SPACER+AI.Yail.YAIL_QUOTE+AI.Yail.YAIL_OPEN_COMBINATION;e=e+"dictionary"+AI.Yail.YAIL_CLOSE_COMBINATION+AI.Yail.YAIL_SPACER;e=e+AI.Yail.YAIL_SPACER+
AI.Yail.YAIL_DOUBLE_QUOTE+"get a shallow copy of a dict"+AI.Yail.YAIL_DOUBLE_QUOTE+AI.Yail.YAIL_CLOSE_COMBINATION;return[e,AI.Yail.ORDER_ATOMIC]};
AI.Yail.forBlock.dictionaries_combine_dicts=function(d,e){var h=e.valueToCode(d,"DICT1",AI.Yail.ORDER_NONE)||AI.Yail.YAIL_FALSE;d=e.valueToCode(d,"DICT2",AI.Yail.ORDER_NONE)||AI.Yail.YAIL_EMPTY_DICT;e=AI.Yail.YAIL_CALL_YAIL_PRIMITIVE+"yail-dictionary-combine-dicts"+AI.Yail.YAIL_SPACER;e=e+AI.Yail.YAIL_OPEN_COMBINATION+AI.Yail.YAIL_LIST_CONSTRUCTOR+AI.Yail.YAIL_SPACER;e=e+h+AI.Yail.YAIL_SPACER+d+AI.Yail.YAIL_SPACER+AI.Yail.YAIL_CLOSE_COMBINATION;e=e+AI.Yail.YAIL_SPACER+AI.Yail.YAIL_QUOTE+AI.Yail.YAIL_OPEN_COMBINATION;
e=e+"dictionary dictionary"+AI.Yail.YAIL_CLOSE_COMBINATION+AI.Yail.YAIL_SPACER;return e=e+AI.Yail.YAIL_SPACER+AI.Yail.YAIL_DOUBLE_QUOTE+"combine 2 dictionaries"+AI.Yail.YAIL_DOUBLE_QUOTE+AI.Yail.YAIL_CLOSE_COMBINATION};
AI.Yail.forBlock.dictionaries_walk_tree=function(d,e){var h=e.valueToCode(d,"PATH",AI.Yail.ORDER_NONE)||AI.Yail.YAIL_EMPTY_YAIL_LIST;d=e.valueToCode(d,"DICT",AI.Yail.ORDER_NONE)||AI.Yail.YAIL_EMPTY_DICT;return[AI.Yail.YAIL_CALL_YAIL_PRIMITIVE+"yail-dictionary-walk"+AI.Yail.YAIL_SPACER+AI.Yail.YAIL_OPEN_COMBINATION+AI.Yail.YAIL_LIST_CONSTRUCTOR+AI.Yail.YAIL_SPACER+h+AI.Yail.YAIL_SPACER+d+AI.Yail.YAIL_SPACER+AI.Yail.YAIL_CLOSE_COMBINATION+AI.Yail.YAIL_SPACER+AI.Yail.YAIL_QUOTE+AI.Yail.YAIL_OPEN_COMBINATION+
"list any"+AI.Yail.YAIL_CLOSE_COMBINATION+AI.Yail.YAIL_SPACER+AI.Yail.YAIL_DOUBLE_QUOTE+"list by walking key path in dictionary"+AI.Yail.YAIL_DOUBLE_QUOTE+AI.Yail.YAIL_CLOSE_COMBINATION,AI.Yail.ORDER_ATOMIC]};AI.Yail.forBlock.dictionaries_walk_all=function(d,e){return[AI.Yail.YAIL_CONSTANT_ALL,AI.Yail.ORDER_ATOMIC]};
AI.Yail.forBlock.dictionaries_is_dict=function(d,e){d=e.valueToCode(d,"THING",AI.Yail.ORDER_NONE)||AI.Yail.YAIL_EMPTY_DICT;e=AI.Yail.YAIL_CALL_YAIL_PRIMITIVE+"yail-dictionary?"+AI.Yail.YAIL_SPACER;e=e+AI.Yail.YAIL_OPEN_COMBINATION+AI.Yail.YAIL_LIST_CONSTRUCTOR+AI.Yail.YAIL_SPACER;e=e+d+AI.Yail.YAIL_SPACER+AI.Yail.YAIL_CLOSE_COMBINATION;e=e+AI.Yail.YAIL_SPACER+AI.Yail.YAIL_QUOTE+AI.Yail.YAIL_OPEN_COMBINATION;e=e+"any"+AI.Yail.YAIL_CLOSE_COMBINATION+AI.Yail.YAIL_SPACER;e=e+AI.Yail.YAIL_SPACER+AI.Yail.YAIL_DOUBLE_QUOTE+
"check if something is a dictionary"+AI.Yail.YAIL_DOUBLE_QUOTE+AI.Yail.YAIL_CLOSE_COMBINATION;return[e,AI.Yail.ORDER_ATOMIC]};AI.Yail.helpers={};AI.Yail.forBlock.helpers_dropdown=function(d,e){e=d.workspace.getComponentDatabase().getOptionList(d.key_);var h=d.getFieldValue("OPTION"),k=e.options.find(function(m){return m.name==h});d="(static-field "+e.className+' "'+h+'")';k=k.value;"java.lang.String"==e.underlyingType&&(k=AI.Yail.quote_(k));return[AI.Yail.forRepl?"(protect-enum "+d+" "+k+")":d,AI.Yail.ORDER_ATOMIC]};AI.Yail.forBlock.helpers_screen_names=function(d,e){return[AI.Yail.quote_(d.getFieldValue("SCREEN")),AI.Yail.ORDER_ATOMIC]};
AI.Yail.forBlock.helpers_assets=function(d,e){return(d=d.getField("ASSET"))?[AI.Yail.quote_(d.getValue()),AI.Yail.ORDER_ATOMIC]:[AI.Yail.quote_(""),AI.Yail.ORDER_ATOMIC]};AI.Yail.forBlock.helpers_providermodel=function(d,e){d=d.getField("PROVIDERMODEL");if(!d)return[AI.Yail.quote_(""),AI.Yail.ORDER_ATOMIC];d=d.getValue();return[AI.Yail.quote_(top.chatproxyinfo.model[d]),AI.Yail.ORDER_ATOMIC]};
AI.Yail.forBlock.helpers_provider=function(d,e){d=d.getField("PROVIDER");if(!d)return[AI.Yail.quote_(""),AI.Yail.ORDER_ATOMIC];d=d.getValue();return[AI.Yail.quote_(d),AI.Yail.ORDER_ATOMIC]};/*

 @fileoverview Lists blocks yail generators for Blockly, modified for MIT App Inventor.
 @author mckinney@mit.edu (Andrew F. McKinney)
*/
AI.Yail.lists={};AI.Yail.emptyListCode=AI.Yail.YAIL_CALL_YAIL_PRIMITIVE+"make-yail-list"+AI.Yail.YAIL_SPACER;AI.Yail.emptyListCode+=AI.Yail.YAIL_OPEN_COMBINATION+AI.Yail.YAIL_LIST_CONSTRUCTOR+AI.Yail.YAIL_SPACER;AI.Yail.emptyListCode+=AI.Yail.YAIL_CLOSE_COMBINATION+AI.Yail.YAIL_SPACER+AI.Yail.YAIL_QUOTE+AI.Yail.YAIL_OPEN_COMBINATION;AI.Yail.emptyListCode+=AI.Yail.YAIL_CLOSE_COMBINATION;AI.Yail.emptyListCode+=AI.Yail.YAIL_SPACER+AI.Yail.YAIL_DOUBLE_QUOTE+"make a list"+AI.Yail.YAIL_DOUBLE_QUOTE+AI.Yail.YAIL_CLOSE_COMBINATION;
AI.Yail.forBlock.lists_create_with=function(d,e){var h=AI.Yail.YAIL_CALL_YAIL_PRIMITIVE+"make-yail-list"+AI.Yail.YAIL_SPACER;h+=AI.Yail.YAIL_OPEN_COMBINATION+AI.Yail.YAIL_LIST_CONSTRUCTOR+AI.Yail.YAIL_SPACER;for(var k=0,m=0;m<d.itemCount_;m++){var p=e.valueToCode(d,"ADD"+m,AI.Yail.ORDER_NONE)||null;null!=p&&(h+=p+AI.Yail.YAIL_SPACER,k++)}h+=AI.Yail.YAIL_CLOSE_COMBINATION+AI.Yail.YAIL_SPACER+AI.Yail.YAIL_QUOTE+AI.Yail.YAIL_OPEN_COMBINATION;for(m=0;m<k;m++)h+="any"+AI.Yail.YAIL_SPACER;h+=AI.Yail.YAIL_CLOSE_COMBINATION;
h+=AI.Yail.YAIL_SPACER+AI.Yail.YAIL_DOUBLE_QUOTE+"make a list"+AI.Yail.YAIL_DOUBLE_QUOTE+AI.Yail.YAIL_CLOSE_COMBINATION;return[h,AI.Yail.ORDER_ATOMIC]};
AI.Yail.forBlock.lists_select_item=function(d,e){var h=e.valueToCode(d,"LIST",AI.Yail.ORDER_NONE)||AI.Yail.emptyListCode;d=e.valueToCode(d,"NUM",AI.Yail.ORDER_NONE)||1;e=AI.Yail.YAIL_CALL_YAIL_PRIMITIVE+"yail-list-get-item"+AI.Yail.YAIL_SPACER;e=e+AI.Yail.YAIL_OPEN_COMBINATION+AI.Yail.YAIL_LIST_CONSTRUCTOR+AI.Yail.YAIL_SPACER;e=e+h+AI.Yail.YAIL_SPACER+d+AI.Yail.YAIL_CLOSE_COMBINATION;e=e+AI.Yail.YAIL_SPACER+AI.Yail.YAIL_QUOTE+AI.Yail.YAIL_OPEN_COMBINATION;e=e+"list number"+AI.Yail.YAIL_CLOSE_COMBINATION+
AI.Yail.YAIL_SPACER;e=e+AI.Yail.YAIL_DOUBLE_QUOTE+"select list item"+AI.Yail.YAIL_DOUBLE_QUOTE+AI.Yail.YAIL_CLOSE_COMBINATION;return[e,AI.Yail.ORDER_ATOMIC]};
AI.Yail.forBlock.lists_replace_item=function(d,e){var h=e.valueToCode(d,"LIST",AI.Yail.ORDER_NONE)||AI.Yail.emptyListCode,k=e.valueToCode(d,"NUM",AI.Yail.ORDER_NONE)||1;d=e.valueToCode(d,"ITEM",AI.Yail.ORDER_NONE)||AI.Yail.YAIL_FALSE;e=AI.Yail.YAIL_CALL_YAIL_PRIMITIVE+"yail-list-set-item!"+AI.Yail.YAIL_SPACER;e=e+AI.Yail.YAIL_OPEN_COMBINATION+AI.Yail.YAIL_LIST_CONSTRUCTOR+AI.Yail.YAIL_SPACER;e=e+h+AI.Yail.YAIL_SPACER+k;e=e+AI.Yail.YAIL_SPACER+d+AI.Yail.YAIL_CLOSE_COMBINATION;e=e+AI.Yail.YAIL_SPACER+
AI.Yail.YAIL_QUOTE+AI.Yail.YAIL_OPEN_COMBINATION;e=e+"list number any"+AI.Yail.YAIL_CLOSE_COMBINATION+AI.Yail.YAIL_SPACER;return e=e+AI.Yail.YAIL_DOUBLE_QUOTE+"replace list item"+AI.Yail.YAIL_DOUBLE_QUOTE+AI.Yail.YAIL_CLOSE_COMBINATION};
AI.Yail.forBlock.lists_remove_item=function(d,e){var h=e.valueToCode(d,"LIST",AI.Yail.ORDER_NONE)||AI.Yail.emptyListCode;d=e.valueToCode(d,"INDEX",AI.Yail.ORDER_NONE)||1;e=AI.Yail.YAIL_CALL_YAIL_PRIMITIVE+"yail-list-remove-item!"+AI.Yail.YAIL_SPACER;e=e+AI.Yail.YAIL_OPEN_COMBINATION+AI.Yail.YAIL_LIST_CONSTRUCTOR+AI.Yail.YAIL_SPACER;e=e+h+AI.Yail.YAIL_SPACER+d+AI.Yail.YAIL_CLOSE_COMBINATION;e=e+AI.Yail.YAIL_SPACER+AI.Yail.YAIL_QUOTE+AI.Yail.YAIL_OPEN_COMBINATION;e=e+"list number"+AI.Yail.YAIL_CLOSE_COMBINATION+
AI.Yail.YAIL_SPACER;return e=e+AI.Yail.YAIL_DOUBLE_QUOTE+"remove list item"+AI.Yail.YAIL_DOUBLE_QUOTE+AI.Yail.YAIL_CLOSE_COMBINATION};
AI.Yail.forBlock.lists_insert_item=function(d,e){var h=e.valueToCode(d,"LIST",AI.Yail.ORDER_NONE)||AI.Yail.emptyListCode,k=e.valueToCode(d,"INDEX",AI.Yail.ORDER_NONE)||1;d=e.valueToCode(d,"ITEM",AI.Yail.ORDER_NONE)||AI.Yail.YAIL_FALSE;e=AI.Yail.YAIL_CALL_YAIL_PRIMITIVE+"yail-list-insert-item!"+AI.Yail.YAIL_SPACER;e=e+AI.Yail.YAIL_OPEN_COMBINATION+AI.Yail.YAIL_LIST_CONSTRUCTOR+AI.Yail.YAIL_SPACER;e=e+h+AI.Yail.YAIL_SPACER+k;e=e+AI.Yail.YAIL_SPACER+d+AI.Yail.YAIL_CLOSE_COMBINATION;e=e+AI.Yail.YAIL_SPACER+
AI.Yail.YAIL_QUOTE+AI.Yail.YAIL_OPEN_COMBINATION;e=e+"list number any"+AI.Yail.YAIL_CLOSE_COMBINATION+AI.Yail.YAIL_SPACER;return e=e+AI.Yail.YAIL_DOUBLE_QUOTE+"insert list item"+AI.Yail.YAIL_DOUBLE_QUOTE+AI.Yail.YAIL_CLOSE_COMBINATION};
AI.Yail.forBlock.lists_length=function(d,e){d=e.valueToCode(d,"LIST",AI.Yail.ORDER_NONE)||AI.Yail.emptyListCode;e=AI.Yail.YAIL_CALL_YAIL_PRIMITIVE+"yail-list-length"+AI.Yail.YAIL_SPACER;e=e+AI.Yail.YAIL_OPEN_COMBINATION+AI.Yail.YAIL_LIST_CONSTRUCTOR+AI.Yail.YAIL_SPACER;e=e+d+AI.Yail.YAIL_SPACER+AI.Yail.YAIL_CLOSE_COMBINATION;e=e+AI.Yail.YAIL_SPACER+AI.Yail.YAIL_QUOTE+AI.Yail.YAIL_OPEN_COMBINATION;e=e+"list"+AI.Yail.YAIL_CLOSE_COMBINATION+AI.Yail.YAIL_SPACER;e=e+AI.Yail.YAIL_DOUBLE_QUOTE+"length of list"+
AI.Yail.YAIL_DOUBLE_QUOTE+AI.Yail.YAIL_CLOSE_COMBINATION;return[e,AI.Yail.ORDER_ATOMIC]};
AI.Yail.forBlock.lists_append_list=function(d,e){var h=e.valueToCode(d,"LIST0",AI.Yail.ORDER_NONE)||AI.Yail.emptyListCode;d=e.valueToCode(d,"LIST1",AI.Yail.ORDER_NONE)||AI.Yail.emptyListCode;e=AI.Yail.YAIL_CALL_YAIL_PRIMITIVE+"yail-list-append!"+AI.Yail.YAIL_SPACER;e=e+AI.Yail.YAIL_OPEN_COMBINATION+AI.Yail.YAIL_LIST_CONSTRUCTOR+AI.Yail.YAIL_SPACER;e=e+h+AI.Yail.YAIL_SPACER;e=e+d+AI.Yail.YAIL_CLOSE_COMBINATION;e=e+AI.Yail.YAIL_SPACER+AI.Yail.YAIL_QUOTE+AI.Yail.YAIL_OPEN_COMBINATION;e=e+"list list"+
AI.Yail.YAIL_CLOSE_COMBINATION+AI.Yail.YAIL_SPACER;return e=e+AI.Yail.YAIL_DOUBLE_QUOTE+"append to list"+AI.Yail.YAIL_DOUBLE_QUOTE+AI.Yail.YAIL_CLOSE_COMBINATION};
AI.Yail.forBlock.lists_add_items=function(d,e){var h=e.valueToCode(d,"LIST",AI.Yail.ORDER_NONE)||AI.Yail.emptyListCode,k=AI.Yail.YAIL_CALL_YAIL_PRIMITIVE+"yail-list-add-to-list!"+AI.Yail.YAIL_SPACER;k=k+AI.Yail.YAIL_OPEN_COMBINATION+AI.Yail.YAIL_LIST_CONSTRUCTOR+AI.Yail.YAIL_SPACER;k=k+h+AI.Yail.YAIL_SPACER;for(h=0;h<d.itemCount_;h++){var m=e.valueToCode(d,"ITEM"+h,AI.Yail.ORDER_NONE)||AI.Yail.YAIL_FALSE;k+=m+AI.Yail.YAIL_SPACER}k+=AI.Yail.YAIL_CLOSE_COMBINATION;k=k+AI.Yail.YAIL_SPACER+AI.Yail.YAIL_QUOTE+
AI.Yail.YAIL_OPEN_COMBINATION;k+="list ";for(h=0;h<d.itemCount_;h++)k+="any"+AI.Yail.YAIL_SPACER;k+=AI.Yail.YAIL_CLOSE_COMBINATION+AI.Yail.YAIL_SPACER;return k=k+AI.Yail.YAIL_DOUBLE_QUOTE+"add items to list"+AI.Yail.YAIL_DOUBLE_QUOTE+AI.Yail.YAIL_CLOSE_COMBINATION};
AI.Yail.forBlock.lists_is_in=function(d,e){var h=e.valueToCode(d,"ITEM",AI.Yail.ORDER_NONE)||AI.Yail.YAIL_FALSE;d=e.valueToCode(d,"LIST",AI.Yail.ORDER_NONE)||AI.Yail.emptyListCode;e=AI.Yail.YAIL_CALL_YAIL_PRIMITIVE+"yail-list-member?"+AI.Yail.YAIL_SPACER;e=e+AI.Yail.YAIL_OPEN_COMBINATION+AI.Yail.YAIL_LIST_CONSTRUCTOR+AI.Yail.YAIL_SPACER;e=e+h+AI.Yail.YAIL_SPACER+d+AI.Yail.YAIL_CLOSE_COMBINATION;e=e+AI.Yail.YAIL_SPACER+AI.Yail.YAIL_QUOTE+AI.Yail.YAIL_OPEN_COMBINATION;e=e+"any list"+AI.Yail.YAIL_CLOSE_COMBINATION+
AI.Yail.YAIL_SPACER;e=e+AI.Yail.YAIL_DOUBLE_QUOTE+"is in list?"+AI.Yail.YAIL_DOUBLE_QUOTE+AI.Yail.YAIL_CLOSE_COMBINATION;return[e,AI.Yail.ORDER_ATOMIC]};
AI.Yail.forBlock.lists_position_in=function(d,e){var h=e.valueToCode(d,"ITEM",AI.Yail.ORDER_NONE)||1;d=e.valueToCode(d,"LIST",AI.Yail.ORDER_NONE)||AI.Yail.emptyListCode;e=AI.Yail.YAIL_CALL_YAIL_PRIMITIVE+"yail-list-index"+AI.Yail.YAIL_SPACER;e=e+AI.Yail.YAIL_OPEN_COMBINATION+AI.Yail.YAIL_LIST_CONSTRUCTOR+AI.Yail.YAIL_SPACER;e=e+h+AI.Yail.YAIL_SPACER+d+AI.Yail.YAIL_CLOSE_COMBINATION;e=e+AI.Yail.YAIL_SPACER+AI.Yail.YAIL_QUOTE+AI.Yail.YAIL_OPEN_COMBINATION;e=e+"any list"+AI.Yail.YAIL_CLOSE_COMBINATION+
AI.Yail.YAIL_SPACER;e=e+AI.Yail.YAIL_DOUBLE_QUOTE+"index in list"+AI.Yail.YAIL_DOUBLE_QUOTE+AI.Yail.YAIL_CLOSE_COMBINATION;return[e,AI.Yail.ORDER_ATOMIC]};
AI.Yail.forBlock.lists_pick_random_item=function(d,e){d=e.valueToCode(d,"LIST",AI.Yail.ORDER_NONE)||AI.Yail.emptyListCode;e=AI.Yail.YAIL_CALL_YAIL_PRIMITIVE+"yail-list-pick-random"+AI.Yail.YAIL_SPACER;e=e+AI.Yail.YAIL_OPEN_COMBINATION+AI.Yail.YAIL_LIST_CONSTRUCTOR+AI.Yail.YAIL_SPACER;e=e+d+AI.Yail.YAIL_SPACER+AI.Yail.YAIL_CLOSE_COMBINATION;e=e+AI.Yail.YAIL_SPACER+AI.Yail.YAIL_QUOTE+AI.Yail.YAIL_OPEN_COMBINATION;e=e+"list"+AI.Yail.YAIL_CLOSE_COMBINATION+AI.Yail.YAIL_SPACER;e=e+AI.Yail.YAIL_DOUBLE_QUOTE+
"pick random item"+AI.Yail.YAIL_DOUBLE_QUOTE+AI.Yail.YAIL_CLOSE_COMBINATION;return[e,AI.Yail.ORDER_ATOMIC]};
AI.Yail.forBlock.lists_is_empty=function(d,e){d=e.valueToCode(d,"LIST",AI.Yail.ORDER_NONE)||AI.Yail.emptyListCode;e=AI.Yail.YAIL_CALL_YAIL_PRIMITIVE+"yail-list-empty?"+AI.Yail.YAIL_SPACER;e=e+AI.Yail.YAIL_OPEN_COMBINATION+AI.Yail.YAIL_LIST_CONSTRUCTOR+AI.Yail.YAIL_SPACER;e=e+d+AI.Yail.YAIL_SPACER+AI.Yail.YAIL_CLOSE_COMBINATION;e=e+AI.Yail.YAIL_SPACER+AI.Yail.YAIL_QUOTE+AI.Yail.YAIL_OPEN_COMBINATION;e=e+"list"+AI.Yail.YAIL_CLOSE_COMBINATION+AI.Yail.YAIL_SPACER;e=e+AI.Yail.YAIL_DOUBLE_QUOTE+"is list empty?"+
AI.Yail.YAIL_DOUBLE_QUOTE+AI.Yail.YAIL_CLOSE_COMBINATION;return[e,AI.Yail.ORDER_ATOMIC]};
AI.Yail.forBlock.lists_copy=function(d,e){d=e.valueToCode(d,"LIST",AI.Yail.ORDER_NONE)||AI.Yail.emptyListCode;e=AI.Yail.YAIL_CALL_YAIL_PRIMITIVE+"yail-list-copy"+AI.Yail.YAIL_SPACER;e=e+AI.Yail.YAIL_OPEN_COMBINATION+AI.Yail.YAIL_LIST_CONSTRUCTOR+AI.Yail.YAIL_SPACER;e=e+d+AI.Yail.YAIL_SPACER+AI.Yail.YAIL_CLOSE_COMBINATION;e=e+AI.Yail.YAIL_SPACER+AI.Yail.YAIL_QUOTE+AI.Yail.YAIL_OPEN_COMBINATION;e=e+"list"+AI.Yail.YAIL_CLOSE_COMBINATION+AI.Yail.YAIL_SPACER;e=e+AI.Yail.YAIL_DOUBLE_QUOTE+"copy list"+AI.Yail.YAIL_DOUBLE_QUOTE+
AI.Yail.YAIL_CLOSE_COMBINATION;return[e,AI.Yail.ORDER_ATOMIC]};
AI.Yail.forBlock.lists_is_list=function(d,e){d=e.valueToCode(d,"ITEM",AI.Yail.ORDER_NONE)||AI.Yail.YAIL_FALSE;e=AI.Yail.YAIL_CALL_YAIL_PRIMITIVE+"yail-list?"+AI.Yail.YAIL_SPACER;e=e+AI.Yail.YAIL_OPEN_COMBINATION+AI.Yail.YAIL_LIST_CONSTRUCTOR+AI.Yail.YAIL_SPACER;e=e+d+AI.Yail.YAIL_SPACER+AI.Yail.YAIL_CLOSE_COMBINATION;e=e+AI.Yail.YAIL_SPACER+AI.Yail.YAIL_QUOTE+AI.Yail.YAIL_OPEN_COMBINATION;e=e+"any"+AI.Yail.YAIL_CLOSE_COMBINATION+AI.Yail.YAIL_SPACER;e=e+AI.Yail.YAIL_DOUBLE_QUOTE+"is a list?"+AI.Yail.YAIL_DOUBLE_QUOTE+
AI.Yail.YAIL_CLOSE_COMBINATION;return[e,AI.Yail.ORDER_ATOMIC]};
AI.Yail.forBlock.lists_reverse=function(d,e){d=e.valueToCode(d,"LIST",AI.Yail.ORDER_NONE)||AI.Yail.emptyListCode;e=AI.Yail.YAIL_CALL_YAIL_PRIMITIVE+"yail-list-reverse"+AI.Yail.YAIL_SPACER;e=e+AI.Yail.YAIL_OPEN_COMBINATION+AI.Yail.YAIL_LIST_CONSTRUCTOR+AI.Yail.YAIL_SPACER;e=e+d+AI.Yail.YAIL_SPACER+AI.Yail.YAIL_CLOSE_COMBINATION;e=e+AI.Yail.YAIL_SPACER+AI.Yail.YAIL_QUOTE+AI.Yail.YAIL_OPEN_COMBINATION;e=e+"list"+AI.Yail.YAIL_CLOSE_COMBINATION+AI.Yail.YAIL_SPACER;e=e+AI.Yail.YAIL_DOUBLE_QUOTE+"reverse list"+
AI.Yail.YAIL_DOUBLE_QUOTE+AI.Yail.YAIL_CLOSE_COMBINATION;return[e,AI.Yail.ORDER_ATOMIC]};
AI.Yail.forBlock.lists_to_csv_row=function(d,e){d=e.valueToCode(d,"LIST",AI.Yail.ORDER_NONE)||AI.Yail.emptyListCode;e=AI.Yail.YAIL_CALL_YAIL_PRIMITIVE+"yail-list-to-csv-row"+AI.Yail.YAIL_SPACER;e=e+AI.Yail.YAIL_OPEN_COMBINATION+AI.Yail.YAIL_LIST_CONSTRUCTOR+AI.Yail.YAIL_SPACER;e=e+d+AI.Yail.YAIL_SPACER+AI.Yail.YAIL_CLOSE_COMBINATION;e=e+AI.Yail.YAIL_SPACER+AI.Yail.YAIL_QUOTE+AI.Yail.YAIL_OPEN_COMBINATION;e=e+"list"+AI.Yail.YAIL_CLOSE_COMBINATION+AI.Yail.YAIL_SPACER;e=e+AI.Yail.YAIL_DOUBLE_QUOTE+"list to csv row"+
AI.Yail.YAIL_DOUBLE_QUOTE+AI.Yail.YAIL_CLOSE_COMBINATION;return[e,AI.Yail.ORDER_ATOMIC]};
AI.Yail.forBlock.lists_to_csv_table=function(d,e){d=e.valueToCode(d,"LIST",AI.Yail.ORDER_NONE)||AI.Yail.emptyListCode;e=AI.Yail.YAIL_CALL_YAIL_PRIMITIVE+"yail-list-to-csv-table"+AI.Yail.YAIL_SPACER;e=e+AI.Yail.YAIL_OPEN_COMBINATION+AI.Yail.YAIL_LIST_CONSTRUCTOR+AI.Yail.YAIL_SPACER;e=e+d+AI.Yail.YAIL_SPACER+AI.Yail.YAIL_CLOSE_COMBINATION;e=e+AI.Yail.YAIL_SPACER+AI.Yail.YAIL_QUOTE+AI.Yail.YAIL_OPEN_COMBINATION;e=e+"list"+AI.Yail.YAIL_CLOSE_COMBINATION+AI.Yail.YAIL_SPACER;e=e+AI.Yail.YAIL_DOUBLE_QUOTE+
"list to csv table"+AI.Yail.YAIL_DOUBLE_QUOTE+AI.Yail.YAIL_CLOSE_COMBINATION;return[e,AI.Yail.ORDER_ATOMIC]};
AI.Yail.forBlock.lists_from_csv_row=function(d,e){d=e.valueToCode(d,"TEXT",AI.Yail.ORDER_NONE)||'""';e=AI.Yail.YAIL_CALL_YAIL_PRIMITIVE+"yail-list-from-csv-row"+AI.Yail.YAIL_SPACER;e=e+AI.Yail.YAIL_OPEN_COMBINATION+AI.Yail.YAIL_LIST_CONSTRUCTOR+AI.Yail.YAIL_SPACER;e=e+d+AI.Yail.YAIL_SPACER+AI.Yail.YAIL_CLOSE_COMBINATION;e=e+AI.Yail.YAIL_SPACER+AI.Yail.YAIL_QUOTE+AI.Yail.YAIL_OPEN_COMBINATION;e=e+"text"+AI.Yail.YAIL_CLOSE_COMBINATION+AI.Yail.YAIL_SPACER;e=e+AI.Yail.YAIL_DOUBLE_QUOTE+"list from csv row"+
AI.Yail.YAIL_DOUBLE_QUOTE+AI.Yail.YAIL_CLOSE_COMBINATION;return[e,AI.Yail.ORDER_ATOMIC]};
AI.Yail.forBlock.lists_from_csv_table=function(d,e){d=e.valueToCode(d,"TEXT",AI.Yail.ORDER_NONE)||'""';e=AI.Yail.YAIL_CALL_YAIL_PRIMITIVE+"yail-list-from-csv-table"+AI.Yail.YAIL_SPACER;e=e+AI.Yail.YAIL_OPEN_COMBINATION+AI.Yail.YAIL_LIST_CONSTRUCTOR+AI.Yail.YAIL_SPACER;e=e+d+AI.Yail.YAIL_SPACER+AI.Yail.YAIL_CLOSE_COMBINATION;e=e+AI.Yail.YAIL_SPACER+AI.Yail.YAIL_QUOTE+AI.Yail.YAIL_OPEN_COMBINATION;e=e+"text"+AI.Yail.YAIL_CLOSE_COMBINATION+AI.Yail.YAIL_SPACER;e=e+AI.Yail.YAIL_DOUBLE_QUOTE+"list from csv table"+
AI.Yail.YAIL_DOUBLE_QUOTE+AI.Yail.YAIL_CLOSE_COMBINATION;return[e,AI.Yail.ORDER_ATOMIC]};
AI.Yail.forBlock.lists_lookup_in_pairs=function(d,e){var h=e.valueToCode(d,"KEY",AI.Yail.ORDER_NONE)||AI.Yail.YAIL_FALSE,k=e.valueToCode(d,"LIST",AI.Yail.ORDER_NONE)||AI.Yail.emptyListCode;d=e.valueToCode(d,"NOTFOUND",AI.Yail.ORDER_NONE)||AI.Yail.YAIL_NULL;e=AI.Yail.YAIL_CALL_YAIL_PRIMITIVE+"yail-alist-lookup"+AI.Yail.YAIL_SPACER;e=e+AI.Yail.YAIL_OPEN_COMBINATION+AI.Yail.YAIL_LIST_CONSTRUCTOR+AI.Yail.YAIL_SPACER;e=e+h+AI.Yail.YAIL_SPACER+k+AI.Yail.YAIL_SPACER+d+AI.Yail.YAIL_CLOSE_COMBINATION;e=e+
AI.Yail.YAIL_SPACER+AI.Yail.YAIL_QUOTE+AI.Yail.YAIL_OPEN_COMBINATION;e=e+"any list any"+AI.Yail.YAIL_CLOSE_COMBINATION+AI.Yail.YAIL_SPACER;e=e+AI.Yail.YAIL_SPACER+AI.Yail.YAIL_DOUBLE_QUOTE+"lookup in pairs"+AI.Yail.YAIL_DOUBLE_QUOTE+AI.Yail.YAIL_CLOSE_COMBINATION;return[e,AI.Yail.ORDER_ATOMIC]};
AI.Yail.forBlock.lists_join_with_separator=function(d,e){var h=e.valueToCode(d,"SEPARATOR",AI.Yail.ORDER_NONE)||'""';d=e.valueToCode(d,"LIST",AI.Yail.ORDER_NONE)||AI.Yail.emptyListCode;e=AI.Yail.YAIL_CALL_YAIL_PRIMITIVE+"yail-list-join-with-separator"+AI.Yail.YAIL_SPACER;e=e+AI.Yail.YAIL_OPEN_COMBINATION+AI.Yail.YAIL_LIST_CONSTRUCTOR+AI.Yail.YAIL_SPACER;e=e+d+AI.Yail.YAIL_SPACER;e=e+h+AI.Yail.YAIL_CLOSE_COMBINATION;e=e+AI.Yail.YAIL_SPACER+AI.Yail.YAIL_QUOTE;e=e+AI.Yail.YAIL_OPEN_COMBINATION+"list"+
AI.Yail.YAIL_SPACER+"text"+AI.Yail.YAIL_CLOSE_COMBINATION;e=e+AI.Yail.YAIL_SPACER+AI.Yail.YAIL_DOUBLE_QUOTE+"join with separator"+AI.Yail.YAIL_DOUBLE_QUOTE+AI.Yail.YAIL_CLOSE_COMBINATION;return[e,AI.Yail.ORDER_ATOMIC]};
AI.Yail.forBlock.lists_map=function(d,e){var h=AI.Yail.YAIL_CALL_YAIL_PRIMITIVE+"make-yail-list"+AI.Yail.YAIL_SPACER;h+=AI.Yail.YAIL_OPEN_COMBINATION+AI.Yail.YAIL_LIST_CONSTRUCTOR+AI.Yail.YAIL_SPACER;h+=AI.Yail.YAIL_CLOSE_COMBINATION+AI.Yail.YAIL_SPACER+AI.Yail.YAIL_QUOTE+AI.Yail.YAIL_OPEN_COMBINATION;h+=AI.Yail.YAIL_CLOSE_COMBINATION;h+=AI.Yail.YAIL_SPACER+AI.Yail.YAIL_DOUBLE_QUOTE+"make a list"+AI.Yail.YAIL_DOUBLE_QUOTE+AI.Yail.YAIL_CLOSE_COMBINATION;var k=AI.Yail.YAIL_LOCAL_VAR_TAG+d.getFieldValue("VAR");
h=e.valueToCode(d,"LIST",AI.Yail.ORDER_NONE)||h;d=e.valueToCode(d,"TO",AI.Yail.ORDER_NONE)||AI.Yail.YAIL_FALSE;return[AI.Yail.YAIL_MAP+k+AI.Yail.YAIL_SPACER+d+AI.Yail.YAIL_SPACER+h+AI.Yail.YAIL_CLOSE_COMBINATION,AI.Yail.ORDER_ATOMIC]};
AI.Yail.forBlock.lists_filter=function(d,e){var h=AI.Yail.YAIL_CALL_YAIL_PRIMITIVE+"make-yail-list"+AI.Yail.YAIL_SPACER;h+=AI.Yail.YAIL_OPEN_COMBINATION+AI.Yail.YAIL_LIST_CONSTRUCTOR+AI.Yail.YAIL_SPACER;h+=AI.Yail.YAIL_CLOSE_COMBINATION+AI.Yail.YAIL_SPACER+AI.Yail.YAIL_QUOTE+AI.Yail.YAIL_OPEN_COMBINATION;h+=AI.Yail.YAIL_CLOSE_COMBINATION;h+=AI.Yail.YAIL_SPACER+AI.Yail.YAIL_DOUBLE_QUOTE+"make a list"+AI.Yail.YAIL_DOUBLE_QUOTE+AI.Yail.YAIL_CLOSE_COMBINATION;var k=AI.Yail.YAIL_LOCAL_VAR_TAG+d.getFieldValue("VAR");
h=e.valueToCode(d,"LIST",AI.Yail.ORDER_NONE)||h;d=e.valueToCode(d,"TEST",AI.Yail.ORDER_NONE)||AI.Yail.YAIL_FALSE;return[AI.Yail.YAIL_FILTER+k+AI.Yail.YAIL_SPACER+d+AI.Yail.YAIL_SPACER+h+AI.Yail.YAIL_CLOSE_COMBINATION,AI.Yail.ORDER_ATOMIC]};
AI.Yail.forBlock.lists_reduce=function(d,e){var h=AI.Yail.YAIL_CALL_YAIL_PRIMITIVE+"make-yail-list"+AI.Yail.YAIL_SPACER;h+=AI.Yail.YAIL_OPEN_COMBINATION+AI.Yail.YAIL_LIST_CONSTRUCTOR+AI.Yail.YAIL_SPACER;h+=AI.Yail.YAIL_CLOSE_COMBINATION+AI.Yail.YAIL_SPACER+AI.Yail.YAIL_QUOTE+AI.Yail.YAIL_OPEN_COMBINATION;h+=AI.Yail.YAIL_CLOSE_COMBINATION;h+=AI.Yail.YAIL_SPACER+AI.Yail.YAIL_DOUBLE_QUOTE+"make a list"+AI.Yail.YAIL_DOUBLE_QUOTE+AI.Yail.YAIL_CLOSE_COMBINATION;var k=AI.Yail.YAIL_LOCAL_VAR_TAG+d.getFieldValue("VAR1"),
m=AI.Yail.YAIL_LOCAL_VAR_TAG+d.getFieldValue("VAR2");h=e.valueToCode(d,"LIST",AI.Yail.ORDER_NONE)||h;var p=e.valueToCode(d,"INITANSWER",AI.Yail.ORDER_NONE);d=e.valueToCode(d,"COMBINE",AI.Yail.ORDER_NONE)||AI.Yail.YAIL_FALSE;return[AI.Yail.YAIL_REDUCE+p+AI.Yail.YAIL_SPACER+m+AI.Yail.YAIL_SPACER+k+AI.Yail.YAIL_SPACER+d+AI.Yail.YAIL_SPACER+h+AI.Yail.YAIL_CLOSE_COMBINATION,AI.Yail.ORDER_ATOMIC]};
AI.Yail.forBlock.lists_sort=function(d,e){d=e.valueToCode(d,"LIST",AI.Yail.ORDER_NONE)||AI.Yail.emptyListCode;e=AI.Yail.YAIL_CALL_YAIL_PRIMITIVE+"yail-list-sort";e=e+AI.Yail.YAIL_SPACER+AI.Yail.YAIL_OPEN_COMBINATION+AI.Yail.YAIL_LIST_CONSTRUCTOR+AI.Yail.YAIL_SPACER;e=e+d+AI.Yail.YAIL_SPACER+AI.Yail.YAIL_CLOSE_COMBINATION;e=e+AI.Yail.YAIL_SPACER+AI.Yail.YAIL_QUOTE+AI.Yail.YAIL_OPEN_COMBINATION;e=e+"list"+AI.Yail.YAIL_CLOSE_COMBINATION+AI.Yail.YAIL_SPACER;e=e+AI.Yail.YAIL_DOUBLE_QUOTE+"sort "+AI.Yail.YAIL_DOUBLE_QUOTE+
AI.Yail.YAIL_CLOSE_COMBINATION;return[e,AI.Yail.ORDER_ATOMIC]};
AI.Yail.forBlock.lists_sort_comparator=function(d,e){var h=AI.Yail.YAIL_CALL_YAIL_PRIMITIVE+"make-yail-list"+AI.Yail.YAIL_SPACER;h+=AI.Yail.YAIL_OPEN_COMBINATION+AI.Yail.YAIL_LIST_CONSTRUCTOR+AI.Yail.YAIL_SPACER;h+=AI.Yail.YAIL_CLOSE_COMBINATION+AI.Yail.YAIL_SPACER+AI.Yail.YAIL_QUOTE+AI.Yail.YAIL_OPEN_COMBINATION;h+=AI.Yail.YAIL_CLOSE_COMBINATION;h+=AI.Yail.YAIL_SPACER+AI.Yail.YAIL_DOUBLE_QUOTE+"make a list"+AI.Yail.YAIL_DOUBLE_QUOTE+AI.Yail.YAIL_CLOSE_COMBINATION;var k=AI.Yail.YAIL_LOCAL_VAR_TAG+
d.getFieldValue("VAR1"),m=AI.Yail.YAIL_LOCAL_VAR_TAG+d.getFieldValue("VAR2");h=e.valueToCode(d,"LIST",AI.Yail.ORDER_NONE)||h;d=e.valueToCode(d,"COMPARE",AI.Yail.ORDER_NONE)||AI.Yail.YAIL_FALSE;return[AI.Yail.YAIL_SORT_COMPARATOR_NONDEST+k+AI.Yail.YAIL_SPACER+m+AI.Yail.YAIL_SPACER+d+AI.Yail.YAIL_SPACER+h+AI.Yail.YAIL_CLOSE_COMBINATION,AI.Yail.ORDER_ATOMIC]};
AI.Yail.forBlock.lists_sort_key=function(d,e){var h=AI.Yail.YAIL_CALL_YAIL_PRIMITIVE+"make-yail-list"+AI.Yail.YAIL_SPACER;h+=AI.Yail.YAIL_OPEN_COMBINATION+AI.Yail.YAIL_LIST_CONSTRUCTOR+AI.Yail.YAIL_SPACER;h+=AI.Yail.YAIL_CLOSE_COMBINATION+AI.Yail.YAIL_SPACER+AI.Yail.YAIL_QUOTE+AI.Yail.YAIL_OPEN_COMBINATION;h+=AI.Yail.YAIL_CLOSE_COMBINATION;h+=AI.Yail.YAIL_SPACER+AI.Yail.YAIL_DOUBLE_QUOTE+"make a list"+AI.Yail.YAIL_DOUBLE_QUOTE+AI.Yail.YAIL_CLOSE_COMBINATION;var k=AI.Yail.YAIL_LOCAL_VAR_TAG+d.getFieldValue("VAR");
h=e.valueToCode(d,"LIST",AI.Yail.ORDER_NONE)||h;d=e.valueToCode(d,"KEY",AI.Yail.ORDER_NONE)||AI.Yail.YAIL_FALSE;return[AI.Yail.YAIL_SORT_KEY_NONDEST+k+AI.Yail.YAIL_SPACER+d+AI.Yail.YAIL_SPACER+h+AI.Yail.YAIL_CLOSE_COMBINATION,AI.Yail.ORDER_ATOMIC]};
AI.Yail.forBlock.lists_minimum_value=function(d,e){var h=AI.Yail.YAIL_CALL_YAIL_PRIMITIVE+"make-yail-list"+AI.Yail.YAIL_SPACER;h+=AI.Yail.YAIL_OPEN_COMBINATION+AI.Yail.YAIL_LIST_CONSTRUCTOR+AI.Yail.YAIL_SPACER;h+=AI.Yail.YAIL_CLOSE_COMBINATION+AI.Yail.YAIL_SPACER+AI.Yail.YAIL_QUOTE+AI.Yail.YAIL_OPEN_COMBINATION;h+=AI.Yail.YAIL_CLOSE_COMBINATION;h+=AI.Yail.YAIL_SPACER+AI.Yail.YAIL_DOUBLE_QUOTE+"minimum value of list"+AI.Yail.YAIL_DOUBLE_QUOTE+AI.Yail.YAIL_CLOSE_COMBINATION;var k=AI.Yail.YAIL_LOCAL_VAR_TAG+
d.getFieldValue("VAR1"),m=AI.Yail.YAIL_LOCAL_VAR_TAG+d.getFieldValue("VAR2");h=e.valueToCode(d,"LIST",AI.Yail.ORDER_NONE)||h;d=e.valueToCode(d,"COMPARE",AI.Yail.ORDER_NONE)||"(call-yail-primitive < (*list-for-runtime* (lexical-value "+k+") (lexical-value "+m+')) \'(number number) "<")';return["(mincomparator-nondest "+k+AI.Yail.YAIL_SPACER+m+AI.Yail.YAIL_SPACER+d+AI.Yail.YAIL_SPACER+h+AI.Yail.YAIL_CLOSE_COMBINATION,AI.Yail.ORDER_ATOMIC]};
AI.Yail.forBlock.lists_maximum_value=function(d,e){var h=AI.Yail.YAIL_CALL_YAIL_PRIMITIVE+"make-yail-list"+AI.Yail.YAIL_SPACER;h+=AI.Yail.YAIL_OPEN_COMBINATION+AI.Yail.YAIL_LIST_CONSTRUCTOR+AI.Yail.YAIL_SPACER;h+=AI.Yail.YAIL_CLOSE_COMBINATION+AI.Yail.YAIL_SPACER+AI.Yail.YAIL_QUOTE+AI.Yail.YAIL_OPEN_COMBINATION;h+=AI.Yail.YAIL_CLOSE_COMBINATION;h+=AI.Yail.YAIL_SPACER+AI.Yail.YAIL_DOUBLE_QUOTE+"maximum value of list"+AI.Yail.YAIL_DOUBLE_QUOTE+AI.Yail.YAIL_CLOSE_COMBINATION;var k=AI.Yail.YAIL_LOCAL_VAR_TAG+
d.getFieldValue("VAR1"),m=AI.Yail.YAIL_LOCAL_VAR_TAG+d.getFieldValue("VAR2");h=e.valueToCode(d,"LIST",AI.Yail.ORDER_NONE)||h;d=e.valueToCode(d,"COMPARE",AI.Yail.ORDER_NONE)||"(call-yail-primitive < (*list-for-runtime* (lexical-value "+k+") (lexical-value "+m+')) \'(number number) "<")';return["(maxcomparator-nondest "+k+AI.Yail.YAIL_SPACER+m+AI.Yail.YAIL_SPACER+d+AI.Yail.YAIL_SPACER+h+AI.Yail.YAIL_CLOSE_COMBINATION,AI.Yail.ORDER_ATOMIC]};
AI.Yail.forBlock.lists_but_first=function(d,e){d=e.valueToCode(d,"LIST",AI.Yail.ORDER_NONE)||AI.Yail.emptyListCode;e=AI.Yail.YAIL_CALL_YAIL_PRIMITIVE+"yail-list-but-first";e=e+AI.Yail.YAIL_SPACER+AI.Yail.YAIL_OPEN_COMBINATION+AI.Yail.YAIL_LIST_CONSTRUCTOR+AI.Yail.YAIL_SPACER;e=e+d+AI.Yail.YAIL_SPACER+AI.Yail.YAIL_CLOSE_COMBINATION;e=e+AI.Yail.YAIL_SPACER+AI.Yail.YAIL_QUOTE+AI.Yail.YAIL_OPEN_COMBINATION;e=e+"list"+AI.Yail.YAIL_CLOSE_COMBINATION+AI.Yail.YAIL_SPACER;e=e+AI.Yail.YAIL_DOUBLE_QUOTE+"butFirst of list"+
AI.Yail.YAIL_DOUBLE_QUOTE+AI.Yail.YAIL_CLOSE_COMBINATION;return[e,AI.Yail.ORDER_ATOMIC]};
AI.Yail.forBlock.lists_but_last=function(d,e){d=e.valueToCode(d,"LIST",AI.Yail.ORDER_NONE)||AI.Yail.emptyListCode;e=AI.Yail.YAIL_CALL_YAIL_PRIMITIVE+"yail-list-but-last";e=e+AI.Yail.YAIL_SPACER+AI.Yail.YAIL_OPEN_COMBINATION+AI.Yail.YAIL_LIST_CONSTRUCTOR+AI.Yail.YAIL_SPACER;e=e+d+AI.Yail.YAIL_SPACER+AI.Yail.YAIL_CLOSE_COMBINATION;e=e+AI.Yail.YAIL_SPACER+AI.Yail.YAIL_QUOTE+AI.Yail.YAIL_OPEN_COMBINATION;e=e+"list"+AI.Yail.YAIL_CLOSE_COMBINATION+AI.Yail.YAIL_SPACER;e=e+AI.Yail.YAIL_DOUBLE_QUOTE+"butLast of list"+
AI.Yail.YAIL_DOUBLE_QUOTE+AI.Yail.YAIL_CLOSE_COMBINATION;return[e,AI.Yail.ORDER_ATOMIC]};
AI.Yail.forBlock.lists_slice=function(d,e){var h=e.valueToCode(d,"LIST",AI.Yail.ORDER_NONE)||AI.Yail.emptyListCode,k=e.valueToCode(d,"INDEX1",AI.Yail.ORDER_NONE)||1;d=e.valueToCode(d,"INDEX2",AI.Yail.ORDER_NONE)||1;e=AI.Yail.YAIL_CALL_YAIL_PRIMITIVE+"yail-list-slice";e=e+AI.Yail.YAIL_SPACER+AI.Yail.YAIL_OPEN_COMBINATION+AI.Yail.YAIL_LIST_CONSTRUCTOR+AI.Yail.YAIL_SPACER;e=e+h+AI.Yail.YAIL_SPACER+k;e=e+AI.Yail.YAIL_SPACER+d+AI.Yail.YAIL_CLOSE_COMBINATION;e=e+AI.Yail.YAIL_SPACER+AI.Yail.YAIL_QUOTE+AI.Yail.YAIL_OPEN_COMBINATION;
e=e+"list number number"+AI.Yail.YAIL_CLOSE_COMBINATION+AI.Yail.YAIL_SPACER;e=e+AI.Yail.YAIL_DOUBLE_QUOTE+"slice of list"+AI.Yail.YAIL_DOUBLE_QUOTE+AI.Yail.YAIL_CLOSE_COMBINATION;return[e,AI.Yail.ORDER_ATOMIC]};/*

 @fileoverview Logic blocks yail generators for Blockly, modified for MIT App Inventor.
 @author mckinney@mit.edu (Andrew F. McKinney)
*/
AI.Yail.logic={};AI.Yail.forBlock.logic_boolean=function(d,e){return["TRUE"==d.getFieldValue("BOOL")?AI.Yail.YAIL_TRUE:AI.Yail.YAIL_FALSE,AI.Yail.ORDER_ATOMIC]};AI.Yail.forBlock.logic_false=function(d,e){return AI.Yail.forBlock.logic_boolean(d,e)};
AI.Yail.forBlock.logic_negate=function(d,e){d=e.valueToCode(d,"BOOL",AI.Yail.ORDER_NONE)||AI.Yail.YAIL_FALSE;e=AI.Yail.YAIL_CALL_YAIL_PRIMITIVE+"yail-not"+AI.Yail.YAIL_SPACER;e=e+AI.Yail.YAIL_OPEN_COMBINATION+AI.Yail.YAIL_LIST_CONSTRUCTOR+AI.Yail.YAIL_SPACER+d+AI.Yail.YAIL_CLOSE_COMBINATION;e=e+AI.Yail.YAIL_SPACER+AI.Yail.YAIL_QUOTE+AI.Yail.YAIL_OPEN_COMBINATION+"boolean"+AI.Yail.YAIL_CLOSE_COMBINATION+AI.Yail.YAIL_SPACER;e=e+AI.Yail.YAIL_DOUBLE_QUOTE+"not"+AI.Yail.YAIL_DOUBLE_QUOTE+AI.Yail.YAIL_CLOSE_COMBINATION;
return[e,AI.Yail.ORDER_ATOMIC]};AI.Yail.forBlock.logic_operation=function(d,e){var h=d.opField.getValue(),k=AI.Yail.LOGIC_OPERATION_OPERATORS[h],m=k[0];h=k[1];var p=k[2];k=e.valueToCode(d,"A",h)||p;p=e.valueToCode(d,"B",h)||p;m=AI.Yail.YAIL_OPEN_COMBINATION+m+AI.Yail.YAIL_SPACER+k+AI.Yail.YAIL_SPACER+p;for(k=2;k<d.itemCount_;k++)p=e.valueToCode(d,d.repeatingInputName+k,h)||AI.Yail.YAIL_FALSE,m+=AI.Yail.YAIL_SPACER+p;m+=AI.Yail.YAIL_CLOSE_COMBINATION;return[m,AI.Yail.ORDER_ATOMIC]};
AI.Yail.LOGIC_OPERATION_OPERATORS={AND:["and-delayed",AI.Yail.ORDER_NONE,AI.Yail.YAIL_TRUE],OR:["or-delayed",AI.Yail.ORDER_NONE,AI.Yail.YAIL_FALSE]};AI.Yail.forBlock.logic_or=function(d,e){return AI.Yail.forBlock.logic_operation(d,e)};
AI.Yail.forBlock.logic_compare=function(d,e){var h=e.valueToCode(d,"A",AI.Yail.ORDER_NONE)||AI.Yail.YAIL_FALSE;e=e.valueToCode(d,"B",AI.Yail.ORDER_NONE)||AI.Yail.YAIL_FALSE;d="NEQ"==d.getFieldValue("OP")?"yail-not-equal?":"yail-equal?";d=AI.Yail.YAIL_CALL_YAIL_PRIMITIVE+d+AI.Yail.YAIL_SPACER;d=d+AI.Yail.YAIL_OPEN_COMBINATION+AI.Yail.YAIL_LIST_CONSTRUCTOR+AI.Yail.YAIL_SPACER+h+AI.Yail.YAIL_SPACER+e+AI.Yail.YAIL_CLOSE_COMBINATION;d=d+AI.Yail.YAIL_SPACER+AI.Yail.YAIL_QUOTE+AI.Yail.YAIL_OPEN_COMBINATION+
"any"+AI.Yail.YAIL_SPACER+"any"+AI.Yail.YAIL_CLOSE_COMBINATION+AI.Yail.YAIL_SPACER;d=d+AI.Yail.YAIL_DOUBLE_QUOTE+"="+AI.Yail.YAIL_DOUBLE_QUOTE+AI.Yail.YAIL_CLOSE_COMBINATION;return[d,AI.Yail.ORDER_ATOMIC]};/*

 @fileoverview Math blocks yail generators for Blockly, modified for MIT App Inventor.
 @author mckinney@mit.edu (Andrew F. McKinney)
*/
AI.Yail.math={};AI.Yail.forBlock.math_number=function(d,e){return[Number(d.getFieldValue("NUM")),AI.Yail.ORDER_ATOMIC]};AI.Yail.forBlock.math_number_radix=function(d,e){e=Blockly.Blocks.math_number_radix.PREFIX[d.getFieldValue("OP")];return[Number(e+d.getFieldValue("NUM")),AI.Yail.ORDER_ATOMIC]};
AI.Yail.forBlock.math_compare=function(d,e){var h=d.getFieldValue("OP"),k=AI.Yail.forBlock.math_compare.OPERATORS[h],m=k[0],p=k[1],t=k[2];k=e.valueToCode(d,"A",t)||0;d=e.valueToCode(d,"B",t)||0;m=AI.Yail.YAIL_CALL_YAIL_PRIMITIVE+m+AI.Yail.YAIL_SPACER;m=m+AI.Yail.YAIL_OPEN_COMBINATION+AI.Yail.YAIL_LIST_CONSTRUCTOR+AI.Yail.YAIL_SPACER+k+AI.Yail.YAIL_SPACER+d+AI.Yail.YAIL_CLOSE_COMBINATION;m=m+AI.Yail.YAIL_SPACER+AI.Yail.YAIL_QUOTE+AI.Yail.YAIL_OPEN_COMBINATION+("EQ"==h||"NEQ"==h?"any any":"number number")+
AI.Yail.YAIL_CLOSE_COMBINATION+AI.Yail.YAIL_SPACER;m=m+AI.Yail.YAIL_DOUBLE_QUOTE+p+AI.Yail.YAIL_DOUBLE_QUOTE+AI.Yail.YAIL_CLOSE_COMBINATION;return[m,AI.Yail.ORDER_ATOMIC]};AI.Yail.forBlock.math_compare.OPERATORS={EQ:["yail-equal?","=",AI.Yail.ORDER_NONE],NEQ:["yail-not-equal?","not =",AI.Yail.ORDER_NONE],LT:["<","<",AI.Yail.ORDER_NONE],LTE:["<=","<=",AI.Yail.ORDER_NONE],GT:[">",">",AI.Yail.ORDER_NONE],GTE:[">=",">=",AI.Yail.ORDER_NONE]};
AI.Yail.forBlock.math_arithmetic=function(d,e,h){var k=AI.Yail.forBlock.math_arithmetic.OPERATORS[d],m=k[0],p=k[1];k=h.valueToCode(e,"A",p)||0;e=h.valueToCode(e,"B",p)||0;h=AI.Yail.YAIL_CALL_YAIL_PRIMITIVE+m+AI.Yail.YAIL_SPACER;h=h+AI.Yail.YAIL_OPEN_COMBINATION+AI.Yail.YAIL_LIST_CONSTRUCTOR+AI.Yail.YAIL_SPACER+k+AI.Yail.YAIL_SPACER+e+AI.Yail.YAIL_CLOSE_COMBINATION;h=h+AI.Yail.YAIL_SPACER+AI.Yail.YAIL_QUOTE+AI.Yail.YAIL_OPEN_COMBINATION;h+=("EQ"==d||"NEQ"==d?"any any":"number number")+AI.Yail.YAIL_CLOSE_COMBINATION+
AI.Yail.YAIL_SPACER;h=h+AI.Yail.YAIL_DOUBLE_QUOTE+m+AI.Yail.YAIL_DOUBLE_QUOTE+AI.Yail.YAIL_CLOSE_COMBINATION;return[h,AI.Yail.ORDER_ATOMIC]};AI.Yail.forBlock.math_subtract=function(d,e){return AI.Yail.forBlock.math_arithmetic("MINUS",d,e)};AI.Yail.forBlock.math_division=function(d,e){return AI.Yail.forBlock.math_arithmetic("DIVIDE",d,e)};AI.Yail.forBlock.math_power=function(d,e){return AI.Yail.forBlock.math_arithmetic("POWER",d,e)};
AI.Yail.forBlock.math_add=function(d,e){return AI.Yail.forBlock.math_arithmetic_list("ADD",d,e)};AI.Yail.forBlock.math_multiply=function(d,e){return AI.Yail.forBlock.math_arithmetic_list("MULTIPLY",d,e)};
AI.Yail.forBlock.math_arithmetic_list=function(d,e,h){var k=AI.Yail.forBlock.math_arithmetic.OPERATORS[d];d=k[0];k=k[1];var m=AI.Yail.YAIL_CALL_YAIL_PRIMITIVE+d+AI.Yail.YAIL_SPACER;m=m+AI.Yail.YAIL_OPEN_COMBINATION+AI.Yail.YAIL_LIST_CONSTRUCTOR+AI.Yail.YAIL_SPACER;for(var p=0;p<e.itemCount_;p++){var t=h.valueToCode(e,"NUM"+p,k)||0;m+=t+AI.Yail.YAIL_SPACER}m+=AI.Yail.YAIL_CLOSE_COMBINATION;m=m+AI.Yail.YAIL_SPACER+AI.Yail.YAIL_QUOTE+AI.Yail.YAIL_OPEN_COMBINATION;for(p=0;p<e.itemCount_;p++)m+="number"+
AI.Yail.YAIL_SPACER;m+=AI.Yail.YAIL_CLOSE_COMBINATION+AI.Yail.YAIL_SPACER;m=m+AI.Yail.YAIL_DOUBLE_QUOTE+d+AI.Yail.YAIL_DOUBLE_QUOTE+AI.Yail.YAIL_CLOSE_COMBINATION;return[m,AI.Yail.ORDER_ATOMIC]};AI.Yail.forBlock.math_arithmetic.OPERATORS={ADD:["+",AI.Yail.ORDER_NONE],MINUS:["-",AI.Yail.ORDER_NONE],MULTIPLY:["*",AI.Yail.ORDER_NONE],DIVIDE:["yail-divide",AI.Yail.ORDER_NONE],POWER:["expt",AI.Yail.ORDER_NONE]};
AI.Yail.forBlock.math_bitwise=function(d,e){var h=d.getFieldValue("OP"),k=AI.Yail.forBlock.math_bitwise.OPERATORS[h];h=k[0];for(var m=k[1],p=k="",t=0;t<d.itemCount_;t++)k+=(e.valueToCode(d,"NUM"+t,m)||0)+AI.Yail.YAIL_SPACER,p+="number"+AI.Yail.YAIL_SPACER;d=AI.Yail.YAIL_CALL_YAIL_PRIMITIVE+h+AI.Yail.YAIL_SPACER;d=d+AI.Yail.YAIL_OPEN_COMBINATION+AI.Yail.YAIL_LIST_CONSTRUCTOR+AI.Yail.YAIL_SPACER+k+AI.Yail.YAIL_CLOSE_COMBINATION;d=d+AI.Yail.YAIL_SPACER+AI.Yail.YAIL_QUOTE+AI.Yail.YAIL_OPEN_COMBINATION+
p+AI.Yail.YAIL_CLOSE_COMBINATION+AI.Yail.YAIL_SPACER;d=d+AI.Yail.YAIL_DOUBLE_QUOTE+h+AI.Yail.YAIL_DOUBLE_QUOTE+AI.Yail.YAIL_CLOSE_COMBINATION;return[d,AI.Yail.ORDER_ATOMIC]};AI.Yail.forBlock.math_bitwise.OPERATORS={BITAND:["bitwise-and",AI.Yail.ORDER_NONE],BITIOR:["bitwise-ior",AI.Yail.ORDER_NONE],BITXOR:["bitwise-xor",AI.Yail.ORDER_NONE]};
AI.Yail.forBlock.math_single=function(d,e){var h=d.getFieldValue("OP"),k=AI.Yail.forBlock.math_single.OPERATORS[h],m=k[0];h=k[1];d=e.valueToCode(d,"NUM",k[2])||1;e=AI.Yail.YAIL_CALL_YAIL_PRIMITIVE+m+AI.Yail.YAIL_SPACER;e=e+AI.Yail.YAIL_OPEN_COMBINATION+AI.Yail.YAIL_LIST_CONSTRUCTOR+AI.Yail.YAIL_SPACER+d+AI.Yail.YAIL_CLOSE_COMBINATION;e=e+AI.Yail.YAIL_SPACER+AI.Yail.YAIL_QUOTE+AI.Yail.YAIL_OPEN_COMBINATION+"number"+AI.Yail.YAIL_CLOSE_COMBINATION+AI.Yail.YAIL_SPACER;e=e+AI.Yail.YAIL_DOUBLE_QUOTE+h+
AI.Yail.YAIL_DOUBLE_QUOTE+AI.Yail.YAIL_CLOSE_COMBINATION;return[e,AI.Yail.ORDER_ATOMIC]};AI.Yail.forBlock.math_single.OPERATORS={ROOT:["sqrt","sqrt",AI.Yail.ORDER_NONE],ABS:["abs","abs",AI.Yail.ORDER_NONE],NEG:["-","negate",AI.Yail.ORDER_NONE],LN:["log","log",AI.Yail.ORDER_NONE],EXP:["exp","exp",AI.Yail.ORDER_NONE],ROUND:["yail-round","round",AI.Yail.ORDER_NONE],CEILING:["yail-ceiling","ceiling",AI.Yail.ORDER_NONE],FLOOR:["yail-floor","floor",AI.Yail.ORDER_NONE]};
AI.Yail.forBlock.math_abs=function(d,e){return AI.Yail.forBlock.math_single(d,e)};AI.Yail.forBlock.math_neg=function(d,e){return AI.Yail.forBlock.math_single(d,e)};AI.Yail.forBlock.math_round=function(d,e){return AI.Yail.forBlock.math_single(d,e)};AI.Yail.forBlock.math_ceiling=function(d,e){return AI.Yail.forBlock.math_single(d,e)};AI.Yail.forBlock.math_floor=function(d,e){return AI.Yail.forBlock.math_single(d,e)};
AI.Yail.forBlock.math_random_int=function(d,e){var h=e.valueToCode(d,"FROM",AI.Yail.ORDER_NONE)||0;d=e.valueToCode(d,"TO",AI.Yail.ORDER_NONE)||0;e=AI.Yail.YAIL_CALL_YAIL_PRIMITIVE+"random-integer"+AI.Yail.YAIL_SPACER;e=e+AI.Yail.YAIL_OPEN_COMBINATION+AI.Yail.YAIL_LIST_CONSTRUCTOR+AI.Yail.YAIL_SPACER+h+AI.Yail.YAIL_SPACER+d+AI.Yail.YAIL_CLOSE_COMBINATION;e=e+AI.Yail.YAIL_SPACER+AI.Yail.YAIL_QUOTE+AI.Yail.YAIL_OPEN_COMBINATION+"number number"+AI.Yail.YAIL_CLOSE_COMBINATION+AI.Yail.YAIL_SPACER;e=e+AI.Yail.YAIL_DOUBLE_QUOTE+
"random integer"+AI.Yail.YAIL_DOUBLE_QUOTE+AI.Yail.YAIL_CLOSE_COMBINATION;return[e,AI.Yail.ORDER_ATOMIC]};
AI.Yail.forBlock.math_random_float=function(d,e){d=AI.Yail.YAIL_CALL_YAIL_PRIMITIVE+"random-fraction"+AI.Yail.YAIL_SPACER;d=d+AI.Yail.YAIL_OPEN_COMBINATION+AI.Yail.YAIL_LIST_CONSTRUCTOR+AI.Yail.YAIL_CLOSE_COMBINATION+AI.Yail.YAIL_SPACER+AI.Yail.YAIL_QUOTE+AI.Yail.YAIL_OPEN_COMBINATION;d=d+AI.Yail.YAIL_CLOSE_COMBINATION+AI.Yail.YAIL_SPACER+AI.Yail.YAIL_DOUBLE_QUOTE+"random fraction"+AI.Yail.YAIL_DOUBLE_QUOTE+AI.Yail.YAIL_CLOSE_COMBINATION;return[d,AI.Yail.ORDER_ATOMIC]};
AI.Yail.forBlock.math_random_set_seed=function(d,e){d=e.valueToCode(d,"NUM",AI.Yail.ORDER_NONE)||0;e=AI.Yail.YAIL_CALL_YAIL_PRIMITIVE+"random-set-seed"+AI.Yail.YAIL_SPACER;e=e+AI.Yail.YAIL_OPEN_COMBINATION+AI.Yail.YAIL_LIST_CONSTRUCTOR+AI.Yail.YAIL_SPACER+d+AI.Yail.YAIL_CLOSE_COMBINATION;e=e+AI.Yail.YAIL_SPACER+AI.Yail.YAIL_QUOTE+AI.Yail.YAIL_OPEN_COMBINATION+"number"+AI.Yail.YAIL_CLOSE_COMBINATION+AI.Yail.YAIL_SPACER;return e=e+AI.Yail.YAIL_DOUBLE_QUOTE+"random set seed"+AI.Yail.YAIL_DOUBLE_QUOTE+
AI.Yail.YAIL_CLOSE_COMBINATION};
AI.Yail.forBlock.math_on_list=function(d,e){var h=d.getFieldValue("OP"),k=AI.Yail.forBlock.math_on_list.OPERATORS[h];h=k[0];for(var m=k[1],p=k[2],t=k="",q=0;q<d.itemCount_;q++)k+=(e.valueToCode(d,"NUM"+q,m)||0)+AI.Yail.YAIL_SPACER,t+="number"+AI.Yail.YAIL_SPACER;0===d.itemCount_&&(k+=p+AI.Yail.YAIL_SPACER,t+="number"+AI.Yail.YAIL_SPACER);d=AI.Yail.YAIL_CALL_YAIL_PRIMITIVE+h+AI.Yail.YAIL_SPACER;d=d+AI.Yail.YAIL_OPEN_COMBINATION+AI.Yail.YAIL_LIST_CONSTRUCTOR+AI.Yail.YAIL_SPACER+k+AI.Yail.YAIL_CLOSE_COMBINATION;
d=d+AI.Yail.YAIL_SPACER+AI.Yail.YAIL_QUOTE+AI.Yail.YAIL_OPEN_COMBINATION+t+AI.Yail.YAIL_CLOSE_COMBINATION+AI.Yail.YAIL_SPACER;d=d+AI.Yail.YAIL_DOUBLE_QUOTE+h+AI.Yail.YAIL_DOUBLE_QUOTE+AI.Yail.YAIL_CLOSE_COMBINATION;return[d,AI.Yail.ORDER_ATOMIC]};AI.Yail.forBlock.math_on_list.OPERATORS={MIN:["min",AI.Yail.ORDER_NONE,"+inf.0"],MAX:["max",AI.Yail.ORDER_NONE,"-inf.0"]};
AI.Yail.forBlock.math_on_list2=function(d,e){var h=d.getFieldValue("OP");h=AI.Yail.forBlock.math_on_list2.OPERATORS[h][0];d=e.valueToCode(d,"LIST",AI.Yail.ORDER_NONE)||AI.Yail.YAIL_EMPTY_YAIL_LIST;e=AI.Yail.YAIL_CALL_YAIL_PRIMITIVE+h+AI.Yail.YAIL_SPACER;e=e+AI.Yail.YAIL_OPEN_COMBINATION+AI.Yail.YAIL_LIST_CONSTRUCTOR+AI.Yail.YAIL_SPACER+d+AI.Yail.YAIL_CLOSE_COMBINATION;e=e+AI.Yail.YAIL_SPACER+AI.Yail.YAIL_QUOTE+AI.Yail.YAIL_OPEN_COMBINATION+"list-of-number"+AI.Yail.YAIL_CLOSE_COMBINATION+AI.Yail.YAIL_SPACER;
e=e+AI.Yail.YAIL_DOUBLE_QUOTE+h+AI.Yail.YAIL_DOUBLE_QUOTE+AI.Yail.YAIL_CLOSE_COMBINATION;return[e,AI.Yail.ORDER_ATOMIC]};AI.Yail.forBlock.math_on_list2.OPERATORS={AVG:["avg",AI.Yail.ORDER_NONE],MIN:["minl",AI.Yail.ORDER_NONE],MAX:["maxl",AI.Yail.ORDER_NONE],GM:["gm",AI.Yail.ORDER_NONE],SD:["std-dev",AI.Yail.ORDER_NONE],SE:["std-err",AI.Yail.ORDER_NONE]};
AI.Yail.forBlock.math_mode_of_list=function(d,e){d=e.valueToCode(d,"LIST",AI.Yail.ORDER_NONE)||AI.Yail.YAIL_EMPTY_YAIL_LIST;e=AI.Yail.YAIL_CALL_YAIL_PRIMITIVE+"mode"+AI.Yail.YAIL_SPACER;e=e+AI.Yail.YAIL_OPEN_COMBINATION+AI.Yail.YAIL_LIST_CONSTRUCTOR+AI.Yail.YAIL_SPACER+d+AI.Yail.YAIL_CLOSE_COMBINATION;e=e+AI.Yail.YAIL_SPACER+AI.Yail.YAIL_QUOTE+AI.Yail.YAIL_OPEN_COMBINATION+"list-of-number"+AI.Yail.YAIL_CLOSE_COMBINATION+AI.Yail.YAIL_SPACER;e=e+AI.Yail.YAIL_DOUBLE_QUOTE+"mode"+AI.Yail.YAIL_DOUBLE_QUOTE+
AI.Yail.YAIL_CLOSE_COMBINATION;return[e,AI.Yail.ORDER_ATOMIC]};
AI.Yail.forBlock.math_divide=function(d,e){var h=d.getFieldValue("OP"),k=AI.Yail.forBlock.math_divide.OPERATORS[h];h=k[0];var m=k[1];k=e.valueToCode(d,"DIVIDEND",m)||0;d=e.valueToCode(d,"DIVISOR",m)||1;e=AI.Yail.YAIL_CALL_YAIL_PRIMITIVE+h+AI.Yail.YAIL_SPACER;e=e+AI.Yail.YAIL_OPEN_COMBINATION+AI.Yail.YAIL_LIST_CONSTRUCTOR+AI.Yail.YAIL_SPACER+k+AI.Yail.YAIL_SPACER+d+AI.Yail.YAIL_CLOSE_COMBINATION;e=e+AI.Yail.YAIL_SPACER+AI.Yail.YAIL_QUOTE+AI.Yail.YAIL_OPEN_COMBINATION+"number number"+AI.Yail.YAIL_CLOSE_COMBINATION+
AI.Yail.YAIL_SPACER;e=e+AI.Yail.YAIL_DOUBLE_QUOTE+h+AI.Yail.YAIL_DOUBLE_QUOTE+AI.Yail.YAIL_CLOSE_COMBINATION;return[e,AI.Yail.ORDER_ATOMIC]};AI.Yail.forBlock.math_divide.OPERATORS={MODULO:["modulo",AI.Yail.ORDER_NONE],REMAINDER:["remainder",AI.Yail.ORDER_NONE],QUOTIENT:["quotient",AI.Yail.ORDER_NONE]};
AI.Yail.forBlock.math_trig=function(d,e){var h=d.getFieldValue("OP"),k=AI.Yail.forBlock.math_trig.OPERATORS[h],m=k[1];h=k[0];d=e.valueToCode(d,"NUM",k[2])||0;e=AI.Yail.YAIL_CALL_YAIL_PRIMITIVE+m+AI.Yail.YAIL_SPACER;e=e+AI.Yail.YAIL_OPEN_COMBINATION+AI.Yail.YAIL_LIST_CONSTRUCTOR+AI.Yail.YAIL_SPACER+d+AI.Yail.YAIL_CLOSE_COMBINATION;e=e+AI.Yail.YAIL_SPACER+AI.Yail.YAIL_QUOTE+AI.Yail.YAIL_OPEN_COMBINATION+"number"+AI.Yail.YAIL_CLOSE_COMBINATION+AI.Yail.YAIL_SPACER;e=e+AI.Yail.YAIL_DOUBLE_QUOTE+h+AI.Yail.YAIL_DOUBLE_QUOTE+
AI.Yail.YAIL_CLOSE_COMBINATION;return[e,AI.Yail.ORDER_ATOMIC]};AI.Yail.forBlock.math_trig.OPERATORS={SIN:["sin","sin-degrees",AI.Yail.ORDER_NONE],COS:["cos","cos-degrees",AI.Yail.ORDER_NONE],TAN:["tan","tan-degrees",AI.Yail.ORDER_NONE],ASIN:["asin","asin-degrees",AI.Yail.ORDER_NONE],ACOS:["acos","acos-degrees",AI.Yail.ORDER_NONE],ATAN:["atan","atan-degrees",AI.Yail.ORDER_NONE]};AI.Yail.forBlock.math_cos=function(d,e){return AI.Yail.forBlock.math_trig(d,e)};
AI.Yail.forBlock.math_tan=function(d,e){return AI.Yail.forBlock.math_trig(d,e)};
AI.Yail.forBlock.math_atan2=function(d,e){var h=e.valueToCode(d,"Y",AI.Yail.ORDER_NONE)||1;d=e.valueToCode(d,"X",AI.Yail.ORDER_NONE)||1;e=AI.Yail.YAIL_CALL_YAIL_PRIMITIVE+"atan2-degrees"+AI.Yail.YAIL_SPACER;e=e+AI.Yail.YAIL_OPEN_COMBINATION+AI.Yail.YAIL_LIST_CONSTRUCTOR+AI.Yail.YAIL_SPACER+h+AI.Yail.YAIL_SPACER+d+AI.Yail.YAIL_CLOSE_COMBINATION;e=e+AI.Yail.YAIL_SPACER+AI.Yail.YAIL_QUOTE+AI.Yail.YAIL_OPEN_COMBINATION+"number number"+AI.Yail.YAIL_CLOSE_COMBINATION+AI.Yail.YAIL_SPACER;e=e+AI.Yail.YAIL_DOUBLE_QUOTE+
"atan2"+AI.Yail.YAIL_DOUBLE_QUOTE+AI.Yail.YAIL_CLOSE_COMBINATION;return[e,AI.Yail.ORDER_ATOMIC]};
AI.Yail.forBlock.math_convert_angles=function(d,e){var h=d.getFieldValue("OP"),k=AI.Yail.forBlock.math_convert_angles.OPERATORS[h],m=k[0];h=k[1];d=e.valueToCode(d,"NUM",k[2])||0;e=AI.Yail.YAIL_CALL_YAIL_PRIMITIVE+m+AI.Yail.YAIL_SPACER;e=e+AI.Yail.YAIL_OPEN_COMBINATION+AI.Yail.YAIL_LIST_CONSTRUCTOR+AI.Yail.YAIL_SPACER+d+AI.Yail.YAIL_CLOSE_COMBINATION;e=e+AI.Yail.YAIL_SPACER+AI.Yail.YAIL_QUOTE+AI.Yail.YAIL_OPEN_COMBINATION+"number"+AI.Yail.YAIL_CLOSE_COMBINATION+AI.Yail.YAIL_SPACER;e=e+AI.Yail.YAIL_DOUBLE_QUOTE+
h+AI.Yail.YAIL_DOUBLE_QUOTE+AI.Yail.YAIL_CLOSE_COMBINATION;return[e,AI.Yail.ORDER_ATOMIC]};AI.Yail.forBlock.math_convert_angles.OPERATORS={RADIANS_TO_DEGREES:["radians->degrees","convert radians to degrees",AI.Yail.ORDER_NONE],DEGREES_TO_RADIANS:["degrees->radians","convert degrees to radians",AI.Yail.ORDER_NONE]};
AI.Yail.forBlock.math_format_as_decimal=function(d,e){var h=e.valueToCode(d,"NUM",AI.Yail.ORDER_NONE)||0;d=e.valueToCode(d,"PLACES",AI.Yail.ORDER_NONE)||0;e=AI.Yail.YAIL_CALL_YAIL_PRIMITIVE+"format-as-decimal"+AI.Yail.YAIL_SPACER;e=e+AI.Yail.YAIL_OPEN_COMBINATION+AI.Yail.YAIL_LIST_CONSTRUCTOR+AI.Yail.YAIL_SPACER+h+AI.Yail.YAIL_SPACER+d+AI.Yail.YAIL_CLOSE_COMBINATION;e=e+AI.Yail.YAIL_SPACER+AI.Yail.YAIL_QUOTE+AI.Yail.YAIL_OPEN_COMBINATION+"number number"+AI.Yail.YAIL_CLOSE_COMBINATION+AI.Yail.YAIL_SPACER;
e=e+AI.Yail.YAIL_DOUBLE_QUOTE+"format as decimal"+AI.Yail.YAIL_DOUBLE_QUOTE+AI.Yail.YAIL_CLOSE_COMBINATION;return[e,AI.Yail.ORDER_ATOMIC]};AI.Yail.forBlock.math_is_a_number=function(d,e){var h=d.getFieldValue("OP"),k=AI.Yail.forBlock.math_is_a_number.OPERATORS[h];h=k[0];k=k[1];d=e.valueToCode(d,"NUM",AI.Yail.ORDER_NONE)||AI.Yail.YAIL_FALSE;return["(call-yail-primitive "+h+" (*list-for-runtime* "+d+") "+k+")",AI.Yail.ORDER_ATOMIC]};
AI.Yail.forBlock.math_is_a_number.OPERATORS={NUMBER:["is-number?",'\'(text) "is a number?"'],BASE10:["is-base10?",'\'(text) "is base10?"'],HEXADECIMAL:["is-hexadecimal?",'\'(text) "is hexadecimal?"'],BINARY:["is-binary?",'\'(text) "is binary?"']};
AI.Yail.forBlock.math_convert_number=function(d,e){var h=d.getFieldValue("OP"),k=AI.Yail.forBlock.math_convert_number.OPERATORS[h];h=k[0];k=k[1];d=e.valueToCode(d,"NUM",AI.Yail.ORDER_NONE)||0;return["(call-yail-primitive "+h+" (*list-for-runtime* "+d+") "+k+")",AI.Yail.ORDER_ATOMIC]};
AI.Yail.forBlock.math_convert_number.OPERATORS={DEC_TO_HEX:["math-convert-dec-hex",'\'(text) "convert Dec to Hex"'],HEX_TO_DEC:["math-convert-hex-dec",'\'(text) "convert Hex to Dec"'],DEC_TO_BIN:["math-convert-dec-bin",'\'(text) "convert Dec to Hex"'],BIN_TO_DEC:["math-convert-bin-dec",'\'(text) "convert Hex to Dec"']};/*

 @fileoverview Matrices blocks yail generators for Blockly, modified for MIT App Inventor.
 @author jackyc@mit.edu (Jacky Chen)
*/
AI.Yail.matrices={};
AI.Yail.forBlock.matrices_create=function(d,e){e=d.getFieldValue("ROWS")||2;var h=d.getFieldValue("COLS")||2,k=AI.Yail.YAIL_CALL_YAIL_PRIMITIVE+"make-yail-matrix"+AI.Yail.YAIL_SPACER;k+=AI.Yail.YAIL_OPEN_COMBINATION+AI.Yail.YAIL_LIST_CONSTRUCTOR+AI.Yail.YAIL_SPACER;k+=e+AI.Yail.YAIL_SPACER+h;for(var m=0;m<e;m++)for(var p=0;p<h;p++){var t=d.getFieldValue("MATRIX_"+m+"_"+p)||0;k+=AI.Yail.YAIL_SPACER+t}k+=AI.Yail.YAIL_CLOSE_COMBINATION+AI.Yail.YAIL_SPACER;k+=AI.Yail.YAIL_QUOTE+AI.Yail.YAIL_OPEN_COMBINATION;k+=
"number number";for(m=0;m<e*h;m++)k+=" number";k+=AI.Yail.YAIL_CLOSE_COMBINATION+AI.Yail.YAIL_SPACER;k+=AI.Yail.YAIL_DOUBLE_QUOTE+"create a matrix"+AI.Yail.YAIL_DOUBLE_QUOTE+AI.Yail.YAIL_CLOSE_COMBINATION;return[k,AI.Yail.ORDER_ATOMIC]};
AI.Yail.forBlock.matrices_create_multidim=function(d,e){var h=e.valueToCode(d,"DIM",AI.Yail.ORDER_NONE)||AI.Yail.YAIL_NULL;d=e.valueToCode(d,"INITIAL",AI.Yail.ORDER_NONE)||"0";e=AI.Yail.YAIL_CALL_YAIL_PRIMITIVE+"make-yail-matrix-multidim"+AI.Yail.YAIL_SPACER;e+=AI.Yail.YAIL_OPEN_COMBINATION+AI.Yail.YAIL_LIST_CONSTRUCTOR+AI.Yail.YAIL_SPACER;e+=h+AI.Yail.YAIL_SPACER+d;e+=AI.Yail.YAIL_CLOSE_COMBINATION+AI.Yail.YAIL_SPACER+AI.Yail.YAIL_QUOTE;e+=AI.Yail.YAIL_OPEN_COMBINATION+"list number"+AI.Yail.YAIL_CLOSE_COMBINATION+
AI.Yail.YAIL_SPACER;e+=AI.Yail.YAIL_DOUBLE_QUOTE+"create multidimensional matrix"+AI.Yail.YAIL_DOUBLE_QUOTE+AI.Yail.YAIL_CLOSE_COMBINATION;return[e,AI.Yail.ORDER_ATOMIC]};
AI.Yail.forBlock.matrices_get_row=function(d,e){var h=e.valueToCode(d,"MATRIX",AI.Yail.ORDER_NONE)||AI.Yail.YAIL_NULL;d=e.valueToCode(d,"ROW",AI.Yail.ORDER_NONE)||1;e=AI.Yail.YAIL_CALL_YAIL_PRIMITIVE+"yail-matrix-get-row"+AI.Yail.YAIL_SPACER;e+=AI.Yail.YAIL_OPEN_COMBINATION+AI.Yail.YAIL_LIST_CONSTRUCTOR+AI.Yail.YAIL_SPACER;e+=h+AI.Yail.YAIL_SPACER+d+AI.Yail.YAIL_CLOSE_COMBINATION;e+=AI.Yail.YAIL_SPACER+AI.Yail.YAIL_QUOTE+AI.Yail.YAIL_OPEN_COMBINATION;e+="matrix number"+AI.Yail.YAIL_CLOSE_COMBINATION+
AI.Yail.YAIL_SPACER;e+=AI.Yail.YAIL_DOUBLE_QUOTE+"get matrix row"+AI.Yail.YAIL_DOUBLE_QUOTE+AI.Yail.YAIL_CLOSE_COMBINATION;return[e,AI.Yail.ORDER_ATOMIC]};
AI.Yail.forBlock.matrices_get_column=function(d,e){var h=e.valueToCode(d,"MATRIX",AI.Yail.ORDER_NONE)||AI.Yail.YAIL_NULL;d=e.valueToCode(d,"COLUMN",AI.Yail.ORDER_NONE)||1;e=AI.Yail.YAIL_CALL_YAIL_PRIMITIVE+"yail-matrix-get-column"+AI.Yail.YAIL_SPACER;e+=AI.Yail.YAIL_OPEN_COMBINATION+AI.Yail.YAIL_LIST_CONSTRUCTOR+AI.Yail.YAIL_SPACER;e+=h+AI.Yail.YAIL_SPACER+d+AI.Yail.YAIL_CLOSE_COMBINATION;e+=AI.Yail.YAIL_SPACER+AI.Yail.YAIL_QUOTE+AI.Yail.YAIL_OPEN_COMBINATION;e+="matrix number"+AI.Yail.YAIL_CLOSE_COMBINATION+
AI.Yail.YAIL_SPACER;e+=AI.Yail.YAIL_DOUBLE_QUOTE+"get matrix column"+AI.Yail.YAIL_DOUBLE_QUOTE+AI.Yail.YAIL_CLOSE_COMBINATION;return[e,AI.Yail.ORDER_ATOMIC]};
AI.Yail.forBlock.matrices_get_cell=function(d,e){var h=e.valueToCode(d,"MATRIX",AI.Yail.ORDER_NONE)||AI.Yail.YAIL_NULL,k=AI.Yail.YAIL_CALL_YAIL_PRIMITIVE+"yail-matrix-get-cell"+AI.Yail.YAIL_SPACER;k+=AI.Yail.YAIL_OPEN_COMBINATION+AI.Yail.YAIL_LIST_CONSTRUCTOR+AI.Yail.YAIL_SPACER;k+=h;for(h=0;h<d.itemCount_;h++){var m=e.valueToCode(d,"DIM"+h,AI.Yail.ORDER_NONE)||"1";k+=AI.Yail.YAIL_SPACER+m}k+=AI.Yail.YAIL_CLOSE_COMBINATION+AI.Yail.YAIL_SPACER;k+=AI.Yail.YAIL_QUOTE+AI.Yail.YAIL_OPEN_COMBINATION+"matrix";
for(h=0;h<d.itemCount_;h++)k+=" number";k+=AI.Yail.YAIL_CLOSE_COMBINATION+AI.Yail.YAIL_SPACER;k+=AI.Yail.YAIL_DOUBLE_QUOTE+"get matrix cell"+AI.Yail.YAIL_DOUBLE_QUOTE+AI.Yail.YAIL_CLOSE_COMBINATION;return[k,AI.Yail.ORDER_ATOMIC]};
AI.Yail.forBlock.matrices_set_cell=function(d,e){var h=e.valueToCode(d,"MATRIX",AI.Yail.ORDER_NONE)||AI.Yail.YAIL_NULL,k=e.valueToCode(d,"VALUE",AI.Yail.ORDER_NONE)||1,m=AI.Yail.YAIL_CALL_YAIL_PRIMITIVE+"yail-matrix-set-cell!"+AI.Yail.YAIL_SPACER;m+=AI.Yail.YAIL_OPEN_COMBINATION+AI.Yail.YAIL_LIST_CONSTRUCTOR+AI.Yail.YAIL_SPACER;m+=h+AI.Yail.YAIL_SPACER+k;for(h=0;h<d.itemCount_;h++)k=e.valueToCode(d,"DIM"+h,AI.Yail.ORDER_NONE)||"1",m+=AI.Yail.YAIL_SPACER+k;m+=AI.Yail.YAIL_CLOSE_COMBINATION+AI.Yail.YAIL_SPACER;
m+=AI.Yail.YAIL_QUOTE+AI.Yail.YAIL_OPEN_COMBINATION+"matrix";for(h=0;h<d.itemCount_+1;h++)m+=" number";m+=AI.Yail.YAIL_CLOSE_COMBINATION+AI.Yail.YAIL_SPACER;return m+=AI.Yail.YAIL_DOUBLE_QUOTE+"set matrix cell"+AI.Yail.YAIL_DOUBLE_QUOTE+AI.Yail.YAIL_CLOSE_COMBINATION};
AI.Yail.forBlock.matrices_get_dims=function(d,e){d=e.valueToCode(d,"MATRIX",AI.Yail.ORDER_NONE)||AI.Yail.YAIL_NULL;e=AI.Yail.YAIL_CALL_YAIL_PRIMITIVE+"yail-matrix-get-dims"+AI.Yail.YAIL_SPACER;e+=AI.Yail.YAIL_OPEN_COMBINATION+AI.Yail.YAIL_LIST_CONSTRUCTOR+AI.Yail.YAIL_SPACER;e+=d+AI.Yail.YAIL_CLOSE_COMBINATION+AI.Yail.YAIL_SPACER;e+=AI.Yail.YAIL_QUOTE+AI.Yail.YAIL_OPEN_COMBINATION+"matrix"+AI.Yail.YAIL_CLOSE_COMBINATION+AI.Yail.YAIL_SPACER;e+=AI.Yail.YAIL_DOUBLE_QUOTE+"get matrix dimensions"+AI.Yail.YAIL_DOUBLE_QUOTE+
AI.Yail.YAIL_CLOSE_COMBINATION;return[e,AI.Yail.ORDER_ATOMIC]};
AI.Yail.forBlock.matrices_operations=function(d,e){var h=d.getFieldValue("OP"),k=AI.Yail.forBlock.matrices_operations.OPERATORS[h],m=k[0];h=k[1];d=e.valueToCode(d,"MATRIX",k[2]);e=AI.Yail.YAIL_CALL_YAIL_PRIMITIVE+m+AI.Yail.YAIL_SPACER;e=e+AI.Yail.YAIL_OPEN_COMBINATION+AI.Yail.YAIL_LIST_CONSTRUCTOR+AI.Yail.YAIL_SPACER+d+AI.Yail.YAIL_CLOSE_COMBINATION;e=e+AI.Yail.YAIL_SPACER+AI.Yail.YAIL_QUOTE+AI.Yail.YAIL_OPEN_COMBINATION+"matrix"+AI.Yail.YAIL_CLOSE_COMBINATION+AI.Yail.YAIL_SPACER;e=e+AI.Yail.YAIL_DOUBLE_QUOTE+
h+AI.Yail.YAIL_DOUBLE_QUOTE+AI.Yail.YAIL_CLOSE_COMBINATION;return[e,AI.Yail.ORDER_ATOMIC]};AI.Yail.forBlock.matrices_operations.OPERATORS={INVERSE:["yail-matrix-inverse","inverse",AI.Yail.ORDER_NONE],TRANSPOSE:["yail-matrix-transpose","transpose",AI.Yail.ORDER_NONE],ROTATE_LEFT:["yail-matrix-rotate-left","rotate_left",AI.Yail.ORDER_NONE],ROTATE_RIGHT:["yail-matrix-rotate-right","rotate_right",AI.Yail.ORDER_NONE]};
AI.Yail.forBlock.matrices_transpose=function(d,e){return AI.Yail.forBlock.matrices_operations.call(d,d,e)};AI.Yail.forBlock.matrices_rotate_left=function(d,e){return AI.Yail.forBlock.matrices_operations.call(d,d,e)};AI.Yail.forBlock.matrices_rotate_right=function(d,e){return AI.Yail.forBlock.matrices_operations.call(d,d,e)};
AI.Yail.forBlock.matrices_arithmetic=function(d,e,h){var k=AI.Yail.forBlock.matrices_arithmetic.OPERATORS[h],m=k[0],p=k[1];k=e.valueToCode(d,"A",p)||0;d=e.valueToCode(d,"B",p)||0;e=AI.Yail.YAIL_CALL_YAIL_PRIMITIVE+m+AI.Yail.YAIL_SPACER;e+=AI.Yail.YAIL_OPEN_COMBINATION+AI.Yail.YAIL_LIST_CONSTRUCTOR+AI.Yail.YAIL_SPACER;e+=k+AI.Yail.YAIL_SPACER+d;e+=AI.Yail.YAIL_CLOSE_COMBINATION+AI.Yail.YAIL_SPACER;e+=AI.Yail.YAIL_QUOTE+AI.Yail.YAIL_OPEN_COMBINATION;e=("POWER"===h?e+"matrix number":"MULTIPLY"===h?e+
"matrix any":e+"matrix matrix")+(AI.Yail.YAIL_CLOSE_COMBINATION+AI.Yail.YAIL_SPACER);e+=AI.Yail.YAIL_DOUBLE_QUOTE+m+AI.Yail.YAIL_DOUBLE_QUOTE+AI.Yail.YAIL_CLOSE_COMBINATION;return[e,AI.Yail.ORDER_ATOMIC]};AI.Yail.forBlock.matrices_subtract=function(d,e){return AI.Yail.forBlock.matrices_arithmetic(d,e,"MINUS")};AI.Yail.forBlock.matrices_power=function(d,e){return AI.Yail.forBlock.matrices_arithmetic(d,e,"POWER")};
AI.Yail.forBlock.matrices_add=function(d,e){return AI.Yail.forBlock.matrices_arithmetic_list(d,e,"ADD")};AI.Yail.forBlock.matrices_multiply=function(d,e){return AI.Yail.forBlock.matrices_arithmetic_list(d,e,"MULTIPLY")};
AI.Yail.forBlock.matrices_arithmetic_list=function(d,e,h){var k=AI.Yail.forBlock.matrices_arithmetic.OPERATORS[h],m=k[0],p=k[1];k=[];for(var t=0;t<d.itemCount_;t++){var q=e.valueToCode(d,"MAT"+t,p)||0;q&&k.push(q)}if("ADD"===h){if(0===k.length)return["0",p];if(1===k.length)return[k[0],p]}if("MULTIPLY"===h){if(0===d.itemCount_)return["1",p];if(0===k.length)return["0",p];if(1===k.length)return[k[0],p]}d=AI.Yail.YAIL_CALL_YAIL_PRIMITIVE+m+AI.Yail.YAIL_SPACER;d+=AI.Yail.YAIL_OPEN_COMBINATION+AI.Yail.YAIL_LIST_CONSTRUCTOR+
AI.Yail.YAIL_SPACER;d+=k.join(AI.Yail.YAIL_SPACER)+AI.Yail.YAIL_SPACER;d+=AI.Yail.YAIL_CLOSE_COMBINATION+AI.Yail.YAIL_SPACER+AI.Yail.YAIL_QUOTE+AI.Yail.YAIL_OPEN_COMBINATION;if("ADD"===h)for(t=0;t<k.length;t++)d+="matrix"+AI.Yail.YAIL_SPACER;else if("MULTIPLY"===h)for(d+="matrix"+AI.Yail.YAIL_SPACER,t=1;t<k.length;t++)d+="any"+AI.Yail.YAIL_SPACER;d+=AI.Yail.YAIL_CLOSE_COMBINATION+AI.Yail.YAIL_SPACER+AI.Yail.YAIL_DOUBLE_QUOTE+m+AI.Yail.YAIL_DOUBLE_QUOTE+AI.Yail.YAIL_CLOSE_COMBINATION;return[d,AI.Yail.ORDER_ATOMIC]};
AI.Yail.forBlock.matrices_arithmetic.OPERATORS={ADD:["yail-matrix-add",AI.Yail.ORDER_NONE],MINUS:["yail-matrix-subtract",AI.Yail.ORDER_NONE],MULTIPLY:["yail-matrix-multiply",AI.Yail.ORDER_NONE],POWER:["yail-matrix-power",AI.Yail.ORDER_NONE]};
AI.Yail.forBlock.matrices_is_matrix=function(d,e){d=e.valueToCode(d,"VALUE",AI.Yail.ORDER_NONE)||AI.Yail.YAIL_NULL;e=AI.Yail.YAIL_CALL_YAIL_PRIMITIVE+"yail-matrix?"+AI.Yail.YAIL_SPACER;e+=AI.Yail.YAIL_OPEN_COMBINATION+AI.Yail.YAIL_LIST_CONSTRUCTOR+AI.Yail.YAIL_SPACER;e+=d+AI.Yail.YAIL_CLOSE_COMBINATION+AI.Yail.YAIL_SPACER;e+=AI.Yail.YAIL_QUOTE+AI.Yail.YAIL_OPEN_COMBINATION+"any"+AI.Yail.YAIL_CLOSE_COMBINATION+AI.Yail.YAIL_SPACER;e+=AI.Yail.YAIL_DOUBLE_QUOTE+"is matrix?"+AI.Yail.YAIL_DOUBLE_QUOTE+
AI.Yail.YAIL_CLOSE_COMBINATION;return[e,AI.Yail.ORDER_ATOMIC]};/*

 @fileoverview Procedure yail generators for Blockly, modified for MIT App Inventor.
 @author mckinney@mit.edu (Andrew F. McKinney)
*/
AI.Yail.procedures={};AI.Yail.YAIL_PROC_TAG="p$";AI.Yail.forBlock.procedures_defreturn=function(d,e){var h=AI.Yail.YAIL_LOCAL_VAR_TAG+(Blockly.usePrefixInYail&&0!=d.arguments_.length?"param_":""),k=d.arguments_.map(function(p){return h+p}).join(" "),m=AI.Yail.YAIL_PROC_TAG+d.getFieldValue("NAME");d=e.valueToCode(d,"RETURN",AI.Yail.ORDER_NONE)||AI.Yail.YAIL_FALSE;return AI.Yail.YAIL_DEFINE+AI.Yail.YAIL_OPEN_COMBINATION+m+AI.Yail.YAIL_SPACER+k+AI.Yail.YAIL_CLOSE_COMBINATION+AI.Yail.YAIL_SPACER+d+AI.Yail.YAIL_CLOSE_COMBINATION};
AI.Yail.forBlock.procedures_defnoreturn=function(d,e){var h=AI.Yail.YAIL_LOCAL_VAR_TAG+(Blockly.usePrefixInYail&&0!=d.arguments_.length?"param_":""),k=d.arguments_.map(function(p){return h+p}).join(" "),m=AI.Yail.YAIL_PROC_TAG+d.getFieldValue("NAME");d=e.statementToCode(d,"STACK")||AI.Yail.YAIL_FALSE;return AI.Yail.YAIL_DEFINE+AI.Yail.YAIL_OPEN_COMBINATION+m+AI.Yail.YAIL_SPACER+k+AI.Yail.YAIL_CLOSE_COMBINATION+d+AI.Yail.YAIL_CLOSE_COMBINATION};
AI.Yail.forBlock.procedures_defanonnoreturn=function(d,e){var h=AI.Yail.YAIL_LOCAL_VAR_TAG+(Blockly.usePrefixInYail&&0!=d.arguments_.length?"param_":""),k=d.getVars().map(function(m){return h+m}).join(" ");d=e.statementToCode(d,"STACK",AI.Yail.ORDER_NONE)||AI.Yail.YAIL_FALSE;return[AI.Yail.YailCallYialPrimitive("create-yail-procedure",AI.Yail.YAIL_LAMBDA+AI.Yail.YAIL_OPEN_COMBINATION+k+AI.Yail.YAIL_CLOSE_COMBINATION+AI.Yail.YAIL_SPACER+d+AI.Yail.YAIL_CLOSE_COMBINATION,"any","create procedure"),AI.Yail.ORDER_ATOMIC]};
AI.Yail.forBlock.procedures_defanonreturn=function(d,e){var h=AI.Yail.YAIL_LOCAL_VAR_TAG+(Blockly.usePrefixInYail&&0!=d.arguments_.length?"param_":""),k=d.getVars().map(function(m){return h+m}).join(" ");d=e.valueToCode(d,"RETURN",AI.Yail.ORDER_NONE)||AI.Yail.YAIL_FALSE;return[AI.Yail.YailCallYialPrimitive("create-yail-procedure",AI.Yail.YAIL_LAMBDA+AI.Yail.YAIL_OPEN_COMBINATION+k+AI.Yail.YAIL_CLOSE_COMBINATION+AI.Yail.YAIL_SPACER+d+AI.Yail.YAIL_CLOSE_COMBINATION,"any","create procedure"),AI.Yail.ORDER_ATOMIC]};
AI.Yail.forBlock.procedure_lexical_variable_get=function(d,e){return AI.Yail.forBlock.lexical_variable_get(d,e)};AI.Yail.forBlock.procedures_do_then_return=function(d,e){return AI.Yail.forBlock.controls_do_then_return(d,e)};
AI.Yail.forBlock.procedures_callnoreturn=function(d,e){for(var h=AI.Yail.YAIL_PROC_TAG+d.getFieldValue("PROCNAME"),k=[],m=0;d.getInput("ARG"+m);m++)k[m]=e.valueToCode(d,"ARG"+m,AI.Yail.ORDER_NONE)||AI.Yail.YAIL_FALSE;return AI.Yail.YAIL_OPEN_COMBINATION+AI.Yail.YAIL_GET_VARIABLE+h+AI.Yail.YAIL_CLOSE_COMBINATION+AI.Yail.YAIL_SPACER+k.join(" ")+AI.Yail.YAIL_CLOSE_COMBINATION};
AI.Yail.forBlock.procedures_callreturn=function(d,e){for(var h=AI.Yail.YAIL_PROC_TAG+d.getFieldValue("PROCNAME"),k=[],m=0;d.getInput("ARG"+m);m++)k[m]=e.valueToCode(d,"ARG"+m,AI.Yail.ORDER_NONE)||AI.Yail.YAIL_FALSE;return[AI.Yail.YAIL_OPEN_COMBINATION+AI.Yail.YAIL_GET_VARIABLE+h+AI.Yail.YAIL_CLOSE_COMBINATION+AI.Yail.YAIL_SPACER+k.join(" ")+AI.Yail.YAIL_CLOSE_COMBINATION,AI.Yail.ORDER_ATOMIC]};
AI.Yail.forBlock.procedures_callanonnoreturn=function(d,e){var h=[],k=[];h.push(e.valueToCode(d,"PROCEDURE",AI.Yail.ORDER_NONE)||AI.Yail.YAIL_FALSE);k.push("any");for(var m=0;d.getInput("ARG"+m);m++)h.push(e.valueToCode(d,"ARG"+m,AI.Yail.ORDER_NONE)||AI.Yail.YAIL_FALSE),k.push("any");return AI.Yail.YailCallYialPrimitive("call-yail-procedure",h,k,"call procedure")};
AI.Yail.forBlock.procedures_callanonreturn=function(d,e){var h=[],k=[];h.push(e.valueToCode(d,"PROCEDURE",AI.Yail.ORDER_NONE)||AI.Yail.YAIL_FALSE);k.push("any");for(var m=0;d.getInput("ARG"+m);m++)h.push(e.valueToCode(d,"ARG"+m,AI.Yail.ORDER_NONE)||AI.Yail.YAIL_FALSE),k.push("any");return[AI.Yail.YailCallYialPrimitive("call-yail-procedure",h,k,"call procedure"),AI.Yail.ORDER_ATOMIC]};
AI.Yail.forBlock.procedures_callanonnoreturn_inputlist=function(d,e){return AI.Yail.YailCallYialPrimitive("call-yail-procedure-input-list",[e.valueToCode(d,"PROCEDURE",AI.Yail.ORDER_NONE)||AI.Yail.YAIL_FALSE,e.valueToCode(d,"INPUTLIST",AI.Yail.ORDER_NONE)||AI.Yail.YAIL_FALSE],["any","any"],"call procedure(with input list)")};
AI.Yail.forBlock.procedures_callanonreturn_inputlist=function(d,e){return[AI.Yail.YailCallYialPrimitive("call-yail-procedure-input-list",[e.valueToCode(d,"PROCEDURE",AI.Yail.ORDER_NONE)||AI.Yail.YAIL_FALSE,e.valueToCode(d,"INPUTLIST",AI.Yail.ORDER_NONE)||AI.Yail.YAIL_FALSE],["any","any"],"call procedure(with input list)"),AI.Yail.ORDER_ATOMIC]};
AI.Yail.forBlock.procedures_numArgs=function(d,e){return[AI.Yail.YailCallYialPrimitive("num-args-yail-procedure",e.valueToCode(d,"PROCEDURE",AI.Yail.ORDER_NONE)||AI.Yail.YAIL_FALSE,"any","get number of arguments"),AI.Yail.ORDER_ATOMIC]};AI.Yail.forBlock.procedures_getWithName=function(d,e){d=e.valueToCode(d,"PROCEDURENAME",AI.Yail.ORDER_NONE)||AI.Yail.YAIL_FALSE;return[AI.Yail.YailCallYialPrimitive("create-yail-procedure-with-name",d,"any","get procedure"),AI.Yail.ORDER_ATOMIC]};
AI.Yail.forBlock.procedures_getWithDropdown=function(d,e){d=AI.Yail.YAIL_GET_VARIABLE+AI.Yail.YAIL_PROC_TAG+d.getFieldValue("PROCNAME")+AI.Yail.YAIL_CLOSE_COMBINATION;return[AI.Yail.YailCallYialPrimitive("create-yail-procedure",d,"any","get procedure"),AI.Yail.ORDER_ATOMIC]};/*

 @fileoverview Text blocks yail generators for Blockly, modified for MIT App Inventor.
 @author mckinney@mit.edu (Andrew F. McKinney)
*/
AI.Yail.text={};AI.Yail.forBlock.text=function(d,e){return[AI.Yail.quote_(d.getFieldValue("TEXT")),AI.Yail.ORDER_ATOMIC]};
AI.Yail.forBlock.text_join=function(d,e){var h=AI.Yail.YAIL_CALL_YAIL_PRIMITIVE+"string-append"+AI.Yail.YAIL_SPACER;h=h+AI.Yail.YAIL_OPEN_COMBINATION+AI.Yail.YAIL_LIST_CONSTRUCTOR+AI.Yail.YAIL_SPACER;for(var k=0;k<d.itemCount_;k++){var m=e.valueToCode(d,"ADD"+k,AI.Yail.ORDER_NONE)||'""';h+=m+AI.Yail.YAIL_SPACER}h+=AI.Yail.YAIL_CLOSE_COMBINATION;h=h+AI.Yail.YAIL_SPACER+AI.Yail.YAIL_QUOTE+AI.Yail.YAIL_OPEN_COMBINATION;for(k=0;k<d.itemCount_;k++)h+="text"+AI.Yail.YAIL_SPACER;h+=AI.Yail.YAIL_CLOSE_COMBINATION+
AI.Yail.YAIL_SPACER;h=h+AI.Yail.YAIL_DOUBLE_QUOTE+"join"+AI.Yail.YAIL_DOUBLE_QUOTE+AI.Yail.YAIL_CLOSE_COMBINATION;return[h,AI.Yail.ORDER_ATOMIC]};
AI.Yail.forBlock.text_length=function(d,e){d=e.valueToCode(d,"VALUE",AI.Yail.ORDER_NONE)||'""';e=AI.Yail.YAIL_CALL_YAIL_PRIMITIVE+"string-length"+AI.Yail.YAIL_SPACER;e=e+AI.Yail.YAIL_OPEN_COMBINATION+AI.Yail.YAIL_LIST_CONSTRUCTOR+AI.Yail.YAIL_SPACER+d+AI.Yail.YAIL_CLOSE_COMBINATION;e=e+AI.Yail.YAIL_SPACER+AI.Yail.YAIL_QUOTE+AI.Yail.YAIL_OPEN_COMBINATION+"text"+AI.Yail.YAIL_CLOSE_COMBINATION+AI.Yail.YAIL_SPACER;e=e+AI.Yail.YAIL_DOUBLE_QUOTE+"length"+AI.Yail.YAIL_DOUBLE_QUOTE+AI.Yail.YAIL_CLOSE_COMBINATION;
return[e,AI.Yail.ORDER_ATOMIC]};
AI.Yail.forBlock.text_isEmpty=function(d,e){d=e.valueToCode(d,"VALUE",AI.Yail.ORDER_NONE)||'""';e=AI.Yail.YAIL_CALL_YAIL_PRIMITIVE+"string-empty?"+AI.Yail.YAIL_SPACER;e=e+AI.Yail.YAIL_OPEN_COMBINATION+AI.Yail.YAIL_LIST_CONSTRUCTOR+AI.Yail.YAIL_SPACER+d+AI.Yail.YAIL_CLOSE_COMBINATION;e=e+AI.Yail.YAIL_SPACER+AI.Yail.YAIL_QUOTE+AI.Yail.YAIL_OPEN_COMBINATION+"text"+AI.Yail.YAIL_CLOSE_COMBINATION+AI.Yail.YAIL_SPACER;e=e+AI.Yail.YAIL_DOUBLE_QUOTE+"is text empty?"+AI.Yail.YAIL_DOUBLE_QUOTE+AI.Yail.YAIL_CLOSE_COMBINATION;
return[e,AI.Yail.ORDER_ATOMIC]};
AI.Yail.forBlock.text_compare=function(d,e){var h=d.getFieldValue("OP"),k=AI.Yail.forBlock.text_compare.OPERATORS[h],m=k[0],p=k[1],t=k[2];k=e.valueToCode(d,"TEXT1",t)||'""';d=e.valueToCode(d,"TEXT2",t)||'""';m=AI.Yail.YAIL_CALL_YAIL_PRIMITIVE+m+AI.Yail.YAIL_SPACER;m=m+AI.Yail.YAIL_OPEN_COMBINATION+AI.Yail.YAIL_LIST_CONSTRUCTOR+AI.Yail.YAIL_SPACER+k+AI.Yail.YAIL_SPACER+d+AI.Yail.YAIL_CLOSE_COMBINATION;m=m+AI.Yail.YAIL_SPACER+AI.Yail.YAIL_QUOTE+AI.Yail.YAIL_OPEN_COMBINATION+"text text"+AI.Yail.YAIL_CLOSE_COMBINATION+
AI.Yail.YAIL_SPACER;m=m+AI.Yail.YAIL_DOUBLE_QUOTE+p+AI.Yail.YAIL_DOUBLE_QUOTE+AI.Yail.YAIL_CLOSE_COMBINATION;"NEQ"==h&&(m="(not "+m+")");return[m,AI.Yail.ORDER_ATOMIC]};AI.Yail.forBlock.text_compare.OPERATORS={LT:["string<?","text<",AI.Yail.ORDER_NONE],GT:["string>?","text>",AI.Yail.ORDER_NONE],EQUAL:["string=?","text=",AI.Yail.ORDER_NONE],NEQ:["string=?","not =",AI.Yail.ORDER_NONE]};
AI.Yail.forBlock.text_trim=function(d,e){d=e.valueToCode(d,"TEXT",AI.Yail.ORDER_NONE)||'""';e=AI.Yail.YAIL_CALL_YAIL_PRIMITIVE+"string-trim"+AI.Yail.YAIL_SPACER;e=e+AI.Yail.YAIL_OPEN_COMBINATION+AI.Yail.YAIL_LIST_CONSTRUCTOR+AI.Yail.YAIL_SPACER+d+AI.Yail.YAIL_CLOSE_COMBINATION;e=e+AI.Yail.YAIL_SPACER+AI.Yail.YAIL_QUOTE+AI.Yail.YAIL_OPEN_COMBINATION+"text"+AI.Yail.YAIL_CLOSE_COMBINATION+AI.Yail.YAIL_SPACER;e=e+AI.Yail.YAIL_DOUBLE_QUOTE+"trim"+AI.Yail.YAIL_DOUBLE_QUOTE+AI.Yail.YAIL_CLOSE_COMBINATION;
return[e,AI.Yail.ORDER_ATOMIC]};
AI.Yail.forBlock.text_changeCase=function(d,e){var h=d.getFieldValue("OP"),k=AI.Yail.forBlock.text_changeCase.OPERATORS[h],m=k[0];h=k[1];d=e.valueToCode(d,"TEXT",k[2])||'""';e=AI.Yail.YAIL_CALL_YAIL_PRIMITIVE+m+AI.Yail.YAIL_SPACER;e=e+AI.Yail.YAIL_OPEN_COMBINATION+AI.Yail.YAIL_LIST_CONSTRUCTOR+AI.Yail.YAIL_SPACER+d+AI.Yail.YAIL_CLOSE_COMBINATION;e=e+AI.Yail.YAIL_SPACER+AI.Yail.YAIL_QUOTE+AI.Yail.YAIL_OPEN_COMBINATION+"text"+AI.Yail.YAIL_CLOSE_COMBINATION+AI.Yail.YAIL_SPACER;e=e+AI.Yail.YAIL_DOUBLE_QUOTE+
h+AI.Yail.YAIL_DOUBLE_QUOTE+AI.Yail.YAIL_CLOSE_COMBINATION;return[e,AI.Yail.ORDER_ATOMIC]};AI.Yail.forBlock.text_changeCase.OPERATORS={UPCASE:["string-to-upper-case","upcase",AI.Yail.ORDER_NONE],DOWNCASE:["string-to-lower-case","downcase",AI.Yail.ORDER_NONE]};
AI.Yail.forBlock.text_starts_at=function(d,e){var h=e.valueToCode(d,"TEXT",AI.Yail.ORDER_NONE)||'""';d=e.valueToCode(d,"PIECE",AI.Yail.ORDER_NONE)||'""';e=AI.Yail.YAIL_CALL_YAIL_PRIMITIVE+"string-starts-at"+AI.Yail.YAIL_SPACER;e=e+AI.Yail.YAIL_OPEN_COMBINATION+AI.Yail.YAIL_LIST_CONSTRUCTOR+AI.Yail.YAIL_SPACER+h+AI.Yail.YAIL_SPACER+d+AI.Yail.YAIL_CLOSE_COMBINATION;e=e+AI.Yail.YAIL_SPACER+AI.Yail.YAIL_QUOTE+AI.Yail.YAIL_OPEN_COMBINATION+"text text"+AI.Yail.YAIL_CLOSE_COMBINATION+AI.Yail.YAIL_SPACER;
e=e+AI.Yail.YAIL_DOUBLE_QUOTE+"starts at"+AI.Yail.YAIL_DOUBLE_QUOTE+AI.Yail.YAIL_CLOSE_COMBINATION;return[e,AI.Yail.ORDER_ATOMIC]};
AI.Yail.forBlock.text_contains=function(d,e){var h=e.valueToCode(d,"TEXT",AI.Yail.ORDER_NONE)||'""';e=e.valueToCode(d,"PIECE",AI.Yail.ORDER_NONE)||'""';d=AI.Yail.forBlock.text_contains.OPERATORS[d.getMode()];var k=AI.Yail.YAIL_CALL_YAIL_PRIMITIVE+d.operator+AI.Yail.YAIL_SPACER;k+=AI.Yail.YAIL_OPEN_COMBINATION+AI.Yail.YAIL_LIST_CONSTRUCTOR+AI.Yail.YAIL_SPACER+h+AI.Yail.YAIL_SPACER+e+AI.Yail.YAIL_CLOSE_COMBINATION;k+=AI.Yail.YAIL_SPACER+AI.Yail.YAIL_QUOTE+AI.Yail.YAIL_OPEN_COMBINATION+"text "+d.type+
AI.Yail.YAIL_CLOSE_COMBINATION+AI.Yail.YAIL_SPACER;k+=AI.Yail.YAIL_DOUBLE_QUOTE+d.blockName+AI.Yail.YAIL_DOUBLE_QUOTE+AI.Yail.YAIL_CLOSE_COMBINATION;return[k,d.order]};
AI.Yail.forBlock.text_contains.OPERATORS={CONTAINS:{operator:"string-contains",blockName:"string contains",order:AI.Yail.ORDER_ATOMIC,type:"text"},CONTAINS_ANY:{operator:"string-contains-any",blockName:"string contains any",order:AI.Yail.ORDER_ATOMIC,type:"list"},CONTAINS_ALL:{operator:"string-contains-all",blockName:"string contains all",order:AI.Yail.ORDER_ATOMIC,type:"list"}};
AI.Yail.forBlock.text_split=function(d,e){var h=d.getFieldValue("OP"),k=AI.Yail.forBlock.text_split.OPERATORS[h],m=k[0];h=k[1];var p=k[2];k=k[3];var t=e.valueToCode(d,"TEXT",AI.Yail.ORDER_NONE)||'""';d=e.valueToCode(d,"AT",AI.Yail.ORDER_NONE)||1;e=AI.Yail.YAIL_CALL_YAIL_PRIMITIVE+m+AI.Yail.YAIL_SPACER;e=e+AI.Yail.YAIL_OPEN_COMBINATION+AI.Yail.YAIL_LIST_CONSTRUCTOR+AI.Yail.YAIL_SPACER+t+AI.Yail.YAIL_SPACER+d+AI.Yail.YAIL_CLOSE_COMBINATION;e=e+AI.Yail.YAIL_SPACER+AI.Yail.YAIL_QUOTE+AI.Yail.YAIL_OPEN_COMBINATION+
"text"+AI.Yail.YAIL_SPACER+k+AI.Yail.YAIL_CLOSE_COMBINATION+AI.Yail.YAIL_SPACER;e=e+AI.Yail.YAIL_DOUBLE_QUOTE+h+AI.Yail.YAIL_DOUBLE_QUOTE+AI.Yail.YAIL_CLOSE_COMBINATION;return[e,p]};
AI.Yail.forBlock.text_split.OPERATORS={SPLITATFIRST:["string-split-at-first","split at first",AI.Yail.ORDER_ATOMIC,"text"],SPLITATFIRSTOFANY:["string-split-at-first-of-any","split at first of any",AI.Yail.ORDER_ATOMIC,"list"],SPLIT:["string-split","split",AI.Yail.ORDER_ATOMIC,"text"],SPLITATANY:["string-split-at-any","split at any",AI.Yail.ORDER_ATOMIC,"list"]};
AI.Yail.forBlock.text_split_at_spaces=function(d,e){d=e.valueToCode(d,"TEXT",AI.Yail.ORDER_NONE)||'""';e=AI.Yail.YAIL_CALL_YAIL_PRIMITIVE+"string-split-at-spaces"+AI.Yail.YAIL_SPACER;e=e+AI.Yail.YAIL_OPEN_COMBINATION+AI.Yail.YAIL_LIST_CONSTRUCTOR+AI.Yail.YAIL_SPACER+d+AI.Yail.YAIL_CLOSE_COMBINATION;e=e+AI.Yail.YAIL_SPACER+AI.Yail.YAIL_QUOTE+AI.Yail.YAIL_OPEN_COMBINATION+"text"+AI.Yail.YAIL_CLOSE_COMBINATION+AI.Yail.YAIL_SPACER;e=e+AI.Yail.YAIL_DOUBLE_QUOTE+"split at spaces"+AI.Yail.YAIL_DOUBLE_QUOTE+
AI.Yail.YAIL_CLOSE_COMBINATION;return[e,AI.Yail.ORDER_ATOMIC]};
AI.Yail.forBlock.text_segment=function(d,e){var h=e.valueToCode(d,"TEXT",AI.Yail.ORDER_NONE)||'""',k=e.valueToCode(d,"START",AI.Yail.ORDER_NONE)||1;d=e.valueToCode(d,"LENGTH",AI.Yail.ORDER_NONE)||1;e=AI.Yail.YAIL_CALL_YAIL_PRIMITIVE+"string-substring"+AI.Yail.YAIL_SPACER;e=e+AI.Yail.YAIL_OPEN_COMBINATION+AI.Yail.YAIL_LIST_CONSTRUCTOR+AI.Yail.YAIL_SPACER+h+AI.Yail.YAIL_SPACER+k+AI.Yail.YAIL_SPACER+d+AI.Yail.YAIL_CLOSE_COMBINATION;e=e+AI.Yail.YAIL_SPACER+AI.Yail.YAIL_QUOTE+AI.Yail.YAIL_OPEN_COMBINATION+
"text number number"+AI.Yail.YAIL_CLOSE_COMBINATION+AI.Yail.YAIL_SPACER;e=e+AI.Yail.YAIL_DOUBLE_QUOTE+"segment"+AI.Yail.YAIL_DOUBLE_QUOTE+AI.Yail.YAIL_CLOSE_COMBINATION;return[e,AI.Yail.ORDER_ATOMIC]};
AI.Yail.forBlock.text_replace_all=function(d,e){var h=e.valueToCode(d,"TEXT",AI.Yail.ORDER_NONE)||'""',k=e.valueToCode(d,"SEGMENT",AI.Yail.ORDER_NONE)||'""';d=e.valueToCode(d,"REPLACEMENT",AI.Yail.ORDER_NONE)||'""';e=AI.Yail.YAIL_CALL_YAIL_PRIMITIVE+"string-replace-all"+AI.Yail.YAIL_SPACER;e=e+AI.Yail.YAIL_OPEN_COMBINATION+AI.Yail.YAIL_LIST_CONSTRUCTOR+AI.Yail.YAIL_SPACER+h+AI.Yail.YAIL_SPACER+k+AI.Yail.YAIL_SPACER+d+AI.Yail.YAIL_CLOSE_COMBINATION;e=e+AI.Yail.YAIL_SPACER+AI.Yail.YAIL_QUOTE+AI.Yail.YAIL_OPEN_COMBINATION+
"text text text"+AI.Yail.YAIL_CLOSE_COMBINATION+AI.Yail.YAIL_SPACER;e=e+AI.Yail.YAIL_DOUBLE_QUOTE+"replace all"+AI.Yail.YAIL_DOUBLE_QUOTE+AI.Yail.YAIL_CLOSE_COMBINATION;return[e,AI.Yail.ORDER_ATOMIC]};
AI.Yail.forBlock.obfuscated_text=function(d,e){var h=d.getFieldValue("TEXT");e=AI.Yail;for(var k=e.quote_,m=d.confounder,p=[];m.length<h.length;)m+=m;for(var t=0;t<h.length;t++){var q=(h.charCodeAt(t)^m.charCodeAt(t))&255;p.push(String.fromCharCode((((q>>8^t)&255)<<8|(q^h.length-t)&255)&255))}h=p.join("");e=k.call(e,h);k=AI.Yail.YAIL_CALL_YAIL_PRIMITIVE+"text-deobfuscate"+AI.Yail.YAIL_SPACER;k=k+AI.Yail.YAIL_OPEN_COMBINATION+AI.Yail.YAIL_LIST_CONSTRUCTOR+AI.Yail.YAIL_SPACER+e+AI.Yail.YAIL_SPACER+
AI.Yail.quote_(d.confounder)+AI.Yail.YAIL_CLOSE_COMBINATION;k=k+AI.Yail.YAIL_SPACER+AI.Yail.YAIL_QUOTE+AI.Yail.YAIL_OPEN_COMBINATION+"text text"+AI.Yail.YAIL_CLOSE_COMBINATION+AI.Yail.YAIL_SPACER;k=k+AI.Yail.YAIL_DOUBLE_QUOTE+"deobfuscate text"+AI.Yail.YAIL_DOUBLE_QUOTE+AI.Yail.YAIL_CLOSE_COMBINATION;return[k,AI.Yail.ORDER_ATOMIC]};
AI.Yail.forBlock.text_is_string=function(d,e){d=e.valueToCode(d,"ITEM",AI.Yail.ORDER_NONE)||AI.Yail.YAIL_FALSE;e=AI.Yail.YAIL_CALL_YAIL_PRIMITIVE+"string?"+AI.Yail.YAIL_SPACER;e=e+AI.Yail.YAIL_OPEN_COMBINATION+AI.Yail.YAIL_LIST_CONSTRUCTOR+AI.Yail.YAIL_SPACER;e=e+d+AI.Yail.YAIL_SPACER+AI.Yail.YAIL_CLOSE_COMBINATION;e=e+AI.Yail.YAIL_SPACER+AI.Yail.YAIL_QUOTE+AI.Yail.YAIL_OPEN_COMBINATION;e=e+"any"+AI.Yail.YAIL_CLOSE_COMBINATION+AI.Yail.YAIL_SPACER;e=e+AI.Yail.YAIL_DOUBLE_QUOTE+"is a string?"+AI.Yail.YAIL_DOUBLE_QUOTE+
AI.Yail.YAIL_CLOSE_COMBINATION;return[e,AI.Yail.ORDER_ATOMIC]};
AI.Yail.forBlock.text_reverse=function(d,e){d=e.valueToCode(d,"VALUE",AI.Yail.ORDER_NONE)||'""';e=AI.Yail.YAIL_CALL_YAIL_PRIMITIVE+"string-reverse"+AI.Yail.YAIL_SPACER;e=e+AI.Yail.YAIL_OPEN_COMBINATION+AI.Yail.YAIL_LIST_CONSTRUCTOR+AI.Yail.YAIL_SPACER+d+AI.Yail.YAIL_CLOSE_COMBINATION;e=e+AI.Yail.YAIL_SPACER+AI.Yail.YAIL_QUOTE+AI.Yail.YAIL_OPEN_COMBINATION+"text"+AI.Yail.YAIL_CLOSE_COMBINATION+AI.Yail.YAIL_SPACER;e=e+AI.Yail.YAIL_DOUBLE_QUOTE+"reverse"+AI.Yail.YAIL_DOUBLE_QUOTE+AI.Yail.YAIL_CLOSE_COMBINATION;
return[e,AI.Yail.ORDER_ATOMIC]};
AI.Yail.forBlock.text_replace_mappings=function(d,e){var h=e.valueToCode(d,"TEXT",AI.Yail.ORDER_NONE)||'""';e=e.valueToCode(d,"MAPPINGS",AI.Yail.ORDER_NONE)||'""';d=d.getFieldValue("OP");d=AI.Yail.YAIL_CALL_YAIL_PRIMITIVE+AI.Yail.forBlock.text_replace_mappings.OPERATORS[d]+AI.Yail.YAIL_SPACER;d=d+AI.Yail.YAIL_OPEN_COMBINATION+AI.Yail.YAIL_LIST_CONSTRUCTOR+AI.Yail.YAIL_SPACER;d=d+h+AI.Yail.YAIL_SPACER;d=d+e+AI.Yail.YAIL_CLOSE_COMBINATION;d=d+AI.Yail.YAIL_SPACER+AI.Yail.YAIL_QUOTE;d=d+AI.Yail.YAIL_OPEN_COMBINATION+
"text"+AI.Yail.YAIL_SPACER;d=d+"dictionary"+AI.Yail.YAIL_CLOSE_COMBINATION;d=d+AI.Yail.YAIL_SPACER+AI.Yail.YAIL_DOUBLE_QUOTE+"replace with mappings"+AI.Yail.YAIL_DOUBLE_QUOTE+AI.Yail.YAIL_CLOSE_COMBINATION;return[d,AI.Yail.ORDER_ATOMIC]};AI.Yail.forBlock.text_replace_mappings.OPERATORS={LONGEST_STRING_FIRST:"string-replace-mappings-longest-string",DICTIONARY_ORDER:"string-replace-mappings-dictionary"};/*

 @fileoverview variables blocks yail generators for Blockly, modified for MIT App Inventor.
 @author mckinney@mit.edu (Andrew F. McKinney)
*/
AI.Yail.variables={};AI.Yail.YAIL_GLOBAL_VAR_TAG="g$";AI.Yail.YAIL_LOCAL_VAR_TAG="$";AI.Yail.forBlock.global_declaration=function(d,e){var h=AI.Yail.YAIL_GLOBAL_VAR_TAG+d.getFieldValue("NAME");d=e.valueToCode(d,"VALUE",AI.Yail.ORDER_NONE)||"0";return AI.Yail.YAIL_DEFINE+h+AI.Yail.YAIL_SPACER+d+AI.Yail.YAIL_CLOSE_COMBINATION};
AI.Yail.forBlock.lexical_variable_get=function(d,e){e="";var h=d.getFieldValue("VAR");d.eventparam?h=d.eventparam:(Blockly.LexicalVariable.getEventParam(d),d.eventparam&&(h=d.eventparam));d=AI.Yail.getVariableCommandAndName(h);e+=d[0];h=d[1];e+=h+AI.Yail.YAIL_CLOSE_COMBINATION;return[e,AI.Yail.ORDER_ATOMIC]};
AI.Yail.forBlock.lexical_variable_set=function(d,e){e=e.valueToCode(d,"VALUE",AI.Yail.ORDER_NONE)||"0";var h="",k=d.getFieldValue("VAR");d.eventparam?k=d.eventparam:(Blockly.LexicalVariable.getEventParam(d),d.eventparam&&(k=d.eventparam));d=AI.Yail.setVariableCommandAndName(k);h+=d[0];k=d[1];return h+=k+AI.Yail.YAIL_SPACER+e+AI.Yail.YAIL_CLOSE_COMBINATION};
AI.Yail.getVariableCommandAndName=function(d){var e=Blockly.unprefixName(d);d=e[0];e=e[1];d===Blockly.Msg.LANG_VARIABLES_GLOBAL_PREFIX||d===Blockly.GLOBAL_KEYWORD?(d=AI.Yail.YAIL_GLOBAL_VAR_TAG+e,e=AI.Yail.YAIL_GET_VARIABLE):(d=AI.Yail.YAIL_LOCAL_VAR_TAG+Blockly.possiblyPrefixYailNameWith(d)(e),e=AI.Yail.YAIL_LEXICAL_VALUE);return[e,d]};
AI.Yail.setVariableCommandAndName=function(d){var e=Blockly.unprefixName(d);d=e[0];e=e[1];d===Blockly.Msg.LANG_VARIABLES_GLOBAL_PREFIX||d===Blockly.GLOBAL_KEYWORD?(d=AI.Yail.YAIL_GLOBAL_VAR_TAG+e,e=AI.Yail.YAIL_SET_VARIABLE):(d=AI.Yail.YAIL_LOCAL_VAR_TAG+Blockly.possiblyPrefixYailNameWith(d)(e),e=AI.Yail.YAIL_SET_LEXICAL_VALUE);return[e,d]};AI.Yail.forBlock.local_declaration_statement=function(d,e){return AI.Yail.local_variable(d,e,!1)};
AI.Yail.forBlock.local_declaration_expression=function(d,e){return AI.Yail.local_variable(d,e,!0)};
AI.Yail.local_variable=function(d,e,h){var k=AI.Yail.YAIL_LET;k+=AI.Yail.YAIL_OPEN_COMBINATION+AI.Yail.YAIL_SPACER;for(var m=0;d.getFieldValue("VAR"+m);m++)k+=AI.Yail.YAIL_OPEN_COMBINATION+AI.Yail.YAIL_LOCAL_VAR_TAG+(Blockly.usePrefixInYail?"local_":"")+d.getFieldValue("VAR"+m),k+=AI.Yail.YAIL_SPACER+(e.valueToCode(d,"DECL"+m,AI.Yail.ORDER_NONE)||"0"),k+=AI.Yail.YAIL_CLOSE_COMBINATION+AI.Yail.YAIL_SPACER;k+=AI.Yail.YAIL_SPACER+AI.Yail.YAIL_CLOSE_COMBINATION;h?k=d.getInputTargetBlock("RETURN")?k+(AI.Yail.YAIL_SPACER+
e.valueToCode(d,"RETURN",AI.Yail.ORDER_NONE)):k+(AI.Yail.YAIL_SPACER+"0"):(d=e.statementToCode(d,"STACK")||AI.Yail.YAIL_FALSE,k+=AI.Yail.YAIL_SPACER+d);k+=AI.Yail.YAIL_SPACER+AI.Yail.YAIL_CLOSE_COMBINATION;return h?[k,AI.Yail.ORDER_ATOMIC]:k};AI.Blockly.ReplMgr={};AI.Blockly.ReplStateObj={};void 0===Blockly.ReplMgr&&(Blockly.ReplMgr={});Blockly.ReplMgr.yail=null;top.usewebrtc=!1;top.loadAll=!0;top.loadAllErrorCount=0;Blockly.ReplMgr.rsState={IDLE:0,RENDEZVOUS:1,CONNECTED:2,WAITING:3,ASSET:4,EXTENSIONS:5};Blockly.ReplStateObj=function(){};
Blockly.ReplStateObj.prototype={state:Blockly.ReplMgr.rsState.IDLE,url:null,baseurl:null,replcode:null,rendezvouscode:null,dialog:null,count:0,didversioncheck:!1,isUSB:!1,rendezvous2:"https://rendezvous.appinventor.mit.edu/rendezvous2/",iceservers:{iceServers:[{urls:["turn:turn.appinventor.mit.edu:3478"],username:"oh",credential:"boy"}]},emulator:!1};
var PROTECT_ENUM_ANDROID="(define-syntax protect-enum   (lambda (x)     (syntax-case x ()       ((_ enum-value number-value)         (if (< com.google.appinventor.components.common.YaVersion:BLOCKS_LANGUAGE_VERSION 34)           #'number-value           #'enum-value)))))",PROTECT_ENUM_IOS="#f))(define-syntax protect-enum (syntax-rules () ((_ enum-value number-value) (if (equal? \"\" (yail:invoke (yail:invoke AIComponentKit.Form 'getActiveForm) 'VersionName)) number-value enum-value))))(begin (begin #f";
top.ReplState=new Blockly.ReplStateObj;top.ReplState.phoneState={};Blockly.ReplMgr.isConnected=function(){return top.ReplState.state===Blockly.ReplMgr.rsState.CONNECTED};
Blockly.ReplMgr.buildYail=function(d,e){function h(H){H.isGeneric?(N[H.typeName]||(N[H.typeName]={}),N[H.typeName][H.eventName]=!0):(da[H.instanceName]||(da[H.instanceName]={}),da[H.instanceName][H.eventName]=!0)}var k=[],m=!1;top.ReplState.phoneState||(top.ReplState.phoneState={});var p=top.ReplState.phoneState;if(p.formJson&&p.packageName){p.initialized||(p.initialized=!0,p.blockYail={},p.componentYail="");var t=p.nofqcn?function(H){H=H.split(".");return H[H.length-1]}:function(H){return H};var q=
JSON.parse(p.formJson);if(q.Properties){var y=q.Properties;var I=y.$Name}var L=Blockly.common.getMainWorkspace().buildComponentMap([],[],!1,!1),Q=[];if(y){"Screen1"!=I&&k.push(AI.Yail.getComponentRenameString("Screen1",I));q=q.Source;if("Form"==q)k=k.concat(AI.Yail.getComponentLines(I,y,null,L,!0,t,d.getComponentDatabase()));else throw"Source type "+q+" is invalid.";Q=AI.Yail.getDeepNames(y,Q);Q=Q.filter(function(H,K){return Q.indexOf(H)==K});k=k.join("\n");if(p.componentYail!=k||e)m=!0,p.blockYail=
{},this.putYail(AI.Yail.YAIL_CLEAR_FORM),this.putYail(AI.Yail.YAIL_SET_FORM_NAME_BEGIN+I+AI.Yail.YAIL_SET_FORM_NAME_END),this.putYail(k),this.putYail(AI.Yail.YAIL_INIT_RUNTIME),p.componentYail=k}d=Blockly.common.getMainWorkspace().getTopBlocks(!0);t=function(){this.block.replError&&(this.block.replError=null);this.block.workspace.getWarningHandler().checkAllBlocksForWarningsAndErrors()};y=function(H){this.block.replError=H;this.block.workspace.getWarningHandler().checkAllBlocksForWarningsAndErrors()};
var da={},N={};for(L=0;e=d[L];L++)if(e.disabled){if(k="component_event"==e.type)k=e.isGeneric&&N[e.typeName]&&N[e.typeName][e.eventName]?!0:!e.isGeneric&&da[e.instanceName]&&da[e.instanceName][e.eventName]?!0:!1,k=!k;k&&(k=AI.Yail.disabledEventBlockToCode(e),p.blockYail[e.id]!=k&&(this.putYail(k,e,t,y),p.blockYail[e.id]=k))}else!e.category||e.hasError&&!e.replError||"event"!=e.blockType&&"global_declaration"!=e.type&&"procedures_defnoreturn"!=e.type&&"procedures_defreturn"!=e.type||("component_event"==
e.type&&h(e),k=AI.Yail.blockToCode(e),p.blockYail[e.id]!=k&&(this.putYail(k,e,t,y),p.blockYail[e.id]=k));m&&this.putYail(AI.Yail.getComponentInitializationString(I,Q))}};Blockly.ReplMgr.sendFormData=function(d,e,h,k){top.ReplState.phoneState.formJson=d;top.ReplState.phoneState.packageName=e;var m=this;this.polltimer&&clearTimeout(this.polltimer);this.polltimer=setTimeout(function(){m.polltimer=null;return m.pollYail.call(m,h,k)},500)};
Blockly.ReplMgr.pollYail=function(d,e){var h=top.AssetManager_refreshAssets;if(void 0!==window){var k=this;top.ReplState.state==this.rsState.CONNECTED&&h(function(){top.ReplState.state==k.rsState.CONNECTED&&k.buildYail(d,e)})}};
Blockly.ReplMgr.resetYail=function(d){console.log("resetYail: partial = "+d);var e=top.ReplState;e.phoneState.initialized=!1;d||(this.putYail.reset(),top.ReplState.phoneState={phoneQueue:[],assetQueue:[]});e.proxy&&(window.removeEventListener("message",top.proxy_handler),e.proxy.close(),e.proxy=void 0)};
Blockly.ReplMgr.putYail=function(){var d,e,h,k,m=!1,p=!1,t=!1,q,y=!1,I=!1,L=!1,Q,da={},N={putYail:function(H,K,C,E){k=this;d=top.ReplState;void 0===H?N.pollphone():void 0===d||null===d?console.log("putYail: replState not set yet."):d.state!=Blockly.ReplMgr.rsState.CONNECTED&&d.state!=Blockly.ReplMgr.rsState.ASSET&&d.state!=Blockly.ReplMgr.rsState.EXTENSIONS?console.log("putYail: phone not connected"):(L||(H=(d.android?PROTECT_ENUM_ANDROID:PROTECT_ENUM_IOS)+H,L=!0),d.phoneState.phoneQueue||(d.phoneState.phoneQueue=
[]),d.phoneState.assetQueue||(d.phoneState.assetQueue=[]),d.phoneState.initialized=!0,d.phoneState.phoneQueue.push({code:Blockly.ReplMgr.quoteUnicode(H),success:C,failure:E,block:K}),N.pollphone())},putAsset:function(H,K,C,E){d=top.ReplState;void 0===d||null===d?console.log("putAsset: replState not set yet."):d.state!=Blockly.ReplMgr.rsState.CONNECTED&&d.state!=Blockly.ReplMgr.rsState.ASSET&&d.state!=Blockly.ReplMgr.rsState.EXTENSIONS?console.log("putAsset: phone not connected"):(d.phoneState.phoneQueue||
(d.phoneState.phoneQueue=[]),d.phoneState.assetQueue||(d.phoneState.assetQueue=[]),d.phoneState.initialized=!0,d.phoneState.assetQueue.push({code:Blockly.ReplMgr.quoteUnicode(H),success:C,failure:E,block:K}),N.pollphone())},webrtcstart:function(){var H=top.AssetManager_refreshAssets,K,C=d.replcode,E=!1,F="none",P=function(ea,aa){N.resetcompanion();if(ea)var W=new Blockly.Util.Dialog(Blockly.Msg.REPL_NETWORK_ERROR,aa,Blockly.Msg.REPL_OK,!1,null,0,function(){W.hide()})};I=y=!1;top.ConnectProgressBar_setProgress(20,
Blockly.Msg.DIALOG_SECURE_ESTABLISHING);var ha=function(){var ea=new XMLHttpRequest;ea.open("GET",top.ReplState.rendezvous2+C+"-r",!0);ea.onreadystatechange=function(){if(4==this.readyState&&200==this.status){if("["==this.response[0])for(var aa=JSON.parse(this.response),W=0;W<aa.length;W++){var ka=aa[W],Z=ka.candidate;K=ka.offer;Z&&E?(ka=ka.nonce,da[ka]?console.log("Seen nonce "+ka):(da[ka]=!0,console.log("addIceCandidate: signalingState = "+q.signalingState+" iceConnectionState = "+q.iceConnectionState),
console.log("addIceCandidate: candidate = "+JSON.stringify(Z)),q.addIceCandidate(Z)["catch"](function(ca){console.error(ca);P(!0,Blockly.Msg.REPL_WEBRTC_CONNECTION_ERROR+"\n"+ca)}))):K&&!E&&(E=!0,W=0,q.setRemoteDescription(K))}y||I||setTimeout(ha,1E3)}else 4==this.readyState&&P(!0,Blockly.Msg.REPL_WEBRTC_CONNECTION_ERROR+"\nRendezvous Fail: "+this.status)};ea.send()};q=new RTCPeerConnection(top.ReplState.iceservers);q.oniceconnectionstatechange=function(ea){var aa="undefined"!==typeof InstallTrigger;
console.log("oniceconnectionstatechange: evt.type = "+ea.type+" ice connection state = "+this.iceConnectionState);F=this.iceConnectionState;("disconnected"==F&&!aa||"failed"==F)&&P(!0,Blockly.Msg.REPL_WEBRTC_CONNECTION_CLOSED)};q.onsignalingstatechange=function(ea){console.log("onsignalingstatechange: evt.type = "+ea.type);console.log("onsignalingstatechange: signalingstate = "+this.signalingState)};q.onicecandidate=function(ea){if("icecandidate"==ea.type){var aa=new XMLHttpRequest;aa.open("POST",
top.ReplState.rendezvous2,!0);aa.send(JSON.stringify({key:C+"-s",webrtc:!0,nonce:Math.floor(1E4*Math.random())+1,candidate:ea.candidate}))}};Q=q.createDataChannel("data");Q.onopen=function(){y=!0;top.ConnectProgressBar_setProgress(30,Blockly.Msg.DIALOG_SECURE_ESTABLISHED);console.log("webrtc data connection open!");Q.onmessage=function(ea){console.log("webrtc(onmessage): "+ea.data);ea=JSON.parse(ea.data);"OK"==ea.status&&k.processRetvals(ea.values)};t=!0;top.webrtcdata=Q;d.dialog&&d.dialog.hide();
H(function(){Blockly.ReplMgr.loadExtensions()})};Q.onclose=function(){console.log("webrtc data closed");Q=null;t=p=!1;q.close();top.BlocklyPanel_indicateDisconnect()};Q.onerror=function(ea){console.log("webrtc data error: "+ea);Q=null;t=p=!1};q.createOffer().then(function(ea){var aa=ea.sdp;aa=aa.replace("a=extmap-allow-mixed\r\n","");ea.sdp=aa;K=ea;aa=new XMLHttpRequest;aa.open("POST",top.ReplState.rendezvous2,!0);aa.send(JSON.stringify({key:C+"-s",webrtc:!0,offer:ea}));q.setLocalDescription(ea)});
top.ConnectProgressBar_setProgress(15,Blockly.Msg.DIALOG_RENDEZVOUS_NEGOTIATING);setTimeout(function(){top.ConnectProgressBar_setProgress(20,Blockly.Msg.DIALOG_SECURE_ESTABLISHING);ha()},5E3)},chunker:function(){var H=0;return function(K){var C=K.length;if(15E3>=C)return[K];for(var E=[];0<C;)C=Math.min(C,15E3),E.push(K.substring(0,C)),K=K.substring(C),C=K.length;H+=1;var F="Q"+H;var P=[];P.push("(define "+F+' "")');E.forEach(function(ha,ea){ha=ha.replace(/\\/g,"\\\\");ha=ha.replace(/"/g,'\\"');P.push("(set! "+
F+" (string-append "+F+' "'+ha+'"))')});d.android?P.push("(eval (read (open-input-string "+F+")))"):P.push("(eval (read (open-input-string "+F+')) "yail")');P.push("(set! "+F+" #!null)");return P}}(),pollphone:function(){d.phoneState.assetQueue||(d.phoneState.assetQueue=[]);d.phoneState.phoneQueue||(d.phoneState.phoneQueue=[]);if(!d.phoneState.ioRunning){m||top.usewebrtc||N.receivefromphone();var H;if(top.usewebrtc)if(!t&&!p)p=!0,N.webrtcstart();else{if(t){for(;H=d.phoneState.assetQueue.shift();){var K=
H.block?'"'+H.block.id+'"':-1;K="(begin (require <com.google.youngandroid.runtime>) (process-repl-input "+K+" (begin "+H.code+")))";console.log(K);K=N.chunker(K);K.forEach(function(ha){console.log("Chunk: "+ha);Q.send(ha)})}if(d.state==Blockly.ReplMgr.rsState.CONNECTED)for(;H=d.phoneState.phoneQueue.shift();)K=H.block?'"'+H.block.id+'"':-1,K="(begin (require <com.google.youngandroid.runtime>) (process-repl-input "+K+" (begin "+H.code+")))",console.log(K),K=N.chunker(K),L||(Q.send(d.android?PROTECT_ENUM_ANDROID:
PROTECT_ENUM_IOS),L=!0),K.forEach(function(ha){console.log("Chunk: "+ha);Q.send(ha)})}}else{if(top.loadAll&&0==d.phoneState.assetQueue.length){for(var C="",E=!1,F,P=!0;K=d.phoneState.phoneQueue.shift();)P?P=!1:(console.log("We did chunk!"),E=!0),d.phoneState.ioRunning=!0,C+=K.code,F=K.block;if(!d.phoneState.ioRunning)return;H={code:C,block:null,chunking:!0};E?console.log("Chunk: "+C):(console.log("Slow Path: "+C),H.block=F)}else{(H=d.phoneState.assetQueue.shift())||(H=d.phoneState.phoneQueue.shift());
if(!H)return;d.phoneState.ioRunning=!0}K=H.block?'"'+H.block.id+'"':H.chunking?"-2":"-1";C=new URLSearchParams;console.log("Low Level Sending: "+H.code);C.append("mac",Blockly.ReplMgr.hmac(H.code+d.seq_count+K));C.append("seq",d.seq_count);C.append("code",H.code);C.append("blockid",K);K=C.toString();d.proxy?(d.proxy.postMessage(["blocks",K],d.proxy_origin),d.seq_count+=1,d.phoneState.ioRunning=!1,d.phoneState.initialized&&N.pollphone()):(e=new XMLHttpRequest,e.open("POST",d.url,!0),e.onreadystatechange=
function(){if(4==this.readyState&&200==this.status){var ha=JSON.parse(this.response);"OK"!=ha.status?H.failure&&H.failure(Blockly.Msg.REPL_ERROR_FROM_COMPANION):H.success&&H.success();k.processRetvals(ha.values);d.seq_count+=1;d.phoneState.initialized&&(d.phoneState.ioRunning=!1,N.pollphone())}else if(4==this.readyState){console.log("putYail(poller): status = "+this.status);H.failure&&H.failure(Blockly.Msg.REPL_NETWORK_CONNECTION_ERROR);var ea=new Blockly.Util.Dialog(Blockly.Msg.REPL_NETWORK_ERROR,
Blockly.Msg.REPL_NETWORK_ERROR_RESTART,Blockly.Msg.REPL_OK,!1,null,0,function(){ea.hide();k.hardreset(k.formName)});N.resetcompanion()}},e.send(K))}}},receivefromphone:function(){m=!0;console.log("receivefromphone called.");d.proxy||(h=new XMLHttpRequest,h.open("POST",d.rurl,!0),h.onreadystatechange=function(){if(4==this.readyState&&(console.log("receivefromphone returned."),200==this.status)){var H=JSON.parse(this.response);"OK"==H.status&&k.processRetvals(H.values);N.receivefromphone()}},h.send("IGNORED=STUFF"))},
reset:function(){L=!1;top.usewebrtc&&(Q&&Q.close(),q&&q.close(),I=!0,p=t=y=!1);h&&h.abort();h=null;top.usewebrtc=!1;if(d=top.ReplState)d.hasfetchassets=!1;m=!1},resetcompanion:function(){console.log("reseting companion");if(d=top.ReplState)d.state=Blockly.ReplMgr.rsState.IDLE,d.connection=null,d.extensionurl=void 0,k.resetYail(!1),d.didversioncheck=!1,d.android=!0,d.hasfetchassets=!1,d.emulator=!1,d.needsUpgradeHelper=!1,top.BlocklyPanel_indicateDisconnect(),top.ConnectProgressBar_hide(),N.reset()},
checkversionupgrade:function(H,K,C){C=C?null:Blockly.Msg.REPL_NOT_NOW;void 0===K&&(K="com.android.vending");if("com.android.vending"!=K&&top.COMPANION_UPDATE_URL&&!d.isUSB)var E=new Blockly.Util.Dialog(Blockly.Msg.REPL_COMPANION_VERSION_CHECK,Blockly.Msg.REPL_COMPANION_OUT_OF_DATE+("emulator"==d.replcode?Blockly.Msg.REPL_EMULATORS:Blockly.Msg.REPL_DEVICES)+Blockly.Msg.REPL_APPROVE_UPDATE,Blockly.Msg.REPL_OK,!1,C,0,function(F){E.hide();F!=Blockly.Msg.REPL_NOT_NOW?k.triggerUpdate():N.pollphone()});
else H?(E=new Blockly.Util.Dialog(Blockly.Msg.REPL_COMPANION_VERSION_CHECK,Blockly.Msg.REPL_COMPANION_OUT_OF_DATE1+top.PREFERRED_COMPANION+Blockly.Msg.REPL_COMPANION_OUT_OF_DATE2,Blockly.Msg.REPL_OK,!1,null,0,function(){E.hide()}),N.resetcompanion()):(E=new Blockly.Util.Dialog(Blockly.Msg.REPL_COMPANION_VERSION_CHECK,Blockly.Msg.REPL_COMPANION_OUT_OF_DATE_IMMEDIATE,Blockly.Msg.REPL_DISMISS,!1,null,1,function(){E.hide()}),N.pollphone())}};N.putYail.reset=N.reset;N.putYail.putAsset=N.putAsset;return N.putYail}();
Blockly.ReplMgr.triggerUpdate=function(){var d=top.ReplState,e=new XMLHttpRequest,h=new URLSearchParams,k=this,m=null,p=!1,t=function(L,Q){m&&!!L!=p&&(m.hide(),m=null);m?m.setContent(Q):L?(m=new Blockly.Util.Dialog(Blockly.Msg.REPL_SOFTWARE_UPDATE,Q,L,!1,null,0,function(){m.hide()}),p=!0):(m=new Blockly.Util.Dialog(Blockly.Msg.REPL_SOFTWARE_UPDATE,Q,null,!1,null,0,void 0),m.display(),p=!1)},q=function(){d.state=Blockly.ReplMgr.rsState.IDLE;d.connection=null;d.didversioncheck=!1;d.isUSB=!1;d.hasfetchassets=
!1;d.emulator=!1;d.needsUpgradeHelper=!1;k.resetYail(!1);top.BlocklyPanel_indicateDisconnect()},y=function(L){t(Blockly.Msg.REPL_OK_LOWER,L);q()};if(""===top.COMPANION_UPDATE_URL)t(Blockly.Msg.REPL_OK,Blockly.Msg.REPL_UPDATE_NO_UPDATE);else if(top.ReplState.state!=Blockly.ReplMgr.rsState.CONNECTED&&top.ReplState.state!=Blockly.ReplMgr.rsState.ASSET)t(Blockly.Msg.REPL_OK,Blockly.Msg.REPL_UPDATE_NO_CONNECTION);else if("emulator"!=top.ReplState.replcode||1==top.ReplState.isUSB)t(Blockly.Msg.REPL_OK,
Blockly.Msg.REPL_EMULATOR_ONLY);else if(top.usewebrtc)e='(AssetFetcher:upgradeCompanion "'+this.getCookie()+'" "'+top.COMPANION_UPDATE_URL+'")',console.log("CompanionUpgrade Yail = "+e),this.putYail.putAsset(e);else{h.append("package","update.apk");var I=h.toString();e.open("GET",top.COMPANION_UPDATE_EMULATOR_URL,!0);e.onreadystatechange=function(){if(4==this.readyState&&200==this.status)try{t(Blockly.Msg.REPL_GOT_IT,Blockly.Msg.REPL_UPDATE_INFO),Blockly.ReplMgr.putAsset(0,"update.apk",Array.from(atob(this.response),
L=>L.charCodeAt(0)),function(){console.log("Update: Downloaded");var L=new XMLHttpRequest;L.open("POST",d.baseurl+"_package",!0);L.onreadystatechange=function(){4==this.readyState&&200==this.status?(console.log("Update: _package success"),q()):4==this.readyState&&(console.log("Update: _package state = 4 probably ok (status = "+this.status+")"),q())};L.send(I)},function(){y(Blockly.Msg.REPL_UNABLE_TO_UPDATE)},!0)}catch(L){y(Blockly.Msg.REPL_UNABLE_TO_LOAD)}else 4==this.readyState&&y(Blockly.Msg.REPL_UNABLE_TO_LOAD_NO_RESPOND)};
t(!1,Blockly.Msg.REPL_NOW_DOWNLOADING);e.send()}};Blockly.ReplMgr.acceptablePackage=function(d){return d==top.ACCEPTABLE_COMPANION_PACKAGE?!0:!1};Blockly.ReplMgr.acceptableVersion=function(d){for(var e=0;e<top.ACCEPTABLE_COMPANIONS.length;e++)if(top.ACCEPTABLE_COMPANIONS[e]==d)return!0;return!1};
Blockly.ReplMgr.processRetvals=function(d){for(var e=top.ReplState,h,k=this,m=function(y){k.runtimeError&&(k.runtimeError.hide(),k.runtimeError=null);k.runtimeError=new Blockly.Util.Dialog(Blockly.Msg.REPL_RUNTIME_ERROR,y,Blockly.Msg.REPL_DISMISS,!1,null,1,function(){k.runtimeError.hide();k.runtimeError=null})},p=function(y){var I=document.createElement("div");y=document.createTextNode(y);I.appendChild(y);return I.innerHTML},t=0;t<d.length;t++){var q=d[t];console.log("processRetVals: "+JSON.stringify(q));
switch(q.type){case "return":"OK"==q.status&&0<top.loadAllErrorCount&&(console.log("Error Countdown: "+top.loadAllErrorCount),--top.loadAllErrorCount,0>=top.loadAllErrorCount&&(top.loadAllErrorCount=0,top.loadAll=!0,console.log("Reseting top.loadAll to true")));"-2"==q.blockid&&"OK"!=q.status?(top.loadAll=!1,top.loadAllErrorCount=Blockly.common.getMainWorkspace().getTopBlocks().length,console.log("Error in chunking, disabling."),this.resetYail(!0),this.pollYail(Blockly.common.getMainWorkspace())):
"-1"!=q.blockid&&"-2"!=q.blockid?(h=Blockly.common.getMainWorkspace().getBlockById(q.blockid),null!==h&&("OK"==q.status?(h.replError=null,q.value&&"*nothing*"!=q.value&&this.setDoitResult(h,q.value)):h.replError=q.value?Blockly.Msg.REPL_ERROR_FROM_COMPANION+": "+q.value:"Error from Companion")):"OK"!=q.status&&m(Blockly.Msg.REPL_ERROR_FROM_COMPANION+": "+q.value);break;case "pushScreen":top.BlocklyPanel_pushScreen(q.screen)||(console.log("processRetVals: Invalid Screen: "+q.screen),m("Invalid Screen: "+
q.screen));break;case "popScreen":top.BlocklyPanel_popScreen();break;case "assetTransferred":top.AssetManager_markAssetTransferred(q.value);break;case "extensionsLoaded":e.state=Blockly.ReplMgr.rsState.CONNECTED;Blockly.common.getMainWorkspace().fireChangeListener(new AI.Events.CompanionConnect);break;case "startCache":top.BlocklyPanel_startCache().then(y=>{y||m("Failed to cache project")}).catch(y=>{m("Encountered issue while caching project: "+y)});break;case "error":console.log("processRetVals: Error value = "+
q.value);m(p(q.value)+Blockly.Msg.REPL_NO_ERROR_FIVE_SECONDS);break;case "log":top.ConsolePanel_addLog(q.level,q.item),console.log("processRetVals: Log level = "+q.level),console.log("processRetVals: Log content = "+q.item)}}(d=Blockly.common.getMainWorkspace().getWarningHandler())&&d.checkAllBlocksForWarningsAndErrors()};
Blockly.ReplMgr.setDoitResult=function(d,e){var h=/Do It Result:.*?\n---\n/m,k=new RegExp(Blockly.Msg.DO_IT_RESULT+".*?\n---\n");e=Blockly.Msg.DO_IT_RESULT+" "+e+"\n---\n";var m="",p=d.getIcon(Blockly.icons.CommentIcon.TYPE);p&&(m=p.getText().replace(h,""));m=m?k.test(m)?m.replace(k,e):e+m:e;d.setCommentText(m);d.getIcon(Blockly.icons.CommentIcon.TYPE).setBubbleVisible(!0)};
Blockly.ReplMgr.startAdbDevice=function(d,e,h){var k=!0,m=this,p=0,t=0,q=0,y=null,I=null,L=null,Q;d=top.ReplState;h=e?Blockly.Msg.REPL_CONNECTING_USB_CABLE:Blockly.Msg.REPL_STARTING_EMULATOR;d.phoneState.initialized||(d.phoneState.initialized=!0,d.phoneState.blockYail={},d.phoneState.componentYail="");top.ReplState.android=!0;L=new Blockly.Util.Dialog(Blockly.Msg.REPL_CONNECTING,h,Blockly.Msg.REPL_CANCEL,!1,null,0,function(){L.hide();clearInterval(H);top.ReplState.state=Blockly.ReplMgr.rsState.IDLE;
top.BlocklyPanel_indicateDisconnect();y&&(y.hide(),y=null)});var da=function(){clearInterval(H);var K=Blockly.Msg.REPL_GIVE_UP;y=new Blockly.Util.Dialog(Blockly.Msg.REPL_CONNECTION_FAILURE1,Blockly.Msg.REPL_NO_START_EMULATOR,K,!1,Blockly.Msg.REPL_KEEP_TRYING,0,function(C){y.hide();y=null;C==K?(L&&(L.hide(),L=null),top.ReplState.state=Blockly.ReplMgr.rsState.IDLE,top.ReplState.connection=null,top.BlocklyPanel_indicateDisconnect(),m.resetYail(!1),m.hardreset(m.formName)):(t=0,p=10,q=2,H=setInterval(N,
1E3))})},N=function(){var K=top.AssetManager_refreshAssets;switch(q){case 0:var C=new XMLHttpRequest;C.onreadystatechange=function(){if(4==this.readyState&&200==this.status){var E=JSON.parse(this.response);"OK"==E.status?(Q=E.device,console.log("ReplMgr: set device = "+Q),q=1,p=e?6:21,I&&(I.hide(),I=null)):k&&!e?(E=new XMLHttpRequest,E.open("GET","http://localhost:8004/start/",!0),E.send(),k=!1):k&&(I=new Blockly.Util.Dialog(Blockly.Msg.REPL_PLUGGED_IN_Q,Blockly.Msg.REPL_AI_NO_SEE_DEVICE,Blockly.Msg.REPL_OK,
!1,null,0,function(){I.hide();I=null}),k=!1)}else 4==this.readyState&&(clearInterval(H),L&&(L.hide(),L=null),y||(top.BlocklyPanel_indicateDisconnect(),y=new Blockly.Util.Dialog(Blockly.Msg.REPL_HELPER_Q,Blockly.Msg.REPL_HELPER_NOT_RUNNING,Blockly.Msg.REPL_OK,!1,null,0,function(){y.hide();y=null;L&&(L.hide(),L=null);top.ReplState.state=Blockly.ReplMgr.rsState.IDLE})))};e?C.open("GET","http://localhost:8004/ucheck/",!0):C.open("GET","http://localhost:8004/echeck/",!0);C.send();break;case 1:--p;e?L.setContent(Blockly.Msg.REPL_USB_CONNECTED_WAIT+
p+Blockly.Msg.REPL_SECONDS_ENSURE_RUNNING):L.setContent(Blockly.Msg.REPL_EMULATOR_STARTED+p+Blockly.Msg.REPL_SECONDS_ENSURE_RUNNING);0>=p&&(e?L.setContent(Blockly.Msg.REPL_STARTING_COMPANION_ON_PHONE):L.setContent(Blockly.Msg.REPL_STARTING_COMPANION_IN_EMULATOR),q=2,p=10,t=0,C=new XMLHttpRequest,C.open("GET","http://localhost:8004/replstart/"+Q,!0),C.send());break;case 2:--p;0<p?L.setContent(Blockly.Msg.REPL_COMPANION_STARTED_WAITING+p+Blockly.Msg.REPL_SECONDS_ENSURE_RUNNING):(L.setContent(Blockly.Msg.REPL_VERIFYING_COMPANION),
C=new XMLHttpRequest,C.timeout=4E3,C.open("GET",d.versionurl,!0),C.onreadystatechange=function(){4==this.readyState&&(200==this.status?q=4:(t+=1,8<t?da():(C=new XMLHttpRequest,C.open("GET","http://localhost:8004/replstart/"+Q,!0),C.send(),p=10,q=2)))},C.send(),q=3);break;case 4:L.hide(),d.state=m.rsState.ASSET,clearInterval(H),K(function(){Blockly.ReplMgr.loadExtensions()})}};var H=setInterval(N,1E3)};
Blockly.ReplMgr.quoteUnicode=function(d){if(!d)return null;for(var e=[],h=d.length,k=0;k<h;k++){var m=d.charCodeAt(k);32>m||126<m?10==m?e.push(d.charAt(k)):(m="000"+m.toString(16),m=m.substring(m.length-4),e.push("\\u"+m)):e.push(d.charAt(k))}return e.join("")};
Blockly.ReplMgr.startRepl=function(d,e,h,k,m){var p=top.ReplState,t=this;p.didversioncheck=!1;p.isUSB=k;p.hasfetchassets=!1;p.phoneState&&(p.phoneState.initialized=!1);if(d){top.ReplState.state==this.rsState.RENDEZVOUS&&top.ReplState.dialog&&top.ReplState.dialog.hide();try{top.webrtcdata&&top.webrtcdata.send("#DONE#")}catch(q){console.log("webrtcdata: Error: "+q)}this.resetYail(!1);this.putYail.reset();top.ReplState.state=this.rsState.IDLE;this.hardreset(this.formName)}else top.ReplState.state==this.rsState.IDLE&&
(h||k||m?(this.startAdbDevice(p,k,m),m?(p.state=this.rsState.ASSET,top.AssetManager_refreshAssets(function(){Blockly.ReplMgr.loadExtensions()})):p.state=this.rsState.WAITING,p.replcode="emulator",p.url="http://127.0.0.1:8001/_newblocks",p.rurl="http://127.0.0.1:8001/_values",p.versionurl="http://127.0.0.1:8001/_getversion",p.baseurl="http://127.0.0.1:8001/",p.extensionurl=p.baseurl+"_extensions",p.seq_count=1,p.count=0):(p=top.ReplState,p.state=this.rsState.RENDEZVOUS,p.replcode=this.genCode(),e&&
window.open("intent://comp/"+p.replcode+"#Intent;scheme=aicompanion;package="+top.ACCEPTABLE_COMPANION_PACKAGE+";end"),p.rendezvouscode=this.sha1(p.replcode),p.seq_count=1,p.count=0,e||(p.dialog=new Blockly.Util.Dialog(Blockly.Msg.REPL_CONNECT_TO_COMPANION,this.makeDialogMessage(p.replcode),Blockly.Msg.REPL_CANCEL,!1,null,1,function(){p.dialog.hide();p.state=Blockly.ReplMgr.rsState.IDLE;p.connection=null;t.putYail.reset(!0);top.BlocklyPanel_indicateDisconnect()})),this.getFromRendezvous()))};
Blockly.ReplMgr.genCode=function(){for(var d="",e=0;6>e;e++)d+=String.fromCharCode(Math.floor(26*Math.random())+97);return d};
Blockly.ReplMgr.getFromRendezvous=function(){var d=this,e=new XMLHttpRequest;if(void 0===top.ReplState||null===top.ReplState)console.log("getFromRendezvous: replState not set yet.");else{var h=top.ReplState,k=this,m=function(){k.rendPoll.call(k)};e.open("GET","https://"+top.rendezvousServer+"/rendezvous/"+h.rendezvouscode,!0);e.onreadystatechange=function(){if(4==e.readyState&&200==this.status)try{if(e.response){h.dialog&&h.dialog.hide();var p=JSON.parse(e.response);h.url="http://"+p.ipaddr+":8001/_newblocks";
h.rurl="http://"+p.ipaddr+":8001/_values";h.versionurl="http://"+p.ipaddr+":8001/_getversion";h.baseurl="http://"+p.ipaddr+":8001/";h.android=!RegExp("^i(pad)?os$").test((p.os||"Android").toLowerCase());!h.android&&p.extensions&&(top.ALLOWED_IOS_EXTENSIONS=JSON.parse(p.extensions));if(!h.android&&Blockly.ReplMgr.hasDisallowedIosExtensions()){h.dialog.hide();top.ReplState.state=Blockly.ReplMgr.rsState.IDLE;top.BlocklyPanel_indicateDisconnect();h.connection=null;var t=new Blockly.Util.Dialog(Blockly.Msg.EXTENSIONS,
Blockly.Msg.EXTENSIONS_iOS,Blockly.Msg.REPL_CANCEL,!0,null,0,function(){t.hide()})}else{top.ConnectProgressBar_start();top.ConnectProgressBar_setProgress(10,Blockly.Msg.DIALOG_FOUND_COMPANION);h.didversioncheck=!0;h.webrtc="true"===p.webrtc;h.useproxy="true"===p.useproxy;h.hasfetchassets=h.android||h.webrtc;p.rendezvous2&&(h.rendezvous2=p.rendezvous2);if(p.iceservers){for(var q=[],y=0;y<p.iceservers.length;y++)q.push({urls:[p.iceservers[y].server],username:p.iceservers[y].username,credential:p.iceservers[y].password});
h.iceservers={iceServers:q}}h.version=p.version;h.installer=p.installer;d.rendezvousDone()}}else console.log("getFromRendezvous(): No answer yet!"),setTimeout(m,2E3)}catch(I){console.log("getFromRendezvous(): Error: "+I),setTimeout(m,2E3)}};e.send()}};Blockly.ReplMgr.hasDisallowedIosExtensions=function(){for(var d=top.AssetManager_getExtensions(),e=0;e<d.length;e++)if(-1==top.ALLOWED_IOS_EXTENSIONS.indexOf(d[e]))return!0;return!1};
Blockly.ReplMgr.rendezvousDone=function(){var d=this,e=top.ReplState,h=top.AssetManager_refreshAssets,k=e.webrtc,m=e.useproxy,p=new Promise(function(y,I){if(!e.version||e.android&&!Blockly.ReplMgr.acceptableVersion(e.version))var L=top.COMPANION_UPDATE_URL1&&!e.isUSB?new Blockly.Util.Dialog(Blockly.Msg.REPL_COMPANION_VERSION_CHECK,Blockly.Msg.REPL_COMPANION_OUT_OF_DATE2+"<br/>"+Blockly.ReplMgr.makeqrcode(top.location.origin+top.COMPANION_UPDATE_URL1),Blockly.Msg.REPL_OK,!1,Blockly.Msg.REPL_NOT_NOW,
0,function(Q){L.hide();Q==Blockly.Msg.REPL_NOT_NOW?y():(top.ReplState.state=Blockly.ReplMgr.rsState.IDLE,top.BlocklyPanel_indicateDisconnect(),top.ConnectProgressBar_hide(),I())}):new Blockly.Util.Dialog(Blockly.Msg.REPL_COMPANION_VERSION_CHECK,Blockly.Msg.REPL_COMPANION_OUT_OF_DATE1+" "+top.PREFERRED_COMPANION,Blockly.Msg.REPL_OK,!1,null,0,function(Q){L.hide();y()});else y()}),t=function(){e.proxy_ready=!1;d.putYail();(new Promise(function(y,I){e.proxy=window.open(e.baseurl+"_proxy","popup","popup,width=600,height=500,top="+
(screen.height/2-250)+",left="+(screen.width/2-300)+",scrollbars=no,toolbar=no,menubar=no");if(e.proxy)setTimeout(function(){e.proxy.blur();window.focus()},3E3),y();else var L=new Blockly.Util.Dialog(Blockly.Msg.REPL_POPUP_TITLE,Blockly.Msg.REPL_POPUP_MESSAGE,Blockly.Msg.REPL_POPUP_CONTINUE,!1,null,0,function(){L.hide();I()})})).then(function(){top.proxy=e.proxy;top.proxy_handler=function(y){var I=y.data;"OK"==I.status?d.processRetvals(I.values):"EXTENSIONS_LOADED"==I.status?(e.state=Blockly.ReplMgr.rsState.CONNECTED,
Blockly.common.getMainWorkspace().fireChangeListener(new AI.Events.CompanionConnect)):"hello"==I.status&&(e.proxy_origin=y.origin,e.proxy_ready=!0,console.log("rs.proxy: Received Hello"),e.state=Blockly.ReplMgr.rsState.ASSET,h(function(){Blockly.ReplMgr.loadExtensions()}))};window.addEventListener("message",top.proxy_handler)},function(){t()})},q=function(){d.putYail();if("https:"===window.location.protocol){e.state=Blockly.ReplMgr.rsState.IDLE;e.connection=null;e.didversioncheck=!1;e.isUSB=!1;e.hasfetchassets=
!1;d.resetYail(!1);top.BlocklyPanel_indicateDisconnect();top.ConnectProgressBar_hide();var y=new Blockly.Util.Dialog(Blockly.REPL_CONNECTION_FAILURE1,Blockly.Msg.REPL_NO_LEGACY,Blockly.Msg.REPL_OK,!1,null,0,function(){y.hide()})}else e.state=Blockly.ReplMgr.rsState.ASSET,h(function(){Blockly.ReplMgr.loadExtensions()})};e.initialized||(e.assetQueue||(e.assetQueue=[]),e.phoneQueue||(e.phoneQueue=[]),e.initialized=!0);p.then(function(){k?(top.usewebrtc=!0,e.state=d.rsState.ASSET,d.putYail()):m?t():q()},
function(){})};Blockly.ReplMgr.resendAssetsAndExtensions=function(){var d=top.AssetManager_refreshAssets;top.ReplState.state=Blockly.ReplMgr.rsState.ASSET;d(function(){Blockly.ReplMgr.loadExtensions()})};
Blockly.ReplMgr.loadExtensions=function(){var d=top.ReplState;if(d.hasfetchassets){d.state=Blockly.ReplMgr.rsState.EXTENSIONS;var e=JSON.stringify(top.AssetManager_getExtensions());e=AI.Yail.quotifyForREPL(e);e="(AssetFetcher:loadExtensions "+e+")";console.log("Blockly.ReplMgr.loadExtensions: Yail = "+e);this.putYail.putAsset(e)}else if(d.extensionurl){d.state=Blockly.ReplMgr.rsState.EXTENSIONS;var h=new XMLHttpRequest;e=new URLSearchParams;e.append("extensions",JSON.stringify(top.AssetManager_getExtensions()));
h.open("POST",d.extensionurl,!0);h.onreadystatechange=function(){4!==h.readyState||200!==this.status&&404!==this.status&&this.status?4===h.readyState&&(d.state=Blockly.ReplMgr.rsState.IDLE,top.BlocklyPanel_indicateDisconnect()):(d.state=Blockly.ReplMgr.rsState.CONNECTED,Blockly.common.getMainWorkspace().fireChangeListener(new AI.Events.CompanionConnect))};h.send(e.toString())}else d.state=Blockly.ReplMgr.rsState.CONNECTED,Blockly.common.getMainWorkspace().fireChangeListener(new AI.Events.CompanionConnect)};
Blockly.ReplMgr.rendPoll=function(){if(top.ReplState.state==this.rsState.RENDEZVOUS){top.ReplState.count+=1;if(40<top.ReplState.count){top.ReplState.state=this.rsState.IDLE;top.ReplState.dialog&&top.ReplState.dialog.hide();var d=new Blockly.Util.Dialog(Blockly.Msg.REPL_CONNECTION_FAILURE1,Blockly.Msg.REPL_TRY_AGAIN1,Blockly.Msg.REPL_OK,!1,null,0,function(){d.hide()});top.ReplState.url=null;top.BlocklyPanel_indicateDisconnect()}this.getFromRendezvous()}};
Blockly.ReplMgr.makeDialogMessage=function(d){var e=top.includeQRcode?top.rendezvousServer+";"+d:d;var h=this.qrcode(2,"L");h.addData(e);try{h.make()}catch(k){console.log("makeDialog: Using qrcode 4"),h=this.qrcode(4,"L"),h.addData(e),h.make()}e=h.createImgTag(6);h="<table>\n"+Blockly.Msg.REPL_CODE_PREAMBLE;h+="<tr><td>"+e+'</td><td><font size="+1">'+Blockly.Msg.REPL_YOUR_CODE_IS+':<br /><br /><font size="+1"><b>'+d+"</b></font></font></td></tr>";"https:"===window.location.protocol&&(h+="<tr><td colspan=2>"+
Blockly.Msg.REPL_SECURE_CONNECTION+' <a href="https://appinventor.mit.edu/ai2/aboutsecurity" target="_blank">'+Blockly.Msg.REPL_MORE_INFORMATION+"</a>.</td></tr>");return h+"</table>"};Blockly.ReplMgr.hmac=function(d){var e=new goog.crypt.Hmac(new goog.crypt.Sha1,this.string_to_bytes(top.ReplState.replcode),64);return this.bytes_to_hexstring(e.getHmac(this.string_to_bytes(d)))};Blockly.ReplMgr.sha1=function(d){var e=new goog.crypt.Sha1;e.update(this.string_to_bytes(d));return this.bytes_to_hexstring(e.digest())};
Blockly.ReplMgr.string_to_bytes=function(d){for(var e=[],h=0;h<d.length;h++)e.push(d.charCodeAt(h));return e};Blockly.ReplMgr.bytes_to_hexstring=function(d){for(var e=[],h=0;h<d.length;h++)e.push(Number(256+d[h]).toString(16).substring(1,3));return e.join("")};Blockly.ReplMgr.getCookie=function(){var d=/AppInventor *=([^;]+)/;d.test(document.cookie)?d=d.exec(document.cookie)[1]:(console.log("Cannot obtain cookie for putAsset!"),d=null);return d};
Blockly.ReplMgr.connectCache=function(d,e){if(void 0===top.ReplState||top.ReplState.state!=this.rsState.ASSET&&top.ReplState.state!=this.rsState.CONNECTED)return!1;var h=window.location.origin,k=this.getCookie();console.log("connectCache uri = "+h+" cookie = "+k);d='(AssetFetcher:fetchCachedProject "'+k+'" "'+d+'" "'+h+'" "'+e+'")';console.log("Yail for connectCache = "+d);this.putYail();this.putYail.putAsset(d);return!0};
Blockly.ReplMgr.putAsset=function(d,e,h,k,m,p){if(void 0===top.ReplState||!p&&top.ReplState.state!=this.rsState.ASSET&&top.ReplState.state!=this.rsState.CONNECTED)return!1;if(!p&&top.ReplState.hasfetchassets)return h=window.location.origin,p=this.getCookie(),console.log("putAsset uri = "+h+" cookie = "+p),e='(AssetFetcher:fetchAssets "'+p+'" "'+d+'" "'+h+'" "'+e+'")',console.log("Yail for putAsset = "+e),this.putYail(),this.putYail.putAsset(e),!0;d=new XMLHttpRequest;var t=new ArrayBuffer(h.length);
d=new Uint8Array(t);for(p=0;p<h.length;p++)d[p]=h[p];var q=top.ReplState,y=new URLSearchParams;e=e.slice(e.indexOf("/")+1,e.length);y.append("filename",e);q.proxy?(q.proxy.postMessage(["asset",y.toString(),t],q.proxy_origin),k()):(d=new XMLHttpRequest,d.retries=3,d.open("PUT",q.baseurl+"?"+y.toString(),!0),d.onreadystatechange=function(){4==this.readyState&&200==this.status?k&&k():4==this.readyState&&(0<this.retries&&(this.retries--,this.open("PUT",q.baseurl+"?"+y.toString(),!0),this.send(t)),m&&
m())},d.send(t));return!0};Blockly.ReplMgr.hardreset=function(d,e){top.AssetManager_reset(d);d=new XMLHttpRequest;d.open("GET","http://localhost:8004/reset/",!0);d.onreadystatechange=function(){4==this.readyState&&e&&e(this.status)};d.send()};
Blockly.ReplMgr.ehardreset=function(d){var e=this,h=new Blockly.Util.Dialog(Blockly.Msg.REPL_DO_YOU_REALLY_Q,Blockly.Msg.REPL_FACTORY_RESET,Blockly.Msg.REPL_RESET,!0,Blockly.Msg.REPL_CANCEL,0,function(k){h.hide();k==Blockly.Msg.REPL_RESET&&e.hardreset(d,function(){var m=new XMLHttpRequest;m.open("GET","http://localhost:8004/emulatorreset/",!0);m.onreadystatchange=function(){};m.send()})})};
Blockly.ReplMgr.makeqrcode=function(d){var e=this.qrcode(4,"L");e.addData(d);try{e.make()}catch(h){e=this.qrcode(6,"L"),e.addData(d),e.make()}return e.createImgTag(4)};
Blockly.ReplMgr.qrcode=function(){function d(N,H){if("undefined"==typeof N.length)throw Error(N.length+"/"+H);var K=function(){for(var E=0;E<N.length&&0===N[E];)E+=1;for(var F=Array(N.length-E+H),P=0;P<N.length-E;P+=1)F[P]=N[P+E];return F}(),C={get:function(E){return K[E]},getLength:function(){return K.length},multiply:function(E){for(var F=Array(C.getLength()+E.getLength()-1),P=0;P<C.getLength();P+=1)for(var ha=0;ha<E.getLength();ha+=1)F[P+ha]^=m.gexp(m.glog(C.get(P))+m.glog(E.get(ha)));return d(F,
0)},mod:function(E){var F;if(0>C.getLength()-E.getLength())return C;var P=m.glog(C.get(0))-m.glog(E.get(0)),ha=Array(C.getLength());for(F=0;F<C.getLength();F+=1)ha[F]=C.get(F);for(F=0;F<E.getLength();F+=1)ha[F]^=m.gexp(m.glog(E.get(F))+P);return d(ha,0).mod(E)}};return C}var e=function(N,H){var K=h[H],C=null,E=0,F=null,P=[],ha={},ea=function(W,ka){for(var Z=E=4*N+17,ca=Array(Z),ia=0;ia<Z;ia+=1){ca[ia]=Array(Z);for(var Da=0;Da<Z;Da+=1)ca[ia][Da]=null}C=ca;aa(0,0);aa(E-7,0);aa(0,E-7);Z=k.getPatternPosition(N);
for(ca=0;ca<Z.length;ca+=1)for(ia=0;ia<Z.length;ia+=1){Da=Z[ca];var la=Z[ia];if(null===C[Da][la])for(var ua=-2;2>=ua;ua+=1)for(var va=-2;2>=va;va+=1)C[Da+ua][la+va]=-2==ua||2==ua||-2==va||2==va||0===ua&&0===va?!0:!1}for(Z=8;Z<E-8;Z+=1)null===C[Z][6]&&(C[Z][6]=0===Z%2);for(Z=8;Z<E-8;Z+=1)null===C[6][Z]&&(C[6][Z]=0===Z%2);Z=k.getBCHTypeInfo(K<<3|ka);for(ca=0;15>ca;ca+=1)ia=!W&&1==(Z>>ca&1),6>ca?C[ca][8]=ia:8>ca?C[ca+1][8]=ia:C[E-15+ca][8]=ia;for(ca=0;15>ca;ca+=1)ia=!W&&1==(Z>>ca&1),8>ca?C[8][E-ca-1]=
ia:9>ca?C[8][15-ca-1+1]=ia:C[8][15-ca-1]=ia;C[E-8][8]=!W;if(7<=N){Z=k.getBCHTypeNumber(N);for(ca=0;18>ca;ca+=1)ia=!W&&1==(Z>>ca&1),C[Math.floor(ca/3)][ca%3+E-8-3]=ia;for(ca=0;18>ca;ca+=1)ia=!W&&1==(Z>>ca&1),C[ca%3+E-8-3][Math.floor(ca/3)]=ia}if(null===F){W=p.getRSBlocks(N,K);Z=t();for(ca=0;ca<P.length;ca+=1)ia=P[ca],Z.put(ia.getMode(),4),Z.put(ia.getLength(),k.getLengthInBits(ia.getMode(),N)),ia.write(Z);for(ca=ia=0;ca<W.length;ca+=1)ia+=W[ca].dataCount;if(Z.getLengthInBits()>8*ia)throw Error("code length overflow. ("+
Z.getLengthInBits()+">"+8*ia+")");for(Z.getLengthInBits()+4<=8*ia&&Z.put(0,4);0!==Z.getLengthInBits()%8;)Z.putBit(!1);for(;!(Z.getLengthInBits()>=8*ia);){Z.put(236,8);if(Z.getLengthInBits()>=8*ia)break;Z.put(17,8)}var u=0;ia=ca=0;Da=Array(W.length);la=Array(W.length);for(va=0;va<W.length;va+=1){var w=W[va].dataCount,z=W[va].totalCount-w;ca=Math.max(ca,w);ia=Math.max(ia,z);Da[va]=Array(w);for(ua=0;ua<Da[va].length;ua+=1)Da[va][ua]=255&Z.getBuffer()[ua+u];u+=w;ua=k.getErrorCorrectPolynomial(z);w=d(Da[va],
ua.getLength()-1).mod(ua);la[va]=Array(ua.getLength()-1);for(ua=0;ua<la[va].length;ua+=1)z=ua+w.getLength()-la[va].length,la[va][ua]=0<=z?w.get(z):0}for(ua=Z=0;ua<W.length;ua+=1)Z+=W[ua].totalCount;Z=Array(Z);for(ua=u=0;ua<ca;ua+=1)for(va=0;va<W.length;va+=1)ua<Da[va].length&&(Z[u]=Da[va][ua],u+=1);for(ua=0;ua<ia;ua+=1)for(va=0;va<W.length;va+=1)ua<la[va].length&&(Z[u]=la[va][ua],u+=1);F=Z}W=F;Z=-1;ca=E-1;ia=7;Da=0;ka=k.getMaskFunction(ka);for(la=E-1;0<la;la-=2)for(6==la&&--la;;){for(ua=0;2>ua;ua+=
1)null===C[ca][la-ua]&&(va=!1,Da<W.length&&(va=1==(W[Da]>>>ia&1)),ka(ca,la-ua)&&(va=!va),C[ca][la-ua]=va,--ia,-1==ia&&(Da+=1,ia=7));ca+=Z;if(0>ca||E<=ca){ca-=Z;Z=-Z;break}}},aa=function(W,ka){for(var Z=-1;7>=Z;Z+=1)if(!(-1>=W+Z||E<=W+Z))for(var ca=-1;7>=ca;ca+=1)-1>=ka+ca||E<=ka+ca||(C[W+Z][ka+ca]=0<=Z&&6>=Z&&(0===ca||6==ca)||0<=ca&&6>=ca&&(0===Z||6==Z)||2<=Z&&4>=Z&&2<=ca&&4>=ca?!0:!1)};ha.addData=function(W){W=q(W);P.push(W);F=null};ha.isDark=function(W,ka){if(0>W||E<=W||0>ka||E<=ka)throw Error(W+
","+ka);return C[W][ka]};ha.getModuleCount=function(){return E};ha.make=function(){for(var W=0,ka=0,Z=0;8>Z;Z+=1){ea(!0,Z);var ca=k.getLostPoint(ha);if(0===Z||W>ca)W=ca,ka=Z}ea(!1,ka)};ha.createTableTag=function(W,ka){W=W||2;ka='<table style=" border-width: 0px; border-style: none; border-collapse: collapse; padding: 0px; margin: '+(("undefined"==typeof ka?4*W:ka)+'px;"><tbody>');for(var Z=0;Z<ha.getModuleCount();Z+=1){ka+="<tr>";for(var ca=0;ca<ha.getModuleCount();ca+=1)ka+='<td style="',ka+=" border-width: 0px; border-style: none;",
ka+=" border-collapse: collapse;",ka+=" padding: 0px; margin: 0px;",ka+=" width: "+W+"px;",ka+=" height: "+W+"px;",ka+=" background-color: ",ka+=ha.isDark(Z,ca)?"#000000":"#ffffff",ka+=";",ka+='"/>';ka+="</tr>"}return ka+"</tbody></table>"};ha.createImgTag=function(W,ka){W=W||2;ka="undefined"==typeof ka?4*W:ka;var Z=ha.getModuleCount()*W+2*ka,ca=ka,ia=Z-ka;return da(Z,Z,function(Da,la){return ca<=Da&&Da<ia&&ca<=la&&la<ia?ha.isDark(Math.floor((la-ca)/W),Math.floor((Da-ca)/W))?0:1:1})};return ha};e.stringToBytes=
function(N){for(var H=[],K=0;K<N.length;K+=1){var C=N.charCodeAt(K);H.push(C&255)}return H};e.createStringToBytes=function(N,H){var K=function(){for(var C=L(N),E=function(){var ka=C.read();if(-1==ka)throw Error();return ka},F=0,P={};;){var ha=C.read();if(-1==ha)break;var ea=E(),aa=E(),W=E();ha=String.fromCharCode(ha<<8|ea);P[ha]=aa<<8|W;F+=1}if(F!=H)throw Error(F+" != "+H);return P}();return function(C){for(var E=[],F=0;F<C.length;F+=1){var P=C.charCodeAt(F);128>P?E.push(P):(P=K[C.charAt(F)],"number"==
typeof P?(P&255)==P?E.push(P):(E.push(P>>>8),E.push(P&255)):E.push(63))}return E}};var h={L:1,M:0,Q:3,H:2},k=function(){var N=[[],[6,18],[6,22],[6,26],[6,30],[6,34],[6,22,38],[6,24,42],[6,26,46],[6,28,50],[6,30,54],[6,32,58],[6,34,62],[6,26,46,66],[6,26,48,70],[6,26,50,74],[6,30,54,78],[6,30,56,82],[6,30,58,86],[6,34,62,90],[6,28,50,72,94],[6,26,50,74,98],[6,30,54,78,102],[6,28,54,80,106],[6,32,58,84,110],[6,30,58,86,114],[6,34,62,90,118],[6,26,50,74,98,122],[6,30,54,78,102,126],[6,26,52,78,104,130],
[6,30,56,82,108,134],[6,34,60,86,112,138],[6,30,58,86,114,142],[6,34,62,90,118,146],[6,30,54,78,102,126,150],[6,24,50,76,102,128,154],[6,28,54,80,106,132,158],[6,32,58,84,110,136,162],[6,26,54,82,110,138,166],[6,30,58,86,114,142,170]],H={},K=function(C){for(var E=0;0!==C;)E+=1,C>>>=1;return E};H.getBCHTypeInfo=function(C){for(var E=C<<10;0<=K(E)-K(1335);)E^=1335<<K(E)-K(1335);return(C<<10|E)^21522};H.getBCHTypeNumber=function(C){for(var E=C<<12;0<=K(E)-K(7973);)E^=7973<<K(E)-K(7973);return C<<12|
E};H.getPatternPosition=function(C){return N[C-1]};H.getMaskFunction=function(C){switch(C){case 0:return function(E,F){return 0===(E+F)%2};case 1:return function(E,F){return 0===E%2};case 2:return function(E,F){return 0===F%3};case 3:return function(E,F){return 0===(E+F)%3};case 4:return function(E,F){return 0===(Math.floor(E/2)+Math.floor(F/3))%2};case 5:return function(E,F){return 0===E*F%2+E*F%3};case 6:return function(E,F){return 0===(E*F%2+E*F%3)%2};case 7:return function(E,F){return 0===(E*
F%3+(E+F)%2)%2};default:throw Error("bad maskPattern:"+C);}};H.getErrorCorrectPolynomial=function(C){for(var E=d([1],0),F=0;F<C;F+=1)E=E.multiply(d([1,m.gexp(F)],0));return E};H.getLengthInBits=function(C,E){if(1<=E&&10>E)switch(C){case 1:return 10;case 2:return 9;case 4:return 8;case 8:return 8;default:throw Error("mode:"+C);}else if(27>E)switch(C){case 1:return 12;case 2:return 11;case 4:return 16;case 8:return 10;default:throw Error("mode:"+C);}else if(41>E)switch(C){case 1:return 14;case 2:return 13;
case 4:return 16;case 8:return 12;default:throw Error("mode:"+C);}else throw Error("type:"+E);};H.getLostPoint=function(C){var E=C.getModuleCount(),F,P,ha=0;for(F=0;F<E;F+=1)for(P=0;P<E;P+=1){for(var ea=0,aa=C.isDark(F,P),W=-1;1>=W;W+=1)if(!(0>F+W||E<=F+W))for(var ka=-1;1>=ka;ka+=1)0>P+ka||E<=P+ka||(0!==W||0!==ka)&&aa==C.isDark(F+W,P+ka)&&(ea+=1);5<ea&&(ha+=3+ea-5)}for(F=0;F<E-1;F+=1)for(P=0;P<E-1;P+=1)if(ea=0,C.isDark(F,P)&&(ea+=1),C.isDark(F+1,P)&&(ea+=1),C.isDark(F,P+1)&&(ea+=1),C.isDark(F+1,P+
1)&&(ea+=1),0===ea||4==ea)ha+=3;for(F=0;F<E;F+=1)for(P=0;P<E-6;P+=1)C.isDark(F,P)&&!C.isDark(F,P+1)&&C.isDark(F,P+2)&&C.isDark(F,P+3)&&C.isDark(F,P+4)&&!C.isDark(F,P+5)&&C.isDark(F,P+6)&&(ha+=40);for(P=0;P<E;P+=1)for(F=0;F<E-6;F+=1)C.isDark(F,P)&&!C.isDark(F+1,P)&&C.isDark(F+2,P)&&C.isDark(F+3,P)&&C.isDark(F+4,P)&&!C.isDark(F+5,P)&&C.isDark(F+6,P)&&(ha+=40);for(P=ea=0;P<E;P+=1)for(F=0;F<E;F+=1)C.isDark(F,P)&&(ea+=1);return ha+Math.abs(100*ea/E/E-50)/5*10};return H}(),m=function(){var N=Array(256),
H=Array(256),K;for(K=0;8>K;K+=1)N[K]=1<<K;for(K=8;256>K;K+=1)N[K]=N[K-4]^N[K-5]^N[K-6]^N[K-8];for(K=0;255>K;K+=1)H[N[K]]=K;return{glog:function(C){if(1>C)throw Error("glog("+C+")");return H[C]},gexp:function(C){for(;0>C;)C+=255;for(;256<=C;)C-=255;return N[C]}}}(),p=function(){var N=[[1,26,19],[1,26,16],[1,26,13],[1,26,9],[1,44,34],[1,44,28],[1,44,22],[1,44,16],[1,70,55],[1,70,44],[2,35,17],[2,35,13],[1,100,80],[2,50,32],[2,50,24],[4,25,9],[1,134,108],[2,67,43],[2,33,15,2,34,16],[2,33,11,2,34,12],
[2,86,68],[4,43,27],[4,43,19],[4,43,15],[2,98,78],[4,49,31],[2,32,14,4,33,15],[4,39,13,1,40,14],[2,121,97],[2,60,38,2,61,39],[4,40,18,2,41,19],[4,40,14,2,41,15],[2,146,116],[3,58,36,2,59,37],[4,36,16,4,37,17],[4,36,12,4,37,13],[2,86,68,2,87,69],[4,69,43,1,70,44],[6,43,19,2,44,20],[6,43,15,2,44,16]],H={},K=function(C,E){switch(E){case h.L:return N[4*(C-1)];case h.M:return N[4*(C-1)+1];case h.Q:return N[4*(C-1)+2];case h.H:return N[4*(C-1)+3]}};H.getRSBlocks=function(C,E){var F=K(C,E);if("undefined"==
typeof F)throw Error("bad rs block @ typeNumber:"+C+"/errorCorrectLevel:"+E);C=F.length/3;E=[];for(var P=0;P<C;P+=1)for(var ha=F[3*P],ea=F[3*P+1],aa=F[3*P+2],W=0;W<ha;W+=1){var ka=E,Z=ka.push,ca=aa,ia={};ia.totalCount=ea;ia.dataCount=ca;Z.call(ka,ia)}return E};return H}(),t=function(){var N=[],H=0,K={getBuffer:function(){return N},get:function(C){return 1==(N[Math.floor(C/8)]>>>7-C%8&1)},put:function(C,E){for(var F=0;F<E;F+=1)K.putBit(1==(C>>>E-F-1&1))},getLengthInBits:function(){return H},putBit:function(C){var E=
Math.floor(H/8);N.length<=E&&N.push(0);C&&(N[E]|=128>>>H%8);H+=1}};return K},q=function(N){var H=e.stringToBytes(N);return{getMode:function(){return 4},getLength:function(K){return H.length},write:function(K){for(var C=0;C<H.length;C+=1)K.put(H[C],8)}}},y=function(){var N=[],H={writeByte:function(K){N.push(K&255)},writeShort:function(K){H.writeByte(K);H.writeByte(K>>>8)},writeBytes:function(K,C,E){C=C||0;E=E||K.length;for(var F=0;F<E;F+=1)H.writeByte(K[F+C])},writeString:function(K){for(var C=0;C<
K.length;C+=1)H.writeByte(K.charCodeAt(C))},toByteArray:function(){return N},toString:function(){var K="[";for(var C=0;C<N.length;C+=1)0<C&&(K+=","),K+=N[C];return K+"]"}};return H},I=function(){var N=0,H=0,K=0,C="",E={},F=function(P){if(!(0>P)){if(26>P)return 65+P;if(52>P)return 97+(P-26);if(62>P)return 48+(P-52);if(62==P)return 43;if(63==P)return 47}throw Error("n:"+P);};E.writeByte=function(P){N=N<<8|P&255;H+=8;for(K+=1;6<=H;)C+=String.fromCharCode(F(N>>>H-6&63)),H-=6};E.flush=function(){0<H&&
(C+=String.fromCharCode(F(N<<6-H&63)),H=N=0);if(0!==K%3)for(var P=3-K%3,ha=0;ha<P;ha+=1)C+="="};E.toString=function(){return C};return E},L=function(N){var H=0,K=0,C=0,E=function(F){if(65<=F&&90>=F)return F-65;if(97<=F&&122>=F)return F-97+26;if(48<=F&&57>=F)return F-48+52;if(43==F)return 62;if(47==F)return 63;throw Error("c:"+F);};return{read:function(){for(;8>C;){if(H>=N.length){if(0===C)return-1;throw Error("unexpected end of file./"+C);}var F=N.charAt(H);H+=1;if("="==F)return C=0,-1;F.match(/^\s$/)||
(K=K<<6|E(F.charCodeAt(0)),C+=6)}F=K>>>C-8&255;C-=8;return F}}},Q=function(N,H){var K=Array(N*H),C=function(F){var P=0,ha=0;return{write:function(ea,aa){if(0!==ea>>>aa)throw Error("length over");for(;8<=P+aa;)F.writeByte(255&(ea<<P|ha)),aa-=8-P,ea>>>=8-P,P=ha=0;ha|=ea<<P;P+=aa},flush:function(){0<P&&F.writeByte(ha)}}},E=function(){var F={},P=0,ha={add:function(ea){if(ha.contains(ea))throw Error("dup key:"+ea);F[ea]=P;P+=1},size:function(){return P},indexOf:function(ea){return F[ea]},contains:function(ea){return"undefined"!=
typeof F[ea]}};return ha};return{setPixel:function(F,P,ha){K[P*N+F]=ha},write:function(F){F.writeString("GIF87a");F.writeShort(N);F.writeShort(H);F.writeByte(128);F.writeByte(0);F.writeByte(0);F.writeByte(0);F.writeByte(0);F.writeByte(0);F.writeByte(255);F.writeByte(255);F.writeByte(255);F.writeString(",");F.writeShort(0);F.writeShort(0);F.writeShort(N);F.writeShort(H);F.writeByte(0);var P=3;for(var ha=E(),ea=0;4>ea;ea+=1)ha.add(String.fromCharCode(ea));ha.add(String.fromCharCode(4));ha.add(String.fromCharCode(5));
ea=y();var aa=C(ea);aa.write(4,P);var W=0,ka=String.fromCharCode(K[W]);for(W+=1;W<K.length;){var Z=String.fromCharCode(K[W]);W+=1;ha.contains(ka+Z)?ka+=Z:(aa.write(ha.indexOf(ka),P),4095>ha.size()&&(ha.size()==1<<P&&(P+=1),ha.add(ka+Z)),ka=Z)}aa.write(ha.indexOf(ka),P);aa.write(5,P);aa.flush();P=ea.toByteArray();F.writeByte(2);for(ha=0;255<P.length-ha;)F.writeByte(255),F.writeBytes(P,ha,255),ha+=255;F.writeByte(P.length-ha);F.writeBytes(P,ha,P.length-ha);F.writeByte(0);F.writeString(";")}}},da=function(N,
H,K,C){for(var E=Q(N,H),F=0;F<H;F+=1)for(var P=0;P<N;P+=1)E.setPixel(P,F,K(P,F));K=y();E.write(K);E=I();K=K.toByteArray();for(F=0;F<K.length;F+=1)E.writeByte(K[F]);E.flush();E='<img src="data:image/gif;base64,'+E+'" width="';E+=N;E+='"';E+=' height="';E+=H;E+='"';C&&(E+=' alt="',E+=C,E+='"');return E+="/>"};return e}();AI.Blockly.TypeBlock=function(d){this.workspace_=d;this.needsReload={components:!0,screens:!0,assets:!0}};AI.Blockly.TypeBlock.prototype.TBOptions_={};AI.Blockly.TypeBlock.prototype.lazyLoadOfOptions_=function(){if(this.needsReload.components||this.needsReload.screens||this.needsReload.assets)this.generateOptions(),this.needsReload.components=!1,this.needsReload.screens=!1,this.needsReload.assets=!1;this.loadGlobalVariables_();this.loadLocalVariables_();this.loadProcedures_()};
AI.Blockly.TypeBlock.prototype.generateOptions=function(){var d={},e;for(e in Blockly.Blocks){var h=Blockly.Blocks[e];if(h.typeblock){var k=h.typeblock;"function"==typeof h.typeblock&&(k=h.typeblock());h=k;k=e;if(h)for(const p of h){h={};var m={};if(p.dropDown)if(p.dropDown.titleName&&p.dropDown.value)h.titleName=p.dropDown.titleName,h.value=p.dropDown.value;else throw Error("TypeBlock not correctly set up for "+k);p.mutatorAttributes&&(m=p.mutatorAttributes);d[p.translatedName.replace(/%[0-9]+/g,
"")]={canonicName:k,dropDown:h,mutatorAttributes:m}}}}this.TBOptions_=d};
AI.Blockly.TypeBlock.prototype.loadProcedures_=function(){function d(h){var k=[];h=this.workspace_.getProcedureDatabase().getMenuItems(h);1==h.length&&""==h[0][0]&&(h=[]);for(const m of h)k.push({translatedName:Blockly.Msg.LANG_PROCEDURES_CALLNORETURN_CALL+m[0],dropDown:{titleName:"PROCNAME",value:m[1]}});return k}this.TBOptions_=Object.fromEntries(Object.entries(this.TBOptions_).filter(([,h])=>!h.isProcedure));var e=d.call(this,!1);for(const h of e)this.TBOptions_[h.translatedName]={canonicName:"procedures_callnoreturn",
dropDown:h.dropDown,isProcedure:!0};e=d.call(this,!0);for(const h of e)this.TBOptions_[h.translatedName]={canonicName:"procedures_callreturn",dropDown:h.dropDown,isProcedure:!0}};
AI.Blockly.TypeBlock.prototype.loadGlobalVariables_=function(){this.TBOptions_=Object.fromEntries(Object.entries(this.TBOptions_).filter(([,e])=>!e.isGlobalvar));var d=Blockly.FieldLexicalVariable.getGlobalNames();for(const e of d)d=Blockly.Msg.LANG_VARIABLES_GLOBAL_PREFIX+" "+e,this.TBOptions_[Blockly.Msg.LANG_VARIABLES_GET_TITLE_GET+" "+d]={canonicName:"lexical_variable_get",dropDown:{titleName:"VAR",value:"global "+e},isGlobalvar:!0},this.TBOptions_[Blockly.Msg.LANG_VARIABLES_SET_TITLE_SET+" "+
d]={canonicName:"lexical_variable_set",dropDown:{titleName:"VAR",value:"global "+e},isGlobalvar:!0}};
AI.Blockly.TypeBlock.prototype.loadLocalVariables_=function(){this.TBOptions_=Object.fromEntries(Object.entries(this.TBOptions_).filter(([,h])=>!h.isLocalVar));var d=Blockly.common.getSelected();if(d){var e=Blockly.FieldLexicalVariable.getLexicalNamesInScope(d).map(function(h){return h[0]});d.getVars&&(e=e.concat(d.getVars().map(function(h){return d.workspace.getTopWorkspace().getComponentDatabase().getInternationalizedParameterName(h)})));for(const h of e)this.TBOptions_[Blockly.Msg.LANG_VARIABLES_GET_TITLE_GET+
" "+h]={canonicName:"lexical_variable_get",dropDown:{titleName:"VAR",value:h},isLocalVar:!0},this.TBOptions_[Blockly.Msg.LANG_VARIABLES_SET_TITLE_SET+" "+h]={canonicName:"lexical_variable_set",dropDown:{titleName:"VAR",value:h},isLocalVar:!0}}};
AI.Blockly.TypeBlock.matchNumberOrTextBlock=function(d){var e,h=RegExp("^-?[0-9]\\d*(.\\d+)?$","g").exec(d),k=RegExp("^[\"|']+","g").exec(d);h&&0<h.length?e={canonicName:"math_number",dropDown:{titleName:"NUM",value:d}}:k&&1===k.length&&(e={canonicName:"text",dropDown:{titleName:"TEXT",value:d.endsWith('"')?d.substring(1,d.length-1):d.substring(1)}});return e};
AI.Blockly.TypeBlock.prototype.connectIfPossible=function(d,e){var h,k=d.inputList,m=k.length;const p=d.workspace.connectionChecker;for(h=0;h<m;h++)try{if(null!=e.outputConnection){if(k[h].connection&&p.canConnect(k[h].connection,e.outputConnection,!1)&&!k[h].connection.targetConnection){e.outputConnection.connect(k[h].connection);break}}else if(!k[h].connection.isConnected()){e.previousConnection.connect(k[h].connection);break}}catch(t){}null===e.parentBlock_&&(null==d.outputConnection&&null==e.outputConnection?
e.previousConnection.connect(d.nextConnection):d.parentBlock_&&(null==d.parentBlock_.outputConnection?null==e.outputConnection&&d.parentBlock_.nextConnection.connect(e.previousConnection):this.connectIfPossible(d.parentBlock_,e)))};AI.Blockly.TypeBlock.ac={};AI.Blockly.TypeBlock.ac.AIArrayMatcher=function(d,e){this.rows_=d;this.useSimilar_=!e};AI.Blockly.TypeBlock.ac.AIArrayMatcher.regExpEscape_=function(d){return String(d).replace(/([-()\[\]{}+?*.$\^|,:#<!\\])/g,"\\$1").replace(/\x08/g,"\\x08")};
AI.Blockly.TypeBlock.ac.AIArrayMatcher.getPrefixMatchesForRows_=function(d,e,h){var k=[];if(""!=d){d=AI.Blockly.TypeBlock.ac.AIArrayMatcher.regExpEscape_(d);d=new RegExp("(^|\\W+)"+d,"i");for(var m=0;m<h.length&&k.length<e;m++){var p=h[m];String(p).match(d)&&k.push(p)}}return k};
AI.Blockly.TypeBlock.ac.AIArrayMatcher.getSimilarMatchesForRows_=function(d,e,h){for(var k=[],m=0;m<h.length;m++){var p=h[m],t=d.toLowerCase(),q=String(p).toLowerCase(),y=0;if(-1!=q.indexOf(t))y=parseInt((q.indexOf(t)/4).toString(),10);else for(var I=t.split(""),L=-1,Q=10,da=0,N;N=I[da];da++)N=q.indexOf(N),N>L?(L=N-L-1,L>Q-5&&(L=Q-5),y+=L,L=N):(y+=Q,Q+=5);y<6*t.length&&k.push({str:p,score:y,index:m})}k.sort(function(H,K){var C=H.score-K.score;return 0!=C?C:H.index-K.index});d=[];for(da=0;da<e&&da<
k.length;da++)d.push(k[da].str);return d};AI.Blockly.TypeBlock.ac.AIArrayMatcher.prototype.getPrefixMatches=function(d,e){return AI.Blockly.TypeBlock.ac.AIArrayMatcher.getPrefixMatchesForRows_(d,e,this.rows_)};AI.Blockly.TypeBlock.ac.AIArrayMatcher.prototype.getSimilarRows=function(d,e){return AI.Blockly.TypeBlock.ac.AIArrayMatcher.getSimilarMatchesForRows_(d,e,this.rows_)};
AI.Blockly.TypeBlock.ac.AIArrayMatcher.prototype.requestMatchingRows=function(d,e,h,k){k=this.getPrefixMatches(d,e);if("text"===d||"Text"===d){var m=k.indexOf("Text");-1<m&&k.splice(m,1);k.unshift("Text")}(m=RegExp("^-?[0-9]\\d*(.\\d+)?$","g").exec(d))&&0<m.length&&k.unshift(d);(m=RegExp("^[\"|']+","g").exec(d))&&1===m.length&&k.push(d);0===k.length&&this.useSimilar_&&(k=this.getSimilarRows(d,e));h(d,k)};/*

 Copyright © 2025-2026 Massachusetts Institute of Technology. All rights reserved.
*/
AI.Blockly.TypeBlockPluginAdapter={};
const toOption=(d,e)=>{d={blockType:e.canonicName,displayText:d};e.dropDown?.titleName&&e.dropDown.value&&(d.fieldValues={[e.dropDown.titleName]:e.dropDown.value});if(e.mutatorAttributes&&Object.keys(e.mutatorAttributes).length){const h=document.createElement("mutation");for(const [k,m]of Object.entries(e.mutatorAttributes))h.setAttribute(k,m);d.extraState=Blockly.utils.xml.domToText(h)}return d},matcher=(d,e)=>{const h=d.map(m=>m.displayText),k=[];(new AI.Blockly.TypeBlock.ac.AIArrayMatcher(h,!1)).requestMatchingRows(e,
100,(m,p)=>{p.forEach(t=>{var q=d.find(y=>y.displayText===t);q?k.push(q):(q=AI.Blockly.TypeBlock.matchNumberOrTextBlock(t))&&k.push(toOption(t,q))})});return k};class OptionGenerator{constructor(d){this.legacyTypeBlock=d}generateOptions(){this.legacyTypeBlock.lazyLoadOfOptions_();return Object.entries(this.legacyTypeBlock.TBOptions_).map(([d,e])=>toOption(d,e)).sort((d,e)=>d.displayText>e.displayText?1:d.displayText<e.displayText?-1:0)}}
class ConnectionStrategy{constructor(d){this.legacyTypeBlock=d}canConnect(d,e,h){return h.selectedBlock&&h.selectedBlock===e}connect(d,e){this.legacyTypeBlock.connectIfPossible(e,d);return null!==d.getParent()?{success:!0}:{success:!1,reason:"No compatible connection found"}}get priority(){return 100}get name(){return"Legacy"}}AI.Blockly.TypeBlockPluginAdapter.create=d=>{d=new AI.Blockly.TypeBlock(d);return{needsReload:d.needsReload,matcher,optionGenerator:new OptionGenerator(d),connectionStrategy:new ConnectionStrategy(d)}};/*

 Copyright © 2016 Massachusetts Institute of Technology. All rights reserved.
*/
AI.Blockly.VariableDatabase={};Blockly.VariableDatabase=function(){this.globals_={}};Blockly.VariableDatabase.prototype.getGlobalNames=function(d){var e=[],h;for(h in this.globals_)this.globals_.hasOwnProperty(h)&&this.globals_[h]!=d&&e.push(h);return e};Blockly.VariableDatabase.prototype.getLexicalNamesInScope=function(d){};Blockly.VariableDatabase.prototype.getNamesInScope=function(d){};/*

 @fileoverview Container block for all mutators for Blockly, modified for MIT App Inventor.
 @author mckinney@mit.edu (Andrew F. McKinney)
*/
AI.Blocks={};AI.Blocks.mutators={};Blockly.Blocks.mutator_container={init:function(){this.setColour(210);this.appendDummyInput().appendField("","CONTAINER_TEXT");this.appendStatementInput("STACK");this.contextMenu=!1}};Blockly.mutationToDom=function(d){d=document.createElement("mutation");d.setAttribute("items",this.itemCount_);return d};
Blockly.domToMutation=function(d){if(null!=this.valuesToSave)for(var e in this.valuesToSave)this.valuesToSave[e]=this.getFieldValue(e);if(0==this.itemCount_)null!=this.emptyInputName&&this.removeInput(this.emptyInputName);else for(e=0;e<this.itemCount_;e++)this.removeInput(this.repeatingInputName+e);this.itemCount_=window.parseInt(d.getAttribute("items"),10);for(e=0;e<this.itemCount_;e++)this.addInput(e);0==this.itemCount_&&this.addEmptyInput()};
Blockly.decompose=function(d,e,h){var k=d.newBlock("mutator_container");k.setColour(h.getColour());null!=h.updateContainerBlock&&h.updateContainerBlock(k);k.initSvg();for(var m=k.getInput("STACK").connection,p=0;p<h.itemCount_;p++){var t=d.newBlock(e);t.initSvg();m.connect(t.previousConnection);m=t.nextConnection}return k};
Blockly.compose=function(d){if(null!=this.valuesToSave)for(var e in this.valuesToSave)this.valuesToSave[e]=this.getFieldValue(e);if(0==this.itemCount_)null!=this.emptyInputName&&this.removeInput(this.emptyInputName);else for(e=this.itemCount_-1;0<=e;e--)this.removeInput(this.repeatingInputName+e);this.itemCount_=0;for(d=d.getInputTargetBlock("STACK");d;)e=this.addInput(this.itemCount_),d.valueConnection_&&e.connection.connect(d.valueConnection_),this.itemCount_++,d=d.nextConnection&&d.nextConnection.targetBlock();
0==this.itemCount_&&this.addEmptyInput()};Blockly.saveConnections=function(d){d=d.getInputTargetBlock("STACK");for(var e=0;d;){var h=this.getInput(this.repeatingInputName+e);d.valueConnection_=h&&h.connection.targetConnection;e++;d=d.nextConnection&&d.nextConnection.targetBlock()}};/*

 @fileoverview Color blocks for Blockly, modified for MIT App Inventor.
 @author mckinney@mit.edu (Andrew F. McKinney)
*/
AI.Blocks.color={};Blockly.Blocks.color_black={category:"Colors",helpUrl:Blockly.Msg.LANG_COLOUR_PICKER_HELPURL,init:function(){this.setColour(Blockly.COLOR_CATEGORY_HUE);this.appendDummyInput().appendField(new Blockly.FieldColour("#000000"),"COLOR");this.setOutput(!0,AI.BlockUtils.YailTypeToBlocklyType("number",AI.BlockUtils.OUTPUT));this.setTooltip(Blockly.Msg.LANG_COLOUR_PICKER_TOOLTIP)},typeblock:[{translatedName:Blockly.Msg.LANG_COLOUR_BLACK}]};
Blockly.Blocks.color_white={category:"Colors",helpUrl:Blockly.Msg.LANG_COLOUR_PICKER_HELPURL,init:function(){this.setColour(Blockly.COLOR_CATEGORY_HUE);this.appendDummyInput().appendField(new Blockly.FieldColour("#ffffff"),"COLOR");this.setOutput(!0,AI.BlockUtils.YailTypeToBlocklyType("number",AI.BlockUtils.OUTPUT));this.setTooltip(Blockly.Msg.LANG_COLOUR_MAKE_COLOUR_TOOLTIP)},typeblock:[{translatedName:Blockly.Msg.LANG_COLOUR_WHITE}]};
Blockly.Blocks.color_red={category:"Colors",helpUrl:Blockly.Msg.LANG_COLOUR_PICKER_HELPURL,init:function(){this.setColour(Blockly.COLOR_CATEGORY_HUE);this.appendDummyInput().appendField(new Blockly.FieldColour("#ff0000"),"COLOR");this.setOutput(!0,AI.BlockUtils.YailTypeToBlocklyType("number",AI.BlockUtils.OUTPUT));this.setTooltip(Blockly.Msg.LANG_COLOUR_MAKE_COLOUR_TOOLTIP)},typeblock:[{translatedName:Blockly.Msg.LANG_COLOUR_RED}]};
Blockly.Blocks.color_pink={category:"Colors",helpUrl:Blockly.Msg.LANG_COLOUR_PICKER_HELPURL,init:function(){this.setColour(Blockly.COLOR_CATEGORY_HUE);this.appendDummyInput().appendField(new Blockly.FieldColour("#ffafaf"),"COLOR");this.setOutput(!0,AI.BlockUtils.YailTypeToBlocklyType("number",AI.BlockUtils.OUTPUT));this.setTooltip(Blockly.Msg.LANG_COLOUR_MAKE_COLOUR_TOOLTIP)},typeblock:[{translatedName:Blockly.Msg.LANG_COLOUR_PINK}]};
Blockly.Blocks.color_orange={category:"Colors",helpUrl:Blockly.Msg.LANG_COLOUR_PICKER_HELPURL,init:function(){this.setColour(Blockly.COLOR_CATEGORY_HUE);this.appendDummyInput().appendField(new Blockly.FieldColour("#ffc800"),"COLOR");this.setOutput(!0,AI.BlockUtils.YailTypeToBlocklyType("number",AI.BlockUtils.OUTPUT));this.setTooltip(Blockly.Msg.LANG_COLOUR_MAKE_COLOUR_TOOLTIP)},typeblock:[{translatedName:Blockly.Msg.LANG_COLOUR_ORANGE}]};
Blockly.Blocks.color_yellow={category:"Colors",helpUrl:Blockly.Msg.LANG_COLOUR_PICKER_HELPURL,init:function(){this.setColour(Blockly.COLOR_CATEGORY_HUE);this.appendDummyInput().appendField(new Blockly.FieldColour("#ffff00"),"COLOR");this.setOutput(!0,AI.BlockUtils.YailTypeToBlocklyType("number",AI.BlockUtils.OUTPUT));this.setTooltip(Blockly.Msg.LANG_COLOUR_MAKE_COLOUR_TOOLTIP)},typeblock:[{translatedName:Blockly.Msg.LANG_COLOUR_YELLOW}]};
Blockly.Blocks.color_green={category:"Colors",helpUrl:Blockly.Msg.LANG_COLOUR_PICKER_HELPURL,init:function(){this.setColour(Blockly.COLOR_CATEGORY_HUE);this.appendDummyInput().appendField(new Blockly.FieldColour("#00ff00"),"COLOR");this.setOutput(!0,AI.BlockUtils.YailTypeToBlocklyType("number",AI.BlockUtils.OUTPUT));this.setTooltip(Blockly.Msg.LANG_COLOUR_MAKE_COLOUR_TOOLTIP)},typeblock:[{translatedName:Blockly.Msg.LANG_COLOUR_GREEN}]};
Blockly.Blocks.color_cyan={category:"Colors",helpUrl:Blockly.Msg.LANG_COLOUR_PICKER_HELPURL,init:function(){this.setColour(Blockly.COLOR_CATEGORY_HUE);this.appendDummyInput().appendField(new Blockly.FieldColour("#00ffff"),"COLOR");this.setOutput(!0,AI.BlockUtils.YailTypeToBlocklyType("number",AI.BlockUtils.OUTPUT));this.setTooltip(Blockly.Msg.LANG_COLOUR_MAKE_COLOUR_TOOLTIP)},typeblock:[{translatedName:Blockly.Msg.LANG_COLOUR_CYAN}]};
Blockly.Blocks.color_blue={category:"Colors",helpUrl:Blockly.Msg.LANG_COLOUR_PICKER_HELPURL,init:function(){this.setColour(Blockly.COLOR_CATEGORY_HUE);this.appendDummyInput().appendField(new Blockly.FieldColour("#0000ff"),"COLOR");this.setOutput(!0,AI.BlockUtils.YailTypeToBlocklyType("number",AI.BlockUtils.OUTPUT));this.setTooltip(Blockly.Msg.LANG_COLOUR_MAKE_COLOUR_TOOLTIP)},typeblock:[{translatedName:Blockly.Msg.LANG_COLOUR_BLUE}]};
Blockly.Blocks.color_magenta={category:"Colors",helpUrl:Blockly.Msg.LANG_COLOUR_PICKER_HELPURL,init:function(){this.setColour(Blockly.COLOR_CATEGORY_HUE);this.appendDummyInput().appendField(new Blockly.FieldColour("#ff00ff"),"COLOR");this.setOutput(!0,AI.BlockUtils.YailTypeToBlocklyType("number",AI.BlockUtils.OUTPUT));this.setTooltip(Blockly.Msg.LANG_COLOUR_MAKE_COLOUR_TOOLTIP)},typeblock:[{translatedName:Blockly.Msg.LANG_COLOUR_MAGENTA}]};
Blockly.Blocks.color_light_gray={category:"Colors",helpUrl:Blockly.Msg.LANG_COLOUR_PICKER_HELPURL,init:function(){this.setColour(Blockly.COLOR_CATEGORY_HUE);this.appendDummyInput().appendField(new Blockly.FieldColour("#cccccc"),"COLOR");this.setOutput(!0,AI.BlockUtils.YailTypeToBlocklyType("number",AI.BlockUtils.OUTPUT));this.setTooltip(Blockly.Msg.LANG_COLOUR_MAKE_COLOUR_TOOLTIP)},typeblock:[{translatedName:Blockly.Msg.LANG_COLOUR_LIGHT_GRAY}]};
Blockly.Blocks.color_gray={category:"Colors",helpUrl:Blockly.Msg.LANG_COLOUR_PICKER_HELPURL,init:function(){this.setColour(Blockly.COLOR_CATEGORY_HUE);this.appendDummyInput().appendField(new Blockly.FieldColour("#888888"),"COLOR");this.setOutput(!0,AI.BlockUtils.YailTypeToBlocklyType("number",AI.BlockUtils.OUTPUT));this.setTooltip(Blockly.Msg.LANG_COLOUR_MAKE_COLOUR_TOOLTIP)},typeblock:[{translatedName:Blockly.Msg.LANG_COLOUR_GRAY}]};
Blockly.Blocks.color_dark_gray={category:"Colors",helpUrl:Blockly.Msg.LANG_COLOUR_PICKER_HELPURL,init:function(){this.setColour(Blockly.COLOR_CATEGORY_HUE);this.appendDummyInput().appendField(new Blockly.FieldColour("#444444"),"COLOR");this.setOutput(!0,AI.BlockUtils.YailTypeToBlocklyType("number",AI.BlockUtils.OUTPUT));this.setTooltip(Blockly.Msg.LANG_COLOUR_MAKE_COLOUR_TOOLTIP)},typeblock:[{translatedName:Blockly.Msg.LANG_COLOUR_DARK_GRAY}]};
Blockly.Blocks.color_make_color={category:"Colors",helpUrl:Blockly.Msg.LANG_COLOUR_MAKE_COLOUR_HELPURL,init:function(){this.setColour(Blockly.COLOR_CATEGORY_HUE);this.appendValueInput("COLORLIST").appendField(Blockly.Msg.LANG_COLOUR_MAKE_COLOUR).setCheck(AI.BlockUtils.YailTypeToBlocklyType("list",AI.BlockUtils.INPUT));this.setOutput(!0,AI.BlockUtils.YailTypeToBlocklyType("number",AI.BlockUtils.OUTPUT));this.setTooltip(Blockly.Msg.LANG_COLOUR_MAKE_COLOUR_TOOLTIP)},typeblock:[{translatedName:Blockly.Msg.LANG_COLOUR_MAKE_COLOUR}]};
Blockly.Blocks.color_split_color={category:"Colors",helpUrl:Blockly.Msg.LANG_COLOUR_SPLIT_COLOUR_HELPURL,init:function(){this.setColour(Blockly.COLOR_CATEGORY_HUE);this.appendValueInput("COLOR").appendField(Blockly.Msg.LANG_COLOUR_SPLIT_COLOUR).setCheck(AI.BlockUtils.YailTypeToBlocklyType("number",AI.BlockUtils.INPUT));this.setOutput(!0,AI.BlockUtils.YailTypeToBlocklyType("list",AI.BlockUtils.OUTPUT));this.setTooltip(Blockly.Msg.LANG_COLOUR_SPLIT_COLOUR_TOOLTIP)},typeblock:[{translatedName:Blockly.Msg.LANG_COLOUR_SPLIT_COLOUR}]};/*

 @fileoverview Non-editable field with flydown representing a component event
     parameter. Necessary to support eventparam mutation and helper blocks in
     the flydown.
*/
AI.Blockly.FieldEventFlydown={};Blockly.FieldEventFlydown=class extends Blockly.FieldParameterFlydown{constructor(d,e,h){super(e.getInternationalizedParameterName(d.name),!1,h);this.componentDb=e;this.param=d}isSerializable(){return!1}};
Blockly.FieldEventFlydown.prototype.flydownBlocksXML_=function(){var d='<mutation><eventparam name="'+this.param.name+'" /></mutation>',e="";this.param.helperKey&&(e=Blockly.Util.xml.valueWithHelperXML("VALUE",this.param.helperKey),e=Blockly.Xml.domToText(e.firstChild));return'<xml><block type="lexical_variable_get">'+d+'<field name="VAR">'+this.param.name+'</field></block><block type="lexical_variable_set">'+d+'<field name="VAR">'+this.param.name+"</field>"+e+"</block></xml>"};/*

 @fileoverview Component blocks for Blockly, modified for MIT App Inventor.
 @author mckinney@mit.edu (Andrew F. McKinney)
 @author sharon@google.com (Sharon Perl)
 @author ewpatton@mit.edu (Evan W. Patton)
*/
AI.Blocks.components={};Blockly.ComponentBlock={};Blockly.ComponentBlock.COLOUR_EVENT=Blockly.CONTROL_CATEGORY_HUE;Blockly.ComponentBlock.COLOUR_METHOD=Blockly.PROCEDURE_CATEGORY_HUE;Blockly.ComponentBlock.COLOUR_GET="#439970";Blockly.ComponentBlock.COLOUR_SET="#266643";Blockly.ComponentBlock.COLOUR_COMPONENT="#439970";Blockly.ComponentBlock.COMPONENT_SELECTOR="COMPONENT_SELECTOR";Blockly.ComponentBlock.COMPONENT_TYPE_SELECTOR="COMPONENT_TYPE_SELECTOR";
Blockly.ComponentBlock.addGenericOption=function(d,e){function h(p,t){var q=p.instanceName,y=p.mutationToDom(),I=Blockly.Xml.domToText(y);y.setAttribute("is_generic","true");y.removeAttribute("instance_name");var L=Blockly.Xml.domToText(y);p.domToMutation(y);p.initSvg();p.render();Blockly.Events.isEnabled()&&Blockly.Events.fire(new Blockly.Events.BlockChange(p,"mutation",null,I,L));"component_event"===p.type&&(t=!1);!1!==t&&(void 0===t&&(t=Blockly.utils.xml.textToDom('<xml><block type="component_component_block"><mutation component_type="'+
p.typeName+'" instance_name="'+q+'"></mutation><field name="COMPONENT_SELECTOR">'+q+"</field></block></xml>").firstElementChild),t=Blockly.Xml.domToBlock(t,p.workspace),t.initSvg(),p.getInput("COMPONENT").connection.connect(t.outputConnection));if(Blockly.Events.isEnabled()){var Q=Blockly.Events.getGroup();setTimeout(function(){Blockly.Events.setGroup(Q);p.bumpNeighbours();Blockly.Events.setGroup(!1)},Blockly.BUMP_DELAY)}}if(!("component_event"===d.type&&d.isGeneric||"Form"===d.typeName||d.workspace&&
d.workspace.isFlyout)){var k={enabled:!1};if(d.isGeneric){var m=d.getInputTargetBlock("COMPONENT");k.enabled=m&&"component_component_block"===m.type;k.text=Blockly.BlocklyEditor.makeMenuItemWithHelp(Blockly.Msg.UNGENERICIZE_BLOCK,"/reference/other/any-component-blocks.html");k.callback=function(){try{Blockly.Events.setGroup(!0);var p=m.instanceName;m.dispose(!0);var t=d.mutationToDom(),q=Blockly.Xml.domToText(t);t.setAttribute("instance_name",p);t.setAttribute("is_generic","false");var y=Blockly.Xml.domToText(t);
d.domToMutation(t);d.initSvg();d.render();if(Blockly.Events.isEnabled()){Blockly.Events.fire(new Blockly.Events.BlockChange(d,"mutation",null,q,y));var I=Blockly.Events.getGroup();setTimeout(function(){Blockly.Events.setGroup(I);d.bumpNeighbours();Blockly.Events.setGroup(!1)},Blockly.BUMP_DELAY)}}finally{Blockly.Events.setGroup(!1)}}}else"component_event"===d.type?(k.enabled=!0,k.text=Blockly.BlocklyEditor.makeMenuItemWithHelp(Blockly.Msg.GENERICIZE_BLOCK,"/reference/other/any-component-blocks.html"),
k.callback=function(){try{Blockly.Events.setGroup(!0);var p=d.instanceName,t=d.workspace.getComponentDatabase().getInternationalizedParameterName("component"),q={},y=0,I=new RegExp("^"+t+"([0-9]+)$"),L=[];d.walk(function(da){"local_declaration_statement"!==da.type&&"local_declaration_expression"!==da.type||da.getVars().forEach(function(N){q[N]=!0;var H=N.match(I);H&&(y=Math.max(y,parseInt(H[1])));N===t&&L.push(da)})});t in q&&L.forEach(function(da){Blockly.LexicalVariable.renameParamFromTo(da,t,t+
(y+1).toString(),!0)});var Q=Blockly.utils.xml.textToDom('<xml><block type="lexical_variable_get"><mutation><eventparam name="component"></eventparam></mutation><field name="VAR">'+t+"</field></block></xml>").firstElementChild;h(d);d.walk(function(da){"component_method"!==da.type&&"component_set_get"!==da.type||da.instanceName!==p||h(da,Q)})}finally{Blockly.Events.setGroup(!1)}}):(k.enabled=!0,k.text=Blockly.BlocklyEditor.makeMenuItemWithHelp(Blockly.Msg.GENERICIZE_BLOCK,"/reference/other/any-component-blocks.html"),
k.callback=function(){try{Blockly.Events.setGroup(!0),h(d)}finally{Blockly.Events.setGroup(!1)}});e.splice(e.length-1,0,k)}};Blockly.ComponentBlock.checkDeprecated=function(d,e){e&&e.deprecated&&d.workspace==Blockly.common.getMainWorkspace()&&d.setEnabled(!1)};
Blockly.Blocks.component_event={category:"Component",blockType:"event",init:function(){this.componentDropDown=Blockly.ComponentBlock.createComponentDropDown(this);this.lexicalVarPrefix=Blockly.localNamePrefix},mutationToDom:function(){var d=document.createElement("mutation");d.setAttribute("component_type",this.typeName);d.setAttribute("is_generic",this.isGeneric?"true":"false");this.isGeneric||d.setAttribute("instance_name",this.instanceName);d.setAttribute("event_name",this.eventName);this.horizontalParameters||
d.setAttribute("vertical_parameters","true");for(var e=0;e<this.parameterNames.length;e++)d.setAttribute("param_name"+e,this.parameterNames[e]);return d},domToMutation:function(d){this.componentDropDown=Blockly.ComponentBlock.createComponentDropDown(this);for(var e=null,h=0,k;k=this.inputList[h];h++){if(k.connection){"DO"===k.name&&(e=k.connection.targetBlock());var m=k.connection.targetBlock();m&&m.unplug()}k.dispose()}this.inputList.length=0;this.typeName=d.getAttribute("component_type");this.eventName=
d.getAttribute("event_name");(this.isGeneric="true"==d.getAttribute("is_generic"))?delete this.instanceName:this.instanceName=d.getAttribute("instance_name");this.parameterNames=[];k=this.getDefaultParameters_().length;for(h=0;h<k;h++){m=d.getAttribute("param_name"+h);if(!m)break;this.parameterNames.push(m)}h="true"!==d.getAttribute("vertical_parameters");this.setColour(Blockly.ComponentBlock.COLOUR_EVENT);d=this.getEventTypeObject();m=this.getTopWorkspace().getComponentDatabase();k=d?m.getInternationalizedEventName(d.name):
m.getInternationalizedEventName(this.eventName);this.isGeneric?this.appendDummyInput("WHENTITLE").appendField(Blockly.Msg.LANG_COMPONENT_BLOCK_GENERIC_EVENT_TITLE+m.getInternationalizedComponentType(this.typeName)+"."+k):(this.appendDummyInput("WHENTITLE").appendField(Blockly.Msg.LANG_COMPONENT_BLOCK_TITLE_WHEN).appendField(this.componentDropDown,Blockly.ComponentBlock.COMPONENT_SELECTOR).appendField("."+k),this.componentDropDown.setValue(this.instanceName));this.setParameterOrientation(h);h=d?m.getInternationalizedEventDescription(this.getTypeName(),
d.name,d.description):m.getInternationalizedEventDescription(this.getTypeName(),this.eventName);this.setTooltip(h);this.setPreviousStatement(!1,null);this.setNextStatement(!1,null);e&&this.getInput("DO").connection.connect(e.previousConnection);this.verify();Blockly.ComponentBlock.checkDeprecated(this,d)},getTypeName:function(){return"Form"===this.typeName?"Screen":this.typeName},setParameterOrientation:function(d){var e=this.getParameters();e||=[];var h=this.getTopWorkspace().getComponentDatabase(),
k=this.getInput("DO");if(!k||d!==this.horizontalParameters&&0<e.length){this.horizontalParameters=d;d=null;var m;k&&(d=k.connection.targetConnection);if(this.horizontalParameters){if(k){for(k=0;k<e.length;k++)this.removeInput("VAR"+k);this.removeInput("DO")}if(0<e.length){var p=this.appendDummyInput("PARAMETERS").appendField(" ").setAlign(Blockly.inputs.Align.LEFT);for(k=0;m=e[k];k++)m=new Blockly.FieldEventFlydown(m,h,Blockly.FieldFlydown.DISPLAY_BELOW),p.appendField(m,"VAR"+k).appendField(" ")}}else for(k&&
(this.removeInput("PARAMETERS"),this.removeInput("DO")),k=0;m=e[k];k++)m=new Blockly.FieldEventFlydown(m,h),this.appendDummyInput("VAR"+k).appendField(m,"VAR"+k).setAlign(Blockly.inputs.Align.RIGHT);e=this.appendStatementInput("DO").appendField(Blockly.Msg.LANG_COMPONENT_BLOCK_TITLE_DO);d&&e.connection.connect(d);Blockly.Events.isEnabled()&&Blockly.Events.fire(new Blockly.Events.BlockChange(this,"parameter_orientation",null,!this.horizontalParameters,this.horizontalParameters))}},getParameters:function(){for(var d=
this.getDefaultParameters_(),e=this.getExplicitParameterNames_(),h=[],k=0;k<d.length;k++)h.push({name:e[k]||d[k].name,type:d[k].type});return h},getDefaultParameters_:function(){var d=this.getEventTypeObject();return this.isGeneric?[{name:"component",type:"component"},{name:"notAlreadyHandled",type:"boolean"}].concat(d&&d.parameters||[]):d&&d.parameters||[]},getExplicitParameterNames_:function(){return this.parameterNames},rename:function(d,e){return this.instanceName==d?(this.instanceName=e,this.componentDropDown.setValue(this.instanceName),
!0):!1},renameVar:function(d,e){for(var h=0,k="VAR"+h,m;m=this.getFieldValue(k);h++,k="VAR"+h)Blockly.Names.equals(d,m)&&this.setFieldValue(k,e)},helpUrl:function(){var d=Blockly.ComponentBlock.EVENTS_HELPURLS[this.getTypeName()];d&&"/"==d[0]&&(d=d.split("#"),d[1]=this.getTypeName()+"."+this.eventName,d=d.join("#"));return d},getVars:function(){for(var d=[],e=0,h;h=this.getFieldValue("VAR"+e);e++)d.push(h);return d},getVarString:function(){for(var d="",e=0,h;h=this.getFieldValue("VAR"+e);e++)0!=e&&
(d+=" "),d+=h;return d},declaredNames:function(){for(var d=[],e=0,h;h=this.getField("VAR"+e);e++)d.push(h.getValue()),h.eventparam&&h.eventparam!=h.getValue()&&d.push(h.eventparam);return d},declaredVariables:function(){for(var d=[],e=0,h;h=this.getField("VAR"+e);e++)d.push(h.getValue());return d},withLexicalVarsAndPrefix:function(d,e){d=this.getParameters().map(function(h){return h.name});for(let h=0;h<d.length;h++)e(d[h],this.lexicalVarPrefix,this.workspace.getComponentDatabase().getInternationalizedParameterName(d[h]))},
blocksInScope:function(){var d=this.getInputTargetBlock("DO");return d?[d]:[]},getEventTypeObject:function(){return this.getTopWorkspace().getComponentDatabase().getEventForType(this.typeName,this.eventName)},typeblock:function(){var d=Blockly.common.getMainWorkspace().getComponentDatabase(),e=[],h={};d.forEachInstance(function(k){h[k.typeName]=!0;d.forEventInType(k.typeName,function(m,p){e.push({translatedName:Blockly.Msg.LANG_COMPONENT_BLOCK_TITLE_WHEN+k.name+"."+d.getInternationalizedEventName(p),
mutatorAttributes:{component_type:k.typeName,instance_name:k.name,event_name:p}})})});delete h.Form;Object.keys(h).forEach(function(k){d.forEventInType(k,function(m,p){e.push({translatedName:Blockly.Msg.LANG_COMPONENT_BLOCK_GENERIC_EVENT_TITLE+d.getInternationalizedComponentType(k)+"."+d.getInternationalizedEventName(p),mutatorAttributes:{component_type:k,is_generic:!0,event_name:p}})})});return e},customContextMenu:function(d){const e=d.findIndex(function(h){return h.text===Blockly.Msg.DO_IT});-1<
e&&d.splice(e,1);this.workspace&&this.workspace.isFlyout||(Blockly.FieldParameterFlydown.addHorizontalVerticalOption(this,d),Blockly.ComponentBlock.addGenericOption(this,d))},verify:function(){(function(){var d=this.getTopWorkspace().getComponentDatabase(),e=d.getType(this.typeName);if(!e)return!1;var h=e.eventDictionary[this.eventName];if(!h)return!1;var k=this.getVars();h=h.parameters;this.isGeneric&&k.splice(0,2);if(k.length!=h.length)return!1;if("true"===e.external)for(e=0;e<k.length;++e){for(var m=
!1,p=0,t;t=h[p];++p)if(d.getInternationalizedParameterName(t.name)==k[e]){m=!0;break}if(!m)return!1}return!0}).call(this)?this.notBadBlock():this.badBlock()},errors:[{name:"checkIfUndefinedBlock"},{name:"checkIfIAmADuplicateEventHandler"},{name:"checkComponentNotExistsError"}],onchange:function(d){return d.isTransient?!1:this.workspace.getWarningHandler()&&this.workspace.getWarningHandler().checkErrors(this)}};
Blockly.Blocks.component_method={category:"Component",helpUrl:function(){var d=Blockly.ComponentBlock.METHODS_HELPURLS[this.getTypeName()];d&&"/"==d[0]&&(d=d.split("#"),d[1]=this.getTypeName()+"."+this.methodName,d=d.join("#"));return d},mutationToDom:function(){var d=document.createElement("mutation");d.setAttribute("component_type",this.typeName);d.setAttribute("method_name",this.methodName);var e="false";this.isGeneric&&(e="true");d.setAttribute("is_generic",e);this.isGeneric||d.setAttribute("instance_name",
this.instanceName);!this.isGeneric&&"Clock"==this.typeName&&Blockly.ComponentBlock.isClockMethodName(this.methodName)&&(e=this.getFieldValue("TIME_UNIT"),d.setAttribute("method_name","Add"+e),d.setAttribute("timeUnit",e));return d},domToMutation:function(d){this.componentDropDown=Blockly.ComponentBlock.createComponentDropDown(this);for(var e=[],h=0,k;k=this.inputList[h];h++){if(k.connection){var m=k.connection.targetBlock();m&&m.unplug();e.push(m)}else e.push(null);k.dispose()}this.inputList.length=
0;this.typeName=d.getAttribute("component_type");this.methodName=d.getAttribute("method_name");this.shape=d.getAttribute("shape");(this.isGeneric="true"==d.getAttribute("is_generic"))?delete this.instanceName:this.instanceName=d.getAttribute("instance_name");this.setColour(Blockly.ComponentBlock.COLOUR_METHOD);this.componentDropDown=Blockly.ComponentBlock.createComponentDropDown(this);this.isGeneric||this.componentDropDown.setValue(this.instanceName);d=this.getTopWorkspace().getComponentDatabase();
h=(m=this.getMethodTypeObject())?d.getInternationalizedMethodName(m.name):this.methodName;if(this.isGeneric)this.appendDummyInput().appendField(Blockly.Msg.LANG_COMPONENT_BLOCK_GENERIC_METHOD_TITLE_CALL+d.getInternationalizedComponentType(this.typeName)+"."+h),this.appendValueInput("COMPONENT").setCheck(this.typeName).appendField(Blockly.Msg.LANG_COMPONENT_BLOCK_GENERIC_METHOD_TITLE_FOR_COMPONENT).setAlign(Blockly.inputs.Align.RIGHT);else{if("Clock"==this.typeName&&Blockly.ComponentBlock.isClockMethodName(this.methodName))switch(h=
Blockly.ComponentBlock.createClockAddDropDown(),this.appendDummyInput().appendField(Blockly.Msg.LANG_COMPONENT_BLOCK_METHOD_TITLE_CALL).appendField(this.componentDropDown,Blockly.ComponentBlock.COMPONENT_SELECTOR).appendField(".Add").appendField(h,"TIME_UNIT"),this.methodName){case "AddYears":this.setFieldValue("Years","TIME_UNIT");break;case "AddMonths":this.setFieldValue("Months","TIME_UNIT");break;case "AddWeeks":this.setFieldValue("Weeks","TIME_UNIT");break;case "AddDays":this.setFieldValue("Days",
"TIME_UNIT");break;case "AddHours":this.setFieldValue("Hours","TIME_UNIT");break;case "AddMinutes":this.setFieldValue("Minutes","TIME_UNIT");break;case "AddSeconds":this.setFieldValue("Seconds","TIME_UNIT");break;case "AddDuration":this.setFieldValue("Duration","TIME_UNIT")}else this.appendDummyInput().appendField(Blockly.Msg.LANG_COMPONENT_BLOCK_METHOD_TITLE_CALL).appendField(this.componentDropDown,Blockly.ComponentBlock.COMPONENT_SELECTOR).appendField("."+h);this.componentDropDown.setValue(this.instanceName)}h=
m?d.getInternationalizedMethodDescription(this.getTypeName(),m.name,m.description):d.getInternationalizedMethodDescription(this.getTypeName(),this.methodName);this.setTooltip(h);var p=[];m&&(p=m.parameters);e.splice(0,e.length-p.length);h=0;for(var t;t=p[h];h++)k=d.getInternationalizedParameterName(t.name),t=this.getParamBlocklyType(t),k=this.appendValueInput("ARG"+h).appendField(k).setAlign(Blockly.inputs.Align.RIGHT).setCheck(t),e[h]&&k.connection&&e[h].outputConnection.reconnect(this,"ARG"+h);
m?m.returnType?this.setOutput(!0,AI.BlockUtils.YailTypeToBlocklyType(m.returnType,AI.BlockUtils.OUTPUT)):(this.setPreviousStatement(!0),this.setNextStatement(!0)):"statement"===this.shape?(this.setPreviousStatement(!0),this.setNextStatement(!0),this.setOutput(!1)):("value"===this.shape?this.setOutput(!0):this.setOutput(!1),this.setPreviousStatement(!1),this.setNextStatement(!1));this.errors=[{name:"checkIfUndefinedBlock"},{name:"checkIsInDefinition"},{name:"checkComponentNotExistsError"},{name:"checkGenericComponentSocket"}];
this.verify();Blockly.ComponentBlock.checkDeprecated(this,this.getMethodTypeObject())},getTypeName:function(){return"Form"===this.typeName?"Screen":this.typeName},rename:function(d,e){return this.instanceName==d?(this.instanceName=e,this.componentDropDown.setValue(this.instanceName),!0):!1},getMethodTypeObject:function(){return this.getTopWorkspace().getComponentDatabase().getMethodForType(this.typeName,this.methodName)},getParamBlocklyType:function(d){var e=[],h=AI.BlockUtils.YailTypeToBlocklyType(d.type,
AI.BlockUtils.INPUT);h&&(Array.isArray(h)?e=h.slice():e.push(h));(d=AI.BlockUtils.helperKeyToBlocklyType(d.helperKey,this))&&d!=h&&e.push(d);return e.length?e:null},getReturnBlocklyType:function(d){var e=[],h=AI.BlockUtils.YailTypeToBlocklyType(d.returnType,AI.BlockUtils.OUTPUT);h&&(Array.isArray(h)?e=h.slice():e.push(h));(d=AI.BlockUtils.helperKeyToBlocklyType(d.returnHelperKey,this))&&d!=h&&e.push(d);return e.length?e:null},getArgInputs:function(){for(var d={},e=0,h;h=this.getInput("ARG"+e);e++)1==
h.fieldRow.length&&(d[h.fieldRow[0].getValue()]=h);return d},getArgs:function(){for(var d=[],e=0,h;h=this.getInput("ARG"+e);e++)1==h.fieldRow.length&&d.push(h.fieldRow[0].getValue());return d},typeblock:function(){var d=Blockly.common.getMainWorkspace().getComponentDatabase(),e=[],h={};d.forEachInstance(function(k){h[k.typeName]=!0;d.forMethodInType(k.typeName,function(m,p){e.push({translatedName:Blockly.Msg.LANG_COMPONENT_BLOCK_METHOD_TITLE_CALL+k.name+"."+d.getInternationalizedMethodName(p),mutatorAttributes:{component_type:k.typeName,
instance_name:k.name,method_name:p,is_generic:"false"}})})});delete h.Form;Object.keys(h).forEach(function(k){d.forMethodInType(k,function(m,p){e.push({translatedName:Blockly.Msg.LANG_COMPONENT_BLOCK_GENERIC_METHOD_TITLE_CALL+d.getInternationalizedComponentType(k)+"."+d.getInternationalizedMethodName(p),mutatorAttributes:{component_type:k,method_name:p,is_generic:"true"}})})});return e},verify:function(){(function(){var d=this.getTopWorkspace().getComponentDatabase();if(!d.getType(this.typeName))return!1;
var e=d.getMethodForType(this.typeName,this.methodName);if(!e)return!1;var h=this.getArgs(),k=this.getArgInputs(),m=e.parameters,p=!1;h.length!=m.length&&(p=!0);for(var t=0;t<h.length;++t){for(var q=!1,y=0,I;I=m[y];++y)if(d.getInternationalizedParameterName(I.name)==h[t]){y=k[h[t]];if(!y||!y.connection){p=!0;break}q=this.getParamBlocklyType(I);y.setCheck(q);q=!0;break}q||(p=!0)}d=!1;e.returnType?this.outputConnection?this.outputConnection.setCheck(this.getReturnBlocklyType(e)):d=!0:e.returnType||
this.outputConnection&&(d=!0);return!(p||d)}).call(this)?this.notBadBlock():this.badBlock()},customContextMenu:function(d){Blockly.ComponentBlock.addGenericOption(this,d)}};
Blockly.Blocks.component_set_get={category:"Component",helpUrl:function(){var d=Blockly.ComponentBlock.PROPERTIES_HELPURLS[this.getTypeName()];d&&"/"==d[0]&&(d=d.split("#"),d[1]=this.getTypeName()+"."+this.propertyName,d=d.join("#"));return d},init:function(){this.componentDropDown=Blockly.ComponentBlock.createComponentDropDown(this);this.genericComponentInput=Blockly.Msg.LANG_COMPONENT_BLOCK_GENERIC_SETTER_TITLE_OF_COMPONENT},mutationToDom:function(){var d=document.createElement("mutation");d.setAttribute("component_type",
this.typeName);d.setAttribute("set_or_get",this.setOrGet);d.setAttribute("property_name",this.propertyName);var e="false";this.isGeneric&&(e="true");d.setAttribute("is_generic",e);this.isGeneric||d.setAttribute("instance_name",this.instanceName);return d},domToMutation:function(d){for(var e="set"==this.setOrGet&&this.getInputTargetBlock("VALUE"),h=0,k;k=this.inputList[h];h++){if(k.connection){var m=k.connection.targetBlock();m&&(m.isShadow()?m.dispose():m.unplug())}k.dispose()}this.inputList.length=
0;var p=this.getTopWorkspace().getComponentDatabase();this.typeName=d.getAttribute("component_type");this.setOrGet=d.getAttribute("set_or_get");this.propertyName=d.getAttribute("property_name");this.propertyObject=this.getPropertyObject(this.propertyName);(this.isGeneric="true"==d.getAttribute("is_generic"))?delete this.instanceName:this.instanceName=d.getAttribute("instance_name");"set"==this.setOrGet?this.setColour(Blockly.ComponentBlock.COLOUR_SET):this.setColour(Blockly.ComponentBlock.COLOUR_GET);
d=this.propertyName&&this.propertyObject?p.getInternationalizedPropertyDescription(this.getTypeName(),this.propertyName,this.propertyObject.description):Blockly.Msg.UNDEFINED_BLOCK_TOOLTIP;var t=this;h=new Blockly.FieldDropdown(function(){return t.getPropertyDropDownList()},function(q){t.propertyName=q;t.propertyObject=t.getPropertyObject(q);t.setTypeCheck();t.propertyName&&t.propertyObject?t.setTooltip(p.getInternationalizedPropertyDescription(t.getTypeName(),t.propertyName,t.propertyObject.description)):
t.setTooltip(Blockly.Msg.UNDEFINED_BLOCK_TOOLTIP)});"get"==this.setOrGet?(this.setOutput(!0),this.isGeneric?(this.appendDummyInput().appendField(p.getInternationalizedComponentType(this.typeName)+".").appendField(h,"PROP"),this.appendValueInput("COMPONENT").setCheck(this.typeName).appendField(Blockly.Msg.LANG_COMPONENT_BLOCK_GENERIC_GETTER_TITLE_OF_COMPONENT).setAlign(Blockly.inputs.Align.RIGHT)):(this.componentDropDown=Blockly.ComponentBlock.createComponentDropDown(this),this.appendDummyInput().appendField(this.componentDropDown,
Blockly.ComponentBlock.COMPONENT_SELECTOR).appendField(".").appendField(h,"PROP"))):(this.setPreviousStatement(!0),this.setNextStatement(!0),this.isGeneric?(this.appendDummyInput().appendField(Blockly.Msg.LANG_COMPONENT_BLOCK_GENERIC_SETTER_TITLE_SET+p.getInternationalizedComponentType(this.typeName)+".").appendField(h,"PROP"),this.appendValueInput("COMPONENT").setCheck(this.typeName).appendField(Blockly.Msg.LANG_COMPONENT_BLOCK_GENERIC_SETTER_TITLE_OF_COMPONENT).setAlign(Blockly.inputs.Align.RIGHT),
this.appendValueInput("VALUE").appendField(Blockly.Msg.LANG_COMPONENT_BLOCK_GENERIC_SETTER_TITLE_TO).setAlign(Blockly.inputs.Align.RIGHT)):(this.componentDropDown=Blockly.ComponentBlock.createComponentDropDown(this),this.appendValueInput("VALUE").appendField(Blockly.Msg.LANG_COMPONENT_BLOCK_SETTER_TITLE_SET).appendField(this.componentDropDown,Blockly.ComponentBlock.COMPONENT_SELECTOR).appendField(".").appendField(h,"PROP").appendField(Blockly.Msg.LANG_COMPONENT_BLOCK_SETTER_TITLE_TO)));e&&e.outputConnection.reconnect(this,
"VALUE");this.isGeneric||this.componentDropDown.setValue(this.instanceName);this.setFieldValue(this.propertyName,"PROP");this.setTypeCheck();this.setTooltip(d);this.errors=[{name:"checkIfUndefinedBlock"},{name:"checkIsInDefinition"},{name:"checkComponentNotExistsError"},{name:"checkGenericComponentSocket"},{name:"checkEmptySetterSocket"}];this.verify();Blockly.ComponentBlock.checkDeprecated(this,this.propertyObject)},getTypeName:function(){return"Form"===this.typeName?"Screen":this.typeName},setTypeCheck:function(){var d=
AI.BlockUtils.OUTPUT;"set"==this.setOrGet&&(d=AI.BlockUtils.INPUT);d=this.getPropertyBlocklyType(this.propertyName,d);"get"==this.setOrGet?this.outputConnection.setCheck(d):this.getInput("VALUE").connection.setCheck(d)},getPropertyBlocklyType:function(d,e){var h=[],k="any";if(d=this.getPropertyObject(d))k=d.type;(e=AI.BlockUtils.YailTypeToBlocklyType(k,e))&&(Array.isArray(e)?h=e.slice():h.push(e));d&&(k=AI.BlockUtils.helperKeyToBlocklyType(d.helperKey,this))&&k!=e&&h.push(k);return h.length?h:null},
getPropertyDropDownList:function(){var d=this.getTopWorkspace().getComponentDatabase(),e=[],h=[this.propertyName];this.propertyObject&&(h="true"==this.propertyObject.deprecated?[this.propertyObject.name]:"set"==this.setOrGet?d.getSetterNamesForType(this.typeName):d.getGetterNamesForType(this.typeName));for(var k=0;k<h.length;k++)e.push([d.getInternationalizedPropertyName(h[k]),h[k]]);return e},getPropertyObject:function(d){return this.getTopWorkspace().getComponentDatabase().getPropertyForType(this.typeName,
d)},rename:function(d,e){return this.instanceName==d?(this.instanceName=e,this.componentDropDown.setValue(this.instanceName),!0):!1},typeblock:function(){function d(m,p,t,q,y){k.push({translatedName:m+y+"."+h.getInternationalizedPropertyName(t),mutatorAttributes:{set_or_get:p,component_type:q,instance_name:y,property_name:t,is_generic:"false"}})}function e(m,p,t,q){"Form"!==q&&k.push({translatedName:m+h.getInternationalizedComponentType(q)+"."+h.getInternationalizedPropertyName(t),mutatorAttributes:{set_or_get:p,
component_type:q,property_name:t,is_generic:!0}})}var h=Blockly.common.getMainWorkspace().getComponentDatabase(),k=[];h.forEachInstance(function(m){var p=[],t=h.types_[m.typeName].properties;for(q in t)t[q].deprecated&&p.push(t[q].name);t=h.getSetterNamesForType(m.typeName);var q=h.getGetterNamesForType(m.typeName);t=t.filter(function(I){return!p.includes(I)});var y=q.filter(function(I){return!p.includes(I)});for(q=0;q<t.length;q++)d(Blockly.Msg.LANG_COMPONENT_BLOCK_SETTER_TITLE_SET,"set",t[q],m.typeName,
m.name,!1);for(q=0;q<y.length;q++)d("","get",y[q],m.typeName,m.name,!1);for(q=0;q<t.length;q++)e(Blockly.Msg.LANG_COMPONENT_BLOCK_SETTER_TITLE_SET,"set",t[q],m.typeName);for(q=0;q<y.length;q++)e("","get",y[q],m.typeName)});return k},verify:function(){(function(){var d=this.getTopWorkspace().getComponentDatabase().getType(this.typeName);if(!d||!d.properties[this.propertyName])return!1;if("get"==this.setOrGet){if(-1==d.getPropertyList.indexOf(this.propertyName))return!1}else if("set"==this.setOrGet&&
-1==d.setPropertyList.indexOf(this.propertyName))return!1;this.setTypeCheck();return!0}).call(this)?this.notBadBlock():this.badBlock(!0)},customContextMenu:function(d){Blockly.ComponentBlock.addGenericOption(this,d)}};
Blockly.Blocks.component_component_block={category:"Component",helpUrl:function(){return Blockly.ComponentBlock.HELPURLS[this.getTypeName()]},mutationToDom:function(){var d=document.createElement("mutation");d.setAttribute("component_type",this.typeName);d.setAttribute("instance_name",this.instanceName);return d},domToMutation:function(d){this.typeName=d.getAttribute("component_type");this.instanceName=d.getAttribute("instance_name");this.setColour(Blockly.ComponentBlock.COLOUR_COMPONENT);this.componentDropDown=
Blockly.ComponentBlock.createComponentDropDown(this);this.componentDropDown.setValue(this.instanceName);this.appendDummyInput().appendField(this.componentDropDown,Blockly.ComponentBlock.COMPONENT_SELECTOR);this.setOutput(!0,[this.typeName,"COMPONENT","Key"]);this.errors=[{name:"checkIfUndefinedBlock"},{name:"checkComponentNotExistsError"}]},getTypeName:function(){return"Form"===this.typeName?"Screen":this.typeName},rename:function(d,e){return this.instanceName==d?(this.instanceName=e,this.componentDropDown.setValue(this.instanceName),
!0):!1},typeblock:function(){var d=[];Blockly.common.getMainWorkspace().getComponentDatabase().forEachInstance(function(e){d.push({translatedName:e.name,mutatorAttributes:{component_type:e.typeName,instance_name:e.name}})});return d},verify:function(){this.getTopWorkspace().getComponentDatabase().hasType(this.typeName)?this.notBadBlock():this.badBlock()}};
Blockly.Blocks.component_all_component_block={category:"Component",helpUrl:function(){return Blockly.ComponentBlock.HELPURLS["Form"===this.typeName?"Screen":this.typeName]},mutationToDom:function(){var d=document.createElement("mutation");d.setAttribute("component_type",this.typeName);return d},domToMutation:function(d){this.typeName=d.getAttribute("component_type");this.setColour(Blockly.ComponentBlock.COLOUR_COMPONENT);this.componentTypeDropDown=Blockly.ComponentBlock.createComponentTypeDropDown(this);
this.componentTypeDropDown.setValue(this.typeName);this.appendDummyInput().appendField(Blockly.Msg.LANG_COMPONENT_BLOCK_EVERY_COMPONENT_TITLE_EVERY).appendField(this.componentTypeDropDown,Blockly.ComponentBlock.COMPONENT_TYPE_SELECTOR);this.setOutput(!0,AI.BlockUtils.YailTypeToBlocklyType("list",AI.BlockUtils.OUTPUT));this.errors=[{name:"checkIfUndefinedBlock"},{name:"checkComponentTypeNotExistsError"}]},rename:function(d,e){return!0},typeblock:function(){var d=Blockly.common.getMainWorkspace().getComponentDatabase(),
e=[];const h=new Set;d.forEachInstance(function(k){"Form"==k.typeName||h.has(k.typeName)||(h.add(k.typeName),e.push({translatedName:Blockly.Msg.LANG_COMPONENT_BLOCK_EVERY_COMPONENT_TITLE_EVERY+" "+d.getInternationalizedComponentType(k.typeName),mutatorAttributes:{component_type:k.typeName}}))});return e},verify:function(){this.getTopWorkspace().getComponentDatabase().hasType(this.typeName)?this.notBadBlock():this.badBlock()}};Blockly.ComponentBlock.timeUnits="Years Months Weeks Days Hours Minutes Seconds Duration".split(" ");
Blockly.ComponentBlock.timeUnitsMenu=[[Blockly.Msg.TIME_YEARS,"Years"],[Blockly.Msg.TIME_MONTHS,"Months"],[Blockly.Msg.TIME_WEEKS,"Weeks"],[Blockly.Msg.TIME_DAYS,"Days"],[Blockly.Msg.TIME_HOURS,"Hours"],[Blockly.Msg.TIME_MINUTES,"Minutes"],[Blockly.Msg.TIME_SECONDS,"Seconds"],[Blockly.Msg.TIME_DURATION,"Duration"]];Blockly.ComponentBlock.clockMethodNames="AddYears AddMonths AddWeeks AddDays AddHours AddMinutes AddSeconds AddDuration".split(" ");
Blockly.ComponentBlock.isClockMethodName=function(d){return-1!=Blockly.ComponentBlock.clockMethodNames.indexOf(d)};Blockly.ComponentBlock.createComponentDropDown=function(d){var e=new AI.Blockly.FieldNoCheckDropdown([["",""]]);e.menuGenerator_=function(){return d.getTopWorkspace().getComponentDatabase().getComponentNamesByType(d.typeName)};return e};
Blockly.ComponentBlock.createComponentTypeDropDown=function(d){var e=new Blockly.FieldDropdown([["",""]]);e.menuGenerator_=function(){return d.getTopWorkspace().getComponentDatabase().getComponentTypes()};return e};Blockly.ComponentBlock.createClockAddDropDown=function(){var d=new Blockly.FieldDropdown([["",""]]);d.menuGenerator_=function(){return Blockly.ComponentBlock.timeUnitsMenu};return d};
Blockly.ComponentBlock.HELPURLS={Button:Blockly.Msg.LANG_COMPONENT_BLOCK_BUTTON_HELPURL,Canvas:Blockly.Msg.LANG_COMPONENT_BLOCK_CANVAS_HELPURL,CheckBox:Blockly.Msg.LANG_COMPONENT_BLOCK_CHECKBOX_HELPURL,Switch:Blockly.Msg.LANG_COMPONENT_BLOCK_SWITCH_HELPURL,Clock:Blockly.Msg.LANG_COMPONENT_BLOCK_CLOCK_HELPURL,Image:Blockly.Msg.LANG_COMPONENT_BLOCK_IMAGE_HELPURL,Label:Blockly.Msg.LANG_COMPONENT_BLOCK_LABEL_HELPURL,ListPicker:Blockly.Msg.LANG_COMPONENT_BLOCK_LISTPICKER_HELPURL,DatePicker:Blockly.Msg.LANG_COMPONENT_BLOCK_DATEPICKER_HELPURL,
TimePicker:Blockly.Msg.LANG_COMPONENT_BLOCK_TIMEPICKER_HELPURL,ListView:Blockly.Msg.LANG_COMPONENT_BLOCK_LISTVIEW_HELPURL,PasswordTextBox:Blockly.Msg.LANG_COMPONENT_BLOCK_PASSWORDTEXTBOX_HELPURL,Screen:Blockly.Msg.LANG_COMPONENT_BLOCK_SCREEN_HELPURL,Slider:Blockly.Msg.LANG_COMPONENT_BLOCK_SLIDER_HELPURL,TextBox:Blockly.Msg.LANG_COMPONENT_BLOCK_TEXTBOX_HELPURL,TinyDB:Blockly.Msg.LANG_COMPONENT_BLOCK_TINYDB_HELPURL,Camcorder:Blockly.Msg.LANG_COMPONENT_BLOCK_CAMCORDER_HELPURL,Camera:Blockly.Msg.LANG_COMPONENT_BLOCK_CAMERA_HELPURL,
ImagePicker:Blockly.Msg.LANG_COMPONENT_BLOCK_IMAGEPICKER_HELPURL,Player:Blockly.Msg.LANG_COMPONENT_BLOCK_PLAYER_HELPURL,Sound:Blockly.Msg.LANG_COMPONENT_BLOCK_SOUND_HELPURL,VideoPlayer:Blockly.Msg.LANG_COMPONENT_BLOCK_VIDEOPLAYER_HELPURL,Ball:Blockly.Msg.LANG_COMPONENT_BLOCK_BALL_HELPURL,ImageSprite:Blockly.Msg.LANG_COMPONENT_BLOCK_IMAGESPRITE_HELPURL,Map:Blockly.Msg.LANG_COMPONENT_BLOCK_MAPS_HELPURL,Circle:Blockly.Msg.LANG_COMPONENT_BLOCK_MAPS_CIRCLE_HELPURL,FeatureCollection:Blockly.Msg.LANG_COMPONENT_BLOCK_MAPS_FEATURECOLLECTION_HELPURL,
LineString:Blockly.Msg.LANG_COMPONENT_BLOCK_MAPS_LINESTRING_HELPURL,Marker:Blockly.Msg.LANG_COMPONENT_BLOCK_MAPS_MARKER_HELPURL,Navigation:Blockly.Msg.LANG_COMPONENT_BLOCK_MAPS_NAVIGATION_HELPURL,Polygon:Blockly.Msg.LANG_COMPONENT_BLOCK_MAPS_POLYGON_HELPURL,Rectangle:Blockly.Msg.LANG_COMPONENT_BLOCK_MAPS_RECTANGLE_HELPURL,Chart:Blockly.Msg.LANG_COMPONENT_BLOCK_CHART_HELPURL,ChartData2D:Blockly.Msg.LANG_COMPONENT_BLOCK_CHARTDATA2D_HELPURL,AnomalyDetection:Blockly.Msg.LANG_COMPONENT_BLOCK_ANOMALYDETECTION_HELPURL,
Regression:Blockly.Msg.LANG_COMPONENT_BLOCK_REGRESSION_HELPURL,ContactPicker:Blockly.Msg.LANG_COMPONENT_BLOCK_CONTACTPICKER_HELPURL,EmailPicker:Blockly.Msg.LANG_COMPONENT_BLOCK_EMAILPICKER_HELPURL,CloudDB:Blockly.Msg.LANG_COMPONENT_BLOCK_CLOUDDB_HELPURL,FirebaseDB:Blockly.Msg.LANG_COMPONENT_BLOCK_FIREBASE_HELPURL,PhoneCall:Blockly.Msg.LANG_COMPONENT_BLOCK_PHONECALL_HELPURL,PhoneNumberPicker:Blockly.Msg.LANG_COMPONENT_BLOCK_PHONENUMBERPICKER_HELPURL,Sharing:Blockly.Msg.LANG_COMPONENT_BLOCK_SHARING_HELPURL,
Texting:Blockly.Msg.LANG_COMPONENT_BLOCK_TEXTING_HELPURL,Twitter:Blockly.Msg.LANG_COMPONENT_BLOCK_TWITTER_HELPURL,AccelerometerSensor:Blockly.Msg.LANG_COMPONENT_BLOCK_ACCELEROMETERSENSOR_HELPURL,Barometer:Blockly.Msg.LANG_COMPONENT_BLOCK_BAROMETER_HELPURL,GyroscopeSensor:Blockly.Msg.LANG_COMPONENT_BLOCK_GYROSCOPESENSOR_HELPURL,Hygrometer:Blockly.Msg.LANG_COMPONENT_BLOCK_HYGROMETER_HELPURL,LightSensor:Blockly.Msg.LANG_COMPONENT_BLOCK_LIGHTSENSOR_HELPURL,LocationSensor:Blockly.Msg.LANG_COMPONENT_BLOCK_LOCATIONSENSOR_HELPURL,
NearField:Blockly.Msg.LANG_COMPONENT_BLOCK_NEARFIELDSENSOR_HELPURL,OrientationSensor:Blockly.Msg.LANG_COMPONENT_BLOCK_ORIENTATIONSENSOR_HELPURL,Pedometer:Blockly.Msg.LANG_COMPONENT_BLOCK_PEDOMETERSENSOR_HELPURL,ProximitySensor:Blockly.Msg.LANG_COMPONENT_BLOCK_PROXIMITYSENSOR_HELPURL,Thermometer:Blockly.Msg.LANG_COMPONENT_BLOCK_THERMOMETER_HELPURL,HorizontalArrangement:Blockly.Msg.LANG_COMPONENT_BLOCK_HORIZARRANGE_HELPURL,HorizontalScrollArrangement:Blockly.Msg.LANG_COMPONENT_BLOCK_HORIZSCROLLARRANGE_HELPURL,
TableArrangement:Blockly.Msg.LANG_COMPONENT_BLOCK_TABLEARRANGE_HELPURL,VerticalArrangement:Blockly.Msg.LANG_COMPONENT_BLOCK_VERTARRANGE_HELPURL,VerticalScrollArrangement:Blockly.Msg.LANG_COMPONENT_BLOCK_VERTSCROLLARRANGE_HELPURL,NxtColorSensor:Blockly.Msg.LANG_COMPONENT_BLOCK_NXTCOLOR_HELPURL,NxtDirectCommands:Blockly.Msg.LANG_COMPONENT_BLOCK_NXTDIRECT_HELPURL,NxtDrive:Blockly.Msg.LANG_COMPONENT_BLOCK_NXTDRIVE_HELPURL,NxtLightSensor:Blockly.Msg.LANG_COMPONENT_BLOCK_NXTLIGHT_HELPURL,NxtSoundSensor:Blockly.Msg.LANG_COMPONENT_BLOCK_NXTSOUND_HELPURL,
NxtTouchSensor:Blockly.Msg.LANG_COMPONENT_BLOCK_NXTTOUCH_HELPURL,NxtUltrasonicSensor:Blockly.Msg.LANG_COMPONENT_BLOCK_NXTULTRASONIC_HELPURL,Ev3Motors:Blockly.Msg.LANG_COMPONENT_BLOCK_EV3MOTORS_HELPURL,Ev3ColorSensor:Blockly.Msg.LANG_COMPONENT_BLOCK_EV3COLORSENSOR_HELPURL,Ev3GyroSensor:Blockly.Msg.LANG_COMPONENT_BLOCK_EV3GYROSENSOR_HELPURL,Ev3TouchSensor:Blockly.Msg.LANG_COMPONENT_BLOCK_EV3TOUCHSENSOR_HELPURL,Ev3UltrasonicSensor:Blockly.Msg.LANG_COMPONENT_BLOCK_EV3ULTRASONICSENSOR_HELPURL,Ev3UI:Blockly.Msg.LANG_COMPONENT_BLOCK_EV3UI_HELPURL,
Ev3Sound:Blockly.Msg.LANG_COMPONENT_BLOCK_EV3SOUND_HELPURL,Ev3Commands:Blockly.Msg.LANG_COMPONENT_BLOCK_EV3COMMANDS_HELPURL,ActivityStarter:Blockly.Msg.LANG_COMPONENT_BLOCK_ACTIVITYSTARTER_HELPURL,BarcodeScanner:Blockly.Msg.LANG_COMPONENT_BLOCK_BARCODESCANNER_HELPURL,BluetoothClient:Blockly.Msg.LANG_COMPONENT_BLOCK_BLUETOOTHCLIENT_HELPURL,BluetoothServer:Blockly.Msg.LANG_COMPONENT_BLOCK_BLUETOOTHSERVER_HELPURL,Notifier:Blockly.Msg.LANG_COMPONENT_BLOCK_NOTIFIER_HELPURL,Serial:Blockly.Msg.LANG_COMPONENT_BLOCK_SERIAL_HELPURL,
SpeechRecognizer:Blockly.Msg.LANG_COMPONENT_BLOCK_SPEECHRECOGNIZER_HELPURL,TextToSpeech:Blockly.Msg.LANG_COMPONENT_BLOCK_TEXTTOSPEECH_HELPURL,TinyWebDB:Blockly.Msg.LANG_COMPONENT_BLOCK_TINYWEBDB_HELPURL,Web:Blockly.Msg.LANG_COMPONENT_BLOCK_WEB_HELPURL,File:Blockly.Msg.LANG_COMPONENT_BLOCK_FILE_HELPURL,FusiontablesControl:Blockly.Msg.LANG_COMPONENT_BLOCK_FUSIONTABLESCONTROL_HELPURL,Spreadsheet:Blockly.Msg.LANG_COMPONENT_BLOCK_SPREADSHEET_HELPURL,GameClient:Blockly.Msg.LANG_COMPONENT_BLOCK_GAMECLIENT_HELPURL,
SoundRecorder:Blockly.Msg.LANG_COMPONENT_BLOCK_SOUNDRECORDER_HELPURL,Voting:Blockly.Msg.LANG_COMPONENT_BLOCK_VOTING_HELPURL,WebViewer:Blockly.Msg.LANG_COMPONENT_BLOCK_WEBVIEWER_HELPURL};
Blockly.ComponentBlock.PROPERTIES_HELPURLS={Button:Blockly.Msg.LANG_COMPONENT_BLOCK_BUTTON_PROPERTIES_HELPURL,Canvas:Blockly.Msg.LANG_COMPONENT_BLOCK_CANVAS_PROPERTIES_HELPURL,CheckBox:Blockly.Msg.LANG_COMPONENT_BLOCK_CHECKBOX_PROPERTIES_HELPURL,Switch:Blockly.Msg.LANG_COMPONENT_BLOCK_SWITCH_HELPURL,Clock:Blockly.Msg.LANG_COMPONENT_BLOCK_CLOCK_PROPERTIES_HELPURL,Image:Blockly.Msg.LANG_COMPONENT_BLOCK_IMAGE_PROPERTIES_HELPURL,Label:Blockly.Msg.LANG_COMPONENT_BLOCK_LABEL_PROPERTIES_HELPURL,ListPicker:Blockly.Msg.LANG_COMPONENT_BLOCK_LISTPICKER_PROPERTIES_HELPURL,
DatePicker:Blockly.Msg.LANG_COMPONENT_BLOCK_DATEPICKER_HELPURL,TimePicker:Blockly.Msg.LANG_COMPONENT_BLOCK_TIMEPICKER_HELPURL,ListView:Blockly.Msg.LANG_COMPONENT_BLOCK_LISTVIEW_HELPURL,PasswordTextBox:Blockly.Msg.LANG_COMPONENT_BLOCK_PASSWORDTEXTBOX_PROPERTIES_HELPURL,Screen:Blockly.Msg.LANG_COMPONENT_BLOCK_SCREEN_PROPERTIES_HELPURL,Slider:Blockly.Msg.LANG_COMPONENT_BLOCK_SLIDER_PROPERTIES_HELPURL,Spinner:Blockly.Msg.LANG_COMPONENT_BLOCK_SPINNER_HELPURL,TextBox:Blockly.Msg.LANG_COMPONENT_BLOCK_TEXTBOX_PROPERTIES_HELPURL,
TinyDB:Blockly.Msg.LANG_COMPONENT_BLOCK_TINYDB_PROPERTIES_HELPURL,Camcorder:Blockly.Msg.LANG_COMPONENT_BLOCK_CAMCORDER_PROPERTIES_HELPURL,Camera:Blockly.Msg.LANG_COMPONENT_BLOCK_CAMERA_PROPERTIES_HELPURL,ImagePicker:Blockly.Msg.LANG_COMPONENT_BLOCK_IMAGEPICKER_PROPERTIES_HELPURL,Player:Blockly.Msg.LANG_COMPONENT_BLOCK_PLAYER_PROPERTIES_HELPURL,Sound:Blockly.Msg.LANG_COMPONENT_BLOCK_SOUND_PROPERTIES_HELPURL,VideoPlayer:Blockly.Msg.LANG_COMPONENT_BLOCK_VIDEOPLAYER_PROPERTIES_HELPURL,Ball:Blockly.Msg.LANG_COMPONENT_BLOCK_BALL_PROPERTIES_HELPURL,
ImageSprite:Blockly.Msg.LANG_COMPONENT_BLOCK_IMAGESPRITE_PROPERTIES_HELPURL,Map:Blockly.Msg.LANG_COMPONENT_BLOCK_MAPS_HELPURL,Chart:Blockly.Msg.LANG_COMPONENT_BLOCK_CHART_HELPURL,ChartData2D:Blockly.Msg.LANG_COMPONENT_BLOCK_CHARTDATA2D_HELPURL,AnomalyDetection:Blockly.Msg.LANG_COMPONENT_BLOCK_ANOMALYDETECTION_HELPURL,Regression:Blockly.Msg.LANG_COMPONENT_BLOCK_REGRESSION_HELPURL,Circle:Blockly.Msg.LANG_COMPONENT_BLOCK_MAPS_CIRCLE_HELPURL,FeatureCollection:Blockly.Msg.LANG_COMPONENT_BLOCK_MAPS_FEATURECOLLECTION_HELPURL,
LineString:Blockly.Msg.LANG_COMPONENT_BLOCK_MAPS_LINESTRING_HELPURL,Marker:Blockly.Msg.LANG_COMPONENT_BLOCK_MAPS_MARKER_HELPURL,Navigation:Blockly.Msg.LANG_COMPONENT_BLOCK_MAPS_NAVIGATION_HELPURL,Polygon:Blockly.Msg.LANG_COMPONENT_BLOCK_MAPS_POLYGON_HELPURL,Rectangle:Blockly.Msg.LANG_COMPONENT_BLOCK_MAPS_RECTANGLE_HELPURL,ContactPicker:Blockly.Msg.LANG_COMPONENT_BLOCK_CONTACTPICKER_PROPERTIES_HELPURL,EmailPicker:Blockly.Msg.LANG_COMPONENT_BLOCK_EMAILPICKER_PROPERTIES_HELPURL,CloudDB:Blockly.Msg.LANG_COMPONENT_BLOCK_CLOUDDB_HELPURL,
FirebaseDB:Blockly.Msg.LANG_COMPONENT_BLOCK_FIREBASE_PROPERTIES_HELPURL,PhoneCall:Blockly.Msg.LANG_COMPONENT_BLOCK_PHONECALL_PROPERTIES_HELPURL,PhoneNumberPicker:Blockly.Msg.LANG_COMPONENT_BLOCK_PHONENUMBERPICKER_PROPERTIES_HELPURL,Sharing:Blockly.Msg.LANG_COMPONENT_BLOCK_SHARING_HELPURL,Texting:Blockly.Msg.LANG_COMPONENT_BLOCK_TEXTING_PROPERTIES_HELPURL,Twitter:Blockly.Msg.LANG_COMPONENT_BLOCK_TWITTER_PROPERTIES_HELPURL,AccelerometerSensor:Blockly.Msg.LANG_COMPONENT_BLOCK_ACCELEROMETERSENSOR_PROPERTIES_HELPURL,
Barometer:Blockly.Msg.LANG_COMPONENT_BLOCK_BAROMETER_HELPURL,GyroscopeSensor:Blockly.Msg.LANG_COMPONENT_BLOCK_GYROSCOPESENSOR_PROPERTIES_HELPURL,Hygrometer:Blockly.Msg.LANG_COMPONENT_BLOCK_HYGROMETER_HELPURL,LightSensor:Blockly.Msg.LANG_COMPONENT_BLOCK_LIGHTSENSOR_HELPURL,LocationSensor:Blockly.Msg.LANG_COMPONENT_BLOCK_LOCATIONSENSOR_PROPERTIES_HELPURL,NearField:Blockly.Msg.LANG_COMPONENT_BLOCK_NEARFIELDSENSOR_HELPURL,OrientationSensor:Blockly.Msg.LANG_COMPONENT_BLOCK_ORIENTATIONSENSOR_PROPERTIES_HELPURL,
Pedometer:Blockly.Msg.LANG_COMPONENT_BLOCK_PEDOMETERSENSOR_HELPURL,ProximitySensor:Blockly.Msg.LANG_COMPONENT_BLOCK_PROXIMITYSENSOR_HELPURL,Thermometer:Blockly.Msg.LANG_COMPONENT_BLOCK_THERMOMETER_HELPURL,HorizontalArrangement:Blockly.Msg.LANG_COMPONENT_BLOCK_HORIZARRANGE_HELPURL,HorizontalScrollArrangement:Blockly.Msg.LANG_COMPONENT_BLOCK_HORIZSCROLLARRANGE_HELPURL,TableArrangement:Blockly.Msg.LANG_COMPONENT_BLOCK_TABLEARRANGE_PROPERTIES_HELPURL,VerticalArrangement:Blockly.Msg.LANG_COMPONENT_BLOCK_VERTARRANGE_PROPERTIES_HELPURL,
VerticalScrollArrangement:Blockly.Msg.LANG_COMPONENT_BLOCK_VERTSCROLLARRANGE_HELPURL,NxtColorSensor:Blockly.Msg.LANG_COMPONENT_BLOCK_NXTCOLOR_PROPERTIES_HELPURL,NxtDirectCommands:Blockly.Msg.LANG_COMPONENT_BLOCK_NXTDIRECT_PROPERTIES_HELPURL,NxtDrive:Blockly.Msg.LANG_COMPONENT_BLOCK_NXTDRIVE_PROPERTIES_HELPURL,NxtLightSensor:Blockly.Msg.LANG_COMPONENT_BLOCK_NXTLIGHT_PROPERTIES_HELPURL,NxtSoundSensor:Blockly.Msg.LANG_COMPONENT_BLOCK_NXTSOUND_PROPERTIES_HELPURL,NxtTouchSensor:Blockly.Msg.LANG_COMPONENT_BLOCK_NXTTOUCH_PROPERTIES_HELPURL,
NxtUltrasonicSensor:Blockly.Msg.LANG_COMPONENT_BLOCK_NXTULTRASONIC_PROPERTIES_HELPURL,Ev3Motors:Blockly.Msg.LANG_COMPONENT_BLOCK_EV3MOTORS_HELPURL,Ev3ColorSensor:Blockly.Msg.LANG_COMPONENT_BLOCK_EV3COLORSENSOR_HELPURL,Ev3GyroSensor:Blockly.Msg.LANG_COMPONENT_BLOCK_EV3GYROSENSOR_HELPURL,Ev3TouchSensor:Blockly.Msg.LANG_COMPONENT_BLOCK_EV3TOUCHSENSOR_HELPURL,Ev3UltrasonicSensor:Blockly.Msg.LANG_COMPONENT_BLOCK_EV3ULTRASONICSENSOR_HELPURL,Ev3UI:Blockly.Msg.LANG_COMPONENT_BLOCK_EV3UI_HELPURL,Ev3Sound:Blockly.Msg.LANG_COMPONENT_BLOCK_EV3SOUND_HELPURL,
Ev3Commands:Blockly.Msg.LANG_COMPONENT_BLOCK_EV3COMMANDS_HELPURL,ActivityStarter:Blockly.Msg.LANG_COMPONENT_BLOCK_ACTIVITYSTARTER_PROPERTIES_HELPURL,BarcodeScanner:Blockly.Msg.LANG_COMPONENT_BLOCK_BARCODESCANNER_PROPERTIES_HELPURL,BluetoothClient:Blockly.Msg.LANG_COMPONENT_BLOCK_BLUETOOTHCLIENT_PROPERTIES_HELPURL,BluetoothServer:Blockly.Msg.LANG_COMPONENT_BLOCK_BLUETOOTHSERVER_PROPERTIES_HELPURL,Notifier:Blockly.Msg.LANG_COMPONENT_BLOCK_NOTIFIER_PROPERTIES_HELPURL,Serial:Blockly.Msg.LANG_COMPONENT_BLOCK_SERIAL_PROPERTIES_HELPURL,
SpeechRecognizer:Blockly.Msg.LANG_COMPONENT_BLOCK_SPEECHRECOGNIZER_PROPERTIES_HELPURL,TextToSpeech:Blockly.Msg.LANG_COMPONENT_BLOCK_TEXTTOSPEECH_PROPERTIES_HELPURL,TinyWebDB:Blockly.Msg.LANG_COMPONENT_BLOCK_TINYWEBDB_PROPERTIES_HELPURL,Web:Blockly.Msg.LANG_COMPONENT_BLOCK_WEB_PROPERTIES_HELPURL,File:Blockly.Msg.LANG_COMPONENT_BLOCK_FILE_HELPURL,FusiontablesControl:Blockly.Msg.LANG_COMPONENT_BLOCK_FUSIONTABLESCONTROL_PROPERTIES_HELPURL,Spreadsheet:Blockly.Msg.LANG_COMPONENT_BLOCK_SPREADSHEET_PROPERTIES_HELPURL,
GameClient:Blockly.Msg.LANG_COMPONENT_BLOCK_GAMECLIENT_PROPERTIES_HELPURL,SoundRecorder:Blockly.Msg.LANG_COMPONENT_BLOCK_SOUNDRECORDER_PROPERTIES_HELPURL,Voting:Blockly.Msg.LANG_COMPONENT_BLOCK_VOTING_PROPERTIES_HELPURL,WebViewer:Blockly.Msg.LANG_COMPONENT_BLOCK_WEBVIEWER_PROPERTIES_HELPURL};
Blockly.ComponentBlock.EVENTS_HELPURLS={Button:Blockly.Msg.LANG_COMPONENT_BLOCK_BUTTON_EVENTS_HELPURL,Canvas:Blockly.Msg.LANG_COMPONENT_BLOCK_CANVAS_EVENTS_HELPURL,Clock:Blockly.Msg.LANG_COMPONENT_BLOCK_CLOCK_EVENTS_HELPURL,CheckBox:Blockly.Msg.LANG_COMPONENT_BLOCK_CHECKBOX_EVENTS_HELPURL,Switch:Blockly.Msg.LANG_COMPONENT_BLOCK_SWITCH_HELPURL,Image:Blockly.Msg.LANG_COMPONENT_BLOCK_IMAGE_EVENTS_HELPURL,Label:Blockly.Msg.LANG_COMPONENT_BLOCK_LABEL_EVENTS_HELPURL,ListPicker:Blockly.Msg.LANG_COMPONENT_BLOCK_LISTPICKER_EVENTS_HELPURL,
DatePicker:Blockly.Msg.LANG_COMPONENT_BLOCK_DATEPICKER_HELPURL,TimePicker:Blockly.Msg.LANG_COMPONENT_BLOCK_TIMEPICKER_HELPURL,ListView:Blockly.Msg.LANG_COMPONENT_BLOCK_LISTVIEW_HELPURL,PasswordTextBox:Blockly.Msg.LANG_COMPONENT_BLOCK_PASSWORDTEXTBOX_EVENTS_HELPURL,Screen:Blockly.Msg.LANG_COMPONENT_BLOCK_SCREEN_EVENTS_HELPURL,Slider:Blockly.Msg.LANG_COMPONENT_BLOCK_SLIDER_EVENTS_HELPURL,Spinner:Blockly.Msg.LANG_COMPONENT_BLOCK_SPINNER_HELPURL,TextBox:Blockly.Msg.LANG_COMPONENT_BLOCK_TEXTBOX_EVENTS_HELPURL,
TinyDB:Blockly.Msg.LANG_COMPONENT_BLOCK_TINYDB_EVENTS_HELPURL,Camcorder:Blockly.Msg.LANG_COMPONENT_BLOCK_CAMCORDER_EVENTS_HELPURL,Camera:Blockly.Msg.LANG_COMPONENT_BLOCK_CAMERA_EVENTS_HELPURL,ImagePicker:Blockly.Msg.LANG_COMPONENT_BLOCK_IMAGEPICKER_EVENTS_HELPURL,Player:Blockly.Msg.LANG_COMPONENT_BLOCK_PLAYER_EVENTS_HELPURL,Sound:Blockly.Msg.LANG_COMPONENT_BLOCK_SOUND_EVENTS_HELPURL,VideoPlayer:Blockly.Msg.LANG_COMPONENT_BLOCK_VIDEOPLAYER_EVENTS_HELPURL,Ball:Blockly.Msg.LANG_COMPONENT_BLOCK_BALL_EVENTS_HELPURL,
ImageSprite:Blockly.Msg.LANG_COMPONENT_BLOCK_IMAGESPRITE_EVENTS_HELPURL,Map:Blockly.Msg.LANG_COMPONENT_BLOCK_MAPS_HELPURL,Chart:Blockly.Msg.LANG_COMPONENT_BLOCK_CHART_HELPURL,ChartData2D:Blockly.Msg.LANG_COMPONENT_BLOCK_CHARTDATA2D_HELPURL,AnomalyDetection:Blockly.Msg.LANG_COMPONENT_BLOCK_ANOMALYDETECTION_HELPURL,Regression:Blockly.Msg.LANG_COMPONENT_BLOCK_REGRESSION_HELPURL,Circle:Blockly.Msg.LANG_COMPONENT_BLOCK_MAPS_CIRCLE_HELPURL,FeatureCollection:Blockly.Msg.LANG_COMPONENT_BLOCK_MAPS_FEATURECOLLECTION_HELPURL,
LineString:Blockly.Msg.LANG_COMPONENT_BLOCK_MAPS_LINESTRING_HELPURL,Marker:Blockly.Msg.LANG_COMPONENT_BLOCK_MAPS_MARKER_HELPURL,Navigation:Blockly.Msg.LANG_COMPONENT_BLOCK_MAPS_NAVIGATION_HELPURL,Polygon:Blockly.Msg.LANG_COMPONENT_BLOCK_MAPS_POLYGON_HELPURL,Rectangle:Blockly.Msg.LANG_COMPONENT_BLOCK_MAPS_RECTANGLE_HELPURL,ContactPicker:Blockly.Msg.LANG_COMPONENT_BLOCK_CONTACTPICKER_EVENTS_HELPURL,EmailPicker:Blockly.Msg.LANG_COMPONENT_BLOCK_EMAILPICKER_EVENTS_HELPURL,CloudDB:Blockly.Msg.LANG_COMPONENT_BLOCK_CLOUDDB_HELPURL,
FirebaseDB:Blockly.Msg.LANG_COMPONENT_BLOCK_FIREBASE_EVENTS_HELPURL,PhoneCall:Blockly.Msg.LANG_COMPONENT_BLOCK_PHONECALL_EVENTS_HELPURL,PhoneNumberPicker:Blockly.Msg.LANG_COMPONENT_BLOCK_PHONENUMBERPICKER_EVENTS_HELPURL,Sharing:Blockly.Msg.LANG_COMPONENT_BLOCK_SHARING_HELPURL,Texting:Blockly.Msg.LANG_COMPONENT_BLOCK_TEXTING_EVENTS_HELPURL,Twitter:Blockly.Msg.LANG_COMPONENT_BLOCK_TWITTER_EVENTS_HELPURL,AccelerometerSensor:Blockly.Msg.LANG_COMPONENT_BLOCK_ACCELEROMETERSENSOR_EVENTS_HELPURL,Barometer:Blockly.Msg.LANG_COMPONENT_BLOCK_BAROMETER_HELPURL,
GyroscopeSensor:Blockly.Msg.LANG_COMPONENT_BLOCK_GYROSCOPESENSOR_EVENTS_HELPURL,Hygrometer:Blockly.Msg.LANG_COMPONENT_BLOCK_HYGROMETER_HELPURL,LightSensor:Blockly.Msg.LANG_COMPONENT_BLOCK_LIGHTSENSOR_HELPURL,LocationSensor:Blockly.Msg.LANG_COMPONENT_BLOCK_LOCATIONSENSOR_EVENTS_HELPURL,NearField:Blockly.Msg.LANG_COMPONENT_BLOCK_NEARFIELDSENSOR_HELPURL,OrientationSensor:Blockly.Msg.LANG_COMPONENT_BLOCK_ORIENTATIONSENSOR_EVENTS_HELPURL,Pedometer:Blockly.Msg.LANG_COMPONENT_BLOCK_PEDOMETERSENSOR_HELPURL,
ProximitySensor:Blockly.Msg.LANG_COMPONENT_BLOCK_PROXIMITYSENSOR_HELPURL,Thermometer:Blockly.Msg.LANG_COMPONENT_BLOCK_THERMOMETER_HELPURL,NxtColorSensor:Blockly.Msg.LANG_COMPONENT_BLOCK_NXTCOLOR_EVENTS_HELPURL,NxtLightSensor:Blockly.Msg.LANG_COMPONENT_BLOCK_NXTLIGHT_EVENTS_HELPURL,NxtSoundSensor:Blockly.Msg.LANG_COMPONENT_BLOCK_NXTSOUND_EVENTS_HELPURL,NxtTouchSensor:Blockly.Msg.LANG_COMPONENT_BLOCK_NXTTOUCH_EVENTS_HELPURL,NxtUltrasonicSensor:Blockly.Msg.LANG_COMPONENT_BLOCK_NXTULTRASONIC_EVENTS_HELPURL,
Ev3Motors:Blockly.Msg.LANG_COMPONENT_BLOCK_EV3MOTORS_HELPURL,Ev3ColorSensor:Blockly.Msg.LANG_COMPONENT_BLOCK_EV3COLORSENSOR_HELPURL,Ev3GyroSensor:Blockly.Msg.LANG_COMPONENT_BLOCK_EV3GYROSENSOR_HELPURL,Ev3TouchSensor:Blockly.Msg.LANG_COMPONENT_BLOCK_EV3TOUCHSENSOR_HELPURL,Ev3UltrasonicSensor:Blockly.Msg.LANG_COMPONENT_BLOCK_EV3ULTRASONICSENSOR_HELPURL,Ev3UI:Blockly.Msg.LANG_COMPONENT_BLOCK_EV3UI_HELPURL,Ev3Sound:Blockly.Msg.LANG_COMPONENT_BLOCK_EV3SOUND_HELPURL,Ev3Commands:Blockly.Msg.LANG_COMPONENT_BLOCK_EV3COMMANDS_HELPURL,
ActivityStarter:Blockly.Msg.LANG_COMPONENT_BLOCK_ACTIVITYSTARTER_EVENTS_HELPURL,BarcodeScanner:Blockly.Msg.LANG_COMPONENT_BLOCK_BARCODESCANNER_EVENTS_HELPURL,BluetoothClient:Blockly.Msg.LANG_COMPONENT_BLOCK_BLUETOOTHCLIENT_EVENTS_HELPURL,BluetoothServer:Blockly.Msg.LANG_COMPONENT_BLOCK_BLUETOOTHSERVER_EVENTS_HELPURL,Notifier:Blockly.Msg.LANG_COMPONENT_BLOCK_NOTIFIER_EVENTS_HELPURL,Serial:Blockly.Msg.LANG_COMPONENT_BLOCK_SERIAL_EVENTS_HELPURL,SpeechRecognizer:Blockly.Msg.LANG_COMPONENT_BLOCK_SPEECHRECOGNIZER_EVENTS_HELPURL,
TextToSpeech:Blockly.Msg.LANG_COMPONENT_BLOCK_TEXTTOSPEECH_EVENTS_HELPURL,TinyWebDB:Blockly.Msg.LANG_COMPONENT_BLOCK_TINYWEBDB_EVENTS_HELPURL,Web:Blockly.Msg.LANG_COMPONENT_BLOCK_WEB_EVENTS_HELPURL,File:Blockly.Msg.LANG_COMPONENT_BLOCK_FILE_HELPURL,FusiontablesControl:Blockly.Msg.LANG_COMPONENT_BLOCK_FUSIONTABLESCONTROL_EVENTS_HELPURL,Spreadsheet:Blockly.Msg.LANG_COMPONENT_BLOCK_SPREADSHEET_EVENTS_HELPURL,GameClient:Blockly.Msg.LANG_COMPONENT_BLOCK_GAMECLIENT_EVENTS_HELPURL,SoundRecorder:Blockly.Msg.LANG_COMPONENT_BLOCK_SOUNDRECORDER_EVENTS_HELPURL,
Voting:Blockly.Msg.LANG_COMPONENT_BLOCK_VOTING_EVENTS_HELPURL,WebViewer:Blockly.Msg.LANG_COMPONENT_BLOCK_WEBVIEWER_EVENTS_HELPURL};
Blockly.ComponentBlock.METHODS_HELPURLS={Canvas:Blockly.Msg.LANG_COMPONENT_BLOCK_CANVAS_METHODS_HELPURL,Clock:Blockly.Msg.LANG_COMPONENT_BLOCK_CLOCK_METHODS_HELPURL,Image:Blockly.Msg.LANG_COMPONENT_BLOCK_IMAGE_METHODS_HELPURL,Label:Blockly.Msg.LANG_COMPONENT_BLOCK_LABEL_METHODS_HELPURL,ListPicker:Blockly.Msg.LANG_COMPONENT_BLOCK_LISTPICKER_METHODS_HELPURL,DatePicker:Blockly.Msg.LANG_COMPONENT_BLOCK_DATEPICKER_HELPURL,TimePicker:Blockly.Msg.LANG_COMPONENT_BLOCK_TIMEPICKER_HELPURL,ListView:Blockly.Msg.LANG_COMPONENT_BLOCK_LISTVIEW_HELPURL,
PasswordTextBox:Blockly.Msg.LANG_COMPONENT_BLOCK_PASSWORDTEXTBOX_METHODS_HELPURL,Screen:Blockly.Msg.LANG_COMPONENT_BLOCK_SCREEN_METHODS_HELPURL,Slider:Blockly.Msg.LANG_COMPONENT_BLOCK_SLIDER_METHODS_HELPURL,Spinner:Blockly.Msg.LANG_COMPONENT_BLOCK_SPINNER_HELPURL,TextBox:Blockly.Msg.LANG_COMPONENT_BLOCK_TEXTBOX_METHODS_HELPURL,TinyDB:Blockly.Msg.LANG_COMPONENT_BLOCK_TINYDB_METHODS_HELPURL,Camcorder:Blockly.Msg.LANG_COMPONENT_BLOCK_CAMCORDER_METHODS_HELPURL,Camera:Blockly.Msg.LANG_COMPONENT_BLOCK_CAMERA_METHODS_HELPURL,
ImagePicker:Blockly.Msg.LANG_COMPONENT_BLOCK_IMAGEPICKER_METHODS_HELPURL,Player:Blockly.Msg.LANG_COMPONENT_BLOCK_PLAYER_METHODS_HELPURL,Sound:Blockly.Msg.LANG_COMPONENT_BLOCK_SOUND_METHODS_HELPURL,VideoPlayer:Blockly.Msg.LANG_COMPONENT_BLOCK_VIDEOPLAYER_METHODS_HELPURL,Ball:Blockly.Msg.LANG_COMPONENT_BLOCK_BALL_METHODS_HELPURL,ImageSprite:Blockly.Msg.LANG_COMPONENT_BLOCK_IMAGESPRITE_METHODS_HELPURL,Map:Blockly.Msg.LANG_COMPONENT_BLOCK_MAPS_HELPURL,Chart:Blockly.Msg.LANG_COMPONENT_BLOCK_CHART_HELPURL,
ChartData2D:Blockly.Msg.LANG_COMPONENT_BLOCK_CHARTDATA2D_HELPURL,AnomalyDetection:Blockly.Msg.LANG_COMPONENT_BLOCK_ANOMALYDETECTION_HELPURL,Regression:Blockly.Msg.LANG_COMPONENT_BLOCK_REGRESSION_HELPURL,Circle:Blockly.Msg.LANG_COMPONENT_BLOCK_MAPS_CIRCLE_HELPURL,FeatureCollection:Blockly.Msg.LANG_COMPONENT_BLOCK_MAPS_FEATURECOLLECTION_HELPURL,LineString:Blockly.Msg.LANG_COMPONENT_BLOCK_MAPS_LINESTRING_HELPURL,Marker:Blockly.Msg.LANG_COMPONENT_BLOCK_MAPS_MARKER_HELPURL,Navigation:Blockly.Msg.LANG_COMPONENT_BLOCK_MAPS_NAVIGATION_HELPURL,
Polygon:Blockly.Msg.LANG_COMPONENT_BLOCK_MAPS_POLYGON_HELPURL,Rectangle:Blockly.Msg.LANG_COMPONENT_BLOCK_MAPS_RECTANGLE_HELPURL,ContactPicker:Blockly.Msg.LANG_COMPONENT_BLOCK_CONTACTPICKER_METHODS_HELPURL,EmailPicker:Blockly.Msg.LANG_COMPONENT_BLOCK_EMAILPICKER_METHODS_HELPURL,CloudDB:Blockly.Msg.LANG_COMPONENT_BLOCK_CLOUDDB_HELPURL,FirebaseDB:Blockly.Msg.LANG_COMPONENT_BLOCK_FIREBASE_METHODS_HELPURL,PhoneCall:Blockly.Msg.LANG_COMPONENT_BLOCK_PHONECALL_METHODS_HELPURL,PhoneNumberPicker:Blockly.Msg.LANG_COMPONENT_BLOCK_PHONENUMBERPICKER_METHODS_HELPURL,
Sharing:Blockly.Msg.LANG_COMPONENT_BLOCK_SHARING_HELPURL,Texting:Blockly.Msg.LANG_COMPONENT_BLOCK_TEXTING_METHODS_HELPURL,Twitter:Blockly.Msg.LANG_COMPONENT_BLOCK_TWITTER_METHODS_HELPURL,AccelerometerSensor:Blockly.Msg.LANG_COMPONENT_BLOCK_ACCELEROMETERSENSOR_METHODS_HELPURL,Barometer:Blockly.Msg.LANG_COMPONENT_BLOCK_BAROMETER_HELPURL,GyroscopeSensor:Blockly.Msg.LANG_COMPONENT_BLOCK_GYROSCOPESENSOR_METHODS_HELPURL,Hygrometer:Blockly.Msg.LANG_COMPONENT_BLOCK_HYGROMETER_HELPURL,LightSensor:Blockly.Msg.LANG_COMPONENT_BLOCK_LIGHTSENSOR_HELPURL,
LocationSensor:Blockly.Msg.LANG_COMPONENT_BLOCK_LOCATIONSENSOR_METHODS_HELPURL,NearField:Blockly.Msg.LANG_COMPONENT_BLOCK_NEARFIELDSENSOR_HELPURL,OrientationSensor:Blockly.Msg.LANG_COMPONENT_BLOCK_ORIENTATIONSENSOR_METHODS_HELPURL,Pedometer:Blockly.Msg.LANG_COMPONENT_BLOCK_PEDOMETERSENSOR_HELPURL,ProximitySensor:Blockly.Msg.LANG_COMPONENT_BLOCK_PROXIMITYSENSOR_HELPURL,Thermometer:Blockly.Msg.LANG_COMPONENT_BLOCK_THERMOMETER_HELPURL,NxtColorSensor:Blockly.Msg.LANG_COMPONENT_BLOCK_NXTCOLOR_METHODS_HELPURL,
NxtDirectCommands:Blockly.Msg.LANG_COMPONENT_BLOCK_NXTDIRECT_METHODS_HELPURL,NxtDrive:Blockly.Msg.LANG_COMPONENT_BLOCK_NXTDRIVE_METHODS_HELPURL,NxtLightSensor:Blockly.Msg.LANG_COMPONENT_BLOCK_NXTLIGHT_METHODS_HELPURL,NxtSoundSensor:Blockly.Msg.LANG_COMPONENT_BLOCK_NXTSOUND_METHODS_HELPURL,NxtTouchSensor:Blockly.Msg.LANG_COMPONENT_BLOCK_NXTTOUCH_METHODS_HELPURL,NxtUltrasonicSensor:Blockly.Msg.LANG_COMPONENT_BLOCK_NXTULTRASONIC_METHODS_HELPURL,Ev3Motors:Blockly.Msg.LANG_COMPONENT_BLOCK_EV3MOTORS_HELPURL,
Ev3ColorSensor:Blockly.Msg.LANG_COMPONENT_BLOCK_EV3COLORSENSOR_HELPURL,Ev3GyroSensor:Blockly.Msg.LANG_COMPONENT_BLOCK_EV3GYROSENSOR_HELPURL,Ev3TouchSensor:Blockly.Msg.LANG_COMPONENT_BLOCK_EV3TOUCHSENSOR_HELPURL,Ev3UltrasonicSensor:Blockly.Msg.LANG_COMPONENT_BLOCK_EV3ULTRASONICSENSOR_HELPURL,Ev3UI:Blockly.Msg.LANG_COMPONENT_BLOCK_EV3UI_HELPURL,Ev3Sound:Blockly.Msg.LANG_COMPONENT_BLOCK_EV3SOUND_HELPURL,Ev3Commands:Blockly.Msg.LANG_COMPONENT_BLOCK_EV3COMMANDS_HELPURL,ActivityStarter:Blockly.Msg.LANG_COMPONENT_BLOCK_ACTIVITYSTARTER_METHODS_HELPURL,
BarcodeScanner:Blockly.Msg.LANG_COMPONENT_BLOCK_BARCODESCANNER_METHODS_HELPURL,BluetoothClient:Blockly.Msg.LANG_COMPONENT_BLOCK_BLUETOOTHCLIENT_METHODS_HELPURL,BluetoothServer:Blockly.Msg.LANG_COMPONENT_BLOCK_BLUETOOTHSERVER_METHODS_HELPURL,Notifier:Blockly.Msg.LANG_COMPONENT_BLOCK_NOTIFIER_METHODS_HELPURL,Serial:Blockly.Msg.LANG_COMPONENT_BLOCK_SERIAL_METHODS_HELPURL,SpeechRecognizer:Blockly.Msg.LANG_COMPONENT_BLOCK_SPEECHRECOGNIZER_METHODS_HELPURL,TextToSpeech:Blockly.Msg.LANG_COMPONENT_BLOCK_TEXTTOSPEECH_METHODS_HELPURL,
TinyWebDB:Blockly.Msg.LANG_COMPONENT_BLOCK_TINYWEBDB_METHODS_HELPURL,Web:Blockly.Msg.LANG_COMPONENT_BLOCK_WEB_METHODS_HELPURL,File:Blockly.Msg.LANG_COMPONENT_BLOCK_FILE_HELPURL,FusiontablesControl:Blockly.Msg.LANG_COMPONENT_BLOCK_FUSIONTABLESCONTROL_METHODS_HELPURL,Spreadsheet:Blockly.Msg.LANG_COMPONENT_BLOCK_SPREADSHEET_METHODS_HELPURL,GameClient:Blockly.Msg.LANG_COMPONENT_BLOCK_GAMECLIENT_METHODS_HELPURL,SoundRecorder:Blockly.Msg.LANG_COMPONENT_BLOCK_SOUNDRECORDER_METHODS_HELPURL,Voting:Blockly.Msg.LANG_COMPONENT_BLOCK_VOTING_METHODS_HELPURL,
WebViewer:Blockly.Msg.LANG_COMPONENT_BLOCK_WEBVIEWER_METHODS_HELPURL};AI.Blockly.Mixins={};
AI.Blockly.Mixins.DynamicConnections={findInputIndexForConnection:function(d){if(!d.targetConnection||d.targetBlock().isInsertionMarker())return null;for(var e=-1,h=0,k;k=this.inputList[h];h++)if(k.connection==d){e=h;break}if(e==this.inputList.length-1)return this.inputList.length;d=this.inputList[e+1];return(d=d.connection&&d.connection.targetConnection)&&!d.getSourceBlock().isInsertionMarker()?e+1:null},onPendingConnection:function(d){d=this.findInputIndexForConnection(d);if(null!==d){this.tempinput||
(this.tempinput=this.appendValueInput("TEMPINSERT"),this.tempinput.init());var e=this.inputList.indexOf(this.tempinput);0===d?this.tempinput.fields[0]=this.inputList[0].fields.splice(0,1)[0]:0===e&&(this.inputList[0].fields[0]=this.tempinput.fields.splice(0,1)[0]);e!==d&&this.moveNumberedInputBefore(e,d)}},finalizeConnections:function(){if(this.tempinput){if(this.tempinput.connection.targetConnection){var d=this.repeatingInputName;this.inputList.forEach(function(h,k){h.name=d+k})}else this.tempinput&&
this.removeInput("TEMPINSERT");this.tempinput=void 0;for(var e=this.inputList.length-1;0<=e;e--)this.inputList[e].connection.targetConnection||this.inputList.splice(e,1);this.itemCount_=this.inputList.length}}};AI.Blockly.Mixins.LexicalVariableMethods={getDeclaredVarFieldNames:function(){return this.getDeclaredVarFieldNamesAndPrefixes().map(([d])=>d)},referenceResults:function(d,e,h){const k=this;var m=k.getDeclaredVarFieldNamesAndPrefixes().map(([t,q])=>Blockly.usePrefixInYail?(t=k.getFieldValue(t),Blockly.possiblyPrefixMenuNameWith(q)(t)):k.getFieldValue(t));const p=h.concat(m);m=k.inputList.map(t=>Blockly.LexicalVariable.referenceResult(k.getInputTargetBlock(t.name),d,e,t.name===k.getScopedInputName()?
p:h));k.nextConnection&&m.push(Blockly.LexicalVariable.referenceResult(k.getNextBlock(),d,e,h));return m},withLexicalVarsAndPrefix:function(d,e){const h=this;d&&h.getInputTargetBlock(h.getScopedInputName())===d&&h.getDeclaredVarFieldNamesAndPrefixes().forEach(([k])=>{k=h.getFieldValue(k);e(k,h.prefix)})},getVars:function(){const d=this;return d.getDeclaredVarFieldNames().map(e=>d.getFieldValue(e))},blocksInScope:function(){const d=this.getInputTargetBlock(this.getScopedInputName());return d&&[d]||
[]},declaredNames:function(){return this.getVars()},renameVar:function(d,e){const h=this;h.getDeclaredVarFieldNames().forEach(k=>{Blockly.Names.equals(d,h.getFieldValue(k))&&h.setFieldValue(e,k)})},renameBound:function(d,e){const h=this;let k=e;h.inputList.forEach(m=>{m.name===h.getScopedInputName()?(h.getDeclaredVarFieldNames().forEach(p=>{p=h.getFieldValue(p);const t=d.apply(p);t!==p?(h.renameVar(p,t),p=Blockly.Substitution.simpleSubstitution(p,t),k=e.extend(p)):k=e.remove([p])}),Blockly.LexicalVariable.renameFree(h.getInputTargetBlock(h.getScopedInputName()),
k)):Blockly.LexicalVariable.renameFree(h.getInputTargetBlock(m.name),e)});if(h.nextConnection){const m=h.nextConnection.targetBlock();Blockly.LexicalVariable.renameFree(m,e)}},renameFree:function(d){const e=this,h=Blockly.LexicalVariable.freeVariables(e.getInputTargetBlock(e.getScopedInputName())),k=new Blockly.Substitution;e.getDeclaredVarFieldNames().forEach(m=>{m=e.getFieldValue(m);h.deleteName(m);var p=h.renamed(d);p.isMember(m)&&(p=Blockly.FieldLexicalVariable.nameNotIn(m,p.toList()),m=Blockly.Substitution.simpleSubstitution(m,
p),k.extend(m))});e.renameBound(k,d)},freeVariables:function(){const d=this,e=Blockly.LexicalVariable.freeVariables(d.getInputTargetBlock(d.getScopedInputName()));d.getDeclaredVarFieldNames().forEach(k=>{e.deleteName(d.getFieldValue(k))});d.inputList.forEach(k=>{k.name!==d.getScopedInputName()&&e.unite(Blockly.LexicalVariable.freeVariables(d.getInputTargetBlock(k.name)))});if(d.nextConnection){var h=d.nextConnection.targetBlock();e.unite(Blockly.LexicalVariable.freeVariables(h))}return e}};AI.Blockly.Mixins.extend=function(d,e){for(var h in e)d[h]=e[h]};AI.Blocks.control={};
Blockly.Blocks.controls_if={category:"Control",helpUrl:Blockly.Msg.LANG_CONTROLS_IF_HELPURL,init:function(){this.setColour(Blockly.CONTROL_CATEGORY_HUE);this.appendValueInput("IF0").setCheck(AI.BlockUtils.YailTypeToBlocklyType("boolean",AI.BlockUtils.INPUT)).appendField(Blockly.Msg.LANG_CONTROLS_IF_MSG_IF);this.appendStatementInput("DO0").appendField(Blockly.Msg.LANG_CONTROLS_IF_MSG_THEN);this.setPreviousStatement(!0);this.setNextStatement(!0);this.setMutator(new Blockly.icons.MutatorIcon(["controls_if_elseif","controls_if_else"],
this));var d=this;this.setTooltip(function(){if(d.elseifCount_||d.elseCount_){if(!d.elseifCount_&&d.elseCount_)return Blockly.Msg.LANG_CONTROLS_IF_TOOLTIP_2;if(d.elseifCount_&&!d.elseCount_)return Blockly.Msg.LANG_CONTROLS_IF_TOOLTIP_3;if(d.elseifCount_&&d.elseCount_)return Blockly.Msg.LANG_CONTROLS_IF_TOOLTIP_4}else return Blockly.Msg.LANG_CONTROLS_IF_TOOLTIP_1;return""});this.elseCount_=this.elseifCount_=0;this.warnings=[{name:"checkEmptySockets",sockets:[{baseName:"IF"},{baseName:"DO"}]}]},mutationToDom:function(){if(!this.elseifCount_&&
!this.elseCount_)return null;var d=document.createElement("mutation");this.elseifCount_&&d.setAttribute("elseif",this.elseifCount_);this.elseCount_&&d.setAttribute("else",1);return d},domToMutation:function(d){this.elseifCount_=parseInt(d.getAttribute("elseif"),10)||0;this.elseCount_=window.parseInt(d.getAttribute("else"),10)||0;this.rebuildShape_()},decompose:function(d){var e=d.newBlock("controls_if_if");e.initSvg();for(var h=e.getInput("STACK").connection,k=1;k<=this.elseifCount_;k++){var m=d.newBlock("controls_if_elseif");
m.initSvg();h.connect(m.previousConnection);h=m.nextConnection}this.elseCount_&&(d=d.newBlock("controls_if_else"),d.initSvg(),h.connect(d.previousConnection));return e},compose:function(d){d=d.getInputTargetBlock("STACK");this.elseCount_=this.elseifCount_=0;for(var e=[null],h=[null],k=null;d;){switch(d.type){case "controls_if_elseif":this.elseifCount_++;e.push(d.valueConnection_);h.push(d.statementConnection_);break;case "controls_if_else":this.elseCount_++;k=d.statementConnection_;break;default:throw"Unknown block type.";
}d=d.nextConnection&&d.nextConnection.targetBlock()}this.rebuildShape_();this.reconnectChildBlocks_(e,h,k)},saveConnections:function(d){for(var e=d.getInput("STACK").connection.targetBlock(),h=1;e;){switch(e.type){case "controls_if_elseif":var k=this.getInput("IF"+h);d=this.getInput("DO"+h);e.valueConnection_=k&&k.connection.targetConnection;e.statementConnection_=d&&d.connection.targetConnection;h++;break;case "controls_if_else":d=this.getInput("ELSE");e.statementConnection_=d&&d.connection.targetConnection;
break;default:throw"Unknown block type.";}e=e.nextConnection&&e.nextConnection.targetBlock()}},typeblock:[{translatedName:Blockly.Msg.LANG_CONTROLS_IF_IF_TITLE_IF}],rebuildShape_:function(){console.log("rebuidShape");var d=[null],e=[null],h=null;this.getInput("ELSE")&&(h=this.getInput("ELSE").connection.targetConnection);for(var k=1;this.getInput("IF"+k);k++){var m=this.getInput("IF"+k),p=this.getInput("DO"+k);d.push(m.connection.targetConnection);e.push(p.connection.targetConnection)}this.updateShape_();
this.reconnectChildBlocks_(d,e,h)},reconnectChildBlocks_:function(d,e,h){for(let k=1;k<=this.elseifCount_;k++)d[k]&&d[k].reconnect(this,"IF"+k),e[k]&&e[k].reconnect(this,"DO"+k);h&&h.reconnect(this,"ELSE")},updateShape_:function(){this.getInput("ELSE")&&this.removeInput("ELSE");for(var d=1;this.getInput("IF"+d);)this.removeInput("IF"+d),this.removeInput("DO"+d),d++;for(d=1;d<=this.elseifCount_;d++)this.appendValueInput("IF"+d).setCheck(AI.BlockUtils.YailTypeToBlocklyType("boolean",AI.BlockUtils.INPUT)).appendField(Blockly.Msg.LANG_CONTROLS_IF_MSG_ELSEIF),
this.appendStatementInput("DO"+d).appendField(Blockly.Msg.LANG_CONTROLS_IF_MSG_THEN);this.elseCount_&&this.appendStatementInput("ELSE").appendField(Blockly.Msg.CONTROLS_IF_MSG_ELSE)}};Blockly.Blocks.controls_if_if={init:function(){this.setColour(Blockly.CONTROL_CATEGORY_HUE);this.appendDummyInput().appendField(Blockly.Msg.LANG_CONTROLS_IF_IF_TITLE_IF);this.appendStatementInput("STACK");this.setTooltip(Blockly.Msg.LANG_CONTROLS_IF_IF_TOOLTIP);this.contextMenu=!1}};
Blockly.Blocks.controls_if_elseif={init:function(){this.setColour(Blockly.CONTROL_CATEGORY_HUE);this.appendDummyInput().appendField(Blockly.Msg.LANG_CONTROLS_IF_ELSEIF_TITLE_ELSEIF);this.setPreviousStatement(!0);this.setNextStatement(!0);this.setTooltip(Blockly.Msg.LANG_CONTROLS_IF_ELSEIF_TOOLTIP);this.contextMenu=!1}};
Blockly.Blocks.controls_if_else={init:function(){this.setColour(Blockly.CONTROL_CATEGORY_HUE);this.appendDummyInput().appendField(Blockly.Msg.LANG_CONTROLS_IF_ELSE_TITLE_ELSE);this.setPreviousStatement(!0);this.setTooltip(Blockly.Msg.LANG_CONTROLS_IF_ELSE_TOOLTIP);this.contextMenu=!1}};
Blockly.Blocks.controls_forRange={category:"Control",helpUrl:Blockly.Msg.LANG_CONTROLS_FORRANGE_HELPURL,init:function(){this.setColour(Blockly.CONTROL_CATEGORY_HUE);this.appendValueInput("START").setCheck(AI.BlockUtils.YailTypeToBlocklyType("number",AI.BlockUtils.INPUT)).appendField(Blockly.Msg.LANG_CONTROLS_FORRANGE_INPUT_ITEM).appendField(new Blockly.FieldParameterFlydown(Blockly.Msg.LANG_CONTROLS_FORRANGE_INPUT_VAR,!0,Blockly.FieldFlydown.DISPLAY_BELOW),"VAR").appendField(Blockly.Msg.LANG_CONTROLS_FORRANGE_INPUT_START).setAlign(Blockly.inputs.Align.RIGHT);
this.appendValueInput("END").setCheck(AI.BlockUtils.YailTypeToBlocklyType("number",AI.BlockUtils.INPUT)).appendField(Blockly.Msg.LANG_CONTROLS_FORRANGE_INPUT_END).setAlign(Blockly.inputs.Align.RIGHT);this.appendValueInput("STEP").setCheck(AI.BlockUtils.YailTypeToBlocklyType("number",AI.BlockUtils.INPUT)).appendField(Blockly.Msg.LANG_CONTROLS_FORRANGE_INPUT_STEP).setAlign(Blockly.inputs.Align.RIGHT);this.appendStatementInput("DO").appendField(Blockly.Msg.LANG_CONTROLS_FORRANGE_INPUT_DO).setAlign(Blockly.inputs.Align.RIGHT);
this.setPreviousStatement(!0);this.setNextStatement(!0);this.setTooltip(Blockly.Msg.LANG_CONTROLS_FORRANGE_TOOLTIP);this.lexicalVarPrefix=Blockly.localNamePrefix},referenceResults:function(d,e,h){var k=this.getFieldValue("VAR");Blockly.usePrefixInCode&&(k=Blockly.possiblyPrefixMenuNameWith(Blockly.loopRangeParameterPrefix)(k));var m=h.concat([k]);k=Blockly.LexicalVariable.referenceResult(this.getInputTargetBlock("START"),d,e,h);const p=Blockly.LexicalVariable.referenceResult(this.getInputTargetBlock("END"),
d,e,h),t=Blockly.LexicalVariable.referenceResult(this.getInputTargetBlock("STEP"),d,e,h);m=Blockly.LexicalVariable.referenceResult(this.getInputTargetBlock("DO"),d,e,m);d=Blockly.LexicalVariable.referenceResult(Blockly.LexicalVariable.getNextTargetBlock(this),d,e,h);return[k,p,t,m,d]},withLexicalVarsAndPrefix:function(d,e){this.getInputTargetBlock("DO")==d&&(d=this.getFieldValue("VAR"),e(d,this.lexicalVarPrefix))},getVars:function(){return[this.getFieldValue("VAR")]},blocksInScope:function(){var d=
this.getInputTargetBlock("DO");return d?[d]:[]},declaredNames:function(){return[this.getFieldValue("VAR")]},renameVar:function(d,e){Blockly.Names.equals(d,this.getFieldValue("VAR"))&&this.setFieldValue(e,"VAR")},renameBound:function(d,e){Blockly.LexicalVariable.renameFree(this.getInputTargetBlock("START"),e);Blockly.LexicalVariable.renameFree(this.getInputTargetBlock("END"),e);Blockly.LexicalVariable.renameFree(this.getInputTargetBlock("STEP"),e);var h=this.getFieldValue("VAR");d=d.apply(h);d!==h?
(this.renameVar(h,d),h=Blockly.Substitution.simpleSubstitution(h,d),h=e.extend(h),Blockly.LexicalVariable.renameFree(this.getInputTargetBlock("DO"),h)):(h=e.remove([h]),Blockly.LexicalVariable.renameFree(this.getInputTargetBlock("DO"),h));this.nextConnection&&(h=this.nextConnection.targetBlock(),Blockly.LexicalVariable.renameFree(h,e))},renameFree:function(d){var e=this.getFieldValue("VAR"),h=Blockly.LexicalVariable.freeVariables(this.getInputTargetBlock("DO"));h.deleteName(e);h=h.renamed(d);h.isMember(e)?
(h=Blockly.FieldLexicalVariable.nameNotIn(e,h.toList()),e=Blockly.Substitution.simpleSubstitution(e,h),this.renameBound(e,d)):this.renameBound(new Blockly.Substitution,d)},freeVariables:function(){var d=Blockly.LexicalVariable.freeVariables(this.getInputTargetBlock("DO"));d.deleteName(this.getFieldValue("VAR"));d.unite(Blockly.LexicalVariable.freeVariables(this.getInputTargetBlock("START")));d.unite(Blockly.LexicalVariable.freeVariables(this.getInputTargetBlock("END")));d.unite(Blockly.LexicalVariable.freeVariables(this.getInputTargetBlock("STEP")));
if(this.nextConnection){var e=this.nextConnection.targetBlock();d.unite(Blockly.LexicalVariable.freeVariables(e))}return d},typeblock:[{translatedName:Blockly.Msg.LANG_CONTROLS_FOREACH_NUMBER_TYPEBLOCK}]};
Blockly.Blocks.controls_forEach={category:"Control",helpUrl:Blockly.Msg.LANG_CONTROLS_FOREACH_HELPURL,init:function(){this.setColour(Blockly.CONTROL_CATEGORY_HUE);this.appendValueInput("LIST").setCheck(AI.BlockUtils.YailTypeToBlocklyType("list",AI.BlockUtils.INPUT)).appendField(Blockly.Msg.LANG_CONTROLS_FOREACH_INPUT_ITEM).appendField(new Blockly.FieldParameterFlydown(Blockly.Msg.LANG_CONTROLS_FOREACH_INPUT_VAR,!0,Blockly.FieldFlydown.DISPLAY_BELOW),"VAR").appendField(Blockly.Msg.LANG_CONTROLS_FOREACH_INPUT_INLIST).setAlign(Blockly.inputs.Align.RIGHT);
this.appendStatementInput("DO").appendField(Blockly.Msg.LANG_CONTROLS_FOREACH_INPUT_DO);this.setPreviousStatement(!0);this.setNextStatement(!0);this.setTooltip(Blockly.Msg.LANG_CONTROLS_FOREACH_TOOLTIP)},referenceResults:function(d,e,h){var k=this.getFieldValue("VAR");Blockly.usePrefixInCode&&(k=Blockly.possiblyPrefixMenuNameWith(Blockly.loopParameterPrefix)(k));var m=h.concat([k]);k=Blockly.LexicalVariable.referenceResult(this.getInputTargetBlock("LIST"),d,e,h);m=Blockly.LexicalVariable.referenceResult(this.getInputTargetBlock("DO"),
d,e,m);d=Blockly.LexicalVariable.referenceResult(Blockly.LexicalVariable.getNextTargetBlock(this),d,e,h);return[k,m,d]},withLexicalVarsAndPrefix:Blockly.Blocks.controls_forRange.withLexicalVarsAndPrefix,getVars:function(){return[this.getFieldValue("VAR")]},blocksInScope:function(){var d=this.getInputTargetBlock("DO");return d?[d]:[]},declaredNames:function(){return[this.getFieldValue("VAR")]},renameVar:function(d,e){Blockly.Names.equals(d,this.getFieldValue("VAR"))&&this.setFieldValue(e,"VAR")},renameBound:function(d,
e){Blockly.LexicalVariable.renameFree(this.getInputTargetBlock("LIST"),e);var h=this.getFieldValue("VAR");d=d.apply(h);d!==h?(this.renameVar(h,d),h=Blockly.Substitution.simpleSubstitution(h,d),h=e.extend(h),Blockly.LexicalVariable.renameFree(this.getInputTargetBlock("DO"),h)):(h=e.remove([h]),Blockly.LexicalVariable.renameFree(this.getInputTargetBlock("DO"),h));this.nextConnection&&(h=this.nextConnection.targetBlock(),Blockly.LexicalVariable.renameFree(h,e))},renameFree:function(d){var e=this.getFieldValue("VAR"),
h=Blockly.LexicalVariable.freeVariables(this.getInputTargetBlock("DO"));h.deleteName(e);h=h.renamed(d);h.isMember(e)?(h=Blockly.FieldLexicalVariable.nameNotIn(e,h.toList()),e=Blockly.Substitution.simpleSubstitution(e,h),this.renameBound(e,d)):this.renameBound(new Blockly.Substitution,d)},freeVariables:function(){var d=Blockly.LexicalVariable.freeVariables(this.getInputTargetBlock("DO"));d.deleteName(this.getFieldValue("VAR"));d.unite(Blockly.LexicalVariable.freeVariables(this.getInputTargetBlock("LIST")));
if(this.nextConnection){var e=this.nextConnection.targetBlock();d.unite(Blockly.LexicalVariable.freeVariables(e))}return d},typeblock:[{translatedName:Blockly.Msg.LANG_CONTROLS_FOREACH_ITEM_TYPEBLOCK}]};
Blockly.Blocks.controls_for_each_dict={category:"Control",helpUrl:Blockly.Msg.LANG_CONTROLS_FOREACH_DICT_HELPURL,init:function(){this.setColour(Blockly.CONTROL_CATEGORY_HUE);var d=AI.BlockUtils.YailTypeToBlocklyType("dictionary",AI.BlockUtils.INPUT),e=new Blockly.FieldParameterFlydown(Blockly.Msg.LANG_CONTROLS_FOREACH_DICT_INPUT_KEY,!0,Blockly.FieldFlydown.DISPLAY_BELOW),h=new Blockly.FieldParameterFlydown(Blockly.Msg.LANG_CONTROLS_FOREACH_DICT_INPUT_VALUE,!0,Blockly.FieldFlydown.DISPLAY_BELOW);this.interpolateMsg(Blockly.Msg.LANG_CONTROLS_FOREACH_DICT_INPUT,
["KEY",e],["VALUE",h],["DICT",d,Blockly.inputs.Align.LEFT],Blockly.inputs.Align.LEFT);this.appendStatementInput("DO").appendField(Blockly.Msg.LANG_CONTROLS_FOREACH_DICT_INPUT_DO);this.setInputsInline(!1);this.setPreviousStatement(!0);this.setNextStatement(!0);this.setTooltip(Blockly.Msg.LANG_CONTROLS_FOREACH_DICT_TOOLTIP);this.lexicalVarPrefix=Blockly.localNamePrefix},getDeclaredVarFieldNamesAndPrefixes:function(){return[["KEY","key"],["VALUE","value"]]},getScopedInputName:function(){return"DO"},
typeblock:[{translatedName:Blockly.Msg.LANG_CONTROLS_FOREACH_DICT_TITLE}]};AI.Blockly.Mixins.extend(Blockly.Blocks.controls_for_each_dict,AI.Blockly.Mixins.LexicalVariableMethods);
Blockly.Blocks.controls_while={category:"Control",helpUrl:Blockly.Msg.LANG_CONTROLS_WHILE_HELPURL,init:function(){this.setColour(Blockly.CONTROL_CATEGORY_HUE);this.appendValueInput("TEST").setCheck(AI.BlockUtils.YailTypeToBlocklyType("boolean",AI.BlockUtils.INPUT)).appendField(Blockly.Msg.LANG_CONTROLS_WHILE_TITLE).appendField(Blockly.Msg.LANG_CONTROLS_WHILE_INPUT_TEST).setAlign(Blockly.inputs.Align.RIGHT);this.appendStatementInput("DO").appendField(Blockly.Msg.LANG_CONTROLS_WHILE_INPUT_DO).setAlign(Blockly.inputs.Align.RIGHT);
this.setPreviousStatement(!0);this.setNextStatement(!0);this.setTooltip(Blockly.Msg.LANG_CONTROLS_WHILE_TOOLTIP)},typeblock:[{translatedName:Blockly.Msg.LANG_CONTROLS_WHILE_TITLE}]};
Blockly.Blocks.controls_choose={category:"Control",helpUrl:Blockly.Msg.LANG_CONTROLS_CHOOSE_HELPURL,init:function(){this.setColour(Blockly.CONTROL_CATEGORY_HUE);this.setOutput(!0,null);this.appendValueInput("TEST").setCheck(AI.BlockUtils.YailTypeToBlocklyType("boolean",AI.BlockUtils.INPUT)).appendField(Blockly.Msg.LANG_CONTROLS_CHOOSE_TITLE).appendField(Blockly.Msg.LANG_CONTROLS_CHOOSE_INPUT_TEST).setAlign(Blockly.inputs.Align.RIGHT);this.appendValueInput("THENRETURN").appendField(Blockly.Msg.LANG_CONTROLS_CHOOSE_INPUT_THEN_RETURN).setAlign(Blockly.inputs.Align.RIGHT);
this.appendValueInput("ELSERETURN").appendField(Blockly.Msg.LANG_CONTROLS_CHOOSE_INPUT_ELSE_RETURN).setAlign(Blockly.inputs.Align.RIGHT);this.setTooltip(Blockly.Msg.LANG_CONTROLS_CHOOSE_TOOLTIP)},typeblock:[{translatedName:Blockly.Msg.LANG_CONTROLS_CHOOSE_TITLE+" "+Blockly.Msg.LANG_CONTROLS_CHOOSE_INPUT_THEN_RETURN+" "+Blockly.Msg.LANG_CONTROLS_CHOOSE_INPUT_ELSE_RETURN}]};
Blockly.Blocks.controls_do_then_return={category:"Control",helpUrl:Blockly.Msg.LANG_CONTROLS_DO_THEN_RETURN_HELPURL,init:function(){this.setColour(Blockly.CONTROL_CATEGORY_HUE);this.appendStatementInput("STM").appendField(Blockly.Msg.LANG_CONTROLS_DO_THEN_RETURN_INPUT_DO);this.appendValueInput("VALUE").appendField(Blockly.Msg.LANG_CONTROLS_DO_THEN_RETURN_INPUT_RETURN).setAlign(Blockly.inputs.Align.RIGHT);this.setOutput(!0,null);this.setTooltip(Blockly.Msg.LANG_CONTROLS_DO_THEN_RETURN_TOOLTIP)},typeblock:[{translatedName:Blockly.Msg.LANG_CONTROLS_DO_THEN_RETURN_TITLE}]};
Blockly.Blocks.controls_run_in_background={helpUrl:Blockly.Msg.LANG_CONTROLS_RUN_IN_BACKGROUND_HELPURL,init:function(){this.setColour(Blockly.CONTROL_CATEGORY_HUE);this.appendDummyInput("HEADER").appendField(Blockly.Msg.LANG_CONTROLS_RUN_IN_BACKGROUND_TITLE);this.appendValueInput("PROCEDURE").setCheck(AI.BlockUtils.YailTypeToBlocklyType("procedure",AI.BlockUtils.INPUT)).appendField(Blockly.Msg.LANG_CONTROLS_RUN_IN_BACKGROUND_PROCEDURE).setAlign(Blockly.inputs.Align.RIGHT);this.appendValueInput("CALLBACK").setCheck(AI.BlockUtils.YailTypeToBlocklyType("procedure",
AI.BlockUtils.INPUT)).appendField(Blockly.Msg.LANG_CONTROLS_RUN_IN_BACKGROUND_CALLBACK).setAlign(Blockly.inputs.Align.RIGHT);this.setPreviousStatement(!0);this.setNextStatement(!0);this.setTooltip(Blockly.Msg.LANG_CONTROLS_RUN_IN_BACKGROUND_TOOLTIP)},typeblock:[{translatedName:Blockly.Msg.LANG_CONTROLS_RUN_IN_BACKGROUND_TITLE}]};
Blockly.Blocks.controls_run_after_period={helpUrl:Blockly.Msg.LANG_CONTROLS_RUN_AFTER_PERIOD_HELPURL,init:function(){this.setColour(Blockly.CONTROL_CATEGORY_HUE);this.appendDummyInput("HEADER").appendField(Blockly.Msg.LANG_CONTROLS_RUN_AFTER_PERIOD_TITLE);this.appendValueInput("MILLIS").setCheck(AI.BlockUtils.YailTypeToBlocklyType("number",AI.BlockUtils.INPUT)).appendField(Blockly.Msg.LANG_CONTROLS_RUN_AFTER_PERIOD_MILLIS).setAlign(Blockly.inputs.Align.RIGHT);this.appendValueInput("PROCEDURE").setCheck(AI.BlockUtils.YailTypeToBlocklyType("procedure",
AI.BlockUtils.INPUT)).appendField(Blockly.Msg.LANG_CONTROLS_RUN_IN_BACKGROUND_PROCEDURE).setAlign(Blockly.inputs.Align.RIGHT);this.setPreviousStatement(!0);this.setNextStatement(!0);this.setTooltip(Blockly.Msg.LANG_CONTROLS_RUN_AFTER_PERIOD_TOOLTIP)},typeblock:[{translatedName:Blockly.Msg.LANG_CONTROLS_RUN_AFTER_PERIOD_TITLE}]};
Blockly.Blocks.controls_eval_but_ignore={category:"Control",helpUrl:Blockly.Msg.LANG_CONTROLS_EVAL_BUT_IGNORE_HELPURL,init:function(){this.setColour(Blockly.CONTROL_CATEGORY_HUE);this.appendValueInput("VALUE").appendField(Blockly.Msg.LANG_CONTROLS_EVAL_BUT_IGNORE_TITLE);this.setPreviousStatement(!0);this.setNextStatement(!0);this.setTooltip(Blockly.Msg.LANG_CONTROLS_EVAL_BUT_IGNORE_TOOLTIP)},typeblock:[{translatedName:Blockly.Msg.LANG_CONTROLS_EVAL_BUT_IGNORE_TITLE}]};
Blockly.Blocks.controls_openAnotherScreen={category:"Control",helpUrl:Blockly.Msg.LANG_CONTROLS_OPEN_ANOTHER_SCREEN_HELPURL,init:function(){this.setColour(Blockly.CONTROL_CATEGORY_HUE);this.appendValueInput("SCREEN").appendField(Blockly.Msg.LANG_CONTROLS_OPEN_ANOTHER_SCREEN_TITLE).appendField(Blockly.Msg.LANG_CONTROLS_OPEN_ANOTHER_SCREEN_INPUT_SCREENNAME).setAlign(Blockly.inputs.Align.RIGHT).setCheck(AI.BlockUtils.YailTypeToBlocklyType("text",AI.BlockUtils.INPUT));this.setPreviousStatement(!0);this.setTooltip(Blockly.Msg.LANG_CONTROLS_OPEN_ANOTHER_SCREEN_TOOLTIP)},
typeblock:[{translatedName:Blockly.Msg.LANG_CONTROLS_OPEN_ANOTHER_SCREEN_TITLE}]};
Blockly.Blocks.controls_openAnotherScreenWithStartValue={category:"Control",helpUrl:Blockly.Msg.LANG_CONTROLS_OPEN_ANOTHER_SCREEN_WITH_START_VALUE_HELPURL,init:function(){this.setColour(Blockly.CONTROL_CATEGORY_HUE);this.appendValueInput("SCREENNAME").setCheck(AI.BlockUtils.YailTypeToBlocklyType("text",AI.BlockUtils.INPUT)).appendField(Blockly.Msg.LANG_CONTROLS_OPEN_ANOTHER_SCREEN_WITH_START_VALUE_TITLE).appendField(Blockly.Msg.LANG_CONTROLS_OPEN_ANOTHER_SCREEN_WITH_START_VALUE_INPUT_SCREENNAME).setAlign(Blockly.inputs.Align.RIGHT);this.appendValueInput("STARTVALUE").appendField(Blockly.Msg.LANG_CONTROLS_OPEN_ANOTHER_SCREEN_WITH_START_VALUE_INPUT_STARTVALUE).setAlign(Blockly.inputs.Align.RIGHT);
this.setPreviousStatement(!0);this.setTooltip(Blockly.Msg.LANG_CONTROLS_OPEN_ANOTHER_SCREEN_WITH_START_VALUE_TOOLTIP)},typeblock:[{translatedName:Blockly.Msg.LANG_CONTROLS_OPEN_ANOTHER_SCREEN_WITH_START_VALUE_TITLE}]};
Blockly.Blocks.controls_getStartValue={category:"Control",helpUrl:Blockly.Msg.LANG_CONTROLS_GET_START_VALUE_HELPURL,init:function(){this.setColour(Blockly.CONTROL_CATEGORY_HUE);this.setOutput(!0,null);this.appendDummyInput().appendField(Blockly.Msg.LANG_CONTROLS_GET_START_VALUE_TITLE);this.setTooltip(Blockly.Msg.LANG_CONTROLS_GET_START_VALUE_TOOLTIP)},typeblock:[{translatedName:Blockly.Msg.LANG_CONTROLS_GET_START_VALUE_TITLE}]};
Blockly.Blocks.controls_closeScreen={category:"Control",helpUrl:Blockly.Msg.LANG_CONTROLS_CLOSE_SCREEN_HELPURL,init:function(){this.setColour(Blockly.CONTROL_CATEGORY_HUE);this.appendDummyInput().appendField(Blockly.Msg.LANG_CONTROLS_CLOSE_SCREEN_TITLE);this.setPreviousStatement(!0);this.setTooltip(Blockly.Msg.LANG_CONTROLS_CLOSE_SCREEN_TOOLTIP)},typeblock:[{translatedName:Blockly.Msg.LANG_CONTROLS_CLOSE_SCREEN_TITLE}]};
Blockly.Blocks.controls_closeScreenWithValue={category:"Control",helpUrl:Blockly.Msg.LANG_CONTROLS_CLOSE_SCREEN_WITH_VALUE_HELPURL,init:function(){this.setColour(Blockly.CONTROL_CATEGORY_HUE);this.appendValueInput("SCREEN").appendField(Blockly.Msg.LANG_CONTROLS_CLOSE_SCREEN_WITH_VALUE_TITLE).appendField(Blockly.Msg.LANG_CONTROLS_CLOSE_SCREEN_WITH_VALUE_INPUT_RESULT).setAlign(Blockly.inputs.Align.RIGHT);this.setPreviousStatement(!0);this.setTooltip(Blockly.Msg.LANG_CONTROLS_CLOSE_SCREEN_WITH_VALUE_TOOLTIP)},
typeblock:[{translatedName:Blockly.Msg.LANG_CONTROLS_CLOSE_SCREEN_WITH_VALUE_TITLE}]};Blockly.Blocks.controls_closeApplication={category:"Control",helpUrl:Blockly.Msg.LANG_CONTROLS_CLOSE_APPLICATION_HELPURL,init:function(){this.setColour(Blockly.CONTROL_CATEGORY_HUE);this.appendDummyInput().appendField(Blockly.Msg.LANG_CONTROLS_CLOSE_APPLICATION_TITLE);this.setPreviousStatement(!0);this.setTooltip(Blockly.Msg.LANG_CONTROLS_CLOSE_APPLICATION_TOOLTIP)},typeblock:[{translatedName:Blockly.Msg.LANG_CONTROLS_CLOSE_APPLICATION_TITLE}]};
Blockly.Blocks.controls_getPlainStartText={category:"Control",helpUrl:Blockly.Msg.LANG_CONTROLS_GET_PLAIN_START_TEXT_HELPURL,init:function(){this.setColour(Blockly.CONTROL_CATEGORY_HUE);this.setOutput(!0,AI.BlockUtils.YailTypeToBlocklyType("text",AI.BlockUtils.OUTPUT));this.appendDummyInput().appendField(Blockly.Msg.LANG_CONTROLS_GET_PLAIN_START_TEXT_TITLE);this.setTooltip(Blockly.Msg.LANG_CONTROLS_GET_PLAIN_START_TEXT_TOOLTIP)},typeblock:[{translatedName:Blockly.Msg.LANG_CONTROLS_GET_PLAIN_START_TEXT_TITLE}]};
Blockly.Blocks.controls_closeScreenWithPlainText={category:"Control",helpUrl:Blockly.Msg.LANG_CONTROLS_CLOSE_SCREEN_WITH_PLAIN_TEXT_HELPURL,init:function(){this.setColour(Blockly.CONTROL_CATEGORY_HUE);this.appendValueInput("TEXT").setCheck(AI.BlockUtils.YailTypeToBlocklyType("text",AI.BlockUtils.INPUT)).appendField(Blockly.Msg.LANG_CONTROLS_CLOSE_SCREEN_WITH_PLAIN_TEXT_TITLE).appendField(Blockly.Msg.LANG_CONTROLS_CLOSE_SCREEN_WITH_PLAIN_TEXT_INPUT_TEXT).setAlign(Blockly.inputs.Align.RIGHT);this.setPreviousStatement(!0);
this.setTooltip(Blockly.Msg.LANG_CONTROLS_CLOSE_SCREEN_WITH_PLAIN_TEXT_TOOLTIP)},typeblock:[{translatedName:Blockly.Msg.LANG_CONTROLS_CLOSE_SCREEN_WITH_PLAIN_TEXT_TITLE}]};
Blockly.Blocks.controls_break={category:"Control",helpUrl:Blockly.Msg.LANG_CONTROLS_BREAK_HELPURL,init:function(){this.setColour(Blockly.CONTROL_CATEGORY_HUE);this.appendDummyInput().appendField(Blockly.Msg.LANG_CONTROLS_BREAK_TITLE);this.setPreviousStatement(!0);this.setTooltip(Blockly.Msg.LANG_CONTROLS_FLOW_STATEMENTS_TOOLTIP_BREAK);this.errors=[{name:"checkIsNotInLoop"}]},typeblock:[{translatedName:Blockly.Msg.LANG_CONTROLS_BREAK_TITLE}]};/*

 @fileoverview Dictionaries blocks for Blockly, modified for MIT App Inventor.
 @author data1013@mit.edu (Danny Tang)
*/
AI.Blocks.dictionaries={};
Blockly.Blocks.dictionaries_create_with={category:"Dictionaries",helpUrl:function(){return 0<this.itemCount_?Blockly.Msg.LANG_DICTIONARIES_CREATE_WITH_EMPTY_HELPURL:Blockly.Msg.LANG_DICTIONARIES_MAKE_DICTIONARY_HELPURL},init:function(){this.setColour(Blockly.DICTIONARY_CATEGORY_HUE);this.appendValueInput("ADD0").appendField(Blockly.Msg.LANG_DICTIONARIES_MAKE_DICTIONARY_TITLE).setCheck(AI.BlockUtils.YailTypeToBlocklyType("pair",AI.BlockUtils.INPUT));this.appendValueInput("ADD1").setCheck(AI.BlockUtils.YailTypeToBlocklyType("pair",AI.BlockUtils.INPUT));
this.setOutput(!0,AI.BlockUtils.YailTypeToBlocklyType("dictionary",AI.BlockUtils.OUTPUT));this.setMutator(new Blockly.icons.MutatorIcon(["dictionaries_mutator_pair"],this));this.setTooltip(Blockly.Msg.LANG_DICTIONARIES_MAKE_DICTIONARY_TOOLTIP);this.itemCount_=2;this.emptyInputName="EMPTY";this.repeatingInputName="ADD"},mutationToDom:Blockly.mutationToDom,domToMutation:Blockly.domToMutation,decompose:function(d){return Blockly.decompose(d,"dictionaries_mutator_pair",this)},compose:function(d){for(var e=
{},h=0;h<this.itemCount_;h++){var k=this.getInputTargetBlock(this.repeatingInputName+h);k&&(e[k.id]=k)}if(0===this.itemCount_)null!=this.emptyInputName&&this.removeInput(this.emptyInputName);else for(h=this.itemCount_-1;0<=h;h--)this.removeInput(this.repeatingInputName+h);this.itemCount_=0;for(d=d.getInputTargetBlock("STACK");d;)h=this.addInput(this.itemCount_),d.valueConnection_&&d.valueConnection_.getSourceBlock()&&null!=d.valueConnection_.getSourceBlock().workspace?(h.connection.connect(d.valueConnection_),
delete e[d.valueConnection_.getSourceBlock().id]):Blockly.Events.isEnabled()&&(k=Blockly.common.getMainWorkspace().newBlock("pair"),k.initSvg(),k.queueRender(),h.connection.connect(k.outputConnection)),this.itemCount_++,d=d.nextConnection&&d.nextConnection.targetBlock();0===this.itemCount_&&this.addEmptyInput();for(var m in e)e.hasOwnProperty(m)&&(d=e[m],d.getInputTargetBlock("KEY")||d.getInputTargetBlock("VALUE")||d.dispose(!1,!1))},saveConnections:Blockly.saveConnections,addEmptyInput:function(){this.appendDummyInput(this.emptyInputName).appendField(Blockly.Msg.LANG_DICTIONARIES_CREATE_EMPTY_TITLE)},
addInput:function(d){var e=this.appendValueInput(this.repeatingInputName+d).setCheck(AI.BlockUtils.YailTypeToBlocklyType("pair",AI.BlockUtils.INPUT));0===d&&e.appendField(Blockly.Msg.LANG_DICTIONARIES_MAKE_DICTIONARY_TITLE);return e},updateContainerBlock:function(d){d.setFieldValue(Blockly.Msg.LANG_DICTIONARIES_CREATE_WITH_CONTAINER_TITLE_ADD,"CONTAINER_TEXT");d.setTooltip(Blockly.Msg.LANG_DICTIONARIES_CREATE_WITH_CONTAINER_TOOLTIP)},toString:function(d,e){var h="{",k=!0;e=e||"?";d&&0!==d||(k=!1);
for(var m="",p=0,t;(t=this.getInput("ADD"+p))&&(!k||h.length<d);p++){var q=t.connection.targetBlock();q&&(t=q.getInput("KEY").connection.targetBlock(),q=q.getInput("VALUE").connection.targetBlock(),t||q)&&(h+=m,h+=t?t.toString(d,e):e,h+=":",h+=q?q.toString(d,e):e,m=",")}k&&h.length>=d&&(h=h.substring(0,d-2),h+="…");return h+"}"},typeblock:[{translatedName:Blockly.Msg.LANG_DICTIONARIES_MAKE_DICTIONARY_TITLE,mutatorAttributes:{items:2}},{translatedName:Blockly.Msg.LANG_DICTIONARIES_CREATE_EMPTY_TITLE,
mutatorAttributes:{items:0}}]};Blockly.Blocks.dictionaries_mutator_pair={init:function(){this.setColour(Blockly.DICTIONARY_CATEGORY_HUE);this.appendDummyInput().appendField(Blockly.Msg.LANG_DICTIONARIES_PAIR_TITLE);this.setPreviousStatement(!0);this.setNextStatement(!0);this.setTooltip(Blockly.Msg.LANG_DICTIONARIES_PAIR_TOOLTIP)},contextMenu:!1};
Blockly.Blocks.pair={category:"Dictionaries",helpUrl:Blockly.Msg.LANG_DICTIONARIES_PAIR_HELPURL,init:function(){this.setColour(Blockly.DICTIONARY_CATEGORY_HUE);this.setOutput(!0,AI.BlockUtils.YailTypeToBlocklyType("pair",AI.BlockUtils.OUTPUT));var d=AI.BlockUtils.YailTypeToBlocklyType("any",AI.BlockUtils.INPUT),e=AI.BlockUtils.YailTypeToBlocklyType("key",AI.BlockUtils.INPUT);this.interpolateMsg(Blockly.Msg.LANG_DICTIONARIES_PAIR_INPUT,["KEY",e,Blockly.inputs.Align.RIGHT],["VALUE",d,Blockly.inputs.Align.RIGHT],
Blockly.inputs.Align.RIGHT);this.setTooltip(Blockly.Msg.LANG_DICTIONARIES_PAIR_TOOLTIP);this.setInputsInline(!0)},typeblock:[{translatedName:Blockly.Msg.LANG_DICTIONARIES_MAKE_PAIR_TITLE}]};
Blockly.Blocks.dictionaries_lookup={category:"Dictionaries",helpUrl:Blockly.Msg.LANG_DICTIONARIES_DICTIONARY_LOOKUP_HELPURL,init:function(){this.setColour(Blockly.DICTIONARY_CATEGORY_HUE);this.setOutput(!0,AI.BlockUtils.YailTypeToBlocklyType("any",AI.BlockUtils.OUTPUT));var d=AI.BlockUtils.YailTypeToBlocklyType("dictionary",AI.BlockUtils.INPUT),e=AI.BlockUtils.YailTypeToBlocklyType("any",AI.BlockUtils.INPUT),h=AI.BlockUtils.YailTypeToBlocklyType("key",AI.BlockUtils.INPUT);this.interpolateMsg(Blockly.Msg.LANG_DICTIONARIES_DICTIONARY_LOOKUP_INPUT,
["KEY",h,Blockly.inputs.Align.RIGHT],["DICT",d,Blockly.inputs.Align.RIGHT],["NOTFOUND",e,Blockly.inputs.Align.RIGHT],Blockly.inputs.Align.RIGHT);this.setTooltip(Blockly.Msg.LANG_DICTIONARIES_DICTIONARY_LOOKUP_TOOLTIP);this.setInputsInline(!1)},typeblock:[{translatedName:Blockly.Msg.LANG_DICTIONARIES_DICTIONARY_LOOKUP_TITLE}]};
Blockly.Blocks.dictionaries_set_pair={category:"Dictionaries",helpUrl:Blockly.Msg.LANG_DICTIONARIES_SET_PAIR_HELPURL,init:function(){this.setColour(Blockly.DICTIONARY_CATEGORY_HUE);var d=AI.BlockUtils.YailTypeToBlocklyType("dictionary",AI.BlockUtils.INPUT),e=AI.BlockUtils.YailTypeToBlocklyType("key",AI.BlockUtils.INPUT);this.interpolateMsg(Blockly.Msg.LANG_DICTIONARIES_SET_PAIR_INPUT,["KEY",e,Blockly.inputs.Align.RIGHT],["DICT",d,Blockly.inputs.Align.RIGHT],["VALUE",null,Blockly.inputs.Align.RIGHT],
Blockly.inputs.Align.RIGHT);this.setPreviousStatement(!0);this.setNextStatement(!0);this.setTooltip(Blockly.Msg.LANG_DICTIONARIES_SET_PAIR_TOOLTIP);this.setInputsInline(!1)},typeblock:[{translatedName:Blockly.Msg.LANG_DICTIONARIES_SET_PAIR_TITLE}]};
Blockly.Blocks.dictionaries_delete_pair={category:"Dictionaries",helpUrl:Blockly.Msg.LANG_DICTIONARIES_DELETE_PAIR_HELPURL,init:function(){this.setColour(Blockly.DICTIONARY_CATEGORY_HUE);var d=AI.BlockUtils.YailTypeToBlocklyType("dictionary",AI.BlockUtils.INPUT),e=AI.BlockUtils.YailTypeToBlocklyType("key",AI.BlockUtils.INPUT);this.interpolateMsg(Blockly.Msg.LANG_DICTIONARIES_DELETE_PAIR_INPUT,["DICT",d,Blockly.inputs.Align.RIGHT],["KEY",e,Blockly.inputs.Align.RIGHT],Blockly.inputs.Align.RIGHT);this.setPreviousStatement(!0);
this.setNextStatement(!0);this.setTooltip(Blockly.Msg.LANG_DICTIONARIES_DELETE_PAIR_TOOLTIP);this.setInputsInline(!1)},typeblock:[{translatedName:Blockly.Msg.LANG_DICTIONARIES_DELETE_PAIR_TITLE}]};
Blockly.Blocks.dictionaries_recursive_lookup={category:"Dictionaries",helpUrl:Blockly.Msg.LANG_DICTIONARIES_DICTIONARY_RECURSIVE_LOOKUP_HELPURL,init:function(){this.setColour(Blockly.DICTIONARY_CATEGORY_HUE);this.setOutput(!0,AI.BlockUtils.YailTypeToBlocklyType("any",AI.BlockUtils.OUTPUT));var d=AI.BlockUtils.YailTypeToBlocklyType("dictionary",AI.BlockUtils.INPUT),e=AI.BlockUtils.YailTypeToBlocklyType("any",AI.BlockUtils.INPUT),h=AI.BlockUtils.YailTypeToBlocklyType("list",AI.BlockUtils.INPUT);this.interpolateMsg(Blockly.Msg.LANG_DICTIONARIES_DICTIONARY_RECURSIVE_LOOKUP_INPUT,
["KEYS",h,Blockly.inputs.Align.RIGHT],["DICT",d,Blockly.inputs.Align.RIGHT],["NOTFOUND",e,Blockly.inputs.Align.RIGHT],Blockly.inputs.Align.RIGHT);this.setTooltip(Blockly.Msg.LANG_DICTIONARIES_DICTIONARY_RECURSIVE_LOOKUP_TOOLTIP);this.setInputsInline(!1)},typeblock:[{translatedName:Blockly.Msg.LANG_DICTIONARIES_DICTIONARY_RECURSIVE_LOOKUP_TITLE}]};
Blockly.Blocks.dictionaries_recursive_set={category:"Dictionaries",helpUrl:Blockly.Msg.LANG_DICTIONARIES_DICTIONARY_RECURSIVE_SET_HELPURL,init:function(){this.setColour(Blockly.DICTIONARY_CATEGORY_HUE);this.setPreviousStatement(!0);this.setNextStatement(!0);var d=AI.BlockUtils.YailTypeToBlocklyType("dictionary",AI.BlockUtils.INPUT),e=AI.BlockUtils.YailTypeToBlocklyType("any",AI.BlockUtils.INPUT),h=AI.BlockUtils.YailTypeToBlocklyType("list",AI.BlockUtils.INPUT);this.interpolateMsg(Blockly.Msg.LANG_DICTIONARIES_DICTIONARY_RECURSIVE_SET_INPUT,
["KEYS",h,Blockly.inputs.Align.RIGHT],["DICT",d,Blockly.inputs.Align.RIGHT],["VALUE",e,Blockly.inputs.Align.RIGHT],Blockly.inputs.Align.RIGHT);this.setTooltip(Blockly.Msg.LANG_DICTIONARIES_DICTIONARY_RECURSIVE_SET_TOOLTIP);this.setInputsInline(!1)},typeblock:[{translatedName:Blockly.Msg.LANG_DICTIONARIES_DICTIONARY_RECURSIVE_SET_TITLE}]};
Blockly.Blocks.dictionaries_getters={category:"Dictionaries",helpUrl:function(){var d=this.getFieldValue("OP");return Blockly.Blocks.dictionaries_getters.HELPURLS()[d]},init:function(){this.setColour(Blockly.DICTIONARY_CATEGORY_HUE);this.setOutput(!0,AI.BlockUtils.YailTypeToBlocklyType("list",AI.BlockUtils.OUTPUT));this.appendValueInput("DICT").setCheck(AI.BlockUtils.YailTypeToBlocklyType("dictionary",AI.BlockUtils.INPUT)).appendField(Blockly.Msg.LANG_DICTIONARIES_GETTERS_TITLE).appendField(new Blockly.FieldDropdown(this.OPERATORS),
"OP");var d=this;this.setTooltip(function(){var e=d.getFieldValue("OP");return Blockly.Blocks.dictionaries_getters.TOOLTIPS()[e]})},typeblock:[{translatedName:Blockly.Msg.LANG_DICTIONARIES_GET_KEYS_TYPEBLOCK,dropDown:{titleName:"OP",value:"KEYS"}},{translatedName:Blockly.Msg.LANG_DICTIONARIES_GET_VALUES_TYPEBLOCK,dropDown:{titleName:"OP",value:"VALUES"}}]};
Blockly.Blocks.dictionaries_getters.OPERATORS=function(){return[[Blockly.Msg.LANG_DICTIONARIES_GET_KEYS_TITLE,"KEYS"],[Blockly.Msg.LANG_DICTIONARIES_GET_VALUES_TITLE,"VALUES"]]};Blockly.Blocks.dictionaries_getters.TOOLTIPS=function(){return{KEYS:Blockly.Msg.LANG_DICTIONARIES_GET_KEYS_TOOLTIP,VALUES:Blockly.Msg.LANG_DICTIONARIES_GET_VALUES_TOOLTIP}};Blockly.Blocks.dictionaries_getters.HELPURLS=function(){return{KEYS:Blockly.Msg.LANG_DICTIONARIES_GET_KEYS_HELPURL,VALUES:Blockly.Msg.LANG_DICTIONARIES_GET_VALUES_HELPURL}};
Blockly.Blocks.dictionaries_get_values={category:"Dictionaries",helpUrl:function(){var d=this.getFieldValue("OP");return Blockly.Blocks.dictionaries_getters.HELPURLS()[d]},init:function(){this.setColour(Blockly.DICTIONARY_CATEGORY_HUE);this.setOutput(!0,AI.BlockUtils.YailTypeToBlocklyType("list",AI.BlockUtils.OUTPUT));this.appendValueInput("DICT").setCheck(AI.BlockUtils.YailTypeToBlocklyType("dictionary",AI.BlockUtils.INPUT)).appendField(Blockly.Msg.LANG_DICTIONARIES_GETTERS_TITLE).appendField(new Blockly.FieldDropdown(Blockly.Blocks.dictionaries_getters.OPERATORS),
"OP");this.setFieldValue("VALUES","OP");var d=this;this.setTooltip(function(){var e=d.getFieldValue("OP");return Blockly.Blocks.dictionaries_getters.TOOLTIPS()[e]})}};
Blockly.Blocks.dictionaries_is_key_in={category:"Dictionaries",init:function(){this.setColour(Blockly.DICTIONARY_CATEGORY_HUE);var d=AI.BlockUtils.YailTypeToBlocklyType("dictionary",AI.BlockUtils.INPUT),e=AI.BlockUtils.YailTypeToBlocklyType("key",AI.BlockUtils.INPUT);this.interpolateMsg(Blockly.Msg.LANG_DICTIONARIES_IS_KEY_IN_INPUT,["KEY",e,Blockly.inputs.Align.RIGHT],["DICT",d,Blockly.inputs.Align.RIGHT],Blockly.inputs.Align.RIGHT);this.setOutput(!0,AI.BlockUtils.YailTypeToBlocklyType("boolean",
AI.BlockUtils.OUTPUT));this.setTooltip(Blockly.Msg.LANG_DICTIONARIES_IS_KEY_IN_TOOLTIP);this.setInputsInline(!1)},typeblock:[{translatedName:Blockly.Msg.LANG_DICTIONARIES_IS_KEY_IN_TITLE}]};
Blockly.Blocks.dictionaries_length={category:"Dictionaries",init:function(){this.setColour(Blockly.DICTIONARY_CATEGORY_HUE);this.setOutput(!0,AI.BlockUtils.YailTypeToBlocklyType("number",AI.BlockUtils.OUTPUT));this.appendValueInput("DICT").setCheck(AI.BlockUtils.YailTypeToBlocklyType("dictionary",AI.BlockUtils.INPUT)).appendField(Blockly.Msg.LANG_DICTIONARIES_LENGTH_TITLE).appendField(Blockly.Msg.LANG_DICTIONARIES_LENGTH_INPUT);this.setTooltip(Blockly.Msg.LANG_DICTIONARIES_LENGTH_TOOLTIP)},typeblock:[{translatedName:Blockly.Msg.LANG_DICTIONARIES_LENGTH_TITLE}]};
Blockly.Blocks.dictionaries_alist_to_dict={category:"Dictionaries",init:function(){this.setColour(Blockly.DICTIONARY_CATEGORY_HUE);this.setOutput(!0,AI.BlockUtils.YailTypeToBlocklyType("dictionary",AI.BlockUtils.OUTPUT));this.appendValueInput("PAIRS").setCheck(AI.BlockUtils.YailTypeToBlocklyType("list",AI.BlockUtils.INPUT)).appendField(Blockly.Msg.LANG_DICTIONARIES_ALIST_TO_DICT_TITLE).appendField(Blockly.Msg.LANG_DICTIONARIES_ALIST_TO_DICT_INPUT);this.setTooltip(Blockly.Msg.LANG_DICTIONARIES_ALIST_TO_DICT_TOOLTIP)},
typeblock:[{translatedName:Blockly.Msg.LANG_DICTIONARIES_ALIST_TO_DICT_TITLE}]};
Blockly.Blocks.dictionaries_dict_to_alist={category:"Dictionaries",init:function(){this.setColour(Blockly.DICTIONARY_CATEGORY_HUE);this.setOutput(!0,AI.BlockUtils.YailTypeToBlocklyType("list",AI.BlockUtils.OUTPUT));this.appendValueInput("DICT").setCheck(AI.BlockUtils.YailTypeToBlocklyType("dictionary",AI.BlockUtils.INPUT)).appendField(Blockly.Msg.LANG_DICTIONARIES_DICT_TO_ALIST_TITLE).appendField(Blockly.Msg.LANG_DICTIONARIES_DICT_TO_ALIST_INPUT);this.setTooltip(Blockly.Msg.LANG_DICTIONARIES_DICT_TO_ALIST_TOOLTIP)},
typeblock:[{translatedName:Blockly.Msg.LANG_DICTIONARIES_DICT_TO_ALIST_TITLE}]};
Blockly.Blocks.dictionaries_copy={category:"Dictionaries",init:function(){this.setColour(Blockly.DICTIONARY_CATEGORY_HUE);this.setOutput(!0,AI.BlockUtils.YailTypeToBlocklyType("dictionary",AI.BlockUtils.OUTPUT));this.appendValueInput("DICT").setCheck(AI.BlockUtils.YailTypeToBlocklyType("dictionary",AI.BlockUtils.INPUT)).appendField(Blockly.Msg.LANG_DICTIONARIES_COPY_TITLE).appendField(Blockly.Msg.LANG_DICTIONARIES_COPY_INPUT);this.setTooltip(Blockly.Msg.LANG_DICTIONARIES_COPY_TOOLTIP)},typeblock:[{translatedName:Blockly.Msg.LANG_DICTIONARIES_COPY_TITLE}]};
Blockly.Blocks.dictionaries_combine_dicts={category:"Dictionaries",init:function(){this.setColour(Blockly.DICTIONARY_CATEGORY_HUE);var d=AI.BlockUtils.YailTypeToBlocklyType("dictionary",AI.BlockUtils.INPUT);this.interpolateMsg(Blockly.Msg.LANG_DICTIONARIES_COMBINE_DICTS_INPUT,["DICT1",d,Blockly.inputs.Align.RIGHT],["DICT2",d,Blockly.inputs.Align.RIGHT],Blockly.inputs.Align.RIGHT);this.setPreviousStatement(!0);this.setNextStatement(!0);this.setTooltip(Blockly.Msg.LANG_DICTIONARIES_COMBINE_DICTS_TOOLTIP);
this.setInputsInline(!1)},typeblock:[{translatedName:Blockly.Msg.LANG_DICTIONARIES_COMBINE_DICTS_TITLE}]};
Blockly.Blocks.dictionaries_walk_tree={category:"Dictionaries",helpUrl:Blockly.Msg.LANG_DICTIONARIES_WALK_TREE_HELPURL,init:function(){this.setColour(Blockly.DICTIONARY_CATEGORY_HUE);var d=AI.BlockUtils.YailTypeToBlocklyType("dictionary",AI.BlockUtils.INPUT),e=AI.BlockUtils.YailTypeToBlocklyType("list",AI.BlockUtils.INPUT);this.interpolateMsg(Blockly.Msg.LANG_DICTIONARIES_WALK_TREE_TITLE,["PATH",e,Blockly.inputs.Align.RIGHT],["DICT",d,Blockly.inputs.Align.RIGHT],Blockly.inputs.Align.RIGHT);this.setOutput(!0,
AI.BlockUtils.YailTypeToBlocklyType("list",AI.BlockUtils.OUTPUT));this.setTooltip(Blockly.Msg.LANG_DICTIONARIES_WALK_TREE_TOOLTIP);this.setInputsInline(!1)},typeblock:[{translatedName:Blockly.Msg.LANG_DICTIONARIES_WALK_TREE_TITLE}]};
Blockly.Blocks.dictionaries_walk_all={category:"Dictionaries",helpUrl:Blockly.Msg.LANG_DICTIONARIES_WALK_TREE_ALL_HELPURL,init:function(){this.setColour(Blockly.DICTIONARY_CATEGORY_HUE);this.interpolateMsg(Blockly.Msg.LANG_DICTIONARIES_WALK_TREE_ALL_TITLE,Blockly.inputs.Align.LEFT);this.setOutput(!0,"ALL_OPERATOR");this.setTooltip(Blockly.Msg.LANG_DICTIONARIES_WALK_TREE_ALL_TOOLTIP);this.setInputsInline(!1)},typeblock:[{translatedName:Blockly.Msg.LANG_DICTIONARIES_WALK_TREE_ALL_TITLE}]};
Blockly.Blocks.dictionaries_is_dict={category:"Dictionaries",init:function(){this.setColour(Blockly.DICTIONARY_CATEGORY_HUE);this.setOutput(!0,AI.BlockUtils.YailTypeToBlocklyType("boolean",AI.BlockUtils.OUTPUT));this.interpolateMsg(Blockly.Msg.LANG_DICTIONARIES_IS_DICT_TITLE,["THING",null,Blockly.inputs.Align.RIGHT],Blockly.inputs.Align.RIGHT);this.setTooltip(Blockly.Msg.LANG_DICTIONARIES_IS_DICT_TOOLTIP)},typeblock:[{translatedName:Blockly.Msg.LANG_DICTIONARIES_IS_DICT_TITLE}]};AI.Blockly.FieldInvalidDropdown={};Blockly.FieldInvalidDropdown=class extends Blockly.FieldDropdown{constructor(d,e,h){super(d,h);this.invalidOptions_=e||[]}doValueInvalid_(d){this.value_=d;this.isDirty_=!0;this.getSourceBlock&&this.getSourceBlock()&&this.getSourceBlock().badBlock();this.selectedOption=[d,d];for(let e=0,h;h=this.invalidOptions_[e];e++)if(h[1]==d){this.selectedOption=h;break}}doValueUpdate_(d){super.doValueUpdate_(d);this.getSourceBlock&&this.getSourceBlock()&&this.getSourceBlock().notBadBlock()}};/*

 @fileoverview Helper block definitions. These are created based on the
     component database, and are meant to be connected to component
     method/setter inputs to make coding faster for users.
*/
AI.Blocks.helpers={};Blockly.COLOUR_HELPERS="#BF4343";
Blockly.Blocks.helpers_dropdown={init:function(){this.key_="";this.setColour(Blockly.COLOUR_HELPERS)},mutationToDom:function(){var d=document.createElement("mutation");d.setAttribute("key",this.key_);return d},domToMutation:function(d){this.key_=d.getAttribute("key");var e=this.getTopWorkspace().getComponentDatabase(),h=e.getOptionList(this.key_);e=e.getInternationalizedOptionListTag(h.tag);var k=new Blockly.FieldInvalidDropdown(this.getValidOptions(),this.getInvalidOptions());this.setOutput(!0,this.getOutputType());
this.appendDummyInput().appendField(e).appendField(k,"OPTION");d=d.getAttribute("value")||h.defaultOpt;this.setFieldValue(d,"OPTION")},getOutputType:function(){var d=[],e=AI.BlockUtils.YailTypeToBlocklyType("enum",AI.BlockUtils.OUTPUT);e&&(Array.isArray(e)?d=e.slice():d.push(e));var h=AI.BlockUtils.helperKeyToBlocklyType({type:"OPTION_LIST",key:this.key_},this);h&&h!=e&&d.push(h);return d.length?d:null},getValidOptions:function(){for(var d=this.getTopWorkspace().getComponentDatabase(),e=d.getOptionList(this.key_),
h=[],k=0,m;m=e.options[k];k++){var p=d.getInternationalizedOptionName(e.tag+m.name,m.name);m.deprecated||h.push([p,m.name])}this.shouldSortOptions()&&h.sort(function(t,q){return t[1]<q[1]?-1:t[1]>q[1]?1:0});return h},getInvalidOptions:function(){for(var d=this.getTopWorkspace().getComponentDatabase(),e=d.getOptionList(this.key_),h=[],k=0,m;m=e.options[k];k++){var p=d.getInternationalizedOptionName(e.tag+m.name,m.name);m.deprecated&&h.push([p,m.name])}return h},shouldSortOptions:function(){return"Permission"===
this.key_},typeblock:function(){var d=Blockly.common.getMainWorkspace().getComponentDatabase(),e=[];d.forEachOptionList(function(h){for(var k=0,m;m=h.options[k];k++){var p=d.getInternationalizedOptionListTag(h.tag),t=d.getInternationalizedOptionName(h.tag+m.name,m.name);e.push({translatedName:p+t,mutatorAttributes:{key:h.tag,value:m.name}})}});return e}};
Blockly.Blocks.helpers_screen_names={init:function(){var d=AI.BlockUtils,e=new Blockly.FieldInvalidDropdown(this.generateOptions.bind(this));this.setColour(Blockly.COLOUR_HELPERS);this.setOutput(!0,d.YailTypeToBlocklyType("text",d.OUTPUT));this.appendDummyInput().appendField(e,"SCREEN")},onchange:function(d){d.type==AI.Events.SCREEN_SWITCH&&this.setFieldValue(this.getFieldValue("SCREEN"),"SCREEN")},domToMutation:function(d){d=d.getAttribute("value");this.setFieldValue(d,"SCREEN")},getScreens:function(){return this.workspace.getScreenList()},
generateOptions:function(){if(!this.workspace)return[["",""]];var d=this.getScreens();return d.length?d.map(function(e){return[e,e]}):[["",""]]},typeblock:function(){for(var d=[],e=Blockly.common.getMainWorkspace().getScreenList(),h=0,k;k=e[h];h++)d.push({translatedName:Blockly.Msg.LANG_SCREENS_TITLE+k,mutatorAttributes:{value:k}});return d}};
Blockly.Blocks.helpers_assets={init:function(){var d=AI.BlockUtils;this.setColour(Blockly.COLOUR_HELPERS);this.setOutput(!0,d.YailTypeToBlocklyType("text",d.OUTPUT));this.appendDummyInput("INPUT");this.addField()},onchange:function(d){if((d.type==AI.Events.SCREEN_SWITCH||d.type==Blockly.Events.MOVE)&&this.addField()){d=this.getFieldValue("ASSET");var e=this.generateOptions();this.isInFlyout&&e.length&&(d=e[0][1]);this.setFieldValue(d,"ASSET")}},domToMutation:function(d){var e=this.getField("ASSET");
e&&(d=d.getAttribute("value"),e.setValue(d))},addField:function(){if(this.workspace){var d=this.getInput("INPUT"),e=this.workspace.getAssetList();if(e.length){if(!this.getField("ASSET")){var h=new Blockly.FieldInvalidDropdown(this.generateOptions.bind(this));d.appendField(h,"ASSET")}this.getField("TEXT")&&d.removeField("TEXT")}else this.getField("TEXT")||(h=new Blockly.FieldLabel(Blockly.Msg.LANG_NO_ASSETS),d.appendField(h,"TEXT")),this.getField("ASSET")&&d.removeField("ASSET");return e.length}},
generateOptions:function(){if(!this.workspace)return[["",""]];var d=[""],e=this.outputConnection.targetConnection&&this.outputConnection.targetConnection.getCheck();if(e)for(var h=0,k;k=e[h];h++)Array.isArray(k)&&(d=k);e=this.workspace.getAssetList();return e.length&&(e=e.map(function(m){if(d.some(function(p){return m.includes(p)}))return[m,m]}),e=e.filter(function(m){return void 0!==m}),e.length)?e:[["",""]]},typeblock:function(){for(var d=[],e=Blockly.common.getMainWorkspace().getAssetList(),h=
0,k;k=e[h];h++)d.push({translatedName:k,mutatorAttributes:{value:k}});return d}};
Blockly.Blocks.helpers_providermodel={init:function(){var d=AI.BlockUtils;this.setColour(Blockly.COLOUR_HELPERS);this.setOutput(!0,d.YailTypeToBlocklyType("text",d.OUTPUT));this.appendDummyInput("INPUT").appendField(Blockly.Msg.LANG_CHATBOTMODEL_TITLE);this.addField()},onchange:function(d){if((d.type==AI.Events.SCREEN_SWITCH||d.type==Blockly.Events.MOVE)&&this.addField()){d=this.getFieldValue("PROVIDERMODEL");var e=this.generateOptions();this.isInFlyout&&e.length&&(d=e[0][1]);this.setFieldValue(d,
"PROVIDERMODEL")}},domToMutation:function(d){var e=this.getField("PROVIDERMODEL");e&&(d=d.getAttribute("value"),e.setValue(d))},addField:function(){if(this.workspace){var d=this.getInput("INPUT"),e=this.workspace.getProviderModelList();if(e.length){if(!this.getField("PROVIDERMODEL")){var h=new Blockly.FieldInvalidDropdown(this.generateOptions.bind(this));d.appendField(h,"PROVIDERMODEL")}this.getField("TEXT")&&d.removeField("TEXT")}else this.getField("TEXT")||(h=new Blockly.FieldLabel(Blockly.Msg.LANG_NO_PROVIDERMODEL),
d.appendField(h,"TEXT")),this.getField("PROVIDERMODEL")&&d.removeField("PROVIDERMODEL");return e.length}},generateOptions:function(){if(!this.workspace)return[["",""]];var d=[""],e=this.outputConnection.targetConnection&&this.outputConnection.targetConnection.getCheck();if(e)for(var h=0,k;k=e[h];h++)Array.isArray(k)&&(d=k);e=this.workspace.getProviderModelList();return e.length&&(e=e.map(function(m){if(d.some(function(p){return m.includes(p)}))return[m,m]}),e=e.filter(function(m){return void 0!==
m}),e.length)?e:[["",""]]},typeblock:function(){for(var d=[],e=Blockly.common.getMainWorkspace().getProviderModelList(),h=0,k;k=e[h];h++)d.push({translatedName:k,mutatorAttributes:{value:k}});return d}};
Blockly.Blocks.helpers_provider={init:function(){var d=AI.BlockUtils;this.setColour(Blockly.COLOUR_HELPERS);this.setOutput(!0,d.YailTypeToBlocklyType("text",d.OUTPUT));this.appendDummyInput("INPUT").appendField(Blockly.Msg.LANG_CHATBOTPROVIDER_TITLE);this.addField()},onchange:function(d){if((d.type==AI.Events.SCREEN_SWITCH||d.type==Blockly.Events.MOVE)&&this.addField()){d=this.getFieldValue("PROVIDER");var e=this.generateOptions();this.isInFlyout&&e.length&&(d=e[0][1]);this.setFieldValue(d,"PROVIDER")}},
domToMutation:function(d){var e=this.getField("PROVIDER");e&&(d=d.getAttribute("value"),e.setValue(d))},addField:function(){if(this.workspace){var d=this.getInput("INPUT"),e=this.workspace.getProviderList();if(e.length){if(!this.getField("PROVIDER")){var h=new Blockly.FieldInvalidDropdown(this.generateOptions.bind(this));d.appendField(h,"PROVIDER")}this.getField("TEXT")&&d.removeField("TEXT")}else this.getField("TEXT")||(h=new Blockly.FieldLabel(Blockly.Msg.LANG_NO_PROVIDERMODEL),d.appendField(h,
"TEXT")),this.getField("PROVIDER")&&d.removeField("PROVIDER");return e.length}},generateOptions:function(){if(!this.workspace)return[["",""]];var d=[""],e=this.outputConnection.targetConnection&&this.outputConnection.targetConnection.getCheck();if(e)for(var h=0,k;k=e[h];h++)Array.isArray(k)&&(d=k);e=this.workspace.getProviderList();return e.length&&(e=e.map(function(m){if(d.some(function(p){return m.includes(p)}))return[m,m]}),e=e.filter(function(m){return void 0!==m}),e.length)?e:[["",""]]},typeblock:function(){for(var d=
[],e=Blockly.common.getMainWorkspace().getProviderList(),h=0,k;k=e[h];h++)d.push({translatedName:k,mutatorAttributes:{value:k}});return d}};/*

 @fileoverview Variables blocks for Blockly, modified for MIT App Inventor.
 @author fturbak@wellesley.edu (Lyn Turbak)
*/
AI.Blocks.lexicalvariables={};
Blockly.Blocks.global_declaration={category:"Variables",helpUrl:Blockly.Msg.LANG_VARIABLES_GLOBAL_DECLARATION_HELPURL,init:function(){this.setColour(Blockly.VARIABLE_CATEGORY_HUE);this.appendValueInput("VALUE").appendField(Blockly.Msg.LANG_VARIABLES_GLOBAL_DECLARATION_TITLE_INIT).appendField(new Blockly.FieldGlobalFlydown(Blockly.Msg.LANG_VARIABLES_GLOBAL_DECLARATION_NAME,Blockly.FieldFlydown.DISPLAY_BELOW),"NAME").appendField(Blockly.Msg.LANG_VARIABLES_GLOBAL_DECLARATION_TO);this.setTooltip(Blockly.Msg.LANG_VARIABLES_GLOBAL_DECLARATION_TOOLTIP)},
getVars:function(){var d=this.getField("NAME");return d?[d.getValue()]:[]},renameVar:function(d,e){Blockly.Names.equals(d,this.getFieldValue("NAME"))&&this.setFieldValue(e,"NAME")},getGlobalNames:function(){return this.getVars()},typeblock:[{translatedName:Blockly.Msg.LANG_VARIABLES_GLOBAL_DECLARATION_TITLE_INIT}]};
Blockly.Blocks.lexical_variable_get={category:"Variables",helpUrl:Blockly.Msg.LANG_VARIABLES_GET_HELPURL,init:function(){this.setColour(Blockly.VARIABLE_CATEGORY_HUE);this.fieldVar_=new Blockly.FieldLexicalVariable(" ");this.appendDummyInput().appendField(Blockly.Msg.LANG_VARIABLES_GET_TITLE_GET).appendField(this.fieldVar_,"VAR");this.setOutput(!0,null);this.setTooltip(Blockly.Msg.LANG_VARIABLES_GET_TOOLTIP);this.errors=[{name:"checkIsInDefinition"},{name:"checkDropDownContainsValidValue",dropDowns:["VAR"]}]},
mutationToDom:function(){return Blockly.LexicalVariable.eventParamMutationToDom(this)},domToMutation:function(d){Blockly.LexicalVariable.eventParamDomToMutation(this,d);this.eventparam&&(d=this.workspace.getComponentDatabase(),this.fieldVar_.setTranslatedValue(d.getInternationalizedParameterName(this.eventparam),this.eventparam))},referenceResults:function(d,e,h){var k=this.getChildren().map(function(y){return Blockly.LexicalVariable.referenceResult(y,d,e,h)});let m=[],p=[];for(var t=0;t<k.length;t++)m=
m.concat(k[t][0]),p=p.concat(k[t][1]);t=this.getField("VAR").getValue();var q=Blockly.unprefixName(t);k=q[0];q=q[1];t=Blockly.usePrefixInCode&&-1==h.indexOf(t)||!Blockly.usePrefixInCode&&-1==h.indexOf(q);if(k!==Blockly.Msg.LANG_VARIABLES_GLOBAL_PREFIX)if(q===d&&t)if(m.push(this),Blockly.usePrefixInCode)for(k=0;k<h.length;k++)t=Blockly.unprefixName(h[k]),e===t[0]&&p.push(t[1]);else p=p.concat(h);else!t||Blockly.usePrefixInCode&&e!==k||p.push(q);this.eventparam&&p.push(this.eventparam);return[[m,p]]},
getVars:function(){return[this.getFieldValue("VAR")]},renameLexicalVar:function(d,e,h,k){void 0===h?d===this.getFieldValue("VAR")&&this.setFieldValue(e,"VAR"):h&&h===this.fieldVar_.getValue()&&(this.fieldVar_.setValue(k),d===e&&this.setFieldValue(e,"VAR"))},renameFree:function(d){var e=Blockly.unprefixName(this.getFieldValue("VAR"));e[0]!==Blockly.Msg.LANG_VARIABLES_GLOBAL_PREFIX&&(e=e[1],d=d.apply(e),d!==e&&this.renameLexicalVar(e,d))},freeVariables:function(){var d=Blockly.unprefixName(this.getFieldValue("VAR"));
return d[0]!==Blockly.Msg.LANG_VARIABLES_GLOBAL_PREFIX?new Blockly.NameSet([d[1]]):new Blockly.NameSet},typeblock:[{translatedName:Blockly.Msg.LANG_VARIABLES_GET_TITLE_GET+Blockly.Msg.LANG_VARIABLES_VARIABLE}]};
Blockly.Blocks.lexical_variable_set={category:"Variables",helpUrl:Blockly.Msg.LANG_VARIABLES_SET_HELPURL,init:function(){this.setColour(Blockly.VARIABLE_CATEGORY_HUE);this.fieldVar_=new Blockly.FieldLexicalVariable(" ");this.appendValueInput("VALUE").appendField(Blockly.Msg.LANG_VARIABLES_SET_TITLE_SET).appendField(this.fieldVar_,"VAR").appendField(Blockly.Msg.LANG_VARIABLES_SET_TITLE_TO);this.setPreviousStatement(!0);this.setNextStatement(!0);this.setTooltip(Blockly.Msg.LANG_VARIABLES_SET_TOOLTIP);
this.errors=[{name:"checkIsInDefinition"},{name:"checkDropDownContainsValidValue",dropDowns:["VAR"]}]},mutationToDom:function(){return Blockly.LexicalVariable.eventParamMutationToDom(this)},domToMutation:function(d){Blockly.LexicalVariable.eventParamDomToMutation(this,d);this.eventparam&&(d=this.workspace.getComponentDatabase(),this.fieldVar_.setTranslatedValue(d.getInternationalizedParameterName(this.eventparam),this.eventparam))},referenceResults:Blockly.Blocks.lexical_variable_get.referenceResults,
getVars:function(){return[this.getFieldValue("VAR")]},renameLexicalVar:Blockly.Blocks.lexical_variable_get.renameLexicalVar,renameFree:function(d){var e=Blockly.unprefixName(this.getFieldValue("VAR"));if(e[0]!==Blockly.Msg.LANG_VARIABLES_GLOBAL_PREFIX){e=e[1];var h=d.apply(e);h!==e&&this.renameLexicalVar(e,h)}this.getChildren().map(function(k){Blockly.LexicalVariable.renameFree(k,d)})},freeVariables:function(){var d=this.getChildren().map(function(h){return Blockly.LexicalVariable.freeVariables(h)});
d=Blockly.NameSet.unionAll(d);var e=Blockly.unprefixName(this.getFieldValue("VAR"));e[0]!==Blockly.Msg.LANG_VARIABLES_GLOBAL_PREFIX&&d.insert(e[1]);return d},typeblock:[{translatedName:Blockly.Msg.LANG_VARIABLES_SET_TITLE_SET+Blockly.Msg.LANG_VARIABLES_VARIABLE}]};
Blockly.Blocks.local_declaration_statement={category:"Variables",helpUrl:Blockly.Msg.LANG_VARIABLES_LOCAL_DECLARATION_HELPURL,bodyInputName:"STACK",init:function(){this.initLocals();this.appendStatementInput("STACK").appendField(Blockly.Msg.LANG_VARIABLES_LOCAL_DECLARATION_IN_DO);this.setPreviousStatement(!0);this.setNextStatement(!0);this.setTooltip(Blockly.Msg.LANG_VARIABLES_LOCAL_DECLARATION_TOOLTIP);this.lexicalVarPrefix=Blockly.localNamePrefix},referenceResults:function(d,e,h){var k=[];for(var m=
0;this.getInput("DECL"+m);m++){var p=this.getFieldValue("VAR"+m);Blockly.usePrefixInCode&&(p=Blockly.possiblyPrefixMenuNameWith(Blockly.localNamePrefix)(p));k.push(p)}k=h.concat(k);m=[];for(p=0;this.getInput("DECL"+p);p++){const t=this.getInputTargetBlock("DECL"+p);t&&m.push(t)}m=m.map(function(t){return Blockly.LexicalVariable.referenceResult(t,d,e,h)});k=Blockly.LexicalVariable.referenceResult(this.getInputTargetBlock("STACK"),d,e,k);p=Blockly.LexicalVariable.referenceResult(Blockly.LexicalVariable.getNextTargetBlock(this),
d,e,h);return m.concat([k,p])},withLexicalVarsAndPrefix:function(d,e){if(this.getInputTargetBlock(this.bodyInputName)==d){d=this.declaredNames();for(let h=0;h<d.length;h++)e(d[h],this.lexicalVarPrefix)}},initLocals:function(){this.setColour(Blockly.VARIABLE_CATEGORY_HUE);this.localNames_=[Blockly.Msg.LANG_VARIABLES_LOCAL_DECLARATION_DEFAULT_NAME];this.appendValueInput("DECL0").appendField(Blockly.Msg.LANG_VARIABLES_LOCAL_DECLARATION_TITLE_INIT).appendField(this.parameterFlydown(0),"VAR0").appendField(Blockly.Msg.LANG_VARIABLES_LOCAL_DECLARATION_INPUT_TO).setAlign(Blockly.inputs.Align.RIGHT);
this.setMutator(new Blockly.icons.MutatorIcon(["local_mutatorarg"],this))},onchange:function(){this.localNames_=this.declaredNames()},mutationToDom:function(){for(var d=document.createElement("mutation"),e=0;e<this.localNames_.length;e++){var h=document.createElement("localname");h.setAttribute("name",this.localNames_[e]);d.appendChild(h)}return d},domToMutation:function(d){d=Array.prototype.filter.call(d.childNodes,function(k){return k.nodeType===Element.ELEMENT_NODE});if(0<d.length){this.localNames_=
[];for(var e=0,h;h=d[e];e++)"localname"==h.nodeName.toLowerCase()&&this.localNames_.push(h.getAttribute("name"))}this.updateDeclarationInputs_(this.localNames_)},updateDeclarationInputs_:function(d,e){var h=this.inputList.length-1,k=this;Blockly.FieldParameterFlydown.withChangeHanderDisabled(function(){for(var t=0;t<h;t++)k.removeInput("DECL"+t)});this.localNames_=d;for(var m=0;m<d.length;m++){var p=this.appendValueInput("DECL"+m);p.appendField(Blockly.Msg.LANG_VARIABLES_LOCAL_DECLARATION_TITLE_INIT).appendField(this.parameterFlydown(m),
"VAR"+m).appendField(Blockly.Msg.LANG_VARIABLES_LOCAL_DECLARATION_INPUT_TO).setAlign(Blockly.inputs.Align.RIGHT);e&&e[m]&&p.connection.connect(e[m])}this.moveInputBefore(this.bodyInputName)},parameterFlydown:function(d){var e=this;return new Blockly.FieldParameterFlydown(this.localNames_[d],!0,Blockly.FieldFlydown.DISPLAY_RIGHT,function(h){e.localNames_[d]=h;if(e.mutator&&e.mutator.rootBlock){for(var k=0,m=e.mutator.rootBlock.getInputTargetBlock("STACK");m&&k<d;)m=m.nextConnection&&m.nextConnection.targetBlock(),
k++;m&&k==d&&Blockly.Field.prototype.setValue.call(m.getField("NAME"),h)}})},decompose:function(d){var e=d.newBlock("local_mutatorcontainer");e.initSvg();e.setDefBlock(this);for(var h=e.getInput("STACK").connection,k=0;k<this.localNames_.length;k++){var m=this.getFieldValue("VAR"+k),p=d.newBlock("local_mutatorarg");p.initSvg();p.setFieldValue(m,"NAME");p.oldLocation=k;h.connect(p.previousConnection);h=p.nextConnection}return e},compose:function(d){var e=[],h=[];for(d=d.getInputTargetBlock("STACK");d;)e.push(d.getFieldValue("NAME")),
h.push(d.valueConnection_),d=d.nextConnection&&d.nextConnection.targetBlock();Blockly.LexicalVariable.stringListsEqual(this.localNames_,e)||this.updateDeclarationInputs_(e,h)},saveConnections:function(d){for(var e=d.getInputTargetBlock("STACK"),h=0;e;){var k=this.getInput("DECL"+h);e.valueConnection_=k&&k.connection.targetConnection;h++;e=e.nextConnection&&e.nextConnection.targetBlock()}if(e=this.getInput(this.bodyInputName))d.bodyConnection_=e.connection.targetConnection},getVars:function(){for(var d=
[],e=0,h;h=this.getField("VAR"+e);e++)d.push(h.getValue());return d},declaredNames:function(){return this.getVars()},declaredVariables:function(){return this.getVars()},initializerConnections:function(){for(var d=[],e=0,h;h=this.getInput("DECL"+e);e++)d.push(h.connection&&h.connection.targetConnection);return d},blocksInScope:function(){var d=this.getInputTargetBlock(this.bodyInputName);return d&&[d]||[]},renameVar:function(d,e){this.renameVars(Blockly.Substitution.simpleSubstitution(d,e))},renameVars:function(d){var e=
this.declaredNames(),h=d.map(e);if(!Blockly.LexicalVariable.stringListsEqual(h,e)&&(e=this.initializerConnections(),this.updateDeclarationInputs_(h,e),this.mutator.isVisible())){h=this.mutator.getWorkspace().getAllBlocks();e=0;for(var k;k=h[e];e++)if("procedures_mutatorarg"==k.type){var m=k.getFieldValue("NAME"),p=d.apply(m);p!==m&&k.setFieldValue(p,"NAME")}}},renameBound:function(d,e){for(var h=Blockly.Xml.domToText(this.mutationToDom()),k=this.declaredNames(),m=0;m<k.length;m++)Blockly.LexicalVariable.renameFree(this.getInputTargetBlock("DECL"+
m),e);d=d.restrictDomain(k);this.renameVars(d);k=e.remove(k).extend(d);Blockly.LexicalVariable.renameFree(this.getInputTargetBlock(this.bodyInputName),k);k=Blockly.Xml.domToText(this.mutationToDom());Blockly.Events.isEnabled()&&Blockly.Events.fire(new Blockly.Events.BlockChange(this,"mutation",null,h,k));this.nextConnection&&(h=this.nextConnection.targetBlock(),Blockly.LexicalVariable.renameFree(h,e))},renameFree:function(d){var e=this.declaredNames();e=new Blockly.NameSet(e);var h=Blockly.LexicalVariable.freeVariables(this.getInputTargetBlock(this.bodyInputName));
h.subtract(e);h=h.renamed(d);var k=h.intersection(e);if(k.isEmpty())this.renameBound(new Blockly.Substitution,d);else{e=e.union(h).toList();h={};k=k.toList();for(var m=0,p;p=k[m];m++){var t=Blockly.FieldLexicalVariable.nameNotIn(p,e);h[p]=t;e.push(t)}this.renameBound(new Blockly.Substitution(h),d)}},freeVariables:function(){var d=Blockly.LexicalVariable.freeVariables(this.getInputTargetBlock(this.bodyInputName)),e=this.declaredNames();d.subtract(new Blockly.NameSet(e));e=e.length;for(var h=0;h<e;h++)d.union(Blockly.LexicalVariable.freeVariables(this.getInputTargetBlock("DECL"+
h)));this.nextConnection&&(e=this.nextConnection.targetBlock(),d.unite(Blockly.LexicalVariable.freeVariables(e)));return d},typeblock:[{translatedName:Blockly.Msg.LANG_VARIABLES_LOCAL_DECLARATION_TRANSLATED_NAME}]};
Blockly.Blocks.local_declaration_expression={category:"Variables",helpUrl:Blockly.Msg.LANG_VARIABLES_LOCAL_DECLARATION_EXPRESSION_HELPURL,initLocals:Blockly.Blocks.local_declaration_statement.initLocals,bodyInputName:"RETURN",init:function(){this.initLocals();this.appendInputFromRegistry("indented_input","RETURN").appendField(Blockly.Msg.LANG_VARIABLES_LOCAL_DECLARATION_EXPRESSION_IN_RETURN);this.setOutput(!0,null);this.setTooltip(Blockly.Msg.LANG_VARIABLES_LOCAL_DECLARATION_EXPRESSION_TOOLTIP)},
referenceResults:function(d,e,h){var k=[];for(var m=0;this.getInput("DECL"+m);m++){var p=this.getFieldValue("VAR"+m);Blockly.usePrefixInCode&&(p=Blockly.possiblyPrefixMenuNameWith(Blockly.localNamePrefix)(p));k.push(p)}k=h.concat(k);m=[];for(p=0;this.getInput("DECL"+p);p++){const t=this.getInputTargetBlock("DECL"+p);t&&m.push(t)}m=m.map(function(t){return Blockly.LexicalVariable.referenceResult(t,d,e,h)});k=Blockly.LexicalVariable.referenceResult(this.getInputTargetBlock("RETURN"),d,e,k);return m.concat([k])},
withLexicalVarsAndPrefix:Blockly.Blocks.local_declaration_statement.withLexicalVarsAndPrefix,onchange:Blockly.Blocks.local_declaration_statement.onchange,mutationToDom:Blockly.Blocks.local_declaration_statement.mutationToDom,domToMutation:Blockly.Blocks.local_declaration_statement.domToMutation,updateDeclarationInputs_:Blockly.Blocks.local_declaration_statement.updateDeclarationInputs_,parameterFlydown:Blockly.Blocks.local_declaration_statement.parameterFlydown,blocksInScope:Blockly.Blocks.local_declaration_statement.blocksInScope,
decompose:Blockly.Blocks.local_declaration_statement.decompose,compose:Blockly.Blocks.local_declaration_statement.compose,saveConnections:Blockly.Blocks.local_declaration_statement.saveConnections,getVars:Blockly.Blocks.local_declaration_statement.getVars,declaredNames:Blockly.Blocks.local_declaration_statement.declaredNames,declaredVariables:Blockly.Blocks.local_declaration_statement.declaredVariables,renameVar:Blockly.Blocks.local_declaration_statement.renameVar,renameVars:Blockly.Blocks.local_declaration_statement.renameVars,
renameBound:Blockly.Blocks.local_declaration_statement.renameBound,renameFree:Blockly.Blocks.local_declaration_statement.renameFree,freeVariables:Blockly.Blocks.local_declaration_statement.freeVariables,typeblock:[{translatedName:Blockly.Msg.LANG_VARIABLES_LOCAL_DECLARATION_EXPRESSION_TRANSLATED_NAME}]};
Blockly.Blocks.local_mutatorcontainer={init:function(){this.setColour(Blockly.VARIABLE_CATEGORY_HUE);this.appendDummyInput().appendField(Blockly.Msg.LANG_VARIABLES_LOCAL_MUTATOR_CONTAINER_TITLE_LOCAL_NAMES);this.appendStatementInput("STACK");this.setTooltip(Blockly.Msg.LANG_VARIABLES_LOCAL_MUTATOR_CONTAINER_TOOLTIP);this.contextMenu=!1},setDefBlock:function(d){this.defBlock_=d},getDefBlock:function(){return this.defBlock_},declaredNames:function(){for(var d=[],e=this.getInputTargetBlock("STACK");e;)d.push(e.getFieldValue("NAME")),
e=e.nextConnection&&e.nextConnection.targetBlock();return d}};
Blockly.Blocks.local_mutatorarg={init:function(){this.setColour(Blockly.VARIABLE_CATEGORY_HUE);this.appendDummyInput().appendField(Blockly.Msg.LANG_VARIABLES_LOCAL_MUTATOR_ARG_TITLE_NAME).appendField(new Blockly.FieldTextInput(Blockly.Msg.LANG_VARIABLES_LOCAL_MUTATOR_ARG_DEFAULT_VARIABLE,Blockly.LexicalVariable.renameParam),"NAME");this.setPreviousStatement(!0);this.setNextStatement(!0);this.setTooltip("");this.contextMenu=!1},getContainerBlock:function(){for(var d=this.getParent();d&&"local_mutatorcontainer"!==
d.type;)d=d.getParent();return this.cachedContainerBlock_=d&&"local_mutatorcontainer"===d.type&&d||null},getDefBlock:function(){var d=this.getContainerBlock();return d&&d.getDefBlock()||null},blocksInScope:function(){var d=this.getDefBlock();return d&&d.blocksInScope()||[]},declaredNames:function(){var d=this.getContainerBlock();return d&&d.declaredNames()||[]},onchange:function(){var d=this.getFieldValue("NAME");if(d){var e=this.cachedContainerBlock_,h=this.getContainerBlock();!e&&h&&(e=this.declaredNames(),
h=e.indexOf(d),-1!=h&&-1!=e.indexOf(d,h+1)&&(d=Blockly.FieldLexicalVariable.nameNotIn(d,e),this.setFieldValue(d,"NAME")))}}};/*

 @fileoverview Lists blocks for Blockly, modified for MIT App Inventor.
 @author mckinney@mit.edu (Andrew F. McKinney)
*/
AI.Blocks.lists={};
Blockly.Blocks.lists_create_with={category:"Lists",helpUrl:Blockly.Msg.LANG_LISTS_CREATE_WITH_EMPTY_HELPURL,init:function(){this.setColour(Blockly.LIST_CATEGORY_HUE);this.appendValueInput("ADD0").appendField(Blockly.Msg.LANG_LISTS_CREATE_WITH_TITLE_MAKE_LIST);this.appendValueInput("ADD1");this.setOutput(!0,AI.BlockUtils.YailTypeToBlocklyType("list",AI.BlockUtils.OUTPUT));this.setMutator(new Blockly.icons.MutatorIcon(["lists_create_with_item"],this));this.setTooltip(Blockly.Msg.LANG_LISTS_CREATE_WITH_TOOLTIP);this.itemCount_=
2;this.emptyInputName="EMPTY";this.repeatingInputName="ADD"},mutationToDom:Blockly.mutationToDom,domToMutation:Blockly.domToMutation,decompose:function(d){return Blockly.decompose(d,"lists_create_with_item",this)},compose:Blockly.compose,saveConnections:Blockly.saveConnections,addEmptyInput:function(){this.appendDummyInput(this.emptyInputName).appendField(Blockly.Msg.LANG_LISTS_CREATE_EMPTY_TITLE)},addInput:function(d){var e=this.appendValueInput(this.repeatingInputName+d);0===d&&e.appendField(Blockly.Msg.LANG_LISTS_CREATE_WITH_TITLE_MAKE_LIST);
return e},updateContainerBlock:function(d){d.setFieldValue(Blockly.Msg.LANG_LISTS_CREATE_WITH_CONTAINER_TITLE_ADD,"CONTAINER_TEXT")},typeblock:[{translatedName:Blockly.Msg.LANG_LISTS_CREATE_WITH_TITLE_MAKE_LIST,mutatorAttributes:{items:2}},{translatedName:Blockly.Msg.LANG_LISTS_CREATE_EMPTY_TITLE,mutatorAttributes:{items:0}}]};AI.Blockly.Mixins.extend(Blockly.Blocks.lists_create_with,AI.Blockly.Mixins.DynamicConnections);
Blockly.Blocks.lists_create_with_item={init:function(){this.setColour(Blockly.LIST_CATEGORY_HUE);this.appendDummyInput().appendField(Blockly.Msg.LANG_LISTS_CREATE_WITH_ITEM_TITLE);this.setPreviousStatement(!0);this.setNextStatement(!0);this.setTooltip(Blockly.Msg.LANG_LISTS_CREATE_WITH_ITEM_TOOLTIP);this.contextMenu=!1}};
Blockly.Blocks.lists_add_items={category:"Lists",helpUrl:Blockly.Msg.LANG_LISTS_ADD_ITEMS_HELPURL,init:function(){this.setColour(Blockly.LIST_CATEGORY_HUE);this.appendValueInput("LIST").setCheck(AI.BlockUtils.YailTypeToBlocklyType("list",AI.BlockUtils.INPUT)).appendField(Blockly.Msg.LANG_LISTS_ADD_ITEMS_TITLE_ADD).appendField(Blockly.Msg.LANG_LISTS_ADD_ITEMS_INPUT_LIST);this.appendValueInput("ITEM0").appendField(Blockly.Msg.LANG_LISTS_ADD_ITEMS_INPUT_ITEM).setAlign(Blockly.inputs.Align.RIGHT);this.setPreviousStatement(!0);
this.setNextStatement(!0);this.setTooltip(Blockly.Msg.LANG_LISTS_ADD_ITEMS_TOOLTIP);this.setMutator(new Blockly.icons.MutatorIcon(["lists_add_items_item"],this));this.itemCount_=1;this.emptyInputName=null;this.repeatingInputName="ITEM"},mutationToDom:Blockly.mutationToDom,domToMutation:Blockly.domToMutation,decompose:function(d){return Blockly.decompose(d,"lists_add_items_item",this)},compose:Blockly.compose,saveConnections:Blockly.saveConnections,addEmptyInput:function(){},addInput:function(d){d=
this.appendValueInput(this.repeatingInputName+d);d.appendField(Blockly.Msg.LANG_LISTS_ADD_ITEMS_INPUT_ITEM).setAlign(Blockly.inputs.Align.RIGHT);return d},updateContainerBlock:function(d){d.setFieldValue(Blockly.Msg.LANG_LISTS_ADD_ITEMS_CONTAINER_TITLE_ADD,"CONTAINER_TEXT");d.setTooltip(Blockly.Msg.LANG_LISTS_ADD_ITEMS_CONTAINER_TOOLTIP)},typeblock:[{translatedName:Blockly.Msg.LANG_LISTS_ADD_ITEMS_TITLE_ADD}]};
Blockly.Blocks.lists_add_items_item={init:function(){this.setColour(Blockly.LIST_CATEGORY_HUE);this.appendDummyInput().appendField(Blockly.Msg.LANG_LISTS_ADD_ITEM_TITLE);this.setPreviousStatement(!0);this.setNextStatement(!0);this.setTooltip(Blockly.Msg.LANG_LISTS_ADD_ITEM_TOOLTIP);this.contextMenu=!1}};
Blockly.Blocks.lists_is_in={category:"Lists",helpUrl:Blockly.Msg.LANG_LISTS_IS_IN_HELPURL,init:function(){this.setColour(Blockly.LIST_CATEGORY_HUE);var d=AI.BlockUtils.YailTypeToBlocklyType("list",AI.BlockUtils.INPUT),e=AI.BlockUtils.YailTypeToBlocklyType("any",AI.BlockUtils.INPUT);this.interpolateMsg(Blockly.Msg.LANG_LISTS_IS_IN_INPUT,["ITEM",e,Blockly.inputs.Align.RIGHT],["LIST",d,Blockly.inputs.Align.RIGHT],Blockly.inputs.Align.RIGHT);this.setOutput(!0,AI.BlockUtils.YailTypeToBlocklyType("boolean",
AI.BlockUtils.OUTPUT));this.setTooltip(Blockly.Msg.LANG_LISTS_IS_IN_TOOLTIP);this.setInputsInline(!1)},typeblock:[{translatedName:Blockly.Msg.LANG_LISTS_IS_IN_TITLE_IS_IN}]};
Blockly.Blocks.lists_length={category:"Lists",helpUrl:Blockly.Msg.LANG_LISTS_LENGTH_HELPURL,init:function(){this.setColour(Blockly.LIST_CATEGORY_HUE);this.setOutput(!0,AI.BlockUtils.YailTypeToBlocklyType("number",AI.BlockUtils.OUTPUT));this.appendValueInput("LIST").setCheck(AI.BlockUtils.YailTypeToBlocklyType("list",AI.BlockUtils.INPUT)).appendField(Blockly.Msg.LANG_LISTS_LENGTH_INPUT_LENGTH).appendField(Blockly.Msg.LANG_LISTS_LENGTH_INPUT_LIST);this.setTooltip(Blockly.Msg.LANG_LISTS_LENGTH_TOOLTIP)},
typeblock:[{translatedName:Blockly.Msg.LANG_LISTS_LENGTH_INPUT_LENGTH}]};
Blockly.Blocks.lists_is_empty={category:"Lists",helpUrl:Blockly.Msg.LANG_LISTS_IS_EMPTY_HELPURL,init:function(){this.setColour(Blockly.LIST_CATEGORY_HUE);this.setOutput(!0,AI.BlockUtils.YailTypeToBlocklyType("boolean",AI.BlockUtils.OUTPUT));this.appendValueInput("LIST").setCheck(AI.BlockUtils.YailTypeToBlocklyType("list",AI.BlockUtils.INPUT)).appendField(Blockly.Msg.LANG_LISTS_TITLE_IS_EMPTY).appendField(Blockly.Msg.LANG_LISTS_INPUT_LIST);this.setTooltip(Blockly.Msg.LANG_LISTS_IS_EMPTY_TOOLTIP)},
typeblock:[{translatedName:Blockly.Msg.LANG_LISTS_TITLE_IS_EMPTY}]};
Blockly.Blocks.lists_pick_random_item={category:"Lists",helpUrl:Blockly.Msg.LANG_LISTS_PICK_RANDOM_ITEM_HELPURL,init:function(){this.setColour(Blockly.LIST_CATEGORY_HUE);this.setOutput(!0,null);this.appendValueInput("LIST").setCheck(AI.BlockUtils.YailTypeToBlocklyType("list",AI.BlockUtils.INPUT)).appendField(Blockly.Msg.LANG_LISTS_PICK_RANDOM_TITLE_PICK_RANDOM).appendField(Blockly.Msg.LANG_LISTS_PICK_RANDOM_ITEM_INPUT_LIST);this.setTooltip(Blockly.Msg.LANG_LISTS_PICK_RANDOM_TOOLTIP)},typeblock:[{translatedName:Blockly.Msg.LANG_LISTS_PICK_RANDOM_TITLE_PICK_RANDOM}]};
Blockly.Blocks.lists_position_in={category:"Lists",helpUrl:Blockly.Msg.LANG_LISTS_POSITION_IN_HELPURL,init:function(){this.setColour(Blockly.LIST_CATEGORY_HUE);this.setOutput(!0,AI.BlockUtils.YailTypeToBlocklyType("number",AI.BlockUtils.OUTPUT));var d=AI.BlockUtils.YailTypeToBlocklyType("list",AI.BlockUtils.INPUT),e=AI.BlockUtils.YailTypeToBlocklyType("any",AI.BlockUtils.INPUT);this.interpolateMsg(Blockly.Msg.LANG_LISTS_POSITION_IN_INPUT,["ITEM",e,Blockly.inputs.Align.RIGHT],["LIST",d,Blockly.inputs.Align.RIGHT],
Blockly.inputs.Align.RIGHT);this.setTooltip(Blockly.Msg.LANG_LISTS_POSITION_IN_TOOLTIP);this.setInputsInline(!1)},typeblock:[{translatedName:Blockly.Msg.LANG_LISTS_POSITION_IN_TITLE_POSITION}]};
Blockly.Blocks.lists_select_item={category:"Lists",helpUrl:Blockly.Msg.LANG_LISTS_SELECT_ITEM_TITLE_HELPURL,init:function(){this.setColour(Blockly.LIST_CATEGORY_HUE);this.setOutput(!0,null);var d=AI.BlockUtils.YailTypeToBlocklyType("list",AI.BlockUtils.INPUT),e=AI.BlockUtils.YailTypeToBlocklyType("number",AI.BlockUtils.INPUT);this.interpolateMsg(Blockly.Msg.LANG_LISTS_SELECT_ITEM_INPUT,["LIST",d,Blockly.inputs.Align.RIGHT],["NUM",e,Blockly.inputs.Align.RIGHT],Blockly.inputs.Align.RIGHT);this.setTooltip(Blockly.Msg.LANG_LISTS_SELECT_ITEM_TOOLTIP);
this.setInputsInline(!1)},typeblock:[{translatedName:Blockly.Msg.LANG_LISTS_SELECT_ITEM_TITLE_SELECT}]};
Blockly.Blocks.lists_insert_item={category:"Lists",helpUrl:Blockly.Msg.LANG_LISTS_INSERT_ITEM_HELPURL,init:function(){this.setColour(Blockly.LIST_CATEGORY_HUE);var d=AI.BlockUtils.YailTypeToBlocklyType("list",AI.BlockUtils.INPUT),e=AI.BlockUtils.YailTypeToBlocklyType("number",AI.BlockUtils.INPUT),h=AI.BlockUtils.YailTypeToBlocklyType("any",AI.BlockUtils.INPUT);this.interpolateMsg(Blockly.Msg.LANG_LISTS_INSERT_INPUT,["LIST",d,Blockly.inputs.Align.RIGHT],["INDEX",e,Blockly.inputs.Align.RIGHT],["ITEM",
h,Blockly.inputs.Align.RIGHT],Blockly.inputs.Align.RIGHT);this.setPreviousStatement(!0);this.setNextStatement(!0);this.setTooltip(Blockly.Msg.LANG_LISTS_INSERT_TOOLTIP);this.setInputsInline(!1)},typeblock:[{translatedName:Blockly.Msg.LANG_LISTS_INSERT_TITLE_INSERT_LIST}]};
Blockly.Blocks.lists_replace_item={category:"Lists",helpUrl:Blockly.Msg.LANG_LISTS_REPLACE_ITEM_HELPURL,init:function(){this.setColour(Blockly.LIST_CATEGORY_HUE);var d=AI.BlockUtils.YailTypeToBlocklyType("list",AI.BlockUtils.INPUT),e=AI.BlockUtils.YailTypeToBlocklyType("number",AI.BlockUtils.INPUT),h=AI.BlockUtils.YailTypeToBlocklyType("any",AI.BlockUtils.INPUT);this.interpolateMsg(Blockly.Msg.LANG_LISTS_REPLACE_ITEM_INPUT,["LIST",d,Blockly.inputs.Align.RIGHT],["NUM",e,Blockly.inputs.Align.RIGHT],
["ITEM",h,Blockly.inputs.Align.RIGHT],Blockly.inputs.Align.RIGHT);this.setPreviousStatement(!0);this.setNextStatement(!0);this.setTooltip(Blockly.Msg.LANG_LISTS_REPLACE_ITEM_TOOLTIP);this.setInputsInline(!1)},typeblock:[{translatedName:Blockly.Msg.LANG_LISTS_REPLACE_ITEM_TITLE_REPLACE}]};
Blockly.Blocks.lists_remove_item={category:"Lists",helpUrl:Blockly.Msg.LANG_LISTS_REMOVE_ITEM_HELPURL,init:function(){this.setColour(Blockly.LIST_CATEGORY_HUE);var d=AI.BlockUtils.YailTypeToBlocklyType("list",AI.BlockUtils.INPUT),e=AI.BlockUtils.YailTypeToBlocklyType("number",AI.BlockUtils.INPUT);this.interpolateMsg(Blockly.Msg.LANG_LISTS_REMOVE_ITEM_INPUT,["LIST",d,Blockly.inputs.Align.RIGHT],["INDEX",e,Blockly.inputs.Align.RIGHT],Blockly.inputs.Align.RIGHT);this.setPreviousStatement(!0);this.setNextStatement(!0);
this.setTooltip(Blockly.Msg.LANG_LISTS_REMOVE_ITEM_TOOLTIP);this.setInputsInline(!1)},typeblock:[{translatedName:Blockly.Msg.LANG_LISTS_REMOVE_ITEM_TITLE_REMOVE}]};
Blockly.Blocks.lists_append_list={category:"Lists",helpUrl:Blockly.Msg.LANG_LISTS_APPEND_LIST_HELPURL,init:function(){this.setColour(Blockly.LIST_CATEGORY_HUE);var d=AI.BlockUtils.YailTypeToBlocklyType("list",AI.BlockUtils.INPUT);this.interpolateMsg(Blockly.Msg.LANG_LISTS_APPEND_LIST_INPUT,["LIST0",d,Blockly.inputs.Align.RIGHT],["LIST1",d,Blockly.inputs.Align.RIGHT],Blockly.inputs.Align.RIGHT);this.setPreviousStatement(!0);this.setNextStatement(!0);this.setTooltip(Blockly.Msg.LANG_LISTS_APPEND_LIST_TOOLTIP);
this.setInputsInline(!1)},typeblock:[{translatedName:Blockly.Msg.LANG_LISTS_APPEND_LIST_TITLE_APPEND}]};
Blockly.Blocks.lists_copy={category:"Lists",helpUrl:Blockly.Msg.LANG_LISTS_COPY_HELPURL,init:function(){this.setColour(Blockly.LIST_CATEGORY_HUE);this.setOutput(!0,AI.BlockUtils.YailTypeToBlocklyType("list",AI.BlockUtils.OUTPUT));this.appendValueInput("LIST").setCheck(AI.BlockUtils.YailTypeToBlocklyType("list",AI.BlockUtils.INPUT)).appendField(Blockly.Msg.LANG_LISTS_COPY_TITLE_COPY).appendField(Blockly.Msg.LANG_LISTS_COPY_INPUT_LIST);this.setTooltip(Blockly.Msg.LANG_LISTS_COPY_TOOLTIP)},typeblock:[{translatedName:Blockly.Msg.LANG_LISTS_COPY_TITLE_COPY}]};
Blockly.Blocks.lists_is_list={category:"Lists",helpUrl:Blockly.Msg.LANG_LISTS_IS_LIST_HELPURL,init:function(){this.setColour(Blockly.LIST_CATEGORY_HUE);this.setOutput(!0,AI.BlockUtils.YailTypeToBlocklyType("boolean",AI.BlockUtils.OUTPUT));this.appendValueInput("ITEM").appendField(Blockly.Msg.LANG_LISTS_IS_LIST_TITLE_IS_LIST).appendField(Blockly.Msg.LANG_LISTS_IS_LIST_INPUT_THING);this.setTooltip(Blockly.Msg.LANG_LISTS_IS_LIST_TOOLTIP)},typeblock:[{translatedName:Blockly.Msg.LANG_LISTS_IS_LIST_TITLE_IS_LIST}]};
Blockly.Blocks.lists_reverse={category:"Lists",helpUrl:Blockly.Msg.LANG_LISTS_REVERSE_HELPURL,init:function(){this.setColour(Blockly.LIST_CATEGORY_HUE);this.setOutput(!0,AI.BlockUtils.YailTypeToBlocklyType("list",AI.BlockUtils.OUTPUT));this.appendValueInput("LIST").setCheck(AI.BlockUtils.YailTypeToBlocklyType("list",AI.BlockUtils.INPUT)).appendField(Blockly.Msg.LANG_LISTS_REVERSE_TITLE_REVERSE).appendField(Blockly.Msg.LANG_LISTS_REVERSE_INPUT_LIST);this.setTooltip(Blockly.Msg.LANG_LISTS_REVERSE_TOOLTIP)},
typeblock:[{translatedName:Blockly.Msg.LANG_LISTS_REVERSE_TITLE_REVERSE}]};
Blockly.Blocks.lists_to_csv_row={category:"Lists",helpUrl:Blockly.Msg.LANG_LISTS_TO_CSV_ROW_HELPURL,init:function(){this.setColour(Blockly.LIST_CATEGORY_HUE);this.setOutput(!0,AI.BlockUtils.YailTypeToBlocklyType("text",AI.BlockUtils.OUTPUT));this.appendValueInput("LIST").setCheck(AI.BlockUtils.YailTypeToBlocklyType("list",AI.BlockUtils.INPUT)).appendField(Blockly.Msg.LANG_LISTS_TO_CSV_ROW_TITLE_TO_CSV).appendField(Blockly.Msg.LANG_LISTS_TO_CSV_ROW_INPUT_LIST);this.setTooltip(Blockly.Msg.LANG_LISTS_TO_CSV_ROW_TOOLTIP)},
typeblock:[{translatedName:Blockly.Msg.LANG_LISTS_TO_CSV_ROW_TITLE_TO_CSV}]};
Blockly.Blocks.lists_to_csv_table={category:"Lists",helpUrl:Blockly.Msg.LANG_LISTS_TO_CSV_TABLE_HELPURL,init:function(){this.setColour(Blockly.LIST_CATEGORY_HUE);this.setOutput(!0,AI.BlockUtils.YailTypeToBlocklyType("text",AI.BlockUtils.OUTPUT));this.appendValueInput("LIST").setCheck(AI.BlockUtils.YailTypeToBlocklyType("list",AI.BlockUtils.INPUT)).appendField(Blockly.Msg.LANG_LISTS_TO_CSV_TABLE_TITLE_TO_CSV).appendField(Blockly.Msg.LANG_LISTS_TO_CSV_TABLE_INPUT_LIST);this.setTooltip(Blockly.Msg.LANG_LISTS_TO_CSV_TABLE_TOOLTIP)},
typeblock:[{translatedName:Blockly.Msg.LANG_LISTS_TO_CSV_TABLE_TITLE_TO_CSV}]};
Blockly.Blocks.lists_from_csv_row={category:"Lists",helpUrl:Blockly.Msg.LANG_LISTS_FROM_CSV_ROW_HELPURL,init:function(){this.setColour(Blockly.LIST_CATEGORY_HUE);this.setOutput(!0,AI.BlockUtils.YailTypeToBlocklyType("list",AI.BlockUtils.OUTPUT));this.appendValueInput("TEXT").setCheck(AI.BlockUtils.YailTypeToBlocklyType("text",AI.BlockUtils.INPUT)).appendField(Blockly.Msg.LANG_LISTS_FROM_CSV_ROW_TITLE_FROM_CSV).appendField(Blockly.Msg.LANG_LISTS_FROM_CSV_ROW_INPUT_TEXT);this.setTooltip(Blockly.Msg.LANG_LISTS_FROM_CSV_ROW_TOOLTIP)},
typeblock:[{translatedName:Blockly.Msg.LANG_LISTS_FROM_CSV_ROW_TITLE_FROM_CSV}]};
Blockly.Blocks.lists_from_csv_table={category:"Lists",helpUrl:Blockly.Msg.LANG_LISTS_FROM_CSV_TABLE_HELPURL,init:function(){this.setColour(Blockly.LIST_CATEGORY_HUE);this.setOutput(!0,AI.BlockUtils.YailTypeToBlocklyType("list",AI.BlockUtils.OUTPUT));this.appendValueInput("TEXT").setCheck(AI.BlockUtils.YailTypeToBlocklyType("text",AI.BlockUtils.INPUT)).appendField(Blockly.Msg.LANG_LISTS_FROM_CSV_TABLE_TITLE_FROM_CSV).appendField(Blockly.Msg.LANG_LISTS_FROM_CSV_TABLE_INPUT_TEXT);this.setTooltip(Blockly.Msg.LANG_LISTS_FROM_CSV_TABLE_TOOLTIP)},
typeblock:[{translatedName:Blockly.Msg.LANG_LISTS_FROM_CSV_TABLE_TITLE_FROM_CSV}]};
Blockly.Blocks.lists_lookup_in_pairs={category:"Lists",helpUrl:Blockly.Msg.LANG_LISTS_LOOKUP_IN_PAIRS_HELPURL,init:function(){this.setColour(Blockly.LIST_CATEGORY_HUE);this.setOutput(!0,AI.BlockUtils.YailTypeToBlocklyType("any",AI.BlockUtils.OUTPUT));var d=AI.BlockUtils.YailTypeToBlocklyType("list",AI.BlockUtils.INPUT);AI.BlockUtils.YailTypeToBlocklyType("number",AI.BlockUtils.INPUT);var e=AI.BlockUtils.YailTypeToBlocklyType("any",AI.BlockUtils.INPUT);this.interpolateMsg(Blockly.Msg.LANG_LISTS_LOOKUP_IN_PAIRS_INPUT,
["KEY",e,Blockly.inputs.Align.RIGHT],["LIST",d,Blockly.inputs.Align.RIGHT],["NOTFOUND",e,Blockly.inputs.Align.RIGHT],Blockly.inputs.Align.RIGHT);this.setTooltip(Blockly.Msg.LANG_LISTS_LOOKUP_IN_PAIRS_TOOLTIP);this.setInputsInline(!1)},typeblock:[{translatedName:Blockly.Msg.LANG_LISTS_LOOKUP_IN_PAIRS_TITLE_LOOKUP_IN_PAIRS}]};
Blockly.Blocks.lists_join_with_separator={category:"Lists",helpUrl:Blockly.Msg.LANG_LISTS_JOIN_WITH_SEPARATOR_HELPURL,init:function(){this.setColour(Blockly.LIST_CATEGORY_HUE);this.setOutput(!0,AI.BlockUtils.YailTypeToBlocklyType("text",AI.BlockUtils.OUTPUT));var d=AI.BlockUtils.YailTypeToBlocklyType("list",AI.BlockUtils.INPUT),e=AI.BlockUtils.YailTypeToBlocklyType("text",AI.BlockUtils.INPUT);this.interpolateMsg(Blockly.Msg.LANG_LISTS_JOIN_WITH_SEPARATOR_INPUT,["SEPARATOR",e,Blockly.inputs.Align.RIGHT],
["LIST",d,Blockly.inputs.Align.RIGHT],Blockly.inputs.Align.RIGHT);this.setTooltip(Blockly.Msg.LANG_LISTS_JOIN_WITH_SEPARATOR_TOOLTIP);this.setInputsInline(!1)},typeblock:[{translatedName:Blockly.Msg.LANG_LISTS_JOIN_WITH_SEPARATOR_TITLE}]};
Blockly.Blocks.lists_map={category:"Lists",helpUrl:Blockly.Msg.LANG_LISTS_MAP_HELPURL,init:function(){this.setColour(Blockly.LIST_CATEGORY_HUE);this.appendValueInput("LIST").setCheck(AI.BlockUtils.YailTypeToBlocklyType("list",AI.BlockUtils.INPUT)).appendField(Blockly.Msg.LANG_LISTS_MAP_NONDEST_TITLE_MAP,"TITLE").setAlign(Blockly.inputs.Align.RIGHT);this.appendDummyInput("DESCRIPTION").appendField(Blockly.Msg.LANG_LISTS_MAP_INPUT_ITEM).appendField(new Blockly.FieldParameterFlydown(Blockly.Msg.LANG_LISTS_MAP_INPUT_VAR,
!0,Blockly.FieldFlydown.DISPLAY_BELOW),"VAR").appendField(Blockly.Msg.LANG_LISTS_MAP_INPUT_TO).setAlign(Blockly.inputs.Align.RIGHT);this.appendInputFromRegistry("indented_input","TO");this.setOutput(!0,null);this.setTooltip(Blockly.Msg.LANG_LISTS_MAP_TOOLTIP);this.setInputsInline(!1);this.lexicalVarPrefix=Blockly.localNamePrefix},getDeclaredVarFieldNamesAndPrefixes:function(){return[["VAR",Blockly.localNamePrefix]]},getScopedInputName:function(){return"TO"},saveConnections:Blockly.saveConnections,
typeblock:[{translatedName:Blockly.Msg.LANG_LISTS_MAP_INPUT_COLLAPSED_TEXT}]};AI.Blockly.Mixins.extend(Blockly.Blocks.lists_map,AI.Blockly.Mixins.LexicalVariableMethods);
Blockly.Blocks.lists_filter={category:"Lists",helpUrl:Blockly.Msg.LANG_LISTS_FILTER_HELPURL,init:function(){this.setColour(Blockly.LIST_CATEGORY_HUE);this.appendValueInput("LIST").setCheck(AI.BlockUtils.YailTypeToBlocklyType("list",AI.BlockUtils.INPUT)).appendField(Blockly.Msg.LANG_LISTS_FILTER_NONDEST_TITLE_FILTER,"TITLE").setAlign(Blockly.inputs.Align.RIGHT);this.appendDummyInput("DESCRIPTION").appendField(Blockly.Msg.LANG_LISTS_FILTER_INPUT_ITEM).appendField(new Blockly.FieldParameterFlydown(Blockly.Msg.LANG_LISTS_FILTER_INPUT_VAR,
!0,Blockly.FieldFlydown.DISPLAY_BELOW),"VAR").appendField(Blockly.Msg.LANG_LISTS_FILTER_INPUT_PASSING).setAlign(Blockly.inputs.Align.RIGHT);this.appendInputFromRegistry("indented_input","TEST").appendField(Blockly.Msg.LANG_LISTS_FILTER_INPUT_TEST);this.setOutput(!0,null);this.setTooltip(Blockly.Msg.LANG_LISTS_FILTER_TOOLTIP);this.setInputsInline(!1);this.lexicalVarPrefix=Blockly.localNamePrefix},saveConnections:Blockly.saveConnections,getDeclaredVarFieldNamesAndPrefixes:function(){return[["VAR",Blockly.localNamePrefix]]},
getScopedInputName:function(){return"TEST"},typeblock:[{translatedName:Blockly.Msg.LANG_LISTS_FILTER_INPUT_COLLAPSED_TEXT}]};AI.Blockly.Mixins.extend(Blockly.Blocks.lists_filter,AI.Blockly.Mixins.LexicalVariableMethods);
Blockly.Blocks.lists_reduce={category:"Lists",helpUrl:Blockly.Msg.LANG_LISTS_REDUCE_HELPURL,init:function(){this.setColour(Blockly.LIST_CATEGORY_HUE);this.appendValueInput("LIST").setCheck(AI.BlockUtils.YailTypeToBlocklyType("list",AI.BlockUtils.INPUT)).appendField(Blockly.Msg.LANG_LISTS_REDUCE_TITLE_REDUCE).appendField(Blockly.Msg.LANG_LISTS_REDUCE_INPUT_INLIST).setAlign(Blockly.inputs.Align.RIGHT);this.appendValueInput("INITANSWER").appendField(Blockly.Msg.LANG_LISTS_REDUCE_INPUT_INITIAL_ANSWER).setAlign(Blockly.inputs.Align.RIGHT);
this.appendDummyInput("DESCRIPTION").appendField(Blockly.Msg.LANG_LISTS_REDUCE_INPUT_COMBINE).appendField(new Blockly.FieldParameterFlydown(Blockly.Msg.LANG_LISTS_REDUCE_INPUT_VAR,!0,Blockly.FieldFlydown.DISPLAY_BELOW),"VAR1").appendField(Blockly.Msg.LANG_LISTS_REDUCE_INPUT_AND).appendField(new Blockly.FieldParameterFlydown(Blockly.Msg.LANG_LISTS_REDUCE_INPUT_ANSWER,!0,Blockly.FieldFlydown.DISPLAY_BELOW),"VAR2").setAlign(Blockly.inputs.Align.RIGHT);this.appendInputFromRegistry("indented_input","COMBINE");
this.setOutput(!0,null);this.setTooltip(Blockly.Msg.LANG_LISTS_REDUCE_TOOLTIP);this.setInputsInline(!1);this.lexicalVarPrefix=Blockly.localNamePrefix},getDeclaredVarFieldNamesAndPrefixes:function(){return[["VAR1",Blockly.localNamePrefix],["VAR2",Blockly.localNamePrefix]]},getScopedInputName:function(){return"COMBINE"},typeblock:[{translatedName:Blockly.Msg.LANG_LISTS_REDUCE_TITLE_REDUCE}]};AI.Blockly.Mixins.extend(Blockly.Blocks.lists_reduce,AI.Blockly.Mixins.LexicalVariableMethods);
Blockly.Blocks.lists_sort={category:"Lists",helpUrl:Blockly.Msg.LANG_LISTS_SORT_HELPURL,init:function(){this.setColour(Blockly.LIST_CATEGORY_HUE);this.appendValueInput("LIST").setCheck(AI.BlockUtils.YailTypeToBlocklyType("list",AI.BlockUtils.INPUT)).appendField(Blockly.Msg.LANG_LISTS_SORT_NONDEST_TITLE_SORT,"TITLE");this.setOutput(!0,null);this.setTooltip(Blockly.Msg.LANG_LISTS_SORT_TOOLTIP);this.setInputsInline(!1)},saveConnections:Blockly.saveConnections,typeblock:[{translatedName:Blockly.Msg.LANG_LISTS_SORT_NONDEST_TITLE_SORT}]};
Blockly.Blocks.lists_sort_comparator={category:"Lists",helpUrl:Blockly.Msg.LANG_LISTS_SORT_COMPARATOR_HELPURL,init:function(){this.setColour(Blockly.LIST_CATEGORY_HUE);this.appendValueInput("LIST").setCheck(AI.BlockUtils.YailTypeToBlocklyType("list",AI.BlockUtils.INPUT)).appendField(Blockly.Msg.LANG_LISTS_SORT_COMPARATOR_NONDEST_TITLE_SORT,"TITLE").setAlign(Blockly.inputs.Align.RIGHT);this.appendDummyInput("DESCRIPTION").appendField(Blockly.Msg.LANG_LISTS_SORT_COMPARATOR_INPUT_COMPARATOR).appendField(new Blockly.FieldParameterFlydown(Blockly.Msg.LANG_LISTS_SORT_COMPARATOR_INPUT_VAR1,
!0,Blockly.FieldFlydown.DISPLAY_BELOW),"VAR1").appendField(Blockly.Msg.LANG_LISTS_SORT_COMPARATOR_INPUT_AND).appendField(new Blockly.FieldParameterFlydown(Blockly.Msg.LANG_LISTS_SORT_COMPARATOR_INPUT_VAR2,!0,Blockly.FieldFlydown.DISPLAY_BELOW),"VAR2").appendField(Blockly.Msg.LANG_LISTS_SORT_COMPARATOR_INPUT_COMPARATOR2).setAlign(Blockly.inputs.Align.RIGHT);this.appendInputFromRegistry("indented_input","COMPARE");this.setOutput(!0,null);this.setTooltip(Blockly.Msg.LANG_LISTS_SORT_COMPARATOR_TOOLTIP);
this.setInputsInline(!1);this.lexicalVarPrefix=Blockly.localNamePrefix},saveConnections:Blockly.saveConnections,getDeclaredVarFieldNamesAndPrefixes:function(){return[["VAR1",Blockly.localNamePrefix],["VAR2",Blockly.localNamePrefix]]},getScopedInputName:function(){return"COMPARE"},typeblock:[{translatedName:Blockly.Msg.LANG_LISTS_SORT_COMPARATOR_INPUT_COLLAPSED_TEXT}]};AI.Blockly.Mixins.extend(Blockly.Blocks.lists_sort_comparator,AI.Blockly.Mixins.LexicalVariableMethods);
Blockly.Blocks.lists_sort_key={category:"Lists",helpUrl:Blockly.Msg.LANG_LISTS_SORT_KEY_HELPURL,init:function(){this.setColour(Blockly.LIST_CATEGORY_HUE);this.appendValueInput("LIST").setCheck(AI.BlockUtils.YailTypeToBlocklyType("list",AI.BlockUtils.INPUT)).appendField(Blockly.Msg.LANG_LISTS_SORT_KEY_NONDEST_TITLE_SORT,"TITLE").setAlign(Blockly.inputs.Align.RIGHT);this.appendDummyInput("DESCRIPTION").appendField(Blockly.Msg.LANG_LISTS_SORT_KEY_INPUT_KEY).appendField(new Blockly.FieldParameterFlydown(Blockly.Msg.LANG_LISTS_SORT_KEY_INPUT_VAR,
!0,Blockly.FieldFlydown.DISPLAY_BELOW),"VAR").setAlign(Blockly.inputs.Align.RIGHT);this.appendInputFromRegistry("indented_input","KEY");this.setOutput(!0,null);this.setTooltip(Blockly.Msg.LANG_LISTS_SORT_KEY_TOOLTIP);this.setInputsInline(!1);this.lexicalVarPrefix=Blockly.localNamePrefix},saveConnections:Blockly.saveConnections,getDeclaredVarFieldNamesAndPrefixes:function(){return[["VAR",Blockly.localNamePrefix]]},getScopedInputName:function(){return"KEY"},typeblock:[{translatedName:Blockly.Msg.LANG_LISTS_SORT_KEY_INPUT_COLLAPSED_TEXT}]};
AI.Blockly.Mixins.extend(Blockly.Blocks.lists_sort_key,AI.Blockly.Mixins.LexicalVariableMethods);
Blockly.Blocks.lists_minimum_value={category:"Lists",helpUrl:Blockly.Msg.LANG_LISTS_MIN_NUMBER_HELPURL,init:function(){this.setColour(Blockly.LIST_CATEGORY_HUE);this.appendValueInput("LIST").setCheck(AI.BlockUtils.YailTypeToBlocklyType("list",AI.BlockUtils.INPUT)).appendField(Blockly.Msg.LANG_LISTS_MIN_NUMBER_INPUT_MIN,"TITLE").setAlign(Blockly.inputs.Align.RIGHT);this.appendDummyInput("DESCRIPTION").appendField(Blockly.Msg.LANG_LISTS_MIN_NUMBER_INPUT_COMPARATOR).appendField(new Blockly.FieldParameterFlydown(Blockly.Msg.LANG_LISTS_MIN_NUMBER_INPUT_VAR1,!0,
Blockly.FieldFlydown.DISPLAY_BELOW),"VAR1").appendField(Blockly.Msg.LANG_LISTS_MIN_NUMBER_INPUT_AND).appendField(new Blockly.FieldParameterFlydown(Blockly.Msg.LANG_LISTS_MIN_NUMBER_INPUT_VAR2,!0,Blockly.FieldFlydown.DISPLAY_BELOW),"VAR2").appendField(Blockly.Msg.LANG_LISTS_MIN_NUMBER_INPUT_COMPARATOR2).setAlign(Blockly.inputs.Align.RIGHT);this.appendInputFromRegistry("indented_input","COMPARE");this.setOutput(!0,null);this.setTooltip(Blockly.Msg.LANG_LISTS_MIN_NUMBER_TOOLTIP);this.setInputsInline(!1);
this.lexicalVarPrefix=Blockly.localNamePrefix},saveConnections:Blockly.saveConnections,getDeclaredVarFieldNamesAndPrefixes:function(){return[["VAR1",Blockly.localNamePrefix],["VAR2",Blockly.localNamePrefix]]},getScopedInputName:function(){return"COMPARE"},typeblock:[{translatedName:Blockly.Msg.LANG_LISTS_MIN_NUMBER_TYPEBLOCK}]};AI.Blockly.Mixins.extend(Blockly.Blocks.lists_minimum_value,AI.Blockly.Mixins.LexicalVariableMethods);
Blockly.Blocks.lists_maximum_value={category:"Lists",helpUrl:Blockly.Msg.LANG_LISTS_MAX_NUMBER_HELPURL,init:function(){this.setColour(Blockly.LIST_CATEGORY_HUE);this.appendValueInput("LIST").setCheck(AI.BlockUtils.YailTypeToBlocklyType("list",AI.BlockUtils.INPUT)).appendField(Blockly.Msg.LANG_LISTS_MAX_NUMBER_INPUT_MAX,"TITLE").setAlign(Blockly.inputs.Align.RIGHT);this.appendDummyInput("DESCRIPTION").appendField(Blockly.Msg.LANG_LISTS_MAX_NUMBER_INPUT_COMPARATOR).appendField(new Blockly.FieldParameterFlydown(Blockly.Msg.LANG_LISTS_MAX_NUMBER_INPUT_VAR1,
!0,Blockly.FieldFlydown.DISPLAY_BELOW),"VAR1").appendField(Blockly.Msg.LANG_LISTS_MAX_NUMBER_INPUT_AND).appendField(new Blockly.FieldParameterFlydown(Blockly.Msg.LANG_LISTS_MAX_NUMBER_INPUT_VAR2,!0,Blockly.FieldFlydown.DISPLAY_BELOW),"VAR2").appendField(Blockly.Msg.LANG_LISTS_MAX_NUMBER_INPUT_COMPARATOR2).setAlign(Blockly.inputs.Align.RIGHT);this.appendInputFromRegistry("indented_input","COMPARE");this.setOutput(!0,null);this.setTooltip(Blockly.Msg.LANG_LISTS_MAX_NUMBER_TOOLTIP);this.setInputsInline(!1);
this.lexicalVarPrefix=Blockly.localNamePrefix},saveConnections:Blockly.saveConnections,getDeclaredVarFieldNamesAndPrefixes:function(){return[["VAR1",Blockly.localNamePrefix],["VAR2",Blockly.localNamePrefix]]},getScopedInputName:function(){return"COMPARE"},typeblock:[{translatedName:Blockly.Msg.LANG_LISTS_MAX_NUMBER_TYPEBLOCK}]};AI.Blockly.Mixins.extend(Blockly.Blocks.lists_maximum_value,AI.Blockly.Mixins.LexicalVariableMethods);
Blockly.Blocks.lists_but_first={category:"Lists",helpUrl:Blockly.Msg.LANG_LISTS_BUT_FIRST_HELPURL,init:function(){this.setColour(Blockly.LIST_CATEGORY_HUE);this.appendValueInput("LIST").setCheck(AI.BlockUtils.YailTypeToBlocklyType("list",AI.BlockUtils.INPUT)).appendField(Blockly.Msg.LANG_LISTS_BUT_FIRST_INPUT_BUT_FIRST);this.setTooltip(Blockly.Msg.LANG_LISTS_BUT_FIRST_TOOLTIP);this.setOutput(!0,null);this.setInputsInline(!1)},saveConnections:Blockly.saveConnections,typeblock:[{translatedName:Blockly.Msg.LANG_LISTS_BUT_FIRST_INPUT_BUT_FIRST}]};
Blockly.Blocks.lists_but_last={category:"Lists",helpUrl:Blockly.Msg.LANG_LISTS_BUT_LAST_HELPURL,init:function(){this.setColour(Blockly.LIST_CATEGORY_HUE);this.appendValueInput("LIST").setCheck(AI.BlockUtils.YailTypeToBlocklyType("list",AI.BlockUtils.INPUT)).appendField(Blockly.Msg.LANG_LISTS_BUT_LAST_INPUT_BUT_LAST);this.setTooltip(Blockly.Msg.LANG_LISTS_BUT_LAST_TOOLTIP);this.setOutput(!0,null);this.setInputsInline(!1)},saveConnections:Blockly.saveConnections,typeblock:[{translatedName:Blockly.Msg.LANG_LISTS_BUT_LAST_INPUT_BUT_LAST}]};
Blockly.Blocks.lists_slice={category:"Lists",helpUrl:Blockly.Msg.LANG_LISTS_SLICE_HELPURL,init:function(){this.setColour(Blockly.LIST_CATEGORY_HUE);var d=AI.BlockUtils.YailTypeToBlocklyType("list",AI.BlockUtils.INPUT),e=AI.BlockUtils.YailTypeToBlocklyType("number",AI.BlockUtils.INPUT);this.interpolateMsg(Blockly.Msg.LANG_LISTS_SLICE_INPUT,["LIST",d,Blockly.inputs.Align.RIGHT],["INDEX1",e,Blockly.inputs.Align.RIGHT],["INDEX2",e,Blockly.inputs.Align.RIGHT],Blockly.inputs.Align.RIGHT);this.setTooltip(Blockly.Msg.LANG_LISTS_SLICE_TOOLTIP);
this.setInputsInline(!1);this.setOutput(!0,null)},saveConnections:Blockly.saveConnections,typeblock:[{translatedName:Blockly.Msg.LANG_LISTS_SLICE_TITLE_SLICE}]};/*

 @fileoverview Logic blocks for Blockly, modified for MIT App Inventor.
 @author mckinney@mit.edu (Andrew F. McKinney)
*/
AI.Blocks.logic={};
Blockly.Blocks.logic_boolean={category:"Logic",init:function(){this.setColour(Blockly.LOGIC_CATEGORY_HUE);this.setOutput(!0,AI.BlockUtils.YailTypeToBlocklyType("boolean",AI.BlockUtils.OUTPUT));this.appendDummyInput().appendField(new Blockly.FieldDropdown(this.OPERATORS),"BOOL");var d=this;this.setTooltip(function(){var e=d.getFieldValue("BOOL");return Blockly.Blocks.logic_boolean.TOOLTIPS()[e]})},helpUrl:function(){var d=this.getFieldValue("BOOL");return Blockly.Blocks.logic_boolean.HELPURLS()[d]},typeblock:[{translatedName:Blockly.Msg.LANG_LOGIC_BOOLEAN_TRUE,
dropDown:{titleName:"BOOL",value:"TRUE"}},{translatedName:Blockly.Msg.LANG_LOGIC_BOOLEAN_FALSE,dropDown:{titleName:"BOOL",value:"FALSE"}}]};Blockly.Blocks.logic_boolean.OPERATORS=function(){return[[Blockly.Msg.LANG_LOGIC_BOOLEAN_TRUE,"TRUE"],[Blockly.Msg.LANG_LOGIC_BOOLEAN_FALSE,"FALSE"]]};Blockly.Blocks.logic_boolean.TOOLTIPS=function(){return{TRUE:Blockly.Msg.LANG_LOGIC_BOOLEAN_TOOLTIP_TRUE,FALSE:Blockly.Msg.LANG_LOGIC_BOOLEAN_TOOLTIP_FALSE}};
Blockly.Blocks.logic_boolean.HELPURLS=function(){return{TRUE:Blockly.Msg.LANG_LOGIC_BOOLEAN_TRUE_HELPURL,FALSE:Blockly.Msg.LANG_LOGIC_BOOLEAN_FALSE_HELPURL}};
Blockly.Blocks.logic_false={category:"Logic",init:function(){this.setColour(Blockly.LOGIC_CATEGORY_HUE);this.setOutput(!0,AI.BlockUtils.YailTypeToBlocklyType("boolean",AI.BlockUtils.OUTPUT));this.appendDummyInput().appendField(new Blockly.FieldDropdown(Blockly.Blocks.logic_boolean.OPERATORS),"BOOL");this.setFieldValue("FALSE","BOOL");var d=this;this.setTooltip(function(){var e=d.getFieldValue("BOOL");return Blockly.Blocks.logic_boolean.TOOLTIPS()[e]})},helpUrl:function(){var d=this.getFieldValue("BOOL");
return Blockly.Blocks.logic_boolean.HELPURLS()[d]}};
Blockly.Blocks.logic_negate={category:"Logic",helpUrl:Blockly.Msg.LANG_LOGIC_NEGATE_HELPURL,init:function(){this.setColour(Blockly.LOGIC_CATEGORY_HUE);this.setOutput(!0,AI.BlockUtils.YailTypeToBlocklyType("boolean",AI.BlockUtils.OUTPUT));this.appendValueInput("BOOL").setCheck(AI.BlockUtils.YailTypeToBlocklyType("boolean",AI.BlockUtils.INPUT)).appendField(Blockly.Msg.LANG_LOGIC_NEGATE_INPUT_NOT);this.setTooltip(Blockly.Msg.LANG_LOGIC_NEGATE_TOOLTIP)},typeblock:[{translatedName:Blockly.Msg.LANG_LOGIC_NEGATE_INPUT_NOT}]};
Blockly.Blocks.logic_compare={category:"Logic",helpUrl:function(){var d=this.getFieldValue("OP");return Blockly.Blocks.logic_compare.HELPURLS()[d]},init:function(){this.setColour(Blockly.LOGIC_CATEGORY_HUE);this.setOutput(!0,AI.BlockUtils.YailTypeToBlocklyType("boolean",AI.BlockUtils.OUTPUT));this.appendValueInput("A");this.appendValueInput("B").appendField(new Blockly.FieldDropdown(this.OPERATORS),"OP");this.setInputsInline(!0);var d=this;this.setTooltip(function(){var e=d.getFieldValue("OP");return Blockly.Blocks.logic_compare.TOOLTIPS()[e]})},
typeblock:[{translatedName:Blockly.Msg.LANG_LOGIC_COMPARE_TRANSLATED_NAME}]};Blockly.Blocks.logic_compare.TOOLTIPS=function(){return{EQ:Blockly.Msg.LANG_LOGIC_COMPARE_TOOLTIP_EQ,NEQ:Blockly.Msg.LANG_LOGIC_COMPARE_TOOLTIP_NEQ}};Blockly.Blocks.logic_compare.HELPURLS=function(){return{EQ:Blockly.Msg.LANG_LOGIC_COMPARE_HELPURL_EQ,NEQ:Blockly.Msg.LANG_LOGIC_COMPARE_HELPURL_NEQ}};
Blockly.Blocks.logic_compare.OPERATORS=function(){return[[Blockly.Msg.LANG_LOGIC_COMPARE_EQ,"EQ"],[Blockly.Msg.LANG_LOGIC_COMPARE_NEQ,"NEQ"]]};
Blockly.Blocks.logic_operation={category:"Logic",init:function(d){d=d||"AND";var e=this;this.opField=new Blockly.FieldDropdown(Blockly.Blocks.logic_operation.OPERATORS,function(h){return e.updateFields(h)});this.lastMutator=null;this.setColour(Blockly.LOGIC_CATEGORY_HUE);this.setOutput(!0,AI.BlockUtils.YailTypeToBlocklyType("boolean",AI.BlockUtils.OUTPUT));this.appendValueInput("A").setCheck(AI.BlockUtils.YailTypeToBlocklyType("boolean",AI.BlockUtils.INPUT));this.appendValueInput("B").setCheck(AI.BlockUtils.YailTypeToBlocklyType("boolean",
AI.BlockUtils.INPUT)).appendField(this.opField,"OP");this.setFieldValue(d,"OP");this.setInputsInline(!0);this.setTooltip(function(){return Blockly.Blocks.logic_operation.TOOLTIPS()[e.getFieldValue("OP")]});this.setMutator(new Blockly.icons.MutatorIcon(["logic_mutator_item"],this));this.emptyInputName="EMPTY";this.repeatingInputName="BOOL";this.itemCount_=2;this.valuesToSave={op:d}},mutationToDom:Blockly.mutationToDom,domToMutation:function(d){if(null!=this.valuesToSave)for(var e in this.valuesToSave)this.valuesToSave[e]=
this.getFieldValue(e);0===this.itemCount_&&this.removeInput(this.emptyInputName,!0);0<this.itemCount_&&this.removeInput("A",!0);1<this.itemCount_&&this.removeInput("B",!0);for(e=2;e<this.itemCount_;e++)this.removeInput(this.repeatingInputName+e,!0);this.itemCount_=window.parseInt(d.getAttribute("items"),10);for(e=0;e<this.itemCount_;e++)this.addInput(e);0===this.itemCount_&&this.addEmptyInput();var h=this.opField.setValue,k=this;this.opField.setValue=function(m){h.call(this,m);k.updateFields(m)}},
decompose:function(d){var e=d.newBlock("mutator_container");e.setColour(this.getColour());e.setFieldValue(this.opField.getValue(),"CONTAINER_TEXT");e.initSvg();for(var h=e.getInput("STACK").connection,k=0;k<this.itemCount_;k++){var m=d.newBlock("logic_mutator_item");m.initSvg();h.connect(m.previousConnection);h=m.nextConnection}this.lastMutator=d;return e},countNumberOfInputs:function(d){d=d.getInputTargetBlock("STACK");for(var e=0;d;)e++,d=d.getNextBlock();return e},compose:function(d){if(null!=
this.valuesToSave)for(var e in this.valuesToSave)this.valuesToSave[e]=this.getFieldValue(e);0===this.itemCount_&&this.removeInput(this.emptyInputName,!0);for(e=this.itemCount_-1;0<=e;e--)this.removeInput(1<e?this.repeatingInputName+e:["A","B"][e],!0);e=d.getInputTargetBlock("STACK");this.itemCount_=this.countNumberOfInputs(d);for(d=0;e;){var h=this.addInput(d);e.valueConnection_&&h.connection.connect(e.valueConnection_);d++;e=e.nextConnection&&e.nextConnection.targetBlock()}0===this.itemCount_&&this.addEmptyInput()},
saveConnections:function(d){d=d.getInputTargetBlock("STACK");for(var e=0;d;){var h=this.getInput(1<e?this.repeatingInputName+e:["A","B"][e]);d.valueConnection_=h&&h.connection.targetConnection;e++;d=d.nextConnection&&d.nextConnection.targetBlock()}},addInput:function(d){var e=this.appendValueInput(1<d?this.repeatingInputName+d:["A","B"][d]).setCheck(AI.BlockUtils.YailTypeToBlocklyType("boolean",AI.BlockUtils.INPUT));this.getInputsInline()?1===d?this.makeDropdown(e):1<d?(d=new Blockly.FieldLabel(this.opField.getValue()),
e.appendField(d),d.init()):1===this.itemCount_&&(e.appendField(Blockly.Blocks.logic_operation.IDENTITY(this.opField.getValue()),"IDENTITY"),this.makeDropdown(e)):0===d&&this.makeDropdown(e);return e},addEmptyInput:function(){this.makeDropdown(this.appendDummyInput(this.emptyInputName))},makeDropdown:function(d){var e=this.opField.getValue();this.opField.dispose();this.opField=new Blockly.FieldDropdown(Blockly.Blocks.logic_operation.OPERATORS(),this.updateFields.bind(this));this.opField.setValue(e);
d.appendField(this.opField,"OP");this.opField.init();return d},helpUrl:function(){var d=this.getFieldValue("OP");return Blockly.Blocks.logic_operation.HELPURLS()[d]},setInputsInline:function(d){if(d){var e=this.getInput("A");e&&0<e.fieldRow.length&&(e.fieldRow.splice(0,1),e=this.getInput("B"),this.makeDropdown(e));e="AND"===this.opField.getValue()?Blockly.Msg.LANG_LOGIC_OPERATION_AND:Blockly.Msg.LANG_LOGIC_OPERATION_OR;for(var h,k=2;h=this.inputList[k];k++){var m=new Blockly.FieldLabel(e);h.appendField(m);
m.init()}}else for((e=this.getInput("B"))&&0<e.fieldRow.length&&(e.fieldRow.splice(0,1),e=this.getInput("A"),this.makeDropdown(e)),k=2;h=this.inputList[k];k++)h.fieldRow[0]&&h.fieldRow[0].dispose(),h.fieldRow.splice(0,1);Blockly.BlockSvg.prototype.setInputsInline.call(this,d)},updateFields:function(d){if(this.getInputsInline())for(var e="AND"===d?Blockly.Msg.LANG_LOGIC_OPERATION_AND:Blockly.Msg.LANG_LOGIC_OPERATION_OR,h,k=2;h=this.inputList[k];k++)h.fieldRow[0].setValue(e);1===this.itemCount_&&(e=
this.getField("IDENTITY"))&&e.setValue(Blockly.Blocks.logic_operation.IDENTITY(d));this.lastMutator&&(e=this.lastMutator.getTopBlocks(!1)[0])&&e.setFieldValue("AND"===d?Blockly.Msg.LANG_LOGIC_OPERATION_AND:Blockly.Msg.LANG_LOGIC_OPERATION_OR,"CONTAINER_TEXT");return d},typeblock:[{translatedName:Blockly.Msg.LANG_LOGIC_OPERATION_AND,dropDown:{titleName:"OP",value:"AND"}},{translatedName:Blockly.Msg.LANG_LOGIC_OPERATION_OR,dropDown:{titleName:"OP",value:"OR"}}]};
Blockly.Blocks.logic_operation.OPERATORS=function(){return[[Blockly.Msg.LANG_LOGIC_OPERATION_AND,"AND"],[Blockly.Msg.LANG_LOGIC_OPERATION_OR,"OR"]]};Blockly.Blocks.logic_operation.IDENTITY=function(d){return{AND:Blockly.Msg.LANG_LOGIC_BOOLEAN_TRUE,OR:Blockly.Msg.LANG_LOGIC_BOOLEAN_FALSE}[d]};Blockly.Blocks.logic_operation.HELPURLS=function(){return{AND:Blockly.Msg.LANG_LOGIC_OPERATION_HELPURL_AND,OR:Blockly.Msg.LANG_LOGIC_OPERATION_HELPURL_OR}};
Blockly.Blocks.logic_operation.TOOLTIPS=function(){return{AND:Blockly.Msg.LANG_LOGIC_OPERATION_TOOLTIP_AND,OR:Blockly.Msg.LANG_LOGIC_OPERATION_TOOLTIP_OR}};
Blockly.Blocks.logic_or={category:"Logic",init:function(){Blockly.Blocks.logic_operation.init.call(this,"OR")},mutationToDom:Blockly.Blocks.logic_operation.mutationToDom,domToMutation:Blockly.Blocks.logic_operation.domToMutation,decompose:Blockly.Blocks.logic_operation.decompose,countNumberOfInputs:Blockly.Blocks.logic_operation.countNumberOfInputs,compose:Blockly.Blocks.logic_operation.compose,saveConnections:Blockly.Blocks.logic_operation.saveConnections,addInput:Blockly.Blocks.logic_operation.addInput,
addEmptyInput:Blockly.Blocks.logic_operation.addEmptyInput,makeDropdown:Blockly.Blocks.logic_operation.makeDropdown,helpUrl:Blockly.Blocks.logic_operation.helpUrl,setInputsInline:Blockly.Blocks.logic_operation.setInputsInline,updateFields:Blockly.Blocks.logic_operation.updateFields};Blockly.Blocks.logic_mutator_item={init:function(){this.setColour(Blockly.LOGIC_CATEGORY_HUE);this.appendDummyInput().appendField("boolean");this.setPreviousStatement(!0);this.setNextStatement(!0);this.contextMenu=!1}};/*

 @fileoverview Math blocks for Blockly, modified for MIT App Inventor.
 @author mckinney@mit.edu (Andrew F. McKinney)
*/
AI.Blocks.math={};Blockly.Blocks.math_number={category:"Math",helpUrl:Blockly.Msg.LANG_MATH_NUMBER_HELPURL,init:function(){this.setColour(Blockly.MATH_CATEGORY_HUE);this.appendDummyInput().appendField(new Blockly.FieldTextInput("0",Blockly.Blocks.math_number.validator),"NUM");this.setOutput(!0,AI.BlockUtils.YailTypeToBlocklyType("number",AI.BlockUtils.OUTPUT));this.setTooltip(Blockly.Msg.LANG_MATH_NUMBER_TOOLTIP)},typeblock:[{translatedName:Blockly.Msg.LANG_MATH_MUTATOR_ITEM_INPUT_NUMBER}]};
Blockly.Blocks.math_number.validator=function(d){var e=Number(d||0);return window.isNaN(e)?(e=window.parseFloat(d||0),window.isNaN(e)?null:String(e)):d};
Blockly.Blocks.math_number_radix={category:"Math",helpUrl:Blockly.Msg.LANG_MATH_NUMBER_RADIX_HELPURL,init:function(){this.dropdown=new Blockly.FieldDropdown([[Blockly.Msg.LANG_MATH_DECIMAL_FORMAT,"DEC"],[Blockly.Msg.LANG_MATH_BINARY_FORMAT,"BIN"],[Blockly.Msg.LANG_MATH_OCTAL_FORMAT,"OCT"],[Blockly.Msg.LANG_MATH_HEXADECIMAL_FORMAT,"HEX"]],this.dropdownListener);this.numberField=new Blockly.FieldTextInput("0",this.numberValidator);this.currentPrefix=Blockly.Blocks.math_number_radix.PREFIX.DEC;this.setColour(Blockly.MATH_CATEGORY_HUE);
this.appendDummyInput().appendField(this.dropdown,"OP").appendField(this.numberField,"NUM");this.setOutput(!0,AI.BlockUtils.YailTypeToBlocklyType("number",AI.BlockUtils.OUTPUT));this.setTooltip(Blockly.Msg.LANG_MATH_NUMBER_RADIX_TOOLTIP)},typeblock:[{translatedName:Blockly.Msg.LANG_MATH_NUMBER_RADIX_TITLE}],dropdownListener:function(d){this.getSourceBlock().currentPrefix=Blockly.Blocks.math_number_radix.PREFIX[d];var e=this.getSourceBlock().numberField,h=Blockly.Blocks.math_number_radix.PREFIX[this.getValue()],
k=Number(h+e.getValue()),m=Blockly.Blocks.math_number_radix.RADIX[d];AI.Blockly.multiselect.withoutMultiFieldUpdates(function(){e.setValue(k.toString(m))})},numberValidator:function(d){if(!d)return 0;var e=Number(this.getSourceBlock().currentPrefix+d);return window.isNaN(e)?null:d}};Blockly.Blocks.math_number_radix.PREFIX={DEC:"",BIN:"0b",OCT:"0o",HEX:"0x"};Blockly.Blocks.math_number_radix.RADIX={DEC:10,BIN:2,OCT:8,HEX:16};
Blockly.Blocks.math_compare={category:"Math",helpUrl:function(){var d=this.getFieldValue("OP");return Blockly.Blocks.math_compare.HELPURLS()[d]},init:function(){this.setColour(Blockly.MATH_CATEGORY_HUE);this.setOutput(!0,AI.BlockUtils.YailTypeToBlocklyType("boolean",AI.BlockUtils.OUTPUT));this.appendValueInput("A").setCheck(null);this.appendValueInput("B").setCheck(null).appendField(new Blockly.FieldDropdown(Blockly.Blocks.math_compare.OPERATORS(),Blockly.Blocks.math_compare.onchange),"OP");this.setInputsInline(!0);
var d=this;this.setTooltip(function(){var e=d.getFieldValue("OP");return Blockly.Blocks.math_compare.TOOLTIPS()[e]})},typeblock:[{translatedName:Blockly.Msg.LANG_MATH_COMPARE_EQ,dropDown:{titleName:"OP",value:"EQ"}},{translatedName:Blockly.Msg.LANG_MATH_COMPARE_NEQ,dropDown:{titleName:"OP",value:"NEQ"}},{translatedName:Blockly.Msg.LANG_MATH_COMPARE_LT,dropDown:{titleName:"OP",value:"LT"}},{translatedName:Blockly.Msg.LANG_MATH_COMPARE_LTE,dropDown:{titleName:"OP",value:"LTE"}},{translatedName:Blockly.Msg.LANG_MATH_COMPARE_GT,
dropDown:{titleName:"OP",value:"GT"}},{translatedName:Blockly.Msg.LANG_MATH_COMPARE_GTE,dropDown:{titleName:"OP",value:"GTE"}}]};
Blockly.Blocks.math_compare.onchange=function(d){this.getSourceBlock&&this.getSourceBlock()&&("EQ"==d||"NEQ"==d?(this.getSourceBlock().getInput("A").setCheck(null),this.getSourceBlock().getInput("B").setCheck(null)):(this.getSourceBlock().getInput("A").setCheck(AI.BlockUtils.YailTypeToBlocklyType("number",AI.BlockUtils.INPUT)),this.getSourceBlock().getInput("B").setCheck(AI.BlockUtils.YailTypeToBlocklyType("number",AI.BlockUtils.INPUT))))};
Blockly.Blocks.math_compare.OPERATORS=function(){return[[Blockly.Msg.LANG_MATH_COMPARE_EQ,"EQ"],[Blockly.Msg.LANG_MATH_COMPARE_NEQ,"NEQ"],[Blockly.Msg.LANG_MATH_COMPARE_LT,"LT"],[Blockly.Msg.LANG_MATH_COMPARE_LTE,"LTE"],[Blockly.Msg.LANG_MATH_COMPARE_GT,"GT"],[Blockly.Msg.LANG_MATH_COMPARE_GTE,"GTE"]]};
Blockly.Blocks.math_compare.TOOLTIPS=function(){return{EQ:Blockly.Msg.LANG_MATH_COMPARE_TOOLTIP_EQ,NEQ:Blockly.Msg.LANG_MATH_COMPARE_TOOLTIP_NEQ,LT:Blockly.Msg.LANG_MATH_COMPARE_TOOLTIP_LT,LTE:Blockly.Msg.LANG_MATH_COMPARE_TOOLTIP_LTE,GT:Blockly.Msg.LANG_MATH_COMPARE_TOOLTIP_GT,GTE:Blockly.Msg.LANG_MATH_COMPARE_TOOLTIP_GTE}};
Blockly.Blocks.math_compare.HELPURLS=function(){return{EQ:Blockly.Msg.LANG_MATH_COMPARE_HELPURL_EQ,NEQ:Blockly.Msg.LANG_MATH_COMPARE_HELPURL_NEQ,LT:Blockly.Msg.LANG_MATH_COMPARE_HELPURL_LT,LTE:Blockly.Msg.LANG_MATH_COMPARE_HELPURL_LTE,GT:Blockly.Msg.LANG_MATH_COMPARE_HELPURL_GT,GTE:Blockly.Msg.LANG_MATH_COMPARE_HELPURL_GTE}};
Blockly.Blocks.math_add={category:"Math",helpUrl:Blockly.Msg.LANG_MATH_ARITHMETIC_HELPURL_ADD,init:function(){this.setColour(Blockly.MATH_CATEGORY_HUE);this.setOutput(!0,AI.BlockUtils.YailTypeToBlocklyType("number",AI.BlockUtils.OUTPUT));this.appendValueInput("NUM0").setCheck(AI.BlockUtils.YailTypeToBlocklyType("number",AI.BlockUtils.INPUT));this.appendValueInput("NUM1").setCheck(AI.BlockUtils.YailTypeToBlocklyType("number",AI.BlockUtils.INPUT)).appendField(Blockly.Msg.LANG_MATH_ARITHMETIC_ADD);this.setInputsInline(!0);
this.setTooltip(function(){return Blockly.Msg.LANG_MATH_ARITHMETIC_TOOLTIP_ADD});this.setMutator(new Blockly.icons.MutatorIcon(["math_mutator_item"],this));this.emptyInputName="EMPTY";this.repeatingInputName="NUM";this.itemCount_=2},mutationToDom:Blockly.mutationToDom,domToMutation:function(d){Blockly.domToMutation.call(this,d);1===this.itemCount_&&this.inputList[0].appendField("0 "+Blockly.Msg.LANG_MATH_ARITHMETIC_ADD)},decompose:function(d){return Blockly.decompose(d,"math_mutator_item",this)},
compose:function(d){Blockly.compose.call(this,d);1===this.itemCount_&&this.inputList[0].appendField("0 "+Blockly.Msg.LANG_MATH_ARITHMETIC_ADD)},saveConnections:Blockly.saveConnections,addEmptyInput:function(){this.appendDummyInput(this.emptyInputName).appendField(Blockly.Msg.LANG_MATH_ARITHMETIC_ADD)},addInput:function(d){var e=this.appendValueInput(this.repeatingInputName+d).setCheck(AI.BlockUtils.YailTypeToBlocklyType("number",AI.BlockUtils.INPUT));0!==d&&e.appendField(Blockly.Msg.LANG_MATH_ARITHMETIC_ADD);
return e},updateContainerBlock:function(d){d.setFieldValue("+","CONTAINER_TEXT")},typeblock:[{translatedName:Blockly.Msg.LANG_MATH_ARITHMETIC_ADD}]};Blockly.Blocks.math_mutator_item={init:function(){this.setColour(Blockly.MATH_CATEGORY_HUE);this.appendDummyInput().appendField("number");this.setPreviousStatement(!0);this.setNextStatement(!0);this.contextMenu=!1}};
Blockly.Blocks.math_subtract={category:"Math",helpUrl:Blockly.Msg.LANG_MATH_ARITHMETIC_HELPURL_MINUS,init:function(){this.setColour(Blockly.MATH_CATEGORY_HUE);this.setOutput(!0,AI.BlockUtils.YailTypeToBlocklyType("number",AI.BlockUtils.OUTPUT));this.appendValueInput("A").setCheck(AI.BlockUtils.YailTypeToBlocklyType("number",AI.BlockUtils.INPUT));this.appendValueInput("B").setCheck(AI.BlockUtils.YailTypeToBlocklyType("number",AI.BlockUtils.INPUT)).appendField(Blockly.Msg.LANG_MATH_ARITHMETIC_MINUS);
this.setInputsInline(!0);this.setTooltip(Blockly.Msg.LANG_MATH_ARITHMETIC_TOOLTIP_MINUS)},typeblock:[{translatedName:Blockly.Msg.LANG_MATH_ARITHMETIC_MINUS}]};
Blockly.Blocks.math_multiply={category:"Math",helpUrl:Blockly.Msg.LANG_MATH_ARITHMETIC_HELPURL_MULTIPLY,init:function(){this.setColour(Blockly.MATH_CATEGORY_HUE);this.setOutput(!0,AI.BlockUtils.YailTypeToBlocklyType("number",AI.BlockUtils.OUTPUT));this.appendValueInput("NUM0").setCheck(AI.BlockUtils.YailTypeToBlocklyType("number",AI.BlockUtils.INPUT));this.appendValueInput("NUM1").setCheck(AI.BlockUtils.YailTypeToBlocklyType("number",AI.BlockUtils.INPUT)).appendField(AI.BlockUtils.times_symbol);this.setInputsInline(!0);
this.setTooltip(function(){return Blockly.Msg.LANG_MATH_ARITHMETIC_TOOLTIP_MULTIPLY});this.setMutator(new Blockly.icons.MutatorIcon(["math_mutator_item"],this));this.emptyInputName="EMPTY";this.repeatingInputName="NUM";this.itemCount_=2},mutationToDom:Blockly.mutationToDom,domToMutation:function(d){Blockly.domToMutation.call(this,d);1===this.itemCount_&&this.inputList[0].appendField("1 "+AI.BlockUtils.times_symbol)},decompose:function(d){return Blockly.decompose(d,"math_mutator_item",this)},compose:function(d){Blockly.compose.call(this,
d);1===this.itemCount_&&this.inputList[0].appendField("1 "+AI.BlockUtils.times_symbol)},saveConnections:Blockly.saveConnections,addEmptyInput:function(){this.appendDummyInput(this.emptyInputName).appendField(AI.BlockUtils.times_symbol)},addInput:function(d){var e=this.appendValueInput(this.repeatingInputName+d).setCheck(AI.BlockUtils.YailTypeToBlocklyType("number",AI.BlockUtils.INPUT));0!==d&&e.appendField(AI.BlockUtils.times_symbol);return e},updateContainerBlock:function(d){d.setFieldValue(AI.BlockUtils.times_symbol,
"CONTAINER_TEXT")},typeblock:[{translatedName:Blockly.Msg.LANG_MATH_ARITHMETIC_MULTIPLY}]};
Blockly.Blocks.math_division={category:"Math",helpUrl:Blockly.Msg.LANG_MATH_ARITHMETIC_HELPURL_DIVIDE,init:function(){this.setColour(Blockly.MATH_CATEGORY_HUE);this.setOutput(!0,AI.BlockUtils.YailTypeToBlocklyType("number",AI.BlockUtils.OUTPUT));this.appendValueInput("A").setCheck(AI.BlockUtils.YailTypeToBlocklyType("number",AI.BlockUtils.INPUT));this.appendValueInput("B").setCheck(AI.BlockUtils.YailTypeToBlocklyType("number",AI.BlockUtils.INPUT)).appendField(Blockly.Msg.LANG_MATH_ARITHMETIC_DIVIDE);
this.setInputsInline(!0);this.setTooltip(Blockly.Msg.LANG_MATH_ARITHMETIC_TOOLTIP_DIVIDE)},typeblock:[{translatedName:Blockly.Msg.LANG_MATH_ARITHMETIC_DIVIDE}]};
Blockly.Blocks.math_power={category:"Math",helpUrl:Blockly.Msg.LANG_MATH_ARITHMETIC_HELPURL_POWER,init:function(){this.setColour(Blockly.MATH_CATEGORY_HUE);this.setOutput(!0,AI.BlockUtils.YailTypeToBlocklyType("number",AI.BlockUtils.OUTPUT));this.appendValueInput("A").setCheck(AI.BlockUtils.YailTypeToBlocklyType("number",AI.BlockUtils.INPUT));this.appendValueInput("B").setCheck(AI.BlockUtils.YailTypeToBlocklyType("number",AI.BlockUtils.INPUT)).appendField(Blockly.Msg.LANG_MATH_ARITHMETIC_POWER);this.setInputsInline(!0);
this.setTooltip(Blockly.Msg.LANG_MATH_ARITHMETIC_TOOLTIP_POWER)},typeblock:[{translatedName:Blockly.Msg.LANG_MATH_ARITHMETIC_POWER}]};
Blockly.Blocks.math_bitwise={category:"Math",helpUrl:function(){var d=this.getFieldValue("OP");return Blockly.Blocks.math_bitwise.HELPURLS()[d]},init:function(){var d=this;this.setColour(Blockly.MATH_CATEGORY_HUE);this.setOutput(!0,AI.BlockUtils.YailTypeToBlocklyType("number",AI.BlockUtils.OUTPUT));this.appendValueInput("NUM0").setCheck(AI.BlockUtils.YailTypeToBlocklyType("number",AI.BlockUtils.INPUT)).appendField(new Blockly.FieldDropdown(Blockly.Blocks.math_bitwise.OPERATORS),"OP");this.appendValueInput("NUM1").setCheck(AI.BlockUtils.YailTypeToBlocklyType("number",
AI.BlockUtils.INPUT));this.setInputsInline(!1);this.setTooltip(function(){var e=d.getFieldValue("OP");return Blockly.Blocks.math_bitwise.TOOLTIPS()[e]});this.setMutator(new Blockly.icons.MutatorIcon(["math_mutator_item"],this));this.itemCount_=2;this.valuesToSave={OP:null};this.emptyInputName="EMPTY";this.repeatingInputName="NUM"},mutationToDom:Blockly.mutationToDom,domToMutation:Blockly.domToMutation,decompose:function(d){return Blockly.decompose(d,"math_mutator_item",this)},compose:Blockly.compose,
saveConnections:Blockly.saveConnections,addEmptyInput:function(){this.appendDummyInput(this.emptyInputName).appendField(new Blockly.FieldDropdown(Blockly.Blocks.math_bitwise.OPERATORS),"OP");this.setFieldValue(this.valuesToSave.OP,"OP")},addInput:function(d){var e=this.appendValueInput(this.repeatingInputName+d).setCheck(AI.BlockUtils.YailTypeToBlocklyType("number",AI.BlockUtils.INPUT));0==d&&(e.appendField(new Blockly.FieldDropdown(Blockly.Blocks.math_bitwise.OPERATORS),"OP"),this.setFieldValue(this.valuesToSave.OP,
"OP"));return e},updateContainerBlock:function(d){for(var e=0;e<Blockly.Blocks.math_bitwise.OPERATORS.length;e++)Blockly.Blocks.math_bitwise.OPERATORS[e][1]==this.getFieldValue("OP")&&d.setFieldValue(Blockly.Blocks.math_bitwise.OPERATORS[e][0],"CONTAINER_TEXT")},typeblock:[{translatedName:Blockly.Msg.LANG_MATH_BITWISE_AND,dropDown:{titleName:"OP",value:"BITAND"}},{translatedName:Blockly.Msg.LANG_MATH_BITWISE_IOR,dropDown:{titleName:"OP",value:"BITIOR"}},{translatedName:Blockly.Msg.LANG_MATH_BITWISE_XOR,
dropDown:{titleName:"OP",value:"BITXOR"}}]};Blockly.Blocks.math_bitwise.OPERATORS=function(){return[[Blockly.Msg.LANG_MATH_BITWISE_AND,"BITAND"],[Blockly.Msg.LANG_MATH_BITWISE_IOR,"BITIOR"],[Blockly.Msg.LANG_MATH_BITWISE_XOR,"BITXOR"]]};Blockly.Blocks.math_bitwise.TOOLTIPS=function(){return{BITAND:Blockly.Msg.LANG_MATH_BITWISE_TOOLTIP_AND,BITIOR:Blockly.Msg.LANG_MATH_BITWISE_TOOLTIP_IOR,BITXOR:Blockly.Msg.LANG_MATH_BITWISE_TOOLTIP_XOR}};
Blockly.Blocks.math_bitwise.HELPURLS=function(){return{BITAND:Blockly.Msg.LANG_MATH_BITWISE_HELPURL_AND,BITIOR:Blockly.Msg.LANG_MATH_BITWISE_HELPURL_IOR,BITXOR:Blockly.Msg.LANG_MATH_BITWISE_HELPURL_XOR}};
Blockly.Blocks.math_random_int={category:"Math",helpUrl:Blockly.Msg.LANG_MATH_RANDOM_INT_HELPURL,init:function(){this.setColour(Blockly.MATH_CATEGORY_HUE);this.setOutput(!0,AI.BlockUtils.YailTypeToBlocklyType("number",AI.BlockUtils.OUTPUT));var d=AI.BlockUtils.YailTypeToBlocklyType("number",AI.BlockUtils.INPUT);this.interpolateMsg(Blockly.Msg.LANG_MATH_RANDOM_INT_INPUT,["FROM",d,Blockly.inputs.Align.RIGHT],["TO",d,Blockly.inputs.Align.RIGHT],Blockly.inputs.Align.RIGHT);this.setInputsInline(!0);this.setTooltip(Blockly.Msg.LANG_MATH_RANDOM_INT_TOOLTIP)},
typeblock:[{translatedName:Blockly.Msg.LANG_MATH_RANDOM_INT_TITLE_RANDOM}]};Blockly.Blocks.math_random_float={category:"Math",helpUrl:Blockly.Msg.LANG_MATH_RANDOM_FLOAT_HELPURL,init:function(){this.setColour(Blockly.MATH_CATEGORY_HUE);this.setOutput(!0,AI.BlockUtils.YailTypeToBlocklyType("number",AI.BlockUtils.OUTPUT));this.appendDummyInput().appendField(Blockly.Msg.LANG_MATH_RANDOM_FLOAT_TITLE_RANDOM);this.setTooltip(Blockly.Msg.LANG_MATH_RANDOM_FLOAT_TOOLTIP)},typeblock:[{translatedName:Blockly.Msg.LANG_MATH_RANDOM_FLOAT_TITLE_RANDOM}]};
Blockly.Blocks.math_random_set_seed={category:"Math",helpUrl:Blockly.Msg.LANG_MATH_RANDOM_SEED_HELPURL,init:function(){this.setColour(Blockly.MATH_CATEGORY_HUE);this.setOutput(!1,AI.BlockUtils.YailTypeToBlocklyType("number",AI.BlockUtils.OUTPUT));this.appendValueInput("NUM").setCheck(AI.BlockUtils.YailTypeToBlocklyType("number",AI.BlockUtils.INPUT)).appendField(Blockly.Msg.LANG_MATH_RANDOM_SEED_TITLE_RANDOM).appendField(Blockly.Msg.LANG_MATH_RANDOM_SEED_INPUT_TO);this.setPreviousStatement(!0);this.setNextStatement(!0);
this.setTooltip(Blockly.Msg.LANG_MATH_RANDOM_SEED_TOOLTIP)},typeblock:[{translatedName:Blockly.Msg.LANG_MATH_RANDOM_SEED_TITLE_RANDOM}]};
Blockly.Blocks.math_on_list={category:"Math",helpUrl:function(){var d=this.getFieldValue("OP");return Blockly.Blocks.math_on_list.HELPURLS()[d]},init:function(){var d=this;this.setColour(Blockly.MATH_CATEGORY_HUE);this.setOutput(!0,AI.BlockUtils.YailTypeToBlocklyType("number",AI.BlockUtils.OUTPUT));this.appendValueInput("NUM0").setCheck(AI.BlockUtils.YailTypeToBlocklyType("number",AI.BlockUtils.INPUT)).appendField(new Blockly.FieldDropdown(Blockly.Blocks.math_on_list.OPERATORS()),"OP");this.appendValueInput("NUM1").setCheck(AI.BlockUtils.YailTypeToBlocklyType("number",
AI.BlockUtils.INPUT));this.setInputsInline(!1);this.setTooltip(function(){var e=d.getFieldValue("OP");return Blockly.Blocks.math_on_list.TOOLTIPS()[e]});this.setMutator(new Blockly.icons.MutatorIcon(["math_mutator_item"],this));this.itemCount_=2;this.valuesToSave={OP:null};this.emptyInputName="EMPTY";this.repeatingInputName="NUM"},mutationToDom:Blockly.mutationToDom,domToMutation:Blockly.domToMutation,decompose:function(d){return Blockly.decompose(d,"math_mutator_item",this)},compose:Blockly.compose,
saveConnections:Blockly.saveConnections,addEmptyInput:function(){this.appendDummyInput(this.emptyInputName).appendField(new Blockly.FieldDropdown(Blockly.Blocks.math_on_list.OPERATORS()),"OP");this.setFieldValue(this.valuesToSave.OP,"OP")},addInput:function(d){var e=this.appendValueInput(this.repeatingInputName+d).setCheck(AI.BlockUtils.YailTypeToBlocklyType("number",AI.BlockUtils.INPUT));0==d&&(e.appendField(new Blockly.FieldDropdown(Blockly.Blocks.math_on_list.OPERATORS()),"OP"),this.setFieldValue(this.valuesToSave.OP,
"OP"));return e},updateContainerBlock:function(d){for(var e=Blockly.Blocks.math_on_list.OPERATORS(),h=0;h<e.length;h++)e[h][1]==this.getFieldValue("OP")&&d.setFieldValue(e[h][0],"CONTAINER_TEXT")},typeblock:[{translatedName:Blockly.Msg.LANG_MATH_ONLIST_OPERATOR_MIN,dropDown:{titleName:"OP",value:"MIN"}},{translatedName:Blockly.Msg.LANG_MATH_ONLIST_OPERATOR_MAX,dropDown:{titleName:"OP",value:"MAX"}}]};
Blockly.Blocks.math_on_list.OPERATORS=function(){return[[Blockly.Msg.LANG_MATH_ONLIST_OPERATOR_MIN,"MIN"],[Blockly.Msg.LANG_MATH_ONLIST_OPERATOR_MAX,"MAX"]]};Blockly.Blocks.math_on_list.TOOLTIPS=function(){return{MIN:Blockly.Msg.LANG_MATH_ONLIST_TOOLTIP_MIN,MAX:Blockly.Msg.LANG_MATH_ONLIST_TOOLTIP_MAX}};Blockly.Blocks.math_on_list.HELPURLS=function(){return{MIN:Blockly.Msg.LANG_MATH_ONLIST_HELPURL_MIN,MAX:Blockly.Msg.LANG_MATH_ONLIST_HELPURL_MAX}};
Blockly.Blocks.math_on_list2={category:"Math",helpUrl:function(){var d=this.getFieldValue("OP");return Blockly.Blocks.math_on_list2.HELPURLS()[d]},init:function(){var d=this;this.setColour(Blockly.MATH_CATEGORY_HUE);this.setOutput(!0,AI.BlockUtils.YailTypeToBlocklyType("number",AI.BlockUtils.OUTPUT));this.appendValueInput("LIST").setCheck(AI.BlockUtils.YailTypeToBlocklyType("list",AI.BlockUtils.INPUT)).appendField(new Blockly.FieldDropdown(Blockly.Blocks.math_on_list2.OPERATORS()),"OP");this.setTooltip(function(){var e=
d.getFieldValue("OP");return Blockly.Blocks.math_on_list2.TOOLTIPS()[e]})},typeblock:[{translatedName:Blockly.Msg.LANG_MATH_ONLIST_OPERATOR_AVG,dropDown:{titleName:"OP",value:"AVG"}},{translatedName:Blockly.Msg.LANG_MATH_ONLIST_OPERATOR_MIN_LIST,dropDown:{titleName:"OP",value:"MIN"}},{translatedName:Blockly.Msg.LANG_MATH_ONLIST_OPERATOR_MAX_LIST,dropDown:{titleName:"OP",value:"MAX"}},{translatedName:Blockly.Msg.LANG_MATH_ONLIST_OPERATOR_GM,dropDown:{titleName:"OP",value:"GM"}},{translatedName:Blockly.Msg.LANG_MATH_ONLIST_OPERATOR_SD,
dropDown:{titleName:"OP",value:"SD"}},{translatedName:Blockly.Msg.LANG_MATH_ONLIST_OPERATOR_SE,dropDown:{titleName:"OP",value:"SE"}}]};Blockly.Blocks.math_on_list2.OPERATORS=function(){return[[Blockly.Msg.LANG_MATH_ONLIST_OPERATOR_AVG,"AVG"],[Blockly.Msg.LANG_MATH_ONLIST_OPERATOR_MIN_LIST,"MIN"],[Blockly.Msg.LANG_MATH_ONLIST_OPERATOR_MAX_LIST,"MAX"],[Blockly.Msg.LANG_MATH_ONLIST_OPERATOR_GM,"GM"],[Blockly.Msg.LANG_MATH_ONLIST_OPERATOR_SD,"SD"],[Blockly.Msg.LANG_MATH_ONLIST_OPERATOR_SE,"SE"]]};
Blockly.Blocks.math_on_list2.TOOLTIPS=function(){return{AVG:Blockly.Msg.LANG_MATH_ONLIST_TOOLTIP_AVG,MIN:Blockly.Msg.LANG_MATH_ONLIST_TOOLTIP_MIN_LIST,MAX:Blockly.Msg.LANG_MATH_ONLIST_TOOLTIP_MAX_LIST,GM:Blockly.Msg.LANG_MATH_ONLIST_TOOLTIP_GM,SD:Blockly.Msg.LANG_MATH_ONLIST_TOOLTIP_SD,SE:Blockly.Msg.LANG_MATH_ONLIST_TOOLTIP_SE}};
Blockly.Blocks.math_on_list2.HELPURLS=function(){return{AVG:Blockly.Msg.LANG_MATH_ONLIST_HELPURL_AVG,MIN:Blockly.Msg.LANG_MATH_ONLIST_HELPURL_MIN_LIST,MAX:Blockly.Msg.LANG_MATH_ONLIST_HELPURL_MAX_LIST,GM:Blockly.Msg.LANG_MATH_ONLIST_HELPURL_GM,SD:Blockly.Msg.LANG_MATH_ONLIST_HELPURL_SD,SE:Blockly.Msg.LANG_MATH_ONLIST_HELPURL_SE}};
Blockly.Blocks.math_mode_of_list={category:"Math",helpUrl:Blockly.Msg.LANG_MATH_ONLIST_HELPURL_MODE,init:function(){this.setColour(Blockly.MATH_CATEGORY_HUE);this.setOutput(!0,AI.BlockUtils.YailTypeToBlocklyType("list",AI.BlockUtils.OUTPUT));this.appendValueInput("LIST").setCheck(AI.BlockUtils.YailTypeToBlocklyType("list",AI.BlockUtils.INPUT)).appendField(Blockly.Msg.LANG_MATH_LIST_MODE_TITLE);this.setTooltip(Blockly.Msg.LANG_MATH_ONLIST_TOOLTIP_MODE)},typeblock:[{translatedName:Blockly.Msg.LANG_MATH_ONLIST_OPERATOR_MODE}]};
Blockly.Blocks.math_single={category:"Math",helpUrl:function(){var d=this.getFieldValue("OP");return Blockly.Blocks.math_single.HELPURLS()[d]},init:function(){this.setColour(Blockly.MATH_CATEGORY_HUE);this.setOutput(!0,AI.BlockUtils.YailTypeToBlocklyType("number",AI.BlockUtils.OUTPUT));this.appendValueInput("NUM").setCheck(AI.BlockUtils.YailTypeToBlocklyType("number",AI.BlockUtils.INPUT)).appendField(new Blockly.FieldDropdown(Blockly.Blocks.math_single.OPERATORS()),"OP");var d=this;this.setTooltip(function(){var e=
d.getFieldValue("OP");return Blockly.Blocks.math_single.TOOLTIPS()[e]})},typeblock:[{translatedName:Blockly.Msg.LANG_MATH_SINGLE_OP_ROOT,dropDown:{titleName:"OP",value:"ROOT"}},{translatedName:Blockly.Msg.LANG_MATH_SINGLE_OP_ABSOLUTE,dropDown:{titleName:"OP",value:"ABS"}},{translatedName:Blockly.Msg.LANG_MATH_SINGLE_OP_NEG,dropDown:{titleName:"OP",value:"NEG"}},{translatedName:Blockly.Msg.LANG_MATH_SINGLE_OP_LN,dropDown:{titleName:"OP",value:"LN"}},{translatedName:Blockly.Msg.LANG_MATH_SINGLE_OP_EXP,
dropDown:{titleName:"OP",value:"EXP"}},{translatedName:Blockly.Msg.LANG_MATH_ROUND_OPERATOR_ROUND,dropDown:{titleName:"OP",value:"ROUND"}},{translatedName:Blockly.Msg.LANG_MATH_ROUND_OPERATOR_CEILING,dropDown:{titleName:"OP",value:"CEILING"}},{translatedName:Blockly.Msg.LANG_MATH_ROUND_OPERATOR_FLOOR,dropDown:{titleName:"OP",value:"FLOOR"}}]};
Blockly.Blocks.math_single.OPERATORS=function(){return[[Blockly.Msg.LANG_MATH_SINGLE_OP_ROOT,"ROOT"],[Blockly.Msg.LANG_MATH_SINGLE_OP_ABSOLUTE,"ABS"],[Blockly.Msg.LANG_MATH_SINGLE_OP_NEG,"NEG"],[Blockly.Msg.LANG_MATH_SINGLE_OP_LN,"LN"],[Blockly.Msg.LANG_MATH_SINGLE_OP_EXP,"EXP"],[Blockly.Msg.LANG_MATH_ROUND_OPERATOR_ROUND,"ROUND"],[Blockly.Msg.LANG_MATH_ROUND_OPERATOR_CEILING,"CEILING"],[Blockly.Msg.LANG_MATH_ROUND_OPERATOR_FLOOR,"FLOOR"]]};
Blockly.Blocks.math_single.TOOLTIPS=function(){return{ROOT:Blockly.Msg.LANG_MATH_SINGLE_TOOLTIP_ROOT,ABS:Blockly.Msg.LANG_MATH_SINGLE_TOOLTIP_ABS,NEG:Blockly.Msg.LANG_MATH_SINGLE_TOOLTIP_NEG,LN:Blockly.Msg.LANG_MATH_SINGLE_TOOLTIP_LN,EXP:Blockly.Msg.LANG_MATH_SINGLE_TOOLTIP_EXP,ROUND:Blockly.Msg.LANG_MATH_ROUND_TOOLTIP_ROUND,CEILING:Blockly.Msg.LANG_MATH_ROUND_TOOLTIP_CEILING,FLOOR:Blockly.Msg.LANG_MATH_ROUND_TOOLTIP_FLOOR}};
Blockly.Blocks.math_single.HELPURLS=function(){return{ROOT:Blockly.Msg.LANG_MATH_SINGLE_HELPURL_ROOT,ABS:Blockly.Msg.LANG_MATH_SINGLE_HELPURL_ABS,NEG:Blockly.Msg.LANG_MATH_SINGLE_HELPURL_NEG,LN:Blockly.Msg.LANG_MATH_SINGLE_HELPURL_LN,EXP:Blockly.Msg.LANG_MATH_SINGLE_HELPURL_EXP,ROUND:Blockly.Msg.LANG_MATH_ROUND_HELPURL_ROUND,CEILING:Blockly.Msg.LANG_MATH_ROUND_HELPURL_CEILING,FLOOR:Blockly.Msg.LANG_MATH_ROUND_HELPURL_FLOOR}};
Blockly.Blocks.math_abs={category:"Math",helpUrl:function(){var d=this.getFieldValue("OP");return Blockly.Blocks.math_single.HELPURLS()[d]},init:function(){this.setColour(Blockly.MATH_CATEGORY_HUE);this.setOutput(!0,AI.BlockUtils.YailTypeToBlocklyType("number",AI.BlockUtils.OUTPUT));this.appendValueInput("NUM").setCheck(AI.BlockUtils.YailTypeToBlocklyType("number",AI.BlockUtils.INPUT)).appendField(new Blockly.FieldDropdown(Blockly.Blocks.math_single.OPERATORS),"OP");this.setFieldValue("ABS","OP");
var d=this;this.setTooltip(function(){var e=d.getFieldValue("OP");return Blockly.Blocks.math_single.TOOLTIPS()[e]})}};
Blockly.Blocks.math_neg={category:"Math",helpUrl:function(){var d=this.getFieldValue("OP");return Blockly.Blocks.math_single.HELPURLS()[d]},init:function(){this.setColour(Blockly.MATH_CATEGORY_HUE);this.setOutput(!0,AI.BlockUtils.YailTypeToBlocklyType("number",AI.BlockUtils.OUTPUT));this.appendValueInput("NUM").setCheck(AI.BlockUtils.YailTypeToBlocklyType("number",AI.BlockUtils.INPUT)).appendField(new Blockly.FieldDropdown(Blockly.Blocks.math_single.OPERATORS),"OP");this.setFieldValue("NEG","OP");
var d=this;this.setTooltip(function(){var e=d.getFieldValue("OP");return Blockly.Blocks.math_single.TOOLTIPS()[e]})}};
Blockly.Blocks.math_round={category:"Math",helpUrl:function(){var d=this.getFieldValue("OP");return Blockly.Blocks.math_single.HELPURLS()[d]},init:function(){this.setColour(Blockly.MATH_CATEGORY_HUE);this.setOutput(!0,AI.BlockUtils.YailTypeToBlocklyType("number",AI.BlockUtils.OUTPUT));this.appendValueInput("NUM").setCheck(AI.BlockUtils.YailTypeToBlocklyType("number",AI.BlockUtils.INPUT)).appendField(new Blockly.FieldDropdown(Blockly.Blocks.math_single.OPERATORS),"OP");this.setFieldValue("ROUND","OP");
var d=this;this.setTooltip(function(){var e=d.getFieldValue("OP");return Blockly.Blocks.math_single.TOOLTIPS()[e]})}};
Blockly.Blocks.math_ceiling={category:"Math",helpUrl:function(){var d=this.getFieldValue("OP");return Blockly.Blocks.math_single.HELPURLS()[d]},init:function(){this.setColour(Blockly.MATH_CATEGORY_HUE);this.setOutput(!0,AI.BlockUtils.YailTypeToBlocklyType("number",AI.BlockUtils.OUTPUT));this.appendValueInput("NUM").setCheck(AI.BlockUtils.YailTypeToBlocklyType("number",AI.BlockUtils.INPUT)).appendField(new Blockly.FieldDropdown(Blockly.Blocks.math_single.OPERATORS),"OP");this.setFieldValue("CEILING",
"OP");var d=this;this.setTooltip(function(){var e=d.getFieldValue("OP");return Blockly.Blocks.math_single.TOOLTIPS()[e]})}};
Blockly.Blocks.math_floor={category:"Math",helpUrl:function(){var d=this.getFieldValue("OP");return Blockly.Blocks.math_single.HELPURLS()[d]},init:function(){this.setColour(Blockly.MATH_CATEGORY_HUE);this.setOutput(!0,AI.BlockUtils.YailTypeToBlocklyType("number",AI.BlockUtils.OUTPUT));this.appendValueInput("NUM").setCheck(AI.BlockUtils.YailTypeToBlocklyType("number",AI.BlockUtils.INPUT)).appendField(new Blockly.FieldDropdown(Blockly.Blocks.math_single.OPERATORS),"OP");this.setFieldValue("FLOOR","OP");
var d=this;this.setTooltip(function(){var e=d.getFieldValue("OP");return Blockly.Blocks.math_single.TOOLTIPS()[e]})}};
Blockly.Blocks.math_divide={category:"Math",helpUrl:function(){var d=this.getFieldValue("OP");return Blockly.Blocks.math_divide.HELPURLS()[d]},init:function(){this.setColour(Blockly.MATH_CATEGORY_HUE);this.setOutput(!0,AI.BlockUtils.YailTypeToBlocklyType("number",AI.BlockUtils.OUTPUT));this.appendValueInput("DIVIDEND").setCheck(AI.BlockUtils.YailTypeToBlocklyType("number",AI.BlockUtils.INPUT)).appendField(new Blockly.FieldDropdown(Blockly.Blocks.math_divide.OPERATORS()),"OP");this.appendValueInput("DIVISOR").setCheck(AI.BlockUtils.YailTypeToBlocklyType("number",
AI.BlockUtils.INPUT)).appendField(Blockly.Msg.LANG_MATH_DIVIDE);this.setInputsInline(!0);var d=this;this.setTooltip(function(){var e=d.getFieldValue("OP");return Blockly.Blocks.math_divide.TOOLTIPS()[e]})},typeblock:[{translatedName:Blockly.Msg.LANG_MATH_DIVIDE_OPERATOR_MODULO,dropDown:{titleName:"OP",value:"MODULO"}},{translatedName:Blockly.Msg.LANG_MATH_DIVIDE_OPERATOR_REMAINDER,dropDown:{titleName:"OP",value:"REMAINDER"}},{translatedName:Blockly.Msg.LANG_MATH_DIVIDE_OPERATOR_QUOTIENT,dropDown:{titleName:"OP",
value:"QUOTIENT"}}]};Blockly.Blocks.math_divide.OPERATORS=function(){return[[Blockly.Msg.LANG_MATH_DIVIDE_OPERATOR_MODULO,"MODULO"],[Blockly.Msg.LANG_MATH_DIVIDE_OPERATOR_REMAINDER,"REMAINDER"],[Blockly.Msg.LANG_MATH_DIVIDE_OPERATOR_QUOTIENT,"QUOTIENT"]]};Blockly.Blocks.math_divide.TOOLTIPS=function(){return{MODULO:Blockly.Msg.LANG_MATH_DIVIDE_TOOLTIP_MODULO,REMAINDER:Blockly.Msg.LANG_MATH_DIVIDE_TOOLTIP_REMAINDER,QUOTIENT:Blockly.Msg.LANG_MATH_DIVIDE_TOOLTIP_QUOTIENT}};
Blockly.Blocks.math_divide.HELPURLS=function(){return{MODULO:Blockly.Msg.LANG_MATH_DIVIDE_HELPURL_MODULO,REMAINDER:Blockly.Msg.LANG_MATH_DIVIDE_HELPURL_REMAINDER,QUOTIENT:Blockly.Msg.LANG_MATH_DIVIDE_HELPURL_QUOTIENT}};
Blockly.Blocks.math_trig={category:"Math",helpUrl:function(){var d=this.getFieldValue("OP");return Blockly.Blocks.math_trig.HELPURLS()[d]},init:function(){this.setColour(Blockly.MATH_CATEGORY_HUE);this.setOutput(!0,AI.BlockUtils.YailTypeToBlocklyType("number",AI.BlockUtils.OUTPUT));this.appendValueInput("NUM").setCheck(AI.BlockUtils.YailTypeToBlocklyType("number",AI.BlockUtils.INPUT)).appendField(new Blockly.FieldDropdown(Blockly.Blocks.math_trig.OPERATORS()),"OP");var d=this;this.setTooltip(function(){var e=
d.getFieldValue("OP");return Blockly.Blocks.math_trig.TOOLTIPS()[e]})},typeblock:[{translatedName:Blockly.Msg.LANG_MATH_TRIG_SIN,dropDown:{titleName:"OP",value:"SIN"}},{translatedName:Blockly.Msg.LANG_MATH_TRIG_COS,dropDown:{titleName:"OP",value:"COS"}},{translatedName:Blockly.Msg.LANG_MATH_TRIG_TAN,dropDown:{titleName:"OP",value:"TAN"}},{translatedName:Blockly.Msg.LANG_MATH_TRIG_ASIN,dropDown:{titleName:"OP",value:"ASIN"}},{translatedName:Blockly.Msg.LANG_MATH_TRIG_ACOS,dropDown:{titleName:"OP",
value:"ACOS"}},{translatedName:Blockly.Msg.LANG_MATH_TRIG_ATAN,dropDown:{titleName:"OP",value:"ATAN"}}]};Blockly.Blocks.math_trig.OPERATORS=function(){return[[Blockly.Msg.LANG_MATH_TRIG_SIN,"SIN"],[Blockly.Msg.LANG_MATH_TRIG_COS,"COS"],[Blockly.Msg.LANG_MATH_TRIG_TAN,"TAN"],[Blockly.Msg.LANG_MATH_TRIG_ASIN,"ASIN"],[Blockly.Msg.LANG_MATH_TRIG_ACOS,"ACOS"],[Blockly.Msg.LANG_MATH_TRIG_ATAN,"ATAN"]]};
Blockly.Blocks.math_trig.TOOLTIPS=function(){return{SIN:Blockly.Msg.LANG_MATH_TRIG_TOOLTIP_SIN,COS:Blockly.Msg.LANG_MATH_TRIG_TOOLTIP_COS,TAN:Blockly.Msg.LANG_MATH_TRIG_TOOLTIP_TAN,ASIN:Blockly.Msg.LANG_MATH_TRIG_TOOLTIP_ASIN,ACOS:Blockly.Msg.LANG_MATH_TRIG_TOOLTIP_ACOS,ATAN:Blockly.Msg.LANG_MATH_TRIG_TOOLTIP_ATAN}};
Blockly.Blocks.math_trig.HELPURLS=function(){return{SIN:Blockly.Msg.LANG_MATH_TRIG_HELPURL_SIN,COS:Blockly.Msg.LANG_MATH_TRIG_HELPURL_COS,TAN:Blockly.Msg.LANG_MATH_TRIG_HELPURL_TAN,ASIN:Blockly.Msg.LANG_MATH_TRIG_HELPURL_ASIN,ACOS:Blockly.Msg.LANG_MATH_TRIG_HELPURL_ACOS,ATAN:Blockly.Msg.LANG_MATH_TRIG_HELPURL_ATAN}};
Blockly.Blocks.math_cos={category:"Math",helpUrl:function(){var d=this.getFieldValue("OP");return Blockly.Blocks.math_trig.HELPURLS()[d]},init:function(){this.setColour(Blockly.MATH_CATEGORY_HUE);this.setOutput(!0,AI.BlockUtils.YailTypeToBlocklyType("number",AI.BlockUtils.OUTPUT));this.appendValueInput("NUM").setCheck(AI.BlockUtils.YailTypeToBlocklyType("number",AI.BlockUtils.INPUT)).appendField(new Blockly.FieldDropdown(Blockly.Blocks.math_trig.OPERATORS),"OP");this.setFieldValue("COS","OP");var d=
this;this.setTooltip(function(){var e=d.getFieldValue("OP");return Blockly.Blocks.math_trig.TOOLTIPS()[e]})}};
Blockly.Blocks.math_tan={category:"Math",helpUrl:function(){var d=this.getFieldValue("OP");return Blockly.Blocks.math_trig.HELPURLS()[d]},init:function(){this.setColour(Blockly.MATH_CATEGORY_HUE);this.setOutput(!0,AI.BlockUtils.YailTypeToBlocklyType("number",AI.BlockUtils.OUTPUT));this.appendValueInput("NUM").setCheck(AI.BlockUtils.YailTypeToBlocklyType("number",AI.BlockUtils.INPUT)).appendField(new Blockly.FieldDropdown(Blockly.Blocks.math_trig.OPERATORS),"OP");this.setFieldValue("TAN","OP");var d=
this;this.setTooltip(function(){var e=d.getFieldValue("OP");return Blockly.Blocks.math_trig.TOOLTIPS()[e]})}};
Blockly.Blocks.math_atan2={category:"Math",helpUrl:Blockly.Msg.LANG_MATH_TRIG_HELPURL_ATAN2,init:function(){this.setColour(Blockly.MATH_CATEGORY_HUE);this.setOutput(!0,AI.BlockUtils.YailTypeToBlocklyType("number",AI.BlockUtils.OUTPUT));this.appendDummyInput().appendField(Blockly.Msg.LANG_MATH_TRIG_ATAN2);this.appendValueInput("Y").setCheck(AI.BlockUtils.YailTypeToBlocklyType("number",AI.BlockUtils.INPUT)).appendField(Blockly.Msg.LANG_MATH_TRIG_ATAN2_Y).setAlign(Blockly.inputs.Align.RIGHT);this.appendValueInput("X").setCheck(AI.BlockUtils.YailTypeToBlocklyType("number",
AI.BlockUtils.INPUT)).appendField(Blockly.Msg.LANG_MATH_TRIG_ATAN2_X).setAlign(Blockly.inputs.Align.RIGHT);this.setInputsInline(!1);this.setTooltip(Blockly.Msg.LANG_MATH_TRIG_TOOLTIP_ATAN2)},typeblock:[{translatedName:Blockly.Msg.LANG_MATH_TRIG_ATAN2}]};
Blockly.Blocks.math_convert_angles={category:"Math",helpUrl:function(){var d=this.getFieldValue("OP");return Blockly.Blocks.math_convert_angles.HELPURLS()[d]},init:function(){this.setColour(Blockly.MATH_CATEGORY_HUE);this.setOutput(!0,AI.BlockUtils.YailTypeToBlocklyType("number",AI.BlockUtils.OUTPUT));this.appendValueInput("NUM").setCheck(AI.BlockUtils.YailTypeToBlocklyType("number",AI.BlockUtils.INPUT)).appendField(Blockly.Msg.LANG_MATH_CONVERT_ANGLES_TITLE_CONVERT).appendField(new Blockly.FieldDropdown(Blockly.Blocks.math_convert_angles.OPERATORS()),
"OP");var d=this;this.setTooltip(function(){var e=d.getFieldValue("OP");return Blockly.Blocks.math_convert_angles.TOOLTIPS()[e]})},typeblock:[{translatedName:Blockly.Msg.LANG_MATH_CONVERT_ANGLES_TITLE_CONVERT+" "+Blockly.Msg.LANG_MATH_CONVERT_ANGLES_OP_RAD_TO_DEG,dropDown:{titleName:"OP",value:"RADIANS_TO_DEGREES"}},{translatedName:Blockly.Msg.LANG_MATH_CONVERT_ANGLES_TITLE_CONVERT+" "+Blockly.Msg.LANG_MATH_CONVERT_ANGLES_OP_DEG_TO_RAD,dropDown:{titleName:"OP",value:"DEGREES_TO_RADIANS"}}]};
Blockly.Blocks.math_convert_angles.OPERATORS=function(){return[[Blockly.Msg.LANG_MATH_CONVERT_ANGLES_OP_RAD_TO_DEG,"RADIANS_TO_DEGREES"],[Blockly.Msg.LANG_MATH_CONVERT_ANGLES_OP_DEG_TO_RAD,"DEGREES_TO_RADIANS"]]};Blockly.Blocks.math_convert_angles.TOOLTIPS=function(){return{RADIANS_TO_DEGREES:Blockly.Msg.LANG_MATH_CONVERT_ANGLES_TOOLTIP_RAD_TO_DEG,DEGREES_TO_RADIANS:Blockly.Msg.LANG_MATH_CONVERT_ANGLES_TOOLTIP_DEG_TO_RAD}};
Blockly.Blocks.math_convert_angles.HELPURLS=function(){return{RADIANS_TO_DEGREES:Blockly.Msg.LANG_MATH_CONVERT_ANGLES_HELPURL_RAD_TO_DEG,DEGREES_TO_RADIANS:Blockly.Msg.LANG_MATH_CONVERT_ANGLES_HELPURL_DEG_TO_RAD}};
Blockly.Blocks.math_format_as_decimal={category:"Math",helpUrl:Blockly.Msg.LANG_MATH_FORMAT_AS_DECIMAL_HELPURL,init:function(){this.setColour(Blockly.MATH_CATEGORY_HUE);this.setOutput(!0,AI.BlockUtils.YailTypeToBlocklyType("number",AI.BlockUtils.OUTPUT));var d=AI.BlockUtils.YailTypeToBlocklyType("number",AI.BlockUtils.INPUT);this.interpolateMsg(Blockly.Msg.LANG_MATH_FORMAT_AS_DECIMAL_INPUT,["NUM",d,Blockly.inputs.Align.RIGHT],["PLACES",d,Blockly.inputs.Align.RIGHT],Blockly.inputs.Align.RIGHT);this.setInputsInline(!1);
this.setTooltip(Blockly.Msg.LANG_MATH_FORMAT_AS_DECIMAL_TOOLTIP)},typeblock:[{translatedName:Blockly.Msg.LANG_MATH_FORMAT_AS_DECIMAL_TITLE}]};
Blockly.Blocks.math_is_a_number={category:"Math",helpUrl:function(){var d=this.getFieldValue("OP");return Blockly.Blocks.math_is_a_number.HELPURLS()[d]},init:function(){this.setColour(Blockly.MATH_CATEGORY_HUE);this.setOutput(!0,AI.BlockUtils.YailTypeToBlocklyType("boolean",AI.BlockUtils.OUTPUT));this.appendValueInput("NUM").appendField(new Blockly.FieldDropdown(Blockly.Blocks.math_is_a_number.OPERATORS()),"OP");var d=this;this.setTooltip(function(){var e=d.getFieldValue("OP");return Blockly.Blocks.math_is_a_number.TOOLTIPS()[e]})},
typeblock:[{translatedName:Blockly.Msg.LANG_MATH_IS_A_NUMBER_INPUT_NUM,dropDown:{titleName:"OP",value:"NUMBER"}},{translatedName:Blockly.Msg.LANG_MATH_IS_A_DECIMAL_INPUT_NUM,dropDown:{titleName:"OP",value:"BASE10"}},{translatedName:Blockly.Msg.LANG_MATH_IS_A_HEXADECIMAL_INPUT_NUM,dropDown:{titleName:"OP",value:"HEXADECIMAL"}},{translatedName:Blockly.Msg.LANG_MATH_IS_A_BINARY_INPUT_NUM,dropDown:{titleName:"OP",value:"BINARY"}}]};
Blockly.Blocks.math_is_a_number.OPERATORS=function(){return[[Blockly.Msg.LANG_MATH_IS_A_NUMBER_INPUT_NUM,"NUMBER"],[Blockly.Msg.LANG_MATH_IS_A_DECIMAL_INPUT_NUM,"BASE10"],[Blockly.Msg.LANG_MATH_IS_A_HEXADECIMAL_INPUT_NUM,"HEXADECIMAL"],[Blockly.Msg.LANG_MATH_IS_A_BINARY_INPUT_NUM,"BINARY"]]};
Blockly.Blocks.math_is_a_number.TOOLTIPS=function(){return{NUMBER:Blockly.Msg.LANG_MATH_IS_A_NUMBER_TOOLTIP,BASE10:Blockly.Msg.LANG_MATH_IS_A_DECIMAL_TOOLTIP,HEXADECIMAL:Blockly.Msg.LANG_MATH_IS_A_HEXADECIMAL_TOOLTIP,BINARY:Blockly.Msg.LANG_MATH_IS_A_BINARY_TOOLTIP}};Blockly.Blocks.math_is_a_number.HELPURLS=function(){return{NUMBER:Blockly.Msg.LANG_MATH_IS_A_NUMBER_HELPURL,BASE10:Blockly.Msg.LANG_MATH_IS_A_DECIMAL_HELPURL,HEXADECIMAL:Blockly.Msg.LANG_MATH_IS_A_HEXADECIMAL_HELPURL,BINARY:Blockly.Msg.LANG_MATH_IS_A_BINARY_HELPURL}};
Blockly.Blocks.math_convert_number={category:"Math",helpUrl:function(){var d=this.getFieldValue("OP");return Blockly.Blocks.math_convert_number.HELPURLS()[d]},init:function(){this.setColour(Blockly.MATH_CATEGORY_HUE);this.setOutput(!0,AI.BlockUtils.YailTypeToBlocklyType("text",AI.BlockUtils.OUTPUT));this.appendValueInput("NUM").appendField(Blockly.Msg.LANG_MATH_CONVERT_NUMBER_TITLE_CONVERT).appendField(new Blockly.FieldDropdown(Blockly.Blocks.math_convert_number.OPERATORS()),"OP");var d=this;this.setTooltip(function(){var e=
d.getFieldValue("OP");return Blockly.Blocks.math_convert_number.TOOLTIPS()[e]})},typeblock:[{translatedName:Blockly.Msg.LANG_MATH_CONVERT_NUMBER_OP_DEC_TO_HEX,dropDown:{titleName:"OP",value:"DEC_TO_HEX"}},{translatedName:Blockly.Msg.LANG_MATH_CONVERT_NUMBER_OP_HEX_TO_DEC,dropDown:{titleName:"OP",value:"HEX_TO_DEC"}},{translatedName:Blockly.Msg.LANG_MATH_CONVERT_NUMBER_OP_DEC_TO_BIN,dropDown:{titleName:"OP",value:"DEC_TO_BIN"}},{translatedName:Blockly.Msg.LANG_MATH_CONVERT_NUMBER_OP_BIN_TO_DEC,dropDown:{titleName:"OP",
value:"BIN_TO_DEC"}}]};Blockly.Blocks.math_convert_number.OPERATORS=function(){return[[Blockly.Msg.LANG_MATH_CONVERT_NUMBER_OP_DEC_TO_HEX,"DEC_TO_HEX"],[Blockly.Msg.LANG_MATH_CONVERT_NUMBER_OP_HEX_TO_DEC,"HEX_TO_DEC"],[Blockly.Msg.LANG_MATH_CONVERT_NUMBER_OP_DEC_TO_BIN,"DEC_TO_BIN"],[Blockly.Msg.LANG_MATH_CONVERT_NUMBER_OP_BIN_TO_DEC,"BIN_TO_DEC"]]};
Blockly.Blocks.math_convert_number.TOOLTIPS=function(){return{DEC_TO_HEX:Blockly.Msg.LANG_MATH_CONVERT_NUMBER_TOOLTIP_DEC_TO_HEX,HEX_TO_DEC:Blockly.Msg.LANG_MATH_CONVERT_NUMBER_TOOLTIP_HEX_TO_DEC,DEC_TO_BIN:Blockly.Msg.LANG_MATH_CONVERT_NUMBER_TOOLTIP_DEC_TO_BIN,BIN_TO_DEC:Blockly.Msg.LANG_MATH_CONVERT_NUMBER_TOOLTIP_BIN_TO_DEC}};
Blockly.Blocks.math_convert_number.HELPURLS=function(){return{DEC_TO_HEX:Blockly.Msg.LANG_MATH_CONVERT_NUMBER_HELPURL_DEC_TO_HEX,HEX_TO_DEC:Blockly.Msg.LANG_MATH_CONVERT_NUMBER_HELPURL_HEX_TO_DEC,DEC_TO_BIN:Blockly.Msg.LANG_MATH_CONVERT_NUMBER_HELPURL_DEC_TO_BIN,BIN_TO_DEC:Blockly.Msg.LANG_MATH_CONVERT_NUMBER_HELPURL_BIN_TO_DEC}};/*

 @fileoverview Matrices blocks for Blockly, modified for MIT App Inventor.
 @author jackyc@mit.edu (Jacky Chen)
*/
AI.Blocks.matrices={};
Blockly.Blocks.matrices_create={category:"Matrices",helpUrl:Blockly.Msg.LANG_MATRICES_CREATE_HELPURL,init:function(){this.setColour(Blockly.MATRIX_CATEGORY_HUE);this.setOutput(!0,AI.BlockUtils.YailTypeToBlocklyType("matrix",AI.BlockUtils.OUTPUT));this.appendDummyInput().appendField(Blockly.Msg.LANG_MATRICES_CREATE).appendField(new Blockly.FieldNumber(2,1,null,null),"ROWS").appendField(AI.BlockUtils.times_symbol).appendField(new Blockly.FieldNumber(2,1,null,null),"COLS");this.setTooltip(Blockly.Msg.LANG_MATRICES_CREATE_TOOLTIP);this.matrixValues=
[];this.createMatrix(2,2)},createMatrix:function(d,e){for(var h=this.matrixValues||[],k=0;this.getInput("ROW"+k);k++)this.removeInput("ROW"+k);this.matrixValues=[];for(k=0;k<d;k++){var m=this.appendDummyInput("ROW"+k);this.matrixValues[k]=[];for(var p=0;p<e;p++){var t="MATRIX_"+k+"_"+p,q=h[k]&&void 0!==h[k][p]?h[k][p]:0;this.matrixValues[k][p]=q;m.appendField(new Blockly.FieldNumber(q,null,null,null,this.updateMatrixValue.bind(this,k,p)),t)}}},updateMatrixSize:function(){var d=Number(this.getFieldValue("ROWS"))||
2,e=Number(this.getFieldValue("COLS"))||2;this.createMatrix(d,e)},updateMatrixValue:function(d,e,h){this.matrixValues[d]&&void 0!==this.matrixValues[d][e]&&(this.matrixValues[d][e]=Number(h)||0)},mutationToDom:function(){var d=document.createElement("mutation");d.setAttribute("rows",this.getFieldValue("ROWS"));d.setAttribute("cols",this.getFieldValue("COLS"));d.setAttribute("matrix",JSON.stringify(this.matrixValues));return d},domToMutation:function(d){var e=parseInt(d.getAttribute("rows"),10),h=
parseInt(d.getAttribute("cols"),10);this.matrixValues=JSON.parse(d.getAttribute("matrix"));this.createMatrix(e,h);this.setFieldValue(e,"ROWS");this.setFieldValue(h,"COLS")},onchange:function(d){if(d.type===Blockly.Events.CHANGE&&"field"===d.element)if("ROWS"===d.name||"COLS"===d.name)this.updateMatrixSize();else if(d.name.startsWith("MATRIX_")){var e=d.name.split("_"),h=parseInt(e[1],10);e=parseInt(e[2],10);this.updateMatrixValue(h,e,d.newValue)}},saveConnections:Blockly.saveConnections,typeblock:[{translatedName:Blockly.Msg.LANG_MATRICES_CREATE}]};
Blockly.Blocks.matrices_create_multidim={category:"Matrices",helpUrl:Blockly.Msg.LANG_MATRICES_CREATE_MULTIDIM_HELPURL,init:function(){this.setColour(Blockly.MATRIX_CATEGORY_HUE);this.setOutput(!0,AI.BlockUtils.YailTypeToBlocklyType("matrix",AI.BlockUtils.OUTPUT));this.appendValueInput("DIM").setCheck(AI.BlockUtils.YailTypeToBlocklyType("list",AI.BlockUtils.INPUT)).appendField(Blockly.Msg.LANG_MATRICES_CREATE_MULTIDIM);this.appendValueInput("INITIAL").setCheck(AI.BlockUtils.YailTypeToBlocklyType("number",
AI.BlockUtils.INPUT)).appendField(Blockly.Msg.LANG_MATRICES_CREATE_MULTIDIM_INITIAL).setAlign(Blockly.ALIGN_RIGHT);this.setTooltip(Blockly.Msg.LANG_MATRICES_CREATE_MULTIDIM_TOOLTIP)},typeblock:[{translatedName:Blockly.Msg.LANG_MATRICES_CREATE_MULTIDIM}]};Blockly.Blocks.matrix_mutator_item_dim={init:function(){this.setColour(Blockly.MATRIX_CATEGORY_HUE);this.appendDummyInput().appendField("dimension");this.setPreviousStatement(!0);this.setNextStatement(!0);this.contextMenu=!1}};
Blockly.Blocks.matrices_get_cell={category:"Matrices",helpUrl:Blockly.Msg.LANG_MATRICES_GET_CELL_HELPURL,init:function(){this.setColour(Blockly.MATRIX_CATEGORY_HUE);this.setOutput(!0,AI.BlockUtils.YailTypeToBlocklyType("number",AI.BlockUtils.OUTPUT));this.appendValueInput("MATRIX").setCheck(AI.BlockUtils.YailTypeToBlocklyType("matrix",AI.BlockUtils.INPUT)).appendField(Blockly.Msg.LANG_MATRICES_GET_CELL).appendField(Blockly.Msg.LANG_MATRICES_GET_INPUT_MATRIX);this.appendValueInput("DIM0").setCheck(AI.BlockUtils.YailTypeToBlocklyType("number",
AI.BlockUtils.INPUT)).appendField(Blockly.Msg.LANG_MATRICES_GET_INPUT_DIM+"1").setAlign(Blockly.ALIGN_RIGHT);this.appendValueInput("DIM1").setCheck(AI.BlockUtils.YailTypeToBlocklyType("number",AI.BlockUtils.INPUT)).appendField(Blockly.Msg.LANG_MATRICES_GET_INPUT_DIM+"2").setAlign(Blockly.ALIGN_RIGHT);this.setTooltip(Blockly.Msg.LANG_MATRICES_GET_CELL_TOOLTIP);this.setMutator(new Blockly.icons.MutatorIcon(["matrix_mutator_item_dim"],this));this.emptyInputName="EMPTY";this.repeatingInputName="DIM";
this.itemCount_=2},mutationToDom:Blockly.mutationToDom,domToMutation:function(d){Blockly.domToMutation.call(this,d)},decompose:function(d){return Blockly.decompose(d,"matrix_mutator_item_dim",this)},compose:function(d){Blockly.compose.call(this,d)},saveConnections:Blockly.saveConnections,addEmptyInput:function(){this.appendValueInput(this.repeatingInputName+"0").setCheck(AI.BlockUtils.YailTypeToBlocklyType("number",AI.BlockUtils.INPUT)).appendField(Blockly.Msg.LANG_MATRICES_GET_INPUT_DIM+"1").setAlign(Blockly.ALIGN_RIGHT);
this.itemCount_=1},addInput:function(d){var e=this.appendValueInput(this.repeatingInputName+d).setCheck(AI.BlockUtils.YailTypeToBlocklyType("number",AI.BlockUtils.INPUT));e.appendField(Blockly.Msg.LANG_MATRICES_GET_INPUT_DIM+(d+1)).setAlign(Blockly.ALIGN_RIGHT);return e},updateContainerBlock:function(d){d.setFieldValue(Blockly.Msg.LANG_MATRICES_GET_INPUT_DIM,"CONTAINER_TEXT")},typeblock:[{translatedName:Blockly.Msg.LANG_MATRICES_GET_CELL}]};
Blockly.Blocks.matrices_set_cell={category:"Matrices",helpUrl:Blockly.Msg.LANG_MATRICES_SET_CELL_HELPURL,init:function(){this.setColour(Blockly.MATRIX_CATEGORY_HUE);this.appendValueInput("MATRIX").setCheck(AI.BlockUtils.YailTypeToBlocklyType("matrix",AI.BlockUtils.INPUT)).appendField(Blockly.Msg.LANG_MATRICES_SET_CELL).appendField(Blockly.Msg.LANG_MATRICES_GET_INPUT_MATRIX);this.appendValueInput("VALUE").setCheck(AI.BlockUtils.YailTypeToBlocklyType("number",AI.BlockUtils.INPUT)).appendField(Blockly.Msg.LANG_MATRICES_GET_INPUT_VALUE).setAlign(Blockly.ALIGN_RIGHT);
this.appendValueInput("DIM0").setCheck(AI.BlockUtils.YailTypeToBlocklyType("number",AI.BlockUtils.INPUT)).appendField(Blockly.Msg.LANG_MATRICES_GET_INPUT_DIM+"1").setAlign(Blockly.ALIGN_RIGHT);this.appendValueInput("DIM1").setCheck(AI.BlockUtils.YailTypeToBlocklyType("number",AI.BlockUtils.INPUT)).appendField(Blockly.Msg.LANG_MATRICES_GET_INPUT_DIM+"2").setAlign(Blockly.ALIGN_RIGHT);this.setPreviousStatement(!0);this.setNextStatement(!0);this.setTooltip(Blockly.Msg.LANG_MATRICES_SET_CELL_TOOLTIP);
this.setMutator(new Blockly.icons.MutatorIcon(["matrix_mutator_item_dim"],this));this.emptyInputName="EMPTY";this.repeatingInputName="DIM";this.itemCount_=2},mutationToDom:Blockly.mutationToDom,domToMutation:function(d){Blockly.domToMutation.call(this,d)},decompose:function(d){return Blockly.decompose(d,"matrix_mutator_item_dim",this)},compose:function(d){Blockly.compose.call(this,d)},saveConnections:Blockly.saveConnections,addEmptyInput:function(){this.appendValueInput(this.repeatingInputName+"0").setCheck(AI.BlockUtils.YailTypeToBlocklyType("number",
AI.BlockUtils.INPUT)).appendField(Blockly.Msg.LANG_MATRICES_GET_INPUT_DIM+"1").setAlign(Blockly.ALIGN_RIGHT);this.itemCount_=1},addInput:function(d){var e=this.appendValueInput(this.repeatingInputName+d).setCheck(AI.BlockUtils.YailTypeToBlocklyType("number",AI.BlockUtils.INPUT));e.appendField(Blockly.Msg.LANG_MATRICES_GET_INPUT_DIM+(d+1)).setAlign(Blockly.ALIGN_RIGHT);return e},updateContainerBlock:function(d){d.setFieldValue(Blockly.Msg.LANG_MATRICES_GET_INPUT_DIM,"CONTAINER_TEXT")},typeblock:[{translatedName:Blockly.Msg.LANG_MATRICES_SET_CELL}]};
Blockly.Blocks.matrices_get_row={category:"Matrices",helpUrl:Blockly.Msg.LANG_MATRICES_GET_ROW_HELPURL,init:function(){this.setColour(Blockly.MATRIX_CATEGORY_HUE);this.setOutput(!0,AI.BlockUtils.YailTypeToBlocklyType("list",AI.BlockUtils.OUTPUT));this.appendValueInput("MATRIX").setCheck(AI.BlockUtils.YailTypeToBlocklyType("matrix",AI.BlockUtils.INPUT)).appendField(Blockly.Msg.LANG_MATRICES_GET_ROW).appendField(Blockly.Msg.LANG_MATRICES_GET_INPUT_MATRIX);this.appendValueInput("ROW").setCheck(AI.BlockUtils.YailTypeToBlocklyType("number",
AI.BlockUtils.INPUT)).appendField(Blockly.Msg.LANG_MATRICES_GET_INPUT_ROW).setAlign(Blockly.ALIGN_RIGHT);this.setTooltip(Blockly.Msg.LANG_MATRICES_GET_ROW_TOOLTIP)},typeblock:[{translatedName:Blockly.Msg.LANG_MATRICES_GET_ROW}]};
Blockly.Blocks.matrices_get_column={category:"Matrices",helpUrl:Blockly.Msg.LANG_MATRICES_GET_COLUMN_HELPURL,init:function(){this.setColour(Blockly.MATRIX_CATEGORY_HUE);this.setOutput(!0,AI.BlockUtils.YailTypeToBlocklyType("list",AI.BlockUtils.OUTPUT));this.appendValueInput("MATRIX").setCheck(AI.BlockUtils.YailTypeToBlocklyType("matrix",AI.BlockUtils.INPUT)).appendField(Blockly.Msg.LANG_MATRICES_GET_COLUMN).appendField(Blockly.Msg.LANG_MATRICES_GET_INPUT_MATRIX);this.appendValueInput("COLUMN").setCheck(AI.BlockUtils.YailTypeToBlocklyType("number",
AI.BlockUtils.INPUT)).appendField(Blockly.Msg.LANG_MATRICES_GET_INPUT_COLUMN).setAlign(Blockly.ALIGN_RIGHT);this.setTooltip(Blockly.Msg.LANG_MATRICES_GET_COLUMN_TOOLTIP)},typeblock:[{translatedName:Blockly.Msg.LANG_MATRICES_GET_COLUMN}]};
Blockly.Blocks.matrices_get_dims={category:"Matrices",helpUrl:Blockly.Msg.LANG_MATRICES_GET_DIMS_HELPURL,init:function(){this.setColour(Blockly.MATRIX_CATEGORY_HUE);this.setOutput(!0,AI.BlockUtils.YailTypeToBlocklyType("list",AI.BlockUtils.OUTPUT));this.appendValueInput("MATRIX").setCheck(AI.BlockUtils.YailTypeToBlocklyType("matrix",AI.BlockUtils.INPUT)).appendField(Blockly.Msg.LANG_MATRICES_GET_DIMS).appendField(Blockly.Msg.LANG_MATRICES_GET_INPUT_MATRIX);this.setTooltip(Blockly.Msg.LANG_MATRICES_GET_DIMS_TOOLTIP)},
typeblock:[{translatedName:Blockly.Msg.LANG_MATRICES_GET_DIMS}]};Blockly.Blocks.matrix_mutator_item_mat={init:function(){this.setColour(Blockly.MATRIX_CATEGORY_HUE);this.appendDummyInput().appendField("matrix");this.setPreviousStatement(!0);this.setNextStatement(!0);this.contextMenu=!1}};
Blockly.Blocks.matrices_add={category:"Matrices",helpUrl:Blockly.Msg.LANG_MATRICES_ADD_HELPURL,init:function(){this.setColour(Blockly.MATRIX_CATEGORY_HUE);this.setOutput(!0,AI.BlockUtils.YailTypeToBlocklyType("matrix",AI.BlockUtils.OUTPUT));this.appendValueInput("MAT0").setCheck(AI.BlockUtils.YailTypeToBlocklyType("matrix",AI.BlockUtils.INPUT));this.appendValueInput("MAT1").setCheck(AI.BlockUtils.YailTypeToBlocklyType("matrix",AI.BlockUtils.INPUT)).appendField(Blockly.Msg.LANG_MATH_ARITHMETIC_ADD);
this.setInputsInline(!0);this.setTooltip(Blockly.Msg.LANG_MATRICES_ARITHMETIC_ADD_TOOLTIP);this.setMutator(new Blockly.icons.MutatorIcon(["matrix_mutator_item_mat"],this));this.emptyInputName="EMPTY";this.repeatingInputName="MAT";this.itemCount_=2},mutationToDom:Blockly.mutationToDom,domToMutation:function(d){Blockly.domToMutation.call(this,d);1===this.itemCount_&&this.inputList[0].appendField("0 "+Blockly.Msg.LANG_MATH_ARITHMETIC_ADD)},decompose:function(d){return Blockly.decompose(d,"matrix_mutator_item_mat",
this)},compose:function(d){Blockly.compose.call(this,d);1===this.itemCount_&&this.inputList[0].appendField("0 "+Blockly.Msg.LANG_MATH_ARITHMETIC_ADD)},saveConnections:Blockly.saveConnections,addEmptyInput:function(){this.appendDummyInput(this.emptyInputName).appendField(Blockly.Msg.LANG_MATH_ARITHMETIC_ADD)},addInput:function(d){var e=this.appendValueInput(this.repeatingInputName+d).setCheck(AI.BlockUtils.YailTypeToBlocklyType("matrix",AI.BlockUtils.INPUT));0!==d&&e.appendField(Blockly.Msg.LANG_MATH_ARITHMETIC_ADD);
return e},updateContainerBlock:function(d){d.setFieldValue(Blockly.Msg.LANG_MATH_ARITHMETIC_ADD,"CONTAINER_TEXT")},typeblock:[{translatedName:Blockly.Msg.LANG_MATRICES_ARTIHMETIC_ADD}]};
Blockly.Blocks.matrices_subtract={category:"Matrices",helpUrl:Blockly.Msg.LANG_MATRICES_SUBTRACT_HELPURL,init:function(){this.setColour(Blockly.MATRIX_CATEGORY_HUE);this.setOutput(!0,AI.BlockUtils.YailTypeToBlocklyType("matrix",AI.BlockUtils.OUTPUT));this.appendValueInput("A").setCheck(AI.BlockUtils.YailTypeToBlocklyType("matrix",AI.BlockUtils.INPUT));this.appendValueInput("B").setCheck(AI.BlockUtils.YailTypeToBlocklyType("matrix",AI.BlockUtils.INPUT)).appendField(Blockly.Msg.LANG_MATH_ARITHMETIC_MINUS);
this.setInputsInline(!0);this.setTooltip(Blockly.Msg.LANG_MATRICES_ARITHMETIC_SUBTRACT_TOOLTIP)},typeblock:[{translatedName:Blockly.Msg.LANG_MATRICES_ARITHMETIC_SUBTRACT}]};
Blockly.Blocks.matrices_multiply={category:"Matrices",helpUrl:Blockly.Msg.LANG_MATRICES_MULTIPLY_HELPURL,init:function(){this.setColour(Blockly.MATRIX_CATEGORY_HUE);this.setOutput(!0,AI.BlockUtils.YailTypeToBlocklyType("matrix",AI.BlockUtils.OUTPUT));this.appendValueInput("MAT0").setCheck(AI.BlockUtils.YailTypeToBlocklyType("matrix",AI.BlockUtils.INPUT));this.appendValueInput("MAT1").setCheck(AI.BlockUtils.YailTypeToBlocklyType("matrix",AI.BlockUtils.INPUT).concat(AI.BlockUtils.YailTypeToBlocklyType("number",
AI.BlockUtils.INPUT))).appendField(AI.BlockUtils.times_symbol);this.setInputsInline(!0);this.setTooltip(Blockly.Msg.LANG_MATRICES_ARITHMETIC_MULTIPLY_TOOLTIP);this.setMutator(new Blockly.icons.MutatorIcon(["matrix_mutator_item_mat"],this));this.emptyInputName="EMPTY";this.repeatingInputName="MAT";this.itemCount_=2},mutationToDom:Blockly.mutationToDom,domToMutation:function(d){Blockly.domToMutation.call(this,d);1===this.itemCount_&&this.inputList[0].appendField("1 "+AI.BlockUtils.times_symbol)},decompose:function(d){return Blockly.decompose(d,
"matrix_mutator_item_mat",this)},compose:function(d){Blockly.compose.call(this,d);1===this.itemCount_&&this.inputList[0].appendField("1 "+AI.BlockUtils.times_symbol)},saveConnections:Blockly.saveConnections,addEmptyInput:function(){this.appendDummyInput(this.emptyInputName).appendField(AI.BlockUtils.times_symbol)},addInput:function(d){var e=this.appendValueInput(this.repeatingInputName+d).setCheck(0===d?AI.BlockUtils.YailTypeToBlocklyType("matrix",AI.BlockUtils.INPUT):AI.BlockUtils.YailTypeToBlocklyType("matrix",
AI.BlockUtils.INPUT).concat(AI.BlockUtils.YailTypeToBlocklyType("number",AI.BlockUtils.INPUT)));0!==d&&e.appendField(AI.BlockUtils.times_symbol);return e},updateContainerBlock:function(d){d.setFieldValue(AI.BlockUtils.times_symbol,"CONTAINER_TEXT")},typeblock:[{translatedName:Blockly.Msg.LANG_MATRICES_ARITHMETIC_MULTIPLY}]};
Blockly.Blocks.matrices_power={category:"Matrices",helpUrl:Blockly.Msg.LANG_MATRICES_POWER_HELPURL,init:function(){this.setColour(Blockly.MATRIX_CATEGORY_HUE);this.setOutput(!0,AI.BlockUtils.YailTypeToBlocklyType("matrix",AI.BlockUtils.OUTPUT));this.appendValueInput("A").setCheck(AI.BlockUtils.YailTypeToBlocklyType("matrix",AI.BlockUtils.INPUT));this.appendValueInput("B").setCheck(AI.BlockUtils.YailTypeToBlocklyType("number",AI.BlockUtils.INPUT)).appendField(Blockly.Msg.LANG_MATH_ARITHMETIC_POWER);
this.setInputsInline(!0);this.setTooltip(Blockly.Msg.LANG_MATRICES_ARITHMETIC_POWER_TOOLTIP)},typeblock:[{translatedName:Blockly.Msg.LANG_MATRICES_ARITHMETIC_POWER}]};
Blockly.Blocks.matrices_operations={category:"Matrices",helpUrl:function(){var d=this.getFieldValue("OP");return Blockly.Blocks.matrices_operations.HELPURLS()[d]},init:function(){this.setColour(Blockly.MATRIX_CATEGORY_HUE);this.setOutput(!0,AI.BlockUtils.YailTypeToBlocklyType("matrix",AI.BlockUtils.OUTPUT));this.appendValueInput("MATRIX").setCheck(AI.BlockUtils.YailTypeToBlocklyType("matrix",AI.BlockUtils.INPUT)).appendField(new Blockly.FieldDropdown(this.OPERATORS),"OP");var d=this;this.setTooltip(function(){var e=
d.getFieldValue("OP");return Blockly.Blocks.matrices_operations.TOOLTIPS()[e]})},typeblock:[{translatedName:Blockly.Msg.LANG_MATRICES_OPERATIONS_INVERSE,dropDown:{titleName:"OP",value:"INVERSE"}},{translatedName:Blockly.Msg.LANG_MATRICES_OPERATIONS_TRANSPOSE,dropDown:{titleName:"OP",value:"TRANSPOSE"}},{translatedName:Blockly.Msg.LANG_MATRICES_OPERATIONS_ROTATE_LEFT,dropDown:{titleName:"OP",value:"ROTATE_LEFT"}},{translatedName:Blockly.Msg.LANG_MATRICES_OPERATIONS_ROTATE_RIGHT,dropDown:{titleName:"OP",
value:"ROTATE_RIGHT"}}]};Blockly.Blocks.matrices_operations.OPERATORS=function(){return[[Blockly.Msg.LANG_MATRICES_OPERATIONS_INVERSE,"INVERSE"],[Blockly.Msg.LANG_MATRICES_OPERATIONS_TRANSPOSE,"TRANSPOSE"],[Blockly.Msg.LANG_MATRICES_OPERATIONS_ROTATE_LEFT,"ROTATE_LEFT"],[Blockly.Msg.LANG_MATRICES_OPERATIONS_ROTATE_RIGHT,"ROTATE_RIGHT"]]};
Blockly.Blocks.matrices_operations.TOOLTIPS=function(){return{INVERSE:Blockly.Msg.LANG_MATRICES_OPERATIONS_TOOLTIP_INVERSE,TRANSPOSE:Blockly.Msg.LANG_MATRICES_OPERATIONS_TOOLTIP_TRANSPOSE,ROTATE_LEFT:Blockly.Msg.LANG_MATRICES_OPERATIONS_TOOLTIP_ROTATE_LEFT,ROTATE_RIGHT:Blockly.Msg.LANG_MATRICES_OPERATIONS_TOOLTIP_ROTATE_RIGHT}};
Blockly.Blocks.matrices_operations.HELPURLS=function(){return{INVERSE:Blockly.Msg.LANG_MATRICES_OPERATIONS_HELPURL_INVERSE,TRANSPOSE:Blockly.Msg.LANG_MATRICES_OPERATIONS_HELPURL_TRANSPOSE,ROTATE_LEFT:Blockly.Msg.LANG_MATRICES_OPERATIONS_HELPURL_ROTATE_LEFT,ROTATE_RIGHT:Blockly.Msg.LANG_MATRICES_OPERATIONS_HELPURL_ROTATE_RIGHT}};
Blockly.Blocks.matrices_transpose={category:"Matrices",helpUrl:function(){var d=this.getFieldValue("OP");return Blockly.Blocks.matrices_operations.HELPURLS()[d]},init:function(){this.setColour(Blockly.MATRIX_CATEGORY_HUE);this.setOutput(!0,AI.BlockUtils.YailTypeToBlocklyType("matrix",AI.BlockUtils.OUTPUT));this.appendValueInput("MATRIX").setCheck(AI.BlockUtils.YailTypeToBlocklyType("matrix",AI.BlockUtils.INPUT)).appendField(new Blockly.FieldDropdown(Blockly.Blocks.matrices_operations.OPERATORS),"OP");
this.setFieldValue("TRANSPOSE","OP");var d=this;this.setTooltip(function(){var e=d.getFieldValue("OP");return Blockly.Blocks.matrices_operations.TOOLTIPS()[e]})}};
Blockly.Blocks.matrices_rotate_left={category:"Matrices",helpUrl:function(){var d=this.getFieldValue("OP");return Blockly.Blocks.matrices_operations.HELPURLS()[d]},init:function(){this.setColour(Blockly.MATRIX_CATEGORY_HUE);this.setOutput(!0,AI.BlockUtils.YailTypeToBlocklyType("matrix",AI.BlockUtils.OUTPUT));this.appendValueInput("MATRIX").setCheck(AI.BlockUtils.YailTypeToBlocklyType("matrix",AI.BlockUtils.INPUT)).appendField(new Blockly.FieldDropdown(Blockly.Blocks.matrices_operations.OPERATORS),
"OP");this.setFieldValue("ROTATE_LEFT","OP");var d=this;this.setTooltip(function(){var e=d.getFieldValue("OP");return Blockly.Blocks.matrices_operations.TOOLTIPS()[e]})}};
Blockly.Blocks.matrices_rotate_right={category:"Matrices",helpUrl:function(){var d=this.getFieldValue("OP");return Blockly.Blocks.matrices_operations.HELPURLS()[d]},init:function(){this.setColour(Blockly.MATRIX_CATEGORY_HUE);this.setOutput(!0,AI.BlockUtils.YailTypeToBlocklyType("matrix",AI.BlockUtils.OUTPUT));this.appendValueInput("MATRIX").setCheck(AI.BlockUtils.YailTypeToBlocklyType("matrix",AI.BlockUtils.INPUT)).appendField(new Blockly.FieldDropdown(Blockly.Blocks.matrices_operations.OPERATORS),
"OP");this.setFieldValue("ROTATE_RIGHT","OP");var d=this;this.setTooltip(function(){var e=d.getFieldValue("OP");return Blockly.Blocks.matrices_operations.TOOLTIPS()[e]})}};
Blockly.Blocks.matrices_is_matrix={category:"Matrices",helpUrl:Blockly.Msg.LANG_MATRICES_IS_MATRIX_HELPURL,init:function(){this.setColour(Blockly.MATRIX_CATEGORY_HUE);this.setOutput(!0,AI.BlockUtils.YailTypeToBlocklyType("boolean",AI.BlockUtils.OUTPUT));this.appendValueInput("VALUE").setCheck(null).appendField(Blockly.Msg.LANG_MATRICES_IS_MATRIX);this.setTooltip(Blockly.Msg.LANG_MATRICES_IS_MATRIX_TOOLTIP)},typeblock:[{translatedName:Blockly.Msg.LANG_MATRICES_IS_MATRIX}]};/*

 @fileoverview Visual blocks editor for App Inventor
 Methods to handle serialization of the blocks workspace

 @author sharon@google.com (Sharon Perl)
*/
AI.Blockly.FieldProcedure={};AI.Blockly.AIProcedure={};AI.Blockly.FieldProcedure.defaultValue=["",""];
AI.Blockly.FieldProcedure.onChange=function(d){var e=this.block.getTopWorkspace();if(this.block.isEditable()&&(d=e.getProcedureDatabase().getProcedure(d))){e=d.getFieldValue("NAME");if(!this.block.isRenaming&&(""==e||e!=this.getValue()))for(let h=0;null!=this.block.getInput("ARG"+h);h++)this.block.removeInput("ARG"+h);this.block.isRenaming?this.block.render():this.block.setProcedureParameters(d.arguments_,d.paramIds_,!0);return e}};
AI.Blockly.AIProcedure.getProcedureNames=function(d,e){e=(e||Blockly.common.getMainWorkspace()).getTopBlocks();for(var h=[AI.Blockly.FieldProcedure.defaultValue],k=0;k<e.length;k++){var m=e[k].getFieldValue("NAME");("procedures_defnoreturn"!=e[k].type||"all"!=d&&d)&&("procedures_defreturn"!=e[k].type||"all"!=d&&!d)||h.push([m,m])}1<h.length&&h.splice(0,1);return h};
AI.Blockly.AIProcedure.getProcedureDeclarationBlocks=function(d,e){e=(e||Blockly.common.getMainWorkspace()).getTopBlocks(!1);for(var h=[],k=0;k<e.length;k++)"procedures_defnoreturn"!=e[k].type||d?"procedures_defreturn"==e[k].type&&d&&h.push(e[k]):h.push(e[k]);return h};
AI.Blockly.AIProcedure.getAllProcedureDeclarationBlocksExcept=function(d){for(var e=d.workspace.getTopBlocks(!1),h=[],k=0;k<e.length;k++)"procedures_defnoreturn"!==e[k].type&&"procedures_defreturn"!==e[k].type||e[k]===d||h.push(e[k]);return h};AI.Blockly.AIProcedure.getAllProcedureDeclarationNames=function(){return AI.Blockly.AIProcedure.getAllProcedureDeclarationBlocks().map(function(d){return d.getFieldValue("NAME")})};
AI.Blockly.AIProcedure.removeProcedureValues=function(d,e,h){if(e&&e===Blockly.common.getMainWorkspace()){e=e.getAllBlocks();for(var k=0;k<e.length;k++){var m=e[k];if("procedures_callreturn"==m.type||"procedures_callnoreturn"==m.type||"procedures_getWithDropdown"==m.type){var p;if(p=m.getFieldValue("PROCNAME")==d){a:{if(p=h)for(var t=m.getParent();t;t=t.getParent())if(t===p){p=!0;break a}p=!1}p=!p}p&&m.removeProcedureValue()}}}};
AI.Blockly.AIProcedure.renameProcedure=function(d){if(this.getSourceBlock&&this.getSourceBlock()&&this.getSourceBlock().isInFlyout)return d;var e=this.oldName_||this.text_;d=Blockly.LexicalVariable.makeLegalIdentifier(d);var h=AI.Blockly.AIProcedure.getAllProcedureDeclarationBlocksExcept(this.getSourceBlock()).map(function(p){return p.getFieldValue("NAME")});d=Blockly.FieldLexicalVariable.nameNotIn(d,h);h=this.getSourceBlock().workspace.getAllBlocks();for(var k=0;k<h.length;k++){var m=h[k].renameProcedure;
m&&m.call(h[k],e,d)}return this.oldName_=d};/*

 @fileoverview Procedure blocks for Blockly, modified for MIT App Inventor.
 @author mckinney@mit.edu (Andrew F. McKinney)
*/
AI.Blocks.procedures={};
Blockly.Blocks.procedures_defnoreturn={category:"Procedures",helpUrl:Blockly.Msg.LANG_PROCEDURES_DEFNORETURN_HELPURL,bodyInputName:"STACK",init:function(){this.setColour(Blockly.PROCEDURE_CATEGORY_HUE);var d=Blockly.Procedures.findLegalName(Blockly.Msg.LANG_PROCEDURES_DEFNORETURN_PROCEDURE,this);this.appendDummyInput("HEADER").appendField(Blockly.Msg.LANG_PROCEDURES_DEFNORETURN_DEFINE).appendField(new AI.Blockly.FieldProcedureName(d),"NAME");this.horizontalParameters=!0;this.appendStatementInput("STACK").appendField(Blockly.Msg.LANG_PROCEDURES_DEFNORETURN_DO);this.setMutator(new Blockly.icons.MutatorIcon(["procedures_mutatorarg"],
this));this.setTooltip(Blockly.Msg.LANG_PROCEDURES_DEFNORETURN_TOOLTIP);this.arguments_=[];this.warnings=[{name:"checkEmptySockets",sockets:["STACK"]}];this.lexicalVarPrefix=Blockly.localNamePrefix},withLexicalVarsAndPrefix:function(d,e){d=this.declaredNames();for(let h=0;h<d.length;h++)e(d[h],this.lexicalVarPrefix)},onchange:function(){this.arguments_=this.declaredNames()},updateParams_:function(d){d&&(this.arguments_=d);d=!1;for(var e={},h=0;h<this.arguments_.length;h++){if(e["arg_"+this.arguments_[h].toLowerCase()]){d=
!0;break}e["arg_"+this.arguments_[h].toLowerCase()]=!0}d?this.setWarningText(Blockly.Msg.LANG_PROCEDURES_DEF_DUPLICATE_WARNING):this.setWarningText(null);d=this.getFieldValue("NAME");var k=this;Blockly.FieldParameterFlydown.withChangeHanderDisabled(function(){k.removeInput("HEADER")});e=this.inputList.length-1;if(0<e&&this.getInput("VAR0"))for(var m=0;m<e;m++)try{Blockly.FieldParameterFlydown.withChangeHanderDisabled(function(){k.removeInput("VAR"+m)})}catch(p){console.log(p)}d=this.appendDummyInput("HEADER").appendField(Blockly.Msg.LANG_PROCEDURES_DEFNORETURN_DEFINE).appendField(new AI.Blockly.FieldProcedureName(d),
"NAME");if(this.horizontalParameters)for(m=0;m<this.arguments_.length;m++)d.appendField(" ").appendField(this.parameterFlydown(m),"VAR"+m);else for(m=0;m<this.arguments_.length;m++)this.appendDummyInput("VAR"+m).appendField(this.parameterFlydown(m),"VAR"+m).setAlign(Blockly.inputs.Align.RIGHT);this.moveInputBefore(this.bodyInputName);this.workspace.loadCompleted&&Blockly.Procedures.mutateCallers(this)},parameterFlydown:function(d){var e=this;return new Blockly.FieldParameterFlydown(this.arguments_[d],
!0,this.horizontalParameters?Blockly.FieldFlydown.DISPLAY_BELOW:Blockly.FieldFlydown.DISPLAY_RIGHT,function(h){e.arguments_[d]=h;Blockly.Procedures.mutateCallers(e);if(e.mutator&&e.mutator.rootBlock){for(var k=0,m=e.mutator.rootBlock.getInputTargetBlock("STACK");m&&k<d;)m=m.nextConnection&&m.nextConnection.targetBlock(),k++;m&&k==d&&Blockly.Field.prototype.setValue.call(m.getField("NAME"),h)}})},setParameterOrientation:function(d){0!=this.getParameters().length&&d!==this.horizontalParameters&&(this.horizontalParameters=
d,this.updateParams_(),Blockly.Events.isEnabled()&&Blockly.Events.fire(new Blockly.Events.BlockChange(this,"parameter_orientation",null,!this.horizontalParameters,this.horizontalParameters)))},mutationToDom:function(){var d=document.createElement("mutation");this.horizontalParameters||d.setAttribute("vertical_parameters","true");for(var e=0;e<this.arguments_.length;e++){var h=document.createElement("arg");h.setAttribute("name",this.arguments_[e]);d.appendChild(h)}return d},domToMutation:function(d){for(var e=
[],h=Array.prototype.filter.call(d.childNodes,function(p){return p.nodeType==Element.ELEMENT_NODE}),k=0,m;m=h[k];k++)"arg"==m.nodeName.toLowerCase()&&e.push(m.getAttribute("name"));this.horizontalParameters="true"!==d.getAttribute("vertical_parameters");this.updateParams_(e)},decompose:function(d){var e=d.newBlock("procedures_mutatorcontainer");e.initSvg();e.setProcBlock(this);this.paramIds_=[];for(var h=e.getInput("STACK").connection,k=0;k<this.arguments_.length;k++){var m=d.newBlock("procedures_mutatorarg");
this.paramIds_.push(m.id);m.initSvg();m.setFieldValue(this.arguments_[k],"NAME");m.oldLocation=k;h.connect(m.previousConnection);h=m.nextConnection}Blockly.Procedures.mutateCallers(this);return e},compose:function(d){var e=[];this.paramIds_=[];for(d=d.getInputTargetBlock("STACK");d;)e.push(d.getFieldValue("NAME")),this.paramIds_.push(d.id),d=d.nextConnection&&d.nextConnection.targetBlock();Blockly.LexicalVariable.stringListsEqual(e,this.arguments_)||(this.updateParams_(e),Blockly.Procedures.mutateCallers(this))},
dispose:function(){var d=this.getFieldValue("NAME"),e=this.isOwnEditable(),h=this.workspace;e&&AI.Blockly.AIProcedure.removeProcedureValues(d,h,this);Object.getPrototypeOf(this).dispose.apply(this,arguments);d=h.getProcedureDatabase();e&&d&&h==Blockly.common.getMainWorkspace()&&d.removeProcedure(this.id)},getProcedureDef:function(){return[this.getFieldValue("NAME"),this.arguments_,"RETURN"===this.bodyInputName]},getVars:function(){for(var d=[],e=0,h;h=this.getFieldValue("VAR"+e);e++)d.push(h);return d},
declaredNames:function(){return this.getVars()},declaredVariables:function(){return this.getVars()},renameVar:function(d,e){this.renameVars(Blockly.Substitution.simpleSubstitution(d,e))},renameVars:function(d){var e=this.getParameters(),h=d.map(e);if(!Blockly.LexicalVariable.stringListsEqual(e,h)&&(this.updateParams_(h),this.mutator.isVisible())){e=this.mutator.getWorkspace().getAllBlocks();h=0;for(var k;k=e[h];h++)if("procedures_mutatorarg"==k.type){var m=k.getFieldValue("NAME"),p=d.apply(m);p!==
m&&k.setFieldValue(p,"NAME")}}},renameBound:function(d,e){d=d.restrictDomain(this.declaredNames());this.renameVars(d);e=e.extend(d);Blockly.LexicalVariable.renameFree(this.getInputTargetBlock(this.bodyInputName),e)},renameFree:function(d){this.freeVariables()},freeVariables:function(){var d=Blockly.LexicalVariable.freeVariables(this.getInputTargetBlock(this.bodyInputName));d.subtract(new Blockly.NameSet(this.declaredNames()));if(d.isEmpty())return d;throw"Violation of invariant: procedure declaration has nonempty free variables: "+
d.toString();},blocksInScope:function(){var d=this.getInputTargetBlock(this.bodyInputName);return d&&[d]||[]},typeblock:[{translatedName:Blockly.Msg.LANG_PROCEDURES_DEFNORETURN_PROCEDURE+" "+Blockly.Msg.LANG_PROCEDURES_DEFNORETURN_DO}],customContextMenu:function(d){const e=d.findIndex(function(h){return h.text===Blockly.Msg.DO_IT});d.splice(e,1);Blockly.FieldParameterFlydown.addHorizontalVerticalOption(this,d)},getParameters:function(){return this.arguments_}};
Blockly.Blocks.procedures_defreturn={category:"Procedures",helpUrl:Blockly.Msg.LANG_PROCEDURES_DEFRETURN_HELPURL,bodyInputName:"RETURN",init:function(){this.setColour(Blockly.PROCEDURE_CATEGORY_HUE);var d=Blockly.Procedures.findLegalName(Blockly.Msg.LANG_PROCEDURES_DEFRETURN_PROCEDURE,this);this.appendDummyInput("HEADER").appendField(Blockly.Msg.LANG_PROCEDURES_DEFRETURN_DEFINE).appendField(new AI.Blockly.FieldProcedureName(d),"NAME");this.horizontalParameters=!0;this.appendInputFromRegistry("indented_input",
"RETURN").appendField(Blockly.Msg.LANG_PROCEDURES_DEFRETURN_RETURN);this.setMutator(new Blockly.icons.MutatorIcon(["procedures_mutatorarg"],this));this.setTooltip(Blockly.Msg.LANG_PROCEDURES_DEFRETURN_TOOLTIP);this.arguments_=[];this.warnings=[{name:"checkEmptySockets",sockets:["RETURN"]}]},withLexicalVarsAndPrefix:Blockly.Blocks.procedures_defnoreturn.withLexicalVarsAndPrefix,onchange:Blockly.Blocks.procedures_defnoreturn.onchange,updateParams_:Blockly.Blocks.procedures_defnoreturn.updateParams_,
parameterFlydown:Blockly.Blocks.procedures_defnoreturn.parameterFlydown,setParameterOrientation:Blockly.Blocks.procedures_defnoreturn.setParameterOrientation,mutationToDom:Blockly.Blocks.procedures_defnoreturn.mutationToDom,domToMutation:Blockly.Blocks.procedures_defnoreturn.domToMutation,decompose:Blockly.Blocks.procedures_defnoreturn.decompose,compose:Blockly.Blocks.procedures_defnoreturn.compose,dispose:Blockly.Blocks.procedures_defnoreturn.dispose,getProcedureDef:Blockly.Blocks.procedures_defnoreturn.getProcedureDef,
getVars:Blockly.Blocks.procedures_defnoreturn.getVars,declaredNames:Blockly.Blocks.procedures_defnoreturn.declaredNames,declaredVariables:Blockly.Blocks.procedures_defnoreturn.declaredVariables,renameVar:Blockly.Blocks.procedures_defnoreturn.renameVar,renameVars:Blockly.Blocks.procedures_defnoreturn.renameVars,renameBound:Blockly.Blocks.procedures_defnoreturn.renameBound,renameFree:Blockly.Blocks.procedures_defnoreturn.renameFree,freeVariables:Blockly.Blocks.procedures_defnoreturn.freeVariables,blocksInScope:Blockly.Blocks.procedures_defnoreturn.blocksInScope,
typeblock:[{translatedName:Blockly.Msg.LANG_PROCEDURES_DEFRETURN_PROCEDURE+" "+Blockly.Msg.LANG_PROCEDURES_DEFRETURN_RETURN}],customContextMenu:Blockly.Blocks.procedures_defnoreturn.customContextMenu,getParameters:Blockly.Blocks.procedures_defnoreturn.getParameters};
Blockly.Blocks.procedures_mutatorcontainer={init:function(){this.setColour(Blockly.PROCEDURE_CATEGORY_HUE);this.appendDummyInput().appendField(Blockly.Msg.LANG_PROCEDURES_MUTATORCONTAINER_TITLE);this.appendStatementInput("STACK");this.setTooltip(Blockly.Msg.LANG_PROCEDURES_MUTATORCONTAINER_TOOLTIP);this.contextMenu=!1},setProcBlock:function(d){this.procBlock_=d},getProcBlock:function(){return this.procBlock_},declaredNames:function(){for(var d=[],e=this.getInputTargetBlock("STACK");e;)d.push(e.getFieldValue("NAME")),
e=e.nextConnection&&e.nextConnection.targetBlock();return d}};
Blockly.Blocks.procedures_mutatorarg={init:function(){this.setColour(Blockly.PROCEDURE_CATEGORY_HUE);var d=new Blockly.FieldTextInput("x",Blockly.LexicalVariable.renameParam);d.onHtmlInputChange=function(e){var h=this.getValue();Blockly.FieldFlydown.prototype.onHtmlInputChange.call(this,e);(e=this.getValue())&&h!==e&&Blockly.Events.isEnabled()&&Blockly.Events.fire(new Blockly.Events.BlockChange(this.getSourceBlock(),"field",this.name,h,e))};this.appendDummyInput().appendField(Blockly.Msg.LANG_PROCEDURES_MUTATORARG_TITLE).appendField(d,
"NAME");this.setPreviousStatement(!0);this.setNextStatement(!0);this.setTooltip(Blockly.Msg.LANG_PROCEDURES_MUTATORARG_TOOLTIP);this.contextMenu=!1},getContainerBlock:function(){for(var d=this.getParent();d&&"procedures_mutatorcontainer"!==d.type;)d=d.getParent();return this.cachedContainerBlock_=d&&"procedures_mutatorcontainer"===d.type&&d||null},getProcBlock:function(){var d=this.getContainerBlock();return d&&d.getProcBlock()||null},declaredNames:function(){var d=this.getContainerBlock();return d&&
d.declaredNames()||[]},blocksInScope:function(){var d=this.getProcBlock();return d&&d.blocksInScope()||[]},onchange:function(){var d=this.getFieldValue("NAME");if(d){var e=this.cachedContainerBlock_,h=this.getContainerBlock();!e&&h&&(e=this.declaredNames(),h=e.indexOf(d),-1!=h&&-1!=e.indexOf(d,h+1)&&(d=Blockly.FieldLexicalVariable.nameNotIn(d,e),this.setFieldValue(d,"NAME")))}}};
Blockly.Blocks.procedures_mutatorarg.validator=function(d){return(d=d.replace(/[\s\xa0]+/g," ").replace(/^ | $/g,""))||null};
Blockly.Blocks.procedures_defanonnoreturn={category:"Procedures",helpUrl:Blockly.Msg.LANG_PROCEDURES_DEFANONNORETURN_HELPURL,bodyInputName:"STACK",init:function(){this.setColour(Blockly.PROCEDURE_CATEGORY_HUE);this.appendDummyInput("HEADER").appendField(Blockly.Msg.LANG_PROCEDURES_DEFANONNORETURN_DEFINE);this.horizontalParameters=!0;this.appendStatementInput("STACK").appendField(Blockly.Msg.LANG_PROCEDURES_DEFNORETURN_DO);this.setOutput(!0,AI.BlockUtils.YailTypeToBlocklyType("procedure",AI.BlockUtils.OUTPUT));
this.setTooltip(Blockly.Msg.LANG_PROCEDURES_DEFNORETURN_TOOLTIP);this.setMutator(new Blockly.icons.MutatorIcon(["procedures_mutatorarg"],this));this.arguments_=[];this.warnings=[{name:"checkEmptySockets",sockets:["STACK"]}]},onchange:Blockly.Blocks.procedures_defnoreturn.onchange,updateParams_:function(d){d&&(this.arguments_=d);d=!1;for(var e={},h=0;h<this.arguments_.length;h++){if(e["arg_"+this.arguments_[h].toLowerCase()]){d=!0;break}e["arg_"+this.arguments_[h].toLowerCase()]=!0}d?this.setWarningText(Blockly.Msg.LANG_PROCEDURES_DEF_DUPLICATE_WARNING):
this.setWarningText(null);var k=this;Blockly.FieldParameterFlydown.withChangeHanderDisabled(function(){k.removeInput("HEADER")});d=this.inputList.length-1;if(0<d&&this.getInput("VAR0"))for(var m=0;m<d;m++)try{Blockly.FieldParameterFlydown.withChangeHanderDisabled(function(){k.removeInput("VAR"+m)})}catch(p){console.log(p)}d=this.appendDummyInput("HEADER").appendField(Blockly.Msg.LANG_PROCEDURES_DEFANONNORETURN_DEFINE);if(this.horizontalParameters)for(m=0;m<this.arguments_.length;m++)d.appendField(" ").appendField(this.parameterFlydown(m),
"VAR"+m);else for(m=0;m<this.arguments_.length;m++)this.appendDummyInput("VAR"+m).appendField(this.parameterFlydown(m),"VAR"+m).setAlign(Blockly.inputs.Align.RIGHT);this.moveInputBefore(this.bodyInputName)},parameterFlydown:function(d){var e=this;return new Blockly.FieldParameterFlydown(this.arguments_[d],!0,this.horizontalParameters?Blockly.FieldFlydown.DISPLAY_BELOW:Blockly.FieldFlydown.DISPLAY_RIGHT,function(h){e.arguments_[d]=h;if(e.mutator&&e.mutator.rootBlock_){for(var k=0,m=e.mutator.rootBlock_.getInputTargetBlock("STACK");m&&
k<d;)m=m.nextConnection&&m.nextConnection.targetBlock(),k++;m&&k==d&&Blockly.Field.prototype.setText.call(m.getField("NAME"),h)}})},setParameterOrientation:Blockly.Blocks.procedures_defnoreturn.setParameterOrientation,mutationToDom:Blockly.Blocks.procedures_defnoreturn.mutationToDom,domToMutation:Blockly.Blocks.procedures_defnoreturn.domToMutation,decompose:function(d){var e=d.newBlock("procedures_mutatorcontainer");e.initSvg();e.setProcBlock(this);this.paramIds_=[];for(var h=e.getInput("STACK").connection,
k=0;k<this.arguments_.length;k++){var m=d.newBlock("procedures_mutatorarg");this.paramIds_.push(m.id);m.initSvg();m.setFieldValue(this.arguments_[k],"NAME");m.oldLocation=k;h.connect(m.previousConnection);h=m.nextConnection}return e},compose:function(d){var e=[];this.paramIds_=[];for(d=d.getInputTargetBlock("STACK");d;)e.push(d.getFieldValue("NAME")),this.paramIds_.push(d.id),d=d.nextConnection&&d.nextConnection.targetBlock();Blockly.LexicalVariable.stringListsEqual(e,this.arguments_)||this.updateParams_(e)},
dispose:function(){Object.getPrototypeOf(this).dispose.apply(this,arguments)},withLexicalVarsAndPrefix:Blockly.Blocks.procedures_defnoreturn.withLexicalVarsAndPrefix,getVars:Blockly.Blocks.procedures_defnoreturn.getVars,declaredNames:Blockly.Blocks.procedures_defnoreturn.declaredNames,renameVar:Blockly.Blocks.procedures_defnoreturn.renameVar,renameVars:Blockly.Blocks.procedures_defnoreturn.renameVars,renameBound:Blockly.Blocks.procedures_defnoreturn.renameBound,renameFree:Blockly.Blocks.procedures_defnoreturn.renameFree,
freeVariables:Blockly.Blocks.procedures_defnoreturn.freeVariables,blocksInScope:Blockly.Blocks.procedures_defnoreturn.blocksInScope,customContextMenu:Blockly.Blocks.procedures_defnoreturn.customContextMenu,getParameters:Blockly.Blocks.procedures_defnoreturn.getParameters,typeblock:[{translatedName:Blockly.Msg.LANG_PROCEDURES_DEFANONNORETURN_DEFINE}]};
Blockly.Blocks.procedures_defanonreturn={category:"Procedures",helpUrl:Blockly.Msg.LANG_PROCEDURES_DEFANONRETURN_HELPURL,bodyInputName:"RETURN",init:function(){this.setColour(Blockly.PROCEDURE_CATEGORY_HUE);this.appendDummyInput("HEADER").appendField(Blockly.Msg.LANG_PROCEDURES_DEFANONNORETURN_DEFINE);this.horizontalParameters=!0;this.appendInputFromRegistry("indented_input","RETURN").appendField(Blockly.Msg.LANG_PROCEDURES_DEFRETURN_RETURN);this.setMutator(new Blockly.icons.MutatorIcon(["procedures_mutatorarg"],
this));this.setOutput(!0,AI.BlockUtils.YailTypeToBlocklyType("procedure",AI.BlockUtils.OUTPUT));this.setTooltip(Blockly.Msg.LANG_PROCEDURES_DEFRETURN_TOOLTIP);this.arguments_=[];this.warnings=[{name:"checkEmptySockets",sockets:["RETURN"]}]},updateParams_:function(d){d&&(this.arguments_=d);d=!1;for(var e={},h=0;h<this.arguments_.length;h++){if(e["arg_"+this.arguments_[h].toLowerCase()]){d=!0;break}e["arg_"+this.arguments_[h].toLowerCase()]=!0}d?this.setWarningText(Blockly.Msg.LANG_PROCEDURES_DEF_DUPLICATE_WARNING):
this.setWarningText(null);var k=this;Blockly.FieldParameterFlydown.withChangeHanderDisabled(function(){k.removeInput("HEADER")});d=this.inputList.length-1;if(0<d&&this.getInput("VAR0"))for(var m=0;m<d;m++)try{Blockly.FieldParameterFlydown.withChangeHanderDisabled(function(){k.removeInput("VAR"+m)})}catch(p){console.log(p)}d=this.appendDummyInput("HEADER").appendField(Blockly.Msg.LANG_PROCEDURES_DEFANONNORETURN_DEFINE);if(this.horizontalParameters)for(m=0;m<this.arguments_.length;m++)d.appendField(" ").appendField(this.parameterFlydown(m),
"VAR"+m);else for(m=0;m<this.arguments_.length;m++)this.appendDummyInput("VAR"+m).appendField(this.parameterFlydown(m),"VAR"+m).setAlign(Blockly.inputs.Align.RIGHT);this.moveInputBefore(this.bodyInputName)},withLexicalVarsAndPrefix:Blockly.Blocks.procedures_defnoreturn.withLexicalVarsAndPrefix,onchange:Blockly.Blocks.procedures_defnoreturn.onchange,parameterFlydown:Blockly.Blocks.procedures_defnoreturn.parameterFlydown,setParameterOrientation:Blockly.Blocks.procedures_defnoreturn.setParameterOrientation,
mutationToDom:Blockly.Blocks.procedures_defnoreturn.mutationToDom,domToMutation:Blockly.Blocks.procedures_defnoreturn.domToMutation,decompose:Blockly.Blocks.procedures_defnoreturn.decompose,compose:Blockly.Blocks.procedures_defnoreturn.compose,dispose:Blockly.Blocks.procedures_defnoreturn.dispose,getProcedureDef:function(){return["",this.arguments_,!0]},getVars:Blockly.Blocks.procedures_defnoreturn.getVars,declaredNames:Blockly.Blocks.procedures_defnoreturn.declaredNames,declaredVariables:Blockly.Blocks.procedures_defnoreturn.declaredVariables,
renameVar:Blockly.Blocks.procedures_defnoreturn.renameVar,renameVars:Blockly.Blocks.procedures_defnoreturn.renameVars,renameBound:Blockly.Blocks.procedures_defnoreturn.renameBound,renameFree:Blockly.Blocks.procedures_defnoreturn.renameFree,freeVariables:Blockly.Blocks.procedures_defnoreturn.freeVariables,blocksInScope:Blockly.Blocks.procedures_defnoreturn.blocksInScope,typeblock:[{translatedName:Blockly.Msg.LANG_PROCEDURES_DEFANONNORETURN_DEFINE+" "+Blockly.Msg.LANG_PROCEDURES_DEFRETURN_RETURN}],
customContextMenu:Blockly.Blocks.procedures_defnoreturn.customContextMenu,getParameters:Blockly.Blocks.procedures_defnoreturn.getParameters};
Blockly.Blocks.procedures_callnoreturn={category:"Procedures",helpUrl:Blockly.Msg.LANG_PROCEDURES_CALLNORETURN_HELPURL,init:function(){this.setColour(Blockly.PROCEDURE_CATEGORY_HUE);var d=this.getTopWorkspace().getProcedureDatabase();this.procNamesFxn=function(){var e=d.getMenuItems(!1);return 0<e.length?e:["",""]};this.procDropDown=new AI.Blockly.ProcedureNameDropdown(this.procNamesFxn,AI.Blockly.FieldProcedure.onChange);this.procDropDown.block=this;this.appendDummyInput().appendField(Blockly.Msg.LANG_PROCEDURES_CALLNORETURN_CALL).appendField(this.procDropDown,
"PROCNAME");this.setPreviousStatement(!0);this.setNextStatement(!0);this.setTooltip(Blockly.Msg.LANG_PROCEDURES_CALLNORETURN_TOOLTIP);this.arguments_=[];this.quarkArguments_=this.quarkConnections_=null;this.errors=[{name:"checkIsInDefinition"},{name:"checkDropDownContainsValidValue",dropDowns:["PROCNAME"]}];AI.Blockly.FieldProcedure.onChange.call(this.getField("PROCNAME"),this.getField("PROCNAME").getValue())},getProcedureCall:function(){return this.getFieldValue("PROCNAME")},renameProcedure:function(d,
e){if(Blockly.Names.equals(d,this.getFieldValue("PROCNAME"))){d=!!this.isRenaming;this.isRenaming=!0;try{this.setFieldValue(e,"PROCNAME")}finally{this.isRenaming=d}}},setProcedureParameters:function(d,e,h){var k,m;e||(this.quarkConnections_={},this.quarkArguments_=null,e=[].concat(d));if(e.length!=d.length)throw"Error: paramNames and paramIds must be the same length.";var p={};for(k=0;k<d.length;k++)p[e[k]]=d[k];"undefined"==typeof h&&(h=null);if(!this.quarkArguments_||h)this.quarkConnections_={},
Blockly.LexicalVariable.stringListsEqual(d,this.arguments_)||h?this.quarkArguments_=e:this.quarkArguments_=[];for(m=0;this.getInput("ARG"+m);m++)if(h=this.getInput("ARG"+m))k=h.connection.targetConnection,this.quarkConnections_[this.quarkArguments_[m]]=k,this.removeInput("ARG"+m);this.arguments_=[].concat(d);this.quarkArguments_=e;for(m=0;m<this.arguments_.length;m++)h=this.appendValueInput("ARG"+m).setAlign(Blockly.inputs.Align.RIGHT).appendField(this.arguments_[m]),this.quarkArguments_&&(d=this.quarkArguments_[m],
d in this.quarkConnections_?(k=this.quarkConnections_[d],!k||k.targetConnection||k.getSourceBlock().workspace!=this.workspace?delete this.quarkConnections_[d]:h.connection.connect(k)):p[d]&&(k=this.quarkConnections_[p[d]])&&h.connection.connect(k))},mutationToDom:function(){var d=document.createElement("mutation");d.setAttribute("name",this.getFieldValue("PROCNAME"));for(var e=0;this.getInput("ARG"+e);e++){var h=document.createElement("arg");h.setAttribute("name",this.getInput("ARG"+e).fieldRow[0].getText());
d.appendChild(h)}return d},domToMutation:function(d){var e=d.getAttribute("name");this.setFieldValue(e,"PROCNAME");this.arguments_=[];d=Array.prototype.filter.call(d.childNodes,function(k){return k.nodeType===Element.ELEMENT_NODE});e=0;for(var h;h=d[e];e++)"arg"==h.nodeName.toLowerCase()&&this.arguments_.push(h.getAttribute("name"));this.setProcedureParameters(this.arguments_,null,!0)},renameVar:function(d,e){for(var h=0;h<this.arguments_.length;h++)Blockly.Names.equals(d,this.arguments_[h])&&(this.arguments_[h]=
e,this.getInput("ARG"+h).fieldRow[0].setValue(e))},customContextMenu:function(d){var e={enabled:!0};e.text=Blockly.Msg.LANG_PROCEDURES_HIGHLIGHT_DEF;var h=this.getFieldValue("PROCNAME"),k=this.workspace;e.callback=function(){var m=Blockly.Procedures.getDefinition(h,k);if(m){Blockly.common.setSelected(m);const p=new AI.Events.WorkspaceMove(k.id);k.centerOnBlock(m.id);p.recordNew();Blockly.Events.fire(p);k.getParentSvg().parentElement.focus()}};d.push(e)},removeProcedureValue:function(){for(var d=0;null!==
this.getInput("ARG"+d);d++)this.removeInput("ARG"+d);this.setFieldValue("none","PROCNAME")},typeblock:[{translatedName:Blockly.Msg.LANG_PROCEDURES_CALLNORETURN_TRANSLATED_NAME}]};
Blockly.Blocks.procedures_callreturn={category:"Procedures",helpUrl:Blockly.Msg.LANG_PROCEDURES_CALLRETURN_HELPURL,init:function(){this.setColour(Blockly.PROCEDURE_CATEGORY_HUE);var d=this.getTopWorkspace().getProcedureDatabase();this.procNamesFxn=function(){var e=d.getMenuItems(!0);return 0<e.length?e:["",""]};this.procDropDown=new AI.Blockly.ProcedureNameDropdown(this.procNamesFxn,AI.Blockly.FieldProcedure.onChange);this.procDropDown.block=this;this.appendDummyInput().appendField(Blockly.Msg.LANG_PROCEDURES_CALLRETURN_CALL).appendField(this.procDropDown,
"PROCNAME");this.setOutput(!0,null);this.setTooltip(Blockly.Msg.LANG_PROCEDURES_CALLRETURN_TOOLTIP);this.arguments_=[];this.quarkArguments_=this.quarkConnections_=null;this.errors=[{name:"checkIsInDefinition"},{name:"checkDropDownContainsValidValue",dropDowns:["PROCNAME"]}];AI.Blockly.FieldProcedure.onChange.call(this.getField("PROCNAME"),this.getField("PROCNAME").getValue())},getProcedureCall:Blockly.Blocks.procedures_callnoreturn.getProcedureCall,renameProcedure:Blockly.Blocks.procedures_callnoreturn.renameProcedure,
setProcedureParameters:Blockly.Blocks.procedures_callnoreturn.setProcedureParameters,mutationToDom:Blockly.Blocks.procedures_callnoreturn.mutationToDom,domToMutation:Blockly.Blocks.procedures_callnoreturn.domToMutation,renameVar:Blockly.Blocks.procedures_callnoreturn.renameVar,customContextMenu:Blockly.Blocks.procedures_callnoreturn.customContextMenu,removeProcedureValue:Blockly.Blocks.procedures_callnoreturn.removeProcedureValue,typeblock:[{translatedName:Blockly.Msg.LANG_PROCEDURES_CALLRETURN_TRANSLATED_NAME}]};
Blockly.Blocks.procedures_callanonnoreturn={category:"Procedures",helpUrl:Blockly.Msg.LANG_PROCEDURES_CALLANONNORETURN_HELPURL,init:function(){this.setColour(Blockly.PROCEDURE_CATEGORY_HUE);var d=this.getTopWorkspace().getProcedureDatabase();this.procNamesFxn=function(){var e=d.getMenuItems(!1);return 0<e.length?e:[" "," "]};this.appendValueInput("PROCEDURE").setCheck(AI.BlockUtils.YailTypeToBlocklyType("procedure",AI.BlockUtils.INPUT)).appendField(Blockly.Msg.LANG_PROCEDURES_CALLANONNORETURN_CALL_ANON);
this.setPreviousStatement(!0);this.setNextStatement(!0);this.setTooltip(Blockly.Msg.LANG_PROCEDURES_CALLANONNORETURN_TOOLTIP);this.setMutator(new Blockly.icons.MutatorIcon(["anon_proc_arg"],this));this.itemCount_=0;this.emptyInputName=null;this.repeatingInputName="ARG"},mutationToDom:Blockly.mutationToDom,domToMutation:Blockly.domToMutation,decompose:function(d){return Blockly.decompose(d,"anon_proc_arg",this)},compose:Blockly.compose,saveConnections:Blockly.saveConnections,addEmptyInput:function(){},
addInput:function(d){return this.appendValueInput(this.repeatingInputName+d).appendField(Blockly.Msg.LANG_PROCEDURES_CALLANONNORETURN_INPUT+" "+(d+1)).setAlign(Blockly.inputs.Align.RIGHT)},updateContainerBlock:function(d){d.setFieldValue(Blockly.Msg.LANG_PROCEDURES_MUTATORCONTAINER_TITLE,"CONTAINER_TEXT")},typeblock:[{translatedName:Blockly.Msg.LANG_PROCEDURES_CALLANONNORETURN_CALL_ANON}]};
Blockly.Blocks.procedures_callanonreturn={category:"Procedures",helpUrl:Blockly.Msg.LANG_PROCEDURES_CALLANONNORETURN_HELPURL,init:function(){this.setColour(Blockly.PROCEDURE_CATEGORY_HUE);this.appendValueInput("PROCEDURE").setCheck(AI.BlockUtils.YailTypeToBlocklyType("procedure",AI.BlockUtils.INPUT)).appendField(Blockly.Msg.LANG_PROCEDURES_CALLANONNORETURN_CALL_ANON);this.setOutput(!0,null);this.setTooltip(Blockly.Msg.LANG_PROCEDURES_CALLANONRETURN_TOOLTIP);this.setMutator(new Blockly.icons.MutatorIcon(["anon_proc_arg"],
this));this.itemCount_=0;this.emptyInputName=null;this.repeatingInputName="ARG"},mutationToDom:Blockly.Blocks.procedures_callanonnoreturn.mutationToDom,domToMutation:Blockly.Blocks.procedures_callanonnoreturn.domToMutation,decompose:Blockly.Blocks.procedures_callanonnoreturn.decompose,compose:Blockly.Blocks.procedures_callanonnoreturn.compose,saveConnections:Blockly.Blocks.procedures_callanonnoreturn.saveConnections,addEmptyInput:Blockly.Blocks.procedures_callanonnoreturn.addEmptyInput,addInput:Blockly.Blocks.procedures_callanonnoreturn.addInput,
updateContainerBlock:Blockly.Blocks.procedures_callanonnoreturn.updateContainerBlock,typeblock:[{translatedName:Blockly.Msg.LANG_PROCEDURES_CALLANONNORETURN_CALL_ANON+"2"}]};Blockly.Blocks.anon_proc_arg={init:function(){this.setColour(Blockly.PROCEDURE_CATEGORY_HUE);this.appendDummyInput().appendField(Blockly.Msg.LANG_PROCEDURES_MUTATORARG_TITLE);this.setPreviousStatement(!0);this.setNextStatement(!0);this.contextMenu=!1}};
Blockly.Blocks.procedures_callanonnoreturn_inputlist={category:"Procedures",helpUrl:Blockly.Msg.LANG_PROCEDURES_CALLANONNORETURN_HELPURL,init:function(){this.setColour(Blockly.PROCEDURE_CATEGORY_HUE);this.appendValueInput("PROCEDURE").setCheck(AI.BlockUtils.YailTypeToBlocklyType("procedure",AI.BlockUtils.INPUT)).appendField(Blockly.Msg.LANG_PROCEDURES_CALLANONNORETURN_CALL_ANON);this.appendValueInput("INPUTLIST").setCheck(AI.BlockUtils.YailTypeToBlocklyType("list",AI.BlockUtils.INPUT)).appendField(Blockly.Msg.LANG_PROCEDURES_CALLANONNORETURN_INPUT_LIST).setAlign(Blockly.inputs.Align.RIGHT);
this.setPreviousStatement(!0);this.setNextStatement(!0);this.setTooltip(Blockly.Msg.LANG_PROCEDURES_CALLANONNORETURN_INPUTLIST_TOOLTIP)},typeblock:[{translatedName:Blockly.Msg.LANG_PROCEDURES_CALLANONNORETURN_CALL_ANON+" "+Blockly.Msg.LANG_PROCEDURES_CALLANONNORETURN_INPUT_LIST}]};
Blockly.Blocks.procedures_callanonreturn_inputlist={category:"Procedures",helpUrl:Blockly.Msg.LANG_PROCEDURES_CALLANONNORETURN_HELPURL,init:function(){this.setColour(Blockly.PROCEDURE_CATEGORY_HUE);this.appendValueInput("PROCEDURE").setCheck(AI.BlockUtils.YailTypeToBlocklyType("procedure",AI.BlockUtils.INPUT)).appendField(Blockly.Msg.LANG_PROCEDURES_CALLANONNORETURN_CALL_ANON);this.appendValueInput("INPUTLIST").setCheck(AI.BlockUtils.YailTypeToBlocklyType("list",AI.BlockUtils.INPUT)).appendField(Blockly.Msg.LANG_PROCEDURES_CALLANONNORETURN_INPUT_LIST).setAlign(Blockly.inputs.Align.RIGHT);
this.setOutput(!0,null);this.setTooltip(Blockly.Msg.LANG_PROCEDURES_CALLANONRETURN_INPUTLIST_TOOLTIP)},typeblock:[{translatedName:Blockly.Msg.LANG_PROCEDURES_CALLANONNORETURN_CALL_ANON+" "+Blockly.Msg.LANG_PROCEDURES_CALLANONNORETURN_INPUT_LIST+"2"}]};
Blockly.Blocks.procedures_numArgs={category:"Procedures",helpUrl:Blockly.Msg.LANG_PROCEDURES_NUMARGS_HELPURL,init:function(){this.setColour(Blockly.PROCEDURE_CATEGORY_HUE);this.appendValueInput("PROCEDURE").setCheck(AI.BlockUtils.YailTypeToBlocklyType("procedure",AI.BlockUtils.INPUT)).appendField(Blockly.Msg.LANG_PROCEDURES_NUMARGS_GET).appendField(Blockly.Msg.LANG_PROCEDURES_NUMARGS_ANONPROC);this.setTooltip(Blockly.Msg.LANG_PROCEDURES_NUMARGS_TOOLTIP);this.setOutput(!0,AI.BlockUtils.YailTypeToBlocklyType("number",
AI.BlockUtils.OUTPUT))},typeblock:[{translatedName:Blockly.Msg.LANG_PROCEDURES_NUMARGS_GET}]};
Blockly.Blocks.procedures_getWithName={category:"Procedures",helpUrl:Blockly.Msg.LANG_PROCEDURES_GETWITHNAME_HELPURL,init:function(){this.setColour(Blockly.PROCEDURE_CATEGORY_HUE);this.appendValueInput("PROCEDURENAME").setCheck(AI.BlockUtils.YailTypeToBlocklyType("text",AI.BlockUtils.INPUT)).appendField(Blockly.Msg.LANG_PROCEDURES_GETWITHNAME_GET).appendField(Blockly.Msg.LANG_PROCEDURES_GETWITHNAME_NAME);this.setTooltip(Blockly.Msg.LANG_PROCEDURES_GETWITHNAME_TOOLTIP);this.setOutput(!0,AI.BlockUtils.YailTypeToBlocklyType("procedure",
AI.BlockUtils.OUTPUT))},typeblock:[{translatedName:Blockly.Msg.LANG_PROCEDURES_GETWITHNAME_GET}]};
Blockly.Blocks.procedures_getWithDropdown={category:"Procedures",helpUrl:Blockly.Msg.LANG_PROCEDURES_GETWITHDROPDOWN_HELPURL,init:function(){this.setColour(Blockly.PROCEDURE_CATEGORY_HUE);var d=this.getTopWorkspace().getProcedureDatabase();this.procNamesFxn=function(){var e=d.getMenuItems("all");return 0<e.length?e:[" "," "]};this.procDropDown=new AI.Blockly.ProcedureNameDropdown(this.procNamesFxn,AI.Blockly.FieldProcedure.onChange);this.procDropDown.block=this;this.appendDummyInput().appendField(Blockly.Msg.LANG_PROCEDURES_GETWITHDROPDOWN_GET).appendField(this.procDropDown,
"PROCNAME");this.setTooltip(Blockly.Msg.LANG_PROCEDURES_GETWITHDROPDOWN_TOOLTIP);this.setOutput(!0,AI.BlockUtils.YailTypeToBlocklyType("procedure",AI.BlockUtils.OUTPUT));this.errors=[{name:"checkDropDownContainsValidValue",dropDowns:["PROCNAME"]}];this.setFieldValue(this.getFieldValue("PROCNAME"),"PROCNAME")},removeProcedureValue:function(){this.setFieldValue("none","PROCNAME")},renameProcedure:function(d,e){Blockly.Names.equals(d,this.getFieldValue("PROCNAME"))&&(this.setFieldValue(e,"PROCNAME"),
AI.BlockUtils.renameCollapsed(this,0))},setProcedureParameters:function(){},typeblock:[{translatedName:Blockly.Msg.LANG_PROCEDURES_GETWITHDROPDOWN_GET}]};/*

 @fileoverview Text blocks for Blockly, modified for MIT App Inventor.
 @author mckinney@mit.edu (Andrew F. McKinney)
*/
AI.Blocks.text={};
Blockly.Blocks.text={category:"Text",helpUrl:Blockly.Msg.LANG_TEXT_TEXT_HELPURL,init:function(){const d=new Blockly.FieldTextInput("",this.inputValidator);this.setColour(Blockly.TEXT_CATEGORY_HUE);this.appendDummyInput().appendField(Blockly.Msg.LANG_TEXT_TEXT_LEFT_QUOTE).appendField(d,"TEXT").appendField(Blockly.Msg.LANG_TEXT_TEXT_RIGHT_QUOTE);this.setOutput(!0,AI.BlockUtils.YailTypeToBlocklyType("text",AI.BlockUtils.OUTPUT));this.setTooltip(Blockly.Msg.LANG_TEXT_TEXT_TOOLTIP)},inputValidator:function(d){const e=
this.getSourceBlock();e.workspace.isLoading&&Blockly.Blocks.text.setOutputOnFinishEdit.call(e,d)},onchange:function(d){d.blockId!==this.id||d.type!==Blockly.Events.BLOCK_CHANGE&&d.type!==Blockly.Events.BLOCK_CREATE||(d=this.getFieldValue("TEXT"),Blockly.Blocks.text.setOutputOnFinishEdit.call(this,d))},errors:[{name:"checkInvalidNumber"}],typeblock:[{translatedName:Blockly.Msg.LANG_CATEGORY_TEXT}]};
Blockly.Blocks.text.setOutputOnFinishEdit=function(d){if(AI.BlockUtils.NUMBER_REGEX.test(d)&&!isNaN(parseFloat(d)))this.outputConnection.setCheck(AI.BlockUtils.YailTypeToBlocklyType("text",AI.BlockUtils.OUTPUT));else{d=Array.from(AI.BlockUtils.YailTypeToBlocklyType("text",AI.BlockUtils.OUTPUT));const e=d.indexOf("Number");-1!==e&&d.splice(e,1);this.outputConnection.setCheck(d)}maybeBumpBlockOnFinishEdit(this)};
function maybeBumpBlockOnFinishEdit(d){d=d.outputConnection;const e=d.targetConnection;e&&!e.getConnectionChecker().canConnect(d,e,!1)&&(e.disconnect(),e.getSourceBlock().bumpNeighbours())}
Blockly.Blocks.text_join={category:"Text",helpUrl:Blockly.Msg.LANG_TEXT_JOIN_HELPURL,init:function(){this.setColour(Blockly.TEXT_CATEGORY_HUE);this.setOutput(!0,AI.BlockUtils.YailTypeToBlocklyType("text",AI.BlockUtils.OUTPUT));this.appendValueInput("ADD0").appendField(Blockly.Msg.LANG_TEXT_JOIN_TITLE_JOIN);this.appendValueInput("ADD1");this.setTooltip(Blockly.Msg.LANG_TEXT_JOIN_TOOLTIP);this.setMutator(new Blockly.icons.MutatorIcon(["text_join_item"],this));this.emptyInputName="EMPTY";this.repeatingInputName=
"ADD";this.itemCount_=2},mutationToDom:Blockly.mutationToDom,domToMutation:Blockly.domToMutation,decompose:function(d){return Blockly.decompose(d,"text_join_item",this)},compose:Blockly.compose,saveConnections:Blockly.saveConnections,addEmptyInput:function(){this.appendDummyInput(this.emptyInputName).appendField(Blockly.Msg.LANG_TEXT_JOIN_TITLE_JOIN)},addInput:function(d){var e=this.appendValueInput(this.repeatingInputName+d).setCheck(AI.BlockUtils.YailTypeToBlocklyType("text",AI.BlockUtils.INPUT));
0===d&&e.appendField(Blockly.Msg.LANG_TEXT_JOIN_TITLE_JOIN);return e},typeblock:[{translatedName:Blockly.Msg.LANG_TEXT_JOIN_TITLE_JOIN}]};AI.Blockly.Mixins.extend(Blockly.Blocks.text_join,AI.Blockly.Mixins.DynamicConnections);
Blockly.Blocks.text_join_item={init:function(){this.setColour(Blockly.TEXT_CATEGORY_HUE);this.appendDummyInput().appendField(Blockly.Msg.LANG_TEXT_JOIN_ITEM_TITLE_ITEM);this.setPreviousStatement(!0);this.setNextStatement(!0);this.setTooltip(Blockly.Msg.LANG_TEXT_JOIN_ITEM_TOOLTIP);this.contextMenu=!1}};
Blockly.Blocks.text_length={category:"Text",helpUrl:Blockly.Msg.LANG_TEXT_LENGTH_HELPURL,init:function(){this.setColour(Blockly.TEXT_CATEGORY_HUE);this.setOutput(!0,AI.BlockUtils.YailTypeToBlocklyType("number",AI.BlockUtils.OUTPUT));this.appendValueInput("VALUE").setCheck(AI.BlockUtils.YailTypeToBlocklyType("text",AI.BlockUtils.INPUT)).appendField(Blockly.Msg.LANG_TEXT_LENGTH_INPUT_LENGTH);this.setTooltip(Blockly.Msg.LANG_TEXT_LENGTH_TOOLTIP)},typeblock:[{translatedName:Blockly.Msg.LANG_TEXT_LENGTH_INPUT_LENGTH}]};
Blockly.Blocks.text_isEmpty={category:"Text",helpUrl:Blockly.Msg.LANG_TEXT_ISEMPTY_HELPURL,init:function(){this.setColour(Blockly.TEXT_CATEGORY_HUE);this.setOutput(!0,AI.BlockUtils.YailTypeToBlocklyType("boolean",AI.BlockUtils.OUTPUT));this.appendValueInput("VALUE").setCheck(AI.BlockUtils.YailTypeToBlocklyType("text",AI.BlockUtils.INPUT)).appendField(Blockly.Msg.LANG_TEXT_ISEMPTY_INPUT_ISEMPTY);this.setTooltip(Blockly.Msg.LANG_TEXT_ISEMPTY_TOOLTIP)},typeblock:[{translatedName:Blockly.Msg.LANG_TEXT_ISEMPTY_INPUT_ISEMPTY}]};
Blockly.Blocks.text_compare={category:"Text",helpUrl:Blockly.Msg.LANG_TEXT_COMPARE_HELPURL,init:function(){this.setColour(Blockly.TEXT_CATEGORY_HUE);this.setOutput(!0,AI.BlockUtils.YailTypeToBlocklyType("boolean",AI.BlockUtils.OUTPUT));this.appendValueInput("TEXT1").setCheck(AI.BlockUtils.YailTypeToBlocklyType("text",AI.BlockUtils.INPUT)).appendField(Blockly.Msg.LANG_TEXT_COMPARE_INPUT_COMPARE);this.appendValueInput("TEXT2").setCheck(AI.BlockUtils.YailTypeToBlocklyType("text",AI.BlockUtils.INPUT)).appendField(new Blockly.FieldDropdown(this.OPERATORS),
"OP");this.setInputsInline(!0);var d=this;this.setTooltip(function(){var e=d.getFieldValue("OP");return Blockly.Blocks.text_compare.TOOLTIPS()[e]})},typeblock:[{translatedName:Blockly.Msg.LANG_TEXT_COMPARE_INPUT_COMPARE+Blockly.Msg.LANG_TEXT_COMPARE_LT,dropDown:{titleName:"OP",value:"LT"}},{translatedName:Blockly.Msg.LANG_TEXT_COMPARE_INPUT_COMPARE+Blockly.Msg.LANG_TEXT_COMPARE_EQUAL,dropDown:{titleName:"OP",value:"EQUAL"}},{translatedName:Blockly.Msg.LANG_TEXT_COMPARE_INPUT_COMPARE+Blockly.Msg.LANG_TEXT_COMPARE_NEQ,
dropDown:{titleName:"OP",value:"NEQ"}},{translatedName:Blockly.Msg.LANG_TEXT_COMPARE_INPUT_COMPARE+Blockly.Msg.LANG_TEXT_COMPARE_GT,dropDown:{titleName:"OP",value:"GT"}}]};Blockly.Blocks.text_compare.OPERATORS=function(){return[[Blockly.Msg.LANG_TEXT_COMPARE_LT,"LT"],[Blockly.Msg.LANG_TEXT_COMPARE_EQUAL,"EQUAL"],[Blockly.Msg.LANG_TEXT_COMPARE_NEQ,"NEQ"],[Blockly.Msg.LANG_TEXT_COMPARE_GT,"GT"]]};
Blockly.Blocks.text_compare.TOOLTIPS=function(){return{LT:Blockly.Msg.LANG_TEXT_COMPARE_TOOLTIP_LT,EQUAL:Blockly.Msg.LANG_TEXT_COMPARE_TOOLTIP_EQUAL,NEQ:Blockly.Msg.LANG_TEXT_COMPARE_TOOLTIP_NEQ,GT:Blockly.Msg.LANG_TEXT_COMPARE_TOOLTIP_GT}};
Blockly.Blocks.text_trim={category:"Text",helpUrl:Blockly.Msg.LANG_TEXT_TRIM_HELPURL,init:function(){this.setColour(Blockly.TEXT_CATEGORY_HUE);this.setOutput(!0,AI.BlockUtils.YailTypeToBlocklyType("text",AI.BlockUtils.OUTPUT));this.appendValueInput("TEXT").setCheck(AI.BlockUtils.YailTypeToBlocklyType("text",AI.BlockUtils.INPUT)).appendField(Blockly.Msg.LANG_TEXT_TRIM_TITLE_TRIM);this.setTooltip(Blockly.Msg.LANG_TEXT_TRIM_TOOLTIP)},typeblock:[{translatedName:Blockly.Msg.LANG_TEXT_TRIM_TITLE_TRIM}]};
Blockly.Blocks.text_changeCase={category:"Text",helpUrl:function(){var d=this.getFieldValue("OP");return Blockly.Blocks.text_changeCase.HELPURLS()[d]},init:function(){this.setColour(Blockly.TEXT_CATEGORY_HUE);this.setOutput(!0,AI.BlockUtils.YailTypeToBlocklyType("text",AI.BlockUtils.OUTPUT));this.appendValueInput("TEXT").setCheck(AI.BlockUtils.YailTypeToBlocklyType("text",AI.BlockUtils.INPUT)).appendField(new Blockly.FieldDropdown(this.OPERATORS),"OP");var d=this;this.setTooltip(function(){var e=
d.getFieldValue("OP");return Blockly.Blocks.text_changeCase.TOOLTIPS()[e]})},typeblock:[{translatedName:Blockly.Msg.LANG_TEXT_CHANGECASE_OPERATOR_UPPERCASE,dropDown:{titleName:"OP",value:"UPCASE"}},{translatedName:Blockly.Msg.LANG_TEXT_CHANGECASE_OPERATOR_DOWNCASE,dropDown:{titleName:"OP",value:"DOWNCASE"}}]};Blockly.Blocks.text_changeCase.OPERATORS=function(){return[[Blockly.Msg.LANG_TEXT_CHANGECASE_OPERATOR_UPPERCASE,"UPCASE"],[Blockly.Msg.LANG_TEXT_CHANGECASE_OPERATOR_DOWNCASE,"DOWNCASE"]]};
Blockly.Blocks.text_changeCase.TOOLTIPS=function(){return{UPCASE:Blockly.Msg.LANG_TEXT_CHANGECASE_TOOLTIP_UPPERCASE,DOWNCASE:Blockly.Msg.LANG_TEXT_CHANGECASE_TOOLTIP_DOWNCASE}};Blockly.Blocks.text_changeCase.HELPURLS=function(){return{UPCASE:Blockly.Msg.LANG_TEXT_CHANGECASE_HELPURL_UPPERCASE,DOWNCASE:Blockly.Msg.LANG_TEXT_CHANGECASE_HELPURL_DOWNCASE}};
Blockly.Blocks.text_starts_at={category:"Text",helpUrl:Blockly.Msg.LANG_TEXT_STARTS_AT_HELPURL,init:function(){this.setColour(Blockly.TEXT_CATEGORY_HUE);this.setOutput(!0,AI.BlockUtils.YailTypeToBlocklyType("number",AI.BlockUtils.OUTPUT));var d=AI.BlockUtils.YailTypeToBlocklyType("text",AI.BlockUtils.INPUT);this.interpolateMsg(Blockly.Msg.LANG_TEXT_STARTS_AT_INPUT,["TEXT",d,Blockly.inputs.Align.RIGHT],["PIECE",d,Blockly.inputs.Align.RIGHT],Blockly.inputs.Align.RIGHT);this.setTooltip(Blockly.Msg.LANG_TEXT_STARTS_AT_TOOLTIP);
this.setInputsInline(!1)},typeblock:[{translatedName:Blockly.Msg.LANG_TEXT_STARTS_AT_INPUT_STARTS_AT}]};
Blockly.Blocks.text_contains={category:"Text",helpUrl:function(){return Blockly.Blocks.text_contains.HELPURLS()[this.getMode()]},init:function(){this.setColour(Blockly.TEXT_CATEGORY_HUE);var d=AI.BlockUtils,e=d.YailTypeToBlocklyType,h=new Blockly.FieldDropdown(Blockly.Blocks.text_contains.OPERATORS(),Blockly.Blocks.text_contains.adjustToMode.bind(this)),k=new Blockly.FieldLabel(Blockly.Msg.LANG_TEXT_CONTAINS_INPUT_PIECE);this.setOutput(!0,e("boolean",d.OUTPUT));this.interpolateMsg(Blockly.Msg.LANG_TEXT_CONTAINS_INPUT,
["OP",h],["TEXT",e("text",d.INPUT),Blockly.inputs.Align.RIGHT],["PIECE_TEXT",k],["PIECE",e("text",d.INPUT),Blockly.inputs.Align.RIGHT],Blockly.inputs.Align.RIGHT);this.setInputsInline(!1);this.setTooltip(function(){return Blockly.Blocks.text_contains.TOOLTIPS()[this.getMode()]}.bind(this))},domToMutation:function(d){d=d.getAttribute("mode");Blockly.Blocks.text_contains.adjustToMode.call(this,d)},mutationToDom:function(){var d=document.createElement("mutation");d.setAttribute("mode",this.getMode());
return d},getMode:function(){return this.getFieldValue("OP")},typeblock:[{translatedName:Blockly.Msg.LANG_TEXT_CONTAINS_OPERATOR_CONTAINS,dropDown:{titleName:"OP",value:"CONTAINS"}},{translatedName:Blockly.Msg.LANG_TEXT_CONTAINS_OPERATOR_CONTAINS_ANY,dropDown:{titleName:"OP",value:"CONTAINS_ANY"}},{translatedName:Blockly.Msg.LANG_TEXT_CONTAINS_OPERATOR_CONTAINS_ALL,dropDown:{titleName:"OP",value:"CONTAINS_ALL"}}]};
Blockly.Blocks.text_contains.adjustToMode=function(d){var e=AI.BlockUtils,h=e.YailTypeToBlocklyType;"CONTAINS"==d?(this.getInput("PIECE").setCheck(h("text",e.INPUT)),this.setFieldValue(Blockly.Msg.LANG_TEXT_CONTAINS_INPUT_PIECE,"PIECE_TEXT")):(this.getInput("PIECE").setCheck(h("list",e.INPUT)),this.setFieldValue(Blockly.Msg.LANG_TEXT_CONTAINS_INPUT_PIECE_LIST,"PIECE_TEXT"))};
Blockly.Blocks.text_contains.OPERATORS=function(){return[[Blockly.Msg.LANG_TEXT_CONTAINS_OPERATOR_CONTAINS,"CONTAINS"],[Blockly.Msg.LANG_TEXT_CONTAINS_OPERATOR_CONTAINS_ANY,"CONTAINS_ANY"],[Blockly.Msg.LANG_TEXT_CONTAINS_OPERATOR_CONTAINS_ALL,"CONTAINS_ALL"]]};Blockly.Blocks.text_contains.TOOLTIPS=function(){return{CONTAINS:Blockly.Msg.LANG_TEXT_CONTAINS_TOOLTIP_CONTAINS,CONTAINS_ANY:Blockly.Msg.LANG_TEXT_CONTAINS_TOOLTIP_CONTAINS_ANY,CONTAINS_ALL:Blockly.Msg.LANG_TEXT_CONTAINS_TOOLTIP_CONTAINS_ALL}};
Blockly.Blocks.text_contains.HELPURLS=function(){return{CONTAINS:Blockly.Msg.LANG_TEXT_CONTAINS_HELPURL_CONTAINS,CONTAINS_ANY:Blockly.Msg.LANG_TEXT_CONTAINS_HELPURL_CONTAINS_ANY,CONTAINS_ALL:Blockly.Msg.LANG_TEXT_CONTAINS_HELPURL_CONTAINS_ALL}};
Blockly.Blocks.text_split={category:"Text",helpUrl:function(){var d=this.getFieldValue("OP");return Blockly.Blocks.text_split.HELPURLS()[d]},init:function(){this.setColour(Blockly.TEXT_CATEGORY_HUE);this.setOutput(!0,AI.BlockUtils.YailTypeToBlocklyType("list",AI.BlockUtils.OUTPUT));this.appendValueInput("TEXT").setCheck(AI.BlockUtils.YailTypeToBlocklyType("text",AI.BlockUtils.INPUT)).appendField(new Blockly.FieldDropdown(this.OPERATORS,Blockly.Blocks.text_split.dropdown_onchange),"OP").appendField(Blockly.Msg.LANG_TEXT_SPLIT_INPUT_TEXT);
this.appendValueInput("AT").setCheck(AI.BlockUtils.YailTypeToBlocklyType("text",AI.BlockUtils.INPUT)).appendField(Blockly.Msg.LANG_TEXT_SPLIT_INPUT_AT,"ARG2_NAME").setAlign(Blockly.inputs.Align.RIGHT)},domToMutation:function(d){d=d.getAttribute("mode");Blockly.Blocks.text_split.adjustToMode(d,this)},mutationToDom:function(){var d=document.createElement("mutation"),e=this.getFieldValue("OP");d.setAttribute("mode",e);return d},typeblock:[{translatedName:Blockly.Msg.LANG_TEXT_SPLIT_OPERATOR_SPLIT,dropDown:{titleName:"OP",
value:"SPLIT"}},{translatedName:Blockly.Msg.LANG_TEXT_SPLIT_OPERATOR_SPLIT_AT_FIRST,dropDown:{titleName:"OP",value:"SPLITATFIRST"}},{translatedName:Blockly.Msg.LANG_TEXT_SPLIT_OPERATOR_SPLIT_AT_ANY,dropDown:{titleName:"OP",value:"SPLITATANY"}},{translatedName:Blockly.Msg.LANG_TEXT_SPLIT_OPERATOR_SPLIT_AT_FIRST_OF_ANY,dropDown:{titleName:"OP",value:"SPLITATFIRSTOFANY"}}]};
Blockly.Blocks.text_split.adjustToMode=function(d,e){if("SPLITATFIRST"==d||"SPLIT"==d)e.getInput("AT").setCheck(AI.BlockUtils.YailTypeToBlocklyType("text",AI.BlockUtils.INPUT)),e.setFieldValue(Blockly.Msg.LANG_TEXT_SPLIT_INPUT_AT,"ARG2_NAME");else if("SPLITATFIRSTOFANY"==d||"SPLITATANY"==d)e.getInput("AT").setCheck(AI.BlockUtils.YailTypeToBlocklyType("list",AI.BlockUtils.INPUT)),e.setFieldValue(Blockly.Msg.LANG_TEXT_SPLIT_INPUT_AT_LIST,"ARG2_NAME");e.setTooltip(Blockly.Blocks.text_split.TOOLTIPS()[d])};
Blockly.Blocks.text_split.dropdown_onchange=function(d){Blockly.Blocks.text_split.adjustToMode(d,this.getSourceBlock())};Blockly.Blocks.text_split.OPERATORS=function(){return[[Blockly.Msg.LANG_TEXT_SPLIT_OPERATOR_SPLIT,"SPLIT"],[Blockly.Msg.LANG_TEXT_SPLIT_OPERATOR_SPLIT_AT_FIRST,"SPLITATFIRST"],[Blockly.Msg.LANG_TEXT_SPLIT_OPERATOR_SPLIT_AT_ANY,"SPLITATANY"],[Blockly.Msg.LANG_TEXT_SPLIT_OPERATOR_SPLIT_AT_FIRST_OF_ANY,"SPLITATFIRSTOFANY"]]};
Blockly.Blocks.text_split.TOOLTIPS=function(){return{SPLITATFIRST:Blockly.Msg.LANG_TEXT_SPLIT_TOOLTIP_SPLIT_AT_FIRST,SPLITATFIRSTOFANY:Blockly.Msg.LANG_TEXT_SPLIT_TOOLTIP_SPLIT_AT_FIRST_OF_ANY,SPLIT:Blockly.Msg.LANG_TEXT_SPLIT_TOOLTIP_SPLIT,SPLITATANY:Blockly.Msg.LANG_TEXT_SPLIT_TOOLTIP_SPLIT_AT_ANY}};
Blockly.Blocks.text_split.HELPURLS=function(){return{SPLITATFIRST:Blockly.Msg.LANG_TEXT_SPLIT_HELPURL_SPLIT_AT_FIRST,SPLITATFIRSTOFANY:Blockly.Msg.LANG_TEXT_SPLIT_HELPURL_SPLIT_AT_FIRST_OF_ANY,SPLIT:Blockly.Msg.LANG_TEXT_SPLIT_HELPURL_SPLIT,SPLITATANY:Blockly.Msg.LANG_TEXT_SPLIT_HELPURL_SPLIT_AT_ANY}};
Blockly.Blocks.text_split_at_spaces={category:"Text",helpUrl:Blockly.Msg.LANG_TEXT_SPLIT_AT_SPACES_HELPURL,init:function(){this.setColour(Blockly.TEXT_CATEGORY_HUE);this.setOutput(!0,AI.BlockUtils.YailTypeToBlocklyType("list",AI.BlockUtils.OUTPUT));this.appendValueInput("TEXT").setCheck(AI.BlockUtils.YailTypeToBlocklyType("text",AI.BlockUtils.INPUT)).appendField(Blockly.Msg.LANG_TEXT_SPLIT_AT_SPACES_TITLE);this.setTooltip(Blockly.Msg.LANG_TEXT_SPLIT_AT_TOOLTIP)},typeblock:[{translatedName:Blockly.Msg.LANG_TEXT_SPLIT_AT_SPACES_TITLE}]};
Blockly.Blocks.text_segment={category:"Text",helpUrl:Blockly.Msg.LANG_TEXT_SEGMENT_HELPURL,init:function(){this.setColour(Blockly.TEXT_CATEGORY_HUE);this.setOutput(!0,AI.BlockUtils.YailTypeToBlocklyType("text",AI.BlockUtils.OUTPUT));var d=AI.BlockUtils.YailTypeToBlocklyType("text",AI.BlockUtils.INPUT),e=AI.BlockUtils.YailTypeToBlocklyType("number",AI.BlockUtils.INPUT);this.interpolateMsg(Blockly.Msg.LANG_TEXT_SEGMENT_INPUT,["TEXT",d,Blockly.inputs.Align.RIGHT],["START",e,Blockly.inputs.Align.RIGHT],
["LENGTH",e,Blockly.inputs.Align.RIGHT],Blockly.inputs.Align.RIGHT);this.setTooltip(Blockly.Msg.LANG_TEXT_SEGMENT_AT_TOOLTIP);this.setInputsInline(!1)},typeblock:[{translatedName:Blockly.Msg.LANG_TEXT_SEGMENT_TITLE_SEGMENT}]};
Blockly.Blocks.text_replace_all={category:"Text",helpUrl:Blockly.Msg.LANG_TEXT_REPLACE_ALL_HELPURL,init:function(){this.setColour(Blockly.TEXT_CATEGORY_HUE);this.setOutput(!0,AI.BlockUtils.YailTypeToBlocklyType("text",AI.BlockUtils.OUTPUT));var d=AI.BlockUtils.YailTypeToBlocklyType("text",AI.BlockUtils.INPUT);this.interpolateMsg(Blockly.Msg.LANG_TEXT_REPLACE_ALL_INPUT,["TEXT",d,Blockly.inputs.Align.RIGHT],["SEGMENT",d,Blockly.inputs.Align.RIGHT],["REPLACEMENT",d,Blockly.inputs.Align.RIGHT],Blockly.inputs.Align.RIGHT);
this.setTooltip(Blockly.Msg.LANG_TEXT_REPLACE_ALL_TOOLTIP);this.setInputsInline(!1)},typeblock:[{translatedName:Blockly.Msg.LANG_TEXT_REPLACE_ALL_TITLE_REPLACE_ALL}]};
Blockly.Blocks.obfuscated_text={category:"Text",helpUrl:Blockly.Msg.LANG_TEXT_TEXT_OBFUSCATE_HELPURL,init:function(){this.setColour(Blockly.TEXT_CATEGORY_HUE);var d=Blockly.Msg.LANG_TEXT_TEXT_OBFUSCATE+" "+Blockly.Msg.LANG_TEXT_TEXT_LEFT_QUOTE,e=new Blockly.FieldTextInput("",Blockly.Blocks.text.inputValidator);this.appendDummyInput().appendField(d).appendField(e,"TEXT").appendField(Blockly.Msg.LANG_TEXT_TEXT_RIGHT_QUOTE);this.setOutput(!0,AI.BlockUtils.YailTypeToBlocklyType("text",AI.BlockUtils.OUTPUT));
this.setTooltip(Blockly.Msg.LANG_TEXT_TEXT_OBFUSCATE_TOOLTIP);this.confounder=Math.random().toString(36).replace(/[^a-z]+/g,"").substr(0,8)},domToMutation:function(d){this.confounder=d.getAttribute("confounder")},mutationToDom:function(){var d=document.createElement("mutation");d.setAttribute("confounder",this.confounder);return d},onchange:Blockly.Blocks.text.onchange,typeblock:[{translatedName:Blockly.Msg.LANG_TEXT_TEXT_OBFUSCATE}]};
Blockly.Blocks.text_is_string={category:"Text",helpUrl:Blockly.Msg.LANG_TEXT_TEXT_IS_STRING_HELPURL,init:function(){this.setColour(Blockly.TEXT_CATEGORY_HUE);this.appendValueInput("ITEM").appendField(Blockly.Msg.LANG_TEXT_TEXT_IS_STRING_TITLE).appendField(Blockly.Msg.LANG_TEXT_TEXT_IS_STRING_INPUT_THING);this.setOutput(!0,AI.BlockUtils.YailTypeToBlocklyType("boolean",AI.BlockUtils.OUTPUT));this.setTooltip(Blockly.Msg.LANG_TEXT_TEXT_IS_STRING_TOOLTIP)},typeblock:[{translatedName:Blockly.Msg.LANG_TEXT_TEXT_IS_STRING_TITLE}]};
Blockly.Blocks.text_reverse={category:"Text",helpUrl:Blockly.Msg.LANG_TEXT_REVERSE_HELPURL,init:function(){this.setColour(Blockly.TEXT_CATEGORY_HUE);this.setOutput(!0,AI.BlockUtils.YailTypeToBlocklyType("text",AI.BlockUtils.OUTPUT));this.appendValueInput("VALUE").setCheck(AI.BlockUtils.YailTypeToBlocklyType("text",AI.BlockUtils.INPUT)).appendField(Blockly.Msg.LANG_TEXT_REVERSE_INPUT);this.setTooltip(Blockly.Msg.LANG_TEXT_REVERSE_TOOLTIP)},typeblock:[{translatedName:Blockly.Msg.LANG_TEXT_REVERSE_INPUT}]};
Blockly.Blocks.text_replace_mappings={category:"Text",helpUrl:function(){var d=this.getFieldValue("OP");return Blockly.Blocks.text_replace_mappings.HELPURLS()[d]},init:function(){this.setColour(Blockly.TEXT_CATEGORY_HUE);this.setOutput(!0,AI.BlockUtils.YailTypeToBlocklyType("text",AI.BlockUtils.OUTPUT));var d=AI.BlockUtils.YailTypeToBlocklyType("text",AI.BlockUtils.INPUT),e=AI.BlockUtils.YailTypeToBlocklyType("dictionary",AI.BlockUtils.INPUT);this.appendValueInput("MAPPINGS").setCheck(e).appendField(Blockly.Msg.LANG_TEXT_REPLACE_ALL_MAPPINGS_TITLE).setAlign(Blockly.inputs.Align.RIGHT);
this.appendValueInput("TEXT").setCheck(d).appendField(Blockly.Msg.LANG_TEXT_REPLACE_ALL_MAPPINGS_INPUT_TEXT).setAlign(Blockly.inputs.Align.RIGHT);this.appendDummyInput().appendField(Blockly.Msg.LANG_TEXT_REPLACE_ALL_MAPPINGS_INPUT_ORDER_PREFIX).appendField(new Blockly.FieldDropdown(this.OPERATORS,Blockly.Blocks.text_replace_mappings.onchange),"OP").appendField(Blockly.Msg.LANG_TEXT_REPLACE_ALL_MAPPINGS_INPUT_ORDER).setAlign(Blockly.inputs.Align.RIGHT);this.setInputsInline(!1);var h=this;this.setTooltip(function(){var k=
h.getFieldValue("OP");return Blockly.Blocks.text_replace_mappings.TOOLTIPS()[k]})},typeblock:[{translatedName:Blockly.Msg.LANG_TEXT_REPLACE_ALL_MAPPINGS_OPERATOR_LONGEST_STRING_FIRST,dropDown:{titleName:"OP",value:"LONGEST_STRING_FIRST"}},{translatedName:Blockly.Msg.LANG_TEXT_REPLACE_ALL_MAPPINGS_OPERATOR_DICTIONARY_ORDER,dropDown:{titleName:"OP",value:"DICTIONARY_ORDER"}}]};
Blockly.Blocks.text_replace_mappings.OPERATORS=function(){return[[Blockly.Msg.LANG_TEXT_REPLACE_ALL_MAPPINGS_OPERATOR_LONGEST_STRING_FIRST,"LONGEST_STRING_FIRST"],[Blockly.Msg.LANG_TEXT_REPLACE_ALL_MAPPINGS_OPERATOR_DICTIONARY_ORDER,"DICTIONARY_ORDER"]]};Blockly.Blocks.text_replace_mappings.TOOLTIPS=function(){return{LONGEST_STRING_FIRST:Blockly.Msg.LANG_TEXT_REPLACE_ALL_MAPPINGS_TOOLTIP_LONGEST_STRING_FIRST,DICTIONARY_ORDER:Blockly.Msg.LANG_TEXT_REPLACE_ALL_MAPPINGS_TOOLTIP_DICTIONARY_ORDER}};
Blockly.Blocks.text_replace_mappings.HELPURLS=function(){return{LONGEST_STRING_FIRST:Blockly.Msg.LANG_TEXT_REPLACE_ALL_MAPPINGS_HELPURL_LONGEST_STRING_FIRST,DICTIONARY_ORDER:Blockly.Msg.LANG_TEXT_REPLACE_ALL_MAPPINGS_HELPURL_DICTIONARY_ORDER}};/*

 Copyright 2021 Google LLC
 SPDX-License-Identifier: Apache-2.0
*/
AI.Blockly.Themes={};AI.Blockly.Themes.darkTheme={};Blockly.Themes.darkTheme=Blockly.Theme.defineTheme("dark",{base:Blockly.Themes.Classic,componentStyles:{workspaceBackgroundColour:"#1e1e1e",toolboxBackgroundColour:"blackBackground",toolboxForegroundColour:"#fff",flyoutBackgroundColour:"#252526",flyoutForegroundColour:"#ccc",flyoutOpacity:1,scrollbarColour:"#797979",insertionMarkerColour:"#fff",insertionMarkerOpacity:.3,scrollbarOpacity:.4,cursorColour:"#d0d0d0",blackBackground:"#333"}});/*

 @fileoverview Visual blocks editor for MIT App Inventor
 Initialize the blocks editor workspace.

 @author mckinney@mit.edu (Andrew F. McKinney)
 @author sharon@google.com (Sharon Perl)
 @author ewpatton@mit.edu (Evan W. Patton)
*/
AI.Blockly.BlocklyEditor={};Blockly.Flyout.prototype.dragAngleRange_=360;void 0===Blockly.BlocklyEditor&&(Blockly.BlocklyEditor={});Blockly.allWorkspaces={};Blockly.BlocklyEditor.HELP_IFRAME=null;
top.addEventListener("mousedown",function(d){if("IMG"===d.target.tagName&&"A"===d.target.parentElement.tagName&&"menu-help-item"===d.target.parentElement.className){d.stopPropagation();Blockly.BlocklyEditor.HELP_IFRAME&&(Blockly.BlocklyEditor.HELP_IFRAME.parentNode.removeChild(Blockly.BlocklyEditor.HELP_IFRAME),Blockly.BlocklyEditor.HELP_IFRAME=null);if(d.shiftKey||d.metaKey)return;d.preventDefault();var e=document.createElement("div");e.style.width="400px";e.style.height="300px";e.style.resize="both";
e.style.zIndex="99999";e.style.border="1px solid gray";e.style.boxSizing="border-box";e.style.position="absolute";e.style.top=d.clientY+"px";e.style.left=d.clientX+"px";e.style.backgroundColor="white";e.style.overflow="hidden";Blockly.BlocklyEditor.HELP_IFRAME=e;var h=document.createElement("iframe");h.src=d.target.parentElement.href;h.style.width="100%";h.style.height="100%";h.style.border="none";e.appendChild(h);Blockly.WidgetDiv.show(Blockly.BlocklyEditor,Blockly.common.getMainWorkspace().options.rtl,
function(){Blockly.BlocklyEditor.HELP_IFRAME.parentNode.removeChild(Blockly.BlocklyEditor.HELP_IFRAME);Blockly.BlocklyEditor.HELP_IFRAME=null});top.document.body.appendChild(e)}return!0},!0);
Blockly.BlocklyEditor.makeMenuItemWithHelp=function(d,e){var h=document.createElement("span"),k=document.createElement("a"),m=document.createElement("img");m.src="/static/images/help.png";k.href=e;k.target="_blank";k.className="menu-help-item";k.style.position="absolute";k.addEventListener("click",function(p){p.shiftKey||p.metaKey||p.preventDefault()});k.appendChild(m);h.appendChild(document.createTextNode(d));h.appendChild(k);return h};
function unboundVariableHandler(d,e){var h=Blockly.LexicalVariable.freeVariables(d);h=h.toList();if(0==h.length)try{AI.Yail.forRepl=!0,Blockly.ReplMgr.putYail(e,d)}finally{AI.Yail.forRepl=!1}else{var k="<form onsubmit='return false;'>"+Blockly.Msg.DIALOG_ENTER_VALUES+"<br>",m;for(m in h)k+=h[m]+" = <input type=text name="+h[m]+"><br>";var p=new Blockly.Util.Dialog(Blockly.Msg.DIALOG_UNBOUND_VAR,k+"</form>",Blockly.Msg.DO_IT,!1,Blockly.Msg.REPL_CANCEL,10,function(t){if(t==Blockly.Msg.DO_IT){t="(let (";
for(var q in h)t+="($"+h[q]+" "+AI.Yail.quotifyForREPL(document.querySelector('input[name="'+h[q]+'"]').value)+") ";t+=")"+e+")";try{AI.Yail.forRepl=!0,Blockly.ReplMgr.putYail(t,d)}finally{AI.Yail.forRepl=!1}}p.hide()})}}AI.Blockly.ContextMenuItems={};
AI.Blockly.ContextMenuItems.registerExportBlockOption=function(){const d={displayText:Blockly.BlocklyEditor.makeMenuItemWithHelp(Blockly.Msg.DOWNLOAD_BLOCKS_AS_PNG,"/reference/other/download-pngs.html"),callback:function(e){Blockly.exportBlockAsPng(e.block)},preconditionFn:function(e){return e.block.workspace.isFlyout?"hidden":"enabled"},weight:100,id:"appinventor_export_block",scopeType:Blockly.ContextMenuRegistry.ScopeType.BLOCK};Blockly.ContextMenuRegistry.registry.register(d)};
AI.Blockly.ContextMenuItems.registerDoItOption=function(){Blockly.ContextMenuRegistry.registry.register({displayText:Blockly.Msg.DO_IT,callback:function(d){d=d.block;if(top.ReplState.state!==Blockly.ReplMgr.rsState.CONNECTED){const e=new Blockly.Util.Dialog(Blockly.Msg.CAN_NOT_DO_IT,Blockly.Msg.CONNECT_TO_DO_IT,Blockly.Msg.REPL_OK,!1,null,1,function(){e.hide()})}else{let e;try{AI.Yail.forRepl=!0,e=AI.Yail.blockToCode1(d)}finally{AI.Yail.forRepl=!1}unboundVariableHandler(d,e instanceof Array?e[0]:
e)}},preconditionFn:function(d){if(d.block.workspace.isFlyout)return"hidden";d=d.block;return top.ReplState.state===Blockly.ReplMgr.rsState.CONNECTED&&d.isEnabled()?"enabled":"disabled"},weight:100,id:"appinventor_doit",scopeType:Blockly.ContextMenuRegistry.ScopeType.BLOCK})};
AI.Blockly.ContextMenuItems.RegisterClearDoItOption=function(){Blockly.ContextMenuRegistry.registry.register({displayText:Blockly.Msg.CLEAR_DO_IT_ERROR,callback:function(d){d=d.block;d.replError=null;Blockly.common.getMainWorkspace().getWarningHandler().checkErrors(d)},preconditionFn:function(d){return d.block.replError?"enabled":"hidden"},weight:100,id:"appinventor_clear_doit",scopeType:Blockly.ContextMenuRegistry.ScopeType.BLOCK})};
AI.Blockly.ContextMenuItems.registerGenerateYailOption=function(){Blockly.ContextMenuRegistry.registry.register({displayText:Blockly.Msg.GENERATE_YAIL,callback:function(d){d=d.block;const e=AI.Yail.blockToCode1(d);d.setCommentText(e instanceof Array?e[0]:e)},preconditionFn:function(d){return d.block.workspace.isFlyout?"hidden":window.parent.BlocklyPanel_checkIsAdmin()?"enabled":"hidden"},weight:100,id:"appinventor_generate_yail",scopeType:Blockly.ContextMenuRegistry.ScopeType.BLOCK})};
AI.Blockly.ContextMenuItems.registerAddToBackpackOption=function(){Blockly.ContextMenuRegistry.registry.register({displayText:function(d){return Blockly.Msg.COPY_TO_BACKPACK+" ("+d.block.workspace.getBackpack().getCount()+")"},callback:function(d){const e=top.blockSelectionWeakMap,h=d.block.workspace,k=h.getBackpack(),m=[];e?e.get(h).forEach(p=>{p=h.getBlockById(p);m.push(p)}):m.push(d.block);m.forEach(p=>{p.isDeletable&&k.addToBackpack(p)})},preconditionFn:function(d){return d.block.workspace.hasBackpack()?
d.block.isEnabled()?"enabled":"disabled":"hidden"},weight:100,id:"appinventor_add_to_backpack",scopeType:Blockly.ContextMenuRegistry.ScopeType.BLOCK})};
AI.Blockly.ContextMenuItems.registerExportBlocksOption=function(){Blockly.ContextMenuRegistry.registry.register({id:"appinventor_export_blocks",scopeType:Blockly.ContextMenuRegistry.ScopeType.WORKSPACE,preconditionFn:function(d){return d.workspace.getAllBlocks().length?"enabled":"hidden"},displayText:Blockly.Msg.EXPORT_IMAGE,callback:function(){AI.Blockly.ExportBlocksImage.onclickExportBlocks(Blockly.common.getMainWorkspace().getMetrics())},weight:100})};
AI.Blockly.ContextMenuItems.registerWorkspaceControlsOption=function(){Blockly.ContextMenuRegistry.registry.register({id:"appinventor_workspaceControls",scopeType:Blockly.ContextMenuRegistry.ScopeType.WORKSPACE,preconditionFn:function(){return"enabled"},displayText:function(d){return d.workspace.chromeHidden?Blockly.Msg.SHOW:Blockly.Msg.HIDE},callback:function(d){let e=d.workspace.chromeHidden?"block":"none";d.workspace.backpack_.svgGroup_.style.display=e;d.workspace.trashcan.svgGroup.style.display=
e;d.workspace.zoomControls_.svgGroup.style.display=e;d.workspace.warningIndicator_.svgGroup_.style.display=e;d.workspace.chromeHidden=!d.workspace.chromeHidden},weight:100})};
AI.Blockly.ContextMenuItems.registerResetArrangementOptions=function(){function d(h){return function(k){try{h.call(this,k)}finally{k.workspace&&k.workspace.resetArrangements()}}}var e=Blockly.ContextMenuRegistry.registry.getItem("collapseWorkspace");e.callback=d(e.callback);e=Blockly.ContextMenuRegistry.registry.getItem("expandWorkspace");e.callback=d(e.callback)};
AI.Blockly.ContextMenuItems.registerArrangeOptions=function(){function d(t){if("Variables"==t.category)return"a,"+t.type+","+t.getVars().join(",");if("Procedures"===t.category)return 0===t.type.indexOf("procedures_def")?"b,a:"+(t.getFieldValue("NAME")||t.getFieldValue("PROCNAME")||t.category):"b,b:"+(t.getFieldValue("NAME")||t.getFieldValue("PROCNAME")||t.category);if("Component"==t.category){let q=t.type+","+t.typeName+","+(t.isGeneric?"!GENERIC!":t.instanceName)+",";q="component_event"==t.type?
q+t.eventName:"component_method"==t.type?q+t.methodName:"component_set_get"==t.type?q+(t.setOrGet+t.propertyName):q+".Component";return"c,"+q}return"d,"+t.type}function e(t,q){let y=t.match(/^(.*?)([0-9]+)$/i),I=q.match(/^(.*?)([0-9]+)$/i);return y&&I?y[1]<I[1]?-1:y[1]>I[1]?1:parseInt(y[2])-parseInt(I[2]):t.localeCompare(q,void 0,{numeric:!0})}function h(t,q){var y=d(t).toLowerCase(),I=d(q).toLowerCase();if(t.category!=q.category)return y.localeCompare(I,void 0,{numeric:!0});if(t.category==q.category&&
"Component"!=t.category)return y=y.substr(2),I=I.substr(2),y=e(y,I),"Variables"==t.category&&t.type==q.type&&("global_declaration"==t.type?(t=t.getSvgRoot().textContent,t=t.substring(17,t.length-2),q=q.getSvgRoot().textContent,q=q.substring(17,q.length-2),y=e(t,q)):(t=t.fieldVar_.text_,q=q.fieldVar_.text_,y=t.includes("global")&&q.includes("global")?e(t.substring(6),q.substring(6)):e(t,q))),y;if("Component"==t.category&&"Component"==q.category&&t.eventName&&q.eventName)return t.typeName==q.typeName?
t.instanceName==q.instanceName?0:t.instanceName?q.instanceName?e(t.instanceName,q.instanceName):1:-1:y.localeCompare(I,void 0,{numeric:!0});if("Component"==t.category&&"Component"==q.category)return y=",2",t.isGeneric&&(y=",1"),I=",2",q.isGeneric&&(I=",1"),y=(t.type+y).localeCompare(q.type+I,void 0,{numeric:!0}),0===y&&(y=e(t.typeName,q.typeName)),0===y&&(t.instanceName&&q.instanceName&&e(t.instanceName,q.instanceName),q=q.propertyName||q.methodName,y=(t.propertyName||t.methodName).toLowerCase().localeCompare(q.toLowerCase(),
void 0,{numeric:!0})),y}function k(t,q,y){Blockly.Events.setGroup(!0);var I=t.id;Blockly.Events.fire(new AI.Events.StartArrangeBlocks(I));t.arranged_type_=q;t.arranged_position_=y;t.arranged_latest_position_=y;t.arrange_blocks_event_group_=Blockly.Events.getGroup();I=new AI.Events.EndArrangeBlocks(I,q,y);let L=t.getTopBlocks(!1);t.arranged_type_===AI.Blockly.BLKS_CATEGORY&&L.sort(h);var Q=t.getMetrics();let da=t.getGrid().getSpacing(),N=1/da,H=t.getGrid().shouldSnap()?function(W){return(Math.ceil(W*
N)-.5)*da}:function(W){return W},K=H(Q.viewLeft+5),C=H(Q.viewTop+5),E=K,F=C,P=K+Q.viewWidth/t.scale;Q=C+Q.viewHeight/t.scale;let ha=0,ea=0;for(let W=0,ka=L.length;W<ka;W++){let Z=L[W],ca=Z.getRelativeToSurfaceXY();var aa=Z.getHeightWidth();let ia=aa.height;aa=aa.width;switch(y){case AI.Blockly.BLKS_HORIZONTAL:E<P?(Z.moveBy(E-ca.x,F-ca.y),Blockly.common.setSelected(Z),E=H(E+aa+25),ia>ha&&(ha=ia)):(F=H(F+ha+25),ha=ia,E=K,Z.moveBy(E-ca.x,F-ca.y),Blockly.common.setSelected(Z),E=H(E+aa+25));break;case AI.Blockly.BLKS_VERTICAL:F<
Q?(Z.moveBy(E-ca.x,F-ca.y),Blockly.common.setSelected(Z),F=H(F+ia+25),aa>ea&&(ea=aa)):(E=H(E+ea+25),ea=aa,F=C,Z.moveBy(E-ca.x,F-ca.y),Blockly.common.setSelected(Z),F=H(F+ia+25))}}Blockly.Events.fire(I);Blockly.Events.setGroup(!1);setTimeout(function(){t.arranged_type_=q;t.arranged_latest_position_=y;t.arranged_position_=y})}let m={id:"appinventor_arrange_horizontal",scopeType:Blockly.ContextMenuRegistry.ScopeType.WORKSPACE,preconditionFn:function(t){return t.workspace.arranged_position_!==AI.Blockly.BLKS_HORIZONTAL?
"enabled":"hidden"},displayText:Blockly.Msg.ARRANGE_H,callback:function(t,q){k(t.workspace,q||t.workspace.arranged_type_,AI.Blockly.BLKS_HORIZONTAL)},weight:100};Blockly.ContextMenuRegistry.registry.register(m);let p={id:"appinventor_arrange_vertical",scopeType:Blockly.ContextMenuRegistry.ScopeType.WORKSPACE,preconditionFn:function(t){return t.workspace.arranged_position_!==AI.Blockly.BLKS_VERTICAL?"enabled":"hidden"},displayText:Blockly.Msg.ARRANGE_V,callback:function(t,q){k(t.workspace,q||t.workspace.arranged_type_,
AI.Blockly.BLKS_VERTICAL)},weight:100};Blockly.ContextMenuRegistry.registry.register(p);Blockly.ContextMenuRegistry.registry.register({id:"appinventor_sort_category",scopeType:Blockly.ContextMenuRegistry.ScopeType.WORKSPACE,preconditionFn:function(t){return t.workspace.arranged_type_!==AI.Blockly.BLKS_CATEGORY?"enabled":"hidden"},displayText:Blockly.Msg.SORT_C,callback:function(t){var q=AI.Blockly.BLKS_CATEGORY;null===t.workspace.arranged_latest_position_||t.workspace.arranged_latest_position_===
AI.Blockly.BLKS_HORIZONTAL?m.callback(t,q):t.workspace.arranged_latest_position_===AI.Blockly.BLKS_VERTICAL&&p.callback(t,q)},weight:100})};
AI.Blockly.ContextMenuItems.registerEnableDisableAllBlocksOption=function(){Blockly.ContextMenuRegistry.registry.register({id:"appinventor_enable_all_blocks",scopeType:Blockly.ContextMenuRegistry.ScopeType.WORKSPACE,preconditionFn:function(){return"enabled"},displayText:Blockly.Msg.ENABLE_ALL_BLOCKS,callback:function(d){d=d.workspace.getAllBlocks();try{Blockly.Events.setGroup(!0),d.forEach(e=>e.setEnabled(!0))}finally{Blockly.Events.setGroup(!1)}},weight:100});Blockly.ContextMenuRegistry.registry.register({id:"appinventor_disable_all_blocks",
scopeType:Blockly.ContextMenuRegistry.ScopeType.WORKSPACE,preconditionFn:function(){return"enabled"},displayText:Blockly.Msg.DISABLE_ALL_BLOCKS,callback:function(d){d=d.workspace.getAllBlocks();try{Blockly.Events.setGroup(!0),d.forEach(e=>e.setEnabled(!1))}finally{Blockly.Events.setGroup(!1)}},weight:100})};
AI.Blockly.ContextMenuItems.registerCommentOptions=function(){Blockly.ContextMenuRegistry.registry.register({id:"appinventor_show_all_comments",scopeType:Blockly.ContextMenuRegistry.ScopeType.WORKSPACE,preconditionFn:function(){return"enabled"},displayText:Blockly.Msg.SHOW_ALL_COMMENTS,callback:function(d){d=d.workspace.getAllBlocks();try{Blockly.Events.setGroup(!0),d.forEach(e=>{let h=e.getIcon(Blockly.icons.CommentIcon.TYPE);h&&!e.isCollapsed()&&h.setBubbleVisible(!0)})}finally{Blockly.Events.setGroup(!1)}},
weight:100});Blockly.ContextMenuRegistry.registry.register({id:"appinventor_hide_all_comments",scopeType:Blockly.ContextMenuRegistry.ScopeType.WORKSPACE,preconditionFn:function(){return"enabled"},displayText:Blockly.Msg.HIDE_ALL_COMMENTS,callback:function(d){d=d.workspace.getAllBlocks();try{Blockly.Events.setGroup(!0),d.forEach(e=>{let h=e.getIcon(Blockly.icons.CommentIcon.TYPE);h&&!e.isCollapsed()&&h.setBubbleVisible(!1)})}finally{Blockly.Events.setGroup(!1)}},weight:100})};
AI.Blockly.ContextMenuItems.registerBackpackOptions=function(){Blockly.ContextMenuRegistry.registry.register({id:"appinventor_copy_all_blocks",scopeType:Blockly.ContextMenuRegistry.ScopeType.WORKSPACE,preconditionFn:function(d){return d.workspace.hasBackpack()?"enabled":"hidden"},displayText:Blockly.Msg.COPY_ALLBLOCKS,callback:function(d){d.workspace.hasBackpack()&&d.workspace.getBackpack().addAllToBackpack()},weight:100});Blockly.ContextMenuRegistry.registry.register({id:"appinventor_retrieve_from_backpack",
scopeType:Blockly.ContextMenuRegistry.ScopeType.WORKSPACE,preconditionFn:function(d){return d.workspace.hasBackpack()?"enabled":"hidden"},displayText:function(d){return Blockly.Msg.BACKPACK_GET+" ("+d.workspace.getBackpack().getCount()+")"},callback:function(d){d.workspace.hasBackpack()&&d.workspace.getBackpack().pasteBackpack()},weight:100})};
AI.Blockly.ContextMenuItems.registerGridOptions=function(){Blockly.ContextMenuRegistry.registry.register({id:"appinventor_grid",scopeType:Blockly.ContextMenuRegistry.ScopeType.WORKSPACE,preconditionFn:function(){return"enabled"},displayText:function(d){return d.workspace.options.gridOptions.enabled?Blockly.Msg.DISABLE_GRID:Blockly.Msg.ENABLE_GRID},callback:function(d){let e=d.workspace.options.gridOptions;const h=d.workspace.options.gridPattern;e.enabled=!e.enabled;d.workspace.getGrid().setSnapToGrid(e.enabled&&
top.BlocklyPanel_getSnapEnabled());e.enabled?Blockly.common.getMainWorkspace().svgBackground_.setAttribute("style","fill: url(#"+h.id+");"):(d=Blockly.common.getMainWorkspace().getTheme().componentStyles.workspaceBackgroundColour??"white",Blockly.common.getMainWorkspace().svgBackground_.setAttribute("style",`fill: ${d};`));top.BlocklyPanel_setGridEnabled&&(top.BlocklyPanel_setGridEnabled(e.enabled),top.BlocklyPanel_saveUserSettings())},weight:100});Blockly.ContextMenuRegistry.registry.register({id:"appinventor_enable_snap",
scopeType:Blockly.ContextMenuRegistry.ScopeType.WORKSPACE,preconditionFn:function(d){return d.workspace.options.gridOptions.enabled?"enabled":"hidden"},displayText:function(d){return d.workspace.getGrid().shouldSnap()?Blockly.Msg.DISABLE_SNAPPING:Blockly.Msg.ENABLE_SNAPPING},callback:function(d){d=d.workspace.getGrid();d.setSnapToGrid(!d.shouldSnap());top.BlocklyPanel_setSnapEnabled&&(top.BlocklyPanel_setSnapEnabled(d.shouldSnap()),top.BlocklyPanel_saveUserSettings())},weight:100})};
AI.Blockly.ContextMenuItems.registerHelpOption=function(){};
AI.Blockly.ContextMenuItems.registerClearUnusedBlocksOption=function(){Blockly.ContextMenuRegistry.registry.register({id:"appinventor_clear_unused_blocks",scopeType:Blockly.ContextMenuRegistry.ScopeType.WORKSPACE,preconditionFn:function(d){return d.workspace.getAllBlocks().length?"enabled":"hidden"},displayText:Blockly.Msg.REMOVE_UNUSED_BLOCKS,callback:function(d){let e=[];d.workspace.getTopBlocks().forEach(h=>{(h.previousConnection||h.outputConnection)&&e.push(h)});if(0!==e.length)try{Blockly.Events.setGroup(!0),
d.workspace.getAudioManager().play("delete"),e.forEach(h=>{h.dispose(!1)})}finally{Blockly.Events.setGroup(!1)}},weight:100})};
AI.Blockly.ContextMenuItems.registerAll=function(){AI.Blockly.ContextMenuItems.registerResetArrangementOptions();AI.Blockly.ContextMenuItems.registerExportBlocksOption();AI.Blockly.ContextMenuItems.registerWorkspaceControlsOption();AI.Blockly.ContextMenuItems.registerArrangeOptions();AI.Blockly.ContextMenuItems.registerEnableDisableAllBlocksOption();AI.Blockly.ContextMenuItems.registerCommentOptions();AI.Blockly.ContextMenuItems.registerBackpackOptions();AI.Blockly.ContextMenuItems.registerGridOptions();
AI.Blockly.ContextMenuItems.registerHelpOption();AI.Blockly.ContextMenuItems.registerClearUnusedBlocksOption();AI.Blockly.ContextMenuItems.registerGenerateYailOption();AI.Blockly.ContextMenuItems.registerExportBlockOption();AI.Blockly.ContextMenuItems.registerDoItOption();AI.Blockly.ContextMenuItems.RegisterClearDoItOption();Blockly.ContextMenuRegistry.registry.getItem("blockHelp").weight=1E3};AI.Blockly.ContextMenuItems.registerAll();Blockly.BlocklyEditor.cssRegistered=!1;
Blockly.BlocklyEditor.create=function(d,e,h,k){if(!Blockly.BlocklyEditor.cssRegistered){Blockly.BlocklyEditor.cssRegistered=!0;try{Blockly.Css.register("\n.blocklyZoom:hover, .blocklyTrash:hover, .blocklyMultiselect:hover { cursor: pointer; }\n.blocklyZoom>image, .blocklyZoom>image:hover { opacity: 1.0; }\n.blocklyMultiselect>image, .blocklyMultiselect>image:hover { opacity: 1.0; }\n")}catch(t){}}var m={toolbox:{kind:"flyoutToolbox",contents:[]},readOnly:h,rtl:k,collapse:!0,scrollbars:!0,trashcan:!0,
comments:!0,disable:!0,media:"./static/media/",grid:{spacing:"20",length:"5",snap:!1,colour:"#ccc"},zoom:{controls:!0,wheel:!0,scaleSpeed:1.1,maxScale:3,minScale:.1},plugins:{blockDragger:ScrollBlockDragger,metricsManager:ScrollMetricsManager,connectionPreviewer:decoratePreviewer(Blockly.InsertionMarkerPreviewer),[Blockly.registry.Type.CONNECTION_CHECKER]:"CustomizableConnectionChecker"},useDoubleClick:!0,bumpNeighbours:!0,multiselectIcon:{hideIcon:!1,enabledIcon:"static/images/select.svg",disabledIcon:"static/images/unselect.svg"},
multiselectCopyPaste:{crossTab:!0,menu:!0},renderer:"geras2_renderer"},p=Blockly.inject(d,m);AI.Blockly.multiselect=Multiselect;(new AI.Blockly.multiselect(p)).init(m);LexicalVariablesPlugin.init(p);(new WorkspaceSearch(p)).init();(new ScrollOptions(p)).init({edgeScrollOptions:{oversizeBlockMargin:0,oversizeBlockThreshold:0,slowBlockSpeed:.15}});Blockly.allWorkspaces[e]=p;p.formName=e;p.screenList_=[];p.assetList_=[];p.componentDb_=new Blockly.ComponentDatabase;p.procedureDb_=new Blockly.ProcedureDatabase(p);
p.variableDb_=new Blockly.VariableDatabase;p.blocksNeedingRendering=[];p.addWarningHandler();h||(d=AI.Blockly.TypeBlockPluginAdapter.create(p),p.typeBlock_=new TypeBlocking(p),p.typeBlock_.needsReload=d.needsReload,p.typeBlock_.init({matcher:d.matcher,optionGenerator:d.optionGenerator,workspaceStateTracker:{get needsReload(){return!0},invalidate(){},dispose(){}},connectionConfig:{strategies:[d.connectionStrategy]},enablePatternRecognition:!1,inputPositioning:{mode:"fixed",fixedPosition:{x:10,y:10}}}),
p.addChangeListener(function(){if(this.workspace&&!this.workspace.isDragging()){var t=p.getMetrics(),q=t.viewLeft+t.absoluteLeft,y=t.viewTop+t.absoluteTop;if(t.contentTop<y||t.contentTop+t.contentHeight>t.viewHeight+y||t.contentLeft<(m.RTL?t.viewLeft:q)||t.contentLeft+t.contentWidth>(m.RTL?t.viewWidth:t.viewWidth+q))for(var I=p.getTopBlocks(!1),L=0,Q;Q=I[L];L++){var da=Q.getRelativeToSurfaceXY(),N=Q.getHeightWidth(),H=y+25-N.height-da.y;0<H&&Q.moveBy(0,H);H=y+t.viewHeight-25-da.y;0>H&&Q.moveBy(0,
H);H=25+q-da.x-(m.RTL?0:N.width);0<H&&Q.moveBy(H,0);da=q+t.viewWidth-25-da.x+(m.RTL?N.width:0);0>da&&Q.moveBy(da,0)}}}));p.addChangeListener(function(t){t.type==Blockly.Events.BLOCK_MOVE&&t.newParentId!==t.oldParentId&&(t=p.getBlockById(t.blockId))&&t.getDescendants().forEach(function(q){if("lexical_variable_get"===q.type||"lexical_variable_set"===q.type){const y=q.getField("VAR");y.getOptions(!1);y.setValue(y.getValue());q.queueRender()}})});p.drawer_=new Blockly.Drawer(p,{scrollbars:!0});p.flyout_=
p.getFlyout();p.addWarningIndicator();p.addBackpack();Blockly.browserEvents.bind(p.getSvgGroup(),"focus",p,p.markFocused);p.flyout_.scrollbar_&&p.flyout_.scrollbar_.setContainerVisible(!1);p.backpack_.flyout_.scrollbar_&&p.backpack_.flyout_.scrollbar_.setContainerVisible(!1);p.flydown_.scrollbar_&&p.flydown_.scrollbar_.setContainerVisible(!1);p.injecting=!1;p.injected=!0;p.notYetRendered=!0;return p};
AI.inject=function(d,e,h=!1){Blockly.common.setMainWorkspace(e);h&&Blockly.common.getMainWorkspace().setTheme(Blockly.Themes.darkTheme);e.fireChangeListener(new AI.Events.ScreenSwitch(e.projectId,e.formName));d=top.BlocklyPanel_getGridEnabled&&top.BlocklyPanel_getGridEnabled();h=top.BlocklyPanel_getSnapEnabled&&top.BlocklyPanel_getSnapEnabled();e.setGridSettings(d,h);for(const k of e.blocksNeedingRendering)e.getWarningHandler().checkErrors(k),k.render();e.blocksNeedingRendering.splice(0);e.resizeContents();
Blockly.common.svgResize(e);e.notYetRendered&&(e.notYetRendered=!1,e.scrollCenter())};window.Blockly=Blockly;top.Blockly=Blockly;window.AI=AI;top.AI=AI;top.document.addEventListener("mousedown",function(d){if(d.target){for(d=d.target;d;){var e=d.classList;if(e.contains("blocklyWidgetDiv")||e.contains("blocklySvg")||e.contains("gwt-TreeItem")||e.contains("blocklyDropDownDiv"))return;d=d.parentElement}Blockly.common.getMainWorkspace()&&Blockly.hideChaff()}},!1);
//# sourceMappingURL=/static/js/blockly-all.js.map
