iobroker.javascript 10.1.4 → 10.2.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (131) hide show
  1. package/README.md +21 -48
  2. package/admin/assets/AiChatPanel-CsDFom-L.js +27 -0
  3. package/admin/assets/AiChatService-k72w0sOt.js +216 -0
  4. package/admin/assets/AiDiffView-DAleMXcP.js +1 -0
  5. package/admin/assets/AiInlineProvider-C5EJApDe.js +5 -0
  6. package/admin/assets/Debugger-B6_1wqlh.js +15 -0
  7. package/admin/assets/Error-DBiAAbCC.js +1 -0
  8. package/admin/assets/Import-Dm-2zYlI.js +1 -0
  9. package/admin/assets/RulesEditor-BML5AwgM.js +1 -0
  10. package/admin/assets/RulesEditor-CybrKL-9.css +1 -0
  11. package/admin/assets/ScriptEditor-BxwJbR3_.js +2 -0
  12. package/admin/assets/ScriptEditorVanillaMonaco-C3AgkXsv.js +3 -0
  13. package/admin/assets/_virtual_mf-localSharedImportMap___mfe_internal__iobroker_javascript__mf_owner__1-CQpJXcpz.js +1 -0
  14. package/admin/assets/_virtual_mf___mfe_internal__iobroker_javascript__mf_owner__113183188387379__loadShare___mf_0_iobroker_mf_1_gui_mf_2_components__loadShare__.js-Drq9CkPs.js +1217 -0
  15. package/admin/assets/_virtual_mf___mfe_internal__iobroker_javascript__mf_owner__113183188387379__loadShare__react_mf_2_dom_mf_1_client__loadShare__.js-B8K8J9cp.js +9 -0
  16. package/admin/assets/aiPromptBuilder-CuCGSQIi.js +1 -0
  17. package/admin/assets/{blockly-DBw-ytY1.js → blockly-Fp-1_Ye3.js} +1 -1
  18. package/admin/assets/{blocks_action-Dflw8PyN.js → blocks_action-CPgrbjAf.js} +1 -1
  19. package/admin/assets/{blocks_convert-XTqMxB04.js → blocks_convert-2eEzarQy.js} +1 -1
  20. package/admin/assets/{blocks_logic-JaZOQj6_.js → blocks_logic-DMEjFKWc.js} +1 -1
  21. package/admin/assets/{blocks_number-TU4dV-Ia.js → blocks_number-Bsx0zQT_.js} +1 -1
  22. package/admin/assets/{blocks_object-V6ojF22C.js → blocks_object-Q1nKLN6t.js} +1 -1
  23. package/admin/assets/{blocks_procedures-Cu8VeJhw.js → blocks_procedures-CHMjZQbf.js} +1 -1
  24. package/admin/assets/{blocks_sendto-BnDWzP0n.js → blocks_sendto-DsDq_Gu7.js} +1 -1
  25. package/admin/assets/{blocks_switch-DKUc060E.js → blocks_switch-Yog8S2MC.js} +1 -1
  26. package/admin/assets/{blocks_system-BW_UpMW-.js → blocks_system-2D8iX32Y.js} +1 -1
  27. package/admin/assets/{blocks_text-BIU2kf_V.js → blocks_text-C5-csrVL.js} +1 -1
  28. package/admin/assets/{blocks_time-2vgvS4_j.js → blocks_time-LB5i9yMW.js} +1 -1
  29. package/admin/assets/{blocks_timeout-BPzmWif8.js → blocks_timeout-CHGW670q.js} +1 -1
  30. package/admin/assets/{blocks_trigger-BSFZEWEO.js → blocks_trigger-D-2z_OfF.js} +1 -1
  31. package/admin/assets/cronHoverProvider-DYMf8M44.js +2 -0
  32. package/admin/assets/{dist-BF-PlO2i.js → dist-D4uJqRBO.js} +1 -1
  33. package/admin/assets/field_cron-B-SF-uZM.js +1 -0
  34. package/admin/assets/field_oid-fYE12Bhj.js +1 -0
  35. package/admin/assets/field_script-aZs3j-vG.js +1 -0
  36. package/admin/assets/{helpers-BFQD9R82.js → helpers-CalO_DDQ.js} +1 -1
  37. package/admin/assets/{hostInit-B_aW3Wuw.js → hostInit-CzvCZFy5.js} +1 -1
  38. package/admin/assets/index-CqFiN-25.js +871 -0
  39. package/admin/assets/inlineChatWidget-n7ufGLov.js +2 -0
  40. package/admin/assets/{inlineDiffController-DGl5rDYU.js → inlineDiffController-5u3tIcIH.js} +1 -1
  41. package/admin/assets/{mf-entry-bootstrap-0-ec2e487a.js → mf-entry-bootstrap-0-db6d825d.js} +14 -2
  42. package/admin/assets/pendingShares-C6DqQuMX.js +1 -0
  43. package/admin/assets/stateHoverProvider-C0OUV2Nh.js +9 -0
  44. package/admin/assets/virtual_mf-REMOTE_ENTRY_ID___mfe_internal__iobroker_javascript__remoteEntry_js-BvxK85AS.js +1 -0
  45. package/admin/assets/{vite-preload-helper-B7qeedMF.js → vite-preload-helper-CaC3yEL3.js} +1 -1
  46. package/admin/custom/assets/Components-qR8oYG5T.js +1 -0
  47. package/admin/custom/assets/_virtual_mf-localSharedImportMap___mfe_internal__ConfigCustomJavascriptSet__mf_owner__1-CB5V_0nT.js +1 -0
  48. package/admin/custom/assets/_virtual_mf___mfe_internal__ConfigCustomJavascriptSet__mf_owner__32150414352696__loadShare___mf_0_emotion_mf_1_react__loadShare__.js-Cc7MmJgr.js +1 -0
  49. package/admin/custom/assets/_virtual_mf___mfe_internal__ConfigCustomJavascriptSet__mf_owner__32150414352696__loadShare___mf_0_emotion_mf_1_styled__loadShare__.js-CFSZkPFK.js +1 -0
  50. package/admin/custom/assets/_virtual_mf___mfe_internal__ConfigCustomJavascriptSet__mf_owner__32150414352696__loadShare___mf_0_iobroker_mf_1_gui_mf_2_components__loadShare__.js-o8Mkax3s.js +1217 -0
  51. package/admin/custom/assets/_virtual_mf___mfe_internal__ConfigCustomJavascriptSet__mf_owner__32150414352696__loadShare___mf_0_iobroker_mf_1_json_mf_2_config__loadShare__.js-DLa2mE8b.js +1 -0
  52. package/admin/custom/assets/_virtual_mf___mfe_internal__ConfigCustomJavascriptSet__mf_owner__32150414352696__loadShare___mf_0_mui_mf_1_x_mf_2_date_mf_2_pickers__loadShare__.js-CZc6K9E9.js +1 -0
  53. package/admin/custom/assets/_virtual_mf___mfe_internal__ConfigCustomJavascriptSet__mf_owner__32150414352696__loadShare__date_mf_2_fns__loadShare__.js-Bx5h7ISf.js +1 -0
  54. package/admin/custom/assets/_virtual_mf___mfe_internal__ConfigCustomJavascriptSet__mf_owner__32150414352696__loadShare__leaflet__loadShare__.js-im3edKNs.js +1 -0
  55. package/admin/custom/assets/_virtual_mf___mfe_internal__ConfigCustomJavascriptSet__mf_owner__32150414352696__loadShare__react_mf_2_dom_mf_1_client__loadShare__.js-Ca3AhTHn.js +1 -0
  56. package/admin/custom/assets/_virtual_mf___mfe_internal__ConfigCustomJavascriptSet__mf_owner__32150414352696__prebuild___mf_0_iobroker_mf_1_json_mf_2_config__prebuild__-bDecxMAs.js +124 -0
  57. package/admin/custom/assets/_virtual_mf___mfe_internal__ConfigCustomJavascriptSet__mf_owner__32150414352696__prebuild__leaflet__prebuild__-CAKlcuIS.js +1 -0
  58. package/admin/custom/assets/_virtual_mf___mfe_internal__ConfigCustomJavascriptSet__mf_owner__32150414352696__prebuild__react_mf_1_jsx_mf_2_runtime__prebuild__-Byvr2uOb.js +1 -0
  59. package/admin/custom/assets/_virtual_mf___mfe_internal__ConfigCustomJavascriptSet__mf_owner__32150414352696__prebuild__react_mf_2_dom_mf_1_client__prebuild__-Thbi9Vo9.js +9 -0
  60. package/admin/custom/assets/dist-D4uJqRBO.js +4 -0
  61. package/admin/custom/assets/{hostInit-CkdLQZaZ.js → hostInit-B0Qa8jfJ.js} +1 -1
  62. package/admin/custom/assets/index-DADYLUN0.js +1 -0
  63. package/admin/custom/assets/{lib-D9tipKpE.js → lib-BDVPOOMD.js} +2 -2
  64. package/admin/custom/assets/{mf-entry-bootstrap-0-ff278fef.js → mf-entry-bootstrap-0-b41e47ad.js} +14 -2
  65. package/admin/custom/assets/pendingShares-Gn0OX49v.js +1 -0
  66. package/admin/custom/assets/virtualExposes-DjwWqUOb.js +1 -0
  67. package/admin/custom/assets/virtual_mf-REMOTE_ENTRY_ID___mfe_internal__ConfigCustomJavascriptSet__customComponents_js-CHOLf9xJ.js +1 -0
  68. package/admin/custom/assets/{virtual_mf-exposes___mfe_internal__ConfigCustomJavascriptSet__customComponents_js-C1DpedFv.js → virtual_mf-exposes___mfe_internal__ConfigCustomJavascriptSet__customComponents_js-C0XlV8T_.js} +2 -2
  69. package/admin/custom/assets/{vite-preload-helper-B7qeedMF.js → vite-preload-helper-CaC3yEL3.js} +1 -1
  70. package/admin/custom/customComponents.js +2 -2
  71. package/admin/i18n/de.json +8 -2
  72. package/admin/i18n/en.json +8 -2
  73. package/admin/i18n/es.json +8 -2
  74. package/admin/i18n/fr.json +8 -2
  75. package/admin/i18n/it.json +8 -2
  76. package/admin/i18n/nl.json +8 -2
  77. package/admin/i18n/pl.json +8 -2
  78. package/admin/i18n/pt.json +8 -2
  79. package/admin/i18n/ru.json +8 -2
  80. package/admin/i18n/uk.json +8 -2
  81. package/admin/i18n/zh-cn.json +8 -2
  82. package/admin/jsonConfig.json +53 -0
  83. package/admin/mf-manifest.json +1 -1
  84. package/admin/mf-stats.json +1 -1
  85. package/admin/remoteEntry.js +2 -2
  86. package/admin/tab.html +5 -5
  87. package/build/lib/aiProviderResolver.js +22 -1
  88. package/build/lib/aiProviderResolver.js.map +1 -1
  89. package/build/lib/lazyTsServer.js +177 -0
  90. package/build/lib/lazyTsServer.js.map +1 -0
  91. package/build/main.js +176 -24
  92. package/build/main.js.map +1 -1
  93. package/build/types.d.ts +13 -0
  94. package/io-package.json +31 -28
  95. package/package.json +7 -8
  96. package/admin/assets/AiChatPanel-D93BBufl.js +0 -242
  97. package/admin/assets/AiDiffView-D5QZDwuC.js +0 -1
  98. package/admin/assets/AiInlineProvider-CRU2J938.js +0 -5
  99. package/admin/assets/Debugger-BLzsRkue.js +0 -15
  100. package/admin/assets/Error-BWXtkB6H.js +0 -1
  101. package/admin/assets/Import-D_RBSmNU.js +0 -1
  102. package/admin/assets/RulesEditor-DpKr8byp.js +0 -1
  103. package/admin/assets/RulesEditor-QNWIRnqB.css +0 -1
  104. package/admin/assets/ScriptEditor-DK6nNmcp.js +0 -2
  105. package/admin/assets/ScriptEditorVanillaMonaco-BVIwadsl.js +0 -3
  106. package/admin/assets/_virtual_mf-localSharedImportMap___mfe_internal__iobroker_javascript__mf_owner__1-v3-PYsgp.js +0 -1
  107. package/admin/assets/_virtual_mf___mfe_internal__iobroker_javascript__mf_owner__1__loadShare___mf_0_iobroker_mf_1_gui_mf_2_components__loadShare__.js-GB0oxSwG.js +0 -1217
  108. package/admin/assets/_virtual_mf___mfe_internal__iobroker_javascript__mf_owner__1__loadShare__react_mf_2_dom_mf_1_client__loadShare__.js-SF46owzN.js +0 -9
  109. package/admin/assets/aiPromptBuilder-CtijdvYL.js +0 -1
  110. package/admin/assets/cronHoverProvider-BMVsvVuG.js +0 -2
  111. package/admin/assets/field_cron-Br4hxeLb.js +0 -1
  112. package/admin/assets/field_oid-ojNnLVGL.js +0 -1
  113. package/admin/assets/field_script-Bs925umq.js +0 -1
  114. package/admin/assets/index-BnLv569U.js +0 -871
  115. package/admin/assets/inlineChatWidget-BcLIwfEH.js +0 -2
  116. package/admin/assets/stateHoverProvider-XKm8a_93.js +0 -9
  117. package/admin/assets/virtual_mf-REMOTE_ENTRY_ID___mfe_internal__iobroker_javascript__remoteEntry_js-IRf47UYM.js +0 -1
  118. package/admin/custom/assets/Components-BpxzAzc7.js +0 -1
  119. package/admin/custom/assets/_virtual_mf-localSharedImportMap___mfe_internal__ConfigCustomJavascriptSet__mf_owner__1-wwYTJNxa.js +0 -1
  120. package/admin/custom/assets/_virtual_mf___mfe_internal__ConfigCustomJavascriptSet__mf_owner__1__loadShare___mf_0_emotion_mf_1_react__loadShare__.js-DzaRKfE_.js +0 -1
  121. package/admin/custom/assets/_virtual_mf___mfe_internal__ConfigCustomJavascriptSet__mf_owner__1__loadShare___mf_0_emotion_mf_1_styled__loadShare__.js-B9fjpXOq.js +0 -1
  122. package/admin/custom/assets/_virtual_mf___mfe_internal__ConfigCustomJavascriptSet__mf_owner__1__loadShare___mf_0_iobroker_mf_1_gui_mf_2_components__loadShare__.js-QxUxIFgP.js +0 -1217
  123. package/admin/custom/assets/_virtual_mf___mfe_internal__ConfigCustomJavascriptSet__mf_owner__1__loadShare___mf_0_iobroker_mf_1_json_mf_2_config__loadShare__.js-BUk3WHjQ.js +0 -1494
  124. package/admin/custom/assets/_virtual_mf___mfe_internal__ConfigCustomJavascriptSet__mf_owner__1__loadShare__leaflet__loadShare__.js-n2zIPi0L.js +0 -1
  125. package/admin/custom/assets/_virtual_mf___mfe_internal__ConfigCustomJavascriptSet__mf_owner__1__loadShare__react_mf_2_dom_mf_1_client__loadShare__.js-DqjU6PXX.js +0 -9
  126. package/admin/custom/assets/_virtual_mf___mfe_internal__ConfigCustomJavascriptSet__mf_owner__1__prebuild__date_mf_2_fns__prebuild__-CXAEcWml.js +0 -1
  127. package/admin/custom/assets/_virtual_mf___mfe_internal__ConfigCustomJavascriptSet__mf_owner__1__prebuild__leaflet__prebuild__-BeF0jEWM.js +0 -1
  128. package/admin/custom/assets/index-D2qJNee0.js +0 -1
  129. package/admin/custom/assets/setYear-DXk_Jooa.js +0 -1
  130. package/admin/custom/assets/virtualExposes-vH26J8jF.js +0 -1
  131. package/admin/custom/assets/virtual_mf-REMOTE_ENTRY_ID___mfe_internal__ConfigCustomJavascriptSet__customComponents_js-qdaLIbFV.js +0 -1
