iobroker.javascript 10.2.5 → 10.4.0

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 (205) hide show
  1. package/README.md +26 -23
  2. package/admin/assets/AiChatPanel-BjRIKaXG.js +27 -0
  3. package/admin/assets/{AiChatService-BOL3J2Jd.js → AiChatService-DP1EmVk2.js} +3 -3
  4. package/admin/assets/AiDiffView-DeynDw7L.js +1 -0
  5. package/admin/assets/{AiInlineProvider-BIlcrTkS.js → AiInlineProvider-jkEIJJJ-.js} +1 -1
  6. package/admin/assets/BlocklyEditor-DhwThchX.js +301 -0
  7. package/admin/assets/Compile-B0uHjrBE.css +1 -0
  8. package/admin/assets/Compile-e8N5zI-J.js +165 -0
  9. package/admin/assets/Debugger-BDQUKM1K.js +15 -0
  10. package/admin/assets/Diff--plofAtP.js +1 -0
  11. package/admin/assets/{Documentation-Bc0RmoEF.js → Documentation-D3E0U4AK.js} +4 -4
  12. package/admin/assets/ExpandMore-Dio4GeHC.js +1 -0
  13. package/admin/assets/FbEditor-B8S-mCvc.css +1 -0
  14. package/admin/assets/FbEditor-BjLPNzpK.js +15 -0
  15. package/admin/assets/History-Ewi5YEEn.js +1 -0
  16. package/admin/assets/Import-6Mm2vrM2.js +1 -0
  17. package/admin/assets/MonacoDiff-BYvG7IqB.js +1 -0
  18. package/admin/assets/NotificationsActive-CuNfWVJM.js +1 -0
  19. package/admin/assets/RulesEditor--YX6ETsU.js +1 -0
  20. package/admin/assets/{ScriptEditor-CEHpEFp7.js → ScriptEditor-BadPC8Mf.js} +2 -2
  21. package/admin/assets/ScriptEditorVanillaMonaco-BnAmy59d.js +3 -0
  22. package/admin/assets/Send-Pz1eveU5.js +1 -0
  23. package/admin/assets/_virtual_mf-localSharedImportMap___mfe_internal__iobroker_javascript__mf_owner__1-Ceh8EDcF.js +1 -0
  24. package/admin/assets/_virtual_mf___mfe_internal__iobroker_javascript__mf_owner__234968779812303__loadShare___mf_0_iobroker_mf_1_gui_mf_2_components__loadShare__.js-BRdHvuuG.js +1217 -0
  25. package/admin/assets/_virtual_mf___mfe_internal__iobroker_javascript__mf_owner__234968779812303__loadShare__react_mf_2_dom_mf_1_client__loadShare__.js-DLWT3PGo.js +9 -0
  26. package/admin/assets/aiPromptBuilder-Co6AqZwx.js +1 -0
  27. package/admin/assets/{blockly-fcfyKYzp.js → blockly-B0t_IRJQ.js} +1 -1
  28. package/admin/assets/blocklyTheme-iZoge1S9.js +1 -0
  29. package/admin/assets/blocks_action-Ctn5A1AU.js +1 -0
  30. package/admin/assets/{blocks_convert-BP2RjhQH.js → blocks_convert-BI0lf0sf.js} +1 -1
  31. package/admin/assets/blocks_logic-o49klUX_.js +1 -0
  32. package/admin/assets/blocks_number-DZtyWFyR.js +1 -0
  33. package/admin/assets/blocks_object-BuzGCxVr.js +1 -0
  34. package/admin/assets/blocks_procedures-jn9sIYmR.js +3 -0
  35. package/admin/assets/blocks_sendto-Coui8w1H.js +5 -0
  36. package/admin/assets/blocks_switch-CeRZizTM.js +2 -0
  37. package/admin/assets/blocks_system-CaBPIC40.js +1 -0
  38. package/admin/assets/blocks_text-DeDtPYWf.js +1 -0
  39. package/admin/assets/blocks_time-CTXQH3Lm.js +1 -0
  40. package/admin/assets/blocks_timeout-D8IOKOb-.js +1 -0
  41. package/admin/assets/{blocks_trigger-CnmXLCUE.js → blocks_trigger-zuuXJbhb.js} +2 -2
  42. package/admin/assets/{cronHoverProvider-CcIFAhVy.js → cronHoverProvider-Curcjz4m.js} +1 -1
  43. package/admin/assets/dist-CzitsFi7.js +1 -0
  44. package/admin/assets/field_cron-RgLY53_S.js +1 -0
  45. package/admin/assets/field_oid-rBhotXJe.js +1 -0
  46. package/admin/assets/field_script-CU7g3-oB.js +1 -0
  47. package/admin/assets/helpers-BZgjFQNf.js +1 -0
  48. package/admin/assets/helpers-BwllSRzJ.js +1 -0
  49. package/admin/assets/hostInit-CrHjJGJJ.js +1 -0
  50. package/admin/assets/index-BHhhebRG.css +1 -0
  51. package/admin/assets/index-Bmmscq2G.js +157 -0
  52. package/admin/assets/{inlineChatWidget-N8xIkvxX.js → inlineChatWidget-ChchJD9a.js} +2 -2
  53. package/admin/assets/{inlineDiffController-BuqYsKKq.js → inlineDiffController-ly6qX4jk.js} +2 -2
  54. package/admin/assets/loadBlocks-BcFtthDb.js +117 -0
  55. package/admin/assets/loadMonaco-BVOEahNw.js +1 -0
  56. package/admin/assets/{mf-entry-bootstrap-0-a5a39621.js → mf-entry-bootstrap-0-6db6c4fc.js} +3 -3
  57. package/admin/assets/pendingShares-mBGPbRwZ.js +2 -0
  58. package/admin/assets/reactour.esm-Dk3aGxKn.js +137 -0
  59. package/admin/assets/{stateHoverProvider-BYAbe1Ay.js → stateHoverProvider-wAsP-THx.js} +1 -1
  60. package/admin/assets/tileFbd-CWAy7R7m.svg +85 -0
  61. package/admin/assets/utils-DUKzLJUz.js +4 -0
  62. package/admin/assets/vite-preload-helper-DjNwdemH.js +1 -0
  63. package/admin/custom/assets/Components-fDcxCyN4.js +1 -0
  64. package/admin/custom/assets/_virtual_mf-localSharedImportMap___mfe_internal__ConfigCustomJavascriptSet__mf_owner__1-BraOrMSu.js +1 -0
  65. package/admin/custom/assets/_virtual_mf___mfe_internal__ConfigCustomJavascriptSet__mf_owner__198282747311932__loadShare___mf_0_emotion_mf_1_react__loadShare__.js-DbKT6Hsb.js +1 -0
  66. package/admin/custom/assets/_virtual_mf___mfe_internal__ConfigCustomJavascriptSet__mf_owner__198282747311932__loadShare___mf_0_emotion_mf_1_styled__loadShare__.js-CVvbIPAy.js +1 -0
  67. package/admin/custom/assets/{_virtual_mf___mfe_internal__ConfigCustomJavascriptSet__mf_owner__37453319418803__loadShare___mf_0_iobroker_mf_1_gui_mf_2_components__loadShare__.js-DVb0ZZ1Q.js → _virtual_mf___mfe_internal__ConfigCustomJavascriptSet__mf_owner__198282747311932__loadShare___mf_0_iobroker_mf_1_gui_mf_2_components__loadShare__.js-BhZYie9-.js} +89 -89
  68. package/admin/custom/assets/_virtual_mf___mfe_internal__ConfigCustomJavascriptSet__mf_owner__198282747311932__loadShare___mf_0_mui_mf_1_x_mf_2_date_mf_2_pickers__loadShare__.js-CV50dgj4.js +1 -0
  69. package/admin/custom/assets/_virtual_mf___mfe_internal__ConfigCustomJavascriptSet__mf_owner__198282747311932__loadShare__date_mf_2_fns__loadShare__.js-Djg9OMcQ.js +1 -0
  70. package/admin/custom/assets/_virtual_mf___mfe_internal__ConfigCustomJavascriptSet__mf_owner__198282747311932__loadShare__leaflet__loadShare__.js-D9EyCd42.js +1 -0
  71. package/admin/custom/assets/_virtual_mf___mfe_internal__ConfigCustomJavascriptSet__mf_owner__198282747311932__loadShare__shared-Hb6V6BnJ.js +2 -0
  72. package/admin/custom/assets/_virtual_mf___mfe_internal__ConfigCustomJavascriptSet__mf_owner__198282747311932__prebuild___mf_0_iobroker_mf_1_json_mf_2_config__prebuild__-BrY-nF2a.js +122 -0
  73. package/admin/custom/assets/_virtual_mf___mfe_internal__ConfigCustomJavascriptSet__mf_owner__198282747311932__prebuild__leaflet__prebuild__-CHjWtrkp.js +1 -0
  74. package/admin/custom/assets/_virtual_mf___mfe_internal__ConfigCustomJavascriptSet__mf_owner__198282747311932__prebuild__react_mf_2_dom_mf_1_client__prebuild__-DOkC-g0X.js +9 -0
  75. package/admin/custom/assets/dist-CzitsFi7.js +1 -0
  76. package/admin/custom/assets/helpers-BZgjFQNf.js +1 -0
  77. package/admin/custom/assets/hostInit-akwaQLq8.js +1 -0
  78. package/admin/custom/assets/index-BkItz-nL.js +1 -0
  79. package/admin/custom/assets/{lib-BmDlTzq2.js → lib-CADOx2YN.js} +1 -1
  80. package/admin/custom/assets/{mf-entry-bootstrap-0-ad1cd7d0.js → mf-entry-bootstrap-0-3c4565e0.js} +3 -3
  81. package/admin/custom/assets/pendingShares-TCMDgBLn.js +2 -0
  82. package/admin/custom/assets/utils-DUKzLJUz.js +4 -0
  83. package/admin/custom/assets/vite-preload-helper-DjNwdemH.js +1 -0
  84. package/admin/custom/customComponents.js +2 -2
  85. package/admin/custom/i18n/de.json +19 -1
  86. package/admin/custom/i18n/en.json +19 -1
  87. package/admin/custom/i18n/es.json +19 -1
  88. package/admin/custom/i18n/fr.json +19 -1
  89. package/admin/custom/i18n/it.json +19 -1
  90. package/admin/custom/i18n/nl.json +19 -1
  91. package/admin/custom/i18n/pl.json +19 -1
  92. package/admin/custom/i18n/pt.json +19 -1
  93. package/admin/custom/i18n/ru.json +19 -1
  94. package/admin/custom/i18n/uk.json +19 -1
  95. package/admin/custom/i18n/zh-cn.json +19 -1
  96. package/admin/i18n/de.json +13 -1
  97. package/admin/i18n/en.json +13 -1
  98. package/admin/i18n/es.json +13 -1
  99. package/admin/i18n/fr.json +13 -1
  100. package/admin/i18n/it.json +13 -1
  101. package/admin/i18n/nl.json +13 -1
  102. package/admin/i18n/pl.json +13 -1
  103. package/admin/i18n/pt.json +13 -1
  104. package/admin/i18n/ru.json +13 -1
  105. package/admin/i18n/uk.json +13 -1
  106. package/admin/i18n/zh-cn.json +13 -1
  107. package/admin/jsonConfig.json +274 -86
  108. package/admin/mf-manifest.json +1 -1
  109. package/admin/mf-stats.json +1 -1
  110. package/admin/remoteEntry.js +2 -2
  111. package/admin/tab.html +3 -7
  112. package/build/lib/aiProviderResolver.js +145 -25
  113. package/build/lib/aiProviderResolver.js.map +1 -1
  114. package/build/lib/anthropicAdapter.js +37 -0
  115. package/build/lib/anthropicAdapter.js.map +1 -1
  116. package/build/lib/fb/analyze.js +288 -0
  117. package/build/lib/fb/analyze.js.map +1 -0
  118. package/build/lib/fb/blocks.js +605 -0
  119. package/build/lib/fb/blocks.js.map +1 -0
  120. package/build/lib/fb/generate.js +326 -0
  121. package/build/lib/fb/generate.js.map +1 -0
  122. package/build/lib/fb/graph.js +240 -0
  123. package/build/lib/fb/graph.js.map +1 -0
  124. package/build/lib/fb/index.js +57 -0
  125. package/build/lib/fb/index.js.map +1 -0
  126. package/build/lib/fb/js.js +33 -0
  127. package/build/lib/fb/js.js.map +1 -0
  128. package/build/lib/fb/layout.js +205 -0
  129. package/build/lib/fb/layout.js.map +1 -0
  130. package/build/lib/fb/library.js +657 -0
  131. package/build/lib/fb/library.js.map +1 -0
  132. package/build/lib/fb/runtime.js +793 -0
  133. package/build/lib/fb/runtime.js.map +1 -0
  134. package/build/lib/fb/time.js +76 -0
  135. package/build/lib/fb/time.js.map +1 -0
  136. package/build/lib/fb/types.js +19 -0
  137. package/build/lib/fb/types.js.map +1 -0
  138. package/build/lib/fb/user.js +78 -0
  139. package/build/lib/fb/user.js.map +1 -0
  140. package/build/lib/inspect.js +66 -10
  141. package/build/lib/inspect.js.map +1 -1
  142. package/build/lib/javascript.d.ts +1 -1
  143. package/build/lib/mirror.js +28 -23
  144. package/build/lib/mirror.js.map +1 -1
  145. package/build/lib/sandbox.js +44 -0
  146. package/build/lib/sandbox.js.map +1 -1
  147. package/build/lib/scriptHistory.js +245 -0
  148. package/build/lib/scriptHistory.js.map +1 -0
  149. package/build/main.js +641 -32
  150. package/build/main.js.map +1 -1
  151. package/build/types.d.ts +20 -1
  152. package/docs/de/fbd.md +274 -0
  153. package/docs/en/fbd.md +260 -0
  154. package/io-package.json +55 -29
  155. package/package.json +7 -7
  156. package/admin/assets/AiChatPanel-oBeXbUFv.js +0 -27
  157. package/admin/assets/AiDiffView-C-KKjnJD.js +0 -1
  158. package/admin/assets/Debugger-DwHHsh9O.js +0 -15
  159. package/admin/assets/Error-DZ4vCykD.js +0 -1
  160. package/admin/assets/Import-Cu02ceLW.js +0 -1
  161. package/admin/assets/RulesEditor-QCbi1lV_.js +0 -1
  162. package/admin/assets/ScriptEditorVanillaMonaco-ChQmnk0p.js +0 -3
  163. package/admin/assets/_virtual_mf-localSharedImportMap___mfe_internal__iobroker_javascript__mf_owner__1-CM95r358.js +0 -1
  164. package/admin/assets/_virtual_mf___mfe_internal__iobroker_javascript__mf_owner__180366418666083__loadShare___mf_0_iobroker_mf_1_gui_mf_2_components__loadShare__.js-BEpNZh4U.js +0 -1217
  165. package/admin/assets/_virtual_mf___mfe_internal__iobroker_javascript__mf_owner__180366418666083__loadShare__react_mf_2_dom_mf_1_client__loadShare__.js-FeM77flT.js +0 -9
  166. package/admin/assets/aiPromptBuilder-DKler0UK.js +0 -1
  167. package/admin/assets/blocks_action-DywZVfRY.js +0 -1
  168. package/admin/assets/blocks_logic-CdTl5YZw.js +0 -1
  169. package/admin/assets/blocks_number-DXFd9Rva.js +0 -1
  170. package/admin/assets/blocks_object-by1uBDHi.js +0 -1
  171. package/admin/assets/blocks_procedures-BcJ7N70D.js +0 -3
  172. package/admin/assets/blocks_sendto-qIKzOAcV.js +0 -5
  173. package/admin/assets/blocks_switch-dLF6hSJl.js +0 -2
  174. package/admin/assets/blocks_system-DmX-SBy8.js +0 -1
  175. package/admin/assets/blocks_text-BI4zNU3o.js +0 -1
  176. package/admin/assets/blocks_time-BgYA4Y_4.js +0 -1
  177. package/admin/assets/blocks_timeout-DUzgMyAu.js +0 -1
  178. package/admin/assets/dist-D4uJqRBO.js +0 -4
  179. package/admin/assets/field_cron-Ba46q8Qc.js +0 -1
  180. package/admin/assets/field_oid-lWCjOzuq.js +0 -1
  181. package/admin/assets/field_script-BCWZHhnW.js +0 -1
  182. package/admin/assets/helpers-CnEjYAup.js +0 -1
  183. package/admin/assets/hostInit-CVybS7BB.js +0 -1
  184. package/admin/assets/index-B3s0zmWC.js +0 -871
  185. package/admin/assets/index-CXaeqPRy.css +0 -1
  186. package/admin/assets/pendingShares-DOAkyFMS.js +0 -1
  187. package/admin/assets/vite-preload-helper-CaC3yEL3.js +0 -1
  188. package/admin/custom/assets/Components-FkGDIlId.js +0 -1
  189. package/admin/custom/assets/_virtual_mf-localSharedImportMap___mfe_internal__ConfigCustomJavascriptSet__mf_owner__1-Cs88NUCd.js +0 -1
  190. package/admin/custom/assets/_virtual_mf___mfe_internal__ConfigCustomJavascriptSet__mf_owner__37453319418803__loadShare___mf_0_emotion_mf_1_react__loadShare__.js-P-8ffWXw.js +0 -1
  191. package/admin/custom/assets/_virtual_mf___mfe_internal__ConfigCustomJavascriptSet__mf_owner__37453319418803__loadShare___mf_0_emotion_mf_1_styled__loadShare__.js-ZVuRAEo5.js +0 -1
  192. package/admin/custom/assets/_virtual_mf___mfe_internal__ConfigCustomJavascriptSet__mf_owner__37453319418803__loadShare___mf_0_iobroker_mf_1_json_mf_2_config__loadShare__.js-Dna3WF04.js +0 -1
  193. package/admin/custom/assets/_virtual_mf___mfe_internal__ConfigCustomJavascriptSet__mf_owner__37453319418803__loadShare___mf_0_mui_mf_1_x_mf_2_date_mf_2_pickers__loadShare__.js-DcjdCGAx.js +0 -1
  194. package/admin/custom/assets/_virtual_mf___mfe_internal__ConfigCustomJavascriptSet__mf_owner__37453319418803__loadShare__date_mf_2_fns__loadShare__.js-CnhNjamd.js +0 -1
  195. package/admin/custom/assets/_virtual_mf___mfe_internal__ConfigCustomJavascriptSet__mf_owner__37453319418803__loadShare__leaflet__loadShare__.js-Dz7BFJqH.js +0 -1
  196. package/admin/custom/assets/_virtual_mf___mfe_internal__ConfigCustomJavascriptSet__mf_owner__37453319418803__loadShare__react_mf_2_dom_mf_1_client__loadShare__.js-B0olko2J.js +0 -1
  197. package/admin/custom/assets/_virtual_mf___mfe_internal__ConfigCustomJavascriptSet__mf_owner__37453319418803__prebuild___mf_0_iobroker_mf_1_json_mf_2_config__prebuild__-CzN4reh_.js +0 -122
  198. package/admin/custom/assets/_virtual_mf___mfe_internal__ConfigCustomJavascriptSet__mf_owner__37453319418803__prebuild__leaflet__prebuild__-xPcBaiTQ.js +0 -1
  199. package/admin/custom/assets/_virtual_mf___mfe_internal__ConfigCustomJavascriptSet__mf_owner__37453319418803__prebuild__react_mf_2_dom_mf_1_client__prebuild__-DuFBE5fh.js +0 -9
  200. package/admin/custom/assets/dist-D4uJqRBO.js +0 -4
  201. package/admin/custom/assets/hostInit-6oh4UY2k.js +0 -1
  202. package/admin/custom/assets/index-BrlyEy6J.js +0 -1
  203. package/admin/custom/assets/pendingShares-kV2kwejX.js +0 -1
  204. package/admin/custom/assets/vite-preload-helper-CaC3yEL3.js +0 -1
  205. /package/admin/custom/assets/{_virtual_mf___mfe_internal__ConfigCustomJavascriptSet__mf_owner__37453319418803__prebuild__react_mf_1_jsx_mf_2_runtime__prebuild__-CXpyx8Vy.js → _virtual_mf___mfe_internal__ConfigCustomJavascriptSet__mf_owner__198282747311932__prebuild__react_mf_1_jsx_mf_2_runtime__prebuild__-CXpyx8Vy.js} +0 -0
