From 0759b62f53e8747cb3dc96aed0612aeec2706eea Mon Sep 17 00:00:00 2001 From: GitHub Action Date: Mon, 13 Jan 2025 04:59:52 +0000 Subject: [PATCH] Update production distribution on Mon Jan 13 04:59:52 UTC 2025 --- dist/csc1030_problems.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dist/csc1030_problems.js b/dist/csc1030_problems.js index 26431b0..35efee0 100644 --- a/dist/csc1030_problems.js +++ b/dist/csc1030_problems.js @@ -1 +1 @@ -"use strict";var _createClass=function(){function e(e,t){for(var n=0;nt.viewLeft+t.viewWidth||n.topt.viewTop+t.viewHeight}))}function u(e){var t=T2C.MSG.currentLanguage===T2C.MSG.PY?"Python":"JavaScript";s(e).filter((function(e){return e.getParent()&&!e.nextConnection&&!e.isCollapsed()})).slice().forEach((function(n){if(!n.isDisposed()){var o=a(e,"code_expression");c(o,Blockly[t].blockToCode(n)[0]||Blockly[t].blockToCode(n),"EXP"),o.setCollapsed(!0),n.getParent().getInputWithBlock(n).connection.connect(o.outputConnection),n.dispose(!0)}})),i(e),s(e).length>0&&e.zoomToFit()}function c(e,t,n){if(n){var o=e.workspace,i=t;e.type.toLowerCase().startsWith("variables_")&&"VAR"===n&&(i=-1===o.getAllVariableNames().indexOf(t)?o.createVariable(t).getId():o.getVariable(t).getId()),e.setFieldValue(i,n)}else console.warn("Ignoring request to set field value to",t," of ",e,"because no field name was given")}function g(e){if(!e)return null;for(var t=e.getParent();t&&!t.previousConnection;)t=t.getParent();return t}function d(e){for(var t=e;!t.nextConnection&&t.getParent();)t=t.getParent();for(;t.getNextBlock();)t=t.getNextBlock();return t}function h(e,t,n){var o=e.getParent(),i=null,r=null,a=-1,l=null;return e.inputList.forEach((function(e){e.fieldRow.forEach((function(e){t.getField(e.name)&&c(t,e.getValue(),e.name)}))})),o?(a=(r=(i=o.getInputWithBlock(e))?i.connection:o.nextConnection).targetConnection.type)===Blockly.OUTPUT_VALUE?r.connect(t.outputConnection):a===Blockly.PREVIOUS_STATEMENT&&(l=t.previousConnection):t.moveBy(e.getRelativeToSurfaceXY().x-t.getRelativeToSurfaceXY().x,e.getRelativeToSurfaceXY().y-t.getRelativeToSurfaceXY().y),e.getChildren().slice().forEach((function(n){if(e.getNextBlock()!==n){var o=e.getInputWithBlock(n),i=t.getInput(o.name);i&&(o=i.connection.connect(n.outputConnection))}else d(t).nextConnection&&d(t).nextConnection.connect(n.previousConnection)})),l&&r.connect(l),n&&e.dispose(),t}n.d(t,"j",(function(){return o})),n.d(t,"f",(function(){return i})),n.d(t,"i",(function(){return r})),n.d(t,"e",(function(){return a})),n.d(t,"d",(function(){return l})),n.d(t,"a",(function(){return u})),n.d(t,"h",(function(){return c})),n.d(t,"c",(function(){return g})),n.d(t,"b",(function(){return d})),n.d(t,"g",(function(){return h}))},function(module,__webpack_exports__,__webpack_require__){__webpack_require__.r(__webpack_exports__),__webpack_require__.d(__webpack_exports__,"getParseTree",(function(){return getParseTree})),__webpack_require__.d(__webpack_exports__,"handleParseTreeToBlocks",(function(){return handleParseTreeToBlocks})),__webpack_require__.d(__webpack_exports__,"parseAndConvertToBlocks",(function(){return parseAndConvertToBlocks})),__webpack_require__.d(__webpack_exports__,"workspaceToLanguageCode",(function(){return workspaceToLanguageCode})),__webpack_require__.d(__webpack_exports__,"workspaceToXML",(function(){return workspaceToXML}));var _grammar_js__WEBPACK_IMPORTED_MODULE_0__=__webpack_require__(6),_tokenizer_js__WEBPACK_IMPORTED_MODULE_1__=__webpack_require__(9),_parser_js__WEBPACK_IMPORTED_MODULE_2__=__webpack_require__(13),_parse_tree_block_connector_js__WEBPACK_IMPORTED_MODULE_3__=__webpack_require__(10),_block_interpretations_js__WEBPACK_IMPORTED_MODULE_4__=__webpack_require__(7),_block_evaluator_js__WEBPACK_IMPORTED_MODULE_5__=__webpack_require__(11),_block_generator_js__WEBPACK_IMPORTED_MODULE_6__=__webpack_require__(8),_block_converters_javascript_text_exact_js__WEBPACK_IMPORTED_MODULE_7__=__webpack_require__(12),_block_utility_functions_js__WEBPACK_IMPORTED_MODULE_8__=__webpack_require__(0);Blockly.COLLAPSE_CHARS=200;var isMobile=Blockly.utils.userAgent.MOBILE||Blockly.utils.userAgent.ANDROID||Blockly.utils.userAgent.IPAD,getParseTree=function(e){console.warn("Attempting to parse",e);var t=T2C.MSG&&T2C.MSG.currentLanguage===T2C.MSG.PY?e.replace(/[\r\n]+/g,";"):e,n=shared.parser.parseBottomUpCYK(t,shared.parseTreeBlockConnector)[0];return n&&console.log("Parse Tree:",n),n},handleParseTreeToBlocks=function(e,t){var n=!(arguments.length>2&&void 0!==arguments[2])||arguments[2],o=arguments.length>3&&void 0!==arguments[3]?arguments[3]:null;o=o||shared.workspace;var i=shared.evaluator.evaluate(e);console.log("Evaluation: ",i,t),t=t||Object(_block_utility_functions_js__WEBPACK_IMPORTED_MODULE_8__.e)(o);var r=Object(_block_generator_js__WEBPACK_IMPORTED_MODULE_6__.a)(i,t,n);return console.log(r),r},parseAndConvertToBlocks=function(e,t){if(console.warn(t.type,t),!this.isCollapsed()&&(e.updateAutocomplete&&e.updateAutocomplete(this.getFieldValue("EXP"),e.OPTIONS,e.shownOPTIONS,(function(e){return console.warn("Parsing Partial",e),shared.parser.parseBottomUpCYK(e,shared.parseTreeBlockConnector).length>0})),this.getFieldValue("AUTOCPLT")&&Object(_block_utility_functions_js__WEBPACK_IMPORTED_MODULE_8__.h)(this,this.getFieldValue("AUTOCPLT")+"\n","EXP"),e.editing&&(this.getFieldValue("EXP").endsWith("\r")||this.getFieldValue("EXP").endsWith("\n"))||e.editing&&"workspaceClick"===t.element)){var n=getParseTree(this.getFieldValue("EXP"));if(n){e.editing=!1;var o=handleParseTreeToBlocks(n,this,!1);shared.workspace.getAllBlocks().filter((function(e){return!e.getParent()&&("code_expression"===e.type||"code_statement"===e.type)})).forEach((function(e){return e.dispose()}));var i=shared.workspace.getAllBlocks().find((function(e){return"code_expression"===e.type||"code_statement"===e.type}));if(i)Object(_block_utility_functions_js__WEBPACK_IMPORTED_MODULE_8__.a)(shared.workspace),i=shared.workspace.getAllBlocks().find((function(e){return"code_expression"===e.type||"code_statement"===e.type})),isMobile||i.getField("EXP").showEditor_();else{console.warn("Replacing block",o);var r=Object(_block_utility_functions_js__WEBPACK_IMPORTED_MODULE_8__.b)(o),a=Object(_block_utility_functions_js__WEBPACK_IMPORTED_MODULE_8__.e)(shared.workspace,"code_statement");r.nextConnection&&Object(_block_utility_functions_js__WEBPACK_IMPORTED_MODULE_8__.i)(r,a),Object(_block_utility_functions_js__WEBPACK_IMPORTED_MODULE_8__.f)(shared.workspace),Object(_block_utility_functions_js__WEBPACK_IMPORTED_MODULE_8__.a)(shared.workspace),a=shared.workspace.getAllBlocks().find((function(e){return"code_statement"===e.type})),isMobile||a.getField("EXP").showEditor_()}}else e.editing&&"workspaceClick"===t.element&&alert("There seems to be a problem with the code you entered. Check that your spelling is correct, that you use lowercase and capital letters as required, that every open parenthesis ( has a matching closed one ), that you use quotation marks as needed, and other potential issues with syntax.")}};function varsToLets(e){var t=e.search(/^\s*var|[\r\n]\s*var/),n=e.indexOf("var",t)+4,o=e.indexOf(";",n),i=[],r=e;return-1!==t&&(i=e.substring(n,o).split(", "),r=e.substring(0,n-4)+e.substring(o+1)),i.forEach((function(e){r=r.replace("\n"+e+" = ","\nlet "+e+" = ")})),r.trim()}var workspaceToLanguageCode=function(e,t){var n=t===T2C.MSG.PY?"Python":"JavaScript";Blockly.Python.tempFinish=Blockly.Python.finish,Blockly.Python.finish=function(e){return e};var o=e.getAllBlocks(),i=o.map((function(e){return e.getCommentText()}));o.forEach((function(e){return e.setCommentText(null)}));var r=Blockly[n].workspaceToCode(e||Blockly.getMainWorkspace());return Blockly.Python.finish=Blockly.Python.tempFinish,o.forEach((function(e,t){return e.setCommentText(i[t])})),"Python"===n?r:varsToLets(r)},workspaceToXML=function(e){var t=Blockly.Xml.workspaceToDom(e||Blockly.getMainWorkspace());return Blockly.Xml.domToPrettyText(t)},shared=function(){var init=function(){window.addEventListener("DOMContentLoaded",(function(e){if(!document.getElementById("blockly-div").getAttribute("hasWorkspace")){document.getElementById("blockly-div").setAttribute("hasWorkspace",!0),shared.toolbox=document.getElementById("toolbox");var t={toolbox:toolbox,collapse:!0,comments:!1,disable:!1,maxBlocks:1/0,trashcan:!0,horizontalLayout:!0,toolboxPosition:"start",css:!0,media:"https://blockly-demo.appspot.com/static/media/",rtl:!1,scrollbars:!0,sounds:!0,oneBasedIndex:!0,zoom:{controls:!0,startScale:Math.min(window.innerWidth/800,1),minScale:Math.min(window.innerWidth/800,.3)}};shared.workspace=Blockly.inject("blockly-div",t),console.warn(shared.workspace.getWidth()),Object(_block_utility_functions_js__WEBPACK_IMPORTED_MODULE_8__.e)(shared.workspace,"code_statement"),Object(_block_utility_functions_js__WEBPACK_IMPORTED_MODULE_8__.f)(shared.workspace);var n=shared.workspace.getAllBlocks().find((function(e){return"code_statement"===e.type}));isMobile||n.getField("EXP").showEditor_();var o=function(){var e=document.getElementById("language").value;T2C.MSG.currentLanguage=T2C.MSG[e.toUpperCase()],updateToolbox(T2C.MSG.currentLanguage),Blockly.Msg.VARIABLES_SET=T2C.MSG.currentLanguage===T2C.MSG.PY?"%1 = %2":"let %1 = %2;",updateTexts(),Object(_block_utility_functions_js__WEBPACK_IMPORTED_MODULE_8__.f)(shared.workspace||Blockly.getMainWorkspace()),document.getElementById("outputAppearsBelow").innerText=T2C.MSG.currentLanguage.HEADING_OUTPUT_APPEARS_BELOW,document.getElementById("bottomText")&&(document.getElementById("bottomText").innerText=T2C.MSG.currentLanguage.HEADING_BOTTOM_TEXT)};if(window.location&&"string"==typeof window.location.href){var i=window.location.href.indexOf("lang=")+5,r=window.location.href.substring(i,i+2);4!==i&&(document.getElementById("language").value=r,o())}window.addEventListener("resize",(function(){document.getElementById("top-header").style.height=Math.max(.1*window.innerHeight,50)+"px",document.getElementById("all-content").style.height=Math.min(.9*window.innerHeight,window.innerHeight-50)+"px",Blockly.svgResize(shared.workspace)})),document.getElementById("language").addEventListener("change",(function(){o();var e=shared.workspace||Blockly.getMainWorkspace();e.getAllBlocks().forEach(_block_converters_javascript_text_exact_js__WEBPACK_IMPORTED_MODULE_7__.a),Object(_block_utility_functions_js__WEBPACK_IMPORTED_MODULE_8__.f)(e)})),document.getElementById("run-code-button")&&(document.getElementById("run-code-button").addEventListener("click",(function(){document.getElementById("output-container").classList.remove("hide-container"),document.getElementById("output-container").classList.add("show-container"),document.getElementById("consoleDisplay")&&(document.getElementById("consoleDisplay").textContent=""),T2C.MSG.currentLanguage===T2C.MSG.PY&&(T2C.MSG.currentLanguage=T2C.MSG.JS),document.getElementById("textCodeBox").value=runCode(),T2C.MSG.currentLanguage=T2C.MSG[document.getElementById("language").value.toUpperCase()],document.getElementById("xmlData").value=generateXML()})),document.getElementById("save-code-button").addEventListener("click",(function(){document.getElementById("text-code-container").classList.remove("hide-container"),document.getElementById("text-code-container").classList.add("show-container"),document.getElementById("textCodeBox").value=generateCode(),document.getElementById("xmlData").value=generateXML(),document.getElementById("load-save-text-code").textContent=T2C.MSG.currentLanguage.BUTTON_SAVE_TEXT_CODE,document.getElementById("load-save-xml").textContent=T2C.MSG.currentLanguage.BUTTON_SAVE_XML})),document.getElementById("load-code-button").addEventListener("click",(function(){document.getElementById("text-code-container").classList.remove("hide-container"),document.getElementById("text-code-container").classList.add("show-container"),document.getElementById("textCodeBox").value="",document.getElementById("xmlData").value="",document.getElementById("load-save-text-code").textContent=T2C.MSG.currentLanguage.BUTTON_LOAD_TEXT_CODE,document.getElementById("load-save-xml").textContent=T2C.MSG.currentLanguage.BUTTON_LOAD_XML})),document.getElementById("load-save-text-code").addEventListener("click",(function(){if(document.getElementById("load-save-text-code").textContent===T2C.MSG.currentLanguage.BUTTON_LOAD_TEXT_CODE){var e=T2C.MSG.currentLanguage.CONFIRM_CONVERT_TEXT_TO_BLOCKS,t=getParseTree(document.getElementById("textCodeBox").value);t&&confirm(e)?(shared.workspace.clear(),handleParseTreeToBlocks(t)):t||alert("There seems to be a problem with the code you entered. Check that your spelling is correct, that you use lowercase and capital letters as required, that every open parenthesis ( has a matching closed one ), that you use quotation marks as needed, and other potential issues with syntax.")}else{var n=document.getElementById("textCodeBox").value;navigator.clipboard.writeText(n).then((function(){alert("Code successfully copied to clipboard")}),(function(){document.getElementById("textCodeBox").select(),alert("Code unable to be copied to clipboard. Please do this manually.")}))}})),document.getElementById("load-save-xml").addEventListener("click",(function(){if(document.getElementById("load-save-xml").textContent===T2C.MSG.currentLanguage.BUTTON_LOAD_XML)generateBlocksFromXML();else{var e=document.getElementById("xmlData").value;navigator.clipboard.writeText(e).then((function(){alert("XML successfully copied to clipboard")}),(function(){document.getElementById("xmlData").select(),alert("XML unable to be copied to clipboard. Please do this manually.")}))}})),document.getElementById("output-container").addEventListener("click",(function(e){"table-cell"===e.target.className&&(document.getElementById("output-container").classList.remove("show-container"),document.getElementById("output-container").classList.add("hide-container"))})),document.getElementById("text-code-container").addEventListener("click",(function(e){"table-cell"===e.target.className&&(document.getElementById("text-code-container").classList.remove("show-container"),document.getElementById("text-code-container").classList.add("hide-container"))})))}}));var e=new _tokenizer_js__WEBPACK_IMPORTED_MODULE_1__.a(_grammar_js__WEBPACK_IMPORTED_MODULE_0__.b);return{lexer:e,parser:new _parser_js__WEBPACK_IMPORTED_MODULE_2__.a(e,_grammar_js__WEBPACK_IMPORTED_MODULE_0__.a,Object.keys(_block_interpretations_js__WEBPACK_IMPORTED_MODULE_4__.a).concat("statement")),parseTreeBlockConnector:new _parse_tree_block_connector_js__WEBPACK_IMPORTED_MODULE_3__.a,evaluator:new _block_evaluator_js__WEBPACK_IMPORTED_MODULE_5__.a(_block_interpretations_js__WEBPACK_IMPORTED_MODULE_4__.a)}},shared=init();function varsToLets(e){var t=e.indexOf("var")+4,n=e.indexOf(";",t),o=[],i=e;return t>3&&(o=e.substring(t,n).split(", "),i=e.substring(0,t-4)+e.substring(n+1)),o.forEach((function(e){i=i.replace("\n"+e+" = ","\nlet "+e+" = ")})),i.trim()}function generateCode(){return workspaceToLanguageCode(shared.workspace,T2C.MSG.currentLanguage)}function generateXML(){return workspaceToXML(shared.workspace)}function generateBlocksFromXML(){var e=shared.workspace||Blockly.getMainWorkspace(),t=document.getElementById("xmlData").value,n=null;try{n=Blockly.Xml.textToDom(t)}catch(e){if(!window.confirm(e))return}n&&(e.clear(),Blockly.Xml.domToWorkspace(n,e)),Blockly.svgResize(e)}function runCode(){var code=generateCode();console.realLog=console.log;try{document.getElementById("consoleDisplay").textContent="",console.log=function(){document.getElementById("consoleDisplay").appendChild(document.createTextNode(Array.prototype.join.call(arguments," ")+"\n"))},eval(code)}catch(e){-1!=e.toString().indexOf("Reference")?alert(e.toString()+"\nMake sure variables are defined before they're used. This means the variable definition let ____ = ____ needs to appear ABOVE."):alert(e.toString())}return console.log=console.realLog,code}function updateToolbox(e){shared.workspace.updateToolbox(shared.toolbox)}function updateTexts(){document.getElementById("text-code-container").querySelectorAll("textarea").forEach((function(e){e.placeholder=T2C.MSG.currentLanguage[e.name]}))}return shared}()},function(e,t,n){t.a=function(){function e(t,n){_classCallCheck(this,e),this.lhs_=t,this.rhs_=n}return _createClass(e,[{key:"lhs",get:function(){return this.lhs_}},{key:"rhs",get:function(){return this.rhs_}}]),e}()},function(e,t,n){var o=function(){function e(){_classCallCheck(this,e)}return _createClass(e,null,[{key:"oneStartsWithOther_",value:function(e,t){var n=arguments.length>2&&void 0!==arguments[2]&&arguments[2],o=n?e:e.toLowerCase(),i=n?t:t.toLowerCase();return o.startsWith(i)||i.startsWith(o)}},{key:"getAfter_",value:function(t,n){if(e.oneStartsWithOther_(t,n))return n.substring(Math.min(t.length,n.length))}},{key:"equalsTerminal",value:function(e){return Object.values(T2C.MSG).find((function(t){return Object.keys(t).find((function(n){return n.toUpperCase().startsWith("TERMINAL_")&&t[n]===e}))}))}},{key:"escapeRegExp",value:function(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}},{key:"getAfterTerminal_",value:function(t,n){var o=Object.values(T2C.MSG).map((function(e){return e["TERMINAL_"+n.toUpperCase()]})).filter((function(e){return"string"==typeof e})),i=t.match(/^\s*/)[0];t.match(/\s*$/)[0];var r=void 0,a=o.find((function(n){return r=t.match(RegExp("^\\s*"+e.escapeRegExp(n)))||(i+n).match(RegExp("^\\s*"+e.escapeRegExp(t)))})),l=a&&r[0];if("string"==typeof a)return{terminal:a,remaining:e.getAfter_(l,t),match:l}}},{key:"getTerminalIndexForSymbol",value:function(t,n){if(-1!==["[","(","."].indexOf(e.getExpected(t[n])))return n-1;if(-1!==[")","]"].indexOf(e.getExpected(t[n]))){for(var o=[],i=0;i1&&void 0!==arguments[1]?arguments[1]:{};if("block"===t.type){var o=t.value.type||t.value.types&&t.value.types[0],i=t.value.inputs;o&&(n[o]=++n[o]||1),Array.isArray(i)&&i.forEach((function(t){return e.getBlocksInBlueprint(t,n)}))}else if("input"===t.type)e.getBlocksInBlueprint(t.value,n);else if("component"===t.type&&T2C.MatchManagers[t.name])if("function"==typeof T2C.MatchManagers[t.name].getBlocksInMatch)T2C.MatchManagers[t.name].getBlocksInBlueprint(t.value,n);else{var r=e.getMatchResult(null,t);console.warn("Component Match",e.getRemainingToolboxBlocks(r,n))}return n}},{key:"getRemainingToolboxBlocks",value:function(t){var n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return t.filter((function(e){return e.remainingBlueprint})).map((function(e){return e.remainingBlueprint})).forEach((function(t){return e.getBlocksInBlueprint(t,n)})),n}},{key:"getMaxInstancesFromMatch",value:function(t){var n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},o=e.getCorrectBlocksFromMatch(t);e.getRemainingToolboxBlocks(t,n),o.forEach((function(e){return n[e.type]=++n[e.type]||1}))}},{key:"getCorrectBlockMatchItems",value:function(e){return e.filter((function(e){return e.match instanceof Blockly.Block&&"block"===e.type}))}},{key:"getCorrectBlocksFromMatch",value:function(t){return e.getCorrectBlockMatchItems(t).map((function(e){return e.match}))}},{key:"getTextToParseFromMatch",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]&&arguments[1];return e.map((function(e){return e.length&&1!==e.length||"string"!=typeof e.match||!e.isMatchComplete&&!t?"":e.match})).join("")}},{key:"makeErrorMatch_",value:function(e,t,n){return{id:t,expected:n,length:0,match:null,remaining:e,isMatchComplete:!1,hasError:!0}}},{key:"getExpected",value:function(e){return null==e?e:[e.value,e.match,e.expected,e].find((function(e){return"string"==typeof e}))}},{key:"getSequentialMatchResult_",value:function(t,n){for(var o=[],i=[{match:null,remaining:t,hasError:!1,isMatchComplete:!0}],r=-1;r0?o[o.length-1].remaining:null,isMatchComplete:o.every((function(e){return e.isMatchComplete})),hasError:o.some((function(e){return e.hasError}))}].concat(o)}if("block"===n.type){if(t instanceof Blockly.Block&&(t.type===n.value.type||Array.isArray(n.value.types)&&n.value.types.includes(t.type))){var i=n.value.inputs.map((function(e){return t.getInput(e.name)})),r=n.value.fields.map((function(e){return t.getField(e.name)})),a=e.getMatchResult(i.concat(r),{type:"Array",value:n.value.inputs.concat(n.value.fields)});return[{id:n.id,match:t,length:a.length+1,remaining:null,type:"block",isMatchComplete:a.every((function(e){return e.isMatchComplete})),hasError:!1}].concat(a)}return[{id:n.id,match:null,length:0,remaining:t,remainingBlueprint:n,hasError:null!=t,isMatchComplete:!1}]}if("input"===n.type){if(t instanceof Blockly.Input&&t.name===n.name){var l=e.getMatchResult(t.connection&&t.connection.targetBlock(),n.value);return[{id:n.id,match:t,length:l.length+1,remaining:null,isMatchComplete:!0,hasError:!1}].concat(l)}return[{id:n.id,match:null,length:0,remaining:t,hasError:null!=t,isMatchComplete:!1}]}if("field"===n.type){if(t instanceof Blockly.Field&&t.name===n.name){var s=e.getMatchResult(n.useText?t.getText():t.getValue(),n.value);return[{id:n.id,expected:e.getExpected(n.value),match:t,length:s.length+1,remaining:s[s.length-1].remaining,isMatchComplete:s.every((function(e){return e.isMatchComplete})),hasError:""!==t.getValue()&&s.some((function(e){return e.hasError}))}].concat(s)}return[{id:n.id,match:null,length:0,remaining:t,hasError:null!=t,isMatchComplete:!1}]}if("property"===n.type)return n.property,e.makeErrorMatch_(t,id);if("exact"===n.type){var u=n.property?t[n.name]:t,c=n.value,g=[{id:n.id,expected:e.getExpected(c),match:null,remaining:u,hasError:!0,isMatchComplete:!1}];if("string"==typeof u&&"string"==typeof c){var d=c.match(/^\s*/)[0],h=u.match(/^\s*/)[0],p=u.substring(h.length),f=c.substring(d.length);return c.match(/\s*$/)[0],u.match(/\s*$/)[0],(h.endsWith(d)||n.partial&&!p)&&(!p||p.startsWith(f)||n.partial&&f.startsWith(p))&&(n.postfix||!p.substring(Math.min(f.length,p.length)).trim())?f.length>p.length?[{id:n.id,match:u,remaining:"",hasError:!1,isMatchComplete:!1}]:[{id:n.id,match:h+f,remaining:u.substring(h.length+f.length),hasError:!1,isMatchComplete:!0}]:g}return u===c?[{id:n.id,match:u,remaining:null,hasError:!1,isMatchComplete:!1}]:g}if("includes"===n.type){var m=n.property?t[n.name]:t;return"function"==typeof m.includes&&m.includes(n.value)?[{id:n.id,match:m,remaining:null,hasError:!1,isMatchComplete:!0}]:[{id:n.id,expected:e.getExpected(n.value),match:null,remaining:m,hasError:null!=m&&""!==m,isMatchComplete:!1}]}if("or"===n.type){var y=e.getBestMatchWithIndex_(t,n.value,n.comparer),T=y.matchArr;return[{id:n.id,match:y.pattern,index:y.index,length:y.matchArr.length+1,remaining:null,hasError:T.some((function(e){return e.hasError})),isMatchComplete:!0}].concat(y.matchArr)}if("Array"===n.type){if("string"==typeof t)return e.getSequentialMatchResult_(t,n.value);console.assert(Array.isArray(n.value));var _=n.value.map((function(n,o){return e.getMatchResult(t[o],n)})),b=_.flat();return[{id:n.id,match:n.value,type:n.type,length:b.length+1,remaining:null,isMatchComplete:b.every((function(e){return e.isMatchComplete})),hasError:_.some((function(e){return e.hasError}))}].concat(b)}if("regexp"===n.type){for(var k=t.toString(),x=k.match(/^\s*/)[0],E=void 0,B=!1,A="";!(E=(A+k).match(n.token))&&A!==x;)A+=" ";if(E)B=!0;else if(void 0!==n.tokenPartial)for(A="";!(E=(A+k).match(n.tokenPartial))&&A!==x;)A+=" ";return E?[{id:n.id,expected:n.token,match:E[0],length:1,remaining:k.substring(x.length+E[0].trim().length),isMatchComplete:B,hasError:!1}]:[e.makeErrorMatch_(t,n.id,n.token)]}if("terminal"===n.type&&!(t instanceof Blockly.Block)){var v=e.getAfterTerminal_(t,n.token);return[{id:n.id,expected:T2C.MSG.currentLanguage["TERMINAL_"+n.token.toUpperCase()],terminal:v?v.terminal:null,match:v?v.match:null,remaining:v?v.remaining:t,hasError:!v,isMatchComplete:v&&v.match.includes(v.terminal)}]}}},{key:"getNonEmptyMatchLength_",value:function(e){return e.filter((function(e){return null!=e.match&&""!=e.match})).length}},{key:"getBestMatchWithIndex_",value:function(t,n,o){return o="function"==typeof o?o:function(t,n){return e.getNonEmptyMatchLength_(t)>e.getNonEmptyMatchLength_(n)||!t.hasError&&n.hasError},n.reduce((function(n,i,r){var a=e.getMatchResult(t,i);return 0===r||o(a,n.matchArr)?{index:r,pattern:i,matchArr:a}:n}),{index:-1,matchArr:[],pattern:{}})}}]),e}();t.a=o},function(e,t,n){function o(e,t,n){return e instanceof Array&&t instanceof Array?e.reduce((function(e,o){return e.concat(t.map((function(e){return n?o.concat(e):[o,e]})))}),[]):[]}function i(e){return 0===e.length?[]:1===e.length?e[0].map((function(e){return[e]})):e.reduce((function(e,t,n){return o(e,t,n>1)}))}n.d(t,"b",(function(){return o})),n.d(t,"a",(function(){return i}))},function(e,t,n){var o=function(){function e(t){_classCallCheck(this,e),this.blockTemplate_=JSON.parse(t),this.args_=[],this.blockVal_=null}return _createClass(e,[{key:"evaluate_",value:function(t){var n=this;if(t instanceof e)return t;if("string"==typeof t){var o=t.split(/(%\d+)/).map((function(e){var t=e.startsWith("%")&&parseInt(e.substring(1));return t?n.evaluate_(n.args_[t-1]):e}));return o.find((function(t){return t instanceof e}))||o.join("")}if(Array.isArray(t))return t.map(this.evaluate_.bind(this));var i={};return Object.keys(t).forEach((function(e){i[e]=n.evaluate_(t[e])})),i}},{key:"hasBeenSet_",value:function(e){return!/"%(\d+)"/.test(e)}},{key:"keys",value:function(e){var t=this;return this.blockVal_[e].filter((function(e){return t.hasBeenSet_(e)}))}},{key:"args",set:function(e){this.args_=e,this.blockVal_=this.evaluate_(this.blockTemplate_)}},{key:"type",get:function(){return this.blockVal_&&this.blockVal_.type}},{key:"inputs",get:function(){return this.blockVal_&&this.blockVal_.inputs}},{key:"fields",get:function(){return this.blockVal_&&this.blockVal_.fields}},{key:"blocks",get:function(){return this.blockVal_&&this.blockVal_.blocks}}]),e}();t.a=o},function(e,t,n){n.d(t,"a",(function(){return o})),n.d(t,"b",(function(){return i}));var o=JSON.parse('{"rules":{"wholeNumberExp":{"wholeNumberSum":["wholeNumberExp","wholeNumberAddMinusOp","wholeNumberTerm"],"wholeNumberTermSingle":["wholeNumberTerm"],"__2__wholeNumberSum":["wholeNumberExp","wholeNumberAddMinusOp"]},"wholeNumberTerm":{"wholeNumberTermSingleGroupedExp":["openParenthesis","wholeNumberTerm","closeParenthesis"],"wholeNumberTermTwoGroupedExp":["openParenthesis","wholeNumberExp","wholeNumberGroupedOp","wholeNumberTerm","closeParenthesis"],"wholeNumberTermProduct":["wholeNumberTerm","wholeNumberTimesDividedByOp","wholeNumberTerm"],"wholeNumberTermAtomic":["wholeNumberAtomic"],"__2__wholeNumberTermSingleGroupedExp":["openParenthesis","wholeNumberTerm"],"__2__wholeNumberTermTwoGroupedExp":["openParenthesis","wholeNumberExp"],"__3__wholeNumberTermTwoGroupedExp":["openParenthesis","wholeNumberExp","wholeNumberGroupedOp"],"__4__wholeNumberTermTwoGroupedExp":["openParenthesis","wholeNumberExp","wholeNumberGroupedOp","wholeNumberTerm"],"__2__wholeNumberTermProduct":["wholeNumberTerm","wholeNumberTimesDividedByOp"]},"wholeNumberAtomic":{"wholeNumberLiteral":"token_","identifierGet":["identifier"],"wholeNumberStringFunc":["stringExpWholeNumber"]},"wholeNumberGroupedOp":{"wholeNumberSumTwo":["wholeNumberAddMinusOp"],"wholeNumberProductTwo":["wholeNumberTimesDividedByOp"]},"wholeNumberAddMinusOp":{"wholeNumberPlus":"+","wholeNumberMinus":"-"},"wholeNumberTimesDividedByOp":{"wholeNumberTimes":"*","wholeNumberDividedBy":"/"},"expression":{"expressionText":["stringExp"],"expressionNumber":["wholeNumberExp"]},"statement":{"statementSingle":["expression"],"statementVariable":["variableStatement"],"statementPrint":["stringDisplay"],"statementSemicolon":["statement","semicolon"],"statementBlockExp":["expression","statementSeparator","statement"],"statementBlockVariable":["variableStatement","statementSeparator","statement"],"statementBlockPrint":["stringDisplay","statementSeparator","statement"]},"statementSeparator":{"semicolonEnd":["semicolon"],"newLineEnd":["newLine"],"carriageReturnEnd":["carriageReturn"],"semicolonMultiSeparator":["semicolon","statementSeparator"],"newLineMultiSeparator":["newLine","statementSeparator"],"carriageReturnMultiSeparator":["carriageReturn","statementSeparator"]},"semicolon":"token_","newLine":"\\n","carriageReturn":"\\r","stringExp":{"identifierGet":["identifier"],"stringGetInputExp":["stringGetInput","openParenthesis","stringExp","closeParenthesis"],"js_stringGetInputExp":["stringPrompt","openParenthesis","stringExp","closeParenthesis"],"stringGroupedExp":["openParenthesis","stringExp","closeParenthesis"],"stringConcatenationFullExpression":["stringExp","plusStr","stringExp"],"stringCharAtFullExpression":["stringExp","dot","getCharacterNumber","openParenthesis","wholeNumberExp","closeParenthesis"],"py_stringCharAtFullExpression":["stringExp","openBracket","wholeNumberExp","closeBracket"],"js_stringCharAtFullExpression":["stringExp","dot","getCharacterNumberJS","openParenthesis","wholeNumberExp","closeParenthesis"],"stringAfterTextFullExpression":["stringExp","dot","getAfterText","openParenthesis","stringExp","closeParenthesis"],"stringBeforeTextFullExpression":["stringExp","dot","getBeforeText","openParenthesis","stringExp","closeParenthesis"],"stringSubstringFullExpression":["stringExp","dot","getTextFrom","openParenthesis","wholeNumberExp","closeParenthesis","dot","getTextTo","openParenthesis","wholeNumberExp","stringSubstringCloseParenthesisOptionalTail"],"py_stringSubstringFullExpression":["stringExp","openBracket","wholeNumberExp","colon","wholeNumberExp","closeBracket"],"js_stringSubstringFullExpression":["stringExp","dot","getSubstringJS","openParenthesis","wholeNumberExp","comma","wholeNumberExp","closeParenthesis"],"stringLiteral":"token_","__2__stringGetInputExp":["stringGetInput","openParenthesis"],"__3__stringGetInputExp":["stringGetInput","openParenthesis","stringExp"],"__2__js_stringGetInputExp":["stringPrompt","openParenthesis"],"__3__js_stringGetInputExp":["stringPrompt","openParenthesis","stringExp"],"__2__stringGroupedExp":["openParenthesis","stringExp"],"__2__stringConcatenationFullExpression":["stringExp","plusStr"],"__2__stringCharAtFullExpression":["stringExp","dot"],"__3__stringCharAtFullExpression":["stringExp","dot","getCharacterNumber"],"__4__stringCharAtFullExpression":["stringExp","dot","getCharacterNumber","openParenthesis"],"__5__stringCharAtFullExpression":["stringExp","dot","getCharacterNumber","openParenthesis","wholeNumberExp"],"__2__py_stringCharAtFullExpression":["stringExp","openBracket"],"__3__py_stringCharAtFullExpression":["stringExp","openBracket","wholeNumberExp"],"__2__js_stringCharAtFullExpression":["stringExp","dot"],"__3__js_stringCharAtFullExpression":["stringExp","dot","getCharacterNumberJS"],"__4__js_stringCharAtFullExpression":["stringExp","dot","getCharacterNumberJS","openParenthesis"],"__5__js_stringCharAtFullExpression":["stringExp","dot","getCharacterNumberJS","openParenthesis","wholeNumberExp"],"__2__stringAfterTextFullExpression":["stringExp","dot"],"__3__stringAfterTextFullExpression":["stringExp","dot","getAfterText"],"__4__stringAfterTextFullExpression":["stringExp","dot","getAfterText","openParenthesis"],"__5__stringAfterTextFullExpression":["stringExp","dot","getAfterText","openParenthesis","stringExp"],"__2__stringBeforeTextFullExpression":["stringExp","dot"],"__3__stringBeforeTextFullExpression":["stringExp","dot","getBeforeText"],"__4__stringBeforeTextFullExpression":["stringExp","dot","getBeforeText","openParenthesis"],"__5__stringBeforeTextFullExpression":["stringExp","dot","getBeforeText","openParenthesis","stringExp"],"__2__stringSubstringFullExpression":["stringExp","dot"],"__3__stringSubstringFullExpression":["stringExp","dot","getTextFrom"],"__4__stringSubstringFullExpression":["stringExp","dot","getTextFrom","openParenthesis"],"__5__stringSubstringFullExpression":["stringExp","dot","getTextFrom","openParenthesis","wholeNumberExp"],"__6__stringSubstringFullExpression":["stringExp","dot","getTextFrom","openParenthesis","wholeNumberExp","closeParenthesis"],"__7__stringSubstringFullExpression":["stringExp","dot","getTextFrom","openParenthesis","wholeNumberExp","closeParenthesis","dot"],"__8__stringSubstringFullExpression":["stringExp","dot","getTextFrom","openParenthesis","wholeNumberExp","closeParenthesis","dot","getTextTo"],"__9__stringSubstringFullExpression":["stringExp","dot","getTextFrom","openParenthesis","wholeNumberExp","closeParenthesis","dot","getTextTo","openParenthesis"],"__10__stringSubstringFullExpression":["stringExp","dot","getTextFrom","openParenthesis","wholeNumberExp","closeParenthesis","dot","getTextTo","openParenthesis","wholeNumberExp"],"__2__py_stringSubstringFullExpression":["stringExp","openBracket"],"__3__py_stringSubstringFullExpression":["stringExp","openBracket","wholeNumberExp"],"__4__py_stringSubstringFullExpression":["stringExp","openBracket","wholeNumberExp","colon"],"__5__py_stringSubstringFullExpression":["stringExp","openBracket","wholeNumberExp","colon","wholeNumberExp"],"__2__js_stringSubstringFullExpression":["stringExp","dot"],"__3__js_stringSubstringFullExpression":["stringExp","dot","getSubstringJS"],"__4__js_stringSubstringFullExpression":["stringExp","dot","getSubstringJS","openParenthesis"],"__5__js_stringSubstringFullExpression":["stringExp","dot","getSubstringJS","openParenthesis","wholeNumberExp"],"__6__js_stringSubstringFullExpression":["stringExp","dot","getSubstringJS","openParenthesis","wholeNumberExp","comma"],"__7__js_stringSubstringFullExpression":["stringExp","dot","getSubstringJS","openParenthesis","wholeNumberExp","comma","wholeNumberExp"]},"stringExpWholeNumber":{"stringFindFirstFullExpression":["stringExp","dot","findFirstOccurrenceOfText","openParenthesis","stringExp","stringFindFirstCloseParenthesisOptionalTail"],"js_stringFindFirstFullExpression":["stringExp","dot","jsIndexOf","openParenthesis","stringExp","closeParenthesis"],"stringExpLength":["stringExp","dot","length"],"py_stringExpLength":["len","openParenthesis","stringExp","closeParenthesis"],"__2__stringFindFirstFullExpression":["stringExp","dot"],"__3__stringFindFirstFullExpression":["stringExp","dot","findFirstOccurrenceOfText"],"__4__stringFindFirstFullExpression":["stringExp","dot","findFirstOccurrenceOfText","openParenthesis"],"__5__stringFindFirstFullExpression":["stringExp","dot","findFirstOccurrenceOfText","openParenthesis","stringExp"],"__2__js_stringFindFirstFullExpression":["stringExp","dot"],"__3__js_stringFindFirstFullExpression":["stringExp","dot","jsIndexOf"],"__4__js_stringFindFirstFullExpression":["stringExp","dot","jsIndexOf","openParenthesis"],"__5__js_stringFindFirstFullExpression":["stringExp","dot","jsIndexOf","openParenthesis","stringExp"],"__2__stringExpLength":["stringExp","dot"],"__2__py_stringExpLength":["len","openParenthesis"],"__3__py_stringExpLength":["len","openParenthesis","stringExp"]},"stringDisplay":{"js_ConsoleLogStatement":["console","dot","log","openParenthesis","expression","closeParenthesis"],"displayStatement":["display","openParenthesis","expression","closeParenthesis"],"__2__js_ConsoleLogStatement":["console","dot"],"__3__js_ConsoleLogStatement":["console","dot","log"],"__4__js_ConsoleLogStatement":["console","dot","log","openParenthesis"],"__5__js_ConsoleLogStatement":["console","dot","log","openParenthesis","expression"],"__2__displayStatement":["display","openParenthesis"],"__3__displayStatement":["display","openParenthesis","expression"]},"stringSubstringCloseParenthesisOptionalTail":{"stringSubstringCloseParenthesisNoTail":["closeParenthesis"],"stringSubstringCloseParenthesisTail":["closeParenthesis","dot","substringTail"],"__2__stringSubstringCloseParenthesisTail":["closeParenthesis","dot"]},"stringFindFirstCloseParenthesisOptionalTail":{"stringFindFirstCloseParenthesisNoTail":["closeParenthesis"],"stringFindFirstCloseParenthesisTail":["closeParenthesis","dot","findFirstTail"],"__2__stringFindFirstCloseParenthesisTail":["closeParenthesis","dot"]},"dot":"token_","console":"console","log":"log","display":"display","openParenthesis":"token_","closeParenthesis":"token_","openBracket":"token_","closeBracket":"token_","comma":"token_","stringGetInput":"getInputByAsking","stringPrompt":"prompt","length":"length","len":"len","getTextFrom":"getTextFromPositionNUMBER","getTextTo":"toPositionNUMBER","getSubstringJS":"substring","jsIndexOf":"indexOf","findFirstOccurrenceOfText":"positionNumberOfTEXT","findLastOccurrenceOfText":"lastPositionNumberOfTEXT","getAfterText":"getAfterTEXT","getBeforeText":"getBeforeTEXT","plusStr":"+","getCharacterNumber":"getCharacterNUMBER","getCharacterNumberJS":"charAt","toNumber":"toNumber","substringTail":"tak_paen","findFirstTail":"ke_sthiti_sankhya","variableStatement":{"variableAssignment":["variablesLet","identifier","equalsSign","expression"],"variableAssignmentNoLet":["identifier","equalsSign","expression"],"__2__variableAssignment":["variablesLet","identifier"],"__3__variableAssignment":["variablesLet","identifier","equalsSign"],"__2__variableAssignmentNoLet":["identifier","equalsSign"]},"variablesLet":"let","equalsSign":"=","identifier":"token_"},"terminals":["wholeNumberPlus","wholeNumberMinus","wholeNumberTimes","wholeNumberDividedBy","semicolon","newLine","carriageReturn","findFirstOccurrenceOfText","jsIndexOf","findLastOccurrenceOfText","getAfterText","getBeforeText","plusStr","getCharacterNumber","getCharacterNumberJS","toNumber","getTextFrom","getSubstringJS","getTextTo","stringGetInput","stringPrompt","console","log","display","length","substringTail","findFirstTail","variablesLet","equalsSign"]}'),i=JSON.parse('{"stringLiteral":{"pattern":"\\"([^\\"]*)\\"|\'([^\']*)\'","order":1},"identifier":{"pattern":"([_\\\\$A-Za-z|ऄ-ह|ऽ|ॐ|क़-ॡ|ॱ-ॿ][\\\\w\\\\$|ऀ-ॣ|०-९|ॱ-ॿ]*)","order":2},"positiveDecimal":{"pattern":"(\\\\d+\\\\.[1-9]\\\\d+)","order":3},"wholeNumberLiteral":{"pattern":"\\\\d+|\\\\d*\\\\.[0]+","order":6},"dot":{"pattern":"(\\\\.)","order":7},"openParenthesis":{"pattern":"(\\\\()","order":8},"closeParenthesis":{"pattern":"(\\\\))","order":9},"openBracket":{"pattern":"(\\\\[)","order":10},"closeBracket":{"pattern":"(\\\\])","order":11},"comma":{"pattern":"(\\\\,)","order":12},"semicolon":{"pattern":"(\\\\;)","order":13},"colon":{"pattern":"(:)","order":14},"negativeDecimalMOVEDFROMFOURFORNOW":{"pattern":"(-\\\\d+\\\\.[1-9]\\\\d+)","order":15},"negativeIntegerMOVEDFROMFIVEFORNOW":{"pattern":"-[1-9]\\\\d*|-[1-9]\\\\d*\\\\.[0]+","order":16}}')},function(e,t,n){n.d(t,"a",(function(){return o}));var o=JSON.parse('{"wholeNumberLiteral":{"type":"math_number","fields":{"NUM":"%1"}},"wholeNumberSum":{"type":"math_arithmetic_basic","fields":{"OP":"%2"},"inputs":{"A":"%1","B":"%3"}},"wholeNumberTermTwoGroupedExp":{"type":"math_arithmetic_basic","fields":{"OP":"%3"},"inputs":{"A":"%2","B":"%4"}},"wholeNumberTermProduct":{"type":"math_arithmetic_basic","fields":{"OP":"%2"},"inputs":{"A":"%1","B":"%3"}},"wholeNumberPlus":"ADD","wholeNumberMinus":"MINUS","wholeNumberTimes":"MULTIPLY","wholeNumberDividedBy":"DIVIDE","wholeNumberTermSingleGroupedExp":"%2","statementBlockExp":{"blocks":["%1","%3"]},"statementBlockVariable":{"blocks":["%1","%3"]},"statementBlockPrint":{"blocks":["%1","%3"]},"stringLiteral":{"type":"text","fields":{"TEXT":"%1"}},"stringGetInputExp":{"type":"text_input","inputs":{"TEXT":"%3"}},"js_stringGetInputExp":{"type":"js_text_input","inputs":{"TEXT":"%3"}},"displayStatement":{"type":"text_print","inputs":{"TEXT":"%3"}},"js_ConsoleLogStatement":{"type":"js_text_print","inputs":{"TEXT":"%5"}},"stringExpLength":{"type":"t2c_text_length","inputs":{"VALUE":"%1"}},"py_stringExpLength":{"type":"t2c_text_length","inputs":{"VALUE":"%3"}},"stringFindFirstFullExpression":{"type":"t2c_text_indexof","inputs":{"VALUE":"%1","FIND":"%5"}},"js_stringFindFirstFullExpression":{"type":"js_text_indexof","inputs":{"VALUE":"%1","FIND":"%5"}},"stringSubstringFullExpression":{"type":"t2c_text_getsubstring","inputs":{"STRING":"%1","AT1":"%5","AT2":"%10"}},"stringCharAtFullExpression":{"type":"%3","inputs":{"VALUE":"%1","AT":"%5"}},"py_stringCharAtFullExpression":{"type":"t2c_text_charat","inputs":{"VALUE":"%1","AT":"%3"}},"js_stringCharAtFullExpression":{"type":"js_text_charat","inputs":{"VALUE":"%1","AT":"%5"}},"py_stringSubstringFullExpression":{"type":"t2c_text_getsubstring","inputs":{"STRING":"%1","AT1":"%3","AT2":"%5"}},"js_stringSubstringFullExpression":{"type":"js_text_getsubstring","inputs":{"STRING":"%1","AT1":"%5","AT2":"%7"}},"stringAfterTextFullExpression":{"type":"t2c_text_after","inputs":{"TEXT":"%1","SUB":"%5"}},"stringBeforeTextFullExpression":{"type":"t2c_text_before","inputs":{"TEXT":"%1","SUB":"%5"}},"stringConcatenationFullExpression":{"type":"t2c_text_join","inputs":{"A":"%1","B":"%3"}},"stringGroupedExp":"%2","plusStr":"t2c_text_join","findFirstOccurrenceOfText":"t2c_text_indexof","getCharacterNumber":"t2c_text_charat","getCharacterNumberJS":"js_text_charat","getSubstringJS":"js_text_getsubstring","jsIndexOf":"js_text_indexof","getTextFrom":"t2c_text_getsubstring","getAfterText":"t2c_text_after","getBeforeText":"t2c_text_before","identifierGet":{"type":"variables_get","fields":{"VAR":"%1"}},"variableAssignment":{"type":"variables_set","fields":{"VAR":"%2"},"inputs":{"VALUE":"%4"}},"variableAssignmentNoLet":{"type":"variables_set","fields":{"VAR":"%1"},"inputs":{"VALUE":"%3"}},"__2__wholeNumberSum":{"type":"math_arithmetic_basic","fields":{"OP":"%2"},"inputs":{"A":"%1","B":{"type":"code_expression"}}},"__2__wholeNumberTermSingleGroupedExp":"%2","__2__wholeNumberTermTwoGroupedExp":{"type":"math_arithmetic_basic","fields":{"OP":{"type":"code_expression"}},"inputs":{"A":"%2","B":{"type":"code_expression"}}},"__3__wholeNumberTermTwoGroupedExp":{"type":"math_arithmetic_basic","fields":{"OP":"%3"},"inputs":{"A":"%2","B":{"type":"code_expression"}}},"__4__wholeNumberTermTwoGroupedExp":{"type":"math_arithmetic_basic","fields":{"OP":"%3"},"inputs":{"A":"%2","B":"%4"}},"__2__wholeNumberTermProduct":{"type":"math_arithmetic_basic","fields":{"OP":"%2"},"inputs":{"A":"%1","B":{"type":"code_expression"}}},"__2__stringGetInputExp":{"type":"text_input","inputs":{"TEXT":{"type":"code_expression"}}},"__3__stringGetInputExp":{"type":"text_input","inputs":{"TEXT":"%3"}},"__2__js_stringGetInputExp":{"type":"js_text_input","inputs":{"TEXT":{"type":"code_expression"}}},"__3__js_stringGetInputExp":{"type":"js_text_input","inputs":{"TEXT":"%3"}},"__2__stringGroupedExp":"%2","__2__stringConcatenationFullExpression":{"type":"t2c_text_join","inputs":{"A":"%1","B":{"type":"code_expression"}}},"__2__stringCharAtFullExpression":{"type":{"type":"code_expression"},"inputs":{"VALUE":"%1","AT":{"type":"code_expression"}}},"__3__stringCharAtFullExpression":{"type":"%3","inputs":{"VALUE":"%1","AT":{"type":"code_expression"}}},"__4__stringCharAtFullExpression":{"type":"%3","inputs":{"VALUE":"%1","AT":{"type":"code_expression"}}},"__5__stringCharAtFullExpression":{"type":"%3","inputs":{"VALUE":"%1","AT":"%5"}},"__2__py_stringCharAtFullExpression":{"type":"t2c_text_charat","inputs":{"VALUE":"%1","AT":{"type":"code_expression"}}},"__3__py_stringCharAtFullExpression":{"type":"t2c_text_charat","inputs":{"VALUE":"%1","AT":"%3"}},"__2__js_stringCharAtFullExpression":{"type":"js_text_charat","inputs":{"VALUE":"%1","AT":{"type":"code_expression"}}},"__3__js_stringCharAtFullExpression":{"type":"js_text_charat","inputs":{"VALUE":"%1","AT":{"type":"code_expression"}}},"__4__js_stringCharAtFullExpression":{"type":"js_text_charat","inputs":{"VALUE":"%1","AT":{"type":"code_expression"}}},"__5__js_stringCharAtFullExpression":{"type":"js_text_charat","inputs":{"VALUE":"%1","AT":"%5"}},"__2__stringAfterTextFullExpression":{"type":"t2c_text_after","inputs":{"TEXT":"%1","SUB":{"type":"code_expression"}}},"__3__stringAfterTextFullExpression":{"type":"t2c_text_after","inputs":{"TEXT":"%1","SUB":{"type":"code_expression"}}},"__4__stringAfterTextFullExpression":{"type":"t2c_text_after","inputs":{"TEXT":"%1","SUB":{"type":"code_expression"}}},"__5__stringAfterTextFullExpression":{"type":"t2c_text_after","inputs":{"TEXT":"%1","SUB":"%5"}},"__2__stringBeforeTextFullExpression":{"type":"t2c_text_before","inputs":{"TEXT":"%1","SUB":{"type":"code_expression"}}},"__3__stringBeforeTextFullExpression":{"type":"t2c_text_before","inputs":{"TEXT":"%1","SUB":{"type":"code_expression"}}},"__4__stringBeforeTextFullExpression":{"type":"t2c_text_before","inputs":{"TEXT":"%1","SUB":{"type":"code_expression"}}},"__5__stringBeforeTextFullExpression":{"type":"t2c_text_before","inputs":{"TEXT":"%1","SUB":"%5"}},"__2__stringSubstringFullExpression":{"type":"t2c_text_getsubstring","inputs":{"STRING":"%1","AT1":{"type":"code_expression"},"AT2":{"type":"code_expression"}}},"__3__stringSubstringFullExpression":{"type":"t2c_text_getsubstring","inputs":{"STRING":"%1","AT1":{"type":"code_expression"},"AT2":{"type":"code_expression"}}},"__4__stringSubstringFullExpression":{"type":"t2c_text_getsubstring","inputs":{"STRING":"%1","AT1":{"type":"code_expression"},"AT2":{"type":"code_expression"}}},"__5__stringSubstringFullExpression":{"type":"t2c_text_getsubstring","inputs":{"STRING":"%1","AT1":"%5","AT2":{"type":"code_expression"}}},"__6__stringSubstringFullExpression":{"type":"t2c_text_getsubstring","inputs":{"STRING":"%1","AT1":"%5","AT2":{"type":"code_expression"}}},"__7__stringSubstringFullExpression":{"type":"t2c_text_getsubstring","inputs":{"STRING":"%1","AT1":"%5","AT2":{"type":"code_expression"}}},"__8__stringSubstringFullExpression":{"type":"t2c_text_getsubstring","inputs":{"STRING":"%1","AT1":"%5","AT2":{"type":"code_expression"}}},"__9__stringSubstringFullExpression":{"type":"t2c_text_getsubstring","inputs":{"STRING":"%1","AT1":"%5","AT2":{"type":"code_expression"}}},"__10__stringSubstringFullExpression":{"type":"t2c_text_getsubstring","inputs":{"STRING":"%1","AT1":"%5","AT2":"%10"}},"__2__py_stringSubstringFullExpression":{"type":"t2c_text_getsubstring","inputs":{"STRING":"%1","AT1":{"type":"code_expression"},"AT2":{"type":"code_expression"}}},"__3__py_stringSubstringFullExpression":{"type":"t2c_text_getsubstring","inputs":{"STRING":"%1","AT1":"%3","AT2":{"type":"code_expression"}}},"__4__py_stringSubstringFullExpression":{"type":"t2c_text_getsubstring","inputs":{"STRING":"%1","AT1":"%3","AT2":{"type":"code_expression"}}},"__5__py_stringSubstringFullExpression":{"type":"t2c_text_getsubstring","inputs":{"STRING":"%1","AT1":"%3","AT2":"%5"}},"__2__js_stringSubstringFullExpression":{"type":"js_text_getsubstring","inputs":{"STRING":"%1","AT1":{"type":"code_expression"},"AT2":{"type":"code_expression"}}},"__3__js_stringSubstringFullExpression":{"type":"js_text_getsubstring","inputs":{"STRING":"%1","AT1":{"type":"code_expression"},"AT2":{"type":"code_expression"}}},"__4__js_stringSubstringFullExpression":{"type":"js_text_getsubstring","inputs":{"STRING":"%1","AT1":{"type":"code_expression"},"AT2":{"type":"code_expression"}}},"__5__js_stringSubstringFullExpression":{"type":"js_text_getsubstring","inputs":{"STRING":"%1","AT1":"%5","AT2":{"type":"code_expression"}}},"__6__js_stringSubstringFullExpression":{"type":"js_text_getsubstring","inputs":{"STRING":"%1","AT1":"%5","AT2":{"type":"code_expression"}}},"__7__js_stringSubstringFullExpression":{"type":"js_text_getsubstring","inputs":{"STRING":"%1","AT1":"%5","AT2":"%7"}},"__2__stringFindFirstFullExpression":{"type":"t2c_text_indexof","inputs":{"VALUE":"%1","FIND":{"type":"code_expression"}}},"__3__stringFindFirstFullExpression":{"type":"t2c_text_indexof","inputs":{"VALUE":"%1","FIND":{"type":"code_expression"}}},"__4__stringFindFirstFullExpression":{"type":"t2c_text_indexof","inputs":{"VALUE":"%1","FIND":{"type":"code_expression"}}},"__5__stringFindFirstFullExpression":{"type":"t2c_text_indexof","inputs":{"VALUE":"%1","FIND":"%5"}},"__2__js_stringFindFirstFullExpression":{"type":"js_text_indexof","inputs":{"VALUE":"%1","FIND":{"type":"code_expression"}}},"__3__js_stringFindFirstFullExpression":{"type":"js_text_indexof","inputs":{"VALUE":"%1","FIND":{"type":"code_expression"}}},"__4__js_stringFindFirstFullExpression":{"type":"js_text_indexof","inputs":{"VALUE":"%1","FIND":{"type":"code_expression"}}},"__5__js_stringFindFirstFullExpression":{"type":"js_text_indexof","inputs":{"VALUE":"%1","FIND":"%5"}},"__2__stringExpLength":{"type":"t2c_text_length","inputs":{"VALUE":"%1"}},"__2__py_stringExpLength":{"type":"t2c_text_length","inputs":{"VALUE":{"type":"code_expression"}}},"__3__py_stringExpLength":{"type":"t2c_text_length","inputs":{"VALUE":"%3"}},"__2__js_ConsoleLogStatement":{"type":"js_text_print","inputs":{"TEXT":{"type":"code_expression"}}},"__3__js_ConsoleLogStatement":{"type":"js_text_print","inputs":{"TEXT":{"type":"code_expression"}}},"__4__js_ConsoleLogStatement":{"type":"js_text_print","inputs":{"TEXT":{"type":"code_expression"}}},"__5__js_ConsoleLogStatement":{"type":"js_text_print","inputs":{"TEXT":"%5"}},"__2__displayStatement":{"type":"text_print","inputs":{"TEXT":{"type":"code_expression"}}},"__3__displayStatement":{"type":"text_print","inputs":{"TEXT":"%3"}},"__2__variableAssignment":{"type":"variables_set","fields":{"VAR":"%2"},"inputs":{"VALUE":{"type":"code_expression"}}},"__3__variableAssignment":{"type":"variables_set","fields":{"VAR":"%2"},"inputs":{"VALUE":{"type":"code_expression"}}},"__2__variableAssignmentNoLet":{"type":"variables_set","fields":{"VAR":"%1"},"inputs":{"VALUE":{"type":"code_expression"}}}}')},function(e,t,n){n(5);var o=n(0);t.a=function(e,t){var n=!(arguments.length>2&&void 0!==arguments[2])||arguments[2],i=t.workspace,r=function e(t,n){var i;if(t&&t.type)return i=Object(o.e)(n,t.type),t.inputs&&Object.keys(t.inputs).forEach((function(r){Object(o.j)(i,r,e(t.inputs[r],n))})),t&&t.fields&&Object.keys(t.fields).forEach((function(e){Object(o.h)(i,t.fields[e],e)})),i;if(t&&Array.isArray(t.blocks)){for(var r=t.blocks.map((function(t){return e(t,n)})),a=0;a1&&void 0!==arguments[1]?arguments[1]:1;return e.rhsides.map((function(r){return"string"==typeof r?[new o.a(e.lhs,r)]:Object(i.a)(r.map((function(e){return t.convertToBlockParseTrees(e,n)}))).map((function(t){return new o.a(e.lhs,t)}))})).reduce((function(e,t){return e.concat(t)}),[]).slice(0,n)}}]),e}()},function(e,t,n){var o=n(2),i=n(5);t.a=function(){function e(t){_classCallCheck(this,e),this.interpretations_=t}return _createClass(e,[{key:"evaluate",value:function(e){if(null===e||e instanceof o.a){if(e){var t="string"==typeof e.rhs?[e.rhs.replace(/\"/g,"'")]:e.rhs.map(this.evaluate.bind(this)),n=this.interpretations_[e.lhs];if("string"==typeof n)return n;if(n){var r=new i.a(JSON.stringify(n));return r.args=t,r}return t[0]}return""}throw console.assert(null!==e&&!(e instanceof o.a),{msg:"Non-null is invalid root type",expectedType:o.a,actual:e}),new Error("Invalid root type")}}]),e}()},function(e,t,n){n.d(t,"a",(function(){return i})),n.d(t,"b",(function(){return r}));var o=n(0);function i(e){var t=e.workspace;"js_text_print"===e.type||"js_text_input"===e.type?Object(o.g)(e,Object(o.e)(t,e.type.substring(3)),!0):"js_text_indexof"===e.type||"js_text_charat"===e.type||"js_text_getsubstring"===e.type?Object(o.g)(e,Object(o.e)(t,e.type.replace("js","t2c")),!0):"text_length"===e.type&&Object(o.g)(e,Object(o.e)(t,"t2c_"+e.type),!0)}function r(e){var t=e.workspace;if("text_print"===e.type)Object(o.g)(e,Object(o.e)(t,"js_text_print"),!0);else if("text_input"===e.type)Object(o.g)(e,Object(o.e)(t,"js_text_input"),!0);else if("t2c_text_indexof"===e.type)Object(o.g)(e,Object(o.e)(t,"js_text_indexof"),!0);else if("t2c_text_charat"===e.type)Object(o.g)(e,Object(o.e)(t,"js_text_charat"),!0);else if("t2c_text_length"===e.type)Object(o.g)(e,Object(o.e)(t,"text_length"),!0);else if("t2c_text_getsubstring"===e.type)Object(o.g)(e,Object(o.e)(t,"js_text_getsubstring"),!0);else if("t2c_text_before"===e.type){var n=e.getInputTargetBlock("SUB"),i=e.getInputTargetBlock("TEXT"),r=null,a=Object(o.e)(t,"js_text_getsubstring"),l=Object(o.e)(t,"math_number"),s=Object(o.e)(t,"js_text_indexof");if(Object(o.h)(l,0,"NUM"),i)if("text"===i.type)r=Object(o.e)(t,i.type),Object(o.h)(r,i.getFieldValue("TEXT"),"TEXT"),s.getInput("VALUE").connection.connect(r.outputConnection),a.getInput("STRING").connection.connect(i.outputConnection);else if("variables_get"===i.type)r=Object(o.e)(t,i.type),Object(o.h)(r,i.getFieldValue("VAR"),"VAR"),s.getInput("VALUE").connection.connect(r.outputConnection),a.getInput("STRING").connection.connect(i.outputConnection);else{var u=createNewTempVariable(t),c=Object(o.e)(t,"variables_set");Object(o.h)(c,u,"VAR"),Object(o.j)(c,"VALUE",i);var g=Object(o.e)(t,"variables_get");Object(o.h)(g,u,"VAR");var d=copyBlock(g);if(Object(o.j)(s,"VALUE",d),Object(o.j)(a,"STRING",g),y=Object(o.c)(e)){var h=y.previousConnection.targetBlock();h&&c.previousConnection.connect(h.nextConnection),y.previousConnection.connect(c.nextConnection)}}n&&Object(o.j)(s,"FIND",n),Object(o.j)(a,"AT1",l),Object(o.j)(a,"AT2",s),e.outputConnection.targetConnection?e.outputConnection.targetConnection.connect(a.outputConnection):Object(o.d)(e,a),e.dispose()}else if("t2c_text_after"===e.type){e.getParent(),a=Object(o.e)(t,"js_text_getsubstring"),i=e.getInputTargetBlock("TEXT"),n=e.getInputTargetBlock("SUB"),s=Object(o.e)(t,"js_text_indexof");var p=Object(o.e)(t,"text_length"),f=Object(o.e)(t,"text_length"),m=Object(o.e)(t,"math_arithmetic_basic");if(Object(o.h)(m,"ADD","OP"),i){if("text"!==i.type&&"variables_get"!==i.type){var y,T=Object(o.e)(t,"variables_set");if(u=createNewTempVariable(t),Object(o.h)(T,u,"VAR"),Object(o.j)(T,"VALUE",i),y=Object(o.c)(e)){var _=y.previousConnection.targetBlock();_&&T.previousConnection.connect(_.nextConnection),y.previousConnection.connect(T.nextConnection)}i=Object(o.e)(t,"variables_get"),Object(o.h)(i,u,"VAR"),Object(o.j)(a,"STRING",i)}else Object(o.j)(a,"STRING",i);Object(o.j)(s,"VALUE",copyBlock(i)),Object(o.j)(p,"VALUE",copyBlock(i))}if(n){if("text"!==n.type&&"variables_get"!==n.type){var b=Object(o.e)(t,"variables_set"),k=createNewTempVariable(t);Object(o.h)(b,k,"VAR"),Object(o.j)(b,"VALUE",n);var x=Object(o.c)(e);if(x){var E=x.previousConnection.targetBlock();E&&b.previousConnection.connect(E.nextConnection),x.previousConnection.connect(b.nextConnection)}n=Object(o.e)(t,"variables_get"),Object(o.h)(n,k,"VAR")}if("variables_get"===n.type)Object(o.j)(m,"B",f),Object(o.j)(f,"VALUE",copyBlock(n));else{var B=Object(o.e)(t,"math_number");Object(o.h)(B,n.getFieldValue("TEXT").length,"NUM"),Object(o.j)(m,"B",B),f.dispose()}Object(o.j)(s,"FIND",n)}else Object(o.j)(m,"B",f);Object(o.j)(m,"A",s),Object(o.j)(a,"AT1",m),Object(o.j)(a,"AT2",p),e.outputConnection.targetConnection?e.outputConnection.targetConnection.connect(a.outputConnection):Object(o.d)(e,a),e.dispose()}}},function(e,t,n){var o=function(){function e(t){var n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:[];_classCallCheck(this,e),this.lhs_=t,this.rhsides_=n}return _createClass(e,[{key:"merge",value:function(e){var t,n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:1;console.assert(this.lhs_===e.lhs_,{msg:"This lhs of "+this.lhs_+" does not match node's lhs of "+e.lhs_}),this.rhsides_.lengtht.length?e:t}))}},{key:"getOppositeRules_",value:function(){var e=this,t={};return Object.keys(this.ruleSets_).forEach((function(n){Array.from(e.ruleSets_[n]).forEach((function(o){if(Array.isArray(o))if(1===o.length)e.addRule_(o[0],n,t);else{var i=n;o.slice(0,o.length-1).forEach((function(n,r){var a=o.length-r-1==1?o[0]:JSON.stringify(o.slice(0,o.length-r-1));e.addRule_(JSON.stringify([a,o[o.length-r-1]]),i,t),i=a}))}else e.addRule_(o,n,t)}))})),t}},{key:"getUnitRules_",value:function(e,t,n){for(var o=[],r=e,a=function(e){var n=[];r.forEach((function(e){t[e.rootLHS]&&Array.from(t[e.rootLHS]).filter((function(t){return t!==e.rootLHS})).forEach((function(t){return n.push(new i(t,[e]))}))})),o.push.apply(o,n),r=n},l=0;l0;l++)a();return o}},{key:"parseBottomUpCYK",value:function(e,t){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:"statement";if(""===e)return[];Object.values(this.ruleSets_).reduce((function(e,t){return e+t.size}),0);var o=this.lexer_.tokenize(e),a=this.maxPathLengthToTerminalOrSplit_("statement"),l=this.getOppositeRules_();console.warn("TOKEN ARRAY:",o,a.length);for(var s=[o.map((function(e){return Array.from(l[e.value]||[]).concat(e.tokenType).filter((function(e,t,n){return n.indexOf(e)===t})).map((function(t){return new i(t,e.value)}))}))],u=0;ul-a+1)return[];if("string"==typeof n&&t.isTerminal_(n)){if(a!==l)return[];var u=t.getRHSOfTokenMatch_(n,o[a]);return u?[{lhs:n,rhs:[u]}]:[]}if("string"==typeof n)return t.flattenOneLevel_(Array.from(t.ruleSets_[n]).map((function(t){var o=i.compute(e,[t,a,l,s-1],0);return o.some((function(e){return e.length!==t.length}))?(console.log("throwing out",n,JSON.stringify(o),t),console.log("problem",t,o,o.find((function(e){return e.length!==t.length}))),null):o.map((function(e){return{lhs:n,rhs:e}}))})).filter((function(e){return e})));if(n instanceof Array&&1===n.length){var c=i.compute(e,[n[0],a,l,s]);return c.length>0?c.map((function(e){return[e]})):[]}for(var g=[],d=a;d0){var p=i.compute(e,[n.slice(1),d+1,l,r.length]);p.length>0&&g.push.apply(g,_toConsumableArray(t.joinEachItemToFront_(h,p)))}}return g}),["statement",0,o.length-1,r.length]);return i.clear(),a}}]),e}()},function(e,t,n){var o=function(){function e(){_classCallCheck(this,e)}return _createClass(e,null,[{key:"interpolateMsg_",value:function(e,t){for(var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},o=e,i=0;/{[^}]+}/.test(o)&&i<5;)o=o.replace(/{[^}]+}/g,(function(e){var o=e.substring(1,e.length-1),i=o.split("."),r={T2C:T2C,options:n,feedbackItem:t}[i[0]];return r?i.slice(1).reduce((function(e,t){return e[t]}),r):null!=n[o]?n[o]:t[o]})),i++;return o}},{key:"getFeedback",value:function(t,n,o){var i={block:Blockly.Block,field:Blockly.Field},r=t.map((function(e){return{msgArr:[]}}));return n.forEach((function(n){var a=[];if("id"===n.selectType){var l=t.findIndex((function(e){return e.id===n.id}));-1!==l&&a.push({index:l,item:t[l]})}else if("expected"===n.selectType)t.forEach((function(e,o){(e.expected===n.expected||"function"==typeof n.expected&&n.expected(e.expected))&&a.push({index:o,item:t[o]})}));else if(Object.keys(i).includes(n.selectType)){var s=i[n.selectType];t.forEach((function(e,n){e.match instanceof s&&e.match.type&&a.push({index:n,item:t[n]})}))}if("error"===n.showType?a=a.filter((function(e){return e.item.hasError})):"correct"===n.showType&&(a=a.filter((function(e){return!e.item.hasError}))),"string"===n.outputType)a.forEach((function(i){return r[i.index].msgArr.push(e.interpolateMsg_(n.msg,t[i.index],o))}));else if("function"===n.outputType){var u=o[n.msg]||n.msg;"function"==typeof u&&a.forEach((function(e){return r[e.index].msgArr.push(u(t[e.index],t,o))}))}})),r}},{key:"displayFeedback",value:function(t,n,o){var i=e.getFeedback(t,n,o),r=t.map((function(e){return e.match||e.remaining})).map((function(e){return e instanceof Blockly.Block||!e?e:e.getSourceBlock&&e.getSourceBlock()})),a=[],l=[];r.forEach((function(e,n){if(e instanceof Blockly.Block){var o=a.indexOf(e);-1!==o?(l[o].indexArr.push(n),l[o].feedbackMsgArr.push(i[n].msgArr),l[o].hasCorrectItem=l[o].hasCorrectItem||!t[n].hasError,l[o].hasErrorItem=l[o].hasErrorItem||t[n].hasError,l[o].isMatchComplete=l[o].isMatchComplete&&t[n].isMatchComplete):(a.push(e),l.push({block:e,indexArr:[n],feedbackMsgArr:[i[n].msgArr],hasCorrectItem:!t[n].hasError,hasErrorItem:t[n].hasError,isMatchComplete:t[n].isMatchComplete}))}})),e.addFeedbackToBlocks(a,l.map((function(e){return e.feedbackMsgArr}))),l.forEach((function(t){var n=t.block;t.hasErrorItem&&!t.hasCorrectItem?e.setBlockFeedbackColour(n,!1):!t.hasErrorItem&&t.hasCorrectItem?e.setBlockFeedbackColour(n,!0,t.isMatchComplete):e.restoreBlockFeedbackColour(n)}))}},{key:"addFeedbackToBlocks",value:function(e,t){e.length>0&&e[0].workspace.getAllBlocks().forEach((function(t){e.includes(t)||(t.setCommentText(""),t.setCommentText(null),null!=t.startColour&&t.setColour(t.startColour))})),e.forEach((function(e,n){var o=t[n].map((function(e){return e.join("\n")})).join("\n\n");if(""!==o.trim()){e.setCommentText(o.trim());var i=e.getCommentIcon().getBubbleSize(),r=i.width,a=i.height;a=Math.max(a,Math.ceil(30*o.trim().length*8/r)),e.getCommentIcon().setBubbleSize(r,a)}else e.setCommentText("")}))}},{key:"restoreBlockFeedbackColour",value:function(e){null!=e.startColour&&e.setColour(e.startColour)}},{key:"setBlockFeedbackColour",value:function(t,n){var o=arguments.length>2&&void 0!==arguments[2]&&arguments[2];t instanceof Blockly.Block&&(t.getCommentText()&&t.getCommentText().trim()||o?(null==t.startColour&&(t.startColour=t.getColour()),n?t.setColour("#080"):t.setColour("#800")):e.restoreBlockFeedbackColour(t))}}]),e}();t.a=o},,,,,,,,,function(e,t,n){n.r(t);var o=n(1),i=n(0),r=function(){function e(t,n){_classCallCheck(this,e),this.taskCondition_=t,this.directions_=n}return _createClass(e,[{key:"areDirectionsCompleted",value:function(){return this.directions_.isComplete()}},{key:"startDirections",value:function(){this.directions_.start()}},{key:"finish",value:function(){this.directions_.finish instanceof Function&&this.directions_.finish()}},{key:"showDirectionStep",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:1;this.directions_.animate(e)}},{key:"isTaskCompleted",value:function(){return this.taskCondition_()}}]),e}(),a=function(){function e(t,n){_classCallCheck(this,e),this.obj_=t,this.options_=n}return _createClass(e,[{key:"start",value:function(){this.numOfMoves_=0,this.totalSteps_=this.value_(this.options_.totalSteps),this.startPosition_=this.value_(this.options_.startPosition),this.endPosition_=this.value_(this.options_.endPosition)||{x:this.startPosition_.x+this.value_(this.options_.velocity).x*this.totalSteps_,y:this.startPosition_.y+this.value_(this.options_.velocity).y*this.totalSteps_},this.velocity_={x:(this.endPosition_.x-this.startPosition_.x)/this.totalSteps_,y:(this.endPosition_.y-this.startPosition_.y)/this.totalSteps_},this.obj_.style.left=this.startPosition_.x+"px",this.obj_.style.top=this.startPosition_.y+"px"}},{key:"isComplete",value:function(){return this.numOfMoves_>=this.totalSteps_}},{key:"finish",value:function(){this.options_.finish instanceof Function&&this.options_.finish()}},{key:"animate",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:1,t=Math.min(e,this.totalSteps_-this.numOfMoves_);this.obj_.style.left=parseFloat(this.obj_.style.left)+this.velocity_.x*t+"px",this.obj_.style.top=parseFloat(this.obj_.style.top)+this.velocity_.y*t+"px",this.numOfMoves_+=e}},{key:"value_",value:function(e){return e instanceof Function?e():e}}]),e}(),l=function(){function e(t,n){_classCallCheck(this,e),this.obj_=t,this.options_=n,this.container_=this.options_.container||document.body}return _createClass(e,[{key:"start",value:function(){this.numOfSteps_=0,this.totalSteps_=this.value_(this.options_.totalSteps),this.startPosition_=this.value_(this.options_.startPosition),this.toggleSteps_=this.value_(this.options_.toggleSteps),this.options_.addAtStart&&this.container_.appendChild(this.obj_),this.obj_.style.left=this.startPosition_.x+"px",this.obj_.style.top=this.startPosition_.y+"px"}},{key:"isComplete",value:function(){return this.numOfSteps_>=this.totalSteps_}},{key:"animate",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:1,t=Math.min(e,this.totalSteps_-this.numOfSteps_);this.obj_.style.display=this.numOfSteps_%(2*this.toggleSteps_)0&&void 0!==arguments[0]?arguments[0]:1;this.animations_.filter((function(e){return!e.isComplete()})).forEach((function(t){return t.animate(e)}))}}]),e}(),c=function(){function e(){_classCallCheck(this,e),this.tasks_=[]}return _createClass(e,[{key:"addTask",value:function(e){this.tasks_.push(e)}},{key:"runTasks",value:function(e,t){var n=this;this.tasks_.length;var o=0,i=null!=e?e+","+t:null,r=i?localStorage.getItem(i):0;r&&confirm("Would you like to resume from the task you last completed?")&&(o=Math.max(parseInt(r),0));var a=0;this.tasks_[o].startDirections();requestAnimationFrame((function e(t){t-a>=5&&(n.tasks_[o].areDirectionsCompleted()||n.tasks_[o].isTaskCompleted()?n.tasks_[o].isTaskCompleted()&&(n.tasks_[o].finish(),++o2&&void 0!==arguments[2]?arguments[2]:0,o=this.tabs_.filter((function(t){return t.title===e}))[n];return o&&(console.log("Changing tab ",o,"with title",e,"#",n),o.display.innerText=e,o.message=t,console.log("Tab is now",o)),!!o}},{key:"changeTab",value:function(e,t,n){var o=this.tabs_.find((function(t){return t.id===e}));return o&&(console.log("Changing tab",o,"with id",e),o.title=t,o.display.innerText=t,o.message=n,console.log("Tab is now",o)),!!o}},{key:"setSelectedTab",value:function(e){var t=this.tabs_.find((function(t){return t.id===e}));return console.log("Setting tab to",t),t&&(this.currentTab_&&(this.currentTab_.display.style.backgroundColor="rgba(200, 200, 200, 0.5)",this.currentTab_.display.style.removeProperty("font-weight")),t.display.style.backgroundColor="rgba(127, 122, 110, 0.5)",t.display.style.fontWeight="bold",t.display.innerText=t.title,this.currentTab_=t),!!t}},{key:"start",value:function(){document.getElementById("message_console_manager_container")?this.show():document.body.appendChild(this.container_),this.started_=!0}},{key:"show",value:function(){this.container_.style.display="block"}},{key:"hide",value:function(){this.container_.style.display="none"}},{key:"isComplete",value:function(){return!1}},{key:"finish",value:function(){var e=this;this.tabs_.map((function(e){return e.display})).forEach((function(t){return e.tabContainer_.removeChild(t)})),this.container_.removeChild(this.msgDisplay_),this.container_.removeChild(this.tabContainer_),this.providedContainer_||document.body.removeChild(this.container_),"function"==typeof this.options_.finish&&this.options_.finish()}},{key:"animate",value:function(){var e=this,t=this.tabs_.map((function(t){return e.value_(t.message)}));this.tabs_.filter((function(n,o){return e.currentTab_!==n&&t[o]&&n.currentMessage!==t[o]&&!n.display.innerText.trim().endsWith("*")})).forEach((function(e){return e.display.innerText+="*"})),this.tabs_.forEach((function(e,n){return e.currentMessage=t[n]})),this.msgDisplay_.innerText=this.currentTab_.currentMessage}},{key:"value_",value:function(e){return e instanceof Function?e():e}}]),e}(),d=function(){function e(t){var n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};_classCallCheck(this,e),this.blockName_=t,this.possibleMatches_=[],this.possibleErrorFunctions_=[],this.currentExp_="",this.hasUnknownError_=!1,this.options_=n,this.standardErrorMessages={EXTRA_AT_END:function(e,t,n){return T2C.MSG.currentLanguage.TYPEIN_ERROR_REMOVE_EXTRA_AT_END.replace("%1",n)},MISTYPED_TERMINAL:function(e,t,n){return T2C.MSG.currentLanguage.TYPEIN_ERROR_TERMINAL_MISTYPED.replace("%1",T2C.MSG.currentLanguage["TERMINAL_"+e.toUpperCase()]||e)},MISSING_OPEN_PARENTHESIS:function(e,t,n){return T2C.MSG.currentLanguage.TYPEIN_ERROR_MISSING_OPEN_PARENTHESIS.replace("%1",t[e])},MISSING_OPEN_BRACKET:function(e,t,n){return T2C.MSG.currentLanguage.TYPEIN_ERROR_MISSING_OPEN_BRACKET.replace("%1",t[e])},MISSING_CLOSE_PARENTHESIS:function(e,t,n){return T2C.MSG.currentLanguage.TYPEIN_ERROR_MISSING_CLOSE_PARENTHESIS.replace("%1",t[e])},MISSING_CLOSE_BRACKET:function(e,t,n){return T2C.MSG.currentLanguage.TYPEIN_ERROR_MISSING_CLOSE_BRACKET.replace("%1",t[e])},MISSING_PERIOD_AFTER_VARIABLE:function(e,t,n){return T2C.MSG.currentLanguage.TYPEIN_ERROR_MISSING_PERIOD_AFTER_VARIABLE.replace("%1",t[e])},UNNECESSARY_OPEN_PARENTHESIS:function(e,t,n){return T2C.MSG.currentLanguage.TYPEIN_WARNING_UNNECESSARY_OPEN_PARENTHESIS.replace("%1",t[e])},UNKNOWN:function(e,t,n){return T2C.MSG.currentLanguage.TYPEIN_UNKNOWN_ERROR.replace("%1",t[e])}}}return _createClass(e,[{key:"oneStartsWithOther_",value:function(e,t){var n=arguments.length>2&&void 0!==arguments[2]&&arguments[2],o=n?e:e.toLowerCase(),i=n?t:t.toLowerCase();return o.startsWith(i)||i.startsWith(o)}},{key:"getAfterTerminal_",value:function(e,t){var n=this;String.prototype.JSSubstring=function(e,t){return e>=this.length||e===t?"":this.substring(e,t)};var o=Object.values(T2C.MSG).map((function(e){return e["TERMINAL_"+t.toUpperCase()]})).filter((function(e){return"string"==typeof e})).find((function(t){return n.oneStartsWithOther_(t,e,!0)}));if("string"==typeof o)return{terminal:o,remaining:e.JSSubstring(o.length).trim()}}},{key:"getTerminalIndexForSymbol_",value:function(e,t){if(-1!==["[","(","."].indexOf(e[t]))return t-1;if(-1!==[")","]"].indexOf(e[t])){for(var n=[],o=0;o1&&void 0!==arguments[1])||arguments[1],n=document.getElementById("alert-display");n||((n=document.createElement("div")).id="alert-display",n.style.fontSize="small",n.style.fontWeight="bold",n.style.borderColor="#000",n.style.backgroundColor="rgba(200, 200, 200, 0.5)",n.style.color="#f00",n.style.position="absolute",n.style.zIndex="1050",n.style.width="98%",n.style.minHeight="50px",n.style.left="0",n.style.bottom="0",n.style.textAlign="left",n.style.padding="1%",document.body.appendChild(n)),t?n.innerText=e:n.innerText+=e}},{key:"matchStatement_",value:function(e,t){for(var n=void 0,o=void 0,i=[],r=e,a=!1,l=-1;l1&&void 0!==arguments[1])||arguments[1];return(n&&this.possibleMatches_||this.addNoExtraMatches_()).find((function(n){var o=t.matchStatement_(e,n),i=o.match;o.error,o.remainingText;return o.isMatchComplete&&n.length===i.length}))}},{key:"generateErrorFunction",value:function(e,t,n){var o=this,i=t[n];if(e instanceof Function)return e;if("string"==typeof e)return function(){return e};if(e&&"GENERIC_MESSAGE"===e.type)return e.args=Array.isArray(e.args)?e.args:[],function(t,n){var i;return(i=o.standardErrorMessages)[e.value].apply(i,_toConsumableArray(e.args).concat([t,n]))};var r="UNKNOWN",a=[];if(i&&"string"==typeof i){var l=["(","[",")","]","."].indexOf(i);-1!==l&&(r=["MISSING_OPEN_PARENTHESIS","MISSING_OPEN_BRACKET","MISSING_CLOSE_PARENTHESIS","MISSING_CLOSE_BRACKET","MISSING_PERIOD_AFTER_VARIABLE"][l],a.push(this.getTerminalIndexForSymbol_(t,n)))}return(i.type&&"TERMINAL"===i.type.toUpperCase()||this.equalsTerminal_(i))&&(r="MISTYPED_TERMINAL",a.push(i.type?i.token:i)),function(e,t){var n;return"UNKNOWN"===r&&i&&"string"==typeof i&&!i.startsWith("(")&&t.startsWith("(")&&(r="UNNECESSARY_OPEN_PARENTHESIS"),(n=o.standardErrorMessages)[r].apply(n,a.concat([e,t]))}}},{key:"equalsTerminal_",value:function(e){return Object.values(T2C.MSG).find((function(t){return Object.keys(t).find((function(n){return n.toUpperCase().startsWith("TERMINAL_")&&t[n]===e}))}))}},{key:"setCurrentExp",value:function(e){this.currentExp_=e}},{key:"addPossibleMatch",value:function(e,t){var n=this;this.possibleMatches_.push(e),this.possibleErrorFunctions_.push(t.map((function(t,o){return n.generateErrorFunction(t,e,o)})))}},{key:"addAllPossibleLanguageMatches",value:function(e,t){var n=this;Object.values(T2C.MSG).map((function(t){return e.map((function(e){return e&&"terminal"===e.type?"string"==typeof t["TERMINAL_"+e.token.toUpperCase()]?t["TERMINAL_"+e.token.toUpperCase()]:e.token:e}))})).forEach((function(e){n.addPossibleMatch(e,t)}))}},{key:"addNoExtraMatches_",value:function(e){return(e=e||this.possibleMatches_).map((function(e){return e.concat({type:"regexp",token:/^$/})}))}},{key:"addNoExtraErrorMessages_",value:function(e){var t=this;return(e=e||this.possibleErrorFunctions_).map((function(e){return e.concat((function(e,n){return t.standardErrorMessages.EXTRA_AT_END("",e,n)}))}))}},{key:"getErrorFeedback",value:function(e){var t=this;e="string"==typeof e?e:this.currentExp_;var n=this.addNoExtraMatches_().reduce((function(e,n,o){var i=t.matchStatement_(t.currentExp_,n);return i.pattern=n,i.index=o,i.error&&!e.error?e:!i.error&&e.error||0===e.pattern.length||i.match.filter((function(e){return e})).length>e.match.filter((function(e){return e})).length?i:e}),{pattern:[],match:[],error:!0,remainingText:this.currentExp_,index:-1});return n.error?this.addNoExtraErrorMessages_()[n.index][n.match.length](n.match,n.remainingText):this.hasUnknownError_?T2C.MSG.currentLanguage.TYPEIN_UNKNOWN_ERROR:""}},{key:"getCodeGeneratorForLanguage",value:function(e,t){var n=this;return function(o){for(var i=o.getFieldValue("EXP"),r=0,a=function(){var o=T2C.MSG[e],a=n.possibleMatches_[r],l=n.matchStatement_(i,a),s=l.match,u=(l.error,l.remainingText),c=l.isMatchComplete;if(a.length===s.length&&!u&&c){var g=s.map((function(e,t){var i=a[t];if(i&&"terminal"===i.type)return"string"==typeof o["TERMINAL_"+i.token.toUpperCase()]?o["TERMINAL_"+i.token.toUpperCase()]:i.token;if("string"==typeof i&&n.equalsTerminal_(i)){var r=n.equalsTerminal_(i),l=Object.keys(r).find((function(e){return e.toUpperCase().startsWith("TERMINAL_")&&r[e]===i}));return l?o[l]:i}return e})).join("");return{v:t?(g.endsWith(T2C.MSG[e].STATEMENT_SEPARATOR)?g:g+T2C.MSG[e].STATEMENT_SEPARATOR)+"\n":[g,Blockly[T2C.MSG[e].LANGUAGENAME].ORDER_NONE]}}++r};r0&&void 0!==arguments[0]?arguments[0]:{},t=this;Blockly.Python[this.blockName_]=this.getCodeGeneratorForLanguage("PY",!e.isExpression),Blockly.JavaScript[this.blockName_]=this.getCodeGeneratorForLanguage("JS",!e.isExpression),Blockly.Blocks[this.blockName_]={validate:function(e){var n=this.getSourceBlock(),o=t.possibleMatches_.reduce((function(n,o,i){var r=t.matchStatement_(e,o);return r.pattern=o,r.index=i,r.error&&!n.error?n:!r.error&&n.error||0===n.pattern.length||r.match.filter((function(e){return e})).length>n.match.filter((function(e){return e})).length?r:n}),{pattern:[],match:[],error:!0,remainingText:e,index:-1});if(t.setCurrentExp(e),o.error)console.log("ERROR",o),n.setColour("#800");else{if(!t.hasFullMatch(e,!1))return n.setColour(60),e;n.setColour("#080")}return o.error?o.match.join(""):e},init:function(){var n=this;this.appendDummyInput("STRING").appendField(new Blockly.FieldTextInput("",this.validate),"EXP"),this.setInputsInline(!1),this.setOutput(e.isExpression),this.setPreviousStatement(!e.isExpression),this.setNextStatement(!e.isExpression),this.setColour(60),this.setTooltip(T2C.MSG.currentLanguage.TYPEIN_STATEMENT_TOOLTIP),this.onchange=function(e){var i=n.getFieldValue("EXP"),r=t.hasFullMatch(i,!1);if(Blockly.selected!==n&&(t.setCurrentExp(i),n.setColour(r?"#080":60)),t.hasUnknownError_=!1,i.length>0&&"workspaceClick"===e.element&&r){if(t.options_.collapseWhenFinished)return n.setCollapsed(!0);var a=Object(o.getParseTree)(n.getFieldValue("EXP"));a?Object(o.handleParseTreeToBlocks)(a,n):t.hasUnknownError_=!0}}}}}}]),e}(),h=n(3),p=function(){function e(t){_classCallCheck(this,e),this.state_={},this.courseInstructionTaskFlow_=t}return _createClass(e,[{key:"loadLevelTasks",value:function(e,t){var n=e||new c,o=t||Blockly.getMainWorkspace();return new ToolboxManager(o),this.helpMsgManager_.start(),n}},{key:"createStandardHelpMessageManager",value:function(){var e=new g;return e.addTab(T2C.MSG.currentLanguage.DIRECTIONS,""),e.addTab(T2C.MSG.currentLanguage.FEEDBACK,""),e}},{key:"createHelpMessageDirections",value:function(e,t,n,o){return{start:function(){var o=e.getTabIdByTitle(T2C.MSG.currentLanguage.DIRECTIONS);e.setTabHandlerByTitle(T2C.MSG.currentLanguage.DIRECTIONS,t),e.setTabHandlerByTitle(T2C.MSG.currentLanguage.FEEDBACK,n),e.start(),e.setSelectedTab(o)},isComplete:function(){return!1},animate:function(t){return e.animate(t)},finish:function(){"function"==typeof o&&o()}}}},{key:"createHelpMessageTask",value:function(e,t,n,o,i){return new r("function"==typeof t?t:function(){return!0},this.createHelpMessageDirections(e,n,o,i))}},{key:"hideOutputAndCodeContainers",value:function(){document.getElementById("output-container").classList.remove("show-container"),document.getElementById("output-container").classList.add("hide-container"),document.getElementById("text-code-container").classList.remove("show-container"),document.getElementById("text-code-container").classList.add("hide-container")}},{key:"addHelpMessageTask",value:function(e,t,n,o,i,r){e.addTask(this.createHelpMessageTask(t,n,o,i,r))}},{key:"addMoveAndFlashTask",value:function(e,t,n){var o=this,i=0;function a(){t.style.color=i%50<25?"#a00":"#000",++i<200&&requestAnimationFrame(a)}e.addTask(new r((function(){return i>=200}),{start:function(){t.style.verticalAlign="top",requestAnimationFrame(a)},isComplete:function(){return!0},animate:function(){return!0},finish:function(){"function"==typeof n&&n(),function(e){e.style.verticalAlign="middle",e.style.color="#000"}(t),o.hideOutputAndCodeContainers()}}))}},{key:"createPointer",value:function(){var e=document.createElement("div");return e.innerText="👆",e.id="ptr",e.style.fontSize="x-large",e.style.position="absolute",e.style.zIndex="1001",e}},{key:"setMaxesFromWorkspace",value:function(e){var t=e.options.maxInstances;e.options.maxInstances={},e.getAllBlocks().forEach((function(t){e.options.maxInstances[t.type]=++e.options.maxInstances[t.type]||1})),Object.keys(t).forEach((function(n){e.options.maxInstances[n]=e.options.maxInstances[n]||t[n]}))}},{key:"addRunTask",value:function(e,t,n,o){var i=!(arguments.length>4&&void 0!==arguments[4])||arguments[4];t.addTask(new r((function(){return document.getElementById("output-container").classList.contains("show-container")}),new u([this.createHelpMessageDirections(e,T2C.MSG.currentLanguage.BUTTON_RUN_CODE,""),new l(o||this.createPointer(),{totalSteps:100,toggleSteps:25,startPosition:{x:document.getElementById("run-code-button").offsetLeft+document.getElementById("run-code-button").offsetWidth/2,y:document.getElementById("run-code-button").offsetTop+document.getElementById("run-code-button").offsetHeight/2},container:document.getElementById("blockly-div"),addAtStart:!o,removeAtEnd:!o})]))),i&&this.addMoveAndFlashTask(t,document.getElementById("output-container").querySelectorAll(".table-cell")[0],n)}},{key:"addDeleteAllBlocksTask",value:function(e,t,n,o,i){t.addTask(new r((function(){return 0===n.getAllBlocks().length}),new u([this.createHelpMessageDirections(e,(function(){return"Move all blocks to the trashcan or rightmouse click (hold down finger on phone) on an empty place in the workspace and select Delete."}),""),new l(i||this.createPointer(),{totalSteps:100,toggleSteps:25,startPosition:function(){var e=n.trashcan.getClientRect();return{x:(e.left+e.right)/2,y:(e.top+e.bottom)/2}}})])))}},{key:"addLoadSaveListeners_",value:function(e){var t=this,n=arguments.length>1&&void 0!==arguments[1]&&arguments[1];n&&(this.state_.clickedLoadButtonLast=!1,this.state_.clickedSaveButtonLast=!1,this.state_.clickedLoadXMLButtonLast=!1,this.state_.clickedSaveXMLButtonLast=!1,this.state_.clickedLoadTextCodeButtonLast=!1,this.state_.clickedSaveTextCodeButtonLast=!1,this.state_.generatedTextCode=Object(o.workspaceToLanguageCode)(e,T2C.MSG.currentLanguage),this.state_.generatedXMLText=Object(o.workspaceToXML)(e)),this.state_.listeners=[{id:"load-code-button",listener:function(){t.state_.clickedLoadButtonLast=!0,t.state_.clickedSaveButtonLast=!1,t.state_.clickedLoadXMLButtonLast=!1,t.state_.clickedSaveXMLButtonLast=!1,t.state_.clickedLoadTextCodeButtonLast=!1,t.state_.clickedSaveTextCodeButtonLast=!1}},{id:"save-code-button",listener:function(){t.state_.clickedLoadButtonLast=!1,t.state_.clickedSaveButtonLast=!0,t.state_.clickedLoadXMLButtonLast=!1,t.state_.clickedSaveXMLButtonLast=!1,t.state_.clickedLoadTextCodeButtonLast=!1,t.state_.clickedSaveTextCodeButtonLast=!1}},{id:"load-save-text-code",listener:function(){t.state_.clickedLoadButtonLast?t.state_.clickedLoadTextCodeButtonLast=!0:t.state_.generatedTextCode.replace(/\s/g,"")!==document.getElementById("textCodeBox").value.replace(/\s/g,"")?alert("Workspace or selected language changed, please restore what you originally had before saving"):t.state_.clickedSaveTextCodeButtonLast=!0}},{id:"load-save-xml",listener:function(){t.state_.clickedLoadButtonLast?t.state_.clickedLoadXMLButtonLast=!0:t.state_.generatedTextCode.replace(/\s/g,"")!==document.getElementById("textCodeBox").value.replace(/\s/g,"")?alert("Workspace or selected language changed, please restore what you originally had before saving"):(t.state_.generatedXMLText=Object(o.workspaceToXML)(e),t.state_.clickedSaveXMLButtonLast=!0)}}],this.state_.listeners.forEach((function(e){return document.getElementById(e.id).addEventListener("click",e.listener)}))}},{key:"removeLoadSaveListeners_",value:function(){return this.state_.listeners.forEach((function(e){return document.getElementById(e.id).removeEventListener("click",e.listener)})),!0}},{key:"createAddSaveListenersDirections_",value:function(e){var t=this,n=arguments.length>1&&void 0!==arguments[1]&&arguments[1];return{start:function(){t.addLoadSaveListeners_(e,n)},isComplete:function(){return!0},animate:function(){return!0}}}},{key:"addSaveXMLTask",value:function(e,t,n,o,i,a){var s=this;t.addTask(new r((function(){return s.state_.clickedSaveButtonLast}),new u([this.createAddSaveListenersDirections_(n,a),this.createHelpMessageDirections(e,(function(){return T2C.MSG.currentLanguage.BUTTON_SAVE_XML}),""),new l(i||this.createPointer(),{totalSteps:100,toggleSteps:25,startPosition:{x:document.getElementById("save-code-button").offsetLeft+document.getElementById("save-code-button").offsetWidth/2,y:document.getElementById("save-code-button").offsetTop+document.getElementById("save-code-button").offsetHeight/2},container:document.getElementById("blockly-div"),addAtStart:!i,removeAtEnd:!i})]))),t.addTask(new r((function(){return s.state_.clickedSaveXMLButtonLast&&s.removeLoadSaveListeners_()}),new u([this.createHelpMessageDirections(e,(function(){return T2C.MSG.currentLanguage.BUTTON_SAVE_XML}),""),new l(i||this.createPointer(),{totalSteps:100,toggleSteps:25,startPosition:function(){return{x:document.getElementById("load-save-xml").offsetLeft+document.getElementById("load-save-xml").offsetWidth/2,y:document.getElementById("load-save-xml").offsetTop+document.getElementById("load-save-xml").offsetHeight/2}},container:document.getElementById("blockly-div"),addAtStart:!i,removeAtEnd:!i})])))}},{key:"addLoadXMLTask",value:function(e,t,n,o,i,a){var s=this;t.addTask(new r((function(){return s.state_.clickedLoadButtonLast}),new u([this.createAddSaveListenersDirections_(n,a),this.createHelpMessageDirections(e,(function(){return T2C.MSG.currentLanguage.BUTTON_LOAD_XML}),""),new l(i||this.createPointer(),{totalSteps:100,toggleSteps:25,startPosition:{x:document.getElementById("load-code-button").offsetLeft+document.getElementById("load-code-button").offsetWidth/2,y:document.getElementById("load-code-button").offsetTop+document.getElementById("load-code-button").offsetHeight/2},container:document.getElementById("blockly-div"),addAtStart:!i,removeAtEnd:!i})]))),t.addTask(new r((function(){return s.state_.generatedXMLText.replace(/\n|\r/g,"")===document.getElementById("xmlData").value.replace(/\n|\r/g,"")}),new u([this.createHelpMessageDirections(e,(function(){return"Paste the XML you copied in this text box."}),""),new l(i||this.createPointer(),{totalSteps:100,toggleSteps:25,startPosition:function(){return{x:document.getElementById("xmlData").offsetLeft+document.getElementById("xmlData").offsetWidth/2,y:document.getElementById("xmlData").offsetTop+document.getElementById("xmlData").offsetHeight/2}},container:document.getElementById("blockly-div"),addAtStart:!i,removeAtEnd:!i})]))),t.addTask(new r((function(){return s.state_.generatedXMLText.replace(/\n|\r/g,"")===document.getElementById("xmlData").value.replace(/\n|\r/g,"")&&s.state_.clickedLoadXMLButtonLast&&s.removeLoadSaveListeners_()}),new u([this.createHelpMessageDirections(e,(function(){return T2C.MSG.currentLanguage.BUTTON_LOAD_XML}),""),new l(i||this.createPointer(),{totalSteps:100,toggleSteps:25,startPosition:function(){return{x:document.getElementById("load-save-xml").offsetLeft+document.getElementById("load-save-xml").offsetWidth/2,y:document.getElementById("load-save-xml").offsetTop+document.getElementById("load-save-xml").offsetHeight/2}},container:document.getElementById("blockly-div"),addAtStart:!i,removeAtEnd:!i})])))}},{key:"addSaveTextCodeTask",value:function(e,t,n,o,i,a){var s=this;t.addTask(new r((function(){return s.state_.clickedSaveButtonLast}),new u([this.createAddSaveListenersDirections_(n,a),this.createHelpMessageDirections(e,(function(){return T2C.MSG.currentLanguage.BUTTON_SAVE_TEXT_CODE}),""),new l(i||this.createPointer(),{totalSteps:100,toggleSteps:25,startPosition:{x:document.getElementById("save-code-button").offsetLeft+document.getElementById("save-code-button").offsetWidth/2,y:document.getElementById("save-code-button").offsetTop+document.getElementById("save-code-button").offsetHeight/2},container:document.getElementById("blockly-div"),addAtStart:!i,removeAtEnd:!i})]))),t.addTask(new r((function(){return s.state_.clickedSaveTextCodeButtonLast&&s.removeLoadSaveListeners_()}),new u([this.createHelpMessageDirections(e,(function(){return T2C.MSG.currentLanguage.BUTTON_SAVE_TEXT_CODE}),""),new l(i||this.createPointer(),{totalSteps:100,toggleSteps:25,startPosition:function(){return{x:document.getElementById("load-save-text-code").offsetLeft+document.getElementById("load-save-text-code").offsetWidth/2,y:document.getElementById("load-save-text-code").offsetTop+document.getElementById("load-save-text-code").offsetHeight/2}},container:document.getElementById("blockly-div"),addAtStart:!i,removeAtEnd:!i})])))}},{key:"addLoadTextCodeTask",value:function(e,t,n,o,i,a){var s=this;t.addTask(new r((function(){return s.state_.clickedLoadButtonLast}),new u([this.createAddSaveListenersDirections_(n,a),this.createHelpMessageDirections(e,(function(){return T2C.MSG.currentLanguage.BUTTON_LOAD_TEXT_CODE}),""),new l(i||this.createPointer(),{totalSteps:100,toggleSteps:25,startPosition:{x:document.getElementById("load-code-button").offsetLeft+document.getElementById("load-code-button").offsetWidth/2,y:document.getElementById("load-code-button").offsetTop+document.getElementById("load-code-button").offsetHeight/2},container:document.getElementById("blockly-div"),addAtStart:!i,removeAtEnd:!i})]))),t.addTask(new r((function(){return s.state_.generatedTextCode.replace(/\n|\r/g,"")===document.getElementById("textCodeBox").value.replace(/\n|\r/g,"")}),new u([this.createHelpMessageDirections(e,(function(){return"Paste the code you copied in this text box."}),""),new l(i||this.createPointer(),{totalSteps:100,toggleSteps:25,startPosition:function(){return{x:document.getElementById("textCodeBox").offsetLeft+document.getElementById("textCodeBox").offsetWidth/2,y:document.getElementById("textCodeBox").offsetTop+document.getElementById("textCodeBox").offsetHeight/2}},container:document.getElementById("blockly-div"),addAtStart:!i,removeAtEnd:!i})]))),t.addTask(new r((function(){return s.state_.generatedTextCode.replace(/\n|\r/g,"")===document.getElementById("textCodeBox").value.replace(/\n|\r/g,"")&&s.state_.clickedLoadTextCodeButtonLast&&s.removeLoadSaveListeners_()}),new u([this.createHelpMessageDirections(e,(function(){return T2C.MSG.currentLanguage.BUTTON_LOAD_TEXT_CODE}),""),new l(i||this.createPointer(),{totalSteps:100,toggleSteps:25,startPosition:function(){return{x:document.getElementById("load-save-text-code").offsetLeft+document.getElementById("load-save-text-code").offsetWidth/2,y:document.getElementById("load-save-text-code").offsetTop+document.getElementById("load-save-text-code").offsetHeight/2}},container:document.getElementById("blockly-div"),addAtStart:!i,removeAtEnd:!i})])))}},{key:"mainCourseInstructionTaskFlow",set:function(e){this.courseInstructionTaskFlow_=e}}]),e}(),f=function(){function e(t){_classCallCheck(this,e),this.workspace_=t||Blocky.getMainWorkspace(),this.toolboxBlocks_=[],this.toolBoxDOM_=document.getElementById("toolbox")}return _createClass(e,[{key:"createBlockWithType_",value:function(e){var t=document.createElement("block");return t.setAttribute("type",e),t}},{key:"clearToolbox",value:function(){Array.from(this.toolBoxDOM_.children).forEach((function(e){return e.remove()})),this.workspace_.options.maxInstances={},this.workspace_.updateToolbox(document.getElementById("toolbox")),this.toolboxBlocks_=[]}},{key:"createToolboxBlock",value:function(e){var t=!(arguments.length>1&&void 0!==arguments[1])||arguments[1],n=this.createBlockWithType_(e);return t?(document.getElementById("toolbox").prepend(n),this.toolboxBlocks_.unshift(n)):(document.getElementById("toolbox").append(n),this.toolboxBlocks_.push(n)),this.workspace_.updateToolbox(document.getElementById("toolbox")),n}},{key:"setToolboxBlockFieldValue",value:function(e,t,n){var o=document.createElement("field");o.setAttribute("name",t),o.appendChild(document.createTextNode(n)),e.appendChild(o)}},{key:"setToolboxBlockInputValue",value:function(e,t,n){var o=document.createElement("value");o.setAttribute("name",t),o.appendChild(n),e.appendChild(o)}},{key:"removeToolboxBlocks",value:function(e){var t=this,n=this.toolboxBlocks_.map(e),o=this.toolboxBlocks_.filter(e);return n.forEach((function(e,n){e&&t.toolboxBlocks_[n].remove()})),this.toolboxBlocks_=this.toolboxBlocks_.filter((function(e,t){return!n[t]})),this.workspace_.updateToolbox(document.getElementById("toolbox")),console.log("Removing blocks",o),o}},{key:"removeToolboxBlocksWithType",value:function(e){return this.removeToolboxBlocks((function(t){return t.getAttribute("type")===e}))}},{key:"findToolboxBlock",value:function(e){return this.toolboxBlocks_.find(e)}},{key:"findToolboxBlockWithType",value:function(e){return this.findToolboxBlock((function(t){return t.getAttribute("type")===e}))}}]),e}(),m=n(14),y=function(){function e(){_classCallCheck(this,e)}return _createClass(e,null,[{key:"createBlock",value:function(e,t,n,o){var i={},r=Blockly.Blocks.code_statement_hybrid;return Object.keys(r).forEach((function(e){i[e]=r[e]})),i.init=function(){r.init.call(this),this.onchange,this.setMatchBlueprint(t),n&&this.setTextFeedbackManager(n),o&&this.setBlockFeedbackManager(o),["Python","JavaScript"].forEach((function(t){return Blockly[t][e]=Blockly[t].code_statement_hybrid}))},Blockly.Blocks[e]=i}}]),e}();function T(e,t){var n={};return Object.keys(e).forEach((function(t){return n[t]=e[t]})),Object.keys(t).forEach((function(e){return n[e]=t[e]})),n}T2C.MatchManagers={},T2C.MatchManagers.string_literal={getMatchResult:function(e,t){var n="string_literal",o=t.suffix||"",i=["'",'"'].map((function(e){var i="'"===e?"single":"double";if(t.exactText)return{id:n+"_"+i+"_text_"+o,type:"exact",value:t.exactText,partial:!0};if(t.nonEmptyText)return{id:n+"_"+i+"_text_"+o,type:"regexp",postfix:!0,tokenPartial:new RegExp("^[^"+e+"]*$"),token:new RegExp("^[^"+e+"]+")};if(t.endsWithText)return{id:n+"_"+i+"_text_"+o,type:"regexp",postfix:!0,tokenPartial:new RegExp("^[^"+e+"]*$"),token:new RegExp("^[^"+e+"]*"+(t.endsWithText.source||t.endsWithText)+"$","i")};var r=t.includeText?t.includeText.source||t.includeText:"";return{id:n+"_"+i+"_text_"+o,type:"regexp",postfix:!0,tokenPartial:new RegExp("^[^"+e+"]*$"),token:new RegExp("^[^"+e+"]*"+r+"^[^"+e+"]*","i")}})),r=i[0],a=i[1],l=void 0;if(t.exactText)l={id:n+"_block_text_"+o,type:"exact",value:t.exactText,partial:!0};else if(t.nonEmptyText)l={id:n+"_block_text_"+o,type:"regexp",postfix:!0,token:/[\s\S]+/};else if(t.endsWithText)l={id:n+"_block_text_"+o,type:"regexp",postfix:!0,token:new RegExp((t.endsWithText.source||t.endsWithText)+"$","i")};else{var s=t.includeText?t.includeText.source||t.includeText:"";l={id:n+"_block_text_"+o,type:"regexp",postfix:!0,token:new RegExp(s,"i")}}return t.textMode?h.a.getMatchResult(e,{id:18,type:"or",value:[{type:"Array",value:[{id:"string_literal_open_double",type:"exact",value:'"',postfix:!0},a,{id:"string_literal_close_double",type:"exact",value:'"',postfix:!0}]},{type:"Array",value:[{id:"string_literal_open_single",type:"exact",value:"'",postfix:!0},r,{id:"string_literal_close_single",type:"exact",value:"'",postfix:!0}]}]}):h.a.getMatchResult(e,{id:"string_literal_block",type:"block",value:{id:"string_literal_block_value",type:"text",inputs:[],fields:[{id:"string_literal_field",type:"field",name:"TEXT",value:l}]}})}},T2C.MatchManagers.display_string_literal={getMatchResult:function(e,t){t.displayText;var n=t.displayLanguage?{id:"display_string_literal_terminal",type:"exact",value:T2C.MSG[t.displayLanguage].TERMINAL_DISPLAY,partial:!0,postfix:!0}:{id:"display_string_literal_terminal",type:"terminal",token:"display"};return t.textMode?h.a.getMatchResult(e,{type:"Array",value:[n,{id:"display_string_literal_open_paren",type:"exact",value:"(",postfix:!0},{id:"display_string_literal_text",type:"component",name:"string_literal",value:T(t,{textMode:!0}),postfix:!0},{id:"display_string_literal_close_paren",type:"exact",value:")",postfix:!0},{id:"display_string_literal_semicolon",token:/^[;]*$/,type:"regexp"}]}):h.a.getMatchResult(e,{id:"display_string_literal_display_block",type:"block",value:{types:["text_print","js_text_print"],inputs:[{id:"display_string_literal_text_block",type:"input",name:"TEXT",value:{type:"component",name:"string_literal",value:T(t,{textMode:!1})}}],fields:[]}})}},T2C.MatchManagers.prompt_store_input={getMatchResult:function(e,t){var n=t.promptText||"",o=t.varName||"item",i=(new RegExp('^"[^"]*'+n+"[^\"]*\"|^'[^']*"+n+"[^']*'","i"),new RegExp("[sS]*"+n+"[sS]*","i"),t.promptLanguage?{id:13,type:"exact",value:T2C.MSG[t.promptLanguage].TERMINAL_GETINPUTBYASKING,partial:!0,postfix:!0}:{id:13,type:"terminal",token:"getInputByAsking"});return t.textMode?h.a.getMatchResult(e,{type:"Array",value:[{id:10,type:"terminal",token:"let"},{id:11,type:"exact",value:o,partial:!0,postfix:!0},{id:12,type:"exact",value:"=",partial:!0,postfix:!0},i,{id:14,type:"exact",value:"(",postfix:!0},{id:15,type:"component",name:"string_literal",value:{includeText:n,textMode:!0},postfix:!0},{id:16,type:"exact",value:")",postfix:!0},{id:17,token:/^[;]*$/,type:"regexp"}]}):h.a.getMatchResult(e,{id:0,type:"block",value:{type:"variables_set",inputs:[{id:1,type:"input",name:"VALUE",value:{id:2,type:"block",value:{types:["text_input","js_text_input"],inputs:[{id:3,type:"input",name:"TEXT",value:{type:"component",name:"string_literal",value:{includeText:n,textMode:!1}}}],fields:[]}}}],fields:[{id:8,type:"field",useText:!0,name:"VAR",value:{id:9,type:"exact",value:o}}]}})}},T2C.MatchManagers.code_statement_hybrid={getMatchResult:function(e,t){var n=t.matchManagerType,o=t.value,i="TEXT"===e.getFieldValue("MODE");return o.textMode=i,i?h.a.getMatchResult(e.getField("EXP"),{id:1e4,type:"field",name:"EXP",value:{type:"component",name:n,value:o}}):h.a.getMatchResult(e.getInputTargetBlock("EXP_STATEMENT"),{id:-1,type:"component",name:n,value:o})}},T2C.FeedbackManagers={},T2C.FeedbackManagers.default={errorFunctions:[{selectType:"expected",expected:"(",outputType:"function",showType:"error",msg:function(e,t,n){var o=t.indexOf(e);return T2C.MSG.currentLanguage.TYPEIN_ERROR_MISSING_OPEN_PARENTHESIS.replace("%1",t[h.a.getTerminalIndexForSymbol(t,o)].match)}},{selectType:"expected",expected:")",outputType:"function",showType:"error",msg:function(e,t,n){var o=t.indexOf(e);return T2C.MSG.currentLanguage.TYPEIN_ERROR_MISSING_CLOSE_PARENTHESIS.replace("%1",t[h.a.getTerminalIndexForSymbol(t,o)].match)}},{selectType:"expected",expected:function(e){return e&&e.source===/^[;]*$/.source},outputType:"function",showType:"error",msg:function(e,t,n){var o=(null!=e.remaining?e.remaining.toString():"").match(/^[;]*/)[0].length;return T2C.MSG.currentLanguage.TYPEIN_ERROR_REMOVE_EXTRA_AT_END.replace("%1","string"==typeof e.remaining&&e.remaining.substring(o))}},{selectType:"expected",expected:function(e,t,n){return h.a.equalsTerminal(e)},outputType:"function",showType:"error",msg:function(e,t,n){return t.indexOf(e),T2C.MSG.currentLanguage.TYPEIN_ERROR_TERMINAL_MISTYPED.replace("%1",h.a.getExpected(e))}}]},T2C.FeedbackManagers.string_literal={DEFAULT_MISSING_OPEN_SINGLE_QUOTE_MSG:"The message to supply to the user should be surrounded by ' and ' because you want it to be displayed as is.",DEFAULT_MISSING_OPEN_DOUBLE_QUOTE_MSG:'The message to supply to the user should be surrounded by " and " because you want it to be displayed as is.',DEFAULT_WRONG_BLOCK_MSG:"This is not the correct block to place here.",DEFAULT_MISSING_PHRASE_ERROR_MSG:"The message to the user should contain {feedbackItem.expected.value}.",errorFunctions:[{selectType:"id",id:"string_literal_open_double",outputType:"function",showType:"error",msg:"stringLiteralMissingOpenDouble"},{selectType:"id",id:"string_literal_open_single",outputType:"function",showType:"error",msg:"stringLiteralMissingOpenSingle"},{selectType:"id",id:"string_literal_single_text_",outputType:"function",showType:"error",msg:"stringLiteralMissingIncludeTextSingle"},{selectType:"id",id:"string_literal_double_text_",outputType:"function",showType:"error",msg:"stringLiteralMissingIncludeTextDouble"},{selectType:"id",id:"string_literal_block_text_",outputType:"function",showType:"error",msg:"stringLiteralWrongBlock"},{selectType:"id",id:"string_literal_field",outputType:"function",showType:"error",msg:"stringLiteralMissingIncludeTextBlock"}]},T2C.FeedbackManagers.display_string_literal={feedbackJsonBlock:[].concat(T2C.FeedbackManagers.default.errorFunctions).concat(T2C.FeedbackManagers.string_literal.errorFunctions)},T2C.FeedbackManagers.prompt_store_input={DEFAULT_VAR_NAME_ERROR_MSG:"Be sure to name the variable you're declaring {feedbackItem.expected.value}.",DEFAULT_MISSING_PHRASE_ERROR_MSG:"The message to the user should contain {feedbackItem.expected.value}.",DEFAULT_VARIABLE_NAME:"item",feedbackJsonText:[],feedbackJsonBlock:[{selectType:"id",id:0,showType:"error",outputType:"string",msg:"You'll want to store the result in a variable, which means you should use a {T2C.MSG.currentLanguage.TERMINAL_LET} variable block."},{selectType:"id",id:2,showType:"error",outputType:"string",msg:"The variable should store what the user enters, which means you'llneed to attach it to a {T2C.MSG.currentLanguage.TERMINAL_GETINPUTBYASKING} block."},{selectType:"id",id:6,outputType:"function",showType:"error",msg:"missingPhraseFunction"},{selectType:"id",id:8,outputType:"function",showType:"error",msg:"wrongVariableFunction"},{selectType:"id",id:11,outputType:"function",showType:"error",msg:"wrongVariableFunction"},{selectType:"id",id:12,outputType:"function",showType:"error",msg:function(e,t,n){return"Remember to include an = after the variable "+h.a.getExpected(t[t.indexOf(e)-1]).trim()+" you're declaring to set it to the string the user enters."}}].concat(T2C.FeedbackManagers.default.errorFunctions).concat(T2C.FeedbackManagers.string_literal.errorFunctions)},T2C.FeedbackManagers.code_statement_hybrid={DEFAULT_TEXT_MODE_FEEDBACK_MANAGER:function(e,t,n){if(-1!==e.id)return m.a.getFeedback(t,n.feedbackManager.feedbackJsonBlock,n.options).map((function(e){return e.msgArr.join("\n")})).join("\n\n")},feedbackJsonBlock:[{selectType:"id",id:1e4,outputType:"function",msg:"textModeFeedbackManager"},{selectType:"id",id:-1,outputType:"component",msg:"textModeFeedbackManager"}]};var _=new d("type_in_display_string_literal");_.addPossibleMatch([{token:"display",type:"terminal"},"(",{token:/^"[^"]*$|^'[^']*$|^"[^"]+"|^'[^"]+'/,type:"regexp"},")",{token:/^[;]*/,type:"regexp"}],[null,null,function(e,t){return t.startsWith('"')||t.startsWith("'")?'""'===t||"''"===t?"Include some message in between the quotation marks so that the user sees some text!":"":'Make sure the text you want to display is between " and " so the computer just displays it without trying to figure out what you mean!'},null,null]),_.addToBlocks();var b=new d("type_in_welcome_message");function k(e){return Array.from(document.querySelectorAll("rect")).filter((function(e){return e.getAttribute("fill-opacity")}))[e]}function x(e,t,n){var o=arguments.length>3&&void 0!==arguments[3]?arguments[3]:0,i=arguments.length>4&&void 0!==arguments[4]?arguments[4]:0,r=t.getBoundingRectangle(),a=e.getMetrics(),l=e.getScale(),s=o,u=i,c=n.blockOffsetScaleX||0,g=n.blockOffsetScaleY||0;return{x:(r.left-a.viewLeft+c*t.width)*l+s,y:(r.top-a.viewTop+a.flyoutHeight+g*t.height)*l+u}}b.addPossibleMatch([{token:/^"[^"]*$|^'[^']*$|^"[^"]+ "|^'[^"]+ '/,type:"regexp"},"+","firstName","+",{token:/^"[^"]+"|^'[^"]+'/,tokenPartial:/^"[^"]*$|^'[^']*$/,type:"regexp"}],[function(e,t){return t.startsWith('"')||t.startsWith("'")?'""'===t||"''"===t?"Include some greeting in between the quotation marks that will appear before the person's first name such as hi or welcome.":/^"[^"]+[^ ]"|^'[^"]+[^ ]'/.test(t)?"Be sure to include a space at the end of the greeting before the quotation marks so the greeting and person's first name will appear with a space in between them (e.g., Hi Jane instead of HiJane).\n NOTE: Including a space *outside* of quotation marks will NOT appear in the message displayed to the user.":"":'Make sure the text you want to display is between " and " so the computer just displays it without trying to figure out what you mean!'},function(e,t){return"Include a + to join the greeting "+e[0].substring(1,e[0].length-1)+" text with the user's first name."},function(e,t){return t.startsWith('"')||t.startsWith("'")?"Be sure that the variable name firstName appears outside of quotation marks since you want its value, which will be the name the user enters instead of the text firstName (e.g., you want "+e[0].substring(1,e[0].length-1)+"Jane instead of "+e[0].substring(1,e[0].length-1)+"firstName.":t.startsWith("firstn")?"Be sure to enter firstName in camel case (first letter of every word after the first capitalized)":"Type the variable name firstName exactly so that its value, mainly what the user entered for his/her first name, will be displayed after "+e[0].substring(1,e[0].length-1)+"."},function(e,t){return"Include a + to join the greeting "+e[0].substring(1,e[0].length-1)+" and the name the user entered with a final punctuation mark (to be gramatically correct)."},function(e,t){return t.startsWith('"')||t.startsWith("'")?'""'===t||"''"===t?"Include some punctuation mark such as . or ! in between the quotation marks so your English teacher doesn't complain.":"":'Since the punctuation mark should be displayed exactly as is without evaluating it any way, be sure you let the computer know this by surrounding the punctuation mark with " and ".'}]),b.addToBlocks({isExpression:!0});var E=new d("type_in_get_last_char_number");function B(e,t){var n=!(arguments.length>2&&void 0!==arguments[2])||arguments[2],o=document.createElement("block");return o.setAttribute("type",t),n?document.getElementById("toolbox").prepend(o):document.getElementById("toolbox").append(o),e.updateToolbox(document.getElementById("toolbox")),o}function A(e,t){var n=!(arguments.length>2&&void 0!==arguments[2])||arguments[2],o=document.createElement("block");return o.setAttribute("type",t),n?document.getElementById("toolbox").prepend(o):document.getElementById("toolbox").append(o),e.updateToolbox(document.getElementById("toolbox")),o}function v(e,t){var n=Object.values(T2C.MSG).map((function(e){return e["TERMINAL_"+t.toUpperCase()]})).filter((function(e){return"string"==typeof e})).find((function(t){return t.startsWith(e)||e.startsWith(t)}));if(n)return{terminal:n,remaining:e.JSSubstring(n.length).trim()}}function I(e,t){e("Check the spelling, case, and punctuation of what you're entering; it should identically match with "+T2C.MSG.currentLanguage["TERMINAL_"+t.toUpperCase()]+".")}function w(e,t,n){for(var o=void 0,i=[],r=e,a=!1,l=-1;l2&&void 0!==arguments[2])||arguments[2],o=O(t);return n?document.getElementById("toolbox").prepend(o):document.getElementById("toolbox").append(o),e.updateToolbox(document.getElementById("toolbox")),o}function O(e){var t=document.createElement("block");return t.setAttribute("type",e),t}function C(e,t,n){var o=document.createElement("field");o.setAttribute("name",t),o.appendChild(document.createTextNode(n)),e.appendChild(o)}function R(e,t,n){var o=document.createElement("value");o.setAttribute("name",t),o.appendChild(n),e.appendChild(o)}function F(e,t,n){var o=arguments.length>3&&void 0!==arguments[3]?arguments[3]:0,i=arguments.length>4&&void 0!==arguments[4]?arguments[4]:0,r=t&&t.getBoundingRectangle()||{left:0,top:0};t=t||{width:0,height:0};var a=e.getMetrics(),l=e.getScale(),s=o,u=i,c=n.blockOffsetScaleX||0,g=n.blockOffsetScaleY||0;return{x:(r.left-a.viewLeft+c*t.width)*l+s,y:(r.top-a.viewTop+a.flyoutHeight+g*t.height)*l+u}}function P(e){var t=!(arguments.length>1&&void 0!==arguments[1])||arguments[1],n=document.getElementById("alert-display");n||((n=document.createElement("div")).id="alert-display",n.style.fontSize="small",n.style.fontWeight="bold",n.style.borderColor="#000",n.style.backgroundColor="rgba(200, 200, 200, 0.5)",n.style.color="#f00",n.style.position="absolute",n.style.zIndex="1050",n.style.width="98%",n.style.minHeight="50px",n.style.left="0",n.style.bottom="0",n.style.textAlign="left",n.style.padding="1%",document.body.appendChild(n)),t?n.innerText=e:n.innerText+=e}function V(e,t){var n=Object.values(T2C.MSG).map((function(e){return e["TERMINAL_"+t.toUpperCase()]})).filter((function(e){return"string"==typeof e})).find((function(t){return t.startsWith(e)||e.startsWith(t)}));if(n)return{terminal:n,remaining:e.JSSubstring(n.length).trim()}}function G(e,t){e("Check the spelling, case, and punctuation of what you're entering; it should identically match with "+T2C.MSG.currentLanguage["TERMINAL_"+t.toUpperCase()]+".")}function U(e,t,n){for(var o=void 0,i=[],r=e,a=!1,l=-1;l2&&void 0!==arguments[2])||arguments[2],o=Y(t);return n?document.getElementById("toolbox").prepend(o):document.getElementById("toolbox").append(o),e.updateToolbox(document.getElementById("toolbox")),o}function Y(e){var t=document.createElement("block");return t.setAttribute("type",e),t}function H(e,t,n){var o=document.createElement("field");o.setAttribute("name",t),o.appendChild(document.createTextNode(n)),e.appendChild(o)}function J(e,t,n){var o=document.createElement("value");o.setAttribute("name",t),o.appendChild(n),e.appendChild(o)}function q(e,t,n){var o=arguments.length>3&&void 0!==arguments[3]?arguments[3]:0,i=arguments.length>4&&void 0!==arguments[4]?arguments[4]:0,r=t&&t.getBoundingRectangle()||{left:0,top:0};t=t||{width:0,height:0};var a=e.getMetrics(),l=e.getScale(),s=o,u=i,c=n.blockOffsetScaleX||0,g=n.blockOffsetScaleY||0;return{x:(r.left-a.viewLeft+c*t.width)*l+s,y:(r.top-a.viewTop+a.flyoutHeight+g*t.height)*l+u}}function $(e){var t=!(arguments.length>1&&void 0!==arguments[1])||arguments[1],n=document.getElementById("alert-display");n||((n=document.createElement("div")).id="alert-display",n.style.fontSize="small",n.style.fontWeight="bold",n.style.borderColor="#000",n.style.backgroundColor="rgba(200, 200, 200, 0.5)",n.style.color="#f00",n.style.position="absolute",n.style.zIndex="1050",n.style.width="98%",n.style.minHeight="50px",n.style.left="0",n.style.bottom="0",n.style.textAlign="left",n.style.padding="1%",document.body.appendChild(n)),t?n.innerText=e:n.innerText+=e}function z(e){e.style.verticalAlign="middle",e.style.color="#000"}function K(){document.getElementById("output-container").classList.remove("show-container"),document.getElementById("output-container").classList.add("hide-container"),document.getElementById("text-code-container").classList.remove("show-container"),document.getElementById("text-code-container").classList.add("hide-container")}function Z(e,t){var n=Object.values(T2C.MSG).map((function(e){return e["TERMINAL_"+t.toUpperCase()]})).filter((function(e){return"string"==typeof e})).find((function(t){return t.startsWith(e)||e.startsWith(t)}));if(n)return{terminal:n,remaining:e.JSSubstring(n.length).trim()}}function Q(e,t){e("Check the spelling, case, and punctuation of what you're entering; it should identically match with "+T2C.MSG.currentLanguage["TERMINAL_"+t.toUpperCase()]+".")}function ee(e,t,n){for(var o=void 0,i=[],r=e,a=!1,l=-1;l3&&void 0!==arguments[3]?arguments[3]:0,i=arguments.length>4&&void 0!==arguments[4]?arguments[4]:0,r=t&&t.getBoundingRectangle()||{left:0,top:0};t=t||{width:0,height:0};var a=e.getMetrics(),l=e.getScale(),s=o,u=i,c=n.blockOffsetScaleX||0,g=n.blockOffsetScaleY||0;return{x:(r.left-a.viewLeft+c*t.width)*l+s,y:(r.top-a.viewTop+a.flyoutHeight+g*t.height)*l+u}}function ne(e){var t=!(arguments.length>1&&void 0!==arguments[1])||arguments[1],n=document.getElementById("alert-display");n||((n=document.createElement("div")).id="alert-display",n.style.fontSize="small",n.style.fontWeight="bold",n.style.borderColor="#000",n.style.backgroundColor="rgba(200, 200, 200, 0.5)",n.style.color="#f00",n.style.position="absolute",n.style.zIndex="1050",n.style.width="98%",n.style.minHeight="50px",n.style.left="0",n.style.bottom="0",n.style.textAlign="left",n.style.padding="1%",document.body.appendChild(n)),t?n.innerText=e:n.innerText+=e}function oe(e){e.style.verticalAlign="middle",e.style.color="#000"}function ie(){document.getElementById("output-container").classList.remove("show-container"),document.getElementById("output-container").classList.add("hide-container"),document.getElementById("text-code-container").classList.remove("show-container"),document.getElementById("text-code-container").classList.add("hide-container")}function re(e,t){var n=Object.values(T2C.MSG).map((function(e){return e["TERMINAL_"+t.toUpperCase()]})).filter((function(e){return"string"==typeof e})).find((function(t){return t.startsWith(e)||e.startsWith(t)}));if(n)return{terminal:n,remaining:e.JSSubstring(n.length).trim()}}function ae(e,t){e("Check the spelling, case, and punctuation of what you're entering; it should identically match with "+T2C.MSG.currentLanguage["TERMINAL_"+t.toUpperCase()]+".")}function le(e,t,n){for(var o=void 0,i=[],r=e,a=!1,l=-1;l3&&void 0!==arguments[3]?arguments[3]:0,i=arguments.length>4&&void 0!==arguments[4]?arguments[4]:0,r=t&&t.getBoundingRectangle()||{left:0,top:0};t=t||{width:0,height:0};var a=e.getMetrics(),l=e.getScale(),s=o,u=i,c=n.blockOffsetScaleX||0,g=n.blockOffsetScaleY||0;return{x:(r.left-a.viewLeft+c*t.width)*l+s,y:(r.top-a.viewTop+a.flyoutHeight+g*t.height)*l+u}}function ue(e){var t=!(arguments.length>1&&void 0!==arguments[1])||arguments[1],n=document.getElementById("alert-display");n||((n=document.createElement("div")).id="alert-display",n.style.fontSize="small",n.style.fontWeight="bold",n.style.borderColor="#000",n.style.backgroundColor="rgba(200, 200, 200, 0.5)",n.style.color="#f00",n.style.position="absolute",n.style.zIndex="1050",n.style.width="98%",n.style.minHeight="50px",n.style.left="0",n.style.bottom="0",n.style.textAlign="left",n.style.padding="1%",document.body.appendChild(n)),t?n.innerText=e:n.innerText+=e}function ce(e){e.style.verticalAlign="middle",e.style.color="#000"}function ge(){document.getElementById("output-container").classList.remove("show-container"),document.getElementById("output-container").classList.add("hide-container"),document.getElementById("text-code-container").classList.remove("show-container"),document.getElementById("text-code-container").classList.add("hide-container")}function de(e,t){var n=Object.values(T2C.MSG).map((function(e){return e["TERMINAL_"+t.toUpperCase()]})).filter((function(e){return"string"==typeof e})).find((function(t){return t.startsWith(e)||e.startsWith(t)}));if(n)return{terminal:n,remaining:e.JSSubstring(n.length).trim()}}function he(e,t){e("Check the spelling, case, and punctuation of what you're entering; it should identically match with "+T2C.MSG.currentLanguage["TERMINAL_"+t.toUpperCase()]+".")}function pe(e,t,n){for(var o=void 0,i=[],r=e,a=!1,l=-1;l3&&void 0!==arguments[3]?arguments[3]:0,i=arguments.length>4&&void 0!==arguments[4]?arguments[4]:0,r=t&&t.getBoundingRectangle()||{left:0,top:0};t=t||{width:0,height:0};var a=e.getMetrics(),l=e.getScale(),s=o,u=i,c=n.blockOffsetScaleX||0,g=n.blockOffsetScaleY||0;return{x:(r.left-a.viewLeft+c*t.width)*l+s,y:(r.top-a.viewTop+a.flyoutHeight+g*t.height)*l+u}}function me(e){var t=!(arguments.length>1&&void 0!==arguments[1])||arguments[1],n=document.getElementById("alert-display");n||((n=document.createElement("div")).id="alert-display",n.style.fontSize="small",n.style.fontWeight="bold",n.style.borderColor="#000",n.style.backgroundColor="rgba(200, 200, 200, 0.5)",n.style.color="#f00",n.style.position="absolute",n.style.zIndex="1050",n.style.width="98%",n.style.minHeight="50px",n.style.left="0",n.style.bottom="0",n.style.textAlign="left",n.style.padding="1%",document.body.appendChild(n)),t?n.innerText=e:n.innerText+=e}function ye(e){e.style.verticalAlign="middle",e.style.color="#000"}function Te(){document.getElementById("output-container").classList.remove("show-container"),document.getElementById("output-container").classList.add("hide-container"),document.getElementById("text-code-container").classList.remove("show-container"),document.getElementById("text-code-container").classList.add("hide-container")}function _e(e,t){var n=Object.values(T2C.MSG).map((function(e){return e["TERMINAL_"+t.toUpperCase()]})).filter((function(e){return"string"==typeof e})).find((function(t){return t.startsWith(e)||e.startsWith(t)}));if(n)return{terminal:n,remaining:e.JSSubstring(n.length).trim()}}function be(e,t){e("Check the spelling, case, and punctuation of what you're entering; it should identically match with "+T2C.MSG.currentLanguage["TERMINAL_"+t.toUpperCase()]+".")}function ke(e,t,n){for(var o=void 0,i=[],r=e,a=!1,l=-1;l3&&void 0!==arguments[3]?arguments[3]:0,i=arguments.length>4&&void 0!==arguments[4]?arguments[4]:0,r=t&&t.getBoundingRectangle()||{left:0,top:0};t=t||{width:0,height:0};var a=e.getMetrics(),l=e.getScale(),s=o,u=i,c=n.blockOffsetScaleX||0,g=n.blockOffsetScaleY||0;return{x:(r.left-a.viewLeft+c*t.width)*l+s,y:(r.top-a.viewTop+a.flyoutHeight+g*t.height)*l+u}}function Ee(e){var t=!(arguments.length>1&&void 0!==arguments[1])||arguments[1],n=document.getElementById("alert-display");n||((n=document.createElement("div")).id="alert-display",n.style.fontSize="small",n.style.fontWeight="bold",n.style.borderColor="#000",n.style.backgroundColor="rgba(200, 200, 200, 0.5)",n.style.color="#f00",n.style.position="absolute",n.style.zIndex="1050",n.style.width="98%",n.style.minHeight="50px",n.style.left="0",n.style.bottom="0",n.style.textAlign="left",n.style.padding="1%",document.body.appendChild(n)),t?n.innerText=e:n.innerText+=e}E.addPossibleMatch([{token:"display",type:"terminal"},"(","s",".",{token:"getCharacterNUMBER",type:"terminal"},"(","4",")",")",{token:/^[;]*/,type:"regexp"}],[null,null,function(e,t){return t.startsWith('"')?"Don't use \" here as you want the computer to evaluate what you typed (e.g., the word the user entered instead of the letter s)":"Be sure to include the variable s that you want to the get the value's last character from"},null,null,null,function(e,t){return t.startsWith('"')?"Don't use \" here as you want the computer to interpret this as a number and not text.":t.startsWith("5")?"Remember that character positions start at the number 0. If you count the letters of a 5-letter word such as `pizza` starting from 0, you won't get up to position 5.":t.startsWith("6")?"Determine the position of the last character a in the 5-letter word `pizza`. If you count starting from 0, you won't get up to position 6.":0===parseInt(t)?"You want the position of the last character, not the first.":parseInt(t)?"Determine the position of the last character a in the 5-letter word `pizza`. The number you're entering is incorrect.":"Include a number for the position you want after "+e[4]+"("},null,null,null]),E.addPossibleMatch([{token:"display",type:"terminal"},"(","s","[","4","]",")"],[null,null,function(e,t){return t.startsWith('"')?"Don't use \" here as you want the computer to evaluate what you typed (e.g., the word the user entered instead of the letter s)":"Be sure to include the variable s that you want to the get the value's last character from"},null,function(e,t){return t.startsWith('"')?"Don't use \" here as you want the computer to interpret this as a number and not text.":t.startsWith("5")?"Remember that character positions start at the number 0. If you count the letters of a 5-letter word such as `pizza` starting from 0, you won't get up to position 5.":t.startsWith("6")?"Determine the position of the last character a in the 5-letter word `pizza`. If you count starting from 0, you won't get up to position 6.":0===parseInt(t)?"You want the position of the last character, not the first.":parseInt(t)?"Determine the position of the last character a in the 5-letter word `pizza`. The number you're entering is incorrect.":"Include a number for the position you want after "+e[3]+"."},null,null]),E.addToBlocks(),String.prototype.JSSubstring=function(e,t){return e>=this.length||e===t?"":this.substring(e,t)},Blockly.Python.type_in_get_input=Blockly.JavaScript.type_in_get_input=Blockly.JavaScript.code_statement,Blockly.Blocks.type_in_get_input={validate:function(e){var t,n=void 0,o=void 0,i=void 0,r=v(e.trim(),"let");if(!r)return P("Check the spelling, case, and punctuation of what you're entering; it should identically match with "+T2C.MSG.currentLanguage.TERMINAL_LET+"."),null;if(r.remaining.length&&!r.remaining.startsWith("s"))return P("Be sure to name the variable you're declaring s. This will store the string with an even number of characters the user enters."),r.terminal;if(r.remaining=r.remaining.JSSubstring(1).trim(),r.remaining.length&&!r.remaining.startsWith("="))return P("Remember to include an = after the variable s you're declaring to set it to the string the user enters."),r.terminal+"s";if(r.remaining=r.remaining.JSSubstring(1).trim(),!r.remaining.length)return P(""),e;if(t=r.terminal+"s = ",!(n=v(r.remaining.trim(),"GETINPUTBYASKING")))return P("Check the spelling, case, and punctuation of what you're entering; it should identically match with "+T2C.MSG.currentLanguage.TERMINAL_GETINPUTBYASKING+"."),t;if(n.remaining.length&&!n.remaining.startsWith("("))return P("You're missing an opening parenthesis after "+n.terminal),t+n.terminal;if(n.remaining=n.remaining.JSSubstring(1).trim(),n.remaining.length&&!n.remaining.startsWith('"')&&!n.remaining.startsWith("'"))return P('The message to supply to the user should be surrounded by " and " because you want it to be displayed as is.'),t+n.terminal+"(";if(n.remaining.length&&(o=n.remaining.match(/^"[^"]*"|^'[^']*'/))){if(-1===(i=o[0]).toLowerCase().indexOf(" even ")&&-1===i.indexOf(" "))return P("Make sure the message contains the word even to tell the user you want him/her to enter an even number of characters (> 0). And be sure it has spaces since you can and should include them in messages read by humans!"),t+n.terminal+"("+i.substring(0,i.length-1);if(-1===i.toLowerCase().indexOf(" even "))return P("Make sure the message contains the word even (surrounded by spaces) to tell the user you want him/her to enter an even number of characters (> 0)."),t+n.terminal+"("+i.substring(0,i.length-1)}return n.remaining.length&&i&&(n.remaining=n.remaining.JSSubstring(i.length).trim()),n.remaining.length&&i&&!n.remaining.startsWith(")")?(P("You're missing a closing parenthesis for "+n.terminal),t+n.terminal+"("+i):(n.remaining.length&&i&&(n.remaining=n.remaining.JSSubstring(1).trim()),P(""),e)},init:function(){var e=this;this.appendDummyInput("STRING").appendField(new Blockly.FieldTextInput("",this.validate),"EXP"),this.setInputsInline(!1),this.setOutput(!1),this.setPreviousStatement(!0),this.setNextStatement(!0),this.setColour(60),this.setTooltip(T2C.MSG.currentLanguage.TYPEIN_STATEMENT_TOOLTIP),this.onchange=function(t){if(e.getFieldValue("EXP").endsWith("\r")||e.getFieldValue("EXP").endsWith("\n")||e.getFieldValue("EXP").length>0&&"workspaceClick"===t.element){if(!e.validate(e.getFieldValue("EXP"))||!e.getFieldValue("EXP").endsWith(")")&&!e.getFieldValue("EXP").endsWith(";"))return;var n=Object(o.getParseTree)(e.getFieldValue("EXP"));n?Object(o.handleParseTreeToBlocks)(n,e):P("Try checking what you entered again for mistakes. You probably just have extra unnecessary code after a ).")}}}},Blockly.Python.type_in_set_to_char_number_0=Blockly.JavaScript.type_in_set_to_char_number_0=Blockly.JavaScript.code_statement,Blockly.Blocks.type_in_set_to_char_number_0={validate:function(e){var t=void 0,n=void 0,o=v(e.trim(),"let");return o?!o.remaining.length||o.remaining.startsWith("firstChar")||"firstChar".startsWith(o.remaining)?(o.remaining=o.remaining.JSSubstring("firstChar".length).trim(),o.remaining.length&&!o.remaining.startsWith("=")?(P("Remember to include an = after the variable firstChar you're declaring to set it to the string's first character."),o.terminal+"firstChar"):(o.remaining=o.remaining.JSSubstring(1).trim(),o.remaining.length?(t=o.terminal+"firstChar = ",o.remaining.length&&!o.remaining.startsWith("s")?(o.remaining.startsWith('"')?P("Don't use \" here as you want the computer to evaluate what you typed (e.g., the word the user entered instead of the letter s)"):o.remaining.startsWith("f")?P("This is the string you want to get the initial character from so you'll want to use s, which stores what the user entered."):P("Be sure to include the variable s that you want to the get the value's first character from."),t):(o.remaining=o.remaining.JSSubstring(1).trim(),o.remaining.length&&!o.remaining.startsWith(".")?(P("Be sure to include the . after the variable"),t+"s"):o.remaining.length?(t+="s.",(n=v(o.remaining.JSSubstring(1).trim(),"GETCHARACTERNUMBER"))?n.remaining.length&&!n.remaining.startsWith("(")?(P("You're missing an opening parenthesis after "+n.terminal),t+n.terminal):(n.remaining=n.remaining.JSSubstring(1).trim(),n.remaining.length&&!n.remaining.startsWith("0")?(n.remaining.startsWith('"')?P("Don't use \" here as you want the computer to interpret this as a number and not text."):n.remaining.startsWith("1")?P("Remember that character positions start at the number 0."):parseInt(n.remaining)?P("The number you're entering is incorrect for getting the initial character."):P("Include a number for the position you want after "+n.terminal+"("),t+n.terminal+"("):(n.remaining=n.remaining.JSSubstring(1).trim(),n.remaining.length&&!n.remaining.startsWith(")")?(P("You're missing a closing parenthesis for "+n.terminal),t+n.terminal+"(0"):(P(""),e))):(P("Check the spelling, case, and punctuation of what you're entering; it should identically match with "+T2C.MSG.currentLanguage.TERMINAL_GETCHARACTERNUMBER),t)):(P(""),e))):(P(""),e))):(P("Be sure to name the variable you're declaring firstChar to representing the fact that it's storing the entered string's first character."),o.terminal):(P("Check the spelling, case, and punctuation of what you're entering; it should identically match with "+T2C.MSG.currentLanguage.TERMINAL_LET+"."),null)},init:function(){var e=this;this.appendDummyInput("STRING").appendField(new Blockly.FieldTextInput("",this.validate),"EXP"),this.setInputsInline(!1),this.setOutput(!1),this.setPreviousStatement(!0),this.setNextStatement(!0),this.setColour(60),this.setTooltip(T2C.MSG.currentLanguage.TYPEIN_STATEMENT_TOOLTIP),this.onchange=function(t){if(e.getFieldValue("EXP").endsWith("\r")||e.getFieldValue("EXP").endsWith("\n")||e.getFieldValue("EXP").length>0&&"workspaceClick"===t.element){if(!e.validate(e.getFieldValue("EXP"))||!e.getFieldValue("EXP").endsWith(")")&&!e.getFieldValue("EXP").endsWith(";"))return;var n=Object(o.getParseTree)(e.getFieldValue("EXP"));n?Object(o.handleParseTreeToBlocks)(n,e):P("Try checking what you entered again for mistakes.")}}}},Blockly.Python.type_in_set_to_last_char=Blockly.JavaScript.type_in_set_to_last_char=Blockly.JavaScript.code_statement,Blockly.Blocks.type_in_set_to_last_char={validate:function(e){var t=w(e,[{token:"let",type:"terminal"},"lastChar","=","s",".",{token:"GETCHARACTERNUMBER",type:"terminal"},"(","s",".",{token:"LENGTH",type:"terminal"},"-","1",")"],[I.bind(null,P,"LET"),function(){return P("Be sure to name the variable you're declaring lastChar to representing the fact that it's storing the entered string's last character.")},function(){return P("Remember to include an = after the variable lastChar you're declaring to set it to the string's last character.")},function(e,t){t.startsWith('"')?P("Don't use \" here as you want the computer to evaluate what you typed (e.g., the word the user entered instead of the letter s)"):t.startsWith("l")?P("This is the string you want to get the last character from so you'll want to use s, which stores what the user entered."):P("Be sure to include the variable s that you want to the get the value's last character from.")},function(){return P("Be sure to include the . after the variable")},I.bind(null,P,"GETCHARACTERNUMBER"),function(e){return"You're missing an open parenthesis after "+e[5]+"."},function(e,t){t.startsWith("-")?P("Let's get the length of the string first when calculating the position of the last character even though it doesn't need to appear before the operation."):isNaN(parseInt(t))?P("To get the length of a string, you'll need to first specify the string you want the length of. In this case, you'll need to use the length of the entered string (stored in s) to get the position of its last character."):P("Remember that since the string can be of any length, its last character will not always be at position "+parseInt(t)+".")},function(e,t){t.startsWith("(")?P("An expression representing a number should go after the open parenthesis for "+e[5]+'. It wouldn\'t make sense to get the character at position number "pizza" (or whatever string the user enters), right?'):P("Be sure to include the . after the variable s if you want to get its length.")},I.bind(null,P,"LENGTH"),function(e,t){t.startsWith("(")?P("The length of a 5-character string such as pizza is 5, but since you start counting from 0, this was not the position of the last character. Consider using some math operation to calculate the correct position."):t.startsWith("+")?P("Consider adding a number such as 1 to 5, which is the length of pizza. This gives you 6, but you wouldn't use 6 for the number of the position for the last character, right?"):P("Type the appropriate option (+ = ADD, - = SUBTRACT, * = MULTIPLY, / = DIVIDE) that you want to perform on the string's length to calculate the character's last position. Your current answer won't work in general.")},function(e,t){var n=parseInt(t);isNaN(n)?P("Remember that the length is a number. What would it mean to subtract a string from a number?"):P(0===n?"The length of a 5-character string such as pizza is 5, but since you start counting from 0, this was not the position of the last character. Also subtracting 0 doesn't change the quantity (e.g., 5 - 0 = 5) so it wouldn't be necessary.":"What number do you want to subtract from the length of the string to get the position of its last character? pizza had a length of 5, and its last character was at what position? food has a length of 4, and its last character is at what position?")},function(e,t){return P("You're missing a closing parenthesis for "+e[5])}]);return t.error?t.match.join(""):e},init:function(){var e=this;this.appendDummyInput("STRING").appendField(new Blockly.FieldTextInput("",this.validate),"EXP"),this.setInputsInline(!1),this.setOutput(!1),this.setPreviousStatement(!0),this.setNextStatement(!0),this.setColour(60),this.setTooltip(T2C.MSG.currentLanguage.TYPEIN_STATEMENT_TOOLTIP),this.onchange=function(t){if(e.getFieldValue("EXP").endsWith("\r")||e.getFieldValue("EXP").endsWith("\n")||e.getFieldValue("EXP").length>0&&"workspaceClick"===t.element){if(!e.validate(e.getFieldValue("EXP"))||!e.getFieldValue("EXP").endsWith(")")&&!e.getFieldValue("EXP").endsWith(";"))return;var n=Object(o.getParseTree)(e.getFieldValue("EXP"));n?Object(o.handleParseTreeToBlocks)(n,e):P("Try checking what you entered again for mistakes.")}}}},Blockly.Python.type_in_set_to_position_of_second_middle_char=Blockly.JavaScript.type_in_set_to_position_of_second_middle_char=Blockly.JavaScript.code_statement,Blockly.Blocks.type_in_set_to_position_of_second_middle_char={validate:function(e){var t=w(e,[{token:"let",type:"terminal"},"positionOfSecondMiddleChar","=","s",".",{token:"LENGTH",type:"terminal"},"/","2"],[I.bind(null,P,"LET"),function(){return P("Be sure to name the variable you're declaring positionOfSecondMiddleChar to represent the fact that it's storing the position number of the string's second middle character.")},function(){return P("Remember to include an = after the variable positionOfSecondMiddleChar you're declaring to set it to the position of the string's second middle character.")},function(e,t){isNaN(parseInt(t))?t.startsWith('"')?P("Don't use \" here as you want the computer to evaluate what you typed (e.g., the word the user entered instead of the letter s)"):t.startsWith("l")||t.startsWith("p")?P("This is the string you want to get the length of so you'll want to use s, which stores what the user entered."):P("Be sure to include the variable s that you want to the get the length of."):P("Let's get the length of the string first when calculating the position of the second middle character even though it doesn't need to appear before the operation.")},function(){return P("Be sure to include the . after the variable")},I.bind(null,P,"LENGTH"),function(e,t){t.startsWith("-")?P("If you subtract a *specific number* for the length, this won't work in general. For example, the length of SCRABBLE is 8 and the position of its second middle character is 4. So subtracting 4 from the length works for that example, but if your string were FOOD, the middle character is at 2, but subtracting 4 from the length of 4 gives you 0."):t.startsWith("+")?P("Remember that the last character is at the length of the string - 1. If you add zero or a positive number to the length, you'll get the position of a character that does not exist! For example, if you add 1 to the length of pizza, you'll get 5 + 1 or 6, but the position of the last character is 4 so you'll go out of bounds!"):t.startsWith("*")?P("Multiplication could work, but not by a positive whole number since multiplying the length of the string by 1, 2, 3, or 4 will always be greater than the position of the last character of the string, which is its length - 1. For example, multiplying the length of pizza by 4, gives you 5 * 4 = 20 and there's no 20th character! What operation could you use instead so you don't refer to a position that's out of bounds?"):P("Type the appropriate option (+ = ADD, - = SUBTRACT, * = MULTIPLY, / = DIVIDE) that you want to perform on the string's length to calculate the position of its second middle character.")},function(e,t){var n=parseInt(t);t.startsWith('"')||t.startsWith("'")?P("Remember that the length is a number. What would it mean to divide a string from a number?"):isNaN(n)?P("Remember that the length is a number. You wouldn't divide it by the string the user enters (e.g., what would 8/SCRABBLE mean?) and you can't divide it by positionOfSecondMiddleChar because you're defining that variable. And if you divide any positive number by itself, that'd be 1 anyway which won't be the position of the second middle character in general. You can divide the length by a specific number to get the position of the second middle character. What should that be?"):P("If you divide the length of SCRABBLE by "+n+", you'll get "+8/n+", which is not the position of its second middle character (4). Try a different number. Also verify that it works for strings of other even lengths such as CODE.")}]);return t.error?t.match.join(""):e},init:function(){var e=this;this.appendDummyInput("STRING").appendField(new Blockly.FieldTextInput("",this.validate),"EXP"),this.setInputsInline(!1),this.setOutput(!1),this.setPreviousStatement(!0),this.setNextStatement(!0),this.setColour(60),this.setTooltip(T2C.MSG.currentLanguage.TYPEIN_STATEMENT_TOOLTIP),this.onchange=function(t){if(e.getFieldValue("EXP").endsWith("\r")||e.getFieldValue("EXP").endsWith("\n")||e.getFieldValue("EXP").length>0&&"workspaceClick"===t.element){if(!e.validate(e.getFieldValue("EXP"))||!e.getFieldValue("EXP").endsWith(")")&&!e.getFieldValue("EXP").endsWith(";"))return;var n=Object(o.getParseTree)(e.getFieldValue("EXP"));n?Object(o.handleParseTreeToBlocks)(n,e):P("Try checking what you entered again for mistakes.")}}}},Blockly.Python.type_in_set_to_position_of_first_middle_char=Blockly.JavaScript.type_in_set_to_position_of_first_middle_char=Blockly.JavaScript.code_statement,Blockly.Blocks.type_in_set_to_position_of_first_middle_char={validate:function(e){var t=w(e,[{token:"let",type:"terminal"},"positionOfFirstMiddleChar","=","positionOfSecondMiddleChar","-","1"],[I.bind(null,P,"LET"),function(){return P("Be sure to name the variable you're declaring positionOfFirstMiddleChar to represent the fact that it's storing the position number of the string's first middle character.")},function(){return P("Remember to include an = after the variable positionOfFirstMiddleChar you're declaring to set it to the position of the string's first middle character.")},function(e,t){t.startsWith("-")?P("Let's get the length of the string first when calculating the position of the first middle character even though it doesn't need to appear before the operation."):t.startsWith('"')?P("Don't use \" here as you want the computer to evaluate the variable."):t.startsWith("l")?P("While you might use a math operation on the *position* of the last character, which is a number, to get the position of the first middle character, you would not use the character itself. E.g., you might do a math operation on 4, which is the position of the a in pizza, but not the a itself. However, try using a math operation on the *position* of the second middle character instead."):t.startsWith("s")?P("Instead of using the length of the string s this time to calculate the position of the first middle character, try using the position of the second middle character instead."):P("You'll want to use the position of the second middle character to get the position of the first middle character. You already stored that in what variable?")},function(e,t){t.startsWith("/")?P("Dividing the position of the second middle character by a number won't get the previous position where the first middle character resides. For example, for SCRABBLE, the second middle character is at position 4. Dividing this by 2 gets you 2, the position of the R, by 3 gets you 4/3, which is not even a position, etc. What would you do to the 4 to get to the position of the first middle character at 3?"):t.startsWith("+")?P("Adding a positive number won't be what you want as that moves you forward. For example, the position of the second middle character of SCRABBLE is 4. Adding 1, 2, or 3 would give you 5, 6, or 7, the positions of the second B, the L, and the E, respectively, not the position of the first middle character (A)."):t.startsWith("*")?P("Multiplying the position of the second middle character by a whole number won't get the previous position where the first middle character resides in general. For example, for SCRABBLE, the second middle character is at position 4. For example, multiplying by 0 always gives you 0 (position of initial character), by 1 gives you 4 (unchanged: position of second middle character), by 2 gives you 8 (number that's out of bounds beyond the position of the last character at 7). What would you do to the 4 to get to the position of the first middle character at 3?"):P("Type the appropriate option (+ = ADD, - = SUBTRACT, * = MULTIPLY, / = DIVIDE) that you want to perform on positionOfSecondMiddleChar to calculate the position of the entered string's first middle character.")},function(e,t){var n=parseInt(t);t.startsWith('"')||t.startsWith("'")?P("Remember that positionOfSecondMiddleChar is a number and that quotes are for specific strings such as 'pizza'. Why would you subtract a specific string from a number and what would it mean?"):isNaN(n)?P("Regardless of whether the string is at, code, pizzas, scrabble, or any other string with an even number of characters (not 0), you can always subtract the same number from the position of the second middle character to get the position of the first middle character. The positions of the second middle characters and first characters are as follows (what number do you subtract from the first number to get the second?): \nat : 1 | 0\ncode : 2 | 1\npizzas : 3 | 2\nscrabble : 4 | 3"):P("If you subtract "+n+"from the position of the second middle character of SCRABBLE, you'll get 4"-n+", which is not the position of its first middle character (3). Try a different number. Also verify that it works for strings of other even lengths such as CODE.")}]);return t.error?t.match.join(""):e},init:function(){var e=this;this.appendDummyInput("STRING").appendField(new Blockly.FieldTextInput("",this.validate),"EXP"),this.setInputsInline(!1),this.setOutput(!1),this.setPreviousStatement(!0),this.setNextStatement(!0),this.setColour(60),this.setTooltip(T2C.MSG.currentLanguage.TYPEIN_STATEMENT_TOOLTIP),this.onchange=function(t){if(e.getFieldValue("EXP").endsWith("\r")||e.getFieldValue("EXP").endsWith("\n")||e.getFieldValue("EXP").length>0&&"workspaceClick"===t.element){if(!e.validate(e.getFieldValue("EXP"))||!e.getFieldValue("EXP").endsWith(")")&&!e.getFieldValue("EXP").endsWith(";"))return;var n=Object(o.getParseTree)(e.getFieldValue("EXP"));n?Object(o.handleParseTreeToBlocks)(n,e):P("Try checking what you entered again for mistakes.")}}}},Blockly.Python.type_in_get_first_middle_char=Blockly.JavaScript.type_in_get_first_middle_char=Blockly.JavaScript.code_statement,Blockly.Blocks.type_in_get_first_middle_char={validate:function(e){var t=w(e,[{token:"let",type:"terminal"},"firstMiddleChar","=","s",".",{token:"GETCHARACTERNUMBER",type:"terminal"},"(","positionOfFirstMiddleChar",")"],[I.bind(null,P,"LET"),function(){return P("Be sure to name the variable you're declaring firstMiddleChar to represent the fact that it's storing the string's first middle character.")},function(){return P("Remember to include an = after the variable firstMiddleChar you're declaring to set it to the string's first middle character.")},function(e,t){t.startsWith('"')?P("Don't use \" here as you want the computer to evaluate what you typed (e.g., the word the user entered instead of the letter s)"):t.startsWith("l")||t.startsWith("p")||t.startsWith("f")?P("To get the a character at a given position in a string, you'll first need to specify the string you want to get the first middle character from so you'll want to use s, which stores what the user entered."):P("Be sure to include the variable s that you want to the get the value's first middle character from.")},function(){return P("Be sure to include the . after the variable")},I.bind(null,P,"GETCHARACTERNUMBER"),function(e){return"You're missing an open parenthesis after "+e[5]+"."},function(e,t){t.startsWith('"')||t.startsWith("'")?P("Remember that quotes are for specific strings such as 'pizza', but you want something representing a number after the open parenthesis for "+e[5]+'. It wouldn\'t make sense to get the character at position *number* "pizza" of some string, right?'):isNaN(t)?P("You already have a variable storing the position number of the character that you want, don't you? If a variable stores the result of a valid math operation, it should be a number so you can use it here. For example, if s stores the 8-character user input SCRABBLE, s.length - 1 evaluates to 8 - 1 or 7. So if a variable positionOfLastChar is set to s.length-1, it'll store 7. You can then use s.length-1 in "+T2C.MSG.currentLanguage.TERMINAL_GETCHARACTERNUMBER+" and it'd get the 7th character. Now you don't have such a variable here, but you do have a variable that stores the position number of the first middle character, which is what you want, right?"):P("You can't use a specific number here since the position of the first middle character will depend on the length of the string entered.")},function(e,t){return P("You're missing a closing parenthesis for "+e[5]+".")}]);return t.error?t.match.join(""):e},init:function(){var e=this;this.appendDummyInput("STRING").appendField(new Blockly.FieldTextInput("",this.validate),"EXP"),this.setInputsInline(!1),this.setOutput(!1),this.setPreviousStatement(!0),this.setNextStatement(!0),this.setColour(60),this.setTooltip(T2C.MSG.currentLanguage.TYPEIN_STATEMENT_TOOLTIP),this.onchange=function(t){if(e.getFieldValue("EXP").endsWith("\r")||e.getFieldValue("EXP").endsWith("\n")||e.getFieldValue("EXP").length>0&&"workspaceClick"===t.element){if(!e.validate(e.getFieldValue("EXP"))||!e.getFieldValue("EXP").endsWith(")")&&!e.getFieldValue("EXP").endsWith(";"))return;var n=Object(o.getParseTree)(e.getFieldValue("EXP"));n?Object(o.handleParseTreeToBlocks)(n,e):P("Try checking what you entered again for mistakes.")}}}},Blockly.Python.type_in_get_second_middle_char=Blockly.JavaScript.type_in_get_second_middle_char=Blockly.JavaScript.code_statement,Blockly.Blocks.type_in_get_second_middle_char={validate:function(e){var t=w(e,[{token:"let",type:"terminal"},"secondMiddleChar","=","s",".",{token:"GETCHARACTERNUMBER",type:"terminal"},"(","positionOfSecondMiddleChar",")"],[I.bind(null,P,"LET"),function(){return P("Be sure to name the variable you're declaring secondMiddleChar to represent the fact that it's storing the string's second middle character.")},function(){return P("Remember to include an = after the variable secondMiddleChar you're declaring to set it to the string's second middle character.")},function(e,t){t.startsWith('"')?P("Don't use \" here as you want the computer to evaluate what you typed (e.g., the word the user entered instead of the letter s)"):t.startsWith("l")||t.startsWith("p")||t.startsWith("f")?P("To get the a character at a given position in a string, you'll first need to specify the string you want to get the second middle character from so you'll want to use s, which stores what the user entered."):P("Be sure to include the variable s that you want to the get the value's second middle character from.")},function(){return P("Be sure to include the . after the variable")},I.bind(null,P,"GETCHARACTERNUMBER"),function(e){return"You're missing an open parenthesis after "+e[5]+"."},function(e,t){t.startsWith('"')||t.startsWith("'")?P("Remember that quotes are for specific strings such as 'pizza', but you want something representing a number after the open parenthesis for "+e[5]+'. It wouldn\'t make sense to get the character at position *number* "pizza" of some string, right?'):isNaN(t)?P("You already have a variable storing the position number of the character that you want, don't you? If a variable stores the result of a valid math operation, it should be a number so you can use it here. For example, if s stores the 8-character user input SCRABBLE, s.length - 1 evaluates to 8 - 1 or 7. So if a variable positionOfLastChar is set to s.length-1, it'll store 7. You can then use s.length-1 in "+T2C.MSG.currentLanguage.TERMINAL_GETCHARACTERNUMBER+" and it'd get the 7th character. Now you don't have such a variable here, but you do have a variable that stores the position number of the second middle character, which is what you want, right?"):P("You can't use a specific number here since the position of the second middle character will depend on the length of the string entered.")},function(e,t){return P("You're missing a closing parenthesis for "+e[5]+".")}]);return t.error?t.match.join(""):e},init:function(){var e=this;this.appendDummyInput("STRING").appendField(new Blockly.FieldTextInput("",this.validate),"EXP"),this.setInputsInline(!1),this.setOutput(!1),this.setPreviousStatement(!0),this.setNextStatement(!0),this.setColour(60),this.setTooltip(T2C.MSG.currentLanguage.TYPEIN_STATEMENT_TOOLTIP),this.onchange=function(t){if(e.getFieldValue("EXP").endsWith("\r")||e.getFieldValue("EXP").endsWith("\n")||e.getFieldValue("EXP").length>0&&"workspaceClick"===t.element){if(!e.validate(e.getFieldValue("EXP"))||!e.getFieldValue("EXP").endsWith(")")&&!e.getFieldValue("EXP").endsWith(";"))return;var n=Object(o.getParseTree)(e.getFieldValue("EXP"));n?Object(o.handleParseTreeToBlocks)(n,e):P("Try checking what you entered again for mistakes.")}}}},Blockly.Python.type_in_combine_first_last_middle2_chars=Blockly.JavaScript.type_in_combine_first_last_middle2_chars=Blockly.JavaScript.code_statement,Blockly.Blocks.type_in_combine_first_last_middle2_chars={validate:function(e){var t=w(e,[{token:"display",type:"terminal"},"(","s","+",'"',": ",'"',"+","firstChar","+","lastChar","+","firstMiddleChar","+","secondMiddleChar",")"],[I.bind(null,P,"DISPLAY"),function(e,t){return P("You're missing an open parenthesis after "+e[0]+".")},function(){return P("First you want to display the string the user entered, which is stored in the variable s.")},function(){return P("Recall from Mission 0 that you can join strings using + .")},function(){return P("After the string the user entered, you want to literally display the separator text. Do you remember what you need to use so the string is displayed exactly as is.")},function(){return P("You want a colon followed by a space. Be sure to display both and nothing else.")},function(){return P("Remember that you'll need (to close the) quotation marks before joining it with the first character that comes next. This is because you'll want the computer to display the first character, which is stored in the variable firstChar. You don't want to literally display firstChar so it needs to be outside of quotation marks.")},function(){return P("You need to include +'s between all strings you want to join together.")},function(){return P("The first character should be displayed next. Recall that it's stored in firstChar.")},function(){return P("You need to include +'s between all strings you want to join together.")},function(){return P("The last character should be displayed next. Recall that it's stored in lastChar.")},function(){return P("You need to include +'s between all strings you want to join together.")},function(){return P("The first middle character should be displayed next. What variable stores it?")},function(){return P("You need to include +'s between all strings you want to join together.")},function(){return P("The second middle character should be displayed next. What variable stores it?")},function(e,t){return P("You're missing a closing parenthesis for "+e[0]+".")}]);return t.error?t.match.join(""):e},init:function(){var e=this;this.appendDummyInput("STRING").appendField(new Blockly.FieldTextInput("",this.validate),"EXP"),this.setInputsInline(!1),this.setOutput(!1),this.setPreviousStatement(!0),this.setNextStatement(!0),this.setColour(60),this.setTooltip(T2C.MSG.currentLanguage.TYPEIN_STATEMENT_TOOLTIP),this.onchange=function(t){if(e.getFieldValue("EXP").endsWith("\r")||e.getFieldValue("EXP").endsWith("\n")||e.getFieldValue("EXP").length>0&&"workspaceClick"===t.element){if(!e.validate(e.getFieldValue("EXP"))||!e.getFieldValue("EXP").endsWith(")")&&!e.getFieldValue("EXP").endsWith(";"))return;var n=Object(o.getParseTree)(e.getFieldValue("EXP"));n?Object(o.handleParseTreeToBlocks)(n,e):P("Try checking what you entered again for mistakes.")}}}},String.prototype.JSSubstring=function(e,t){return e>=this.length||e===t?"":this.substring(e,t)},Blockly.Python.type_in_all_but_first_specific_str=Blockly.JavaScript.type_in_all_but_first_specific_str=Blockly.JavaScript.code_statement,Blockly.Blocks.type_in_all_but_first_specific_str={validate:function(e){var t=U(e,[{token:"display",type:"terminal"},"(","welcomeMsg",".",{token:"GETTEXTFROMPOSITIONNUMBER",type:"terminal"},"(","1",")",".",{token:"TOPOSITIONNUMBER",type:"terminal"},"(","15",")",")"],[G.bind(null,$,"DISPLAY"),function(e,t){return $("You're missing an open parenthesis after "+e[0]+".")},function(){return $("Be sure to include the variable welcomeMsg that you want to extract text from.")},function(){return $("Be sure to include the . after the variable welcomeMsg you want to extract text from.")},G.bind(null,$,"GETTEXTFROMPOSITIONNUMBER"),function(e,t){return $("You're missing an open parenthesis after "+e[4]+".")},function(){return $("What position number should you start extracting from if you want to remove the initial character? Change this to the correct number.")},function(e,t){return $("You're missing a closing parenthesis for "+e[4]+" after the starting position number.")},function(){return $("Be sure to include the . after the closing parenthesis after the starting position number before the next part.")},G.bind(null,$,"TOPOSITIONNUMBER"),function(e,t){return $("You're missing an open parenthesis after "+e[9]+".")},function(){return $("What position number should you stop extracting from (stops one place before) if you want to get the rest of the string? Just use a *specific* number here. We'll generalize this so it works for other strings next. Change this to the correct number.")},function(e,t){return $("You're missing a closing parenthesis for "+e[9]+" after the ending position number.")},function(e,t){return $("You're missing a closing parenthesis for "+e[0]+".")}]);return t.error?t.match.join(""):e},init:function(){var e=this;this.appendDummyInput("STRING").appendField(new Blockly.FieldTextInput("",this.validate),"EXP"),this.setInputsInline(!1),this.setOutput(!1),this.setPreviousStatement(!0),this.setNextStatement(!0),this.setColour(60),this.setTooltip(T2C.MSG.currentLanguage.TYPEIN_STATEMENT_TOOLTIP),this.onchange=function(t){if(e.getFieldValue("EXP").endsWith("\r")||e.getFieldValue("EXP").endsWith("\n")||e.getFieldValue("EXP").length>0&&"workspaceClick"===t.element){if(!e.validate(e.getFieldValue("EXP"))||!e.getFieldValue("EXP").endsWith(")")&&!e.getFieldValue("EXP").endsWith(";"))return;var n=Object(o.getParseTree)(e.getFieldValue("EXP"));n?Object(o.handleParseTreeToBlocks)(n,e):$("Try checking what you entered again for mistakes.")}}}},Blockly.Python.type_in_all_but_first_general_str=Blockly.JavaScript.type_in_all_but_first_general_str=Blockly.JavaScript.code_statement,Blockly.Blocks.type_in_all_but_first_general_str={validate:function(e){var t=U(e,[{token:"display",type:"terminal"},"(","response",".",{token:"GETTEXTFROMPOSITIONNUMBER",type:"terminal"},"(","1",")",".",{token:"TOPOSITIONNUMBER",type:"terminal"},"(","response",".",{token:"LENGTH",type:"terminal"},")",")"],[G.bind(null,$,"DISPLAY"),function(e,t){return $("You're missing an open parenthesis after "+e[0]+".")},function(){return $("Be sure to include the variable response that you want to extract text from.")},function(){return $("Be sure to include the . after the variable response you want to extract text from.")},G.bind(null,$,"GETTEXTFROMPOSITIONNUMBER"),function(e,t){return $("You're missing an open parenthesis after "+e[4]+".")},function(){return $("What position number should you start extracting from if you want to remove the initial character? Change this to the correct number.")},function(e,t){return $("You're missing a closing parenthesis for "+e[4]+" after the starting position number.")},function(){return $("Be sure to include the . after the closing parenthesis after the starting position number before the next part.")},G.bind(null,$,"TOPOSITIONNUMBER"),function(e,t){return $("You're missing an open parenthesis after "+e[9]+".")},function(e,t){var n=parseInt(t);isNaN(n)?$("Remember the expression you used when you wanted to get the position of the last character for "+T2C.MSG.currentLanguage.TERMINAL_GETCHARACTERNUMBER+"? This is a little different because the ending position will be 1 past the position of the last character since we stop 1 place before.\nFor some examples of the numbers we'd want to use for some strings: ok: 2, theek: 5, bahut acchaa: 12"):$("Remember that since you no longer know how short or long the entered string will be, the stopping position will not always be at position "+n+". Instead, this position will depend on something about this string so your answer should refer to it.")},function(){return $("Be sure to include the . after the variable response you want to use.")},function(e,t){return $("What property of response do you want to get to determine the ending position here?")},function(e,t){-1!==t.replace(/\s/g,"").indexOf("-1")?$("Remember that "+T2C.MSG.currentLanguage.TERMINAL_GETTEXTFROMPOSITIONNUMBER+" ends one position before the numerical expression given. So for example, for a response of theek, response.length - 1 would be 5 - 1 or 4, which means you'd extract the text ending with the second e at position 3 instead of the k at position 4."):-1!==t.replace(/\s/g,"").indexOf("+1")?$("For a response of theek, response.length + 1 would be 5 + 1 or 6, but there is no 5th character since positions start at 0."):$("What you're doing to the "+T2C.MSG.currentLanguage.TERMINAL_LENGTH+" seems incorrect. Be sure to have examples in mind before deciding what to type. For example, for theek, the length is 5 and you want to go up to position 5 (since you'd stop extracting at character 4). If you're done, be sure to include a closing parenthesis for "+e[9]+" after the ending position.")},function(e,t){return $("You're missing a closing parenthesis for "+e[0]+".")}]);return t.error?t.match.join(""):e},init:function(){var e=this;this.appendDummyInput("STRING").appendField(new Blockly.FieldTextInput("",this.validate),"EXP"),this.setInputsInline(!1),this.setOutput(!1),this.setPreviousStatement(!0),this.setNextStatement(!0),this.setColour(60),this.setTooltip(T2C.MSG.currentLanguage.TYPEIN_STATEMENT_TOOLTIP),this.onchange=function(t){if(e.getFieldValue("EXP").endsWith("\r")||e.getFieldValue("EXP").endsWith("\n")||e.getFieldValue("EXP").length>0&&"workspaceClick"===t.element){if(!e.validate(e.getFieldValue("EXP"))||!e.getFieldValue("EXP").endsWith(")")&&!e.getFieldValue("EXP").endsWith(";"))return;var n=Object(o.getParseTree)(e.getFieldValue("EXP"));n?Object(o.handleParseTreeToBlocks)(n,e):$("Try checking what you entered again for mistakes.")}}}},String.prototype.JSSubstring=function(e,t){return e>=this.length||e===t?"":this.substring(e,t)},Blockly.Python.type_in_get_email_input=Blockly.JavaScript.type_in_get_email_input=Blockly.JavaScript.code_statement,Blockly.Blocks.type_in_get_email_input={validate:function(e){var t=ee(e,[{token:"let",type:"terminal"},"email","=",{token:"GETINPUTBYASKING",type:"terminal"},"(",{token:/^"[^"]*$|^'[^']*$|^"[^"]*e[-]?mail[^"]*"|^'[^']*e[-]?[^']*mail'/i,type:"regexp"},")"],[Q.bind(null,ne,"LET"),function(){return ne("Be sure to name the variable you're declaring email to represent the fact that it's storing the entered e-mail address.")},function(){return ne("Remember to include an = after the variable email you're declaring to set it to the entered e-mail address.")},Q.bind(null,ne,"GETINPUTBYASKING"),function(e){return ne("You're missing an open parenthesis after "+e[3]+".")},function(){return ne('The message to supply to the user should be surrounded by " and " because you want it to be displayed as is. Be sure it also includes e-mail in it so the user knows to enter an e-mail.')},function(e,t){return ne("You're missing a closing parenthesis for "+e[3]+".")}]);return t.error?t.match.join(""):e},init:function(){var e=this;this.appendDummyInput("STRING").appendField(new Blockly.FieldTextInput("",this.validate),"EXP"),this.setInputsInline(!1),this.setOutput(!1),this.setPreviousStatement(!0),this.setNextStatement(!0),this.setColour(60),this.setTooltip(T2C.MSG.currentLanguage.TYPEIN_STATEMENT_TOOLTIP),this.onchange=function(t){if(e.getFieldValue("EXP").endsWith("\r")||e.getFieldValue("EXP").endsWith("\n")||e.getFieldValue("EXP").length>0&&"workspaceClick"===t.element){if(!e.validate(e.getFieldValue("EXP"))||!e.getFieldValue("EXP").endsWith(")")&&!e.getFieldValue("EXP").endsWith(";"))return;var n=Object(o.getParseTree)(e.getFieldValue("EXP"));n?Object(o.handleParseTreeToBlocks)(n,e):ne("Try checking what you entered again for mistakes.")}}}},Blockly.Python.type_in_between_at_and_period=Blockly.JavaScript.type_in_between_at_and_period=Blockly.JavaScript.code_statement,Blockly.Blocks.type_in_between_at_and_period={validate:function(e){var t="coolcoder@google.com",n=ee(e,[{token:"display",type:"terminal"},"(","email",".",{token:"GETTEXTFROMPOSITIONNUMBER",type:"terminal"},"(","email",".",{token:"FINDFIRSTOCCURRENCEOFTEXT",type:"terminal"},"(",'"',"@",'"',")","+","1",")",".",{token:"TOPOSITIONNUMBER",type:"terminal"},"(","email",".",{token:"FINDFIRSTOCCURRENCEOFTEXT",type:"terminal"},"(",'"',".",'"',")",")",")"],[Q.bind(null,ne,"DISPLAY"),function(e,t){return ne("You're missing an open parenthesis after "+e[0]+".")},function(){return ne("Be sure to include the variable email that you want to extract text from.")},function(){return ne("Be sure to include the . after the variable email you want to extract text from.")},Q.bind(null,ne,"GETTEXTFROMPOSITIONNUMBER"),function(e,t){return ne("You're missing an open parenthesis after "+e[4]+".")},function(e,t){t.startsWith("(")?ne("Although you *can* have multiple opening parentheses as shown above, it's not necessary in this instance. When you first start programming, it may be good to include them to make sure operations are performed in the required order, but it can also make your code more difficult to read and correctly match the open parentheses with closing ones. Before continuing, remove the extra opening parenthesis here since you don't need it."):ne("The starting position will be as before, *the position* of the @ sign in email + 1. To get the position of the needle @ in the haystack email, we'll first need to specify the variable email to search.")},function(){return ne("Be sure to include the . after the variable email you want to search.")},Q.bind(null,ne,"FINDFIRSTOCCURRENCEOFTEXT"),function(e,t){return ne("You're missing an open parenthesis after "+e[8]+".")},function(e,t){t.startsWith("@")?ne("Since you're looking for the literal @ sign and don't want the computer to evaluate it in any way, you need to surround it with quotation marks."):ne("Since the needle you're going to use here is a literal string and not an expression, you need to surround it with quotation marks. You're currently missing quotation marks.")},function(e,t){return ne("What string do you want to get the position of to help you determine where you should start? "+(-1===t.indexOf('"')?t:t.substring(0,t.indexOf('"')))+" is not correct.")},function(e,t){return ne("You're missing closing quotation marks for "+e[e.length-1]+".")},function(e,t){t.startsWith("+")?ne("Be careful where you place the +; you certainly don't want to add a number to the string @! Instead you want to add a number to the *position* of the @ in email so it should go outside of the "+e[8]+"."):ne("You're missing a closing parenthesis for "+e[8]+".")},function(e,t){t.startsWith(")")||t.startsWith(".")?ne("You do not want to start extracting text at the @ exactly since you want to get the text *after* it. As with before, you'll want to start at the position after so you'll need to do what arithmetic operation to the position number you get?"):t.replace(/\s/g,"").startsWith("--1")?ne("Add 1 instead of subtracting -1 as this makes your code clearer."):ne("As in the previous part, what operation and number should you use on the position of the @ you get from "+T2C.MSG.currentLanguage.TERMINAL_FINDFIRSTOCCURRENCEOFTEXT+" to start at the position number after the position of the @?")},function(e,t){var n=parseInt(t);!isNaN(n)||t.startsWith("-")?ne("What number do you want to add to the position number of the first occurrence of the @ to get to the position you want to start at? Change this to the correct number."):ne(T2C.MSG.currentLanguage.TERMINAL_FINDFIRSTOCCURRENCEOFTEXT+" gives you back a number. What specific *number* do you want to add to the position number of the first occurrence of the @ to get to the position you want to start at? Change this to the correct number.")},function(e,t){return ne("You're missing a closing parenthesis for "+e[4]+" after the starting position number.")},function(){return ne("Be sure to include the . after the closing parenthesis after the starting position number before the next part.")},Q.bind(null,ne,"TOPOSITIONNUMBER"),function(e,t){return ne("You're missing an open parenthesis after "+e[e.length-1]+".")},function(e,n){var o=parseInt(n);isNaN(o)?Z(n,"FINDFIRSTOCCURRENCEOFTEXT")?ne("You'll need to refer to the variable name before using "+T2C.MSG.currentLanguage.TERMINAL_FINDFIRSTOCCURRENCEOFTEXT+" so the computer knows which string to search through (haystack) to find the given needle."):ne("The correct place to stop extracting text will depend on the e-mail address. For an email of "+t+", you'd use "+t.indexOf(".")+" (stopping before it), but for jdoe@foo.com, you'd want to use "+"jdoe@foo.com".indexOf(".")+". Since it depends on some property of the entered e-mail address, start by entering the appropriate variable name here."):ne("The correct place to stop extracting text cannot be a specific number if you want it to work in general regardless of the e-mail address. For an email of "+t+", you'd use "+t.indexOf(".")+" (stopping before it), but for jdoe@foo.com, you'd want to use "+"jdoe@foo.com".indexOf(".")+". Since it depends on some property of the entered e-mail address, start by entering the appropriate variable name here instead of a specific number.")},function(){return ne("Be sure to include the . after the variable email you want to use to refer to one of its properties.")},function(e,t){Z(t,"LENGTH")?ne("If you stop immediately before the position given by the length of the variable email, you'll get the substring of all text after the @ but you only want to get the text in between the @ and ."):Z(t,"GETCHARACTERNUMBER")?ne(T2C.MSG.currentLanguage.TERMINAL_GETCHARACTERNUMBER+" gives you a *character* at a specific position; it won't give you a number, which you need for the position to stop before for "+T2C.MSG.currentLanguage.TERMINAL_GETTEXTFROMPOSITIONNUMBER+"."):Z(t,"GETTEXTFROMPOSITIONNUMBER")?ne(T2C.MSG.currentLanguage.TERMINAL_GETTEXTFROMPOSITIONNUMBER+" gives you part of the text; you're already using that, but you want a number, which you need for the position to stop before."):ne("What property of email do you want to get to determine the ending position here? Make sure your spelling and capitalization (e.g., M versus m) are correct.")},function(e,t){return ne("You're missing an open parenthesis after "+e[e.length-1]+".")},function(e,t){t.startsWith(".")?ne("Since you're looking for the literal . and don't want the computer to evaluate it in any way, you need to surround it with quotation marks."):ne("Since the needle you're going to use here is a literal string and not an expression, you need to surround it with quotation marks. You're currently missing quotation marks.")},function(e,t){return ne("What string do you want to get the position of to help you determine where you should end?"+(-1===t.indexOf('"')?t:t.substring(0,t.indexOf('"')))+" is not correct.")},function(e,t){return ne("You're missing closing quotation marks for "+e[e.length-1]+".")},function(e,t){t.startsWith("+")||t.startsWith("-")?ne("Be careful where you place the math operation; you certainly don't want to add/subtract a number from a period! Any math you may want to do to the *position* of the period in email (which may not be necessary) should go outside of the parentheses for the character to find in "+e[18]+"."):ne("You're missing a closing parenthesis for "+e[22]+".")},function(e,n){-1!==n.replace(/\s/g,"").indexOf("-1")?ne("Remember that "+T2C.MSG.currentLanguage.TERMINAL_GETTEXTFROMPOSITIONNUMBER+" ends one position before the numerical expression given. So for example, for an e-mail of "+t+", you'd want to use "+t.indexOf(".")+" so the last character you'd extract would be at position "+(t.indexOf(".")-1)+", mainly the "+t[t.indexOf(".")-1]+" before the period. If you subtracted 1, you'd instead stop extracting text at position "+(t.indexOf(".")-2)+" so you'd instead incorrectly get the "+t[t.indexOf(".")-2]+" as the last character."):-1!==n.replace(/\s/g,"").indexOf("+1")?ne("Although "+T2C.MSG.currentLanguage.TERMINAL_GETTEXTFROMPOSITIONNUMBER+" ends one position before the numerical expression given, you want to stop before the period anyway. Adding 1 means you'll instead stop at the period. For example, for an e-mail of "+t+" the period would be located at position "+t.indexOf(".")+" so by adding 1, you'd get "+(t.indexOf(".")+1)+", which means the last character you'd extract would be at position "+t.indexOf(".")+", mainly the period itself."):ne("What you're doing to the ending position of "+T2C.MSG.currentLanguage.TERMINAL_GETTEXTFROMPOSITIONNUMBER+" seems incorrect or unnecessary. Be sure to have examples in mind before deciding what to type. If you're done, be sure to include a closing parenthesis for "+e[18]+" after the ending position.")},function(e,t){return ne("You're missing a closing parenthesis for "+e[0]+".")}]);return n.error?n.match.join(""):e},init:function(){var e=this;this.appendDummyInput("STRING").appendField(new Blockly.FieldTextInput("",this.validate),"EXP"),this.setInputsInline(!1),this.setOutput(!1),this.setPreviousStatement(!0),this.setNextStatement(!0),this.setColour(60),this.setTooltip(T2C.MSG.currentLanguage.TYPEIN_STATEMENT_TOOLTIP),this.onchange=function(t){if(e.getFieldValue("EXP").endsWith("\r")||e.getFieldValue("EXP").endsWith("\n")||e.getFieldValue("EXP").length>0&&"workspaceClick"===t.element){if(!e.validate(e.getFieldValue("EXP"))||!e.getFieldValue("EXP").endsWith(")")&&!e.getFieldValue("EXP").endsWith(";"))return;var n=Object(o.getParseTree)(e.getFieldValue("EXP"));n?Object(o.handleParseTreeToBlocks)(n,e):ne("Try checking what you entered again for mistakes.")}}}},String.prototype.JSSubstring=function(e,t){return e>=this.length||e===t?"":this.substring(e,t)},Blockly.Python.type_in_display_first_last_name=Blockly.JavaScript.type_in_display_first_last_name=Blockly.JavaScript.code_statement,Blockly.Blocks.type_in_display_first_last_name={validate:function(e){var t=le(e,[{token:"display",type:"terminal"},"(","firstName","+",{token:/^" "|^' '/,type:"regexp"},"+","lastName",")"],[ae.bind(null,ue,"DISPLAY"),function(e,t){return ue("You're missing an open parenthesis after "+e[0]+".")},function(e,t){t.startsWith('"')||t.startsWith("'")?ue("If you're using variable names to be evaluated instead of displayed as is (e.g., displaying the text Jane instead of the text firstName), you don't want to use quotation marks."):ue('Remember the variable names are firstName and lastName. If firstName = "Jane" and lastName = "Doe" and you want to display "Jane Doe", what should be displayed first?')},function(){return ue("How do you join strings together?")},function(e,t){"lastName".toLowerCase().startsWith(t.toLowerCase())||t.toLowerCase().startsWith("lastName".toLowerCase())?ue('Remember that you\'ll want a space between the first and last name; joining the two strings together without one would result in "JaneDoe" instead of say "Jane Doe".'):ue("Remember that you want to *literally* display a space between the first and last name. What do you need to surround text with (including spaces) when you want to display something without evaluating it?")},function(){return ue("How do you join strings together?")},function(e,t){t.startsWith('"')||t.startsWith("'")?ue("If you're using variable names to be evaluated instead of displayed as is (e.g., displaying the text Doe instead of the text lastName), you don't want to use quotation marks."):ue('Remember the variable names are firstName and lastName. If firstName = "Jane" and lastName = "Doe" and you want to display "Jane Doe", what should be displayed last?')},function(e,t){return ue("You're missing a closing parenthesis for "+e[0]+".")}]);return t.error?t.match.join(""):e},init:function(){var e=this;this.appendDummyInput("STRING").appendField(new Blockly.FieldTextInput("",this.validate),"EXP"),this.setInputsInline(!1),this.setOutput(!1),this.setPreviousStatement(!0),this.setNextStatement(!0),this.setColour(60),this.setTooltip(T2C.MSG.currentLanguage.TYPEIN_STATEMENT_TOOLTIP),this.onchange=function(t){if(e.getFieldValue("EXP").endsWith("\r")||e.getFieldValue("EXP").endsWith("\n")||e.getFieldValue("EXP").length>0&&"workspaceClick"===t.element){if(!e.validate(e.getFieldValue("EXP"))||!e.getFieldValue("EXP").endsWith(")")&&!e.getFieldValue("EXP").endsWith(";"))return;var n=Object(o.getParseTree)(e.getFieldValue("EXP"));n?Object(o.handleParseTreeToBlocks)(n,e):ue("Try checking what you entered again for mistakes.")}}}},Blockly.Python.type_in_set_last_name=Blockly.JavaScript.type_in_set_last_name=Blockly.JavaScript.code_statement,Blockly.Blocks.type_in_set_last_name={validate:function(e){"Doe, Jane".substring(0,"Doe, Jane".indexOf(",")),"Doe, Jane".substring("Doe, Jane".indexOf(",")+2),"Doe, Jane".substring(0,"Doe, Jane".indexOf(",")),"Doe, Jane".substring("Doe, Jane".indexOf(",")+2);var t=le(e,[{token:"let",type:"terminal"},"lastName","=","enteredName",".",{token:"GETTEXTFROMPOSITIONNUMBER",type:"terminal"},"(","0",")",".",{token:"TOPOSITIONNUMBER",type:"terminal"},"(","commaPosition",")"],[ae.bind(null,ue,"LET"),function(){return ue("Be sure to name the variable you're declaring lastName to represent the fact that it should store the last name if the user entered the input in the correct form. Since you use lastName in the "+T2C.MSG.currentLanguage.TERMINAL_DISPLAY+" statement, you need to use lastName here.")},function(){return ue("Remember to include an = after the variable lastName you're declaring to set it to the value that follows.")},function(){return ue("Be sure to include the variable enteredName that you want to extract text from.")},function(){return ue("Be sure to include the . after the variable enteredName you want to extract text from.")},ae.bind(null,ue,"GETTEXTFROMPOSITIONNUMBER"),function(e,t){return ue("You're missing an open parenthesis after "+e[5]+".")},function(e,t){t.startsWith("(")?ue("Although you *can* have multiple opening parentheses, it's not necessary in this instance. When you first start programming, it may be good to include them to make sure operations are performed in the required order, but it can also make your code more difficult to read and correctly match the open parentheses with closing ones. Before continuing, remove the extra opening parenthesis here since you don't need it."):1===parseInt(t)?ue("Remember that positions start at 0."):parseInt(t)?ue("The last name starts at the beginning of the string. What number should you use if you want to start extracting text there?"):ue("The last name starts at the beginning of the string so regardless of the string the user enters, the numerical position will always be the same. Use a specific number, accordingly.")},function(e,t){return ue("You're missing a closing parenthesis for "+e[5]+" after the starting position number.")},function(){return ue("Be sure to include the . after the closing parenthesis after the starting position number before the next part.")},ae.bind(null,ue,"TOPOSITIONNUMBER"),function(e,t){return ue("You're missing an open parenthesis after "+e[e.length-1]+".")},function(e,t){var n=parseInt(t);isNaN(n)?re(t,"FINDFIRSTOCCURRENCEOFTEXT")?ue("You'd need to refer to the variable name before using "+T2C.MSG.currentLanguage.TERMINAL_FINDFIRSTOCCURRENCEOFTEXT+" so the computer knows which string to search through (haystack) to find the given needle, but remember that you're already assuming you have a variable that stores the position of the comma, which might help..."):ue("For an entered name of Doe, Jane, you'd use "+"Doe, Jane".indexOf(",")+" (stopping before it), but for Torvalds, Linus, you'd want to use "+"Torvalds, Linus".indexOf(",")+". Since it depends on the position of the comma, start by entering the appropriate variable name here."):ue("The correct place to stop extracting text cannot be a specific number if you want it to work in general regardless of the entered name. For an entered name of Doe, Jane, you'd use "+"Doe, Jane".indexOf(",")+" (stopping before it), but for Torvalds, Linus, you'd want to use "+"Torvalds, Linus".indexOf(",")+". Since it depends on the position of the comma, start by entering the appropriate variable name here instead of a specific number.")},function(e,t){-1!==t.replace(/\s/g,"").indexOf("-1")?ue("Remember that "+T2C.MSG.currentLanguage.TERMINAL_GETTEXTFROMPOSITIONNUMBER+" ends one position before the numerical expression given. So for example, for an entered name of Doe, Jane, you'd want to use "+"Doe, Jane".indexOf(",")+" so the last character you'd extract would be at position "+("Doe, Jane".indexOf(",")-1)+", mainly the "+"Doe, Jane"["Doe, Jane".indexOf(",")-1]+" before the comma. If you subtracted 1, you'd instead stop extracting text at position "+("Doe, Jane".indexOf(",")-2)+" so you'd instead incorrectly get the "+"Doe, Jane"["Doe, Jane".indexOf(",")-2]+" as the last character."):-1!==t.replace(/\s/g,"").indexOf("+1")?ue("Although "+T2C.MSG.currentLanguage.TERMINAL_GETTEXTFROMPOSITIONNUMBER+" ends one position before the numerical expression given, you want to stop before the comma anyway. Adding 1 means you'll instead stop at the comma. For example, for an entered name of Doe, Jane the comma would be located at position "+"Doe, Jane".indexOf(",")+" so by adding 1, you'd get "+("Doe, Jane".indexOf(",")+1)+", which means the last character you'd extract would be at position "+"Doe, Jane".indexOf(",")+", mainly the comma itself."):ue("What you're doing to the ending position of "+T2C.MSG.currentLanguage.TERMINAL_GETTEXTFROMPOSITIONNUMBER+" seems incorrect or unnecessary. Be sure to have examples in mind before deciding what to type. If you're done, be sure to include a closing parenthesis for "+e[10]+" after the ending position.")}]);return t.error?t.match.join(""):e},init:function(){var e=this;this.appendDummyInput("STRING").appendField(new Blockly.FieldTextInput("",this.validate),"EXP"),this.setInputsInline(!1),this.setOutput(!1),this.setPreviousStatement(!0),this.setNextStatement(!0),this.setColour(60),this.setTooltip(T2C.MSG.currentLanguage.TYPEIN_STATEMENT_TOOLTIP),this.onchange=function(t){if(e.getFieldValue("EXP").endsWith("\r")||e.getFieldValue("EXP").endsWith("\n")||e.getFieldValue("EXP").length>0&&"workspaceClick"===t.element){if(!e.validate(e.getFieldValue("EXP"))||!e.getFieldValue("EXP").endsWith(")")&&!e.getFieldValue("EXP").endsWith(";"))return;var n=Object(o.getParseTree)(e.getFieldValue("EXP"));n?Object(o.handleParseTreeToBlocks)(n,e):ue("Try checking what you entered again for mistakes.")}}}},Blockly.Python.type_in_set_first_name=Blockly.JavaScript.type_in_set_first_name=Blockly.JavaScript.code_statement,Blockly.Blocks.type_in_set_first_name={validate:function(e){var t="Torvalds, Linus",n=("Doe, Jane".substring(0,"Doe, Jane".indexOf(",")),"Doe, Jane".substring("Doe, Jane".indexOf(",")+2)),o=(t.substring(0,t.indexOf(",")),t.substring(t.indexOf(",")+2)),i=le(e,[{token:"let",type:"terminal"},"firstName","=","enteredName",".",{token:"GETTEXTFROMPOSITIONNUMBER",type:"terminal"},"(","commaPosition","+","2",")",".",{token:"TOPOSITIONNUMBER",type:"terminal"},"(","enteredName",".",{token:"LENGTH",type:"terminal"},")"],[ae.bind(null,ue,"LET"),function(){return ue("Be sure to name the variable you're declaring firstName to represent the fact that it should store the first name if the user entered the input in the correct form. Since you use firstName in the "+T2C.MSG.currentLanguage.TERMINAL_DISPLAY+" statement, you need to use firstName here.")},function(){return ue("Remember to include an = after the variable firstName you're declaring to set it to first name.")},function(){return ue("Be sure to include the variable enteredName that you want to extract text from.")},function(){return ue("Be sure to include the . after the variable enteredName you want to extract text from.")},ae.bind(null,ue,"GETTEXTFROMPOSITIONNUMBER"),function(e,t){return ue("You're missing an open parenthesis after "+e[5]+".")},function(e,n){var o=parseInt(n);isNaN(o)?re(n,"FINDFIRSTOCCURRENCEOFTEXT")?ue("You'd need to refer to the variable name before using "+T2C.MSG.currentLanguage.TERMINAL_FINDFIRSTOCCURRENCEOFTEXT+" so the computer knows which string to search through (haystack) to find the given needle, but remember that you're already assuming you have a variable that stores the position of the comma, which might help..."):ue("For an entered name of Doe, Jane, you'd use "+("Doe, Jane".indexOf(",")+2)+", but for "+t+", you'd want to use "+(t.indexOf(",")+2)+". Since it depends on the position of the comma, start by entering the appropriate variable name here."):ue("The correct place to start extracting text cannot be a specific number if you want it to work in general regardless of the entered name. For an entered name of Doe, Jane, you'd use "+("Doe, Jane".indexOf(",")+2)+", but for "+t+", you'd want to use "+(t.indexOf(",")+2)+". Since it depends on the position of the comma, start by entering the appropriate variable name here instead of a specific number.")},function(e,i){i.startsWith(")")||i.startsWith(".")?ue("You do not want to start extracting text at the comma exactly since you want to get the text *after* the space that follows it. What arithmetic operation do you want to perform on the position number you get and with what number to start at the character after the space after the comma? For Doe, Jane, the comma position will be at "+"Doe, Jane".indexOf(",")+" but you'll want to start at position "+("Doe, Jane".indexOf(",")+2)+", with "+n[0]+" whereas for "+t+", the comma position will be at "+t.indexOf(",")+" but you'll want to start at position "+(t.indexOf(",")+2)+", with "+o[0]+"."):i.replace(/\s/g,"").startsWith("--2")?ue("Add 2 instead of subtracting -2 as this makes your code clearer."):ue("What arithmetic operation do you want to perform on the position number you get and with what number to start at the character after the space after the comma? For Doe, Jane, the comma position will be at "+"Doe, Jane".indexOf(",")+" but you'll want to start at position "+("Doe, Jane".indexOf(",")+2)+", with "+n[0]+" whereas for "+t+", the comma position will be at "+t.indexOf(",")+" but you'll want to start at position "+(t.indexOf(",")+2)+", with "+o[0]+".")},function(e,i){var r=parseInt(i);!isNaN(r)||i.startsWith("-")?ue(1===r?"Remember that there's a space after the comma and you don't want to start with the space. What number do you want to add to the position number of the first occurrence of the , to get to the position you want to start at? For Doe, Jane, the comma position will be at "+"Doe, Jane".indexOf(",")+" but you'll want to start at position "+("Doe, Jane".indexOf(",")+2)+", with "+n[0]+" whereas for "+t+", the comma position will be at "+t.indexOf(",")+" but you'll want to start at position "+(t.indexOf(",")+2)+", with "+o[0]+". Change this to the correct number, accordingly.":"What number do you want to add to the position number of the first occurrence of the , to get to the position you want to start at? For Doe, Jane, the comma position will be at "+"Doe, Jane".indexOf(",")+" but you'll want to start at position "+("Doe, Jane".indexOf(",")+2)+", with "+n[0]+" whereas for "+t+", the comma position will be at "+t.indexOf(",")+" but you'll want to start at position "+(t.indexOf(",")+2)+", with "+o[0]+". Change this to the correct number, accordingly."):ue("If the name is entered correctly as e.g., Doe, Jane or "+t+", then the number of places the last name will be beyond the position of the comma will always be the same so you can enter a *specific* number. For Doe, Jane, the comma position will be at "+"Doe, Jane".indexOf(",")+" but you'll want to start at position "+("Doe, Jane".indexOf(",")+2)+", with "+n[0]+" whereas for "+t+", the comma position will be at "+t.indexOf(",")+" but you'll want to start at position "+(t.indexOf(",")+2)+", with "+o[0]+". Change your answer to the specific number you can add in both cases, accordingly.")},function(e,t){return ue("You're missing a closing parenthesis for "+e[5]+" after the starting position number.")},function(){return ue("Be sure to include the . after the closing parenthesis after the starting position number before the next part.")},ae.bind(null,ue,"TOPOSITIONNUMBER"),function(e,t){return ue("You're missing an open parenthesis after "+e[e.length-1]+".")},function(e,n){var o=parseInt(n);isNaN(o)?n.startsWith("commaPosition")||"commaPosition".startsWith(n)?ue("You don't want to stop extracting text at commaPosition, do you?"):ue("If entered correctly, the end of the first name will be at the end of the entered string. For Doe, Jane, you'd use "+"Doe, Jane".length+" while for "+t+", you'd use "+t.length+", the position number after the last character. Since this position number will depend on something about the entered name, your answer should refer to it."):ue("The stopping position will not always be at position "+o+". Instead, this position will depend on something about the entered name so your answer should refer to it.")},function(){return ue("Be sure to include the . after the variable enteredName you want to use.")},function(e,n){return ue("If entered correctly, the end of the first name will be at the end of the entered string. For Doe, Jane, you'd use "+"Doe, Jane".length+" while for "+t+", you'd use "+t.length+", the position number after the last character. Do you remember how you can get these positions from the entered name?")},function(e,t){-1!==t.replace(/\s/g,"").indexOf("-1")?ue("Remember that "+T2C.MSG.currentLanguage.TERMINAL_GETTEXTFROMPOSITIONNUMBER+" ends one position before the numerical expression given. So for example, for an enteredName of Doe, Jane, sampleInput.length - 1 would be "+("Doe, Jane".length-1)+", which means you'd extract the text ending with the "+"Doe, Jane".charAt("Doe, Jane".length-2)+" instead of the last character of "+"Doe, Jane".charAt("Doe, Jane".length-1)+"."):-1!==t.replace(/\s/g,"").indexOf("+1")?ue("For an enteredName of Doe, Jane, enteredName.length + 1 would be "+("Doe, Jane".length+1)+", but there is no character at this position since positions start at 0."):ue("What you're doing to the "+T2C.MSG.currentLanguage.TERMINAL_LENGTH+" seems incorrect. Be sure to have examples in mind before deciding what to type. For example, for Doe, Jane, the length is "+"Doe, Jane".length+" and you want to go up to position "+"Doe, Jane".length+" (since you'd stop extracting at character "+("Doe, Jane".length-1)+"). If you're done, be sure to include a closing parenthesis for "+e[12]+" after the ending position.")}]);return i.error?i.match.join(""):e},init:function(){var e=this;this.appendDummyInput("STRING").appendField(new Blockly.FieldTextInput("",this.validate),"EXP"),this.setInputsInline(!1),this.setOutput(!1),this.setPreviousStatement(!0),this.setNextStatement(!0),this.setColour(60),this.setTooltip(T2C.MSG.currentLanguage.TYPEIN_STATEMENT_TOOLTIP),this.onchange=function(t){if(e.getFieldValue("EXP").endsWith("\r")||e.getFieldValue("EXP").endsWith("\n")||e.getFieldValue("EXP").length>0&&"workspaceClick"===t.element){if(!e.validate(e.getFieldValue("EXP"))||!e.getFieldValue("EXP").endsWith(")")&&!e.getFieldValue("EXP").endsWith(";"))return;var n=Object(o.getParseTree)(e.getFieldValue("EXP"));n?Object(o.handleParseTreeToBlocks)(n,e):ue("Try checking what you entered again for mistakes.")}}}},Blockly.Python.type_in_set_comma_pos=Blockly.JavaScript.type_in_set_comma_pos=Blockly.JavaScript.code_statement,Blockly.Blocks.type_in_set_comma_pos={validate:function(e){var t=le(e,[{token:"let",type:"terminal"},"commaPosition","=","enteredName",".",{token:"FINDFIRSTOCCURRENCEOFTEXT",type:"terminal"},"(",{token:/",[ ]?"|',[ ]?'/,type:"regexp"},")"],[ae.bind(null,ue,"LET"),function(){return ue("Be sure to name the variable you're declaring commaPosition to represent the fact that it should store the position of the comma. Since you use commaPosition in the assignment of firstName and lastName, you need to use commaPosition here as well.")},function(){return ue("Remember to include an = after the variable commaPosition you're declaring to set it to a value.")},function(){return ue("Be sure to include the variable enteredName that you want to get the position of the comma from.")},function(){return ue("Be sure to include the . after the variable enteredName you want to get the comma from.")},ae.bind(null,ue,"FINDFIRSTOCCURRENCEOFTEXT"),function(e,t){return ue("You're missing an open parenthesis after "+e[5]+".")},function(e,t){t.startsWith(",")?ue("Since you're looking for the literal , and don't want the computer to evaluate it in any way, you need to surround it with quotation marks."):t.startsWith("'")||t.startsWith('"')?","!==t[1]?ue("What string literal are you getting the position for?"):ue("You're only looking for the comma, correct? If so, remember to close the quotation marks."):ue("Since the needle you're going to use here is a literal string and not an expression, you need to surround it with quotation marks. You're currently missing quotation marks.")},function(e,t){return ue("You're missing a closing parenthesis for "+e[5]+".")}]);return t.error?t.match.join(""):e},init:function(){var e=this;this.appendDummyInput("STRING").appendField(new Blockly.FieldTextInput("",this.validate),"EXP"),this.setInputsInline(!1),this.setOutput(!1),this.setPreviousStatement(!0),this.setNextStatement(!0),this.setColour(60),this.setTooltip(T2C.MSG.currentLanguage.TYPEIN_STATEMENT_TOOLTIP),this.onchange=function(t){if(e.getFieldValue("EXP").endsWith("\r")||e.getFieldValue("EXP").endsWith("\n")||e.getFieldValue("EXP").length>0&&"workspaceClick"===t.element){if(!e.validate(e.getFieldValue("EXP"))||!e.getFieldValue("EXP").endsWith(")")&&!e.getFieldValue("EXP").endsWith(";"))return;var n=Object(o.getParseTree)(e.getFieldValue("EXP"));n?Object(o.handleParseTreeToBlocks)(n,e):ue("Try checking what you entered again for mistakes.")}}}},Blockly.Python.type_in_get_last_first_name_input=Blockly.JavaScript.type_in_get_last_first_name_input=Blockly.JavaScript.code_statement,Blockly.Blocks.type_in_get_last_first_name_input={validate:function(e){var t=le(e,[{token:"let",type:"terminal"},"enteredName","=",{token:"GETINPUTBYASKING",type:"terminal"},"(",{token:/^"[^"]*$|^'[^']*$|^"[^"]*name[^"]*"|^'[^']*name[^']*'/i,type:"regexp"},")"],[ae.bind(null,ue,"LET"),function(){return ue("Be sure to name the variable you're declaring enteredName to represent the fact that it's storing the entered name.")},function(){return ue("Remember to include an = after the variable enteredName you're declaring to set it to the entered name.")},ae.bind(null,ue,"GETINPUTBYASKING"),function(e){return ue("You're missing an open parenthesis after "+e[3]+".")},function(){return ue('The message to supply to the user should be surrounded by " and " because you want it to be displayed as is. Be sure it also includes name in it so the user knows to enter a name. You\'ll also want to indicate the form: last name, first name, perhaps with an example (e.g., Doe, Jane).')},function(e,t){return ue("You're missing a closing parenthesis for "+e[3]+".")}]);return t.error?t.match.join(""):e},init:function(){var e=this;this.appendDummyInput("STRING").appendField(new Blockly.FieldTextInput("",this.validate),"EXP"),this.setInputsInline(!1),this.setOutput(!1),this.setPreviousStatement(!0),this.setNextStatement(!0),this.setColour(60),this.setTooltip(T2C.MSG.currentLanguage.TYPEIN_STATEMENT_TOOLTIP),this.onchange=function(t){if(e.getFieldValue("EXP").endsWith("\r")||e.getFieldValue("EXP").endsWith("\n")||e.getFieldValue("EXP").length>0&&"workspaceClick"===t.element){if(!e.validate(e.getFieldValue("EXP"))||!e.getFieldValue("EXP").endsWith(")")&&!e.getFieldValue("EXP").endsWith(";"))return;var n=Object(o.getParseTree)(e.getFieldValue("EXP"));n?Object(o.handleParseTreeToBlocks)(n,e):ue("Try checking what you entered again for mistakes.")}}}},String.prototype.JSSubstring=function(e,t){return e>=this.length||e===t?"":this.substring(e,t)},Blockly.Python.type_in_get_input_with_s=Blockly.JavaScript.type_in_get_input_with_s=Blockly.JavaScript.code_statement,Blockly.Blocks.type_in_get_input_with_s={validate:function(e){var t=pe(e,[{token:"let",type:"terminal"},"enteredTextWithS","=",T2C.MSG.JS.TERMINAL_GETINPUTBYASKING,"(",{token:/^"[^"]*$|^'[^']*$|^"[^"]*with an s[^"]*"|^'[^']*with an s[^']*'/i,type:"regexp"},")"],[he.bind(null,me,"LET"),function(){return me("Be sure to name the variable you're declaring enteredTextWithS.")},function(){return me("Remember to include an = after the variable enteredTextWithS to set it to a value.")},he.bind(null,me,"GETINPUTBYASKING"),function(e){return me("You're missing an open parenthesis after "+e[3]+".")},function(){return me("The message to supply to the user should be surrounded by \" and \" because you want it to be displayed as is. Be sure it also includes the text 'with an s' in it so the user knows that the string he/she enters must contain an s.")},function(e,t){return me("You're missing a closing parenthesis for "+e[3]+".")}]);return t.error?t.match.join(""):e},init:function(){var e=this;this.appendDummyInput("STRING").appendField(new Blockly.FieldTextInput("",this.validate),"EXP"),this.setInputsInline(!1),this.setOutput(!1),this.setPreviousStatement(!0),this.setNextStatement(!0),this.setColour(60),this.setTooltip(T2C.MSG.currentLanguage.TYPEIN_STATEMENT_TOOLTIP),this.onchange=function(t){if(e.getFieldValue("EXP").endsWith("\r")||e.getFieldValue("EXP").endsWith("\n")||e.getFieldValue("EXP").length>0&&"workspaceClick"===t.element){if(!e.validate(e.getFieldValue("EXP"))||!e.getFieldValue("EXP").endsWith(")")&&!e.getFieldValue("EXP").endsWith(";"))return;var n=Object(o.getParseTree)(e.getFieldValue("EXP"));n?Object(o.handleParseTreeToBlocks)(n,e):me("Try checking what you entered again for mistakes.")}}}},Blockly.Python.type_in_set_s_pos=Blockly.JavaScript.type_in_set_s_pos=Blockly.JavaScript.code_statement,Blockly.Blocks.type_in_set_s_pos={validate:function(e){var t=pe(e,[{token:"let",type:"terminal"},"sPosition","=","enteredTextWithS",".",T2C.MSG.JS.TERMINAL_FINDFIRSTOCCURRENCEOFTEXT,"(",{token:/"s"|'s'/,type:"regexp"},")"],[he.bind(null,me,"LET"),function(){return me("Be sure to name the variable you're declaring _Position to represent the fact that it should store the position of the first _ (where _ is replaced with the character you're looking for).")},function(){return me("Remember to include an = after the variable sPosition you're declaring to set it to a value.")},function(){return me("Be sure to include the variable enteredTextWithS that you want to get the position of the s from.")},function(){return me("Be sure to include the . after the variable enteredTextWithS you want to get the position of the first s from.")},he.bind(null,me,"FINDFIRSTOCCURRENCEOFTEXT"),function(e,t){return me("You're missing an open parenthesis after "+e[5]+".")},function(e,t){t.startsWith("s")?me("Since you're looking for the literal s and don't want the computer to evaluate it in any way, you need to surround it with quotation marks."):t.startsWith("'")||t.startsWith('"')?"s"!==t[1]?me("What string literal are you getting the position for?"):me("You're only looking for the first s, correct? If so, remember to close the quotation marks."):me("Since the needle you're going to use here is a literal string and not an expression, you need to surround it with quotation marks. You're currently missing quotation marks.")},function(e,t){return me("You're missing a closing parenthesis for "+e[5]+".")}]);return t.error?t.match.join(""):e},init:function(){var e=this;this.appendDummyInput("STRING").appendField(new Blockly.FieldTextInput("",this.validate),"EXP"),this.setInputsInline(!1),this.setOutput(!1),this.setPreviousStatement(!0),this.setNextStatement(!0),this.setColour(60),this.setTooltip(T2C.MSG.currentLanguage.TYPEIN_STATEMENT_TOOLTIP),this.onchange=function(t){if(e.getFieldValue("EXP").endsWith("\r")||e.getFieldValue("EXP").endsWith("\n")||e.getFieldValue("EXP").length>0&&"workspaceClick"===t.element){if(!e.validate(e.getFieldValue("EXP"))||!e.getFieldValue("EXP").endsWith(")")&&!e.getFieldValue("EXP").endsWith(";"))return;var n=Object(o.getParseTree)(e.getFieldValue("EXP"));n?Object(o.handleParseTreeToBlocks)(n,e):me("Try checking what you entered again for mistakes.")}}}},Blockly.Python.type_in_set_before_s=Blockly.JavaScript.type_in_set_before_s=Blockly.JavaScript.code_statement,Blockly.Blocks.type_in_set_before_s={validate:function(e){var t="Mississippi",n=(t.substring(0,t.indexOf("s")),t.substring(t.indexOf("s")+1),t.substring(0,t.indexOf("s")),t.substring(t.indexOf("s")+1),pe(e,[{token:"let",type:"terminal"},"beforeS","=","enteredTextWithS",".",T2C.MSG.JS.TERMINAL_GETTEXTFROMPOSITIONNUMBER,"(","0",",","sPosition",")"],[he.bind(null,me,"LET"),function(){return me("Be sure to name the variable you're declaring beforeS to represent the fact that it should store the text before the first occurrence of the s in the entered text.")},function(){return me("Remember to include an = after the variable beforeS you're declaring to set it to the value that follows.")},function(){return me("Be sure to include the variable enteredTextWithS that you want to extract text from.")},function(){return me("Be sure to include the . after the variable enteredTextWithS you want to extract text from.")},he.bind(null,me,"GETTEXTFROMPOSITIONNUMBER"),function(e,t){return me("You're missing an open parenthesis after "+e[5]+".")},function(e,t){t.startsWith("(")?me("Although you *can* have multiple opening parentheses, it's not necessary in this instance. When you first start programming, it may be good to include them to make sure operations are performed in the required order, but it can also make your code more difficult to read and correctly match the open parentheses with closing ones. Before continuing, remove the extra opening parenthesis here since you don't need it."):1===parseInt(t)?me("Remember that positions start at 0."):parseInt(t)?me("The text occurring before the first s starts at the beginning of the string. What number should you use if you want to start extracting text there?"):me("The text occurring before the first s starts at the beginning of the string so regardless of the string the user enters, the numerical position will always be the same. Use a specific number, accordingly.")},function(e){return me("You're missing a comma after the starting position. In "+T2C.MSG.currentLanguage.LANGUAGE_NAME+", you put the starting and ending positions in the same parentheses when using "+e[5]+". The comma is used to separate the two positions with the starting position first and the ending position second in order for the computer to know which is which.")},function(e,n){var o=parseInt(n);isNaN(o)?de(n,"FINDFIRSTOCCURRENCEOFTEXT")?me("You'd need to refer to the variable name before using "+T2C.MSG.currentLanguage.TERMINAL_FINDFIRSTOCCURRENCEOFTEXT+" so the computer knows which string to search through (haystack) to find the given needle, but remember that you're already assuming you have a variable that stores the position of the first s, which might help..."):me("For an entered string of "+t+", you'd use "+t.indexOf("s")+" (stopping before it), but for sorry, you'd want to use "+"sorry".indexOf("s")+". Since it depends on the position of the first s, start by entering the appropriate variable name here."):me("The correct place to stop extracting text cannot be a specific number if you want it to work in general regardless of the entered string with an s. For an entered string of "+t+", you'd use "+t.indexOf("s")+" (stopping before it), but for sorry, you'd want to use "+"sorry".indexOf("s")+". Since it depends on the position of the first s, start by entering the appropriate variable name here instead of a specific number.")},function(e,n){-1!==n.replace(/\s/g,"").indexOf("-1")?me("Remember that "+e[5]+" ends one position before the numerical expression given. So for example, for an entered text of "+t+", you'd want to use "+t.indexOf("s")+" so the last character you'd extract would be at position "+(t.indexOf("s")-1)+", mainly the "+t[t.indexOf("s")-1]+" before the first s. If you subtracted 1, you'd instead stop extracting text at position "+(t.indexOf("s")-2)+" so you'd instead incorrectly get the "+t[t.indexOf("s")-2]+" as the last character."):-1!==n.replace(/\s/g,"").indexOf("+1")?me("Although "+T2C.MSG.currentLanguage.TERMINAL_GETTEXTFROMPOSITIONNUMBER+" ends one position before the numerical expression given, you want to stop before the first s anyway. Adding 1 means you'll instead stop at the s. For example, for an entered string of "+t+" the first s would be located at position "+t.indexOf("s")+" so by adding 1, you'd get "+(t.indexOf("s")+1)+", which means the last character you'd extract would be at position "+t.indexOf("s")+", mainly the s itself."):me("What you're doing to the ending position of "+T2C.MSG.currentLanguage.TERMINAL_GETTEXTFROMPOSITIONNUMBER+" seems incorrect or unnecessary. Be sure to have examples in mind before deciding what to type. If you're done, be sure to include a closing parenthesis for "+e[5]+" after the ending position.")}]));return n.error?n.match.join(""):e},init:function(){var e=this;this.appendDummyInput("STRING").appendField(new Blockly.FieldTextInput("",this.validate),"EXP"),this.setInputsInline(!1),this.setOutput(!1),this.setPreviousStatement(!0),this.setNextStatement(!0),this.setColour(60),this.setTooltip(T2C.MSG.currentLanguage.TYPEIN_STATEMENT_TOOLTIP),this.onchange=function(t){if(e.getFieldValue("EXP").endsWith("\r")||e.getFieldValue("EXP").endsWith("\n")||e.getFieldValue("EXP").length>0&&"workspaceClick"===t.element){if(!e.validate(e.getFieldValue("EXP"))||!e.getFieldValue("EXP").endsWith(")")&&!e.getFieldValue("EXP").endsWith(";"))return;var n=Object(o.getParseTree)(e.getFieldValue("EXP"));n?Object(o.handleParseTreeToBlocks)(n,e):me("Try checking what you entered again for mistakes.")}}}},Blockly.Python.type_in_set_after_s=Blockly.JavaScript.type_in_set_after_s=Blockly.JavaScript.code_statement,Blockly.Blocks.type_in_set_after_s={validate:function(e){var t="Mississippi",n=(t.substring(0,t.indexOf("s")),t.substring(t.indexOf("s")+1)),o=("sorry".substring(0,t.indexOf("s")),"sorry".substring(t.indexOf("s")+1)),i=pe(e,[{token:"let",type:"terminal"},"afterS","=","enteredTextWithS",".",T2C.MSG.JS.TERMINAL_GETTEXTFROMPOSITIONNUMBER,"(","sPosition","+","1",",","enteredTextWithS",".",{token:"LENGTH",type:"terminal"},")"],[he.bind(null,me,"LET"),function(){return me("Be sure to name the variable you're declaring afterS to represent the fact that it should store the text after the s from the user input.")},function(){return me("Remember to include an = after the variable afterS you're declaring to set it to the value that follows.")},function(){return me("Be sure to include the variable enteredTextWithS that you want to extract text from.")},function(){return me("Be sure to include the . after the variable enteredTextWithS you want to extract text from.")},he.bind(null,me,"GETTEXTFROMPOSITIONNUMBER"),function(e,t){return me("You're missing an open parenthesis after "+e[5]+".")},function(e,n){var o=parseInt(n);isNaN(o)?de(n,"FINDFIRSTOCCURRENCEOFTEXT")?me("You'd need to refer to the variable name before using "+T2C.MSG.currentLanguage.TERMINAL_FINDFIRSTOCCURRENCEOFTEXT+" so the computer knows which string to search through (haystack) to find the given needle, but remember that you already have a variable that stores the position of the first s, which might help..."):me("For an entered string of "+t+", you'd use "+(t.indexOf("s")+1)+", but for sorry, you'd want to use "+("sorry".indexOf("s")+1)+". Since it depends on the position of the first s, start by entering the appropriate variable name here."):me("The correct place to start extracting text cannot be a specific number if you want it to work in general regardless of the entered string containing an s. For an entered string of "+t+", you'd use "+(t.indexOf("s")+1)+", but for sorry, you'd want to use "+("sorry".indexOf("s")+1)+". Since it depends on the position of the s, start by entering the appropriate variable name here instead of a specific number.")},function(e,i){i.startsWith(")")||i.startsWith(",")?me("You do not want to start extracting text at the first occurrence of the s exactly since you want to get the text that immediately follows it. What arithmetic operation do you want to perform on the position number you get and with what number to start at the character after the s? For "+t+", the position of the first s will be at "+t.indexOf("s")+" but you'll want to start at position "+(t.indexOf("s")+1)+", with the second "+n[0]+" whereas for sorry, the position of the first s will be at "+"sorry".indexOf("s")+" but you'll want to start at position "+("sorry".indexOf("s")+1)+", with "+o[0]+"."):i.replace(/\s/g,"").startsWith("--1")?me("Add 1 instead of subtracting -1 as this makes your code clearer."):me("What arithmetic operation do you want to perform on the position number you get and with what number to start at the character after the s? For "+t+", the position of the first s will be at "+t.indexOf("s")+" but you'll want to start at position "+(t.indexOf("s")+1)+", with the second "+n[0]+" whereas for sorry, the position of the first s will be at "+"sorry".indexOf("s")+" but you'll want to start at position "+("sorry".indexOf("s")+1)+", with "+o[0]+".")},function(e,i){var r=parseInt(i);!isNaN(r)||i.startsWith("-")?me("What number do you want to add to the position number of the first occurrence of the s to get to the position you want to start at? For "+t+", the position of the first s will be at "+t.indexOf("s")+" but you'll want to start at position "+(t.indexOf("s")+1)+", with "+n[0]+" whereas for sorry, the position of the first s will be at "+"sorry".indexOf("s")+" but you'll want to start at position "+("sorry".indexOf("s")+1)+", with "+o[1]+". Change this to the correct number, accordingly."):me("If the user enters a string with an s such as e.g., "+t+" or sorry, then the number of places the last name will be beyond the position of the first s will always be the same so you can enter a *specific* number. For "+t+", the position of the first s will be at "+t.indexOf("s")+" but you'll want to start at position "+(t.indexOf("s")+1)+", with "+n[0]+" whereas for sorry, the position of the first s will be at "+"sorry".indexOf("s")+" but you'll want to start at position "+("sorry".indexOf("s")+1)+", with "+o[0]+". Change your answer to the specific number you can add in both cases, accordingly.")},function(e){return me("You're missing a comma after the starting position. In "+T2C.MSG.currentLanguage.LANGUAGE_NAME+", you put the starting and ending positions in the same parentheses when using "+e[5]+". The comma is used to separate the two positions with the starting position first and the ending position second in order for the computer to know which is which.")},function(e,n){var o=parseInt(n);isNaN(o)?n.startsWith("sPosition")||"sPosition".startsWith(n)?me("You don't want to stop extracting text at sPosition, do you?"):me("If we want all of the characters after the first s, we won't stop extracting text until we get to the end of the string. So for "+t+", you'd use "+t.length+" while for sorry, you'd use "+"sorry".length+", the position number after the last character. Since this position number will depend on something about the entered string, your answer should refer to it."):me("The stopping position will not always be at position "+o+". Instead, this position will depend on something about the entered string so your answer should refer to it.")},function(){return me("Be sure to include the . after the variable enteredTextWithS you want to use.")},function(e,n){return me("If we want all of the characters after the first s, we won't stop extracting text until we get to the end of the string. For "+t+", you'd use "+t.length+" while for sorry, you'd use "+"sorry".length+", the position number after the last character. Do you remember how you can get these positions from the entered string?")},function(e,n){-1!==n.replace(/\s/g,"").indexOf("-1")?me("Remember that "+T2C.MSG.currentLanguage.TERMINAL_GETTEXTFROMPOSITIONNUMBER+" ends one position before the numerical expression given. So for example, for an enteredTextWithS of "+t+", enteredTextWithS.length - 1 would be "+(t.length-1)+", which means you'd extract the text ending with the "+t.charAt(t.length-2)+" instead of the last character of "+t.charAt(t.length-1)+"."):-1!==n.replace(/\s/g,"").indexOf("+1")?me("For an enteredTextWithS of "+t+", enteredTextWithS.length + 1 would be "+(t.length+1)+", but there is no character at this position since positions start at 0."):me("What you're doing to the "+T2C.MSG.currentLanguage.TERMINAL_LENGTH+" seems incorrect. Be sure to have examples in mind before deciding what to type. For example, for "+t+", the length is "+t.length+" and you want to go up to position "+t.length+" (since you'd stop extracting at character "+(t.length-1)+"). If you're done, be sure to include a closing parenthesis for "+e[5]+" after the ending position.")}]);return i.error?i.match.join(""):e},init:function(){var e=this;this.appendDummyInput("STRING").appendField(new Blockly.FieldTextInput("",this.validate),"EXP"),this.setInputsInline(!1),this.setOutput(!1),this.setPreviousStatement(!0),this.setNextStatement(!0),this.setColour(60),this.setTooltip(T2C.MSG.currentLanguage.TYPEIN_STATEMENT_TOOLTIP),this.onchange=function(t){if(e.getFieldValue("EXP").endsWith("\r")||e.getFieldValue("EXP").endsWith("\n")||e.getFieldValue("EXP").length>0&&"workspaceClick"===t.element){if(!e.validate(e.getFieldValue("EXP"))||!e.getFieldValue("EXP").endsWith(")")&&!e.getFieldValue("EXP").endsWith(";"))return;var n=Object(o.getParseTree)(e.getFieldValue("EXP"));n?Object(o.handleParseTreeToBlocks)(n,e):me("Try checking what you entered again for mistakes.")}}}},Blockly.Python.type_in_display_s_replaced_with_dollar=Blockly.JavaScript.type_in_display_s_replaced_with_dollar=Blockly.JavaScript.code_statement,Blockly.Blocks.type_in_display_s_replaced_with_dollar={validate:function(e){var t="Mississippi".substring(0,"Mississippi".indexOf("s")),n="Mississippi".substring("Mississippi".indexOf("s")+1),o=("sorry".substring(0,"Mississippi".indexOf("s")),"sorry".substring("Mississippi".indexOf("s")+1),t+"$"+n),i=pe(e,[T2C.MSG.JS.TERMINAL_DISPLAY,"(","beforeS","+",{token:/^"\$"|^'\$'/,type:"regexp"},"+","afterS",")"],[he.bind(null,me,"DISPLAY"),function(e,t){return me("You're missing an open parenthesis after "+e[0]+".")},function(e,i){i.startsWith('"')||i.startsWith("'")?me("If you're using variable names to be evaluated instead of displayed as is (e.g., displaying the text Mi instead of the text beforeS), you don't want to use quotation marks."):me('Remember the variable names are beforeS and afterS. If beforeS = "'+t+'" and afterS = "'+n+'" and you want to display "'+o+'", what should be displayed first?')},function(){return me("How do you join strings together?")},function(e,i){"afterS".toLowerCase().startsWith(i.toLowerCase())||i.toLowerCase().startsWith("lastName".toLowerCase())?me("Remember that you'll want a $ between what comes before and after the first s; joining the two strings together without one would result in \""+t+n+'" instead of say "'+o+'".'):me("Remember that you want to *literally* display a $ between what comes before and after the first s. What do you need to surround text with when you want to display something without evaluating it?")},function(){return me("How do you join strings together?")},function(e,i){i.startsWith('"')||i.startsWith("'")?me("If you're using variable names to be evaluated instead of displayed as is (e.g., displaying the text "+n+" instead of the text afterS), you don't want to use quotation marks."):me('Remember the variable names are beforeS and afterS. If beforeS = "'+t+'" and afterS = "'+n+'" and you want to display "'+o+'", what should be displayed last?')},function(e,t){return me("You're missing a closing parenthesis for "+e[0]+".")}]);return i.error?i.match.join(""):e},init:function(){var e=this;this.appendDummyInput("STRING").appendField(new Blockly.FieldTextInput("",this.validate),"EXP"),this.setInputsInline(!1),this.setOutput(!1),this.setPreviousStatement(!0),this.setNextStatement(!0),this.setColour(60),this.setTooltip(T2C.MSG.currentLanguage.TYPEIN_STATEMENT_TOOLTIP),this.onchange=function(t){if(e.getFieldValue("EXP").endsWith("\r")||e.getFieldValue("EXP").endsWith("\n")||e.getFieldValue("EXP").length>0&&"workspaceClick"===t.element){if(!e.validate(e.getFieldValue("EXP"))||!e.getFieldValue("EXP").endsWith(")")&&!e.getFieldValue("EXP").endsWith(";"))return;var n=Object(o.getParseTree)(e.getFieldValue("EXP"));n?Object(o.handleParseTreeToBlocks)(n,e):me("Try checking what you entered again for mistakes.")}}}},String.prototype.JSSubstring=function(e,t){return e>=this.length||e===t?"":this.substring(e,t)},Blockly.Python.type_in_get_full_name=Blockly.JavaScript.type_in_get_full_name=Blockly.JavaScript.code_statement,Blockly.Blocks.type_in_get_full_name={validate:function(e){var t=ke(e,[{token:"let",type:"terminal"},"fullName","=",T2C.MSG.JS.TERMINAL_GETINPUTBYASKING,"(",{token:/^"[^"]*$|^'[^']*$|^"[^"]*full name[^"]*"|^'[^']*full name[^']*'/i,type:"regexp"},")"],[be.bind(null,Ee,"LET"),function(){return Ee("Be sure to name the variable you're declaring fullName.")},function(){return Ee("Remember to include an = after the variable fullName to set it to a value.")},be.bind(null,Ee,"GETINPUTBYASKING"),function(e){return Ee("You're missing an open parenthesis after "+e[3]+".")},function(){return Ee("The message to supply to the user should be surrounded by \" and \" because you want it to be displayed as is. Be sure it also includes the text 'full name' in it so the user knows to enter his/her full name.")},function(e,t){return Ee("You're missing a closing parenthesis for "+e[3]+".")}]);return t.error?t.match.join(""):e},init:function(){var e=this;this.appendDummyInput("STRING").appendField(new Blockly.FieldTextInput("",this.validate),"EXP"),this.setInputsInline(!1),this.setOutput(!1),this.setPreviousStatement(!0),this.setNextStatement(!0),this.setColour(60),this.setTooltip(T2C.MSG.currentLanguage.TYPEIN_STATEMENT_TOOLTIP),this.onchange=function(t){if(e.getFieldValue("EXP").endsWith("\r")||e.getFieldValue("EXP").endsWith("\n")||e.getFieldValue("EXP").length>0&&"workspaceClick"===t.element){if(!e.validate(e.getFieldValue("EXP"))||!e.getFieldValue("EXP").endsWith(")")&&!e.getFieldValue("EXP").endsWith(";"))return;var n=Object(o.getParseTree)(e.getFieldValue("EXP"));n?Object(o.handleParseTreeToBlocks)(n,e):Ee("Try checking what you entered again for mistakes.")}}}},Blockly.Python.type_in_print_initials=Blockly.JavaScript.type_in_print_initials=Blockly.JavaScript.code_statement,Blockly.Blocks.type_in_print_initials={validate:function(e){var t="Linus Torvalds",n="Jane Doe".substring(0,"Jane Doe".indexOf(" ")),o="Jane Doe".substring("Jane Doe".indexOf(" ")+1),i=n[0],r=o[0],a=i+"."+r+".",l=t.substring(0,t.indexOf(" ")),s=t.substring(t.indexOf(" ")+1),u=l[0],c=s[0],g=u+"."+c+".",d=ke(e,[T2C.MSG.JS.TERMINAL_DISPLAY,"(","fullName",".",T2C.MSG.JS.TERMINAL_GETCHARACTERNUMBER,"(","0",")","+",{token:/^"."|^'.'/,type:"regexp"},"+","fullName",".",T2C.MSG.JS.TERMINAL_GETCHARACTERNUMBER,"(","fullName",".",T2C.MSG.JS.TERMINAL_FINDFIRSTOCCURRENCEOFTEXT,"(",{token:/^" "|^' '/,type:"regexp"},")","+","1",")","+",{token:/^"."|^'.'/,type:"regexp"},")"],[be.bind(null,Ee,"DISPLAY"),function(e,t){return Ee("You're missing an open parenthesis after "+e[0]+".")},function(){return Ee("Be sure to include the variable fullName that you want to extract text from.")},function(){return Ee("Be sure to include the . after the variable fullName you want to extract text from.")},be.bind(null,Ee,"GETCHARACTERNUMBER"),function(e,t){return Ee("You're missing an open parenthesis after "+e[4]+".")},function(e,n){n.startsWith("(")?Ee("Although you *can* have multiple opening parentheses, it's not necessary in this instance. When you first start programming, it may be good to include them to make sure operations are performed in the required order, but it can also make your code more difficult to read and correctly match the open parentheses with closing ones. Before continuing, remove the extra opening parenthesis here since you don't need it."):1===parseInt(n)?Ee("Remember that positions start at 0."):parseInt(n)?Ee("In what position will the first initial of "+i+" appear if the person enters Jane Doe or the first initial of "+u+" if the person enters "+t+"?"):("fullName".toLowerCase().startsWith(n.toLowerCase())||n.toLowerCase().startsWith("fullName".toLowerCase()),Ee("Assuming the full name is always entered as first last such as Jane Doe with a first initial of "+i+" or "+t+" with a first initial of "+u+", the numerical position will always be the same. Use a specific number, accordingly."))},function(e,t){return Ee("You're missing a closing parenthesis for "+e[4]+".")},function(){return Ee("How do you join text together?")},function(e,n){"fullName".toLowerCase().startsWith(n.toLowerCase())||n.toLowerCase().startsWith("fullName".toLowerCase())?Ee("What character do you want to appear after the first initial of "+i+" to get the text "+a+" if the person enters Jane Doe or the first initial of "+u+" to get "+g+" if the person enters "+t+"? It's the same in both cases."):n.startsWith(".")?Ee("Since you want a literal . and don't want the computer to evaluate it in any way, you need to surround it with quotation marks."):n.match(/^"\.$|^"$|^'\.$|^'$/)?Ee(""):Ee("What character do you want to appear after the first initial of "+i+" to get the text "+a+" if the person enters Jane Doe or the first initial of "+u+" to get "+g+" if the person enters "+t+"? It's the same in both cases.")},function(){return Ee("How do you join text together?")},function(e,t){"lastInitial".toLowerCase().startsWith(t.toLowerCase())||t.toLowerCase().startsWith("lastInitial".toLowerCase())?Ee("You don't have lastInitial defined. As with the first initial, where do you get it from?"):T2C.MSG.JS.TERMINAL_GETCHARACTERNUMBER.toLowerCase().startsWith(t.toLowerCase())||t.toLowerCase().startsWith(T2C.MSG.JS.TERMINAL_GETCHARACTERNUMBER.toLowerCase())?Ee("Remember you need to give the text you want to extract the character from first when using "+T2C.MSG.JS.TERMINAL_GETCHARACTERNUMBER+"."):Ee("Given you have the first initial and a period, what do you want to appear next? As with the first initial, where do you get it from?")},function(){return Ee("Be sure to include the . after the variable fullName you want to extract text from.")},function(){return Ee("At this point, you'd have "+i+". for Jane Doe and "+u+". for "+t+". So what would you display next: a number, a character, or something else? Type in the appropriate of "+T2C.MSG.JS.TERMINAL_FINDFIRSTOCCURRENCEOFTEXT+", "+T2C.MSG.JS.TERMINAL_LENGTH+", "+T2C.MSG.JS.TERMINAL_GETCHARACTERNUMBER+", etc. accordingly, being mindful of spelling and case.")},function(e,t){return Ee("You're missing an open parenthesis after "+e[e.length-1]+".")},function(e,n){var o=parseInt(n);isNaN(o)?_e(n,"FINDFIRSTOCCURRENCEOFTEXT")?Ee("You'll need to refer to the variable name before using "+T2C.MSG.currentLanguage.TERMINAL_FINDFIRSTOCCURRENCEOFTEXT+" so the computer knows which string to search through (haystack) to find the given needle."):n.startsWith("(")?Ee("Although you *can* have multiple opening parentheses, it's not necessary in this instance. When you first start programming, it may be good to include them to make sure operations are performed in the required order, but it can also make your code more difficult to read and correctly match the open parentheses with closing ones. Before continuing, remove the extra opening parenthesis here since you don't need it."):Ee("The correct place in the string where the last initial appears will be a number depending on the entered string. For a full name of Jane Doe, you'd use "+("Jane Doe".indexOf(" ")+1)+", but for "+t+", you'd want to use "+(t.indexOf(" ")+1)+". Since it depends on some property of the entered name, start by entering the appropriate variable name here instead of what you have."):Ee("The correct place in the string where the last initial appears will not be always be the same number. For a full name of Jane Doe, you'd use "+("Jane Doe".indexOf(" ")+1)+", but for "+t+", you'd want to use "+(t.indexOf(" ")+1)+". Since it depends on some property of the entered name, start by entering the appropriate variable name here instead of a specific number.")},function(){return Ee("Be sure to include the . after the variable fullName you want to search.")},function(e,n){T2C.MSG.JS.TERMINAL_GETCHARACTERNUMBER.toLowerCase().startsWith(n.toLowerCase())||n.toLowerCase().startsWith(T2C.MSG.JS.TERMINAL_GETCHARACTERNUMBER.toLowerCase())?Ee("You're already inside the parentheses of a "+T2C.MSG.JS.TERMINAL_GETCHARACTERNUMBER+". What do you need to give it now so it can get the last initial from fullName?"):T2C.MSG.JS.TERMINAL_LENGTH.toLowerCase().startsWith(n.toLowerCase())||n.toLowerCase().startsWith(T2C.MSG.JS.TERMINAL_LENGTH.toLowerCase())?Ee("Getting the number of characters in the entire string does not help you find the position of the last initial unless you also had something like the number of characters in the first or last name. For example, the length of Jane Doe is "+"Jane Doe".length+" while the last initial is at position "+("Jane Doe".indexOf(" ")+1)+" whereas the length of "+t+" is "+t.length+" while the last initial is at position "+(t.indexOf(" ")+1)+"."):T2C.MSG.JS.TERMINAL_GETTEXTFROMPOSITIONNUMBER.toLowerCase().startsWith(n.toLowerCase())||n.toLowerCase().startsWith(T2C.MSG.JS.TERMINAL_GETTEXTFROMPOSITIONNUMBER.toLowerCase())?Ee(T2C.MSG.currentLanguage.TERMINAL_GETTEXTFROMPOSITIONNUMBER+" gives you part of the text, but you want the position number of the last initial to give to "+T2C.MSG.currentLanguage.TERMINAL_GETCHARACTERNUMBER+" to get the character at that position."):Ee("Given you have the first initial and a period, what do you want to appear next? What property of fullName do you want to get its position? Make sure your spelling and capitalization (e.g., M versus m) are correct.")},function(e,t){return Ee("You're missing an open parenthesis after "+e[e.length-1]+".")},function(e,t){"positionOfLastInitial".toLowerCase().startsWith(t.toLowerCase())||t.toLowerCase().startsWith("positionOfLastInitial".toLowerCase())?Ee("The position of the last initial will not be defined; you're using "+T2C.MSG.currentLanguage.TERMINAL_FINDFIRSTOCCURRENCEOFTEXT+" to calculate it."):t.match(/^""|^''/)?Ee("You are trying to get the location of an empty string; that's not what you want, right?"):t.match(/^" [^"]|^' [^']/)?Ee("Remember that that last name of an entered input won't always start with "+t[2]+". Is it really necessary to include? If you're done, close the quotation marks."):t.match(/^" $|^"$|^' $|^'$/)?Ee(""):parseInt(t)||t.startsWith("0")?Ee("You're looking for the first position number of a character in fullName to tell you where the last initial is, you are not searching for the *position* of "+parseInt(t)+" in fullName."):t.match(/^"|^'/)?Ee("What string (needle) are you looking for in lastName (haystack) to help you calculate the position number of the last initial?"):Ee("Since the needle you're going to use here is a string literal, you need to surround it with quotation marks. You're currently missing quotation marks.")},function(e,t){t.startsWith("+")?Ee("Be careful where you place the +; you certainly don't want to add a number to a space! Instead you want to add a number to the *position* of the space in fullName so it should go outside of the "+e[17]+"."):Ee("You're missing a closing parenthesis for "+e[17]+".")},function(e,o){o.startsWith(")")?Ee("You do not want to get the character located at the position of the space exactly or you'll get back the space itself! Instead, you'll want to get the character at the position after so you'll need to do what arithmetic operation to the position number you get? For fullName of Jane Doe, the position of the space will be at "+"Jane Doe".indexOf(" ")+" while for fullName of "+t+", the position of the space will be at "+t.indexOf(" ")+". What position will the last initial be in each case?"):o.replace(/\s/g,"").startsWith("-1")?Ee("If you subtract 1, you'll get the position of the last character of the first name. Instead, you'll want to get the character at the position after the space so you'll need to do what arithmetic operation to the position number you get? For example, for a fullName of Jane Doe, the position of the space will be at "+"Jane Doe".indexOf(" ")+" so subtracting 1 will give you "+("Jane Doe".indexOf(" ")-1)+", which will be the position of the first "+n.charAt(n.length-1)+". What do you want to do instead to get the position of the last initial from the position of the space?"):o.replace(/\s/g,"").startsWith("--1")?Ee("Add 1 instead of subtracting -1 as this makes your code clearer."):Ee("What operation and number should you use on the position of the space you get from "+T2C.MSG.currentLanguage.TERMINAL_FINDFIRSTOCCURRENCEOFTEXT+"? Remember, you'll want to get the character at the position after so you'll need to do what arithmetic operation to the position number you get? For fullName of Jane Doe, the position of the space will be at "+"Jane Doe".indexOf(" ")+" while for fullName of "+t+", the position of the space will be at "+t.indexOf(" ")+". What position will the last initial be in each case?")},function(e,n){var o=parseInt(n);!isNaN(o)||n.startsWith("-")?Ee("What number do you want to add to the position number of the first occurrence of the space to get to the position of the last initial? Change this to the correct number."):Ee(T2C.MSG.currentLanguage.TERMINAL_FINDFIRSTOCCURRENCEOFTEXT+" gives you back a number. What specific *number* do you want to add to the position number of the first occurrence of the space to get to the position you want to start at? Change this to the correct number. For fullName of Jane Doe, the position of the space will be at "+"Jane Doe".indexOf(" ")+" while for fullName of "+t+", the position of the space will be at "+t.indexOf(" ")+". To figure out what you want to add, what position will the last initial be in each case?")},function(e,t){return Ee("You're missing a closing parenthesis for the second "+e[4]+".")},function(e,n){n.startsWith(")")?Ee("At this point, you have "+a.substring(0,a.length-1)+" for Jane Doe and "+g.substring(0,g.length-1)+" for "+t+". What are you missing?"):Ee("At this point, you have "+a.substring(0,a.length-1)+" for Jane Doe and "+g.substring(0,g.length-1)+" for "+t+". What should go next and what do you do to add more to the text you already have?")},function(e,n){"fullName".toLowerCase().startsWith(n.toLowerCase())||n.toLowerCase().startsWith("fullName".toLowerCase())?Ee("What character do you want to appear after the last initial of "+i+" to get the text "+a+" if the person enters Jane Doe or the last initial of "+u+" to get "+g+" if the person enters "+t+"? It's the same in both cases."):n.startsWith(".")?Ee("Since you want a literal . and don't want the computer to evaluate it in any way, you need to surround it with quotation marks."):n.match(/^"\.$|^"$|^'\.$|^'$/)?Ee(""):Ee("What character do you want to appear after the last initial of "+a.substring(0,a.length-1)+" to get the text "+a+" if the person enters Jane Doe or the last initial of "+g.substring(0,g.length-1)+" to get "+g+" if the person enters "+t+"? It's the same in both cases.")},function(e,t){return Ee("You're missing a closing parenthesis for "+e[0]+".")}]);return d.error?d.match.join(""):e},init:function(){var e=this;this.appendDummyInput("STRING").appendField(new Blockly.FieldTextInput("",this.validate),"EXP"),this.setInputsInline(!1),this.setOutput(!1),this.setPreviousStatement(!0),this.setNextStatement(!0),this.setColour(60),this.setTooltip(T2C.MSG.currentLanguage.TYPEIN_STATEMENT_TOOLTIP),this.onchange=function(t){if(e.getFieldValue("EXP").endsWith("\r")||e.getFieldValue("EXP").endsWith("\n")||e.getFieldValue("EXP").length>0&&"workspaceClick"===t.element){if(!e.validate(e.getFieldValue("EXP"))||!e.getFieldValue("EXP").endsWith(")")&&!e.getFieldValue("EXP").endsWith(";"))return;var n=Object(o.getParseTree)(e.getFieldValue("EXP"));n?Object(o.handleParseTreeToBlocks)(n,e):Ee("Try checking what you entered again for mistakes.")}}}};var Be=new g,Ae=Be.addTab(T2C.MSG.currentLanguage.DIRECTIONS,""),ve=Be.addTab(T2C.MSG.currentLanguage.FEEDBACK,""),Ie="apple,banana,cantaloupe,kiwi,orange",we="atari,nintendo,sega genesis,super nintendo",Se=Ie.substring(Ie.indexOf(",")+1),Me=we.substring(we.indexOf(",")+1),Ne=Se.substring(Se.indexOf(",")+1),Le=Me.substring(Me.indexOf(",")+1),Oe=Ne.substring(0,Ne.indexOf(",")),Ce=Le.substring(0,Le.indexOf(","));function Re(e){e.style.verticalAlign="middle",e.style.color="#000"}function Fe(){document.getElementById("output-container").classList.remove("show-container"),document.getElementById("output-container").classList.add("hide-container"),document.getElementById("text-code-container").classList.remove("show-container"),document.getElementById("text-code-container").classList.add("hide-container")}function Pe(e,t){var n=arguments.length>2&&void 0!==arguments[2]&&arguments[2],o=n?e:e.toLowerCase(),i=n?t:t.toLowerCase();return o.startsWith(i)||i.startsWith(o)}function Ve(e,t){var n=Object.values(T2C.MSG).map((function(e){return e["TERMINAL_"+t.toUpperCase()]})).filter((function(e){return"string"==typeof e})).find((function(t){return Pe(t,e,!0)}));if(n)return{terminal:n,remaining:e.JSSubstring(n.length).trim()}}String.prototype.JSSubstring=function(e,t){return e>=this.length||e===t?"":this.substring(e,t)};var Ge=new d("type_in_get_item_list");Ge.addPossibleMatch([{token:"let",type:"terminal"},"itemList","=",T2C.MSG.JS.TERMINAL_GETINPUTBYASKING,"(",{token:/^"[^"]*$|^'[^']*$|^"[^"]*at least 4[^"]*"|^'[^']*at least 4[^']*'/i,type:"regexp"},")"],[null,function(){return"Be sure to name the variable you're declaring itemList."},function(){return"Remember to include an = after the variable itemList to set it to a value."},null,null,function(){return"The message to supply to the user should be surrounded by \" and \" because you want it to be displayed as is. Be sure it also includes the text 'at least 4' in it so the user knows to enter at least 4 items (separated by commas)."},null]),Ge.addToBlocks();var Ue=new d("type_in_display_item_list");Ue.addPossibleMatch([T2C.MSG.JS.TERMINAL_DISPLAY,"(","itemList",")"],[null,null,function(){return"Check the spelling and the case of the variable name of the value you want to display, itemList."},null]),Ue.addToBlocks();var Xe=new d("type_in_set_after_first");Xe.addPossibleMatch([{token:"let",type:"terminal"},"afterFirstComma","=","itemList",".",T2C.MSG.JS.TERMINAL_GETTEXTFROMPOSITIONNUMBER,"(","itemList",".",T2C.MSG.JS.TERMINAL_FINDFIRSTOCCURRENCEOFTEXT,"(",{token:/^","|^','/,type:"regexp"},")","+","1",",","itemList",".",{token:"LENGTH",type:"terminal"},")"],[null,function(){return"Be sure to name the variable you're declaring afterFirstComma to represent the fact that it should store the text after the first comma from the user input."},function(){return"Remember to include an = after the variable afterFirstComma you're declaring to set it to the value that follows."},function(){return"Be sure to include the variable itemList that you want to extract text from."},function(){return"Be sure to include the . after the variable itemList you want to extract text from."},null,null,function(e,t){var n=parseInt(t);return isNaN(n)?t.startsWith(",")?"You need a position *number* to start extracting text from here, but a comma is not a number. Perhaps you wanted the position of the comma instead?":Ve(t,"FINDFIRSTOCCURRENCEOFTEXT")?"You'll need to refer to the variable name before using "+T2C.MSG.currentLanguage.TERMINAL_FINDFIRSTOCCURRENCEOFTEXT+" so the computer knows which string to search through (haystack) to find the given needle.":t.startsWith("(")?"Although you *can* have multiple opening parentheses, it's not necessary in this instance. When you first start programming, it may be good to include them to make sure operations are performed in the required order, but it can also make your code more difficult to read and correctly match the open parentheses with closing ones. Before continuing, remove the extra opening parenthesis here since you don't need it.":"The correct place in the string where the second item begins (after the first comma) will be a number depending on the entered string. For an itemList of "+Ie+", you'd use "+(Ie.indexOf(",")+1)+", but for "+we+", you'd want to use "+(we.indexOf(",")+1)+". Since it depends on some property of the entered item list, start by entering the appropriate variable name here instead of what you have.":"The correct place in the string where the second item begins (after the first comma) will not be always be the same number. For an itemList of "+Ie+", you'd use "+(Ie.indexOf(",")+1)+", but for "+we+", you'd want to use "+(we.indexOf(",")+1)+". Since it depends on some property of the entered item list, start by entering the appropriate variable name here instead of a specific number."},function(){return"Be sure to include the . after the variable itemList you want to search."},function(e,t){return Pe(t,T2C.MSG.JS.TERMINAL_GETTEXTFROMPOSITIONNUMBER)?"You're already inside the parentheses of a "+T2C.MSG.JS.TERMINAL_GETTEXTFROMPOSITIONNUMBER+". What do you need to give the computer now so it knows what position to start extracting text from to get the text after the first comma?":Pe(t,T2C.MSG.JS.TERMINAL_LENGTH)?"You don't want to *start* extracting text after the last character of the string, right?":Pe(t,T2C.MSG.currentLanguage.TERMINAL_GETCHARACTERNUMBER)?T2C.MSG.currentLanguage.TERMINAL_GETCHARACTERNUMBER+" gives you a character, but you need a position *number* to start extracting text from for "+T2C.MSG.currentLanguage.TERMINAL_GETTEXTFROMPOSITIONNUMBER+" to start extracting text from.":"What property of itemList do you want to determine where to start extracting text from? Make sure your spelling and capitalization (e.g., M versus m) are correct."},null,function(e,t){return t.startsWith(",")?"Since you're looking for the literal , and don't want the computer to evaluate it in any way, you need to surround it with quotation marks.":t.match(/^",[^"]|^',[^']/)?"Remember that that second item of the entered input won't always start with "+t[2]+". Is it really necessary to include? If you're done, close the quotation marks.":t.match(/^",$|^"$|^',$|^'$/)?"":parseInt(t)||t.startsWith("0")?"You're looking for the first position number of a character in itemList to tell you where the beginning of the second item is, you are not searching for the *position* of "+parseInt(t)+" in itemList.":t.match(/^"|^'/)?"What string (needle) are you looking for in itemList (haystack) to help you calculate the position number of the start of the second item?":"Since the needle you're going to use here is a string literal, you need to surround it with quotation marks. You're currently missing quotation marks."},function(e,t){return t.startsWith("+")?"Be careful where you place the +; you certainly don't want to add a number to a comma! Instead you want to add a number to the *position* of the comma in itemList so it should go outside of the "+e[9]+".":"You're missing a closing parenthesis for "+e[9]+"."},function(e,t){return t.startsWith(",")||t.startsWith(")")?"You do not want to start extracting text from the position of the comma exactly or the result will start with the comma! Instead, you'll want to start extracting text from the position after so you'll need to do what arithmetic operation to the position number you get? For itemList of "+Ie+", the position of the comma will be at "+Ie.indexOf(",")+" while for itemList of "+we+", the position of the comma will be at "+we.indexOf(",")+". What position will the start of the second item be in each case?":t.replace(/\s/g,"").startsWith("-1")?"If you subtract 1, you'll get the position of the last character of the first item. Instead, you'll want to start extracting text from the position after the comma so you'll need to do what arithmetic operation to the position number you get? For example, for an itemList of "+Ie+", the position of the comma will be at "+Ie.indexOf(",")+" so subtracting 1 will give you "+(Ie.indexOf(",")-1)+", which will be the position of the first "+Ie.charAt(Ie.indexOf(",")-1)+". What do you want to do instead to get the position of the start of the second item from the position of the comma?":t.replace(/\s/g,"").startsWith("--1")?"Add 1 instead of subtracting -1 as this makes your code clearer.":"What operation and number should you use on the position of the comma you get from "+T2C.MSG.currentLanguage.TERMINAL_FINDFIRSTOCCURRENCEOFTEXT+"? Remember, you'll want to start extracting text from the position after the comma so you'll need to do what arithmetic operation to the position number you get? For itemList of "+Ie+", the position of the comma will be at "+Ie.indexOf(",")+" while for itemList of "+we+", the position of the comma will be at "+we.indexOf(",")+". What position will the start of the second item be in each case?"},function(e,t){var n=parseInt(t);return!isNaN(n)||t.startsWith("-")?"What number do you want to add to the position number of the first occurrence of the comma to get to the position of the start of the second item after it? Change this to the correct number.":T2C.MSG.currentLanguage.TERMINAL_FINDFIRSTOCCURRENCEOFTEXT+" gives you back a number. What specific *number* do you want to add to the position number of the first occurrence of the comma to get to the position you want to start at? Change this to the correct number. For itemList of "+Ie+", the position of the comma will be at "+Ie.indexOf(",")+" while for itemList of "+we+", the position of the comma will be at "+we.indexOf(",")+". To figure out what you want to add, what position will the start of the second item be in each case?"},function(e){return"You're missing a comma after the starting position. In "+T2C.MSG.currentLanguage.LANGUAGE_NAME+", you put the starting and ending positions in the same parentheses when using "+e[5]+". The comma is used to separate the two positions with the starting position first and the ending position second in order for the computer to know which is which."},function(e,t){var n=parseInt(t);return isNaN(n)?"If we want all of the characters after the first comma, we won't stop extracting text until we get to the end of the string. So for "+Ie+", you'd use "+Ie.length+" while for "+we+", you'd use "+we.length+", the position number after the last character. Since this position number will depend on something about the entered string, your answer should refer to it.":"The stopping position will not always be at position "+n+". Instead, this position will depend on something about the entered string so your answer should refer to it."},function(){return"Be sure to include the . after the variable itemList you want to use."},function(e,t){return"If we want all of the characters after the first comma, we won't stop extracting text until we get to the end of the string. For "+Ie+", you'd use "+Ie.length+" while for "+we+", you'd use "+we.length+", the position number after the last character. Do you remember how you can get these positions from the entered string?"},function(e,t){return-1!==t.replace(/\s/g,"").indexOf("-1")?"Remember that "+T2C.MSG.currentLanguage.TERMINAL_GETTEXTFROMPOSITIONNUMBER+" ends one position before the numerical expression given. So for example, for an itemList of "+Ie+", itemList.length - 1 would be "+(Ie.length-1)+", which means you'd extract the text ending with the "+Ie.charAt(Ie.length-2)+" instead of the last character of "+Ie.charAt(Ie.length-1)+".":-1!==t.replace(/\s/g,"").indexOf("+1")?"For an itemList of "+Ie+", itemList.length + 1 would be "+(Ie.length+1)+", but there is no character at this position since positions start at 0.":"What you're doing to the "+T2C.MSG.currentLanguage.TERMINAL_LENGTH+" seems incorrect. Be sure to have examples in mind before deciding what to type. For example, for "+Ie+", the length is "+Ie.length+" and you want to go up to position "+Ie.length+" (since you'd stop extracting at character "+(Ie.length-1)+"). If you're done, be sure to include a closing parenthesis for "+e[5]+" after the ending position."}]),Xe.addToBlocks();var je=new d("type_in_display_after_first");je.addPossibleMatch([T2C.MSG.JS.TERMINAL_DISPLAY,"(","afterFirstComma",")"],[null,null,function(){return"Check the spelling and the case of the variable name of the value you want to display, afterFirstComma."},null]),je.addToBlocks();var De=new d("type_in_set_after_second");De.addPossibleMatch([{token:"let",type:"terminal"},"afterSecondComma","=","afterFirstComma",".",T2C.MSG.JS.TERMINAL_GETTEXTFROMPOSITIONNUMBER,"(","afterFirstComma",".",T2C.MSG.JS.TERMINAL_FINDFIRSTOCCURRENCEOFTEXT,"(",{token:/^","|^','/,type:"regexp"},")","+","1",",","afterFirstComma",".",{token:"LENGTH",type:"terminal"},")"],[null,function(){return"Be sure to name the variable you're declaring afterSecondComma to represent the fact that it should store the text after the second comma from the user input."},function(){return"Remember to include an = after the variable afterSecondComma you're declaring to set it to the value that follows."},function(e,t){return Pe(t,"itemList")?"If you're using the originial inputted itemList, you will *not* be able to extract the text after the *second* comma in general when you're only able to get the position of its first comma. What variable can you use instead?":"Be sure to include the variable that you want to extract text from."},function(){return"Be sure to include the . after the variable afterFirstComma you want to extract text from."},null,null,function(e,t){var n=parseInt(t);return isNaN(n)?Pe(t,"itemList")?"If you're using the original inputted itemList, you will *not* be able to extract the text after the *second* comma in general when you're only able to get the position of its first comma. For example, the position of the first comma in "+Ie+" is "+Ie.indexOf(",")+" while the position of the first comma in "+Ie+" with its first item removed ("+Se+") is "+Se.indexOf(",")+". Perhaps you want to use a different variable?":t.startsWith(",")?"You need a position *number* to start extracting text from here, but a comma is not a number. Perhaps you wanted the position of the comma instead?":Ve(t,"FINDFIRSTOCCURRENCEOFTEXT")?"You'll need to refer to the variable name before using "+T2C.MSG.currentLanguage.TERMINAL_FINDFIRSTOCCURRENCEOFTEXT+" so the computer knows which string to search through (haystack) to find the given needle.":t.startsWith("(")?"Although you *can* have multiple opening parentheses, it's not necessary in this instance. When you first start programming, it may be good to include them to make sure operations are performed in the required order, but it can also make your code more difficult to read and correctly match the open parentheses with closing ones. Before continuing, remove the extra opening parenthesis here since you don't need it.":"The correct place in the string where the third item begins (after the first comma in afterFirstComma) will be a number depending on the entered string. For an afterFirstComma of "+Se+", you'd use "+(Se.indexOf(",")+1)+", but for "+Me+", you'd want to use "+(Me.indexOf(",")+1)+". Since it depends on some property of afterFirstComma, start by entering the appropriate variable name here instead of what you have.":"The correct place in the inputted itemList where the third item begins (after the first comma in afterFirstComma) will not be always be the same number. For an afterFirstComma of "+Se+", you'd use "+(Se.indexOf(",")+1)+", but for "+Me+", you'd want to use "+(Me.indexOf(",")+1)+". Since it depends on some property of afterFirstComma, start by entering the appropriate variable name here instead of a specific number."},function(){return"Be sure to include the . after the variable afterFirstComma you want to search."},function(e,t){return Pe(t,T2C.MSG.JS.TERMINAL_GETTEXTFROMPOSITIONNUMBER)?"You're already inside the parentheses of a "+T2C.MSG.JS.TERMINAL_GETTEXTFROMPOSITIONNUMBER+". What do you need to give the computer now so it knows what position to start extracting text from to get the text after the first comma in afterFirstComma?":Pe(t,T2C.MSG.JS.TERMINAL_LENGTH)?"You don't want to *start* extracting text after the last character of the string, right?":Pe(t,T2C.MSG.currentLanguage.TERMINAL_GETCHARACTERNUMBER)?T2C.MSG.currentLanguage.TERMINAL_GETCHARACTERNUMBER+" gives you a character, but you need a position *number* to start extracting text from for "+T2C.MSG.currentLanguage.TERMINAL_GETTEXTFROMPOSITIONNUMBER+" to start extracting text from.":"What property of afterFirstComma do you want to determine where to start extracting text from? Make sure your spelling and capitalization (e.g., M versus m) are correct."},null,function(e,t){return t.startsWith(",")?"Since you're looking for the literal , and don't want the computer to evaluate it in any way, you need to surround it with quotation marks.":t.match(/^",[^"]|^',[^']/)?"Remember that that second item of afterFirstComma won't always start with "+t[2]+". Is it really necessary to include? If you're done, close the quotation marks.":t.match(/^",$|^"$|^',$|^'$/)?"":parseInt(t)||t.startsWith("0")?"You're looking for the first position number of a character in afterFirstComma to tell you where the beginning of the second item in afterFirstComma is (third item in original itemList), you are not searching for the *position* of "+parseInt(t)+" in afterFirstComma.":t.match(/^"|^'/)?"What string (needle) are you looking for in afterFirstComma (haystack) to help you calculate the position number of the start of its second item (third item in original list)?":"Since the needle you're going to use here is a string literal, you need to surround it with quotation marks. You're currently missing quotation marks."},function(e,t){return t.startsWith("+")?"Be careful where you place the +; you certainly don't want to add a number to a comma! Instead you want to add a number to the *position* of the comma in afterFirstComma so it should go outside of the "+e[9]+".":"You're missing a closing parenthesis for "+e[9]+"."},function(e,t){return t.startsWith(",")||t.startsWith(")")?"You do not want to start extracting text from the position of the comma exactly or the result will start with the comma! Instead, you'll want to start extracting text from the position after so you'll need to do what arithmetic operation to the position number you get? For afterFirstComma of "+Se+", the position of the first comma will be at "+Se.indexOf(",")+" while for afterFirstComma of "+Me+", the position of the comma will be at "+Me.indexOf(",")+". What position will the start of the second item from afterFirstComma be in each case?":t.replace(/\s/g,"").startsWith("-1")?"If you subtract 1, you'll get the position of the last character of the first item. Instead, you'll want to start extracting text from the position after the comma so you'll need to do what arithmetic operation to the position number you get? For example, for an afterFirstComma of "+Se+", the position of the first comma will be at "+Se.indexOf(",")+" so subtracting 1 will give you "+(Se.indexOf(",")-1)+", which will be the position of "+Se.charAt(Se.indexOf(",")-1)+". What do you want to do instead to get the position of the start of the second item in afterFirstComma?":t.replace(/\s/g,"").startsWith("--1")?"Add 1 instead of subtracting -1 as this makes your code clearer.":"What operation and number should you use on the position of the first comma from afterFirstComma you get from "+T2C.MSG.currentLanguage.TERMINAL_FINDFIRSTOCCURRENCEOFTEXT+"? Remember, you'll want to start extracting text from the position after the comma so you'll need to do what arithmetic operation to the position number you get? For afterFirstComma of "+Se+", the position of its first comma will be at "+Se.indexOf(",")+" while for afterFirstComma of "+Me+", the position of the comma will be at "+Me.indexOf(",")+". What position will the start of the second item from afterFirstComma be in each case?"},function(e,t){var n=parseInt(t);return!isNaN(n)||t.startsWith("-")?"What number do you want to add to the position number of the first occurrence of the comma to get to the position of the start of the second item in afterFirstComma after it? Change this to the correct number.":T2C.MSG.currentLanguage.TERMINAL_FINDFIRSTOCCURRENCEOFTEXT+" gives you back a number. What specific *number* do you want to add to the position number of the first occurrence of the comma in afterFirstComma to get to the position you want to start at? Change this to the correct number. For afterFirstComma of "+Se+", the position of the first comma will be at "+Se.indexOf(",")+" while for afterFirstComma of "+Me+", the position of the first comma will be at "+Me.indexOf(",")+". To figure out what you want to add, what position will the start of the second item be in each case?"},function(e){return"You're missing a comma after the starting position. In "+T2C.MSG.currentLanguage.LANGUAGE_NAME+", you put the starting and ending positions in the same parentheses when using "+e[5]+". The comma is used to separate the two positions with the starting position first and the ending position second in order for the computer to know which is which."},function(e,t){var n=parseInt(t);return Pe(t,"itemList")?"If we want all of the characters after the first comma in afterFirstComma, the ending position we give to "+T2C.MSG.currentLanguage.TERMINAL_GETTEXTFROMPOSITIONNUMBER+" will need to be "+Se.length+" for "+Se+" and "+Me.length+" for "+Me+". These are different than one more than the ending positions for "+Ie+" and "+we+", which would be "+Ie.length+" and "+we.length+", respectively. No calculations will be required if we work with afterFirstComma instead.":isNaN(n)?"If we want all of the characters after the first comma in afterFirstComma, we won't stop extracting text until we get to the end of the string. So for "+Se+", you'd use "+Se.length+" while for "+Me+", you'd use "+Me.length+", the position number after the last character. Since this position number will depend on something about afterFirstComma, your answer should refer to it.":"The stopping position will not always be at position "+n+". Instead, this position will depend on something about afterFirstComma so your answer should refer to it."},function(){return"Be sure to include the . after the variable afterFirstComma you want to use."},function(e,t){return"If we want all of the characters after the first comma of afterFirstComma, we won't stop extracting text until we get to the end of the string. For "+Se+", you'd use "+Se.length+" while for "+Me+", you'd use "+Me.length+", the position number after the last character. Do you remember how you can get these positions from the entered string?"},function(e,t){return-1!==t.replace(/\s/g,"").indexOf("-1")?"Remember that "+T2C.MSG.currentLanguage.TERMINAL_GETTEXTFROMPOSITIONNUMBER+" ends one position before the numerical expression given. So for example, for an afterFirstComma of "+Se+", afterFirstComma.length - 1 would be "+(Se.length-1)+", which means you'd extract the text ending with the "+Se.charAt(Se.length-2)+" instead of the last character of "+Se.charAt(Se.length-1)+".":-1!==t.replace(/\s/g,"").indexOf("+1")?"For an afterFirstComma of "+Se+", afterFirstComma.length + 1 would be "+(Ie.length+1)+", but there is no character at this position since positions start at 0.":"What you're doing to the "+T2C.MSG.currentLanguage.TERMINAL_LENGTH+" seems incorrect. Be sure to have examples in mind before deciding what to type. For example, for "+Se+", the length is "+Se.length+" and you want to go up to position "+Se.length+" (since you'd stop extracting at character "+(Se.length-1)+"). If you're done, be sure to include a closing parenthesis for "+e[5]+" after the ending position."}]),De.addToBlocks();var We=new d("type_in_display_after_second");We.addPossibleMatch([T2C.MSG.JS.TERMINAL_DISPLAY,"(","afterSecondComma",")"],[null,null,function(){return"Check the spelling and the case of the variable name of the value you want to display, afterSecondComma."},null]),We.addToBlocks();var Ye=new d("type_in_display_third_item");Ye.addPossibleMatch([T2C.MSG.JS.TERMINAL_DISPLAY,"(","afterSecondComma",".",T2C.MSG.JS.TERMINAL_GETTEXTFROMPOSITIONNUMBER,"(","0",",","afterSecondComma",".",T2C.MSG.JS.TERMINAL_FINDFIRSTOCCURRENCEOFTEXT,"(",{token:/^","|^','/,type:"regexp"},")",")",")"],[null,null,function(e,t){return Pe(t,"itemList")?"If you're using the originial inputted itemList, you will *not* be able to extract the text before the *third* comma in general when you're only able to get the position of its first comma. What variable can you use instead?":Pe(t,"afterFirstComma")?"If you're using afterFirstComma, you will *not* be able to extract the text before its second comma (before third comma in itemList) in general when you're only able to get the position of its first comma. What variable can you use instead?":"Be sure to include the variable that you want to extract text from."},function(){return"Be sure to include the . after the variable afterSecondComma you want to extract text from."},null,null,function(e,t){return t.startsWith("(")?T2C.MSG.currentLanguage.TYPEIN_WARNING_UNNECESSARY_OPEN_PARENTHESIS:Pe(t,"secondFirstComma")?"The text occurring before the first comma in a string starts at what numerical position regardless of what it is? Use that specific number, accordingly.":1===parseInt(t)?"Remember that positions start at 0.":parseInt(t)?"Where do you want to start extracting text from if you want all of the text *before* the first comma in afterSecondComma. What number should you use if you want to start extracting text there?":"The text occurring before the first comma in a string starts at what numerical position regardless of what it is? Use that specific number, accordingly."},function(e){return"You're missing a comma after the starting position. In "+T2C.MSG.currentLanguage.LANGUAGE_NAME+", you put the starting and ending positions in the same parentheses when using "+e[4]+". The comma is used to separate the two positions with the starting position first and the ending position second in order for the computer to know which is which."},function(e,t){var n=parseInt(t);return isNaN(n)?Pe(t,"itemList")?"If we want all of the characters before the first comma in afterSecondComma, the ending position we give to "+T2C.MSG.currentLanguage.TERMINAL_GETTEXTFROMPOSITIONNUMBER+" will need to be "+Ne.indexOf(",")+" for "+Ne+" and "+Le.indexOf(",")+" for "+Le+". These are different than the ending positions of the first comma for "+Ie+" and "+we+", which would be "+Ie.indexOf(",")+" and "+we.indexOf(",")+", respectively. No calculations will be required if we work with afterSecondComma instead.":Pe(t,"afterFirstComma")?"If we want all of the characters before the first comma in afterSecondComma, the ending position we give to "+T2C.MSG.currentLanguage.TERMINAL_GETTEXTFROMPOSITIONNUMBER+" will need to be "+Ne.indexOf(",")+" for "+Ne+" and "+Le.indexOf(",")+" for "+Le+". These are different than the ending positions of the first comma for "+Se+" and "+Me+", which would be "+Se.indexOf(",")+" and "+Me.indexOf(",")+", respectively. No calculations will be required if we work with afterSecondComma instead.":Ve(t,"FINDFIRSTOCCURRENCEOFTEXT")?"You'll need to refer to the variable name before using "+T2C.MSG.currentLanguage.TERMINAL_FINDFIRSTOCCURRENCEOFTEXT+" so the computer knows which string to search through (haystack) to find the given needle.":t.startsWith("(")?T2C.MSG.currentLanguage.TYPEIN_WARNING_UNNECESSARY_OPEN_PARENTHESIS:"For an afterSecondComma of "+Ne+", you'd use "+Ne.indexOf(",")+" (stopping before it), but for "+Le+", you'd want to use "+Le.indexOf(",")+". Since it depends on the position of the comma, start by entering the appropriate variable name here instead of a specific number.":"The correct place to stop extracting text cannot be a specific number if you want it to work in general regardless of the entered list. For an afterSecondComma of "+Ne+", you'd use "+Ne.indexOf(",")+" (stopping before the comma), but for "+we+", you'd want to use "+Le.indexOf(",")+". Since it depends on the position of the comma, start by entering the appropriate variable name here instead of a specific number."},function(){return"Be sure to include the . after the variable afterSecondComma you want to search."},function(e,t){return Pe(t,T2C.MSG.JS.TERMINAL_GETTEXTFROMPOSITIONNUMBER)?"You're already inside the parentheses of a "+T2C.MSG.JS.TERMINAL_GETTEXTFROMPOSITIONNUMBER+". What do you need to give the computer now so it knows what position to stop extracting text from to get the text before the first comma in afterSecondComma?":Pe(t,T2C.MSG.JS.TERMINAL_LENGTH)?"You don't want to stop extracting text after the last character of the string if you want to get everything before the first comma in afterSecondComma, right?":Pe(t,T2C.MSG.currentLanguage.TERMINAL_GETCHARACTERNUMBER)?T2C.MSG.currentLanguage.TERMINAL_GETCHARACTERNUMBER+" gives you a character, but you need to give "+T2C.MSG.currentLanguage.TERMINAL_GETTEXTFROMPOSITIONNUMBER+" a position *number* to stop extracting text from.":"What property of afterSecondComma do you want in order to determine where to stop extracting text? Make sure your spelling and capitalization (e.g., M versus m) are correct."},null,function(e,t){return t.startsWith(",")?"Since you're looking for the literal , and don't want the computer to evaluate it in any way, you need to surround it with quotation marks.":t.match(/^",[^"]|^',[^']/)?"Remember that that second item of afterSecondComma won't always start with "+t[2]+". Is it really necessary to include? If you're done, close the quotation marks.":t.match(/^",$|^"$|^',$|^'$/)?"":parseInt(t)||t.startsWith("0")?"You're looking for the first position number of a character in afterSecondComma to tell you where the end of the first item in afterSecondComma is (third item in original itemList), you are not searching for the *position* of "+parseInt(t)+" in afterSecondComma.":t.match(/^"|^'/)?"What string (needle) are you looking for in afterSecondComma (haystack) to help you calculate the position number of the end of its first item (third item in original list)?":"Since the needle you're going to use here is a string literal, you need to surround it with quotation marks. You're currently missing quotation marks."},function(e,t){return t.startsWith("+")||t.startsWith("-")?"Be careful where you place the math operation; you certainly don't want to add/subtract a number from a comma! Any math you may want to do to the *position* of the comma in email (which may not be necessary) should go outside of the parentheses for the character to find in "+e[10]+".":"You're missing a closing parenthesis for "+e[10]+"."},function(e,t){return-1!==t.replace(/\s/g,"").indexOf("-1")?"Remember that "+T2C.MSG.currentLanguage.TERMINAL_GETTEXTFROMPOSITIONNUMBER+" ends one position before the numerical expression given. So for example, for a afterSecondComma of "+Ne+", you'd want to use "+Ne.indexOf(",")+" so the last character you'd extract would be at position "+(Ne.indexOf(",")-1)+", mainly the "+Ne[Ne.indexOf(",")-1]+" before the comma. If you subtracted 1, you'd instead stop extracting text at position "+(Ne.indexOf(",")-2)+" so you'd instead incorrectly get the "+Ne[Ne.indexOf(",")-2]+" as the last character.":-1!==t.replace(/\s/g,"").indexOf("+1")?"Although "+T2C.MSG.currentLanguage.TERMINAL_GETTEXTFROMPOSITIONNUMBER+" ends one position before the numerical expression given, you want to stop before the first comma of afterSecondComma anyway. Adding 1 means you'll instead stop at its first comma instead. For example, for an afterSecondComma of "+Ne+" the comma would be located at position "+Ne.indexOf(",")+" so by adding 1, you'd get "+(Ne.indexOf(",")+1)+", which means the last character you'd extract would be at position "+Ne.indexOf(",")+", mainly the comma itself.":"What you're doing to the ending position of "+T2C.MSG.currentLanguage.TERMINAL_GETTEXTFROMPOSITIONNUMBER+" seems incorrect or unnecessary. Be sure to have examples in mind before deciding what to type. If you're done, be sure to include a closing parenthesis for "+e[4]+" after the ending position."},null]),Ye.addToBlocks();var He=["type_in_get_start_num","cs1030_10_type_in_step1","cs1030_10_type_in_display_step1","cs1030_10_type_in_step2","cs1030_10_type_in_display_step2","cs1030_10_type_in_step3","cs1030_10_type_in_display_step3","cs1030_10_type_in_step4","cs1030_10_type_in_display_step4","cs1030_10_type_in_step5","cs1030_10_type_in_display_step5"],Je=["startNum","step1","step2","step3","step4","step5"],qe=["*","+","-","/","-"],$e=["2","100","16","2","startNum"],ze=[],Ke=new d("type_in_get_start_num",{collapseWhenFinished:!0}),Ze=[{token:"let",type:"terminal"},"startNum","=",{token:"parseFloat",type:"terminal"},"(",{token:"GETINPUTBYASKING",type:"terminal"},"(",'"',"Enter a number:",'"',")",")",{token:/^[;]*$/,type:"regexp"}],Qe=T2C.MSG.currentLanguage===T2C.MSG.PY?T2C.MSG.PY:T2C.MSG.JS,et=Ze.slice(0,Ze.length-1).map((function(e){return"terminal"===e.type?Qe["TERMINAL_"+e.token.toUpperCase()]:e})).join(""),tt=[null,null,null,null,null,null,null,null,null,null,null,null,null];Ke.addPossibleMatch(Ze,tt),Ke.addToBlocks(),ze.push(Ke);for(e=1;e7&&ct%2!=0?[{token:"display",type:"terminal"},"(",ot[(ct-1)/2],")",{token:/^[;]*$/,type:"regexp"}]:ct<7&&ct%2!=0?[{token:"let",type:"terminal"},ot[(ct+1)/2],"=",ot[(ct-1)/2],it[(ct-1)/2],rt[(ct-1)/2],{token:/^[;]*$/,type:"regexp"}]:[{token:"let",type:"terminal"},ot[ct/2],"=",ot[(ct-2)/2],it[(ct-2)/2],rt[(ct-2)/2],{token:/^[;]*$/,type:"regexp"}],at[ct].addPossibleMatch(st,ut.slice(0,st.length)),"+"===st[4]||"*"===st[4]){var gt=st.slice();gt[3]=st[5],gt[5]=st[3],at[ct].addPossibleMatch(gt,ut.slice(0,st.length))}at[ct].addToBlocks()}var dt=[function(e,t){var n=function(e,t){return console.warn("MATCH ARR ON MISSING PHRASE",t),t.find((function(e){return e.match&&"text"===e.match.type})),e.remaining,h.a.getExpected(e),"Include some message in between the quotation marks so that the user sees some text!"},o=function(){return'Make sure the text you want to display is between " and " so the computer just displays it without trying to figure out what you mean!'},s=new p,g=s.createStandardHelpMessageManager(),d=e||new c,m=t||Blockly.getMainWorkspace(),T=new f(m);T.clearToolbox(),m.clear(),["text_print","text"].forEach((function(e){T.createToolboxBlock(e,!1),m.options.maxInstances[e]=1})),m.setScale(1),Object(i.f)(m);var _=Array.from(document.querySelectorAll("rect")).filter((function(e){return e.getAttribute("fill-opacity")})),E=_[0],B=_[1];console.warn("TEXT",B);var A=s.createPointer();return document.getElementById("blockly-div").appendChild(A),d.addTask(new r((function(){return m.getAllBlocks().find((function(e){return("text_print"===e.type||"js_text_print"===e.type)&&Blockly.selected!==e}))}),new u([s.createHelpMessageDirections(g,"Drag the "+T2C.MSG.currentLanguage.TERMINAL_DISPLAY+" block somewhere in the workspace.",""),new a(A,{totalSteps:50,startPosition:{x:E.x.baseVal.value+E.width.baseVal.value/2,y:document.getElementById("top-header").offsetHeight+E.y.baseVal.value+E.height.baseVal.value/2},velocity:{x:0,y:2}})]))),d.addTask(new r((function(){return m.getAllBlocks().find((function(e){return"text"===e.type&&e.getParent()&&"text_print"===e.getParent().type}))}),new u([s.createHelpMessageDirections(g,"Drag the text block in the space in the "+T2C.MSG.currentLanguage.TERMINAL_DISPLAY+" block.",""),new a(A,{totalSteps:50,startPosition:{x:B.x.baseVal.value+B.width.baseVal.value/2,y:document.getElementById("top-header").offsetHeight+B.y.baseVal.value+E.height.baseVal.value/2},endPosition:function(){var e=m.getAllBlocks().find((function(e){return"text_print"===e.type||"js_text_print"===e.type}));return x(m,e,{blockOffsetScaleX:.5,blockOffsetScaleY:.5},A.offsetWidth/4,document.getElementById("top-header").offsetHeight-A.offsetHeight/4)}})]))),d.addTask(new r((function(){return m.getAllBlocks().find((function(e){return"text"===e.type&&e.getFieldValue("TEXT")}))}),new u([s.createHelpMessageDirections(g,(function(){return"Click on the area between the quotation marks in the text block and "+T2C.MSG.currentLanguage.TYPE_SOMETHING}),""),new l(A,{totalSteps:100,toggleSteps:25,startPosition:function(){var e=m.getAllBlocks().find((function(e){return"text"===e.type}));return x(m,e,{blockOffsetScaleX:.5,blockOffsetScaleY:1},-A.offsetWidth/4,document.getElementById("top-header").offsetHeight)}})]))),s.addRunTask(g,d,(function(){alert("✔ Congratulations! You just created and ran your first program!"),y.createBlock("level0_display_string_literal_block",{type:"component",name:"code_statement_hybrid",value:{matchManagerType:"display_string_literal",value:{nonEmptyText:!0}}},{textModeFeedbackManager:T2C.FeedbackManagers.code_statement_hybrid.DEFAULT_TEXT_MODE_FEEDBACK_MANAGER,feedbackManager:T2C.FeedbackManagers.display_string_literal,options:{stringLiteralMissingIncludeTextDouble:n,stringLiteralMissingIncludeTextSingle:n,stringLiteralMissingOpenDouble:o}},{feedbackManager:T2C.FeedbackManagers.display_string_literal.feedbackJsonBlock,missing_phrase_error_msg:T2C.FeedbackManagers.display_string_literal.DEFAULT_MISSING_PHRASE_ERROR_MSG,stringLiteralWrongBlock:function(){return T2C.FeedbackManagers.string_literal.DEFAULT_WRONG_BLOCK_MSG},stringLiteralMissingIncludeTextBlock:n},null),T.createToolboxBlock("level0_display_string_literal_block",!0),m.options.maxInstances.level0_display_string_literal_block=1,m.getFlyout().getWorkspace().getAllBlocks().find((function(e){return"level0_display_string_literal_block"===e.type})).setDeletable(!1)}),A),d.addTask(new r((function(){return m.getAllBlocks().find((function(e){return("text_print"===e.type||"js_text_print"===e.type)&&e.getNextBlock()&&"level0_display_string_literal_block"===e.getNextBlock().type&&!m.isDragging()}))}),new u([s.createHelpMessageDirections(g,(function(){return"Drag in the type-in-code block so its top groove connects to the point of the bottom of the "+T2C.MSG.currentLanguage.TERMINAL_DISPLAY+" block."}),""),new a(A,{totalSteps:150,startPosition:function(){var e=k(0);return console.warn(e),{x:e.x.baseVal.value+e.width.baseVal.value/2,y:document.getElementById("top-header").offsetHeight+E.y.baseVal.value+E.height.baseVal.value/2}},endPosition:function(){var e=m.getAllBlocks().find((function(e){return"text_print"===e.type||"js_text_print"===e.type}));return x(m,e,{blockOffsetScaleX:0,blockOffsetScaleY:1.25},A.offsetWidth/4,document.getElementById("top-header").offsetHeight)}})]))),d.addTask(new r((function(){return m.getAllBlocks().find((function(e){return("text_print"===e.type||"js_text_print"===e.type)&&e.getNextBlock()&&("text_print"===e.getNextBlock().type||"js_text_print"===e.getNextBlock().type)&&e.getNextBlock().getInputTargetBlock("TEXT")&&"text"===e.getNextBlock().getInputTargetBlock("TEXT").type}))}),new u([s.createHelpMessageDirections(g,(function(){return"Type in code matching above block but with different text to display. I.e., Type\n"+T2C.MSG.currentLanguage.TEXT_PRINT_TITLE.replace("%1",'"your new message"')+"\nreplacing your new message with whatever you want to display. Be exact with parentheses, quotation marks, etc. Tap off the block when you're done."}),(function(){return"Click the ? on the blocks to see if there's any feedback."})),new l(A,{totalSteps:200,toggleSteps:50,startPosition:function(){var e=m.getAllBlocks().find((function(e){return"level0_display_string_literal_block"===e.type}));return x(m,e,{blockOffsetScaleX:0,blockOffsetScaleY:1},0,document.getElementById("top-header").offsetHeight)}})]))),s.addRunTask(g,d,(function(){alert("✔ Awesome! You just typed code for and ran your first program!"),m.options.maxInstances.level0_display_string_literal_block=0,T.removeToolboxBlocksWithType("level0_display_string_literal_block"),["variables_get","variables_set"].forEach((function(e){var t=document.createElement("block");t.setAttribute("type",e),document.getElementById("toolbox").prepend(t),m.options.maxInstances[e]=1})),m.updateToolbox(document.getElementById("toolbox"))}),A),d.addTask(new r((function(){return m.getAllBlocks().find((function(e){return"variables_set"===e.type&&e.getNextBlock()&&("text_print"===e.getNextBlock().type||"js_text_print"===e.getNextBlock().type)}))}),new u([s.createHelpMessageDirections(g,(function(){return"Drag in the "+T2C.MSG.currentLanguage.TERMINAL_LET+" variable declaration block directly above the "+T2C.MSG.currentLanguage.TERMINAL_DISPLAY+" block so its bottom point connects to the groove of the top of the "+T2C.MSG.currentLanguage.TERMINAL_DISPLAY+" block."}),""),new a(A,{totalSteps:150,startPosition:function(){var e=k(0);return{x:e.x.baseVal.value+e.width.baseVal.value/2,y:document.getElementById("top-header").offsetHeight+e.y.baseVal.value+e.height.baseVal.value/2}},endPosition:function(){var e=m.getAllBlocks().find((function(e){return"text_print"===e.type||"js_text_print"===e.type}));return x(m,e,{blockOffsetScaleX:0,blockOffsetScaleY:0},A.offsetWidth/4,document.getElementById("top-header").offsetHeight)}})]))),d.addTask(new r((function(){return m.getAllBlocks().find((function(e){return"variables_set"===e.type&&e.getInputTargetBlock("VALUE")&&"text"===e.getInputTargetBlock("VALUE").type}))}),new u([s.createHelpMessageDirections(g,(function(){return"Drag the text from inside the "+T2C.MSG.currentLanguage.TERMINAL_DISPLAY+" block to the inside of the "+T2C.MSG.currentLanguage.TERMINAL_LET+" variable declaration block directly above it so the variable stores the text."}),""),new a(A,{totalSteps:150,startPosition:function(){var e=m.getAllBlocks().find((function(e){return"text"===e.type}));return e.getBoundingRectangle(),x(m,e,{blockOffsetScaleX:.5,blockOffsetScaleY:.5},0,document.getElementById("top-header").offsetHeight)},endPosition:function(){var e=m.getAllBlocks().find((function(e){return"variables_set"===e.type}));return e.getBoundingRectangle(),x(m,e,{blockOffsetScaleX:.75,blockOffsetScaleY:.5},0,document.getElementById("top-header").offsetHeight)}})]))),d.addTask(new r((function(){return m.getAllBlocks().find((function(e){return("text_print"===e.type||"js_text_print"===e.type)&&e.getInputTargetBlock("TEXT")&&"variables_get"===e.getInputTargetBlock("TEXT").type}))}),new u([s.createHelpMessageDirections(g,(function(){var e=m.getAllBlocks().find((function(e){return"variables_set"===e.type})),t=m.getAllBlocks().find((function(t){return"text"===t.type&&t.getParent()===e})),n=e?e.getField("VAR").getText():"item",o=t?t.getFieldValue("TEXT"):"";return"Drag the variable get block from the toolbox to the inside of the "+T2C.MSG.currentLanguage.TERMINAL_DISPLAY+" block. This will cause the variable the text is set to ("+o+") to display. (The computer knows to display its value instead of the literal text "+n+" because it is not surrounded by quotation marks.)"}),""),new a(A,{totalSteps:150,startPosition:function(){var e=k(1);return{x:e.x.baseVal.value+e.width.baseVal.value/2,y:document.getElementById("top-header").offsetHeight+e.y.baseVal.value+e.height.baseVal.value/2}},endPosition:function(){var e=m.getAllBlocks().find((function(e){return("text_print"===e.type||"js_text_print"===e.type)&&!e.getInputTargetBlock("TEXT")}));return x(m,e,{blockOffsetScaleX:.5,blockOffsetScaleY:.5},A.offsetWidth/4,document.getElementById("top-header").offsetHeight)}})]))),s.addRunTask(g,d,(function(){alert("👍 Great! Notice how the output is the same as before, but in this program, we store one of the lines of text to display in a variable first. Variables are useful for storing stuff we'll want to use later.");var e=document.createElement("block");e.setAttribute("type","text_input"),document.getElementById("toolbox").prepend(e),m.options.maxInstances.text_input=1,m.updateToolbox(document.getElementById("toolbox"))}),A),d.addTask(new r((function(){return m.getAllBlocks().find((function(e){return"variables_set"===e.type&&e.getInputTargetBlock("VALUE")&&("text_input"===e.getInputTargetBlock("VALUE").type||"js_text_input"===e.getInputTargetBlock("VALUE").type)}))}),new u([s.createHelpMessageDirections(g,(function(){var e=m.getAllBlocks().find((function(e){return"variables_set"===e.type})),t=m.getAllBlocks().find((function(e){return"text_input"===e.type||"js_text_input"===e.type})),n=m.getAllBlocks().find((function(n){return"text"===n.type&&(n.getParent()===e||n.getParent()===t)})),o=e?e.getField("VAR").getText():"item",i=n?n.getFieldValue("TEXT"):"";return"Drag the "+T2C.MSG.currentLanguage.TERMINAL_GETINPUTBYASKING+" block inside the "+T2C.MSG.currentLanguage.TERMINAL_LET+" variable block and move the text block that currently resides there inside the new "+T2C.MSG.currentLanguage.TERMINAL_GETINPUTBYASKING+" block. This will ask the user for text with the message "+i+" and store whatever the user types in the variable "+o+"."}),""),new a(A,{totalSteps:150,startPosition:function(){var e=k(0);return{x:e.x.baseVal.value+e.width.baseVal.value/2,y:document.getElementById("top-header").offsetHeight+e.y.baseVal.value+e.height.baseVal.value/2}},endPosition:function(){var e=m.getAllBlocks().find((function(e){return"variables_set"===e.type}));return x(m,e,{blockOffsetScaleX:.75,blockOffsetScaleY:.5},0,document.getElementById("top-header").offsetHeight)}})]))),d.addTask(new r((function(){return m.getAllBlocks().find((function(e){return"variables_set"===e.type&&"firstName"===e.getField("VAR").getText()}))}),new u([s.createHelpMessageDirections(g,(function(){return"You will be asking the user for his/her first name, and this variable will store it. Rename the variable:\nfirstName\nThis variable is in camel case, which is a convention in Python and JavaScript. This means that the first letter of each word after the first is capitalized."}),(function(){var e=m.getAllBlocks().find((function(e){return"variables_set"===e.type})),t=e&&e.getField("VAR")&&e.getField("VAR").getText()||"";return/\s/.test(t)?"Be sure you type firstName exactly as it appears without spaces. You're not allowed to use spaces in variable names in most programming languages such as Python or JavaScript.":"firstname"===t.toLowerCase()&&"firstName"!==t?"Be sure to enter firstName in camel case (first letter of every word after the first capitalized), a convention for variable names in some programming languages such as Python or JavaScript since spaces are *not* allowed in variable names.":"firstName"!==t?"Check your spelling of firstName, and retype it accordingly.":void 0})),new l(A,{totalSteps:100,toggleSteps:25,startPosition:function(){var e=m.getAllBlocks().find((function(e){return"variables_set"===e.type}));return x(m,e,{blockOffsetScaleX:0,blockOffsetScaleY:.5},A.offsetWidth,document.getElementById("top-header").offsetHeight)}})]))),d.addTask(new r((function(){return m.getAllBlocks().find((function(e){return"text"===e.type&&e.getParent()&&("text_input"===e.getParent().type||"js_text_input"===e.getParent().type)&&(e.getFieldValue("TEXT").toLowerCase().includes("name ")||e.getFieldValue("TEXT").toLowerCase().includes(" name"))}))}),new u([s.createHelpMessageDirections(g,(function(){return"This text is the message the user will receive asking for his/her name. Write a message asking the user for his/her name. Unlike the variable name which cannot have spaces in most programming languages, the message will be seen by the user and should have spaces. The variable will store the name your user enters."}),""),new l(A,{totalSteps:100,toggleSteps:25,startPosition:function(){var e=m.getAllBlocks().find((function(e){return"text"===e.type&&e.getParent()&&("text_input"===e.getParent().type||"js_text_input"===e.getParent().type)}));return e.getBoundingRectangle(),x(m,e,{blockOffsetScaleX:.5,blockOffsetScaleY:.5},-A.offsetWidth/4,document.getElementById("top-header").offsetHeight)}})]))),s.addRunTask(g,d,(function(){alert("👍 Cool! Notice how the output includes what you typed in for your first name. If you run it again and type in something different, you'll see this different name.");var e=document.createElement("block");e.setAttribute("type","t2c_text_join"),document.getElementById("toolbox").prepend(e),m.options.maxInstances.t2c_text_join=1,m.updateToolbox(document.getElementById("toolbox"))}),A),d.addTask(new r((function(){return m.getAllBlocks().find((function(e){return("text_print"===e.type||"js_text_print"===e.type)&&e.getInputTargetBlock("TEXT")&&"t2c_text_join"===e.getInputTargetBlock("TEXT").type}))}),new u([s.createHelpMessageDirections(g,(function(){var e=m.getAllBlocks().find((function(e){return"variables_get"===e.type})),t=m.getAllBlocks().find((function(e){return"text_print"===e.type||"js_text_print"===e.type})),n=m.getAllBlocks().find((function(e){return"text"===e.type&&e.getParent()===t})),o=e?e.getField("VAR").getText():"item",i=n?n.getFieldValue("TEXT"):"";return"Drag the + block inside the "+T2C.MSG.currentLanguage.TERMINAL_DISPLAY+" block, replacing the variable "+o+" get block currently inside it. The + is used to join text expressions together (also called string concatenation). We will join the text "+i+" currently appearing below with the value of the variable "+o+", which is whatever the user types in and use the "+T2C.MSG.currentLanguage.TERMINAL_DISPLAY+" block to display the result on a single line."}),""),new a(A,{totalSteps:150,startPosition:function(){var e=k(0);return{x:e.x.baseVal.value+e.width.baseVal.value/2,y:document.getElementById("top-header").offsetHeight+e.y.baseVal.value+e.height.baseVal.value/2}},endPosition:function(){var e=m.getAllBlocks().find((function(e){return("text_print"===e.type||"js_text_print"===e.type)&&e.getInputTargetBlock("TEXT")&&"variables_get"===e.getInputTargetBlock("TEXT").type}));return x(m,e,{blockOffsetScaleX:.5,blockOffsetScaleY:.5},0,document.getElementById("top-header").offsetHeight)}})]))),d.addTask(new r((function(){return m.getAllBlocks().find((function(e){return("text_print"===e.type||"js_text_print"===e.type)&&e.getInputTargetBlock("TEXT")&&"t2c_text_join"===e.getInputTargetBlock("TEXT").type&&e.getInputTargetBlock("TEXT").getInputTargetBlock("A")&&"text"===e.getInputTargetBlock("TEXT").getInputTargetBlock("A").type}))}),new u([s.createHelpMessageDirections(g,(function(){var e=m.getAllBlocks().find((function(e){return"variables_get"===e.type})),t=m.getAllBlocks().find((function(e){return"text"===e.type&&e.getParent()&&("text_print"===e.getParent().type||"js_text_print"===e.getParent().type)}));return e&&e.getField("VAR").getText(),"Drag the text "+(t?t.getFieldValue("TEXT"):"")+" appearing in the bottom "+T2C.MSG.currentLanguage.TERMINAL_DISPLAY+" block in the left space of the + block."}),""),new a(A,{totalSteps:150,startPosition:function(){var e=m.getAllBlocks().find((function(e){return"text"===e.type&&e.getParent()&&("text_print"===e.getParent().type||"text_print"===e.getParent().type)}));return x(m,e,{blockOffsetScaleX:.5,blockOffsetScaleY:.5},0,document.getElementById("top-header").offsetHeight)},endPosition:function(){var e=m.getAllBlocks().find((function(e){return"t2c_text_join"===e.type}));return x(m,e,{blockOffsetScaleX:.25,blockOffsetScaleY:.5},0,document.getElementById("top-header").offsetHeight)}})]))),d.addTask(new r((function(){return m.getAllBlocks().find((function(e){return("text_print"===e.type||"js_text_print"===e.type)&&e.getInputTargetBlock("TEXT")&&"t2c_text_join"===e.getInputTargetBlock("TEXT").type&&e.getInputTargetBlock("TEXT").getInputTargetBlock("A")&&"text"===e.getInputTargetBlock("TEXT").getInputTargetBlock("A").type&&e.getInputTargetBlock("TEXT").getInputTargetBlock("B")&&"variables_get"===e.getInputTargetBlock("TEXT").getInputTargetBlock("B").type}))}),new u([s.createHelpMessageDirections(g,(function(){var e=m.getAllBlocks().find((function(e){return"variables_get"===e.type}));return"Now drag the variable "+(e?e.getField("VAR").getText():"item")+" block inside the right space of the + block."}),""),new a(A,{totalSteps:150,startPosition:function(){var e=m.getAllBlocks().find((function(e){return"variables_get"===e.type}));return x(m,e,{blockOffsetScaleX:.5,blockOffsetScaleY:.5},0,document.getElementById("top-header").offsetHeight)},endPosition:function(){var e=m.getAllBlocks().find((function(e){return"t2c_text_join"===e.type}));return x(m,e,{blockOffsetScaleX:.75,blockOffsetScaleY:.5},0,document.getElementById("top-header").offsetHeight)}})]))),d.addTask(new r((function(){return 1===m.getAllBlocks().filter((function(e){return"text_print"===e.type||"js_text_print"===e.type})).length}),new u([s.createHelpMessageDirections(g,(function(){return"Now drag the bottom "+T2C.MSG.currentLanguage.TERMINAL_DISPLAY+" block in the trashcan since you no longer need it."}),""),new a(A,{totalSteps:150,startPosition:function(){var e=m.getAllBlocks().find((function(e){return("text_print"===e.type||"js_text_print"===e.type)&&!e.getInputTargetBlock("TEXT")}));return x(m,e,{blockOffsetScaleX:.5,blockOffsetScaleY:.5},0,document.getElementById("top-header").offsetHeight)},endPosition:function(){var e=m.trashcan.getClientRect();return{x:(e.left+e.right)/2,y:(e.top+e.bottom)/2}}})]))),s.addRunTask(g,d,(function(){var e;alert("👍 Great! Notice how the + was used to concatenate or join together the literal message (in quotes) and the name the user enters (*NOT* in quotes)."),(e=document.getElementById("output-container").querySelectorAll(".table-cell")[0]).style.verticalAlign="middle",e.style.color="#000",document.getElementById("output-container").classList.remove("show-container"),document.getElementById("output-container").classList.add("hide-container"),document.getElementById("text-code-container").classList.remove("show-container"),document.getElementById("text-code-container").classList.add("hide-container");var t=document.createElement("block");t.setAttribute("type","type_in_welcome_message"),document.getElementById("toolbox").prepend(t),m.options.maxInstances.type_in_welcome_message=1,m.updateToolbox(document.getElementById("toolbox"))}),A),d.addTask(new r((function(){return 1===m.getAllBlocks().filter((function(e){return"text_print"===e.type||"js_text_print"===e.type})).length&&0===m.getAllBlocks().filter((function(e){return"t2c_text_join"===e.type})).length&&0===m.getAllBlocks().filter((function(e){return"variables_get"===e.type})).length&&1===m.getAllBlocks().filter((function(e){return"text"===e.type})).length}),new u([s.createHelpMessageDirections(g,(function(){return"Now drag the + block with the text and variable blocks inside of it into the trashcan. Do *NOT* drag the "+T2C.MSG.currentLanguage.TERMINAL_DISPLAY+" statement block in the trashcan since we will be using an expression type-in block. In JavaScript, an expression is just something that produces a value whereas a statement does not. As a block, it connects inside such as +, a variable get, text, or "+T2C.MSG.currentLanguage.TERMINAL_GETINPUTBYASKING+"."}),""),new a(A,{totalSteps:150,startPosition:function(){var e=m.getAllBlocks().find((function(e){return"t2c_text_join"===e.type}));return x(m,e,{blockOffsetScaleX:.5,blockOffsetScaleY:.5},0,document.getElementById("top-header").offsetHeight)},endPosition:function(){var e=m.trashcan.getClientRect();return{x:(e.left+e.right)/2,y:(e.top+e.bottom)/2}},finish:function(){m.options.maxInstances.t2c_text_join=0,m.options.maxInstances.variables_get=0,m.updateToolbox(document.getElementById("toolbox"))}})]))),d.addTask(new r((function(){return m.getAllBlocks().find((function(e){return("text_print"===e.type||"js_text_print"===e.type)&&e.getInputTargetBlock("TEXT")&&"type_in_welcome_message"===e.getInputTargetBlock("TEXT").type}))}),new u([s.createHelpMessageDirections(g,(function(){return"Now drag the type-in-expression block inside the "+T2C.MSG.currentLanguage.TERMINAL_DISPLAY+" one."}),(function(){return""})),new a(A,{totalSteps:150,startPosition:function(){var e=k(0);return{x:e.x.baseVal.value+e.width.baseVal.value/2,y:document.getElementById("top-header").offsetHeight+e.y.baseVal.value+e.height.baseVal.value/2}},endPosition:function(){var e=m.getAllBlocks().find((function(e){return"text_print"===e.type||"js_text_print"===e.type}));return x(m,e,{blockOffsetScaleX:.5,blockOffsetScaleY:.5},0,document.getElementById("top-header").offsetHeight)}})]))),d.addTask(new r((function(){var e=m.getAllBlocks().find((function(e){return"text_print"===e.type||"js_text_print"===e.type})),t=e.getInputTargetBlock("TEXT")&&"t2c_text_join"===e.getInputTargetBlock("TEXT").type&&e.getInputTargetBlock("TEXT"),n=t&&t.getInputTargetBlock("A"),o=t&&t.getInputTargetBlock("B");if(!n||!o)return!1;var i="t2c_text_join"===n.type?n.getInputTargetBlock("A"):n,r="t2c_text_join"===n.type?n.getInputTargetBlock("B"):"t2c_text_join"===o.type&&o.getInputTargetBlock("A"),a="t2c_text_join"===o.type?o.getInputTargetBlock("B"):o;return i&&"text"===i.type&&r&&"variables_get"===r.type&&"firstName"===r.getField("VAR").getText()&&a&&"text"===a.type}),new u([s.createHelpMessageDirections(g,(function(){return"Write a message to welcome the user with his/her name with punctuation at the end. To do this type:\n(1) Something like welcome *in quotes* because you want it to be displayed as is.\n(2) + firstName (+ to join text and firstName without the quotes to get the name the user typed in and not literally the text firstName)\n(3) + and a punctuation mark in quotes to tack on a punctuation symbol at the end."}),(function(){return m.getAllBlocks().find((function(e){return"type_in_welcome_message"===e.type}))?b.getErrorFeedback():""})),new l(A,{totalSteps:100,toggleSteps:25,startPosition:function(){var e=m.getAllBlocks().find((function(e){return"type_in_welcome_message"===e.type}));return x(m,e,{blockOffsetScaleX:.5,blockOffsetScaleY:.5},0,document.getElementById("top-header").offsetHeight)},finish:function(){m.options.maxInstances.type_in_welcome_message=0,m.updateToolbox(document.getElementById("toolbox"))}})]))),s.addRunTask(g,d,(function(){alert("✔✔ Excellent! You just wrote a program to welcome the user and along the way you learned some things about variables, getting input from the user, and joining together string literals and variables to produce output. Mission 0 is just about complete; let's just make sure you can save your work and load it up later! For extra credit, we'll show you what your code looks in pure JavaScript.")}),A),s.addSaveTextCodeTask(g,d,m,null,A,!0),d.addTask(new r((function(){return!0}),{start:function(){return!0},isComplete:function(){return!0},animate:function(){return!0},finish:function(){alert("OK, now that you've copied the code, let's clear the workspace of the blocks and then load it (without reloading the page!) to confirm that everything works. BE SURE NOT TO overwrite the clipboard until you load the code again or you'll lose your work!"),s.hideOutputAndCodeContainers()}})),d.addTask(new r((function(){return 0===m.getAllBlocks().length}),new u([s.createHelpMessageDirections(g,(function(){return"Move all blocks to the trashcan or rightmouse click (hold down finger on phone) on an empty place in the workspace and select Delete."}),""),new l(A,{totalSteps:100,toggleSteps:25,startPosition:function(){var e=m.trashcan.getClientRect();return{x:(e.left+e.right)/2,y:(e.top+e.bottom)/2}}})]))),s.addLoadTextCodeTask(g,d,m,null,A),d.addTask(new r((function(){return!0}),{start:function(){return!0},isComplete:function(){return!0},animate:function(){return!0},finish:function(){alert("👍 Great! You can also save/load the information about the blocks (XML) from/to the second box. This will lay out the blocks exactly as you had them in the workspace. So let's try that now."),s.hideOutputAndCodeContainers()}})),s.addSaveXMLTask(g,d,m,null,A,!0),d.addTask(new r((function(){return!0}),{start:function(){return!0},isComplete:function(){return!0},animate:function(){return!0},finish:function(){alert("OK, now that you've copied the XML for the blocks, let's clear the workspace of the blocks and then load it (without reloading the page!) to confirm that everything works. BE SURE NOT TO overwrite the clipboard until you load the code again or you'll lose your work!"),s.hideOutputAndCodeContainers()}})),d.addTask(new r((function(){return 0===m.getAllBlocks().length}),new u([s.createHelpMessageDirections(g,(function(){return"Move all blocks to the trashcan or rightmouse click (hold down finger on phone) on an empty place in the workspace and select Delete."}),""),new l(A,{totalSteps:100,toggleSteps:25,startPosition:function(){var e=m.trashcan.getClientRect();return{x:(e.left+e.right)/2,y:(e.top+e.bottom)/2}}})]))),s.addLoadXMLTask(g,d,m,null,A),d.addTask(new r((function(){return!0}),{start:function(){return!0},isComplete:function(){return!0},animate:function(){return!0},finish:function(){alert("👍 Excellent! As the last part of this initial exercise, let's see how the blocks look in pure JavaScript."),s.hideOutputAndCodeContainers()}})),d.addTask(new r((function(){return"js"===document.getElementById("language").value}),new u([s.createHelpMessageDirections(g,(function(){return"Select JavaScript and then see what happens to the toolbox and blocks."}),""),new l(A,{totalSteps:100,toggleSteps:25,startPosition:{x:document.getElementById("language").offsetLeft+document.getElementById("language").offsetWidth/2,y:document.getElementById("language").offsetTop+document.getElementById("language").offsetHeight/2}})]))),d.addTask(new r((function(){return!0}),{start:function(){return!0},isComplete:function(){return!0},animate:function(){return!0},finish:function(){alert("✔✔✔ Congratulations! You just completed Mission 0! In your upcoming missions, you'll begin to solve problems without explicit instructions of how to use the blocks.")}})),d},function(e,t){var n=new p,o=n.createStandardHelpMessageManager(),a=e||new c,l=t||Blockly.getMainWorkspace();!function(e){Array.from(document.getElementById("toolbox").children).forEach((function(e){return e.remove()})),e.options.maxInstances={},e.updateToolbox(document.getElementById("toolbox"))}(l),["variables_set","text","text_input"].forEach((function(e){B(l,e,!1),l.options.maxInstances[e]=1})),l.clear(),l.setScale(1),Object(i.f)(l);var s=Array.from(document.querySelectorAll("rect")).filter((function(e){return e.getAttribute("fill-opacity")})),u=(s[0],s[1]);console.warn("TEXT",u);var g=n.createPointer();return document.getElementById("blockly-div").appendChild(g),n.addHelpMessageTask(a,o,(function(){var e=l.getAllBlocks().find((function(e){return"variables_set"===e.type})),t=l.getAllBlocks().find((function(e){return"text_input"===e.type||"js_text_input"===e.type})),n=l.getAllBlocks().find((function(e){return"text"===e.type}));return e&&t&&n&&"s"===e.getField("VAR").getText()&&e.getInputTargetBlock("VALUE")===t&&t.getInputTargetBlock("TEXT")===n&&n.getFieldValue("TEXT").includes("5")&&n.getFieldValue("TEXT").includes("letter")}),"Drag in and assemble code blocks to ask the user for a 5-letter word, and store the input in a variable. \nName the variable s AND\nbe sure that the message includes 5 and letters in it so the user knows to enter 5 letters.",(function(){var e=l.getAllBlocks().find((function(e){return"variables_set"===e.type})),t=(l.getAllBlocks().find((function(e){return"text_input"===e.type||"js_text_input"===e.type})),l.getAllBlocks().find((function(e){return"text"===e.type})));if(e){var n=e.getField("VAR").getText();if("item"===n)return"You can change the variable name by clicking item and then selecting Rename variable...";if(n.includes("5")||n.includes("letter"))return"The variable name, which stores the value the user enters, should be s, not "+n+'. The message you want to display to the user should be in the "" block';if("s"!==n)return"The variable name, which stores the value the user enters, should be s, not "+n+"."}if(t){var o=t.getFieldValue("TEXT");if(""===o)return"You can change the text by clicking the blank field and then typing the desired message.";if("s"===o)return"The text which is displayed to the user should contain 5 and letters; the variable name s should appear in the let block.";if(!o.includes("5")||!o.includes("letter"))return"Make sure the text which is displayed to the user contains 5 and letters so the user knows to enter a 5 letter word."}return e&&t&&e.getInputTargetBlock("VALUE")===t?"The variable should store what the user enters, which means you'll need to attach it to a getInputByAsking block.":""}),null),n.addRunTask(o,a,(function(){alert("✔ Good, but notice there's no output yet. That's because all we did is store what the user entered. So now let's add code blocks to display it!"),B(l,"text_print"),B(l,"variables_get"),l.options.maxInstances.text_print=1,l.options.maxInstances.variables_get=1,l.updateToolbox(document.getElementById("toolbox"))}),g),n.addHelpMessageTask(a,o,(function(){var e=l.getAllBlocks().find((function(e){return"variables_set"===e.type})),t=l.getAllBlocks().find((function(e){return"text_print"===e.type||"js_text_print"===e.type})),n=l.getAllBlocks().find((function(e){return"variables_get"===e.type}));return e&&t&&n&&e.getNextBlock()&&e.getNextBlock()===t&&t.getInputTargetBlock("TEXT")===n&&"s"===n.getField("VAR").getText()}),"Now assemble the blocks to display the value of the variable that the user entered.",(function(){var e=l.getAllBlocks().find((function(e){return"variables_set"===e.type})),t=l.getAllBlocks().find((function(e){return"text_print"===e.type||"js_text_print"===e.type})),n=l.getAllBlocks().find((function(e){return"variables_get"===e.type}));if(n&&"s"!==n.getField("VAR").getText())return"Make sure you change the variable name to s since that's what you want to display its value, which is what the user entered.";if(t){if(e){if(t.getNextBlock()&&t.getNextBlock()===e)return"Make sure the display block appears *after* (below) the variable set block. Otherwise the computer would try to display what the user enters before he/she enters it!";if(!e.getNextBlock())return"Make sure to connect the display block below the let block above it. This way the computer will ask the user for a string, store it in s and then display it!"}if(n&&!t.getInputTargetBlock("TEXT"))return"Place the s block inside the display statement to display its value!"}return""}),null),n.addRunTask(o,a,(function(){alert("✔ Great, so now that we echoed what the user entered, it's time for something new! Let's now display the first letter of the user's word."),B(l,"math_number"),B(l,"t2c_text_charat"),l.options.maxInstances.math_number=1,l.options.maxInstances.t2c_text_charat=1,l.options.maxInstances.text_print++,l.options.maxInstances.variables_get++,l.updateToolbox(document.getElementById("toolbox"))}),g),n.addHelpMessageTask(a,o,(function(){var e=l.getAllBlocks().find((function(e){return("text_print"===e.type||"js_text_print"===e.type)&&e.getInputTargetBlock("TEXT")&&"variables_get"===e.getInputTargetBlock("TEXT").type})),t=l.getAllBlocks().find((function(e){return"math_number"===e.type})),n=l.getAllBlocks().find((function(e){return"t2c_text_charat"===e.type||"js_text_charat"===e.type})),o=l.getAllBlocks().find((function(t){return("text_print"===t.type||"js_text_print"===t.type)&&t!==e})),i=l.getAllBlocks().find((function(t){return"variables_get"===t.type&&t.getParent()!==e}));return e&&t&&n&&o&&i&&e.getNextBlock()&&e.getNextBlock()===o&&o.getInputTargetBlock("TEXT")===n&&"s"===i.getField("VAR").getText()&&n.getInputTargetBlock("VALUE")===i&&n.getInputTargetBlock("AT")===t&&0===t.getFieldValue("NUM")}),"The "+T2C.MSG.currentLanguage.TERMINAL_GETCHARACTERNUMBER+" block gets the single character (letter, number, punctuation mark, space, etc.) of the string of characters at the given numerical position, starting with 0. (E.g., for \"pizza\", the 0th character is 'p', the 1st character is 'i', the 2nd character is 'z', etc.\n Add a statement to display the entered string's initial character.\n\nThe string to get the character from goes in the left and the number to get goes in the right.",(function(){var e=l.getAllBlocks().find((function(e){return("text_print"===e.type||"js_text_print"===e.type)&&e.getInputTargetBlock("TEXT")&&"variables_get"===e.getInputTargetBlock("TEXT").type})),t=l.getAllBlocks().find((function(e){return"math_number"===e.type})),n=l.getAllBlocks().find((function(e){return"t2c_text_charat"===e.type||"js_text_charat"===e.type})),o=l.getAllBlocks().find((function(t){return("text_print"===t.type||"js_text_print"===t.type)&&t!==e})),i=l.getAllBlocks().find((function(t){return"variables_get"===t.type&&t.getParent()!==e}));if(o){if(o.getParent()!==e)return"Make sure to connect the new display statement below the previous one since you want to display word's initial letter after displaying the word itself.";if(o.getInputTargetBlock("TEXT")===t)return"You want to display the character at the initial position, not a number. Use the "+T2C.MSG.currentLanguage.TERMINAL_GETCHARACTERNUMBER+" block inside the display.";if(o.getInputTargetBlock("TEXT")===i)return"You want to display the word's initial character, not the entire word. Use the "+T2C.MSG.currentLanguage.TERMINAL_GETCHARACTERNUMBER+" block inside the display."}if(i&&"s"!==i.getField("VAR").getText())return"Make sure you change the variable name to s since you want its value's (user input's) initial letter.";if(n&&i&&n.getInputTargetBlock("AT")===i)return"The variable storing the text (s) that you want to get the character of should go in the left side of the "+T2C.MSG.currentLanguage.TERMINAL_GETCHARACTERNUMBER+" block.";if(t){if(1===t.getFieldValue("NUM"))return"Remember that positions of characters start at 0, not 1.";if(0!==t.getFieldValue("NUM"))return"Remember that you want a number representing the word's inital position. Change the number accordingly."}return""}),null),n.addRunTask(o,a,(function(){alert("✔ Excellent! Now since you displayed the first character of the user's word, how about the last one? But let's make it more interesting this time by having you type in the code to do this instead! You ready? Let's get to it!"),B(l,"type_in_get_last_char_number"),l.options.maxInstances.type_in_get_last_char_number=1,l.updateToolbox(document.getElementById("toolbox"))}),g),n.addHelpMessageTask(a,o,(function(){var e=l.getAllBlocks().find((function(e){return("text_print"===e.type||"js_text_print"===e.type)&&e.getInputTargetBlock("TEXT")&&("t2c_text_charat"===e.getInputTargetBlock("TEXT").type||"js_text_charat"===e.getInputTargetBlock("TEXT").type)})),t=l.getAllBlocks().find((function(t){return("text_print"===t.type||"js_text_print"===t.type)&&t.getParent()===e})),n=l.getAllBlocks().find((function(e){return"math_number"===e.type&&4===e.getFieldValue("NUM")})),o=l.getAllBlocks().find((function(e){return("t2c_text_charat"===e.type||"js_text_charat"===e.type)&&e.getInputTargetBlock("AT")===n&&e.getParent()===t})),i=l.getAllBlocks().find((function(e){return"variables_get"===e.type&&e.getParent()===o&&"s"===e.getField("VAR").getText()}));return e&&n&&o&&t&&i}),"Drag in the new type-in-code block from the toolbox below the statement that displays the inputted word's first character, and type in code to print its last character.\nThe code you type in should match the previous line except you'll use a different number.",(function(){var e=l.getAllBlocks().find((function(e){return("text_print"===e.type||"js_text_print"===e.type)&&e.getInputTargetBlock("TEXT")&&("t2c_text_charat"===e.getInputTargetBlock("TEXT").type||"js_text_charat"===e.getInputTargetBlock("TEXT").type)})),t=l.getAllBlocks().find((function(e){return("text_print"===e.type||"js_text_print"===e.type)&&e.getInputTargetBlock("TEXT")&&("t2c_text_charat"===e.getInputTargetBlock("TEXT").type||"js_text_charat"===e.getInputTargetBlock("TEXT").type)&&e.getInputTargetBlock("TEXT").getInputTargetBlock("AT")&&"math_number"===e.getInputTargetBlock("TEXT").getInputTargetBlock("AT").type&&4===e.getInputTargetBlock("TEXT").getInputTargetBlock("AT").getFieldValue("NUM")})),n=l.getAllBlocks().find((function(e){return"type_in_get_last_char_number"===e.type}));return e&&t&&t.getParent()!==e?"Make sure to connect the new display statement below the previous one since you want to display word's last letter after displaying its first letter.":n?E.getErrorFeedback(n.getFieldValue("EXP")):""}),null),n.addRunTask(o,a,(function(){l.options.maxInstances.type_in_get_last_char_number=0,alert("✔✔👍 Outstanding! So do you feel comfortable with the new "+T2C.MSG.currentLanguage.TERMINAL_GETCHARACTERNUMBER+" block yet? You'll get some more practice with it in the next mission. But for now, let's conclude Mission # 1 by making sure you remember how to save and load this code the next time you want to refer to it. Let's save and load the block code.")}),g),n.addSaveXMLTask(o,a,l,null,g,!0),a.addTask(new r((function(){return!0}),{start:function(){return!0},isComplete:function(){return!0},animate:function(){return!0},finish:function(){alert("OK, now that you've copied the XML for the blocks, let's clear the workspace of the blocks and then load it (without reloading the page!) to confirm that everything works. BE SURE NOT TO overwrite the clipboard until you load the code again or you'll lose your work!"),n.hideOutputAndCodeContainers()}})),n.addDeleteAllBlocksTask(o,a,l,null,g),n.addLoadXMLTask(o,a,l,null,g),a.addTask(new r((function(){return!0}),{start:function(){return!0},isComplete:function(){return!0},animate:function(){return!0},finish:function(){alert("✔✔✔ Congratulations! You just completed Mission 1! In your upcoming mission, you'll get the last character for strings that may not have 5 letters with the help of some new blocks."),n.hideOutputAndCodeContainers()}})),a},function(e,t){var n=new p,o=n.createStandardHelpMessageManager(),a=e||new c,l=t||Blockly.getMainWorkspace();!function(e){Array.from(document.getElementById("toolbox").children).forEach((function(e){return e.remove()})),e.options.maxInstances={},e.updateToolbox(document.getElementById("toolbox"))}(l),["variables_set","text","text_input"].forEach((function(e){A(l,e,!1),l.options.maxInstances[e]=1})),l.clear(),l.setScale(1),Object(i.f)(l);var s=n.createPointer();return document.getElementById("blockly-div").appendChild(s),n.addHelpMessageTask(a,o,(function(){var e=l.getAllBlocks().find((function(e){return"variables_set"===e.type})),t=l.getAllBlocks().find((function(e){return"text_input"===e.type||"js_text_input"===e.type})),n=l.getAllBlocks().find((function(e){return"text"===e.type}));return e&&t&&n&&e.getInputTargetBlock("VALUE")===t&&t.getInputTargetBlock("TEXT")===n&&n.getFieldValue("TEXT")&&!e.getField("VAR").getText().includes(" ")}),"Drag in and assemble code blocks to ask the user for a string of any length, and store the input in a variable. By string, we simply mean a series of characters, which can be numbers, letters, punctuation, or spaces. Choose your own variable name and message this time.",(function(){var e=l.getAllBlocks().find((function(e){return"variables_set"===e.type})),t=(l.getAllBlocks().find((function(e){return"text_input"===e.type||"js_text_input"===e.type})),l.getAllBlocks().find((function(e){return"text"===e.type})));return e&&e.getField("VAR").getText().includes(" ")?"Avoid spaces in your variable names as they won't be allowed if you program in languages such as JavaScript or Python.":t&&""===t.getFieldValue("TEXT")?"You can change the text by clicking the blank field and then typing the desired message.":e&&t&&e.getInputTargetBlock("VALUE")===t?"The variable should store what the user enters, which means you'll need to attach it to a getInputByAsking block.":""}),null),n.addRunTask(o,a,(function(){alert("✔ Good, so as in the previous mission, we won't see any output because we only set a variable. As before, let's display the string next."),A(l,"text_print"),A(l,"variables_get"),l.options.maxInstances.text_print=1,l.options.maxInstances.variables_get=1,l.updateToolbox(document.getElementById("toolbox"))}),s),n.addHelpMessageTask(a,o,(function(){var e=l.getAllBlocks().find((function(e){return"variables_set"===e.type})),t=l.getAllBlocks().find((function(e){return"text_print"===e.type||"js_text_print"===e.type})),n=l.getAllBlocks().find((function(e){return"variables_get"===e.type}));return e&&t&&n&&e.getNextBlock()&&e.getNextBlock()===t&&t.getInputTargetBlock("TEXT")===n&&n.getField("VAR").getText()===e.getField("VAR").getText()}),"Now assemble the blocks to display the value of the variable that the user entered.",(function(){var e=l.getAllBlocks().find((function(e){return"variables_set"===e.type})),t=l.getAllBlocks().find((function(e){return"text_print"===e.type||"js_text_print"===e.type})),n=l.getAllBlocks().find((function(e){return"variables_get"===e.type}));if(n&&e&&n.getField("VAR").getText()!==e.getField("VAR").getText())return"Make sure the variable name you display matches the one you set to the value of the user's input so you display what the user entered.";if(t){if(e){var o=e.getField("VAR").getText();if(t.getNextBlock()&&t.getNextBlock()===e)return"Make sure the "+T2C.MSG.currentLanguage.TERMINAL_DISPLAY+" block appears *after* (below) the "+T2C.MSG.currentLanguage.TERMINAL_LET+" variable block setting "+o+". Otherwise the computer would try to display what the user enters before he/she enters it!";if(!e.getNextBlock())return"Make sure to connect the display block below the "+T2C.MSG.currentLanguage.TERMINAL_LET+" variable block setting "+o+". This way the computer will ask the user for a string, store it in "+o+" and then display it!"}if(n&&!t.getInputTargetBlock("TEXT"))return"Place the variable block inside the display statement to display its value!"}return""}),null),n.addRunTask(o,a,(function(){alert("✔ Great, so now that we echoed what the user entered, it's time for something new! Let's display the number of characters in the string the user entered."),A(l,"t2c_text_length"),l.options.maxInstances.t2c_text_length=1,l.options.maxInstances.text_print++,l.options.maxInstances.variables_get++,l.updateToolbox(document.getElementById("toolbox"))}),s),n.addHelpMessageTask(a,o,(function(){var e=l.getAllBlocks().find((function(e){return("text_print"===e.type||"js_text_print"===e.type)&&e.getInputTargetBlock("TEXT")&&"variables_get"===e.getInputTargetBlock("TEXT").type})),t=l.getAllBlocks().find((function(t){return("text_print"===t.type||"js_text_print"===t.type)&&t!==e})),n=l.getAllBlocks().find((function(t){return"variables_get"===t.type&&t.getParent()!==e})),o=l.getAllBlocks().find((function(e){return"variables_set"===e.type})),i=l.getAllBlocks().find((function(e){return"t2c_text_length"===e.type}));return e&&t&&n&&i&&o&&e.getNextBlock()&&e.getNextBlock()===t&&t.getInputTargetBlock("TEXT")===i&&n.getField("VAR").getText()===o.getField("VAR").getText()&&i.getInputTargetBlock("VALUE")===n}),"The "+T2C.MSG.currentLanguage.TERMINAL_LENGTH+" block gets the number of characters in the provided string. Unlike the "+T2C.MSG.currentLanguage.TERMINAL_GETCHARACTERNUMBER+' block though, the count starts at 1! (E.g., for "pizza", the length would be 5.)\n Add a statement to display the length of the given string.',(function(){var e=l.getAllBlocks().find((function(e){return("text_print"===e.type||"js_text_print"===e.type)&&e.getInputTargetBlock("TEXT")&&"variables_get"===e.getInputTargetBlock("TEXT").type})),t=l.getAllBlocks().find((function(t){return("text_print"===t.type||"js_text_print"===t.type)&&t!==e})),n=l.getAllBlocks().find((function(t){return"variables_get"===t.type&&t.getParent()!==e})),o=l.getAllBlocks().find((function(e){return"variables_set"===e.type})),i=l.getAllBlocks().find((function(e){return"t2c_text_length"===e.type}));if(t){if(t.getParent()!==e)return"Make sure to connect the new display statement below the previous one since you want to display word's length after displaying the word itself.";if(t.getInputTargetBlock("TEXT")===n)return"You want to display the word's length, not the entire word. Use the "+T2C.MSG.currentLanguage.TERMINAL_LENGTH+" block inside the display."}return n&&o&&n.getField("VAR").getText()!==o.getField("VAR").getText()?"Make sure the variable name you display matches the one you set to the value of the user's input so you display what the user entered.":i&&n&&i.getInputTargetBlock("VALUE")!==n?"Be sure to attach the variable block to the "+T2C.MSG.currentLanguage.TERMINAL_LENGTH+" block to get the number of characters in the user input.":""}),null),n.addRunTask(o,a,(function(){alert("✔ Great! Now since you displayed the length of the user's word, can you display double its length instead for good measure? We'll need a new arithmetic block for this."),A(l,"math_number"),A(l,"math_arithmetic_basic"),l.options.maxInstances.math_number=1,l.options.maxInstances.math_arithmetic_basic=1,l.updateToolbox(document.getElementById("toolbox"))}),s),n.addHelpMessageTask(a,o,(function(){var e=l.getAllBlocks().find((function(e){return("text_print"===e.type||"js_text_print"===e.type)&&e.getInputTargetBlock("TEXT")&&"variables_get"===e.getInputTargetBlock("TEXT").type})),t=l.getAllBlocks().find((function(t){return("text_print"===t.type||"js_text_print"===t.type)&&t!==e})),n=l.getAllBlocks().find((function(t){return"variables_get"===t.type&&t.getParent()!==e})),o=l.getAllBlocks().find((function(e){return"variables_set"===e.type})),i=l.getAllBlocks().find((function(e){return"t2c_text_length"===e.type})),r=l.getAllBlocks().find((function(e){return"math_arithmetic_basic"===e.type})),a=l.getAllBlocks().find((function(e){return"math_number"===e.type}));return e&&t&&n&&i&&o&&r&&a&&e.getNextBlock()&&e.getNextBlock()===t&&t.getInputTargetBlock("TEXT")===r&&n.getField("VAR").getText()===o.getField("VAR").getText()&&a.getParent()===r&&i.getParent()===r&&("MULTIPLY"===r.getFieldValue("OP")&&2===a.getFieldValue("NUM")||"DIVIDE"===r.getFieldValue("OP")&&.5===a.getFieldValue("NUM"))}),"The arithmetic block can be used on blocks producing numerical values such as "+T2C.MSG.currentLanguage.TERMINAL_LENGTH+" to add, subtract, multiply, or divide depending on the selected option from +, -, *, / by placing the number-producing blocks you want to use in the calculation.\nUsing this new arithmetic block and number block, modify your display statement to show double the length of the entered string.",(function(){var e=l.getAllBlocks().find((function(e){return("text_print"===e.type||"js_text_print"===e.type)&&e.getInputTargetBlock("TEXT")&&"variables_get"===e.getInputTargetBlock("TEXT").type})),t=l.getAllBlocks().find((function(t){return("text_print"===t.type||"js_text_print"===t.type)&&t!==e})),n=l.getAllBlocks().find((function(t){return"variables_get"===t.type&&t.getParent()!==e})),o=l.getAllBlocks().find((function(e){return"variables_set"===e.type})),i=l.getAllBlocks().find((function(e){return"t2c_text_length"===e.type})),r=l.getAllBlocks().find((function(e){return"math_arithmetic_basic"===e.type})),a=l.getAllBlocks().find((function(e){return"math_number"===e.type}));if(t){if(t.getParent()!==e)return"Make sure the display statement stays below the previous one since you want to display double the word's length after displaying the word itself.";if(t.getInputTargetBlock("TEXT")===i)return"You want to display double the string's length, not just its length. Use the arithmetic (+,-,*,/) block inside the display.";if(t.getInputTargetBlock("TEXT")===n)return"You want to display double the string's length, not the entire string. Use the arithmetic (+,-,*,/) block inside the display.";if(t.getInputTargetBlock("TEXT")===a)return"You want to display double the string's length, not just a number. Use the arithmetic (+,-,*,/) block inside the display."}if(n&&o&&n.getField("VAR").getText()!==o.getField("VAR").getText())return"Make sure the variable name you display matches the one you set to the value of the user's input so you display what the user entered.";if(i&&n&&i.getInputTargetBlock("VALUE")!==n)return"Be sure that the variable block remains inside the "+T2C.MSG.currentLanguage.TERMINAL_LENGTH+" block so you can get the number of characters in the user input before doubling it.";if(r){if(n&&n.getParent()===r)return"Be sure the variable block remains inside the "+T2C.MSG.currentLanguage.TERMINAL_LENGTH+" block since you don't want to double the string itself, but its length! Doubling 'pizza' doesn't give you 10, right? Doubling its length of 5 does.";if(a&&("MULTIPLY"!==r.getFieldValue("OP")&&.5!==a.getFieldValue("NUM")||"DIVIDE"!==r.getFieldValue("OP")&&2!==a.getFieldValue("NUM")))return"What operation/number could you use to double the length? Select the appropriate option from the dropdown (+ = ADD, - = SUBTRACT, * = MULTIPLY, / = DIVIDE), and change the value of the number block from "+a.getFieldValue("NUM")+" to this desired number accordingly."}return""}),null),n.addRunTask(o,a,(function(){alert("✔ Excellent! OK, so now that you can use the arithmetic and length blocks, let's combine them with the previous "+T2C.MSG.currentLanguage.TERMINAL_GETCHARACTERNUMBER+" block to get the last character of the string, regardless of whether it's 1 character or 100 or any other number! You up for the challenge? Let's get to it!"),A(l,"t2c_text_charat"),l.options.maxInstances.t2c_text_charat=1,l.options.maxInstances.variables_get++,l.updateToolbox(document.getElementById("toolbox"))}),s),n.addHelpMessageTask(a,o,(function(){var e=l.getAllBlocks().find((function(e){return("text_print"===e.type||"js_text_print"===e.type)&&e.getInputTargetBlock("TEXT")&&"variables_get"===e.getInputTargetBlock("TEXT").type})),t=l.getAllBlocks().find((function(e){return"t2c_text_charat"===e.type||"js_text_charat"===e.type})),n=l.getAllBlocks().find((function(e){return("text_print"===e.type||"js_text_print"===e.type)&&e.getInputTargetBlock("TEXT")===t})),o=l.getAllBlocks().find((function(e){return"math_arithmetic_basic"===e.type})),i=l.getAllBlocks().find((function(e){return"t2c_text_length"===e.type})),r=l.getAllBlocks().find((function(e){return"math_number"===e.type})),a=l.getAllBlocks().find((function(e){return"variables_get"===e.type&&e.getParent()===t})),s=l.getAllBlocks().find((function(e){return"variables_get"===e.type&&e.getParent()===i})),u=l.getAllBlocks().find((function(e){return"variables_set"===e.type}));return e&&n&&o&&i&&r&&t&&a&&s&&u&&a.getField("VAR").getText()===u.getField("VAR").getText()&&s.getField("VAR").getText()===u.getField("VAR").getText()&&t.getInputTargetBlock("VALUE")===a&&t.getInputTargetBlock("AT")===o&&o.getInputTargetBlock("A")===i&&"MINUS"===o.getFieldValue("OP")&&o.getInputTargetBlock("B")===r&&1===r.getFieldValue("NUM")}),"Change the math operation and number that's used with the "+T2C.MSG.currentLanguage.TERMINAL_LENGTH+" to calculate the *position* of the last character from its number of characters. Then add a "+T2C.MSG.currentLanguage.TERMINAL_GETCHARACTERNUMBER+" and variable block in the appropriate places to display the last character, regardless of the length of the string. To determine the appropriate math operation and number to use for the position, consider strings of different lengths. How did you determine the number to use for the position of the last character of a 5-character string? What would you do with the 5 to get it? What if you wanted to calculate the position of the last character of a string of length 3? What about the position of the last character for a string of length 10? The math operation and number you use should be the same for each example to get your answer.",(function(){var e=l.getAllBlocks().find((function(e){return("text_print"===e.type||"js_text_print"===e.type)&&e.getInputTargetBlock("TEXT")&&"variables_get"===e.getInputTargetBlock("TEXT").type})),t=l.getAllBlocks().find((function(e){return"t2c_text_charat"===e.type||"js_text_charat"===e.type})),n=l.getAllBlocks().find((function(t){return("text_print"===t.type||"js_text_print"===t.type)&&t!==e})),o=l.getAllBlocks().find((function(e){return"math_arithmetic_basic"===e.type})),i=l.getAllBlocks().find((function(e){return"t2c_text_length"===e.type})),r=l.getAllBlocks().find((function(e){return"math_number"===e.type})),a=(l.getAllBlocks().find((function(e){return"variables_get"===e.type&&e.getParent()===i})),l.getAllBlocks().find((function(e){return"variables_get"===e.type&&e.getParent()===t})));if(l.getAllBlocks().find((function(e){return"variables_set"===e.type})),n&&n.getParent()!==e)return"Make sure to connect the new display statement below the previous one since you want to display the string's last character after displaying the whole string.";if(t){if(a&&t.getInputTargetBlock("AT")===a)return"The variable storing the text that you want to get the character of should go in the left side of the "+T2C.MSG.currentLanguage.TERMINAL_GETCHARACTERNUMBER+' block. It wouldn\'t make sense to get the character at position number "pizza" (or whatever string the user enters), right?';if(i&&t.getInputTargetBlock("AT")===i)return"The length of the 5-character string pizza is 5, but since you start counting from 0, this was not the position of the last character that you used in the previous exercise, correct? Consider using some math operation on this number to calculate the correct position.";if(r&&t.getInputTargetBlock("AT")===r)return"The position of the last character will depend on the length of the string so you can't use a specific number such as "+r.getFieldValue("NUM")+". You will need to use the "+MSG.T2C.currentLanguage.TERMINAL_LENGTH+" block and a math operation to calculate the correct position for each string containing at least one character."}if(n&&t){if(n.getInputTargetBlock("TEXT")===o)return"You want to display the string's last character, not the result of an arithmetic calculation, which would be a number.";if(n.getInputTargetBlock("TEXT")===i)return"You want to display the string's last character, not the length of the string, which would be a number.";if(n.getInputTargetBlock("TEXT")===r)return"You want to display the string's last character, not a number."}if(o&&r&&i&&t&&r.getParent()===o&&i.getParent()===o){if("PLUS"===o.getFieldValue("OP")&&1===r.getFieldValue("NUM"))return"Consider that adding 1 to 5, which is the length of pizza gives you 6. Did you use 6 for the position for the last mission?";if("PLUS"!==o.getFieldValue("OP")&&1!==r.getFieldValue("NUM")||"MINUS"!==o.getFieldValue("OP")&&-1!==r.getFieldValue("NUM"))return"Select the appropriate option from the arithmetic block dropdown menu (+ = ADD, - = SUBTRACT, * = MULTIPLY, / = DIVIDE) and choose the appropriate number. Your current answer won't work in general."}return""}),null),n.addRunTask(o,a,(function(){l.options.maxInstances.type_in_get_last_char_number=0,alert("✔✔👍 Outstanding! So do you feel comfortable with using the new "+T2C.MSG.currentLanguage.TERMINAL_LENGTH+" block in combination with the arithmetic and "+T2C.MSG.currentLanguage.TERMINAL_GETCHARACTERNUMBER+" blocks yet? In the next mission, we'll use these blocks to get the middle two characters of strings with an even number of characters (and not 0). But for now, let's conclude Mission # 2 by making sure you can save this code for later use. Let's save and load the block code.")}),s),n.addSaveXMLTask(o,a,l,null,s,!0),a.addTask(new r((function(){return!0}),{start:function(){return!0},isComplete:function(){return!0},animate:function(){return!0},finish:function(){alert("OK, now that you've copied the XML for the blocks, let's clear the workspace of the blocks and then load it (without reloading the page!) to confirm that everything works. BE SURE NOT TO overwrite the clipboard until you load the code again or you'll lose your work!"),n.hideOutputAndCodeContainers()}})),n.addDeleteAllBlocksTask(o,a,l,null,s),n.addLoadXMLTask(o,a,l,null,s),a.addTask(new r((function(){return!0}),{start:function(){return!0},isComplete:function(){return!0},animate:function(){return!0},finish:function(){alert("✔✔✔ Congratulations! You just completed Mission 2! On to even tougher challenges ahead!"),n.hideOutputAndCodeContainers()}})),a},function(e,t){var n=e||new c;alert("In this mission, you'll be prompting the user for a string with an even number of characters (at least 2) and then displaying a single 4-character string as first character, last character, first middle character, and second middle character in that order. For example, for SCRABBLE, you'd display SEAB.");var o=t||Blockly.getMainWorkspace();N(o),["type_in_get_input"].forEach((function(e){L(o,e,!1),o.options.maxInstances[e]=1})),o.clear();var a=O("variables_set"),g=O("text_input"),d=O("text");C(d,"TEXT","message to user"),R(g,"TEXT",d),R(a,"VALUE",g),o.options.maxInstances.variables_set=0,document.getElementById("toolbox").append(a),o.updateToolbox(document.getElementById("toolbox")),o.setScale(1),Object(i.f)(o),Array.from(document.querySelectorAll("rect")).filter((function(e){return e.getAttribute("fill-opacity")}));var h=document.createElement("div");return h.innerText="👆",h.id="ptr",h.style.fontSize="x-large",h.style.position="absolute",h.style.zIndex="1001",document.getElementById("blockly-div").appendChild(h),n.addTask(new r((function(){var e=o.getAllBlocks().find((function(e){return"text"===e.type&&-1!==e.getFieldValue("TEXT").toLowerCase().indexOf(" even ")})),t=o.getAllBlocks().find((function(t){return("text_input"===t.type||"js_text_input"===t.type)&&t.getInputTargetBlock("TEXT")===e})),n=o.getAllBlocks().find((function(e){return"variables_set"===e.type&&null===e.getNextBlock()&&e.getInputTargetBlock("VALUE")===t&&"s"===e.getField("VAR").getText()}));return e&&t&&n}),new s((function(){return"OK, you know the drill; let's start by asking the user for a string and storing it in a variable. This time, we'll be asking the user for a string with an even number of characters (> 0) so make sure even (surrounded by spaces) appears in your message. Let's store the user's string in a variable s. But this time, we'll make it more interesting: you'll drag in the block and type in the code! Do you remember what you'll be typing, i.e., what appeared on the blocks, from previous exercises? If not, use the blocks above as reference, and start typing it in accordingly. Don't worry, we'll give you hints if you make a mistake."}),{startPosition:F(o,null,{},50,document.getElementById("top-header").offsetHeight+50)}))),n.addTask(new r((function(){return!0}),{start:function(){return!0},isComplete:function(){return!0},animate:function(){return!0},finish:function(){alert("✔ Good, so let's start by creating a variable named firstCharacter to store the initial character of the string the user enters. As before, we'll make it more interesting by typing in the code."),S(document.getElementById("output-container").querySelectorAll(".table-cell")[0]),M(),N(o);var e=O("variables_set"),t=O("variables_get"),n=O("t2c_text_charat"),i=O("math_number");C(i,"NUM",0),C(t,"VAR","textVariable"),R(n,"VALUE",t),R(n,"AT",i),R(e,"VALUE",n),L(o,"type_in_set_to_char_number_0"),o.options.maxInstances.variables_set=0,o.options.maxInstances.type_in_set_to_char_number_0=1,document.getElementById("toolbox").append(e),o.updateToolbox(document.getElementById("toolbox"))}})),n.addTask(new r((function(){var e=o.getAllBlocks().find((function(e){return"math_number"===e.type&&0===e.getFieldValue("NUM")})),t=o.getAllBlocks().find((function(e){return"variables_get"===e.type&&"s"===e.getField("VAR").getText()})),n=o.getAllBlocks().find((function(n){return("t2c_text_charat"===n.type||"js_text_charat"===n.type)&&n.getInputTargetBlock("VALUE")===t&&n.getInputTargetBlock("AT")===e})),i=o.getAllBlocks().find((function(e){return"variables_set"===e.type&&null===e.getNextBlock()&&e.getInputTargetBlock("VALUE")===n&&"firstChar"===e.getField("VAR").getText()})),r=o.getAllBlocks().find((function(e){return"text"===e.type&&-1!==e.getFieldValue("TEXT").toLowerCase().indexOf(" even ")})),a=o.getAllBlocks().find((function(e){return("text_input"===e.type||"js_text_input"===e.type)&&e.getInputTargetBlock("TEXT")===r})),l=o.getAllBlocks().find((function(e){return"variables_set"===e.type&&e.getNextBlock()===i&&e.getInputTargetBlock("VALUE")===a&&"s"===e.getField("VAR").getText()}));return e&&t&&n&&i&&r&&a&&l}),new s((function(){var e=o.getAllBlocks().find((function(e){return"variables_set"===e.type&&"firstChar"===e.getField("VAR").getText()})),t=o.getAllBlocks().find((function(e){return"variables_set"===e.type&&"s"===e.getField("VAR").getText()}));return e&&t&&t.getPreviousBlock()===e?"Make sure to attach the block storing the entered string's first character below the one storing the string itself. Since instructions are run top to bottom, if you reversed the order, the computer wouldn't know what s is when trying get the string!":e&&t&&e.getPreviousBlock()!==t?"Make sure to attach the block storing the entered string's first character below the one storing the string itself.":"Drag in the type-in-code block and enter the code needed to get and store the initial character of the entered string in the variable firstChar. Be sure to attach this statement below the one declaring the variable to store the user's entered string."}),{startPosition:F(o,null,{},50,document.getElementById("top-header").offsetHeight+50)}))),n.addTask(new r((function(){return!0}),{start:function(){return!0},isComplete:function(){return!0},animate:function(){return!0},finish:function(){alert("✔ Good, so now we'll define a variable named lastCharacter to store the last character of the string the user enters. As before, you'll be typing in the code and as in the previous mission, remember that you don't know how many characters the string has so you'll be using "+T2C.MSG.currentLanguage.TERMINAL_LENGTH+" in your answer."),S(document.getElementById("output-container").querySelectorAll(".table-cell")[0]),M(),N(o);var e=O("variables_set"),t=O("variables_get"),n=O("variables_get"),i=O("t2c_text_charat"),r=O("math_number"),a=O("math_arithmetic_basic"),l=O("t2c_text_length");C(r,"NUM",1),C(t,"VAR","textVariable"),C(n,"VAR","textVariable"),R(i,"VALUE",t),R(i,"AT",a),R(a,"A",l),R(l,"VALUE",n),R(a,"B",r),C(a,"OP","MINUS"),R(e,"VALUE",i),L(o,"type_in_set_to_last_char"),o.options.maxInstances.variables_set=0,o.options.maxInstances.type_in_set_to_last_char=1,document.getElementById("toolbox").append(e),o.updateToolbox(document.getElementById("toolbox"))}})),n.addTask(new r((function(){var e=o.getAllBlocks().find((function(e){return"math_number"===e.type&&1===e.getFieldValue("NUM")})),t=o.getAllBlocks().find((function(e){return"t2c_text_length"===e.type&&e.getInputTargetBlock("VALUE")&&"variables_get"===e.getInputTargetBlock("VALUE").type&&"s"===e.getInputTargetBlock("VALUE").getField("VAR").getText()})),n=o.getAllBlocks().find((function(n){return"math_arithmetic_basic"===n.type&&n.getInputTargetBlock("A")===t&&n.getInputTargetBlock("B")===e&&"MINUS"===n.getFieldValue("OP")})),i=o.getAllBlocks().find((function(e){return("t2c_text_charat"===e.type||"js_text_charat"===e.type)&&e.getInputTargetBlock("VALUE")&&"variables_get"===e.getInputTargetBlock("VALUE").type&&"s"===e.getInputTargetBlock("VALUE").getField("VAR").getText()&&e.getInputTargetBlock("AT")===n})),r=o.getAllBlocks().find((function(e){return"variables_set"===e.type&&null===e.getNextBlock()&&e.getInputTargetBlock("VALUE")===i&&"lastChar"===e.getField("VAR").getText()})),a=o.getAllBlocks().find((function(e){return"math_number"===e.type&&0===e.getFieldValue("NUM")})),l=o.getAllBlocks().find((function(e){return("t2c_text_charat"===e.type||"js_text_charat"===e.type)&&e.getInputTargetBlock("VALUE")&&"variables_get"===e.getInputTargetBlock("VALUE").type&&"s"===e.getInputTargetBlock("VALUE").getField("VAR").getText()&&e.getInputTargetBlock("AT")===a})),s=o.getAllBlocks().find((function(e){return"variables_set"===e.type&&e.getNextBlock()===r&&e.getInputTargetBlock("VALUE")===l&&"firstChar"===e.getField("VAR").getText()})),u=o.getAllBlocks().find((function(e){return"text"===e.type})),c=o.getAllBlocks().find((function(e){return("text_input"===e.type||"js_text_input"===e.type)&&e.getInputTargetBlock("TEXT")===u})),g=o.getAllBlocks().find((function(e){return"variables_set"===e.type&&e.getNextBlock()===s&&e.getInputTargetBlock("VALUE")===c&&"s"===e.getField("VAR").getText()}));return e&&t&&n&&i&&r&&a&&l&&s&&u&&c&&g}),new s((function(){var e=o.getAllBlocks().find((function(e){return"variables_set"===e.type&&"lastChar"===e.getField("VAR").getText()})),t=o.getAllBlocks().find((function(e){return"variables_set"===e.type&&"firstChar"===e.getField("VAR").getText()})),n=o.getAllBlocks().find((function(e){return"variables_set"===e.type&&"s"===e.getField("VAR").getText()}));return n&&e&&n.getPreviousBlock()===e?"Make sure to attach the block storing the entered string's last character below the one storing the string itself. Since instructions are run top to bottom, if you reversed the order, the computer wouldn't know what s is when trying get the string!":t&&e&&e.getPreviousBlock()!==t?"Make sure to attach the block storing the entered string's last character below the one storing the string's first one. Although it won't matter which we store first, we'll do it this way for the purposes of this exercise.":"Drag in the type-in-code block and enter the code needed to get and store the last character of the entered string in the variable lastChar. Be sure to attach this statement below the one declaring the variable to store the entered string's first character."}),{startPosition:F(o,null,{},50,document.getElementById("top-header").offsetHeight+50)}))),n.addTask(new r((function(){return!0}),{start:function(){return!0},isComplete:function(){return!0},animate:function(){return!0},finish:function(){alert("✔ Great, so enough review, it's time for something new! We will need to get the middle two characters. Just like the last character, this will require do some math on the length of the string to get the correct position numbers. Let's start by getting just the *position* of the *2nd* middle character first. We'll do the second first because the relationship between the length and the last position is easier to see. And then we can use this number to get the position of the first middle character since it appears one place before the second."),S(document.getElementById("output-container").querySelectorAll(".table-cell")[0]),M(),N(o),L(o,"type_in_set_to_position_of_second_middle_char"),o.options.maxInstances.type_in_set_to_position_of_second_middle_char=1,o.updateToolbox(document.getElementById("toolbox"))}})),n.addTask(new r((function(){var e=o.getAllBlocks().find((function(e){return"math_number"===e.type&&2===e.getFieldValue("NUM")})),t=o.getAllBlocks().find((function(t){return"math_arithmetic_basic"===t.type&&t.getInputTargetBlock("A")&&"t2c_text_length"===t.getInputTargetBlock("A").type&&t.getInputTargetBlock("A").getInputTargetBlock("VALUE")&&"variables_get"===t.getInputTargetBlock("A").getInputTargetBlock("VALUE").type&&"s"===t.getInputTargetBlock("A").getInputTargetBlock("VALUE").getField("VAR").getText()&&t.getInputTargetBlock("B")===e&&"DIVIDE"===t.getFieldValue("OP")})),n=o.getAllBlocks().find((function(e){return"variables_set"===e.type&&null===e.getNextBlock()&&e.getInputTargetBlock("VALUE")===t&&"positionOfSecondMiddleChar"===e.getField("VAR").getText()})),i=o.getAllBlocks().find((function(e){return"math_number"===e.type&&1===e.getFieldValue("NUM")})),r=o.getAllBlocks().find((function(e){return"math_arithmetic_basic"===e.type&&e.getInputTargetBlock("A")&&"t2c_text_length"===e.getInputTargetBlock("A").type&&e.getInputTargetBlock("A").getInputTargetBlock("VALUE")&&"variables_get"===e.getInputTargetBlock("A").getInputTargetBlock("VALUE").type&&"s"===e.getInputTargetBlock("A").getInputTargetBlock("VALUE").getField("VAR").getText()&&e.getInputTargetBlock("B")===i&&"MINUS"===e.getFieldValue("OP")})),a=o.getAllBlocks().find((function(e){return("t2c_text_charat"===e.type||"js_text_charat"===e.type)&&e.getInputTargetBlock("VALUE")&&"variables_get"===e.getInputTargetBlock("VALUE").type&&"s"===e.getInputTargetBlock("VALUE").getField("VAR").getText()&&e.getInputTargetBlock("AT")===r})),l=o.getAllBlocks().find((function(e){return"variables_set"===e.type&&e.getNextBlock()===n&&e.getInputTargetBlock("VALUE")===a&&"lastChar"===e.getField("VAR").getText()})),s=o.getAllBlocks().find((function(e){return"math_number"===e.type&&0===e.getFieldValue("NUM")})),u=o.getAllBlocks().find((function(e){return("t2c_text_charat"===e.type||"js_text_charat"===e.type)&&e.getInputTargetBlock("VALUE")&&"variables_get"===e.getInputTargetBlock("VALUE").type&&"s"===e.getInputTargetBlock("VALUE").getField("VAR").getText()&&e.getInputTargetBlock("AT")===s})),c=o.getAllBlocks().find((function(e){return"variables_set"===e.type&&e.getNextBlock()===l&&e.getInputTargetBlock("VALUE")===u&&"firstChar"===e.getField("VAR").getText()})),g=o.getAllBlocks().find((function(e){return"text"===e.type})),d=o.getAllBlocks().find((function(e){return("text_input"===e.type||"js_text_input"===e.type)&&e.getInputTargetBlock("TEXT")===g})),h=o.getAllBlocks().find((function(e){return"variables_set"===e.type&&e.getNextBlock()===c&&e.getInputTargetBlock("VALUE")===d&&"s"===e.getField("VAR").getText()}));return e&&t&&n&&i&&r&&a&&l&&s&&u&&c&&g&&d&&h}),new s((function(){var e=o.getAllBlocks().find((function(e){return"variables_set"===e.type&&"positionOfSecondMiddleChar"===e.getField("VAR").getText()})),t=(o.getAllBlocks().find((function(e){return"variables_set"===e.type&&"lastChar"===e.getField("VAR").getText()})),o.getAllBlocks().find((function(e){return"variables_set"===e.type&&"s"===e.getField("VAR").getText()}))),n=e&&e.getPreviousBlock()&&"variables_set"===e.getPreviousBlock().type&&e.getPreviousBlock().getField("VAR").getText();return e&&e.getNextBlock()&&"variables_set"===e.getNextBlock().type&&e.getNextBlock().getField("VAR").getText(),e&&t&&e.getNextBlock()===t?"Make sure to attach the block storing the position of the string's second middle character below the one storing the string itself. Since instructions are run top to bottom, if you reversed the order, the computer wouldn't know what s is when trying to get its length in the calculation of the its second middle character's position!":!e||n&&"lastChar"===n?"Drag in the type-in-code block, and enter the code needed to calculate the position of the second middle character of the entered string FROM the string's length and store it in the variable positionOfSecondMiddleChar. Be sure to attach this statement below the one declaring the variable to store the entered string's last character.\nThis means you'll be using s.length and a math operation in your code.\nIf you're not sure what math operation and number to use, consider the following strings' lengths and second middle character positions: \nat : 2 | 1\ncode : 4 | 2\npizzas : 6 | 3\nscrabble : 8 | 4":"Make sure to attach this block storing the position of the second middle character below the last one you entered in which you store the last character in the variable lastChar."}),{startPosition:F(o,null,{},50,document.getElementById("top-header").offsetHeight+50)}))),n.addTask(new r((function(){return!0}),{start:function(){return!0},isComplete:function(){return!0},animate:function(){return!0},finish:function(){alert("✔ Great again! So now let's get the *position* of the first middle character. Remember the first middle character appears *one place before* the second so what math operation can you use on the position of the second middle character to get the position of the first middle character?"),S(document.getElementById("output-container").querySelectorAll(".table-cell")[0]),M(),N(o),L(o,"type_in_set_to_position_of_first_middle_char"),o.options.maxInstances.type_in_set_to_position_of_first_middle_char=1,o.updateToolbox(document.getElementById("toolbox"))}})),n.addTask(new r((function(){var e=o.getAllBlocks().find((function(e){return"variables_get"===e.type&&"positionOfSecondMiddleChar"===e.getField("VAR").getText()})),t=o.getAllBlocks().find((function(t){return"math_arithmetic_basic"===t.type&&t.getInputTargetBlock("A")===e&&t.getInputTargetBlock("B")&&"math_number"===t.getInputTargetBlock("B").type&&1===t.getInputTargetBlock("B").getFieldValue("NUM")&&"MINUS"===t.getFieldValue("OP")})),n=o.getAllBlocks().find((function(e){return"variables_set"===e.type&&null===e.getNextBlock()&&e.getInputTargetBlock("VALUE")===t&&"positionOfFirstMiddleChar"===e.getField("VAR").getText()})),i=o.getAllBlocks().find((function(e){return"math_number"===e.type&&2===e.getFieldValue("NUM")})),r=o.getAllBlocks().find((function(e){return"math_arithmetic_basic"===e.type&&e.getInputTargetBlock("A")&&"t2c_text_length"===e.getInputTargetBlock("A").type&&e.getInputTargetBlock("A").getInputTargetBlock("VALUE")&&"variables_get"===e.getInputTargetBlock("A").getInputTargetBlock("VALUE").type&&"s"===e.getInputTargetBlock("A").getInputTargetBlock("VALUE").getField("VAR").getText()&&e.getInputTargetBlock("B")===i&&"DIVIDE"===e.getFieldValue("OP")})),a=o.getAllBlocks().find((function(e){return"variables_set"===e.type&&e.getNextBlock()===n&&e.getInputTargetBlock("VALUE")===r&&"positionOfSecondMiddleChar"===e.getField("VAR").getText()})),l=o.getAllBlocks().find((function(e){return"math_arithmetic_basic"===e.type&&e.getInputTargetBlock("A")&&"t2c_text_length"===e.getInputTargetBlock("A").type&&e.getInputTargetBlock("A").getInputTargetBlock("VALUE")&&"variables_get"===e.getInputTargetBlock("A").getInputTargetBlock("VALUE").type&&"s"===e.getInputTargetBlock("A").getInputTargetBlock("VALUE").getField("VAR").getText()&&e.getInputTargetBlock("B")&&"math_number"===e.getInputTargetBlock("B").type&&1===e.getInputTargetBlock("B").getFieldValue("NUM")&&"MINUS"===e.getFieldValue("OP")})),s=o.getAllBlocks().find((function(e){return("t2c_text_charat"===e.type||"js_text_charat"===e.type)&&e.getInputTargetBlock("VALUE")&&"variables_get"===e.getInputTargetBlock("VALUE").type&&"s"===e.getInputTargetBlock("VALUE").getField("VAR").getText()&&e.getInputTargetBlock("AT")===l})),u=o.getAllBlocks().find((function(e){return"variables_set"===e.type&&e.getNextBlock()===a&&e.getInputTargetBlock("VALUE")===s&&"lastChar"===e.getField("VAR").getText()})),c=o.getAllBlocks().find((function(e){return"math_number"===e.type&&0===e.getFieldValue("NUM")})),g=o.getAllBlocks().find((function(e){return("t2c_text_charat"===e.type||"js_text_charat"===e.type)&&e.getInputTargetBlock("VALUE")&&"variables_get"===e.getInputTargetBlock("VALUE").type&&"s"===e.getInputTargetBlock("VALUE").getField("VAR").getText()&&e.getInputTargetBlock("AT")===c})),d=o.getAllBlocks().find((function(e){return"variables_set"===e.type&&e.getNextBlock()===u&&e.getInputTargetBlock("VALUE")===g&&"firstChar"===e.getField("VAR").getText()})),h=o.getAllBlocks().find((function(e){return"text"===e.type})),p=o.getAllBlocks().find((function(e){return("text_input"===e.type||"js_text_input"===e.type)&&e.getInputTargetBlock("TEXT")===h})),f=o.getAllBlocks().find((function(e){return"variables_set"===e.type&&e.getNextBlock()===d&&e.getInputTargetBlock("VALUE")===p&&"s"===e.getField("VAR").getText()}));return e&&t&&n&&i&&r&&a&&l&&s&&u&&c&&g&&d&&h&&p&&f}),new s((function(){var e=o.getAllBlocks().find((function(e){return"variables_set"===e.type&&"positionOfFirstMiddleChar"===e.getField("VAR").getText()})),t=o.getAllBlocks().find((function(e){return"variables_set"===e.type&&"positionOfSecondMiddleChar"===e.getField("VAR").getText()})),n=e&&e.getPreviousBlock()&&"variables_set"===e.getPreviousBlock().type&&e.getPreviousBlock().getField("VAR").getText();return e&&e.getNextBlock()&&"variables_set"===e.getNextBlock().type&&e.getNextBlock().getField("VAR").getText(),e&&t&&e.getNextBlock(),!e||n&&"positionOfSecondMiddleChar"===n?"Drag in the type-in-code block, and enter the code needed to calculate the position of the first middle character of the entered string FROM the position of the second middle character and store it in the variable positionOfFirstMiddleChar. Be sure to attach this statement below the one declaring the variable to store the position of the entered string's second middle character.\nThis means you'll be using positionOfFirstMiddleChar and a math operation in your code.\nIf you're not sure what math operation and number to use, consider the positions of the second middle characters and first characters of the following: \nat : 1 | 0\ncode : 2 | 1\npizzas : 3 | 2\nscrabble : 4 | 3":"Make sure to attach this block storing the position of the first middle character below the last one you entered in which you store the position of the second middle character in the variable positionOfSecondMiddleChar."}),{startPosition:F(o,null,{},50,document.getElementById("top-header").offsetHeight+50)}))),n.addTask(new r((function(){return!0}),{start:function(){return!0},isComplete:function(){return!0},animate:function(){return!0},finish:function(){alert("✔ Excellent! So now that we have the positions of the first and second middle characters, let's store the characters themselves, starting with the first middle one."),S(document.getElementById("output-container").querySelectorAll(".table-cell")[0]),M(),N(o),L(o,"type_in_get_first_middle_char"),o.options.maxInstances.type_in_get_first_middle_char=1,o.updateToolbox(document.getElementById("toolbox"))}})),n.addTask(new r((function(){var e=o.getAllBlocks().find((function(e){return"variables_get"===e.type&&"positionOfFirstMiddleChar"===e.getField("VAR").getText()})),t=o.getAllBlocks().find((function(t){return("t2c_text_charat"===t.type||"js_text_charat"===t.type)&&t.getInputTargetBlock("VALUE")&&"variables_get"===t.getInputTargetBlock("VALUE").type&&"s"===t.getInputTargetBlock("VALUE").getField("VAR").getText()&&t.getInputTargetBlock("AT")===e})),n=o.getAllBlocks().find((function(e){return"variables_set"===e.type&&null===e.getNextBlock()&&e.getInputTargetBlock("VALUE")===t&&"firstMiddleChar"===e.getField("VAR").getText()})),i=o.getAllBlocks().find((function(e){return"variables_get"===e.type&&"positionOfSecondMiddleChar"===e.getField("VAR").getText()})),r=o.getAllBlocks().find((function(e){return"math_arithmetic_basic"===e.type&&e.getInputTargetBlock("A")===i&&e.getInputTargetBlock("B")&&"math_number"===e.getInputTargetBlock("B").type&&1===e.getInputTargetBlock("B").getFieldValue("NUM")&&"MINUS"===e.getFieldValue("OP")})),a=o.getAllBlocks().find((function(e){return"variables_set"===e.type&&e.getNextBlock()===n&&e.getInputTargetBlock("VALUE")===r&&"positionOfFirstMiddleChar"===e.getField("VAR").getText()})),l=o.getAllBlocks().find((function(e){return"math_number"===e.type&&2===e.getFieldValue("NUM")})),s=o.getAllBlocks().find((function(e){return"math_arithmetic_basic"===e.type&&e.getInputTargetBlock("A")&&"t2c_text_length"===e.getInputTargetBlock("A").type&&e.getInputTargetBlock("A").getInputTargetBlock("VALUE")&&"variables_get"===e.getInputTargetBlock("A").getInputTargetBlock("VALUE").type&&"s"===e.getInputTargetBlock("A").getInputTargetBlock("VALUE").getField("VAR").getText()&&e.getInputTargetBlock("B")===l&&"DIVIDE"===e.getFieldValue("OP")})),u=o.getAllBlocks().find((function(e){return"variables_set"===e.type&&e.getNextBlock()===a&&e.getInputTargetBlock("VALUE")===s&&"positionOfSecondMiddleChar"===e.getField("VAR").getText()})),c=o.getAllBlocks().find((function(e){return"math_arithmetic_basic"===e.type&&e.getInputTargetBlock("A")&&"t2c_text_length"===e.getInputTargetBlock("A").type&&e.getInputTargetBlock("A").getInputTargetBlock("VALUE")&&"variables_get"===e.getInputTargetBlock("A").getInputTargetBlock("VALUE").type&&"s"===e.getInputTargetBlock("A").getInputTargetBlock("VALUE").getField("VAR").getText()&&e.getInputTargetBlock("B")&&"math_number"===e.getInputTargetBlock("B").type&&1===e.getInputTargetBlock("B").getFieldValue("NUM")&&"MINUS"===e.getFieldValue("OP")})),g=o.getAllBlocks().find((function(e){return("t2c_text_charat"===e.type||"js_text_charat"===e.type)&&e.getInputTargetBlock("VALUE")&&"variables_get"===e.getInputTargetBlock("VALUE").type&&"s"===e.getInputTargetBlock("VALUE").getField("VAR").getText()&&e.getInputTargetBlock("AT")===c})),d=o.getAllBlocks().find((function(e){return"variables_set"===e.type&&e.getNextBlock()===u&&e.getInputTargetBlock("VALUE")===g&&"lastChar"===e.getField("VAR").getText()})),h=o.getAllBlocks().find((function(e){return"math_number"===e.type&&0==e.getFieldValue("NUM")})),p=o.getAllBlocks().find((function(e){return("t2c_text_charat"===e.type||"js_text_charat"===e.type)&&e.getInputTargetBlock("VALUE")&&"variables_get"===e.getInputTargetBlock("VALUE").type&&"s"===e.getInputTargetBlock("VALUE").getField("VAR").getText()&&e.getInputTargetBlock("AT")===h})),f=o.getAllBlocks().find((function(e){return"variables_set"===e.type&&e.getNextBlock()===d&&e.getInputTargetBlock("VALUE")===p&&"firstChar"===e.getField("VAR").getText()})),m=o.getAllBlocks().find((function(e){return"text"===e.type})),y=o.getAllBlocks().find((function(e){return("text_input"===e.type||"js_text_input"===e.type)&&e.getInputTargetBlock("TEXT")===m})),T=o.getAllBlocks().find((function(e){return"variables_set"===e.type&&e.getNextBlock()===f&&e.getInputTargetBlock("VALUE")===y&&"s"===e.getField("VAR").getText()}));return e&&t&&n&&i&&r&&a&&l&&s&&u&&c&&g&&d&&h&&p&&f&&m&&y&&T}),new s((function(){var e=o.getAllBlocks().find((function(e){return"variables_set"===e.type&&"positionOfFirstMiddleChar"===e.getField("VAR").getText()})),t=o.getAllBlocks().find((function(e){return"variables_set"===e.type&&"firstMiddleChar"===e.getField("VAR").getText()})),n=t&&t.getPreviousBlock()&&"variables_set"===t.getPreviousBlock().type&&t.getPreviousBlock().getField("VAR").getText();return t&&t.getNextBlock()&&"variables_set"===t.getNextBlock().type&&t.getNextBlock().getField("VAR").getText(),t&&e&&t.getNextBlock(),!t||n&&"positionOfFirstMiddleChar"===n?"Drag in the type-in-code block and enter the code needed to get the first middle character of the entered string from its position and store it in the variable firstMiddleChar. Be sure to attach this statement below the one declaring the variable to store the position of the entered string's first middle character.":"Make sure to attach this block storing the first middle character below the last one you entered in which you store its position in the variable positionOfFirstMiddleChar."}),{startPosition:F(o,null,{},50,document.getElementById("top-header").offsetHeight+50)}))),n.addTask(new r((function(){return"js"===document.getElementById("language").value||"py"===document.getElementById("language").value}),{start:function(){var e=document.getElementById("language").value;alert("✔ Excellent x 2! So now it's time to store the 2nd middle character. "+("js"===e||"py"===e?"":"But let's type this using pure JavaScript or Python. Select JavaScript or Python and watch how the declaration for the firstMiddleChar translates for reference."))},isComplete:function(){return!0},animate:function(){return!0},finish:function(){S(document.getElementById("output-container").querySelectorAll(".table-cell")[0]),M(),N(o),L(o,"type_in_get_second_middle_char"),o.options.maxInstances.type_in_get_second_middle_char=1,o.updateToolbox(document.getElementById("toolbox"))}})),n.addTask(new r((function(){var e=o.getAllBlocks().find((function(e){return("t2c_text_charat"===e.type||"js_text_charat"===e.type)&&e.getInputTargetBlock("VALUE")&&"variables_get"===e.getInputTargetBlock("VALUE").type&&"s"===e.getInputTargetBlock("VALUE").getField("VAR").getText()&&e.getInputTargetBlock("AT")&&"variables_get"===e.getInputTargetBlock("AT").type&&"positionOfSecondMiddleChar"===e.getInputTargetBlock("AT").getField("VAR").getText()})),t=o.getAllBlocks().find((function(t){return"variables_set"===t.type&&null===t.getNextBlock()&&t.getInputTargetBlock("VALUE")===e&&"secondMiddleChar"===t.getField("VAR").getText()})),n=o.getAllBlocks().find((function(e){return"variables_get"===e.type&&"positionOfFirstMiddleChar"===e.getField("VAR").getText()})),i=o.getAllBlocks().find((function(e){return("t2c_text_charat"===e.type||"js_text_charat"===e.type)&&e.getInputTargetBlock("VALUE")&&"variables_get"===e.getInputTargetBlock("VALUE").type&&"s"===e.getInputTargetBlock("VALUE").getField("VAR").getText()&&e.getInputTargetBlock("AT")===n})),r=o.getAllBlocks().find((function(e){return"variables_set"===e.type&&e.getNextBlock()===t&&e.getInputTargetBlock("VALUE")===i&&"firstMiddleChar"===e.getField("VAR").getText()})),a=o.getAllBlocks().find((function(e){return"math_arithmetic_basic"===e.type&&e.getInputTargetBlock("A")&&"variables_get"===e.getInputTargetBlock("A").type&&"positionOfSecondMiddleChar"===e.getInputTargetBlock("A").getField("VAR").getText()&&e.getInputTargetBlock("B")&&"math_number"===e.getInputTargetBlock("B").type&&1===e.getInputTargetBlock("B").getFieldValue("NUM")&&"MINUS"===e.getFieldValue("OP")})),l=o.getAllBlocks().find((function(e){return"variables_set"===e.type&&e.getNextBlock()===r&&e.getInputTargetBlock("VALUE")===a&&"positionOfFirstMiddleChar"===e.getField("VAR").getText()})),s=o.getAllBlocks().find((function(e){return"math_number"===e.type&&2===e.getFieldValue("NUM")})),u=o.getAllBlocks().find((function(e){return"math_arithmetic_basic"===e.type&&e.getInputTargetBlock("A")&&"t2c_text_length"===e.getInputTargetBlock("A").type&&e.getInputTargetBlock("A").getInputTargetBlock("VALUE")&&"variables_get"===e.getInputTargetBlock("A").getInputTargetBlock("VALUE").type&&"s"===e.getInputTargetBlock("A").getInputTargetBlock("VALUE").getField("VAR").getText()&&e.getInputTargetBlock("B")===s&&"DIVIDE"===e.getFieldValue("OP")})),c=o.getAllBlocks().find((function(e){return"variables_set"===e.type&&e.getNextBlock()===l&&e.getInputTargetBlock("VALUE")===u&&"positionOfSecondMiddleChar"===e.getField("VAR").getText()})),g=o.getAllBlocks().find((function(e){return"math_arithmetic_basic"===e.type&&e.getInputTargetBlock("A")&&"t2c_text_length"===e.getInputTargetBlock("A").type&&e.getInputTargetBlock("A").getInputTargetBlock("VALUE")&&"variables_get"===e.getInputTargetBlock("A").getInputTargetBlock("VALUE").type&&"s"===e.getInputTargetBlock("A").getInputTargetBlock("VALUE").getField("VAR").getText()&&e.getInputTargetBlock("B")&&"math_number"===e.getInputTargetBlock("B").type&&1===e.getInputTargetBlock("B").getFieldValue("NUM")&&"MINUS"===e.getFieldValue("OP")})),d=o.getAllBlocks().find((function(e){return("t2c_text_charat"===e.type||"js_text_charat"===e.type)&&e.getInputTargetBlock("VALUE")&&"variables_get"===e.getInputTargetBlock("VALUE").type&&"s"===e.getInputTargetBlock("VALUE").getField("VAR").getText()&&e.getInputTargetBlock("AT")===g})),h=o.getAllBlocks().find((function(e){return"variables_set"===e.type&&e.getNextBlock()===c&&e.getInputTargetBlock("VALUE")===d&&"lastChar"===e.getField("VAR").getText()})),p=o.getAllBlocks().find((function(e){return"math_number"===e.type&&0===e.getFieldValue("NUM")})),f=o.getAllBlocks().find((function(e){return("t2c_text_charat"===e.type||"js_text_charat"===e.type)&&e.getInputTargetBlock("VALUE")&&"variables_get"===e.getInputTargetBlock("VALUE").type&&"s"===e.getInputTargetBlock("VALUE").getField("VAR").getText()&&e.getInputTargetBlock("AT")===p})),m=o.getAllBlocks().find((function(e){return"variables_set"===e.type&&e.getNextBlock()===h&&e.getInputTargetBlock("VALUE")===f&&"firstChar"===e.getField("VAR").getText()})),y=o.getAllBlocks().find((function(e){return"text"===e.type})),T=o.getAllBlocks().find((function(e){return("text_input"===e.type||"js_text_input"===e.type)&&e.getInputTargetBlock("TEXT")===y})),_=o.getAllBlocks().find((function(e){return"variables_set"===e.type&&e.getNextBlock()===m&&e.getInputTargetBlock("VALUE")===T&&"s"===e.getField("VAR").getText()}));return e&&t&&n&&i&&r&&a&&l&&s&&u&&c&&g&&d&&h&&p&&f&&m&&y&&T&&_}),new s((function(){var e=o.getAllBlocks().find((function(e){return"variables_set"===e.type&&"secondMiddleChar"===e.getField("VAR").getText()})),t=e&&e.getPreviousBlock()&&"variables_set"===e.getPreviousBlock().type&&e.getPreviousBlock().getField("VAR").getText();return e&&e.getNextBlock()&&"variables_set"===e.getNextBlock().type&&e.getNextBlock().getField("VAR").getText(),!e||t&&"firstMiddleChar"===t?"Drag in the type-in-code block and enter the code needed to get the second middle character of the entered string from its position and store it in the variable secondMiddleChar. Do this in "+T2C.MSG.currentLanguage.LANGUAGE_NAME+" by adapting the code from the last blocks assembled to get the first middle character. Be sure to attach this statement below the one declaring the variable to store the entered string's first middle character.":"Make sure to attach this block storing the second middle character below the last one you entered in which you store the user's first middle character in the variable firstMiddleChar."}),{startPosition:F(o,null,{},50,document.getElementById("top-header").offsetHeight+50)}))),n.addTask(new r((function(){return!0}),{start:function(){return!0},isComplete:function(){return!0},animate:function(){return!0},finish:function(){alert("✔ Excellent x 3! So now for the grand finale: we need to put all of these characters together and display them on one line. Do you remember how to do that? Also, let's include the full string the user enters at the beginning because our users can be forgetful!\n So for an input of SCRABBLE, we'd want the output to be as follows: \nSCRABBLE: SEAB"),S(document.getElementById("output-container").querySelectorAll(".table-cell")[0]),M(),N(o),L(o,"type_in_combine_first_last_middle2_chars"),o.options.maxInstances.type_in_combine_first_last_middle2_chars=1,o.updateToolbox(document.getElementById("toolbox"))}})),n.addTask(new r((function(){var e=o.getAllBlocks().find((function(e){return"variables_get"===e.type&&"secondMiddleChar"===e.getField("VAR").getText()})),t=o.getAllBlocks().find((function(e){return"variables_get"===e.type&&"firstMiddleChar"===e.getField("VAR").getText()})),n=o.getAllBlocks().find((function(n){return"t2c_text_join"===n.type&&n.getInputTargetBlock("A")===t&&n.getInputTargetBlock("B")===e})),i=o.getAllBlocks().find((function(e){return"variables_get"===e.type&&"lastChar"===e.getField("VAR").getText()})),r=o.getAllBlocks().find((function(e){return"t2c_text_join"===e.type&&e.getInputTargetBlock("A")===i&&e.getInputTargetBlock("B")===n})),a=o.getAllBlocks().find((function(e){return"variables_get"===e.type&&"firstChar"===e.getField("VAR").getText()})),l=o.getAllBlocks().find((function(e){return"t2c_text_join"===e.type&&e.getInputTargetBlock("A")===a&&e.getInputTargetBlock("B")===r})),s=o.getAllBlocks().find((function(e){return"text"===e.type&&": "===e.getFieldValue("TEXT")})),u=o.getAllBlocks().find((function(e){return"t2c_text_join"===e.type&&e.getInputTargetBlock("A")===s&&e.getInputTargetBlock("B")===l})),c=o.getAllBlocks().find((function(e){return"t2c_text_join"===e.type&&e.getInputTargetBlock("A")&&"variables_get"===e.getInputTargetBlock("A").type&&"s"===e.getInputTargetBlock("A").getField("VAR").getText()&&e.getInputTargetBlock("B")===u})),g=o.getAllBlocks().find((function(e){return("text_print"===e.type||"js_text_print"===e.type)&&null===e.getNextBlock()&&e.getInputTargetBlock("TEXT")===c})),d=o.getAllBlocks().find((function(e){return("t2c_text_charat"===e.type||"js_text_charat"===e.type)&&e.getInputTargetBlock("VALUE")&&"variables_get"===e.getInputTargetBlock("VALUE").type&&"s"===e.getInputTargetBlock("VALUE").getField("VAR").getText()&&e.getInputTargetBlock("AT")&&"variables_get"===e.getInputTargetBlock("AT").type&&"positionOfSecondMiddleChar"===e.getInputTargetBlock("AT").getField("VAR").getText()})),h=o.getAllBlocks().find((function(e){return"variables_set"===e.type&&e.getNextBlock()===g&&e.getInputTargetBlock("VALUE")===d&&"secondMiddleChar"===e.getField("VAR").getText()})),p=o.getAllBlocks().find((function(e){return"variables_get"===e.type&&"positionOfFirstMiddleChar"===e.getField("VAR").getText()})),f=o.getAllBlocks().find((function(e){return("t2c_text_charat"===e.type||"js_text_charat"===e.type)&&e.getInputTargetBlock("VALUE")&&"variables_get"===e.getInputTargetBlock("VALUE").type&&"s"===e.getInputTargetBlock("VALUE").getField("VAR").getText()&&e.getInputTargetBlock("AT")===p})),m=o.getAllBlocks().find((function(e){return"variables_set"===e.type&&e.getNextBlock()===h&&e.getInputTargetBlock("VALUE")===f&&"firstMiddleChar"===e.getField("VAR").getText()})),y=o.getAllBlocks().find((function(e){return"math_arithmetic_basic"===e.type&&e.getInputTargetBlock("A")&&"variables_get"===e.getInputTargetBlock("A").type&&"positionOfSecondMiddleChar"===e.getInputTargetBlock("A").getField("VAR").getText()&&e.getInputTargetBlock("B")&&"math_number"===e.getInputTargetBlock("B").type&&1===e.getInputTargetBlock("B").getFieldValue("NUM")&&"MINUS"===e.getFieldValue("OP")})),T=o.getAllBlocks().find((function(e){return"variables_set"===e.type&&e.getNextBlock()===m&&e.getInputTargetBlock("VALUE")===y&&"positionOfFirstMiddleChar"===e.getField("VAR").getText()})),_=o.getAllBlocks().find((function(e){return"math_number"===e.type&&2===e.getFieldValue("NUM")})),b=o.getAllBlocks().find((function(e){return"math_arithmetic_basic"===e.type&&e.getInputTargetBlock("A")&&"t2c_text_length"===e.getInputTargetBlock("A").type&&e.getInputTargetBlock("A").getInputTargetBlock("VALUE")&&"variables_get"===e.getInputTargetBlock("A").getInputTargetBlock("VALUE").type&&"s"===e.getInputTargetBlock("A").getInputTargetBlock("VALUE").getField("VAR").getText()&&e.getInputTargetBlock("B")===_&&"DIVIDE"===e.getFieldValue("OP")})),k=o.getAllBlocks().find((function(e){return"variables_set"===e.type&&e.getNextBlock()===T&&e.getInputTargetBlock("VALUE")===b&&"positionOfSecondMiddleChar"===e.getField("VAR").getText()})),x=o.getAllBlocks().find((function(e){return"math_arithmetic_basic"===e.type&&e.getInputTargetBlock("A")&&"t2c_text_length"===e.getInputTargetBlock("A").type&&e.getInputTargetBlock("A").getInputTargetBlock("VALUE")&&"variables_get"===e.getInputTargetBlock("A").getInputTargetBlock("VALUE").type&&"s"===e.getInputTargetBlock("A").getInputTargetBlock("VALUE").getField("VAR").getText()&&e.getInputTargetBlock("B")&&"math_number"===e.getInputTargetBlock("B").type&&1===e.getInputTargetBlock("B").getFieldValue("NUM")&&"MINUS"===e.getFieldValue("OP")})),E=o.getAllBlocks().find((function(e){return("t2c_text_charat"===e.type||"js_text_charat"===e.type)&&e.getInputTargetBlock("VALUE")&&"variables_get"===e.getInputTargetBlock("VALUE").type&&"s"===e.getInputTargetBlock("VALUE").getField("VAR").getText()&&e.getInputTargetBlock("AT")===x})),B=o.getAllBlocks().find((function(e){return"variables_set"===e.type&&e.getNextBlock()===k&&e.getInputTargetBlock("VALUE")===E&&"lastChar"===e.getField("VAR").getText()})),A=o.getAllBlocks().find((function(e){return"math_number"===e.type&&0===e.getFieldValue("NUM")})),v=o.getAllBlocks().find((function(e){return("t2c_text_charat"===e.type||"js_text_charat"===e.type)&&e.getInputTargetBlock("VALUE")&&"variables_get"===e.getInputTargetBlock("VALUE").type&&"s"===e.getInputTargetBlock("VALUE").getField("VAR").getText()&&e.getInputTargetBlock("AT")===A})),I=o.getAllBlocks().find((function(e){return"variables_set"===e.type&&e.getNextBlock()===B&&e.getInputTargetBlock("VALUE")===v&&"firstChar"===e.getField("VAR").getText()})),w=o.getAllBlocks().find((function(e){return"text"===e.type})),S=o.getAllBlocks().find((function(e){return("text_input"===e.type||"js_text_input"===e.type)&&e.getInputTargetBlock("TEXT")===w})),M=o.getAllBlocks().find((function(e){return"variables_set"===e.type&&e.getNextBlock()===I&&e.getInputTargetBlock("VALUE")===S&&"s"===e.getField("VAR").getText()}));return e&&t&&n&&i&&r&&a&&l&&s&&u&&c&&g&&d&&h&&p&&f&&m&&y&&T&&_&&b&&k&&x&&E&&B&&A&&v&&I&&w&&S&&M}),new s((function(){var e=o.getAllBlocks().find((function(e){return"text_print"===e.type||"js_text_print"===e.type})),t=(o.getAllBlocks().find((function(t){return"variables_set"===t.type&&t.getNextBlock()===e&&"secondMiddleChar"===t.getField("VAR").getText()})),e&&e.getPreviousBlock()&&"variables_set"===e.getPreviousBlock().type&&e.getPreviousBlock().getField("VAR").getText()),n=e&&e.getNextBlock()&&"variables_set"===e.getNextBlock().type&&e.getNextBlock().getField("VAR").getText();return e&&!t?"Make sure to attach this block displaying the entered string and its first, last, and first and second middle characters below the last one you entered in which you store the user's second middle character in the variable secondMiddleChar.":n?"Make sure to attach this block displaying the entered string and its first, last, and first and second middle characters below the last one you entered in which you store the user's second middle character in the variable secondMiddleChar. Since instructions are run top to bottom, if you place this before the block you did, the computer wouldn't know what "+(n.startsWith("positionOf")?n.substring(10):n)+" means!":'Drag in the type-in-code block and place it below the block that stores the second character in a variable. Enter code to display the user entered string, followed by the string literal ": " followed by its first character, then its last character, then its first middle character, and finally its second middle character.\n So for an input of SCRABBLE, we\'d want the output to be as follows: \nSCRABBLE: SEAB'}),{startPosition:F(o,null,{},50,document.getElementById("top-header").offsetHeight+50)}))),function(e){e.addTask(new r((function(){return document.getElementById("output-container").classList.contains("show-container")}),new u([new s((function(){return T2C.MSG.currentLanguage.BUTTON_RUN_CODE}),{startPosition:{x:document.getElementById("run-code-button").offsetLeft+document.getElementById("run-code-button").offsetWidth,y:document.getElementById("run-code-button").offsetTop+document.getElementById("run-code-button").offsetHeight}}),new l(h,{totalSteps:100,toggleSteps:25,startPosition:{x:document.getElementById("run-code-button").offsetLeft+document.getElementById("run-code-button").offsetWidth/2,y:document.getElementById("run-code-button").offsetTop+document.getElementById("run-code-button").offsetHeight/2}})])))}(n),function(e,t){var n=0;function o(){t.style.color=n%50<25?"#a00":"#000",++n<200&&requestAnimationFrame(o)}e.addTask(new r((function(){return n>=200}),{start:function(){t.style.verticalAlign="top",requestAnimationFrame(o)},isComplete:function(){return!0},animate:function(){return!0}}))}(n,document.getElementById("output-container").querySelectorAll(".table-cell")[0]),n.addTask(new r((function(){return!0}),{start:function(){return!0},isComplete:function(){return!0},animate:function(){return!0},finish:function(){alert("✔✔✔ Congratulations! You just completed the challenging Mission 3! Take a moment to bask in your accomplishments! Not only did you solve the problem yourself, you also proved to be an excellent teacher! You managed to explain to the computer how it could solve the problem as well in a language it could understand. This meant you were also perfect in your grammar, spelling everything correctly and placing every parenthesis and period where it needed to go, making your English teachers proud!\nIn Mission 4, we'll introduce a new block that'll allow you to get *all* the characters from a starting position to an ending one (rather than just getting one character at a time). We'll then use this block to display a string with its initial character removed. Until next time!"),S(document.getElementById("output-container").querySelectorAll(".table-cell")[0]),M(),N(o),L(o,"code_statement"),o.options.maxInstances.code_statement=1,o.updateToolbox(document.getElementById("toolbox"))}})),n},function(e,t){var n=e||new c;alert("In previous missions, you'd use "+T2C.MSG.currentLanguage.TERMINAL_GETCHARACTERNUMBER+" to get a *single* character at a given numerical position in a string. In this mission, you'll be using a new block "+T2C.MSG.EN.TERMINAL_GETTEXTFROM+" to display all characters between given starting and ending numerical positions.");var o=t||Blockly.getMainWorkspace();D(o),["t2c_text_getsubstring","text_print","variables_get","math_number","text","variables_set"].forEach((function(e,t){W(o,e,!1),o.options.maxInstances[e]=3===t?2:1})),o.clear();var a=Object(i.e)(o,"text"),g=Object(i.e)(o,"variables_set");Object(i.h)(a,"aap kaise hain?","TEXT"),Object(i.j)(g,"VALUE",a),Object(i.h)(g,"welcomeMsg","VAR"),o.setScale(1),Object(i.f)(o),Array.from(document.querySelectorAll("rect")).filter((function(e){return e.getAttribute("fill-opacity")}));var d=document.createElement("div");function h(e){e.addTask(new r((function(){return document.getElementById("output-container").classList.contains("show-container")}),new u([new s((function(){return T2C.MSG.currentLanguage.BUTTON_RUN_CODE}),{startPosition:{x:document.getElementById("run-code-button").offsetLeft+document.getElementById("run-code-button").offsetWidth,y:document.getElementById("run-code-button").offsetTop+document.getElementById("run-code-button").offsetHeight}}),new l(d,{totalSteps:100,toggleSteps:25,startPosition:{x:document.getElementById("run-code-button").offsetLeft+document.getElementById("run-code-button").offsetWidth/2,y:document.getElementById("run-code-button").offsetTop+document.getElementById("run-code-button").offsetHeight/2}})])))}function p(e,t){var n=0;function o(){t.style.color=n%50<25?"#a00":"#000",++n<200&&requestAnimationFrame(o)}e.addTask(new r((function(){return n>=200}),{start:function(){t.style.verticalAlign="top",requestAnimationFrame(o)},isComplete:function(){return!0},animate:function(){return!0}}))}return d.innerText="👆",d.id="ptr",d.style.fontSize="x-large",d.style.position="absolute",d.style.zIndex="1001",document.getElementById("blockly-div").appendChild(d),n.addTask(new r((function(){var e=o.getAllBlocks().find((function(e){return"math_number"===e.type&&9===e.getFieldValue("NUM")})),t=o.getAllBlocks().find((function(e){return"math_number"===e.type&&4===e.getFieldValue("NUM")})),n=o.getAllBlocks().find((function(e){return"variables_get"===e.type&&"welcomeMsg"===e.getField("VAR").getText()})),i=o.getAllBlocks().find((function(o){return("t2c_text_getsubstring"===o.type||"js_text_getsubstring"===o.type)&&o.getInputTargetBlock("STRING")===n&&o.getInputTargetBlock("AT1")===t&&o.getInputTargetBlock("AT2")===e})),r=o.getAllBlocks().find((function(e){return("text_print"===e.type||"js_text_print"===e.type)&&null===e.getNextBlock()&&e.getInputTargetBlock("TEXT")===i})),a=o.getAllBlocks().find((function(e){return"text"===e.type&&"aap kaise hain?"==e.getFieldValue("TEXT")})),l=o.getAllBlocks().find((function(e){return"variables_set"===e.type&&e.getNextBlock()===r&&e.getInputTargetBlock("VALUE")===a&&"welcomeMsg"===e.getField("VAR").getText()}));return e&&t&&n&&i&&r&&a&&l}),new s((function(){var e=o.getAllBlocks().find((function(e){return"math_number"===e.type})),t=o.getAllBlocks().find((function(t){return"math_number"===t.type&&t!==e})),n=o.getAllBlocks().find((function(e){return"variables_get"===e.type})),i=o.getAllBlocks().find((function(e){return"t2c_text_getsubstring"===e.type||"js_text_getsubstring"===e.type})),r=o.getAllBlocks().find((function(e){return"text_print"===e.type||"js_text_print"===e.type})),a=o.getAllBlocks().find((function(e){return"text"===e.type})),l=o.getAllBlocks().find((function(e){return"variables_set"===e.type}));if(i&&(i.getInputTargetBlock("AT1")===e||i.getInputTargetBlock("AT1")===t)){var s=i.getInputTargetBlock("AT1").getFieldValue("NUM");if(5===s)return"The given starting position is incorrect. Remember that the initial character starts at position (index) 0 and unlike the given ending position to "+T2C.MSG.currentLanguage.TERMINAL_GETTEXTFROMPOSITIONNUMBER+", the computer starts extracting text from the first position number you give it.";if(3===s)return"The given starting position is incorrect. Remember that the initial character starts at position (index) 0 and that spaces are characters as well.";if(9===s)return"The given starting position is incorrect. The first number given to "+T2C.MSG.currentLanguage.TERMINAL_GETTEXTFROMPOSITIONNUMBER+" is the starting position, not the ending one.";if(4!==s)return"Incorrect number for the starting position. Please try recounting the characters from the beginning of the string, starting from 0 and include spaces in your count."}if(i&&(i.getInputTargetBlock("AT2")===e||i.getInputTargetBlock("AT2")===t)){var u=i.getInputTargetBlock("AT2").getFieldValue("NUM");if(8===u)return"The given ending position is incorrect. Remember to count spaces and unlike the given starting position to "+T2C.MSG.currentLanguage.TERMINAL_GETTEXTFROMPOSITIONNUMBER+", the computer stops extracting text *one place before* the second number you give it.";if(4===u)return"The given ending position is incorrect. The second number given to "+T2C.MSG.currentLanguage.TERMINAL_GETTEXTFROMPOSITIONNUMBER+" is the ending position, not the starting one.";if(9!==u)return"Incorrect number for the ending position. Please try recounting the characters from the beginning of the string, starting from 0 and include spaces in your count."}return l&&"welcomeMsg"!==l.getField("VAR").getText()?"Make sure you keep the variable name for the "+T2C.MSG.currentLanguage.TERMINAL_LET+"block as it was; it should be welcomeMsg.":l&&l.getInputTargetBlock("VALUE")!==a?"Keep the text block with the text aap kaise hain? inside the "+T2C.MSG.currentLanguage.TERMINAL_LET+" variable block. When using the "+T2C.MSG.currentLanguage.TERMINAL_GETTEXTFROMPOSITIONNUMBER+" block, refer to the variable welcomeMsg.":"aap kaise hain?"!==a.getFieldValue("TEXT")?"Make sure to leave the text aap kaise hain? for the text block.":n&&"welcomeMsg"!==n.getField("VAR").getText()?"Make sure you use the variable name welcomeMsg for the variable get block so that it refers to the value assigned to the variable.":i&&n&&i.getInputTargetBlock("STRING")!==n?"Make sure to place the variable with the string's value inside the left space of the "+T2C.MSG.currentLanguage.TERMINAL_GETTEXTFROMPOSITIONNUMBER+" so the computer knows which string to extract the substring from.":i&&n&&(i.getInputTargetBlock("A")===n||i.getInputTargetBlock("B")===n)?"The variable which holds the text to get the string from should go inside the left space of the "+T2C.MSG.currentLanguage.TERMINAL_GETTEXTFROMPOSITIONNUMBER+" block. The other spaces are for the *numbers* of the starting and ending positions from where to extract the text.":r&&i&&r.getInputTargetBlock("TEXT")!==i?"You want to display the result of extracting text from welcomeMsg so you should use the "+T2C.MSG.currentLanguage.TERMINAL_GETTEXTFROMPOSITIONNUMBER+" block inside of the "+T2C.MSG.currentLanguage.TERMINAL_DISPLAY+" block.":r&&l&&r.getNextBlock()===l?"The "+T2C.MSG.currentLanguage.TERMINAL_DISPLAY+" block should go below the "+T2C.MSG.currentLanguage.TERMINAL_LET+" variable block so the computer knows what welcomeMsg is when attempting to extract text from it. Remember that statements are run from top to bottom.":r&&null!==r.getNextBlock()?"The next statement above the "+T2C.MSG.currentLanguage.TERMINAL_DISPLAY+" block is incorrect.":r&&l&&l.getNextBlock()!==r?"Place the "+T2C.MSG.currentLanguage.TERMINAL_DISPLAY+" block below the "+T2C.MSG.currentLanguage.TERMINAL_LET+" variable declaration block.":"Drag in and assemble the blocks from the toolbox to get the text kaise (without spaces) from aap kaise hain? Do NOT change the existing ones.\nTo do this, use the new "+T2C.MSG.currentLanguage.TERMINAL_GETTEXTFROMPOSITIONNUMBER+" block, which takes a string, the position to start getting text from, and the position to stop at (NOTE: IT WILL STOP 1 BEFORE THE second number.)\nIn case you were curious, aap kaise hain? is the polite formal way to ask 'how are you?' in Hindi, literally, 'you (aap) how (kaise) are (hain)?'"}),{startPosition:q(o,null,{},50,document.getElementById("top-header").offsetHeight+50)}))),h(n),p(n,document.getElementById("output-container").querySelectorAll(".table-cell")[0]),n.addTask(new r((function(){return!0}),{start:function(){return!0},isComplete:function(){return!0},animate:function(){return!0},finish:function(){alert("👍 Nice! So now let's try another example with the new block, but let's type it! This time, you'll display everything except the string's initial character. So we'll want to display ap kaise hain?"),X(document.getElementById("output-container").querySelectorAll(".table-cell")[0]),j(),W(o,"type_in_all_but_first_specific_str"),o.options.maxInstances.type_in_all_but_first_specific_str=1,o.updateToolbox(document.getElementById("toolbox"))}})),n.addTask(new r((function(){var e=o.getAllBlocks().find((function(e){return"math_number"===e.type&&15===e.getFieldValue("NUM")})),t=o.getAllBlocks().find((function(e){return"math_number"===e.type&&1===e.getFieldValue("NUM")})),n=o.getAllBlocks().filter((function(e){return"variables_get"===e.type&&"welcomeMsg"===e.getField("VAR").getText()})),i=o.getAllBlocks().find((function(o){return("t2c_text_getsubstring"===o.type||"js_text_getsubstring"===o.type)&&-1!==n.indexOf(o.getInputTargetBlock("STRING"))&&o.getInputTargetBlock("AT1")===t&&o.getInputTargetBlock("AT2")===e})),r=o.getAllBlocks().find((function(e){return("text_print"===e.type||"js_text_print"===e.type)&&null===e.getNextBlock()&&e.getInputTargetBlock("TEXT")===i})),a=o.getAllBlocks().find((function(e){return"math_number"===e.type&&9===e.getFieldValue("NUM")})),l=o.getAllBlocks().find((function(e){return"math_number"===e.type&&4===e.getFieldValue("NUM")})),s=o.getAllBlocks().find((function(e){return("t2c_text_getsubstring"===e.type||"js_text_getsubstring"===e.type)&&-1!==n.indexOf(e.getInputTargetBlock("STRING"))&&e.getInputTargetBlock("AT1")===l&&e.getInputTargetBlock("AT2")===a})),u=o.getAllBlocks().find((function(e){return("text_print"===e.type||"js_text_print"===e.type)&&e.getNextBlock()===r&&e.getInputTargetBlock("TEXT")===s})),c=o.getAllBlocks().find((function(e){return"text"===e.type&&"aap kaise hain?"==e.getFieldValue("TEXT")})),g=o.getAllBlocks().find((function(e){return"variables_set"===e.type&&e.getNextBlock()===u&&e.getInputTargetBlock("VALUE")===c&&"welcomeMsg"===e.getField("VAR").getText()}));return e&&t&&n&&i&&r&&a&&l&&s&&u&&c&&g}),new s((function(){var e=o.getAllBlocks().find((function(e){return"math_number"===e.type&&15===e.getFieldValue("NUM")})),t=o.getAllBlocks().find((function(e){return"math_number"===e.type&&1===e.getFieldValue("NUM")})),n=o.getAllBlocks().filter((function(e){return"variables_get"===e.type&&"welcomeMsg"===e.getField("VAR").getText()})),i=o.getAllBlocks().find((function(o){return("t2c_text_getsubstring"===o.type||"js_text_getsubstring"===o.type)&&-1!==n.indexOf(o.getInputTargetBlock("STRING"))&&o.getInputTargetBlock("AT1")===t&&o.getInputTargetBlock("AT2")===e})),r=o.getAllBlocks().find((function(e){return("text_print"===e.type||"js_text_print"===e.type)&&e.getInputTargetBlock("TEXT")===i})),a=o.getAllBlocks().find((function(e){return"math_number"===e.type&&9===e.getFieldValue("NUM")})),l=o.getAllBlocks().find((function(e){return"math_number"===e.type&&4===e.getFieldValue("NUM")})),s=o.getAllBlocks().find((function(e){return("t2c_text_getsubstring"===e.type||"js_text_getsubstring"===e.type)&&-1!==n.indexOf(e.getInputTargetBlock("STRING"))&&e.getInputTargetBlock("AT1")===l&&e.getInputTargetBlock("AT2")===a})),u=o.getAllBlocks().find((function(e){return("text_print"===e.type||"js_text_print"===e.type)&&e.getInputTargetBlock("TEXT")===s})),c=o.getAllBlocks().find((function(e){return"text"===e.type&&"aap kaise hain?"==e.getFieldValue("TEXT")})),g=o.getAllBlocks().find((function(e){return"variables_set"===e.type&&e.getInputTargetBlock("VALUE")===c&&"welcomeMsg"===e.getField("VAR").getText()}));return r&&g&&r.getNextBlock()===g?"The "+T2C.MSG.currentLanguage.TERMINAL_DISPLAY+" block should go below the "+T2C.MSG.currentLanguage.TERMINAL_LET+" variable block so the computer knows what welcomeMsg is when attempting to extract text from it. Remember that statements are run from top to bottom.":r&&u&&u.getNextBlock()!==r?"Place the new "+T2C.MSG.currentLanguage.TERMINAL_DISPLAY+" block that's used to display all characters beyond the initial one below the previous "+T2C.MSG.currentLanguage.TERMINAL_DISPLAY+" block used to display kaise.":"Drag in the type-in code block from the toolbox and type in the code necessary to display all the characters except the initial one from aap kaise hain? As before, use "+T2C.MSG.currentLanguage.TERMINAL_GETTEXTFROMPOSITIONNUMBER+", the variable welcomeMsg, and 2 specific numbers for the starting and ending positions. We'll generalize this so it works for other strings next. Place this new block below the previous "+T2C.MSG.currentLanguage.TERMINAL_DISPLAY+"."}),{startPosition:q(o,null,{},50,document.getElementById("top-header").offsetHeight+50)}))),h(n),p(n,document.getElementById("output-container").querySelectorAll(".table-cell")[0]),n.addTask(new r((function(){return!0}),{start:function(){return!0},isComplete:function(){return!0},animate:function(){return!0},finish:function(){alert("👍 Good! So of course this is not a very useful program as we could've just displayed two lines of text 'kaise' and 'ap kaise hain?' and the user would not know the difference. So now let's show the usefulness of the new "+T2C.MSG.currentLanguage.TERMINAL_GETTEXTFROMPOSITIONNUMBER+" by instead using the string literal 'aap kaise hain?' as our message to get input from the user instead. Then our user can respond with something like theek (fine) or bahut acchaa (very good)."),X(document.getElementById("output-container").querySelectorAll(".table-cell")[0]),j(),W(o,"text_input"),o.options.maxInstances.text_input=1,o.options.maxInstances.type_in_all_but_first_specific_str=0,o.updateToolbox(document.getElementById("toolbox"))}})),n.addTask(new r((function(){var e=o.getAllBlocks().find((function(e){return"math_number"===e.type&&15===e.getFieldValue("NUM")})),t=o.getAllBlocks().find((function(e){return"math_number"===e.type&&1===e.getFieldValue("NUM")})),n=o.getAllBlocks().filter((function(e){return"variables_get"===e.type&&"response"===e.getField("VAR").getText()})),i=o.getAllBlocks().find((function(o){return("t2c_text_getsubstring"===o.type||"js_text_getsubstring"===o.type)&&-1!==n.indexOf(o.getInputTargetBlock("STRING"))&&o.getInputTargetBlock("AT1")===t&&o.getInputTargetBlock("AT2")===e})),r=o.getAllBlocks().find((function(e){return("text_print"===e.type||"js_text_print"===e.type)&&null===e.getNextBlock()&&e.getInputTargetBlock("TEXT")===i})),a=o.getAllBlocks().find((function(e){return"math_number"===e.type&&9===e.getFieldValue("NUM")})),l=o.getAllBlocks().find((function(e){return"math_number"===e.type&&4===e.getFieldValue("NUM")})),s=o.getAllBlocks().find((function(e){return("t2c_text_getsubstring"===e.type||"js_text_getsubstring"===e.type)&&-1!==n.indexOf(e.getInputTargetBlock("STRING"))&&e.getInputTargetBlock("AT1")===l&&e.getInputTargetBlock("AT2")===a})),u=o.getAllBlocks().find((function(e){return("text_print"===e.type||"js_text_print"===e.type)&&e.getNextBlock()===r&&e.getInputTargetBlock("TEXT")===s})),c=o.getAllBlocks().find((function(e){return"text"===e.type&&"aap kaise hain?"==e.getFieldValue("TEXT")})),g=o.getAllBlocks().find((function(e){return("text_input"===e.type||"js_text_input"===e.type)&&e.getInputTargetBlock("TEXT")===c})),d=o.getAllBlocks().find((function(e){return"variables_set"===e.type&&e.getNextBlock()===u&&e.getInputTargetBlock("VALUE")===g&&"response"===e.getField("VAR").getText()}));return e&&t&&2===n.length&&i&&r&&a&&l&&s&&u&&c&&g&&d}),new s((function(){var e=o.getAllBlocks().find((function(e){return"math_number"===e.type&&15===e.getFieldValue("NUM")})),t=o.getAllBlocks().find((function(e){return"math_number"===e.type&&1===e.getFieldValue("NUM")})),n=o.getAllBlocks().filter((function(e){return"variables_get"===e.type})),i=o.getAllBlocks().find((function(o){return("t2c_text_getsubstring"===o.type||"js_text_getsubstring"===o.type)&&-1!==n.indexOf(o.getInputTargetBlock("STRING"))&&o.getInputTargetBlock("AT1")===t&&o.getInputTargetBlock("AT2")===e})),r=o.getAllBlocks().find((function(e){return("text_print"===e.type||"js_text_print"===e.type)&&null===e.getNextBlock()&&e.getInputTargetBlock("TEXT")===i})),a=o.getAllBlocks().find((function(e){return"math_number"===e.type&&9===e.getFieldValue("NUM")})),l=o.getAllBlocks().find((function(e){return"math_number"===e.type&&4===e.getFieldValue("NUM")})),s=o.getAllBlocks().find((function(e){return("t2c_text_getsubstring"===e.type||"js_text_getsubstring"===e.type)&&-1!==n.indexOf(e.getInputTargetBlock("STRING"))&&e.getInputTargetBlock("AT1")===l&&e.getInputTargetBlock("AT2")===a})),u=o.getAllBlocks().find((function(e){return("text_print"===e.type||"js_text_print"===e.type)&&e.getNextBlock()===r&&e.getInputTargetBlock("TEXT")===s})),c=o.getAllBlocks().find((function(e){return"text"===e.type})),g=o.getAllBlocks().find((function(e){return"text_input"===e.type||"js_text_input"===e.type})),d=o.getAllBlocks().find((function(e){return"variables_set"===e.type&&e.getNextBlock()===u&&e.getInputTargetBlock("VALUE")===g}));if(d){var h=d.getField("VAR").getText();if(n.find((function(e){return e.getField("VAR").getText()!==h})))return"Be sure that the variable names all match so they all refer to the same text.";if("welcomeMsg"!==h&&"response"!==h)return"Be sure to name the variable response to reflect that it now holds the user response to the question aap kaise hain? You can change a variable name by clicking its current name of "+h+" and then selecting Rename variable..."}if(g){if(g.getParent()!==d)return"Be sure to place the "+T2C.MSG.currentLanguage.TERMINAL_GETINPUTBYASKING+" block inside the "+T2C.MSG.currentLanguage.TERMINAL_LET+" one so the variable stores the response from the user.";if(c){if("aap kaise hain?"!==c.getFieldValue("TEXT"))return"The message of aap kaise hain? should stay the same so change it back to that. The only difference here is that it becomes the prompt to the user rather than the text we'll be extracting a substring from, which instead will be the user's response.";if(c.getParent()!==g)return"Place the text block with the message aap kaise hain? inside the "+T2C.MSG.currentLanguage.TERMINAL_GETINPUTBYASKING+" one so that the user is prompted with this question."}}return"Drag in the "+T2C.MSG.currentLanguage.TERMINAL_GETINPUTBYASKING+" block from the toolbox and make aap kaise hain? its prompt. Then change the variable name from welcomeMsg to response to reflect the fact that the variable will now hold the user's reply to the question aap kaise hain? instead of the question itself."}),{startPosition:q(o,null,{},50,document.getElementById("top-header").offsetHeight+50)}))),h(n),p(n,document.getElementById("output-container").querySelectorAll(".table-cell")[0]),n.addTask(new r((function(){return!0}),{start:function(){return!0},isComplete:function(){return!0},animate:function(){return!0},finish:function(){alert("👍 Great! So are you seeing 2 lines of text here, or did you get an error? If you received an error, it means your text that you entered wasn't long enough. E.g., you can't extract all the characters from the input from position 1 to before position 15 for an input of bahut acchaa whose last character appears at position 11 (positions 12, 13, and 14 don't exist for this string!). On the other hand, if your text was too long, you wouldn't get all of the characters beyond the initial one. So to conclude this mission, let's fix this problem so it works for any string with at least 1 character!"),X(document.getElementById("output-container").querySelectorAll(".table-cell")[0]),j(),o.updateToolbox(document.getElementById("toolbox"))}})),n.addTask(new r((function(){var e=o.getAllBlocks().find((function(e){return"text"===e.type&&"aap kaise hain?"==e.getFieldValue("TEXT")})),t=o.getAllBlocks().find((function(t){return("text_input"===t.type||"js_text_input"===t.type)&&t.getInputTargetBlock("TEXT")===e})),n=o.getAllBlocks().find((function(e){return"variables_set"===e.type&&null===e.getNextBlock()&&e.getInputTargetBlock("VALUE")===t&&"response"===e.getField("VAR").getText()}));return e&&t&&n}),new s((function(){return"First, delete the two "+T2C.MSG.currentLanguage.TERMINAL_DISPLAY+" blocks and all the ones that appear inside them so all that's left is the initial "+T2C.MSG.currentLanguage.TERMINAL_LET+" variable statement assigned to the user's response."}),{startPosition:q(o,null,{},50,document.getElementById("top-header").offsetHeight+50),finish:function(){var e=Y("text_print"),t=Y("t2c_text_getsubstring"),n=Y("variables_get"),i=Y("math_number"),r=Y("math_number");H(n,"VAR","response"),H(i,"NUM",1),H(r,"NUM",15),J(e,"TEXT",t),J(t,"STRING",n),J(t,"AT1",i),J(t,"AT2",r),o.options.maxInstances.text_print=0,o.options.maxInstances.text=0,o.options.maxInstances.variables_get=0,o.options.maxInstances.math_number=0,o.options.maxInstances.t2c_text_getsubstring=0,document.getElementById("toolbox").prepend(e),W(o,"type_in_all_but_first_general_str"),o.options.maxInstances.type_in_all_but_first_general_str=1}}))),n.addTask(new r((function(){var e=o.getAllBlocks().filter((function(e){return"variables_get"===e.type&&"response"===e.getField("VAR").getText()})),t=o.getAllBlocks().find((function(t){return"t2c_text_length"===t.type&&-1!==e.indexOf(t.getInputTargetBlock("VALUE"))})),n=o.getAllBlocks().find((function(e){return"math_number"===e.type&&1===e.getFieldValue("NUM")})),i=o.getAllBlocks().find((function(o){return("t2c_text_getsubstring"===o.type||"js_text_getsubstring"===o.type)&&-1!==e.indexOf(o.getInputTargetBlock("STRING"))&&o.getInputTargetBlock("AT1")===n&&o.getInputTargetBlock("AT2")===t})),r=o.getAllBlocks().find((function(e){return("text_print"===e.type||"js_text_print"===e.type)&&null===e.getNextBlock()&&e.getInputTargetBlock("TEXT")===i})),a=o.getAllBlocks().find((function(e){return"text"===e.type&&"aap kaise hain?"==e.getFieldValue("TEXT")})),l=o.getAllBlocks().find((function(e){return("text_input"===e.type||"js_text_input"===e.type)&&e.getInputTargetBlock("TEXT")===a})),s=o.getAllBlocks().find((function(e){return"variables_set"===e.type&&e.getNextBlock()===r&&e.getInputTargetBlock("VALUE")===l&&"response"===e.getField("VAR").getText()}));return 2===e.length&&t&&n&&i&&r&&a&&l&&s}),new s((function(){var e=o.getAllBlocks().filter((function(e){return"variables_get"===e.type&&"response"===e.getField("VAR").getText()})),t=o.getAllBlocks().find((function(t){return"t2c_text_length"===t.type&&-1!==e.indexOf(t.getInputTargetBlock("VALUE"))})),n=o.getAllBlocks().find((function(e){return"math_number"===e.type&&1===e.getFieldValue("NUM")})),i=o.getAllBlocks().find((function(o){return("t2c_text_getsubstring"===o.type||"js_text_getsubstring"===o.type)&&-1!==e.indexOf(o.getInputTargetBlock("STRING"))&&o.getInputTargetBlock("AT1")===n&&o.getInputTargetBlock("AT2")===t})),r=o.getAllBlocks().find((function(e){return("text_print"===e.type||"js_text_print"===e.type)&&e.getInputTargetBlock("TEXT")===i})),a=o.getAllBlocks().find((function(e){return"text"===e.type&&"aap kaise hain?"==e.getFieldValue("TEXT")})),l=o.getAllBlocks().find((function(e){return("text_input"===e.type||"js_text_input"===e.type)&&e.getInputTargetBlock("TEXT")===a})),s=o.getAllBlocks().find((function(e){return"variables_set"===e.type&&e.getInputTargetBlock("VALUE")===l&&"response"===e.getField("VAR").getText()}));return r&&s&&r.getNextBlock()===s?"The "+T2C.MSG.currentLanguage.TERMINAL_DISPLAY+" block should go below the "+T2C.MSG.currentLanguage.TERMINAL_LET+" variable block so the computer knows what response is when attempting to extract text from it. Remember that statements are run from top to bottom.":r&&r.getPreviousBlock()!==s?"Place the new "+T2C.MSG.currentLanguage.TERMINAL_DISPLAY+" block that's used to display all characters beyond the initial one below the previous "+T2C.MSG.currentLanguage.TERMINAL_LET+" variable block.":"Drag in the type-in code block from the toolbox and type in the code necessary to display all the characters except the initial one from the user response. As before, use "+T2C.MSG.currentLanguage.TERMINAL_GETTEXTFROMPOSITIONNUMBER+" and the variable response in your answer. But this time, make it work for any entered string, which means you can no longer enter a specific number for the position to end before.\nHINT: Remember what you used when you wanted to get the position of the last character? How is 15, the number we used for aap kaise hain?, related to this string? What would we use for theek?\nPlace this new block below the previous "+T2C.MSG.currentLanguage.TERMINAL_DISPLAY+"."}),{startPosition:q(o,null,{},50,document.getElementById("top-header").offsetHeight+50)}))),h(n),p(n,document.getElementById("output-container").querySelectorAll(".table-cell")[0]),n.addTask(new r((function(){return!0}),{start:function(){return!0},isComplete:function(){return!0},animate:function(){return!0},finish:function(){alert("✔✔👍 You got it, excellent problem solving as always! And with that mastery, mission 4 is now complete! In the next mission, we'll introduce a new block that'll be used to find the position numbers of the first occurrence of a given substring in another one. We'll then use it in combination with the "+T2C.MSG.currentLanguage.TERMINAL_GETTEXTFROMPOSITIONNUMBER+" from this lesson to get the text appearing between the first @ and . in an e-mail address (e.g., google from coolcoder@google.com or mail from expertsoftwareengineer@mail.co.uk)."),X(document.getElementById("output-container").querySelectorAll(".table-cell")[0]),j(),D(o),o.updateToolbox(document.getElementById("toolbox"))}})),n},function(e,t){var n=e||new c,o=t||Blockly.getMainWorkspace(),a=new f(o);o.setScale(1),Object(i.f)(o);var g=document.createElement("div");function d(e){e.addTask(new r((function(){return document.getElementById("output-container").classList.contains("show-container")}),new u([new s((function(){return T2C.MSG.currentLanguage.BUTTON_RUN_CODE}),{startPosition:{x:document.getElementById("run-code-button").offsetLeft+document.getElementById("run-code-button").offsetWidth,y:document.getElementById("run-code-button").offsetTop+document.getElementById("run-code-button").offsetHeight}}),new l(g,{totalSteps:100,toggleSteps:25,startPosition:{x:document.getElementById("run-code-button").offsetLeft+document.getElementById("run-code-button").offsetWidth/2,y:document.getElementById("run-code-button").offsetTop+document.getElementById("run-code-button").offsetHeight/2}})])))}function h(e,t){var n=0;function o(){t.style.color=n%50<25?"#a00":"#000",++n<200&&requestAnimationFrame(o)}e.addTask(new r((function(){return n>=200}),{start:function(){t.style.verticalAlign="top",requestAnimationFrame(o)},isComplete:function(){return!0},animate:function(){return!0}}))}return g.innerText="👆",g.id="ptr",g.style.fontSize="x-large",g.style.position="absolute",g.style.zIndex="1001",document.getElementById("blockly-div").appendChild(g),n.addTask(new r((function(){return!0}),{start:function(){return!0},isComplete:function(){return!0},animate:function(){return!0},finish:function(){alert("In this mission, you will learn about the "+T2C.MSG.currentLanguage.TERMINAL_FINDFIRSTOCCURRENCEOFTEXT+" and how it can be used to say get all of the text from the first @ up to the period. But first let's warm up by playing the role of the computer! You'll be given blocks of code and make the same substitutions the computer does step by step. For example, you'd be given blocks of code and would then fix the values in the blocks in each "+T2C.MSG.currentLanguage.TERMINAL_DISPLAY+", as necessary, so that each line of output is the same. Review the following code and run it. "),o.clear(),Blockly.Xml.domToWorkspace(Blockly.Xml.textToDom('sdsbahut badhiya!d2sDIVIDEsdbahut badhiya!DIVIDEbahut badhiya!2bahut badhiya!DIVIDE142bahut badhiya!7a'),o),Blockly.svgResize(o),a.clearToolbox()}})),d(n),h(n,document.getElementById("output-container").querySelectorAll(".table-cell")[0]),n.addTask(new r((function(){return!0}),{start:function(){return!0},isComplete:function(){return!0},animate:function(){return!0},finish:function(){var e="bahut badhiya!",t=e.length/2;alert("So from the first "+T2C.MSG.currentLanguage.TERMINAL_DISPLAY+" to the next, we combine the two substitutions of "+e+" for s and 2 for d. Then we substitute "+e.length+' for "'+e+'".length from the second '+T2C.MSG.currentLanguage.TERMINAL_DISPLAY+" to the third, "+e.length/2+" for "+e.length+"/2 from the third to the fourth and finally "+e.charAt(t)+" for s."+T2C.MSG.currentLanguage.TERMINAL_GETCHARACTERNUMBER+"("+t+").\n Now it's your turn, fill in the empty text \"\" blocks/change the 0's so the substitutions are correctly made."),o.clear(),Blockly.Xml.domToWorkspace(Blockly.Xml.textToDom('sdsbahut badhiya!d2sdMINUSs30MINUS30MINUS0300'),o),Blockly.svgResize(o),o.getAllBlocks().forEach((function(e){return e.setMovable(!1)})),z(document.getElementById("output-container").querySelectorAll(".table-cell")[0]),K()}})),n.addTask(new r((function(){var e=o.getAllBlocks().filter((function(e){return"text"===e.type&&"hut badhi"==e.getFieldValue("TEXT")})),t=o.getAllBlocks().filter((function(t){return"text_print"===t.type&&null===t.getNextBlock()&&-1!==e.indexOf(t.getInputTargetBlock("TEXT"))})),n=o.getAllBlocks().filter((function(e){return"math_number"===e.type&&"11"==e.getFieldValue("NUM")})),i=o.getAllBlocks().filter((function(e){return"math_number"===e.type&&"2"==e.getFieldValue("NUM")})),r=o.getAllBlocks().filter((function(e){return"text"===e.type&&"bahut badhiya!"==e.getFieldValue("TEXT")})),a=o.getAllBlocks().filter((function(e){return"t2c_text_getsubstring"===e.type&&-1!==r.indexOf(e.getInputTargetBlock("STRING"))&&-1!==i.indexOf(e.getInputTargetBlock("AT1"))&&-1!==n.indexOf(e.getInputTargetBlock("AT2"))})),l=o.getAllBlocks().filter((function(e){return"text_print"===e.type&&-1!==t.indexOf(e.getNextBlock())&&-1!==a.indexOf(e.getInputTargetBlock("TEXT"))})),s=o.getAllBlocks().filter((function(e){return"math_number"===e.type&&"3"==e.getFieldValue("NUM")})),u=o.getAllBlocks().filter((function(e){return"math_number"===e.type&&"14"==e.getFieldValue("NUM")})),c=o.getAllBlocks().filter((function(e){return"math_arithmetic_basic"===e.type&&-1!==u.indexOf(e.getInputTargetBlock("A"))&&-1!==s.indexOf(e.getInputTargetBlock("B"))&&"MINUS"==e.getFieldValue("OP")})),g=o.getAllBlocks().filter((function(e){return"t2c_text_getsubstring"===e.type&&-1!==r.indexOf(e.getInputTargetBlock("STRING"))&&-1!==i.indexOf(e.getInputTargetBlock("AT1"))&&-1!==c.indexOf(e.getInputTargetBlock("AT2"))})),d=o.getAllBlocks().filter((function(e){return"text_print"===e.type&&-1!==l.indexOf(e.getNextBlock())&&-1!==g.indexOf(e.getInputTargetBlock("TEXT"))})),h=o.getAllBlocks().filter((function(e){return"t2c_text_length"===e.type&&-1!==r.indexOf(e.getInputTargetBlock("VALUE"))})),p=o.getAllBlocks().filter((function(e){return"math_arithmetic_basic"===e.type&&-1!==h.indexOf(e.getInputTargetBlock("A"))&&-1!==s.indexOf(e.getInputTargetBlock("B"))&&"MINUS"==e.getFieldValue("OP")})),f=o.getAllBlocks().filter((function(e){return"t2c_text_getsubstring"===e.type&&-1!==r.indexOf(e.getInputTargetBlock("STRING"))&&-1!==i.indexOf(e.getInputTargetBlock("AT1"))&&-1!==p.indexOf(e.getInputTargetBlock("AT2"))})),m=o.getAllBlocks().filter((function(e){return"text_print"===e.type&&-1!==d.indexOf(e.getNextBlock())&&-1!==f.indexOf(e.getInputTargetBlock("TEXT"))})),y=o.getAllBlocks().filter((function(e){return"variables_get"===e.type&&"s"===e.getField("VAR").getText()})),T=o.getAllBlocks().filter((function(e){return"t2c_text_length"===e.type&&-1!==y.indexOf(e.getInputTargetBlock("VALUE"))})),_=o.getAllBlocks().filter((function(e){return"math_arithmetic_basic"===e.type&&-1!==T.indexOf(e.getInputTargetBlock("A"))&&-1!==s.indexOf(e.getInputTargetBlock("B"))&&"MINUS"==e.getFieldValue("OP")})),b=o.getAllBlocks().filter((function(e){return"variables_get"===e.type&&"d"===e.getField("VAR").getText()})),k=o.getAllBlocks().filter((function(e){return"t2c_text_getsubstring"===e.type&&-1!==y.indexOf(e.getInputTargetBlock("STRING"))&&-1!==b.indexOf(e.getInputTargetBlock("AT1"))&&-1!==_.indexOf(e.getInputTargetBlock("AT2"))})),x=o.getAllBlocks().filter((function(e){return"text_print"===e.type&&-1!==m.indexOf(e.getNextBlock())&&-1!==k.indexOf(e.getInputTargetBlock("TEXT"))})),E=o.getAllBlocks().filter((function(e){return"variables_set"===e.type&&-1!==x.indexOf(e.getNextBlock())&&-1!==i.indexOf(e.getInputTargetBlock("VALUE"))&&"d"===e.getField("VAR").getText()})),B=o.getAllBlocks().filter((function(e){return"variables_set"===e.type&&-1!==E.indexOf(e.getNextBlock())&&-1!==r.indexOf(e.getInputTargetBlock("VALUE"))&&"s"===e.getField("VAR").getText()}));return 1===e.length&&1===t.length&&1===n.length&&4===i.length&&5===r.length&&1===a.length&&1===l.length&&3===s.length&&1===u.length&&1===c.length&&1===g.length&&1===d.length&&1===h.length&&1===p.length&&1===f.length&&1===m.length&&2===y.length&&1===T.length&&1===_.length&&1===b.length&&1===k.length&&1===x.length&&1===E.length&&1===B.length}),new s((function(){for(var e=o.getAllBlocks(!0),t=e.filter((function(e){return"text_print"===e.type||"js_text_print"===e.type})),n=e.filter((function(e){return"t2c_text_getsubstring"===e.type||"js_text_getsubstring"===e.type})),i=e.find((function(e){return"text"===e.type&&e.getParent()&&"t2c_text_length"===e.getParent().type})),r=e.find((function(e){return"math_arithmetic_basic"===e.type&&e.getInputTargetBlock("A")&&"math_number"===e.getInputTargetBlock("A").type})),a=n.map((function(e){return e.getInputTargetBlock("AT2")})).find((function(e){return e&&"math_number"===e.type})),l=t.map((function(e){return e.getInputTargetBlock("TEXT")})).find((function(e){return e&&"text"===e.type})),s="bahut badhiya!",u=s.substring(2,s.length-3),c=1;c<=3;c++){var g=n[c].getInputTargetBlock("STRING"),d=n[c].getInputTargetBlock("AT1");if(g&&"text"===g.type&&g.getFieldValue("TEXT")&&g.getFieldValue("TEXT")!==s)return"The text on line "+(c+3)+" is incorrect. Substitute s with the value that it's initially assigned to.";if(d&&"math_number"===d.type&&d.getFieldValue("NUM")&&2!==d.getFieldValue("NUM"))return"The number in the first position on line "+(c+3)+" is incorrect. Substitute d with the value that it's initially assigned to."}if(i&&i.getFieldValue("TEXT")&&i.getFieldValue("TEXT")!==s)return"The text in the "+T2C.MSG.currentLanguage.TERMINAL_LENGTH+" block on line 4 is incorrect. Substitute s with the value that it's initially assigned to.";if(r&&l){var h=r.getInputTargetBlock("A").getFieldValue("NUM"),p=l.getFieldValue("TEXT");if(h===s.length-1)return"Remember the count for the length starts with 1 and include the spaces and punctuation are counted.";if(h&&h!==s.length)return"Substitute the first number in the arithmetic block with the subtraction on line 5 with s's length.";if(h&&a&&a.getFieldValue("NUM")!==s.length-3)return"What is s.length - 3? This is what should be substituted for the second number block on line 6.";if(h&&p){if(u===p.substring(1))return"Remember to start counting from 0 when determining what the resulting string will be on the last line.";if(p===u.substring(1))return"Remember that "+T2C.MSG.currentLanguage.TERMINAL_GETTEXTFROMPOSITIONNUMBER+" starts extracting text at the exact position given for its first number. Change the string literal on the last line, accordingly.";if(u===p.substring(0,p.length-1))return"Remember that "+T2C.MSG.currentLanguage.TERMINAL_GETTEXTFROMPOSITIONNUMBER+" stops extracting text at one position before its given second number. Change the string literal on the last line, accordingly.";if(u!==p)return"The string literal you have on the last line is incorrect. Check the previous lines in order and then fix it accordingly."}}return"Replace all the blank string literals and 0's with the appropriate text and numbers that are substituted as the computer would from top to bottom so that every line of output is the same. Try to do this without running the program until you get the message to do so (when you filled in everything correctly)."}),{startPosition:te(o,null,{},50,document.getElementById("top-header").offsetHeight+50)}))),d(n),h(n,document.getElementById("output-container").querySelectorAll(".table-cell")[0]),n.addTask(new r((function(){return!0}),{start:function(){return!0},isComplete:function(){return!0},animate:function(){return!0},finish:function(){alert("✔ Nice, so now let's tweak this a little, adding the new "+T2C.MSG.currentLanguage.TERMINAL_FINDFIRSTOCCURRENCEOFTEXT+" block, which given a string (haystack) to look through and a string appearing in it (needle) to find, produces the position NUMBER of its first occurrence. As before, replace all the blank string literals and 0's with the appropriate text and numbers that are substituted as the computer would from top to bottom so that every line of output is the same. Try to do this without running the program until you get the message to do so (when you filled in everything correctly)."),o.clear(),Blockly.Xml.domToWorkspace(Blockly.Xml.textToDom('sspacePositionsbahut badhiya!spacePositions sMINUS1spacePosition13ADDspacePosition4MINUS1013ADD0400'),o),Blockly.svgResize(o),o.getAllBlocks().forEach((function(e){return e.setMovable(!1)})),z(document.getElementById("output-container").querySelectorAll(".table-cell")[0]),K()}})),n.addTask(new r((function(){var e=o.getAllBlocks().filter((function(e){return"text"===e.type&&"hut bad"==e.getFieldValue("TEXT")})),t=o.getAllBlocks().filter((function(t){return"text_print"===t.type&&null===t.getNextBlock()&&-1!==e.indexOf(t.getInputTargetBlock("TEXT"))})),n=o.getAllBlocks().filter((function(e){return"math_number"===e.type&&"9"==e.getFieldValue("NUM")})),i=o.getAllBlocks().filter((function(e){return"math_number"===e.type&&"2"==e.getFieldValue("NUM")})),r=o.getAllBlocks().filter((function(e){return"text"===e.type&&"bahut badhiya!"==e.getFieldValue("TEXT")})),a=o.getAllBlocks().filter((function(e){return"t2c_text_getsubstring"===e.type&&-1!==r.indexOf(e.getInputTargetBlock("STRING"))&&-1!==i.indexOf(e.getInputTargetBlock("AT1"))&&-1!==n.indexOf(e.getInputTargetBlock("AT2"))})),l=o.getAllBlocks().filter((function(e){return"text_print"===e.type&&-1!==t.indexOf(e.getNextBlock())&&-1!==a.indexOf(e.getInputTargetBlock("TEXT"))})),s=o.getAllBlocks().filter((function(e){return"math_number"===e.type&&"4"==e.getFieldValue("NUM")})),u=o.getAllBlocks().filter((function(e){return"math_number"===e.type&&"5"==e.getFieldValue("NUM")})),c=o.getAllBlocks().filter((function(e){return"math_arithmetic_basic"===e.type&&-1!==u.indexOf(e.getInputTargetBlock("A"))&&-1!==s.indexOf(e.getInputTargetBlock("B"))&&"ADD"==e.getFieldValue("OP")})),g=o.getAllBlocks().filter((function(e){return"math_number"===e.type&&"3"==e.getFieldValue("NUM")})),d=o.getAllBlocks().filter((function(e){return"math_arithmetic_basic"===e.type&&-1!==u.indexOf(e.getInputTargetBlock("A"))&&-1!==g.indexOf(e.getInputTargetBlock("B"))&&"MINUS"==e.getFieldValue("OP")})),h=o.getAllBlocks().filter((function(e){return"t2c_text_getsubstring"===e.type&&-1!==r.indexOf(e.getInputTargetBlock("STRING"))&&-1!==d.indexOf(e.getInputTargetBlock("AT1"))&&-1!==c.indexOf(e.getInputTargetBlock("AT2"))})),p=o.getAllBlocks().filter((function(e){return"text_print"===e.type&&-1!==l.indexOf(e.getNextBlock())&&-1!==h.indexOf(e.getInputTargetBlock("TEXT"))})),f=o.getAllBlocks().filter((function(e){return"variables_get"===e.type&&"spacePosition"===e.getField("VAR").getText()})),m=o.getAllBlocks().filter((function(e){return"math_arithmetic_basic"===e.type&&-1!==f.indexOf(e.getInputTargetBlock("A"))&&-1!==s.indexOf(e.getInputTargetBlock("B"))&&"ADD"==e.getFieldValue("OP")})),y=o.getAllBlocks().filter((function(e){return"math_arithmetic_basic"===e.type&&-1!==f.indexOf(e.getInputTargetBlock("A"))&&-1!==g.indexOf(e.getInputTargetBlock("B"))&&"MINUS"==e.getFieldValue("OP")})),T=o.getAllBlocks().filter((function(e){return"variables_get"===e.type&&"s"===e.getField("VAR").getText()})),_=o.getAllBlocks().filter((function(e){return"t2c_text_getsubstring"===e.type&&-1!==T.indexOf(e.getInputTargetBlock("STRING"))&&-1!==y.indexOf(e.getInputTargetBlock("AT1"))&&-1!==m.indexOf(e.getInputTargetBlock("AT2"))})),b=o.getAllBlocks().filter((function(e){return"text_print"===e.type&&-1!==p.indexOf(e.getNextBlock())&&-1!==_.indexOf(e.getInputTargetBlock("TEXT"))})),k=o.getAllBlocks().filter((function(e){return"text"===e.type&&" "==e.getFieldValue("TEXT")})),x=o.getAllBlocks().filter((function(e){return"t2c_text_indexof"===e.type&&-1!==T.indexOf(e.getInputTargetBlock("VALUE"))&&-1!==k.indexOf(e.getInputTargetBlock("FIND"))})),E=o.getAllBlocks().filter((function(e){return"variables_set"===e.type&&-1!==b.indexOf(e.getNextBlock())&&-1!==x.indexOf(e.getInputTargetBlock("VALUE"))&&"spacePosition"===e.getField("VAR").getText()})),B=o.getAllBlocks().filter((function(e){return"variables_set"===e.type&&-1!==E.indexOf(e.getNextBlock())&&-1!==r.indexOf(e.getInputTargetBlock("VALUE"))&&"s"===e.getField("VAR").getText()}));return 1===e.length&&1===t.length&&1===n.length&&1===i.length&&3===r.length&&1===a.length&&1===l.length&&2===s.length&&2===u.length&&1===c.length&&2===g.length&&1===d.length&&1===h.length&&1===p.length&&2===f.length&&1===m.length&&1===y.length&&2===T.length&&1===_.length&&1===b.length&&1===k.length&&1===x.length&&1===E.length&&1===B.length}),new s((function(){for(var e=o.getAllBlocks(!0),t=e.filter((function(e){return"text_print"===e.type||"js_text_print"===e.type})),n=e.filter((function(e){return"t2c_text_getsubstring"===e.type||"js_text_getsubstring"===e.type})),i=e.filter((function(e){return"math_arithmetic_basic"===e.type})).map((function(e){return e.getInputTargetBlock("A")})).filter((function(e){return e&&"math_number"===e.type})),r=n.find((function(e){return e.getInputTargetBlock("AT1")&&e.getInputTargetBlock("AT2")&&"math_number"===e.getInputTargetBlock("AT1").type&&"math_number"===e.getInputTargetBlock("AT2").type})),a=t.map((function(e){return e.getInputTargetBlock("TEXT")})).find((function(e){return e&&"text"===e.type})),l=r&&r.getInputTargetBlock("AT1").getFieldValue("NUM"),s=r&&r.getInputTargetBlock("AT2").getFieldValue("NUM"),u="bahut badhiya!",c=u.indexOf(" "),g=u.substring(c-3,c+4),d=1;d<=2;d++){var h=n[d].getInputTargetBlock("STRING"),p=i[d-1];if(h&&"text"===h.type&&h.getFieldValue("TEXT")&&h.getFieldValue("TEXT")!==u)return"The text on line "+(d+3)+" is incorrect. Substitute s with the value that it's initially assigned to.";if(p&&p.getFieldValue("NUM")&&p.getFieldValue("NUM")!==c)return"The left number in the "+(1===d?"first":"second")+" arithmetic block on line 4 is incorrect. Substitute each spacePosition with the position of the first space in s, i.e., "+u+"."}if(l&&l!==c-3)return"The "+l+" on line 5 is incorrect; it should be the result of subtracting 3 from the value of spacePosition.";if(s&&s!==c+4)return"The "+s+" on line 5 is incorrect; it should be the result of adding 4 to the value of spacePosition.";if(l&&s&&a){var f=a.getFieldValue("TEXT");if(f){if(g===f.substring(1))return"Remember to start counting from 0 when determining what the resulting string will be on the last line.";if(f===g.substring(1))return"Remember that "+T2C.MSG.currentLanguage.TERMINAL_GETTEXTFROMPOSITIONNUMBER+" starts extracting text at the exact position given for its first number. Change the string literal on the last line, accordingly.";if(g===f.substring(0,f.length-1))return"Remember that "+T2C.MSG.currentLanguage.TERMINAL_GETTEXTFROMPOSITIONNUMBER+" stops extracting text at one position before its given second number. Change the string literal on the last line, accordingly.";if(g!==f)return"The string literal you have on the last line is incorrect. Check the previous lines in order and then fix it accordingly."}}return"The new "+T2C.MSG.currentLanguage.TERMINAL_FINDFIRSTOCCURRENCEOFTEXT+" takes a string (haystack: a space in this code excerpt) to look through and a string appearing in it (needle) to find as inputs and produces the position NUMBER of the needle's first occurrence in haystack. As before, replace all the blank string literals and 0's with the appropriate text and numbers that are substituted as the computer would from top to bottom so that every line of output is the same. Try to do this without running the program until you get the message to do so (when you filled in everything correctly)."}),{startPosition:te(o,null,{},50,document.getElementById("top-header").offsetHeight+50)}))),d(n),h(n,document.getElementById("output-container").querySelectorAll(".table-cell")[0]),n.addTask(new r((function(){return!0}),{start:function(){return!0},isComplete:function(){return!0},animate:function(){return!0},finish:function(){alert("✔ Nice x 2! So as you can see the new "+T2C.MSG.currentLanguage.TERMINAL_FINDFIRSTOCCURRENCEOFTEXT+" allows us to extract characters before/after a desired character(s) when used to determine starting/ending positions for "+T2C.MSG.currentLanguage.TERMINAL_GETTEXTFROMPOSITIONNUMBER+" (or just a single position for "+T2C.MSG.currentLanguage.TERMINAL_GETCHARACTERNUMBER+"). Let's try a few more examples where you'll again replace all the blank string literals and 0's with the appropriate text and numbers that are substituted as the computer would from top to bottom so that every line of output is the same. Try to do this without running the program until you get the message to do so (when you filled in everything correctly)."),o.clear(),Blockly.Xml.domToWorkspace(Blockly.Xml.textToDom('greetinggreetinghey HEY hey!greetinggreetingHH0'),o),Blockly.svgResize(o),o.getAllBlocks().forEach((function(e){return e.setMovable(!1)})),z(document.getElementById("output-container").querySelectorAll(".table-cell")[0]),K()}})),n.addTask(new r((function(){var e=o.getAllBlocks().filter((function(e){return"text"===e.type&&"H"===e.getFieldValue("TEXT")})),t=o.getAllBlocks().filter((function(t){return"text_print"===t.type&&null===t.getNextBlock()&&-1!==e.indexOf(t.getInputTargetBlock("TEXT"))})),n=o.getAllBlocks().filter((function(e){return"math_number"===e.type&&4===e.getFieldValue("NUM")})),i=o.getAllBlocks().filter((function(e){return"text"===e.type&&"hey HEY hey!"==e.getFieldValue("TEXT")})),r=o.getAllBlocks().filter((function(e){return"t2c_text_charat"===e.type&&-1!==i.indexOf(e.getInputTargetBlock("VALUE"))&&-1!==n.indexOf(e.getInputTargetBlock("AT"))})),a=o.getAllBlocks().filter((function(e){return"text_print"===e.type&&-1!==t.indexOf(e.getNextBlock())&&-1!==r.indexOf(e.getInputTargetBlock("TEXT"))})),l=o.getAllBlocks().filter((function(t){return"t2c_text_indexof"===t.type&&-1!==i.indexOf(t.getInputTargetBlock("VALUE"))&&-1!==e.indexOf(t.getInputTargetBlock("FIND"))})),s=o.getAllBlocks().filter((function(e){return"t2c_text_charat"===e.type&&-1!==i.indexOf(e.getInputTargetBlock("VALUE"))&&-1!==l.indexOf(e.getInputTargetBlock("AT"))})),u=o.getAllBlocks().filter((function(e){return"text_print"===e.type&&-1!==a.indexOf(e.getNextBlock())&&-1!==s.indexOf(e.getInputTargetBlock("TEXT"))})),c=o.getAllBlocks().filter((function(e){return"variables_get"===e.type&&"greeting"===e.getField("VAR").getText()})),g=o.getAllBlocks().filter((function(t){return"t2c_text_indexof"===t.type&&-1!==c.indexOf(t.getInputTargetBlock("VALUE"))&&-1!==e.indexOf(t.getInputTargetBlock("FIND"))})),d=o.getAllBlocks().filter((function(e){return"t2c_text_charat"===e.type&&-1!==c.indexOf(e.getInputTargetBlock("VALUE"))&&-1!==g.indexOf(e.getInputTargetBlock("AT"))})),h=o.getAllBlocks().filter((function(e){return"text_print"===e.type&&-1!==u.indexOf(e.getNextBlock())&&-1!==d.indexOf(e.getInputTargetBlock("TEXT"))})),p=o.getAllBlocks().filter((function(e){return"variables_set"===e.type&&-1!==h.indexOf(e.getNextBlock())&&-1!==i.indexOf(e.getInputTargetBlock("VALUE"))&&"greeting"===e.getField("VAR").getText()}));return 3===e.length&&1===t.length&&1===n.length&&4===i.length&&1===r.length&&1===a.length&&1===l.length&&1===s.length&&1===u.length&&2===c.length&&1===g.length&&1===d.length&&1===h.length&&1===p.length}),new s((function(){var e=o.getAllBlocks(!0),t=e.filter((function(e){return"t2c_text_charat"===e.type||"js_text_charat"===e.type})).map((function(e){return e.getInputTargetBlock("VALUE")})).filter((function(e){return e&&"text"===e.type})),n=e.filter((function(e){return"t2c_text_indexof"===e.type||"js_text_indexof"===e.type})).map((function(e){return e.getInputTargetBlock("VALUE")})).find((function(e){return e&&"text"===e.type})),i=e.find((function(e){return"math_number"===e.type&&e.getParent()&&("t2c_text_charat"===e.getParent().type||"js_text_charat"===e.getParent().type)})),r=e.find((function(e){return"text"===e.type&&e.getParent()&&("text_print"===e.getParent().type||"js_text_print"===e.getParent().type)})),a="hey HEY hey!",l="H";a.indexOf(l);for(var s=0;s<=1;s++){var u=t[s];if(u&&u.getFieldValue("TEXT")&&u.getFieldValue("TEXT")!==a)return"The text before "+T2C.MSG.currentLanguage.TERMINAL_GETCHARACTERNUMBER+" on line "+(s+3)+" is incorrect. Substitute greeting with the value that it's initially assigned to."}if(n&&n.getFieldValue("TEXT")&&n.getFieldValue("TEXT")!==a)return"The text before "+T2C.MSG.currentLanguage.TERMINAL_FINDFIRSTOCCURRENCEOFTEXT+" on line 3 is incorrect. Substitute greeting with the value that it's initially assigned to.";if(i){var c=i.getFieldValue("NUM");if(c&&c===a.indexOf(l.toLowerCase()))return"The number you substituted on line 4 is incorrect. "+T2C.MSG.currentLanguage.TERMINAL_FINDFIRSTOCCURRENCEOFTEXT+" is case sensitive meaning that H is different than "+l.toLowerCase()+".";if(c&&c===a.indexOf(l)+1)return"The number you substituted on line 4 is incorrect. Remember that positions start at 0.";if(c&&c===a.indexOf(l)-1)return"The number you substituted on line 4 is incorrect. "+T2C.MSG.currentLanguage.TERMINAL_FINDFIRSTOCCURRENCEOFTEXT+" gets the *exact* position of the first occurrence.";if(c&&c!==a.indexOf(l))return"The number you substituted on line 4 is incorrect. Remember to count all of the characters including spaces when getting the position of the first H.";if(c===a.indexOf(l)&&r){var g=r.getFieldValue("TEXT");if(g===l.toLowerCase())return"The string literal on the last line is incorrect. Remember to type in the same case ("+l.toLowerCase()+" versus H).";if(g&&g!==l)return"The string literal on the last line is incorrect. Check the previous lines in order and then fix it accordingly; it should be the result of the substitution of "+T2C.MSG.currentLanguage.TERMINAL_GETCHARACTERNUMBER+"."}}return"Replace all the blank string literals and 0's with the appropriate text and numbers that are substituted as the computer would from top to bottom so that every line of output is the same. Try to do this without running the program until you get the message to do so (when you filled in everything correctly)."}),{startPosition:te(o,null,{},50,document.getElementById("top-header").offsetHeight+50)}))),d(n),h(n,document.getElementById("output-container").querySelectorAll(".table-cell")[0]),n.addTask(new r((function(){return!0}),{start:function(){return!0},isComplete:function(){return!0},animate:function(){return!0},finish:function(){alert("✔ Nice x 3! So as you may have noticed, you got back the character you started with. Can you see why? If you get the position number of an H and then ask what character is at that position, it should be H! Now, let's reverse the order of the "+T2C.MSG.currentLanguage.TERMINAL_GETCHARACTERNUMBER+" and "+T2C.MSG.currentLanguage.TERMINAL_FINDFIRSTOCCURRENCEOFTEXT+" to see what happens."),o.clear(),Blockly.Xml.domToWorkspace(Blockly.Xml.textToDom('greetinggreetingHEY hey hey!greetinggreeting880'),o),Blockly.svgResize(o),o.getAllBlocks().forEach((function(e){return e.setMovable(!1)})),z(document.getElementById("output-container").querySelectorAll(".table-cell")[0]),K()}})),n.addTask(new r((function(){var e=o.getAllBlocks().filter((function(e){return"math_number"===e.type&&"4"==e.getFieldValue("NUM")})),t=o.getAllBlocks().filter((function(t){return"text_print"===t.type&&null===t.getNextBlock()&&-1!==e.indexOf(t.getInputTargetBlock("TEXT"))})),n=o.getAllBlocks().filter((function(e){return"text"===e.type&&"h"==e.getFieldValue("TEXT")})),i=o.getAllBlocks().filter((function(e){return"text"===e.type&&"HEY hey hey!"==e.getFieldValue("TEXT")})),r=o.getAllBlocks().filter((function(e){return"t2c_text_indexof"===e.type&&-1!==i.indexOf(e.getInputTargetBlock("VALUE"))&&-1!==n.indexOf(e.getInputTargetBlock("FIND"))})),a=o.getAllBlocks().filter((function(e){return"text_print"===e.type&&-1!==t.indexOf(e.getNextBlock())&&-1!==r.indexOf(e.getInputTargetBlock("TEXT"))})),l=o.getAllBlocks().filter((function(e){return"math_number"===e.type&&"8"==e.getFieldValue("NUM")})),s=o.getAllBlocks().filter((function(e){return"t2c_text_charat"===e.type&&-1!==i.indexOf(e.getInputTargetBlock("VALUE"))&&-1!==l.indexOf(e.getInputTargetBlock("AT"))})),u=o.getAllBlocks().filter((function(e){return"t2c_text_indexof"===e.type&&-1!==i.indexOf(e.getInputTargetBlock("VALUE"))&&-1!==s.indexOf(e.getInputTargetBlock("FIND"))})),c=o.getAllBlocks().filter((function(e){return"text_print"===e.type&&-1!==a.indexOf(e.getNextBlock())&&-1!==u.indexOf(e.getInputTargetBlock("TEXT"))})),g=o.getAllBlocks().filter((function(e){return"variables_get"===e.type&&"greeting"===e.getField("VAR").getText()})),d=o.getAllBlocks().filter((function(e){return"t2c_text_charat"===e.type&&-1!==g.indexOf(e.getInputTargetBlock("VALUE"))&&-1!==l.indexOf(e.getInputTargetBlock("AT"))})),h=o.getAllBlocks().filter((function(e){return"t2c_text_indexof"===e.type&&-1!==g.indexOf(e.getInputTargetBlock("VALUE"))&&-1!==d.indexOf(e.getInputTargetBlock("FIND"))})),p=o.getAllBlocks().filter((function(e){return"text_print"===e.type&&-1!==c.indexOf(e.getNextBlock())&&-1!==h.indexOf(e.getInputTargetBlock("TEXT"))})),f=o.getAllBlocks().filter((function(e){return"variables_set"===e.type&&-1!==p.indexOf(e.getNextBlock())&&-1!==i.indexOf(e.getInputTargetBlock("VALUE"))&&"greeting"===e.getField("VAR").getText()}));return 1===e.length&&1===t.length&&1===n.length&&4===i.length&&1===r.length&&1===a.length&&2===l.length&&1===s.length&&1===u.length&&1===c.length&&2===g.length&&1===d.length&&1===h.length&&1===p.length&&1===f.length}),new s((function(){for(var e=o.getAllBlocks(!0),t=e.filter((function(e){return"t2c_text_indexof"===e.type||"js_text_indexof"===e.type})).map((function(e){return e.getInputTargetBlock("VALUE")})).filter((function(e){return e&&"text"===e.type})),n=e.filter((function(e){return"t2c_text_charat"===e.type||"js_text_charat"===e.type})).map((function(e){return e.getInputTargetBlock("VALUE")})).find((function(e){return e&&"text"===e.type})),i=e.filter((function(e){return"t2c_text_indexof"===e.type||"js_text_indexof"===e.type})).map((function(e){return e.getInputTargetBlock("FIND")})).find((function(e){return e&&"text"===e.type})),r=e.find((function(e){return"math_number"===e.type&&e.getParent()&&("text_print"===e.getParent().type||"js_text_print"===e.getParent().type)})),a="HEY hey hey!".charAt(8),l=0;l<=1;l++){var s=t[l];if(s&&s.getFieldValue("TEXT")&&"HEY hey hey!"!==s.getFieldValue("TEXT"))return"The text before "+T2C.MSG.currentLanguage.TERMINAL_FINDFIRSTOCCURRENCEOFTEXT+" on line "+(l+3)+" is incorrect. Substitute greeting with the value that it's initially assigned to."}if(n&&n.getFieldValue("TEXT")&&"HEY hey hey!"!==n.getFieldValue("TEXT"))return"The text before "+T2C.MSG.currentLanguage.TERMINAL_GETCHARACTERNUMBER+" on line 3 is incorrect. Substitute greeting with the value that it's initially assigned to.";if(i){var u=i.getFieldValue("TEXT");if(u&&u!==a)return"The text you substituted on line 4 is incorrect. Remember to count all of the characters, starting from 0 and including spaces, when getting the character at position 8.";if(u===a&&r){var c=r.getFieldValue("NUM");if(8===c)return"Remember that "+T2C.MSG.currentLanguage.TERMINAL_FINDFIRSTOCCURRENCEOFTEXT+" gets the position of the *first* occurrence.";if(c!=="HEY hey hey!".indexOf(a))return"The number on the last line is incorrect. Check the previous lines in order and then fix it accordingly; it should be the result of the substitution of "+T2C.MSG.currentLanguage.TERMINAL_FINDFIRSTOCCURRENCEOFTEXT+". Remember that positions start with 0 and to count spaces."}}return"Replace all the blank string literals and 0's with the appropriate text and numbers that are substituted as the computer would from top to bottom so that every line of output is the same. Try to do this without running the program until you get the message to do so (when you filled in everything correctly)."}),{startPosition:te(o,null,{},50,document.getElementById("top-header").offsetHeight+50)}))),d(n),h(n,document.getElementById("output-container").querySelectorAll(".table-cell")[0]),n.addTask(new r((function(){return!0}),{start:function(){return!0},isComplete:function(){return!0},animate:function(){return!0},finish:function(){alert("✔ Nice x 4! Did you notice that you did *not* get the number you started with this time. Can you see why? Well, the character you got appeared earlier. So when you looked for its first position, you got a smaller number back. Had you gotten the character at its first position (i.e., 4 in this case), and then asked for its position, you would have indeed gotten back the number you started with. OK, one more code reading substitution example before we get to a code writing one! We'll skip a few steps since it's a little long, but you're up for the challenge, right?"),o.clear(),Blockly.Xml.domToWorkspace(Blockly.Xml.textToDom('questionneedlepart1part2questionWhere is the code?needle is part1questionADDquestionneedle4MINUSquestion1part2question1questionneedlepart1needlepart2questionADD04MINUS01question100010'),o),Blockly.svgResize(o),o.getAllBlocks().forEach((function(e){return e.setMovable(!1)})),z(document.getElementById("output-container").querySelectorAll(".table-cell")[0]),K()}})),n.addTask(new r((function(){var e=o.getAllBlocks().filter((function(e){return"text"===e.type&&"the code is here"==e.getFieldValue("TEXT")})),t=o.getAllBlocks().filter((function(t){return"text_print"===t.type&&null===t.getNextBlock()&&-1!==e.indexOf(t.getInputTargetBlock("TEXT"))})),n=o.getAllBlocks().filter((function(e){return"text"===e.type&&"here"==e.getFieldValue("TEXT")})),i=o.getAllBlocks().filter((function(e){return"text"===e.type&&" is "==e.getFieldValue("TEXT")})),r=o.getAllBlocks().filter((function(e){return"t2c_text_join"===e.type&&-1!==i.indexOf(e.getInputTargetBlock("A"))&&-1!==n.indexOf(e.getInputTargetBlock("B"))})),a=o.getAllBlocks().filter((function(e){return"text"===e.type&&"the code"==e.getFieldValue("TEXT")})),l=o.getAllBlocks().filter((function(e){return"t2c_text_join"===e.type&&-1!==a.indexOf(e.getInputTargetBlock("A"))&&-1!==r.indexOf(e.getInputTargetBlock("B"))})),s=o.getAllBlocks().filter((function(e){return"text_print"===e.type&&-1!==t.indexOf(e.getNextBlock())&&-1!==l.indexOf(e.getInputTargetBlock("TEXT"))})),u=o.getAllBlocks().filter((function(e){return"math_number"===e.type&&"5"==e.getFieldValue("NUM")})),c=o.getAllBlocks().filter((function(e){return"math_number"===e.type&&"1"==e.getFieldValue("NUM")})),g=o.getAllBlocks().filter((function(e){return"text"===e.type&&"Where is the code?"==e.getFieldValue("TEXT")})),d=o.getAllBlocks().filter((function(e){return"t2c_text_getsubstring"===e.type&&-1!==g.indexOf(e.getInputTargetBlock("STRING"))&&-1!==c.indexOf(e.getInputTargetBlock("AT1"))&&-1!==u.indexOf(e.getInputTargetBlock("AT2"))})),h=o.getAllBlocks().filter((function(e){return"t2c_text_join"===e.type&&-1!==i.indexOf(e.getInputTargetBlock("A"))&&-1!==d.indexOf(e.getInputTargetBlock("B"))})),p=o.getAllBlocks().filter((function(e){return"math_number"===e.type&&"17"==e.getFieldValue("NUM")})),f=o.getAllBlocks().filter((function(e){return"math_number"===e.type&&"9"==e.getFieldValue("NUM")})),m=o.getAllBlocks().filter((function(e){return"t2c_text_getsubstring"===e.type&&-1!==g.indexOf(e.getInputTargetBlock("STRING"))&&-1!==f.indexOf(e.getInputTargetBlock("AT1"))&&-1!==p.indexOf(e.getInputTargetBlock("AT2"))})),y=o.getAllBlocks().filter((function(e){return"t2c_text_join"===e.type&&-1!==m.indexOf(e.getInputTargetBlock("A"))&&-1!==h.indexOf(e.getInputTargetBlock("B"))})),T=o.getAllBlocks().filter((function(e){return"text_print"===e.type&&-1!==s.indexOf(e.getNextBlock())&&-1!==y.indexOf(e.getInputTargetBlock("TEXT"))})),_=o.getAllBlocks().filter((function(e){return"variables_get"===e.type&&"question"===e.getField("VAR").getText()})),b=o.getAllBlocks().filter((function(e){return"t2c_text_getsubstring"===e.type&&-1!==_.indexOf(e.getInputTargetBlock("STRING"))&&-1!==c.indexOf(e.getInputTargetBlock("AT1"))&&-1!==u.indexOf(e.getInputTargetBlock("AT2"))})),k=o.getAllBlocks().filter((function(e){return"t2c_text_join"===e.type&&-1!==i.indexOf(e.getInputTargetBlock("A"))&&-1!==b.indexOf(e.getInputTargetBlock("B"))})),x=o.getAllBlocks().filter((function(e){return"math_number"===e.type&&"18"==e.getFieldValue("NUM")})),E=o.getAllBlocks().filter((function(e){return"math_arithmetic_basic"===e.type&&-1!==x.indexOf(e.getInputTargetBlock("A"))&&-1!==c.indexOf(e.getInputTargetBlock("B"))&&"MINUS"==e.getFieldValue("OP")})),B=o.getAllBlocks().filter((function(e){return"math_number"===e.type&&"4"==e.getFieldValue("NUM")})),A=o.getAllBlocks().filter((function(e){return"math_arithmetic_basic"===e.type&&-1!==u.indexOf(e.getInputTargetBlock("A"))&&-1!==B.indexOf(e.getInputTargetBlock("B"))&&"ADD"==e.getFieldValue("OP")})),v=o.getAllBlocks().filter((function(e){return"t2c_text_getsubstring"===e.type&&-1!==_.indexOf(e.getInputTargetBlock("STRING"))&&-1!==A.indexOf(e.getInputTargetBlock("AT1"))&&-1!==E.indexOf(e.getInputTargetBlock("AT2"))})),I=o.getAllBlocks().filter((function(e){return"t2c_text_join"===e.type&&-1!==v.indexOf(e.getInputTargetBlock("A"))&&-1!==k.indexOf(e.getInputTargetBlock("B"))})),w=o.getAllBlocks().filter((function(e){return"text_print"===e.type&&-1!==T.indexOf(e.getNextBlock())&&-1!==I.indexOf(e.getInputTargetBlock("TEXT"))})),S=o.getAllBlocks().filter((function(e){return"variables_get"===e.type&&"part2"===e.getField("VAR").getText()})),M=o.getAllBlocks().filter((function(e){return"variables_get"===e.type&&"needle"===e.getField("VAR").getText()})),N=o.getAllBlocks().filter((function(e){return"t2c_text_join"===e.type&&-1!==M.indexOf(e.getInputTargetBlock("A"))&&-1!==S.indexOf(e.getInputTargetBlock("B"))})),L=o.getAllBlocks().filter((function(e){return"variables_get"===e.type&&"part1"===e.getField("VAR").getText()})),O=o.getAllBlocks().filter((function(e){return"t2c_text_join"===e.type&&-1!==L.indexOf(e.getInputTargetBlock("A"))&&-1!==N.indexOf(e.getInputTargetBlock("B"))})),C=o.getAllBlocks().filter((function(e){return"text_print"===e.type&&-1!==w.indexOf(e.getNextBlock())&&-1!==O.indexOf(e.getInputTargetBlock("TEXT"))})),R=o.getAllBlocks().filter((function(e){return"t2c_text_indexof"===e.type&&-1!==_.indexOf(e.getInputTargetBlock("VALUE"))&&-1!==M.indexOf(e.getInputTargetBlock("FIND"))})),F=o.getAllBlocks().filter((function(e){return"t2c_text_getsubstring"===e.type&&-1!==_.indexOf(e.getInputTargetBlock("STRING"))&&-1!==c.indexOf(e.getInputTargetBlock("AT1"))&&-1!==R.indexOf(e.getInputTargetBlock("AT2"))})),P=o.getAllBlocks().filter((function(e){return"variables_set"===e.type&&-1!==C.indexOf(e.getNextBlock())&&-1!==F.indexOf(e.getInputTargetBlock("VALUE"))&&"part2"===e.getField("VAR").getText()})),V=o.getAllBlocks().filter((function(e){return"t2c_text_length"===e.type&&-1!==_.indexOf(e.getInputTargetBlock("VALUE"))})),G=o.getAllBlocks().filter((function(e){return"math_arithmetic_basic"===e.type&&-1!==V.indexOf(e.getInputTargetBlock("A"))&&-1!==c.indexOf(e.getInputTargetBlock("B"))&&"MINUS"==e.getFieldValue("OP")})),U=o.getAllBlocks().filter((function(e){return"math_arithmetic_basic"===e.type&&-1!==R.indexOf(e.getInputTargetBlock("A"))&&-1!==B.indexOf(e.getInputTargetBlock("B"))&&"ADD"==e.getFieldValue("OP")})),X=o.getAllBlocks().filter((function(e){return"t2c_text_getsubstring"===e.type&&-1!==_.indexOf(e.getInputTargetBlock("STRING"))&&-1!==U.indexOf(e.getInputTargetBlock("AT1"))&&-1!==G.indexOf(e.getInputTargetBlock("AT2"))})),j=o.getAllBlocks().filter((function(e){return"variables_set"===e.type&&-1!==P.indexOf(e.getNextBlock())&&-1!==X.indexOf(e.getInputTargetBlock("VALUE"))&&"part1"===e.getField("VAR").getText()})),D=o.getAllBlocks().filter((function(e){return"variables_set"===e.type&&-1!==j.indexOf(e.getNextBlock())&&-1!==i.indexOf(e.getInputTargetBlock("VALUE"))&&"needle"===e.getField("VAR").getText()})),W=o.getAllBlocks().filter((function(e){return"variables_set"===e.type&&-1!==D.indexOf(e.getNextBlock())&&-1!==g.indexOf(e.getInputTargetBlock("VALUE"))&&"question"===e.getField("VAR").getText()}));return 1===e.length&&1===t.length&&1===n.length&&4===i.length&&1===r.length&&1===a.length&&1===l.length&&1===s.length&&3===u.length&&5===c.length&&3===g.length&&1===d.length&&1===h.length&&1===p.length&&1===f.length&&1===m.length&&1===y.length&&1===T.length&&7===_.length&&1===b.length&&1===k.length&&1===x.length&&1===E.length&&2===B.length&&1===A.length&&1===v.length&&1===I.length&&1===w.length&&1===S.length&&3===M.length&&1===N.length&&1===L.length&&1===O.length&&1===C.length&&2===R.length&&1===F.length&&1===P.length&&1===V.length&&1===G.length&&1===U.length&&1===X.length&&1===j.length&&1===D.length&&1===W.length}),new s((function(){for(var e=o.getAllBlocks(!0),t=e.filter((function(e){return"t2c_text_getsubstring"===e.type||"js_text_getsubstring"===e.type})).map((function(e){return e.getInputTargetBlock("STRING")})).filter((function(e){return e&&"text"===e.type})),n=e.filter((function(e){return"t2c_text_join"===e.type||"text_join"===e.type})).map((function(e){return e.getInputTargetBlock("B")})).filter((function(e){return e&&("t2c_text_join"===e.type||"text_join"===e.type)})).map((function(e){return e.getInputTargetBlock("A")})).filter((function(e){return e&&"text"===e.type})),i=e.filter((function(e){return"t2c_text_getsubstring"===e.type||"js_text_getsubstring"===e.type})).map((function(e){return e.getInputTargetBlock("AT1")})).filter((function(e){return e&&"math_arithmetic_basic"===e.type})).map((function(e){return e.getInputTargetBlock("A")})).find((function(e){return e&&"math_number"===e.type})),r=e.filter((function(e){return"t2c_text_getsubstring"===e.type||"js_text_getsubstring"===e.type})).map((function(e){return e.getInputTargetBlock("AT2")})).filter((function(e){return e&&"math_arithmetic_basic"===e.type})).map((function(e){return e.getInputTargetBlock("A")})).find((function(e){return e&&"math_number"===e.type})),a=e.filter((function(e){return"t2c_text_join"===e.type||"text_join"===e.type})).map((function(e){return e.getInputTargetBlock("B")})).filter((function(e){return e&&("t2c_text_getsubstring"===e.type||"js_text_getsubstring"===e.type)})).map((function(e){return e.getInputTargetBlock("AT2")})).filter((function(e){return e&&"math_number"===e.type})),l=e.filter((function(e){return"t2c_text_join"===e.type||"text_join"===e.type})).map((function(e){return e.getInputTargetBlock("A")})).filter((function(e){return e&&("t2c_text_getsubstring"===e.type||"js_text_getsubstring"===e.type)})).map((function(e){return e.getInputTargetBlock("AT1")})).find((function(e){return e&&"math_number"===e.type})),s=e.filter((function(e){return"t2c_text_join"===e.type||"text_join"===e.type})).map((function(e){return e.getInputTargetBlock("A")})).filter((function(e){return e&&("t2c_text_getsubstring"===e.type||"js_text_getsubstring"===e.type)})).map((function(e){return e.getInputTargetBlock("AT2")})).find((function(e){return e&&"math_number"===e.type})),u=e.filter((function(e){return("t2c_text_join"===e.type||"text_join"===e.type)&&e.getParent()&&("text_print"===e.getParent().type||"js_text_print"===e.getParent().type)})).map((function(e){return e.getInputTargetBlock("A")})).find((function(e){return e&&"text"===e.type})),c=e.filter((function(e){return"t2c_text_join"===e.type||"text_join"===e.type})).map((function(e){return e.getInputTargetBlock("B")})).filter((function(e){return e&&("t2c_text_join"===e.type||"text_join"===e.type)})).map((function(e){return e.getInputTargetBlock("B")})).find((function(e){return e&&"text"===e.type})),g=e.find((function(e){return"text"===e.type&&e.getParent()&&("text_print"===e.getParent().type||"js_text_print"===e.getParent().type)})),d="Where is the code?",h=d.indexOf(" is "),p=0;p<=1;p++){var f=t[p];if(f&&f.getFieldValue("TEXT")&&f.getFieldValue("TEXT")!==d)return"The text before the "+(0===p?"first ":"second ")+T2C.MSG.currentLanguage.TERMINAL_GETTEXTFROMPOSITIONNUMBER+" on line 7 is incorrect. Substitute question with the value that it's initially assigned to."}for(var m=0;m<=2;m++){var y=n[m];if(y&&y.getFieldValue("TEXT")&&" is "!==y.getFieldValue("TEXT"))return"The text after the first + (for string concatenation, NOT numbers) on line "+(m+6)+" is incorrect. Substitute needle with the value that it's initially assigned to (*including* a single space at the beginning *and* end)."}if(i&&i.getFieldValue("NUM")&&i.getFieldValue("NUM")!==h)return"The first number on line 6 (in the addition block) is incorrect. It should be the substitution of "+T2C.MSG.currentLanguage.TERMINAL_FINDFIRSTOCCURRENCEOFTEXT+", which will be the *starting* position of the first occurrence of the value of needle. Fix it accordingly.";if(r&&r.getFieldValue("NUM")&&r.getFieldValue("NUM")!==d.length)return"The third number on line 6 (in the subtraction block) should be the length of the value of question. Fix it accordingly.";for(var T=0;T<=1;T++){var _=a[T];if(_&&_.getFieldValue("NUM")&&_.getFieldValue("NUM")!==h)return"The last number on line "+(T+6)+" is incorrect. It should be the substitution of "+T2C.MSG.currentLanguage.TERMINAL_FINDFIRSTOCCURRENCEOFTEXT+", which will be the *starting* position of the first occurrence of the value of needle. Fix it accordingly."}return i&&i.getFieldValue("NUM")&&i.getFieldValue("NUM")===h&&l&&l.getFieldValue("NUM")&&l.getFieldValue("NUM")!==h+4?"The first number on line 7 should be the result of the addition with 4 from the previous line. Fix it accordingly.":r&&r.getFieldValue("NUM")&&r.getFieldValue("NUM")===d.length&&s&&s.getFieldValue("NUM")&&s.getFieldValue("NUM")!==d.length-1?"The second number on line 7 should be the result of the subtraction by 1 from the previous line. Fix it accordingly.":i&&i.getFieldValue("NUM")&&i.getFieldValue("NUM")===h&&l&&l.getFieldValue("NUM")&&l.getFieldValue("NUM")===h+4&&r&&r.getFieldValue("NUM")&&r.getFieldValue("NUM")===d.length&&s&&s.getFieldValue("NUM")&&s.getFieldValue("NUM")===d.length-1&&u&&u.getFieldValue("TEXT")&&u.getFieldValue("TEXT")!==d.substring(h+4,d.length-1)?"The first string on line 8 (before the text concatenation +) should be the result of the substitution of the first "+T2C.MSG.currentLanguage.TERMINAL_GETTEXTFROMPOSITIONNUMBER+". Fix it accordingly.":a[1]&&a[1].getFieldValue("NUM")&&a[1].getFieldValue("NUM")===h&&c&&c.getFieldValue("TEXT")&&c.getFieldValue("TEXT")!==d.substring(1,h)?"The last string on line 8 (after both text concatenation +) should be the result of the substitution of the second "+T2C.MSG.currentLanguage.TERMINAL_GETTEXTFROMPOSITIONNUMBER+". Fix it accordingly.":u&&u.getFieldValue("TEXT")&&u.getFieldValue("TEXT")===d.substring(h+4,d.length-1)&&n[2]&&n[2].getFieldValue("TEXT")&&" is "===n[2].getFieldValue("TEXT")&&c&&c.getFieldValue("TEXT")&&c.getFieldValue("TEXT")===d.substring(1,h)&&g&&g.getFieldValue("TEXT")&&g.getFieldValue("TEXT")!==d.substring(h+4,d.length-1)+" is "+d.substring(1,h)?"The string on the last line is incorrect; it should be the result of the substitution of the concatenation of the three strings above it on line 8.":"Replace all the blank string literals and 0's with the appropriate text and numbers that are substituted as the computer would from top to bottom so that every line of output is the same. Try to do this without running the program until you get the message to do so (when you filled in everything correctly)."}),{startPosition:te(o,null,{},50,document.getElementById("top-header").offsetHeight+50)}))),d(n),h(n,document.getElementById("output-container").querySelectorAll(".table-cell")[0]),n.addTask(new r((function(){return!0}),{start:function(){return!0},isComplete:function(){return!0},animate:function(){return!0},finish:function(){alert('👍 Bahut badhiya (Hindi for Very nice or Awesome)! Just as reading more books can make you a better writer, reading through code excerpts and "tracing" code as the computer does will make you a better code writer! It will also make you better at finding errors or bugs.\nIn the rest of this mission, you will get all of the text between the @ and the . in an e-mail address. As a warm-up exercise, you\'ll get everything after the @ to start.'),z(document.getElementById("output-container").querySelectorAll(".table-cell")[0]),K(),o.clear(),a.clearToolbox(),a.createToolboxBlock("type_in_get_email_input"),o.options.maxInstances.type_in_get_email_input=1}})),n.addTask(new r((function(){var e=o.getAllBlocks().find((function(e){return"text"===e.type&&(-1!==(e.getFieldValue("TEXT")||"").toLowerCase().indexOf("email")||-1!==(e.getFieldValue("TEXT")||"").toLowerCase().indexOf("e-mail"))})),t=o.getAllBlocks().find((function(t){return("text_input"===t.type||"js_text_input"===t.type)&&t.getInputTargetBlock("TEXT")===e})),n=o.getAllBlocks().find((function(e){return"variables_set"===e.type&&null===e.getNextBlock()&&e.getInputTargetBlock("VALUE")===t&&"email"===e.getField("VAR").getText()}));return e&&t&&n}),new s((function(){return"So now let's start applying these ideas to get the text appearing between the first @ and . in an e-mail address (e.g., google from coolcoder@google.com or mail from expertsoftwareengineer@mail.co.uk). First, let's ask the user for an e-mail address and store it in a variable email. Drag in the type-in-code block and type in the necessary code."}),{startPosition:te(o,null,{},50,document.getElementById("top-header").offsetHeight+50)}))),n.addTask(new r((function(){return!0}),{start:function(){return!0},isComplete:function(){return!0},animate:function(){return!0},finish:function(){var e=[1,1,1,2,1,1,1,1],t=o.getAllBlocks().find((function(e){return"variables_set"===e.type}));a.clearToolbox(),["t2c_text_getsubstring","t2c_text_length","text_print","variables_get","math_number","text","text_input","variables_set"].forEach((function(t,n){a.createToolboxBlock(t,!1),o.options.maxInstances[t]=e[n]})),t&&t.setCollapsed(!0),alert("✔ Nice, so as a warm-up and review, let's start by displaying everything that appears *after* the @ in any e-mail address where the text before the @ is exactly 9 characters, such as coolcoder@gmail.com using the "+T2C.MSG.currentLanguage.TERMINAL_GETTEXTFROMPOSITIONNUMBER+" and "+T2C.MSG.currentLanguage.TERMINAL_LENGTH+" blocks. We'll use a specific number for the starting position so it can't work in general, but we'll fix that soon by adding the new "+T2C.MSG.currentLanguage.TERMINAL_FINDFIRSTOCCURRENCEOFTEXT+" block.")}})),n.addTask(new r((function(){var e=o.getAllBlocks().filter((function(e){return"variables_get"===e.type&&"email"===e.getField("VAR").getText()})),t=o.getAllBlocks().find((function(t){return"t2c_text_length"===t.type&&-1!==e.indexOf(t.getInputTargetBlock("VALUE"))})),n=o.getAllBlocks().find((function(e){return"math_number"===e.type&&10===e.getFieldValue("NUM")})),i=o.getAllBlocks().find((function(o){return("t2c_text_getsubstring"===o.type||"js_text_getsubstring"===o.type)&&-1!==e.indexOf(o.getInputTargetBlock("STRING"))&&o.getInputTargetBlock("AT1")===n&&o.getInputTargetBlock("AT2")===t})),r=o.getAllBlocks().find((function(e){return("text_print"===e.type||"js_text_print"===e.type)&&null===e.getNextBlock()&&e.getInputTargetBlock("TEXT")===i})),a=o.getAllBlocks().find((function(e){return"text"===e.type&&(-1!==(e.getFieldValue("TEXT")||"").toLowerCase().indexOf("email")||-1!==(e.getFieldValue("TEXT")||"").toLowerCase().indexOf("e-mail"))})),l=o.getAllBlocks().find((function(e){return("text_input"===e.type||"js_text_input"===e.type)&&e.getInputTargetBlock("TEXT")===a})),s=o.getAllBlocks().find((function(e){return"variables_set"===e.type&&e.getNextBlock()===r&&e.getInputTargetBlock("VALUE")===l&&"email"===e.getField("VAR").getText()}));return 2===e.length&&t&&n&&i&&r&&a&&l&&s}),new s((function(){var e=o.getAllBlocks().find((function(e){return"text"===e.type&&(-1!==(e.getFieldValue("TEXT")||"").toLowerCase().indexOf("email")||-1!==(e.getFieldValue("TEXT")||"").toLowerCase().indexOf("e-mail"))})),t=o.getAllBlocks().find((function(t){return("text_input"===t.type||"js_text_input"===t.type)&&t.getInputTargetBlock("TEXT")===e})),n=o.getAllBlocks().find((function(e){return"variables_set"===e.type&&e.getInputTargetBlock("VALUE")===t&&"email"===e.getField("VAR").getText()})),i=o.getAllBlocks().filter((function(e){return"variables_get"===e.type})),r=o.getAllBlocks().find((function(e){return"t2c_text_length"===e.type})),a=o.getAllBlocks().find((function(e){return"math_number"===e.type})),l=o.getAllBlocks().find((function(e){return"t2c_text_getsubstring"===e.type||"js_text_getsubstring"===e.type})),s=o.getAllBlocks().find((function(e){return"text_print"===e.type||"js_text_print"===e.type}));if(i.find((function(e){return"email"!==e.getField("VAR").getText()})))return"Make sure the variable get blocks are both set to email so they refer to the one storing the entered e-mail.";if(n&&"email"!==n.getField("VAR").getText())return"Make sure the name of the variable storing the user's input stays email.";if(l){if(-1!==i.indexOf(l.getInputTargetBlock("AT1")))return"You placed the email block in the starting position of the "+T2C.MSG.currentLanguage.TERMINAL_GETTEXTFROMPOSITIONNUMBER+" block. But email stores a string, not a number; what would it mean to start extracting text at position *NUMBER* coolcoder@gmail.com?";if(-1!==i.indexOf(l.getInputTargetBlock("AT2")))return"You placed the email block in the ending position of the "+T2C.MSG.currentLanguage.TERMINAL_GETTEXTFROMPOSITIONNUMBER+" block. But email stores a string, not a number; what would it mean to stop extracting text at position *NUMBER* coolcoder@gmail.com?";if(r&&l.getInputTargetBlock("AT1")===r)return"You placed the "+T2C.MSG.currentLanguage.TERMINAL_LENGTH+" block in the starting position of the "+T2C.MSG.currentLanguage.TERMINAL_GETTEXTFROMPOSITIONNUMBER+" block. But for say coolcoder@gmail.com, the last position is at "+("coolcoder@gmail.com".length-1).toString()+" and its length is "+"coolcoder@gmail.com".length+". You certainly don't want to start extracting text at position 19, which doesn't even exist!";if(a&&l.getInputTargetBlock("AT2")===a)return"You cannot use a *specific* number for the ending position if you don't know how long the e-mail address is. Change the block in the last position of the "+T2C.MSG.currentLanguage.TERMINAL_GETTEXTFROMPOSITIONNUMBER+" block, accordingly.";if(a&&l.getInputTargetBlock("AT1")===a){var u=a.getFieldValue("NUM");if(11===u)return"The given starting position is incorrect. Remember that the initial character starts at position (index) 0 and unlike the given ending position to "+T2C.MSG.currentLanguage.TERMINAL_GETTEXTFROMPOSITIONNUMBER+", the computer starts extracting text from the first position number you give it.";if(9===u)return"The given starting position is incorrect. Remember that you want to start extracting text *after* the @ and unlike the given ending position to "+T2C.MSG.currentLanguage.TERMINAL_GETTEXTFROMPOSITIONNUMBER+", the computer starts extracting text from the first position number you give it.";if(u==="coolcoder@gmail.com".length)return"The first number given to "+T2C.MSG.currentLanguage.TERMINAL_GETTEXTFROMPOSITIONNUMBER+" is the starting position, not the ending one.";if(10!==u)return"Incorrect number for the starting position. Please try recounting the characters from the beginning of the string, starting from 0 until you get to the character after the @ sign."}}return s&&l&&s.getInputTargetBlock("TEXT")!==l?"As with the last exercise, you'll want to show a substring of the e-mail so the "+T2C.MSG.currentLanguage.TERMINAL_GETTEXTFROMPOSITIONNUMBER+" should be placed in "+T2C.MSG.currentLanguage.TERMINAL_DISPLAY+".":s&&n&&s.getNextBlock()===n?"Since instructions are run from top to bottom, you can't display a substring of email before the user enters it!":s&&null===s.getPreviousBlock()?"Be sure to attach the "+T2C.MSG.currentLanguage.TERMINAL_DISPLAY+" block below the "+T2C.MSG.currentLanguage.TERMINAL_LET+" block.":"Drag in and assemble the blocks of code so that the computer displays everything that appears *after* the @ in any entered e-mail address where the text before the @ is exactly 9 characters, such as coolcoder@gmail.com using the "+T2C.MSG.currentLanguage.TERMINAL_GETTEXTFROMPOSITIONNUMBER+" and "+T2C.MSG.currentLanguage.TERMINAL_LENGTH+" blocks. For this part, use a specific number for the starting position."}),{startPosition:te(o,null,{},50,document.getElementById("top-header").offsetHeight+50)}))),d(n),h(n,document.getElementById("output-container").querySelectorAll(".table-cell")[0]),n.addTask(new r((function(){return!0}),{start:function(){return!0},isComplete:function(){return!0},animate:function(){return!0},finish:function(){var e=[1,1,2,3,1,1,1,1,1,1],t=o.getAllBlocks().filter((function(e){return"variables_get"===e.type||"t2c_text_length"===e.type}));alert("✔ Good, so did you type in coolcoder@google.com or some other e-mail address with 9 characters before the @, or did you enjoy breaking the rules and watching it fail?!! Well, now it's time to make it work for those troublemakers so long as they're kind enough to enter an @.\nTo do this, we'll use our new "+T2C.MSG.currentLanguage.TERMINAL_FINDFIRSTOCCURRENCEOFTEXT+" and will need some arithmetic as well."),z(document.getElementById("output-container").querySelectorAll(".table-cell")[0]),K(),a.clearToolbox(),["t2c_text_indexof","math_arithmetic_basic","text","variables_get","math_number","t2c_text_getsubstring","t2c_text_length","text_print","text_input","variables_set"].forEach((function(t,n){a.createToolboxBlock(t,!1),o.options.maxInstances[t]=e[n]})),t.forEach((function(e){return e.setCollapsed(!0)}))}})),n.addTask(new r((function(){var e=o.getAllBlocks().filter((function(e){return"variables_get"===e.type&&"email"===e.getField("VAR").getText()})),t=o.getAllBlocks().find((function(t){return"t2c_text_length"===t.type&&-1!==e.indexOf(t.getInputTargetBlock("VALUE"))})),n=o.getAllBlocks().find((function(e){return"math_number"===e.type&&1===e.getFieldValue("NUM")})),i=o.getAllBlocks().find((function(e){return"text"===e.type&&"@"==e.getFieldValue("TEXT")})),r=o.getAllBlocks().find((function(t){return("t2c_text_indexof"===t.type||"js_text_indexof"===t.type)&&-1!==e.indexOf(t.getInputTargetBlock("VALUE"))&&t.getInputTargetBlock("FIND")===i})),a=o.getAllBlocks().find((function(e){return"math_arithmetic_basic"===e.type&&(e.getInputTargetBlock("A")===r&&e.getInputTargetBlock("B")===n||e.getInputTargetBlock("B")===r&&e.getInputTargetBlock("A")===n)&&"ADD"==e.getFieldValue("OP")})),l=o.getAllBlocks().find((function(n){return("t2c_text_getsubstring"===n.type||"js_text_getsubstring"===n.type)&&-1!==e.indexOf(n.getInputTargetBlock("STRING"))&&n.getInputTargetBlock("AT1")===a&&n.getInputTargetBlock("AT2")===t})),s=o.getAllBlocks().find((function(e){return("text_print"===e.type||"js_text_print"===e.type)&&null===e.getNextBlock()&&e.getInputTargetBlock("TEXT")===l})),u=o.getAllBlocks().find((function(e){return"text"===e.type&&(-1!==(e.getFieldValue("TEXT")||"").toLowerCase().indexOf("email")||-1!==(e.getFieldValue("TEXT")||"").toLowerCase().indexOf("e-mail"))})),c=o.getAllBlocks().find((function(e){return("text_input"===e.type||"js_text_input"===e.type)&&e.getInputTargetBlock("TEXT")===u})),g=o.getAllBlocks().find((function(e){return"variables_set"===e.type&&e.getNextBlock()===s&&e.getInputTargetBlock("VALUE")===c&&"email"===e.getField("VAR").getText()}));return 3===e.length&&t&&n&&i&&r&&a&&l&&s&&u&&c&&g}),new s((function(){var e=o.getAllBlocks().find((function(e){return"text"===e.type&&(-1!==(e.getFieldValue("TEXT")||"").toLowerCase().indexOf("email")||-1!==(e.getFieldValue("TEXT")||"").toLowerCase().indexOf("e-mail"))})),t=o.getAllBlocks().find((function(t){return("text_input"===t.type||"js_text_input"===t.type)&&t.getInputTargetBlock("TEXT")===e})),n=o.getAllBlocks().find((function(e){return"variables_set"===e.type&&e.getInputTargetBlock("VALUE")===t&&"email"===e.getField("VAR").getText()})),i=o.getAllBlocks().filter((function(e){return"variables_get"===e.type})),r=o.getAllBlocks().find((function(e){return"t2c_text_length"===e.type})),a=o.getAllBlocks().find((function(e){return"math_number"===e.type})),l=o.getAllBlocks().find((function(t){return"text"===t.type&&t!==e})),s=o.getAllBlocks().find((function(e){return"t2c_text_indexof"===e.type||"js_text_indexof"===e.type})),u=o.getAllBlocks().find((function(e){return"math_arithmetic_basic"===e.type})),c=o.getAllBlocks().find((function(e){return"t2c_text_getsubstring"===e.type||"js_text_getsubstring"===e.type})),g=o.getAllBlocks().find((function(e){return"text_print"===e.type||"js_text_print"===e.type})),d="coolcoder@gmail.com";if(s){if(l&&s.getInputTargetBlock("VALUE")===l)return"The first space in the "+T2C.MSG.currentLanguage.TERMINAL_FINDFIRSTOCCURRENCEOFTEXT+" block is for the string you want to search through (proverbial haystack), not the string you're looking for (proverbial needle) so you'll want to move the text block, accordingly.";if(-1!==i.indexOf(s.getInputTargetBlock("FIND")))return"The second space in the "+T2C.MSG.currentLanguage.TERMINAL_FINDFIRSTOCCURRENCEOFTEXT+" block is for the string you're looking for (proverbial needle), not the one you want to search through (proverbial haystack) so you'll want to move the variable get block, accordingly.";if(l&&s.getInputTargetBlock("FIND")===l){var h=l.getFieldValue("TEXT")||"";if(""===h)return"Type in something the text (needle) you're searching for in the block with quotes";if("."===h)return"You don't know how many characters there may be before the period after the at sign as this can depend on the e-mail address so this won't work for calculating the starting position.";if("at"===h.toLowerCase())return"The literal 2-character string "+h.toLowerCase()+" will not necessarily appear in the address. You don't need to use letters for the needle (string your searching for); you can use symbols as well.";if("@"!==h)return"It's possible that "+h+" won't necessarily appear in an e-mail address, or at least it won't help you calculate the desired starting position. Try something else.";if(c&&c.getInputTargetBlock("AT1")===s)return"You'll need to perform a math operation on the position number of the @ since if you start extracting text at the position of the @, the string you get back will always start with an @! For example, for "+d+", you'd start extracting text at position "+d.indexOf("@")+", which means you'd get "+d.substring(d.indexOf("@"))+". What do you do with this number if you'd want to start at position number "+(d.indexOf("@")+1).toString()+", the position of the "+d.charAt(d.indexOf("@")+1)+" immediately after the @ instead?"}}if(u){if(i.find((function(e){return e===u.getInputTargetBlock("A")||e===u.getInputTargetBlock("B")})))return"The variable email holds a string such as "+d+", not a number so what would it mean to perform a math operation on it? Remove it from the arithmetic block, accordingly.";if(s&&a&&(u.getInputTargetBlock("A")===s&&u.getInputTargetBlock("B")===a||u.getInputTargetBlock("B")===s&&u.getInputTargetBlock("A")===a)){var p=a.getFieldValue("NUM"),f=u.getFieldValue("OP");if(u.getInputTargetBlock("B")===a&&"MINUS"===f&&-1===p)return"Although you can subtract -1, it's clearer to add 1 so switch the operation to addition and the number from -1 to 1.";if(u.getInputTargetBlock("B")===a&&"MINUS"===f&&1===p)return"Subtracting 1 from the answer will move your position back one. Do you want to start extracting text 1 place before?";if("ADD"!==f||1!==p)return"Using your given operation and number, the starting position you're calculating does not seem to work for every e-mail address in general. Try (re)examining some e-mail addresses and the specific starting positions of the calculations for these examples to help you see your error."}}if(i.find((function(e){return"email"!==e.getField("VAR").getText()})))return"Make sure the variable get blocks are all set to email so they refer to the one storing the entered e-mail.";if(n&&"email"!==n.getField("VAR").getText())return"Make sure the name of the variable storing the user's input stays email.";if(c){if(-1!==i.indexOf(c.getInputTargetBlock("AT1")))return"You placed the email block in the starting position of the "+T2C.MSG.currentLanguage.TERMINAL_GETTEXTFROMPOSITIONNUMBER+" block. But email stores a string, not a number; what would it mean to start extracting text at position *NUMBER* coolcoder@gmail.com?";if(-1!==i.indexOf(c.getInputTargetBlock("AT2")))return"You placed the email block in the ending position of the "+T2C.MSG.currentLanguage.TERMINAL_GETTEXTFROMPOSITIONNUMBER+" block. But email stores a string, not a number; what would it mean to stop extracting text at position *NUMBER* coolcoder@gmail.com?";if(r&&c.getInputTargetBlock("AT1")===r)return"You placed the "+T2C.MSG.currentLanguage.TERMINAL_LENGTH+" block in the starting position of the "+T2C.MSG.currentLanguage.TERMINAL_GETTEXTFROMPOSITIONNUMBER+" block. But for say "+d+", the last position is at "+(d.length-1).toString()+" and its length is "+d.length+". You certainly don't want to start extracting text at position 19, which doesn't even exist!";if(a&&c.getInputTargetBlock("AT2")===a)return"You cannot use a *specific* number for the ending position if you don't know how long the e-mail address is. Change the block in the last position of the "+T2C.MSG.currentLanguage.TERMINAL_GETTEXTFROMPOSITIONNUMBER+" block, accordingly."}return g&&c&&g.getInputTargetBlock("TEXT")!==c?"As with the last exercise, you'll want to show a substring of the e-mail so the "+T2C.MSG.currentLanguage.TERMINAL_GETTEXTFROMPOSITIONNUMBER+" should be placed in "+T2C.MSG.currentLanguage.TERMINAL_DISPLAY+".":g&&n&&g.getNextBlock()===n?"Since instructions are run from top to bottom, you can't display a substring of email before the user enters it!":g&&null===g.getPreviousBlock()?"Be sure to attach the "+T2C.MSG.currentLanguage.TERMINAL_DISPLAY+" block below the "+T2C.MSG.currentLanguage.TERMINAL_LET+" block.":"Use the new "+T2C.MSG.currentLanguage.TERMINAL_FINDFIRSTOCCURRENCEOFTEXT+" and arithmetic blocks in the place of the starting position of the specific number 10 you currently have in the "+T2C.MSG.currentLanguage.TERMINAL_GETTEXTFROMPOSITIONNUMBER+" block so that the computer displays everything that appears *after* the @ in any entered e-mail address, regardless of how long the text is before the @.\nHINT: If you didn't know what email was but you were able to ask for the position number of whatever character(s) you want, what position would you ask for? Once you had that position, what math operation would you use to get the starting position of the string after the @? Make sure your calculations work on coolcoder@google.com, jdoe@foo.edu, or any other e-mail address!"}),{startPosition:te(o,null,{},50,document.getElementById("top-header").offsetHeight+50)}))),d(n),h(n,document.getElementById("output-container").querySelectorAll(".table-cell")[0]),n.addTask(new r((function(){return!0}),{start:function(){return!0},isComplete:function(){return!0},animate:function(){return!0},finish:function(){var e=[1,1,1,2,3,1,1,1,1,1,1],t=o.getAllBlocks().filter((function(e){return"text_print"===e.type||"js_text_print"===e.type}));alert("✔ Great work! So now let's return to the original task, to get the text between the first @ and the first ., e.g., the google in coolcoder@google.com or the mail in expertsoftwareengineer@mail.co.uk. To simplify, we'll assume the first . always follows the first @, which may not always be the case in an e-mail address (e.g., jane.doe@gmail.com). So are you up to the task of typing it all in! You'll use two "+T2C.MSG.currentLanguage.TERMINAL_FINDFIRSTOCCURRENCEOFTEXT+" this time."),K(),a.clearToolbox(),["type_in_between_at_and_period","t2c_text_indexof","math_arithmetic_basic","text","variables_get","math_number","t2c_text_getsubstring","t2c_text_length","text_print","text_input","variables_set"].forEach((function(t,n){a.createToolboxBlock(t,!1),o.options.maxInstances[t]=e[n]})),t.forEach((function(e){return e.setCollapsed(!0)}))}})),n.addTask(new r((function(){var e=o.getAllBlocks().filter((function(e){return"variables_get"===e.type&&"email"===e.getField("VAR").getText()})),t=o.getAllBlocks().find((function(t){return"t2c_text_length"===t.type&&-1!==e.indexOf(t.getInputTargetBlock("VALUE"))})),n=o.getAllBlocks().filter((function(e){return"math_number"===e.type&&1===e.getFieldValue("NUM")})),i=o.getAllBlocks().filter((function(e){return"text"===e.type&&"@"==e.getFieldValue("TEXT")})),r=o.getAllBlocks().filter((function(t){return("t2c_text_indexof"===t.type||"js_text_indexof"===t.type)&&-1!==e.indexOf(t.getInputTargetBlock("VALUE"))&&-1!==i.indexOf(t.getInputTargetBlock("FIND"))})),a=o.getAllBlocks().filter((function(e){return"math_arithmetic_basic"===e.type&&(-1!==r.indexOf(e.getInputTargetBlock("A"))&&-1!==n.indexOf(e.getInputTargetBlock("B"))||-1!==r.indexOf(e.getInputTargetBlock("B"))&&e.getInputTargetBlock("A")===n)&&"ADD"==e.getFieldValue("OP")})),l=o.getAllBlocks().find((function(n){return("t2c_text_getsubstring"===n.type||"js_text_getsubstring"===n.type)&&-1!==e.indexOf(n.getInputTargetBlock("STRING"))&&-1!==a.indexOf(n.getInputTargetBlock("AT1"))&&n.getInputTargetBlock("AT2")===t})),s=o.getAllBlocks().find((function(e){return("text_print"===e.type||"js_text_print"===e.type)&&null!==e.getPreviousBlock()&&e.getInputTargetBlock("TEXT")===l})),u=o.getAllBlocks().find((function(e){return"text"===e.type&&(-1!==(e.getFieldValue("TEXT")||"").toLowerCase().indexOf("email")||-1!==(e.getFieldValue("TEXT")||"").toLowerCase().indexOf("e-mail"))})),c=o.getAllBlocks().find((function(e){return("text_input"===e.type||"js_text_input"===e.type)&&e.getInputTargetBlock("TEXT")===u})),g=o.getAllBlocks().find((function(e){return"variables_set"===e.type&&e.getNextBlock()===s&&e.getInputTargetBlock("VALUE")===c&&"email"===e.getField("VAR").getText()})),d=o.getAllBlocks().find((function(e){return"text"===e.type&&"."==e.getFieldValue("TEXT")})),h=o.getAllBlocks().find((function(t){return("t2c_text_indexof"===t.type||"js_text_indexof"===t.type)&&-1!==e.indexOf(t.getInputTargetBlock("VALUE"))&&t.getInputTargetBlock("FIND")===d})),p=o.getAllBlocks().find((function(t){return("t2c_text_getsubstring"===t.type||"js_text_getsubstring"===t.type)&&-1!==e.indexOf(t.getInputTargetBlock("STRING"))&&-1!==a.indexOf(t.getInputTargetBlock("AT1"))&&t.getInputTargetBlock("AT2")===h})),f=o.getAllBlocks().find((function(e){return"text_print"===e.type&&e.getPreviousBlock()===s&&e.getInputTargetBlock("TEXT")===p}));return 6===e.length&&t&&2===n.length&&2===i.length&&2===r.length&&2===a.length&&l&&s&&u&&c&&g&&d&&h&&p&&f}),new s((function(){var e=o.getAllBlocks().find((function(e){return"text"===e.type&&(-1!==(e.getFieldValue("TEXT")||"").toLowerCase().indexOf("email")||-1!==(e.getFieldValue("TEXT")||"").toLowerCase().indexOf("e-mail"))})),t=o.getAllBlocks().find((function(t){return("text_input"===t.type||"js_text_input"===t.type)&&t.getInputTargetBlock("TEXT")===e})),n=o.getAllBlocks().find((function(e){return"variables_set"===e.type&&e.getInputTargetBlock("VALUE")===t&&"email"===e.getField("VAR").getText()})),i=o.getAllBlocks().filter((function(e){return"variables_get"===e.type})),r=(o.getAllBlocks().find((function(e){return"t2c_text_length"===e.type})),o.getAllBlocks().find((function(e){return"math_number"===e.type})),o.getAllBlocks().find((function(t){return"text"===t.type&&t!==e})),o.getAllBlocks().find((function(e){return"t2c_text_indexof"===e.type||"js_text_indexof"===e.type})),o.getAllBlocks().filter((function(e){return"math_arithmetic_basic"===e.type}))),a=(o.getAllBlocks().find((function(e){return"t2c_text_getsubstring"===e.type||"js_text_getsubstring"===e.type})),o.getAllBlocks().find((function(e){return"text_print"===e.type||"js_text_print"===e.type}))),l=o.getAllBlocks().find((function(e){return"text"===e.type&&"."==e.getFieldValue("TEXT")})),s=o.getAllBlocks().find((function(e){return("t2c_text_indexof"===e.type||"js_text_indexof"===e.type)&&-1!==i.indexOf(e.getInputTargetBlock("VALUE"))&&e.getInputTargetBlock("FIND")===l})),u=o.getAllBlocks().find((function(e){return("t2c_text_getsubstring"===e.type||"js_text_getsubstring"===e.type)&&-1!==i.indexOf(e.getInputTargetBlock("STRING"))&&-1!==r.indexOf(e.getInputTargetBlock("AT1"))&&e.getInputTargetBlock("AT2")===s})),c=o.getAllBlocks().find((function(e){return"text_print"===e.type&&e.getInputTargetBlock("TEXT")===u}));return c&&n&&c.getNextBlock()===n?"Since instructions are run from top to bottom, you can't display a substring of email before the user enters it!":c&&null===a.getPreviousBlock()?"Be sure to attach the "+T2C.MSG.currentLanguage.TERMINAL_DISPLAY+" block below the previous "+T2C.MSG.currentLanguage.TERMINAL_DISPLAY+" block.":"Drag the type-in-code block, and attach it to the below the previously assembled "+T2C.MSG.currentLanguage.TERMINAL_DISPLAY+" block. Then type the necessary code to get the text between the first @ and the first ., e.g., the google in coolcoder@google.com or the mail in expertsoftwareengineer@mail.co.uk. HINT: Use "+T2C.MSG.currentLanguage.TERMINAL_GETTEXTFROMPOSITIONNUMBER+" as you did before, but consider how you'd use a second "+T2C.MSG.currentLanguage.TERMINAL_FINDFIRSTOCCURRENCEOFTEXT+" to *stop* at the correct position number this time as you'd no longer use "+T2C.MSG.currentLanguage.TERMINAL_LENGTH+" since you don't want to stop at the end. As before, make sure your calculations simultaneously work on coolcoder@google.com (start #: 10, end before #: 16), expertsoftwareengineer@mail.co.uk (start #: 23, end before #: 27), and jdoe@foo.edu (start #: 5, end before #: 8), or any other e-mail address by substituting as you did at the beginning."}),{startPosition:te(o,null,{},50,document.getElementById("top-header").offsetHeight+50)}))),d(n),h(n,document.getElementById("output-container").querySelectorAll(".table-cell")[0]),n.addTask(new r((function(){return!0}),{start:function(){return!0},isComplete:function(){return!0},animate:function(){return!0},finish:function(){alert("✔✔✔ Outstanding! And with that, Mission # 5 is accomplished! In the next mission, we'll take an input of last name, first name and display it as first name last name. E.g., Doe, Jane would result in Jane Doe. No new blocks next time, just more challenges with the existing ones! Until next time!"),K(),a.clearToolbox(),["code_statement"].forEach((function(e,t){a.createToolboxBlock(e,!1),o.options.maxInstances[e]=maxBlocks[t]}))}})),n},function(e,t){var n=e||new c,o=t||Blockly.getMainWorkspace(),a=new f(o);o.setScale(1),Object(i.f)(o);var g=document.createElement("div");return g.innerText="👆",g.id="ptr",g.style.fontSize="x-large",g.style.position="absolute",g.style.zIndex="1001",document.getElementById("blockly-div").appendChild(g),n.addTask(new r((function(){return!0}),{start:function(){return!0},isComplete:function(){return!0},animate:function(){return!0},finish:function(){alert("In this mission, we'll take an input of last name, first name and display it as first name last name. E.g., Doe, Jane would result in Jane Doe. To remember how we can use the blocks we'll need for this task, let's redo the last code tracing exercise from the last mission."),o.clear(),Blockly.Xml.domToWorkspace(Blockly.Xml.textToDom('questionneedlepart1part2questionWhere is the code?needle is part1questionADDquestionneedle4MINUSquestion1part2question1questionneedlepart1needlepart2questionADD04MINUS01question100010'),o),Blockly.svgResize(o),o.getAllBlocks().forEach((function(e){return e.setMovable(!1)})),oe(document.getElementById("output-container").querySelectorAll(".table-cell")[0]),ie()}})),n.addTask(new r((function(){var e=o.getAllBlocks().filter((function(e){return"text"===e.type&&"the code is here"==e.getFieldValue("TEXT")})),t=o.getAllBlocks().filter((function(t){return"text_print"===t.type&&null===t.getNextBlock()&&-1!==e.indexOf(t.getInputTargetBlock("TEXT"))})),n=o.getAllBlocks().filter((function(e){return"text"===e.type&&"here"==e.getFieldValue("TEXT")})),i=o.getAllBlocks().filter((function(e){return"text"===e.type&&" is "==e.getFieldValue("TEXT")})),r=o.getAllBlocks().filter((function(e){return"t2c_text_join"===e.type&&-1!==i.indexOf(e.getInputTargetBlock("A"))&&-1!==n.indexOf(e.getInputTargetBlock("B"))})),a=o.getAllBlocks().filter((function(e){return"text"===e.type&&"the code"==e.getFieldValue("TEXT")})),l=o.getAllBlocks().filter((function(e){return"t2c_text_join"===e.type&&-1!==a.indexOf(e.getInputTargetBlock("A"))&&-1!==r.indexOf(e.getInputTargetBlock("B"))})),s=o.getAllBlocks().filter((function(e){return"text_print"===e.type&&-1!==t.indexOf(e.getNextBlock())&&-1!==l.indexOf(e.getInputTargetBlock("TEXT"))})),u=o.getAllBlocks().filter((function(e){return"math_number"===e.type&&"5"==e.getFieldValue("NUM")})),c=o.getAllBlocks().filter((function(e){return"math_number"===e.type&&"1"==e.getFieldValue("NUM")})),g=o.getAllBlocks().filter((function(e){return"text"===e.type&&"Where is the code?"==e.getFieldValue("TEXT")})),d=o.getAllBlocks().filter((function(e){return"t2c_text_getsubstring"===e.type&&-1!==g.indexOf(e.getInputTargetBlock("STRING"))&&-1!==c.indexOf(e.getInputTargetBlock("AT1"))&&-1!==u.indexOf(e.getInputTargetBlock("AT2"))})),h=o.getAllBlocks().filter((function(e){return"t2c_text_join"===e.type&&-1!==i.indexOf(e.getInputTargetBlock("A"))&&-1!==d.indexOf(e.getInputTargetBlock("B"))})),p=o.getAllBlocks().filter((function(e){return"math_number"===e.type&&"17"==e.getFieldValue("NUM")})),f=o.getAllBlocks().filter((function(e){return"math_number"===e.type&&"9"==e.getFieldValue("NUM")})),m=o.getAllBlocks().filter((function(e){return"t2c_text_getsubstring"===e.type&&-1!==g.indexOf(e.getInputTargetBlock("STRING"))&&-1!==f.indexOf(e.getInputTargetBlock("AT1"))&&-1!==p.indexOf(e.getInputTargetBlock("AT2"))})),y=o.getAllBlocks().filter((function(e){return"t2c_text_join"===e.type&&-1!==m.indexOf(e.getInputTargetBlock("A"))&&-1!==h.indexOf(e.getInputTargetBlock("B"))})),T=o.getAllBlocks().filter((function(e){return"text_print"===e.type&&-1!==s.indexOf(e.getNextBlock())&&-1!==y.indexOf(e.getInputTargetBlock("TEXT"))})),_=o.getAllBlocks().filter((function(e){return"variables_get"===e.type&&"question"===e.getField("VAR").getText()})),b=o.getAllBlocks().filter((function(e){return"t2c_text_getsubstring"===e.type&&-1!==_.indexOf(e.getInputTargetBlock("STRING"))&&-1!==c.indexOf(e.getInputTargetBlock("AT1"))&&-1!==u.indexOf(e.getInputTargetBlock("AT2"))})),k=o.getAllBlocks().filter((function(e){return"t2c_text_join"===e.type&&-1!==i.indexOf(e.getInputTargetBlock("A"))&&-1!==b.indexOf(e.getInputTargetBlock("B"))})),x=o.getAllBlocks().filter((function(e){return"math_number"===e.type&&"18"==e.getFieldValue("NUM")})),E=o.getAllBlocks().filter((function(e){return"math_arithmetic_basic"===e.type&&-1!==x.indexOf(e.getInputTargetBlock("A"))&&-1!==c.indexOf(e.getInputTargetBlock("B"))&&"MINUS"==e.getFieldValue("OP")})),B=o.getAllBlocks().filter((function(e){return"math_number"===e.type&&"4"==e.getFieldValue("NUM")})),A=o.getAllBlocks().filter((function(e){return"math_arithmetic_basic"===e.type&&-1!==u.indexOf(e.getInputTargetBlock("A"))&&-1!==B.indexOf(e.getInputTargetBlock("B"))&&"ADD"==e.getFieldValue("OP")})),v=o.getAllBlocks().filter((function(e){return"t2c_text_getsubstring"===e.type&&-1!==_.indexOf(e.getInputTargetBlock("STRING"))&&-1!==A.indexOf(e.getInputTargetBlock("AT1"))&&-1!==E.indexOf(e.getInputTargetBlock("AT2"))})),I=o.getAllBlocks().filter((function(e){return"t2c_text_join"===e.type&&-1!==v.indexOf(e.getInputTargetBlock("A"))&&-1!==k.indexOf(e.getInputTargetBlock("B"))})),w=o.getAllBlocks().filter((function(e){return"text_print"===e.type&&-1!==T.indexOf(e.getNextBlock())&&-1!==I.indexOf(e.getInputTargetBlock("TEXT"))})),S=o.getAllBlocks().filter((function(e){return"variables_get"===e.type&&"part2"===e.getField("VAR").getText()})),M=o.getAllBlocks().filter((function(e){return"variables_get"===e.type&&"needle"===e.getField("VAR").getText()})),N=o.getAllBlocks().filter((function(e){return"t2c_text_join"===e.type&&-1!==M.indexOf(e.getInputTargetBlock("A"))&&-1!==S.indexOf(e.getInputTargetBlock("B"))})),L=o.getAllBlocks().filter((function(e){return"variables_get"===e.type&&"part1"===e.getField("VAR").getText()})),O=o.getAllBlocks().filter((function(e){return"t2c_text_join"===e.type&&-1!==L.indexOf(e.getInputTargetBlock("A"))&&-1!==N.indexOf(e.getInputTargetBlock("B"))})),C=o.getAllBlocks().filter((function(e){return"text_print"===e.type&&-1!==w.indexOf(e.getNextBlock())&&-1!==O.indexOf(e.getInputTargetBlock("TEXT"))})),R=o.getAllBlocks().filter((function(e){return"t2c_text_indexof"===e.type&&-1!==_.indexOf(e.getInputTargetBlock("VALUE"))&&-1!==M.indexOf(e.getInputTargetBlock("FIND"))})),F=o.getAllBlocks().filter((function(e){return"t2c_text_getsubstring"===e.type&&-1!==_.indexOf(e.getInputTargetBlock("STRING"))&&-1!==c.indexOf(e.getInputTargetBlock("AT1"))&&-1!==R.indexOf(e.getInputTargetBlock("AT2"))})),P=o.getAllBlocks().filter((function(e){return"variables_set"===e.type&&-1!==C.indexOf(e.getNextBlock())&&-1!==F.indexOf(e.getInputTargetBlock("VALUE"))&&"part2"===e.getField("VAR").getText()})),V=o.getAllBlocks().filter((function(e){return"t2c_text_length"===e.type&&-1!==_.indexOf(e.getInputTargetBlock("VALUE"))})),G=o.getAllBlocks().filter((function(e){return"math_arithmetic_basic"===e.type&&-1!==V.indexOf(e.getInputTargetBlock("A"))&&-1!==c.indexOf(e.getInputTargetBlock("B"))&&"MINUS"==e.getFieldValue("OP")})),U=o.getAllBlocks().filter((function(e){return"math_arithmetic_basic"===e.type&&-1!==R.indexOf(e.getInputTargetBlock("A"))&&-1!==B.indexOf(e.getInputTargetBlock("B"))&&"ADD"==e.getFieldValue("OP")})),X=o.getAllBlocks().filter((function(e){return"t2c_text_getsubstring"===e.type&&-1!==_.indexOf(e.getInputTargetBlock("STRING"))&&-1!==U.indexOf(e.getInputTargetBlock("AT1"))&&-1!==G.indexOf(e.getInputTargetBlock("AT2"))})),j=o.getAllBlocks().filter((function(e){return"variables_set"===e.type&&-1!==P.indexOf(e.getNextBlock())&&-1!==X.indexOf(e.getInputTargetBlock("VALUE"))&&"part1"===e.getField("VAR").getText()})),D=o.getAllBlocks().filter((function(e){return"variables_set"===e.type&&-1!==j.indexOf(e.getNextBlock())&&-1!==i.indexOf(e.getInputTargetBlock("VALUE"))&&"needle"===e.getField("VAR").getText()})),W=o.getAllBlocks().filter((function(e){return"variables_set"===e.type&&-1!==D.indexOf(e.getNextBlock())&&-1!==g.indexOf(e.getInputTargetBlock("VALUE"))&&"question"===e.getField("VAR").getText()}));return 1===e.length&&1===t.length&&1===n.length&&4===i.length&&1===r.length&&1===a.length&&1===l.length&&1===s.length&&3===u.length&&5===c.length&&3===g.length&&1===d.length&&1===h.length&&1===p.length&&1===f.length&&1===m.length&&1===y.length&&1===T.length&&7===_.length&&1===b.length&&1===k.length&&1===x.length&&1===E.length&&2===B.length&&1===A.length&&1===v.length&&1===I.length&&1===w.length&&1===S.length&&3===M.length&&1===N.length&&1===L.length&&1===O.length&&1===C.length&&2===R.length&&1===F.length&&1===P.length&&1===V.length&&1===G.length&&1===U.length&&1===X.length&&1===j.length&&1===D.length&&1===W.length}),new s((function(){for(var e=o.getAllBlocks(!0),t=e.filter((function(e){return"t2c_text_getsubstring"===e.type||"js_text_getsubstring"===e.type})).map((function(e){return e.getInputTargetBlock("STRING")})).filter((function(e){return e&&"text"===e.type})),n=e.filter((function(e){return"t2c_text_join"===e.type||"text_join"===e.type})).map((function(e){return e.getInputTargetBlock("B")})).filter((function(e){return e&&("t2c_text_join"===e.type||"text_join"===e.type)})).map((function(e){return e.getInputTargetBlock("A")})).filter((function(e){return e&&"text"===e.type})),i=e.filter((function(e){return"t2c_text_getsubstring"===e.type||"js_text_getsubstring"===e.type})).map((function(e){return e.getInputTargetBlock("AT1")})).filter((function(e){return e&&"math_arithmetic_basic"===e.type})).map((function(e){return e.getInputTargetBlock("A")})).find((function(e){return e&&"math_number"===e.type})),r=e.filter((function(e){return"t2c_text_getsubstring"===e.type||"js_text_getsubstring"===e.type})).map((function(e){return e.getInputTargetBlock("AT2")})).filter((function(e){return e&&"math_arithmetic_basic"===e.type})).map((function(e){return e.getInputTargetBlock("A")})).find((function(e){return e&&"math_number"===e.type})),a=e.filter((function(e){return"t2c_text_join"===e.type||"text_join"===e.type})).map((function(e){return e.getInputTargetBlock("B")})).filter((function(e){return e&&("t2c_text_getsubstring"===e.type||"js_text_getsubstring"===e.type)})).map((function(e){return e.getInputTargetBlock("AT2")})).filter((function(e){return e&&"math_number"===e.type})),l=e.filter((function(e){return"t2c_text_join"===e.type||"text_join"===e.type})).map((function(e){return e.getInputTargetBlock("A")})).filter((function(e){return e&&("t2c_text_getsubstring"===e.type||"js_text_getsubstring"===e.type)})).map((function(e){return e.getInputTargetBlock("AT1")})).find((function(e){return e&&"math_number"===e.type})),s=e.filter((function(e){return"t2c_text_join"===e.type||"text_join"===e.type})).map((function(e){return e.getInputTargetBlock("A")})).filter((function(e){return e&&("t2c_text_getsubstring"===e.type||"js_text_getsubstring"===e.type)})).map((function(e){return e.getInputTargetBlock("AT2")})).find((function(e){return e&&"math_number"===e.type})),u=e.filter((function(e){return("t2c_text_join"===e.type||"text_join"===e.type)&&e.getParent()&&("text_print"===e.getParent().type||"js_text_print"===e.getParent().type)})).map((function(e){return e.getInputTargetBlock("A")})).find((function(e){return e&&"text"===e.type})),c=e.filter((function(e){return"t2c_text_join"===e.type||"text_join"===e.type})).map((function(e){return e.getInputTargetBlock("B")})).filter((function(e){return e&&("t2c_text_join"===e.type||"text_join"===e.type)})).map((function(e){return e.getInputTargetBlock("B")})).find((function(e){return e&&"text"===e.type})),g=e.find((function(e){return"text"===e.type&&e.getParent()&&("text_print"===e.getParent().type||"js_text_print"===e.getParent().type)})),d="Where is the code?",h=d.indexOf(" is "),p=0;p<=1;p++){var f=t[p];if(f&&f.getFieldValue("TEXT")&&f.getFieldValue("TEXT")!==d)return"The text before the "+(0===p?"first ":"second ")+T2C.MSG.currentLanguage.TERMINAL_GETTEXTFROMPOSITIONNUMBER+" on line 7 is incorrect. Substitute question with the value that it's initially assigned to."}for(var m=0;m<=2;m++){var y=n[m];if(y&&y.getFieldValue("TEXT")&&" is "!==y.getFieldValue("TEXT"))return"The text after the first + (for string concatenation, NOT numbers) on line "+(m+6)+" is incorrect. Substitute needle with the value that it's initially assigned to (*including* a single space at the beginning *and* end)."}if(i&&i.getFieldValue("NUM")&&i.getFieldValue("NUM")!==h)return"The first number on line 6 (in the addition block) is incorrect. It should be the substitution of "+T2C.MSG.currentLanguage.TERMINAL_FINDFIRSTOCCURRENCEOFTEXT+", which will be the *starting* position of the first occurrence of the value of needle. Fix it accordingly.";if(r&&r.getFieldValue("NUM")&&r.getFieldValue("NUM")!==d.length)return"The third number on line 6 (in the subtraction block) should be the length of the value of question. Fix it accordingly.";for(var T=0;T<=1;T++){var _=a[T];if(_&&_.getFieldValue("NUM")&&_.getFieldValue("NUM")!==h)return"The last number on line "+(T+6)+" is incorrect. It should be the substitution of "+T2C.MSG.currentLanguage.TERMINAL_FINDFIRSTOCCURRENCEOFTEXT+", which will be the *starting* position of the first occurrence of the value of needle. Fix it accordingly."}return i&&i.getFieldValue("NUM")&&i.getFieldValue("NUM")===h&&l&&l.getFieldValue("NUM")&&l.getFieldValue("NUM")!==h+4?"The first number on line 7 should be the result of the addition with 4 from the previous line. Fix it accordingly.":r&&r.getFieldValue("NUM")&&r.getFieldValue("NUM")===d.length&&s&&s.getFieldValue("NUM")&&s.getFieldValue("NUM")!==d.length-1?"The second number on line 7 should be the result of the subtraction by 1 from the previous line. Fix it accordingly.":i&&i.getFieldValue("NUM")&&i.getFieldValue("NUM")===h&&l&&l.getFieldValue("NUM")&&l.getFieldValue("NUM")===h+4&&r&&r.getFieldValue("NUM")&&r.getFieldValue("NUM")===d.length&&s&&s.getFieldValue("NUM")&&s.getFieldValue("NUM")===d.length-1&&u&&u.getFieldValue("TEXT")&&u.getFieldValue("TEXT")!==d.substring(h+4,d.length-1)?"The first string on line 8 (before the text concatenation +) should be the result of the substitution of the first "+T2C.MSG.currentLanguage.TERMINAL_GETTEXTFROMPOSITIONNUMBER+". Fix it accordingly.":a[1]&&a[1].getFieldValue("NUM")&&a[1].getFieldValue("NUM")===h&&c&&c.getFieldValue("TEXT")&&c.getFieldValue("TEXT")!==d.substring(1,h)?"The last string on line 8 (after both text concatenation +) should be the result of the substitution of the second "+T2C.MSG.currentLanguage.TERMINAL_GETTEXTFROMPOSITIONNUMBER+". Fix it accordingly.":u&&u.getFieldValue("TEXT")&&u.getFieldValue("TEXT")===d.substring(h+4,d.length-1)&&n[2]&&n[2].getFieldValue("TEXT")&&" is "===n[2].getFieldValue("TEXT")&&c&&c.getFieldValue("TEXT")&&c.getFieldValue("TEXT")===d.substring(1,h)&&g&&g.getFieldValue("TEXT")&&g.getFieldValue("TEXT")!==d.substring(h+4,d.length-1)+" is "+d.substring(1,h)?"The string on the last line is incorrect; it should be the result of the substitution of the concatenation of the three strings above it on line 8.":"Replace all the blank string literals and 0's with the appropriate text and numbers that are substituted as the computer would from top to bottom so that every line of output is the same. Try to do this without running the program until you get the message to do so (when you filled in everything correctly)."}),{startPosition:se(o,null,{},50,document.getElementById("top-header").offsetHeight+50)}))),function(e){e.addTask(new r((function(){return document.getElementById("output-container").classList.contains("show-container")}),new u([new s((function(){return T2C.MSG.currentLanguage.BUTTON_RUN_CODE}),{startPosition:{x:document.getElementById("run-code-button").offsetLeft+document.getElementById("run-code-button").offsetWidth,y:document.getElementById("run-code-button").offsetTop+document.getElementById("run-code-button").offsetHeight}}),new l(g,{totalSteps:100,toggleSteps:25,startPosition:{x:document.getElementById("run-code-button").offsetLeft+document.getElementById("run-code-button").offsetWidth/2,y:document.getElementById("run-code-button").offsetTop+document.getElementById("run-code-button").offsetHeight/2}})])))}(n),function(e,t){var n=0;function o(){t.style.color=n%50<25?"#a00":"#000",++n<200&&requestAnimationFrame(o)}e.addTask(new r((function(){return n>=200}),{start:function(){t.style.verticalAlign="top",requestAnimationFrame(o)},isComplete:function(){return!0},animate:function(){return!0}}))}(n,document.getElementById("output-container").querySelectorAll(".table-cell")[0]),n.addTask(new r((function(){return!0}),{start:function(){return!0},isComplete:function(){return!0},animate:function(){return!0},finish:function(){alert("Good, so now we're ready for today's main mission. But we're going to plan ahead! When you finish these training missions and need to take on a challenging new coding problem without guidance, you may find yourself lost and typing code that gets you nowhere. In these situations, it may help to work backward from your objective, which is exactly what we're going to do here. Since we want to display the user's name as \"first last\", let's suppose we have their first and last names stored in the variables firstName and lastName and *use them* to display the person's full name separated by a space."),oe(document.getElementById("output-container").querySelectorAll(".table-cell")[0]),ie(),o.clear(),a.clearToolbox(),a.createToolboxBlock("type_in_display_first_last_name"),o.options.maxInstances.type_in_display_first_last_name=1}})),n.addTask(new r((function(){var e=o.getAllBlocks().filter((function(e){return"variables_get"===e.type&&"lastName"===e.getField("VAR").getText()})),t=o.getAllBlocks().filter((function(e){return"text"===e.type&&" "==e.getFieldValue("TEXT")})),n=o.getAllBlocks().filter((function(n){return("text_join"===n.type||"t2c_text_join"===n.type)&&-1!==t.indexOf(n.getInputTargetBlock("A"))&&-1!==e.indexOf(n.getInputTargetBlock("B"))})),i=o.getAllBlocks().filter((function(e){return"variables_get"===e.type&&"firstName"===e.getField("VAR").getText()})),r=o.getAllBlocks().filter((function(e){return("text_join"===e.type||"t2c_text_join"===e.type)&&-1!==i.indexOf(e.getInputTargetBlock("A"))&&-1!==n.indexOf(e.getInputTargetBlock("B"))})),a=o.getAllBlocks().filter((function(e){return("text_print"===e.type||"js_text_print"===e.type)&&null===e.getNextBlock()&&-1!==r.indexOf(e.getInputTargetBlock("TEXT"))}));return 1===e.length&&1===t.length&&1===n.length&&1===i.length&&1===r.length&&1===a.length}),new s((function(){return'Drag the type-in-code block, and type the necessary code to display the person\'s first name and last name separated by a space, assuming the first and last names are stored in the variables, firstName and lastName, respectively. E.g., if firstName = "Jane" and lastName = "Doe", you\'d want to display "Jane Doe".'}),{startPosition:se(o,null,{},50,document.getElementById("top-header").offsetHeight+50)}))),n.addTask(new r((function(){return!0}),{start:function(){return!0},isComplete:function(){return!0},animate:function(){return!0},finish:function(){alert('✔ Acchaa (Good), so now of course we need to get the first and last names. Let\'s get the last name first. The input will be something like "Doe, Jane" so the last name will be a consecutive series of characters from part of this string...');for(var e="Which of the following can be used to get a consecutive series of characters from part of this string? (Enter a, b, c, or d.)\nA. "+T2C.MSG.currentLanguage.TERMINAL_GETCHARACTERNUMBER+"\nB. "+T2C.MSG.currentLanguage.TERMINAL_FINDFIRSTOCCURRENCEOFTEXT+"\nC. "+T2C.MSG.currentLanguage.TERMINAL_LENGTH+"\nD. "+T2C.MSG.currentLanguage.TERMINAL_GETTEXTFROMPOSITIONNUMBER,t=prompt(e);"string"==typeof t&&!t.toLowerCase().startsWith("d");)t=prompt("No, "+t[0]+" is not correct. Please try again. "+e);alert((t?"Yes":"OK, we'll tell you")+", D "+T2C.MSG.currentLanguage.TERMINAL_GETTEXTFROMPOSITIONNUMBER+' is the correct answer. Now this requires the string to extract text from and both starting and ending *numbers*, the first one telling the computer where to start extracting text from and the second telling it where to stop. For an input of "Doe, Jane", the last name starts at the beginning and ends at the position of the comma. So let\'s assume we have the input stored in enteredName and position of the comma in commaPosition and store the last name in a variable lastName, accordingly.'),oe(document.getElementById("output-container").querySelectorAll(".table-cell")[0]),ie(),a.clearToolbox(),a.createToolboxBlock("type_in_set_last_name"),o.options.maxInstances.type_in_set_last_name=1}})),n.addTask(new r((function(){var e=o.getAllBlocks().filter((function(e){return"variables_get"===e.type&&"lastName"===e.getField("VAR").getText()})),t=o.getAllBlocks().filter((function(e){return"text"===e.type&&" "===e.getFieldValue("TEXT")})),n=o.getAllBlocks().filter((function(n){return("t2c_text_join"===n.type||"text_join"===n.type)&&-1!==t.indexOf(n.getInputTargetBlock("A"))&&-1!==e.indexOf(n.getInputTargetBlock("B"))})),i=o.getAllBlocks().filter((function(e){return"variables_get"===e.type&&"firstName"===e.getField("VAR").getText()})),r=o.getAllBlocks().filter((function(e){return("t2c_text_join"===e.type||"text_join"===e.type)&&-1!==i.indexOf(e.getInputTargetBlock("A"))&&-1!==n.indexOf(e.getInputTargetBlock("B"))})),a=o.getAllBlocks().filter((function(e){return("text_print"===e.type||"js_text_print"===e.type)&&null===e.getNextBlock()&&-1!==r.indexOf(e.getInputTargetBlock("TEXT"))})),l=o.getAllBlocks().filter((function(e){return"variables_get"===e.type&&"commaPosition"===e.getField("VAR").getText()})),s=o.getAllBlocks().filter((function(e){return"math_number"===e.type&&0===e.getFieldValue("NUM")})),u=o.getAllBlocks().filter((function(e){return"variables_get"===e.type&&"enteredName"===e.getField("VAR").getText()})),c=o.getAllBlocks().filter((function(e){return("t2c_text_getsubstring"===e.type||"js_text_getsubstring"===e.type)&&-1!==u.indexOf(e.getInputTargetBlock("STRING"))&&-1!==s.indexOf(e.getInputTargetBlock("AT1"))&&-1!==l.indexOf(e.getInputTargetBlock("AT2"))})),g=o.getAllBlocks().filter((function(e){return"variables_set"===e.type&&-1!==a.indexOf(e.getNextBlock())&&-1!==c.indexOf(e.getInputTargetBlock("VALUE"))&&"lastName"===e.getField("VAR").getText()}));return 1===e.length&&1===t.length&&1===n.length&&1===i.length&&1===r.length&&1===a.length&&1===l.length&&1===s.length&&1===u.length&&1===c.length&&1===g.length}),new s((function(){var e=o.getAllBlocks().find((function(e){return"variables_set"===e.type})),t=o.getAllBlocks().find((function(e){return"text_print"===e.type||"js_text_print"===e.type}));return t&&e&&t.getNextBlock()===e?"The "+T2C.MSG.currentLanguage.TERMINAL_LET+" variable block declaring lastName needs to go above the "+T2C.MSG.currentLanguage.TERMINAL_DISPLAY+" block so the computer knows what lastName is when attempting to display the user's full name, which references lastName! Remember that statements are run from top to bottom.":t&&e&&t.getPreviousBlock()!==e?"Place the new "+T2C.MSG.currentLanguage.TERMINAL_LET+" variable block that sets lastName above the "+T2C.MSG.currentLanguage.TERMINAL_DISPLAY+" block so the computer knows what lastName is when attempting to display the user's full name, which references lastName.":"Drag the type-in-code block, and attach it above the previous "+T2C.MSG.currentLanguage.TERMINAL_DISPLAY+' block. Then type the necessary code to store the user\'s last name in the variable lastName, *assuming* we have the input in the form "last name, first name" stored in the variable enteredName (e.g., enteredName = "Doe, Jane") *AND* the position of the comma stored in commaPosition (e.g., for "Doe, Jane", commaPosition = 3).'}),{startPosition:se(o,null,{},50,document.getElementById("top-header").offsetHeight+50)}))),n.addTask(new r((function(){return!0}),{start:function(){return!0},isComplete:function(){return!0},animate:function(){return!0},finish:function(){alert('✔ Bahut acchaa (Very good), so now let\'s get the first name. The input will be something like "Doe, Jane" so the first name will also be a consecutive series of characters from part of this string so we can once again use '+T2C.MSG.currentLanguage.TERMINAL_GETTEXTFROMPOSITIONNUMBER+". You can figure out how you could get the numerical starting and ending positions from enteredString and commaPosition, right?"),oe(document.getElementById("output-container").querySelectorAll(".table-cell")[0]),ie(),a.clearToolbox(),a.createToolboxBlock("type_in_set_first_name"),o.options.maxInstances.type_in_set_first_name=1}})),n.addTask(new r((function(){var e=o.getAllBlocks().filter((function(e){return"variables_get"===e.type&&"lastName"===e.getField("VAR").getText()})),t=o.getAllBlocks().filter((function(e){return"text"===e.type&&" "===e.getFieldValue("TEXT")})),n=o.getAllBlocks().filter((function(n){return("t2c_text_join"===n.type||"text_join"===n.type)&&-1!==t.indexOf(n.getInputTargetBlock("A"))&&-1!==e.indexOf(n.getInputTargetBlock("B"))})),i=o.getAllBlocks().filter((function(e){return"variables_get"===e.type&&"firstName"===e.getField("VAR").getText()})),r=o.getAllBlocks().filter((function(e){return("t2c_text_join"===e.type||"text_join"===e.type)&&-1!==i.indexOf(e.getInputTargetBlock("A"))&&-1!==n.indexOf(e.getInputTargetBlock("B"))})),a=o.getAllBlocks().filter((function(e){return("text_print"===e.type||"js_text_print"===e.type)&&null===e.getNextBlock()&&-1!==r.indexOf(e.getInputTargetBlock("TEXT"))})),l=o.getAllBlocks().filter((function(e){return"variables_get"===e.type&&"commaPosition"===e.getField("VAR").getText()})),s=o.getAllBlocks().filter((function(e){return"math_number"===e.type&&0===e.getFieldValue("NUM")})),u=o.getAllBlocks().filter((function(e){return"variables_get"===e.type&&"enteredName"===e.getField("VAR").getText()})),c=o.getAllBlocks().filter((function(e){return("t2c_text_getsubstring"===e.type||"js_text_getsubstring"===e.type)&&-1!==u.indexOf(e.getInputTargetBlock("STRING"))&&-1!==s.indexOf(e.getInputTargetBlock("AT1"))&&-1!==l.indexOf(e.getInputTargetBlock("AT2"))})),g=o.getAllBlocks().filter((function(e){return"variables_set"===e.type&&-1!==a.indexOf(e.getNextBlock())&&-1!==c.indexOf(e.getInputTargetBlock("VALUE"))&&"lastName"===e.getField("VAR").getText()})),d=o.getAllBlocks().filter((function(e){return"t2c_text_length"===e.type&&-1!==u.indexOf(e.getInputTargetBlock("VALUE"))})),h=o.getAllBlocks().filter((function(e){return"math_number"===e.type&&2===e.getFieldValue("NUM")})),p=o.getAllBlocks().filter((function(e){return"math_arithmetic_basic"===e.type&&-1!==l.indexOf(e.getInputTargetBlock("A"))&&-1!==h.indexOf(e.getInputTargetBlock("B"))&&"ADD"==e.getFieldValue("OP")})),f=o.getAllBlocks().filter((function(e){return("t2c_text_getsubstring"===e.type||"js_text_getsubstring"===e.type)&&-1!==u.indexOf(e.getInputTargetBlock("STRING"))&&-1!==p.indexOf(e.getInputTargetBlock("AT1"))&&-1!==d.indexOf(e.getInputTargetBlock("AT2"))})),m=o.getAllBlocks().filter((function(e){return"variables_set"===e.type&&-1!==g.indexOf(e.getNextBlock())&&-1!==f.indexOf(e.getInputTargetBlock("VALUE"))&&"firstName"===e.getField("VAR").getText()}));return 1===e.length&&1===t.length&&1===n.length&&1===i.length&&1===r.length&&1===a.length&&2===l.length&&1===s.length&&3===u.length&&1===c.length&&1===g.length&&1===d.length&&1===h.length&&1===p.length&&1===f.length&&1===m.length}),new s((function(){var e=o.getAllBlocks().find((function(e){return"variables_set"===e.type&&"firstName"===e.getField("VAR").getText()})),t=o.getAllBlocks().find((function(e){return"variables_set"===e.type&&"lastName"===e.getField("VAR").getText()})),n=o.getAllBlocks().find((function(e){return"text_print"===e.type||"js_text_print"===e.type}));return e&&n&&n.getNextBlock()===e?"The "+T2C.MSG.currentLanguage.TERMINAL_LET+" variable block declaring firstName needs to go above the "+T2C.MSG.currentLanguage.TERMINAL_DISPLAY+" block so the computer knows what firstName is when attempting to display the user's full name, which references firstName! Remember that statements are run from top to bottom.":e&&e.getNextBlock()!==t?"Place the new "+T2C.MSG.currentLanguage.TERMINAL_LET+" variable block that sets firstName above the "+T2C.MSG.currentLanguage.TERMINAL_LET+" variable block storing lastName.":"Drag the type-in-code block, and attach it above the previous "+T2C.MSG.currentLanguage.TERMINAL_LET+' block. Then type the necessary code to store the user\'s first name in the variable firstName, *assuming* we have the input in the form "last name, first name" stored in the variable enteredName (e.g., enteredName = "Doe, Jane") *AND* the position of the comma stored in commaPosition (e.g., for "Doe, Jane", commaPosition = 3). Remember that there\'s a space after the comma.'}),{startPosition:se(o,null,{},50,document.getElementById("top-header").offsetHeight+50)}))),n.addTask(new r((function(){return!0}),{start:function(){return!0},isComplete:function(){return!0},animate:function(){return!0},finish:function(){alert("✔ Mahaan (Great)! So for both the first and last name, we needed the position of the comma in the input, which we assume is being stored in enteredName. You know how to tell the computer to find the position number of the (first) comma in enteredName and store it in the variable commaPosition, right?"),oe(document.getElementById("output-container").querySelectorAll(".table-cell")[0]),ie(),a.clearToolbox(),a.createToolboxBlock("type_in_set_comma_pos"),o.options.maxInstances.type_in_set_comma_pos=1}})),n.addTask(new r((function(){var e=o.getAllBlocks().filter((function(e){return"variables_get"===e.type&&"lastName"===e.getField("VAR").getText()})),t=o.getAllBlocks().filter((function(e){return"text"===e.type&&" "===e.getFieldValue("TEXT")})),n=o.getAllBlocks().filter((function(n){return("t2c_text_join"===n.type||"text_join"===n.type)&&-1!==t.indexOf(n.getInputTargetBlock("A"))&&-1!==e.indexOf(n.getInputTargetBlock("B"))})),i=o.getAllBlocks().filter((function(e){return"variables_get"===e.type&&"firstName"===e.getField("VAR").getText()})),r=o.getAllBlocks().filter((function(e){return("t2c_text_join"===e.type||"text_join"===e.type)&&-1!==i.indexOf(e.getInputTargetBlock("A"))&&-1!==n.indexOf(e.getInputTargetBlock("B"))})),a=o.getAllBlocks().filter((function(e){return("text_print"===e.type||"js_text_print"===e.type)&&null===e.getNextBlock()&&-1!==r.indexOf(e.getInputTargetBlock("TEXT"))})),l=o.getAllBlocks().filter((function(e){return"variables_get"===e.type&&"commaPosition"===e.getField("VAR").getText()})),s=o.getAllBlocks().filter((function(e){return"math_number"===e.type&&0===e.getFieldValue("NUM")})),u=o.getAllBlocks().filter((function(e){return"variables_get"===e.type&&"enteredName"===e.getField("VAR").getText()})),c=o.getAllBlocks().filter((function(e){return("t2c_text_getsubstring"===e.type||"js_text_getsubstring"===e.type)&&-1!==u.indexOf(e.getInputTargetBlock("STRING"))&&-1!==s.indexOf(e.getInputTargetBlock("AT1"))&&-1!==l.indexOf(e.getInputTargetBlock("AT2"))})),g=o.getAllBlocks().filter((function(e){return"variables_set"===e.type&&-1!==a.indexOf(e.getNextBlock())&&-1!==c.indexOf(e.getInputTargetBlock("VALUE"))&&"lastName"===e.getField("VAR").getText()})),d=o.getAllBlocks().filter((function(e){return"t2c_text_length"===e.type&&-1!==u.indexOf(e.getInputTargetBlock("VALUE"))})),h=o.getAllBlocks().filter((function(e){return"math_number"===e.type&&2===e.getFieldValue("NUM")})),p=o.getAllBlocks().filter((function(e){return"math_arithmetic_basic"===e.type&&-1!==l.indexOf(e.getInputTargetBlock("A"))&&-1!==h.indexOf(e.getInputTargetBlock("B"))&&"ADD"==e.getFieldValue("OP")})),f=o.getAllBlocks().filter((function(e){return("t2c_text_getsubstring"===e.type||"js_text_getsubstring"===e.type)&&-1!==u.indexOf(e.getInputTargetBlock("STRING"))&&-1!==p.indexOf(e.getInputTargetBlock("AT1"))&&-1!==d.indexOf(e.getInputTargetBlock("AT2"))})),m=o.getAllBlocks().filter((function(e){return"variables_set"===e.type&&-1!==g.indexOf(e.getNextBlock())&&-1!==f.indexOf(e.getInputTargetBlock("VALUE"))&&"firstName"===e.getField("VAR").getText()})),y=o.getAllBlocks().filter((function(e){return"text"===e.type&&(","==e.getFieldValue("TEXT")||", "==e.getFieldValue("TEXT"))})),T=o.getAllBlocks().filter((function(e){return("t2c_text_indexof"===e.type||"js_text_indexof"===e.type)&&-1!==u.indexOf(e.getInputTargetBlock("VALUE"))&&-1!==y.indexOf(e.getInputTargetBlock("FIND"))})),_=o.getAllBlocks().filter((function(e){return"variables_set"===e.type&&-1!==m.indexOf(e.getNextBlock())&&-1!==T.indexOf(e.getInputTargetBlock("VALUE"))&&"commaPosition"===e.getField("VAR").getText()}));return 1===e.length&&1===t.length&&1===n.length&&1===i.length&&1===r.length&&1===a.length&&2===l.length&&1===s.length&&4===u.length&&1===c.length&&1===g.length&&1===d.length&&1===h.length&&1===p.length&&1===f.length&&1===m.length&&1===y.length&&1===T.length&&1===_.length}),new s((function(){var e=o.getAllBlocks().find((function(e){return"variables_set"===e.type&&"commaPosition"===e.getField("VAR").getText()})),t=o.getAllBlocks().find((function(e){return"variables_set"===e.type&&"firstName"===e.getField("VAR").getText()})),n=o.getAllBlocks().find((function(e){return"variables_set"===e.type&&"lastName"===e.getField("VAR").getText()})),i=o.getAllBlocks().find((function(e){return"text_print"===e.type||"js_text_print"===e.type}));return e&&e.getPreviousBlock()===i?"The "+T2C.MSG.currentLanguage.TERMINAL_LET+" variable block declaring commaPosition must go above the "+T2C.MSG.currentLanguage.TERMINAL_DISPLAY+" block because the computer uses commaPosition in firstName and in lastName, both which need commaPosition to determine what they are. Since instructions are run from top to bottom, it won't be able to determine firstName and lastName, which are used in the "+T2C.MSG.currentLanguage.TERMINAL_DISPLAY+" otherwise!":e&&e.getPreviousBlock()===t?"The "+T2C.MSG.currentLanguage.TERMINAL_LET+" variable block declaring commaPosition must go above the "+T2C.MSG.currentLanguage.TERMINAL_LET+" variable block setting firstName, because the computer uses commaPosition to determine what firstName is. Since instructions are run from top to bottom, it won't know what commaPosition means, otherwise!":e&&e.getPreviousBlock()===n?"The "+T2C.MSG.currentLanguage.TERMINAL_LET+" variable block declaring commaPosition must go above the "+T2C.MSG.currentLanguage.TERMINAL_LET+" variable block setting lastName, because the computer uses commaPosition to determine what lastName is. Since instructions are run from top to bottom, it won't know what commaPosition means, otherwise!":e&&null===e.getNextBlock()?"Place the new "+T2C.MSG.currentLanguage.TERMINAL_LET+" variable block that sets commaPosition above the "+T2C.MSG.currentLanguage.TERMINAL_LET+" variable block storing firstName.":"Drag the type-in-code block, and attach it above the previous "+T2C.MSG.currentLanguage.TERMINAL_LET+" block. Then type the necessary code to store the position number of the (first) comma from the value of enteredName in the variable commaPosition."}),{startPosition:se(o,null,{},50,document.getElementById("top-header").offsetHeight+50)}))),n.addTask(new r((function(){return!0}),{start:function(){return!0},isComplete:function(){return!0},animate:function(){return!0},finish:function(){alert("✔ Excellent! So now all we have left is to ask the user to enter a name in the form last name, first name and store it in the variable enteredName and we'll be done!"),oe(document.getElementById("output-container").querySelectorAll(".table-cell")[0]),ie(),a.clearToolbox(),a.createToolboxBlock("type_in_get_last_first_name_input"),o.options.maxInstances.type_in_get_last_first_name_input=1}})),n.addTask(new r((function(){var e=o.getAllBlocks().filter((function(e){return"variables_get"===e.type&&"lastName"===e.getField("VAR").getText()})),t=o.getAllBlocks().filter((function(e){return"text"===e.type&&" "===e.getFieldValue("TEXT")})),n=o.getAllBlocks().filter((function(n){return("t2c_text_join"===n.type||"text_join"===n.type)&&-1!==t.indexOf(n.getInputTargetBlock("A"))&&-1!==e.indexOf(n.getInputTargetBlock("B"))})),i=o.getAllBlocks().filter((function(e){return"variables_get"===e.type&&"firstName"===e.getField("VAR").getText()})),r=o.getAllBlocks().filter((function(e){return("t2c_text_join"===e.type||"text_join"===e.type)&&-1!==i.indexOf(e.getInputTargetBlock("A"))&&-1!==n.indexOf(e.getInputTargetBlock("B"))})),a=o.getAllBlocks().filter((function(e){return("text_print"===e.type||"js_text_print"===e.type)&&null===e.getNextBlock()&&-1!==r.indexOf(e.getInputTargetBlock("TEXT"))})),l=o.getAllBlocks().filter((function(e){return"variables_get"===e.type&&"commaPosition"===e.getField("VAR").getText()})),s=o.getAllBlocks().filter((function(e){return"math_number"===e.type&&0===e.getFieldValue("NUM")})),u=o.getAllBlocks().filter((function(e){return"variables_get"===e.type&&"enteredName"===e.getField("VAR").getText()})),c=o.getAllBlocks().filter((function(e){return("t2c_text_getsubstring"===e.type||"js_text_getsubstring"===e.type)&&-1!==u.indexOf(e.getInputTargetBlock("STRING"))&&-1!==s.indexOf(e.getInputTargetBlock("AT1"))&&-1!==l.indexOf(e.getInputTargetBlock("AT2"))})),g=o.getAllBlocks().filter((function(e){return"variables_set"===e.type&&-1!==a.indexOf(e.getNextBlock())&&-1!==c.indexOf(e.getInputTargetBlock("VALUE"))&&"lastName"===e.getField("VAR").getText()})),d=o.getAllBlocks().filter((function(e){return"t2c_text_length"===e.type&&-1!==u.indexOf(e.getInputTargetBlock("VALUE"))})),h=o.getAllBlocks().filter((function(e){return"math_number"===e.type&&2===e.getFieldValue("NUM")})),p=o.getAllBlocks().filter((function(e){return"math_arithmetic_basic"===e.type&&-1!==l.indexOf(e.getInputTargetBlock("A"))&&-1!==h.indexOf(e.getInputTargetBlock("B"))&&"ADD"==e.getFieldValue("OP")})),f=o.getAllBlocks().filter((function(e){return("t2c_text_getsubstring"===e.type||"js_text_getsubstring"===e.type)&&-1!==u.indexOf(e.getInputTargetBlock("STRING"))&&-1!==p.indexOf(e.getInputTargetBlock("AT1"))&&-1!==d.indexOf(e.getInputTargetBlock("AT2"))})),m=o.getAllBlocks().filter((function(e){return"variables_set"===e.type&&-1!==g.indexOf(e.getNextBlock())&&-1!==f.indexOf(e.getInputTargetBlock("VALUE"))&&"firstName"===e.getField("VAR").getText()})),y=o.getAllBlocks().filter((function(e){return"text"===e.type&&(","==e.getFieldValue("TEXT")||", "==e.getFieldValue("TEXT"))})),T=o.getAllBlocks().filter((function(e){return("t2c_text_indexof"===e.type||"js_text_indexof"===e.type)&&-1!==u.indexOf(e.getInputTargetBlock("VALUE"))&&-1!==y.indexOf(e.getInputTargetBlock("FIND"))})),_=o.getAllBlocks().filter((function(e){return"variables_set"===e.type&&-1!==m.indexOf(e.getNextBlock())&&-1!==T.indexOf(e.getInputTargetBlock("VALUE"))&&"commaPosition"===e.getField("VAR").getText()})),b=o.getAllBlocks().filter((function(e){return"text"===e.type&&"string"==typeof e.getFieldValue("TEXT")&&-1!==e.getFieldValue("TEXT").indexOf("name")})),k=o.getAllBlocks().filter((function(e){return("text_input"===e.type||"js_text_input"===e.type)&&-1!==b.indexOf(e.getInputTargetBlock("TEXT"))})),x=o.getAllBlocks().filter((function(e){return"variables_set"===e.type&&-1!==_.indexOf(e.getNextBlock())&&-1!==k.indexOf(e.getInputTargetBlock("VALUE"))&&"enteredName"===e.getField("VAR").getText()}));return 1===e.length&&1===t.length&&1===n.length&&1===i.length&&1===r.length&&1===a.length&&2===l.length&&1===s.length&&4===u.length&&1===c.length&&1===g.length&&1===d.length&&1===h.length&&1===p.length&&1===f.length&&1===m.length&&1===y.length&&1===T.length&&1===_.length&&1===b.length&&1===k.length&&1===x.length}),new s((function(){var e=o.getAllBlocks().find((function(e){return"variables_set"===e.type&&"enteredName"===e.getField("VAR").getText()})),t=(o.getAllBlocks().find((function(e){return"variables_set"===e.type&&"commaPosition"===e.getField("VAR").getText()})),o.getAllBlocks().find((function(e){return"variables_set"===e.type&&"firstName"===e.getField("VAR").getText()})),o.getAllBlocks().find((function(e){return"variables_set"===e.type&&"lastName"===e.getField("VAR").getText()})),o.getAllBlocks().find((function(e){return"text_print"===e.type||"js_text_print"===e.type})));if(e&&t&&t.getNextBlock()===e)return"The "+T2C.MSG.currentLanguage.TERMINAL_LET+" variable block setting enteredName must go above the "+T2C.MSG.currentLanguage.TERMINAL_DISPLAY+" block because the computer uses enteredName in firstName and in lastName, both which need enteredName to determine what they are. Since instructions are run from top to bottom, it won't be able to determine firstName and lastName, which are used in the "+T2C.MSG.currentLanguage.TERMINAL_DISPLAY+" otherwise!";if(e&&null!==e.getPreviousBlock()){var n="variables_set"===e.getPreviousBlock().type&&e.getPreviousBlock().getField("VAR").getText();return"The "+T2C.MSG.currentLanguage.TERMINAL_LET+" variable block setting enteredName must go above the "+T2C.MSG.currentLanguage.TERMINAL_LET+" variable block setting "+n+" because the computer uses enteredName to determine what "+n+" is. Since instructions are run from top to bottom, it won't know what enteredName means, otherwise!"}return e&&null===e.getNextBlock()?"Place the new "+T2C.MSG.currentLanguage.TERMINAL_LET+" variable block that sets enteredName above the "+T2C.MSG.currentLanguage.TERMINAL_LET+" variable block storing commaPosition.":"Drag the type-in-code block, and attach it above the previous "+T2C.MSG.currentLanguage.TERMINAL_LET+" block. Then type the necessary code to ask the user for their full name in the form last, first, including the space after the comma (e.g., as Doe, Jane) and storing his/her inputted name in enteredName."}),{startPosition:se(o,null,{},50,document.getElementById("top-header").offsetHeight+50)}))),n.addTask(new r((function(){return!0}),{start:function(){return!0},isComplete:function(){return!0},animate:function(){return!0},finish:function(){alert("✔✔✔ Outstanding! And with that, Mission # 6 is accomplished! Can you believe you finished the problem already? You see how working backward can take a potentially challenging problem and make it a lot simpler? In the next mission 7, you'll continue your training turning s's into dollar signs with a little cutting and pasting using the same types of blocks from this mission. However, next time, you'll be typing code in straight up JavaScript! Your ready? Until next time!"),ie(),a.clearToolbox(),["code_statement"].forEach((function(e,t){a.createToolboxBlock(e,!1),o.options.maxInstances[e]=maxBlocks[t]}))}})),n},function(e,t){var n=e||new c,o=t||Blockly.getMainWorkspace(),a=new f(o),g="Mississippi".indexOf("s"),d="Mississippi".substring(0,g),h="Mississippi".substring(g+1),p=d+"$"+h;o.setScale(1),Object(i.f)(o);var m=document.createElement("div");function y(e){var t=e.options.maxInstances;e.options.maxInstances={},e.getAllBlocks().forEach((function(t){e.options.maxInstances[t.type]=++e.options.maxInstances[t.type]||1})),Object.keys(t).forEach((function(n){e.options.maxInstances[n]=e.options.maxInstances[n]||t[n]}))}return m.innerText="👆",m.id="ptr",m.style.fontSize="x-large",m.style.position="absolute",m.style.zIndex="1001",document.getElementById("blockly-div").appendChild(m),n.addTask(new r((function(){return T2C.MSG.currentLanguage===T2C.MSG.JS}),{start:function(){var e=T2C.MSG.currentLanguage===T2C.MSG.JS?"":"So to start, select JavaScript from the dropdown menu at the top and watch how the blocks in the toolbox transform to their JavaScript equivalents.";a.clearToolbox(),["text_print","text_input","t2c_text_indexof","t2c_text_getsubstring","variables_set","variables_get"].forEach((function(e,t){a.createToolboxBlock(e,!1),o.options.maxInstances[e]=0})),alert("In this mission, you'll ask the user for a string with at least one (lowercase) s and then output the entered string with the first s replaced by $. E.g., for Mississippi, the output would be "+p+". This task can be accomplished similar to the way the last one was, but this time you're going to work in pure JavaScript. "+e),o.clear(),Blockly.svgResize(o),ce(document.getElementById("output-container").querySelectorAll(".table-cell")[0]),ge()},isComplete:function(){return!0},animate:function(){return!0},finish:function(){}})),n.addTask(new r((function(){return!0}),{start:function(){alert("Theek hai (OK), so since you got the setup from last time for a similar problem, this time we'll work in the usual direction from the start of the program where we ask the user to enter a string and store it in a variable, which we'll call enteredTextWithS this time. In pure JavaScript, we use "+T2C.MSG.JS.TERMINAL_GETINPUTBYASKING+" for "+T2C.MSG.EN.TERMINAL_GETINPUTBYASKING+". As before, you'll drag in a type-in-code block, and type in the code."),o.clear(),Blockly.svgResize(o),ce(document.getElementById("output-container").querySelectorAll(".table-cell")[0]),ge(),a.createToolboxBlock("type_in_get_input_with_s"),o.options.maxInstances.type_in_get_input_with_s=1},isComplete:function(){return!0},animate:function(){return!0},finish:function(){}})),n.addTask(new r((function(){var e=o.getAllBlocks().filter((function(e){return"text"===e.type&&"string"==typeof e.getFieldValue("TEXT")&&-1!==e.getFieldValue("TEXT").toLowerCase().indexOf("with an s")})),t=o.getAllBlocks().filter((function(t){return("text_input"===t.type||"js_text_input"===t.type)&&-1!==e.indexOf(t.getInputTargetBlock("TEXT"))})),n=o.getAllBlocks().filter((function(e){return"variables_set"===e.type&&-1!==t.indexOf(e.getInputTargetBlock("VALUE"))&&"enteredTextWithS"===e.getField("VAR").getText()}));return 1===e.length&&1===t.length&&1===n.length}),new s((function(){return"Drag in the type-in-code block, and type the necessary code to ask the user for a string with an s and store it in a variable enteredTextWithS. Be sure the message contains the text 'with an s' to let the user know that his/her string needs at least one s and to use the JavaScript "+T2C.MSG.JS.TERMINAL_GETINPUTBYASKING+" instead of "+T2C.MSG.EN.TERMINAL_GETINPUTBYASKING+"."}),{startPosition:fe(o,null,{},50,document.getElementById("top-header").offsetHeight+50)}))),n.addTask(new r((function(){return!0}),{start:function(){return!0},isComplete:function(){return!0},animate:function(){return!0},finish:function(){alert("✔ Acchaa (Good), so last time we got the position of the comma so we could get the last name which came before it and the first name which came two places after. Do you remember what we used to do this? Just to make it more interesting, we'll give you the choices in JavaScript this time and see if you can figure out the equivalences.");for(var e="Which of the following can be used to get the position of a needle (string) appearing in another one (haystack)? (Enter a, b, c, or d.)\nA. "+T2C.MSG.currentLanguage.TERMINAL_GETCHARACTERNUMBER+"\nB. "+T2C.MSG.currentLanguage.TERMINAL_FINDFIRSTOCCURRENCEOFTEXT+"\nC. "+T2C.MSG.currentLanguage.TERMINAL_LENGTH+"\nD. "+T2C.MSG.currentLanguage.TERMINAL_GETTEXTFROMPOSITIONNUMBER,t=prompt(e);"string"==typeof t&&!t.toLowerCase().startsWith("b");)t=prompt("No, "+t[0]+" is not correct. Please try again. "+e);alert((t?"Yes":"OK, we'll tell you")+", B "+T2C.MSG.currentLanguage.TERMINAL_FINDFIRSTOCCURRENCEOFTEXT+" is the correct answer. The solution to the last problem could be thought of as taking a piece of paper with say |Doe, Jane|, making cuts around the comma |Doe|, |Jane| using "+T2C.MSG.currentLanguage.TERMINAL_FINDFIRSTOCCURRENCEOFTEXT+" to determine where to cut, "+T2C.MSG.currentLanguage.TERMINAL_GETTEXTFROMPOSITIONNUMBER+" to get the pieces, and + to paste the ones we want to keep (with perhaps a new piece (the space)). No rearrangement is needed here, but the idea is the same. So let's start by determining/storing the position number to cut at."),ce(document.getElementById("output-container").querySelectorAll(".table-cell")[0]),ge(),a.clearToolbox(),["js_text_print","js_text_input","js_text_indexof","js_text_getsubstring","variables_set","variables_get","text"].forEach((function(e,t){a.createToolboxBlock(e,!1),o.options.maxInstances[e]=0})),y(o),a.createToolboxBlock("type_in_set_s_pos"),o.options.maxInstances.type_in_set_s_pos=1}})),n.addTask(new r((function(){var e=o.getAllBlocks().filter((function(e){return"variables_get"===e.type&&"enteredTextWithS"===e.getField("VAR").getText()})),t=o.getAllBlocks().filter((function(e){return"text"===e.type&&"s"===e.getFieldValue("TEXT")})),n=o.getAllBlocks().filter((function(n){return("t2c_text_indexof"===n.type||"js_text_indexof"===n.type)&&-1!==e.indexOf(n.getInputTargetBlock("VALUE"))&&-1!==t.indexOf(n.getInputTargetBlock("FIND"))})),i=o.getAllBlocks().filter((function(e){return"variables_set"===e.type&&-1!==n.indexOf(e.getInputTargetBlock("VALUE"))&&"sPosition"===e.getField("VAR").getText()})),r=o.getAllBlocks().filter((function(e){return"text"===e.type&&"string"==typeof e.getFieldValue("TEXT")&&-1!==e.getFieldValue("TEXT").toLowerCase().indexOf("with an s")})),a=o.getAllBlocks().filter((function(e){return("text_input"===e.type||"js_text_input"===e.type)&&-1!==r.indexOf(e.getInputTargetBlock("TEXT"))})),l=o.getAllBlocks().filter((function(e){return"variables_set"===e.type&&-1!==i.indexOf(e.getNextBlock())&&-1!==a.indexOf(e.getInputTargetBlock("VALUE"))&&"enteredTextWithS"===e.getField("VAR").getText()}));return 1===e.length&&1===t.length&&1===n.length&&1===i.length&&1===r.length&&1===a.length&&1===l.length}),new s((function(){var e=o.getAllBlocks().find((function(e){return"variables_set"===e.type&&"enteredTextWithS"===e.getField("VAR").getText()})),t=o.getAllBlocks().find((function(e){return"variables_set"===e.type&&"sPosition"===e.getField("VAR").getText()}));return t&&t.getNextBlock()===e?"The "+T2C.MSG.currentLanguage.TERMINAL_LET+" variable block declaring sPosition must go below the "+T2C.MSG.currentLanguage.TERMINAL_LET+" variable block setting enteredTextWithS because it won't be able to find the position of the s in the entered string if it hasn't been entered yet! Remember instructions are run from top to bottom.":t&&null===t.getPreviousBlock()?"Place the "+T2C.MSG.currentLanguage.TERMINAL_LET+" variable block declaring sPosition below the "+T2C.MSG.currentLanguage.TERMINAL_LET+" variable block setting enteredTextWithS, because the computer uses this variable to determine what sPosition is.":"Drag the type-in-code block, and attach it below the previous "+T2C.MSG.currentLanguage.TERMINAL_LET+" block. Then type the necessary code to store the position number of the (first) _ from the value of enteredTextWithS in the variable called _Position filling in the blank with the character(s) in the same case (lower or upper) that you're searching for."}),{startPosition:fe(o,null,{},50,document.getElementById("top-header").offsetHeight+50)}))),n.addTask(new r((function(){return!0}),{start:function(){return!0},isComplete:function(){return!0},animate:function(){return!0},finish:function(){alert('✔ Bahut acchaa (Very good), so now let\'s get the text before the first s. E.g., for "Mississippi", we\'d want "'+d+'". The equivalent of '+T2C.MSG.EN.TERMINAL_GETTEXTFROMPOSITIONNUMBER+" in "+T2C.MSG.currentLanguage.LANGUAGE_NAME+" is "+T2C.MSG.currentLanguage.TERMINAL_GETTEXTFROMPOSITIONNUMBER+" except you'll only use one set of parentheses with the starting and ending positions separated by a comma. You can figure out how you could get the numerical starting and ending positions from enteredTextWithS and sPosition in "+T2C.MSG.currentLanguage.LANGUAGE_NAME+", right?"),ce(document.getElementById("output-container").querySelectorAll(".table-cell")[0]),ge(),a.removeToolboxBlocks((function(e){return"type_in_set_s_pos"===e.getAttribute("type")})),y(o),a.createToolboxBlock("type_in_set_before_s"),o.options.maxInstances.type_in_set_before_s=1}})),n.addTask(new r((function(){var e=o.getAllBlocks().filter((function(e){return"variables_get"===e.type&&"enteredTextWithS"===e.getField("VAR").getText()})),t=o.getAllBlocks().filter((function(e){return"variables_get"===e.type&&"sPosition"===e.getField("VAR").getText()})),n=o.getAllBlocks().filter((function(e){return"math_number"===e.type&&0===e.getFieldValue("NUM")})),i=o.getAllBlocks().filter((function(o){return("t2c_text_getsubstring"===o.type||"js_text_getsubstring"===o.type)&&-1!==e.indexOf(o.getInputTargetBlock("STRING"))&&-1!==n.indexOf(o.getInputTargetBlock("AT1"))&&-1!==t.indexOf(o.getInputTargetBlock("AT2"))})),r=o.getAllBlocks().filter((function(e){return"variables_set"===e.type&&-1!==i.indexOf(e.getInputTargetBlock("VALUE"))&&"beforeS"===e.getField("VAR").getText()})),a=o.getAllBlocks().filter((function(e){return"text"===e.type&&"s"===e.getFieldValue("TEXT")})),l=o.getAllBlocks().filter((function(t){return("t2c_text_indexof"===t.type||"js_text_indexof"===t.type)&&-1!==e.indexOf(t.getInputTargetBlock("VALUE"))&&-1!==a.indexOf(t.getInputTargetBlock("FIND"))})),s=o.getAllBlocks().filter((function(e){return"variables_set"===e.type&&-1!==r.indexOf(e.getNextBlock())&&-1!==l.indexOf(e.getInputTargetBlock("VALUE"))&&"sPosition"===e.getField("VAR").getText()})),u=o.getAllBlocks().filter((function(e){return"text"===e.type&&"string"==typeof e.getFieldValue("TEXT")&&-1!==e.getFieldValue("TEXT").toLowerCase().indexOf("with an s")})),c=o.getAllBlocks().filter((function(e){return("text_input"===e.type||"js_text_input"===e.type)&&-1!==u.indexOf(e.getInputTargetBlock("TEXT"))})),g=o.getAllBlocks().filter((function(e){return"variables_set"===e.type&&-1!==s.indexOf(e.getNextBlock())&&-1!==c.indexOf(e.getInputTargetBlock("VALUE"))&&"enteredTextWithS"===e.getField("VAR").getText()}));return 2===e.length&&1===t.length&&1===n.length&&1===i.length&&1===r.length&&1===a.length&&1===l.length&&1===s.length&&1===u.length&&1===c.length&&1===g.length}),new s((function(){o.getAllBlocks().find((function(e){return"variables_set"===e.type&&"enteredTextWithS"===e.getField("VAR").getText()})),o.getAllBlocks().find((function(e){return"variables_set"===e.type&&"sPosition"===e.getField("VAR").getText()}));var e=o.getAllBlocks().find((function(e){return"variables_set"===e.type&&"beforeS"===e.getField("VAR").getText()}));if(e&&null!==e.getNextBlock()){var t="variables_set"===e.getNextBlock().type&&e.getNextBlock().getField("VAR").getText();return"The "+T2C.MSG.currentLanguage.TERMINAL_LET+" variable block setting beforeS must go below the "+T2C.MSG.currentLanguage.TERMINAL_LET+" variable block setting "+t+" because the computer uses this one to determine what beforeS is. Since instructions are run from top to bottom, it won't know what "+t+" means, otherwise!"}return e&&null===e.getPreviousBlock()?"Place the "+T2C.MSG.currentLanguage.TERMINAL_LET+" variable block declaring beforeS below the "+T2C.MSG.currentLanguage.TERMINAL_LET+" variable block setting sPosition, because the computer uses this variable to determine what beforeS is.":"Drag the type-in-code block, and attach it below the previous "+T2C.MSG.currentLanguage.TERMINAL_LET+" variable block setting sPosition. Then type the necessary code to store the text coming before the first s of the user input in beforeS (assuming there was an s). E.g., for Mississippi, have it store "+d}),{startPosition:fe(o,null,{},50,document.getElementById("top-header").offsetHeight+50)}))),n.addTask(new r((function(){return!0}),{start:function(){return!0},isComplete:function(){return!0},animate:function(){return!0},finish:function(){alert('✔ Mahaan (Great)! So now let\'s get the text after the s. E.g., for "Mississippi", we\'d want "'+h+'".'),ce(document.getElementById("output-container").querySelectorAll(".table-cell")[0]),ge(),a.removeToolboxBlocks((function(e){return"type_in_set_before_s"===e.getAttribute("type")})),y(o),a.createToolboxBlock("type_in_set_after_s"),o.options.maxInstances.type_in_set_after_s=1}})),n.addTask(new r((function(){var e=o.getAllBlocks().filter((function(e){return"variables_get"===e.type&&"enteredTextWithS"===e.getField("VAR").getText()})),t=o.getAllBlocks().filter((function(t){return"t2c_text_length"===t.type&&-1!==e.indexOf(t.getInputTargetBlock("VALUE"))})),n=o.getAllBlocks().filter((function(e){return"math_number"===e.type&&1===e.getFieldValue("NUM")})),i=o.getAllBlocks().filter((function(e){return"variables_get"===e.type&&"sPosition"===e.getField("VAR").getText()})),r=o.getAllBlocks().filter((function(e){return"math_arithmetic_basic"===e.type&&-1!==i.indexOf(e.getInputTargetBlock("A"))&&-1!==n.indexOf(e.getInputTargetBlock("B"))&&"ADD"==e.getFieldValue("OP")})),a=o.getAllBlocks().filter((function(n){return("t2c_text_getsubstring"===n.type||"js_text_getsubstring"===n.type)&&-1!==e.indexOf(n.getInputTargetBlock("STRING"))&&-1!==r.indexOf(n.getInputTargetBlock("AT1"))&&-1!==t.indexOf(n.getInputTargetBlock("AT2"))})),l=o.getAllBlocks().filter((function(e){return"variables_set"===e.type&&-1!==a.indexOf(e.getInputTargetBlock("VALUE"))&&"afterS"===e.getField("VAR").getText()})),s=o.getAllBlocks().filter((function(e){return"math_number"===e.type&&0===e.getFieldValue("NUM")})),u=o.getAllBlocks().filter((function(t){return("t2c_text_getsubstring"===t.type||"js_text_getsubstring"===t.type)&&-1!==e.indexOf(t.getInputTargetBlock("STRING"))&&-1!==s.indexOf(t.getInputTargetBlock("AT1"))&&-1!==i.indexOf(t.getInputTargetBlock("AT2"))})),c=o.getAllBlocks().filter((function(e){return"variables_set"===e.type&&-1!==u.indexOf(e.getInputTargetBlock("VALUE"))&&"beforeS"===e.getField("VAR").getText()})),g=o.getAllBlocks().filter((function(e){return"text"===e.type&&"s"==e.getFieldValue("TEXT")})),d=o.getAllBlocks().filter((function(t){return("t2c_text_indexof"===t.type||"js_text_indexof"===t.type)&&-1!==e.indexOf(t.getInputTargetBlock("VALUE"))&&-1!==g.indexOf(t.getInputTargetBlock("FIND"))})),h=o.getAllBlocks().filter((function(e){return"variables_set"===e.type&&-1!==c.indexOf(e.getNextBlock())&&-1!==d.indexOf(e.getInputTargetBlock("VALUE"))&&"sPosition"===e.getField("VAR").getText()})),p=o.getAllBlocks().filter((function(e){return"text"===e.type&&"string"==typeof e.getFieldValue("TEXT")&&-1!==e.getFieldValue("TEXT").toLowerCase().indexOf("with an s")})),f=o.getAllBlocks().filter((function(e){return("text_input"===e.type||"js_text_input"===e.type)&&-1!==p.indexOf(e.getInputTargetBlock("TEXT"))})),m=o.getAllBlocks().filter((function(e){return"variables_set"===e.type&&-1!==h.indexOf(e.getNextBlock())&&-1!==f.indexOf(e.getInputTargetBlock("VALUE"))&&"enteredTextWithS"===e.getField("VAR").getText()}));return 4===e.length&&1===t.length&&1===n.length&&2===i.length&&1===r.length&&1===a.length&&1===l.length&&1===s.length&&1===u.length&&1===c.length&&1===g.length&&1===d.length&&1===h.length&&1===p.length&&1===f.length&&1===m.length}),new s((function(){o.getAllBlocks().find((function(e){return"variables_set"===e.type&&"enteredTextWithS"===e.getField("VAR").getText()})),o.getAllBlocks().find((function(e){return"variables_set"===e.type&&"sPosition"===e.getField("VAR").getText()}));var e=o.getAllBlocks().find((function(e){return"variables_set"===e.type&&"afterS"===e.getField("VAR").getText()})),t=o.getAllBlocks().find((function(e){return"variables_set"===e.type&&"beforeS"===e.getField("VAR").getText()}));if(e&&null!==e.getNextBlock()&&e.getNextBlock()!==t){var n="variables_set"===e.getNextBlock().type&&e.getNextBlock().getField("VAR").getText();return"The "+T2C.MSG.currentLanguage.TERMINAL_LET+" variable block setting afterS must go below the "+T2C.MSG.currentLanguage.TERMINAL_LET+" variable block setting "+n+" because the computer uses this one to determine what afterS is. Since instructions are run from top to bottom, it won't know what "+n+" means, otherwise!"}return!e||e.getNextBlock()!==t&&null!==e.getPreviousBlock()?"Drag the type-in-code block, and attach it below the previous "+T2C.MSG.currentLanguage.TERMINAL_LET+" variable block setting beforeS. Then type the necessary code to store the text coming after the first s of the user input in afterS (assuming there was an s).":"Place the new "+T2C.MSG.currentLanguage.TERMINAL_LET+" variable block setting afterS below the previous "+T2C.MSG.currentLanguage.TERMINAL_LET+" block setting beforeS. E.g., for an entered string of Mississippi, you'd display "+h+"."}),{startPosition:fe(o,null,{},50,document.getElementById("top-header").offsetHeight+50)}))),n.addTask(new r((function(){return!0}),{start:function(){return!0},isComplete:function(){return!0},animate:function(){return!0},finish:function(){alert("✔✔ Excellent, so now we display the result of pasting, which will be the same in "+T2C.MSG.currentLanguage.LANGUAGE_NAME+" that it was in "+T2C.MSG.EN.LANGUAGE_NAME+". E.g., for an input of Mississippi , we'd have a beforeS of "+d+", an afterS of "+h+" and would want "+p+"."),ce(document.getElementById("output-container").querySelectorAll(".table-cell")[0]),ge(),a.removeToolboxBlocks((function(e){return"type_in_set_after_s"===e.getAttribute("type")})),y(o),a.createToolboxBlock("type_in_display_s_replaced_with_dollar"),o.options.maxInstances.type_in_display_s_replaced_with_dollar=1}})),n.addTask(new r((function(){var e=o.getAllBlocks().filter((function(e){return"variables_get"===e.type&&"afterS"===e.getField("VAR").getText()})),t=o.getAllBlocks().filter((function(e){return"text"===e.type&&"$"==e.getFieldValue("TEXT")})),n=o.getAllBlocks().filter((function(n){return"t2c_text_join"===n.type&&-1!==t.indexOf(n.getInputTargetBlock("A"))&&-1!==e.indexOf(n.getInputTargetBlock("B"))})),i=o.getAllBlocks().filter((function(e){return"variables_get"===e.type&&"beforeS"===e.getField("VAR").getText()})),r=o.getAllBlocks().filter((function(e){return"t2c_text_join"===e.type&&-1!==i.indexOf(e.getInputTargetBlock("A"))&&-1!==n.indexOf(e.getInputTargetBlock("B"))})),a=o.getAllBlocks().filter((function(e){return("text_print"===e.type||"js_text_print"===e.type)&&null===e.getNextBlock()&&-1!==r.indexOf(e.getInputTargetBlock("TEXT"))})),l=o.getAllBlocks().filter((function(e){return"variables_get"===e.type&&"enteredTextWithS"===e.getField("VAR").getText()})),s=o.getAllBlocks().filter((function(e){return"t2c_text_length"===e.type&&-1!==l.indexOf(e.getInputTargetBlock("VALUE"))})),u=o.getAllBlocks().filter((function(e){return"math_number"===e.type&&1===e.getFieldValue("NUM")})),c=o.getAllBlocks().filter((function(e){return"variables_get"===e.type&&"sPosition"===e.getField("VAR").getText()})),g=o.getAllBlocks().filter((function(e){return"math_arithmetic_basic"===e.type&&-1!==c.indexOf(e.getInputTargetBlock("A"))&&-1!==u.indexOf(e.getInputTargetBlock("B"))&&"ADD"==e.getFieldValue("OP")})),d=o.getAllBlocks().filter((function(e){return("t2c_text_getsubstring"===e.type||"js_text_getsubstring"===e.type)&&-1!==l.indexOf(e.getInputTargetBlock("STRING"))&&-1!==g.indexOf(e.getInputTargetBlock("AT1"))&&-1!==s.indexOf(e.getInputTargetBlock("AT2"))})),h=o.getAllBlocks().filter((function(e){return"variables_set"===e.type&&-1!==d.indexOf(e.getInputTargetBlock("VALUE"))&&"afterS"===e.getField("VAR").getText()&&-1!==a.indexOf(e.getNextBlock())})),p=o.getAllBlocks().filter((function(e){return"math_number"===e.type&&0===e.getFieldValue("NUM")})),f=o.getAllBlocks().filter((function(e){return("t2c_text_getsubstring"===e.type||"js_text_getsubstring"===e.type)&&-1!==l.indexOf(e.getInputTargetBlock("STRING"))&&-1!==p.indexOf(e.getInputTargetBlock("AT1"))&&-1!==c.indexOf(e.getInputTargetBlock("AT2"))})),m=o.getAllBlocks().filter((function(e){return"variables_set"===e.type&&-1!==f.indexOf(e.getInputTargetBlock("VALUE"))&&"beforeS"===e.getField("VAR").getText()&&-1!==h.indexOf(e.getNextBlock())})),y=o.getAllBlocks().filter((function(e){return"text"===e.type&&"s"==e.getFieldValue("TEXT")})),T=o.getAllBlocks().filter((function(e){return("t2c_text_indexof"===e.type||"js_text_indexof"===e.type)&&-1!==l.indexOf(e.getInputTargetBlock("VALUE"))&&-1!==y.indexOf(e.getInputTargetBlock("FIND"))})),_=o.getAllBlocks().filter((function(e){return"variables_set"===e.type&&-1!==m.indexOf(e.getNextBlock())&&-1!==T.indexOf(e.getInputTargetBlock("VALUE"))&&"sPosition"===e.getField("VAR").getText()})),b=o.getAllBlocks().filter((function(e){return"text"===e.type&&"string"==typeof e.getFieldValue("TEXT")&&-1!==e.getFieldValue("TEXT").toLowerCase().indexOf("with an s")})),k=o.getAllBlocks().filter((function(e){return("text_input"===e.type||"js_text_input"===e.type)&&-1!==b.indexOf(e.getInputTargetBlock("TEXT"))})),x=o.getAllBlocks().filter((function(e){return"variables_set"===e.type&&-1!==_.indexOf(e.getNextBlock())&&-1!==k.indexOf(e.getInputTargetBlock("VALUE"))&&"enteredTextWithS"===e.getField("VAR").getText()}));return 1===e.length&&1===t.length&&1===n.length&&1===i.length&&1===r.length&&1===a.length&&4===l.length&&1===s.length&&1===u.length&&2===c.length&&1===g.length&&1===d.length&&1===h.length&&1===p.length&&1===f.length&&1===m.length&&1===y.length&&1===T.length&&1===_.length&&1===b.length&&1===k.length&&1===x.length}),new s((function(){var e=o.getAllBlocks().find((function(e){return"variables_set"===e.type&&"enteredTextWithS"===e.getField("VAR").getText()})),t=o.getAllBlocks().find((function(e){return"text_print"===e.type||"js_text_print"===e.type}));if(e&&t&&t.getNextBlock()===e)return"The "+T2C.MSG.currentLanguage.TERMINAL_DISPLAY+" block must go below the "+T2C.MSG.currentLanguage.TERMINAL_LET+" variable block setting enteredTextWithS because the computer uses enteredTextWithS in beforeS and afterS, both which need enteredTextWithS to determine what they are. Since instructions are run from top to bottom, it won't be able to determine beforeS and afterS, which are used in the "+T2C.MSG.currentLanguage.TERMINAL_DISPLAY+" otherwise!";if(t&&null!==t.getNextBlock()){var n="variables_set"===t.getNextBlock().type&&t.getNextBlock().getField("VAR").getText();return"The "+T2C.MSG.currentLanguage.TERMINAL_DISPLAY+" block must go below the "+T2C.MSG.currentLanguage.TERMINAL_LET+" variable block setting "+n+" because the computer uses "+n+" in what it displays! Since instructions are run from top to bottom, it won't know what "+n+" means, otherwise!"}return t&&null===t.getPreviousBlock()?"Place the new "+T2C.MSG.currentLanguage.TERMINAL_DISPLAY+" block below the previous "+T2C.MSG.currentLanguage.TERMINAL_LET+" block setting afterS.":"Drag the type-in-code block, and type the necessary code to display the user's entered string with its first s replaced by a $ (assuming the user typed in a string with at least one s). E.g., for an entered string of Mississippi, you'd display "+p+"."}),{startPosition:fe(o,null,{},50,document.getElementById("top-header").offsetHeight+50)}))),function(e){e.addTask(new r((function(){return document.getElementById("output-container").classList.contains("show-container")}),new u([new s((function(){return T2C.MSG.currentLanguage.BUTTON_RUN_CODE}),{startPosition:{x:document.getElementById("run-code-button").offsetLeft+document.getElementById("run-code-button").offsetWidth,y:document.getElementById("run-code-button").offsetTop+document.getElementById("run-code-button").offsetHeight}}),new l(m,{totalSteps:100,toggleSteps:25,startPosition:{x:document.getElementById("run-code-button").offsetLeft+document.getElementById("run-code-button").offsetWidth/2,y:document.getElementById("run-code-button").offsetTop+document.getElementById("run-code-button").offsetHeight/2}})])))}(n),function(e,t){var n=0;function o(){t.style.color=n%50<25?"#a00":"#000",++n<200&&requestAnimationFrame(o)}e.addTask(new r((function(){return n>=200}),{start:function(){t.style.verticalAlign="top",requestAnimationFrame(o)},isComplete:function(){return!0},animate:function(){return!0}}))}(n,document.getElementById("output-container").querySelectorAll(".table-cell")[0]),n.addTask(new r((function(){return!0}),{start:function(){return!0},isComplete:function(){return!0},animate:function(){return!0},finish:function(){alert("✔✔✔ Outstanding! And with that, Mission # 7 is accomplished and you just typed an entire program in pure JavaScript! That wasn't too bad was it? In the next mission 8, you'll get a person's first/last initials from their first and last name. As you did in this mission, you'll be typing code in pure JavaScript except you'll be returning to the "+T2C.MSG.JS.TERMINAL_GETCHARACTERNUMBER+" to get single characters at given positions. Phir milenge (See you again)!"),ge(),a.clearToolbox(),["code_statement"].forEach((function(e,t){a.createToolboxBlock(e,!1),o.options.maxInstances[e]=maxBlocks[t]}))}})),n},function(e,t){var n=e||new c,o=t||Blockly.getMainWorkspace(),a=new f(o),g="Mississippi".indexOf("s");"Mississippi".substring(0,g),"Mississippi".substring(g+1),o.setScale(1),Object(i.f)(o);var d=document.createElement("div");return d.innerText="👆",d.id="ptr",d.style.fontSize="x-large",d.style.position="absolute",d.style.zIndex="1001",document.getElementById("blockly-div").appendChild(d),n.addTask(new r((function(){return T2C.MSG.currentLanguage===T2C.MSG.JS}),{start:function(){var e=T2C.MSG.currentLanguage===T2C.MSG.JS?"":"So to start, select JavaScript from the dropdown menu at the top and watch how the blocks in the toolbox transform to their JavaScript equivalents.";a.clearToolbox(),["text_print","text_input","t2c_text_indexof","t2c_text_charat","variables_set","variables_get"].forEach((function(e,t){a.createToolboxBlock(e,!1),o.options.maxInstances[e]=0})),alert("In this mission, you'll ask the user for their first and last name separated by a space (output from Mission # 6) and print their initials separated by periods. For example, for an input of Jane Doe, you'd output J.D. Once again you're going to work in pure JavaScript, but this time you'll accomplish the task using "+T2C.MSG.JS.TERMINAL_FINDFIRSTOCCURRENCEOFTEXT+" and "+T2C.MSG.JS.TERMINAL_GETCHARACTERNUMBER+" instead of "+T2C.MSG.JS.TERMINAL_FINDFIRSTOCCURRENCEOFTEXT+" and "+T2C.MSG.JS.TERMINAL_GETTEXTFROMPOSITIONNUMBER+". You'll also do this with only two lines of code, one to store the input and one to display the output! "+e),o.clear(),Blockly.svgResize(o),ye(document.getElementById("output-container").querySelectorAll(".table-cell")[0]),Te()},isComplete:function(){return!0},animate:function(){return!0},finish:function(){}})),n.addTask(new r((function(){return!0}),{start:function(){alert("Theek hai (OK), so let's ask the user to enter their full name (no middle name) in the form first last such as Jane Doe, and store it in a variable fullName. Remember that in pure JavaScript, we use "+T2C.MSG.JS.TERMINAL_GETINPUTBYASKING+" for "+T2C.MSG.EN.TERMINAL_GETINPUTBYASKING+". As before, you'll drag in a type-in-code block, and type in the code."),o.clear(),Blockly.svgResize(o),ye(document.getElementById("output-container").querySelectorAll(".table-cell")[0]),Te(),a.createToolboxBlock("type_in_get_full_name"),o.options.maxInstances.type_in_get_full_name=1},isComplete:function(){return!0},animate:function(){return!0},finish:function(){}})),n.addTask(new r((function(){var e=o.getAllBlocks().filter((function(e){return"text"===e.type&&"string"==typeof e.getFieldValue("TEXT")&&-1!==e.getFieldValue("TEXT").toLowerCase().indexOf("full name")})),t=o.getAllBlocks().filter((function(t){return("text_input"===t.type||"js_text_input"===t.type)&&-1!==e.indexOf(t.getInputTargetBlock("TEXT"))})),n=o.getAllBlocks().filter((function(e){return"variables_set"===e.type&&-1!==t.indexOf(e.getInputTargetBlock("VALUE"))&&"fullName"===e.getField("VAR").getText()}));return 1===e.length&&1===t.length&&1===n.length}),new s((function(){return"Drag in the type-in-code block, and type the necessary code to ask the user for their full name in the form first last (no middle) and store it in a variable fullName. Be sure the message contains the text 'full name' to let the user know to type in his/her first and last name. Also, use the JavaScript "+T2C.MSG.JS.TERMINAL_GETINPUTBYASKING+" instead of "+T2C.MSG.EN.TERMINAL_GETINPUTBYASKING+"."}),{startPosition:xe(o,null,{},50,document.getElementById("top-header").offsetHeight+50)}))),n.addTask(new r((function(){return!0}),{start:function(){return!0},isComplete:function(){return!0},animate:function(){return!0},finish:function(){alert("✔ Acchaa (Good), so now with one more line of code we're going to finish today's mission! In this next step, you're going to display the user's initials (assuming he/she entered his/her correct name in the form first last). So for Jane Doe, you'd output J.D. (with the periods between the first and last initials)."),ye(document.getElementById("output-container").querySelectorAll(".table-cell")[0]),Te(),a.clearToolbox(),["js_text_print","js_text_input","js_text_indexof","js_text_charat","variables_set","variables_get","text"].forEach((function(e,t){a.createToolboxBlock(e,!1),o.options.maxInstances[e]=0})),function(e){var t=e.options.maxInstances;e.options.maxInstances={},e.getAllBlocks().forEach((function(t){e.options.maxInstances[t.type]=++e.options.maxInstances[t.type]||1})),Object.keys(t).forEach((function(n){e.options.maxInstances[n]=e.options.maxInstances[n]||t[n]}))}(o),a.createToolboxBlock("type_in_print_initials"),o.options.maxInstances.type_in_print_initials=1}})),n.addTask(new r((function(){var e=o.getAllBlocks().filter((function(e){return"text"===e.type&&"."===e.getFieldValue("TEXT")})),t=o.getAllBlocks().filter((function(e){return"math_number"===e.type&&1===e.getFieldValue("NUM")})),n=o.getAllBlocks().filter((function(e){return"text"===e.type&&" "===e.getFieldValue("TEXT")})),i=o.getAllBlocks().filter((function(e){return"variables_get"===e.type&&"fullName"===e.getField("VAR").getText()})),r=o.getAllBlocks().filter((function(e){return("js_text_indexof"===e.type||"t2c_text_indexof"===e.type)&&-1!==i.indexOf(e.getInputTargetBlock("VALUE"))&&-1!==n.indexOf(e.getInputTargetBlock("FIND"))})),a=o.getAllBlocks().filter((function(e){return"math_arithmetic_basic"===e.type&&-1!==r.indexOf(e.getInputTargetBlock("A"))&&-1!==t.indexOf(e.getInputTargetBlock("B"))&&"ADD"==e.getFieldValue("OP")})),l=o.getAllBlocks().filter((function(e){return("js_text_charat"===e.type||"t2c_text_charat"===e.type)&&-1!==i.indexOf(e.getInputTargetBlock("VALUE"))&&-1!==a.indexOf(e.getInputTargetBlock("AT"))})),s=o.getAllBlocks().filter((function(t){return"t2c_text_join"===t.type&&-1!==l.indexOf(t.getInputTargetBlock("A"))&&-1!==e.indexOf(t.getInputTargetBlock("B"))})),u=o.getAllBlocks().filter((function(t){return"t2c_text_join"===t.type&&-1!==e.indexOf(t.getInputTargetBlock("A"))&&-1!==s.indexOf(t.getInputTargetBlock("B"))})),c=o.getAllBlocks().filter((function(e){return"math_number"===e.type&&0===e.getFieldValue("NUM")})),g=o.getAllBlocks().filter((function(e){return("js_text_charat"===e.type||"t2c_text_charat"===e.type)&&-1!==i.indexOf(e.getInputTargetBlock("VALUE"))&&-1!==c.indexOf(e.getInputTargetBlock("AT"))})),d=o.getAllBlocks().filter((function(e){return"t2c_text_join"===e.type&&-1!==g.indexOf(e.getInputTargetBlock("A"))&&-1!==u.indexOf(e.getInputTargetBlock("B"))})),h=o.getAllBlocks().filter((function(e){return("js_text_print"===e.type||"t2c_text_print"===e.type)&&null===e.getNextBlock()&&-1!==d.indexOf(e.getInputTargetBlock("TEXT"))})),p=o.getAllBlocks().filter((function(e){return"text"===e.type&&"text"===e.type&&"string"==typeof e.getFieldValue("TEXT")&&-1!==e.getFieldValue("TEXT").toLowerCase().indexOf("full name")})),f=o.getAllBlocks().filter((function(e){return("js_text_input"===e.type||"t2c_text_input"===e.type)&&-1!==p.indexOf(e.getInputTargetBlock("TEXT"))})),m=o.getAllBlocks().filter((function(e){return"variables_set"===e.type&&-1!==h.indexOf(e.getNextBlock())&&-1!==f.indexOf(e.getInputTargetBlock("VALUE"))&&"fullName"===e.getField("VAR").getText()}));return 2===e.length&&1===t.length&&1===n.length&&3===i.length&&1===r.length&&1===a.length&&1===l.length&&1===s.length&&1===u.length&&1===c.length&&1===g.length&&1===d.length&&1===h.length&&1===p.length&&1===f.length&&1===m.length}),new s((function(){var e=o.getAllBlocks().find((function(e){return"variables_set"===e.type&&"fullName"===e.getField("VAR").getText()})),t=o.getAllBlocks().find((function(e){return"text_print"===e.type||"js_text_print"===e.type}));return e&&t&&t.getNextBlock()===e?"The "+T2C.MSG.currentLanguage.TERMINAL_DISPLAY+" block must go below the "+T2C.MSG.currentLanguage.TERMINAL_LET+" variable block setting fullName because the computer needs to know what the user's name is in order to display his/her initials. Remember that instructions are run from top to bottom.":t&&null===t.getPreviousBlock()?"Place the new "+T2C.MSG.currentLanguage.TERMINAL_DISPLAY+" block below the previous "+T2C.MSG.currentLanguage.TERMINAL_LET+" block setting fullName.":"Drag the type-in-code block, and type the necessary code to display the user's user's initials (assuming he/she entered his/her correct name in the form first last). So for Jane Doe, you'd output J.D. (with the periods between the first and last initials). Do this in one line!"}),{startPosition:xe(o,null,{},50,document.getElementById("top-header").offsetHeight+50)}))),function(e){e.addTask(new r((function(){return document.getElementById("output-container").classList.contains("show-container")}),new u([new s((function(){return T2C.MSG.currentLanguage.BUTTON_RUN_CODE}),{startPosition:{x:document.getElementById("run-code-button").offsetLeft+document.getElementById("run-code-button").offsetWidth,y:document.getElementById("run-code-button").offsetTop+document.getElementById("run-code-button").offsetHeight}}),new l(d,{totalSteps:100,toggleSteps:25,startPosition:{x:document.getElementById("run-code-button").offsetLeft+document.getElementById("run-code-button").offsetWidth/2,y:document.getElementById("run-code-button").offsetTop+document.getElementById("run-code-button").offsetHeight/2}})])))}(n),function(e,t){var n=0;function o(){t.style.color=n%50<25?"#a00":"#000",++n<200&&requestAnimationFrame(o)}e.addTask(new r((function(){return n>=200}),{start:function(){t.style.verticalAlign="top",requestAnimationFrame(o)},isComplete:function(){return!0},animate:function(){return!0}}))}(n,document.getElementById("output-container").querySelectorAll(".table-cell")[0]),n.addTask(new r((function(){return!0}),{start:function(){return!0},isComplete:function(){return!0},animate:function(){return!0},finish:function(){alert("✔✔✔ Outstanding! And with that single line of code wizadry, you got the user's initials and completed Mission # 8! Once again you typed an entire program in pure JavaScript! In the next mission 9, you'll face a new challenge of finding the third item in a list of items separated by commas. As you did in this mission, you'll be typing code in pure JavaScript. Stay tuned and phir milenge (See you again)!"),Te(),a.clearToolbox(),["code_statement"].forEach((function(e,t){a.createToolboxBlock(e,!1),o.options.maxInstances[e]=maxBlocks[t]}))}})),n},function(e,t){var n=e||new c,o=t||Blockly.getMainWorkspace(),a=new f(o);Be.start(),o.setScale(1),Object(i.f)(o);var s=document.createElement("div");function g(e,t){return{start:function(){Be.changeTab(Ae,"Directions",e),Be.changeTab(ve,"Feedback",t),Be.setSelectedTab(Ae)},isComplete:function(){return!1},animate:function(e){return Be.animate(e)}}}function d(e,t,n,o){e.addTask(function(e,t,n){return new r("function"==typeof e?e:function(){return!0},g(t,n))}(t,n,o))}function h(e){e.addTask(new r((function(){return document.getElementById("output-container").classList.contains("show-container")}),new u([g(T2C.MSG.currentLanguage.BUTTON_RUN_CODE,""),new l(s,{totalSteps:100,toggleSteps:25,startPosition:{x:document.getElementById("run-code-button").offsetLeft+document.getElementById("run-code-button").offsetWidth/2,y:document.getElementById("run-code-button").offsetTop+document.getElementById("run-code-button").offsetHeight/2}})])))}function p(e,t){var n=0;function o(){t.style.color=n%50<25?"#a00":"#000",++n<200&&requestAnimationFrame(o)}e.addTask(new r((function(){return n>=200}),{start:function(){t.style.verticalAlign="top",requestAnimationFrame(o)},isComplete:function(){return!0},animate:function(){return!0}}))}function m(e){var t=e.options.maxInstances;e.options.maxInstances={},e.getAllBlocks().forEach((function(t){e.options.maxInstances[t.type]=++e.options.maxInstances[t.type]||1})),Object.keys(t).forEach((function(n){e.options.maxInstances[n]=e.options.maxInstances[n]||t[n]}))}return s.innerText="👆",s.id="ptr",s.style.fontSize="x-large",s.style.position="absolute",s.style.zIndex="1001",document.getElementById("blockly-div").appendChild(s),n.addTask(new r((function(){return T2C.MSG.currentLanguage===T2C.MSG.JS}),new u([g("To start, select JavaScript from the dropdown menu at the top and watch how the blocks in the toolbox transform to their JavaScript equivalents.",""),{start:function(){var e=T2C.MSG.currentLanguage===T2C.MSG.JS?"":"So to start, select JavaScript from the dropdown menu at the top and watch how the blocks in the toolbox transform to their JavaScript equivalents.";a.clearToolbox(),["text_print","text_input","t2c_text_indexof","t2c_text_getsubstring","variables_set","variables_get"].forEach((function(e,t){a.createToolboxBlock(e,!1),o.options.maxInstances[e]=0})),alert("In this mission, you'll ask the user for a list of at least four (chaar in Hindi) items separated by commas and display its third item. For example, for an input of "+Ie+", you'd output "+Oe+" while for an input of "+we+", you'd output "+Ce+". Once again we're going to be working in pure JavaScript. "+e),o.clear(),Blockly.svgResize(o),Re(document.getElementById("output-container").querySelectorAll(".table-cell")[0]),Fe()},isComplete:function(){return!0},animate:function(){return!0},finish:function(){}}]))),n.addTask(new r((function(){return!0}),{start:function(){alert("Theek hai (OK), so as usual, let's start by asking the user to enter a string, this time a list of at least chaar items, separated by commas, and store it in a variable itemList. Drag in a type-in-code block, and type in the code to do this. Be sure the message includes the text 'at least 4' in it so the user knows to enter at least 4 items (separated by commas)."),o.clear(),Blockly.svgResize(o),Re(document.getElementById("output-container").querySelectorAll(".table-cell")[0]),Fe(),a.createToolboxBlock("type_in_get_item_list"),o.options.maxInstances.type_in_get_item_list=1},isComplete:function(){return!0},animate:function(){return!0},finish:function(){}})),d(n,(function(){var e=o.getAllBlocks().filter((function(e){return"text"===e.type&&"string"==typeof e.getFieldValue("TEXT")&&-1!==e.getFieldValue("TEXT").toLowerCase().indexOf("at least 4")})),t=o.getAllBlocks().filter((function(t){return("text_input"===t.type||"js_text_input"===t.type)&&-1!==e.indexOf(t.getInputTargetBlock("TEXT"))})),n=o.getAllBlocks().filter((function(e){return"variables_set"===e.type&&null===e.getNextBlock()&&-1!==t.indexOf(e.getInputTargetBlock("VALUE"))&&"itemList"===e.getField("VAR").getText()}));return 1===e.length&&1===t.length&&1===n.length}),(function(){return"Drag in the type-in-code block, and type the necessary code to ask the user for a list of at least 4 items, separated by commas, and store it in a variable itemList. Be sure the message contains the text 'at least 4' to let the user know to type in a minimum of this number of items."}),(function(){return o.getAllBlocks().find((function(e){return"text"===e.type})),o.getAllBlocks().find((function(e){return"text_input"===e.type||"js_text_input"===e.type})),o.getAllBlocks().find((function(e){return"variables_set"===e.type})),o.getAllBlocks().find((function(e){return"type_in_get_item_list"===e.type}))?Ge.getErrorFeedback():""})),n.addTask(new r((function(){return!0}),{start:function(){alert("✔ Acchaa (Good). Since in this problem we're going to consider multiple sublists of the original one, i.e., lists that contain some (or all) of the items from the original, we're going to display each one as we solve this problem to see what's happening. So now let's start by displaying the original one."),Blockly.svgResize(o),a.removeToolboxBlocks((function(e){return"type_in_get_item_list"===e.getAttribute("type")})),m(o),a.createToolboxBlock("type_in_display_item_list"),o.options.maxInstances.type_in_display_item_list=1},isComplete:function(){return!0},animate:function(){return!0},finish:function(){}})),d(n,(function(){var e=o.getAllBlocks().filter((function(e){return"variables_get"===e.type&&"itemList"===e.getField("VAR").getText()})),t=o.getAllBlocks().filter((function(t){return("text_print"===t.type||"js_text_print"===t.type)&&null===t.getNextBlock()&&-1!==e.indexOf(t.getInputTargetBlock("TEXT"))})),n=o.getAllBlocks().filter((function(e){return"text"===e.type&&"string"==typeof e.getFieldValue("TEXT")&&-1!==e.getFieldValue("TEXT").toLowerCase().indexOf("at least 4")})),i=o.getAllBlocks().filter((function(e){return("text_input"===e.type||"js_text_input"===e.type)&&-1!==n.indexOf(e.getInputTargetBlock("TEXT"))})),r=o.getAllBlocks().filter((function(e){return"variables_set"===e.type&&-1!==t.indexOf(e.getNextBlock())&&-1!==i.indexOf(e.getInputTargetBlock("VALUE"))&&"itemList"===e.getField("VAR").getText()}));return 1===e.length&&1===t.length&&1===n.length&&1===i.length&&1===r.length}),(function(){return"Drag in the type-in-code block, and type the necessary code to display the inputted item list, stored in itemList."}),(function(){o.getAllBlocks().find((function(e){return"variables_get"===e.type}));var e=o.getAllBlocks().find((function(e){return"text_print"===e.type||"js_text_print"===e.type})),t=(o.getAllBlocks().find((function(e){return"text"===e.type})),o.getAllBlocks().find((function(e){return"text_input"===e.type||"js_text_input"===e.type})),o.getAllBlocks().find((function(e){return"variables_set"===e.type}))),n=o.getAllBlocks().find((function(e){return"type_in_display_item_list"===e.type}));return t&&e&&e.getNextBlock()===t?"The "+T2C.MSG.currentLanguage.TERMINAL_DISPLAY+" block must go below the "+T2C.MSG.currentLanguage.TERMINAL_LET+" variable block setting itemList because the computer uses the value of this variable in the "+T2C.MSG.currentLanguage.TERMINAL_DISPLAY+" block. Since instructions are run from top to bottom, it won't know what itemList means, otherwise!":e?"Place the "+T2C.MSG.currentLanguage.TERMINAL_DISPLAY+" block below the "+T2C.MSG.currentLanguage.TERMINAL_LET+" variable block setting itemList so the computer can use the value of this variable in the "+T2C.MSG.currentLanguage.TERMINAL_DISPLAY+" block.":n?Ue.getErrorFeedback():""})),h(n),p(n,document.getElementById("output-container").querySelectorAll(".table-cell")[0]),n.addTask(new r((function(){return!0}),{start:function(){alert("✔ Phir se acchaa (Good again), so now think back to Mission # 5 where we found the text between the first @ and . Do you remember how we did that? Do you think you could use a similar strategy here? If not, what goes wrong?");for(var e="What is the problem? (Enter a, b, c, or d.)\nA. We can only use "+T2C.MSG.currentLanguage.TERMINAL_GETTEXTFROMPOSITIONNUMBER+" to extract text starting from the beginning of a string OR ending at its end and the third item neither starts at the beginning nor ends at its end.\nB. "+T2C.MSG.currentLanguage.TERMINAL_FINDFIRSTOCCURRENCEOFTEXT+" can only be used to get the position of the first occurrence of something in a string and the third item appears between the third and fourth commas.\nC. "+T2C.MSG.currentLanguage.TERMINAL_FINDFIRSTOCCURRENCEOFTEXT+" can only be used to get the position of the first occurrence of something in a string and the third item appears between the second and third commas.\nD. "+T2C.MSG.currentLanguage.TERMINAL_GETCHARACTERNUMBER+" can only be used to get the comma, not a character that comes after it.",t=prompt(e);"string"==typeof t&&!t.toLowerCase().startsWith("c");)t=prompt("No, "+t[0]+" is not correct. Please try again. "+e);for(alert((t?"Yes":"OK, we'll tell you")+", C "+T2C.MSG.currentLanguage.TERMINAL_FINDFIRSTOCCURRENCEOFTEXT+" can only be used to get the position of the first occurrence of something in a string and the third item appears between the second and third commas is the correct answer. So as we did in problem 6, we'll work backwards in steps, trying to use the tools we have to bridge the gap between what we start with and what we want to end up with. For an input of "+Ie+", the output would be "+Oe+"."),e="Which of the following lists could we get "+Oe+" from using only one "+T2C.MSG.currentLanguage.TERMINAL_FINDFIRSTOCCURRENCEOFTEXT+"? (Enter a, b, c, or d.)\nA. "+Ie+"\nB. "+Se+"\nC. "+Ne+"\nD. "+Se.substring(0,Se.lastIndexOf(",")),t=prompt(e);"string"==typeof t&&!t.toLowerCase().startsWith("c");)t=prompt("No, "+t[0]+" is not correct. Please try again. "+e);for(alert((t?"Yes":"OK, we'll tell you")+", C "+Ne+" is the correct answer. We can get the third item of "+Oe+" from "+Ne+"."),e="Now which of the following lists could we get "+Ne+" from using only one "+T2C.MSG.currentLanguage.TERMINAL_FINDFIRSTOCCURRENCEOFTEXT+"? (Enter a, b, c, or d.)\nA. "+Ie+"\nB. "+Se+"\nC. "+Oe+"\nD. "+Ie.substring(0,Ie.lastIndexOf(",")),t=prompt(e);"string"==typeof t&&!t.toLowerCase().startsWith("b");)t=prompt("No, "+t[0]+" is not correct. Please try again. "+e);alert((t?"Exactly":"OK, we'll tell you")+", B "+Se+" is the correct answer. And then finally, we could get this string using only one "+T2C.MSG.currentLanguage.TERMINAL_FINDFIRSTOCCURRENCEOFTEXT+" from the original entered "+Ie+". So to summarize, going forward, we start with "+Ie+", where the desired third item is between the second and third commas, then chop off its first item to get "+Se+" where the desired item is the second one between the first and second commas, chop off its first item to get "+Ne+" where the desired item is now first and appears before the *first* comma. Then we can get the first item in this list, which is the original third item. So let's start by chopping off the first item from itemList."),a.removeToolboxBlocks((function(e){return"type_in_display_item_list"===e.getAttribute("type")})),m(o),a.createToolboxBlock("type_in_set_after_first"),o.options.maxInstances.type_in_set_after_first=1,Re(document.getElementById("output-container").querySelectorAll(".table-cell")[0]),Fe()},isComplete:function(){return!0},animate:function(){return!0},finish:function(){}})),d(n,(function(){var e=o.getAllBlocks().filter((function(e){return"variables_get"===e.type&&"itemList"===e.getField("VAR").getText()})),t=o.getAllBlocks().filter((function(t){return"t2c_text_length"===t.type&&-1!==e.indexOf(t.getInputTargetBlock("VALUE"))})),n=o.getAllBlocks().filter((function(e){return"math_number"===e.type&&1===e.getFieldValue("NUM")})),i=o.getAllBlocks().filter((function(e){return"text"===e.type&&","===e.getFieldValue("TEXT")})),r=o.getAllBlocks().filter((function(t){return("js_text_indexof"===t.type||"t2c_text_indexof"===t.type)&&-1!==e.indexOf(t.getInputTargetBlock("VALUE"))&&-1!==i.indexOf(t.getInputTargetBlock("FIND"))})),a=o.getAllBlocks().filter((function(e){return"math_arithmetic_basic"===e.type&&-1!==r.indexOf(e.getInputTargetBlock("A"))&&-1!==n.indexOf(e.getInputTargetBlock("B"))&&"ADD"===e.getFieldValue("OP")})),l=o.getAllBlocks().filter((function(n){return("js_text_getsubstring"===n.type||"t2c_text_getsubstring"===n.type)&&-1!==e.indexOf(n.getInputTargetBlock("STRING"))&&-1!==a.indexOf(n.getInputTargetBlock("AT1"))&&-1!==t.indexOf(n.getInputTargetBlock("AT2"))})),s=o.getAllBlocks().filter((function(e){return"variables_set"===e.type&&null===e.getNextBlock()&&-1!==l.indexOf(e.getInputTargetBlock("VALUE"))&&"afterFirstComma"===e.getField("VAR").getText()})),u=o.getAllBlocks().filter((function(t){return("text_print"===t.type||"js_text_print"===t.type)&&-1!==s.indexOf(t.getNextBlock())&&-1!==e.indexOf(t.getInputTargetBlock("TEXT"))})),c=o.getAllBlocks().filter((function(e){return"text"===e.type&&"string"==typeof e.getFieldValue("TEXT")&&-1!==e.getFieldValue("TEXT").toLowerCase().indexOf("at least 4")})),g=o.getAllBlocks().filter((function(e){return("text_input"===e.type||"js_text_input"===e.type)&&-1!==c.indexOf(e.getInputTargetBlock("TEXT"))})),d=o.getAllBlocks().filter((function(e){return"variables_set"===e.type&&-1!==u.indexOf(e.getNextBlock())&&-1!==g.indexOf(e.getInputTargetBlock("VALUE"))&&"itemList"===e.getField("VAR").getText()}));return 4===e.length&&1===t.length&&1===n.length&&1===i.length&&1===r.length&&1===a.length&&1===l.length&&1===s.length&&1===u.length&&1===c.length&&1===g.length&&1===d.length}),(function(){return"Drag in the type-in-code block, and type the necessary code to get all items from itemList after the first comma (second item on) and store the result in the variable afterFirstComma. Then place the block below the one displaying the entire list."}),(function(){var e=o.getAllBlocks().filter((function(e){return"variables_get"===e.type&&"itemList"===e.getField("VAR").getText()})),t=o.getAllBlocks().find((function(t){return("text_print"===t.type||"js_text_print"===t.type)&&-1!==e.indexOf(t.getInputTargetBlock("TEXT"))})),n=o.getAllBlocks().find((function(e){return"variables_set"===e.type&&"itemList"===e.getField("VAR").getText()})),i=o.getAllBlocks().find((function(e){return"variables_set"===e.type&&"afterFirstComma"===e.getField("VAR").getText()})),r=o.getAllBlocks().find((function(e){return"type_in_set_after_first"===e.type}));return n&&i&&i.getNextBlock()===n?"The "+T2C.MSG.currentLanguage.TERMINAL_LET+" variable block setting afterFirstComma must go below the "+T2C.MSG.currentLanguage.TERMINAL_LET+" variable block setting itemList because the computer uses this one to determine what afterFirstComma is. Since instructions are run from top to bottom, it won't know what itemList means, otherwise!":n&&t&&t.getNextBlock()===n?"The "+T2C.MSG.currentLanguage.TERMINAL_DISPLAY+" block must go below the "+T2C.MSG.currentLanguage.TERMINAL_LET+" variable block setting itemList because the computer uses the value of this variable in the "+T2C.MSG.currentLanguage.TERMINAL_DISPLAY+" block. Since instructions are run from top to bottom, it won't know what itemList means, otherwise!":t&&i&&t.getNextBlock()!==i?"Place the "+T2C.MSG.currentLanguage.TERMINAL_LET+" variable block setting afterFirstComma below the "+T2C.MSG.currentLanguage.TERMINAL_DISPLAY+" block displaying the original item list.":r?Xe.getErrorFeedback():""})),n.addTask(new r((function(){return!0}),{start:function(){alert("✔ Bahut acchaa (very good), so let's display this new list, which will be the original one with its first item removed."),a.removeToolboxBlocks((function(e){return"type_in_set_after_first"===e.getAttribute("type")})),m(o),a.createToolboxBlock("type_in_display_after_first"),o.options.maxInstances.type_in_display_after_first=1,Re(document.getElementById("output-container").querySelectorAll(".table-cell")[0]),Fe()},isComplete:function(){return!0},animate:function(){return!0},finish:function(){}})),d(n,(function(){var e=o.getAllBlocks().filter((function(e){return"variables_get"===e.type&&"afterFirstComma"===e.getField("VAR").getText()})),t=o.getAllBlocks().filter((function(t){return("text_print"===t.type||"js_text_print"===t.type)&&null===t.getNextBlock()&&-1!==e.indexOf(t.getInputTargetBlock("TEXT"))})),n=o.getAllBlocks().filter((function(e){return"variables_get"===e.type&&"itemList"===e.getField("VAR").getText()})),i=o.getAllBlocks().filter((function(e){return"t2c_text_length"===e.type&&-1!==n.indexOf(e.getInputTargetBlock("VALUE"))})),r=o.getAllBlocks().filter((function(e){return"math_number"===e.type&&1===e.getFieldValue("NUM")})),a=o.getAllBlocks().filter((function(e){return"text"===e.type&&","===e.getFieldValue("TEXT")})),l=o.getAllBlocks().filter((function(e){return("js_text_indexof"===e.type||"t2c_text_indexof"===e.type)&&-1!==n.indexOf(e.getInputTargetBlock("VALUE"))&&-1!==a.indexOf(e.getInputTargetBlock("FIND"))})),s=o.getAllBlocks().filter((function(e){return"math_arithmetic_basic"===e.type&&-1!==l.indexOf(e.getInputTargetBlock("A"))&&-1!==r.indexOf(e.getInputTargetBlock("B"))&&"ADD"===e.getFieldValue("OP")})),u=o.getAllBlocks().filter((function(e){return("js_text_getsubstring"===e.type||"t2c_text_getsubstring"===e.type)&&-1!==n.indexOf(e.getInputTargetBlock("STRING"))&&-1!==s.indexOf(e.getInputTargetBlock("AT1"))&&-1!==i.indexOf(e.getInputTargetBlock("AT2"))})),c=o.getAllBlocks().filter((function(e){return"variables_set"===e.type&&-1!==t.indexOf(e.getNextBlock())&&-1!==u.indexOf(e.getInputTargetBlock("VALUE"))&&"afterFirstComma"===e.getField("VAR").getText()})),g=o.getAllBlocks().filter((function(e){return("text_print"===e.type||"js_text_print"===e.type)&&-1!==c.indexOf(e.getNextBlock())&&-1!==n.indexOf(e.getInputTargetBlock("TEXT"))})),d=o.getAllBlocks().filter((function(e){return"text"===e.type&&"string"==typeof e.getFieldValue("TEXT")&&-1!==e.getFieldValue("TEXT").toLowerCase().indexOf("at least 4")})),h=o.getAllBlocks().filter((function(e){return("text_input"===e.type||"js_text_input"===e.type)&&-1!==d.indexOf(e.getInputTargetBlock("TEXT"))})),p=o.getAllBlocks().filter((function(e){return"variables_set"===e.type&&-1!==g.indexOf(e.getNextBlock())&&-1!==h.indexOf(e.getInputTargetBlock("VALUE"))&&"itemList"===e.getField("VAR").getText()}));return 1===e.length&&1===t.length&&4===n.length&&1===i.length&&1===r.length&&1===a.length&&1===l.length&&1===s.length&&1===u.length&&1===c.length&&1===g.length&&1===d.length&&1===h.length&&1===p.length}),(function(){return"Drag in the type-in-code block, and type the necessary code to display afterFirstComma, which will be all items from itemList after the first comma (second item on). Then place the block below the one setting afterFirstComma."}),(function(){var e=o.getAllBlocks().filter((function(e){return"variables_get"===e.type&&"afterFirstComma"===e.getField("VAR").getText()})),t=o.getAllBlocks().find((function(t){return("text_print"===t.type||"js_text_print"===t.type)&&-1!==e.indexOf(t.getInputTargetBlock("TEXT"))})),n=o.getAllBlocks().filter((function(e){return"variables_get"===e.type&&"itemList"===e.getField("VAR").getText()})),i=o.getAllBlocks().find((function(e){return("text_print"===e.type||"js_text_print"===e.type)&&-1!==n.indexOf(e.getInputTargetBlock("TEXT"))})),r=o.getAllBlocks().find((function(e){return"variables_set"===e.type&&"itemList"===e.getField("VAR").getText()})),a=o.getAllBlocks().find((function(e){return"variables_set"===e.type&&"afterFirstComma"===e.getField("VAR").getText()})),l=o.getAllBlocks().find((function(e){return"type_in_display_after_first"===e.type}));return r&&a&&a.getNextBlock()===r?"The "+T2C.MSG.currentLanguage.TERMINAL_LET+" variable block setting afterFirstComma must go below the "+T2C.MSG.currentLanguage.TERMINAL_LET+" variable block setting itemList because the computer uses this one to determine what afterFirstComma is. Since instructions are run from top to bottom, it won't know what itemList means, otherwise!":r&&i&&i.getNextBlock()===r?"The "+T2C.MSG.currentLanguage.TERMINAL_DISPLAY+" block must go below the "+T2C.MSG.currentLanguage.TERMINAL_LET+" variable block setting itemList because the computer uses the value of this variable in the "+T2C.MSG.currentLanguage.TERMINAL_DISPLAY+" block. Since instructions are run from top to bottom, it won't know what itemList means, otherwise!":a&&t&&t.getNextBlock()===a?"The "+T2C.MSG.currentLanguage.TERMINAL_DISPLAY+" block must go below the "+T2C.MSG.currentLanguage.TERMINAL_LET+" variable block setting afterFirstComma because the computer uses the value of this variable in the "+T2C.MSG.currentLanguage.TERMINAL_DISPLAY+" block. Since instructions are run from top to bottom, it won't know what afterFirstComma means, otherwise!":t?"Place the "+T2C.MSG.currentLanguage.TERMINAL_DISPLAY+" block displaying afterFirstComma below the "+T2C.MSG.currentLanguage.TERMINAL_LET+" variable block setting its value.":l?je.getErrorFeedback():""})),h(n),p(n,document.getElementById("output-container").querySelectorAll(".table-cell")[0]),n.addTask(new r((function(){return!0}),{start:function(){alert("✔ Phir se bahut acchaa (very good again), so now let's get the original list with its first two items removed by removing the first one from this new sublist."),a.removeToolboxBlocks((function(e){return"type_in_display_after_first"===e.getAttribute("type")})),m(o),a.createToolboxBlock("type_in_set_after_second"),o.options.maxInstances.type_in_set_after_second=1,Re(document.getElementById("output-container").querySelectorAll(".table-cell")[0]),Fe()},isComplete:function(){return!0},animate:function(){return!0},finish:function(){}})),d(n,(function(){var e=o.getAllBlocks().filter((function(e){return"variables_get"===e.type&&"afterFirstComma"===e.getField("VAR").getText()})),t=o.getAllBlocks().filter((function(t){return"t2c_text_length"===t.type&&-1!==e.indexOf(t.getInputTargetBlock("VALUE"))})),n=o.getAllBlocks().filter((function(e){return"math_number"===e.type&&1===e.getFieldValue("NUM")})),i=o.getAllBlocks().filter((function(e){return"text"===e.type&&","===e.getFieldValue("TEXT")})),r=o.getAllBlocks().filter((function(t){return("js_text_indexof"===t.type||"t2c_text_indexof"===t.type)&&-1!==e.indexOf(t.getInputTargetBlock("VALUE"))&&-1!==i.indexOf(t.getInputTargetBlock("FIND"))})),a=o.getAllBlocks().filter((function(e){return"math_arithmetic_basic"===e.type&&-1!==r.indexOf(e.getInputTargetBlock("A"))&&-1!==n.indexOf(e.getInputTargetBlock("B"))&&"ADD"===e.getFieldValue("OP")})),l=o.getAllBlocks().filter((function(n){return("js_text_getsubstring"===n.type||"t2c_text_getsubstring"===n.type)&&-1!==e.indexOf(n.getInputTargetBlock("STRING"))&&-1!==a.indexOf(n.getInputTargetBlock("AT1"))&&-1!==t.indexOf(n.getInputTargetBlock("AT2"))})),s=o.getAllBlocks().filter((function(e){return"variables_set"===e.type&&null===e.getNextBlock()&&-1!==l.indexOf(e.getInputTargetBlock("VALUE"))&&"afterSecondComma"===e.getField("VAR").getText()})),u=o.getAllBlocks().filter((function(t){return("text_print"===t.type||"js_text_print"===t.type)&&-1!==s.indexOf(t.getNextBlock())&&-1!==e.indexOf(t.getInputTargetBlock("TEXT"))})),c=o.getAllBlocks().filter((function(e){return"variables_get"===e.type&&"itemList"===e.getField("VAR").getText()})),g=o.getAllBlocks().filter((function(e){return"t2c_text_length"===e.type&&-1!==c.indexOf(e.getInputTargetBlock("VALUE"))})),d=o.getAllBlocks().filter((function(e){return("js_text_indexof"===e.type||"t2c_text_indexof"===e.type)&&-1!==c.indexOf(e.getInputTargetBlock("VALUE"))&&-1!==i.indexOf(e.getInputTargetBlock("FIND"))})),h=o.getAllBlocks().filter((function(e){return"math_arithmetic_basic"===e.type&&-1!==d.indexOf(e.getInputTargetBlock("A"))&&-1!==n.indexOf(e.getInputTargetBlock("B"))&&"ADD"===e.getFieldValue("OP")})),p=o.getAllBlocks().filter((function(e){return("js_text_getsubstring"===e.type||"t2c_text_getsubstring"===e.type)&&-1!==c.indexOf(e.getInputTargetBlock("STRING"))&&-1!==h.indexOf(e.getInputTargetBlock("AT1"))&&-1!==g.indexOf(e.getInputTargetBlock("AT2"))})),f=o.getAllBlocks().filter((function(e){return"variables_set"===e.type&&-1!==u.indexOf(e.getNextBlock())&&-1!==p.indexOf(e.getInputTargetBlock("VALUE"))&&"afterFirstComma"===e.getField("VAR").getText()})),m=o.getAllBlocks().filter((function(e){return("text_print"===e.type||"js_text_print"===e.type)&&-1!==f.indexOf(e.getNextBlock())&&-1!==c.indexOf(e.getInputTargetBlock("TEXT"))})),y=o.getAllBlocks().filter((function(e){return"text"===e.type&&"string"==typeof e.getFieldValue("TEXT")&&-1!==e.getFieldValue("TEXT").toLowerCase().indexOf("at least 4")})),T=o.getAllBlocks().filter((function(e){return("text_input"===e.type||"js_text_input"===e.type)&&-1!==y.indexOf(e.getInputTargetBlock("TEXT"))})),_=o.getAllBlocks().filter((function(e){return"variables_set"===e.type&&-1!==m.indexOf(e.getNextBlock())&&-1!==T.indexOf(e.getInputTargetBlock("VALUE"))&&"itemList"===e.getField("VAR").getText()}));return 4===e.length&&1===t.length&&2===n.length&&2===i.length&&1===r.length&&1===a.length&&1===l.length&&1===s.length&&1===u.length&&4===c.length&&1===g.length&&1===d.length&&1===h.length&&1===p.length&&1===f.length&&1===m.length&&1===y.length&&1===T.length&&1===_.length}),(function(){return"Drag in the type-in-code block, and type the necessary code to get all items from afterFirstComma after its first comma (second item until end of afterFirstComma, which will be the third item until end of original item list) and store the result in the variable afterSecondComma. Then place the block below the one displaying afterFirstComma."}),(function(){var e=o.getAllBlocks().filter((function(e){return"variables_get"===e.type&&"afterFirstComma"===e.getField("VAR").getText()})),t=o.getAllBlocks().find((function(e){return"variables_set"===e.type&&"afterSecondComma"===e.getField("VAR").getText()})),n=o.getAllBlocks().filter((function(e){return"variables_get"===e.type&&"itemList"===e.getField("VAR").getText()})),i=o.getAllBlocks().find((function(t){return("text_print"===t.type||"js_text_print"===t.type)&&-1!==e.indexOf(t.getInputTargetBlock("TEXT"))})),r=o.getAllBlocks().find((function(e){return"variables_set"===e.type&&"afterFirstComma"===e.getField("VAR").getText()})),a=o.getAllBlocks().find((function(e){return("text_print"===e.type||"js_text_print"===e.type)&&-1!==n.indexOf(e.getInputTargetBlock("TEXT"))})),l=o.getAllBlocks().find((function(e){return"variables_set"===e.type&&"itemList"===e.getField("VAR").getText()})),s=o.getAllBlocks().find((function(e){return"type_in_set_after_second"===e.type}));return r&&t&&t.getNextBlock()===r?"The "+T2C.MSG.currentLanguage.TERMINAL_LET+" variable block setting afterSecondComma must go below the "+T2C.MSG.currentLanguage.TERMINAL_LET+" variable block setting afterFirstComma because the computer uses this one to determine what afterSecondComma is. Since instructions are run from top to bottom, it won't know what afterFirstComma means, otherwise!":r&&i&&i.getNextBlock()===r?"The "+T2C.MSG.currentLanguage.TERMINAL_DISPLAY+" block must go below the "+T2C.MSG.currentLanguage.TERMINAL_LET+" variable block setting afterFirstComma because the computer uses the value of this variable in the "+T2C.MSG.currentLanguage.TERMINAL_DISPLAY+" block. Since instructions are run from top to bottom, it won't know what afterFirstComma means, otherwise!":l&&r&&r.getNextBlock()===l?"The "+T2C.MSG.currentLanguage.TERMINAL_LET+" variable block setting afterFirstComma must go below the "+T2C.MSG.currentLanguage.TERMINAL_LET+" variable block setting itemList because the computer uses this one to determine what afterFirstComma is. Since instructions are run from top to bottom, it won't know what itemList means, otherwise!":l&&a&&a.getNextBlock()===l?"The "+T2C.MSG.currentLanguage.TERMINAL_DISPLAY+" block must go below the "+T2C.MSG.currentLanguage.TERMINAL_LET+" variable block setting itemList because the computer uses the value of this variable in the "+T2C.MSG.currentLanguage.TERMINAL_DISPLAY+" block. Since instructions are run from top to bottom, it won't know what itemList means, otherwise!":i&&t&&i.getNextBlock()!==t?"Place the "+T2C.MSG.currentLanguage.TERMINAL_LET+" variable block setting afterSecondComma below the "+T2C.MSG.currentLanguage.TERMINAL_DISPLAY+" block displaying afterFirstComma.":s?De.getErrorFeedback():""})),n.addTask(new r((function(){return!0}),{start:function(){alert("✔ Mahaan (great), so let's display this new list, which will be the original one with its first two items removed."),a.removeToolboxBlocks((function(e){return"type_in_set_after_second"===e.getAttribute("type")})),m(o),a.createToolboxBlock("type_in_display_after_second"),o.options.maxInstances.type_in_display_after_second=1,Re(document.getElementById("output-container").querySelectorAll(".table-cell")[0]),Fe()},isComplete:function(){return!0},animate:function(){return!0},finish:function(){}})),d(n,(function(){var e=o.getAllBlocks().filter((function(e){return"variables_get"===e.type&&"afterSecondComma"===e.getField("VAR").getText()})),t=o.getAllBlocks().filter((function(t){return("text_print"===t.type||"js_text_print"===t.type)&&null===t.getNextBlock()&&-1!==e.indexOf(t.getInputTargetBlock("TEXT"))})),n=o.getAllBlocks().filter((function(e){return"variables_get"===e.type&&"afterFirstComma"===e.getField("VAR").getText()})),i=o.getAllBlocks().filter((function(e){return"t2c_text_length"===e.type&&-1!==n.indexOf(e.getInputTargetBlock("VALUE"))})),r=o.getAllBlocks().filter((function(e){return"math_number"===e.type&&1===e.getFieldValue("NUM")})),a=o.getAllBlocks().filter((function(e){return"text"===e.type&&","===e.getFieldValue("TEXT")})),l=o.getAllBlocks().filter((function(e){return("js_text_indexof"===e.type||"t2c_text_indexof"===e.type)&&-1!==n.indexOf(e.getInputTargetBlock("VALUE"))&&-1!==a.indexOf(e.getInputTargetBlock("FIND"))})),s=o.getAllBlocks().filter((function(e){return"math_arithmetic_basic"===e.type&&-1!==l.indexOf(e.getInputTargetBlock("A"))&&-1!==r.indexOf(e.getInputTargetBlock("B"))&&"ADD"===e.getFieldValue("OP")})),u=o.getAllBlocks().filter((function(e){return("js_text_getsubstring"===e.type||"t2c_text_getsubstring"===e.type)&&-1!==n.indexOf(e.getInputTargetBlock("STRING"))&&-1!==s.indexOf(e.getInputTargetBlock("AT1"))&&-1!==i.indexOf(e.getInputTargetBlock("AT2"))})),c=o.getAllBlocks().filter((function(e){return"variables_set"===e.type&&-1!==t.indexOf(e.getNextBlock())&&-1!==u.indexOf(e.getInputTargetBlock("VALUE"))&&"afterSecondComma"===e.getField("VAR").getText()})),g=o.getAllBlocks().filter((function(e){return("text_print"===e.type||"js_text_print"===e.type)&&-1!==c.indexOf(e.getNextBlock())&&-1!==n.indexOf(e.getInputTargetBlock("TEXT"))})),d=o.getAllBlocks().filter((function(e){return"variables_get"===e.type&&"itemList"===e.getField("VAR").getText()})),h=o.getAllBlocks().filter((function(e){return"t2c_text_length"===e.type&&-1!==d.indexOf(e.getInputTargetBlock("VALUE"))})),p=o.getAllBlocks().filter((function(e){return("js_text_indexof"===e.type||"t2c_text_indexof"===e.type)&&-1!==d.indexOf(e.getInputTargetBlock("VALUE"))&&-1!==a.indexOf(e.getInputTargetBlock("FIND"))})),f=o.getAllBlocks().filter((function(e){return"math_arithmetic_basic"===e.type&&-1!==p.indexOf(e.getInputTargetBlock("A"))&&-1!==r.indexOf(e.getInputTargetBlock("B"))&&"ADD"===e.getFieldValue("OP")})),m=o.getAllBlocks().filter((function(e){return("js_text_getsubstring"===e.type||"t2c_text_getsubstring"===e.type)&&-1!==d.indexOf(e.getInputTargetBlock("STRING"))&&-1!==f.indexOf(e.getInputTargetBlock("AT1"))&&-1!==h.indexOf(e.getInputTargetBlock("AT2"))})),y=o.getAllBlocks().filter((function(e){return"variables_set"===e.type&&-1!==g.indexOf(e.getNextBlock())&&-1!==m.indexOf(e.getInputTargetBlock("VALUE"))&&"afterFirstComma"===e.getField("VAR").getText()})),T=o.getAllBlocks().filter((function(e){return("text_print"===e.type||"js_text_print"===e.type)&&-1!==y.indexOf(e.getNextBlock())&&-1!==d.indexOf(e.getInputTargetBlock("TEXT"))})),_=o.getAllBlocks().filter((function(e){return"text"===e.type&&"string"==typeof e.getFieldValue("TEXT")&&-1!==e.getFieldValue("TEXT").toLowerCase().indexOf("at least 4")})),b=o.getAllBlocks().filter((function(e){return("text_input"===e.type||"js_text_input"===e.type)&&-1!==_.indexOf(e.getInputTargetBlock("TEXT"))})),k=o.getAllBlocks().filter((function(e){return"variables_set"===e.type&&-1!==T.indexOf(e.getNextBlock())&&-1!==b.indexOf(e.getInputTargetBlock("VALUE"))&&"itemList"===e.getField("VAR").getText()}));return 1===e.length&&1===t.length&&4===n.length&&1===i.length&&2===r.length&&2===a.length&&1===l.length&&1===s.length&&1===u.length&&1===c.length&&1===g.length&&4===d.length&&1===h.length&&1===p.length&&1===f.length&&1===m.length&&1===y.length&&1===T.length&&1===_.length&&1===b.length&&1===k.length}),(function(){return"Drag in the type-in-code block, and type the necessary code to display the original item list with its first two items removed (afterSecondComma). Then place the block below the one setting afterSecondComma."}),(function(){var e=o.getAllBlocks().filter((function(e){return"variables_get"===e.type&&"afterSecondComma"===e.getField("VAR").getText()})),t=o.getAllBlocks().find((function(t){return("text_print"===t.type||"js_text_print"===t.type)&&-1!==e.indexOf(t.getInputTargetBlock("TEXT"))})),n=o.getAllBlocks().filter((function(e){return"variables_get"===e.type&&"afterFirstComma"===e.getField("VAR").getText()})),i=o.getAllBlocks().find((function(e){return"variables_set"===e.type&&"afterSecondComma"===e.getField("VAR").getText()})),r=o.getAllBlocks().find((function(e){return("text_print"===e.type||"js_text_print"===e.type)&&-1!==n.indexOf(e.getInputTargetBlock("TEXT"))})),a=o.getAllBlocks().filter((function(e){return"variables_get"===e.type&&"itemList"===e.getField("VAR").getText()})),l=o.getAllBlocks().find((function(e){return"variables_set"===e.type&&"afterFirstComma"===e.getField("VAR").getText()})),s=o.getAllBlocks().find((function(e){return("text_print"===e.type||"js_text_print"===e.type)&&-1!==a.indexOf(e.getInputTargetBlock("TEXT"))})),u=o.getAllBlocks().find((function(e){return"variables_set"===e.type&&"itemList"===e.getField("VAR").getText()})),c=o.getAllBlocks().find((function(e){return"type_in_display_after_second"===e.type}));return i&&t&&t.getNextBlock()===i?"The "+T2C.MSG.currentLanguage.TERMINAL_DISPLAY+" block must go below the "+T2C.MSG.currentLanguage.TERMINAL_LET+" variable block setting afterSecondComma because the computer uses the value of this variable in the "+T2C.MSG.currentLanguage.TERMINAL_DISPLAY+" block. Since instructions are run from top to bottom, it won't know what afterSecondComma means, otherwise!":l&&i&&i.getNextBlock()===l?"The "+T2C.MSG.currentLanguage.TERMINAL_LET+" variable block setting afterSecondComma must go below the "+T2C.MSG.currentLanguage.TERMINAL_LET+" variable block setting afterFirstComma because the computer uses this one to determine what afterSecondComma is. Since instructions are run from top to bottom, it won't know what afterFirstComma means, otherwise!":l&&r&&r.getNextBlock()===l?"The "+T2C.MSG.currentLanguage.TERMINAL_DISPLAY+" block must go below the "+T2C.MSG.currentLanguage.TERMINAL_LET+" variable block setting afterFirstComma because the computer uses the value of this variable in the "+T2C.MSG.currentLanguage.TERMINAL_DISPLAY+" block. Since instructions are run from top to bottom, it won't know what afterFirstComma means, otherwise!":u&&l&&l.getNextBlock()===u?"The "+T2C.MSG.currentLanguage.TERMINAL_LET+" variable block setting afterFirstComma must go below the "+T2C.MSG.currentLanguage.TERMINAL_LET+" variable block setting itemList because the computer uses this one to determine what afterFirstComma is. Since instructions are run from top to bottom, it won't know what itemList means, otherwise!":u&&s&&s.getNextBlock()===u?"The "+T2C.MSG.currentLanguage.TERMINAL_DISPLAY+" block must go below the "+T2C.MSG.currentLanguage.TERMINAL_LET+" variable block setting itemList because the computer uses the value of this variable in the "+T2C.MSG.currentLanguage.TERMINAL_DISPLAY+" block. Since instructions are run from top to bottom, it won't know what itemList means, otherwise!":t?"Place the "+T2C.MSG.currentLanguage.TERMINAL_DISPLAY+" block displaying the value of afterSecondComma after the "+T2C.MSG.currentLanguage.TERMINAL_LET+" variable block setting it.":c?We.getErrorFeedback():""})),h(n),p(n,document.getElementById("output-container").querySelectorAll(".table-cell")[0]),n.addTask(new r((function(){return!0}),{start:function(){alert("✔ Utkrsht (excellent), so finally let's display the third item, which will be the first item of the last list, which is the original one with its first two items removed."),a.removeToolboxBlocks((function(e){return"type_in_display_after_second"===e.getAttribute("type")})),m(o),a.createToolboxBlock("type_in_display_third_item"),o.options.maxInstances.type_in_display_third_item=1,Re(document.getElementById("output-container").querySelectorAll(".table-cell")[0]),Fe()},isComplete:function(){return!0},animate:function(){return!0},finish:function(){}})),d(n,(function(){var e=o.getAllBlocks().filter((function(e){return"text"===e.type&&","===e.getFieldValue("TEXT")})),t=o.getAllBlocks().filter((function(e){return"variables_get"===e.type&&"afterSecondComma"===e.getField("VAR").getText()})),n=o.getAllBlocks().filter((function(n){return("js_text_indexof"===n.type||"t2c_text_indexof"===n.type)&&-1!==t.indexOf(n.getInputTargetBlock("VALUE"))&&-1!==e.indexOf(n.getInputTargetBlock("FIND"))})),i=o.getAllBlocks().filter((function(e){return"math_number"===e.type&&0===e.getFieldValue("NUM")})),r=o.getAllBlocks().filter((function(e){return("js_text_getsubstring"===e.type||"t2c_text_getsubstring"===e.type)&&-1!==t.indexOf(e.getInputTargetBlock("STRING"))&&-1!==i.indexOf(e.getInputTargetBlock("AT1"))&&-1!==n.indexOf(e.getInputTargetBlock("AT2"))})),a=o.getAllBlocks().filter((function(e){return("text_print"===e.type||"js_text_print"===e.type)&&null===e.getNextBlock()&&-1!==r.indexOf(e.getInputTargetBlock("TEXT"))})),l=o.getAllBlocks().filter((function(e){return("text_print"===e.type||"js_text_print"===e.type)&&-1!==a.indexOf(e.getNextBlock())&&-1!==t.indexOf(e.getInputTargetBlock("TEXT"))})),s=o.getAllBlocks().filter((function(e){return"variables_get"===e.type&&"afterFirstComma"===e.getField("VAR").getText()})),u=o.getAllBlocks().filter((function(e){return"t2c_text_length"===e.type&&-1!==s.indexOf(e.getInputTargetBlock("VALUE"))})),c=o.getAllBlocks().filter((function(e){return"math_number"===e.type&&1===e.getFieldValue("NUM")})),g=o.getAllBlocks().filter((function(t){return("js_text_indexof"===t.type||"t2c_text_indexof"===t.type)&&-1!==s.indexOf(t.getInputTargetBlock("VALUE"))&&-1!==e.indexOf(t.getInputTargetBlock("FIND"))})),d=o.getAllBlocks().filter((function(e){return"math_arithmetic_basic"===e.type&&-1!==g.indexOf(e.getInputTargetBlock("A"))&&-1!==c.indexOf(e.getInputTargetBlock("B"))&&"ADD"===e.getFieldValue("OP")})),h=o.getAllBlocks().filter((function(e){return("js_text_getsubstring"===e.type||"t2c_text_getsubstring"===e.type)&&-1!==s.indexOf(e.getInputTargetBlock("STRING"))&&-1!==d.indexOf(e.getInputTargetBlock("AT1"))&&-1!==u.indexOf(e.getInputTargetBlock("AT2"))})),p=o.getAllBlocks().filter((function(e){return"variables_set"===e.type&&-1!==l.indexOf(e.getNextBlock())&&-1!==h.indexOf(e.getInputTargetBlock("VALUE"))&&"afterSecondComma"===e.getField("VAR").getText()})),f=o.getAllBlocks().filter((function(e){return("text_print"===e.type||"js_text_print"===e.type)&&-1!==p.indexOf(e.getNextBlock())&&-1!==s.indexOf(e.getInputTargetBlock("TEXT"))})),m=o.getAllBlocks().filter((function(e){return"variables_get"===e.type&&"itemList"===e.getField("VAR").getText()})),y=o.getAllBlocks().filter((function(e){return"t2c_text_length"===e.type&&-1!==m.indexOf(e.getInputTargetBlock("VALUE"))})),T=o.getAllBlocks().filter((function(t){return("js_text_indexof"===t.type||"t2c_text_indexof"===t.type)&&-1!==m.indexOf(t.getInputTargetBlock("VALUE"))&&-1!==e.indexOf(t.getInputTargetBlock("FIND"))})),_=o.getAllBlocks().filter((function(e){return"math_arithmetic_basic"===e.type&&-1!==T.indexOf(e.getInputTargetBlock("A"))&&-1!==c.indexOf(e.getInputTargetBlock("B"))&&"ADD"===e.getFieldValue("OP")})),b=o.getAllBlocks().filter((function(e){return("js_text_getsubstring"===e.type||"t2c_text_getsubstring"===e.type)&&-1!==m.indexOf(e.getInputTargetBlock("STRING"))&&-1!==_.indexOf(e.getInputTargetBlock("AT1"))&&-1!==y.indexOf(e.getInputTargetBlock("AT2"))})),k=o.getAllBlocks().filter((function(e){return"variables_set"===e.type&&-1!==f.indexOf(e.getNextBlock())&&-1!==b.indexOf(e.getInputTargetBlock("VALUE"))&&"afterFirstComma"===e.getField("VAR").getText()})),x=o.getAllBlocks().filter((function(e){return("text_print"===e.type||"js_text_print"===e.type)&&-1!==k.indexOf(e.getNextBlock())&&-1!==m.indexOf(e.getInputTargetBlock("TEXT"))})),E=o.getAllBlocks().filter((function(e){return"text"===e.type&&"string"==typeof e.getFieldValue("TEXT")&&-1!==e.getFieldValue("TEXT").toLowerCase().indexOf("at least 4")})),B=o.getAllBlocks().filter((function(e){return("text_input"===e.type||"js_text_input"===e.type)&&-1!==E.indexOf(e.getInputTargetBlock("TEXT"))})),A=o.getAllBlocks().filter((function(e){return"variables_set"===e.type&&-1!==x.indexOf(e.getNextBlock())&&-1!==B.indexOf(e.getInputTargetBlock("VALUE"))&&"itemList"===e.getField("VAR").getText()}));return 3===e.length&&3===t.length&&1===n.length&&1===i.length&&1===r.length&&1===a.length&&1===l.length&&4===s.length&&1===u.length&&2===c.length&&1===g.length&&1===d.length&&1===h.length&&1===p.length&&1===f.length&&4===m.length&&1===y.length&&1===T.length&&1===_.length&&1===b.length&&1===k.length&&1===x.length&&1===E.length&&1===B.length&&1===A.length}),(function(){return"Drag in the type-in-code block, and type the necessary code to display the third item from itemList, which will be the text appearing before the first comma in afterSecondComma. Then place the block below the one displaying the original list with its first two items removed (afterSecondComma)."}),(function(){var e=o.getAllBlocks().filter((function(e){return"text"===e.type&&","===e.getFieldValue("TEXT")})),t=o.getAllBlocks().filter((function(e){return"variables_get"===e.type&&"afterSecondComma"===e.getField("VAR").getText()})),n=o.getAllBlocks().filter((function(n){return("js_text_indexof"===n.type||"t2c_text_indexof"===n.type)&&-1!==t.indexOf(n.getInputTargetBlock("VALUE"))&&-1!==e.indexOf(n.getInputTargetBlock("FIND"))})),i=o.getAllBlocks().filter((function(e){return"math_number"===e.type&&0===e.getFieldValue("NUM")})),r=o.getAllBlocks().filter((function(e){return("js_text_getsubstring"===e.type||"t2c_text_getsubstring"===e.type)&&-1!==t.indexOf(e.getInputTargetBlock("STRING"))&&-1!==i.indexOf(e.getInputTargetBlock("AT1"))&&-1!==n.indexOf(e.getInputTargetBlock("AT2"))})),a=o.getAllBlocks().find((function(e){return("text_print"===e.type||"js_text_print"===e.type)&&-1!==r.indexOf(e.getInputTargetBlock("TEXT"))})),l=o.getAllBlocks().find((function(e){return("text_print"===e.type||"js_text_print"===e.type)&&-1!==t.indexOf(e.getInputTargetBlock("TEXT"))})),s=o.getAllBlocks().filter((function(e){return"variables_get"===e.type&&"afterFirstComma"===e.getField("VAR").getText()})),u=o.getAllBlocks().find((function(e){return"variables_set"===e.type&&"afterSecondComma"===e.getField("VAR").getText()})),c=o.getAllBlocks().find((function(e){return("text_print"===e.type||"js_text_print"===e.type)&&-1!==s.indexOf(e.getInputTargetBlock("TEXT"))})),g=o.getAllBlocks().filter((function(e){return"variables_get"===e.type&&"itemList"===e.getField("VAR").getText()})),d=o.getAllBlocks().find((function(e){return"variables_set"===e.type&&"afterFirstComma"===e.getField("VAR").getText()})),h=o.getAllBlocks().find((function(e){return("text_print"===e.type||"js_text_print"===e.type)&&-1!==g.indexOf(e.getInputTargetBlock("TEXT"))})),p=o.getAllBlocks().find((function(e){return"variables_set"===e.type&&"itemList"===e.getField("VAR").getText()})),f=o.getAllBlocks().find((function(e){return"type_in_display_third_item"===e.type}));return u&&a&&a.getNextBlock()===u||u&&l&&l.getNextBlock()===u?"The "+T2C.MSG.currentLanguage.TERMINAL_DISPLAY+" block must go below the "+T2C.MSG.currentLanguage.TERMINAL_LET+" variable block setting afterSecondComma because the computer uses the value of this variable in the "+T2C.MSG.currentLanguage.TERMINAL_DISPLAY+" block. Since instructions are run from top to bottom, it won't know what afterSecondComma means, otherwise!":d&&a&&a.getNextBlock()===d?"The "+T2C.MSG.currentLanguage.TERMINAL_DISPLAY+" block must go below the "+T2C.MSG.currentLanguage.TERMINAL_LET+" variable block setting afterFirstComma because the computer uses the value of this variable in the "+T2C.MSG.currentLanguage.TERMINAL_DISPLAY+" block. Since instructions are run from top to bottom, it won't know what afterFirstComma means, otherwise!":d&&u&&u.getNextBlock()===d?"The "+T2C.MSG.currentLanguage.TERMINAL_LET+" variable block setting afterSecondComma must go below the "+T2C.MSG.currentLanguage.TERMINAL_LET+" variable block setting afterFirstComma because the computer uses this one to determine what afterSecondComma is. Since instructions are run from top to bottom, it won't know what afterFirstComma means, otherwise!":d&&c&&c.getNextBlock()===d?"The "+T2C.MSG.currentLanguage.TERMINAL_DISPLAY+" block must go below the "+T2C.MSG.currentLanguage.TERMINAL_LET+" variable block setting afterFirstComma because the computer uses the value of this variable in the "+T2C.MSG.currentLanguage.TERMINAL_DISPLAY+" block. Since instructions are run from top to bottom, it won't know what afterFirstComma means, otherwise!":p&&d&&d.getNextBlock()===p?"The "+T2C.MSG.currentLanguage.TERMINAL_LET+" variable block setting afterFirstComma must go below the "+T2C.MSG.currentLanguage.TERMINAL_LET+" variable block setting itemList because the computer uses this one to determine what afterFirstComma is. Since instructions are run from top to bottom, it won't know what itemList means, otherwise!":p&&h&&h.getNextBlock()===p?"The "+T2C.MSG.currentLanguage.TERMINAL_DISPLAY+" block must go below the "+T2C.MSG.currentLanguage.TERMINAL_LET+" variable block setting itemList because the computer uses the value of this variable in the "+T2C.MSG.currentLanguage.TERMINAL_DISPLAY+" block. Since instructions are run from top to bottom, it won't know what itemList means, otherwise!":a?"Place the "+T2C.MSG.currentLanguage.TERMINAL_DISPLAY+" block displaying the third item after the "+T2C.MSG.currentLanguage.TERMINAL_DISPLAY+" block displaying the value of afterSecondComma.":f?Ye.getErrorFeedback():""})),h(n),p(n,document.getElementById("output-container").querySelectorAll(".table-cell")[0]),n.addTask(new r((function(){return!0}),{start:function(){return!0},isComplete:function(){return!0},animate:function(){return!0},finish:function(){alert("✔✔✔ Amazing! You just solved that very challenging problem and completed Mission # 9. And with that, you became a pro at working with strings. In next missions, you'll be working more with numbers and the four operations of addition, subtraction, multiplication, and division. We'll start the next mission with a simple cool math magic trick you could amaze all your friends with! Until next time, phir milenge (See you again)!"),Fe(),a.clearToolbox(),["code_statement"].forEach((function(e,t){a.createToolboxBlock(e,!1),o.options.maxInstances[e]=maxBlocks[t]}))}})),n},function(e,t){var n=new p,o=n.createStandardHelpMessageManager(),a=e||new c,l=t||Blockly.getMainWorkspace(),s=new f(l);l.clear(),s.clearToolbox();var u=He.map((function(e){return Object(i.e)(l,e)}));u.slice(0,u.length-1).forEach((function(e,t){return Object(i.i)(e,u[t+1])})),l.setScale(1),l.getAllBlocks().forEach((function(e){return e.setMovable(!1)})),u[0].setFieldValue(et,"EXP"),u[1].setFieldValue(Qe.TERMINAL_LET+"step1 = 2 * startNum","EXP"),u[2].setFieldValue(Qe.TERMINAL_DISPLAY+"(step1)","EXP"),Object(i.f)(l),a.addTask(new r((function(){return!0}),{start:function(){return!0},isComplete:function(){return!0},animate:function(){return!0},finish:function(){var e=void 0;if(alert("Before you start this mission, the computer will be scanning your brain and revealing the meaning of life to you! But answers don't come so easy. First, you'll need to choose a number and remember it. You'll also need to perform the following operations and remember the number after each step. Remember your starting number though!\n1. Multiply your starting number by 2.\n2. Add 100 to the result of step 1.\n 3. Subtract 16 from the result of step 2.\n 4. Divide your number from step 3 by 2. \n 5. Finally, subtract the number you started with from the number from step 4 and you'll get the meaning of life according to The Hitchiker's Guide to the Galaxy."),!confirm("Was your number 42?")){for(var t="There must be a mistake, let's walk you through the steps to show you that you should've gotten 42. Enter the number you chose (or click cancel if you just want to use 0): ",n=prompt(t);null!==n&isNaN(parseFloat(n));)n=prompt("What you entered doesn't seem to be a number. "+t);e=parseFloat(n)||0,alert("So you started with "+e+":\nStep 1 result (multiplying by 2): "+2*e+"\nStep 2 result (adding 100 to result of step 1): "+(2*e+100)+"\nStep 3 result (subtracting 16 from step2 result): "+(2*e+84)+"\nStep 4 result (dividing step3 result by 2): "+(e+42)+"\nStep 5 result (subtracting number you started with): 42")}alert("Do you know how the trick worked? Hint: The computer didn't actually read your mind. It's just an algebra trick. Remember in algebra, when we have an unknown, we use a variable. Here, the unknown is the starting number. If x represents it, then after doubling it in step1, we'll have 2x. The point is we'll have to eventually get rid of x since we always want to wind up with the same number of 42 and you can verify that we perform the operations to do just that. If you really want to amaze your friends, you can ask them to tell you a number first and then tell them to pick a different number (and not tell you), and then perform operations to wind up with that number they asked for. For kuch mazaa (some fun), let's try that now:");for(var o,i=prompt("Enter your favorite number (or cancel for 0):");null!==i&isNaN(parseFloat(i));)i=prompt("What you entered doesn't seem to be a number. Enter your favorite number (or cancel for 0):");o=parseFloat(i)||0,alert("So now choose any new number and remember this one. \n1. Add "+(2*o+5)+" to your starting number.\n2. Multiply the result of step 1 by 3.\n 3. Subtract "+(3*o+15)+" from the result of step 2.\n 4. Divide your number from step 3 by 3. \n 5. Finally, subtract the number you started with from the number from step 4 and you should get the number you told the computer was your favorite!"),alert("Now back to the mission at hand: you'll have the computer challenge the user to select a number and then show him/her the result after each step, which will predictably end in 42*. (*Note: Due to the way the computer stores numbers, if you start with a number with a decimal point, the answer it produces may not be exactly 42.) Just as in algebra, when we program and want to store something for later use, we can use a variable, and here we'd do the same for the starting number. You will also store each step's result in a variable. One final note is the use of "+T2C.MSG.currentLanguage.TERMINAL_PARSEFLOAT+', which converts what the user enters from text to a number. This is important because otherwise, JavaScript will for example treat 1 + "1" as the text "11" (join the two together as strings) instead of adding them together as numbers to get 2 while Python will simply give you an error, refusing to add a number and string. See QuickMaths JavaScript meme.')}})),n.addHelpMessageTask(a,o,(function(){return He.every((function(e,t){var n=l.getAllBlocks().find((function(t){return t.type===e}));return ze[t].hasFullMatch(n.getFieldValue("EXP"),!1)}))}),"Type in the code to get the computer to calculate each step's result by performing the specified operation (+ for addition, - for subtraction, * for multiplcation, or / for division) on the previous step's value. Name your variables step1, step2, step3, step4, and step5. Be sure to display the result after each step. The steps are as follows:\n 1. Multiply your starting number by 2.\n2. Add 100 to the result of step 1.\n 3. Subtract 16 from the result of step 2.\n 4. Divide your number from step 3 by 2. \n 5. Finally, subtract the number you started with from the number from step 4.",(function(){for(var e=0;e1?y.addRunTask(T,_,(function(){5===e?alert("Great, so now for the trickier calculations. To determine the seconds that'll display on a clock, you'll need to get the remaining number of seconds after you've accounted for the minutes. So for example, 90 seconds after midnight would be 00:01:30 (1 minute, 30 seconds), 130 seconds after would be 00:02:10 (2 minutes, 10 seconds), and 200 seconds after would be 00:03:20 (3 minutes, 20 seconds). You got the 1, 2, and 3 from 90, 130, and 210 so how do you go from:\n90 and 1 => 30,\n 130 and 2 => 10, \n 200 and 3 => 20 \nFind the common operations you use in each and then substitute these numbers with the variables totalSeconds and totalMinutes to get your answer, which you should store in remainingSeconds."):alert("Directions to be added later"),function(e){(s=s.map((function(e){return b.getAllBlocks().find((function(t){return e.type===t.type}))}))).push(Object(i.e)(b,n[e])),e>0&&Object(i.i)(s[e-1],s[e]),b.getAllBlocks().forEach((function(e){return e.setMovable(!1)})),Object(i.f)(b)}(e)}),x):_.addTask(new r((function(){return!0}),{start:function(){return!0},isComplete:function(){return!0},animate:function(){return!0},finish:function(){if(0===e)alert("In JavaScript, Dates are represented by the number of milliseconds since January 1, 1970 at midnight UTC (Coordinated Universal Time), where 0 represents this time. For example, 64,000 would correspond to Thu Jan 01 1970 00:01:04 GMT+0000 (Greenwich Mean Time), i.e., 64 seconds or 0 hours, 1 minute, and 4 seconds after midnight since there are 1000 milliseconds in a second. In this mission, the user will input a number of milliseconds and you will output the time (ignoring leap seconds). So let's start by asking the user for a number of milliseconds and storing the *numerical* value in a variable milliseconds, which we'll allow to be a non-whole number such as 64000.5. Remember what you have to do to convert a string to a number?");else if(1===e){var t="To do this, you'll need to know about "+T2C.MSG.currentLanguage.TERMINAL_TRUNC+", which can be used to convert a number to an integer (...,-3,-2,-1,0,1,2,3,...) by truncating or removing all digits to the right of the decimal point (e.g., "+T2C.MSG.currentLanguage.TERMINAL_TRUNC+"(2.41) is 2). When we are dividing 0 or some positive integer by a positive integer, we can use "+T2C.MSG.currentLanguage.TERMINAL_TRUNC+" to perform integer division. So "+T2C.MSG.currentLanguage.TERMINAL_TRUNC+"(14/5) = "+T2C.MSG.currentLanguage.TERMINAL_TRUNC+"(2.8) = 2, which is the quotient when you divide 14 by 5.";alert("Sahee (Right), so remembering that there are 1000 ms (milliseconds) in a second, let's get the total number of *whole* seconds contained in the entered number of ms. So the answer for 64000, 64500, and 64543.21 should all be 64. "+t+" So using this information, can you do this? Store the answer in totalSeconds.")}else alert("Message to be added later");(s=s.map((function(e){return b.getAllBlocks().find((function(t){return e.type===t.type}))}))).push(Object(i.e)(b,n[e])),e>0&&Object(i.i)(s[e-1],s[e]),b.getAllBlocks().forEach((function(e){return e.setMovable(!1)})),Object(i.f)(b)}})),y.addHelpMessageTask(_,T,(function(){return n.slice(0,e+1).every((function(e,t){var n=b.getAllBlocks().find((function(t){return t.type===e}));return o[t].hasFullMatch(n.getFieldValue("EXP"),!1)}))}),(function(){return 0===e?"Ask the user for a number of milliseconds, convert the input to a number, and store it in a variable named "+a[0]+".":1===e?"Apply the appropriate math operation on "+a[0]+" and the appropriate integer to convert to the total number of whole seconds. Recall that for an input of 64000 milliseconds, there are 64 seconds. Be sure to apply "+T2C.MSG.currentLanguage.TERMINAL_TRUNC+" to the result of this operation so that 64500 and 64543.21 also result in 64. Store the final answer in "+a[1]+".":e%2==0?"Display "+a[e/2]+".":3===e?"Apply the appropriate math operation on "+a[1]+" and the appropriate integer to convert to the total number of whole minutes. For some examples, 90, 130, and 200 seconds, the answers should be 1, 2, and 3 minutes, respectively. As in the previous conversion, be sure to apply "+T2C.MSG.currentLanguage.TERMINAL_TRUNC+" to the result of this operation so that you get whole numbers in each case. Store the final answer in "+a[2]+".":5===e?"Apply the appropriate math operations on "+a[1]+" and "+a[2]+" and the appropriate integer to convert to the remaining number of seconds. For some examples:\n90 seconds = 1 whole minute & *30 remaining seconds* \n 130 seconds = 2 whole minutes & *10 remaining seconds*\n200 seconds = 3 whole minutes & *20 remaining seconds*\nConsider what you could do with the total number of seconds and number of whole minutes to get the remaining number of seconds. Store the final answer in "+a[3]+". Do *NOT* include parentheses as you will not need them since the computer performs multiplication/division before addition/subtraction because they have higher precedence as they do in math (Parentheses first, exponentation next, multiplication/division next, addition/subtraction last).":7===e||11===e?"Apply the appropriate math operation on "+a[(e-3)/2]+" and the appropriate integer to convert to the total number of whole "+(7===e?"hours":"days")+" in the given number of "+(7===e?"minutes":"hours")+". Remember to apply "+T2C.MSG.currentLanguage.TERMINAL_TRUNC+" to the result of this operation so you get a whole number. Store the final answer in "+a[(e+1)/2]+".":9===e||13===e?"Apply the appropriate math operations on "+a[Math.trunc((e-1)/3)]+", "+a[(e-1)/2]+", and the appropriate integer to convert to the remaining number of "+(9===e?"minutes":"hours")+" after accounting for the "+(9===e?"hours":"days")+". As you did when getting the number of remaining seconds after extracting the seconds from the minutes, be sure to consider some examples to determine the appropriate calculations. Store the final answer in "+a[(e+1)/2]+". Do *NOT* include parentheses as you will not need them since the computer performs multiplication/division before addition/subtraction because they have higher precedence as they do in math (Parentheses first, exponentation next, multiplication/division next, addition/subtraction last).":"Display the time in the form hour (0 - 23): minute (0 - 59): second (0 - 59). Don't worry about including a leading 0, e.g., 2 : 4 : 5 is fine if the time is 2:04:05 AM. Use commas in your "+T2C.MSG.currentLanguage.TERMINAL_DISPLAY+" between the variables representing the numbers and the string literals ':' separating them."}),(function(){for(var t=0;t2||e%5==4?T.addRunTask(_,b,(function(){4===e?alert("Sahee (Right) so now since we'll want the "+l[4]+", which will be a whole number, and we'll later want "+l[7]+", let's get the "+l[3]+" next from the "+l[2]+". You remember how we can do this, right?"):alert("Directions to be added later"),function(e){(u=u.map((function(e){return k.getAllBlocks().find((function(t){return e.type===t.type}))}))).push(Object(i.e)(k,n[e])),e>0&&Object(i.i)(u[e-1],u[e]),k.getAllBlocks().forEach((function(e){return e.setMovable(!1)})),Object(i.f)(k)}(e)}),E):b.addTask(new r((function(){return!0}),{start:function(){return!0},isComplete:function(){return!0},animate:function(){return!0},finish:function(){0===e?alert("In Excel/Google Sheets, Dates are represented as the number of days since December 31, 1899 at midnight (represented by 0; 1 represents a day later or January 1, 1900 at midnight). Fractions of days affect the hours/minutes/seconds so e.g., 3.25 represents January 3, 1900 at 06:00:00 am (3 and 1 quarter day after December 31 at midnight). You can see this by typing a number in a cell in a spreadsheet and switching the format to e.g., Time, Long Date, Date time, etc. In this mission, the user will input a number of days after midnight in decimal such as 3.25 and you will again output the time (ignoring leap seconds). So let's start by asking the user for a number of days in decimal and storing the *numerical* result in a variable named "+a[0]+". As in the previous missions, you'll need to convert the user input to a number."):1===e?alert("Sahee (Right), so this time we're going to work in the opposite direction from the previous mission to get the time, proceeding from the largest unit of the total "+l[0]+" to the smallest unit of "+l[l.length-1].substring(l[l.length-1].indexOf(" ")+1)+". Recall that in the previous exercise, before the last step to get the "+l[4]+", we first got the "+l[1]+" so we could subtract out the "+l[3]+" contributed by them. So let's start by getting "+l[1]+" from the inputted "+l[0]+"."):2===e?alert("Acchaa (Good) so now we'll get the "+l[2]+" from the "+l[0]+". Do *NOT* use "+T2C.MSG.currentLanguage.TERMINAL_TRUNC+" this time as we'll need to preserve what comes after the decimal point to get "+l[7]+" and "+l[10]+"."):3===e?alert("Phir se acchaa (Good again). So let's now display the "+l[2]+" to verify it's what you expect for an example you have in mind."):5===e?alert("Mahaan (Great), so now that we have "+l[3]+" and "+l[1]+", you remember how to calculate the "+l[4]+" from the last mission, right? As before, use some examples, show the math operations, and then substitute the numbers with the appropriate variables to get the hour number that'll display on a clock."):alert("Message to be added later"),(u=u.map((function(e){return k.getAllBlocks().find((function(t){return e.type===t.type}))}))).push(Object(i.e)(k,n[e])),e>0&&Object(i.i)(u[e-1],u[e]),k.getAllBlocks().forEach((function(e){return e.setMovable(!1)})),Object(i.f)(k)}})),T.addHelpMessageTask(b,_,(function(){return n.slice(0,e+1).every((function(e,t){var n=k.getAllBlocks().find((function(t){return t.type===e}));return o[t].hasFullMatch(n.getFieldValue("EXP"),!1)}))}),(function(){if(0===e)return"Ask the user for a number of "+l[0]+", convert the input to a number, and store it in a variable named "+a[0]+".";if(1===e)return"Store the total "+l[1]+" in the variable "+a[1]+" by using "+T2C.MSG.currentLanguage.TERMINAL_TRUNC+" on "+a[0]+".";if(e%5==1||e%5==3)return"Display "+a[e-Math.round(e/3)-Math.trunc(e/12)]+".";if(2===e)return"Apply the appropriate math operation on "+a[0]+" and the appropriate integer to convert to the "+l[2]+". Do NOT apply "+T2C.MSG.currentLanguage.TERMINAL_TRUNC+". Store the final answer in "+a[2]+".";if(4===e)return"Next, store the "+l[3]+" in the variable "+a[3]+".";if(5===e)return"Apply the appropriate math operations on "+a[3]+" and "+a[1]+" and the appropriate integer to convert to the "+l[4]+". Store this result in "+a[4]+".";if(e%5==2&&e3&&void 0!==arguments[3]?arguments[3]:1/0;return o(e.map((function(e){return n.map((function(n){return function e(t,n,o){var i=arguments.length>3&&void 0!==arguments[3]?arguments[3]:1/0;return t===n?o:0!==i&&Array.isArray(t)?t.map((function(t){return e(t,n,o,i-1)})):t}(e,t,n,i)}))})))}(e,n,function e(t){return 1===t.length?[t]:t.map((function(n,o){return e(t.slice(0,o).concat(t.slice(o+1))).map((function(e){return[t[o]].concat(e)}))})).reduce((function(e,t){return e.concat(t)}),[])}(n),t)}),[e])})))}function s(e,t){return e.reduce((function(e,n){return e.concat([t]).concat(n)}),[]).slice(1)}var u=["cs1030_14_type_in_get_is_weekday","cs1030_14_type_in_get_is_vacation","cs1030_14_type_in_set_can_sleep_in","cs1030_14_type_in_display_can_sleep_in"],g=["isWeekday","isVacation","canSleepIn"],h=u.map((function(e){return new d(e,{collapseWhenFinished:!0})})),m=function(e,t){var o=t.reduce((function(e,t,o){return l(a(e,n,o+1,[function(e){return e.token===t}]),o)}),e);return t.slice().reduce((function(e,n,o){return a(e,s,t.length-o,[{token:t[t.length-1-o],type:"terminal"}])}),o)}([[g[0],{token:"and",type:"terminal"},g[1],{token:"or",type:"terminal"},{token:"not",type:"terminal"},g[0],{token:"and",type:"terminal"},g[1],{token:"or",type:"terminal"},{token:"not",type:"terminal"},g[0],{token:"and",type:"terminal"},{token:"not",type:"terminal"},g[1]]],["or","and"]),y=[[{token:"not",type:"terminal"},"(",{token:"not",type:"terminal"},g[1],{token:"and",type:"terminal"},g[0],")"],[{token:"not",type:"terminal"},"(",g[0],{token:"and",type:"terminal"},{token:"not",type:"terminal"},g[1],")"],[{token:"not",type:"terminal"},g[0],{token:"or",type:"terminal"},g[1]],[g[1],{token:"or",type:"terminal"},{token:"not",type:"terminal"},g[0]]],T=['"Is it a weekday? (true:OK or false:Cancel)"','"Is it a vacation? (true:OK or false:Cancel)"'],_=[null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null],b=m.concat(y).map((function(e){return[{token:"let",type:"terminal"},g[2],"="].concat(e).concat([{token:/^[;]*$/,type:"regexp"}])}));b.forEach((function(e){return h[2].addPossibleMatch(e,_.slice(0,e.length))})),console.log("SLEEP IN MATCHES",b);var k=[[{token:"let",type:"terminal"},g[0],"=",{token:"confirm",type:"terminal"},"(",{token:/^"[^"]*$|^'[^']*$|^"[^"]*"|^'[^']*'/,type:"regexp"},")",{token:/^[;]*$/,type:"regexp"}],[{token:"let",type:"terminal"},g[1],"=",{token:"confirm",type:"terminal"},"(",{token:/^"[^"]*$|^'[^']*$|^"[^"]*"|^'[^']*'/,type:"regexp"},")",{token:/^[;]*$/,type:"regexp"}],null,[{token:"display",type:"terminal"},"(",g[2],")",{token:/^[;]*$/,type:"regexp"}]];k.forEach((function(e,t){return 2!==t&&h[t].addPossibleMatch(e,_.slice(0,e.length))})),h.forEach((function(e){return e.addToBlocks()}));var x=new p,E=x.createStandardHelpMessageManager(),B=e||new c,A=t||Blockly.getMainWorkspace(),v=new f(A);A.clear(),v.clearToolbox();var I=x.createPointer();document.body.appendChild(I);var w=u.map((function(e){return Object(i.e)(A,e)}));w.slice(0,w.length-1).forEach((function(e,t){return Object(i.i)(e,w[t+1])}));var S=T2C.MSG.currentLanguage===T2C.MSG.PY?T2C.MSG.PY:T2C.MSG.JS;return w.forEach((function(e,t){return 2!==t&&e.setFieldValue(k[t].slice(0,k[t].length-1).map((function(e){return"terminal"===e.type?S["TERMINAL_"+e.token.toUpperCase()]:"regexp"===e.type?T[t]:e})).join(""),"EXP")})),A.setScale(1),A.getAllBlocks().forEach((function(e){return e.setMovable(!1)})),Object(i.f)(A),B.addTask(new r((function(){return!0}),{start:function(){return!0},isComplete:function(){return!0},animate:function(){return!0},finish:function(){alert("In progress: ADAPTED FROM SLEEP IN (http://codingbat.com/prob/p173401): The parameter "+g[0]+" is true if it is a weekday, and the parameter "+g[1]+" is true if we are on vacation. We can sleep in if it is not a weekday or we're on vacation. Write a line of code to set "+g[2]+" so that the computer displays true exactly when we can sleep in.")}})),x.addHelpMessageTask(B,E,(function(){return u.every((function(e,t){var n=A.getAllBlocks().find((function(t){return t.type===e}));return h[t].hasFullMatch(n.getFieldValue("EXP"),!1)}))}),(function(){return"Using the truth table, set "+g[2]+" to the appropriate Boolean expression in terms of "+g[0]+" and "+g[1]+"."}),(function(){for(var e=0;e3&&void 0!==arguments[3]?arguments[3]:1/0;return o(e.map((function(e){return n.map((function(n){return function e(t,n,o){var i=arguments.length>3&&void 0!==arguments[3]?arguments[3]:1/0;return t===n?o:0!==i&&Array.isArray(t)?t.map((function(t){return e(t,n,o,i-1)})):t}(e,t,n,i)}))})))}(e,n,function e(t){return 1===t.length?[t]:t.map((function(n,o){return e(t.slice(0,o).concat(t.slice(o+1))).map((function(e){return[t[o]].concat(e)}))})).reduce((function(e,t){return e.concat(t)}),[])}(n),t)}),[e])})))}function s(e,t){return e.reduce((function(e,n){return e.concat([t]).concat(n)}),[]).slice(1)}var u=["cs1030_15_type_in_get_is_a_smile","cs1030_15_type_in_get_is_b_smile","cs1030_15_type_in_set_in_trouble","cs1030_15_type_in_display_in_trouble"],g=["isASmile","isBSmile","inTrouble"],h=u.map((function(e){return new d(e,{collapseWhenFinished:!0})})),m=function(e,t){var o=t.reduce((function(e,t,o){return l(a(e,n,o+1,[function(e){return e.token===t}]),o)}),e);return t.slice().reduce((function(e,n,o){return a(e,s,t.length-o,[{token:t[t.length-1-o],type:"terminal"}])}),o)}([[g[0],{token:"and",type:"terminal"},g[1],{token:"or",type:"terminal"},{token:"not",type:"terminal"},g[0],{token:"and",type:"terminal"},{token:"not",type:"terminal"},g[1]]],["or","and"]),y=['"Is monkey A smiling? (true:OK or false:CANCEL)"','"Is monkey B smiling? (true:OK or false:CANCEL)"'],T=[null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null],_=m.map((function(e){return[{token:"let",type:"terminal"},g[2],"="].concat(e).concat([{token:/^[;]*$/,type:"regexp"}])}));_.forEach((function(e){return h[2].addPossibleMatch(e,T.slice(0,e.length))})),console.log(m.length),_.forEach((function(e){return console.log(e)}));var b=[[{token:"let",type:"terminal"},g[0],"=",{token:"confirm",type:"terminal"},"(",{token:/^"[^"]*$|^'[^']*$|^"[^"]*"|^'[^']*'/,type:"regexp"},")",{token:/^[;]*$/,type:"regexp"}],[{token:"let",type:"terminal"},g[1],"=",{token:"confirm",type:"terminal"},"(",{token:/^"[^"]*$|^'[^']*$|^"[^"]*"|^'[^']*'/,type:"regexp"},")",{token:/^[;]*$/,type:"regexp"}],null,[{token:"display",type:"terminal"},"(",g[2],")",{token:/^[;]*$/,type:"regexp"}]];b.forEach((function(e,t){return 2!==t&&h[t].addPossibleMatch(e,T.slice(0,e.length))})),h.forEach((function(e){return e.addToBlocks()}));var k=new p,x=k.createStandardHelpMessageManager(),E=e||new c,B=t||Blockly.getMainWorkspace(),A=new f(B);B.clear(),A.clearToolbox();var v=k.createPointer();document.body.appendChild(v);var I=u.map((function(e){return Object(i.e)(B,e)}));I.slice(0,I.length-1).forEach((function(e,t){return Object(i.i)(e,I[t+1])}));var w=T2C.MSG.currentLanguage===T2C.MSG.PY?T2C.MSG.PY:T2C.MSG.JS;return I.forEach((function(e,t){return 2!==t&&e.setFieldValue(b[t].slice(0,b[t].length-1).map((function(e){return"terminal"===e.type?w["TERMINAL_"+e.token.toUpperCase()]:"regexp"===e.type?y[t]:e})).join(""),"EXP")})),B.setScale(1),B.getAllBlocks().forEach((function(e){return e.setMovable(!1)})),Object(i.f)(B),E.addTask(new r((function(){return!0}),{start:function(){return!0},isComplete:function(){return!0},animate:function(){return!0},finish:function(){alert("In progress: ADAPTED FROM Monkey Trouble (http://codingbat.com/prob/p120546): We have two monkeys, a and b, and the parameters "+g[0]+" and "+g[1]+" indicate if each is smiling. We are in trouble if they are both smiling or if neither of them is smiling (and not in trouble otherwise). Write a line of code to set "+g[2]+" so that the computer displays true exactly when we are in trouble.")}})),k.addHelpMessageTask(E,x,(function(){return u.every((function(e,t){var n=B.getAllBlocks().find((function(t){return t.type===e}));return h[t].hasFullMatch(n.getFieldValue("EXP"),!1)}))}),(function(){return"Using the truth table, set "+g[2]+" to the appropriate Boolean expression in terms of "+g[0]+" and "+g[1]+"."}),(function(){for(var e=0;e3&&void 0!==arguments[3]?arguments[3]:1/0;return o(e.map((function(e){return n.map((function(n){return function e(t,n,o){var i=arguments.length>3&&void 0!==arguments[3]?arguments[3]:1/0;return t===n?o:0!==i&&Array.isArray(t)?t.map((function(t){return e(t,n,o,i-1)})):t}(e,t,n,i)}))})))}(e,n,function e(t){return 1===t.length?[t]:t.map((function(n,o){return e(t.slice(0,o).concat(t.slice(o+1))).map((function(e){return[t[o]].concat(e)}))})).reduce((function(e,t){return e.concat(t)}),[])}(n),t)}),[e])})))}function s(e,t){var o=t.reduce((function(e,t,o){return l(a(e,n,o+1,[function(e){return e.token===t}]),o)}),e);return t.slice().reduce((function(e,n,o){return a(e,u,t.length-o,[{token:t[t.length-1-o],type:"terminal"}])}),o)}function u(e,t){return e.reduce((function(e,n){return e.concat([t]).concat(n)}),[]).slice(1)}var g=["cs1030_16_type_in_is_mets_fan","cs1030_16_type_in_is_yankees_fan","cs1030_16_type_in_set_can_be_newyorker","cs1030_16_type_in_display_in_can_be_newyorker"],h=["isMetsFan","isYankeesFan","canBeNewYorker"],m=g.map((function(e){return new d(e,{collapseWhenFinished:!0})})),y=s([[h[0],{token:"and",type:"terminal"},{token:"not",type:"terminal"},h[1],{token:"or",type:"terminal"},{token:"not",type:"terminal"},h[0],{token:"and",type:"terminal"},h[1]]],["or","and"]),T=s([[h[0],{token:"or",type:"terminal"},h[1],{token:"and",type:"terminal"},{token:"not",type:"terminal"},h[0],{token:"or",type:"terminal"},{token:"not",type:"terminal"},h[1]]],["and","or"]).map((function(e){return["("].concat(e.slice(0,e.findIndex((function(e){return"and"===e.token})))).concat([")",{token:"and",type:"terminal"},"("]).concat(e.slice(e.findIndex((function(e){return"and"===e.token}))+1)).concat([")"])})),_=T.map((function(e){var t=e.findIndex((function(e){return"not"===e.token}));return e.slice(0,t-1).concat([{token:"not",type:"terminal"},"("]).concat(e[t+1]).concat([{token:"and",type:"terminal"}]).concat(e.slice(t+4))})),b=['"Are you a Mets fan? (true:OK or false:CANCEL)"','"Are you a Yankees fan? (true:OK or false:CANCEL)"'],k=[null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null],x=y.concat(T).concat(_).map((function(e){return[{token:"let",type:"terminal"},h[2],"="].concat(e).concat([{token:/^[;]*$/,type:"regexp"}])}));x.forEach((function(e){return m[2].addPossibleMatch(e,k.slice(0,e.length))})),console.log(y.length,T.length,_.length),x.forEach((function(e){return console.log(e)}));var E=[[{token:"let",type:"terminal"},h[0],"=",{token:"confirm",type:"terminal"},"(",{token:/^"[^"]*$|^'[^']*$|^"[^"]*"|^'[^']*'/,type:"regexp"},")",{token:/^[;]*$/,type:"regexp"}],[{token:"let",type:"terminal"},h[1],"=",{token:"confirm",type:"terminal"},"(",{token:/^"[^"]*$|^'[^']*$|^"[^"]*"|^'[^']*'/,type:"regexp"},")",{token:/^[;]*$/,type:"regexp"}],null,[{token:"display",type:"terminal"},"(",h[2],")",{token:/^[;]*$/,type:"regexp"}]];E.forEach((function(e,t){return 2!==t&&m[t].addPossibleMatch(e,k.slice(0,e.length))})),m.forEach((function(e){return e.addToBlocks()}));var B=new p,A=B.createStandardHelpMessageManager(),v=e||new c,I=t||Blockly.getMainWorkspace(),w=new f(I);I.clear(),w.clearToolbox();var S=B.createPointer();document.body.appendChild(S);var M=g.map((function(e){return Object(i.e)(I,e)}));M.slice(0,M.length-1).forEach((function(e,t){return Object(i.i)(e,M[t+1])}));var N=T2C.MSG.currentLanguage===T2C.MSG.PY?T2C.MSG.PY:T2C.MSG.JS;return M.forEach((function(e,t){return 2!==t&&e.setFieldValue(E[t].slice(0,E[t].length-1).map((function(e){return"terminal"===e.type?N["TERMINAL_"+e.token.toUpperCase()]:"regexp"===e.type?b[t]:e})).join(""),"EXP")})),I.setScale(1),I.getAllBlocks().forEach((function(e){return e.setMovable(!1)})),Object(i.f)(I),v.addTask(new r((function(){return!0}),{start:function(){return!0},isComplete:function(){return!0},animate:function(){return!0},finish:function(){alert("In progress: NEW YORK BASEBALL FAN - NEW YORKER IS A METS FAN OR A YANKEES FAN (HYPOTHETICAL): A New Yorker must either be a Mets fan or a Yankees fan but cannot be both. Write a line of code to set "+h[2]+" so that the computer displays true exactly when the person can be a New Yorker.")}})),B.addHelpMessageTask(v,A,(function(){return g.every((function(e,t){var n=I.getAllBlocks().find((function(t){return t.type===e}));return m[t].hasFullMatch(n.getFieldValue("EXP"),!1)}))}),(function(){return"Using the truth table, set "+h[2]+" to the appropriate Boolean expression in terms of "+h[0]+" and "+h[1]+"."}),(function(){for(var e=0;e3&&void 0!==arguments[3]?arguments[3]:1/0;return o(e.map((function(e){return n.map((function(n){return function e(t,n,o){var i=arguments.length>3&&void 0!==arguments[3]?arguments[3]:1/0;return t===n?o:0!==i&&Array.isArray(t)?t.map((function(t){return e(t,n,o,i-1)})):t}(e,t,n,i)}))})))}(e,n,function e(t){return 1===t.length?[t]:t.map((function(n,o){return e(t.slice(0,o).concat(t.slice(o+1))).map((function(e){return[t[o]].concat(e)}))})).reduce((function(e,t){return e.concat(t)}),[])}(n),t)}),[e])})))}function s(e,t){return e.reduce((function(e,n){return e.concat([t]).concat(n)}),[]).slice(1)}var u=["cs1030_17_type_in_is_mets_fan","cs1030_17_type_in_is_yankees_fan","cs1030_17_type_in_set_can_be_true_fan","cs1030_17_type_in_display_in_can_be_true_fan"],g=["isMetsFan","isYankeesFan","canBeTrueFan"],h=u.map((function(e){return new d(e,{collapseWhenFinished:!0})})),m=function(e,t){var o=t.reduce((function(e,t,o){return l(a(e,n,o+1,[function(e){return e.token===t}]),o)}),e);return t.slice().reduce((function(e,n,o){return a(e,s,t.length-o,[{token:t[t.length-1-o],type:"terminal"}])}),o)}([[g[0],{token:"and",type:"terminal"},{token:"not",type:"terminal"},g[1],{token:"or",type:"terminal"},{token:"not",type:"terminal"},g[0],{token:"and",type:"terminal"},g[1],{token:"or",type:"terminal"},{token:"not",type:"terminal"},g[0],{token:"and",type:"terminal"},{token:"not",type:"terminal"},g[1]]],["or","and"]),y=[[{token:"not",type:"terminal"},"(",g[0],{token:"and",type:"terminal"},g[1],")"],[{token:"not",type:"terminal"},"(",g[1],{token:"and",type:"terminal"},g[0],")"],[{token:"not",type:"terminal"},g[0],{token:"or",type:"terminal"},{token:"not",type:"terminal"},g[1]],[{token:"not",type:"terminal"},g[1],{token:"or",type:"terminal"},{token:"not",type:"terminal"},g[0]]],T=['"Are you a Mets fan? (true:OK or false:CANCEL)"','"Are you a Yankees fan? (true:OK or false:CANCEL)"'],_=[null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null],b=m.concat(y).map((function(e){return[{token:"let",type:"terminal"},g[2],"="].concat(e).concat([{token:/^[;]*$/,type:"regexp"}])}));b.forEach((function(e){return h[2].addPossibleMatch(e,_.slice(0,e.length))})),console.log(m.length,y.length),b.forEach((function(e){return console.log(e)}));var k=[[{token:"let",type:"terminal"},g[0],"=",{token:"confirm",type:"terminal"},"(",{token:/^"[^"]*$|^'[^']*$|^"[^"]*"|^'[^']*'/,type:"regexp"},")",{token:/^[;]*$/,type:"regexp"}],[{token:"let",type:"terminal"},g[1],"=",{token:"confirm",type:"terminal"},"(",{token:/^"[^"]*$|^'[^']*$|^"[^"]*"|^'[^']*'/,type:"regexp"},")",{token:/^[;]*$/,type:"regexp"}],null,[{token:"display",type:"terminal"},"(",g[2],")",{token:/^[;]*$/,type:"regexp"}]];k.forEach((function(e,t){return 2!==t&&h[t].addPossibleMatch(e,_.slice(0,e.length))})),h.forEach((function(e){return e.addToBlocks()}));var x=new p,E=x.createStandardHelpMessageManager(),B=e||new c,A=t||Blockly.getMainWorkspace(),v=new f(A);A.clear(),v.clearToolbox();var I=x.createPointer();document.body.appendChild(I);var w=u.map((function(e){return Object(i.e)(A,e)}));w.slice(0,w.length-1).forEach((function(e,t){return Object(i.i)(e,w[t+1])}));var S=T2C.MSG.currentLanguage===T2C.MSG.PY?T2C.MSG.PY:T2C.MSG.JS;return w.forEach((function(e,t){return 2!==t&&e.setFieldValue(k[t].slice(0,k[t].length-1).map((function(e){return"terminal"===e.type?S["TERMINAL_"+e.token.toUpperCase()]:"regexp"===e.type?T[t]:e})).join(""),"EXP")})),A.setScale(1),A.getAllBlocks().forEach((function(e){return e.setMovable(!1)})),Object(i.f)(A),B.addTask(new r((function(){return!0}),{start:function(){return!0},isComplete:function(){return!0},animate:function(){return!0},finish:function(){alert("In progress: A TRUE BASEBALL FAN - A TRUE BASEBALL FAN MAY BE A METS FAN OR A YANKEES FAN BUT NEVER BOTH (HYPOTHETICAL): A true baseball fan may be a Mets fan or a Yankees fan or neither but cannot be both. Write a line of code to set "+g[2]+" so that the computer displays true exactly when the person can be a true baseball fan.")}})),x.addHelpMessageTask(B,E,(function(){return u.every((function(e,t){var n=A.getAllBlocks().find((function(t){return t.type===e}));return h[t].hasFullMatch(n.getFieldValue("EXP"),!1)}))}),(function(){return"Using the truth table, set "+g[2]+" to the appropriate Boolean expression in terms of "+g[0]+" and "+g[1]+"."}),(function(){for(var e=0;e3&&void 0!==arguments[3]?arguments[3]:1/0;return o(e.map((function(e){return n.map((function(n){return function e(t,n,o){var i=arguments.length>3&&void 0!==arguments[3]?arguments[3]:1/0;return t===n?o:0!==i&&Array.isArray(t)?t.map((function(t){return e(t,n,o,i-1)})):t}(e,t,n,i)}))})))}(e,n,function e(t){return 1===t.length?[t]:t.map((function(n,o){return e(t.slice(0,o).concat(t.slice(o+1))).map((function(e){return[t[o]].concat(e)}))})).reduce((function(e,t){return e.concat(t)}),[])}(n),t)}),[e])})))}function s(e,t){return e.reduce((function(e,n){return e.concat([t]).concat(n)}),[]).slice(1)}var u=["cs1030_18_type_in_p","cs1030_18_type_in_q","cs1030_18_type_in_r","cs1030_18_type_in_set_exactly_two","cs1030_18_type_in_display_exactly_two"],g=["p","q","r","exactlyOne"],h=u.map((function(e){return new d(e,{collapseWhenFinished:!0})})),m=function(e,t){var o=t.reduce((function(e,t,o){return l(a(e,n,o+1,[function(e){return e.token===t}]),o)}),e);return t.slice().reduce((function(e,n,o){return a(e,s,t.length-o,[{token:t[t.length-1-o],type:"terminal"}])}),o)}([[g[0],{token:"and",type:"terminal"},{token:"not",type:"terminal"},g[1],{token:"and",type:"terminal"},{token:"not",type:"terminal"},g[2],{token:"or",type:"terminal"},g[1],{token:"and",type:"terminal"},{token:"not",type:"terminal"},g[2],{token:"and",type:"terminal"},{token:"not",type:"terminal"},g[0],{token:"or",type:"terminal"},g[2],{token:"and",type:"terminal"},{token:"not",type:"terminal"},g[0],{token:"and",type:"terminal"},{token:"not",type:"terminal"},g[1]]],["or","and"]),y=['"Enter p: (true:OK or false:CANCEL)"','"Enter q: (true:OK or false:CANCEL)"','"Enter r: (true:OK or false:CANCEL)"'],T=[null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null],_=m.map((function(e){return[{token:"let",type:"terminal"},g[3],"="].concat(e).concat([{token:/^[;]*$/,type:"regexp"}])}));_.forEach((function(e){return h[3].addPossibleMatch(e,T.slice(0,e.length))})),console.log(_,m.length);var b=[[{token:"let",type:"terminal"},g[0],"=",{token:"confirm",type:"terminal"},"(",{token:/^"[^"]*$|^'[^']*$|^"[^"]*"|^'[^']*'/,type:"regexp"},")",{token:/^[;]*$/,type:"regexp"}],[{token:"let",type:"terminal"},g[1],"=",{token:"confirm",type:"terminal"},"(",{token:/^"[^"]*$|^'[^']*$|^"[^"]*"|^'[^']*'/,type:"regexp"},")",{token:/^[;]*$/,type:"regexp"}],[{token:"let",type:"terminal"},g[2],"=",{token:"confirm",type:"terminal"},"(",{token:/^"[^"]*$|^'[^']*$|^"[^"]*"|^'[^']*'/,type:"regexp"},")",{token:/^[;]*$/,type:"regexp"}],null,[{token:"display",type:"terminal"},"(",g[3],")",{token:/^[;]*$/,type:"regexp"}]];b.forEach((function(e,t){return 3!==t&&h[t].addPossibleMatch(e,T.slice(0,e.length))})),h.forEach((function(e){return e.addToBlocks()}));var k=new p,x=k.createStandardHelpMessageManager(),E=e||new c,B=t||Blockly.getMainWorkspace(),A=new f(B);B.clear(),A.clearToolbox();var v=k.createPointer();document.body.appendChild(v);var I=u.map((function(e){return Object(i.e)(B,e)}));I.slice(0,I.length-1).forEach((function(e,t){return Object(i.i)(e,I[t+1])}));var w=T2C.MSG.currentLanguage===T2C.MSG.PY?T2C.MSG.PY:T2C.MSG.JS;return I.forEach((function(e,t){return 3!==t&&e.setFieldValue(b[t].slice(0,b[t].length-1).map((function(e){return"terminal"===e.type?w["TERMINAL_"+e.token.toUpperCase()]:"regexp"===e.type?y[t]:e})).join(""),"EXP")})),B.setScale(1),B.getAllBlocks().forEach((function(e){return e.setMovable(!1)})),Object(i.f)(B),E.addTask(new r((function(){return!0}),{start:function(){return!0},isComplete:function(){return!0},animate:function(){return!0},finish:function(){alert("In progress: 3 Letters: Exactly One. Write a line of code to set "+g[3]+" so that the computer displays true exactly when one of "+g[0]+", "+g[1]+", "+g[2]+" is true.")}})),k.addHelpMessageTask(E,x,(function(){return u.every((function(e,t){var n=B.getAllBlocks().find((function(t){return t.type===e}));return h[t].hasFullMatch(n.getFieldValue("EXP"),!1)}))}),(function(){return"Using the truth table, set "+g[3]+" to the appropriate Boolean expression in terms of "+g[0]+", "+g[1]+", and "+g[2]+"."}),(function(){for(var e=0;et.viewLeft+t.viewWidth||n.topt.viewTop+t.viewHeight}))}function u(e){var t=T2C.MSG.currentLanguage===T2C.MSG.PY?"Python":"JavaScript";s(e).filter((function(e){return e.getParent()&&!e.nextConnection&&!e.isCollapsed()})).slice().forEach((function(n){if(!n.isDisposed()){var o=a(e,"code_expression");c(o,Blockly[t].blockToCode(n)[0]||Blockly[t].blockToCode(n),"EXP"),o.setCollapsed(!0),n.getParent().getInputWithBlock(n).connection.connect(o.outputConnection),n.dispose(!0)}})),i(e),s(e).length>0&&e.zoomToFit()}function c(e,t,n){if(n){var o=e.workspace,i=t;e.type.toLowerCase().startsWith("variables_")&&"VAR"===n&&(i=-1===o.getAllVariableNames().indexOf(t)?o.createVariable(t).getId():o.getVariable(t).getId()),e.setFieldValue(i,n)}else console.warn("Ignoring request to set field value to",t," of ",e,"because no field name was given")}function g(e){if(!e)return null;for(var t=e.getParent();t&&!t.previousConnection;)t=t.getParent();return t}function d(e){for(var t=e;!t.nextConnection&&t.getParent();)t=t.getParent();for(;t.getNextBlock();)t=t.getNextBlock();return t}function h(e,t,n){var o=e.getParent(),i=null,r=null,a=-1,l=null;return e.inputList.forEach((function(e){e.fieldRow.forEach((function(e){t.getField(e.name)&&c(t,e.getValue(),e.name)}))})),o?(a=(r=(i=o.getInputWithBlock(e))?i.connection:o.nextConnection).targetConnection.type)===Blockly.OUTPUT_VALUE?r.connect(t.outputConnection):a===Blockly.PREVIOUS_STATEMENT&&(l=t.previousConnection):t.moveBy(e.getRelativeToSurfaceXY().x-t.getRelativeToSurfaceXY().x,e.getRelativeToSurfaceXY().y-t.getRelativeToSurfaceXY().y),e.getChildren().slice().forEach((function(n){if(e.getNextBlock()!==n){var o=e.getInputWithBlock(n),i=t.getInput(o.name);i&&(o=i.connection.connect(n.outputConnection))}else d(t).nextConnection&&d(t).nextConnection.connect(n.previousConnection)})),l&&r.connect(l),n&&e.dispose(),t}n.d(t,"j",(function(){return o})),n.d(t,"f",(function(){return i})),n.d(t,"i",(function(){return r})),n.d(t,"e",(function(){return a})),n.d(t,"d",(function(){return l})),n.d(t,"a",(function(){return u})),n.d(t,"h",(function(){return c})),n.d(t,"c",(function(){return g})),n.d(t,"b",(function(){return d})),n.d(t,"g",(function(){return h}))},function(module,__webpack_exports__,__webpack_require__){__webpack_require__.r(__webpack_exports__),__webpack_require__.d(__webpack_exports__,"getParseTree",(function(){return getParseTree})),__webpack_require__.d(__webpack_exports__,"handleParseTreeToBlocks",(function(){return handleParseTreeToBlocks})),__webpack_require__.d(__webpack_exports__,"parseAndConvertToBlocks",(function(){return parseAndConvertToBlocks})),__webpack_require__.d(__webpack_exports__,"workspaceToLanguageCode",(function(){return workspaceToLanguageCode})),__webpack_require__.d(__webpack_exports__,"workspaceToXML",(function(){return workspaceToXML}));var _grammar_js__WEBPACK_IMPORTED_MODULE_0__=__webpack_require__(6),_tokenizer_js__WEBPACK_IMPORTED_MODULE_1__=__webpack_require__(9),_parser_js__WEBPACK_IMPORTED_MODULE_2__=__webpack_require__(13),_parse_tree_block_connector_js__WEBPACK_IMPORTED_MODULE_3__=__webpack_require__(10),_block_interpretations_js__WEBPACK_IMPORTED_MODULE_4__=__webpack_require__(7),_block_evaluator_js__WEBPACK_IMPORTED_MODULE_5__=__webpack_require__(11),_block_generator_js__WEBPACK_IMPORTED_MODULE_6__=__webpack_require__(8),_block_converters_javascript_text_exact_js__WEBPACK_IMPORTED_MODULE_7__=__webpack_require__(12),_block_utility_functions_js__WEBPACK_IMPORTED_MODULE_8__=__webpack_require__(0);Blockly.COLLAPSE_CHARS=200;var isMobile=Blockly.utils.userAgent.MOBILE||Blockly.utils.userAgent.ANDROID||Blockly.utils.userAgent.IPAD,getParseTree=function(e){console.warn("Attempting to parse",e);var t=T2C.MSG&&T2C.MSG.currentLanguage===T2C.MSG.PY?e.replace(/[\r\n]+/g,";"):e,n=shared.parser.parseBottomUpCYK(t,shared.parseTreeBlockConnector)[0];return n&&console.log("Parse Tree:",n),n},handleParseTreeToBlocks=function(e,t){var n=!(arguments.length>2&&void 0!==arguments[2])||arguments[2],o=arguments.length>3&&void 0!==arguments[3]?arguments[3]:null;o=o||shared.workspace;var i=shared.evaluator.evaluate(e);console.log("Evaluation: ",i,t),t=t||Object(_block_utility_functions_js__WEBPACK_IMPORTED_MODULE_8__.e)(o);var r=Object(_block_generator_js__WEBPACK_IMPORTED_MODULE_6__.a)(i,t,n);return console.log(r),r},parseAndConvertToBlocks=function(e,t){if(console.warn(t.type,t),!this.isCollapsed()&&(e.updateAutocomplete&&e.updateAutocomplete(this.getFieldValue("EXP"),e.OPTIONS,e.shownOPTIONS,(function(e){return console.warn("Parsing Partial",e),shared.parser.parseBottomUpCYK(e,shared.parseTreeBlockConnector).length>0})),this.getFieldValue("AUTOCPLT")&&Object(_block_utility_functions_js__WEBPACK_IMPORTED_MODULE_8__.h)(this,this.getFieldValue("AUTOCPLT")+"\n","EXP"),e.editing&&(this.getFieldValue("EXP").endsWith("\r")||this.getFieldValue("EXP").endsWith("\n"))||e.editing&&"workspaceClick"===t.element)){var n=getParseTree(this.getFieldValue("EXP"));if(n){e.editing=!1;var o=handleParseTreeToBlocks(n,this,!1);shared.workspace.getAllBlocks().filter((function(e){return!e.getParent()&&("code_expression"===e.type||"code_statement"===e.type)})).forEach((function(e){return e.dispose()}));var i=shared.workspace.getAllBlocks().find((function(e){return"code_expression"===e.type||"code_statement"===e.type}));if(i)Object(_block_utility_functions_js__WEBPACK_IMPORTED_MODULE_8__.a)(shared.workspace),i=shared.workspace.getAllBlocks().find((function(e){return"code_expression"===e.type||"code_statement"===e.type})),isMobile||i.getField("EXP").showEditor_();else{console.warn("Replacing block",o);var r=Object(_block_utility_functions_js__WEBPACK_IMPORTED_MODULE_8__.b)(o),a=Object(_block_utility_functions_js__WEBPACK_IMPORTED_MODULE_8__.e)(shared.workspace,"code_statement");r.nextConnection&&Object(_block_utility_functions_js__WEBPACK_IMPORTED_MODULE_8__.i)(r,a),Object(_block_utility_functions_js__WEBPACK_IMPORTED_MODULE_8__.f)(shared.workspace),Object(_block_utility_functions_js__WEBPACK_IMPORTED_MODULE_8__.a)(shared.workspace),a=shared.workspace.getAllBlocks().find((function(e){return"code_statement"===e.type})),isMobile||a.getField("EXP").showEditor_()}}else e.editing&&"workspaceClick"===t.element&&alert("There seems to be a problem with the code you entered. Check that your spelling is correct, that you use lowercase and capital letters as required, that every open parenthesis ( has a matching closed one ), that you use quotation marks as needed, and other potential issues with syntax.")}};function varsToLets(e){var t=e.search(/^\s*var|[\r\n]\s*var/),n=e.indexOf("var",t)+4,o=e.indexOf(";",n),i=[],r=e;return-1!==t&&(i=e.substring(n,o).split(", "),r=e.substring(0,n-4)+e.substring(o+1)),i.forEach((function(e){r=r.replace("\n"+e+" = ","\nlet "+e+" = ")})),r.trim()}var workspaceToLanguageCode=function(e,t){var n=t===T2C.MSG.PY?"Python":"JavaScript";Blockly.Python.tempFinish=Blockly.Python.finish,Blockly.Python.finish=function(e){return e};var o=e.getAllBlocks(),i=o.map((function(e){return e.getCommentText()}));o.forEach((function(e){return e.setCommentText(null)}));var r=Blockly[n].workspaceToCode(e||Blockly.getMainWorkspace());return Blockly.Python.finish=Blockly.Python.tempFinish,o.forEach((function(e,t){return e.setCommentText(i[t])})),"Python"===n?r:varsToLets(r)},workspaceToXML=function(e){var t=Blockly.Xml.workspaceToDom(e||Blockly.getMainWorkspace());return Blockly.Xml.domToPrettyText(t)},shared=function(){var init=function(){window.addEventListener("DOMContentLoaded",(function(e){if(!document.getElementById("blockly-div").getAttribute("hasWorkspace")){document.getElementById("blockly-div").setAttribute("hasWorkspace",!0),shared.toolbox=document.getElementById("toolbox");var t={toolbox:toolbox,collapse:!0,comments:!1,disable:!1,maxBlocks:1/0,trashcan:!0,horizontalLayout:!0,toolboxPosition:"start",css:!0,media:"https://blockly-demo.appspot.com/static/media/",rtl:!1,scrollbars:!0,sounds:!0,oneBasedIndex:!0,zoom:{controls:!0,startScale:Math.min(window.innerWidth/800,1),minScale:Math.min(window.innerWidth/800,.3)}};shared.workspace=Blockly.inject("blockly-div",t),console.warn(shared.workspace.getWidth()),Object(_block_utility_functions_js__WEBPACK_IMPORTED_MODULE_8__.e)(shared.workspace,"code_statement"),Object(_block_utility_functions_js__WEBPACK_IMPORTED_MODULE_8__.f)(shared.workspace);var n=shared.workspace.getAllBlocks().find((function(e){return"code_statement"===e.type}));isMobile||n.getField("EXP").showEditor_();var o=function(){var e=document.getElementById("language").value;T2C.MSG.currentLanguage=T2C.MSG[e.toUpperCase()],updateToolbox(T2C.MSG.currentLanguage),Blockly.Msg.VARIABLES_SET=T2C.MSG.currentLanguage===T2C.MSG.PY?"%1 = %2":"let %1 = %2;",updateTexts(),Object(_block_utility_functions_js__WEBPACK_IMPORTED_MODULE_8__.f)(shared.workspace||Blockly.getMainWorkspace()),document.getElementById("outputAppearsBelow").innerText=T2C.MSG.currentLanguage.HEADING_OUTPUT_APPEARS_BELOW,document.getElementById("bottomText")&&(document.getElementById("bottomText").innerText=T2C.MSG.currentLanguage.HEADING_BOTTOM_TEXT)};if(window.location&&"string"==typeof window.location.href){var i=window.location.href.indexOf("lang=")+5,r=window.location.href.substring(i,i+2);4!==i&&(document.getElementById("language").value=r,o())}window.addEventListener("resize",(function(){document.getElementById("top-header").style.height=Math.max(.1*window.innerHeight,50)+"px",document.getElementById("all-content").style.height=Math.min(.9*window.innerHeight,window.innerHeight-50)+"px",Blockly.svgResize(shared.workspace)})),document.getElementById("language").addEventListener("change",(function(){o();var e=shared.workspace||Blockly.getMainWorkspace();e.getAllBlocks().forEach(_block_converters_javascript_text_exact_js__WEBPACK_IMPORTED_MODULE_7__.a),Object(_block_utility_functions_js__WEBPACK_IMPORTED_MODULE_8__.f)(e)})),document.getElementById("run-code-button")&&(document.getElementById("run-code-button").addEventListener("click",(function(){document.getElementById("output-container").classList.remove("hide-container"),document.getElementById("output-container").classList.add("show-container"),document.getElementById("consoleDisplay")&&(document.getElementById("consoleDisplay").textContent=""),T2C.MSG.currentLanguage===T2C.MSG.PY&&(T2C.MSG.currentLanguage=T2C.MSG.JS),document.getElementById("textCodeBox").value=runCode(),T2C.MSG.currentLanguage=T2C.MSG[document.getElementById("language").value.toUpperCase()],document.getElementById("xmlData").value=generateXML()})),document.getElementById("save-code-button").addEventListener("click",(function(){document.getElementById("text-code-container").classList.remove("hide-container"),document.getElementById("text-code-container").classList.add("show-container"),document.getElementById("textCodeBox").value=generateCode(),document.getElementById("xmlData").value=generateXML(),document.getElementById("load-save-text-code").textContent=T2C.MSG.currentLanguage.BUTTON_SAVE_TEXT_CODE,document.getElementById("load-save-xml").textContent=T2C.MSG.currentLanguage.BUTTON_SAVE_XML})),document.getElementById("load-code-button").addEventListener("click",(function(){document.getElementById("text-code-container").classList.remove("hide-container"),document.getElementById("text-code-container").classList.add("show-container"),document.getElementById("textCodeBox").value="",document.getElementById("xmlData").value="",document.getElementById("load-save-text-code").textContent=T2C.MSG.currentLanguage.BUTTON_LOAD_TEXT_CODE,document.getElementById("load-save-xml").textContent=T2C.MSG.currentLanguage.BUTTON_LOAD_XML})),document.getElementById("load-save-text-code").addEventListener("click",(function(){if(document.getElementById("load-save-text-code").textContent===T2C.MSG.currentLanguage.BUTTON_LOAD_TEXT_CODE){var e=T2C.MSG.currentLanguage.CONFIRM_CONVERT_TEXT_TO_BLOCKS,t=getParseTree(document.getElementById("textCodeBox").value);t&&confirm(e)?(shared.workspace.clear(),handleParseTreeToBlocks(t)):t||alert("There seems to be a problem with the code you entered. Check that your spelling is correct, that you use lowercase and capital letters as required, that every open parenthesis ( has a matching closed one ), that you use quotation marks as needed, and other potential issues with syntax.")}else{var n=document.getElementById("textCodeBox").value;navigator.clipboard.writeText(n).then((function(){alert("Code successfully copied to clipboard")}),(function(){document.getElementById("textCodeBox").select(),alert("Code unable to be copied to clipboard. Please do this manually.")}))}})),document.getElementById("load-save-xml").addEventListener("click",(function(){if(document.getElementById("load-save-xml").textContent===T2C.MSG.currentLanguage.BUTTON_LOAD_XML)generateBlocksFromXML();else{var e=document.getElementById("xmlData").value;navigator.clipboard.writeText(e).then((function(){alert("XML successfully copied to clipboard")}),(function(){document.getElementById("xmlData").select(),alert("XML unable to be copied to clipboard. Please do this manually.")}))}})),document.getElementById("output-container").addEventListener("click",(function(e){"table-cell"===e.target.className&&(document.getElementById("output-container").classList.remove("show-container"),document.getElementById("output-container").classList.add("hide-container"))})),document.getElementById("text-code-container").addEventListener("click",(function(e){"table-cell"===e.target.className&&(document.getElementById("text-code-container").classList.remove("show-container"),document.getElementById("text-code-container").classList.add("hide-container"))})))}}));var e=new _tokenizer_js__WEBPACK_IMPORTED_MODULE_1__.a(_grammar_js__WEBPACK_IMPORTED_MODULE_0__.b);return{lexer:e,parser:new _parser_js__WEBPACK_IMPORTED_MODULE_2__.a(e,_grammar_js__WEBPACK_IMPORTED_MODULE_0__.a,Object.keys(_block_interpretations_js__WEBPACK_IMPORTED_MODULE_4__.a).concat("statement")),parseTreeBlockConnector:new _parse_tree_block_connector_js__WEBPACK_IMPORTED_MODULE_3__.a,evaluator:new _block_evaluator_js__WEBPACK_IMPORTED_MODULE_5__.a(_block_interpretations_js__WEBPACK_IMPORTED_MODULE_4__.a)}},shared=init();function varsToLets(e){var t=e.indexOf("var")+4,n=e.indexOf(";",t),o=[],i=e;return t>3&&(o=e.substring(t,n).split(", "),i=e.substring(0,t-4)+e.substring(n+1)),o.forEach((function(e){i=i.replace("\n"+e+" = ","\nlet "+e+" = ")})),i.trim()}function generateCode(){return workspaceToLanguageCode(shared.workspace,T2C.MSG.currentLanguage)}function generateXML(){return workspaceToXML(shared.workspace)}function generateBlocksFromXML(){var e=shared.workspace||Blockly.getMainWorkspace(),t=document.getElementById("xmlData").value,n=null;try{n=Blockly.Xml.textToDom(t)}catch(e){if(!window.confirm(e))return}n&&(e.clear(),Blockly.Xml.domToWorkspace(n,e)),Blockly.svgResize(e)}function runCode(){var code=generateCode();console.realLog=console.log;try{document.getElementById("consoleDisplay").textContent="",console.log=function(){document.getElementById("consoleDisplay").appendChild(document.createTextNode(Array.prototype.join.call(arguments," ")+"\n"))},eval(code)}catch(e){-1!=e.toString().indexOf("Reference")?alert(e.toString()+"\nMake sure variables are defined before they're used. This means the variable definition let ____ = ____ needs to appear ABOVE."):alert(e.toString())}return console.log=console.realLog,code}function updateToolbox(e){shared.workspace.updateToolbox(shared.toolbox)}function updateTexts(){document.getElementById("text-code-container").querySelectorAll("textarea").forEach((function(e){e.placeholder=T2C.MSG.currentLanguage[e.name]}))}return shared}()},function(e,t,n){t.a=function(){function e(t,n){_classCallCheck(this,e),this.lhs_=t,this.rhs_=n}return _createClass(e,[{key:"lhs",get:function(){return this.lhs_}},{key:"rhs",get:function(){return this.rhs_}}]),e}()},function(e,t,n){var o=function(){function e(){_classCallCheck(this,e)}return _createClass(e,null,[{key:"oneStartsWithOther_",value:function(e,t){var n=arguments.length>2&&void 0!==arguments[2]&&arguments[2],o=n?e:e.toLowerCase(),i=n?t:t.toLowerCase();return o.startsWith(i)||i.startsWith(o)}},{key:"getAfter_",value:function(t,n){if(e.oneStartsWithOther_(t,n))return n.substring(Math.min(t.length,n.length))}},{key:"equalsTerminal",value:function(e){return Object.values(T2C.MSG).find((function(t){return Object.keys(t).find((function(n){return n.toUpperCase().startsWith("TERMINAL_")&&t[n]===e}))}))}},{key:"escapeRegExp",value:function(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}},{key:"getAfterTerminal_",value:function(t,n){var o=Object.values(T2C.MSG).map((function(e){return e["TERMINAL_"+n.toUpperCase()]})).filter((function(e){return"string"==typeof e})),i=t.match(/^\s*/)[0];t.match(/\s*$/)[0];var r=void 0,a=o.find((function(n){return r=t.match(RegExp("^\\s*"+e.escapeRegExp(n)))||(i+n).match(RegExp("^\\s*"+e.escapeRegExp(t)))})),l=a&&r[0];if("string"==typeof a)return{terminal:a,remaining:e.getAfter_(l,t),match:l}}},{key:"getTerminalIndexForSymbol",value:function(t,n){if(-1!==["[","(","."].indexOf(e.getExpected(t[n])))return n-1;if(-1!==[")","]"].indexOf(e.getExpected(t[n]))){for(var o=[],i=0;i1&&void 0!==arguments[1]?arguments[1]:{};if("block"===t.type){var o=t.value.type||t.value.types&&t.value.types[0],i=t.value.inputs;o&&(n[o]=++n[o]||1),Array.isArray(i)&&i.forEach((function(t){return e.getBlocksInBlueprint(t,n)}))}else if("input"===t.type)e.getBlocksInBlueprint(t.value,n);else if("component"===t.type&&T2C.MatchManagers[t.name])if("function"==typeof T2C.MatchManagers[t.name].getBlocksInMatch)T2C.MatchManagers[t.name].getBlocksInBlueprint(t.value,n);else{var r=e.getMatchResult(null,t);console.warn("Component Match",e.getRemainingToolboxBlocks(r,n))}return n}},{key:"getRemainingToolboxBlocks",value:function(t){var n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return t.filter((function(e){return e.remainingBlueprint})).map((function(e){return e.remainingBlueprint})).forEach((function(t){return e.getBlocksInBlueprint(t,n)})),n}},{key:"getMaxInstancesFromMatch",value:function(t){var n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},o=e.getCorrectBlocksFromMatch(t);e.getRemainingToolboxBlocks(t,n),o.forEach((function(e){return n[e.type]=++n[e.type]||1}))}},{key:"getCorrectBlockMatchItems",value:function(e){return e.filter((function(e){return e.match instanceof Blockly.Block&&"block"===e.type}))}},{key:"getCorrectBlocksFromMatch",value:function(t){return e.getCorrectBlockMatchItems(t).map((function(e){return e.match}))}},{key:"getTextToParseFromMatch",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]&&arguments[1];return e.map((function(e){return e.length&&1!==e.length||"string"!=typeof e.match||!e.isMatchComplete&&!t?"":e.match})).join("")}},{key:"makeErrorMatch_",value:function(e,t,n){return{id:t,expected:n,length:0,match:null,remaining:e,isMatchComplete:!1,hasError:!0}}},{key:"getExpected",value:function(e){return null==e?e:[e.value,e.match,e.expected,e].find((function(e){return"string"==typeof e}))}},{key:"getSequentialMatchResult_",value:function(t,n){for(var o=[],i=[{match:null,remaining:t,hasError:!1,isMatchComplete:!0}],r=-1;r0?o[o.length-1].remaining:null,isMatchComplete:o.every((function(e){return e.isMatchComplete})),hasError:o.some((function(e){return e.hasError}))}].concat(o)}if("block"===n.type){if(t instanceof Blockly.Block&&(t.type===n.value.type||Array.isArray(n.value.types)&&n.value.types.includes(t.type))){var i=n.value.inputs.map((function(e){return t.getInput(e.name)})),r=n.value.fields.map((function(e){return t.getField(e.name)})),a=e.getMatchResult(i.concat(r),{type:"Array",value:n.value.inputs.concat(n.value.fields)});return[{id:n.id,match:t,length:a.length+1,remaining:null,type:"block",isMatchComplete:a.every((function(e){return e.isMatchComplete})),hasError:!1}].concat(a)}return[{id:n.id,match:null,length:0,remaining:t,remainingBlueprint:n,hasError:null!=t,isMatchComplete:!1}]}if("input"===n.type){if(t instanceof Blockly.Input&&t.name===n.name){var l=e.getMatchResult(t.connection&&t.connection.targetBlock(),n.value);return[{id:n.id,match:t,length:l.length+1,remaining:null,isMatchComplete:!0,hasError:!1}].concat(l)}return[{id:n.id,match:null,length:0,remaining:t,hasError:null!=t,isMatchComplete:!1}]}if("field"===n.type){if(t instanceof Blockly.Field&&t.name===n.name){var s=e.getMatchResult(n.useText?t.getText():t.getValue(),n.value);return[{id:n.id,expected:e.getExpected(n.value),match:t,length:s.length+1,remaining:s[s.length-1].remaining,isMatchComplete:s.every((function(e){return e.isMatchComplete})),hasError:""!==t.getValue()&&s.some((function(e){return e.hasError}))}].concat(s)}return[{id:n.id,match:null,length:0,remaining:t,hasError:null!=t,isMatchComplete:!1}]}if("property"===n.type)return n.property,e.makeErrorMatch_(t,id);if("exact"===n.type){var u=n.property?t[n.name]:t,c=n.value,g=[{id:n.id,expected:e.getExpected(c),match:null,remaining:u,hasError:!0,isMatchComplete:!1}];if("string"==typeof u&&"string"==typeof c){var d=c.match(/^\s*/)[0],h=u.match(/^\s*/)[0],p=u.substring(h.length),f=c.substring(d.length);return c.match(/\s*$/)[0],u.match(/\s*$/)[0],(h.endsWith(d)||n.partial&&!p)&&(!p||p.startsWith(f)||n.partial&&f.startsWith(p))&&(n.postfix||!p.substring(Math.min(f.length,p.length)).trim())?f.length>p.length?[{id:n.id,match:u,remaining:"",hasError:!1,isMatchComplete:!1}]:[{id:n.id,match:h+f,remaining:u.substring(h.length+f.length),hasError:!1,isMatchComplete:!0}]:g}return u===c?[{id:n.id,match:u,remaining:null,hasError:!1,isMatchComplete:!1}]:g}if("includes"===n.type){var m=n.property?t[n.name]:t;return"function"==typeof m.includes&&m.includes(n.value)?[{id:n.id,match:m,remaining:null,hasError:!1,isMatchComplete:!0}]:[{id:n.id,expected:e.getExpected(n.value),match:null,remaining:m,hasError:null!=m&&""!==m,isMatchComplete:!1}]}if("or"===n.type){var y=e.getBestMatchWithIndex_(t,n.value,n.comparer),T=y.matchArr;return[{id:n.id,match:y.pattern,index:y.index,length:y.matchArr.length+1,remaining:null,hasError:T.some((function(e){return e.hasError})),isMatchComplete:!0}].concat(y.matchArr)}if("Array"===n.type){if("string"==typeof t)return e.getSequentialMatchResult_(t,n.value);console.assert(Array.isArray(n.value));var _=n.value.map((function(n,o){return e.getMatchResult(t[o],n)})),b=_.flat();return[{id:n.id,match:n.value,type:n.type,length:b.length+1,remaining:null,isMatchComplete:b.every((function(e){return e.isMatchComplete})),hasError:_.some((function(e){return e.hasError}))}].concat(b)}if("regexp"===n.type){for(var k=t.toString(),x=k.match(/^\s*/)[0],E=void 0,B=!1,A="";!(E=(A+k).match(n.token))&&A!==x;)A+=" ";if(E)B=!0;else if(void 0!==n.tokenPartial)for(A="";!(E=(A+k).match(n.tokenPartial))&&A!==x;)A+=" ";return E?[{id:n.id,expected:n.token,match:E[0],length:1,remaining:k.substring(x.length+E[0].trim().length),isMatchComplete:B,hasError:!1}]:[e.makeErrorMatch_(t,n.id,n.token)]}if("terminal"===n.type&&!(t instanceof Blockly.Block)){var v=e.getAfterTerminal_(t,n.token);return[{id:n.id,expected:T2C.MSG.currentLanguage["TERMINAL_"+n.token.toUpperCase()],terminal:v?v.terminal:null,match:v?v.match:null,remaining:v?v.remaining:t,hasError:!v,isMatchComplete:v&&v.match.includes(v.terminal)}]}}},{key:"getNonEmptyMatchLength_",value:function(e){return e.filter((function(e){return null!=e.match&&""!=e.match})).length}},{key:"getBestMatchWithIndex_",value:function(t,n,o){return o="function"==typeof o?o:function(t,n){return e.getNonEmptyMatchLength_(t)>e.getNonEmptyMatchLength_(n)||!t.hasError&&n.hasError},n.reduce((function(n,i,r){var a=e.getMatchResult(t,i);return 0===r||o(a,n.matchArr)?{index:r,pattern:i,matchArr:a}:n}),{index:-1,matchArr:[],pattern:{}})}}]),e}();t.a=o},function(e,t,n){function o(e,t,n){return e instanceof Array&&t instanceof Array?e.reduce((function(e,o){return e.concat(t.map((function(e){return n?o.concat(e):[o,e]})))}),[]):[]}function i(e){return 0===e.length?[]:1===e.length?e[0].map((function(e){return[e]})):e.reduce((function(e,t,n){return o(e,t,n>1)}))}n.d(t,"b",(function(){return o})),n.d(t,"a",(function(){return i}))},function(e,t,n){var o=function(){function e(t){_classCallCheck(this,e),this.blockTemplate_=JSON.parse(t),this.args_=[],this.blockVal_=null}return _createClass(e,[{key:"evaluate_",value:function(t){var n=this;if(t instanceof e)return t;if("string"==typeof t){var o=t.split(/(%\d+)/).map((function(e){var t=e.startsWith("%")&&parseInt(e.substring(1));return t?n.evaluate_(n.args_[t-1]):e}));return o.find((function(t){return t instanceof e}))||o.join("")}if(Array.isArray(t))return t.map(this.evaluate_.bind(this));var i={};return Object.keys(t).forEach((function(e){i[e]=n.evaluate_(t[e])})),i}},{key:"hasBeenSet_",value:function(e){return!/"%(\d+)"/.test(e)}},{key:"keys",value:function(e){var t=this;return this.blockVal_[e].filter((function(e){return t.hasBeenSet_(e)}))}},{key:"args",set:function(e){this.args_=e,this.blockVal_=this.evaluate_(this.blockTemplate_)}},{key:"type",get:function(){return this.blockVal_&&this.blockVal_.type}},{key:"inputs",get:function(){return this.blockVal_&&this.blockVal_.inputs}},{key:"fields",get:function(){return this.blockVal_&&this.blockVal_.fields}},{key:"blocks",get:function(){return this.blockVal_&&this.blockVal_.blocks}}]),e}();t.a=o},function(e,t,n){n.d(t,"a",(function(){return o})),n.d(t,"b",(function(){return i}));var o=JSON.parse('{"rules":{"wholeNumberExp":{"wholeNumberSum":["wholeNumberExp","wholeNumberAddMinusOp","wholeNumberTerm"],"wholeNumberTermSingle":["wholeNumberTerm"],"__2__wholeNumberSum":["wholeNumberExp","wholeNumberAddMinusOp"]},"wholeNumberTerm":{"wholeNumberTermSingleGroupedExp":["openParenthesis","wholeNumberTerm","closeParenthesis"],"wholeNumberTermTwoGroupedExp":["openParenthesis","wholeNumberExp","wholeNumberGroupedOp","wholeNumberTerm","closeParenthesis"],"wholeNumberTermProduct":["wholeNumberTerm","wholeNumberTimesDividedByOp","wholeNumberTerm"],"wholeNumberTermAtomic":["wholeNumberAtomic"],"__2__wholeNumberTermSingleGroupedExp":["openParenthesis","wholeNumberTerm"],"__2__wholeNumberTermTwoGroupedExp":["openParenthesis","wholeNumberExp"],"__3__wholeNumberTermTwoGroupedExp":["openParenthesis","wholeNumberExp","wholeNumberGroupedOp"],"__4__wholeNumberTermTwoGroupedExp":["openParenthesis","wholeNumberExp","wholeNumberGroupedOp","wholeNumberTerm"],"__2__wholeNumberTermProduct":["wholeNumberTerm","wholeNumberTimesDividedByOp"]},"wholeNumberAtomic":{"wholeNumberLiteral":"token_","identifierGet":["identifier"],"wholeNumberStringFunc":["stringExpWholeNumber"]},"wholeNumberGroupedOp":{"wholeNumberSumTwo":["wholeNumberAddMinusOp"],"wholeNumberProductTwo":["wholeNumberTimesDividedByOp"]},"wholeNumberAddMinusOp":{"wholeNumberPlus":"+","wholeNumberMinus":"-"},"wholeNumberTimesDividedByOp":{"wholeNumberTimes":"*","wholeNumberDividedBy":"/"},"expression":{"expressionText":["stringExp"],"expressionNumber":["wholeNumberExp"]},"statement":{"statementSingle":["expression"],"statementVariable":["variableStatement"],"statementPrint":["stringDisplay"],"statementSemicolon":["statement","semicolon"],"statementBlockExp":["expression","statementSeparator","statement"],"statementBlockVariable":["variableStatement","statementSeparator","statement"],"statementBlockPrint":["stringDisplay","statementSeparator","statement"]},"statementSeparator":{"semicolonEnd":["semicolon"],"newLineEnd":["newLine"],"carriageReturnEnd":["carriageReturn"],"semicolonMultiSeparator":["semicolon","statementSeparator"],"newLineMultiSeparator":["newLine","statementSeparator"],"carriageReturnMultiSeparator":["carriageReturn","statementSeparator"]},"semicolon":"token_","newLine":"\\n","carriageReturn":"\\r","stringExp":{"identifierGet":["identifier"],"stringGetInputExp":["stringGetInput","openParenthesis","stringExp","closeParenthesis"],"js_stringGetInputExp":["stringPrompt","openParenthesis","stringExp","closeParenthesis"],"stringGroupedExp":["openParenthesis","stringExp","closeParenthesis"],"stringConcatenationFullExpression":["stringExp","plusStr","stringExp"],"stringCharAtFullExpression":["stringExp","dot","getCharacterNumber","openParenthesis","wholeNumberExp","closeParenthesis"],"py_stringCharAtFullExpression":["stringExp","openBracket","wholeNumberExp","closeBracket"],"js_stringCharAtFullExpression":["stringExp","dot","getCharacterNumberJS","openParenthesis","wholeNumberExp","closeParenthesis"],"stringAfterTextFullExpression":["stringExp","dot","getAfterText","openParenthesis","stringExp","closeParenthesis"],"stringBeforeTextFullExpression":["stringExp","dot","getBeforeText","openParenthesis","stringExp","closeParenthesis"],"stringSubstringFullExpression":["stringExp","dot","getTextFrom","openParenthesis","wholeNumberExp","closeParenthesis","dot","getTextTo","openParenthesis","wholeNumberExp","stringSubstringCloseParenthesisOptionalTail"],"py_stringSubstringFullExpression":["stringExp","openBracket","wholeNumberExp","colon","wholeNumberExp","closeBracket"],"js_stringSubstringFullExpression":["stringExp","dot","getSubstringJS","openParenthesis","wholeNumberExp","comma","wholeNumberExp","closeParenthesis"],"stringLiteral":"token_","__2__stringGetInputExp":["stringGetInput","openParenthesis"],"__3__stringGetInputExp":["stringGetInput","openParenthesis","stringExp"],"__2__js_stringGetInputExp":["stringPrompt","openParenthesis"],"__3__js_stringGetInputExp":["stringPrompt","openParenthesis","stringExp"],"__2__stringGroupedExp":["openParenthesis","stringExp"],"__2__stringConcatenationFullExpression":["stringExp","plusStr"],"__2__stringCharAtFullExpression":["stringExp","dot"],"__3__stringCharAtFullExpression":["stringExp","dot","getCharacterNumber"],"__4__stringCharAtFullExpression":["stringExp","dot","getCharacterNumber","openParenthesis"],"__5__stringCharAtFullExpression":["stringExp","dot","getCharacterNumber","openParenthesis","wholeNumberExp"],"__2__py_stringCharAtFullExpression":["stringExp","openBracket"],"__3__py_stringCharAtFullExpression":["stringExp","openBracket","wholeNumberExp"],"__2__js_stringCharAtFullExpression":["stringExp","dot"],"__3__js_stringCharAtFullExpression":["stringExp","dot","getCharacterNumberJS"],"__4__js_stringCharAtFullExpression":["stringExp","dot","getCharacterNumberJS","openParenthesis"],"__5__js_stringCharAtFullExpression":["stringExp","dot","getCharacterNumberJS","openParenthesis","wholeNumberExp"],"__2__stringAfterTextFullExpression":["stringExp","dot"],"__3__stringAfterTextFullExpression":["stringExp","dot","getAfterText"],"__4__stringAfterTextFullExpression":["stringExp","dot","getAfterText","openParenthesis"],"__5__stringAfterTextFullExpression":["stringExp","dot","getAfterText","openParenthesis","stringExp"],"__2__stringBeforeTextFullExpression":["stringExp","dot"],"__3__stringBeforeTextFullExpression":["stringExp","dot","getBeforeText"],"__4__stringBeforeTextFullExpression":["stringExp","dot","getBeforeText","openParenthesis"],"__5__stringBeforeTextFullExpression":["stringExp","dot","getBeforeText","openParenthesis","stringExp"],"__2__stringSubstringFullExpression":["stringExp","dot"],"__3__stringSubstringFullExpression":["stringExp","dot","getTextFrom"],"__4__stringSubstringFullExpression":["stringExp","dot","getTextFrom","openParenthesis"],"__5__stringSubstringFullExpression":["stringExp","dot","getTextFrom","openParenthesis","wholeNumberExp"],"__6__stringSubstringFullExpression":["stringExp","dot","getTextFrom","openParenthesis","wholeNumberExp","closeParenthesis"],"__7__stringSubstringFullExpression":["stringExp","dot","getTextFrom","openParenthesis","wholeNumberExp","closeParenthesis","dot"],"__8__stringSubstringFullExpression":["stringExp","dot","getTextFrom","openParenthesis","wholeNumberExp","closeParenthesis","dot","getTextTo"],"__9__stringSubstringFullExpression":["stringExp","dot","getTextFrom","openParenthesis","wholeNumberExp","closeParenthesis","dot","getTextTo","openParenthesis"],"__10__stringSubstringFullExpression":["stringExp","dot","getTextFrom","openParenthesis","wholeNumberExp","closeParenthesis","dot","getTextTo","openParenthesis","wholeNumberExp"],"__2__py_stringSubstringFullExpression":["stringExp","openBracket"],"__3__py_stringSubstringFullExpression":["stringExp","openBracket","wholeNumberExp"],"__4__py_stringSubstringFullExpression":["stringExp","openBracket","wholeNumberExp","colon"],"__5__py_stringSubstringFullExpression":["stringExp","openBracket","wholeNumberExp","colon","wholeNumberExp"],"__2__js_stringSubstringFullExpression":["stringExp","dot"],"__3__js_stringSubstringFullExpression":["stringExp","dot","getSubstringJS"],"__4__js_stringSubstringFullExpression":["stringExp","dot","getSubstringJS","openParenthesis"],"__5__js_stringSubstringFullExpression":["stringExp","dot","getSubstringJS","openParenthesis","wholeNumberExp"],"__6__js_stringSubstringFullExpression":["stringExp","dot","getSubstringJS","openParenthesis","wholeNumberExp","comma"],"__7__js_stringSubstringFullExpression":["stringExp","dot","getSubstringJS","openParenthesis","wholeNumberExp","comma","wholeNumberExp"]},"stringExpWholeNumber":{"stringFindFirstFullExpression":["stringExp","dot","findFirstOccurrenceOfText","openParenthesis","stringExp","stringFindFirstCloseParenthesisOptionalTail"],"js_stringFindFirstFullExpression":["stringExp","dot","jsIndexOf","openParenthesis","stringExp","closeParenthesis"],"stringExpLength":["stringExp","dot","length"],"py_stringExpLength":["len","openParenthesis","stringExp","closeParenthesis"],"__2__stringFindFirstFullExpression":["stringExp","dot"],"__3__stringFindFirstFullExpression":["stringExp","dot","findFirstOccurrenceOfText"],"__4__stringFindFirstFullExpression":["stringExp","dot","findFirstOccurrenceOfText","openParenthesis"],"__5__stringFindFirstFullExpression":["stringExp","dot","findFirstOccurrenceOfText","openParenthesis","stringExp"],"__2__js_stringFindFirstFullExpression":["stringExp","dot"],"__3__js_stringFindFirstFullExpression":["stringExp","dot","jsIndexOf"],"__4__js_stringFindFirstFullExpression":["stringExp","dot","jsIndexOf","openParenthesis"],"__5__js_stringFindFirstFullExpression":["stringExp","dot","jsIndexOf","openParenthesis","stringExp"],"__2__stringExpLength":["stringExp","dot"],"__2__py_stringExpLength":["len","openParenthesis"],"__3__py_stringExpLength":["len","openParenthesis","stringExp"]},"stringDisplay":{"js_ConsoleLogStatement":["console","dot","log","openParenthesis","expression","closeParenthesis"],"displayStatement":["display","openParenthesis","expression","closeParenthesis"],"__2__js_ConsoleLogStatement":["console","dot"],"__3__js_ConsoleLogStatement":["console","dot","log"],"__4__js_ConsoleLogStatement":["console","dot","log","openParenthesis"],"__5__js_ConsoleLogStatement":["console","dot","log","openParenthesis","expression"],"__2__displayStatement":["display","openParenthesis"],"__3__displayStatement":["display","openParenthesis","expression"]},"stringSubstringCloseParenthesisOptionalTail":{"stringSubstringCloseParenthesisNoTail":["closeParenthesis"],"stringSubstringCloseParenthesisTail":["closeParenthesis","dot","substringTail"],"__2__stringSubstringCloseParenthesisTail":["closeParenthesis","dot"]},"stringFindFirstCloseParenthesisOptionalTail":{"stringFindFirstCloseParenthesisNoTail":["closeParenthesis"],"stringFindFirstCloseParenthesisTail":["closeParenthesis","dot","findFirstTail"],"__2__stringFindFirstCloseParenthesisTail":["closeParenthesis","dot"]},"dot":"token_","console":"console","log":"log","display":"display","openParenthesis":"token_","closeParenthesis":"token_","openBracket":"token_","closeBracket":"token_","comma":"token_","stringGetInput":"getInputByAsking","stringPrompt":"prompt","length":"length","len":"len","getTextFrom":"getTextFromPositionNUMBER","getTextTo":"toPositionNUMBER","getSubstringJS":"substring","jsIndexOf":"indexOf","findFirstOccurrenceOfText":"positionNumberOfTEXT","findLastOccurrenceOfText":"lastPositionNumberOfTEXT","getAfterText":"getAfterTEXT","getBeforeText":"getBeforeTEXT","plusStr":"+","getCharacterNumber":"getCharacterNUMBER","getCharacterNumberJS":"charAt","toNumber":"toNumber","substringTail":"tak_paen","findFirstTail":"ke_sthiti_sankhya","variableStatement":{"variableAssignment":["variablesLet","identifier","equalsSign","expression"],"variableAssignmentNoLet":["identifier","equalsSign","expression"],"__2__variableAssignment":["variablesLet","identifier"],"__3__variableAssignment":["variablesLet","identifier","equalsSign"],"__2__variableAssignmentNoLet":["identifier","equalsSign"]},"variablesLet":"let","equalsSign":"=","identifier":"token_"},"terminals":["wholeNumberPlus","wholeNumberMinus","wholeNumberTimes","wholeNumberDividedBy","semicolon","newLine","carriageReturn","findFirstOccurrenceOfText","jsIndexOf","findLastOccurrenceOfText","getAfterText","getBeforeText","plusStr","getCharacterNumber","getCharacterNumberJS","toNumber","getTextFrom","getSubstringJS","getTextTo","stringGetInput","stringPrompt","console","log","display","length","substringTail","findFirstTail","variablesLet","equalsSign"]}'),i=JSON.parse('{"stringLiteral":{"pattern":"\\"([^\\"]*)\\"|\'([^\']*)\'","order":1},"identifier":{"pattern":"([_\\\\$A-Za-z|ऄ-ह|ऽ|ॐ|क़-ॡ|ॱ-ॿ][\\\\w\\\\$|ऀ-ॣ|०-९|ॱ-ॿ]*)","order":2},"positiveDecimal":{"pattern":"(\\\\d+\\\\.[1-9]\\\\d+)","order":3},"wholeNumberLiteral":{"pattern":"\\\\d+|\\\\d*\\\\.[0]+","order":6},"dot":{"pattern":"(\\\\.)","order":7},"openParenthesis":{"pattern":"(\\\\()","order":8},"closeParenthesis":{"pattern":"(\\\\))","order":9},"openBracket":{"pattern":"(\\\\[)","order":10},"closeBracket":{"pattern":"(\\\\])","order":11},"comma":{"pattern":"(\\\\,)","order":12},"semicolon":{"pattern":"(\\\\;)","order":13},"colon":{"pattern":"(:)","order":14},"negativeDecimalMOVEDFROMFOURFORNOW":{"pattern":"(-\\\\d+\\\\.[1-9]\\\\d+)","order":15},"negativeIntegerMOVEDFROMFIVEFORNOW":{"pattern":"-[1-9]\\\\d*|-[1-9]\\\\d*\\\\.[0]+","order":16}}')},function(e,t,n){n.d(t,"a",(function(){return o}));var o=JSON.parse('{"wholeNumberLiteral":{"type":"math_number","fields":{"NUM":"%1"}},"wholeNumberSum":{"type":"math_arithmetic_basic","fields":{"OP":"%2"},"inputs":{"A":"%1","B":"%3"}},"wholeNumberTermTwoGroupedExp":{"type":"math_arithmetic_basic","fields":{"OP":"%3"},"inputs":{"A":"%2","B":"%4"}},"wholeNumberTermProduct":{"type":"math_arithmetic_basic","fields":{"OP":"%2"},"inputs":{"A":"%1","B":"%3"}},"wholeNumberPlus":"ADD","wholeNumberMinus":"MINUS","wholeNumberTimes":"MULTIPLY","wholeNumberDividedBy":"DIVIDE","wholeNumberTermSingleGroupedExp":"%2","statementBlockExp":{"blocks":["%1","%3"]},"statementBlockVariable":{"blocks":["%1","%3"]},"statementBlockPrint":{"blocks":["%1","%3"]},"stringLiteral":{"type":"text","fields":{"TEXT":"%1"}},"stringGetInputExp":{"type":"text_input","inputs":{"TEXT":"%3"}},"js_stringGetInputExp":{"type":"js_text_input","inputs":{"TEXT":"%3"}},"displayStatement":{"type":"text_print","inputs":{"TEXT":"%3"}},"js_ConsoleLogStatement":{"type":"js_text_print","inputs":{"TEXT":"%5"}},"stringExpLength":{"type":"t2c_text_length","inputs":{"VALUE":"%1"}},"py_stringExpLength":{"type":"t2c_text_length","inputs":{"VALUE":"%3"}},"stringFindFirstFullExpression":{"type":"t2c_text_indexof","inputs":{"VALUE":"%1","FIND":"%5"}},"js_stringFindFirstFullExpression":{"type":"js_text_indexof","inputs":{"VALUE":"%1","FIND":"%5"}},"stringSubstringFullExpression":{"type":"t2c_text_getsubstring","inputs":{"STRING":"%1","AT1":"%5","AT2":"%10"}},"stringCharAtFullExpression":{"type":"%3","inputs":{"VALUE":"%1","AT":"%5"}},"py_stringCharAtFullExpression":{"type":"t2c_text_charat","inputs":{"VALUE":"%1","AT":"%3"}},"js_stringCharAtFullExpression":{"type":"js_text_charat","inputs":{"VALUE":"%1","AT":"%5"}},"py_stringSubstringFullExpression":{"type":"t2c_text_getsubstring","inputs":{"STRING":"%1","AT1":"%3","AT2":"%5"}},"js_stringSubstringFullExpression":{"type":"js_text_getsubstring","inputs":{"STRING":"%1","AT1":"%5","AT2":"%7"}},"stringAfterTextFullExpression":{"type":"t2c_text_after","inputs":{"TEXT":"%1","SUB":"%5"}},"stringBeforeTextFullExpression":{"type":"t2c_text_before","inputs":{"TEXT":"%1","SUB":"%5"}},"stringConcatenationFullExpression":{"type":"t2c_text_join","inputs":{"A":"%1","B":"%3"}},"stringGroupedExp":"%2","plusStr":"t2c_text_join","findFirstOccurrenceOfText":"t2c_text_indexof","getCharacterNumber":"t2c_text_charat","getCharacterNumberJS":"js_text_charat","getSubstringJS":"js_text_getsubstring","jsIndexOf":"js_text_indexof","getTextFrom":"t2c_text_getsubstring","getAfterText":"t2c_text_after","getBeforeText":"t2c_text_before","identifierGet":{"type":"variables_get","fields":{"VAR":"%1"}},"variableAssignment":{"type":"variables_set","fields":{"VAR":"%2"},"inputs":{"VALUE":"%4"}},"variableAssignmentNoLet":{"type":"variables_set","fields":{"VAR":"%1"},"inputs":{"VALUE":"%3"}},"__2__wholeNumberSum":{"type":"math_arithmetic_basic","fields":{"OP":"%2"},"inputs":{"A":"%1","B":{"type":"code_expression"}}},"__2__wholeNumberTermSingleGroupedExp":"%2","__2__wholeNumberTermTwoGroupedExp":{"type":"math_arithmetic_basic","fields":{"OP":{"type":"code_expression"}},"inputs":{"A":"%2","B":{"type":"code_expression"}}},"__3__wholeNumberTermTwoGroupedExp":{"type":"math_arithmetic_basic","fields":{"OP":"%3"},"inputs":{"A":"%2","B":{"type":"code_expression"}}},"__4__wholeNumberTermTwoGroupedExp":{"type":"math_arithmetic_basic","fields":{"OP":"%3"},"inputs":{"A":"%2","B":"%4"}},"__2__wholeNumberTermProduct":{"type":"math_arithmetic_basic","fields":{"OP":"%2"},"inputs":{"A":"%1","B":{"type":"code_expression"}}},"__2__stringGetInputExp":{"type":"text_input","inputs":{"TEXT":{"type":"code_expression"}}},"__3__stringGetInputExp":{"type":"text_input","inputs":{"TEXT":"%3"}},"__2__js_stringGetInputExp":{"type":"js_text_input","inputs":{"TEXT":{"type":"code_expression"}}},"__3__js_stringGetInputExp":{"type":"js_text_input","inputs":{"TEXT":"%3"}},"__2__stringGroupedExp":"%2","__2__stringConcatenationFullExpression":{"type":"t2c_text_join","inputs":{"A":"%1","B":{"type":"code_expression"}}},"__2__stringCharAtFullExpression":{"type":{"type":"code_expression"},"inputs":{"VALUE":"%1","AT":{"type":"code_expression"}}},"__3__stringCharAtFullExpression":{"type":"%3","inputs":{"VALUE":"%1","AT":{"type":"code_expression"}}},"__4__stringCharAtFullExpression":{"type":"%3","inputs":{"VALUE":"%1","AT":{"type":"code_expression"}}},"__5__stringCharAtFullExpression":{"type":"%3","inputs":{"VALUE":"%1","AT":"%5"}},"__2__py_stringCharAtFullExpression":{"type":"t2c_text_charat","inputs":{"VALUE":"%1","AT":{"type":"code_expression"}}},"__3__py_stringCharAtFullExpression":{"type":"t2c_text_charat","inputs":{"VALUE":"%1","AT":"%3"}},"__2__js_stringCharAtFullExpression":{"type":"js_text_charat","inputs":{"VALUE":"%1","AT":{"type":"code_expression"}}},"__3__js_stringCharAtFullExpression":{"type":"js_text_charat","inputs":{"VALUE":"%1","AT":{"type":"code_expression"}}},"__4__js_stringCharAtFullExpression":{"type":"js_text_charat","inputs":{"VALUE":"%1","AT":{"type":"code_expression"}}},"__5__js_stringCharAtFullExpression":{"type":"js_text_charat","inputs":{"VALUE":"%1","AT":"%5"}},"__2__stringAfterTextFullExpression":{"type":"t2c_text_after","inputs":{"TEXT":"%1","SUB":{"type":"code_expression"}}},"__3__stringAfterTextFullExpression":{"type":"t2c_text_after","inputs":{"TEXT":"%1","SUB":{"type":"code_expression"}}},"__4__stringAfterTextFullExpression":{"type":"t2c_text_after","inputs":{"TEXT":"%1","SUB":{"type":"code_expression"}}},"__5__stringAfterTextFullExpression":{"type":"t2c_text_after","inputs":{"TEXT":"%1","SUB":"%5"}},"__2__stringBeforeTextFullExpression":{"type":"t2c_text_before","inputs":{"TEXT":"%1","SUB":{"type":"code_expression"}}},"__3__stringBeforeTextFullExpression":{"type":"t2c_text_before","inputs":{"TEXT":"%1","SUB":{"type":"code_expression"}}},"__4__stringBeforeTextFullExpression":{"type":"t2c_text_before","inputs":{"TEXT":"%1","SUB":{"type":"code_expression"}}},"__5__stringBeforeTextFullExpression":{"type":"t2c_text_before","inputs":{"TEXT":"%1","SUB":"%5"}},"__2__stringSubstringFullExpression":{"type":"t2c_text_getsubstring","inputs":{"STRING":"%1","AT1":{"type":"code_expression"},"AT2":{"type":"code_expression"}}},"__3__stringSubstringFullExpression":{"type":"t2c_text_getsubstring","inputs":{"STRING":"%1","AT1":{"type":"code_expression"},"AT2":{"type":"code_expression"}}},"__4__stringSubstringFullExpression":{"type":"t2c_text_getsubstring","inputs":{"STRING":"%1","AT1":{"type":"code_expression"},"AT2":{"type":"code_expression"}}},"__5__stringSubstringFullExpression":{"type":"t2c_text_getsubstring","inputs":{"STRING":"%1","AT1":"%5","AT2":{"type":"code_expression"}}},"__6__stringSubstringFullExpression":{"type":"t2c_text_getsubstring","inputs":{"STRING":"%1","AT1":"%5","AT2":{"type":"code_expression"}}},"__7__stringSubstringFullExpression":{"type":"t2c_text_getsubstring","inputs":{"STRING":"%1","AT1":"%5","AT2":{"type":"code_expression"}}},"__8__stringSubstringFullExpression":{"type":"t2c_text_getsubstring","inputs":{"STRING":"%1","AT1":"%5","AT2":{"type":"code_expression"}}},"__9__stringSubstringFullExpression":{"type":"t2c_text_getsubstring","inputs":{"STRING":"%1","AT1":"%5","AT2":{"type":"code_expression"}}},"__10__stringSubstringFullExpression":{"type":"t2c_text_getsubstring","inputs":{"STRING":"%1","AT1":"%5","AT2":"%10"}},"__2__py_stringSubstringFullExpression":{"type":"t2c_text_getsubstring","inputs":{"STRING":"%1","AT1":{"type":"code_expression"},"AT2":{"type":"code_expression"}}},"__3__py_stringSubstringFullExpression":{"type":"t2c_text_getsubstring","inputs":{"STRING":"%1","AT1":"%3","AT2":{"type":"code_expression"}}},"__4__py_stringSubstringFullExpression":{"type":"t2c_text_getsubstring","inputs":{"STRING":"%1","AT1":"%3","AT2":{"type":"code_expression"}}},"__5__py_stringSubstringFullExpression":{"type":"t2c_text_getsubstring","inputs":{"STRING":"%1","AT1":"%3","AT2":"%5"}},"__2__js_stringSubstringFullExpression":{"type":"js_text_getsubstring","inputs":{"STRING":"%1","AT1":{"type":"code_expression"},"AT2":{"type":"code_expression"}}},"__3__js_stringSubstringFullExpression":{"type":"js_text_getsubstring","inputs":{"STRING":"%1","AT1":{"type":"code_expression"},"AT2":{"type":"code_expression"}}},"__4__js_stringSubstringFullExpression":{"type":"js_text_getsubstring","inputs":{"STRING":"%1","AT1":{"type":"code_expression"},"AT2":{"type":"code_expression"}}},"__5__js_stringSubstringFullExpression":{"type":"js_text_getsubstring","inputs":{"STRING":"%1","AT1":"%5","AT2":{"type":"code_expression"}}},"__6__js_stringSubstringFullExpression":{"type":"js_text_getsubstring","inputs":{"STRING":"%1","AT1":"%5","AT2":{"type":"code_expression"}}},"__7__js_stringSubstringFullExpression":{"type":"js_text_getsubstring","inputs":{"STRING":"%1","AT1":"%5","AT2":"%7"}},"__2__stringFindFirstFullExpression":{"type":"t2c_text_indexof","inputs":{"VALUE":"%1","FIND":{"type":"code_expression"}}},"__3__stringFindFirstFullExpression":{"type":"t2c_text_indexof","inputs":{"VALUE":"%1","FIND":{"type":"code_expression"}}},"__4__stringFindFirstFullExpression":{"type":"t2c_text_indexof","inputs":{"VALUE":"%1","FIND":{"type":"code_expression"}}},"__5__stringFindFirstFullExpression":{"type":"t2c_text_indexof","inputs":{"VALUE":"%1","FIND":"%5"}},"__2__js_stringFindFirstFullExpression":{"type":"js_text_indexof","inputs":{"VALUE":"%1","FIND":{"type":"code_expression"}}},"__3__js_stringFindFirstFullExpression":{"type":"js_text_indexof","inputs":{"VALUE":"%1","FIND":{"type":"code_expression"}}},"__4__js_stringFindFirstFullExpression":{"type":"js_text_indexof","inputs":{"VALUE":"%1","FIND":{"type":"code_expression"}}},"__5__js_stringFindFirstFullExpression":{"type":"js_text_indexof","inputs":{"VALUE":"%1","FIND":"%5"}},"__2__stringExpLength":{"type":"t2c_text_length","inputs":{"VALUE":"%1"}},"__2__py_stringExpLength":{"type":"t2c_text_length","inputs":{"VALUE":{"type":"code_expression"}}},"__3__py_stringExpLength":{"type":"t2c_text_length","inputs":{"VALUE":"%3"}},"__2__js_ConsoleLogStatement":{"type":"js_text_print","inputs":{"TEXT":{"type":"code_expression"}}},"__3__js_ConsoleLogStatement":{"type":"js_text_print","inputs":{"TEXT":{"type":"code_expression"}}},"__4__js_ConsoleLogStatement":{"type":"js_text_print","inputs":{"TEXT":{"type":"code_expression"}}},"__5__js_ConsoleLogStatement":{"type":"js_text_print","inputs":{"TEXT":"%5"}},"__2__displayStatement":{"type":"text_print","inputs":{"TEXT":{"type":"code_expression"}}},"__3__displayStatement":{"type":"text_print","inputs":{"TEXT":"%3"}},"__2__variableAssignment":{"type":"variables_set","fields":{"VAR":"%2"},"inputs":{"VALUE":{"type":"code_expression"}}},"__3__variableAssignment":{"type":"variables_set","fields":{"VAR":"%2"},"inputs":{"VALUE":{"type":"code_expression"}}},"__2__variableAssignmentNoLet":{"type":"variables_set","fields":{"VAR":"%1"},"inputs":{"VALUE":{"type":"code_expression"}}}}')},function(e,t,n){n(5);var o=n(0);t.a=function(e,t){var n=!(arguments.length>2&&void 0!==arguments[2])||arguments[2],i=t.workspace,r=function e(t,n){var i;if(t&&t.type)return i=Object(o.e)(n,t.type),t.inputs&&Object.keys(t.inputs).forEach((function(r){Object(o.j)(i,r,e(t.inputs[r],n))})),t&&t.fields&&Object.keys(t.fields).forEach((function(e){Object(o.h)(i,t.fields[e],e)})),i;if(t&&Array.isArray(t.blocks)){for(var r=t.blocks.map((function(t){return e(t,n)})),a=0;a1&&void 0!==arguments[1]?arguments[1]:1;return e.rhsides.map((function(r){return"string"==typeof r?[new o.a(e.lhs,r)]:Object(i.a)(r.map((function(e){return t.convertToBlockParseTrees(e,n)}))).map((function(t){return new o.a(e.lhs,t)}))})).reduce((function(e,t){return e.concat(t)}),[]).slice(0,n)}}]),e}()},function(e,t,n){var o=n(2),i=n(5);t.a=function(){function e(t){_classCallCheck(this,e),this.interpretations_=t}return _createClass(e,[{key:"evaluate",value:function(e){if(null===e||e instanceof o.a){if(e){var t="string"==typeof e.rhs?[e.rhs.replace(/\"/g,"'")]:e.rhs.map(this.evaluate.bind(this)),n=this.interpretations_[e.lhs];if("string"==typeof n)return n;if(n){var r=new i.a(JSON.stringify(n));return r.args=t,r}return t[0]}return""}throw console.assert(null!==e&&!(e instanceof o.a),{msg:"Non-null is invalid root type",expectedType:o.a,actual:e}),new Error("Invalid root type")}}]),e}()},function(e,t,n){n.d(t,"a",(function(){return i})),n.d(t,"b",(function(){return r}));var o=n(0);function i(e){var t=e.workspace;"js_text_print"===e.type||"js_text_input"===e.type?Object(o.g)(e,Object(o.e)(t,e.type.substring(3)),!0):"js_text_indexof"===e.type||"js_text_charat"===e.type||"js_text_getsubstring"===e.type?Object(o.g)(e,Object(o.e)(t,e.type.replace("js","t2c")),!0):"text_length"===e.type&&Object(o.g)(e,Object(o.e)(t,"t2c_"+e.type),!0)}function r(e){var t=e.workspace;if("text_print"===e.type)Object(o.g)(e,Object(o.e)(t,"js_text_print"),!0);else if("text_input"===e.type)Object(o.g)(e,Object(o.e)(t,"js_text_input"),!0);else if("t2c_text_indexof"===e.type)Object(o.g)(e,Object(o.e)(t,"js_text_indexof"),!0);else if("t2c_text_charat"===e.type)Object(o.g)(e,Object(o.e)(t,"js_text_charat"),!0);else if("t2c_text_length"===e.type)Object(o.g)(e,Object(o.e)(t,"text_length"),!0);else if("t2c_text_getsubstring"===e.type)Object(o.g)(e,Object(o.e)(t,"js_text_getsubstring"),!0);else if("t2c_text_before"===e.type){var n=e.getInputTargetBlock("SUB"),i=e.getInputTargetBlock("TEXT"),r=null,a=Object(o.e)(t,"js_text_getsubstring"),l=Object(o.e)(t,"math_number"),s=Object(o.e)(t,"js_text_indexof");if(Object(o.h)(l,0,"NUM"),i)if("text"===i.type)r=Object(o.e)(t,i.type),Object(o.h)(r,i.getFieldValue("TEXT"),"TEXT"),s.getInput("VALUE").connection.connect(r.outputConnection),a.getInput("STRING").connection.connect(i.outputConnection);else if("variables_get"===i.type)r=Object(o.e)(t,i.type),Object(o.h)(r,i.getFieldValue("VAR"),"VAR"),s.getInput("VALUE").connection.connect(r.outputConnection),a.getInput("STRING").connection.connect(i.outputConnection);else{var u=createNewTempVariable(t),c=Object(o.e)(t,"variables_set");Object(o.h)(c,u,"VAR"),Object(o.j)(c,"VALUE",i);var g=Object(o.e)(t,"variables_get");Object(o.h)(g,u,"VAR");var d=copyBlock(g);if(Object(o.j)(s,"VALUE",d),Object(o.j)(a,"STRING",g),y=Object(o.c)(e)){var h=y.previousConnection.targetBlock();h&&c.previousConnection.connect(h.nextConnection),y.previousConnection.connect(c.nextConnection)}}n&&Object(o.j)(s,"FIND",n),Object(o.j)(a,"AT1",l),Object(o.j)(a,"AT2",s),e.outputConnection.targetConnection?e.outputConnection.targetConnection.connect(a.outputConnection):Object(o.d)(e,a),e.dispose()}else if("t2c_text_after"===e.type){e.getParent(),a=Object(o.e)(t,"js_text_getsubstring"),i=e.getInputTargetBlock("TEXT"),n=e.getInputTargetBlock("SUB"),s=Object(o.e)(t,"js_text_indexof");var p=Object(o.e)(t,"text_length"),f=Object(o.e)(t,"text_length"),m=Object(o.e)(t,"math_arithmetic_basic");if(Object(o.h)(m,"ADD","OP"),i){if("text"!==i.type&&"variables_get"!==i.type){var y,T=Object(o.e)(t,"variables_set");if(u=createNewTempVariable(t),Object(o.h)(T,u,"VAR"),Object(o.j)(T,"VALUE",i),y=Object(o.c)(e)){var _=y.previousConnection.targetBlock();_&&T.previousConnection.connect(_.nextConnection),y.previousConnection.connect(T.nextConnection)}i=Object(o.e)(t,"variables_get"),Object(o.h)(i,u,"VAR"),Object(o.j)(a,"STRING",i)}else Object(o.j)(a,"STRING",i);Object(o.j)(s,"VALUE",copyBlock(i)),Object(o.j)(p,"VALUE",copyBlock(i))}if(n){if("text"!==n.type&&"variables_get"!==n.type){var b=Object(o.e)(t,"variables_set"),k=createNewTempVariable(t);Object(o.h)(b,k,"VAR"),Object(o.j)(b,"VALUE",n);var x=Object(o.c)(e);if(x){var E=x.previousConnection.targetBlock();E&&b.previousConnection.connect(E.nextConnection),x.previousConnection.connect(b.nextConnection)}n=Object(o.e)(t,"variables_get"),Object(o.h)(n,k,"VAR")}if("variables_get"===n.type)Object(o.j)(m,"B",f),Object(o.j)(f,"VALUE",copyBlock(n));else{var B=Object(o.e)(t,"math_number");Object(o.h)(B,n.getFieldValue("TEXT").length,"NUM"),Object(o.j)(m,"B",B),f.dispose()}Object(o.j)(s,"FIND",n)}else Object(o.j)(m,"B",f);Object(o.j)(m,"A",s),Object(o.j)(a,"AT1",m),Object(o.j)(a,"AT2",p),e.outputConnection.targetConnection?e.outputConnection.targetConnection.connect(a.outputConnection):Object(o.d)(e,a),e.dispose()}}},function(e,t,n){var o=function(){function e(t){var n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:[];_classCallCheck(this,e),this.lhs_=t,this.rhsides_=n}return _createClass(e,[{key:"merge",value:function(e){var t,n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:1;console.assert(this.lhs_===e.lhs_,{msg:"This lhs of "+this.lhs_+" does not match node's lhs of "+e.lhs_}),this.rhsides_.lengtht.length?e:t}))}},{key:"getOppositeRules_",value:function(){var e=this,t={};return Object.keys(this.ruleSets_).forEach((function(n){Array.from(e.ruleSets_[n]).forEach((function(o){if(Array.isArray(o))if(1===o.length)e.addRule_(o[0],n,t);else{var i=n;o.slice(0,o.length-1).forEach((function(n,r){var a=o.length-r-1==1?o[0]:JSON.stringify(o.slice(0,o.length-r-1));e.addRule_(JSON.stringify([a,o[o.length-r-1]]),i,t),i=a}))}else e.addRule_(o,n,t)}))})),t}},{key:"getUnitRules_",value:function(e,t,n){for(var o=[],r=e,a=function(e){var n=[];r.forEach((function(e){t[e.rootLHS]&&Array.from(t[e.rootLHS]).filter((function(t){return t!==e.rootLHS})).forEach((function(t){return n.push(new i(t,[e]))}))})),o.push.apply(o,n),r=n},l=0;l0;l++)a();return o}},{key:"parseBottomUpCYK",value:function(e,t){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:"statement";if(""===e)return[];Object.values(this.ruleSets_).reduce((function(e,t){return e+t.size}),0);var o=this.lexer_.tokenize(e),a=this.maxPathLengthToTerminalOrSplit_("statement"),l=this.getOppositeRules_();console.warn("TOKEN ARRAY:",o,a.length);for(var s=[o.map((function(e){return Array.from(l[e.value]||[]).concat(e.tokenType).filter((function(e,t,n){return n.indexOf(e)===t})).map((function(t){return new i(t,e.value)}))}))],u=0;ul-a+1)return[];if("string"==typeof n&&t.isTerminal_(n)){if(a!==l)return[];var u=t.getRHSOfTokenMatch_(n,o[a]);return u?[{lhs:n,rhs:[u]}]:[]}if("string"==typeof n)return t.flattenOneLevel_(Array.from(t.ruleSets_[n]).map((function(t){var o=i.compute(e,[t,a,l,s-1],0);return o.some((function(e){return e.length!==t.length}))?(console.log("throwing out",n,JSON.stringify(o),t),console.log("problem",t,o,o.find((function(e){return e.length!==t.length}))),null):o.map((function(e){return{lhs:n,rhs:e}}))})).filter((function(e){return e})));if(n instanceof Array&&1===n.length){var c=i.compute(e,[n[0],a,l,s]);return c.length>0?c.map((function(e){return[e]})):[]}for(var g=[],d=a;d0){var p=i.compute(e,[n.slice(1),d+1,l,r.length]);p.length>0&&g.push.apply(g,_toConsumableArray(t.joinEachItemToFront_(h,p)))}}return g}),["statement",0,o.length-1,r.length]);return i.clear(),a}}]),e}()},function(e,t,n){var o=function(){function e(){_classCallCheck(this,e)}return _createClass(e,null,[{key:"interpolateMsg_",value:function(e,t){for(var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},o=e,i=0;/{[^}]+}/.test(o)&&i<5;)o=o.replace(/{[^}]+}/g,(function(e){var o=e.substring(1,e.length-1),i=o.split("."),r={T2C:T2C,options:n,feedbackItem:t}[i[0]];return r?i.slice(1).reduce((function(e,t){return e[t]}),r):null!=n[o]?n[o]:t[o]})),i++;return o}},{key:"getFeedback",value:function(t,n,o){var i={block:Blockly.Block,field:Blockly.Field},r=t.map((function(e){return{msgArr:[]}}));return n.forEach((function(n){var a=[];if("id"===n.selectType){var l=t.findIndex((function(e){return e.id===n.id}));-1!==l&&a.push({index:l,item:t[l]})}else if("expected"===n.selectType)t.forEach((function(e,o){(e.expected===n.expected||"function"==typeof n.expected&&n.expected(e.expected))&&a.push({index:o,item:t[o]})}));else if(Object.keys(i).includes(n.selectType)){var s=i[n.selectType];t.forEach((function(e,n){e.match instanceof s&&e.match.type&&a.push({index:n,item:t[n]})}))}if("error"===n.showType?a=a.filter((function(e){return e.item.hasError})):"correct"===n.showType&&(a=a.filter((function(e){return!e.item.hasError}))),"string"===n.outputType)a.forEach((function(i){return r[i.index].msgArr.push(e.interpolateMsg_(n.msg,t[i.index],o))}));else if("function"===n.outputType){var u=o[n.msg]||n.msg;"function"==typeof u&&a.forEach((function(e){return r[e.index].msgArr.push(u(t[e.index],t,o))}))}})),r}},{key:"displayFeedback",value:function(t,n,o){var i=e.getFeedback(t,n,o),r=t.map((function(e){return e.match||e.remaining})).map((function(e){return e instanceof Blockly.Block||!e?e:e.getSourceBlock&&e.getSourceBlock()})),a=[],l=[];r.forEach((function(e,n){if(e instanceof Blockly.Block){var o=a.indexOf(e);-1!==o?(l[o].indexArr.push(n),l[o].feedbackMsgArr.push(i[n].msgArr),l[o].hasCorrectItem=l[o].hasCorrectItem||!t[n].hasError,l[o].hasErrorItem=l[o].hasErrorItem||t[n].hasError,l[o].isMatchComplete=l[o].isMatchComplete&&t[n].isMatchComplete):(a.push(e),l.push({block:e,indexArr:[n],feedbackMsgArr:[i[n].msgArr],hasCorrectItem:!t[n].hasError,hasErrorItem:t[n].hasError,isMatchComplete:t[n].isMatchComplete}))}})),e.addFeedbackToBlocks(a,l.map((function(e){return e.feedbackMsgArr}))),l.forEach((function(t){var n=t.block;t.hasErrorItem&&!t.hasCorrectItem?e.setBlockFeedbackColour(n,!1):!t.hasErrorItem&&t.hasCorrectItem?e.setBlockFeedbackColour(n,!0,t.isMatchComplete):e.restoreBlockFeedbackColour(n)}))}},{key:"addFeedbackToBlocks",value:function(e,t){e.length>0&&e[0].workspace.getAllBlocks().forEach((function(t){e.includes(t)||(t.setCommentText(""),t.setCommentText(null),null!=t.startColour&&t.setColour(t.startColour))})),e.forEach((function(e,n){var o=t[n].map((function(e){return e.join("\n")})).join("\n\n");if(""!==o.trim()){e.setCommentText(o.trim());var i=e.getCommentIcon().getBubbleSize(),r=i.width,a=i.height;a=Math.max(a,Math.ceil(30*o.trim().length*8/r)),e.getCommentIcon().setBubbleSize(r,a)}else e.setCommentText("")}))}},{key:"restoreBlockFeedbackColour",value:function(e){null!=e.startColour&&e.setColour(e.startColour)}},{key:"setBlockFeedbackColour",value:function(t,n){var o=arguments.length>2&&void 0!==arguments[2]&&arguments[2];t instanceof Blockly.Block&&(t.getCommentText()&&t.getCommentText().trim()||o?(null==t.startColour&&(t.startColour=t.getColour()),n?t.setColour("#080"):t.setColour("#800")):e.restoreBlockFeedbackColour(t))}}]),e}();t.a=o},,,,,,,,,function(e,t,n){n.r(t);var o=n(1),i=n(0),r=function(){function e(t,n){_classCallCheck(this,e),this.taskCondition_=t,this.directions_=n}return _createClass(e,[{key:"areDirectionsCompleted",value:function(){return this.directions_.isComplete()}},{key:"startDirections",value:function(){this.directions_.start()}},{key:"finish",value:function(){this.directions_.finish instanceof Function&&this.directions_.finish()}},{key:"showDirectionStep",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:1;this.directions_.animate(e)}},{key:"isTaskCompleted",value:function(){return this.taskCondition_()}}]),e}(),a=function(){function e(t,n){_classCallCheck(this,e),this.obj_=t,this.options_=n}return _createClass(e,[{key:"start",value:function(){this.numOfMoves_=0,this.totalSteps_=this.value_(this.options_.totalSteps),this.startPosition_=this.value_(this.options_.startPosition),this.endPosition_=this.value_(this.options_.endPosition)||{x:this.startPosition_.x+this.value_(this.options_.velocity).x*this.totalSteps_,y:this.startPosition_.y+this.value_(this.options_.velocity).y*this.totalSteps_},this.velocity_={x:(this.endPosition_.x-this.startPosition_.x)/this.totalSteps_,y:(this.endPosition_.y-this.startPosition_.y)/this.totalSteps_},this.obj_.style.left=this.startPosition_.x+"px",this.obj_.style.top=this.startPosition_.y+"px"}},{key:"isComplete",value:function(){return this.numOfMoves_>=this.totalSteps_}},{key:"finish",value:function(){this.options_.finish instanceof Function&&this.options_.finish()}},{key:"animate",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:1,t=Math.min(e,this.totalSteps_-this.numOfMoves_);this.obj_.style.left=parseFloat(this.obj_.style.left)+this.velocity_.x*t+"px",this.obj_.style.top=parseFloat(this.obj_.style.top)+this.velocity_.y*t+"px",this.numOfMoves_+=e}},{key:"value_",value:function(e){return e instanceof Function?e():e}}]),e}(),l=function(){function e(t,n){_classCallCheck(this,e),this.obj_=t,this.options_=n,this.container_=this.options_.container||document.body}return _createClass(e,[{key:"start",value:function(){this.numOfSteps_=0,this.totalSteps_=this.value_(this.options_.totalSteps),this.startPosition_=this.value_(this.options_.startPosition),this.toggleSteps_=this.value_(this.options_.toggleSteps),this.options_.addAtStart&&this.container_.appendChild(this.obj_),this.obj_.style.left=this.startPosition_.x+"px",this.obj_.style.top=this.startPosition_.y+"px"}},{key:"isComplete",value:function(){return this.numOfSteps_>=this.totalSteps_}},{key:"animate",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:1,t=Math.min(e,this.totalSteps_-this.numOfSteps_);this.obj_.style.display=this.numOfSteps_%(2*this.toggleSteps_)0&&void 0!==arguments[0]?arguments[0]:1;this.animations_.filter((function(e){return!e.isComplete()})).forEach((function(t){return t.animate(e)}))}}]),e}(),c=function(){function e(){_classCallCheck(this,e),this.tasks_=[]}return _createClass(e,[{key:"addTask",value:function(e){this.tasks_.push(e)}},{key:"runTasks",value:function(e,t){var n=this;this.tasks_.length;var o=0,i=null!=e?e+","+t:null,r=i?localStorage.getItem(i):0;r&&confirm("Would you like to resume from the task you last completed?")&&(o=Math.max(parseInt(r),0));var a=0;this.tasks_[o].startDirections();requestAnimationFrame((function e(t){t-a>=5&&(n.tasks_[o].areDirectionsCompleted()||n.tasks_[o].isTaskCompleted()?n.tasks_[o].isTaskCompleted()&&(n.tasks_[o].finish(),++o2&&void 0!==arguments[2]?arguments[2]:0,o=this.tabs_.filter((function(t){return t.title===e}))[n];return o&&(console.log("Changing tab ",o,"with title",e,"#",n),o.display.innerText=e,o.message=t,console.log("Tab is now",o)),!!o}},{key:"changeTab",value:function(e,t,n){var o=this.tabs_.find((function(t){return t.id===e}));return o&&(console.log("Changing tab",o,"with id",e),o.title=t,o.display.innerText=t,o.message=n,console.log("Tab is now",o)),!!o}},{key:"setSelectedTab",value:function(e){var t=this.tabs_.find((function(t){return t.id===e}));return console.log("Setting tab to",t),t&&(this.currentTab_&&(this.currentTab_.display.style.backgroundColor="rgba(200, 200, 200, 0.5)",this.currentTab_.display.style.removeProperty("font-weight")),t.display.style.backgroundColor="rgba(127, 122, 110, 0.5)",t.display.style.fontWeight="bold",t.display.innerText=t.title,this.currentTab_=t),!!t}},{key:"start",value:function(){document.getElementById("message_console_manager_container")?this.show():document.body.appendChild(this.container_),this.started_=!0}},{key:"show",value:function(){this.container_.style.display="block"}},{key:"hide",value:function(){this.container_.style.display="none"}},{key:"isComplete",value:function(){return!1}},{key:"finish",value:function(){var e=this;this.tabs_.map((function(e){return e.display})).forEach((function(t){return e.tabContainer_.removeChild(t)})),this.container_.removeChild(this.msgDisplay_),this.container_.removeChild(this.tabContainer_),this.providedContainer_||document.body.removeChild(this.container_),"function"==typeof this.options_.finish&&this.options_.finish()}},{key:"animate",value:function(){var e=this,t=this.tabs_.map((function(t){return e.value_(t.message)}));this.tabs_.filter((function(n,o){return e.currentTab_!==n&&t[o]&&n.currentMessage!==t[o]&&!n.display.innerText.trim().endsWith("*")})).forEach((function(e){return e.display.innerText+="*"})),this.tabs_.forEach((function(e,n){return e.currentMessage=t[n]})),this.msgDisplay_.innerText=this.currentTab_.currentMessage}},{key:"value_",value:function(e){return e instanceof Function?e():e}}]),e}(),d=function(){function e(t){var n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};_classCallCheck(this,e),this.blockName_=t,this.possibleMatches_=[],this.possibleErrorFunctions_=[],this.currentExp_="",this.hasUnknownError_=!1,this.options_=n,this.standardErrorMessages={EXTRA_AT_END:function(e,t,n){return T2C.MSG.currentLanguage.TYPEIN_ERROR_REMOVE_EXTRA_AT_END.replace("%1",n)},MISTYPED_TERMINAL:function(e,t,n){return T2C.MSG.currentLanguage.TYPEIN_ERROR_TERMINAL_MISTYPED.replace("%1",T2C.MSG.currentLanguage["TERMINAL_"+e.toUpperCase()]||e)},MISSING_OPEN_PARENTHESIS:function(e,t,n){return T2C.MSG.currentLanguage.TYPEIN_ERROR_MISSING_OPEN_PARENTHESIS.replace("%1",t[e])},MISSING_OPEN_BRACKET:function(e,t,n){return T2C.MSG.currentLanguage.TYPEIN_ERROR_MISSING_OPEN_BRACKET.replace("%1",t[e])},MISSING_CLOSE_PARENTHESIS:function(e,t,n){return T2C.MSG.currentLanguage.TYPEIN_ERROR_MISSING_CLOSE_PARENTHESIS.replace("%1",t[e])},MISSING_CLOSE_BRACKET:function(e,t,n){return T2C.MSG.currentLanguage.TYPEIN_ERROR_MISSING_CLOSE_BRACKET.replace("%1",t[e])},MISSING_PERIOD_AFTER_VARIABLE:function(e,t,n){return T2C.MSG.currentLanguage.TYPEIN_ERROR_MISSING_PERIOD_AFTER_VARIABLE.replace("%1",t[e])},UNNECESSARY_OPEN_PARENTHESIS:function(e,t,n){return T2C.MSG.currentLanguage.TYPEIN_WARNING_UNNECESSARY_OPEN_PARENTHESIS.replace("%1",t[e])},UNKNOWN:function(e,t,n){return T2C.MSG.currentLanguage.TYPEIN_UNKNOWN_ERROR.replace("%1",t[e])}}}return _createClass(e,[{key:"oneStartsWithOther_",value:function(e,t){var n=arguments.length>2&&void 0!==arguments[2]&&arguments[2],o=n?e:e.toLowerCase(),i=n?t:t.toLowerCase();return o.startsWith(i)||i.startsWith(o)}},{key:"getAfterTerminal_",value:function(e,t){var n=this;String.prototype.JSSubstring=function(e,t){return e>=this.length||e===t?"":this.substring(e,t)};var o=Object.values(T2C.MSG).map((function(e){return e["TERMINAL_"+t.toUpperCase()]})).filter((function(e){return"string"==typeof e})).find((function(t){return n.oneStartsWithOther_(t,e,!0)}));if("string"==typeof o)return{terminal:o,remaining:e.JSSubstring(o.length).trim()}}},{key:"getTerminalIndexForSymbol_",value:function(e,t){if(-1!==["[","(","."].indexOf(e[t]))return t-1;if(-1!==[")","]"].indexOf(e[t])){for(var n=[],o=0;o1&&void 0!==arguments[1])||arguments[1],n=document.getElementById("alert-display");n||((n=document.createElement("div")).id="alert-display",n.style.fontSize="small",n.style.fontWeight="bold",n.style.borderColor="#000",n.style.backgroundColor="rgba(200, 200, 200, 0.5)",n.style.color="#f00",n.style.position="absolute",n.style.zIndex="1050",n.style.width="98%",n.style.minHeight="50px",n.style.left="0",n.style.bottom="0",n.style.textAlign="left",n.style.padding="1%",document.body.appendChild(n)),t?n.innerText=e:n.innerText+=e}},{key:"matchStatement_",value:function(e,t){for(var n=void 0,o=void 0,i=[],r=e,a=!1,l=-1;l1&&void 0!==arguments[1])||arguments[1];return(n&&this.possibleMatches_||this.addNoExtraMatches_()).find((function(n){var o=t.matchStatement_(e,n),i=o.match;o.error,o.remainingText;return o.isMatchComplete&&n.length===i.length}))}},{key:"generateErrorFunction",value:function(e,t,n){var o=this,i=t[n];if(e instanceof Function)return e;if("string"==typeof e)return function(){return e};if(e&&"GENERIC_MESSAGE"===e.type)return e.args=Array.isArray(e.args)?e.args:[],function(t,n){var i;return(i=o.standardErrorMessages)[e.value].apply(i,_toConsumableArray(e.args).concat([t,n]))};var r="UNKNOWN",a=[];if(i&&"string"==typeof i){var l=["(","[",")","]","."].indexOf(i);-1!==l&&(r=["MISSING_OPEN_PARENTHESIS","MISSING_OPEN_BRACKET","MISSING_CLOSE_PARENTHESIS","MISSING_CLOSE_BRACKET","MISSING_PERIOD_AFTER_VARIABLE"][l],a.push(this.getTerminalIndexForSymbol_(t,n)))}return(i.type&&"TERMINAL"===i.type.toUpperCase()||this.equalsTerminal_(i))&&(r="MISTYPED_TERMINAL",a.push(i.type?i.token:i)),function(e,t){var n;return"UNKNOWN"===r&&i&&"string"==typeof i&&!i.startsWith("(")&&t.startsWith("(")&&(r="UNNECESSARY_OPEN_PARENTHESIS"),(n=o.standardErrorMessages)[r].apply(n,a.concat([e,t]))}}},{key:"equalsTerminal_",value:function(e){return Object.values(T2C.MSG).find((function(t){return Object.keys(t).find((function(n){return n.toUpperCase().startsWith("TERMINAL_")&&t[n]===e}))}))}},{key:"setCurrentExp",value:function(e){this.currentExp_=e}},{key:"addPossibleMatch",value:function(e,t){var n=this;this.possibleMatches_.push(e),this.possibleErrorFunctions_.push(t.map((function(t,o){return n.generateErrorFunction(t,e,o)})))}},{key:"addAllPossibleLanguageMatches",value:function(e,t){var n=this;Object.values(T2C.MSG).map((function(t){return e.map((function(e){return e&&"terminal"===e.type?"string"==typeof t["TERMINAL_"+e.token.toUpperCase()]?t["TERMINAL_"+e.token.toUpperCase()]:e.token:e}))})).forEach((function(e){n.addPossibleMatch(e,t)}))}},{key:"addNoExtraMatches_",value:function(e){return(e=e||this.possibleMatches_).map((function(e){return e.concat({type:"regexp",token:/^$/})}))}},{key:"addNoExtraErrorMessages_",value:function(e){var t=this;return(e=e||this.possibleErrorFunctions_).map((function(e){return e.concat((function(e,n){return t.standardErrorMessages.EXTRA_AT_END("",e,n)}))}))}},{key:"getErrorFeedback",value:function(e){var t=this;e="string"==typeof e?e:this.currentExp_;var n=this.addNoExtraMatches_().reduce((function(e,n,o){var i=t.matchStatement_(t.currentExp_,n);return i.pattern=n,i.index=o,i.error&&!e.error?e:!i.error&&e.error||0===e.pattern.length||i.match.filter((function(e){return e})).length>e.match.filter((function(e){return e})).length?i:e}),{pattern:[],match:[],error:!0,remainingText:this.currentExp_,index:-1});return n.error?this.addNoExtraErrorMessages_()[n.index][n.match.length](n.match,n.remainingText):this.hasUnknownError_?T2C.MSG.currentLanguage.TYPEIN_UNKNOWN_ERROR:""}},{key:"getCodeGeneratorForLanguage",value:function(e,t){var n=this;return function(o){for(var i=o.getFieldValue("EXP"),r=0,a=function(){var o=T2C.MSG[e],a=n.possibleMatches_[r],l=n.matchStatement_(i,a),s=l.match,u=(l.error,l.remainingText),c=l.isMatchComplete;if(a.length===s.length&&!u&&c){var g=s.map((function(e,t){var i=a[t];if(i&&"terminal"===i.type)return"string"==typeof o["TERMINAL_"+i.token.toUpperCase()]?o["TERMINAL_"+i.token.toUpperCase()]:i.token;if("string"==typeof i&&n.equalsTerminal_(i)){var r=n.equalsTerminal_(i),l=Object.keys(r).find((function(e){return e.toUpperCase().startsWith("TERMINAL_")&&r[e]===i}));return l?o[l]:i}return e})).join("");return{v:t?(g.endsWith(T2C.MSG[e].STATEMENT_SEPARATOR)?g:g+T2C.MSG[e].STATEMENT_SEPARATOR)+"\n":[g,Blockly[T2C.MSG[e].LANGUAGENAME].ORDER_NONE]}}++r};r0&&void 0!==arguments[0]?arguments[0]:{},t=this;Blockly.Python[this.blockName_]=this.getCodeGeneratorForLanguage("PY",!e.isExpression),Blockly.JavaScript[this.blockName_]=this.getCodeGeneratorForLanguage("JS",!e.isExpression),Blockly.Blocks[this.blockName_]={validate:function(e){var n=this.getSourceBlock(),o=t.possibleMatches_.reduce((function(n,o,i){var r=t.matchStatement_(e,o);return r.pattern=o,r.index=i,r.error&&!n.error?n:!r.error&&n.error||0===n.pattern.length||r.match.filter((function(e){return e})).length>n.match.filter((function(e){return e})).length?r:n}),{pattern:[],match:[],error:!0,remainingText:e,index:-1});if(t.setCurrentExp(e),o.error)console.log("ERROR",o),n.setColour("#800");else{if(!t.hasFullMatch(e,!1))return n.setColour(60),e;n.setColour("#080")}return o.error?o.match.join(""):e},init:function(){var n=this;this.appendDummyInput("STRING").appendField(new Blockly.FieldTextInput("",this.validate),"EXP"),this.setInputsInline(!1),this.setOutput(e.isExpression),this.setPreviousStatement(!e.isExpression),this.setNextStatement(!e.isExpression),this.setColour(60),this.setTooltip(T2C.MSG.currentLanguage.TYPEIN_STATEMENT_TOOLTIP),this.onchange=function(e){var i=n.getFieldValue("EXP"),r=t.hasFullMatch(i,!1);if(Blockly.selected!==n&&(t.setCurrentExp(i),n.setColour(r?"#080":60)),t.hasUnknownError_=!1,i.length>0&&"workspaceClick"===e.element&&r){if(t.options_.collapseWhenFinished)return n.setCollapsed(!0);var a=Object(o.getParseTree)(n.getFieldValue("EXP"));a?Object(o.handleParseTreeToBlocks)(a,n):t.hasUnknownError_=!0}}}}}}]),e}(),h=n(3),p=function(){function e(t){_classCallCheck(this,e),this.state_={},this.courseInstructionTaskFlow_=t}return _createClass(e,[{key:"loadLevelTasks",value:function(e,t){var n=e||new c,o=t||Blockly.getMainWorkspace();return new ToolboxManager(o),this.helpMsgManager_.start(),n}},{key:"createStandardHelpMessageManager",value:function(){var e=new g;return e.addTab(T2C.MSG.currentLanguage.DIRECTIONS,""),e.addTab(T2C.MSG.currentLanguage.FEEDBACK,""),e}},{key:"createHelpMessageDirections",value:function(e,t,n,o){return{start:function(){var o=e.getTabIdByTitle(T2C.MSG.currentLanguage.DIRECTIONS);e.setTabHandlerByTitle(T2C.MSG.currentLanguage.DIRECTIONS,t),e.setTabHandlerByTitle(T2C.MSG.currentLanguage.FEEDBACK,n),e.start(),e.setSelectedTab(o)},isComplete:function(){return!1},animate:function(t){return e.animate(t)},finish:function(){"function"==typeof o&&o()}}}},{key:"createHelpMessageTask",value:function(e,t,n,o,i){return new r("function"==typeof t?t:function(){return!0},this.createHelpMessageDirections(e,n,o,i))}},{key:"hideOutputAndCodeContainers",value:function(){document.getElementById("output-container").classList.remove("show-container"),document.getElementById("output-container").classList.add("hide-container"),document.getElementById("text-code-container").classList.remove("show-container"),document.getElementById("text-code-container").classList.add("hide-container")}},{key:"addHelpMessageTask",value:function(e,t,n,o,i,r){e.addTask(this.createHelpMessageTask(t,n,o,i,r))}},{key:"addMoveAndFlashTask",value:function(e,t,n){var o=this,i=0;function a(){t.style.color=i%50<25?"#a00":"#000",++i<200&&requestAnimationFrame(a)}e.addTask(new r((function(){return i>=200}),{start:function(){t.style.verticalAlign="top",requestAnimationFrame(a)},isComplete:function(){return!0},animate:function(){return!0},finish:function(){"function"==typeof n&&n(),function(e){e.style.verticalAlign="middle",e.style.color="#000"}(t),o.hideOutputAndCodeContainers()}}))}},{key:"createPointer",value:function(){var e=document.createElement("div");return e.innerText="👆",e.id="ptr",e.style.fontSize="x-large",e.style.position="absolute",e.style.zIndex="1001",e}},{key:"setMaxesFromWorkspace",value:function(e){var t=e.options.maxInstances;e.options.maxInstances={},e.getAllBlocks().forEach((function(t){e.options.maxInstances[t.type]=++e.options.maxInstances[t.type]||1})),Object.keys(t).forEach((function(n){e.options.maxInstances[n]=e.options.maxInstances[n]||t[n]}))}},{key:"addRunTask",value:function(e,t,n,o){var i=!(arguments.length>4&&void 0!==arguments[4])||arguments[4];t.addTask(new r((function(){return document.getElementById("output-container").classList.contains("show-container")}),new u([this.createHelpMessageDirections(e,T2C.MSG.currentLanguage.BUTTON_RUN_CODE,""),new l(o||this.createPointer(),{totalSteps:100,toggleSteps:25,startPosition:{x:document.getElementById("run-code-button").offsetLeft+document.getElementById("run-code-button").offsetWidth/2,y:document.getElementById("run-code-button").offsetTop+document.getElementById("run-code-button").offsetHeight/2},container:document.getElementById("blockly-div"),addAtStart:!o,removeAtEnd:!o})]))),i&&this.addMoveAndFlashTask(t,document.getElementById("output-container").querySelectorAll(".table-cell")[0],n)}},{key:"addDeleteAllBlocksTask",value:function(e,t,n,o,i){t.addTask(new r((function(){return 0===n.getAllBlocks().length}),new u([this.createHelpMessageDirections(e,(function(){return"Move all blocks to the trashcan or rightmouse click (hold down finger on phone) on an empty place in the workspace and select Delete."}),""),new l(i||this.createPointer(),{totalSteps:100,toggleSteps:25,startPosition:function(){var e=n.trashcan.getClientRect();return{x:(e.left+e.right)/2,y:(e.top+e.bottom)/2}}})])))}},{key:"addLoadSaveListeners_",value:function(e){var t=this,n=arguments.length>1&&void 0!==arguments[1]&&arguments[1];n&&(this.state_.clickedLoadButtonLast=!1,this.state_.clickedSaveButtonLast=!1,this.state_.clickedLoadXMLButtonLast=!1,this.state_.clickedSaveXMLButtonLast=!1,this.state_.clickedLoadTextCodeButtonLast=!1,this.state_.clickedSaveTextCodeButtonLast=!1,this.state_.generatedTextCode=Object(o.workspaceToLanguageCode)(e,T2C.MSG.currentLanguage),this.state_.generatedXMLText=Object(o.workspaceToXML)(e)),this.state_.listeners=[{id:"load-code-button",listener:function(){t.state_.clickedLoadButtonLast=!0,t.state_.clickedSaveButtonLast=!1,t.state_.clickedLoadXMLButtonLast=!1,t.state_.clickedSaveXMLButtonLast=!1,t.state_.clickedLoadTextCodeButtonLast=!1,t.state_.clickedSaveTextCodeButtonLast=!1}},{id:"save-code-button",listener:function(){t.state_.clickedLoadButtonLast=!1,t.state_.clickedSaveButtonLast=!0,t.state_.clickedLoadXMLButtonLast=!1,t.state_.clickedSaveXMLButtonLast=!1,t.state_.clickedLoadTextCodeButtonLast=!1,t.state_.clickedSaveTextCodeButtonLast=!1}},{id:"load-save-text-code",listener:function(){t.state_.clickedLoadButtonLast?t.state_.clickedLoadTextCodeButtonLast=!0:t.state_.generatedTextCode.replace(/\s/g,"")!==document.getElementById("textCodeBox").value.replace(/\s/g,"")?alert("Workspace or selected language changed, please restore what you originally had before saving"):t.state_.clickedSaveTextCodeButtonLast=!0}},{id:"load-save-xml",listener:function(){t.state_.clickedLoadButtonLast?t.state_.clickedLoadXMLButtonLast=!0:t.state_.generatedTextCode.replace(/\s/g,"")!==document.getElementById("textCodeBox").value.replace(/\s/g,"")?alert("Workspace or selected language changed, please restore what you originally had before saving"):(t.state_.generatedXMLText=Object(o.workspaceToXML)(e),t.state_.clickedSaveXMLButtonLast=!0)}}],this.state_.listeners.forEach((function(e){return document.getElementById(e.id).addEventListener("click",e.listener)}))}},{key:"removeLoadSaveListeners_",value:function(){return this.state_.listeners.forEach((function(e){return document.getElementById(e.id).removeEventListener("click",e.listener)})),!0}},{key:"createAddSaveListenersDirections_",value:function(e){var t=this,n=arguments.length>1&&void 0!==arguments[1]&&arguments[1];return{start:function(){t.addLoadSaveListeners_(e,n)},isComplete:function(){return!0},animate:function(){return!0}}}},{key:"addSaveXMLTask",value:function(e,t,n,o,i,a){var s=this;t.addTask(new r((function(){return s.state_.clickedSaveButtonLast}),new u([this.createAddSaveListenersDirections_(n,a),this.createHelpMessageDirections(e,(function(){return T2C.MSG.currentLanguage.BUTTON_SAVE_XML}),""),new l(i||this.createPointer(),{totalSteps:100,toggleSteps:25,startPosition:{x:document.getElementById("save-code-button").offsetLeft+document.getElementById("save-code-button").offsetWidth/2,y:document.getElementById("save-code-button").offsetTop+document.getElementById("save-code-button").offsetHeight/2},container:document.getElementById("blockly-div"),addAtStart:!i,removeAtEnd:!i})]))),t.addTask(new r((function(){return s.state_.clickedSaveXMLButtonLast&&s.removeLoadSaveListeners_()}),new u([this.createHelpMessageDirections(e,(function(){return T2C.MSG.currentLanguage.BUTTON_SAVE_XML}),""),new l(i||this.createPointer(),{totalSteps:100,toggleSteps:25,startPosition:function(){return{x:document.getElementById("load-save-xml").offsetLeft+document.getElementById("load-save-xml").offsetWidth/2,y:document.getElementById("load-save-xml").offsetTop+document.getElementById("load-save-xml").offsetHeight/2}},container:document.getElementById("blockly-div"),addAtStart:!i,removeAtEnd:!i})])))}},{key:"addLoadXMLTask",value:function(e,t,n,o,i,a){var s=this;t.addTask(new r((function(){return s.state_.clickedLoadButtonLast}),new u([this.createAddSaveListenersDirections_(n,a),this.createHelpMessageDirections(e,(function(){return T2C.MSG.currentLanguage.BUTTON_LOAD_XML}),""),new l(i||this.createPointer(),{totalSteps:100,toggleSteps:25,startPosition:{x:document.getElementById("load-code-button").offsetLeft+document.getElementById("load-code-button").offsetWidth/2,y:document.getElementById("load-code-button").offsetTop+document.getElementById("load-code-button").offsetHeight/2},container:document.getElementById("blockly-div"),addAtStart:!i,removeAtEnd:!i})]))),t.addTask(new r((function(){return s.state_.generatedXMLText.replace(/\n|\r/g,"")===document.getElementById("xmlData").value.replace(/\n|\r/g,"")}),new u([this.createHelpMessageDirections(e,(function(){return"Paste the XML you copied in this text box."}),""),new l(i||this.createPointer(),{totalSteps:100,toggleSteps:25,startPosition:function(){return{x:document.getElementById("xmlData").offsetLeft+document.getElementById("xmlData").offsetWidth/2,y:document.getElementById("xmlData").offsetTop+document.getElementById("xmlData").offsetHeight/2}},container:document.getElementById("blockly-div"),addAtStart:!i,removeAtEnd:!i})]))),t.addTask(new r((function(){return s.state_.generatedXMLText.replace(/\n|\r/g,"")===document.getElementById("xmlData").value.replace(/\n|\r/g,"")&&s.state_.clickedLoadXMLButtonLast&&s.removeLoadSaveListeners_()}),new u([this.createHelpMessageDirections(e,(function(){return T2C.MSG.currentLanguage.BUTTON_LOAD_XML}),""),new l(i||this.createPointer(),{totalSteps:100,toggleSteps:25,startPosition:function(){return{x:document.getElementById("load-save-xml").offsetLeft+document.getElementById("load-save-xml").offsetWidth/2,y:document.getElementById("load-save-xml").offsetTop+document.getElementById("load-save-xml").offsetHeight/2}},container:document.getElementById("blockly-div"),addAtStart:!i,removeAtEnd:!i})])))}},{key:"addSaveTextCodeTask",value:function(e,t,n,o,i,a){var s=this;t.addTask(new r((function(){return s.state_.clickedSaveButtonLast}),new u([this.createAddSaveListenersDirections_(n,a),this.createHelpMessageDirections(e,(function(){return T2C.MSG.currentLanguage.BUTTON_SAVE_TEXT_CODE}),""),new l(i||this.createPointer(),{totalSteps:100,toggleSteps:25,startPosition:{x:document.getElementById("save-code-button").offsetLeft+document.getElementById("save-code-button").offsetWidth/2,y:document.getElementById("save-code-button").offsetTop+document.getElementById("save-code-button").offsetHeight/2},container:document.getElementById("blockly-div"),addAtStart:!i,removeAtEnd:!i})]))),t.addTask(new r((function(){return s.state_.clickedSaveTextCodeButtonLast&&s.removeLoadSaveListeners_()}),new u([this.createHelpMessageDirections(e,(function(){return T2C.MSG.currentLanguage.BUTTON_SAVE_TEXT_CODE}),""),new l(i||this.createPointer(),{totalSteps:100,toggleSteps:25,startPosition:function(){return{x:document.getElementById("load-save-text-code").offsetLeft+document.getElementById("load-save-text-code").offsetWidth/2,y:document.getElementById("load-save-text-code").offsetTop+document.getElementById("load-save-text-code").offsetHeight/2}},container:document.getElementById("blockly-div"),addAtStart:!i,removeAtEnd:!i})])))}},{key:"addLoadTextCodeTask",value:function(e,t,n,o,i,a){var s=this;t.addTask(new r((function(){return s.state_.clickedLoadButtonLast}),new u([this.createAddSaveListenersDirections_(n,a),this.createHelpMessageDirections(e,(function(){return T2C.MSG.currentLanguage.BUTTON_LOAD_TEXT_CODE}),""),new l(i||this.createPointer(),{totalSteps:100,toggleSteps:25,startPosition:{x:document.getElementById("load-code-button").offsetLeft+document.getElementById("load-code-button").offsetWidth/2,y:document.getElementById("load-code-button").offsetTop+document.getElementById("load-code-button").offsetHeight/2},container:document.getElementById("blockly-div"),addAtStart:!i,removeAtEnd:!i})]))),t.addTask(new r((function(){return s.state_.generatedTextCode.replace(/\n|\r/g,"")===document.getElementById("textCodeBox").value.replace(/\n|\r/g,"")}),new u([this.createHelpMessageDirections(e,(function(){return"Paste the code you copied in this text box."}),""),new l(i||this.createPointer(),{totalSteps:100,toggleSteps:25,startPosition:function(){return{x:document.getElementById("textCodeBox").offsetLeft+document.getElementById("textCodeBox").offsetWidth/2,y:document.getElementById("textCodeBox").offsetTop+document.getElementById("textCodeBox").offsetHeight/2}},container:document.getElementById("blockly-div"),addAtStart:!i,removeAtEnd:!i})]))),t.addTask(new r((function(){return s.state_.generatedTextCode.replace(/\n|\r/g,"")===document.getElementById("textCodeBox").value.replace(/\n|\r/g,"")&&s.state_.clickedLoadTextCodeButtonLast&&s.removeLoadSaveListeners_()}),new u([this.createHelpMessageDirections(e,(function(){return T2C.MSG.currentLanguage.BUTTON_LOAD_TEXT_CODE}),""),new l(i||this.createPointer(),{totalSteps:100,toggleSteps:25,startPosition:function(){return{x:document.getElementById("load-save-text-code").offsetLeft+document.getElementById("load-save-text-code").offsetWidth/2,y:document.getElementById("load-save-text-code").offsetTop+document.getElementById("load-save-text-code").offsetHeight/2}},container:document.getElementById("blockly-div"),addAtStart:!i,removeAtEnd:!i})])))}},{key:"mainCourseInstructionTaskFlow",set:function(e){this.courseInstructionTaskFlow_=e}}]),e}(),f=function(){function e(t){_classCallCheck(this,e),this.workspace_=t||Blocky.getMainWorkspace(),this.toolboxBlocks_=[],this.toolBoxDOM_=document.getElementById("toolbox")}return _createClass(e,[{key:"createBlockWithType_",value:function(e){var t=document.createElement("block");return t.setAttribute("type",e),t}},{key:"clearToolbox",value:function(){Array.from(this.toolBoxDOM_.children).forEach((function(e){return e.remove()})),this.workspace_.options.maxInstances={},this.workspace_.updateToolbox(document.getElementById("toolbox")),this.toolboxBlocks_=[]}},{key:"createToolboxBlock",value:function(e){var t=!(arguments.length>1&&void 0!==arguments[1])||arguments[1],n=this.createBlockWithType_(e);return t?(document.getElementById("toolbox").prepend(n),this.toolboxBlocks_.unshift(n)):(document.getElementById("toolbox").append(n),this.toolboxBlocks_.push(n)),this.workspace_.updateToolbox(document.getElementById("toolbox")),n}},{key:"setToolboxBlockFieldValue",value:function(e,t,n){var o=document.createElement("field");o.setAttribute("name",t),o.appendChild(document.createTextNode(n)),e.appendChild(o)}},{key:"setToolboxBlockInputValue",value:function(e,t,n){var o=document.createElement("value");o.setAttribute("name",t),o.appendChild(n),e.appendChild(o)}},{key:"removeToolboxBlocks",value:function(e){var t=this,n=this.toolboxBlocks_.map(e),o=this.toolboxBlocks_.filter(e);return n.forEach((function(e,n){e&&t.toolboxBlocks_[n].remove()})),this.toolboxBlocks_=this.toolboxBlocks_.filter((function(e,t){return!n[t]})),this.workspace_.updateToolbox(document.getElementById("toolbox")),console.log("Removing blocks",o),o}},{key:"removeToolboxBlocksWithType",value:function(e){return this.removeToolboxBlocks((function(t){return t.getAttribute("type")===e}))}},{key:"findToolboxBlock",value:function(e){return this.toolboxBlocks_.find(e)}},{key:"findToolboxBlockWithType",value:function(e){return this.findToolboxBlock((function(t){return t.getAttribute("type")===e}))}}]),e}(),m=n(14),y=function(){function e(){_classCallCheck(this,e)}return _createClass(e,null,[{key:"createBlock",value:function(e,t,n,o){var i={},r=Blockly.Blocks.code_statement_hybrid;return Object.keys(r).forEach((function(e){i[e]=r[e]})),i.init=function(){r.init.call(this),this.onchange,this.setMatchBlueprint(t),n&&this.setTextFeedbackManager(n),o&&this.setBlockFeedbackManager(o),["Python","JavaScript"].forEach((function(t){return Blockly[t][e]=Blockly[t].code_statement_hybrid}))},Blockly.Blocks[e]=i}}]),e}();function T(e,t){var n={};return Object.keys(e).forEach((function(t){return n[t]=e[t]})),Object.keys(t).forEach((function(e){return n[e]=t[e]})),n}T2C.MatchManagers={},T2C.MatchManagers.string_literal={getMatchResult:function(e,t){var n="string_literal",o=t.suffix||"",i=["'",'"'].map((function(e){var i="'"===e?"single":"double";if(t.exactText)return{id:n+"_"+i+"_text_"+o,type:"exact",value:t.exactText,partial:!0};if(t.nonEmptyText)return{id:n+"_"+i+"_text_"+o,type:"regexp",postfix:!0,tokenPartial:new RegExp("^[^"+e+"]*$"),token:new RegExp("^[^"+e+"]+")};if(t.endsWithText)return{id:n+"_"+i+"_text_"+o,type:"regexp",postfix:!0,tokenPartial:new RegExp("^[^"+e+"]*$"),token:new RegExp("^[^"+e+"]*"+(t.endsWithText.source||t.endsWithText)+"$","i")};var r=t.includeText?t.includeText.source||t.includeText:"";return{id:n+"_"+i+"_text_"+o,type:"regexp",postfix:!0,tokenPartial:new RegExp("^[^"+e+"]*$"),token:new RegExp("^[^"+e+"]*"+r+"^[^"+e+"]*","i")}})),r=i[0],a=i[1],l=void 0;if(t.exactText)l={id:n+"_block_text_"+o,type:"exact",value:t.exactText,partial:!0};else if(t.nonEmptyText)l={id:n+"_block_text_"+o,type:"regexp",postfix:!0,token:/[\s\S]+/};else if(t.endsWithText)l={id:n+"_block_text_"+o,type:"regexp",postfix:!0,token:new RegExp((t.endsWithText.source||t.endsWithText)+"$","i")};else{var s=t.includeText?t.includeText.source||t.includeText:"";l={id:n+"_block_text_"+o,type:"regexp",postfix:!0,token:new RegExp(s,"i")}}return t.textMode?h.a.getMatchResult(e,{id:18,type:"or",value:[{type:"Array",value:[{id:"string_literal_open_double",type:"exact",value:'"',postfix:!0},a,{id:"string_literal_close_double",type:"exact",value:'"',postfix:!0}]},{type:"Array",value:[{id:"string_literal_open_single",type:"exact",value:"'",postfix:!0},r,{id:"string_literal_close_single",type:"exact",value:"'",postfix:!0}]}]}):h.a.getMatchResult(e,{id:"string_literal_block",type:"block",value:{id:"string_literal_block_value",type:"text",inputs:[],fields:[{id:"string_literal_field",type:"field",name:"TEXT",value:l}]}})}},T2C.MatchManagers.display_string_literal={getMatchResult:function(e,t){t.displayText;var n=t.displayLanguage?{id:"display_string_literal_terminal",type:"exact",value:T2C.MSG[t.displayLanguage].TERMINAL_DISPLAY,partial:!0,postfix:!0}:{id:"display_string_literal_terminal",type:"terminal",token:"display"};return t.textMode?h.a.getMatchResult(e,{type:"Array",value:[n,{id:"display_string_literal_open_paren",type:"exact",value:"(",postfix:!0},{id:"display_string_literal_text",type:"component",name:"string_literal",value:T(t,{textMode:!0}),postfix:!0},{id:"display_string_literal_close_paren",type:"exact",value:")",postfix:!0},{id:"display_string_literal_semicolon",token:/^[;]*$/,type:"regexp"}]}):h.a.getMatchResult(e,{id:"display_string_literal_display_block",type:"block",value:{types:["text_print","js_text_print"],inputs:[{id:"display_string_literal_text_block",type:"input",name:"TEXT",value:{type:"component",name:"string_literal",value:T(t,{textMode:!1})}}],fields:[]}})}},T2C.MatchManagers.prompt_store_input={getMatchResult:function(e,t){var n=t.promptText||"",o=t.varName||"item",i=(new RegExp('^"[^"]*'+n+"[^\"]*\"|^'[^']*"+n+"[^']*'","i"),new RegExp("[sS]*"+n+"[sS]*","i"),t.promptLanguage?{id:13,type:"exact",value:T2C.MSG[t.promptLanguage].TERMINAL_GETINPUTBYASKING,partial:!0,postfix:!0}:{id:13,type:"terminal",token:"getInputByAsking"});return t.textMode?h.a.getMatchResult(e,{type:"Array",value:[{id:10,type:"terminal",token:"let"},{id:11,type:"exact",value:o,partial:!0,postfix:!0},{id:12,type:"exact",value:"=",partial:!0,postfix:!0},i,{id:14,type:"exact",value:"(",postfix:!0},{id:15,type:"component",name:"string_literal",value:{includeText:n,textMode:!0},postfix:!0},{id:16,type:"exact",value:")",postfix:!0},{id:17,token:/^[;]*$/,type:"regexp"}]}):h.a.getMatchResult(e,{id:0,type:"block",value:{type:"variables_set",inputs:[{id:1,type:"input",name:"VALUE",value:{id:2,type:"block",value:{types:["text_input","js_text_input"],inputs:[{id:3,type:"input",name:"TEXT",value:{type:"component",name:"string_literal",value:{includeText:n,textMode:!1}}}],fields:[]}}}],fields:[{id:8,type:"field",useText:!0,name:"VAR",value:{id:9,type:"exact",value:o}}]}})}},T2C.MatchManagers.code_statement_hybrid={getMatchResult:function(e,t){var n=t.matchManagerType,o=t.value,i="TEXT"===e.getFieldValue("MODE");return o.textMode=i,i?h.a.getMatchResult(e.getField("EXP"),{id:1e4,type:"field",name:"EXP",value:{type:"component",name:n,value:o}}):h.a.getMatchResult(e.getInputTargetBlock("EXP_STATEMENT"),{id:-1,type:"component",name:n,value:o})}},T2C.FeedbackManagers={},T2C.FeedbackManagers.default={errorFunctions:[{selectType:"expected",expected:"(",outputType:"function",showType:"error",msg:function(e,t,n){var o=t.indexOf(e);return T2C.MSG.currentLanguage.TYPEIN_ERROR_MISSING_OPEN_PARENTHESIS.replace("%1",t[h.a.getTerminalIndexForSymbol(t,o)].match)}},{selectType:"expected",expected:")",outputType:"function",showType:"error",msg:function(e,t,n){var o=t.indexOf(e);return T2C.MSG.currentLanguage.TYPEIN_ERROR_MISSING_CLOSE_PARENTHESIS.replace("%1",t[h.a.getTerminalIndexForSymbol(t,o)].match)}},{selectType:"expected",expected:function(e){return e&&e.source===/^[;]*$/.source},outputType:"function",showType:"error",msg:function(e,t,n){var o=(null!=e.remaining?e.remaining.toString():"").match(/^[;]*/)[0].length;return T2C.MSG.currentLanguage.TYPEIN_ERROR_REMOVE_EXTRA_AT_END.replace("%1","string"==typeof e.remaining&&e.remaining.substring(o))}},{selectType:"expected",expected:function(e,t,n){return h.a.equalsTerminal(e)},outputType:"function",showType:"error",msg:function(e,t,n){return t.indexOf(e),T2C.MSG.currentLanguage.TYPEIN_ERROR_TERMINAL_MISTYPED.replace("%1",h.a.getExpected(e))}}]},T2C.FeedbackManagers.string_literal={DEFAULT_MISSING_OPEN_SINGLE_QUOTE_MSG:"The message to supply to the user should be surrounded by ' and ' because you want it to be displayed as is.",DEFAULT_MISSING_OPEN_DOUBLE_QUOTE_MSG:'The message to supply to the user should be surrounded by " and " because you want it to be displayed as is.',DEFAULT_WRONG_BLOCK_MSG:"This is not the correct block to place here.",DEFAULT_MISSING_PHRASE_ERROR_MSG:"The message to the user should contain {feedbackItem.expected.value}.",errorFunctions:[{selectType:"id",id:"string_literal_open_double",outputType:"function",showType:"error",msg:"stringLiteralMissingOpenDouble"},{selectType:"id",id:"string_literal_open_single",outputType:"function",showType:"error",msg:"stringLiteralMissingOpenSingle"},{selectType:"id",id:"string_literal_single_text_",outputType:"function",showType:"error",msg:"stringLiteralMissingIncludeTextSingle"},{selectType:"id",id:"string_literal_double_text_",outputType:"function",showType:"error",msg:"stringLiteralMissingIncludeTextDouble"},{selectType:"id",id:"string_literal_block_text_",outputType:"function",showType:"error",msg:"stringLiteralWrongBlock"},{selectType:"id",id:"string_literal_field",outputType:"function",showType:"error",msg:"stringLiteralMissingIncludeTextBlock"}]},T2C.FeedbackManagers.display_string_literal={feedbackJsonBlock:[].concat(T2C.FeedbackManagers.default.errorFunctions).concat(T2C.FeedbackManagers.string_literal.errorFunctions)},T2C.FeedbackManagers.prompt_store_input={DEFAULT_VAR_NAME_ERROR_MSG:"Be sure to name the variable you're declaring {feedbackItem.expected.value}.",DEFAULT_MISSING_PHRASE_ERROR_MSG:"The message to the user should contain {feedbackItem.expected.value}.",DEFAULT_VARIABLE_NAME:"item",feedbackJsonText:[],feedbackJsonBlock:[{selectType:"id",id:0,showType:"error",outputType:"string",msg:"You'll want to store the result in a variable, which means you should use a {T2C.MSG.currentLanguage.TERMINAL_LET} variable block."},{selectType:"id",id:2,showType:"error",outputType:"string",msg:"The variable should store what the user enters, which means you'llneed to attach it to a {T2C.MSG.currentLanguage.TERMINAL_GETINPUTBYASKING} block."},{selectType:"id",id:6,outputType:"function",showType:"error",msg:"missingPhraseFunction"},{selectType:"id",id:8,outputType:"function",showType:"error",msg:"wrongVariableFunction"},{selectType:"id",id:11,outputType:"function",showType:"error",msg:"wrongVariableFunction"},{selectType:"id",id:12,outputType:"function",showType:"error",msg:function(e,t,n){return"Remember to include an = after the variable "+h.a.getExpected(t[t.indexOf(e)-1]).trim()+" you're declaring to set it to the string the user enters."}}].concat(T2C.FeedbackManagers.default.errorFunctions).concat(T2C.FeedbackManagers.string_literal.errorFunctions)},T2C.FeedbackManagers.code_statement_hybrid={DEFAULT_TEXT_MODE_FEEDBACK_MANAGER:function(e,t,n){if(-1!==e.id)return m.a.getFeedback(t,n.feedbackManager.feedbackJsonBlock,n.options).map((function(e){return e.msgArr.join("\n")})).join("\n\n")},feedbackJsonBlock:[{selectType:"id",id:1e4,outputType:"function",msg:"textModeFeedbackManager"},{selectType:"id",id:-1,outputType:"component",msg:"textModeFeedbackManager"}]};var _=new d("type_in_display_string_literal");_.addPossibleMatch([{token:"display",type:"terminal"},"(",{token:/^"[^"]*$|^'[^']*$|^"[^"]+"|^'[^"]+'/,type:"regexp"},")",{token:/^[;]*/,type:"regexp"}],[null,null,function(e,t){return t.startsWith('"')||t.startsWith("'")?'""'===t||"''"===t?"Include some message in between the quotation marks so that the user sees some text!":"":'Make sure the text you want to display is between " and " so the computer just displays it without trying to figure out what you mean!'},null,null]),_.addToBlocks();var b=new d("type_in_welcome_message");function k(e){return Array.from(document.querySelectorAll("rect")).filter((function(e){return e.getAttribute("fill-opacity")}))[e]}function x(e,t,n){var o=arguments.length>3&&void 0!==arguments[3]?arguments[3]:0,i=arguments.length>4&&void 0!==arguments[4]?arguments[4]:0,r=t.getBoundingRectangle(),a=e.getMetrics(),l=e.getScale(),s=o,u=i,c=n.blockOffsetScaleX||0,g=n.blockOffsetScaleY||0;return{x:(r.left-a.viewLeft+c*t.width)*l+s,y:(r.top-a.viewTop+a.flyoutHeight+g*t.height)*l+u}}b.addPossibleMatch([{token:/^"[^"]*$|^'[^']*$|^"[^"]+ "|^'[^"]+ '/,type:"regexp"},"+","firstName","+",{token:/^"[^"]+"|^'[^"]+'/,tokenPartial:/^"[^"]*$|^'[^']*$/,type:"regexp"}],[function(e,t){return t.startsWith('"')||t.startsWith("'")?'""'===t||"''"===t?"Include some greeting in between the quotation marks that will appear before the person's first name such as hi or welcome.":/^"[^"]+[^ ]"|^'[^"]+[^ ]'/.test(t)?"Be sure to include a space at the end of the greeting before the quotation marks so the greeting and person's first name will appear with a space in between them (e.g., Hi Jane instead of HiJane).\n NOTE: Including a space *outside* of quotation marks will NOT appear in the message displayed to the user.":"":'Make sure the text you want to display is between " and " so the computer just displays it without trying to figure out what you mean!'},function(e,t){return"Include a + to join the greeting "+e[0].substring(1,e[0].length-1)+" text with the user's first name."},function(e,t){return t.startsWith('"')||t.startsWith("'")?"Be sure that the variable name firstName appears outside of quotation marks since you want its value, which will be the name the user enters instead of the text firstName (e.g., you want "+e[0].substring(1,e[0].length-1)+"Jane instead of "+e[0].substring(1,e[0].length-1)+"firstName.":t.startsWith("firstn")?"Be sure to enter firstName in camel case (first letter of every word after the first capitalized)":"Type the variable name firstName exactly so that its value, mainly what the user entered for his/her first name, will be displayed after "+e[0].substring(1,e[0].length-1)+"."},function(e,t){return"Include a + to join the greeting "+e[0].substring(1,e[0].length-1)+" and the name the user entered with a final punctuation mark (to be gramatically correct)."},function(e,t){return t.startsWith('"')||t.startsWith("'")?'""'===t||"''"===t?"Include some punctuation mark such as . or ! in between the quotation marks so your English teacher doesn't complain.":"":'Since the punctuation mark should be displayed exactly as is without evaluating it any way, be sure you let the computer know this by surrounding the punctuation mark with " and ".'}]),b.addToBlocks({isExpression:!0});var E=new d("type_in_get_last_char_number");function B(e,t){var n=!(arguments.length>2&&void 0!==arguments[2])||arguments[2],o=document.createElement("block");return o.setAttribute("type",t),n?document.getElementById("toolbox").prepend(o):document.getElementById("toolbox").append(o),e.updateToolbox(document.getElementById("toolbox")),o}function A(e,t){var n=!(arguments.length>2&&void 0!==arguments[2])||arguments[2],o=document.createElement("block");return o.setAttribute("type",t),n?document.getElementById("toolbox").prepend(o):document.getElementById("toolbox").append(o),e.updateToolbox(document.getElementById("toolbox")),o}function v(e,t){var n=Object.values(T2C.MSG).map((function(e){return e["TERMINAL_"+t.toUpperCase()]})).filter((function(e){return"string"==typeof e})).find((function(t){return t.startsWith(e)||e.startsWith(t)}));if(n)return{terminal:n,remaining:e.JSSubstring(n.length).trim()}}function I(e,t){e("Check the spelling, case, and punctuation of what you're entering; it should identically match with "+T2C.MSG.currentLanguage["TERMINAL_"+t.toUpperCase()]+".")}function w(e,t,n){for(var o=void 0,i=[],r=e,a=!1,l=-1;l2&&void 0!==arguments[2])||arguments[2],o=O(t);return n?document.getElementById("toolbox").prepend(o):document.getElementById("toolbox").append(o),e.updateToolbox(document.getElementById("toolbox")),o}function O(e){var t=document.createElement("block");return t.setAttribute("type",e),t}function C(e,t,n){var o=document.createElement("field");o.setAttribute("name",t),o.appendChild(document.createTextNode(n)),e.appendChild(o)}function R(e,t,n){var o=document.createElement("value");o.setAttribute("name",t),o.appendChild(n),e.appendChild(o)}function F(e,t,n){var o=arguments.length>3&&void 0!==arguments[3]?arguments[3]:0,i=arguments.length>4&&void 0!==arguments[4]?arguments[4]:0,r=t&&t.getBoundingRectangle()||{left:0,top:0};t=t||{width:0,height:0};var a=e.getMetrics(),l=e.getScale(),s=o,u=i,c=n.blockOffsetScaleX||0,g=n.blockOffsetScaleY||0;return{x:(r.left-a.viewLeft+c*t.width)*l+s,y:(r.top-a.viewTop+a.flyoutHeight+g*t.height)*l+u}}function P(e){var t=!(arguments.length>1&&void 0!==arguments[1])||arguments[1],n=document.getElementById("alert-display");n||((n=document.createElement("div")).id="alert-display",n.style.fontSize="small",n.style.fontWeight="bold",n.style.borderColor="#000",n.style.backgroundColor="rgba(200, 200, 200, 0.5)",n.style.color="#f00",n.style.position="absolute",n.style.zIndex="1050",n.style.width="98%",n.style.minHeight="50px",n.style.left="0",n.style.bottom="0",n.style.textAlign="left",n.style.padding="1%",document.body.appendChild(n)),t?n.innerText=e:n.innerText+=e}function V(e,t){var n=Object.values(T2C.MSG).map((function(e){return e["TERMINAL_"+t.toUpperCase()]})).filter((function(e){return"string"==typeof e})).find((function(t){return t.startsWith(e)||e.startsWith(t)}));if(n)return{terminal:n,remaining:e.JSSubstring(n.length).trim()}}function G(e,t){e("Check the spelling, case, and punctuation of what you're entering; it should identically match with "+T2C.MSG.currentLanguage["TERMINAL_"+t.toUpperCase()]+".")}function U(e,t,n){for(var o=void 0,i=[],r=e,a=!1,l=-1;l2&&void 0!==arguments[2])||arguments[2],o=Y(t);return n?document.getElementById("toolbox").prepend(o):document.getElementById("toolbox").append(o),e.updateToolbox(document.getElementById("toolbox")),o}function Y(e){var t=document.createElement("block");return t.setAttribute("type",e),t}function H(e,t,n){var o=document.createElement("field");o.setAttribute("name",t),o.appendChild(document.createTextNode(n)),e.appendChild(o)}function J(e,t,n){var o=document.createElement("value");o.setAttribute("name",t),o.appendChild(n),e.appendChild(o)}function q(e,t,n){var o=arguments.length>3&&void 0!==arguments[3]?arguments[3]:0,i=arguments.length>4&&void 0!==arguments[4]?arguments[4]:0,r=t&&t.getBoundingRectangle()||{left:0,top:0};t=t||{width:0,height:0};var a=e.getMetrics(),l=e.getScale(),s=o,u=i,c=n.blockOffsetScaleX||0,g=n.blockOffsetScaleY||0;return{x:(r.left-a.viewLeft+c*t.width)*l+s,y:(r.top-a.viewTop+a.flyoutHeight+g*t.height)*l+u}}function $(e){var t=!(arguments.length>1&&void 0!==arguments[1])||arguments[1],n=document.getElementById("alert-display");n||((n=document.createElement("div")).id="alert-display",n.style.fontSize="small",n.style.fontWeight="bold",n.style.borderColor="#000",n.style.backgroundColor="rgba(200, 200, 200, 0.5)",n.style.color="#f00",n.style.position="absolute",n.style.zIndex="1050",n.style.width="98%",n.style.minHeight="50px",n.style.left="0",n.style.bottom="0",n.style.textAlign="left",n.style.padding="1%",document.body.appendChild(n)),t?n.innerText=e:n.innerText+=e}function z(e){e.style.verticalAlign="middle",e.style.color="#000"}function K(){document.getElementById("output-container").classList.remove("show-container"),document.getElementById("output-container").classList.add("hide-container"),document.getElementById("text-code-container").classList.remove("show-container"),document.getElementById("text-code-container").classList.add("hide-container")}function Z(e,t){var n=Object.values(T2C.MSG).map((function(e){return e["TERMINAL_"+t.toUpperCase()]})).filter((function(e){return"string"==typeof e})).find((function(t){return t.startsWith(e)||e.startsWith(t)}));if(n)return{terminal:n,remaining:e.JSSubstring(n.length).trim()}}function Q(e,t){e("Check the spelling, case, and punctuation of what you're entering; it should identically match with "+T2C.MSG.currentLanguage["TERMINAL_"+t.toUpperCase()]+".")}function ee(e,t,n){for(var o=void 0,i=[],r=e,a=!1,l=-1;l3&&void 0!==arguments[3]?arguments[3]:0,i=arguments.length>4&&void 0!==arguments[4]?arguments[4]:0,r=t&&t.getBoundingRectangle()||{left:0,top:0};t=t||{width:0,height:0};var a=e.getMetrics(),l=e.getScale(),s=o,u=i,c=n.blockOffsetScaleX||0,g=n.blockOffsetScaleY||0;return{x:(r.left-a.viewLeft+c*t.width)*l+s,y:(r.top-a.viewTop+a.flyoutHeight+g*t.height)*l+u}}function ne(e){var t=!(arguments.length>1&&void 0!==arguments[1])||arguments[1],n=document.getElementById("alert-display");n||((n=document.createElement("div")).id="alert-display",n.style.fontSize="small",n.style.fontWeight="bold",n.style.borderColor="#000",n.style.backgroundColor="rgba(200, 200, 200, 0.5)",n.style.color="#f00",n.style.position="absolute",n.style.zIndex="1050",n.style.width="98%",n.style.minHeight="50px",n.style.left="0",n.style.bottom="0",n.style.textAlign="left",n.style.padding="1%",document.body.appendChild(n)),t?n.innerText=e:n.innerText+=e}function oe(e){e.style.verticalAlign="middle",e.style.color="#000"}function ie(){document.getElementById("output-container").classList.remove("show-container"),document.getElementById("output-container").classList.add("hide-container"),document.getElementById("text-code-container").classList.remove("show-container"),document.getElementById("text-code-container").classList.add("hide-container")}function re(e,t){var n=Object.values(T2C.MSG).map((function(e){return e["TERMINAL_"+t.toUpperCase()]})).filter((function(e){return"string"==typeof e})).find((function(t){return t.startsWith(e)||e.startsWith(t)}));if(n)return{terminal:n,remaining:e.JSSubstring(n.length).trim()}}function ae(e,t){e("Check the spelling, case, and punctuation of what you're entering; it should identically match with "+T2C.MSG.currentLanguage["TERMINAL_"+t.toUpperCase()]+".")}function le(e,t,n){for(var o=void 0,i=[],r=e,a=!1,l=-1;l3&&void 0!==arguments[3]?arguments[3]:0,i=arguments.length>4&&void 0!==arguments[4]?arguments[4]:0,r=t&&t.getBoundingRectangle()||{left:0,top:0};t=t||{width:0,height:0};var a=e.getMetrics(),l=e.getScale(),s=o,u=i,c=n.blockOffsetScaleX||0,g=n.blockOffsetScaleY||0;return{x:(r.left-a.viewLeft+c*t.width)*l+s,y:(r.top-a.viewTop+a.flyoutHeight+g*t.height)*l+u}}function ue(e){var t=!(arguments.length>1&&void 0!==arguments[1])||arguments[1],n=document.getElementById("alert-display");n||((n=document.createElement("div")).id="alert-display",n.style.fontSize="small",n.style.fontWeight="bold",n.style.borderColor="#000",n.style.backgroundColor="rgba(200, 200, 200, 0.5)",n.style.color="#f00",n.style.position="absolute",n.style.zIndex="1050",n.style.width="98%",n.style.minHeight="50px",n.style.left="0",n.style.bottom="0",n.style.textAlign="left",n.style.padding="1%",document.body.appendChild(n)),t?n.innerText=e:n.innerText+=e}function ce(e){e.style.verticalAlign="middle",e.style.color="#000"}function ge(){document.getElementById("output-container").classList.remove("show-container"),document.getElementById("output-container").classList.add("hide-container"),document.getElementById("text-code-container").classList.remove("show-container"),document.getElementById("text-code-container").classList.add("hide-container")}function de(e,t){var n=Object.values(T2C.MSG).map((function(e){return e["TERMINAL_"+t.toUpperCase()]})).filter((function(e){return"string"==typeof e})).find((function(t){return t.startsWith(e)||e.startsWith(t)}));if(n)return{terminal:n,remaining:e.JSSubstring(n.length).trim()}}function he(e,t){e("Check the spelling, case, and punctuation of what you're entering; it should identically match with "+T2C.MSG.currentLanguage["TERMINAL_"+t.toUpperCase()]+".")}function pe(e,t,n){for(var o=void 0,i=[],r=e,a=!1,l=-1;l3&&void 0!==arguments[3]?arguments[3]:0,i=arguments.length>4&&void 0!==arguments[4]?arguments[4]:0,r=t&&t.getBoundingRectangle()||{left:0,top:0};t=t||{width:0,height:0};var a=e.getMetrics(),l=e.getScale(),s=o,u=i,c=n.blockOffsetScaleX||0,g=n.blockOffsetScaleY||0;return{x:(r.left-a.viewLeft+c*t.width)*l+s,y:(r.top-a.viewTop+a.flyoutHeight+g*t.height)*l+u}}function me(e){var t=!(arguments.length>1&&void 0!==arguments[1])||arguments[1],n=document.getElementById("alert-display");n||((n=document.createElement("div")).id="alert-display",n.style.fontSize="small",n.style.fontWeight="bold",n.style.borderColor="#000",n.style.backgroundColor="rgba(200, 200, 200, 0.5)",n.style.color="#f00",n.style.position="absolute",n.style.zIndex="1050",n.style.width="98%",n.style.minHeight="50px",n.style.left="0",n.style.bottom="0",n.style.textAlign="left",n.style.padding="1%",document.body.appendChild(n)),t?n.innerText=e:n.innerText+=e}function ye(e){e.style.verticalAlign="middle",e.style.color="#000"}function Te(){document.getElementById("output-container").classList.remove("show-container"),document.getElementById("output-container").classList.add("hide-container"),document.getElementById("text-code-container").classList.remove("show-container"),document.getElementById("text-code-container").classList.add("hide-container")}function _e(e,t){var n=Object.values(T2C.MSG).map((function(e){return e["TERMINAL_"+t.toUpperCase()]})).filter((function(e){return"string"==typeof e})).find((function(t){return t.startsWith(e)||e.startsWith(t)}));if(n)return{terminal:n,remaining:e.JSSubstring(n.length).trim()}}function be(e,t){e("Check the spelling, case, and punctuation of what you're entering; it should identically match with "+T2C.MSG.currentLanguage["TERMINAL_"+t.toUpperCase()]+".")}function ke(e,t,n){for(var o=void 0,i=[],r=e,a=!1,l=-1;l3&&void 0!==arguments[3]?arguments[3]:0,i=arguments.length>4&&void 0!==arguments[4]?arguments[4]:0,r=t&&t.getBoundingRectangle()||{left:0,top:0};t=t||{width:0,height:0};var a=e.getMetrics(),l=e.getScale(),s=o,u=i,c=n.blockOffsetScaleX||0,g=n.blockOffsetScaleY||0;return{x:(r.left-a.viewLeft+c*t.width)*l+s,y:(r.top-a.viewTop+a.flyoutHeight+g*t.height)*l+u}}function Ee(e){var t=!(arguments.length>1&&void 0!==arguments[1])||arguments[1],n=document.getElementById("alert-display");n||((n=document.createElement("div")).id="alert-display",n.style.fontSize="small",n.style.fontWeight="bold",n.style.borderColor="#000",n.style.backgroundColor="rgba(200, 200, 200, 0.5)",n.style.color="#f00",n.style.position="absolute",n.style.zIndex="1050",n.style.width="98%",n.style.minHeight="50px",n.style.left="0",n.style.bottom="0",n.style.textAlign="left",n.style.padding="1%",document.body.appendChild(n)),t?n.innerText=e:n.innerText+=e}E.addPossibleMatch([{token:"display",type:"terminal"},"(","s",".",{token:"getCharacterNUMBER",type:"terminal"},"(","4",")",")",{token:/^[;]*/,type:"regexp"}],[null,null,function(e,t){return t.startsWith('"')?"Don't use \" here as you want the computer to evaluate what you typed (e.g., the word the user entered instead of the letter s)":"Be sure to include the variable s that you want to the get the value's last character from"},null,null,null,function(e,t){return t.startsWith('"')?"Don't use \" here as you want the computer to interpret this as a number and not text.":t.startsWith("5")?"Remember that character positions start at the number 0. If you count the letters of a 5-letter word such as `pizza` starting from 0, you won't get up to position 5.":t.startsWith("6")?"Determine the position of the last character a in the 5-letter word `pizza`. If you count starting from 0, you won't get up to position 6.":0===parseInt(t)?"You want the position of the last character, not the first.":parseInt(t)?"Determine the position of the last character a in the 5-letter word `pizza`. The number you're entering is incorrect.":"Include a number for the position you want after "+e[4]+"("},null,null,null]),E.addPossibleMatch([{token:"display",type:"terminal"},"(","s","[","4","]",")"],[null,null,function(e,t){return t.startsWith('"')?"Don't use \" here as you want the computer to evaluate what you typed (e.g., the word the user entered instead of the letter s)":"Be sure to include the variable s that you want to the get the value's last character from"},null,function(e,t){return t.startsWith('"')?"Don't use \" here as you want the computer to interpret this as a number and not text.":t.startsWith("5")?"Remember that character positions start at the number 0. If you count the letters of a 5-letter word such as `pizza` starting from 0, you won't get up to position 5.":t.startsWith("6")?"Determine the position of the last character a in the 5-letter word `pizza`. If you count starting from 0, you won't get up to position 6.":0===parseInt(t)?"You want the position of the last character, not the first.":parseInt(t)?"Determine the position of the last character a in the 5-letter word `pizza`. The number you're entering is incorrect.":"Include a number for the position you want after "+e[3]+"."},null,null]),E.addToBlocks(),String.prototype.JSSubstring=function(e,t){return e>=this.length||e===t?"":this.substring(e,t)},Blockly.Python.type_in_get_input=Blockly.JavaScript.type_in_get_input=Blockly.JavaScript.code_statement,Blockly.Blocks.type_in_get_input={validate:function(e){var t,n=void 0,o=void 0,i=void 0,r=v(e.trim(),"let");if(!r)return P("Check the spelling, case, and punctuation of what you're entering; it should identically match with "+T2C.MSG.currentLanguage.TERMINAL_LET+"."),null;if(r.remaining.length&&!r.remaining.startsWith("s"))return P("Be sure to name the variable you're declaring s. This will store the string with an even number of characters the user enters."),r.terminal;if(r.remaining=r.remaining.JSSubstring(1).trim(),r.remaining.length&&!r.remaining.startsWith("="))return P("Remember to include an = after the variable s you're declaring to set it to the string the user enters."),r.terminal+"s";if(r.remaining=r.remaining.JSSubstring(1).trim(),!r.remaining.length)return P(""),e;if(t=r.terminal+"s = ",!(n=v(r.remaining.trim(),"GETINPUTBYASKING")))return P("Check the spelling, case, and punctuation of what you're entering; it should identically match with "+T2C.MSG.currentLanguage.TERMINAL_GETINPUTBYASKING+"."),t;if(n.remaining.length&&!n.remaining.startsWith("("))return P("You're missing an opening parenthesis after "+n.terminal),t+n.terminal;if(n.remaining=n.remaining.JSSubstring(1).trim(),n.remaining.length&&!n.remaining.startsWith('"')&&!n.remaining.startsWith("'"))return P('The message to supply to the user should be surrounded by " and " because you want it to be displayed as is.'),t+n.terminal+"(";if(n.remaining.length&&(o=n.remaining.match(/^"[^"]*"|^'[^']*'/))){if(-1===(i=o[0]).toLowerCase().indexOf(" even ")&&-1===i.indexOf(" "))return P("Make sure the message contains the word even to tell the user you want him/her to enter an even number of characters (> 0). And be sure it has spaces since you can and should include them in messages read by humans!"),t+n.terminal+"("+i.substring(0,i.length-1);if(-1===i.toLowerCase().indexOf(" even "))return P("Make sure the message contains the word even (surrounded by spaces) to tell the user you want him/her to enter an even number of characters (> 0)."),t+n.terminal+"("+i.substring(0,i.length-1)}return n.remaining.length&&i&&(n.remaining=n.remaining.JSSubstring(i.length).trim()),n.remaining.length&&i&&!n.remaining.startsWith(")")?(P("You're missing a closing parenthesis for "+n.terminal),t+n.terminal+"("+i):(n.remaining.length&&i&&(n.remaining=n.remaining.JSSubstring(1).trim()),P(""),e)},init:function(){var e=this;this.appendDummyInput("STRING").appendField(new Blockly.FieldTextInput("",this.validate),"EXP"),this.setInputsInline(!1),this.setOutput(!1),this.setPreviousStatement(!0),this.setNextStatement(!0),this.setColour(60),this.setTooltip(T2C.MSG.currentLanguage.TYPEIN_STATEMENT_TOOLTIP),this.onchange=function(t){if(e.getFieldValue("EXP").endsWith("\r")||e.getFieldValue("EXP").endsWith("\n")||e.getFieldValue("EXP").length>0&&"workspaceClick"===t.element){if(!e.validate(e.getFieldValue("EXP"))||!e.getFieldValue("EXP").endsWith(")")&&!e.getFieldValue("EXP").endsWith(";"))return;var n=Object(o.getParseTree)(e.getFieldValue("EXP"));n?Object(o.handleParseTreeToBlocks)(n,e):P("Try checking what you entered again for mistakes. You probably just have extra unnecessary code after a ).")}}}},Blockly.Python.type_in_set_to_char_number_0=Blockly.JavaScript.type_in_set_to_char_number_0=Blockly.JavaScript.code_statement,Blockly.Blocks.type_in_set_to_char_number_0={validate:function(e){var t=void 0,n=void 0,o=v(e.trim(),"let");return o?!o.remaining.length||o.remaining.startsWith("firstChar")||"firstChar".startsWith(o.remaining)?(o.remaining=o.remaining.JSSubstring("firstChar".length).trim(),o.remaining.length&&!o.remaining.startsWith("=")?(P("Remember to include an = after the variable firstChar you're declaring to set it to the string's first character."),o.terminal+"firstChar"):(o.remaining=o.remaining.JSSubstring(1).trim(),o.remaining.length?(t=o.terminal+"firstChar = ",o.remaining.length&&!o.remaining.startsWith("s")?(o.remaining.startsWith('"')?P("Don't use \" here as you want the computer to evaluate what you typed (e.g., the word the user entered instead of the letter s)"):o.remaining.startsWith("f")?P("This is the string you want to get the initial character from so you'll want to use s, which stores what the user entered."):P("Be sure to include the variable s that you want to the get the value's first character from."),t):(o.remaining=o.remaining.JSSubstring(1).trim(),o.remaining.length&&!o.remaining.startsWith(".")?(P("Be sure to include the . after the variable"),t+"s"):o.remaining.length?(t+="s.",(n=v(o.remaining.JSSubstring(1).trim(),"GETCHARACTERNUMBER"))?n.remaining.length&&!n.remaining.startsWith("(")?(P("You're missing an opening parenthesis after "+n.terminal),t+n.terminal):(n.remaining=n.remaining.JSSubstring(1).trim(),n.remaining.length&&!n.remaining.startsWith("0")?(n.remaining.startsWith('"')?P("Don't use \" here as you want the computer to interpret this as a number and not text."):n.remaining.startsWith("1")?P("Remember that character positions start at the number 0."):parseInt(n.remaining)?P("The number you're entering is incorrect for getting the initial character."):P("Include a number for the position you want after "+n.terminal+"("),t+n.terminal+"("):(n.remaining=n.remaining.JSSubstring(1).trim(),n.remaining.length&&!n.remaining.startsWith(")")?(P("You're missing a closing parenthesis for "+n.terminal),t+n.terminal+"(0"):(P(""),e))):(P("Check the spelling, case, and punctuation of what you're entering; it should identically match with "+T2C.MSG.currentLanguage.TERMINAL_GETCHARACTERNUMBER),t)):(P(""),e))):(P(""),e))):(P("Be sure to name the variable you're declaring firstChar to representing the fact that it's storing the entered string's first character."),o.terminal):(P("Check the spelling, case, and punctuation of what you're entering; it should identically match with "+T2C.MSG.currentLanguage.TERMINAL_LET+"."),null)},init:function(){var e=this;this.appendDummyInput("STRING").appendField(new Blockly.FieldTextInput("",this.validate),"EXP"),this.setInputsInline(!1),this.setOutput(!1),this.setPreviousStatement(!0),this.setNextStatement(!0),this.setColour(60),this.setTooltip(T2C.MSG.currentLanguage.TYPEIN_STATEMENT_TOOLTIP),this.onchange=function(t){if(e.getFieldValue("EXP").endsWith("\r")||e.getFieldValue("EXP").endsWith("\n")||e.getFieldValue("EXP").length>0&&"workspaceClick"===t.element){if(!e.validate(e.getFieldValue("EXP"))||!e.getFieldValue("EXP").endsWith(")")&&!e.getFieldValue("EXP").endsWith(";"))return;var n=Object(o.getParseTree)(e.getFieldValue("EXP"));n?Object(o.handleParseTreeToBlocks)(n,e):P("Try checking what you entered again for mistakes.")}}}},Blockly.Python.type_in_set_to_last_char=Blockly.JavaScript.type_in_set_to_last_char=Blockly.JavaScript.code_statement,Blockly.Blocks.type_in_set_to_last_char={validate:function(e){var t=w(e,[{token:"let",type:"terminal"},"lastChar","=","s",".",{token:"GETCHARACTERNUMBER",type:"terminal"},"(","s",".",{token:"LENGTH",type:"terminal"},"-","1",")"],[I.bind(null,P,"LET"),function(){return P("Be sure to name the variable you're declaring lastChar to representing the fact that it's storing the entered string's last character.")},function(){return P("Remember to include an = after the variable lastChar you're declaring to set it to the string's last character.")},function(e,t){t.startsWith('"')?P("Don't use \" here as you want the computer to evaluate what you typed (e.g., the word the user entered instead of the letter s)"):t.startsWith("l")?P("This is the string you want to get the last character from so you'll want to use s, which stores what the user entered."):P("Be sure to include the variable s that you want to the get the value's last character from.")},function(){return P("Be sure to include the . after the variable")},I.bind(null,P,"GETCHARACTERNUMBER"),function(e){return"You're missing an open parenthesis after "+e[5]+"."},function(e,t){t.startsWith("-")?P("Let's get the length of the string first when calculating the position of the last character even though it doesn't need to appear before the operation."):isNaN(parseInt(t))?P("To get the length of a string, you'll need to first specify the string you want the length of. In this case, you'll need to use the length of the entered string (stored in s) to get the position of its last character."):P("Remember that since the string can be of any length, its last character will not always be at position "+parseInt(t)+".")},function(e,t){t.startsWith("(")?P("An expression representing a number should go after the open parenthesis for "+e[5]+'. It wouldn\'t make sense to get the character at position number "pizza" (or whatever string the user enters), right?'):P("Be sure to include the . after the variable s if you want to get its length.")},I.bind(null,P,"LENGTH"),function(e,t){t.startsWith("(")?P("The length of a 5-character string such as pizza is 5, but since you start counting from 0, this was not the position of the last character. Consider using some math operation to calculate the correct position."):t.startsWith("+")?P("Consider adding a number such as 1 to 5, which is the length of pizza. This gives you 6, but you wouldn't use 6 for the number of the position for the last character, right?"):P("Type the appropriate option (+ = ADD, - = SUBTRACT, * = MULTIPLY, / = DIVIDE) that you want to perform on the string's length to calculate the character's last position. Your current answer won't work in general.")},function(e,t){var n=parseInt(t);isNaN(n)?P("Remember that the length is a number. What would it mean to subtract a string from a number?"):P(0===n?"The length of a 5-character string such as pizza is 5, but since you start counting from 0, this was not the position of the last character. Also subtracting 0 doesn't change the quantity (e.g., 5 - 0 = 5) so it wouldn't be necessary.":"What number do you want to subtract from the length of the string to get the position of its last character? pizza had a length of 5, and its last character was at what position? food has a length of 4, and its last character is at what position?")},function(e,t){return P("You're missing a closing parenthesis for "+e[5])}]);return t.error?t.match.join(""):e},init:function(){var e=this;this.appendDummyInput("STRING").appendField(new Blockly.FieldTextInput("",this.validate),"EXP"),this.setInputsInline(!1),this.setOutput(!1),this.setPreviousStatement(!0),this.setNextStatement(!0),this.setColour(60),this.setTooltip(T2C.MSG.currentLanguage.TYPEIN_STATEMENT_TOOLTIP),this.onchange=function(t){if(e.getFieldValue("EXP").endsWith("\r")||e.getFieldValue("EXP").endsWith("\n")||e.getFieldValue("EXP").length>0&&"workspaceClick"===t.element){if(!e.validate(e.getFieldValue("EXP"))||!e.getFieldValue("EXP").endsWith(")")&&!e.getFieldValue("EXP").endsWith(";"))return;var n=Object(o.getParseTree)(e.getFieldValue("EXP"));n?Object(o.handleParseTreeToBlocks)(n,e):P("Try checking what you entered again for mistakes.")}}}},Blockly.Python.type_in_set_to_position_of_second_middle_char=Blockly.JavaScript.type_in_set_to_position_of_second_middle_char=Blockly.JavaScript.code_statement,Blockly.Blocks.type_in_set_to_position_of_second_middle_char={validate:function(e){var t=w(e,[{token:"let",type:"terminal"},"positionOfSecondMiddleChar","=","s",".",{token:"LENGTH",type:"terminal"},"/","2"],[I.bind(null,P,"LET"),function(){return P("Be sure to name the variable you're declaring positionOfSecondMiddleChar to represent the fact that it's storing the position number of the string's second middle character.")},function(){return P("Remember to include an = after the variable positionOfSecondMiddleChar you're declaring to set it to the position of the string's second middle character.")},function(e,t){isNaN(parseInt(t))?t.startsWith('"')?P("Don't use \" here as you want the computer to evaluate what you typed (e.g., the word the user entered instead of the letter s)"):t.startsWith("l")||t.startsWith("p")?P("This is the string you want to get the length of so you'll want to use s, which stores what the user entered."):P("Be sure to include the variable s that you want to the get the length of."):P("Let's get the length of the string first when calculating the position of the second middle character even though it doesn't need to appear before the operation.")},function(){return P("Be sure to include the . after the variable")},I.bind(null,P,"LENGTH"),function(e,t){t.startsWith("-")?P("If you subtract a *specific number* for the length, this won't work in general. For example, the length of SCRABBLE is 8 and the position of its second middle character is 4. So subtracting 4 from the length works for that example, but if your string were FOOD, the middle character is at 2, but subtracting 4 from the length of 4 gives you 0."):t.startsWith("+")?P("Remember that the last character is at the length of the string - 1. If you add zero or a positive number to the length, you'll get the position of a character that does not exist! For example, if you add 1 to the length of pizza, you'll get 5 + 1 or 6, but the position of the last character is 4 so you'll go out of bounds!"):t.startsWith("*")?P("Multiplication could work, but not by a positive whole number since multiplying the length of the string by 1, 2, 3, or 4 will always be greater than the position of the last character of the string, which is its length - 1. For example, multiplying the length of pizza by 4, gives you 5 * 4 = 20 and there's no 20th character! What operation could you use instead so you don't refer to a position that's out of bounds?"):P("Type the appropriate option (+ = ADD, - = SUBTRACT, * = MULTIPLY, / = DIVIDE) that you want to perform on the string's length to calculate the position of its second middle character.")},function(e,t){var n=parseInt(t);t.startsWith('"')||t.startsWith("'")?P("Remember that the length is a number. What would it mean to divide a string from a number?"):isNaN(n)?P("Remember that the length is a number. You wouldn't divide it by the string the user enters (e.g., what would 8/SCRABBLE mean?) and you can't divide it by positionOfSecondMiddleChar because you're defining that variable. And if you divide any positive number by itself, that'd be 1 anyway which won't be the position of the second middle character in general. You can divide the length by a specific number to get the position of the second middle character. What should that be?"):P("If you divide the length of SCRABBLE by "+n+", you'll get "+8/n+", which is not the position of its second middle character (4). Try a different number. Also verify that it works for strings of other even lengths such as CODE.")}]);return t.error?t.match.join(""):e},init:function(){var e=this;this.appendDummyInput("STRING").appendField(new Blockly.FieldTextInput("",this.validate),"EXP"),this.setInputsInline(!1),this.setOutput(!1),this.setPreviousStatement(!0),this.setNextStatement(!0),this.setColour(60),this.setTooltip(T2C.MSG.currentLanguage.TYPEIN_STATEMENT_TOOLTIP),this.onchange=function(t){if(e.getFieldValue("EXP").endsWith("\r")||e.getFieldValue("EXP").endsWith("\n")||e.getFieldValue("EXP").length>0&&"workspaceClick"===t.element){if(!e.validate(e.getFieldValue("EXP"))||!e.getFieldValue("EXP").endsWith("2")&&!e.getFieldValue("EXP").endsWith(";"))return;var n=Object(o.getParseTree)(e.getFieldValue("EXP"));n?Object(o.handleParseTreeToBlocks)(n,e):P("Try checking what you entered again for mistakes.")}}}},Blockly.Python.type_in_set_to_position_of_first_middle_char=Blockly.JavaScript.type_in_set_to_position_of_first_middle_char=Blockly.JavaScript.code_statement,Blockly.Blocks.type_in_set_to_position_of_first_middle_char={validate:function(e){var t=w(e,[{token:"let",type:"terminal"},"positionOfFirstMiddleChar","=","positionOfSecondMiddleChar","-","1"],[I.bind(null,P,"LET"),function(){return P("Be sure to name the variable you're declaring positionOfFirstMiddleChar to represent the fact that it's storing the position number of the string's first middle character.")},function(){return P("Remember to include an = after the variable positionOfFirstMiddleChar you're declaring to set it to the position of the string's first middle character.")},function(e,t){t.startsWith("-")?P("Let's get the length of the string first when calculating the position of the first middle character even though it doesn't need to appear before the operation."):t.startsWith('"')?P("Don't use \" here as you want the computer to evaluate the variable."):t.startsWith("l")?P("While you might use a math operation on the *position* of the last character, which is a number, to get the position of the first middle character, you would not use the character itself. E.g., you might do a math operation on 4, which is the position of the a in pizza, but not the a itself. However, try using a math operation on the *position* of the second middle character instead."):t.startsWith("s")?P("Instead of using the length of the string s this time to calculate the position of the first middle character, try using the position of the second middle character instead."):P("You'll want to use the position of the second middle character to get the position of the first middle character. You already stored that in what variable?")},function(e,t){t.startsWith("/")?P("Dividing the position of the second middle character by a number won't get the previous position where the first middle character resides. For example, for SCRABBLE, the second middle character is at position 4. Dividing this by 2 gets you 2, the position of the R, by 3 gets you 4/3, which is not even a position, etc. What would you do to the 4 to get to the position of the first middle character at 3?"):t.startsWith("+")?P("Adding a positive number won't be what you want as that moves you forward. For example, the position of the second middle character of SCRABBLE is 4. Adding 1, 2, or 3 would give you 5, 6, or 7, the positions of the second B, the L, and the E, respectively, not the position of the first middle character (A)."):t.startsWith("*")?P("Multiplying the position of the second middle character by a whole number won't get the previous position where the first middle character resides in general. For example, for SCRABBLE, the second middle character is at position 4. For example, multiplying by 0 always gives you 0 (position of initial character), by 1 gives you 4 (unchanged: position of second middle character), by 2 gives you 8 (number that's out of bounds beyond the position of the last character at 7). What would you do to the 4 to get to the position of the first middle character at 3?"):P("Type the appropriate option (+ = ADD, - = SUBTRACT, * = MULTIPLY, / = DIVIDE) that you want to perform on positionOfSecondMiddleChar to calculate the position of the entered string's first middle character.")},function(e,t){var n=parseInt(t);t.startsWith('"')||t.startsWith("'")?P("Remember that positionOfSecondMiddleChar is a number and that quotes are for specific strings such as 'pizza'. Why would you subtract a specific string from a number and what would it mean?"):isNaN(n)?P("Regardless of whether the string is at, code, pizzas, scrabble, or any other string with an even number of characters (not 0), you can always subtract the same number from the position of the second middle character to get the position of the first middle character. The positions of the second middle characters and first characters are as follows (what number do you subtract from the first number to get the second?): \nat : 1 | 0\ncode : 2 | 1\npizzas : 3 | 2\nscrabble : 4 | 3"):P("If you subtract "+n+"from the position of the second middle character of SCRABBLE, you'll get 4"-n+", which is not the position of its first middle character (3). Try a different number. Also verify that it works for strings of other even lengths such as CODE.")}]);return t.error?t.match.join(""):e},init:function(){var e=this;this.appendDummyInput("STRING").appendField(new Blockly.FieldTextInput("",this.validate),"EXP"),this.setInputsInline(!1),this.setOutput(!1),this.setPreviousStatement(!0),this.setNextStatement(!0),this.setColour(60),this.setTooltip(T2C.MSG.currentLanguage.TYPEIN_STATEMENT_TOOLTIP),this.onchange=function(t){if(e.getFieldValue("EXP").endsWith("\r")||e.getFieldValue("EXP").endsWith("\n")||e.getFieldValue("EXP").length>0&&"workspaceClick"===t.element){if(!e.validate(e.getFieldValue("EXP"))||!e.getFieldValue("EXP").endsWith("1")&&!e.getFieldValue("EXP").endsWith(";"))return;var n=Object(o.getParseTree)(e.getFieldValue("EXP"));n?Object(o.handleParseTreeToBlocks)(n,e):P("Try checking what you entered again for mistakes.")}}}},Blockly.Python.type_in_get_first_middle_char=Blockly.JavaScript.type_in_get_first_middle_char=Blockly.JavaScript.code_statement,Blockly.Blocks.type_in_get_first_middle_char={validate:function(e){var t=w(e,[{token:"let",type:"terminal"},"firstMiddleChar","=","s",".",{token:"GETCHARACTERNUMBER",type:"terminal"},"(","positionOfFirstMiddleChar",")"],[I.bind(null,P,"LET"),function(){return P("Be sure to name the variable you're declaring firstMiddleChar to represent the fact that it's storing the string's first middle character.")},function(){return P("Remember to include an = after the variable firstMiddleChar you're declaring to set it to the string's first middle character.")},function(e,t){t.startsWith('"')?P("Don't use \" here as you want the computer to evaluate what you typed (e.g., the word the user entered instead of the letter s)"):t.startsWith("l")||t.startsWith("p")||t.startsWith("f")?P("To get the a character at a given position in a string, you'll first need to specify the string you want to get the first middle character from so you'll want to use s, which stores what the user entered."):P("Be sure to include the variable s that you want to the get the value's first middle character from.")},function(){return P("Be sure to include the . after the variable")},I.bind(null,P,"GETCHARACTERNUMBER"),function(e){return"You're missing an open parenthesis after "+e[5]+"."},function(e,t){t.startsWith('"')||t.startsWith("'")?P("Remember that quotes are for specific strings such as 'pizza', but you want something representing a number after the open parenthesis for "+e[5]+'. It wouldn\'t make sense to get the character at position *number* "pizza" of some string, right?'):isNaN(t)?P("You already have a variable storing the position number of the character that you want, don't you? If a variable stores the result of a valid math operation, it should be a number so you can use it here. For example, if s stores the 8-character user input SCRABBLE, s.length - 1 evaluates to 8 - 1 or 7. So if a variable positionOfLastChar is set to s.length-1, it'll store 7. You can then use s.length-1 in "+T2C.MSG.currentLanguage.TERMINAL_GETCHARACTERNUMBER+" and it'd get the 7th character. Now you don't have such a variable here, but you do have a variable that stores the position number of the first middle character, which is what you want, right?"):P("You can't use a specific number here since the position of the first middle character will depend on the length of the string entered.")},function(e,t){return P("You're missing a closing parenthesis for "+e[5]+".")}]);return t.error?t.match.join(""):e},init:function(){var e=this;this.appendDummyInput("STRING").appendField(new Blockly.FieldTextInput("",this.validate),"EXP"),this.setInputsInline(!1),this.setOutput(!1),this.setPreviousStatement(!0),this.setNextStatement(!0),this.setColour(60),this.setTooltip(T2C.MSG.currentLanguage.TYPEIN_STATEMENT_TOOLTIP),this.onchange=function(t){if(e.getFieldValue("EXP").endsWith("\r")||e.getFieldValue("EXP").endsWith("\n")||e.getFieldValue("EXP").length>0&&"workspaceClick"===t.element){if(!e.validate(e.getFieldValue("EXP"))||!e.getFieldValue("EXP").endsWith(")")&&!e.getFieldValue("EXP").endsWith(";"))return;var n=Object(o.getParseTree)(e.getFieldValue("EXP"));n?Object(o.handleParseTreeToBlocks)(n,e):P("Try checking what you entered again for mistakes.")}}}},Blockly.Python.type_in_get_second_middle_char=Blockly.JavaScript.type_in_get_second_middle_char=Blockly.JavaScript.code_statement,Blockly.Blocks.type_in_get_second_middle_char={validate:function(e){var t=w(e,[{token:"let",type:"terminal"},"secondMiddleChar","=","s",".",{token:"GETCHARACTERNUMBER",type:"terminal"},"(","positionOfSecondMiddleChar",")"],[I.bind(null,P,"LET"),function(){return P("Be sure to name the variable you're declaring secondMiddleChar to represent the fact that it's storing the string's second middle character.")},function(){return P("Remember to include an = after the variable secondMiddleChar you're declaring to set it to the string's second middle character.")},function(e,t){t.startsWith('"')?P("Don't use \" here as you want the computer to evaluate what you typed (e.g., the word the user entered instead of the letter s)"):t.startsWith("l")||t.startsWith("p")||t.startsWith("f")?P("To get the a character at a given position in a string, you'll first need to specify the string you want to get the second middle character from so you'll want to use s, which stores what the user entered."):P("Be sure to include the variable s that you want to the get the value's second middle character from.")},function(){return P("Be sure to include the . after the variable")},I.bind(null,P,"GETCHARACTERNUMBER"),function(e){return"You're missing an open parenthesis after "+e[5]+"."},function(e,t){t.startsWith('"')||t.startsWith("'")?P("Remember that quotes are for specific strings such as 'pizza', but you want something representing a number after the open parenthesis for "+e[5]+'. It wouldn\'t make sense to get the character at position *number* "pizza" of some string, right?'):isNaN(t)?P("You already have a variable storing the position number of the character that you want, don't you? If a variable stores the result of a valid math operation, it should be a number so you can use it here. For example, if s stores the 8-character user input SCRABBLE, s.length - 1 evaluates to 8 - 1 or 7. So if a variable positionOfLastChar is set to s.length-1, it'll store 7. You can then use s.length-1 in "+T2C.MSG.currentLanguage.TERMINAL_GETCHARACTERNUMBER+" and it'd get the 7th character. Now you don't have such a variable here, but you do have a variable that stores the position number of the second middle character, which is what you want, right?"):P("You can't use a specific number here since the position of the second middle character will depend on the length of the string entered.")},function(e,t){return P("You're missing a closing parenthesis for "+e[5]+".")}]);return t.error?t.match.join(""):e},init:function(){var e=this;this.appendDummyInput("STRING").appendField(new Blockly.FieldTextInput("",this.validate),"EXP"),this.setInputsInline(!1),this.setOutput(!1),this.setPreviousStatement(!0),this.setNextStatement(!0),this.setColour(60),this.setTooltip(T2C.MSG.currentLanguage.TYPEIN_STATEMENT_TOOLTIP),this.onchange=function(t){if(e.getFieldValue("EXP").endsWith("\r")||e.getFieldValue("EXP").endsWith("\n")||e.getFieldValue("EXP").length>0&&"workspaceClick"===t.element){if(!e.validate(e.getFieldValue("EXP"))||!e.getFieldValue("EXP").endsWith(")")&&!e.getFieldValue("EXP").endsWith(";"))return;var n=Object(o.getParseTree)(e.getFieldValue("EXP"));n?Object(o.handleParseTreeToBlocks)(n,e):P("Try checking what you entered again for mistakes.")}}}},Blockly.Python.type_in_combine_first_last_middle2_chars=Blockly.JavaScript.type_in_combine_first_last_middle2_chars=Blockly.JavaScript.code_statement,Blockly.Blocks.type_in_combine_first_last_middle2_chars={validate:function(e){var t=w(e,[{token:"display",type:"terminal"},"(","s","+",'"',": ",'"',"+","firstChar","+","lastChar","+","firstMiddleChar","+","secondMiddleChar",")"],[I.bind(null,P,"DISPLAY"),function(e,t){return P("You're missing an open parenthesis after "+e[0]+".")},function(){return P("First you want to display the string the user entered, which is stored in the variable s.")},function(){return P("Recall from Mission 0 that you can join strings using + .")},function(){return P("After the string the user entered, you want to literally display the separator text. Do you remember what you need to use so the string is displayed exactly as is.")},function(){return P("You want a colon followed by a space. Be sure to display both and nothing else.")},function(){return P("Remember that you'll need (to close the) quotation marks before joining it with the first character that comes next. This is because you'll want the computer to display the first character, which is stored in the variable firstChar. You don't want to literally display firstChar so it needs to be outside of quotation marks.")},function(){return P("You need to include +'s between all strings you want to join together.")},function(){return P("The first character should be displayed next. Recall that it's stored in firstChar.")},function(){return P("You need to include +'s between all strings you want to join together.")},function(){return P("The last character should be displayed next. Recall that it's stored in lastChar.")},function(){return P("You need to include +'s between all strings you want to join together.")},function(){return P("The first middle character should be displayed next. What variable stores it?")},function(){return P("You need to include +'s between all strings you want to join together.")},function(){return P("The second middle character should be displayed next. What variable stores it?")},function(e,t){return P("You're missing a closing parenthesis for "+e[0]+".")}]);return t.error?t.match.join(""):e},init:function(){var e=this;this.appendDummyInput("STRING").appendField(new Blockly.FieldTextInput("",this.validate),"EXP"),this.setInputsInline(!1),this.setOutput(!1),this.setPreviousStatement(!0),this.setNextStatement(!0),this.setColour(60),this.setTooltip(T2C.MSG.currentLanguage.TYPEIN_STATEMENT_TOOLTIP),this.onchange=function(t){if(e.getFieldValue("EXP").endsWith("\r")||e.getFieldValue("EXP").endsWith("\n")||e.getFieldValue("EXP").length>0&&"workspaceClick"===t.element){if(!e.validate(e.getFieldValue("EXP"))||!e.getFieldValue("EXP").endsWith(")")&&!e.getFieldValue("EXP").endsWith(";"))return;var n=Object(o.getParseTree)(e.getFieldValue("EXP"));n?Object(o.handleParseTreeToBlocks)(n,e):P("Try checking what you entered again for mistakes.")}}}},String.prototype.JSSubstring=function(e,t){return e>=this.length||e===t?"":this.substring(e,t)},Blockly.Python.type_in_all_but_first_specific_str=Blockly.JavaScript.type_in_all_but_first_specific_str=Blockly.JavaScript.code_statement,Blockly.Blocks.type_in_all_but_first_specific_str={validate:function(e){var t=U(e,[{token:"display",type:"terminal"},"(","welcomeMsg",".",{token:"GETTEXTFROMPOSITIONNUMBER",type:"terminal"},"(","1",")",".",{token:"TOPOSITIONNUMBER",type:"terminal"},"(","15",")",")"],[G.bind(null,$,"DISPLAY"),function(e,t){return $("You're missing an open parenthesis after "+e[0]+".")},function(){return $("Be sure to include the variable welcomeMsg that you want to extract text from.")},function(){return $("Be sure to include the . after the variable welcomeMsg you want to extract text from.")},G.bind(null,$,"GETTEXTFROMPOSITIONNUMBER"),function(e,t){return $("You're missing an open parenthesis after "+e[4]+".")},function(){return $("What position number should you start extracting from if you want to remove the initial character? Change this to the correct number.")},function(e,t){return $("You're missing a closing parenthesis for "+e[4]+" after the starting position number.")},function(){return $("Be sure to include the . after the closing parenthesis after the starting position number before the next part.")},G.bind(null,$,"TOPOSITIONNUMBER"),function(e,t){return $("You're missing an open parenthesis after "+e[9]+".")},function(){return $("What position number should you stop extracting from (stops one place before) if you want to get the rest of the string? Just use a *specific* number here. We'll generalize this so it works for other strings next. Change this to the correct number.")},function(e,t){return $("You're missing a closing parenthesis for "+e[9]+" after the ending position number.")},function(e,t){return $("You're missing a closing parenthesis for "+e[0]+".")}]);return t.error?t.match.join(""):e},init:function(){var e=this;this.appendDummyInput("STRING").appendField(new Blockly.FieldTextInput("",this.validate),"EXP"),this.setInputsInline(!1),this.setOutput(!1),this.setPreviousStatement(!0),this.setNextStatement(!0),this.setColour(60),this.setTooltip(T2C.MSG.currentLanguage.TYPEIN_STATEMENT_TOOLTIP),this.onchange=function(t){if(e.getFieldValue("EXP").endsWith("\r")||e.getFieldValue("EXP").endsWith("\n")||e.getFieldValue("EXP").length>0&&"workspaceClick"===t.element){if(!e.validate(e.getFieldValue("EXP"))||!e.getFieldValue("EXP").endsWith(")")&&!e.getFieldValue("EXP").endsWith(";"))return;var n=Object(o.getParseTree)(e.getFieldValue("EXP"));n?Object(o.handleParseTreeToBlocks)(n,e):$("Try checking what you entered again for mistakes.")}}}},Blockly.Python.type_in_all_but_first_general_str=Blockly.JavaScript.type_in_all_but_first_general_str=Blockly.JavaScript.code_statement,Blockly.Blocks.type_in_all_but_first_general_str={validate:function(e){var t=U(e,[{token:"display",type:"terminal"},"(","response",".",{token:"GETTEXTFROMPOSITIONNUMBER",type:"terminal"},"(","1",")",".",{token:"TOPOSITIONNUMBER",type:"terminal"},"(","response",".",{token:"LENGTH",type:"terminal"},")",")"],[G.bind(null,$,"DISPLAY"),function(e,t){return $("You're missing an open parenthesis after "+e[0]+".")},function(){return $("Be sure to include the variable response that you want to extract text from.")},function(){return $("Be sure to include the . after the variable response you want to extract text from.")},G.bind(null,$,"GETTEXTFROMPOSITIONNUMBER"),function(e,t){return $("You're missing an open parenthesis after "+e[4]+".")},function(){return $("What position number should you start extracting from if you want to remove the initial character? Change this to the correct number.")},function(e,t){return $("You're missing a closing parenthesis for "+e[4]+" after the starting position number.")},function(){return $("Be sure to include the . after the closing parenthesis after the starting position number before the next part.")},G.bind(null,$,"TOPOSITIONNUMBER"),function(e,t){return $("You're missing an open parenthesis after "+e[9]+".")},function(e,t){var n=parseInt(t);isNaN(n)?$("Remember the expression you used when you wanted to get the position of the last character for "+T2C.MSG.currentLanguage.TERMINAL_GETCHARACTERNUMBER+"? This is a little different because the ending position will be 1 past the position of the last character since we stop 1 place before.\nFor some examples of the numbers we'd want to use for some strings: ok: 2, theek: 5, bahut acchaa: 12"):$("Remember that since you no longer know how short or long the entered string will be, the stopping position will not always be at position "+n+". Instead, this position will depend on something about this string so your answer should refer to it.")},function(){return $("Be sure to include the . after the variable response you want to use.")},function(e,t){return $("What property of response do you want to get to determine the ending position here?")},function(e,t){-1!==t.replace(/\s/g,"").indexOf("-1")?$("Remember that "+T2C.MSG.currentLanguage.TERMINAL_GETTEXTFROMPOSITIONNUMBER+" ends one position before the numerical expression given. So for example, for a response of theek, response.length - 1 would be 5 - 1 or 4, which means you'd extract the text ending with the second e at position 3 instead of the k at position 4."):-1!==t.replace(/\s/g,"").indexOf("+1")?$("For a response of theek, response.length + 1 would be 5 + 1 or 6, but there is no 5th character since positions start at 0."):$("What you're doing to the "+T2C.MSG.currentLanguage.TERMINAL_LENGTH+" seems incorrect. Be sure to have examples in mind before deciding what to type. For example, for theek, the length is 5 and you want to go up to position 5 (since you'd stop extracting at character 4). If you're done, be sure to include a closing parenthesis for "+e[9]+" after the ending position.")},function(e,t){return $("You're missing a closing parenthesis for "+e[0]+".")}]);return t.error?t.match.join(""):e},init:function(){var e=this;this.appendDummyInput("STRING").appendField(new Blockly.FieldTextInput("",this.validate),"EXP"),this.setInputsInline(!1),this.setOutput(!1),this.setPreviousStatement(!0),this.setNextStatement(!0),this.setColour(60),this.setTooltip(T2C.MSG.currentLanguage.TYPEIN_STATEMENT_TOOLTIP),this.onchange=function(t){if(e.getFieldValue("EXP").endsWith("\r")||e.getFieldValue("EXP").endsWith("\n")||e.getFieldValue("EXP").length>0&&"workspaceClick"===t.element){if(!e.validate(e.getFieldValue("EXP"))||!e.getFieldValue("EXP").endsWith(")")&&!e.getFieldValue("EXP").endsWith(";"))return;var n=Object(o.getParseTree)(e.getFieldValue("EXP"));n?Object(o.handleParseTreeToBlocks)(n,e):$("Try checking what you entered again for mistakes.")}}}},String.prototype.JSSubstring=function(e,t){return e>=this.length||e===t?"":this.substring(e,t)},Blockly.Python.type_in_get_email_input=Blockly.JavaScript.type_in_get_email_input=Blockly.JavaScript.code_statement,Blockly.Blocks.type_in_get_email_input={validate:function(e){var t=ee(e,[{token:"let",type:"terminal"},"email","=",{token:"GETINPUTBYASKING",type:"terminal"},"(",{token:/^"[^"]*$|^'[^']*$|^"[^"]*e[-]?mail[^"]*"|^'[^']*e[-]?[^']*mail'/i,type:"regexp"},")"],[Q.bind(null,ne,"LET"),function(){return ne("Be sure to name the variable you're declaring email to represent the fact that it's storing the entered e-mail address.")},function(){return ne("Remember to include an = after the variable email you're declaring to set it to the entered e-mail address.")},Q.bind(null,ne,"GETINPUTBYASKING"),function(e){return ne("You're missing an open parenthesis after "+e[3]+".")},function(){return ne('The message to supply to the user should be surrounded by " and " because you want it to be displayed as is. Be sure it also includes e-mail in it so the user knows to enter an e-mail.')},function(e,t){return ne("You're missing a closing parenthesis for "+e[3]+".")}]);return t.error?t.match.join(""):e},init:function(){var e=this;this.appendDummyInput("STRING").appendField(new Blockly.FieldTextInput("",this.validate),"EXP"),this.setInputsInline(!1),this.setOutput(!1),this.setPreviousStatement(!0),this.setNextStatement(!0),this.setColour(60),this.setTooltip(T2C.MSG.currentLanguage.TYPEIN_STATEMENT_TOOLTIP),this.onchange=function(t){if(e.getFieldValue("EXP").endsWith("\r")||e.getFieldValue("EXP").endsWith("\n")||e.getFieldValue("EXP").length>0&&"workspaceClick"===t.element){if(!e.validate(e.getFieldValue("EXP"))||!e.getFieldValue("EXP").endsWith(")")&&!e.getFieldValue("EXP").endsWith(";"))return;var n=Object(o.getParseTree)(e.getFieldValue("EXP"));n?Object(o.handleParseTreeToBlocks)(n,e):ne("Try checking what you entered again for mistakes.")}}}},Blockly.Python.type_in_between_at_and_period=Blockly.JavaScript.type_in_between_at_and_period=Blockly.JavaScript.code_statement,Blockly.Blocks.type_in_between_at_and_period={validate:function(e){var t="coolcoder@google.com",n=ee(e,[{token:"display",type:"terminal"},"(","email",".",{token:"GETTEXTFROMPOSITIONNUMBER",type:"terminal"},"(","email",".",{token:"FINDFIRSTOCCURRENCEOFTEXT",type:"terminal"},"(",'"',"@",'"',")","+","1",")",".",{token:"TOPOSITIONNUMBER",type:"terminal"},"(","email",".",{token:"FINDFIRSTOCCURRENCEOFTEXT",type:"terminal"},"(",'"',".",'"',")",")",")"],[Q.bind(null,ne,"DISPLAY"),function(e,t){return ne("You're missing an open parenthesis after "+e[0]+".")},function(){return ne("Be sure to include the variable email that you want to extract text from.")},function(){return ne("Be sure to include the . after the variable email you want to extract text from.")},Q.bind(null,ne,"GETTEXTFROMPOSITIONNUMBER"),function(e,t){return ne("You're missing an open parenthesis after "+e[4]+".")},function(e,t){t.startsWith("(")?ne("Although you *can* have multiple opening parentheses as shown above, it's not necessary in this instance. When you first start programming, it may be good to include them to make sure operations are performed in the required order, but it can also make your code more difficult to read and correctly match the open parentheses with closing ones. Before continuing, remove the extra opening parenthesis here since you don't need it."):ne("The starting position will be as before, *the position* of the @ sign in email + 1. To get the position of the needle @ in the haystack email, we'll first need to specify the variable email to search.")},function(){return ne("Be sure to include the . after the variable email you want to search.")},Q.bind(null,ne,"FINDFIRSTOCCURRENCEOFTEXT"),function(e,t){return ne("You're missing an open parenthesis after "+e[8]+".")},function(e,t){t.startsWith("@")?ne("Since you're looking for the literal @ sign and don't want the computer to evaluate it in any way, you need to surround it with quotation marks."):ne("Since the needle you're going to use here is a literal string and not an expression, you need to surround it with quotation marks. You're currently missing quotation marks.")},function(e,t){return ne("What string do you want to get the position of to help you determine where you should start? "+(-1===t.indexOf('"')?t:t.substring(0,t.indexOf('"')))+" is not correct.")},function(e,t){return ne("You're missing closing quotation marks for "+e[e.length-1]+".")},function(e,t){t.startsWith("+")?ne("Be careful where you place the +; you certainly don't want to add a number to the string @! Instead you want to add a number to the *position* of the @ in email so it should go outside of the "+e[8]+"."):ne("You're missing a closing parenthesis for "+e[8]+".")},function(e,t){t.startsWith(")")||t.startsWith(".")?ne("You do not want to start extracting text at the @ exactly since you want to get the text *after* it. As with before, you'll want to start at the position after so you'll need to do what arithmetic operation to the position number you get?"):t.replace(/\s/g,"").startsWith("--1")?ne("Add 1 instead of subtracting -1 as this makes your code clearer."):ne("As in the previous part, what operation and number should you use on the position of the @ you get from "+T2C.MSG.currentLanguage.TERMINAL_FINDFIRSTOCCURRENCEOFTEXT+" to start at the position number after the position of the @?")},function(e,t){var n=parseInt(t);!isNaN(n)||t.startsWith("-")?ne("What number do you want to add to the position number of the first occurrence of the @ to get to the position you want to start at? Change this to the correct number."):ne(T2C.MSG.currentLanguage.TERMINAL_FINDFIRSTOCCURRENCEOFTEXT+" gives you back a number. What specific *number* do you want to add to the position number of the first occurrence of the @ to get to the position you want to start at? Change this to the correct number.")},function(e,t){return ne("You're missing a closing parenthesis for "+e[4]+" after the starting position number.")},function(){return ne("Be sure to include the . after the closing parenthesis after the starting position number before the next part.")},Q.bind(null,ne,"TOPOSITIONNUMBER"),function(e,t){return ne("You're missing an open parenthesis after "+e[e.length-1]+".")},function(e,n){var o=parseInt(n);isNaN(o)?Z(n,"FINDFIRSTOCCURRENCEOFTEXT")?ne("You'll need to refer to the variable name before using "+T2C.MSG.currentLanguage.TERMINAL_FINDFIRSTOCCURRENCEOFTEXT+" so the computer knows which string to search through (haystack) to find the given needle."):ne("The correct place to stop extracting text will depend on the e-mail address. For an email of "+t+", you'd use "+t.indexOf(".")+" (stopping before it), but for jdoe@foo.com, you'd want to use "+"jdoe@foo.com".indexOf(".")+". Since it depends on some property of the entered e-mail address, start by entering the appropriate variable name here."):ne("The correct place to stop extracting text cannot be a specific number if you want it to work in general regardless of the e-mail address. For an email of "+t+", you'd use "+t.indexOf(".")+" (stopping before it), but for jdoe@foo.com, you'd want to use "+"jdoe@foo.com".indexOf(".")+". Since it depends on some property of the entered e-mail address, start by entering the appropriate variable name here instead of a specific number.")},function(){return ne("Be sure to include the . after the variable email you want to use to refer to one of its properties.")},function(e,t){Z(t,"LENGTH")?ne("If you stop immediately before the position given by the length of the variable email, you'll get the substring of all text after the @ but you only want to get the text in between the @ and ."):Z(t,"GETCHARACTERNUMBER")?ne(T2C.MSG.currentLanguage.TERMINAL_GETCHARACTERNUMBER+" gives you a *character* at a specific position; it won't give you a number, which you need for the position to stop before for "+T2C.MSG.currentLanguage.TERMINAL_GETTEXTFROMPOSITIONNUMBER+"."):Z(t,"GETTEXTFROMPOSITIONNUMBER")?ne(T2C.MSG.currentLanguage.TERMINAL_GETTEXTFROMPOSITIONNUMBER+" gives you part of the text; you're already using that, but you want a number, which you need for the position to stop before."):ne("What property of email do you want to get to determine the ending position here? Make sure your spelling and capitalization (e.g., M versus m) are correct.")},function(e,t){return ne("You're missing an open parenthesis after "+e[e.length-1]+".")},function(e,t){t.startsWith(".")?ne("Since you're looking for the literal . and don't want the computer to evaluate it in any way, you need to surround it with quotation marks."):ne("Since the needle you're going to use here is a literal string and not an expression, you need to surround it with quotation marks. You're currently missing quotation marks.")},function(e,t){return ne("What string do you want to get the position of to help you determine where you should end?"+(-1===t.indexOf('"')?t:t.substring(0,t.indexOf('"')))+" is not correct.")},function(e,t){return ne("You're missing closing quotation marks for "+e[e.length-1]+".")},function(e,t){t.startsWith("+")||t.startsWith("-")?ne("Be careful where you place the math operation; you certainly don't want to add/subtract a number from a period! Any math you may want to do to the *position* of the period in email (which may not be necessary) should go outside of the parentheses for the character to find in "+e[18]+"."):ne("You're missing a closing parenthesis for "+e[22]+".")},function(e,n){-1!==n.replace(/\s/g,"").indexOf("-1")?ne("Remember that "+T2C.MSG.currentLanguage.TERMINAL_GETTEXTFROMPOSITIONNUMBER+" ends one position before the numerical expression given. So for example, for an e-mail of "+t+", you'd want to use "+t.indexOf(".")+" so the last character you'd extract would be at position "+(t.indexOf(".")-1)+", mainly the "+t[t.indexOf(".")-1]+" before the period. If you subtracted 1, you'd instead stop extracting text at position "+(t.indexOf(".")-2)+" so you'd instead incorrectly get the "+t[t.indexOf(".")-2]+" as the last character."):-1!==n.replace(/\s/g,"").indexOf("+1")?ne("Although "+T2C.MSG.currentLanguage.TERMINAL_GETTEXTFROMPOSITIONNUMBER+" ends one position before the numerical expression given, you want to stop before the period anyway. Adding 1 means you'll instead stop at the period. For example, for an e-mail of "+t+" the period would be located at position "+t.indexOf(".")+" so by adding 1, you'd get "+(t.indexOf(".")+1)+", which means the last character you'd extract would be at position "+t.indexOf(".")+", mainly the period itself."):ne("What you're doing to the ending position of "+T2C.MSG.currentLanguage.TERMINAL_GETTEXTFROMPOSITIONNUMBER+" seems incorrect or unnecessary. Be sure to have examples in mind before deciding what to type. If you're done, be sure to include a closing parenthesis for "+e[18]+" after the ending position.")},function(e,t){return ne("You're missing a closing parenthesis for "+e[0]+".")}]);return n.error?n.match.join(""):e},init:function(){var e=this;this.appendDummyInput("STRING").appendField(new Blockly.FieldTextInput("",this.validate),"EXP"),this.setInputsInline(!1),this.setOutput(!1),this.setPreviousStatement(!0),this.setNextStatement(!0),this.setColour(60),this.setTooltip(T2C.MSG.currentLanguage.TYPEIN_STATEMENT_TOOLTIP),this.onchange=function(t){if(e.getFieldValue("EXP").endsWith("\r")||e.getFieldValue("EXP").endsWith("\n")||e.getFieldValue("EXP").length>0&&"workspaceClick"===t.element){if(!e.validate(e.getFieldValue("EXP"))||!e.getFieldValue("EXP").endsWith(")")&&!e.getFieldValue("EXP").endsWith(";"))return;var n=Object(o.getParseTree)(e.getFieldValue("EXP"));n?Object(o.handleParseTreeToBlocks)(n,e):ne("Try checking what you entered again for mistakes.")}}}},String.prototype.JSSubstring=function(e,t){return e>=this.length||e===t?"":this.substring(e,t)},Blockly.Python.type_in_display_first_last_name=Blockly.JavaScript.type_in_display_first_last_name=Blockly.JavaScript.code_statement,Blockly.Blocks.type_in_display_first_last_name={validate:function(e){var t=le(e,[{token:"display",type:"terminal"},"(","firstName","+",{token:/^" "|^' '/,type:"regexp"},"+","lastName",")"],[ae.bind(null,ue,"DISPLAY"),function(e,t){return ue("You're missing an open parenthesis after "+e[0]+".")},function(e,t){t.startsWith('"')||t.startsWith("'")?ue("If you're using variable names to be evaluated instead of displayed as is (e.g., displaying the text Jane instead of the text firstName), you don't want to use quotation marks."):ue('Remember the variable names are firstName and lastName. If firstName = "Jane" and lastName = "Doe" and you want to display "Jane Doe", what should be displayed first?')},function(){return ue("How do you join strings together?")},function(e,t){"lastName".toLowerCase().startsWith(t.toLowerCase())||t.toLowerCase().startsWith("lastName".toLowerCase())?ue('Remember that you\'ll want a space between the first and last name; joining the two strings together without one would result in "JaneDoe" instead of say "Jane Doe".'):ue("Remember that you want to *literally* display a space between the first and last name. What do you need to surround text with (including spaces) when you want to display something without evaluating it?")},function(){return ue("How do you join strings together?")},function(e,t){t.startsWith('"')||t.startsWith("'")?ue("If you're using variable names to be evaluated instead of displayed as is (e.g., displaying the text Doe instead of the text lastName), you don't want to use quotation marks."):ue('Remember the variable names are firstName and lastName. If firstName = "Jane" and lastName = "Doe" and you want to display "Jane Doe", what should be displayed last?')},function(e,t){return ue("You're missing a closing parenthesis for "+e[0]+".")}]);return t.error?t.match.join(""):e},init:function(){var e=this;this.appendDummyInput("STRING").appendField(new Blockly.FieldTextInput("",this.validate),"EXP"),this.setInputsInline(!1),this.setOutput(!1),this.setPreviousStatement(!0),this.setNextStatement(!0),this.setColour(60),this.setTooltip(T2C.MSG.currentLanguage.TYPEIN_STATEMENT_TOOLTIP),this.onchange=function(t){if(e.getFieldValue("EXP").endsWith("\r")||e.getFieldValue("EXP").endsWith("\n")||e.getFieldValue("EXP").length>0&&"workspaceClick"===t.element){if(!e.validate(e.getFieldValue("EXP"))||!e.getFieldValue("EXP").endsWith(")")&&!e.getFieldValue("EXP").endsWith(";"))return;var n=Object(o.getParseTree)(e.getFieldValue("EXP"));n?Object(o.handleParseTreeToBlocks)(n,e):ue("Try checking what you entered again for mistakes.")}}}},Blockly.Python.type_in_set_last_name=Blockly.JavaScript.type_in_set_last_name=Blockly.JavaScript.code_statement,Blockly.Blocks.type_in_set_last_name={validate:function(e){"Doe, Jane".substring(0,"Doe, Jane".indexOf(",")),"Doe, Jane".substring("Doe, Jane".indexOf(",")+2),"Doe, Jane".substring(0,"Doe, Jane".indexOf(",")),"Doe, Jane".substring("Doe, Jane".indexOf(",")+2);var t=le(e,[{token:"let",type:"terminal"},"lastName","=","enteredName",".",{token:"GETTEXTFROMPOSITIONNUMBER",type:"terminal"},"(","0",")",".",{token:"TOPOSITIONNUMBER",type:"terminal"},"(","commaPosition",")"],[ae.bind(null,ue,"LET"),function(){return ue("Be sure to name the variable you're declaring lastName to represent the fact that it should store the last name if the user entered the input in the correct form. Since you use lastName in the "+T2C.MSG.currentLanguage.TERMINAL_DISPLAY+" statement, you need to use lastName here.")},function(){return ue("Remember to include an = after the variable lastName you're declaring to set it to the value that follows.")},function(){return ue("Be sure to include the variable enteredName that you want to extract text from.")},function(){return ue("Be sure to include the . after the variable enteredName you want to extract text from.")},ae.bind(null,ue,"GETTEXTFROMPOSITIONNUMBER"),function(e,t){return ue("You're missing an open parenthesis after "+e[5]+".")},function(e,t){t.startsWith("(")?ue("Although you *can* have multiple opening parentheses, it's not necessary in this instance. When you first start programming, it may be good to include them to make sure operations are performed in the required order, but it can also make your code more difficult to read and correctly match the open parentheses with closing ones. Before continuing, remove the extra opening parenthesis here since you don't need it."):1===parseInt(t)?ue("Remember that positions start at 0."):parseInt(t)?ue("The last name starts at the beginning of the string. What number should you use if you want to start extracting text there?"):ue("The last name starts at the beginning of the string so regardless of the string the user enters, the numerical position will always be the same. Use a specific number, accordingly.")},function(e,t){return ue("You're missing a closing parenthesis for "+e[5]+" after the starting position number.")},function(){return ue("Be sure to include the . after the closing parenthesis after the starting position number before the next part.")},ae.bind(null,ue,"TOPOSITIONNUMBER"),function(e,t){return ue("You're missing an open parenthesis after "+e[e.length-1]+".")},function(e,t){var n=parseInt(t);isNaN(n)?re(t,"FINDFIRSTOCCURRENCEOFTEXT")?ue("You'd need to refer to the variable name before using "+T2C.MSG.currentLanguage.TERMINAL_FINDFIRSTOCCURRENCEOFTEXT+" so the computer knows which string to search through (haystack) to find the given needle, but remember that you're already assuming you have a variable that stores the position of the comma, which might help..."):ue("For an entered name of Doe, Jane, you'd use "+"Doe, Jane".indexOf(",")+" (stopping before it), but for Torvalds, Linus, you'd want to use "+"Torvalds, Linus".indexOf(",")+". Since it depends on the position of the comma, start by entering the appropriate variable name here."):ue("The correct place to stop extracting text cannot be a specific number if you want it to work in general regardless of the entered name. For an entered name of Doe, Jane, you'd use "+"Doe, Jane".indexOf(",")+" (stopping before it), but for Torvalds, Linus, you'd want to use "+"Torvalds, Linus".indexOf(",")+". Since it depends on the position of the comma, start by entering the appropriate variable name here instead of a specific number.")},function(e,t){-1!==t.replace(/\s/g,"").indexOf("-1")?ue("Remember that "+T2C.MSG.currentLanguage.TERMINAL_GETTEXTFROMPOSITIONNUMBER+" ends one position before the numerical expression given. So for example, for an entered name of Doe, Jane, you'd want to use "+"Doe, Jane".indexOf(",")+" so the last character you'd extract would be at position "+("Doe, Jane".indexOf(",")-1)+", mainly the "+"Doe, Jane"["Doe, Jane".indexOf(",")-1]+" before the comma. If you subtracted 1, you'd instead stop extracting text at position "+("Doe, Jane".indexOf(",")-2)+" so you'd instead incorrectly get the "+"Doe, Jane"["Doe, Jane".indexOf(",")-2]+" as the last character."):-1!==t.replace(/\s/g,"").indexOf("+1")?ue("Although "+T2C.MSG.currentLanguage.TERMINAL_GETTEXTFROMPOSITIONNUMBER+" ends one position before the numerical expression given, you want to stop before the comma anyway. Adding 1 means you'll instead stop at the comma. For example, for an entered name of Doe, Jane the comma would be located at position "+"Doe, Jane".indexOf(",")+" so by adding 1, you'd get "+("Doe, Jane".indexOf(",")+1)+", which means the last character you'd extract would be at position "+"Doe, Jane".indexOf(",")+", mainly the comma itself."):ue("What you're doing to the ending position of "+T2C.MSG.currentLanguage.TERMINAL_GETTEXTFROMPOSITIONNUMBER+" seems incorrect or unnecessary. Be sure to have examples in mind before deciding what to type. If you're done, be sure to include a closing parenthesis for "+e[10]+" after the ending position.")}]);return t.error?t.match.join(""):e},init:function(){var e=this;this.appendDummyInput("STRING").appendField(new Blockly.FieldTextInput("",this.validate),"EXP"),this.setInputsInline(!1),this.setOutput(!1),this.setPreviousStatement(!0),this.setNextStatement(!0),this.setColour(60),this.setTooltip(T2C.MSG.currentLanguage.TYPEIN_STATEMENT_TOOLTIP),this.onchange=function(t){if(e.getFieldValue("EXP").endsWith("\r")||e.getFieldValue("EXP").endsWith("\n")||e.getFieldValue("EXP").length>0&&"workspaceClick"===t.element){if(!e.validate(e.getFieldValue("EXP"))||!e.getFieldValue("EXP").endsWith(")")&&!e.getFieldValue("EXP").endsWith(";"))return;var n=Object(o.getParseTree)(e.getFieldValue("EXP"));n?Object(o.handleParseTreeToBlocks)(n,e):ue("Try checking what you entered again for mistakes.")}}}},Blockly.Python.type_in_set_first_name=Blockly.JavaScript.type_in_set_first_name=Blockly.JavaScript.code_statement,Blockly.Blocks.type_in_set_first_name={validate:function(e){var t="Torvalds, Linus",n=("Doe, Jane".substring(0,"Doe, Jane".indexOf(",")),"Doe, Jane".substring("Doe, Jane".indexOf(",")+2)),o=(t.substring(0,t.indexOf(",")),t.substring(t.indexOf(",")+2)),i=le(e,[{token:"let",type:"terminal"},"firstName","=","enteredName",".",{token:"GETTEXTFROMPOSITIONNUMBER",type:"terminal"},"(","commaPosition","+","2",")",".",{token:"TOPOSITIONNUMBER",type:"terminal"},"(","enteredName",".",{token:"LENGTH",type:"terminal"},")"],[ae.bind(null,ue,"LET"),function(){return ue("Be sure to name the variable you're declaring firstName to represent the fact that it should store the first name if the user entered the input in the correct form. Since you use firstName in the "+T2C.MSG.currentLanguage.TERMINAL_DISPLAY+" statement, you need to use firstName here.")},function(){return ue("Remember to include an = after the variable firstName you're declaring to set it to first name.")},function(){return ue("Be sure to include the variable enteredName that you want to extract text from.")},function(){return ue("Be sure to include the . after the variable enteredName you want to extract text from.")},ae.bind(null,ue,"GETTEXTFROMPOSITIONNUMBER"),function(e,t){return ue("You're missing an open parenthesis after "+e[5]+".")},function(e,n){var o=parseInt(n);isNaN(o)?re(n,"FINDFIRSTOCCURRENCEOFTEXT")?ue("You'd need to refer to the variable name before using "+T2C.MSG.currentLanguage.TERMINAL_FINDFIRSTOCCURRENCEOFTEXT+" so the computer knows which string to search through (haystack) to find the given needle, but remember that you're already assuming you have a variable that stores the position of the comma, which might help..."):ue("For an entered name of Doe, Jane, you'd use "+("Doe, Jane".indexOf(",")+2)+", but for "+t+", you'd want to use "+(t.indexOf(",")+2)+". Since it depends on the position of the comma, start by entering the appropriate variable name here."):ue("The correct place to start extracting text cannot be a specific number if you want it to work in general regardless of the entered name. For an entered name of Doe, Jane, you'd use "+("Doe, Jane".indexOf(",")+2)+", but for "+t+", you'd want to use "+(t.indexOf(",")+2)+". Since it depends on the position of the comma, start by entering the appropriate variable name here instead of a specific number.")},function(e,i){i.startsWith(")")||i.startsWith(".")?ue("You do not want to start extracting text at the comma exactly since you want to get the text *after* the space that follows it. What arithmetic operation do you want to perform on the position number you get and with what number to start at the character after the space after the comma? For Doe, Jane, the comma position will be at "+"Doe, Jane".indexOf(",")+" but you'll want to start at position "+("Doe, Jane".indexOf(",")+2)+", with "+n[0]+" whereas for "+t+", the comma position will be at "+t.indexOf(",")+" but you'll want to start at position "+(t.indexOf(",")+2)+", with "+o[0]+"."):i.replace(/\s/g,"").startsWith("--2")?ue("Add 2 instead of subtracting -2 as this makes your code clearer."):ue("What arithmetic operation do you want to perform on the position number you get and with what number to start at the character after the space after the comma? For Doe, Jane, the comma position will be at "+"Doe, Jane".indexOf(",")+" but you'll want to start at position "+("Doe, Jane".indexOf(",")+2)+", with "+n[0]+" whereas for "+t+", the comma position will be at "+t.indexOf(",")+" but you'll want to start at position "+(t.indexOf(",")+2)+", with "+o[0]+".")},function(e,i){var r=parseInt(i);!isNaN(r)||i.startsWith("-")?ue(1===r?"Remember that there's a space after the comma and you don't want to start with the space. What number do you want to add to the position number of the first occurrence of the , to get to the position you want to start at? For Doe, Jane, the comma position will be at "+"Doe, Jane".indexOf(",")+" but you'll want to start at position "+("Doe, Jane".indexOf(",")+2)+", with "+n[0]+" whereas for "+t+", the comma position will be at "+t.indexOf(",")+" but you'll want to start at position "+(t.indexOf(",")+2)+", with "+o[0]+". Change this to the correct number, accordingly.":"What number do you want to add to the position number of the first occurrence of the , to get to the position you want to start at? For Doe, Jane, the comma position will be at "+"Doe, Jane".indexOf(",")+" but you'll want to start at position "+("Doe, Jane".indexOf(",")+2)+", with "+n[0]+" whereas for "+t+", the comma position will be at "+t.indexOf(",")+" but you'll want to start at position "+(t.indexOf(",")+2)+", with "+o[0]+". Change this to the correct number, accordingly."):ue("If the name is entered correctly as e.g., Doe, Jane or "+t+", then the number of places the last name will be beyond the position of the comma will always be the same so you can enter a *specific* number. For Doe, Jane, the comma position will be at "+"Doe, Jane".indexOf(",")+" but you'll want to start at position "+("Doe, Jane".indexOf(",")+2)+", with "+n[0]+" whereas for "+t+", the comma position will be at "+t.indexOf(",")+" but you'll want to start at position "+(t.indexOf(",")+2)+", with "+o[0]+". Change your answer to the specific number you can add in both cases, accordingly.")},function(e,t){return ue("You're missing a closing parenthesis for "+e[5]+" after the starting position number.")},function(){return ue("Be sure to include the . after the closing parenthesis after the starting position number before the next part.")},ae.bind(null,ue,"TOPOSITIONNUMBER"),function(e,t){return ue("You're missing an open parenthesis after "+e[e.length-1]+".")},function(e,n){var o=parseInt(n);isNaN(o)?n.startsWith("commaPosition")||"commaPosition".startsWith(n)?ue("You don't want to stop extracting text at commaPosition, do you?"):ue("If entered correctly, the end of the first name will be at the end of the entered string. For Doe, Jane, you'd use "+"Doe, Jane".length+" while for "+t+", you'd use "+t.length+", the position number after the last character. Since this position number will depend on something about the entered name, your answer should refer to it."):ue("The stopping position will not always be at position "+o+". Instead, this position will depend on something about the entered name so your answer should refer to it.")},function(){return ue("Be sure to include the . after the variable enteredName you want to use.")},function(e,n){return ue("If entered correctly, the end of the first name will be at the end of the entered string. For Doe, Jane, you'd use "+"Doe, Jane".length+" while for "+t+", you'd use "+t.length+", the position number after the last character. Do you remember how you can get these positions from the entered name?")},function(e,t){-1!==t.replace(/\s/g,"").indexOf("-1")?ue("Remember that "+T2C.MSG.currentLanguage.TERMINAL_GETTEXTFROMPOSITIONNUMBER+" ends one position before the numerical expression given. So for example, for an enteredName of Doe, Jane, sampleInput.length - 1 would be "+("Doe, Jane".length-1)+", which means you'd extract the text ending with the "+"Doe, Jane".charAt("Doe, Jane".length-2)+" instead of the last character of "+"Doe, Jane".charAt("Doe, Jane".length-1)+"."):-1!==t.replace(/\s/g,"").indexOf("+1")?ue("For an enteredName of Doe, Jane, enteredName.length + 1 would be "+("Doe, Jane".length+1)+", but there is no character at this position since positions start at 0."):ue("What you're doing to the "+T2C.MSG.currentLanguage.TERMINAL_LENGTH+" seems incorrect. Be sure to have examples in mind before deciding what to type. For example, for Doe, Jane, the length is "+"Doe, Jane".length+" and you want to go up to position "+"Doe, Jane".length+" (since you'd stop extracting at character "+("Doe, Jane".length-1)+"). If you're done, be sure to include a closing parenthesis for "+e[12]+" after the ending position.")}]);return i.error?i.match.join(""):e},init:function(){var e=this;this.appendDummyInput("STRING").appendField(new Blockly.FieldTextInput("",this.validate),"EXP"),this.setInputsInline(!1),this.setOutput(!1),this.setPreviousStatement(!0),this.setNextStatement(!0),this.setColour(60),this.setTooltip(T2C.MSG.currentLanguage.TYPEIN_STATEMENT_TOOLTIP),this.onchange=function(t){if(e.getFieldValue("EXP").endsWith("\r")||e.getFieldValue("EXP").endsWith("\n")||e.getFieldValue("EXP").length>0&&"workspaceClick"===t.element){if(!e.validate(e.getFieldValue("EXP"))||!e.getFieldValue("EXP").endsWith(")")&&!e.getFieldValue("EXP").endsWith(";"))return;var n=Object(o.getParseTree)(e.getFieldValue("EXP"));n?Object(o.handleParseTreeToBlocks)(n,e):ue("Try checking what you entered again for mistakes.")}}}},Blockly.Python.type_in_set_comma_pos=Blockly.JavaScript.type_in_set_comma_pos=Blockly.JavaScript.code_statement,Blockly.Blocks.type_in_set_comma_pos={validate:function(e){var t=le(e,[{token:"let",type:"terminal"},"commaPosition","=","enteredName",".",{token:"FINDFIRSTOCCURRENCEOFTEXT",type:"terminal"},"(",{token:/",[ ]?"|',[ ]?'/,type:"regexp"},")"],[ae.bind(null,ue,"LET"),function(){return ue("Be sure to name the variable you're declaring commaPosition to represent the fact that it should store the position of the comma. Since you use commaPosition in the assignment of firstName and lastName, you need to use commaPosition here as well.")},function(){return ue("Remember to include an = after the variable commaPosition you're declaring to set it to a value.")},function(){return ue("Be sure to include the variable enteredName that you want to get the position of the comma from.")},function(){return ue("Be sure to include the . after the variable enteredName you want to get the comma from.")},ae.bind(null,ue,"FINDFIRSTOCCURRENCEOFTEXT"),function(e,t){return ue("You're missing an open parenthesis after "+e[5]+".")},function(e,t){t.startsWith(",")?ue("Since you're looking for the literal , and don't want the computer to evaluate it in any way, you need to surround it with quotation marks."):t.startsWith("'")||t.startsWith('"')?","!==t[1]?ue("What string literal are you getting the position for?"):ue("You're only looking for the comma, correct? If so, remember to close the quotation marks."):ue("Since the needle you're going to use here is a literal string and not an expression, you need to surround it with quotation marks. You're currently missing quotation marks.")},function(e,t){return ue("You're missing a closing parenthesis for "+e[5]+".")}]);return t.error?t.match.join(""):e},init:function(){var e=this;this.appendDummyInput("STRING").appendField(new Blockly.FieldTextInput("",this.validate),"EXP"),this.setInputsInline(!1),this.setOutput(!1),this.setPreviousStatement(!0),this.setNextStatement(!0),this.setColour(60),this.setTooltip(T2C.MSG.currentLanguage.TYPEIN_STATEMENT_TOOLTIP),this.onchange=function(t){if(e.getFieldValue("EXP").endsWith("\r")||e.getFieldValue("EXP").endsWith("\n")||e.getFieldValue("EXP").length>0&&"workspaceClick"===t.element){if(!e.validate(e.getFieldValue("EXP"))||!e.getFieldValue("EXP").endsWith(")")&&!e.getFieldValue("EXP").endsWith(";"))return;var n=Object(o.getParseTree)(e.getFieldValue("EXP"));n?Object(o.handleParseTreeToBlocks)(n,e):ue("Try checking what you entered again for mistakes.")}}}},Blockly.Python.type_in_get_last_first_name_input=Blockly.JavaScript.type_in_get_last_first_name_input=Blockly.JavaScript.code_statement,Blockly.Blocks.type_in_get_last_first_name_input={validate:function(e){var t=le(e,[{token:"let",type:"terminal"},"enteredName","=",{token:"GETINPUTBYASKING",type:"terminal"},"(",{token:/^"[^"]*$|^'[^']*$|^"[^"]*name[^"]*"|^'[^']*name[^']*'/i,type:"regexp"},")"],[ae.bind(null,ue,"LET"),function(){return ue("Be sure to name the variable you're declaring enteredName to represent the fact that it's storing the entered name.")},function(){return ue("Remember to include an = after the variable enteredName you're declaring to set it to the entered name.")},ae.bind(null,ue,"GETINPUTBYASKING"),function(e){return ue("You're missing an open parenthesis after "+e[3]+".")},function(){return ue('The message to supply to the user should be surrounded by " and " because you want it to be displayed as is. Be sure it also includes name in it so the user knows to enter a name. You\'ll also want to indicate the form: last name, first name, perhaps with an example (e.g., Doe, Jane).')},function(e,t){return ue("You're missing a closing parenthesis for "+e[3]+".")}]);return t.error?t.match.join(""):e},init:function(){var e=this;this.appendDummyInput("STRING").appendField(new Blockly.FieldTextInput("",this.validate),"EXP"),this.setInputsInline(!1),this.setOutput(!1),this.setPreviousStatement(!0),this.setNextStatement(!0),this.setColour(60),this.setTooltip(T2C.MSG.currentLanguage.TYPEIN_STATEMENT_TOOLTIP),this.onchange=function(t){if(e.getFieldValue("EXP").endsWith("\r")||e.getFieldValue("EXP").endsWith("\n")||e.getFieldValue("EXP").length>0&&"workspaceClick"===t.element){if(!e.validate(e.getFieldValue("EXP"))||!e.getFieldValue("EXP").endsWith(")")&&!e.getFieldValue("EXP").endsWith(";"))return;var n=Object(o.getParseTree)(e.getFieldValue("EXP"));n?Object(o.handleParseTreeToBlocks)(n,e):ue("Try checking what you entered again for mistakes.")}}}},String.prototype.JSSubstring=function(e,t){return e>=this.length||e===t?"":this.substring(e,t)},Blockly.Python.type_in_get_input_with_s=Blockly.JavaScript.type_in_get_input_with_s=Blockly.JavaScript.code_statement,Blockly.Blocks.type_in_get_input_with_s={validate:function(e){var t=pe(e,[{token:"let",type:"terminal"},"enteredTextWithS","=",T2C.MSG.JS.TERMINAL_GETINPUTBYASKING,"(",{token:/^"[^"]*$|^'[^']*$|^"[^"]*with an s[^"]*"|^'[^']*with an s[^']*'/i,type:"regexp"},")"],[he.bind(null,me,"LET"),function(){return me("Be sure to name the variable you're declaring enteredTextWithS.")},function(){return me("Remember to include an = after the variable enteredTextWithS to set it to a value.")},he.bind(null,me,"GETINPUTBYASKING"),function(e){return me("You're missing an open parenthesis after "+e[3]+".")},function(){return me("The message to supply to the user should be surrounded by \" and \" because you want it to be displayed as is. Be sure it also includes the text 'with an s' in it so the user knows that the string he/she enters must contain an s.")},function(e,t){return me("You're missing a closing parenthesis for "+e[3]+".")}]);return t.error?t.match.join(""):e},init:function(){var e=this;this.appendDummyInput("STRING").appendField(new Blockly.FieldTextInput("",this.validate),"EXP"),this.setInputsInline(!1),this.setOutput(!1),this.setPreviousStatement(!0),this.setNextStatement(!0),this.setColour(60),this.setTooltip(T2C.MSG.currentLanguage.TYPEIN_STATEMENT_TOOLTIP),this.onchange=function(t){if(e.getFieldValue("EXP").endsWith("\r")||e.getFieldValue("EXP").endsWith("\n")||e.getFieldValue("EXP").length>0&&"workspaceClick"===t.element){if(!e.validate(e.getFieldValue("EXP"))||!e.getFieldValue("EXP").endsWith(")")&&!e.getFieldValue("EXP").endsWith(";"))return;var n=Object(o.getParseTree)(e.getFieldValue("EXP"));n?Object(o.handleParseTreeToBlocks)(n,e):me("Try checking what you entered again for mistakes.")}}}},Blockly.Python.type_in_set_s_pos=Blockly.JavaScript.type_in_set_s_pos=Blockly.JavaScript.code_statement,Blockly.Blocks.type_in_set_s_pos={validate:function(e){var t=pe(e,[{token:"let",type:"terminal"},"sPosition","=","enteredTextWithS",".",T2C.MSG.JS.TERMINAL_FINDFIRSTOCCURRENCEOFTEXT,"(",{token:/"s"|'s'/,type:"regexp"},")"],[he.bind(null,me,"LET"),function(){return me("Be sure to name the variable you're declaring _Position to represent the fact that it should store the position of the first _ (where _ is replaced with the character you're looking for).")},function(){return me("Remember to include an = after the variable sPosition you're declaring to set it to a value.")},function(){return me("Be sure to include the variable enteredTextWithS that you want to get the position of the s from.")},function(){return me("Be sure to include the . after the variable enteredTextWithS you want to get the position of the first s from.")},he.bind(null,me,"FINDFIRSTOCCURRENCEOFTEXT"),function(e,t){return me("You're missing an open parenthesis after "+e[5]+".")},function(e,t){t.startsWith("s")?me("Since you're looking for the literal s and don't want the computer to evaluate it in any way, you need to surround it with quotation marks."):t.startsWith("'")||t.startsWith('"')?"s"!==t[1]?me("What string literal are you getting the position for?"):me("You're only looking for the first s, correct? If so, remember to close the quotation marks."):me("Since the needle you're going to use here is a literal string and not an expression, you need to surround it with quotation marks. You're currently missing quotation marks.")},function(e,t){return me("You're missing a closing parenthesis for "+e[5]+".")}]);return t.error?t.match.join(""):e},init:function(){var e=this;this.appendDummyInput("STRING").appendField(new Blockly.FieldTextInput("",this.validate),"EXP"),this.setInputsInline(!1),this.setOutput(!1),this.setPreviousStatement(!0),this.setNextStatement(!0),this.setColour(60),this.setTooltip(T2C.MSG.currentLanguage.TYPEIN_STATEMENT_TOOLTIP),this.onchange=function(t){if(e.getFieldValue("EXP").endsWith("\r")||e.getFieldValue("EXP").endsWith("\n")||e.getFieldValue("EXP").length>0&&"workspaceClick"===t.element){if(!e.validate(e.getFieldValue("EXP"))||!e.getFieldValue("EXP").endsWith(")")&&!e.getFieldValue("EXP").endsWith(";"))return;var n=Object(o.getParseTree)(e.getFieldValue("EXP"));n?Object(o.handleParseTreeToBlocks)(n,e):me("Try checking what you entered again for mistakes.")}}}},Blockly.Python.type_in_set_before_s=Blockly.JavaScript.type_in_set_before_s=Blockly.JavaScript.code_statement,Blockly.Blocks.type_in_set_before_s={validate:function(e){var t="Mississippi",n=(t.substring(0,t.indexOf("s")),t.substring(t.indexOf("s")+1),t.substring(0,t.indexOf("s")),t.substring(t.indexOf("s")+1),pe(e,[{token:"let",type:"terminal"},"beforeS","=","enteredTextWithS",".",T2C.MSG.JS.TERMINAL_GETTEXTFROMPOSITIONNUMBER,"(","0",",","sPosition",")"],[he.bind(null,me,"LET"),function(){return me("Be sure to name the variable you're declaring beforeS to represent the fact that it should store the text before the first occurrence of the s in the entered text.")},function(){return me("Remember to include an = after the variable beforeS you're declaring to set it to the value that follows.")},function(){return me("Be sure to include the variable enteredTextWithS that you want to extract text from.")},function(){return me("Be sure to include the . after the variable enteredTextWithS you want to extract text from.")},he.bind(null,me,"GETTEXTFROMPOSITIONNUMBER"),function(e,t){return me("You're missing an open parenthesis after "+e[5]+".")},function(e,t){t.startsWith("(")?me("Although you *can* have multiple opening parentheses, it's not necessary in this instance. When you first start programming, it may be good to include them to make sure operations are performed in the required order, but it can also make your code more difficult to read and correctly match the open parentheses with closing ones. Before continuing, remove the extra opening parenthesis here since you don't need it."):1===parseInt(t)?me("Remember that positions start at 0."):parseInt(t)?me("The text occurring before the first s starts at the beginning of the string. What number should you use if you want to start extracting text there?"):me("The text occurring before the first s starts at the beginning of the string so regardless of the string the user enters, the numerical position will always be the same. Use a specific number, accordingly.")},function(e){return me("You're missing a comma after the starting position. In "+T2C.MSG.currentLanguage.LANGUAGE_NAME+", you put the starting and ending positions in the same parentheses when using "+e[5]+". The comma is used to separate the two positions with the starting position first and the ending position second in order for the computer to know which is which.")},function(e,n){var o=parseInt(n);isNaN(o)?de(n,"FINDFIRSTOCCURRENCEOFTEXT")?me("You'd need to refer to the variable name before using "+T2C.MSG.currentLanguage.TERMINAL_FINDFIRSTOCCURRENCEOFTEXT+" so the computer knows which string to search through (haystack) to find the given needle, but remember that you're already assuming you have a variable that stores the position of the first s, which might help..."):me("For an entered string of "+t+", you'd use "+t.indexOf("s")+" (stopping before it), but for sorry, you'd want to use "+"sorry".indexOf("s")+". Since it depends on the position of the first s, start by entering the appropriate variable name here."):me("The correct place to stop extracting text cannot be a specific number if you want it to work in general regardless of the entered string with an s. For an entered string of "+t+", you'd use "+t.indexOf("s")+" (stopping before it), but for sorry, you'd want to use "+"sorry".indexOf("s")+". Since it depends on the position of the first s, start by entering the appropriate variable name here instead of a specific number.")},function(e,n){-1!==n.replace(/\s/g,"").indexOf("-1")?me("Remember that "+e[5]+" ends one position before the numerical expression given. So for example, for an entered text of "+t+", you'd want to use "+t.indexOf("s")+" so the last character you'd extract would be at position "+(t.indexOf("s")-1)+", mainly the "+t[t.indexOf("s")-1]+" before the first s. If you subtracted 1, you'd instead stop extracting text at position "+(t.indexOf("s")-2)+" so you'd instead incorrectly get the "+t[t.indexOf("s")-2]+" as the last character."):-1!==n.replace(/\s/g,"").indexOf("+1")?me("Although "+T2C.MSG.currentLanguage.TERMINAL_GETTEXTFROMPOSITIONNUMBER+" ends one position before the numerical expression given, you want to stop before the first s anyway. Adding 1 means you'll instead stop at the s. For example, for an entered string of "+t+" the first s would be located at position "+t.indexOf("s")+" so by adding 1, you'd get "+(t.indexOf("s")+1)+", which means the last character you'd extract would be at position "+t.indexOf("s")+", mainly the s itself."):me("What you're doing to the ending position of "+T2C.MSG.currentLanguage.TERMINAL_GETTEXTFROMPOSITIONNUMBER+" seems incorrect or unnecessary. Be sure to have examples in mind before deciding what to type. If you're done, be sure to include a closing parenthesis for "+e[5]+" after the ending position.")}]));return n.error?n.match.join(""):e},init:function(){var e=this;this.appendDummyInput("STRING").appendField(new Blockly.FieldTextInput("",this.validate),"EXP"),this.setInputsInline(!1),this.setOutput(!1),this.setPreviousStatement(!0),this.setNextStatement(!0),this.setColour(60),this.setTooltip(T2C.MSG.currentLanguage.TYPEIN_STATEMENT_TOOLTIP),this.onchange=function(t){if(e.getFieldValue("EXP").endsWith("\r")||e.getFieldValue("EXP").endsWith("\n")||e.getFieldValue("EXP").length>0&&"workspaceClick"===t.element){if(!e.validate(e.getFieldValue("EXP"))||!e.getFieldValue("EXP").endsWith(")")&&!e.getFieldValue("EXP").endsWith(";"))return;var n=Object(o.getParseTree)(e.getFieldValue("EXP"));n?Object(o.handleParseTreeToBlocks)(n,e):me("Try checking what you entered again for mistakes.")}}}},Blockly.Python.type_in_set_after_s=Blockly.JavaScript.type_in_set_after_s=Blockly.JavaScript.code_statement,Blockly.Blocks.type_in_set_after_s={validate:function(e){var t="Mississippi",n=(t.substring(0,t.indexOf("s")),t.substring(t.indexOf("s")+1)),o=("sorry".substring(0,t.indexOf("s")),"sorry".substring(t.indexOf("s")+1)),i=pe(e,[{token:"let",type:"terminal"},"afterS","=","enteredTextWithS",".",T2C.MSG.JS.TERMINAL_GETTEXTFROMPOSITIONNUMBER,"(","sPosition","+","1",",","enteredTextWithS",".",{token:"LENGTH",type:"terminal"},")"],[he.bind(null,me,"LET"),function(){return me("Be sure to name the variable you're declaring afterS to represent the fact that it should store the text after the s from the user input.")},function(){return me("Remember to include an = after the variable afterS you're declaring to set it to the value that follows.")},function(){return me("Be sure to include the variable enteredTextWithS that you want to extract text from.")},function(){return me("Be sure to include the . after the variable enteredTextWithS you want to extract text from.")},he.bind(null,me,"GETTEXTFROMPOSITIONNUMBER"),function(e,t){return me("You're missing an open parenthesis after "+e[5]+".")},function(e,n){var o=parseInt(n);isNaN(o)?de(n,"FINDFIRSTOCCURRENCEOFTEXT")?me("You'd need to refer to the variable name before using "+T2C.MSG.currentLanguage.TERMINAL_FINDFIRSTOCCURRENCEOFTEXT+" so the computer knows which string to search through (haystack) to find the given needle, but remember that you already have a variable that stores the position of the first s, which might help..."):me("For an entered string of "+t+", you'd use "+(t.indexOf("s")+1)+", but for sorry, you'd want to use "+("sorry".indexOf("s")+1)+". Since it depends on the position of the first s, start by entering the appropriate variable name here."):me("The correct place to start extracting text cannot be a specific number if you want it to work in general regardless of the entered string containing an s. For an entered string of "+t+", you'd use "+(t.indexOf("s")+1)+", but for sorry, you'd want to use "+("sorry".indexOf("s")+1)+". Since it depends on the position of the s, start by entering the appropriate variable name here instead of a specific number.")},function(e,i){i.startsWith(")")||i.startsWith(",")?me("You do not want to start extracting text at the first occurrence of the s exactly since you want to get the text that immediately follows it. What arithmetic operation do you want to perform on the position number you get and with what number to start at the character after the s? For "+t+", the position of the first s will be at "+t.indexOf("s")+" but you'll want to start at position "+(t.indexOf("s")+1)+", with the second "+n[0]+" whereas for sorry, the position of the first s will be at "+"sorry".indexOf("s")+" but you'll want to start at position "+("sorry".indexOf("s")+1)+", with "+o[0]+"."):i.replace(/\s/g,"").startsWith("--1")?me("Add 1 instead of subtracting -1 as this makes your code clearer."):me("What arithmetic operation do you want to perform on the position number you get and with what number to start at the character after the s? For "+t+", the position of the first s will be at "+t.indexOf("s")+" but you'll want to start at position "+(t.indexOf("s")+1)+", with the second "+n[0]+" whereas for sorry, the position of the first s will be at "+"sorry".indexOf("s")+" but you'll want to start at position "+("sorry".indexOf("s")+1)+", with "+o[0]+".")},function(e,i){var r=parseInt(i);!isNaN(r)||i.startsWith("-")?me("What number do you want to add to the position number of the first occurrence of the s to get to the position you want to start at? For "+t+", the position of the first s will be at "+t.indexOf("s")+" but you'll want to start at position "+(t.indexOf("s")+1)+", with "+n[0]+" whereas for sorry, the position of the first s will be at "+"sorry".indexOf("s")+" but you'll want to start at position "+("sorry".indexOf("s")+1)+", with "+o[1]+". Change this to the correct number, accordingly."):me("If the user enters a string with an s such as e.g., "+t+" or sorry, then the number of places the last name will be beyond the position of the first s will always be the same so you can enter a *specific* number. For "+t+", the position of the first s will be at "+t.indexOf("s")+" but you'll want to start at position "+(t.indexOf("s")+1)+", with "+n[0]+" whereas for sorry, the position of the first s will be at "+"sorry".indexOf("s")+" but you'll want to start at position "+("sorry".indexOf("s")+1)+", with "+o[0]+". Change your answer to the specific number you can add in both cases, accordingly.")},function(e){return me("You're missing a comma after the starting position. In "+T2C.MSG.currentLanguage.LANGUAGE_NAME+", you put the starting and ending positions in the same parentheses when using "+e[5]+". The comma is used to separate the two positions with the starting position first and the ending position second in order for the computer to know which is which.")},function(e,n){var o=parseInt(n);isNaN(o)?n.startsWith("sPosition")||"sPosition".startsWith(n)?me("You don't want to stop extracting text at sPosition, do you?"):me("If we want all of the characters after the first s, we won't stop extracting text until we get to the end of the string. So for "+t+", you'd use "+t.length+" while for sorry, you'd use "+"sorry".length+", the position number after the last character. Since this position number will depend on something about the entered string, your answer should refer to it."):me("The stopping position will not always be at position "+o+". Instead, this position will depend on something about the entered string so your answer should refer to it.")},function(){return me("Be sure to include the . after the variable enteredTextWithS you want to use.")},function(e,n){return me("If we want all of the characters after the first s, we won't stop extracting text until we get to the end of the string. For "+t+", you'd use "+t.length+" while for sorry, you'd use "+"sorry".length+", the position number after the last character. Do you remember how you can get these positions from the entered string?")},function(e,n){-1!==n.replace(/\s/g,"").indexOf("-1")?me("Remember that "+T2C.MSG.currentLanguage.TERMINAL_GETTEXTFROMPOSITIONNUMBER+" ends one position before the numerical expression given. So for example, for an enteredTextWithS of "+t+", enteredTextWithS.length - 1 would be "+(t.length-1)+", which means you'd extract the text ending with the "+t.charAt(t.length-2)+" instead of the last character of "+t.charAt(t.length-1)+"."):-1!==n.replace(/\s/g,"").indexOf("+1")?me("For an enteredTextWithS of "+t+", enteredTextWithS.length + 1 would be "+(t.length+1)+", but there is no character at this position since positions start at 0."):me("What you're doing to the "+T2C.MSG.currentLanguage.TERMINAL_LENGTH+" seems incorrect. Be sure to have examples in mind before deciding what to type. For example, for "+t+", the length is "+t.length+" and you want to go up to position "+t.length+" (since you'd stop extracting at character "+(t.length-1)+"). If you're done, be sure to include a closing parenthesis for "+e[5]+" after the ending position.")}]);return i.error?i.match.join(""):e},init:function(){var e=this;this.appendDummyInput("STRING").appendField(new Blockly.FieldTextInput("",this.validate),"EXP"),this.setInputsInline(!1),this.setOutput(!1),this.setPreviousStatement(!0),this.setNextStatement(!0),this.setColour(60),this.setTooltip(T2C.MSG.currentLanguage.TYPEIN_STATEMENT_TOOLTIP),this.onchange=function(t){if(e.getFieldValue("EXP").endsWith("\r")||e.getFieldValue("EXP").endsWith("\n")||e.getFieldValue("EXP").length>0&&"workspaceClick"===t.element){if(!e.validate(e.getFieldValue("EXP"))||!e.getFieldValue("EXP").endsWith(")")&&!e.getFieldValue("EXP").endsWith(";"))return;var n=Object(o.getParseTree)(e.getFieldValue("EXP"));n?Object(o.handleParseTreeToBlocks)(n,e):me("Try checking what you entered again for mistakes.")}}}},Blockly.Python.type_in_display_s_replaced_with_dollar=Blockly.JavaScript.type_in_display_s_replaced_with_dollar=Blockly.JavaScript.code_statement,Blockly.Blocks.type_in_display_s_replaced_with_dollar={validate:function(e){var t="Mississippi".substring(0,"Mississippi".indexOf("s")),n="Mississippi".substring("Mississippi".indexOf("s")+1),o=("sorry".substring(0,"Mississippi".indexOf("s")),"sorry".substring("Mississippi".indexOf("s")+1),t+"$"+n),i=pe(e,[T2C.MSG.JS.TERMINAL_DISPLAY,"(","beforeS","+",{token:/^"\$"|^'\$'/,type:"regexp"},"+","afterS",")"],[he.bind(null,me,"DISPLAY"),function(e,t){return me("You're missing an open parenthesis after "+e[0]+".")},function(e,i){i.startsWith('"')||i.startsWith("'")?me("If you're using variable names to be evaluated instead of displayed as is (e.g., displaying the text Mi instead of the text beforeS), you don't want to use quotation marks."):me('Remember the variable names are beforeS and afterS. If beforeS = "'+t+'" and afterS = "'+n+'" and you want to display "'+o+'", what should be displayed first?')},function(){return me("How do you join strings together?")},function(e,i){"afterS".toLowerCase().startsWith(i.toLowerCase())||i.toLowerCase().startsWith("lastName".toLowerCase())?me("Remember that you'll want a $ between what comes before and after the first s; joining the two strings together without one would result in \""+t+n+'" instead of say "'+o+'".'):me("Remember that you want to *literally* display a $ between what comes before and after the first s. What do you need to surround text with when you want to display something without evaluating it?")},function(){return me("How do you join strings together?")},function(e,i){i.startsWith('"')||i.startsWith("'")?me("If you're using variable names to be evaluated instead of displayed as is (e.g., displaying the text "+n+" instead of the text afterS), you don't want to use quotation marks."):me('Remember the variable names are beforeS and afterS. If beforeS = "'+t+'" and afterS = "'+n+'" and you want to display "'+o+'", what should be displayed last?')},function(e,t){return me("You're missing a closing parenthesis for "+e[0]+".")}]);return i.error?i.match.join(""):e},init:function(){var e=this;this.appendDummyInput("STRING").appendField(new Blockly.FieldTextInput("",this.validate),"EXP"),this.setInputsInline(!1),this.setOutput(!1),this.setPreviousStatement(!0),this.setNextStatement(!0),this.setColour(60),this.setTooltip(T2C.MSG.currentLanguage.TYPEIN_STATEMENT_TOOLTIP),this.onchange=function(t){if(e.getFieldValue("EXP").endsWith("\r")||e.getFieldValue("EXP").endsWith("\n")||e.getFieldValue("EXP").length>0&&"workspaceClick"===t.element){if(!e.validate(e.getFieldValue("EXP"))||!e.getFieldValue("EXP").endsWith(")")&&!e.getFieldValue("EXP").endsWith(";"))return;var n=Object(o.getParseTree)(e.getFieldValue("EXP"));n?Object(o.handleParseTreeToBlocks)(n,e):me("Try checking what you entered again for mistakes.")}}}},String.prototype.JSSubstring=function(e,t){return e>=this.length||e===t?"":this.substring(e,t)},Blockly.Python.type_in_get_full_name=Blockly.JavaScript.type_in_get_full_name=Blockly.JavaScript.code_statement,Blockly.Blocks.type_in_get_full_name={validate:function(e){var t=ke(e,[{token:"let",type:"terminal"},"fullName","=",T2C.MSG.JS.TERMINAL_GETINPUTBYASKING,"(",{token:/^"[^"]*$|^'[^']*$|^"[^"]*full name[^"]*"|^'[^']*full name[^']*'/i,type:"regexp"},")"],[be.bind(null,Ee,"LET"),function(){return Ee("Be sure to name the variable you're declaring fullName.")},function(){return Ee("Remember to include an = after the variable fullName to set it to a value.")},be.bind(null,Ee,"GETINPUTBYASKING"),function(e){return Ee("You're missing an open parenthesis after "+e[3]+".")},function(){return Ee("The message to supply to the user should be surrounded by \" and \" because you want it to be displayed as is. Be sure it also includes the text 'full name' in it so the user knows to enter his/her full name.")},function(e,t){return Ee("You're missing a closing parenthesis for "+e[3]+".")}]);return t.error?t.match.join(""):e},init:function(){var e=this;this.appendDummyInput("STRING").appendField(new Blockly.FieldTextInput("",this.validate),"EXP"),this.setInputsInline(!1),this.setOutput(!1),this.setPreviousStatement(!0),this.setNextStatement(!0),this.setColour(60),this.setTooltip(T2C.MSG.currentLanguage.TYPEIN_STATEMENT_TOOLTIP),this.onchange=function(t){if(e.getFieldValue("EXP").endsWith("\r")||e.getFieldValue("EXP").endsWith("\n")||e.getFieldValue("EXP").length>0&&"workspaceClick"===t.element){if(!e.validate(e.getFieldValue("EXP"))||!e.getFieldValue("EXP").endsWith(")")&&!e.getFieldValue("EXP").endsWith(";"))return;var n=Object(o.getParseTree)(e.getFieldValue("EXP"));n?Object(o.handleParseTreeToBlocks)(n,e):Ee("Try checking what you entered again for mistakes.")}}}},Blockly.Python.type_in_print_initials=Blockly.JavaScript.type_in_print_initials=Blockly.JavaScript.code_statement,Blockly.Blocks.type_in_print_initials={validate:function(e){var t="Linus Torvalds",n="Jane Doe".substring(0,"Jane Doe".indexOf(" ")),o="Jane Doe".substring("Jane Doe".indexOf(" ")+1),i=n[0],r=o[0],a=i+"."+r+".",l=t.substring(0,t.indexOf(" ")),s=t.substring(t.indexOf(" ")+1),u=l[0],c=s[0],g=u+"."+c+".",d=ke(e,[T2C.MSG.JS.TERMINAL_DISPLAY,"(","fullName",".",T2C.MSG.JS.TERMINAL_GETCHARACTERNUMBER,"(","0",")","+",{token:/^"."|^'.'/,type:"regexp"},"+","fullName",".",T2C.MSG.JS.TERMINAL_GETCHARACTERNUMBER,"(","fullName",".",T2C.MSG.JS.TERMINAL_FINDFIRSTOCCURRENCEOFTEXT,"(",{token:/^" "|^' '/,type:"regexp"},")","+","1",")","+",{token:/^"."|^'.'/,type:"regexp"},")"],[be.bind(null,Ee,"DISPLAY"),function(e,t){return Ee("You're missing an open parenthesis after "+e[0]+".")},function(){return Ee("Be sure to include the variable fullName that you want to extract text from.")},function(){return Ee("Be sure to include the . after the variable fullName you want to extract text from.")},be.bind(null,Ee,"GETCHARACTERNUMBER"),function(e,t){return Ee("You're missing an open parenthesis after "+e[4]+".")},function(e,n){n.startsWith("(")?Ee("Although you *can* have multiple opening parentheses, it's not necessary in this instance. When you first start programming, it may be good to include them to make sure operations are performed in the required order, but it can also make your code more difficult to read and correctly match the open parentheses with closing ones. Before continuing, remove the extra opening parenthesis here since you don't need it."):1===parseInt(n)?Ee("Remember that positions start at 0."):parseInt(n)?Ee("In what position will the first initial of "+i+" appear if the person enters Jane Doe or the first initial of "+u+" if the person enters "+t+"?"):("fullName".toLowerCase().startsWith(n.toLowerCase())||n.toLowerCase().startsWith("fullName".toLowerCase()),Ee("Assuming the full name is always entered as first last such as Jane Doe with a first initial of "+i+" or "+t+" with a first initial of "+u+", the numerical position will always be the same. Use a specific number, accordingly."))},function(e,t){return Ee("You're missing a closing parenthesis for "+e[4]+".")},function(){return Ee("How do you join text together?")},function(e,n){"fullName".toLowerCase().startsWith(n.toLowerCase())||n.toLowerCase().startsWith("fullName".toLowerCase())?Ee("What character do you want to appear after the first initial of "+i+" to get the text "+a+" if the person enters Jane Doe or the first initial of "+u+" to get "+g+" if the person enters "+t+"? It's the same in both cases."):n.startsWith(".")?Ee("Since you want a literal . and don't want the computer to evaluate it in any way, you need to surround it with quotation marks."):n.match(/^"\.$|^"$|^'\.$|^'$/)?Ee(""):Ee("What character do you want to appear after the first initial of "+i+" to get the text "+a+" if the person enters Jane Doe or the first initial of "+u+" to get "+g+" if the person enters "+t+"? It's the same in both cases.")},function(){return Ee("How do you join text together?")},function(e,t){"lastInitial".toLowerCase().startsWith(t.toLowerCase())||t.toLowerCase().startsWith("lastInitial".toLowerCase())?Ee("You don't have lastInitial defined. As with the first initial, where do you get it from?"):T2C.MSG.JS.TERMINAL_GETCHARACTERNUMBER.toLowerCase().startsWith(t.toLowerCase())||t.toLowerCase().startsWith(T2C.MSG.JS.TERMINAL_GETCHARACTERNUMBER.toLowerCase())?Ee("Remember you need to give the text you want to extract the character from first when using "+T2C.MSG.JS.TERMINAL_GETCHARACTERNUMBER+"."):Ee("Given you have the first initial and a period, what do you want to appear next? As with the first initial, where do you get it from?")},function(){return Ee("Be sure to include the . after the variable fullName you want to extract text from.")},function(){return Ee("At this point, you'd have "+i+". for Jane Doe and "+u+". for "+t+". So what would you display next: a number, a character, or something else? Type in the appropriate of "+T2C.MSG.JS.TERMINAL_FINDFIRSTOCCURRENCEOFTEXT+", "+T2C.MSG.JS.TERMINAL_LENGTH+", "+T2C.MSG.JS.TERMINAL_GETCHARACTERNUMBER+", etc. accordingly, being mindful of spelling and case.")},function(e,t){return Ee("You're missing an open parenthesis after "+e[e.length-1]+".")},function(e,n){var o=parseInt(n);isNaN(o)?_e(n,"FINDFIRSTOCCURRENCEOFTEXT")?Ee("You'll need to refer to the variable name before using "+T2C.MSG.currentLanguage.TERMINAL_FINDFIRSTOCCURRENCEOFTEXT+" so the computer knows which string to search through (haystack) to find the given needle."):n.startsWith("(")?Ee("Although you *can* have multiple opening parentheses, it's not necessary in this instance. When you first start programming, it may be good to include them to make sure operations are performed in the required order, but it can also make your code more difficult to read and correctly match the open parentheses with closing ones. Before continuing, remove the extra opening parenthesis here since you don't need it."):Ee("The correct place in the string where the last initial appears will be a number depending on the entered string. For a full name of Jane Doe, you'd use "+("Jane Doe".indexOf(" ")+1)+", but for "+t+", you'd want to use "+(t.indexOf(" ")+1)+". Since it depends on some property of the entered name, start by entering the appropriate variable name here instead of what you have."):Ee("The correct place in the string where the last initial appears will not be always be the same number. For a full name of Jane Doe, you'd use "+("Jane Doe".indexOf(" ")+1)+", but for "+t+", you'd want to use "+(t.indexOf(" ")+1)+". Since it depends on some property of the entered name, start by entering the appropriate variable name here instead of a specific number.")},function(){return Ee("Be sure to include the . after the variable fullName you want to search.")},function(e,n){T2C.MSG.JS.TERMINAL_GETCHARACTERNUMBER.toLowerCase().startsWith(n.toLowerCase())||n.toLowerCase().startsWith(T2C.MSG.JS.TERMINAL_GETCHARACTERNUMBER.toLowerCase())?Ee("You're already inside the parentheses of a "+T2C.MSG.JS.TERMINAL_GETCHARACTERNUMBER+". What do you need to give it now so it can get the last initial from fullName?"):T2C.MSG.JS.TERMINAL_LENGTH.toLowerCase().startsWith(n.toLowerCase())||n.toLowerCase().startsWith(T2C.MSG.JS.TERMINAL_LENGTH.toLowerCase())?Ee("Getting the number of characters in the entire string does not help you find the position of the last initial unless you also had something like the number of characters in the first or last name. For example, the length of Jane Doe is "+"Jane Doe".length+" while the last initial is at position "+("Jane Doe".indexOf(" ")+1)+" whereas the length of "+t+" is "+t.length+" while the last initial is at position "+(t.indexOf(" ")+1)+"."):T2C.MSG.JS.TERMINAL_GETTEXTFROMPOSITIONNUMBER.toLowerCase().startsWith(n.toLowerCase())||n.toLowerCase().startsWith(T2C.MSG.JS.TERMINAL_GETTEXTFROMPOSITIONNUMBER.toLowerCase())?Ee(T2C.MSG.currentLanguage.TERMINAL_GETTEXTFROMPOSITIONNUMBER+" gives you part of the text, but you want the position number of the last initial to give to "+T2C.MSG.currentLanguage.TERMINAL_GETCHARACTERNUMBER+" to get the character at that position."):Ee("Given you have the first initial and a period, what do you want to appear next? What property of fullName do you want to get its position? Make sure your spelling and capitalization (e.g., M versus m) are correct.")},function(e,t){return Ee("You're missing an open parenthesis after "+e[e.length-1]+".")},function(e,t){"positionOfLastInitial".toLowerCase().startsWith(t.toLowerCase())||t.toLowerCase().startsWith("positionOfLastInitial".toLowerCase())?Ee("The position of the last initial will not be defined; you're using "+T2C.MSG.currentLanguage.TERMINAL_FINDFIRSTOCCURRENCEOFTEXT+" to calculate it."):t.match(/^""|^''/)?Ee("You are trying to get the location of an empty string; that's not what you want, right?"):t.match(/^" [^"]|^' [^']/)?Ee("Remember that that last name of an entered input won't always start with "+t[2]+". Is it really necessary to include? If you're done, close the quotation marks."):t.match(/^" $|^"$|^' $|^'$/)?Ee(""):parseInt(t)||t.startsWith("0")?Ee("You're looking for the first position number of a character in fullName to tell you where the last initial is, you are not searching for the *position* of "+parseInt(t)+" in fullName."):t.match(/^"|^'/)?Ee("What string (needle) are you looking for in lastName (haystack) to help you calculate the position number of the last initial?"):Ee("Since the needle you're going to use here is a string literal, you need to surround it with quotation marks. You're currently missing quotation marks.")},function(e,t){t.startsWith("+")?Ee("Be careful where you place the +; you certainly don't want to add a number to a space! Instead you want to add a number to the *position* of the space in fullName so it should go outside of the "+e[17]+"."):Ee("You're missing a closing parenthesis for "+e[17]+".")},function(e,o){o.startsWith(")")?Ee("You do not want to get the character located at the position of the space exactly or you'll get back the space itself! Instead, you'll want to get the character at the position after so you'll need to do what arithmetic operation to the position number you get? For fullName of Jane Doe, the position of the space will be at "+"Jane Doe".indexOf(" ")+" while for fullName of "+t+", the position of the space will be at "+t.indexOf(" ")+". What position will the last initial be in each case?"):o.replace(/\s/g,"").startsWith("-1")?Ee("If you subtract 1, you'll get the position of the last character of the first name. Instead, you'll want to get the character at the position after the space so you'll need to do what arithmetic operation to the position number you get? For example, for a fullName of Jane Doe, the position of the space will be at "+"Jane Doe".indexOf(" ")+" so subtracting 1 will give you "+("Jane Doe".indexOf(" ")-1)+", which will be the position of the first "+n.charAt(n.length-1)+". What do you want to do instead to get the position of the last initial from the position of the space?"):o.replace(/\s/g,"").startsWith("--1")?Ee("Add 1 instead of subtracting -1 as this makes your code clearer."):Ee("What operation and number should you use on the position of the space you get from "+T2C.MSG.currentLanguage.TERMINAL_FINDFIRSTOCCURRENCEOFTEXT+"? Remember, you'll want to get the character at the position after so you'll need to do what arithmetic operation to the position number you get? For fullName of Jane Doe, the position of the space will be at "+"Jane Doe".indexOf(" ")+" while for fullName of "+t+", the position of the space will be at "+t.indexOf(" ")+". What position will the last initial be in each case?")},function(e,n){var o=parseInt(n);!isNaN(o)||n.startsWith("-")?Ee("What number do you want to add to the position number of the first occurrence of the space to get to the position of the last initial? Change this to the correct number."):Ee(T2C.MSG.currentLanguage.TERMINAL_FINDFIRSTOCCURRENCEOFTEXT+" gives you back a number. What specific *number* do you want to add to the position number of the first occurrence of the space to get to the position you want to start at? Change this to the correct number. For fullName of Jane Doe, the position of the space will be at "+"Jane Doe".indexOf(" ")+" while for fullName of "+t+", the position of the space will be at "+t.indexOf(" ")+". To figure out what you want to add, what position will the last initial be in each case?")},function(e,t){return Ee("You're missing a closing parenthesis for the second "+e[4]+".")},function(e,n){n.startsWith(")")?Ee("At this point, you have "+a.substring(0,a.length-1)+" for Jane Doe and "+g.substring(0,g.length-1)+" for "+t+". What are you missing?"):Ee("At this point, you have "+a.substring(0,a.length-1)+" for Jane Doe and "+g.substring(0,g.length-1)+" for "+t+". What should go next and what do you do to add more to the text you already have?")},function(e,n){"fullName".toLowerCase().startsWith(n.toLowerCase())||n.toLowerCase().startsWith("fullName".toLowerCase())?Ee("What character do you want to appear after the last initial of "+i+" to get the text "+a+" if the person enters Jane Doe or the last initial of "+u+" to get "+g+" if the person enters "+t+"? It's the same in both cases."):n.startsWith(".")?Ee("Since you want a literal . and don't want the computer to evaluate it in any way, you need to surround it with quotation marks."):n.match(/^"\.$|^"$|^'\.$|^'$/)?Ee(""):Ee("What character do you want to appear after the last initial of "+a.substring(0,a.length-1)+" to get the text "+a+" if the person enters Jane Doe or the last initial of "+g.substring(0,g.length-1)+" to get "+g+" if the person enters "+t+"? It's the same in both cases.")},function(e,t){return Ee("You're missing a closing parenthesis for "+e[0]+".")}]);return d.error?d.match.join(""):e},init:function(){var e=this;this.appendDummyInput("STRING").appendField(new Blockly.FieldTextInput("",this.validate),"EXP"),this.setInputsInline(!1),this.setOutput(!1),this.setPreviousStatement(!0),this.setNextStatement(!0),this.setColour(60),this.setTooltip(T2C.MSG.currentLanguage.TYPEIN_STATEMENT_TOOLTIP),this.onchange=function(t){if(e.getFieldValue("EXP").endsWith("\r")||e.getFieldValue("EXP").endsWith("\n")||e.getFieldValue("EXP").length>0&&"workspaceClick"===t.element){if(!e.validate(e.getFieldValue("EXP"))||!e.getFieldValue("EXP").endsWith(")")&&!e.getFieldValue("EXP").endsWith(";"))return;var n=Object(o.getParseTree)(e.getFieldValue("EXP"));n?Object(o.handleParseTreeToBlocks)(n,e):Ee("Try checking what you entered again for mistakes.")}}}};var Be=new g,Ae=Be.addTab(T2C.MSG.currentLanguage.DIRECTIONS,""),ve=Be.addTab(T2C.MSG.currentLanguage.FEEDBACK,""),Ie="apple,banana,cantaloupe,kiwi,orange",we="atari,nintendo,sega genesis,super nintendo",Se=Ie.substring(Ie.indexOf(",")+1),Me=we.substring(we.indexOf(",")+1),Ne=Se.substring(Se.indexOf(",")+1),Le=Me.substring(Me.indexOf(",")+1),Oe=Ne.substring(0,Ne.indexOf(",")),Ce=Le.substring(0,Le.indexOf(","));function Re(e){e.style.verticalAlign="middle",e.style.color="#000"}function Fe(){document.getElementById("output-container").classList.remove("show-container"),document.getElementById("output-container").classList.add("hide-container"),document.getElementById("text-code-container").classList.remove("show-container"),document.getElementById("text-code-container").classList.add("hide-container")}function Pe(e,t){var n=arguments.length>2&&void 0!==arguments[2]&&arguments[2],o=n?e:e.toLowerCase(),i=n?t:t.toLowerCase();return o.startsWith(i)||i.startsWith(o)}function Ve(e,t){var n=Object.values(T2C.MSG).map((function(e){return e["TERMINAL_"+t.toUpperCase()]})).filter((function(e){return"string"==typeof e})).find((function(t){return Pe(t,e,!0)}));if(n)return{terminal:n,remaining:e.JSSubstring(n.length).trim()}}String.prototype.JSSubstring=function(e,t){return e>=this.length||e===t?"":this.substring(e,t)};var Ge=new d("type_in_get_item_list");Ge.addPossibleMatch([{token:"let",type:"terminal"},"itemList","=",T2C.MSG.JS.TERMINAL_GETINPUTBYASKING,"(",{token:/^"[^"]*$|^'[^']*$|^"[^"]*at least 4[^"]*"|^'[^']*at least 4[^']*'/i,type:"regexp"},")"],[null,function(){return"Be sure to name the variable you're declaring itemList."},function(){return"Remember to include an = after the variable itemList to set it to a value."},null,null,function(){return"The message to supply to the user should be surrounded by \" and \" because you want it to be displayed as is. Be sure it also includes the text 'at least 4' in it so the user knows to enter at least 4 items (separated by commas)."},null]),Ge.addToBlocks();var Ue=new d("type_in_display_item_list");Ue.addPossibleMatch([T2C.MSG.JS.TERMINAL_DISPLAY,"(","itemList",")"],[null,null,function(){return"Check the spelling and the case of the variable name of the value you want to display, itemList."},null]),Ue.addToBlocks();var Xe=new d("type_in_set_after_first");Xe.addPossibleMatch([{token:"let",type:"terminal"},"afterFirstComma","=","itemList",".",T2C.MSG.JS.TERMINAL_GETTEXTFROMPOSITIONNUMBER,"(","itemList",".",T2C.MSG.JS.TERMINAL_FINDFIRSTOCCURRENCEOFTEXT,"(",{token:/^","|^','/,type:"regexp"},")","+","1",",","itemList",".",{token:"LENGTH",type:"terminal"},")"],[null,function(){return"Be sure to name the variable you're declaring afterFirstComma to represent the fact that it should store the text after the first comma from the user input."},function(){return"Remember to include an = after the variable afterFirstComma you're declaring to set it to the value that follows."},function(){return"Be sure to include the variable itemList that you want to extract text from."},function(){return"Be sure to include the . after the variable itemList you want to extract text from."},null,null,function(e,t){var n=parseInt(t);return isNaN(n)?t.startsWith(",")?"You need a position *number* to start extracting text from here, but a comma is not a number. Perhaps you wanted the position of the comma instead?":Ve(t,"FINDFIRSTOCCURRENCEOFTEXT")?"You'll need to refer to the variable name before using "+T2C.MSG.currentLanguage.TERMINAL_FINDFIRSTOCCURRENCEOFTEXT+" so the computer knows which string to search through (haystack) to find the given needle.":t.startsWith("(")?"Although you *can* have multiple opening parentheses, it's not necessary in this instance. When you first start programming, it may be good to include them to make sure operations are performed in the required order, but it can also make your code more difficult to read and correctly match the open parentheses with closing ones. Before continuing, remove the extra opening parenthesis here since you don't need it.":"The correct place in the string where the second item begins (after the first comma) will be a number depending on the entered string. For an itemList of "+Ie+", you'd use "+(Ie.indexOf(",")+1)+", but for "+we+", you'd want to use "+(we.indexOf(",")+1)+". Since it depends on some property of the entered item list, start by entering the appropriate variable name here instead of what you have.":"The correct place in the string where the second item begins (after the first comma) will not be always be the same number. For an itemList of "+Ie+", you'd use "+(Ie.indexOf(",")+1)+", but for "+we+", you'd want to use "+(we.indexOf(",")+1)+". Since it depends on some property of the entered item list, start by entering the appropriate variable name here instead of a specific number."},function(){return"Be sure to include the . after the variable itemList you want to search."},function(e,t){return Pe(t,T2C.MSG.JS.TERMINAL_GETTEXTFROMPOSITIONNUMBER)?"You're already inside the parentheses of a "+T2C.MSG.JS.TERMINAL_GETTEXTFROMPOSITIONNUMBER+". What do you need to give the computer now so it knows what position to start extracting text from to get the text after the first comma?":Pe(t,T2C.MSG.JS.TERMINAL_LENGTH)?"You don't want to *start* extracting text after the last character of the string, right?":Pe(t,T2C.MSG.currentLanguage.TERMINAL_GETCHARACTERNUMBER)?T2C.MSG.currentLanguage.TERMINAL_GETCHARACTERNUMBER+" gives you a character, but you need a position *number* to start extracting text from for "+T2C.MSG.currentLanguage.TERMINAL_GETTEXTFROMPOSITIONNUMBER+" to start extracting text from.":"What property of itemList do you want to determine where to start extracting text from? Make sure your spelling and capitalization (e.g., M versus m) are correct."},null,function(e,t){return t.startsWith(",")?"Since you're looking for the literal , and don't want the computer to evaluate it in any way, you need to surround it with quotation marks.":t.match(/^",[^"]|^',[^']/)?"Remember that that second item of the entered input won't always start with "+t[2]+". Is it really necessary to include? If you're done, close the quotation marks.":t.match(/^",$|^"$|^',$|^'$/)?"":parseInt(t)||t.startsWith("0")?"You're looking for the first position number of a character in itemList to tell you where the beginning of the second item is, you are not searching for the *position* of "+parseInt(t)+" in itemList.":t.match(/^"|^'/)?"What string (needle) are you looking for in itemList (haystack) to help you calculate the position number of the start of the second item?":"Since the needle you're going to use here is a string literal, you need to surround it with quotation marks. You're currently missing quotation marks."},function(e,t){return t.startsWith("+")?"Be careful where you place the +; you certainly don't want to add a number to a comma! Instead you want to add a number to the *position* of the comma in itemList so it should go outside of the "+e[9]+".":"You're missing a closing parenthesis for "+e[9]+"."},function(e,t){return t.startsWith(",")||t.startsWith(")")?"You do not want to start extracting text from the position of the comma exactly or the result will start with the comma! Instead, you'll want to start extracting text from the position after so you'll need to do what arithmetic operation to the position number you get? For itemList of "+Ie+", the position of the comma will be at "+Ie.indexOf(",")+" while for itemList of "+we+", the position of the comma will be at "+we.indexOf(",")+". What position will the start of the second item be in each case?":t.replace(/\s/g,"").startsWith("-1")?"If you subtract 1, you'll get the position of the last character of the first item. Instead, you'll want to start extracting text from the position after the comma so you'll need to do what arithmetic operation to the position number you get? For example, for an itemList of "+Ie+", the position of the comma will be at "+Ie.indexOf(",")+" so subtracting 1 will give you "+(Ie.indexOf(",")-1)+", which will be the position of the first "+Ie.charAt(Ie.indexOf(",")-1)+". What do you want to do instead to get the position of the start of the second item from the position of the comma?":t.replace(/\s/g,"").startsWith("--1")?"Add 1 instead of subtracting -1 as this makes your code clearer.":"What operation and number should you use on the position of the comma you get from "+T2C.MSG.currentLanguage.TERMINAL_FINDFIRSTOCCURRENCEOFTEXT+"? Remember, you'll want to start extracting text from the position after the comma so you'll need to do what arithmetic operation to the position number you get? For itemList of "+Ie+", the position of the comma will be at "+Ie.indexOf(",")+" while for itemList of "+we+", the position of the comma will be at "+we.indexOf(",")+". What position will the start of the second item be in each case?"},function(e,t){var n=parseInt(t);return!isNaN(n)||t.startsWith("-")?"What number do you want to add to the position number of the first occurrence of the comma to get to the position of the start of the second item after it? Change this to the correct number.":T2C.MSG.currentLanguage.TERMINAL_FINDFIRSTOCCURRENCEOFTEXT+" gives you back a number. What specific *number* do you want to add to the position number of the first occurrence of the comma to get to the position you want to start at? Change this to the correct number. For itemList of "+Ie+", the position of the comma will be at "+Ie.indexOf(",")+" while for itemList of "+we+", the position of the comma will be at "+we.indexOf(",")+". To figure out what you want to add, what position will the start of the second item be in each case?"},function(e){return"You're missing a comma after the starting position. In "+T2C.MSG.currentLanguage.LANGUAGE_NAME+", you put the starting and ending positions in the same parentheses when using "+e[5]+". The comma is used to separate the two positions with the starting position first and the ending position second in order for the computer to know which is which."},function(e,t){var n=parseInt(t);return isNaN(n)?"If we want all of the characters after the first comma, we won't stop extracting text until we get to the end of the string. So for "+Ie+", you'd use "+Ie.length+" while for "+we+", you'd use "+we.length+", the position number after the last character. Since this position number will depend on something about the entered string, your answer should refer to it.":"The stopping position will not always be at position "+n+". Instead, this position will depend on something about the entered string so your answer should refer to it."},function(){return"Be sure to include the . after the variable itemList you want to use."},function(e,t){return"If we want all of the characters after the first comma, we won't stop extracting text until we get to the end of the string. For "+Ie+", you'd use "+Ie.length+" while for "+we+", you'd use "+we.length+", the position number after the last character. Do you remember how you can get these positions from the entered string?"},function(e,t){return-1!==t.replace(/\s/g,"").indexOf("-1")?"Remember that "+T2C.MSG.currentLanguage.TERMINAL_GETTEXTFROMPOSITIONNUMBER+" ends one position before the numerical expression given. So for example, for an itemList of "+Ie+", itemList.length - 1 would be "+(Ie.length-1)+", which means you'd extract the text ending with the "+Ie.charAt(Ie.length-2)+" instead of the last character of "+Ie.charAt(Ie.length-1)+".":-1!==t.replace(/\s/g,"").indexOf("+1")?"For an itemList of "+Ie+", itemList.length + 1 would be "+(Ie.length+1)+", but there is no character at this position since positions start at 0.":"What you're doing to the "+T2C.MSG.currentLanguage.TERMINAL_LENGTH+" seems incorrect. Be sure to have examples in mind before deciding what to type. For example, for "+Ie+", the length is "+Ie.length+" and you want to go up to position "+Ie.length+" (since you'd stop extracting at character "+(Ie.length-1)+"). If you're done, be sure to include a closing parenthesis for "+e[5]+" after the ending position."}]),Xe.addToBlocks();var je=new d("type_in_display_after_first");je.addPossibleMatch([T2C.MSG.JS.TERMINAL_DISPLAY,"(","afterFirstComma",")"],[null,null,function(){return"Check the spelling and the case of the variable name of the value you want to display, afterFirstComma."},null]),je.addToBlocks();var De=new d("type_in_set_after_second");De.addPossibleMatch([{token:"let",type:"terminal"},"afterSecondComma","=","afterFirstComma",".",T2C.MSG.JS.TERMINAL_GETTEXTFROMPOSITIONNUMBER,"(","afterFirstComma",".",T2C.MSG.JS.TERMINAL_FINDFIRSTOCCURRENCEOFTEXT,"(",{token:/^","|^','/,type:"regexp"},")","+","1",",","afterFirstComma",".",{token:"LENGTH",type:"terminal"},")"],[null,function(){return"Be sure to name the variable you're declaring afterSecondComma to represent the fact that it should store the text after the second comma from the user input."},function(){return"Remember to include an = after the variable afterSecondComma you're declaring to set it to the value that follows."},function(e,t){return Pe(t,"itemList")?"If you're using the originial inputted itemList, you will *not* be able to extract the text after the *second* comma in general when you're only able to get the position of its first comma. What variable can you use instead?":"Be sure to include the variable that you want to extract text from."},function(){return"Be sure to include the . after the variable afterFirstComma you want to extract text from."},null,null,function(e,t){var n=parseInt(t);return isNaN(n)?Pe(t,"itemList")?"If you're using the original inputted itemList, you will *not* be able to extract the text after the *second* comma in general when you're only able to get the position of its first comma. For example, the position of the first comma in "+Ie+" is "+Ie.indexOf(",")+" while the position of the first comma in "+Ie+" with its first item removed ("+Se+") is "+Se.indexOf(",")+". Perhaps you want to use a different variable?":t.startsWith(",")?"You need a position *number* to start extracting text from here, but a comma is not a number. Perhaps you wanted the position of the comma instead?":Ve(t,"FINDFIRSTOCCURRENCEOFTEXT")?"You'll need to refer to the variable name before using "+T2C.MSG.currentLanguage.TERMINAL_FINDFIRSTOCCURRENCEOFTEXT+" so the computer knows which string to search through (haystack) to find the given needle.":t.startsWith("(")?"Although you *can* have multiple opening parentheses, it's not necessary in this instance. When you first start programming, it may be good to include them to make sure operations are performed in the required order, but it can also make your code more difficult to read and correctly match the open parentheses with closing ones. Before continuing, remove the extra opening parenthesis here since you don't need it.":"The correct place in the string where the third item begins (after the first comma in afterFirstComma) will be a number depending on the entered string. For an afterFirstComma of "+Se+", you'd use "+(Se.indexOf(",")+1)+", but for "+Me+", you'd want to use "+(Me.indexOf(",")+1)+". Since it depends on some property of afterFirstComma, start by entering the appropriate variable name here instead of what you have.":"The correct place in the inputted itemList where the third item begins (after the first comma in afterFirstComma) will not be always be the same number. For an afterFirstComma of "+Se+", you'd use "+(Se.indexOf(",")+1)+", but for "+Me+", you'd want to use "+(Me.indexOf(",")+1)+". Since it depends on some property of afterFirstComma, start by entering the appropriate variable name here instead of a specific number."},function(){return"Be sure to include the . after the variable afterFirstComma you want to search."},function(e,t){return Pe(t,T2C.MSG.JS.TERMINAL_GETTEXTFROMPOSITIONNUMBER)?"You're already inside the parentheses of a "+T2C.MSG.JS.TERMINAL_GETTEXTFROMPOSITIONNUMBER+". What do you need to give the computer now so it knows what position to start extracting text from to get the text after the first comma in afterFirstComma?":Pe(t,T2C.MSG.JS.TERMINAL_LENGTH)?"You don't want to *start* extracting text after the last character of the string, right?":Pe(t,T2C.MSG.currentLanguage.TERMINAL_GETCHARACTERNUMBER)?T2C.MSG.currentLanguage.TERMINAL_GETCHARACTERNUMBER+" gives you a character, but you need a position *number* to start extracting text from for "+T2C.MSG.currentLanguage.TERMINAL_GETTEXTFROMPOSITIONNUMBER+" to start extracting text from.":"What property of afterFirstComma do you want to determine where to start extracting text from? Make sure your spelling and capitalization (e.g., M versus m) are correct."},null,function(e,t){return t.startsWith(",")?"Since you're looking for the literal , and don't want the computer to evaluate it in any way, you need to surround it with quotation marks.":t.match(/^",[^"]|^',[^']/)?"Remember that that second item of afterFirstComma won't always start with "+t[2]+". Is it really necessary to include? If you're done, close the quotation marks.":t.match(/^",$|^"$|^',$|^'$/)?"":parseInt(t)||t.startsWith("0")?"You're looking for the first position number of a character in afterFirstComma to tell you where the beginning of the second item in afterFirstComma is (third item in original itemList), you are not searching for the *position* of "+parseInt(t)+" in afterFirstComma.":t.match(/^"|^'/)?"What string (needle) are you looking for in afterFirstComma (haystack) to help you calculate the position number of the start of its second item (third item in original list)?":"Since the needle you're going to use here is a string literal, you need to surround it with quotation marks. You're currently missing quotation marks."},function(e,t){return t.startsWith("+")?"Be careful where you place the +; you certainly don't want to add a number to a comma! Instead you want to add a number to the *position* of the comma in afterFirstComma so it should go outside of the "+e[9]+".":"You're missing a closing parenthesis for "+e[9]+"."},function(e,t){return t.startsWith(",")||t.startsWith(")")?"You do not want to start extracting text from the position of the comma exactly or the result will start with the comma! Instead, you'll want to start extracting text from the position after so you'll need to do what arithmetic operation to the position number you get? For afterFirstComma of "+Se+", the position of the first comma will be at "+Se.indexOf(",")+" while for afterFirstComma of "+Me+", the position of the comma will be at "+Me.indexOf(",")+". What position will the start of the second item from afterFirstComma be in each case?":t.replace(/\s/g,"").startsWith("-1")?"If you subtract 1, you'll get the position of the last character of the first item. Instead, you'll want to start extracting text from the position after the comma so you'll need to do what arithmetic operation to the position number you get? For example, for an afterFirstComma of "+Se+", the position of the first comma will be at "+Se.indexOf(",")+" so subtracting 1 will give you "+(Se.indexOf(",")-1)+", which will be the position of "+Se.charAt(Se.indexOf(",")-1)+". What do you want to do instead to get the position of the start of the second item in afterFirstComma?":t.replace(/\s/g,"").startsWith("--1")?"Add 1 instead of subtracting -1 as this makes your code clearer.":"What operation and number should you use on the position of the first comma from afterFirstComma you get from "+T2C.MSG.currentLanguage.TERMINAL_FINDFIRSTOCCURRENCEOFTEXT+"? Remember, you'll want to start extracting text from the position after the comma so you'll need to do what arithmetic operation to the position number you get? For afterFirstComma of "+Se+", the position of its first comma will be at "+Se.indexOf(",")+" while for afterFirstComma of "+Me+", the position of the comma will be at "+Me.indexOf(",")+". What position will the start of the second item from afterFirstComma be in each case?"},function(e,t){var n=parseInt(t);return!isNaN(n)||t.startsWith("-")?"What number do you want to add to the position number of the first occurrence of the comma to get to the position of the start of the second item in afterFirstComma after it? Change this to the correct number.":T2C.MSG.currentLanguage.TERMINAL_FINDFIRSTOCCURRENCEOFTEXT+" gives you back a number. What specific *number* do you want to add to the position number of the first occurrence of the comma in afterFirstComma to get to the position you want to start at? Change this to the correct number. For afterFirstComma of "+Se+", the position of the first comma will be at "+Se.indexOf(",")+" while for afterFirstComma of "+Me+", the position of the first comma will be at "+Me.indexOf(",")+". To figure out what you want to add, what position will the start of the second item be in each case?"},function(e){return"You're missing a comma after the starting position. In "+T2C.MSG.currentLanguage.LANGUAGE_NAME+", you put the starting and ending positions in the same parentheses when using "+e[5]+". The comma is used to separate the two positions with the starting position first and the ending position second in order for the computer to know which is which."},function(e,t){var n=parseInt(t);return Pe(t,"itemList")?"If we want all of the characters after the first comma in afterFirstComma, the ending position we give to "+T2C.MSG.currentLanguage.TERMINAL_GETTEXTFROMPOSITIONNUMBER+" will need to be "+Se.length+" for "+Se+" and "+Me.length+" for "+Me+". These are different than one more than the ending positions for "+Ie+" and "+we+", which would be "+Ie.length+" and "+we.length+", respectively. No calculations will be required if we work with afterFirstComma instead.":isNaN(n)?"If we want all of the characters after the first comma in afterFirstComma, we won't stop extracting text until we get to the end of the string. So for "+Se+", you'd use "+Se.length+" while for "+Me+", you'd use "+Me.length+", the position number after the last character. Since this position number will depend on something about afterFirstComma, your answer should refer to it.":"The stopping position will not always be at position "+n+". Instead, this position will depend on something about afterFirstComma so your answer should refer to it."},function(){return"Be sure to include the . after the variable afterFirstComma you want to use."},function(e,t){return"If we want all of the characters after the first comma of afterFirstComma, we won't stop extracting text until we get to the end of the string. For "+Se+", you'd use "+Se.length+" while for "+Me+", you'd use "+Me.length+", the position number after the last character. Do you remember how you can get these positions from the entered string?"},function(e,t){return-1!==t.replace(/\s/g,"").indexOf("-1")?"Remember that "+T2C.MSG.currentLanguage.TERMINAL_GETTEXTFROMPOSITIONNUMBER+" ends one position before the numerical expression given. So for example, for an afterFirstComma of "+Se+", afterFirstComma.length - 1 would be "+(Se.length-1)+", which means you'd extract the text ending with the "+Se.charAt(Se.length-2)+" instead of the last character of "+Se.charAt(Se.length-1)+".":-1!==t.replace(/\s/g,"").indexOf("+1")?"For an afterFirstComma of "+Se+", afterFirstComma.length + 1 would be "+(Ie.length+1)+", but there is no character at this position since positions start at 0.":"What you're doing to the "+T2C.MSG.currentLanguage.TERMINAL_LENGTH+" seems incorrect. Be sure to have examples in mind before deciding what to type. For example, for "+Se+", the length is "+Se.length+" and you want to go up to position "+Se.length+" (since you'd stop extracting at character "+(Se.length-1)+"). If you're done, be sure to include a closing parenthesis for "+e[5]+" after the ending position."}]),De.addToBlocks();var We=new d("type_in_display_after_second");We.addPossibleMatch([T2C.MSG.JS.TERMINAL_DISPLAY,"(","afterSecondComma",")"],[null,null,function(){return"Check the spelling and the case of the variable name of the value you want to display, afterSecondComma."},null]),We.addToBlocks();var Ye=new d("type_in_display_third_item");Ye.addPossibleMatch([T2C.MSG.JS.TERMINAL_DISPLAY,"(","afterSecondComma",".",T2C.MSG.JS.TERMINAL_GETTEXTFROMPOSITIONNUMBER,"(","0",",","afterSecondComma",".",T2C.MSG.JS.TERMINAL_FINDFIRSTOCCURRENCEOFTEXT,"(",{token:/^","|^','/,type:"regexp"},")",")",")"],[null,null,function(e,t){return Pe(t,"itemList")?"If you're using the originial inputted itemList, you will *not* be able to extract the text before the *third* comma in general when you're only able to get the position of its first comma. What variable can you use instead?":Pe(t,"afterFirstComma")?"If you're using afterFirstComma, you will *not* be able to extract the text before its second comma (before third comma in itemList) in general when you're only able to get the position of its first comma. What variable can you use instead?":"Be sure to include the variable that you want to extract text from."},function(){return"Be sure to include the . after the variable afterSecondComma you want to extract text from."},null,null,function(e,t){return t.startsWith("(")?T2C.MSG.currentLanguage.TYPEIN_WARNING_UNNECESSARY_OPEN_PARENTHESIS:Pe(t,"secondFirstComma")?"The text occurring before the first comma in a string starts at what numerical position regardless of what it is? Use that specific number, accordingly.":1===parseInt(t)?"Remember that positions start at 0.":parseInt(t)?"Where do you want to start extracting text from if you want all of the text *before* the first comma in afterSecondComma. What number should you use if you want to start extracting text there?":"The text occurring before the first comma in a string starts at what numerical position regardless of what it is? Use that specific number, accordingly."},function(e){return"You're missing a comma after the starting position. In "+T2C.MSG.currentLanguage.LANGUAGE_NAME+", you put the starting and ending positions in the same parentheses when using "+e[4]+". The comma is used to separate the two positions with the starting position first and the ending position second in order for the computer to know which is which."},function(e,t){var n=parseInt(t);return isNaN(n)?Pe(t,"itemList")?"If we want all of the characters before the first comma in afterSecondComma, the ending position we give to "+T2C.MSG.currentLanguage.TERMINAL_GETTEXTFROMPOSITIONNUMBER+" will need to be "+Ne.indexOf(",")+" for "+Ne+" and "+Le.indexOf(",")+" for "+Le+". These are different than the ending positions of the first comma for "+Ie+" and "+we+", which would be "+Ie.indexOf(",")+" and "+we.indexOf(",")+", respectively. No calculations will be required if we work with afterSecondComma instead.":Pe(t,"afterFirstComma")?"If we want all of the characters before the first comma in afterSecondComma, the ending position we give to "+T2C.MSG.currentLanguage.TERMINAL_GETTEXTFROMPOSITIONNUMBER+" will need to be "+Ne.indexOf(",")+" for "+Ne+" and "+Le.indexOf(",")+" for "+Le+". These are different than the ending positions of the first comma for "+Se+" and "+Me+", which would be "+Se.indexOf(",")+" and "+Me.indexOf(",")+", respectively. No calculations will be required if we work with afterSecondComma instead.":Ve(t,"FINDFIRSTOCCURRENCEOFTEXT")?"You'll need to refer to the variable name before using "+T2C.MSG.currentLanguage.TERMINAL_FINDFIRSTOCCURRENCEOFTEXT+" so the computer knows which string to search through (haystack) to find the given needle.":t.startsWith("(")?T2C.MSG.currentLanguage.TYPEIN_WARNING_UNNECESSARY_OPEN_PARENTHESIS:"For an afterSecondComma of "+Ne+", you'd use "+Ne.indexOf(",")+" (stopping before it), but for "+Le+", you'd want to use "+Le.indexOf(",")+". Since it depends on the position of the comma, start by entering the appropriate variable name here instead of a specific number.":"The correct place to stop extracting text cannot be a specific number if you want it to work in general regardless of the entered list. For an afterSecondComma of "+Ne+", you'd use "+Ne.indexOf(",")+" (stopping before the comma), but for "+we+", you'd want to use "+Le.indexOf(",")+". Since it depends on the position of the comma, start by entering the appropriate variable name here instead of a specific number."},function(){return"Be sure to include the . after the variable afterSecondComma you want to search."},function(e,t){return Pe(t,T2C.MSG.JS.TERMINAL_GETTEXTFROMPOSITIONNUMBER)?"You're already inside the parentheses of a "+T2C.MSG.JS.TERMINAL_GETTEXTFROMPOSITIONNUMBER+". What do you need to give the computer now so it knows what position to stop extracting text from to get the text before the first comma in afterSecondComma?":Pe(t,T2C.MSG.JS.TERMINAL_LENGTH)?"You don't want to stop extracting text after the last character of the string if you want to get everything before the first comma in afterSecondComma, right?":Pe(t,T2C.MSG.currentLanguage.TERMINAL_GETCHARACTERNUMBER)?T2C.MSG.currentLanguage.TERMINAL_GETCHARACTERNUMBER+" gives you a character, but you need to give "+T2C.MSG.currentLanguage.TERMINAL_GETTEXTFROMPOSITIONNUMBER+" a position *number* to stop extracting text from.":"What property of afterSecondComma do you want in order to determine where to stop extracting text? Make sure your spelling and capitalization (e.g., M versus m) are correct."},null,function(e,t){return t.startsWith(",")?"Since you're looking for the literal , and don't want the computer to evaluate it in any way, you need to surround it with quotation marks.":t.match(/^",[^"]|^',[^']/)?"Remember that that second item of afterSecondComma won't always start with "+t[2]+". Is it really necessary to include? If you're done, close the quotation marks.":t.match(/^",$|^"$|^',$|^'$/)?"":parseInt(t)||t.startsWith("0")?"You're looking for the first position number of a character in afterSecondComma to tell you where the end of the first item in afterSecondComma is (third item in original itemList), you are not searching for the *position* of "+parseInt(t)+" in afterSecondComma.":t.match(/^"|^'/)?"What string (needle) are you looking for in afterSecondComma (haystack) to help you calculate the position number of the end of its first item (third item in original list)?":"Since the needle you're going to use here is a string literal, you need to surround it with quotation marks. You're currently missing quotation marks."},function(e,t){return t.startsWith("+")||t.startsWith("-")?"Be careful where you place the math operation; you certainly don't want to add/subtract a number from a comma! Any math you may want to do to the *position* of the comma in email (which may not be necessary) should go outside of the parentheses for the character to find in "+e[10]+".":"You're missing a closing parenthesis for "+e[10]+"."},function(e,t){return-1!==t.replace(/\s/g,"").indexOf("-1")?"Remember that "+T2C.MSG.currentLanguage.TERMINAL_GETTEXTFROMPOSITIONNUMBER+" ends one position before the numerical expression given. So for example, for a afterSecondComma of "+Ne+", you'd want to use "+Ne.indexOf(",")+" so the last character you'd extract would be at position "+(Ne.indexOf(",")-1)+", mainly the "+Ne[Ne.indexOf(",")-1]+" before the comma. If you subtracted 1, you'd instead stop extracting text at position "+(Ne.indexOf(",")-2)+" so you'd instead incorrectly get the "+Ne[Ne.indexOf(",")-2]+" as the last character.":-1!==t.replace(/\s/g,"").indexOf("+1")?"Although "+T2C.MSG.currentLanguage.TERMINAL_GETTEXTFROMPOSITIONNUMBER+" ends one position before the numerical expression given, you want to stop before the first comma of afterSecondComma anyway. Adding 1 means you'll instead stop at its first comma instead. For example, for an afterSecondComma of "+Ne+" the comma would be located at position "+Ne.indexOf(",")+" so by adding 1, you'd get "+(Ne.indexOf(",")+1)+", which means the last character you'd extract would be at position "+Ne.indexOf(",")+", mainly the comma itself.":"What you're doing to the ending position of "+T2C.MSG.currentLanguage.TERMINAL_GETTEXTFROMPOSITIONNUMBER+" seems incorrect or unnecessary. Be sure to have examples in mind before deciding what to type. If you're done, be sure to include a closing parenthesis for "+e[4]+" after the ending position."},null]),Ye.addToBlocks();var He=["type_in_get_start_num","cs1030_10_type_in_step1","cs1030_10_type_in_display_step1","cs1030_10_type_in_step2","cs1030_10_type_in_display_step2","cs1030_10_type_in_step3","cs1030_10_type_in_display_step3","cs1030_10_type_in_step4","cs1030_10_type_in_display_step4","cs1030_10_type_in_step5","cs1030_10_type_in_display_step5"],Je=["startNum","step1","step2","step3","step4","step5"],qe=["*","+","-","/","-"],$e=["2","100","16","2","startNum"],ze=[],Ke=new d("type_in_get_start_num",{collapseWhenFinished:!0}),Ze=[{token:"let",type:"terminal"},"startNum","=",{token:"parseFloat",type:"terminal"},"(",{token:"GETINPUTBYASKING",type:"terminal"},"(",'"',"Enter a number:",'"',")",")",{token:/^[;]*$/,type:"regexp"}],Qe=T2C.MSG.currentLanguage===T2C.MSG.PY?T2C.MSG.PY:T2C.MSG.JS,et=Ze.slice(0,Ze.length-1).map((function(e){return"terminal"===e.type?Qe["TERMINAL_"+e.token.toUpperCase()]:e})).join(""),tt=[null,null,null,null,null,null,null,null,null,null,null,null,null];Ke.addPossibleMatch(Ze,tt),Ke.addToBlocks(),ze.push(Ke);for(e=1;e7&&ct%2!=0?[{token:"display",type:"terminal"},"(",ot[(ct-1)/2],")",{token:/^[;]*$/,type:"regexp"}]:ct<7&&ct%2!=0?[{token:"let",type:"terminal"},ot[(ct+1)/2],"=",ot[(ct-1)/2],it[(ct-1)/2],rt[(ct-1)/2],{token:/^[;]*$/,type:"regexp"}]:[{token:"let",type:"terminal"},ot[ct/2],"=",ot[(ct-2)/2],it[(ct-2)/2],rt[(ct-2)/2],{token:/^[;]*$/,type:"regexp"}],at[ct].addPossibleMatch(st,ut.slice(0,st.length)),"+"===st[4]||"*"===st[4]){var gt=st.slice();gt[3]=st[5],gt[5]=st[3],at[ct].addPossibleMatch(gt,ut.slice(0,st.length))}at[ct].addToBlocks()}var dt=[function(e,t){var n=function(e,t){return console.warn("MATCH ARR ON MISSING PHRASE",t),t.find((function(e){return e.match&&"text"===e.match.type})),e.remaining,h.a.getExpected(e),"Include some message in between the quotation marks so that the user sees some text!"},o=function(){return'Make sure the text you want to display is between " and " so the computer just displays it without trying to figure out what you mean!'},s=new p,g=s.createStandardHelpMessageManager(),d=e||new c,m=t||Blockly.getMainWorkspace(),T=new f(m);T.clearToolbox(),m.clear(),["text_print","text"].forEach((function(e){T.createToolboxBlock(e,!1),m.options.maxInstances[e]=1})),m.setScale(1),Object(i.f)(m);var _=Array.from(document.querySelectorAll("rect")).filter((function(e){return e.getAttribute("fill-opacity")})),E=_[0],B=_[1];console.warn("TEXT",B);var A=s.createPointer();return document.getElementById("blockly-div").appendChild(A),d.addTask(new r((function(){return m.getAllBlocks().find((function(e){return("text_print"===e.type||"js_text_print"===e.type)&&Blockly.selected!==e}))}),new u([s.createHelpMessageDirections(g,"Drag the "+T2C.MSG.currentLanguage.TERMINAL_DISPLAY+" block somewhere in the workspace.",""),new a(A,{totalSteps:50,startPosition:{x:E.x.baseVal.value+E.width.baseVal.value/2,y:document.getElementById("top-header").offsetHeight+E.y.baseVal.value+E.height.baseVal.value/2},velocity:{x:0,y:2}})]))),d.addTask(new r((function(){return m.getAllBlocks().find((function(e){return"text"===e.type&&e.getParent()&&"text_print"===e.getParent().type}))}),new u([s.createHelpMessageDirections(g,"Drag the text block in the space in the "+T2C.MSG.currentLanguage.TERMINAL_DISPLAY+" block.",""),new a(A,{totalSteps:50,startPosition:{x:B.x.baseVal.value+B.width.baseVal.value/2,y:document.getElementById("top-header").offsetHeight+B.y.baseVal.value+E.height.baseVal.value/2},endPosition:function(){var e=m.getAllBlocks().find((function(e){return"text_print"===e.type||"js_text_print"===e.type}));return x(m,e,{blockOffsetScaleX:.5,blockOffsetScaleY:.5},A.offsetWidth/4,document.getElementById("top-header").offsetHeight-A.offsetHeight/4)}})]))),d.addTask(new r((function(){return m.getAllBlocks().find((function(e){return"text"===e.type&&e.getFieldValue("TEXT")}))}),new u([s.createHelpMessageDirections(g,(function(){return"Click on the area between the quotation marks in the text block and "+T2C.MSG.currentLanguage.TYPE_SOMETHING}),""),new l(A,{totalSteps:100,toggleSteps:25,startPosition:function(){var e=m.getAllBlocks().find((function(e){return"text"===e.type}));return x(m,e,{blockOffsetScaleX:.5,blockOffsetScaleY:1},-A.offsetWidth/4,document.getElementById("top-header").offsetHeight)}})]))),s.addRunTask(g,d,(function(){alert("✔ Congratulations! You just created and ran your first program!"),y.createBlock("level0_display_string_literal_block",{type:"component",name:"code_statement_hybrid",value:{matchManagerType:"display_string_literal",value:{nonEmptyText:!0}}},{textModeFeedbackManager:T2C.FeedbackManagers.code_statement_hybrid.DEFAULT_TEXT_MODE_FEEDBACK_MANAGER,feedbackManager:T2C.FeedbackManagers.display_string_literal,options:{stringLiteralMissingIncludeTextDouble:n,stringLiteralMissingIncludeTextSingle:n,stringLiteralMissingOpenDouble:o}},{feedbackManager:T2C.FeedbackManagers.display_string_literal.feedbackJsonBlock,missing_phrase_error_msg:T2C.FeedbackManagers.display_string_literal.DEFAULT_MISSING_PHRASE_ERROR_MSG,stringLiteralWrongBlock:function(){return T2C.FeedbackManagers.string_literal.DEFAULT_WRONG_BLOCK_MSG},stringLiteralMissingIncludeTextBlock:n},null),T.createToolboxBlock("level0_display_string_literal_block",!0),m.options.maxInstances.level0_display_string_literal_block=1,m.getFlyout().getWorkspace().getAllBlocks().find((function(e){return"level0_display_string_literal_block"===e.type})).setDeletable(!1)}),A),d.addTask(new r((function(){return m.getAllBlocks().find((function(e){return("text_print"===e.type||"js_text_print"===e.type)&&e.getNextBlock()&&"level0_display_string_literal_block"===e.getNextBlock().type&&!m.isDragging()}))}),new u([s.createHelpMessageDirections(g,(function(){return"Drag in the type-in-code block so its top groove connects to the point of the bottom of the "+T2C.MSG.currentLanguage.TERMINAL_DISPLAY+" block."}),""),new a(A,{totalSteps:150,startPosition:function(){var e=k(0);return console.warn(e),{x:e.x.baseVal.value+e.width.baseVal.value/2,y:document.getElementById("top-header").offsetHeight+E.y.baseVal.value+E.height.baseVal.value/2}},endPosition:function(){var e=m.getAllBlocks().find((function(e){return"text_print"===e.type||"js_text_print"===e.type}));return x(m,e,{blockOffsetScaleX:0,blockOffsetScaleY:1.25},A.offsetWidth/4,document.getElementById("top-header").offsetHeight)}})]))),d.addTask(new r((function(){return m.getAllBlocks().find((function(e){return("text_print"===e.type||"js_text_print"===e.type)&&e.getNextBlock()&&("text_print"===e.getNextBlock().type||"js_text_print"===e.getNextBlock().type)&&e.getNextBlock().getInputTargetBlock("TEXT")&&"text"===e.getNextBlock().getInputTargetBlock("TEXT").type}))}),new u([s.createHelpMessageDirections(g,(function(){return"Type in code matching above block but with different text to display. I.e., Type\n"+T2C.MSG.currentLanguage.TEXT_PRINT_TITLE.replace("%1",'"your new message"')+"\nreplacing your new message with whatever you want to display. Be exact with parentheses, quotation marks, etc. Tap off the block when you're done."}),(function(){return"Click the ? on the blocks to see if there's any feedback."})),new l(A,{totalSteps:200,toggleSteps:50,startPosition:function(){var e=m.getAllBlocks().find((function(e){return"level0_display_string_literal_block"===e.type}));return x(m,e,{blockOffsetScaleX:0,blockOffsetScaleY:1},0,document.getElementById("top-header").offsetHeight)}})]))),s.addRunTask(g,d,(function(){alert("✔ Awesome! You just typed code for and ran your first program!"),m.options.maxInstances.level0_display_string_literal_block=0,T.removeToolboxBlocksWithType("level0_display_string_literal_block"),["variables_get","variables_set"].forEach((function(e){var t=document.createElement("block");t.setAttribute("type",e),document.getElementById("toolbox").prepend(t),m.options.maxInstances[e]=1})),m.updateToolbox(document.getElementById("toolbox"))}),A),d.addTask(new r((function(){return m.getAllBlocks().find((function(e){return"variables_set"===e.type&&e.getNextBlock()&&("text_print"===e.getNextBlock().type||"js_text_print"===e.getNextBlock().type)}))}),new u([s.createHelpMessageDirections(g,(function(){return"Drag in the "+T2C.MSG.currentLanguage.TERMINAL_LET+" variable declaration block directly above the "+T2C.MSG.currentLanguage.TERMINAL_DISPLAY+" block so its bottom point connects to the groove of the top of the "+T2C.MSG.currentLanguage.TERMINAL_DISPLAY+" block."}),""),new a(A,{totalSteps:150,startPosition:function(){var e=k(0);return{x:e.x.baseVal.value+e.width.baseVal.value/2,y:document.getElementById("top-header").offsetHeight+e.y.baseVal.value+e.height.baseVal.value/2}},endPosition:function(){var e=m.getAllBlocks().find((function(e){return"text_print"===e.type||"js_text_print"===e.type}));return x(m,e,{blockOffsetScaleX:0,blockOffsetScaleY:0},A.offsetWidth/4,document.getElementById("top-header").offsetHeight)}})]))),d.addTask(new r((function(){return m.getAllBlocks().find((function(e){return"variables_set"===e.type&&e.getInputTargetBlock("VALUE")&&"text"===e.getInputTargetBlock("VALUE").type}))}),new u([s.createHelpMessageDirections(g,(function(){return"Drag the text from inside the "+T2C.MSG.currentLanguage.TERMINAL_DISPLAY+" block to the inside of the "+T2C.MSG.currentLanguage.TERMINAL_LET+" variable declaration block directly above it so the variable stores the text."}),""),new a(A,{totalSteps:150,startPosition:function(){var e=m.getAllBlocks().find((function(e){return"text"===e.type}));return e.getBoundingRectangle(),x(m,e,{blockOffsetScaleX:.5,blockOffsetScaleY:.5},0,document.getElementById("top-header").offsetHeight)},endPosition:function(){var e=m.getAllBlocks().find((function(e){return"variables_set"===e.type}));return e.getBoundingRectangle(),x(m,e,{blockOffsetScaleX:.75,blockOffsetScaleY:.5},0,document.getElementById("top-header").offsetHeight)}})]))),d.addTask(new r((function(){return m.getAllBlocks().find((function(e){return("text_print"===e.type||"js_text_print"===e.type)&&e.getInputTargetBlock("TEXT")&&"variables_get"===e.getInputTargetBlock("TEXT").type}))}),new u([s.createHelpMessageDirections(g,(function(){var e=m.getAllBlocks().find((function(e){return"variables_set"===e.type})),t=m.getAllBlocks().find((function(t){return"text"===t.type&&t.getParent()===e})),n=e?e.getField("VAR").getText():"item",o=t?t.getFieldValue("TEXT"):"";return"Drag the variable get block from the toolbox to the inside of the "+T2C.MSG.currentLanguage.TERMINAL_DISPLAY+" block. This will cause the variable the text is set to ("+o+") to display. (The computer knows to display its value instead of the literal text "+n+" because it is not surrounded by quotation marks.)"}),""),new a(A,{totalSteps:150,startPosition:function(){var e=k(1);return{x:e.x.baseVal.value+e.width.baseVal.value/2,y:document.getElementById("top-header").offsetHeight+e.y.baseVal.value+e.height.baseVal.value/2}},endPosition:function(){var e=m.getAllBlocks().find((function(e){return("text_print"===e.type||"js_text_print"===e.type)&&!e.getInputTargetBlock("TEXT")}));return x(m,e,{blockOffsetScaleX:.5,blockOffsetScaleY:.5},A.offsetWidth/4,document.getElementById("top-header").offsetHeight)}})]))),s.addRunTask(g,d,(function(){alert("👍 Great! Notice how the output is the same as before, but in this program, we store one of the lines of text to display in a variable first. Variables are useful for storing stuff we'll want to use later.");var e=document.createElement("block");e.setAttribute("type","text_input"),document.getElementById("toolbox").prepend(e),m.options.maxInstances.text_input=1,m.updateToolbox(document.getElementById("toolbox"))}),A),d.addTask(new r((function(){return m.getAllBlocks().find((function(e){return"variables_set"===e.type&&e.getInputTargetBlock("VALUE")&&("text_input"===e.getInputTargetBlock("VALUE").type||"js_text_input"===e.getInputTargetBlock("VALUE").type)}))}),new u([s.createHelpMessageDirections(g,(function(){var e=m.getAllBlocks().find((function(e){return"variables_set"===e.type})),t=m.getAllBlocks().find((function(e){return"text_input"===e.type||"js_text_input"===e.type})),n=m.getAllBlocks().find((function(n){return"text"===n.type&&(n.getParent()===e||n.getParent()===t)})),o=e?e.getField("VAR").getText():"item",i=n?n.getFieldValue("TEXT"):"";return"Drag the "+T2C.MSG.currentLanguage.TERMINAL_GETINPUTBYASKING+" block inside the "+T2C.MSG.currentLanguage.TERMINAL_LET+" variable block and move the text block that currently resides there inside the new "+T2C.MSG.currentLanguage.TERMINAL_GETINPUTBYASKING+" block. This will ask the user for text with the message "+i+" and store whatever the user types in the variable "+o+"."}),""),new a(A,{totalSteps:150,startPosition:function(){var e=k(0);return{x:e.x.baseVal.value+e.width.baseVal.value/2,y:document.getElementById("top-header").offsetHeight+e.y.baseVal.value+e.height.baseVal.value/2}},endPosition:function(){var e=m.getAllBlocks().find((function(e){return"variables_set"===e.type}));return x(m,e,{blockOffsetScaleX:.75,blockOffsetScaleY:.5},0,document.getElementById("top-header").offsetHeight)}})]))),d.addTask(new r((function(){return m.getAllBlocks().find((function(e){return"variables_set"===e.type&&"firstName"===e.getField("VAR").getText()}))}),new u([s.createHelpMessageDirections(g,(function(){return"You will be asking the user for his/her first name, and this variable will store it. Rename the variable:\nfirstName\nThis variable is in camel case, which is a convention in Python and JavaScript. This means that the first letter of each word after the first is capitalized."}),(function(){var e=m.getAllBlocks().find((function(e){return"variables_set"===e.type})),t=e&&e.getField("VAR")&&e.getField("VAR").getText()||"";return/\s/.test(t)?"Be sure you type firstName exactly as it appears without spaces. You're not allowed to use spaces in variable names in most programming languages such as Python or JavaScript.":"firstname"===t.toLowerCase()&&"firstName"!==t?"Be sure to enter firstName in camel case (first letter of every word after the first capitalized), a convention for variable names in some programming languages such as Python or JavaScript since spaces are *not* allowed in variable names.":"firstName"!==t?"Check your spelling of firstName, and retype it accordingly.":void 0})),new l(A,{totalSteps:100,toggleSteps:25,startPosition:function(){var e=m.getAllBlocks().find((function(e){return"variables_set"===e.type}));return x(m,e,{blockOffsetScaleX:0,blockOffsetScaleY:.5},A.offsetWidth,document.getElementById("top-header").offsetHeight)}})]))),d.addTask(new r((function(){return m.getAllBlocks().find((function(e){return"text"===e.type&&e.getParent()&&("text_input"===e.getParent().type||"js_text_input"===e.getParent().type)&&(e.getFieldValue("TEXT").toLowerCase().includes("name ")||e.getFieldValue("TEXT").toLowerCase().includes(" name"))}))}),new u([s.createHelpMessageDirections(g,(function(){return"This text is the message the user will receive asking for his/her name. Write a message asking the user for his/her name. Unlike the variable name which cannot have spaces in most programming languages, the message will be seen by the user and should have spaces. The variable will store the name your user enters."}),""),new l(A,{totalSteps:100,toggleSteps:25,startPosition:function(){var e=m.getAllBlocks().find((function(e){return"text"===e.type&&e.getParent()&&("text_input"===e.getParent().type||"js_text_input"===e.getParent().type)}));return e.getBoundingRectangle(),x(m,e,{blockOffsetScaleX:.5,blockOffsetScaleY:.5},-A.offsetWidth/4,document.getElementById("top-header").offsetHeight)}})]))),s.addRunTask(g,d,(function(){alert("👍 Cool! Notice how the output includes what you typed in for your first name. If you run it again and type in something different, you'll see this different name.");var e=document.createElement("block");e.setAttribute("type","t2c_text_join"),document.getElementById("toolbox").prepend(e),m.options.maxInstances.t2c_text_join=1,m.updateToolbox(document.getElementById("toolbox"))}),A),d.addTask(new r((function(){return m.getAllBlocks().find((function(e){return("text_print"===e.type||"js_text_print"===e.type)&&e.getInputTargetBlock("TEXT")&&"t2c_text_join"===e.getInputTargetBlock("TEXT").type}))}),new u([s.createHelpMessageDirections(g,(function(){var e=m.getAllBlocks().find((function(e){return"variables_get"===e.type})),t=m.getAllBlocks().find((function(e){return"text_print"===e.type||"js_text_print"===e.type})),n=m.getAllBlocks().find((function(e){return"text"===e.type&&e.getParent()===t})),o=e?e.getField("VAR").getText():"item",i=n?n.getFieldValue("TEXT"):"";return"Drag the + block inside the "+T2C.MSG.currentLanguage.TERMINAL_DISPLAY+" block, replacing the variable "+o+" get block currently inside it. The + is used to join text expressions together (also called string concatenation). We will join the text "+i+" currently appearing below with the value of the variable "+o+", which is whatever the user types in and use the "+T2C.MSG.currentLanguage.TERMINAL_DISPLAY+" block to display the result on a single line."}),""),new a(A,{totalSteps:150,startPosition:function(){var e=k(0);return{x:e.x.baseVal.value+e.width.baseVal.value/2,y:document.getElementById("top-header").offsetHeight+e.y.baseVal.value+e.height.baseVal.value/2}},endPosition:function(){var e=m.getAllBlocks().find((function(e){return("text_print"===e.type||"js_text_print"===e.type)&&e.getInputTargetBlock("TEXT")&&"variables_get"===e.getInputTargetBlock("TEXT").type}));return x(m,e,{blockOffsetScaleX:.5,blockOffsetScaleY:.5},0,document.getElementById("top-header").offsetHeight)}})]))),d.addTask(new r((function(){return m.getAllBlocks().find((function(e){return("text_print"===e.type||"js_text_print"===e.type)&&e.getInputTargetBlock("TEXT")&&"t2c_text_join"===e.getInputTargetBlock("TEXT").type&&e.getInputTargetBlock("TEXT").getInputTargetBlock("A")&&"text"===e.getInputTargetBlock("TEXT").getInputTargetBlock("A").type}))}),new u([s.createHelpMessageDirections(g,(function(){var e=m.getAllBlocks().find((function(e){return"variables_get"===e.type})),t=m.getAllBlocks().find((function(e){return"text"===e.type&&e.getParent()&&("text_print"===e.getParent().type||"js_text_print"===e.getParent().type)}));return e&&e.getField("VAR").getText(),"Drag the text "+(t?t.getFieldValue("TEXT"):"")+" appearing in the bottom "+T2C.MSG.currentLanguage.TERMINAL_DISPLAY+" block in the left space of the + block."}),""),new a(A,{totalSteps:150,startPosition:function(){var e=m.getAllBlocks().find((function(e){return"text"===e.type&&e.getParent()&&("text_print"===e.getParent().type||"text_print"===e.getParent().type)}));return x(m,e,{blockOffsetScaleX:.5,blockOffsetScaleY:.5},0,document.getElementById("top-header").offsetHeight)},endPosition:function(){var e=m.getAllBlocks().find((function(e){return"t2c_text_join"===e.type}));return x(m,e,{blockOffsetScaleX:.25,blockOffsetScaleY:.5},0,document.getElementById("top-header").offsetHeight)}})]))),d.addTask(new r((function(){return m.getAllBlocks().find((function(e){return("text_print"===e.type||"js_text_print"===e.type)&&e.getInputTargetBlock("TEXT")&&"t2c_text_join"===e.getInputTargetBlock("TEXT").type&&e.getInputTargetBlock("TEXT").getInputTargetBlock("A")&&"text"===e.getInputTargetBlock("TEXT").getInputTargetBlock("A").type&&e.getInputTargetBlock("TEXT").getInputTargetBlock("B")&&"variables_get"===e.getInputTargetBlock("TEXT").getInputTargetBlock("B").type}))}),new u([s.createHelpMessageDirections(g,(function(){var e=m.getAllBlocks().find((function(e){return"variables_get"===e.type}));return"Now drag the variable "+(e?e.getField("VAR").getText():"item")+" block inside the right space of the + block."}),""),new a(A,{totalSteps:150,startPosition:function(){var e=m.getAllBlocks().find((function(e){return"variables_get"===e.type}));return x(m,e,{blockOffsetScaleX:.5,blockOffsetScaleY:.5},0,document.getElementById("top-header").offsetHeight)},endPosition:function(){var e=m.getAllBlocks().find((function(e){return"t2c_text_join"===e.type}));return x(m,e,{blockOffsetScaleX:.75,blockOffsetScaleY:.5},0,document.getElementById("top-header").offsetHeight)}})]))),d.addTask(new r((function(){return 1===m.getAllBlocks().filter((function(e){return"text_print"===e.type||"js_text_print"===e.type})).length}),new u([s.createHelpMessageDirections(g,(function(){return"Now drag the bottom "+T2C.MSG.currentLanguage.TERMINAL_DISPLAY+" block in the trashcan since you no longer need it."}),""),new a(A,{totalSteps:150,startPosition:function(){var e=m.getAllBlocks().find((function(e){return("text_print"===e.type||"js_text_print"===e.type)&&!e.getInputTargetBlock("TEXT")}));return x(m,e,{blockOffsetScaleX:.5,blockOffsetScaleY:.5},0,document.getElementById("top-header").offsetHeight)},endPosition:function(){var e=m.trashcan.getClientRect();return{x:(e.left+e.right)/2,y:(e.top+e.bottom)/2}}})]))),s.addRunTask(g,d,(function(){var e;alert("👍 Great! Notice how the + was used to concatenate or join together the literal message (in quotes) and the name the user enters (*NOT* in quotes)."),(e=document.getElementById("output-container").querySelectorAll(".table-cell")[0]).style.verticalAlign="middle",e.style.color="#000",document.getElementById("output-container").classList.remove("show-container"),document.getElementById("output-container").classList.add("hide-container"),document.getElementById("text-code-container").classList.remove("show-container"),document.getElementById("text-code-container").classList.add("hide-container");var t=document.createElement("block");t.setAttribute("type","type_in_welcome_message"),document.getElementById("toolbox").prepend(t),m.options.maxInstances.type_in_welcome_message=1,m.updateToolbox(document.getElementById("toolbox"))}),A),d.addTask(new r((function(){return 1===m.getAllBlocks().filter((function(e){return"text_print"===e.type||"js_text_print"===e.type})).length&&0===m.getAllBlocks().filter((function(e){return"t2c_text_join"===e.type})).length&&0===m.getAllBlocks().filter((function(e){return"variables_get"===e.type})).length&&1===m.getAllBlocks().filter((function(e){return"text"===e.type})).length}),new u([s.createHelpMessageDirections(g,(function(){return"Now drag the + block with the text and variable blocks inside of it into the trashcan. Do *NOT* drag the "+T2C.MSG.currentLanguage.TERMINAL_DISPLAY+" statement block in the trashcan since we will be using an expression type-in block. In JavaScript, an expression is just something that produces a value whereas a statement does not. As a block, it connects inside such as +, a variable get, text, or "+T2C.MSG.currentLanguage.TERMINAL_GETINPUTBYASKING+"."}),""),new a(A,{totalSteps:150,startPosition:function(){var e=m.getAllBlocks().find((function(e){return"t2c_text_join"===e.type}));return x(m,e,{blockOffsetScaleX:.5,blockOffsetScaleY:.5},0,document.getElementById("top-header").offsetHeight)},endPosition:function(){var e=m.trashcan.getClientRect();return{x:(e.left+e.right)/2,y:(e.top+e.bottom)/2}},finish:function(){m.options.maxInstances.t2c_text_join=0,m.options.maxInstances.variables_get=0,m.updateToolbox(document.getElementById("toolbox"))}})]))),d.addTask(new r((function(){return m.getAllBlocks().find((function(e){return("text_print"===e.type||"js_text_print"===e.type)&&e.getInputTargetBlock("TEXT")&&"type_in_welcome_message"===e.getInputTargetBlock("TEXT").type}))}),new u([s.createHelpMessageDirections(g,(function(){return"Now drag the type-in-expression block inside the "+T2C.MSG.currentLanguage.TERMINAL_DISPLAY+" one."}),(function(){return""})),new a(A,{totalSteps:150,startPosition:function(){var e=k(0);return{x:e.x.baseVal.value+e.width.baseVal.value/2,y:document.getElementById("top-header").offsetHeight+e.y.baseVal.value+e.height.baseVal.value/2}},endPosition:function(){var e=m.getAllBlocks().find((function(e){return"text_print"===e.type||"js_text_print"===e.type}));return x(m,e,{blockOffsetScaleX:.5,blockOffsetScaleY:.5},0,document.getElementById("top-header").offsetHeight)}})]))),d.addTask(new r((function(){var e=m.getAllBlocks().find((function(e){return"text_print"===e.type||"js_text_print"===e.type})),t=e.getInputTargetBlock("TEXT")&&"t2c_text_join"===e.getInputTargetBlock("TEXT").type&&e.getInputTargetBlock("TEXT"),n=t&&t.getInputTargetBlock("A"),o=t&&t.getInputTargetBlock("B");if(!n||!o)return!1;var i="t2c_text_join"===n.type?n.getInputTargetBlock("A"):n,r="t2c_text_join"===n.type?n.getInputTargetBlock("B"):"t2c_text_join"===o.type&&o.getInputTargetBlock("A"),a="t2c_text_join"===o.type?o.getInputTargetBlock("B"):o;return i&&"text"===i.type&&r&&"variables_get"===r.type&&"firstName"===r.getField("VAR").getText()&&a&&"text"===a.type}),new u([s.createHelpMessageDirections(g,(function(){return"Write a message to welcome the user with his/her name with punctuation at the end. To do this type:\n(1) Something like welcome *in quotes* because you want it to be displayed as is.\n(2) + firstName (+ to join text and firstName without the quotes to get the name the user typed in and not literally the text firstName)\n(3) + and a punctuation mark in quotes to tack on a punctuation symbol at the end."}),(function(){return m.getAllBlocks().find((function(e){return"type_in_welcome_message"===e.type}))?b.getErrorFeedback():""})),new l(A,{totalSteps:100,toggleSteps:25,startPosition:function(){var e=m.getAllBlocks().find((function(e){return"type_in_welcome_message"===e.type}));return x(m,e,{blockOffsetScaleX:.5,blockOffsetScaleY:.5},0,document.getElementById("top-header").offsetHeight)},finish:function(){m.options.maxInstances.type_in_welcome_message=0,m.updateToolbox(document.getElementById("toolbox"))}})]))),s.addRunTask(g,d,(function(){alert("✔✔ Excellent! You just wrote a program to welcome the user and along the way you learned some things about variables, getting input from the user, and joining together string literals and variables to produce output. Mission 0 is just about complete; let's just make sure you can save your work and load it up later! For extra credit, we'll show you what your code looks in pure JavaScript.")}),A),s.addSaveTextCodeTask(g,d,m,null,A,!0),d.addTask(new r((function(){return!0}),{start:function(){return!0},isComplete:function(){return!0},animate:function(){return!0},finish:function(){alert("OK, now that you've copied the code, let's clear the workspace of the blocks and then load it (without reloading the page!) to confirm that everything works. BE SURE NOT TO overwrite the clipboard until you load the code again or you'll lose your work!"),s.hideOutputAndCodeContainers()}})),d.addTask(new r((function(){return 0===m.getAllBlocks().length}),new u([s.createHelpMessageDirections(g,(function(){return"Move all blocks to the trashcan or rightmouse click (hold down finger on phone) on an empty place in the workspace and select Delete."}),""),new l(A,{totalSteps:100,toggleSteps:25,startPosition:function(){var e=m.trashcan.getClientRect();return{x:(e.left+e.right)/2,y:(e.top+e.bottom)/2}}})]))),s.addLoadTextCodeTask(g,d,m,null,A),d.addTask(new r((function(){return!0}),{start:function(){return!0},isComplete:function(){return!0},animate:function(){return!0},finish:function(){alert("👍 Great! You can also save/load the information about the blocks (XML) from/to the second box. This will lay out the blocks exactly as you had them in the workspace. So let's try that now."),s.hideOutputAndCodeContainers()}})),s.addSaveXMLTask(g,d,m,null,A,!0),d.addTask(new r((function(){return!0}),{start:function(){return!0},isComplete:function(){return!0},animate:function(){return!0},finish:function(){alert("OK, now that you've copied the XML for the blocks, let's clear the workspace of the blocks and then load it (without reloading the page!) to confirm that everything works. BE SURE NOT TO overwrite the clipboard until you load the code again or you'll lose your work!"),s.hideOutputAndCodeContainers()}})),d.addTask(new r((function(){return 0===m.getAllBlocks().length}),new u([s.createHelpMessageDirections(g,(function(){return"Move all blocks to the trashcan or rightmouse click (hold down finger on phone) on an empty place in the workspace and select Delete."}),""),new l(A,{totalSteps:100,toggleSteps:25,startPosition:function(){var e=m.trashcan.getClientRect();return{x:(e.left+e.right)/2,y:(e.top+e.bottom)/2}}})]))),s.addLoadXMLTask(g,d,m,null,A),d.addTask(new r((function(){return!0}),{start:function(){return!0},isComplete:function(){return!0},animate:function(){return!0},finish:function(){alert("👍 Excellent! As the last part of this initial exercise, let's see how the blocks look in pure JavaScript."),s.hideOutputAndCodeContainers()}})),d.addTask(new r((function(){return"js"===document.getElementById("language").value}),new u([s.createHelpMessageDirections(g,(function(){return"Select JavaScript and then see what happens to the toolbox and blocks."}),""),new l(A,{totalSteps:100,toggleSteps:25,startPosition:{x:document.getElementById("language").offsetLeft+document.getElementById("language").offsetWidth/2,y:document.getElementById("language").offsetTop+document.getElementById("language").offsetHeight/2}})]))),d.addTask(new r((function(){return!0}),{start:function(){return!0},isComplete:function(){return!0},animate:function(){return!0},finish:function(){alert("✔✔✔ Congratulations! You just completed Mission 0! In your upcoming missions, you'll begin to solve problems without explicit instructions of how to use the blocks.")}})),d},function(e,t){var n=new p,o=n.createStandardHelpMessageManager(),a=e||new c,l=t||Blockly.getMainWorkspace();!function(e){Array.from(document.getElementById("toolbox").children).forEach((function(e){return e.remove()})),e.options.maxInstances={},e.updateToolbox(document.getElementById("toolbox"))}(l),["variables_set","text","text_input"].forEach((function(e){B(l,e,!1),l.options.maxInstances[e]=1})),l.clear(),l.setScale(1),Object(i.f)(l);var s=Array.from(document.querySelectorAll("rect")).filter((function(e){return e.getAttribute("fill-opacity")})),u=(s[0],s[1]);console.warn("TEXT",u);var g=n.createPointer();return document.getElementById("blockly-div").appendChild(g),n.addHelpMessageTask(a,o,(function(){var e=l.getAllBlocks().find((function(e){return"variables_set"===e.type})),t=l.getAllBlocks().find((function(e){return"text_input"===e.type||"js_text_input"===e.type})),n=l.getAllBlocks().find((function(e){return"text"===e.type}));return e&&t&&n&&"s"===e.getField("VAR").getText()&&e.getInputTargetBlock("VALUE")===t&&t.getInputTargetBlock("TEXT")===n&&n.getFieldValue("TEXT").includes("5")&&n.getFieldValue("TEXT").includes("letter")}),"Drag in and assemble code blocks to ask the user for a 5-letter word, and store the input in a variable. \nName the variable s AND\nbe sure that the message includes 5 and letters in it so the user knows to enter 5 letters.",(function(){var e=l.getAllBlocks().find((function(e){return"variables_set"===e.type})),t=(l.getAllBlocks().find((function(e){return"text_input"===e.type||"js_text_input"===e.type})),l.getAllBlocks().find((function(e){return"text"===e.type})));if(e){var n=e.getField("VAR").getText();if("item"===n)return"You can change the variable name by clicking item and then selecting Rename variable...";if(n.includes("5")||n.includes("letter"))return"The variable name, which stores the value the user enters, should be s, not "+n+'. The message you want to display to the user should be in the "" block';if("s"!==n)return"The variable name, which stores the value the user enters, should be s, not "+n+"."}if(t){var o=t.getFieldValue("TEXT");if(""===o)return"You can change the text by clicking the blank field and then typing the desired message.";if("s"===o)return"The text which is displayed to the user should contain 5 and letters; the variable name s should appear in the let block.";if(!o.includes("5")||!o.includes("letter"))return"Make sure the text which is displayed to the user contains 5 and letters so the user knows to enter a 5 letter word."}return e&&t&&e.getInputTargetBlock("VALUE")===t?"The variable should store what the user enters, which means you'll need to attach it to a getInputByAsking block.":""}),null),n.addRunTask(o,a,(function(){alert("✔ Good, but notice there's no output yet. That's because all we did is store what the user entered. So now let's add code blocks to display it!"),B(l,"text_print"),B(l,"variables_get"),l.options.maxInstances.text_print=1,l.options.maxInstances.variables_get=1,l.updateToolbox(document.getElementById("toolbox"))}),g),n.addHelpMessageTask(a,o,(function(){var e=l.getAllBlocks().find((function(e){return"variables_set"===e.type})),t=l.getAllBlocks().find((function(e){return"text_print"===e.type||"js_text_print"===e.type})),n=l.getAllBlocks().find((function(e){return"variables_get"===e.type}));return e&&t&&n&&e.getNextBlock()&&e.getNextBlock()===t&&t.getInputTargetBlock("TEXT")===n&&"s"===n.getField("VAR").getText()}),"Now assemble the blocks to display the value of the variable that the user entered.",(function(){var e=l.getAllBlocks().find((function(e){return"variables_set"===e.type})),t=l.getAllBlocks().find((function(e){return"text_print"===e.type||"js_text_print"===e.type})),n=l.getAllBlocks().find((function(e){return"variables_get"===e.type}));if(n&&"s"!==n.getField("VAR").getText())return"Make sure you change the variable name to s since that's what you want to display its value, which is what the user entered.";if(t){if(e){if(t.getNextBlock()&&t.getNextBlock()===e)return"Make sure the display block appears *after* (below) the variable set block. Otherwise the computer would try to display what the user enters before he/she enters it!";if(!e.getNextBlock())return"Make sure to connect the display block below the let block above it. This way the computer will ask the user for a string, store it in s and then display it!"}if(n&&!t.getInputTargetBlock("TEXT"))return"Place the s block inside the display statement to display its value!"}return""}),null),n.addRunTask(o,a,(function(){alert("✔ Great, so now that we echoed what the user entered, it's time for something new! Let's now display the first letter of the user's word."),B(l,"math_number"),B(l,"t2c_text_charat"),l.options.maxInstances.math_number=1,l.options.maxInstances.t2c_text_charat=1,l.options.maxInstances.text_print++,l.options.maxInstances.variables_get++,l.updateToolbox(document.getElementById("toolbox"))}),g),n.addHelpMessageTask(a,o,(function(){var e=l.getAllBlocks().find((function(e){return("text_print"===e.type||"js_text_print"===e.type)&&e.getInputTargetBlock("TEXT")&&"variables_get"===e.getInputTargetBlock("TEXT").type})),t=l.getAllBlocks().find((function(e){return"math_number"===e.type})),n=l.getAllBlocks().find((function(e){return"t2c_text_charat"===e.type||"js_text_charat"===e.type})),o=l.getAllBlocks().find((function(t){return("text_print"===t.type||"js_text_print"===t.type)&&t!==e})),i=l.getAllBlocks().find((function(t){return"variables_get"===t.type&&t.getParent()!==e}));return e&&t&&n&&o&&i&&e.getNextBlock()&&e.getNextBlock()===o&&o.getInputTargetBlock("TEXT")===n&&"s"===i.getField("VAR").getText()&&n.getInputTargetBlock("VALUE")===i&&n.getInputTargetBlock("AT")===t&&0===t.getFieldValue("NUM")}),"The "+T2C.MSG.currentLanguage.TERMINAL_GETCHARACTERNUMBER+" block gets the single character (letter, number, punctuation mark, space, etc.) of the string of characters at the given numerical position, starting with 0. (E.g., for \"pizza\", the 0th character is 'p', the 1st character is 'i', the 2nd character is 'z', etc.\n Add a statement to display the entered string's initial character.\n\nThe string to get the character from goes in the left and the number to get goes in the right.",(function(){var e=l.getAllBlocks().find((function(e){return("text_print"===e.type||"js_text_print"===e.type)&&e.getInputTargetBlock("TEXT")&&"variables_get"===e.getInputTargetBlock("TEXT").type})),t=l.getAllBlocks().find((function(e){return"math_number"===e.type})),n=l.getAllBlocks().find((function(e){return"t2c_text_charat"===e.type||"js_text_charat"===e.type})),o=l.getAllBlocks().find((function(t){return("text_print"===t.type||"js_text_print"===t.type)&&t!==e})),i=l.getAllBlocks().find((function(t){return"variables_get"===t.type&&t.getParent()!==e}));if(o){if(o.getParent()!==e)return"Make sure to connect the new display statement below the previous one since you want to display word's initial letter after displaying the word itself.";if(o.getInputTargetBlock("TEXT")===t)return"You want to display the character at the initial position, not a number. Use the "+T2C.MSG.currentLanguage.TERMINAL_GETCHARACTERNUMBER+" block inside the display.";if(o.getInputTargetBlock("TEXT")===i)return"You want to display the word's initial character, not the entire word. Use the "+T2C.MSG.currentLanguage.TERMINAL_GETCHARACTERNUMBER+" block inside the display."}if(i&&"s"!==i.getField("VAR").getText())return"Make sure you change the variable name to s since you want its value's (user input's) initial letter.";if(n&&i&&n.getInputTargetBlock("AT")===i)return"The variable storing the text (s) that you want to get the character of should go in the left side of the "+T2C.MSG.currentLanguage.TERMINAL_GETCHARACTERNUMBER+" block.";if(t){if(1===t.getFieldValue("NUM"))return"Remember that positions of characters start at 0, not 1.";if(0!==t.getFieldValue("NUM"))return"Remember that you want a number representing the word's inital position. Change the number accordingly."}return""}),null),n.addRunTask(o,a,(function(){alert("✔ Excellent! Now since you displayed the first character of the user's word, how about the last one? But let's make it more interesting this time by having you type in the code to do this instead! You ready? Let's get to it!"),B(l,"type_in_get_last_char_number"),l.options.maxInstances.type_in_get_last_char_number=1,l.updateToolbox(document.getElementById("toolbox"))}),g),n.addHelpMessageTask(a,o,(function(){var e=l.getAllBlocks().find((function(e){return("text_print"===e.type||"js_text_print"===e.type)&&e.getInputTargetBlock("TEXT")&&("t2c_text_charat"===e.getInputTargetBlock("TEXT").type||"js_text_charat"===e.getInputTargetBlock("TEXT").type)})),t=l.getAllBlocks().find((function(t){return("text_print"===t.type||"js_text_print"===t.type)&&t.getParent()===e})),n=l.getAllBlocks().find((function(e){return"math_number"===e.type&&4===e.getFieldValue("NUM")})),o=l.getAllBlocks().find((function(e){return("t2c_text_charat"===e.type||"js_text_charat"===e.type)&&e.getInputTargetBlock("AT")===n&&e.getParent()===t})),i=l.getAllBlocks().find((function(e){return"variables_get"===e.type&&e.getParent()===o&&"s"===e.getField("VAR").getText()}));return e&&n&&o&&t&&i}),"Drag in the new type-in-code block from the toolbox below the statement that displays the inputted word's first character, and type in code to print its last character.\nThe code you type in should match the previous line except you'll use a different number.",(function(){var e=l.getAllBlocks().find((function(e){return("text_print"===e.type||"js_text_print"===e.type)&&e.getInputTargetBlock("TEXT")&&("t2c_text_charat"===e.getInputTargetBlock("TEXT").type||"js_text_charat"===e.getInputTargetBlock("TEXT").type)})),t=l.getAllBlocks().find((function(e){return("text_print"===e.type||"js_text_print"===e.type)&&e.getInputTargetBlock("TEXT")&&("t2c_text_charat"===e.getInputTargetBlock("TEXT").type||"js_text_charat"===e.getInputTargetBlock("TEXT").type)&&e.getInputTargetBlock("TEXT").getInputTargetBlock("AT")&&"math_number"===e.getInputTargetBlock("TEXT").getInputTargetBlock("AT").type&&4===e.getInputTargetBlock("TEXT").getInputTargetBlock("AT").getFieldValue("NUM")})),n=l.getAllBlocks().find((function(e){return"type_in_get_last_char_number"===e.type}));return e&&t&&t.getParent()!==e?"Make sure to connect the new display statement below the previous one since you want to display word's last letter after displaying its first letter.":n?E.getErrorFeedback(n.getFieldValue("EXP")):""}),null),n.addRunTask(o,a,(function(){l.options.maxInstances.type_in_get_last_char_number=0,alert("✔✔👍 Outstanding! So do you feel comfortable with the new "+T2C.MSG.currentLanguage.TERMINAL_GETCHARACTERNUMBER+" block yet? You'll get some more practice with it in the next mission. But for now, let's conclude Mission # 1 by making sure you remember how to save and load this code the next time you want to refer to it. Let's save and load the block code.")}),g),n.addSaveXMLTask(o,a,l,null,g,!0),a.addTask(new r((function(){return!0}),{start:function(){return!0},isComplete:function(){return!0},animate:function(){return!0},finish:function(){alert("OK, now that you've copied the XML for the blocks, let's clear the workspace of the blocks and then load it (without reloading the page!) to confirm that everything works. BE SURE NOT TO overwrite the clipboard until you load the code again or you'll lose your work!"),n.hideOutputAndCodeContainers()}})),n.addDeleteAllBlocksTask(o,a,l,null,g),n.addLoadXMLTask(o,a,l,null,g),a.addTask(new r((function(){return!0}),{start:function(){return!0},isComplete:function(){return!0},animate:function(){return!0},finish:function(){alert("✔✔✔ Congratulations! You just completed Mission 1! In your upcoming mission, you'll get the last character for strings that may not have 5 letters with the help of some new blocks."),n.hideOutputAndCodeContainers()}})),a},function(e,t){var n=new p,o=n.createStandardHelpMessageManager(),a=e||new c,l=t||Blockly.getMainWorkspace();!function(e){Array.from(document.getElementById("toolbox").children).forEach((function(e){return e.remove()})),e.options.maxInstances={},e.updateToolbox(document.getElementById("toolbox"))}(l),["variables_set","text","text_input"].forEach((function(e){A(l,e,!1),l.options.maxInstances[e]=1})),l.clear(),l.setScale(1),Object(i.f)(l);var s=n.createPointer();return document.getElementById("blockly-div").appendChild(s),n.addHelpMessageTask(a,o,(function(){var e=l.getAllBlocks().find((function(e){return"variables_set"===e.type})),t=l.getAllBlocks().find((function(e){return"text_input"===e.type||"js_text_input"===e.type})),n=l.getAllBlocks().find((function(e){return"text"===e.type}));return e&&t&&n&&e.getInputTargetBlock("VALUE")===t&&t.getInputTargetBlock("TEXT")===n&&n.getFieldValue("TEXT")&&!e.getField("VAR").getText().includes(" ")}),"Drag in and assemble code blocks to ask the user for a string of any length, and store the input in a variable. By string, we simply mean a series of characters, which can be numbers, letters, punctuation, or spaces. Choose your own variable name and message this time.",(function(){var e=l.getAllBlocks().find((function(e){return"variables_set"===e.type})),t=(l.getAllBlocks().find((function(e){return"text_input"===e.type||"js_text_input"===e.type})),l.getAllBlocks().find((function(e){return"text"===e.type})));return e&&e.getField("VAR").getText().includes(" ")?"Avoid spaces in your variable names as they won't be allowed if you program in languages such as JavaScript or Python.":t&&""===t.getFieldValue("TEXT")?"You can change the text by clicking the blank field and then typing the desired message.":e&&t&&e.getInputTargetBlock("VALUE")===t?"The variable should store what the user enters, which means you'll need to attach it to a getInputByAsking block.":""}),null),n.addRunTask(o,a,(function(){alert("✔ Good, so as in the previous mission, we won't see any output because we only set a variable. As before, let's display the string next."),A(l,"text_print"),A(l,"variables_get"),l.options.maxInstances.text_print=1,l.options.maxInstances.variables_get=1,l.updateToolbox(document.getElementById("toolbox"))}),s),n.addHelpMessageTask(a,o,(function(){var e=l.getAllBlocks().find((function(e){return"variables_set"===e.type})),t=l.getAllBlocks().find((function(e){return"text_print"===e.type||"js_text_print"===e.type})),n=l.getAllBlocks().find((function(e){return"variables_get"===e.type}));return e&&t&&n&&e.getNextBlock()&&e.getNextBlock()===t&&t.getInputTargetBlock("TEXT")===n&&n.getField("VAR").getText()===e.getField("VAR").getText()}),"Now assemble the blocks to display the value of the variable that the user entered.",(function(){var e=l.getAllBlocks().find((function(e){return"variables_set"===e.type})),t=l.getAllBlocks().find((function(e){return"text_print"===e.type||"js_text_print"===e.type})),n=l.getAllBlocks().find((function(e){return"variables_get"===e.type}));if(n&&e&&n.getField("VAR").getText()!==e.getField("VAR").getText())return"Make sure the variable name you display matches the one you set to the value of the user's input so you display what the user entered.";if(t){if(e){var o=e.getField("VAR").getText();if(t.getNextBlock()&&t.getNextBlock()===e)return"Make sure the "+T2C.MSG.currentLanguage.TERMINAL_DISPLAY+" block appears *after* (below) the "+T2C.MSG.currentLanguage.TERMINAL_LET+" variable block setting "+o+". Otherwise the computer would try to display what the user enters before he/she enters it!";if(!e.getNextBlock())return"Make sure to connect the display block below the "+T2C.MSG.currentLanguage.TERMINAL_LET+" variable block setting "+o+". This way the computer will ask the user for a string, store it in "+o+" and then display it!"}if(n&&!t.getInputTargetBlock("TEXT"))return"Place the variable block inside the display statement to display its value!"}return""}),null),n.addRunTask(o,a,(function(){alert("✔ Great, so now that we echoed what the user entered, it's time for something new! Let's display the number of characters in the string the user entered."),A(l,"t2c_text_length"),l.options.maxInstances.t2c_text_length=1,l.options.maxInstances.text_print++,l.options.maxInstances.variables_get++,l.updateToolbox(document.getElementById("toolbox"))}),s),n.addHelpMessageTask(a,o,(function(){var e=l.getAllBlocks().find((function(e){return("text_print"===e.type||"js_text_print"===e.type)&&e.getInputTargetBlock("TEXT")&&"variables_get"===e.getInputTargetBlock("TEXT").type})),t=l.getAllBlocks().find((function(t){return("text_print"===t.type||"js_text_print"===t.type)&&t!==e})),n=l.getAllBlocks().find((function(t){return"variables_get"===t.type&&t.getParent()!==e})),o=l.getAllBlocks().find((function(e){return"variables_set"===e.type})),i=l.getAllBlocks().find((function(e){return"t2c_text_length"===e.type}));return e&&t&&n&&i&&o&&e.getNextBlock()&&e.getNextBlock()===t&&t.getInputTargetBlock("TEXT")===i&&n.getField("VAR").getText()===o.getField("VAR").getText()&&i.getInputTargetBlock("VALUE")===n}),"The "+T2C.MSG.currentLanguage.TERMINAL_LENGTH+" block gets the number of characters in the provided string. Unlike the "+T2C.MSG.currentLanguage.TERMINAL_GETCHARACTERNUMBER+' block though, the count starts at 1! (E.g., for "pizza", the length would be 5.)\n Add a statement to display the length of the given string.',(function(){var e=l.getAllBlocks().find((function(e){return("text_print"===e.type||"js_text_print"===e.type)&&e.getInputTargetBlock("TEXT")&&"variables_get"===e.getInputTargetBlock("TEXT").type})),t=l.getAllBlocks().find((function(t){return("text_print"===t.type||"js_text_print"===t.type)&&t!==e})),n=l.getAllBlocks().find((function(t){return"variables_get"===t.type&&t.getParent()!==e})),o=l.getAllBlocks().find((function(e){return"variables_set"===e.type})),i=l.getAllBlocks().find((function(e){return"t2c_text_length"===e.type}));if(t){if(t.getParent()!==e)return"Make sure to connect the new display statement below the previous one since you want to display word's length after displaying the word itself.";if(t.getInputTargetBlock("TEXT")===n)return"You want to display the word's length, not the entire word. Use the "+T2C.MSG.currentLanguage.TERMINAL_LENGTH+" block inside the display."}return n&&o&&n.getField("VAR").getText()!==o.getField("VAR").getText()?"Make sure the variable name you display matches the one you set to the value of the user's input so you display what the user entered.":i&&n&&i.getInputTargetBlock("VALUE")!==n?"Be sure to attach the variable block to the "+T2C.MSG.currentLanguage.TERMINAL_LENGTH+" block to get the number of characters in the user input.":""}),null),n.addRunTask(o,a,(function(){alert("✔ Great! Now since you displayed the length of the user's word, can you display double its length instead for good measure? We'll need a new arithmetic block for this."),A(l,"math_number"),A(l,"math_arithmetic_basic"),l.options.maxInstances.math_number=1,l.options.maxInstances.math_arithmetic_basic=1,l.updateToolbox(document.getElementById("toolbox"))}),s),n.addHelpMessageTask(a,o,(function(){var e=l.getAllBlocks().find((function(e){return("text_print"===e.type||"js_text_print"===e.type)&&e.getInputTargetBlock("TEXT")&&"variables_get"===e.getInputTargetBlock("TEXT").type})),t=l.getAllBlocks().find((function(t){return("text_print"===t.type||"js_text_print"===t.type)&&t!==e})),n=l.getAllBlocks().find((function(t){return"variables_get"===t.type&&t.getParent()!==e})),o=l.getAllBlocks().find((function(e){return"variables_set"===e.type})),i=l.getAllBlocks().find((function(e){return"t2c_text_length"===e.type})),r=l.getAllBlocks().find((function(e){return"math_arithmetic_basic"===e.type})),a=l.getAllBlocks().find((function(e){return"math_number"===e.type}));return e&&t&&n&&i&&o&&r&&a&&e.getNextBlock()&&e.getNextBlock()===t&&t.getInputTargetBlock("TEXT")===r&&n.getField("VAR").getText()===o.getField("VAR").getText()&&a.getParent()===r&&i.getParent()===r&&("MULTIPLY"===r.getFieldValue("OP")&&2===a.getFieldValue("NUM")||"DIVIDE"===r.getFieldValue("OP")&&.5===a.getFieldValue("NUM"))}),"The arithmetic block can be used on blocks producing numerical values such as "+T2C.MSG.currentLanguage.TERMINAL_LENGTH+" to add, subtract, multiply, or divide depending on the selected option from +, -, *, / by placing the number-producing blocks you want to use in the calculation.\nUsing this new arithmetic block and number block, modify your display statement to show double the length of the entered string.",(function(){var e=l.getAllBlocks().find((function(e){return("text_print"===e.type||"js_text_print"===e.type)&&e.getInputTargetBlock("TEXT")&&"variables_get"===e.getInputTargetBlock("TEXT").type})),t=l.getAllBlocks().find((function(t){return("text_print"===t.type||"js_text_print"===t.type)&&t!==e})),n=l.getAllBlocks().find((function(t){return"variables_get"===t.type&&t.getParent()!==e})),o=l.getAllBlocks().find((function(e){return"variables_set"===e.type})),i=l.getAllBlocks().find((function(e){return"t2c_text_length"===e.type})),r=l.getAllBlocks().find((function(e){return"math_arithmetic_basic"===e.type})),a=l.getAllBlocks().find((function(e){return"math_number"===e.type}));if(t){if(t.getParent()!==e)return"Make sure the display statement stays below the previous one since you want to display double the word's length after displaying the word itself.";if(t.getInputTargetBlock("TEXT")===i)return"You want to display double the string's length, not just its length. Use the arithmetic (+,-,*,/) block inside the display.";if(t.getInputTargetBlock("TEXT")===n)return"You want to display double the string's length, not the entire string. Use the arithmetic (+,-,*,/) block inside the display.";if(t.getInputTargetBlock("TEXT")===a)return"You want to display double the string's length, not just a number. Use the arithmetic (+,-,*,/) block inside the display."}if(n&&o&&n.getField("VAR").getText()!==o.getField("VAR").getText())return"Make sure the variable name you display matches the one you set to the value of the user's input so you display what the user entered.";if(i&&n&&i.getInputTargetBlock("VALUE")!==n)return"Be sure that the variable block remains inside the "+T2C.MSG.currentLanguage.TERMINAL_LENGTH+" block so you can get the number of characters in the user input before doubling it.";if(r){if(n&&n.getParent()===r)return"Be sure the variable block remains inside the "+T2C.MSG.currentLanguage.TERMINAL_LENGTH+" block since you don't want to double the string itself, but its length! Doubling 'pizza' doesn't give you 10, right? Doubling its length of 5 does.";if(a&&("MULTIPLY"!==r.getFieldValue("OP")&&.5!==a.getFieldValue("NUM")||"DIVIDE"!==r.getFieldValue("OP")&&2!==a.getFieldValue("NUM")))return"What operation/number could you use to double the length? Select the appropriate option from the dropdown (+ = ADD, - = SUBTRACT, * = MULTIPLY, / = DIVIDE), and change the value of the number block from "+a.getFieldValue("NUM")+" to this desired number accordingly."}return""}),null),n.addRunTask(o,a,(function(){alert("✔ Excellent! OK, so now that you can use the arithmetic and length blocks, let's combine them with the previous "+T2C.MSG.currentLanguage.TERMINAL_GETCHARACTERNUMBER+" block to get the last character of the string, regardless of whether it's 1 character or 100 or any other number! You up for the challenge? Let's get to it!"),A(l,"t2c_text_charat"),l.options.maxInstances.t2c_text_charat=1,l.options.maxInstances.variables_get++,l.updateToolbox(document.getElementById("toolbox"))}),s),n.addHelpMessageTask(a,o,(function(){var e=l.getAllBlocks().find((function(e){return("text_print"===e.type||"js_text_print"===e.type)&&e.getInputTargetBlock("TEXT")&&"variables_get"===e.getInputTargetBlock("TEXT").type})),t=l.getAllBlocks().find((function(e){return"t2c_text_charat"===e.type||"js_text_charat"===e.type})),n=l.getAllBlocks().find((function(e){return("text_print"===e.type||"js_text_print"===e.type)&&e.getInputTargetBlock("TEXT")===t})),o=l.getAllBlocks().find((function(e){return"math_arithmetic_basic"===e.type})),i=l.getAllBlocks().find((function(e){return"t2c_text_length"===e.type})),r=l.getAllBlocks().find((function(e){return"math_number"===e.type})),a=l.getAllBlocks().find((function(e){return"variables_get"===e.type&&e.getParent()===t})),s=l.getAllBlocks().find((function(e){return"variables_get"===e.type&&e.getParent()===i})),u=l.getAllBlocks().find((function(e){return"variables_set"===e.type}));return e&&n&&o&&i&&r&&t&&a&&s&&u&&a.getField("VAR").getText()===u.getField("VAR").getText()&&s.getField("VAR").getText()===u.getField("VAR").getText()&&t.getInputTargetBlock("VALUE")===a&&t.getInputTargetBlock("AT")===o&&o.getInputTargetBlock("A")===i&&"MINUS"===o.getFieldValue("OP")&&o.getInputTargetBlock("B")===r&&1===r.getFieldValue("NUM")}),"Change the math operation and number that's used with the "+T2C.MSG.currentLanguage.TERMINAL_LENGTH+" to calculate the *position* of the last character from its number of characters. Then add a "+T2C.MSG.currentLanguage.TERMINAL_GETCHARACTERNUMBER+" and variable block in the appropriate places to display the last character, regardless of the length of the string. To determine the appropriate math operation and number to use for the position, consider strings of different lengths. How did you determine the number to use for the position of the last character of a 5-character string? What would you do with the 5 to get it? What if you wanted to calculate the position of the last character of a string of length 3? What about the position of the last character for a string of length 10? The math operation and number you use should be the same for each example to get your answer.",(function(){var e=l.getAllBlocks().find((function(e){return("text_print"===e.type||"js_text_print"===e.type)&&e.getInputTargetBlock("TEXT")&&"variables_get"===e.getInputTargetBlock("TEXT").type})),t=l.getAllBlocks().find((function(e){return"t2c_text_charat"===e.type||"js_text_charat"===e.type})),n=l.getAllBlocks().find((function(t){return("text_print"===t.type||"js_text_print"===t.type)&&t!==e})),o=l.getAllBlocks().find((function(e){return"math_arithmetic_basic"===e.type})),i=l.getAllBlocks().find((function(e){return"t2c_text_length"===e.type})),r=l.getAllBlocks().find((function(e){return"math_number"===e.type})),a=(l.getAllBlocks().find((function(e){return"variables_get"===e.type&&e.getParent()===i})),l.getAllBlocks().find((function(e){return"variables_get"===e.type&&e.getParent()===t})));if(l.getAllBlocks().find((function(e){return"variables_set"===e.type})),n&&n.getParent()!==e)return"Make sure to connect the new display statement below the previous one since you want to display the string's last character after displaying the whole string.";if(t){if(a&&t.getInputTargetBlock("AT")===a)return"The variable storing the text that you want to get the character of should go in the left side of the "+T2C.MSG.currentLanguage.TERMINAL_GETCHARACTERNUMBER+' block. It wouldn\'t make sense to get the character at position number "pizza" (or whatever string the user enters), right?';if(i&&t.getInputTargetBlock("AT")===i)return"The length of the 5-character string pizza is 5, but since you start counting from 0, this was not the position of the last character that you used in the previous exercise, correct? Consider using some math operation on this number to calculate the correct position.";if(r&&t.getInputTargetBlock("AT")===r)return"The position of the last character will depend on the length of the string so you can't use a specific number such as "+r.getFieldValue("NUM")+". You will need to use the "+MSG.T2C.currentLanguage.TERMINAL_LENGTH+" block and a math operation to calculate the correct position for each string containing at least one character."}if(n&&t){if(n.getInputTargetBlock("TEXT")===o)return"You want to display the string's last character, not the result of an arithmetic calculation, which would be a number.";if(n.getInputTargetBlock("TEXT")===i)return"You want to display the string's last character, not the length of the string, which would be a number.";if(n.getInputTargetBlock("TEXT")===r)return"You want to display the string's last character, not a number."}if(o&&r&&i&&t&&r.getParent()===o&&i.getParent()===o){if("PLUS"===o.getFieldValue("OP")&&1===r.getFieldValue("NUM"))return"Consider that adding 1 to 5, which is the length of pizza gives you 6. Did you use 6 for the position for the last mission?";if("PLUS"!==o.getFieldValue("OP")&&1!==r.getFieldValue("NUM")||"MINUS"!==o.getFieldValue("OP")&&-1!==r.getFieldValue("NUM"))return"Select the appropriate option from the arithmetic block dropdown menu (+ = ADD, - = SUBTRACT, * = MULTIPLY, / = DIVIDE) and choose the appropriate number. Your current answer won't work in general."}return""}),null),n.addRunTask(o,a,(function(){l.options.maxInstances.type_in_get_last_char_number=0,alert("✔✔👍 Outstanding! So do you feel comfortable with using the new "+T2C.MSG.currentLanguage.TERMINAL_LENGTH+" block in combination with the arithmetic and "+T2C.MSG.currentLanguage.TERMINAL_GETCHARACTERNUMBER+" blocks yet? In the next mission, we'll use these blocks to get the middle two characters of strings with an even number of characters (and not 0). But for now, let's conclude Mission # 2 by making sure you can save this code for later use. Let's save and load the block code.")}),s),n.addSaveXMLTask(o,a,l,null,s,!0),a.addTask(new r((function(){return!0}),{start:function(){return!0},isComplete:function(){return!0},animate:function(){return!0},finish:function(){alert("OK, now that you've copied the XML for the blocks, let's clear the workspace of the blocks and then load it (without reloading the page!) to confirm that everything works. BE SURE NOT TO overwrite the clipboard until you load the code again or you'll lose your work!"),n.hideOutputAndCodeContainers()}})),n.addDeleteAllBlocksTask(o,a,l,null,s),n.addLoadXMLTask(o,a,l,null,s),a.addTask(new r((function(){return!0}),{start:function(){return!0},isComplete:function(){return!0},animate:function(){return!0},finish:function(){alert("✔✔✔ Congratulations! You just completed Mission 2! On to even tougher challenges ahead!"),n.hideOutputAndCodeContainers()}})),a},function(e,t){var n=e||new c;alert("In this mission, you'll be prompting the user for a string with an even number of characters (at least 2) and then displaying a single 4-character string as first character, last character, first middle character, and second middle character in that order. For example, for SCRABBLE, you'd display SEAB.");var o=t||Blockly.getMainWorkspace();N(o),["type_in_get_input"].forEach((function(e){L(o,e,!1),o.options.maxInstances[e]=1})),o.clear();var a=O("variables_set"),g=O("text_input"),d=O("text");C(d,"TEXT","message to user"),R(g,"TEXT",d),R(a,"VALUE",g),o.options.maxInstances.variables_set=0,document.getElementById("toolbox").append(a),o.updateToolbox(document.getElementById("toolbox")),o.setScale(1),Object(i.f)(o),Array.from(document.querySelectorAll("rect")).filter((function(e){return e.getAttribute("fill-opacity")}));var h=document.createElement("div");return h.innerText="👆",h.id="ptr",h.style.fontSize="x-large",h.style.position="absolute",h.style.zIndex="1001",document.getElementById("blockly-div").appendChild(h),n.addTask(new r((function(){var e=o.getAllBlocks().find((function(e){return"text"===e.type&&-1!==e.getFieldValue("TEXT").toLowerCase().indexOf(" even ")})),t=o.getAllBlocks().find((function(t){return("text_input"===t.type||"js_text_input"===t.type)&&t.getInputTargetBlock("TEXT")===e})),n=o.getAllBlocks().find((function(e){return"variables_set"===e.type&&null===e.getNextBlock()&&e.getInputTargetBlock("VALUE")===t&&"s"===e.getField("VAR").getText()}));return e&&t&&n}),new s((function(){return"OK, you know the drill; let's start by asking the user for a string and storing it in a variable. This time, we'll be asking the user for a string with an even number of characters (> 0) so make sure even (surrounded by spaces) appears in your message. Let's store the user's string in a variable s. But this time, we'll make it more interesting: you'll drag in the block and type in the code! Do you remember what you'll be typing, i.e., what appeared on the blocks, from previous exercises? If not, use the blocks above as reference, and start typing it in accordingly. Don't worry, we'll give you hints if you make a mistake."}),{startPosition:F(o,null,{},50,document.getElementById("top-header").offsetHeight+50)}))),n.addTask(new r((function(){return!0}),{start:function(){return!0},isComplete:function(){return!0},animate:function(){return!0},finish:function(){alert("✔ Good, so let's start by creating a variable named firstCharacter to store the initial character of the string the user enters. As before, we'll make it more interesting by typing in the code."),S(document.getElementById("output-container").querySelectorAll(".table-cell")[0]),M(),N(o);var e=O("variables_set"),t=O("variables_get"),n=O("t2c_text_charat"),i=O("math_number");C(i,"NUM",0),C(t,"VAR","textVariable"),R(n,"VALUE",t),R(n,"AT",i),R(e,"VALUE",n),L(o,"type_in_set_to_char_number_0"),o.options.maxInstances.variables_set=0,o.options.maxInstances.type_in_set_to_char_number_0=1,document.getElementById("toolbox").append(e),o.updateToolbox(document.getElementById("toolbox"))}})),n.addTask(new r((function(){var e=o.getAllBlocks().find((function(e){return"math_number"===e.type&&0===e.getFieldValue("NUM")})),t=o.getAllBlocks().find((function(e){return"variables_get"===e.type&&"s"===e.getField("VAR").getText()})),n=o.getAllBlocks().find((function(n){return("t2c_text_charat"===n.type||"js_text_charat"===n.type)&&n.getInputTargetBlock("VALUE")===t&&n.getInputTargetBlock("AT")===e})),i=o.getAllBlocks().find((function(e){return"variables_set"===e.type&&null===e.getNextBlock()&&e.getInputTargetBlock("VALUE")===n&&"firstChar"===e.getField("VAR").getText()})),r=o.getAllBlocks().find((function(e){return"text"===e.type&&-1!==e.getFieldValue("TEXT").toLowerCase().indexOf(" even ")})),a=o.getAllBlocks().find((function(e){return("text_input"===e.type||"js_text_input"===e.type)&&e.getInputTargetBlock("TEXT")===r})),l=o.getAllBlocks().find((function(e){return"variables_set"===e.type&&e.getNextBlock()===i&&e.getInputTargetBlock("VALUE")===a&&"s"===e.getField("VAR").getText()}));return e&&t&&n&&i&&r&&a&&l}),new s((function(){var e=o.getAllBlocks().find((function(e){return"variables_set"===e.type&&"firstChar"===e.getField("VAR").getText()})),t=o.getAllBlocks().find((function(e){return"variables_set"===e.type&&"s"===e.getField("VAR").getText()}));return e&&t&&t.getPreviousBlock()===e?"Make sure to attach the block storing the entered string's first character below the one storing the string itself. Since instructions are run top to bottom, if you reversed the order, the computer wouldn't know what s is when trying get the string!":e&&t&&e.getPreviousBlock()!==t?"Make sure to attach the block storing the entered string's first character below the one storing the string itself.":"Drag in the type-in-code block and enter the code needed to get and store the initial character of the entered string in the variable firstChar. Be sure to attach this statement below the one declaring the variable to store the user's entered string."}),{startPosition:F(o,null,{},50,document.getElementById("top-header").offsetHeight+50)}))),n.addTask(new r((function(){return!0}),{start:function(){return!0},isComplete:function(){return!0},animate:function(){return!0},finish:function(){alert("✔ Good, so now we'll define a variable named lastCharacter to store the last character of the string the user enters. As before, you'll be typing in the code and as in the previous mission, remember that you don't know how many characters the string has so you'll be using "+T2C.MSG.currentLanguage.TERMINAL_LENGTH+" in your answer."),S(document.getElementById("output-container").querySelectorAll(".table-cell")[0]),M(),N(o);var e=O("variables_set"),t=O("variables_get"),n=O("variables_get"),i=O("t2c_text_charat"),r=O("math_number"),a=O("math_arithmetic_basic"),l=O("t2c_text_length");C(r,"NUM",1),C(t,"VAR","textVariable"),C(n,"VAR","textVariable"),R(i,"VALUE",t),R(i,"AT",a),R(a,"A",l),R(l,"VALUE",n),R(a,"B",r),C(a,"OP","MINUS"),R(e,"VALUE",i),L(o,"type_in_set_to_last_char"),o.options.maxInstances.variables_set=0,o.options.maxInstances.type_in_set_to_last_char=1,document.getElementById("toolbox").append(e),o.updateToolbox(document.getElementById("toolbox"))}})),n.addTask(new r((function(){var e=o.getAllBlocks().find((function(e){return"math_number"===e.type&&1===e.getFieldValue("NUM")})),t=o.getAllBlocks().find((function(e){return"t2c_text_length"===e.type&&e.getInputTargetBlock("VALUE")&&"variables_get"===e.getInputTargetBlock("VALUE").type&&"s"===e.getInputTargetBlock("VALUE").getField("VAR").getText()})),n=o.getAllBlocks().find((function(n){return"math_arithmetic_basic"===n.type&&n.getInputTargetBlock("A")===t&&n.getInputTargetBlock("B")===e&&"MINUS"===n.getFieldValue("OP")})),i=o.getAllBlocks().find((function(e){return("t2c_text_charat"===e.type||"js_text_charat"===e.type)&&e.getInputTargetBlock("VALUE")&&"variables_get"===e.getInputTargetBlock("VALUE").type&&"s"===e.getInputTargetBlock("VALUE").getField("VAR").getText()&&e.getInputTargetBlock("AT")===n})),r=o.getAllBlocks().find((function(e){return"variables_set"===e.type&&null===e.getNextBlock()&&e.getInputTargetBlock("VALUE")===i&&"lastChar"===e.getField("VAR").getText()})),a=o.getAllBlocks().find((function(e){return"math_number"===e.type&&0===e.getFieldValue("NUM")})),l=o.getAllBlocks().find((function(e){return("t2c_text_charat"===e.type||"js_text_charat"===e.type)&&e.getInputTargetBlock("VALUE")&&"variables_get"===e.getInputTargetBlock("VALUE").type&&"s"===e.getInputTargetBlock("VALUE").getField("VAR").getText()&&e.getInputTargetBlock("AT")===a})),s=o.getAllBlocks().find((function(e){return"variables_set"===e.type&&e.getNextBlock()===r&&e.getInputTargetBlock("VALUE")===l&&"firstChar"===e.getField("VAR").getText()})),u=o.getAllBlocks().find((function(e){return"text"===e.type})),c=o.getAllBlocks().find((function(e){return("text_input"===e.type||"js_text_input"===e.type)&&e.getInputTargetBlock("TEXT")===u})),g=o.getAllBlocks().find((function(e){return"variables_set"===e.type&&e.getNextBlock()===s&&e.getInputTargetBlock("VALUE")===c&&"s"===e.getField("VAR").getText()}));return e&&t&&n&&i&&r&&a&&l&&s&&u&&c&&g}),new s((function(){var e=o.getAllBlocks().find((function(e){return"variables_set"===e.type&&"lastChar"===e.getField("VAR").getText()})),t=o.getAllBlocks().find((function(e){return"variables_set"===e.type&&"firstChar"===e.getField("VAR").getText()})),n=o.getAllBlocks().find((function(e){return"variables_set"===e.type&&"s"===e.getField("VAR").getText()}));return n&&e&&n.getPreviousBlock()===e?"Make sure to attach the block storing the entered string's last character below the one storing the string itself. Since instructions are run top to bottom, if you reversed the order, the computer wouldn't know what s is when trying get the string!":t&&e&&e.getPreviousBlock()!==t?"Make sure to attach the block storing the entered string's last character below the one storing the string's first one. Although it won't matter which we store first, we'll do it this way for the purposes of this exercise.":"Drag in the type-in-code block and enter the code needed to get and store the last character of the entered string in the variable lastChar. Be sure to attach this statement below the one declaring the variable to store the entered string's first character."}),{startPosition:F(o,null,{},50,document.getElementById("top-header").offsetHeight+50)}))),n.addTask(new r((function(){return!0}),{start:function(){return!0},isComplete:function(){return!0},animate:function(){return!0},finish:function(){alert("✔ Great, so enough review, it's time for something new! We will need to get the middle two characters. Just like the last character, this will require do some math on the length of the string to get the correct position numbers. Let's start by getting just the *position* of the *2nd* middle character first. We'll do the second first because the relationship between the length and the last position is easier to see. And then we can use this number to get the position of the first middle character since it appears one place before the second."),S(document.getElementById("output-container").querySelectorAll(".table-cell")[0]),M(),N(o),L(o,"type_in_set_to_position_of_second_middle_char"),o.options.maxInstances.type_in_set_to_position_of_second_middle_char=1,o.updateToolbox(document.getElementById("toolbox"))}})),n.addTask(new r((function(){var e=o.getAllBlocks().find((function(e){return"math_number"===e.type&&2===e.getFieldValue("NUM")})),t=o.getAllBlocks().find((function(t){return"math_arithmetic_basic"===t.type&&t.getInputTargetBlock("A")&&"t2c_text_length"===t.getInputTargetBlock("A").type&&t.getInputTargetBlock("A").getInputTargetBlock("VALUE")&&"variables_get"===t.getInputTargetBlock("A").getInputTargetBlock("VALUE").type&&"s"===t.getInputTargetBlock("A").getInputTargetBlock("VALUE").getField("VAR").getText()&&t.getInputTargetBlock("B")===e&&"DIVIDE"===t.getFieldValue("OP")})),n=o.getAllBlocks().find((function(e){return"variables_set"===e.type&&null===e.getNextBlock()&&e.getInputTargetBlock("VALUE")===t&&"positionOfSecondMiddleChar"===e.getField("VAR").getText()})),i=o.getAllBlocks().find((function(e){return"math_number"===e.type&&1===e.getFieldValue("NUM")})),r=o.getAllBlocks().find((function(e){return"math_arithmetic_basic"===e.type&&e.getInputTargetBlock("A")&&"t2c_text_length"===e.getInputTargetBlock("A").type&&e.getInputTargetBlock("A").getInputTargetBlock("VALUE")&&"variables_get"===e.getInputTargetBlock("A").getInputTargetBlock("VALUE").type&&"s"===e.getInputTargetBlock("A").getInputTargetBlock("VALUE").getField("VAR").getText()&&e.getInputTargetBlock("B")===i&&"MINUS"===e.getFieldValue("OP")})),a=o.getAllBlocks().find((function(e){return("t2c_text_charat"===e.type||"js_text_charat"===e.type)&&e.getInputTargetBlock("VALUE")&&"variables_get"===e.getInputTargetBlock("VALUE").type&&"s"===e.getInputTargetBlock("VALUE").getField("VAR").getText()&&e.getInputTargetBlock("AT")===r})),l=o.getAllBlocks().find((function(e){return"variables_set"===e.type&&e.getNextBlock()===n&&e.getInputTargetBlock("VALUE")===a&&"lastChar"===e.getField("VAR").getText()})),s=o.getAllBlocks().find((function(e){return"math_number"===e.type&&0===e.getFieldValue("NUM")})),u=o.getAllBlocks().find((function(e){return("t2c_text_charat"===e.type||"js_text_charat"===e.type)&&e.getInputTargetBlock("VALUE")&&"variables_get"===e.getInputTargetBlock("VALUE").type&&"s"===e.getInputTargetBlock("VALUE").getField("VAR").getText()&&e.getInputTargetBlock("AT")===s})),c=o.getAllBlocks().find((function(e){return"variables_set"===e.type&&e.getNextBlock()===l&&e.getInputTargetBlock("VALUE")===u&&"firstChar"===e.getField("VAR").getText()})),g=o.getAllBlocks().find((function(e){return"text"===e.type})),d=o.getAllBlocks().find((function(e){return("text_input"===e.type||"js_text_input"===e.type)&&e.getInputTargetBlock("TEXT")===g})),h=o.getAllBlocks().find((function(e){return"variables_set"===e.type&&e.getNextBlock()===c&&e.getInputTargetBlock("VALUE")===d&&"s"===e.getField("VAR").getText()}));return e&&t&&n&&i&&r&&a&&l&&s&&u&&c&&g&&d&&h}),new s((function(){var e=o.getAllBlocks().find((function(e){return"variables_set"===e.type&&"positionOfSecondMiddleChar"===e.getField("VAR").getText()})),t=(o.getAllBlocks().find((function(e){return"variables_set"===e.type&&"lastChar"===e.getField("VAR").getText()})),o.getAllBlocks().find((function(e){return"variables_set"===e.type&&"s"===e.getField("VAR").getText()}))),n=e&&e.getPreviousBlock()&&"variables_set"===e.getPreviousBlock().type&&e.getPreviousBlock().getField("VAR").getText();return e&&e.getNextBlock()&&"variables_set"===e.getNextBlock().type&&e.getNextBlock().getField("VAR").getText(),e&&t&&e.getNextBlock()===t?"Make sure to attach the block storing the position of the string's second middle character below the one storing the string itself. Since instructions are run top to bottom, if you reversed the order, the computer wouldn't know what s is when trying to get its length in the calculation of the its second middle character's position!":!e||n&&"lastChar"===n?"Drag in the type-in-code block, and enter the code needed to calculate the position of the second middle character of the entered string FROM the string's length and store it in the variable positionOfSecondMiddleChar. Be sure to attach this statement below the one declaring the variable to store the entered string's last character.\nThis means you'll be using s.length and a math operation in your code.\nIf you're not sure what math operation and number to use, consider the following strings' lengths and second middle character positions: \nat : 2 | 1\ncode : 4 | 2\npizzas : 6 | 3\nscrabble : 8 | 4":"Make sure to attach this block storing the position of the second middle character below the last one you entered in which you store the last character in the variable lastChar."}),{startPosition:F(o,null,{},50,document.getElementById("top-header").offsetHeight+50)}))),n.addTask(new r((function(){return!0}),{start:function(){return!0},isComplete:function(){return!0},animate:function(){return!0},finish:function(){alert("✔ Great again! So now let's get the *position* of the first middle character. Remember the first middle character appears *one place before* the second so what math operation can you use on the position of the second middle character to get the position of the first middle character?"),S(document.getElementById("output-container").querySelectorAll(".table-cell")[0]),M(),N(o),L(o,"type_in_set_to_position_of_first_middle_char"),o.options.maxInstances.type_in_set_to_position_of_first_middle_char=1,o.updateToolbox(document.getElementById("toolbox"))}})),n.addTask(new r((function(){var e=o.getAllBlocks().find((function(e){return"variables_get"===e.type&&"positionOfSecondMiddleChar"===e.getField("VAR").getText()})),t=o.getAllBlocks().find((function(t){return"math_arithmetic_basic"===t.type&&t.getInputTargetBlock("A")===e&&t.getInputTargetBlock("B")&&"math_number"===t.getInputTargetBlock("B").type&&1===t.getInputTargetBlock("B").getFieldValue("NUM")&&"MINUS"===t.getFieldValue("OP")})),n=o.getAllBlocks().find((function(e){return"variables_set"===e.type&&null===e.getNextBlock()&&e.getInputTargetBlock("VALUE")===t&&"positionOfFirstMiddleChar"===e.getField("VAR").getText()})),i=o.getAllBlocks().find((function(e){return"math_number"===e.type&&2===e.getFieldValue("NUM")})),r=o.getAllBlocks().find((function(e){return"math_arithmetic_basic"===e.type&&e.getInputTargetBlock("A")&&"t2c_text_length"===e.getInputTargetBlock("A").type&&e.getInputTargetBlock("A").getInputTargetBlock("VALUE")&&"variables_get"===e.getInputTargetBlock("A").getInputTargetBlock("VALUE").type&&"s"===e.getInputTargetBlock("A").getInputTargetBlock("VALUE").getField("VAR").getText()&&e.getInputTargetBlock("B")===i&&"DIVIDE"===e.getFieldValue("OP")})),a=o.getAllBlocks().find((function(e){return"variables_set"===e.type&&e.getNextBlock()===n&&e.getInputTargetBlock("VALUE")===r&&"positionOfSecondMiddleChar"===e.getField("VAR").getText()})),l=o.getAllBlocks().find((function(e){return"math_arithmetic_basic"===e.type&&e.getInputTargetBlock("A")&&"t2c_text_length"===e.getInputTargetBlock("A").type&&e.getInputTargetBlock("A").getInputTargetBlock("VALUE")&&"variables_get"===e.getInputTargetBlock("A").getInputTargetBlock("VALUE").type&&"s"===e.getInputTargetBlock("A").getInputTargetBlock("VALUE").getField("VAR").getText()&&e.getInputTargetBlock("B")&&"math_number"===e.getInputTargetBlock("B").type&&1===e.getInputTargetBlock("B").getFieldValue("NUM")&&"MINUS"===e.getFieldValue("OP")})),s=o.getAllBlocks().find((function(e){return("t2c_text_charat"===e.type||"js_text_charat"===e.type)&&e.getInputTargetBlock("VALUE")&&"variables_get"===e.getInputTargetBlock("VALUE").type&&"s"===e.getInputTargetBlock("VALUE").getField("VAR").getText()&&e.getInputTargetBlock("AT")===l})),u=o.getAllBlocks().find((function(e){return"variables_set"===e.type&&e.getNextBlock()===a&&e.getInputTargetBlock("VALUE")===s&&"lastChar"===e.getField("VAR").getText()})),c=o.getAllBlocks().find((function(e){return"math_number"===e.type&&0===e.getFieldValue("NUM")})),g=o.getAllBlocks().find((function(e){return("t2c_text_charat"===e.type||"js_text_charat"===e.type)&&e.getInputTargetBlock("VALUE")&&"variables_get"===e.getInputTargetBlock("VALUE").type&&"s"===e.getInputTargetBlock("VALUE").getField("VAR").getText()&&e.getInputTargetBlock("AT")===c})),d=o.getAllBlocks().find((function(e){return"variables_set"===e.type&&e.getNextBlock()===u&&e.getInputTargetBlock("VALUE")===g&&"firstChar"===e.getField("VAR").getText()})),h=o.getAllBlocks().find((function(e){return"text"===e.type})),p=o.getAllBlocks().find((function(e){return("text_input"===e.type||"js_text_input"===e.type)&&e.getInputTargetBlock("TEXT")===h})),f=o.getAllBlocks().find((function(e){return"variables_set"===e.type&&e.getNextBlock()===d&&e.getInputTargetBlock("VALUE")===p&&"s"===e.getField("VAR").getText()}));return e&&t&&n&&i&&r&&a&&l&&s&&u&&c&&g&&d&&h&&p&&f}),new s((function(){var e=o.getAllBlocks().find((function(e){return"variables_set"===e.type&&"positionOfFirstMiddleChar"===e.getField("VAR").getText()})),t=o.getAllBlocks().find((function(e){return"variables_set"===e.type&&"positionOfSecondMiddleChar"===e.getField("VAR").getText()})),n=e&&e.getPreviousBlock()&&"variables_set"===e.getPreviousBlock().type&&e.getPreviousBlock().getField("VAR").getText();return e&&e.getNextBlock()&&"variables_set"===e.getNextBlock().type&&e.getNextBlock().getField("VAR").getText(),e&&t&&e.getNextBlock(),!e||n&&"positionOfSecondMiddleChar"===n?"Drag in the type-in-code block, and enter the code needed to calculate the position of the first middle character of the entered string FROM the position of the second middle character and store it in the variable positionOfFirstMiddleChar. Be sure to attach this statement below the one declaring the variable to store the position of the entered string's second middle character.\nThis means you'll be using positionOfFirstMiddleChar and a math operation in your code.\nIf you're not sure what math operation and number to use, consider the positions of the second middle characters and first characters of the following: \nat : 1 | 0\ncode : 2 | 1\npizzas : 3 | 2\nscrabble : 4 | 3":"Make sure to attach this block storing the position of the first middle character below the last one you entered in which you store the position of the second middle character in the variable positionOfSecondMiddleChar."}),{startPosition:F(o,null,{},50,document.getElementById("top-header").offsetHeight+50)}))),n.addTask(new r((function(){return!0}),{start:function(){return!0},isComplete:function(){return!0},animate:function(){return!0},finish:function(){alert("✔ Excellent! So now that we have the positions of the first and second middle characters, let's store the characters themselves, starting with the first middle one."),S(document.getElementById("output-container").querySelectorAll(".table-cell")[0]),M(),N(o),L(o,"type_in_get_first_middle_char"),o.options.maxInstances.type_in_get_first_middle_char=1,o.updateToolbox(document.getElementById("toolbox"))}})),n.addTask(new r((function(){var e=o.getAllBlocks().find((function(e){return"variables_get"===e.type&&"positionOfFirstMiddleChar"===e.getField("VAR").getText()})),t=o.getAllBlocks().find((function(t){return("t2c_text_charat"===t.type||"js_text_charat"===t.type)&&t.getInputTargetBlock("VALUE")&&"variables_get"===t.getInputTargetBlock("VALUE").type&&"s"===t.getInputTargetBlock("VALUE").getField("VAR").getText()&&t.getInputTargetBlock("AT")===e})),n=o.getAllBlocks().find((function(e){return"variables_set"===e.type&&null===e.getNextBlock()&&e.getInputTargetBlock("VALUE")===t&&"firstMiddleChar"===e.getField("VAR").getText()})),i=o.getAllBlocks().find((function(e){return"variables_get"===e.type&&"positionOfSecondMiddleChar"===e.getField("VAR").getText()})),r=o.getAllBlocks().find((function(e){return"math_arithmetic_basic"===e.type&&e.getInputTargetBlock("A")===i&&e.getInputTargetBlock("B")&&"math_number"===e.getInputTargetBlock("B").type&&1===e.getInputTargetBlock("B").getFieldValue("NUM")&&"MINUS"===e.getFieldValue("OP")})),a=o.getAllBlocks().find((function(e){return"variables_set"===e.type&&e.getNextBlock()===n&&e.getInputTargetBlock("VALUE")===r&&"positionOfFirstMiddleChar"===e.getField("VAR").getText()})),l=o.getAllBlocks().find((function(e){return"math_number"===e.type&&2===e.getFieldValue("NUM")})),s=o.getAllBlocks().find((function(e){return"math_arithmetic_basic"===e.type&&e.getInputTargetBlock("A")&&"t2c_text_length"===e.getInputTargetBlock("A").type&&e.getInputTargetBlock("A").getInputTargetBlock("VALUE")&&"variables_get"===e.getInputTargetBlock("A").getInputTargetBlock("VALUE").type&&"s"===e.getInputTargetBlock("A").getInputTargetBlock("VALUE").getField("VAR").getText()&&e.getInputTargetBlock("B")===l&&"DIVIDE"===e.getFieldValue("OP")})),u=o.getAllBlocks().find((function(e){return"variables_set"===e.type&&e.getNextBlock()===a&&e.getInputTargetBlock("VALUE")===s&&"positionOfSecondMiddleChar"===e.getField("VAR").getText()})),c=o.getAllBlocks().find((function(e){return"math_arithmetic_basic"===e.type&&e.getInputTargetBlock("A")&&"t2c_text_length"===e.getInputTargetBlock("A").type&&e.getInputTargetBlock("A").getInputTargetBlock("VALUE")&&"variables_get"===e.getInputTargetBlock("A").getInputTargetBlock("VALUE").type&&"s"===e.getInputTargetBlock("A").getInputTargetBlock("VALUE").getField("VAR").getText()&&e.getInputTargetBlock("B")&&"math_number"===e.getInputTargetBlock("B").type&&1===e.getInputTargetBlock("B").getFieldValue("NUM")&&"MINUS"===e.getFieldValue("OP")})),g=o.getAllBlocks().find((function(e){return("t2c_text_charat"===e.type||"js_text_charat"===e.type)&&e.getInputTargetBlock("VALUE")&&"variables_get"===e.getInputTargetBlock("VALUE").type&&"s"===e.getInputTargetBlock("VALUE").getField("VAR").getText()&&e.getInputTargetBlock("AT")===c})),d=o.getAllBlocks().find((function(e){return"variables_set"===e.type&&e.getNextBlock()===u&&e.getInputTargetBlock("VALUE")===g&&"lastChar"===e.getField("VAR").getText()})),h=o.getAllBlocks().find((function(e){return"math_number"===e.type&&0==e.getFieldValue("NUM")})),p=o.getAllBlocks().find((function(e){return("t2c_text_charat"===e.type||"js_text_charat"===e.type)&&e.getInputTargetBlock("VALUE")&&"variables_get"===e.getInputTargetBlock("VALUE").type&&"s"===e.getInputTargetBlock("VALUE").getField("VAR").getText()&&e.getInputTargetBlock("AT")===h})),f=o.getAllBlocks().find((function(e){return"variables_set"===e.type&&e.getNextBlock()===d&&e.getInputTargetBlock("VALUE")===p&&"firstChar"===e.getField("VAR").getText()})),m=o.getAllBlocks().find((function(e){return"text"===e.type})),y=o.getAllBlocks().find((function(e){return("text_input"===e.type||"js_text_input"===e.type)&&e.getInputTargetBlock("TEXT")===m})),T=o.getAllBlocks().find((function(e){return"variables_set"===e.type&&e.getNextBlock()===f&&e.getInputTargetBlock("VALUE")===y&&"s"===e.getField("VAR").getText()}));return e&&t&&n&&i&&r&&a&&l&&s&&u&&c&&g&&d&&h&&p&&f&&m&&y&&T}),new s((function(){var e=o.getAllBlocks().find((function(e){return"variables_set"===e.type&&"positionOfFirstMiddleChar"===e.getField("VAR").getText()})),t=o.getAllBlocks().find((function(e){return"variables_set"===e.type&&"firstMiddleChar"===e.getField("VAR").getText()})),n=t&&t.getPreviousBlock()&&"variables_set"===t.getPreviousBlock().type&&t.getPreviousBlock().getField("VAR").getText();return t&&t.getNextBlock()&&"variables_set"===t.getNextBlock().type&&t.getNextBlock().getField("VAR").getText(),t&&e&&t.getNextBlock(),!t||n&&"positionOfFirstMiddleChar"===n?"Drag in the type-in-code block and enter the code needed to get the first middle character of the entered string from its position and store it in the variable firstMiddleChar. Be sure to attach this statement below the one declaring the variable to store the position of the entered string's first middle character.":"Make sure to attach this block storing the first middle character below the last one you entered in which you store its position in the variable positionOfFirstMiddleChar."}),{startPosition:F(o,null,{},50,document.getElementById("top-header").offsetHeight+50)}))),n.addTask(new r((function(){return"js"===document.getElementById("language").value||"py"===document.getElementById("language").value}),{start:function(){var e=document.getElementById("language").value;alert("✔ Excellent x 2! So now it's time to store the 2nd middle character. "+("js"===e||"py"===e?"":"But let's type this using pure JavaScript or Python. Select JavaScript or Python and watch how the declaration for the firstMiddleChar translates for reference."))},isComplete:function(){return!0},animate:function(){return!0},finish:function(){S(document.getElementById("output-container").querySelectorAll(".table-cell")[0]),M(),N(o),L(o,"type_in_get_second_middle_char"),o.options.maxInstances.type_in_get_second_middle_char=1,o.updateToolbox(document.getElementById("toolbox"))}})),n.addTask(new r((function(){var e=o.getAllBlocks().find((function(e){return("t2c_text_charat"===e.type||"js_text_charat"===e.type)&&e.getInputTargetBlock("VALUE")&&"variables_get"===e.getInputTargetBlock("VALUE").type&&"s"===e.getInputTargetBlock("VALUE").getField("VAR").getText()&&e.getInputTargetBlock("AT")&&"variables_get"===e.getInputTargetBlock("AT").type&&"positionOfSecondMiddleChar"===e.getInputTargetBlock("AT").getField("VAR").getText()})),t=o.getAllBlocks().find((function(t){return"variables_set"===t.type&&null===t.getNextBlock()&&t.getInputTargetBlock("VALUE")===e&&"secondMiddleChar"===t.getField("VAR").getText()})),n=o.getAllBlocks().find((function(e){return"variables_get"===e.type&&"positionOfFirstMiddleChar"===e.getField("VAR").getText()})),i=o.getAllBlocks().find((function(e){return("t2c_text_charat"===e.type||"js_text_charat"===e.type)&&e.getInputTargetBlock("VALUE")&&"variables_get"===e.getInputTargetBlock("VALUE").type&&"s"===e.getInputTargetBlock("VALUE").getField("VAR").getText()&&e.getInputTargetBlock("AT")===n})),r=o.getAllBlocks().find((function(e){return"variables_set"===e.type&&e.getNextBlock()===t&&e.getInputTargetBlock("VALUE")===i&&"firstMiddleChar"===e.getField("VAR").getText()})),a=o.getAllBlocks().find((function(e){return"math_arithmetic_basic"===e.type&&e.getInputTargetBlock("A")&&"variables_get"===e.getInputTargetBlock("A").type&&"positionOfSecondMiddleChar"===e.getInputTargetBlock("A").getField("VAR").getText()&&e.getInputTargetBlock("B")&&"math_number"===e.getInputTargetBlock("B").type&&1===e.getInputTargetBlock("B").getFieldValue("NUM")&&"MINUS"===e.getFieldValue("OP")})),l=o.getAllBlocks().find((function(e){return"variables_set"===e.type&&e.getNextBlock()===r&&e.getInputTargetBlock("VALUE")===a&&"positionOfFirstMiddleChar"===e.getField("VAR").getText()})),s=o.getAllBlocks().find((function(e){return"math_number"===e.type&&2===e.getFieldValue("NUM")})),u=o.getAllBlocks().find((function(e){return"math_arithmetic_basic"===e.type&&e.getInputTargetBlock("A")&&"t2c_text_length"===e.getInputTargetBlock("A").type&&e.getInputTargetBlock("A").getInputTargetBlock("VALUE")&&"variables_get"===e.getInputTargetBlock("A").getInputTargetBlock("VALUE").type&&"s"===e.getInputTargetBlock("A").getInputTargetBlock("VALUE").getField("VAR").getText()&&e.getInputTargetBlock("B")===s&&"DIVIDE"===e.getFieldValue("OP")})),c=o.getAllBlocks().find((function(e){return"variables_set"===e.type&&e.getNextBlock()===l&&e.getInputTargetBlock("VALUE")===u&&"positionOfSecondMiddleChar"===e.getField("VAR").getText()})),g=o.getAllBlocks().find((function(e){return"math_arithmetic_basic"===e.type&&e.getInputTargetBlock("A")&&"t2c_text_length"===e.getInputTargetBlock("A").type&&e.getInputTargetBlock("A").getInputTargetBlock("VALUE")&&"variables_get"===e.getInputTargetBlock("A").getInputTargetBlock("VALUE").type&&"s"===e.getInputTargetBlock("A").getInputTargetBlock("VALUE").getField("VAR").getText()&&e.getInputTargetBlock("B")&&"math_number"===e.getInputTargetBlock("B").type&&1===e.getInputTargetBlock("B").getFieldValue("NUM")&&"MINUS"===e.getFieldValue("OP")})),d=o.getAllBlocks().find((function(e){return("t2c_text_charat"===e.type||"js_text_charat"===e.type)&&e.getInputTargetBlock("VALUE")&&"variables_get"===e.getInputTargetBlock("VALUE").type&&"s"===e.getInputTargetBlock("VALUE").getField("VAR").getText()&&e.getInputTargetBlock("AT")===g})),h=o.getAllBlocks().find((function(e){return"variables_set"===e.type&&e.getNextBlock()===c&&e.getInputTargetBlock("VALUE")===d&&"lastChar"===e.getField("VAR").getText()})),p=o.getAllBlocks().find((function(e){return"math_number"===e.type&&0===e.getFieldValue("NUM")})),f=o.getAllBlocks().find((function(e){return("t2c_text_charat"===e.type||"js_text_charat"===e.type)&&e.getInputTargetBlock("VALUE")&&"variables_get"===e.getInputTargetBlock("VALUE").type&&"s"===e.getInputTargetBlock("VALUE").getField("VAR").getText()&&e.getInputTargetBlock("AT")===p})),m=o.getAllBlocks().find((function(e){return"variables_set"===e.type&&e.getNextBlock()===h&&e.getInputTargetBlock("VALUE")===f&&"firstChar"===e.getField("VAR").getText()})),y=o.getAllBlocks().find((function(e){return"text"===e.type})),T=o.getAllBlocks().find((function(e){return("text_input"===e.type||"js_text_input"===e.type)&&e.getInputTargetBlock("TEXT")===y})),_=o.getAllBlocks().find((function(e){return"variables_set"===e.type&&e.getNextBlock()===m&&e.getInputTargetBlock("VALUE")===T&&"s"===e.getField("VAR").getText()}));return e&&t&&n&&i&&r&&a&&l&&s&&u&&c&&g&&d&&h&&p&&f&&m&&y&&T&&_}),new s((function(){var e=o.getAllBlocks().find((function(e){return"variables_set"===e.type&&"secondMiddleChar"===e.getField("VAR").getText()})),t=e&&e.getPreviousBlock()&&"variables_set"===e.getPreviousBlock().type&&e.getPreviousBlock().getField("VAR").getText();return e&&e.getNextBlock()&&"variables_set"===e.getNextBlock().type&&e.getNextBlock().getField("VAR").getText(),!e||t&&"firstMiddleChar"===t?"Drag in the type-in-code block and enter the code needed to get the second middle character of the entered string from its position and store it in the variable secondMiddleChar. Do this in "+T2C.MSG.currentLanguage.LANGUAGE_NAME+" by adapting the code from the last blocks assembled to get the first middle character. Be sure to attach this statement below the one declaring the variable to store the entered string's first middle character.":"Make sure to attach this block storing the second middle character below the last one you entered in which you store the user's first middle character in the variable firstMiddleChar."}),{startPosition:F(o,null,{},50,document.getElementById("top-header").offsetHeight+50)}))),n.addTask(new r((function(){return!0}),{start:function(){return!0},isComplete:function(){return!0},animate:function(){return!0},finish:function(){alert("✔ Excellent x 3! So now for the grand finale: we need to put all of these characters together and display them on one line. Do you remember how to do that? Also, let's include the full string the user enters at the beginning because our users can be forgetful!\n So for an input of SCRABBLE, we'd want the output to be as follows: \nSCRABBLE: SEAB"),S(document.getElementById("output-container").querySelectorAll(".table-cell")[0]),M(),N(o),L(o,"type_in_combine_first_last_middle2_chars"),o.options.maxInstances.type_in_combine_first_last_middle2_chars=1,o.updateToolbox(document.getElementById("toolbox"))}})),n.addTask(new r((function(){var e=o.getAllBlocks().find((function(e){return"variables_get"===e.type&&"secondMiddleChar"===e.getField("VAR").getText()})),t=o.getAllBlocks().find((function(e){return"variables_get"===e.type&&"firstMiddleChar"===e.getField("VAR").getText()})),n=o.getAllBlocks().find((function(n){return"t2c_text_join"===n.type&&n.getInputTargetBlock("A")===t&&n.getInputTargetBlock("B")===e})),i=o.getAllBlocks().find((function(e){return"variables_get"===e.type&&"lastChar"===e.getField("VAR").getText()})),r=o.getAllBlocks().find((function(e){return"t2c_text_join"===e.type&&e.getInputTargetBlock("A")===i&&e.getInputTargetBlock("B")===n})),a=o.getAllBlocks().find((function(e){return"variables_get"===e.type&&"firstChar"===e.getField("VAR").getText()})),l=o.getAllBlocks().find((function(e){return"t2c_text_join"===e.type&&e.getInputTargetBlock("A")===a&&e.getInputTargetBlock("B")===r})),s=o.getAllBlocks().find((function(e){return"text"===e.type&&": "===e.getFieldValue("TEXT")})),u=o.getAllBlocks().find((function(e){return"t2c_text_join"===e.type&&e.getInputTargetBlock("A")===s&&e.getInputTargetBlock("B")===l})),c=o.getAllBlocks().find((function(e){return"t2c_text_join"===e.type&&e.getInputTargetBlock("A")&&"variables_get"===e.getInputTargetBlock("A").type&&"s"===e.getInputTargetBlock("A").getField("VAR").getText()&&e.getInputTargetBlock("B")===u})),g=o.getAllBlocks().find((function(e){return("text_print"===e.type||"js_text_print"===e.type)&&null===e.getNextBlock()&&e.getInputTargetBlock("TEXT")===c})),d=o.getAllBlocks().find((function(e){return("t2c_text_charat"===e.type||"js_text_charat"===e.type)&&e.getInputTargetBlock("VALUE")&&"variables_get"===e.getInputTargetBlock("VALUE").type&&"s"===e.getInputTargetBlock("VALUE").getField("VAR").getText()&&e.getInputTargetBlock("AT")&&"variables_get"===e.getInputTargetBlock("AT").type&&"positionOfSecondMiddleChar"===e.getInputTargetBlock("AT").getField("VAR").getText()})),h=o.getAllBlocks().find((function(e){return"variables_set"===e.type&&e.getNextBlock()===g&&e.getInputTargetBlock("VALUE")===d&&"secondMiddleChar"===e.getField("VAR").getText()})),p=o.getAllBlocks().find((function(e){return"variables_get"===e.type&&"positionOfFirstMiddleChar"===e.getField("VAR").getText()})),f=o.getAllBlocks().find((function(e){return("t2c_text_charat"===e.type||"js_text_charat"===e.type)&&e.getInputTargetBlock("VALUE")&&"variables_get"===e.getInputTargetBlock("VALUE").type&&"s"===e.getInputTargetBlock("VALUE").getField("VAR").getText()&&e.getInputTargetBlock("AT")===p})),m=o.getAllBlocks().find((function(e){return"variables_set"===e.type&&e.getNextBlock()===h&&e.getInputTargetBlock("VALUE")===f&&"firstMiddleChar"===e.getField("VAR").getText()})),y=o.getAllBlocks().find((function(e){return"math_arithmetic_basic"===e.type&&e.getInputTargetBlock("A")&&"variables_get"===e.getInputTargetBlock("A").type&&"positionOfSecondMiddleChar"===e.getInputTargetBlock("A").getField("VAR").getText()&&e.getInputTargetBlock("B")&&"math_number"===e.getInputTargetBlock("B").type&&1===e.getInputTargetBlock("B").getFieldValue("NUM")&&"MINUS"===e.getFieldValue("OP")})),T=o.getAllBlocks().find((function(e){return"variables_set"===e.type&&e.getNextBlock()===m&&e.getInputTargetBlock("VALUE")===y&&"positionOfFirstMiddleChar"===e.getField("VAR").getText()})),_=o.getAllBlocks().find((function(e){return"math_number"===e.type&&2===e.getFieldValue("NUM")})),b=o.getAllBlocks().find((function(e){return"math_arithmetic_basic"===e.type&&e.getInputTargetBlock("A")&&"t2c_text_length"===e.getInputTargetBlock("A").type&&e.getInputTargetBlock("A").getInputTargetBlock("VALUE")&&"variables_get"===e.getInputTargetBlock("A").getInputTargetBlock("VALUE").type&&"s"===e.getInputTargetBlock("A").getInputTargetBlock("VALUE").getField("VAR").getText()&&e.getInputTargetBlock("B")===_&&"DIVIDE"===e.getFieldValue("OP")})),k=o.getAllBlocks().find((function(e){return"variables_set"===e.type&&e.getNextBlock()===T&&e.getInputTargetBlock("VALUE")===b&&"positionOfSecondMiddleChar"===e.getField("VAR").getText()})),x=o.getAllBlocks().find((function(e){return"math_arithmetic_basic"===e.type&&e.getInputTargetBlock("A")&&"t2c_text_length"===e.getInputTargetBlock("A").type&&e.getInputTargetBlock("A").getInputTargetBlock("VALUE")&&"variables_get"===e.getInputTargetBlock("A").getInputTargetBlock("VALUE").type&&"s"===e.getInputTargetBlock("A").getInputTargetBlock("VALUE").getField("VAR").getText()&&e.getInputTargetBlock("B")&&"math_number"===e.getInputTargetBlock("B").type&&1===e.getInputTargetBlock("B").getFieldValue("NUM")&&"MINUS"===e.getFieldValue("OP")})),E=o.getAllBlocks().find((function(e){return("t2c_text_charat"===e.type||"js_text_charat"===e.type)&&e.getInputTargetBlock("VALUE")&&"variables_get"===e.getInputTargetBlock("VALUE").type&&"s"===e.getInputTargetBlock("VALUE").getField("VAR").getText()&&e.getInputTargetBlock("AT")===x})),B=o.getAllBlocks().find((function(e){return"variables_set"===e.type&&e.getNextBlock()===k&&e.getInputTargetBlock("VALUE")===E&&"lastChar"===e.getField("VAR").getText()})),A=o.getAllBlocks().find((function(e){return"math_number"===e.type&&0===e.getFieldValue("NUM")})),v=o.getAllBlocks().find((function(e){return("t2c_text_charat"===e.type||"js_text_charat"===e.type)&&e.getInputTargetBlock("VALUE")&&"variables_get"===e.getInputTargetBlock("VALUE").type&&"s"===e.getInputTargetBlock("VALUE").getField("VAR").getText()&&e.getInputTargetBlock("AT")===A})),I=o.getAllBlocks().find((function(e){return"variables_set"===e.type&&e.getNextBlock()===B&&e.getInputTargetBlock("VALUE")===v&&"firstChar"===e.getField("VAR").getText()})),w=o.getAllBlocks().find((function(e){return"text"===e.type})),S=o.getAllBlocks().find((function(e){return("text_input"===e.type||"js_text_input"===e.type)&&e.getInputTargetBlock("TEXT")===w})),M=o.getAllBlocks().find((function(e){return"variables_set"===e.type&&e.getNextBlock()===I&&e.getInputTargetBlock("VALUE")===S&&"s"===e.getField("VAR").getText()}));return e&&t&&n&&i&&r&&a&&l&&s&&u&&c&&g&&d&&h&&p&&f&&m&&y&&T&&_&&b&&k&&x&&E&&B&&A&&v&&I&&w&&S&&M}),new s((function(){var e=o.getAllBlocks().find((function(e){return"text_print"===e.type||"js_text_print"===e.type})),t=(o.getAllBlocks().find((function(t){return"variables_set"===t.type&&t.getNextBlock()===e&&"secondMiddleChar"===t.getField("VAR").getText()})),e&&e.getPreviousBlock()&&"variables_set"===e.getPreviousBlock().type&&e.getPreviousBlock().getField("VAR").getText()),n=e&&e.getNextBlock()&&"variables_set"===e.getNextBlock().type&&e.getNextBlock().getField("VAR").getText();return e&&!t?"Make sure to attach this block displaying the entered string and its first, last, and first and second middle characters below the last one you entered in which you store the user's second middle character in the variable secondMiddleChar.":n?"Make sure to attach this block displaying the entered string and its first, last, and first and second middle characters below the last one you entered in which you store the user's second middle character in the variable secondMiddleChar. Since instructions are run top to bottom, if you place this before the block you did, the computer wouldn't know what "+(n.startsWith("positionOf")?n.substring(10):n)+" means!":'Drag in the type-in-code block and place it below the block that stores the second character in a variable. Enter code to display the user entered string, followed by the string literal ": " followed by its first character, then its last character, then its first middle character, and finally its second middle character.\n So for an input of SCRABBLE, we\'d want the output to be as follows: \nSCRABBLE: SEAB'}),{startPosition:F(o,null,{},50,document.getElementById("top-header").offsetHeight+50)}))),function(e){e.addTask(new r((function(){return document.getElementById("output-container").classList.contains("show-container")}),new u([new s((function(){return T2C.MSG.currentLanguage.BUTTON_RUN_CODE}),{startPosition:{x:document.getElementById("run-code-button").offsetLeft+document.getElementById("run-code-button").offsetWidth,y:document.getElementById("run-code-button").offsetTop+document.getElementById("run-code-button").offsetHeight}}),new l(h,{totalSteps:100,toggleSteps:25,startPosition:{x:document.getElementById("run-code-button").offsetLeft+document.getElementById("run-code-button").offsetWidth/2,y:document.getElementById("run-code-button").offsetTop+document.getElementById("run-code-button").offsetHeight/2}})])))}(n),function(e,t){var n=0;function o(){t.style.color=n%50<25?"#a00":"#000",++n<200&&requestAnimationFrame(o)}e.addTask(new r((function(){return n>=200}),{start:function(){t.style.verticalAlign="top",requestAnimationFrame(o)},isComplete:function(){return!0},animate:function(){return!0}}))}(n,document.getElementById("output-container").querySelectorAll(".table-cell")[0]),n.addTask(new r((function(){return!0}),{start:function(){return!0},isComplete:function(){return!0},animate:function(){return!0},finish:function(){alert("✔✔✔ Congratulations! You just completed the challenging Mission 3! Take a moment to bask in your accomplishments! Not only did you solve the problem yourself, you also proved to be an excellent teacher! You managed to explain to the computer how it could solve the problem as well in a language it could understand. This meant you were also perfect in your grammar, spelling everything correctly and placing every parenthesis and period where it needed to go, making your English teachers proud!\nIn Mission 4, we'll introduce a new block that'll allow you to get *all* the characters from a starting position to an ending one (rather than just getting one character at a time). We'll then use this block to display a string with its initial character removed. Until next time!"),S(document.getElementById("output-container").querySelectorAll(".table-cell")[0]),M(),N(o),L(o,"code_statement"),o.options.maxInstances.code_statement=1,o.updateToolbox(document.getElementById("toolbox"))}})),n},function(e,t){var n=e||new c;alert("In previous missions, you'd use "+T2C.MSG.currentLanguage.TERMINAL_GETCHARACTERNUMBER+" to get a *single* character at a given numerical position in a string. In this mission, you'll be using a new block "+T2C.MSG.EN.TERMINAL_GETTEXTFROM+" to display all characters between given starting and ending numerical positions.");var o=t||Blockly.getMainWorkspace();D(o),["t2c_text_getsubstring","text_print","variables_get","math_number","text","variables_set"].forEach((function(e,t){W(o,e,!1),o.options.maxInstances[e]=3===t?2:1})),o.clear();var a=Object(i.e)(o,"text"),g=Object(i.e)(o,"variables_set");Object(i.h)(a,"aap kaise hain?","TEXT"),Object(i.j)(g,"VALUE",a),Object(i.h)(g,"welcomeMsg","VAR"),o.setScale(1),Object(i.f)(o),Array.from(document.querySelectorAll("rect")).filter((function(e){return e.getAttribute("fill-opacity")}));var d=document.createElement("div");function h(e){e.addTask(new r((function(){return document.getElementById("output-container").classList.contains("show-container")}),new u([new s((function(){return T2C.MSG.currentLanguage.BUTTON_RUN_CODE}),{startPosition:{x:document.getElementById("run-code-button").offsetLeft+document.getElementById("run-code-button").offsetWidth,y:document.getElementById("run-code-button").offsetTop+document.getElementById("run-code-button").offsetHeight}}),new l(d,{totalSteps:100,toggleSteps:25,startPosition:{x:document.getElementById("run-code-button").offsetLeft+document.getElementById("run-code-button").offsetWidth/2,y:document.getElementById("run-code-button").offsetTop+document.getElementById("run-code-button").offsetHeight/2}})])))}function p(e,t){var n=0;function o(){t.style.color=n%50<25?"#a00":"#000",++n<200&&requestAnimationFrame(o)}e.addTask(new r((function(){return n>=200}),{start:function(){t.style.verticalAlign="top",requestAnimationFrame(o)},isComplete:function(){return!0},animate:function(){return!0}}))}return d.innerText="👆",d.id="ptr",d.style.fontSize="x-large",d.style.position="absolute",d.style.zIndex="1001",document.getElementById("blockly-div").appendChild(d),n.addTask(new r((function(){var e=o.getAllBlocks().find((function(e){return"math_number"===e.type&&9===e.getFieldValue("NUM")})),t=o.getAllBlocks().find((function(e){return"math_number"===e.type&&4===e.getFieldValue("NUM")})),n=o.getAllBlocks().find((function(e){return"variables_get"===e.type&&"welcomeMsg"===e.getField("VAR").getText()})),i=o.getAllBlocks().find((function(o){return("t2c_text_getsubstring"===o.type||"js_text_getsubstring"===o.type)&&o.getInputTargetBlock("STRING")===n&&o.getInputTargetBlock("AT1")===t&&o.getInputTargetBlock("AT2")===e})),r=o.getAllBlocks().find((function(e){return("text_print"===e.type||"js_text_print"===e.type)&&null===e.getNextBlock()&&e.getInputTargetBlock("TEXT")===i})),a=o.getAllBlocks().find((function(e){return"text"===e.type&&"aap kaise hain?"==e.getFieldValue("TEXT")})),l=o.getAllBlocks().find((function(e){return"variables_set"===e.type&&e.getNextBlock()===r&&e.getInputTargetBlock("VALUE")===a&&"welcomeMsg"===e.getField("VAR").getText()}));return e&&t&&n&&i&&r&&a&&l}),new s((function(){var e=o.getAllBlocks().find((function(e){return"math_number"===e.type})),t=o.getAllBlocks().find((function(t){return"math_number"===t.type&&t!==e})),n=o.getAllBlocks().find((function(e){return"variables_get"===e.type})),i=o.getAllBlocks().find((function(e){return"t2c_text_getsubstring"===e.type||"js_text_getsubstring"===e.type})),r=o.getAllBlocks().find((function(e){return"text_print"===e.type||"js_text_print"===e.type})),a=o.getAllBlocks().find((function(e){return"text"===e.type})),l=o.getAllBlocks().find((function(e){return"variables_set"===e.type}));if(i&&(i.getInputTargetBlock("AT1")===e||i.getInputTargetBlock("AT1")===t)){var s=i.getInputTargetBlock("AT1").getFieldValue("NUM");if(5===s)return"The given starting position is incorrect. Remember that the initial character starts at position (index) 0 and unlike the given ending position to "+T2C.MSG.currentLanguage.TERMINAL_GETTEXTFROMPOSITIONNUMBER+", the computer starts extracting text from the first position number you give it.";if(3===s)return"The given starting position is incorrect. Remember that the initial character starts at position (index) 0 and that spaces are characters as well.";if(9===s)return"The given starting position is incorrect. The first number given to "+T2C.MSG.currentLanguage.TERMINAL_GETTEXTFROMPOSITIONNUMBER+" is the starting position, not the ending one.";if(4!==s)return"Incorrect number for the starting position. Please try recounting the characters from the beginning of the string, starting from 0 and include spaces in your count."}if(i&&(i.getInputTargetBlock("AT2")===e||i.getInputTargetBlock("AT2")===t)){var u=i.getInputTargetBlock("AT2").getFieldValue("NUM");if(8===u)return"The given ending position is incorrect. Remember to count spaces and unlike the given starting position to "+T2C.MSG.currentLanguage.TERMINAL_GETTEXTFROMPOSITIONNUMBER+", the computer stops extracting text *one place before* the second number you give it.";if(4===u)return"The given ending position is incorrect. The second number given to "+T2C.MSG.currentLanguage.TERMINAL_GETTEXTFROMPOSITIONNUMBER+" is the ending position, not the starting one.";if(9!==u)return"Incorrect number for the ending position. Please try recounting the characters from the beginning of the string, starting from 0 and include spaces in your count."}return l&&"welcomeMsg"!==l.getField("VAR").getText()?"Make sure you keep the variable name for the "+T2C.MSG.currentLanguage.TERMINAL_LET+"block as it was; it should be welcomeMsg.":l&&l.getInputTargetBlock("VALUE")!==a?"Keep the text block with the text aap kaise hain? inside the "+T2C.MSG.currentLanguage.TERMINAL_LET+" variable block. When using the "+T2C.MSG.currentLanguage.TERMINAL_GETTEXTFROMPOSITIONNUMBER+" block, refer to the variable welcomeMsg.":"aap kaise hain?"!==a.getFieldValue("TEXT")?"Make sure to leave the text aap kaise hain? for the text block.":n&&"welcomeMsg"!==n.getField("VAR").getText()?"Make sure you use the variable name welcomeMsg for the variable get block so that it refers to the value assigned to the variable.":i&&n&&i.getInputTargetBlock("STRING")!==n?"Make sure to place the variable with the string's value inside the left space of the "+T2C.MSG.currentLanguage.TERMINAL_GETTEXTFROMPOSITIONNUMBER+" so the computer knows which string to extract the substring from.":i&&n&&(i.getInputTargetBlock("A")===n||i.getInputTargetBlock("B")===n)?"The variable which holds the text to get the string from should go inside the left space of the "+T2C.MSG.currentLanguage.TERMINAL_GETTEXTFROMPOSITIONNUMBER+" block. The other spaces are for the *numbers* of the starting and ending positions from where to extract the text.":r&&i&&r.getInputTargetBlock("TEXT")!==i?"You want to display the result of extracting text from welcomeMsg so you should use the "+T2C.MSG.currentLanguage.TERMINAL_GETTEXTFROMPOSITIONNUMBER+" block inside of the "+T2C.MSG.currentLanguage.TERMINAL_DISPLAY+" block.":r&&l&&r.getNextBlock()===l?"The "+T2C.MSG.currentLanguage.TERMINAL_DISPLAY+" block should go below the "+T2C.MSG.currentLanguage.TERMINAL_LET+" variable block so the computer knows what welcomeMsg is when attempting to extract text from it. Remember that statements are run from top to bottom.":r&&null!==r.getNextBlock()?"The next statement above the "+T2C.MSG.currentLanguage.TERMINAL_DISPLAY+" block is incorrect.":r&&l&&l.getNextBlock()!==r?"Place the "+T2C.MSG.currentLanguage.TERMINAL_DISPLAY+" block below the "+T2C.MSG.currentLanguage.TERMINAL_LET+" variable declaration block.":"Drag in and assemble the blocks from the toolbox to get the text kaise (without spaces) from aap kaise hain? Do NOT change the existing ones.\nTo do this, use the new "+T2C.MSG.currentLanguage.TERMINAL_GETTEXTFROMPOSITIONNUMBER+" block, which takes a string, the position to start getting text from, and the position to stop at (NOTE: IT WILL STOP 1 BEFORE THE second number.)\nIn case you were curious, aap kaise hain? is the polite formal way to ask 'how are you?' in Hindi, literally, 'you (aap) how (kaise) are (hain)?'"}),{startPosition:q(o,null,{},50,document.getElementById("top-header").offsetHeight+50)}))),h(n),p(n,document.getElementById("output-container").querySelectorAll(".table-cell")[0]),n.addTask(new r((function(){return!0}),{start:function(){return!0},isComplete:function(){return!0},animate:function(){return!0},finish:function(){alert("👍 Nice! So now let's try another example with the new block, but let's type it! This time, you'll display everything except the string's initial character. So we'll want to display ap kaise hain?"),X(document.getElementById("output-container").querySelectorAll(".table-cell")[0]),j(),W(o,"type_in_all_but_first_specific_str"),o.options.maxInstances.type_in_all_but_first_specific_str=1,o.updateToolbox(document.getElementById("toolbox"))}})),n.addTask(new r((function(){var e=o.getAllBlocks().find((function(e){return"math_number"===e.type&&15===e.getFieldValue("NUM")})),t=o.getAllBlocks().find((function(e){return"math_number"===e.type&&1===e.getFieldValue("NUM")})),n=o.getAllBlocks().filter((function(e){return"variables_get"===e.type&&"welcomeMsg"===e.getField("VAR").getText()})),i=o.getAllBlocks().find((function(o){return("t2c_text_getsubstring"===o.type||"js_text_getsubstring"===o.type)&&-1!==n.indexOf(o.getInputTargetBlock("STRING"))&&o.getInputTargetBlock("AT1")===t&&o.getInputTargetBlock("AT2")===e})),r=o.getAllBlocks().find((function(e){return("text_print"===e.type||"js_text_print"===e.type)&&null===e.getNextBlock()&&e.getInputTargetBlock("TEXT")===i})),a=o.getAllBlocks().find((function(e){return"math_number"===e.type&&9===e.getFieldValue("NUM")})),l=o.getAllBlocks().find((function(e){return"math_number"===e.type&&4===e.getFieldValue("NUM")})),s=o.getAllBlocks().find((function(e){return("t2c_text_getsubstring"===e.type||"js_text_getsubstring"===e.type)&&-1!==n.indexOf(e.getInputTargetBlock("STRING"))&&e.getInputTargetBlock("AT1")===l&&e.getInputTargetBlock("AT2")===a})),u=o.getAllBlocks().find((function(e){return("text_print"===e.type||"js_text_print"===e.type)&&e.getNextBlock()===r&&e.getInputTargetBlock("TEXT")===s})),c=o.getAllBlocks().find((function(e){return"text"===e.type&&"aap kaise hain?"==e.getFieldValue("TEXT")})),g=o.getAllBlocks().find((function(e){return"variables_set"===e.type&&e.getNextBlock()===u&&e.getInputTargetBlock("VALUE")===c&&"welcomeMsg"===e.getField("VAR").getText()}));return e&&t&&n&&i&&r&&a&&l&&s&&u&&c&&g}),new s((function(){var e=o.getAllBlocks().find((function(e){return"math_number"===e.type&&15===e.getFieldValue("NUM")})),t=o.getAllBlocks().find((function(e){return"math_number"===e.type&&1===e.getFieldValue("NUM")})),n=o.getAllBlocks().filter((function(e){return"variables_get"===e.type&&"welcomeMsg"===e.getField("VAR").getText()})),i=o.getAllBlocks().find((function(o){return("t2c_text_getsubstring"===o.type||"js_text_getsubstring"===o.type)&&-1!==n.indexOf(o.getInputTargetBlock("STRING"))&&o.getInputTargetBlock("AT1")===t&&o.getInputTargetBlock("AT2")===e})),r=o.getAllBlocks().find((function(e){return("text_print"===e.type||"js_text_print"===e.type)&&e.getInputTargetBlock("TEXT")===i})),a=o.getAllBlocks().find((function(e){return"math_number"===e.type&&9===e.getFieldValue("NUM")})),l=o.getAllBlocks().find((function(e){return"math_number"===e.type&&4===e.getFieldValue("NUM")})),s=o.getAllBlocks().find((function(e){return("t2c_text_getsubstring"===e.type||"js_text_getsubstring"===e.type)&&-1!==n.indexOf(e.getInputTargetBlock("STRING"))&&e.getInputTargetBlock("AT1")===l&&e.getInputTargetBlock("AT2")===a})),u=o.getAllBlocks().find((function(e){return("text_print"===e.type||"js_text_print"===e.type)&&e.getInputTargetBlock("TEXT")===s})),c=o.getAllBlocks().find((function(e){return"text"===e.type&&"aap kaise hain?"==e.getFieldValue("TEXT")})),g=o.getAllBlocks().find((function(e){return"variables_set"===e.type&&e.getInputTargetBlock("VALUE")===c&&"welcomeMsg"===e.getField("VAR").getText()}));return r&&g&&r.getNextBlock()===g?"The "+T2C.MSG.currentLanguage.TERMINAL_DISPLAY+" block should go below the "+T2C.MSG.currentLanguage.TERMINAL_LET+" variable block so the computer knows what welcomeMsg is when attempting to extract text from it. Remember that statements are run from top to bottom.":r&&u&&u.getNextBlock()!==r?"Place the new "+T2C.MSG.currentLanguage.TERMINAL_DISPLAY+" block that's used to display all characters beyond the initial one below the previous "+T2C.MSG.currentLanguage.TERMINAL_DISPLAY+" block used to display kaise.":"Drag in the type-in code block from the toolbox and type in the code necessary to display all the characters except the initial one from aap kaise hain? As before, use "+T2C.MSG.currentLanguage.TERMINAL_GETTEXTFROMPOSITIONNUMBER+", the variable welcomeMsg, and 2 specific numbers for the starting and ending positions. We'll generalize this so it works for other strings next. Place this new block below the previous "+T2C.MSG.currentLanguage.TERMINAL_DISPLAY+"."}),{startPosition:q(o,null,{},50,document.getElementById("top-header").offsetHeight+50)}))),h(n),p(n,document.getElementById("output-container").querySelectorAll(".table-cell")[0]),n.addTask(new r((function(){return!0}),{start:function(){return!0},isComplete:function(){return!0},animate:function(){return!0},finish:function(){alert("👍 Good! So of course this is not a very useful program as we could've just displayed two lines of text 'kaise' and 'ap kaise hain?' and the user would not know the difference. So now let's show the usefulness of the new "+T2C.MSG.currentLanguage.TERMINAL_GETTEXTFROMPOSITIONNUMBER+" by instead using the string literal 'aap kaise hain?' as our message to get input from the user instead. Then our user can respond with something like theek (fine) or bahut acchaa (very good)."),X(document.getElementById("output-container").querySelectorAll(".table-cell")[0]),j(),W(o,"text_input"),o.options.maxInstances.text_input=1,o.options.maxInstances.type_in_all_but_first_specific_str=0,o.updateToolbox(document.getElementById("toolbox"))}})),n.addTask(new r((function(){var e=o.getAllBlocks().find((function(e){return"math_number"===e.type&&15===e.getFieldValue("NUM")})),t=o.getAllBlocks().find((function(e){return"math_number"===e.type&&1===e.getFieldValue("NUM")})),n=o.getAllBlocks().filter((function(e){return"variables_get"===e.type&&"response"===e.getField("VAR").getText()})),i=o.getAllBlocks().find((function(o){return("t2c_text_getsubstring"===o.type||"js_text_getsubstring"===o.type)&&-1!==n.indexOf(o.getInputTargetBlock("STRING"))&&o.getInputTargetBlock("AT1")===t&&o.getInputTargetBlock("AT2")===e})),r=o.getAllBlocks().find((function(e){return("text_print"===e.type||"js_text_print"===e.type)&&null===e.getNextBlock()&&e.getInputTargetBlock("TEXT")===i})),a=o.getAllBlocks().find((function(e){return"math_number"===e.type&&9===e.getFieldValue("NUM")})),l=o.getAllBlocks().find((function(e){return"math_number"===e.type&&4===e.getFieldValue("NUM")})),s=o.getAllBlocks().find((function(e){return("t2c_text_getsubstring"===e.type||"js_text_getsubstring"===e.type)&&-1!==n.indexOf(e.getInputTargetBlock("STRING"))&&e.getInputTargetBlock("AT1")===l&&e.getInputTargetBlock("AT2")===a})),u=o.getAllBlocks().find((function(e){return("text_print"===e.type||"js_text_print"===e.type)&&e.getNextBlock()===r&&e.getInputTargetBlock("TEXT")===s})),c=o.getAllBlocks().find((function(e){return"text"===e.type&&"aap kaise hain?"==e.getFieldValue("TEXT")})),g=o.getAllBlocks().find((function(e){return("text_input"===e.type||"js_text_input"===e.type)&&e.getInputTargetBlock("TEXT")===c})),d=o.getAllBlocks().find((function(e){return"variables_set"===e.type&&e.getNextBlock()===u&&e.getInputTargetBlock("VALUE")===g&&"response"===e.getField("VAR").getText()}));return e&&t&&2===n.length&&i&&r&&a&&l&&s&&u&&c&&g&&d}),new s((function(){var e=o.getAllBlocks().find((function(e){return"math_number"===e.type&&15===e.getFieldValue("NUM")})),t=o.getAllBlocks().find((function(e){return"math_number"===e.type&&1===e.getFieldValue("NUM")})),n=o.getAllBlocks().filter((function(e){return"variables_get"===e.type})),i=o.getAllBlocks().find((function(o){return("t2c_text_getsubstring"===o.type||"js_text_getsubstring"===o.type)&&-1!==n.indexOf(o.getInputTargetBlock("STRING"))&&o.getInputTargetBlock("AT1")===t&&o.getInputTargetBlock("AT2")===e})),r=o.getAllBlocks().find((function(e){return("text_print"===e.type||"js_text_print"===e.type)&&null===e.getNextBlock()&&e.getInputTargetBlock("TEXT")===i})),a=o.getAllBlocks().find((function(e){return"math_number"===e.type&&9===e.getFieldValue("NUM")})),l=o.getAllBlocks().find((function(e){return"math_number"===e.type&&4===e.getFieldValue("NUM")})),s=o.getAllBlocks().find((function(e){return("t2c_text_getsubstring"===e.type||"js_text_getsubstring"===e.type)&&-1!==n.indexOf(e.getInputTargetBlock("STRING"))&&e.getInputTargetBlock("AT1")===l&&e.getInputTargetBlock("AT2")===a})),u=o.getAllBlocks().find((function(e){return("text_print"===e.type||"js_text_print"===e.type)&&e.getNextBlock()===r&&e.getInputTargetBlock("TEXT")===s})),c=o.getAllBlocks().find((function(e){return"text"===e.type})),g=o.getAllBlocks().find((function(e){return"text_input"===e.type||"js_text_input"===e.type})),d=o.getAllBlocks().find((function(e){return"variables_set"===e.type&&e.getNextBlock()===u&&e.getInputTargetBlock("VALUE")===g}));if(d){var h=d.getField("VAR").getText();if(n.find((function(e){return e.getField("VAR").getText()!==h})))return"Be sure that the variable names all match so they all refer to the same text.";if("welcomeMsg"!==h&&"response"!==h)return"Be sure to name the variable response to reflect that it now holds the user response to the question aap kaise hain? You can change a variable name by clicking its current name of "+h+" and then selecting Rename variable..."}if(g){if(g.getParent()!==d)return"Be sure to place the "+T2C.MSG.currentLanguage.TERMINAL_GETINPUTBYASKING+" block inside the "+T2C.MSG.currentLanguage.TERMINAL_LET+" one so the variable stores the response from the user.";if(c){if("aap kaise hain?"!==c.getFieldValue("TEXT"))return"The message of aap kaise hain? should stay the same so change it back to that. The only difference here is that it becomes the prompt to the user rather than the text we'll be extracting a substring from, which instead will be the user's response.";if(c.getParent()!==g)return"Place the text block with the message aap kaise hain? inside the "+T2C.MSG.currentLanguage.TERMINAL_GETINPUTBYASKING+" one so that the user is prompted with this question."}}return"Drag in the "+T2C.MSG.currentLanguage.TERMINAL_GETINPUTBYASKING+" block from the toolbox and make aap kaise hain? its prompt. Then change the variable name from welcomeMsg to response to reflect the fact that the variable will now hold the user's reply to the question aap kaise hain? instead of the question itself."}),{startPosition:q(o,null,{},50,document.getElementById("top-header").offsetHeight+50)}))),h(n),p(n,document.getElementById("output-container").querySelectorAll(".table-cell")[0]),n.addTask(new r((function(){return!0}),{start:function(){return!0},isComplete:function(){return!0},animate:function(){return!0},finish:function(){alert("👍 Great! So are you seeing 2 lines of text here, or did you get an error? If you received an error, it means your text that you entered wasn't long enough. E.g., you can't extract all the characters from the input from position 1 to before position 15 for an input of bahut acchaa whose last character appears at position 11 (positions 12, 13, and 14 don't exist for this string!). On the other hand, if your text was too long, you wouldn't get all of the characters beyond the initial one. So to conclude this mission, let's fix this problem so it works for any string with at least 1 character!"),X(document.getElementById("output-container").querySelectorAll(".table-cell")[0]),j(),o.updateToolbox(document.getElementById("toolbox"))}})),n.addTask(new r((function(){var e=o.getAllBlocks().find((function(e){return"text"===e.type&&"aap kaise hain?"==e.getFieldValue("TEXT")})),t=o.getAllBlocks().find((function(t){return("text_input"===t.type||"js_text_input"===t.type)&&t.getInputTargetBlock("TEXT")===e})),n=o.getAllBlocks().find((function(e){return"variables_set"===e.type&&null===e.getNextBlock()&&e.getInputTargetBlock("VALUE")===t&&"response"===e.getField("VAR").getText()}));return e&&t&&n}),new s((function(){return"First, delete the two "+T2C.MSG.currentLanguage.TERMINAL_DISPLAY+" blocks and all the ones that appear inside them so all that's left is the initial "+T2C.MSG.currentLanguage.TERMINAL_LET+" variable statement assigned to the user's response."}),{startPosition:q(o,null,{},50,document.getElementById("top-header").offsetHeight+50),finish:function(){var e=Y("text_print"),t=Y("t2c_text_getsubstring"),n=Y("variables_get"),i=Y("math_number"),r=Y("math_number");H(n,"VAR","response"),H(i,"NUM",1),H(r,"NUM",15),J(e,"TEXT",t),J(t,"STRING",n),J(t,"AT1",i),J(t,"AT2",r),o.options.maxInstances.text_print=0,o.options.maxInstances.text=0,o.options.maxInstances.variables_get=0,o.options.maxInstances.math_number=0,o.options.maxInstances.t2c_text_getsubstring=0,document.getElementById("toolbox").prepend(e),W(o,"type_in_all_but_first_general_str"),o.options.maxInstances.type_in_all_but_first_general_str=1}}))),n.addTask(new r((function(){var e=o.getAllBlocks().filter((function(e){return"variables_get"===e.type&&"response"===e.getField("VAR").getText()})),t=o.getAllBlocks().find((function(t){return"t2c_text_length"===t.type&&-1!==e.indexOf(t.getInputTargetBlock("VALUE"))})),n=o.getAllBlocks().find((function(e){return"math_number"===e.type&&1===e.getFieldValue("NUM")})),i=o.getAllBlocks().find((function(o){return("t2c_text_getsubstring"===o.type||"js_text_getsubstring"===o.type)&&-1!==e.indexOf(o.getInputTargetBlock("STRING"))&&o.getInputTargetBlock("AT1")===n&&o.getInputTargetBlock("AT2")===t})),r=o.getAllBlocks().find((function(e){return("text_print"===e.type||"js_text_print"===e.type)&&null===e.getNextBlock()&&e.getInputTargetBlock("TEXT")===i})),a=o.getAllBlocks().find((function(e){return"text"===e.type&&"aap kaise hain?"==e.getFieldValue("TEXT")})),l=o.getAllBlocks().find((function(e){return("text_input"===e.type||"js_text_input"===e.type)&&e.getInputTargetBlock("TEXT")===a})),s=o.getAllBlocks().find((function(e){return"variables_set"===e.type&&e.getNextBlock()===r&&e.getInputTargetBlock("VALUE")===l&&"response"===e.getField("VAR").getText()}));return 2===e.length&&t&&n&&i&&r&&a&&l&&s}),new s((function(){var e=o.getAllBlocks().filter((function(e){return"variables_get"===e.type&&"response"===e.getField("VAR").getText()})),t=o.getAllBlocks().find((function(t){return"t2c_text_length"===t.type&&-1!==e.indexOf(t.getInputTargetBlock("VALUE"))})),n=o.getAllBlocks().find((function(e){return"math_number"===e.type&&1===e.getFieldValue("NUM")})),i=o.getAllBlocks().find((function(o){return("t2c_text_getsubstring"===o.type||"js_text_getsubstring"===o.type)&&-1!==e.indexOf(o.getInputTargetBlock("STRING"))&&o.getInputTargetBlock("AT1")===n&&o.getInputTargetBlock("AT2")===t})),r=o.getAllBlocks().find((function(e){return("text_print"===e.type||"js_text_print"===e.type)&&e.getInputTargetBlock("TEXT")===i})),a=o.getAllBlocks().find((function(e){return"text"===e.type&&"aap kaise hain?"==e.getFieldValue("TEXT")})),l=o.getAllBlocks().find((function(e){return("text_input"===e.type||"js_text_input"===e.type)&&e.getInputTargetBlock("TEXT")===a})),s=o.getAllBlocks().find((function(e){return"variables_set"===e.type&&e.getInputTargetBlock("VALUE")===l&&"response"===e.getField("VAR").getText()}));return r&&s&&r.getNextBlock()===s?"The "+T2C.MSG.currentLanguage.TERMINAL_DISPLAY+" block should go below the "+T2C.MSG.currentLanguage.TERMINAL_LET+" variable block so the computer knows what response is when attempting to extract text from it. Remember that statements are run from top to bottom.":r&&r.getPreviousBlock()!==s?"Place the new "+T2C.MSG.currentLanguage.TERMINAL_DISPLAY+" block that's used to display all characters beyond the initial one below the previous "+T2C.MSG.currentLanguage.TERMINAL_LET+" variable block.":"Drag in the type-in code block from the toolbox and type in the code necessary to display all the characters except the initial one from the user response. As before, use "+T2C.MSG.currentLanguage.TERMINAL_GETTEXTFROMPOSITIONNUMBER+" and the variable response in your answer. But this time, make it work for any entered string, which means you can no longer enter a specific number for the position to end before.\nHINT: Remember what you used when you wanted to get the position of the last character? How is 15, the number we used for aap kaise hain?, related to this string? What would we use for theek?\nPlace this new block below the previous "+T2C.MSG.currentLanguage.TERMINAL_DISPLAY+"."}),{startPosition:q(o,null,{},50,document.getElementById("top-header").offsetHeight+50)}))),h(n),p(n,document.getElementById("output-container").querySelectorAll(".table-cell")[0]),n.addTask(new r((function(){return!0}),{start:function(){return!0},isComplete:function(){return!0},animate:function(){return!0},finish:function(){alert("✔✔👍 You got it, excellent problem solving as always! And with that mastery, mission 4 is now complete! In the next mission, we'll introduce a new block that'll be used to find the position numbers of the first occurrence of a given substring in another one. We'll then use it in combination with the "+T2C.MSG.currentLanguage.TERMINAL_GETTEXTFROMPOSITIONNUMBER+" from this lesson to get the text appearing between the first @ and . in an e-mail address (e.g., google from coolcoder@google.com or mail from expertsoftwareengineer@mail.co.uk)."),X(document.getElementById("output-container").querySelectorAll(".table-cell")[0]),j(),D(o),o.updateToolbox(document.getElementById("toolbox"))}})),n},function(e,t){var n=e||new c,o=t||Blockly.getMainWorkspace(),a=new f(o);o.setScale(1),Object(i.f)(o);var g=document.createElement("div");function d(e){e.addTask(new r((function(){return document.getElementById("output-container").classList.contains("show-container")}),new u([new s((function(){return T2C.MSG.currentLanguage.BUTTON_RUN_CODE}),{startPosition:{x:document.getElementById("run-code-button").offsetLeft+document.getElementById("run-code-button").offsetWidth,y:document.getElementById("run-code-button").offsetTop+document.getElementById("run-code-button").offsetHeight}}),new l(g,{totalSteps:100,toggleSteps:25,startPosition:{x:document.getElementById("run-code-button").offsetLeft+document.getElementById("run-code-button").offsetWidth/2,y:document.getElementById("run-code-button").offsetTop+document.getElementById("run-code-button").offsetHeight/2}})])))}function h(e,t){var n=0;function o(){t.style.color=n%50<25?"#a00":"#000",++n<200&&requestAnimationFrame(o)}e.addTask(new r((function(){return n>=200}),{start:function(){t.style.verticalAlign="top",requestAnimationFrame(o)},isComplete:function(){return!0},animate:function(){return!0}}))}return g.innerText="👆",g.id="ptr",g.style.fontSize="x-large",g.style.position="absolute",g.style.zIndex="1001",document.getElementById("blockly-div").appendChild(g),n.addTask(new r((function(){return!0}),{start:function(){return!0},isComplete:function(){return!0},animate:function(){return!0},finish:function(){alert("In this mission, you will learn about the "+T2C.MSG.currentLanguage.TERMINAL_FINDFIRSTOCCURRENCEOFTEXT+" and how it can be used to say get all of the text from the first @ up to the period. But first let's warm up by playing the role of the computer! You'll be given blocks of code and make the same substitutions the computer does step by step. For example, you'd be given blocks of code and would then fix the values in the blocks in each "+T2C.MSG.currentLanguage.TERMINAL_DISPLAY+", as necessary, so that each line of output is the same. Review the following code and run it. "),o.clear(),Blockly.Xml.domToWorkspace(Blockly.Xml.textToDom('sdsbahut badhiya!d2sDIVIDEsdbahut badhiya!DIVIDEbahut badhiya!2bahut badhiya!DIVIDE142bahut badhiya!7a'),o),Blockly.svgResize(o),a.clearToolbox()}})),d(n),h(n,document.getElementById("output-container").querySelectorAll(".table-cell")[0]),n.addTask(new r((function(){return!0}),{start:function(){return!0},isComplete:function(){return!0},animate:function(){return!0},finish:function(){var e="bahut badhiya!",t=e.length/2;alert("So from the first "+T2C.MSG.currentLanguage.TERMINAL_DISPLAY+" to the next, we combine the two substitutions of "+e+" for s and 2 for d. Then we substitute "+e.length+' for "'+e+'".length from the second '+T2C.MSG.currentLanguage.TERMINAL_DISPLAY+" to the third, "+e.length/2+" for "+e.length+"/2 from the third to the fourth and finally "+e.charAt(t)+" for s."+T2C.MSG.currentLanguage.TERMINAL_GETCHARACTERNUMBER+"("+t+").\n Now it's your turn, fill in the empty text \"\" blocks/change the 0's so the substitutions are correctly made."),o.clear(),Blockly.Xml.domToWorkspace(Blockly.Xml.textToDom('sdsbahut badhiya!d2sdMINUSs30MINUS30MINUS0300'),o),Blockly.svgResize(o),o.getAllBlocks().forEach((function(e){return e.setMovable(!1)})),z(document.getElementById("output-container").querySelectorAll(".table-cell")[0]),K()}})),n.addTask(new r((function(){var e=o.getAllBlocks().filter((function(e){return"text"===e.type&&"hut badhi"==e.getFieldValue("TEXT")})),t=o.getAllBlocks().filter((function(t){return"text_print"===t.type&&null===t.getNextBlock()&&-1!==e.indexOf(t.getInputTargetBlock("TEXT"))})),n=o.getAllBlocks().filter((function(e){return"math_number"===e.type&&"11"==e.getFieldValue("NUM")})),i=o.getAllBlocks().filter((function(e){return"math_number"===e.type&&"2"==e.getFieldValue("NUM")})),r=o.getAllBlocks().filter((function(e){return"text"===e.type&&"bahut badhiya!"==e.getFieldValue("TEXT")})),a=o.getAllBlocks().filter((function(e){return"t2c_text_getsubstring"===e.type&&-1!==r.indexOf(e.getInputTargetBlock("STRING"))&&-1!==i.indexOf(e.getInputTargetBlock("AT1"))&&-1!==n.indexOf(e.getInputTargetBlock("AT2"))})),l=o.getAllBlocks().filter((function(e){return"text_print"===e.type&&-1!==t.indexOf(e.getNextBlock())&&-1!==a.indexOf(e.getInputTargetBlock("TEXT"))})),s=o.getAllBlocks().filter((function(e){return"math_number"===e.type&&"3"==e.getFieldValue("NUM")})),u=o.getAllBlocks().filter((function(e){return"math_number"===e.type&&"14"==e.getFieldValue("NUM")})),c=o.getAllBlocks().filter((function(e){return"math_arithmetic_basic"===e.type&&-1!==u.indexOf(e.getInputTargetBlock("A"))&&-1!==s.indexOf(e.getInputTargetBlock("B"))&&"MINUS"==e.getFieldValue("OP")})),g=o.getAllBlocks().filter((function(e){return"t2c_text_getsubstring"===e.type&&-1!==r.indexOf(e.getInputTargetBlock("STRING"))&&-1!==i.indexOf(e.getInputTargetBlock("AT1"))&&-1!==c.indexOf(e.getInputTargetBlock("AT2"))})),d=o.getAllBlocks().filter((function(e){return"text_print"===e.type&&-1!==l.indexOf(e.getNextBlock())&&-1!==g.indexOf(e.getInputTargetBlock("TEXT"))})),h=o.getAllBlocks().filter((function(e){return"t2c_text_length"===e.type&&-1!==r.indexOf(e.getInputTargetBlock("VALUE"))})),p=o.getAllBlocks().filter((function(e){return"math_arithmetic_basic"===e.type&&-1!==h.indexOf(e.getInputTargetBlock("A"))&&-1!==s.indexOf(e.getInputTargetBlock("B"))&&"MINUS"==e.getFieldValue("OP")})),f=o.getAllBlocks().filter((function(e){return"t2c_text_getsubstring"===e.type&&-1!==r.indexOf(e.getInputTargetBlock("STRING"))&&-1!==i.indexOf(e.getInputTargetBlock("AT1"))&&-1!==p.indexOf(e.getInputTargetBlock("AT2"))})),m=o.getAllBlocks().filter((function(e){return"text_print"===e.type&&-1!==d.indexOf(e.getNextBlock())&&-1!==f.indexOf(e.getInputTargetBlock("TEXT"))})),y=o.getAllBlocks().filter((function(e){return"variables_get"===e.type&&"s"===e.getField("VAR").getText()})),T=o.getAllBlocks().filter((function(e){return"t2c_text_length"===e.type&&-1!==y.indexOf(e.getInputTargetBlock("VALUE"))})),_=o.getAllBlocks().filter((function(e){return"math_arithmetic_basic"===e.type&&-1!==T.indexOf(e.getInputTargetBlock("A"))&&-1!==s.indexOf(e.getInputTargetBlock("B"))&&"MINUS"==e.getFieldValue("OP")})),b=o.getAllBlocks().filter((function(e){return"variables_get"===e.type&&"d"===e.getField("VAR").getText()})),k=o.getAllBlocks().filter((function(e){return"t2c_text_getsubstring"===e.type&&-1!==y.indexOf(e.getInputTargetBlock("STRING"))&&-1!==b.indexOf(e.getInputTargetBlock("AT1"))&&-1!==_.indexOf(e.getInputTargetBlock("AT2"))})),x=o.getAllBlocks().filter((function(e){return"text_print"===e.type&&-1!==m.indexOf(e.getNextBlock())&&-1!==k.indexOf(e.getInputTargetBlock("TEXT"))})),E=o.getAllBlocks().filter((function(e){return"variables_set"===e.type&&-1!==x.indexOf(e.getNextBlock())&&-1!==i.indexOf(e.getInputTargetBlock("VALUE"))&&"d"===e.getField("VAR").getText()})),B=o.getAllBlocks().filter((function(e){return"variables_set"===e.type&&-1!==E.indexOf(e.getNextBlock())&&-1!==r.indexOf(e.getInputTargetBlock("VALUE"))&&"s"===e.getField("VAR").getText()}));return 1===e.length&&1===t.length&&1===n.length&&4===i.length&&5===r.length&&1===a.length&&1===l.length&&3===s.length&&1===u.length&&1===c.length&&1===g.length&&1===d.length&&1===h.length&&1===p.length&&1===f.length&&1===m.length&&2===y.length&&1===T.length&&1===_.length&&1===b.length&&1===k.length&&1===x.length&&1===E.length&&1===B.length}),new s((function(){for(var e=o.getAllBlocks(!0),t=e.filter((function(e){return"text_print"===e.type||"js_text_print"===e.type})),n=e.filter((function(e){return"t2c_text_getsubstring"===e.type||"js_text_getsubstring"===e.type})),i=e.find((function(e){return"text"===e.type&&e.getParent()&&"t2c_text_length"===e.getParent().type})),r=e.find((function(e){return"math_arithmetic_basic"===e.type&&e.getInputTargetBlock("A")&&"math_number"===e.getInputTargetBlock("A").type})),a=n.map((function(e){return e.getInputTargetBlock("AT2")})).find((function(e){return e&&"math_number"===e.type})),l=t.map((function(e){return e.getInputTargetBlock("TEXT")})).find((function(e){return e&&"text"===e.type})),s="bahut badhiya!",u=s.substring(2,s.length-3),c=1;c<=3;c++){var g=n[c].getInputTargetBlock("STRING"),d=n[c].getInputTargetBlock("AT1");if(g&&"text"===g.type&&g.getFieldValue("TEXT")&&g.getFieldValue("TEXT")!==s)return"The text on line "+(c+3)+" is incorrect. Substitute s with the value that it's initially assigned to.";if(d&&"math_number"===d.type&&d.getFieldValue("NUM")&&2!==d.getFieldValue("NUM"))return"The number in the first position on line "+(c+3)+" is incorrect. Substitute d with the value that it's initially assigned to."}if(i&&i.getFieldValue("TEXT")&&i.getFieldValue("TEXT")!==s)return"The text in the "+T2C.MSG.currentLanguage.TERMINAL_LENGTH+" block on line 4 is incorrect. Substitute s with the value that it's initially assigned to.";if(r&&l){var h=r.getInputTargetBlock("A").getFieldValue("NUM"),p=l.getFieldValue("TEXT");if(h===s.length-1)return"Remember the count for the length starts with 1 and include the spaces and punctuation are counted.";if(h&&h!==s.length)return"Substitute the first number in the arithmetic block with the subtraction on line 5 with s's length.";if(h&&a&&a.getFieldValue("NUM")!==s.length-3)return"What is s.length - 3? This is what should be substituted for the second number block on line 6.";if(h&&p){if(u===p.substring(1))return"Remember to start counting from 0 when determining what the resulting string will be on the last line.";if(p===u.substring(1))return"Remember that "+T2C.MSG.currentLanguage.TERMINAL_GETTEXTFROMPOSITIONNUMBER+" starts extracting text at the exact position given for its first number. Change the string literal on the last line, accordingly.";if(u===p.substring(0,p.length-1))return"Remember that "+T2C.MSG.currentLanguage.TERMINAL_GETTEXTFROMPOSITIONNUMBER+" stops extracting text at one position before its given second number. Change the string literal on the last line, accordingly.";if(u!==p)return"The string literal you have on the last line is incorrect. Check the previous lines in order and then fix it accordingly."}}return"Replace all the blank string literals and 0's with the appropriate text and numbers that are substituted as the computer would from top to bottom so that every line of output is the same. Try to do this without running the program until you get the message to do so (when you filled in everything correctly)."}),{startPosition:te(o,null,{},50,document.getElementById("top-header").offsetHeight+50)}))),d(n),h(n,document.getElementById("output-container").querySelectorAll(".table-cell")[0]),n.addTask(new r((function(){return!0}),{start:function(){return!0},isComplete:function(){return!0},animate:function(){return!0},finish:function(){alert("✔ Nice, so now let's tweak this a little, adding the new "+T2C.MSG.currentLanguage.TERMINAL_FINDFIRSTOCCURRENCEOFTEXT+" block, which given a string (haystack) to look through and a string appearing in it (needle) to find, produces the position NUMBER of its first occurrence. As before, replace all the blank string literals and 0's with the appropriate text and numbers that are substituted as the computer would from top to bottom so that every line of output is the same. Try to do this without running the program until you get the message to do so (when you filled in everything correctly)."),o.clear(),Blockly.Xml.domToWorkspace(Blockly.Xml.textToDom('sspacePositionsbahut badhiya!spacePositions sMINUS1spacePosition13ADDspacePosition4MINUS1013ADD0400'),o),Blockly.svgResize(o),o.getAllBlocks().forEach((function(e){return e.setMovable(!1)})),z(document.getElementById("output-container").querySelectorAll(".table-cell")[0]),K()}})),n.addTask(new r((function(){var e=o.getAllBlocks().filter((function(e){return"text"===e.type&&"hut bad"==e.getFieldValue("TEXT")})),t=o.getAllBlocks().filter((function(t){return"text_print"===t.type&&null===t.getNextBlock()&&-1!==e.indexOf(t.getInputTargetBlock("TEXT"))})),n=o.getAllBlocks().filter((function(e){return"math_number"===e.type&&"9"==e.getFieldValue("NUM")})),i=o.getAllBlocks().filter((function(e){return"math_number"===e.type&&"2"==e.getFieldValue("NUM")})),r=o.getAllBlocks().filter((function(e){return"text"===e.type&&"bahut badhiya!"==e.getFieldValue("TEXT")})),a=o.getAllBlocks().filter((function(e){return"t2c_text_getsubstring"===e.type&&-1!==r.indexOf(e.getInputTargetBlock("STRING"))&&-1!==i.indexOf(e.getInputTargetBlock("AT1"))&&-1!==n.indexOf(e.getInputTargetBlock("AT2"))})),l=o.getAllBlocks().filter((function(e){return"text_print"===e.type&&-1!==t.indexOf(e.getNextBlock())&&-1!==a.indexOf(e.getInputTargetBlock("TEXT"))})),s=o.getAllBlocks().filter((function(e){return"math_number"===e.type&&"4"==e.getFieldValue("NUM")})),u=o.getAllBlocks().filter((function(e){return"math_number"===e.type&&"5"==e.getFieldValue("NUM")})),c=o.getAllBlocks().filter((function(e){return"math_arithmetic_basic"===e.type&&-1!==u.indexOf(e.getInputTargetBlock("A"))&&-1!==s.indexOf(e.getInputTargetBlock("B"))&&"ADD"==e.getFieldValue("OP")})),g=o.getAllBlocks().filter((function(e){return"math_number"===e.type&&"3"==e.getFieldValue("NUM")})),d=o.getAllBlocks().filter((function(e){return"math_arithmetic_basic"===e.type&&-1!==u.indexOf(e.getInputTargetBlock("A"))&&-1!==g.indexOf(e.getInputTargetBlock("B"))&&"MINUS"==e.getFieldValue("OP")})),h=o.getAllBlocks().filter((function(e){return"t2c_text_getsubstring"===e.type&&-1!==r.indexOf(e.getInputTargetBlock("STRING"))&&-1!==d.indexOf(e.getInputTargetBlock("AT1"))&&-1!==c.indexOf(e.getInputTargetBlock("AT2"))})),p=o.getAllBlocks().filter((function(e){return"text_print"===e.type&&-1!==l.indexOf(e.getNextBlock())&&-1!==h.indexOf(e.getInputTargetBlock("TEXT"))})),f=o.getAllBlocks().filter((function(e){return"variables_get"===e.type&&"spacePosition"===e.getField("VAR").getText()})),m=o.getAllBlocks().filter((function(e){return"math_arithmetic_basic"===e.type&&-1!==f.indexOf(e.getInputTargetBlock("A"))&&-1!==s.indexOf(e.getInputTargetBlock("B"))&&"ADD"==e.getFieldValue("OP")})),y=o.getAllBlocks().filter((function(e){return"math_arithmetic_basic"===e.type&&-1!==f.indexOf(e.getInputTargetBlock("A"))&&-1!==g.indexOf(e.getInputTargetBlock("B"))&&"MINUS"==e.getFieldValue("OP")})),T=o.getAllBlocks().filter((function(e){return"variables_get"===e.type&&"s"===e.getField("VAR").getText()})),_=o.getAllBlocks().filter((function(e){return"t2c_text_getsubstring"===e.type&&-1!==T.indexOf(e.getInputTargetBlock("STRING"))&&-1!==y.indexOf(e.getInputTargetBlock("AT1"))&&-1!==m.indexOf(e.getInputTargetBlock("AT2"))})),b=o.getAllBlocks().filter((function(e){return"text_print"===e.type&&-1!==p.indexOf(e.getNextBlock())&&-1!==_.indexOf(e.getInputTargetBlock("TEXT"))})),k=o.getAllBlocks().filter((function(e){return"text"===e.type&&" "==e.getFieldValue("TEXT")})),x=o.getAllBlocks().filter((function(e){return"t2c_text_indexof"===e.type&&-1!==T.indexOf(e.getInputTargetBlock("VALUE"))&&-1!==k.indexOf(e.getInputTargetBlock("FIND"))})),E=o.getAllBlocks().filter((function(e){return"variables_set"===e.type&&-1!==b.indexOf(e.getNextBlock())&&-1!==x.indexOf(e.getInputTargetBlock("VALUE"))&&"spacePosition"===e.getField("VAR").getText()})),B=o.getAllBlocks().filter((function(e){return"variables_set"===e.type&&-1!==E.indexOf(e.getNextBlock())&&-1!==r.indexOf(e.getInputTargetBlock("VALUE"))&&"s"===e.getField("VAR").getText()}));return 1===e.length&&1===t.length&&1===n.length&&1===i.length&&3===r.length&&1===a.length&&1===l.length&&2===s.length&&2===u.length&&1===c.length&&2===g.length&&1===d.length&&1===h.length&&1===p.length&&2===f.length&&1===m.length&&1===y.length&&2===T.length&&1===_.length&&1===b.length&&1===k.length&&1===x.length&&1===E.length&&1===B.length}),new s((function(){for(var e=o.getAllBlocks(!0),t=e.filter((function(e){return"text_print"===e.type||"js_text_print"===e.type})),n=e.filter((function(e){return"t2c_text_getsubstring"===e.type||"js_text_getsubstring"===e.type})),i=e.filter((function(e){return"math_arithmetic_basic"===e.type})).map((function(e){return e.getInputTargetBlock("A")})).filter((function(e){return e&&"math_number"===e.type})),r=n.find((function(e){return e.getInputTargetBlock("AT1")&&e.getInputTargetBlock("AT2")&&"math_number"===e.getInputTargetBlock("AT1").type&&"math_number"===e.getInputTargetBlock("AT2").type})),a=t.map((function(e){return e.getInputTargetBlock("TEXT")})).find((function(e){return e&&"text"===e.type})),l=r&&r.getInputTargetBlock("AT1").getFieldValue("NUM"),s=r&&r.getInputTargetBlock("AT2").getFieldValue("NUM"),u="bahut badhiya!",c=u.indexOf(" "),g=u.substring(c-3,c+4),d=1;d<=2;d++){var h=n[d].getInputTargetBlock("STRING"),p=i[d-1];if(h&&"text"===h.type&&h.getFieldValue("TEXT")&&h.getFieldValue("TEXT")!==u)return"The text on line "+(d+3)+" is incorrect. Substitute s with the value that it's initially assigned to.";if(p&&p.getFieldValue("NUM")&&p.getFieldValue("NUM")!==c)return"The left number in the "+(1===d?"first":"second")+" arithmetic block on line 4 is incorrect. Substitute each spacePosition with the position of the first space in s, i.e., "+u+"."}if(l&&l!==c-3)return"The "+l+" on line 5 is incorrect; it should be the result of subtracting 3 from the value of spacePosition.";if(s&&s!==c+4)return"The "+s+" on line 5 is incorrect; it should be the result of adding 4 to the value of spacePosition.";if(l&&s&&a){var f=a.getFieldValue("TEXT");if(f){if(g===f.substring(1))return"Remember to start counting from 0 when determining what the resulting string will be on the last line.";if(f===g.substring(1))return"Remember that "+T2C.MSG.currentLanguage.TERMINAL_GETTEXTFROMPOSITIONNUMBER+" starts extracting text at the exact position given for its first number. Change the string literal on the last line, accordingly.";if(g===f.substring(0,f.length-1))return"Remember that "+T2C.MSG.currentLanguage.TERMINAL_GETTEXTFROMPOSITIONNUMBER+" stops extracting text at one position before its given second number. Change the string literal on the last line, accordingly.";if(g!==f)return"The string literal you have on the last line is incorrect. Check the previous lines in order and then fix it accordingly."}}return"The new "+T2C.MSG.currentLanguage.TERMINAL_FINDFIRSTOCCURRENCEOFTEXT+" takes a string (haystack: a space in this code excerpt) to look through and a string appearing in it (needle) to find as inputs and produces the position NUMBER of the needle's first occurrence in haystack. As before, replace all the blank string literals and 0's with the appropriate text and numbers that are substituted as the computer would from top to bottom so that every line of output is the same. Try to do this without running the program until you get the message to do so (when you filled in everything correctly)."}),{startPosition:te(o,null,{},50,document.getElementById("top-header").offsetHeight+50)}))),d(n),h(n,document.getElementById("output-container").querySelectorAll(".table-cell")[0]),n.addTask(new r((function(){return!0}),{start:function(){return!0},isComplete:function(){return!0},animate:function(){return!0},finish:function(){alert("✔ Nice x 2! So as you can see the new "+T2C.MSG.currentLanguage.TERMINAL_FINDFIRSTOCCURRENCEOFTEXT+" allows us to extract characters before/after a desired character(s) when used to determine starting/ending positions for "+T2C.MSG.currentLanguage.TERMINAL_GETTEXTFROMPOSITIONNUMBER+" (or just a single position for "+T2C.MSG.currentLanguage.TERMINAL_GETCHARACTERNUMBER+"). Let's try a few more examples where you'll again replace all the blank string literals and 0's with the appropriate text and numbers that are substituted as the computer would from top to bottom so that every line of output is the same. Try to do this without running the program until you get the message to do so (when you filled in everything correctly)."),o.clear(),Blockly.Xml.domToWorkspace(Blockly.Xml.textToDom('greetinggreetinghey HEY hey!greetinggreetingHH0'),o),Blockly.svgResize(o),o.getAllBlocks().forEach((function(e){return e.setMovable(!1)})),z(document.getElementById("output-container").querySelectorAll(".table-cell")[0]),K()}})),n.addTask(new r((function(){var e=o.getAllBlocks().filter((function(e){return"text"===e.type&&"H"===e.getFieldValue("TEXT")})),t=o.getAllBlocks().filter((function(t){return"text_print"===t.type&&null===t.getNextBlock()&&-1!==e.indexOf(t.getInputTargetBlock("TEXT"))})),n=o.getAllBlocks().filter((function(e){return"math_number"===e.type&&4===e.getFieldValue("NUM")})),i=o.getAllBlocks().filter((function(e){return"text"===e.type&&"hey HEY hey!"==e.getFieldValue("TEXT")})),r=o.getAllBlocks().filter((function(e){return"t2c_text_charat"===e.type&&-1!==i.indexOf(e.getInputTargetBlock("VALUE"))&&-1!==n.indexOf(e.getInputTargetBlock("AT"))})),a=o.getAllBlocks().filter((function(e){return"text_print"===e.type&&-1!==t.indexOf(e.getNextBlock())&&-1!==r.indexOf(e.getInputTargetBlock("TEXT"))})),l=o.getAllBlocks().filter((function(t){return"t2c_text_indexof"===t.type&&-1!==i.indexOf(t.getInputTargetBlock("VALUE"))&&-1!==e.indexOf(t.getInputTargetBlock("FIND"))})),s=o.getAllBlocks().filter((function(e){return"t2c_text_charat"===e.type&&-1!==i.indexOf(e.getInputTargetBlock("VALUE"))&&-1!==l.indexOf(e.getInputTargetBlock("AT"))})),u=o.getAllBlocks().filter((function(e){return"text_print"===e.type&&-1!==a.indexOf(e.getNextBlock())&&-1!==s.indexOf(e.getInputTargetBlock("TEXT"))})),c=o.getAllBlocks().filter((function(e){return"variables_get"===e.type&&"greeting"===e.getField("VAR").getText()})),g=o.getAllBlocks().filter((function(t){return"t2c_text_indexof"===t.type&&-1!==c.indexOf(t.getInputTargetBlock("VALUE"))&&-1!==e.indexOf(t.getInputTargetBlock("FIND"))})),d=o.getAllBlocks().filter((function(e){return"t2c_text_charat"===e.type&&-1!==c.indexOf(e.getInputTargetBlock("VALUE"))&&-1!==g.indexOf(e.getInputTargetBlock("AT"))})),h=o.getAllBlocks().filter((function(e){return"text_print"===e.type&&-1!==u.indexOf(e.getNextBlock())&&-1!==d.indexOf(e.getInputTargetBlock("TEXT"))})),p=o.getAllBlocks().filter((function(e){return"variables_set"===e.type&&-1!==h.indexOf(e.getNextBlock())&&-1!==i.indexOf(e.getInputTargetBlock("VALUE"))&&"greeting"===e.getField("VAR").getText()}));return 3===e.length&&1===t.length&&1===n.length&&4===i.length&&1===r.length&&1===a.length&&1===l.length&&1===s.length&&1===u.length&&2===c.length&&1===g.length&&1===d.length&&1===h.length&&1===p.length}),new s((function(){var e=o.getAllBlocks(!0),t=e.filter((function(e){return"t2c_text_charat"===e.type||"js_text_charat"===e.type})).map((function(e){return e.getInputTargetBlock("VALUE")})).filter((function(e){return e&&"text"===e.type})),n=e.filter((function(e){return"t2c_text_indexof"===e.type||"js_text_indexof"===e.type})).map((function(e){return e.getInputTargetBlock("VALUE")})).find((function(e){return e&&"text"===e.type})),i=e.find((function(e){return"math_number"===e.type&&e.getParent()&&("t2c_text_charat"===e.getParent().type||"js_text_charat"===e.getParent().type)})),r=e.find((function(e){return"text"===e.type&&e.getParent()&&("text_print"===e.getParent().type||"js_text_print"===e.getParent().type)})),a="hey HEY hey!",l="H";a.indexOf(l);for(var s=0;s<=1;s++){var u=t[s];if(u&&u.getFieldValue("TEXT")&&u.getFieldValue("TEXT")!==a)return"The text before "+T2C.MSG.currentLanguage.TERMINAL_GETCHARACTERNUMBER+" on line "+(s+3)+" is incorrect. Substitute greeting with the value that it's initially assigned to."}if(n&&n.getFieldValue("TEXT")&&n.getFieldValue("TEXT")!==a)return"The text before "+T2C.MSG.currentLanguage.TERMINAL_FINDFIRSTOCCURRENCEOFTEXT+" on line 3 is incorrect. Substitute greeting with the value that it's initially assigned to.";if(i){var c=i.getFieldValue("NUM");if(c&&c===a.indexOf(l.toLowerCase()))return"The number you substituted on line 4 is incorrect. "+T2C.MSG.currentLanguage.TERMINAL_FINDFIRSTOCCURRENCEOFTEXT+" is case sensitive meaning that H is different than "+l.toLowerCase()+".";if(c&&c===a.indexOf(l)+1)return"The number you substituted on line 4 is incorrect. Remember that positions start at 0.";if(c&&c===a.indexOf(l)-1)return"The number you substituted on line 4 is incorrect. "+T2C.MSG.currentLanguage.TERMINAL_FINDFIRSTOCCURRENCEOFTEXT+" gets the *exact* position of the first occurrence.";if(c&&c!==a.indexOf(l))return"The number you substituted on line 4 is incorrect. Remember to count all of the characters including spaces when getting the position of the first H.";if(c===a.indexOf(l)&&r){var g=r.getFieldValue("TEXT");if(g===l.toLowerCase())return"The string literal on the last line is incorrect. Remember to type in the same case ("+l.toLowerCase()+" versus H).";if(g&&g!==l)return"The string literal on the last line is incorrect. Check the previous lines in order and then fix it accordingly; it should be the result of the substitution of "+T2C.MSG.currentLanguage.TERMINAL_GETCHARACTERNUMBER+"."}}return"Replace all the blank string literals and 0's with the appropriate text and numbers that are substituted as the computer would from top to bottom so that every line of output is the same. Try to do this without running the program until you get the message to do so (when you filled in everything correctly)."}),{startPosition:te(o,null,{},50,document.getElementById("top-header").offsetHeight+50)}))),d(n),h(n,document.getElementById("output-container").querySelectorAll(".table-cell")[0]),n.addTask(new r((function(){return!0}),{start:function(){return!0},isComplete:function(){return!0},animate:function(){return!0},finish:function(){alert("✔ Nice x 3! So as you may have noticed, you got back the character you started with. Can you see why? If you get the position number of an H and then ask what character is at that position, it should be H! Now, let's reverse the order of the "+T2C.MSG.currentLanguage.TERMINAL_GETCHARACTERNUMBER+" and "+T2C.MSG.currentLanguage.TERMINAL_FINDFIRSTOCCURRENCEOFTEXT+" to see what happens."),o.clear(),Blockly.Xml.domToWorkspace(Blockly.Xml.textToDom('greetinggreetingHEY hey hey!greetinggreeting880'),o),Blockly.svgResize(o),o.getAllBlocks().forEach((function(e){return e.setMovable(!1)})),z(document.getElementById("output-container").querySelectorAll(".table-cell")[0]),K()}})),n.addTask(new r((function(){var e=o.getAllBlocks().filter((function(e){return"math_number"===e.type&&"4"==e.getFieldValue("NUM")})),t=o.getAllBlocks().filter((function(t){return"text_print"===t.type&&null===t.getNextBlock()&&-1!==e.indexOf(t.getInputTargetBlock("TEXT"))})),n=o.getAllBlocks().filter((function(e){return"text"===e.type&&"h"==e.getFieldValue("TEXT")})),i=o.getAllBlocks().filter((function(e){return"text"===e.type&&"HEY hey hey!"==e.getFieldValue("TEXT")})),r=o.getAllBlocks().filter((function(e){return"t2c_text_indexof"===e.type&&-1!==i.indexOf(e.getInputTargetBlock("VALUE"))&&-1!==n.indexOf(e.getInputTargetBlock("FIND"))})),a=o.getAllBlocks().filter((function(e){return"text_print"===e.type&&-1!==t.indexOf(e.getNextBlock())&&-1!==r.indexOf(e.getInputTargetBlock("TEXT"))})),l=o.getAllBlocks().filter((function(e){return"math_number"===e.type&&"8"==e.getFieldValue("NUM")})),s=o.getAllBlocks().filter((function(e){return"t2c_text_charat"===e.type&&-1!==i.indexOf(e.getInputTargetBlock("VALUE"))&&-1!==l.indexOf(e.getInputTargetBlock("AT"))})),u=o.getAllBlocks().filter((function(e){return"t2c_text_indexof"===e.type&&-1!==i.indexOf(e.getInputTargetBlock("VALUE"))&&-1!==s.indexOf(e.getInputTargetBlock("FIND"))})),c=o.getAllBlocks().filter((function(e){return"text_print"===e.type&&-1!==a.indexOf(e.getNextBlock())&&-1!==u.indexOf(e.getInputTargetBlock("TEXT"))})),g=o.getAllBlocks().filter((function(e){return"variables_get"===e.type&&"greeting"===e.getField("VAR").getText()})),d=o.getAllBlocks().filter((function(e){return"t2c_text_charat"===e.type&&-1!==g.indexOf(e.getInputTargetBlock("VALUE"))&&-1!==l.indexOf(e.getInputTargetBlock("AT"))})),h=o.getAllBlocks().filter((function(e){return"t2c_text_indexof"===e.type&&-1!==g.indexOf(e.getInputTargetBlock("VALUE"))&&-1!==d.indexOf(e.getInputTargetBlock("FIND"))})),p=o.getAllBlocks().filter((function(e){return"text_print"===e.type&&-1!==c.indexOf(e.getNextBlock())&&-1!==h.indexOf(e.getInputTargetBlock("TEXT"))})),f=o.getAllBlocks().filter((function(e){return"variables_set"===e.type&&-1!==p.indexOf(e.getNextBlock())&&-1!==i.indexOf(e.getInputTargetBlock("VALUE"))&&"greeting"===e.getField("VAR").getText()}));return 1===e.length&&1===t.length&&1===n.length&&4===i.length&&1===r.length&&1===a.length&&2===l.length&&1===s.length&&1===u.length&&1===c.length&&2===g.length&&1===d.length&&1===h.length&&1===p.length&&1===f.length}),new s((function(){for(var e=o.getAllBlocks(!0),t=e.filter((function(e){return"t2c_text_indexof"===e.type||"js_text_indexof"===e.type})).map((function(e){return e.getInputTargetBlock("VALUE")})).filter((function(e){return e&&"text"===e.type})),n=e.filter((function(e){return"t2c_text_charat"===e.type||"js_text_charat"===e.type})).map((function(e){return e.getInputTargetBlock("VALUE")})).find((function(e){return e&&"text"===e.type})),i=e.filter((function(e){return"t2c_text_indexof"===e.type||"js_text_indexof"===e.type})).map((function(e){return e.getInputTargetBlock("FIND")})).find((function(e){return e&&"text"===e.type})),r=e.find((function(e){return"math_number"===e.type&&e.getParent()&&("text_print"===e.getParent().type||"js_text_print"===e.getParent().type)})),a="HEY hey hey!".charAt(8),l=0;l<=1;l++){var s=t[l];if(s&&s.getFieldValue("TEXT")&&"HEY hey hey!"!==s.getFieldValue("TEXT"))return"The text before "+T2C.MSG.currentLanguage.TERMINAL_FINDFIRSTOCCURRENCEOFTEXT+" on line "+(l+3)+" is incorrect. Substitute greeting with the value that it's initially assigned to."}if(n&&n.getFieldValue("TEXT")&&"HEY hey hey!"!==n.getFieldValue("TEXT"))return"The text before "+T2C.MSG.currentLanguage.TERMINAL_GETCHARACTERNUMBER+" on line 3 is incorrect. Substitute greeting with the value that it's initially assigned to.";if(i){var u=i.getFieldValue("TEXT");if(u&&u!==a)return"The text you substituted on line 4 is incorrect. Remember to count all of the characters, starting from 0 and including spaces, when getting the character at position 8.";if(u===a&&r){var c=r.getFieldValue("NUM");if(8===c)return"Remember that "+T2C.MSG.currentLanguage.TERMINAL_FINDFIRSTOCCURRENCEOFTEXT+" gets the position of the *first* occurrence.";if(c!=="HEY hey hey!".indexOf(a))return"The number on the last line is incorrect. Check the previous lines in order and then fix it accordingly; it should be the result of the substitution of "+T2C.MSG.currentLanguage.TERMINAL_FINDFIRSTOCCURRENCEOFTEXT+". Remember that positions start with 0 and to count spaces."}}return"Replace all the blank string literals and 0's with the appropriate text and numbers that are substituted as the computer would from top to bottom so that every line of output is the same. Try to do this without running the program until you get the message to do so (when you filled in everything correctly)."}),{startPosition:te(o,null,{},50,document.getElementById("top-header").offsetHeight+50)}))),d(n),h(n,document.getElementById("output-container").querySelectorAll(".table-cell")[0]),n.addTask(new r((function(){return!0}),{start:function(){return!0},isComplete:function(){return!0},animate:function(){return!0},finish:function(){alert("✔ Nice x 4! Did you notice that you did *not* get the number you started with this time. Can you see why? Well, the character you got appeared earlier. So when you looked for its first position, you got a smaller number back. Had you gotten the character at its first position (i.e., 4 in this case), and then asked for its position, you would have indeed gotten back the number you started with. OK, one more code reading substitution example before we get to a code writing one! We'll skip a few steps since it's a little long, but you're up for the challenge, right?"),o.clear(),Blockly.Xml.domToWorkspace(Blockly.Xml.textToDom('questionneedlepart1part2questionWhere is the code?needle is part1questionADDquestionneedle4MINUSquestion1part2question1questionneedlepart1needlepart2questionADD04MINUS01question100010'),o),Blockly.svgResize(o),o.getAllBlocks().forEach((function(e){return e.setMovable(!1)})),z(document.getElementById("output-container").querySelectorAll(".table-cell")[0]),K()}})),n.addTask(new r((function(){var e=o.getAllBlocks().filter((function(e){return"text"===e.type&&"the code is here"==e.getFieldValue("TEXT")})),t=o.getAllBlocks().filter((function(t){return"text_print"===t.type&&null===t.getNextBlock()&&-1!==e.indexOf(t.getInputTargetBlock("TEXT"))})),n=o.getAllBlocks().filter((function(e){return"text"===e.type&&"here"==e.getFieldValue("TEXT")})),i=o.getAllBlocks().filter((function(e){return"text"===e.type&&" is "==e.getFieldValue("TEXT")})),r=o.getAllBlocks().filter((function(e){return"t2c_text_join"===e.type&&-1!==i.indexOf(e.getInputTargetBlock("A"))&&-1!==n.indexOf(e.getInputTargetBlock("B"))})),a=o.getAllBlocks().filter((function(e){return"text"===e.type&&"the code"==e.getFieldValue("TEXT")})),l=o.getAllBlocks().filter((function(e){return"t2c_text_join"===e.type&&-1!==a.indexOf(e.getInputTargetBlock("A"))&&-1!==r.indexOf(e.getInputTargetBlock("B"))})),s=o.getAllBlocks().filter((function(e){return"text_print"===e.type&&-1!==t.indexOf(e.getNextBlock())&&-1!==l.indexOf(e.getInputTargetBlock("TEXT"))})),u=o.getAllBlocks().filter((function(e){return"math_number"===e.type&&"5"==e.getFieldValue("NUM")})),c=o.getAllBlocks().filter((function(e){return"math_number"===e.type&&"1"==e.getFieldValue("NUM")})),g=o.getAllBlocks().filter((function(e){return"text"===e.type&&"Where is the code?"==e.getFieldValue("TEXT")})),d=o.getAllBlocks().filter((function(e){return"t2c_text_getsubstring"===e.type&&-1!==g.indexOf(e.getInputTargetBlock("STRING"))&&-1!==c.indexOf(e.getInputTargetBlock("AT1"))&&-1!==u.indexOf(e.getInputTargetBlock("AT2"))})),h=o.getAllBlocks().filter((function(e){return"t2c_text_join"===e.type&&-1!==i.indexOf(e.getInputTargetBlock("A"))&&-1!==d.indexOf(e.getInputTargetBlock("B"))})),p=o.getAllBlocks().filter((function(e){return"math_number"===e.type&&"17"==e.getFieldValue("NUM")})),f=o.getAllBlocks().filter((function(e){return"math_number"===e.type&&"9"==e.getFieldValue("NUM")})),m=o.getAllBlocks().filter((function(e){return"t2c_text_getsubstring"===e.type&&-1!==g.indexOf(e.getInputTargetBlock("STRING"))&&-1!==f.indexOf(e.getInputTargetBlock("AT1"))&&-1!==p.indexOf(e.getInputTargetBlock("AT2"))})),y=o.getAllBlocks().filter((function(e){return"t2c_text_join"===e.type&&-1!==m.indexOf(e.getInputTargetBlock("A"))&&-1!==h.indexOf(e.getInputTargetBlock("B"))})),T=o.getAllBlocks().filter((function(e){return"text_print"===e.type&&-1!==s.indexOf(e.getNextBlock())&&-1!==y.indexOf(e.getInputTargetBlock("TEXT"))})),_=o.getAllBlocks().filter((function(e){return"variables_get"===e.type&&"question"===e.getField("VAR").getText()})),b=o.getAllBlocks().filter((function(e){return"t2c_text_getsubstring"===e.type&&-1!==_.indexOf(e.getInputTargetBlock("STRING"))&&-1!==c.indexOf(e.getInputTargetBlock("AT1"))&&-1!==u.indexOf(e.getInputTargetBlock("AT2"))})),k=o.getAllBlocks().filter((function(e){return"t2c_text_join"===e.type&&-1!==i.indexOf(e.getInputTargetBlock("A"))&&-1!==b.indexOf(e.getInputTargetBlock("B"))})),x=o.getAllBlocks().filter((function(e){return"math_number"===e.type&&"18"==e.getFieldValue("NUM")})),E=o.getAllBlocks().filter((function(e){return"math_arithmetic_basic"===e.type&&-1!==x.indexOf(e.getInputTargetBlock("A"))&&-1!==c.indexOf(e.getInputTargetBlock("B"))&&"MINUS"==e.getFieldValue("OP")})),B=o.getAllBlocks().filter((function(e){return"math_number"===e.type&&"4"==e.getFieldValue("NUM")})),A=o.getAllBlocks().filter((function(e){return"math_arithmetic_basic"===e.type&&-1!==u.indexOf(e.getInputTargetBlock("A"))&&-1!==B.indexOf(e.getInputTargetBlock("B"))&&"ADD"==e.getFieldValue("OP")})),v=o.getAllBlocks().filter((function(e){return"t2c_text_getsubstring"===e.type&&-1!==_.indexOf(e.getInputTargetBlock("STRING"))&&-1!==A.indexOf(e.getInputTargetBlock("AT1"))&&-1!==E.indexOf(e.getInputTargetBlock("AT2"))})),I=o.getAllBlocks().filter((function(e){return"t2c_text_join"===e.type&&-1!==v.indexOf(e.getInputTargetBlock("A"))&&-1!==k.indexOf(e.getInputTargetBlock("B"))})),w=o.getAllBlocks().filter((function(e){return"text_print"===e.type&&-1!==T.indexOf(e.getNextBlock())&&-1!==I.indexOf(e.getInputTargetBlock("TEXT"))})),S=o.getAllBlocks().filter((function(e){return"variables_get"===e.type&&"part2"===e.getField("VAR").getText()})),M=o.getAllBlocks().filter((function(e){return"variables_get"===e.type&&"needle"===e.getField("VAR").getText()})),N=o.getAllBlocks().filter((function(e){return"t2c_text_join"===e.type&&-1!==M.indexOf(e.getInputTargetBlock("A"))&&-1!==S.indexOf(e.getInputTargetBlock("B"))})),L=o.getAllBlocks().filter((function(e){return"variables_get"===e.type&&"part1"===e.getField("VAR").getText()})),O=o.getAllBlocks().filter((function(e){return"t2c_text_join"===e.type&&-1!==L.indexOf(e.getInputTargetBlock("A"))&&-1!==N.indexOf(e.getInputTargetBlock("B"))})),C=o.getAllBlocks().filter((function(e){return"text_print"===e.type&&-1!==w.indexOf(e.getNextBlock())&&-1!==O.indexOf(e.getInputTargetBlock("TEXT"))})),R=o.getAllBlocks().filter((function(e){return"t2c_text_indexof"===e.type&&-1!==_.indexOf(e.getInputTargetBlock("VALUE"))&&-1!==M.indexOf(e.getInputTargetBlock("FIND"))})),F=o.getAllBlocks().filter((function(e){return"t2c_text_getsubstring"===e.type&&-1!==_.indexOf(e.getInputTargetBlock("STRING"))&&-1!==c.indexOf(e.getInputTargetBlock("AT1"))&&-1!==R.indexOf(e.getInputTargetBlock("AT2"))})),P=o.getAllBlocks().filter((function(e){return"variables_set"===e.type&&-1!==C.indexOf(e.getNextBlock())&&-1!==F.indexOf(e.getInputTargetBlock("VALUE"))&&"part2"===e.getField("VAR").getText()})),V=o.getAllBlocks().filter((function(e){return"t2c_text_length"===e.type&&-1!==_.indexOf(e.getInputTargetBlock("VALUE"))})),G=o.getAllBlocks().filter((function(e){return"math_arithmetic_basic"===e.type&&-1!==V.indexOf(e.getInputTargetBlock("A"))&&-1!==c.indexOf(e.getInputTargetBlock("B"))&&"MINUS"==e.getFieldValue("OP")})),U=o.getAllBlocks().filter((function(e){return"math_arithmetic_basic"===e.type&&-1!==R.indexOf(e.getInputTargetBlock("A"))&&-1!==B.indexOf(e.getInputTargetBlock("B"))&&"ADD"==e.getFieldValue("OP")})),X=o.getAllBlocks().filter((function(e){return"t2c_text_getsubstring"===e.type&&-1!==_.indexOf(e.getInputTargetBlock("STRING"))&&-1!==U.indexOf(e.getInputTargetBlock("AT1"))&&-1!==G.indexOf(e.getInputTargetBlock("AT2"))})),j=o.getAllBlocks().filter((function(e){return"variables_set"===e.type&&-1!==P.indexOf(e.getNextBlock())&&-1!==X.indexOf(e.getInputTargetBlock("VALUE"))&&"part1"===e.getField("VAR").getText()})),D=o.getAllBlocks().filter((function(e){return"variables_set"===e.type&&-1!==j.indexOf(e.getNextBlock())&&-1!==i.indexOf(e.getInputTargetBlock("VALUE"))&&"needle"===e.getField("VAR").getText()})),W=o.getAllBlocks().filter((function(e){return"variables_set"===e.type&&-1!==D.indexOf(e.getNextBlock())&&-1!==g.indexOf(e.getInputTargetBlock("VALUE"))&&"question"===e.getField("VAR").getText()}));return 1===e.length&&1===t.length&&1===n.length&&4===i.length&&1===r.length&&1===a.length&&1===l.length&&1===s.length&&3===u.length&&5===c.length&&3===g.length&&1===d.length&&1===h.length&&1===p.length&&1===f.length&&1===m.length&&1===y.length&&1===T.length&&7===_.length&&1===b.length&&1===k.length&&1===x.length&&1===E.length&&2===B.length&&1===A.length&&1===v.length&&1===I.length&&1===w.length&&1===S.length&&3===M.length&&1===N.length&&1===L.length&&1===O.length&&1===C.length&&2===R.length&&1===F.length&&1===P.length&&1===V.length&&1===G.length&&1===U.length&&1===X.length&&1===j.length&&1===D.length&&1===W.length}),new s((function(){for(var e=o.getAllBlocks(!0),t=e.filter((function(e){return"t2c_text_getsubstring"===e.type||"js_text_getsubstring"===e.type})).map((function(e){return e.getInputTargetBlock("STRING")})).filter((function(e){return e&&"text"===e.type})),n=e.filter((function(e){return"t2c_text_join"===e.type||"text_join"===e.type})).map((function(e){return e.getInputTargetBlock("B")})).filter((function(e){return e&&("t2c_text_join"===e.type||"text_join"===e.type)})).map((function(e){return e.getInputTargetBlock("A")})).filter((function(e){return e&&"text"===e.type})),i=e.filter((function(e){return"t2c_text_getsubstring"===e.type||"js_text_getsubstring"===e.type})).map((function(e){return e.getInputTargetBlock("AT1")})).filter((function(e){return e&&"math_arithmetic_basic"===e.type})).map((function(e){return e.getInputTargetBlock("A")})).find((function(e){return e&&"math_number"===e.type})),r=e.filter((function(e){return"t2c_text_getsubstring"===e.type||"js_text_getsubstring"===e.type})).map((function(e){return e.getInputTargetBlock("AT2")})).filter((function(e){return e&&"math_arithmetic_basic"===e.type})).map((function(e){return e.getInputTargetBlock("A")})).find((function(e){return e&&"math_number"===e.type})),a=e.filter((function(e){return"t2c_text_join"===e.type||"text_join"===e.type})).map((function(e){return e.getInputTargetBlock("B")})).filter((function(e){return e&&("t2c_text_getsubstring"===e.type||"js_text_getsubstring"===e.type)})).map((function(e){return e.getInputTargetBlock("AT2")})).filter((function(e){return e&&"math_number"===e.type})),l=e.filter((function(e){return"t2c_text_join"===e.type||"text_join"===e.type})).map((function(e){return e.getInputTargetBlock("A")})).filter((function(e){return e&&("t2c_text_getsubstring"===e.type||"js_text_getsubstring"===e.type)})).map((function(e){return e.getInputTargetBlock("AT1")})).find((function(e){return e&&"math_number"===e.type})),s=e.filter((function(e){return"t2c_text_join"===e.type||"text_join"===e.type})).map((function(e){return e.getInputTargetBlock("A")})).filter((function(e){return e&&("t2c_text_getsubstring"===e.type||"js_text_getsubstring"===e.type)})).map((function(e){return e.getInputTargetBlock("AT2")})).find((function(e){return e&&"math_number"===e.type})),u=e.filter((function(e){return("t2c_text_join"===e.type||"text_join"===e.type)&&e.getParent()&&("text_print"===e.getParent().type||"js_text_print"===e.getParent().type)})).map((function(e){return e.getInputTargetBlock("A")})).find((function(e){return e&&"text"===e.type})),c=e.filter((function(e){return"t2c_text_join"===e.type||"text_join"===e.type})).map((function(e){return e.getInputTargetBlock("B")})).filter((function(e){return e&&("t2c_text_join"===e.type||"text_join"===e.type)})).map((function(e){return e.getInputTargetBlock("B")})).find((function(e){return e&&"text"===e.type})),g=e.find((function(e){return"text"===e.type&&e.getParent()&&("text_print"===e.getParent().type||"js_text_print"===e.getParent().type)})),d="Where is the code?",h=d.indexOf(" is "),p=0;p<=1;p++){var f=t[p];if(f&&f.getFieldValue("TEXT")&&f.getFieldValue("TEXT")!==d)return"The text before the "+(0===p?"first ":"second ")+T2C.MSG.currentLanguage.TERMINAL_GETTEXTFROMPOSITIONNUMBER+" on line 7 is incorrect. Substitute question with the value that it's initially assigned to."}for(var m=0;m<=2;m++){var y=n[m];if(y&&y.getFieldValue("TEXT")&&" is "!==y.getFieldValue("TEXT"))return"The text after the first + (for string concatenation, NOT numbers) on line "+(m+6)+" is incorrect. Substitute needle with the value that it's initially assigned to (*including* a single space at the beginning *and* end)."}if(i&&i.getFieldValue("NUM")&&i.getFieldValue("NUM")!==h)return"The first number on line 6 (in the addition block) is incorrect. It should be the substitution of "+T2C.MSG.currentLanguage.TERMINAL_FINDFIRSTOCCURRENCEOFTEXT+", which will be the *starting* position of the first occurrence of the value of needle. Fix it accordingly.";if(r&&r.getFieldValue("NUM")&&r.getFieldValue("NUM")!==d.length)return"The third number on line 6 (in the subtraction block) should be the length of the value of question. Fix it accordingly.";for(var T=0;T<=1;T++){var _=a[T];if(_&&_.getFieldValue("NUM")&&_.getFieldValue("NUM")!==h)return"The last number on line "+(T+6)+" is incorrect. It should be the substitution of "+T2C.MSG.currentLanguage.TERMINAL_FINDFIRSTOCCURRENCEOFTEXT+", which will be the *starting* position of the first occurrence of the value of needle. Fix it accordingly."}return i&&i.getFieldValue("NUM")&&i.getFieldValue("NUM")===h&&l&&l.getFieldValue("NUM")&&l.getFieldValue("NUM")!==h+4?"The first number on line 7 should be the result of the addition with 4 from the previous line. Fix it accordingly.":r&&r.getFieldValue("NUM")&&r.getFieldValue("NUM")===d.length&&s&&s.getFieldValue("NUM")&&s.getFieldValue("NUM")!==d.length-1?"The second number on line 7 should be the result of the subtraction by 1 from the previous line. Fix it accordingly.":i&&i.getFieldValue("NUM")&&i.getFieldValue("NUM")===h&&l&&l.getFieldValue("NUM")&&l.getFieldValue("NUM")===h+4&&r&&r.getFieldValue("NUM")&&r.getFieldValue("NUM")===d.length&&s&&s.getFieldValue("NUM")&&s.getFieldValue("NUM")===d.length-1&&u&&u.getFieldValue("TEXT")&&u.getFieldValue("TEXT")!==d.substring(h+4,d.length-1)?"The first string on line 8 (before the text concatenation +) should be the result of the substitution of the first "+T2C.MSG.currentLanguage.TERMINAL_GETTEXTFROMPOSITIONNUMBER+". Fix it accordingly.":a[1]&&a[1].getFieldValue("NUM")&&a[1].getFieldValue("NUM")===h&&c&&c.getFieldValue("TEXT")&&c.getFieldValue("TEXT")!==d.substring(1,h)?"The last string on line 8 (after both text concatenation +) should be the result of the substitution of the second "+T2C.MSG.currentLanguage.TERMINAL_GETTEXTFROMPOSITIONNUMBER+". Fix it accordingly.":u&&u.getFieldValue("TEXT")&&u.getFieldValue("TEXT")===d.substring(h+4,d.length-1)&&n[2]&&n[2].getFieldValue("TEXT")&&" is "===n[2].getFieldValue("TEXT")&&c&&c.getFieldValue("TEXT")&&c.getFieldValue("TEXT")===d.substring(1,h)&&g&&g.getFieldValue("TEXT")&&g.getFieldValue("TEXT")!==d.substring(h+4,d.length-1)+" is "+d.substring(1,h)?"The string on the last line is incorrect; it should be the result of the substitution of the concatenation of the three strings above it on line 8.":"Replace all the blank string literals and 0's with the appropriate text and numbers that are substituted as the computer would from top to bottom so that every line of output is the same. Try to do this without running the program until you get the message to do so (when you filled in everything correctly)."}),{startPosition:te(o,null,{},50,document.getElementById("top-header").offsetHeight+50)}))),d(n),h(n,document.getElementById("output-container").querySelectorAll(".table-cell")[0]),n.addTask(new r((function(){return!0}),{start:function(){return!0},isComplete:function(){return!0},animate:function(){return!0},finish:function(){alert('👍 Bahut badhiya (Hindi for Very nice or Awesome)! Just as reading more books can make you a better writer, reading through code excerpts and "tracing" code as the computer does will make you a better code writer! It will also make you better at finding errors or bugs.\nIn the rest of this mission, you will get all of the text between the @ and the . in an e-mail address. As a warm-up exercise, you\'ll get everything after the @ to start.'),z(document.getElementById("output-container").querySelectorAll(".table-cell")[0]),K(),o.clear(),a.clearToolbox(),a.createToolboxBlock("type_in_get_email_input"),o.options.maxInstances.type_in_get_email_input=1}})),n.addTask(new r((function(){var e=o.getAllBlocks().find((function(e){return"text"===e.type&&(-1!==(e.getFieldValue("TEXT")||"").toLowerCase().indexOf("email")||-1!==(e.getFieldValue("TEXT")||"").toLowerCase().indexOf("e-mail"))})),t=o.getAllBlocks().find((function(t){return("text_input"===t.type||"js_text_input"===t.type)&&t.getInputTargetBlock("TEXT")===e})),n=o.getAllBlocks().find((function(e){return"variables_set"===e.type&&null===e.getNextBlock()&&e.getInputTargetBlock("VALUE")===t&&"email"===e.getField("VAR").getText()}));return e&&t&&n}),new s((function(){return"So now let's start applying these ideas to get the text appearing between the first @ and . in an e-mail address (e.g., google from coolcoder@google.com or mail from expertsoftwareengineer@mail.co.uk). First, let's ask the user for an e-mail address and store it in a variable email. Drag in the type-in-code block and type in the necessary code."}),{startPosition:te(o,null,{},50,document.getElementById("top-header").offsetHeight+50)}))),n.addTask(new r((function(){return!0}),{start:function(){return!0},isComplete:function(){return!0},animate:function(){return!0},finish:function(){var e=[1,1,1,2,1,1,1,1],t=o.getAllBlocks().find((function(e){return"variables_set"===e.type}));a.clearToolbox(),["t2c_text_getsubstring","t2c_text_length","text_print","variables_get","math_number","text","text_input","variables_set"].forEach((function(t,n){a.createToolboxBlock(t,!1),o.options.maxInstances[t]=e[n]})),t&&t.setCollapsed(!0),alert("✔ Nice, so as a warm-up and review, let's start by displaying everything that appears *after* the @ in any e-mail address where the text before the @ is exactly 9 characters, such as coolcoder@gmail.com using the "+T2C.MSG.currentLanguage.TERMINAL_GETTEXTFROMPOSITIONNUMBER+" and "+T2C.MSG.currentLanguage.TERMINAL_LENGTH+" blocks. We'll use a specific number for the starting position so it can't work in general, but we'll fix that soon by adding the new "+T2C.MSG.currentLanguage.TERMINAL_FINDFIRSTOCCURRENCEOFTEXT+" block.")}})),n.addTask(new r((function(){var e=o.getAllBlocks().filter((function(e){return"variables_get"===e.type&&"email"===e.getField("VAR").getText()})),t=o.getAllBlocks().find((function(t){return"t2c_text_length"===t.type&&-1!==e.indexOf(t.getInputTargetBlock("VALUE"))})),n=o.getAllBlocks().find((function(e){return"math_number"===e.type&&10===e.getFieldValue("NUM")})),i=o.getAllBlocks().find((function(o){return("t2c_text_getsubstring"===o.type||"js_text_getsubstring"===o.type)&&-1!==e.indexOf(o.getInputTargetBlock("STRING"))&&o.getInputTargetBlock("AT1")===n&&o.getInputTargetBlock("AT2")===t})),r=o.getAllBlocks().find((function(e){return("text_print"===e.type||"js_text_print"===e.type)&&null===e.getNextBlock()&&e.getInputTargetBlock("TEXT")===i})),a=o.getAllBlocks().find((function(e){return"text"===e.type&&(-1!==(e.getFieldValue("TEXT")||"").toLowerCase().indexOf("email")||-1!==(e.getFieldValue("TEXT")||"").toLowerCase().indexOf("e-mail"))})),l=o.getAllBlocks().find((function(e){return("text_input"===e.type||"js_text_input"===e.type)&&e.getInputTargetBlock("TEXT")===a})),s=o.getAllBlocks().find((function(e){return"variables_set"===e.type&&e.getNextBlock()===r&&e.getInputTargetBlock("VALUE")===l&&"email"===e.getField("VAR").getText()}));return 2===e.length&&t&&n&&i&&r&&a&&l&&s}),new s((function(){var e=o.getAllBlocks().find((function(e){return"text"===e.type&&(-1!==(e.getFieldValue("TEXT")||"").toLowerCase().indexOf("email")||-1!==(e.getFieldValue("TEXT")||"").toLowerCase().indexOf("e-mail"))})),t=o.getAllBlocks().find((function(t){return("text_input"===t.type||"js_text_input"===t.type)&&t.getInputTargetBlock("TEXT")===e})),n=o.getAllBlocks().find((function(e){return"variables_set"===e.type&&e.getInputTargetBlock("VALUE")===t&&"email"===e.getField("VAR").getText()})),i=o.getAllBlocks().filter((function(e){return"variables_get"===e.type})),r=o.getAllBlocks().find((function(e){return"t2c_text_length"===e.type})),a=o.getAllBlocks().find((function(e){return"math_number"===e.type})),l=o.getAllBlocks().find((function(e){return"t2c_text_getsubstring"===e.type||"js_text_getsubstring"===e.type})),s=o.getAllBlocks().find((function(e){return"text_print"===e.type||"js_text_print"===e.type}));if(i.find((function(e){return"email"!==e.getField("VAR").getText()})))return"Make sure the variable get blocks are both set to email so they refer to the one storing the entered e-mail.";if(n&&"email"!==n.getField("VAR").getText())return"Make sure the name of the variable storing the user's input stays email.";if(l){if(-1!==i.indexOf(l.getInputTargetBlock("AT1")))return"You placed the email block in the starting position of the "+T2C.MSG.currentLanguage.TERMINAL_GETTEXTFROMPOSITIONNUMBER+" block. But email stores a string, not a number; what would it mean to start extracting text at position *NUMBER* coolcoder@gmail.com?";if(-1!==i.indexOf(l.getInputTargetBlock("AT2")))return"You placed the email block in the ending position of the "+T2C.MSG.currentLanguage.TERMINAL_GETTEXTFROMPOSITIONNUMBER+" block. But email stores a string, not a number; what would it mean to stop extracting text at position *NUMBER* coolcoder@gmail.com?";if(r&&l.getInputTargetBlock("AT1")===r)return"You placed the "+T2C.MSG.currentLanguage.TERMINAL_LENGTH+" block in the starting position of the "+T2C.MSG.currentLanguage.TERMINAL_GETTEXTFROMPOSITIONNUMBER+" block. But for say coolcoder@gmail.com, the last position is at "+("coolcoder@gmail.com".length-1).toString()+" and its length is "+"coolcoder@gmail.com".length+". You certainly don't want to start extracting text at position 19, which doesn't even exist!";if(a&&l.getInputTargetBlock("AT2")===a)return"You cannot use a *specific* number for the ending position if you don't know how long the e-mail address is. Change the block in the last position of the "+T2C.MSG.currentLanguage.TERMINAL_GETTEXTFROMPOSITIONNUMBER+" block, accordingly.";if(a&&l.getInputTargetBlock("AT1")===a){var u=a.getFieldValue("NUM");if(11===u)return"The given starting position is incorrect. Remember that the initial character starts at position (index) 0 and unlike the given ending position to "+T2C.MSG.currentLanguage.TERMINAL_GETTEXTFROMPOSITIONNUMBER+", the computer starts extracting text from the first position number you give it.";if(9===u)return"The given starting position is incorrect. Remember that you want to start extracting text *after* the @ and unlike the given ending position to "+T2C.MSG.currentLanguage.TERMINAL_GETTEXTFROMPOSITIONNUMBER+", the computer starts extracting text from the first position number you give it.";if(u==="coolcoder@gmail.com".length)return"The first number given to "+T2C.MSG.currentLanguage.TERMINAL_GETTEXTFROMPOSITIONNUMBER+" is the starting position, not the ending one.";if(10!==u)return"Incorrect number for the starting position. Please try recounting the characters from the beginning of the string, starting from 0 until you get to the character after the @ sign."}}return s&&l&&s.getInputTargetBlock("TEXT")!==l?"As with the last exercise, you'll want to show a substring of the e-mail so the "+T2C.MSG.currentLanguage.TERMINAL_GETTEXTFROMPOSITIONNUMBER+" should be placed in "+T2C.MSG.currentLanguage.TERMINAL_DISPLAY+".":s&&n&&s.getNextBlock()===n?"Since instructions are run from top to bottom, you can't display a substring of email before the user enters it!":s&&null===s.getPreviousBlock()?"Be sure to attach the "+T2C.MSG.currentLanguage.TERMINAL_DISPLAY+" block below the "+T2C.MSG.currentLanguage.TERMINAL_LET+" block.":"Drag in and assemble the blocks of code so that the computer displays everything that appears *after* the @ in any entered e-mail address where the text before the @ is exactly 9 characters, such as coolcoder@gmail.com using the "+T2C.MSG.currentLanguage.TERMINAL_GETTEXTFROMPOSITIONNUMBER+" and "+T2C.MSG.currentLanguage.TERMINAL_LENGTH+" blocks. For this part, use a specific number for the starting position."}),{startPosition:te(o,null,{},50,document.getElementById("top-header").offsetHeight+50)}))),d(n),h(n,document.getElementById("output-container").querySelectorAll(".table-cell")[0]),n.addTask(new r((function(){return!0}),{start:function(){return!0},isComplete:function(){return!0},animate:function(){return!0},finish:function(){var e=[1,1,2,3,1,1,1,1,1,1],t=o.getAllBlocks().filter((function(e){return"variables_get"===e.type||"t2c_text_length"===e.type}));alert("✔ Good, so did you type in coolcoder@google.com or some other e-mail address with 9 characters before the @, or did you enjoy breaking the rules and watching it fail?!! Well, now it's time to make it work for those troublemakers so long as they're kind enough to enter an @.\nTo do this, we'll use our new "+T2C.MSG.currentLanguage.TERMINAL_FINDFIRSTOCCURRENCEOFTEXT+" and will need some arithmetic as well."),z(document.getElementById("output-container").querySelectorAll(".table-cell")[0]),K(),a.clearToolbox(),["t2c_text_indexof","math_arithmetic_basic","text","variables_get","math_number","t2c_text_getsubstring","t2c_text_length","text_print","text_input","variables_set"].forEach((function(t,n){a.createToolboxBlock(t,!1),o.options.maxInstances[t]=e[n]})),t.forEach((function(e){return e.setCollapsed(!0)}))}})),n.addTask(new r((function(){var e=o.getAllBlocks().filter((function(e){return"variables_get"===e.type&&"email"===e.getField("VAR").getText()})),t=o.getAllBlocks().find((function(t){return"t2c_text_length"===t.type&&-1!==e.indexOf(t.getInputTargetBlock("VALUE"))})),n=o.getAllBlocks().find((function(e){return"math_number"===e.type&&1===e.getFieldValue("NUM")})),i=o.getAllBlocks().find((function(e){return"text"===e.type&&"@"==e.getFieldValue("TEXT")})),r=o.getAllBlocks().find((function(t){return("t2c_text_indexof"===t.type||"js_text_indexof"===t.type)&&-1!==e.indexOf(t.getInputTargetBlock("VALUE"))&&t.getInputTargetBlock("FIND")===i})),a=o.getAllBlocks().find((function(e){return"math_arithmetic_basic"===e.type&&(e.getInputTargetBlock("A")===r&&e.getInputTargetBlock("B")===n||e.getInputTargetBlock("B")===r&&e.getInputTargetBlock("A")===n)&&"ADD"==e.getFieldValue("OP")})),l=o.getAllBlocks().find((function(n){return("t2c_text_getsubstring"===n.type||"js_text_getsubstring"===n.type)&&-1!==e.indexOf(n.getInputTargetBlock("STRING"))&&n.getInputTargetBlock("AT1")===a&&n.getInputTargetBlock("AT2")===t})),s=o.getAllBlocks().find((function(e){return("text_print"===e.type||"js_text_print"===e.type)&&null===e.getNextBlock()&&e.getInputTargetBlock("TEXT")===l})),u=o.getAllBlocks().find((function(e){return"text"===e.type&&(-1!==(e.getFieldValue("TEXT")||"").toLowerCase().indexOf("email")||-1!==(e.getFieldValue("TEXT")||"").toLowerCase().indexOf("e-mail"))})),c=o.getAllBlocks().find((function(e){return("text_input"===e.type||"js_text_input"===e.type)&&e.getInputTargetBlock("TEXT")===u})),g=o.getAllBlocks().find((function(e){return"variables_set"===e.type&&e.getNextBlock()===s&&e.getInputTargetBlock("VALUE")===c&&"email"===e.getField("VAR").getText()}));return 3===e.length&&t&&n&&i&&r&&a&&l&&s&&u&&c&&g}),new s((function(){var e=o.getAllBlocks().find((function(e){return"text"===e.type&&(-1!==(e.getFieldValue("TEXT")||"").toLowerCase().indexOf("email")||-1!==(e.getFieldValue("TEXT")||"").toLowerCase().indexOf("e-mail"))})),t=o.getAllBlocks().find((function(t){return("text_input"===t.type||"js_text_input"===t.type)&&t.getInputTargetBlock("TEXT")===e})),n=o.getAllBlocks().find((function(e){return"variables_set"===e.type&&e.getInputTargetBlock("VALUE")===t&&"email"===e.getField("VAR").getText()})),i=o.getAllBlocks().filter((function(e){return"variables_get"===e.type})),r=o.getAllBlocks().find((function(e){return"t2c_text_length"===e.type})),a=o.getAllBlocks().find((function(e){return"math_number"===e.type})),l=o.getAllBlocks().find((function(t){return"text"===t.type&&t!==e})),s=o.getAllBlocks().find((function(e){return"t2c_text_indexof"===e.type||"js_text_indexof"===e.type})),u=o.getAllBlocks().find((function(e){return"math_arithmetic_basic"===e.type})),c=o.getAllBlocks().find((function(e){return"t2c_text_getsubstring"===e.type||"js_text_getsubstring"===e.type})),g=o.getAllBlocks().find((function(e){return"text_print"===e.type||"js_text_print"===e.type})),d="coolcoder@gmail.com";if(s){if(l&&s.getInputTargetBlock("VALUE")===l)return"The first space in the "+T2C.MSG.currentLanguage.TERMINAL_FINDFIRSTOCCURRENCEOFTEXT+" block is for the string you want to search through (proverbial haystack), not the string you're looking for (proverbial needle) so you'll want to move the text block, accordingly.";if(-1!==i.indexOf(s.getInputTargetBlock("FIND")))return"The second space in the "+T2C.MSG.currentLanguage.TERMINAL_FINDFIRSTOCCURRENCEOFTEXT+" block is for the string you're looking for (proverbial needle), not the one you want to search through (proverbial haystack) so you'll want to move the variable get block, accordingly.";if(l&&s.getInputTargetBlock("FIND")===l){var h=l.getFieldValue("TEXT")||"";if(""===h)return"Type in something the text (needle) you're searching for in the block with quotes";if("."===h)return"You don't know how many characters there may be before the period after the at sign as this can depend on the e-mail address so this won't work for calculating the starting position.";if("at"===h.toLowerCase())return"The literal 2-character string "+h.toLowerCase()+" will not necessarily appear in the address. You don't need to use letters for the needle (string your searching for); you can use symbols as well.";if("@"!==h)return"It's possible that "+h+" won't necessarily appear in an e-mail address, or at least it won't help you calculate the desired starting position. Try something else.";if(c&&c.getInputTargetBlock("AT1")===s)return"You'll need to perform a math operation on the position number of the @ since if you start extracting text at the position of the @, the string you get back will always start with an @! For example, for "+d+", you'd start extracting text at position "+d.indexOf("@")+", which means you'd get "+d.substring(d.indexOf("@"))+". What do you do with this number if you'd want to start at position number "+(d.indexOf("@")+1).toString()+", the position of the "+d.charAt(d.indexOf("@")+1)+" immediately after the @ instead?"}}if(u){if(i.find((function(e){return e===u.getInputTargetBlock("A")||e===u.getInputTargetBlock("B")})))return"The variable email holds a string such as "+d+", not a number so what would it mean to perform a math operation on it? Remove it from the arithmetic block, accordingly.";if(s&&a&&(u.getInputTargetBlock("A")===s&&u.getInputTargetBlock("B")===a||u.getInputTargetBlock("B")===s&&u.getInputTargetBlock("A")===a)){var p=a.getFieldValue("NUM"),f=u.getFieldValue("OP");if(u.getInputTargetBlock("B")===a&&"MINUS"===f&&-1===p)return"Although you can subtract -1, it's clearer to add 1 so switch the operation to addition and the number from -1 to 1.";if(u.getInputTargetBlock("B")===a&&"MINUS"===f&&1===p)return"Subtracting 1 from the answer will move your position back one. Do you want to start extracting text 1 place before?";if("ADD"!==f||1!==p)return"Using your given operation and number, the starting position you're calculating does not seem to work for every e-mail address in general. Try (re)examining some e-mail addresses and the specific starting positions of the calculations for these examples to help you see your error."}}if(i.find((function(e){return"email"!==e.getField("VAR").getText()})))return"Make sure the variable get blocks are all set to email so they refer to the one storing the entered e-mail.";if(n&&"email"!==n.getField("VAR").getText())return"Make sure the name of the variable storing the user's input stays email.";if(c){if(-1!==i.indexOf(c.getInputTargetBlock("AT1")))return"You placed the email block in the starting position of the "+T2C.MSG.currentLanguage.TERMINAL_GETTEXTFROMPOSITIONNUMBER+" block. But email stores a string, not a number; what would it mean to start extracting text at position *NUMBER* coolcoder@gmail.com?";if(-1!==i.indexOf(c.getInputTargetBlock("AT2")))return"You placed the email block in the ending position of the "+T2C.MSG.currentLanguage.TERMINAL_GETTEXTFROMPOSITIONNUMBER+" block. But email stores a string, not a number; what would it mean to stop extracting text at position *NUMBER* coolcoder@gmail.com?";if(r&&c.getInputTargetBlock("AT1")===r)return"You placed the "+T2C.MSG.currentLanguage.TERMINAL_LENGTH+" block in the starting position of the "+T2C.MSG.currentLanguage.TERMINAL_GETTEXTFROMPOSITIONNUMBER+" block. But for say "+d+", the last position is at "+(d.length-1).toString()+" and its length is "+d.length+". You certainly don't want to start extracting text at position 19, which doesn't even exist!";if(a&&c.getInputTargetBlock("AT2")===a)return"You cannot use a *specific* number for the ending position if you don't know how long the e-mail address is. Change the block in the last position of the "+T2C.MSG.currentLanguage.TERMINAL_GETTEXTFROMPOSITIONNUMBER+" block, accordingly."}return g&&c&&g.getInputTargetBlock("TEXT")!==c?"As with the last exercise, you'll want to show a substring of the e-mail so the "+T2C.MSG.currentLanguage.TERMINAL_GETTEXTFROMPOSITIONNUMBER+" should be placed in "+T2C.MSG.currentLanguage.TERMINAL_DISPLAY+".":g&&n&&g.getNextBlock()===n?"Since instructions are run from top to bottom, you can't display a substring of email before the user enters it!":g&&null===g.getPreviousBlock()?"Be sure to attach the "+T2C.MSG.currentLanguage.TERMINAL_DISPLAY+" block below the "+T2C.MSG.currentLanguage.TERMINAL_LET+" block.":"Use the new "+T2C.MSG.currentLanguage.TERMINAL_FINDFIRSTOCCURRENCEOFTEXT+" and arithmetic blocks in the place of the starting position of the specific number 10 you currently have in the "+T2C.MSG.currentLanguage.TERMINAL_GETTEXTFROMPOSITIONNUMBER+" block so that the computer displays everything that appears *after* the @ in any entered e-mail address, regardless of how long the text is before the @.\nHINT: If you didn't know what email was but you were able to ask for the position number of whatever character(s) you want, what position would you ask for? Once you had that position, what math operation would you use to get the starting position of the string after the @? Make sure your calculations work on coolcoder@google.com, jdoe@foo.edu, or any other e-mail address!"}),{startPosition:te(o,null,{},50,document.getElementById("top-header").offsetHeight+50)}))),d(n),h(n,document.getElementById("output-container").querySelectorAll(".table-cell")[0]),n.addTask(new r((function(){return!0}),{start:function(){return!0},isComplete:function(){return!0},animate:function(){return!0},finish:function(){var e=[1,1,1,2,3,1,1,1,1,1,1],t=o.getAllBlocks().filter((function(e){return"text_print"===e.type||"js_text_print"===e.type}));alert("✔ Great work! So now let's return to the original task, to get the text between the first @ and the first ., e.g., the google in coolcoder@google.com or the mail in expertsoftwareengineer@mail.co.uk. To simplify, we'll assume the first . always follows the first @, which may not always be the case in an e-mail address (e.g., jane.doe@gmail.com). So are you up to the task of typing it all in! You'll use two "+T2C.MSG.currentLanguage.TERMINAL_FINDFIRSTOCCURRENCEOFTEXT+" this time."),K(),a.clearToolbox(),["type_in_between_at_and_period","t2c_text_indexof","math_arithmetic_basic","text","variables_get","math_number","t2c_text_getsubstring","t2c_text_length","text_print","text_input","variables_set"].forEach((function(t,n){a.createToolboxBlock(t,!1),o.options.maxInstances[t]=e[n]})),t.forEach((function(e){return e.setCollapsed(!0)}))}})),n.addTask(new r((function(){var e=o.getAllBlocks().filter((function(e){return"variables_get"===e.type&&"email"===e.getField("VAR").getText()})),t=o.getAllBlocks().find((function(t){return"t2c_text_length"===t.type&&-1!==e.indexOf(t.getInputTargetBlock("VALUE"))})),n=o.getAllBlocks().filter((function(e){return"math_number"===e.type&&1===e.getFieldValue("NUM")})),i=o.getAllBlocks().filter((function(e){return"text"===e.type&&"@"==e.getFieldValue("TEXT")})),r=o.getAllBlocks().filter((function(t){return("t2c_text_indexof"===t.type||"js_text_indexof"===t.type)&&-1!==e.indexOf(t.getInputTargetBlock("VALUE"))&&-1!==i.indexOf(t.getInputTargetBlock("FIND"))})),a=o.getAllBlocks().filter((function(e){return"math_arithmetic_basic"===e.type&&(-1!==r.indexOf(e.getInputTargetBlock("A"))&&-1!==n.indexOf(e.getInputTargetBlock("B"))||-1!==r.indexOf(e.getInputTargetBlock("B"))&&e.getInputTargetBlock("A")===n)&&"ADD"==e.getFieldValue("OP")})),l=o.getAllBlocks().find((function(n){return("t2c_text_getsubstring"===n.type||"js_text_getsubstring"===n.type)&&-1!==e.indexOf(n.getInputTargetBlock("STRING"))&&-1!==a.indexOf(n.getInputTargetBlock("AT1"))&&n.getInputTargetBlock("AT2")===t})),s=o.getAllBlocks().find((function(e){return("text_print"===e.type||"js_text_print"===e.type)&&null!==e.getPreviousBlock()&&e.getInputTargetBlock("TEXT")===l})),u=o.getAllBlocks().find((function(e){return"text"===e.type&&(-1!==(e.getFieldValue("TEXT")||"").toLowerCase().indexOf("email")||-1!==(e.getFieldValue("TEXT")||"").toLowerCase().indexOf("e-mail"))})),c=o.getAllBlocks().find((function(e){return("text_input"===e.type||"js_text_input"===e.type)&&e.getInputTargetBlock("TEXT")===u})),g=o.getAllBlocks().find((function(e){return"variables_set"===e.type&&e.getNextBlock()===s&&e.getInputTargetBlock("VALUE")===c&&"email"===e.getField("VAR").getText()})),d=o.getAllBlocks().find((function(e){return"text"===e.type&&"."==e.getFieldValue("TEXT")})),h=o.getAllBlocks().find((function(t){return("t2c_text_indexof"===t.type||"js_text_indexof"===t.type)&&-1!==e.indexOf(t.getInputTargetBlock("VALUE"))&&t.getInputTargetBlock("FIND")===d})),p=o.getAllBlocks().find((function(t){return("t2c_text_getsubstring"===t.type||"js_text_getsubstring"===t.type)&&-1!==e.indexOf(t.getInputTargetBlock("STRING"))&&-1!==a.indexOf(t.getInputTargetBlock("AT1"))&&t.getInputTargetBlock("AT2")===h})),f=o.getAllBlocks().find((function(e){return"text_print"===e.type&&e.getPreviousBlock()===s&&e.getInputTargetBlock("TEXT")===p}));return 6===e.length&&t&&2===n.length&&2===i.length&&2===r.length&&2===a.length&&l&&s&&u&&c&&g&&d&&h&&p&&f}),new s((function(){var e=o.getAllBlocks().find((function(e){return"text"===e.type&&(-1!==(e.getFieldValue("TEXT")||"").toLowerCase().indexOf("email")||-1!==(e.getFieldValue("TEXT")||"").toLowerCase().indexOf("e-mail"))})),t=o.getAllBlocks().find((function(t){return("text_input"===t.type||"js_text_input"===t.type)&&t.getInputTargetBlock("TEXT")===e})),n=o.getAllBlocks().find((function(e){return"variables_set"===e.type&&e.getInputTargetBlock("VALUE")===t&&"email"===e.getField("VAR").getText()})),i=o.getAllBlocks().filter((function(e){return"variables_get"===e.type})),r=(o.getAllBlocks().find((function(e){return"t2c_text_length"===e.type})),o.getAllBlocks().find((function(e){return"math_number"===e.type})),o.getAllBlocks().find((function(t){return"text"===t.type&&t!==e})),o.getAllBlocks().find((function(e){return"t2c_text_indexof"===e.type||"js_text_indexof"===e.type})),o.getAllBlocks().filter((function(e){return"math_arithmetic_basic"===e.type}))),a=(o.getAllBlocks().find((function(e){return"t2c_text_getsubstring"===e.type||"js_text_getsubstring"===e.type})),o.getAllBlocks().find((function(e){return"text_print"===e.type||"js_text_print"===e.type}))),l=o.getAllBlocks().find((function(e){return"text"===e.type&&"."==e.getFieldValue("TEXT")})),s=o.getAllBlocks().find((function(e){return("t2c_text_indexof"===e.type||"js_text_indexof"===e.type)&&-1!==i.indexOf(e.getInputTargetBlock("VALUE"))&&e.getInputTargetBlock("FIND")===l})),u=o.getAllBlocks().find((function(e){return("t2c_text_getsubstring"===e.type||"js_text_getsubstring"===e.type)&&-1!==i.indexOf(e.getInputTargetBlock("STRING"))&&-1!==r.indexOf(e.getInputTargetBlock("AT1"))&&e.getInputTargetBlock("AT2")===s})),c=o.getAllBlocks().find((function(e){return"text_print"===e.type&&e.getInputTargetBlock("TEXT")===u}));return c&&n&&c.getNextBlock()===n?"Since instructions are run from top to bottom, you can't display a substring of email before the user enters it!":c&&null===a.getPreviousBlock()?"Be sure to attach the "+T2C.MSG.currentLanguage.TERMINAL_DISPLAY+" block below the previous "+T2C.MSG.currentLanguage.TERMINAL_DISPLAY+" block.":"Drag the type-in-code block, and attach it to the below the previously assembled "+T2C.MSG.currentLanguage.TERMINAL_DISPLAY+" block. Then type the necessary code to get the text between the first @ and the first ., e.g., the google in coolcoder@google.com or the mail in expertsoftwareengineer@mail.co.uk. HINT: Use "+T2C.MSG.currentLanguage.TERMINAL_GETTEXTFROMPOSITIONNUMBER+" as you did before, but consider how you'd use a second "+T2C.MSG.currentLanguage.TERMINAL_FINDFIRSTOCCURRENCEOFTEXT+" to *stop* at the correct position number this time as you'd no longer use "+T2C.MSG.currentLanguage.TERMINAL_LENGTH+" since you don't want to stop at the end. As before, make sure your calculations simultaneously work on coolcoder@google.com (start #: 10, end before #: 16), expertsoftwareengineer@mail.co.uk (start #: 23, end before #: 27), and jdoe@foo.edu (start #: 5, end before #: 8), or any other e-mail address by substituting as you did at the beginning."}),{startPosition:te(o,null,{},50,document.getElementById("top-header").offsetHeight+50)}))),d(n),h(n,document.getElementById("output-container").querySelectorAll(".table-cell")[0]),n.addTask(new r((function(){return!0}),{start:function(){return!0},isComplete:function(){return!0},animate:function(){return!0},finish:function(){alert("✔✔✔ Outstanding! And with that, Mission # 5 is accomplished! In the next mission, we'll take an input of last name, first name and display it as first name last name. E.g., Doe, Jane would result in Jane Doe. No new blocks next time, just more challenges with the existing ones! Until next time!"),K(),a.clearToolbox(),["code_statement"].forEach((function(e,t){a.createToolboxBlock(e,!1),o.options.maxInstances[e]=maxBlocks[t]}))}})),n},function(e,t){var n=e||new c,o=t||Blockly.getMainWorkspace(),a=new f(o);o.setScale(1),Object(i.f)(o);var g=document.createElement("div");return g.innerText="👆",g.id="ptr",g.style.fontSize="x-large",g.style.position="absolute",g.style.zIndex="1001",document.getElementById("blockly-div").appendChild(g),n.addTask(new r((function(){return!0}),{start:function(){return!0},isComplete:function(){return!0},animate:function(){return!0},finish:function(){alert("In this mission, we'll take an input of last name, first name and display it as first name last name. E.g., Doe, Jane would result in Jane Doe. To remember how we can use the blocks we'll need for this task, let's redo the last code tracing exercise from the last mission."),o.clear(),Blockly.Xml.domToWorkspace(Blockly.Xml.textToDom('questionneedlepart1part2questionWhere is the code?needle is part1questionADDquestionneedle4MINUSquestion1part2question1questionneedlepart1needlepart2questionADD04MINUS01question100010'),o),Blockly.svgResize(o),o.getAllBlocks().forEach((function(e){return e.setMovable(!1)})),oe(document.getElementById("output-container").querySelectorAll(".table-cell")[0]),ie()}})),n.addTask(new r((function(){var e=o.getAllBlocks().filter((function(e){return"text"===e.type&&"the code is here"==e.getFieldValue("TEXT")})),t=o.getAllBlocks().filter((function(t){return"text_print"===t.type&&null===t.getNextBlock()&&-1!==e.indexOf(t.getInputTargetBlock("TEXT"))})),n=o.getAllBlocks().filter((function(e){return"text"===e.type&&"here"==e.getFieldValue("TEXT")})),i=o.getAllBlocks().filter((function(e){return"text"===e.type&&" is "==e.getFieldValue("TEXT")})),r=o.getAllBlocks().filter((function(e){return"t2c_text_join"===e.type&&-1!==i.indexOf(e.getInputTargetBlock("A"))&&-1!==n.indexOf(e.getInputTargetBlock("B"))})),a=o.getAllBlocks().filter((function(e){return"text"===e.type&&"the code"==e.getFieldValue("TEXT")})),l=o.getAllBlocks().filter((function(e){return"t2c_text_join"===e.type&&-1!==a.indexOf(e.getInputTargetBlock("A"))&&-1!==r.indexOf(e.getInputTargetBlock("B"))})),s=o.getAllBlocks().filter((function(e){return"text_print"===e.type&&-1!==t.indexOf(e.getNextBlock())&&-1!==l.indexOf(e.getInputTargetBlock("TEXT"))})),u=o.getAllBlocks().filter((function(e){return"math_number"===e.type&&"5"==e.getFieldValue("NUM")})),c=o.getAllBlocks().filter((function(e){return"math_number"===e.type&&"1"==e.getFieldValue("NUM")})),g=o.getAllBlocks().filter((function(e){return"text"===e.type&&"Where is the code?"==e.getFieldValue("TEXT")})),d=o.getAllBlocks().filter((function(e){return"t2c_text_getsubstring"===e.type&&-1!==g.indexOf(e.getInputTargetBlock("STRING"))&&-1!==c.indexOf(e.getInputTargetBlock("AT1"))&&-1!==u.indexOf(e.getInputTargetBlock("AT2"))})),h=o.getAllBlocks().filter((function(e){return"t2c_text_join"===e.type&&-1!==i.indexOf(e.getInputTargetBlock("A"))&&-1!==d.indexOf(e.getInputTargetBlock("B"))})),p=o.getAllBlocks().filter((function(e){return"math_number"===e.type&&"17"==e.getFieldValue("NUM")})),f=o.getAllBlocks().filter((function(e){return"math_number"===e.type&&"9"==e.getFieldValue("NUM")})),m=o.getAllBlocks().filter((function(e){return"t2c_text_getsubstring"===e.type&&-1!==g.indexOf(e.getInputTargetBlock("STRING"))&&-1!==f.indexOf(e.getInputTargetBlock("AT1"))&&-1!==p.indexOf(e.getInputTargetBlock("AT2"))})),y=o.getAllBlocks().filter((function(e){return"t2c_text_join"===e.type&&-1!==m.indexOf(e.getInputTargetBlock("A"))&&-1!==h.indexOf(e.getInputTargetBlock("B"))})),T=o.getAllBlocks().filter((function(e){return"text_print"===e.type&&-1!==s.indexOf(e.getNextBlock())&&-1!==y.indexOf(e.getInputTargetBlock("TEXT"))})),_=o.getAllBlocks().filter((function(e){return"variables_get"===e.type&&"question"===e.getField("VAR").getText()})),b=o.getAllBlocks().filter((function(e){return"t2c_text_getsubstring"===e.type&&-1!==_.indexOf(e.getInputTargetBlock("STRING"))&&-1!==c.indexOf(e.getInputTargetBlock("AT1"))&&-1!==u.indexOf(e.getInputTargetBlock("AT2"))})),k=o.getAllBlocks().filter((function(e){return"t2c_text_join"===e.type&&-1!==i.indexOf(e.getInputTargetBlock("A"))&&-1!==b.indexOf(e.getInputTargetBlock("B"))})),x=o.getAllBlocks().filter((function(e){return"math_number"===e.type&&"18"==e.getFieldValue("NUM")})),E=o.getAllBlocks().filter((function(e){return"math_arithmetic_basic"===e.type&&-1!==x.indexOf(e.getInputTargetBlock("A"))&&-1!==c.indexOf(e.getInputTargetBlock("B"))&&"MINUS"==e.getFieldValue("OP")})),B=o.getAllBlocks().filter((function(e){return"math_number"===e.type&&"4"==e.getFieldValue("NUM")})),A=o.getAllBlocks().filter((function(e){return"math_arithmetic_basic"===e.type&&-1!==u.indexOf(e.getInputTargetBlock("A"))&&-1!==B.indexOf(e.getInputTargetBlock("B"))&&"ADD"==e.getFieldValue("OP")})),v=o.getAllBlocks().filter((function(e){return"t2c_text_getsubstring"===e.type&&-1!==_.indexOf(e.getInputTargetBlock("STRING"))&&-1!==A.indexOf(e.getInputTargetBlock("AT1"))&&-1!==E.indexOf(e.getInputTargetBlock("AT2"))})),I=o.getAllBlocks().filter((function(e){return"t2c_text_join"===e.type&&-1!==v.indexOf(e.getInputTargetBlock("A"))&&-1!==k.indexOf(e.getInputTargetBlock("B"))})),w=o.getAllBlocks().filter((function(e){return"text_print"===e.type&&-1!==T.indexOf(e.getNextBlock())&&-1!==I.indexOf(e.getInputTargetBlock("TEXT"))})),S=o.getAllBlocks().filter((function(e){return"variables_get"===e.type&&"part2"===e.getField("VAR").getText()})),M=o.getAllBlocks().filter((function(e){return"variables_get"===e.type&&"needle"===e.getField("VAR").getText()})),N=o.getAllBlocks().filter((function(e){return"t2c_text_join"===e.type&&-1!==M.indexOf(e.getInputTargetBlock("A"))&&-1!==S.indexOf(e.getInputTargetBlock("B"))})),L=o.getAllBlocks().filter((function(e){return"variables_get"===e.type&&"part1"===e.getField("VAR").getText()})),O=o.getAllBlocks().filter((function(e){return"t2c_text_join"===e.type&&-1!==L.indexOf(e.getInputTargetBlock("A"))&&-1!==N.indexOf(e.getInputTargetBlock("B"))})),C=o.getAllBlocks().filter((function(e){return"text_print"===e.type&&-1!==w.indexOf(e.getNextBlock())&&-1!==O.indexOf(e.getInputTargetBlock("TEXT"))})),R=o.getAllBlocks().filter((function(e){return"t2c_text_indexof"===e.type&&-1!==_.indexOf(e.getInputTargetBlock("VALUE"))&&-1!==M.indexOf(e.getInputTargetBlock("FIND"))})),F=o.getAllBlocks().filter((function(e){return"t2c_text_getsubstring"===e.type&&-1!==_.indexOf(e.getInputTargetBlock("STRING"))&&-1!==c.indexOf(e.getInputTargetBlock("AT1"))&&-1!==R.indexOf(e.getInputTargetBlock("AT2"))})),P=o.getAllBlocks().filter((function(e){return"variables_set"===e.type&&-1!==C.indexOf(e.getNextBlock())&&-1!==F.indexOf(e.getInputTargetBlock("VALUE"))&&"part2"===e.getField("VAR").getText()})),V=o.getAllBlocks().filter((function(e){return"t2c_text_length"===e.type&&-1!==_.indexOf(e.getInputTargetBlock("VALUE"))})),G=o.getAllBlocks().filter((function(e){return"math_arithmetic_basic"===e.type&&-1!==V.indexOf(e.getInputTargetBlock("A"))&&-1!==c.indexOf(e.getInputTargetBlock("B"))&&"MINUS"==e.getFieldValue("OP")})),U=o.getAllBlocks().filter((function(e){return"math_arithmetic_basic"===e.type&&-1!==R.indexOf(e.getInputTargetBlock("A"))&&-1!==B.indexOf(e.getInputTargetBlock("B"))&&"ADD"==e.getFieldValue("OP")})),X=o.getAllBlocks().filter((function(e){return"t2c_text_getsubstring"===e.type&&-1!==_.indexOf(e.getInputTargetBlock("STRING"))&&-1!==U.indexOf(e.getInputTargetBlock("AT1"))&&-1!==G.indexOf(e.getInputTargetBlock("AT2"))})),j=o.getAllBlocks().filter((function(e){return"variables_set"===e.type&&-1!==P.indexOf(e.getNextBlock())&&-1!==X.indexOf(e.getInputTargetBlock("VALUE"))&&"part1"===e.getField("VAR").getText()})),D=o.getAllBlocks().filter((function(e){return"variables_set"===e.type&&-1!==j.indexOf(e.getNextBlock())&&-1!==i.indexOf(e.getInputTargetBlock("VALUE"))&&"needle"===e.getField("VAR").getText()})),W=o.getAllBlocks().filter((function(e){return"variables_set"===e.type&&-1!==D.indexOf(e.getNextBlock())&&-1!==g.indexOf(e.getInputTargetBlock("VALUE"))&&"question"===e.getField("VAR").getText()}));return 1===e.length&&1===t.length&&1===n.length&&4===i.length&&1===r.length&&1===a.length&&1===l.length&&1===s.length&&3===u.length&&5===c.length&&3===g.length&&1===d.length&&1===h.length&&1===p.length&&1===f.length&&1===m.length&&1===y.length&&1===T.length&&7===_.length&&1===b.length&&1===k.length&&1===x.length&&1===E.length&&2===B.length&&1===A.length&&1===v.length&&1===I.length&&1===w.length&&1===S.length&&3===M.length&&1===N.length&&1===L.length&&1===O.length&&1===C.length&&2===R.length&&1===F.length&&1===P.length&&1===V.length&&1===G.length&&1===U.length&&1===X.length&&1===j.length&&1===D.length&&1===W.length}),new s((function(){for(var e=o.getAllBlocks(!0),t=e.filter((function(e){return"t2c_text_getsubstring"===e.type||"js_text_getsubstring"===e.type})).map((function(e){return e.getInputTargetBlock("STRING")})).filter((function(e){return e&&"text"===e.type})),n=e.filter((function(e){return"t2c_text_join"===e.type||"text_join"===e.type})).map((function(e){return e.getInputTargetBlock("B")})).filter((function(e){return e&&("t2c_text_join"===e.type||"text_join"===e.type)})).map((function(e){return e.getInputTargetBlock("A")})).filter((function(e){return e&&"text"===e.type})),i=e.filter((function(e){return"t2c_text_getsubstring"===e.type||"js_text_getsubstring"===e.type})).map((function(e){return e.getInputTargetBlock("AT1")})).filter((function(e){return e&&"math_arithmetic_basic"===e.type})).map((function(e){return e.getInputTargetBlock("A")})).find((function(e){return e&&"math_number"===e.type})),r=e.filter((function(e){return"t2c_text_getsubstring"===e.type||"js_text_getsubstring"===e.type})).map((function(e){return e.getInputTargetBlock("AT2")})).filter((function(e){return e&&"math_arithmetic_basic"===e.type})).map((function(e){return e.getInputTargetBlock("A")})).find((function(e){return e&&"math_number"===e.type})),a=e.filter((function(e){return"t2c_text_join"===e.type||"text_join"===e.type})).map((function(e){return e.getInputTargetBlock("B")})).filter((function(e){return e&&("t2c_text_getsubstring"===e.type||"js_text_getsubstring"===e.type)})).map((function(e){return e.getInputTargetBlock("AT2")})).filter((function(e){return e&&"math_number"===e.type})),l=e.filter((function(e){return"t2c_text_join"===e.type||"text_join"===e.type})).map((function(e){return e.getInputTargetBlock("A")})).filter((function(e){return e&&("t2c_text_getsubstring"===e.type||"js_text_getsubstring"===e.type)})).map((function(e){return e.getInputTargetBlock("AT1")})).find((function(e){return e&&"math_number"===e.type})),s=e.filter((function(e){return"t2c_text_join"===e.type||"text_join"===e.type})).map((function(e){return e.getInputTargetBlock("A")})).filter((function(e){return e&&("t2c_text_getsubstring"===e.type||"js_text_getsubstring"===e.type)})).map((function(e){return e.getInputTargetBlock("AT2")})).find((function(e){return e&&"math_number"===e.type})),u=e.filter((function(e){return("t2c_text_join"===e.type||"text_join"===e.type)&&e.getParent()&&("text_print"===e.getParent().type||"js_text_print"===e.getParent().type)})).map((function(e){return e.getInputTargetBlock("A")})).find((function(e){return e&&"text"===e.type})),c=e.filter((function(e){return"t2c_text_join"===e.type||"text_join"===e.type})).map((function(e){return e.getInputTargetBlock("B")})).filter((function(e){return e&&("t2c_text_join"===e.type||"text_join"===e.type)})).map((function(e){return e.getInputTargetBlock("B")})).find((function(e){return e&&"text"===e.type})),g=e.find((function(e){return"text"===e.type&&e.getParent()&&("text_print"===e.getParent().type||"js_text_print"===e.getParent().type)})),d="Where is the code?",h=d.indexOf(" is "),p=0;p<=1;p++){var f=t[p];if(f&&f.getFieldValue("TEXT")&&f.getFieldValue("TEXT")!==d)return"The text before the "+(0===p?"first ":"second ")+T2C.MSG.currentLanguage.TERMINAL_GETTEXTFROMPOSITIONNUMBER+" on line 7 is incorrect. Substitute question with the value that it's initially assigned to."}for(var m=0;m<=2;m++){var y=n[m];if(y&&y.getFieldValue("TEXT")&&" is "!==y.getFieldValue("TEXT"))return"The text after the first + (for string concatenation, NOT numbers) on line "+(m+6)+" is incorrect. Substitute needle with the value that it's initially assigned to (*including* a single space at the beginning *and* end)."}if(i&&i.getFieldValue("NUM")&&i.getFieldValue("NUM")!==h)return"The first number on line 6 (in the addition block) is incorrect. It should be the substitution of "+T2C.MSG.currentLanguage.TERMINAL_FINDFIRSTOCCURRENCEOFTEXT+", which will be the *starting* position of the first occurrence of the value of needle. Fix it accordingly.";if(r&&r.getFieldValue("NUM")&&r.getFieldValue("NUM")!==d.length)return"The third number on line 6 (in the subtraction block) should be the length of the value of question. Fix it accordingly.";for(var T=0;T<=1;T++){var _=a[T];if(_&&_.getFieldValue("NUM")&&_.getFieldValue("NUM")!==h)return"The last number on line "+(T+6)+" is incorrect. It should be the substitution of "+T2C.MSG.currentLanguage.TERMINAL_FINDFIRSTOCCURRENCEOFTEXT+", which will be the *starting* position of the first occurrence of the value of needle. Fix it accordingly."}return i&&i.getFieldValue("NUM")&&i.getFieldValue("NUM")===h&&l&&l.getFieldValue("NUM")&&l.getFieldValue("NUM")!==h+4?"The first number on line 7 should be the result of the addition with 4 from the previous line. Fix it accordingly.":r&&r.getFieldValue("NUM")&&r.getFieldValue("NUM")===d.length&&s&&s.getFieldValue("NUM")&&s.getFieldValue("NUM")!==d.length-1?"The second number on line 7 should be the result of the subtraction by 1 from the previous line. Fix it accordingly.":i&&i.getFieldValue("NUM")&&i.getFieldValue("NUM")===h&&l&&l.getFieldValue("NUM")&&l.getFieldValue("NUM")===h+4&&r&&r.getFieldValue("NUM")&&r.getFieldValue("NUM")===d.length&&s&&s.getFieldValue("NUM")&&s.getFieldValue("NUM")===d.length-1&&u&&u.getFieldValue("TEXT")&&u.getFieldValue("TEXT")!==d.substring(h+4,d.length-1)?"The first string on line 8 (before the text concatenation +) should be the result of the substitution of the first "+T2C.MSG.currentLanguage.TERMINAL_GETTEXTFROMPOSITIONNUMBER+". Fix it accordingly.":a[1]&&a[1].getFieldValue("NUM")&&a[1].getFieldValue("NUM")===h&&c&&c.getFieldValue("TEXT")&&c.getFieldValue("TEXT")!==d.substring(1,h)?"The last string on line 8 (after both text concatenation +) should be the result of the substitution of the second "+T2C.MSG.currentLanguage.TERMINAL_GETTEXTFROMPOSITIONNUMBER+". Fix it accordingly.":u&&u.getFieldValue("TEXT")&&u.getFieldValue("TEXT")===d.substring(h+4,d.length-1)&&n[2]&&n[2].getFieldValue("TEXT")&&" is "===n[2].getFieldValue("TEXT")&&c&&c.getFieldValue("TEXT")&&c.getFieldValue("TEXT")===d.substring(1,h)&&g&&g.getFieldValue("TEXT")&&g.getFieldValue("TEXT")!==d.substring(h+4,d.length-1)+" is "+d.substring(1,h)?"The string on the last line is incorrect; it should be the result of the substitution of the concatenation of the three strings above it on line 8.":"Replace all the blank string literals and 0's with the appropriate text and numbers that are substituted as the computer would from top to bottom so that every line of output is the same. Try to do this without running the program until you get the message to do so (when you filled in everything correctly)."}),{startPosition:se(o,null,{},50,document.getElementById("top-header").offsetHeight+50)}))),function(e){e.addTask(new r((function(){return document.getElementById("output-container").classList.contains("show-container")}),new u([new s((function(){return T2C.MSG.currentLanguage.BUTTON_RUN_CODE}),{startPosition:{x:document.getElementById("run-code-button").offsetLeft+document.getElementById("run-code-button").offsetWidth,y:document.getElementById("run-code-button").offsetTop+document.getElementById("run-code-button").offsetHeight}}),new l(g,{totalSteps:100,toggleSteps:25,startPosition:{x:document.getElementById("run-code-button").offsetLeft+document.getElementById("run-code-button").offsetWidth/2,y:document.getElementById("run-code-button").offsetTop+document.getElementById("run-code-button").offsetHeight/2}})])))}(n),function(e,t){var n=0;function o(){t.style.color=n%50<25?"#a00":"#000",++n<200&&requestAnimationFrame(o)}e.addTask(new r((function(){return n>=200}),{start:function(){t.style.verticalAlign="top",requestAnimationFrame(o)},isComplete:function(){return!0},animate:function(){return!0}}))}(n,document.getElementById("output-container").querySelectorAll(".table-cell")[0]),n.addTask(new r((function(){return!0}),{start:function(){return!0},isComplete:function(){return!0},animate:function(){return!0},finish:function(){alert("Good, so now we're ready for today's main mission. But we're going to plan ahead! When you finish these training missions and need to take on a challenging new coding problem without guidance, you may find yourself lost and typing code that gets you nowhere. In these situations, it may help to work backward from your objective, which is exactly what we're going to do here. Since we want to display the user's name as \"first last\", let's suppose we have their first and last names stored in the variables firstName and lastName and *use them* to display the person's full name separated by a space."),oe(document.getElementById("output-container").querySelectorAll(".table-cell")[0]),ie(),o.clear(),a.clearToolbox(),a.createToolboxBlock("type_in_display_first_last_name"),o.options.maxInstances.type_in_display_first_last_name=1}})),n.addTask(new r((function(){var e=o.getAllBlocks().filter((function(e){return"variables_get"===e.type&&"lastName"===e.getField("VAR").getText()})),t=o.getAllBlocks().filter((function(e){return"text"===e.type&&" "==e.getFieldValue("TEXT")})),n=o.getAllBlocks().filter((function(n){return("text_join"===n.type||"t2c_text_join"===n.type)&&-1!==t.indexOf(n.getInputTargetBlock("A"))&&-1!==e.indexOf(n.getInputTargetBlock("B"))})),i=o.getAllBlocks().filter((function(e){return"variables_get"===e.type&&"firstName"===e.getField("VAR").getText()})),r=o.getAllBlocks().filter((function(e){return("text_join"===e.type||"t2c_text_join"===e.type)&&-1!==i.indexOf(e.getInputTargetBlock("A"))&&-1!==n.indexOf(e.getInputTargetBlock("B"))})),a=o.getAllBlocks().filter((function(e){return("text_print"===e.type||"js_text_print"===e.type)&&null===e.getNextBlock()&&-1!==r.indexOf(e.getInputTargetBlock("TEXT"))}));return 1===e.length&&1===t.length&&1===n.length&&1===i.length&&1===r.length&&1===a.length}),new s((function(){return'Drag the type-in-code block, and type the necessary code to display the person\'s first name and last name separated by a space, assuming the first and last names are stored in the variables, firstName and lastName, respectively. E.g., if firstName = "Jane" and lastName = "Doe", you\'d want to display "Jane Doe".'}),{startPosition:se(o,null,{},50,document.getElementById("top-header").offsetHeight+50)}))),n.addTask(new r((function(){return!0}),{start:function(){return!0},isComplete:function(){return!0},animate:function(){return!0},finish:function(){alert('✔ Acchaa (Good), so now of course we need to get the first and last names. Let\'s get the last name first. The input will be something like "Doe, Jane" so the last name will be a consecutive series of characters from part of this string...');for(var e="Which of the following can be used to get a consecutive series of characters from part of this string? (Enter a, b, c, or d.)\nA. "+T2C.MSG.currentLanguage.TERMINAL_GETCHARACTERNUMBER+"\nB. "+T2C.MSG.currentLanguage.TERMINAL_FINDFIRSTOCCURRENCEOFTEXT+"\nC. "+T2C.MSG.currentLanguage.TERMINAL_LENGTH+"\nD. "+T2C.MSG.currentLanguage.TERMINAL_GETTEXTFROMPOSITIONNUMBER,t=prompt(e);"string"==typeof t&&!t.toLowerCase().startsWith("d");)t=prompt("No, "+t[0]+" is not correct. Please try again. "+e);alert((t?"Yes":"OK, we'll tell you")+", D "+T2C.MSG.currentLanguage.TERMINAL_GETTEXTFROMPOSITIONNUMBER+' is the correct answer. Now this requires the string to extract text from and both starting and ending *numbers*, the first one telling the computer where to start extracting text from and the second telling it where to stop. For an input of "Doe, Jane", the last name starts at the beginning and ends at the position of the comma. So let\'s assume we have the input stored in enteredName and position of the comma in commaPosition and store the last name in a variable lastName, accordingly.'),oe(document.getElementById("output-container").querySelectorAll(".table-cell")[0]),ie(),a.clearToolbox(),a.createToolboxBlock("type_in_set_last_name"),o.options.maxInstances.type_in_set_last_name=1}})),n.addTask(new r((function(){var e=o.getAllBlocks().filter((function(e){return"variables_get"===e.type&&"lastName"===e.getField("VAR").getText()})),t=o.getAllBlocks().filter((function(e){return"text"===e.type&&" "===e.getFieldValue("TEXT")})),n=o.getAllBlocks().filter((function(n){return("t2c_text_join"===n.type||"text_join"===n.type)&&-1!==t.indexOf(n.getInputTargetBlock("A"))&&-1!==e.indexOf(n.getInputTargetBlock("B"))})),i=o.getAllBlocks().filter((function(e){return"variables_get"===e.type&&"firstName"===e.getField("VAR").getText()})),r=o.getAllBlocks().filter((function(e){return("t2c_text_join"===e.type||"text_join"===e.type)&&-1!==i.indexOf(e.getInputTargetBlock("A"))&&-1!==n.indexOf(e.getInputTargetBlock("B"))})),a=o.getAllBlocks().filter((function(e){return("text_print"===e.type||"js_text_print"===e.type)&&null===e.getNextBlock()&&-1!==r.indexOf(e.getInputTargetBlock("TEXT"))})),l=o.getAllBlocks().filter((function(e){return"variables_get"===e.type&&"commaPosition"===e.getField("VAR").getText()})),s=o.getAllBlocks().filter((function(e){return"math_number"===e.type&&0===e.getFieldValue("NUM")})),u=o.getAllBlocks().filter((function(e){return"variables_get"===e.type&&"enteredName"===e.getField("VAR").getText()})),c=o.getAllBlocks().filter((function(e){return("t2c_text_getsubstring"===e.type||"js_text_getsubstring"===e.type)&&-1!==u.indexOf(e.getInputTargetBlock("STRING"))&&-1!==s.indexOf(e.getInputTargetBlock("AT1"))&&-1!==l.indexOf(e.getInputTargetBlock("AT2"))})),g=o.getAllBlocks().filter((function(e){return"variables_set"===e.type&&-1!==a.indexOf(e.getNextBlock())&&-1!==c.indexOf(e.getInputTargetBlock("VALUE"))&&"lastName"===e.getField("VAR").getText()}));return 1===e.length&&1===t.length&&1===n.length&&1===i.length&&1===r.length&&1===a.length&&1===l.length&&1===s.length&&1===u.length&&1===c.length&&1===g.length}),new s((function(){var e=o.getAllBlocks().find((function(e){return"variables_set"===e.type})),t=o.getAllBlocks().find((function(e){return"text_print"===e.type||"js_text_print"===e.type}));return t&&e&&t.getNextBlock()===e?"The "+T2C.MSG.currentLanguage.TERMINAL_LET+" variable block declaring lastName needs to go above the "+T2C.MSG.currentLanguage.TERMINAL_DISPLAY+" block so the computer knows what lastName is when attempting to display the user's full name, which references lastName! Remember that statements are run from top to bottom.":t&&e&&t.getPreviousBlock()!==e?"Place the new "+T2C.MSG.currentLanguage.TERMINAL_LET+" variable block that sets lastName above the "+T2C.MSG.currentLanguage.TERMINAL_DISPLAY+" block so the computer knows what lastName is when attempting to display the user's full name, which references lastName.":"Drag the type-in-code block, and attach it above the previous "+T2C.MSG.currentLanguage.TERMINAL_DISPLAY+' block. Then type the necessary code to store the user\'s last name in the variable lastName, *assuming* we have the input in the form "last name, first name" stored in the variable enteredName (e.g., enteredName = "Doe, Jane") *AND* the position of the comma stored in commaPosition (e.g., for "Doe, Jane", commaPosition = 3).'}),{startPosition:se(o,null,{},50,document.getElementById("top-header").offsetHeight+50)}))),n.addTask(new r((function(){return!0}),{start:function(){return!0},isComplete:function(){return!0},animate:function(){return!0},finish:function(){alert('✔ Bahut acchaa (Very good), so now let\'s get the first name. The input will be something like "Doe, Jane" so the first name will also be a consecutive series of characters from part of this string so we can once again use '+T2C.MSG.currentLanguage.TERMINAL_GETTEXTFROMPOSITIONNUMBER+". You can figure out how you could get the numerical starting and ending positions from enteredString and commaPosition, right?"),oe(document.getElementById("output-container").querySelectorAll(".table-cell")[0]),ie(),a.clearToolbox(),a.createToolboxBlock("type_in_set_first_name"),o.options.maxInstances.type_in_set_first_name=1}})),n.addTask(new r((function(){var e=o.getAllBlocks().filter((function(e){return"variables_get"===e.type&&"lastName"===e.getField("VAR").getText()})),t=o.getAllBlocks().filter((function(e){return"text"===e.type&&" "===e.getFieldValue("TEXT")})),n=o.getAllBlocks().filter((function(n){return("t2c_text_join"===n.type||"text_join"===n.type)&&-1!==t.indexOf(n.getInputTargetBlock("A"))&&-1!==e.indexOf(n.getInputTargetBlock("B"))})),i=o.getAllBlocks().filter((function(e){return"variables_get"===e.type&&"firstName"===e.getField("VAR").getText()})),r=o.getAllBlocks().filter((function(e){return("t2c_text_join"===e.type||"text_join"===e.type)&&-1!==i.indexOf(e.getInputTargetBlock("A"))&&-1!==n.indexOf(e.getInputTargetBlock("B"))})),a=o.getAllBlocks().filter((function(e){return("text_print"===e.type||"js_text_print"===e.type)&&null===e.getNextBlock()&&-1!==r.indexOf(e.getInputTargetBlock("TEXT"))})),l=o.getAllBlocks().filter((function(e){return"variables_get"===e.type&&"commaPosition"===e.getField("VAR").getText()})),s=o.getAllBlocks().filter((function(e){return"math_number"===e.type&&0===e.getFieldValue("NUM")})),u=o.getAllBlocks().filter((function(e){return"variables_get"===e.type&&"enteredName"===e.getField("VAR").getText()})),c=o.getAllBlocks().filter((function(e){return("t2c_text_getsubstring"===e.type||"js_text_getsubstring"===e.type)&&-1!==u.indexOf(e.getInputTargetBlock("STRING"))&&-1!==s.indexOf(e.getInputTargetBlock("AT1"))&&-1!==l.indexOf(e.getInputTargetBlock("AT2"))})),g=o.getAllBlocks().filter((function(e){return"variables_set"===e.type&&-1!==a.indexOf(e.getNextBlock())&&-1!==c.indexOf(e.getInputTargetBlock("VALUE"))&&"lastName"===e.getField("VAR").getText()})),d=o.getAllBlocks().filter((function(e){return"t2c_text_length"===e.type&&-1!==u.indexOf(e.getInputTargetBlock("VALUE"))})),h=o.getAllBlocks().filter((function(e){return"math_number"===e.type&&2===e.getFieldValue("NUM")})),p=o.getAllBlocks().filter((function(e){return"math_arithmetic_basic"===e.type&&-1!==l.indexOf(e.getInputTargetBlock("A"))&&-1!==h.indexOf(e.getInputTargetBlock("B"))&&"ADD"==e.getFieldValue("OP")})),f=o.getAllBlocks().filter((function(e){return("t2c_text_getsubstring"===e.type||"js_text_getsubstring"===e.type)&&-1!==u.indexOf(e.getInputTargetBlock("STRING"))&&-1!==p.indexOf(e.getInputTargetBlock("AT1"))&&-1!==d.indexOf(e.getInputTargetBlock("AT2"))})),m=o.getAllBlocks().filter((function(e){return"variables_set"===e.type&&-1!==g.indexOf(e.getNextBlock())&&-1!==f.indexOf(e.getInputTargetBlock("VALUE"))&&"firstName"===e.getField("VAR").getText()}));return 1===e.length&&1===t.length&&1===n.length&&1===i.length&&1===r.length&&1===a.length&&2===l.length&&1===s.length&&3===u.length&&1===c.length&&1===g.length&&1===d.length&&1===h.length&&1===p.length&&1===f.length&&1===m.length}),new s((function(){var e=o.getAllBlocks().find((function(e){return"variables_set"===e.type&&"firstName"===e.getField("VAR").getText()})),t=o.getAllBlocks().find((function(e){return"variables_set"===e.type&&"lastName"===e.getField("VAR").getText()})),n=o.getAllBlocks().find((function(e){return"text_print"===e.type||"js_text_print"===e.type}));return e&&n&&n.getNextBlock()===e?"The "+T2C.MSG.currentLanguage.TERMINAL_LET+" variable block declaring firstName needs to go above the "+T2C.MSG.currentLanguage.TERMINAL_DISPLAY+" block so the computer knows what firstName is when attempting to display the user's full name, which references firstName! Remember that statements are run from top to bottom.":e&&e.getNextBlock()!==t?"Place the new "+T2C.MSG.currentLanguage.TERMINAL_LET+" variable block that sets firstName above the "+T2C.MSG.currentLanguage.TERMINAL_LET+" variable block storing lastName.":"Drag the type-in-code block, and attach it above the previous "+T2C.MSG.currentLanguage.TERMINAL_LET+' block. Then type the necessary code to store the user\'s first name in the variable firstName, *assuming* we have the input in the form "last name, first name" stored in the variable enteredName (e.g., enteredName = "Doe, Jane") *AND* the position of the comma stored in commaPosition (e.g., for "Doe, Jane", commaPosition = 3). Remember that there\'s a space after the comma.'}),{startPosition:se(o,null,{},50,document.getElementById("top-header").offsetHeight+50)}))),n.addTask(new r((function(){return!0}),{start:function(){return!0},isComplete:function(){return!0},animate:function(){return!0},finish:function(){alert("✔ Mahaan (Great)! So for both the first and last name, we needed the position of the comma in the input, which we assume is being stored in enteredName. You know how to tell the computer to find the position number of the (first) comma in enteredName and store it in the variable commaPosition, right?"),oe(document.getElementById("output-container").querySelectorAll(".table-cell")[0]),ie(),a.clearToolbox(),a.createToolboxBlock("type_in_set_comma_pos"),o.options.maxInstances.type_in_set_comma_pos=1}})),n.addTask(new r((function(){var e=o.getAllBlocks().filter((function(e){return"variables_get"===e.type&&"lastName"===e.getField("VAR").getText()})),t=o.getAllBlocks().filter((function(e){return"text"===e.type&&" "===e.getFieldValue("TEXT")})),n=o.getAllBlocks().filter((function(n){return("t2c_text_join"===n.type||"text_join"===n.type)&&-1!==t.indexOf(n.getInputTargetBlock("A"))&&-1!==e.indexOf(n.getInputTargetBlock("B"))})),i=o.getAllBlocks().filter((function(e){return"variables_get"===e.type&&"firstName"===e.getField("VAR").getText()})),r=o.getAllBlocks().filter((function(e){return("t2c_text_join"===e.type||"text_join"===e.type)&&-1!==i.indexOf(e.getInputTargetBlock("A"))&&-1!==n.indexOf(e.getInputTargetBlock("B"))})),a=o.getAllBlocks().filter((function(e){return("text_print"===e.type||"js_text_print"===e.type)&&null===e.getNextBlock()&&-1!==r.indexOf(e.getInputTargetBlock("TEXT"))})),l=o.getAllBlocks().filter((function(e){return"variables_get"===e.type&&"commaPosition"===e.getField("VAR").getText()})),s=o.getAllBlocks().filter((function(e){return"math_number"===e.type&&0===e.getFieldValue("NUM")})),u=o.getAllBlocks().filter((function(e){return"variables_get"===e.type&&"enteredName"===e.getField("VAR").getText()})),c=o.getAllBlocks().filter((function(e){return("t2c_text_getsubstring"===e.type||"js_text_getsubstring"===e.type)&&-1!==u.indexOf(e.getInputTargetBlock("STRING"))&&-1!==s.indexOf(e.getInputTargetBlock("AT1"))&&-1!==l.indexOf(e.getInputTargetBlock("AT2"))})),g=o.getAllBlocks().filter((function(e){return"variables_set"===e.type&&-1!==a.indexOf(e.getNextBlock())&&-1!==c.indexOf(e.getInputTargetBlock("VALUE"))&&"lastName"===e.getField("VAR").getText()})),d=o.getAllBlocks().filter((function(e){return"t2c_text_length"===e.type&&-1!==u.indexOf(e.getInputTargetBlock("VALUE"))})),h=o.getAllBlocks().filter((function(e){return"math_number"===e.type&&2===e.getFieldValue("NUM")})),p=o.getAllBlocks().filter((function(e){return"math_arithmetic_basic"===e.type&&-1!==l.indexOf(e.getInputTargetBlock("A"))&&-1!==h.indexOf(e.getInputTargetBlock("B"))&&"ADD"==e.getFieldValue("OP")})),f=o.getAllBlocks().filter((function(e){return("t2c_text_getsubstring"===e.type||"js_text_getsubstring"===e.type)&&-1!==u.indexOf(e.getInputTargetBlock("STRING"))&&-1!==p.indexOf(e.getInputTargetBlock("AT1"))&&-1!==d.indexOf(e.getInputTargetBlock("AT2"))})),m=o.getAllBlocks().filter((function(e){return"variables_set"===e.type&&-1!==g.indexOf(e.getNextBlock())&&-1!==f.indexOf(e.getInputTargetBlock("VALUE"))&&"firstName"===e.getField("VAR").getText()})),y=o.getAllBlocks().filter((function(e){return"text"===e.type&&(","==e.getFieldValue("TEXT")||", "==e.getFieldValue("TEXT"))})),T=o.getAllBlocks().filter((function(e){return("t2c_text_indexof"===e.type||"js_text_indexof"===e.type)&&-1!==u.indexOf(e.getInputTargetBlock("VALUE"))&&-1!==y.indexOf(e.getInputTargetBlock("FIND"))})),_=o.getAllBlocks().filter((function(e){return"variables_set"===e.type&&-1!==m.indexOf(e.getNextBlock())&&-1!==T.indexOf(e.getInputTargetBlock("VALUE"))&&"commaPosition"===e.getField("VAR").getText()}));return 1===e.length&&1===t.length&&1===n.length&&1===i.length&&1===r.length&&1===a.length&&2===l.length&&1===s.length&&4===u.length&&1===c.length&&1===g.length&&1===d.length&&1===h.length&&1===p.length&&1===f.length&&1===m.length&&1===y.length&&1===T.length&&1===_.length}),new s((function(){var e=o.getAllBlocks().find((function(e){return"variables_set"===e.type&&"commaPosition"===e.getField("VAR").getText()})),t=o.getAllBlocks().find((function(e){return"variables_set"===e.type&&"firstName"===e.getField("VAR").getText()})),n=o.getAllBlocks().find((function(e){return"variables_set"===e.type&&"lastName"===e.getField("VAR").getText()})),i=o.getAllBlocks().find((function(e){return"text_print"===e.type||"js_text_print"===e.type}));return e&&e.getPreviousBlock()===i?"The "+T2C.MSG.currentLanguage.TERMINAL_LET+" variable block declaring commaPosition must go above the "+T2C.MSG.currentLanguage.TERMINAL_DISPLAY+" block because the computer uses commaPosition in firstName and in lastName, both which need commaPosition to determine what they are. Since instructions are run from top to bottom, it won't be able to determine firstName and lastName, which are used in the "+T2C.MSG.currentLanguage.TERMINAL_DISPLAY+" otherwise!":e&&e.getPreviousBlock()===t?"The "+T2C.MSG.currentLanguage.TERMINAL_LET+" variable block declaring commaPosition must go above the "+T2C.MSG.currentLanguage.TERMINAL_LET+" variable block setting firstName, because the computer uses commaPosition to determine what firstName is. Since instructions are run from top to bottom, it won't know what commaPosition means, otherwise!":e&&e.getPreviousBlock()===n?"The "+T2C.MSG.currentLanguage.TERMINAL_LET+" variable block declaring commaPosition must go above the "+T2C.MSG.currentLanguage.TERMINAL_LET+" variable block setting lastName, because the computer uses commaPosition to determine what lastName is. Since instructions are run from top to bottom, it won't know what commaPosition means, otherwise!":e&&null===e.getNextBlock()?"Place the new "+T2C.MSG.currentLanguage.TERMINAL_LET+" variable block that sets commaPosition above the "+T2C.MSG.currentLanguage.TERMINAL_LET+" variable block storing firstName.":"Drag the type-in-code block, and attach it above the previous "+T2C.MSG.currentLanguage.TERMINAL_LET+" block. Then type the necessary code to store the position number of the (first) comma from the value of enteredName in the variable commaPosition."}),{startPosition:se(o,null,{},50,document.getElementById("top-header").offsetHeight+50)}))),n.addTask(new r((function(){return!0}),{start:function(){return!0},isComplete:function(){return!0},animate:function(){return!0},finish:function(){alert("✔ Excellent! So now all we have left is to ask the user to enter a name in the form last name, first name and store it in the variable enteredName and we'll be done!"),oe(document.getElementById("output-container").querySelectorAll(".table-cell")[0]),ie(),a.clearToolbox(),a.createToolboxBlock("type_in_get_last_first_name_input"),o.options.maxInstances.type_in_get_last_first_name_input=1}})),n.addTask(new r((function(){var e=o.getAllBlocks().filter((function(e){return"variables_get"===e.type&&"lastName"===e.getField("VAR").getText()})),t=o.getAllBlocks().filter((function(e){return"text"===e.type&&" "===e.getFieldValue("TEXT")})),n=o.getAllBlocks().filter((function(n){return("t2c_text_join"===n.type||"text_join"===n.type)&&-1!==t.indexOf(n.getInputTargetBlock("A"))&&-1!==e.indexOf(n.getInputTargetBlock("B"))})),i=o.getAllBlocks().filter((function(e){return"variables_get"===e.type&&"firstName"===e.getField("VAR").getText()})),r=o.getAllBlocks().filter((function(e){return("t2c_text_join"===e.type||"text_join"===e.type)&&-1!==i.indexOf(e.getInputTargetBlock("A"))&&-1!==n.indexOf(e.getInputTargetBlock("B"))})),a=o.getAllBlocks().filter((function(e){return("text_print"===e.type||"js_text_print"===e.type)&&null===e.getNextBlock()&&-1!==r.indexOf(e.getInputTargetBlock("TEXT"))})),l=o.getAllBlocks().filter((function(e){return"variables_get"===e.type&&"commaPosition"===e.getField("VAR").getText()})),s=o.getAllBlocks().filter((function(e){return"math_number"===e.type&&0===e.getFieldValue("NUM")})),u=o.getAllBlocks().filter((function(e){return"variables_get"===e.type&&"enteredName"===e.getField("VAR").getText()})),c=o.getAllBlocks().filter((function(e){return("t2c_text_getsubstring"===e.type||"js_text_getsubstring"===e.type)&&-1!==u.indexOf(e.getInputTargetBlock("STRING"))&&-1!==s.indexOf(e.getInputTargetBlock("AT1"))&&-1!==l.indexOf(e.getInputTargetBlock("AT2"))})),g=o.getAllBlocks().filter((function(e){return"variables_set"===e.type&&-1!==a.indexOf(e.getNextBlock())&&-1!==c.indexOf(e.getInputTargetBlock("VALUE"))&&"lastName"===e.getField("VAR").getText()})),d=o.getAllBlocks().filter((function(e){return"t2c_text_length"===e.type&&-1!==u.indexOf(e.getInputTargetBlock("VALUE"))})),h=o.getAllBlocks().filter((function(e){return"math_number"===e.type&&2===e.getFieldValue("NUM")})),p=o.getAllBlocks().filter((function(e){return"math_arithmetic_basic"===e.type&&-1!==l.indexOf(e.getInputTargetBlock("A"))&&-1!==h.indexOf(e.getInputTargetBlock("B"))&&"ADD"==e.getFieldValue("OP")})),f=o.getAllBlocks().filter((function(e){return("t2c_text_getsubstring"===e.type||"js_text_getsubstring"===e.type)&&-1!==u.indexOf(e.getInputTargetBlock("STRING"))&&-1!==p.indexOf(e.getInputTargetBlock("AT1"))&&-1!==d.indexOf(e.getInputTargetBlock("AT2"))})),m=o.getAllBlocks().filter((function(e){return"variables_set"===e.type&&-1!==g.indexOf(e.getNextBlock())&&-1!==f.indexOf(e.getInputTargetBlock("VALUE"))&&"firstName"===e.getField("VAR").getText()})),y=o.getAllBlocks().filter((function(e){return"text"===e.type&&(","==e.getFieldValue("TEXT")||", "==e.getFieldValue("TEXT"))})),T=o.getAllBlocks().filter((function(e){return("t2c_text_indexof"===e.type||"js_text_indexof"===e.type)&&-1!==u.indexOf(e.getInputTargetBlock("VALUE"))&&-1!==y.indexOf(e.getInputTargetBlock("FIND"))})),_=o.getAllBlocks().filter((function(e){return"variables_set"===e.type&&-1!==m.indexOf(e.getNextBlock())&&-1!==T.indexOf(e.getInputTargetBlock("VALUE"))&&"commaPosition"===e.getField("VAR").getText()})),b=o.getAllBlocks().filter((function(e){return"text"===e.type&&"string"==typeof e.getFieldValue("TEXT")&&-1!==e.getFieldValue("TEXT").indexOf("name")})),k=o.getAllBlocks().filter((function(e){return("text_input"===e.type||"js_text_input"===e.type)&&-1!==b.indexOf(e.getInputTargetBlock("TEXT"))})),x=o.getAllBlocks().filter((function(e){return"variables_set"===e.type&&-1!==_.indexOf(e.getNextBlock())&&-1!==k.indexOf(e.getInputTargetBlock("VALUE"))&&"enteredName"===e.getField("VAR").getText()}));return 1===e.length&&1===t.length&&1===n.length&&1===i.length&&1===r.length&&1===a.length&&2===l.length&&1===s.length&&4===u.length&&1===c.length&&1===g.length&&1===d.length&&1===h.length&&1===p.length&&1===f.length&&1===m.length&&1===y.length&&1===T.length&&1===_.length&&1===b.length&&1===k.length&&1===x.length}),new s((function(){var e=o.getAllBlocks().find((function(e){return"variables_set"===e.type&&"enteredName"===e.getField("VAR").getText()})),t=(o.getAllBlocks().find((function(e){return"variables_set"===e.type&&"commaPosition"===e.getField("VAR").getText()})),o.getAllBlocks().find((function(e){return"variables_set"===e.type&&"firstName"===e.getField("VAR").getText()})),o.getAllBlocks().find((function(e){return"variables_set"===e.type&&"lastName"===e.getField("VAR").getText()})),o.getAllBlocks().find((function(e){return"text_print"===e.type||"js_text_print"===e.type})));if(e&&t&&t.getNextBlock()===e)return"The "+T2C.MSG.currentLanguage.TERMINAL_LET+" variable block setting enteredName must go above the "+T2C.MSG.currentLanguage.TERMINAL_DISPLAY+" block because the computer uses enteredName in firstName and in lastName, both which need enteredName to determine what they are. Since instructions are run from top to bottom, it won't be able to determine firstName and lastName, which are used in the "+T2C.MSG.currentLanguage.TERMINAL_DISPLAY+" otherwise!";if(e&&null!==e.getPreviousBlock()){var n="variables_set"===e.getPreviousBlock().type&&e.getPreviousBlock().getField("VAR").getText();return"The "+T2C.MSG.currentLanguage.TERMINAL_LET+" variable block setting enteredName must go above the "+T2C.MSG.currentLanguage.TERMINAL_LET+" variable block setting "+n+" because the computer uses enteredName to determine what "+n+" is. Since instructions are run from top to bottom, it won't know what enteredName means, otherwise!"}return e&&null===e.getNextBlock()?"Place the new "+T2C.MSG.currentLanguage.TERMINAL_LET+" variable block that sets enteredName above the "+T2C.MSG.currentLanguage.TERMINAL_LET+" variable block storing commaPosition.":"Drag the type-in-code block, and attach it above the previous "+T2C.MSG.currentLanguage.TERMINAL_LET+" block. Then type the necessary code to ask the user for their full name in the form last, first, including the space after the comma (e.g., as Doe, Jane) and storing his/her inputted name in enteredName."}),{startPosition:se(o,null,{},50,document.getElementById("top-header").offsetHeight+50)}))),n.addTask(new r((function(){return!0}),{start:function(){return!0},isComplete:function(){return!0},animate:function(){return!0},finish:function(){alert("✔✔✔ Outstanding! And with that, Mission # 6 is accomplished! Can you believe you finished the problem already? You see how working backward can take a potentially challenging problem and make it a lot simpler? In the next mission 7, you'll continue your training turning s's into dollar signs with a little cutting and pasting using the same types of blocks from this mission. However, next time, you'll be typing code in straight up JavaScript! Your ready? Until next time!"),ie(),a.clearToolbox(),["code_statement"].forEach((function(e,t){a.createToolboxBlock(e,!1),o.options.maxInstances[e]=maxBlocks[t]}))}})),n},function(e,t){var n=e||new c,o=t||Blockly.getMainWorkspace(),a=new f(o),g="Mississippi".indexOf("s"),d="Mississippi".substring(0,g),h="Mississippi".substring(g+1),p=d+"$"+h;o.setScale(1),Object(i.f)(o);var m=document.createElement("div");function y(e){var t=e.options.maxInstances;e.options.maxInstances={},e.getAllBlocks().forEach((function(t){e.options.maxInstances[t.type]=++e.options.maxInstances[t.type]||1})),Object.keys(t).forEach((function(n){e.options.maxInstances[n]=e.options.maxInstances[n]||t[n]}))}return m.innerText="👆",m.id="ptr",m.style.fontSize="x-large",m.style.position="absolute",m.style.zIndex="1001",document.getElementById("blockly-div").appendChild(m),n.addTask(new r((function(){return T2C.MSG.currentLanguage===T2C.MSG.JS}),{start:function(){var e=T2C.MSG.currentLanguage===T2C.MSG.JS?"":"So to start, select JavaScript from the dropdown menu at the top and watch how the blocks in the toolbox transform to their JavaScript equivalents.";a.clearToolbox(),["text_print","text_input","t2c_text_indexof","t2c_text_getsubstring","variables_set","variables_get"].forEach((function(e,t){a.createToolboxBlock(e,!1),o.options.maxInstances[e]=0})),alert("In this mission, you'll ask the user for a string with at least one (lowercase) s and then output the entered string with the first s replaced by $. E.g., for Mississippi, the output would be "+p+". This task can be accomplished similar to the way the last one was, but this time you're going to work in pure JavaScript. "+e),o.clear(),Blockly.svgResize(o),ce(document.getElementById("output-container").querySelectorAll(".table-cell")[0]),ge()},isComplete:function(){return!0},animate:function(){return!0},finish:function(){}})),n.addTask(new r((function(){return!0}),{start:function(){alert("Theek hai (OK), so since you got the setup from last time for a similar problem, this time we'll work in the usual direction from the start of the program where we ask the user to enter a string and store it in a variable, which we'll call enteredTextWithS this time. In pure JavaScript, we use "+T2C.MSG.JS.TERMINAL_GETINPUTBYASKING+" for "+T2C.MSG.EN.TERMINAL_GETINPUTBYASKING+". As before, you'll drag in a type-in-code block, and type in the code."),o.clear(),Blockly.svgResize(o),ce(document.getElementById("output-container").querySelectorAll(".table-cell")[0]),ge(),a.createToolboxBlock("type_in_get_input_with_s"),o.options.maxInstances.type_in_get_input_with_s=1},isComplete:function(){return!0},animate:function(){return!0},finish:function(){}})),n.addTask(new r((function(){var e=o.getAllBlocks().filter((function(e){return"text"===e.type&&"string"==typeof e.getFieldValue("TEXT")&&-1!==e.getFieldValue("TEXT").toLowerCase().indexOf("with an s")})),t=o.getAllBlocks().filter((function(t){return("text_input"===t.type||"js_text_input"===t.type)&&-1!==e.indexOf(t.getInputTargetBlock("TEXT"))})),n=o.getAllBlocks().filter((function(e){return"variables_set"===e.type&&-1!==t.indexOf(e.getInputTargetBlock("VALUE"))&&"enteredTextWithS"===e.getField("VAR").getText()}));return 1===e.length&&1===t.length&&1===n.length}),new s((function(){return"Drag in the type-in-code block, and type the necessary code to ask the user for a string with an s and store it in a variable enteredTextWithS. Be sure the message contains the text 'with an s' to let the user know that his/her string needs at least one s and to use the JavaScript "+T2C.MSG.JS.TERMINAL_GETINPUTBYASKING+" instead of "+T2C.MSG.EN.TERMINAL_GETINPUTBYASKING+"."}),{startPosition:fe(o,null,{},50,document.getElementById("top-header").offsetHeight+50)}))),n.addTask(new r((function(){return!0}),{start:function(){return!0},isComplete:function(){return!0},animate:function(){return!0},finish:function(){alert("✔ Acchaa (Good), so last time we got the position of the comma so we could get the last name which came before it and the first name which came two places after. Do you remember what we used to do this? Just to make it more interesting, we'll give you the choices in JavaScript this time and see if you can figure out the equivalences.");for(var e="Which of the following can be used to get the position of a needle (string) appearing in another one (haystack)? (Enter a, b, c, or d.)\nA. "+T2C.MSG.currentLanguage.TERMINAL_GETCHARACTERNUMBER+"\nB. "+T2C.MSG.currentLanguage.TERMINAL_FINDFIRSTOCCURRENCEOFTEXT+"\nC. "+T2C.MSG.currentLanguage.TERMINAL_LENGTH+"\nD. "+T2C.MSG.currentLanguage.TERMINAL_GETTEXTFROMPOSITIONNUMBER,t=prompt(e);"string"==typeof t&&!t.toLowerCase().startsWith("b");)t=prompt("No, "+t[0]+" is not correct. Please try again. "+e);alert((t?"Yes":"OK, we'll tell you")+", B "+T2C.MSG.currentLanguage.TERMINAL_FINDFIRSTOCCURRENCEOFTEXT+" is the correct answer. The solution to the last problem could be thought of as taking a piece of paper with say |Doe, Jane|, making cuts around the comma |Doe|, |Jane| using "+T2C.MSG.currentLanguage.TERMINAL_FINDFIRSTOCCURRENCEOFTEXT+" to determine where to cut, "+T2C.MSG.currentLanguage.TERMINAL_GETTEXTFROMPOSITIONNUMBER+" to get the pieces, and + to paste the ones we want to keep (with perhaps a new piece (the space)). No rearrangement is needed here, but the idea is the same. So let's start by determining/storing the position number to cut at."),ce(document.getElementById("output-container").querySelectorAll(".table-cell")[0]),ge(),a.clearToolbox(),["js_text_print","js_text_input","js_text_indexof","js_text_getsubstring","variables_set","variables_get","text"].forEach((function(e,t){a.createToolboxBlock(e,!1),o.options.maxInstances[e]=0})),y(o),a.createToolboxBlock("type_in_set_s_pos"),o.options.maxInstances.type_in_set_s_pos=1}})),n.addTask(new r((function(){var e=o.getAllBlocks().filter((function(e){return"variables_get"===e.type&&"enteredTextWithS"===e.getField("VAR").getText()})),t=o.getAllBlocks().filter((function(e){return"text"===e.type&&"s"===e.getFieldValue("TEXT")})),n=o.getAllBlocks().filter((function(n){return("t2c_text_indexof"===n.type||"js_text_indexof"===n.type)&&-1!==e.indexOf(n.getInputTargetBlock("VALUE"))&&-1!==t.indexOf(n.getInputTargetBlock("FIND"))})),i=o.getAllBlocks().filter((function(e){return"variables_set"===e.type&&-1!==n.indexOf(e.getInputTargetBlock("VALUE"))&&"sPosition"===e.getField("VAR").getText()})),r=o.getAllBlocks().filter((function(e){return"text"===e.type&&"string"==typeof e.getFieldValue("TEXT")&&-1!==e.getFieldValue("TEXT").toLowerCase().indexOf("with an s")})),a=o.getAllBlocks().filter((function(e){return("text_input"===e.type||"js_text_input"===e.type)&&-1!==r.indexOf(e.getInputTargetBlock("TEXT"))})),l=o.getAllBlocks().filter((function(e){return"variables_set"===e.type&&-1!==i.indexOf(e.getNextBlock())&&-1!==a.indexOf(e.getInputTargetBlock("VALUE"))&&"enteredTextWithS"===e.getField("VAR").getText()}));return 1===e.length&&1===t.length&&1===n.length&&1===i.length&&1===r.length&&1===a.length&&1===l.length}),new s((function(){var e=o.getAllBlocks().find((function(e){return"variables_set"===e.type&&"enteredTextWithS"===e.getField("VAR").getText()})),t=o.getAllBlocks().find((function(e){return"variables_set"===e.type&&"sPosition"===e.getField("VAR").getText()}));return t&&t.getNextBlock()===e?"The "+T2C.MSG.currentLanguage.TERMINAL_LET+" variable block declaring sPosition must go below the "+T2C.MSG.currentLanguage.TERMINAL_LET+" variable block setting enteredTextWithS because it won't be able to find the position of the s in the entered string if it hasn't been entered yet! Remember instructions are run from top to bottom.":t&&null===t.getPreviousBlock()?"Place the "+T2C.MSG.currentLanguage.TERMINAL_LET+" variable block declaring sPosition below the "+T2C.MSG.currentLanguage.TERMINAL_LET+" variable block setting enteredTextWithS, because the computer uses this variable to determine what sPosition is.":"Drag the type-in-code block, and attach it below the previous "+T2C.MSG.currentLanguage.TERMINAL_LET+" block. Then type the necessary code to store the position number of the (first) _ from the value of enteredTextWithS in the variable called _Position filling in the blank with the character(s) in the same case (lower or upper) that you're searching for."}),{startPosition:fe(o,null,{},50,document.getElementById("top-header").offsetHeight+50)}))),n.addTask(new r((function(){return!0}),{start:function(){return!0},isComplete:function(){return!0},animate:function(){return!0},finish:function(){alert('✔ Bahut acchaa (Very good), so now let\'s get the text before the first s. E.g., for "Mississippi", we\'d want "'+d+'". The equivalent of '+T2C.MSG.EN.TERMINAL_GETTEXTFROMPOSITIONNUMBER+" in "+T2C.MSG.currentLanguage.LANGUAGE_NAME+" is "+T2C.MSG.currentLanguage.TERMINAL_GETTEXTFROMPOSITIONNUMBER+" except you'll only use one set of parentheses with the starting and ending positions separated by a comma. You can figure out how you could get the numerical starting and ending positions from enteredTextWithS and sPosition in "+T2C.MSG.currentLanguage.LANGUAGE_NAME+", right?"),ce(document.getElementById("output-container").querySelectorAll(".table-cell")[0]),ge(),a.removeToolboxBlocks((function(e){return"type_in_set_s_pos"===e.getAttribute("type")})),y(o),a.createToolboxBlock("type_in_set_before_s"),o.options.maxInstances.type_in_set_before_s=1}})),n.addTask(new r((function(){var e=o.getAllBlocks().filter((function(e){return"variables_get"===e.type&&"enteredTextWithS"===e.getField("VAR").getText()})),t=o.getAllBlocks().filter((function(e){return"variables_get"===e.type&&"sPosition"===e.getField("VAR").getText()})),n=o.getAllBlocks().filter((function(e){return"math_number"===e.type&&0===e.getFieldValue("NUM")})),i=o.getAllBlocks().filter((function(o){return("t2c_text_getsubstring"===o.type||"js_text_getsubstring"===o.type)&&-1!==e.indexOf(o.getInputTargetBlock("STRING"))&&-1!==n.indexOf(o.getInputTargetBlock("AT1"))&&-1!==t.indexOf(o.getInputTargetBlock("AT2"))})),r=o.getAllBlocks().filter((function(e){return"variables_set"===e.type&&-1!==i.indexOf(e.getInputTargetBlock("VALUE"))&&"beforeS"===e.getField("VAR").getText()})),a=o.getAllBlocks().filter((function(e){return"text"===e.type&&"s"===e.getFieldValue("TEXT")})),l=o.getAllBlocks().filter((function(t){return("t2c_text_indexof"===t.type||"js_text_indexof"===t.type)&&-1!==e.indexOf(t.getInputTargetBlock("VALUE"))&&-1!==a.indexOf(t.getInputTargetBlock("FIND"))})),s=o.getAllBlocks().filter((function(e){return"variables_set"===e.type&&-1!==r.indexOf(e.getNextBlock())&&-1!==l.indexOf(e.getInputTargetBlock("VALUE"))&&"sPosition"===e.getField("VAR").getText()})),u=o.getAllBlocks().filter((function(e){return"text"===e.type&&"string"==typeof e.getFieldValue("TEXT")&&-1!==e.getFieldValue("TEXT").toLowerCase().indexOf("with an s")})),c=o.getAllBlocks().filter((function(e){return("text_input"===e.type||"js_text_input"===e.type)&&-1!==u.indexOf(e.getInputTargetBlock("TEXT"))})),g=o.getAllBlocks().filter((function(e){return"variables_set"===e.type&&-1!==s.indexOf(e.getNextBlock())&&-1!==c.indexOf(e.getInputTargetBlock("VALUE"))&&"enteredTextWithS"===e.getField("VAR").getText()}));return 2===e.length&&1===t.length&&1===n.length&&1===i.length&&1===r.length&&1===a.length&&1===l.length&&1===s.length&&1===u.length&&1===c.length&&1===g.length}),new s((function(){o.getAllBlocks().find((function(e){return"variables_set"===e.type&&"enteredTextWithS"===e.getField("VAR").getText()})),o.getAllBlocks().find((function(e){return"variables_set"===e.type&&"sPosition"===e.getField("VAR").getText()}));var e=o.getAllBlocks().find((function(e){return"variables_set"===e.type&&"beforeS"===e.getField("VAR").getText()}));if(e&&null!==e.getNextBlock()){var t="variables_set"===e.getNextBlock().type&&e.getNextBlock().getField("VAR").getText();return"The "+T2C.MSG.currentLanguage.TERMINAL_LET+" variable block setting beforeS must go below the "+T2C.MSG.currentLanguage.TERMINAL_LET+" variable block setting "+t+" because the computer uses this one to determine what beforeS is. Since instructions are run from top to bottom, it won't know what "+t+" means, otherwise!"}return e&&null===e.getPreviousBlock()?"Place the "+T2C.MSG.currentLanguage.TERMINAL_LET+" variable block declaring beforeS below the "+T2C.MSG.currentLanguage.TERMINAL_LET+" variable block setting sPosition, because the computer uses this variable to determine what beforeS is.":"Drag the type-in-code block, and attach it below the previous "+T2C.MSG.currentLanguage.TERMINAL_LET+" variable block setting sPosition. Then type the necessary code to store the text coming before the first s of the user input in beforeS (assuming there was an s). E.g., for Mississippi, have it store "+d}),{startPosition:fe(o,null,{},50,document.getElementById("top-header").offsetHeight+50)}))),n.addTask(new r((function(){return!0}),{start:function(){return!0},isComplete:function(){return!0},animate:function(){return!0},finish:function(){alert('✔ Mahaan (Great)! So now let\'s get the text after the s. E.g., for "Mississippi", we\'d want "'+h+'".'),ce(document.getElementById("output-container").querySelectorAll(".table-cell")[0]),ge(),a.removeToolboxBlocks((function(e){return"type_in_set_before_s"===e.getAttribute("type")})),y(o),a.createToolboxBlock("type_in_set_after_s"),o.options.maxInstances.type_in_set_after_s=1}})),n.addTask(new r((function(){var e=o.getAllBlocks().filter((function(e){return"variables_get"===e.type&&"enteredTextWithS"===e.getField("VAR").getText()})),t=o.getAllBlocks().filter((function(t){return"t2c_text_length"===t.type&&-1!==e.indexOf(t.getInputTargetBlock("VALUE"))})),n=o.getAllBlocks().filter((function(e){return"math_number"===e.type&&1===e.getFieldValue("NUM")})),i=o.getAllBlocks().filter((function(e){return"variables_get"===e.type&&"sPosition"===e.getField("VAR").getText()})),r=o.getAllBlocks().filter((function(e){return"math_arithmetic_basic"===e.type&&-1!==i.indexOf(e.getInputTargetBlock("A"))&&-1!==n.indexOf(e.getInputTargetBlock("B"))&&"ADD"==e.getFieldValue("OP")})),a=o.getAllBlocks().filter((function(n){return("t2c_text_getsubstring"===n.type||"js_text_getsubstring"===n.type)&&-1!==e.indexOf(n.getInputTargetBlock("STRING"))&&-1!==r.indexOf(n.getInputTargetBlock("AT1"))&&-1!==t.indexOf(n.getInputTargetBlock("AT2"))})),l=o.getAllBlocks().filter((function(e){return"variables_set"===e.type&&-1!==a.indexOf(e.getInputTargetBlock("VALUE"))&&"afterS"===e.getField("VAR").getText()})),s=o.getAllBlocks().filter((function(e){return"math_number"===e.type&&0===e.getFieldValue("NUM")})),u=o.getAllBlocks().filter((function(t){return("t2c_text_getsubstring"===t.type||"js_text_getsubstring"===t.type)&&-1!==e.indexOf(t.getInputTargetBlock("STRING"))&&-1!==s.indexOf(t.getInputTargetBlock("AT1"))&&-1!==i.indexOf(t.getInputTargetBlock("AT2"))})),c=o.getAllBlocks().filter((function(e){return"variables_set"===e.type&&-1!==u.indexOf(e.getInputTargetBlock("VALUE"))&&"beforeS"===e.getField("VAR").getText()})),g=o.getAllBlocks().filter((function(e){return"text"===e.type&&"s"==e.getFieldValue("TEXT")})),d=o.getAllBlocks().filter((function(t){return("t2c_text_indexof"===t.type||"js_text_indexof"===t.type)&&-1!==e.indexOf(t.getInputTargetBlock("VALUE"))&&-1!==g.indexOf(t.getInputTargetBlock("FIND"))})),h=o.getAllBlocks().filter((function(e){return"variables_set"===e.type&&-1!==c.indexOf(e.getNextBlock())&&-1!==d.indexOf(e.getInputTargetBlock("VALUE"))&&"sPosition"===e.getField("VAR").getText()})),p=o.getAllBlocks().filter((function(e){return"text"===e.type&&"string"==typeof e.getFieldValue("TEXT")&&-1!==e.getFieldValue("TEXT").toLowerCase().indexOf("with an s")})),f=o.getAllBlocks().filter((function(e){return("text_input"===e.type||"js_text_input"===e.type)&&-1!==p.indexOf(e.getInputTargetBlock("TEXT"))})),m=o.getAllBlocks().filter((function(e){return"variables_set"===e.type&&-1!==h.indexOf(e.getNextBlock())&&-1!==f.indexOf(e.getInputTargetBlock("VALUE"))&&"enteredTextWithS"===e.getField("VAR").getText()}));return 4===e.length&&1===t.length&&1===n.length&&2===i.length&&1===r.length&&1===a.length&&1===l.length&&1===s.length&&1===u.length&&1===c.length&&1===g.length&&1===d.length&&1===h.length&&1===p.length&&1===f.length&&1===m.length}),new s((function(){o.getAllBlocks().find((function(e){return"variables_set"===e.type&&"enteredTextWithS"===e.getField("VAR").getText()})),o.getAllBlocks().find((function(e){return"variables_set"===e.type&&"sPosition"===e.getField("VAR").getText()}));var e=o.getAllBlocks().find((function(e){return"variables_set"===e.type&&"afterS"===e.getField("VAR").getText()})),t=o.getAllBlocks().find((function(e){return"variables_set"===e.type&&"beforeS"===e.getField("VAR").getText()}));if(e&&null!==e.getNextBlock()&&e.getNextBlock()!==t){var n="variables_set"===e.getNextBlock().type&&e.getNextBlock().getField("VAR").getText();return"The "+T2C.MSG.currentLanguage.TERMINAL_LET+" variable block setting afterS must go below the "+T2C.MSG.currentLanguage.TERMINAL_LET+" variable block setting "+n+" because the computer uses this one to determine what afterS is. Since instructions are run from top to bottom, it won't know what "+n+" means, otherwise!"}return!e||e.getNextBlock()!==t&&null!==e.getPreviousBlock()?"Drag the type-in-code block, and attach it below the previous "+T2C.MSG.currentLanguage.TERMINAL_LET+" variable block setting beforeS. Then type the necessary code to store the text coming after the first s of the user input in afterS (assuming there was an s).":"Place the new "+T2C.MSG.currentLanguage.TERMINAL_LET+" variable block setting afterS below the previous "+T2C.MSG.currentLanguage.TERMINAL_LET+" block setting beforeS. E.g., for an entered string of Mississippi, you'd display "+h+"."}),{startPosition:fe(o,null,{},50,document.getElementById("top-header").offsetHeight+50)}))),n.addTask(new r((function(){return!0}),{start:function(){return!0},isComplete:function(){return!0},animate:function(){return!0},finish:function(){alert("✔✔ Excellent, so now we display the result of pasting, which will be the same in "+T2C.MSG.currentLanguage.LANGUAGE_NAME+" that it was in "+T2C.MSG.EN.LANGUAGE_NAME+". E.g., for an input of Mississippi , we'd have a beforeS of "+d+", an afterS of "+h+" and would want "+p+"."),ce(document.getElementById("output-container").querySelectorAll(".table-cell")[0]),ge(),a.removeToolboxBlocks((function(e){return"type_in_set_after_s"===e.getAttribute("type")})),y(o),a.createToolboxBlock("type_in_display_s_replaced_with_dollar"),o.options.maxInstances.type_in_display_s_replaced_with_dollar=1}})),n.addTask(new r((function(){var e=o.getAllBlocks().filter((function(e){return"variables_get"===e.type&&"afterS"===e.getField("VAR").getText()})),t=o.getAllBlocks().filter((function(e){return"text"===e.type&&"$"==e.getFieldValue("TEXT")})),n=o.getAllBlocks().filter((function(n){return"t2c_text_join"===n.type&&-1!==t.indexOf(n.getInputTargetBlock("A"))&&-1!==e.indexOf(n.getInputTargetBlock("B"))})),i=o.getAllBlocks().filter((function(e){return"variables_get"===e.type&&"beforeS"===e.getField("VAR").getText()})),r=o.getAllBlocks().filter((function(e){return"t2c_text_join"===e.type&&-1!==i.indexOf(e.getInputTargetBlock("A"))&&-1!==n.indexOf(e.getInputTargetBlock("B"))})),a=o.getAllBlocks().filter((function(e){return("text_print"===e.type||"js_text_print"===e.type)&&null===e.getNextBlock()&&-1!==r.indexOf(e.getInputTargetBlock("TEXT"))})),l=o.getAllBlocks().filter((function(e){return"variables_get"===e.type&&"enteredTextWithS"===e.getField("VAR").getText()})),s=o.getAllBlocks().filter((function(e){return"t2c_text_length"===e.type&&-1!==l.indexOf(e.getInputTargetBlock("VALUE"))})),u=o.getAllBlocks().filter((function(e){return"math_number"===e.type&&1===e.getFieldValue("NUM")})),c=o.getAllBlocks().filter((function(e){return"variables_get"===e.type&&"sPosition"===e.getField("VAR").getText()})),g=o.getAllBlocks().filter((function(e){return"math_arithmetic_basic"===e.type&&-1!==c.indexOf(e.getInputTargetBlock("A"))&&-1!==u.indexOf(e.getInputTargetBlock("B"))&&"ADD"==e.getFieldValue("OP")})),d=o.getAllBlocks().filter((function(e){return("t2c_text_getsubstring"===e.type||"js_text_getsubstring"===e.type)&&-1!==l.indexOf(e.getInputTargetBlock("STRING"))&&-1!==g.indexOf(e.getInputTargetBlock("AT1"))&&-1!==s.indexOf(e.getInputTargetBlock("AT2"))})),h=o.getAllBlocks().filter((function(e){return"variables_set"===e.type&&-1!==d.indexOf(e.getInputTargetBlock("VALUE"))&&"afterS"===e.getField("VAR").getText()&&-1!==a.indexOf(e.getNextBlock())})),p=o.getAllBlocks().filter((function(e){return"math_number"===e.type&&0===e.getFieldValue("NUM")})),f=o.getAllBlocks().filter((function(e){return("t2c_text_getsubstring"===e.type||"js_text_getsubstring"===e.type)&&-1!==l.indexOf(e.getInputTargetBlock("STRING"))&&-1!==p.indexOf(e.getInputTargetBlock("AT1"))&&-1!==c.indexOf(e.getInputTargetBlock("AT2"))})),m=o.getAllBlocks().filter((function(e){return"variables_set"===e.type&&-1!==f.indexOf(e.getInputTargetBlock("VALUE"))&&"beforeS"===e.getField("VAR").getText()&&-1!==h.indexOf(e.getNextBlock())})),y=o.getAllBlocks().filter((function(e){return"text"===e.type&&"s"==e.getFieldValue("TEXT")})),T=o.getAllBlocks().filter((function(e){return("t2c_text_indexof"===e.type||"js_text_indexof"===e.type)&&-1!==l.indexOf(e.getInputTargetBlock("VALUE"))&&-1!==y.indexOf(e.getInputTargetBlock("FIND"))})),_=o.getAllBlocks().filter((function(e){return"variables_set"===e.type&&-1!==m.indexOf(e.getNextBlock())&&-1!==T.indexOf(e.getInputTargetBlock("VALUE"))&&"sPosition"===e.getField("VAR").getText()})),b=o.getAllBlocks().filter((function(e){return"text"===e.type&&"string"==typeof e.getFieldValue("TEXT")&&-1!==e.getFieldValue("TEXT").toLowerCase().indexOf("with an s")})),k=o.getAllBlocks().filter((function(e){return("text_input"===e.type||"js_text_input"===e.type)&&-1!==b.indexOf(e.getInputTargetBlock("TEXT"))})),x=o.getAllBlocks().filter((function(e){return"variables_set"===e.type&&-1!==_.indexOf(e.getNextBlock())&&-1!==k.indexOf(e.getInputTargetBlock("VALUE"))&&"enteredTextWithS"===e.getField("VAR").getText()}));return 1===e.length&&1===t.length&&1===n.length&&1===i.length&&1===r.length&&1===a.length&&4===l.length&&1===s.length&&1===u.length&&2===c.length&&1===g.length&&1===d.length&&1===h.length&&1===p.length&&1===f.length&&1===m.length&&1===y.length&&1===T.length&&1===_.length&&1===b.length&&1===k.length&&1===x.length}),new s((function(){var e=o.getAllBlocks().find((function(e){return"variables_set"===e.type&&"enteredTextWithS"===e.getField("VAR").getText()})),t=o.getAllBlocks().find((function(e){return"text_print"===e.type||"js_text_print"===e.type}));if(e&&t&&t.getNextBlock()===e)return"The "+T2C.MSG.currentLanguage.TERMINAL_DISPLAY+" block must go below the "+T2C.MSG.currentLanguage.TERMINAL_LET+" variable block setting enteredTextWithS because the computer uses enteredTextWithS in beforeS and afterS, both which need enteredTextWithS to determine what they are. Since instructions are run from top to bottom, it won't be able to determine beforeS and afterS, which are used in the "+T2C.MSG.currentLanguage.TERMINAL_DISPLAY+" otherwise!";if(t&&null!==t.getNextBlock()){var n="variables_set"===t.getNextBlock().type&&t.getNextBlock().getField("VAR").getText();return"The "+T2C.MSG.currentLanguage.TERMINAL_DISPLAY+" block must go below the "+T2C.MSG.currentLanguage.TERMINAL_LET+" variable block setting "+n+" because the computer uses "+n+" in what it displays! Since instructions are run from top to bottom, it won't know what "+n+" means, otherwise!"}return t&&null===t.getPreviousBlock()?"Place the new "+T2C.MSG.currentLanguage.TERMINAL_DISPLAY+" block below the previous "+T2C.MSG.currentLanguage.TERMINAL_LET+" block setting afterS.":"Drag the type-in-code block, and type the necessary code to display the user's entered string with its first s replaced by a $ (assuming the user typed in a string with at least one s). E.g., for an entered string of Mississippi, you'd display "+p+"."}),{startPosition:fe(o,null,{},50,document.getElementById("top-header").offsetHeight+50)}))),function(e){e.addTask(new r((function(){return document.getElementById("output-container").classList.contains("show-container")}),new u([new s((function(){return T2C.MSG.currentLanguage.BUTTON_RUN_CODE}),{startPosition:{x:document.getElementById("run-code-button").offsetLeft+document.getElementById("run-code-button").offsetWidth,y:document.getElementById("run-code-button").offsetTop+document.getElementById("run-code-button").offsetHeight}}),new l(m,{totalSteps:100,toggleSteps:25,startPosition:{x:document.getElementById("run-code-button").offsetLeft+document.getElementById("run-code-button").offsetWidth/2,y:document.getElementById("run-code-button").offsetTop+document.getElementById("run-code-button").offsetHeight/2}})])))}(n),function(e,t){var n=0;function o(){t.style.color=n%50<25?"#a00":"#000",++n<200&&requestAnimationFrame(o)}e.addTask(new r((function(){return n>=200}),{start:function(){t.style.verticalAlign="top",requestAnimationFrame(o)},isComplete:function(){return!0},animate:function(){return!0}}))}(n,document.getElementById("output-container").querySelectorAll(".table-cell")[0]),n.addTask(new r((function(){return!0}),{start:function(){return!0},isComplete:function(){return!0},animate:function(){return!0},finish:function(){alert("✔✔✔ Outstanding! And with that, Mission # 7 is accomplished and you just typed an entire program in pure JavaScript! That wasn't too bad was it? In the next mission 8, you'll get a person's first/last initials from their first and last name. As you did in this mission, you'll be typing code in pure JavaScript except you'll be returning to the "+T2C.MSG.JS.TERMINAL_GETCHARACTERNUMBER+" to get single characters at given positions. Phir milenge (See you again)!"),ge(),a.clearToolbox(),["code_statement"].forEach((function(e,t){a.createToolboxBlock(e,!1),o.options.maxInstances[e]=maxBlocks[t]}))}})),n},function(e,t){var n=e||new c,o=t||Blockly.getMainWorkspace(),a=new f(o),g="Mississippi".indexOf("s");"Mississippi".substring(0,g),"Mississippi".substring(g+1),o.setScale(1),Object(i.f)(o);var d=document.createElement("div");return d.innerText="👆",d.id="ptr",d.style.fontSize="x-large",d.style.position="absolute",d.style.zIndex="1001",document.getElementById("blockly-div").appendChild(d),n.addTask(new r((function(){return T2C.MSG.currentLanguage===T2C.MSG.JS}),{start:function(){var e=T2C.MSG.currentLanguage===T2C.MSG.JS?"":"So to start, select JavaScript from the dropdown menu at the top and watch how the blocks in the toolbox transform to their JavaScript equivalents.";a.clearToolbox(),["text_print","text_input","t2c_text_indexof","t2c_text_charat","variables_set","variables_get"].forEach((function(e,t){a.createToolboxBlock(e,!1),o.options.maxInstances[e]=0})),alert("In this mission, you'll ask the user for their first and last name separated by a space (output from Mission # 6) and print their initials separated by periods. For example, for an input of Jane Doe, you'd output J.D. Once again you're going to work in pure JavaScript, but this time you'll accomplish the task using "+T2C.MSG.JS.TERMINAL_FINDFIRSTOCCURRENCEOFTEXT+" and "+T2C.MSG.JS.TERMINAL_GETCHARACTERNUMBER+" instead of "+T2C.MSG.JS.TERMINAL_FINDFIRSTOCCURRENCEOFTEXT+" and "+T2C.MSG.JS.TERMINAL_GETTEXTFROMPOSITIONNUMBER+". You'll also do this with only two lines of code, one to store the input and one to display the output! "+e),o.clear(),Blockly.svgResize(o),ye(document.getElementById("output-container").querySelectorAll(".table-cell")[0]),Te()},isComplete:function(){return!0},animate:function(){return!0},finish:function(){}})),n.addTask(new r((function(){return!0}),{start:function(){alert("Theek hai (OK), so let's ask the user to enter their full name (no middle name) in the form first last such as Jane Doe, and store it in a variable fullName. Remember that in pure JavaScript, we use "+T2C.MSG.JS.TERMINAL_GETINPUTBYASKING+" for "+T2C.MSG.EN.TERMINAL_GETINPUTBYASKING+". As before, you'll drag in a type-in-code block, and type in the code."),o.clear(),Blockly.svgResize(o),ye(document.getElementById("output-container").querySelectorAll(".table-cell")[0]),Te(),a.createToolboxBlock("type_in_get_full_name"),o.options.maxInstances.type_in_get_full_name=1},isComplete:function(){return!0},animate:function(){return!0},finish:function(){}})),n.addTask(new r((function(){var e=o.getAllBlocks().filter((function(e){return"text"===e.type&&"string"==typeof e.getFieldValue("TEXT")&&-1!==e.getFieldValue("TEXT").toLowerCase().indexOf("full name")})),t=o.getAllBlocks().filter((function(t){return("text_input"===t.type||"js_text_input"===t.type)&&-1!==e.indexOf(t.getInputTargetBlock("TEXT"))})),n=o.getAllBlocks().filter((function(e){return"variables_set"===e.type&&-1!==t.indexOf(e.getInputTargetBlock("VALUE"))&&"fullName"===e.getField("VAR").getText()}));return 1===e.length&&1===t.length&&1===n.length}),new s((function(){return"Drag in the type-in-code block, and type the necessary code to ask the user for their full name in the form first last (no middle) and store it in a variable fullName. Be sure the message contains the text 'full name' to let the user know to type in his/her first and last name. Also, use the JavaScript "+T2C.MSG.JS.TERMINAL_GETINPUTBYASKING+" instead of "+T2C.MSG.EN.TERMINAL_GETINPUTBYASKING+"."}),{startPosition:xe(o,null,{},50,document.getElementById("top-header").offsetHeight+50)}))),n.addTask(new r((function(){return!0}),{start:function(){return!0},isComplete:function(){return!0},animate:function(){return!0},finish:function(){alert("✔ Acchaa (Good), so now with one more line of code we're going to finish today's mission! In this next step, you're going to display the user's initials (assuming he/she entered his/her correct name in the form first last). So for Jane Doe, you'd output J.D. (with the periods between the first and last initials)."),ye(document.getElementById("output-container").querySelectorAll(".table-cell")[0]),Te(),a.clearToolbox(),["js_text_print","js_text_input","js_text_indexof","js_text_charat","variables_set","variables_get","text"].forEach((function(e,t){a.createToolboxBlock(e,!1),o.options.maxInstances[e]=0})),function(e){var t=e.options.maxInstances;e.options.maxInstances={},e.getAllBlocks().forEach((function(t){e.options.maxInstances[t.type]=++e.options.maxInstances[t.type]||1})),Object.keys(t).forEach((function(n){e.options.maxInstances[n]=e.options.maxInstances[n]||t[n]}))}(o),a.createToolboxBlock("type_in_print_initials"),o.options.maxInstances.type_in_print_initials=1}})),n.addTask(new r((function(){var e=o.getAllBlocks().filter((function(e){return"text"===e.type&&"."===e.getFieldValue("TEXT")})),t=o.getAllBlocks().filter((function(e){return"math_number"===e.type&&1===e.getFieldValue("NUM")})),n=o.getAllBlocks().filter((function(e){return"text"===e.type&&" "===e.getFieldValue("TEXT")})),i=o.getAllBlocks().filter((function(e){return"variables_get"===e.type&&"fullName"===e.getField("VAR").getText()})),r=o.getAllBlocks().filter((function(e){return("js_text_indexof"===e.type||"t2c_text_indexof"===e.type)&&-1!==i.indexOf(e.getInputTargetBlock("VALUE"))&&-1!==n.indexOf(e.getInputTargetBlock("FIND"))})),a=o.getAllBlocks().filter((function(e){return"math_arithmetic_basic"===e.type&&-1!==r.indexOf(e.getInputTargetBlock("A"))&&-1!==t.indexOf(e.getInputTargetBlock("B"))&&"ADD"==e.getFieldValue("OP")})),l=o.getAllBlocks().filter((function(e){return("js_text_charat"===e.type||"t2c_text_charat"===e.type)&&-1!==i.indexOf(e.getInputTargetBlock("VALUE"))&&-1!==a.indexOf(e.getInputTargetBlock("AT"))})),s=o.getAllBlocks().filter((function(t){return"t2c_text_join"===t.type&&-1!==l.indexOf(t.getInputTargetBlock("A"))&&-1!==e.indexOf(t.getInputTargetBlock("B"))})),u=o.getAllBlocks().filter((function(t){return"t2c_text_join"===t.type&&-1!==e.indexOf(t.getInputTargetBlock("A"))&&-1!==s.indexOf(t.getInputTargetBlock("B"))})),c=o.getAllBlocks().filter((function(e){return"math_number"===e.type&&0===e.getFieldValue("NUM")})),g=o.getAllBlocks().filter((function(e){return("js_text_charat"===e.type||"t2c_text_charat"===e.type)&&-1!==i.indexOf(e.getInputTargetBlock("VALUE"))&&-1!==c.indexOf(e.getInputTargetBlock("AT"))})),d=o.getAllBlocks().filter((function(e){return"t2c_text_join"===e.type&&-1!==g.indexOf(e.getInputTargetBlock("A"))&&-1!==u.indexOf(e.getInputTargetBlock("B"))})),h=o.getAllBlocks().filter((function(e){return("js_text_print"===e.type||"t2c_text_print"===e.type)&&null===e.getNextBlock()&&-1!==d.indexOf(e.getInputTargetBlock("TEXT"))})),p=o.getAllBlocks().filter((function(e){return"text"===e.type&&"text"===e.type&&"string"==typeof e.getFieldValue("TEXT")&&-1!==e.getFieldValue("TEXT").toLowerCase().indexOf("full name")})),f=o.getAllBlocks().filter((function(e){return("js_text_input"===e.type||"t2c_text_input"===e.type)&&-1!==p.indexOf(e.getInputTargetBlock("TEXT"))})),m=o.getAllBlocks().filter((function(e){return"variables_set"===e.type&&-1!==h.indexOf(e.getNextBlock())&&-1!==f.indexOf(e.getInputTargetBlock("VALUE"))&&"fullName"===e.getField("VAR").getText()}));return 2===e.length&&1===t.length&&1===n.length&&3===i.length&&1===r.length&&1===a.length&&1===l.length&&1===s.length&&1===u.length&&1===c.length&&1===g.length&&1===d.length&&1===h.length&&1===p.length&&1===f.length&&1===m.length}),new s((function(){var e=o.getAllBlocks().find((function(e){return"variables_set"===e.type&&"fullName"===e.getField("VAR").getText()})),t=o.getAllBlocks().find((function(e){return"text_print"===e.type||"js_text_print"===e.type}));return e&&t&&t.getNextBlock()===e?"The "+T2C.MSG.currentLanguage.TERMINAL_DISPLAY+" block must go below the "+T2C.MSG.currentLanguage.TERMINAL_LET+" variable block setting fullName because the computer needs to know what the user's name is in order to display his/her initials. Remember that instructions are run from top to bottom.":t&&null===t.getPreviousBlock()?"Place the new "+T2C.MSG.currentLanguage.TERMINAL_DISPLAY+" block below the previous "+T2C.MSG.currentLanguage.TERMINAL_LET+" block setting fullName.":"Drag the type-in-code block, and type the necessary code to display the user's user's initials (assuming he/she entered his/her correct name in the form first last). So for Jane Doe, you'd output J.D. (with the periods between the first and last initials). Do this in one line!"}),{startPosition:xe(o,null,{},50,document.getElementById("top-header").offsetHeight+50)}))),function(e){e.addTask(new r((function(){return document.getElementById("output-container").classList.contains("show-container")}),new u([new s((function(){return T2C.MSG.currentLanguage.BUTTON_RUN_CODE}),{startPosition:{x:document.getElementById("run-code-button").offsetLeft+document.getElementById("run-code-button").offsetWidth,y:document.getElementById("run-code-button").offsetTop+document.getElementById("run-code-button").offsetHeight}}),new l(d,{totalSteps:100,toggleSteps:25,startPosition:{x:document.getElementById("run-code-button").offsetLeft+document.getElementById("run-code-button").offsetWidth/2,y:document.getElementById("run-code-button").offsetTop+document.getElementById("run-code-button").offsetHeight/2}})])))}(n),function(e,t){var n=0;function o(){t.style.color=n%50<25?"#a00":"#000",++n<200&&requestAnimationFrame(o)}e.addTask(new r((function(){return n>=200}),{start:function(){t.style.verticalAlign="top",requestAnimationFrame(o)},isComplete:function(){return!0},animate:function(){return!0}}))}(n,document.getElementById("output-container").querySelectorAll(".table-cell")[0]),n.addTask(new r((function(){return!0}),{start:function(){return!0},isComplete:function(){return!0},animate:function(){return!0},finish:function(){alert("✔✔✔ Outstanding! And with that single line of code wizadry, you got the user's initials and completed Mission # 8! Once again you typed an entire program in pure JavaScript! In the next mission 9, you'll face a new challenge of finding the third item in a list of items separated by commas. As you did in this mission, you'll be typing code in pure JavaScript. Stay tuned and phir milenge (See you again)!"),Te(),a.clearToolbox(),["code_statement"].forEach((function(e,t){a.createToolboxBlock(e,!1),o.options.maxInstances[e]=maxBlocks[t]}))}})),n},function(e,t){var n=e||new c,o=t||Blockly.getMainWorkspace(),a=new f(o);Be.start(),o.setScale(1),Object(i.f)(o);var s=document.createElement("div");function g(e,t){return{start:function(){Be.changeTab(Ae,"Directions",e),Be.changeTab(ve,"Feedback",t),Be.setSelectedTab(Ae)},isComplete:function(){return!1},animate:function(e){return Be.animate(e)}}}function d(e,t,n,o){e.addTask(function(e,t,n){return new r("function"==typeof e?e:function(){return!0},g(t,n))}(t,n,o))}function h(e){e.addTask(new r((function(){return document.getElementById("output-container").classList.contains("show-container")}),new u([g(T2C.MSG.currentLanguage.BUTTON_RUN_CODE,""),new l(s,{totalSteps:100,toggleSteps:25,startPosition:{x:document.getElementById("run-code-button").offsetLeft+document.getElementById("run-code-button").offsetWidth/2,y:document.getElementById("run-code-button").offsetTop+document.getElementById("run-code-button").offsetHeight/2}})])))}function p(e,t){var n=0;function o(){t.style.color=n%50<25?"#a00":"#000",++n<200&&requestAnimationFrame(o)}e.addTask(new r((function(){return n>=200}),{start:function(){t.style.verticalAlign="top",requestAnimationFrame(o)},isComplete:function(){return!0},animate:function(){return!0}}))}function m(e){var t=e.options.maxInstances;e.options.maxInstances={},e.getAllBlocks().forEach((function(t){e.options.maxInstances[t.type]=++e.options.maxInstances[t.type]||1})),Object.keys(t).forEach((function(n){e.options.maxInstances[n]=e.options.maxInstances[n]||t[n]}))}return s.innerText="👆",s.id="ptr",s.style.fontSize="x-large",s.style.position="absolute",s.style.zIndex="1001",document.getElementById("blockly-div").appendChild(s),n.addTask(new r((function(){return T2C.MSG.currentLanguage===T2C.MSG.JS}),new u([g("To start, select JavaScript from the dropdown menu at the top and watch how the blocks in the toolbox transform to their JavaScript equivalents.",""),{start:function(){var e=T2C.MSG.currentLanguage===T2C.MSG.JS?"":"So to start, select JavaScript from the dropdown menu at the top and watch how the blocks in the toolbox transform to their JavaScript equivalents.";a.clearToolbox(),["text_print","text_input","t2c_text_indexof","t2c_text_getsubstring","variables_set","variables_get"].forEach((function(e,t){a.createToolboxBlock(e,!1),o.options.maxInstances[e]=0})),alert("In this mission, you'll ask the user for a list of at least four (chaar in Hindi) items separated by commas and display its third item. For example, for an input of "+Ie+", you'd output "+Oe+" while for an input of "+we+", you'd output "+Ce+". Once again we're going to be working in pure JavaScript. "+e),o.clear(),Blockly.svgResize(o),Re(document.getElementById("output-container").querySelectorAll(".table-cell")[0]),Fe()},isComplete:function(){return!0},animate:function(){return!0},finish:function(){}}]))),n.addTask(new r((function(){return!0}),{start:function(){alert("Theek hai (OK), so as usual, let's start by asking the user to enter a string, this time a list of at least chaar items, separated by commas, and store it in a variable itemList. Drag in a type-in-code block, and type in the code to do this. Be sure the message includes the text 'at least 4' in it so the user knows to enter at least 4 items (separated by commas)."),o.clear(),Blockly.svgResize(o),Re(document.getElementById("output-container").querySelectorAll(".table-cell")[0]),Fe(),a.createToolboxBlock("type_in_get_item_list"),o.options.maxInstances.type_in_get_item_list=1},isComplete:function(){return!0},animate:function(){return!0},finish:function(){}})),d(n,(function(){var e=o.getAllBlocks().filter((function(e){return"text"===e.type&&"string"==typeof e.getFieldValue("TEXT")&&-1!==e.getFieldValue("TEXT").toLowerCase().indexOf("at least 4")})),t=o.getAllBlocks().filter((function(t){return("text_input"===t.type||"js_text_input"===t.type)&&-1!==e.indexOf(t.getInputTargetBlock("TEXT"))})),n=o.getAllBlocks().filter((function(e){return"variables_set"===e.type&&null===e.getNextBlock()&&-1!==t.indexOf(e.getInputTargetBlock("VALUE"))&&"itemList"===e.getField("VAR").getText()}));return 1===e.length&&1===t.length&&1===n.length}),(function(){return"Drag in the type-in-code block, and type the necessary code to ask the user for a list of at least 4 items, separated by commas, and store it in a variable itemList. Be sure the message contains the text 'at least 4' to let the user know to type in a minimum of this number of items."}),(function(){return o.getAllBlocks().find((function(e){return"text"===e.type})),o.getAllBlocks().find((function(e){return"text_input"===e.type||"js_text_input"===e.type})),o.getAllBlocks().find((function(e){return"variables_set"===e.type})),o.getAllBlocks().find((function(e){return"type_in_get_item_list"===e.type}))?Ge.getErrorFeedback():""})),n.addTask(new r((function(){return!0}),{start:function(){alert("✔ Acchaa (Good). Since in this problem we're going to consider multiple sublists of the original one, i.e., lists that contain some (or all) of the items from the original, we're going to display each one as we solve this problem to see what's happening. So now let's start by displaying the original one."),Blockly.svgResize(o),a.removeToolboxBlocks((function(e){return"type_in_get_item_list"===e.getAttribute("type")})),m(o),a.createToolboxBlock("type_in_display_item_list"),o.options.maxInstances.type_in_display_item_list=1},isComplete:function(){return!0},animate:function(){return!0},finish:function(){}})),d(n,(function(){var e=o.getAllBlocks().filter((function(e){return"variables_get"===e.type&&"itemList"===e.getField("VAR").getText()})),t=o.getAllBlocks().filter((function(t){return("text_print"===t.type||"js_text_print"===t.type)&&null===t.getNextBlock()&&-1!==e.indexOf(t.getInputTargetBlock("TEXT"))})),n=o.getAllBlocks().filter((function(e){return"text"===e.type&&"string"==typeof e.getFieldValue("TEXT")&&-1!==e.getFieldValue("TEXT").toLowerCase().indexOf("at least 4")})),i=o.getAllBlocks().filter((function(e){return("text_input"===e.type||"js_text_input"===e.type)&&-1!==n.indexOf(e.getInputTargetBlock("TEXT"))})),r=o.getAllBlocks().filter((function(e){return"variables_set"===e.type&&-1!==t.indexOf(e.getNextBlock())&&-1!==i.indexOf(e.getInputTargetBlock("VALUE"))&&"itemList"===e.getField("VAR").getText()}));return 1===e.length&&1===t.length&&1===n.length&&1===i.length&&1===r.length}),(function(){return"Drag in the type-in-code block, and type the necessary code to display the inputted item list, stored in itemList."}),(function(){o.getAllBlocks().find((function(e){return"variables_get"===e.type}));var e=o.getAllBlocks().find((function(e){return"text_print"===e.type||"js_text_print"===e.type})),t=(o.getAllBlocks().find((function(e){return"text"===e.type})),o.getAllBlocks().find((function(e){return"text_input"===e.type||"js_text_input"===e.type})),o.getAllBlocks().find((function(e){return"variables_set"===e.type}))),n=o.getAllBlocks().find((function(e){return"type_in_display_item_list"===e.type}));return t&&e&&e.getNextBlock()===t?"The "+T2C.MSG.currentLanguage.TERMINAL_DISPLAY+" block must go below the "+T2C.MSG.currentLanguage.TERMINAL_LET+" variable block setting itemList because the computer uses the value of this variable in the "+T2C.MSG.currentLanguage.TERMINAL_DISPLAY+" block. Since instructions are run from top to bottom, it won't know what itemList means, otherwise!":e?"Place the "+T2C.MSG.currentLanguage.TERMINAL_DISPLAY+" block below the "+T2C.MSG.currentLanguage.TERMINAL_LET+" variable block setting itemList so the computer can use the value of this variable in the "+T2C.MSG.currentLanguage.TERMINAL_DISPLAY+" block.":n?Ue.getErrorFeedback():""})),h(n),p(n,document.getElementById("output-container").querySelectorAll(".table-cell")[0]),n.addTask(new r((function(){return!0}),{start:function(){alert("✔ Phir se acchaa (Good again), so now think back to Mission # 5 where we found the text between the first @ and . Do you remember how we did that? Do you think you could use a similar strategy here? If not, what goes wrong?");for(var e="What is the problem? (Enter a, b, c, or d.)\nA. We can only use "+T2C.MSG.currentLanguage.TERMINAL_GETTEXTFROMPOSITIONNUMBER+" to extract text starting from the beginning of a string OR ending at its end and the third item neither starts at the beginning nor ends at its end.\nB. "+T2C.MSG.currentLanguage.TERMINAL_FINDFIRSTOCCURRENCEOFTEXT+" can only be used to get the position of the first occurrence of something in a string and the third item appears between the third and fourth commas.\nC. "+T2C.MSG.currentLanguage.TERMINAL_FINDFIRSTOCCURRENCEOFTEXT+" can only be used to get the position of the first occurrence of something in a string and the third item appears between the second and third commas.\nD. "+T2C.MSG.currentLanguage.TERMINAL_GETCHARACTERNUMBER+" can only be used to get the comma, not a character that comes after it.",t=prompt(e);"string"==typeof t&&!t.toLowerCase().startsWith("c");)t=prompt("No, "+t[0]+" is not correct. Please try again. "+e);for(alert((t?"Yes":"OK, we'll tell you")+", C "+T2C.MSG.currentLanguage.TERMINAL_FINDFIRSTOCCURRENCEOFTEXT+" can only be used to get the position of the first occurrence of something in a string and the third item appears between the second and third commas is the correct answer. So as we did in problem 6, we'll work backwards in steps, trying to use the tools we have to bridge the gap between what we start with and what we want to end up with. For an input of "+Ie+", the output would be "+Oe+"."),e="Which of the following lists could we get "+Oe+" from using only one "+T2C.MSG.currentLanguage.TERMINAL_FINDFIRSTOCCURRENCEOFTEXT+"? (Enter a, b, c, or d.)\nA. "+Ie+"\nB. "+Se+"\nC. "+Ne+"\nD. "+Se.substring(0,Se.lastIndexOf(",")),t=prompt(e);"string"==typeof t&&!t.toLowerCase().startsWith("c");)t=prompt("No, "+t[0]+" is not correct. Please try again. "+e);for(alert((t?"Yes":"OK, we'll tell you")+", C "+Ne+" is the correct answer. We can get the third item of "+Oe+" from "+Ne+"."),e="Now which of the following lists could we get "+Ne+" from using only one "+T2C.MSG.currentLanguage.TERMINAL_FINDFIRSTOCCURRENCEOFTEXT+"? (Enter a, b, c, or d.)\nA. "+Ie+"\nB. "+Se+"\nC. "+Oe+"\nD. "+Ie.substring(0,Ie.lastIndexOf(",")),t=prompt(e);"string"==typeof t&&!t.toLowerCase().startsWith("b");)t=prompt("No, "+t[0]+" is not correct. Please try again. "+e);alert((t?"Exactly":"OK, we'll tell you")+", B "+Se+" is the correct answer. And then finally, we could get this string using only one "+T2C.MSG.currentLanguage.TERMINAL_FINDFIRSTOCCURRENCEOFTEXT+" from the original entered "+Ie+". So to summarize, going forward, we start with "+Ie+", where the desired third item is between the second and third commas, then chop off its first item to get "+Se+" where the desired item is the second one between the first and second commas, chop off its first item to get "+Ne+" where the desired item is now first and appears before the *first* comma. Then we can get the first item in this list, which is the original third item. So let's start by chopping off the first item from itemList."),a.removeToolboxBlocks((function(e){return"type_in_display_item_list"===e.getAttribute("type")})),m(o),a.createToolboxBlock("type_in_set_after_first"),o.options.maxInstances.type_in_set_after_first=1,Re(document.getElementById("output-container").querySelectorAll(".table-cell")[0]),Fe()},isComplete:function(){return!0},animate:function(){return!0},finish:function(){}})),d(n,(function(){var e=o.getAllBlocks().filter((function(e){return"variables_get"===e.type&&"itemList"===e.getField("VAR").getText()})),t=o.getAllBlocks().filter((function(t){return"t2c_text_length"===t.type&&-1!==e.indexOf(t.getInputTargetBlock("VALUE"))})),n=o.getAllBlocks().filter((function(e){return"math_number"===e.type&&1===e.getFieldValue("NUM")})),i=o.getAllBlocks().filter((function(e){return"text"===e.type&&","===e.getFieldValue("TEXT")})),r=o.getAllBlocks().filter((function(t){return("js_text_indexof"===t.type||"t2c_text_indexof"===t.type)&&-1!==e.indexOf(t.getInputTargetBlock("VALUE"))&&-1!==i.indexOf(t.getInputTargetBlock("FIND"))})),a=o.getAllBlocks().filter((function(e){return"math_arithmetic_basic"===e.type&&-1!==r.indexOf(e.getInputTargetBlock("A"))&&-1!==n.indexOf(e.getInputTargetBlock("B"))&&"ADD"===e.getFieldValue("OP")})),l=o.getAllBlocks().filter((function(n){return("js_text_getsubstring"===n.type||"t2c_text_getsubstring"===n.type)&&-1!==e.indexOf(n.getInputTargetBlock("STRING"))&&-1!==a.indexOf(n.getInputTargetBlock("AT1"))&&-1!==t.indexOf(n.getInputTargetBlock("AT2"))})),s=o.getAllBlocks().filter((function(e){return"variables_set"===e.type&&null===e.getNextBlock()&&-1!==l.indexOf(e.getInputTargetBlock("VALUE"))&&"afterFirstComma"===e.getField("VAR").getText()})),u=o.getAllBlocks().filter((function(t){return("text_print"===t.type||"js_text_print"===t.type)&&-1!==s.indexOf(t.getNextBlock())&&-1!==e.indexOf(t.getInputTargetBlock("TEXT"))})),c=o.getAllBlocks().filter((function(e){return"text"===e.type&&"string"==typeof e.getFieldValue("TEXT")&&-1!==e.getFieldValue("TEXT").toLowerCase().indexOf("at least 4")})),g=o.getAllBlocks().filter((function(e){return("text_input"===e.type||"js_text_input"===e.type)&&-1!==c.indexOf(e.getInputTargetBlock("TEXT"))})),d=o.getAllBlocks().filter((function(e){return"variables_set"===e.type&&-1!==u.indexOf(e.getNextBlock())&&-1!==g.indexOf(e.getInputTargetBlock("VALUE"))&&"itemList"===e.getField("VAR").getText()}));return 4===e.length&&1===t.length&&1===n.length&&1===i.length&&1===r.length&&1===a.length&&1===l.length&&1===s.length&&1===u.length&&1===c.length&&1===g.length&&1===d.length}),(function(){return"Drag in the type-in-code block, and type the necessary code to get all items from itemList after the first comma (second item on) and store the result in the variable afterFirstComma. Then place the block below the one displaying the entire list."}),(function(){var e=o.getAllBlocks().filter((function(e){return"variables_get"===e.type&&"itemList"===e.getField("VAR").getText()})),t=o.getAllBlocks().find((function(t){return("text_print"===t.type||"js_text_print"===t.type)&&-1!==e.indexOf(t.getInputTargetBlock("TEXT"))})),n=o.getAllBlocks().find((function(e){return"variables_set"===e.type&&"itemList"===e.getField("VAR").getText()})),i=o.getAllBlocks().find((function(e){return"variables_set"===e.type&&"afterFirstComma"===e.getField("VAR").getText()})),r=o.getAllBlocks().find((function(e){return"type_in_set_after_first"===e.type}));return n&&i&&i.getNextBlock()===n?"The "+T2C.MSG.currentLanguage.TERMINAL_LET+" variable block setting afterFirstComma must go below the "+T2C.MSG.currentLanguage.TERMINAL_LET+" variable block setting itemList because the computer uses this one to determine what afterFirstComma is. Since instructions are run from top to bottom, it won't know what itemList means, otherwise!":n&&t&&t.getNextBlock()===n?"The "+T2C.MSG.currentLanguage.TERMINAL_DISPLAY+" block must go below the "+T2C.MSG.currentLanguage.TERMINAL_LET+" variable block setting itemList because the computer uses the value of this variable in the "+T2C.MSG.currentLanguage.TERMINAL_DISPLAY+" block. Since instructions are run from top to bottom, it won't know what itemList means, otherwise!":t&&i&&t.getNextBlock()!==i?"Place the "+T2C.MSG.currentLanguage.TERMINAL_LET+" variable block setting afterFirstComma below the "+T2C.MSG.currentLanguage.TERMINAL_DISPLAY+" block displaying the original item list.":r?Xe.getErrorFeedback():""})),n.addTask(new r((function(){return!0}),{start:function(){alert("✔ Bahut acchaa (very good), so let's display this new list, which will be the original one with its first item removed."),a.removeToolboxBlocks((function(e){return"type_in_set_after_first"===e.getAttribute("type")})),m(o),a.createToolboxBlock("type_in_display_after_first"),o.options.maxInstances.type_in_display_after_first=1,Re(document.getElementById("output-container").querySelectorAll(".table-cell")[0]),Fe()},isComplete:function(){return!0},animate:function(){return!0},finish:function(){}})),d(n,(function(){var e=o.getAllBlocks().filter((function(e){return"variables_get"===e.type&&"afterFirstComma"===e.getField("VAR").getText()})),t=o.getAllBlocks().filter((function(t){return("text_print"===t.type||"js_text_print"===t.type)&&null===t.getNextBlock()&&-1!==e.indexOf(t.getInputTargetBlock("TEXT"))})),n=o.getAllBlocks().filter((function(e){return"variables_get"===e.type&&"itemList"===e.getField("VAR").getText()})),i=o.getAllBlocks().filter((function(e){return"t2c_text_length"===e.type&&-1!==n.indexOf(e.getInputTargetBlock("VALUE"))})),r=o.getAllBlocks().filter((function(e){return"math_number"===e.type&&1===e.getFieldValue("NUM")})),a=o.getAllBlocks().filter((function(e){return"text"===e.type&&","===e.getFieldValue("TEXT")})),l=o.getAllBlocks().filter((function(e){return("js_text_indexof"===e.type||"t2c_text_indexof"===e.type)&&-1!==n.indexOf(e.getInputTargetBlock("VALUE"))&&-1!==a.indexOf(e.getInputTargetBlock("FIND"))})),s=o.getAllBlocks().filter((function(e){return"math_arithmetic_basic"===e.type&&-1!==l.indexOf(e.getInputTargetBlock("A"))&&-1!==r.indexOf(e.getInputTargetBlock("B"))&&"ADD"===e.getFieldValue("OP")})),u=o.getAllBlocks().filter((function(e){return("js_text_getsubstring"===e.type||"t2c_text_getsubstring"===e.type)&&-1!==n.indexOf(e.getInputTargetBlock("STRING"))&&-1!==s.indexOf(e.getInputTargetBlock("AT1"))&&-1!==i.indexOf(e.getInputTargetBlock("AT2"))})),c=o.getAllBlocks().filter((function(e){return"variables_set"===e.type&&-1!==t.indexOf(e.getNextBlock())&&-1!==u.indexOf(e.getInputTargetBlock("VALUE"))&&"afterFirstComma"===e.getField("VAR").getText()})),g=o.getAllBlocks().filter((function(e){return("text_print"===e.type||"js_text_print"===e.type)&&-1!==c.indexOf(e.getNextBlock())&&-1!==n.indexOf(e.getInputTargetBlock("TEXT"))})),d=o.getAllBlocks().filter((function(e){return"text"===e.type&&"string"==typeof e.getFieldValue("TEXT")&&-1!==e.getFieldValue("TEXT").toLowerCase().indexOf("at least 4")})),h=o.getAllBlocks().filter((function(e){return("text_input"===e.type||"js_text_input"===e.type)&&-1!==d.indexOf(e.getInputTargetBlock("TEXT"))})),p=o.getAllBlocks().filter((function(e){return"variables_set"===e.type&&-1!==g.indexOf(e.getNextBlock())&&-1!==h.indexOf(e.getInputTargetBlock("VALUE"))&&"itemList"===e.getField("VAR").getText()}));return 1===e.length&&1===t.length&&4===n.length&&1===i.length&&1===r.length&&1===a.length&&1===l.length&&1===s.length&&1===u.length&&1===c.length&&1===g.length&&1===d.length&&1===h.length&&1===p.length}),(function(){return"Drag in the type-in-code block, and type the necessary code to display afterFirstComma, which will be all items from itemList after the first comma (second item on). Then place the block below the one setting afterFirstComma."}),(function(){var e=o.getAllBlocks().filter((function(e){return"variables_get"===e.type&&"afterFirstComma"===e.getField("VAR").getText()})),t=o.getAllBlocks().find((function(t){return("text_print"===t.type||"js_text_print"===t.type)&&-1!==e.indexOf(t.getInputTargetBlock("TEXT"))})),n=o.getAllBlocks().filter((function(e){return"variables_get"===e.type&&"itemList"===e.getField("VAR").getText()})),i=o.getAllBlocks().find((function(e){return("text_print"===e.type||"js_text_print"===e.type)&&-1!==n.indexOf(e.getInputTargetBlock("TEXT"))})),r=o.getAllBlocks().find((function(e){return"variables_set"===e.type&&"itemList"===e.getField("VAR").getText()})),a=o.getAllBlocks().find((function(e){return"variables_set"===e.type&&"afterFirstComma"===e.getField("VAR").getText()})),l=o.getAllBlocks().find((function(e){return"type_in_display_after_first"===e.type}));return r&&a&&a.getNextBlock()===r?"The "+T2C.MSG.currentLanguage.TERMINAL_LET+" variable block setting afterFirstComma must go below the "+T2C.MSG.currentLanguage.TERMINAL_LET+" variable block setting itemList because the computer uses this one to determine what afterFirstComma is. Since instructions are run from top to bottom, it won't know what itemList means, otherwise!":r&&i&&i.getNextBlock()===r?"The "+T2C.MSG.currentLanguage.TERMINAL_DISPLAY+" block must go below the "+T2C.MSG.currentLanguage.TERMINAL_LET+" variable block setting itemList because the computer uses the value of this variable in the "+T2C.MSG.currentLanguage.TERMINAL_DISPLAY+" block. Since instructions are run from top to bottom, it won't know what itemList means, otherwise!":a&&t&&t.getNextBlock()===a?"The "+T2C.MSG.currentLanguage.TERMINAL_DISPLAY+" block must go below the "+T2C.MSG.currentLanguage.TERMINAL_LET+" variable block setting afterFirstComma because the computer uses the value of this variable in the "+T2C.MSG.currentLanguage.TERMINAL_DISPLAY+" block. Since instructions are run from top to bottom, it won't know what afterFirstComma means, otherwise!":t?"Place the "+T2C.MSG.currentLanguage.TERMINAL_DISPLAY+" block displaying afterFirstComma below the "+T2C.MSG.currentLanguage.TERMINAL_LET+" variable block setting its value.":l?je.getErrorFeedback():""})),h(n),p(n,document.getElementById("output-container").querySelectorAll(".table-cell")[0]),n.addTask(new r((function(){return!0}),{start:function(){alert("✔ Phir se bahut acchaa (very good again), so now let's get the original list with its first two items removed by removing the first one from this new sublist."),a.removeToolboxBlocks((function(e){return"type_in_display_after_first"===e.getAttribute("type")})),m(o),a.createToolboxBlock("type_in_set_after_second"),o.options.maxInstances.type_in_set_after_second=1,Re(document.getElementById("output-container").querySelectorAll(".table-cell")[0]),Fe()},isComplete:function(){return!0},animate:function(){return!0},finish:function(){}})),d(n,(function(){var e=o.getAllBlocks().filter((function(e){return"variables_get"===e.type&&"afterFirstComma"===e.getField("VAR").getText()})),t=o.getAllBlocks().filter((function(t){return"t2c_text_length"===t.type&&-1!==e.indexOf(t.getInputTargetBlock("VALUE"))})),n=o.getAllBlocks().filter((function(e){return"math_number"===e.type&&1===e.getFieldValue("NUM")})),i=o.getAllBlocks().filter((function(e){return"text"===e.type&&","===e.getFieldValue("TEXT")})),r=o.getAllBlocks().filter((function(t){return("js_text_indexof"===t.type||"t2c_text_indexof"===t.type)&&-1!==e.indexOf(t.getInputTargetBlock("VALUE"))&&-1!==i.indexOf(t.getInputTargetBlock("FIND"))})),a=o.getAllBlocks().filter((function(e){return"math_arithmetic_basic"===e.type&&-1!==r.indexOf(e.getInputTargetBlock("A"))&&-1!==n.indexOf(e.getInputTargetBlock("B"))&&"ADD"===e.getFieldValue("OP")})),l=o.getAllBlocks().filter((function(n){return("js_text_getsubstring"===n.type||"t2c_text_getsubstring"===n.type)&&-1!==e.indexOf(n.getInputTargetBlock("STRING"))&&-1!==a.indexOf(n.getInputTargetBlock("AT1"))&&-1!==t.indexOf(n.getInputTargetBlock("AT2"))})),s=o.getAllBlocks().filter((function(e){return"variables_set"===e.type&&null===e.getNextBlock()&&-1!==l.indexOf(e.getInputTargetBlock("VALUE"))&&"afterSecondComma"===e.getField("VAR").getText()})),u=o.getAllBlocks().filter((function(t){return("text_print"===t.type||"js_text_print"===t.type)&&-1!==s.indexOf(t.getNextBlock())&&-1!==e.indexOf(t.getInputTargetBlock("TEXT"))})),c=o.getAllBlocks().filter((function(e){return"variables_get"===e.type&&"itemList"===e.getField("VAR").getText()})),g=o.getAllBlocks().filter((function(e){return"t2c_text_length"===e.type&&-1!==c.indexOf(e.getInputTargetBlock("VALUE"))})),d=o.getAllBlocks().filter((function(e){return("js_text_indexof"===e.type||"t2c_text_indexof"===e.type)&&-1!==c.indexOf(e.getInputTargetBlock("VALUE"))&&-1!==i.indexOf(e.getInputTargetBlock("FIND"))})),h=o.getAllBlocks().filter((function(e){return"math_arithmetic_basic"===e.type&&-1!==d.indexOf(e.getInputTargetBlock("A"))&&-1!==n.indexOf(e.getInputTargetBlock("B"))&&"ADD"===e.getFieldValue("OP")})),p=o.getAllBlocks().filter((function(e){return("js_text_getsubstring"===e.type||"t2c_text_getsubstring"===e.type)&&-1!==c.indexOf(e.getInputTargetBlock("STRING"))&&-1!==h.indexOf(e.getInputTargetBlock("AT1"))&&-1!==g.indexOf(e.getInputTargetBlock("AT2"))})),f=o.getAllBlocks().filter((function(e){return"variables_set"===e.type&&-1!==u.indexOf(e.getNextBlock())&&-1!==p.indexOf(e.getInputTargetBlock("VALUE"))&&"afterFirstComma"===e.getField("VAR").getText()})),m=o.getAllBlocks().filter((function(e){return("text_print"===e.type||"js_text_print"===e.type)&&-1!==f.indexOf(e.getNextBlock())&&-1!==c.indexOf(e.getInputTargetBlock("TEXT"))})),y=o.getAllBlocks().filter((function(e){return"text"===e.type&&"string"==typeof e.getFieldValue("TEXT")&&-1!==e.getFieldValue("TEXT").toLowerCase().indexOf("at least 4")})),T=o.getAllBlocks().filter((function(e){return("text_input"===e.type||"js_text_input"===e.type)&&-1!==y.indexOf(e.getInputTargetBlock("TEXT"))})),_=o.getAllBlocks().filter((function(e){return"variables_set"===e.type&&-1!==m.indexOf(e.getNextBlock())&&-1!==T.indexOf(e.getInputTargetBlock("VALUE"))&&"itemList"===e.getField("VAR").getText()}));return 4===e.length&&1===t.length&&2===n.length&&2===i.length&&1===r.length&&1===a.length&&1===l.length&&1===s.length&&1===u.length&&4===c.length&&1===g.length&&1===d.length&&1===h.length&&1===p.length&&1===f.length&&1===m.length&&1===y.length&&1===T.length&&1===_.length}),(function(){return"Drag in the type-in-code block, and type the necessary code to get all items from afterFirstComma after its first comma (second item until end of afterFirstComma, which will be the third item until end of original item list) and store the result in the variable afterSecondComma. Then place the block below the one displaying afterFirstComma."}),(function(){var e=o.getAllBlocks().filter((function(e){return"variables_get"===e.type&&"afterFirstComma"===e.getField("VAR").getText()})),t=o.getAllBlocks().find((function(e){return"variables_set"===e.type&&"afterSecondComma"===e.getField("VAR").getText()})),n=o.getAllBlocks().filter((function(e){return"variables_get"===e.type&&"itemList"===e.getField("VAR").getText()})),i=o.getAllBlocks().find((function(t){return("text_print"===t.type||"js_text_print"===t.type)&&-1!==e.indexOf(t.getInputTargetBlock("TEXT"))})),r=o.getAllBlocks().find((function(e){return"variables_set"===e.type&&"afterFirstComma"===e.getField("VAR").getText()})),a=o.getAllBlocks().find((function(e){return("text_print"===e.type||"js_text_print"===e.type)&&-1!==n.indexOf(e.getInputTargetBlock("TEXT"))})),l=o.getAllBlocks().find((function(e){return"variables_set"===e.type&&"itemList"===e.getField("VAR").getText()})),s=o.getAllBlocks().find((function(e){return"type_in_set_after_second"===e.type}));return r&&t&&t.getNextBlock()===r?"The "+T2C.MSG.currentLanguage.TERMINAL_LET+" variable block setting afterSecondComma must go below the "+T2C.MSG.currentLanguage.TERMINAL_LET+" variable block setting afterFirstComma because the computer uses this one to determine what afterSecondComma is. Since instructions are run from top to bottom, it won't know what afterFirstComma means, otherwise!":r&&i&&i.getNextBlock()===r?"The "+T2C.MSG.currentLanguage.TERMINAL_DISPLAY+" block must go below the "+T2C.MSG.currentLanguage.TERMINAL_LET+" variable block setting afterFirstComma because the computer uses the value of this variable in the "+T2C.MSG.currentLanguage.TERMINAL_DISPLAY+" block. Since instructions are run from top to bottom, it won't know what afterFirstComma means, otherwise!":l&&r&&r.getNextBlock()===l?"The "+T2C.MSG.currentLanguage.TERMINAL_LET+" variable block setting afterFirstComma must go below the "+T2C.MSG.currentLanguage.TERMINAL_LET+" variable block setting itemList because the computer uses this one to determine what afterFirstComma is. Since instructions are run from top to bottom, it won't know what itemList means, otherwise!":l&&a&&a.getNextBlock()===l?"The "+T2C.MSG.currentLanguage.TERMINAL_DISPLAY+" block must go below the "+T2C.MSG.currentLanguage.TERMINAL_LET+" variable block setting itemList because the computer uses the value of this variable in the "+T2C.MSG.currentLanguage.TERMINAL_DISPLAY+" block. Since instructions are run from top to bottom, it won't know what itemList means, otherwise!":i&&t&&i.getNextBlock()!==t?"Place the "+T2C.MSG.currentLanguage.TERMINAL_LET+" variable block setting afterSecondComma below the "+T2C.MSG.currentLanguage.TERMINAL_DISPLAY+" block displaying afterFirstComma.":s?De.getErrorFeedback():""})),n.addTask(new r((function(){return!0}),{start:function(){alert("✔ Mahaan (great), so let's display this new list, which will be the original one with its first two items removed."),a.removeToolboxBlocks((function(e){return"type_in_set_after_second"===e.getAttribute("type")})),m(o),a.createToolboxBlock("type_in_display_after_second"),o.options.maxInstances.type_in_display_after_second=1,Re(document.getElementById("output-container").querySelectorAll(".table-cell")[0]),Fe()},isComplete:function(){return!0},animate:function(){return!0},finish:function(){}})),d(n,(function(){var e=o.getAllBlocks().filter((function(e){return"variables_get"===e.type&&"afterSecondComma"===e.getField("VAR").getText()})),t=o.getAllBlocks().filter((function(t){return("text_print"===t.type||"js_text_print"===t.type)&&null===t.getNextBlock()&&-1!==e.indexOf(t.getInputTargetBlock("TEXT"))})),n=o.getAllBlocks().filter((function(e){return"variables_get"===e.type&&"afterFirstComma"===e.getField("VAR").getText()})),i=o.getAllBlocks().filter((function(e){return"t2c_text_length"===e.type&&-1!==n.indexOf(e.getInputTargetBlock("VALUE"))})),r=o.getAllBlocks().filter((function(e){return"math_number"===e.type&&1===e.getFieldValue("NUM")})),a=o.getAllBlocks().filter((function(e){return"text"===e.type&&","===e.getFieldValue("TEXT")})),l=o.getAllBlocks().filter((function(e){return("js_text_indexof"===e.type||"t2c_text_indexof"===e.type)&&-1!==n.indexOf(e.getInputTargetBlock("VALUE"))&&-1!==a.indexOf(e.getInputTargetBlock("FIND"))})),s=o.getAllBlocks().filter((function(e){return"math_arithmetic_basic"===e.type&&-1!==l.indexOf(e.getInputTargetBlock("A"))&&-1!==r.indexOf(e.getInputTargetBlock("B"))&&"ADD"===e.getFieldValue("OP")})),u=o.getAllBlocks().filter((function(e){return("js_text_getsubstring"===e.type||"t2c_text_getsubstring"===e.type)&&-1!==n.indexOf(e.getInputTargetBlock("STRING"))&&-1!==s.indexOf(e.getInputTargetBlock("AT1"))&&-1!==i.indexOf(e.getInputTargetBlock("AT2"))})),c=o.getAllBlocks().filter((function(e){return"variables_set"===e.type&&-1!==t.indexOf(e.getNextBlock())&&-1!==u.indexOf(e.getInputTargetBlock("VALUE"))&&"afterSecondComma"===e.getField("VAR").getText()})),g=o.getAllBlocks().filter((function(e){return("text_print"===e.type||"js_text_print"===e.type)&&-1!==c.indexOf(e.getNextBlock())&&-1!==n.indexOf(e.getInputTargetBlock("TEXT"))})),d=o.getAllBlocks().filter((function(e){return"variables_get"===e.type&&"itemList"===e.getField("VAR").getText()})),h=o.getAllBlocks().filter((function(e){return"t2c_text_length"===e.type&&-1!==d.indexOf(e.getInputTargetBlock("VALUE"))})),p=o.getAllBlocks().filter((function(e){return("js_text_indexof"===e.type||"t2c_text_indexof"===e.type)&&-1!==d.indexOf(e.getInputTargetBlock("VALUE"))&&-1!==a.indexOf(e.getInputTargetBlock("FIND"))})),f=o.getAllBlocks().filter((function(e){return"math_arithmetic_basic"===e.type&&-1!==p.indexOf(e.getInputTargetBlock("A"))&&-1!==r.indexOf(e.getInputTargetBlock("B"))&&"ADD"===e.getFieldValue("OP")})),m=o.getAllBlocks().filter((function(e){return("js_text_getsubstring"===e.type||"t2c_text_getsubstring"===e.type)&&-1!==d.indexOf(e.getInputTargetBlock("STRING"))&&-1!==f.indexOf(e.getInputTargetBlock("AT1"))&&-1!==h.indexOf(e.getInputTargetBlock("AT2"))})),y=o.getAllBlocks().filter((function(e){return"variables_set"===e.type&&-1!==g.indexOf(e.getNextBlock())&&-1!==m.indexOf(e.getInputTargetBlock("VALUE"))&&"afterFirstComma"===e.getField("VAR").getText()})),T=o.getAllBlocks().filter((function(e){return("text_print"===e.type||"js_text_print"===e.type)&&-1!==y.indexOf(e.getNextBlock())&&-1!==d.indexOf(e.getInputTargetBlock("TEXT"))})),_=o.getAllBlocks().filter((function(e){return"text"===e.type&&"string"==typeof e.getFieldValue("TEXT")&&-1!==e.getFieldValue("TEXT").toLowerCase().indexOf("at least 4")})),b=o.getAllBlocks().filter((function(e){return("text_input"===e.type||"js_text_input"===e.type)&&-1!==_.indexOf(e.getInputTargetBlock("TEXT"))})),k=o.getAllBlocks().filter((function(e){return"variables_set"===e.type&&-1!==T.indexOf(e.getNextBlock())&&-1!==b.indexOf(e.getInputTargetBlock("VALUE"))&&"itemList"===e.getField("VAR").getText()}));return 1===e.length&&1===t.length&&4===n.length&&1===i.length&&2===r.length&&2===a.length&&1===l.length&&1===s.length&&1===u.length&&1===c.length&&1===g.length&&4===d.length&&1===h.length&&1===p.length&&1===f.length&&1===m.length&&1===y.length&&1===T.length&&1===_.length&&1===b.length&&1===k.length}),(function(){return"Drag in the type-in-code block, and type the necessary code to display the original item list with its first two items removed (afterSecondComma). Then place the block below the one setting afterSecondComma."}),(function(){var e=o.getAllBlocks().filter((function(e){return"variables_get"===e.type&&"afterSecondComma"===e.getField("VAR").getText()})),t=o.getAllBlocks().find((function(t){return("text_print"===t.type||"js_text_print"===t.type)&&-1!==e.indexOf(t.getInputTargetBlock("TEXT"))})),n=o.getAllBlocks().filter((function(e){return"variables_get"===e.type&&"afterFirstComma"===e.getField("VAR").getText()})),i=o.getAllBlocks().find((function(e){return"variables_set"===e.type&&"afterSecondComma"===e.getField("VAR").getText()})),r=o.getAllBlocks().find((function(e){return("text_print"===e.type||"js_text_print"===e.type)&&-1!==n.indexOf(e.getInputTargetBlock("TEXT"))})),a=o.getAllBlocks().filter((function(e){return"variables_get"===e.type&&"itemList"===e.getField("VAR").getText()})),l=o.getAllBlocks().find((function(e){return"variables_set"===e.type&&"afterFirstComma"===e.getField("VAR").getText()})),s=o.getAllBlocks().find((function(e){return("text_print"===e.type||"js_text_print"===e.type)&&-1!==a.indexOf(e.getInputTargetBlock("TEXT"))})),u=o.getAllBlocks().find((function(e){return"variables_set"===e.type&&"itemList"===e.getField("VAR").getText()})),c=o.getAllBlocks().find((function(e){return"type_in_display_after_second"===e.type}));return i&&t&&t.getNextBlock()===i?"The "+T2C.MSG.currentLanguage.TERMINAL_DISPLAY+" block must go below the "+T2C.MSG.currentLanguage.TERMINAL_LET+" variable block setting afterSecondComma because the computer uses the value of this variable in the "+T2C.MSG.currentLanguage.TERMINAL_DISPLAY+" block. Since instructions are run from top to bottom, it won't know what afterSecondComma means, otherwise!":l&&i&&i.getNextBlock()===l?"The "+T2C.MSG.currentLanguage.TERMINAL_LET+" variable block setting afterSecondComma must go below the "+T2C.MSG.currentLanguage.TERMINAL_LET+" variable block setting afterFirstComma because the computer uses this one to determine what afterSecondComma is. Since instructions are run from top to bottom, it won't know what afterFirstComma means, otherwise!":l&&r&&r.getNextBlock()===l?"The "+T2C.MSG.currentLanguage.TERMINAL_DISPLAY+" block must go below the "+T2C.MSG.currentLanguage.TERMINAL_LET+" variable block setting afterFirstComma because the computer uses the value of this variable in the "+T2C.MSG.currentLanguage.TERMINAL_DISPLAY+" block. Since instructions are run from top to bottom, it won't know what afterFirstComma means, otherwise!":u&&l&&l.getNextBlock()===u?"The "+T2C.MSG.currentLanguage.TERMINAL_LET+" variable block setting afterFirstComma must go below the "+T2C.MSG.currentLanguage.TERMINAL_LET+" variable block setting itemList because the computer uses this one to determine what afterFirstComma is. Since instructions are run from top to bottom, it won't know what itemList means, otherwise!":u&&s&&s.getNextBlock()===u?"The "+T2C.MSG.currentLanguage.TERMINAL_DISPLAY+" block must go below the "+T2C.MSG.currentLanguage.TERMINAL_LET+" variable block setting itemList because the computer uses the value of this variable in the "+T2C.MSG.currentLanguage.TERMINAL_DISPLAY+" block. Since instructions are run from top to bottom, it won't know what itemList means, otherwise!":t?"Place the "+T2C.MSG.currentLanguage.TERMINAL_DISPLAY+" block displaying the value of afterSecondComma after the "+T2C.MSG.currentLanguage.TERMINAL_LET+" variable block setting it.":c?We.getErrorFeedback():""})),h(n),p(n,document.getElementById("output-container").querySelectorAll(".table-cell")[0]),n.addTask(new r((function(){return!0}),{start:function(){alert("✔ Utkrsht (excellent), so finally let's display the third item, which will be the first item of the last list, which is the original one with its first two items removed."),a.removeToolboxBlocks((function(e){return"type_in_display_after_second"===e.getAttribute("type")})),m(o),a.createToolboxBlock("type_in_display_third_item"),o.options.maxInstances.type_in_display_third_item=1,Re(document.getElementById("output-container").querySelectorAll(".table-cell")[0]),Fe()},isComplete:function(){return!0},animate:function(){return!0},finish:function(){}})),d(n,(function(){var e=o.getAllBlocks().filter((function(e){return"text"===e.type&&","===e.getFieldValue("TEXT")})),t=o.getAllBlocks().filter((function(e){return"variables_get"===e.type&&"afterSecondComma"===e.getField("VAR").getText()})),n=o.getAllBlocks().filter((function(n){return("js_text_indexof"===n.type||"t2c_text_indexof"===n.type)&&-1!==t.indexOf(n.getInputTargetBlock("VALUE"))&&-1!==e.indexOf(n.getInputTargetBlock("FIND"))})),i=o.getAllBlocks().filter((function(e){return"math_number"===e.type&&0===e.getFieldValue("NUM")})),r=o.getAllBlocks().filter((function(e){return("js_text_getsubstring"===e.type||"t2c_text_getsubstring"===e.type)&&-1!==t.indexOf(e.getInputTargetBlock("STRING"))&&-1!==i.indexOf(e.getInputTargetBlock("AT1"))&&-1!==n.indexOf(e.getInputTargetBlock("AT2"))})),a=o.getAllBlocks().filter((function(e){return("text_print"===e.type||"js_text_print"===e.type)&&null===e.getNextBlock()&&-1!==r.indexOf(e.getInputTargetBlock("TEXT"))})),l=o.getAllBlocks().filter((function(e){return("text_print"===e.type||"js_text_print"===e.type)&&-1!==a.indexOf(e.getNextBlock())&&-1!==t.indexOf(e.getInputTargetBlock("TEXT"))})),s=o.getAllBlocks().filter((function(e){return"variables_get"===e.type&&"afterFirstComma"===e.getField("VAR").getText()})),u=o.getAllBlocks().filter((function(e){return"t2c_text_length"===e.type&&-1!==s.indexOf(e.getInputTargetBlock("VALUE"))})),c=o.getAllBlocks().filter((function(e){return"math_number"===e.type&&1===e.getFieldValue("NUM")})),g=o.getAllBlocks().filter((function(t){return("js_text_indexof"===t.type||"t2c_text_indexof"===t.type)&&-1!==s.indexOf(t.getInputTargetBlock("VALUE"))&&-1!==e.indexOf(t.getInputTargetBlock("FIND"))})),d=o.getAllBlocks().filter((function(e){return"math_arithmetic_basic"===e.type&&-1!==g.indexOf(e.getInputTargetBlock("A"))&&-1!==c.indexOf(e.getInputTargetBlock("B"))&&"ADD"===e.getFieldValue("OP")})),h=o.getAllBlocks().filter((function(e){return("js_text_getsubstring"===e.type||"t2c_text_getsubstring"===e.type)&&-1!==s.indexOf(e.getInputTargetBlock("STRING"))&&-1!==d.indexOf(e.getInputTargetBlock("AT1"))&&-1!==u.indexOf(e.getInputTargetBlock("AT2"))})),p=o.getAllBlocks().filter((function(e){return"variables_set"===e.type&&-1!==l.indexOf(e.getNextBlock())&&-1!==h.indexOf(e.getInputTargetBlock("VALUE"))&&"afterSecondComma"===e.getField("VAR").getText()})),f=o.getAllBlocks().filter((function(e){return("text_print"===e.type||"js_text_print"===e.type)&&-1!==p.indexOf(e.getNextBlock())&&-1!==s.indexOf(e.getInputTargetBlock("TEXT"))})),m=o.getAllBlocks().filter((function(e){return"variables_get"===e.type&&"itemList"===e.getField("VAR").getText()})),y=o.getAllBlocks().filter((function(e){return"t2c_text_length"===e.type&&-1!==m.indexOf(e.getInputTargetBlock("VALUE"))})),T=o.getAllBlocks().filter((function(t){return("js_text_indexof"===t.type||"t2c_text_indexof"===t.type)&&-1!==m.indexOf(t.getInputTargetBlock("VALUE"))&&-1!==e.indexOf(t.getInputTargetBlock("FIND"))})),_=o.getAllBlocks().filter((function(e){return"math_arithmetic_basic"===e.type&&-1!==T.indexOf(e.getInputTargetBlock("A"))&&-1!==c.indexOf(e.getInputTargetBlock("B"))&&"ADD"===e.getFieldValue("OP")})),b=o.getAllBlocks().filter((function(e){return("js_text_getsubstring"===e.type||"t2c_text_getsubstring"===e.type)&&-1!==m.indexOf(e.getInputTargetBlock("STRING"))&&-1!==_.indexOf(e.getInputTargetBlock("AT1"))&&-1!==y.indexOf(e.getInputTargetBlock("AT2"))})),k=o.getAllBlocks().filter((function(e){return"variables_set"===e.type&&-1!==f.indexOf(e.getNextBlock())&&-1!==b.indexOf(e.getInputTargetBlock("VALUE"))&&"afterFirstComma"===e.getField("VAR").getText()})),x=o.getAllBlocks().filter((function(e){return("text_print"===e.type||"js_text_print"===e.type)&&-1!==k.indexOf(e.getNextBlock())&&-1!==m.indexOf(e.getInputTargetBlock("TEXT"))})),E=o.getAllBlocks().filter((function(e){return"text"===e.type&&"string"==typeof e.getFieldValue("TEXT")&&-1!==e.getFieldValue("TEXT").toLowerCase().indexOf("at least 4")})),B=o.getAllBlocks().filter((function(e){return("text_input"===e.type||"js_text_input"===e.type)&&-1!==E.indexOf(e.getInputTargetBlock("TEXT"))})),A=o.getAllBlocks().filter((function(e){return"variables_set"===e.type&&-1!==x.indexOf(e.getNextBlock())&&-1!==B.indexOf(e.getInputTargetBlock("VALUE"))&&"itemList"===e.getField("VAR").getText()}));return 3===e.length&&3===t.length&&1===n.length&&1===i.length&&1===r.length&&1===a.length&&1===l.length&&4===s.length&&1===u.length&&2===c.length&&1===g.length&&1===d.length&&1===h.length&&1===p.length&&1===f.length&&4===m.length&&1===y.length&&1===T.length&&1===_.length&&1===b.length&&1===k.length&&1===x.length&&1===E.length&&1===B.length&&1===A.length}),(function(){return"Drag in the type-in-code block, and type the necessary code to display the third item from itemList, which will be the text appearing before the first comma in afterSecondComma. Then place the block below the one displaying the original list with its first two items removed (afterSecondComma)."}),(function(){var e=o.getAllBlocks().filter((function(e){return"text"===e.type&&","===e.getFieldValue("TEXT")})),t=o.getAllBlocks().filter((function(e){return"variables_get"===e.type&&"afterSecondComma"===e.getField("VAR").getText()})),n=o.getAllBlocks().filter((function(n){return("js_text_indexof"===n.type||"t2c_text_indexof"===n.type)&&-1!==t.indexOf(n.getInputTargetBlock("VALUE"))&&-1!==e.indexOf(n.getInputTargetBlock("FIND"))})),i=o.getAllBlocks().filter((function(e){return"math_number"===e.type&&0===e.getFieldValue("NUM")})),r=o.getAllBlocks().filter((function(e){return("js_text_getsubstring"===e.type||"t2c_text_getsubstring"===e.type)&&-1!==t.indexOf(e.getInputTargetBlock("STRING"))&&-1!==i.indexOf(e.getInputTargetBlock("AT1"))&&-1!==n.indexOf(e.getInputTargetBlock("AT2"))})),a=o.getAllBlocks().find((function(e){return("text_print"===e.type||"js_text_print"===e.type)&&-1!==r.indexOf(e.getInputTargetBlock("TEXT"))})),l=o.getAllBlocks().find((function(e){return("text_print"===e.type||"js_text_print"===e.type)&&-1!==t.indexOf(e.getInputTargetBlock("TEXT"))})),s=o.getAllBlocks().filter((function(e){return"variables_get"===e.type&&"afterFirstComma"===e.getField("VAR").getText()})),u=o.getAllBlocks().find((function(e){return"variables_set"===e.type&&"afterSecondComma"===e.getField("VAR").getText()})),c=o.getAllBlocks().find((function(e){return("text_print"===e.type||"js_text_print"===e.type)&&-1!==s.indexOf(e.getInputTargetBlock("TEXT"))})),g=o.getAllBlocks().filter((function(e){return"variables_get"===e.type&&"itemList"===e.getField("VAR").getText()})),d=o.getAllBlocks().find((function(e){return"variables_set"===e.type&&"afterFirstComma"===e.getField("VAR").getText()})),h=o.getAllBlocks().find((function(e){return("text_print"===e.type||"js_text_print"===e.type)&&-1!==g.indexOf(e.getInputTargetBlock("TEXT"))})),p=o.getAllBlocks().find((function(e){return"variables_set"===e.type&&"itemList"===e.getField("VAR").getText()})),f=o.getAllBlocks().find((function(e){return"type_in_display_third_item"===e.type}));return u&&a&&a.getNextBlock()===u||u&&l&&l.getNextBlock()===u?"The "+T2C.MSG.currentLanguage.TERMINAL_DISPLAY+" block must go below the "+T2C.MSG.currentLanguage.TERMINAL_LET+" variable block setting afterSecondComma because the computer uses the value of this variable in the "+T2C.MSG.currentLanguage.TERMINAL_DISPLAY+" block. Since instructions are run from top to bottom, it won't know what afterSecondComma means, otherwise!":d&&a&&a.getNextBlock()===d?"The "+T2C.MSG.currentLanguage.TERMINAL_DISPLAY+" block must go below the "+T2C.MSG.currentLanguage.TERMINAL_LET+" variable block setting afterFirstComma because the computer uses the value of this variable in the "+T2C.MSG.currentLanguage.TERMINAL_DISPLAY+" block. Since instructions are run from top to bottom, it won't know what afterFirstComma means, otherwise!":d&&u&&u.getNextBlock()===d?"The "+T2C.MSG.currentLanguage.TERMINAL_LET+" variable block setting afterSecondComma must go below the "+T2C.MSG.currentLanguage.TERMINAL_LET+" variable block setting afterFirstComma because the computer uses this one to determine what afterSecondComma is. Since instructions are run from top to bottom, it won't know what afterFirstComma means, otherwise!":d&&c&&c.getNextBlock()===d?"The "+T2C.MSG.currentLanguage.TERMINAL_DISPLAY+" block must go below the "+T2C.MSG.currentLanguage.TERMINAL_LET+" variable block setting afterFirstComma because the computer uses the value of this variable in the "+T2C.MSG.currentLanguage.TERMINAL_DISPLAY+" block. Since instructions are run from top to bottom, it won't know what afterFirstComma means, otherwise!":p&&d&&d.getNextBlock()===p?"The "+T2C.MSG.currentLanguage.TERMINAL_LET+" variable block setting afterFirstComma must go below the "+T2C.MSG.currentLanguage.TERMINAL_LET+" variable block setting itemList because the computer uses this one to determine what afterFirstComma is. Since instructions are run from top to bottom, it won't know what itemList means, otherwise!":p&&h&&h.getNextBlock()===p?"The "+T2C.MSG.currentLanguage.TERMINAL_DISPLAY+" block must go below the "+T2C.MSG.currentLanguage.TERMINAL_LET+" variable block setting itemList because the computer uses the value of this variable in the "+T2C.MSG.currentLanguage.TERMINAL_DISPLAY+" block. Since instructions are run from top to bottom, it won't know what itemList means, otherwise!":a?"Place the "+T2C.MSG.currentLanguage.TERMINAL_DISPLAY+" block displaying the third item after the "+T2C.MSG.currentLanguage.TERMINAL_DISPLAY+" block displaying the value of afterSecondComma.":f?Ye.getErrorFeedback():""})),h(n),p(n,document.getElementById("output-container").querySelectorAll(".table-cell")[0]),n.addTask(new r((function(){return!0}),{start:function(){return!0},isComplete:function(){return!0},animate:function(){return!0},finish:function(){alert("✔✔✔ Amazing! You just solved that very challenging problem and completed Mission # 9. And with that, you became a pro at working with strings. In next missions, you'll be working more with numbers and the four operations of addition, subtraction, multiplication, and division. We'll start the next mission with a simple cool math magic trick you could amaze all your friends with! Until next time, phir milenge (See you again)!"),Fe(),a.clearToolbox(),["code_statement"].forEach((function(e,t){a.createToolboxBlock(e,!1),o.options.maxInstances[e]=maxBlocks[t]}))}})),n},function(e,t){var n=new p,o=n.createStandardHelpMessageManager(),a=e||new c,l=t||Blockly.getMainWorkspace(),s=new f(l);l.clear(),s.clearToolbox();var u=He.map((function(e){return Object(i.e)(l,e)}));u.slice(0,u.length-1).forEach((function(e,t){return Object(i.i)(e,u[t+1])})),l.setScale(1),l.getAllBlocks().forEach((function(e){return e.setMovable(!1)})),u[0].setFieldValue(et,"EXP"),u[1].setFieldValue(Qe.TERMINAL_LET+"step1 = 2 * startNum","EXP"),u[2].setFieldValue(Qe.TERMINAL_DISPLAY+"(step1)","EXP"),Object(i.f)(l),a.addTask(new r((function(){return!0}),{start:function(){return!0},isComplete:function(){return!0},animate:function(){return!0},finish:function(){var e=void 0;if(alert("Before you start this mission, the computer will be scanning your brain and revealing the meaning of life to you! But answers don't come so easy. First, you'll need to choose a number and remember it. You'll also need to perform the following operations and remember the number after each step. Remember your starting number though!\n1. Multiply your starting number by 2.\n2. Add 100 to the result of step 1.\n 3. Subtract 16 from the result of step 2.\n 4. Divide your number from step 3 by 2. \n 5. Finally, subtract the number you started with from the number from step 4 and you'll get the meaning of life according to The Hitchiker's Guide to the Galaxy."),!confirm("Was your number 42?")){for(var t="There must be a mistake, let's walk you through the steps to show you that you should've gotten 42. Enter the number you chose (or click cancel if you just want to use 0): ",n=prompt(t);null!==n&isNaN(parseFloat(n));)n=prompt("What you entered doesn't seem to be a number. "+t);e=parseFloat(n)||0,alert("So you started with "+e+":\nStep 1 result (multiplying by 2): "+2*e+"\nStep 2 result (adding 100 to result of step 1): "+(2*e+100)+"\nStep 3 result (subtracting 16 from step2 result): "+(2*e+84)+"\nStep 4 result (dividing step3 result by 2): "+(e+42)+"\nStep 5 result (subtracting number you started with): 42")}alert("Do you know how the trick worked? Hint: The computer didn't actually read your mind. It's just an algebra trick. Remember in algebra, when we have an unknown, we use a variable. Here, the unknown is the starting number. If x represents it, then after doubling it in step1, we'll have 2x. The point is we'll have to eventually get rid of x since we always want to wind up with the same number of 42 and you can verify that we perform the operations to do just that. If you really want to amaze your friends, you can ask them to tell you a number first and then tell them to pick a different number (and not tell you), and then perform operations to wind up with that number they asked for. For kuch mazaa (some fun), let's try that now:");for(var o,i=prompt("Enter your favorite number (or cancel for 0):");null!==i&isNaN(parseFloat(i));)i=prompt("What you entered doesn't seem to be a number. Enter your favorite number (or cancel for 0):");o=parseFloat(i)||0,alert("So now choose any new number and remember this one. \n1. Add "+(2*o+5)+" to your starting number.\n2. Multiply the result of step 1 by 3.\n 3. Subtract "+(3*o+15)+" from the result of step 2.\n 4. Divide your number from step 3 by 3. \n 5. Finally, subtract the number you started with from the number from step 4 and you should get the number you told the computer was your favorite!"),alert("Now back to the mission at hand: you'll have the computer challenge the user to select a number and then show him/her the result after each step, which will predictably end in 42*. (*Note: Due to the way the computer stores numbers, if you start with a number with a decimal point, the answer it produces may not be exactly 42.) Just as in algebra, when we program and want to store something for later use, we can use a variable, and here we'd do the same for the starting number. You will also store each step's result in a variable. One final note is the use of "+T2C.MSG.currentLanguage.TERMINAL_PARSEFLOAT+', which converts what the user enters from text to a number. This is important because otherwise, JavaScript will for example treat 1 + "1" as the text "11" (join the two together as strings) instead of adding them together as numbers to get 2 while Python will simply give you an error, refusing to add a number and string. See QuickMaths JavaScript meme.')}})),n.addHelpMessageTask(a,o,(function(){return He.every((function(e,t){var n=l.getAllBlocks().find((function(t){return t.type===e}));return ze[t].hasFullMatch(n.getFieldValue("EXP"),!1)}))}),"Type in the code to get the computer to calculate each step's result by performing the specified operation (+ for addition, - for subtraction, * for multiplcation, or / for division) on the previous step's value. Name your variables step1, step2, step3, step4, and step5. Be sure to display the result after each step. The steps are as follows:\n 1. Multiply your starting number by 2.\n2. Add 100 to the result of step 1.\n 3. Subtract 16 from the result of step 2.\n 4. Divide your number from step 3 by 2. \n 5. Finally, subtract the number you started with from the number from step 4.",(function(){for(var e=0;e1?y.addRunTask(T,_,(function(){5===e?alert("Great, so now for the trickier calculations. To determine the seconds that'll display on a clock, you'll need to get the remaining number of seconds after you've accounted for the minutes. So for example, 90 seconds after midnight would be 00:01:30 (1 minute, 30 seconds), 130 seconds after would be 00:02:10 (2 minutes, 10 seconds), and 200 seconds after would be 00:03:20 (3 minutes, 20 seconds). You got the 1, 2, and 3 from 90, 130, and 210 so how do you go from:\n90 and 1 => 30,\n 130 and 2 => 10, \n 200 and 3 => 20 \nFind the common operations you use in each and then substitute these numbers with the variables totalSeconds and totalMinutes to get your answer, which you should store in remainingSeconds."):alert("Directions to be added later"),function(e){(s=s.map((function(e){return b.getAllBlocks().find((function(t){return e.type===t.type}))}))).push(Object(i.e)(b,n[e])),e>0&&Object(i.i)(s[e-1],s[e]),b.getAllBlocks().forEach((function(e){return e.setMovable(!1)})),Object(i.f)(b)}(e)}),x):_.addTask(new r((function(){return!0}),{start:function(){return!0},isComplete:function(){return!0},animate:function(){return!0},finish:function(){if(0===e)alert("In JavaScript, Dates are represented by the number of milliseconds since January 1, 1970 at midnight UTC (Coordinated Universal Time), where 0 represents this time. For example, 64,000 would correspond to Thu Jan 01 1970 00:01:04 GMT+0000 (Greenwich Mean Time), i.e., 64 seconds or 0 hours, 1 minute, and 4 seconds after midnight since there are 1000 milliseconds in a second. In this mission, the user will input a number of milliseconds and you will output the time (ignoring leap seconds). So let's start by asking the user for a number of milliseconds and storing the *numerical* value in a variable milliseconds, which we'll allow to be a non-whole number such as 64000.5. Remember what you have to do to convert a string to a number?");else if(1===e){var t="To do this, you'll need to know about "+T2C.MSG.currentLanguage.TERMINAL_TRUNC+", which can be used to convert a number to an integer (...,-3,-2,-1,0,1,2,3,...) by truncating or removing all digits to the right of the decimal point (e.g., "+T2C.MSG.currentLanguage.TERMINAL_TRUNC+"(2.41) is 2). When we are dividing 0 or some positive integer by a positive integer, we can use "+T2C.MSG.currentLanguage.TERMINAL_TRUNC+" to perform integer division. So "+T2C.MSG.currentLanguage.TERMINAL_TRUNC+"(14/5) = "+T2C.MSG.currentLanguage.TERMINAL_TRUNC+"(2.8) = 2, which is the quotient when you divide 14 by 5.";alert("Sahee (Right), so remembering that there are 1000 ms (milliseconds) in a second, let's get the total number of *whole* seconds contained in the entered number of ms. So the answer for 64000, 64500, and 64543.21 should all be 64. "+t+" So using this information, can you do this? Store the answer in totalSeconds.")}else alert("Message to be added later");(s=s.map((function(e){return b.getAllBlocks().find((function(t){return e.type===t.type}))}))).push(Object(i.e)(b,n[e])),e>0&&Object(i.i)(s[e-1],s[e]),b.getAllBlocks().forEach((function(e){return e.setMovable(!1)})),Object(i.f)(b)}})),y.addHelpMessageTask(_,T,(function(){return n.slice(0,e+1).every((function(e,t){var n=b.getAllBlocks().find((function(t){return t.type===e}));return o[t].hasFullMatch(n.getFieldValue("EXP"),!1)}))}),(function(){return 0===e?"Ask the user for a number of milliseconds, convert the input to a number, and store it in a variable named "+a[0]+".":1===e?"Apply the appropriate math operation on "+a[0]+" and the appropriate integer to convert to the total number of whole seconds. Recall that for an input of 64000 milliseconds, there are 64 seconds. Be sure to apply "+T2C.MSG.currentLanguage.TERMINAL_TRUNC+" to the result of this operation so that 64500 and 64543.21 also result in 64. Store the final answer in "+a[1]+".":e%2==0?"Display "+a[e/2]+".":3===e?"Apply the appropriate math operation on "+a[1]+" and the appropriate integer to convert to the total number of whole minutes. For some examples, 90, 130, and 200 seconds, the answers should be 1, 2, and 3 minutes, respectively. As in the previous conversion, be sure to apply "+T2C.MSG.currentLanguage.TERMINAL_TRUNC+" to the result of this operation so that you get whole numbers in each case. Store the final answer in "+a[2]+".":5===e?"Apply the appropriate math operations on "+a[1]+" and "+a[2]+" and the appropriate integer to convert to the remaining number of seconds. For some examples:\n90 seconds = 1 whole minute & *30 remaining seconds* \n 130 seconds = 2 whole minutes & *10 remaining seconds*\n200 seconds = 3 whole minutes & *20 remaining seconds*\nConsider what you could do with the total number of seconds and number of whole minutes to get the remaining number of seconds. Store the final answer in "+a[3]+". Do *NOT* include parentheses as you will not need them since the computer performs multiplication/division before addition/subtraction because they have higher precedence as they do in math (Parentheses first, exponentation next, multiplication/division next, addition/subtraction last).":7===e||11===e?"Apply the appropriate math operation on "+a[(e-3)/2]+" and the appropriate integer to convert to the total number of whole "+(7===e?"hours":"days")+" in the given number of "+(7===e?"minutes":"hours")+". Remember to apply "+T2C.MSG.currentLanguage.TERMINAL_TRUNC+" to the result of this operation so you get a whole number. Store the final answer in "+a[(e+1)/2]+".":9===e||13===e?"Apply the appropriate math operations on "+a[Math.trunc((e-1)/3)]+", "+a[(e-1)/2]+", and the appropriate integer to convert to the remaining number of "+(9===e?"minutes":"hours")+" after accounting for the "+(9===e?"hours":"days")+". As you did when getting the number of remaining seconds after extracting the seconds from the minutes, be sure to consider some examples to determine the appropriate calculations. Store the final answer in "+a[(e+1)/2]+". Do *NOT* include parentheses as you will not need them since the computer performs multiplication/division before addition/subtraction because they have higher precedence as they do in math (Parentheses first, exponentation next, multiplication/division next, addition/subtraction last).":"Display the time in the form hour (0 - 23): minute (0 - 59): second (0 - 59). Don't worry about including a leading 0, e.g., 2 : 4 : 5 is fine if the time is 2:04:05 AM. Use commas in your "+T2C.MSG.currentLanguage.TERMINAL_DISPLAY+" between the variables representing the numbers and the string literals ':' separating them."}),(function(){for(var t=0;t2||e%5==4?T.addRunTask(_,b,(function(){4===e?alert("Sahee (Right) so now since we'll want the "+l[4]+", which will be a whole number, and we'll later want "+l[7]+", let's get the "+l[3]+" next from the "+l[2]+". You remember how we can do this, right?"):alert("Directions to be added later"),function(e){(u=u.map((function(e){return k.getAllBlocks().find((function(t){return e.type===t.type}))}))).push(Object(i.e)(k,n[e])),e>0&&Object(i.i)(u[e-1],u[e]),k.getAllBlocks().forEach((function(e){return e.setMovable(!1)})),Object(i.f)(k)}(e)}),E):b.addTask(new r((function(){return!0}),{start:function(){return!0},isComplete:function(){return!0},animate:function(){return!0},finish:function(){0===e?alert("In Excel/Google Sheets, Dates are represented as the number of days since December 31, 1899 at midnight (represented by 0; 1 represents a day later or January 1, 1900 at midnight). Fractions of days affect the hours/minutes/seconds so e.g., 3.25 represents January 3, 1900 at 06:00:00 am (3 and 1 quarter day after December 31 at midnight). You can see this by typing a number in a cell in a spreadsheet and switching the format to e.g., Time, Long Date, Date time, etc. In this mission, the user will input a number of days after midnight in decimal such as 3.25 and you will again output the time (ignoring leap seconds). So let's start by asking the user for a number of days in decimal and storing the *numerical* result in a variable named "+a[0]+". As in the previous missions, you'll need to convert the user input to a number."):1===e?alert("Sahee (Right), so this time we're going to work in the opposite direction from the previous mission to get the time, proceeding from the largest unit of the total "+l[0]+" to the smallest unit of "+l[l.length-1].substring(l[l.length-1].indexOf(" ")+1)+". Recall that in the previous exercise, before the last step to get the "+l[4]+", we first got the "+l[1]+" so we could subtract out the "+l[3]+" contributed by them. So let's start by getting "+l[1]+" from the inputted "+l[0]+"."):2===e?alert("Acchaa (Good) so now we'll get the "+l[2]+" from the "+l[0]+". Do *NOT* use "+T2C.MSG.currentLanguage.TERMINAL_TRUNC+" this time as we'll need to preserve what comes after the decimal point to get "+l[7]+" and "+l[10]+"."):3===e?alert("Phir se acchaa (Good again). So let's now display the "+l[2]+" to verify it's what you expect for an example you have in mind."):5===e?alert("Mahaan (Great), so now that we have "+l[3]+" and "+l[1]+", you remember how to calculate the "+l[4]+" from the last mission, right? As before, use some examples, show the math operations, and then substitute the numbers with the appropriate variables to get the hour number that'll display on a clock."):alert("Message to be added later"),(u=u.map((function(e){return k.getAllBlocks().find((function(t){return e.type===t.type}))}))).push(Object(i.e)(k,n[e])),e>0&&Object(i.i)(u[e-1],u[e]),k.getAllBlocks().forEach((function(e){return e.setMovable(!1)})),Object(i.f)(k)}})),T.addHelpMessageTask(b,_,(function(){return n.slice(0,e+1).every((function(e,t){var n=k.getAllBlocks().find((function(t){return t.type===e}));return o[t].hasFullMatch(n.getFieldValue("EXP"),!1)}))}),(function(){if(0===e)return"Ask the user for a number of "+l[0]+", convert the input to a number, and store it in a variable named "+a[0]+".";if(1===e)return"Store the total "+l[1]+" in the variable "+a[1]+" by using "+T2C.MSG.currentLanguage.TERMINAL_TRUNC+" on "+a[0]+".";if(e%5==1||e%5==3)return"Display "+a[e-Math.round(e/3)-Math.trunc(e/12)]+".";if(2===e)return"Apply the appropriate math operation on "+a[0]+" and the appropriate integer to convert to the "+l[2]+". Do NOT apply "+T2C.MSG.currentLanguage.TERMINAL_TRUNC+". Store the final answer in "+a[2]+".";if(4===e)return"Next, store the "+l[3]+" in the variable "+a[3]+".";if(5===e)return"Apply the appropriate math operations on "+a[3]+" and "+a[1]+" and the appropriate integer to convert to the "+l[4]+". Store this result in "+a[4]+".";if(e%5==2&&e3&&void 0!==arguments[3]?arguments[3]:1/0;return o(e.map((function(e){return n.map((function(n){return function e(t,n,o){var i=arguments.length>3&&void 0!==arguments[3]?arguments[3]:1/0;return t===n?o:0!==i&&Array.isArray(t)?t.map((function(t){return e(t,n,o,i-1)})):t}(e,t,n,i)}))})))}(e,n,function e(t){return 1===t.length?[t]:t.map((function(n,o){return e(t.slice(0,o).concat(t.slice(o+1))).map((function(e){return[t[o]].concat(e)}))})).reduce((function(e,t){return e.concat(t)}),[])}(n),t)}),[e])})))}function s(e,t){return e.reduce((function(e,n){return e.concat([t]).concat(n)}),[]).slice(1)}var u=["cs1030_14_type_in_get_is_weekday","cs1030_14_type_in_get_is_vacation","cs1030_14_type_in_set_can_sleep_in","cs1030_14_type_in_display_can_sleep_in"],g=["isWeekday","isVacation","canSleepIn"],h=u.map((function(e){return new d(e,{collapseWhenFinished:!0})})),m=function(e,t){var o=t.reduce((function(e,t,o){return l(a(e,n,o+1,[function(e){return e.token===t}]),o)}),e);return t.slice().reduce((function(e,n,o){return a(e,s,t.length-o,[{token:t[t.length-1-o],type:"terminal"}])}),o)}([[g[0],{token:"and",type:"terminal"},g[1],{token:"or",type:"terminal"},{token:"not",type:"terminal"},g[0],{token:"and",type:"terminal"},g[1],{token:"or",type:"terminal"},{token:"not",type:"terminal"},g[0],{token:"and",type:"terminal"},{token:"not",type:"terminal"},g[1]]],["or","and"]),y=[[{token:"not",type:"terminal"},"(",{token:"not",type:"terminal"},g[1],{token:"and",type:"terminal"},g[0],")"],[{token:"not",type:"terminal"},"(",g[0],{token:"and",type:"terminal"},{token:"not",type:"terminal"},g[1],")"],[{token:"not",type:"terminal"},g[0],{token:"or",type:"terminal"},g[1]],[g[1],{token:"or",type:"terminal"},{token:"not",type:"terminal"},g[0]]],T=['"Is it a weekday? (true:OK or false:Cancel)"','"Is it a vacation? (true:OK or false:Cancel)"'],_=[null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null],b=m.concat(y).map((function(e){return[{token:"let",type:"terminal"},g[2],"="].concat(e).concat([{token:/^[;]*$/,type:"regexp"}])}));b.forEach((function(e){return h[2].addPossibleMatch(e,_.slice(0,e.length))})),console.log("SLEEP IN MATCHES",b);var k=[[{token:"let",type:"terminal"},g[0],"=",{token:"confirm",type:"terminal"},"(",{token:/^"[^"]*$|^'[^']*$|^"[^"]*"|^'[^']*'/,type:"regexp"},")",{token:/^[;]*$/,type:"regexp"}],[{token:"let",type:"terminal"},g[1],"=",{token:"confirm",type:"terminal"},"(",{token:/^"[^"]*$|^'[^']*$|^"[^"]*"|^'[^']*'/,type:"regexp"},")",{token:/^[;]*$/,type:"regexp"}],null,[{token:"display",type:"terminal"},"(",g[2],")",{token:/^[;]*$/,type:"regexp"}]];k.forEach((function(e,t){return 2!==t&&h[t].addPossibleMatch(e,_.slice(0,e.length))})),h.forEach((function(e){return e.addToBlocks()}));var x=new p,E=x.createStandardHelpMessageManager(),B=e||new c,A=t||Blockly.getMainWorkspace(),v=new f(A);A.clear(),v.clearToolbox();var I=x.createPointer();document.body.appendChild(I);var w=u.map((function(e){return Object(i.e)(A,e)}));w.slice(0,w.length-1).forEach((function(e,t){return Object(i.i)(e,w[t+1])}));var S=T2C.MSG.currentLanguage===T2C.MSG.PY?T2C.MSG.PY:T2C.MSG.JS;return w.forEach((function(e,t){return 2!==t&&e.setFieldValue(k[t].slice(0,k[t].length-1).map((function(e){return"terminal"===e.type?S["TERMINAL_"+e.token.toUpperCase()]:"regexp"===e.type?T[t]:e})).join(""),"EXP")})),A.setScale(1),A.getAllBlocks().forEach((function(e){return e.setMovable(!1)})),Object(i.f)(A),B.addTask(new r((function(){return!0}),{start:function(){return!0},isComplete:function(){return!0},animate:function(){return!0},finish:function(){alert("In progress: ADAPTED FROM SLEEP IN (http://codingbat.com/prob/p173401): The parameter "+g[0]+" is true if it is a weekday, and the parameter "+g[1]+" is true if we are on vacation. We can sleep in if it is not a weekday or we're on vacation. Write a line of code to set "+g[2]+" so that the computer displays true exactly when we can sleep in.")}})),x.addHelpMessageTask(B,E,(function(){return u.every((function(e,t){var n=A.getAllBlocks().find((function(t){return t.type===e}));return h[t].hasFullMatch(n.getFieldValue("EXP"),!1)}))}),(function(){return"Using the truth table, set "+g[2]+" to the appropriate Boolean expression in terms of "+g[0]+" and "+g[1]+"."}),(function(){for(var e=0;e3&&void 0!==arguments[3]?arguments[3]:1/0;return o(e.map((function(e){return n.map((function(n){return function e(t,n,o){var i=arguments.length>3&&void 0!==arguments[3]?arguments[3]:1/0;return t===n?o:0!==i&&Array.isArray(t)?t.map((function(t){return e(t,n,o,i-1)})):t}(e,t,n,i)}))})))}(e,n,function e(t){return 1===t.length?[t]:t.map((function(n,o){return e(t.slice(0,o).concat(t.slice(o+1))).map((function(e){return[t[o]].concat(e)}))})).reduce((function(e,t){return e.concat(t)}),[])}(n),t)}),[e])})))}function s(e,t){return e.reduce((function(e,n){return e.concat([t]).concat(n)}),[]).slice(1)}var u=["cs1030_15_type_in_get_is_a_smile","cs1030_15_type_in_get_is_b_smile","cs1030_15_type_in_set_in_trouble","cs1030_15_type_in_display_in_trouble"],g=["isASmile","isBSmile","inTrouble"],h=u.map((function(e){return new d(e,{collapseWhenFinished:!0})})),m=function(e,t){var o=t.reduce((function(e,t,o){return l(a(e,n,o+1,[function(e){return e.token===t}]),o)}),e);return t.slice().reduce((function(e,n,o){return a(e,s,t.length-o,[{token:t[t.length-1-o],type:"terminal"}])}),o)}([[g[0],{token:"and",type:"terminal"},g[1],{token:"or",type:"terminal"},{token:"not",type:"terminal"},g[0],{token:"and",type:"terminal"},{token:"not",type:"terminal"},g[1]]],["or","and"]),y=['"Is monkey A smiling? (true:OK or false:CANCEL)"','"Is monkey B smiling? (true:OK or false:CANCEL)"'],T=[null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null],_=m.map((function(e){return[{token:"let",type:"terminal"},g[2],"="].concat(e).concat([{token:/^[;]*$/,type:"regexp"}])}));_.forEach((function(e){return h[2].addPossibleMatch(e,T.slice(0,e.length))})),console.log(m.length),_.forEach((function(e){return console.log(e)}));var b=[[{token:"let",type:"terminal"},g[0],"=",{token:"confirm",type:"terminal"},"(",{token:/^"[^"]*$|^'[^']*$|^"[^"]*"|^'[^']*'/,type:"regexp"},")",{token:/^[;]*$/,type:"regexp"}],[{token:"let",type:"terminal"},g[1],"=",{token:"confirm",type:"terminal"},"(",{token:/^"[^"]*$|^'[^']*$|^"[^"]*"|^'[^']*'/,type:"regexp"},")",{token:/^[;]*$/,type:"regexp"}],null,[{token:"display",type:"terminal"},"(",g[2],")",{token:/^[;]*$/,type:"regexp"}]];b.forEach((function(e,t){return 2!==t&&h[t].addPossibleMatch(e,T.slice(0,e.length))})),h.forEach((function(e){return e.addToBlocks()}));var k=new p,x=k.createStandardHelpMessageManager(),E=e||new c,B=t||Blockly.getMainWorkspace(),A=new f(B);B.clear(),A.clearToolbox();var v=k.createPointer();document.body.appendChild(v);var I=u.map((function(e){return Object(i.e)(B,e)}));I.slice(0,I.length-1).forEach((function(e,t){return Object(i.i)(e,I[t+1])}));var w=T2C.MSG.currentLanguage===T2C.MSG.PY?T2C.MSG.PY:T2C.MSG.JS;return I.forEach((function(e,t){return 2!==t&&e.setFieldValue(b[t].slice(0,b[t].length-1).map((function(e){return"terminal"===e.type?w["TERMINAL_"+e.token.toUpperCase()]:"regexp"===e.type?y[t]:e})).join(""),"EXP")})),B.setScale(1),B.getAllBlocks().forEach((function(e){return e.setMovable(!1)})),Object(i.f)(B),E.addTask(new r((function(){return!0}),{start:function(){return!0},isComplete:function(){return!0},animate:function(){return!0},finish:function(){alert("In progress: ADAPTED FROM Monkey Trouble (http://codingbat.com/prob/p120546): We have two monkeys, a and b, and the parameters "+g[0]+" and "+g[1]+" indicate if each is smiling. We are in trouble if they are both smiling or if neither of them is smiling (and not in trouble otherwise). Write a line of code to set "+g[2]+" so that the computer displays true exactly when we are in trouble.")}})),k.addHelpMessageTask(E,x,(function(){return u.every((function(e,t){var n=B.getAllBlocks().find((function(t){return t.type===e}));return h[t].hasFullMatch(n.getFieldValue("EXP"),!1)}))}),(function(){return"Using the truth table, set "+g[2]+" to the appropriate Boolean expression in terms of "+g[0]+" and "+g[1]+"."}),(function(){for(var e=0;e3&&void 0!==arguments[3]?arguments[3]:1/0;return o(e.map((function(e){return n.map((function(n){return function e(t,n,o){var i=arguments.length>3&&void 0!==arguments[3]?arguments[3]:1/0;return t===n?o:0!==i&&Array.isArray(t)?t.map((function(t){return e(t,n,o,i-1)})):t}(e,t,n,i)}))})))}(e,n,function e(t){return 1===t.length?[t]:t.map((function(n,o){return e(t.slice(0,o).concat(t.slice(o+1))).map((function(e){return[t[o]].concat(e)}))})).reduce((function(e,t){return e.concat(t)}),[])}(n),t)}),[e])})))}function s(e,t){var o=t.reduce((function(e,t,o){return l(a(e,n,o+1,[function(e){return e.token===t}]),o)}),e);return t.slice().reduce((function(e,n,o){return a(e,u,t.length-o,[{token:t[t.length-1-o],type:"terminal"}])}),o)}function u(e,t){return e.reduce((function(e,n){return e.concat([t]).concat(n)}),[]).slice(1)}var g=["cs1030_16_type_in_is_mets_fan","cs1030_16_type_in_is_yankees_fan","cs1030_16_type_in_set_can_be_newyorker","cs1030_16_type_in_display_in_can_be_newyorker"],h=["isMetsFan","isYankeesFan","canBeNewYorker"],m=g.map((function(e){return new d(e,{collapseWhenFinished:!0})})),y=s([[h[0],{token:"and",type:"terminal"},{token:"not",type:"terminal"},h[1],{token:"or",type:"terminal"},{token:"not",type:"terminal"},h[0],{token:"and",type:"terminal"},h[1]]],["or","and"]),T=s([[h[0],{token:"or",type:"terminal"},h[1],{token:"and",type:"terminal"},{token:"not",type:"terminal"},h[0],{token:"or",type:"terminal"},{token:"not",type:"terminal"},h[1]]],["and","or"]).map((function(e){return["("].concat(e.slice(0,e.findIndex((function(e){return"and"===e.token})))).concat([")",{token:"and",type:"terminal"},"("]).concat(e.slice(e.findIndex((function(e){return"and"===e.token}))+1)).concat([")"])})),_=T.map((function(e){var t=e.findIndex((function(e){return"not"===e.token}));return e.slice(0,t-1).concat([{token:"not",type:"terminal"},"("]).concat(e[t+1]).concat([{token:"and",type:"terminal"}]).concat(e.slice(t+4))})),b=['"Are you a Mets fan? (true:OK or false:CANCEL)"','"Are you a Yankees fan? (true:OK or false:CANCEL)"'],k=[null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null],x=y.concat(T).concat(_).map((function(e){return[{token:"let",type:"terminal"},h[2],"="].concat(e).concat([{token:/^[;]*$/,type:"regexp"}])}));x.forEach((function(e){return m[2].addPossibleMatch(e,k.slice(0,e.length))})),console.log(y.length,T.length,_.length),x.forEach((function(e){return console.log(e)}));var E=[[{token:"let",type:"terminal"},h[0],"=",{token:"confirm",type:"terminal"},"(",{token:/^"[^"]*$|^'[^']*$|^"[^"]*"|^'[^']*'/,type:"regexp"},")",{token:/^[;]*$/,type:"regexp"}],[{token:"let",type:"terminal"},h[1],"=",{token:"confirm",type:"terminal"},"(",{token:/^"[^"]*$|^'[^']*$|^"[^"]*"|^'[^']*'/,type:"regexp"},")",{token:/^[;]*$/,type:"regexp"}],null,[{token:"display",type:"terminal"},"(",h[2],")",{token:/^[;]*$/,type:"regexp"}]];E.forEach((function(e,t){return 2!==t&&m[t].addPossibleMatch(e,k.slice(0,e.length))})),m.forEach((function(e){return e.addToBlocks()}));var B=new p,A=B.createStandardHelpMessageManager(),v=e||new c,I=t||Blockly.getMainWorkspace(),w=new f(I);I.clear(),w.clearToolbox();var S=B.createPointer();document.body.appendChild(S);var M=g.map((function(e){return Object(i.e)(I,e)}));M.slice(0,M.length-1).forEach((function(e,t){return Object(i.i)(e,M[t+1])}));var N=T2C.MSG.currentLanguage===T2C.MSG.PY?T2C.MSG.PY:T2C.MSG.JS;return M.forEach((function(e,t){return 2!==t&&e.setFieldValue(E[t].slice(0,E[t].length-1).map((function(e){return"terminal"===e.type?N["TERMINAL_"+e.token.toUpperCase()]:"regexp"===e.type?b[t]:e})).join(""),"EXP")})),I.setScale(1),I.getAllBlocks().forEach((function(e){return e.setMovable(!1)})),Object(i.f)(I),v.addTask(new r((function(){return!0}),{start:function(){return!0},isComplete:function(){return!0},animate:function(){return!0},finish:function(){alert("In progress: NEW YORK BASEBALL FAN - NEW YORKER IS A METS FAN OR A YANKEES FAN (HYPOTHETICAL): A New Yorker must either be a Mets fan or a Yankees fan but cannot be both. Write a line of code to set "+h[2]+" so that the computer displays true exactly when the person can be a New Yorker.")}})),B.addHelpMessageTask(v,A,(function(){return g.every((function(e,t){var n=I.getAllBlocks().find((function(t){return t.type===e}));return m[t].hasFullMatch(n.getFieldValue("EXP"),!1)}))}),(function(){return"Using the truth table, set "+h[2]+" to the appropriate Boolean expression in terms of "+h[0]+" and "+h[1]+"."}),(function(){for(var e=0;e3&&void 0!==arguments[3]?arguments[3]:1/0;return o(e.map((function(e){return n.map((function(n){return function e(t,n,o){var i=arguments.length>3&&void 0!==arguments[3]?arguments[3]:1/0;return t===n?o:0!==i&&Array.isArray(t)?t.map((function(t){return e(t,n,o,i-1)})):t}(e,t,n,i)}))})))}(e,n,function e(t){return 1===t.length?[t]:t.map((function(n,o){return e(t.slice(0,o).concat(t.slice(o+1))).map((function(e){return[t[o]].concat(e)}))})).reduce((function(e,t){return e.concat(t)}),[])}(n),t)}),[e])})))}function s(e,t){return e.reduce((function(e,n){return e.concat([t]).concat(n)}),[]).slice(1)}var u=["cs1030_17_type_in_is_mets_fan","cs1030_17_type_in_is_yankees_fan","cs1030_17_type_in_set_can_be_true_fan","cs1030_17_type_in_display_in_can_be_true_fan"],g=["isMetsFan","isYankeesFan","canBeTrueFan"],h=u.map((function(e){return new d(e,{collapseWhenFinished:!0})})),m=function(e,t){var o=t.reduce((function(e,t,o){return l(a(e,n,o+1,[function(e){return e.token===t}]),o)}),e);return t.slice().reduce((function(e,n,o){return a(e,s,t.length-o,[{token:t[t.length-1-o],type:"terminal"}])}),o)}([[g[0],{token:"and",type:"terminal"},{token:"not",type:"terminal"},g[1],{token:"or",type:"terminal"},{token:"not",type:"terminal"},g[0],{token:"and",type:"terminal"},g[1],{token:"or",type:"terminal"},{token:"not",type:"terminal"},g[0],{token:"and",type:"terminal"},{token:"not",type:"terminal"},g[1]]],["or","and"]),y=[[{token:"not",type:"terminal"},"(",g[0],{token:"and",type:"terminal"},g[1],")"],[{token:"not",type:"terminal"},"(",g[1],{token:"and",type:"terminal"},g[0],")"],[{token:"not",type:"terminal"},g[0],{token:"or",type:"terminal"},{token:"not",type:"terminal"},g[1]],[{token:"not",type:"terminal"},g[1],{token:"or",type:"terminal"},{token:"not",type:"terminal"},g[0]]],T=['"Are you a Mets fan? (true:OK or false:CANCEL)"','"Are you a Yankees fan? (true:OK or false:CANCEL)"'],_=[null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null],b=m.concat(y).map((function(e){return[{token:"let",type:"terminal"},g[2],"="].concat(e).concat([{token:/^[;]*$/,type:"regexp"}])}));b.forEach((function(e){return h[2].addPossibleMatch(e,_.slice(0,e.length))})),console.log(m.length,y.length),b.forEach((function(e){return console.log(e)}));var k=[[{token:"let",type:"terminal"},g[0],"=",{token:"confirm",type:"terminal"},"(",{token:/^"[^"]*$|^'[^']*$|^"[^"]*"|^'[^']*'/,type:"regexp"},")",{token:/^[;]*$/,type:"regexp"}],[{token:"let",type:"terminal"},g[1],"=",{token:"confirm",type:"terminal"},"(",{token:/^"[^"]*$|^'[^']*$|^"[^"]*"|^'[^']*'/,type:"regexp"},")",{token:/^[;]*$/,type:"regexp"}],null,[{token:"display",type:"terminal"},"(",g[2],")",{token:/^[;]*$/,type:"regexp"}]];k.forEach((function(e,t){return 2!==t&&h[t].addPossibleMatch(e,_.slice(0,e.length))})),h.forEach((function(e){return e.addToBlocks()}));var x=new p,E=x.createStandardHelpMessageManager(),B=e||new c,A=t||Blockly.getMainWorkspace(),v=new f(A);A.clear(),v.clearToolbox();var I=x.createPointer();document.body.appendChild(I);var w=u.map((function(e){return Object(i.e)(A,e)}));w.slice(0,w.length-1).forEach((function(e,t){return Object(i.i)(e,w[t+1])}));var S=T2C.MSG.currentLanguage===T2C.MSG.PY?T2C.MSG.PY:T2C.MSG.JS;return w.forEach((function(e,t){return 2!==t&&e.setFieldValue(k[t].slice(0,k[t].length-1).map((function(e){return"terminal"===e.type?S["TERMINAL_"+e.token.toUpperCase()]:"regexp"===e.type?T[t]:e})).join(""),"EXP")})),A.setScale(1),A.getAllBlocks().forEach((function(e){return e.setMovable(!1)})),Object(i.f)(A),B.addTask(new r((function(){return!0}),{start:function(){return!0},isComplete:function(){return!0},animate:function(){return!0},finish:function(){alert("In progress: A TRUE BASEBALL FAN - A TRUE BASEBALL FAN MAY BE A METS FAN OR A YANKEES FAN BUT NEVER BOTH (HYPOTHETICAL): A true baseball fan may be a Mets fan or a Yankees fan or neither but cannot be both. Write a line of code to set "+g[2]+" so that the computer displays true exactly when the person can be a true baseball fan.")}})),x.addHelpMessageTask(B,E,(function(){return u.every((function(e,t){var n=A.getAllBlocks().find((function(t){return t.type===e}));return h[t].hasFullMatch(n.getFieldValue("EXP"),!1)}))}),(function(){return"Using the truth table, set "+g[2]+" to the appropriate Boolean expression in terms of "+g[0]+" and "+g[1]+"."}),(function(){for(var e=0;e3&&void 0!==arguments[3]?arguments[3]:1/0;return o(e.map((function(e){return n.map((function(n){return function e(t,n,o){var i=arguments.length>3&&void 0!==arguments[3]?arguments[3]:1/0;return t===n?o:0!==i&&Array.isArray(t)?t.map((function(t){return e(t,n,o,i-1)})):t}(e,t,n,i)}))})))}(e,n,function e(t){return 1===t.length?[t]:t.map((function(n,o){return e(t.slice(0,o).concat(t.slice(o+1))).map((function(e){return[t[o]].concat(e)}))})).reduce((function(e,t){return e.concat(t)}),[])}(n),t)}),[e])})))}function s(e,t){return e.reduce((function(e,n){return e.concat([t]).concat(n)}),[]).slice(1)}var u=["cs1030_18_type_in_p","cs1030_18_type_in_q","cs1030_18_type_in_r","cs1030_18_type_in_set_exactly_two","cs1030_18_type_in_display_exactly_two"],g=["p","q","r","exactlyOne"],h=u.map((function(e){return new d(e,{collapseWhenFinished:!0})})),m=function(e,t){var o=t.reduce((function(e,t,o){return l(a(e,n,o+1,[function(e){return e.token===t}]),o)}),e);return t.slice().reduce((function(e,n,o){return a(e,s,t.length-o,[{token:t[t.length-1-o],type:"terminal"}])}),o)}([[g[0],{token:"and",type:"terminal"},{token:"not",type:"terminal"},g[1],{token:"and",type:"terminal"},{token:"not",type:"terminal"},g[2],{token:"or",type:"terminal"},g[1],{token:"and",type:"terminal"},{token:"not",type:"terminal"},g[2],{token:"and",type:"terminal"},{token:"not",type:"terminal"},g[0],{token:"or",type:"terminal"},g[2],{token:"and",type:"terminal"},{token:"not",type:"terminal"},g[0],{token:"and",type:"terminal"},{token:"not",type:"terminal"},g[1]]],["or","and"]),y=['"Enter p: (true:OK or false:CANCEL)"','"Enter q: (true:OK or false:CANCEL)"','"Enter r: (true:OK or false:CANCEL)"'],T=[null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null],_=m.map((function(e){return[{token:"let",type:"terminal"},g[3],"="].concat(e).concat([{token:/^[;]*$/,type:"regexp"}])}));_.forEach((function(e){return h[3].addPossibleMatch(e,T.slice(0,e.length))})),console.log(_,m.length);var b=[[{token:"let",type:"terminal"},g[0],"=",{token:"confirm",type:"terminal"},"(",{token:/^"[^"]*$|^'[^']*$|^"[^"]*"|^'[^']*'/,type:"regexp"},")",{token:/^[;]*$/,type:"regexp"}],[{token:"let",type:"terminal"},g[1],"=",{token:"confirm",type:"terminal"},"(",{token:/^"[^"]*$|^'[^']*$|^"[^"]*"|^'[^']*'/,type:"regexp"},")",{token:/^[;]*$/,type:"regexp"}],[{token:"let",type:"terminal"},g[2],"=",{token:"confirm",type:"terminal"},"(",{token:/^"[^"]*$|^'[^']*$|^"[^"]*"|^'[^']*'/,type:"regexp"},")",{token:/^[;]*$/,type:"regexp"}],null,[{token:"display",type:"terminal"},"(",g[3],")",{token:/^[;]*$/,type:"regexp"}]];b.forEach((function(e,t){return 3!==t&&h[t].addPossibleMatch(e,T.slice(0,e.length))})),h.forEach((function(e){return e.addToBlocks()}));var k=new p,x=k.createStandardHelpMessageManager(),E=e||new c,B=t||Blockly.getMainWorkspace(),A=new f(B);B.clear(),A.clearToolbox();var v=k.createPointer();document.body.appendChild(v);var I=u.map((function(e){return Object(i.e)(B,e)}));I.slice(0,I.length-1).forEach((function(e,t){return Object(i.i)(e,I[t+1])}));var w=T2C.MSG.currentLanguage===T2C.MSG.PY?T2C.MSG.PY:T2C.MSG.JS;return I.forEach((function(e,t){return 3!==t&&e.setFieldValue(b[t].slice(0,b[t].length-1).map((function(e){return"terminal"===e.type?w["TERMINAL_"+e.token.toUpperCase()]:"regexp"===e.type?y[t]:e})).join(""),"EXP")})),B.setScale(1),B.getAllBlocks().forEach((function(e){return e.setMovable(!1)})),Object(i.f)(B),E.addTask(new r((function(){return!0}),{start:function(){return!0},isComplete:function(){return!0},animate:function(){return!0},finish:function(){alert("In progress: 3 Letters: Exactly One. Write a line of code to set "+g[3]+" so that the computer displays true exactly when one of "+g[0]+", "+g[1]+", "+g[2]+" is true.")}})),k.addHelpMessageTask(E,x,(function(){return u.every((function(e,t){var n=B.getAllBlocks().find((function(t){return t.type===e}));return h[t].hasFullMatch(n.getFieldValue("EXP"),!1)}))}),(function(){return"Using the truth table, set "+g[3]+" to the appropriate Boolean expression in terms of "+g[0]+", "+g[1]+", and "+g[2]+"."}),(function(){for(var e=0;e