@@ -3,7 +3,7 @@ import{o as e,r as t,t as n}from"./rolldown-runtime-C0FnF6B9.js";var r=n(((e,t)=
3
3
  `)+(ds?`\xA0`:``),ds=!ds,n.appendChild(e),rs.length=0,ns=es.OFF},10)},h=function(e,t,n){var r=document.createElementNS(`http://www.w3.org/2000/svg`,`${e}`);e!==A.SVG.toString()&&e!==A.G.toString()&&r.tagName!==A.SVG.toString()&&r.tagName!==A.G.toString()||p(r,O.NONE);for(let e in t)r.setAttribute(e,`${t[e]}`);return n&&n.appendChild(r),r},g=function(e,t){return t=t.split(` `),!t.every(t=>e.classList.contains(t))&&(e.classList.add(...t),!0)},ce=function(e,t){e.classList.remove(...t.split(` `))},_=function(e,t){return t=t.split(` `),!t.every(t=>!e.classList.contains(t))&&(e.classList.remove(...t),!0)},le=function(e,t){return e.classList.contains(t)},v=function(e){return e&&e.parentNode?e.parentNode.removeChild(e):null},ue=function(e,t){var n=t.nextSibling;if(t=t.parentNode,!t)throw Error(`Reference node has no parent.`);n?t.insertBefore(e,n):t.appendChild(e)},de=function(e,t){e.style.transform=t,e.style[`-webkit-transform`]=t},fe=function(){gs++,hs||=Object.create(null)},pe=function(){gs--,gs||(hs=null)},me=function(e){var t=e.textContent+`
4
4
  `+e.className.baseVal,n;return hs&&(n=hs[t])?n:(n=window.getComputedStyle(e),n=he(e,n.fontSize,n.fontWeight,n.fontFamily),hs&&(hs[t]=n),n)},he=function(e,t,n,r){var i=e.textContent;e=i+`
5
5
  `+e.className.baseVal;var a;return hs&&(a=hs[e])?a:(_s||=(a=document.createElement(`canvas`),a.className=`blocklyComputeCanvas`,document.body.appendChild(a),a.getContext(`2d`)),i&&_s?(_s.font=n+` `+t+` `+r,a=_s.measureText(i).width):a=0,hs&&(hs[e]=a),a)},ge=function(e,t,n,r){var i=document.createElement(`span`);i.style.font=n+` `+t+` `+r,i.textContent=e,e=document.createElement(`div`),e.style.width=`1px`,e.style.height=`0`,t=document.createElement(`div`),t.style.display=`flex`,t.style.position=`fixed`,t.style.top=`0`,t.style.left=`0`,t.appendChild(i),t.appendChild(e),document.body.appendChild(t),n={height:0,baseline:0};try{t.style.alignItems=`baseline`,n.baseline=e.offsetTop-i.offsetTop,t.style.alignItems=`flex-end`,n.height=e.offsetTop-i.offsetTop}finally{document.body.removeChild(t)}return n},_e,ve,ye,be,xe,Se,Ce,we,Te,Ee,De,Oe,ke,Ae,je,Me,Ne,Pe,Fe,y,Ie,Le,Re,ze,Be,Ve,He,Ue,b,We,Ge,Ke,qe,Je,Ye,x,Xe,Ze,Qe,$e,et,tt,nt,rt,it,at,ot,st,ct,lt,ut,dt,ft,pt,mt,ht,gt,_t,vt,yt,bt,xt,St,Ct,wt,Tt,Et,Dt,Ot,kt,At,jt,Mt,Nt,Pt,Ft,It,Lt,Rt,zt,Bt,Vt,Ht,Ut,Wt,Gt,Kt,qt,Jt,Yt,Xt,Zt,Qt,$t,en,tn,nn,rn,an,on,sn,cn,ln,un,dn,fn,pn,mn,hn,gn,_n,vn,yn,bn,xn,Sn,Cn,wn,Tn,En,Dn,On,kn,An,jn,Mn,Nn,Pn,Fn,In,Ln,Rn,zn,Bn,Vn,Hn,Un,Wn,Gn,Kn,qn,Jn,Yn,Xn,Zn,Qn,$n,er,tr,nr,rr,ir,ar,or,sr,cr,lr,ur,dr,fr,pr,mr,hr,gr,_r,vr,yr,br,xr,Sr,Cr,wr,Tr,Er,Dr,Or,kr,Ar,jr,Mr,Nr,Pr,Fr,Ir,Lr,Rr,zr,Br,Vr,Hr,Ur,Wr,Gr,Kr,qr,Jr,Yr,Xr,Zr,Qr,$r,ei,ti,ni,ri,ii,ai,oi,si,ci,li,ui,di,fi,pi,mi,hi,S,gi,_i,vi,yi,bi,C,xi,Si,Ci,wi,Ti,Ei,Di,Oi,ki,Ai,ji,Mi,Ni,Pi,Fi,Ii,Li,Ri,zi,Bi,Vi,Hi,Ui,Wi,Gi,Ki,qi,Ji,Yi,Xi,Zi,Qi,$i,ea,ta,na,ra,ia,aa,oa,sa,ca,la,ua,da,fa,pa,ma,ha,ga,_a,va,ya,ba,xa,Sa,Ca,wa,Ta,Ea,Da,Oa,ka,Aa,ja,Ma,Na,Pa,Fa,Ia,La,Ra,za,Ba,Va,Ha,Ua,Wa,Ga,Ka,qa,Ja,Ya,Xa,Za,Qa,$a,eo,to,no,ro,io,ao,oo,so,co,lo,uo,fo,po,mo,ho,go,_o,w;e.t=function(){return xs.getFocusManager()},_e=function(e){return e&&typeof e.getFocusableElement==`function`&&typeof e.getFocusableTree==`function`&&typeof e.onNodeFocus==`function`&&typeof e.onNodeBlur==`function`&&typeof e.canBeFocused==`function`},ve=function(e){return _e(e)&&typeof e.id==`string`&&typeof e.workspace==`object`&&typeof e.select==`function`&&typeof e.unselect==`function`},ye=function(e,t){for(let n in t)e[n]=t[n]!==null&&Array.isArray(t[n])?ye(e[n]||[],t[n]):t[n]!==null&&typeof t[n]==`object`?ye(e[n]||Object.create(null),t[n]):t[n];return e},be=function(e,t,n,r){e=e+` was deprecated in `+t+` and will be deleted in `+n+`.`,r&&(e+=`
6
- Use `+r+` instead.`),Ts.has(e)||(Ts.add(e),console.warn(e))},xe=function(e){return Ds[e]||null},Se=function(){var e=[];for(let t in Ds)e.push(Ds[t]);return e},Ce=function(e){Ds[e.id]=e},we=function(e){delete Ds[e.id]},Te=function(){return Os},Ee=function(t){Os=t,t.rendered&&e.t().setPopoverFocusRoot(t.getInjectionDiv())},De=function(){var t=e.t().getFocusedNode();return t&&ve(t)?t:null},Oe=function(e){var t=De(),n=new(x(E.SELECTED))((t==null?void 0:t.id)??null,(e==null?void 0:e.id)??null,(e==null?void 0:e.workspace.id)??(t==null?void 0:t.workspace.id)??``);b(n)},ke=function(e=Os){return ks||(e&&e.rendered?e.getInjectionDiv():null)},Ae=function(e){ks=e},je=function(e){for(;e.options.parentWorkspace;)e=e.options.parentWorkspace;var t=e.getParentSvg(),n=e.getCachedParentSvgSize(),r=t.parentElement;if(r instanceof HTMLElement){var i=r.offsetWidth;r=r.offsetHeight,n.width!==i&&(t.setAttribute(`width`,i+`px`),e.setCachedParentSvgSize(i,null)),n.height!==r&&(t.setAttribute(`height`,r+`px`),e.setCachedParentSvgSize(null,r)),e.resize()}},Me=function(e,t){var n=Object.create(null),r=e.getDescendants(!0);t&&(e=e.getNextBlock())&&(e=r.indexOf(e),r.splice(e,r.length-e));for(let e=0,t;t=r[e];e++)n[t.type]?n[t.type]++:n[t.type]=1;return n},Ne=function(e){return function(){this.jsonInit(e)}},Pe=function(e){js.defineBlocksWithJsonArrayInternal(e)},e.yb=function(e){var t={};for(let n=0;n<e.length;n++){let r=e[n];if(!r){console.warn(`Block definition #${n} in JSON array is ${r}. Skipping`);continue}let i=r.type;i?t[i]={init:Ne(r)}:console.warn(`Block definition #${n} in JSON array is missing a type attribute. Skipping.`)}return t},e.Ab=function(e){for(let t of Object.keys(e)){let n=e[t];t in $o&&console.warn(`Block definition "${t}" overwrites previous definition.`),$o[t]=n}},Fe=function(t){var n=Os,r=e.t().getFocusedTree();for(let e of Se())if(r===e){n=e;break}!l(t)&&n&&(!n.rendered||n.isFlyout||n.isVisible())&&j.registry.onKeyDown(n,t)},y=function(e,t,n,r){if(!(e instanceof M)&&typeof e!=`string`||`${e}`.trim()===``)throw Error(`Invalid type "`+e+`". The type must be a non-empty string or a Blockly.registry.Type.`);if(e=`${e}`.toLowerCase(),typeof t!=`string`||t.trim()===``)throw Error(`Invalid name "`+t+`". The name must be a non-empty string.`);var i=t.toLowerCase();if(!n)throw Error(`Can not register a null value`);var a=Ns[e],o=Fs[e];switch(a||(a=Ns[e]=Object.create(null),o=Fs[e]=Object.create(null)),e){case String(M.FIELD):if(typeof n.fromJson!=`function`)throw Error(`Type "`+e+`" must have a fromJson function`)}if(!r&&a[i]&&a[i]!==n)throw Error(`Name "`+i+`" with type "`+e+`" already registered.`);a[i]=n,o[i]=t},Ie=function(e,t){e=`${e}`.toLowerCase(),t=t.toLowerCase();var n=Ns[e];n&&n[t]?(delete Ns[e][t],delete Fs[e][t]):console.warn(`Unable to unregister [`+t+`][`+e+`] from the registry.`)},Le=function(e,t,n){e=`${e}`.toLowerCase(),t=t.toLowerCase();var r=Ns[e];if(!r||!r[t]){if(t=`Unable to find [`+t+`][`+e+`] in the registry.`,n)throw Error(t+` You must require or register a `+e+` plugin.`);return console.warn(t),null}return r[t]},Re=function(e,t){return e=`${e}`.toLowerCase(),t=t.toLowerCase(),(e=Ns[e])?!!e[t]:!1},ze=function(e,t,n){return Le(e,t,n)},Be=function(e,t,n){e=`${e}`.toLowerCase();var r=Ns[e];if(!r){if(r=`Unable to find [${e}] in the registry.`,n)throw Error(`${r} You must require or register a ${e} plugin.`);return console.warn(r),null}if(!t)return r;e=Fs[e],n=Object.create(null);for(let t of Object.keys(r))n[e[t]]=r[t];return n},Ve=function(e,t,n){return t=t.plugins[String(e)]||`default`,typeof t==`function`?t:Le(e,t,n)},He=function(){return`blockly-`+(Rs++).toString(36)},Ue=function(){return Ls.genUid()},b=function(e){Vs.fireInternal(e)},We=function(){var e=Ke(Bs);Bs.length=0;for(let t of e){if(!t.workspaceId)continue;let e;(e=xe(t.workspaceId))==null||e.fireChangeListener(t)}},Ge=function(e){if(e.type===E.BLOCK_CHANGE&&e.element===`mutation`){let t;for(t=Bs.length;t>0;t--){let n=Bs[t-1];if(n.group!==e.group||n.workspaceId!==e.workspaceId||n.type!==E.BLOCK_MOVE||n.newParentId!==e.blockId)break}Bs.splice(t,0,e)}else Bs.push(e)},Ke=function(e){var t=[];for(let n of e)e=t[t.length-1],!n.isNull()&&(!e||e.workspaceId!==n.workspaceId||e.group!==n.group?t.push(n):n.type===E.BLOCK_MOVE&&e.type===E.BLOCK_MOVE&&n.blockId===e.blockId?(e.newParentId=n.newParentId,e.newInputName=n.newInputName,e.newCoordinate=n.newCoordinate,(e.reason||n.reason)&&(e.reason=Array.from(new Set((e.reason??[]).concat(n.reason??[]))))):n.type===E.BLOCK_CHANGE&&e.type===E.BLOCK_CHANGE&&n.blockId===e.blockId&&n.element===e.element&&n.name===e.name?e.newValue=n.newValue:n.type===E.VIEWPORT_CHANGE&&e.type===E.VIEWPORT_CHANGE?(e.viewTop=n.viewTop,e.viewLeft=n.viewLeft,e.scale=n.scale,e.oldScale=n.oldScale):(n.type!==E.CLICK||e.type!==E.BUBBLE_OPEN)&&(n.type===E.SELECTED&&e.type===E.SELECTED&&e.newElementId===void 0?(e.newElementId=n.newElementId,e.oldElementId===e.newElementId&&t.pop()):t.push(n)));return e=t.filter(e=>!e.isNull())},qe=function(){for(let e=0,t;t=Bs[e];e++)t.recordUndo=!1},Je=function(){return e.Ub===0},e.B=function(e){Vs.setGroupInternal(e)},Ye=function(e){var t=[];e=e.getDescendants(!1);for(let n=0,r;r=e[n];n++)t[n]=r.id;return t},x=function(e){var t=Le(M.EVENT,e,void 0);if(!t)throw Error(`Event type ${e} not found in registry.`);return t},Xe=function(t){Object.keys(t).forEach(function(n){e.C[n]=t[n]})},Ze=function(e){return Us.getSizeInternal(e)},Qe=function(e,t){return e=window.getComputedStyle(e),e[t]||e.getPropertyValue(t)},$e=function(e){var t=new N(0,0);e=e.getBoundingClientRect();var n=document.documentElement;return n=new N(window.pageXOffset||n.scrollLeft,window.pageYOffset||n.scrollTop),t.x=e.left+n.x,t.y=e.top+n.y,t},et=function(){var e=document.body,t=document.documentElement;return new N(e.scrollLeft||t.scrollLeft,e.scrollTop||t.scrollTop)},tt=function(e){var t=parseFloat(Qe(e,`borderLeftWidth`)),n=parseFloat(Qe(e,`borderRightWidth`)),r=parseFloat(Qe(e,`borderTopWidth`));return e=parseFloat(Qe(e,`borderBottomWidth`)),new P(r,e,t,n)},nt=function(e,t,n){e=rt(e,t,n),t.scrollLeft=e.x,t.scrollTop=e.y},rt=function(e,t,n){var r=$e(e),i=$e(t),a=tt(t),o=r.x-i.x-a.left;return r=r.y-i.y-a.top,i=new F(e.offsetWidth,e.offsetHeight),e=t.clientWidth-i.width,i=t.clientHeight-i.height,a=t.scrollLeft,t=t.scrollTop,n?(a+=o-e/2,t+=r-i/2):(a+=Math.min(o,Math.max(o-e,0)),t+=Math.min(r,Math.max(r-i,0))),new N(a,t)},it=function(e){var t=new N(0,0),n=e.x&&e.getAttribute(`x`),r=e.y&&e.getAttribute(`y`);return n&&(t.x=parseInt(n)),r&&(t.y=parseInt(r)),(n=(n=e.getAttribute(`transform`))&&n.match(Gs))&&(t.x+=Number(n[1]),n[3]&&(t.y+=Number(n[3]))),(e=e.getAttribute(`style`))&&e.includes(`translate`)&&(e=e.match(Ks))&&(t.x+=Number(e[1]),e[3]&&(t.y+=Number(e[3]))),t},at=function(e){for(var t=0,n=0;e;){let r=it(e);if(t+=r.x,n+=r.y,(` `+(e.getAttribute(`class`)||``)+` `).includes(` injectionDiv `))break;e=e.parentNode}return new N(t,n)},ot=function(){var e=et();return new P(e.y,document.documentElement.clientHeight+e.y,e.x,document.documentElement.clientWidth+e.x)},st=function(){var e=document.documentElement,t=window;return new N(t.pageXOffset||e.scrollLeft,t.pageYOffset||e.scrollTop)},ct=function(e,t){var n=t.x;t=t.y;var r=e.getInjectionDiv().getBoundingClientRect();return n=new N(n-r.left,t-r.top),t=e.getOriginOffsetInPixels(),N.difference(n,t).scale(1/e.scale)},lt=function(e,t){var n=t.scale(e.scale);t=n.x,n=n.y;var r=e.getInjectionDiv().getBoundingClientRect();return e=e.getOriginOffsetInPixels(),new N(t+r.left+e.x,n+r.top+e.y)},e.rc=function(e){return Zs.createElementNS(`https://developers.google.com/blockly/xml`,e)},e.sc=function(e){return Zs.createTextNode(e)},e.uc=function(e){var t=Ys.parseFromString(e,`text/xml`);if(t&&t.documentElement&&!t.getElementsByTagName(`parsererror`).length)return t.documentElement;if((t=Ys.parseFromString(e,`text/html`))&&t.body.firstChild&&t.body.firstChild.nodeName.toLowerCase()===`xml`)return t.body.firstChild;throw Error(`DOMParser was unable to parse: ${e}`)},ut=function(e){return dt(Xs.serializeToString(e))},dt=function(e){return e.replace(ec,e=>`&#${e.charCodeAt(0)};`)},ft=function(e){if(!e)return null;if(e instanceof Element||typeof e==`string`){e=vt(e);var t={contents:gt(e)};e instanceof Node&&_t(e,t),e=t}t=e.kind;var n=e.contents;if(t&&t!==`flyoutToolbox`&&t!==`categoryToolbox`)throw Error(`Invalid toolbox kind `+t+`. Please supply either flyoutToolbox or categoryToolbox`);if(!n)throw Error(`Toolbox must have a contents attribute.`);return e},pt=function(e){return e?e.contents?e.contents:Array.isArray(e)&&e.length>0&&!e[0].nodeType?e:gt(e):[]},mt=function(e){return rc.hasCategoriesInternal(e)},ht=function(e){return e&&e.contents?!!e.contents.filter(function(e){return e.kind.toUpperCase()===`CATEGORY`}).length:!1},gt=function(e){var t=[],n=e.childNodes;n||=e;for(let r=0,i;i=n[r];r++){if(!i.tagName)continue;e={};let n=i.tagName.toUpperCase();e.kind=n,n===`BLOCK`?e.blockxml=i:i.childNodes&&i.childNodes.length>0&&(e.contents=gt(i)),_t(i,e),t.push(e)}return t},_t=function(e,t){for(let n=0;n<e.attributes.length;n++){let r=e.attributes[n];r.nodeName.includes(`css-`)?(t.cssconfig=t.cssconfig||{},t.cssconfig[r.nodeName.replace(`css-`,``)]=r.value):t[r.nodeName]=r.value}},vt=function(t){var n=null;if(t){if(typeof t==`string`){if(n=e.uc(t),n.nodeName.toLowerCase()!==`xml`)throw TypeError(`Toolbox should be an <xml> document.`)}else t instanceof Element&&(n=t)}return n},yt=function(e,t,n,r,i,a){var o=a.scrollbar&&a.scrollbar.canScrollVertically();return e.horizontal===sc.LEFT?(n=i.absoluteMetrics.left+n,o&&a.RTL&&(n+=Js.scrollbarThickness)):(n=i.absoluteMetrics.left+i.viewMetrics.width-t.width-n,o&&!a.RTL&&(n-=Js.scrollbarThickness)),e.vertical===ac.TOP?e=i.absoluteMetrics.top+r:(e=i.absoluteMetrics.top+i.viewMetrics.height-t.height-r,a.scrollbar&&a.scrollbar.canScrollHorizontally()&&(e-=Js.scrollbarThickness)),new P(e,e+t.height,n,n+t.width)},bt=function(e,t){return{horizontal:t.toolboxMetrics.position===I.LEFT||e.horizontalLayout&&!e.RTL?sc.RIGHT:sc.LEFT,vertical:t.toolboxMetrics.position===I.BOTTOM?ac.TOP:ac.BOTTOM}},xt=function(e,t,n,r){var i=e.left,a=e.right-e.left,o=e.bottom-e.top;for(let s=0;s<r.length;s++){let c=r[s];e.intersects(c)&&(e=n===lc.UP?c.top-o-t:c.bottom+t,e=new P(e,e+o,i,i+a),s=-1)}return e},St=function(e,t){y(M.SERIALIZER,e,t)},Ct=function(e,{addCoordinates:t=!1,saveIds:n=!0}={}){var r=e.workspace,i=Object.create(null);return i.height=e.getSize().height,i.width=e.getSize().width,n&&(i.id=e.id),t&&(t=e.getRelativeToSurfaceXY(),i.x=r.RTL?r.getWidth()-t.x:t.x,i.y=t.y),e.getText()&&(i.text=e.getText()),e.isCollapsed()&&(i.collapsed=!0),e.isOwnEditable()||(i.editable=!1),e.isOwnMovable()||(i.movable=!1),e.isOwnDeletable()||(i.deletable=!1),i},wt=function(t,n,{recordUndo:r=!1}={}){var i=e.Qc;if(e.Qc=r,r=n.newComment(t.id),t.text!==void 0&&r.setText(t.text),t.x!==void 0||t.y!==void 0){let e=r.getRelativeToSurfaceXY(),i=t.x??e.x;i=n.RTL?n.getWidth()-i:i;var a;n=(a=t.y)??e.y,r.moveTo(new N(i,n))}return(t.width!==void 0||t.height)&&(a=r.getSize(),r.setSize(new F(t.width??a.width,t.height??a.height))),t.collapsed!==void 0&&r.setCollapsed(t.collapsed),t.editable!==void 0&&r.setEditable(t.editable),t.movable!==void 0&&r.setMovable(t.movable),t.deletable!==void 0&&r.setDeletable(t.deletable),e.Qc=i,r},Tt=function(e,t){y(M.PASTER,e,t)},Et=function(e){for(var t=e.workspace,n=e.getRelativeToSurfaceXY(),r=new N(0,0),i=t.getTopComments(!1).filter(t=>t.id!==e.id).map(e=>e.getRelativeToSurfaceXY());Dt(N.sum(n,r),i);)r.translate(t.RTL?-30:30,30);e.moveTo(N.sum(n,r))},Dt=function(e,t){return t.some(t=>Math.abs(t.x-e.x)<=1&&Math.abs(t.y-e.y)<=1)},Ot=function(e){return e&&typeof e.saveState==`function`&&typeof e.loadState==`function`},kt=function(e){return Mt(e),Po?(Nt(),Promise.resolve()):(Ac||=new Promise(e=>{jc=e,Mc=window.requestAnimationFrame(()=>{Nt(),e()})}),Ac)},At=function(){return Ac||Promise.resolve()},jt=function(e){e||window.cancelAnimationFrame(Mc),Nt(e),!e&&jc&&jc()},Mt=function(t){Oc.add(t),kc.set(t,e.gd);var n=t.getParent();n?Mt(n):Dc.add(t)},Nt=function(t){var n=t?new Set([t]):new Set([...Dc].map(e=>e.workspace)),r=[...Dc].filter(Ft).filter(e=>n.has(e.workspace));for(var i of r)It(i);for(let e of n)e.resizeContents(),e.connectionDBList.forEach(e=>e==null?void 0:e.beginBulkUpdates());for(var a of r)i=a.getRelativeToSurfaceXY(),a.updateComponentLocations(i);for(var o of n)o.connectionDBList.forEach(e=>e==null?void 0:e.endBulkUpdates());for(let t of r)a=e.gd,(o=kc.get(t))&&e.B(o),t.bumpNeighbours(),e.B(a);for(let e of r)Pt(e);t||(Ac=null)},Pt=function(e){Dc.delete(e),Oc.delete(e),kc.delete(e);for(let t of e.getChildren(!1))Pt(t)},Ft=function(e){return!e.isDisposed()&&!e.getParent()},It=function(e){if(Oc.has(e)&&e.initialized){for(let t of e.getChildren(!1))It(t);e.renderEfficiently()}},Lt=function(e,t){Ut(Fc.ALERT,e,t,void 0)},Rt=function(e,t){Ut(Fc.CONFIRM,e,t,void 0)},zt=function(e,t,n){Ut(Fc.PROMPT,e,n,t)},Bt=function(e,t){Rc(e,t)},Vt=function(e,t){zc(e,t)},Ht=function(e,t,n){Bc(e,t,n)},Ut=function(...[t,n,r,i]){var a=document.createElement(`dialog`),o=document.createElement(`form`),s=document.createElement(`label`),c=document.createElement(`input`),l=document.createElement(`div`),u=document.createElement(`button`);a.className=`blocklyDialog`,o.className=`blocklyDialogForm`,s.className=`blocklyDialogPrompt`,l.className=`blocklyDialogButtonRow`,u.className=`blocklyDialogConfirmButton`,o.setAttribute(`method`,`dialog`),s.textContent=n,s.setAttribute(`for`,`blockly-form-input`),u.textContent=e.C.DIALOG_OK,u.value=`ok`,a.appendChild(o),o.appendChild(s),t===Fc.PROMPT&&(c.id=`blockly-form-input`,c.className=`blocklyDialogInput`,c.type=`text`,c.name=`input`,c.autofocus=!0,i&&(c.value=i),o.appendChild(c)),l.appendChild(u),(t===Fc.CONFIRM||t===Fc.PROMPT)&&(n=document.createElement(`button`),n.className=`blocklyDialogCancelButton`,n.textContent=e.C.DIALOG_CANCEL,n.value=`cancel`,l.appendChild(n)),o.appendChild(l);var d;Lc===0&&(d=e.t().ephemeralFocusTaken()?void 0:e.t().takeEphemeralFocus(a)),Lc++,a.addEventListener(`close`,()=>{if(Lc--,!Lc){let e;(e=d)==null||e()}switch(a.remove(),t){case Fc.CONFIRM:r(a.returnValue===`ok`);break;case Fc.PROMPT:r(a.returnValue===`ok`?c.value:null);break;case Fc.ALERT:r==null||r()}}),document.body.appendChild(a),a.showModal()},Wt=function(e){return typeof e.bubbleIsVisible==`function`&&typeof e.setBubbleVisible==`function`&&typeof e.getBubble==`function`},Gt=function(e,t){return t.map(t=>e.getBlockById(t)).filter(e=>e&&e.isShadow()).length===t.length},Kt=function(e){return e&&typeof e.getProcedureDef==`function`},qt=function(e){return e.getVariableModel!==void 0},e.Bd=function(e){e=e.getAllBlocks(!1);var t=new Set;for(let n=0;n<e.length;n++){let r=e[n].getVarModels();if(r)for(let e=0;e<r.length;e++){let n=r[e];n.getId()&&t.add(n)}}return Array.from(t.values())},e.Cd=function(e){e=e.getAllBlocks(!1);var t=new Set;for(let r=0,i;i=e[r];r++){var n=i.getDeveloperVariables;if(n){n=n();for(let e=0;e<n.length;e++)t.add(n[e])}}return Array.from(t.values())},Jt=function(e){return $o.variables_set||$o.variables_get||console.warn(`There are no variable blocks, but there is a variable category.`),e.registerButtonCallback(`CREATE_VARIABLE`,function(e){$t(e.getTargetWorkspace())}),[{kind:`button`,text:`%{BKY_NEW_VARIABLE}`,callbackkey:`CREATE_VARIABLE`},...Xt(e,e.getVariableMap().getVariablesOfType(``),!0)]},Yt=function(e){return{VAR:{name:e.getName(),type:e.getType()}}},Xt=function(e,t,n,r=`variables_get`,i=`variables_set`){n&&=$o.math_change,e=[];var a=t.slice(-1)[0];return a&&($o[i]&&e.push({kind:`block`,type:i,gap:n?8:24,fields:Yt(a)}),n&&e.push({kind:`block`,type:`math_change`,gap:$o[r]?20:8,fields:Yt(a),inputs:{DELTA:{shadow:{type:`math_number`,fields:{NUM:1}}}}})),$o[r]&&e.push(...t.sort(ln).map(e=>({kind:`block`,type:r,gap:8,fields:Yt(e)}))),e},Zt=function(e){return Ql.generateUniqueNameInternal(e)},Qt=function(e,t){if(!t.length)return e;for(var n=``,r=`ijkmnopqrstuvwxyzabcdefgh`.indexOf(e);;){let i=!1;for(let n=0;n<t.length;n++)if(t[n].toLowerCase()===e){i=!0;break}if(!i)break;r++,r===25&&(r=0,n=`${Number(n)+1}`),e=`ijkmnopqrstuvwxyzabcdefgh`.charAt(r)+n}return e},$t=function(t,n,r){function i(r){en(e.C.NEW_VARIABLE_TITLE,r,function(r){if(r){var o=nn(r,t);if(o){if(o.getType()===a)var s=e.C.VARIABLE_ALREADY_EXISTS.replace(`%1`,o.getName());else s=e.C.VARIABLE_ALREADY_EXISTS_FOR_ANOTHER_TYPE,s=s.replace(`%1`,o.getName()).replace(`%2`,o.getType());Bt(s,function(){i(r)})}else{let i=t.getVariableMap().createVariable(r,a);n&&n(r);let o=(s=t.getFlyout())==null?void 0:s.getWorkspace();if(o&&z.getIsActive()){var c=t=>{t.type===e.Od&&(t=t.blockId)&&(t=o.getBlockById(t))&&t.type===`variables_set`&&t.getFieldValue(`VAR`)===i.getId()&&(e.t().focusNode(t),o.removeChangeListener(c))};o.addChangeListener(c)}}}else n&&n(null)})}var a=r||``;i(``)},e.Rd=function(t,n,r){function i(a){var o=e.C.RENAME_VARIABLE_TITLE.replace(`%1`,n.getName());en(o,a,function(a){if(a){var o=tn(a,n.getType(),t),s=rn(n.getName(),a,t);if(o||s){var c=``;o?c=e.C.VARIABLE_ALREADY_EXISTS_FOR_ANOTHER_TYPE.replace(`%1`,o.getName()).replace(`%2`,o.getType()):s&&(c=e.C.VARIABLE_ALREADY_EXISTS_FOR_A_PARAMETER.replace(`%1`,a).replace(`%2`,s)),Bt(c,function(){i(a)})}else t.getVariableMap().renameVariable(n,a),r&&r(a)}else r&&r(null)})}i(``)},en=function(t,n,r){Ht(t,n,function(t){t&&(t=t.replace(/[\s\xa0]+/g,` `).trim(),t===e.C.RENAME_VARIABLE||t===e.C.NEW_VARIABLE)&&(t=null),r(t)})},tn=function(e,t,n){n=n.getVariableMap().getAllVariables(),e=e.toLowerCase();for(let r=0,i;i=n[r];r++)if(i.getName().toLowerCase()===e&&i.getType()!==t)return i;return null},nn=function(e,t){t=t.getVariableMap().getAllVariables(),e=e.toLowerCase();for(let n=0,r;r=t[n];n++)if(r.getName().toLowerCase()===e)return r;return null},rn=function(e,t,n){return n.getProcedureMap().getProcedures().length?an(e,t,n):on(e,t,n)},an=function(e,t,n){e=e.toLowerCase(),t=t.toLowerCase(),n=n.getProcedureMap().getProcedures();for(let i of n){var r=i.getParameters().filter(qt).map(e=>e.getVariableModel().getName());if(r&&(n=r.some(t=>t.toLowerCase()===e),r=r.some(e=>e.toLowerCase()===t),n&&r))return i.getName()}return null},on=function(e,t,n){e=e.toLowerCase(),t=t.toLowerCase(),n=n.getAllBlocks(!1);for(let i of n){if(!Kt(i))continue;n=i.getProcedureDef();var r=n[1];let a=r.some(t=>t.toLowerCase()===e);if(r=r.some(e=>e.toLowerCase()===t),a&&r)return n[0]}return null},sn=function(t){var n=e.rc(`field`);return n.setAttribute(`name`,`VAR`),n.setAttribute(`id`,t.getId()),n.setAttribute(`variabletype`,t.getType()),t=e.sc(t.getName()),n.appendChild(t),n},e.Wd=function(t,n,r,i){var a=e.Vd(t,n,r,i);if(!a){a=t.getVariableMap();let e=t.getPotentialVariableMap();r||=Zt(t.isFlyout?t.targetWorkspace:t),a=e?e.createVariable(r,i,n??void 0):a.createVariable(r,i,n)}return a},e.Vd=function(e,t,n,r){var i=e.getPotentialVariableMap(),a=null;if(t&&(a=e.getVariableMap().getVariableById(t),!a&&i&&(a=i.getVariableById(t)),a))return a;if(n){if(r===void 0)throw Error(`Tried to look up a variable by name without a type`);a=e.getVariableMap().getVariable(n,r),!a&&i&&(a=i.getVariable(n,r))}return a},cn=function(e,t){e=e.getVariableMap().getAllVariables();var n=[];if(t.length!==e.length)for(let r=0;r<e.length;r++){let i=e[r];t.includes(i)||n.push(i)}return n},ln=function(e,t){return Zl.compare(e.getName(),t.getName())},un=function(e,t){var n=[];e=e.getAllBlocks(!1);for(let r=0;r<e.length;r++){let i=e[r].getVarModels();if(i)for(let a=0;a<i.length;a++)i[a].getId()===t&&n.push(e[r])}return n},e.$d=function(t,n,r){var i=n.getName(),a=un(t,n.getId());for(let t=a.length-1;t>=0;t--){let n=a[t];if(n.type===`procedures_defnoreturn`||n.type===`procedures_defreturn`){r=String(n.getFieldValue(`NAME`)),i=e.C.CANNOT_DELETE_VARIABLE_PROCEDURE.replace(`%1`,i).replace(`%2`,r),Rc(i,void 0);return}n===r&&a.splice(t,1)}r&&a.length||a.length>1?(i=e.C.DELETE_VARIABLE_CONFIRMATION.replace(`%1`,String(a.length+(r&&!r.workspace.isFlyout?1:0))).replace(`%2`,i),Vt(i,e=>{e&&n&&t.getVariableMap().deleteVariable(n)})):t.getVariableMap().deleteVariable(n)},dn=function(e,{addCoordinates:t=!1,addInputBlocks:n=!0,addNextBlocks:r=!0,doFullSerialization:i=!0,saveIds:a=!0}={}){if(e.isInsertionMarker())return null;var o={type:e.type,id:a?e.id:void 0};if(t){t=e.workspace;var s=e.getRelativeToSurfaceXY();o.x=Math.round(t.RTL?t.getWidth()-s.x:s.x),o.y=Math.round(s.y)}e.isCollapsed()&&(o.collapsed=!0),e.isEnabled()||(o.disabledReasons=Array.from(e.getDisabledReasons())),e.isOwnDeletable()||(o.deletable=!1),e.isOwnMovable()||(o.movable=!1),e.isOwnEditable()||(o.editable=!1),e.inputsInline!==void 0&&e.inputsInline!==e.inputsInlineDefault&&(o.inline=e.inputsInline),e.data&&(o.data=e.data),e.saveExtraState?(t=e.saveExtraState(i),t!==null&&(o.extraState=t)):e.mutationToDom&&(t=e.mutationToDom(),t!==null&&(o.extraState=ti(t).replace(` xmlns="https://developers.google.com/blockly/xml"`,``))),t=Object.create(null);for(var c of e.getIcons())Ot(c)&&(s=c.saveState(i))&&(t[c.getType().toString()]=s);Object.keys(t).length&&(o.icons=t),c=Object.create(null);for(var l of e.getFields())l.isSerializable()&&(c[l.name]=l.saveState(i));if(Object.keys(c).length&&(o.fields=c),n){for(n=Object.create(null),l=0;l<e.inputList.length;l++)c=e.inputList[l],c.connection&&(t=fn(c.connection,i,a))&&(n[c.name]=t);Object.keys(n).length&&(o.inputs=n)}return r&&e.nextConnection&&(e=fn(e.nextConnection,i,a))&&(o.next=e),o},fn=function(e,t,n){var r=e.getShadowState(!0);if(e=e.targetBlock(),!r&&!e)return null;var i=Object.create(null);return r&&(i.shadow=r),e&&!e.isShadow()&&(i.block=dn(e,{doFullSerialization:t,saveIds:n})),i},pn=function(e,t,{recordUndo:n=!1}={}){return e=mn(e,t,{recordUndo:n}),t.rendered&&jt(),e},mn=function(t,n,{parentConnection:r,isShadow:i=!1,recordUndo:a=!1}={}){var o=e.Qc;e.Qc=a,(a=e.gd)||e.B(!0),e.Ub++;var s=n.getVariableMap().getAllVariables();try{var c=hn(t,n,{parentConnection:r,isShadow:i})}finally{e.Ub--}if(gn(n,s),Je()&&b(new(x(E.BLOCK_CREATE))(c)),e.B(a),e.Qc=o,n.rendered){let e=c;setTimeout(()=>{e.disposed||e.setConnectionTracking(!0)},1)}return c},hn=function(t,n,{parentConnection:r,isShadow:i=!1}={}){if(!t.type)throw new tu(t);var a=n.newBlock(t.type,t.id);a.setShadow(i),i=t.x===void 0?0:t.x;var o=t.y===void 0?0:t.y,s=a.workspace;if(i=s.RTL?s.getWidth()-i:i,a.moveBy(i,o),t.collapsed&&a.setCollapsed(!0),t.deletable===!1&&a.setDeletable(!1),t.movable===!1&&a.setMovable(!1),t.editable===!1&&a.setEditable(!1),t.enabled===!1&&a.setDisabledReason(!0,`MANUALLY_DISABLED`),Array.isArray(t.disabledReasons))for(var c of t.disabledReasons)a.setDisabledReason(!0,c);if(t.inline!==void 0&&a.setInputsInline(t.inline),t.data!==void 0&&(a.data=t.data),t.extraState&&(a.loadExtraState?a.loadExtraState(t.extraState):a.domToMutation&&a.domToMutation(e.uc(t.extraState))),r){if(r.getSourceBlock().isShadow()&&!a.isShadow())throw new iu(t);if(r.type===e.je.VALUE){if(c=a.outputConnection,!c)throw new nu(`output`,a,t)}else if(c=a.previousConnection,!c)throw new nu(`previous`,a,t);if(!r.connect(c))throw n=a.workspace.connectionChecker,new ru(n.getErrorMessage(n.canConnectWithReason(c,r,!1),c,r),r.type===e.je.VALUE?`output connection`:`previous connection`,a,t)}if(t.icons){r=Object.keys(t.icons);for(var l of r){if(r=t.icons[l],c=a.getIcon(l),!c){if(c=Le(M.ICON,l,!1),!c)throw new au(l,a,t);c=new c(a),a.addIcon(c)}Ot(c)&&c.loadState(r)}}if(t.fields)for(l=Object.keys(t.fields),r=0;r<l.length;r++)c=l[r],i=t.fields[c],(o=a.getField(c))?o.loadState(i):console.warn(`Ignoring non-existant field ${c} in block ${a.type}`);if(t.inputs)for(l=Object.keys(t.inputs),r=0;r<l.length;r++){if(c=l[r],i=a.getInput(c),!i||!i.connection)throw new nu(c,a,t);_n(i.connection,t.inputs[c])}if(t.next){if(!a.nextConnection)throw new nu(`next`,a,t);_n(a.nextConnection,t.next)}if(n.rendered){a.setConnectionTracking(!1),a.initSvg(),a.queueRender();for(let e of a.getIcons())e.onLocationChange(a.getRelativeToSurfaceXY())}else a.initModel();return a},gn=function(e,t){if(Je())for(e=cn(e,t),t=0;t<e.length;t++){let n=e[t];b(new(x(E.VAR_CREATE))(n))}},_n=function(e,t){t.shadow&&e.setShadowState(t.shadow),t.block&&hn(t.block,e.getSourceBlock().workspace,{parentConnection:e})},vn=function(e){return e=yn(e,lu),e.length?e[0].join(Vo?` `:` + `):``},yn=function(t,n){if(t=j.registry.getKeyCodesByShortcutName(t),t.length===0)return[];t=t.map(e=>e.split(`+`)),t.forEach(e=>e.sort((e,t)=>(e=bn(e),t=bn(t),e-t))),t.sort((e,t)=>(e=+!!e.includes(`Meta`),+!!t.includes(`Meta`)-e));var r=t.filter(e=>e.includes(`Meta`)===Vo);return r=r.length===0?t:r,r.sort((e,t)=>e.length-t.length),(r.some(e=>e.some(e=>e===`Meta`||e===`Alt`||e===`Control`))?[r[0]]:r).map(t=>t.map(t=>{if(Number.isFinite(+t)){if(t=+t,t>=65&&t<=90)t=String.fromCharCode(t);else{var n={8:e.C.BACKSPACE_KEY,9:e.C.TAB_KEY,13:e.C.ENTER_KEY,16:e.C.SHIFT_KEY,17:e.C.CONTROL_KEY,18:e.C.ALT_KEY,19:e.C.PAUSE_KEY,20:e.C.CAPS_LOCK_KEY,27:e.C.ESCAPE,32:e.C.SPACE_KEY,33:e.C.PAGE_UP_KEY,34:e.C.PAGE_DOWN_KEY,35:e.C.END_KEY,36:e.C.HOME_KEY,37:`←`,38:`↑`,39:`→`,40:`↓`,45:e.C.INSERT_KEY,46:e.C.DELETE_KEY,48:`0`,49:`1`,50:`2`,51:`3`,52:`4`,53:`5`,54:`6`,55:`7`,56:`8`,57:`9`,59:`;`,61:`=`,93:e.C.CONTEXT_MENU_KEY,96:`0`,97:`1`,98:`2`,99:`3`,100:`4`,101:`5`,102:`6`,103:`7`,104:`8`,105:`9`,106:`×`,107:`+`,109:`−`,110:`.`,111:`÷`,112:`F1`,113:`F2`,114:`F3`,115:`F4`,116:`F5`,117:`F6`,118:`F7`,119:`F8`,120:`F9`,121:`F10`,122:`F11`,123:`F12`,186:`;`,187:`=`,189:`-`,188:`,`,190:`.`,191:`/`,192:"`",219:`[`,220:`\\`,221:`]`,222:`'`,224:`⌘`}[t];n?t=n:(console.warn(`Unknown key code: `+t),t=String.fromCharCode(t))}}return t}).map(e=>{var t=n[e]??e;return t.charAt(0).toUpperCase()+t.substring(1)}))},bn=function(e){return e=uu.indexOf(e),e===-1?Number.MAX_VALUE:e},xn=function(e){return e&&typeof e.init==`function`&&typeof e.getDiv==`function`&&typeof e.getId==`function`&&typeof e.getParent==`function`&&typeof e.getLevel==`function`&&typeof e.isSelectable==`function`&&typeof e.isCollapsible==`function`&&typeof e.dispose==`function`&&typeof e.getClickTarget==`function`&&typeof e.setVisible_==`function`&&typeof e.getParentToolbox==`function`},Sn=function(e){return typeof e.getName==`function`&&typeof e.getContents==`function`&&typeof e.setSelected==`function`&&typeof e.onClick==`function`&&xn(e)&&e.isSelectable()},Cn=function(t,n=ss.STANDARD,r){return[n>=ss.STANDARD&&En(t),Tn(t),...Dn(t,n,r),n===ss.LOQUACIOUS&&Mn(t),n>=ss.STANDARD&&(t.isEnabled()?void 0:e.C.BLOCK_LABEL_DISABLED),n>=ss.STANDARD&&(t.isCollapsed()?e.C.BLOCK_LABEL_COLLAPSED:void 0),n>=ss.LOQUACIOUS&&(t.isShadow()?e.C.BLOCK_LABEL_REPLACEABLE:void 0),n>=ss.STANDARD&&Ln(t),n>=ss.LOQUACIOUS&&t.getAriaRoleDescription()].filter(e=>!!e).join(`, `)},wn=function(t,n,r=ss.STANDARD){var i=r>=ss.LOQUACIOUS,a=[],o=t.fieldRow.filter(e=>e.isVisible()).flatMap((e,t,n)=>{if(e.isLabelField()){if(t<n.length-1&&n[t+1].isLabelField())return a.push(e.computeAriaLabel(i)),[];if(a.length>=1)return a.push(e.computeAriaLabel(i)),e=a.join(` `),a=[],e}return e.computeAriaLabel(i)});if(!o.length&&n){let e=t.getSourceBlock().inputList,i=e.indexOf(t);if(i>0)return wn(e[i-1],n,r)}var s;return t.type===e.je.VALUE&&((s=t.connection)==null?void 0:s.targetConnection)===null&&r>=ss.STANDARD&&o.push(e.C.INPUT_LABEL_EMPTY),o.filter(e=>!!e)},Tn=function(t){var n,r,i=(n=t.outputConnection??t.previousConnection)==null||(r=n.targetConnection)==null?void 0:r.getParentInput();if(i&&(t=i.getSourceBlock(),!t.isInsertionMarker())){if(n=i.getAriaLabelText())t=n;else{if(!t.statementInputCount||(n=t.inputList.find(t=>t.type===e.je.STATEMENT),i===n)||(t=An(t,i,!1),!t.length))return;t=t.join(`, `)}return i.type===e.je.STATEMENT?(i=Array.isArray(t)?t.join(` `):t,e.C.BLOCK_LABEL_BEGIN_PREFIX.replace(`%1`,i)):t}},En=function(t){if(!t.isInFlyout&&!t.isDragging())return t.getRootBlock()===t?e.C.BLOCK_LABEL_BEGIN_STACK:void 0},Dn=function(t,n=ss.STANDARD,r){if(r)return[r];if(r=t=t.inputList.filter(e=>e.isVisible()),n<=ss.STANDARD){let n=t.filter(t=>t.type===e.je.STATEMENT);n.length>1&&(r=t.slice(0,t.indexOf(n[0])+1))}var i=[];return r.flatMap((t,r,a)=>{var o=t.getLabel(n),s;if(s=r<a.length-1&&kn(t)&&On(a[r+1])){s=a[r+1];let n;r=((n=t.connection)==null?void 0:n.type)===L.NEXT_STATEMENT||t.type===e.je.END_ROW;let i;s=!(!t.getSourceBlock().getInputsInline()||((i=s.connection)==null?void 0:i.type)===L.NEXT_STATEMENT||r)}return s?(i.push(o),[]):On(t)&&i.length>0?(i.push(o),t=i.join(` `),i=[],t):o})},On=function(e){return e=e.fieldRow.filter(e=>e.isVisible()),e.length>0&&e[0].isLabelField()},kn=function(t){return t.type===e.je.VALUE||t.type===e.je.STATEMENT?!1:(t=t.fieldRow.filter(e=>e.isVisible()),t.length>0&&t[t.length-1].isLabelField())},An=function(t,n,r){var i=t.inputList.indexOf(n);if(i===-1)throw Error(`Input with name "${n.name}" not found on block with id "${t.id}".`);var a=n.type===e.je.STATEMENT,o=a?jn(t.inputList,i):i,s=t.inputList.slice(o,i+1).filter(e=>e.isVisible()),c=s.map(e=>e.getLabel(ss.TERSE,e!==n||r)),l=a&&c.slice(0,-1).some(e=>!!e);return c.map((t,n)=>{if(t)return t;if(t=s[n],!(t.type===e.je.DUMMY||t.type===e.je.END_ROW||a&&n===c.length-1&&l))return e.C.INPUT_LABEL_INDEX.replace(`%1`,(t.getIndex()+1).toString())}).filter(e=>e!==void 0)},jn=function(t,n){for(--n;n>=0;n--)if(t[n].type===e.je.STATEMENT)return n+1;return 0},Mn=function(t){var n=t.workspace.getToolbox();if(n){var r=void 0;for(let e of n.getToolboxItems())if(Sn(e)){if(n=e.getContents(),Array.isArray(n)&&n.some(e=>e.kind.toLowerCase()===`block`&&`type`in e&&e.type===t.type)){r=e;break}`getColour`in e&&typeof e.getColour==`function`&&e.getColour()===t.getColour()&&(r=e)}if(r)return e.C.BLOCK_LABEL_TOOLBOX_CATEGORY.replace(`%1`,r.getName())}},Nn=function(t){switch(t){case du.BEFORE:return e.C.ANNOUNCE_MOVE_BEFORE;case du.AFTER:return e.C.ANNOUNCE_MOVE_AFTER;case du.INSIDE:return e.C.ANNOUNCE_MOVE_INSIDE;case du.AROUND:return e.C.ANNOUNCE_MOVE_AROUND;default:return e.C.ANNOUNCE_MOVE_TO}},Pn=function(t,n){var r=t.getParentInput();if(!r)return n;var i=r.getAriaLabelText();if(!i){if(t=An(t.getSourceBlock(),r,!0),!t.length)return n;i=t.join(`, `)}return n?e.C.ANNOUNCE_MOVE_OF.replace(`%1`,i).replace(`%2`,n):i},Fn=function(e,t,n,r=!1){var i=In(e,t),a=Nn(i),o=![du.BEFORE,du.AFTER].includes(i);return i=o&&n(!0),n=o&&n(!1),r=r?e.getSourceBlock().getStackBlocksCountLabel():``,o=t.getSourceBlock().getAriaLabel(ss.TERSE),i&&(r=Pn(e,r)),n&&(o=Pn(t,o)),a.replace(`%1`,r).replace(`%2`,o)},In=function(e,t){switch(e.type){case L.INPUT_VALUE:case L.OUTPUT_VALUE:return du.TO;case L.NEXT_STATEMENT:return e===e.getSourceBlock().nextConnection?du.BEFORE:du.AROUND;case L.PREVIOUS_STATEMENT:return t===t.getSourceBlock().nextConnection?du.AFTER:du.INSIDE}return du.UNKNOWN},Ln=function(t){var n=t.inputList.filter(t=>t.type===e.je.STATEMENT).length;if(n>1)return e.C.BLOCK_LABEL_HAS_BRANCHES.replace(`%1`,n.toString());switch(t.inputList.reduce((e,t)=>{var n;return t.fieldRow.reduce((e,t)=>t.EDITABLE&&!t.isFullBlockField()?++e:e,e)+ +(((n=t.connection)==null?void 0:n.type)===L.INPUT_VALUE)},0)){case 0:break;case 1:return e.C.BLOCK_LABEL_HAS_INPUT;default:return e.C.BLOCK_LABEL_HAS_INPUTS}},Rn=function(e){return e*Math.PI/180},zn=function(e,t,n){if(n<e){let t=n;n=e,e=t}return Math.max(e,Math.min(t,n))},Bn=function(){document.querySelector(`.blocklyDropDownDiv`)||(B=document.createElement(`div`),B.className=`blocklyDropDownDiv`,B.tabIndex=-1,B.id=He(),(ke()||document.body).appendChild(B),vu=document.createElement(`div`),vu.className=`blocklyDropDownContent`,B.appendChild(vu),wu=o(vu,`keydown`,null,Fe),yu=document.createElement(`div`),yu.className=`blocklyDropDownArrow`,B.appendChild(yu),B.style.opacity=`0`,B.style.transition=`transform 0.25s, opacity 0.25s`)},Vn=function(){Cu&&=(Cu(!1),null),$n()},Hn=function(){wu&&=(c(wu),null),B.remove(),Bn()},Un=function(e,t){B.style.backgroundColor=e,B.style.borderColor=t},Wn=function(e,t,n,r=!0){return Su=!0,qn(Kn(e),e,r,t,n)},Gn=function(e){var t=e.getSvgRoot(),n=e.workspace.scale,r=e.height*n;return e=e.width*n,t=$e(t),new P(t.y,t.y+r,t.x,t.x+e)},Kn=function(e){return e=e.getScaledBBox(),new P(e.top,e.bottom,e.left,e.right)},qn=function(e,t,n,r,i){var a=e.left+(e.right-e.left)/2,o=e.bottom;e=e.top,i&&(e+=i),i=t.getSourceBlock();for(var s=i.workspace;s.options.parentWorkspace;)s=s.options.parentWorkspace;return bu=s.getParentSvg().parentNode,Jn(t,i.RTL,a,o,a,e,n,r)},Jn=function(t,n,r,i,a,o,s,c){e.t().registerPopoverFocusLossHandler(Vn);var l;return(l=ke())==null||l.appendChild(B),xu=t,hu=c||null,B.style.direction=n?`rtl`:`ltr`,t=Os,gu=t.getRenderer().getClassName(),_u=t.getTheme().getClassName(),g(B,gu),g(B,_u),n=ae(t.getFocusableElement(),k.OWNS),m(t.getFocusableElement(),k.OWNS,n?[n,B.id]:B.id),t.getFocusableElement().classList.add(`blocklyShowingDropDownDiv`),r=tr(r,i,a,o),s&&(Cu=e.t().takeEphemeralFocus(B)),r},Yn=function(e,t,n,r){return e=Zn(e,n.left,n.right,r.width),{initialX:e.divX,initialY:t,finalX:e.divX,finalY:t+16,arrowX:e.arrowX,arrowY:-9,arrowAtTop:!0,arrowVisible:!0}},Xn=function(e,t,n,r){return e=Zn(e,n.left,n.right,r.width),{initialX:e.divX,initialY:t-r.height,finalX:e.divX,finalY:t-r.height-16,arrowX:e.arrowX,arrowY:r.height-2-8,arrowAtTop:!1,arrowVisible:!0}},Zn=function(e,t,n,r){return t=zn(t,e-r/2,n-r),e=e-8-t,e=zn(12,e,r-12-16),{arrowX:e,divX:t}},Qn=function(e,t){return xu===e&&(t?er():$n(),!0)},$n=function(){xu&&(e.t().unregisterPopoverFocusLossHandler(Vn),B.style.transform=`translate(0, 0)`,B.style.opacity=`0`,mu=setTimeout(function(){er()},250),hu&&=(hu(),null))},er=function(){if(xu){mu&&clearTimeout(mu),hu&&=(hu(),null),xu=null;var e=Os,t=ae(e.getFocusableElement(),k.OWNS)??``;m(e.getFocusableElement(),k.OWNS,t.replace(B.id,``)),e.getFocusableElement().classList.remove(`blocklyShowingDropDownDiv`),e.markFocused(),Cu&&=(Cu(),null),Hn()}},tr=function(e,t,n,r){e=Tu.getPositionMetrics(e,t,n,r),e.arrowVisible?(t=e.arrowX,n=e.arrowY,r=e.arrowAtTop?45:225,yu.style.display=``,yu.style.transform=`translate(${t}px, ${n}px) rotate(${r}deg)`,yu.setAttribute(`class`,`blocklyDropDownArrow`)):yu.style.display=`none`,t=Math.floor(e.initialX),n=Math.floor(e.initialY),r=Math.floor(e.finalX);var i=Math.floor(e.finalY),a=B.parentElement;return a&&(a=a.getBoundingClientRect(),t-=a.left+window.scrollX,r-=a.left+window.scrollX,n-=a.top+window.scrollY,i-=a.top+window.scrollY),B.style.left=t+`px`,B.style.top=n+`px`,B.style.visibility=`visible`,B.style.opacity=`1`,B.style.transform=`translate(`+(r-t)+`px,`+(i-n)+`px)`,!!e.arrowAtTop},nr=function(){if(xu){var e=xu.getSourceBlock();e=Su?Kn(xu):Gn(e);let t=e.left+(e.right-e.left)/2;tr(t,e.bottom,t,e.top)}else $n()},rr=function(e){return e.length?e.reduce(function(e,t){return e.length<t.length?e:t}).length:0},ir=function(e,t){if(!e.length)return 0;if(e.length===1)return e[0].length;var n=0;t||=rr(e);var r;for(r=0;r<t;r++){for(var i=e[0][r],a=1;a<e.length;a++)if(i!==e[a][r])return n;i===` `&&(n=r+1)}for(i=1;i<e.length;i++)if((a=e[i][r])&&a!==` `)return n;return t},ar=function(e,t){if(!e.length)return 0;if(e.length===1)return e[0].length;var n=0;t||=rr(e);var r;for(r=0;r<t;r++){for(var i=e[0].substr(-r-1,1),a=1;a<e.length;a++)if(i!==e[a].substr(-r-1,1))return n;i===` `&&(n=r+1)}for(i=1;i<e.length;i++)if((a=e[i].charAt(e[i].length-r-1))&&a!==` `)return n;return t},e.yf=function(e,t){e=e.split(`
6
+ Use `+r+` instead.`),Ts.has(e)||(Ts.add(e),console.warn(e))},xe=function(e){return Ds[e]||null},Se=function(){var e=[];for(let t in Ds)e.push(Ds[t]);return e},Ce=function(e){Ds[e.id]=e},we=function(e){delete Ds[e.id]},Te=function(){return Os},Ee=function(t){Os=t,t.rendered&&e.t().setPopoverFocusRoot(t.getInjectionDiv())},De=function(){var t=e.t().getFocusedNode();return t&&ve(t)?t:null},Oe=function(e){var t=De(),n=new(x(E.SELECTED))((t==null?void 0:t.id)??null,(e==null?void 0:e.id)??null,(e==null?void 0:e.workspace.id)??(t==null?void 0:t.workspace.id)??``);b(n)},ke=function(e=Os){return ks||(e&&e.rendered?e.getInjectionDiv():null)},Ae=function(e){ks=e},je=function(e){for(;e.options.parentWorkspace;)e=e.options.parentWorkspace;var t=e.getParentSvg(),n=e.getCachedParentSvgSize(),r=t.parentElement;if(r instanceof HTMLElement){var i=r.offsetWidth;r=r.offsetHeight,n.width!==i&&(t.setAttribute(`width`,i+`px`),e.setCachedParentSvgSize(i,null)),n.height!==r&&(t.setAttribute(`height`,r+`px`),e.setCachedParentSvgSize(null,r)),e.resize()}},Me=function(e,t){var n=Object.create(null),r=e.getDescendants(!0);t&&(e=e.getNextBlock())&&(e=r.indexOf(e),r.splice(e,r.length-e));for(let e=0,t;t=r[e];e++)n[t.type]?n[t.type]++:n[t.type]=1;return n},Ne=function(e){return function(){this.jsonInit(e)}},Pe=function(e){js.defineBlocksWithJsonArrayInternal(e)},e.yb=function(e){var t={};for(let n=0;n<e.length;n++){let r=e[n];if(!r){console.warn(`Block definition #${n} in JSON array is ${r}. Skipping`);continue}let i=r.type;i?t[i]={init:Ne(r)}:console.warn(`Block definition #${n} in JSON array is missing a type attribute. Skipping.`)}return t},e.Ab=function(e){for(let t of Object.keys(e)){let n=e[t];t in $o&&console.warn(`Block definition "${t}" overwrites previous definition.`),$o[t]=n}},Fe=function(t){var n=Os,r=e.t().getFocusedTree();for(let e of Se())if(r===e){n=e;break}!l(t)&&n&&(!n.rendered||n.isFlyout||n.isVisible())&&j.registry.onKeyDown(n,t)},y=function(e,t,n,r){if(!(e instanceof M)&&typeof e!=`string`||`${e}`.trim()===``)throw Error(`Invalid type "`+e+`". The type must be a non-empty string or a Blockly.registry.Type.`);if(e=`${e}`.toLowerCase(),typeof t!=`string`||t.trim()===``)throw Error(`Invalid name "`+t+`". The name must be a non-empty string.`);var i=t.toLowerCase();if(!n)throw Error(`Can not register a null value`);var a=Ns[e],o=Fs[e];switch(a||(a=Ns[e]=Object.create(null),o=Fs[e]=Object.create(null)),e){case String(M.FIELD):if(typeof n.fromJson!=`function`)throw Error(`Type "`+e+`" must have a fromJson function`)}if(!r&&a[i]&&a[i]!==n)throw Error(`Name "`+i+`" with type "`+e+`" already registered.`);a[i]=n,o[i]=t},Ie=function(e,t){e=`${e}`.toLowerCase(),t=t.toLowerCase();var n=Ns[e];n&&n[t]?(delete Ns[e][t],delete Fs[e][t]):console.warn(`Unable to unregister [`+t+`][`+e+`] from the registry.`)},Le=function(e,t,n){e=`${e}`.toLowerCase(),t=t.toLowerCase();var r=Ns[e];if(!r||!r[t]){if(t=`Unable to find [`+t+`][`+e+`] in the registry.`,n)throw Error(t+` You must require or register a `+e+` plugin.`);return console.warn(t),null}return r[t]},Re=function(e,t){return e=`${e}`.toLowerCase(),t=t.toLowerCase(),(e=Ns[e])?!!e[t]:!1},ze=function(e,t,n){return Le(e,t,n)},Be=function(e,t,n){e=`${e}`.toLowerCase();var r=Ns[e];if(!r){if(r=`Unable to find [${e}] in the registry.`,n)throw Error(`${r} You must require or register a ${e} plugin.`);return console.warn(r),null}if(!t)return r;e=Fs[e],n=Object.create(null);for(let t of Object.keys(r))n[e[t]]=r[t];return n},Ve=function(e,t,n){return t=t.plugins[String(e)]||`default`,typeof t==`function`?t:Le(e,t,n)},He=function(){return`blockly-`+(Rs++).toString(36)},Ue=function(){return Ls.genUid()},b=function(e){Vs.fireInternal(e)},We=function(){var e=Ke(Bs);Bs.length=0;for(let t of e){if(!t.workspaceId)continue;let e;(e=xe(t.workspaceId))==null||e.fireChangeListener(t)}},Ge=function(e){if(e.type===E.BLOCK_CHANGE&&e.element===`mutation`){let t;for(t=Bs.length;t>0;t--){let n=Bs[t-1];if(n.group!==e.group||n.workspaceId!==e.workspaceId||n.type!==E.BLOCK_MOVE||n.newParentId!==e.blockId)break}Bs.splice(t,0,e)}else Bs.push(e)},Ke=function(e){var t=[];for(let n of e)e=t[t.length-1],!n.isNull()&&(!e||e.workspaceId!==n.workspaceId||e.group!==n.group?t.push(n):n.type===E.BLOCK_MOVE&&e.type===E.BLOCK_MOVE&&n.blockId===e.blockId?(e.newParentId=n.newParentId,e.newInputName=n.newInputName,e.newCoordinate=n.newCoordinate,(e.reason||n.reason)&&(e.reason=Array.from(new Set((e.reason??[]).concat(n.reason??[]))))):n.type===E.BLOCK_CHANGE&&e.type===E.BLOCK_CHANGE&&n.blockId===e.blockId&&n.element===e.element&&n.name===e.name?e.newValue=n.newValue:n.type===E.VIEWPORT_CHANGE&&e.type===E.VIEWPORT_CHANGE?(e.viewTop=n.viewTop,e.viewLeft=n.viewLeft,e.scale=n.scale,e.oldScale=n.oldScale):(n.type!==E.CLICK||e.type!==E.BUBBLE_OPEN)&&(n.type===E.SELECTED&&e.type===E.SELECTED&&e.newElementId===void 0?(e.newElementId=n.newElementId,e.oldElementId===e.newElementId&&t.pop()):t.push(n)));return e=t.filter(e=>!e.isNull())},qe=function(){for(let e=0,t;t=Bs[e];e++)t.recordUndo=!1},Je=function(){return e.Ub===0},e.B=function(e){Vs.setGroupInternal(e)},Ye=function(e){var t=[];e=e.getDescendants(!1);for(let n=0,r;r=e[n];n++)t[n]=r.id;return t},x=function(e){var t=Le(M.EVENT,e,void 0);if(!t)throw Error(`Event type ${e} not found in registry.`);return t},Xe=function(t){Object.keys(t).forEach(function(n){e.C[n]=t[n]})},Ze=function(e){return Us.getSizeInternal(e)},Qe=function(e,t){return e=window.getComputedStyle(e),e[t]||e.getPropertyValue(t)},$e=function(e){var t=new N(0,0);e=e.getBoundingClientRect();var n=document.documentElement;return n=new N(window.pageXOffset||n.scrollLeft,window.pageYOffset||n.scrollTop),t.x=e.left+n.x,t.y=e.top+n.y,t},et=function(){var e=document.body,t=document.documentElement;return new N(e.scrollLeft||t.scrollLeft,e.scrollTop||t.scrollTop)},tt=function(e){var t=parseFloat(Qe(e,`borderLeftWidth`)),n=parseFloat(Qe(e,`borderRightWidth`)),r=parseFloat(Qe(e,`borderTopWidth`));return e=parseFloat(Qe(e,`borderBottomWidth`)),new P(r,e,t,n)},nt=function(e,t,n){e=rt(e,t,n),t.scrollLeft=e.x,t.scrollTop=e.y},rt=function(e,t,n){var r=$e(e),i=$e(t),a=tt(t),o=r.x-i.x-a.left;return r=r.y-i.y-a.top,i=new F(e.offsetWidth,e.offsetHeight),e=t.clientWidth-i.width,i=t.clientHeight-i.height,a=t.scrollLeft,t=t.scrollTop,n?(a+=o-e/2,t+=r-i/2):(a+=Math.min(o,Math.max(o-e,0)),t+=Math.min(r,Math.max(r-i,0))),new N(a,t)},it=function(e){var t=new N(0,0),n=e.x&&e.getAttribute(`x`),r=e.y&&e.getAttribute(`y`);return n&&(t.x=parseInt(n)),r&&(t.y=parseInt(r)),(n=(n=e.getAttribute(`transform`))&&n.match(Gs))&&(t.x+=Number(n[1]),n[3]&&(t.y+=Number(n[3]))),(e=e.getAttribute(`style`))&&e.includes(`translate`)&&(e=e.match(Ks))&&(t.x+=Number(e[1]),e[3]&&(t.y+=Number(e[3]))),t},at=function(e){for(var t=0,n=0;e;){let r=it(e);if(t+=r.x,n+=r.y,(` `+(e.getAttribute(`class`)||``)+` `).includes(` injectionDiv `))break;e=e.parentNode}return new N(t,n)},ot=function(){var e=et();return new P(e.y,document.documentElement.clientHeight+e.y,e.x,document.documentElement.clientWidth+e.x)},st=function(){var e=document.documentElement,t=window;return new N(t.pageXOffset||e.scrollLeft,t.pageYOffset||e.scrollTop)},ct=function(e,t){var n=t.x;t=t.y;var r=e.getInjectionDiv().getBoundingClientRect();return n=new N(n-r.left,t-r.top),t=e.getOriginOffsetInPixels(),N.difference(n,t).scale(1/e.scale)},lt=function(e,t){var n=t.scale(e.scale);t=n.x,n=n.y;var r=e.getInjectionDiv().getBoundingClientRect();return e=e.getOriginOffsetInPixels(),new N(t+r.left+e.x,n+r.top+e.y)},e.rc=function(e){return Zs.createElementNS(`https://developers.google.com/blockly/xml`,e)},e.sc=function(e){return Zs.createTextNode(e)},e.uc=function(e){var t=Ys.parseFromString(e,`text/xml`);if(t&&t.documentElement&&!t.getElementsByTagName(`parsererror`).length)return t.documentElement;if((t=Ys.parseFromString(e,`text/html`))&&t.body.firstChild&&t.body.firstChild.nodeName.toLowerCase()===`xml`)return t.body.firstChild;throw Error(`DOMParser was unable to parse: ${e}`)},ut=function(e){return dt(Xs.serializeToString(e))},dt=function(e){return e.replace(ec,e=>`&#${e.charCodeAt(0)};`)},ft=function(e){if(!e)return null;if(e instanceof Element||typeof e==`string`){e=vt(e);var t={contents:gt(e)};e instanceof Node&&_t(e,t),e=t}t=e.kind;var n=e.contents;if(t&&t!==`flyoutToolbox`&&t!==`categoryToolbox`)throw Error(`Invalid toolbox kind `+t+`. Please supply either flyoutToolbox or categoryToolbox`);if(!n)throw Error(`Toolbox must have a contents attribute.`);return e},pt=function(e){return e?e.contents?e.contents:Array.isArray(e)&&e.length>0&&!e[0].nodeType?e:gt(e):[]},mt=function(e){return rc.hasCategoriesInternal(e)},ht=function(e){return e&&e.contents?!!e.contents.filter(function(e){return e.kind.toUpperCase()===`CATEGORY`}).length:!1},gt=function(e){var t=[],n=e.childNodes;n||=e;for(let r=0,i;i=n[r];r++){if(!i.tagName)continue;e={};let n=i.tagName.toUpperCase();e.kind=n,n===`BLOCK`?e.blockxml=i:i.childNodes&&i.childNodes.length>0&&(e.contents=gt(i)),_t(i,e),t.push(e)}return t},_t=function(e,t){for(let n=0;n<e.attributes.length;n++){let r=e.attributes[n];r.nodeName.includes(`css-`)?(t.cssconfig=t.cssconfig||{},t.cssconfig[r.nodeName.replace(`css-`,``)]=r.value):t[r.nodeName]=r.value}},vt=function(t){var n=null;if(t){if(typeof t==`string`){if(n=e.uc(t),n.nodeName.toLowerCase()!==`xml`)throw TypeError(`Toolbox should be an <xml> document.`)}else t instanceof Element&&(n=t)}return n},yt=function(e,t,n,r,i,a){var o=a.scrollbar&&a.scrollbar.canScrollVertically();return e.horizontal===sc.LEFT?(n=i.absoluteMetrics.left+n,o&&a.RTL&&(n+=Js.scrollbarThickness)):(n=i.absoluteMetrics.left+i.viewMetrics.width-t.width-n,o&&!a.RTL&&(n-=Js.scrollbarThickness)),e.vertical===ac.TOP?e=i.absoluteMetrics.top+r:(e=i.absoluteMetrics.top+i.viewMetrics.height-t.height-r,a.scrollbar&&a.scrollbar.canScrollHorizontally()&&(e-=Js.scrollbarThickness)),new P(e,e+t.height,n,n+t.width)},bt=function(e,t){return{horizontal:t.toolboxMetrics.position===I.LEFT||e.horizontalLayout&&!e.RTL?sc.RIGHT:sc.LEFT,vertical:t.toolboxMetrics.position===I.BOTTOM?ac.TOP:ac.BOTTOM}},xt=function(e,t,n,r){var i=e.left,a=e.right-e.left,o=e.bottom-e.top;for(let s=0;s<r.length;s++){let c=r[s];e.intersects(c)&&(e=n===lc.UP?c.top-o-t:c.bottom+t,e=new P(e,e+o,i,i+a),s=-1)}return e},St=function(e,t){y(M.SERIALIZER,e,t)},Ct=function(e,{addCoordinates:t=!1,saveIds:n=!0}={}){var r=e.workspace,i=Object.create(null);return i.height=e.getSize().height,i.width=e.getSize().width,n&&(i.id=e.id),t&&(t=e.getRelativeToSurfaceXY(),i.x=r.RTL?r.getWidth()-t.x:t.x,i.y=t.y),e.getText()&&(i.text=e.getText()),e.isCollapsed()&&(i.collapsed=!0),e.isOwnEditable()||(i.editable=!1),e.isOwnMovable()||(i.movable=!1),e.isOwnDeletable()||(i.deletable=!1),i},wt=function(t,n,{recordUndo:r=!1}={}){var i=e.Qc;if(e.Qc=r,r=n.newComment(t.id),t.text!==void 0&&r.setText(t.text),t.x!==void 0||t.y!==void 0){let e=r.getRelativeToSurfaceXY(),i=t.x??e.x;i=n.RTL?n.getWidth()-i:i;var a;n=(a=t.y)??e.y,r.moveTo(new N(i,n))}return(t.width!==void 0||t.height)&&(a=r.getSize(),r.setSize(new F(t.width??a.width,t.height??a.height))),t.collapsed!==void 0&&r.setCollapsed(t.collapsed),t.editable!==void 0&&r.setEditable(t.editable),t.movable!==void 0&&r.setMovable(t.movable),t.deletable!==void 0&&r.setDeletable(t.deletable),e.Qc=i,r},Tt=function(e,t){y(M.PASTER,e,t)},Et=function(e){for(var t=e.workspace,n=e.getRelativeToSurfaceXY(),r=new N(0,0),i=t.getTopComments(!1).filter(t=>t.id!==e.id).map(e=>e.getRelativeToSurfaceXY());Dt(N.sum(n,r),i);)r.translate(t.RTL?-30:30,30);e.moveTo(N.sum(n,r))},Dt=function(e,t){return t.some(t=>Math.abs(t.x-e.x)<=1&&Math.abs(t.y-e.y)<=1)},Ot=function(e){return e&&typeof e.saveState==`function`&&typeof e.loadState==`function`},kt=function(e){return Mt(e),Po?(Nt(),Promise.resolve()):(Ac||=new Promise(e=>{jc=e,Mc=window.requestAnimationFrame(()=>{Nt(),e()})}),Ac)},At=function(){return Ac||Promise.resolve()},jt=function(e){e||window.cancelAnimationFrame(Mc),Nt(e),!e&&jc&&jc()},Mt=function(t){Oc.add(t),kc.set(t,e.gd);var n=t.getParent();n?Mt(n):Dc.add(t)},Nt=function(t){var n=t?new Set([t]):new Set([...Dc].map(e=>e.workspace)),r=[...Dc].filter(Ft).filter(e=>n.has(e.workspace));for(var i of r)It(i);for(let e of n)e.resizeContents(),e.connectionDBList.forEach(e=>e==null?void 0:e.beginBulkUpdates());for(var a of r)i=a.getRelativeToSurfaceXY(),a.updateComponentLocations(i);for(var o of n)o.connectionDBList.forEach(e=>e==null?void 0:e.endBulkUpdates());for(let t of r)a=e.gd,(o=kc.get(t))&&e.B(o),t.bumpNeighbours(),e.B(a);for(let e of r)Pt(e);t||(Ac=null)},Pt=function(e){Dc.delete(e),Oc.delete(e),kc.delete(e);for(let t of e.getChildren(!1))Pt(t)},Ft=function(e){return!e.isDisposed()&&!e.getParent()},It=function(e){if(Oc.has(e)&&e.initialized){for(let t of e.getChildren(!1))It(t);e.renderEfficiently()}},Lt=function(e,t){Ut(Fc.ALERT,e,t,void 0)},Rt=function(e,t){Ut(Fc.CONFIRM,e,t,void 0)},zt=function(e,t,n){Ut(Fc.PROMPT,e,n,t)},Bt=function(e,t){Rc(e,t)},Vt=function(e,t){zc(e,t)},Ht=function(e,t,n){Bc(e,t,n)},Ut=function(...[t,n,r,i]){var a=document.createElement(`dialog`),o=document.createElement(`form`),s=document.createElement(`label`),c=document.createElement(`input`),l=document.createElement(`div`),u=document.createElement(`button`);a.className=`blocklyDialog`,o.className=`blocklyDialogForm`,s.className=`blocklyDialogPrompt`,l.className=`blocklyDialogButtonRow`,u.className=`blocklyDialogConfirmButton`,o.setAttribute(`method`,`dialog`),s.textContent=n,s.setAttribute(`for`,`blockly-form-input`),u.textContent=e.C.DIALOG_OK,u.value=`ok`,a.appendChild(o),o.appendChild(s),t===Fc.PROMPT&&(c.id=`blockly-form-input`,c.className=`blocklyDialogInput`,c.type=`text`,c.name=`input`,c.autofocus=!0,i&&(c.value=i),o.appendChild(c)),l.appendChild(u),(t===Fc.CONFIRM||t===Fc.PROMPT)&&(n=document.createElement(`button`),n.className=`blocklyDialogCancelButton`,n.textContent=e.C.DIALOG_CANCEL,n.value=`cancel`,l.appendChild(n)),o.appendChild(l);var d;Lc===0&&(d=e.t().ephemeralFocusTaken()?void 0:e.t().takeEphemeralFocus(a)),Lc++,a.addEventListener(`close`,()=>{if(Lc--,!Lc){let e;(e=d)==null||e()}switch(a.remove(),t){case Fc.CONFIRM:r(a.returnValue===`ok`);break;case Fc.PROMPT:r(a.returnValue===`ok`?c.value:null);break;case Fc.ALERT:r==null||r()}}),document.body.appendChild(a),a.showModal()},Wt=function(e){return typeof e.bubbleIsVisible==`function`&&typeof e.setBubbleVisible==`function`&&typeof e.getBubble==`function`},Gt=function(e,t){return t.map(t=>e.getBlockById(t)).filter(e=>e&&e.isShadow()).length===t.length},Kt=function(e){return e&&typeof e.getProcedureDef==`function`},qt=function(e){return e.getVariableModel!==void 0},e.Bd=function(e){e=e.getAllBlocks(!1);var t=new Set;for(let n=0;n<e.length;n++){let r=e[n].getVarModels();if(r)for(let e=0;e<r.length;e++){let n=r[e];n.getId()&&t.add(n)}}return Array.from(t.values())},e.Cd=function(e){e=e.getAllBlocks(!1);var t=new Set;for(let r=0,i;i=e[r];r++){var n=i.getDeveloperVariables;if(n){n=n();for(let e=0;e<n.length;e++)t.add(n[e])}}return Array.from(t.values())},Jt=function(e){return $o.variables_set||$o.variables_get||console.warn(`There are no variable blocks, but there is a variable category.`),e.registerButtonCallback(`CREATE_VARIABLE`,function(e){$t(e.getTargetWorkspace())}),[{kind:`button`,text:`%{BKY_NEW_VARIABLE}`,callbackkey:`CREATE_VARIABLE`},...Xt(e,e.getVariableMap().getVariablesOfType(``),!0)]},Yt=function(e){return{VAR:{name:e.getName(),type:e.getType()}}},Xt=function(e,t,n,r=`variables_get`,i=`variables_set`){n&&=$o.math_change,e=[];var a=t.slice(-1)[0];return a&&($o[i]&&e.push({kind:`block`,type:i,gap:n?8:24,fields:Yt(a)}),n&&e.push({kind:`block`,type:`math_change`,gap:$o[r]?20:8,fields:Yt(a),inputs:{DELTA:{shadow:{type:`math_number`,fields:{NUM:1}}}}})),$o[r]&&e.push(...t.sort(ln).map(e=>({kind:`block`,type:r,gap:8,fields:Yt(e)}))),e},Zt=function(e){return Ql.generateUniqueNameInternal(e)},Qt=function(e,t){if(!t.length)return e;for(var n=``,r=`ijkmnopqrstuvwxyzabcdefgh`.indexOf(e);;){let i=!1;for(let n=0;n<t.length;n++)if(t[n].toLowerCase()===e){i=!0;break}if(!i)break;r++,r===25&&(r=0,n=`${Number(n)+1}`),e=`ijkmnopqrstuvwxyzabcdefgh`.charAt(r)+n}return e},$t=function(t,n,r){function i(r){en(e.C.NEW_VARIABLE_TITLE,r,function(r){if(r){var o=nn(r,t);if(o){if(o.getType()===a)var s=e.C.VARIABLE_ALREADY_EXISTS.replace(`%1`,o.getName());else s=e.C.VARIABLE_ALREADY_EXISTS_FOR_ANOTHER_TYPE,s=s.replace(`%1`,o.getName()).replace(`%2`,o.getType());Bt(s,function(){i(r)})}else{let i=t.getVariableMap().createVariable(r,a);n&&n(r);let o=(s=t.getFlyout())==null?void 0:s.getWorkspace();if(o&&z.getIsActive()){var c=t=>{t.type===e.Od&&(t=t.blockId)&&(t=o.getBlockById(t))&&t.type===`variables_set`&&t.getFieldValue(`VAR`)===i.getId()&&(e.t().focusNode(t),o.removeChangeListener(c))};o.addChangeListener(c)}}}else n&&n(null)})}var a=r||``;i(``)},e.Rd=function(t,n,r){function i(a){var o=e.C.RENAME_VARIABLE_TITLE.replace(`%1`,n.getName());en(o,a,function(a){if(a){var o=tn(a,n.getType(),t),s=rn(n.getName(),a,t);if(o||s){var c=``;o?c=e.C.VARIABLE_ALREADY_EXISTS_FOR_ANOTHER_TYPE.replace(`%1`,o.getName()).replace(`%2`,o.getType()):s&&(c=e.C.VARIABLE_ALREADY_EXISTS_FOR_A_PARAMETER.replace(`%1`,a).replace(`%2`,s)),Bt(c,function(){i(a)})}else t.getVariableMap().renameVariable(n,a),r&&r(a)}else r&&r(null)})}i(``)},en=function(t,n,r){Ht(t,n,function(t){t&&(t=t.replace(/[\s\xa0]+/g,` `).trim(),t===e.C.RENAME_VARIABLE||t===e.C.NEW_VARIABLE)&&(t=null),r(t)})},tn=function(e,t,n){n=n.getVariableMap().getAllVariables(),e=e.toLowerCase();for(let r=0,i;i=n[r];r++)if(i.getName().toLowerCase()===e&&i.getType()!==t)return i;return null},nn=function(e,t){t=t.getVariableMap().getAllVariables(),e=e.toLowerCase();for(let n=0,r;r=t[n];n++)if(r.getName().toLowerCase()===e)return r;return null},rn=function(e,t,n){return n.getProcedureMap().getProcedures().length?an(e,t,n):on(e,t,n)},an=function(e,t,n){e=e.toLowerCase(),t=t.toLowerCase(),n=n.getProcedureMap().getProcedures();for(let i of n){var r=i.getParameters().filter(qt).map(e=>e.getVariableModel().getName());if(r&&(n=r.some(t=>t.toLowerCase()===e),r=r.some(e=>e.toLowerCase()===t),n&&r))return i.getName()}return null},on=function(e,t,n){e=e.toLowerCase(),t=t.toLowerCase(),n=n.getAllBlocks(!1);for(let i of n){if(!Kt(i))continue;n=i.getProcedureDef();var r=n[1];let a=r.some(t=>t.toLowerCase()===e);if(r=r.some(e=>e.toLowerCase()===t),a&&r)return n[0]}return null},sn=function(t){var n=e.rc(`field`);return n.setAttribute(`name`,`VAR`),n.setAttribute(`id`,t.getId()),n.setAttribute(`variabletype`,t.getType()),t=e.sc(t.getName()),n.appendChild(t),n},e.Wd=function(t,n,r,i){var a=e.Vd(t,n,r,i);if(!a){a=t.getVariableMap();let e=t.getPotentialVariableMap();r||=Zt(t.isFlyout?t.targetWorkspace:t),a=e?e.createVariable(r,i,n??void 0):a.createVariable(r,i,n)}return a},e.Vd=function(e,t,n,r){var i=e.getPotentialVariableMap(),a=null;if(t&&(a=e.getVariableMap().getVariableById(t),!a&&i&&(a=i.getVariableById(t)),a))return a;if(n){if(r===void 0)throw Error(`Tried to look up a variable by name without a type`);a=e.getVariableMap().getVariable(n,r),!a&&i&&(a=i.getVariable(n,r))}return a},cn=function(e,t){e=e.getVariableMap().getAllVariables();var n=[];if(t.length!==e.length)for(let r=0;r<e.length;r++){let i=e[r];t.includes(i)||n.push(i)}return n},ln=function(e,t){return Zl.compare(e.getName(),t.getName())},un=function(e,t){var n=[];e=e.getAllBlocks(!1);for(let r=0;r<e.length;r++){let i=e[r].getVarModels();if(i)for(let a=0;a<i.length;a++)i[a].getId()===t&&n.push(e[r])}return n},e.$d=function(t,n,r){var i=n.getName(),a=un(t,n.getId());for(let t=a.length-1;t>=0;t--){let n=a[t];if(n.type===`procedures_defnoreturn`||n.type===`procedures_defreturn`){r=String(n.getFieldValue(`NAME`)),i=e.C.CANNOT_DELETE_VARIABLE_PROCEDURE.replace(`%1`,i).replace(`%2`,r),Rc(i,void 0);return}n===r&&a.splice(t,1)}r&&a.length||a.length>1?(i=e.C.DELETE_VARIABLE_CONFIRMATION.replace(`%1`,String(a.length+(r&&!r.workspace.isFlyout?1:0))).replace(`%2`,i),Vt(i,e=>{e&&n&&t.getVariableMap().deleteVariable(n)})):t.getVariableMap().deleteVariable(n)},dn=function(e,{addCoordinates:t=!1,addInputBlocks:n=!0,addNextBlocks:r=!0,doFullSerialization:i=!0,saveIds:a=!0}={}){if(e.isInsertionMarker())return null;var o={type:e.type,id:a?e.id:void 0};if(t){t=e.workspace;var s=e.getRelativeToSurfaceXY();o.x=Math.round(t.RTL?t.getWidth()-s.x:s.x),o.y=Math.round(s.y)}e.isCollapsed()&&(o.collapsed=!0),e.isEnabled()||(o.disabledReasons=Array.from(e.getDisabledReasons())),e.isOwnDeletable()||(o.deletable=!1),e.isOwnMovable()||(o.movable=!1),e.isOwnEditable()||(o.editable=!1),e.inputsInline!==void 0&&e.inputsInline!==e.inputsInlineDefault&&(o.inline=e.inputsInline),e.data&&(o.data=e.data),e.saveExtraState?(t=e.saveExtraState(i),t!==null&&(o.extraState=t)):e.mutationToDom&&(t=e.mutationToDom(),t!==null&&(o.extraState=ti(t).replace(` xmlns="https://developers.google.com/blockly/xml"`,``))),t=Object.create(null);for(var c of e.getIcons())Ot(c)&&(s=c.saveState(i))&&(t[c.getType().toString()]=s);Object.keys(t).length&&(o.icons=t),c=Object.create(null);for(var l of e.getFields())l.isSerializable()&&(c[l.name]=l.saveState(i));if(Object.keys(c).length&&(o.fields=c),n){for(n=Object.create(null),l=0;l<e.inputList.length;l++)c=e.inputList[l],c.connection&&(t=fn(c.connection,i,a))&&(n[c.name]=t);Object.keys(n).length&&(o.inputs=n)}return r&&e.nextConnection&&(e=fn(e.nextConnection,i,a))&&(o.next=e),o},fn=function(e,t,n){var r=e.getShadowState(!0);if(e=e.targetBlock(),!r&&!e)return null;var i=Object.create(null);return r&&(i.shadow=r),e&&!e.isShadow()&&(i.block=dn(e,{doFullSerialization:t,saveIds:n})),i},pn=function(e,t,{recordUndo:n=!1}={}){return e=mn(e,t,{recordUndo:n}),t.rendered&&jt(),e},mn=function(t,n,{parentConnection:r,isShadow:i=!1,recordUndo:a=!1}={}){var o=e.Qc;e.Qc=a,(a=e.gd)||e.B(!0),e.Ub++;var s=n.getVariableMap().getAllVariables();try{var c=hn(t,n,{parentConnection:r,isShadow:i})}finally{e.Ub--}if(gn(n,s),Je()&&b(new(x(E.BLOCK_CREATE))(c)),e.B(a),e.Qc=o,n.rendered){let e=c;setTimeout(()=>{e.disposed||e.setConnectionTracking(!0)},1)}return c},hn=function(t,n,{parentConnection:r,isShadow:i=!1}={}){if(!t.type)throw new tu(t);var a=n.newBlock(t.type,t.id);a.setShadow(i),i=t.x===void 0?0:t.x;var o=t.y===void 0?0:t.y,s=a.workspace;if(i=s.RTL?s.getWidth()-i:i,a.moveBy(i,o),t.collapsed&&a.setCollapsed(!0),t.deletable===!1&&a.setDeletable(!1),t.movable===!1&&a.setMovable(!1),t.editable===!1&&a.setEditable(!1),t.enabled===!1&&a.setDisabledReason(!0,`MANUALLY_DISABLED`),Array.isArray(t.disabledReasons))for(var c of t.disabledReasons)a.setDisabledReason(!0,c);if(t.inline!==void 0&&a.setInputsInline(t.inline),t.data!==void 0&&(a.data=t.data),t.extraState&&(a.loadExtraState?a.loadExtraState(t.extraState):a.domToMutation&&a.domToMutation(e.uc(t.extraState))),r){if(r.getSourceBlock().isShadow()&&!a.isShadow())throw new iu(t);if(r.type===e.je.VALUE){if(c=a.outputConnection,!c)throw new nu(`output`,a,t)}else if(c=a.previousConnection,!c)throw new nu(`previous`,a,t);if(!r.connect(c))throw n=a.workspace.connectionChecker,new ru(n.getErrorMessage(n.canConnectWithReason(c,r,!1),c,r),r.type===e.je.VALUE?`output connection`:`previous connection`,a,t)}if(t.icons){r=Object.keys(t.icons);for(var l of r){if(r=t.icons[l],c=a.getIcon(l),!c){if(c=Le(M.ICON,l,!1),!c)throw new au(l,a,t);c=new c(a),a.addIcon(c)}Ot(c)&&c.loadState(r)}}if(t.fields)for(l=Object.keys(t.fields),r=0;r<l.length;r++)c=l[r],i=t.fields[c],(o=a.getField(c))?o.loadState(i):console.warn(`Ignoring non-existant field ${c} in block ${a.type}`);if(t.inputs)for(l=Object.keys(t.inputs),r=0;r<l.length;r++){if(c=l[r],i=a.getInput(c),!i||!i.connection)throw new nu(c,a,t);_n(i.connection,t.inputs[c])}if(t.next){if(!a.nextConnection)throw new nu(`next`,a,t);_n(a.nextConnection,t.next)}if(n.rendered){a.setConnectionTracking(!1),a.initSvg(),a.queueRender();for(let e of a.getIcons())e.onLocationChange(a.getRelativeToSurfaceXY())}else a.initModel();return a},gn=function(e,t){if(Je())for(e=cn(e,t),t=0;t<e.length;t++){let n=e[t];b(new(x(E.VAR_CREATE))(n))}},_n=function(e,t){t.shadow&&e.setShadowState(t.shadow),t.block&&hn(t.block,e.getSourceBlock().workspace,{parentConnection:e})},vn=function(e){return e=yn(e,lu),e.length?e[0].join(Vo?` `:` + `):``},yn=function(t,n){if(t=j.registry.getKeyCodesByShortcutName(t),t.length===0)return[];t=t.map(e=>e.split(`+`)),t.forEach(e=>e.sort((e,t)=>(e=bn(e),t=bn(t),e-t))),t.sort((e,t)=>(e=+!!e.includes(`Meta`),+!!t.includes(`Meta`)-e));var r=t.filter(e=>e.includes(`Meta`)===Vo);return r=r.length===0?t:r,r.sort((e,t)=>e.length-t.length),(r.some(e=>e.some(e=>e===`Meta`||e===`Alt`||e===`Control`))?[r[0]]:r).map(t=>t.map(t=>{if(Number.isFinite(+t)){if(t=+t,t>=65&&t<=90)t=String.fromCharCode(t);else{var n={8:e.C.BACKSPACE_KEY,9:e.C.TAB_KEY,13:e.C.ENTER_KEY,16:e.C.SHIFT_KEY,17:e.C.CONTROL_KEY,18:e.C.ALT_KEY,19:e.C.PAUSE_KEY,20:e.C.CAPS_LOCK_KEY,27:e.C.ESCAPE,32:e.C.SPACE_KEY,33:e.C.PAGE_UP_KEY,34:e.C.PAGE_DOWN_KEY,35:e.C.END_KEY,36:e.C.HOME_KEY,37:`←`,38:`↑`,39:`→`,40:`↓`,45:e.C.INSERT_KEY,46:e.C.DELETE_KEY,48:`0`,49:`1`,50:`2`,51:`3`,52:`4`,53:`5`,54:`6`,55:`7`,56:`8`,57:`9`,59:`;`,61:`=`,93:e.C.CONTEXT_MENU_KEY,96:`0`,97:`1`,98:`2`,99:`3`,100:`4`,101:`5`,102:`6`,103:`7`,104:`8`,105:`9`,106:`×`,107:`+`,109:`−`,110:`.`,111:`÷`,112:`F1`,113:`F2`,114:`F3`,115:`F4`,116:`F5`,117:`F6`,118:`F7`,119:`F8`,120:`F9`,121:`F10`,122:`F11`,123:`F12`,186:`;`,187:`=`,189:`-`,188:`,`,190:`.`,191:`/`,192:"`",219:`[`,220:`\\`,221:`]`,222:`'`,224:`⌘`}[t];n?t=n:(console.warn(`Unknown key code: `+t),t=String.fromCharCode(t))}}return t}).map(e=>{var t=n[e]??e;return t.charAt(0).toUpperCase()+t.substring(1)}))},bn=function(e){return e=uu.indexOf(e),e===-1?Number.MAX_VALUE:e},xn=function(e){return e&&typeof e.init==`function`&&typeof e.getDiv==`function`&&typeof e.getId==`function`&&typeof e.getParent==`function`&&typeof e.getLevel==`function`&&typeof e.isSelectable==`function`&&typeof e.isCollapsible==`function`&&typeof e.dispose==`function`&&typeof e.getClickTarget==`function`&&typeof e.setVisible_==`function`&&typeof e.getParentToolbox==`function`},Sn=function(e){return typeof e.getName==`function`&&typeof e.getContents==`function`&&typeof e.setSelected==`function`&&typeof e.onClick==`function`&&xn(e)&&e.isSelectable()},Cn=function(t,n=ss.STANDARD,r){return[n>=ss.STANDARD&&En(t),Tn(t),...Dn(t,n,r),n===ss.LOQUACIOUS&&Mn(t),n>=ss.STANDARD&&(t.isEnabled()?void 0:e.C.BLOCK_LABEL_DISABLED),n>=ss.STANDARD&&(t.isCollapsed()?e.C.BLOCK_LABEL_COLLAPSED:void 0),n>=ss.LOQUACIOUS&&(t.isShadow()?e.C.BLOCK_LABEL_REPLACEABLE:void 0),n>=ss.STANDARD&&Ln(t),n>=ss.LOQUACIOUS&&t.getAriaRoleDescription()].filter(e=>!!e).join(`, `)},wn=function(t,n,r=ss.STANDARD){var i=r>=ss.LOQUACIOUS,a=[],o=t.fieldRow.filter(e=>e.isVisible()).flatMap((e,t,n)=>{if(e.isLabelField()){if(t<n.length-1&&n[t+1].isLabelField())return a.push(e.computeAriaLabel(i)),[];if(a.length>=1)return a.push(e.computeAriaLabel(i)),e=a.join(` `),a=[],e}return e.computeAriaLabel(i)});if(!o.length&&n){let e=t.getSourceBlock().inputList,i=e.indexOf(t);if(i>0)return wn(e[i-1],n,r)}var s;return t.type===e.je.VALUE&&((s=t.connection)==null?void 0:s.targetConnection)===null&&r>=ss.STANDARD&&o.push(e.C.INPUT_LABEL_EMPTY),o.filter(e=>!!e)},Tn=function(t){var n,r,i=(n=t.outputConnection??t.previousConnection)==null||(r=n.targetConnection)==null?void 0:r.getParentInput();if(i&&(t=i.getSourceBlock(),!t.isInsertionMarker())){if(n=i.getAriaLabelText())t=n;else{if(!t.statementInputCount||(n=t.inputList.find(t=>t.type===e.je.STATEMENT),i===n)||(t=An(t,i,!1),!t.length))return;t=t.join(`, `)}return i.type===e.je.STATEMENT?(i=Array.isArray(t)?t.join(` `):t,e.C.BLOCK_LABEL_BEGIN_PREFIX.replace(`%1`,i)):t}},En=function(t){if(!t.isInFlyout&&!t.isDragging())return t.getRootBlock()===t?e.C.BLOCK_LABEL_BEGIN_STACK:void 0},Dn=function(t,n=ss.STANDARD,r){if(r)return[r];if(r=t=t.inputList.filter(e=>e.isVisible()),n<=ss.STANDARD){let n=t.filter(t=>t.type===e.je.STATEMENT);n.length>1&&(r=t.slice(0,t.indexOf(n[0])+1))}var i=[];return r.flatMap((t,r,a)=>{var o=t.getLabel(n),s;if(s=r<a.length-1&&kn(t)&&On(a[r+1])){s=a[r+1];let n;r=((n=t.connection)==null?void 0:n.type)===L.NEXT_STATEMENT||t.type===e.je.END_ROW;let i;s=!(!t.getSourceBlock().getInputsInline()||((i=s.connection)==null?void 0:i.type)===L.NEXT_STATEMENT||r)}return s?(i.push(o),[]):On(t)&&i.length>0?(i.push(o),t=i.join(` `),i=[],t):o})},On=function(e){return e=e.fieldRow.filter(e=>e.isVisible()),e.length>0&&e[0].isLabelField()},kn=function(t){return t.type===e.je.VALUE||t.type===e.je.STATEMENT?!1:(t=t.fieldRow.filter(e=>e.isVisible()),t.length>0&&t[t.length-1].isLabelField())},An=function(t,n,r){var i=t.inputList.indexOf(n);if(i===-1)throw Error(`Input with name "${n.name}" not found on block with id "${t.id}".`);var a=n.type===e.je.STATEMENT,o=a?jn(t.inputList,i):i,s=t.inputList.slice(o,i+1).filter(e=>e.isVisible()),c=s.map(e=>e.getLabel(ss.TERSE,e!==n||r)),l=a&&c.slice(0,-1).some(e=>!!e);return c.map((t,n)=>{if(t)return t;if(t=s[n],!(t.type===e.je.DUMMY||t.type===e.je.END_ROW||a&&n===c.length-1&&l))return e.C.INPUT_LABEL_INDEX.replace(`%1`,(t.getIndex()+1).toString())}).filter(e=>e!==void 0)},jn=function(t,n){for(--n;n>=0;n--)if(t[n].type===e.je.STATEMENT)return n+1;return 0},Mn=function(t){var n=t.workspace.getToolbox();if(n){var r=void 0;for(let e of n.getToolboxItems())if(Sn(e)){if(n=e.getContents(),Array.isArray(n)&&n.some(e=>e.kind.toLowerCase()===`block`&&`type`in e&&e.type===t.type)){r=e;break}`getColour`in e&&typeof e.getColour==`function`&&e.getColour()===t.getColour()&&(r=e)}if(r)return e.C.BLOCK_LABEL_TOOLBOX_CATEGORY.replace(`%1`,r.getName())}},Nn=function(t){switch(t){case du.BEFORE:return e.C.ANNOUNCE_MOVE_BEFORE;case du.AFTER:return e.C.ANNOUNCE_MOVE_AFTER;case du.INSIDE:return e.C.ANNOUNCE_MOVE_INSIDE;case du.AROUND:return e.C.ANNOUNCE_MOVE_AROUND;default:return e.C.ANNOUNCE_MOVE_TO}},Pn=function(t,n){var r=t.getParentInput();if(!r)return n;var i=r.getAriaLabelText();if(!i){if(t=An(t.getSourceBlock(),r,!0),!t.length)return n;i=t.join(`, `)}return n?e.C.ANNOUNCE_MOVE_OF.replace(`%1`,i).replace(`%2`,n):i},Fn=function(e,t,n,r=!1){var i=In(e,t),a=Nn(i),o=![du.BEFORE,du.AFTER].includes(i);return i=o&&n(!0),n=o&&n(!1),r=r?e.getSourceBlock().getStackBlocksCountLabel():``,o=t.getSourceBlock().getAriaLabel(ss.TERSE),i&&(r=Pn(e,r)),n&&(o=Pn(t,o)),a.replace(`%1`,r).replace(`%2`,o)},In=function(e,t){switch(e.type){case L.INPUT_VALUE:case L.OUTPUT_VALUE:return du.TO;case L.NEXT_STATEMENT:return e===e.getSourceBlock().nextConnection?du.BEFORE:du.AROUND;case L.PREVIOUS_STATEMENT:return t===t.getSourceBlock().nextConnection?du.AFTER:du.INSIDE}return du.UNKNOWN},Ln=function(t){var n=t.inputList.filter(t=>t.type===e.je.STATEMENT).length;if(n>1)return e.C.BLOCK_LABEL_HAS_BRANCHES.replace(`%1`,n.toString());switch(t.inputList.reduce((e,t)=>{var n;return t.fieldRow.reduce((e,t)=>t.EDITABLE&&!t.isFullBlockField()?++e:e,e)+ +(((n=t.connection)==null?void 0:n.type)===L.INPUT_VALUE)},0)){case 0:break;case 1:return e.C.BLOCK_LABEL_HAS_INPUT;default:return e.C.BLOCK_LABEL_HAS_INPUTS}},Rn=function(e){return e*Math.PI/180},zn=function(e,t,n){if(n<e){let t=n;n=e,e=t}return Math.max(e,Math.min(t,n))},Bn=function(){document.querySelector(`.blocklyDropDownDiv`)||(B=document.createElement(`div`),B.className=`blocklyDropDownDiv`,B.tabIndex=-1,B.id=He(),(ke()||document.body).appendChild(B),vu=document.createElement(`div`),vu.className=`blocklyDropDownContent`,B.appendChild(vu),wu=o(vu,`keydown`,null,Fe),yu=document.createElement(`div`),yu.className=`blocklyDropDownArrow`,B.appendChild(yu),B.style.opacity=`0`,B.style.transition=`transform 0.25s, opacity 0.25s`)},Vn=function(){Cu&&=(Cu(!1),null),$n()},Hn=function(){wu&&=(c(wu),null),B.remove(),Bn()},Un=function(e,t){B.style.backgroundColor=e,B.style.borderColor=t},Wn=function(e,t,n,r=!0){return Su=!0,qn(Kn(e),e,r,t,n)},Gn=function(e){var t=e.getSvgRoot(),n=e.workspace.scale,r=e.height*n;return e=e.width*n,t=$e(t),new P(t.y,t.y+r,t.x,t.x+e)},Kn=function(e){return e=e.getScaledBBox(),new P(e.top,e.bottom,e.left,e.right)},qn=function(e,t,n,r,i){var a=e.left+(e.right-e.left)/2,o=e.bottom;e=e.top,i&&(e+=i),i=t.getSourceBlock();for(var s=i.workspace;s.options.parentWorkspace;)s=s.options.parentWorkspace;return bu=s.getParentSvg().parentNode,Jn(t,i.RTL,a,o,a,e,n,r)},Jn=function(t,n,r,i,a,o,s,c){e.t().registerPopoverFocusLossHandler(Vn);var l;return(l=ke())==null||l.appendChild(B),xu=t,hu=c||null,B.style.direction=n?`rtl`:`ltr`,t=Os,gu=t.getRenderer().getClassName(),_u=t.getTheme().getClassName(),g(B,gu),g(B,_u),n=ae(t.getFocusableElement(),k.OWNS),m(t.getFocusableElement(),k.OWNS,n?[n,B.id]:B.id),t.getFocusableElement().classList.add(`blocklyShowingDropDownDiv`),r=tr(r,i,a,o),s&&(Cu=e.t().takeEphemeralFocus(B)),r},Yn=function(e,t,n,r){return e=Zn(e,n.left,n.right,r.width),{initialX:e.divX,initialY:t,finalX:e.divX,finalY:t+16,arrowX:e.arrowX,arrowY:-9,arrowAtTop:!0,arrowVisible:!0}},Xn=function(e,t,n,r){return e=Zn(e,n.left,n.right,r.width),{initialX:e.divX,initialY:t-r.height,finalX:e.divX,finalY:t-r.height-16,arrowX:e.arrowX,arrowY:r.height-2-8,arrowAtTop:!1,arrowVisible:!0}},Zn=function(e,t,n,r){return t=zn(t,e-r/2,n-r),e=e-8-t,e=zn(12,e,r-12-16),{arrowX:e,divX:t}},Qn=function(e,t){return xu===e&&(t?er():$n(),!0)},$n=function(){xu&&(e.t().unregisterPopoverFocusLossHandler(Vn),B.style.transform=`translate(0, 0)`,B.style.opacity=`0`,mu=setTimeout(function(){er()},250),hu&&=(hu(),null))},er=function(){if(xu){mu&&clearTimeout(mu),hu&&=(hu(),null),xu=null;var e=Os,t=ae(e.getFocusableElement(),k.OWNS)??``;m(e.getFocusableElement(),k.OWNS,t.replace(B.id,``)),e.getFocusableElement().classList.remove(`blocklyShowingDropDownDiv`),e.markFocused(),Cu&&=(Cu(),null),Hn()}},tr=function(e,t,n,r){e=Tu.getPositionMetrics(e,t,n,r),e.arrowVisible?(t=e.arrowX,n=e.arrowY,r=e.arrowAtTop?45:225,yu.style.display=``,yu.style.transform=`translate(${t}px, ${n}px) rotate(${r}deg)`,yu.setAttribute(`class`,`blocklyDropDownArrow`)):yu.style.display=`none`,t=Math.floor(e.initialX),n=Math.floor(e.initialY),r=Math.floor(e.finalX);var i=Math.floor(e.finalY),a=B.parentElement;return a&&(a=a.getBoundingClientRect(),t-=a.left+window.scrollX,r-=a.left+window.scrollX,n-=a.top+window.scrollY,i-=a.top+window.scrollY),B.style.left=t+`px`,B.style.top=n+`px`,B.style.visibility=`visible`,B.style.opacity=`1`,B.style.transform=`translate(`+(r-t)+`px,`+(i-n)+`px)`,!!e.arrowAtTop},nr=function(){if(xu){var e=xu.getSourceBlock();e=Su?Kn(xu):Gn(e);let t=e.left+(e.right-e.left)/2;tr(t,e.bottom,t,e.top)}else $n()},rr=function(e){return e.length?e.reduce(function(e,t){return e.length<t.length?e:t}).length:0},ir=function(e,t){if(!e.length)return 0;if(e.length===1)return e[0].length;var n=0;t||=rr(e);for(var r=0;r<t;r++){for(var i=e[0][r],a=1;a<e.length;a++)if(i!==e[a][r])return n;i===` `&&(n=r+1)}for(i=1;i<e.length;i++)if((a=e[i][r])&&a!==` `)return n;return t},ar=function(e,t){if(!e.length)return 0;if(e.length===1)return e[0].length;var n=0;t||=rr(e);for(var r=0;r<t;r++){for(var i=e[0].substr(-r-1,1),a=1;a<e.length;a++)if(i!==e[a].substr(-r-1,1))return n;i===` `&&(n=r+1)}for(i=1;i<e.length;i++)if((a=e[i].charAt(e[i].length-r-1))&&a!==` `)return n;return t},e.yf=function(e,t){e=e.split(`
7
7
  `);for(let l=0;l<e.length;l++){var n=l;a:{var r=void 0;let n;var i=e[l],a=t;if(i.length<=a){a=i;break a}let u=i.trim().split(/\s+/);for(r=0;r<u.length;r++)u[r].length>a&&(a=u[r].length);var o=-1/0;let d=1;do{n=o,r=i;var s=[];o=u.length/d,i=1;for(var c=0;c<u.length-1;c++)i<(c+1.5)/o?(i++,s[c]=!0):s[c]=!1;s=sr(u,s,a),o=or(u,s,a),i=u,c=[];for(let e=0;e<i.length;e++)c.push(i[e]),s[e]!==void 0&&c.push(s[e]?`
8
8
  `:` `);i=c.join(``),d++}while(o>n);a=r}e[n]=a}return e.join(`
9
9
  `)},or=function(e,t,n){for(var r=[0],i=[],a=0;a<e.length;a++)r[r.length-1]+=e[a].length,t[a]===!0?(r.push(0),i.push(e[a].charAt(e[a].length-1))):t[a]===!1&&r[r.length-1]++;for(e=Math.max(...r),t=0,a=0;a<r.length;a++)t-=Math.abs(n-r[a])**1.5*2,t-=(e-r[a])**1.5,`.?!`.includes(i[a])?t+=n/3:`,;)]}`.includes(i[a])&&(t+=n/4);return r.length>1&&r[r.length-1]<=r[r.length-2]&&(t+=.5),t},sr=function(e,t,n){var r=or(e,t,n);for(let a=0;a<t.length-1;a++){if(t[a]===t[a+1])continue;let o=[].concat(t);o[a]=!o[a],o[a+1]=!o[a+1];let s=or(e,o,n);if(s>r){r=s;var i=o}}return i?sr(e,i,n):t},e.zf=function(e){return/^\s*-?\d+(\.\d+)?\s*$/.test(e)},cr=function(e){if(e=lr(e)){for(e=e.tooltip;typeof e==`function`;)e=e();if(typeof e!=`string`)throw Error(`Tooltip function must return a string.`);return e}return``},lr=function(e){for(;e&&e.tooltip;){if(typeof e.tooltip==`string`||typeof e.tooltip==`function`)return e;e=e.tooltip}return null},ur=function(){document.querySelector(`.blocklyTooltipDiv`)||(Lu=document.createElement(`div`),Lu.className=`blocklyTooltipDiv`,(ke()||document.body).appendChild(Lu))},dr=function(e){e.mouseOverWrapper_=s(e,`pointerover`,null,pr),e.mouseOutWrapper_=s(e,`pointerout`,null,mr),e.addEventListener(`pointermove`,hr,!1)},fr=function(e){e&&(c(e.mouseOverWrapper_),c(e.mouseOutWrapper_),e.removeEventListener(`pointermove`,hr))},pr=function(e){Au||(e=lr(e.currentTarget),Fu!==e&&(_r(),Iu=null,Fu=e),clearTimeout(ju))},mr=function(){Au||(ju=setTimeout(function(){Iu=Fu=null,_r()},1),clearTimeout(Mu),Mu=0)},hr=function(e){if(Fu&&Fu.tooltip&&!Au){if(ku){let t=Nu-e.pageX;e=Pu-e.pageY,Math.sqrt(t*t+e*e)>10&&_r()}else Iu!==Fu&&(clearTimeout(Mu),Nu=e.pageX,Pu=e.pageY,Mu=setTimeout(()=>{if(this instanceof Element)for(let t of Se()){if(!t.rendered)continue;let n;if((n=t.getInjectionDiv())!=null&&n.contains(this)){var e=t;break}}br(e)},750))}},gr=function(){Iu=Fu=null,_r()},_r=function(){ku&&(ku=!1,Lu&&(Lu.style.display=`none`)),Mu&&=(clearTimeout(Mu),0)},vr=function(e,t){Fu!==e&&(_r(),Iu=null,Fu=e),Fu&&Fu.tooltip&&!Au&&(e=e.getFocusableElement().getBoundingClientRect(),Nu=Fu.RTL?e.x+e.width:e.x,Pu=e.y+e.height,br(t))},yr=function(){_r(),Au=!0},br=function(t){if(!Au&&(Iu=Fu,Lu)){var n;if((n=ke(t))==null||n.appendChild(Lu),Lu.textContent=``,Lu&&Fu){if(typeof Ou==`function`)Ou(Lu,Fu);else for(t=cr(Fu),t=e.yf(t,50),t=t.split(`
