"use strict";function initLanguage(e){var l=e||"en";"en"!==l&&injectLanguageJsSources(l)}function logout(){$.ajax("".concat(CCB.base_url,"api/logout"),{type:"GET",xhrFields:{withCredentials:!0},success:function(){appendIframe("TM_login"),$("#TM_login").children().css("height","820px"),appendIframe("before_login"),appendIframe("cloud_askLogin"),Materialize.toast(CCB.str_group.success_userLogout,4e3),CCB.userState=!1,$("#cloud_fileListArea").html(""),loginModalStatus(),$("#modal_logout_btn").addClass("blue"),$(".svgImg").css("display","none"),$(".translate-signout").css("opacity","1")}})}function getUrlLanguage(){var e=location.search.match(new RegExp("[?&]lang=([^&]+)")),l=e?decodeURIComponent(e[1].replace(/\+/g,"%20")):"";return["en","zh-hant","zh-hans"].indexOf(l)<0?"zh-hant":l}function injectLanguageJsSources(e){var l=document.getElementsByTagName("head")[0],o=document.createElement("script"),n=createAjaxRequest(),c="msg/".concat(e,".js");try{n.open("GET",c,!1),n.send(""),o.text=n.responseText}catch(e){o.src=c}l.appendChild(o);var t=document.createElement("script");t.src="blockly/msg/js/".concat(e,".js"),l.appendChild(t)}function createAjaxRequest(){var l=!1;try{l=new XMLHttpRequest}catch(e){try{l=new ActiveXObject("Msxml2.XMLHTTP")}catch(e){try{l=new ActiveXObject("Microsoft.XMLHTTP")}catch(e){throw"Your browser does not support AJAX. You will not be able touse all of Ardublockly features."}}}return l}function updateLanguageText(){for(var e in LOCALISED_TEXT)for(var l=document.getElementsByClassName("translate-".concat(e)),o=0;o[xml]  ":"[py]  ")+$(".HarxA")[o].children[n].innerHTML,ai_tt.children[n].onclick=function(o,n){return function(){"Main"==c[o][n].split("/")[0]?($("#mode")[0].selectedIndex=0,$("#mode")[0].onchange(),$(".selectMode_input")[0].value=Ardublockly.LOCALISED_TEXT.iot_module):($("#mode")[0].selectedIndex=1,$("#mode")[0].onchange(),$(".selectMode_input")[0].value=Ardublockly.LOCALISED_TEXT.ai_module),$(".ModeSelect")[0].className="ModeSelect",readTxt("/src/python/"+c[o][n],function(e){if("xml"==c[o][n].split(".")[1]){var l=Blockly.Xml.textToDom(e);blockpy.components.editor.setBlocksFromXml(l)}else blockpy.components.editor.codeMirror.setValue(e)})}}(o,n)),$(".HarxA")[o].children[n].innerHTML=("xml"==c[o][n].split(".")[1]?"[xml]  ":"[py]  ")+$(".HarxA")[o].children[n].innerHTML,$(".HarxA")[o].children[n].onclick=function(o,n){return function(){"Main"==c[o][n].split("/")[0]?($("#mode")[0].selectedIndex=0,$("#mode")[0].onchange(),$(".selectMode_input")[0].value=Ardublockly.LOCALISED_TEXT.iot_module):($("#mode")[0].selectedIndex=1,$("#mode")[0].onchange(),$(".selectMode_input")[0].value=Ardublockly.LOCALISED_TEXT.ai_module),$(".ModeSelect")[0].className="ModeSelect",readTxt("/src/python/"+c[o][n],function(e){if("xml"==c[o][n].split(".")[1]){var l=Blockly.Xml.textToDom(e);blockpy.components.editor.setBlocksFromXml(l)}else blockpy.components.editor.codeMirror.setValue(e)})}}(o,n);$(".qiehuanbtn")[0].onclick=function(e){CCB.socket&&CCB.socket.id&&(U.UF.EV.stopBubble(),"en"==Ardublockly.LANG?$("#localsssssaveOrOpen")[0].className="dropdown-content qiehuan qiehuanposi":$("#localsssssaveOrOpen")[0].className="dropdown-content qiehuan")};var t=$("#localsssssaveOrOpen")[0].children;for(o=0;o a").dropdown("open")}),$("#file-tool").click(function(){return $("#side-file-trigger > a").dropdown("open")}),$("#blockpy-content > .blockpy-editor img.fullscreenIcon").click(function(e){$(e.currentTarget.parentNode).toggleClass("fullscreen"),$("#blockpy-content > .blockpy-editor img.fullscreenIcon").toggleClass("hidden"),$("html").toggleClass("fullscreenMode"),setTimeout(function(){Blockly.svgResize(blockpy.components.editor.blockly),Blockly.svgResize(Blockly.mainWorkspace)},100)}),$("#blockpy-content .card-header > img.fullscreenIcon").click(function(e){$(e.currentTarget.parentNode.parentNode).toggleClass("fullscreen"),$("#blockpy-content .card-header > img.fullscreenIcon").toggleClass("hidden"),$("html").toggleClass("fullscreenMode"),setTimeout(function(){return $(".blockpy-toolbar > .blockpy-text").css("height","90%").css("height","100%")},0)}),setTimeout(function(){document.body.clientWidth<1265&&alert(CCB.str_group.alert)},1e3)}),window.onbeforeunload=window.onunload=function(){0==$("#mode")[0].selectedIndex?(saveLocalStorage("type",0),saveLocalStorageBlocks("pythonmc-mode-blocks-xml")):(saveLocalStorage("type",1),saveLocalStorageBlocks("pythonai-mode-blocks-xml"))},window.onload=function(){window.location.hash.substring(1);$(".dropdown-trigger").dropdown(),setTimeout(function(){return $(".modal").modal()},0),blockpy=new BlockPy({blocklyPath:"blockly/",attachmentPoint:document.getElementById("blockpy-div"),instructor:!getQueryParams().instructor||"true"==getQueryParams().instructor,developer:!0,editor:getQueryParams().mode||"Split",urls:{}});var e=calculate_size($("#term")[0]);term=new Terminal({cols:e[0],rows:e[1],useStyle:!0,screenKeys:!0,cursorBlink:!1}),term.open(document.getElementById("term")),$(".filled-in")[0].onclick=function(){var e=$(".filled-in")[0],l=$(".filled-in")[0].parentNode;e.checked?(l.children[1].className="translatable_Adapter_connected",l.children[1].innerHTML=CCB.str_group.Adapter_connected):(l.children[1].className="filled-in_nocheked translatable_Adapter_fill_connected",l.children[1].innerHTML=CCB.str_group.Adapter_fill_connected)},setTimeout(function(){cocoblockly()},0),$(".blockpy-toolbar-download").on("click",function(){return export_data(pythonnewcode||Blockly.Python.workspaceToCode(blockpy.components.editor.blockly)||blockpy.components.editor.codeMirror.getValue(),".py",0)});var o=$("#pyFileImport > input");o.change(function(){var e=new FileReader,l=o[0].files[0];e.onload=function(e){var l=e.target.result;blockpy.components.editor.codeMirror.setValue(l)},e.readAsText(l),o.val("")}),$(".blockpy-toolbar-upload").click(function(e){return $("#pyFileImport > input").click()}),fanyi(),selectOnload(),styled();var l=document.createElement("iframe");l.src="//project-x.cocorobo.cn/",l.style.width="100%",l.style.height="50vh",document.getElementById("iframe").appendChild(l),$("#toggle-button").click(function(){$("#toggle-button")[0].checked?$("#edit")[0].style.display="none":$("#edit")[0].style.display="block"})};var debounce=function(o,n,c){var t;return function(){var e=this,l=arguments;t?clearTimeout(t):c&&o.apply(e,l),t=setTimeout(function(){c||o.apply(e,l),t=null},n||100)}};window.onresize=debounce(function(){document.body.clientWidth<1265&&alert(CCB.str_group.alert)},100,!0);