@@ -0,0 +1 @@
1
+ import{i as e,o as t,r as n,t as r}from"./blockly-B0t_IRJQ.js";import{n as i,r as a}from"./BlocklyEditor-DhwThchX.js";import{c as o,d as s,i as c,p as l,r as u,s as d}from"./helpers-BwllSRzJ.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-fcfyKYzp.js";import{c as i,l as a}from"./index-B3s0zmWC.js";import{c as o,n as s,t as c}from"./helpers-CnEjYAup.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-B0t_IRJQ.js";import{n as i,r as a}from"./BlocklyEditor-DhwThchX.js";import{c as o,n as s,t as c}from"./helpers-BwllSRzJ.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};
@@ -0,0 +1 @@
1
+ import{i as e,m as t,p as n,t as r}from"./blockly-B0t_IRJQ.js";import{n as i,r as a}from"./BlocklyEditor-DhwThchX.js";import{l as o}from"./helpers-BwllSRzJ.js";function s(e,s,c,l,u){let d=window.Blockly.Translate,f=`${e}_container`,p=`${e}_mutator`;r[f]={init:function(){this.appendDummyInput().appendField(d(e)),this.appendStatementInput(`STACK`),this.setColour(`%{BKY_LOGIC_HUE}`),this.setTooltip(d(`${e}_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(`${e}_tooltip`)),this.contextMenu=!1}},r[e]={init:function(){this.itemCount_=2,this.setMutator(new n.MutatorIcon([p],this)),this.setInputsInline(!1),this.setOutput(!0,`Boolean`),this.setColour(`%{BKY_LOGIC_HUE}`),this.setTooltip(d(`${e}_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 n=this.appendValueInput(`${s}${e}`).setAlign(t.Align.RIGHT);e>0&&n.appendField(d(c))}for(let e=this.itemCount_;this.getInput(`${s}${e}`);e++)this.removeInput(`${s}${e}`)}},a.forBlock[e]=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 n=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 e([[`<`,`LT`],[`≤`,`LE`]]),`MIN_OPERATOR`),this.appendValueInput(`MAX`).setCheck(`Number`).appendField(new e([[`<`,`LT`],[`≤`,`LE`]]),`MAX_OPERATOR`),this.setInputsInline(!0),this.setOutput(!0,`Boolean`),this.setColour(`%{BKY_LOGIC_HUE}`),this.setTooltip(n(`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(t.Align.RIGHT).appendField(n(`logic_ifempty`)),this.appendValueInput(`DEFLT`).setCheck(null).setAlign(t.Align.RIGHT).appendField(n(`logic_ifempty_then`)),this.setInputsInline(!0),this.setOutput(!0,null),this.setColour(`%{BKY_LOGIC_HUE}`),this.setTooltip(n(`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};
@@ -0,0 +1 @@
1
+ import{a as e,s as t,t as n}from"./blockly-B0t_IRJQ.js";import{n as r,r as i}from"./BlocklyEditor-DhwThchX.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};
@@ -0,0 +1 @@
1
+ import{m as e,o as t,p as n,t as r}from"./blockly-B0t_IRJQ.js";import{n as i,r as a}from"./BlocklyEditor-DhwThchX.js";import{c as o,l as s}from"./helpers-BwllSRzJ.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 n.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 t=this.workspace;for(let n=0;n<this.itemCount_;n++){let r=this.getInput(`ATTR_${n}`);r?r.fieldRow[0].setValue(this.attributes_[n]):(r=this.appendValueInput(`ATTR_${n}`).setAlign(e.Align.RIGHT),r.appendField(this.attributes_[n])),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,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};
@@ -0,0 +1,3 @@
1
+ import{g as e,l as t,o as n,p as r,s as i,t as a,u as o}from"./blockly-B0t_IRJQ.js";import{n as s,r as c}from"./BlocklyEditor-DhwThchX.js";import{FieldScript as l,b64DecodeUnicode as u}from"./field_script-CU7g3-oB.js";function d(e){return a[e]}function f(){let f=window.Blockly,p=f.Translate,m=e.xml,h=d(`procedures_ifreturn`);h.FUNCTION_TYPES.includes(`procedures_defcustomreturn`)||h.FUNCTION_TYPES.push(`procedures_defcustomreturn`),h.FUNCTION_TYPES.includes(`procedures_defcustomnoreturn`)||h.FUNCTION_TYPES.push(`procedures_defcustomnoreturn`),f.Procedures.allProceduresNew=function(e){let n=t.allProcedures(e),r=()=>e.getProcedureMap().getProcedures().filter(e=>!!e.getReturnTypes()).map(e=>[e.getName(),e.getParameters().map(e=>e.getName()),!0]),i=n=>{let i=r();return e.getBlocksByType(n,!1).forEach(e=>{t.isProcedureBlock(e)||i.push(e.getProcedureDef())}),i};return n.concat([i(`procedures_defcustomnoreturn`),i(`procedures_defcustomreturn`)])},f.Procedures.flyoutCategoryNew=function(e){let t=[],n=(e,n)=>{if(!a[e])return;let r=m.createElement(`block`);r.setAttribute(`type`,e),r.setAttribute(`gap`,`16`);let o=m.createElement(`field`);o.setAttribute(`name`,`NAME`),o.appendChild(m.createTextNode(i[n])),r.appendChild(o),t.push(r)},r=e=>{if(!a[e])return;let n=m.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=m.createElement(`block`);e.setAttribute(`type`,n),e.setAttribute(`gap`,`16`);let a=m.createElement(`mutation`);a.setAttribute(`name`,r),e.appendChild(a);for(let e of i){let t=m.createElement(`arg`);t.setAttribute(`name`,e),a.appendChild(t)}t.push(e)}},s=f.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},c.forBlock.procedures_defreturn=function(e){let n=c,r=n.nameDB_.getName(e.getFieldValue(`NAME`),t.CATEGORY_NAME),i=``;n.STATEMENT_PREFIX&&(i+=n.injectId(n.STATEMENT_PREFIX,e)),n.STATEMENT_SUFFIX&&(i+=n.injectId(n.STATEMENT_SUFFIX,e)),i&&=n.prefixLines(i,n.INDENT);let a=``;n.INFINITE_LOOP_TRAP&&(a=n.prefixLines(n.injectId(n.INFINITE_LOOP_TRAP,e),n.INDENT));let o=``,l=``,u=e.getInput(`STACK`)?n.statementToCode(e,`STACK`):``;e.getInput(`RETURN`)&&(o=n.valueToCode(e,`RETURN`,s.NONE)||``,u&&o&&(l=i),o&&=`${n.INDENT}return ${o};\n`);let d=`async function ${r}(${e.getVarModels().map(e=>n.nameDB_.getName(e.name,`VARIABLE`)).join(`, `)}) {\n${i}${a}${u}${l}${o}}`;return d=n.scrub_(e,d),n.definitions_[`%${r}`]=d,null},c.forBlock.procedures_defnoreturn=c.forBlock.procedures_defreturn,c.forBlock.procedures_callreturn=function(e){let n=c;return[`await ${n.nameDB_.getName(e.getFieldValue(`NAME`),t.CATEGORY_NAME)}(${e.getVarModels().map((t,r)=>n.valueToCode(e,`ARG${r}`,s.NONE)||`null`).join(`, `)})`,s.FUNCTION_CALL]};let g=e=>{let s=e?`procedures_defcustomreturn`:`procedures_defcustomnoreturn`,c=d(e?`procedures_defreturn`:`procedures_defnoreturn`),u=e?`procedures_defcustomreturn_name`:`procedures_defcustomnoreturn_name`,f=e?`PROCEDURES_DEFRETURN`:`PROCEDURES_DEFNORETURN`;a[s]={getProcedureModel(){return this.model},isProcedureDef(){return!0},init:function(){var a;let o=new n(``,t.rename);o.setSpellcheck(!1),this.appendDummyInput().appendField(p(u)).appendField(o,`NAME`).appendField(``,`PARAMS`),this.setMutator(new r.MutatorIcon([`procedures_mutatorarg`],this));let s=this.workspace.options;(s.comments||(a=s.parentWorkspace)!=null&&a.options.comments)&&i[`${f}_COMMENT`]&&this.setCommentText(i[`${f}_COMMENT`]),this.setStyle(`procedure_blocks`),e||this.setColour(i.PROCEDURES_HUE),this.setTooltip(i[`${f}_TOOLTIP`]),this.setHelpUrl(i[`${f}_HELPURL`]),this.arguments_=[],this.argumentVarModels_=[],this.setStatements_(!0),this.statementConnection_=null,this.appendDummyInput(`SCRIPT`).appendField(new l(e?btoa(`return 0;`):``),`SCRIPT`),this.setInputsInline(!0),this.setStatements_(!1)},setStatements_:c.setStatements_,updateParams_:c.updateParams_,mutationToDom:c.mutationToDom,domToMutation:c.domToMutation,decompose:function(e){var n,r;let i=e.newBlock(`procedures_mutatorcontainer`);i.initSvg(),(n=i.getInput(`STATEMENT_INPUT`))==null||n.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 t.mutateCallers(this),i},compose:function(e){this.arguments_=[],this.paramIds_=[],this.argumentVarModels_=[];let n=e.getInputTargetBlock(`STACK`);for(;n&&!n.isInsertionMarker();){let e=n.getFieldValue(`NAME`);this.arguments_.push(e),this.argumentVarModels_.push(o.getOrCreateVariablePackage(this.workspace,null,e,``)),this.paramIds_.push(n.id),n=n.nextConnection&&n.nextConnection.targetBlock()}this.updateParams_(),t.mutateCallers(this)},getProcedureDef:function(){return[this.getFieldValue(`NAME`),this.arguments_,e,!0]},getVarModels:c.getVarModels,renameVarById:c.renameVarById,updateVarName:c.updateVarName,displayRenamedVar_:c.displayRenamedVar_,customContextMenu:c.customContextMenu,callType_:e?`procedures_callcustomreturn`:`procedures_callcustomnoreturn`}},_=e=>{let t=e?`procedures_callcustomreturn`:`procedures_callcustomnoreturn`,n=d(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`}};g(!0),c.forBlock.procedures_defcustomreturn=function(e){let n=c,r=n.nameDB_.getName(e.getFieldValue(`NAME`),t.CATEGORY_NAME),i=e.arguments_.map(e=>n.nameDB_.getName(e,`VARIABLE`)),a=u(e.getFieldValue(`SCRIPT`)||``).split(`
2
+ `).map(e=>` ${e}`),o=`async function ${r}(${i.join(`, `)}) {\n${a.join(`
3
+ `)}\n}`;return o=n.scrub_(e,o),n.definitions_[`%${r}`]=o,null},_(!0),c.forBlock.procedures_callcustomreturn=c.forBlock.procedures_callreturn,d(`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},g(!1),a.procedures_defcustomnoreturn.decompose=a.procedures_defcustomreturn.decompose,a.procedures_defcustomnoreturn.compose=a.procedures_defcustomreturn.compose,c.forBlock.procedures_defcustomnoreturn=c.forBlock.procedures_defcustomreturn,_(!1),c.forBlock.procedures_callcustomnoreturn=function(e){return`${c.forBlock.procedures_callcustomreturn(e,c)[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=m.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`]},c.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`,s.NONE)||`null`;n+=`${t.INDENT}return ${r};\n`}else n+=`${t.INDENT}return;\n`;return n}}export{f as install};
@@ -0,0 +1,5 @@
1
+ import{i as e,m as t,o as n,p as r,r as i,t as a}from"./blockly-B0t_IRJQ.js";import{n as o,r as s}from"./BlocklyEditor-DhwThchX.js";import{c,d as l,i as u,l as d,r as f,s as p}from"./helpers-BwllSRzJ.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 t;let i=[];if((t=window.main)!=null&&t.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 e(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 e(u()),`LOG`),this.appendDummyInput(`WITH_STATEMENT`).appendField(g(`with_results`)).appendField(v(),`WITH_STATEMENT`),this.attributes_=[],this.itemCount_=0,this.setMutator(new r.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 n=this.workspace;for(let e=0;e<this.itemCount_;e++){let r=this.getInput(`ARG${e}`);r?r.fieldRow.length>=1&&r.fieldRow[0].setValue(this.attributes_[e]):(r=this.appendValueInput(`ARG${e}`).setAlign(t.Align.RIGHT),r.appendField(this.attributes_[e])),setTimeout(e=>{var t;if(!((t=e.connection)!=null&&t.isConnected())){let t=n.newBlock(`text`);t.setShadow(!0),t.initSvg(),t.render(),t.outputConnection.connect(e.connection)}},100,r)}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
+ `):``;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 t;let r=[];if((t=window.main)!=null&&t.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 e(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 e([[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 t;let r=[[`default`,`default`]];if((t=window.main)!=null&&t.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 e(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 e([[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 e([[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
+ `:``)+(f?s.prefixLines(f,s.INDENT):``)+` }
4
+ });
5
+ `}}export{h as install};
@@ -0,0 +1,2 @@
1
+ import{p as e,t}from"./blockly-B0t_IRJQ.js";import{n,r}from"./BlocklyEditor-DhwThchX.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
+ `}else alert(`logic_switch_case: ${s} is not a variable name`)}return i}}export{i as install};
@@ -0,0 +1 @@
1
+ import{i as e,o as t,r as n,s as r,t as i}from"./blockly-B0t_IRJQ.js";import{n as a,r as o}from"./BlocklyEditor-DhwThchX.js";import{c as s,o as c,r as l,u}from"./helpers-BwllSRzJ.js";import{FieldOID as d}from"./field_oid-rBhotXJe.js";function f(){let f=window.Blockly,p=f.Translate,m=window.getHelp;f.CustomBlocks=f.CustomBlocks||[],f.CustomBlocks.push(`System`),f.System={HUE:210,blocks:{},WARNING_PARENTS:[`on_ext`]};let h=e=>[[p(`get_value_val`),`val`],[p(`get_value_ack`),`ack`],[p(`get_value_ts`),`ts`],[p(`get_value_lc`),`lc`],[p(`get_value_q`),`q`],[p(`get_value_comment`),`c`],[p(`get_value_from`),`from`],...e?[[p(`get_value_user`),`user`]]:[],[p(`get_common_name`),`common.name`],[p(`get_common_desc`),`common.desc`],[p(`get_common_unit`),`common.unit`],[p(`get_common_role`),`common.role`],[p(`get_common_state_type`),`common.type`],[p(`get_common_read`),`common.read`],[p(`get_common_write`),`common.write`]],g=e=>e===`type`||e.startsWith(`common.`),_=function(){let e=this.getParent();e&&f.System.WARNING_PARENTS.includes(e.type)?this.setWarningText(p(`false_connection_trigger_warning`),this.id):this.setWarningText(null,this.id)},v=r=>({mutationToDom:function(){let e=document.createElement(`mutation`);return e.setAttribute(`delay_input`,String(l(this.getFieldValue(`WITH_DELAY`)))),e},domToMutation:function(e){this.updateShape_(l(e.getAttribute(`delay_input`)))},updateShape_:function(i){i?this.getInput(`DELAY`)||this.appendDummyInput(`DELAY`).appendField(` `).appendField(new t(`1000`),`DELAY_MS`).appendField(new e([[p(`control_ms`),`ms`],[p(`control_sec`),`sec`],[p(`control_min`),`min`]]),`UNIT`):this.getInput(`DELAY`)&&this.removeInput(`DELAY`),i?this.getInput(`CLEAR_RUNNING_INPUT`)||this.appendDummyInput(`CLEAR_RUNNING_INPUT`).appendField(p(r)).appendField(new n,`CLEAR_RUNNING`):this.getInput(`CLEAR_RUNNING_INPUT`)&&this.removeInput(`CLEAR_RUNNING_INPUT`)}}),y=()=>new n(`FALSE`,function(e){this.getSourceBlock().updateShape_(l(e))}),b=e=>u(e.getFieldValue(`DELAY_MS`),e.getFieldValue(`UNIT`));f.System.blocks.global_var=`<block type="global_var"> <field name="VAR">scriptName</field></block>`,i.global_var={init:function(){this.appendDummyInput(`VAR`).appendField(new e([[p(`global_var_scriptname`),`scriptName`],[p(`global_var_defaultdatadir`),`defaultDataDir`],[p(`global_var_verbose`),`verbose`]]),`VAR`),this.setInputsInline(!0),this.setOutput(!0),this.setColour(f.System.HUE),this.setTooltip(p(`global_var_tooltip`)),this.setHelpUrl(m(`global_var`))}},o.forBlock.global_var=function(e){return[e.getFieldValue(`VAR`),a.ATOMIC]},f.System.blocks.secret=`<block type="secret"></block>`;let x=()=>{var e;return((e=window.main)==null?void 0:e.secrets)||[]},S=()=>x().length?x().map(e=>[e.name,e.name]):[[p(`secret_no_secrets`),``]],C=function(){var e,t;let n=(e=this.getSourceBlock())==null?void 0:e.getFieldValue(`NAME`),r=(t=x().find(e=>e.name===n))==null?void 0:t.fields;return(r!=null&&r.length?r:[`key`,`login`,`password`]).map(e=>[e,e])};i.secret={init:function(){let n=this.appendDummyInput(`SECRET`).appendField(p(`secret`));x().length?n.appendField(new e(S),`NAME`):n.appendField(new t(`CameraPassword`),`NAME`),n.appendField(p(`secret_attr`)).appendField(new e(C),`ATTR`),this.setInputsInline(!0),this.setOutput(!0),this.setColour(f.System.HUE),this.setTooltip(p(`secret_tooltip`)),this.setHelpUrl(m(`secret_help`))}},o.forBlock.secret=function(e){let t=e.getFieldValue(`NAME`),n=e.getFieldValue(`ATTR`),r=/^[A-Za-z_$][A-Za-z0-9_$]*$/.test(n)?`.${n}`:`[${s(n)}]`;return[`SECRETS[${s(t)}]?${r}`,a.ATOMIC]},f.System.blocks.debug=`<block type="debug"> <field name="Severity">info</field> <value name="TEXT"> <shadow type="text"> <field name="TEXT">test</field> </shadow> </value></block>`,i.debug={init:function(){this.appendValueInput(`TEXT`).setCheck(null).appendField(p(`debug`)),this.appendDummyInput(`Severity`).appendField(new e([[p(`loglevel_debug`),`debug`],[p(`loglevel_info`),`info`],[p(`loglevel_warn`),`warn`],[p(`loglevel_error`),`error`]]),`Severity`),this.setInputsInline(!1),this.setPreviousStatement(!0,null),this.setNextStatement(!0,null),this.setColour(f.System.HUE),this.setTooltip(p(`debug_tooltip`)),this.setHelpUrl(m(`debug_help`))}},o.forBlock.debug=function(e){let t=o.valueToCode(e,`TEXT`,a.ATOMIC);return`console.${e.getFieldValue(`Severity`)}(${t});\n`},f.System.blocks.comment=`<block type="comment"></block>`,i.comment={init:function(){this.appendDummyInput(`COMMENT`).appendField(new f.FieldMultilineInput(p(`comment`)),`COMMENT`),this.setInputsInline(!1),this.setPreviousStatement(!0,null),this.setNextStatement(!0,null),this.setColour(`#FFFF00`),this.setTooltip(p(`comment_tooltip`))}},o.forBlock.comment=function(e){return`${o.prefixLines(e.getFieldValue(`COMMENT`),`// `)}\n`},f.System.blocks.control=`<block type="control"> <mutation delay_input="false"></mutation> <field name="WITH_DELAY">FALSE</field></block>`,i.control={init:function(){this.appendDummyInput().appendField(p(`control`)),this.appendDummyInput(`OID`).appendField(new d(p(`select_id`),`state`),`OID`),this.appendValueInput(`VALUE`).setCheck(null).appendField(p(`control_with`)),this.appendDummyInput(`WITH_DELAY`).appendField(p(`control_delay`)).appendField(y(),`WITH_DELAY`),this.setInputsInline(!0),this.setPreviousStatement(!0,null),this.setNextStatement(!0,null),this.setColour(f.System.HUE),this.setTooltip(p(`control_tooltip`)),this.setHelpUrl(m(`control_help`))},...v(`control_clear_running`)},o.forBlock.control=function(e){let t=e.getFieldValue(`OID`);r.VARIABLES_DEFAULT_NAME=`value`;let n=b(e),i=l(e.getFieldValue(`CLEAR_RUNNING`)),s=o.valueToCode(e,`VALUE`,a.ATOMIC),u=c(t),d=u?` /* ${u} */`:``;return l(e.getFieldValue(`WITH_DELAY`))?`setStateDelayed('${t}'${d}, ${s}, ${n}, ${i});\n`:`setState('${t}'${d}, ${s});\n`},f.System.blocks.toggle=`<sep gap="5"></sep><block type="toggle"> <mutation delay_input="false"></mutation> <field name="WITH_DELAY">FALSE</field></block>`,i.toggle={init:function(){this.appendDummyInput().appendField(p(`toggle`)),this.appendDummyInput(`OID`).appendField(new d(p(`select_id`),`state`),`OID`),this.appendDummyInput(`WITH_DELAY`).appendField(p(`toggle_delay`)).appendField(y(),`WITH_DELAY`),this.setInputsInline(!0),this.setPreviousStatement(!0,null),this.setNextStatement(!0,null),this.setColour(f.System.HUE),this.setTooltip(p(`toggle_tooltip`)),this.setHelpUrl(m(`toggle_help`))},...v(`toggle_clear_running`)},o.forBlock.toggle=function(e){var t;let n=e.getFieldValue(`OID`);r.VARIABLES_DEFAULT_NAME=`value`;let i=b(e),a=(t=window.main)==null||(t=t.objects[n])==null?void 0:t.common,s=(a==null?void 0:a.type)||`boolean`,u=c(n),d=u?` /* ${u} */`:``,f=l(e.getFieldValue(`CLEAR_RUNNING`)),p;if(s===`number`){let e=a.max===void 0?100:parseFloat(a.max),t=a.min===void 0?0:parseFloat(a.min);p=`setState('${n}'${d}, state ? (state.val === ${t} ? ${e} : ${t}) : ${e});`}else p=`setState('${n}'${d}, state ? !state.val : true);`;let m=l(e.getFieldValue(`WITH_DELAY`))?`setStateDelayed('${n}'${d}, state ? !state.val : true, ${i}, ${f});`:p;return`getState('${n}', (err, state) => {\n${o.prefixLines(m,o.INDENT)}\n});\n`},f.System.blocks.update=`<sep gap="5"></sep><block type="update"> <mutation delay_input="false"></mutation> <field name="WITH_DELAY">FALSE</field></block>`,i.update={init:function(){this.appendDummyInput().appendField(p(`update`)),this.appendDummyInput(`OID`).appendField(new d(p(`select_id`),`state`),`OID`),this.appendValueInput(`VALUE`).setCheck(null).appendField(p(`update_with`)),this.appendDummyInput(`WITH_DELAY`).appendField(p(`update_delay`)).appendField(y(),`WITH_DELAY`),this.setInputsInline(!0),this.setPreviousStatement(!0,null),this.setNextStatement(!0,null),this.setColour(f.System.HUE),this.setTooltip(p(`update_tooltip`)),this.setHelpUrl(m(`update_help`))},...v(`control_clear_running`)},o.forBlock.update=function(e){let t=e.getFieldValue(`OID`);r.VARIABLES_DEFAULT_NAME=`value`;let n=o.valueToCode(e,`VALUE`,a.ATOMIC),i=b(e),s=l(e.getFieldValue(`CLEAR_RUNNING`)),u=c(t),d=u?` /* ${u} */`:``;return l(e.getFieldValue(`WITH_DELAY`))?`setStateDelayed('${t}'${d}, ${n}, true, ${i}, ${s});\n`:`setState('${t}'${d}, ${n}, true);\n`},f.System.blocks.control_ex=`<sep gap="5"></sep><block type="control_ex"> <field name="TYPE">false</field> <field name="CLEAR_RUNNING">FALSE</field> <value name="OID"> <shadow type="field_oid"> </shadow> </value> <value name="VALUE"> <shadow type="logic_boolean"> <field name="BOOL">TRUE</field> </shadow> </value> <value name="DELAY_MS"> <shadow type="math_number"> <field name="NUM">0</field> </shadow> </value> <value name="EXPIRE"> <shadow type="math_number"> <field name="NUM">0</field> </shadow> </value></block>`,i.control_ex={init:function(){this.appendDummyInput().appendField(p(`control_ex`)),this.appendValueInput(`OID`).setCheck(`String`).appendField(p(`field_oid_OID`)),this.appendDummyInput(`TYPE`).appendField(new e([[p(`control_ex_control`),`false`],[p(`control_ex_update`),`true`]]),`TYPE`),this.appendValueInput(`VALUE`).setCheck(null).appendField(p(`control_ex_value`)),this.appendValueInput(`DELAY_MS`).setCheck(`Number`).appendField(p(`control_ex_delay`)),this.appendValueInput(`EXPIRE`).setCheck(`Number`).appendField(p(`control_ex_expire`)),this.appendDummyInput(`CLEAR_RUNNING_INPUT`).appendField(p(`control_ex_clear_running`)).appendField(new n,`CLEAR_RUNNING`),this.setInputsInline(!1),this.setPreviousStatement(!0,null),this.setNextStatement(!0,null),this.setColour(f.System.HUE),this.setTooltip(p(`control_tooltip`)),this.setHelpUrl(m(`control_help`))}},o.forBlock.control_ex=function(e){let t=o.valueToCode(e,`OID`,a.ATOMIC),n=o.valueToCode(e,`VALUE`,a.ATOMIC),r=o.valueToCode(e,`DELAY_MS`,a.ATOMIC),i=o.valueToCode(e,`EXPIRE`,a.ATOMIC),s=l(e.getFieldValue(`CLEAR_RUNNING`));return`setStateDelayed(${t}, { val: ${n}, ack: ${l(e.getFieldValue(`TYPE`))}${i?`, expire: ${i}`:``} }, parseInt(((${r}) || '').toString(), 10), ${s});\n`},f.System.blocks.create=`<block type="create"> <field name="NAME">0_userdata.0.example</field></block>`,i.create={init:function(){this.appendDummyInput().appendField(p(`create`)),this.appendDummyInput(`NAME`).appendField(p(`create_oid`)).appendField(new t(`0_userdata.0.example`),`NAME`);let e=this.appendValueInput(`VALUE`).setCheck(null).appendField(p(`create_init`));e.connection&&(e.connection._optional=!0);let n=this.appendValueInput(`COMMON`).setCheck(null).appendField(p(`create_common`));n.connection&&(n.connection._optional=!0),this.appendStatementInput(`STATEMENT`).setCheck(null),this.setInputsInline(!1),this.setPreviousStatement(!0,null),this.setNextStatement(!0,null),this.setColour(f.System.HUE),this.setTooltip(p(`create_tooltip`)),this.setHelpUrl(m(`create_help`))}},o.forBlock.create=function(e){let t=e.getFieldValue(`NAME`),n=o.valueToCode(e,`VALUE`,a.ATOMIC),r=n!==null&&n!==``?`, ${n}`:``,i=o.valueToCode(e,`COMMON`,a.ATOMIC),c=i!==null&&i!==``?`, ((common) => typeof common !== 'object' ? JSON.parse(common) : common)(${i})`:``,l=o.statementToCode(e,`STATEMENT`);return`createState(${s(t)}${r}${c}, async () => {\n${l}});\n`},f.System.blocks.create_ex=`<sep gap="5"></sep><block type="create_ex"> <field name="NAME">0_userdata.0.example</field> <field name="TYPE">string</field> <field name="READABLE">FALSE</field> <field name="WRITEABLE">FALSE</field></block>`,i.create_ex={init:function(){this.appendDummyInput().appendField(p(`create`)),this.appendDummyInput(`NAME`).appendField(p(`create_oid`)).appendField(new t(`0_userdata.0.example`),`NAME`),this.appendDummyInput(`TYPE`).appendField(p(`create_type`)).appendField(new e([[p(`create_type_string`),`string`],[p(`create_type_number`),`number`],[p(`create_type_boolean`),`boolean`],[p(`create_type_json`),`json`],[p(`create_type_object`),`object`],[p(`create_type_array`),`array`]]),`TYPE`);let r=this.appendValueInput(`VALUE`).setCheck(null).appendField(p(`create_init`));r.connection&&(r.connection._optional=!0),this.appendDummyInput(`READABLE_INPUT`).appendField(p(`create_readable`)).appendField(new n(`FALSE`),`READABLE`),this.appendDummyInput(`WRITEABLE_INPUT`).appendField(p(`create_writeable`)).appendField(new n(`FALSE`),`WRITEABLE`),this.appendStatementInput(`STATEMENT`).setCheck(null),this.setInputsInline(!1),this.setPreviousStatement(!0,null),this.setNextStatement(!0,null),this.setColour(f.System.HUE),this.setTooltip(p(`create_tooltip`)),this.setHelpUrl(m(`create_help`))}},o.forBlock.create_ex=function(e){let t=e.getFieldValue(`NAME`),n=e.getFieldValue(`TYPE`),r=``,i=o.valueToCode(e,`VALUE`,a.ATOMIC);i!==null&&i!==``&&(r=n===`number`?`, parseFloat(${i})`:n===`boolean`?`, !!${i}`:n===`string`?`, String(${i})`:`, ${i}`);let c=l(e.getFieldValue(`READABLE`)),u=l(e.getFieldValue(`WRITEABLE`)),d=o.statementToCode(e,`STATEMENT`);return`createState(${s(t)}${r}, { type: '${n}', read: ${c}, write: ${u} }, async () => {\n${d}});\n`},f.System.blocks.get_value=`<block type="get_value"> <field name="ATTR">val</field></block>`,i.get_value={init:function(){this.appendDummyInput(`ATTR`).appendField(new e(h(!0)),`ATTR`),this.appendDummyInput().appendField(p(`get_value_OID`)),this.appendDummyInput().appendField(new d(p(`select_id`),`state`),`OID`),this.setInputsInline(!0),this.setOutput(!0),this.setColour(f.System.HUE),this.setTooltip(p(`get_value_tooltip`)),this.setHelpUrl(m(`get_value_help`))},onchange:_},o.forBlock.get_value=function(e){let t=e.getFieldValue(`OID`),n=e.getFieldValue(`ATTR`);return g(n)?[`(await getObjectAsync('${t}')).${n}`,a.ATOMIC]:[`getState(${s(t)}).${n}`,a.ATOMIC]},f.System.blocks.get_value_var=`<sep gap="5"></sep><block type="get_value_var"> <field name="ATTR">val</field> <value name="OID"> <shadow type="field_oid"> </shadow> </value></block>`,i.get_value_var={init:function(){this.appendDummyInput(`ATTR`).appendField(new e(h(!1)),`ATTR`),this.appendDummyInput().appendField(p(`get_value_OID`)),this.appendValueInput(`OID`).setCheck(null),this.setInputsInline(!0),this.setOutput(!0),this.setColour(f.System.HUE),this.setTooltip(p(`get_value_tooltip`)),this.setHelpUrl(m(`get_value_help`))},onchange:_},o.forBlock.get_value_var=function(e){let t=o.valueToCode(e,`OID`,a.ATOMIC),n=e.getFieldValue(`ATTR`);return g(n)?[`(await getObjectAsync(${t})).${n}`,a.ATOMIC]:[`getState(${t}).${n}`,a.ATOMIC]},f.System.blocks.get_value_async=`<sep gap="5"></sep><block type="get_value_async"> <field name="ATTR">val</field></block>`,i.get_value_async={init:function(){this.appendDummyInput(`ATTR`).appendField(new e(h(!1)),`ATTR`),this.appendDummyInput().appendField(p(`get_value_OID`)),this.appendDummyInput().appendField(new d(p(`select_id`),`state`),`OID`),this.appendStatementInput(`STATEMENT`).setCheck(null),this.setInputsInline(!0),this.setPreviousStatement(!0,null),this.setNextStatement(!0,null),this.setColour(f.System.HUE),this.setTooltip(p(`get_value_tooltip`)),this.setHelpUrl(m(`get_value_help`))}},o.forBlock.get_value_async=function(e){let t=e.getFieldValue(`OID`),n=e.getFieldValue(`ATTR`),r=o.statementToCode(e,`STATEMENT`),i=g(n)?{call:`getObjectAsync`,args:`(err, obj)`,from:`obj`}:{call:`getState`,args:`(err, state)`,from:`state`};return`${i.call}(${s(t)}, async ${i.args} => {\n${o.prefixLines(`let value = ${i.from}.${n};`,o.INDENT)}\n${r}});\n`},f.System.blocks.get_object=`<block type="get_object"></block>`,i.get_object={init:function(){this.appendDummyInput().appendField(p(`get_object`)),this.appendDummyInput().appendField(new d(p(`select_id`),`all`),`OID`),this.setInputsInline(!0),this.setOutput(!0),this.setColour(f.Object.HUE),this.setTooltip(p(`get_object_tooltip`)),this.setHelpUrl(m(`get_object_help`))},onchange:function(){let e=this.getParent();e&&f.System.WARNING_PARENTS.includes(e.type)?this.setWarningText(p(`false_connection_trigger_warning`),this.id):e&&[`direct`,`control_ex`,`get_value_var`].includes(e.type)?this.setWarningText(p(`get_object_connection_warning`),this.id):this.setWarningText(null,this.id)}},o.forBlock.get_object=function(e){return[`getObject(${s(e.getFieldValue(`OID`))})`,a.ATOMIC]},f.System.blocks.get_object_async=`<sep gap="5"></sep><block type="get_object_async"></block>`,i.get_object_async={init:function(){this.appendDummyInput().appendField(p(`get_object`)),this.appendDummyInput().appendField(new d(p(`select_id`),`all`),`OID`),this.appendStatementInput(`STATEMENT`).setCheck(null),this.setPreviousStatement(!0,null),this.setNextStatement(!0,null),this.setInputsInline(!0),this.setColour(f.Object.HUE),this.setTooltip(p(`get_object_tooltip`)),this.setHelpUrl(m(`get_object_help`))}},o.forBlock.get_object_async=function(e){let t=o.statementToCode(e,`STATEMENT`);return`getObjectAsync(${s(e.getFieldValue(`OID`))}).then(async (obj) => {\n${t}});\n`},f.System.blocks.state_exists_var=`<sep gap="5"></sep><block type="state_exists_var"> <value name="OID"> <shadow type="field_oid"> </shadow> </value></block>`,i.state_exists_var={init:function(){this.appendDummyInput().appendField(p(`state_exists`)),this.appendValueInput(`OID`).setCheck(null),this.setInputsInline(!0),this.setOutput(!0,`Boolean`),this.setColour(f.System.HUE),this.setTooltip(p(`state_exists_tooltip`)),this.setHelpUrl(m(`state_exists_help`))}},o.forBlock.state_exists_var=function(e){return[`(await existsStateAsync(${o.valueToCode(e,`OID`,a.ATOMIC)||`''`}))`,a.ATOMIC]};let w=(e,t,n)=>{i[e]={init:function(){this.appendDummyInput().appendField(p(t)),this.appendDummyInput().appendField(new d(p(`select_id`),n),`oid`),this.setInputsInline(!0),this.setOutput(!0,`String`),this.setColour(`%{BKY_TEXTS_HUE}`),this.setTooltip(p(`field_oid_tooltip`))}},o.forBlock[e]=function(e){return[s(e.getFieldValue(`oid`)),a.ATOMIC]}};f.System.blocks.field_oid=`<block type="field_oid"></block>`,w(`field_oid`,`field_oid_OID`,`state`),f.System.blocks.field_oid_meta=`<sep gap="5"></sep><block type="field_oid_meta"></block>`,w(`field_oid_meta`,`field_oid_OID_meta`,`meta`),f.System.blocks.field_oid_script=`<sep gap="5"></sep><block type="field_oid_script"></block>`,w(`field_oid_script`,`field_oid_OID_script`,`script`),f.System.blocks.get_attr=`<block type="get_attr"> <value name="PATH"> <shadow type="text"> <field name="TEXT">attribute1</field> </shadow> </value> <value name="OBJECT"> <shadow type="get_object"> <field name="OID">Object ID</field> </shadow> </value></block>`,i.get_attr={init:function(){this.appendValueInput(`PATH`).setCheck(null).appendField(p(`get_attr_path`)),this.appendValueInput(`OBJECT`).appendField(p(`get_attr_by`)),this.setInputsInline(!0),this.setOutput(!0),this.setColour(f.System.HUE),this.setTooltip(p(`get_attr_tooltip`)),this.setHelpUrl(m(`get_attr_help`))}},o.forBlock.get_attr=function(e){return[`getAttr(${o.valueToCode(e,`OBJECT`,a.ATOMIC)}, ${o.valueToCode(e,`PATH`,a.ATOMIC)})`,a.ATOMIC]},f.System.blocks.direct=`<block type="direct"> <field name="ONLY_CHANGES">TRUE</field> <value name="OID_SRC"> <shadow type="field_oid"> <field name="oid">Object ID 1</field> </shadow> </value> <value name="OID_DST"> <shadow type="field_oid"> <field name="oid">Object ID 2</field> </shadow> </value></block>`,i.direct={init:function(){this.appendDummyInput().appendField(p(`direct`)),this.appendValueInput(`OID_SRC`).setCheck(`String`).appendField(p(`direct_oid_src`)),this.appendValueInput(`OID_DST`).setCheck(`String`).appendField(p(`direct_oid_dst`)),this.appendDummyInput(`ONLY_CHANGES`).appendField(p(`direct_only_changes`)).appendField(new n(`TRUE`),`ONLY_CHANGES`),this.setPreviousStatement(!0,null),this.setNextStatement(!0,null),this.setColour(f.Trigger.HUE),this.setTooltip(p(`direct_tooltip`)),this.setHelpUrl(m(`direct_help`))}},o.forBlock.direct=function(e){let t=o.valueToCode(e,`OID_SRC`,a.ATOMIC),n=o.valueToCode(e,`OID_DST`,a.ATOMIC);return`on({ id: ${t}, change: '${l(e.getFieldValue(`ONLY_CHANGES`))?`ne`:`any`}' }, (obj) => {\n${o.prefixLines(`setState(${n}, obj.state.val);`,o.INDENT)}\n});\n`},f.System.blocks.control_instance=`<block type="control_instance"> <field name="INSTANCE">admin.0</field> <field name="ACTION">restartInstanceAsync</field></block>`,i.control_instance={init:function(){var n;let r=[];if((n=window.main)!=null&&n.instances){for(let e of window.main.instances){let t=e.substring(15);r.push([t,t])}r.length||r.push([p(`control_instance_no_instances`),``]),this.appendDummyInput(`INSTANCE`).appendField(p(`control_instance`)).appendField(new e(r),`INSTANCE`)}else this.appendDummyInput(`INSTANCE`).appendField(p(`control_instance`)).appendField(new t(`adapter.0`),`INSTANCE`);this.appendDummyInput(`ACTION`).appendField(p(`control_instance_action`)).appendField(new e([[p(`control_instance_start`),`startInstanceAsync`],[p(`control_instance_stop`),`stopInstanceAsync`],[p(`control_instance_restart`),`restartInstanceAsync`]]),`ACTION`),this.setPreviousStatement(!0,null),this.setNextStatement(!0,null),this.setColour(f.System.HUE),this.setTooltip(p(`control_instance_tooltip`)),this.setHelpUrl(m(`control_instance_help`))}},o.forBlock.control_instance=function(e){return`await ${e.getFieldValue(`ACTION`)}(${s(e.getFieldValue(`INSTANCE`))});\n`},f.System.blocks.control_script=`<block type="control_script"> <field name="ACTION">startScriptAsync</field></block>`,i.control_script={init:function(){this.appendDummyInput(`OID`).appendField(p(`control_script`)).appendField(new d(p(`select_id`),`script`),`OID`),this.appendDummyInput(`ACTION`).appendField(p(`control_instance_action`)).appendField(new e([[p(`control_script_start`),`startScriptAsync`],[p(`control_script_stop`),`stopScriptAsync`]]),`ACTION`),this.setPreviousStatement(!0,null),this.setNextStatement(!0,null),this.setColour(f.System.HUE),this.setTooltip(p(`control_script_tooltip`)),this.setHelpUrl(m(`control_script_help`))}},o.forBlock.control_script=function(e){return`await ${e.getFieldValue(`ACTION`)}(${s(e.getFieldValue(`OID`))});\n`},f.System.blocks.regex=`<block type="regex"> <field name="TEXT">(.*)</field></block>`,i.regex={init:function(){this.appendDummyInput().appendField(`RegExp`),this.appendDummyInput(`TEXT`).appendField(new t(`(.*)`),`TEXT`),this.setInputsInline(!0),this.setOutput(!0,`Array`),this.setColour(f.System.HUE)}},o.forBlock.regex=function(e){return[`new RegExp(${s(e.getFieldValue(`TEXT`))})`,a.ATOMIC]},f.System.blocks.selector=`<block type="selector"> <field name="TEXT">channel[state.id=*]</field></block>`,i.selector={init:function(){this.appendDummyInput().appendField(`${p(`selector`)} $(`),this.appendDummyInput(`TEXT`).appendField(new t(`channel[state.id=*]`),`TEXT`),this.appendDummyInput().appendField(`)`),this.setInputsInline(!0),this.setOutput(!0,`Array`),this.setColour(f.System.HUE)}},o.forBlock.selector=function(e){return[`Array.prototype.slice.apply($(${s(e.getFieldValue(`TEXT`))}))`,a.ATOMIC]}}export{f as install};
@@ -0,0 +1 @@
1
+ import{i as e,t}from"./blockly-B0t_IRJQ.js";import{n,r}from"./BlocklyEditor-DhwThchX.js";function i(){let i=window.Blockly.Translate;t.text_newline={init:function(){this.appendDummyInput().appendField(i(`text_newline`)),this.appendDummyInput().appendField(new e([[`\\n`,`\\n`],[`\\r`,`\\r`],[`\\r\\n`,`\\r\\n`]]),`Type`),this.setInputsInline(!0),this.setOutput(!0,`String`),this.setColour(`%{BKY_TEXTS_HUE}`),this.setTooltip(i(`text_newline_tooltip`))}},r.forBlock.text_newline=function(e){return[`'${e.getFieldValue(`Type`)}'`,n.ATOMIC]},t.text_contains={init:function(){this.appendDummyInput().appendField(i(`text_contains`)),this.appendValueInput(`VALUE`).setCheck(null),this.appendValueInput(`FIND`).setCheck(null).appendField(i(`text_contains_value`)),this.setInputsInline(!0),this.setOutput(!0,`Boolean`),this.setColour(`%{BKY_TEXTS_HUE}`)}},r.forBlock.text_contains=function(e){return[`String(${r.valueToCode(e,`VALUE`,n.ATOMIC)}).includes(${r.valueToCode(e,`FIND`,n.ATOMIC)})`,n.ATOMIC]},t.text_format_value={init:function(){this.appendValueInput(`VALUE`).appendField(i(`text_format_value`)).setCheck(null),this.appendDummyInput().appendField(i(`text_format_value_format`)).appendField(new e([[`System`,`system`],[`.,`,`.,`],[`,.`,`,.`],[` .`,` .`]]),`FORMAT`),this.appendValueInput(`DECIMALS`).appendField(i(`text_format_value_decimals`)),this.setInputsInline(!0),this.setOutput(!0,`String`),this.setColour(`%{BKY_TEXTS_HUE}`)}},r.forBlock.text_format_value=function(e){let t=r.valueToCode(e,`VALUE`,n.ATOMIC),i=r.valueToCode(e,`DECIMALS`,n.ATOMIC),a=e.getFieldValue(`FORMAT`);return a===`system`?[`formatValue(parseFloat(${t}), ${i})`,n.ATOMIC]:[`formatValue(parseFloat(${t}), ${i}, '${a}')`,n.ATOMIC]}}export{i as install};
@@ -0,0 +1 @@
1
+ import{i as e,o as t,r as n,t as r}from"./blockly-B0t_IRJQ.js";import{n as i,r as a}from"./BlocklyEditor-DhwThchX.js";import{c as o,n as s,t as c}from"./helpers-BwllSRzJ.js";var l={"time_get_yyyy.mm.dd":`YYYY.MM.DD`,"time_get_yyyy/mm/dd":`YYYY/MM/DD`,"time_get_yy.mm.dd":`YY.MM.DD`,"time_get_yy/mm/dd":`YY/MM/DD`,"time_get_dd.mm.yyyy":`DD.MM.YYYY`,"time_get_dd/mm/yyyy":`DD/MM/YYYY`,"time_get_dd.mm.yy":`DD.MM.YY`,"time_get_dd/mm/yy":`DD/MM/YY`,"time_get_mm/dd/yyyy":`MM/DD/YYYY`,"time_get_mm/dd/yy":`MM/DD/YY`,"time_get_dd.mm":`DD.MM.`,"time_get_dd/mm":`DD/MM`,"time_get_mm.dd":`MM.DD`,"time_get_mm/dd":`MM/DD`,time_get_hh_mm:`hh:mm`,time_get_hh_mm_ss:`hh:mm:ss`,"time_get_hh_mm_ss.sss":`hh:mm:ss.sss`};function u(e){return e===!0||e===`true`||e===`TRUE`}function d(){let d=window.Blockly,f=d.Translate,p=window.getHelp;d.CustomBlocks=d.CustomBlocks||[],d.CustomBlocks.push(`Time`),d.Time={HUE:270,blocks:{}};for(let[e,t]of Object.entries(l))d.Words[e].format=t;let m=()=>[[f(`time_compare_lt`),`<`],[f(`time_compare_le`),`<=`],[f(`time_compare_gt`),`>`],[f(`time_compare_ge`),`>=`],[f(`time_compare_eq`),`==`],[f(`time_compare_bw`),`between`],[f(`time_compare_nb`),`not between`]];d.Time.blocks.time_compare_ex=`<block type="time_compare_ex"> <mutation end_time="false" actual_time="true"></mutation> <field name="USE_ACTUAL_TIME">TRUE</field> <field name="OPTION">&lt;</field> <value name="START_TIME"> <shadow type="text"> <field name="TEXT">12:00</field> </shadow> </value></block>`,r.time_compare_ex={init:function(){this.appendDummyInput(`TIME_TEXT`).appendField(f(`time_compare_ex`)),this.appendDummyInput(`USE_ACTUAL_TIME`).appendField(new n(`TRUE`,function(e){this.getSourceBlock().updateShape_(void 0,e)}),`USE_ACTUAL_TIME`),this.appendDummyInput().appendField(f(`time_compare_is_ex`)),this.appendDummyInput(`OPTION`).appendField(new e(m(),function(e){this.getSourceBlock().updateShape_(e===`between`||e===`not between`)}),`OPTION`),this.appendDummyInput().appendField(` `),this.appendValueInput(`START_TIME`),this.setInputsInline(!0),this.setOutput(!0,`Boolean`),this.setColour(d.Time.HUE),this.setTooltip(f(`time_compare_ex_tooltip`)),this.setHelpUrl(p(`time_compare_ex_help`))},mutationToDom:function(){let e=document.createElement(`mutation`),t=this.getFieldValue(`OPTION`),n=this.getFieldValue(`USE_ACTUAL_TIME`);return e.setAttribute(`end_time`,t===`between`||t===`not between`?`true`:`false`),e.setAttribute(`actual_time`,u(n)?`true`:`false`),e},domToMutation:function(e){this.updateShape_(u(e.getAttribute(`end_time`)),u(e.getAttribute(`actual_time`)))},updateShape_:function(e,t){if(e===void 0&&(e=this.getFieldValue(`OPTION`)===`between`||this.getFieldValue(`OPTION`)===`not between`),e){if(!this.getInput(`END_TIME`)&&(this.getInput(`CUSTOM_TIME`)&&(this.removeInput(`CUSTOM_TIME`),this.removeInput(`CUSTOM_TEXT`)),this.appendDummyInput(`AND`).appendField(f(`time_compare_and`)),this.appendValueInput(`END_TIME`),!window.scripts.loading)){let e=this.workspace;setTimeout(()=>{var t;let n=this.getInput(`END_TIME`);if(!(n!=null&&(t=n.connection)!=null&&t.isConnected())){let t=e.newBlock(`text`);t.setShadow(!0),t.setFieldValue(`18:00`,`TEXT`),t.outputConnection.connect(n.connection),t.initSvg(),t.render()}},100)}}else this.getInput(`END_TIME`)&&(this.removeInput(`END_TIME`),this.removeInput(`AND`));t===void 0&&(t=this.getFieldValue(`USE_ACTUAL_TIME`));let n=u(t),r=this.getInput(`CUSTOM_TIME`);n?r&&(this.getInput(`TIME_TEXT`).fieldRow[0].setValue(f(`time_compare_ex`)),this.removeInput(`CUSTOM_TIME`),this.removeInput(`CUSTOM_TEXT`)):(this.getInput(`TIME_TEXT`).fieldRow[0].setValue(f(`time_compare_custom_ex`)),r||(this.appendDummyInput(`CUSTOM_TEXT`).appendField(f(`time_compare_ex_custom`)),this.appendValueInput(`CUSTOM_TIME`)))}},a.forBlock.time_compare_ex=function(e){let t=e.getFieldValue(`OPTION`);return[`compareTime(${a.valueToCode(e,`START_TIME`,i.ATOMIC)}, ${e.getInput(`END_TIME`)&&a.valueToCode(e,`END_TIME`,i.ATOMIC)||null}, '${t}', ${e.getInput(`CUSTOM_TIME`)&&a.valueToCode(e,`CUSTOM_TIME`,i.ATOMIC)||null})`,i.ATOMIC]},d.Time.blocks.time_compare=`<block type="time_compare"> <mutation end_time="false"></mutation> <field name="OPTION">&lt;</field> <field name="START_TIME">12:00</field></block>`,r.time_compare={init:function(){this.appendDummyInput().appendField(f(`time_compare`)),this.appendDummyInput(`OPTION`).appendField(new e(m(),function(e){this.getSourceBlock().updateShape_(e===`between`||e===`not between`)}),`OPTION`),this.appendDummyInput().appendField(` `),this.appendDummyInput(`START_TIME`).appendField(new t(`12:00`),`START_TIME`),this.setInputsInline(!0),this.setOutput(!0,`Boolean`),this.setColour(d.Time.HUE),this.setTooltip(f(`time_compare_tooltip`)),this.setHelpUrl(p(`time_compare_help`))},mutationToDom:function(){let e=document.createElement(`mutation`),t=this.getFieldValue(`OPTION`);return e.setAttribute(`end_time`,t===`between`||t===`not between`?`true`:`false`),e},domToMutation:function(e){this.updateShape_(u(e.getAttribute(`end_time`)))},updateShape_:function(e){e?this.getInput(`END_TIME`)||(this.appendDummyInput(`AND`).appendField(f(`time_compare_and`)),this.appendDummyInput(`END_TIME`).appendField(new t(`18:00`),`END_TIME`)):this.getInput(`END_TIME`)&&(this.removeInput(`END_TIME`),this.removeInput(`AND`))}},a.forBlock.time_compare=function(e){let t=e.getFieldValue(`OPTION`),n=e.getFieldValue(`START_TIME`),r=e.getFieldValue(`END_TIME`);return[`compareTime(${o(n)}, ${r?o(r):`null`}, ${o(t)})`,i.ATOMIC]},d.Time.blocks.time_get=`<block type="time_get"> <mutation format="false" language="false"></mutation> <field name="OPTION">object</field></block>`,r.time_get={init:function(){this.appendDummyInput().appendField(f(`time_get`)),this.appendDummyInput(`OPTION`).appendField(new e(c(),function(e){this.getSourceBlock().updateShape_(e===`custom`,e===`wdt`||e===`wdts`||e===`Mt`||e===`Mts`)}),`OPTION`),this.setInputsInline(!0),this.setOutput(!0),this.setColour(d.Time.HUE),this.setTooltip(f(`time_get_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){this.updateShape_(u(e.getAttribute(`format`)),u(e.getAttribute(`language`)))},updateShape_:function(n,r){n?this.getInput(`FORMAT`)||this.appendDummyInput(`FORMAT`).appendField(` `).appendField(new t(f(`time_get_default_format`)),`FORMAT`):this.getInput(`FORMAT`)&&this.removeInput(`FORMAT`),r?this.getInput(`LANGUAGE`)||this.appendDummyInput(`LANGUAGE`).appendField(new e(s()),`LANGUAGE`):this.getInput(`LANGUAGE`)&&this.removeInput(`LANGUAGE`)}},a.forBlock.time_get=function(e){let t=e.getFieldValue(`OPTION`),n=e.getFieldValue(`FORMAT`),r=e.getFieldValue(`LANGUAGE`),a;return a=t===`object`?`(new Date().getTime())`:t===`ms`?`(new Date().getMilliseconds())`:t===`s`?`(new Date().getSeconds())`:t===`sid`?`(() => { const v = new Date(); return v.getHours() * 3600 + v.getMinutes() * 60 + v.getSeconds(); })()`:t===`m`?`(new Date().getMinutes())`:t===`mid`?`(() => { const v = new Date(); return v.getHours() * 60 + v.getMinutes(); })()`:t===`h`?`(new Date().getHours())`:t===`d`?`(new Date().getDate())`:t===`M`?`(new Date().getMonth() + 1)`:t===`Mt`?`formatDate(new Date(), 'OO', '${r}')`:t===`Mts`?`formatDate(new Date(), 'O', '${r}')`:t===`y`?`(new Date().getYear())`:t===`fy`?`(new Date().getFullYear())`:t===`wdt`?`formatDate(new Date(), 'WW', '${r}')`:t===`wdts`?`formatDate(new Date(), 'W', '${r}')`:t===`wd`?`(() => { const d = new Date().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); })(new Date())`:t===`custom`?`formatDate(new Date(), ${o(n)})`:`formatDate(new Date(), ${o(t)})`,[a,i.ATOMIC]},d.Time.blocks.time_get_special=`<block type="time_get_special"> <field name="TYPE">dayStart</field></block>`,r.time_get_special={init:function(){this.appendDummyInput().appendField(f(`time_get_special`)),this.appendDummyInput(`TYPE`).appendField(new e([[f(`time_get_special_day_start`),`dayStart`],[f(`time_get_special_day_end`),`dayEnd`],[f(`time_get_special_week_start`),`weekStart`],[f(`time_get_special_week_end`),`weekEnd`],[f(`time_get_special_month_start`),`monthStart`],[f(`time_get_special_month_end`),`monthEnd`]]),`TYPE`),this.setInputsInline(!0),this.setOutput(!0,`Number`),this.setColour(d.Time.HUE),this.setTooltip(f(`time_get_special_tooltip`))}},a.forBlock.time_get_special=function(e){let t=e.getFieldValue(`TYPE`),n=``;return t===`dayStart`?n=`/* start of day */ (() => { const d = new Date(); d.setHours(0, 0, 0, 0); return d.getTime(); })()`:t===`dayEnd`?n=`/* end of day */ (() => { const d = new Date(); d.setHours(23, 59, 59, 999); return d.getTime(); })()`:t===`weekStart`?n=`/* start of week */ (() => { const d = new Date(); d.setHours(0, 0, 0, 0); return new Date(d.getFullYear(), d.getMonth(), d.getDate() - d.getDay() + (d.getDay() == 0 ? -6 : 1)).getTime(); })()`:t===`weekEnd`?n=`/* end of week */ (() => { const d = new Date(); d.setHours(0, 0, 0, 0); return new Date(d.getFullYear(), d.getMonth(), d.getDate() + (8 - d.getDay())).getTime() - 1; })()`:t===`monthStart`?n=`/* start of month */ (() => { const d = new Date(); d.setHours(0, 0, 0, 0); d.setDate(1); return d.getTime(); })()`:t===`monthEnd`&&(n=`/* end of month */ (() => { const d = new Date(); d.setHours(0, 0, 0, 0); return new Date(d.getFullYear(), d.getMonth() + 1, 1).getTime() - 1; })()`),[n,i.ATOMIC]},d.Time.blocks.time_astro=`<block type="time_astro"> <field name="TYPE">sunrise</field> <field name="OFFSET">0</field></block>`,r.time_astro={init:function(){this.appendDummyInput().appendField(f(`time_astro`)),this.appendDummyInput(`TYPE`).appendField(new e([[f(`astro_sunriseText`),`sunrise`],[f(`astro_sunriseEndText`),`sunriseEnd`],[f(`astro_goldenHourEndText`),`goldenHourEnd`],[f(`astro_solarNoonText`),`solarNoon`],[f(`astro_goldenHourText`),`goldenHour`],[f(`astro_sunsetStartText`),`sunsetStart`],[f(`astro_sunsetText`),`sunset`],[f(`astro_duskText`),`dusk`],[f(`astro_nauticalDuskText`),`nauticalDusk`],[f(`astro_nightText`),`night`],[f(`astro_nightEndText`),`nightEnd`],[f(`astro_nauticalDawnText`),`nauticalDawn`],[f(`astro_dawnText`),`dawn`],[f(`astro_nadirText`),`nadir`]]),`TYPE`),this.appendDummyInput(`OFFSET`).appendField(f(`time_astro_offset`)).appendField(new t(`0`),`OFFSET`),this.setInputsInline(!0),this.setOutput(!0),this.setColour(d.Time.HUE),this.setTooltip(f(`time_astro_tooltip`)),this.setHelpUrl(p(`time_astro_help`))}},a.forBlock.time_astro=function(e){return[`getAstroDate('${e.getFieldValue(`TYPE`)}', undefined, ${parseFloat(e.getFieldValue(`OFFSET`))})`,i.ATOMIC]},d.Time.blocks.time_calculation=`<block type="time_calculation"> <field name="OPERATION">+</field> <field name="UNIT">ms</field> <value name="DATE_TIME"> <shadow type="time_get"> <mutation format="false" language="false"></mutation> <field name="OPTION">object</field> </shadow> </value> <value name="VALUE"> <shadow type="math_number"> <field name="NUM">1</field> </shadow> </value></block>`,r.time_calculation={init:function(){this.appendDummyInput(`NAME`).appendField(f(`time_calculation`)),this.appendValueInput(`DATE_TIME`).appendField(f(`time_calculation_on`)).setCheck(null),this.appendDummyInput(`OPERATION`).appendField(new e([[`+`,`+`],[`-`,`-`]]),`OPERATION`),this.appendValueInput(`VALUE`),this.appendDummyInput(`UNIT`).appendField(new e([[f(`time_calculation_ms`),`ms`],[f(`time_calculation_sec`),`sec`],[f(`time_calculation_min`),`min`],[f(`time_calculation_hour`),`hour`],[f(`time_calculation_day`),`day`],[f(`time_calculation_week`),`week`]]),`UNIT`),this.setInputsInline(!0),this.setOutput(!0,`Number`),this.setColour(d.Time.HUE),this.setTooltip(f(`time_calculation_tooltip`))}},a.forBlock.time_calculation=function(e){let t=a.valueToCode(e,`DATE_TIME`,i.ATOMIC),n=e.getFieldValue(`OPERATION`),r=a.valueToCode(e,`VALUE`,i.ATOMIC),o=e.getFieldValue(`UNIT`),s=1;return o===`sec`?s=1e3:o===`min`?s=6e4:o===`hour`?s=36e5:o===`day`?s=864e5:o===`week`&&(s=6048e5),[`/* time calculation */ ((dateTime) => { const ts = (typeof dateTime === 'object' ? dateTime.getTime() : dateTime); return ts ${n} ((${r}) * ${s}); })(${t})`,i.ATOMIC]}}export{d as install};
@@ -0,0 +1 @@
1
+ import{c as e,i as t,o as n,t as r}from"./blockly-B0t_IRJQ.js";import{n as i,r as a}from"./BlocklyEditor-DhwThchX.js";import{a as o}from"./helpers-BwllSRzJ.js";var s={id:`timeout`,marker:`isTimeout_`,variableType:`timeout`},c={id:`interval`,marker:`isInterval_`,variableType:`interval`};function l(e,t){let n=parseFloat(e);return t===`min`?n*6e4:t===`sec`?n*1e3:n}function u(e){return a.nameDB_.safeName(e.getFieldValue(`NAME`))}function d(){let d=window.Blockly,f=d.Translate,p=window.getHelp;d.CustomBlocks=d.CustomBlocks||[],d.CustomBlocks.push(`Timeouts`);let m=()=>[[f(`timeouts_settimeout_ms`),`ms`],[f(`timeouts_settimeout_sec`),`sec`],[f(`timeouts_settimeout_min`),`min`]],h=(t,n,r)=>{for(let i of n.getAllBlocks())if(i!==r&&(i.isTimeout_||i.isInterval_)&&e.equals(i.getFieldValue(`NAME`),t))return!1;return!0},g=(e,t)=>{if(t.isInFlyout)return e;for(;!h(e,t.workspace,t);){let t=e.match(/^(.*?)(\d+)$/);t?e=t[1]+(parseInt(t[2],10)+1):e+=`2`}return e},_=function(e){return g(e.replace(/^[\s\xa0]+|[\s\xa0]+$/g,``),this.getSourceBlock())},v=(e,t)=>{let n=[];for(let r of e.getAllBlocks())if(r[t.marker]){let e=r.getFieldValue(`NAME`);n.push([e,e])}if(window.scripts.loading)for(let t of e.getVariableMap().getVariablesOfType(``))n.find(e=>e[0]===t.getName())||n.push([t.getName(),t.getName()]);for(let r of e.getVariableMap().getVariablesOfType(t.variableType))n.find(e=>e[0]===r.getName())||n.push([r.getName(),r.getName()]);return n.length||n.push([``,``]),n};d.Timeouts={HUE:70,blocks:{},getAllTimeouts:e=>v(e,s),getAllIntervals:e=>v(e,c)};let y=e=>new t(()=>{var t;return(t=window.scripts)!=null&&t.blocklyWorkspace?v(window.scripts.blocklyWorkspace,e):[]});d.Timeouts.blocks.timeouts_wait=`<block type="timeouts_wait"> <field name="DELAY">1000</field> <field name="UNIT">ms</field></block>`,r.timeouts_wait={init:function(){this.appendDummyInput().appendField(f(`timeouts_wait`)).appendField(new n(`1000`),`DELAY`).appendField(new t(m()),`UNIT`),this.setInputsInline(!0),this.setPreviousStatement(!0,null),this.setNextStatement(!0,null),this.setColour(d.Timeouts.HUE),this.setTooltip(f(`timeouts_wait_tooltip`)),this.setHelpUrl(p(`timeouts_wait_help`))}},a.forBlock.timeouts_wait=function(e){return`await wait(${l(e.getFieldValue(`DELAY`),e.getFieldValue(`UNIT`))});\n`};let b=(e,s)=>{let c=e.id===`timeout`,h=`timeouts_set${e.id}${s?`_variable`:``}`,v=c?`DELAY`:`INTERVAL`,y=c?`DELAY_MS`:`INTERVAL_MS`,b=`timeouts_set${e.id}`,x=c?`timeout`:f(`timeouts_setinterval_name`);r[h]={init:function(){let e=new n(g(x,this),_);e.setSpellcheck(!1);let r=this.appendDummyInput().appendField(f(b)).appendField(e,`NAME`).appendField(f(`${b}_in`));s?this.appendValueInput(y).setCheck(`Number`).appendField(f(`timeouts_settimeout_ms`)):r.appendField(new n(`1000`),v).appendField(new t(m()),`UNIT`),this.appendStatementInput(`STATEMENT`).setCheck(null),this.setInputsInline(s),this.setPreviousStatement(!0,null),this.setNextStatement(!0,null),this.setColour(d.Timeouts.HUE),this.setTooltip(f(`${b}_tooltip`)),this.setHelpUrl(p(`${b}_help`))},[e.marker]:!0,getVars:function(){return[this.getFieldValue(`NAME`)]},getVarModels:function(){return[o(this.getFieldValue(`NAME`),e.variableType)]}},a.forBlock[h]=function(e){let t=u(e),n=a.statementToCode(e,`STATEMENT`),r=s?`parseInt(${a.valueToCode(e,y,i.ATOMIC)})`:String(l(e.getFieldValue(v),e.getFieldValue(`UNIT`))),o=c?`${a.prefixLines(`${t} = null;`,a.INDENT)}\n`:``;return`${t} = ${c?`setTimeout`:`setInterval`}(async () => {\n${o}${n}}, ${r});\n`}},x=e=>{let t=`timeouts_clear${e.id}`,n=`timeouts_get${e.id}`;d.Timeouts.blocks[t]=`<sep gap="5"></sep><block type="${t}"> <field name="NAME"></field></block>`,r[t]={init:function(){this.appendDummyInput(`NAME`).appendField(f(t)).appendField(y(e),`NAME`),this.setInputsInline(!0),this.setPreviousStatement(!0,null),this.setNextStatement(!0,null),this.setColour(d.Timeouts.HUE),this.setTooltip(f(`${t}_tooltip`)),this.setHelpUrl(p(`${t}_help`))}},a.forBlock[t]=function(t){let n=u(t);return`(() => { if (${n}) { ${e.id===`timeout`?`clearTimeout`:`clearInterval`}(${n}); ${n} = null; }})();\n`},d.Timeouts.blocks[n]=`<sep gap="5"></sep><block type="${n}"> <field name="NAME"></field></block>`,r[n]={init:function(){this.appendDummyInput(`NAME`).appendField(f(n)).appendField(y(e),`NAME`),this.setInputsInline(!0),this.setOutput(!0),this.setColour(d.Timeouts.HUE),this.setTooltip(f(`${n}_tooltip`)),this.setHelpUrl(p(`${n}_help`))}},a.forBlock[n]=function(e){return[u(e),i.ATOMIC]}};d.Timeouts.blocks.timeouts_settimeout=`<block type="timeouts_settimeout"> <field name="NAME">timeout</field> <field name="DELAY">1000</field> <field name="UNIT">ms</field></block>`,b(s,!1),d.Timeouts.blocks.timeouts_settimeout_variable=`<sep gap="5"></sep><block type="timeouts_settimeout_variable"> <value name="DELAY_MS"> <shadow type="math_number"> <field name="NUM">1000</field> </shadow> </value></block>`,b(s,!0),x(s),d.Timeouts.blocks.timeouts_setinterval=`<block type="timeouts_setinterval"> <field name="INTERVAL">1000</field> <field name="UNIT">ms</field></block>`,b(c,!1),d.Timeouts.blocks.timeouts_setinterval_variable=`<sep gap="5"></sep><block type="timeouts_setinterval_variable"> <value name="INTERVAL_MS"> <shadow type="math_number"> <field name="NUM">1000</field> </shadow> </value></block>`,b(c,!0),x(c)}export{d as install};
@@ -1,2 +1,2 @@
1
- import{c as e,f as t,i as n,o as r,r as i,s as a,t as o}from"./blockly-fcfyKYzp.js";import{c as s,l as c}from"./index-B3s0zmWC.js";import{a as l,c as u,f as d,l as f,o as p,p as m,r as h,s as g}from"./helpers-CnEjYAup.js";import{FieldOID as _}from"./field_oid-lWCjOzuq.js";import{FieldCRON as v}from"./field_cron-Ba46q8Qc.js";function y(e){return c.nameDB_.safeName(e.getFieldValue(`NAME`))}function b(){let b=window.Blockly,x=b.Translate,S=window.getHelp;b.CustomBlocks=b.CustomBlocks||[],b.CustomBlocks.push(`Trigger`);let C=e=>{let t=[];for(let n of e.getAllBlocks())if(n.isSchedule_){let e=n.getFieldValue(`NAME`);t.push([e,e])}if(window.scripts.loading)for(let n of e.getVariableMap().getVariablesOfType(``))t.find(e=>e[0]===n.getName())||t.push([n.getName(),n.getName()]);for(let n of e.getVariableMap().getVariablesOfType(`cron`))t.find(e=>e[0]===n.getName())||t.push([n.getName(),n.getName()]);return t.length||t.push([``,``]),t};b.Trigger={HUE:330,getAllSchedules:C,blocks:{},WARNING_PARENTS:[`on`,`on_ext`,`schedule`,`schedule_by_id`,`schedule_create`,`astro`,`onMessage`,`onFile`,`onLog`,`onEnumMembers`,`timeouts_setinterval`,`timeouts_setinterval_variable`,`controls_repeat_ext`,`controls_repeat_ext`,`controls_for`,`controls_forEach`]};let w=()=>[[x(`on_onchange`),`ne`],[x(`on_any`),`any`],[x(`on_gt`),`gt`],[x(`on_ge`),`ge`],[x(`on_lt`),`lt`],[x(`on_le`),`le`],[x(`on_true`),`true`],[x(`on_false`),`false`]],T=()=>[[x(`on_ack_any`),``],[x(`on_ack_true`),`true`],[x(`on_ack_false`),`false`]],E=e=>e===`true`||e===`false`?`val: ${e}`:`change: '${e}'`,D=()=>`${c.prefixLines(`let value = obj.state.val;`,c.INDENT)}\n${c.prefixLines(`let oldValue = obj.oldState.val;`,c.INDENT)}\n`,O=(e,t,n,r)=>{setTimeout(()=>{var i;if(!((i=t.connection)!=null&&i.isConnected())){let i=e.newBlock(n);i.setShadow(!0),r&&i.setFieldValue(r[1],r[0]),i.outputConnection.connect(t.connection),i.initSvg(),i.render()}},100)},k=(e,t,r,i,a,s,c)=>{o[e]={init:function(){this.appendDummyInput().appendField(t),this.appendDummyInput(`ATTR`).appendField(new n(r),`ATTR`),this.setInputsInline(!0),this.setOutput(!0),this.setColour(s),this.setTooltip(x(`${e}_tooltip`)),c&&this.setHelpUrl(S(c))},onchange:function(){m(this,i,a)},FUNCTION_TYPES:i}};b.Trigger.blocks.on_ext=`<block type="on_ext"> <mutation items="1"></mutation> <field name="CONDITION">ne</field> <field name="ACK_CONDITION"></field> <value name="OID0"> <shadow type="field_oid"> </shadow> </value></block>`,o.on_ext_oid_container={init:function(){this.appendDummyInput().appendField(x(`on_ext_on`)),this.appendStatementInput(`STACK`),this.setColour(b.Trigger.HUE),this.setTooltip(x(`on_ext_on_tooltip`)),this.contextMenu=!1}},o.on_ext_oid={init:function(){this.appendDummyInput(`OID`).appendField(x(`on_ext_oid`)),this.setPreviousStatement(!0),this.setNextStatement(!0),this.setColour(b.Trigger.HUE),this.setTooltip(x(`on_ext_oid_tooltip`)),this.contextMenu=!1}},o.on_ext={init:function(){this.itemCount_=1,this.setMutator(new t.MutatorIcon([`on_ext_oid`],this)),this.setInputsInline(!1),this.setPreviousStatement(!0,null),this.setNextStatement(!0,null),this.setColour(b.Trigger.HUE),this.setTooltip(x(`on_ext_tooltip`)),this.setHelpUrl(S(`on_help`))},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(`on_ext_oid_container`);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(`on_ext_oid`);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(`OID${e}`))==null||(r=r.connection)==null?void 0:r.targetConnection;t&&!n.includes(t)&&t.disconnect()}this.itemCount_=n.length,this.itemCount_<1&&(this.itemCount_=1),this.updateShape_();for(let e=0;e<this.itemCount_;e++)f(n[e],this,`OID${e}`)},saveConnections:function(e){let t=e.getInputTargetBlock(`STACK`),n=0;for(;t;){var r,i;t.valueConnection_=(r=this.getInput(`OID${n}`))==null||(r=r.connection)==null?void 0:r.targetConnection,n++,t=(i=t.nextConnection)==null?void 0:i.targetBlock()}},updateShape_:function(){let e;this.getInput(`CONDITION`)&&(e=this.getFieldValue(`CONDITION`),this.removeInput(`CONDITION`));let t;this.getInput(`ACK_CONDITION`)&&(t=this.getFieldValue(`ACK_CONDITION`),this.removeInput(`ACK_CONDITION`));let r;for(let e=0;this.inputList[e];e++)if(this.inputList[e].name===`STATEMENT`){r=this.inputList[e],this.inputList.splice(e,1);break}let i=this.workspace,a=0;for(;a<this.itemCount_;a++){let e=this.getInput(`OID${a}`);e||(e=this.appendValueInput(`OID${a}`),a===0&&e.appendField(x(`on_ext`))),O(i,e,`field_oid`)}for(;this.getInput(`OID${a}`);)this.removeInput(`OID${a}`),a++;this.appendDummyInput(`CONDITION`).appendField(new n(w()),`CONDITION`),e&&this.setFieldValue(e,`CONDITION`),this.appendDummyInput(`ACK_CONDITION`).appendField(x(`on_ack`)).appendField(new n(T()),`ACK_CONDITION`),t&&this.setFieldValue(t,`ACK_CONDITION`),r?this.inputList.push(r):this.appendStatementInput(`STATEMENT`).setCheck(null)},onchange:function(){d(this)}},c.forBlock.on_ext=function(e){let t=e,n=E(e.getFieldValue(`CONDITION`)),r=e.getFieldValue(`ACK_CONDITION`),i=[];for(let n=0;n<t.itemCount_;n++){let t=c.valueToCode(e,`OID${n}`,s.COMMA);t&&(t=t.toString(),t.startsWith(`'`)&&t.endsWith(`'`)&&(t=`[${t}]`),i.includes(t)||i.push(t))}let a=`[].concat(${i.join(`).concat(`)})`,o=c.statementToCode(e,`STATEMENT`);return`on({ id: ${a}, ${n}${r?`, ack: ${r}`:``} }, async (obj) => {\n${i.length===1?D():``}${o}});\n`},b.Trigger.blocks.on=`<sep gap="5"></sep><block type="on"> <field name="CONDITION">ne</field> <field name="ACK_CONDITION"></field></block>`,o.on={init:function(){this.appendDummyInput().appendField(x(`on`)),this.appendDummyInput(`OID`).appendField(new _(x(`select_id`),`state`),`OID`),this.appendDummyInput(`CONDITION`).appendField(new n(w()),`CONDITION`),this.appendDummyInput(`ACK_CONDITION`).appendField(x(`on_ack`)).appendField(new n(T()),`ACK_CONDITION`),this.appendStatementInput(`STATEMENT`).setCheck(null),this.setInputsInline(!1),this.setPreviousStatement(!0,null),this.setNextStatement(!0,null),this.setColour(b.Trigger.HUE),this.setTooltip(x(`on_tooltip`)),this.setHelpUrl(S(`on_help`))},onchange:function(){d(this)}},c.forBlock.on=function(e){let t=e.getFieldValue(`OID`),n=E(e.getFieldValue(`CONDITION`)),r=e.getFieldValue(`ACK_CONDITION`);a.VARIABLES_DEFAULT_NAME=`value`;let i=p(t),o=c.statementToCode(e,`STATEMENT`);return`on({ id: '${t}'${i?` /* ${i} */`:``}, ${n}${r?`, ack: ${r}`:``} }, async (obj) => {\n${D()}${o}});\n`},b.Trigger.blocks.on_source=`<sep gap="5"></sep><block type="on_source"> <field name="ATTR">state.val</field></block>`,k(`on_source`,`↪`,[[x(`on_source_state_val`),`state.val`],[x(`on_source_state_ts`),`state.ts`],[x(`on_source_state_q`),`state.q`],[x(`on_source_state_from`),`state.from`],[x(`on_source_state_ack`),`state.ack`],[x(`on_source_state_lc`),`state.lc`],[x(`on_source_state_c`),`state.c`],[x(`on_source_state_user`),`state.user`],[x(`on_source_id`),`id`],[x(`on_source_name`),`common.name`],[x(`on_source_desc`),`common.desc`],[x(`on_source_channel_id`),`channelId`],[x(`on_source_channel_name`),`channelName`],[x(`on_source_device_id`),`deviceId`],[x(`on_source_device_name`),`deviceName`],[x(`on_source_oldstate_val`),`oldState.val`],[x(`on_source_oldstate_ts`),`oldState.ts`],[x(`on_source_oldstate_q`),`oldState.q`],[x(`on_source_oldstate_from`),`oldState.from`],[x(`on_source_oldstate_ack`),`oldState.ack`],[x(`on_source_oldstate_lc`),`oldState.lc`],[x(`on_source_oldstate_c`),`oldState.c`],[x(`on_source_oldstate_user`),`oldState.user`]],[`on`,`on_ext`,`onEnumMembers`],`on_source_warning`,b.Trigger.HUE,`on_help`),c.forBlock.on_source=function(e){let t=e.getFieldValue(`ATTR`),n=t.split(`.`);return[n.length>1?`(obj.${n[0]} ? obj.${t} : '')`:`obj.${t}`,s.ATOMIC]},b.Trigger.blocks.on_ack_value=`<sep gap="5"></sep><block type="on_ack_value"></block>`,o.on_ack_value={init:function(){this.appendDummyInput().appendField(`↪ ${x(`on_ack_value`)}`),this.setInputsInline(!1),this.setPreviousStatement(!0,null),this.setNextStatement(!0,null),this.setColour(b.Trigger.HUE),this.setTooltip(x(`on_ack_value_tooltip`)),this.setHelpUrl(S(`on_help`))},onchange:function(){m(this,[`on`,`on_ext`,`onEnumMembers`],`on_ack_value_warning`)},FUNCTION_TYPES:[`on`,`on_ext`,`onEnumMembers`]},c.forBlock.on_ack_value=function(){return`if (obj.id && obj?.state && !obj.state.ack) {
2
- ${c.prefixLines(`await setStateAsync(obj.id, { val: obj.state.val, ack: true });`,c.INDENT)}\n}\n`},b.Trigger.blocks.astro=`<block type="astro"> <field name="TYPE">sunrise</field> <field name="OFFSET">0</field></block>`,o.astro={init:function(){this.appendDummyInput().appendField(x(`astro`)),this.appendDummyInput(`TYPE`).appendField(new n([[x(`astro_sunriseText`),`sunrise`],[x(`astro_sunriseEndText`),`sunriseEnd`],[x(`astro_goldenHourEndText`),`goldenHourEnd`],[x(`astro_solarNoonText`),`solarNoon`],[x(`astro_goldenHourText`),`goldenHour`],[x(`astro_sunsetStartText`),`sunsetStart`],[x(`astro_sunsetText`),`sunset`],[x(`astro_duskText`),`dusk`],[x(`astro_nauticalDuskText`),`nauticalDusk`],[x(`astro_nightText`),`night`],[x(`astro_nightEndText`),`nightEnd`],[x(`astro_nauticalDawnText`),`nauticalDawn`],[x(`astro_dawnText`),`dawn`],[x(`astro_nadirText`),`nadir`]]),`TYPE`),this.appendDummyInput().appendField(x(`astro_offset`)),this.appendDummyInput(`OFFSET`).appendField(new r(`0`),`OFFSET`),this.appendDummyInput().appendField(x(`astro_minutes`)),this.appendStatementInput(`STATEMENT`).setCheck(null),this.setInputsInline(!0),this.setPreviousStatement(!0,null),this.setNextStatement(!0,null),this.setColour(b.Trigger.HUE),this.setTooltip(x(`astro_tooltip`)),this.setHelpUrl(S(`astro_help`))},onchange:function(){d(this)}},c.forBlock.astro=function(e){return`schedule({ astro: '${e.getFieldValue(`TYPE`)}', shift: ${parseInt(e.getFieldValue(`OFFSET`),10)} }, async () => {\n${c.statementToCode(e,`STATEMENT`)}});\n`},b.Trigger.blocks.schedule=`<block type="schedule"> <field name="SCHEDULE">* * * * *</field></block>`,o.schedule={init:function(){this.appendDummyInput().appendField(x(`schedule`)),this.appendDummyInput(`SCHEDULE`).appendField(new v(`* * * * *`),`SCHEDULE`),this.appendStatementInput(`STATEMENT`).setCheck(null),this.setInputsInline(!1),this.setPreviousStatement(!0,null),this.setNextStatement(!0,null),this.setColour(b.Trigger.HUE),this.setTooltip(x(`schedule_tooltip`)),this.setHelpUrl(S(`schedule_help`))},onchange:function(){d(this)}},c.forBlock.schedule=function(e){let t=e.getFieldValue(`SCHEDULE`),n=c.statementToCode(e,`STATEMENT`);return`schedule(${t.startsWith(`{`)?`'${t}'`:`"${t}"`}, async () => {\n${n}});\n`},b.Trigger.blocks.schedule_by_id=`<block type="schedule_by_id"> <field name="ACK_CONDITION"></field></block>`,o.schedule_by_id={init:function(){this.appendDummyInput().appendField(x(`schedule_by_id`)),this.appendDummyInput(`OID`).appendField(new _(x(`select_id`),`state`),`OID`),this.appendDummyInput(`ACK_CONDITION`).appendField(x(`on_ack`)).appendField(new n(T()),`ACK_CONDITION`),this.appendStatementInput(`STATEMENT`).setCheck(null),this.setInputsInline(!1),this.setPreviousStatement(!0,null),this.setNextStatement(!0,null),this.setColour(b.Trigger.HUE),this.setTooltip(x(`schedule_by_id_tooltip`)),this.setHelpUrl(S(`schedule_by_id_help`))}},c.forBlock.schedule_by_id=function(e){let t=e.getFieldValue(`OID`),n=e.getFieldValue(`ACK_CONDITION`),r=c.statementToCode(e,`STATEMENT`),i=p(t);return`scheduleById('${t}'${i?` /* ${i} */`:``}${n?`, ${n}`:``}, async () => {\n${r}});\n`},b.Trigger.blocks.schedule_create=`<block type="schedule_create"> <field name="NAME">schedule</field> <value name="SCHEDULE"> <shadow type="field_cron"> </shadow> </value></block>`;let A=(t,n,r)=>{if(t===`schedule`)return!1;for(let i of n.getAllBlocks())if(i!==r&&i.isSchedule_&&e.equals(i.getFieldValue(`NAME`),t))return!1;return!0},j=(e,t)=>{if(t.isInFlyout)return e;for(;!A(e,t.workspace,t);){let t=e.match(/^(.*?)(\d+)$/);t?e=t[1]+(parseInt(t[2],10)+1):e+=`1`}return e},M=function(e){return j(e.replace(/^[\s\xa0]+|[\s\xa0]+$/g,``),this.getSourceBlock())};o.schedule_create={init:function(){let e=new r(j(`schedule`,this),M);e.setSpellcheck(!1),this.appendDummyInput(`NAME`).appendField(x(`schedule_create`)).appendField(e,`NAME`),this.appendValueInput(`SCHEDULE`).appendField(x(`schedule_text`)),this.appendStatementInput(`STATEMENT`).setCheck(null),this.setInputsInline(!1),this.setPreviousStatement(!0,null),this.setNextStatement(!0,null),this.setColour(b.Trigger.HUE),this.setTooltip(x(`schedule_create_tooltip`)),this.setHelpUrl(S(`schedule_create_help`))},isSchedule_:!0,getVars:function(){return[this.getFieldValue(`NAME`)]},getVarModels:function(){return[l(this.getFieldValue(`NAME`),`cron`)]}},c.forBlock.schedule_create=function(e){return`${y(e)} = schedule(${c.valueToCode(e,`SCHEDULE`,s.ATOMIC)}, async () => {\n${c.statementToCode(e,`STATEMENT`)}});\n`},b.Trigger.blocks.schedule_clear=`<sep gap="5"></sep><block type="schedule_clear"> <field name="NAME"></field></block>`,o.schedule_clear={init:function(){this.appendDummyInput(`NAME`).appendField(x(`schedule_clear`)).appendField(new n(()=>{var e;return(e=window.scripts)!=null&&e.blocklyWorkspace?C(window.scripts.blocklyWorkspace):[]}),`NAME`),this.setInputsInline(!0),this.setPreviousStatement(!0,null),this.setNextStatement(!0,null),this.setColour(b.Trigger.HUE),this.setTooltip(x(`schedule_clear_tooltip`)),this.setHelpUrl(S(`schedule_clear_help`))}},c.forBlock.schedule_clear=function(e){let t=y(e);return`(() => { if (${t}) { clearSchedule(${t}); ${t} = null; }})();\n`},b.Trigger.blocks.field_cron=`<sep gap="5"></sep><block type="field_cron"> <field name="CRON">* * * * *</field></block>`,o.field_cron={init:function(){this.appendDummyInput().appendField(x(`field_cron_CRON`)),this.appendDummyInput().appendField(new v(`* * * * *`),`CRON`),this.setInputsInline(!0),this.setOutput(!0,`String`),this.setColour(b.Trigger.HUE),this.setTooltip(x(`field_cron_tooltip`))}},c.forBlock.field_cron=function(e){return[`'${e.getFieldValue(`CRON`)}'`,s.ATOMIC]},b.Trigger.blocks.cron_builder=`<sep gap="5"></sep><block type="cron_builder"> <mutation seconds="false" as_line="false"></mutation> <field name="LINE">FALSE</field> <field name="WITH_SECONDS">FALSE</field> <value name="DOW"> <shadow type="text"> <field name="TEXT">*</field> </shadow> </value> <value name="MONTHS"> <shadow type="text"> <field name="TEXT">*</field> </shadow> </value> <value name="DAYS"> <shadow type="text"> <field name="TEXT">*</field> </shadow> </value> <value name="HOURS"> <shadow type="text"> <field name="TEXT">*</field> </shadow> </value> <value name="MINUTES"> <shadow type="text"> <field name="TEXT">*</field> </shadow> </value></block>`,o.cron_builder={init:function(){this.appendDummyInput().appendField(x(`cron_builder_CRON`)),this.appendDummyInput(`LINE`).appendField(x(`cron_builder_line`)).appendField(new i(`FALSE`,function(e){var t;(t=this.getSourceBlock())==null||t.setInputsInline(h(e))}),`LINE`);let e=this.workspace;for(let[t,n]of[[`DOW`,`cron_builder_dow`],[`MONTHS`,`cron_builder_month`],[`DAYS`,`cron_builder_day`],[`HOURS`,`cron_builder_hour`],[`MINUTES`,`cron_builder_minutes`]]){let r=this.appendValueInput(t).appendField(x(n));O(e,r,`text`,[`TEXT`,`*`])}this.appendDummyInput(`WITH_SECONDS`).appendField(x(`cron_builder_with_seconds`)).appendField(new i(`FALSE`,function(e){this.getSourceBlock().updateShape_(h(e))}),`WITH_SECONDS`),this.seconds_=!1,this.as_line_=!1,this.setInputsInline(this.as_line_),this.setOutput(!0,`String`),this.setColour(b.Trigger.HUE),this.setTooltip(x(`field_cron_tooltip`))},mutationToDom:function(){let e=document.createElement(`mutation`);return e.setAttribute(`seconds`,String(this.seconds_)),e.setAttribute(`as_line`,String(this.as_line_)),e},domToMutation:function(e){this.seconds_=e.getAttribute(`seconds`)===`true`,this.as_line_=e.getAttribute(`as_line`)===`true`,this.setInputsInline(this.as_line_),this.updateShape_(this.seconds_)},updateShape_:function(e){if(this.seconds_=e,e){if(!this.getInput(`SECONDS`)){let e=this.appendValueInput(`SECONDS`).appendField(x(`cron_builder_seconds`));O(this.workspace,e,`text`,[`TEXT`,`*`])}}else this.getInput(`SECONDS`)&&this.removeInput(`SECONDS`)}},c.forBlock.cron_builder=function(e){let t=t=>c.valueToCode(e,t,s.ATOMIC),n=e.getFieldValue(`WITH_SECONDS`),r=n&&e.getInput(`SECONDS`)?t(`SECONDS`):`0`;return[(h(n)?`${r}.toString().trim() + ' ' + `:``)+`${t(`MINUTES`)}.toString().trim() + ' ' + ${t(`HOURS`)}.toString().trim() + ' ' + ${t(`DAYS`)}.toString().trim() + ' ' + ${t(`MONTHS`)}.toString().trim() + ' ' + ${t(`DOW`)}.toString().trim()`,s.ATOMIC]},b.Trigger.blocks.onMessage=`<block type="onMessage"> <field name="MESSAGE">customMessage</field></block>`,o.onMessage={init:function(){this.appendDummyInput(`NAME`).appendField(`✉️ ${x(`onMessage`)}`),this.appendDummyInput(`MESSAGE`).appendField(x(`onMessage_message`)).appendField(new r(`customMessage`),`MESSAGE`),this.appendStatementInput(`STATEMENT`).setCheck(null),this.setInputsInline(!1),this.setPreviousStatement(!0,null),this.setNextStatement(!0,null),this.setColour(b.Trigger.HUE),this.setTooltip(x(`onMessage_tooltip`)),this.setHelpUrl(S(`onMessage_help`))},onchange:function(){d(this)}},c.forBlock.onMessage=function(e){let t=e.getFieldValue(`MESSAGE`),n=c.statementToCode(e,`STATEMENT`);return`onMessage(${u(t)}, async (data, callback) => {\n${n}${c.prefixLines(`typeof callback === 'function' && callback({ result: true }); // default callback`,c.INDENT)}\n});\n`},b.Trigger.blocks.onMessage_data=`<sep gap="5"></sep><block type="onMessage_data"> <field name="ATTR">data</field></block>`,k(`onMessage_data`,`✉️ `,[[x(`onMessage_data_data`),`data`]],[`onMessage`],`onMessage_data_warning`,b.Action.HUE,`onMessage_data_help`),c.forBlock.onMessage_data=function(e){return[e.getFieldValue(`ATTR`),s.ATOMIC]},b.Trigger.blocks.onFile=`<block type="onFile"> <field name="WITH_FILE">FALSE</field> <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">*</field> </shadow> </value></block>`,o.onFile={init:function(){this.appendValueInput(`OID`).appendField(`📁 ${x(`onFile`)}`).setCheck(null),this.appendValueInput(`FILE`).appendField(x(`onFile_file`)).setCheck(null),this.appendDummyInput(`WITH_FILE_INPUT`).appendField(x(`onFile_withFile`)).appendField(new i(`FALSE`),`WITH_FILE`),this.appendStatementInput(`STATEMENT`).setCheck(null),this.setInputsInline(!1),this.setPreviousStatement(!0,null),this.setNextStatement(!0,null),this.setColour(b.Trigger.HUE),this.setTooltip(x(`onFile_tooltip`)),this.setHelpUrl(S(`onFile_help`))},onchange:function(){d(this)}},c.forBlock.onFile=function(e){let t=c.valueToCode(e,`OID`,s.ATOMIC),n=c.valueToCode(e,`FILE`,s.ATOMIC),r=e.getFieldValue(`WITH_FILE`),i=c.statementToCode(e,`STATEMENT`),a=g(t);return`onFile(${t}${a?` /* ${a} */`:``}, ${n}, ${r===`TRUE`?`true`:`false`}, async (id, fileName, size, data, mimeType) => {\n${i}});\n`},b.Trigger.blocks.onFile_data=`<sep gap="5"></sep><block type="onFile_data"> <field name="ATTR">data</field></block>`,k(`onFile_data`,`📁`,[[x(`onFile_data_data`),`data`],[x(`onFile_data_filename`),`fileName`],[x(`onFile_data_size`),`size`],[x(`onFile_data_mimeType`),`mimeType`],[x(`onFile_data_id`),`id`],[x(`onFile_data_tempFile`),`TEMP_FILE_PATH`]],[`onFile`],`onFile_data_warning`,b.Trigger.HUE),c.forBlock.onFile_data=function(e){let t=e.getFieldValue(`ATTR`);return t===`TEMP_FILE_PATH`?[`createTempFile(fileName, data)`,s.ATOMIC]:[t,s.ATOMIC]},b.Trigger.blocks.offFile=`<sep gap="5"></sep><block type="offFile"> <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">*</field> </shadow> </value></block>`,o.offFile={init:function(){this.appendValueInput(`OID`).appendField(`📁 ${x(`offFile`)}`).setCheck(null),this.appendValueInput(`FILE`).appendField(x(`onFile_file`)).setCheck(null),this.setInputsInline(!1),this.setPreviousStatement(!0,null),this.setNextStatement(!0,null),this.setColour(b.Trigger.HUE),this.setTooltip(x(`offFile_tooltip`)),this.setHelpUrl(S(`offFile_help`))}},c.forBlock.offFile=function(e){let t=c.valueToCode(e,`OID`,s.ATOMIC),n=c.valueToCode(e,`FILE`,s.ATOMIC),r=g(t);return`offFile(${t}${r?` /* ${r} */`:``}, ${n});\n`},b.Trigger.blocks.onLog=`<block type="onLog"> <field name="Severity">error</field></block>`,o.onLog={init:function(){this.appendDummyInput(`TEXT`).appendField(`💬 ${x(`onLog`)}`),this.appendDummyInput(`Severity`).appendField(x(`loglevel`)).appendField(new n([[x(`loglevel_error`),`error`],[x(`loglevel_warn`),`warn`],[x(`loglevel_info`),`info`],[x(`loglevel_debug`),`debug`],[x(`loglevel_all`),`*`]]),`Severity`),this.appendStatementInput(`STATEMENT`).setCheck(null),this.setInputsInline(!1),this.setPreviousStatement(!0,null),this.setNextStatement(!0,null),this.setColour(b.Trigger.HUE),this.setTooltip(x(`onLog_tooltip`)),this.setHelpUrl(S(`onLog_help`))},onchange:function(){d(this)}},c.forBlock.onLog=function(e){let t=c.statementToCode(e,`STATEMENT`);return`onLog('${e.getFieldValue(`Severity`)}', async (data) => {\n${t}});\n`},b.Trigger.blocks.onLog_data=`<sep gap="5"></sep><block type="onLog_data"> <field name="ATTR">data.message</field></block>`,k(`onLog_data`,`💬 `,[[x(`onLog_data_message`),`data.message`],[x(`loglevel`),`data.severity`],[x(`onLog_data_from`),`data.from`],[x(`onLog_data_ts`),`data.ts`]],[`onLog`],`onLog_data_warning`,b.Trigger.HUE),c.forBlock.onLog_data=function(e){return[e.getFieldValue(`ATTR`),s.ATOMIC]},b.Trigger.blocks.onEnumMembers=`<block type="onEnumMembers"></block>`,o.onEnumMembers={init:function(){this.appendDummyInput().appendField(x(`onEnumMembers`)),this.appendDummyInput(`OID`).appendField(new _(x(`select_id`),`enum`),`OID`),this.appendStatementInput(`STATEMENT`).setCheck(null),this.setInputsInline(!1),this.setPreviousStatement(!0,null),this.setNextStatement(!0,null),this.setColour(b.Trigger.HUE),this.setTooltip(x(`onEnumMembers_tooltip`)),this.setHelpUrl(S(`onEnumMembers_help`))},onchange:function(){d(this)}},c.forBlock.onEnumMembers=function(e){let t=e.getFieldValue(`OID`),n=c.statementToCode(e,`STATEMENT`),r=p(t);return`onEnumMembers('${t}'${r?` /* ${r} */`:``}, async (obj) => {\n${D()}${n}});\n`}}export{b as install};
1
+ import{c as e,i as t,o as n,p as r,r as i,s as a,t as o}from"./blockly-B0t_IRJQ.js";import{n as s,r as c}from"./BlocklyEditor-DhwThchX.js";import{a as l,c as u,f as d,l as f,o as p,p as m,r as h,s as g}from"./helpers-BwllSRzJ.js";import{FieldOID as _}from"./field_oid-rBhotXJe.js";import{FieldCRON as v}from"./field_cron-RgLY53_S.js";function y(e){return c.nameDB_.safeName(e.getFieldValue(`NAME`))}function b(){let b=window.Blockly,x=b.Translate,S=window.getHelp;b.CustomBlocks=b.CustomBlocks||[],b.CustomBlocks.push(`Trigger`);let C=e=>{let t=[];for(let n of e.getAllBlocks())if(n.isSchedule_){let e=n.getFieldValue(`NAME`);t.push([e,e])}if(window.scripts.loading)for(let n of e.getVariableMap().getVariablesOfType(``))t.find(e=>e[0]===n.getName())||t.push([n.getName(),n.getName()]);for(let n of e.getVariableMap().getVariablesOfType(`cron`))t.find(e=>e[0]===n.getName())||t.push([n.getName(),n.getName()]);return t.length||t.push([``,``]),t};b.Trigger={HUE:330,getAllSchedules:C,blocks:{},WARNING_PARENTS:[`on`,`on_ext`,`schedule`,`schedule_by_id`,`schedule_create`,`astro`,`onMessage`,`onFile`,`onLog`,`onEnumMembers`,`timeouts_setinterval`,`timeouts_setinterval_variable`,`controls_repeat_ext`,`controls_repeat_ext`,`controls_for`,`controls_forEach`]};let w=()=>[[x(`on_onchange`),`ne`],[x(`on_any`),`any`],[x(`on_gt`),`gt`],[x(`on_ge`),`ge`],[x(`on_lt`),`lt`],[x(`on_le`),`le`],[x(`on_true`),`true`],[x(`on_false`),`false`]],T=()=>[[x(`on_ack_any`),``],[x(`on_ack_true`),`true`],[x(`on_ack_false`),`false`]],E=e=>e===`true`||e===`false`?`val: ${e}`:`change: '${e}'`,D=()=>`${c.prefixLines(`let value = obj.state.val;`,c.INDENT)}\n${c.prefixLines(`let oldValue = obj.oldState.val;`,c.INDENT)}\n`,O=(e,t,n,r)=>{setTimeout(()=>{var i;if(!((i=t.connection)!=null&&i.isConnected())){let i=e.newBlock(n);i.setShadow(!0),r&&i.setFieldValue(r[1],r[0]),i.outputConnection.connect(t.connection),i.initSvg(),i.render()}},100)},k=(e,n,r,i,a,s,c)=>{o[e]={init:function(){this.appendDummyInput().appendField(n),this.appendDummyInput(`ATTR`).appendField(new t(r),`ATTR`),this.setInputsInline(!0),this.setOutput(!0),this.setColour(s),this.setTooltip(x(`${e}_tooltip`)),c&&this.setHelpUrl(S(c))},onchange:function(){m(this,i,a)},FUNCTION_TYPES:i}};b.Trigger.blocks.on_ext=`<block type="on_ext"> <mutation items="1"></mutation> <field name="CONDITION">ne</field> <field name="ACK_CONDITION"></field> <value name="OID0"> <shadow type="field_oid"> </shadow> </value></block>`,o.on_ext_oid_container={init:function(){this.appendDummyInput().appendField(x(`on_ext_on`)),this.appendStatementInput(`STACK`),this.setColour(b.Trigger.HUE),this.setTooltip(x(`on_ext_on_tooltip`)),this.contextMenu=!1}},o.on_ext_oid={init:function(){this.appendDummyInput(`OID`).appendField(x(`on_ext_oid`)),this.setPreviousStatement(!0),this.setNextStatement(!0),this.setColour(b.Trigger.HUE),this.setTooltip(x(`on_ext_oid_tooltip`)),this.contextMenu=!1}},o.on_ext={init:function(){this.itemCount_=1,this.setMutator(new r.MutatorIcon([`on_ext_oid`],this)),this.setInputsInline(!1),this.setPreviousStatement(!0,null),this.setNextStatement(!0,null),this.setColour(b.Trigger.HUE),this.setTooltip(x(`on_ext_tooltip`)),this.setHelpUrl(S(`on_help`))},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(`on_ext_oid_container`);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(`on_ext_oid`);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(`OID${e}`))==null||(r=r.connection)==null?void 0:r.targetConnection;t&&!n.includes(t)&&t.disconnect()}this.itemCount_=n.length,this.itemCount_<1&&(this.itemCount_=1),this.updateShape_();for(let e=0;e<this.itemCount_;e++)f(n[e],this,`OID${e}`)},saveConnections:function(e){let t=e.getInputTargetBlock(`STACK`),n=0;for(;t;){var r,i;t.valueConnection_=(r=this.getInput(`OID${n}`))==null||(r=r.connection)==null?void 0:r.targetConnection,n++,t=(i=t.nextConnection)==null?void 0:i.targetBlock()}},updateShape_:function(){let e;this.getInput(`CONDITION`)&&(e=this.getFieldValue(`CONDITION`),this.removeInput(`CONDITION`));let n;this.getInput(`ACK_CONDITION`)&&(n=this.getFieldValue(`ACK_CONDITION`),this.removeInput(`ACK_CONDITION`));let r;for(let e=0;this.inputList[e];e++)if(this.inputList[e].name===`STATEMENT`){r=this.inputList[e],this.inputList.splice(e,1);break}let i=this.workspace,a=0;for(;a<this.itemCount_;a++){let e=this.getInput(`OID${a}`);e||(e=this.appendValueInput(`OID${a}`),a===0&&e.appendField(x(`on_ext`))),O(i,e,`field_oid`)}for(;this.getInput(`OID${a}`);)this.removeInput(`OID${a}`),a++;this.appendDummyInput(`CONDITION`).appendField(new t(w()),`CONDITION`),e&&this.setFieldValue(e,`CONDITION`),this.appendDummyInput(`ACK_CONDITION`).appendField(x(`on_ack`)).appendField(new t(T()),`ACK_CONDITION`),n&&this.setFieldValue(n,`ACK_CONDITION`),r?this.inputList.push(r):this.appendStatementInput(`STATEMENT`).setCheck(null)},onchange:function(){d(this)}},c.forBlock.on_ext=function(e){let t=e,n=E(e.getFieldValue(`CONDITION`)),r=e.getFieldValue(`ACK_CONDITION`),i=[];for(let n=0;n<t.itemCount_;n++){let t=c.valueToCode(e,`OID${n}`,s.COMMA);t&&(t=t.toString(),t.startsWith(`'`)&&t.endsWith(`'`)&&(t=`[${t}]`),i.includes(t)||i.push(t))}let a=`[].concat(${i.join(`).concat(`)})`,o=c.statementToCode(e,`STATEMENT`);return`on({ id: ${a}, ${n}${r?`, ack: ${r}`:``} }, async (obj) => {\n${i.length===1?D():``}${o}});\n`},b.Trigger.blocks.on=`<sep gap="5"></sep><block type="on"> <field name="CONDITION">ne</field> <field name="ACK_CONDITION"></field></block>`,o.on={init:function(){this.appendDummyInput().appendField(x(`on`)),this.appendDummyInput(`OID`).appendField(new _(x(`select_id`),`state`),`OID`),this.appendDummyInput(`CONDITION`).appendField(new t(w()),`CONDITION`),this.appendDummyInput(`ACK_CONDITION`).appendField(x(`on_ack`)).appendField(new t(T()),`ACK_CONDITION`),this.appendStatementInput(`STATEMENT`).setCheck(null),this.setInputsInline(!1),this.setPreviousStatement(!0,null),this.setNextStatement(!0,null),this.setColour(b.Trigger.HUE),this.setTooltip(x(`on_tooltip`)),this.setHelpUrl(S(`on_help`))},onchange:function(){d(this)}},c.forBlock.on=function(e){let t=e.getFieldValue(`OID`),n=E(e.getFieldValue(`CONDITION`)),r=e.getFieldValue(`ACK_CONDITION`);a.VARIABLES_DEFAULT_NAME=`value`;let i=p(t),o=c.statementToCode(e,`STATEMENT`);return`on({ id: '${t}'${i?` /* ${i} */`:``}, ${n}${r?`, ack: ${r}`:``} }, async (obj) => {\n${D()}${o}});\n`},b.Trigger.blocks.on_source=`<sep gap="5"></sep><block type="on_source"> <field name="ATTR">state.val</field></block>`,k(`on_source`,`↪`,[[x(`on_source_state_val`),`state.val`],[x(`on_source_state_ts`),`state.ts`],[x(`on_source_state_q`),`state.q`],[x(`on_source_state_from`),`state.from`],[x(`on_source_state_ack`),`state.ack`],[x(`on_source_state_lc`),`state.lc`],[x(`on_source_state_c`),`state.c`],[x(`on_source_state_user`),`state.user`],[x(`on_source_id`),`id`],[x(`on_source_name`),`common.name`],[x(`on_source_desc`),`common.desc`],[x(`on_source_channel_id`),`channelId`],[x(`on_source_channel_name`),`channelName`],[x(`on_source_device_id`),`deviceId`],[x(`on_source_device_name`),`deviceName`],[x(`on_source_oldstate_val`),`oldState.val`],[x(`on_source_oldstate_ts`),`oldState.ts`],[x(`on_source_oldstate_q`),`oldState.q`],[x(`on_source_oldstate_from`),`oldState.from`],[x(`on_source_oldstate_ack`),`oldState.ack`],[x(`on_source_oldstate_lc`),`oldState.lc`],[x(`on_source_oldstate_c`),`oldState.c`],[x(`on_source_oldstate_user`),`oldState.user`]],[`on`,`on_ext`,`onEnumMembers`],`on_source_warning`,b.Trigger.HUE,`on_help`),c.forBlock.on_source=function(e){let t=e.getFieldValue(`ATTR`),n=t.split(`.`);return[n.length>1?`(obj.${n[0]} ? obj.${t} : '')`:`obj.${t}`,s.ATOMIC]},b.Trigger.blocks.on_ack_value=`<sep gap="5"></sep><block type="on_ack_value"></block>`,o.on_ack_value={init:function(){this.appendDummyInput().appendField(`↪ ${x(`on_ack_value`)}`),this.setInputsInline(!1),this.setPreviousStatement(!0,null),this.setNextStatement(!0,null),this.setColour(b.Trigger.HUE),this.setTooltip(x(`on_ack_value_tooltip`)),this.setHelpUrl(S(`on_help`))},onchange:function(){m(this,[`on`,`on_ext`,`onEnumMembers`],`on_ack_value_warning`)},FUNCTION_TYPES:[`on`,`on_ext`,`onEnumMembers`]},c.forBlock.on_ack_value=function(){return`if (obj.id && obj?.state && !obj.state.ack) {
2
+ ${c.prefixLines(`await setStateAsync(obj.id, { val: obj.state.val, ack: true });`,c.INDENT)}\n}\n`},b.Trigger.blocks.astro=`<block type="astro"> <field name="TYPE">sunrise</field> <field name="OFFSET">0</field></block>`,o.astro={init:function(){this.appendDummyInput().appendField(x(`astro`)),this.appendDummyInput(`TYPE`).appendField(new t([[x(`astro_sunriseText`),`sunrise`],[x(`astro_sunriseEndText`),`sunriseEnd`],[x(`astro_goldenHourEndText`),`goldenHourEnd`],[x(`astro_solarNoonText`),`solarNoon`],[x(`astro_goldenHourText`),`goldenHour`],[x(`astro_sunsetStartText`),`sunsetStart`],[x(`astro_sunsetText`),`sunset`],[x(`astro_duskText`),`dusk`],[x(`astro_nauticalDuskText`),`nauticalDusk`],[x(`astro_nightText`),`night`],[x(`astro_nightEndText`),`nightEnd`],[x(`astro_nauticalDawnText`),`nauticalDawn`],[x(`astro_dawnText`),`dawn`],[x(`astro_nadirText`),`nadir`]]),`TYPE`),this.appendDummyInput().appendField(x(`astro_offset`)),this.appendDummyInput(`OFFSET`).appendField(new n(`0`),`OFFSET`),this.appendDummyInput().appendField(x(`astro_minutes`)),this.appendStatementInput(`STATEMENT`).setCheck(null),this.setInputsInline(!0),this.setPreviousStatement(!0,null),this.setNextStatement(!0,null),this.setColour(b.Trigger.HUE),this.setTooltip(x(`astro_tooltip`)),this.setHelpUrl(S(`astro_help`))},onchange:function(){d(this)}},c.forBlock.astro=function(e){return`schedule({ astro: '${e.getFieldValue(`TYPE`)}', shift: ${parseInt(e.getFieldValue(`OFFSET`),10)} }, async () => {\n${c.statementToCode(e,`STATEMENT`)}});\n`},b.Trigger.blocks.schedule=`<block type="schedule"> <field name="SCHEDULE">* * * * *</field></block>`,o.schedule={init:function(){this.appendDummyInput().appendField(x(`schedule`)),this.appendDummyInput(`SCHEDULE`).appendField(new v(`* * * * *`),`SCHEDULE`),this.appendStatementInput(`STATEMENT`).setCheck(null),this.setInputsInline(!1),this.setPreviousStatement(!0,null),this.setNextStatement(!0,null),this.setColour(b.Trigger.HUE),this.setTooltip(x(`schedule_tooltip`)),this.setHelpUrl(S(`schedule_help`))},onchange:function(){d(this)}},c.forBlock.schedule=function(e){let t=e.getFieldValue(`SCHEDULE`),n=c.statementToCode(e,`STATEMENT`);return`schedule(${t.startsWith(`{`)?`'${t}'`:`"${t}"`}, async () => {\n${n}});\n`},b.Trigger.blocks.schedule_by_id=`<block type="schedule_by_id"> <field name="ACK_CONDITION"></field></block>`,o.schedule_by_id={init:function(){this.appendDummyInput().appendField(x(`schedule_by_id`)),this.appendDummyInput(`OID`).appendField(new _(x(`select_id`),`state`),`OID`),this.appendDummyInput(`ACK_CONDITION`).appendField(x(`on_ack`)).appendField(new t(T()),`ACK_CONDITION`),this.appendStatementInput(`STATEMENT`).setCheck(null),this.setInputsInline(!1),this.setPreviousStatement(!0,null),this.setNextStatement(!0,null),this.setColour(b.Trigger.HUE),this.setTooltip(x(`schedule_by_id_tooltip`)),this.setHelpUrl(S(`schedule_by_id_help`))}},c.forBlock.schedule_by_id=function(e){let t=e.getFieldValue(`OID`),n=e.getFieldValue(`ACK_CONDITION`),r=c.statementToCode(e,`STATEMENT`),i=p(t);return`scheduleById('${t}'${i?` /* ${i} */`:``}${n?`, ${n}`:``}, async () => {\n${r}});\n`},b.Trigger.blocks.schedule_create=`<block type="schedule_create"> <field name="NAME">schedule</field> <value name="SCHEDULE"> <shadow type="field_cron"> </shadow> </value></block>`;let A=(t,n,r)=>{if(t===`schedule`)return!1;for(let i of n.getAllBlocks())if(i!==r&&i.isSchedule_&&e.equals(i.getFieldValue(`NAME`),t))return!1;return!0},j=(e,t)=>{if(t.isInFlyout)return e;for(;!A(e,t.workspace,t);){let t=e.match(/^(.*?)(\d+)$/);t?e=t[1]+(parseInt(t[2],10)+1):e+=`1`}return e},M=function(e){return j(e.replace(/^[\s\xa0]+|[\s\xa0]+$/g,``),this.getSourceBlock())};o.schedule_create={init:function(){let e=new n(j(`schedule`,this),M);e.setSpellcheck(!1),this.appendDummyInput(`NAME`).appendField(x(`schedule_create`)).appendField(e,`NAME`),this.appendValueInput(`SCHEDULE`).appendField(x(`schedule_text`)),this.appendStatementInput(`STATEMENT`).setCheck(null),this.setInputsInline(!1),this.setPreviousStatement(!0,null),this.setNextStatement(!0,null),this.setColour(b.Trigger.HUE),this.setTooltip(x(`schedule_create_tooltip`)),this.setHelpUrl(S(`schedule_create_help`))},isSchedule_:!0,getVars:function(){return[this.getFieldValue(`NAME`)]},getVarModels:function(){return[l(this.getFieldValue(`NAME`),`cron`)]}},c.forBlock.schedule_create=function(e){return`${y(e)} = schedule(${c.valueToCode(e,`SCHEDULE`,s.ATOMIC)}, async () => {\n${c.statementToCode(e,`STATEMENT`)}});\n`},b.Trigger.blocks.schedule_clear=`<sep gap="5"></sep><block type="schedule_clear"> <field name="NAME"></field></block>`,o.schedule_clear={init:function(){this.appendDummyInput(`NAME`).appendField(x(`schedule_clear`)).appendField(new t(()=>{var e;return(e=window.scripts)!=null&&e.blocklyWorkspace?C(window.scripts.blocklyWorkspace):[]}),`NAME`),this.setInputsInline(!0),this.setPreviousStatement(!0,null),this.setNextStatement(!0,null),this.setColour(b.Trigger.HUE),this.setTooltip(x(`schedule_clear_tooltip`)),this.setHelpUrl(S(`schedule_clear_help`))}},c.forBlock.schedule_clear=function(e){let t=y(e);return`(() => { if (${t}) { clearSchedule(${t}); ${t} = null; }})();\n`},b.Trigger.blocks.field_cron=`<sep gap="5"></sep><block type="field_cron"> <field name="CRON">* * * * *</field></block>`,o.field_cron={init:function(){this.appendDummyInput().appendField(x(`field_cron_CRON`)),this.appendDummyInput().appendField(new v(`* * * * *`),`CRON`),this.setInputsInline(!0),this.setOutput(!0,`String`),this.setColour(b.Trigger.HUE),this.setTooltip(x(`field_cron_tooltip`))}},c.forBlock.field_cron=function(e){return[`'${e.getFieldValue(`CRON`)}'`,s.ATOMIC]},b.Trigger.blocks.cron_builder=`<sep gap="5"></sep><block type="cron_builder"> <mutation seconds="false" as_line="false"></mutation> <field name="LINE">FALSE</field> <field name="WITH_SECONDS">FALSE</field> <value name="DOW"> <shadow type="text"> <field name="TEXT">*</field> </shadow> </value> <value name="MONTHS"> <shadow type="text"> <field name="TEXT">*</field> </shadow> </value> <value name="DAYS"> <shadow type="text"> <field name="TEXT">*</field> </shadow> </value> <value name="HOURS"> <shadow type="text"> <field name="TEXT">*</field> </shadow> </value> <value name="MINUTES"> <shadow type="text"> <field name="TEXT">*</field> </shadow> </value></block>`,o.cron_builder={init:function(){this.appendDummyInput().appendField(x(`cron_builder_CRON`)),this.appendDummyInput(`LINE`).appendField(x(`cron_builder_line`)).appendField(new i(`FALSE`,function(e){var t;(t=this.getSourceBlock())==null||t.setInputsInline(h(e))}),`LINE`);let e=this.workspace;for(let[t,n]of[[`DOW`,`cron_builder_dow`],[`MONTHS`,`cron_builder_month`],[`DAYS`,`cron_builder_day`],[`HOURS`,`cron_builder_hour`],[`MINUTES`,`cron_builder_minutes`]]){let r=this.appendValueInput(t).appendField(x(n));O(e,r,`text`,[`TEXT`,`*`])}this.appendDummyInput(`WITH_SECONDS`).appendField(x(`cron_builder_with_seconds`)).appendField(new i(`FALSE`,function(e){this.getSourceBlock().updateShape_(h(e))}),`WITH_SECONDS`),this.seconds_=!1,this.as_line_=!1,this.setInputsInline(this.as_line_),this.setOutput(!0,`String`),this.setColour(b.Trigger.HUE),this.setTooltip(x(`field_cron_tooltip`))},mutationToDom:function(){let e=document.createElement(`mutation`);return e.setAttribute(`seconds`,String(this.seconds_)),e.setAttribute(`as_line`,String(this.as_line_)),e},domToMutation:function(e){this.seconds_=e.getAttribute(`seconds`)===`true`,this.as_line_=e.getAttribute(`as_line`)===`true`,this.setInputsInline(this.as_line_),this.updateShape_(this.seconds_)},updateShape_:function(e){if(this.seconds_=e,e){if(!this.getInput(`SECONDS`)){let e=this.appendValueInput(`SECONDS`).appendField(x(`cron_builder_seconds`));O(this.workspace,e,`text`,[`TEXT`,`*`])}}else this.getInput(`SECONDS`)&&this.removeInput(`SECONDS`)}},c.forBlock.cron_builder=function(e){let t=t=>c.valueToCode(e,t,s.ATOMIC),n=e.getFieldValue(`WITH_SECONDS`),r=n&&e.getInput(`SECONDS`)?t(`SECONDS`):`0`;return[(h(n)?`${r}.toString().trim() + ' ' + `:``)+`${t(`MINUTES`)}.toString().trim() + ' ' + ${t(`HOURS`)}.toString().trim() + ' ' + ${t(`DAYS`)}.toString().trim() + ' ' + ${t(`MONTHS`)}.toString().trim() + ' ' + ${t(`DOW`)}.toString().trim()`,s.ATOMIC]},b.Trigger.blocks.onMessage=`<block type="onMessage"> <field name="MESSAGE">customMessage</field></block>`,o.onMessage={init:function(){this.appendDummyInput(`NAME`).appendField(`✉️ ${x(`onMessage`)}`),this.appendDummyInput(`MESSAGE`).appendField(x(`onMessage_message`)).appendField(new n(`customMessage`),`MESSAGE`),this.appendStatementInput(`STATEMENT`).setCheck(null),this.setInputsInline(!1),this.setPreviousStatement(!0,null),this.setNextStatement(!0,null),this.setColour(b.Trigger.HUE),this.setTooltip(x(`onMessage_tooltip`)),this.setHelpUrl(S(`onMessage_help`))},onchange:function(){d(this)}},c.forBlock.onMessage=function(e){let t=e.getFieldValue(`MESSAGE`),n=c.statementToCode(e,`STATEMENT`);return`onMessage(${u(t)}, async (data, callback) => {\n${n}${c.prefixLines(`typeof callback === 'function' && callback({ result: true }); // default callback`,c.INDENT)}\n});\n`},b.Trigger.blocks.onMessage_data=`<sep gap="5"></sep><block type="onMessage_data"> <field name="ATTR">data</field></block>`,k(`onMessage_data`,`✉️ `,[[x(`onMessage_data_data`),`data`]],[`onMessage`],`onMessage_data_warning`,b.Action.HUE,`onMessage_data_help`),c.forBlock.onMessage_data=function(e){return[e.getFieldValue(`ATTR`),s.ATOMIC]},b.Trigger.blocks.onFile=`<block type="onFile"> <field name="WITH_FILE">FALSE</field> <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">*</field> </shadow> </value></block>`,o.onFile={init:function(){this.appendValueInput(`OID`).appendField(`📁 ${x(`onFile`)}`).setCheck(null),this.appendValueInput(`FILE`).appendField(x(`onFile_file`)).setCheck(null),this.appendDummyInput(`WITH_FILE_INPUT`).appendField(x(`onFile_withFile`)).appendField(new i(`FALSE`),`WITH_FILE`),this.appendStatementInput(`STATEMENT`).setCheck(null),this.setInputsInline(!1),this.setPreviousStatement(!0,null),this.setNextStatement(!0,null),this.setColour(b.Trigger.HUE),this.setTooltip(x(`onFile_tooltip`)),this.setHelpUrl(S(`onFile_help`))},onchange:function(){d(this)}},c.forBlock.onFile=function(e){let t=c.valueToCode(e,`OID`,s.ATOMIC),n=c.valueToCode(e,`FILE`,s.ATOMIC),r=e.getFieldValue(`WITH_FILE`),i=c.statementToCode(e,`STATEMENT`),a=g(t);return`onFile(${t}${a?` /* ${a} */`:``}, ${n}, ${r===`TRUE`?`true`:`false`}, async (id, fileName, size, data, mimeType) => {\n${i}});\n`},b.Trigger.blocks.onFile_data=`<sep gap="5"></sep><block type="onFile_data"> <field name="ATTR">data</field></block>`,k(`onFile_data`,`📁`,[[x(`onFile_data_data`),`data`],[x(`onFile_data_filename`),`fileName`],[x(`onFile_data_size`),`size`],[x(`onFile_data_mimeType`),`mimeType`],[x(`onFile_data_id`),`id`],[x(`onFile_data_tempFile`),`TEMP_FILE_PATH`]],[`onFile`],`onFile_data_warning`,b.Trigger.HUE),c.forBlock.onFile_data=function(e){let t=e.getFieldValue(`ATTR`);return t===`TEMP_FILE_PATH`?[`createTempFile(fileName, data)`,s.ATOMIC]:[t,s.ATOMIC]},b.Trigger.blocks.offFile=`<sep gap="5"></sep><block type="offFile"> <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">*</field> </shadow> </value></block>`,o.offFile={init:function(){this.appendValueInput(`OID`).appendField(`📁 ${x(`offFile`)}`).setCheck(null),this.appendValueInput(`FILE`).appendField(x(`onFile_file`)).setCheck(null),this.setInputsInline(!1),this.setPreviousStatement(!0,null),this.setNextStatement(!0,null),this.setColour(b.Trigger.HUE),this.setTooltip(x(`offFile_tooltip`)),this.setHelpUrl(S(`offFile_help`))}},c.forBlock.offFile=function(e){let t=c.valueToCode(e,`OID`,s.ATOMIC),n=c.valueToCode(e,`FILE`,s.ATOMIC),r=g(t);return`offFile(${t}${r?` /* ${r} */`:``}, ${n});\n`},b.Trigger.blocks.onLog=`<block type="onLog"> <field name="Severity">error</field></block>`,o.onLog={init:function(){this.appendDummyInput(`TEXT`).appendField(`💬 ${x(`onLog`)}`),this.appendDummyInput(`Severity`).appendField(x(`loglevel`)).appendField(new t([[x(`loglevel_error`),`error`],[x(`loglevel_warn`),`warn`],[x(`loglevel_info`),`info`],[x(`loglevel_debug`),`debug`],[x(`loglevel_all`),`*`]]),`Severity`),this.appendStatementInput(`STATEMENT`).setCheck(null),this.setInputsInline(!1),this.setPreviousStatement(!0,null),this.setNextStatement(!0,null),this.setColour(b.Trigger.HUE),this.setTooltip(x(`onLog_tooltip`)),this.setHelpUrl(S(`onLog_help`))},onchange:function(){d(this)}},c.forBlock.onLog=function(e){let t=c.statementToCode(e,`STATEMENT`);return`onLog('${e.getFieldValue(`Severity`)}', async (data) => {\n${t}});\n`},b.Trigger.blocks.onLog_data=`<sep gap="5"></sep><block type="onLog_data"> <field name="ATTR">data.message</field></block>`,k(`onLog_data`,`💬 `,[[x(`onLog_data_message`),`data.message`],[x(`loglevel`),`data.severity`],[x(`onLog_data_from`),`data.from`],[x(`onLog_data_ts`),`data.ts`]],[`onLog`],`onLog_data_warning`,b.Trigger.HUE),c.forBlock.onLog_data=function(e){return[e.getFieldValue(`ATTR`),s.ATOMIC]},b.Trigger.blocks.onEnumMembers=`<block type="onEnumMembers"></block>`,o.onEnumMembers={init:function(){this.appendDummyInput().appendField(x(`onEnumMembers`)),this.appendDummyInput(`OID`).appendField(new _(x(`select_id`),`enum`),`OID`),this.appendStatementInput(`STATEMENT`).setCheck(null),this.setInputsInline(!1),this.setPreviousStatement(!0,null),this.setNextStatement(!0,null),this.setColour(b.Trigger.HUE),this.setTooltip(x(`onEnumMembers_tooltip`)),this.setHelpUrl(S(`onEnumMembers_help`))},onchange:function(){d(this)}},c.forBlock.onEnumMembers=function(e){let t=e.getFieldValue(`OID`),n=c.statementToCode(e,`STATEMENT`),r=p(t);return`onEnumMembers('${t}'${r?` /* ${r} */`:``}, async (obj) => {\n${D()}${n}});\n`}}export{b as install};
@@ -1,2 +1,2 @@
1
- import{m as e,y as t}from"./_virtual_mf___mfe_internal__iobroker_javascript__mf_owner__180366418666083__loadShare___mf_0_iobroker_mf_1_gui_mf_2_components__loadShare__.js-BEpNZh4U.js";var n=[`'`,`"`,"`"],r=/^@(annually|yearly|monthly|weekly|daily|midnight|hourly|reboot)$/i,i=/^[0-9A-Za-z*/,?#\-LW]+$/;function a(e){let t=e.trim();if(!t)return!1;if(r.test(t))return!0;let n=t.split(/\s+/);return n.length<5||n.length>7||!n.every(e=>i.test(e))?!1:/[\d*/]/.test(t)}function o(e,t){if(!e)return null;let r=Math.max(1,Math.min(t,e.length+1))-1,i=null,o=-1;for(let t=r-1;t>=0;t--){let r=e[t];if(n.includes(r)&&e[t-1]!==`\\`){let n=0;for(let i=0;i<t;i++)e[i]===r&&e[i-1]!==`\\`&&n++;if(n%2==0){i=r,o=t;break}}}if(i===null||o<0)return null;let s=-1;for(let t=o+1;t<e.length;t++)if(e[t]===i&&e[t-1]!==`\\`){s=t;break}if(s<0||r<o||r>s)return null;let c=e.substring(o+1,s);return a(c)?{expression:c.trim(),startColumn:o+2,endColumn:s+1}:null}function s(n,r){try{return t(n,r||e.getLanguage())||null}catch{return null}}function c(t){let n=e.t(`Second`),r=e.t(`Minute`),i=e.t(`Hour`),a=e.t(`Day of month`),o=e.t(`Month`),s=e.t(`Day of week`),c=e.t(`Year`);return t===7?[n,r,i,a,o,s,c]:t===6?[n,r,i,a,o,s]:[r,i,a,o,s]}function l(t,n){let i=[];i.push(`**⏰ ${e.t(`Cron expression`)}** · \`${t}\``),i.push(``,`**${n}**`);let a=t.split(/\s+/);if(!r.test(t)&&a.length>=5&&a.length<=7){let e=c(a.length);i.push(``),a.forEach((t,n)=>{i.push(`- \`${t}\` — ${e[n]}`)})}return i.join(`
1
+ import{m as e,y as t}from"./_virtual_mf___mfe_internal__iobroker_javascript__mf_owner__234968779812303__loadShare___mf_0_iobroker_mf_1_gui_mf_2_components__loadShare__.js-BRdHvuuG.js";var n=[`'`,`"`,"`"],r=/^@(annually|yearly|monthly|weekly|daily|midnight|hourly|reboot)$/i,i=/^[0-9A-Za-z*/,?#\-LW]+$/;function a(e){let t=e.trim();if(!t)return!1;if(r.test(t))return!0;let n=t.split(/\s+/);return n.length<5||n.length>7||!n.every(e=>i.test(e))?!1:/[\d*/]/.test(t)}function o(e,t){if(!e)return null;let r=Math.max(1,Math.min(t,e.length+1))-1,i=null,o=-1;for(let t=r-1;t>=0;t--){let r=e[t];if(n.includes(r)&&e[t-1]!==`\\`){let n=0;for(let i=0;i<t;i++)e[i]===r&&e[i-1]!==`\\`&&n++;if(n%2==0){i=r,o=t;break}}}if(i===null||o<0)return null;let s=-1;for(let t=o+1;t<e.length;t++)if(e[t]===i&&e[t-1]!==`\\`){s=t;break}if(s<0||r<o||r>s)return null;let c=e.substring(o+1,s);return a(c)?{expression:c.trim(),startColumn:o+2,endColumn:s+1}:null}function s(n,r){try{return t(n,r||e.getLanguage())||null}catch{return null}}function c(t){let n=e.t(`Second`),r=e.t(`Minute`),i=e.t(`Hour`),a=e.t(`Day of month`),o=e.t(`Month`),s=e.t(`Day of week`),c=e.t(`Year`);return t===7?[n,r,i,a,o,s,c]:t===6?[n,r,i,a,o,s]:[r,i,a,o,s]}function l(t,n){let i=[];i.push(`**⏰ ${e.t(`Cron expression`)}** · \`${t}\``),i.push(``,`**${n}**`);let a=t.split(/\s+/);if(!r.test(t)&&a.length>=5&&a.length<=7){let e=c(a.length);i.push(``),a.forEach((t,n)=>{i.push(`- \`${t}\` — ${e[n]}`)})}return i.join(`
2
2
  `)}function u(e){let t=[];for(let n of[`javascript`,`typescript`]){let r=e.languages.registerHoverProvider(n,{provideHover:(t,n)=>{let r=o(t.getLineContent(n.lineNumber),n.column);if(!r)return null;let i=s(r.expression);if(!i)return null;let a=l(r.expression,i);return{range:new e.Range(n.lineNumber,r.startColumn,n.lineNumber,r.endColumn),contents:[{value:a,isTrusted:!1,supportHtml:!1}]}}});t.push(r)}return{dispose(){t.forEach(e=>{try{e.dispose()}catch{}})}}}export{u as registerCronHoverProvider};
@@ -0,0 +1 @@
1
+ import{a as e,c as t,i as n,l as r,o as i,r as a,s as o,t as s}from"./utils-DUKzLJUz.js";function c(e){let n=new((i())||a)({id:`${e.name}@${e.version||Date.now()}`,...e});return t(n),n}var l=null;function u(e){let t=s(e.name,e.version),n={...e,id:e.id||``};return t?(t.initOptions(n),l||=t,t):(l=c(n),l)}function d(...t){return r(l,e,n),l.loadRemote.apply(l,t)}function f(...t){return r(l,e,n),l.registerRemotes.apply(l,t)}o(a);export{d as n,f as r,u as t};
@@ -0,0 +1 @@
1
+ import{or as e}from"./_virtual_mf___mfe_internal__iobroker_javascript__mf_owner__234968779812303__loadShare___mf_0_iobroker_mf_1_gui_mf_2_components__loadShare__.js-BRdHvuuG.js";import{d as t,n}from"./blockly-B0t_IRJQ.js";var r=class extends n{constructor(t){super(t),e(this,`FONTSIZE`,void 0),e(this,`CURSOR`,void 0),e(this,`SERIALIZABLE`,void 0),e(this,`spellcheck_`,void 0),this.FONTSIZE=11,this.CURSOR=`pointer`,this.SERIALIZABLE=!0,this.spellcheck_=!1}dispose(){t.hideIfOwner(this),super.dispose()}setValue(e){e!==null&&super.setValue(e)}showEditor_(){window.main.cronDialog(this.getValue(),e=>{e!=null&&this.setValue(e)})}};function i(){window.Blockly.FieldCRON=r}export{r as FieldCRON,i as install};
@@ -0,0 +1 @@
1
+ import{or as e}from"./_virtual_mf___mfe_internal__iobroker_javascript__mf_owner__234968779812303__loadShare___mf_0_iobroker_mf_1_gui_mf_2_components__loadShare__.js-BRdHvuuG.js";import{d as t,n}from"./blockly-B0t_IRJQ.js";var r=`http://www.w3.org/2000/svg`,i=`http://www.w3.org/1999/xlink`,a=16,o=class o extends n{constructor(t,n){super(t),e(this,`FONTSIZE`,void 0),e(this,`CURSOR`,void 0),e(this,`SERIALIZABLE`,void 0),e(this,`spellcheck_`,void 0),e(this,`maxDisplayLength`,void 0),e(this,`_type`,void 0),e(this,`_idName`,null),e(this,`_iconElement`,null),e(this,`_iconUrl`,null),e(this,`_showValue`,!1),e(this,`_stateValueText`,null),e(this,`_valueBadge`,null),e(this,`_hoverHandler`,null),e(this,`_disposed`,!1),this._type=n,this.FONTSIZE=11,this.CURSOR=`pointer`,this.SERIALIZABLE=!0,this.spellcheck_=!1,this.maxDisplayLength=200}dispose(){this._disposed=!0,t.hideIfOwner(this),this.fieldGroup_&&this._hoverHandler&&(this.fieldGroup_.removeEventListener(`mouseenter`,this._hoverHandler),this._hoverHandler=null),this._valueBadge&&=(this._valueBadge.remove(),null),super.dispose()}initView(){super.initView();let e=this.getValue();e&&this.updateIcon_(e),this.fieldGroup_&&!this._hoverHandler&&(this._hoverHandler=()=>this._fetchStateValue(),this.fieldGroup_.addEventListener(`mouseenter`,this._hoverHandler)),this._ensureValueBadge()}static _objects(){var e;return(e=window.main)==null?void 0:e.objects}static _resolveObjectName(e){var t;let n=o._objects();if(!(n!=null&&(t=n[e])!=null&&(t=t.common)!=null&&t.name))return null;let r=n[e].common.name;return typeof r==`object`&&(r=r[window.systemLang]||r.en),r||null}static computeDisplayText(e,t){var r;let i=o.displayMode,a=o._objects(),s;switch(i){case 1:{let t=e.split(`.`),n=[];for(let e=0;e<t.length;e++){let r=t.slice(0,e+1).join(`.`),i=o._resolveObjectName(r);n.push(i||t[e])}s=n.join(`.`);break}case 2:s=e.split(`.`).pop()||e;break;case 3:s=e;break;default:s=o._resolveObjectName(e)||e}return a!=null&&(r=a[e])!=null&&r.type&&![`state`,`meta`,`script`].includes(a[e].type)&&(s+=` (${a[e].type})`),t&&s.length>t&&(s=`${s.substring(0,t-2)}…`),s=s.replace(/\s/g,n.NBSP),s||n.NBSP}refreshDisplay(){let e=this.getValue();e&&(this._idName=o.computeDisplayText(e,this.maxDisplayLength),this.updateIcon_(e),this.forceRerender(),o.displayMode===1&&this._resolvePathNamesAsync(e))}_resolvePathNamesAsync(e){var t;if(typeof((t=window.main)==null?void 0:t.getObject)!=`function`)return;let n=o._objects(),r=e.split(`.`),i=0,a=!1;for(let t=0;t<r.length;t++){let s=r.slice(0,t+1).join(`.`);n[s]||(i++,window.main.getObject(s,(t,r)=>{r&&(n[r._id]=n[r._id]||r,a=!0),i--,i===0&&a&&(this._idName=o.computeDisplayText(e,this.maxDisplayLength),this.forceRerender())}))}}_getIconOffset(){return o.showIcon&&this._iconElement?20:0}updateSize_(e){let t=this.getConstants();if(!t)return;let n=e===void 0?this.isFullBlockField()?0:t.FIELD_BORDER_RECT_X_PADDING:e,r=this._getIconOffset(),i=this._getBadgeOffset(),a=0;this.textElement_&&(a=this.textElement_.getComputedTextLength());let o=2*n+a+r+i,s=t.FIELD_TEXT_HEIGHT;this.isFullBlockField()||(s=Math.max(s,t.FIELD_BORDER_RECT_HEIGHT)),this.size_.height=s,this.size_.width=o,this.positionTextElement_(n+r,a),this.positionBorderRect_(),this._positionValueBadge(o,n,s)}updateIcon_(e){if(!this.fieldGroup_)return;if(!o.showIcon){this._iconElement&&(this._iconElement.remove(),this._iconElement=null,this._iconUrl=null);return}let t=o.resolveIcon(e);t&&this._applyIcon(t),this._resolveIconAsync(e)}_applyIcon(e){this.fieldGroup_&&e&&(this._iconUrl===e&&this._iconElement||(this._iconUrl=e,this._iconElement||(this._iconElement=document.createElementNS(r,`image`),this._iconElement.setAttribute(`width`,String(a)),this._iconElement.setAttribute(`height`,String(a)),this.textElement_?this.fieldGroup_.insertBefore(this._iconElement,this.textElement_):this.fieldGroup_.appendChild(this._iconElement)),this._iconElement.setAttributeNS(i,`xlink:href`,e),this._positionIcon()))}_positionIcon(){if(this._iconElement&&this.textElement_)try{let e=this.getConstants(),t=this.borderRect_&&e?e.FIELD_BORDER_RECT_X_PADDING:0;this._iconElement.setAttribute(`x`,String(t+2));let n=this.textElement_.getBBox();if(n.height>0){let e=n.y+n.height/2;this._iconElement.setAttribute(`y`,String(e-a/2))}}catch{}}_resolveIconAsync(e){var t;if(!o.showIcon||typeof((t=window.main)==null?void 0:t.getObject)!=`function`)return;let n=o._objects(),r=e.split(`.`),i=r[0],a=e=>{if(e<1)return;let t=r.slice(0,e).join(`.`);if(n[t]){var s;if((s=n[t].common)!=null&&s.icon){this._applyIcon(o._buildIconUrl(n[t].common.icon,i));return}a(e-1);return}window.main.getObject(t,(t,r)=>{let s=r;if(s){var c;if(n[s._id]=n[s._id]||s,(c=s.common)!=null&&c.icon){this._applyIcon(o._buildIconUrl(s.common.icon,i));return}}a(e-1)})};a(r.length)}static _formatStateValue(e,t){var n;if((t==null?void 0:t.val)===void 0||(t==null?void 0:t.val)===null)return`null`;let r;if(typeof t.val==`object`)try{r=JSON.stringify(t.val)}catch{r=String(t.val)}else r=String(t.val);r.length>60&&(r=`${r.substring(0,60)}…`);let i=(n=o._objects())==null||(n=n[e])==null?void 0:n.common;return i!=null&&i.unit&&(r+=` ${i.unit}`),t.ack===!1&&(r+=` (?)`),r}_fetchStateValue(e){var t;let n=this.getValue();if(!n||typeof((t=window.main)==null?void 0:t.getState)!=`function`){e==null||e();return}window.main.getState(n,(t,r)=>{this._disposed||(this._stateValueText=r?o._formatStateValue(n,r):null,e==null||e())})}_composeTooltip(){let e=this.getValue();if(!e)return``;let t=o._resolveObjectName(e),n=t?`${t}\n${e}`:e;return this._stateValueText&&(n+=`\n= ${this._stateValueText}`),n}_getBadgeOffset(){return this._valueBadge?18:0}_ensureValueBadge(){var e;if(this._type!==`state`||this._valueBadge||!this.fieldGroup_||!this.getValue())return;let t=document.createElementNS(r,`text`);t.setAttribute(`class`,`blocklyText`),t.setAttribute(`text-anchor`,`middle`),t.style.fill=`#2196f3`,t.style.fontWeight=`bold`,t.style.cursor=`pointer`,t.textContent=`=`;let n=document.createElementNS(r,`title`);n.textContent=`Show/hide current value`,t.appendChild(n);let i=e=>e.stopPropagation();t.addEventListener(`pointerdown`,i),t.addEventListener(`mousedown`,i),t.addEventListener(`click`,e=>{e.stopPropagation(),this._toggleValue()}),this._valueBadge=t,this.fieldGroup_.appendChild(t),(e=this.getSourceBlock())!=null&&e.rendered&&this.forceRerender()}_positionValueBadge(e,t,n){this._valueBadge&&(this._valueBadge.setAttribute(`x`,String(e-t-9)),this._valueBadge.setAttribute(`y`,String(n/2+4)))}_toggleValue(){this._showValue=!this._showValue,this._valueBadge&&(this._valueBadge.textContent=this._showValue?`×`:`=`),this._showValue?(this._stateValueText=this._stateValueText||`…`,this.forceRerender(),this._fetchStateValue(()=>this.forceRerender())):this.forceRerender()}setValue(e){var t;if(e===null)return;let r=o._objects();r&&!r[e]&&typeof((t=window.main)==null?void 0:t.getObject)==`function`?(this._idName=e||n.NBSP,window.main.getObject(e,(t,n)=>{if(n){r[n._id]=r[n._id]||n;let t=o.computeDisplayText(e,this.maxDisplayLength);t&&(this._idName=t,this.forceRerender()),o.displayMode===1&&this._resolvePathNamesAsync(e)}})):(this._idName=o.computeDisplayText(e,this.maxDisplayLength),o.displayMode===1&&this._resolvePathNamesAsync(e)),this.updateIcon_(e),super.setValue(e),super.setTooltip(()=>this._composeTooltip()),this._ensureValueBadge()}getDisplayText_(){var e;let t=this._idName;return this._showValue&&this._stateValueText&&(t=`${t||``} = ${this._stateValueText}`),t?(t.length>this.maxDisplayLength&&(t=`${t.substring(0,this.maxDisplayLength-2)}…`),t=t.replace(/\s/g,n.NBSP),(e=this.getSourceBlock())!=null&&e.RTL&&(t+=`‏`),t):n.NBSP}showEditor_(){var e,t;(e=window.main)==null||(t=e.selectIdDialog)==null||t.call(e,this.getValue(),this._type,e=>{e!==null&&this.setValue(e)})}static _buildIconUrl(e,t){return e?e.startsWith(`data:`)||e.startsWith(`http://`)||e.startsWith(`https://`)||e.startsWith(`/`)?e:`/adapter/${t}/${e}`:null}static resolveIcon(e){let t=o._objects();if(!t)return null;let n=e.split(`.`),r=n[0];for(let e=n.length;e>=1;e--){var i;let a=t[n.slice(0,e).join(`.`)];if(a!=null&&(i=a.common)!=null&&i.icon)return o._buildIconUrl(a.common.icon,r)}if(n.length>=2){var a;let e=t[`system.adapter.${n[0]}.${n[1]}`];if(e!=null&&(a=e.common)!=null&&a.icon)return o._buildIconUrl(e.common.icon,r)}return null}static _refreshAll(e){for(let t of e.getAllBlocks(!1))for(let e of t.inputList)for(let t of e.fieldRow)t instanceof o&&t.refreshDisplay()}static setDisplayMode(e,t){o.displayMode=e,localStorage.setItem(`Blockly.FieldOID.displayMode`,String(e)),o._refreshAll(t)}static setShowIcon(e,t){o.showIcon=e,localStorage.setItem(`Blockly.FieldOID.showIcon`,String(e)),o._refreshAll(t)}};e(o,`DISPLAY_MODE_KEYS`,[`oid_display_name`,`oid_display_path`,`oid_display_id`,`oid_display_full_id`]),e(o,`displayMode`,parseInt(localStorage.getItem(`Blockly.FieldOID.displayMode`)||`0`,10)||0),e(o,`showIcon`,localStorage.getItem(`Blockly.FieldOID.showIcon`)===`true`);function s(){window.Blockly.FieldOID=o}export{o as FieldOID,s as install};
@@ -0,0 +1 @@
1
+ import{or as e}from"./_virtual_mf___mfe_internal__iobroker_javascript__mf_owner__234968779812303__loadShare___mf_0_iobroker_mf_1_gui_mf_2_components__loadShare__.js-BRdHvuuG.js";import{d as t,n}from"./blockly-B0t_IRJQ.js";function r(e){return btoa(encodeURIComponent(e).replace(/%([0-9A-F]{2})/g,(e,t)=>String.fromCharCode(parseInt(t,16))))}function i(e){try{return decodeURIComponent(Array.prototype.map.call(atob(e),e=>`%${`00${e.charCodeAt(0).toString(16)}`.slice(-2)}`).join(``))}catch{return atob(e||``)}}var a=class extends n{constructor(t){super(t),e(this,`FONTSIZE`,void 0),e(this,`CURSOR`,void 0),e(this,`SERIALIZABLE`,void 0),e(this,`spellcheck_`,void 0),this.FONTSIZE=11,this.CURSOR=`pointer`,this.SERIALIZABLE=!0,this.spellcheck_=!1}dispose(){t.hideIfOwner(this),super.dispose()}setValue(e){e!==null&&super.setValue(e)}showEditor_(){let e=this.getValue(),t=this.getSourceBlock(),n=null,a=!1;t!=null&&t.arguments_&&(n=t.arguments_),t!=null&&t.getProcedureDef&&(a=t.getProcedureDef()[2]),window.main.showScriptDialog(i(e||``),n,a,e=>{e!=null&&this.setValue(r(e))})}render_(){let e=this.getConstants();if(!e)return;let t=this.borderRect_?e.FIELD_BORDER_RECT_X_PADDING:0,n=t*2+12,r=e.FIELD_TEXT_HEIGHT;this.borderRect_&&(r=Math.max(r,e.FIELD_BORDER_RECT_HEIGHT)),this.size_.height=r,this.size_.width=n,this.positionTextElement_(t,12),this.positionBorderRect_(),this.getTextElement().textContent=`...`}};function o(){window.Blockly.FieldScript=a,window.Blockly.b64EncodeUnicode=r,window.Blockly.b64DecodeUnicode=i}export{a as FieldScript,i as b64DecodeUnicode,r as b64EncodeUnicode,o as install};
@@ -0,0 +1 @@
1
+ import{n as e}from"./utils-DUKzLJUz.js";({...e.global});var t=e.share;e.utils;export{t};
@@ -0,0 +1 @@
1
+ import{r as javascriptGenerator}from"./BlocklyEditor-DhwThchX.js";function reconnectChild(e,t,n){var r;if(!(e!=null&&e.getSourceBlock().workspace))return!1;let i=(r=t.getInput(n))==null?void 0:r.connection;if(!i)return!1;let a=e.targetBlock();return(!a||a===t)&&i.targetConnection!==e&&(i.isConnected()&&i.disconnect(),i.connect(e),!0)}function quote(e){return javascriptGenerator.quote_(e)}function dateFormat(e){return window.Blockly.Words[e].format}function dateFormatOptions(){let e=window.Blockly.Translate,t=[`object`,`ms`,`s`,`sid`,`m`,`mid`,`h`,`d`,`M`,`Mt`,`Mts`,`y`,`fy`,`wdt`,`wdts`,`wd`,`cw`,`custom`],n=[`time_get_yyyy.mm.dd`,`time_get_yyyy/mm/dd`,`time_get_yy.mm.dd`,`time_get_yy/mm/dd`,`time_get_dd.mm.yyyy`,`time_get_dd/mm/yyyy`,`time_get_dd.mm.yy`,`time_get_dd/mm/yy`,`time_get_mm/dd/yyyy`,`time_get_mm/dd/yy`,`time_get_dd.mm`,`time_get_dd/mm`,`time_get_mm.dd`,`time_get_mm/dd`,`time_get_hh_mm`,`time_get_hh_mm_ss`,`time_get_hh_mm_ss.sss`];return[...t.map(t=>[e(`time_get_${t}`),t]),...n.map(t=>[e(t),dateFormat(t)])]}function dateLanguageOptions(){let e=[`in english`,`en`],t=[`auf deutsch`,`de`],n=[`на русском`,`ru`];return window.systemLang===`de`?[t,e,n]:window.systemLang===`ru`?[n,e,t]:[e,t,n]}function isTrue(e){return e===!0||e===`true`||e===`TRUE`}function logLevelOptions(){let e=window.Blockly.Translate;return[[e(`loglevel_none`),``],[e(`loglevel_debug`),`debug`],[e(`loglevel_info`),`info`],[e(`loglevel_warn`),`warn`],[e(`loglevel_error`),`error`]]}function updateStatementInput(e,t){let n=t===void 0?isTrue(e.getFieldValue(`WITH_STATEMENT`)):t;e.getInput(`STATEMENT`)&&e.removeInput(`STATEMENT`),n&&e.appendStatementInput(`STATEMENT`)}function warnIfNotNestedIn(e,t,n){let r=!1,i=e;do{if(t.includes(i.type)){r=!0;break}i=i.getSurroundParent()}while(i);e.setWarningText(r?null:window.Blockly.Translate(n),e.id)}function objectNameOf(code){try{var _window$main;const objId=eval(code);let name=((_window$main=window.main)==null||(_window$main=_window$main.objects[objId])==null||(_window$main=_window$main.common)==null?void 0:_window$main.name)||``;return typeof name==`object`&&(name=name[window.systemLang]||name.en),name||``}catch{return``}}function toMilliseconds(e,t){let n=parseFloat(e);return t===`min`?n*6e4:t===`sec`?n*1e3:n}function objectNameById(e){var t;let n=((t=window.main)==null||(t=t.objects[e])==null||(t=t.common)==null?void 0:t.name)||``;return typeof n==`object`&&(n=n[window.systemLang]||n.en),n||``}function warnIfInsideTrigger(e){let t=e.getSurroundParent();for(;t;){if(window.Blockly.Trigger.WARNING_PARENTS.includes(t.type)){e.setWarningText(window.Blockly.Translate(`trigger_in_trigger_warning`),e.id);return}t=t.getSurroundParent()}e.setWarningText(null,e.id)}function namedResourceVariableModel(e,t){return{getId:()=>e,getName:()=>e,getType:()=>t,name:e,type:t}}export{namedResourceVariableModel as a,quote as c,updateStatementInput as d,warnIfInsideTrigger as f,logLevelOptions as i,reconnectChild as l,dateLanguageOptions as n,objectNameById as o,warnIfNotNestedIn as p,isTrue as r,objectNameOf as s,dateFormatOptions as t,toMilliseconds as u};
@@ -0,0 +1 @@
1
+ import{t as e}from"./vite-preload-helper-DjNwdemH.js";import{t}from"./helpers-BZgjFQNf.js";var n=`__mf_module_cache__`;globalThis[n]||={share:{},remote:{}},globalThis[n].share||={},globalThis[n].remote||={};var r=globalThis[n];for(let e of Object.keys(r.share))if(e.startsWith(`default:`)){let t=e.slice(8);r.share[t]===void 0&&(r.share[t]=r.share[e])}else if(!e.includes(`:`)){let t=`default:`+e;r.share[t]===void 0&&(r.share[t]=r.share[e])}var i;async function a(){return i||=(async()=>{let n=(e,t,n,r)=>{let i=(Array.isArray(r)?r[0]:r)||`default`,a=t||!n?e:e+`@`+n,o={canonical:i+`:`+a};return i==="default"&&(o.aliases=[a]),o},i=(e,t)=>{let n=e[t.canonical];if(n!==void 0)return n;let r=t.aliases||[];for(let n of r){if(!Object.prototype.hasOwnProperty.call(e,n))continue;let r=e[n];if(r!==void 0)return e[t.canonical]=r,r}},a=Symbol.for(`module-federation.shared-cache-listeners`),o=Symbol.for(`module-federation.shared-cache-owners`),s=e=>{let t=e[o];return t===void 0&&(t=Object.create(null),Object.defineProperty(e,o,{value:t,enumerable:!1,configurable:!1,writable:!1})),t},c=(e,t)=>{var n;return(n=e[o])==null?void 0:n[t.canonical]},l=e=>{let t=[e,e==null?void 0:e.default];for(let e of t)if(e&&typeof e==`object`){for(let t of[`__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE`,`__TEST_INTERNALS`,`__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED`]){let n=e[t];if(n&&typeof n==`object`)return{internals:n}}if(typeof e.useState==`function`)return{hook:e.useState}}},u=(e,t)=>{if(e===t)return!0;let n=l(e),r=l(t);if(!n||!r)return!1;let i=n.internals,a=r.internals;return i!==void 0||a!==void 0?i!==void 0&&i===a:typeof n.hook==`function`&&n.hook===r.hook},d=(e,t,n,r)=>{var c;let l=i(e,t);if(l!==void 0&&u(l,n))return n;e[t.canonical]=n;let d=t.aliases||[];for(let t of d)Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0});let f=e[o];r===void 0?f&&delete f[t.canonical]:s(e)[t.canonical]=r;let p=(c=e[a])==null?void 0:c[t.canonical];if(p)for(let e of p)e(n);return n},f=await(await e(()=>import(`../remoteEntry.js`),[],import.meta.url)).init(),{usedShared:p}=await e(async()=>{let{usedShared:e}=await import(`./_virtual_mf-localSharedImportMap___mfe_internal__iobroker_javascript__mf_owner__1-Ceh8EDcF.js`);return{usedShared:e}},[],import.meta.url),m=e=>{let t=e;for(let e=0;e<5;e++){let e=t==null?void 0:t.default;if(!e||typeof e!=`object`||Object.keys(e).length===0)break;let n=Object.getPrototypeOf(e);if(n!==null&&n!==Object.prototype)break;let r=Object.keys(t).filter(e=>e!=="default").map(e=>t[e]);if(r.length>0&&r.some(e=>e!==void 0))break;t=e}return t},h=(e,t)=>y(t).some(n=>{var r;return Object.keys(((r=f.shareScopeMap)==null||(r=r[n])==null?void 0:r[e])||{}).some(e=>e!==t.version)}),g=[[`react`,`prop-types`],[`react-dom`],[`@mui/material`],[`@iobroker/gui-components`]],_=Symbol(`mf.originalSharedProvider`),v={emit:e=>e},y=e=>Array.isArray(e.scope)?e.scope:[e.scope||`default`],b=(e,t)=>{if(t!==`version-first`)return e;let n={};for(let[t,r]of Object.entries(e))n[t]=Object.assign({},r,{[_]:r});return n},x=(e,n,r,i)=>{var a;if(!e||!r)return;let o=Object.fromEntries(Object.entries(e).filter(([,e])=>{var t;return(e==null||(t=e.shareConfig)==null?void 0:t.import)!==!1}));if(Object.keys(o).length===0)return;let s=y(r),c=b(o,i),l={};for(let e of s)l[e||`default`]={[n]:c};let u=(a=t.getRegisteredShare(l,n,{...r,scope:s,strategy:i},v))==null?void 0:a.shared;return(u==null?void 0:u[_])||u},S=(e,t,n,r)=>{var i;return(i=n.shareConfig)!=null&&i.singleton?Object.values(e||{}).some(e=>{var t;return(e==null||(t=e.shareConfig)==null?void 0:t.import)!==!1}):!!x(e,t,{...n,scope:[r]},`version-first`)};for(let e of g)await Promise.all(e.map(async e=>{var t,a,o,s;let l=p[e];if(!l||l.materialize===!1&&!l.lazy||l.treeShaking)return;let u=n(e,(t=l.shareConfig)==null?void 0:t.singleton,l.version,l.scope);if(!(i(r.share,u)!==void 0&&(!((a=l.shareConfig)!=null&&a.singleton)&&c(r.share,u)===`iobroker_javascript`||(o=l.shareConfig)!=null&&o.singleton&&!h(e,l)))){if(((s=l.shareConfig)==null?void 0:s.import)===!1){let t=y(l),n=t=>{var n;return!S((n=f.shareScopeMap)==null||(n=n[t])==null?void 0:n[e],e,l,t)};if(t.some(n)){var g;if(!f.__mfKeepAdoptedProviders){var _,v;f.__mfKeepAdoptedProviders=!0,(_=f.sharedHandler)==null||(_=_.hooks)==null||(_=_.lifecycle)==null||(_=_.afterRegisterShare)==null||(v=_.on)==null||v.call(_,e=>{var t,n,r;let{shared:i,previousShared:a,registeredShared:o}=e||{};if((i==null||(t=i.shareConfig)==null?void 0:t.import)!==!1||o!==i||!a||((n=a.shareConfig)==null?void 0:n.import)===!1)return;let s=(r=f.shareScopeMap)==null||(r=r[e.scope])==null?void 0:r[e.pkgName];s&&s[i.version]===i&&(s[i.version]=a)})}for(let r of((g=globalThis.__FEDERATION__)==null?void 0:g.__INSTANCES__)||[])for(let i of t){var b;let t=r==null||(b=r.shareScopeMap)==null||(b=b[i])==null?void 0:b[e];if(!S(t,e,l,i)||!n(i))continue;let a=(f.shareScopeMap[i]||={})[e]||={};for(let[e,n]of Object.entries(t)){var x,C;(n==null||(x=n.shareConfig)==null?void 0:x.import)!==!1&&(a[e]&&((C=a[e].shareConfig)==null?void 0:C.import)!==!1||(a[e]=n))}}}if(t.every(n))return}await f.loadShare(e,{customShareInfo:{shareConfig:l.shareConfig}}).then(async e=>{if(e===!1)return;let t=typeof e==`function`?e():e,n=m(await Promise.resolve(t));d(r.share,u,n,`iobroker_javascript`)})}}));return f})(),i}i=a();export{i as hostInitPromise,a as initHost};
@@ -0,0 +1 @@
1
+ html{width:100%;height:100%}.Light.visGutter{background:#dadada!important}.Dark.visGutter{background:#1e1e1e!important}body{-webkit-font-smoothing:antialiased;-moz-osx-font-smoothing:grayscale;width:100%;height:100%;margin:0;padding:0;font-family:-apple-system,BlinkMacSystemFont,Segoe UI,Roboto,Oxygen,Ubuntu,Cantarell,Fira Sans,Droid Sans,Helvetica Neue,sans-serif;overflow:hidden}#root{width:100%;height:100%}#___reactour>div:first-of-type{opacity:.4}.layout-pane-primary{height:100%}.blocklyToolboxDiv{width:180px;height:100%!important;top:0!important;left:0!important}.no-underline:before{border-bottom:0!important}.monaco-aria-container{top:0}.iobVerticalSplitter .layout-pane-primary{overflow:hidden}.monacoCurrentLine{background:#59fd8c}.monacoCurrentLineDark{background:#165b2c}.monacoCurrentFullLine{opacity:.7;background:#cbffdc}.monacoCurrentFullLineDark{opacity:.7;background:#0e3b1f}.monacoBreakPointDark{background:maroon;border-radius:50%;margin-left:4px;width:16px!important;height:16px!important}.monacoBreakPoint{background:#d71a1a;border-radius:50%;margin-left:4px;width:16px!important;height:16px!important}