@@ -1 +1 @@
1
- import{i as e,o as t,r as n,t as r}from"./blockly-DBw-ytY1.js";import{c as i,l as a}from"./index-BnLv569U.js";import{c as o,d as s,i as c,p as l,r as u,s as d}from"./helpers-BFQD9R82.js";function f(){let f=window.Blockly,p=f.Translate,m=window.getHelp;f.CustomBlocks=f.CustomBlocks||[],f.CustomBlocks.push(`Action`),f.Action={HUE:330,blocks:{}};let h=()=>new n(`FALSE`,function(e){this.getSourceBlock().updateShape_(u(e))}),g=()=>[[p(`http_timeout_ms`),`ms`],[p(`http_timeout_sec`),`sec`]],_=()=>[[p(`http_type_text`),`text`],[p(`http_type_arraybuffer`),`arraybuffer`]],v=()=>[[p(`http_content_type_default`),`default`],[`application/json`,`application/json`],[`application/x-www-form-urlencoded`,`application/x-www-form-urlencoded`],[`text/plain`,`text/plain`],[`text/xml`,`text/xml`],[`application/xml`,`application/xml`],[p(`http_content_type_custom`),`custom`]],y={mutationToDom:function(){let e=document.createElement(`mutation`);return e.setAttribute(`with_statement`,String(u(this.getFieldValue(`WITH_STATEMENT`)))),e},domToMutation:function(e){this.updateShape_(u(e.getAttribute(`with_statement`)))},updateShape_:function(e){s(this,e)}},b=(t,n,o,s,c,u)=>{r[t]={init:function(){this.appendDummyInput().appendField(n),this.appendDummyInput(`ATTR`).appendField(new e(o),`ATTR`),this.setInputsInline(!0),this.setOutput(!0),this.setColour(f.Action.HUE),this.setTooltip(p(`${t}_tooltip`)),u&&this.setHelpUrl(m(u))},onchange:function(){l(this,s,c)},FUNCTION_TYPES:s},a.forBlock[t]=function(e){return[e.getFieldValue(`ATTR`),i.ATOMIC]}};f.Action.blocks.exec=`<block type="exec"> <mutation with_statement="false"></mutation> <field name="WITH_STATEMENT">FALSE</field> <field name="LOG"></field> <value name="COMMAND"> <shadow type="text"> <field name="TEXT">pwd</field> </shadow> </value></block>`,r.exec={init:function(){this.appendDummyInput(`TEXT`).appendField(`» ${p(`exec`)}`),this.appendValueInput(`COMMAND`).appendField(p(`exec_command`)),this.appendDummyInput(`WITH_STATEMENT`).appendField(p(`with_results`)).appendField(h(),`WITH_STATEMENT`),this.appendDummyInput(`LOG`).appendField(p(`loglevel`)).appendField(new e(c()),`LOG`),this.setInputsInline(!1),this.setPreviousStatement(!0,null),this.setNextStatement(!0,null),this.setColour(f.Action.HUE),this.setTooltip(p(`exec_tooltip`)),this.setHelpUrl(m(`exec_help`))},...y},a.forBlock.exec=function(e){let t=a.valueToCode(e,`COMMAND`,i.ATOMIC),n=e.getFieldValue(`LOG`),r=``;if(n&&(r=`console.${n}('exec: ' + ${t});\n`),u(e.getFieldValue(`WITH_STATEMENT`))){let n=a.statementToCode(e,`STATEMENT`);if(n)return`exec(${t}, async (error, result, stderr) => {\n${n}});\n${r}`}return`exec(${t});\n${r}`},f.Action.blocks.exec_result=`<sep gap="5"></sep><block type="exec_result"> <field name="ATTR">result</field></block>`,b(`exec_result`,`»`,[[p(`exec_result_result`),`result`],[p(`exec_result_stderr`),`stderr`],[p(`exec_result_error`),`error`]],[`exec`],`exec_result_warning`,`exec_help`),f.Action.blocks.http_get=`<block type="http_get"> <field name="TIMEOUT">2000</field> <field name="UNIT">ms</field> <field name="TYPE">text</field> <value name="URL"> <shadow type="text"> <field name="TEXT">http://</field> </shadow> </value></block>`,r.http_get={init:function(){this.appendValueInput(`URL`).appendField(`🌐 ${p(`http_get`)}`),this.appendDummyInput().appendField(p(`http_timeout`)).appendField(new t(`2000`),`TIMEOUT`).appendField(new e(g()),`UNIT`),this.appendDummyInput(`TYPE`).appendField(p(`http_type`)).appendField(new e(_()),`TYPE`),this.appendStatementInput(`STATEMENT`).setCheck(null),this.setInputsInline(!1),this.setPreviousStatement(!0,null),this.setNextStatement(!0,null),this.setColour(f.Action.HUE),this.setTooltip(p(`http_get_tooltip`)),this.setHelpUrl(m(`http_get_help`))}},a.forBlock.http_get=function(e){let t=a.valueToCode(e,`URL`,i.ATOMIC),n=e.getFieldValue(`UNIT`),r=e.getFieldValue(`TIMEOUT`);Number.isNaN(r)&&(r=2e3),n===`sec`&&(r*=1e3);let o=e.getFieldValue(`TYPE`)||`text`,s=a.statementToCode(e,`STATEMENT`);return`httpGet(${t}, { timeout: ${r}, responseType: '${o}' }, async (err, response) => {\n${s}});\n`},f.Action.blocks.http_post=`<sep gap="5"></sep><block type="http_post"> <field name="TIMEOUT">2000</field> <field name="UNIT">ms</field> <field name="TYPE">text</field> <field name="CONTENT_TYPE">default</field> <value name="URL"> <shadow type="text"> <field name="TEXT">http://</field> </shadow> </value> <value name="DATA"> <shadow type="logic_null"></shadow> </value></block>`,r.http_post={init:function(){this.appendValueInput(`URL`).appendField(`🌐 ${p(`http_post`)}`),this.appendDummyInput().appendField(p(`http_timeout`)).appendField(new t(`2000`),`TIMEOUT`).appendField(new e(g()),`UNIT`),this.appendDummyInput(`TYPE`).appendField(p(`http_type`)).appendField(new e(_()),`TYPE`),this.appendDummyInput(`CONTENT_TYPE`).appendField(p(`http_content_type`)).appendField(new e(v(),function(e){this.getSourceBlock().updateContentTypeShape_(e===`custom`)}),`CONTENT_TYPE`),this.appendValueInput(`DATA`).appendField(p(`http_post_data`)),this.appendStatementInput(`STATEMENT`).setCheck(null),this.setInputsInline(!1),this.setPreviousStatement(!0,null),this.setNextStatement(!0,null),this.setColour(f.Action.HUE),this.setTooltip(p(`http_post_tooltip`)),this.setHelpUrl(m(`http_post_help`))},mutationToDom:function(){let e=document.createElement(`mutation`);return e.setAttribute(`custom_content_type`,String(this.getFieldValue(`CONTENT_TYPE`)===`custom`)),e},domToMutation:function(e){this.updateContentTypeShape_(u(e.getAttribute(`custom_content_type`)))},updateContentTypeShape_:function(e){e?this.getInput(`CONTENT_TYPE_CUSTOM`)||(this.appendDummyInput(`CONTENT_TYPE_CUSTOM`).appendField(` `).appendField(new t(`application/json`),`CONTENT_TYPE_CUSTOM`),this.moveInputBefore(`CONTENT_TYPE_CUSTOM`,`DATA`)):this.getInput(`CONTENT_TYPE_CUSTOM`)&&this.removeInput(`CONTENT_TYPE_CUSTOM`)}},a.forBlock.http_post=function(e){let t=a.valueToCode(e,`URL`,i.ATOMIC),n=e.getFieldValue(`UNIT`),r=e.getFieldValue(`TIMEOUT`);isNaN(r)&&(r=2e3),n===`sec`&&(r*=1e3);let s=e.getFieldValue(`TYPE`)||`text`,c=a.valueToCode(e,`DATA`,i.ATOMIC)||`null`,l=a.statementToCode(e,`STATEMENT`),u=e.getFieldValue(`CONTENT_TYPE`)||`default`,d=u===`custom`?(e.getFieldValue(`CONTENT_TYPE_CUSTOM`)||``).trim():u,f=d&&d!=="default"?`, headers: { 'Content-Type': ${o(d)} }`:``;return`httpPost(${t}, ${c}, { timeout: ${r}, responseType: '${s}'${f} }, async (err, response) => {\n${l}});\n`},f.Action.blocks.http_response=`<sep gap="5"></sep><block type="http_response"> <field name="ATTR">response.data</field></block>`,b(`http_response`,`🌐`,[[p(`http_response_data`),`response.data`],[p(`http_response_statuscode`),`response.statusCode`],[p(`http_response_responsetime`),`response.responseTime`],[p(`http_response_headers`),`response.headers`],[p(`http_response_error`),`err`]],[`http_get`,`http_post`],`http_response_warning`,`http_response_help`),f.Action.blocks.http_response_tofile=`<sep gap="5"></sep><block type="http_response_tofile"> <value name="FILENAME"> <shadow type="text"> <field name="TEXT">temp.jpg</field> </shadow> </value></block>`,r.http_response_tofile={init:function(){this.appendDummyInput().appendField(`🌐 ${p(`http_response_tofile`)}`),this.appendValueInput(`FILENAME`).appendField(p(`http_response_tofile_filename`)).setCheck(null),this.setInputsInline(!1),this.setOutput(!0,`String`),this.setColour(f.Action.HUE),this.setTooltip(p(`http_response_tofile_tooltip`)),this.setHelpUrl(m(`http_response_tofile_help`))},onchange:function(){l(this,[`http_get`,`http_post`],`http_response_warning`)},FUNCTION_TYPES:[`http_get`,`http_post`]},a.forBlock.http_response_tofile=function(e){return[`createTempFile(${a.valueToCode(e,`FILENAME`,i.ATOMIC)}, response.data)`,i.ATOMIC]};let x=()=>`${a.prefixLines(`if (err) {`,a.INDENT)}\n${a.prefixLines(`console.error(err);`,a.INDENT+a.INDENT)}\n${a.prefixLines(`}`,a.INDENT)}\n`;f.Action.blocks.file_write=`<block type="file_write"> <value name="OID"> <shadow type="field_oid_meta"> <field name="oid">0_userdata.0</field> </shadow> </value> <value name="FILE"> <shadow type="text"> <field name="TEXT">demo.json</field> </shadow> </value></block>`,r.file_write={init:function(){this.appendValueInput(`OID`).appendField(`📁 ${p(`file_write`)}`),this.appendValueInput(`FILE`).appendField(p(`file_write_filename`)).setCheck(null),this.appendValueInput(`DATA`).appendField(p(`file_write_data`)),this.setInputsInline(!1),this.setPreviousStatement(!0,null),this.setNextStatement(!0,null),this.setColour(f.Action.HUE),this.setTooltip(p(`file_write_tooltip`)),this.setHelpUrl(m(`file_write_help`))}},a.forBlock.file_write=function(e){let t=a.valueToCode(e,`OID`,i.ATOMIC),n=a.valueToCode(e,`FILE`,i.ATOMIC),r=a.valueToCode(e,`DATA`,i.ATOMIC),o=d(t);return`writeFile(${t}${o?` /* ${o} */`:``}, String(${n}), ${r||`null`}, (err) => {\n${x()}});\n`},f.Action.blocks.file_read=`<sep gap="5"></sep><block type="file_read"> <value name="OID"> <shadow type="field_oid_meta"> <field name="oid">0_userdata.0</field> </shadow> </value> <value name="FILE"> <shadow type="text"> <field name="TEXT">demo.json</field> </shadow> </value></block>`,r.file_read={init:function(){this.appendValueInput(`OID`).appendField(`📁 ${p(`file_read`)}`),this.appendValueInput(`FILE`).appendField(p(`file_read_filename`)).setCheck(null),this.appendStatementInput(`STATEMENT`).setCheck(null),this.setInputsInline(!1),this.setPreviousStatement(!0,null),this.setNextStatement(!0,null),this.setColour(f.Action.HUE),this.setTooltip(p(`file_read_tooltip`)),this.setHelpUrl(m(`file_read_help`))}},a.forBlock.file_read=function(e){let t=a.valueToCode(e,`OID`,i.ATOMIC),n=a.valueToCode(e,`FILE`,i.ATOMIC),r=a.statementToCode(e,`STATEMENT`),o=d(t);return`readFile(${t}${o?` /* ${o} */`:``}, String(${n}), (err, data, mimeType) => {\n${x()}${r}});\n`},f.Action.blocks.file_data=`<sep gap="5"></sep><block type="file_data"> <field name="ATTR">data</field></block>`,b(`file_data`,`📁`,[[p(`file_data_data`),`data`],[p(`file_data_mimeType`),`mimeType`]],[`file_read`],`file_data_warning`),f.Action.blocks.request=`<block type="request"> <mutation with_statement="false"></mutation> <field name="WITH_STATEMENT">FALSE</field> <field name="LOG"></field> <value name="URL"> <shadow type="text"> <field name="TEXT">http://</field> </shadow> </value></block>`,r.request={init:function(){this.appendDummyInput(`TEXT`).appendField(p(`request`)),this.appendValueInput(`URL`).appendField(p(`request_url`)),this.appendDummyInput(`WITH_STATEMENT`).appendField(p(`with_results`)).appendField(h(),`WITH_STATEMENT`),this.appendDummyInput(`LOG`).appendField(p(`loglevel`)).appendField(new e(c()),`LOG`),this.setInputsInline(!1),this.setPreviousStatement(!0,null),this.setNextStatement(!0,null),this.setColour(f.Action.HUE),this.setTooltip(p(`request_tooltip`)),this.setHelpUrl(p(`request_help`))},...y},a.forBlock.request=function(e){let t=a.valueToCode(e,`URL`,i.ATOMIC),n=e.getFieldValue(`LOG`),r=``;if(n&&(r=`console.${n}('request: ' + ${t});\n`),u(e.getFieldValue(`WITH_STATEMENT`))){let n=a.statementToCode(e,`STATEMENT`);if(n)return`try {\n require("request")(${t}, async (error, response, result) => {\n ${n} }).on("error", (e) => { console.error(e); });\n} catch (e) { console.error(e); }\n${r}`}return`try {\n require("request")(${t}).on("error", (e) => { console.error(e); });\n} catch (e) { console.error(e); }\n${r}`}}export{f as install};
1
+ import{i as e,o as t,r as n,t as r}from"./blockly-Fp-1_Ye3.js";import{c as i,l as a}from"./index-CqFiN-25.js";import{c as o,d as s,i as c,p as l,r as u,s as d}from"./helpers-CalO_DDQ.js";function f(){let f=window.Blockly,p=f.Translate,m=window.getHelp;f.CustomBlocks=f.CustomBlocks||[],f.CustomBlocks.push(`Action`),f.Action={HUE:330,blocks:{}};let h=()=>new n(`FALSE`,function(e){this.getSourceBlock().updateShape_(u(e))}),g=()=>[[p(`http_timeout_ms`),`ms`],[p(`http_timeout_sec`),`sec`]],_=()=>[[p(`http_type_text`),`text`],[p(`http_type_arraybuffer`),`arraybuffer`]],v=()=>[[p(`http_content_type_default`),`default`],[`application/json`,`application/json`],[`application/x-www-form-urlencoded`,`application/x-www-form-urlencoded`],[`text/plain`,`text/plain`],[`text/xml`,`text/xml`],[`application/xml`,`application/xml`],[p(`http_content_type_custom`),`custom`]],y={mutationToDom:function(){let e=document.createElement(`mutation`);return e.setAttribute(`with_statement`,String(u(this.getFieldValue(`WITH_STATEMENT`)))),e},domToMutation:function(e){this.updateShape_(u(e.getAttribute(`with_statement`)))},updateShape_:function(e){s(this,e)}},b=(t,n,o,s,c,u)=>{r[t]={init:function(){this.appendDummyInput().appendField(n),this.appendDummyInput(`ATTR`).appendField(new e(o),`ATTR`),this.setInputsInline(!0),this.setOutput(!0),this.setColour(f.Action.HUE),this.setTooltip(p(`${t}_tooltip`)),u&&this.setHelpUrl(m(u))},onchange:function(){l(this,s,c)},FUNCTION_TYPES:s},a.forBlock[t]=function(e){return[e.getFieldValue(`ATTR`),i.ATOMIC]}};f.Action.blocks.exec=`<block type="exec"> <mutation with_statement="false"></mutation> <field name="WITH_STATEMENT">FALSE</field> <field name="LOG"></field> <value name="COMMAND"> <shadow type="text"> <field name="TEXT">pwd</field> </shadow> </value></block>`,r.exec={init:function(){this.appendDummyInput(`TEXT`).appendField(`» ${p(`exec`)}`),this.appendValueInput(`COMMAND`).appendField(p(`exec_command`)),this.appendDummyInput(`WITH_STATEMENT`).appendField(p(`with_results`)).appendField(h(),`WITH_STATEMENT`),this.appendDummyInput(`LOG`).appendField(p(`loglevel`)).appendField(new e(c()),`LOG`),this.setInputsInline(!1),this.setPreviousStatement(!0,null),this.setNextStatement(!0,null),this.setColour(f.Action.HUE),this.setTooltip(p(`exec_tooltip`)),this.setHelpUrl(m(`exec_help`))},...y},a.forBlock.exec=function(e){let t=a.valueToCode(e,`COMMAND`,i.ATOMIC),n=e.getFieldValue(`LOG`),r=``;if(n&&(r=`console.${n}('exec: ' + ${t});\n`),u(e.getFieldValue(`WITH_STATEMENT`))){let n=a.statementToCode(e,`STATEMENT`);if(n)return`exec(${t}, async (error, result, stderr) => {\n${n}});\n${r}`}return`exec(${t});\n${r}`},f.Action.blocks.exec_result=`<sep gap="5"></sep><block type="exec_result"> <field name="ATTR">result</field></block>`,b(`exec_result`,`»`,[[p(`exec_result_result`),`result`],[p(`exec_result_stderr`),`stderr`],[p(`exec_result_error`),`error`]],[`exec`],`exec_result_warning`,`exec_help`),f.Action.blocks.http_get=`<block type="http_get"> <field name="TIMEOUT">2000</field> <field name="UNIT">ms</field> <field name="TYPE">text</field> <value name="URL"> <shadow type="text"> <field name="TEXT">http://</field> </shadow> </value></block>`,r.http_get={init:function(){this.appendValueInput(`URL`).appendField(`🌐 ${p(`http_get`)}`),this.appendDummyInput().appendField(p(`http_timeout`)).appendField(new t(`2000`),`TIMEOUT`).appendField(new e(g()),`UNIT`),this.appendDummyInput(`TYPE`).appendField(p(`http_type`)).appendField(new e(_()),`TYPE`),this.appendStatementInput(`STATEMENT`).setCheck(null),this.setInputsInline(!1),this.setPreviousStatement(!0,null),this.setNextStatement(!0,null),this.setColour(f.Action.HUE),this.setTooltip(p(`http_get_tooltip`)),this.setHelpUrl(m(`http_get_help`))}},a.forBlock.http_get=function(e){let t=a.valueToCode(e,`URL`,i.ATOMIC),n=e.getFieldValue(`UNIT`),r=e.getFieldValue(`TIMEOUT`);Number.isNaN(r)&&(r=2e3),n===`sec`&&(r*=1e3);let o=e.getFieldValue(`TYPE`)||`text`,s=a.statementToCode(e,`STATEMENT`);return`httpGet(${t}, { timeout: ${r}, responseType: '${o}' }, async (err, response) => {\n${s}});\n`},f.Action.blocks.http_post=`<sep gap="5"></sep><block type="http_post"> <field name="TIMEOUT">2000</field> <field name="UNIT">ms</field> <field name="TYPE">text</field> <field name="CONTENT_TYPE">default</field> <value name="URL"> <shadow type="text"> <field name="TEXT">http://</field> </shadow> </value> <value name="DATA"> <shadow type="logic_null"></shadow> </value></block>`,r.http_post={init:function(){this.appendValueInput(`URL`).appendField(`🌐 ${p(`http_post`)}`),this.appendDummyInput().appendField(p(`http_timeout`)).appendField(new t(`2000`),`TIMEOUT`).appendField(new e(g()),`UNIT`),this.appendDummyInput(`TYPE`).appendField(p(`http_type`)).appendField(new e(_()),`TYPE`),this.appendDummyInput(`CONTENT_TYPE`).appendField(p(`http_content_type`)).appendField(new e(v(),function(e){this.getSourceBlock().updateContentTypeShape_(e===`custom`)}),`CONTENT_TYPE`),this.appendValueInput(`DATA`).appendField(p(`http_post_data`)),this.appendStatementInput(`STATEMENT`).setCheck(null),this.setInputsInline(!1),this.setPreviousStatement(!0,null),this.setNextStatement(!0,null),this.setColour(f.Action.HUE),this.setTooltip(p(`http_post_tooltip`)),this.setHelpUrl(m(`http_post_help`))},mutationToDom:function(){let e=document.createElement(`mutation`);return e.setAttribute(`custom_content_type`,String(this.getFieldValue(`CONTENT_TYPE`)===`custom`)),e},domToMutation:function(e){this.updateContentTypeShape_(u(e.getAttribute(`custom_content_type`)))},updateContentTypeShape_:function(e){e?this.getInput(`CONTENT_TYPE_CUSTOM`)||(this.appendDummyInput(`CONTENT_TYPE_CUSTOM`).appendField(` `).appendField(new t(`application/json`),`CONTENT_TYPE_CUSTOM`),this.moveInputBefore(`CONTENT_TYPE_CUSTOM`,`DATA`)):this.getInput(`CONTENT_TYPE_CUSTOM`)&&this.removeInput(`CONTENT_TYPE_CUSTOM`)}},a.forBlock.http_post=function(e){let t=a.valueToCode(e,`URL`,i.ATOMIC),n=e.getFieldValue(`UNIT`),r=e.getFieldValue(`TIMEOUT`);isNaN(r)&&(r=2e3),n===`sec`&&(r*=1e3);let s=e.getFieldValue(`TYPE`)||`text`,c=a.valueToCode(e,`DATA`,i.ATOMIC)||`null`,l=a.statementToCode(e,`STATEMENT`),u=e.getFieldValue(`CONTENT_TYPE`)||`default`,d=u===`custom`?(e.getFieldValue(`CONTENT_TYPE_CUSTOM`)||``).trim():u,f=d&&d!=="default"?`, headers: { 'Content-Type': ${o(d)} }`:``;return`httpPost(${t}, ${c}, { timeout: ${r}, responseType: '${s}'${f} }, async (err, response) => {\n${l}});\n`},f.Action.blocks.http_response=`<sep gap="5"></sep><block type="http_response"> <field name="ATTR">response.data</field></block>`,b(`http_response`,`🌐`,[[p(`http_response_data`),`response.data`],[p(`http_response_statuscode`),`response.statusCode`],[p(`http_response_responsetime`),`response.responseTime`],[p(`http_response_headers`),`response.headers`],[p(`http_response_error`),`err`]],[`http_get`,`http_post`],`http_response_warning`,`http_response_help`),f.Action.blocks.http_response_tofile=`<sep gap="5"></sep><block type="http_response_tofile"> <value name="FILENAME"> <shadow type="text"> <field name="TEXT">temp.jpg</field> </shadow> </value></block>`,r.http_response_tofile={init:function(){this.appendDummyInput().appendField(`🌐 ${p(`http_response_tofile`)}`),this.appendValueInput(`FILENAME`).appendField(p(`http_response_tofile_filename`)).setCheck(null),this.setInputsInline(!1),this.setOutput(!0,`String`),this.setColour(f.Action.HUE),this.setTooltip(p(`http_response_tofile_tooltip`)),this.setHelpUrl(m(`http_response_tofile_help`))},onchange:function(){l(this,[`http_get`,`http_post`],`http_response_warning`)},FUNCTION_TYPES:[`http_get`,`http_post`]},a.forBlock.http_response_tofile=function(e){return[`createTempFile(${a.valueToCode(e,`FILENAME`,i.ATOMIC)}, response.data)`,i.ATOMIC]};let x=()=>`${a.prefixLines(`if (err) {`,a.INDENT)}\n${a.prefixLines(`console.error(err);`,a.INDENT+a.INDENT)}\n${a.prefixLines(`}`,a.INDENT)}\n`;f.Action.blocks.file_write=`<block type="file_write"> <value name="OID"> <shadow type="field_oid_meta"> <field name="oid">0_userdata.0</field> </shadow> </value> <value name="FILE"> <shadow type="text"> <field name="TEXT">demo.json</field> </shadow> </value></block>`,r.file_write={init:function(){this.appendValueInput(`OID`).appendField(`📁 ${p(`file_write`)}`),this.appendValueInput(`FILE`).appendField(p(`file_write_filename`)).setCheck(null),this.appendValueInput(`DATA`).appendField(p(`file_write_data`)),this.setInputsInline(!1),this.setPreviousStatement(!0,null),this.setNextStatement(!0,null),this.setColour(f.Action.HUE),this.setTooltip(p(`file_write_tooltip`)),this.setHelpUrl(m(`file_write_help`))}},a.forBlock.file_write=function(e){let t=a.valueToCode(e,`OID`,i.ATOMIC),n=a.valueToCode(e,`FILE`,i.ATOMIC),r=a.valueToCode(e,`DATA`,i.ATOMIC),o=d(t);return`writeFile(${t}${o?` /* ${o} */`:``}, String(${n}), ${r||`null`}, (err) => {\n${x()}});\n`},f.Action.blocks.file_read=`<sep gap="5"></sep><block type="file_read"> <value name="OID"> <shadow type="field_oid_meta"> <field name="oid">0_userdata.0</field> </shadow> </value> <value name="FILE"> <shadow type="text"> <field name="TEXT">demo.json</field> </shadow> </value></block>`,r.file_read={init:function(){this.appendValueInput(`OID`).appendField(`📁 ${p(`file_read`)}`),this.appendValueInput(`FILE`).appendField(p(`file_read_filename`)).setCheck(null),this.appendStatementInput(`STATEMENT`).setCheck(null),this.setInputsInline(!1),this.setPreviousStatement(!0,null),this.setNextStatement(!0,null),this.setColour(f.Action.HUE),this.setTooltip(p(`file_read_tooltip`)),this.setHelpUrl(m(`file_read_help`))}},a.forBlock.file_read=function(e){let t=a.valueToCode(e,`OID`,i.ATOMIC),n=a.valueToCode(e,`FILE`,i.ATOMIC),r=a.statementToCode(e,`STATEMENT`),o=d(t);return`readFile(${t}${o?` /* ${o} */`:``}, String(${n}), (err, data, mimeType) => {\n${x()}${r}});\n`},f.Action.blocks.file_data=`<sep gap="5"></sep><block type="file_data"> <field name="ATTR">data</field></block>`,b(`file_data`,`📁`,[[p(`file_data_data`),`data`],[p(`file_data_mimeType`),`mimeType`]],[`file_read`],`file_data_warning`),f.Action.blocks.request=`<block type="request"> <mutation with_statement="false"></mutation> <field name="WITH_STATEMENT">FALSE</field> <field name="LOG"></field> <value name="URL"> <shadow type="text"> <field name="TEXT">http://</field> </shadow> </value></block>`,r.request={init:function(){this.appendDummyInput(`TEXT`).appendField(p(`request`)),this.appendValueInput(`URL`).appendField(p(`request_url`)),this.appendDummyInput(`WITH_STATEMENT`).appendField(p(`with_results`)).appendField(h(),`WITH_STATEMENT`),this.appendDummyInput(`LOG`).appendField(p(`loglevel`)).appendField(new e(c()),`LOG`),this.setInputsInline(!1),this.setPreviousStatement(!0,null),this.setNextStatement(!0,null),this.setColour(f.Action.HUE),this.setTooltip(p(`request_tooltip`)),this.setHelpUrl(p(`request_help`))},...y},a.forBlock.request=function(e){let t=a.valueToCode(e,`URL`,i.ATOMIC),n=e.getFieldValue(`LOG`),r=``;if(n&&(r=`console.${n}('request: ' + ${t});\n`),u(e.getFieldValue(`WITH_STATEMENT`))){let n=a.statementToCode(e,`STATEMENT`);if(n)return`try {\n require("request")(${t}, async (error, response, result) => {\n ${n} }).on("error", (e) => { console.error(e); });\n} catch (e) { console.error(e); }\n${r}`}return`try {\n require("request")(${t}).on("error", (e) => { console.error(e); });\n} catch (e) { console.error(e); }\n${r}`}}export{f as install};
@@ -1,3 +1,3 @@
1
- import{i as e,o as t,r as n,t as r}from"./blockly-DBw-ytY1.js";import{c as i,l as a}from"./index-BnLv569U.js";import{c as o,n as s,t as c}from"./helpers-BFQD9R82.js";function l(){let l=window.Blockly,u=l.Translate;l.CustomBlocks=l.CustomBlocks||[],l.CustomBlocks.push(`Convert`),l.Convert={HUE:280,blocks:{}},l.Convert.blocks.convert_tonumber=`<block type="convert_tonumber"></block>`,r.convert_tonumber={init:function(){this.appendValueInput(`VALUE`).appendField(u(`convert_tonumber`)),this.setOutput(!0,`Number`),this.setColour(l.Convert.HUE),this.setTooltip(u(`convert_tonumber_tooltip`))}},a.forBlock.convert_tonumber=function(e){return[`parseFloat(${a.valueToCode(e,`VALUE`,i.ATOMIC)})`,i.ATOMIC]},l.Convert.blocks.convert_toboolean=`<block type="convert_toboolean"></block>`,r.convert_toboolean={init:function(){this.appendValueInput(`VALUE`).appendField(u(`convert_toboolean`)),this.setOutput(!0,`Boolean`),this.setColour(l.Convert.HUE),this.setTooltip(u(`convert_toboolean_tooltip`))}},a.forBlock.convert_toboolean=function(e){return[`(() => {
1
+ import{i as e,o as t,r as n,t as r}from"./blockly-Fp-1_Ye3.js";import{c as i,l as a}from"./index-CqFiN-25.js";import{c as o,n as s,t as c}from"./helpers-CalO_DDQ.js";function l(){let l=window.Blockly,u=l.Translate;l.CustomBlocks=l.CustomBlocks||[],l.CustomBlocks.push(`Convert`),l.Convert={HUE:280,blocks:{}},l.Convert.blocks.convert_tonumber=`<block type="convert_tonumber"></block>`,r.convert_tonumber={init:function(){this.appendValueInput(`VALUE`).appendField(u(`convert_tonumber`)),this.setOutput(!0,`Number`),this.setColour(l.Convert.HUE),this.setTooltip(u(`convert_tonumber_tooltip`))}},a.forBlock.convert_tonumber=function(e){return[`parseFloat(${a.valueToCode(e,`VALUE`,i.ATOMIC)})`,i.ATOMIC]},l.Convert.blocks.convert_toboolean=`<block type="convert_toboolean"></block>`,r.convert_toboolean={init:function(){this.appendValueInput(`VALUE`).appendField(u(`convert_toboolean`)),this.setOutput(!0,`Boolean`),this.setColour(l.Convert.HUE),this.setTooltip(u(`convert_toboolean_tooltip`))}},a.forBlock.convert_toboolean=function(e){return[`(() => {
2
2
  const val = ${a.valueToCode(e,`VALUE`,i.ATOMIC)};\n if (val === 'true' || val === 'TRUE') return true;\n if (val === 'false' || val === 'FALSE') return false;\n return !!val;
3
3
  })()`,i.ATOMIC]},l.Convert.blocks.convert_tostring=`<block type="convert_tostring"></block>`,r.convert_tostring={init:function(){this.appendValueInput(`VALUE`).appendField(u(`convert_tostring`)),this.setOutput(!0,`String`),this.setColour(l.Convert.HUE),this.setTooltip(u(`convert_tostring_tooltip`))}},a.forBlock.convert_tostring=function(e){return[`('' + ${a.valueToCode(e,`VALUE`,i.ATOMIC)})`,i.ATOMIC]},l.Convert.blocks.convert_type=`<block type="convert_type"></block>`,r.convert_type={init:function(){this.appendValueInput(`ITEM`).appendField(u(`convert_type`)),this.setOutput(!0,`String`),this.setColour(l.Convert.HUE),this.setTooltip(u(`convert_type_tooltip`))}},a.forBlock.convert_type=function(e){return[`typeof ${a.valueToCode(e,`ITEM`,i.ATOMIC)}`,i.ATOMIC]},l.Convert.blocks.convert_to_date=`<block type="convert_to_date"></block>`,r.convert_to_date={init:function(){this.appendValueInput(`VALUE`).appendField(u(`convert_to_date`)),this.setOutput(!0,`Date`),this.setColour(l.Convert.HUE),this.setTooltip(u(`convert_to_date_tooltip`))}},a.forBlock.convert_to_date=function(e){return[`getDateObject(${a.valueToCode(e,`VALUE`,i.ATOMIC)}).getTime()`,i.ATOMIC]},l.Convert.blocks.convert_from_date=`<block type="convert_from_date"> <mutation format="false" language="false"></mutation> <field name="OPTION">object</field></block>`,r.convert_from_date={init:function(){this.appendValueInput(`VALUE`).appendField(u(`convert_from_date`)),this.appendDummyInput(`OPTION`).appendField(u(`convert_to`)).appendField(new e(c(),function(e){this.getSourceBlock().updateShape_(e===`custom`,e===`wdts`||e===`wdt`||e===`Mt`||e===`Mts`)}),`OPTION`),this.setInputsInline(!0),this.setOutput(!0),this.setColour(l.Convert.HUE),this.setTooltip(u(`convert_from_date_tooltip`))},mutationToDom:function(){let e=document.createElement(`mutation`),t=this.getFieldValue(`OPTION`);return e.setAttribute(`format`,t===`custom`?`true`:`false`),e.setAttribute(`language`,t===`wdt`||t===`wdts`||t===`Mt`||t===`Mts`?`true`:`false`),e},domToMutation:function(e){let t=e.getAttribute(`format`),n=e.getAttribute(`language`);this.updateShape_(t===`true`||t===`TRUE`,n===`true`||n===`TRUE`)},updateShape_:function(n,r){if(n?this.getInput(`FORMAT`)||this.appendDummyInput(`FORMAT`).appendField(` `).appendField(new t(u(`time_get_default_format`)),`FORMAT`):this.getInput(`FORMAT`)&&this.removeInput(`FORMAT`),r){if(!this.getInput(`LANGUAGE`)){let t=s();this.appendDummyInput(`LANGUAGE`).appendField(new e(t),`LANGUAGE`)}}else this.getInput(`LANGUAGE`)&&this.removeInput(`LANGUAGE`)}},a.forBlock.convert_from_date=function(e){let t=e.getFieldValue(`OPTION`),n=e.getFieldValue(`FORMAT`),r=e.getFieldValue(`LANGUAGE`),s=a.valueToCode(e,`VALUE`,i.ATOMIC),c;return c=t===`object`?`getDateObject(${s}).getTime()`:t===`ms`?`getDateObject(${s}).getMilliseconds()`:t===`s`?`getDateObject(${s}).getSeconds()`:t===`sid`?`(() => { const v = getDateObject(${s}); return v.getHours() * 3600 + v.getMinutes() * 60 + v.getSeconds(); })()`:t===`m`?`getDateObject(${s}).getMinutes()`:t===`mid`?`(() => { const v = getDateObject(${s}); return v.getHours() * 60 + v.getMinutes(); })()`:t===`h`?`getDateObject(${s}).getHours()`:t===`d`?`getDateObject(${s}).getDate()`:t===`M`?`(getDateObject(${s}).getMonth() + 1)`:t===`Mt`?`formatDate(getDateObject(${s}), 'OO', '${r}')`:t===`Mts`?`formatDate(getDateObject(${s}), 'O', '${r}')`:t===`y`?`getDateObject(${s}).getYear()`:t===`fy`?`getDateObject(${s}).getFullYear()`:t===`wdt`?`formatDate(getDateObject(${s}), 'WW', '${r}')`:t===`wdts`?`formatDate(getDateObject(${s}), 'W', '${r}')`:t===`wd`?`(() => { const d = getDateObject(${s}).getDay(); return d === 0 ? 7 : d; })()`:t===`cw`?`((date) => { const d = new Date(Date.UTC(date.getFullYear(), date.getMonth(), date.getDate())); const dayNum = d.getUTCDay() || 7; d.setUTCDate(d.getUTCDate() + 4 - dayNum); const yearStart = new Date(Date.UTC(d.getUTCFullYear(), 0, 1)); return Math.ceil(((d.getTime() - yearStart.getTime()) / 86400000 + 1) / 7); })(getDateObject(${s}))`:t===`custom`?`formatDate(getDateObject(${s}), ${o(n)})`:`formatDate(getDateObject(${s}), ${o(t)})`,[c,i.ATOMIC]},l.Convert.blocks.convert_time_difference=`<block type="convert_time_difference"> <mutation format="false"></mutation> <field name="OPTION">hh:mm:ss</field> </block>`,r.convert_time_difference={init:function(){this.appendValueInput(`VALUE`).appendField(u(`convert_time_difference`)),this.appendDummyInput(`OPTION`).appendField(u(`convert_to`)).appendField(new e([[u(`time_difference_hh:mm:ss`),`hh:mm:ss`],[u(`time_difference_h:m:s`),`h:m:s`],[u(`time_difference_hh:mm`),`hh:mm`],[u(`time_difference_h:m`),`h:m`],[u(`time_difference_mm:ss`),`mm:ss`],[u(`time_difference_m:s`),`m:s`],[u(`time_difference_custom`),`custom`]],function(e){this.getSourceBlock().updateShape_(e===`custom`)}),`OPTION`),this.setInputsInline(!0),this.setOutput(!0,`String`),this.setColour(l.Convert.HUE),this.setTooltip(u(`convert_time_difference_tooltip`))},mutationToDom:function(){let e=document.createElement(`mutation`),t=this.getFieldValue(`OPTION`);return e.setAttribute(`format`,t===`custom`?`true`:`false`),e},domToMutation:function(e){let t=e.getAttribute(`format`);this.updateShape_(t===`true`||t===`TRUE`)},updateShape_:function(e){e?this.getInput(`FORMAT`)||this.appendDummyInput(`FORMAT`).appendField(` `).appendField(new t(u(`time_difference_default_format`)),`FORMAT`):this.getInput(`FORMAT`)&&this.removeInput(`FORMAT`)}},a.forBlock.convert_time_difference=function(e){let t=e.getFieldValue(`OPTION`),n=e.getFieldValue(`FORMAT`);return[`formatTimeDiff(${a.valueToCode(e,`VALUE`,i.ATOMIC)||`0`}, ${o(t===`custom`?n:t)})`,i.ATOMIC]},l.Convert.blocks.convert_json2object=`<block type="convert_json2object"></block>`,r.convert_json2object={init:function(){this.appendValueInput(`VALUE`).appendField(u(`convert_json2object`)),this.setOutput(!0),this.setColour(l.Convert.HUE),this.setTooltip(u(`convert_json2object_tooltip`))}},a.forBlock.convert_json2object=function(e){return[`(() => { try { return JSON.parse(${a.valueToCode(e,`VALUE`,i.ATOMIC)}); } catch (e) { return {}; }})()`,i.ATOMIC]},l.Convert.blocks.convert_object2json=`<block type="convert_object2json"> <field name="PRETTIFY">FALSE</field></block>`,r.convert_object2json={init:function(){this.appendValueInput(`VALUE`).appendField(u(`convert_object2json`)),this.appendDummyInput(`PRETTIFY`).appendField(u(`convert_object2json_prettify`)).appendField(new n(`FALSE`),`PRETTIFY`),this.setOutput(!0,`String`),this.setColour(l.Convert.HUE),this.setTooltip(u(`convert_object2json_tooltip`))}},a.forBlock.convert_object2json=function(e){let t=a.valueToCode(e,`VALUE`,i.ATOMIC),n=e.getFieldValue(`PRETTIFY`);return[`JSON.stringify(${t}${n===`TRUE`||n===`true`||n===!0?`, null, 2`:``})`,i.ATOMIC]},l.Convert.blocks.convert_jsonata=`<block type="convert_jsonata"> <value name="EXPRESSION"> <shadow type="text"> <field name="TEXT">*</field> </shadow> </value></block>`,r.convert_jsonata={init:function(){this.appendValueInput(`EXPRESSION`).appendField(u(`convert_jsonata`)),this.appendValueInput(`TARGET`).appendField(u(`convert_jsonata_target`)),this.setInputsInline(!0),this.setOutput(!0,`String`),this.setColour(l.Convert.HUE),this.setTooltip(u(`convert_jsonata_tooltip`))}},a.forBlock.convert_jsonata=function(e){let t=a.valueToCode(e,`EXPRESSION`,i.ATOMIC),n=a.valueToCode(e,`TARGET`,i.ATOMIC);return n||=`{}`,[`(await jsonataExpression(${n}, ${t}))`,i.ATOMIC]}}export{l as install};
@@ -1 +1 @@
1
- import{f as e,i as t,p as n,t as r}from"./blockly-DBw-ytY1.js";import{c as i,l as a}from"./index-BnLv569U.js";import{l as o}from"./helpers-BFQD9R82.js";function s(t,s,c,l,u){let d=window.Blockly.Translate,f=`${t}_container`,p=`${t}_mutator`;r[f]={init:function(){this.appendDummyInput().appendField(d(t)),this.appendStatementInput(`STACK`),this.setColour(`%{BKY_LOGIC_HUE}`),this.setTooltip(d(`${t}_tooltip`)),this.contextMenu=!1}},r[p]={init:function(){this.appendDummyInput(s).appendField(d(c)),this.setPreviousStatement(!0),this.setNextStatement(!0),this.setColour(`%{BKY_LOGIC_HUE}`),this.setTooltip(d(`${t}_tooltip`)),this.contextMenu=!1}},r[t]={init:function(){this.itemCount_=2,this.setMutator(new e.MutatorIcon([p],this)),this.setInputsInline(!1),this.setOutput(!0,`Boolean`),this.setColour(`%{BKY_LOGIC_HUE}`),this.setTooltip(d(`${t}_tooltip`))},mutationToDom:function(){let e=document.createElement(`mutation`);return e.setAttribute(`items`,String(this.itemCount_)),e},domToMutation:function(e){this.itemCount_=parseInt(e.getAttribute(`items`),10),this.updateShape_()},decompose:function(e){var t;let n=e.newBlock(f);n.initSvg();let r=(t=n.getInput(`STACK`))==null?void 0:t.connection;for(let t=0;t<this.itemCount_;t++){let t=e.newBlock(p);t.initSvg(),r.connect(t.previousConnection),r=t.nextConnection}return n},compose:function(e){let t=e.getInputTargetBlock(`STACK`),n=[];for(;t;)n.push(t.valueConnection_),t=t.nextConnection&&t.nextConnection.targetBlock();for(let e=0;e<this.itemCount_;e++){var r;let t=(r=this.getInput(`${s}${e}`))==null||(r=r.connection)==null?void 0:r.targetConnection;t&&!n.includes(t)&&t.disconnect()}this.itemCount_=n.length,this.itemCount_<2&&(this.itemCount_=2),this.updateShape_();for(let e=0;e<this.itemCount_;e++)o(n[e],this,`${s}${e}`)},saveConnections:function(e){let t=e.getInputTargetBlock(`STACK`),n=0;for(;t;){var r,i;let e=this.getInput(`${s}${n}`);t.valueConnection_=e==null||(r=e.connection)==null?void 0:r.targetConnection,n++,t=(i=t.nextConnection)==null?void 0:i.targetBlock()}},updateShape_:function(){for(let e=0;e<this.itemCount_;e++)if(!this.getInput(`${s}${e}`)){let t=this.appendValueInput(`${s}${e}`).setAlign(n.Align.RIGHT);e>0&&t.appendField(d(c))}for(let e=this.itemCount_;this.getInput(`${s}${e}`);e++)this.removeInput(`${s}${e}`)}},a.forBlock[t]=function(e){let t=e,n=[];for(let r=0;r<t.itemCount_;r++){let t=a.valueToCode(e,`${s}${r}`,i.ATOMIC);t&&n.push(t)}return[`${n.length>0?n.join(l):`false`}`,u]}}function c(){let e=window.Blockly.Translate;s(`logic_multi_and`,`AND`,`logic_multi_and_and`,` && `,i.LOGICAL_AND),s(`logic_multi_or`,`OR`,`logic_multi_or_or`,` || `,i.LOGICAL_OR),r.logic_between={init:function(){this.appendValueInput(`MIN`).setCheck(`Number`),this.appendValueInput(`VALUE`).setCheck(`Number`).appendField(new t([[`<`,`LT`],[`≤`,`LE`]]),`MIN_OPERATOR`),this.appendValueInput(`MAX`).setCheck(`Number`).appendField(new t([[`<`,`LT`],[`≤`,`LE`]]),`MAX_OPERATOR`),this.setInputsInline(!0),this.setOutput(!0,`Boolean`),this.setColour(`%{BKY_LOGIC_HUE}`),this.setTooltip(e(`logic_between_tooltip`))}},a.forBlock.logic_between=function(e){let t=a.valueToCode(e,`MIN`,i.RELATIONAL)||0,n=a.valueToCode(e,`VALUE`,i.RELATIONAL)||0,r=a.valueToCode(e,`MAX`,i.RELATIONAL)||0;return[`${t} ${e.getFieldValue(`MIN_OPERATOR`)===`LT`?`<`:`<=`} ${n} && ${n} ${e.getFieldValue(`MAX_OPERATOR`)===`LT`?`<`:`<=`} ${r}`,i.LOGICAL_AND]},r.logic_ifempty={init:function(){this.appendValueInput(`VALUE`).setCheck(null).setAlign(n.Align.RIGHT).appendField(e(`logic_ifempty`)),this.appendValueInput(`DEFLT`).setCheck(null).setAlign(n.Align.RIGHT).appendField(e(`logic_ifempty_then`)),this.setInputsInline(!0),this.setOutput(!0,null),this.setColour(`%{BKY_LOGIC_HUE}`),this.setTooltip(e(`logic_ifempty_tooltip`))}},a.forBlock.logic_ifempty=function(e){return[`${a.valueToCode(e,`VALUE`,i.LOGICAL_OR)||null} || ${a.valueToCode(e,`DEFLT`,i.LOGICAL_OR)||null}`,i.LOGICAL_OR]}}export{c as install};
1
+ import{f as e,i as t,p as n,t as r}from"./blockly-Fp-1_Ye3.js";import{c as i,l as a}from"./index-CqFiN-25.js";import{l as o}from"./helpers-CalO_DDQ.js";function s(t,s,c,l,u){let d=window.Blockly.Translate,f=`${t}_container`,p=`${t}_mutator`;r[f]={init:function(){this.appendDummyInput().appendField(d(t)),this.appendStatementInput(`STACK`),this.setColour(`%{BKY_LOGIC_HUE}`),this.setTooltip(d(`${t}_tooltip`)),this.contextMenu=!1}},r[p]={init:function(){this.appendDummyInput(s).appendField(d(c)),this.setPreviousStatement(!0),this.setNextStatement(!0),this.setColour(`%{BKY_LOGIC_HUE}`),this.setTooltip(d(`${t}_tooltip`)),this.contextMenu=!1}},r[t]={init:function(){this.itemCount_=2,this.setMutator(new e.MutatorIcon([p],this)),this.setInputsInline(!1),this.setOutput(!0,`Boolean`),this.setColour(`%{BKY_LOGIC_HUE}`),this.setTooltip(d(`${t}_tooltip`))},mutationToDom:function(){let e=document.createElement(`mutation`);return e.setAttribute(`items`,String(this.itemCount_)),e},domToMutation:function(e){this.itemCount_=parseInt(e.getAttribute(`items`),10),this.updateShape_()},decompose:function(e){var t;let n=e.newBlock(f);n.initSvg();let r=(t=n.getInput(`STACK`))==null?void 0:t.connection;for(let t=0;t<this.itemCount_;t++){let t=e.newBlock(p);t.initSvg(),r.connect(t.previousConnection),r=t.nextConnection}return n},compose:function(e){let t=e.getInputTargetBlock(`STACK`),n=[];for(;t;)n.push(t.valueConnection_),t=t.nextConnection&&t.nextConnection.targetBlock();for(let e=0;e<this.itemCount_;e++){var r;let t=(r=this.getInput(`${s}${e}`))==null||(r=r.connection)==null?void 0:r.targetConnection;t&&!n.includes(t)&&t.disconnect()}this.itemCount_=n.length,this.itemCount_<2&&(this.itemCount_=2),this.updateShape_();for(let e=0;e<this.itemCount_;e++)o(n[e],this,`${s}${e}`)},saveConnections:function(e){let t=e.getInputTargetBlock(`STACK`),n=0;for(;t;){var r,i;let e=this.getInput(`${s}${n}`);t.valueConnection_=e==null||(r=e.connection)==null?void 0:r.targetConnection,n++,t=(i=t.nextConnection)==null?void 0:i.targetBlock()}},updateShape_:function(){for(let e=0;e<this.itemCount_;e++)if(!this.getInput(`${s}${e}`)){let t=this.appendValueInput(`${s}${e}`).setAlign(n.Align.RIGHT);e>0&&t.appendField(d(c))}for(let e=this.itemCount_;this.getInput(`${s}${e}`);e++)this.removeInput(`${s}${e}`)}},a.forBlock[t]=function(e){let t=e,n=[];for(let r=0;r<t.itemCount_;r++){let t=a.valueToCode(e,`${s}${r}`,i.ATOMIC);t&&n.push(t)}return[`${n.length>0?n.join(l):`false`}`,u]}}function c(){let e=window.Blockly.Translate;s(`logic_multi_and`,`AND`,`logic_multi_and_and`,` && `,i.LOGICAL_AND),s(`logic_multi_or`,`OR`,`logic_multi_or_or`,` || `,i.LOGICAL_OR),r.logic_between={init:function(){this.appendValueInput(`MIN`).setCheck(`Number`),this.appendValueInput(`VALUE`).setCheck(`Number`).appendField(new t([[`<`,`LT`],[`≤`,`LE`]]),`MIN_OPERATOR`),this.appendValueInput(`MAX`).setCheck(`Number`).appendField(new t([[`<`,`LT`],[`≤`,`LE`]]),`MAX_OPERATOR`),this.setInputsInline(!0),this.setOutput(!0,`Boolean`),this.setColour(`%{BKY_LOGIC_HUE}`),this.setTooltip(e(`logic_between_tooltip`))}},a.forBlock.logic_between=function(e){let t=a.valueToCode(e,`MIN`,i.RELATIONAL)||0,n=a.valueToCode(e,`VALUE`,i.RELATIONAL)||0,r=a.valueToCode(e,`MAX`,i.RELATIONAL)||0;return[`${t} ${e.getFieldValue(`MIN_OPERATOR`)===`LT`?`<`:`<=`} ${n} && ${n} ${e.getFieldValue(`MAX_OPERATOR`)===`LT`?`<`:`<=`} ${r}`,i.LOGICAL_AND]},r.logic_ifempty={init:function(){this.appendValueInput(`VALUE`).setCheck(null).setAlign(n.Align.RIGHT).appendField(e(`logic_ifempty`)),this.appendValueInput(`DEFLT`).setCheck(null).setAlign(n.Align.RIGHT).appendField(e(`logic_ifempty_then`)),this.setInputsInline(!0),this.setOutput(!0,null),this.setColour(`%{BKY_LOGIC_HUE}`),this.setTooltip(e(`logic_ifempty_tooltip`))}},a.forBlock.logic_ifempty=function(e){return[`${a.valueToCode(e,`VALUE`,i.LOGICAL_OR)||null} || ${a.valueToCode(e,`DEFLT`,i.LOGICAL_OR)||null}`,i.LOGICAL_OR]}}export{c as install};
@@ -1 +1 @@
1
- import{a as e,s as t,t as n}from"./blockly-DBw-ytY1.js";import{c as r,l as i}from"./index-BnLv569U.js";function a(){let a=window.Blockly.Translate;n.math_rndfixed={init:function(){this.appendValueInput(`x`).setCheck(`Number`).appendField(a(`math_rndfixed_round`)),this.appendDummyInput().appendField(a(`math_rndfixed_to`)).appendField(new e(0,1,25),`n`).appendField(a(`math_rndfixed_decplcs`)),this.setInputsInline(!0),this.setOutput(!0,`Number`),this.setColour(t.MATH_HUE),this.setTooltip(a(`math_rndfixed_tooltip`))}},i.forBlock.math_rndfixed=function(e){let t=i.valueToCode(e,`x`,r.ATOMIC),n=10**Number(e.getFieldValue(`n`));return[`Math.round(${t} * ${n}) / ${n}`,r.ATOMIC]}}export{a as install};
1
+ import{a as e,s as t,t as n}from"./blockly-Fp-1_Ye3.js";import{c as r,l as i}from"./index-CqFiN-25.js";function a(){let a=window.Blockly.Translate;n.math_rndfixed={init:function(){this.appendValueInput(`x`).setCheck(`Number`).appendField(a(`math_rndfixed_round`)),this.appendDummyInput().appendField(a(`math_rndfixed_to`)).appendField(new e(0,1,25),`n`).appendField(a(`math_rndfixed_decplcs`)),this.setInputsInline(!0),this.setOutput(!0,`Number`),this.setColour(t.MATH_HUE),this.setTooltip(a(`math_rndfixed_tooltip`))}},i.forBlock.math_rndfixed=function(e){let t=i.valueToCode(e,`x`,r.ATOMIC),n=10**Number(e.getFieldValue(`n`));return[`Math.round(${t} * ${n}) / ${n}`,r.ATOMIC]}}export{a as install};
@@ -1 +1 @@
1
- import{f as e,o as t,p as n,t as r}from"./blockly-DBw-ytY1.js";import{c as i,l as a}from"./index-BnLv569U.js";import{c as o,l as s}from"./helpers-BFQD9R82.js";function c(){let c=window.Blockly,l=c.Translate;c.CustomBlocks=c.CustomBlocks||[],c.CustomBlocks.push(`Object`),c.Object={HUE:40,blocks:{}},c.Object.blocks.object_new=`<block type="object_new"></block>`,r.object_new_container={init:function(){this.setColour(c.Object.HUE),this.appendDummyInput().appendField(l(`object_new_attributes`)),this.appendStatementInput(`STACK`),this.setTooltip(l(`object_new_tooltip`)),this.contextMenu=!1}},r.object_new_mutator={init:function(){this.setColour(c.Object.HUE),this.appendDummyInput(`ATTR`).appendField(l(`object_new_attribute`)).appendField(new t(`attribute1`),`ATTR`),this.setPreviousStatement(!0),this.setNextStatement(!0),this.setTooltip(l(`object_new_tooltip`)),this.contextMenu=!1}},r.object_new={init:function(){this.appendDummyInput(`NAME`).appendField(l(`object_new`)),this.attributes_=[],this.itemCount_=0,this.setMutator(new e.MutatorIcon([`object_new_mutator`],this)),this.setInputsInline(!1),this.setOutput(!0),this.setColour(c.Object.HUE),this.setTooltip(l(`object_new_tooltip`))},mutationToDom:function(){let e=document.createElement(`mutation`);for(let t=0;t<this.attributes_.length;t++){let n=document.createElement(`attribute`);n.setAttribute(`id`,`ATTR_${t}`),n.setAttribute(`name`,this.attributes_[t]),e.appendChild(n)}return e},domToMutation:function(e){this.attributes_=[];for(let t=0,n;n=e.childNodes[t];t++)n.nodeName.toLowerCase()===`attribute`&&this.attributes_.push(n.getAttribute(`name`));this.itemCount_=this.attributes_.length,this.updateShape_()},decompose:function(e){var t;let n=e.newBlock(`object_new_container`);n.initSvg();let r=(t=n.getInput(`STACK`))==null?void 0:t.connection;for(let t=0;t<this.itemCount_;t++){let n=e.newBlock(`object_new_mutator`);n.setFieldValue(this.attributes_[t],`ATTR`),n.initSvg(),r.connect(n.previousConnection),r=n.nextConnection}return n},compose:function(e){this.attributes_=[];let t=e.getInputTargetBlock(`STACK`),n=[];for(;t;){let e=t.getFieldValue(`ATTR`);this.attributes_.push(e),n.push(t.valueConnection_),t=t.nextConnection&&t.nextConnection.targetBlock()}for(let e=0;e<this.itemCount_;e++){var r;let t=(r=this.getInput(`ATTR_${e}`))==null||(r=r.connection)==null?void 0:r.targetConnection;t&&!n.includes(t)&&t.disconnect()}this.itemCount_=n.length,this.itemCount_<0&&(this.itemCount_=0),this.updateShape_();for(let e=0;e<this.itemCount_;e++)s(n[e],this,`ATTR_${e}`)},saveConnections:function(e){let t=e.getInputTargetBlock(`STACK`),n=0;for(;t;){var r,i;let e=this.getInput(`ATTR_${n}`);t.valueConnection_=e==null||(r=e.connection)==null?void 0:r.targetConnection,n++,t=(i=t.nextConnection)==null?void 0:i.targetBlock()}},updateShape_:function(){let e=this.workspace;for(let t=0;t<this.itemCount_;t++){let r=this.getInput(`ATTR_${t}`);r?r.fieldRow[0].setValue(this.attributes_[t]):(r=this.appendValueInput(`ATTR_${t}`).setAlign(n.Align.RIGHT),r.appendField(this.attributes_[t])),setTimeout(t=>{var n;if(!((n=t.connection)!=null&&n.isConnected())){let n=e.newBlock(`text`);n.setShadow(!0),n.initSvg(),n.render(),n.outputConnection.connect(t.connection)}},100,r)}for(let e=this.itemCount_;this.getInput(`ATTR_${e}`);e++)this.removeInput(`ATTR_${e}`)}},a.forBlock.object_new=function(e){let t=e,n=[];for(let r=0;r<t.itemCount_;r++){let s=a.valueToCode(e,`ATTR_${r}`,i.COMMA);s&&n.push(`${o(t.attributes_[r])}: ${s}`)}return[`{ ${n.length?n.join(`, `):``} }`,i.ATOMIC]},c.Object.blocks.object_set_attr=`<block type="object_set_attr"> <field name="ATTR">attribute1</field> <value name="VALUE"> <shadow type="text"> <field name="TEXT">value</field> </shadow> </value></block>`,r.object_set_attr={init:function(){this.appendDummyInput(`ATTR`).appendField(l(`object_set_attr`)).appendField(new t(`attribute1`),`ATTR`),this.appendValueInput(`OBJECT`).appendField(l(`object_set_attr_object`)),this.appendValueInput(`VALUE`).setCheck(null).appendField(l(`object_set_attr_value`)),this.setInputsInline(!1),this.setPreviousStatement(!0,null),this.setNextStatement(!0,null),this.setColour(c.Object.HUE),this.setTooltip(l(`object_set_attr_tooltip`))}},a.forBlock.object_set_attr=function(e){let t=e.getFieldValue(`ATTR`),n=a.valueToCode(e,`VALUE`,i.ATOMIC),r=a.valueToCode(e,`OBJECT`,i.ATOMIC);return r||=`{}`,`((obj) => { if (typeof obj === 'object') { obj[${o(t)}] = ${n}; } })(${r});\n`},c.Object.blocks.object_del_attr=`<block type="object_del_attr"> <field name="ATTR">attribute1</field></block>`,r.object_del_attr={init:function(){this.appendDummyInput(`ATTR`).appendField(l(`object_del_attr`)).appendField(new t(`attribute1`),`ATTR`),this.appendValueInput(`OBJECT`).appendField(l(`object_del_attr_object`)),this.setInputsInline(!1),this.setPreviousStatement(!0,null),this.setNextStatement(!0,null),this.setColour(c.Object.HUE),this.setTooltip(l(`object_del_attr_tooltip`))}},a.forBlock.object_del_attr=function(e){let t=e.getFieldValue(`ATTR`),n=a.valueToCode(e,`OBJECT`,i.ATOMIC);return n||=`{}`,`((obj) => { if (typeof obj === 'object') { delete obj[${o(t)}]; } })(${n});\n`},c.Object.blocks.object_has_attr=`<block type="object_has_attr"> <field name="ATTR">attribute1</field> <value name="OBJECT"> <shadow type="get_object"> <field name="OID">Object ID</field> </shadow> </value></block>`,r.object_has_attr={init:function(){this.appendValueInput(`OBJECT`).appendField(l(`object_has_attr`)),this.appendDummyInput(`ATTR`).appendField(l(`object_has_attr_attr`)).appendField(new t(`attribute1`),`ATTR`),this.setInputsInline(!0),this.setOutput(!0,`Boolean`),this.setColour(c.Object.HUE),this.setTooltip(l(`object_has_attr_tooltip`))}},a.forBlock.object_has_attr=function(e){let t=a.valueToCode(e,`OBJECT`,i.ATOMIC),n=e.getFieldValue(`ATTR`);return[`Object.prototype.hasOwnProperty.call(${t}, ${o(n)})`,i.ATOMIC]},c.Object.blocks.object_keys=`<block type="object_keys"> <value name="OBJECT"> <shadow type="get_object"> <field name="OID">Object ID</field> </shadow> </value></block>`,r.object_keys={init:function(){this.appendValueInput(`OBJECT`).appendField(l(`object_keys`)),this.setInputsInline(!0),this.setOutput(!0,`Array`),this.setColour(c.Object.HUE),this.setTooltip(l(`object_keys_tooltip`))}},a.forBlock.object_keys=function(e){let t=a.valueToCode(e,`OBJECT`,i.ATOMIC);return t||=`{}`,[`Object.keys(${t})`,i.ATOMIC]}}export{c as install};
1
+ import{f as e,o as t,p as n,t as r}from"./blockly-Fp-1_Ye3.js";import{c as i,l as a}from"./index-CqFiN-25.js";import{c as o,l as s}from"./helpers-CalO_DDQ.js";function c(){let c=window.Blockly,l=c.Translate;c.CustomBlocks=c.CustomBlocks||[],c.CustomBlocks.push(`Object`),c.Object={HUE:40,blocks:{}},c.Object.blocks.object_new=`<block type="object_new"></block>`,r.object_new_container={init:function(){this.setColour(c.Object.HUE),this.appendDummyInput().appendField(l(`object_new_attributes`)),this.appendStatementInput(`STACK`),this.setTooltip(l(`object_new_tooltip`)),this.contextMenu=!1}},r.object_new_mutator={init:function(){this.setColour(c.Object.HUE),this.appendDummyInput(`ATTR`).appendField(l(`object_new_attribute`)).appendField(new t(`attribute1`),`ATTR`),this.setPreviousStatement(!0),this.setNextStatement(!0),this.setTooltip(l(`object_new_tooltip`)),this.contextMenu=!1}},r.object_new={init:function(){this.appendDummyInput(`NAME`).appendField(l(`object_new`)),this.attributes_=[],this.itemCount_=0,this.setMutator(new e.MutatorIcon([`object_new_mutator`],this)),this.setInputsInline(!1),this.setOutput(!0),this.setColour(c.Object.HUE),this.setTooltip(l(`object_new_tooltip`))},mutationToDom:function(){let e=document.createElement(`mutation`);for(let t=0;t<this.attributes_.length;t++){let n=document.createElement(`attribute`);n.setAttribute(`id`,`ATTR_${t}`),n.setAttribute(`name`,this.attributes_[t]),e.appendChild(n)}return e},domToMutation:function(e){this.attributes_=[];for(let t=0,n;n=e.childNodes[t];t++)n.nodeName.toLowerCase()===`attribute`&&this.attributes_.push(n.getAttribute(`name`));this.itemCount_=this.attributes_.length,this.updateShape_()},decompose:function(e){var t;let n=e.newBlock(`object_new_container`);n.initSvg();let r=(t=n.getInput(`STACK`))==null?void 0:t.connection;for(let t=0;t<this.itemCount_;t++){let n=e.newBlock(`object_new_mutator`);n.setFieldValue(this.attributes_[t],`ATTR`),n.initSvg(),r.connect(n.previousConnection),r=n.nextConnection}return n},compose:function(e){this.attributes_=[];let t=e.getInputTargetBlock(`STACK`),n=[];for(;t;){let e=t.getFieldValue(`ATTR`);this.attributes_.push(e),n.push(t.valueConnection_),t=t.nextConnection&&t.nextConnection.targetBlock()}for(let e=0;e<this.itemCount_;e++){var r;let t=(r=this.getInput(`ATTR_${e}`))==null||(r=r.connection)==null?void 0:r.targetConnection;t&&!n.includes(t)&&t.disconnect()}this.itemCount_=n.length,this.itemCount_<0&&(this.itemCount_=0),this.updateShape_();for(let e=0;e<this.itemCount_;e++)s(n[e],this,`ATTR_${e}`)},saveConnections:function(e){let t=e.getInputTargetBlock(`STACK`),n=0;for(;t;){var r,i;let e=this.getInput(`ATTR_${n}`);t.valueConnection_=e==null||(r=e.connection)==null?void 0:r.targetConnection,n++,t=(i=t.nextConnection)==null?void 0:i.targetBlock()}},updateShape_:function(){let e=this.workspace;for(let t=0;t<this.itemCount_;t++){let r=this.getInput(`ATTR_${t}`);r?r.fieldRow[0].setValue(this.attributes_[t]):(r=this.appendValueInput(`ATTR_${t}`).setAlign(n.Align.RIGHT),r.appendField(this.attributes_[t])),setTimeout(t=>{var n;if(!((n=t.connection)!=null&&n.isConnected())){let n=e.newBlock(`text`);n.setShadow(!0),n.initSvg(),n.render(),n.outputConnection.connect(t.connection)}},100,r)}for(let e=this.itemCount_;this.getInput(`ATTR_${e}`);e++)this.removeInput(`ATTR_${e}`)}},a.forBlock.object_new=function(e){let t=e,n=[];for(let r=0;r<t.itemCount_;r++){let s=a.valueToCode(e,`ATTR_${r}`,i.COMMA);s&&n.push(`${o(t.attributes_[r])}: ${s}`)}return[`{ ${n.length?n.join(`, `):``} }`,i.ATOMIC]},c.Object.blocks.object_set_attr=`<block type="object_set_attr"> <field name="ATTR">attribute1</field> <value name="VALUE"> <shadow type="text"> <field name="TEXT">value</field> </shadow> </value></block>`,r.object_set_attr={init:function(){this.appendDummyInput(`ATTR`).appendField(l(`object_set_attr`)).appendField(new t(`attribute1`),`ATTR`),this.appendValueInput(`OBJECT`).appendField(l(`object_set_attr_object`)),this.appendValueInput(`VALUE`).setCheck(null).appendField(l(`object_set_attr_value`)),this.setInputsInline(!1),this.setPreviousStatement(!0,null),this.setNextStatement(!0,null),this.setColour(c.Object.HUE),this.setTooltip(l(`object_set_attr_tooltip`))}},a.forBlock.object_set_attr=function(e){let t=e.getFieldValue(`ATTR`),n=a.valueToCode(e,`VALUE`,i.ATOMIC),r=a.valueToCode(e,`OBJECT`,i.ATOMIC);return r||=`{}`,`((obj) => { if (typeof obj === 'object') { obj[${o(t)}] = ${n}; } })(${r});\n`},c.Object.blocks.object_del_attr=`<block type="object_del_attr"> <field name="ATTR">attribute1</field></block>`,r.object_del_attr={init:function(){this.appendDummyInput(`ATTR`).appendField(l(`object_del_attr`)).appendField(new t(`attribute1`),`ATTR`),this.appendValueInput(`OBJECT`).appendField(l(`object_del_attr_object`)),this.setInputsInline(!1),this.setPreviousStatement(!0,null),this.setNextStatement(!0,null),this.setColour(c.Object.HUE),this.setTooltip(l(`object_del_attr_tooltip`))}},a.forBlock.object_del_attr=function(e){let t=e.getFieldValue(`ATTR`),n=a.valueToCode(e,`OBJECT`,i.ATOMIC);return n||=`{}`,`((obj) => { if (typeof obj === 'object') { delete obj[${o(t)}]; } })(${n});\n`},c.Object.blocks.object_has_attr=`<block type="object_has_attr"> <field name="ATTR">attribute1</field> <value name="OBJECT"> <shadow type="get_object"> <field name="OID">Object ID</field> </shadow> </value></block>`,r.object_has_attr={init:function(){this.appendValueInput(`OBJECT`).appendField(l(`object_has_attr`)),this.appendDummyInput(`ATTR`).appendField(l(`object_has_attr_attr`)).appendField(new t(`attribute1`),`ATTR`),this.setInputsInline(!0),this.setOutput(!0,`Boolean`),this.setColour(c.Object.HUE),this.setTooltip(l(`object_has_attr_tooltip`))}},a.forBlock.object_has_attr=function(e){let t=a.valueToCode(e,`OBJECT`,i.ATOMIC),n=e.getFieldValue(`ATTR`);return[`Object.prototype.hasOwnProperty.call(${t}, ${o(n)})`,i.ATOMIC]},c.Object.blocks.object_keys=`<block type="object_keys"> <value name="OBJECT"> <shadow type="get_object"> <field name="OID">Object ID</field> </shadow> </value></block>`,r.object_keys={init:function(){this.appendValueInput(`OBJECT`).appendField(l(`object_keys`)),this.setInputsInline(!0),this.setOutput(!0,`Array`),this.setColour(c.Object.HUE),this.setTooltip(l(`object_keys_tooltip`))}},a.forBlock.object_keys=function(e){let t=a.valueToCode(e,`OBJECT`,i.ATOMIC);return t||=`{}`,[`Object.keys(${t})`,i.ATOMIC]}}export{c as install};
@@ -1,3 +1,3 @@
1
- import{f as e,h as t,l as n,o as r,s as i,t as a}from"./blockly-DBw-ytY1.js";import{c as o,l as s}from"./index-BnLv569U.js";import{FieldScript as c,b64DecodeUnicode as l}from"./field_script-Bs925umq.js";function u(e){return a[e]}function d(){let d=window.Blockly,f=d.Translate,p=t.xml,m=u(`procedures_ifreturn`);m.FUNCTION_TYPES.includes(`procedures_defcustomreturn`)||m.FUNCTION_TYPES.push(`procedures_defcustomreturn`),m.FUNCTION_TYPES.includes(`procedures_defcustomnoreturn`)||m.FUNCTION_TYPES.push(`procedures_defcustomnoreturn`),d.Procedures.allProceduresNew=function(e){let t=n.allProcedures(e),r=()=>e.getProcedureMap().getProcedures().filter(e=>!!e.getReturnTypes()).map(e=>[e.getName(),e.getParameters().map(e=>e.getName()),!0]),i=t=>{let i=r();return e.getBlocksByType(t,!1).forEach(e=>{n.isProcedureBlock(e)||i.push(e.getProcedureDef())}),i};return t.concat([i(`procedures_defcustomnoreturn`),i(`procedures_defcustomreturn`)])},d.Procedures.flyoutCategoryNew=function(e){let t=[],n=(e,n)=>{if(!a[e])return;let r=p.createElement(`block`);r.setAttribute(`type`,e),r.setAttribute(`gap`,`16`);let o=p.createElement(`field`);o.setAttribute(`name`,`NAME`),o.appendChild(p.createTextNode(i[n])),r.appendChild(o),t.push(r)},r=e=>{if(!a[e])return;let n=p.createElement(`block`);n.setAttribute(`type`,e),n.setAttribute(`gap`,`16`),t.push(n)};n(`procedures_defnoreturn`,`PROCEDURES_DEFNORETURN_PROCEDURE`),n(`procedures_defreturn`,`PROCEDURES_DEFRETURN_PROCEDURE`),r(`procedures_ifreturn`),r(`procedures_return`),n(`procedures_defcustomnoreturn`,`PROCEDURES_DEFNORETURN_PROCEDURE`),n(`procedures_defcustomreturn`,`PROCEDURES_DEFRETURN_PROCEDURE`),t.length&&t[t.length-1].setAttribute(`gap`,`24`);let o=(e,n)=>{for(let[r,i]of e){let e=p.createElement(`block`);e.setAttribute(`type`,n),e.setAttribute(`gap`,`16`);let a=p.createElement(`mutation`);a.setAttribute(`name`,r),e.appendChild(a);for(let e of i){let t=p.createElement(`arg`);t.setAttribute(`name`,e),a.appendChild(t)}t.push(e)}},s=d.Procedures.allProceduresNew(e);return o(s[0],`procedures_callnoreturn`),o(s[1],`procedures_callreturn`),o(s[2],`procedures_callcustomnoreturn`),o(s[3],`procedures_callcustomreturn`),t},s.forBlock.procedures_defreturn=function(e){let t=s,r=t.nameDB_.getName(e.getFieldValue(`NAME`),n.CATEGORY_NAME),i=``;t.STATEMENT_PREFIX&&(i+=t.injectId(t.STATEMENT_PREFIX,e)),t.STATEMENT_SUFFIX&&(i+=t.injectId(t.STATEMENT_SUFFIX,e)),i&&=t.prefixLines(i,t.INDENT);let a=``;t.INFINITE_LOOP_TRAP&&(a=t.prefixLines(t.injectId(t.INFINITE_LOOP_TRAP,e),t.INDENT));let c=``,l=``,u=e.getInput(`STACK`)?t.statementToCode(e,`STACK`):``;e.getInput(`RETURN`)&&(c=t.valueToCode(e,`RETURN`,o.NONE)||``,u&&c&&(l=i),c&&=`${t.INDENT}return ${c};\n`);let d=`async function ${r}(${e.getVarModels().map(e=>t.nameDB_.getName(e.name,`VARIABLE`)).join(`, `)}) {\n${i}${a}${u}${l}${c}}`;return d=t.scrub_(e,d),t.definitions_[`%${r}`]=d,null},s.forBlock.procedures_defnoreturn=s.forBlock.procedures_defreturn,s.forBlock.procedures_callreturn=function(e){let t=s;return[`await ${t.nameDB_.getName(e.getFieldValue(`NAME`),n.CATEGORY_NAME)}(${e.getVarModels().map((n,r)=>t.valueToCode(e,`ARG${r}`,o.NONE)||`null`).join(`, `)})`,o.FUNCTION_CALL]};let h=t=>{let o=t?`procedures_defcustomreturn`:`procedures_defcustomnoreturn`,s=u(t?`procedures_defreturn`:`procedures_defnoreturn`),l=t?`procedures_defcustomreturn_name`:`procedures_defcustomnoreturn_name`,d=t?`PROCEDURES_DEFRETURN`:`PROCEDURES_DEFNORETURN`;a[o]={getProcedureModel(){return this.model},isProcedureDef(){return!0},init:function(){var a;let o=new r(``,n.rename);o.setSpellcheck(!1),this.appendDummyInput().appendField(f(l)).appendField(o,`NAME`).appendField(``,`PARAMS`),this.setMutator(new e.MutatorIcon([`procedures_mutatorarg`],this));let s=this.workspace.options;(s.comments||(a=s.parentWorkspace)!=null&&a.options.comments)&&i[`${d}_COMMENT`]&&this.setCommentText(i[`${d}_COMMENT`]),this.setStyle(`procedure_blocks`),t||this.setColour(i.PROCEDURES_HUE),this.setTooltip(i[`${d}_TOOLTIP`]),this.setHelpUrl(i[`${d}_HELPURL`]),this.arguments_=[],this.argumentVarModels_=[],this.setStatements_(!0),this.statementConnection_=null,this.appendDummyInput(`SCRIPT`).appendField(new c(t?btoa(`return 0;`):``),`SCRIPT`),this.setInputsInline(!0),this.setStatements_(!1)},setStatements_:s.setStatements_,updateParams_:s.updateParams_,mutationToDom:s.mutationToDom,domToMutation:s.domToMutation,decompose:function(e){var t,r;let i=e.newBlock(`procedures_mutatorcontainer`);i.initSvg(),(t=i.getInput(`STATEMENT_INPUT`))==null||t.setVisible(!1);let a=(r=i.getInput(`STACK`))==null?void 0:r.connection;for(let t=0;t<this.arguments_.length;t++){let n=e.newBlock(`procedures_mutatorarg`);n.initSvg(),n.setFieldValue(this.arguments_[t],`NAME`),n.oldLocation=t,a.connect(n.previousConnection),a=n.nextConnection}return n.mutateCallers(this),i},compose:function(e){this.arguments_=[],this.paramIds_=[],this.argumentVarModels_=[];let t=e.getInputTargetBlock(`STACK`);for(;t&&!t.isInsertionMarker();){let e=t.getFieldValue(`NAME`);this.arguments_.push(e),this.argumentVarModels_.push(this.workspace.getVariableMap().getVariable(e,``)),this.paramIds_.push(t.id),t=t.nextConnection&&t.nextConnection.targetBlock()}this.updateParams_(),n.mutateCallers(this)},getProcedureDef:function(){return[this.getFieldValue(`NAME`),this.arguments_,t,!0]},getVarModels:s.getVarModels,renameVarById:s.renameVarById,updateVarName:s.updateVarName,displayRenamedVar_:s.displayRenamedVar_,customContextMenu:s.customContextMenu,callType_:t?`procedures_callcustomreturn`:`procedures_callcustomnoreturn`}},g=e=>{let t=e?`procedures_callcustomreturn`:`procedures_callcustomnoreturn`,n=u(e?`procedures_callreturn`:`procedures_callnoreturn`);a[t]={init:n.init,getProcedureCall:n.getProcedureCall,renameProcedure:n.renameProcedure,setProcedureParameters_:n.setProcedureParameters_,updateShape_:n.updateShape_,mutationToDom:n.mutationToDom,domToMutation:n.domToMutation,getVarModels:n.getVarModels,onchange:n.onchange,customContextMenu:n.customContextMenu,defType_:e?`procedures_defcustomreturn`:`procedures_defcustomnoreturn`}};h(!0),s.forBlock.procedures_defcustomreturn=function(e){let t=s,r=t.nameDB_.getName(e.getFieldValue(`NAME`),n.CATEGORY_NAME),i=e.arguments_.map(e=>t.nameDB_.getName(e,`VARIABLE`)),a=l(e.getFieldValue(`SCRIPT`)||``).split(`
1
+ import{f as e,h as t,l as n,o as r,s as i,t as a}from"./blockly-Fp-1_Ye3.js";import{c as o,l as s}from"./index-CqFiN-25.js";import{FieldScript as c,b64DecodeUnicode as l}from"./field_script-aZs3j-vG.js";function u(e){return a[e]}function d(){let d=window.Blockly,f=d.Translate,p=t.xml,m=u(`procedures_ifreturn`);m.FUNCTION_TYPES.includes(`procedures_defcustomreturn`)||m.FUNCTION_TYPES.push(`procedures_defcustomreturn`),m.FUNCTION_TYPES.includes(`procedures_defcustomnoreturn`)||m.FUNCTION_TYPES.push(`procedures_defcustomnoreturn`),d.Procedures.allProceduresNew=function(e){let t=n.allProcedures(e),r=()=>e.getProcedureMap().getProcedures().filter(e=>!!e.getReturnTypes()).map(e=>[e.getName(),e.getParameters().map(e=>e.getName()),!0]),i=t=>{let i=r();return e.getBlocksByType(t,!1).forEach(e=>{n.isProcedureBlock(e)||i.push(e.getProcedureDef())}),i};return t.concat([i(`procedures_defcustomnoreturn`),i(`procedures_defcustomreturn`)])},d.Procedures.flyoutCategoryNew=function(e){let t=[],n=(e,n)=>{if(!a[e])return;let r=p.createElement(`block`);r.setAttribute(`type`,e),r.setAttribute(`gap`,`16`);let o=p.createElement(`field`);o.setAttribute(`name`,`NAME`),o.appendChild(p.createTextNode(i[n])),r.appendChild(o),t.push(r)},r=e=>{if(!a[e])return;let n=p.createElement(`block`);n.setAttribute(`type`,e),n.setAttribute(`gap`,`16`),t.push(n)};n(`procedures_defnoreturn`,`PROCEDURES_DEFNORETURN_PROCEDURE`),n(`procedures_defreturn`,`PROCEDURES_DEFRETURN_PROCEDURE`),r(`procedures_ifreturn`),r(`procedures_return`),n(`procedures_defcustomnoreturn`,`PROCEDURES_DEFNORETURN_PROCEDURE`),n(`procedures_defcustomreturn`,`PROCEDURES_DEFRETURN_PROCEDURE`),t.length&&t[t.length-1].setAttribute(`gap`,`24`);let o=(e,n)=>{for(let[r,i]of e){let e=p.createElement(`block`);e.setAttribute(`type`,n),e.setAttribute(`gap`,`16`);let a=p.createElement(`mutation`);a.setAttribute(`name`,r),e.appendChild(a);for(let e of i){let t=p.createElement(`arg`);t.setAttribute(`name`,e),a.appendChild(t)}t.push(e)}},s=d.Procedures.allProceduresNew(e);return o(s[0],`procedures_callnoreturn`),o(s[1],`procedures_callreturn`),o(s[2],`procedures_callcustomnoreturn`),o(s[3],`procedures_callcustomreturn`),t},s.forBlock.procedures_defreturn=function(e){let t=s,r=t.nameDB_.getName(e.getFieldValue(`NAME`),n.CATEGORY_NAME),i=``;t.STATEMENT_PREFIX&&(i+=t.injectId(t.STATEMENT_PREFIX,e)),t.STATEMENT_SUFFIX&&(i+=t.injectId(t.STATEMENT_SUFFIX,e)),i&&=t.prefixLines(i,t.INDENT);let a=``;t.INFINITE_LOOP_TRAP&&(a=t.prefixLines(t.injectId(t.INFINITE_LOOP_TRAP,e),t.INDENT));let c=``,l=``,u=e.getInput(`STACK`)?t.statementToCode(e,`STACK`):``;e.getInput(`RETURN`)&&(c=t.valueToCode(e,`RETURN`,o.NONE)||``,u&&c&&(l=i),c&&=`${t.INDENT}return ${c};\n`);let d=`async function ${r}(${e.getVarModels().map(e=>t.nameDB_.getName(e.name,`VARIABLE`)).join(`, `)}) {\n${i}${a}${u}${l}${c}}`;return d=t.scrub_(e,d),t.definitions_[`%${r}`]=d,null},s.forBlock.procedures_defnoreturn=s.forBlock.procedures_defreturn,s.forBlock.procedures_callreturn=function(e){let t=s;return[`await ${t.nameDB_.getName(e.getFieldValue(`NAME`),n.CATEGORY_NAME)}(${e.getVarModels().map((n,r)=>t.valueToCode(e,`ARG${r}`,o.NONE)||`null`).join(`, `)})`,o.FUNCTION_CALL]};let h=t=>{let o=t?`procedures_defcustomreturn`:`procedures_defcustomnoreturn`,s=u(t?`procedures_defreturn`:`procedures_defnoreturn`),l=t?`procedures_defcustomreturn_name`:`procedures_defcustomnoreturn_name`,d=t?`PROCEDURES_DEFRETURN`:`PROCEDURES_DEFNORETURN`;a[o]={getProcedureModel(){return this.model},isProcedureDef(){return!0},init:function(){var a;let o=new r(``,n.rename);o.setSpellcheck(!1),this.appendDummyInput().appendField(f(l)).appendField(o,`NAME`).appendField(``,`PARAMS`),this.setMutator(new e.MutatorIcon([`procedures_mutatorarg`],this));let s=this.workspace.options;(s.comments||(a=s.parentWorkspace)!=null&&a.options.comments)&&i[`${d}_COMMENT`]&&this.setCommentText(i[`${d}_COMMENT`]),this.setStyle(`procedure_blocks`),t||this.setColour(i.PROCEDURES_HUE),this.setTooltip(i[`${d}_TOOLTIP`]),this.setHelpUrl(i[`${d}_HELPURL`]),this.arguments_=[],this.argumentVarModels_=[],this.setStatements_(!0),this.statementConnection_=null,this.appendDummyInput(`SCRIPT`).appendField(new c(t?btoa(`return 0;`):``),`SCRIPT`),this.setInputsInline(!0),this.setStatements_(!1)},setStatements_:s.setStatements_,updateParams_:s.updateParams_,mutationToDom:s.mutationToDom,domToMutation:s.domToMutation,decompose:function(e){var t,r;let i=e.newBlock(`procedures_mutatorcontainer`);i.initSvg(),(t=i.getInput(`STATEMENT_INPUT`))==null||t.setVisible(!1);let a=(r=i.getInput(`STACK`))==null?void 0:r.connection;for(let t=0;t<this.arguments_.length;t++){let n=e.newBlock(`procedures_mutatorarg`);n.initSvg(),n.setFieldValue(this.arguments_[t],`NAME`),n.oldLocation=t,a.connect(n.previousConnection),a=n.nextConnection}return n.mutateCallers(this),i},compose:function(e){this.arguments_=[],this.paramIds_=[],this.argumentVarModels_=[];let t=e.getInputTargetBlock(`STACK`);for(;t&&!t.isInsertionMarker();){let e=t.getFieldValue(`NAME`);this.arguments_.push(e),this.argumentVarModels_.push(this.workspace.getVariableMap().getVariable(e,``)),this.paramIds_.push(t.id),t=t.nextConnection&&t.nextConnection.targetBlock()}this.updateParams_(),n.mutateCallers(this)},getProcedureDef:function(){return[this.getFieldValue(`NAME`),this.arguments_,t,!0]},getVarModels:s.getVarModels,renameVarById:s.renameVarById,updateVarName:s.updateVarName,displayRenamedVar_:s.displayRenamedVar_,customContextMenu:s.customContextMenu,callType_:t?`procedures_callcustomreturn`:`procedures_callcustomnoreturn`}},g=e=>{let t=e?`procedures_callcustomreturn`:`procedures_callcustomnoreturn`,n=u(e?`procedures_callreturn`:`procedures_callnoreturn`);a[t]={init:n.init,getProcedureCall:n.getProcedureCall,renameProcedure:n.renameProcedure,setProcedureParameters_:n.setProcedureParameters_,updateShape_:n.updateShape_,mutationToDom:n.mutationToDom,domToMutation:n.domToMutation,getVarModels:n.getVarModels,onchange:n.onchange,customContextMenu:n.customContextMenu,defType_:e?`procedures_defcustomreturn`:`procedures_defcustomnoreturn`}};h(!0),s.forBlock.procedures_defcustomreturn=function(e){let t=s,r=t.nameDB_.getName(e.getFieldValue(`NAME`),n.CATEGORY_NAME),i=e.arguments_.map(e=>t.nameDB_.getName(e,`VARIABLE`)),a=l(e.getFieldValue(`SCRIPT`)||``).split(`
2
2
  `).map(e=>` ${e}`),o=`async function ${r}(${i.join(`, `)}) {\n${a.join(`
3
3
  `)}\n}`;return o=t.scrub_(e,o),t.definitions_[`%${r}`]=o,null},g(!0),s.forBlock.procedures_callcustomreturn=s.forBlock.procedures_callreturn,u(`procedures_ifreturn`).init=function(){let e=this.appendValueInput(`CONDITION`).setCheck(`Boolean`).appendField(i.CONTROLS_IF_MSG_IF),t=this.workspace.newBlock(`logic_boolean`);t.setShadow(!0),t.setFieldValue(`TRUE`,`BOOL`),t.outputConnection.connect(e.connection),this.appendValueInput(`VALUE`).appendField(i.PROCEDURES_DEFRETURN_RETURN),this.setInputsInline(!0),this.setPreviousStatement(!0),this.setNextStatement(!0),this.setStyle(`procedure_blocks`),this.setTooltip(i.PROCEDURES_IFRETURN_TOOLTIP),this.setHelpUrl(i.PROCEDURES_IFRETURN_HELPURL),this.hasReturnValue_=!0},h(!1),a.procedures_defcustomnoreturn.decompose=a.procedures_defcustomreturn.decompose,a.procedures_defcustomnoreturn.compose=a.procedures_defcustomreturn.compose,s.forBlock.procedures_defcustomnoreturn=s.forBlock.procedures_defcustomreturn,g(!1),s.forBlock.procedures_callcustomnoreturn=function(e){return`${s.forBlock.procedures_callcustomreturn(e,s)[0]};\n`},a.procedures_return={init:function(){this.appendValueInput(`VALUE`).appendField(i.PROCEDURES_DEFRETURN_RETURN),this.setInputsInline(!0),this.setPreviousStatement(!0),this.setNextStatement(!0),this.setStyle(`procedure_blocks`),this.setTooltip(i.PROCEDURES_IFRETURN_TOOLTIP),this.setHelpUrl(i.PROCEDURES_IFRETURN_HELPURL),this.hasReturnValue_=!0},mutationToDom:function(){let e=p.createElement(`mutation`);return e.setAttribute(`value`,String(Number(this.hasReturnValue_))),e},domToMutation:function(e){this.hasReturnValue_=e.getAttribute(`value`)===`1`,this.hasReturnValue_||(this.removeInput(`VALUE`),this.appendDummyInput(`VALUE`).appendField(i.PROCEDURES_DEFRETURN_RETURN))},onchange:function(e){var t,n;if((t=(n=this.workspace).isDragging)!=null&&t.call(n)||e.type!==`move`&&e.type!==`create`)return;let r=!1,a=this;do{if(this.FUNCTION_TYPES.includes(a.type)){r=!0;break}a=a.getSurroundParent()}while(a);r?(a.type===`procedures_defnoreturn`&&this.hasReturnValue_?(this.removeInput(`VALUE`),this.appendDummyInput(`VALUE`).appendField(i.PROCEDURES_DEFRETURN_RETURN),this.hasReturnValue_=!1):a.type===`procedures_defreturn`&&!this.hasReturnValue_&&(this.removeInput(`VALUE`),this.appendValueInput(`VALUE`).appendField(i.PROCEDURES_DEFRETURN_RETURN),this.hasReturnValue_=!0),this.setWarningText(null)):this.setWarningText(i.PROCEDURES_IFRETURN_WARNING),this.isInFlyout||this.setDisabledReason(!r,`UNPARENTED_IFRETURN`)},FUNCTION_TYPES:[`procedures_defnoreturn`,`procedures_defreturn`,`procedures_defcustomreturn`,`procedures_defcustomnoreturn`]},s.forBlock.procedures_return=function(e,t){let n=``;if(t.STATEMENT_SUFFIX&&(n+=t.prefixLines(t.injectId(t.STATEMENT_SUFFIX,e),t.INDENT)),e.hasReturnValue_){let r=t.valueToCode(e,`VALUE`,o.NONE)||`null`;n+=`${t.INDENT}return ${r};\n`}else n+=`${t.INDENT}return;\n`;return n}}export{d as install};
@@ -1,4 +1,4 @@
1
- import{f as e,i as t,o as n,p as r,r as i,t as a}from"./blockly-DBw-ytY1.js";import{c as o,l as s}from"./index-BnLv569U.js";import{c,d as l,i as u,l as d,r as f,s as p}from"./helpers-BFQD9R82.js";function m(e,t){let n=parseFloat(e);return t===`min`?n*6e4:t===`sec`?n*1e3:n}function h(){let h=window.Blockly,g=h.Translate,_=window.getHelp;h.CustomBlocks=h.CustomBlocks||[],h.CustomBlocks.push(`Sendto`),h.Sendto={HUE:310,blocks:{}};let v=()=>new i(`FALSE`,function(e){this.getSourceBlock().updateShape_(f(e))});h.Sendto.blocks.sendto_custom=`<block type="sendto_custom"> <mutation xmlns="http://www.w3.org/1999/xhtml" items="parameter"></mutation> <field name="INSTANCE">admin.0</field> <field name="COMMAND">send</field> <field name="LOG"></field> <field name="WITH_STATEMENT">FALSE</field> <value name="ARG0"> <shadow type="text"> <field name="TEXT"></field> </shadow> </value></block>`,a.sendto_custom_container={init:function(){this.appendDummyInput().appendField(g(`sendto_custom_arguments`)),this.appendStatementInput(`STACK`),this.setColour(h.Sendto.HUE),this.setTooltip(g(`sendto_custom_arg_tooltip`)),this.contextMenu=!1}},a.sendto_custom_mutator={init:function(){this.appendDummyInput(`ATTR`).appendField(g(`sendto_custom_argument`)).appendField(new n(`parameter`),`ATTR`),this.setPreviousStatement(!0),this.setNextStatement(!0),this.setColour(h.Sendto.HUE),this.setTooltip(g(`sendto_custom_arg_tooltip`)),this.contextMenu=!1}},a.sendto_custom={init:function(){var r;let i=[];if((r=window.main)!=null&&r.instances){for(let e of window.main.instances){var a;if((a=window.main.objects[e])!=null&&(a=a.common)!=null&&a.messagebox){let t=e.substring(15);i.push([t,t])}}i.length||i.push([g(`sendto_no_instances`),``]),this.appendDummyInput(`INSTANCE`).appendField(g(`sendto_custom`)).appendField(new t(i),`INSTANCE`)}else this.appendDummyInput(`INSTANCE`).appendField(g(`sendto_custom`)).appendField(new n(`adapter.0`),`INSTANCE`);this.appendDummyInput(`COMMAND`).appendField(g(`sendto_custom_command`)).appendField(new n(`send`),`COMMAND`),this.appendDummyInput(`LOG`).appendField(g(`loglevel`)).appendField(new t(u()),`LOG`),this.appendDummyInput(`WITH_STATEMENT`).appendField(g(`with_results`)).appendField(v(),`WITH_STATEMENT`),this.attributes_=[],this.itemCount_=0,this.setMutator(new e.MutatorIcon([`sendto_custom_mutator`],this)),this.updateShape_(),this.setInputsInline(!1),this.setPreviousStatement(!0,null),this.setNextStatement(!0,null),this.setColour(h.Sendto.HUE),this.setTooltip(g(`sendto_custom_tooltip`)),this.setHelpUrl(_(`sendto_custom_help`))},mutationToDom:function(){let e=document.createElement(`mutation`);return e.setAttribute(`items`,this.attributes_.map(e=>encodeURIComponent(e)).join(`,`)),e},domToMutation:function(e){this.attributes_=e.getAttribute(`items`).split(`,`).map(e=>decodeURIComponent(e)),this.itemCount_=this.attributes_.length,this.updateShape_()},decompose:function(e){var t;let n=e.newBlock(`sendto_custom_container`);n.initSvg();let r=(t=n.getInput(`STACK`))==null?void 0:t.connection;for(let t=0;t<this.itemCount_;t++){let n=e.newBlock(`sendto_custom_mutator`);n.setFieldValue(this.attributes_[t],`ATTR`),n.initSvg(),r.connect(n.previousConnection),r=n.nextConnection}return n},compose:function(e){this.attributes_=[];let t=e.getInputTargetBlock(`STACK`),n=[];for(;t;)this.attributes_.push(t.getFieldValue(`ATTR`)),n.push(t.valueConnection_),t=t.nextConnection&&t.nextConnection.targetBlock();for(let e=0;e<this.itemCount_;e++){var r;let t=(r=this.getInput(`ARG${e}`))==null||(r=r.connection)==null?void 0:r.targetConnection;t&&!n.includes(t)&&t.disconnect()}this.itemCount_=n.length,this.itemCount_<0&&(this.itemCount_=0),this.updateShape_();for(let e=0;e<this.itemCount_;e++)d(n[e],this,`ARG${e}`)},saveConnections:function(e){let t=e.getInputTargetBlock(`STACK`),n=0;for(;t;){var r,i;t.valueConnection_=(r=this.getInput(`ARG${n}`))==null||(r=r.connection)==null?void 0:r.targetConnection,t=(i=t.nextConnection)==null?void 0:i.targetBlock(),n++}},updateShape_:function(e){let t=this.workspace;for(let e=0;e<this.itemCount_;e++){let n=this.getInput(`ARG${e}`);n?n.fieldRow.length>=1&&n.fieldRow[0].setValue(this.attributes_[e]):(n=this.appendValueInput(`ARG${e}`).setAlign(r.Align.RIGHT),n.appendField(this.attributes_[e])),setTimeout(e=>{var n;if(!((n=e.connection)!=null&&n.isConnected())){let n=t.newBlock(`text`);n.setShadow(!0),n.initSvg(),n.render(),n.outputConnection.connect(e.connection)}},100,n)}for(let e=this.itemCount_;this.getInput(`ARG${e}`);e++)this.removeInput(`ARG${e}`);l(this,e)}},s.forBlock.sendto_custom=function(e){let t=e,n=e.getFieldValue(`INSTANCE`),r=e.getFieldValue(`LOG`),i=e.getFieldValue(`COMMAND`),a=``,l;f(e.getFieldValue(`WITH_STATEMENT`))&&(l=s.statementToCode(e,`STATEMENT`));let u=[];for(let d=0;d<t.itemCount_;d++){let f=String(t.attributes_[d]),p=s.valueToCode(e,`ARG${d}`,o.COMMA);if(p&&p.startsWith(`'{`)&&p.endsWith(`}'`)&&(p=p.substring(1,p.length-1)),t.itemCount_===1&&!f)return r&&(a=`console.${r}('sendTo[custom] ${n}: ' + ${p});\n`),l?`sendTo('${n}', ${c(i)}, ${p}, async (result) => {\n${l}});\n${a}`:`sendTo('${n}', ${c(i)}, ${p});\n${a}`;u.push({attr:f.replace(/'/g,`\\'`),val:p})}let d=u.length?u.map(e=>s.prefixLines(`'${e.attr}': ${e.val},`,s.INDENT)).join(`
1
+ import{f as e,i as t,o as n,p as r,r as i,t as a}from"./blockly-Fp-1_Ye3.js";import{c as o,l as s}from"./index-CqFiN-25.js";import{c,d as l,i as u,l as d,r as f,s as p}from"./helpers-CalO_DDQ.js";function m(e,t){let n=parseFloat(e);return t===`min`?n*6e4:t===`sec`?n*1e3:n}function h(){let h=window.Blockly,g=h.Translate,_=window.getHelp;h.CustomBlocks=h.CustomBlocks||[],h.CustomBlocks.push(`Sendto`),h.Sendto={HUE:310,blocks:{}};let v=()=>new i(`FALSE`,function(e){this.getSourceBlock().updateShape_(f(e))});h.Sendto.blocks.sendto_custom=`<block type="sendto_custom"> <mutation xmlns="http://www.w3.org/1999/xhtml" items="parameter"></mutation> <field name="INSTANCE">admin.0</field> <field name="COMMAND">send</field> <field name="LOG"></field> <field name="WITH_STATEMENT">FALSE</field> <value name="ARG0"> <shadow type="text"> <field name="TEXT"></field> </shadow> </value></block>`,a.sendto_custom_container={init:function(){this.appendDummyInput().appendField(g(`sendto_custom_arguments`)),this.appendStatementInput(`STACK`),this.setColour(h.Sendto.HUE),this.setTooltip(g(`sendto_custom_arg_tooltip`)),this.contextMenu=!1}},a.sendto_custom_mutator={init:function(){this.appendDummyInput(`ATTR`).appendField(g(`sendto_custom_argument`)).appendField(new n(`parameter`),`ATTR`),this.setPreviousStatement(!0),this.setNextStatement(!0),this.setColour(h.Sendto.HUE),this.setTooltip(g(`sendto_custom_arg_tooltip`)),this.contextMenu=!1}},a.sendto_custom={init:function(){var r;let i=[];if((r=window.main)!=null&&r.instances){for(let e of window.main.instances){var a;if((a=window.main.objects[e])!=null&&(a=a.common)!=null&&a.messagebox){let t=e.substring(15);i.push([t,t])}}i.length||i.push([g(`sendto_no_instances`),``]),this.appendDummyInput(`INSTANCE`).appendField(g(`sendto_custom`)).appendField(new t(i),`INSTANCE`)}else this.appendDummyInput(`INSTANCE`).appendField(g(`sendto_custom`)).appendField(new n(`adapter.0`),`INSTANCE`);this.appendDummyInput(`COMMAND`).appendField(g(`sendto_custom_command`)).appendField(new n(`send`),`COMMAND`),this.appendDummyInput(`LOG`).appendField(g(`loglevel`)).appendField(new t(u()),`LOG`),this.appendDummyInput(`WITH_STATEMENT`).appendField(g(`with_results`)).appendField(v(),`WITH_STATEMENT`),this.attributes_=[],this.itemCount_=0,this.setMutator(new e.MutatorIcon([`sendto_custom_mutator`],this)),this.updateShape_(),this.setInputsInline(!1),this.setPreviousStatement(!0,null),this.setNextStatement(!0,null),this.setColour(h.Sendto.HUE),this.setTooltip(g(`sendto_custom_tooltip`)),this.setHelpUrl(_(`sendto_custom_help`))},mutationToDom:function(){let e=document.createElement(`mutation`);return e.setAttribute(`items`,this.attributes_.map(e=>encodeURIComponent(e)).join(`,`)),e},domToMutation:function(e){this.attributes_=e.getAttribute(`items`).split(`,`).map(e=>decodeURIComponent(e)),this.itemCount_=this.attributes_.length,this.updateShape_()},decompose:function(e){var t;let n=e.newBlock(`sendto_custom_container`);n.initSvg();let r=(t=n.getInput(`STACK`))==null?void 0:t.connection;for(let t=0;t<this.itemCount_;t++){let n=e.newBlock(`sendto_custom_mutator`);n.setFieldValue(this.attributes_[t],`ATTR`),n.initSvg(),r.connect(n.previousConnection),r=n.nextConnection}return n},compose:function(e){this.attributes_=[];let t=e.getInputTargetBlock(`STACK`),n=[];for(;t;)this.attributes_.push(t.getFieldValue(`ATTR`)),n.push(t.valueConnection_),t=t.nextConnection&&t.nextConnection.targetBlock();for(let e=0;e<this.itemCount_;e++){var r;let t=(r=this.getInput(`ARG${e}`))==null||(r=r.connection)==null?void 0:r.targetConnection;t&&!n.includes(t)&&t.disconnect()}this.itemCount_=n.length,this.itemCount_<0&&(this.itemCount_=0),this.updateShape_();for(let e=0;e<this.itemCount_;e++)d(n[e],this,`ARG${e}`)},saveConnections:function(e){let t=e.getInputTargetBlock(`STACK`),n=0;for(;t;){var r,i;t.valueConnection_=(r=this.getInput(`ARG${n}`))==null||(r=r.connection)==null?void 0:r.targetConnection,t=(i=t.nextConnection)==null?void 0:i.targetBlock(),n++}},updateShape_:function(e){let t=this.workspace;for(let e=0;e<this.itemCount_;e++){let n=this.getInput(`ARG${e}`);n?n.fieldRow.length>=1&&n.fieldRow[0].setValue(this.attributes_[e]):(n=this.appendValueInput(`ARG${e}`).setAlign(r.Align.RIGHT),n.appendField(this.attributes_[e])),setTimeout(e=>{var n;if(!((n=e.connection)!=null&&n.isConnected())){let n=t.newBlock(`text`);n.setShadow(!0),n.initSvg(),n.render(),n.outputConnection.connect(e.connection)}},100,n)}for(let e=this.itemCount_;this.getInput(`ARG${e}`);e++)this.removeInput(`ARG${e}`);l(this,e)}},s.forBlock.sendto_custom=function(e){let t=e,n=e.getFieldValue(`INSTANCE`),r=e.getFieldValue(`LOG`),i=e.getFieldValue(`COMMAND`),a=``,l;f(e.getFieldValue(`WITH_STATEMENT`))&&(l=s.statementToCode(e,`STATEMENT`));let u=[];for(let d=0;d<t.itemCount_;d++){let f=String(t.attributes_[d]),p=s.valueToCode(e,`ARG${d}`,o.COMMA);if(p&&p.startsWith(`'{`)&&p.endsWith(`}'`)&&(p=p.substring(1,p.length-1)),t.itemCount_===1&&!f)return r&&(a=`console.${r}('sendTo[custom] ${n}: ' + ${p});\n`),l?`sendTo('${n}', ${c(i)}, ${p}, async (result) => {\n${l}});\n${a}`:`sendTo('${n}', ${c(i)}, ${p});\n${a}`;u.push({attr:f.replace(/'/g,`\\'`),val:p})}let d=u.length?u.map(e=>s.prefixLines(`'${e.attr}': ${e.val},`,s.INDENT)).join(`
2
2
  `):``;return r&&(a=`console.${r}('sendTo[custom] ${n}: ${u.length?u.map(e=>`${e.attr}: ' + ${e.val} + '`).join(`, `):`[no args]`}');\n`),l?`sendTo('${n}', ${c(i)}, {\n${d}\n}, async (result) => {\n${l}});\n${a}`:`sendTo('${n}', ${c(i)}, {\n${d}\n});\n${a}`},h.Sendto.blocks.sendto_otherscript=`<block type="sendto_otherscript"> <field name="INSTANCE">0</field> <field name="TIMEOUT">1000</field> <field name="UNIT">ms</field> <field name="MESSAGE">customMessage</field> <field name="WITH_STATEMENT">FALSE</field> <value name="OID"> <shadow type="field_oid_script"> <field name="oid">Script Object ID</field> </shadow> </value></block>`,a.sendto_otherscript={init:function(){var e;let r=[];if((e=window.main)!=null&&e.instances)for(let e of window.main.instances){let t=e.match(/^system\.adapter\.javascript\.(\d+)$/);if(t){let e=parseInt(t[1],10);r.push([`javascript.${e}`,String(e)])}}if(!r.length)for(let e=0;e<=4;e++)r.push([`javascript.${e}`,String(e)]);this.appendDummyInput(`NAME`).appendField(`✉️ ${g(`sendto_otherscript_name`)}`),this.appendDummyInput(`INSTANCE`).appendField(g(`sendto_otherscript_instance`)).appendField(new t(r),`INSTANCE`),this.appendValueInput(`OID`).appendField(g(`sendto_otherscript_script`)).setCheck(null),this.appendDummyInput().appendField(g(`sendto_otherscript_timeout`)).appendField(new n(`1000`),`TIMEOUT`).appendField(new t([[g(`timeouts_settimeout_ms`),`ms`],[g(`timeouts_settimeout_sec`),`sec`],[g(`timeouts_settimeout_min`),`min`]]),`UNIT`),this.appendDummyInput(`MESSAGE`).appendField(g(`sendto_otherscript_message`)).appendField(new n(`customMessage`),`MESSAGE`),this.appendValueInput(`DATA`).appendField(g(`sendto_otherscript_data`)),this.appendDummyInput(`WITH_STATEMENT`).appendField(g(`with_results`)).appendField(v(),`WITH_STATEMENT`),this.updateShape_(),this.setInputsInline(!1),this.setPreviousStatement(!0,null),this.setNextStatement(!0,null),this.setColour(h.Sendto.HUE),this.setTooltip(g(`sendto_otherscript_tooltip`)),this.setHelpUrl(_(`sendto_otherscript_help`))},updateShape_:function(e){l(this,e)}},s.forBlock.sendto_otherscript=function(e){let t=e.getFieldValue(`INSTANCE`),n=s.valueToCode(e,`OID`,o.ATOMIC),r=e.getFieldValue(`MESSAGE`),i=m(e.getFieldValue(`TIMEOUT`),e.getFieldValue(`UNIT`)),a;f(e.getFieldValue(`WITH_STATEMENT`))&&(a=s.statementToCode(e,`STATEMENT`));let l=p(n),u=s.valueToCode(e,`DATA`,o.ATOMIC)||`true`,d=`{ instance: ${t}, script: ${n}${l?` /* ${l} */`:``}, message: ${c(r)} }`;return a?`messageTo(${d}, ${u}, { timeout: ${i} }, (result) => {\n${a}})\n`:`messageTo(${d}, ${u}, { timeout: ${i} });\n`},h.Sendto.blocks.sendto_gethistory=`<block type="sendto_gethistory"> <field name="INSTANCE">default</field> <field name="AGGREGATE">none</field> <field name="STEP">0</field> <field name="COUNT">500</field> <field name="UNIT">min</field> <value name="OID"> <shadow type="field_oid"> </shadow> </value> <value name="START"> <shadow type="time_get_special"> <field name="TYPE">dayStart</field> </shadow> </value> <value name="END"> <shadow type="time_get_special"> <field name="TYPE">dayEnd</field> </shadow> </value></block>`,a.sendto_gethistory={init:function(){var e;let r=[[`default`,`default`]];if((e=window.main)!=null&&e.instances)for(let e of window.main.instances){let t=e.match(/^system\.adapter\.(history|influxdb|sql)\.(\d+)$/);if(t){let e=`${t[1]}.${t[2]}`;r.push([e,e])}}this.appendDummyInput(`NAME`).appendField(g(`sendto_gethistory_name`)),this.appendDummyInput(`INSTANCE`).appendField(g(`sendto_gethistory_instance`)).appendField(new t(r),`INSTANCE`),this.appendValueInput(`OID`).appendField(g(`sendto_gethistory_oid`)).setCheck(null),this.appendValueInput(`START`).appendField(g(`sendto_gethistory_start`)).setCheck(null),this.appendValueInput(`END`).appendField(g(`sendto_gethistory_end`)).setCheck(null),this.appendDummyInput(`AGGREGATE`).appendField(g(`sendto_gethistory_aggregate`)).appendField(new t([[g(`sendto_gethistory_none`),`none`],[g(`sendto_gethistory_minimum`),`min`],[g(`sendto_gethistory_maximum`),`max`],[g(`sendto_gethistory_avg`),`average`],[g(`sendto_gethistory_cnt`),`count`]]),`AGGREGATE`),this.appendDummyInput(`UNIT`).appendField(g(`sendto_gethistory_step`)).appendField(new n(`0`),`STEP`).appendField(new t([[g(`sendto_gethistory_ms`),`ms`],[g(`sendto_gethistory_sec`),`sec`],[g(`sendto_gethistory_min`),`min`],[g(`sendto_gethistory_hour`),`hour`],[g(`sendto_gethistory_day`),`day`]]),`UNIT`),this.appendDummyInput(`COUNT`).appendField(g(`sendto_gethistory_count`)).appendField(new n(`0`),`COUNT`),this.appendStatementInput(`STATEMENT`).setCheck(null),this.setInputsInline(!1),this.setPreviousStatement(!0,null),this.setNextStatement(!0,null),this.setColour(h.Sendto.HUE),this.setTooltip(g(`sendto_gethistory_tooltip`)),this.setHelpUrl(_(`sendto_gethistory_help`))}},s.forBlock.sendto_gethistory=function(e){let t=e.getFieldValue(`INSTANCE`),n=s.valueToCode(e,`OID`,o.ATOMIC),r=s.valueToCode(e,`START`,o.ATOMIC),i=s.valueToCode(e,`END`,o.ATOMIC),a=e.getFieldValue(`AGGREGATE`),l=e.getFieldValue(`UNIT`),u=parseInt(e.getFieldValue(`COUNT`),10),d=parseFloat(e.getFieldValue(`STEP`));l===`day`?d*=864e5:l===`hour`?d*=36e5:l===`min`?d*=6e4:l===`sec`&&(d*=1e3);let f=s.statementToCode(e,`STATEMENT`),m=p(n);return`getHistory(${t==="default"?``:`${c(t)}, `}{\n id: ${n}${m?` /* ${m} */`:``},\n start: ${r},\n end: ${i},\n`+(d>0&&a!==`none`?` step: ${d},\n`:``)+(d===0||a===`none`?` count: ${u},\n`:``)+` aggregate: '${a}',\n removeBorderValues: true,\n}, async (err, result) => {\n if (err) {\n console.error(err);\n`+(f?` } else {
3
3
  `:``)+(f?s.prefixLines(f,s.INDENT):``)+` }
4
4
  });
@@ -1,2 +1,2 @@
1
- import{f as e,t}from"./blockly-DBw-ytY1.js";import{c as n,l as r}from"./index-BnLv569U.js";function i(){let i=window.Blockly.Translate;t.logic_switch_case={init:function(){this.appendValueInput(`CONDITION`).appendField(i(`logic_switch_case_is`)),this.appendValueInput(`CASECONDITION0`).appendField(i(`logic_switch_case_of`)),this.appendStatementInput(`CASE0`).appendField(i(`logic_switch_do`)),this.setMutator(new e.MutatorIcon([`case_incaseof`,`case_default`],this)),this.setPreviousStatement(!0),this.setNextStatement(!0),this.setColour(`%{BKY_LOGIC_HUE}`),this.setTooltip(i(`logic_switch_tooltip`)),this.caseCount_=0,this.defaultCount_=0},mutationToDom:function(){if(!this.caseCount_&&!this.defaultCount_)return null;let e=document.createElement(`mutation`);return this.caseCount_&&e.setAttribute(`case`,String(this.caseCount_)),this.defaultCount_&&e.setAttribute(`default`,`1`),e},domToMutation:function(e){this.caseCount_=parseInt(e.getAttribute(`case`),10),this.defaultCount_=parseInt(e.getAttribute(`default`),10);for(let e=1;e<=this.caseCount_;e++)this.appendValueInput(`CASECONDITION${e}`).appendField(i(`logic_switch_case_of`)),this.appendStatementInput(`CASE${e}`).appendField(i(`logic_switch_do`));this.defaultCount_&&this.appendStatementInput(`ONDEFAULT`).appendField(`default`)},decompose:function(e){var t;let n=e.newBlock(`control_case`);n.initSvg();let r=(t=n.getInput(`STACK`))==null?void 0:t.connection;for(let t=1;t<=this.caseCount_;t++){let t=e.newBlock(`case_incaseof`);t.initSvg(),r.connect(t.previousConnection),r=t.nextConnection}if(this.defaultCount_){let t=e.newBlock(`case_default`);t.initSvg(),r.connect(t.previousConnection)}return n},compose:function(e){this.defaultCount_&&this.removeInput(`ONDEFAULT`),this.defaultCount_=0;for(let e=this.caseCount_;e>0;e--)this.removeInput(`CASECONDITION${e}`),this.removeInput(`CASE${e}`);this.caseCount_=0;let t=e.getInputTargetBlock(`STACK`);for(;t;){switch(t.type){case`case_incaseof`:{this.caseCount_++;let e=this.appendValueInput(`CASECONDITION${this.caseCount_}`).appendField(i(`logic_switch_case_of`)),a=this.appendStatementInput(`CASE${this.caseCount_}`).appendField(i(`logic_switch_do`));if(t.valueConnection_){var n;(n=e.connection)==null||n.connect(t.valueConnection_)}if(t.statementConnection_){var r;(r=a.connection)==null||r.connect(t.statementConnection_)}break}case`case_default`:{this.defaultCount_++;let e=this.appendStatementInput(`ONDEFAULT`).appendField(`default`);if(t.statementConnection_){var a;(a=e.connection)==null||a.connect(t.statementConnection_)}break}default:throw`Unknown block type.`}t=t.nextConnection&&t.nextConnection.targetBlock()}},saveConnections:function(e){let t=e.getInputTargetBlock(`STACK`),n=1;for(;t;){var r;switch(t.type){case`case_incaseof`:{var i,a;let e=this.getInput(`CASECONDITION${n}`),r=this.getInput(`CASE${n}`);t.valueConnection_=e==null||(i=e.connection)==null?void 0:i.targetConnection,t.statementConnection_=r==null||(a=r.connection)==null?void 0:a.targetConnection,n++;break}case`case_default`:{var o;let e=this.getInput(`ONDEFAULT`);t.statementConnection_=e==null||(o=e.connection)==null?void 0:o.targetConnection;break}default:throw`Unknown block type`}t=(r=t.nextConnection)==null?void 0:r.targetBlock()}}},t.control_case={init:function(){this.appendDummyInput().appendField(i(`logic_switch_case_is`)),this.appendStatementInput(`STACK`),this.setColour(`%{BKY_LOGIC_HUE}`),this.setTooltip(i(`logic_switch_control_case_tooltip`)),this.contextMenu=!1}},t.case_incaseof={init:function(){this.appendDummyInput().appendField(i(`logic_switch_case_of`)),this.setPreviousStatement(!0),this.setNextStatement(!0),this.setColour(`%{BKY_LOGIC_HUE}`),this.setTooltip(i(`logic_switch_case_incaseof_tooltip`)),this.contextMenu=!1}},t.case_default={init:function(){this.appendDummyInput().appendField(`default`),this.setPreviousStatement(!0),this.setNextStatement(!1),this.setColour(`%{BKY_LOGIC_HUE}`),this.setTooltip(i(`logic_switch_default_tooltip`)),this.contextMenu=!1}},r.forBlock.logic_switch_case=function(e){let t=e,i=``,a,o,s=r.valueToCode(e,`CONDITION`,n.NONE)||null;if(s){if(/^\(?([._$\d\w"'?: ()])*\)?$/g.test(s)){i=`\nswitch (${s}) {\n`;let c=r.valueToCode(e,`CASECONDITION0`,n.NONE)||null,l=r.statementToCode(e,`CASE0`);i+=`\tcase ${c}:\n${l}\n\t\tbreak;\n`;for(let s=1;s<=t.caseCount_;s++)o=r.valueToCode(e,`CASECONDITION${s}`,n.NONE)||null,o&&(a=r.statementToCode(e,`CASE${s}`),i+=`\tcase ${o}:\n${a}\n\t\tbreak;\n`);t.defaultCount_&&(a=r.statementToCode(e,`ONDEFAULT`),i+=`\tdefault:\n${a}\n\t\tbreak;\n`),i+=`}
1
+ import{f as e,t}from"./blockly-Fp-1_Ye3.js";import{c as n,l as r}from"./index-CqFiN-25.js";function i(){let i=window.Blockly.Translate;t.logic_switch_case={init:function(){this.appendValueInput(`CONDITION`).appendField(i(`logic_switch_case_is`)),this.appendValueInput(`CASECONDITION0`).appendField(i(`logic_switch_case_of`)),this.appendStatementInput(`CASE0`).appendField(i(`logic_switch_do`)),this.setMutator(new e.MutatorIcon([`case_incaseof`,`case_default`],this)),this.setPreviousStatement(!0),this.setNextStatement(!0),this.setColour(`%{BKY_LOGIC_HUE}`),this.setTooltip(i(`logic_switch_tooltip`)),this.caseCount_=0,this.defaultCount_=0},mutationToDom:function(){if(!this.caseCount_&&!this.defaultCount_)return null;let e=document.createElement(`mutation`);return this.caseCount_&&e.setAttribute(`case`,String(this.caseCount_)),this.defaultCount_&&e.setAttribute(`default`,`1`),e},domToMutation:function(e){this.caseCount_=parseInt(e.getAttribute(`case`),10),this.defaultCount_=parseInt(e.getAttribute(`default`),10);for(let e=1;e<=this.caseCount_;e++)this.appendValueInput(`CASECONDITION${e}`).appendField(i(`logic_switch_case_of`)),this.appendStatementInput(`CASE${e}`).appendField(i(`logic_switch_do`));this.defaultCount_&&this.appendStatementInput(`ONDEFAULT`).appendField(`default`)},decompose:function(e){var t;let n=e.newBlock(`control_case`);n.initSvg();let r=(t=n.getInput(`STACK`))==null?void 0:t.connection;for(let t=1;t<=this.caseCount_;t++){let t=e.newBlock(`case_incaseof`);t.initSvg(),r.connect(t.previousConnection),r=t.nextConnection}if(this.defaultCount_){let t=e.newBlock(`case_default`);t.initSvg(),r.connect(t.previousConnection)}return n},compose:function(e){this.defaultCount_&&this.removeInput(`ONDEFAULT`),this.defaultCount_=0;for(let e=this.caseCount_;e>0;e--)this.removeInput(`CASECONDITION${e}`),this.removeInput(`CASE${e}`);this.caseCount_=0;let t=e.getInputTargetBlock(`STACK`);for(;t;){switch(t.type){case`case_incaseof`:{this.caseCount_++;let e=this.appendValueInput(`CASECONDITION${this.caseCount_}`).appendField(i(`logic_switch_case_of`)),a=this.appendStatementInput(`CASE${this.caseCount_}`).appendField(i(`logic_switch_do`));if(t.valueConnection_){var n;(n=e.connection)==null||n.connect(t.valueConnection_)}if(t.statementConnection_){var r;(r=a.connection)==null||r.connect(t.statementConnection_)}break}case`case_default`:{this.defaultCount_++;let e=this.appendStatementInput(`ONDEFAULT`).appendField(`default`);if(t.statementConnection_){var a;(a=e.connection)==null||a.connect(t.statementConnection_)}break}default:throw`Unknown block type.`}t=t.nextConnection&&t.nextConnection.targetBlock()}},saveConnections:function(e){let t=e.getInputTargetBlock(`STACK`),n=1;for(;t;){var r;switch(t.type){case`case_incaseof`:{var i,a;let e=this.getInput(`CASECONDITION${n}`),r=this.getInput(`CASE${n}`);t.valueConnection_=e==null||(i=e.connection)==null?void 0:i.targetConnection,t.statementConnection_=r==null||(a=r.connection)==null?void 0:a.targetConnection,n++;break}case`case_default`:{var o;let e=this.getInput(`ONDEFAULT`);t.statementConnection_=e==null||(o=e.connection)==null?void 0:o.targetConnection;break}default:throw`Unknown block type`}t=(r=t.nextConnection)==null?void 0:r.targetBlock()}}},t.control_case={init:function(){this.appendDummyInput().appendField(i(`logic_switch_case_is`)),this.appendStatementInput(`STACK`),this.setColour(`%{BKY_LOGIC_HUE}`),this.setTooltip(i(`logic_switch_control_case_tooltip`)),this.contextMenu=!1}},t.case_incaseof={init:function(){this.appendDummyInput().appendField(i(`logic_switch_case_of`)),this.setPreviousStatement(!0),this.setNextStatement(!0),this.setColour(`%{BKY_LOGIC_HUE}`),this.setTooltip(i(`logic_switch_case_incaseof_tooltip`)),this.contextMenu=!1}},t.case_default={init:function(){this.appendDummyInput().appendField(`default`),this.setPreviousStatement(!0),this.setNextStatement(!1),this.setColour(`%{BKY_LOGIC_HUE}`),this.setTooltip(i(`logic_switch_default_tooltip`)),this.contextMenu=!1}},r.forBlock.logic_switch_case=function(e){let t=e,i=``,a,o,s=r.valueToCode(e,`CONDITION`,n.NONE)||null;if(s){if(/^\(?([._$\d\w"'?: ()])*\)?$/g.test(s)){i=`\nswitch (${s}) {\n`;let c=r.valueToCode(e,`CASECONDITION0`,n.NONE)||null,l=r.statementToCode(e,`CASE0`);i+=`\tcase ${c}:\n${l}\n\t\tbreak;\n`;for(let s=1;s<=t.caseCount_;s++)o=r.valueToCode(e,`CASECONDITION${s}`,n.NONE)||null,o&&(a=r.statementToCode(e,`CASE${s}`),i+=`\tcase ${o}:\n${a}\n\t\tbreak;\n`);t.defaultCount_&&(a=r.statementToCode(e,`ONDEFAULT`),i+=`\tdefault:\n${a}\n\t\tbreak;\n`),i+=`}
2
2
  `}else alert(`logic_switch_case: ${s} is not a variable name`)}return i}}export{i as install};