${We(p("codegen_pseudocode_hint"))}
+ + + +${Ee(p("codegen_pseudocode_hint"))}
${We(p("codegen_generated_hint"))}
- `;const e=a=>this.element.querySelector(a);this.codeView=e(".code-view"),this.javaModeRow=e(".java-mode"),this.runButton=e("[data-act=run]"),this.saveButton=e("[data-act=save]"),this.copyButton=e("[data-act=copy]"),this.runner=e(".runner"),this.runOutput=e(".runner-out"),this.runInput=e(".runner-input"),this.pseudocodeBox=e("[data-opt=pseudocode]"),this.pseudocodeHint=e(".pseudocode-hint"),this.pseudocodeBox.addEventListener("change",()=>this.setPseudocode(this.pseudocodeBox.checked)),e(".code-close").addEventListener("click",()=>this.onClose());for(const a of this.element.querySelectorAll("[data-target]"))a.addEventListener("click",()=>{this.target=a.dataset.target,na(vn.target,this.target),this.refresh()});for(const a of this.element.querySelectorAll("[data-java-mode]"))a.addEventListener("click",()=>{this.javaMode=a.dataset.javaMode,na(vn.javaMode,this.javaMode),this.refresh()});const t=e("[data-opt=comments]");t.checked=this.comments,t.addEventListener("change",()=>{this.comments=t.checked,na(vn.comments,String(this.comments)),this.refresh()});const n=e("[data-opt=emptyElse]");n.checked=this.emptyElse,n.addEventListener("change",()=>{this.emptyElse=n.checked,na(vn.emptyElse,String(this.emptyElse)),this.refresh()}),this.copyButton.addEventListener("click",()=>this.copy()),this.saveButton.addEventListener("click",()=>{const a=qs(this.classStem()),s=Su(this.currentDocument(),this.classStem(),this.options());this.saveFile(`${a}.java`,s)}),this.runButton.addEventListener("click",()=>this.run()),e("[data-act=stop]").addEventListener("click",()=>this.stopRun(!1)),e("[data-act=cancel]").addEventListener("click",()=>this.answer(null)),this.runInput.addEventListener("submit",a=>{a.preventDefault(),this.answer(this.runInput.querySelector("input").value)})}async copy(){var t;let e=!1;try{await navigator.clipboard.writeText(this.code),e=!0}catch{const n=document.createRange();n.selectNodeContents(this.codeView);const a=getSelection();a==null||a.removeAllRanges(),a==null||a.addRange(n),e=((t=document.execCommand)==null?void 0:t.call(document,"copy"))??!1}this.copyButton.textContent=p(e?"web_copied_check":"web_copy_manual"),setTimeout(()=>this.copyButton.textContent=p("codegen_copy"),2e3)}run(){this.stopRun(!0),this.runner.hidden=!1,this.runOutput.textContent="",this.outputLines=[],this.droppedLines=0,this.runOutput.classList.remove("error");const e=jb(this.code),t=n=>this.onRunnerMessage(n);try{const n=URL.createObjectURL(new Blob([Db],{type:"text/javascript"})),a=new Worker(n);URL.revokeObjectURL(n),a.onmessage=s=>t(s.data),a.onerror=s=>{s.preventDefault(),t({type:"error",text:s.message||p("web_run_error")})},a.postMessage({type:"run",code:e}),this.worker=a}catch{this.runInPage(e,t)}this.setRunning(!0)}runInPage(e,t){const n={log:(...r)=>t({type:"log",lines:[r.map(o=>typeof o=="string"?o:JSON.stringify(o)).join(" ")]})},a=r=>new Promise((o,l)=>{this.pendingAnswer=u=>u===null?l(new Error(Wh())):o(u),t({type:"prompt",text:r})}),s=(async()=>{}).constructor;new s("__visuStructPrompt","console",e)(a,n).then(()=>t({type:"done"})).catch(r=>t({type:"error",text:String(r)}))}onRunnerMessage(e){switch(e.type){case"log":this.appendOutput(e.lines??[]);break;case"prompt":{this.runInput.hidden=!1,this.runInput.querySelector("label").textContent=e.text??"";const t=this.runInput.querySelector("input");t.value="",t.focus();break}case"error":this.appendOutput([e.text??""]),this.runOutput.classList.add("error"),this.stopRun(!1);break;case"done":this.stopRun(!1);break}}appendOutput(e){this.outputLines.push(...e),this.outputLines.length>yr&&(this.droppedLines+=this.outputLines.length-yr,this.outputLines.splice(0,this.outputLines.length-yr)),this.outputFrame===void 0&&(this.outputFrame=requestAnimationFrame(()=>{this.outputFrame=void 0;const t=this.droppedLines>0?p("web_run_dropped_fmt",this.droppedLines)+` +${Ee(p("codegen_generated_hint"))}
+ `;const e=a=>this.element.querySelector(a);this.codeView=e(".code-view"),this.javaModeRow=e(".java-mode"),this.runButton=e("[data-act=run]"),this.saveButton=e("[data-act=save]"),this.copyButton=e("[data-act=copy]"),this.runner=e(".runner"),this.runOutput=e(".runner-out"),this.runInput=e(".runner-input"),this.pseudocodeBox=e("[data-opt=pseudocode]"),this.pseudocodeHint=e(".pseudocode-hint"),this.pseudocodeBox.addEventListener("change",()=>this.setPseudocode(this.pseudocodeBox.checked)),e(".code-close").addEventListener("click",()=>this.onClose());for(const a of this.element.querySelectorAll("[data-target]"))a.addEventListener("click",()=>{this.target=a.dataset.target,na(vn.target,this.target),this.refresh()});for(const a of this.element.querySelectorAll("[data-java-mode]"))a.addEventListener("click",()=>{this.javaMode=a.dataset.javaMode,na(vn.javaMode,this.javaMode),this.refresh()});const t=e("[data-opt=comments]");t.checked=this.comments,t.addEventListener("change",()=>{this.comments=t.checked,na(vn.comments,String(this.comments)),this.refresh()});const n=e("[data-opt=emptyElse]");n.checked=this.emptyElse,n.addEventListener("change",()=>{this.emptyElse=n.checked,na(vn.emptyElse,String(this.emptyElse)),this.refresh()}),this.copyButton.addEventListener("click",()=>this.copy()),this.saveButton.addEventListener("click",()=>{const a=Qs(this.classStem()),s=Su(this.currentDocument(),this.classStem(),this.options());this.saveFile(`${a}.java`,s)}),this.runButton.addEventListener("click",()=>this.run()),e("[data-act=stop]").addEventListener("click",()=>this.stopRun(!1)),e("[data-act=cancel]").addEventListener("click",()=>this.answer(null)),this.runInput.addEventListener("submit",a=>{a.preventDefault(),this.answer(this.runInput.querySelector("input").value)})}async copy(){var t;let e=!1;try{await navigator.clipboard.writeText(this.code),e=!0}catch{const n=document.createRange();n.selectNodeContents(this.codeView);const a=getSelection();a==null||a.removeAllRanges(),a==null||a.addRange(n),e=((t=document.execCommand)==null?void 0:t.call(document,"copy"))??!1}this.copyButton.textContent=p(e?"web_copied_check":"web_copy_manual"),setTimeout(()=>this.copyButton.textContent=p("codegen_copy"),2e3)}run(){this.stopRun(!0),this.runner.hidden=!1,this.runOutput.textContent="",this.outputLines=[],this.droppedLines=0,this.runOutput.classList.remove("error");const e=Ob(this.code),t=n=>this.onRunnerMessage(n);try{const n=URL.createObjectURL(new Blob([Db],{type:"text/javascript"})),a=new Worker(n);URL.revokeObjectURL(n),a.onmessage=s=>t(s.data),a.onerror=s=>{s.preventDefault(),t({type:"error",text:s.message||p("web_run_error")})},a.postMessage({type:"run",code:e}),this.worker=a}catch{this.runInPage(e,t)}this.setRunning(!0)}runInPage(e,t){const n={log:(...r)=>t({type:"log",lines:[r.map(o=>typeof o=="string"?o:JSON.stringify(o)).join(" ")]})},a=r=>new Promise((o,l)=>{this.pendingAnswer=u=>u===null?l(new Error(Eh())):o(u),t({type:"prompt",text:r})}),s=(async()=>{}).constructor;new s("__visuStructPrompt","console",e)(a,n).then(()=>t({type:"done"})).catch(r=>t({type:"error",text:String(r)}))}onRunnerMessage(e){switch(e.type){case"log":this.appendOutput(e.lines??[]);break;case"prompt":{this.runInput.hidden=!1,this.runInput.querySelector("label").textContent=e.text??"";const t=this.runInput.querySelector("input");t.value="",t.focus();break}case"error":this.appendOutput([e.text??""]),this.runOutput.classList.add("error"),this.stopRun(!1);break;case"done":this.stopRun(!1);break}}appendOutput(e){this.outputLines.push(...e),this.outputLines.length>yr&&(this.droppedLines+=this.outputLines.length-yr,this.outputLines.splice(0,this.outputLines.length-yr)),this.outputFrame===void 0&&(this.outputFrame=requestAnimationFrame(()=>{this.outputFrame=void 0;const t=this.droppedLines>0?p("web_run_dropped_fmt",this.droppedLines)+` `:"";this.runOutput.textContent=t+this.outputLines.join(` `)+(this.outputLines.length?` -`:""),this.runOutput.scrollTop=this.runOutput.scrollHeight}))}answer(e){var t;this.runInput.hidden=!0,this.worker?this.worker.postMessage({type:"answer",value:e}):(t=this.pendingAnswer)==null||t.call(this,e),this.pendingAnswer=void 0}stopRun(e){var t;(t=this.worker)==null||t.terminate(),this.worker=void 0,this.pendingAnswer=void 0,this.runInput&&(this.runInput.hidden=!0),e&&this.runner&&(this.runner.hidden=!0),this.setRunning(!1)}setRunning(e){const t=this.element.querySelector("[data-act=stop]");t&&(t.disabled=!e)}}const De=(i,e=!1)=>``,se={newFile:De('${e[Number(a)]}`)}function Tn(i){const e=[],t=i.replace(/\r\n/g,`
+${l}`)}Na=aM(((o=e.find(([l])=>l==="begriffe.md"))==null?void 0:o[1])??"")}const Vu={1:3,2:5,3:5,4:8,5:11,6:11,7:11,8:11,9:11,10:11,11:11,12:11,13:11,14:11,15:11,16:14,17:15,18:15,19:17,20:17,21:17,22:18},Qu=i=>i.map(([e])=>{var t;return Number((t=/^(\d+)/.exec(e))==null?void 0:t[1])}).filter(Number.isFinite).sort((e,t)=>e-t);function NM(i,e){const t=[...i].reverse().find(o=>o<=19)??i.at(-1)??0,n=o=>i.includes(Vu[o])?Vu[o]:t,a=new Map,s=new Map;let r=1;for(const o of i){a.set(o,r++);for(const l of e.filter(u=>n(u)===o))s.set(l,r++)}return{normal:a,robot:s}}function qu(i,e){return e?i.replace(/\b(Lektion(?:en)?|Lessons?|Li[cç](?:ão|ões))(\s+\d+(?:\s*(?:,|bis|und|and|to|a|e|–|-)\s*\d+)*)/gi,(t,n,a)=>n+a.replace(/\d+/g,s=>String(e.get(Number(s))??s))):i}fs("en");function eg(i,e){return I1==="de"?i.get(e)??i.get(`en/${e}`):(I1==="en"?void 0:i.get(`${I1}/${e}`))??i.get(`en/${e}`)??i.get(e)}const tg=(i,e)=>i.slice(i.indexOf(e)+e.length),JM=new Map(Object.entries(LM).map(([i,e])=>[tg(i,"/diagramme/"),e]));function ti(i){const e=eg(JM,i);return e===void 0?void 0:Nl(e)}const FM=new Map(Object.entries(EM).map(([i,e])=>[tg(i,"/bilder/"),e]));function zr(i){return eg(FM,i)}const RM=new Map(Object.entries(WM).map(([i,e])=>[Kh(i).replace(/\.txt$/,""),e])),Uu=new Map;function Ja(i){const e=RM.get(i);if(e===void 0)return;let t=Uu.get(i);return t||Uu.set(i,t=Gb(e)),t}const ng=i=>i.replace(/&/g,"&").replace(//g,">").replace(/"/g,""");function Ce(i){const e=[];let t=ng(i).replace(/`([^`]+)`/g,(n,a)=>(e.push(a),`\0${e.length-1}\0`));return t=t.replace(/\*\*(.+?)\*\*/g,"$1").replace(/(^|[^*])\*([^*\s][^*]*?)\*/g,"$1$2").replace(/\[([^\]]+)\]\(([^)\s]+)\)/g,(n,a,s)=>{const r=/^(https?:|mailto:|#|\.{0,2}\/)/.test(s)?s:"#",o=/^https?:/.test(r)?' target="_blank" rel="noopener noreferrer"':"";return`${a}`}).replace(/\[([^\]]+)\]\{\.(blau|orange|gruen|gelb|rosa)\}/g,'$1').replace(/\[([^\]]+)\]\{(?:teil|part)=([\w,]+)\}/g,'$1'),t.replace(/\u0000(\d+)\u0000/g,(n,a)=>`${e[Number(a)]}`)}function Tn(i){const e=[],t=i.replace(/\r\n/g,`
`).split(`
-`);let n=0;for(;n${ng(m.join(`
-`))}`);continue}const s=/^(#{2,4})\s+(.*)$/.exec(a);if(s){const o=s[1].length;e.push(`| ${c} | `).join("")}
|---|
| ${m} | `).join("")}
${Ce(r.join(" "))}
`)}return e.join(` -`)}const ra=""+new URL("ludwig-Cus1i402.webp",import.meta.url).href,Zo="f4ecc8e489ae7865308288c7d0fa313333cf2be3ff529b23bc214bee010310e0",r0="visustruct.learn.teacher";let o0=!1;function $u(){if(o0)return!0;try{return localStorage.getItem(r0)===Zo}catch{return!1}}async function EB(i){const e=await crypto.subtle.digest("SHA-256",new TextEncoder().encode(i));return[...new Uint8Array(e)].map(t=>t.toString(16).padStart(2,"0")).join("")}async function WB(i){let e=!1;try{e=await EB(i.trim())===Zo}catch{return!1}if(e){o0=!0;try{localStorage.setItem(r0,Zo)}catch{}}return e}function NB(){o0=!1;try{localStorage.removeItem(r0)}catch{}}function ig(i,e,t=!1){const n=document.createElement("figure");n.className=t?"learn-file written":"learn-file";const a=document.createElement("figcaption"),s=document.createElement("span");s.className="learn-file-icon",s.setAttribute("aria-hidden","true"),s.textContent="📄",a.append(s,t?p("web_sim_written_file_fmt",i):i);const r=document.createElement("pre");return r.className="learn-file-text",r.dir="ltr",e.replace(/\n$/,"").split(` -`).forEach((l,u)=>{const c=document.createElement("span");c.className="ln",c.textContent=String(u+1),r.append(c,l+` -`)}),n.append(a,r),n}function ag(i){return[...i].map(([e,t])=>ig(e,t,!0))}function t1(i){switch(i.kind){case"finished":return p("sim_notice_finished");case"infiniteLoopWithoutBody":return p("sim_notice_infinite_loop_empty");case"unsupportedStatement":return p("sim_notice_unsupported_statement_fmt",i.text);case"invalidExpression":return p("sim_notice_invalid_expression_fmt",i.text);case"unknownVariable":return p("sim_notice_unknown_variable_fmt",i.text);case"divisionByZero":return p("sim_notice_division_by_zero");case"wholeNumberExpected":return p("sim_notice_whole_number_expected");case"numberExpected":return p("sim_notice_number_expected");case"booleanExpected":return p("sim_notice_boolean_expected");case"subprogramNotFound":return p("sim_notice_subprogram_not_found_fmt",i.text);case"callTooDeep":return p("sim_notice_call_too_deep");case"callArguments":return p("web_sim_call_arguments_fmt",i.text);case"missingReturn":return p("web_sim_missing_return_fmt",i.text);case"fileNotFound":return p("web_sim_file_not_found_fmt",i.text);case"endOfFile":return p("web_sim_end_of_file_fmt",i.text);case"nullValue":return p("web_sim_null_value_fmt",i.text);case"other":return i.text}}const Be=i=>i.replace(/&/g,"&").replace(//g,">").replace(/"/g,"""),Yu=["0.2","0.5","1.0","1.5","2.0"],FB=i=>Number(i).toLocaleString(s1()==="java"?"en":s1(),{minimumFractionDigits:1}),Ir="visustruct.simulation.stepDelay",Xu="visustruct.simulation.highlightMode";function kr(i){try{return localStorage.getItem(i)}catch{return null}}function Ku(i,e){try{localStorage.setItem(i,e)}catch{}}class JB{constructor(e,t,n=()=>{},a=()=>{},s=()=>{}){y(this,"element");y(this,"engine");y(this,"isPlaying",!1);y(this,"playTimer");y(this,"wasPlayingBeforeInput",!1);y(this,"delay",Yu.includes(kr(Ir)??"")?kr(Ir):"0.5");y(this,"highlightMode",kr(Xu)==="nextToExecute"?"nextToExecute":"lastExecuted");y(this,"buttons");y(this,"inputSection");y(this,"trace");y(this,"variables");y(this,"output");y(this,"transcript",[]);y(this,"printed",0);y(this,"notice");y(this,"editButton");y(this,"robot");y(this,"liveBusy",!1);this.currentDocument=e,this.onHighlight=t,this.findSubprogram=n,this.onEdit=a,this.onTranscript=s,this.engine=new wi(e(),n),this.element=document.createElement("aside"),this.element.className="simpanel",this.build()}setRobot(e){var t;this.robot!==e&&((t=this.robot)==null||t.element.remove(),this.robot=e,e&&(this.element.querySelector("section").after(e.element),e.onWorldChange=()=>this.restartEngine(),e.reset()))}showRobot(){var e;(e=this.robot)==null||e.show()}begin(){this.pause(),this.restartEngine(),this.showRobot()}end(){this.pause()}step(){var n,a,s;if((n=this.robot)!=null&&n.live){this.stepLive();return}if(!this.engine.canStep){this.pause();return}const e=this.isPlaying,t=this.engine.currentStepPath;(a=this.robot)==null||a.prepare(this.engine),this.engine.step(),(s=this.robot)==null||s.follow(this.engine.state.robotActions,e?Number(this.delay)*850:450),this.afterStep(e,t)}async stepLive(){if(this.liveBusy)return;if(!this.engine.canStep){this.pause();return}this.liveBusy=!0;const e=this.robot,t=this.isPlaying,n=this.engine.currentStepPath;try{await e.prepareLive(this.engine,x3(JSON.stringify(this.currentDocument()))),this.engine.step(),e.follow(this.engine.state.robotActions,450),await e.drive(this.engine.state.robotActions)}catch(a){e.liveFailed(a),this.isPlaying=!1}finally{this.liveBusy=!1}this.afterStep(t,n)}afterStep(e,t){this.collectOutput(),this.highlightMode==="nextToExecute"&&this.engine.canStep?this.onHighlight(this.engine.currentStepPath):this.onHighlight(t??this.engine.currentStepPath),this.engine.state.inputRequest&&e&&(this.wasPlayingBeforeInput=!0),this.engine.canStep||this.pause(),this.update()}reset(){this.pause(),this.restartEngine()}play(){if(this.isPlaying||!this.engine.canStep)return;this.isPlaying=!0;const e=async()=>{var t;this.playTimer=void 0,this.isPlaying&&((t=this.robot)!=null&&t.live?await this.stepLive():this.step(),this.isPlaying&&this.engine.canStep?this.playTimer=window.setTimeout(()=>void e(),Number(this.delay)*1e3):(this.isPlaying=!1,this.update()))};e()}pause(){this.playTimer!==void 0&&window.clearTimeout(this.playTimer),this.playTimer=void 0,this.isPlaying=!1,this.update()}submitInput(e){var s,r;const t=this.isPlaying||this.wasPlayingBeforeInput;this.pause();const n=((s=this.engine.state.inputRequest)==null?void 0:s.prompt)??"",a=(r=this.engine.state.inputRequest)==null?void 0:r.continuesLine;if(this.engine.provideInput(e.value),!this.engine.state.inputRequest){const o=this.transcript[this.transcript.length-1];a&&o&&o.typed===void 0?o.typed=e.value:this.transcript.push({text:n?`${n} `:"",typed:e.value}),e.value=""}this.onHighlight(this.engine.currentStepPath),t&&this.engine.canStep&&(this.wasPlayingBeforeInput=!1,this.play()),this.update()}restartEngine(){var e;this.engine=new wi(this.currentDocument(),this.findSubprogram),this.transcript=[],this.printed=0,this.wasPlayingBeforeInput=!1,(e=this.robot)==null||e.reset(),this.onHighlight(this.engine.currentStepPath),this.update()}build(){this.element.innerHTML=` +`)}const ra=""+new URL("ludwig-Cus1i402.webp",import.meta.url).href,Bo="f4ecc8e489ae7865308288c7d0fa313333cf2be3ff529b23bc214bee010310e0",r0="visustruct.learn.teacher";let o0=!1;function $u(){if(o0)return!0;try{return localStorage.getItem(r0)===Bo}catch{return!1}}async function GM(i){const e=await crypto.subtle.digest("SHA-256",new TextEncoder().encode(i));return[...new Uint8Array(e)].map(t=>t.toString(16).padStart(2,"0")).join("")}async function HM(i){let e=!1;try{e=await GM(i.trim())===Bo}catch{return!1}if(e){o0=!0;try{localStorage.setItem(r0,Bo)}catch{}}return e}function VM(){o0=!1;try{localStorage.removeItem(r0)}catch{}}function ig(i,e,t=!1){const n=document.createElement("figure");n.className=t?"learn-file written":"learn-file";const a=document.createElement("figcaption"),s=document.createElement("span");s.className="learn-file-icon",s.setAttribute("aria-hidden","true"),s.textContent="📄",a.append(s,t?p("web_sim_written_file_fmt",i):i);const r=document.createElement("pre");return r.className="learn-file-text",r.dir="ltr",e.replace(/\n$/,"").split(` +`).forEach((l,u)=>{const m=document.createElement("span");m.className="ln",m.textContent=String(u+1),r.append(m,l+` +`)}),n.append(a,r),n}function ag(i){return[...i].map(([e,t])=>ig(e,t,!0))}function t1(i){switch(i.kind){case"finished":return p("sim_notice_finished");case"infiniteLoopWithoutBody":return p("sim_notice_infinite_loop_empty");case"unsupportedStatement":return p("sim_notice_unsupported_statement_fmt",i.text);case"invalidExpression":return p("sim_notice_invalid_expression_fmt",i.text);case"unknownVariable":return p("sim_notice_unknown_variable_fmt",i.text);case"divisionByZero":return p("sim_notice_division_by_zero");case"wholeNumberExpected":return p("sim_notice_whole_number_expected");case"numberExpected":return p("sim_notice_number_expected");case"booleanExpected":return p("sim_notice_boolean_expected");case"subprogramNotFound":return p("sim_notice_subprogram_not_found_fmt",i.text);case"callTooDeep":return p("sim_notice_call_too_deep");case"callArguments":return p("web_sim_call_arguments_fmt",i.text);case"missingReturn":return p("web_sim_missing_return_fmt",i.text);case"fileNotFound":return p("web_sim_file_not_found_fmt",i.text);case"endOfFile":return p("web_sim_end_of_file_fmt",i.text);case"nullValue":return p("web_sim_null_value_fmt",i.text);case"other":return i.text}}const Me=i=>i.replace(/&/g,"&").replace(//g,">").replace(/"/g,"""),Yu=["0.2","0.5","1.0","1.5","2.0"],QM=i=>Number(i).toLocaleString(s1()==="java"?"en":s1(),{minimumFractionDigits:1}),Ir="visustruct.simulation.stepDelay",Xu="visustruct.simulation.highlightMode";function kr(i){try{return localStorage.getItem(i)}catch{return null}}function Ku(i,e){try{localStorage.setItem(i,e)}catch{}}class qM{constructor(e,t,n=()=>{},a=()=>{},s=()=>{}){y(this,"element");y(this,"engine");y(this,"isPlaying",!1);y(this,"playTimer");y(this,"wasPlayingBeforeInput",!1);y(this,"delay",Yu.includes(kr(Ir)??"")?kr(Ir):"0.5");y(this,"highlightMode",kr(Xu)==="nextToExecute"?"nextToExecute":"lastExecuted");y(this,"buttons");y(this,"inputSection");y(this,"trace");y(this,"variables");y(this,"output");y(this,"transcript",[]);y(this,"printed",0);y(this,"notice");y(this,"editButton");y(this,"robot");y(this,"liveBusy",!1);this.currentDocument=e,this.onHighlight=t,this.findSubprogram=n,this.onEdit=a,this.onTranscript=s,this.engine=new wi(e(),n),this.element=document.createElement("aside"),this.element.className="simpanel",this.build()}setRobot(e){var t;this.robot!==e&&((t=this.robot)==null||t.element.remove(),this.robot=e,e&&(this.element.querySelector("section").after(e.element),e.onWorldChange=()=>this.restartEngine(),e.reset()))}showRobot(){var e;(e=this.robot)==null||e.show()}begin(){this.pause(),this.restartEngine(),this.showRobot()}end(){this.pause()}step(){var n,a,s;if((n=this.robot)!=null&&n.live){this.stepLive();return}if(!this.engine.canStep){this.pause();return}const e=this.isPlaying,t=this.engine.currentStepPath;(a=this.robot)==null||a.prepare(this.engine),this.engine.step(),(s=this.robot)==null||s.follow(this.engine.state.robotActions,e?Number(this.delay)*850:450),this.afterStep(e,t)}async stepLive(){if(this.liveBusy)return;if(!this.engine.canStep){this.pause();return}this.liveBusy=!0;const e=this.robot,t=this.isPlaying,n=this.engine.currentStepPath;try{await e.prepareLive(this.engine,x3(JSON.stringify(this.currentDocument()))),this.engine.step(),e.follow(this.engine.state.robotActions,450),await e.drive(this.engine.state.robotActions)}catch(a){e.liveFailed(a),this.isPlaying=!1}finally{this.liveBusy=!1}this.afterStep(t,n)}afterStep(e,t){this.collectOutput(),this.highlightMode==="nextToExecute"&&this.engine.canStep?this.onHighlight(this.engine.currentStepPath):this.onHighlight(t??this.engine.currentStepPath),this.engine.state.inputRequest&&e&&(this.wasPlayingBeforeInput=!0),this.engine.canStep||this.pause(),this.update()}reset(){this.pause(),this.restartEngine()}play(){if(this.isPlaying||!this.engine.canStep)return;this.isPlaying=!0;const e=async()=>{var t;this.playTimer=void 0,this.isPlaying&&((t=this.robot)!=null&&t.live?await this.stepLive():this.step(),this.isPlaying&&this.engine.canStep?this.playTimer=window.setTimeout(()=>void e(),Number(this.delay)*1e3):(this.isPlaying=!1,this.update()))};e()}pause(){this.playTimer!==void 0&&window.clearTimeout(this.playTimer),this.playTimer=void 0,this.isPlaying=!1,this.update()}submitInput(e){var s,r;const t=this.isPlaying||this.wasPlayingBeforeInput;this.pause();const n=((s=this.engine.state.inputRequest)==null?void 0:s.prompt)??"",a=(r=this.engine.state.inputRequest)==null?void 0:r.continuesLine;if(this.engine.provideInput(e.value),!this.engine.state.inputRequest){const o=this.transcript[this.transcript.length-1];a&&o&&o.typed===void 0?o.typed=e.value:this.transcript.push({text:n?`${n} `:"",typed:e.value}),e.value=""}this.onHighlight(this.engine.currentStepPath),t&&this.engine.canStep&&(this.wasPlayingBeforeInput=!1,this.play()),this.update()}restartEngine(){var e;this.engine=new wi(this.currentDocument(),this.findSubprogram),this.transcript=[],this.printed=0,this.wasPlayingBeforeInput=!1,(e=this.robot)==null||e.reset(),this.onHighlight(this.engine.currentStepPath),this.update()}build(){this.element.innerHTML=`${Be(p("simulation_variables_placeholder"))}
`;else{const r=document.createElement("table");for(const o of n){const l=r.insertRow();l.insertCell().textContent=o;const u=e.variables.get(o),c=l.insertCell();u.kind==="grid"?c.append(sg(u)):c.textContent=_e(u)}this.variables.replaceChildren(r)}e.outputLines.length===0&&e.files.size===0?this.output.innerHTML=`${Be(p("simulation_output_placeholder"))}
`:(this.output.replaceChildren(...e.outputLines.map(r=>{const o=document.createElement("div");return o.textContent=r,o}),...ag(e.files)),this.output.scrollTop=this.output.scrollHeight)}updateInput(){const e=this.engine.state.inputRequest,t=this.inputSection;if(t.parentElement.classList.toggle("active",!!e),!e){t.innerHTML=`${Be(p("simulation_input_placeholder"))}
`;return}let n=t.querySelector("form");if(!n){n=document.createElement("form"),n.innerHTML=``;const l=n.querySelector("input");n.addEventListener("submit",u=>{u.preventDefault(),this.submitInput(l)}),t.replaceChildren(n),requestAnimationFrame(()=>l.focus())}const a=this.engine.state.outputLines;n.querySelector(".sim-prompt").textContent=e.prompt||(a[a.length-1]??"");const s=n.querySelector("input");s.inputMode=e.valueType==="string"||e.valueType==="boolean"?"text":"decimal";const r=this.engine.state.inputErrorNotice,o=n.querySelector(".sim-input-error");o.textContent=r?t1(r):"",o.hidden=!r}}function sg(i){const e=document.createElement("table");e.className="sim-grid";for(const t of i.value){const n=e.insertRow();for(const a of t){const s=n.insertCell();s.textContent=String(a),a===!0&&(s.className="sim-grid-true")}}return e}const x1=Array.from("ABCDEFGHIJKLMNOPQRSTUVWXYZ"),Gn=360/x1.length,RB="http://www.w3.org/2000/svg";function Je(i,e={},...t){const n=document.createElement(i);for(const[a,s]of Object.entries(e))n.setAttribute(a,s);return n.append(...t),n}function xt(i,e={},t){const n=document.createElementNS(RB,i);for(const[a,s]of Object.entries(e))n.setAttribute(a,String(s));return t!==void 0&&(n.textContent=t),n}function GB(i,e){const t=(e%26+26)%26;return Array.from(i).map(n=>{const a=n.charCodeAt(0);return a>=65&&a<=90?String.fromCharCode((a-65+t)%26+65):a>=97&&a<=122?String.fromCharCode((a-97+t)%26+97):n}).join("")}function ec(i,e){const t=xt("g",{class:e}),n=x1.map((a,s)=>{const r=xt("g",{transform:`rotate(${s*Gn})`});return r.append(xt("text",{x:0,y:-i,"text-anchor":"middle","dominant-baseline":"central"},a)),t.append(r),r});return{group:t,cells:n}}function HB(i,e){let t=i,n=!1,a=-t*Gn;const s=Je("section",{class:"learn-game learn-caesar"});s.append(Je("div",{class:"learn-game-head"},Je("strong",{},p("web_learn_caesar_title")))),s.append(Je("p",{class:"learn-game-status"},p("web_learn_caesar_hint")));const r=xt("svg",{viewBox:"-200 -200 400 400",class:"learn-caesar-disc",role:"img"});r.append(xt("circle",{r:196,class:"outer-disc"})),r.append(xt("path",{d:VB(196,92,Gn/2),class:"window"}));const o=ec(168,"outer-letters");r.append(o.group);for(let O=0;O${Me(p("simulation_variables_placeholder"))}
`;else{const r=document.createElement("table");for(const o of n){const l=r.insertRow();l.insertCell().textContent=o;const u=e.variables.get(o),m=l.insertCell();u.kind==="grid"?m.append(sg(u)):m.textContent=_e(u)}this.variables.replaceChildren(r)}e.outputLines.length===0&&e.files.size===0?this.output.innerHTML=`${Me(p("simulation_output_placeholder"))}
`:(this.output.replaceChildren(...e.outputLines.map(r=>{const o=document.createElement("div");return o.textContent=r,o}),...ag(e.files)),this.output.scrollTop=this.output.scrollHeight)}updateInput(){const e=this.engine.state.inputRequest,t=this.inputSection;if(t.parentElement.classList.toggle("active",!!e),!e){t.innerHTML=`${Me(p("simulation_input_placeholder"))}
`;return}let n=t.querySelector("form");if(!n){n=document.createElement("form"),n.innerHTML=``;const l=n.querySelector("input");n.addEventListener("submit",u=>{u.preventDefault(),this.submitInput(l)}),t.replaceChildren(n),requestAnimationFrame(()=>l.focus())}const a=this.engine.state.outputLines;n.querySelector(".sim-prompt").textContent=e.prompt||(a[a.length-1]??"");const s=n.querySelector("input");s.inputMode=e.valueType==="string"||e.valueType==="boolean"?"text":"decimal";const r=this.engine.state.inputErrorNotice,o=n.querySelector(".sim-input-error");o.textContent=r?t1(r):"",o.hidden=!r}}function sg(i){const e=document.createElement("table");e.className="sim-grid";for(const t of i.value){const n=e.insertRow();for(const a of t){const s=n.insertCell();s.textContent=String(a),a===!0&&(s.className="sim-grid-true")}}return e}const x1=Array.from("ABCDEFGHIJKLMNOPQRSTUVWXYZ"),Gn=360/x1.length,UM="http://www.w3.org/2000/svg";function Fe(i,e={},...t){const n=document.createElement(i);for(const[a,s]of Object.entries(e))n.setAttribute(a,s);return n.append(...t),n}function xt(i,e={},t){const n=document.createElementNS(UM,i);for(const[a,s]of Object.entries(e))n.setAttribute(a,String(s));return t!==void 0&&(n.textContent=t),n}function $M(i,e){const t=(e%26+26)%26;return Array.from(i).map(n=>{const a=n.charCodeAt(0);return a>=65&&a<=90?String.fromCharCode((a-65+t)%26+65):a>=97&&a<=122?String.fromCharCode((a-97+t)%26+97):n}).join("")}function em(i,e){const t=xt("g",{class:e}),n=x1.map((a,s)=>{const r=xt("g",{transform:`rotate(${s*Gn})`});return r.append(xt("text",{x:0,y:-i,"text-anchor":"middle","dominant-baseline":"central"},a)),t.append(r),r});return{group:t,cells:n}}function YM(i,e){let t=i,n=!1,a=-t*Gn;const s=Fe("section",{class:"learn-game learn-caesar"});s.append(Fe("div",{class:"learn-game-head"},Fe("strong",{},p("web_learn_caesar_title")))),s.append(Fe("p",{class:"learn-game-status"},p("web_learn_caesar_hint")));const r=xt("svg",{viewBox:"-200 -200 400 400",class:"learn-caesar-disc",role:"img"});r.append(xt("circle",{r:196,class:"outer-disc"})),r.append(xt("path",{d:XM(196,92,Gn/2),class:"window"}));const o=em(168,"outer-letters");r.append(o.group);for(let A=0;A${p("web_visubot_world_in_preview")}
${SM()}${TM()}`,this.stage=this.element.querySelector(".visubot-stage"),this.picker=this.element.querySelector(".visubot-worlds"),this.status=this.element.querySelector(".visubot-status"),this.liveStatus=this.element.querySelector(".visubot-live"),this.viewport=this.element.querySelector(".visubot-viewport"),this.stopListening=ge.listen(()=>this.updateLive()),this.setupControls(),this.check=this.element.querySelector(".visubot-check"),this.setupCheck(),this.updateLive(),this.updateStatus()}show(){this.loading??(this.loading=K(async()=>{const{Robot3D:e}=await import("./robot3d-DIKtuHQj.js");return{Robot3D:e}},[],import.meta.url).then(({Robot3D:e})=>{this.view=new e(this.stage),this.view.setWorld(this.world.setup),this.view.place(this.world.pose,this.world.trail),this.view.setLeds(this.world.leds)}).catch(()=>{this.stage.textContent=p("web_visubot_no_3d")}))}restoreViewport(){this.viewport.parentElement!==this.element&&this.liveStatus.after(this.viewport)}setWorlds(e){this.picker.replaceChildren(),this.picker.hidden=e.length<2,e.forEach((t,n)=>{const a=document.createElement("button");a.textContent=p("web_visubot_world_fmt",n+1),a.addEventListener("click",()=>this.useWorld(t,a)),this.picker.append(a)}),this.useWorld(e[0]??Ii,this.picker.firstElementChild)}useWorld(e,t){var n,a,s,r,o;for(const l of this.picker.children)l.classList.toggle("active",l===t);e!==this.world.setup&&(this.world=new ds(e),this.applied=0,this.sent=0,(n=this.view)==null||n.setWorld(e),(a=this.view)==null||a.place(this.world.pose,this.world.trail),(s=this.view)==null||s.setLed(void 0),(r=this.view)==null||r.setScreen(void 0),this.updateStatus(),(o=this.onWorldChange)==null||o.call(this))}reset(){var e,t,n;this.world.reset(),this.applied=0,this.sent=0,this.realSensors=void 0,(e=this.view)==null||e.place(this.world.pose,this.world.trail),(t=this.view)==null||t.setLed(void 0),(n=this.view)==null||n.setScreen(void 0),this.updateStatus()}prepare(e){e.robotSensors={...this.controls,...this.world.sensors()}}setupControls(){for(const e of this.element.querySelectorAll(".visubot-controls input[type=range]")){const t=e.parentElement.querySelector("output"),n=()=>{this.controls[e.name]=Number(e.value),t.textContent=e.value};e.addEventListener("input",n),n()}for(const e of this.element.querySelectorAll(".visubot-controls button[name]"))e.addEventListener("click",()=>{const t=e.name;this.controls[t]=!0,e.classList.add("pressed"),window.clearTimeout(this.pressTimers.get(t)),this.pressTimers.set(t,window.setTimeout(()=>{this.controls[t]=!1,e.classList.remove("pressed")},1e3))})}setupCheck(){for(const e of this.check.querySelectorAll("button[data-py]"))e.addEventListener("click",()=>{const{after:t,wait:n}=e.dataset;ge.run(e.dataset.py).then(()=>t?new Promise(a=>setTimeout(a,Number(n))).then(()=>ge.run(t)):void 0).catch(a=>this.liveFailed(a))});this.check.addEventListener("toggle",()=>void this.readCheck())}async readCheck(){if(!this.checking){this.checking=!0;try{for(;this.check.open&&ge.connected;){for(const e of this.check.querySelectorAll("[data-sensor]")){if(!this.check.open||!ge.connected)break;const t=e.dataset.sensor,n=await ge.ask(At[t].python).catch(()=>{});n!==void 0&&(e.textContent=typeof At[t].simulated=="boolean"?n===!0||typeof n=="number"&&n!==0?"✓":"–":String(typeof n=="number"?Math.round(n*10)/10:n))}await new Promise(e=>setTimeout(e,200))}}finally{this.checking=!1}}}get live(){return ge.connected}async prepareLive(e,t=[]){const n={};for(const a of new Set(["getDistance","getLine",...t])){const s=await ge.ask(At[a].python);typeof At[a].simulated=="boolean"?n[a]=s===!0||typeof s=="number"&&s!==0:typeof At[a].simulated=="string"?n[a]=typeof s=="string"?s:String(At[a].simulated):n[a]=typeof s=="number"?a==="getDistance"?Math.round(s):s:0}this.realSensors=n,e.robotSensors={...this.controls,...this.world.sensors(),...n}}async drive(e){for(;this.sent${p("web_visubot_world_in_preview")}
${CZ()}${OZ()}`,this.stage=this.element.querySelector(".visubot-stage"),this.picker=this.element.querySelector(".visubot-worlds"),this.status=this.element.querySelector(".visubot-status"),this.liveStatus=this.element.querySelector(".visubot-live"),this.viewport=this.element.querySelector(".visubot-viewport"),this.stopListening=ge.listen(()=>this.updateLive()),this.setupControls(),this.check=this.element.querySelector(".visubot-check"),this.setupCheck(),this.updateLive(),this.updateStatus()}show(){this.loading??(this.loading=K(async()=>{const{Robot3D:e}=await import("./robot3d-B1TGngW1.js");return{Robot3D:e}},[],import.meta.url).then(({Robot3D:e})=>{this.view=new e(this.stage),this.view.setWorld(this.world.setup),this.view.place(this.world.pose,this.world.trail),this.view.setLeds(this.world.leds)}).catch(()=>{this.stage.textContent=p("web_visubot_no_3d")}))}restoreViewport(){this.viewport.parentElement!==this.element&&this.liveStatus.after(this.viewport)}setWorlds(e){this.picker.replaceChildren(),this.picker.hidden=e.length<2,e.forEach((t,n)=>{const a=document.createElement("button");a.textContent=p("web_visubot_world_fmt",n+1),a.addEventListener("click",()=>this.useWorld(t,a)),this.picker.append(a)}),this.useWorld(e[0]??Ii,this.picker.firstElementChild)}useWorld(e,t){var n,a,s,r,o;for(const l of this.picker.children)l.classList.toggle("active",l===t);e!==this.world.setup&&(this.world=new ds(e),this.applied=0,this.sent=0,(n=this.view)==null||n.setWorld(e),(a=this.view)==null||a.place(this.world.pose,this.world.trail),(s=this.view)==null||s.setLed(void 0),(r=this.view)==null||r.setScreen(void 0),this.updateStatus(),(o=this.onWorldChange)==null||o.call(this))}reset(){var e,t,n;this.world.reset(),this.applied=0,this.sent=0,this.realSensors=void 0,(e=this.view)==null||e.place(this.world.pose,this.world.trail),(t=this.view)==null||t.setLed(void 0),(n=this.view)==null||n.setScreen(void 0),this.updateStatus()}prepare(e){e.robotSensors={...this.controls,...this.world.sensors()}}setupControls(){for(const e of this.element.querySelectorAll(".visubot-controls input[type=range]")){const t=e.parentElement.querySelector("output"),n=()=>{this.controls[e.name]=Number(e.value),t.textContent=e.value};e.addEventListener("input",n),n()}for(const e of this.element.querySelectorAll(".visubot-controls button[name]"))e.addEventListener("click",()=>{const t=e.name;this.controls[t]=!0,e.classList.add("pressed"),window.clearTimeout(this.pressTimers.get(t)),this.pressTimers.set(t,window.setTimeout(()=>{this.controls[t]=!1,e.classList.remove("pressed")},1e3))})}setupCheck(){for(const e of this.check.querySelectorAll("button[data-py]"))e.addEventListener("click",()=>{const{after:t,wait:n}=e.dataset;ge.run(e.dataset.py).then(()=>t?new Promise(a=>setTimeout(a,Number(n))).then(()=>ge.run(t)):void 0).catch(a=>this.liveFailed(a))});this.check.addEventListener("toggle",()=>void this.readCheck())}async readCheck(){if(!this.checking){this.checking=!0;try{for(;this.check.open&&ge.connected;){for(const e of this.check.querySelectorAll("[data-sensor]")){if(!this.check.open||!ge.connected)break;const t=e.dataset.sensor,n=await ge.ask(jt[t].python).catch(()=>{});n!==void 0&&(e.textContent=typeof jt[t].simulated=="boolean"?n===!0||typeof n=="number"&&n!==0?"✓":"–":String(typeof n=="number"?Math.round(n*10)/10:n))}await new Promise(e=>setTimeout(e,200))}}finally{this.checking=!1}}}get live(){return ge.connected}async prepareLive(e,t=[]){const n={};for(const a of new Set(["getDistance","getLine",...t])){const s=await ge.ask(jt[a].python);typeof jt[a].simulated=="boolean"?n[a]=s===!0||typeof s=="number"&&s!==0:typeof jt[a].simulated=="string"?n[a]=typeof s=="string"?s:String(jt[a].simulated):n[a]=typeof s=="number"?a==="getDistance"?Math.round(s):s:0}this.realSensors=n,e.robotSensors={...this.controls,...this.world.sensors(),...n}}async drive(e){for(;this.sent${p("web_visubot_controls_hint")}
${i("getBrightness","web_visubot_sensor_brightness",0,100,50)} ${i("getLoudness","web_visubot_sensor_loudness",0,100,0)} @@ -63939,23 +64251,23 @@ ${a}`));this.body.append(s),this.foldReference(s)}}foldReference(e){const t="vis ${e("isJoystickLeft","←","web_visubot_sensor_joy_left")}${e("isJoystickRight","→","web_visubot_sensor_joy_right")} ${e("isShaken",`〰 ${p("web_visubot_shake")}`,"web_visubot_sensor_shake")}${p("web_visubot_check_hint")}
${te(c)}
`:""}`,n=la()?[this.pending?t("reconnect",`${se.open} ${te(p("web_learn_start_continue_fmt",this.pending.name))}`,!0):"",t("pick",`${se.open} ${te(p("web_learn_start_open"))}`,!this.pending),t("create",`${se.newFolder} ${te(p("web_learn_start_create_fmt",e))}`,!1,p("web_learn_start_create_hint"))]:[t("browser",te(p("web_files_browser")),!0,p("web_files_browser_hint"))],a=document.createElement("div");a.className="confirm",a.innerHTML=`${te(m)}
`:""}`,n=la()?[this.pending?t("reconnect",`${se.open} ${te(p("web_learn_start_continue_fmt",this.pending.name))}`,!0):"",t("pick",`${se.open} ${te(p("web_learn_start_open"))}`,!this.pending),t("create",`${se.newFolder} ${te(p("web_learn_start_create_fmt",e))}`,!1,p("web_learn_start_create_hint"))]:[t("browser",te(p("web_files_browser")),!0,p("web_files_browser_hint"))],a=document.createElement("div");a.className="confirm",a.innerHTML=`${te(p("web_visubot_world_title"))}
${te(p("web_learn_start_title"))}
@@ -63971,11 +64283,11 @@ ${a}`));this.body.append(s),this.foldReference(s)}}foldReference(e){const t="vis ${n.join("")}${te(p("web_learn_start_without_hint"))}
-${te(o.message)}
`)}if(e!==this.rendering)return;const s=t.kind==="folder"?`📁 ${te(t.root.name)}`:te(p("web_files_in_browser")),r=p("web_files_save_hint_fmt",_u());this.body.innerHTML=`${s}
@@ -63985,30 +64297,30 @@ ${a}`));this.body.append(s),this.foldReference(s)}}foldReference(e){const t="vis `:la()?`${te(p("web_files_connect_hint"))}
`:`${te(p("web_files_browser_hint"))}
- `}async onTreeClick(e){var r;const t=e.target,n=(r=t.closest("[data-start]"))==null?void 0:r.dataset.start;if(n==="pick")return this.connectFolder();if(n==="reconnect")return this.reconnect();if(n==="browser")return this.useBrowser();const a=t.closest(".files-row");if(!a||!this.workspace)return;const s=a.dataset.path;if(t.closest(".files-delete"))return this.remove(a);if(a.dataset.kind==="dir")return this.expanded.has(s)?this.expanded.delete(s):this.expanded.add(s),this.rememberExpanded(),this.render();if(a.dataset.kind==="program")return this.openProgram(s)}async locate(e){const t=e.split("/");let n=this.workspace.root;for(const a of t.slice(0,-1))n=await n.dir(a);return{dir:n,name:t.at(-1)}}async openProgram(e){try{const{dir:t,name:n}=await this.locate(e),a=n.replace(/\.(visustruct|java)$/i,""),s=await t.has(`${a}.visustruct`)?await t.read(`${a}.visustruct`):void 0,r=await t.has(`${a}.java`)?await t.read(`${a}.java`):void 0;if(s===void 0&&r===void 0)return;const o={dir:t,base:a,path:e.replace(/\.(visustruct|java)$/i,"")};this.host.open(s??"",o,r)}catch(t){this.host.message(t.message)}}async remove(e){const t=e.dataset.path,n=e.dataset.kind==="program",a=n?t.replace(/\.(visustruct|java)$/i,""):t;if(await pc({title:p("web_files_delete_confirm_fmt",a),ok:p("web_files_delete"),danger:!0})!==void 0){try{const{dir:s,name:r}=await this.locate(t);if(n){const o=r.replace(/\.(visustruct|java)$/i,"");for(const l of[".visustruct",".java"])await s.has(o+l)&&await s.remove(o+l)}else await s.remove(r)}catch(s){this.host.message(s.message)}await this.render()}}async newFolder(){if(!this.workspace)return;const e=Rb(await pc({title:p("web_files_folder_prompt"),input:"",ok:p("web_files_create")})??"");if(e){try{await this.workspace.root.dir(e,!0)}catch(t){this.host.message(t.message)}await this.render()}}async save(e,t,n,a){const s=this.workspace;if(!s)return;let r=a;if(!r){const o=_u(),l=await s.root.dir(o,!0),u=Jb(Fb(e,p("web_files_default_name")),(await l.list()).map(c=>c.name));r={dir:l,base:u,path:`${o}/${u}`},this.expanded.add(o),this.rememberExpanded()}return await r.dir.write(`${r.base}.visustruct`,t),n!==void 0&&await r.dir.write(`${r.base}.java`,n),await this.render(),r}}const yg=["boolean","int","double","String","char","long","float","short","byte"],ZM=new Set([...yg,"Boolean","Integer","Double","Character","Long","Float","Short","Byte","var","void"]);function LM(i){if(ZM.has(i))return;const e=i.toLowerCase();for(const t of yg)if(EM(e,t.toLowerCase())<=(t.length>=6?2:1))return t}function EM(i,e){const t=Array.from({length:i.length+1},(n,a)=>Array.from({length:e.length+1},(s,r)=>a===0?r:r===0?a:0));for(let n=1;n<=i.length;n++)for(let a=1;a<=e.length;a++){const s=i[n-1]===e[a-1]?0:1;t[n][a]=Math.min(t[n-1][a]+1,t[n][a-1]+1,t[n-1][a-1]+s),n>1&&a>1&&i[n-1]===e[a-2]&&i[n-2]===e[a-1]&&(t[n][a]=Math.min(t[n][a],t[n-2][a-2]+1))}return t[i.length][e.length]}const WM=[">>>=","<<=",">>=",">>>","->","::","++","--","==","!=","<=",">=","&&","||","+=","-=","*=","/=","%=","&=","|=","^=","<<"];function NM(i,e){const t=[];let n=0,a=0;const s=(r,o,l,u)=>t.push({kind:r,text:i.slice(o,l),start:o,end:l,line:u});for(;n