x-block-lib 0.11.1 → 0.11.3

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.
package/dist/index.js CHANGED
@@ -1,36 +1,36 @@
1
- import{$ as e,A as t,B as n,C as r,D as i,E as a,F as o,G as s,H as c,I as l,J as u,K as ee,L as d,M as f,N as te,O as ne,P as re,Q as ie,R as ae,S as p,T as m,U as oe,V as h,W as se,X as ce,Y as g,Z as le,_,a as ue,b as de,c as fe,d as pe,f as me,g as he,h as ge,i as _e,j as v,k as ve,l as ye,m as y,n as be,o as xe,p as Se,q as b,r as Ce,s as we,u as Te,v as x,w as Ee,x as De,y as S,z as Oe}from"./vendor.chw9q9nj.js";import{eventBus as ke,globalObjects as Ae,messageWarning as je,openConfirmDlg as Me,openPromptDlg as Ne,useColor as Pe,useSystem as Fe,useViewStack as Ie}from"x-essential-lib";import{globalState as C}from"x-state-lib";import{addIndent as Le,finalProperties as w,getElement as T,getImplementMethodName as Re,getItems as ze,getTag as Be,getTypes as Ve,makeEventId as E,makeEventKeyOfCustomSlot as He,makeEventKeyOfElementSlot as Ue,makeMethodId as We,makeMethodKeyOfCustomSlot as Ge,makeMethodKeyOfElementSlot as Ke,makePropertyId as qe,makePropertyKeyOfCustomSlot as Je,makePropertyKeyOfElementSlot as Ye,makeTriggerId as Xe,parseNumberUnit as Ze,pkgs as Qe,themeColors as $e,toEventName as et,toMethodName as tt,toPropertyName as nt,unwrapEventId as rt,unwrapEventKeyOfCustomSlot as it,unwrapEventKeyOfElementSlot as at,unwrapMethodId as ot,unwrapMethodKeyOfCustomSlot as st,unwrapMethodKeyOfElementSlot as ct,unwrapPropertyId as lt,unwrapPropertyKeyOfCustomSlot as ut,unwrapPropertyKeyOfElementSlot as dt,unwrapSlotId as ft}from"x-runtime-lib";import{Fragment as pt,computed as D,createBlock as mt,createCommentVNode as ht,createElementBlock as O,createElementVNode as k,createVNode as A,defineComponent as gt,inject as _t,isRef as vt,mergeModels as yt,mergeProps as bt,nextTick as xt,normalizeStyle as j,onBeforeUnmount as St,onMounted as Ct,onUnmounted as wt,openBlock as M,provide as Tt,ref as Et,renderList as Dt,renderSlot as Ot,resolveComponent as N,resolveDirective as kt,toDisplayString as At,unref as P,useId as jt,useModel as Mt,useTemplateRef as Nt,watch as Pt,withCtx as Ft,withDirectives as It,withKeys as Lt,withModifiers as Rt}from"vue";import{useI18n as zt}from"vue-i18n";import{useDisplay as Bt}from"vuetify";async function Vt(e){if(e===`en`)ce((await import(`./en.md0q5xx8.js`)).default);else if(e===`zhHans`)ce((await import(`./zhHans.ei0ea10m.js`)).default);else throw Error(`invalid locale=${e}`)}function F(e){return t[e]??e}function Ht(t){let n=`<block type="text_v1"><field name="TEXT">${t}</field></block>`;return e.xml.textToDom(n)}function Ut(t){let n=`<block type="math_number_v1"><field name="NUM">${t}</field></block>`;return e.xml.textToDom(n)}function Wt(t){let n=`<block type="logic_boolean_v1"><field name="BOOL">${t?`TRUE`:`FALSE`}</field></block>`;return e.xml.textToDom(n)}function Gt(e,t){let n=null;return t===`string`?n=Ht(``):t===`integer`||t===`decimal`?n=Ut(0):t===`boolean`?n=Wt(!1):t===`enum`||t===`dateTime`?n=Ht(``):console.assert(!1,`type not implementd`),n?Oe.domToBlock(n,e):null}const Kt=`data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHZlcnNpb249IjEuMSIgd2lkdGg9IjI0IiBoZWlnaHQ9IjI0Ij48cGF0aCBkPSJNMTggMTBoLTR2LTRjMC0xLjEwNC0uODk2LTItMi0ycy0yIC44OTYtMiAybC4wNzEgNGgtNC4wNzFjLTEuMTA0IDAtMiAuODk2LTIgMnMuODk2IDIgMiAybDQuMDcxLS4wNzEtLjA3MSA0LjA3MWMwIDEuMTA0Ljg5NiAyIDIgMnMyLS44OTYgMi0ydi00LjA3MWw0IC4wNzFjMS4xMDQgMCAyLS44OTYgMi0ycy0uODk2LTItMi0yeiIgZmlsbD0id2hpdGUiIC8+PC9zdmc+Cg==`,qt=`data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHZlcnNpb249IjEuMSIgd2lkdGg9IjI0IiBoZWlnaHQ9IjI0Ij48cGF0aCBkPSJNMTggMTFoLTEyYy0xLjEwNCAwLTIgLjg5Ni0yIDJzLjg5NiAyIDIgMmgxMmMxLjEwNCAwIDItLjg5NiAyLTJzLS44OTYtMi0yLTJ6IiBmaWxsPSJ3aGl0ZSIgLz48L3N2Zz4K`;function Jt(e){let t=e.lastIndexOf(`V`);if(t<=0||t>=e.length-1)throw Error(`must has V`);return`${me(e.substring(0,t))}_${`v`+e.substring(t+1)}`}function Yt(e){let t=e.lastIndexOf(`V`);if(t<=0||t>=e.length-1)return console.assert(!1,`invalid key=${e}`),``;let n=e.substring(0,t-1);return`${n[0].toUpperCase()}${n.substring(1)}`}function I(e){return e.length<=0&&e.push([F(`NO_OPTION`),``]),e}function Xt(e){let t=0;for(;e;)t++,e=e.getParent();return t}function Zt(e){return e.ui===`text`?`string`:e.ui===`number`?`number`:e.ui===`switch`?`boolean`:`string`}function Qt(e,t){return!!(e.startsWith(`basic.`)||!t.ui||t.readonly)}function L(e){return e.startsWith(`globality_v`)}function $t(e){return e.startsWith(`ref_v`)}function en(e){return e.startsWith(`multiple_ref_v`)}function R(e){return e.startsWith(`slot_v`)}function z(e){return e.startsWith(`multiple_slot_v`)}function tn(e,t,n){let{kind:r,mainKey:i,slotKey:a}=ft(e);return!(r!==`elementSlot`&&r!==`multipleElementSlot`||t!==i||n!==a)}function nn(e,t,n){let{kind:r,mainKey:i,slotKey:a}=ft(e);return!(r!==`customSlot`&&r!==`multipleCustomSlot`||t!==i||n!==a)}function B(e){return e===`string`?`String`:e===`number`?`Number`:e===`boolean`?`Boolean`:e===`array`?`Array`:e===`object`?`Object`:(e===`any`||console.assert(!1),null)}function rn(e){return e.array?`Array`:e.ui===`transient`?B(e.type):e.ui===`dummy`?null:e.ui===`text`?`String`:e.ui===`number`?`Number`:e.ui===`switch`?`Boolean`:e.ui===`select`?Yt(e.items):e.ui===`multiTypes`?Yt(e.types):e.ui===`comp`?`Comp`:e.ui===`slot`?`Slot`:e.ui===`adaptSlot`?`AdaptSlot`:(console.assert(!1),null)}function an(e){return e===`string`?`String`:e===`integer`||e===`decimal`?`Number`:e===`boolean`?`Boolean`:e===`enum`||e===`dateTime`?`String`:(console.assert(!1),null)}const on=`#F44336.#FFEBEE.#FFCDD2.#EF9A9A.#E57373.#EF5350.#E53935.#D32F2F.#C62828.#B71C1C.#FF8A80.#FF5252.#FF1744.#D50000.#e91e63.#fce4ec.#f8bbd0.#f48fb1.#f06292.#ec407a.#d81b60.#c2185b.#ad1457.#880e4f.#ff80ab.#ff4081.#f50057.#c51162.#9c27b0.#f3e5f5.#e1bee7.#ce93d8.#ba68c8.#ab47bc.#8e24aa.#7b1fa2.#6a1b9a.#4a148c.#ea80fc.#e040fb.#d500f9.#aa00ff.#673ab7.#ede7f6.#d1c4e9.#b39ddb.#9575cd.#7e57c2.#5e35b1.#512da8.#4527a0.#311b92.#b388ff.#7c4dff.#651fff.#6200ea.#3f51b5.#e8eaf6.#c5cae9.#9fa8da.#7986cb.#5c6bc0.#3949ab.#303f9f.#283593.#1a237e.#8c9eff.#536dfe.#3d5afe.#304ffe.#2196F3.#E3F2FD.#BBDEFB.#90CAF9.#64B5F6.#42A5F5.#1E88E5.#1976D2.#1565C0.#0D47A1.#82B1FF.#448AFF.#2979FF.#2962FF.#03a9f4.#e1f5fe.#b3e5fc.#81d4fa.#4fc3f7.#29b6f6.#039be5.#0288d1.#0277bd.#01579b.#80d8ff.#40c4ff.#00b0ff.#0091ea.#00bcd4.#e0f7fa.#b2ebf2.#80deea.#4dd0e1.#26c6da.#00acc1.#0097a7.#00838f.#006064.#84ffff.#18ffff.#00e5ff.#00b8d4.#009688.#e0f2f1.#b2dfdb.#80cbc4.#4db6ac.#26a69a.#00897b.#00796b.#00695c.#004d40.#a7ffeb.#64ffda.#1de9b6.#00bfa5.#4CAF50.#E8F5E9.#C8E6C9.#A5D6A7.#81C784.#66BB6A.#43A047.#388E3C.#2E7D32.#1B5E20.#B9F6CA.#69F0AE.#00E676.#00C853.#8bc34a.#f1f8e9.#dcedc8.#c5e1a5.#aed581.#9ccc65.#7cb342.#689f38.#558b2f.#33691e.#ccff90.#b2ff59.#76ff03.#64dd17.#cddc39.#f9fbe7.#f0f4c3.#e6ee9c.#dce775.#d4e157.#c0ca33.#afb42b.#9e9d24.#827717.#f4ff81.#eeff41.#c6ff00.#aeea00.#ffeb3b.#fffde7.#fff9c4.#fff59d.#fff176.#ffee58.#fdd835.#fbc02d.#f9a825.#f57f17.#ffff8d.#ffff00.#ffea00.#ffd600.#ffc107.#fff8e1.#ffecb3.#ffe082.#ffd54f.#ffca28.#ffb300.#ffa000.#ff8f00.#ff6f00.#ffe57f.#ffd740.#ffc400.#ffab00.#ff9800.#fff3e0.#ffe0b2.#ffcc80.#ffb74d.#ffa726.#fb8c00.#f57c00.#ef6c00.#e65100.#ffd180.#ffab40.#ff9100.#ff6d00.#ff5722.#fbe9e7.#ffccbc.#ffab91.#ff8a65.#ff7043.#f4511e.#e64a19.#d84315.#bf360c.#ff9e80.#ff6e40.#ff3d00.#dd2c00.#795548.#efebe9.#d7ccc8.#bcaaa4.#a1887f.#8d6e63.#6d4c41.#5d4037.#4e342e.#3e2723.#.#.#.#.#607d8b.#eceff1.#cfd8dc.#b0bec5.#90a4ae.#78909c.#546e7a.#455a64.#37474f.#263238.#.#.#.#.#9e9e9e.#fafafa.#f5f5f5.#eeeeee.#e0e0e0.#bdbdbd.#757575.#616161.#424242.#212121.#.#.#.#.#000000.#FFFFFF.#FFFFFF00`.split(`.`),sn=[`add_data_v`,`call_app_method_v`,`call_func_v`,`call_func_internal_v`,`delete_data_v`,`func_entry_v`,`implement_app_method_v`,`open_confirm_dlg_v`,`open_prompt_dlg_v`,`on_app_event_v`,`procedure_def_v`,`transaction_v`,`query_data_v`,`update_data_v`];function cn(e){return!!sn.find(t=>e.startsWith(t))}const ln=e.xml;S.parameter_v1={init:function(){this.key=``,this.name=``,this.locale=!1,this.appendDummyInput().appendField(``,`LABEL`),this.setOutput(!0),this.setColour(220)},mutationToDom:function(){let e=ln.createElement(`mutation`);return e.setAttribute(`key`,this.key),e.setAttribute(`name`,this.name),e.setAttribute(`locale`,this.locale?`TRUE`:`FALSE`),e},domToMutation:function(e){this.key=e.getAttribute(`key`)??``,this.name=e.getAttribute(`name`)??``,this.locale=e.getAttribute(`locale`)===`TRUE`,this.updateShape_(),setTimeout(()=>{this.checkWarning_()},0)},saveExtraState:function(){return{key:this.key,name:this.name,locale:this.locale}},loadExtraState:function(e){this.key=e.key??``,this.name=e.name??``,this.locale=e.locale??!1,this.updateShape_(),setTimeout(()=>{this.checkWarning_()},0)},setKeyName:function(e,t,n){this.key=e,this.name=t,this.locale=n,this.updateShape_(),setTimeout(()=>{this.checkWarning_()},0)},onchange:function(e){if(e.type===p.BLOCK_MOVE){let t=e;if(t.blockId!==this.id)return;this.tryDuplicate_(t)}setTimeout(()=>{this.checkWarning_()},0)},tryDuplicate_:function(e){let t=this.workspace.getBlockById(e.oldParentId);if(t&&cn(t.type))try{p.disable();let n=t.getInput(e.oldInputName)?.connection;if(n){let e=un(this.workspace,this.key,this.name,this.locale);n.connect(e.outputConnection)}}finally{p.enable()}},updateShape_:function(){if(this.locale){let{i18n:e}=Ae;this.setFieldValue(e.global.t(this.name),`LABEL`)}else this.setFieldValue(this.name,`LABEL`)},checkWarning_:function(){let e=this.getSurroundParent();for(;e;){if(cn(e.type))for(let t of e.inputList){let e=t.connection?.targetBlock();if(!e||e.type!==`parameter_v1`)continue;let n=e;if(n.key===this.key){n.name!==this.name&&(this.name=n.name),n.locale!==this.locale&&(this.locale=n.locale),this.setWarningText(null);return}}e=e.getSurroundParent()}this.setWarningText(F(`WARN_PARAMETER_NOT_FOUND`))}},x.forBlock.parameter_v1=function(e){return[e.key,_.ATOMIC]};function un(t,n,r,i){let a=`
1
+ import{A as e,B as t,C as n,D as r,E as i,F as a,G as o,H as s,I as c,J as l,K as u,L as ee,M as te,N as d,O as f,P as ne,Q as p,R as re,S as m,T as h,U as ie,V as ae,W as oe,X as se,Y as ce,Z as le,_ as g,a as ue,b as de,c as fe,d as pe,f as me,g as _,h as he,i as ge,j as _e,k as ve,l as ye,m as be,n as xe,o as Se,p as v,q as Ce,r as we,s as Te,t as Ee,u as De,v as y,w as b,x,y as Oe,z as ke}from"./vendor.bsmu4xkh.js";import{eventBus as Ae,globalObjects as je,messageWarning as Me,openConfirmDlg as Ne,openPromptDlg as Pe,useColor as Fe,useSystem as Ie,useViewStack as Le}from"x-essential-lib";import{globalState as S}from"x-state-lib";import{addIndent as Re,finalProperties as C,getElement as w,getImplementMethodName as ze,getItems as Be,getTag as Ve,getTypes as He,makeEventId as T,makeEventKeyOfCustomSlot as Ue,makeEventKeyOfElementSlot as We,makeMethodId as Ge,makeMethodKeyOfCustomSlot as Ke,makeMethodKeyOfElementSlot as qe,makePropertyId as Je,makePropertyKeyOfCustomSlot as Ye,makePropertyKeyOfElementSlot as Xe,makeTriggerId as Ze,parseNumberUnit as Qe,pkgs as $e,themeColors as et,toEventName as tt,toMethodName as nt,toPropertyName as rt,unwrapEventId as it,unwrapEventKeyOfCustomSlot as at,unwrapEventKeyOfElementSlot as ot,unwrapMethodId as st,unwrapMethodKeyOfCustomSlot as ct,unwrapMethodKeyOfElementSlot as lt,unwrapPropertyId as ut,unwrapPropertyKeyOfCustomSlot as dt,unwrapPropertyKeyOfElementSlot as ft,unwrapSlotId as pt}from"x-runtime-lib";import{Fragment as mt,computed as E,createBlock as D,createCommentVNode as ht,createElementBlock as O,createElementVNode as k,createVNode as A,defineComponent as gt,inject as _t,isRef as vt,mergeModels as yt,mergeProps as bt,nextTick as xt,normalizeStyle as j,onBeforeUnmount as St,onMounted as Ct,onUnmounted as wt,openBlock as M,provide as Tt,ref as Et,renderList as Dt,renderSlot as Ot,resolveComponent as N,resolveDirective as kt,toDisplayString as At,unref as P,useId as jt,useModel as Mt,useTemplateRef as Nt,watch as Pt,withCtx as Ft,withDirectives as It,withKeys as Lt,withModifiers as Rt}from"vue";import{useI18n as zt}from"vue-i18n";import{useDisplay as Bt}from"vuetify";async function Vt(e){if(e===`en`)ce((await import(`./en.md0q5xx8.js`)).default);else if(e===`zhHans`)ce((await import(`./zhHans.ei0ea10m.js`)).default);else throw Error(`invalid locale=${e}`)}function F(e){return ve[e]??e}function Ht(e){let t=`<block type="text_v1"><field name="TEXT">${e}</field></block>`;return p.xml.textToDom(t)}function Ut(e){let t=`<block type="math_number_v1"><field name="NUM">${e}</field></block>`;return p.xml.textToDom(t)}function Wt(e){let t=`<block type="logic_boolean_v1"><field name="BOOL">${e?`TRUE`:`FALSE`}</field></block>`;return p.xml.textToDom(t)}function Gt(e,t){let n=null;return t===`string`?n=Ht(``):t===`integer`||t===`decimal`?n=Ut(0):t===`boolean`?n=Wt(!1):t===`enum`||t===`dateTime`?n=Ht(``):console.assert(!1,`type not implementd`),n?re.domToBlock(n,e):null}const Kt=`data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHZlcnNpb249IjEuMSIgd2lkdGg9IjI0IiBoZWlnaHQ9IjI0Ij48cGF0aCBkPSJNMTggMTBoLTR2LTRjMC0xLjEwNC0uODk2LTItMi0ycy0yIC44OTYtMiAybC4wNzEgNGgtNC4wNzFjLTEuMTA0IDAtMiAuODk2LTIgMnMuODk2IDIgMiAybDQuMDcxLS4wNzEtLjA3MSA0LjA3MWMwIDEuMTA0Ljg5NiAyIDIgMnMyLS44OTYgMi0ydi00LjA3MWw0IC4wNzFjMS4xMDQgMCAyLS44OTYgMi0ycy0uODk2LTItMi0yeiIgZmlsbD0id2hpdGUiIC8+PC9zdmc+Cg==`,qt=`data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHZlcnNpb249IjEuMSIgd2lkdGg9IjI0IiBoZWlnaHQ9IjI0Ij48cGF0aCBkPSJNMTggMTFoLTEyYy0xLjEwNCAwLTIgLjg5Ni0yIDJzLjg5NiAyIDIgMmgxMmMxLjEwNCAwIDItLjg5NiAyLTJzLS44OTYtMi0yLTJ6IiBmaWxsPSJ3aGl0ZSIgLz48L3N2Zz4K`;function Jt(e){let t=e.lastIndexOf(`V`);if(t<=0||t>=e.length-1)throw Error(`must has V`);return`${pe(e.substring(0,t))}_${`v`+e.substring(t+1)}`}function Yt(e){let t=e.lastIndexOf(`V`);if(t<=0||t>=e.length-1)return console.assert(!1,`invalid key=${e}`),``;let n=e.substring(0,t-1);return`${n[0].toUpperCase()}${n.substring(1)}`}function I(e){return e.length<=0&&e.push([F(`NO_OPTION`),``]),e}function Xt(e){let t=0;for(;e;)t++,e=e.getParent();return t}function Zt(e){return e.ui===`text`?`string`:e.ui===`number`?`number`:e.ui===`switch`?`boolean`:`string`}function Qt(e,t){return!!(e.startsWith(`basic.`)||!t.ui||t.readonly)}function L(e){return e.startsWith(`globality_v`)}function $t(e){return e.startsWith(`ref_v`)}function en(e){return e.startsWith(`multiple_ref_v`)}function R(e){return e.startsWith(`slot_v`)}function z(e){return e.startsWith(`multiple_slot_v`)}function tn(e,t,n){let{kind:r,mainKey:i,slotKey:a}=pt(e);return!(r!==`elementSlot`&&r!==`multipleElementSlot`||t!==i||n!==a)}function nn(e,t,n){let{kind:r,mainKey:i,slotKey:a}=pt(e);return!(r!==`customSlot`&&r!==`multipleCustomSlot`||t!==i||n!==a)}function B(e){return e===`string`?`String`:e===`number`?`Number`:e===`boolean`?`Boolean`:e===`array`?`Array`:e===`object`?`Object`:(e===`any`||console.assert(!1),null)}function rn(e){return e.array?`Array`:e.ui===`transient`?B(e.type):e.ui===`dummy`?null:e.ui===`text`?`String`:e.ui===`number`?`Number`:e.ui===`switch`?`Boolean`:e.ui===`select`?Yt(e.items):e.ui===`multiTypes`?Yt(e.types):e.ui===`comp`?`Comp`:e.ui===`slot`?`Slot`:e.ui===`adaptSlot`?`AdaptSlot`:(console.assert(!1),null)}function an(e){return e===`string`?`String`:e===`integer`||e===`decimal`?`Number`:e===`boolean`?`Boolean`:e===`enum`||e===`dateTime`?`String`:(console.assert(!1),null)}const on=`#F44336.#FFEBEE.#FFCDD2.#EF9A9A.#E57373.#EF5350.#E53935.#D32F2F.#C62828.#B71C1C.#FF8A80.#FF5252.#FF1744.#D50000.#e91e63.#fce4ec.#f8bbd0.#f48fb1.#f06292.#ec407a.#d81b60.#c2185b.#ad1457.#880e4f.#ff80ab.#ff4081.#f50057.#c51162.#9c27b0.#f3e5f5.#e1bee7.#ce93d8.#ba68c8.#ab47bc.#8e24aa.#7b1fa2.#6a1b9a.#4a148c.#ea80fc.#e040fb.#d500f9.#aa00ff.#673ab7.#ede7f6.#d1c4e9.#b39ddb.#9575cd.#7e57c2.#5e35b1.#512da8.#4527a0.#311b92.#b388ff.#7c4dff.#651fff.#6200ea.#3f51b5.#e8eaf6.#c5cae9.#9fa8da.#7986cb.#5c6bc0.#3949ab.#303f9f.#283593.#1a237e.#8c9eff.#536dfe.#3d5afe.#304ffe.#2196F3.#E3F2FD.#BBDEFB.#90CAF9.#64B5F6.#42A5F5.#1E88E5.#1976D2.#1565C0.#0D47A1.#82B1FF.#448AFF.#2979FF.#2962FF.#03a9f4.#e1f5fe.#b3e5fc.#81d4fa.#4fc3f7.#29b6f6.#039be5.#0288d1.#0277bd.#01579b.#80d8ff.#40c4ff.#00b0ff.#0091ea.#00bcd4.#e0f7fa.#b2ebf2.#80deea.#4dd0e1.#26c6da.#00acc1.#0097a7.#00838f.#006064.#84ffff.#18ffff.#00e5ff.#00b8d4.#009688.#e0f2f1.#b2dfdb.#80cbc4.#4db6ac.#26a69a.#00897b.#00796b.#00695c.#004d40.#a7ffeb.#64ffda.#1de9b6.#00bfa5.#4CAF50.#E8F5E9.#C8E6C9.#A5D6A7.#81C784.#66BB6A.#43A047.#388E3C.#2E7D32.#1B5E20.#B9F6CA.#69F0AE.#00E676.#00C853.#8bc34a.#f1f8e9.#dcedc8.#c5e1a5.#aed581.#9ccc65.#7cb342.#689f38.#558b2f.#33691e.#ccff90.#b2ff59.#76ff03.#64dd17.#cddc39.#f9fbe7.#f0f4c3.#e6ee9c.#dce775.#d4e157.#c0ca33.#afb42b.#9e9d24.#827717.#f4ff81.#eeff41.#c6ff00.#aeea00.#ffeb3b.#fffde7.#fff9c4.#fff59d.#fff176.#ffee58.#fdd835.#fbc02d.#f9a825.#f57f17.#ffff8d.#ffff00.#ffea00.#ffd600.#ffc107.#fff8e1.#ffecb3.#ffe082.#ffd54f.#ffca28.#ffb300.#ffa000.#ff8f00.#ff6f00.#ffe57f.#ffd740.#ffc400.#ffab00.#ff9800.#fff3e0.#ffe0b2.#ffcc80.#ffb74d.#ffa726.#fb8c00.#f57c00.#ef6c00.#e65100.#ffd180.#ffab40.#ff9100.#ff6d00.#ff5722.#fbe9e7.#ffccbc.#ffab91.#ff8a65.#ff7043.#f4511e.#e64a19.#d84315.#bf360c.#ff9e80.#ff6e40.#ff3d00.#dd2c00.#795548.#efebe9.#d7ccc8.#bcaaa4.#a1887f.#8d6e63.#6d4c41.#5d4037.#4e342e.#3e2723.#.#.#.#.#607d8b.#eceff1.#cfd8dc.#b0bec5.#90a4ae.#78909c.#546e7a.#455a64.#37474f.#263238.#.#.#.#.#9e9e9e.#fafafa.#f5f5f5.#eeeeee.#e0e0e0.#bdbdbd.#757575.#616161.#424242.#212121.#.#.#.#.#000000.#FFFFFF.#FFFFFF00`.split(`.`),sn=[`add_data_v`,`call_app_method_v`,`call_func_v`,`call_func_internal_v`,`delete_data_v`,`func_entry_v`,`implement_app_method_v`,`open_confirm_dlg_v`,`open_prompt_dlg_v`,`on_app_event_v`,`procedure_def_v`,`transaction_v`,`query_data_v`,`update_data_v`];function cn(e){return!!sn.find(t=>e.startsWith(t))}const ln=p.xml;y.parameter_v1={init:function(){this.key=``,this.name=``,this.locale=!1,this.appendDummyInput().appendField(``,`LABEL`),this.setOutput(!0),this.setColour(220)},mutationToDom:function(){let e=ln.createElement(`mutation`);return e.setAttribute(`key`,this.key),e.setAttribute(`name`,this.name),e.setAttribute(`locale`,this.locale?`TRUE`:`FALSE`),e},domToMutation:function(e){this.key=e.getAttribute(`key`)??``,this.name=e.getAttribute(`name`)??``,this.locale=e.getAttribute(`locale`)===`TRUE`,this.updateShape_(),setTimeout(()=>{this.checkWarning_()},0)},saveExtraState:function(){return{key:this.key,name:this.name,locale:this.locale}},loadExtraState:function(e){this.key=e.key??``,this.name=e.name??``,this.locale=e.locale??!1,this.updateShape_(),setTimeout(()=>{this.checkWarning_()},0)},setKeyName:function(e,t,n){this.key=e,this.name=t,this.locale=n,this.updateShape_(),setTimeout(()=>{this.checkWarning_()},0)},onchange:function(e){if(e.type===x.BLOCK_MOVE){let t=e;if(t.blockId!==this.id)return;this.tryDuplicate_(t)}setTimeout(()=>{this.checkWarning_()},0)},tryDuplicate_:function(e){let t=this.workspace.getBlockById(e.oldParentId);if(t&&cn(t.type))try{x.disable();let n=t.getInput(e.oldInputName)?.connection;if(n){let e=un(this.workspace,this.key,this.name,this.locale);n.connect(e.outputConnection)}}finally{x.enable()}},updateShape_:function(){if(this.locale){let{i18n:e}=je;this.setFieldValue(e.global.t(this.name),`LABEL`)}else this.setFieldValue(this.name,`LABEL`)},checkWarning_:function(){let e=this.getSurroundParent();for(;e;){if(cn(e.type))for(let t of e.inputList){let e=t.connection?.targetBlock();if(!e||e.type!==`parameter_v1`)continue;let n=e;if(n.key===this.key){n.name!==this.name&&(this.name=n.name),n.locale!==this.locale&&(this.locale=n.locale),this.setWarningText(null);return}}e=e.getSurroundParent()}this.setWarningText(F(`WARN_PARAMETER_NOT_FOUND`))}},g.forBlock.parameter_v1=function(e){return[e.key,_.ATOMIC]};function un(e,t,n,r){let i=`
2
2
  <block type="parameter_v1">
3
- <mutation key="${n}" name="${r}" locale="${i?`TRUE`:`FALSE`}"/>
3
+ <mutation key="${t}" name="${n}" locale="${r?`TRUE`:`FALSE`}"/>
4
4
  </block>
5
- `,o=e.xml.textToDom(a);return Oe.domToBlock(o,t)}function V(e,t){try{p.disable(),t.forEach(t=>{let[n,r,i,a]=t,o=e.getInput(n)?.connection;if(!o)return;let s=o.targetBlock();if(s){let e=s;if(e&&e.key===r&&e.name===i&&e.locale===a)return;s.dispose()}s=un(e.workspace,r,i,a),s.outputConnection.connect(o)})}finally{p.enable()}}function dn(t){let n=`<shadow type="text_v1"><field name="TEXT">${t}</field></shadow>`;return e.xml.textToDom(n)}function fn(t){let n=`<shadow type="math_number_v1"><field name="NUM">${t}</field></shadow>`;return e.xml.textToDom(n)}function pn(t){let n=`<shadow type="logic_boolean_v1"><field name="BOOL">${t?`TRUE`:`FALSE`}</field></shadow>`;return e.xml.textToDom(n)}function mn(){return e.xml.textToDom(`<shadow type="list_create_v1"></shadow>`)}function hn(){return e.xml.textToDom(`<shadow type="object_create_v1"></shadow>`)}function gn(t){let n=`<shadow type="${Jt(t)}"></shadow>`;return e.xml.textToDom(n)}function _n(t){let n=`<shadow type="${Jt(t)}"></shadow>`;return e.xml.textToDom(n)}function vn(){return e.xml.textToDom(`<shadow type="select_comp_v1"></shadow>`)}function yn(){return e.xml.textToDom(`<shadow type="select_slot_v1"></shadow>`)}function bn(){return e.xml.textToDom(`
5
+ `,a=p.xml.textToDom(i);return re.domToBlock(a,e)}function V(e,t){try{x.disable(),t.forEach(t=>{let[n,r,i,a]=t,o=e.getInput(n)?.connection;if(!o)return;let s=o.targetBlock();if(s){let e=s;if(e&&e.key===r&&e.name===i&&e.locale===a)return;s.dispose()}s=un(e.workspace,r,i,a),s.outputConnection.connect(o)})}finally{x.enable()}}function dn(e){let t=`<shadow type="text_v1"><field name="TEXT">${e}</field></shadow>`;return p.xml.textToDom(t)}function fn(e){let t=`<shadow type="math_number_v1"><field name="NUM">${e}</field></shadow>`;return p.xml.textToDom(t)}function pn(e){let t=`<shadow type="logic_boolean_v1"><field name="BOOL">${e?`TRUE`:`FALSE`}</field></shadow>`;return p.xml.textToDom(t)}function mn(){return p.xml.textToDom(`<shadow type="list_create_v1"></shadow>`)}function hn(){return p.xml.textToDom(`<shadow type="object_create_v1"></shadow>`)}function gn(e){let t=`<shadow type="${Jt(e)}"></shadow>`;return p.xml.textToDom(t)}function _n(e){let t=`<shadow type="${Jt(e)}"></shadow>`;return p.xml.textToDom(t)}function vn(){return p.xml.textToDom(`<shadow type="select_comp_v1"></shadow>`)}function yn(){return p.xml.textToDom(`<shadow type="select_slot_v1"></shadow>`)}function bn(){return p.xml.textToDom(`
6
6
  <shadow type="app_bind_entry_v1">
7
7
  <field name="KIND">notSet</field>
8
- </shadow>`)}function H(e){let t=null;return e===`string`?t=dn(``):e===`number`?t=fn(0):e===`boolean`?t=pn(!1):e===`array`?t=mn():e===`object`?t=hn():e===`any`?t=null:console.assert(!1,`type not implementd`),t}function xn(e){let t=null;return e.array?t=mn():e.ui===`transient`?t=H(e.type):e.ui===`dummy`?t=null:e.ui===`text`?t=dn(e.default):e.ui===`number`?t=fn(e.default??0):e.ui===`switch`?t=pn(e.default):e.ui===`select`?t=gn(e.items):e.ui===`multiTypes`?t=_n(e.types):e.ui===`comp`?t=vn():e.ui===`slot`?t=yn():console.assert(!1,`property ui not implementd`),t}function Sn(){let{activeObject:e,activePage:t}=C.app,n=[];if(e.type===`page`&&t.meta.arguments)for(let{id:e,name:r,type:i}of t.meta.arguments)n.push({key:e,name:r,type:i});return n}function Cn(e){let{activeObject:t,activePage:n}=C.app;if(t.type===`page`){let t=n.meta.arguments?.find(t=>t.id===e);if(t)return{key:t.id,name:t.name,type:t.type}}}function wn(){let e=[];return Sn().forEach(({key:t,name:n})=>{e.push([n,t])}),I(e)}S.get_page_argument_v1={init:function(){this.argument={key:``,name:``,type:`string`},this.appendDummyInput().appendField(`%{BKY_APP_V1_GET_PAGE_ARGUMENT_TITLE}`).appendField(new m(()=>this.genArgumentOpts_()),`ARGUMENT`),this.setOutput(!0,null),this.setStyle(`variable_blocks`),this.setTooltip(`%{BKY_APP_V1_GET_PAGE_ARGUMENT_TOOLTIP}`),this.setHelpUrl(`%{BKY_APP_V1_GET_PAGE_ARGUMENT_HELPURL}`)},saveExtraState:function(){return{argument:this.argument}},loadExtraState:function(e){this.argument.key=e.argument?.key??``,this.argument.name=e.argument?.name??``,this.argument.type=e.argument?.type??``,this.updateShape_(),setTimeout(()=>{this.checkWarning_()},0)},genArgumentOpts_:function(){return wn()},onchange:function(e){if(e.type===p.BLOCK_CHANGE){let t=e;t.blockId===this.id&&(t.element===`field`&&t.name===`ARGUMENT`&&this.onArgumentChange_(t.newValue),setTimeout(()=>{this.checkWarning_()},0))}},onArgumentChange_:function(e){let t=Cn(e);if(!t){console.assert(!1);return}this.argument.key=t.key,this.argument.name=t.name,this.argument.type=t.type,this.updateShape_()},updateShape_:function(){this.setOutput(!0,B(this.argument.type))},checkWarning_:function(){let e=Cn(this.argument.key);if(!e){this.setWarningText(F(`WARN_ARGUMENT_NOT_FOUND`));return}if(e.name!==this.argument.name&&(this.argument.name=e.name),e.type!==this.argument.type){this.setWarningText(F(`WARN_ARGUMENT_HAS_CHANGED`));return}this.setWarningText(null)}},x.forBlock.get_page_argument_v1=function(e){let t=e;return[`__getPageArgumentV1__(${x.quote_(t.argument.key)})`,_.FUNCTION_CALL]};const Tn=(e,t)=>{let n=Jt(e),r=Yt(e);S[n]={init:function(){this.appendDummyInput().appendField(new m(()=>this.genOpts_()),`ITEM`),this.setOutput(!0,r),this.setStyle(`property_blocks`),this.setTooltip(``),this.setHelpUrl(``)},genOpts_:function(){let{i18n:e}=Ae,n=[];for(let{title:r,value:i}of t)n.push([e.global.t(r),i]);return I(n)}},x.forBlock[n]=function(e){let t=x.quote_;return[t(e.getFieldValue(`ITEM`)),_.ATOMIC]}};for(let e in Qe){let t=Qe[e];for(let e of t.items)Tn(e,ze(e))}var En=Te();const Dn=(e,t)=>{let n=Jt(e),r=Yt(e);S[n]={init:function(){this.value=t[0].default,this.appendDummyInput(`DUMMY`).appendField(new m(()=>this.genOpts_()),`TYPE`),this.setOutput(!0,r),this.setStyle(`property_blocks`),this.setTooltip(``),this.setHelpUrl(``),this.updateShape_()},saveExtraState:function(){return{value:this.value}},loadExtraState:function(e){this.value=e.value,this.updateShape_(),setTimeout(()=>{this.checkWarning_()},0)},genOpts_:function(){let{i18n:e}=Ae,n=[];for(let{title:r,value:i}of t)n.push([e.global.t(r),i]);return I(n)},onchange:function(e){if(e.type===p.BLOCK_CHANGE){let t=e;t.blockId===this.id&&(t.element===`field`&&t.name===`TYPE`&&this.onTypeChange_(t.newValue),setTimeout(()=>{this.checkWarning_()},0))}},onTypeChange_:function(e){let n=t.find(t=>t.value===e);if(!n){console.assert(!1);return}this.value=n.default,this.updateShape_()},updateShape_:function(){let e=this.getInput(`DUMMY`);if(!e)return;let n=t.find(e=>e.validator(this.value));if(!n)return;e.removeField(`VALUE`,!0),e.removeField(`SUFFIX`,!0);let r,i;if(n.trait===`number`)r=new ne(this.value??0,n.min,n.max,n.precision?1/10**n.precision:null,e=>{this.value=e});else if(n.trait===`numberUnit`)r=new ne(Ze(this.value,n.unit)??0,n.min,n.max,n.precision?1/10**n.precision:null,e=>{this.value=e+n.unit}),i=n.unit;else if(n.trait===`hexColor`)r=new En.FieldColour(this.value,e=>{this.value=e},{colourOptions:on,columns:14});else if(n.trait===`themeColor`){let{i18n:e}=Ae;r=new m(()=>{let t=[];for(let{value:n,title:r}of $e)t.push([e.global.t(r),n]);return t},e=>{this.value=e})}r&&e.appendField(r,`VALUE`),i&&e.appendField(i,`SUFFIX`)},checkWarning_:function(){if(!t.find(e=>e.validator(this.value))){this.setWarningText(F(`WARN_TYPE_NOT_FOUND`));return}this.setWarningText(null)}},x.forBlock[n]=function(e){let t=x.quote_,n=e;return typeof n.value==`string`?[t(n.value),_.ATOMIC]:[n.value,_.ATOMIC]}};for(let e in Qe){let t=Qe[e];for(let e of t.types)Dn(e,Ve(e))}function On(){let e=[],{appList:t}=C.app;for(let{id:n,name:r}of t)e.push({id:n,name:r});return e}function kn(e){let{appList:t}=C.app,n=t.find(t=>t.id===e);if(n)return{id:n.id,name:n.name}}function An(){let e=[];return On().forEach(({id:t,name:n})=>{e.push([n,t])}),I(e)}function jn(e,t){let{activeObject:n,activeComp:r}=C.app;if(R(e.key)&&t&&n.type===`comp`&&r.meta.slots){let e=r.meta.slots.find(e=>e.id===t);if(e&&e.events&&e.events.length>0)return!1}if(z(e.key)&&t&&n.type===`comp`&&r.meta.slots){let e=r.meta.slots.find(e=>e.id===t);if(e&&e.events&&e.events.length>0)return!1}return!(L(e.key)&&n.type===`comp`&&r.meta.events&&r.meta.events.length>0)}function Mn(e,t,n){let{activeObject:r,activeComp:i,depends:a}=C.app;if(e.methods&&e.methods.length>0)return!1;if($t(e.key)&&t){let e=a[t];if(e&&e.meta.methods&&e.meta.methods.length>0)return!1}if(en(e.key)&&t){let e=a[t];if(e&&e.meta.methods&&e.meta.methods.length>0)return!1}if(L(e.key)&&r.type===`comp`&&i.meta.methods&&i.meta.methods.length>0)return!1;if(L(e.key)&&n&&r.type===`comp`){let{kind:e,mainKey:t,slotKey:r}=ft(n);if(e===`elementSlot`){let e=T(t);if(e&&e.slots){let t=e.slots.find(e=>e.key===r);if(t&&t.methods&&t.methods.length>0)return!1}}else if(e===`customSlot`){let e=a[t];if(e&&e.meta.slots){let t=e.meta.slots.find(e=>e.id===r);if(t&&t.methods&&t.methods.length>0)return!1}}}return!0}function Nn(e,t){let{activeObject:n,activeComp:r}=C.app;if(R(e.key)&&t&&n.type===`comp`&&r.meta.slots){let e=r.meta.slots.find(e=>e.id===t);if(e&&e.methods&&e.methods.length>0)return!1}if(z(e.key)&&t&&n.type===`comp`&&r.meta.slots){let e=r.meta.slots.find(e=>e.id===t);if(e&&e.methods&&e.methods.length>0)return!1}return!(L(e.key)&&n.type===`comp`&&r.meta.methods&&r.meta.methods.length>0)}function Pn(e,t){let{activeObject:n,activeComp:r}=C.app;if(R(e.key)&&t&&n.type===`comp`&&r.meta.slots){let e=r.meta.slots.find(e=>e.id===t);if(e&&e.methods){for(let{outputs:t}of e.methods)if(t&&t.length>0)return!1}}if(z(e.key)&&t&&n.type===`comp`&&r.meta.slots){let e=r.meta.slots.find(e=>e.id===t);if(e&&e.methods){for(let{outputs:t}of e.methods)if(t&&t.length>0)return!1}}if(L(e.key)&&n.type===`comp`&&r.meta.methods){for(let{outputs:e}of r.meta.methods)if(e&&e.length>0)return!1}return!0}function Fn(e,t,n,r,i){return e===`triggerEvent`?jn(t,n):e===`callMethod`?Mn(t,r,i):e===`implementMethod`?Nn(t,n):e===`implementMethodOutput`?Pn(t,n):!1}function U(e){let{activeObject:t}=C.app;for(let n of t.nodes){let t=T(n.key);if(!t){console.assert(!1,`invalid element`,n.key);continue}if(!Fn(e,t,n.slot,n.comp,n.adaptSlot))return!0}return!1}function In(e){let{activeObject:t}=C.app,n=[];for(let r of t.nodes){let t=T(r.key);if(!t){console.assert(!1,`invalid element`,r.key);continue}Fn(e,t,r.slot,r.comp,r.adaptSlot)||n.push({id:r.id,key:r.key,name:t.name,alias:r.alias})}return n}function W(e){let{activeObject:t}=C.app,n=t.nodes.find(t=>t.id===e);if(!n)return;let r=T(n.key);if(!r){console.assert(!1,`invalid element`,n.key);return}return{id:n.id,key:n.key,name:r.name,alias:n.alias}}function Ln(e){let{i18n:t}=Ae,n=[],r=In(e);for(let{id:e,name:i,alias:a}of r){let r=t.global.t(i);a&&(r+=` / `+a),n.push([r,e])}return I(n)}function Rn(){let{activeObject:e,activePage:t,activeComp:n}=C.app;return e.type===`page`?t.meta.states??[]:e.type===`comp`?n.meta.states??[]:[]}function zn(e){let{activeObject:t,activePage:n,activeComp:r}=C.app;if(t.type===`page`)return n.meta.states?.find(t=>t.id===e);if(t.type===`comp`)return r.meta.states?.find(t=>t.id===e)}function Bn(){let e=[],t=Rn();for(let{id:n,name:r}of t)e.push([r,n]);return I(e)}function Vn(){let e=[`notSet`];return In(`setProperty`).length>0&&e.push(`property`),Rn().length>0&&e.push(`state`),e}function Hn(){let{i18n:e}=Ae;return I(Vn().map(t=>t===`notSet`?[e.global.t(`x-runtime-lib.${t}`),t]:[F(`APP_${pe(t)}`),t]))}function Un(){let{activeApp:e}=C.app,t=[{id:``,name:``}];for(let{id:n,name:r}of e.comps)t.push({id:n,name:r});return t}function Wn(e){let{activeApp:t}=C.app;if(!e)return{id:``,name:``};let n=t.comps.find(t=>t.id===e);if(n)return{id:n.id,name:n.name}}function Gn(){let{i18n:e}=Ae,t=[];return Un().forEach(({id:n,name:r})=>{let i=r;n===``&&(i=e.global.t(`x-runtime-lib.notSet`)),t.push([i,n])}),I(t)}function G(e){if(!e)return;let t=[];for(let{id:n,name:r,type:i}of e)t.push({key:n,name:r,type:i});return t}function K(e){return[{key:`newValue`,name:`x-runtime-lib.newValue`,type:e},{key:`oldValue`,name:`x-runtime-lib.oldValue`,type:e}]}function Kn(e){let t=!0;switch(e){case``:break;case`elementEvent`:case`elementPropertyChangeEvent`:case`elementSlotEvent`:case`elementSlotPropertyChangeEvent`:case`multipleElementSlotEvent`:case`multipleElementSlotPropertyChangeEvent`:break;case`refEvent`:t=!1;break;case`refPropertyChangeEvent`:break;case`multipleRefEvent`:t=!1;break;case`multipleRefPropertyChangeEvent`:break;case`customSlotEvent`:t=!1;break;case`customSlotPropertyChangeEvent`:break;case`multipleCustomSlotEvent`:t=!1;break;case`multipleCustomSlotPropertyChangeEvent`:break;case`customEvent`:t=!1;break;case`customPropertyChangeEvent`:break;case`elementAdaptSlotEvent`:break;case`elementAdaptSlotPropertyChangeEvent`:break;case`customAdaptSlotEvent`:t=!1;break;case`customAdaptSlotPropertyChangeEvent`:break;case`stateChangeEvent`:break;default:console.assert(!1,`not implemented kind=${e}`)}return t}function qn(e){let{activeObject:t,activePage:n,activeComp:r,depends:i}=C.app,a=[],o=Be(t.type,t.subtype),s=t.nodes.find(t=>t.id===e);if(!s)return a;let c=T(s.key);if(!c)return console.assert(!1,`invalid element`,s.key),a;if(c.events)for(let{key:t,name:n,params:r}of c.events)a.push({id:E(`elementEvent`,e,t),kind:`elementEvent`,names:[n],params:r});if(w[c.key]&&w[c.key][o])for(let{keys:t,names:n,raw:r}of w[c.key][o])a.push({id:E(`elementPropertyChangeEvent`,e,t),kind:`elementPropertyChangeEvent`,names:n,params:K(Zt(r))});if($t(c.key)&&s.comp){let t=i[s.comp];if(t&&t.meta.events)for(let{id:n,name:r,params:i}of t.meta.events)a.push({id:E(`refEvent`,e,n),kind:`refEvent`,names:[r],params:G(i)})}if($t(c.key)&&s.comp){let t=i[s.comp];if(t&&t.meta.properties)for(let{id:n,name:r,type:i}of t.meta.properties)a.push({id:E(`refPropertyChangeEvent`,e,n),kind:`refPropertyChangeEvent`,names:[r],params:K(i)})}if(en(c.key)&&s.comp){let t=i[s.comp];if(t&&t.meta.events)for(let{id:n,name:r,params:i}of t.meta.events)a.push({id:E(`multipleRefEvent`,e,n),kind:`multipleRefEvent`,names:[r],params:G(i)})}if(en(c.key)&&s.comp){let t=i[s.comp];if(t&&t.meta.properties)for(let{id:n,name:r,type:i}of t.meta.properties)a.push({id:E(`multipleRefPropertyChangeEvent`,e,n),kind:`multipleRefPropertyChangeEvent`,names:[r],params:K(i)})}if(R(c.key)&&s.slot&&t.type===`comp`&&r.meta.slots){let t=r.meta.slots.find(e=>e.id===s.slot);if(t&&t.events)for(let n of t.events)a.push({id:E(`customSlotEvent`,e,He(r.id,t.id,n.id)),kind:`customSlotEvent`,names:[t.name,n.name],params:G(n.params)})}if(R(c.key)&&s.slot&&t.type===`comp`&&r.meta.slots){let t=r.meta.slots.find(e=>e.id===s.slot);if(t&&t.properties)for(let n of t.properties)a.push({id:E(`customSlotPropertyChangeEvent`,e,Je(r.id,t.id,n.id)),kind:`customSlotPropertyChangeEvent`,names:[t.name,n.name],params:K(n.type)})}if(z(c.key)&&s.slot&&t.type===`comp`&&r.meta.slots){let t=r.meta.slots.find(e=>e.id===s.slot);if(t&&t.events)for(let n of t.events)a.push({id:E(`multipleCustomSlotEvent`,e,He(r.id,t.id,n.id)),kind:`multipleCustomSlotEvent`,names:[t.name,n.name],params:G(n.params)})}if(z(c.key)&&s.slot&&t.type===`comp`&&r.meta.slots){let t=r.meta.slots.find(e=>e.id===s.slot);if(t&&t.properties)for(let n of t.properties)a.push({id:E(`multipleCustomSlotPropertyChangeEvent`,e,Je(r.id,t.id,n.id)),kind:`multipleCustomSlotPropertyChangeEvent`,names:[t.name,n.name],params:K(n.type)})}if(L(c.key)&&t.type===`comp`&&r.meta.events)for(let{id:t,name:n,params:i}of r.meta.events)a.push({id:E(`customEvent`,e,t),kind:`customEvent`,names:[n],params:G(i)});if(L(c.key)&&t.type===`comp`&&r.meta.properties)for(let{id:t,name:n,type:i}of r.meta.properties)a.push({id:E(`customPropertyChangeEvent`,e,t),kind:`customPropertyChangeEvent`,names:[n],params:K(i)});if(L(c.key)&&t.type===`comp`&&s.adaptSlot){let{kind:t,mainKey:n,slotKey:r}=ft(s.adaptSlot);if(t===`elementSlot`){let t=T(n);if(t&&t.slots){let i=t.slots.find(e=>e.key===r);if(i&&i.events)for(let o of i.events)a.push({id:E(`elementAdaptSlotEvent`,e,Ue(n,r,o.key)),kind:`elementAdaptSlotEvent`,names:[t.name,i.name,o.name],params:o.params});if(i&&i.properties)for(let n of i.properties)a.push({id:E(`elementAdaptSlotPropertyChangeEvent`,e,Ye(t.key,i.key,n.key)),kind:`elementAdaptSlotPropertyChangeEvent`,names:[t.name,i.name,n.name],params:K(n.type)})}}else if(t===`customSlot`){let t=i[n];if(t&&t.meta.slots){let i=t.meta.slots.find(e=>e.id===r);if(i&&i.events)for(let r of i.events)a.push({id:E(`customAdaptSlotEvent`,e,He(n,i.id,r.id)),kind:`customAdaptSlotEvent`,names:[t.name,i.name,r.name],params:G(r.params)});if(i&&i.properties)for(let r of i.properties)a.push({id:E(`customAdaptSlotPropertyChangeEvent`,e,Je(n,i.id,r.id)),kind:`customAdaptSlotPropertyChangeEvent`,names:[t.name,i.name,r.name],params:K(r.type)})}}}if(L(c.key)){if(t.type===`page`){if(n.meta.states)for(let{id:e,name:t,type:r}of n.meta.states)a.push({id:E(`stateChangeEvent`,`globality`,e),kind:`stateChangeEvent`,names:[t],params:K(r)})}else if(t.type===`comp`&&r.meta.states)for(let{id:e,name:t,type:n}of r.meta.states)a.push({id:E(`stateChangeEvent`,`globality`,e),kind:`stateChangeEvent`,names:[t],params:K(n)})}return a}function Jn(e){if(!e)return;let{activeObject:t,activePage:n,activeComp:r,depends:i}=C.app,a=Be(t.type,t.subtype),{kind:o,nodeId:s,eventKey:c}=rt(e),l=t.nodes.find(e=>e.id===s);if(!l)return;let u=T(l.key);if(!u){console.assert(!1,`invalid element`,l.key);return}if(o===`elementEvent`){let t=u.events?.find(e=>e.key===c);if(t)return{id:e,kind:o,names:[t.name],params:t.params}}else if(o===`elementPropertyChangeEvent`){if(w[u.key]&&w[u.key][a]){let t=w[u.key][a].find(e=>e.keys===c);if(t)return{id:e,kind:o,names:t.names,params:K(Zt(t.raw))}}}else if(o===`refEvent`){if($t(u.key)&&l.comp){let t=i[l.comp];if(t){let n=t.meta.events?.find(e=>e.id===c);if(n)return{id:e,kind:o,names:[n.name],params:G(n.params)}}}}else if(o===`refPropertyChangeEvent`){if($t(u.key)&&l.comp){let t=i[l.comp];if(t){let n=t.meta.properties?.find(e=>e.id===c);if(n)return{id:e,kind:o,names:[n.name],params:K(n.type)}}}}else if(o===`multipleRefEvent`){if(en(u.key)&&l.comp){let t=i[l.comp];if(t){let n=t.meta.events?.find(e=>e.id===c);if(n)return{id:e,kind:o,names:[n.name],params:G(n.params)}}}}else if(o===`multipleRefPropertyChangeEvent`){if(en(u.key)&&l.comp){let t=i[l.comp];if(t){let n=t.meta.properties?.find(e=>e.id===c);if(n)return{id:e,kind:o,names:[n.name],params:K(n.type)}}}}else if(o===`customSlotEvent`){if(R(u.key)&&l.slot&&t.type===`comp`&&r.meta.slots){let{compId:t,slotId:n,eventId:i}=it(c);if(r.id===t&&l.slot===n){let t=r.meta.slots.find(e=>e.id===n);if(t&&t.events){let n=t.events.find(e=>e.id===i);if(n)return{id:e,kind:o,names:[t.name,n.name],params:G(n.params)}}}}}else if(o===`customSlotPropertyChangeEvent`){if(R(u.key)&&l.slot&&t.type===`comp`&&r.meta.slots){let{compId:t,slotId:n,eventId:i}=it(c);if(r.id===t&&l.slot===n){let t=r.meta.slots.find(e=>e.id===n);if(t&&t.properties){let n=t.properties.find(e=>e.id===i);if(n)return{id:e,kind:o,names:[t.name,n.name],params:K(n.type)}}}}}else if(o===`multipleCustomSlotEvent`){if(z(u.key)&&l.slot&&t.type===`comp`&&r.meta.slots){let{compId:t,slotId:n,eventId:i}=it(c);if(r.id===t&&l.slot&&n){let t=r.meta.slots.find(e=>e.id===n);if(t&&t.events){let n=t.events.find(e=>e.id===i);if(n)return{id:e,kind:o,names:[t.name,n.name],params:G(n.params)}}}}}else if(o===`multipleCustomSlotPropertyChangeEvent`){if(z(u.key)&&l.slot&&t.type===`comp`&&r.meta.slots){let{compId:t,slotId:n,eventId:i}=it(c);if(r.id===t&&l.slot===n){let t=r.meta.slots.find(e=>e.id===n);if(t&&t.properties){let n=t.properties.find(e=>e.id===i);if(n)return{id:e,kind:o,names:[t.name,n.name],params:K(n.type)}}}}}else if(o===`customEvent`){if(L(u.key)&&t.type===`comp`){let t=r.meta.events?.find(e=>e.id===c);if(t)return{id:e,kind:o,names:[t.name],params:G(t.params)}}}else if(o===`customPropertyChangeEvent`){if(L(u.key)&&t.type===`comp`){let t=r.meta.properties?.find(e=>e.id===c);if(t)return{id:e,kind:o,names:[t.name],params:K(t.type)}}}else if(o===`elementAdaptSlotEvent`){if(L(u.key)&&t.type===`comp`&&l.adaptSlot){let{elementKey:t,slotKey:n,eventKey:r}=at(c);if(tn(l.adaptSlot,t,n)){let i=T(t);if(i&&i.slots){let t=i.slots.find(e=>e.key===n);if(t&&t.events){let n=t.events.find(e=>e.key===r);if(n)return{id:e,kind:o,names:[i.name,t.name,n.name],params:n.params}}}}}}else if(o===`elementAdaptSlotPropertyChangeEvent`){if(L(u.key)&&t.type===`comp`&&l.adaptSlot){let{elementKey:t,slotKey:n,propertyKey:r}=dt(c);if(tn(l.adaptSlot,t,n)){let i=T(t);if(i&&i.slots){let t=i.slots.find(e=>e.key===n);if(t&&t.properties){let n=t.properties.find(e=>e.key===r);if(n)return{id:e,kind:o,names:[i.name,t.name,n.name],params:K(n.type)}}}}}}else if(o===`customAdaptSlotEvent`){if(L(u.key)&&t.type===`comp`&&l.adaptSlot){let{compId:t,slotId:n,eventId:r}=it(c);if(nn(l.adaptSlot,t,n)){let a=i[t];if(a&&a.meta.slots){let t=a.meta.slots.find(e=>e.id===n);if(t&&t.events){let n=t.events.find(e=>e.id===r);if(n)return{id:e,kind:o,names:[a.name,t.name,n.name],params:G(n.params)}}}}}}else if(o===`customAdaptSlotPropertyChangeEvent`){if(L(u.key)&&t.type===`comp`&&l.adaptSlot){let{compId:t,slotId:n,propertyId:r}=ut(c);if(nn(l.adaptSlot,t,n)){let a=i[t];if(a&&a.meta.slots){let t=a.meta.slots.find(e=>e.id===n);if(t&&t.properties){let n=t.properties.find(e=>e.id===r);if(n)return{id:e,kind:o,names:[a.name,t.name,n.name],params:K(n.type)}}}}}}else if(o===`stateChangeEvent`&&L(u.key)){if(t.type===`page`){let t=n.meta.states?.find(e=>e.id===c);if(t)return{id:e,kind:o,names:[t.name],params:K(t.type)}}else if(t.type===`comp`){let t=r.meta.states?.find(e=>e.id===c);if(t)return{id:e,kind:o,names:[t.name],params:K(t.type)}}}}function Yn(e){let t=[],n=qn(e),r;for(let{id:e,kind:i,names:a}of n)i!==r&&(r&&t.push(`separator`),r=i),t.push([et(i,a),e]);return I(t)}function Xn(e){let{activeObject:t,activeComp:n}=C.app,r=[],i=t.nodes.find(t=>t.id===e);if(!i)return r;let a=T(i.key);if(!a)return console.assert(!1,`invalid element`,i.key),r;if(R(a.key)&&i.slot&&t.type===`comp`&&n.meta.slots){let t=n.meta.slots.find(e=>e.id===i.slot);if(t&&t.events)for(let i of t.events)r.push({id:E(`customSlotEvent`,e,He(n.id,t.id,i.id)),kind:`customSlotEvent`,names:[t.name,i.name],params:G(i.params)})}if(z(a.key)&&i.slot&&t.type===`comp`&&n.meta.slots){let t=n.meta.slots.find(e=>e.id===i.slot);if(t&&t.events)for(let i of t.events)r.push({id:E(`multipleCustomSlotEvent`,e,He(n.id,t.id,i.id)),kind:`multipleCustomSlotEvent`,names:[t.name,i.name],params:G(i.params)})}if(L(a.key)&&t.type===`comp`&&n.meta.events)for(let e of n.meta.events)r.push({id:E(`customEvent`,`globality`,e.id),kind:`customEvent`,names:[e.name],params:G(e.params)});return r}function Zn(e){if(!e)return;let{activeObject:t,activeComp:n}=C.app,{kind:r,nodeId:i,eventKey:a}=rt(e),o=t.nodes.find(e=>e.id===i);if(!o)return;let s=T(o.key);if(!s){console.assert(!1,`invalid element`,o.key);return}if(r===`customSlotEvent`){if(R(s.key)&&o.slot&&t.type===`comp`&&n.meta.slots){let{compId:t,slotId:i,eventId:s}=it(a);if(n.id===t&&o.slot===i){let t=n.meta.slots.find(e=>e.id===i);if(t&&t.events){let n=t.events.find(e=>e.id===s);if(n)return{id:e,kind:r,names:[t.name,n.name],params:G(n.params)}}}}}else if(r===`multipleCustomSlotEvent`){if(z(s.key)&&o.slot&&t.type===`comp`&&n.meta.slots){let{compId:t,slotId:i,eventId:s}=it(a);if(n.id===t&&o.slot&&i){let t=n.meta.slots.find(e=>e.id===i);if(t&&t.events){let n=t.events.find(e=>e.id===s);if(n)return{id:e,kind:r,names:[t.name,n.name],params:G(n.params)}}}}}else if(r===`customEvent`&&L(s.key)&&t.type===`comp`&&n.meta.events){let t=n.meta.events.find(e=>e.id===a);if(t)return{id:e,kind:r,names:[t.name],params:G(t.params)}}}function Qn(e){let t=[],n=Xn(e),r;for(let{id:e,kind:i,names:a}of n)i!==r&&(r&&t.push(`separator`),r=i),t.push([et(i,a),e]);return I(t)}function q(e){if(!e)return;let t=[];for(let{id:n,name:r,type:i}of e)t.push({key:n,name:r,type:i});return t}function J(e){if(!e)return;let t=[];for(let{id:n,name:r,type:i}of e)t.push({key:n,name:r,type:i});return t}function $n(e){let t=!0;switch(e){case``:break;case`elementMethod`:case`elementSlotMethod`:case`multipeElementSlotMethod`:break;case`refMethod`:case`multipleRefMethod`:t=!1;break;case`customSlotMethod`:case`multipleCustomSlotMethod`:t=!1;break;case`customMethod`:t=!1;break;case`elementAdaptSlotMethod`:break;case`customAdaptSlotMethod`:t=!1;break;default:console.assert(!1,`not implemented kind=${e}`)}return t}function er(e){let{activeObject:t,activeComp:n,depends:r}=C.app,i=[],a=t.nodes.find(t=>t.id===e);if(!a)return i;let o=T(a.key);if(!o)return console.assert(!1,`inavlid element`,a.key),i;if(o.methods)for(let{key:t,name:n,inputs:r,outputs:a}of o.methods)i.push({id:We(`elementMethod`,e,t),kind:`elementMethod`,names:[n],inputs:r,outputs:a});if($t(o.key)&&a.comp){let t=r[a.comp];if(t&&t.meta.methods)for(let{id:n,name:r,inputs:a,outputs:o}of t.meta.methods)i.push({id:We(`refMethod`,e,n),kind:`refMethod`,names:[r],inputs:q(a),outputs:J(o)})}if(en(o.key)&&a.comp){let t=r[a.comp];if(t&&t.meta.methods)for(let{id:n,name:r,inputs:a,outputs:o}of t.meta.methods)i.push({id:We(`multipleRefMethod`,e,n),kind:`multipleRefMethod`,names:[r],inputs:q(a),outputs:J(o)})}if(L(o.key)&&t.type===`comp`&&n.meta.methods)for(let{id:t,name:r,inputs:a,outputs:o}of n.meta.methods)i.push({id:We(`customMethod`,e,t),kind:`customMethod`,names:[r],inputs:q(a),outputs:J(o)});if(L(o.key)&&t.type===`comp`&&a.adaptSlot){let{kind:t,mainKey:n,slotKey:o}=ft(a.adaptSlot);if(t===`elementSlot`){let t=T(n);if(t&&t.slots){let n=t.slots.find(e=>e.key===o);if(n&&n.methods)for(let r of n.methods)i.push({id:We(`elementAdaptSlotMethod`,e,Ke(t.key,n.key,r.key)),kind:`elementAdaptSlotMethod`,names:[t.name,n.name,r.name],inputs:r.inputs,outputs:r.outputs})}}else if(t===`customSlot`){let t=r[n];if(t&&t.meta.slots){let r=t.meta.slots.find(e=>e.id===o);if(r&&r.methods)for(let a of r.methods)i.push({id:We(`customAdaptSlotMethod`,e,Ge(n,r.id,a.id)),kind:`customAdaptSlotMethod`,names:[t.name,r.name,a.name],inputs:q(a.inputs),outputs:J(a.outputs)})}}}return i}function tr(e){if(!e)return;let{activeObject:t,activeComp:n,depends:r}=C.app,{kind:i,nodeId:a,methodKey:o}=ot(e),s=t.nodes.find(e=>e.id===a);if(!s)return;let c=T(s.key);if(!c){console.assert(!1,`invalid element`,s.key);return}if(i===`elementMethod`){let t=c.methods?.find(e=>e.key===o);if(t)return{id:e,kind:i,names:[t.name],inputs:t.inputs,outputs:t.outputs}}else if(i===`refMethod`){if($t(c.key)&&s.comp){let t=r[s.comp];if(t){let n=t.meta.methods?.find(e=>e.id===o);if(n)return{id:e,kind:i,names:[n.name],inputs:q(n.inputs),outputs:J(n.outputs)}}}}else if(i===`multipleRefMethod`){if(en(c.key)&&s.comp){let t=r[s.comp];if(t){let n=t.meta.methods?.find(e=>e.id===o);if(n)return{id:e,kind:i,names:[n.name],inputs:q(n.inputs),outputs:J(n.outputs)}}}}else if(i===`customMethod`){if(L(c.key)&&t.type===`comp`){let t=n.meta.methods?.find(e=>e.id===o);if(t)return{id:e,kind:i,names:[t.name],inputs:q(t.inputs),outputs:q(t.outputs)}}}else if(i===`customSlotMethod`){if(L(c.key)&&t.type===`comp`&&n.meta.slots){let{slotId:t,methodId:r}=st(o),a=n.meta.slots.find(e=>e.id===t);if(a&&a.methods){let t=a.methods.find(e=>e.id===r);if(t)return{id:e,kind:i,names:[a.name,t.name],inputs:q(t.inputs),outputs:J(t.outputs)}}}}else if(i===`elementAdaptSlotMethod`){if(L(c.key)&&t.type===`comp`&&s.adaptSlot){let{elementKey:t,slotKey:n,methodKey:r}=ct(o);if(tn(s.adaptSlot,t,n)){let a=T(t);if(a&&a.slots){let t=a.slots.find(e=>e.key===n);if(t&&t.methods){let n=t.methods.find(e=>e.key===r);if(n)return{id:e,kind:i,names:[a.name,t.name,n.name],inputs:n.inputs,outputs:n.outputs}}}}}}else if(i===`customAdaptSlotMethod`&&L(c.key)&&t.type===`comp`&&s.adaptSlot){let{compId:t,slotId:n,methodId:a}=st(o);if(nn(s.adaptSlot,t,n)){let o=r[t];if(o&&o.meta.slots){let t=o.meta.slots.find(e=>e.id===n);if(t&&t.methods){let n=t.methods.find(e=>e.id===a);if(n)return{id:e,kind:i,names:[o.name,t.name,n.name],inputs:q(n.inputs),outputs:J(n.outputs)}}}}}}function nr(e){let t=[],n=er(e),r;for(let{id:e,kind:i,names:a}of n)i!==r&&(r&&t.push(`separator`),r=i),t.push([tt(i,a),e]);return I(t)}function rr(e){let t=!0;switch(e){case``:break;case`elementMethod`:case`elementSlotMethod`:case`multipeElementSlotMethod`:break;case`refMethod`:case`multipleRefMethod`:t=!1;break;case`customSlotMethod`:case`multipleCustomSlotMethod`:t=!1;break;case`customMethod`:t=!1;break;case`elementAdaptSlotMethod`:break;case`customAdaptSlotMethod`:t=!1;break;default:console.assert(!1,`not implemented kind=${e}`)}return t}function ir(e){let{activeObject:t,activeComp:n}=C.app,r=[],i=t.nodes.find(t=>t.id===e);if(!i)return r;let a=T(i.key);if(!a)return console.assert(!1,`inavlid element`,i.key),r;if(R(a.key)&&i.slot&&t.type===`comp`&&n.meta.slots){let t=n.meta.slots.find(e=>e.id===i.slot);if(t&&t.methods)for(let i of t.methods)r.push({id:We(`customSlotMethod`,e,Ge(n.id,t.id,i.id)),kind:`customSlotMethod`,names:[t.name,i.name],inputs:q(i.inputs),outputs:q(i.outputs)})}if(z(a.key)&&i.slot&&t.type===`comp`&&n.meta.slots){let t=n.meta.slots.find(e=>e.id===i.slot);if(t&&t.methods)for(let i of t.methods)r.push({id:We(`multipleCustomSlotMethod`,e,Ge(n.id,t.id,i.id)),kind:`multipleCustomSlotMethod`,names:[t.name,i.name],inputs:q(i.inputs),outputs:J(i.outputs)})}if(L(a.key)&&t.type===`comp`&&n.meta.methods)for(let{id:t,name:i,inputs:a,outputs:o}of n.meta.methods)r.push({id:We(`customMethod`,e,t),kind:`customMethod`,names:[i],inputs:q(a),outputs:J(o)});return r}function ar(e){if(!e)return;let{activeObject:t,activeComp:n}=C.app,{kind:r,nodeId:i,methodKey:a}=ot(e),o=t.nodes.find(e=>e.id===i);if(!o)return;let s=T(o.key);if(!s){console.assert(!1,`invalid element`,o.key);return}if(r===`customSlotMethod`){if(R(s.key)&&o.slot&&t.type===`comp`&&n.meta.slots){let{compId:t,slotId:i,methodId:s}=st(a);if(n.id===t&&i===o.slot){let t=n.meta.slots.find(e=>e.id===i);if(t&&t.methods){let n=t.methods.find(e=>e.id===s);if(n)return{id:e,kind:r,names:[t.name,n.name],inputs:q(n.inputs),outputs:J(n.outputs)}}}}}else if(r===`multipleCustomSlotMethod`){if(z(s.key)&&o.slot&&t.type===`comp`&&n.meta.slots){let{compId:t,slotId:i,methodId:s}=st(a);if(n.id===t&&o.slot===i){let t=n.meta.slots.find(e=>e.id===i);if(t&&t.methods){let n=t.methods.find(e=>e.id===s);if(n)return{id:e,kind:r,names:[t.name,n.name],inputs:q(n.inputs),outputs:J(n.outputs)}}}}}else if(r===`customMethod`&&L(s.key)&&t.type===`comp`&&n.meta.methods){let t=n.meta.methods.find(e=>e.id===a);if(t)return{id:e,kind:r,names:[t.name],inputs:q(t.inputs),outputs:J(t.outputs)}}}function or(e){let t=[],n=ir(e),r;for(let{id:e,kind:i,names:a}of n)i!==r&&(r&&t.push(`separator`),r=i),t.push([tt(i,a),e]);return I(t)}function sr(e){let t=ar(e);return t?t.outputs:[]}function cr(e,t){let n=ar(e);if(n)return n.outputs?.find(e=>e.key===t)}function lr(e){let t=[],n=sr(e);if(n)for(let{name:e,key:r}of n)t.push([e,r]);return I(t)}function ur(e){let{appList:t}=C.app,n=[],r=t.find(t=>t.id===e);if(!r)return n;for(let{id:e,name:t}of r.pages)n.push({id:e,name:t});return n}function dr(e,t){let{appList:n}=C.app,r=n.find(t=>t.id===e);if(!r)return;let i=r.pages.find(e=>e.id===t);if(i)return{id:i.id,name:i.name}}function fr(e){let t=[];return ur(e).forEach(({id:e,name:n})=>{t.push([n,e])}),I(t)}function pr(e,t){let{activeObject:n,activeComp:r,depends:i}=C.app,a=[],o=Be(n.type,n.subtype),s=n.nodes.find(t=>t.id===e);if(!s)return a;let c=T(s.key);if(!c)return console.assert(!1,`invalid element`,s.key),a;if(w[c.key]&&w[c.key][o])for(let{keys:n,names:r,raw:i}of w[c.key][o])t===`write`&&Qt(n,i)||a.push({id:qe(`elementProperty`,e,n),kind:`elementProperty`,names:r,meta:{element:!0,raw:i}});if($t(c.key)&&s.comp){let t=i[s.comp];if(t&&t.meta.properties)for(let{id:n,name:r,type:i}of t.meta.properties)a.push({id:qe(`refProperty`,e,n),kind:`refProperty`,names:[r],meta:{raw:{type:i}}})}if(en(c.key)&&s.comp){let t=i[s.comp];if(t&&t.meta.properties)for(let{id:n,name:r,type:i}of t.meta.properties)a.push({id:qe(`multipleRefProperty`,e,n),kind:`multipleRefProperty`,names:[r],meta:{raw:{type:i}}})}if(R(c.key)&&s.slot&&n.type===`comp`&&r.meta.slots){let t=r.meta.slots.find(e=>e.id===s.slot);if(t&&t.properties)for(let n of t.properties)a.push({id:qe(`customSlotProperty`,e,Je(r.id,t.id,n.id)),kind:`customSlotProperty`,names:[t.name,n.name],meta:{raw:{type:n.type}}})}if(z(c.key)&&s.slot&&n.type===`comp`&&r.meta.slots){let t=r.meta.slots.find(e=>e.id===s.slot);if(t&&t.properties)for(let n of t.properties)a.push({id:qe(`multipleCustomSlotProperty`,e,Je(r.id,t.id,n.id)),kind:`multipleCustomSlotProperty`,names:[t.name,n.name],meta:{raw:{type:n.type}}})}if(L(c.key)&&n.type===`comp`&&r.meta.properties)for(let{id:t,name:n,type:i}of r.meta.properties)a.push({id:qe(`customProperty`,e,t),kind:`customProperty`,names:[n],meta:{raw:{type:i}}});if(L(c.key)&&n.type===`comp`&&s.adaptSlot){let{kind:n,mainKey:r,slotKey:o}=ft(s.adaptSlot);if(n===`elementSlot`){let n=T(r);if(n&&n.slots){let r=n.slots.find(e=>e.key===o);if(r&&r.properties)for(let i of r.properties)t===`write`&&i.readonly||a.push({id:qe(`elementAdaptSlotProperty`,e,Ye(n.key,r.key,i.key)),kind:`elementAdaptSlotProperty`,names:[n.name,r.name,i.name],meta:{raw:{type:i.type}}})}}else if(n===`customSlot`){let t=i[r];if(t&&t.meta.slots){let n=t.meta.slots.find(e=>e.id===o);if(n&&n.properties)for(let i of n.properties)a.push({id:qe(`customAdaptSlotProperty`,e,Je(r,n.id,i.id)),kind:`customAdaptSlotProperty`,names:[t.name,n.name,i.name],meta:{raw:{type:i.type}}})}}}return a}function mr(e){if(!e)return;let{activeObject:t,activeComp:n,depends:r}=C.app,i=Be(t.type,t.subtype),{kind:a,nodeId:o,propertyKey:s}=lt(e),c=t.nodes.find(e=>e.id===o);if(!c)return;let l=T(c.key);if(!l){console.assert(!1,`invalid element`,c.key);return}if(a===`elementProperty`){if(w[l.key]&&w[l.key][i]){let t=w[l.key][i].find(e=>e.keys===s);if(t)return{id:e,kind:a,names:t.names,meta:{element:!0,raw:t.raw}}}}else if(a===`refProperty`){if($t(l.key)&&c.comp){let t=r[c.comp];if(t){let n=t.meta.properties?.find(e=>e.id===s);if(n)return{id:e,kind:a,names:[n.name],meta:{raw:{type:n.type}}}}}}else if(a===`multipleRefProperty`){if(en(l.key)&&c.comp){let t=r[c.comp];if(t){let n=t.meta.properties?.find(e=>e.id===s);if(n)return{id:e,kind:a,names:[n.name],meta:{raw:{type:n.type}}}}}}else if(a===`customSlotProperty`){if(R(l.key)&&c.slot&&t.type===`comp`&&n.meta.slots){let{compId:t,slotId:r,propertyId:i}=ut(s);if(n.id===t&&c.slot===r){let t=n.meta.slots.find(e=>e.id===r);if(t&&t.properties){let n=t.properties.find(e=>e.id===i);if(n)return{id:e,kind:a,names:[t.name,n.name],meta:{raw:{type:n.type}}}}}}}else if(a===`multipleCustomSlotProperty`){if(z(l.key)&&c.slot&&t.type===`comp`&&n.meta.slots){let{compId:t,slotId:r,propertyId:i}=ut(s);if(n.id===t&&c.slot===r){let t=n.meta.slots.find(e=>e.id===r);if(t&&t.properties){let n=t.properties.find(e=>e.id===i);if(n)return{id:e,kind:a,names:[t.name,n.name],meta:{raw:{type:n.type}}}}}}}else if(a===`customProperty`){if(L(l.key)&&t.type===`comp`){let t=n.meta.properties?.find(e=>e.id===s);if(t)return{id:e,kind:a,names:[t.name],meta:{raw:{type:t.type}}}}}else if(a===`elementAdaptSlotProperty`){if(L(l.key)&&t.type===`comp`&&c.adaptSlot){let{elementKey:t,slotKey:n,propertyKey:r}=dt(s);if(tn(c.adaptSlot,t,n)){let i=T(t);if(i&&i.slots){let t=i.slots.find(e=>e.key===n);if(t&&t.properties){let n=t.properties.find(e=>e.key===r);if(n)return{id:e,kind:a,names:[i.name,t.name,n.name],meta:{raw:{type:n.type}}}}}}}}else if(a===`customAdaptSlotProperty`&&L(l.key)&&t.type===`comp`&&c.adaptSlot){let{compId:t,slotId:n,propertyId:i}=ut(s);if(nn(c.adaptSlot,t,n)){let o=r[t];if(o&&o.meta.slots){let t=o.meta.slots.find(e=>e.id===n);if(t&&t.properties){let n=t.properties.find(e=>e.id===i);if(n)return{id:e,kind:a,names:[o.name,t.name,n.name],meta:{raw:{type:n.type}}}}}}}}function hr(e,t){let n=[],r=pr(e,t),i;for(let{id:e,kind:t,names:a}of r)t!==i&&(i&&n.push(`separator`),i=t),n.push([nt(t,a),e]);return I(n)}function gr(){let{activeObject:e,activeComp:t}=C.app,n=[{id:``,name:``}];if(e.type!==`comp`||!t.meta.slots)return n;for(let{id:e,name:r}of t.meta.slots)n.push({id:e,name:r});return n}function _r(e){let{activeObject:t,activeComp:n}=C.app;if(t.type!==`comp`||!n.meta.slots)return;if(!e)return{id:``,name:``};let r=n.meta.slots.find(t=>t.id===e);if(r)return{id:r.id,name:r.name}}function vr(){let{i18n:e}=Ae,t=[],n=gr();for(let{id:r,name:i}of n){let n=i;r===``&&(n=e.global.t(`x-runtime-lib.notSet`)),t.push([n,r])}return I(t)}S.app_bind_entry_v1={init:function(){this.kind=`notSet`,this.node={id:``,key:``,alias:``},this.property={id:``,kind:``,names:[]},this.state={id:``,name:``,type:`string`},this.appendDummyInput().appendField(new m(()=>this.genKindOpts_()),`KIND`).appendField(new m(()=>this.genNodeOpts_()),`NODE`).appendField(new m(()=>this.genPropertyOpts_()),`PROPERTY`).appendField(new m(()=>this.genStateOpts_()),`STATE`),this.setOutput(!0,`BindEntry`),this.updateShape_()},saveExtraState:function(){return{kind:this.kind,node:this.node,property:this.property,state:this.state}},loadExtraState:function(e){this.kind=e.kind??`notSet`,this.node.id=e.node?.id??``,this.node.key=e.node?.key??``,this.node.alias=e.node?.alias??``,this.property.id=e.property?.id??``,this.property.kind=e.property?.kind??``,this.property.names=e.property?.names??[],this.state.id=e.state?.id??``,this.state.name=e.state?.name??``,this.state.type=e.state?.type??`string`,this.updateShape_(),setTimeout(()=>{this.checkWarning_()},0)},genKindOpts_:function(){return Hn()},genNodeOpts_:function(){return this.kind===`property`?Ln(`setProperty`):I([])},genPropertyOpts_:function(){return this.kind===`property`?hr(this.node.id,`write`):I([])},genStateOpts_:function(){return this.kind===`state`?Bn():I([])},onchange:function(e){if(e.type===p.BLOCK_CHANGE){let t=e;t.blockId===this.id&&(t.element===`field`&&(t.name===`KIND`?this.onKindChange_(t.newValue):t.name===`NODE`?this.onNodeChange_(t.newValue):t.name===`PROPERTY`?this.onPropertyChange_(t.newValue):t.name===`STATE`&&this.onStateChange_(t.newValue)),setTimeout(()=>{this.checkWarning_()}))}},onKindChange_:function(e){let t=this.kind!==e;if(this.kind=e,this.kind===`notSet`)this.updateShape_();else if(this.kind===`property`){let e=this.getField(`NODE`);if(e.getOptions(!1),t){let t=In(`setProperty`)?.[0];e.setValue(t?.id??``)}this.onNodeChange_(e.getValue())}else if(this.kind===`state`){let e=this.getField(`STATE`);if(e.getOptions(!1),t){let t=Rn()?.[0];e.setValue(t?.id??``)}this.onStateChange_(e.getValue())}},onNodeChange_:function(e){let t=W(e);if(!t){console.assert(!1);return}let n=this.node?.id!==t.id;this.node.id=t.id,this.node.key=t.key,this.node.alias=t.alias;let r=this.getField(`PROPERTY`);if(r.getOptions(!1),n){let e=pr(this.node.id,`write`)?.[0];r.setValue(e?.id??``)}this.onPropertyChange_(r.getValue())},onPropertyChange_:function(e){let t=mr(e);if(!t){console.assert(!1);return}this.property.id=t.id,this.property.kind=t.kind,this.property.names=t.names,this.updateShape_()},onStateChange_:function(e){let t=zn(e);if(!t){console.assert(!1);return}this.state.id=t.id,this.state.name=t.name,this.state.type=t.type,this.updateShape_()},updateShape_:function(){this.kind===`notSet`?(this.setStyle(`event_blocks`),this.getField(`NODE`).setVisible(!1),this.getField(`PROPERTY`).setVisible(!1),this.getField(`STATE`).setVisible(!1)):this.kind===`property`?(this.setStyle(`property_blocks`),this.getField(`NODE`).setVisible(!0),this.getField(`PROPERTY`).setVisible(!0),this.getField(`STATE`).setVisible(!1)):this.kind===`state`&&(this.setStyle(`state_blocks`),this.getField(`NODE`).setVisible(!1),this.getField(`PROPERTY`).setVisible(!1),this.getField(`STATE`).setVisible(!0)),setTimeout(()=>{this.render()},0)},checkWarning_:function(){if(this.kind===`property`){let e=W(this.node.id);if(!e){this.setWarningText(F(`WARN_NODE_NOT_FOUND`));return}if(e.key!==this.node.key){this.setWarningText(F(`WARN_NODE_HAS_CHANGED`));return}e.alias!==this.node.alias&&(this.node.alias=e.alias);let t=mr(this.property.id);if(!t){this.setWarningText(F(`WARN_PROPERTY_NOT_FOUND`));return}if(t.kind!==this.property.kind){this.setWarningText(F(`WARN_PROPERTY_HAS_CHANGED`));return}y(t.names,this.property.names)||(this.property.names=t.names)}else if(this.kind===`state`){let e=zn(this.state.id);if(!e){this.setWarningText(F(`WARN_STATE_NOT_FOUND`));return}if(e.name!==this.state.name&&(this.state.name=e.name),e.type!==this.state.type){this.setWarningText(F(`WARN_STATE_HAS_CHANGED`));return}}this.setWarningText(null)}},x.forBlock.app_bind_entry_v1=function(){return``};const yr=e.xml;S.app_bind_container_v1={init:function(){this.appendDummyInput().appendField(`%{BKY_APP_V1_APP_BIND_CONTAINER_TITLE}`),this.appendStatementInput(`STACK`),this.setStyle(`event_blocks`),this.contextMenu=!1}},S.app_bind_item_v1={init:function(){this.appendDummyInput().appendField(`%{BKY_APP_V1_APP_BIND_ITEM_TITLE}`),this.setPreviousStatement(!0),this.setNextStatement(!0),this.setStyle(`event_blocks`),this.contextMenu=!1}},S.app_bind_v1={init:function(){this.itemCount_=0,this.setMutator(new s.MutatorIcon([`app_bind_item_v1`],this)),this.debounce_=ge(()=>{this.checkWarning_()},250),this.setStyle(`event_blocks`),this.setTooltip(`%{BKY_APP_V1_APP_BIND_TOOLTIP}`),this.setHelpUrl(`%{BKY_APP_V1_APP_BIND_HELPURL}`)},mutationToDom:function(){let e=yr.createElement(`mutation`);return e.setAttribute(`items`,String(this.itemCount_)),e},domToMutation:function(e){let t=e.getAttribute(`items`)??``;this.itemCount_=parseInt(t,0),this.updateShape_(),this.updateShadow_(),setTimeout(()=>{this.checkWarning_()},0)},saveExtraState:function(){return{itemCount:this.itemCount_}},loadExtraState:function(e){this.itemCount_=e.itemCount??0,this.updateShape_(),this.updateShadow_(),setTimeout(()=>{this.checkWarning_()},0)},decompose:function(e){let t=e.newBlock(`app_bind_container_v1`);t.initSvg();let n=t.getInput(`STACK`).connection;for(let t=0;t<this.itemCount_;t++){let t=e.newBlock(`app_bind_item_v1`);t.initSvg(),n.connect(t.previousConnection),n=t.nextConnection}return t},compose:function(e){let t=e.getInputTargetBlock(`STACK`),n=[];for(;t;){if(t.isInsertionMarker()){t=t.getNextBlock();continue}n.push(t.valueConnection_),t=t.getNextBlock()}for(let e=0;e<this.itemCount_;e++){this.getInput(`ADD`+e).setShadowDom(null);let t=this.getInput(`ADD`+e).connection.targetConnection;t&&!n.includes(t)&&t.disconnect()}this.itemCount_=n.length,this.updateShape_();for(let e=0;e<this.itemCount_;e++)n[e]?.reconnect(this,`ADD`+e);this.updateShadow_(),setTimeout(()=>{this.checkWarning_()},0)},saveConnections:function(e){let t=e.getInputTargetBlock(`STACK`),n=0;for(;t;){if(t.isInsertionMarker()){t=t.getNextBlock();continue}let e=this.getInput(`ADD`+n);t.valueConnection_=e?.connection.targetConnection,t=t.getNextBlock(),n++}},onchange:function(){this.debounce_()},updateShape_:function(){this.itemCount_&&this.getInput(`EMPTY`)?this.removeInput(`EMPTY`):!this.itemCount_&&!this.getInput(`EMPTY`)&&this.appendDummyInput(`EMPTY`).appendField(`%{BKY_APP_V1_APP_BIND_TITLE}`);for(let e=0;e<this.itemCount_;e++)this.getInput(`ADD`+e)||(this.appendValueInput(`ADD`+e).setCheck(`BindEntry`),e===0&&this.getInput(`ADD`+e).setAlign(b.Align.RIGHT).appendField(`%{BKY_APP_V1_APP_BIND_TITLE}`));for(let e=this.itemCount_;this.getInput(`ADD`+e);e++)this.removeInput(`ADD`+e)},updateShadow_:function(){if(!this.isInsertionMarker())for(let e=0;e<this.itemCount_;e++)this.getInput(`ADD`+e).setShadowDom(bn())},checkWarning_:function(){let e;for(let t=0;t<this.itemCount_;t++){let n=this.getInput(`ADD`+t)?.connection?.targetBlock();if(!n)continue;let r;if(n.kind===`property`){let e=mr(n.property.id);e&&(r=e.meta.element?rn(e.meta.raw):B(e.meta.raw.type))}else if(n.kind===`state`){let e=zn(n.state.id);e&&(r=B(e.type))}if(r&&(e||(e=r),r!==e)){this.setWarningText(F(`WARN_TYPE_NOT_MATCH`));return}}this.setWarningText(null)}},x.forBlock.app_bind_v1=function(){return``},S.on_app_event_v1={init:function(){this.node={id:``,key:``,alias:``},this.event={id:``,kind:``,names:[]},this.appendDummyInput().appendField(`%{BKY_APP_V1_ON_APP_EVENT_TITLE}`).appendField(new m(()=>this.genNodeOpts_()),`NODE`).appendField(new m(()=>this.genEventOpts_()),`EVENT`),this.appendStatementInput(`HANDLE`).appendField(`%{BKY_APP_DO}`),this.setStyle(`event_blocks`),this.setTooltip(`%{BKY_APP_V1_ON_APP_EVENT_TOOLTIP}`),this.setHelpUrl(`%{BKY_APP_V1_ON_APP_EVENT_HELPURL}`),this.initData_()},initData_:function(){if(this.node.id)return;let e=In(`onEvent`)?.[0];if(!e)return;this.node.id=e.id,this.node.key=e.key,this.node.alias=e.alias;let t=this.getField(`NODE`);t.getOptions(!1),t.setValue(this.node.id);let n=qn(this.node.id)?.[0];if(!n)return;this.event.id=n.id,this.event.kind=n.kind,this.event.names=n.names,this.event.params=n.params;let r=this.getField(`EVENT`);r.getOptions(!1),r.setValue(this.event.id)},saveExtraState:function(){return{node:this.node,event:this.event}},loadExtraState:function(e){this.node.id=e.node?.id??``,this.node.key=e.node?.key??``,this.node.alias=e.node?.alias??``,this.event.id=e.event?.id??``,this.event.kind=e.event?.kind??``,this.event.names=e.event?.names??[],this.event.params=e.event?.params,this.updateShape_(),setTimeout(()=>{this.ensureBlocks_(),this.checkWarning_()},0)},genNodeOpts_:function(){return Ln(`onEvent`)},genEventOpts_:function(){return Yn(this.node.id)},onchange:function(e){if(e.type===p.BLOCK_CHANGE){let t=e;t.blockId===this.id&&(t.element===`field`&&(t.name===`NODE`?this.onNodeChange_(t.newValue):t.name===`EVENT`&&this.onEventChange_(t.newValue)),setTimeout(()=>{this.checkWarning_()},0))}},onNodeChange_:function(e){let t=W(e);if(!t){console.assert(!1);return}let n=this.node.id!==t.id;this.node.id=t.id,this.node.key=t.key,this.node.alias=t.alias;let r=this.getField(`EVENT`);if(r.getOptions(!1),n){let e=qn(this.node.id)?.[0];r.setValue(e?.id??``)}this.onEventChange_(r.getValue())},onEventChange_:function(e){let t=Jn(e);if(!t){console.assert(!1);return}this.event.id=t.id,this.event.kind=t.kind,this.event.names=t.names,this.event.params=t.params,this.updateShape_(),setTimeout(()=>{this.ensureBlocks_()},0)},updateShape_:function(){for(let e=this.event.params?.length??0;this.getInput(`PARAM`+e);e++){let t=this.getInput(`PARAM`+e).connection.targetBlock();t&&t.dispose(),this.removeInput(`PARAM`+e)}if(this.event.params)for(let e=0;e<this.event.params.length;e++)this.getInput(`PARAM`+e)||(this.appendValueInput(`PARAM`+e),this.moveInputBefore(`PARAM`+e,`HANDLE`));let e=!1;switch(this.event.kind){case`multipleRefEvent`:case`multipleRefPropertyChangeEvent`:case`multipleCustomSlotEvent`:case`multipleCustomSlotPropertyChangeEvent`:e=!0}if(e)this.getInput(`INSTANCE`)||this.appendValueInput(`INSTANCE`).setCheck(`String`),this.event.params&&this.event.params.length>0?this.moveInputBefore(`INSTANCE`,`PARAM0`):this.moveInputBefore(`INSTANCE`,`HANDLE`);else if(this.getInput(`INSTANCE`)){let e=this.getInput(`INSTANCE`).connection.targetBlock();e&&e.dispose(),this.removeInput(`INSTANCE`)}},ensureBlocks_:function(){if(this.isInsertionMarker())return;let e=[];this.getInput(`INSTANCE`)&&e.push([`INSTANCE`,`__instance__`,`x-runtime-lib.instance`,!0]);let t=Kn(this.event.kind);if(this.event.params)for(let n=0;n<this.event.params.length;n++){let{key:r,name:i}=this.event.params[n];e.push([`PARAM`+n,`__param$${r}__`,i,t])}e.length>0&&V(this,e)},checkWarning_:function(){let e=W(this.node.id);if(!e){this.setWarningText(F(`WARN_NODE_NOT_FOUND`));return}if(e.key!==this.node.key){this.setWarningText(F(`WARN_NODE_HAS_CHANGED`));return}e.alias!==this.node.alias&&(this.node.alias=e.alias);let t=Jn(this.event.id);if(!t){this.setWarningText(F(`WARN_EVENT_NOT_FOUND`));return}if(t.kind!==this.event.kind){this.setWarningText(F(`WARN_EVENT_HAS_CHANGED`));return}if(y(t.names,this.event.names)||(this.event.names=t.names),!y(t.params,this.event.params)){this.setWarningText(F(`WARN_EVENT_HAS_CHANGED`));return}this.setWarningText(null)}},x.forBlock.on_app_event_v1=function(e){let t=x.quote_,n=e,r=``;if(n.event.params)for(let e=0;e<n.event.params.length;e++){let t=n.event.params[e];r+=`const __param$${t.key}__ = __params__[${e}];\n`}let i=x.statementToCode(n,`HANDLE`);return`__onEventV1__(${t(n.event.id)}, async (__params__, __instance__) => {
8
+ </shadow>`)}function H(e){let t=null;return e===`string`?t=dn(``):e===`number`?t=fn(0):e===`boolean`?t=pn(!1):e===`array`?t=mn():e===`object`?t=hn():e===`any`?t=null:console.assert(!1,`type not implementd`),t}function xn(e){let t=null;return e.array?t=mn():e.ui===`transient`?t=H(e.type):e.ui===`dummy`?t=null:e.ui===`text`?t=dn(e.default):e.ui===`number`?t=fn(e.default??0):e.ui===`switch`?t=pn(e.default):e.ui===`select`?t=gn(e.items):e.ui===`multiTypes`?t=_n(e.types):e.ui===`comp`?t=vn():e.ui===`slot`?t=yn():console.assert(!1,`property ui not implementd`),t}function Sn(){let{activeObject:e,activePage:t}=S.app,n=[];if(e.type===`page`&&t.meta.arguments)for(let{id:e,name:r,type:i}of t.meta.arguments)n.push({key:e,name:r,type:i});return n}function Cn(e){let{activeObject:t,activePage:n}=S.app;if(t.type===`page`){let t=n.meta.arguments?.find(t=>t.id===e);if(t)return{key:t.id,name:t.name,type:t.type}}}function wn(){let e=[];return Sn().forEach(({key:t,name:n})=>{e.push([n,t])}),I(e)}y.get_page_argument_v1={init:function(){this.argument={key:``,name:``,type:`string`},this.appendDummyInput().appendField(`%{BKY_APP_V1_GET_PAGE_ARGUMENT_TITLE}`).appendField(new b(()=>this.genArgumentOpts_()),`ARGUMENT`),this.setOutput(!0,null),this.setStyle(`variable_blocks`),this.setTooltip(`%{BKY_APP_V1_GET_PAGE_ARGUMENT_TOOLTIP}`),this.setHelpUrl(`%{BKY_APP_V1_GET_PAGE_ARGUMENT_HELPURL}`)},saveExtraState:function(){return{argument:this.argument}},loadExtraState:function(e){this.argument.key=e.argument?.key??``,this.argument.name=e.argument?.name??``,this.argument.type=e.argument?.type??``,this.updateShape_(),setTimeout(()=>{this.checkWarning_()},0)},genArgumentOpts_:function(){return wn()},onchange:function(e){if(e.type===x.BLOCK_CHANGE){let t=e;t.blockId===this.id&&(t.element===`field`&&t.name===`ARGUMENT`&&this.onArgumentChange_(t.newValue),setTimeout(()=>{this.checkWarning_()},0))}},onArgumentChange_:function(e){let t=Cn(e);if(!t){console.assert(!1);return}this.argument.key=t.key,this.argument.name=t.name,this.argument.type=t.type,this.updateShape_()},updateShape_:function(){this.setOutput(!0,B(this.argument.type))},checkWarning_:function(){let e=Cn(this.argument.key);if(!e){this.setWarningText(F(`WARN_ARGUMENT_NOT_FOUND`));return}if(e.name!==this.argument.name&&(this.argument.name=e.name),e.type!==this.argument.type){this.setWarningText(F(`WARN_ARGUMENT_HAS_CHANGED`));return}this.setWarningText(null)}},g.forBlock.get_page_argument_v1=function(e){let t=e;return[`__getPageArgumentV1__(${g.quote_(t.argument.key)})`,_.FUNCTION_CALL]};const Tn=(e,t)=>{let n=Jt(e),r=Yt(e);y[n]={init:function(){this.appendDummyInput().appendField(new b(()=>this.genOpts_()),`ITEM`),this.setOutput(!0,r),this.setStyle(`property_blocks`),this.setTooltip(``),this.setHelpUrl(``)},genOpts_:function(){let{i18n:e}=je,n=[];for(let{title:r,value:i}of t)n.push([e.global.t(r),i]);return I(n)}},g.forBlock[n]=function(e){let t=g.quote_;return[t(e.getFieldValue(`ITEM`)),_.ATOMIC]}};for(let e in $e){let t=$e[e];for(let e of t.items)Tn(e,Be(e))}var En=ye();const Dn=(e,t)=>{let n=Jt(e),i=Yt(e);y[n]={init:function(){this.value=t[0].default,this.appendDummyInput(`DUMMY`).appendField(new b(()=>this.genOpts_()),`TYPE`),this.setOutput(!0,i),this.setStyle(`property_blocks`),this.setTooltip(``),this.setHelpUrl(``),this.updateShape_()},saveExtraState:function(){return{value:this.value}},loadExtraState:function(e){this.value=e.value,this.updateShape_(),setTimeout(()=>{this.checkWarning_()},0)},genOpts_:function(){let{i18n:e}=je,n=[];for(let{title:r,value:i}of t)n.push([e.global.t(r),i]);return I(n)},onchange:function(e){if(e.type===x.BLOCK_CHANGE){let t=e;t.blockId===this.id&&(t.element===`field`&&t.name===`TYPE`&&this.onTypeChange_(t.newValue),setTimeout(()=>{this.checkWarning_()},0))}},onTypeChange_:function(e){let n=t.find(t=>t.value===e);if(!n){console.assert(!1);return}this.value=n.default,this.updateShape_()},updateShape_:function(){let e=this.getInput(`DUMMY`);if(!e)return;let n=t.find(e=>e.validator(this.value));if(!n)return;e.removeField(`VALUE`,!0),e.removeField(`SUFFIX`,!0);let i,a;if(n.trait===`number`)i=new r(this.value??0,n.min,n.max,n.precision?1/10**n.precision:null,e=>{this.value=e});else if(n.trait===`numberUnit`)i=new r(Qe(this.value,n.unit)??0,n.min,n.max,n.precision?1/10**n.precision:null,e=>{this.value=e+n.unit}),a=n.unit;else if(n.trait===`hexColor`)i=new En.FieldColour(this.value,e=>{this.value=e},{colourOptions:on,columns:14});else if(n.trait===`themeColor`){let{i18n:e}=je;i=new b(()=>{let t=[];for(let{value:n,title:r}of et)t.push([e.global.t(r),n]);return t},e=>{this.value=e})}i&&e.appendField(i,`VALUE`),a&&e.appendField(a,`SUFFIX`)},checkWarning_:function(){if(!t.find(e=>e.validator(this.value))){this.setWarningText(F(`WARN_TYPE_NOT_FOUND`));return}this.setWarningText(null)}},g.forBlock[n]=function(e){let t=g.quote_,n=e;return typeof n.value==`string`?[t(n.value),_.ATOMIC]:[n.value,_.ATOMIC]}};for(let e in $e){let t=$e[e];for(let e of t.types)Dn(e,He(e))}function On(){let e=[],{appList:t}=S.app;for(let{id:n,name:r}of t)e.push({id:n,name:r});return e}function kn(e){let{appList:t}=S.app,n=t.find(t=>t.id===e);if(n)return{id:n.id,name:n.name}}function An(){let e=[];return On().forEach(({id:t,name:n})=>{e.push([n,t])}),I(e)}function jn(e,t){let{activeObject:n,activeComp:r}=S.app;if(R(e.key)&&t&&n.type===`comp`&&r.meta.slots){let e=r.meta.slots.find(e=>e.id===t);if(e&&e.events&&e.events.length>0)return!1}if(z(e.key)&&t&&n.type===`comp`&&r.meta.slots){let e=r.meta.slots.find(e=>e.id===t);if(e&&e.events&&e.events.length>0)return!1}return!(L(e.key)&&n.type===`comp`&&r.meta.events&&r.meta.events.length>0)}function Mn(e,t,n){let{activeObject:r,activeComp:i,depends:a}=S.app;if(e.methods&&e.methods.length>0)return!1;if($t(e.key)&&t){let e=a[t];if(e&&e.meta.methods&&e.meta.methods.length>0)return!1}if(en(e.key)&&t){let e=a[t];if(e&&e.meta.methods&&e.meta.methods.length>0)return!1}if(L(e.key)&&r.type===`comp`&&i.meta.methods&&i.meta.methods.length>0)return!1;if(L(e.key)&&n&&r.type===`comp`){let{kind:e,mainKey:t,slotKey:r}=pt(n);if(e===`elementSlot`){let e=w(t);if(e&&e.slots){let t=e.slots.find(e=>e.key===r);if(t&&t.methods&&t.methods.length>0)return!1}}else if(e===`customSlot`){let e=a[t];if(e&&e.meta.slots){let t=e.meta.slots.find(e=>e.id===r);if(t&&t.methods&&t.methods.length>0)return!1}}}return!0}function Nn(e,t){let{activeObject:n,activeComp:r}=S.app;if(R(e.key)&&t&&n.type===`comp`&&r.meta.slots){let e=r.meta.slots.find(e=>e.id===t);if(e&&e.methods&&e.methods.length>0)return!1}if(z(e.key)&&t&&n.type===`comp`&&r.meta.slots){let e=r.meta.slots.find(e=>e.id===t);if(e&&e.methods&&e.methods.length>0)return!1}return!(L(e.key)&&n.type===`comp`&&r.meta.methods&&r.meta.methods.length>0)}function Pn(e,t){let{activeObject:n,activeComp:r}=S.app;if(R(e.key)&&t&&n.type===`comp`&&r.meta.slots){let e=r.meta.slots.find(e=>e.id===t);if(e&&e.methods){for(let{outputs:t}of e.methods)if(t&&t.length>0)return!1}}if(z(e.key)&&t&&n.type===`comp`&&r.meta.slots){let e=r.meta.slots.find(e=>e.id===t);if(e&&e.methods){for(let{outputs:t}of e.methods)if(t&&t.length>0)return!1}}if(L(e.key)&&n.type===`comp`&&r.meta.methods){for(let{outputs:e}of r.meta.methods)if(e&&e.length>0)return!1}return!0}function Fn(e,t,n,r,i){return e===`triggerEvent`?jn(t,n):e===`callMethod`?Mn(t,r,i):e===`implementMethod`?Nn(t,n):e===`implementMethodOutput`?Pn(t,n):!1}function U(e){let{activeObject:t}=S.app;for(let n of t.nodes){let t=w(n.key);if(!t){console.assert(!1,`invalid element`,n.key);continue}if(!Fn(e,t,n.slot,n.comp,n.adaptSlot))return!0}return!1}function In(e){let{activeObject:t}=S.app,n=[];for(let r of t.nodes){let t=w(r.key);if(!t){console.assert(!1,`invalid element`,r.key);continue}Fn(e,t,r.slot,r.comp,r.adaptSlot)||n.push({id:r.id,key:r.key,name:t.name,alias:r.alias})}return n}function W(e){let{activeObject:t}=S.app,n=t.nodes.find(t=>t.id===e);if(!n)return;let r=w(n.key);if(!r){console.assert(!1,`invalid element`,n.key);return}return{id:n.id,key:n.key,name:r.name,alias:n.alias}}function Ln(e){let{i18n:t}=je,n=[],r=In(e);for(let{id:e,name:i,alias:a}of r){let r=t.global.t(i);a&&(r+=` / `+a),n.push([r,e])}return I(n)}function Rn(){let{activeObject:e,activePage:t,activeComp:n}=S.app;return e.type===`page`?t.meta.states??[]:e.type===`comp`?n.meta.states??[]:[]}function zn(e){let{activeObject:t,activePage:n,activeComp:r}=S.app;if(t.type===`page`)return n.meta.states?.find(t=>t.id===e);if(t.type===`comp`)return r.meta.states?.find(t=>t.id===e)}function Bn(){let e=[],t=Rn();for(let{id:n,name:r}of t)e.push([r,n]);return I(e)}function Vn(){let e=[`notSet`];return In(`setProperty`).length>0&&e.push(`property`),Rn().length>0&&e.push(`state`),e}function Hn(){let{i18n:e}=je;return I(Vn().map(t=>t===`notSet`?[e.global.t(`x-runtime-lib.${t}`),t]:[F(`APP_${De(t)}`),t]))}function Un(){let{activeApp:e}=S.app,t=[{id:``,name:``}];for(let{id:n,name:r}of e.comps)t.push({id:n,name:r});return t}function Wn(e){let{activeApp:t}=S.app;if(!e)return{id:``,name:``};let n=t.comps.find(t=>t.id===e);if(n)return{id:n.id,name:n.name}}function Gn(){let{i18n:e}=je,t=[];return Un().forEach(({id:n,name:r})=>{let i=r;n===``&&(i=e.global.t(`x-runtime-lib.notSet`)),t.push([i,n])}),I(t)}function G(e){if(!e)return;let t=[];for(let{id:n,name:r,type:i}of e)t.push({key:n,name:r,type:i});return t}function K(e){return[{key:`newValue`,name:`x-runtime-lib.newValue`,type:e},{key:`oldValue`,name:`x-runtime-lib.oldValue`,type:e}]}function Kn(e){let t=!0;switch(e){case``:break;case`elementEvent`:case`elementPropertyChangeEvent`:case`elementSlotEvent`:case`elementSlotPropertyChangeEvent`:case`multipleElementSlotEvent`:case`multipleElementSlotPropertyChangeEvent`:break;case`refEvent`:t=!1;break;case`refPropertyChangeEvent`:break;case`multipleRefEvent`:t=!1;break;case`multipleRefPropertyChangeEvent`:break;case`customSlotEvent`:t=!1;break;case`customSlotPropertyChangeEvent`:break;case`multipleCustomSlotEvent`:t=!1;break;case`multipleCustomSlotPropertyChangeEvent`:break;case`customEvent`:t=!1;break;case`customPropertyChangeEvent`:break;case`elementAdaptSlotEvent`:break;case`elementAdaptSlotPropertyChangeEvent`:break;case`customAdaptSlotEvent`:t=!1;break;case`customAdaptSlotPropertyChangeEvent`:break;case`stateChangeEvent`:break;default:console.assert(!1,`not implemented kind=${e}`)}return t}function qn(e){let{activeObject:t,activePage:n,activeComp:r,depends:i}=S.app,a=[],o=Ve(t.type,t.subtype),s=t.nodes.find(t=>t.id===e);if(!s)return a;let c=w(s.key);if(!c)return console.assert(!1,`invalid element`,s.key),a;if(c.events)for(let{key:t,name:n,params:r}of c.events)a.push({id:T(`elementEvent`,e,t),kind:`elementEvent`,names:[n],params:r});if(C[c.key]&&C[c.key][o])for(let{keys:t,names:n,raw:r}of C[c.key][o])a.push({id:T(`elementPropertyChangeEvent`,e,t),kind:`elementPropertyChangeEvent`,names:n,params:K(Zt(r))});if($t(c.key)&&s.comp){let t=i[s.comp];if(t&&t.meta.events)for(let{id:n,name:r,params:i}of t.meta.events)a.push({id:T(`refEvent`,e,n),kind:`refEvent`,names:[r],params:G(i)})}if($t(c.key)&&s.comp){let t=i[s.comp];if(t&&t.meta.properties)for(let{id:n,name:r,type:i}of t.meta.properties)a.push({id:T(`refPropertyChangeEvent`,e,n),kind:`refPropertyChangeEvent`,names:[r],params:K(i)})}if(en(c.key)&&s.comp){let t=i[s.comp];if(t&&t.meta.events)for(let{id:n,name:r,params:i}of t.meta.events)a.push({id:T(`multipleRefEvent`,e,n),kind:`multipleRefEvent`,names:[r],params:G(i)})}if(en(c.key)&&s.comp){let t=i[s.comp];if(t&&t.meta.properties)for(let{id:n,name:r,type:i}of t.meta.properties)a.push({id:T(`multipleRefPropertyChangeEvent`,e,n),kind:`multipleRefPropertyChangeEvent`,names:[r],params:K(i)})}if(R(c.key)&&s.slot&&t.type===`comp`&&r.meta.slots){let t=r.meta.slots.find(e=>e.id===s.slot);if(t&&t.events)for(let n of t.events)a.push({id:T(`customSlotEvent`,e,Ue(r.id,t.id,n.id)),kind:`customSlotEvent`,names:[t.name,n.name],params:G(n.params)})}if(R(c.key)&&s.slot&&t.type===`comp`&&r.meta.slots){let t=r.meta.slots.find(e=>e.id===s.slot);if(t&&t.properties)for(let n of t.properties)a.push({id:T(`customSlotPropertyChangeEvent`,e,Ye(r.id,t.id,n.id)),kind:`customSlotPropertyChangeEvent`,names:[t.name,n.name],params:K(n.type)})}if(z(c.key)&&s.slot&&t.type===`comp`&&r.meta.slots){let t=r.meta.slots.find(e=>e.id===s.slot);if(t&&t.events)for(let n of t.events)a.push({id:T(`multipleCustomSlotEvent`,e,Ue(r.id,t.id,n.id)),kind:`multipleCustomSlotEvent`,names:[t.name,n.name],params:G(n.params)})}if(z(c.key)&&s.slot&&t.type===`comp`&&r.meta.slots){let t=r.meta.slots.find(e=>e.id===s.slot);if(t&&t.properties)for(let n of t.properties)a.push({id:T(`multipleCustomSlotPropertyChangeEvent`,e,Ye(r.id,t.id,n.id)),kind:`multipleCustomSlotPropertyChangeEvent`,names:[t.name,n.name],params:K(n.type)})}if(L(c.key)&&t.type===`comp`&&r.meta.events)for(let{id:t,name:n,params:i}of r.meta.events)a.push({id:T(`customEvent`,e,t),kind:`customEvent`,names:[n],params:G(i)});if(L(c.key)&&t.type===`comp`&&r.meta.properties)for(let{id:t,name:n,type:i}of r.meta.properties)a.push({id:T(`customPropertyChangeEvent`,e,t),kind:`customPropertyChangeEvent`,names:[n],params:K(i)});if(L(c.key)&&t.type===`comp`&&s.adaptSlot){let{kind:t,mainKey:n,slotKey:r}=pt(s.adaptSlot);if(t===`elementSlot`){let t=w(n);if(t&&t.slots){let i=t.slots.find(e=>e.key===r);if(i&&i.events)for(let o of i.events)a.push({id:T(`elementAdaptSlotEvent`,e,We(n,r,o.key)),kind:`elementAdaptSlotEvent`,names:[t.name,i.name,o.name],params:o.params});if(i&&i.properties)for(let n of i.properties)a.push({id:T(`elementAdaptSlotPropertyChangeEvent`,e,Xe(t.key,i.key,n.key)),kind:`elementAdaptSlotPropertyChangeEvent`,names:[t.name,i.name,n.name],params:K(n.type)})}}else if(t===`customSlot`){let t=i[n];if(t&&t.meta.slots){let i=t.meta.slots.find(e=>e.id===r);if(i&&i.events)for(let r of i.events)a.push({id:T(`customAdaptSlotEvent`,e,Ue(n,i.id,r.id)),kind:`customAdaptSlotEvent`,names:[t.name,i.name,r.name],params:G(r.params)});if(i&&i.properties)for(let r of i.properties)a.push({id:T(`customAdaptSlotPropertyChangeEvent`,e,Ye(n,i.id,r.id)),kind:`customAdaptSlotPropertyChangeEvent`,names:[t.name,i.name,r.name],params:K(r.type)})}}}if(L(c.key)){if(t.type===`page`){if(n.meta.states)for(let{id:e,name:t,type:r}of n.meta.states)a.push({id:T(`stateChangeEvent`,`globality`,e),kind:`stateChangeEvent`,names:[t],params:K(r)})}else if(t.type===`comp`&&r.meta.states)for(let{id:e,name:t,type:n}of r.meta.states)a.push({id:T(`stateChangeEvent`,`globality`,e),kind:`stateChangeEvent`,names:[t],params:K(n)})}return a}function Jn(e){if(!e)return;let{activeObject:t,activePage:n,activeComp:r,depends:i}=S.app,a=Ve(t.type,t.subtype),{kind:o,nodeId:s,eventKey:c}=it(e),l=t.nodes.find(e=>e.id===s);if(!l)return;let u=w(l.key);if(!u){console.assert(!1,`invalid element`,l.key);return}if(o===`elementEvent`){let t=u.events?.find(e=>e.key===c);if(t)return{id:e,kind:o,names:[t.name],params:t.params}}else if(o===`elementPropertyChangeEvent`){if(C[u.key]&&C[u.key][a]){let t=C[u.key][a].find(e=>e.keys===c);if(t)return{id:e,kind:o,names:t.names,params:K(Zt(t.raw))}}}else if(o===`refEvent`){if($t(u.key)&&l.comp){let t=i[l.comp];if(t){let n=t.meta.events?.find(e=>e.id===c);if(n)return{id:e,kind:o,names:[n.name],params:G(n.params)}}}}else if(o===`refPropertyChangeEvent`){if($t(u.key)&&l.comp){let t=i[l.comp];if(t){let n=t.meta.properties?.find(e=>e.id===c);if(n)return{id:e,kind:o,names:[n.name],params:K(n.type)}}}}else if(o===`multipleRefEvent`){if(en(u.key)&&l.comp){let t=i[l.comp];if(t){let n=t.meta.events?.find(e=>e.id===c);if(n)return{id:e,kind:o,names:[n.name],params:G(n.params)}}}}else if(o===`multipleRefPropertyChangeEvent`){if(en(u.key)&&l.comp){let t=i[l.comp];if(t){let n=t.meta.properties?.find(e=>e.id===c);if(n)return{id:e,kind:o,names:[n.name],params:K(n.type)}}}}else if(o===`customSlotEvent`){if(R(u.key)&&l.slot&&t.type===`comp`&&r.meta.slots){let{compId:t,slotId:n,eventId:i}=at(c);if(r.id===t&&l.slot===n){let t=r.meta.slots.find(e=>e.id===n);if(t&&t.events){let n=t.events.find(e=>e.id===i);if(n)return{id:e,kind:o,names:[t.name,n.name],params:G(n.params)}}}}}else if(o===`customSlotPropertyChangeEvent`){if(R(u.key)&&l.slot&&t.type===`comp`&&r.meta.slots){let{compId:t,slotId:n,eventId:i}=at(c);if(r.id===t&&l.slot===n){let t=r.meta.slots.find(e=>e.id===n);if(t&&t.properties){let n=t.properties.find(e=>e.id===i);if(n)return{id:e,kind:o,names:[t.name,n.name],params:K(n.type)}}}}}else if(o===`multipleCustomSlotEvent`){if(z(u.key)&&l.slot&&t.type===`comp`&&r.meta.slots){let{compId:t,slotId:n,eventId:i}=at(c);if(r.id===t&&l.slot&&n){let t=r.meta.slots.find(e=>e.id===n);if(t&&t.events){let n=t.events.find(e=>e.id===i);if(n)return{id:e,kind:o,names:[t.name,n.name],params:G(n.params)}}}}}else if(o===`multipleCustomSlotPropertyChangeEvent`){if(z(u.key)&&l.slot&&t.type===`comp`&&r.meta.slots){let{compId:t,slotId:n,eventId:i}=at(c);if(r.id===t&&l.slot===n){let t=r.meta.slots.find(e=>e.id===n);if(t&&t.properties){let n=t.properties.find(e=>e.id===i);if(n)return{id:e,kind:o,names:[t.name,n.name],params:K(n.type)}}}}}else if(o===`customEvent`){if(L(u.key)&&t.type===`comp`){let t=r.meta.events?.find(e=>e.id===c);if(t)return{id:e,kind:o,names:[t.name],params:G(t.params)}}}else if(o===`customPropertyChangeEvent`){if(L(u.key)&&t.type===`comp`){let t=r.meta.properties?.find(e=>e.id===c);if(t)return{id:e,kind:o,names:[t.name],params:K(t.type)}}}else if(o===`elementAdaptSlotEvent`){if(L(u.key)&&t.type===`comp`&&l.adaptSlot){let{elementKey:t,slotKey:n,eventKey:r}=ot(c);if(tn(l.adaptSlot,t,n)){let i=w(t);if(i&&i.slots){let t=i.slots.find(e=>e.key===n);if(t&&t.events){let n=t.events.find(e=>e.key===r);if(n)return{id:e,kind:o,names:[i.name,t.name,n.name],params:n.params}}}}}}else if(o===`elementAdaptSlotPropertyChangeEvent`){if(L(u.key)&&t.type===`comp`&&l.adaptSlot){let{elementKey:t,slotKey:n,propertyKey:r}=ft(c);if(tn(l.adaptSlot,t,n)){let i=w(t);if(i&&i.slots){let t=i.slots.find(e=>e.key===n);if(t&&t.properties){let n=t.properties.find(e=>e.key===r);if(n)return{id:e,kind:o,names:[i.name,t.name,n.name],params:K(n.type)}}}}}}else if(o===`customAdaptSlotEvent`){if(L(u.key)&&t.type===`comp`&&l.adaptSlot){let{compId:t,slotId:n,eventId:r}=at(c);if(nn(l.adaptSlot,t,n)){let a=i[t];if(a&&a.meta.slots){let t=a.meta.slots.find(e=>e.id===n);if(t&&t.events){let n=t.events.find(e=>e.id===r);if(n)return{id:e,kind:o,names:[a.name,t.name,n.name],params:G(n.params)}}}}}}else if(o===`customAdaptSlotPropertyChangeEvent`){if(L(u.key)&&t.type===`comp`&&l.adaptSlot){let{compId:t,slotId:n,propertyId:r}=dt(c);if(nn(l.adaptSlot,t,n)){let a=i[t];if(a&&a.meta.slots){let t=a.meta.slots.find(e=>e.id===n);if(t&&t.properties){let n=t.properties.find(e=>e.id===r);if(n)return{id:e,kind:o,names:[a.name,t.name,n.name],params:K(n.type)}}}}}}else if(o===`stateChangeEvent`&&L(u.key)){if(t.type===`page`){let t=n.meta.states?.find(e=>e.id===c);if(t)return{id:e,kind:o,names:[t.name],params:K(t.type)}}else if(t.type===`comp`){let t=r.meta.states?.find(e=>e.id===c);if(t)return{id:e,kind:o,names:[t.name],params:K(t.type)}}}}function Yn(e){let t=[],n=qn(e),r;for(let{id:e,kind:i,names:a}of n)i!==r&&(r&&t.push(`separator`),r=i),t.push([tt(i,a),e]);return I(t)}function Xn(e){let{activeObject:t,activeComp:n}=S.app,r=[],i=t.nodes.find(t=>t.id===e);if(!i)return r;let a=w(i.key);if(!a)return console.assert(!1,`invalid element`,i.key),r;if(R(a.key)&&i.slot&&t.type===`comp`&&n.meta.slots){let t=n.meta.slots.find(e=>e.id===i.slot);if(t&&t.events)for(let i of t.events)r.push({id:T(`customSlotEvent`,e,Ue(n.id,t.id,i.id)),kind:`customSlotEvent`,names:[t.name,i.name],params:G(i.params)})}if(z(a.key)&&i.slot&&t.type===`comp`&&n.meta.slots){let t=n.meta.slots.find(e=>e.id===i.slot);if(t&&t.events)for(let i of t.events)r.push({id:T(`multipleCustomSlotEvent`,e,Ue(n.id,t.id,i.id)),kind:`multipleCustomSlotEvent`,names:[t.name,i.name],params:G(i.params)})}if(L(a.key)&&t.type===`comp`&&n.meta.events)for(let e of n.meta.events)r.push({id:T(`customEvent`,`globality`,e.id),kind:`customEvent`,names:[e.name],params:G(e.params)});return r}function Zn(e){if(!e)return;let{activeObject:t,activeComp:n}=S.app,{kind:r,nodeId:i,eventKey:a}=it(e),o=t.nodes.find(e=>e.id===i);if(!o)return;let s=w(o.key);if(!s){console.assert(!1,`invalid element`,o.key);return}if(r===`customSlotEvent`){if(R(s.key)&&o.slot&&t.type===`comp`&&n.meta.slots){let{compId:t,slotId:i,eventId:s}=at(a);if(n.id===t&&o.slot===i){let t=n.meta.slots.find(e=>e.id===i);if(t&&t.events){let n=t.events.find(e=>e.id===s);if(n)return{id:e,kind:r,names:[t.name,n.name],params:G(n.params)}}}}}else if(r===`multipleCustomSlotEvent`){if(z(s.key)&&o.slot&&t.type===`comp`&&n.meta.slots){let{compId:t,slotId:i,eventId:s}=at(a);if(n.id===t&&o.slot&&i){let t=n.meta.slots.find(e=>e.id===i);if(t&&t.events){let n=t.events.find(e=>e.id===s);if(n)return{id:e,kind:r,names:[t.name,n.name],params:G(n.params)}}}}}else if(r===`customEvent`&&L(s.key)&&t.type===`comp`&&n.meta.events){let t=n.meta.events.find(e=>e.id===a);if(t)return{id:e,kind:r,names:[t.name],params:G(t.params)}}}function Qn(e){let t=[],n=Xn(e),r;for(let{id:e,kind:i,names:a}of n)i!==r&&(r&&t.push(`separator`),r=i),t.push([tt(i,a),e]);return I(t)}function q(e){if(!e)return;let t=[];for(let{id:n,name:r,type:i}of e)t.push({key:n,name:r,type:i});return t}function J(e){if(!e)return;let t=[];for(let{id:n,name:r,type:i}of e)t.push({key:n,name:r,type:i});return t}function $n(e){let t=!0;switch(e){case``:break;case`elementMethod`:case`elementSlotMethod`:case`multipeElementSlotMethod`:break;case`refMethod`:case`multipleRefMethod`:t=!1;break;case`customSlotMethod`:case`multipleCustomSlotMethod`:t=!1;break;case`customMethod`:t=!1;break;case`elementAdaptSlotMethod`:break;case`customAdaptSlotMethod`:t=!1;break;default:console.assert(!1,`not implemented kind=${e}`)}return t}function er(e){let{activeObject:t,activeComp:n,depends:r}=S.app,i=[],a=t.nodes.find(t=>t.id===e);if(!a)return i;let o=w(a.key);if(!o)return console.assert(!1,`inavlid element`,a.key),i;if(o.methods)for(let{key:t,name:n,inputs:r,outputs:a}of o.methods)i.push({id:Ge(`elementMethod`,e,t),kind:`elementMethod`,names:[n],inputs:r,outputs:a});if($t(o.key)&&a.comp){let t=r[a.comp];if(t&&t.meta.methods)for(let{id:n,name:r,inputs:a,outputs:o}of t.meta.methods)i.push({id:Ge(`refMethod`,e,n),kind:`refMethod`,names:[r],inputs:q(a),outputs:J(o)})}if(en(o.key)&&a.comp){let t=r[a.comp];if(t&&t.meta.methods)for(let{id:n,name:r,inputs:a,outputs:o}of t.meta.methods)i.push({id:Ge(`multipleRefMethod`,e,n),kind:`multipleRefMethod`,names:[r],inputs:q(a),outputs:J(o)})}if(L(o.key)&&t.type===`comp`&&n.meta.methods)for(let{id:t,name:r,inputs:a,outputs:o}of n.meta.methods)i.push({id:Ge(`customMethod`,e,t),kind:`customMethod`,names:[r],inputs:q(a),outputs:J(o)});if(L(o.key)&&t.type===`comp`&&a.adaptSlot){let{kind:t,mainKey:n,slotKey:o}=pt(a.adaptSlot);if(t===`elementSlot`){let t=w(n);if(t&&t.slots){let n=t.slots.find(e=>e.key===o);if(n&&n.methods)for(let r of n.methods)i.push({id:Ge(`elementAdaptSlotMethod`,e,qe(t.key,n.key,r.key)),kind:`elementAdaptSlotMethod`,names:[t.name,n.name,r.name],inputs:r.inputs,outputs:r.outputs})}}else if(t===`customSlot`){let t=r[n];if(t&&t.meta.slots){let r=t.meta.slots.find(e=>e.id===o);if(r&&r.methods)for(let a of r.methods)i.push({id:Ge(`customAdaptSlotMethod`,e,Ke(n,r.id,a.id)),kind:`customAdaptSlotMethod`,names:[t.name,r.name,a.name],inputs:q(a.inputs),outputs:J(a.outputs)})}}}return i}function tr(e){if(!e)return;let{activeObject:t,activeComp:n,depends:r}=S.app,{kind:i,nodeId:a,methodKey:o}=st(e),s=t.nodes.find(e=>e.id===a);if(!s)return;let c=w(s.key);if(!c){console.assert(!1,`invalid element`,s.key);return}if(i===`elementMethod`){let t=c.methods?.find(e=>e.key===o);if(t)return{id:e,kind:i,names:[t.name],inputs:t.inputs,outputs:t.outputs}}else if(i===`refMethod`){if($t(c.key)&&s.comp){let t=r[s.comp];if(t){let n=t.meta.methods?.find(e=>e.id===o);if(n)return{id:e,kind:i,names:[n.name],inputs:q(n.inputs),outputs:J(n.outputs)}}}}else if(i===`multipleRefMethod`){if(en(c.key)&&s.comp){let t=r[s.comp];if(t){let n=t.meta.methods?.find(e=>e.id===o);if(n)return{id:e,kind:i,names:[n.name],inputs:q(n.inputs),outputs:J(n.outputs)}}}}else if(i===`customMethod`){if(L(c.key)&&t.type===`comp`){let t=n.meta.methods?.find(e=>e.id===o);if(t)return{id:e,kind:i,names:[t.name],inputs:q(t.inputs),outputs:q(t.outputs)}}}else if(i===`customSlotMethod`){if(L(c.key)&&t.type===`comp`&&n.meta.slots){let{slotId:t,methodId:r}=ct(o),a=n.meta.slots.find(e=>e.id===t);if(a&&a.methods){let t=a.methods.find(e=>e.id===r);if(t)return{id:e,kind:i,names:[a.name,t.name],inputs:q(t.inputs),outputs:J(t.outputs)}}}}else if(i===`elementAdaptSlotMethod`){if(L(c.key)&&t.type===`comp`&&s.adaptSlot){let{elementKey:t,slotKey:n,methodKey:r}=lt(o);if(tn(s.adaptSlot,t,n)){let a=w(t);if(a&&a.slots){let t=a.slots.find(e=>e.key===n);if(t&&t.methods){let n=t.methods.find(e=>e.key===r);if(n)return{id:e,kind:i,names:[a.name,t.name,n.name],inputs:n.inputs,outputs:n.outputs}}}}}}else if(i===`customAdaptSlotMethod`&&L(c.key)&&t.type===`comp`&&s.adaptSlot){let{compId:t,slotId:n,methodId:a}=ct(o);if(nn(s.adaptSlot,t,n)){let o=r[t];if(o&&o.meta.slots){let t=o.meta.slots.find(e=>e.id===n);if(t&&t.methods){let n=t.methods.find(e=>e.id===a);if(n)return{id:e,kind:i,names:[o.name,t.name,n.name],inputs:q(n.inputs),outputs:J(n.outputs)}}}}}}function nr(e){let t=[],n=er(e),r;for(let{id:e,kind:i,names:a}of n)i!==r&&(r&&t.push(`separator`),r=i),t.push([nt(i,a),e]);return I(t)}function rr(e){let t=!0;switch(e){case``:break;case`elementMethod`:case`elementSlotMethod`:case`multipeElementSlotMethod`:break;case`refMethod`:case`multipleRefMethod`:t=!1;break;case`customSlotMethod`:case`multipleCustomSlotMethod`:t=!1;break;case`customMethod`:t=!1;break;case`elementAdaptSlotMethod`:break;case`customAdaptSlotMethod`:t=!1;break;default:console.assert(!1,`not implemented kind=${e}`)}return t}function ir(e){let{activeObject:t,activeComp:n}=S.app,r=[],i=t.nodes.find(t=>t.id===e);if(!i)return r;let a=w(i.key);if(!a)return console.assert(!1,`inavlid element`,i.key),r;if(R(a.key)&&i.slot&&t.type===`comp`&&n.meta.slots){let t=n.meta.slots.find(e=>e.id===i.slot);if(t&&t.methods)for(let i of t.methods)r.push({id:Ge(`customSlotMethod`,e,Ke(n.id,t.id,i.id)),kind:`customSlotMethod`,names:[t.name,i.name],inputs:q(i.inputs),outputs:q(i.outputs)})}if(z(a.key)&&i.slot&&t.type===`comp`&&n.meta.slots){let t=n.meta.slots.find(e=>e.id===i.slot);if(t&&t.methods)for(let i of t.methods)r.push({id:Ge(`multipleCustomSlotMethod`,e,Ke(n.id,t.id,i.id)),kind:`multipleCustomSlotMethod`,names:[t.name,i.name],inputs:q(i.inputs),outputs:J(i.outputs)})}if(L(a.key)&&t.type===`comp`&&n.meta.methods)for(let{id:t,name:i,inputs:a,outputs:o}of n.meta.methods)r.push({id:Ge(`customMethod`,e,t),kind:`customMethod`,names:[i],inputs:q(a),outputs:J(o)});return r}function ar(e){if(!e)return;let{activeObject:t,activeComp:n}=S.app,{kind:r,nodeId:i,methodKey:a}=st(e),o=t.nodes.find(e=>e.id===i);if(!o)return;let s=w(o.key);if(!s){console.assert(!1,`invalid element`,o.key);return}if(r===`customSlotMethod`){if(R(s.key)&&o.slot&&t.type===`comp`&&n.meta.slots){let{compId:t,slotId:i,methodId:s}=ct(a);if(n.id===t&&i===o.slot){let t=n.meta.slots.find(e=>e.id===i);if(t&&t.methods){let n=t.methods.find(e=>e.id===s);if(n)return{id:e,kind:r,names:[t.name,n.name],inputs:q(n.inputs),outputs:J(n.outputs)}}}}}else if(r===`multipleCustomSlotMethod`){if(z(s.key)&&o.slot&&t.type===`comp`&&n.meta.slots){let{compId:t,slotId:i,methodId:s}=ct(a);if(n.id===t&&o.slot===i){let t=n.meta.slots.find(e=>e.id===i);if(t&&t.methods){let n=t.methods.find(e=>e.id===s);if(n)return{id:e,kind:r,names:[t.name,n.name],inputs:q(n.inputs),outputs:J(n.outputs)}}}}}else if(r===`customMethod`&&L(s.key)&&t.type===`comp`&&n.meta.methods){let t=n.meta.methods.find(e=>e.id===a);if(t)return{id:e,kind:r,names:[t.name],inputs:q(t.inputs),outputs:J(t.outputs)}}}function or(e){let t=[],n=ir(e),r;for(let{id:e,kind:i,names:a}of n)i!==r&&(r&&t.push(`separator`),r=i),t.push([nt(i,a),e]);return I(t)}function sr(e){let t=ar(e);return t?t.outputs:[]}function cr(e,t){let n=ar(e);if(n)return n.outputs?.find(e=>e.key===t)}function lr(e){let t=[],n=sr(e);if(n)for(let{name:e,key:r}of n)t.push([e,r]);return I(t)}function ur(e){let{appList:t}=S.app,n=[],r=t.find(t=>t.id===e);if(!r)return n;for(let{id:e,name:t}of r.pages)n.push({id:e,name:t});return n}function dr(e,t){let{appList:n}=S.app,r=n.find(t=>t.id===e);if(!r)return;let i=r.pages.find(e=>e.id===t);if(i)return{id:i.id,name:i.name}}function fr(e){let t=[];return ur(e).forEach(({id:e,name:n})=>{t.push([n,e])}),I(t)}function pr(e,t){let{activeObject:n,activeComp:r,depends:i}=S.app,a=[],o=Ve(n.type,n.subtype),s=n.nodes.find(t=>t.id===e);if(!s)return a;let c=w(s.key);if(!c)return console.assert(!1,`invalid element`,s.key),a;if(C[c.key]&&C[c.key][o])for(let{keys:n,names:r,raw:i}of C[c.key][o])t===`write`&&Qt(n,i)||a.push({id:Je(`elementProperty`,e,n),kind:`elementProperty`,names:r,meta:{element:!0,raw:i}});if($t(c.key)&&s.comp){let t=i[s.comp];if(t&&t.meta.properties)for(let{id:n,name:r,type:i}of t.meta.properties)a.push({id:Je(`refProperty`,e,n),kind:`refProperty`,names:[r],meta:{raw:{type:i}}})}if(en(c.key)&&s.comp){let t=i[s.comp];if(t&&t.meta.properties)for(let{id:n,name:r,type:i}of t.meta.properties)a.push({id:Je(`multipleRefProperty`,e,n),kind:`multipleRefProperty`,names:[r],meta:{raw:{type:i}}})}if(R(c.key)&&s.slot&&n.type===`comp`&&r.meta.slots){let t=r.meta.slots.find(e=>e.id===s.slot);if(t&&t.properties)for(let n of t.properties)a.push({id:Je(`customSlotProperty`,e,Ye(r.id,t.id,n.id)),kind:`customSlotProperty`,names:[t.name,n.name],meta:{raw:{type:n.type}}})}if(z(c.key)&&s.slot&&n.type===`comp`&&r.meta.slots){let t=r.meta.slots.find(e=>e.id===s.slot);if(t&&t.properties)for(let n of t.properties)a.push({id:Je(`multipleCustomSlotProperty`,e,Ye(r.id,t.id,n.id)),kind:`multipleCustomSlotProperty`,names:[t.name,n.name],meta:{raw:{type:n.type}}})}if(L(c.key)&&n.type===`comp`&&r.meta.properties)for(let{id:t,name:n,type:i}of r.meta.properties)a.push({id:Je(`customProperty`,e,t),kind:`customProperty`,names:[n],meta:{raw:{type:i}}});if(L(c.key)&&n.type===`comp`&&s.adaptSlot){let{kind:n,mainKey:r,slotKey:o}=pt(s.adaptSlot);if(n===`elementSlot`){let n=w(r);if(n&&n.slots){let r=n.slots.find(e=>e.key===o);if(r&&r.properties)for(let i of r.properties)t===`write`&&i.readonly||a.push({id:Je(`elementAdaptSlotProperty`,e,Xe(n.key,r.key,i.key)),kind:`elementAdaptSlotProperty`,names:[n.name,r.name,i.name],meta:{raw:{type:i.type}}})}}else if(n===`customSlot`){let t=i[r];if(t&&t.meta.slots){let n=t.meta.slots.find(e=>e.id===o);if(n&&n.properties)for(let i of n.properties)a.push({id:Je(`customAdaptSlotProperty`,e,Ye(r,n.id,i.id)),kind:`customAdaptSlotProperty`,names:[t.name,n.name,i.name],meta:{raw:{type:i.type}}})}}}return a}function mr(e){if(!e)return;let{activeObject:t,activeComp:n,depends:r}=S.app,i=Ve(t.type,t.subtype),{kind:a,nodeId:o,propertyKey:s}=ut(e),c=t.nodes.find(e=>e.id===o);if(!c)return;let l=w(c.key);if(!l){console.assert(!1,`invalid element`,c.key);return}if(a===`elementProperty`){if(C[l.key]&&C[l.key][i]){let t=C[l.key][i].find(e=>e.keys===s);if(t)return{id:e,kind:a,names:t.names,meta:{element:!0,raw:t.raw}}}}else if(a===`refProperty`){if($t(l.key)&&c.comp){let t=r[c.comp];if(t){let n=t.meta.properties?.find(e=>e.id===s);if(n)return{id:e,kind:a,names:[n.name],meta:{raw:{type:n.type}}}}}}else if(a===`multipleRefProperty`){if(en(l.key)&&c.comp){let t=r[c.comp];if(t){let n=t.meta.properties?.find(e=>e.id===s);if(n)return{id:e,kind:a,names:[n.name],meta:{raw:{type:n.type}}}}}}else if(a===`customSlotProperty`){if(R(l.key)&&c.slot&&t.type===`comp`&&n.meta.slots){let{compId:t,slotId:r,propertyId:i}=dt(s);if(n.id===t&&c.slot===r){let t=n.meta.slots.find(e=>e.id===r);if(t&&t.properties){let n=t.properties.find(e=>e.id===i);if(n)return{id:e,kind:a,names:[t.name,n.name],meta:{raw:{type:n.type}}}}}}}else if(a===`multipleCustomSlotProperty`){if(z(l.key)&&c.slot&&t.type===`comp`&&n.meta.slots){let{compId:t,slotId:r,propertyId:i}=dt(s);if(n.id===t&&c.slot===r){let t=n.meta.slots.find(e=>e.id===r);if(t&&t.properties){let n=t.properties.find(e=>e.id===i);if(n)return{id:e,kind:a,names:[t.name,n.name],meta:{raw:{type:n.type}}}}}}}else if(a===`customProperty`){if(L(l.key)&&t.type===`comp`){let t=n.meta.properties?.find(e=>e.id===s);if(t)return{id:e,kind:a,names:[t.name],meta:{raw:{type:t.type}}}}}else if(a===`elementAdaptSlotProperty`){if(L(l.key)&&t.type===`comp`&&c.adaptSlot){let{elementKey:t,slotKey:n,propertyKey:r}=ft(s);if(tn(c.adaptSlot,t,n)){let i=w(t);if(i&&i.slots){let t=i.slots.find(e=>e.key===n);if(t&&t.properties){let n=t.properties.find(e=>e.key===r);if(n)return{id:e,kind:a,names:[i.name,t.name,n.name],meta:{raw:{type:n.type}}}}}}}}else if(a===`customAdaptSlotProperty`&&L(l.key)&&t.type===`comp`&&c.adaptSlot){let{compId:t,slotId:n,propertyId:i}=dt(s);if(nn(c.adaptSlot,t,n)){let o=r[t];if(o&&o.meta.slots){let t=o.meta.slots.find(e=>e.id===n);if(t&&t.properties){let n=t.properties.find(e=>e.id===i);if(n)return{id:e,kind:a,names:[o.name,t.name,n.name],meta:{raw:{type:n.type}}}}}}}}function hr(e,t){let n=[],r=pr(e,t),i;for(let{id:e,kind:t,names:a}of r)t!==i&&(i&&n.push(`separator`),i=t),n.push([rt(t,a),e]);return I(n)}function gr(){let{activeObject:e,activeComp:t}=S.app,n=[{id:``,name:``}];if(e.type!==`comp`||!t.meta.slots)return n;for(let{id:e,name:r}of t.meta.slots)n.push({id:e,name:r});return n}function _r(e){let{activeObject:t,activeComp:n}=S.app;if(t.type!==`comp`||!n.meta.slots)return;if(!e)return{id:``,name:``};let r=n.meta.slots.find(t=>t.id===e);if(r)return{id:r.id,name:r.name}}function vr(){let{i18n:e}=je,t=[],n=gr();for(let{id:r,name:i}of n){let n=i;r===``&&(n=e.global.t(`x-runtime-lib.notSet`)),t.push([n,r])}return I(t)}y.app_bind_entry_v1={init:function(){this.kind=`notSet`,this.node={id:``,key:``,alias:``},this.property={id:``,kind:``,names:[]},this.state={id:``,name:``,type:`string`},this.appendDummyInput().appendField(new b(()=>this.genKindOpts_()),`KIND`).appendField(new b(()=>this.genNodeOpts_()),`NODE`).appendField(new b(()=>this.genPropertyOpts_()),`PROPERTY`).appendField(new b(()=>this.genStateOpts_()),`STATE`),this.setOutput(!0,`BindEntry`),this.updateShape_()},saveExtraState:function(){return{kind:this.kind,node:this.node,property:this.property,state:this.state}},loadExtraState:function(e){this.kind=e.kind??`notSet`,this.node.id=e.node?.id??``,this.node.key=e.node?.key??``,this.node.alias=e.node?.alias??``,this.property.id=e.property?.id??``,this.property.kind=e.property?.kind??``,this.property.names=e.property?.names??[],this.state.id=e.state?.id??``,this.state.name=e.state?.name??``,this.state.type=e.state?.type??`string`,this.updateShape_(),setTimeout(()=>{this.checkWarning_()},0)},genKindOpts_:function(){return Hn()},genNodeOpts_:function(){return this.kind===`property`?Ln(`setProperty`):I([])},genPropertyOpts_:function(){return this.kind===`property`?hr(this.node.id,`write`):I([])},genStateOpts_:function(){return this.kind===`state`?Bn():I([])},onchange:function(e){if(e.type===x.BLOCK_CHANGE){let t=e;t.blockId===this.id&&(t.element===`field`&&(t.name===`KIND`?this.onKindChange_(t.newValue):t.name===`NODE`?this.onNodeChange_(t.newValue):t.name===`PROPERTY`?this.onPropertyChange_(t.newValue):t.name===`STATE`&&this.onStateChange_(t.newValue)),setTimeout(()=>{this.checkWarning_()}))}},onKindChange_:function(e){let t=this.kind!==e;if(this.kind=e,this.kind===`notSet`)this.updateShape_();else if(this.kind===`property`){let e=this.getField(`NODE`);if(e.getOptions(!1),t){let t=In(`setProperty`)?.[0];e.setValue(t?.id??``)}this.onNodeChange_(e.getValue())}else if(this.kind===`state`){let e=this.getField(`STATE`);if(e.getOptions(!1),t){let t=Rn()?.[0];e.setValue(t?.id??``)}this.onStateChange_(e.getValue())}},onNodeChange_:function(e){let t=W(e);if(!t){console.assert(!1);return}let n=this.node?.id!==t.id;this.node.id=t.id,this.node.key=t.key,this.node.alias=t.alias;let r=this.getField(`PROPERTY`);if(r.getOptions(!1),n){let e=pr(this.node.id,`write`)?.[0];r.setValue(e?.id??``)}this.onPropertyChange_(r.getValue())},onPropertyChange_:function(e){let t=mr(e);if(!t){console.assert(!1);return}this.property.id=t.id,this.property.kind=t.kind,this.property.names=t.names,this.updateShape_()},onStateChange_:function(e){let t=zn(e);if(!t){console.assert(!1);return}this.state.id=t.id,this.state.name=t.name,this.state.type=t.type,this.updateShape_()},updateShape_:function(){this.kind===`notSet`?(this.setStyle(`event_blocks`),this.getField(`NODE`).setVisible(!1),this.getField(`PROPERTY`).setVisible(!1),this.getField(`STATE`).setVisible(!1)):this.kind===`property`?(this.setStyle(`property_blocks`),this.getField(`NODE`).setVisible(!0),this.getField(`PROPERTY`).setVisible(!0),this.getField(`STATE`).setVisible(!1)):this.kind===`state`&&(this.setStyle(`state_blocks`),this.getField(`NODE`).setVisible(!1),this.getField(`PROPERTY`).setVisible(!1),this.getField(`STATE`).setVisible(!0)),setTimeout(()=>{this.render()},0)},checkWarning_:function(){if(this.kind===`property`){let e=W(this.node.id);if(!e){this.setWarningText(F(`WARN_NODE_NOT_FOUND`));return}if(e.key!==this.node.key){this.setWarningText(F(`WARN_NODE_HAS_CHANGED`));return}e.alias!==this.node.alias&&(this.node.alias=e.alias);let t=mr(this.property.id);if(!t){this.setWarningText(F(`WARN_PROPERTY_NOT_FOUND`));return}if(t.kind!==this.property.kind){this.setWarningText(F(`WARN_PROPERTY_HAS_CHANGED`));return}v(t.names,this.property.names)||(this.property.names=t.names)}else if(this.kind===`state`){let e=zn(this.state.id);if(!e){this.setWarningText(F(`WARN_STATE_NOT_FOUND`));return}if(e.name!==this.state.name&&(this.state.name=e.name),e.type!==this.state.type){this.setWarningText(F(`WARN_STATE_HAS_CHANGED`));return}}this.setWarningText(null)}},g.forBlock.app_bind_entry_v1=function(){return``};const yr=p.xml;y.app_bind_container_v1={init:function(){this.appendDummyInput().appendField(`%{BKY_APP_V1_APP_BIND_CONTAINER_TITLE}`),this.appendStatementInput(`STACK`),this.setStyle(`event_blocks`),this.contextMenu=!1}},y.app_bind_item_v1={init:function(){this.appendDummyInput().appendField(`%{BKY_APP_V1_APP_BIND_ITEM_TITLE}`),this.setPreviousStatement(!0),this.setNextStatement(!0),this.setStyle(`event_blocks`),this.contextMenu=!1}},y.app_bind_v1={init:function(){this.itemCount_=0,this.setMutator(new oe.MutatorIcon([`app_bind_item_v1`],this)),this.debounce_=be(()=>{this.checkWarning_()},250),this.setStyle(`event_blocks`),this.setTooltip(`%{BKY_APP_V1_APP_BIND_TOOLTIP}`),this.setHelpUrl(`%{BKY_APP_V1_APP_BIND_HELPURL}`)},mutationToDom:function(){let e=yr.createElement(`mutation`);return e.setAttribute(`items`,String(this.itemCount_)),e},domToMutation:function(e){let t=e.getAttribute(`items`)??``;this.itemCount_=parseInt(t,0),this.updateShape_(),this.updateShadow_(),setTimeout(()=>{this.checkWarning_()},0)},saveExtraState:function(){return{itemCount:this.itemCount_}},loadExtraState:function(e){this.itemCount_=e.itemCount??0,this.updateShape_(),this.updateShadow_(),setTimeout(()=>{this.checkWarning_()},0)},decompose:function(e){let t=e.newBlock(`app_bind_container_v1`);t.initSvg();let n=t.getInput(`STACK`).connection;for(let t=0;t<this.itemCount_;t++){let t=e.newBlock(`app_bind_item_v1`);t.initSvg(),n.connect(t.previousConnection),n=t.nextConnection}return t},compose:function(e){let t=e.getInputTargetBlock(`STACK`),n=[];for(;t;){if(t.isInsertionMarker()){t=t.getNextBlock();continue}n.push(t.valueConnection_),t=t.getNextBlock()}for(let e=0;e<this.itemCount_;e++){this.getInput(`ADD`+e).setShadowDom(null);let t=this.getInput(`ADD`+e).connection.targetConnection;t&&!n.includes(t)&&t.disconnect()}this.itemCount_=n.length,this.updateShape_();for(let e=0;e<this.itemCount_;e++)n[e]?.reconnect(this,`ADD`+e);this.updateShadow_(),setTimeout(()=>{this.checkWarning_()},0)},saveConnections:function(e){let t=e.getInputTargetBlock(`STACK`),n=0;for(;t;){if(t.isInsertionMarker()){t=t.getNextBlock();continue}let e=this.getInput(`ADD`+n);t.valueConnection_=e?.connection.targetConnection,t=t.getNextBlock(),n++}},onchange:function(){this.debounce_()},updateShape_:function(){this.itemCount_&&this.getInput(`EMPTY`)?this.removeInput(`EMPTY`):!this.itemCount_&&!this.getInput(`EMPTY`)&&this.appendDummyInput(`EMPTY`).appendField(`%{BKY_APP_V1_APP_BIND_TITLE}`);for(let e=0;e<this.itemCount_;e++)this.getInput(`ADD`+e)||(this.appendValueInput(`ADD`+e).setCheck(`BindEntry`),e===0&&this.getInput(`ADD`+e).setAlign(u.Align.RIGHT).appendField(`%{BKY_APP_V1_APP_BIND_TITLE}`));for(let e=this.itemCount_;this.getInput(`ADD`+e);e++)this.removeInput(`ADD`+e)},updateShadow_:function(){if(!this.isInsertionMarker())for(let e=0;e<this.itemCount_;e++)this.getInput(`ADD`+e).setShadowDom(bn())},checkWarning_:function(){let e;for(let t=0;t<this.itemCount_;t++){let n=this.getInput(`ADD`+t)?.connection?.targetBlock();if(!n)continue;let r;if(n.kind===`property`){let e=mr(n.property.id);e&&(r=e.meta.element?rn(e.meta.raw):B(e.meta.raw.type))}else if(n.kind===`state`){let e=zn(n.state.id);e&&(r=B(e.type))}if(r&&(e||(e=r),r!==e)){this.setWarningText(F(`WARN_TYPE_NOT_MATCH`));return}}this.setWarningText(null)}},g.forBlock.app_bind_v1=function(){return``},y.on_app_event_v1={init:function(){this.node={id:``,key:``,alias:``},this.event={id:``,kind:``,names:[]},this.appendDummyInput().appendField(`%{BKY_APP_V1_ON_APP_EVENT_TITLE}`).appendField(new b(()=>this.genNodeOpts_()),`NODE`).appendField(new b(()=>this.genEventOpts_()),`EVENT`),this.appendStatementInput(`HANDLE`).appendField(`%{BKY_APP_DO}`),this.setStyle(`event_blocks`),this.setTooltip(`%{BKY_APP_V1_ON_APP_EVENT_TOOLTIP}`),this.setHelpUrl(`%{BKY_APP_V1_ON_APP_EVENT_HELPURL}`),this.initData_()},initData_:function(){if(this.node.id)return;let e=In(`onEvent`)?.[0];if(!e)return;this.node.id=e.id,this.node.key=e.key,this.node.alias=e.alias;let t=this.getField(`NODE`);t.getOptions(!1),t.setValue(this.node.id);let n=qn(this.node.id)?.[0];if(!n)return;this.event.id=n.id,this.event.kind=n.kind,this.event.names=n.names,this.event.params=n.params;let r=this.getField(`EVENT`);r.getOptions(!1),r.setValue(this.event.id)},saveExtraState:function(){return{node:this.node,event:this.event}},loadExtraState:function(e){this.node.id=e.node?.id??``,this.node.key=e.node?.key??``,this.node.alias=e.node?.alias??``,this.event.id=e.event?.id??``,this.event.kind=e.event?.kind??``,this.event.names=e.event?.names??[],this.event.params=e.event?.params,this.updateShape_(),setTimeout(()=>{this.ensureBlocks_(),this.checkWarning_()},0)},genNodeOpts_:function(){return Ln(`onEvent`)},genEventOpts_:function(){return Yn(this.node.id)},onchange:function(e){if(e.type===x.BLOCK_CHANGE){let t=e;t.blockId===this.id&&(t.element===`field`&&(t.name===`NODE`?this.onNodeChange_(t.newValue):t.name===`EVENT`&&this.onEventChange_(t.newValue)),setTimeout(()=>{this.checkWarning_()},0))}},onNodeChange_:function(e){let t=W(e);if(!t){console.assert(!1);return}let n=this.node.id!==t.id;this.node.id=t.id,this.node.key=t.key,this.node.alias=t.alias;let r=this.getField(`EVENT`);if(r.getOptions(!1),n){let e=qn(this.node.id)?.[0];r.setValue(e?.id??``)}this.onEventChange_(r.getValue())},onEventChange_:function(e){let t=Jn(e);if(!t){console.assert(!1);return}this.event.id=t.id,this.event.kind=t.kind,this.event.names=t.names,this.event.params=t.params,this.updateShape_(),setTimeout(()=>{this.ensureBlocks_()},0)},updateShape_:function(){for(let e=this.event.params?.length??0;this.getInput(`PARAM`+e);e++){let t=this.getInput(`PARAM`+e).connection.targetBlock();t&&t.dispose(),this.removeInput(`PARAM`+e)}if(this.event.params)for(let e=0;e<this.event.params.length;e++)this.getInput(`PARAM`+e)||(this.appendValueInput(`PARAM`+e),this.moveInputBefore(`PARAM`+e,`HANDLE`));let e=!1;switch(this.event.kind){case`multipleRefEvent`:case`multipleRefPropertyChangeEvent`:case`multipleCustomSlotEvent`:case`multipleCustomSlotPropertyChangeEvent`:e=!0}if(e)this.getInput(`INSTANCE`)||this.appendValueInput(`INSTANCE`).setCheck(`String`),this.event.params&&this.event.params.length>0?this.moveInputBefore(`INSTANCE`,`PARAM0`):this.moveInputBefore(`INSTANCE`,`HANDLE`);else if(this.getInput(`INSTANCE`)){let e=this.getInput(`INSTANCE`).connection.targetBlock();e&&e.dispose(),this.removeInput(`INSTANCE`)}},ensureBlocks_:function(){if(this.isInsertionMarker())return;let e=[];this.getInput(`INSTANCE`)&&e.push([`INSTANCE`,`__instance__`,`x-runtime-lib.instance`,!0]);let t=Kn(this.event.kind);if(this.event.params)for(let n=0;n<this.event.params.length;n++){let{key:r,name:i}=this.event.params[n];e.push([`PARAM`+n,`__param$${r}__`,i,t])}e.length>0&&V(this,e)},checkWarning_:function(){let e=W(this.node.id);if(!e){this.setWarningText(F(`WARN_NODE_NOT_FOUND`));return}if(e.key!==this.node.key){this.setWarningText(F(`WARN_NODE_HAS_CHANGED`));return}e.alias!==this.node.alias&&(this.node.alias=e.alias);let t=Jn(this.event.id);if(!t){this.setWarningText(F(`WARN_EVENT_NOT_FOUND`));return}if(t.kind!==this.event.kind){this.setWarningText(F(`WARN_EVENT_HAS_CHANGED`));return}if(v(t.names,this.event.names)||(this.event.names=t.names),!v(t.params,this.event.params)){this.setWarningText(F(`WARN_EVENT_HAS_CHANGED`));return}this.setWarningText(null)}},g.forBlock.on_app_event_v1=function(e){let t=g.quote_,n=e,r=``;if(n.event.params)for(let e=0;e<n.event.params.length;e++){let t=n.event.params[e];r+=`const __param$${t.key}__ = __params__[${e}];\n`}let i=g.statementToCode(n,`HANDLE`);return`__onEventV1__(${t(n.event.id)}, async (__params__, __instance__) => {
9
9
  try {
10
- ${Le(r,4)}${Le(i,2)} } catch (e) {
10
+ ${Re(r,4)}${Re(i,2)} } catch (e) {
11
11
  __messageV1__('error', e);
12
12
  }
13
13
  });
14
- `},S.trigger_app_event_v1={init:function(){this.node={id:``,key:``,alias:``},this.event={id:``,kind:``,names:[]},this.appendDummyInput().appendField(`%{BKY_APP_V1_TRIGGER_APP_EVENT_TITLE}`).appendField(new m(()=>this.genNodeOpts_()),`NODE`).appendField(new m(()=>this.genEventOpts_()),`EVENT`),this.setPreviousStatement(!0,null),this.setNextStatement(!0,null),this.setStyle(`event_blocks`),this.setTooltip(`%{BKY_APP_V1_TRIGGER_APP_EVENT_TOOLTIP}`),this.setHelpUrl(`%{BKY_APP_V1_TRIGGER_APP_EVENT_HELPURL}`),this.initData_()},initData_:function(){if(this.node.id)return;let e=In(`triggerEvent`)?.[0];if(!e)return;this.node.id=e.id,this.node.key=e.key,this.node.alias=e.alias;let t=this.getField(`NODE`);t.getOptions(!1),t.setValue(this.node.id);let n=Xn(this.node.id)?.[0];if(!n)return;this.event.id=n.id,this.event.kind=n.kind,this.event.names=n.names,this.event.params=n.params;let r=this.getField(`EVENT`);r.getOptions(!1),r.setValue(this.event.id)},saveExtraState:function(){return{node:this.node,event:this.event}},loadExtraState:function(e){this.node.id=e.node?.id??``,this.node.key=e.node?.key??``,this.node.alias=e.node?.alias??``,this.event.id=e.event?.id??``,this.event.kind=e.event?.kind??``,this.event.names=e.event?.names??[],this.event.params=e.event?.params,this.updateShape_(),this.updateShadows_(),setTimeout(()=>{this.checkWarning_()},0)},genNodeOpts_:function(){return Ln(`triggerEvent`)},genEventOpts_:function(){return Qn(this.node.id)},onchange:function(e){if(e.type===p.BLOCK_CHANGE){let t=e;t.blockId===this.id&&(t.element===`field`&&(t.name===`NODE`?this.onNodeChange_(t.newValue):t.name===`EVENT`&&this.onEventChange_(t.newValue)),setTimeout(()=>{this.checkWarning_()},0))}},onNodeChange_:function(e){let t=W(e);if(!t){console.assert(!1);return}let n=this.node.id!==t.id;this.node.id=t.id,this.node.key=t.key,this.node.alias=t.alias;let r=this.getField(`EVENT`);if(r.getOptions(!1),n){let e=Xn(this.node.id)?.[0];r.setValue(e?.id??``)}this.onEventChange_(r.getValue())},onEventChange_:function(e){let t=Zn(e);if(!t){console.assert(!1);return}this.event.id=t.id,this.event.kind=t.kind,this.event.names=t.names,this.event.params=t.params,this.updateShape_(),this.updateShadows_()},updateShape_:function(){for(let e=this.event.params?.length??0;this.getInput(`PARAM`+e);e++){let t=this.getInput(`PARAM`+e)?.connection?.targetBlock();t&&t.dispose(),this.removeInput(`PARAM`+e)}if(this.event.params){for(let e=0;e<this.event.params.length;e++)this.getInput(`PARAM`+e)||this.appendValueInput(`PARAM`+e);for(let e=0;e<this.event.params.length;e++){let{type:t}=this.event.params[e],n=this.getInput(`PARAM`+e);n.connection.setShadowDom(null);let r=n.connection.targetBlock();r&&!r.isShadow()&&r.dispose(),n.setCheck(B(t))}}let e=!1;switch(this.event.kind){case`multipleRefEvent`:case`multipleRefPropertyChangeEvent`:case`multipleCustomSlotEvent`:case`multipleCustomSlotPropertyChangeEvent`:e=!0}if(e)this.getInput(`INSTANCE`)||this.appendValueInput(`INSTANCE`).setAlign(b.Align.RIGHT).appendField(`%{BKY_APP_INSTANCE}`).setCheck(`String`),this.event.params&&this.event.params.length>0&&this.moveInputBefore(`INSTANCE`,`PARAM0`);else if(this.getInput(`INSTANCE`)){let e=this.getInput(`INSTANCE`).connection.targetBlock();e&&e.dispose(),this.removeInput(`INSTANCE`)}},updateShadows_:function(){if(!this.isInsertionMarker()){if(this.getInput(`INSTANCE`)){let e=H(`string`);this.getInput(`INSTANCE`).setShadowDom(e)}if(this.event.params)for(let e=0;e<this.event.params.length;e++){let t=this.event.params[e],n=H(t.type);this.getInput(`PARAM`+e).connection.setShadowDom(n)}}},checkWarning_:function(){let e=W(this.node.id);if(!e){this.setWarningText(F(`WARN_NODE_NOT_FOUND`));return}if(e.key!==this.node.key){this.setWarningText(F(`WARN_NODE_HAS_CHANGED`));return}e.alias!==this.node.alias&&(this.node.alias=e.alias);let t=Zn(this.event.id);if(!t){this.setWarningText(F(`WARN_EVENT_NOT_FOUND`));return}if(t.kind!==this.event.kind){this.setWarningText(F(`WARN_EVENT_HAS_CHANGED`));return}if(y(t.names,this.event.names)||(this.event.names=t.names),!y(t.params,this.event.params)){this.setWarningText(F(`WARN_EVENT_HAS_CHANGED`));return}this.setWarningText(null)}},x.forBlock.trigger_app_event_v1=function(e){let t=x.quote_,n=e,r=`[`;if(n.event.params)for(let e=0;e<n.event.params.length;e++){let t=x.valueToCode(n,`PARAM`+e,_.NONE);e!==0&&(r+=`, `),r+=t}r+=`]`;let i=`''`;return n.getInput(`INSTANCE`)&&(i=x.valueToCode(n,`INSTANCE`,_.NONE)||`''`),`await __triggerEventV1__(${t(n.event.id)}, ${r}, ${i});\n`},h([{type:`watch_effect_v1`,message0:`%{BKY_APP_V1_WATCH_EFFECT_TITLE}`,args0:[{type:`input_dummy`},{type:`input_statement`,name:`HANDLE`}],style:`event_blocks`,tooltip:`%{BKY_APP_V1_WATCH_EFFECT_TOOLTIP}`,helpUrl:`%{BKY_APP_V1_WATCH_EFFECT_HELPURL}`}]),x.forBlock.watch_effect_v1=function(e){return`async function __watchEffect$${ye(e.id)}__() {
15
- ${x.statementToCode(e,`HANDLE`)}};
16
- `},h([{type:`app_debug_trace_v1`,message0:`%{BKY_APP_V1_APP_DEBUG_TRACE_TITLE}`,args0:[{type:`input_value`,name:`OBJECT`}],previousStatement:null,nextStatement:null,style:`procedure_blocks`,tooltip:`%{BKY_APP_V1_APP_DEBUG_TRACE_TOOLTIP}`,helpUrl:`%{BKY_APP_V1_APP_DEBUG_TRACE_HELPURL}`}]),x.forBlock.app_debug_trace_v1=function(e){return`__debugTraceV1__(${x.valueToCode(e,`OBJECT`,_.NONE)});\n`},S.open_confirm_dlg_v1={init:function(){this.appendDummyInput().appendField(`%{BKY_APP_V1_OPEN_CONFIRM_DLG_TITLE}`),this.setPreviousStatement(!0,null),this.setNextStatement(!0,null),this.setStyle(`procedure_blocks`),this.setTooltip(`%{BKY_APP_V1_OPEN_CONFIRM_DLG_TOOLTIP}`),this.setHelpUrl(`%{BKY_APP_V1_OPEN_CONFIRM_DLG_HELPURL}`)},saveExtraState:function(){return{}},loadExtraState:function(){this.updateShape_(),this.updateShadow_(),setTimeout(()=>{this.ensureBlocks_()},0)},updateShape_:function(){this.getInput(`HANDLE`)||this.appendStatementInput(`HANDLE`).appendField(`%{BKY_APP_DO}`),this.getInput(`RESULT`)||(this.appendValueInput(`RESULT`).appendField(`%{BKY_APP_RETURN}`),this.moveInputBefore(`RESULT`,`HANDLE`)),this.getInput(`TEXT`)||(this.appendValueInput(`TEXT`).setCheck(`String`).setAlign(b.Align.RIGHT).appendField(`%{BKY_APP_TEXT}`),this.moveInputBefore(`TEXT`,`RESULT`)),this.getInput(`TITLE`)||(this.appendValueInput(`TITLE`).setCheck(`String`).setAlign(b.Align.RIGHT).appendField(`%{BKY_APP_TITLE}`),this.moveInputBefore(`TITLE`,`TEXT`))},updateShadow_:function(){if(this.isInsertionMarker())return;let e=dn(`title`);this.getInput(`TITLE`).connection.setShadowDom(e);let t=dn(`text`);this.getInput(`TEXT`).connection.setShadowDom(t)},ensureBlocks_:function(){this.isInsertionMarker()||V(this,[[`RESULT`,`__result__`,`x-runtime-lib.result`,!0]])}},x.forBlock.open_confirm_dlg_v1=function(e){return`{
17
- var __result__ = await __openConfirmDlgV1__(${x.valueToCode(e,`TITLE`,_.ATOMIC)}, ${x.valueToCode(e,`TEXT`,_.ATOMIC)});
18
- ${x.statementToCode(e,`HANDLE`)}}
19
- `},S.open_prompt_dlg_v1={init:function(){this.appendDummyInput().appendField(`%{BKY_APP_V1_OPEN_PROMPT_DLG_TITLE}`),this.setPreviousStatement(!0,null),this.setNextStatement(!0,null),this.setStyle(`procedure_blocks`),this.setTooltip(`%{BKY_APP_V1_OPEN_PROMPT_DLG_TOOLTIP}`),this.setHelpUrl(`%{BKY_APP_V1_OPEN_PROMPT_DLG_HELPURL}`)},saveExtraState:function(){return{}},loadExtraState:function(){this.updateShape_(),this.updateShadow_(),setTimeout(()=>{this.ensureBlocks_()},0)},updateShape_:function(){this.getInput(`HANDLE`)||this.appendStatementInput(`HANDLE`).appendField(`%{BKY_APP_DO}`),this.getInput(`RESULT`)||(this.appendValueInput(`RESULT`).appendField(`%{BKY_APP_RETURN}`),this.moveInputBefore(`RESULT`,`HANDLE`)),this.getInput(`VALUE`)||(this.appendValueInput(`VALUE`).setCheck(`String`).setAlign(b.Align.RIGHT).appendField(`%{BKY_APP_VALUE}`),this.moveInputBefore(`VALUE`,`RESULT`)),this.getInput(`LABEL`)||(this.appendValueInput(`LABEL`).setCheck(`String`).setAlign(b.Align.RIGHT).appendField(`%{BKY_APP_LABEL}`),this.moveInputBefore(`LABEL`,`VALUE`)),this.getInput(`TITLE`)||(this.appendValueInput(`TITLE`).setCheck(`String`).setAlign(b.Align.RIGHT).appendField(`%{BKY_APP_TITLE}`),this.moveInputBefore(`TITLE`,`LABEL`))},updateShadow_:function(){if(this.isInsertionMarker())return;let e=dn(`title`);this.getInput(`TITLE`).connection.setShadowDom(e);let t=dn(`label`);this.getInput(`LABEL`).connection.setShadowDom(t);let n=dn(``);this.getInput(`VALUE`).connection.setShadowDom(n)},ensureBlocks_:function(){this.isInsertionMarker()||V(this,[[`RESULT`,`__result__`,`x-runtime-lib.result`,!0]])}},x.forBlock.open_prompt_dlg_v1=function(e){return`{
20
- var __result__ = await __openPromptDlgV1__(${x.valueToCode(e,`TITLE`,_.ATOMIC)}, ${x.valueToCode(e,`LABEL`,_.ATOMIC)}, ${x.valueToCode(e,`VALUE`,_.ATOMIC)});
21
- ${x.statementToCode(e,`HANDLE`)}}
22
- `},h([{type:`popup_message_v1`,message0:`%{BKY_APP_V1_POPUP_MESSAGE_TITLE}`,args0:[{type:`field_dropdown`,name:`TYPE`,options:[[`%{BKY_APP_POPUP_MESSAGE_TYPE_INFO}`,`info`],[`%{BKY_APP_POPUP_MESSAGE_TYPE_SUCCESS}`,`success`],[`%{BKY_APP_POPUP_MESSAGE_TYPE_WARNING}`,`warning`],[`%{BKY_APP_POPUP_MESSAGE_TYPE_ERROR}`,`error`]]},{type:`input_value`,name:`TEXT`}],previousStatement:null,nextStatement:null,style:`procedure_blocks`,helpUrl:`%{BKY_APP_V1_POPUP_MESSAGE_HELPURL}`,tooltip:`%{BKY_APP_V1_POPUP_MESSAGE_TOOLTIP}`}]),x.forBlock.popup_message_v1=function(e){return`__messageV1__(${x.quote_(e.getFieldValue(`TYPE`))}, ${x.valueToCode(e,`TEXT`,_.ATOMIC)});\n`},S.call_app_method_v1={init:function(){this.node={id:``,key:``,alias:``},this.method={id:``,kind:``,names:[]},this.appendDummyInput().appendField(`%{BKY_APP_V1_CALL_APP_METHOD_TITLE}`).appendField(new m(()=>this.genNodeOpts_()),`NODE`).appendField(new m(()=>this.genMethodOpts_()),`METHOD`),this.setPreviousStatement(!0,null),this.setNextStatement(!0,null),this.setStyle(`procedure_blocks`),this.setTooltip(`%{BKY_APP_V1_CALL_APP_METHOD_TOOLTIP}`),this.setHelpUrl(`%{BKY_APP_V1_CALL_APP_METHOD_HELPURL}`),this.initData_()},initData_:function(){if(this.node.id)return;let e=In(`callMethod`)?.[0];if(!e)return;this.node.id=e.id,this.node.key=e.key,this.node.alias=e.alias;let t=this.getField(`NODE`);t.getOptions(!1),t.setValue(this.node.id);let n=er(this.node.id)?.[0];if(!n)return;this.method.id=n.id,this.method.kind=n.kind,this.method.names=n.names,this.method.inputs=n.inputs,this.method.outputs=n.outputs;let r=this.getField(`METHOD`);r.getOptions(!1),r.setValue(this.method.id)},saveExtraState:function(){return{node:this.node,method:this.method}},loadExtraState:function(e){this.node.id=e.node?.id??``,this.node.key=e.node?.key??``,this.node.alias=e.node?.alias??``,this.method.id=e.method?.id??``,this.method.kind=e.method?.kind??``,this.method.names=e.method?.names??[],this.method.inputs=e.method?.inputs,this.method.outputs=e.method?.outputs,this.updateShape_(),this.updateShadow_(),setTimeout(()=>{this.ensureBlocks_(),this.checkWarning_()},0)},genNodeOpts_:function(){return Ln(`callMethod`)},genMethodOpts_:function(){return nr(this.node.id)},onchange:function(e){if(e.type===p.BLOCK_CHANGE){let t=e;t.blockId===this.id&&(t.element===`field`&&(t.name===`NODE`?this.onNodeChange_(t.newValue):t.name===`METHOD`&&this.onMethodChange_(t.newValue)),setTimeout(()=>{this.checkWarning_()},0))}},onNodeChange_:function(e){let t=W(e);if(!t){console.assert(!1);return}let n=this.node.id!==t.id;this.node.id=t.id,this.node.key=t.key,this.node.alias=t.alias;let r=this.getField(`METHOD`);if(r.getOptions(!1),n){let e=er(this.node.id)?.[0];r.setValue(e?.id??``)}this.onMethodChange_(r.getValue())},onMethodChange_:function(e){let t=tr(e);if(!t){console.assert(!1);return}this.method.id=t.id,this.method.kind=t.kind,this.method.names=t.names,this.method.inputs=t.inputs,this.method.outputs=t.outputs,this.updateShape_(),this.updateShadow_(),setTimeout(()=>{this.ensureBlocks_()},0)},updateShape_:function(){this.method.outputs&&this.method.outputs.length>0?this.getInput(`HANDLE`)||this.appendStatementInput(`HANDLE`).appendField(`%{BKY_APP_DO}`):this.getInput(`HANDLE`)&&this.removeInput(`HANDLE`);for(let e=this.method.outputs?.length??0;this.getInput(`OUTPUT`+e);e++){let t=this.getInput(`OUTPUT`+e)?.connection?.targetBlock();t&&t.dispose(),this.removeInput(`OUTPUT`+e)}if(this.method.outputs)for(let e=0;e<this.method.outputs.length;e++){if(this.getInput(`OUTPUT`+e))continue;let t=this.appendValueInput(`OUTPUT`+e);e===0&&t.appendField(`%{BKY_APP_RETURN}`),this.moveInputBefore(`OUTPUT`+e,`HANDLE`)}for(let e=this.method.inputs?.length??0;this.getInput(`INPUT`+e);e++)this.removeInput(`INPUT`+e);if(this.method.inputs)for(let e=0;e<this.method.inputs.length;e++){let t=this.method.inputs[e];this.getInput(`INPUT`+e)||(this.appendValueInput(`INPUT`+e).setAlign(b.Align.RIGHT).appendField(F(t.name)),this.method.outputs&&this.method.outputs.length>0&&this.moveInputBefore(`INPUT`+e,`OUTPUT0`))}let e=!1;switch(this.method.kind){case`multipleRefMethod`:case`multipleCustomSlotMethod`:e=!0}if(e)this.getInput(`INSTANCE`)||this.appendValueInput(`INSTANCE`).setAlign(b.Align.RIGHT).appendField(`%{BKY_APP_INSTANCE}`).setCheck(`String`),this.method.inputs&&this.method.inputs.length>0?this.moveInputBefore(`INSTANCE`,`INPUT0`):this.method.outputs&&this.method.outputs.length>0&&this.moveInputBefore(`INSTANCE`,`OUTPUT0`);else if(this.getInput(`INSTANCE`)){let e=this.getInput(`INSTANCE`).connection.targetBlock();e&&e.dispose(),this.removeInput(`INSTANCE`)}},updateShadow_:function(){if(this.isInsertionMarker())return;let e=!1;switch(this.method.kind){case`multipleRefMethod`:case`multipleCustomSlotMethod`:e=!0}if(e){let e=H(`string`);this.getInput(`INSTANCE`).setShadowDom(e)}if(this.method.inputs)for(let e=0;e<this.method.inputs.length;e++){let t=this.method.inputs[e];if(!t.type)continue;let n=H(t.type);this.getInput(`INPUT`+e).setShadowDom(n)}},ensureBlocks_:function(){if(this.isInsertionMarker())return;let e=[],t=$n(this.method.kind);if(this.method.outputs)for(let n=0;n<this.method.outputs.length;n++){let{key:r,name:i}=this.method.outputs[n];e.push([`OUTPUT`+n,`__output$${r}__`,i,t])}e.length>0&&V(this,e)},checkWarning_:function(){let e=W(this.node.id);if(!e){this.setWarningText(F(`WARN_NODE_NOT_FOUND`));return}if(e.key!==this.node.key){this.setWarningText(F(`WARN_NODE_HAS_CHANGED`));return}e.alias!==this.node.alias&&(this.node.alias=e.alias);let t=tr(this.method.id);if(!t){this.setWarningText(F(`WARN_METHOD_NOT_FOUND`));return}if(t.kind!==this.method.kind){this.setWarningText(F(`WARN_METHOD_HAS_CHANGED`));return}if(y(t.names,this.method.names)||(this.method.names=t.names),!y(t.inputs,this.method.inputs)){this.setWarningText(F(`WARN_METHOD_HAS_CHANGED`));return}if(!y(t.outputs,this.method.outputs)){this.setWarningText(F(`WARN_METHOD_HAS_CHANGED`));return}this.setWarningText(null)}},x.forBlock.call_app_method_v1=function(e){let t=x.INDENT,n=x.quote_,r=e,i=`''`;switch(r.method.kind){case`multipleRefMethod`:case`multipleCustomSlotMethod`:i=x.valueToCode(r,`INSTANCE`,_.NONE)||`''`}let a=`{`;if(r.method.inputs)for(let e=0;e<r.method.inputs.length;e++){let{key:t,type:i}=r.method.inputs[e],o=x.valueToCode(r,`INPUT`+e,_.ATOMIC);if(o===void 0)switch(i){case`string`:o=`''`;break;case`number`:o=`0`;break;case`boolean`:o=`false`;break;case`array`:o=`[]`;break;case`object`:o=`{}`;break;default:o=`null`}a!==`{`&&(a+=`, `),a+=`${n(t)}: ${o}`}a+=`}`;let o=``;if(r.method.outputs)for(let{key:e}of r.method.outputs)o+=`${t}const __output$${e}__ = __outputs__[${n(e)}];\n`;if(r.method.kind===`customMethod`){let{kind:e,nodeId:t,methodKey:n}=ot(r.method.id),s=Re(e,t,n);if(r.method.outputs&&r.method.outputs.length>0){let e=x.statementToCode(r,`HANDLE`);return`{
14
+ `},y.trigger_app_event_v1={init:function(){this.node={id:``,key:``,alias:``},this.event={id:``,kind:``,names:[]},this.appendDummyInput().appendField(`%{BKY_APP_V1_TRIGGER_APP_EVENT_TITLE}`).appendField(new b(()=>this.genNodeOpts_()),`NODE`).appendField(new b(()=>this.genEventOpts_()),`EVENT`),this.setPreviousStatement(!0,null),this.setNextStatement(!0,null),this.setStyle(`event_blocks`),this.setTooltip(`%{BKY_APP_V1_TRIGGER_APP_EVENT_TOOLTIP}`),this.setHelpUrl(`%{BKY_APP_V1_TRIGGER_APP_EVENT_HELPURL}`),this.initData_()},initData_:function(){if(this.node.id)return;let e=In(`triggerEvent`)?.[0];if(!e)return;this.node.id=e.id,this.node.key=e.key,this.node.alias=e.alias;let t=this.getField(`NODE`);t.getOptions(!1),t.setValue(this.node.id);let n=Xn(this.node.id)?.[0];if(!n)return;this.event.id=n.id,this.event.kind=n.kind,this.event.names=n.names,this.event.params=n.params;let r=this.getField(`EVENT`);r.getOptions(!1),r.setValue(this.event.id)},saveExtraState:function(){return{node:this.node,event:this.event}},loadExtraState:function(e){this.node.id=e.node?.id??``,this.node.key=e.node?.key??``,this.node.alias=e.node?.alias??``,this.event.id=e.event?.id??``,this.event.kind=e.event?.kind??``,this.event.names=e.event?.names??[],this.event.params=e.event?.params,this.updateShape_(),this.updateShadows_(),setTimeout(()=>{this.checkWarning_()},0)},genNodeOpts_:function(){return Ln(`triggerEvent`)},genEventOpts_:function(){return Qn(this.node.id)},onchange:function(e){if(e.type===x.BLOCK_CHANGE){let t=e;t.blockId===this.id&&(t.element===`field`&&(t.name===`NODE`?this.onNodeChange_(t.newValue):t.name===`EVENT`&&this.onEventChange_(t.newValue)),setTimeout(()=>{this.checkWarning_()},0))}},onNodeChange_:function(e){let t=W(e);if(!t){console.assert(!1);return}let n=this.node.id!==t.id;this.node.id=t.id,this.node.key=t.key,this.node.alias=t.alias;let r=this.getField(`EVENT`);if(r.getOptions(!1),n){let e=Xn(this.node.id)?.[0];r.setValue(e?.id??``)}this.onEventChange_(r.getValue())},onEventChange_:function(e){let t=Zn(e);if(!t){console.assert(!1);return}this.event.id=t.id,this.event.kind=t.kind,this.event.names=t.names,this.event.params=t.params,this.updateShape_(),this.updateShadows_()},updateShape_:function(){for(let e=this.event.params?.length??0;this.getInput(`PARAM`+e);e++){let t=this.getInput(`PARAM`+e)?.connection?.targetBlock();t&&t.dispose(),this.removeInput(`PARAM`+e)}if(this.event.params){for(let e=0;e<this.event.params.length;e++)this.getInput(`PARAM`+e)||this.appendValueInput(`PARAM`+e);for(let e=0;e<this.event.params.length;e++){let{type:t}=this.event.params[e],n=this.getInput(`PARAM`+e);n.connection.setShadowDom(null);let r=n.connection.targetBlock();r&&!r.isShadow()&&r.dispose(),n.setCheck(B(t))}}let e=!1;switch(this.event.kind){case`multipleRefEvent`:case`multipleRefPropertyChangeEvent`:case`multipleCustomSlotEvent`:case`multipleCustomSlotPropertyChangeEvent`:e=!0}if(e)this.getInput(`INSTANCE`)||this.appendValueInput(`INSTANCE`).setAlign(u.Align.RIGHT).appendField(`%{BKY_APP_INSTANCE}`).setCheck(`String`),this.event.params&&this.event.params.length>0&&this.moveInputBefore(`INSTANCE`,`PARAM0`);else if(this.getInput(`INSTANCE`)){let e=this.getInput(`INSTANCE`).connection.targetBlock();e&&e.dispose(),this.removeInput(`INSTANCE`)}},updateShadows_:function(){if(!this.isInsertionMarker()){if(this.getInput(`INSTANCE`)){let e=H(`string`);this.getInput(`INSTANCE`).setShadowDom(e)}if(this.event.params)for(let e=0;e<this.event.params.length;e++){let t=this.event.params[e],n=H(t.type);this.getInput(`PARAM`+e).connection.setShadowDom(n)}}},checkWarning_:function(){let e=W(this.node.id);if(!e){this.setWarningText(F(`WARN_NODE_NOT_FOUND`));return}if(e.key!==this.node.key){this.setWarningText(F(`WARN_NODE_HAS_CHANGED`));return}e.alias!==this.node.alias&&(this.node.alias=e.alias);let t=Zn(this.event.id);if(!t){this.setWarningText(F(`WARN_EVENT_NOT_FOUND`));return}if(t.kind!==this.event.kind){this.setWarningText(F(`WARN_EVENT_HAS_CHANGED`));return}if(v(t.names,this.event.names)||(this.event.names=t.names),!v(t.params,this.event.params)){this.setWarningText(F(`WARN_EVENT_HAS_CHANGED`));return}this.setWarningText(null)}},g.forBlock.trigger_app_event_v1=function(e){let t=g.quote_,n=e,r=`[`;if(n.event.params)for(let e=0;e<n.event.params.length;e++){let t=g.valueToCode(n,`PARAM`+e,_.NONE);e!==0&&(r+=`, `),r+=t}r+=`]`;let i=`''`;return n.getInput(`INSTANCE`)&&(i=g.valueToCode(n,`INSTANCE`,_.NONE)||`''`),`await __triggerEventV1__(${t(n.event.id)}, ${r}, ${i});\n`},t([{type:`watch_effect_v1`,message0:`%{BKY_APP_V1_WATCH_EFFECT_TITLE}`,args0:[{type:`input_dummy`},{type:`input_statement`,name:`HANDLE`}],style:`event_blocks`,tooltip:`%{BKY_APP_V1_WATCH_EFFECT_TOOLTIP}`,helpUrl:`%{BKY_APP_V1_WATCH_EFFECT_HELPURL}`}]),g.forBlock.watch_effect_v1=function(e){return`async function __watchEffect$${fe(e.id)}__() {
15
+ ${g.statementToCode(e,`HANDLE`)}};
16
+ `},t([{type:`app_debug_trace_v1`,message0:`%{BKY_APP_V1_APP_DEBUG_TRACE_TITLE}`,args0:[{type:`input_value`,name:`OBJECT`}],previousStatement:null,nextStatement:null,style:`procedure_blocks`,tooltip:`%{BKY_APP_V1_APP_DEBUG_TRACE_TOOLTIP}`,helpUrl:`%{BKY_APP_V1_APP_DEBUG_TRACE_HELPURL}`}]),g.forBlock.app_debug_trace_v1=function(e){return`__debugTraceV1__(${g.valueToCode(e,`OBJECT`,_.NONE)});\n`},y.open_confirm_dlg_v1={init:function(){this.appendDummyInput().appendField(`%{BKY_APP_V1_OPEN_CONFIRM_DLG_TITLE}`),this.setPreviousStatement(!0,null),this.setNextStatement(!0,null),this.setStyle(`procedure_blocks`),this.setTooltip(`%{BKY_APP_V1_OPEN_CONFIRM_DLG_TOOLTIP}`),this.setHelpUrl(`%{BKY_APP_V1_OPEN_CONFIRM_DLG_HELPURL}`)},saveExtraState:function(){return{}},loadExtraState:function(){this.updateShape_(),this.updateShadow_(),setTimeout(()=>{this.ensureBlocks_()},0)},updateShape_:function(){this.getInput(`HANDLE`)||this.appendStatementInput(`HANDLE`).appendField(`%{BKY_APP_DO}`),this.getInput(`RESULT`)||(this.appendValueInput(`RESULT`).appendField(`%{BKY_APP_RETURN}`),this.moveInputBefore(`RESULT`,`HANDLE`)),this.getInput(`TEXT`)||(this.appendValueInput(`TEXT`).setCheck(`String`).setAlign(u.Align.RIGHT).appendField(`%{BKY_APP_TEXT}`),this.moveInputBefore(`TEXT`,`RESULT`)),this.getInput(`TITLE`)||(this.appendValueInput(`TITLE`).setCheck(`String`).setAlign(u.Align.RIGHT).appendField(`%{BKY_APP_TITLE}`),this.moveInputBefore(`TITLE`,`TEXT`))},updateShadow_:function(){if(this.isInsertionMarker())return;let e=dn(`title`);this.getInput(`TITLE`).connection.setShadowDom(e);let t=dn(`text`);this.getInput(`TEXT`).connection.setShadowDom(t)},ensureBlocks_:function(){this.isInsertionMarker()||V(this,[[`RESULT`,`__result__`,`x-runtime-lib.result`,!0]])}},g.forBlock.open_confirm_dlg_v1=function(e){return`{
17
+ var __result__ = await __openConfirmDlgV1__(${g.valueToCode(e,`TITLE`,_.ATOMIC)}, ${g.valueToCode(e,`TEXT`,_.ATOMIC)});
18
+ ${g.statementToCode(e,`HANDLE`)}}
19
+ `},y.open_prompt_dlg_v1={init:function(){this.appendDummyInput().appendField(`%{BKY_APP_V1_OPEN_PROMPT_DLG_TITLE}`),this.setPreviousStatement(!0,null),this.setNextStatement(!0,null),this.setStyle(`procedure_blocks`),this.setTooltip(`%{BKY_APP_V1_OPEN_PROMPT_DLG_TOOLTIP}`),this.setHelpUrl(`%{BKY_APP_V1_OPEN_PROMPT_DLG_HELPURL}`)},saveExtraState:function(){return{}},loadExtraState:function(){this.updateShape_(),this.updateShadow_(),setTimeout(()=>{this.ensureBlocks_()},0)},updateShape_:function(){this.getInput(`HANDLE`)||this.appendStatementInput(`HANDLE`).appendField(`%{BKY_APP_DO}`),this.getInput(`RESULT`)||(this.appendValueInput(`RESULT`).appendField(`%{BKY_APP_RETURN}`),this.moveInputBefore(`RESULT`,`HANDLE`)),this.getInput(`VALUE`)||(this.appendValueInput(`VALUE`).setCheck(`String`).setAlign(u.Align.RIGHT).appendField(`%{BKY_APP_VALUE}`),this.moveInputBefore(`VALUE`,`RESULT`)),this.getInput(`LABEL`)||(this.appendValueInput(`LABEL`).setCheck(`String`).setAlign(u.Align.RIGHT).appendField(`%{BKY_APP_LABEL}`),this.moveInputBefore(`LABEL`,`VALUE`)),this.getInput(`TITLE`)||(this.appendValueInput(`TITLE`).setCheck(`String`).setAlign(u.Align.RIGHT).appendField(`%{BKY_APP_TITLE}`),this.moveInputBefore(`TITLE`,`LABEL`))},updateShadow_:function(){if(this.isInsertionMarker())return;let e=dn(`title`);this.getInput(`TITLE`).connection.setShadowDom(e);let t=dn(`label`);this.getInput(`LABEL`).connection.setShadowDom(t);let n=dn(``);this.getInput(`VALUE`).connection.setShadowDom(n)},ensureBlocks_:function(){this.isInsertionMarker()||V(this,[[`RESULT`,`__result__`,`x-runtime-lib.result`,!0]])}},g.forBlock.open_prompt_dlg_v1=function(e){return`{
20
+ var __result__ = await __openPromptDlgV1__(${g.valueToCode(e,`TITLE`,_.ATOMIC)}, ${g.valueToCode(e,`LABEL`,_.ATOMIC)}, ${g.valueToCode(e,`VALUE`,_.ATOMIC)});
21
+ ${g.statementToCode(e,`HANDLE`)}}
22
+ `},t([{type:`popup_message_v1`,message0:`%{BKY_APP_V1_POPUP_MESSAGE_TITLE}`,args0:[{type:`field_dropdown`,name:`TYPE`,options:[[`%{BKY_APP_POPUP_MESSAGE_TYPE_INFO}`,`info`],[`%{BKY_APP_POPUP_MESSAGE_TYPE_SUCCESS}`,`success`],[`%{BKY_APP_POPUP_MESSAGE_TYPE_WARNING}`,`warning`],[`%{BKY_APP_POPUP_MESSAGE_TYPE_ERROR}`,`error`]]},{type:`input_value`,name:`TEXT`}],previousStatement:null,nextStatement:null,style:`procedure_blocks`,helpUrl:`%{BKY_APP_V1_POPUP_MESSAGE_HELPURL}`,tooltip:`%{BKY_APP_V1_POPUP_MESSAGE_TOOLTIP}`}]),g.forBlock.popup_message_v1=function(e){return`__messageV1__(${g.quote_(e.getFieldValue(`TYPE`))}, ${g.valueToCode(e,`TEXT`,_.ATOMIC)});\n`},y.call_app_method_v1={init:function(){this.node={id:``,key:``,alias:``},this.method={id:``,kind:``,names:[]},this.appendDummyInput().appendField(`%{BKY_APP_V1_CALL_APP_METHOD_TITLE}`).appendField(new b(()=>this.genNodeOpts_()),`NODE`).appendField(new b(()=>this.genMethodOpts_()),`METHOD`),this.setPreviousStatement(!0,null),this.setNextStatement(!0,null),this.setStyle(`procedure_blocks`),this.setTooltip(`%{BKY_APP_V1_CALL_APP_METHOD_TOOLTIP}`),this.setHelpUrl(`%{BKY_APP_V1_CALL_APP_METHOD_HELPURL}`),this.initData_()},initData_:function(){if(this.node.id)return;let e=In(`callMethod`)?.[0];if(!e)return;this.node.id=e.id,this.node.key=e.key,this.node.alias=e.alias;let t=this.getField(`NODE`);t.getOptions(!1),t.setValue(this.node.id);let n=er(this.node.id)?.[0];if(!n)return;this.method.id=n.id,this.method.kind=n.kind,this.method.names=n.names,this.method.inputs=n.inputs,this.method.outputs=n.outputs;let r=this.getField(`METHOD`);r.getOptions(!1),r.setValue(this.method.id)},saveExtraState:function(){return{node:this.node,method:this.method}},loadExtraState:function(e){this.node.id=e.node?.id??``,this.node.key=e.node?.key??``,this.node.alias=e.node?.alias??``,this.method.id=e.method?.id??``,this.method.kind=e.method?.kind??``,this.method.names=e.method?.names??[],this.method.inputs=e.method?.inputs,this.method.outputs=e.method?.outputs,this.updateShape_(),this.updateShadow_(),setTimeout(()=>{this.ensureBlocks_(),this.checkWarning_()},0)},genNodeOpts_:function(){return Ln(`callMethod`)},genMethodOpts_:function(){return nr(this.node.id)},onchange:function(e){if(e.type===x.BLOCK_CHANGE){let t=e;t.blockId===this.id&&(t.element===`field`&&(t.name===`NODE`?this.onNodeChange_(t.newValue):t.name===`METHOD`&&this.onMethodChange_(t.newValue)),setTimeout(()=>{this.checkWarning_()},0))}},onNodeChange_:function(e){let t=W(e);if(!t){console.assert(!1);return}let n=this.node.id!==t.id;this.node.id=t.id,this.node.key=t.key,this.node.alias=t.alias;let r=this.getField(`METHOD`);if(r.getOptions(!1),n){let e=er(this.node.id)?.[0];r.setValue(e?.id??``)}this.onMethodChange_(r.getValue())},onMethodChange_:function(e){let t=tr(e);if(!t){console.assert(!1);return}this.method.id=t.id,this.method.kind=t.kind,this.method.names=t.names,this.method.inputs=t.inputs,this.method.outputs=t.outputs,this.updateShape_(),this.updateShadow_(),setTimeout(()=>{this.ensureBlocks_()},0)},updateShape_:function(){this.method.outputs&&this.method.outputs.length>0?this.getInput(`HANDLE`)||this.appendStatementInput(`HANDLE`).appendField(`%{BKY_APP_DO}`):this.getInput(`HANDLE`)&&this.removeInput(`HANDLE`);for(let e=this.method.outputs?.length??0;this.getInput(`OUTPUT`+e);e++){let t=this.getInput(`OUTPUT`+e)?.connection?.targetBlock();t&&t.dispose(),this.removeInput(`OUTPUT`+e)}if(this.method.outputs)for(let e=0;e<this.method.outputs.length;e++){if(this.getInput(`OUTPUT`+e))continue;let t=this.appendValueInput(`OUTPUT`+e);e===0&&t.appendField(`%{BKY_APP_RETURN}`),this.moveInputBefore(`OUTPUT`+e,`HANDLE`)}for(let e=this.method.inputs?.length??0;this.getInput(`INPUT`+e);e++)this.removeInput(`INPUT`+e);if(this.method.inputs)for(let e=0;e<this.method.inputs.length;e++){let t=this.method.inputs[e];this.getInput(`INPUT`+e)||(this.appendValueInput(`INPUT`+e).setAlign(u.Align.RIGHT).appendField(F(t.name)),this.method.outputs&&this.method.outputs.length>0&&this.moveInputBefore(`INPUT`+e,`OUTPUT0`))}let e=!1;switch(this.method.kind){case`multipleRefMethod`:case`multipleCustomSlotMethod`:e=!0}if(e)this.getInput(`INSTANCE`)||this.appendValueInput(`INSTANCE`).setAlign(u.Align.RIGHT).appendField(`%{BKY_APP_INSTANCE}`).setCheck(`String`),this.method.inputs&&this.method.inputs.length>0?this.moveInputBefore(`INSTANCE`,`INPUT0`):this.method.outputs&&this.method.outputs.length>0&&this.moveInputBefore(`INSTANCE`,`OUTPUT0`);else if(this.getInput(`INSTANCE`)){let e=this.getInput(`INSTANCE`).connection.targetBlock();e&&e.dispose(),this.removeInput(`INSTANCE`)}},updateShadow_:function(){if(this.isInsertionMarker())return;let e=!1;switch(this.method.kind){case`multipleRefMethod`:case`multipleCustomSlotMethod`:e=!0}if(e){let e=H(`string`);this.getInput(`INSTANCE`).setShadowDom(e)}if(this.method.inputs)for(let e=0;e<this.method.inputs.length;e++){let t=this.method.inputs[e];if(!t.type)continue;let n=H(t.type);this.getInput(`INPUT`+e).setShadowDom(n)}},ensureBlocks_:function(){if(this.isInsertionMarker())return;let e=[],t=$n(this.method.kind);if(this.method.outputs)for(let n=0;n<this.method.outputs.length;n++){let{key:r,name:i}=this.method.outputs[n];e.push([`OUTPUT`+n,`__output$${r}__`,i,t])}e.length>0&&V(this,e)},checkWarning_:function(){let e=W(this.node.id);if(!e){this.setWarningText(F(`WARN_NODE_NOT_FOUND`));return}if(e.key!==this.node.key){this.setWarningText(F(`WARN_NODE_HAS_CHANGED`));return}e.alias!==this.node.alias&&(this.node.alias=e.alias);let t=tr(this.method.id);if(!t){this.setWarningText(F(`WARN_METHOD_NOT_FOUND`));return}if(t.kind!==this.method.kind){this.setWarningText(F(`WARN_METHOD_HAS_CHANGED`));return}if(v(t.names,this.method.names)||(this.method.names=t.names),!v(t.inputs,this.method.inputs)){this.setWarningText(F(`WARN_METHOD_HAS_CHANGED`));return}if(!v(t.outputs,this.method.outputs)){this.setWarningText(F(`WARN_METHOD_HAS_CHANGED`));return}this.setWarningText(null)}},g.forBlock.call_app_method_v1=function(e){let t=g.INDENT,n=g.quote_,r=e,i=`''`;switch(r.method.kind){case`multipleRefMethod`:case`multipleCustomSlotMethod`:i=g.valueToCode(r,`INSTANCE`,_.NONE)||`''`}let a=`{`;if(r.method.inputs)for(let e=0;e<r.method.inputs.length;e++){let{key:t,type:i}=r.method.inputs[e],o=g.valueToCode(r,`INPUT`+e,_.ATOMIC);if(o===void 0)switch(i){case`string`:o=`''`;break;case`number`:o=`0`;break;case`boolean`:o=`false`;break;case`array`:o=`[]`;break;case`object`:o=`{}`;break;default:o=`null`}a!==`{`&&(a+=`, `),a+=`${n(t)}: ${o}`}a+=`}`;let o=``;if(r.method.outputs)for(let{key:e}of r.method.outputs)o+=`${t}const __output$${e}__ = __outputs__[${n(e)}];\n`;if(r.method.kind===`customMethod`){let{kind:e,nodeId:t,methodKey:n}=st(r.method.id),s=ze(e,t,n);if(r.method.outputs&&r.method.outputs.length>0){let e=g.statementToCode(r,`HANDLE`);return`{
23
23
  const __outputs__ = await ${s}(${i}, ${a});
24
24
  ${o}${e}}
25
- `}else return`await ${s}(${i}, ${a});\n`}else if(r.method.outputs&&r.method.outputs.length>0){let e=x.statementToCode(r,`HANDLE`);return`{
25
+ `}else return`await ${s}(${i}, ${a});\n`}else if(r.method.outputs&&r.method.outputs.length>0){let e=g.statementToCode(r,`HANDLE`);return`{
26
26
  const __outputs__ = await __callMethodV1__(${n(r.method.id)}, ${i}, ${a});
27
27
  ${o}${e}}
28
- `}else return`await __callMethodV1__(${n(r.method.id)}, ${i}, ${a});\n`},S.implement_app_method_v1={init:function(){this.node={id:``,key:``,alias:``},this.method={id:``,kind:``,names:[]},this.appendDummyInput().appendField(`%{BKY_APP_V1_IMPLEMENT_APP_METHOD_TITLE}`).appendField(new m(()=>this.genNodeOpts_()),`NODE`).appendField(new m(()=>this.genMethodOpts_()),`METHOD`),this.appendStatementInput(`HANDLE`).appendField(`%{BKY_APP_DO}`),this.setStyle(`procedure_blocks`),this.setTooltip(`%{BKY_APP_V1_IMPLEMENT_APP_METHOD_TOOLTIP}`),this.setHelpUrl(`%{BKY_APP_V1_IMPLEMENT_APP_METHOD_HELPURL}`),this.initData_()},initData_:function(){if(this.node.id)return;let e=In(`implementMethod`)?.[0];if(!e)return;this.node.id=e.id,this.node.key=e.key,this.node.alias=e.alias;let t=this.getField(`NODE`);t.getOptions(!1),t.setValue(this.node.id);let n=ir(this.node.id)?.[0];if(!n)return;this.method.id=n.id,this.method.kind=n.kind,this.method.names=n.names,this.method.inputs=n.inputs;let r=this.getField(`METHOD`);r.getOptions(!1),r.setValue(this.method.id)},saveExtraState:function(){return{node:this.node,method:this.method}},loadExtraState:function(e){this.node.id=e.node?.id??``,this.node.key=e.node?.key??``,this.node.alias=e.node?.alias??``,this.method.id=e.method?.id??``,this.method.kind=e.method?.kind??``,this.method.names=e.method?.names??[],this.method.inputs=e.method?.inputs,this.updateShape_(),setTimeout(()=>{this.ensureBlocks_(),this.checkWarning_()},0)},genNodeOpts_:function(){return Ln(`implementMethod`)},genMethodOpts_:function(){return or(this.node.id)},onchange:function(e){if(e.type===p.BLOCK_CHANGE){let t=e;t.blockId===this.id&&(t.element===`field`&&(t.name===`NODE`?this.onNodeChange_(t.newValue):t.name===`METHOD`&&this.onMethodChange_(t.newValue)),setTimeout(()=>{this.checkWarning_()},0))}},onNodeChange_:function(e){let t=W(e);if(!t){console.assert(!1);return}let n=this.node.id!==t.id;this.node.id=t.id,this.node.key=t.key,this.node.alias=t.alias;let r=this.getField(`METHOD`);if(r.getOptions(!1),n){let e=ir(this.node.id)?.[0];r.setValue(e?.id??``)}r.setValue(r.getValue())},onMethodChange_:function(e){let t=ar(e);if(!t){console.assert(!1);return}this.method.id=t.id,this.method.kind=t.kind,this.method.names=t.names,this.method.inputs=t.inputs,this.updateShape_(),setTimeout(()=>{this.ensureBlocks_()},0)},updateShape_:function(){for(let e=this.method.inputs?.length??0;this.getInput(`INPUT`+e);e++){let t=this.getInput(`INPUT`+e)?.connection?.targetBlock();t&&t.dispose(),this.removeInput(`INPUT`+e)}if(this.method.inputs)for(let e=0;e<this.method.inputs.length;e++)this.getInput(`INPUT`+e)||(this.appendValueInput(`INPUT`+e),this.moveInputBefore(`INPUT`+e,`HANDLE`));let e=!1;switch(this.method.kind){case`multipleCustomSlotMethod`:e=!0}if(e)this.getInput(`INSTANCE`)||this.appendValueInput(`INSTANCE`).setAlign(b.Align.RIGHT).appendField(`%{BKY_APP_INSTANCE}`).setCheck(`String`),this.method.inputs&&this.method.inputs.length>0&&this.moveInputBefore(`INSTANCE`,`INPUT0`);else if(this.getInput(`INSTANCE`)){let e=this.getInput(`INSTANCE`).connection.targetBlock();e&&e.dispose(),this.removeInput(`INSTANCE`)}},ensureBlocks_:function(){if(this.isInsertionMarker())return;let e=[];this.getInput(`INSTANCE`)&&e.push([`INSTANCE`,`__instance__`,`x-runtime-lib.instance`,!0]);let t=rr(this.method.kind);if(this.method.inputs)for(let n=0;n<this.method.inputs.length;n++){let{key:r,name:i}=this.method.inputs[n];e.push([`INPUT`+n,`__input$${r}__`,i,t])}V(this,e)},checkWarning_:function(){let e=W(this.node.id);if(!e){this.setWarningText(F(`WARN_NODE_NOT_FOUND`));return}if(e.key!==this.node.key){this.setWarningText(F(`WARN_NODE_HAS_CHANGED`));return}e.alias!==this.node.alias&&(this.node.alias=e.alias);let t=ar(this.method.id);if(!t){this.setWarningText(F(`WARN_METHOD_NOT_FOUND`));return}if(t.kind!==this.method.kind){this.setWarningText(F(`WARN_METHOD_HAS_CHANGED`));return}if(y(t.names,this.method.names)||(this.method.names=t.names),!y(t.inputs,this.method.inputs)){this.setWarningText(F(`WARN_METHOD_HAS_CHANGED`));return}this.setWarningText(null)}},x.forBlock.implement_app_method_v1=function(e){let t=x.INDENT,n=x.quote_,r=e,{kind:i,nodeId:a,methodKey:o}=ot(r.method.id),s=``;if(r.method.inputs)for(let{key:e}of r.method.inputs)s+=`${t}const __input$${e}__ = __inputs__[${n(e)}];\n`;let c=x.statementToCode(r,`HANDLE`);return`async function ${Re(i,a,o)}(__instance__, __inputs__) {
28
+ `}else return`await __callMethodV1__(${n(r.method.id)}, ${i}, ${a});\n`},y.implement_app_method_v1={init:function(){this.node={id:``,key:``,alias:``},this.method={id:``,kind:``,names:[]},this.appendDummyInput().appendField(`%{BKY_APP_V1_IMPLEMENT_APP_METHOD_TITLE}`).appendField(new b(()=>this.genNodeOpts_()),`NODE`).appendField(new b(()=>this.genMethodOpts_()),`METHOD`),this.appendStatementInput(`HANDLE`).appendField(`%{BKY_APP_DO}`),this.setStyle(`procedure_blocks`),this.setTooltip(`%{BKY_APP_V1_IMPLEMENT_APP_METHOD_TOOLTIP}`),this.setHelpUrl(`%{BKY_APP_V1_IMPLEMENT_APP_METHOD_HELPURL}`),this.initData_()},initData_:function(){if(this.node.id)return;let e=In(`implementMethod`)?.[0];if(!e)return;this.node.id=e.id,this.node.key=e.key,this.node.alias=e.alias;let t=this.getField(`NODE`);t.getOptions(!1),t.setValue(this.node.id);let n=ir(this.node.id)?.[0];if(!n)return;this.method.id=n.id,this.method.kind=n.kind,this.method.names=n.names,this.method.inputs=n.inputs;let r=this.getField(`METHOD`);r.getOptions(!1),r.setValue(this.method.id)},saveExtraState:function(){return{node:this.node,method:this.method}},loadExtraState:function(e){this.node.id=e.node?.id??``,this.node.key=e.node?.key??``,this.node.alias=e.node?.alias??``,this.method.id=e.method?.id??``,this.method.kind=e.method?.kind??``,this.method.names=e.method?.names??[],this.method.inputs=e.method?.inputs,this.updateShape_(),setTimeout(()=>{this.ensureBlocks_(),this.checkWarning_()},0)},genNodeOpts_:function(){return Ln(`implementMethod`)},genMethodOpts_:function(){return or(this.node.id)},onchange:function(e){if(e.type===x.BLOCK_CHANGE){let t=e;t.blockId===this.id&&(t.element===`field`&&(t.name===`NODE`?this.onNodeChange_(t.newValue):t.name===`METHOD`&&this.onMethodChange_(t.newValue)),setTimeout(()=>{this.checkWarning_()},0))}},onNodeChange_:function(e){let t=W(e);if(!t){console.assert(!1);return}let n=this.node.id!==t.id;this.node.id=t.id,this.node.key=t.key,this.node.alias=t.alias;let r=this.getField(`METHOD`);if(r.getOptions(!1),n){let e=ir(this.node.id)?.[0];r.setValue(e?.id??``)}r.setValue(r.getValue())},onMethodChange_:function(e){let t=ar(e);if(!t){console.assert(!1);return}this.method.id=t.id,this.method.kind=t.kind,this.method.names=t.names,this.method.inputs=t.inputs,this.updateShape_(),setTimeout(()=>{this.ensureBlocks_()},0)},updateShape_:function(){for(let e=this.method.inputs?.length??0;this.getInput(`INPUT`+e);e++){let t=this.getInput(`INPUT`+e)?.connection?.targetBlock();t&&t.dispose(),this.removeInput(`INPUT`+e)}if(this.method.inputs)for(let e=0;e<this.method.inputs.length;e++)this.getInput(`INPUT`+e)||(this.appendValueInput(`INPUT`+e),this.moveInputBefore(`INPUT`+e,`HANDLE`));let e=!1;switch(this.method.kind){case`multipleCustomSlotMethod`:e=!0}if(e)this.getInput(`INSTANCE`)||this.appendValueInput(`INSTANCE`).setAlign(u.Align.RIGHT).appendField(`%{BKY_APP_INSTANCE}`).setCheck(`String`),this.method.inputs&&this.method.inputs.length>0&&this.moveInputBefore(`INSTANCE`,`INPUT0`);else if(this.getInput(`INSTANCE`)){let e=this.getInput(`INSTANCE`).connection.targetBlock();e&&e.dispose(),this.removeInput(`INSTANCE`)}},ensureBlocks_:function(){if(this.isInsertionMarker())return;let e=[];this.getInput(`INSTANCE`)&&e.push([`INSTANCE`,`__instance__`,`x-runtime-lib.instance`,!0]);let t=rr(this.method.kind);if(this.method.inputs)for(let n=0;n<this.method.inputs.length;n++){let{key:r,name:i}=this.method.inputs[n];e.push([`INPUT`+n,`__input$${r}__`,i,t])}V(this,e)},checkWarning_:function(){let e=W(this.node.id);if(!e){this.setWarningText(F(`WARN_NODE_NOT_FOUND`));return}if(e.key!==this.node.key){this.setWarningText(F(`WARN_NODE_HAS_CHANGED`));return}e.alias!==this.node.alias&&(this.node.alias=e.alias);let t=ar(this.method.id);if(!t){this.setWarningText(F(`WARN_METHOD_NOT_FOUND`));return}if(t.kind!==this.method.kind){this.setWarningText(F(`WARN_METHOD_HAS_CHANGED`));return}if(v(t.names,this.method.names)||(this.method.names=t.names),!v(t.inputs,this.method.inputs)){this.setWarningText(F(`WARN_METHOD_HAS_CHANGED`));return}this.setWarningText(null)}},g.forBlock.implement_app_method_v1=function(e){let t=g.INDENT,n=g.quote_,r=e,{kind:i,nodeId:a,methodKey:o}=st(r.method.id),s=``;if(r.method.inputs)for(let{key:e}of r.method.inputs)s+=`${t}const __input$${e}__ = __inputs__[${n(e)}];\n`;let c=g.statementToCode(r,`HANDLE`);return`async function ${ze(i,a,o)}(__instance__, __inputs__) {
29
29
  ${s}${t}const __outputs__ = {};
30
30
  ${c}${t}return __outputs__;
31
31
  }
32
- `},S.set_app_method_output_v1={init:function(){this.node={id:``,key:``,alias:``},this.method={id:``,kind:``,names:[]},this.output={key:``,name:``,type:`string`},this.appendValueInput(`VALUE`).appendField(`%{BKY_APP_V1_SET_APP_METHOD_OUTPUT_TITLE}`).appendField(new m(()=>this.genNodeOpts_()),`NODE`).appendField(new m(()=>this.genMethodOpts_()),`METHOD`).appendField(new m(()=>this.genOutputOpts_()),`OUTPUT`),this.setPreviousStatement(!0,null),this.setNextStatement(!0,null),this.setStyle(`procedure_blocks`),this.setTooltip(`%{BKY_APP_V1_SET_APP_METHOD_OUTPUT_TOOLTIP}`),this.setHelpUrl(`%{BKY_APP_V1_SET_APP_METHOD_OUTPUT_HELPURL}`),this.initData_(),this.updateShape_(),this.updateShadows_()},initData_:function(){if(this.node.id)return;let e=In(`implementMethod`)?.[0];if(!e)return;this.node.id=e.id,this.node.key=e.key,this.node.alias=e.alias;let t=this.getField(`NODE`);t.getOptions(!1),t.setValue(this.node.id);let n=ir(this.node.id)?.[0];if(!n)return;this.method.id=n.id,this.method.kind=n.kind,this.method.names=n.names;let r=this.getField(`METHOD`);r.getOptions(!1),r.setValue(this.method.id);let i=sr(this.method.id)?.[0];if(!i)return;this.output.key=i.key,this.output.name=i.name,this.output.type=i.type;let a=this.getField(`OUTPUT`);a.getOptions(!1),a.setValue(this.output.key)},saveExtraState:function(){return{node:this.node,method:this.method,output:this.output}},loadExtraState:function(e){this.node.id=e.node?.id??``,this.node.key=e.node?.key??``,this.node.alias=e.node?.alias??``,this.method.id=e.method?.id??``,this.method.kind=e.method?.kind??``,this.method.names=e.method?.names??[],this.output.key=e.output?.key??``,this.output.name=e.output?.name??``,this.output.type=e.output?.type??``,this.updateShape_(),this.updateShadows_(),setTimeout(()=>{this.checkWarning_()},0)},genNodeOpts_:function(){return Ln(`implementMethod`)},genMethodOpts_:function(){return or(this.node.id)},genOutputOpts_:function(){return lr(this.method.id)},onchange:function(e){if(e.type===p.BLOCK_CHANGE){let t=e;t.blockId===this.id&&(t.element===`field`&&(t.name===`NODE`?this.onNodeChange_(t.newValue):t.name===`METHOD`?this.onMethodChange_(t.newValue):t.name===`OUTPUT`&&this.onOutputChange_(t.newValue)),setTimeout(()=>{this.checkWarning_()},0))}},onNodeChange_:function(e){let t=W(e);if(!t){console.assert(!1);return}let n=this.node.id!==t.id;this.node.id=t.id,this.node.key=t.key,this.node.alias=t.alias;let r=this.getField(`METHOD`);if(r.getOptions(!1),n){let e=ir(this.node.id)?.[0];r.setValue(e?.id??``)}r.setValue(r.getValue())},onMethodChange_:function(e){let t=ar(e);if(!t){console.assert(!1);return}let n=this.method.id!==t.id;this.method.id=t.id,this.method.kind=t.kind,this.method.names=t.names;let r=this.getField(`OUTPUT`);if(r.getOptions(!1),n||!cr(this.method.id,this.output.key)){let e=sr(this.method.id)?.[0];r.setValue(e?.key??``)}this.onOutputChange_(r.getValue())},onOutputChange_:function(e){let t=cr(this.method.id,e);if(!t){console.assert(!1);return}this.output.key=t.key,this.output.name=t.name,this.output.type=t.type},updateShape_:function(){let e=this.getInput(`VALUE`);e.connection.setShadowDom(null);let t=e.connection.targetBlock();t&&!t.isShadow()&&t.dispose();let n=B(this.output.type);e.setCheck(n)},updateShadows_:function(){if(this.isInsertionMarker())return;let e=H(this.output.type);this.getInput(`VALUE`).connection.setShadowDom(e)},checkWarning_:function(){let e=W(this.node.id);if(!e){this.setWarningText(F(`WARN_NODE_NOT_FOUND`));return}if(e.key!==this.node.key){this.setWarningText(F(`WARN_NODE_HAS_CHANGED`));return}e.alias!==this.node.alias&&(this.node.alias=e.alias);let t=ar(this.method.id);if(!t){this.setWarningText(F(`WARN_METHOD_NOT_FOUND`));return}if(t.kind!==this.method.kind){this.setWarningText(F(`WARN_METHOD_HAS_CHANGED`));return}t.names!==this.method.names&&(this.method.names=t.names);let n=cr(this.method.id,this.output.key);if(!n){this.setWarningText(F(`WARN_OUTPUT_NOT_FOUND`));return}if(n.name!==this.output.name&&(this.output.name=n.name),n.type!==this.output.type){this.setWarningText(F(`WARN_OUTPUT_HAS_CHANGED`));return}this.setWarningText(null)}},x.forBlock.set_app_method_output_v1=function(e){let t=x.quote_,n=e,r=x.valueToCode(n,`VALUE`,_.ATOMIC);if(r===void 0)switch(n.output.type){case`string`:r=`''`;break;case`number`:r=`0`;break;case`boolean`:r=`false`;break;case`array`:r=`[]`;break;case`object`:r=`{}`;break;default:r=`null`}return`__outputs__[${t(n.output.key)}] = ${r};\n`},h([{type:`app_env_is_v1`,message0:`%{BKY_APP_V1_APP_ENV_IS_TITLE}`,args0:[{type:`field_dropdown`,name:`ENV`,options:[[`%{BKY_APP_ENV_DEV}`,`dev`],[`%{BKY_APP_ENV_PROD}`,`prod`]]}],output:`Boolean`,style:`logic_blocks`,tooltip:`%{BKY_APP_V1_APP_ENV_IS_TOOLTIP}`,helpUrl:`%{BKY_APP_V1_APP_ENV_IS_HELPURL}`}]),x.forBlock.app_env_is_v1=function(e){return[`__getEnvV1__() === ${x.quote_(e.getFieldValue(`ENV`))}`,_.ATOMIC]},S.navigate_to_v1={init:function(){this.app={id:``,name:``},this.page={id:``,name:``},this.appendDummyInput().appendField(`%{BKY_APP_V1_NAVIGATE_TO_TITLE}`).appendField(new m(()=>this.genAppOpts_()),`APP`).appendField(new m(()=>this.genPageOpts_()),`PAGE`),this.setPreviousStatement(!0,null),this.setNextStatement(!0,null),this.setStyle(`procedure_blocks`),this.setTooltip(`%{BKY_APP_V1_NAVIGATE_TOOLTIP}`),this.setHelpUrl(`%{BKY_APP_V1_NAVIGATE_HELPURL}`),this.initData_()},initData_:function(){if(this.app.id)return;let e=On()?.[0];if(!e)return;this.app.id=e.id,this.app.name=e.name;let t=this.getField(`APP`);t.getOptions(!1),t.setValue(this.app.id);let n=ur(this.app.id)?.[0];if(!n)return;this.page.id=n.id,this.page.name=n.name;let r=this.getField(`PAGE`);r.getOptions(!1),r.setValue(this.page.id)},saveExtraState:function(){return{app:this.app,page:this.page}},loadExtraState:function(e){this.app.id=e.app?.id??``,this.app.name=e.app?.name??``,this.page.id=e.page?.id??``,this.page.name=e.page?.name??``,setTimeout(()=>{this.checkWarning_()},0)},genAppOpts_:function(){return An()},genPageOpts_:function(){return fr(this.app.id)},onchange:function(e){if(e.type===p.BLOCK_CHANGE){let t=e;t.blockId===this.id&&(t.element===`field`&&(t.name===`APP`?this.onAppChange_(t.newValue):t.name===`PAGE`&&this.onPageChange_(t.newValue)),setTimeout(()=>{this.checkWarning_()},0))}},onAppChange_:function(e){let t=kn(e);if(!t){console.assert(!1);return}let n=this.app.id!==t.id;this.app.id=t.id,this.app.name=t.name;let r=this.getField(`PAGE`);if(r.getOptions(!1),n){let e=ur(this.app.id)?.[0];r.setValue(e?.id??``)}this.onPageChange_(r.getValue())},onPageChange_:function(e){let t=dr(this.app.id,e);if(!t){console.assert(!1);return}this.page.id=t.id,this.page.name=t.name},checkWarning_:function(){let e=kn(this.app.id);if(!e){this.setWarningText(F(`WARN_APP_NOT_FOUND`));return}e.name!==this.app.name&&(this.app.name=e.name);let t=dr(this.app.id,this.page.id);if(!t){this.setWarningText(F(`WARN_PAGE_NOT_FOUND`));return}t.name!==this.page.name&&(this.page.name=t.name),this.setWarningText(null)}},x.forBlock.navigate_to_v1=function(e){let t=e;return`__navigateToV1__(${x.quote_(t.app.id)}, ${x.quote_(t.page.id)});\n`},S.select_comp_v1={init:function(){this.comp={id:``,name:``},this.appendDummyInput().appendField(`%{BKY_APP_V1_SELECT_COMP_TITLE}`).appendField(new m(()=>this.genCompOpts_()),`COMP`),this.setOutput(!0,`Comp`),this.setStyle(`property_blocks`),this.setTooltip(`%{BKY_APP_V1_SELECT_COMP_TOOLTIP}`),this.setHelpUrl(`%{BKY_APP_V1_SELECT_COMP_HELPURL}`),this.initData_()},initData_:function(){if(this.comp.id)return;let e=Un()?.[0];if(!e)return;this.comp.id=e.id,this.comp.name=e.name;let t=this.getField(`COMP`);t.getOptions(!1),t.setValue(this.comp.id)},saveExtraState:function(){return{comp:this.comp}},loadExtraState:function(e){this.comp.id=e.comp?.id??``,this.comp.name=e.comp?.name??``,setTimeout(()=>{this.checkWarning_()},0)},genCompOpts_:function(){return Gn()},onchange:function(e){if(e.type===p.BLOCK_CHANGE){let t=e;t.blockId===this.id&&(t.element===`field`&&t.name===`COMP`&&this.onCompChange_(t.newValue),setTimeout(()=>{this.checkWarning_()},0))}},onCompChange_:function(e){let t=Wn(e);if(!t){console.assert(!1);return}this.comp.id=t.id,this.comp.name=t.name},checkWarning_:function(){let e=Wn(this.comp.id);if(!e){this.setWarningText(F(`WARN_COMP_NOT_FOUND`));return}e.name!==this.comp.name&&(this.comp.name=e.name),this.setWarningText(null)}},x.forBlock.select_comp_v1=function(e){let t=x.quote_,n=e,r=n.comp.id,i=n.comp.name;return[`{id:${t(r)},name:${t(i)}}`,_.ATOMIC]},S.select_slot_v1={init:function(){this.slot={id:``,name:``},this.appendDummyInput().appendField(`%{BKY_APP_V1_SELECT_SLOT_TITLE}`).appendField(new m(()=>this.genSlotOpts_()),`SLOT`),this.setOutput(!0,`Slot`),this.setStyle(`property_blocks`),this.setTooltip(`%{BKY_APP_V1_SELECT_SLOT_TOOLTIP}`),this.setHelpUrl(`%{BKY_APP_V1_SELECT_SLOT_HELPURL}`),this.initData_()},initData_:function(){if(this.slot.id)return;let e=gr()?.[0];if(!e)return;this.slot.id=e.id,this.slot.name=e.name;let t=this.getField(`SLOT`);t.getOptions(!1),t.setValue(this.slot.id)},saveExtraState:function(){return{slot:this.slot}},loadExtraState:function(e){this.slot.id=e.slot?.id??``,this.slot.name=e.slot?.name??``,setTimeout(()=>{this.checkWarning_()},0)},genSlotOpts_:function(){return vr()},onchange:function(e){if(e.type===p.BLOCK_CHANGE){let t=e;t.blockId===this.id&&(t.element===`field`&&t.name===`SLOT`&&this.onSlotChange_(t.newValue),setTimeout(()=>{this.checkWarning_()},0))}},onSlotChange_:function(e){let t=_r(e);if(!t){console.assert(!1);return}this.slot.id=t.id,this.slot.name=t.name},checkWarning_:function(){let e=_r(this.slot.id);if(!e){this.setWarningText(F(`WARN_SLOT_NOT_FOUND`));return}e.name!==this.slot.name&&(this.slot.name=e.name),this.setWarningText(null)}},x.forBlock.select_slot_v1=function(e){let t=x.quote_,n=e,r=n.slot.id,i=n.slot.name;return[`{id:${t(r)},name:${t(i)}}`,_.ATOMIC]},S.get_app_property_v1={init:function(){this.node={id:``,key:``,alias:``},this.property={id:``,kind:``,names:[]},this.appendDummyInput().appendField(`%{BKY_APP_V1_GET_APP_PROPERTY_TITLE}`).appendField(new m(()=>this.genNodeOpts_()),`NODE`).appendField(new m(()=>this.genPropertyOpts_()),`PROPERTY`),this.setOutput(!0,null),this.setInputsInline(!0),this.setStyle(`property_blocks`),this.setTooltip(`%{BKY_APP_V1_GET_APP_PROPERTY_TOOLTIP}`),this.setHelpUrl(`%{BKY_APP_V1_GET_APP_PROPERTY_HELPURL}`),this.initData_(),this.updateShape_()},initData_:function(){if(this.node.id)return;let e=In(`getProperty`)?.[0];if(!e)return;this.node.id=e.id,this.node.key=e.key,this.node.alias=e.alias;let t=this.getField(`NODE`);t.getOptions(!1),t.setValue(this.node.id);let n=pr(this.node.id,`read`)?.[0];if(!n)return;this.property.id=n.id,this.property.kind=n.kind,this.property.names=n.names;let r=this.getField(`PROPERTY`);r.getOptions(!1),r.setValue(this.property.id)},saveExtraState:function(){return{node:this.node,property:this.property}},loadExtraState:function(e){this.node.id=e.node?.id??``,this.node.key=e.node?.key??``,this.node.alias=e.node?.alias??``,this.property.id=e.property?.id??``,this.property.kind=e.property?.kind??``,this.property.names=e.property?.names??[],this.updateShape_(),setTimeout(()=>{this.checkWarning_()},0)},genNodeOpts_:function(){return Ln(`getProperty`)},genPropertyOpts_:function(){return hr(this.node.id,`read`)},onchange:function(e){if(e.type===p.BLOCK_CHANGE){let t=e;t.blockId===this.id&&(t.element===`field`&&(t.name===`NODE`?this.onNodeChange_(t.newValue):t.name===`PROPERTY`&&this.onPropertyChange_(t.newValue)),setTimeout(()=>{this.checkWarning_()},0))}},onNodeChange_:function(e){let t=W(e);if(!t){console.assert(!1);return}let n=this.node.id!==t.id;this.node.id=t.id,this.node.key=t.key,this.node.alias=t.alias;let r=this.getField(`PROPERTY`);if(r.getOptions(!1),n){let e=pr(this.node.id,`read`)?.[0];r.setValue(e?.id??``)}this.onPropertyChange_(r.getValue())},onPropertyChange_:function(e){let t=mr(e);if(!t){console.assert(!1);return}this.property.id=t.id,this.property.kind=t.kind,this.property.names=t.names,this.updateShape_(),this.updateShadow_()},updateShape_:function(){let e=!1;switch(this.property.kind){case`multipleRefProperty`:case`multipleCustomSlotProperty`:e=!0}if(e)this.getInput(`INSTANCE`)||this.appendValueInput(`INSTANCE`).setAlign(b.Align.RIGHT).appendField(`%{BKY_APP_INSTANCE}`).setCheck(`String`);else if(this.getInput(`INSTANCE`)){let e=this.getInput(`INSTANCE`).connection.targetBlock();e&&e.dispose(),this.removeInput(`INSTANCE`)}},updateShadow_:function(){if(this.isInsertionMarker())return;let e=this.getInput(`INSTANCE`);if(e){e.setShadowDom(null);let t=e.connection?.targetBlock();t&&t.dispose(),e.setShadowDom(H(`string`))}},checkWarning_:function(){let e=W(this.node.id);if(!e){this.setWarningText(F(`WARN_NODE_NOT_FOUND`));return}if(e.key!==this.node.key){this.setWarningText(F(`WARN_NODE_HAS_CHANGED`));return}e.alias!==this.node.alias&&(this.node.alias=e.alias);let t=mr(this.property.id);if(!t){this.setWarningText(F(`WARN_PROPERTY_NOT_FOUND`));return}if(t.kind!==this.property.kind){this.setWarningText(F(`WARN_PROPERTY_HAS_CHANGED`));return}y(t.names,this.property.names)||(this.property.names=t.names),this.setWarningText(null)}},x.forBlock.get_app_property_v1=function(e){let t=x.quote_,n=e,r=`''`;return n.getInput(`INSTANCE`)&&(r=x.valueToCode(n,`INSTANCE`,_.NONE)||`''`),[`__getPropertyV1__(${t(n.property.id)}, ${r})`,_.ATOMIC]},S.set_app_property_v1={init:function(){this.node={id:``,key:``,alias:``},this.property={id:``,kind:``,names:[]},this.appendValueInput(`VALUE`).appendField(`%{BKY_APP_V1_SET_APP_PROPERTY_TITLE}`).appendField(new m(()=>this.genNodeOpts_()),`NODE`).appendField(new m(()=>this.genPropertyOpts_()),`PROPERTY`),this.setPreviousStatement(!0,null),this.setNextStatement(!0,null),this.setInputsInline(!0),this.setStyle(`property_blocks`),this.setTooltip(`%{BKY_APP_V1_SET_APP_PROPERTY_TOOLTIP}`),this.setHelpUrl(`%{BKY_APP_V1_SET_APP_PROPERTY_HELPURL}`),this.initData_(),this.updateShape_(),this.isInFlyout&&this.updateShadow_()},initData_:function(){if(this.node.id)return;let e=In(`setProperty`)?.[0];if(!e)return;this.node.id=e.id,this.node.key=e.key,this.node.alias=e.alias;let t=this.getField(`NODE`);t.getOptions(!1),t.setValue(this.node.id);let n=pr(this.node.id,`write`)?.[0];if(!n)return;this.property.id=n.id,this.property.kind=n.kind,this.property.names=n.names;let r=this.getField(`PROPERTY`);r.getOptions(!1),r.setValue(this.property.id)},saveExtraState:function(){return{node:this.node,property:this.property}},loadExtraState:function(e){this.node.id=e.node?.id??``,this.node.key=e.node?.key??``,this.node.alias=e.node?.alias??``,this.property.id=e.property?.id??``,this.property.kind=e.property?.kind??``,this.property.names=e.property?.names??[],this.updateShape_(),setTimeout(()=>{this.checkWarning_()},0)},genNodeOpts_:function(){return Ln(`setProperty`)},genPropertyOpts_:function(){return hr(this.node.id,`write`)},onchange:function(e){if(e.type===p.BLOCK_CHANGE){let t=e;t.blockId===this.id&&(t.element===`field`&&(t.name===`NODE`?this.onNodeChange_(t.newValue):t.name===`PROPERTY`&&this.onPropertyChange_(t.newValue)),setTimeout(()=>{this.checkWarning_()},0))}},onNodeChange_:function(e){let t=W(e);if(!t){console.assert(!1);return}let n=this.node.id!==t.id;this.node.id=t.id,this.node.key=t.key,this.node.alias=t.alias;let r=this.getField(`PROPERTY`);if(r.getOptions(!1),n){let e=pr(this.node.id,`write`)?.[0];r.setValue(e?.id??``)}this.onPropertyChange_(r.getValue())},onPropertyChange_:function(e){let t=mr(e);if(!t){console.assert(!1);return}this.property.id=t.id,this.property.kind=t.kind,this.property.names=t.names,this.updateShape_(),this.updateShadow_()},updateShape_:function(){let e=!1;switch(this.property.kind){case`multipleRefProperty`:case`multipleCustomSlotProperty`:e=!0}if(e)this.getInput(`INSTANCE`)||this.appendValueInput(`INSTANCE`).setAlign(b.Align.RIGHT).appendField(`%{BKY_APP_INSTANCE}`).setCheck(`String`);else if(this.getInput(`INSTANCE`)){let e=this.getInput(`INSTANCE`).connection.targetBlock();e&&e.dispose(),this.removeInput(`INSTANCE`)}},updateShadow_:function(){if(this.isInsertionMarker())return;let e=mr(this.property.id);if(!e)return;let t=this.getInput(`INSTANCE`);if(t){t.setShadowDom(null);let e=t.connection?.targetBlock();e&&e.dispose(),t.setShadowDom(H(`string`))}let n=this.getInput(`VALUE`);if(n){n.setShadowDom(null);let t=n.connection?.targetBlock();t&&t.dispose(),e.meta.element?n.setCheck(rn(e.meta.raw)).setShadowDom(xn(e.meta.raw)):n.setCheck(B(e.meta.raw.type)).setShadowDom(H(e.meta.raw.type))}},checkWarning_:function(){let e=W(this.node.id);if(!e){this.setWarningText(F(`WARN_NODE_NOT_FOUND`));return}if(e.key!==this.node.key){this.setWarningText(F(`WARN_NODE_HAS_CHANGED`));return}e.alias!==this.node.alias&&(this.node.alias=e.alias);let t=mr(this.property.id);if(!t){this.setWarningText(F(`WARN_PROPERTY_NOT_FOUND`));return}if(t.kind!==this.property.kind){this.setWarningText(F(`WARN_PROPERTY_HAS_CHANGED`));return}y(t.names,this.property.names)||(this.property.names=t.names),this.setWarningText(null)}},x.forBlock.set_app_property_v1=function(e){let t=x.quote_,n=e,r=`''`;switch(n.property.kind){case`multipleRefProperty`:case`multipleCustomSlotProperty`:r=x.valueToCode(n,`INSTANCE`,_.NONE)||`''`}let i=x.valueToCode(n,`VALUE`,_.NONE);return`await __setPropertyV1__(${t(n.property.id)}, ${i}, ${r});\n`},S.get_app_state_v1={init:function(){this.state={id:``,name:``,type:`string`},this.appendDummyInput().appendField(`%{BKY_APP_V1_GET_APP_STATE_TITLE}`).appendField(new m(()=>this.genStateOpts_()),`STATE`),this.setOutput(!0,null),this.setStyle(`state_blocks`),this.setTooltip(`%{BKY_APP_V1_GET_APP_STATE_TOOLTIP}`),this.setHelpUrl(`%{BKY_APP_V1_GET_APP_STATE_HELPURL}`),this.initData_()},initData_:function(){if(this.state.id)return;let e=Rn()?.[0];if(!e)return;this.state.id=e.id,this.state.name=e.name,this.state.type=e.type;let t=this.getField(`STATE`);t.getOptions(!1),t.setValue(this.state.id)},saveExtraState:function(){return{state:this.state}},loadExtraState:function(e){this.state.id=e.state?.id??``,this.state.name=e.state?.name??``,this.state.type=e.state?.type??`string`,setTimeout(()=>{this.checkWarning_()},0)},genStateOpts_:function(){return Bn()},onchange:function(e){if(e.type===p.BLOCK_CHANGE){let t=e;t.blockId===this.id&&t.element===`field`&&t.name===`STATE`&&this.onStateChange_(t.newValue)}},onStateChange_:function(e){let t=zn(e);if(!t){console.assert(!1);return}this.state.id=t.id,this.state.name=t.name,this.state.type=t.type},checkWarning_:function(){let e=zn(this.state.id);if(!e){this.setWarningText(F(`WARN_STATE_NOT_FOUND`));return}if(e.name!==this.state.name&&(this.state.name=e.name),e.type!==this.state.type){this.setWarningText(F(`WARN_STATE_HAS_CHANGED`));return}this.setWarningText(null)}},x.forBlock.get_app_state_v1=function(e){let t=x.quote_;return[`await __getStateV1__(${t(e.state.id)})`,_.ATOMIC]},S.set_app_state_v1={init:function(){this.state={id:``,name:``,type:`string`},this.appendValueInput(`VALUE`).appendField(`%{BKY_APP_V1_SET_APP_STATE_TITLE}`).appendField(new m(()=>this.genStateOpts_()),`STATE`),this.setPreviousStatement(!0,null),this.setNextStatement(!0,null),this.setStyle(`state_blocks`),this.setTooltip(`%{BKY_APP_V1_SET_APP_STATE_TOOLTIP}`),this.setHelpUrl(`%{BKY_APP_V1_SET_APP_STATE_HELPURL}`),this.initData_(),this.isInFlyout&&this.updateShadow_()},initData_:function(){if(this.state.id)return;let e=Rn()?.[0];if(!e)return;this.state.id=e.id,this.state.name=e.name,this.state.type=e.type;let t=this.getField(`STATE`);t.getOptions(!1),t.setValue(this.state.id)},saveExtraState:function(){return{state:this.state}},loadExtraState:function(e){this.state.id=e.state?.id??``,this.state.name=e.state?.name??``,this.state.type=e.state?.type??`string`},genStateOpts_:function(){return Bn()},onchange:function(e){if(e.type===p.BLOCK_CHANGE){let t=e;t.blockId===this.id&&t.element===`field`&&t.name===`STATE`&&this.onStateChange_(t.newValue)}},onStateChange_:function(e){let t=zn(e);if(!t){console.assert(!1);return}this.state.id=t.id,this.state.name=t.name,this.state.type=t.type,this.updateShadow_()},updateShadow_:function(){if(this.isInsertionMarker())return;this.getInput(`VALUE`).setShadowDom(null);let e=this.getInput(`VALUE`).connection.targetBlock();e&&e.dispose();let t=B(this.state.type),n=H(this.state.type);this.getInput(`VALUE`).setCheck(t).setShadowDom(n)},checkWarning_:function(){let e=zn(this.state.id);if(!e){this.setWarningText(F(`WARN_STATE_NOT_FOUND`));return}if(e.name!==this.state.name&&(this.state.name=e.name),e.type!==this.state.type){this.setWarningText(F(`WARN_STATE_HAS_CHANGED`));return}this.setWarningText(null)}},x.forBlock.set_app_state_v1=function(e){let t=x.quote_,n=e,r=x.valueToCode(n,`VALUE`,_.NONE);return`await __setStateV1__(${t(n.state.id)}, ${r});\n`},h([{type:`color_blend_v1`,message0:`%{BKY_COLOR_V1_BLEND_TITLE}`,args0:[{type:`input_value`,name:`COLOR1`,check:`Color`,align:`RIGHT`},{type:`input_value`,name:`COLOR2`,check:`Color`,align:`RIGHT`},{type:`input_value`,name:`RATIO`,check:`Number`,align:`RIGHT`}],output:`Color`,style:`color_blocks`,tooltip:`%{BKY_COLOR_V1_BLEND_TOOLTIP}`,helpUrl:`%{BKY_COLOR_V1_BLEND_HELPURL}`}]),x.forBlock.color_blend_v1=function(e){let t=x.valueToCode(e,`COLOR1`,_.NONE)||`'#ffffff'`,n=x.valueToCode(e,`COLOR2`,_.NONE)||`'#000000'`,r=x.valueToCode(e,`RATIO`,_.NONE)||.5;return[`${x.provideFunction_(`colorBlend`,`
33
- function ${x.FUNCTION_NAME_PLACEHOLDER_}(c1, c2, ratio) {
32
+ `},y.set_app_method_output_v1={init:function(){this.node={id:``,key:``,alias:``},this.method={id:``,kind:``,names:[]},this.output={key:``,name:``,type:`string`},this.appendValueInput(`VALUE`).appendField(`%{BKY_APP_V1_SET_APP_METHOD_OUTPUT_TITLE}`).appendField(new b(()=>this.genNodeOpts_()),`NODE`).appendField(new b(()=>this.genMethodOpts_()),`METHOD`).appendField(new b(()=>this.genOutputOpts_()),`OUTPUT`),this.setPreviousStatement(!0,null),this.setNextStatement(!0,null),this.setStyle(`procedure_blocks`),this.setTooltip(`%{BKY_APP_V1_SET_APP_METHOD_OUTPUT_TOOLTIP}`),this.setHelpUrl(`%{BKY_APP_V1_SET_APP_METHOD_OUTPUT_HELPURL}`),this.initData_(),this.updateShape_(),this.updateShadows_()},initData_:function(){if(this.node.id)return;let e=In(`implementMethod`)?.[0];if(!e)return;this.node.id=e.id,this.node.key=e.key,this.node.alias=e.alias;let t=this.getField(`NODE`);t.getOptions(!1),t.setValue(this.node.id);let n=ir(this.node.id)?.[0];if(!n)return;this.method.id=n.id,this.method.kind=n.kind,this.method.names=n.names;let r=this.getField(`METHOD`);r.getOptions(!1),r.setValue(this.method.id);let i=sr(this.method.id)?.[0];if(!i)return;this.output.key=i.key,this.output.name=i.name,this.output.type=i.type;let a=this.getField(`OUTPUT`);a.getOptions(!1),a.setValue(this.output.key)},saveExtraState:function(){return{node:this.node,method:this.method,output:this.output}},loadExtraState:function(e){this.node.id=e.node?.id??``,this.node.key=e.node?.key??``,this.node.alias=e.node?.alias??``,this.method.id=e.method?.id??``,this.method.kind=e.method?.kind??``,this.method.names=e.method?.names??[],this.output.key=e.output?.key??``,this.output.name=e.output?.name??``,this.output.type=e.output?.type??``,this.updateShape_(),this.updateShadows_(),setTimeout(()=>{this.checkWarning_()},0)},genNodeOpts_:function(){return Ln(`implementMethod`)},genMethodOpts_:function(){return or(this.node.id)},genOutputOpts_:function(){return lr(this.method.id)},onchange:function(e){if(e.type===x.BLOCK_CHANGE){let t=e;t.blockId===this.id&&(t.element===`field`&&(t.name===`NODE`?this.onNodeChange_(t.newValue):t.name===`METHOD`?this.onMethodChange_(t.newValue):t.name===`OUTPUT`&&this.onOutputChange_(t.newValue)),setTimeout(()=>{this.checkWarning_()},0))}},onNodeChange_:function(e){let t=W(e);if(!t){console.assert(!1);return}let n=this.node.id!==t.id;this.node.id=t.id,this.node.key=t.key,this.node.alias=t.alias;let r=this.getField(`METHOD`);if(r.getOptions(!1),n){let e=ir(this.node.id)?.[0];r.setValue(e?.id??``)}r.setValue(r.getValue())},onMethodChange_:function(e){let t=ar(e);if(!t){console.assert(!1);return}let n=this.method.id!==t.id;this.method.id=t.id,this.method.kind=t.kind,this.method.names=t.names;let r=this.getField(`OUTPUT`);if(r.getOptions(!1),n||!cr(this.method.id,this.output.key)){let e=sr(this.method.id)?.[0];r.setValue(e?.key??``)}this.onOutputChange_(r.getValue())},onOutputChange_:function(e){let t=cr(this.method.id,e);if(!t){console.assert(!1);return}this.output.key=t.key,this.output.name=t.name,this.output.type=t.type},updateShape_:function(){let e=this.getInput(`VALUE`);e.connection.setShadowDom(null);let t=e.connection.targetBlock();t&&!t.isShadow()&&t.dispose();let n=B(this.output.type);e.setCheck(n)},updateShadows_:function(){if(this.isInsertionMarker())return;let e=H(this.output.type);this.getInput(`VALUE`).connection.setShadowDom(e)},checkWarning_:function(){let e=W(this.node.id);if(!e){this.setWarningText(F(`WARN_NODE_NOT_FOUND`));return}if(e.key!==this.node.key){this.setWarningText(F(`WARN_NODE_HAS_CHANGED`));return}e.alias!==this.node.alias&&(this.node.alias=e.alias);let t=ar(this.method.id);if(!t){this.setWarningText(F(`WARN_METHOD_NOT_FOUND`));return}if(t.kind!==this.method.kind){this.setWarningText(F(`WARN_METHOD_HAS_CHANGED`));return}t.names!==this.method.names&&(this.method.names=t.names);let n=cr(this.method.id,this.output.key);if(!n){this.setWarningText(F(`WARN_OUTPUT_NOT_FOUND`));return}if(n.name!==this.output.name&&(this.output.name=n.name),n.type!==this.output.type){this.setWarningText(F(`WARN_OUTPUT_HAS_CHANGED`));return}this.setWarningText(null)}},g.forBlock.set_app_method_output_v1=function(e){let t=g.quote_,n=e,r=g.valueToCode(n,`VALUE`,_.ATOMIC);if(r===void 0)switch(n.output.type){case`string`:r=`''`;break;case`number`:r=`0`;break;case`boolean`:r=`false`;break;case`array`:r=`[]`;break;case`object`:r=`{}`;break;default:r=`null`}return`__outputs__[${t(n.output.key)}] = ${r};\n`},t([{type:`app_env_is_v1`,message0:`%{BKY_APP_V1_APP_ENV_IS_TITLE}`,args0:[{type:`field_dropdown`,name:`ENV`,options:[[`%{BKY_APP_ENV_DEV}`,`dev`],[`%{BKY_APP_ENV_PROD}`,`prod`]]}],output:`Boolean`,style:`logic_blocks`,tooltip:`%{BKY_APP_V1_APP_ENV_IS_TOOLTIP}`,helpUrl:`%{BKY_APP_V1_APP_ENV_IS_HELPURL}`}]),g.forBlock.app_env_is_v1=function(e){return[`__getEnvV1__() === ${g.quote_(e.getFieldValue(`ENV`))}`,_.ATOMIC]},y.navigate_to_v1={init:function(){this.app={id:``,name:``},this.page={id:``,name:``},this.appendDummyInput().appendField(`%{BKY_APP_V1_NAVIGATE_TO_TITLE}`).appendField(new b(()=>this.genAppOpts_()),`APP`).appendField(new b(()=>this.genPageOpts_()),`PAGE`),this.setPreviousStatement(!0,null),this.setNextStatement(!0,null),this.setStyle(`procedure_blocks`),this.setTooltip(`%{BKY_APP_V1_NAVIGATE_TOOLTIP}`),this.setHelpUrl(`%{BKY_APP_V1_NAVIGATE_HELPURL}`),this.initData_()},initData_:function(){if(this.app.id)return;let e=On()?.[0];if(!e)return;this.app.id=e.id,this.app.name=e.name;let t=this.getField(`APP`);t.getOptions(!1),t.setValue(this.app.id);let n=ur(this.app.id)?.[0];if(!n)return;this.page.id=n.id,this.page.name=n.name;let r=this.getField(`PAGE`);r.getOptions(!1),r.setValue(this.page.id)},saveExtraState:function(){return{app:this.app,page:this.page}},loadExtraState:function(e){this.app.id=e.app?.id??``,this.app.name=e.app?.name??``,this.page.id=e.page?.id??``,this.page.name=e.page?.name??``,setTimeout(()=>{this.checkWarning_()},0)},genAppOpts_:function(){return An()},genPageOpts_:function(){return fr(this.app.id)},onchange:function(e){if(e.type===x.BLOCK_CHANGE){let t=e;t.blockId===this.id&&(t.element===`field`&&(t.name===`APP`?this.onAppChange_(t.newValue):t.name===`PAGE`&&this.onPageChange_(t.newValue)),setTimeout(()=>{this.checkWarning_()},0))}},onAppChange_:function(e){let t=kn(e);if(!t){console.assert(!1);return}let n=this.app.id!==t.id;this.app.id=t.id,this.app.name=t.name;let r=this.getField(`PAGE`);if(r.getOptions(!1),n){let e=ur(this.app.id)?.[0];r.setValue(e?.id??``)}this.onPageChange_(r.getValue())},onPageChange_:function(e){let t=dr(this.app.id,e);if(!t){console.assert(!1);return}this.page.id=t.id,this.page.name=t.name},checkWarning_:function(){let e=kn(this.app.id);if(!e){this.setWarningText(F(`WARN_APP_NOT_FOUND`));return}e.name!==this.app.name&&(this.app.name=e.name);let t=dr(this.app.id,this.page.id);if(!t){this.setWarningText(F(`WARN_PAGE_NOT_FOUND`));return}t.name!==this.page.name&&(this.page.name=t.name),this.setWarningText(null)}},g.forBlock.navigate_to_v1=function(e){let t=e;return`__navigateToV1__(${g.quote_(t.app.id)}, ${g.quote_(t.page.id)});\n`},y.select_comp_v1={init:function(){this.comp={id:``,name:``},this.appendDummyInput().appendField(`%{BKY_APP_V1_SELECT_COMP_TITLE}`).appendField(new b(()=>this.genCompOpts_()),`COMP`),this.setOutput(!0,`Comp`),this.setStyle(`property_blocks`),this.setTooltip(`%{BKY_APP_V1_SELECT_COMP_TOOLTIP}`),this.setHelpUrl(`%{BKY_APP_V1_SELECT_COMP_HELPURL}`),this.initData_()},initData_:function(){if(this.comp.id)return;let e=Un()?.[0];if(!e)return;this.comp.id=e.id,this.comp.name=e.name;let t=this.getField(`COMP`);t.getOptions(!1),t.setValue(this.comp.id)},saveExtraState:function(){return{comp:this.comp}},loadExtraState:function(e){this.comp.id=e.comp?.id??``,this.comp.name=e.comp?.name??``,setTimeout(()=>{this.checkWarning_()},0)},genCompOpts_:function(){return Gn()},onchange:function(e){if(e.type===x.BLOCK_CHANGE){let t=e;t.blockId===this.id&&(t.element===`field`&&t.name===`COMP`&&this.onCompChange_(t.newValue),setTimeout(()=>{this.checkWarning_()},0))}},onCompChange_:function(e){let t=Wn(e);if(!t){console.assert(!1);return}this.comp.id=t.id,this.comp.name=t.name},checkWarning_:function(){let e=Wn(this.comp.id);if(!e){this.setWarningText(F(`WARN_COMP_NOT_FOUND`));return}e.name!==this.comp.name&&(this.comp.name=e.name),this.setWarningText(null)}},g.forBlock.select_comp_v1=function(e){let t=g.quote_,n=e,r=n.comp.id,i=n.comp.name;return[`{id:${t(r)},name:${t(i)}}`,_.ATOMIC]},y.select_slot_v1={init:function(){this.slot={id:``,name:``},this.appendDummyInput().appendField(`%{BKY_APP_V1_SELECT_SLOT_TITLE}`).appendField(new b(()=>this.genSlotOpts_()),`SLOT`),this.setOutput(!0,`Slot`),this.setStyle(`property_blocks`),this.setTooltip(`%{BKY_APP_V1_SELECT_SLOT_TOOLTIP}`),this.setHelpUrl(`%{BKY_APP_V1_SELECT_SLOT_HELPURL}`),this.initData_()},initData_:function(){if(this.slot.id)return;let e=gr()?.[0];if(!e)return;this.slot.id=e.id,this.slot.name=e.name;let t=this.getField(`SLOT`);t.getOptions(!1),t.setValue(this.slot.id)},saveExtraState:function(){return{slot:this.slot}},loadExtraState:function(e){this.slot.id=e.slot?.id??``,this.slot.name=e.slot?.name??``,setTimeout(()=>{this.checkWarning_()},0)},genSlotOpts_:function(){return vr()},onchange:function(e){if(e.type===x.BLOCK_CHANGE){let t=e;t.blockId===this.id&&(t.element===`field`&&t.name===`SLOT`&&this.onSlotChange_(t.newValue),setTimeout(()=>{this.checkWarning_()},0))}},onSlotChange_:function(e){let t=_r(e);if(!t){console.assert(!1);return}this.slot.id=t.id,this.slot.name=t.name},checkWarning_:function(){let e=_r(this.slot.id);if(!e){this.setWarningText(F(`WARN_SLOT_NOT_FOUND`));return}e.name!==this.slot.name&&(this.slot.name=e.name),this.setWarningText(null)}},g.forBlock.select_slot_v1=function(e){let t=g.quote_,n=e,r=n.slot.id,i=n.slot.name;return[`{id:${t(r)},name:${t(i)}}`,_.ATOMIC]},y.get_app_property_v1={init:function(){this.node={id:``,key:``,alias:``},this.property={id:``,kind:``,names:[]},this.appendDummyInput().appendField(`%{BKY_APP_V1_GET_APP_PROPERTY_TITLE}`).appendField(new b(()=>this.genNodeOpts_()),`NODE`).appendField(new b(()=>this.genPropertyOpts_()),`PROPERTY`),this.setOutput(!0,null),this.setInputsInline(!0),this.setStyle(`property_blocks`),this.setTooltip(`%{BKY_APP_V1_GET_APP_PROPERTY_TOOLTIP}`),this.setHelpUrl(`%{BKY_APP_V1_GET_APP_PROPERTY_HELPURL}`),this.initData_(),this.updateShape_()},initData_:function(){if(this.node.id)return;let e=In(`getProperty`)?.[0];if(!e)return;this.node.id=e.id,this.node.key=e.key,this.node.alias=e.alias;let t=this.getField(`NODE`);t.getOptions(!1),t.setValue(this.node.id);let n=pr(this.node.id,`read`)?.[0];if(!n)return;this.property.id=n.id,this.property.kind=n.kind,this.property.names=n.names;let r=this.getField(`PROPERTY`);r.getOptions(!1),r.setValue(this.property.id)},saveExtraState:function(){return{node:this.node,property:this.property}},loadExtraState:function(e){this.node.id=e.node?.id??``,this.node.key=e.node?.key??``,this.node.alias=e.node?.alias??``,this.property.id=e.property?.id??``,this.property.kind=e.property?.kind??``,this.property.names=e.property?.names??[],this.updateShape_(),setTimeout(()=>{this.checkWarning_()},0)},genNodeOpts_:function(){return Ln(`getProperty`)},genPropertyOpts_:function(){return hr(this.node.id,`read`)},onchange:function(e){if(e.type===x.BLOCK_CHANGE){let t=e;t.blockId===this.id&&(t.element===`field`&&(t.name===`NODE`?this.onNodeChange_(t.newValue):t.name===`PROPERTY`&&this.onPropertyChange_(t.newValue)),setTimeout(()=>{this.checkWarning_()},0))}},onNodeChange_:function(e){let t=W(e);if(!t){console.assert(!1);return}let n=this.node.id!==t.id;this.node.id=t.id,this.node.key=t.key,this.node.alias=t.alias;let r=this.getField(`PROPERTY`);if(r.getOptions(!1),n){let e=pr(this.node.id,`read`)?.[0];r.setValue(e?.id??``)}this.onPropertyChange_(r.getValue())},onPropertyChange_:function(e){let t=mr(e);if(!t){console.assert(!1);return}this.property.id=t.id,this.property.kind=t.kind,this.property.names=t.names,this.updateShape_(),this.updateShadow_()},updateShape_:function(){let e=!1;switch(this.property.kind){case`multipleRefProperty`:case`multipleCustomSlotProperty`:e=!0}if(e)this.getInput(`INSTANCE`)||this.appendValueInput(`INSTANCE`).setAlign(u.Align.RIGHT).appendField(`%{BKY_APP_INSTANCE}`).setCheck(`String`);else if(this.getInput(`INSTANCE`)){let e=this.getInput(`INSTANCE`).connection.targetBlock();e&&e.dispose(),this.removeInput(`INSTANCE`)}},updateShadow_:function(){if(this.isInsertionMarker())return;let e=this.getInput(`INSTANCE`);if(e){e.setShadowDom(null);let t=e.connection?.targetBlock();t&&t.dispose(),e.setShadowDom(H(`string`))}},checkWarning_:function(){let e=W(this.node.id);if(!e){this.setWarningText(F(`WARN_NODE_NOT_FOUND`));return}if(e.key!==this.node.key){this.setWarningText(F(`WARN_NODE_HAS_CHANGED`));return}e.alias!==this.node.alias&&(this.node.alias=e.alias);let t=mr(this.property.id);if(!t){this.setWarningText(F(`WARN_PROPERTY_NOT_FOUND`));return}if(t.kind!==this.property.kind){this.setWarningText(F(`WARN_PROPERTY_HAS_CHANGED`));return}v(t.names,this.property.names)||(this.property.names=t.names),this.setWarningText(null)}},g.forBlock.get_app_property_v1=function(e){let t=g.quote_,n=e,r=`''`;return n.getInput(`INSTANCE`)&&(r=g.valueToCode(n,`INSTANCE`,_.NONE)||`''`),[`__getPropertyV1__(${t(n.property.id)}, ${r})`,_.ATOMIC]},y.set_app_property_v1={init:function(){this.node={id:``,key:``,alias:``},this.property={id:``,kind:``,names:[]},this.appendValueInput(`VALUE`).appendField(`%{BKY_APP_V1_SET_APP_PROPERTY_TITLE}`).appendField(new b(()=>this.genNodeOpts_()),`NODE`).appendField(new b(()=>this.genPropertyOpts_()),`PROPERTY`),this.setPreviousStatement(!0,null),this.setNextStatement(!0,null),this.setInputsInline(!0),this.setStyle(`property_blocks`),this.setTooltip(`%{BKY_APP_V1_SET_APP_PROPERTY_TOOLTIP}`),this.setHelpUrl(`%{BKY_APP_V1_SET_APP_PROPERTY_HELPURL}`),this.initData_(),this.updateShape_(),this.isInFlyout&&this.updateShadow_()},initData_:function(){if(this.node.id)return;let e=In(`setProperty`)?.[0];if(!e)return;this.node.id=e.id,this.node.key=e.key,this.node.alias=e.alias;let t=this.getField(`NODE`);t.getOptions(!1),t.setValue(this.node.id);let n=pr(this.node.id,`write`)?.[0];if(!n)return;this.property.id=n.id,this.property.kind=n.kind,this.property.names=n.names;let r=this.getField(`PROPERTY`);r.getOptions(!1),r.setValue(this.property.id)},saveExtraState:function(){return{node:this.node,property:this.property}},loadExtraState:function(e){this.node.id=e.node?.id??``,this.node.key=e.node?.key??``,this.node.alias=e.node?.alias??``,this.property.id=e.property?.id??``,this.property.kind=e.property?.kind??``,this.property.names=e.property?.names??[],this.updateShape_(),setTimeout(()=>{this.checkWarning_()},0)},genNodeOpts_:function(){return Ln(`setProperty`)},genPropertyOpts_:function(){return hr(this.node.id,`write`)},onchange:function(e){if(e.type===x.BLOCK_CHANGE){let t=e;t.blockId===this.id&&(t.element===`field`&&(t.name===`NODE`?this.onNodeChange_(t.newValue):t.name===`PROPERTY`&&this.onPropertyChange_(t.newValue)),setTimeout(()=>{this.checkWarning_()},0))}},onNodeChange_:function(e){let t=W(e);if(!t){console.assert(!1);return}let n=this.node.id!==t.id;this.node.id=t.id,this.node.key=t.key,this.node.alias=t.alias;let r=this.getField(`PROPERTY`);if(r.getOptions(!1),n){let e=pr(this.node.id,`write`)?.[0];r.setValue(e?.id??``)}this.onPropertyChange_(r.getValue())},onPropertyChange_:function(e){let t=mr(e);if(!t){console.assert(!1);return}this.property.id=t.id,this.property.kind=t.kind,this.property.names=t.names,this.updateShape_(),this.updateShadow_()},updateShape_:function(){let e=!1;switch(this.property.kind){case`multipleRefProperty`:case`multipleCustomSlotProperty`:e=!0}if(e)this.getInput(`INSTANCE`)||this.appendValueInput(`INSTANCE`).setAlign(u.Align.RIGHT).appendField(`%{BKY_APP_INSTANCE}`).setCheck(`String`);else if(this.getInput(`INSTANCE`)){let e=this.getInput(`INSTANCE`).connection.targetBlock();e&&e.dispose(),this.removeInput(`INSTANCE`)}},updateShadow_:function(){if(this.isInsertionMarker())return;let e=mr(this.property.id);if(!e)return;let t=this.getInput(`INSTANCE`);if(t){t.setShadowDom(null);let e=t.connection?.targetBlock();e&&e.dispose(),t.setShadowDom(H(`string`))}let n=this.getInput(`VALUE`);if(n){n.setShadowDom(null);let t=n.connection?.targetBlock();t&&t.dispose(),e.meta.element?n.setCheck(rn(e.meta.raw)).setShadowDom(xn(e.meta.raw)):n.setCheck(B(e.meta.raw.type)).setShadowDom(H(e.meta.raw.type))}},checkWarning_:function(){let e=W(this.node.id);if(!e){this.setWarningText(F(`WARN_NODE_NOT_FOUND`));return}if(e.key!==this.node.key){this.setWarningText(F(`WARN_NODE_HAS_CHANGED`));return}e.alias!==this.node.alias&&(this.node.alias=e.alias);let t=mr(this.property.id);if(!t){this.setWarningText(F(`WARN_PROPERTY_NOT_FOUND`));return}if(t.kind!==this.property.kind){this.setWarningText(F(`WARN_PROPERTY_HAS_CHANGED`));return}v(t.names,this.property.names)||(this.property.names=t.names),this.setWarningText(null)}},g.forBlock.set_app_property_v1=function(e){let t=g.quote_,n=e,r=`''`;switch(n.property.kind){case`multipleRefProperty`:case`multipleCustomSlotProperty`:r=g.valueToCode(n,`INSTANCE`,_.NONE)||`''`}let i=g.valueToCode(n,`VALUE`,_.NONE);return`await __setPropertyV1__(${t(n.property.id)}, ${i}, ${r});\n`},y.get_app_state_v1={init:function(){this.state={id:``,name:``,type:`string`},this.appendDummyInput().appendField(`%{BKY_APP_V1_GET_APP_STATE_TITLE}`).appendField(new b(()=>this.genStateOpts_()),`STATE`),this.setOutput(!0,null),this.setStyle(`state_blocks`),this.setTooltip(`%{BKY_APP_V1_GET_APP_STATE_TOOLTIP}`),this.setHelpUrl(`%{BKY_APP_V1_GET_APP_STATE_HELPURL}`),this.initData_()},initData_:function(){if(this.state.id)return;let e=Rn()?.[0];if(!e)return;this.state.id=e.id,this.state.name=e.name,this.state.type=e.type;let t=this.getField(`STATE`);t.getOptions(!1),t.setValue(this.state.id)},saveExtraState:function(){return{state:this.state}},loadExtraState:function(e){this.state.id=e.state?.id??``,this.state.name=e.state?.name??``,this.state.type=e.state?.type??`string`,setTimeout(()=>{this.checkWarning_()},0)},genStateOpts_:function(){return Bn()},onchange:function(e){if(e.type===x.BLOCK_CHANGE){let t=e;t.blockId===this.id&&t.element===`field`&&t.name===`STATE`&&this.onStateChange_(t.newValue)}},onStateChange_:function(e){let t=zn(e);if(!t){console.assert(!1);return}this.state.id=t.id,this.state.name=t.name,this.state.type=t.type},checkWarning_:function(){let e=zn(this.state.id);if(!e){this.setWarningText(F(`WARN_STATE_NOT_FOUND`));return}if(e.name!==this.state.name&&(this.state.name=e.name),e.type!==this.state.type){this.setWarningText(F(`WARN_STATE_HAS_CHANGED`));return}this.setWarningText(null)}},g.forBlock.get_app_state_v1=function(e){let t=g.quote_;return[`await __getStateV1__(${t(e.state.id)})`,_.ATOMIC]},y.set_app_state_v1={init:function(){this.state={id:``,name:``,type:`string`},this.appendValueInput(`VALUE`).appendField(`%{BKY_APP_V1_SET_APP_STATE_TITLE}`).appendField(new b(()=>this.genStateOpts_()),`STATE`),this.setPreviousStatement(!0,null),this.setNextStatement(!0,null),this.setStyle(`state_blocks`),this.setTooltip(`%{BKY_APP_V1_SET_APP_STATE_TOOLTIP}`),this.setHelpUrl(`%{BKY_APP_V1_SET_APP_STATE_HELPURL}`),this.initData_(),this.isInFlyout&&this.updateShadow_()},initData_:function(){if(this.state.id)return;let e=Rn()?.[0];if(!e)return;this.state.id=e.id,this.state.name=e.name,this.state.type=e.type;let t=this.getField(`STATE`);t.getOptions(!1),t.setValue(this.state.id)},saveExtraState:function(){return{state:this.state}},loadExtraState:function(e){this.state.id=e.state?.id??``,this.state.name=e.state?.name??``,this.state.type=e.state?.type??`string`},genStateOpts_:function(){return Bn()},onchange:function(e){if(e.type===x.BLOCK_CHANGE){let t=e;t.blockId===this.id&&t.element===`field`&&t.name===`STATE`&&this.onStateChange_(t.newValue)}},onStateChange_:function(e){let t=zn(e);if(!t){console.assert(!1);return}this.state.id=t.id,this.state.name=t.name,this.state.type=t.type,this.updateShadow_()},updateShadow_:function(){if(this.isInsertionMarker())return;this.getInput(`VALUE`).setShadowDom(null);let e=this.getInput(`VALUE`).connection.targetBlock();e&&e.dispose();let t=B(this.state.type),n=H(this.state.type);this.getInput(`VALUE`).setCheck(t).setShadowDom(n)},checkWarning_:function(){let e=zn(this.state.id);if(!e){this.setWarningText(F(`WARN_STATE_NOT_FOUND`));return}if(e.name!==this.state.name&&(this.state.name=e.name),e.type!==this.state.type){this.setWarningText(F(`WARN_STATE_HAS_CHANGED`));return}this.setWarningText(null)}},g.forBlock.set_app_state_v1=function(e){let t=g.quote_,n=e,r=g.valueToCode(n,`VALUE`,_.NONE);return`await __setStateV1__(${t(n.state.id)}, ${r});\n`},t([{type:`color_blend_v1`,message0:`%{BKY_COLOR_V1_BLEND_TITLE}`,args0:[{type:`input_value`,name:`COLOR1`,check:`Color`,align:`RIGHT`},{type:`input_value`,name:`COLOR2`,check:`Color`,align:`RIGHT`},{type:`input_value`,name:`RATIO`,check:`Number`,align:`RIGHT`}],output:`Color`,style:`color_blocks`,tooltip:`%{BKY_COLOR_V1_BLEND_TOOLTIP}`,helpUrl:`%{BKY_COLOR_V1_BLEND_HELPURL}`}]),g.forBlock.color_blend_v1=function(e){let t=g.valueToCode(e,`COLOR1`,_.NONE)||`'#ffffff'`,n=g.valueToCode(e,`COLOR2`,_.NONE)||`'#000000'`,r=g.valueToCode(e,`RATIO`,_.NONE)||.5;return[`${g.provideFunction_(`colorBlend`,`
33
+ function ${g.FUNCTION_NAME_PLACEHOLDER_}(c1, c2, ratio) {
34
34
  ratio = Math.max(Math.min(ratio, 1), 0);
35
35
  var r1 = parseInt(c1.substring(1, 3), 16);
36
36
  var g1 = parseInt(c1.substring(3, 5), 16);
@@ -46,13 +46,13 @@ function ${x.FUNCTION_NAME_PLACEHOLDER_}(c1, c2, ratio) {
46
46
  b = ('0' + (b || 0).toString(16)).slice(-2);
47
47
  return '#' + r + g + b;
48
48
  }
49
- `)}(${t}, ${n}, ${r})`,_.FUNCTION_CALL]},h([{type:`color_picker_v1`,message0:`%1`,args0:[{type:`field_colour`,name:`COLOR`,colour:`#ff0000`,colourOptions:on,columns:14}],output:`Color`,style:`color_blocks`,tooltip:`%{BKY_COLOR_V1_PICKER_TOOLTIP}`,helpUrl:`%{BKY_COLOR_V1_PICKER_HELPURL}`}]),x.forBlock.color_picker_v1=function(e){return[x.quote_(e.getFieldValue(`COLOR`)),_.ATOMIC]},h([{type:`color_random_v1`,message0:`%{BKY_COLOR_V1_RANDOM_TITLE}`,output:`Color`,style:`color_blocks`,tooltip:`%{BKY_COLOR_V1_RANDOM_TOOLTIP}`,helpUrl:`%{BKY_COLOR_V1_RANDOM_HELPURL}`}]),x.forBlock.color_random_v1=function(){return[`${x.provideFunction_(`colorRandom`,`
50
- function ${x.FUNCTION_NAME_PLACEHOLDER_}() {
49
+ `)}(${t}, ${n}, ${r})`,_.FUNCTION_CALL]},t([{type:`color_picker_v1`,message0:`%1`,args0:[{type:`field_colour`,name:`COLOR`,colour:`#ff0000`,colourOptions:on,columns:14}],output:`Color`,style:`color_blocks`,tooltip:`%{BKY_COLOR_V1_PICKER_TOOLTIP}`,helpUrl:`%{BKY_COLOR_V1_PICKER_HELPURL}`}]),g.forBlock.color_picker_v1=function(e){return[g.quote_(e.getFieldValue(`COLOR`)),_.ATOMIC]},t([{type:`color_random_v1`,message0:`%{BKY_COLOR_V1_RANDOM_TITLE}`,output:`Color`,style:`color_blocks`,tooltip:`%{BKY_COLOR_V1_RANDOM_TOOLTIP}`,helpUrl:`%{BKY_COLOR_V1_RANDOM_HELPURL}`}]),g.forBlock.color_random_v1=function(){return[`${g.provideFunction_(`colorRandom`,`
50
+ function ${g.FUNCTION_NAME_PLACEHOLDER_}() {
51
51
  var num = Math.floor(Math.random() * Math.pow(2, 24));
52
52
  return '#' + ('00000' + num.toString(16)).substr(-6);
53
53
  }
54
- `)}()`,_.FUNCTION_CALL]},h([{type:`color_rgb_v1`,message0:`%{BKY_COLOR_V1_RGB_TITLE}`,args0:[{type:`input_value`,name:`RED`,check:`Number`,align:`RIGHT`},{type:`input_value`,name:`GREEN`,check:`Number`,align:`RIGHT`},{type:`input_value`,name:`BLUE`,check:`Number`,align:`RIGHT`}],output:`Color`,style:`color_blocks`,tooltip:`%{BKY_COLOR_V1_RGB_TOOLTIP}`,helpUrl:`%{BKY_COLOR_V1_RGB_HELPURL}`}]),x.forBlock.color_rgb_v1=function(e){let t=x.valueToCode(e,`RED`,_.NONE)||0,n=x.valueToCode(e,`GREEN`,_.NONE)||0,r=x.valueToCode(e,`BLUE`,_.NONE)||0;return[`${x.provideFunction_(`colorRgb`,`
55
- function ${x.FUNCTION_NAME_PLACEHOLDER_}(r, g, b) {
54
+ `)}()`,_.FUNCTION_CALL]},t([{type:`color_rgb_v1`,message0:`%{BKY_COLOR_V1_RGB_TITLE}`,args0:[{type:`input_value`,name:`RED`,check:`Number`,align:`RIGHT`},{type:`input_value`,name:`GREEN`,check:`Number`,align:`RIGHT`},{type:`input_value`,name:`BLUE`,check:`Number`,align:`RIGHT`}],output:`Color`,style:`color_blocks`,tooltip:`%{BKY_COLOR_V1_RGB_TOOLTIP}`,helpUrl:`%{BKY_COLOR_V1_RGB_HELPURL}`}]),g.forBlock.color_rgb_v1=function(e){let t=g.valueToCode(e,`RED`,_.NONE)||0,n=g.valueToCode(e,`GREEN`,_.NONE)||0,r=g.valueToCode(e,`BLUE`,_.NONE)||0;return[`${g.provideFunction_(`colorRgb`,`
55
+ function ${g.FUNCTION_NAME_PLACEHOLDER_}(r, g, b) {
56
56
  r = Math.max(Math.min(r, 100), 0) * 2.55;
57
57
  g = Math.max(Math.min(g, 100), 0) * 2.55;
58
58
  b = Math.max(Math.min(b, 100), 0) * 2.55;
@@ -61,22 +61,22 @@ function ${x.FUNCTION_NAME_PLACEHOLDER_}(r, g, b) {
61
61
  b = ('0' + (Math.round(b) || 0).toString(16)).slice(-2);
62
62
  return '#' + r + g + b;
63
63
  }
64
- `)}(${t}, ${n}, ${r})`,_.FUNCTION_CALL]},S.on_flow_state_event_v1={init:function(){}},x.forBlock.on_flow_state_event_v1=function(){return`__onFlowStateEventV1__();
65
- `};function br(e){let t=C.compute.spaces.find(t=>t.id===e);return t?t.funcs:[]}function xr(e,t){let n=C.compute.spaces.find(t=>t.id===e);if(n)return n.funcs.find(e=>e.id===t)}function Sr(e){let t=[];return br(e).forEach(({id:e,name:n})=>{t.push([n,e])}),I(t)}function Cr(){return C.compute.activeFunc}function wr(e){let{activeFunc:t}=C.compute;return t.outputs?.find(t=>t.id===e)}function Tr(){let{activeFunc:e}=C.compute,t=[];return e.outputs?.forEach(({id:e,name:n})=>{t.push([n,e])}),I(t)}function Er(e){let t=[];return C.compute.spaces.forEach(n=>{e===`func`&&n.funcs.length>0&&t.push(n),e===`flow`&&n.flows.length>0&&t.push(n)}),t}function Dr(e){return C.compute.spaces.find(t=>t.id===e)}function Or(e){let t=[];return Er(e).forEach(({id:e,name:n})=>{t.push([n,e])}),I(t)}S.call_func_v1={init:function(){this.space={id:``,name:``},this.func={id:``,name:``,inputs:[],outputs:[]},this.appendDummyInput().appendField(`%{BKY_COMPUTE_CALL}`).appendField(new m(()=>this.genSpaceOpts_()),`SPACE`).appendField(new m(()=>this.genFuncOpts_()),`FUNC`),this.setPreviousStatement(!0,null),this.setNextStatement(!0,null),this.setStyle(`procedure_blocks`),this.setTooltip(`%{BKY_COMPUTE_V1_CALL_FUNC_TOOLTIP}`),this.setHelpUrl(`%{BKY_COMPUTE_V1_CALL_FUNC_HELPURL}`),this.initData_()},initData_:function(){if(this.space.id)return;let e=Er(`func`)?.[0];if(!e)return;this.space.id=e.id,this.space.name=e.name;let t=this.getField(`SPACE`);t.getOptions(!1),t.setValue(this.space.id);let n=br(this.space.id)?.[0];if(!n)return;this.func.id=n.id,this.func.name=n.name,this.func.inputs=n.inputs,this.func.outputs=n.outputs;let r=this.getField(`FUNC`);r.getOptions(!1),r.setValue(this.func.id)},saveExtraState:function(){return{space:this.space,func:this.func}},loadExtraState:function(e){this.space.id=e.space?.id??``,this.space.name=e.space?.name??``,this.func.id=e.func?.id??``,this.func.name=e.func?.name??``,this.func.inputs=e.func?.inputs??[],this.func.outputs=e.func?.outputs??[],this.updateShape_(),this.updateCheck_(),this.updateShadow_(),setTimeout(()=>{this.ensureBlocks_(),this.checkWarning_()},0)},genSpaceOpts_:function(){return Or(`func`)},genFuncOpts_:function(){return Sr(this.space.id)},onchange:function(e){if(e.type===p.BLOCK_CHANGE){let t=e;t.blockId===this.id&&(t.element===`field`&&(t.name===`SPACE`?this.onSpaceChange_(t.newValue):t.name===`FUNC`&&this.onFuncChange_(t.newValue)),setTimeout(()=>{this.checkWarning_()},0))}},onSpaceChange_:function(e){let t=Dr(e);if(!t){console.assert(!1);return}let n=t.id!==this.space.id;this.space.id=t.id,this.space.name=t.name;let r=this.getField(`FUNC`);if(r.getOptions(!1),n){let e=br(this.space.id)?.[0];r.setValue(e?.id??``)}this.onFuncChange_(r.getValue())},onFuncChange_:function(e){let t=xr(this.space.id,e);if(!t){console.assert(!1);return}this.func.id=t.id,this.func.inputs=t.inputs,this.func.outputs=t.outputs,this.updateShape_(),this.updateCheck_(),this.updateShadow_(),setTimeout(()=>{this.ensureBlocks_(),this.checkWarning_()},0)},updateShape_:function(){this.getInput(`CALLBACK`)||this.appendStatementInput(`CALLBACK`).appendField(`%{BKY_COMPUTE_DO}`);for(let e=this.func.outputs.length;this.getInput(`OUTPUT`+e);e++){let t=this.getInput(`OUTPUT`+e)?.connection?.targetBlock();t&&t.dispose(),this.removeInput(`OUTPUT`+e)}for(let e=0;e<this.func.outputs.length;e++){if(this.getInput(`OUTPUT`+e))continue;let t=this.appendValueInput(`OUTPUT`+e);e==0&&t.appendField(`%{BKY_COMPUTE_CALLBACK}`),this.moveInputBefore(`OUTPUT`+e,`CALLBACK`)}for(let e=this.func.inputs.length;this.getInput(`INPUT`+e);e++){let t=this.getInput(`INPUT`+e)?.connection?.targetBlock();t&&t.dispose(),this.removeInput(`INPUT`+e)}for(let e=0;e<this.func.inputs.length;e++){let{name:t}=this.func.inputs[e],n=this.getInput(`INPUT`+e);n?(this.setFieldValue(t,`NAME`+e),n.setCheck(null)):(this.appendValueInput(`INPUT`+e).setAlign(b.Align.RIGHT).appendField(t,`NAME`+e).setCheck(null),this.getInput(`OUTPUT0`)?this.moveInputBefore(`INPUT`+e,`OUTPUT0`):this.moveInputBefore(`INPUT`+e,`CALLBACK`))}},updateCheck_:function(){for(let e=0;e<this.func.inputs.length;e++){let{type:t}=this.func.inputs[e],n=B(t);this.getInput(`INPUT`+e).connection.setCheck(n)}},updateShadow_:function(){if(!this.isInsertionMarker())for(let e=0;e<this.func.inputs.length;e++){let t=this.func.inputs[e],n=H(t.type);this.getInput(`INPUT`+e).setShadowDom(n)}},ensureBlocks_:function(){if(this.isInsertionMarker())return;let e=[];for(let t=0;t<this.func.outputs.length;t++){let{id:n,name:r}=this.func.outputs[t];e.push([`OUTPUT`+t,`__output$${n}__`,r,!1])}V(this,e)},checkWarning_:function(){let e=Dr(this.space.id);if(!e){this.setWarningText(F(`WARN_SPACE_NOT_FOUND`));return}e.name!==this.space.name&&(this.space.name=e.name);let t=xr(this.space.id,this.func.id);if(!t){this.setWarningText(F(`WARN_FUNC_NOT_FOUND`));return}if(!y(t.inputs,this.func.inputs)){this.setWarningText(F(`WARN_FUNC_HAS_CHANGED`));return}if(!y(t.outputs,this.func.outputs)){this.setWarningText(F(`WARN_FUNC_HAS_CHANGED`));return}this.setWarningText(null)}},x.forBlock.call_func_v1=function(e){let t=x.INDENT,n=x.quote_,r=e,i=n(r.space.id),a=n(r.func.id),o=``;o+=`${t}var __inputs__ = {\n`,r.func.inputs.forEach(({id:e},i)=>{let a=x.valueToCode(r,`INPUT`+i,_.ATOMIC);o+=`${t}${t}${n(e)}: ${a},\n`}),o+=`${t}};`;let s=n(r.space.name+`/`+r.func.name),c=``;r.func.outputs.forEach(({id:e})=>{c+=`${t}var __output${e}__ = __result__[${n(e)}];\n`});let l=x.statementToCode(r,`CALLBACK`);return`{
64
+ `)}(${t}, ${n}, ${r})`,_.FUNCTION_CALL]},y.on_flow_state_event_v1={init:function(){}},g.forBlock.on_flow_state_event_v1=function(){return`__onFlowStateEventV1__();
65
+ `};function br(e){let t=S.compute.spaces.find(t=>t.id===e);return t?t.funcs:[]}function xr(e,t){let n=S.compute.spaces.find(t=>t.id===e);if(n)return n.funcs.find(e=>e.id===t)}function Sr(e){let t=[];return br(e).forEach(({id:e,name:n})=>{t.push([n,e])}),I(t)}function Cr(){return S.compute.activeFunc}function wr(e){let{activeFunc:t}=S.compute;return t.outputs?.find(t=>t.id===e)}function Tr(){let{activeFunc:e}=S.compute,t=[];return e.outputs?.forEach(({id:e,name:n})=>{t.push([n,e])}),I(t)}function Er(e){let t=[];return S.compute.spaces.forEach(n=>{e===`func`&&n.funcs.length>0&&t.push(n),e===`flow`&&n.flows.length>0&&t.push(n)}),t}function Dr(e){return S.compute.spaces.find(t=>t.id===e)}function Or(e){let t=[];return Er(e).forEach(({id:e,name:n})=>{t.push([n,e])}),I(t)}y.call_func_v1={init:function(){this.space={id:``,name:``},this.func={id:``,name:``,inputs:[],outputs:[]},this.appendDummyInput().appendField(`%{BKY_COMPUTE_CALL}`).appendField(new b(()=>this.genSpaceOpts_()),`SPACE`).appendField(new b(()=>this.genFuncOpts_()),`FUNC`),this.setPreviousStatement(!0,null),this.setNextStatement(!0,null),this.setStyle(`procedure_blocks`),this.setTooltip(`%{BKY_COMPUTE_V1_CALL_FUNC_TOOLTIP}`),this.setHelpUrl(`%{BKY_COMPUTE_V1_CALL_FUNC_HELPURL}`),this.initData_()},initData_:function(){if(this.space.id)return;let e=Er(`func`)?.[0];if(!e)return;this.space.id=e.id,this.space.name=e.name;let t=this.getField(`SPACE`);t.getOptions(!1),t.setValue(this.space.id);let n=br(this.space.id)?.[0];if(!n)return;this.func.id=n.id,this.func.name=n.name,this.func.inputs=n.inputs,this.func.outputs=n.outputs;let r=this.getField(`FUNC`);r.getOptions(!1),r.setValue(this.func.id)},saveExtraState:function(){return{space:this.space,func:this.func}},loadExtraState:function(e){this.space.id=e.space?.id??``,this.space.name=e.space?.name??``,this.func.id=e.func?.id??``,this.func.name=e.func?.name??``,this.func.inputs=e.func?.inputs??[],this.func.outputs=e.func?.outputs??[],this.updateShape_(),this.updateCheck_(),this.updateShadow_(),setTimeout(()=>{this.ensureBlocks_(),this.checkWarning_()},0)},genSpaceOpts_:function(){return Or(`func`)},genFuncOpts_:function(){return Sr(this.space.id)},onchange:function(e){if(e.type===x.BLOCK_CHANGE){let t=e;t.blockId===this.id&&(t.element===`field`&&(t.name===`SPACE`?this.onSpaceChange_(t.newValue):t.name===`FUNC`&&this.onFuncChange_(t.newValue)),setTimeout(()=>{this.checkWarning_()},0))}},onSpaceChange_:function(e){let t=Dr(e);if(!t){console.assert(!1);return}let n=t.id!==this.space.id;this.space.id=t.id,this.space.name=t.name;let r=this.getField(`FUNC`);if(r.getOptions(!1),n){let e=br(this.space.id)?.[0];r.setValue(e?.id??``)}this.onFuncChange_(r.getValue())},onFuncChange_:function(e){let t=xr(this.space.id,e);if(!t){console.assert(!1);return}this.func.id=t.id,this.func.inputs=t.inputs,this.func.outputs=t.outputs,this.updateShape_(),this.updateCheck_(),this.updateShadow_(),setTimeout(()=>{this.ensureBlocks_(),this.checkWarning_()},0)},updateShape_:function(){this.getInput(`CALLBACK`)||this.appendStatementInput(`CALLBACK`).appendField(`%{BKY_COMPUTE_DO}`);for(let e=this.func.outputs.length;this.getInput(`OUTPUT`+e);e++){let t=this.getInput(`OUTPUT`+e)?.connection?.targetBlock();t&&t.dispose(),this.removeInput(`OUTPUT`+e)}for(let e=0;e<this.func.outputs.length;e++){if(this.getInput(`OUTPUT`+e))continue;let t=this.appendValueInput(`OUTPUT`+e);e==0&&t.appendField(`%{BKY_COMPUTE_CALLBACK}`),this.moveInputBefore(`OUTPUT`+e,`CALLBACK`)}for(let e=this.func.inputs.length;this.getInput(`INPUT`+e);e++){let t=this.getInput(`INPUT`+e)?.connection?.targetBlock();t&&t.dispose(),this.removeInput(`INPUT`+e)}for(let e=0;e<this.func.inputs.length;e++){let{name:t}=this.func.inputs[e],n=this.getInput(`INPUT`+e);n?(this.setFieldValue(t,`NAME`+e),n.setCheck(null)):(this.appendValueInput(`INPUT`+e).setAlign(u.Align.RIGHT).appendField(t,`NAME`+e).setCheck(null),this.getInput(`OUTPUT0`)?this.moveInputBefore(`INPUT`+e,`OUTPUT0`):this.moveInputBefore(`INPUT`+e,`CALLBACK`))}},updateCheck_:function(){for(let e=0;e<this.func.inputs.length;e++){let{type:t}=this.func.inputs[e],n=B(t);this.getInput(`INPUT`+e).connection.setCheck(n)}},updateShadow_:function(){if(!this.isInsertionMarker())for(let e=0;e<this.func.inputs.length;e++){let t=this.func.inputs[e],n=H(t.type);this.getInput(`INPUT`+e).setShadowDom(n)}},ensureBlocks_:function(){if(this.isInsertionMarker())return;let e=[];for(let t=0;t<this.func.outputs.length;t++){let{id:n,name:r}=this.func.outputs[t];e.push([`OUTPUT`+t,`__output$${n}__`,r,!1])}V(this,e)},checkWarning_:function(){let e=Dr(this.space.id);if(!e){this.setWarningText(F(`WARN_SPACE_NOT_FOUND`));return}e.name!==this.space.name&&(this.space.name=e.name);let t=xr(this.space.id,this.func.id);if(!t){this.setWarningText(F(`WARN_FUNC_NOT_FOUND`));return}if(!v(t.inputs,this.func.inputs)){this.setWarningText(F(`WARN_FUNC_HAS_CHANGED`));return}if(!v(t.outputs,this.func.outputs)){this.setWarningText(F(`WARN_FUNC_HAS_CHANGED`));return}this.setWarningText(null)}},g.forBlock.call_func_v1=function(e){let t=g.INDENT,n=g.quote_,r=e,i=n(r.space.id),a=n(r.func.id),o=``;o+=`${t}var __inputs__ = {\n`,r.func.inputs.forEach(({id:e},i)=>{let a=g.valueToCode(r,`INPUT`+i,_.ATOMIC);o+=`${t}${t}${n(e)}: ${a},\n`}),o+=`${t}};`;let s=n(r.space.name+`/`+r.func.name),c=``;r.func.outputs.forEach(({id:e})=>{c+=`${t}var __output${e}__ = __result__[${n(e)}];\n`});let l=g.statementToCode(r,`CALLBACK`);return`{
66
66
  ${o}
67
67
  ${t}var __result__ = __callFuncV1__(${i},${a},__inputs__,__getEnvV1__(),${s});
68
68
  ${c}${l}}
69
- `},S.call_func_internal_v1={init:function(){this.space={id:``,name:``},this.func={id:``,name:``,inputs:[],outputs:[]},this.appendDummyInput().appendField(`%{BKY_COMPUTE_CALL}`).appendField(new m(()=>this.genSpaceOpts_()),`SPACE`).appendField(new m(()=>this.genFuncOpts_()),`FUNC`),this.setPreviousStatement(!0,null),this.setNextStatement(!0,null),this.setStyle(`procedure_blocks`),this.setTooltip(`%{BKY_COMPUTE_V1_CALL_FUNC_INTERNAL_TOOLTIP}`),this.setHelpUrl(`%{BKY_COMPUTE_V1_CALL_FUNC_INTERNAL_HELPURL}`),this.initData_()},initData_:function(){if(this.space.id)return;let e=Er(`func`)?.[0];if(!e)return;this.space.id=e.id,this.space.name=e.name;let t=this.getField(`SPACE`);t.getOptions(!1),t.setValue(this.space.id);let n=br(this.space.id)?.[0];if(!n)return;this.func.id=n.id,this.func.name=n.name,this.func.inputs=n.inputs,this.func.outputs=n.outputs;let r=this.getField(`FUNC`);r.getOptions(!1),r.setValue(this.func.id)},saveExtraState:function(){return{space:this.space,func:this.func}},loadExtraState:function(e){this.space.id=e.space?.id??``,this.space.name=e.space?.name??``,this.func.id=e.func?.id??``,this.func.name=e.func?.name??``,this.func.inputs=e.func?.inputs??[],this.func.outputs=e.func?.outputs??[],this.updateShape_(),this.updateCheck_(),this.updateShadow_(),setTimeout(()=>{this.ensureBlocks_(),this.checkWarning_()},0)},genSpaceOpts_:function(){return Or(`func`)},genFuncOpts_:function(){return Sr(this.space.id)},onchange:function(e){if(e.type===p.BLOCK_CHANGE){let t=e;t.blockId===this.id&&(t.element===`field`&&(t.name===`SPACE`?this.onSpaceChange_(t.newValue):t.name===`FUNC`&&this.onFuncChange_(t.newValue)),setTimeout(()=>{this.checkWarning_()},0))}},onSpaceChange_:function(e){let t=Dr(e);if(!t){console.assert(!1);return}let n=t.id!==this.space.id;this.space.id=t.id,this.space.name=t.name;let r=this.getField(`FUNC`);if(r.getOptions(!1),n){let e=br(this.space.id)?.[0];r.setValue(e?.id??``)}this.onFuncChange_(r.getValue())},onFuncChange_:function(e){let t=xr(this.space.id,e);if(!t){console.assert(!1);return}this.func.id=t.id,this.func.inputs=t.inputs,this.func.outputs=t.outputs,this.updateShape_(),this.updateCheck_(),this.updateShadow_(),setTimeout(()=>{this.ensureBlocks_(),this.checkWarning_()},0)},updateShape_:function(){this.getInput(`CALLBACK`)||this.appendStatementInput(`CALLBACK`).appendField(`%{BKY_COMPUTE_DO}`);for(let e=this.func.outputs.length;this.getInput(`OUTPUT`+e);e++){let t=this.getInput(`OUTPUT`+e)?.connection?.targetBlock();t&&t.dispose(),this.removeInput(`OUTPUT`+e)}for(let e=0;e<this.func.outputs.length;e++){if(this.getInput(`OUTPUT`+e))continue;let t=this.appendValueInput(`OUTPUT`+e);e==0&&t.appendField(`%{BKY_COMPUTE_CALLBACK}`),this.moveInputBefore(`OUTPUT`+e,`CALLBACK`)}for(let e=this.func.inputs.length;this.getInput(`INPUT`+e);e++){let t=this.getInput(`INPUT`+e)?.connection?.targetBlock();t&&t.dispose(),this.removeInput(`INPUT`+e)}for(let e=0;e<this.func.inputs.length;e++){let{name:t}=this.func.inputs[e],n=this.getInput(`INPUT`+e);n?(this.setFieldValue(t,`NAME`+e),n.setCheck(null)):(this.appendValueInput(`INPUT`+e).setAlign(b.Align.RIGHT).appendField(t,`NAME`+e).setCheck(null),this.getInput(`OUTPUT0`)?this.moveInputBefore(`INPUT`+e,`OUTPUT0`):this.moveInputBefore(`INPUT`+e,`CALLBACK`))}},updateCheck_:function(){for(let e=0;e<this.func.inputs.length;e++){let{type:t}=this.func.inputs[e],n=B(t);this.getInput(`INPUT`+e).connection.setCheck(n)}},updateShadow_:function(){if(!this.isInsertionMarker())for(let e=0;e<this.func.inputs.length;e++){let t=this.func.inputs[e],n=H(t.type);this.getInput(`INPUT`+e).setShadowDom(n)}},ensureBlocks_:function(){if(this.isInsertionMarker())return;let e=[];for(let t=0;t<this.func.outputs.length;t++){let{id:n,name:r}=this.func.outputs[t];e.push([`OUTPUT`+t,`__output$${n}__`,r,!1])}V(this,e)},checkWarning_:function(){let e=Dr(this.space.id);if(!e){this.setWarningText(F(`WARN_SPACE_NOT_FOUND`));return}e.name!==this.space.name&&(this.space.name=e.name);let t=xr(this.space.id,this.func.id);if(!t){this.setWarningText(F(`WARN_FUNC_NOT_FOUND`));return}if(!y(t.inputs,this.func.inputs)){this.setWarningText(F(`WARN_FUNC_HAS_CHANGED`));return}if(!y(t.outputs,this.func.outputs)){this.setWarningText(F(`WARN_FUNC_HAS_CHANGED`));return}this.setWarningText(null)}},x.forBlock.call_func_internal_v1=function(e){let t=x.INDENT,n=x.quote_,r=e,i=n(r.space.id),a=n(r.func.id),o=`${t}var __inputs__ = {\n`;r.func.inputs.forEach(({id:e},i)=>{let a=x.valueToCode(r,`INPUT`+i,_.ATOMIC);o+=`${t}${t}${n(e)}: ${a},\n`}),o+=`${t}};`;let s=r.space.name+`/`+r.func.name,c=``;r.func.outputs.forEach(({id:e})=>{c+=`${t}var __output$${e}__ = __result__.outputs[${n(e)}];\n`});let l=x.statementToCode(r,`CALLBACK`);return`{
69
+ `},y.call_func_internal_v1={init:function(){this.space={id:``,name:``},this.func={id:``,name:``,inputs:[],outputs:[]},this.appendDummyInput().appendField(`%{BKY_COMPUTE_CALL}`).appendField(new b(()=>this.genSpaceOpts_()),`SPACE`).appendField(new b(()=>this.genFuncOpts_()),`FUNC`),this.setPreviousStatement(!0,null),this.setNextStatement(!0,null),this.setStyle(`procedure_blocks`),this.setTooltip(`%{BKY_COMPUTE_V1_CALL_FUNC_INTERNAL_TOOLTIP}`),this.setHelpUrl(`%{BKY_COMPUTE_V1_CALL_FUNC_INTERNAL_HELPURL}`),this.initData_()},initData_:function(){if(this.space.id)return;let e=Er(`func`)?.[0];if(!e)return;this.space.id=e.id,this.space.name=e.name;let t=this.getField(`SPACE`);t.getOptions(!1),t.setValue(this.space.id);let n=br(this.space.id)?.[0];if(!n)return;this.func.id=n.id,this.func.name=n.name,this.func.inputs=n.inputs,this.func.outputs=n.outputs;let r=this.getField(`FUNC`);r.getOptions(!1),r.setValue(this.func.id)},saveExtraState:function(){return{space:this.space,func:this.func}},loadExtraState:function(e){this.space.id=e.space?.id??``,this.space.name=e.space?.name??``,this.func.id=e.func?.id??``,this.func.name=e.func?.name??``,this.func.inputs=e.func?.inputs??[],this.func.outputs=e.func?.outputs??[],this.updateShape_(),this.updateCheck_(),this.updateShadow_(),setTimeout(()=>{this.ensureBlocks_(),this.checkWarning_()},0)},genSpaceOpts_:function(){return Or(`func`)},genFuncOpts_:function(){return Sr(this.space.id)},onchange:function(e){if(e.type===x.BLOCK_CHANGE){let t=e;t.blockId===this.id&&(t.element===`field`&&(t.name===`SPACE`?this.onSpaceChange_(t.newValue):t.name===`FUNC`&&this.onFuncChange_(t.newValue)),setTimeout(()=>{this.checkWarning_()},0))}},onSpaceChange_:function(e){let t=Dr(e);if(!t){console.assert(!1);return}let n=t.id!==this.space.id;this.space.id=t.id,this.space.name=t.name;let r=this.getField(`FUNC`);if(r.getOptions(!1),n){let e=br(this.space.id)?.[0];r.setValue(e?.id??``)}this.onFuncChange_(r.getValue())},onFuncChange_:function(e){let t=xr(this.space.id,e);if(!t){console.assert(!1);return}this.func.id=t.id,this.func.inputs=t.inputs,this.func.outputs=t.outputs,this.updateShape_(),this.updateCheck_(),this.updateShadow_(),setTimeout(()=>{this.ensureBlocks_(),this.checkWarning_()},0)},updateShape_:function(){this.getInput(`CALLBACK`)||this.appendStatementInput(`CALLBACK`).appendField(`%{BKY_COMPUTE_DO}`);for(let e=this.func.outputs.length;this.getInput(`OUTPUT`+e);e++){let t=this.getInput(`OUTPUT`+e)?.connection?.targetBlock();t&&t.dispose(),this.removeInput(`OUTPUT`+e)}for(let e=0;e<this.func.outputs.length;e++){if(this.getInput(`OUTPUT`+e))continue;let t=this.appendValueInput(`OUTPUT`+e);e==0&&t.appendField(`%{BKY_COMPUTE_CALLBACK}`),this.moveInputBefore(`OUTPUT`+e,`CALLBACK`)}for(let e=this.func.inputs.length;this.getInput(`INPUT`+e);e++){let t=this.getInput(`INPUT`+e)?.connection?.targetBlock();t&&t.dispose(),this.removeInput(`INPUT`+e)}for(let e=0;e<this.func.inputs.length;e++){let{name:t}=this.func.inputs[e],n=this.getInput(`INPUT`+e);n?(this.setFieldValue(t,`NAME`+e),n.setCheck(null)):(this.appendValueInput(`INPUT`+e).setAlign(u.Align.RIGHT).appendField(t,`NAME`+e).setCheck(null),this.getInput(`OUTPUT0`)?this.moveInputBefore(`INPUT`+e,`OUTPUT0`):this.moveInputBefore(`INPUT`+e,`CALLBACK`))}},updateCheck_:function(){for(let e=0;e<this.func.inputs.length;e++){let{type:t}=this.func.inputs[e],n=B(t);this.getInput(`INPUT`+e).connection.setCheck(n)}},updateShadow_:function(){if(!this.isInsertionMarker())for(let e=0;e<this.func.inputs.length;e++){let t=this.func.inputs[e],n=H(t.type);this.getInput(`INPUT`+e).setShadowDom(n)}},ensureBlocks_:function(){if(this.isInsertionMarker())return;let e=[];for(let t=0;t<this.func.outputs.length;t++){let{id:n,name:r}=this.func.outputs[t];e.push([`OUTPUT`+t,`__output$${n}__`,r,!1])}V(this,e)},checkWarning_:function(){let e=Dr(this.space.id);if(!e){this.setWarningText(F(`WARN_SPACE_NOT_FOUND`));return}e.name!==this.space.name&&(this.space.name=e.name);let t=xr(this.space.id,this.func.id);if(!t){this.setWarningText(F(`WARN_FUNC_NOT_FOUND`));return}if(!v(t.inputs,this.func.inputs)){this.setWarningText(F(`WARN_FUNC_HAS_CHANGED`));return}if(!v(t.outputs,this.func.outputs)){this.setWarningText(F(`WARN_FUNC_HAS_CHANGED`));return}this.setWarningText(null)}},g.forBlock.call_func_internal_v1=function(e){let t=g.INDENT,n=g.quote_,r=e,i=n(r.space.id),a=n(r.func.id),o=`${t}var __inputs__ = {\n`;r.func.inputs.forEach(({id:e},i)=>{let a=g.valueToCode(r,`INPUT`+i,_.ATOMIC);o+=`${t}${t}${n(e)}: ${a},\n`}),o+=`${t}};`;let s=r.space.name+`/`+r.func.name,c=``;r.func.outputs.forEach(({id:e})=>{c+=`${t}var __output$${e}__ = __result__.outputs[${n(e)}];\n`});let l=g.statementToCode(r,`CALLBACK`);return`{
70
70
  ${o}
71
71
  ${t}var __result__ = __callFuncInternalV1__(${i}, ${a}, __inputs__);
72
72
  ${t}if (!__result__.success) {
73
73
  ${t}${t}throw 'call func<${s}> failed, reason: ' + __result__.message;
74
74
  ${t}}
75
75
  ${c}${l}}
76
- `},S.func_entry_v1={init:function(){this.func={id:``},this.appendDummyInput().appendField(`%{BKY_COMPUTE_FUNC_ENTRY}`).appendField(``),this.appendStatementInput(`HANDLE`).appendField(`%{BKY_COMPUTE_DO}`),this.setStyle(`procedure_blocks`),this.setTooltip(`%{BKY_COMPUTE_V1_FUNC_ENTRY_TOOLTIP}`),this.setHelpUrl(`%{BKY_COMPUTE_V1_FUNC_ENTRY_HELPURL}`),this.initData_()},initData_:function(){if(this.func.id)return;let{id:e,inputs:t}=Cr();this.func.id=e,this.func.inputs=t},saveExtraState:function(){return{func:this.func}},loadExtraState:function(e){this.func.id=e.func?.id??``,this.func.inputs=e.func?.inputs,this.updateShape_(),setTimeout(()=>{this.ensureBlocks_()},0)},onchange:function(){setTimeout(()=>{this.checkWarning_()},0)},updateShape_:function(){for(let e=this.func.inputs?.length??0;this.getInput(`INPUT`+e);e++){let t=this.getInput(`INPUT`+e)?.connection?.targetBlock();t&&t.dispose(),this.removeInput(`INPUT`+e)}if(this.func.inputs)for(let e=0;e<this.func.inputs.length;e++)this.appendValueInput(`INPUT`+e),this.moveInputBefore(`INPUT`+e,`HANDLE`)},ensureBlocks_:function(){if(this.isInsertionMarker())return;let e=[];if(this.func.inputs)for(let t=0;t<this.func.inputs.length;t++){let{id:n,name:r}=this.func.inputs[t];e.push([`INPUT`+t,`__input$${n}__`,r,!1])}V(this,e)},checkWarning_:function(){let{id:e,inputs:t}=Cr();if(this.func.id!==e&&(this.func.id=e),!y(t,this.func.inputs)){this.setWarningText(F(`WARN_FUNC_HAS_CHANGED`));return}this.setWarningText(null)}},x.forBlock.func_entry_v1=function(e){let t=e,n=x.statementToCode(t,`HANDLE`),r=[];if(t.func.inputs)for(let e=0;e<t.func.inputs.length;e++){let{id:n}=t.func.inputs[e];r.push(`__input$${n}__`)}return`function __funcEntryV1__(${r.join(`, `)}) {
77
- ${n}}`},S.set_func_output_v1={init:function(){this.output={id:``,name:``,type:`string`},this.appendValueInput(`VALUE`).appendField(`%{BKY_COMPUTE_V1_SET_FUNC_OUTPUT_TITLE}`).appendField(new m(()=>this.genOutputOpts_()),`OUTPUT`),this.setPreviousStatement(!0,null),this.setNextStatement(!0,null),this.setStyle(`procedure_blocks`),this.setTooltip(`%{BKY_COMPUTE_V1_SET_FUNC_OUTPUT_TOOLTIP}`),this.setHelpUrl(`%{BKY_COMPUTE_V1_SET_FUNC_OUTPUT_HELPURL}`),this.initData_(),this.updateShape_(),this.updateShadows_()},initData_:function(){if(this.output.id)return;let e=Cr().outputs?.[0];e&&(this.output.id=e.id,this.output.name=e.name,this.output.type=e.type)},saveExtraState:function(){return{output:this.output}},loadExtraState:function(e){this.output.id=e.output?.id??``,this.output.name=e.output?.name??``,this.output.type=e.output?.type??``,this.updateShape_(),this.updateShadows_(),setTimeout(()=>{this.checkWarning_()},0)},genOutputOpts_:function(){return Tr()},onchange:function(e){if(e.type===p.BLOCK_CHANGE){let t=e;t.blockId===this.id&&(t.element===`field`&&t.name===`OUTPUT`&&this.onOutputChange_(t.newValue),setTimeout(()=>{this.checkWarning_()},0))}},onOutputChange_:function(e){let t=wr(e);if(!t){console.assert(!1);return}this.output.id=t.id,this.output.name=t.name,this.output.type=t.type,this.updateShape_(),this.updateShadows_()},updateShape_:function(){let e=this.getInput(`VALUE`);e.connection.setShadowDom(null);let t=e.connection.targetBlock();t&&!t.isShadow()&&t.dispose();let n=B(this.output.type);e.setCheck(n)},updateShadows_:function(){if(this.isInsertionMarker())return;let e=H(this.output.type);this.getInput(`VALUE`).setShadowDom(e)},checkWarning_:function(){let e=wr(this.output.id);if(!e){this.setWarningText(F(`WARN_FUNC_HAS_CHANGED`));return}if(e.name!==this.output.name&&(this.output.name=e.name),e.type!==this.output.type){this.setWarningText(F(`WARN_FUNC_HAS_CHANGED`));return}this.setWarningText(null)}},x.forBlock.set_func_output_v1=function(e){let t=x.quote_,n=e,{id:r,type:i}=n.output,a=x.valueToCode(n,`VALUE`,_.ATOMIC);if(a===void 0)switch(i){case`string`:a=`''`;break;case`number`:a=`0`;break;case`boolean`:a=`false`;break;case`array`:a=`[]`;break;case`object`:a=`{}`;break;default:a=`null`}return`__setFuncOutputV1__(${t(r)}, ${a});\n`},h([{type:`compute_debug_trace_v1`,message0:`%{BKY_COMPUTE_V1_COMPUTE_DEBUG_TRACE_TITLE}`,args0:[{type:`input_value`,name:`OBJECT`,check:null}],previousStatement:null,nextStatement:null,style:`procedure_blocks`,tooltip:`%{BKY_COMPUTE_V1_COMPUTE_DEBUG_TRACE_TOOLTIP}`,helpUrl:`%{BKY_COMPUTE_V1_COMPUTE_DEBUG_TRACE_HELPURL}`}]),x.forBlock.compute_debug_trace_v1=function(e){return`__debugTraceV1__(${x.valueToCode(e,`OBJECT`,_.ATOMIC)});\n`},h([{type:`compute_env_is_v1`,message0:`%{BKY_COMPUTE_V1_COMPUTE_ENV_IS_TITLE}`,args0:[{type:`field_dropdown`,name:`ENV`,options:[[`%{BKY_COMPUTE_ENV_DEV}`,`dev`],[`%{BKY_COMPUTE_ENV_PROD}`,`prod`]]}],output:`Boolean`,style:`logic_blocks`,tooltip:`%{BKY_COMPUTE_V1_COMPUTE_ENV_IS_TOOLTIP}`,helpUrl:`%{BKY_COMPUTE_V1_COMPUTE_ENV_IS_HELPURL}`}]),x.forBlock.compute_env_is_v1=function(e){return[`__getEnvV1__() === ${x.quote_(e.getFieldValue(`ENV`))}`,_.ATOMIC]};function Y(){let e=[];return C.data.spaces.forEach(t=>{t.tables.length>0&&e.push(t)}),e}function kr(e){let{spaces:t}=C.data;return t.find(t=>t.id===e)}function Ar(){let e=[];return Y().forEach(({id:t,name:n})=>{e.push([n,t])}),I(e)}function X(e){let{spaces:t}=C.data,n=t.find(t=>t.id===e);return n?n.tables:[]}function jr(e,t){let{spaces:n}=C.data,r=n.find(t=>t.id===e);if(r)return r.tables.find(e=>e.id===t)}function Mr(e){let t=[];return X(e).forEach(({id:e,name:n})=>{t.push([n,e])}),I(t)}function Nr(e,t){let{spaces:n}=C.data,r=n.find(t=>t.id===e);if(!r)return[];let i=r.tables.find(e=>e.id===t);return i?i.columns:[]}function Pr(e,t,n){let{spaces:r}=C.data,i=r.find(t=>t.id===e);if(!i)return;let a=i.tables.find(e=>e.id===t);if(a)return a.columns.find(e=>e.id===n)}function Fr(e,t){let n=[];return Nr(e,t).forEach(({id:e,name:t})=>{n.push([t,e])}),I(n)}function Ir(e){let t=e.getInput(`TABLE`).connection;if(t.targetBlock())return;let n,r,i=Y()?.[0];if(i){let e=X(i.id)?.[0];if(e){n={space:{id:i.id,name:i.name},table:{id:e.id,name:e.name,columns:e.columns},itemCount:e.columns.length},r={};for(let t=0;t<e.columns.length;t++){let n=e.columns[t];r[`COLUMN`+t]=n.id}}}let a={type:`update_column_v1`,extraState:n,fields:r},o=g.blocks.append(a,e.workspace);t.connect(o.outputConnection)}function Lr(e){let t=e.getInput(`HANDLE`).connection;if(t.targetBlock())return;let n=g.blocks.append({type:`compute_debug_trace_v1`,inputs:{OBJECT:{shadow:{type:`text_v1`},block:{type:`parameter_v1`,extraState:{key:`__message__`,name:`x-runtime-lib.message`,locale:!0}}}}},e.workspace);t.connect(n.previousConnection)}S.add_data_v1={init:function(){this.appendDummyInput().appendField(`%{BKY_DATA_V1_ADD_DATA_TITLE}`),this.setPreviousStatement(!0,null),this.setNextStatement(!0,null),this.setStyle(`procedure_blocks`),this.setTooltip(`%{BKY_DATA_V1_ADD_DATA_TOOLTIP}`),this.setHelpUrl(`%{BKY_DATA_V1_ADD_DATA_HELPURL}`)},saveExtraState:function(){return{}},loadExtraState:function(){this.updateShape_(),setTimeout(()=>{this.ensureBlocks_()},0)},updateShape_:function(){this.getInput(`HANDLE`)||this.appendStatementInput(`HANDLE`).appendField(`%{BKY_DATA_DO}`),this.getInput(`DATA`)||(this.appendValueInput(`DATA`),this.moveInputBefore(`DATA`,`HANDLE`)),this.getInput(`MESSAGE`)||(this.appendValueInput(`MESSAGE`),this.moveInputBefore(`MESSAGE`,`DATA`)),this.getInput(`SUCCESS`)||(this.appendValueInput(`SUCCESS`).appendField(`%{BKY_DATA_RETURN}`),this.moveInputBefore(`SUCCESS`,`MESSAGE`)),this.getInput(`TABLE`)||(this.appendValueInput(`TABLE`).setCheck(`UpdateColumn`).setAlign(b.Align.RIGHT).appendField(`%{BKY_DATA_TABLE}`),this.moveInputBefore(`TABLE`,`SUCCESS`))},ensureBlocks_:function(){this.isInsertionMarker()||(Ir(this),V(this,[[`SUCCESS`,`__success__`,`x-runtime-lib.success`,!0],[`MESSAGE`,`__message__`,`x-runtime-lib.message`,!0],[`DATA`,`__data__`,`x-runtime-lib.data`,!0]]),Lr(this))}},x.forBlock.add_data_v1=function(e){let t=x.INDENT;return`{
76
+ `},y.func_entry_v1={init:function(){this.func={id:``},this.appendDummyInput().appendField(`%{BKY_COMPUTE_FUNC_ENTRY}`).appendField(``),this.appendStatementInput(`HANDLE`).appendField(`%{BKY_COMPUTE_DO}`),this.setStyle(`procedure_blocks`),this.setTooltip(`%{BKY_COMPUTE_V1_FUNC_ENTRY_TOOLTIP}`),this.setHelpUrl(`%{BKY_COMPUTE_V1_FUNC_ENTRY_HELPURL}`),this.initData_()},initData_:function(){if(this.func.id)return;let{id:e,inputs:t}=Cr();this.func.id=e,this.func.inputs=t},saveExtraState:function(){return{func:this.func}},loadExtraState:function(e){this.func.id=e.func?.id??``,this.func.inputs=e.func?.inputs,this.updateShape_(),setTimeout(()=>{this.ensureBlocks_()},0)},onchange:function(){setTimeout(()=>{this.checkWarning_()},0)},updateShape_:function(){for(let e=this.func.inputs?.length??0;this.getInput(`INPUT`+e);e++){let t=this.getInput(`INPUT`+e)?.connection?.targetBlock();t&&t.dispose(),this.removeInput(`INPUT`+e)}if(this.func.inputs)for(let e=0;e<this.func.inputs.length;e++)this.appendValueInput(`INPUT`+e),this.moveInputBefore(`INPUT`+e,`HANDLE`)},ensureBlocks_:function(){if(this.isInsertionMarker())return;let e=[];if(this.func.inputs)for(let t=0;t<this.func.inputs.length;t++){let{id:n,name:r}=this.func.inputs[t];e.push([`INPUT`+t,`__input$${n}__`,r,!1])}V(this,e)},checkWarning_:function(){let{id:e,inputs:t}=Cr();if(this.func.id!==e&&(this.func.id=e),!v(t,this.func.inputs)){this.setWarningText(F(`WARN_FUNC_HAS_CHANGED`));return}this.setWarningText(null)}},g.forBlock.func_entry_v1=function(e){let t=e,n=g.statementToCode(t,`HANDLE`),r=[];if(t.func.inputs)for(let e=0;e<t.func.inputs.length;e++){let{id:n}=t.func.inputs[e];r.push(`__input$${n}__`)}return`function __funcEntryV1__(${r.join(`, `)}) {
77
+ ${n}}`},y.set_func_output_v1={init:function(){this.output={id:``,name:``,type:`string`},this.appendValueInput(`VALUE`).appendField(`%{BKY_COMPUTE_V1_SET_FUNC_OUTPUT_TITLE}`).appendField(new b(()=>this.genOutputOpts_()),`OUTPUT`),this.setPreviousStatement(!0,null),this.setNextStatement(!0,null),this.setStyle(`procedure_blocks`),this.setTooltip(`%{BKY_COMPUTE_V1_SET_FUNC_OUTPUT_TOOLTIP}`),this.setHelpUrl(`%{BKY_COMPUTE_V1_SET_FUNC_OUTPUT_HELPURL}`),this.initData_(),this.updateShape_(),this.updateShadows_()},initData_:function(){if(this.output.id)return;let e=Cr().outputs?.[0];e&&(this.output.id=e.id,this.output.name=e.name,this.output.type=e.type)},saveExtraState:function(){return{output:this.output}},loadExtraState:function(e){this.output.id=e.output?.id??``,this.output.name=e.output?.name??``,this.output.type=e.output?.type??``,this.updateShape_(),this.updateShadows_(),setTimeout(()=>{this.checkWarning_()},0)},genOutputOpts_:function(){return Tr()},onchange:function(e){if(e.type===x.BLOCK_CHANGE){let t=e;t.blockId===this.id&&(t.element===`field`&&t.name===`OUTPUT`&&this.onOutputChange_(t.newValue),setTimeout(()=>{this.checkWarning_()},0))}},onOutputChange_:function(e){let t=wr(e);if(!t){console.assert(!1);return}this.output.id=t.id,this.output.name=t.name,this.output.type=t.type,this.updateShape_(),this.updateShadows_()},updateShape_:function(){let e=this.getInput(`VALUE`);e.connection.setShadowDom(null);let t=e.connection.targetBlock();t&&!t.isShadow()&&t.dispose();let n=B(this.output.type);e.setCheck(n)},updateShadows_:function(){if(this.isInsertionMarker())return;let e=H(this.output.type);this.getInput(`VALUE`).setShadowDom(e)},checkWarning_:function(){let e=wr(this.output.id);if(!e){this.setWarningText(F(`WARN_FUNC_HAS_CHANGED`));return}if(e.name!==this.output.name&&(this.output.name=e.name),e.type!==this.output.type){this.setWarningText(F(`WARN_FUNC_HAS_CHANGED`));return}this.setWarningText(null)}},g.forBlock.set_func_output_v1=function(e){let t=g.quote_,n=e,{id:r,type:i}=n.output,a=g.valueToCode(n,`VALUE`,_.ATOMIC);if(a===void 0)switch(i){case`string`:a=`''`;break;case`number`:a=`0`;break;case`boolean`:a=`false`;break;case`array`:a=`[]`;break;case`object`:a=`{}`;break;default:a=`null`}return`__setFuncOutputV1__(${t(r)}, ${a});\n`},t([{type:`compute_debug_trace_v1`,message0:`%{BKY_COMPUTE_V1_COMPUTE_DEBUG_TRACE_TITLE}`,args0:[{type:`input_value`,name:`OBJECT`,check:null}],previousStatement:null,nextStatement:null,style:`procedure_blocks`,tooltip:`%{BKY_COMPUTE_V1_COMPUTE_DEBUG_TRACE_TOOLTIP}`,helpUrl:`%{BKY_COMPUTE_V1_COMPUTE_DEBUG_TRACE_HELPURL}`}]),g.forBlock.compute_debug_trace_v1=function(e){return`__debugTraceV1__(${g.valueToCode(e,`OBJECT`,_.ATOMIC)});\n`},t([{type:`compute_env_is_v1`,message0:`%{BKY_COMPUTE_V1_COMPUTE_ENV_IS_TITLE}`,args0:[{type:`field_dropdown`,name:`ENV`,options:[[`%{BKY_COMPUTE_ENV_DEV}`,`dev`],[`%{BKY_COMPUTE_ENV_PROD}`,`prod`]]}],output:`Boolean`,style:`logic_blocks`,tooltip:`%{BKY_COMPUTE_V1_COMPUTE_ENV_IS_TOOLTIP}`,helpUrl:`%{BKY_COMPUTE_V1_COMPUTE_ENV_IS_HELPURL}`}]),g.forBlock.compute_env_is_v1=function(e){return[`__getEnvV1__() === ${g.quote_(e.getFieldValue(`ENV`))}`,_.ATOMIC]};function Y(){let e=[];return S.data.spaces.forEach(t=>{t.tables.length>0&&e.push(t)}),e}function kr(e){let{spaces:t}=S.data;return t.find(t=>t.id===e)}function Ar(){let e=[];return Y().forEach(({id:t,name:n})=>{e.push([n,t])}),I(e)}function X(e){let{spaces:t}=S.data,n=t.find(t=>t.id===e);return n?n.tables:[]}function jr(e,t){let{spaces:n}=S.data,r=n.find(t=>t.id===e);if(r)return r.tables.find(e=>e.id===t)}function Mr(e){let t=[];return X(e).forEach(({id:e,name:n})=>{t.push([n,e])}),I(t)}function Nr(e,t){let{spaces:n}=S.data,r=n.find(t=>t.id===e);if(!r)return[];let i=r.tables.find(e=>e.id===t);return i?i.columns:[]}function Pr(e,t,n){let{spaces:r}=S.data,i=r.find(t=>t.id===e);if(!i)return;let a=i.tables.find(e=>e.id===t);if(a)return a.columns.find(e=>e.id===n)}function Fr(e,t){let n=[];return Nr(e,t).forEach(({id:e,name:t})=>{n.push([t,e])}),I(n)}function Ir(e){let t=e.getInput(`TABLE`).connection;if(t.targetBlock())return;let n,r,i=Y()?.[0];if(i){let e=X(i.id)?.[0];if(e){n={space:{id:i.id,name:i.name},table:{id:e.id,name:e.name,columns:e.columns},itemCount:e.columns.length},r={};for(let t=0;t<e.columns.length;t++){let n=e.columns[t];r[`COLUMN`+t]=n.id}}}let a={type:`update_column_v1`,extraState:n,fields:r},o=l.blocks.append(a,e.workspace);t.connect(o.outputConnection)}function Lr(e){let t=e.getInput(`HANDLE`).connection;if(t.targetBlock())return;let n=l.blocks.append({type:`compute_debug_trace_v1`,inputs:{OBJECT:{shadow:{type:`text_v1`},block:{type:`parameter_v1`,extraState:{key:`__message__`,name:`x-runtime-lib.message`,locale:!0}}}}},e.workspace);t.connect(n.previousConnection)}y.add_data_v1={init:function(){this.appendDummyInput().appendField(`%{BKY_DATA_V1_ADD_DATA_TITLE}`),this.setPreviousStatement(!0,null),this.setNextStatement(!0,null),this.setStyle(`procedure_blocks`),this.setTooltip(`%{BKY_DATA_V1_ADD_DATA_TOOLTIP}`),this.setHelpUrl(`%{BKY_DATA_V1_ADD_DATA_HELPURL}`)},saveExtraState:function(){return{}},loadExtraState:function(){this.updateShape_(),setTimeout(()=>{this.ensureBlocks_()},0)},updateShape_:function(){this.getInput(`HANDLE`)||this.appendStatementInput(`HANDLE`).appendField(`%{BKY_DATA_DO}`),this.getInput(`DATA`)||(this.appendValueInput(`DATA`),this.moveInputBefore(`DATA`,`HANDLE`)),this.getInput(`MESSAGE`)||(this.appendValueInput(`MESSAGE`),this.moveInputBefore(`MESSAGE`,`DATA`)),this.getInput(`SUCCESS`)||(this.appendValueInput(`SUCCESS`).appendField(`%{BKY_DATA_RETURN}`),this.moveInputBefore(`SUCCESS`,`MESSAGE`)),this.getInput(`TABLE`)||(this.appendValueInput(`TABLE`).setCheck(`UpdateColumn`).setAlign(u.Align.RIGHT).appendField(`%{BKY_DATA_TABLE}`),this.moveInputBefore(`TABLE`,`SUCCESS`))},ensureBlocks_:function(){this.isInsertionMarker()||(Ir(this),V(this,[[`SUCCESS`,`__success__`,`x-runtime-lib.success`,!0],[`MESSAGE`,`__message__`,`x-runtime-lib.message`,!0],[`DATA`,`__data__`,`x-runtime-lib.data`,!0]]),Lr(this))}},g.forBlock.add_data_v1=function(e){let t=g.INDENT;return`{
78
78
  ${t}var __tx__ = typeof(__tx__) !== 'undefined' ? __tx__ : null;
79
- ${t}var __table__ = ${x.valueToCode(e,`TABLE`,_.ATOMIC)||`null`};
79
+ ${t}var __table__ = ${g.valueToCode(e,`TABLE`,_.ATOMIC)||`null`};
80
80
  ${t}var __result__ = __addDataV1__(__tx__, __table__);
81
81
  ${t}var __success__ = __result__.success;
82
82
  ${t}var __message__ = __result__.message;
@@ -84,23 +84,23 @@ ${t}var __data__ = __result__.data;
84
84
  ${t}if (__tx__ && !__success__) {
85
85
  ${t}${t}throw __message__;
86
86
  ${t}}
87
- ${x.statementToCode(e,`HANDLE`)}}
88
- `},S.cond_atomic_v1={init:function(){this.space={id:``,name:``},this.table={id:``,name:``},this.column={id:``,name:``,type:``,extend:``},this.appendValueInput(`VALUE`).appendField(new m(()=>this.genSpaceOpts_()),`SPACE`).appendField(new m(()=>this.genTableOpts_()),`TABLE`).appendField(new m(()=>this.genColumnOpts_()),`COLUMN`).appendField(new m([[`=`,`EQ`],[`≠`,`NEQ`],[`‏<`,`LT`],[`‏≤`,`LTE`],[`‏>`,`GT`],[`‏≥`,`GTE`]]),`OP`),this.setOutput(!0,`Condition`),this.setStyle(`object_blocks`),this.setTooltip(`%{BKY_DATA_V1_COND_ATOMIC_TOOLTIP}`),this.setHelpUrl(`%{BKY_DATA_V1_COND_ATOMIC_HELPURL}`),this.initData_(),this.updateShape_(),setTimeout(()=>{this.updateBlocks_()},0)},initData_:function(){if(this.space.id)return;let e=Y()?.[0];if(!e)return;this.space.id=e.id,this.space.name=e.name;let t=X(this.space.id)?.[0];if(!t)return;this.table.id=t.id,this.table.name=t.name;let n=Nr(this.space.id,this.table.id)?.[0];n&&(this.column.id=n.id,this.column.name=n.name,this.column.type=n.type,this.column.extend=n.extend)},saveExtraState:function(){return{space:this.space,table:this.table,column:this.column}},loadExtraState:function(e){this.space.id=e.space?.id??``,this.space.name=e.space?.name??``,this.table.id=e.table?.id??``,this.table.name=e.table?.name??``,this.column.id=e.column?.id??``,this.column.name=e.column?.name??``,this.column.type=e.column?.type??``,this.column.extend=e.column?.extend??``,this.updateShape_(),setTimeout(()=>{this.updateBlocks_(),this.updateCheck_(),this.checkWarning_()},0)},genSpaceOpts_:function(){return Ar()},genTableOpts_:function(){return Mr(this.space.id)},genColumnOpts_:function(){return Fr(this.space.id,this.table.id)},onchange:function(e){if(e.type===p.BLOCK_CHANGE){let t=e;t.blockId===this.id&&t.element===`field`&&(t.name===`SPACE`?this.onSpaceChange_(t.newValue):t.name===`TABLE`?this.onTableChange_(t.newValue):t.name===`COLUMN`&&this.onColumnChange_(t.newValue)),setTimeout(()=>{this.checkWarning_()},0)}},onSpaceChange_:function(e){let t=kr(e);if(!t){console.assert(!1);return}let n=t.id!==this.space.id;this.space.id=t.id,this.space.name=t.name;let r=this.getField(`TABLE`);if(r.getOptions(!1),n){let e=X(this.space.id)?.[0];r.setValue(e?.id??``)}this.onTableChange_(r.getValue())},onTableChange_:function(e){let t=jr(this.space.id,e);if(!t){console.assert(!1);return}let n=t.id!==this.table.id;this.table.id=t.id,this.table.name=t.name;let r=this.getField(`COLUMN`);if(r.getOptions(!1),n){let e=Nr(this.space.id,this.table.id)?.[0];r.setValue(e?.id??``)}this.onColumnChange_(r.getValue())},onColumnChange_:function(e){let t=Pr(this.space.id,this.table.id,e);if(!t){console.assert(!1);return}this.column.id=t.id,this.column.name=t.name,this.column.type=t.type,this.column.extend=t.extend,this.updateShape_(),this.updateBlocks_(!0),this.updateCheck_()},updateShape_:function(){let e=this.getField(`SPACE`);e.getOptions(!1),e.setValue(this.space.id);let t=this.getField(`TABLE`);t.getOptions(!1),t.setValue(this.table.id);let n=this.getField(`COLUMN`);n.getOptions(!1),n.setValue(this.column.id)},updateBlocks_:function(e){if(this.isInsertionMarker())return;let t=this.getInput(`VALUE`).connection,n=t.targetBlock();if(e)n&&n.dispose();else if(n)return;let r=Gt(this.workspace,this.column.type);r&&(t.setCheck(null),t.connect(r.outputConnection))},updateCheck_:function(){let e=an(this.column.type);this.getInput(`VALUE`).connection.setCheck(e)},checkWarning_:function(){let e=kr(this.space.id);if(!e){this.setWarningText(F(`WARN_SPACE_NOT_FOUND`));return}e.name!==this.space.name&&(this.space.name=e.name);let t=jr(this.space.id,this.table.id);if(!t){this.setWarningText(F(`WARN_TABLE_NOT_FOUND`));return}t.name!==this.table.name&&(this.table.name=t.name);let n=Pr(this.space.id,this.table.id,this.column.id);if(!n){this.setWarningText(F(`WARN_COLUMN_NOT_FOUND`));return}if(n.name!==this.column.name&&(this.column.name=n.name),n.type!==this.column.type||n.extend!==this.column.extend){this.setWarningText(F(`WARN_COLUMN_HAS_CHANGED`));return}this.setWarningText(null)}},x.forBlock.cond_atomic_v1=function(e){let t=x.quote_,n=e,r=n.column.name,i=x.valueToCode(n,`VALUE`,_.ATOMIC)||null,a={EQ:`=`,NEQ:`!=`,LT:`<`,LTE:`<=`,GT:`>`,GTE:`>=`}[n.getFieldValue(`OP`)];return[`{type:'ATOMIC',key:${t(r)},value:${i},operator:${t(a)}}`,_.ATOMIC]},S.cond_logic_container_v1={init:function(){this.appendDummyInput().appendField(`%{BKY_DATA_LIST}`),this.appendStatementInput(`STACK`),this.setStyle(`logic_blocks`),this.contextMenu=!1}},S.cond_logic_item_v1={init:function(){this.appendDummyInput().appendField(`%{BKY_DATA_ITEM}`),this.setPreviousStatement(!0),this.setNextStatement(!0),this.setStyle(`logic_blocks`),this.contextMenu=!1}},S.cond_logic_v1={init:function(){this.itemCount_=1,this.appendValueInput(`VALUE`).setCheck(`Condition`).appendField(new m([[`%{BKY_DATA_COND_LOGIC_TYPE_AND}`,`AND`],[`%{BKY_DATA_COND_LOGIC_TYPE_OR}`,`OR`]]),`TYPE`),this.setMutator(new s.MutatorIcon([`cond_logic_item_v1`],this)),this.setOutput(!0,`Condition`),this.setStyle(`logic_blocks`),this.setTooltip(`%{BKY_DATA_V1_COND_LOGIC_TOOLTIP}`),this.setHelpUrl(`%{BKY_DATA_V1_COND_LOGIC_HELPURL}`),this.updateShape_()},saveExtraState:function(){return{itemCount:this.itemCount_}},loadExtraState:function(e){this.itemCount_=e.itemCount??1,this.updateShape_()},decompose:function(e){let t=e.newBlock(`cond_logic_container_v1`);t.initSvg();let n=t.getInput(`STACK`).connection;for(let t=0;t<this.itemCount_;t++){let t=e.newBlock(`cond_logic_item_v1`);t.initSvg(),n.connect(t.previousConnection),n=t.nextConnection}return t},compose:function(e){let t=e.getInputTargetBlock(`STACK`),n=[];for(;t;){if(t.isInsertionMarker()){t=t.getNextBlock();continue}n.push(t.valueConnection_),t=t.getNextBlock()}for(let e=0;e<this.itemCount_;e++){let t=this.getInput(`ADD`+e).connection?.targetConnection;t&&n.indexOf(t)===-1&&t.disconnect()}this.itemCount_=n.length,this.updateShape_();for(let e=0;e<this.itemCount_;e++)n[e]?.reconnect(this,`ADD`+e)},saveConnections:function(e){let t=e.getInputTargetBlock(`STACK`),n=0;for(;t;){if(t.isInsertionMarker()){t=t.getNextBlock();continue}t.valueConnection_=this.getInput(`ADD`+n)?.connection?.targetConnection,t=t.getNextBlock(),n++}},updateShape_:function(){for(let e=this.itemCount_;this.getInput(`ADD`+e);e++)this.removeInput(`ADD`+e);for(let e=0;e<this.itemCount_;e++)this.getInput(`ADD`+e)||this.appendValueInput(`ADD`+e).setCheck(`Condition`)}},x.forBlock.cond_logic_v1=function(e){let t=x.quote_,n=e,r=n.getFieldValue(`TYPE`),i=[],a=x.valueToCode(n,`VALUE`,_.ATOMIC)||null;i.push(a);for(let e=0;e<n.itemCount_;e++){let t=x.valueToCode(n,`ADD`+e,_.ATOMIC)||null;i.push(t)}return[`{type:${t(r)},entries:[${i}]}`,_.ATOMIC]};function Rr(e){let t=e.getInput(`TABLE`).connection;if(t.targetBlock())return;let n=Y()?.[0],r=X(n?.id??``)?.[0],i={type:`select_table_v1`,extraState:{space:{id:n?.id??``,name:n?.name??``},table:{id:r?.id??``,name:r?.name??``}}},a=g.blocks.append(i,e.workspace);t.connect(a.outputConnection)}function zr(e){let t=e.getInput(`CONDITION`).connection;if(t.targetBlock())return;let n=Y()?.[0],r=X(n?.id??``)?.[0],i=Nr(n?.id,r?.id)?.[0],a={type:`cond_atomic_v1`,extraState:{space:{id:n?.id??``,name:n?.name??``},table:{id:r?.id??``,name:r?.name??``},column:{id:i?.id??``,name:i?.name??``,type:i?.type??``,extend:i?.extend??``}}},o=g.blocks.append(a,e.workspace);t.connect(o.outputConnection)}function Br(e){let t=e.getInput(`HANDLE`).connection;if(t.targetBlock())return;let n=g.blocks.append({type:`compute_debug_trace_v1`,inputs:{OBJECT:{shadow:{type:`text_v1`},block:{type:`parameter_v1`,extraState:{key:`__message__`,name:`x-runtime-lib.message`,locale:!0}}}}},e.workspace);t.connect(n.previousConnection)}S.delete_data_v1={init:function(){this.appendDummyInput().appendField(`%{BKY_DATA_V1_DELETE_DATA_TITLE}`),this.setPreviousStatement(!0,null),this.setNextStatement(!0,null),this.setStyle(`procedure_blocks`),this.setTooltip(`%{BKY_DATA_V1_DELETE_DATA_TOOLTIP}`),this.setHelpUrl(`%{BKY_DATA_V1_DELETE_DATA_HELPURL}`)},saveExtraState:function(){return{}},loadExtraState:function(){this.updateShape_(),setTimeout(()=>{this.ensureBlocks_()},0)},updateShape_:function(){this.getInput(`HANDLE`)||this.appendStatementInput(`HANDLE`).appendField(`%{BKY_DATA_DO}`),this.getInput(`MESSAGE`)||(this.appendValueInput(`MESSAGE`),this.moveInputBefore(`MESSAGE`,`HANDLE`)),this.getInput(`SUCCESS`)||(this.appendValueInput(`SUCCESS`),this.moveInputBefore(`SUCCESS`,`MESSAGE`)),this.getInput(`CONDITION`)||(this.appendValueInput(`CONDITION`).setCheck(`Condition`).setAlign(b.Align.RIGHT).appendField(`%{BKY_DATA_CONDITION}`),this.moveInputBefore(`CONDITION`,`SUCCESS`)),this.getInput(`TABLE`)||(this.appendValueInput(`TABLE`).setCheck(`SelectTable`).setAlign(b.Align.RIGHT).appendField(`%{BKY_DATA_TABLE}`),this.moveInputBefore(`TABLE`,`CONDITION`))},ensureBlocks_:function(){this.isInsertionMarker()||(Rr(this),zr(this),V(this,[[`SUCCESS`,`__success__`,`x-runtime-lib.success`,!0],[`MESSAGE`,`__message__`,`x-runtime-lib.message`,!0]]),Br(this))}},x.forBlock.delete_data_v1=function(e){let t=x.INDENT;return`{
87
+ ${g.statementToCode(e,`HANDLE`)}}
88
+ `},y.cond_atomic_v1={init:function(){this.space={id:``,name:``},this.table={id:``,name:``},this.column={id:``,name:``,type:``,extend:``},this.appendValueInput(`VALUE`).appendField(new b(()=>this.genSpaceOpts_()),`SPACE`).appendField(new b(()=>this.genTableOpts_()),`TABLE`).appendField(new b(()=>this.genColumnOpts_()),`COLUMN`).appendField(new b([[`=`,`EQ`],[`≠`,`NEQ`],[`‏<`,`LT`],[`‏≤`,`LTE`],[`‏>`,`GT`],[`‏≥`,`GTE`]]),`OP`),this.setOutput(!0,`Condition`),this.setStyle(`object_blocks`),this.setTooltip(`%{BKY_DATA_V1_COND_ATOMIC_TOOLTIP}`),this.setHelpUrl(`%{BKY_DATA_V1_COND_ATOMIC_HELPURL}`),this.initData_(),this.updateShape_(),setTimeout(()=>{this.updateBlocks_()},0)},initData_:function(){if(this.space.id)return;let e=Y()?.[0];if(!e)return;this.space.id=e.id,this.space.name=e.name;let t=X(this.space.id)?.[0];if(!t)return;this.table.id=t.id,this.table.name=t.name;let n=Nr(this.space.id,this.table.id)?.[0];n&&(this.column.id=n.id,this.column.name=n.name,this.column.type=n.type,this.column.extend=n.extend)},saveExtraState:function(){return{space:this.space,table:this.table,column:this.column}},loadExtraState:function(e){this.space.id=e.space?.id??``,this.space.name=e.space?.name??``,this.table.id=e.table?.id??``,this.table.name=e.table?.name??``,this.column.id=e.column?.id??``,this.column.name=e.column?.name??``,this.column.type=e.column?.type??``,this.column.extend=e.column?.extend??``,this.updateShape_(),setTimeout(()=>{this.updateBlocks_(),this.updateCheck_(),this.checkWarning_()},0)},genSpaceOpts_:function(){return Ar()},genTableOpts_:function(){return Mr(this.space.id)},genColumnOpts_:function(){return Fr(this.space.id,this.table.id)},onchange:function(e){if(e.type===x.BLOCK_CHANGE){let t=e;t.blockId===this.id&&t.element===`field`&&(t.name===`SPACE`?this.onSpaceChange_(t.newValue):t.name===`TABLE`?this.onTableChange_(t.newValue):t.name===`COLUMN`&&this.onColumnChange_(t.newValue)),setTimeout(()=>{this.checkWarning_()},0)}},onSpaceChange_:function(e){let t=kr(e);if(!t){console.assert(!1);return}let n=t.id!==this.space.id;this.space.id=t.id,this.space.name=t.name;let r=this.getField(`TABLE`);if(r.getOptions(!1),n){let e=X(this.space.id)?.[0];r.setValue(e?.id??``)}this.onTableChange_(r.getValue())},onTableChange_:function(e){let t=jr(this.space.id,e);if(!t){console.assert(!1);return}let n=t.id!==this.table.id;this.table.id=t.id,this.table.name=t.name;let r=this.getField(`COLUMN`);if(r.getOptions(!1),n){let e=Nr(this.space.id,this.table.id)?.[0];r.setValue(e?.id??``)}this.onColumnChange_(r.getValue())},onColumnChange_:function(e){let t=Pr(this.space.id,this.table.id,e);if(!t){console.assert(!1);return}this.column.id=t.id,this.column.name=t.name,this.column.type=t.type,this.column.extend=t.extend,this.updateShape_(),this.updateBlocks_(!0),this.updateCheck_()},updateShape_:function(){let e=this.getField(`SPACE`);e.getOptions(!1),e.setValue(this.space.id);let t=this.getField(`TABLE`);t.getOptions(!1),t.setValue(this.table.id);let n=this.getField(`COLUMN`);n.getOptions(!1),n.setValue(this.column.id)},updateBlocks_:function(e){if(this.isInsertionMarker())return;let t=this.getInput(`VALUE`).connection,n=t.targetBlock();if(e)n&&n.dispose();else if(n)return;let r=Gt(this.workspace,this.column.type);r&&(t.setCheck(null),t.connect(r.outputConnection))},updateCheck_:function(){let e=an(this.column.type);this.getInput(`VALUE`).connection.setCheck(e)},checkWarning_:function(){let e=kr(this.space.id);if(!e){this.setWarningText(F(`WARN_SPACE_NOT_FOUND`));return}e.name!==this.space.name&&(this.space.name=e.name);let t=jr(this.space.id,this.table.id);if(!t){this.setWarningText(F(`WARN_TABLE_NOT_FOUND`));return}t.name!==this.table.name&&(this.table.name=t.name);let n=Pr(this.space.id,this.table.id,this.column.id);if(!n){this.setWarningText(F(`WARN_COLUMN_NOT_FOUND`));return}if(n.name!==this.column.name&&(this.column.name=n.name),n.type!==this.column.type||n.extend!==this.column.extend){this.setWarningText(F(`WARN_COLUMN_HAS_CHANGED`));return}this.setWarningText(null)}},g.forBlock.cond_atomic_v1=function(e){let t=g.quote_,n=e,r=n.column.name,i=g.valueToCode(n,`VALUE`,_.ATOMIC)||null,a={EQ:`=`,NEQ:`!=`,LT:`<`,LTE:`<=`,GT:`>`,GTE:`>=`}[n.getFieldValue(`OP`)];return[`{type:'ATOMIC',key:${t(r)},value:${i},operator:${t(a)}}`,_.ATOMIC]},y.cond_logic_container_v1={init:function(){this.appendDummyInput().appendField(`%{BKY_DATA_LIST}`),this.appendStatementInput(`STACK`),this.setStyle(`logic_blocks`),this.contextMenu=!1}},y.cond_logic_item_v1={init:function(){this.appendDummyInput().appendField(`%{BKY_DATA_ITEM}`),this.setPreviousStatement(!0),this.setNextStatement(!0),this.setStyle(`logic_blocks`),this.contextMenu=!1}},y.cond_logic_v1={init:function(){this.itemCount_=1,this.appendValueInput(`VALUE`).setCheck(`Condition`).appendField(new b([[`%{BKY_DATA_COND_LOGIC_TYPE_AND}`,`AND`],[`%{BKY_DATA_COND_LOGIC_TYPE_OR}`,`OR`]]),`TYPE`),this.setMutator(new oe.MutatorIcon([`cond_logic_item_v1`],this)),this.setOutput(!0,`Condition`),this.setStyle(`logic_blocks`),this.setTooltip(`%{BKY_DATA_V1_COND_LOGIC_TOOLTIP}`),this.setHelpUrl(`%{BKY_DATA_V1_COND_LOGIC_HELPURL}`),this.updateShape_()},saveExtraState:function(){return{itemCount:this.itemCount_}},loadExtraState:function(e){this.itemCount_=e.itemCount??1,this.updateShape_()},decompose:function(e){let t=e.newBlock(`cond_logic_container_v1`);t.initSvg();let n=t.getInput(`STACK`).connection;for(let t=0;t<this.itemCount_;t++){let t=e.newBlock(`cond_logic_item_v1`);t.initSvg(),n.connect(t.previousConnection),n=t.nextConnection}return t},compose:function(e){let t=e.getInputTargetBlock(`STACK`),n=[];for(;t;){if(t.isInsertionMarker()){t=t.getNextBlock();continue}n.push(t.valueConnection_),t=t.getNextBlock()}for(let e=0;e<this.itemCount_;e++){let t=this.getInput(`ADD`+e).connection?.targetConnection;t&&n.indexOf(t)===-1&&t.disconnect()}this.itemCount_=n.length,this.updateShape_();for(let e=0;e<this.itemCount_;e++)n[e]?.reconnect(this,`ADD`+e)},saveConnections:function(e){let t=e.getInputTargetBlock(`STACK`),n=0;for(;t;){if(t.isInsertionMarker()){t=t.getNextBlock();continue}t.valueConnection_=this.getInput(`ADD`+n)?.connection?.targetConnection,t=t.getNextBlock(),n++}},updateShape_:function(){for(let e=this.itemCount_;this.getInput(`ADD`+e);e++)this.removeInput(`ADD`+e);for(let e=0;e<this.itemCount_;e++)this.getInput(`ADD`+e)||this.appendValueInput(`ADD`+e).setCheck(`Condition`)}},g.forBlock.cond_logic_v1=function(e){let t=g.quote_,n=e,r=n.getFieldValue(`TYPE`),i=[],a=g.valueToCode(n,`VALUE`,_.ATOMIC)||null;i.push(a);for(let e=0;e<n.itemCount_;e++){let t=g.valueToCode(n,`ADD`+e,_.ATOMIC)||null;i.push(t)}return[`{type:${t(r)},entries:[${i}]}`,_.ATOMIC]};function Rr(e){let t=e.getInput(`TABLE`).connection;if(t.targetBlock())return;let n=Y()?.[0],r=X(n?.id??``)?.[0],i={type:`select_table_v1`,extraState:{space:{id:n?.id??``,name:n?.name??``},table:{id:r?.id??``,name:r?.name??``}}},a=l.blocks.append(i,e.workspace);t.connect(a.outputConnection)}function zr(e){let t=e.getInput(`CONDITION`).connection;if(t.targetBlock())return;let n=Y()?.[0],r=X(n?.id??``)?.[0],i=Nr(n?.id,r?.id)?.[0],a={type:`cond_atomic_v1`,extraState:{space:{id:n?.id??``,name:n?.name??``},table:{id:r?.id??``,name:r?.name??``},column:{id:i?.id??``,name:i?.name??``,type:i?.type??``,extend:i?.extend??``}}},o=l.blocks.append(a,e.workspace);t.connect(o.outputConnection)}function Br(e){let t=e.getInput(`HANDLE`).connection;if(t.targetBlock())return;let n=l.blocks.append({type:`compute_debug_trace_v1`,inputs:{OBJECT:{shadow:{type:`text_v1`},block:{type:`parameter_v1`,extraState:{key:`__message__`,name:`x-runtime-lib.message`,locale:!0}}}}},e.workspace);t.connect(n.previousConnection)}y.delete_data_v1={init:function(){this.appendDummyInput().appendField(`%{BKY_DATA_V1_DELETE_DATA_TITLE}`),this.setPreviousStatement(!0,null),this.setNextStatement(!0,null),this.setStyle(`procedure_blocks`),this.setTooltip(`%{BKY_DATA_V1_DELETE_DATA_TOOLTIP}`),this.setHelpUrl(`%{BKY_DATA_V1_DELETE_DATA_HELPURL}`)},saveExtraState:function(){return{}},loadExtraState:function(){this.updateShape_(),setTimeout(()=>{this.ensureBlocks_()},0)},updateShape_:function(){this.getInput(`HANDLE`)||this.appendStatementInput(`HANDLE`).appendField(`%{BKY_DATA_DO}`),this.getInput(`MESSAGE`)||(this.appendValueInput(`MESSAGE`),this.moveInputBefore(`MESSAGE`,`HANDLE`)),this.getInput(`SUCCESS`)||(this.appendValueInput(`SUCCESS`),this.moveInputBefore(`SUCCESS`,`MESSAGE`)),this.getInput(`CONDITION`)||(this.appendValueInput(`CONDITION`).setCheck(`Condition`).setAlign(u.Align.RIGHT).appendField(`%{BKY_DATA_CONDITION}`),this.moveInputBefore(`CONDITION`,`SUCCESS`)),this.getInput(`TABLE`)||(this.appendValueInput(`TABLE`).setCheck(`SelectTable`).setAlign(u.Align.RIGHT).appendField(`%{BKY_DATA_TABLE}`),this.moveInputBefore(`TABLE`,`CONDITION`))},ensureBlocks_:function(){this.isInsertionMarker()||(Rr(this),zr(this),V(this,[[`SUCCESS`,`__success__`,`x-runtime-lib.success`,!0],[`MESSAGE`,`__message__`,`x-runtime-lib.message`,!0]]),Br(this))}},g.forBlock.delete_data_v1=function(e){let t=g.INDENT;return`{
89
89
  ${t}var __tx__ = typeof(__tx__) !== 'undefined' ? __tx__ : null;
90
- ${t}var __table__ = ${x.valueToCode(e,`TABLE`,_.ATOMIC)||`null`};
91
- ${t}var __condition__ = ${x.valueToCode(e,`CONDITION`,_.ATOMIC)||`null`};
90
+ ${t}var __table__ = ${g.valueToCode(e,`TABLE`,_.ATOMIC)||`null`};
91
+ ${t}var __condition__ = ${g.valueToCode(e,`CONDITION`,_.ATOMIC)||`null`};
92
92
  ${t}var __result__ = __deleteDataV1__(__tx__, __table__, __condition__);
93
93
  ${t}var __success__ = __result__.success;
94
94
  ${t}var __message__ = __result__.message;
95
95
  ${t}if (__tx__ && !__success__) {
96
96
  ${t}${t}throw __message__;
97
97
  ${t}}
98
- ${x.statementToCode(e,`HANDLE`)}}
99
- `},h([{type:`interrupt_transaction_v1`,message0:`%{BKY_DATA_V1_INTERRUPT_TRANSACTION_TITLE}`,args0:[{type:`input_value`,name:`VALUE`,check:`String`}],previousStatement:null,nextStatement:null,style:`procedure_blocks`,tooltip:`%{BKY_DATA_V1_INTERRUPT_TRANSACTION_TOOLTIP}`,helpUrl:`%{BKY_DATA_V1_INTERRUPT_TRANSACTION_HELPURL}`}]),x.forBlock.interrupt_transaction_v1=function(e){return`throw ${x.valueToCode(e,`VALUE`,_.NONE)||`''`};\n`};function Vr(e){let t=e.getInput(`TABLE`).connection;if(t.targetBlock())return;let n,r,i=Y()?.[0];if(i){let e=X(i.id)?.[0];if(e){n={space:{id:i.id,name:i.name},table:{id:e.id,name:e.name,columns:e.columns},itemCount:e.columns.length},r={};for(let t=0;t<e.columns.length;t++){let n=e.columns[t];r[`COLUMN`+t]=n.id,r[`ALIAS`+t]=n.name}}}let a={type:`select_column_v1`,extraState:n,fields:r},o=g.blocks.append(a,e.workspace);t.connect(o.outputConnection)}function Hr(e){let t=e.getInput(`CONDITION`).connection;if(t.targetBlock())return;let n=g.blocks.append({type:`cond_atomic_v1`},e.workspace);t.connect(n.outputConnection)}function Ur(e){let t=e.getInput(`EXTRA`).connection;if(t.targetBlock())return;let n=g.blocks.append({type:`list_create_v1`,extraState:{itemCount:1},inputs:{ADD0:{block:{type:`query_extra_limit_v1`,inputs:{OFFSET:{shadow:{type:`math_number_v1`,fields:{NUM:0}}},LIMIT:{shadow:{type:`math_number_v1`,fields:{NUM:100}}}}}}}},e.workspace);t.connect(n.outputConnection)}function Wr(e){let t=e.getInput(`HANDLE`).connection;if(t.targetBlock())return;let n=g.blocks.append({type:`compute_debug_trace_v1`,inputs:{OBJECT:{shadow:{type:`text_v1`},block:{type:`parameter_v1`,extraState:{key:`__message__`,name:`x-runtime-lib.message`,locale:!0}}}}},e.workspace);t.connect(n.previousConnection)}h([{type:`query_data_container_v1`,message0:`%{BKY_DATA_EXTRA} %1`,args0:[{type:`field_checkbox`,name:`EXTRA`,checked:!0}],style:`procedure_blocks`}]),S.query_data_v1={init:function(){this.appendDummyInput().appendField(`%{BKY_DATA_V1_QUERY_DATA_TITLE}`),this.setPreviousStatement(!0,null),this.setNextStatement(!0,null),this.setStyle(`procedure_blocks`),this.setTooltip(`%{BKY_DATA_V1_QUERY_DATA_TOOLTIP}`),this.setHelpUrl(`%{BKY_DATA_V1_QUERY_DATA_HELPURL}`)},saveExtraState:function(){return{}},loadExtraState:function(){this.updateShape_(),setTimeout(()=>{this.ensureBlocks_()},0)},updateShape_:function(){this.getInput(`HANDLE`)||this.appendStatementInput(`HANDLE`).appendField(`%{BKY_DATA_DO}`),this.getInput(`EXTRA_DATA`)||(this.appendValueInput(`EXTRA_DATA`),this.moveInputBefore(`EXTRA_DATA`,`HANDLE`)),this.getInput(`MAIN_DATA`)||(this.appendValueInput(`MAIN_DATA`),this.moveInputBefore(`MAIN_DATA`,`EXTRA_DATA`)),this.getInput(`MESSAGE`)||(this.appendValueInput(`MESSAGE`),this.moveInputBefore(`MESSAGE`,`MAIN_DATA`)),this.getInput(`SUCCESS`)||(this.appendValueInput(`SUCCESS`).appendField(`%{BKY_DATA_RETURN}`),this.moveInputBefore(`SUCCESS`,`MESSAGE`)),this.getInput(`EXTRA`)||(this.appendValueInput(`EXTRA`).setCheck([`QueryExtra`,`Array`]).setAlign(b.Align.RIGHT).appendField(`%{BKY_DATA_EXTRA}`),this.moveInputBefore(`EXTRA`,`SUCCESS`)),this.getInput(`CONDITION`)||(this.appendValueInput(`CONDITION`).setCheck(`Condition`).setAlign(b.Align.RIGHT).appendField(`%{BKY_DATA_CONDITION}`),this.moveInputBefore(`CONDITION`,`EXTRA`)),this.getInput(`TABLE`)||(this.appendValueInput(`TABLE`).setCheck([`SelectColumn`,`Array`]).setAlign(b.Align.RIGHT).appendField(`%{BKY_DATA_TABLE}`),this.moveInputBefore(`TABLE`,`CONDITION`))},ensureBlocks_:function(){this.isInsertionMarker()||(Vr(this),Hr(this),Ur(this),V(this,[[`SUCCESS`,`__success__`,`x-runtime-lib.success`,!0],[`MESSAGE`,`__message__`,`x-runtime-lib.message`,!0],[`MAIN_DATA`,`__mainData__`,`x-runtime-lib.mainData`,!0],[`EXTRA_DATA`,`__extraData__`,`x-runtime-lib.extraData`,!0]]),Wr(this))}},x.forBlock.query_data_v1=function(e){let t=x.INDENT;return`{
98
+ ${g.statementToCode(e,`HANDLE`)}}
99
+ `},t([{type:`interrupt_transaction_v1`,message0:`%{BKY_DATA_V1_INTERRUPT_TRANSACTION_TITLE}`,args0:[{type:`input_value`,name:`VALUE`,check:`String`}],previousStatement:null,nextStatement:null,style:`procedure_blocks`,tooltip:`%{BKY_DATA_V1_INTERRUPT_TRANSACTION_TOOLTIP}`,helpUrl:`%{BKY_DATA_V1_INTERRUPT_TRANSACTION_HELPURL}`}]),g.forBlock.interrupt_transaction_v1=function(e){return`throw ${g.valueToCode(e,`VALUE`,_.NONE)||`''`};\n`};function Vr(e){let t=e.getInput(`TABLE`).connection;if(t.targetBlock())return;let n,r,i=Y()?.[0];if(i){let e=X(i.id)?.[0];if(e){n={space:{id:i.id,name:i.name},table:{id:e.id,name:e.name,columns:e.columns},itemCount:e.columns.length},r={};for(let t=0;t<e.columns.length;t++){let n=e.columns[t];r[`COLUMN`+t]=n.id,r[`ALIAS`+t]=n.name}}}let a={type:`select_column_v1`,extraState:n,fields:r},o=l.blocks.append(a,e.workspace);t.connect(o.outputConnection)}function Hr(e){let t=e.getInput(`CONDITION`).connection;if(t.targetBlock())return;let n=l.blocks.append({type:`cond_atomic_v1`},e.workspace);t.connect(n.outputConnection)}function Ur(e){let t=e.getInput(`EXTRA`).connection;if(t.targetBlock())return;let n=l.blocks.append({type:`list_create_v1`,extraState:{itemCount:1},inputs:{ADD0:{block:{type:`query_extra_limit_v1`,inputs:{OFFSET:{shadow:{type:`math_number_v1`,fields:{NUM:0}}},LIMIT:{shadow:{type:`math_number_v1`,fields:{NUM:100}}}}}}}},e.workspace);t.connect(n.outputConnection)}function Wr(e){let t=e.getInput(`HANDLE`).connection;if(t.targetBlock())return;let n=l.blocks.append({type:`compute_debug_trace_v1`,inputs:{OBJECT:{shadow:{type:`text_v1`},block:{type:`parameter_v1`,extraState:{key:`__message__`,name:`x-runtime-lib.message`,locale:!0}}}}},e.workspace);t.connect(n.previousConnection)}t([{type:`query_data_container_v1`,message0:`%{BKY_DATA_EXTRA} %1`,args0:[{type:`field_checkbox`,name:`EXTRA`,checked:!0}],style:`procedure_blocks`}]),y.query_data_v1={init:function(){this.appendDummyInput().appendField(`%{BKY_DATA_V1_QUERY_DATA_TITLE}`),this.setPreviousStatement(!0,null),this.setNextStatement(!0,null),this.setStyle(`procedure_blocks`),this.setTooltip(`%{BKY_DATA_V1_QUERY_DATA_TOOLTIP}`),this.setHelpUrl(`%{BKY_DATA_V1_QUERY_DATA_HELPURL}`)},saveExtraState:function(){return{}},loadExtraState:function(){this.updateShape_(),setTimeout(()=>{this.ensureBlocks_()},0)},updateShape_:function(){this.getInput(`HANDLE`)||this.appendStatementInput(`HANDLE`).appendField(`%{BKY_DATA_DO}`),this.getInput(`EXTRA_DATA`)||(this.appendValueInput(`EXTRA_DATA`),this.moveInputBefore(`EXTRA_DATA`,`HANDLE`)),this.getInput(`MAIN_DATA`)||(this.appendValueInput(`MAIN_DATA`),this.moveInputBefore(`MAIN_DATA`,`EXTRA_DATA`)),this.getInput(`MESSAGE`)||(this.appendValueInput(`MESSAGE`),this.moveInputBefore(`MESSAGE`,`MAIN_DATA`)),this.getInput(`SUCCESS`)||(this.appendValueInput(`SUCCESS`).appendField(`%{BKY_DATA_RETURN}`),this.moveInputBefore(`SUCCESS`,`MESSAGE`)),this.getInput(`EXTRA`)||(this.appendValueInput(`EXTRA`).setCheck([`QueryExtra`,`Array`]).setAlign(u.Align.RIGHT).appendField(`%{BKY_DATA_EXTRA}`),this.moveInputBefore(`EXTRA`,`SUCCESS`)),this.getInput(`CONDITION`)||(this.appendValueInput(`CONDITION`).setCheck(`Condition`).setAlign(u.Align.RIGHT).appendField(`%{BKY_DATA_CONDITION}`),this.moveInputBefore(`CONDITION`,`EXTRA`)),this.getInput(`TABLE`)||(this.appendValueInput(`TABLE`).setCheck([`SelectColumn`,`Array`]).setAlign(u.Align.RIGHT).appendField(`%{BKY_DATA_TABLE}`),this.moveInputBefore(`TABLE`,`CONDITION`))},ensureBlocks_:function(){this.isInsertionMarker()||(Vr(this),Hr(this),Ur(this),V(this,[[`SUCCESS`,`__success__`,`x-runtime-lib.success`,!0],[`MESSAGE`,`__message__`,`x-runtime-lib.message`,!0],[`MAIN_DATA`,`__mainData__`,`x-runtime-lib.mainData`,!0],[`EXTRA_DATA`,`__extraData__`,`x-runtime-lib.extraData`,!0]]),Wr(this))}},g.forBlock.query_data_v1=function(e){let t=g.INDENT;return`{
100
100
  ${t}var __tx__ = typeof(__tx__) !== 'undefined' ? __tx__ : null;
101
- ${t}var __table__ = ${x.valueToCode(e,`TABLE`,_.ATOMIC)||`null`};
102
- ${t}var __condition__ = ${x.valueToCode(e,`CONDITION`,_.ATOMIC)||`null`};
103
- ${t}var __extra__ = ${x.valueToCode(e,`EXTRA`,_.ATOMIC)||`null`};
101
+ ${t}var __table__ = ${g.valueToCode(e,`TABLE`,_.ATOMIC)||`null`};
102
+ ${t}var __condition__ = ${g.valueToCode(e,`CONDITION`,_.ATOMIC)||`null`};
103
+ ${t}var __extra__ = ${g.valueToCode(e,`EXTRA`,_.ATOMIC)||`null`};
104
104
  ${t}var __result__ = __queryDataV1__(__tx__, __table__, __condition__, __extra__);
105
105
  ${t}var __success__ = __result__.success;
106
106
  ${t}var __message__ = __result__.message;
@@ -109,8 +109,8 @@ ${t}var __extraData__ = __result__.extraData;
109
109
  ${t}if (__tx__ && !__success__) {
110
110
  ${t}${t}throw __message__;
111
111
  ${t}}
112
- ${x.statementToCode(e,`HANDLE`)}}
113
- `},h([{type:`query_extra_limit_v1`,message0:`%{BKY_DATA_V1_QUERY_EXTRA_LIMIT_TITLE}`,args0:[{type:`input_value`,name:`OFFSET`,check:`Number`},{type:`input_value`,name:`LIMIT`,check:`Number`}],inputsInline:!0,output:`QueryExtra`,style:`object_blocks`,tooltip:`%{BKY_DATA_V1_QUERY_EXTRA_LIMIT_TOOLTIP}`,helpUrl:`%{BKY_DATA_V1_QUERY_EXTRA_LIMIT_HELPURL}`}]),x.forBlock.query_extra_limit_v1=function(e){return[`{type:'limit',value:${x.valueToCode(e,`OFFSET`,_.ATOMIC)||0},value2:${x.valueToCode(e,`LIMIT`,_.ATOMIC)||0}}`,_.ATOMIC]},h([{type:`query_extra_sortby_v1`,message0:`%{BKY_DATA_V1_QUERY_EXTRA_SORTBY_TITLE}`,args0:[{type:`input_value`,name:`COLUMN`,check:`String`},{type:`input_value`,name:`DESC`,check:`Boolean`}],inputsInline:!0,output:`QueryExtra`,style:`object_blocks`,tooltip:`%{BKY_DATA_V1_QUERY_EXTRA_SORTBY_TOOLTIP}`,helpUrl:`%{BKY_DATA_V1_QUERY_EXTRA_SORTBY_HELPURL}`}]),x.forBlock.query_extra_sortby_v1=function(e){return[`{type:'sortby',value:${x.valueToCode(e,`COLUMN`,_.ATOMIC)||`''`},value2:${x.valueToCode(e,`DESC`,_.ATOMIC)||!1}}`,_.ATOMIC]},S.select_column_container_v1={init:function(){this.appendDummyInput().appendField(`%{BKY_DATA_LIST}`),this.appendStatementInput(`STACK`),this.setStyle(`object_blocks`),this.contextMenu=!1}},S.select_column_item_v1={init:function(){this.appendDummyInput().appendField(`%{BKY_DATA_ITEM}`),this.setPreviousStatement(!0),this.setNextStatement(!0),this.setStyle(`object_blocks`),this.contextMenu=!1}},S.select_column_v1={init:function(){this.space={id:``,name:``},this.table={id:``,name:``,columns:[]},this.itemCount_=0,this.appendDummyInput().appendField(`%{BKY_DATA_V1_SELECT_COLUMN_TITLE}`).appendField(new m(()=>this.genSpaceOpts_()),`SPACE`).appendField(new m(()=>this.genTableOpts_()),`TABLE`),this.setMutator(new s.MutatorIcon([`select_column_item_v1`],this)),this.setOutput(!0,`SelectColumn`),this.setStyle(`object_blocks`),this.setTooltip(`%{BKY_DATA_V1_SELECT_COLUMN_TOOLTIP}`),this.setHelpUrl(`%{BKY_DATA_V1_SELECT_COLUMN_HELPURL}`),this.initData_(),this.initShape_()},initData_:function(){if(this.space.id)return;let e=Y()?.[0];if(!e)return;this.space.id=e.id,this.space.name=e.name;let t=this.getField(`SPACE`);t.getOptions(!1),t.setValue(this.space.id,!1);let n=X(this.space.id)?.[0];if(!n)return;this.table.id=n.id,this.table.name=n.name,this.table.columns=n.columns;let r=this.getField(`TABLE`);r.getOptions(!1),r.setValue(this.table.id,!1),this.itemCount_=n.columns.length},saveExtraState:function(){return{space:this.space,table:this.table,itemCount:this.itemCount_}},loadExtraState:function(e){this.space.id=e.space?.id??``,this.space.name=e.space?.name??``,this.table.id=e.table?.id??``,this.table.name=e.table?.name??``,this.table.columns=e.table?.columns??[],this.itemCount_=e.itemCount??0,this.updateShape_(),setTimeout(()=>{this.checkWarning_()},0)},genSpaceOpts_:function(){return Ar()},genTableOpts_:function(){return Mr(this.space.id)},genColumnOpts_:function(){let e=[];return this.table.columns.forEach(({id:t,name:n})=>{e.push([n,t])}),I(e)},onchange:function(e){if(e.type===p.BLOCK_CHANGE){let t=e;if(t.blockId===this.id){if(t.element===`field`){if(t.name===`SPACE`)this.onSpaceChange_(t.newValue);else if(t.name===`TABLE`)this.onTableChange_(t.newValue);else if(t.name?.startsWith(`COLUMN`)){let e=parseInt(t.name.substring(6));this.onColumnChange_(e,t.newValue)}}setTimeout(()=>{this.checkWarning_()},0)}}},onSpaceChange_:function(e){let t=kr(e);if(!t){console.assert(!1);return}let n=t.id!==this.space.id;this.space.id=t.id,this.space.name=t.name;let r=this.getField(`TABLE`);if(r.getOptions(!1),n){let e=X(this.space.id)?.[0];r.setValue(e?.id??``)}this.onTableChange_(r.getValue())},onTableChange_:function(e){let t=jr(this.space.id,e);if(!t){console.assert(!1);return}this.table.id=t.id,this.table.name=t.name,this.table.columns=t.columns,this.itemCount_=t.columns.length,this.updateShape_();for(let e=0;e<t.columns.length;e++){let{id:n,name:r}=t.columns[e],i=this.getField(`COLUMN`+e);i.getOptions(!1),i.setValue(n,!1),this.getField(`ALIAS`+e).setValue(r,!1)}},onColumnChange_:function(e,t){let n=this.table.columns.find(e=>e.id===t);if(!n){console.assert(!1);return}this.setFieldValue(n.name,`ALIAS`+e)},decompose:function(e){let t=e.newBlock(`select_column_container_v1`);t.initSvg();let n=t.getInput(`STACK`).connection;for(let t=0;t<this.itemCount_;t++){let t=e.newBlock(`select_column_item_v1`);t.initSvg(),n.connect(t.previousConnection),n=t.nextConnection}return t},compose:function(e){let t=e.getInputTargetBlock(`STACK`),n=[],r=[];for(;t;){if(t.isInsertionMarker()){t=t.getNextBlock();continue}n.push(t.column_),r.push(t.alias_),t=t.getNextBlock()}this.itemCount_=n.length,this.updateShape_();for(let e=0;e<this.itemCount_;e++){let t=n[e]??this.table.columns[0]?.id??``,i=r[e]??this.table.columns[0]?.name??``;this.getField(`COLUMN`+e).setValue(t,!1),this.getField(`ALIAS`+e).setValue(i,!1)}setTimeout(()=>{this.checkWarning_()},0)},saveConnections:function(e){let t=e.getInputTargetBlock(`STACK`),n=0;for(;t;){if(t.isInsertionMarker()){t=t.getNextBlock();continue}t.column_=this.getFieldValue(`COLUMN`+n),t.alias_=this.getFieldValue(`ALIAS`+n),t=t.getNextBlock(),n++}},initShape_:function(){if(!this.isInFlyout&&!this.getInput(`ADD0`))for(let e=0;e<this.table.columns.length;e++){let t=this.table.columns[e],n=new m(()=>this.genColumnOpts_()),r=new ve(``);this.appendDummyInput(`ADD`+e).setAlign(b.Align.RIGHT).appendField(n,`COLUMN`+e).appendField(`%{BKY_DATA_AS}`).appendField(r,`ALIAS`+e),n.setValue(t.id,!1),r.setValue(t.name,!1)}},updateShape_:function(){for(let e=this.itemCount_;this.getInput(`ADD`+e);e++)this.removeInput(`ADD`+e);for(let e=0;e<this.itemCount_;e++){if(this.getInput(`ADD`+e))continue;let t=new m(()=>this.genColumnOpts_()),n=new ve(``);this.appendDummyInput(`ADD`+e).setAlign(b.Align.RIGHT).appendField(t,`COLUMN`+e).appendField(`%{BKY_DATA_AS}`).appendField(n,`ALIAS`+e);let r=this.table.columns[0];t.setValue(r.id??``,!1),n.setValue(r.name??``,!1)}},checkWarning_:function(){let e=kr(this.space.id);if(!e){this.setWarningText(F(`WARN_SPACE_NOT_FOUND`));return}e.name!==this.space.name&&(this.space.name=e.name);let t=jr(this.space.id,this.table.id);if(!t){this.setWarningText(F(`WARN_TABLE_NOT_FOUND`));return}if(t.name!==this.table.name&&(this.table.name=t.name),!y(t.columns,this.table.columns)){this.setWarningText(F(`WARN_TABLE_HAS_CHANGED`));return}this.setWarningText(null)}},x.forBlock.select_column_v1=function(e){let t=x.quote_,n=e,r=n.space.id,i=n.table.id,a=[];for(let e=0;e<n.itemCount_;e++){let t=n.getFieldValue(`COLUMN`+e),r=n.table.columns.find(e=>e.id===t).name,i=n.getFieldValue(`ALIAS`+e);a.push({name:r,alias:i})}let o=`[`;return a.forEach(({name:e,alias:n},r)=>{r!==0&&(o+=`,`),o+=`{name:${t(e)},alias:${t(n)}}`}),o+=`]`,[`{spaceId:${t(r)},tableId:${t(i)},columns:${o}}`,_.ATOMIC]},S.select_table_v1={init:function(){this.space={id:``,name:``},this.table={id:``,name:``},this.appendDummyInput().appendField(`%{BKY_DATA_V1_SELECT_TABLE_TITLE}`).appendField(new m(()=>this.genSpaceOpts_()),`SPACE`).appendField(new m(()=>this.genTableOpts_()),`TABLE`),this.setOutput(!0,`SelectTable`),this.setStyle(`object_blocks`),this.setTooltip(`%{BKY_DATA_V1_SELECT_TABLE_TOOLTIP}`),this.setHelpUrl(`%{BKY_DATA_V1_SELECT_TABLE_HELPURL}`),this.initData_()},initData_:function(){if(this.space.id)return;let e=Y()?.[0];if(!e)return;this.space.id=e.id,this.space.name=e.name;let t=this.getField(`SPACE`);t.getOptions(!1),t.setValue(this.space.id);let n=X(this.space.id)?.[0];if(!n)return;this.table.id=n.id,this.table.name=n.name;let r=this.getField(`TABLE`);r.getOptions(!1),r.setValue(this.table.id)},saveExtraState:function(){return{space:this.space,table:this.table}},loadExtraState:function(e){this.space.id=e.space?.id??``,this.space.name=e.space?.name??``,this.table.id=e.table?.id??``,this.table.name=e.table?.name??``,this.checkWarning_()},genSpaceOpts_:function(){return Ar()},genTableOpts_:function(){return Mr(this.space.id)},onchange:function(e){if(e.type===p.BLOCK_CHANGE){let t=e;t.blockId===this.id&&(t.element===`field`&&(t.name===`SPACE`?this.onSpaceChange_(t.newValue):t.name===`TABLE`&&this.onTableChange_(t.newValue)),setTimeout(()=>{this.checkWarning_()},0))}},onSpaceChange_:function(e){let t=kr(e);if(!t){console.assert(!1);return}let n=t.id!==this.space.id;this.space.id=t.id,this.space.name=t.name;let r=this.getField(`TABLE`);if(r.getOptions(!1),n){let e=X(this.space.id)?.[0];r.setValue(e?.id??``)}this.onTableChange_(r.getValue())},onTableChange_:function(e){let t=jr(this.space.id,e);if(!t){console.assert(!1);return}this.table.id=t.id,this.table.name=t.name},checkWarning_:function(){let e=kr(this.space.id);if(!e){this.setWarningText(F(`WARN_SPACE_NOT_FOUND`));return}e.name!==this.space.name&&(this.space.name=e.name);let t=jr(this.space.id,this.table.id);if(!t){this.setWarningText(F(`WARN_TABLE_NOT_FOUND`));return}t.name!==this.table.name&&(this.table.name=t.name),this.setWarningText(null)}},x.forBlock.select_table_v1=function(e){let t=x.quote_,n=e,r=n.space.id,i=n.table.id;return[`{spaceId:${t(r)},tableId:${t(i)}}`,_.ATOMIC]},S.transaction_v1={init:function(){this.appendDummyInput().appendField(`%{BKY_DATA_V1_TRANSACTION_TITLE}`),this.setPreviousStatement(!0,null),this.setNextStatement(!0,null),this.setStyle(`procedure_blocks`),this.setTooltip(`%{BKY_DATA_V1_TRANSACTION_TOOLTIP}`),this.setHelpUrl(`%{BKY_DATA_V1_TRANSACTION_HELPURL}`)},saveExtraState:function(){return{}},loadExtraState:function(){this.updateShape_(),setTimeout(()=>{this.ensureBlocks_()},0)},updateShape_:function(){this.getInput(`FINALLY`)||this.appendStatementInput(`FINALLY`).appendField(`%{BKY_DATA_FINALLY}`),this.getInput(`MESSAGE`)||(this.appendValueInput(`MESSAGE`),this.moveInputBefore(`MESSAGE`,`FINALLY`)),this.getInput(`SUCCESS`)||(this.appendValueInput(`SUCCESS`),this.moveInputBefore(`SUCCESS`,`MESSAGE`)),this.getInput(`HANDLE`)||(this.appendStatementInput(`HANDLE`).appendField(`%{BKY_DATA_DO}`),this.moveInputBefore(`HANDLE`,`SUCCESS`))},ensureBlocks_:function(){this.isInsertionMarker()||V(this,[[`SUCCESS`,`__success__`,`x-runtime-lib.success`,!0],[`MESSAGE`,`__message__`,`x-runtime-lib.message`,!0]])}},x.forBlock.transaction_v1=function(e){let t=x.INDENT,n=e,r=Xt(n),i=x.statementToCode(n,`HANDLE`),a=x.statementToCode(n,`FINALLY`);return`{
112
+ ${g.statementToCode(e,`HANDLE`)}}
113
+ `},t([{type:`query_extra_limit_v1`,message0:`%{BKY_DATA_V1_QUERY_EXTRA_LIMIT_TITLE}`,args0:[{type:`input_value`,name:`OFFSET`,check:`Number`},{type:`input_value`,name:`LIMIT`,check:`Number`}],inputsInline:!0,output:`QueryExtra`,style:`object_blocks`,tooltip:`%{BKY_DATA_V1_QUERY_EXTRA_LIMIT_TOOLTIP}`,helpUrl:`%{BKY_DATA_V1_QUERY_EXTRA_LIMIT_HELPURL}`}]),g.forBlock.query_extra_limit_v1=function(e){return[`{type:'limit',value:${g.valueToCode(e,`OFFSET`,_.ATOMIC)||0},value2:${g.valueToCode(e,`LIMIT`,_.ATOMIC)||0}}`,_.ATOMIC]},t([{type:`query_extra_sortby_v1`,message0:`%{BKY_DATA_V1_QUERY_EXTRA_SORTBY_TITLE}`,args0:[{type:`input_value`,name:`COLUMN`,check:`String`},{type:`input_value`,name:`DESC`,check:`Boolean`}],inputsInline:!0,output:`QueryExtra`,style:`object_blocks`,tooltip:`%{BKY_DATA_V1_QUERY_EXTRA_SORTBY_TOOLTIP}`,helpUrl:`%{BKY_DATA_V1_QUERY_EXTRA_SORTBY_HELPURL}`}]),g.forBlock.query_extra_sortby_v1=function(e){return[`{type:'sortby',value:${g.valueToCode(e,`COLUMN`,_.ATOMIC)||`''`},value2:${g.valueToCode(e,`DESC`,_.ATOMIC)||!1}}`,_.ATOMIC]},y.select_column_container_v1={init:function(){this.appendDummyInput().appendField(`%{BKY_DATA_LIST}`),this.appendStatementInput(`STACK`),this.setStyle(`object_blocks`),this.contextMenu=!1}},y.select_column_item_v1={init:function(){this.appendDummyInput().appendField(`%{BKY_DATA_ITEM}`),this.setPreviousStatement(!0),this.setNextStatement(!0),this.setStyle(`object_blocks`),this.contextMenu=!1}},y.select_column_v1={init:function(){this.space={id:``,name:``},this.table={id:``,name:``,columns:[]},this.itemCount_=0,this.appendDummyInput().appendField(`%{BKY_DATA_V1_SELECT_COLUMN_TITLE}`).appendField(new b(()=>this.genSpaceOpts_()),`SPACE`).appendField(new b(()=>this.genTableOpts_()),`TABLE`),this.setMutator(new oe.MutatorIcon([`select_column_item_v1`],this)),this.setOutput(!0,`SelectColumn`),this.setStyle(`object_blocks`),this.setTooltip(`%{BKY_DATA_V1_SELECT_COLUMN_TOOLTIP}`),this.setHelpUrl(`%{BKY_DATA_V1_SELECT_COLUMN_HELPURL}`),this.initData_(),this.initShape_()},initData_:function(){if(this.space.id)return;let e=Y()?.[0];if(!e)return;this.space.id=e.id,this.space.name=e.name;let t=this.getField(`SPACE`);t.getOptions(!1),t.setValue(this.space.id,!1);let n=X(this.space.id)?.[0];if(!n)return;this.table.id=n.id,this.table.name=n.name,this.table.columns=n.columns;let r=this.getField(`TABLE`);r.getOptions(!1),r.setValue(this.table.id,!1),this.itemCount_=n.columns.length},saveExtraState:function(){return{space:this.space,table:this.table,itemCount:this.itemCount_}},loadExtraState:function(e){this.space.id=e.space?.id??``,this.space.name=e.space?.name??``,this.table.id=e.table?.id??``,this.table.name=e.table?.name??``,this.table.columns=e.table?.columns??[],this.itemCount_=e.itemCount??0,this.updateShape_(),setTimeout(()=>{this.checkWarning_()},0)},genSpaceOpts_:function(){return Ar()},genTableOpts_:function(){return Mr(this.space.id)},genColumnOpts_:function(){let e=[];return this.table.columns.forEach(({id:t,name:n})=>{e.push([n,t])}),I(e)},onchange:function(e){if(e.type===x.BLOCK_CHANGE){let t=e;if(t.blockId===this.id){if(t.element===`field`){if(t.name===`SPACE`)this.onSpaceChange_(t.newValue);else if(t.name===`TABLE`)this.onTableChange_(t.newValue);else if(t.name?.startsWith(`COLUMN`)){let e=parseInt(t.name.substring(6));this.onColumnChange_(e,t.newValue)}}setTimeout(()=>{this.checkWarning_()},0)}}},onSpaceChange_:function(e){let t=kr(e);if(!t){console.assert(!1);return}let n=t.id!==this.space.id;this.space.id=t.id,this.space.name=t.name;let r=this.getField(`TABLE`);if(r.getOptions(!1),n){let e=X(this.space.id)?.[0];r.setValue(e?.id??``)}this.onTableChange_(r.getValue())},onTableChange_:function(e){let t=jr(this.space.id,e);if(!t){console.assert(!1);return}this.table.id=t.id,this.table.name=t.name,this.table.columns=t.columns,this.itemCount_=t.columns.length,this.updateShape_();for(let e=0;e<t.columns.length;e++){let{id:n,name:r}=t.columns[e],i=this.getField(`COLUMN`+e);i.getOptions(!1),i.setValue(n,!1),this.getField(`ALIAS`+e).setValue(r,!1)}},onColumnChange_:function(e,t){let n=this.table.columns.find(e=>e.id===t);if(!n){console.assert(!1);return}this.setFieldValue(n.name,`ALIAS`+e)},decompose:function(e){let t=e.newBlock(`select_column_container_v1`);t.initSvg();let n=t.getInput(`STACK`).connection;for(let t=0;t<this.itemCount_;t++){let t=e.newBlock(`select_column_item_v1`);t.initSvg(),n.connect(t.previousConnection),n=t.nextConnection}return t},compose:function(e){let t=e.getInputTargetBlock(`STACK`),n=[],r=[];for(;t;){if(t.isInsertionMarker()){t=t.getNextBlock();continue}n.push(t.column_),r.push(t.alias_),t=t.getNextBlock()}this.itemCount_=n.length,this.updateShape_();for(let e=0;e<this.itemCount_;e++){let t=n[e]??this.table.columns[0]?.id??``,i=r[e]??this.table.columns[0]?.name??``;this.getField(`COLUMN`+e).setValue(t,!1),this.getField(`ALIAS`+e).setValue(i,!1)}setTimeout(()=>{this.checkWarning_()},0)},saveConnections:function(e){let t=e.getInputTargetBlock(`STACK`),n=0;for(;t;){if(t.isInsertionMarker()){t=t.getNextBlock();continue}t.column_=this.getFieldValue(`COLUMN`+n),t.alias_=this.getFieldValue(`ALIAS`+n),t=t.getNextBlock(),n++}},initShape_:function(){if(!this.isInFlyout&&!this.getInput(`ADD0`))for(let e=0;e<this.table.columns.length;e++){let t=this.table.columns[e],n=new b(()=>this.genColumnOpts_()),r=new f(``);this.appendDummyInput(`ADD`+e).setAlign(u.Align.RIGHT).appendField(n,`COLUMN`+e).appendField(`%{BKY_DATA_AS}`).appendField(r,`ALIAS`+e),n.setValue(t.id,!1),r.setValue(t.name,!1)}},updateShape_:function(){for(let e=this.itemCount_;this.getInput(`ADD`+e);e++)this.removeInput(`ADD`+e);for(let e=0;e<this.itemCount_;e++){if(this.getInput(`ADD`+e))continue;let t=new b(()=>this.genColumnOpts_()),n=new f(``);this.appendDummyInput(`ADD`+e).setAlign(u.Align.RIGHT).appendField(t,`COLUMN`+e).appendField(`%{BKY_DATA_AS}`).appendField(n,`ALIAS`+e);let r=this.table.columns[0];t.setValue(r.id??``,!1),n.setValue(r.name??``,!1)}},checkWarning_:function(){let e=kr(this.space.id);if(!e){this.setWarningText(F(`WARN_SPACE_NOT_FOUND`));return}e.name!==this.space.name&&(this.space.name=e.name);let t=jr(this.space.id,this.table.id);if(!t){this.setWarningText(F(`WARN_TABLE_NOT_FOUND`));return}if(t.name!==this.table.name&&(this.table.name=t.name),!v(t.columns,this.table.columns)){this.setWarningText(F(`WARN_TABLE_HAS_CHANGED`));return}this.setWarningText(null)}},g.forBlock.select_column_v1=function(e){let t=g.quote_,n=e,r=n.space.id,i=n.table.id,a=[];for(let e=0;e<n.itemCount_;e++){let t=n.getFieldValue(`COLUMN`+e),r=n.table.columns.find(e=>e.id===t).name,i=n.getFieldValue(`ALIAS`+e);a.push({name:r,alias:i})}let o=`[`;return a.forEach(({name:e,alias:n},r)=>{r!==0&&(o+=`,`),o+=`{name:${t(e)},alias:${t(n)}}`}),o+=`]`,[`{spaceId:${t(r)},tableId:${t(i)},columns:${o}}`,_.ATOMIC]},y.select_table_v1={init:function(){this.space={id:``,name:``},this.table={id:``,name:``},this.appendDummyInput().appendField(`%{BKY_DATA_V1_SELECT_TABLE_TITLE}`).appendField(new b(()=>this.genSpaceOpts_()),`SPACE`).appendField(new b(()=>this.genTableOpts_()),`TABLE`),this.setOutput(!0,`SelectTable`),this.setStyle(`object_blocks`),this.setTooltip(`%{BKY_DATA_V1_SELECT_TABLE_TOOLTIP}`),this.setHelpUrl(`%{BKY_DATA_V1_SELECT_TABLE_HELPURL}`),this.initData_()},initData_:function(){if(this.space.id)return;let e=Y()?.[0];if(!e)return;this.space.id=e.id,this.space.name=e.name;let t=this.getField(`SPACE`);t.getOptions(!1),t.setValue(this.space.id);let n=X(this.space.id)?.[0];if(!n)return;this.table.id=n.id,this.table.name=n.name;let r=this.getField(`TABLE`);r.getOptions(!1),r.setValue(this.table.id)},saveExtraState:function(){return{space:this.space,table:this.table}},loadExtraState:function(e){this.space.id=e.space?.id??``,this.space.name=e.space?.name??``,this.table.id=e.table?.id??``,this.table.name=e.table?.name??``,this.checkWarning_()},genSpaceOpts_:function(){return Ar()},genTableOpts_:function(){return Mr(this.space.id)},onchange:function(e){if(e.type===x.BLOCK_CHANGE){let t=e;t.blockId===this.id&&(t.element===`field`&&(t.name===`SPACE`?this.onSpaceChange_(t.newValue):t.name===`TABLE`&&this.onTableChange_(t.newValue)),setTimeout(()=>{this.checkWarning_()},0))}},onSpaceChange_:function(e){let t=kr(e);if(!t){console.assert(!1);return}let n=t.id!==this.space.id;this.space.id=t.id,this.space.name=t.name;let r=this.getField(`TABLE`);if(r.getOptions(!1),n){let e=X(this.space.id)?.[0];r.setValue(e?.id??``)}this.onTableChange_(r.getValue())},onTableChange_:function(e){let t=jr(this.space.id,e);if(!t){console.assert(!1);return}this.table.id=t.id,this.table.name=t.name},checkWarning_:function(){let e=kr(this.space.id);if(!e){this.setWarningText(F(`WARN_SPACE_NOT_FOUND`));return}e.name!==this.space.name&&(this.space.name=e.name);let t=jr(this.space.id,this.table.id);if(!t){this.setWarningText(F(`WARN_TABLE_NOT_FOUND`));return}t.name!==this.table.name&&(this.table.name=t.name),this.setWarningText(null)}},g.forBlock.select_table_v1=function(e){let t=g.quote_,n=e,r=n.space.id,i=n.table.id;return[`{spaceId:${t(r)},tableId:${t(i)}}`,_.ATOMIC]},y.transaction_v1={init:function(){this.appendDummyInput().appendField(`%{BKY_DATA_V1_TRANSACTION_TITLE}`),this.setPreviousStatement(!0,null),this.setNextStatement(!0,null),this.setStyle(`procedure_blocks`),this.setTooltip(`%{BKY_DATA_V1_TRANSACTION_TOOLTIP}`),this.setHelpUrl(`%{BKY_DATA_V1_TRANSACTION_HELPURL}`)},saveExtraState:function(){return{}},loadExtraState:function(){this.updateShape_(),setTimeout(()=>{this.ensureBlocks_()},0)},updateShape_:function(){this.getInput(`FINALLY`)||this.appendStatementInput(`FINALLY`).appendField(`%{BKY_DATA_FINALLY}`),this.getInput(`MESSAGE`)||(this.appendValueInput(`MESSAGE`),this.moveInputBefore(`MESSAGE`,`FINALLY`)),this.getInput(`SUCCESS`)||(this.appendValueInput(`SUCCESS`),this.moveInputBefore(`SUCCESS`,`MESSAGE`)),this.getInput(`HANDLE`)||(this.appendStatementInput(`HANDLE`).appendField(`%{BKY_DATA_DO}`),this.moveInputBefore(`HANDLE`,`SUCCESS`))},ensureBlocks_:function(){this.isInsertionMarker()||V(this,[[`SUCCESS`,`__success__`,`x-runtime-lib.success`,!0],[`MESSAGE`,`__message__`,`x-runtime-lib.message`,!0]])}},g.forBlock.transaction_v1=function(e){let t=g.INDENT,n=e,r=Xt(n),i=g.statementToCode(n,`HANDLE`),a=g.statementToCode(n,`FINALLY`);return`{
114
114
  ${t}var __error${r}__ = '';
115
115
  ${t}var __txExist${r}__ = typeof(__tx__) !== 'undefined';
116
116
  ${t}var __tx__ = __txExist${r}__ ? __tx__ : __txBeginV1__();
@@ -124,7 +124,7 @@ ${t}${t}${t}if (__txSavePointV1__(__tx__, __spName${r}__)) {
124
124
  ${t}${t}${t}${t}throw 'save point of transaction failed';
125
125
  ${t}${t}${t}}
126
126
  ${t}${t}}
127
- ${x.prefixLines(i,t)}${t}} catch (__e__) {
127
+ ${g.prefixLines(i,t)}${t}} catch (__e__) {
128
128
  ${t}${t}__error${r}__ = __e__ ? __e__ : 'transaction interrupted';
129
129
  ${t}} finally {
130
130
  ${t}${t}if (__txExist${r}__) {
@@ -144,15 +144,15 @@ ${t}${t}${t}}
144
144
  ${t}${t}}
145
145
  ${t}${t}var __success__ = !__error${r}__;
146
146
  ${t}${t}var __message__ = __error${r}__ ? __error${r}__ : 'success';
147
- ${x.prefixLines(a,t)}${t}${t}if (__txExist${r}__ && __error${r}__) {
147
+ ${g.prefixLines(a,t)}${t}${t}if (__txExist${r}__ && __error${r}__) {
148
148
  ${t}${t}${t}throw __error${r}__;
149
149
  ${t}${t}}
150
150
  ${t}}
151
151
  }
152
- `},S.update_column_container_v1={init:function(){this.appendDummyInput().appendField(`%{BKY_DATA_LIST}`),this.appendStatementInput(`STACK`),this.setStyle(`object_blocks`),this.contextMenu=!1}},S.update_column_item_v1={init:function(){this.appendDummyInput().appendField(`%{BKY_DATA_ITEM}`),this.setPreviousStatement(!0),this.setNextStatement(!0),this.setStyle(`object_blocks`),this.contextMenu=!1}},S.update_column_v1={init:function(){this.space={id:``,name:``},this.table={id:``,name:``,columns:[]},this.itemCount_=0,this.appendDummyInput().appendField(`%{BKY_DATA_V1_UPDATE_COLUMN_TITLE}`).appendField(new m(()=>this.genSpaceOpts_()),`SPACE`).appendField(new m(()=>this.genTableOpts_()),`TABLE`),this.setMutator(new s.MutatorIcon([`update_column_item_v1`],this)),this.setOutput(!0,`UpdateColumn`),this.setStyle(`object_blocks`),this.setTooltip(`%{BKY_DATA_V1_UPDATE_COLUMN_TOOLTIP}`),this.setHelpUrl(`%{BKY_DATA_V1_UPDATE_COLUMN_HELPURL}`),this.initData_(),this.initShape_()},initData_:function(){if(this.space.id)return;let e=Y()?.[0];if(!e)return;this.space.id=e.id,this.space.name=e.name;let t=this.getField(`SPACE`);t.getOptions(!1),t.setValue(this.space.id,!1);let n=X(this.space.id)?.[0];if(!n)return;this.table.id=n.id,this.table.name=n.name,this.table.columns=n.columns;let r=this.getField(`TABLE`);r.getOptions(!1),r.setValue(this.table.id,!1),this.itemCount_=n.columns.length},saveExtraState:function(){return{space:this.space,table:this.table,itemCount:this.itemCount_}},loadExtraState:function(e){this.space.id=e.space?.id??``,this.space.name=e.space?.name??``,this.table.id=e.table?.id??``,this.table.name=e.table?.name??``,this.table.columns=e.table?.columns??[],this.itemCount_=e.itemCount??0,this.updateShape_(),setTimeout(()=>{this.updateBlocks_(),this.updateCheck_(),this.checkWarning_()},0)},genSpaceOpts_:function(){return Ar()},genTableOpts_:function(){return Mr(this.space.id)},genColumnOpts_:function(){let e=[];return this.table.columns.forEach(({id:t,name:n})=>{e.push([n,t])}),I(e)},onchange:function(e){if(e.type===p.BLOCK_CHANGE){let t=e;if(t.blockId===this.id){if(t.element===`field`){if(t.name===`SPACE`)this.onSpaceChange_(t.newValue);else if(t.name===`TABLE`)this.onTableChange_(t.newValue);else if(t.name.startsWith(`COLUMN`)){let e=parseInt(t.name.substring(6));this.onColumnChange_(e,t.newValue)}}setTimeout(()=>{this.checkWarning_()},0)}}},onSpaceChange_:function(e){let t=kr(e);if(!t){console.assert(!1);return}let n=t.id!==this.space.id;this.space.id=t.id,this.space.name=t.name;let r=this.getField(`TABLE`);if(r.getOptions(!1),n){let e=X(this.space.id)?.[0];r.setValue(e?.id??``)}this.onTableChange_(r.getValue())},onTableChange_:function(e){let t=jr(this.space.id,e);if(!t){console.assert(!1);return}this.table.id=t.id,this.table.name=t.name,this.table.columns=t.columns,this.itemCount_=t.columns.length,this.updateShape_();for(let e=0;e<this.itemCount_;e++){let t=this.table.columns[e].id,n=this.getField(`COLUMN`+e);n.getOptions(!1),n.setValue(t,!1)}setTimeout(()=>{this.updateBlocks_(!0),this.updateCheck_()},0)},onColumnChange_:function(e,t){let n=this.table.columns.find(e=>e.id===t);if(!n){console.assert(!1);return}let r=this.getInput(`ADD`+e).connection,i=r.targetBlock();i&&i.dispose();let a=Gt(this.workspace,n.type);a&&(r.setCheck(null),r.connect(a.outputConnection)),this.updateCheck_()},decompose:function(e){let t=e.newBlock(`update_column_container_v1`);t.initSvg();let n=t.getInput(`STACK`).connection;for(let t=0;t<this.itemCount_;t++){let t=e.newBlock(`update_column_item_v1`);t.initSvg(),n.connect(t.previousConnection),n=t.nextConnection}return t},compose:function(e){let t=e.getInputTargetBlock(`STACK`),n=[],r=[];for(;t;){if(t.isInsertionMarker()){t=t.getNextBlock();continue}n.push(t.column_),r.push(t.valueConnection_),t=t.getNextBlock()}for(let e=0;e<this.itemCount_;e++){let t=this.getInput(`ADD`+e).connection.targetConnection;t&&r.indexOf(t)===-1&&t.disconnect()}this.itemCount_=n.length,this.updateShape_();for(let e=0;e<this.itemCount_;e++){let t=n[e]??this.table.columns?.[0]?.id??``;this.getField(`COLUMN`+e).setValue(t,!1)}setTimeout(()=>{for(let e=0;e<this.itemCount_;e++)this.getInput(`ADD`+e).setCheck(null),r[e]?.reconnect(this,`ADD`+e);this.updateBlocks_(),this.updateCheck_()},0)},saveConnections:function(e){let t=e.getInputTargetBlock(`STACK`),n=0;for(;t;){if(t.isInsertionMarker()){t=t.getNextBlock();continue}t.column_=this.getFieldValue(`COLUMN`+n),t.valueConnection_=this.getInput(`ADD`+n).connection.targetConnection,t=t.getNextBlock(),n++}},initShape_:function(){if(!this.isInFlyout&&!this.getInput(`ADD0`))for(let e=0;e<this.table.columns.length;e++){let t=this.table.columns[e],n=new m(()=>this.genColumnOpts_());this.appendValueInput(`ADD`+e).setAlign(b.Align.RIGHT).appendField(n,`COLUMN`+e),n.setValue(t.id,!1)}},updateShape_:function(){for(let e=this.itemCount_;this.getInput(`ADD`+e);e++){let t=this.getInput(`ADD`+e).connection.targetBlock();t&&t.dispose(),this.removeInput(`ADD`+e)}for(let e=0;e<this.itemCount_;e++){if(this.getInput(`ADD`+e))continue;let t=new m(()=>this.genColumnOpts_());this.appendValueInput(`ADD`+e).setAlign(b.Align.RIGHT).appendField(t,`COLUMN`+e)}},updateBlocks_:function(e){if(!this.isInsertionMarker())for(let t=0;t<this.itemCount_;t++){let n=this.getInput(`ADD`+t),r=n.connection,i=r.targetBlock();if(e)i&&i.dispose();else if(i)continue;let a=this.getFieldValue(`COLUMN`+t),o=this.table.columns.find(e=>e.id===a);if(!o)continue;n.setCheck(null);let s=Gt(this.workspace,o.type);s&&r.connect(s.outputConnection)}},updateCheck_:function(){for(let e=0;e<this.itemCount_;e++){let t=this.getFieldValue(`COLUMN`+e),n=this.table.columns.find(e=>e.id===t);if(!n)continue;let r=an(n.type);this.getInput(`ADD`+e).setCheck(r)}},checkWarning_:function(){let e=kr(this.space.id);if(!e){this.setWarningText(F(`WARN_SPACE_NOT_FOUND`));return}e.name!==this.space.name&&(this.space.name=e.name);let t=jr(this.space.id,this.table.id);if(!t){this.setWarningText(F(`WARN_TABLE_NOT_FOUND`));return}if(t.name!==this.table.name&&(this.table.name=t.name),!y(t.columns,this.table.columns)){this.setWarningText(F(`WARN_TABLE_HAS_CHANGED`));return}this.setWarningText(null)}},x.forBlock.update_column_v1=function(e){let t=x.quote_,n=e,r=n.space.id,i=n.table.id,a=[];for(let e=0;e<n.itemCount_;e++){let t=n.getFieldValue(`COLUMN`+e),r=n.table.columns.find(e=>e.id===t).name,i=x.valueToCode(n,`ADD`+e,_.ATOMIC)||`null`;a.push({name:r,value:i})}let o=`[`;return a.forEach(({name:e,value:n},r)=>{r!==0&&(o+=`,`),o+=`{name:${t(e)},value:${n}}`}),o+=`]`,[`{spaceId:${t(r)},tableId:${t(i)},columns:${o}}`,_.ATOMIC]};function Gr(e){let t=e.getInput(`TABLE`).connection;if(t.targetBlock())return;let n,r,i=Y()?.[0];if(i){let e=X(i.id)?.[0];if(e){n={space:{id:i.id,name:i.name},table:{id:e.id,name:e.name,columns:e.columns},itemCount:e.columns.length},r={};for(let t=0;t<e.columns.length;t++){let n=e.columns[t];r[`COLUMN`+t]=n.id}}}let a={type:`update_column_v1`,extraState:n,fields:r},o=g.blocks.append(a,e.workspace);t.connect(o.outputConnection)}function Kr(e){let t=e.getInput(`CONDITION`).connection;if(t.targetBlock())return;let n=g.blocks.append({type:`cond_atomic_v1`},e.workspace);t.connect(n.outputConnection)}function qr(e){let t=e.getInput(`HANDLE`).connection;if(t.targetBlock())return;let n=g.blocks.append({type:`compute_debug_trace_v1`,inputs:{OBJECT:{shadow:{type:`text_v1`},block:{type:`parameter_v1`,extraState:{key:`__message__`,name:`x-runtime-lib.message`,locale:!0}}}}},e.workspace);t.connect(n.previousConnection)}S.update_data_v1={init:function(){this.appendDummyInput().appendField(`%{BKY_DATA_V1_UPDATE_DATA_TITLE}`),this.setPreviousStatement(!0,null),this.setNextStatement(!0,null),this.setStyle(`procedure_blocks`),this.setTooltip(`%{BKY_DATA_V1_UPDATE_DATA_TOOLTIP}`),this.setHelpUrl(`%{BKY_DATA_V1_UPDATE_DATA_HELPURL}`)},saveExtraState:function(){return{}},loadExtraState:function(){this.updateShape_(),setTimeout(()=>{this.ensureBlocks()},0)},updateShape_:function(){this.getInput(`HANDLE`)||this.appendStatementInput(`HANDLE`).appendField(`%{BKY_DATA_DO}`),this.getInput(`DATA`)||(this.appendValueInput(`DATA`),this.moveInputBefore(`DATA`,`HANDLE`)),this.getInput(`MESSAGE`)||(this.appendValueInput(`MESSAGE`),this.moveInputBefore(`MESSAGE`,`DATA`)),this.getInput(`SUCCESS`)||(this.appendValueInput(`SUCCESS`).appendField(`%{BKY_DATA_RETURN}`),this.moveInputBefore(`SUCCESS`,`MESSAGE`)),this.getInput(`CONDITION`)||(this.appendValueInput(`CONDITION`).setCheck(`Condition`).setAlign(b.Align.RIGHT).appendField(`%{BKY_DATA_CONDITION}`),this.moveInputBefore(`CONDITION`,`SUCCESS`)),this.getInput(`TABLE`)||(this.appendValueInput(`TABLE`).setCheck(`UpdateColumn`).setAlign(b.Align.RIGHT).appendField(`%{BKY_DATA_TABLE}`),this.moveInputBefore(`TABLE`,`CONDITION`))},ensureBlocks:function(){this.isInsertionMarker()||(Gr(this),Kr(this),V(this,[[`SUCCESS`,`__success__`,`x-runtime-lib.success`,!0],[`MESSAGE`,`__message__`,`x-runtime-lib.message`,!0],[`DATA`,`__data__`,`x-runtime-lib.data`,!0]]),qr(this))}},x.forBlock.update_data_v1=function(e){let t=x.INDENT;return`{
152
+ `},y.update_column_container_v1={init:function(){this.appendDummyInput().appendField(`%{BKY_DATA_LIST}`),this.appendStatementInput(`STACK`),this.setStyle(`object_blocks`),this.contextMenu=!1}},y.update_column_item_v1={init:function(){this.appendDummyInput().appendField(`%{BKY_DATA_ITEM}`),this.setPreviousStatement(!0),this.setNextStatement(!0),this.setStyle(`object_blocks`),this.contextMenu=!1}},y.update_column_v1={init:function(){this.space={id:``,name:``},this.table={id:``,name:``,columns:[]},this.itemCount_=0,this.appendDummyInput().appendField(`%{BKY_DATA_V1_UPDATE_COLUMN_TITLE}`).appendField(new b(()=>this.genSpaceOpts_()),`SPACE`).appendField(new b(()=>this.genTableOpts_()),`TABLE`),this.setMutator(new oe.MutatorIcon([`update_column_item_v1`],this)),this.setOutput(!0,`UpdateColumn`),this.setStyle(`object_blocks`),this.setTooltip(`%{BKY_DATA_V1_UPDATE_COLUMN_TOOLTIP}`),this.setHelpUrl(`%{BKY_DATA_V1_UPDATE_COLUMN_HELPURL}`),this.initData_(),this.initShape_()},initData_:function(){if(this.space.id)return;let e=Y()?.[0];if(!e)return;this.space.id=e.id,this.space.name=e.name;let t=this.getField(`SPACE`);t.getOptions(!1),t.setValue(this.space.id,!1);let n=X(this.space.id)?.[0];if(!n)return;this.table.id=n.id,this.table.name=n.name,this.table.columns=n.columns;let r=this.getField(`TABLE`);r.getOptions(!1),r.setValue(this.table.id,!1),this.itemCount_=n.columns.length},saveExtraState:function(){return{space:this.space,table:this.table,itemCount:this.itemCount_}},loadExtraState:function(e){this.space.id=e.space?.id??``,this.space.name=e.space?.name??``,this.table.id=e.table?.id??``,this.table.name=e.table?.name??``,this.table.columns=e.table?.columns??[],this.itemCount_=e.itemCount??0,this.updateShape_(),setTimeout(()=>{this.updateBlocks_(),this.updateCheck_(),this.checkWarning_()},0)},genSpaceOpts_:function(){return Ar()},genTableOpts_:function(){return Mr(this.space.id)},genColumnOpts_:function(){let e=[];return this.table.columns.forEach(({id:t,name:n})=>{e.push([n,t])}),I(e)},onchange:function(e){if(e.type===x.BLOCK_CHANGE){let t=e;if(t.blockId===this.id){if(t.element===`field`){if(t.name===`SPACE`)this.onSpaceChange_(t.newValue);else if(t.name===`TABLE`)this.onTableChange_(t.newValue);else if(t.name.startsWith(`COLUMN`)){let e=parseInt(t.name.substring(6));this.onColumnChange_(e,t.newValue)}}setTimeout(()=>{this.checkWarning_()},0)}}},onSpaceChange_:function(e){let t=kr(e);if(!t){console.assert(!1);return}let n=t.id!==this.space.id;this.space.id=t.id,this.space.name=t.name;let r=this.getField(`TABLE`);if(r.getOptions(!1),n){let e=X(this.space.id)?.[0];r.setValue(e?.id??``)}this.onTableChange_(r.getValue())},onTableChange_:function(e){let t=jr(this.space.id,e);if(!t){console.assert(!1);return}this.table.id=t.id,this.table.name=t.name,this.table.columns=t.columns,this.itemCount_=t.columns.length,this.updateShape_();for(let e=0;e<this.itemCount_;e++){let t=this.table.columns[e].id,n=this.getField(`COLUMN`+e);n.getOptions(!1),n.setValue(t,!1)}setTimeout(()=>{this.updateBlocks_(!0),this.updateCheck_()},0)},onColumnChange_:function(e,t){let n=this.table.columns.find(e=>e.id===t);if(!n){console.assert(!1);return}let r=this.getInput(`ADD`+e).connection,i=r.targetBlock();i&&i.dispose();let a=Gt(this.workspace,n.type);a&&(r.setCheck(null),r.connect(a.outputConnection)),this.updateCheck_()},decompose:function(e){let t=e.newBlock(`update_column_container_v1`);t.initSvg();let n=t.getInput(`STACK`).connection;for(let t=0;t<this.itemCount_;t++){let t=e.newBlock(`update_column_item_v1`);t.initSvg(),n.connect(t.previousConnection),n=t.nextConnection}return t},compose:function(e){let t=e.getInputTargetBlock(`STACK`),n=[],r=[];for(;t;){if(t.isInsertionMarker()){t=t.getNextBlock();continue}n.push(t.column_),r.push(t.valueConnection_),t=t.getNextBlock()}for(let e=0;e<this.itemCount_;e++){let t=this.getInput(`ADD`+e).connection.targetConnection;t&&r.indexOf(t)===-1&&t.disconnect()}this.itemCount_=n.length,this.updateShape_();for(let e=0;e<this.itemCount_;e++){let t=n[e]??this.table.columns?.[0]?.id??``;this.getField(`COLUMN`+e).setValue(t,!1)}setTimeout(()=>{for(let e=0;e<this.itemCount_;e++)this.getInput(`ADD`+e).setCheck(null),r[e]?.reconnect(this,`ADD`+e);this.updateBlocks_(),this.updateCheck_()},0)},saveConnections:function(e){let t=e.getInputTargetBlock(`STACK`),n=0;for(;t;){if(t.isInsertionMarker()){t=t.getNextBlock();continue}t.column_=this.getFieldValue(`COLUMN`+n),t.valueConnection_=this.getInput(`ADD`+n).connection.targetConnection,t=t.getNextBlock(),n++}},initShape_:function(){if(!this.isInFlyout&&!this.getInput(`ADD0`))for(let e=0;e<this.table.columns.length;e++){let t=this.table.columns[e],n=new b(()=>this.genColumnOpts_());this.appendValueInput(`ADD`+e).setAlign(u.Align.RIGHT).appendField(n,`COLUMN`+e),n.setValue(t.id,!1)}},updateShape_:function(){for(let e=this.itemCount_;this.getInput(`ADD`+e);e++){let t=this.getInput(`ADD`+e).connection.targetBlock();t&&t.dispose(),this.removeInput(`ADD`+e)}for(let e=0;e<this.itemCount_;e++){if(this.getInput(`ADD`+e))continue;let t=new b(()=>this.genColumnOpts_());this.appendValueInput(`ADD`+e).setAlign(u.Align.RIGHT).appendField(t,`COLUMN`+e)}},updateBlocks_:function(e){if(!this.isInsertionMarker())for(let t=0;t<this.itemCount_;t++){let n=this.getInput(`ADD`+t),r=n.connection,i=r.targetBlock();if(e)i&&i.dispose();else if(i)continue;let a=this.getFieldValue(`COLUMN`+t),o=this.table.columns.find(e=>e.id===a);if(!o)continue;n.setCheck(null);let s=Gt(this.workspace,o.type);s&&r.connect(s.outputConnection)}},updateCheck_:function(){for(let e=0;e<this.itemCount_;e++){let t=this.getFieldValue(`COLUMN`+e),n=this.table.columns.find(e=>e.id===t);if(!n)continue;let r=an(n.type);this.getInput(`ADD`+e).setCheck(r)}},checkWarning_:function(){let e=kr(this.space.id);if(!e){this.setWarningText(F(`WARN_SPACE_NOT_FOUND`));return}e.name!==this.space.name&&(this.space.name=e.name);let t=jr(this.space.id,this.table.id);if(!t){this.setWarningText(F(`WARN_TABLE_NOT_FOUND`));return}if(t.name!==this.table.name&&(this.table.name=t.name),!v(t.columns,this.table.columns)){this.setWarningText(F(`WARN_TABLE_HAS_CHANGED`));return}this.setWarningText(null)}},g.forBlock.update_column_v1=function(e){let t=g.quote_,n=e,r=n.space.id,i=n.table.id,a=[];for(let e=0;e<n.itemCount_;e++){let t=n.getFieldValue(`COLUMN`+e),r=n.table.columns.find(e=>e.id===t).name,i=g.valueToCode(n,`ADD`+e,_.ATOMIC)||`null`;a.push({name:r,value:i})}let o=`[`;return a.forEach(({name:e,value:n},r)=>{r!==0&&(o+=`,`),o+=`{name:${t(e)},value:${n}}`}),o+=`]`,[`{spaceId:${t(r)},tableId:${t(i)},columns:${o}}`,_.ATOMIC]};function Gr(e){let t=e.getInput(`TABLE`).connection;if(t.targetBlock())return;let n,r,i=Y()?.[0];if(i){let e=X(i.id)?.[0];if(e){n={space:{id:i.id,name:i.name},table:{id:e.id,name:e.name,columns:e.columns},itemCount:e.columns.length},r={};for(let t=0;t<e.columns.length;t++){let n=e.columns[t];r[`COLUMN`+t]=n.id}}}let a={type:`update_column_v1`,extraState:n,fields:r},o=l.blocks.append(a,e.workspace);t.connect(o.outputConnection)}function Kr(e){let t=e.getInput(`CONDITION`).connection;if(t.targetBlock())return;let n=l.blocks.append({type:`cond_atomic_v1`},e.workspace);t.connect(n.outputConnection)}function qr(e){let t=e.getInput(`HANDLE`).connection;if(t.targetBlock())return;let n=l.blocks.append({type:`compute_debug_trace_v1`,inputs:{OBJECT:{shadow:{type:`text_v1`},block:{type:`parameter_v1`,extraState:{key:`__message__`,name:`x-runtime-lib.message`,locale:!0}}}}},e.workspace);t.connect(n.previousConnection)}y.update_data_v1={init:function(){this.appendDummyInput().appendField(`%{BKY_DATA_V1_UPDATE_DATA_TITLE}`),this.setPreviousStatement(!0,null),this.setNextStatement(!0,null),this.setStyle(`procedure_blocks`),this.setTooltip(`%{BKY_DATA_V1_UPDATE_DATA_TOOLTIP}`),this.setHelpUrl(`%{BKY_DATA_V1_UPDATE_DATA_HELPURL}`)},saveExtraState:function(){return{}},loadExtraState:function(){this.updateShape_(),setTimeout(()=>{this.ensureBlocks()},0)},updateShape_:function(){this.getInput(`HANDLE`)||this.appendStatementInput(`HANDLE`).appendField(`%{BKY_DATA_DO}`),this.getInput(`DATA`)||(this.appendValueInput(`DATA`),this.moveInputBefore(`DATA`,`HANDLE`)),this.getInput(`MESSAGE`)||(this.appendValueInput(`MESSAGE`),this.moveInputBefore(`MESSAGE`,`DATA`)),this.getInput(`SUCCESS`)||(this.appendValueInput(`SUCCESS`).appendField(`%{BKY_DATA_RETURN}`),this.moveInputBefore(`SUCCESS`,`MESSAGE`)),this.getInput(`CONDITION`)||(this.appendValueInput(`CONDITION`).setCheck(`Condition`).setAlign(u.Align.RIGHT).appendField(`%{BKY_DATA_CONDITION}`),this.moveInputBefore(`CONDITION`,`SUCCESS`)),this.getInput(`TABLE`)||(this.appendValueInput(`TABLE`).setCheck(`UpdateColumn`).setAlign(u.Align.RIGHT).appendField(`%{BKY_DATA_TABLE}`),this.moveInputBefore(`TABLE`,`CONDITION`))},ensureBlocks:function(){this.isInsertionMarker()||(Gr(this),Kr(this),V(this,[[`SUCCESS`,`__success__`,`x-runtime-lib.success`,!0],[`MESSAGE`,`__message__`,`x-runtime-lib.message`,!0],[`DATA`,`__data__`,`x-runtime-lib.data`,!0]]),qr(this))}},g.forBlock.update_data_v1=function(e){let t=g.INDENT;return`{
153
153
  ${t}var __tx__ = typeof(__tx__) !== 'undefined' ? __tx__ : null;
154
- ${t}var __table__ = ${x.valueToCode(e,`TABLE`,_.ATOMIC)||`null`};
155
- ${t}var __condition__ = ${x.valueToCode(e,`CONDITION`,_.ATOMIC)||`null`};
154
+ ${t}var __table__ = ${g.valueToCode(e,`TABLE`,_.ATOMIC)||`null`};
155
+ ${t}var __condition__ = ${g.valueToCode(e,`CONDITION`,_.ATOMIC)||`null`};
156
156
  ${t}var __result__ = __updateDataV1__(__tx__, __table__, __condition__);
157
157
  ${t}var __success__ = __result__.success;
158
158
  ${t}var __message__ = __result__.message;
@@ -160,14 +160,14 @@ ${t}var __data__ = __result__.data;
160
160
  ${t}if (__tx__ && !__success__) {
161
161
  ${t}${t}throw __message__;
162
162
  ${t}}
163
- ${x.statementToCode(e,`HANDLE`)}}
164
- `};const Jr=e.xml;S.json_array_v1={init:function(){this.length=0,this.appendDummyInput(`OPEN_BRACKET`).appendField(` [ `),this.appendDummyInput(`ADD`).setAlign(b.Align.CENTRE).appendField(new a(Kt,20,20,void 0,()=>{this.isInFlyout||this.addEntry_()})),this.appendDummyInput(`CLOSE_BRACKET`).appendField(` ] `),this.setInputsInline(!1),this.setOutput(!0,`JsonArray`),this.setColour(350),this.setTooltip(``),this.setHelpUrl(``)},mutationToDom:function(){let e=Jr.createElement(`mutation`);return e.setAttribute(`items`,String(this.length)),e},domToMutation:function(e){this.length=Se(e.getAttribute(`items`)??``,0),this.initShape_()},initData:function(e){this.length=e,this.initShape_()},initShape_:function(){for(let e=0;e<this.length;e++){let t=`ENTRY`+e,n=this.appendValueInput(t);n.appendField(new a(Kt,20,20,void 0,()=>{this.isInFlyout||this.addEntry_(n)})),n.appendField(new i(String(e))),n.appendField(new a(qt,20,20,void 0,()=>{this.isInFlyout||this.removeEntry_(n)})),this.moveInputBefore(t,`ADD`)}},addEntry_:function(e){let t=this.length;e&&(t=Se(e.name.substring(5)));for(let e=this.length-1;e>=t;e--){let t=this.getInput(`ENTRY`+e);t.name=`ENTRY`+(e+1),t.fieldRow[1].setValue(e+1)}let n=this.appendValueInput(`ENTRY`+t);n.appendField(new a(Kt,20,20,void 0,()=>{this.isInFlyout||this.addEntry_(n)})),n.appendField(new i(String(t))),n.appendField(new a(qt,20,20,void 0,()=>{this.isInFlyout||this.removeEntry_(n)})),t===this.length?this.moveInputBefore(`ENTRY`+t,`ADD`):this.moveInputBefore(`ENTRY`+t,`ENTRY`+(t+1)),this.length++},removeEntry_:function(e){let t=e.name,n=this.getInputTargetBlock(t);n&&n.dispose(),this.removeInput(t);let r=Se(t.substring(5));for(let e=r+1;e<this.length;e++){let t=this.getInput(`ENTRY`+e);t.name=`ENTRY`+(e-1),t.fieldRow[1].setValue(e-1)}this.length--}},S.json_boolean_v1={init:function(){this.appendDummyInput().appendField(new m([[`false`,`false`],[`true`,`true`]]),`VALUE`),this.setOutput(!0,`JsonBoolean`),this.setColour(210)}};const Yr=e.xml;S.json_map_v1={init:function(){this.length=0,this.appendDummyInput(`OPEN_BRACKET`).appendField(` { `),this.appendDummyInput(`ADD`).setAlign(b.Align.CENTRE).appendField(new a(Kt,20,20,void 0,()=>{this.isInFlyout||this.addEntry_()})),this.appendDummyInput(`CLOSE_BRACHET`).appendField(` } `),this.setInputsInline(!1),this.setOutput(!0,`JsonMap`),this.setColour(120),this.setTooltip(``),this.setHelpUrl(``)},mutationToDom:function(){let e=Yr.createElement(`mutation`);for(let t=0;t<this.length;t++){let n=Yr.createElement(`item`);n.setAttribute(`key`,this.getFieldValue(`KEY`+t)),e.appendChild(n)}return e},domToMutation:function(e){let t=[];for(let n=0;n<e.childNodes.length;n++){let r=e.childNodes[n].getAttribute(`key`);r&&t.push(r)}this.length=t.length,this.initShape_(t)},initData:function(e){this.length=e.length,this.initShape_(e)},initShape_:function(e){for(let t=0;t<e.length;t++){let n=e[t],r=`ENTRY`+t,i=this.appendValueInput(r);i.appendField(new a(Kt,20,20,void 0,()=>{this.isInFlyout||this.addEntry_(i)})),i.appendField(new ve(n),`KEY`+t),i.appendField(new a(qt,20,20,void 0,()=>{this.isInFlyout||this.removeEntry_(i)})),this.moveInputBefore(r,`ADD`)}},addEntry_:function(e){let t=this.length;e&&(t=Se(e.name.substring(5)));for(let e=this.length-1;e>=t;e--)this.getField(`KEY`+e).name=`KEY`+(e+1),this.getInput(`ENTRY`+e).name=`ENTRY`+(e+1);let n=this.appendValueInput(`ENTRY`+t);n.appendField(new a(Kt,20,20,void 0,()=>{this.isInFlyout||this.addEntry_(n)})),n.appendField(new ve(`key`),`KEY`+t),n.appendField(new a(qt,20,20,void 0,()=>{this.isInFlyout||this.removeEntry_(n)})),t===this.length?this.moveInputBefore(`ENTRY`+t,`ADD`):this.moveInputBefore(`ENTRY`+t,`ENTRY`+(t+1)),this.length++},removeEntry_:function(e){let t=e.name,n=this.getInputTargetBlock(t);n&&n.dispose(),this.removeInput(t);let r=Se(t.substring(5));for(let e=r+1;e<this.length;e++)this.getField(`KEY`+e).name=`KEY`+(e-1),this.getInput(`ENTRY`+e).name=`ENTRY`+(e-1);this.length--}},S.json_number_v1={init:function(){this.appendDummyInput().appendField(new ne(0),`VALUE`),this.setOutput(!0,`JsonNumber`),this.setColour(230)}},S.json_root_v1={init:function(){this.appendDummyInput().setAlign(b.Align.CENTRE).appendField(`JSON`),this.appendValueInput(`JSON`).setCheck([`JsonMap`,`JsonArray`]),this.setDeletable(!1),this.setColour(250),this.setTooltip(``),this.setHelpUrl(``)}},S.json_string_v1={init:function(){this.appendDummyInput().appendField(`"`).appendField(new ve(``),`VALUE`).appendField(`"`),this.setOutput(!0,`JsonString`),this.setColour(160)}};const Xr=e.xml;S.list_create_container_v1={init:function(){this.appendDummyInput().appendField(`%{BKY_LIST_V1_CREATE_CONTAINER_TITLE}`),this.appendStatementInput(`STACK`),this.setStyle(`list_blocks`),this.contextMenu=!1}},S.list_create_item_v1={init:function(){this.appendDummyInput().appendField(`%{BKY_LIST_V1_CREATE_ITEM_TITLE}`),this.setPreviousStatement(!0),this.setNextStatement(!0),this.setStyle(`list_blocks`),this.contextMenu=!1}},S.list_create_v1={init:function(){this.itemCount_=0,this.setMutator(new s.MutatorIcon([`list_create_item_v1`],this)),this.setOutput(!0,`Array`),this.setStyle(`list_blocks`),this.setTooltip(`%{BKY_LIST_V1_CREATE_TOOLTIP}`),this.setHelpUrl(`%{BKY_LIST_V1_CREATE_HELPURL}`),this.updateShape_()},mutationToDom:function(){let e=Xr.createElement(`mutation`);return e.setAttribute(`items`,String(this.itemCount_)),e},domToMutation:function(e){let t=e.getAttribute(`items`)??``;this.itemCount_=parseInt(t,0),this.updateShape_()},saveExtraState:function(){return{itemCount:this.itemCount_}},loadExtraState:function(e){this.itemCount_=e.itemCount??0,this.updateShape_()},decompose:function(e){let t=e.newBlock(`list_create_container_v1`);t.initSvg();let n=t.getInput(`STACK`).connection;for(let t=0;t<this.itemCount_;t++){let t=e.newBlock(`list_create_item_v1`);t.initSvg(),n.connect(t.previousConnection),n=t.nextConnection}return t},compose:function(e){let t=e.getInputTargetBlock(`STACK`),n=[];for(;t;){if(t.isInsertionMarker()){t=t.getNextBlock();continue}n.push(t.valueConnection_),t=t.getNextBlock()}for(let e=0;e<this.itemCount_;e++){let t=this.getInput(`ADD`+e).connection.targetConnection;t&&!n.includes(t)&&t.disconnect()}this.itemCount_=n.length,this.updateShape_();for(let e=0;e<this.itemCount_;e++)n[e]?.reconnect(this,`ADD`+e)},saveConnections:function(e){let t=e.getInputTargetBlock(`STACK`),n=0;for(;t;){if(t.isInsertionMarker()){t=t.getNextBlock();continue}let e=this.getInput(`ADD`+n);t.valueConnection_=e?.connection.targetConnection,t=t.getNextBlock(),n++}},updateShape_:function(){this.itemCount_&&this.getInput(`EMPTY`)?this.removeInput(`EMPTY`):!this.itemCount_&&!this.getInput(`EMPTY`)&&this.appendDummyInput(`EMPTY`).appendField(`%{BKY_LIST_V1_CREATE_TITLE}`);for(let e=0;e<this.itemCount_;e++)this.getInput(`ADD`+e)||(this.appendValueInput(`ADD`+e).setCheck([`String`,`Number`,`Boolean`,`Array`,`Object`]),e===0&&this.getInput(`ADD`+e).setAlign(b.Align.RIGHT).appendField(`%{BKY_LIST_V1_CREATE_TITLE}`));for(let e=this.itemCount_;this.getInput(`ADD`+e);e++)this.removeInput(`ADD`+e)}},x.forBlock.list_create_v1=function(e){let t=e,n=Array(t.itemCount_);for(let e=0;e<t.itemCount_;e++)n[e]=x.valueToCode(t,`ADD`+e,_.NONE)||`null`;return[`[`+n.join(`, `)+`]`,_.ATOMIC]},h([{type:`list_delete_v1`,message0:`%{BKY_LIST_V1_DELETE_TITLE}`,args0:[{type:`input_value`,name:`VALUE`,check:`Array`},{type:`input_value`,name:`AT`,check:`Number`}],inputsInline:!0,previousStatement:null,nextStatement:null,style:`list_blocks`,tooltip:`%{BKY_LIST_V1_DELETE_TOOLTIP}`,helpUrl:`%{BKY_LIST_V1_DELETE_HELPURL}`}]),x.forBlock.list_delete_v1=function(e){return`${x.valueToCode(e,`VALUE`,_.MEMBER)||`[]`}.splice(${x.getAdjusted(e,`AT`)}, 1)`},h([{type:`list_get_v1`,message0:`%{BKY_LIST_V1_GET_TITLE}`,args0:[{type:`input_value`,name:`VALUE`,check:`Array`},{type:`input_value`,name:`AT`,check:`Number`}],inputsInline:!0,output:null,style:`list_blocks`,tooltip:`%{BKY_LIST_V1_GET_TOOLTIP}`,helpUrl:`%{BKY_LIST_V1_GET_HELPURL}`}]),x.forBlock.list_get_v1=function(e){return[`${x.valueToCode(e,`VALUE`,_.MEMBER)||`[]`}[${x.getAdjusted(e,`AT`)}]`,_.MEMBER]},h([{type:`list_get_sublist_v1`,message0:`%{BKY_LIST_V1_GET_SUBLIST_TITLE}`,args0:[{type:`input_value`,name:`LIST`,check:`Array`},{type:`input_value`,name:`START`,check:`Number`},{type:`input_value`,name:`END`,check:`Number`}],inputsInline:!0,output:`Array`,style:`list_blocks`,tooltip:`%{BKY_LIST_V1_GET_SUBLIST_TOOLTIP}`,helpUrl:`%{BKY_LIST_V1_GET_SUBLIST_HELPURL}`}]),x.forBlock.list_get_sublist_v1=function(e){return[`${x.valueToCode(e,`LIST`,_.MEMBER)||`[]`}.slice(${x.getAdjusted(e,`START`)}, ${x.getAdjusted(e,`END`,1)})`,_.FUNCTION_CALL]},h([{type:`list_is_empty_v1`,message0:`%{BKY_LIST_V1_IS_EMPTY_TITLE}`,args0:[{type:`input_value`,name:`VALUE`,check:`Array`}],output:`Boolean`,style:`list_blocks`,tooltip:`%{BKY_LIST_V1_IS_EMPTY_TOOLTIP}`,helpUrl:`%{BKY_LIST_V1_IS_EMPTY_HELPURL}`}]),x.forBlock.list_is_empty_v1=function(e){return[`!${x.valueToCode(e,`VALUE`,_.MEMBER)||`[]`}.length`,_.LOGICAL_NOT]},h([{type:`list_join_v1`,message0:`%{BKY_LIST_V1_JOIN_TITLE}`,args0:[{type:`input_value`,name:`LIST`,check:`Array`},{type:`input_value`,name:`DELIM`,check:`String`}],inputsInline:!0,output:`String`,style:`list_blocks`,tooltip:`%{BKY_LIST_V1_JOIN_TOOLTIP}`,helpUrl:`%{BKY_LIST_V1_JOIN_HELPURL}`}]),x.forBlock.list_join_v1=function(e){return[`${x.valueToCode(e,`LIST`,_.MEMBER)||`[]`}.join(${x.valueToCode(e,`DELIM`,_.NONE)||`''`})`,_.FUNCTION_CALL]},h([{type:`list_length_v1`,message0:`%{BKY_LIST_V1_LENGTH_TITLE}`,args0:[{type:`input_value`,name:`VALUE`,check:`Array`}],output:`Number`,style:`list_blocks`,tooltip:`%{BKY_LIST_V1_LENGTH_TOOLTIP}`,helpUrl:`%{BKY_LIST_V1_LENGTH_HELPURL}`}]),x.forBlock.list_length_v1=function(e){return[`${x.valueToCode(e,`VALUE`,_.MEMBER)||`[]`}.length`,_.MEMBER]},h([{type:`list_reverse_v1`,message0:`%{BKY_LIST_V1_REVERSE_TITLE}`,args0:[{type:`input_value`,name:`LIST`,check:`Array`}],inputsInline:!0,output:`Array`,style:`list_blocks`,tooltip:`%{BKY_LIST_V1_REVERSE_TOOLTIP}`,helpUrl:`%{BKY_LIST_V1_REVERSE_HELPURL}`}]),x.forBlock.list_reverse_v1=function(e){return[`${x.valueToCode(e,`LIST`,_.NONE)||`[]`}.slice().reverse()`,_.FUNCTION_CALL]},h([{type:`list_set_v1`,message0:`%{BKY_LIST_V1_SET_TITLE}`,args0:[{type:`input_value`,name:`LIST`,check:`Array`},{type:`input_value`,name:`AT`,check:`Number`},{type:`input_value`,name:`VALUE`,check:null}],inputsInline:!0,previousStatement:null,nextStatement:null,style:`list_blocks`,tooltip:`%{BKY_LIST_V1_SET_TOOLTIP}`,helpUrl:`%{BKY_LIST_V1_SET_HELPURL}`}]),x.forBlock.list_set_v1=function(e){return`${x.valueToCode(e,`LIST`,_.MEMBER)||`[]`}[${x.getAdjusted(e,`AT`)}] = ${x.valueToCode(e,`VALUE`,_.ASSIGNMENT)||`null`};\n`},r.register(`logic_op_tooltip_v1`,r.buildTooltipForDropdown(`OP`,{EQ:`%{BKY_LOGIC_V1_COMPARE_TOOLTIP_EQ}`,NEQ:`%{BKY_LOGIC_V1_COMPARE_TOOLTIP_NEQ}`,LT:`%{BKY_LOGIC_V1_COMPARE_TOOLTIP_LT}`,LTE:`%{BKY_LOGIC_V1_COMPARE_TOOLTIP_LTE}`,GT:`%{BKY_LOGIC_V1_COMPARE_TOOLTIP_GT}`,GTE:`%{BKY_LOGIC_V1_COMPARE_TOOLTIP_GTE}`,AND:`%{BKY_LOGIC_V1_OPERATION_TOOLTIP_AND}`,OR:`%{BKY_LOGIC_V1_OPERATION_TOOLTIP_OR}`})),h([{type:`logic_boolean_v1`,message0:`%1`,args0:[{type:`field_dropdown`,name:`BOOL`,options:[[`%{BKY_LOGIC_BOOLEAN_FALSE}`,`FALSE`],[`%{BKY_LOGIC_BOOLEAN_TRUE}`,`TRUE`]]}],output:`Boolean`,style:`logic_blocks`,tooltip:`%{BKY_LOGIC_V1_BOOLEAN_TOOLTIP}`,helpUrl:`%{BKY_LOGIC_V1_BOOLEAN_HELPURL}`}]),x.forBlock.logic_boolean_v1=function(e){return[e.getFieldValue(`BOOL`)===`TRUE`?`true`:`false`,_.ATOMIC]};const Zr={onchange:function(e){this.prevBlocks_||(this.prevBlocks_=[null,null]);let t=this.getInputTargetBlock(`A`),n=this.getInputTargetBlock(`B`);if(t&&n&&!this.workspace.connectionChecker.doTypeChecks(t.outputConnection,n.outputConnection)){p.setGroup(e.group);let r=this.prevBlocks_[0];r!==t&&(t.unplug(),r&&!r.isDisposed()&&!r.isShadow()&&this.getInput(`A`).connection.connect(r.outputConnection));let i=this.prevBlocks_[1];i!==n&&(n.unplug(),i&&!i.isDisposed()&&!i.isShadow()&&this.getInput(`B`).connection.connect(i.outputConnection)),this.bumpNeighbours(),p.setGroup(!1)}this.prevBlocks_[0]=this.getInputTargetBlock(`A`),this.prevBlocks_[1]=this.getInputTargetBlock(`B`)}};r.register(`logic_compare_v1`,function(){this.mixin(Zr)}),h([{type:`logic_compare_v1`,message0:`%1 %2 %3`,args0:[{type:`input_value`,name:`A`},{type:`field_dropdown`,name:`OP`,options:[[`=`,`EQ`],[`≠`,`NEQ`],[`‏<`,`LT`],[`‏≤`,`LTE`],[`‏>`,`GT`],[`‏≥`,`GTE`]]},{type:`input_value`,name:`B`}],inputsInline:!0,output:`Boolean`,style:`logic_blocks`,helpUrl:`%{BKY_LOGIC_V1_COMPARE_HELPURL}`,extensions:[`logic_compare_v1`,`logic_op_tooltip_v1`]}]),x.forBlock.logic_compare_v1=function(e){let t={EQ:`==`,NEQ:`!=`,LT:`<`,LTE:`<=`,GT:`>`,GTE:`>=`}[e.getFieldValue(`OP`)],n=_.RELATIONAL;return(t===`==`||t===`!=`)&&(n=_.EQUALITY),[`${x.valueToCode(e,`A`,n)||`0`} ${t} ${x.valueToCode(e,`B`,n)||`0`}`,n]},r.registerMutator(`logic_if_v1_mutator`,{elseIfCount_:0,hasElse_:!1,mutationToDom:function(){if(this.elseIfCount_<=0&&!this.hasElse_)return null;let t=e.xml.createElement(`mutation`);return this.elseIfCount_>0&&t.setAttribute(`elseIf`,String(this.elseIfCount_)),this.hasElse_&&t.setAttribute(`else`,`TRUE`),t},domToMutation:function(e){this.elseIfCount_=parseInt(e.getAttribute(`elseif`),10)||0,this.hasElse_=e.getAttribute(`else`)===`TRUE`,this.rebuildShape_()},saveExtraState:function(){if(this.elseIfCount_<=0&&!this.hasElse_)return null;let e=Object.create(null);return this.elseIfCount_>0&&(e.elseIfCount=this.elseIfCount_),this.hasElse_&&(e.hasElse=!0),e},loadExtraState:function(e){this.elseIfCount_=e.elseIfCount||0,this.hasElse_=!!e.hasElse,this.updateShape_()},decompose:function(e){let t=e.newBlock(`logic_if_if_v1`);t.initSvg();let n=t.nextConnection;for(let t=0;t<this.elseIfCount_;t++){let t=e.newBlock(`logic_if_else_if_v1`);t.initSvg(),n.connect(t.previousConnection),n=t.nextConnection}if(this.hasElse_){let t=e.newBlock(`logic_if_else_v1`);t.initSvg(),n.connect(t.previousConnection)}return t},compose:function(e){let t=e.nextConnection.targetBlock();this.elseIfCount_=0,this.hasElse_=!1;let n=[null],r=[null],i=null;for(;t;){if(t.isInsertionMarker()){t=t.getNextBlock();continue}switch(t.type){case`logic_if_else_if_v1`:this.elseIfCount_++,n.push(t.valueConnection_),r.push(t.statementConnection_);break;case`logic_if_else_v1`:this.hasElse_=!0,i=t.statementConnection_;break;default:throw TypeError(`Unknown block type: `+t.type)}t=t.getNextBlock()}this.updateShape_(),this.reconnectChildBlocks_(n,r,i)},saveConnections:function(e){let t=e.nextConnection.targetBlock(),n=1;for(;t;){if(t.isInsertionMarker()){t=t.getNextBlock();continue}switch(t.type){case`Logic_if_else_if_v1`:{let e=this.getInput(`IF`+n),r=this.getInput(`DO`+n);t.valueConnection_=e&&e.connection.targetConnection,t.statementConnection_=r&&r.connection.targetConnection,n++;break}case`logic_if_else_v1`:{let e=this.getInput(`ELSE`);t.statementConnection_=e&&e.connection.targetConnection;break}default:throw TypeError(`Unknown block type: `+t.type)}t=t.getNextBlock()}},rebuildShape_:function(){let e=[null],t=[null],n=null;this.getInput(`ELSE`)&&(n=this.getInput(`ELSE`).connection.targetConnection);for(let n=1;this.getInput(`IF`+n);n++){let r=this.getInput(`IF`+n),i=this.getInput(`DO`+n);e.push(r.connection.targetConnection),t.push(i.connection.targetConnection)}this.updateShape_(),this.reconnectChildBlocks_(e,t,n)},updateShape_:function(){this.getInput(`ELSE`)&&this.removeInput(`ELSE`);for(let e=1;this.getInput(`IF`+e);e++)this.removeInput(`IF`+e),this.removeInput(`DO`+e);for(let e=1;e<=this.elseIfCount_;e++)this.appendValueInput(`IF`+e).setCheck(`Boolean`).appendField(F(`LOGIC_ELSE_IF`)),this.appendStatementInput(`DO`+e).appendField(F(`LOGIC_DO`));this.hasElse_&&this.appendStatementInput(`ELSE`).appendField(F(`LOGIC_ELSE`))},reconnectChildBlocks_:function(e,t,n){for(let n=1;n<=this.elseIfCount_;n++)e[n]?.reconnect(this,`IF`+n),t[n]?.reconnect(this,`DO`+n);n?.reconnect(this,`ELSE`)}},void 0,[`logic_if_else_if_v1`,`logic_if_else_v1`]),h([{type:`logic_if_v1`,message0:`%{BKY_LOGIC_IF} %1`,args0:[{type:`input_value`,name:`IF0`,check:`Boolean`}],message1:`%{BKY_LOGIC_DO} %1`,args1:[{type:`input_statement`,name:`DO0`}],previousStatement:null,nextStatement:null,style:`logic_blocks`,helpUrl:`%{BKY_LOGIC_V1_IF_HELPURL`,suppressPrefixSuffix:!0,mutator:`logic_if_v1_mutator`},{type:`logic_if_if_v1`,message0:`%{BKY_LOGIC_IF}`,nextStatement:null,enableContextMenu:!1,style:`logic_blocks`},{type:`logic_if_else_if_v1`,message0:`%{BKY_LOGIC_ELSE_IF}`,previousStatement:null,nextStatement:null,enableContextMenu:!1,style:`logic_blocks`},{type:`logic_if_else_v1`,message0:`%{BKY_LOGIC_ELSE}`,previousStatement:null,enableContextMenu:!1,style:`logic_blocks`}]),x.forBlock.logic_if_v1=function(e){let t=0,n=``;x.STATEMENT_PREFIX&&(n+=x.injectId(x.STATEMENT_PREFIX,e));do{let r=x.valueToCode(e,`IF`+t,_.NONE)||`false`,i=x.statementToCode(e,`DO`+t);x.STATEMENT_SUFFIX&&(i=x.prefixLines(x.injectId(x.STATEMENT_SUFFIX,e),x.INDENT)+i),n+=(t>0?` else `:``)+`if (`+r+`) {
165
- `+i+`}`,t++}while(e.getInput(`IF`+t));if(e.getInput(`ELSE`)||x.STATEMENT_SUFFIX){let t=x.statementToCode(e,`ELSE`);x.STATEMENT_SUFFIX&&(t=x.prefixLines(x.injectId(x.STATEMENT_SUFFIX,e),x.INDENT)+t),n+=` else {
163
+ ${g.statementToCode(e,`HANDLE`)}}
164
+ `};const Jr=p.xml;y.json_array_v1={init:function(){this.length=0,this.appendDummyInput(`OPEN_BRACKET`).appendField(` [ `),this.appendDummyInput(`ADD`).setAlign(u.Align.CENTRE).appendField(new h(Kt,20,20,void 0,()=>{this.isInFlyout||this.addEntry_()})),this.appendDummyInput(`CLOSE_BRACKET`).appendField(` ] `),this.setInputsInline(!1),this.setOutput(!0,`JsonArray`),this.setColour(350),this.setTooltip(``),this.setHelpUrl(``)},mutationToDom:function(){let e=Jr.createElement(`mutation`);return e.setAttribute(`items`,String(this.length)),e},domToMutation:function(e){this.length=me(e.getAttribute(`items`)??``,0),this.initShape_()},initData:function(e){this.length=e,this.initShape_()},initShape_:function(){for(let e=0;e<this.length;e++){let t=`ENTRY`+e,n=this.appendValueInput(t);n.appendField(new h(Kt,20,20,void 0,()=>{this.isInFlyout||this.addEntry_(n)})),n.appendField(new i(String(e))),n.appendField(new h(qt,20,20,void 0,()=>{this.isInFlyout||this.removeEntry_(n)})),this.moveInputBefore(t,`ADD`)}},addEntry_:function(e){let t=this.length;e&&(t=me(e.name.substring(5)));for(let e=this.length-1;e>=t;e--){let t=this.getInput(`ENTRY`+e);t.name=`ENTRY`+(e+1),t.fieldRow[1].setValue(e+1)}let n=this.appendValueInput(`ENTRY`+t);n.appendField(new h(Kt,20,20,void 0,()=>{this.isInFlyout||this.addEntry_(n)})),n.appendField(new i(String(t))),n.appendField(new h(qt,20,20,void 0,()=>{this.isInFlyout||this.removeEntry_(n)})),t===this.length?this.moveInputBefore(`ENTRY`+t,`ADD`):this.moveInputBefore(`ENTRY`+t,`ENTRY`+(t+1)),this.length++},removeEntry_:function(e){let t=e.name,n=this.getInputTargetBlock(t);n&&n.dispose(),this.removeInput(t);let r=me(t.substring(5));for(let e=r+1;e<this.length;e++){let t=this.getInput(`ENTRY`+e);t.name=`ENTRY`+(e-1),t.fieldRow[1].setValue(e-1)}this.length--}},y.json_boolean_v1={init:function(){this.appendDummyInput().appendField(new b([[`false`,`false`],[`true`,`true`]]),`VALUE`),this.setOutput(!0,`JsonBoolean`),this.setColour(210)}};const Yr=p.xml;y.json_map_v1={init:function(){this.length=0,this.appendDummyInput(`OPEN_BRACKET`).appendField(` { `),this.appendDummyInput(`ADD`).setAlign(u.Align.CENTRE).appendField(new h(Kt,20,20,void 0,()=>{this.isInFlyout||this.addEntry_()})),this.appendDummyInput(`CLOSE_BRACHET`).appendField(` } `),this.setInputsInline(!1),this.setOutput(!0,`JsonMap`),this.setColour(120),this.setTooltip(``),this.setHelpUrl(``)},mutationToDom:function(){let e=Yr.createElement(`mutation`);for(let t=0;t<this.length;t++){let n=Yr.createElement(`item`);n.setAttribute(`key`,this.getFieldValue(`KEY`+t)),e.appendChild(n)}return e},domToMutation:function(e){let t=[];for(let n=0;n<e.childNodes.length;n++){let r=e.childNodes[n].getAttribute(`key`);r&&t.push(r)}this.length=t.length,this.initShape_(t)},initData:function(e){this.length=e.length,this.initShape_(e)},initShape_:function(e){for(let t=0;t<e.length;t++){let n=e[t],r=`ENTRY`+t,i=this.appendValueInput(r);i.appendField(new h(Kt,20,20,void 0,()=>{this.isInFlyout||this.addEntry_(i)})),i.appendField(new f(n),`KEY`+t),i.appendField(new h(qt,20,20,void 0,()=>{this.isInFlyout||this.removeEntry_(i)})),this.moveInputBefore(r,`ADD`)}},addEntry_:function(e){let t=this.length;e&&(t=me(e.name.substring(5)));for(let e=this.length-1;e>=t;e--)this.getField(`KEY`+e).name=`KEY`+(e+1),this.getInput(`ENTRY`+e).name=`ENTRY`+(e+1);let n=this.appendValueInput(`ENTRY`+t);n.appendField(new h(Kt,20,20,void 0,()=>{this.isInFlyout||this.addEntry_(n)})),n.appendField(new f(`key`),`KEY`+t),n.appendField(new h(qt,20,20,void 0,()=>{this.isInFlyout||this.removeEntry_(n)})),t===this.length?this.moveInputBefore(`ENTRY`+t,`ADD`):this.moveInputBefore(`ENTRY`+t,`ENTRY`+(t+1)),this.length++},removeEntry_:function(e){let t=e.name,n=this.getInputTargetBlock(t);n&&n.dispose(),this.removeInput(t);let r=me(t.substring(5));for(let e=r+1;e<this.length;e++)this.getField(`KEY`+e).name=`KEY`+(e-1),this.getInput(`ENTRY`+e).name=`ENTRY`+(e-1);this.length--}},y.json_number_v1={init:function(){this.appendDummyInput().appendField(new r(0),`VALUE`),this.setOutput(!0,`JsonNumber`),this.setColour(230)}},y.json_root_v1={init:function(){this.appendDummyInput().setAlign(u.Align.CENTRE).appendField(`JSON`),this.appendValueInput(`JSON`).setCheck([`JsonMap`,`JsonArray`]),this.setDeletable(!1),this.setColour(250),this.setTooltip(``),this.setHelpUrl(``)}},y.json_string_v1={init:function(){this.appendDummyInput().appendField(`"`).appendField(new f(``),`VALUE`).appendField(`"`),this.setOutput(!0,`JsonString`),this.setColour(160)}};const Xr=p.xml;y.list_create_container_v1={init:function(){this.appendDummyInput().appendField(`%{BKY_LIST_V1_CREATE_CONTAINER_TITLE}`),this.appendStatementInput(`STACK`),this.setStyle(`list_blocks`),this.contextMenu=!1}},y.list_create_item_v1={init:function(){this.appendDummyInput().appendField(`%{BKY_LIST_V1_CREATE_ITEM_TITLE}`),this.setPreviousStatement(!0),this.setNextStatement(!0),this.setStyle(`list_blocks`),this.contextMenu=!1}},y.list_create_v1={init:function(){this.itemCount_=0,this.setMutator(new oe.MutatorIcon([`list_create_item_v1`],this)),this.setOutput(!0,`Array`),this.setStyle(`list_blocks`),this.setTooltip(`%{BKY_LIST_V1_CREATE_TOOLTIP}`),this.setHelpUrl(`%{BKY_LIST_V1_CREATE_HELPURL}`),this.updateShape_()},mutationToDom:function(){let e=Xr.createElement(`mutation`);return e.setAttribute(`items`,String(this.itemCount_)),e},domToMutation:function(e){let t=e.getAttribute(`items`)??``;this.itemCount_=parseInt(t,0),this.updateShape_()},saveExtraState:function(){return{itemCount:this.itemCount_}},loadExtraState:function(e){this.itemCount_=e.itemCount??0,this.updateShape_()},decompose:function(e){let t=e.newBlock(`list_create_container_v1`);t.initSvg();let n=t.getInput(`STACK`).connection;for(let t=0;t<this.itemCount_;t++){let t=e.newBlock(`list_create_item_v1`);t.initSvg(),n.connect(t.previousConnection),n=t.nextConnection}return t},compose:function(e){let t=e.getInputTargetBlock(`STACK`),n=[];for(;t;){if(t.isInsertionMarker()){t=t.getNextBlock();continue}n.push(t.valueConnection_),t=t.getNextBlock()}for(let e=0;e<this.itemCount_;e++){let t=this.getInput(`ADD`+e).connection.targetConnection;t&&!n.includes(t)&&t.disconnect()}this.itemCount_=n.length,this.updateShape_();for(let e=0;e<this.itemCount_;e++)n[e]?.reconnect(this,`ADD`+e)},saveConnections:function(e){let t=e.getInputTargetBlock(`STACK`),n=0;for(;t;){if(t.isInsertionMarker()){t=t.getNextBlock();continue}let e=this.getInput(`ADD`+n);t.valueConnection_=e?.connection.targetConnection,t=t.getNextBlock(),n++}},updateShape_:function(){this.itemCount_&&this.getInput(`EMPTY`)?this.removeInput(`EMPTY`):!this.itemCount_&&!this.getInput(`EMPTY`)&&this.appendDummyInput(`EMPTY`).appendField(`%{BKY_LIST_V1_CREATE_TITLE}`);for(let e=0;e<this.itemCount_;e++)this.getInput(`ADD`+e)||(this.appendValueInput(`ADD`+e).setCheck([`String`,`Number`,`Boolean`,`Array`,`Object`]),e===0&&this.getInput(`ADD`+e).setAlign(u.Align.RIGHT).appendField(`%{BKY_LIST_V1_CREATE_TITLE}`));for(let e=this.itemCount_;this.getInput(`ADD`+e);e++)this.removeInput(`ADD`+e)}},g.forBlock.list_create_v1=function(e){let t=e,n=Array(t.itemCount_);for(let e=0;e<t.itemCount_;e++)n[e]=g.valueToCode(t,`ADD`+e,_.NONE)||`null`;return[`[`+n.join(`, `)+`]`,_.ATOMIC]},t([{type:`list_delete_v1`,message0:`%{BKY_LIST_V1_DELETE_TITLE}`,args0:[{type:`input_value`,name:`VALUE`,check:`Array`},{type:`input_value`,name:`AT`,check:`Number`}],inputsInline:!0,previousStatement:null,nextStatement:null,style:`list_blocks`,tooltip:`%{BKY_LIST_V1_DELETE_TOOLTIP}`,helpUrl:`%{BKY_LIST_V1_DELETE_HELPURL}`}]),g.forBlock.list_delete_v1=function(e){return`${g.valueToCode(e,`VALUE`,_.MEMBER)||`[]`}.splice(${g.getAdjusted(e,`AT`)}, 1)`},t([{type:`list_get_v1`,message0:`%{BKY_LIST_V1_GET_TITLE}`,args0:[{type:`input_value`,name:`VALUE`,check:`Array`},{type:`input_value`,name:`AT`,check:`Number`}],inputsInline:!0,output:null,style:`list_blocks`,tooltip:`%{BKY_LIST_V1_GET_TOOLTIP}`,helpUrl:`%{BKY_LIST_V1_GET_HELPURL}`}]),g.forBlock.list_get_v1=function(e){return[`${g.valueToCode(e,`VALUE`,_.MEMBER)||`[]`}[${g.getAdjusted(e,`AT`)}]`,_.MEMBER]},t([{type:`list_get_sublist_v1`,message0:`%{BKY_LIST_V1_GET_SUBLIST_TITLE}`,args0:[{type:`input_value`,name:`LIST`,check:`Array`},{type:`input_value`,name:`START`,check:`Number`},{type:`input_value`,name:`END`,check:`Number`}],inputsInline:!0,output:`Array`,style:`list_blocks`,tooltip:`%{BKY_LIST_V1_GET_SUBLIST_TOOLTIP}`,helpUrl:`%{BKY_LIST_V1_GET_SUBLIST_HELPURL}`}]),g.forBlock.list_get_sublist_v1=function(e){return[`${g.valueToCode(e,`LIST`,_.MEMBER)||`[]`}.slice(${g.getAdjusted(e,`START`)}, ${g.getAdjusted(e,`END`,1)})`,_.FUNCTION_CALL]},t([{type:`list_is_empty_v1`,message0:`%{BKY_LIST_V1_IS_EMPTY_TITLE}`,args0:[{type:`input_value`,name:`VALUE`,check:`Array`}],output:`Boolean`,style:`list_blocks`,tooltip:`%{BKY_LIST_V1_IS_EMPTY_TOOLTIP}`,helpUrl:`%{BKY_LIST_V1_IS_EMPTY_HELPURL}`}]),g.forBlock.list_is_empty_v1=function(e){return[`!${g.valueToCode(e,`VALUE`,_.MEMBER)||`[]`}.length`,_.LOGICAL_NOT]},t([{type:`list_join_v1`,message0:`%{BKY_LIST_V1_JOIN_TITLE}`,args0:[{type:`input_value`,name:`LIST`,check:`Array`},{type:`input_value`,name:`DELIM`,check:`String`}],inputsInline:!0,output:`String`,style:`list_blocks`,tooltip:`%{BKY_LIST_V1_JOIN_TOOLTIP}`,helpUrl:`%{BKY_LIST_V1_JOIN_HELPURL}`}]),g.forBlock.list_join_v1=function(e){return[`${g.valueToCode(e,`LIST`,_.MEMBER)||`[]`}.join(${g.valueToCode(e,`DELIM`,_.NONE)||`''`})`,_.FUNCTION_CALL]},t([{type:`list_length_v1`,message0:`%{BKY_LIST_V1_LENGTH_TITLE}`,args0:[{type:`input_value`,name:`VALUE`,check:`Array`}],output:`Number`,style:`list_blocks`,tooltip:`%{BKY_LIST_V1_LENGTH_TOOLTIP}`,helpUrl:`%{BKY_LIST_V1_LENGTH_HELPURL}`}]),g.forBlock.list_length_v1=function(e){return[`${g.valueToCode(e,`VALUE`,_.MEMBER)||`[]`}.length`,_.MEMBER]},t([{type:`list_reverse_v1`,message0:`%{BKY_LIST_V1_REVERSE_TITLE}`,args0:[{type:`input_value`,name:`LIST`,check:`Array`}],inputsInline:!0,output:`Array`,style:`list_blocks`,tooltip:`%{BKY_LIST_V1_REVERSE_TOOLTIP}`,helpUrl:`%{BKY_LIST_V1_REVERSE_HELPURL}`}]),g.forBlock.list_reverse_v1=function(e){return[`${g.valueToCode(e,`LIST`,_.NONE)||`[]`}.slice().reverse()`,_.FUNCTION_CALL]},t([{type:`list_set_v1`,message0:`%{BKY_LIST_V1_SET_TITLE}`,args0:[{type:`input_value`,name:`LIST`,check:`Array`},{type:`input_value`,name:`AT`,check:`Number`},{type:`input_value`,name:`VALUE`,check:null}],inputsInline:!0,previousStatement:null,nextStatement:null,style:`list_blocks`,tooltip:`%{BKY_LIST_V1_SET_TOOLTIP}`,helpUrl:`%{BKY_LIST_V1_SET_HELPURL}`}]),g.forBlock.list_set_v1=function(e){return`${g.valueToCode(e,`LIST`,_.MEMBER)||`[]`}[${g.getAdjusted(e,`AT`)}] = ${g.valueToCode(e,`VALUE`,_.ASSIGNMENT)||`null`};\n`},m.register(`logic_op_tooltip_v1`,m.buildTooltipForDropdown(`OP`,{EQ:`%{BKY_LOGIC_V1_COMPARE_TOOLTIP_EQ}`,NEQ:`%{BKY_LOGIC_V1_COMPARE_TOOLTIP_NEQ}`,LT:`%{BKY_LOGIC_V1_COMPARE_TOOLTIP_LT}`,LTE:`%{BKY_LOGIC_V1_COMPARE_TOOLTIP_LTE}`,GT:`%{BKY_LOGIC_V1_COMPARE_TOOLTIP_GT}`,GTE:`%{BKY_LOGIC_V1_COMPARE_TOOLTIP_GTE}`,AND:`%{BKY_LOGIC_V1_OPERATION_TOOLTIP_AND}`,OR:`%{BKY_LOGIC_V1_OPERATION_TOOLTIP_OR}`})),t([{type:`logic_boolean_v1`,message0:`%1`,args0:[{type:`field_dropdown`,name:`BOOL`,options:[[`%{BKY_LOGIC_BOOLEAN_FALSE}`,`FALSE`],[`%{BKY_LOGIC_BOOLEAN_TRUE}`,`TRUE`]]}],output:`Boolean`,style:`logic_blocks`,tooltip:`%{BKY_LOGIC_V1_BOOLEAN_TOOLTIP}`,helpUrl:`%{BKY_LOGIC_V1_BOOLEAN_HELPURL}`}]),g.forBlock.logic_boolean_v1=function(e){return[e.getFieldValue(`BOOL`)===`TRUE`?`true`:`false`,_.ATOMIC]};const Zr={onchange:function(e){this.prevBlocks_||(this.prevBlocks_=[null,null]);let t=this.getInputTargetBlock(`A`),n=this.getInputTargetBlock(`B`);if(t&&n&&!this.workspace.connectionChecker.doTypeChecks(t.outputConnection,n.outputConnection)){x.setGroup(e.group);let r=this.prevBlocks_[0];r!==t&&(t.unplug(),r&&!r.isDisposed()&&!r.isShadow()&&this.getInput(`A`).connection.connect(r.outputConnection));let i=this.prevBlocks_[1];i!==n&&(n.unplug(),i&&!i.isDisposed()&&!i.isShadow()&&this.getInput(`B`).connection.connect(i.outputConnection)),this.bumpNeighbours(),x.setGroup(!1)}this.prevBlocks_[0]=this.getInputTargetBlock(`A`),this.prevBlocks_[1]=this.getInputTargetBlock(`B`)}};m.register(`logic_compare_v1`,function(){this.mixin(Zr)}),t([{type:`logic_compare_v1`,message0:`%1 %2 %3`,args0:[{type:`input_value`,name:`A`},{type:`field_dropdown`,name:`OP`,options:[[`=`,`EQ`],[`≠`,`NEQ`],[`‏<`,`LT`],[`‏≤`,`LTE`],[`‏>`,`GT`],[`‏≥`,`GTE`]]},{type:`input_value`,name:`B`}],inputsInline:!0,output:`Boolean`,style:`logic_blocks`,helpUrl:`%{BKY_LOGIC_V1_COMPARE_HELPURL}`,extensions:[`logic_compare_v1`,`logic_op_tooltip_v1`]}]),g.forBlock.logic_compare_v1=function(e){let t={EQ:`==`,NEQ:`!=`,LT:`<`,LTE:`<=`,GT:`>`,GTE:`>=`}[e.getFieldValue(`OP`)],n=_.RELATIONAL;return(t===`==`||t===`!=`)&&(n=_.EQUALITY),[`${g.valueToCode(e,`A`,n)||`0`} ${t} ${g.valueToCode(e,`B`,n)||`0`}`,n]},m.registerMutator(`logic_if_v1_mutator`,{elseIfCount_:0,hasElse_:!1,mutationToDom:function(){if(this.elseIfCount_<=0&&!this.hasElse_)return null;let e=p.xml.createElement(`mutation`);return this.elseIfCount_>0&&e.setAttribute(`elseIf`,String(this.elseIfCount_)),this.hasElse_&&e.setAttribute(`else`,`TRUE`),e},domToMutation:function(e){this.elseIfCount_=parseInt(e.getAttribute(`elseif`),10)||0,this.hasElse_=e.getAttribute(`else`)===`TRUE`,this.rebuildShape_()},saveExtraState:function(){if(this.elseIfCount_<=0&&!this.hasElse_)return null;let e=Object.create(null);return this.elseIfCount_>0&&(e.elseIfCount=this.elseIfCount_),this.hasElse_&&(e.hasElse=!0),e},loadExtraState:function(e){this.elseIfCount_=e.elseIfCount||0,this.hasElse_=!!e.hasElse,this.updateShape_()},decompose:function(e){let t=e.newBlock(`logic_if_if_v1`);t.initSvg();let n=t.nextConnection;for(let t=0;t<this.elseIfCount_;t++){let t=e.newBlock(`logic_if_else_if_v1`);t.initSvg(),n.connect(t.previousConnection),n=t.nextConnection}if(this.hasElse_){let t=e.newBlock(`logic_if_else_v1`);t.initSvg(),n.connect(t.previousConnection)}return t},compose:function(e){let t=e.nextConnection.targetBlock();this.elseIfCount_=0,this.hasElse_=!1;let n=[null],r=[null],i=null;for(;t;){if(t.isInsertionMarker()){t=t.getNextBlock();continue}switch(t.type){case`logic_if_else_if_v1`:this.elseIfCount_++,n.push(t.valueConnection_),r.push(t.statementConnection_);break;case`logic_if_else_v1`:this.hasElse_=!0,i=t.statementConnection_;break;default:throw TypeError(`Unknown block type: `+t.type)}t=t.getNextBlock()}this.updateShape_(),this.reconnectChildBlocks_(n,r,i)},saveConnections:function(e){let t=e.nextConnection.targetBlock(),n=1;for(;t;){if(t.isInsertionMarker()){t=t.getNextBlock();continue}switch(t.type){case`Logic_if_else_if_v1`:{let e=this.getInput(`IF`+n),r=this.getInput(`DO`+n);t.valueConnection_=e&&e.connection.targetConnection,t.statementConnection_=r&&r.connection.targetConnection,n++;break}case`logic_if_else_v1`:{let e=this.getInput(`ELSE`);t.statementConnection_=e&&e.connection.targetConnection;break}default:throw TypeError(`Unknown block type: `+t.type)}t=t.getNextBlock()}},rebuildShape_:function(){let e=[null],t=[null],n=null;this.getInput(`ELSE`)&&(n=this.getInput(`ELSE`).connection.targetConnection);for(let n=1;this.getInput(`IF`+n);n++){let r=this.getInput(`IF`+n),i=this.getInput(`DO`+n);e.push(r.connection.targetConnection),t.push(i.connection.targetConnection)}this.updateShape_(),this.reconnectChildBlocks_(e,t,n)},updateShape_:function(){this.getInput(`ELSE`)&&this.removeInput(`ELSE`);for(let e=1;this.getInput(`IF`+e);e++)this.removeInput(`IF`+e),this.removeInput(`DO`+e);for(let e=1;e<=this.elseIfCount_;e++)this.appendValueInput(`IF`+e).setCheck(`Boolean`).appendField(F(`LOGIC_ELSE_IF`)),this.appendStatementInput(`DO`+e).appendField(F(`LOGIC_DO`));this.hasElse_&&this.appendStatementInput(`ELSE`).appendField(F(`LOGIC_ELSE`))},reconnectChildBlocks_:function(e,t,n){for(let n=1;n<=this.elseIfCount_;n++)e[n]?.reconnect(this,`IF`+n),t[n]?.reconnect(this,`DO`+n);n?.reconnect(this,`ELSE`)}},void 0,[`logic_if_else_if_v1`,`logic_if_else_v1`]),t([{type:`logic_if_v1`,message0:`%{BKY_LOGIC_IF} %1`,args0:[{type:`input_value`,name:`IF0`,check:`Boolean`}],message1:`%{BKY_LOGIC_DO} %1`,args1:[{type:`input_statement`,name:`DO0`}],previousStatement:null,nextStatement:null,style:`logic_blocks`,helpUrl:`%{BKY_LOGIC_V1_IF_HELPURL`,suppressPrefixSuffix:!0,mutator:`logic_if_v1_mutator`},{type:`logic_if_if_v1`,message0:`%{BKY_LOGIC_IF}`,nextStatement:null,enableContextMenu:!1,style:`logic_blocks`},{type:`logic_if_else_if_v1`,message0:`%{BKY_LOGIC_ELSE_IF}`,previousStatement:null,nextStatement:null,enableContextMenu:!1,style:`logic_blocks`},{type:`logic_if_else_v1`,message0:`%{BKY_LOGIC_ELSE}`,previousStatement:null,enableContextMenu:!1,style:`logic_blocks`}]),g.forBlock.logic_if_v1=function(e){let t=0,n=``;g.STATEMENT_PREFIX&&(n+=g.injectId(g.STATEMENT_PREFIX,e));do{let r=g.valueToCode(e,`IF`+t,_.NONE)||`false`,i=g.statementToCode(e,`DO`+t);g.STATEMENT_SUFFIX&&(i=g.prefixLines(g.injectId(g.STATEMENT_SUFFIX,e),g.INDENT)+i),n+=(t>0?` else `:``)+`if (`+r+`) {
165
+ `+i+`}`,t++}while(e.getInput(`IF`+t));if(e.getInput(`ELSE`)||g.STATEMENT_SUFFIX){let t=g.statementToCode(e,`ELSE`);g.STATEMENT_SUFFIX&&(t=g.prefixLines(g.injectId(g.STATEMENT_SUFFIX,e),g.INDENT)+t),n+=` else {
166
166
  `+t+`}`}return n+`
167
- `},h([{type:`logic_negate_v1`,message0:`%{BKY_LOGIC_V1_NEGATE_TITLE}`,args0:[{type:`input_value`,name:`BOOL`,check:`Boolean`}],output:`Boolean`,style:`logic_blocks`,tooltip:`%{BKY_LOGIC_V1_NEGATE_TOOLTIP}`,helpUrl:`%{BKY_LOGIC_V1_NEGATE_HELPURL}`}]),x.forBlock.logic_negate_v1=function(e){return[`!${x.valueToCode(e,`BOOL`,_.LOGICAL_NOT)||`true`}`,_.LOGICAL_NOT]},h([{type:`logic_operation_v1`,message0:`%1 %2 %3`,args0:[{type:`input_value`,name:`A`,check:`Boolean`},{type:`field_dropdown`,name:`OP`,options:[[`%{BKY_LOGIC_OPERATION_AND}`,`AND`],[`%{BKY_LOGIC_OPERATION_OR}`,`OR`]]},{type:`input_value`,name:`B`,check:`Boolean`}],inputsInline:!0,output:`Boolean`,style:`logic_blocks`,helpUrl:`%{BKY_LOGIC_V1_OPERATION_HELPURL}`,extensions:[`logic_op_tooltip_v1`]}]),x.forBlock.logic_operation_v1=function(e){let t=e.getFieldValue(`OP`)===`AND`?`&&`:`||`,n=t===`&&`?_.LOGICAL_AND:_.LOGICAL_OR,r=x.valueToCode(e,`A`,n),i=x.valueToCode(e,`B`,n);if(!r&&!i)r=`false`,i=`false`;else{let e=t===`&&`?`true`:`false`;r||(r=e),i||(i=e)}return[`${r} ${t} ${i}`,n]},r.registerMixin(`logic_ternary_v1`,{prevParentConnection_:null,onchange:function(e){let t=this.getInputTargetBlock(`THEN`),n=this.getInputTargetBlock(`ELSE`),r=this.outputConnection.targetConnection;if((t||n)&&r)for(let i=0;i<2;i++){let a=i===1?t:n;a&&!a.workspace.connectionChecker.doTypeChecks(a.outputConnection,r)&&(p.setGroup(e.group),r===this.prevParentConnection_?(this.unplug(),r.getSourceBlock().bumpNeighbours()):(a.unplug(),a.bumpNeighbours()),p.setGroup(!1))}this.prevParentConnection_=r}}),h([{type:`logic_ternary_v1`,message0:`%{BKY_LOGIC_TERNARY_CONDITION} %1`,args0:[{type:`input_value`,name:`IF`,check:`Boolean`}],message1:`%{BKY_LOGIC_TERNARY_IF_TRUE} %1`,args1:[{type:`input_value`,name:`THEN`}],message2:`%{BKY_LOGIC_TERNARY_IF_FALSE} %1`,args2:[{type:`input_value`,name:`ELSE`}],output:null,style:`logic_blocks`,tooltip:`%{BKY_LOGIC_V1_TERNARY_TOOLTIP}`,helpUrl:`%{BKY_LOGIC_V1_TERNARY_HELPURL}`,extensions:[`logic_ternary_v1`]}]),x.forBlock.logic_ternary_v1=function(e){let t=x.valueToCode(e,`IF`,_.CONDITIONAL)||`false`,n=x.valueToCode(e,`THEN`,_.CONDITIONAL)||`null`,r=x.valueToCode(e,`ELSE`,_.CONDITIONAL)||`null`;return[t+` ? `+n+` : `+r,_.CONDITIONAL]},r.registerMixin(`contextMenu_newGetVariableBlock_v1`,{customContextMenu:function(e){if(this.isInFlyout)return;let t=this.getField(`VAR`),n=t.getVariable()?.getName();if(!this.isCollapsed()&&n){let r={type:`variable_get_v1`,fields:{VAR:t.saveState(!0)}};e.push({enabled:!0,text:F(`VARIABLE_SET_CREATE_GET`).replace(`%1`,n),callback:de.callbackFactory(this,r)})}}}),r.register(`flow_control_tooltip_v1`,r.buildTooltipForDropdown(`MODE`,{BREAK:`%{BKY_LOOP_V1_FLOW_CONTROL_TOOLTIP_BREAK}`,CONTINUE:`%{BKY_LOOP_V1_FLOW_CONTROL_TOOLTIP_CONTINUE}`}));const Qr=new Set([`repeat_v1`,`for_each_v1`,`for_v1`,`while_until_v1`]);r.registerMixin(`flow_control_in_loop_check_v1`,{getSurroundLoop:function(){let e=this;do{if(Qr.has(e.type))return e;e=e?.getSurroundParent()}while(e);return null},onchange:function(e){let t=this.workspace;if(!t.isDragging||t.isDragging()||e.type!==p.BLOCK_MOVE&&e.type!==p.BLOCK_CREATE)return;let n=this.getSurroundLoop();if(this.setWarningText(n?null:F(`LOOP_FLOW_CONTROL_WARNING`)),!this.isInFlyout)try{p.setRecordUndo(!1),this.setDisabledReason(!n,`FLOW_CONTROL_NOT_IN_LOOP`)}finally{p.setRecordUndo(!0)}}}),h([{type:`flow_control_v1`,message0:`%1`,args0:[{type:`field_dropdown`,name:`MODE`,options:[[`%{BKY_LOOP_V1_FLOW_CONTROL_OPERATOR_BREAK}`,`BREAK`],[`%{BKY_LOOP_V1_FLOW_CONTROL_OPERATOR_CONTINUE}`,`CONTINUE`]]}],previousStatement:null,style:`loop_blocks`,helpurl:`%{BKY_LOOP_V1_FLOW_CONTROL_HELPURL}`,suppressPrefixSuffix:!0,extensions:[`flow_control_tooltip_v1`,`flow_control_in_loop_check_v1`]}]),x.forBlock.flow_control_v1=function(e){let t=``;if(x.STATEMENT_PREFIX&&(t+=x.injectId(x.STATEMENT_PREFIX,e)),x.STATEMENT_SUFFIX&&(t+=x.injectId(x.STATEMENT_SUFFIX,e)),x.STATEMENT_PREFIX){let n=e.getSurroundLoop();n&&!n.suppressPrefixSuffix&&(t+=x.injectId(x.STATEMENT_PREFIX,n))}switch(e.getFieldValue(`MODE`)){case`BREAK`:return`${t}break;\n`;case`CONTINUE`:return`${t}continue;\n`;default:throw`unknown mode`}},r.register(`for_tooltip_v1`,r.buildTooltipWithFieldText(`%{BKY_LOOP_V1_FOR_TOOLTIP}`,`VAR`)),h([{type:`for_v1`,message0:`%{BKY_LOOP_V1_FOR_TITLE}`,args0:[{type:`field_variable`,name:`VAR`,variable:null},{type:`input_value`,name:`FROM`,check:`Number`,align:`RIGHT`},{type:`input_value`,name:`TO`,check:`Number`,align:`RIGHT`},{type:`input_value`,name:`BY`,check:`Number`,align:`RIGHT`}],message1:`%{BKY_LOOP_DO} %1`,args1:[{type:`input_statement`,name:`DO`}],inputsInline:!0,previousStatement:null,nextStatement:null,style:`loop_blocks`,helpUrl:`%{BKY_LOOP_V1_FOR_HELPURL}`,extensions:[`contextMenu_newGetVariableBlock_v1`,`for_tooltip_v1`]}]),x.forBlock.for_v1=function(t){let n=x.INDENT,r=x.getVariableName(t.getFieldValue(`VAR`)),i=x.valueToCode(t,`FROM`,_.ASSIGNMENT)||`0`,a=x.valueToCode(t,`TO`,_.ASSIGNMENT)||`0`,o=x.valueToCode(t,`BY`,_.ASSIGNMENT)||`1`,s=x.addLoopTrap(x.statementToCode(t,`DO`),t);if(e.string.isNumber(i)&&e.string.isNumber(a)&&e.string.isNumber(o)){let e=Math.abs(Number(o));return Number(i)<=Number(a)?`for (${r} = ${i}; ${r} <= ${a}; ${r} += ${e}) {\n${s}}\n`:`for (${r} = ${i}; ${r} >= ${a}; ${r} -= ${e}) {\n${s}}\n`}else{let t=``,c=i;!i.match(/^\w+$/)&&!e.string.isNumber(i)&&(c=x.nameDB_.getDistinctName(`${r}_from`,v.NameType.VARIABLE),t+=`var ${c} = ${i};\n`);let l=a;!a.match(/^\w+$/)&&!e.string.isNumber(a)&&(l=x.nameDB_.getDistinctName(`${r}_to`,v.NameType.VARIABLE),t+=`var ${l} = ${a};\n`);let u=x.nameDB_.getDistinctName(`${r}_by`,v.NameType.VARIABLE);return t+=`var ${u} = `,e.string.isNumber(o)?t+=`${Math.abs(Number(o))};\n`:t+=`Math.abs(${o});\n`,t+=`if (${c} > ${l}) {\n${n}${u} = -${u};\n}\n`,t+=`for (${r} = ${c}; ${u} >= 0 ? ${r} <= ${l} : ${r} >= ${l}; ${r} += ${u}) {\n${s}}\n`,t}},r.register(`for_each_tooltip_v1`,r.buildTooltipWithFieldText(`%{BKY_LOOP_V1_FOR_EACH_TOOLTIP}`,`VAR`)),h([{type:`for_each_v1`,message0:`%{BKY_LOOP_V1_FOR_EACH_TITLE}`,args0:[{type:`field_variable`,name:`VAR`,variable:null},{type:`input_value`,name:`LIST`,check:`Array`}],message1:`%{BKY_LOOP_DO} %1`,args1:[{type:`input_statement`,name:`DO`}],previousStatement:null,nextStatement:null,style:`loop_blocks`,helpUrl:`%{BKY_LOOP_V1_FOR_EACH_HELPURL}`,extensions:[`contextMenu_newGetVariableBlock_v1`,`for_each_tooltip_v1`]}]),x.forBlock.for_each_v1=function(e){let t=x.INDENT,n=x.getVariableName(e.getFieldValue(`VAR`)),r=x.valueToCode(e,`LIST`,_.ASSIGNMENT)||`[]`,i=x.addLoopTrap(x.statementToCode(e,`DO`),e),a=``,o=r;r.match(/^\w+$/)||(o=x.nameDB_.getDistinctName(`${n}_list`,v.NameType.VARIABLE),a+=`var ${o} = ${r};\n`);let s=x.nameDB_.getDistinctName(`${n}_index`,v.NameType.VARIABLE);return a+=`for (var ${s} in ${o}) {
168
- ${t}${n} = ${o}[${s}];
169
- ${i}}\n`,a},h([{type:`repeat_v1`,message0:`%{BKY_LOOP_V1_REPEAT_TITLE}`,args0:[{type:`input_value`,name:`TIMES`,check:`Number`}],message1:`%{BKY_LOOP_DO} %1`,args1:[{type:`input_statement`,name:`DO`}],previousStatement:null,nextStatement:null,style:`loop_blocks`,tooltip:`%{BKY_LOOP_REPEAT_TOOLTIP}`,helpUrl:`%{BKY_LOOP_REPEAT_HELPURL}`}]),x.forBlock.repeat_v1=function(t){let n;n=t.getField(`TIMES`)?String(Number(t.getFieldValue(`TIMES`))):x.valueToCode(t,`TIMES`,_.ASSIGNMENT)||`0`;let r=x.addLoopTrap(x.statementToCode(t,`DO`),t),i=``,a=x.nameDB_.getDistinctName(`count`,v.NameType.VARIABLE),o=n;return!n.match(/^\w+$/)&&!e.string.isNumber(n)&&(o=x.nameDB_.getDistinctName(`repeat_end`,v.NameType.VARIABLE),i+=`var ${o} = ${n};\n`),i+=`for (var ${a} = 0; ${a} < ${o}; ${a}++) {\n${r}}\n`,i},r.register(`while_until_tooltip_v1`,r.buildTooltipForDropdown(`MODE`,{WHILE:`%{BKY_LOOP_V1_WHILE_UNTIL_TOOLTIP_WHILE}`,UNTIL:`%{BKY_LOOP_V1_WHILE_UNTIL_TOOLTIP_UNTIL}`})),h([{type:`while_until_v1`,message0:`%1 %2`,args0:[{type:`field_dropdown`,name:`MODE`,options:[[`%{BKY_LOOP_V1_WHILE_UNTIL_OPERATOR_WHILE}`,`WHILE`],[`%{BKY_LOOP_V1_WHILE_UNTIL_OPERATOR_UNTIL}`,`UNTIL`]]},{type:`input_value`,name:`CONDITION`,check:`Boolean`}],message1:`%{BKY_LOOP_DO} %1`,args1:[{type:`input_statement`,name:`HANDLE`}],previousStatement:null,nextStatement:null,style:`loop_blocks`,helpUrl:`%{BKY_LOOP_V1_WHILE_UNTIL_HELPURL}`,extensions:[`while_until_tooltip_v1`]}]),x.forBlock.while_until_v1=function(e){let t=e.getFieldValue(`MODE`),n=x.valueToCode(e,`CONDITION`,t===`UNTIL`?_.LOGICAL_NOT:_.NONE)||`false`;t===`UNTIL`&&(n=`!`+n);let r=x.addLoopTrap(x.statementToCode(e,`HANDLE`),e);return`while (${n}) {\n${r}}\n`},r.register(`math_op_tooltip_v1`,r.buildTooltipForDropdown(`OP`,{ADD:`%{BKY_MATH_V1_ARITHMETIC_TOOLTIP_ADD}`,SUBTRACT:`%{BKY_MATH_V1_ARITHMETIC_TOOLTIP_SUBTRACT}`,MULTIPLY:`%{BKY_MATH_V1_ARITHMETIC_TOOLTIP_MULTIPLY}`,DIVIDE:`%{BKY_MATH_V1_ARITHMETIC_TOOLTIP_DIVIDE}`,POWER:`%{BKY_MATH_V1_ARITHMETIC_TOOLTIP_POWER}`,ROOT:`%{BKY_MATH_V1_SINGLE_TOOLTIP_ROOT}`,ABS:`%{BKY_MATH_V1_SINGLE_TOOLTIP_ABS}`,NEG:`%{BKY_MATH_V1_SINGLE_TOOLTIP_NEG}`,LN:`%{BKY_MATH_V1_SINGLE_TOOLTIP_LN}`,LOG10:`%{BKY_MATH_V1_SINGLE_TOOLTIP_LOG10}`,EXP:`%{BKY_MATH_V1_SINGLE_TOOLTIP_EXP}`,POW10:`%{BKY_MATH_V1_SINGLE_TOOLTIP_POW10}`,SIN:`%{BKY_MATH_V1_TRIG_TOOLTIP_SIN}`,COS:`%{BKY_MATH_V1_TRIG_TOOLTIP_COS}`,TAN:`%{BKY_MATH_V1_TRIG_TOOLTIP_TAN}`,ASIN:`%{BKY_MATH_V1_TRIG_TOOLTIP_ASIN}`,ACOS:`%{BKY_MATH_V1_TRIG_TOOLTIP_ACOS}`,ATAN:`%{BKY_MATH_V1_TRIG_TOOLTIP_ATAN}`,SUM:`%{BKY_MATH_V1_ON_LIST_TOOLTIP_SUM}`,MIN:`%{BKY_MATH_V1_ON_LIST_TOOLTIP_MIN}`,MAX:`%{BKY_MATH_V1_ON_LIST_TOOLTIP_MAX}`,AVERAGE:`%{BKY_MATH_V1_ON_LIST_TOOLTIP_AVERAGE}`,MEDIAN:`%{BKY_MATH_V1_ON_LIST_TOOLTIP_MEDIAN}`,MODE:`%{BKY_MATH_V1_ON_LIST_TOOLTIP_MODE}`,STD_DEV:`%{BKY_MATH_V1_ON_LIST_TOOLTIP_STD_DEV}`,RANDOM:`%{BKY_MATH_V1_ON_LIST_TOOLTIP_RANDOM}`})),h([{type:`math_arithmetic_v1`,message0:`%1 %2 %3`,args0:[{type:`input_value`,name:`A`,check:`Number`},{type:`field_dropdown`,name:`OP`,options:[[`%{BKY_MATH_SYMBOL_ADD}`,`ADD`],[`%{BKY_MATH_SYMBOL_SUBTRACT}`,`SUBTRACT`],[`%{BKY_MATH_SYMBOL_MULTIPLY}`,`MULTIPLY`],[`%{BKY_MATH_SYMBOL_DIVIDE}`,`DIVIDE`],[`%{BKY_MATH_SYMBOL_POWER}`,`POWER`]]},{type:`input_value`,name:`B`,check:`Number`}],inputsInline:!0,output:`Number`,style:`math_blocks`,helpUrl:`%{BKY_MATH_V1_ARITHMETIC_HELPURL}`,extensions:[`math_op_tooltip_v1`]}]),x.forBlock.math_arithmetic_v1=function(e){let[t,n]={ADD:[` + `,_.ADDITION],SUBTRACT:[` - `,_.SUBTRACTION],MULTIPLY:[` * `,_.MULTIPLICATION],DIVIDE:[` / `,_.DIVISION],POWER:[null,_.NONE]}[e.getFieldValue(`OP`)],r=x.valueToCode(e,`A`,n)||`0`,i=x.valueToCode(e,`B`,n)||`0`;return t?[r+t+i,n]:[`Math.pow(${r}, ${i})`,_.FUNCTION_CALL]},h([{type:`math_constant_v1`,message0:`%1`,args0:[{type:`field_dropdown`,name:`CONSTANT`,options:[[`π`,`PI`],[`e`,`E`],[`φ`,`GOLDEN_RATIO`],[`sqrt(2)`,`SQRT2`],[`sqrt(½)`,`SQRT1_2`],[`∞`,`INFINITY`]]}],output:`Number`,style:`math_blocks`,tooltip:`%{BKY_MATH_V1_CONSTANT_TOOLTIP}`,helpUrl:`%{BKY_MATH_V1_CONSTANT_HELPURL}`}]),x.forBlock.math_constant_v1=function(e){return{PI:[`Math.PI`,_.MEMBER],E:[`Math.E`,_.MEMBER],GOLDEN_RATIO:[`(1 + Math.sqrt(5)) / 2`,_.DIVISION],SQRT2:[`Math.SQRT2`,_.MEMBER],SQRT1_2:[`Math.SQRT1_2`,_.MEMBER],INFINITY:[`Infinity`,_.ATOMIC]}[e.getFieldValue(`CONSTANT`)]},h([{type:`math_constrain_v1`,message0:`%{BKY_MATH_V1_CONSTRAIN_TITLE}`,args0:[{type:`input_value`,name:`VALUE`,check:`Number`},{type:`input_value`,name:`LOW`,check:`Number`},{type:`input_value`,name:`HIGH`,check:`Number`}],inputsInline:!0,output:`Number`,style:`math_blocks`,tooltip:`%{BKY_MATH_V1_CONSTRAIN_TOOLTIP}`,helpUrl:`%{BKY_MATH_V1_CONSTRAIN_HELPURL}`}]),x.forBlock.math_constrain_v1=function(e){return[`Math.min(Math.max(${x.valueToCode(e,`VALUE`,_.NONE)||`0`}, ${x.valueToCode(e,`LOW`,_.NONE)||`0`}), ${x.valueToCode(e,`HIGH`,_.NONE)||`Infinity`})`,_.FUNCTION_CALL]},h([{type:`math_modulo_v1`,message0:`%{BKY_MATH_V1_MODULO_TITLE}`,args0:[{type:`input_value`,name:`DIVIDEND`,check:`Number`},{type:`input_value`,name:`DIVISOR`,check:`Number`}],inputsInline:!0,output:`Number`,style:`math_blocks`,tooltip:`%{BKY_MATH_V1_MODULO_TOOLTIP}`,helpUrl:`%{BKY_MATH_V1_MODULO_HELPURL}`}]),x.forBlock.math_modulo_v1=function(e){let t=x.valueToCode(e,`DIVIDEND`,_.MODULUS)||`0`,n=x.valueToCode(e,`DIVISOR`,_.MODULUS)||`0`;return[t+` % `+n,_.MODULUS]},h([{type:`math_number_v1`,message0:`%1`,args0:[{type:`field_number`,name:`NUM`,value:0}],output:`Number`,style:`math_blocks`,helpUrl:`%{BKY_MATH_V1_NUMBER_HELPURL}`,tooltip:`%{BKY_MATH_V1_NUMBER_TOOLTIP}`,extensions:[`parent_tooltip_when_inline`]}]),x.forBlock.math_number_v1=function(e){let t=Number(e.getFieldValue(`NUM`)),n=t>=0?_.ATOMIC:_.UNARY_NEGATION;return[String(t),n]},h([{type:`math_number_property_v1`,message0:`%{BKY_MATH_V1_NUMBER_PROPERTY_TITLE}`,args0:[{type:`input_value`,name:`NUM`,check:`Number`},{type:`field_dropdown`,name:`PROP`,options:[[`%{BKY_MATH_NUMBER_PROP_EVEN}`,`EVEN`],[`%{BKY_MATH_NUMBER_PROP_ODD}`,`ODD`],[`%{BKY_MATH_NUMBER_PROP_PRIME}`,`PRIME`],[`%{BKY_MATH_NUMBER_PROP_WHOLE}`,`WHOLE`],[`%{BKY_MATH_NUMBER_PROP_POSITIVE}`,`POSITIVE`],[`%{BKY_MATH_NUMBER_PROP_NEGATIVE}`,`NEGATIVE`]]}],inputsInline:!0,output:`Boolean`,style:`math_blocks`,tooltip:`%{BKY_MATH_V1_NUMBER_PROPERTY_TOOLTIP}`,helpUrl:`%{BKY_MATH_V1_NUMBER_PROPERTY_HELPURL}`}]),x.forBlock.math_number_property_v1=function(e){let t={EVEN:[` % 2 === 0`,_.MODULUS,_.EQUALITY],ODD:[` % 2 === 1`,_.MODULUS,_.EQUALITY],WHOLE:[` % 1 === 0`,_.MODULUS,_.EQUALITY],POSITIVE:[` > 0`,_.RELATIONAL,_.RELATIONAL],NEGATIVE:[` < 0`,_.RELATIONAL,_.RELATIONAL],DIVISIBLE_BY:[null,_.MODULUS,_.EQUALITY],PRIME:[null,_.NONE,_.FUNCTION_CALL]},n=e.getFieldValue(`PROPERTY`),[r,i,a]=t[e.getFieldValue(`PROPERTY`)],o=x.valueToCode(e,`NUMBER_TO_CHECK`,i)||`0`,s;if(n===`PRIME`)s=x.provideFunction_(`mathIsPrime`,`
170
- function ${x.FUNCTION_NAME_PLACEHOLDER_}(n) {
167
+ `},t([{type:`logic_negate_v1`,message0:`%{BKY_LOGIC_V1_NEGATE_TITLE}`,args0:[{type:`input_value`,name:`BOOL`,check:`Boolean`}],output:`Boolean`,style:`logic_blocks`,tooltip:`%{BKY_LOGIC_V1_NEGATE_TOOLTIP}`,helpUrl:`%{BKY_LOGIC_V1_NEGATE_HELPURL}`}]),g.forBlock.logic_negate_v1=function(e){return[`!${g.valueToCode(e,`BOOL`,_.LOGICAL_NOT)||`true`}`,_.LOGICAL_NOT]},t([{type:`logic_operation_v1`,message0:`%1 %2 %3`,args0:[{type:`input_value`,name:`A`,check:`Boolean`},{type:`field_dropdown`,name:`OP`,options:[[`%{BKY_LOGIC_OPERATION_AND}`,`AND`],[`%{BKY_LOGIC_OPERATION_OR}`,`OR`]]},{type:`input_value`,name:`B`,check:`Boolean`}],inputsInline:!0,output:`Boolean`,style:`logic_blocks`,helpUrl:`%{BKY_LOGIC_V1_OPERATION_HELPURL}`,extensions:[`logic_op_tooltip_v1`]}]),g.forBlock.logic_operation_v1=function(e){let t=e.getFieldValue(`OP`)===`AND`?`&&`:`||`,n=t===`&&`?_.LOGICAL_AND:_.LOGICAL_OR,r=g.valueToCode(e,`A`,n),i=g.valueToCode(e,`B`,n);if(!r&&!i)r=`false`,i=`false`;else{let e=t===`&&`?`true`:`false`;r||(r=e),i||(i=e)}return[`${r} ${t} ${i}`,n]},m.registerMixin(`logic_ternary_v1`,{prevParentConnection_:null,onchange:function(e){let t=this.getInputTargetBlock(`THEN`),n=this.getInputTargetBlock(`ELSE`),r=this.outputConnection.targetConnection;if((t||n)&&r)for(let i=0;i<2;i++){let a=i===1?t:n;a&&!a.workspace.connectionChecker.doTypeChecks(a.outputConnection,r)&&(x.setGroup(e.group),r===this.prevParentConnection_?(this.unplug(),r.getSourceBlock().bumpNeighbours()):(a.unplug(),a.bumpNeighbours()),x.setGroup(!1))}this.prevParentConnection_=r}}),t([{type:`logic_ternary_v1`,message0:`%{BKY_LOGIC_TERNARY_CONDITION} %1`,args0:[{type:`input_value`,name:`IF`,check:`Boolean`}],message1:`%{BKY_LOGIC_TERNARY_IF_TRUE} %1`,args1:[{type:`input_value`,name:`THEN`}],message2:`%{BKY_LOGIC_TERNARY_IF_FALSE} %1`,args2:[{type:`input_value`,name:`ELSE`}],output:null,style:`logic_blocks`,tooltip:`%{BKY_LOGIC_V1_TERNARY_TOOLTIP}`,helpUrl:`%{BKY_LOGIC_V1_TERNARY_HELPURL}`,extensions:[`logic_ternary_v1`]}]),g.forBlock.logic_ternary_v1=function(e){let t=g.valueToCode(e,`IF`,_.CONDITIONAL)||`false`,n=g.valueToCode(e,`THEN`,_.CONDITIONAL)||`null`,r=g.valueToCode(e,`ELSE`,_.CONDITIONAL)||`null`;return[t+` ? `+n+` : `+r,_.CONDITIONAL]},m.registerMixin(`contextMenu_newGetVariableBlock_v1`,{customContextMenu:function(e){if(this.isInFlyout)return;let t=this.getField(`VAR`),n=t.getVariable()?.getName();if(!this.isCollapsed()&&n){let r={type:`variable_get_v1`,fields:{VAR:t.saveState(!0)}};e.push({enabled:!0,text:F(`VARIABLE_SET_CREATE_GET`).replace(`%1`,n),callback:Oe.callbackFactory(this,r)})}}}),m.register(`flow_control_tooltip_v1`,m.buildTooltipForDropdown(`MODE`,{BREAK:`%{BKY_LOOP_V1_FLOW_CONTROL_TOOLTIP_BREAK}`,CONTINUE:`%{BKY_LOOP_V1_FLOW_CONTROL_TOOLTIP_CONTINUE}`}));const Qr=new Set([`repeat_v1`,`for_each_v1`,`for_v1`,`while_until_v1`]);m.registerMixin(`flow_control_in_loop_check_v1`,{getSurroundLoop:function(){let e=this;do{if(Qr.has(e.type))return e;e=e?.getSurroundParent()}while(e);return null},onchange:function(e){let t=this.workspace;if(!t.isDragging||t.isDragging()||e.type!==x.BLOCK_MOVE&&e.type!==x.BLOCK_CREATE)return;let n=this.getSurroundLoop();if(this.setWarningText(n?null:F(`LOOP_FLOW_CONTROL_WARNING`)),!this.isInFlyout)try{x.setRecordUndo(!1),this.setDisabledReason(!n,`FLOW_CONTROL_NOT_IN_LOOP`)}finally{x.setRecordUndo(!0)}}}),t([{type:`flow_control_v1`,message0:`%1`,args0:[{type:`field_dropdown`,name:`MODE`,options:[[`%{BKY_LOOP_V1_FLOW_CONTROL_OPERATOR_BREAK}`,`BREAK`],[`%{BKY_LOOP_V1_FLOW_CONTROL_OPERATOR_CONTINUE}`,`CONTINUE`]]}],previousStatement:null,style:`loop_blocks`,helpurl:`%{BKY_LOOP_V1_FLOW_CONTROL_HELPURL}`,suppressPrefixSuffix:!0,extensions:[`flow_control_tooltip_v1`,`flow_control_in_loop_check_v1`]}]),g.forBlock.flow_control_v1=function(e){let t=``;if(g.STATEMENT_PREFIX&&(t+=g.injectId(g.STATEMENT_PREFIX,e)),g.STATEMENT_SUFFIX&&(t+=g.injectId(g.STATEMENT_SUFFIX,e)),g.STATEMENT_PREFIX){let n=e.getSurroundLoop();n&&!n.suppressPrefixSuffix&&(t+=g.injectId(g.STATEMENT_PREFIX,n))}switch(e.getFieldValue(`MODE`)){case`BREAK`:return`${t}break;\n`;case`CONTINUE`:return`${t}continue;\n`;default:throw`unknown mode`}},m.register(`for_tooltip_v1`,m.buildTooltipWithFieldText(`%{BKY_LOOP_V1_FOR_TOOLTIP}`,`VAR`)),t([{type:`for_v1`,message0:`%{BKY_LOOP_V1_FOR_TITLE}`,args0:[{type:`field_variable`,name:`VAR`,variable:null},{type:`input_value`,name:`FROM`,check:`Number`,align:`RIGHT`},{type:`input_value`,name:`TO`,check:`Number`,align:`RIGHT`},{type:`input_value`,name:`BY`,check:`Number`,align:`RIGHT`}],message1:`%{BKY_LOOP_DO} %1`,args1:[{type:`input_statement`,name:`DO`}],inputsInline:!0,previousStatement:null,nextStatement:null,style:`loop_blocks`,helpUrl:`%{BKY_LOOP_V1_FOR_HELPURL}`,extensions:[`contextMenu_newGetVariableBlock_v1`,`for_tooltip_v1`]}]),g.forBlock.for_v1=function(t){let n=g.INDENT,r=g.getVariableName(t.getFieldValue(`VAR`)),i=g.valueToCode(t,`FROM`,_.ASSIGNMENT)||`0`,a=g.valueToCode(t,`TO`,_.ASSIGNMENT)||`0`,o=g.valueToCode(t,`BY`,_.ASSIGNMENT)||`1`,s=g.addLoopTrap(g.statementToCode(t,`DO`),t);if(p.string.isNumber(i)&&p.string.isNumber(a)&&p.string.isNumber(o)){let e=Math.abs(Number(o));return Number(i)<=Number(a)?`for (${r} = ${i}; ${r} <= ${a}; ${r} += ${e}) {\n${s}}\n`:`for (${r} = ${i}; ${r} >= ${a}; ${r} -= ${e}) {\n${s}}\n`}else{let t=``,c=i;!i.match(/^\w+$/)&&!p.string.isNumber(i)&&(c=g.nameDB_.getDistinctName(`${r}_from`,e.NameType.VARIABLE),t+=`var ${c} = ${i};\n`);let l=a;!a.match(/^\w+$/)&&!p.string.isNumber(a)&&(l=g.nameDB_.getDistinctName(`${r}_to`,e.NameType.VARIABLE),t+=`var ${l} = ${a};\n`);let u=g.nameDB_.getDistinctName(`${r}_by`,e.NameType.VARIABLE);return t+=`var ${u} = `,p.string.isNumber(o)?t+=`${Math.abs(Number(o))};\n`:t+=`Math.abs(${o});\n`,t+=`if (${c} > ${l}) {\n${n}${u} = -${u};\n}\n`,t+=`for (${r} = ${c}; ${u} >= 0 ? ${r} <= ${l} : ${r} >= ${l}; ${r} += ${u}) {\n${s}}\n`,t}},m.register(`for_each_tooltip_v1`,m.buildTooltipWithFieldText(`%{BKY_LOOP_V1_FOR_EACH_TOOLTIP}`,`VAR`)),t([{type:`for_each_v1`,message0:`%{BKY_LOOP_V1_FOR_EACH_TITLE}`,args0:[{type:`field_variable`,name:`VAR`,variable:null},{type:`input_value`,name:`LIST`,check:`Array`}],message1:`%{BKY_LOOP_DO} %1`,args1:[{type:`input_statement`,name:`DO`}],previousStatement:null,nextStatement:null,style:`loop_blocks`,helpUrl:`%{BKY_LOOP_V1_FOR_EACH_HELPURL}`,extensions:[`contextMenu_newGetVariableBlock_v1`,`for_each_tooltip_v1`]}]),g.forBlock.for_each_v1=function(t){let n=g.INDENT,r=g.getVariableName(t.getFieldValue(`VAR`)),i=g.valueToCode(t,`LIST`,_.ASSIGNMENT)||`[]`,a=g.addLoopTrap(g.statementToCode(t,`DO`),t),o=``,s=i;i.match(/^\w+$/)||(s=g.nameDB_.getDistinctName(`${r}_list`,e.NameType.VARIABLE),o+=`var ${s} = ${i};\n`);let c=g.nameDB_.getDistinctName(`${r}_index`,e.NameType.VARIABLE);return o+=`for (var ${c} in ${s}) {
168
+ ${n}${r} = ${s}[${c}];
169
+ ${a}}\n`,o},t([{type:`repeat_v1`,message0:`%{BKY_LOOP_V1_REPEAT_TITLE}`,args0:[{type:`input_value`,name:`TIMES`,check:`Number`}],message1:`%{BKY_LOOP_DO} %1`,args1:[{type:`input_statement`,name:`DO`}],previousStatement:null,nextStatement:null,style:`loop_blocks`,tooltip:`%{BKY_LOOP_REPEAT_TOOLTIP}`,helpUrl:`%{BKY_LOOP_REPEAT_HELPURL}`}]),g.forBlock.repeat_v1=function(t){let n;n=t.getField(`TIMES`)?String(Number(t.getFieldValue(`TIMES`))):g.valueToCode(t,`TIMES`,_.ASSIGNMENT)||`0`;let r=g.addLoopTrap(g.statementToCode(t,`DO`),t),i=``,a=g.nameDB_.getDistinctName(`count`,e.NameType.VARIABLE),o=n;return!n.match(/^\w+$/)&&!p.string.isNumber(n)&&(o=g.nameDB_.getDistinctName(`repeat_end`,e.NameType.VARIABLE),i+=`var ${o} = ${n};\n`),i+=`for (var ${a} = 0; ${a} < ${o}; ${a}++) {\n${r}}\n`,i},m.register(`while_until_tooltip_v1`,m.buildTooltipForDropdown(`MODE`,{WHILE:`%{BKY_LOOP_V1_WHILE_UNTIL_TOOLTIP_WHILE}`,UNTIL:`%{BKY_LOOP_V1_WHILE_UNTIL_TOOLTIP_UNTIL}`})),t([{type:`while_until_v1`,message0:`%1 %2`,args0:[{type:`field_dropdown`,name:`MODE`,options:[[`%{BKY_LOOP_V1_WHILE_UNTIL_OPERATOR_WHILE}`,`WHILE`],[`%{BKY_LOOP_V1_WHILE_UNTIL_OPERATOR_UNTIL}`,`UNTIL`]]},{type:`input_value`,name:`CONDITION`,check:`Boolean`}],message1:`%{BKY_LOOP_DO} %1`,args1:[{type:`input_statement`,name:`HANDLE`}],previousStatement:null,nextStatement:null,style:`loop_blocks`,helpUrl:`%{BKY_LOOP_V1_WHILE_UNTIL_HELPURL}`,extensions:[`while_until_tooltip_v1`]}]),g.forBlock.while_until_v1=function(e){let t=e.getFieldValue(`MODE`),n=g.valueToCode(e,`CONDITION`,t===`UNTIL`?_.LOGICAL_NOT:_.NONE)||`false`;t===`UNTIL`&&(n=`!`+n);let r=g.addLoopTrap(g.statementToCode(e,`HANDLE`),e);return`while (${n}) {\n${r}}\n`},m.register(`math_op_tooltip_v1`,m.buildTooltipForDropdown(`OP`,{ADD:`%{BKY_MATH_V1_ARITHMETIC_TOOLTIP_ADD}`,SUBTRACT:`%{BKY_MATH_V1_ARITHMETIC_TOOLTIP_SUBTRACT}`,MULTIPLY:`%{BKY_MATH_V1_ARITHMETIC_TOOLTIP_MULTIPLY}`,DIVIDE:`%{BKY_MATH_V1_ARITHMETIC_TOOLTIP_DIVIDE}`,POWER:`%{BKY_MATH_V1_ARITHMETIC_TOOLTIP_POWER}`,ROOT:`%{BKY_MATH_V1_SINGLE_TOOLTIP_ROOT}`,ABS:`%{BKY_MATH_V1_SINGLE_TOOLTIP_ABS}`,NEG:`%{BKY_MATH_V1_SINGLE_TOOLTIP_NEG}`,LN:`%{BKY_MATH_V1_SINGLE_TOOLTIP_LN}`,LOG10:`%{BKY_MATH_V1_SINGLE_TOOLTIP_LOG10}`,EXP:`%{BKY_MATH_V1_SINGLE_TOOLTIP_EXP}`,POW10:`%{BKY_MATH_V1_SINGLE_TOOLTIP_POW10}`,SIN:`%{BKY_MATH_V1_TRIG_TOOLTIP_SIN}`,COS:`%{BKY_MATH_V1_TRIG_TOOLTIP_COS}`,TAN:`%{BKY_MATH_V1_TRIG_TOOLTIP_TAN}`,ASIN:`%{BKY_MATH_V1_TRIG_TOOLTIP_ASIN}`,ACOS:`%{BKY_MATH_V1_TRIG_TOOLTIP_ACOS}`,ATAN:`%{BKY_MATH_V1_TRIG_TOOLTIP_ATAN}`,SUM:`%{BKY_MATH_V1_ON_LIST_TOOLTIP_SUM}`,MIN:`%{BKY_MATH_V1_ON_LIST_TOOLTIP_MIN}`,MAX:`%{BKY_MATH_V1_ON_LIST_TOOLTIP_MAX}`,AVERAGE:`%{BKY_MATH_V1_ON_LIST_TOOLTIP_AVERAGE}`,MEDIAN:`%{BKY_MATH_V1_ON_LIST_TOOLTIP_MEDIAN}`,MODE:`%{BKY_MATH_V1_ON_LIST_TOOLTIP_MODE}`,STD_DEV:`%{BKY_MATH_V1_ON_LIST_TOOLTIP_STD_DEV}`,RANDOM:`%{BKY_MATH_V1_ON_LIST_TOOLTIP_RANDOM}`})),t([{type:`math_arithmetic_v1`,message0:`%1 %2 %3`,args0:[{type:`input_value`,name:`A`,check:`Number`},{type:`field_dropdown`,name:`OP`,options:[[`%{BKY_MATH_SYMBOL_ADD}`,`ADD`],[`%{BKY_MATH_SYMBOL_SUBTRACT}`,`SUBTRACT`],[`%{BKY_MATH_SYMBOL_MULTIPLY}`,`MULTIPLY`],[`%{BKY_MATH_SYMBOL_DIVIDE}`,`DIVIDE`],[`%{BKY_MATH_SYMBOL_POWER}`,`POWER`]]},{type:`input_value`,name:`B`,check:`Number`}],inputsInline:!0,output:`Number`,style:`math_blocks`,helpUrl:`%{BKY_MATH_V1_ARITHMETIC_HELPURL}`,extensions:[`math_op_tooltip_v1`]}]),g.forBlock.math_arithmetic_v1=function(e){let[t,n]={ADD:[` + `,_.ADDITION],SUBTRACT:[` - `,_.SUBTRACTION],MULTIPLY:[` * `,_.MULTIPLICATION],DIVIDE:[` / `,_.DIVISION],POWER:[null,_.NONE]}[e.getFieldValue(`OP`)],r=g.valueToCode(e,`A`,n)||`0`,i=g.valueToCode(e,`B`,n)||`0`;return t?[r+t+i,n]:[`Math.pow(${r}, ${i})`,_.FUNCTION_CALL]},t([{type:`math_constant_v1`,message0:`%1`,args0:[{type:`field_dropdown`,name:`CONSTANT`,options:[[`π`,`PI`],[`e`,`E`],[`φ`,`GOLDEN_RATIO`],[`sqrt(2)`,`SQRT2`],[`sqrt(½)`,`SQRT1_2`],[`∞`,`INFINITY`]]}],output:`Number`,style:`math_blocks`,tooltip:`%{BKY_MATH_V1_CONSTANT_TOOLTIP}`,helpUrl:`%{BKY_MATH_V1_CONSTANT_HELPURL}`}]),g.forBlock.math_constant_v1=function(e){return{PI:[`Math.PI`,_.MEMBER],E:[`Math.E`,_.MEMBER],GOLDEN_RATIO:[`(1 + Math.sqrt(5)) / 2`,_.DIVISION],SQRT2:[`Math.SQRT2`,_.MEMBER],SQRT1_2:[`Math.SQRT1_2`,_.MEMBER],INFINITY:[`Infinity`,_.ATOMIC]}[e.getFieldValue(`CONSTANT`)]},t([{type:`math_constrain_v1`,message0:`%{BKY_MATH_V1_CONSTRAIN_TITLE}`,args0:[{type:`input_value`,name:`VALUE`,check:`Number`},{type:`input_value`,name:`LOW`,check:`Number`},{type:`input_value`,name:`HIGH`,check:`Number`}],inputsInline:!0,output:`Number`,style:`math_blocks`,tooltip:`%{BKY_MATH_V1_CONSTRAIN_TOOLTIP}`,helpUrl:`%{BKY_MATH_V1_CONSTRAIN_HELPURL}`}]),g.forBlock.math_constrain_v1=function(e){return[`Math.min(Math.max(${g.valueToCode(e,`VALUE`,_.NONE)||`0`}, ${g.valueToCode(e,`LOW`,_.NONE)||`0`}), ${g.valueToCode(e,`HIGH`,_.NONE)||`Infinity`})`,_.FUNCTION_CALL]},t([{type:`math_modulo_v1`,message0:`%{BKY_MATH_V1_MODULO_TITLE}`,args0:[{type:`input_value`,name:`DIVIDEND`,check:`Number`},{type:`input_value`,name:`DIVISOR`,check:`Number`}],inputsInline:!0,output:`Number`,style:`math_blocks`,tooltip:`%{BKY_MATH_V1_MODULO_TOOLTIP}`,helpUrl:`%{BKY_MATH_V1_MODULO_HELPURL}`}]),g.forBlock.math_modulo_v1=function(e){let t=g.valueToCode(e,`DIVIDEND`,_.MODULUS)||`0`,n=g.valueToCode(e,`DIVISOR`,_.MODULUS)||`0`;return[t+` % `+n,_.MODULUS]},t([{type:`math_number_v1`,message0:`%1`,args0:[{type:`field_number`,name:`NUM`,value:0}],output:`Number`,style:`math_blocks`,helpUrl:`%{BKY_MATH_V1_NUMBER_HELPURL}`,tooltip:`%{BKY_MATH_V1_NUMBER_TOOLTIP}`,extensions:[`parent_tooltip_when_inline`]}]),g.forBlock.math_number_v1=function(e){let t=Number(e.getFieldValue(`NUM`)),n=t>=0?_.ATOMIC:_.UNARY_NEGATION;return[String(t),n]},t([{type:`math_number_property_v1`,message0:`%{BKY_MATH_V1_NUMBER_PROPERTY_TITLE}`,args0:[{type:`input_value`,name:`NUM`,check:`Number`},{type:`field_dropdown`,name:`PROP`,options:[[`%{BKY_MATH_NUMBER_PROP_EVEN}`,`EVEN`],[`%{BKY_MATH_NUMBER_PROP_ODD}`,`ODD`],[`%{BKY_MATH_NUMBER_PROP_PRIME}`,`PRIME`],[`%{BKY_MATH_NUMBER_PROP_WHOLE}`,`WHOLE`],[`%{BKY_MATH_NUMBER_PROP_POSITIVE}`,`POSITIVE`],[`%{BKY_MATH_NUMBER_PROP_NEGATIVE}`,`NEGATIVE`]]}],inputsInline:!0,output:`Boolean`,style:`math_blocks`,tooltip:`%{BKY_MATH_V1_NUMBER_PROPERTY_TOOLTIP}`,helpUrl:`%{BKY_MATH_V1_NUMBER_PROPERTY_HELPURL}`}]),g.forBlock.math_number_property_v1=function(e){let t={EVEN:[` % 2 === 0`,_.MODULUS,_.EQUALITY],ODD:[` % 2 === 1`,_.MODULUS,_.EQUALITY],WHOLE:[` % 1 === 0`,_.MODULUS,_.EQUALITY],POSITIVE:[` > 0`,_.RELATIONAL,_.RELATIONAL],NEGATIVE:[` < 0`,_.RELATIONAL,_.RELATIONAL],DIVISIBLE_BY:[null,_.MODULUS,_.EQUALITY],PRIME:[null,_.NONE,_.FUNCTION_CALL]},n=e.getFieldValue(`PROPERTY`),[r,i,a]=t[e.getFieldValue(`PROPERTY`)],o=g.valueToCode(e,`NUMBER_TO_CHECK`,i)||`0`,s;if(n===`PRIME`)s=g.provideFunction_(`mathIsPrime`,`
170
+ function ${g.FUNCTION_NAME_PLACEHOLDER_}(n) {
171
171
  // https://en.wikipedia.org/wiki/Primality_test#Naive_methods
172
172
  if (n == 2 || n == 3) {
173
173
  return true;
@@ -185,12 +185,12 @@ function ${x.FUNCTION_NAME_PLACEHOLDER_}(n) {
185
185
  }
186
186
  return true;
187
187
  }
188
- `)+`(`+o+`)`;else if(n===`DIVISIBLE_BY`){let t=x.valueToCode(e,`DIVISOR`,_.MODULUS)||`0`;s=o+` % `+t+` === 0`}else s=o+r;return[s,a]},h([{type:`math_on_list_v1`,message0:`%{BKY_MATH_V1_ON_LIST_TITLE}`,args0:[{type:`field_dropdown`,name:`OP`,options:[[`%{BKY_MATH_ON_LIST_OPERATOR_SUM}`,`SUM`],[`%{BKY_MATH_ON_LIST_OPERATOR_MIN}`,`MIN`],[`%{BKY_MATH_ON_LIST_OPERATOR_MAX}`,`MAX`],[`%{BKY_MATH_ON_LIST_OPERATOR_AVERAGE}`,`AVERAGE`],[`%{BKY_MATH_ON_LIST_OPERATOR_MEDIAN}`,`MEDIAN`],[`%{BKY_MATH_ON_LIST_OPERATOR_MODE}`,`MODE`],[`%{BKY_MATH_ON_LIST_OPERATOR_STD_DEV}`,`STD_DEV`],[`%{BKY_MATH_ON_LIST_OPERATOR_RANDOM}`,`RANDOM`]]},{type:`input_value`,name:`LIST`,check:`Array`}],output:`Number`,style:`math_blocks`,helpUrl:`%{BKY_MATH_V1_ON_LIST_HELPURL}`,extensions:[`math_op_tooltip_v1`]}]),x.forBlock.math_on_list_v1=function(e){let t=e.getFieldValue(`OP`),n,r;switch(t){case`SUM`:n=x.valueToCode(e,`LIST`,_.MEMBER)||`[]`,r=n+`.reduce(function(x, y) {return x + y;}, 0)`;break;case`MIN`:n=x.valueToCode(e,`LIST`,_.NONE)||`[]`,r=`Math.min.apply(null, `+n+`)`;break;case`MAX`:n=x.valueToCode(e,`LIST`,_.NONE)||`[]`,r=`Math.max.apply(null, `+n+`)`;break;case`AVERAGE`:{let t=x.provideFunction_(`mathMean`,`
189
- function ${x.FUNCTION_NAME_PLACEHOLDER_}(myList) {
188
+ `)+`(`+o+`)`;else if(n===`DIVISIBLE_BY`){let t=g.valueToCode(e,`DIVISOR`,_.MODULUS)||`0`;s=o+` % `+t+` === 0`}else s=o+r;return[s,a]},t([{type:`math_on_list_v1`,message0:`%{BKY_MATH_V1_ON_LIST_TITLE}`,args0:[{type:`field_dropdown`,name:`OP`,options:[[`%{BKY_MATH_ON_LIST_OPERATOR_SUM}`,`SUM`],[`%{BKY_MATH_ON_LIST_OPERATOR_MIN}`,`MIN`],[`%{BKY_MATH_ON_LIST_OPERATOR_MAX}`,`MAX`],[`%{BKY_MATH_ON_LIST_OPERATOR_AVERAGE}`,`AVERAGE`],[`%{BKY_MATH_ON_LIST_OPERATOR_MEDIAN}`,`MEDIAN`],[`%{BKY_MATH_ON_LIST_OPERATOR_MODE}`,`MODE`],[`%{BKY_MATH_ON_LIST_OPERATOR_STD_DEV}`,`STD_DEV`],[`%{BKY_MATH_ON_LIST_OPERATOR_RANDOM}`,`RANDOM`]]},{type:`input_value`,name:`LIST`,check:`Array`}],output:`Number`,style:`math_blocks`,helpUrl:`%{BKY_MATH_V1_ON_LIST_HELPURL}`,extensions:[`math_op_tooltip_v1`]}]),g.forBlock.math_on_list_v1=function(e){let t=e.getFieldValue(`OP`),n,r;switch(t){case`SUM`:n=g.valueToCode(e,`LIST`,_.MEMBER)||`[]`,r=n+`.reduce(function(x, y) {return x + y;}, 0)`;break;case`MIN`:n=g.valueToCode(e,`LIST`,_.NONE)||`[]`,r=`Math.min.apply(null, `+n+`)`;break;case`MAX`:n=g.valueToCode(e,`LIST`,_.NONE)||`[]`,r=`Math.max.apply(null, `+n+`)`;break;case`AVERAGE`:{let t=g.provideFunction_(`mathMean`,`
189
+ function ${g.FUNCTION_NAME_PLACEHOLDER_}(myList) {
190
190
  return myList.reduce(function(x, y) {return x + y;}, 0) / myList.length;
191
191
  }
192
- `);n=x.valueToCode(e,`LIST`,_.NONE)||`[]`,r=t+`(`+n+`)`;break}case`MEDIAN`:{let t=x.provideFunction_(`mathMedian`,`
193
- function ${x.FUNCTION_NAME_PLACEHOLDER_}(myList) {
192
+ `);n=g.valueToCode(e,`LIST`,_.NONE)||`[]`,r=t+`(`+n+`)`;break}case`MEDIAN`:{let t=g.provideFunction_(`mathMedian`,`
193
+ function ${g.FUNCTION_NAME_PLACEHOLDER_}(myList) {
194
194
  var localList = myList.filter(function (x) {return typeof x === 'number';});
195
195
  if (!localList.length) return null;
196
196
  localList.sort(function(a, b) {return b - a;});
@@ -200,8 +200,8 @@ function ${x.FUNCTION_NAME_PLACEHOLDER_}(myList) {
200
200
  return localList[(localList.length - 1) / 2];
201
201
  }
202
202
  }
203
- `);n=x.valueToCode(e,`LIST`,_.NONE)||`[]`,r=t+`(`+n+`)`;break}case`MODE`:{let t=x.provideFunction_(`mathModes`,`
204
- function ${x.FUNCTION_NAME_PLACEHOLDER_}(values) {
203
+ `);n=g.valueToCode(e,`LIST`,_.NONE)||`[]`,r=t+`(`+n+`)`;break}case`MODE`:{let t=g.provideFunction_(`mathModes`,`
204
+ function ${g.FUNCTION_NAME_PLACEHOLDER_}(values) {
205
205
  var modes = [];
206
206
  var counts = [];
207
207
  var maxCount = 0;
@@ -229,8 +229,8 @@ function ${x.FUNCTION_NAME_PLACEHOLDER_}(values) {
229
229
  }
230
230
  return modes;
231
231
  }
232
- `);n=x.valueToCode(e,`LIST`,_.NONE)||`[]`,r=t+`(`+n+`)`;break}case`STD_DEV`:{let t=x.provideFunction_(`mathStandardDeviation`,`
233
- function ${x.FUNCTION_NAME_PLACEHOLDER_}(numbers) {
232
+ `);n=g.valueToCode(e,`LIST`,_.NONE)||`[]`,r=t+`(`+n+`)`;break}case`STD_DEV`:{let t=g.provideFunction_(`mathStandardDeviation`,`
233
+ function ${g.FUNCTION_NAME_PLACEHOLDER_}(numbers) {
234
234
  var n = numbers.length;
235
235
  if (!n) return null;
236
236
  var mean = numbers.reduce(function(x, y) {return x + y;}) / n;
@@ -241,13 +241,13 @@ function ${x.FUNCTION_NAME_PLACEHOLDER_}(numbers) {
241
241
  variance /= n;
242
242
  return Math.sqrt(variance);
243
243
  }
244
- `);n=x.valueToCode(e,`LIST`,_.NONE)||`[]`,r=t+`(`+n+`)`;break}case`RANDOM`:{let t=x.provideFunction_(`mathRandomList`,`
245
- function ${x.FUNCTION_NAME_PLACEHOLDER_}(list) {
244
+ `);n=g.valueToCode(e,`LIST`,_.NONE)||`[]`,r=t+`(`+n+`)`;break}case`RANDOM`:{let t=g.provideFunction_(`mathRandomList`,`
245
+ function ${g.FUNCTION_NAME_PLACEHOLDER_}(list) {
246
246
  var x = Math.floor(Math.random() * list.length);
247
247
  return list[x];
248
248
  }
249
- `);n=x.valueToCode(e,`LIST`,_.NONE)||`[]`,r=t+`(`+n+`)`;break}default:throw Error(`Unknown operator: `+t)}return[r,_.FUNCTION_CALL]},h([{type:`math_random_float_v1`,message0:`%{BKY_MATH_V1_RANDOM_FLOAT_TITLE}`,output:`Number`,style:`math_blocks`,tooltip:`%{BKY_MATH_V1_RANDOM_FLOAT_TOOLTIP}`,helpUrl:`%{BKY_MATH_V1_RANDOM_FLOAT_HELPURL}`}]),x.forBlock.math_random_float_v1=function(){return[`Math.random()`,_.FUNCTION_CALL]},h([{type:`math_random_int_v1`,message0:`%{BKY_MATH_V1_RANDOM_INT_TITLE}`,args0:[{type:`input_value`,name:`FROM`,check:`Number`},{type:`input_value`,name:`TO`,check:`Number`}],inputsInline:!0,output:`Number`,style:`math_blocks`,tooltip:`%{BKY_MATH_V1_RANDOM_INT_TOOLTIP}`,helpUrl:`%{BKY_MATH_V1_RANDOM_INT_HELPURL}`}]),x.forBlock.math_random_int_v1=function(e){let t=x.valueToCode(e,`FROM`,_.NONE)||`0`,n=x.valueToCode(e,`TO`,_.NONE)||`0`;return[x.provideFunction_(`mathRandomInt`,`
250
- function ${x.FUNCTION_NAME_PLACEHOLDER_}(a, b) {
249
+ `);n=g.valueToCode(e,`LIST`,_.NONE)||`[]`,r=t+`(`+n+`)`;break}default:throw Error(`Unknown operator: `+t)}return[r,_.FUNCTION_CALL]},t([{type:`math_random_float_v1`,message0:`%{BKY_MATH_V1_RANDOM_FLOAT_TITLE}`,output:`Number`,style:`math_blocks`,tooltip:`%{BKY_MATH_V1_RANDOM_FLOAT_TOOLTIP}`,helpUrl:`%{BKY_MATH_V1_RANDOM_FLOAT_HELPURL}`}]),g.forBlock.math_random_float_v1=function(){return[`Math.random()`,_.FUNCTION_CALL]},t([{type:`math_random_int_v1`,message0:`%{BKY_MATH_V1_RANDOM_INT_TITLE}`,args0:[{type:`input_value`,name:`FROM`,check:`Number`},{type:`input_value`,name:`TO`,check:`Number`}],inputsInline:!0,output:`Number`,style:`math_blocks`,tooltip:`%{BKY_MATH_V1_RANDOM_INT_TOOLTIP}`,helpUrl:`%{BKY_MATH_V1_RANDOM_INT_HELPURL}`}]),g.forBlock.math_random_int_v1=function(e){let t=g.valueToCode(e,`FROM`,_.NONE)||`0`,n=g.valueToCode(e,`TO`,_.NONE)||`0`;return[g.provideFunction_(`mathRandomInt`,`
250
+ function ${g.FUNCTION_NAME_PLACEHOLDER_}(a, b) {
251
251
  if (a > b) {
252
252
  // Swap a and b to ensure a is smaller.
253
253
  var c = a;
@@ -256,8 +256,8 @@ function ${x.FUNCTION_NAME_PLACEHOLDER_}(a, b) {
256
256
  }
257
257
  return Math.floor(Math.random() * (b - a + 1) + a);
258
258
  }
259
- `)+`(`+t+`, `+n+`)`,_.FUNCTION_CALL]},h([{type:`math_round_v1`,message0:`%1 %2`,args0:[{type:`field_dropdown`,name:`OP`,options:[[`%{BKY_MATH_ROUND_OPERATOR_ROUND}`,`ROUND`],[`%{BKY_MATH_ROUND_OPERATOR_ROUNDUP}`,`ROUNDUP`],[`%{BKY_MATH_ROUND_OPERATOR_ROUNDDOWN}`,`ROUNDDOWN`]]},{type:`input_value`,name:`NUM`,check:`Number`}],output:`Number`,style:`math_blocks`,helpUrl:`%{BKY_MATH_V1_ROUND_HELPURL}`,tooltip:`%{BKY_MATH_V1_ROUND_TOOLTIP}`}]),x.forBlock.math_round_v1=function(e){let t=e.getFieldValue(`OP`),n=x.valueToCode(e,`NUM`,_.NONE)||`0`,r=``;switch(t){case`ROUND`:r=`Math.round(${n})`;break;case`ROUNDUP`:r=`Math.ceil(${n})`;break;case`ROUNDDOWN`:r=`Math.floor(${n})`;break}return[r,_.FUNCTION_CALL]},h([{type:`math_single_v1`,message0:`%1 %2`,args0:[{type:`field_dropdown`,name:`OP`,options:[[`%{BKY_MATH_SINGLE_OP_ROOT}`,`ROOT`],[`%{BKY_MATH_SINGLE_OP_ABSOLUTE}`,`ABS`],[`-`,`NEG`],[`ln`,`LN`],[`log10`,`LOG10`],[`e^`,`EXP`],[`10^`,`POW10`]]},{type:`input_value`,name:`NUM`,check:`Number`}],output:`Number`,style:`math_blocks`,helpUrl:`%{BKY_MATH_V1_SINGLE_HELPURL}`,extensions:[`math_op_tooltip_v1`]}]),x.forBlock.math_single_v1=function(e){let t=e.getFieldValue(`OP`),n,r;if(t===`NEG`)return r=x.valueToCode(e,`NUM`,_.UNARY_NEGATION)||`0`,r[0]===`-`&&(r=` `+r),n=`-`+r,[n,_.UNARY_NEGATION];switch(r=x.valueToCode(e,`NUM`,_.NONE)||`0`,t){case`ROOT`:n=`Math.sqrt(${r})`;break;case`ABS`:n=`Math.abs(${r})`;break;case`LN`:n=`Math.log(${r})`;break;case`EXP`:n=`Math.exp(${r})`;break;case`POW10`:n=`Math.pow(10, ${r})`;break}if(n)return[n,_.FUNCTION_CALL];switch(t){case`LOG10`:n=`Math.log(${r}) / Math.log(10)`;break;default:throw Error(`Unknown math operator: `+t)}return[n,_.DIVISION]},h([{type:`math_trig_v1`,message0:`%1 %2`,args0:[{type:`field_dropdown`,name:`OP`,options:[[`%{BKY_MATH_TRIG_SIN}`,`SIN`],[`%{BKY_MATH_TRIG_COS}`,`COS`],[`%{BKY_MATH_TRIG_TAN}`,`TAN`],[`%{BKY_MATH_TRIG_ASIN}`,`ASIN`],[`%{BKY_MATH_TRIG_ACOS}`,`ACOS`],[`%{BKY_MATH_TRIG_ATAN}`,`ATAN`]]},{type:`input_value`,name:`NUM`,check:`Number`}],output:`Number`,style:`math_blocks`,helpUrl:`%{BKY_MATH_V1_TRIG_HELPURL}`,extensions:[`math_op_tooltip_v1`]}]),x.forBlock.math_trig_v1=function(e){let t,n=e.getFieldValue(`OP`);t=n===`SIN`||n===`COS`||n===`TAN`?x.valueToCode(e,`NUM`,_.DIVISION)||`0`:x.valueToCode(e,`NUM`,_.NONE)||`0`;let r;switch(n){case`SIN`:r=`Math.sin(${t} / 180 * Math.PI)`;break;case`COS`:r=`Math.cos(${t} / 180 * Math.PI)`;break;case`TAN`:r=`Math.tan(${t} / 180 * Math.PI)`;break}if(r)return[r,_.FUNCTION_CALL];switch(n){case`ASIN`:r=`Math.asin(${t}) / Math.PI * 180`;break;case`ACOS`:r=`Math.acos(${t}) / Math.PI * 180`;break;case`ATAN`:r=`Math.atan(${t}) / Math.PI * 180`;break;default:throw Error(`Unknown math operator: `+n)}return[r,_.DIVISION]};const $r=e.xml;S.object_create_container_v1={init:function(){this.appendDummyInput().appendField(`%{BKY_OBJECT_V1_CREATE_CONTAINER_TITLE}`),this.appendStatementInput(`STACK`),this.setStyle(`object_blocks`),this.contextMenu=!1}},S.object_create_item_v1={init:function(){this.appendDummyInput().appendField(`%{BKY_OBJECT_V1_CREATE_ITEM_TITLE}`),this.setPreviousStatement(!0),this.setNextStatement(!0),this.setStyle(`object_blocks`),this.contextMenu=!1}},S.object_create_v1={init:function(){this.itemCount_=0,this.appendDummyInput().appendField(`%{BKY_OBJECT_V1_CREATE_TITLE}`),this.setMutator(new s.MutatorIcon([`object_create_item_v1`],this)),this.setOutput(!0,`Object`),this.setStyle(`object_blocks`),this.setTooltip(`%{BKY_OBJECT_V1_CREATE_TOOLTIP}`),this.setHelpUrl(`%{BKY_OBJECT_V1_CREATE_HELPURL}`)},mutationToDom:function(){let e=$r.createElement(`mutation`);return e.setAttribute(`items`,String(this.itemCount_)),e},domToMutation:function(e){let t=e.getAttribute(`items`)??``;this.itemCount_=parseInt(t,0),this.updateShape_()},saveExtraState:function(){return{itemCount:this.itemCount_}},loadExtraState:function(e){this.itemCount_=e.itemCount??0,this.updateShape_()},decompose:function(e){let t=e.newBlock(`object_create_container_v1`);t.initSvg();let n=t.getInput(`STACK`).connection;for(let t=0;t<this.itemCount_;t++){let t=e.newBlock(`object_create_item_v1`);t.initSvg(),n.connect(t.previousConnection),n=t.nextConnection}return t},compose:function(e){let t=e.getInputTargetBlock(`STACK`),n=[],r=[];for(;t;){if(t.isInsertionMarker()){t=t.getNextBlock();continue}n.push(t.key_),r.push(t.valueConnection_),t=t.getNextBlock()}for(let e=0;e<this.itemCount_;e++){let t=this.getInput(`ADD`+e).connection.targetConnection;t&&!r.includes(t)&&t.disconnect()}this.itemCount_=r.length,this.updateShape_();for(let e=0;e<this.itemCount_;e++)this.setFieldValue(n[e],`KEY`+e),r[e]?.reconnect(this,`ADD`+e)},saveConnections:function(e){let t=e.getInputTargetBlock(`STACK`),n=0;for(;t;){if(t.isInsertionMarker()){t=t.getNextBlock();continue}t.key_=this.getFieldValue(`KEY`+n),t.valueConnection_=this.getInput(`ADD`+n)?.connection.targetConnection,t=t.getNextBlock(),n++}},updateShape_:function(){for(let e=0;e<this.itemCount_;e++)this.getInput(`ADD`+e)||this.appendValueInput(`ADD`+e).setAlign(b.Align.RIGHT).appendField(new ve(`key`),`KEY`+e);for(let e=this.itemCount_;this.getInput(`ADD`+e);e++)this.removeInput(`ADD`+e)}},x.forBlock.object_create_v1=function(e){let t=e,n=`{`;for(let e=0;e<t.itemCount_;e++){let r=t.getFieldValue(`KEY`+e),i=x.valueToCode(t,`ADD`+e,_.ATOMIC)||null;n+=x.quote_(r)+`: `+i,e<t.itemCount_-1&&(n+=`, `)}return n+=`}`,[n,_.ATOMIC]},h([{type:`object_delete_v1`,message0:`%{BKY_OBJECT_V1_DELETE_TITLE}`,args0:[{type:`input_value`,name:`OBJECT`,check:`Object`,align:`RIGHT`},{type:`input_value`,name:`KEY`,check:`String`,align:`RIGHT`}],inputsInline:!0,previousStatement:null,nextStatement:null,style:`object_blocks`,tooltip:`%{BKY_OBJECT_V1_DELETE_TOOLTIP}`,helpUrl:`%{BKY_OBJECT_V1_DELETE_HELPURL}`}]),x.forBlock.object_delete_v1=function(e){return`${x.provideFunction_(`objectDelete`,`
260
- function ${x.FUNCTION_NAME_PLACEHOLDER_}(obj, key) {
259
+ `)+`(`+t+`, `+n+`)`,_.FUNCTION_CALL]},t([{type:`math_round_v1`,message0:`%1 %2`,args0:[{type:`field_dropdown`,name:`OP`,options:[[`%{BKY_MATH_ROUND_OPERATOR_ROUND}`,`ROUND`],[`%{BKY_MATH_ROUND_OPERATOR_ROUNDUP}`,`ROUNDUP`],[`%{BKY_MATH_ROUND_OPERATOR_ROUNDDOWN}`,`ROUNDDOWN`]]},{type:`input_value`,name:`NUM`,check:`Number`}],output:`Number`,style:`math_blocks`,helpUrl:`%{BKY_MATH_V1_ROUND_HELPURL}`,tooltip:`%{BKY_MATH_V1_ROUND_TOOLTIP}`}]),g.forBlock.math_round_v1=function(e){let t=e.getFieldValue(`OP`),n=g.valueToCode(e,`NUM`,_.NONE)||`0`,r=``;switch(t){case`ROUND`:r=`Math.round(${n})`;break;case`ROUNDUP`:r=`Math.ceil(${n})`;break;case`ROUNDDOWN`:r=`Math.floor(${n})`;break}return[r,_.FUNCTION_CALL]},t([{type:`math_single_v1`,message0:`%1 %2`,args0:[{type:`field_dropdown`,name:`OP`,options:[[`%{BKY_MATH_SINGLE_OP_ROOT}`,`ROOT`],[`%{BKY_MATH_SINGLE_OP_ABSOLUTE}`,`ABS`],[`-`,`NEG`],[`ln`,`LN`],[`log10`,`LOG10`],[`e^`,`EXP`],[`10^`,`POW10`]]},{type:`input_value`,name:`NUM`,check:`Number`}],output:`Number`,style:`math_blocks`,helpUrl:`%{BKY_MATH_V1_SINGLE_HELPURL}`,extensions:[`math_op_tooltip_v1`]}]),g.forBlock.math_single_v1=function(e){let t=e.getFieldValue(`OP`),n,r;if(t===`NEG`)return r=g.valueToCode(e,`NUM`,_.UNARY_NEGATION)||`0`,r[0]===`-`&&(r=` `+r),n=`-`+r,[n,_.UNARY_NEGATION];switch(r=g.valueToCode(e,`NUM`,_.NONE)||`0`,t){case`ROOT`:n=`Math.sqrt(${r})`;break;case`ABS`:n=`Math.abs(${r})`;break;case`LN`:n=`Math.log(${r})`;break;case`EXP`:n=`Math.exp(${r})`;break;case`POW10`:n=`Math.pow(10, ${r})`;break}if(n)return[n,_.FUNCTION_CALL];switch(t){case`LOG10`:n=`Math.log(${r}) / Math.log(10)`;break;default:throw Error(`Unknown math operator: `+t)}return[n,_.DIVISION]},t([{type:`math_trig_v1`,message0:`%1 %2`,args0:[{type:`field_dropdown`,name:`OP`,options:[[`%{BKY_MATH_TRIG_SIN}`,`SIN`],[`%{BKY_MATH_TRIG_COS}`,`COS`],[`%{BKY_MATH_TRIG_TAN}`,`TAN`],[`%{BKY_MATH_TRIG_ASIN}`,`ASIN`],[`%{BKY_MATH_TRIG_ACOS}`,`ACOS`],[`%{BKY_MATH_TRIG_ATAN}`,`ATAN`]]},{type:`input_value`,name:`NUM`,check:`Number`}],output:`Number`,style:`math_blocks`,helpUrl:`%{BKY_MATH_V1_TRIG_HELPURL}`,extensions:[`math_op_tooltip_v1`]}]),g.forBlock.math_trig_v1=function(e){let t,n=e.getFieldValue(`OP`);t=n===`SIN`||n===`COS`||n===`TAN`?g.valueToCode(e,`NUM`,_.DIVISION)||`0`:g.valueToCode(e,`NUM`,_.NONE)||`0`;let r;switch(n){case`SIN`:r=`Math.sin(${t} / 180 * Math.PI)`;break;case`COS`:r=`Math.cos(${t} / 180 * Math.PI)`;break;case`TAN`:r=`Math.tan(${t} / 180 * Math.PI)`;break}if(r)return[r,_.FUNCTION_CALL];switch(n){case`ASIN`:r=`Math.asin(${t}) / Math.PI * 180`;break;case`ACOS`:r=`Math.acos(${t}) / Math.PI * 180`;break;case`ATAN`:r=`Math.atan(${t}) / Math.PI * 180`;break;default:throw Error(`Unknown math operator: `+n)}return[r,_.DIVISION]};const $r=p.xml;y.object_create_container_v1={init:function(){this.appendDummyInput().appendField(`%{BKY_OBJECT_V1_CREATE_CONTAINER_TITLE}`),this.appendStatementInput(`STACK`),this.setStyle(`object_blocks`),this.contextMenu=!1}},y.object_create_item_v1={init:function(){this.appendDummyInput().appendField(`%{BKY_OBJECT_V1_CREATE_ITEM_TITLE}`),this.setPreviousStatement(!0),this.setNextStatement(!0),this.setStyle(`object_blocks`),this.contextMenu=!1}},y.object_create_v1={init:function(){this.itemCount_=0,this.appendDummyInput().appendField(`%{BKY_OBJECT_V1_CREATE_TITLE}`),this.setMutator(new oe.MutatorIcon([`object_create_item_v1`],this)),this.setOutput(!0,`Object`),this.setStyle(`object_blocks`),this.setTooltip(`%{BKY_OBJECT_V1_CREATE_TOOLTIP}`),this.setHelpUrl(`%{BKY_OBJECT_V1_CREATE_HELPURL}`)},mutationToDom:function(){let e=$r.createElement(`mutation`);return e.setAttribute(`items`,String(this.itemCount_)),e},domToMutation:function(e){let t=e.getAttribute(`items`)??``;this.itemCount_=parseInt(t,0),this.updateShape_()},saveExtraState:function(){return{itemCount:this.itemCount_}},loadExtraState:function(e){this.itemCount_=e.itemCount??0,this.updateShape_()},decompose:function(e){let t=e.newBlock(`object_create_container_v1`);t.initSvg();let n=t.getInput(`STACK`).connection;for(let t=0;t<this.itemCount_;t++){let t=e.newBlock(`object_create_item_v1`);t.initSvg(),n.connect(t.previousConnection),n=t.nextConnection}return t},compose:function(e){let t=e.getInputTargetBlock(`STACK`),n=[],r=[];for(;t;){if(t.isInsertionMarker()){t=t.getNextBlock();continue}n.push(t.key_),r.push(t.valueConnection_),t=t.getNextBlock()}for(let e=0;e<this.itemCount_;e++){let t=this.getInput(`ADD`+e).connection.targetConnection;t&&!r.includes(t)&&t.disconnect()}this.itemCount_=r.length,this.updateShape_();for(let e=0;e<this.itemCount_;e++)this.setFieldValue(n[e],`KEY`+e),r[e]?.reconnect(this,`ADD`+e)},saveConnections:function(e){let t=e.getInputTargetBlock(`STACK`),n=0;for(;t;){if(t.isInsertionMarker()){t=t.getNextBlock();continue}t.key_=this.getFieldValue(`KEY`+n),t.valueConnection_=this.getInput(`ADD`+n)?.connection.targetConnection,t=t.getNextBlock(),n++}},updateShape_:function(){for(let e=0;e<this.itemCount_;e++)this.getInput(`ADD`+e)||this.appendValueInput(`ADD`+e).setAlign(u.Align.RIGHT).appendField(new f(`key`),`KEY`+e);for(let e=this.itemCount_;this.getInput(`ADD`+e);e++)this.removeInput(`ADD`+e)}},g.forBlock.object_create_v1=function(e){let t=e,n=`{`;for(let e=0;e<t.itemCount_;e++){let r=t.getFieldValue(`KEY`+e),i=g.valueToCode(t,`ADD`+e,_.ATOMIC)||null;n+=g.quote_(r)+`: `+i,e<t.itemCount_-1&&(n+=`, `)}return n+=`}`,[n,_.ATOMIC]},t([{type:`object_delete_v1`,message0:`%{BKY_OBJECT_V1_DELETE_TITLE}`,args0:[{type:`input_value`,name:`OBJECT`,check:`Object`,align:`RIGHT`},{type:`input_value`,name:`KEY`,check:`String`,align:`RIGHT`}],inputsInline:!0,previousStatement:null,nextStatement:null,style:`object_blocks`,tooltip:`%{BKY_OBJECT_V1_DELETE_TOOLTIP}`,helpUrl:`%{BKY_OBJECT_V1_DELETE_HELPURL}`}]),g.forBlock.object_delete_v1=function(e){return`${g.provideFunction_(`objectDelete`,`
260
+ function ${g.FUNCTION_NAME_PLACEHOLDER_}(obj, key) {
261
261
  if (typeof(obj) !== 'object' || obj === null) {
262
262
  return
263
263
  }
@@ -289,8 +289,8 @@ function ${x.FUNCTION_NAME_PLACEHOLDER_}(obj, key) {
289
289
  }
290
290
  }
291
291
  }
292
- `)}(${x.valueToCode(e,`OBJECT`,_.ATOMIC)||`null`}, ${x.valueToCode(e,`KEY`,_.ATOMIC)||`''`});\n`},h([{type:`object_from_json_v1`,message0:`%{BKY_OBJECT_V1_FROM_JSON_TITLE}`,args0:[{type:`input_value`,name:`JSON`,check:`String`}],inputsInline:!0,output:`Object`,style:`object_blocks`,tooltip:`%{BKY_OBJECT_V1_FROM_JSON_TOOLTIP}`,helpUrl:`%{BKY_OBJECT_V1_FROM_JSON_HELPURL}`}]),x.forBlock.object_from_json_v1=function(e){return[`__parseJsonV1__(${x.valueToCode(e,`JSON`,_.NONE)||`''`})`,_.FUNCTION_CALL]},h([{type:`object_get_v1`,message0:`%{BKY_OBJECT_V1_GET_TITLE}`,args0:[{type:`input_value`,name:`OBJECT`,check:`Object`,align:`RIGHT`},{type:`input_value`,name:`KEY`,check:`String`,align:`RIGHT`}],inputsInline:!0,output:null,style:`object_blocks`,tooltip:`%{BKY_OBJECT_V1_GET_TOOLTIP}`,helpUrl:`%{BKY_OBJECT_V1_GET_HELPURL}`}]),x.forBlock.object_get_v1=function(e){return[`${x.provideFunction_(`objectGet`,`
293
- function ${x.FUNCTION_NAME_PLACEHOLDER_}(obj, key) {
292
+ `)}(${g.valueToCode(e,`OBJECT`,_.ATOMIC)||`null`}, ${g.valueToCode(e,`KEY`,_.ATOMIC)||`''`});\n`},t([{type:`object_from_json_v1`,message0:`%{BKY_OBJECT_V1_FROM_JSON_TITLE}`,args0:[{type:`input_value`,name:`JSON`,check:`String`}],inputsInline:!0,output:`Object`,style:`object_blocks`,tooltip:`%{BKY_OBJECT_V1_FROM_JSON_TOOLTIP}`,helpUrl:`%{BKY_OBJECT_V1_FROM_JSON_HELPURL}`}]),g.forBlock.object_from_json_v1=function(e){return[`__parseJsonV1__(${g.valueToCode(e,`JSON`,_.NONE)||`''`})`,_.FUNCTION_CALL]},t([{type:`object_get_v1`,message0:`%{BKY_OBJECT_V1_GET_TITLE}`,args0:[{type:`input_value`,name:`OBJECT`,check:`Object`,align:`RIGHT`},{type:`input_value`,name:`KEY`,check:`String`,align:`RIGHT`}],inputsInline:!0,output:null,style:`object_blocks`,tooltip:`%{BKY_OBJECT_V1_GET_TOOLTIP}`,helpUrl:`%{BKY_OBJECT_V1_GET_HELPURL}`}]),g.forBlock.object_get_v1=function(e){return[`${g.provideFunction_(`objectGet`,`
293
+ function ${g.FUNCTION_NAME_PLACEHOLDER_}(obj, key) {
294
294
  if (typeof(obj) !== 'object' || obj === null) {
295
295
  return
296
296
  }
@@ -314,8 +314,8 @@ function ${x.FUNCTION_NAME_PLACEHOLDER_}(obj, key) {
314
314
  }
315
315
  }
316
316
  }
317
- `)}(${x.valueToCode(e,`OBJECT`,_.ATOMIC)||`null`}, ${x.valueToCode(e,`KEY`,_.ATOMIC)||`''`})`,_.FUNCTION_CALL]},h([{type:`object_set_v1`,message0:`%{BKY_OBJECT_V1_SET_TITLE}`,args0:[{type:`input_value`,name:`OBJECT`,check:`Object`,align:`RIGHT`},{type:`input_value`,name:`KEY`,check:`String`,align:`RIGHT`},{type:`input_value`,name:`TO`,check:[`String`,`Number`,`Boolean`,`Array`,`Object`],align:`RIGHT`}],inputsInline:!0,previousStatement:null,nextStatement:null,style:`object_blocks`,tooltip:`%{BKY_OBJECT_V1_SET_TOOLTIP}`,helpUrl:`%{BKY_OBJECT_V1_SET_HELPURL}`}]),x.forBlock.object_set_v1=function(e){return`${x.provideFunction_(`objectSet`,`
318
- function ${x.FUNCTION_NAME_PLACEHOLDER_}(obj, key, val) {
317
+ `)}(${g.valueToCode(e,`OBJECT`,_.ATOMIC)||`null`}, ${g.valueToCode(e,`KEY`,_.ATOMIC)||`''`})`,_.FUNCTION_CALL]},t([{type:`object_set_v1`,message0:`%{BKY_OBJECT_V1_SET_TITLE}`,args0:[{type:`input_value`,name:`OBJECT`,check:`Object`,align:`RIGHT`},{type:`input_value`,name:`KEY`,check:`String`,align:`RIGHT`},{type:`input_value`,name:`TO`,check:[`String`,`Number`,`Boolean`,`Array`,`Object`],align:`RIGHT`}],inputsInline:!0,previousStatement:null,nextStatement:null,style:`object_blocks`,tooltip:`%{BKY_OBJECT_V1_SET_TOOLTIP}`,helpUrl:`%{BKY_OBJECT_V1_SET_HELPURL}`}]),g.forBlock.object_set_v1=function(e){return`${g.provideFunction_(`objectSet`,`
318
+ function ${g.FUNCTION_NAME_PLACEHOLDER_}(obj, key, val) {
319
319
  if (typeof(obj) !== 'object' || obj === null) {
320
320
  return
321
321
  }
@@ -340,38 +340,38 @@ function ${x.FUNCTION_NAME_PLACEHOLDER_}(obj, key, val) {
340
340
  }
341
341
  }
342
342
  }
343
- `)}(${x.valueToCode(e,`OBJECT`,_.ATOMIC)||`null`}, ${x.valueToCode(e,`KEY`,_.ATOMIC)||`''`}, ${x.valueToCode(e,`TO`,_.ATOMIC)||`null`});\n`},h([{type:`object_to_json_v1`,message0:`%{BKY_OBJECT_V1_TO_JSON_TITLE}`,args0:[{type:`input_value`,name:`OBJECT`,check:`Object`}],inputsInline:!0,output:`String`,style:`object_blocks`,tooltip:`%{BKY_OBJECT_V1_TO_JSON_TOOLTIP}`,helpUrl:`%{BKY_OBJECT_V1_TO_JSON_HELPURL}`}]),x.forBlock.object_to_json_v1=function(e){return[`__jsonStringifyV1__(${x.valueToCode(e,`OBJECT`,_.NONE)||`null`})`,_.FUNCTION_CALL]};const ei=e.xml;S.procedure_def_container_v1={init:function(){this.appendDummyInput().appendField(`%{BKY_PROCEDURE_V1_DEF_CONTAINER_TITLE}`).appendField(new Ee(!1),`WITHRETURN`),this.appendStatementInput(`STACK`),this.setStyle(`procedure_blocks`),this.contextMenu=!1}},S.procedure_def_item_v1={init:function(){let e=new ve(f.DEFAULT_ARG);e.setValidator(this.validator_),this.appendDummyInput().appendField(`%{BKY_PROCEDURE_V1_DEF_ITEM_TITLE}`).appendField(e,`NAME`),this.setPreviousStatement(!0),this.setNextStatement(!0),this.setStyle(`procedure_blocks`),this.contextMenu=!1},validator_:function(e){if(e=e.replace(/[\s\xa0]+/g,` `).replace(/^ | $/g,``),!e)return null;let t=this.getSourceBlock();if(!t)return null;let n=t.workspace;n.targetWorkspace&&(n=n.targetWorkspace);let r=n.getAllBlocks(!1);for(let n=0;n<r.length;n++){let i=r[n];if(i.type===`procedure_def_item_v1`&&i.id!==t.id&&i.getFieldValue(`NAME`).toLowerCase()===e.toLowerCase())return null}return e}},S.procedure_def_v1={init:function(){this.withReturn=!1,this.args=[];let e=new ve(f.findLegalName(``,this));e.setValidator(f.rename),e.setSpellcheck(!1),this.appendDummyInput(`DUMMY`).appendField(e,`NAME`),this.appendStatementInput(`HANDLE`),this.setMutator(new s.MutatorIcon([`procedure_def_item_v1`],this)),this.setStyle(`procedure_blocks`),this.setTooltip(`%{BKY_PROCEDURE_V1_DEF_TOOLTIP}`),this.setHelpUrl(`%{BKY_PROCEDURE_V1_DEF_HELPURL}`)},mutationToDom:function(){let e=ei.createElement(`mutation`);return e.setAttribute(`withreturn`,this.withReturn?`TRUE`:`FALSE`),this.args.forEach(t=>{let n=ei.createElement(`arg`);n.setAttribute(`name`,t.name),n.setAttribute(`id`,t.id),e.appendChild(n)}),e},domToMutation:function(e){this.withReturn=e.getAttribute(`withreturn`)===`TRUE`;let t=[];for(let n=0;n<e.childNodes.length;n++){let r=e.childNodes[n];if(r&&r.nodeName.toLowerCase()===`arg`){let e=r.getAttribute(`name`),n=r.getAttribute(`id`);t.push({name:e,id:n})}}this.args=t,this.updateShape_()},saveExtraState:function(){return{withReturn:this.withReturn,args:this.args}},loadExtraState:function(e){this.withReturn=e.withReturn,this.args=e.args,this.updateShape_()},getProcedureDef:function(){let e=this.getFieldValue(`NAME`),t=[];return this.args.forEach(e=>{t.push(e.name)}),[e,t,this.withReturn]},decompose:function(e){let t=e.newBlock(`procedure_def_container_v1`);t.initSvg(),t.setFieldValue(this.withReturn,`WITHRETURN`);let n=t.getInput(`STACK`).connection;for(let t=0;t<this.args.length;t++){let r=this.args[t],i=e.newBlock(`procedure_def_item_v1`);i.setFieldValue(r.name,`NAME`),i.initSvg(),n.connect(i.previousConnection),n=i.nextConnection}return t},compose:function(e){this.withReturn=e.getFieldValue(`WITHRETURN`)===`TRUE`;let t=[],n=e.getInputTargetBlock(`STACK`);for(;n;){if(n.isInsertionMarker()){n=n.getNextBlock();continue}t.push({name:n.getFieldValue(`NAME`),id:n.id}),n=n.getNextBlock()}this.args=t,this.updateShape_(),this.ensureBlocks_()},updateShape_:function(){let e=this.getInput(`DUMMY`);this.withReturn?e.fieldRow.find(e=>e.name===`WITHRETURN`)||e.appendField(`%{BKY_PROCEDURE_WITH_RETURN}`,`WITHRETURN`):e.removeField(`WITHRETURN`,!0);for(let e=0;e<this.args.length;e++)this.getInput(`ARG`+e)||(this.appendValueInput(`ARG`+e),this.moveInputBefore(`ARG`+e,`HANDLE`));for(let e=this.args.length;this.getInput(`ARG`+e);e++){let t=this.getInput(`ARG`+e)?.connection?.targetBlock();t&&t.dispose(),this.removeInput(`ARG`+e)}},ensureBlocks_:function(){if(!this.isInsertionMarker())for(let e=0;e<this.args.length;e++){let t=this.args[e],n=this.getInput(`ARG`+e).connection,r=n.targetBlock();if(r)r.setKeyName(`__param@${t.id}__`,t.name,!1);else try{p.disable(),r=un(this.workspace,`__param@${t.id}__`,t.name,!1),r.outputConnection.connect(n)}finally{p.enable()}}}};const ti=e.xml;S.procedure_return_v1={init:function(){this.withReturn=!1,this.appendDummyInput(`DUMMY`).appendField(`%{BKY_PROCEDURE_RETURN}`),this.appendValueInput(`VALUE`).appendField(`%{BKY_PROCEDURE_RETURN}`).setVisible(!1),this.setPreviousStatement(!0),this.setStyle(`procedure_blocks`),this.setTooltip(`%{BKY_PROCEDURE_V1_RETURN_TOOLTIP}`),this.setHelpUrl(`%{BKY_PROCEDURE_V1_RETURN_HELPURL}`)},mutationToDom:function(){let e=ti.createElement(`mutation`);return e.setAttribute(`withreturn`,this.withReturn?`TRUE`:`FALSE`),e},domToMutation:function(e){this.withReturn=e.getAttribute(`withreturn`)===`TRUE`,this.updateShape_(),setTimeout(()=>{this.checkWarning_()},0)},saveExtraState:function(){return{withReturn:this.withReturn}},loadExtraState:function(e){this.withReturn=e.withReturn,this.updateShape_(),setTimeout(()=>{this.checkWarning_()},0)},onchange:function(e){if(e.type===p.BLOCK_DRAG){let t=e;if(t.isStart||!t.blocks?.find(e=>e.id===this.id))return;this.updateShape_(),setTimeout(()=>{this.checkWarning_()},0)}},updateShape_:function(){let e=!1,t=this.getRootBlock();if(t.type.startsWith(`procedure_def_v`)){let n=t;this.withReturn!==n.withReturn&&(e=!0)}else t.type.startsWith(`func_entry_v`)&&this.withReturn&&(e=!0);if(e){if(this.withReturn){let e=this.getInput(`INPUT`)?.connection?.targetConnection;e&&e.disconnect()}this.withReturn=!this.withReturn}this.getInput(`DUMMY`).setVisible(!this.withReturn),this.getInput(`VALUE`).setVisible(this.withReturn),this.render()},checkWarning_:function(){let e=this.getRootBlock();e.type===`procedure_def_v1`||e.type===`func_entry_v1`?this.setWarningText(null):this.setWarningText(`the block can only be used in procedure block`)}},x.forBlock.procedure_return_v1=function(e){let t=e;return t.withReturn?`return ${x.valueToCode(t,`VALUE`,_.NONE)||`null`};\n`:`return;
344
- `},S.download_resource_v1={init:function(){this.appendDummyInput().appendField(`%{BKY_ASSET_V1_DOWNLOAD_ASSET_TITLE}`),this.setPreviousStatement(!0,null),this.setNextStatement(!0,null),this.setStyle(`procedure_blocks`),this.setTooltip(`%{BKY_ASSET_V1_DOWNLOAD_ASSET_TOOLTIP}`),this.setHelpUrl(`%{BKY_ASSET_V1_DOWNLOAD_ASSET_HELPURL}`)},saveExtraState:function(){return{}},loadExtraState:function(){this.updateShape_(),setTimeout(()=>{this.ensureBlocks_()},0)},updateShape_:function(){this.getInput(`HANDLE`)||this.appendStatementInput(`HANDLE`).appendField(`%{BKY_ASSET_DO}`),this.getInput(`DATA`)||(this.appendValueInput(`DATA`),this.moveInputBefore(`DATA`,`HANDLE`)),this.getInput(`MESSAGE`)||(this.appendValueInput(`MESSAGE`),this.moveInputBefore(`MESSAGE`,`DATA`)),this.getInput(`SUCCESS`)||(this.appendValueInput(`SUCCESS`).appendField(`%{BKY_ASSET_RETURN}`),this.moveInputBefore(`SUCCESS`,`MESSAGE`)),this.getInput(`ASSET`)||(this.appendValueInput(`ASSET`).setCheck(`Resource`).setAlign(b.Align.RIGHT).appendField(`%{BKY_ASSET_ASSET}`),this.moveInputBefore(`ASSET`,`SUCCESS`))},ensureBlocks_:function(){this.isInsertionMarker()||V(this,[[`SUCCESS`,`__success__`,`x-runtime-lib.success`,!0],[`MESSAGE`,`__message__`,`x-runtime-lib.message`,!0],[`DATA`,`__data__`,`x-runtime-lib.data`,!0]])}},x.forBlock.download_resource_v1=function(e){return`{
345
- var res = __downloadResourceV1__(${x.valueToCode(e,`ASSET`,_.ATOMIC)||null});
343
+ `)}(${g.valueToCode(e,`OBJECT`,_.ATOMIC)||`null`}, ${g.valueToCode(e,`KEY`,_.ATOMIC)||`''`}, ${g.valueToCode(e,`TO`,_.ATOMIC)||`null`});\n`},t([{type:`object_to_json_v1`,message0:`%{BKY_OBJECT_V1_TO_JSON_TITLE}`,args0:[{type:`input_value`,name:`OBJECT`,check:`Object`}],inputsInline:!0,output:`String`,style:`object_blocks`,tooltip:`%{BKY_OBJECT_V1_TO_JSON_TOOLTIP}`,helpUrl:`%{BKY_OBJECT_V1_TO_JSON_HELPURL}`}]),g.forBlock.object_to_json_v1=function(e){return[`__jsonStringifyV1__(${g.valueToCode(e,`OBJECT`,_.NONE)||`null`})`,_.FUNCTION_CALL]};const ei=p.xml;y.procedure_def_container_v1={init:function(){this.appendDummyInput().appendField(`%{BKY_PROCEDURE_V1_DEF_CONTAINER_TITLE}`).appendField(new n(!1),`WITHRETURN`),this.appendStatementInput(`STACK`),this.setStyle(`procedure_blocks`),this.contextMenu=!1}},y.procedure_def_item_v1={init:function(){let e=new f(_e.DEFAULT_ARG);e.setValidator(this.validator_),this.appendDummyInput().appendField(`%{BKY_PROCEDURE_V1_DEF_ITEM_TITLE}`).appendField(e,`NAME`),this.setPreviousStatement(!0),this.setNextStatement(!0),this.setStyle(`procedure_blocks`),this.contextMenu=!1},validator_:function(e){if(e=e.replace(/[\s\xa0]+/g,` `).replace(/^ | $/g,``),!e)return null;let t=this.getSourceBlock();if(!t)return null;let n=t.workspace;n.targetWorkspace&&(n=n.targetWorkspace);let r=n.getAllBlocks(!1);for(let n=0;n<r.length;n++){let i=r[n];if(i.type===`procedure_def_item_v1`&&i.id!==t.id&&i.getFieldValue(`NAME`).toLowerCase()===e.toLowerCase())return null}return e}},y.procedure_def_v1={init:function(){this.withReturn=!1,this.args=[];let e=new f(_e.findLegalName(``,this));e.setValidator(_e.rename),e.setSpellcheck(!1),this.appendDummyInput(`DUMMY`).appendField(e,`NAME`),this.appendStatementInput(`HANDLE`),this.setMutator(new oe.MutatorIcon([`procedure_def_item_v1`],this)),this.setStyle(`procedure_blocks`),this.setTooltip(`%{BKY_PROCEDURE_V1_DEF_TOOLTIP}`),this.setHelpUrl(`%{BKY_PROCEDURE_V1_DEF_HELPURL}`)},mutationToDom:function(){let e=ei.createElement(`mutation`);return e.setAttribute(`withreturn`,this.withReturn?`TRUE`:`FALSE`),this.args.forEach(t=>{let n=ei.createElement(`arg`);n.setAttribute(`name`,t.name),n.setAttribute(`id`,t.id),e.appendChild(n)}),e},domToMutation:function(e){this.withReturn=e.getAttribute(`withreturn`)===`TRUE`;let t=[];for(let n=0;n<e.childNodes.length;n++){let r=e.childNodes[n];if(r&&r.nodeName.toLowerCase()===`arg`){let e=r.getAttribute(`name`),n=r.getAttribute(`id`);t.push({name:e,id:n})}}this.args=t,this.updateShape_()},saveExtraState:function(){return{withReturn:this.withReturn,args:this.args}},loadExtraState:function(e){this.withReturn=e.withReturn,this.args=e.args,this.updateShape_()},getProcedureDef:function(){let e=this.getFieldValue(`NAME`),t=[];return this.args.forEach(e=>{t.push(e.name)}),[e,t,this.withReturn]},decompose:function(e){let t=e.newBlock(`procedure_def_container_v1`);t.initSvg(),t.setFieldValue(this.withReturn,`WITHRETURN`);let n=t.getInput(`STACK`).connection;for(let t=0;t<this.args.length;t++){let r=this.args[t],i=e.newBlock(`procedure_def_item_v1`);i.setFieldValue(r.name,`NAME`),i.initSvg(),n.connect(i.previousConnection),n=i.nextConnection}return t},compose:function(e){this.withReturn=e.getFieldValue(`WITHRETURN`)===`TRUE`;let t=[],n=e.getInputTargetBlock(`STACK`);for(;n;){if(n.isInsertionMarker()){n=n.getNextBlock();continue}t.push({name:n.getFieldValue(`NAME`),id:n.id}),n=n.getNextBlock()}this.args=t,this.updateShape_(),this.ensureBlocks_()},updateShape_:function(){let e=this.getInput(`DUMMY`);this.withReturn?e.fieldRow.find(e=>e.name===`WITHRETURN`)||e.appendField(`%{BKY_PROCEDURE_WITH_RETURN}`,`WITHRETURN`):e.removeField(`WITHRETURN`,!0);for(let e=0;e<this.args.length;e++)this.getInput(`ARG`+e)||(this.appendValueInput(`ARG`+e),this.moveInputBefore(`ARG`+e,`HANDLE`));for(let e=this.args.length;this.getInput(`ARG`+e);e++){let t=this.getInput(`ARG`+e)?.connection?.targetBlock();t&&t.dispose(),this.removeInput(`ARG`+e)}},ensureBlocks_:function(){if(!this.isInsertionMarker())for(let e=0;e<this.args.length;e++){let t=this.args[e],n=this.getInput(`ARG`+e).connection,r=n.targetBlock();if(r)r.setKeyName(`__param@${t.id}__`,t.name,!1);else try{x.disable(),r=un(this.workspace,`__param@${t.id}__`,t.name,!1),r.outputConnection.connect(n)}finally{x.enable()}}}};const ti=p.xml;y.procedure_return_v1={init:function(){this.withReturn=!1,this.appendDummyInput(`DUMMY`).appendField(`%{BKY_PROCEDURE_RETURN}`),this.appendValueInput(`VALUE`).appendField(`%{BKY_PROCEDURE_RETURN}`).setVisible(!1),this.setPreviousStatement(!0),this.setStyle(`procedure_blocks`),this.setTooltip(`%{BKY_PROCEDURE_V1_RETURN_TOOLTIP}`),this.setHelpUrl(`%{BKY_PROCEDURE_V1_RETURN_HELPURL}`)},mutationToDom:function(){let e=ti.createElement(`mutation`);return e.setAttribute(`withreturn`,this.withReturn?`TRUE`:`FALSE`),e},domToMutation:function(e){this.withReturn=e.getAttribute(`withreturn`)===`TRUE`,this.updateShape_(),setTimeout(()=>{this.checkWarning_()},0)},saveExtraState:function(){return{withReturn:this.withReturn}},loadExtraState:function(e){this.withReturn=e.withReturn,this.updateShape_(),setTimeout(()=>{this.checkWarning_()},0)},onchange:function(e){if(e.type===x.BLOCK_DRAG){let t=e;if(t.isStart||!t.blocks?.find(e=>e.id===this.id))return;this.updateShape_(),setTimeout(()=>{this.checkWarning_()},0)}},updateShape_:function(){let e=!1,t=this.getRootBlock();if(t.type.startsWith(`procedure_def_v`)){let n=t;this.withReturn!==n.withReturn&&(e=!0)}else t.type.startsWith(`func_entry_v`)&&this.withReturn&&(e=!0);if(e){if(this.withReturn){let e=this.getInput(`INPUT`)?.connection?.targetConnection;e&&e.disconnect()}this.withReturn=!this.withReturn}this.getInput(`DUMMY`).setVisible(!this.withReturn),this.getInput(`VALUE`).setVisible(this.withReturn),this.render()},checkWarning_:function(){let e=this.getRootBlock();e.type===`procedure_def_v1`||e.type===`func_entry_v1`?this.setWarningText(null):this.setWarningText(`the block can only be used in procedure block`)}},g.forBlock.procedure_return_v1=function(e){let t=e;return t.withReturn?`return ${g.valueToCode(t,`VALUE`,_.NONE)||`null`};\n`:`return;
344
+ `},y.download_resource_v1={init:function(){this.appendDummyInput().appendField(`%{BKY_ASSET_V1_DOWNLOAD_ASSET_TITLE}`),this.setPreviousStatement(!0,null),this.setNextStatement(!0,null),this.setStyle(`procedure_blocks`),this.setTooltip(`%{BKY_ASSET_V1_DOWNLOAD_ASSET_TOOLTIP}`),this.setHelpUrl(`%{BKY_ASSET_V1_DOWNLOAD_ASSET_HELPURL}`)},saveExtraState:function(){return{}},loadExtraState:function(){this.updateShape_(),setTimeout(()=>{this.ensureBlocks_()},0)},updateShape_:function(){this.getInput(`HANDLE`)||this.appendStatementInput(`HANDLE`).appendField(`%{BKY_ASSET_DO}`),this.getInput(`DATA`)||(this.appendValueInput(`DATA`),this.moveInputBefore(`DATA`,`HANDLE`)),this.getInput(`MESSAGE`)||(this.appendValueInput(`MESSAGE`),this.moveInputBefore(`MESSAGE`,`DATA`)),this.getInput(`SUCCESS`)||(this.appendValueInput(`SUCCESS`).appendField(`%{BKY_ASSET_RETURN}`),this.moveInputBefore(`SUCCESS`,`MESSAGE`)),this.getInput(`ASSET`)||(this.appendValueInput(`ASSET`).setCheck(`Resource`).setAlign(u.Align.RIGHT).appendField(`%{BKY_ASSET_ASSET}`),this.moveInputBefore(`ASSET`,`SUCCESS`))},ensureBlocks_:function(){this.isInsertionMarker()||V(this,[[`SUCCESS`,`__success__`,`x-runtime-lib.success`,!0],[`MESSAGE`,`__message__`,`x-runtime-lib.message`,!0],[`DATA`,`__data__`,`x-runtime-lib.data`,!0]])}},g.forBlock.download_resource_v1=function(e){return`{
345
+ var res = __downloadResourceV1__(${g.valueToCode(e,`ASSET`,_.ATOMIC)||null});
346
346
  var __success__ = res.success;
347
347
  var __message__ = res.message;
348
348
  var __data__ = res.data;
349
- ${x.statementToCode(e,`HANDLE`)}
349
+ ${g.statementToCode(e,`HANDLE`)}
350
350
  }
351
- `};function ni(e){let t=C.resource.spaces.find(t=>t.id===e);if(!t)return[];let n=[];function r(e,t){let i=t+e.name+`/`;n.push({id:e.id,name:i}),e.children.forEach(e=>{r(e,i)})}return r(t.dirTree,``),n}function ri(e){let t=[];return ni(e).forEach(({id:e,name:n})=>{t.push([n,e])}),I(t)}function ii(e,t){let n=C.resource.spaces.find(t=>t.id===e);if(!n)return[];let r=[];return n.resources.forEach(e=>{e.dirid===t&&r.push(e)}),r}function ai(e,t){let n=[];return ii(e,t).forEach(({id:e,name:t})=>{n.push([t,e])}),I(n)}function oi(){let e=[];return C.resource.spaces.forEach(t=>{t.resources.length>0&&e.push(t)}),e}function si(){let e=[];return oi().forEach(({id:t,name:n})=>{e.push([n,t])}),I(e)}S.select_resource_v1={init:function(){this.space={id:``,name:``},this.dir={id:``,name:``},this.resource={id:``,name:``},this.appendDummyInput().appendField(`%{BKY_RESOURCE_V1_SELECT_RESOURCE_TITLE`).appendField(new m(()=>this.genSpaceOpts_()),`SPACE`).appendField(new m(()=>this.genDirOpts_()),`DIR`).appendField(new m(()=>this.genResourceOpts_()),`RESOURCE`),this.setOutput(!0,`Resource`),this.setStyle(`resource_blocks`),this.setTooltip(`%{BKY_RESOURCE_V1_SELECT_RESOURCE_TOOLTIP}`),this.setHelpUrl(`%{BKY_RESOURCE_V1_SELECT_RESOURCE_HELPURL}`),this.initData_()},initData_:function(){if(this.space.id)return;let e=oi()?.[0];if(!e)return;this.space.id=e.id,this.space.name=e.name;let t=this.getField(`SPACE`);t.getOptions(!1),t.setValue(this.space.id);let n=ni(this.space.id)?.[0];if(!n)return;this.dir.id=n.id,this.dir.name=n.name;let r=this.getField(`DIR`);r.getOptions(!1),r.setValue(this.dir.id);let i=ii(this.space.id,this.dir.id)?.[0];if(!i)return;this.resource.id=i.id,this.resource.name=i.name;let a=this.getField(`RESOURCE`);a.getOptions(!1),a.setValue(this.resource.id)},saveExtraState:function(){return{space:this.space,dir:this.dir,resource:this.resource}},loadExtraState:function(e){this.space=he(e.space),this.dir=he(e.dir),this.resource=he(e.resource)},genSpaceOpts_:function(){return si()},genDirOpts_:function(){return ri(this.space.id)},genResourceOpts_:function(){return ai(this.space.id,this.dir.id)}},x.forBlock.select_resource_v1=function(){return``},S.upload_resource_v1={init:function(){this.appendDummyInput().appendField(`%{BKY_RESOURCE_V1_UPLOAD_RESOURCE_TITLE}`),this.setPreviousStatement(!0,null),this.setNextStatement(!0,null),this.setStyle(`resource_blocks`),this.setTooltip(`%{BKY_RESOURCE_V1_UPLOAD_RESOURCE_TOOLTIP}`),this.setHelpUrl(`%{BKY_RESOURCE_V1_UPLOAD_RESOURCE_HELPURL}`)},saveExtraState:function(){return{}},loadExtraState:function(){this.updateShape_(),this.updateShadow_(),setTimeout(()=>{this.ensureBlocks_()},0)},updateShape_:function(){this.getInput(`HANDLE`)||this.appendStatementInput(`HANDLE`).appendField(`%{BKY_RESOURCE_DO}`),this.getInput(`RESULT`)||(this.appendValueInput(`RESULT`),this.moveInputBefore(`RESULT`,`HANDLE`)),this.getInput(`MESSAGE`)||(this.appendValueInput(`MESSAGE`),this.moveInputBefore(`MESSAGE`,`RESULT`)),this.getInput(`SUCCESS`)||(this.appendValueInput(`SUCCESS`).appendField(`%{BKY_RESOURCE_RESULT}`),this.moveInputBefore(`SUCCESS`,`MESSAGE`)),this.getInput(`DATA`)||(this.appendValueInput(`DATA`).setAlign(b.Align.RIGHT).appendField(`%{BKY_RESOURCE_DATA}`),this.moveInputBefore(`DATA`,`SUCCESS`)),this.getInput(`DIR`)||(this.appendValueInput(`DIR`).setCheck(`SelectDir`).setAlign(b.Align.RIGHT).appendField(`%{BKY_RESOURCE_DIR}`),this.moveInputBefore(`DIR`,`DATA`)),this.getInput(`NAME`)||(this.appendValueInput(`NAME`).setCheck(`String`).setAlign(b.Align.RIGHT).appendField(`%{BKY_RESOURCE_NAME}`),this.moveInputBefore(`NAME`,`DIR`))},updateShadow_:function(){if(this.isInsertionMarker())return;let e=dn(``);this.getInput(`NAME`)?.setShadowDom(e)},ensureBlocks_:function(){this.isInsertionMarker()||V(this,[[`SUCCESS`,`__success__`,`x-runtime-lib.success`,!0],[`MESSAGE`,`__message__`,`x-runtime-lib.message`,!0],[`RESULT`,`__result__`,`x-runtime-lib.result`,!0]])}},x.forBlock.upload_resource_v1=function(e){return`{
352
- var res = __uploadResourceV1__(${x.valueToCode(e,`NAME`,_.ATOMIC)||`''`}, ${x.valueToCode(e,`DIR`,_.ATOMIC)||`null`}, ${x.valueToCode(e,`DATA`,_.ATOMIC)||`null`});
351
+ `};function ni(e){let t=S.resource.spaces.find(t=>t.id===e);if(!t)return[];let n=[];function r(e,t){let i=t+e.name+`/`;n.push({id:e.id,name:i}),e.children.forEach(e=>{r(e,i)})}return r(t.dirTree,``),n}function ri(e){let t=[];return ni(e).forEach(({id:e,name:n})=>{t.push([n,e])}),I(t)}function ii(e,t){let n=S.resource.spaces.find(t=>t.id===e);if(!n)return[];let r=[];return n.resources.forEach(e=>{e.dirid===t&&r.push(e)}),r}function ai(e,t){let n=[];return ii(e,t).forEach(({id:e,name:t})=>{n.push([t,e])}),I(n)}function oi(){let e=[];return S.resource.spaces.forEach(t=>{t.resources.length>0&&e.push(t)}),e}function si(){let e=[];return oi().forEach(({id:t,name:n})=>{e.push([n,t])}),I(e)}y.select_resource_v1={init:function(){this.space={id:``,name:``},this.dir={id:``,name:``},this.resource={id:``,name:``},this.appendDummyInput().appendField(`%{BKY_RESOURCE_V1_SELECT_RESOURCE_TITLE`).appendField(new b(()=>this.genSpaceOpts_()),`SPACE`).appendField(new b(()=>this.genDirOpts_()),`DIR`).appendField(new b(()=>this.genResourceOpts_()),`RESOURCE`),this.setOutput(!0,`Resource`),this.setStyle(`resource_blocks`),this.setTooltip(`%{BKY_RESOURCE_V1_SELECT_RESOURCE_TOOLTIP}`),this.setHelpUrl(`%{BKY_RESOURCE_V1_SELECT_RESOURCE_HELPURL}`),this.initData_()},initData_:function(){if(this.space.id)return;let e=oi()?.[0];if(!e)return;this.space.id=e.id,this.space.name=e.name;let t=this.getField(`SPACE`);t.getOptions(!1),t.setValue(this.space.id);let n=ni(this.space.id)?.[0];if(!n)return;this.dir.id=n.id,this.dir.name=n.name;let r=this.getField(`DIR`);r.getOptions(!1),r.setValue(this.dir.id);let i=ii(this.space.id,this.dir.id)?.[0];if(!i)return;this.resource.id=i.id,this.resource.name=i.name;let a=this.getField(`RESOURCE`);a.getOptions(!1),a.setValue(this.resource.id)},saveExtraState:function(){return{space:this.space,dir:this.dir,resource:this.resource}},loadExtraState:function(e){this.space=he(e.space),this.dir=he(e.dir),this.resource=he(e.resource)},genSpaceOpts_:function(){return si()},genDirOpts_:function(){return ri(this.space.id)},genResourceOpts_:function(){return ai(this.space.id,this.dir.id)}},g.forBlock.select_resource_v1=function(){return``},y.upload_resource_v1={init:function(){this.appendDummyInput().appendField(`%{BKY_RESOURCE_V1_UPLOAD_RESOURCE_TITLE}`),this.setPreviousStatement(!0,null),this.setNextStatement(!0,null),this.setStyle(`resource_blocks`),this.setTooltip(`%{BKY_RESOURCE_V1_UPLOAD_RESOURCE_TOOLTIP}`),this.setHelpUrl(`%{BKY_RESOURCE_V1_UPLOAD_RESOURCE_HELPURL}`)},saveExtraState:function(){return{}},loadExtraState:function(){this.updateShape_(),this.updateShadow_(),setTimeout(()=>{this.ensureBlocks_()},0)},updateShape_:function(){this.getInput(`HANDLE`)||this.appendStatementInput(`HANDLE`).appendField(`%{BKY_RESOURCE_DO}`),this.getInput(`RESULT`)||(this.appendValueInput(`RESULT`),this.moveInputBefore(`RESULT`,`HANDLE`)),this.getInput(`MESSAGE`)||(this.appendValueInput(`MESSAGE`),this.moveInputBefore(`MESSAGE`,`RESULT`)),this.getInput(`SUCCESS`)||(this.appendValueInput(`SUCCESS`).appendField(`%{BKY_RESOURCE_RESULT}`),this.moveInputBefore(`SUCCESS`,`MESSAGE`)),this.getInput(`DATA`)||(this.appendValueInput(`DATA`).setAlign(u.Align.RIGHT).appendField(`%{BKY_RESOURCE_DATA}`),this.moveInputBefore(`DATA`,`SUCCESS`)),this.getInput(`DIR`)||(this.appendValueInput(`DIR`).setCheck(`SelectDir`).setAlign(u.Align.RIGHT).appendField(`%{BKY_RESOURCE_DIR}`),this.moveInputBefore(`DIR`,`DATA`)),this.getInput(`NAME`)||(this.appendValueInput(`NAME`).setCheck(`String`).setAlign(u.Align.RIGHT).appendField(`%{BKY_RESOURCE_NAME}`),this.moveInputBefore(`NAME`,`DIR`))},updateShadow_:function(){if(this.isInsertionMarker())return;let e=dn(``);this.getInput(`NAME`)?.setShadowDom(e)},ensureBlocks_:function(){this.isInsertionMarker()||V(this,[[`SUCCESS`,`__success__`,`x-runtime-lib.success`,!0],[`MESSAGE`,`__message__`,`x-runtime-lib.message`,!0],[`RESULT`,`__result__`,`x-runtime-lib.result`,!0]])}},g.forBlock.upload_resource_v1=function(e){return`{
352
+ var res = __uploadResourceV1__(${g.valueToCode(e,`NAME`,_.ATOMIC)||`''`}, ${g.valueToCode(e,`DIR`,_.ATOMIC)||`null`}, ${g.valueToCode(e,`DATA`,_.ATOMIC)||`null`});
353
353
  var __success__ = res.success;
354
354
  var __message__ = res.message;
355
355
  var __result__ = res.result;
356
- ${x.statementToCode(e,`HANDLE`)}
356
+ ${g.statementToCode(e,`HANDLE`)}
357
357
  }
358
- `},h([{type:`text_v1`,message0:`%{BKY_TEXT_V1_TEXT_TITLE}`,args0:[{type:`field_input`,name:`TEXT`,text:``}],output:`String`,style:`text_blocks`,tooltip:`%{BKY_TEXT_V1_TEXT_TOOLTIP}`,helpUrl:`%{BKY_TEXT_V1_TEXT_HELPURL}`,extensions:[`parent_tooltip_when_inline`]}]),x.forBlock.text_v1=function(e){return[x.quote_(e.getFieldValue(`TEXT`)),_.ATOMIC]};const ci=/^\s*'([^']|\\')*'\s*$/;function li(e){return ci.test(e)?[e,_.ATOMIC]:[`String(${e})`,_.FUNCTION_CALL]}r.register(`text_append_tooltip_v1`,r.buildTooltipWithFieldText(`%{BKY_TEXT_V1_APPEND_TOOLTIP}`,`VAR`)),h([{type:`text_append_v1`,message0:`%{BKY_TEXT_V1_APPEND_TITLE}`,args0:[{type:`field_variable`,name:`VAR`},{type:`input_value`,name:`TEXT`}],previousStatement:null,nextStatement:null,style:`text_blocks`,helpUrl:`%{BKY_TEXT_V1_APPEND_HELPURL}`,extensions:[`text_append_tooltip_v1`]}]),x.forBlock.text_append_v1=function(e){return`${x.nameDB_?.getName(e.getFieldValue(`VAR`),v.NameType.VARIABLE)} += ${li(x.valueToCode(e,`TEXT`,_.NONE)||`''`)};\n`},h([{type:`text_change_case_v1`,message0:`%{BKY_TEXT_V1_CHANGE_CASE_TITLE}`,args0:[{type:`input_value`,name:`TEXT`,check:`String`},{type:`field_dropdown`,name:`CASE`,options:[[`%{BKY_TEXT_CHANGE_CASE_OPERATOR_UPPER_CASE}`,`UPPERCASE`],[`%{BKY_TEXT_CHANGE_CASE_OPERATOR_LOWER_CASE}`,`LOWERCASE`],[`%{BKY_TEXT_CHANGE_CASE_OPERATOR_TITLE_CASE}`,`TITLECASE`]]}],output:`String`,style:`text_blocks`,tooltip:`%{BKY_TEXT_V1_CHANGE_CASE_TOOLTIP}`,helpUrl:`%{BKY_TEXT_V1_CHANGE_CASE_HELPURL}`}]),x.forBlock.text_change_case_v1=function(e){let t={UPPERCASE:`.toUpperCase()`,LOWERCASE:`.toLowerCase()`,TITLECASE:null}[e.getFieldValue(`CASE`)],n=x.valueToCode(e,`TEXT`,t?_.MEMBER:_.NONE)||`''`,r;return r=t?n+t:x.provideFunction_(`textToTitleCase`,`
359
- function ${x.FUNCTION_NAME_PLACEHOLDER_}(str) {
358
+ `},t([{type:`text_v1`,message0:`%{BKY_TEXT_V1_TEXT_TITLE}`,args0:[{type:`field_input`,name:`TEXT`,text:``}],output:`String`,style:`text_blocks`,tooltip:`%{BKY_TEXT_V1_TEXT_TOOLTIP}`,helpUrl:`%{BKY_TEXT_V1_TEXT_HELPURL}`,extensions:[`parent_tooltip_when_inline`]}]),g.forBlock.text_v1=function(e){return[g.quote_(e.getFieldValue(`TEXT`)),_.ATOMIC]};const ci=/^\s*'([^']|\\')*'\s*$/;function li(e){return ci.test(e)?[e,_.ATOMIC]:[`String(${e})`,_.FUNCTION_CALL]}m.register(`text_append_tooltip_v1`,m.buildTooltipWithFieldText(`%{BKY_TEXT_V1_APPEND_TOOLTIP}`,`VAR`)),t([{type:`text_append_v1`,message0:`%{BKY_TEXT_V1_APPEND_TITLE}`,args0:[{type:`field_variable`,name:`VAR`},{type:`input_value`,name:`TEXT`}],previousStatement:null,nextStatement:null,style:`text_blocks`,helpUrl:`%{BKY_TEXT_V1_APPEND_HELPURL}`,extensions:[`text_append_tooltip_v1`]}]),g.forBlock.text_append_v1=function(t){return`${g.nameDB_?.getName(t.getFieldValue(`VAR`),e.NameType.VARIABLE)} += ${li(g.valueToCode(t,`TEXT`,_.NONE)||`''`)};\n`},t([{type:`text_change_case_v1`,message0:`%{BKY_TEXT_V1_CHANGE_CASE_TITLE}`,args0:[{type:`input_value`,name:`TEXT`,check:`String`},{type:`field_dropdown`,name:`CASE`,options:[[`%{BKY_TEXT_CHANGE_CASE_OPERATOR_UPPER_CASE}`,`UPPERCASE`],[`%{BKY_TEXT_CHANGE_CASE_OPERATOR_LOWER_CASE}`,`LOWERCASE`],[`%{BKY_TEXT_CHANGE_CASE_OPERATOR_TITLE_CASE}`,`TITLECASE`]]}],output:`String`,style:`text_blocks`,tooltip:`%{BKY_TEXT_V1_CHANGE_CASE_TOOLTIP}`,helpUrl:`%{BKY_TEXT_V1_CHANGE_CASE_HELPURL}`}]),g.forBlock.text_change_case_v1=function(e){let t={UPPERCASE:`.toUpperCase()`,LOWERCASE:`.toLowerCase()`,TITLECASE:null}[e.getFieldValue(`CASE`)],n=g.valueToCode(e,`TEXT`,t?_.MEMBER:_.NONE)||`''`,r;return r=t?n+t:g.provideFunction_(`textToTitleCase`,`
359
+ function ${g.FUNCTION_NAME_PLACEHOLDER_}(str) {
360
360
  return str.slice(0, 1).toUpperCase() + str.slice(1).toLowerCase();
361
361
  }
362
- `)+`(`+n+`)`,[r,_.FUNCTION_CALL]},h([{type:`text_char_at_v1`,message0:`%{BKY_TEXT_V1_CHAR_AT_TITLE}`,args0:[{type:`input_value`,name:`VALUE`,check:`String`},{type:`input_value`,name:`AT`,check:`Number`}],inputsInline:!0,output:`String`,style:`text_blocks`,tooltip:`%{BKY_TEXT_V1_CHAR_AT_TOOLTIP}`,helpUrl:`%{BKY_TEXT_V1_CHAR_AT_HELPURL}`}]),x.forBlock.text_char_at_v1=function(e){return[`${x.valueToCode(e,`VALUE`,_.MEMBER)||`[]`}.charAt(${x.getAdjusted(e,`AT`)})`,_.FUNCTION_CALL]},h([{type:`text_count_v1`,message0:`%{BKY_TEXT_V1_COUNT_TITLE}`,args0:[{type:`input_value`,name:`TEXT`,check:`String`},{type:`input_value`,name:`SUBSTR`,check:`String`}],output:`Number`,inputsInline:!0,style:`text_blocks`,tooltip:`%{BKY_TEXT_V1_COUNT_TOOLTIP}`,helpUrl:`%{BKY_TEXT_V1_COUNT_HELPURL}`}]),x.forBlock.text_count_v1=function(e){let t=x.valueToCode(e,`TEXT`,_.NONE)||`''`,n=x.valueToCode(e,`SUBSTR`,_.NONE)||`''`;return[`${x.provideFunction_(`textCount`,`
363
- function ${x.FUNCTION_NAME_PLACEHOLDER_}(haystack, needle) {
362
+ `)+`(`+n+`)`,[r,_.FUNCTION_CALL]},t([{type:`text_char_at_v1`,message0:`%{BKY_TEXT_V1_CHAR_AT_TITLE}`,args0:[{type:`input_value`,name:`VALUE`,check:`String`},{type:`input_value`,name:`AT`,check:`Number`}],inputsInline:!0,output:`String`,style:`text_blocks`,tooltip:`%{BKY_TEXT_V1_CHAR_AT_TOOLTIP}`,helpUrl:`%{BKY_TEXT_V1_CHAR_AT_HELPURL}`}]),g.forBlock.text_char_at_v1=function(e){return[`${g.valueToCode(e,`VALUE`,_.MEMBER)||`[]`}.charAt(${g.getAdjusted(e,`AT`)})`,_.FUNCTION_CALL]},t([{type:`text_count_v1`,message0:`%{BKY_TEXT_V1_COUNT_TITLE}`,args0:[{type:`input_value`,name:`TEXT`,check:`String`},{type:`input_value`,name:`SUBSTR`,check:`String`}],output:`Number`,inputsInline:!0,style:`text_blocks`,tooltip:`%{BKY_TEXT_V1_COUNT_TOOLTIP}`,helpUrl:`%{BKY_TEXT_V1_COUNT_HELPURL}`}]),g.forBlock.text_count_v1=function(e){let t=g.valueToCode(e,`TEXT`,_.NONE)||`''`,n=g.valueToCode(e,`SUBSTR`,_.NONE)||`''`;return[`${g.provideFunction_(`textCount`,`
363
+ function ${g.FUNCTION_NAME_PLACEHOLDER_}(haystack, needle) {
364
364
  if (needle.length > 0) {
365
365
  return haystack.split(needle).length - 1;
366
366
  } else {
367
367
  return 0;
368
368
  }
369
369
  }
370
- `)}(${t}, ${n})`,_.FUNCTION_CALL]},h([{type:`text_index_of_v1`,message0:`%{BKY_TEXT_V1_INDEX_OF_TITLE}`,args0:[{type:`input_value`,name:`TEXT`,check:`String`},{type:`field_dropdown`,name:`OP`,options:[[`%{BKY_TEXT_INDEX_OF_OPERATOR_FIRST}`,`FIRST`],[`%{BKY_TEXT_INDEX_OF_OPERATOR_LAST}`,`LAST`]]},{type:`input_value`,name:`SUBSTR`,check:`String`}],inputsInline:!0,output:`Number`,style:`text_blocks`,tooltip:`%{BKY_TEXT_V1_INDEX_OF_TOOLTIP}`,helpUrl:`%{BKY_TEXT_V1_INDEX_OF_HELPURL}`}]),x.forBlock.text_index_of_v1=function(e){let t=e.getFieldValue(`OP`)===`FIRST`?`indexOf`:`lastIndexOf`;return[`${x.valueToCode(e,`TEXT`,_.MEMBER)||`''`}.${t}(${x.valueToCode(e,`SUBSTR`,_.NONE)||`''`})`,_.FUNCTION_CALL]},h([{type:`text_is_empty_v1`,message0:`%{BKY_TEXT_V1_IS_EMPTY_TITLE}`,args0:[{type:`input_value`,name:`VALUE`,check:`String`}],output:`Boolean`,style:`text_blocks`,tooltip:`%{BKY_TEXT_V1_IS_EMPTY_TOOLTIP}`,helpUrl:`%{BKY_TEXT_V1_IS_EMPTY_HELPURL}`}]),x.forBlock.text_is_empty_v1=function(e){return[`!${x.valueToCode(e,`VALUE`,_.MEMBER)||`''`}.length`,_.LOGICAL_NOT]};const ui=e.xml;r.registerMutator(`text_join_mutator_v1`,{itemCount_:0,mutationToDom:function(){let e=ui.createElement(`mutation`);return e.setAttribute(`items`,`${this.itemCount_}`),e},domToMutation:function(e){this.itemCount_=parseInt(e.getAttribute(`items`),0),this.updateShape_()},saveExtraState:function(){return{itemCount:this.itemCount_}},loadExtraState:function(e){this.itemCount_=e.itemCount,this.updateShape_()},decompose:function(e){let t=e.newBlock(`text_join_container_v1`);t.initSvg();let n=t.getInput(`STACK`).connection;for(let t=0;t<this.itemCount_;t++){let t=e.newBlock(`text_join_item_v1`);t.initSvg(),n.connect(t.previousConnection),n=t.nextConnection}return t},compose:function(e){let t=e.getInputTargetBlock(`STACK`),n=[];for(;t;){if(t.isInsertionMarker()){t=t.getNextBlock();continue}n.push(t.valueConnection_),t=t.getNextBlock()}for(let e=0;e<this.itemCount_;e++){let t=this.getInput(`ADD`+e).connection.targetConnection;t&&n.indexOf(t)===-1&&t.disconnect()}this.itemCount_=n.length,this.updateShape_();for(let e=0;e<this.itemCount_;e++)n[e]?.reconnect(this,`ADD`+e)},saveConnections:function(e){let t=e.getInputTargetBlock(`STACK`),n=0;for(;t;){if(t.isInsertionMarker()){t=t.getNextBlock();continue}let e=this.getInput(`ADD`+n);t.valueConnection_=e&&e.connection.targetConnection,t=t.getNextBlock(),n++}},updateShape_:function(){this.itemCount_&&this.getInput(`EMPTY`)?this.removeInput(`EMPTY`):!this.itemCount_&&!this.getInput(`EMPTY`)&&this.appendDummyInput(`EMPTY`).appendField(`"`).appendField(`"`);for(let e=0;e<this.itemCount_;e++)if(!this.getInput(`ADD`+e)){let t=this.appendValueInput(`ADD`+e).setAlign(b.Align.RIGHT);e===0&&t.appendField(`%{BKY_TEXT_V1_JOIN_TITLE}`)}for(let e=this.itemCount_;this.getInput(`ADD`+e);e++)this.removeInput(`ADD`+e)}},function(){this.itemCount_=2,this.updateShape_(),this.setMutator(new s.MutatorIcon([`text_join_item_v1`],this))}),h([{type:`text_join_v1`,message0:``,output:`String`,style:`text_blocks`,helpUrl:`%{BKY_TEXT_V1_JOIN_HELPURL}`,tooltip:`%{BKY_TEXT_V1_JOIN_TOOLTIP}`,mutator:`text_join_mutator_v1`},{type:`text_join_container_v1`,message0:`%{BKY_TEXT_V1_JOIN_TITLE} %1 %2`,args0:[{type:`input_dummy`},{type:`input_statement`,name:`STACK`}],style:`text_blocks`,enableContextMenu:!1},{type:`text_join_item_v1`,message0:`%{BKY_TEXT_V1_JOIN_ITEM_TITLE}`,previousStatement:null,nextStatement:null,style:`text_blocks`,enableContextMenu:!1}]),x.forBlock.text_join_v1=function(e){let t=e;switch(t.itemCount_){case 0:return[`''`,_.ATOMIC];case 1:return li(x.valueToCode(t,`ADD0`,_.NONE)||`''`);case 2:{let e=x.valueToCode(t,`ADD0`,_.NONE)||`''`,n=x.valueToCode(t,`ADD1`,_.NONE)||`''`;return[li(e)[0]+` + `+li(n)[0],_.ADDITION]}default:{let e=Array(t.itemCount_);for(let n=0;n<t.itemCount_;n++)e[n]=x.valueToCode(t,`ADD`+n,_.NONE)||`''`;return[`[`+e.join(`,`)+`].join('')`,_.FUNCTION_CALL]}}},h([{type:`text_length_v1`,message0:`%{BKY_TEXT_V1_LENGTH_TITLE}`,args0:[{type:`input_value`,name:`VALUE`,check:`String`}],output:`Number`,style:`text_blocks`,tooltip:`%{BKY_TEXT_V1_LENGTH_TOOLTIP}`,helpUrl:`%{BKY_TEXT_V1_LENGTH_HELPURL}`}]),x.forBlock.text_length_v1=function(e){return[`${x.valueToCode(e,`VALUE`,_.MEMBER)||`''`}.length`,_.MEMBER]},h([{type:`text_replace_v1`,message0:`%{BKY_TEXT_V1_REPLACE_TITLE}`,args0:[{type:`input_value`,name:`TEXT`,check:`String`},{type:`input_value`,name:`FROM`,check:`String`},{type:`input_value`,name:`TO`,check:`String`}],inputsInline:!0,output:`String`,style:`text_blocks`,tooltip:`%{BKY_TEXT_V1_REPLACE_TOOLTIP}`,helpUrl:`%{BKY_TEXT_V1_REPLACE_HELPURL}`}]),x.forBlock.text_replace_v1=function(e){let t=x.valueToCode(e,`TEXT`,_.NONE)||`''`,n=x.valueToCode(e,`FROM`,_.NONE)||`''`,r=x.valueToCode(e,`TO`,_.NONE)||`''`;return[`${x.provideFunction_(`textReplace`,`
371
- function ${x.FUNCTION_NAME_PLACEHOLDER_}(haystack, needle, replacement) {
370
+ `)}(${t}, ${n})`,_.FUNCTION_CALL]},t([{type:`text_index_of_v1`,message0:`%{BKY_TEXT_V1_INDEX_OF_TITLE}`,args0:[{type:`input_value`,name:`TEXT`,check:`String`},{type:`field_dropdown`,name:`OP`,options:[[`%{BKY_TEXT_INDEX_OF_OPERATOR_FIRST}`,`FIRST`],[`%{BKY_TEXT_INDEX_OF_OPERATOR_LAST}`,`LAST`]]},{type:`input_value`,name:`SUBSTR`,check:`String`}],inputsInline:!0,output:`Number`,style:`text_blocks`,tooltip:`%{BKY_TEXT_V1_INDEX_OF_TOOLTIP}`,helpUrl:`%{BKY_TEXT_V1_INDEX_OF_HELPURL}`}]),g.forBlock.text_index_of_v1=function(e){let t=e.getFieldValue(`OP`)===`FIRST`?`indexOf`:`lastIndexOf`;return[`${g.valueToCode(e,`TEXT`,_.MEMBER)||`''`}.${t}(${g.valueToCode(e,`SUBSTR`,_.NONE)||`''`})`,_.FUNCTION_CALL]},t([{type:`text_is_empty_v1`,message0:`%{BKY_TEXT_V1_IS_EMPTY_TITLE}`,args0:[{type:`input_value`,name:`VALUE`,check:`String`}],output:`Boolean`,style:`text_blocks`,tooltip:`%{BKY_TEXT_V1_IS_EMPTY_TOOLTIP}`,helpUrl:`%{BKY_TEXT_V1_IS_EMPTY_HELPURL}`}]),g.forBlock.text_is_empty_v1=function(e){return[`!${g.valueToCode(e,`VALUE`,_.MEMBER)||`''`}.length`,_.LOGICAL_NOT]};const ui=p.xml;m.registerMutator(`text_join_mutator_v1`,{itemCount_:0,mutationToDom:function(){let e=ui.createElement(`mutation`);return e.setAttribute(`items`,`${this.itemCount_}`),e},domToMutation:function(e){this.itemCount_=parseInt(e.getAttribute(`items`),0),this.updateShape_()},saveExtraState:function(){return{itemCount:this.itemCount_}},loadExtraState:function(e){this.itemCount_=e.itemCount,this.updateShape_()},decompose:function(e){let t=e.newBlock(`text_join_container_v1`);t.initSvg();let n=t.getInput(`STACK`).connection;for(let t=0;t<this.itemCount_;t++){let t=e.newBlock(`text_join_item_v1`);t.initSvg(),n.connect(t.previousConnection),n=t.nextConnection}return t},compose:function(e){let t=e.getInputTargetBlock(`STACK`),n=[];for(;t;){if(t.isInsertionMarker()){t=t.getNextBlock();continue}n.push(t.valueConnection_),t=t.getNextBlock()}for(let e=0;e<this.itemCount_;e++){let t=this.getInput(`ADD`+e).connection.targetConnection;t&&n.indexOf(t)===-1&&t.disconnect()}this.itemCount_=n.length,this.updateShape_();for(let e=0;e<this.itemCount_;e++)n[e]?.reconnect(this,`ADD`+e)},saveConnections:function(e){let t=e.getInputTargetBlock(`STACK`),n=0;for(;t;){if(t.isInsertionMarker()){t=t.getNextBlock();continue}let e=this.getInput(`ADD`+n);t.valueConnection_=e&&e.connection.targetConnection,t=t.getNextBlock(),n++}},updateShape_:function(){this.itemCount_&&this.getInput(`EMPTY`)?this.removeInput(`EMPTY`):!this.itemCount_&&!this.getInput(`EMPTY`)&&this.appendDummyInput(`EMPTY`).appendField(`"`).appendField(`"`);for(let e=0;e<this.itemCount_;e++)if(!this.getInput(`ADD`+e)){let t=this.appendValueInput(`ADD`+e).setAlign(u.Align.RIGHT);e===0&&t.appendField(`%{BKY_TEXT_V1_JOIN_TITLE}`)}for(let e=this.itemCount_;this.getInput(`ADD`+e);e++)this.removeInput(`ADD`+e)}},function(){this.itemCount_=2,this.updateShape_(),this.setMutator(new oe.MutatorIcon([`text_join_item_v1`],this))}),t([{type:`text_join_v1`,message0:``,output:`String`,style:`text_blocks`,helpUrl:`%{BKY_TEXT_V1_JOIN_HELPURL}`,tooltip:`%{BKY_TEXT_V1_JOIN_TOOLTIP}`,mutator:`text_join_mutator_v1`},{type:`text_join_container_v1`,message0:`%{BKY_TEXT_V1_JOIN_TITLE} %1 %2`,args0:[{type:`input_dummy`},{type:`input_statement`,name:`STACK`}],style:`text_blocks`,enableContextMenu:!1},{type:`text_join_item_v1`,message0:`%{BKY_TEXT_V1_JOIN_ITEM_TITLE}`,previousStatement:null,nextStatement:null,style:`text_blocks`,enableContextMenu:!1}]),g.forBlock.text_join_v1=function(e){let t=e;switch(t.itemCount_){case 0:return[`''`,_.ATOMIC];case 1:return li(g.valueToCode(t,`ADD0`,_.NONE)||`''`);case 2:{let e=g.valueToCode(t,`ADD0`,_.NONE)||`''`,n=g.valueToCode(t,`ADD1`,_.NONE)||`''`;return[li(e)[0]+` + `+li(n)[0],_.ADDITION]}default:{let e=Array(t.itemCount_);for(let n=0;n<t.itemCount_;n++)e[n]=g.valueToCode(t,`ADD`+n,_.NONE)||`''`;return[`[`+e.join(`,`)+`].join('')`,_.FUNCTION_CALL]}}},t([{type:`text_length_v1`,message0:`%{BKY_TEXT_V1_LENGTH_TITLE}`,args0:[{type:`input_value`,name:`VALUE`,check:`String`}],output:`Number`,style:`text_blocks`,tooltip:`%{BKY_TEXT_V1_LENGTH_TOOLTIP}`,helpUrl:`%{BKY_TEXT_V1_LENGTH_HELPURL}`}]),g.forBlock.text_length_v1=function(e){return[`${g.valueToCode(e,`VALUE`,_.MEMBER)||`''`}.length`,_.MEMBER]},t([{type:`text_replace_v1`,message0:`%{BKY_TEXT_V1_REPLACE_TITLE}`,args0:[{type:`input_value`,name:`TEXT`,check:`String`},{type:`input_value`,name:`FROM`,check:`String`},{type:`input_value`,name:`TO`,check:`String`}],inputsInline:!0,output:`String`,style:`text_blocks`,tooltip:`%{BKY_TEXT_V1_REPLACE_TOOLTIP}`,helpUrl:`%{BKY_TEXT_V1_REPLACE_HELPURL}`}]),g.forBlock.text_replace_v1=function(e){let t=g.valueToCode(e,`TEXT`,_.NONE)||`''`,n=g.valueToCode(e,`FROM`,_.NONE)||`''`,r=g.valueToCode(e,`TO`,_.NONE)||`''`;return[`${g.provideFunction_(`textReplace`,`
371
+ function ${g.FUNCTION_NAME_PLACEHOLDER_}(haystack, needle, replacement) {
372
372
  needle = needle.replace(/([-()\\[\\]{}+?*.$\\^|,:#<!\\\\])/g, '\\\\$1')
373
373
  .replace(/\\x08/g, '\\\\x08');
374
374
  return haystack.replace(new RegExp(needle, 'g'), replacement);
375
375
  }
376
- `)}(${t}, ${n}, ${r})`,_.FUNCTION_CALL]},h([{type:`text_reverse_v1`,message0:`%{BKY_TEXT_V1_REVERSE_TITLE}`,args0:[{type:`input_value`,name:`TEXT`,check:`String`}],inputsInline:!0,output:`String`,style:`text_blocks`,tooltip:`%{BKY_TEXT_V1_REVERSE_TOOLTIP}`,helpUrl:`%{BKY_TEXT_V1_REVERSE_HELPURL}`}]),x.forBlock.text_reverse_v1=function(e){return[(x.valueToCode(e,`TEXT`,_.MEMBER)||`''`)+`.split('').reverse().join('')`,_.FUNCTION_CALL]},h([{type:`text_split_v1`,message0:`%{BKY_TEXT_V1_SPLIT_TITLE}`,args0:[{type:`input_value`,name:`TEXT`,check:`String`},{type:`input_value`,name:`DELIM`,check:`String`}],inputsInline:!0,output:`Array`,style:`text_blocks`,tooltip:`%{BKY_TEXT_V1_SPLIT_TOOLTIP}`,helpUrl:`%{BKY_TEXT_V1_SPLIT_HELPURL}`}]),x.forBlock.text_split_v1=function(e){return[`${x.valueToCode(e,`TEXT`,_.MEMBER)||`''`}.split(${x.valueToCode(e,`DELIM`,_.NONE)||`''`})`,_.FUNCTION_CALL]},h([{type:`text_substring_v1`,message0:`%{BKY_TEXT_V1_SUBSTRING_TITLE}`,args0:[{type:`input_value`,name:`TEXT`,check:`String`},{type:`input_value`,name:`START`,check:`Number`},{type:`input_value`,name:`END`,check:`Number`}],inputsInline:!0,output:`String`,style:`text_blocks`,tooltip:`%{BKY_TEXT_V1_SUBSTRING_TOOLTIP}`,helpUrl:`%{BKY_TEXT_V1_SUBSTRING_HELPURL}`}]),x.forBlock.text_substring_v1=function(e){return[`${x.valueToCode(e,`TEXT`,_.MEMBER)||`''`}.slice(${x.getAdjusted(e,`START`)}, ${x.getAdjusted(e,`END`,1)})`,_.FUNCTION_CALL]},h([{type:`text_trim_v1`,message0:`%{BKY_TEXT_V1_TRIM_TITLE}`,args0:[{type:`field_dropdown`,name:`MODE`,options:[[`%{BKY_TEXT_TRIM_OPERATOR_BOTH}`,`BOTH`],[`%{BKY_TEXT_TRIM_OPERATOR_LEFT}`,`LEFT`],[`%{BKY_TEXT_TRIM_OPERATOR_RIGHT}`,`RIGHT`]]},{type:`input_value`,name:`TEXT`,check:`String`}],output:`String`,style:`text_blocks`,tooltip:`%{BKY_TEXT_V1_TRIM_TOOLTIP}`,helpUrl:`%{BKY_TEXT_V1_TRIM_HELPURL}`}]),x.forBlock.text_trim_v1=function(e){return[`__trimV1__(${x.valueToCode(e,`TEXT`,_.NONE)||`''`}, ${{BOTH:0,LEFT:1,RIGHT:2}[e.getFieldValue(`MODE`)]})`,_.ATOMIC]},S.create_timer_v1={init:function(){this.appendDummyInput().appendField(`%{BKY_TIME_V1_CREATE_TIMER_TITLE}`),this.setPreviousStatement(!0,null),this.setNextStatement(!0,null),this.setStyle(`time_blocks`),this.setTooltip(`%{BKY_TIME_V1_CREATE_TIMER_TOOLTIP}`),this.setHelpUrl(`%{BKY_TIME_V1_CREATE_TIMER_HELPURL}`)},saveExtraState:function(){return{}},loadExtraState:function(){this.updateShape_(),this.updateShadow_()},updateShape_:function(){this.getInput(`CALLBACK`)||this.appendStatementInput(`CALLBACK`).appendField(`%{BKY_TIME_DO}`),this.getInput(`IMMEDIATE`)||(this.appendValueInput(`IMMEDIATE`).setCheck(`Boolean`).setAlign(b.Align.RIGHT).appendField(`%{BKY_TIME_IMMEDIATE}`),this.moveInputBefore(`IMMEDIATE`,`CALLBACK`)),this.getInput(`COUNT`)||(this.appendValueInput(`COUNT`).setCheck(`Number`).setAlign(b.Align.RIGHT).appendField(`%{BKY_TIME_COUNT}`),this.moveInputBefore(`COUNT`,`IMMEDIATE`)),this.getInput(`LOOP`)||(this.appendValueInput(`LOOP`).setCheck(`Boolean`).setAlign(b.Align.RIGHT).appendField(`%{BKY_TIME_LOOP}`),this.moveInputBefore(`LOOP`,`COUNT`)),this.getInput(`INTERVAL`)||(this.appendValueInput(`INTERVAL`).setCheck(`Number`).setAlign(b.Align.RIGHT).appendField(`%{BKY_TIME_INTERVAL_MS}`),this.moveInputBefore(`INTERVAL`,`LOOP`))},updateShadow_:function(){if(this.isInsertionMarker())return;let e=fn(1e3);this.getInput(`INTERVAL`)?.setShadowDom(e);let t=pn(!1);this.getInput(`LOOP`)?.setShadowDom(t);let n=fn(1);this.getInput(`COUNT`)?.setShadowDom(n);let r=pn(!1);this.getInput(`IMMEDIATE`)?.setShadowDom(r)}},x.forBlock.create_timer_v1=function(e){return`__createTimerV1__(${x.valueToCode(e,`INTERVAL`,_.ATOMIC)||`1000`}, ${x.valueToCode(e,`LOOP`,_.ATOMIC)||`false`}, ${x.valueToCode(e,`COUNT`,_.ATOMIC)||`1`}, ${x.valueToCode(e,`IMMEDIATE`,_.ATOMIC)||`false`}, async function() {
377
- ${x.statementToCode(e,`CALLBACK`)}});\n`},h([{type:`delay_v1`,message0:`%{BKY_TIME_V1_DELAY_TITLE}`,args0:[{type:`input_value`,name:`DURATION`,check:`Number`}],previousStatement:null,nextStatement:null,style:`time_blocks`,tooltip:`%{BKY_TIME_V1_DELAY_TOOLTIP}`,helpUrl:`%{BKY_TIME_V1_DELAY_HELPURL}`}]),x.forBlock.delay_v1=function(e){return`await __delayV1__(${x.valueToCode(e,`DURATION`,_.ATOMIC)||`0`});\n`};const di={customContextMenu:function(e){if(!this.isInFlyout){let t,n;this.type===`variable_get_v1`?(t=`variable_set_v1`,n=F(`VARIABLE_GET_CREATE_SET`)):this.type===`variable_set_v1`?(t=`variable_get_v1`,n=F(`VARIABLE_SET_CREATE_GET`)):console.assert(!1);let r=this.getField(`VAR`),i={type:t,fields:{VAR:r.saveState(!0)}};e.push({enabled:this.workspace.remainingCapacity()>0,text:n.replace(`%1`,r.getText()),callback:de.callbackFactory(this,i)})}else if(this.type===`variable_get_v1`){let t={text:F(`RENAME_VARIABLE`),enabled:!0,callback:fi(this)},n=this.getField(`VAR`).getText(),r={text:F(`DELETE_VARIABLE`).replace(`%1`,n),enabled:!0,callback:pi(this)};e.unshift(t),e.unshift(r)}}},fi=function(e){return function(){let t=e.workspace,n=e.getField(`VAR`).getVariable();d.renameVariable(t,n)}},pi=function(e){return function(){let t=e.getField(`VAR`).getVariable();t&&d.deleteVariable(t.getWorkspace(),t,e)}};r.registerMixin(`context_menu_variable_v1`,di),h([{type:`variable_get_v1`,message0:`%1`,args0:[{type:`field_variable`,name:`VAR`}],output:null,style:`variable_blocks`,tooltip:`%{BKY_VARIABLE_V1_GET_TOOLTIP}`,helpUrl:`%{BKY_VARIABLE_V1_GET_HELPURL}`,extensions:[`context_menu_variable_v1`]}]),x.forBlock.variable_get_v1=function(e){return[x.nameDB_.getName(e.getFieldValue(`VAR`),v.NameType.VARIABLE),_.ATOMIC]},h([{type:`variable_set_v1`,message0:`%{BKY_VARIABLE_V1_SET_TITLE}`,args0:[{type:`field_variable`,name:`VAR`,variable:``},{type:`input_value`,name:`VALUE`}],previousStatement:null,nextStatement:null,style:`variable_blocks`,tooltip:`%{BKY_VARIABLE_V1_SET_TOOLTIP}`,helpUrl:`%{BKY_VARIABLE_V1_SET_HELPURL}`,extensions:[`context_menu_variable_v1`]}]),x.forBlock.variable_set_v1=function(e){return`${x.nameDB_.getName(e.getFieldValue(`VAR`),v.NameType.VARIABLE)} = ${x.valueToCode(e,`VALUE`,_.ASSIGNMENT)||`0`};\n`},c.setConfirm(async(e,t)=>{t(!!await Me({title:``,text:e}))}),c.setPrompt(async(e,t,n)=>{let r=await Ne({title:``,value:t});r!==void 0&&n(String(r))});const mi=m.prototype;mi.doClassValidation_=function(e){return e};const hi=mi.doValueUpdate_;mi.doValueUpdate_=function(e){hi.call(this,e),this.selectedOption&&this.selectedOption[1]!==e&&(this.selectedOption=null)};const gi=mi.getText_;mi.getText_=function(){if(this.selectedOption)return gi.call(this);let{i18n:e}=Ae,t=this.getSourceBlock();if(this.name===`APP`)return t.app.name;if(this.name===`PAGE`)return t.page.name;if(this.name===`ELEMENT`)return t.element.name;if(this.name===`NODE`){let n=T(t.node.key);if(n)return`${e.global.t(n.name)} / ${t.node.alias}`}else if(this.name===`PROPERTY`){let{kind:e,names:n}=t.property;return nt(e,n)}else if(this.name===`EVENT`){let{kind:e,names:n}=t.event;return et(e,n)}else if(this.name===`METHOD`){let{kind:e,names:n}=t.method;return tt(e,n)}else if(this.name===`SPACE`)return t.space.name;else if(this.name===`FUNC`)return t.func.name;else if(this.name===`OUTPUT`)return t.output.name;else if(this.name===`TABLE`)return t.table.name;else if(this.name===`COLUMN`)return t.column.name;else if(this.name===`DIR`)return t.dir.name;else if(this.name===`RESOURCE`)return t.resource.name;return`<n/a>`},ae.prototype.cleanUp=function(){this.setResizesEnabled(!1);let e=p.getGroup();e||p.setGroup(!0);let t=this.getTopBlocks(!0),n=t.filter(e=>e.isMovable()),r=t.filter(e=>!e.isMovable()).map(e=>e.getBoundingRectangle()),i=function(e){for(let t of r)if(e.intersects(t))return t;return null},a=0;for(let e of n){let t=e.getBoundingRectangle();e.moveBy(-t.left,a-t.top,[`cleanup`]),e.snapToGrid(),t=e.getBoundingRectangle();let n=i(t);for(;n!=null;)a=n.top+n.getHeight()+60,e.moveBy(0,a-t.top,[`cleanup`]),e.snapToGrid(),t=e.getBoundingRectangle(),n=i(t);a=e.getRelativeToSurfaceXY().y+e.getHeightWidth().height+60}p.setGroup(e),this.setResizesEnabled(!0)};var _i=fe();function vi(e){let t=e.getParent();return t&&vi(t)?!0:!t&&!!(e.outputConnection||e.previousConnection)}var yi=class{init(){let e=De.registry.getItem(`blockDisable`);e&&(e.preconditionFn=function(e){let t=e.block;return t&&!t.isInFlyout&&t.workspace.options.disable&&t.isEditable()?t.getInheritedDisabled()||vi(t)?`disabled`:`enabled`:`hidden`})}};(0,En.registerFieldColour)(),re.registry.unregister(te.names.ESCAPE),new _i.CrossTabCopyPaste().init({contextMenu:!0,shortcut:!0}),new yi().init();function bi(e){"@babel/helpers - typeof";return bi=typeof Symbol==`function`&&typeof Symbol.iterator==`symbol`?function(e){return typeof e}:function(e){return e&&typeof Symbol==`function`&&e.constructor===Symbol&&e!==Symbol.prototype?`symbol`:typeof e},bi(e)}function xi(e,t){if(bi(e)!=`object`||!e)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var r=n.call(e,t||`default`);if(bi(r)!=`object`)return r;throw TypeError(`@@toPrimitive must return a primitive value.`)}return(t===`string`?String:Number)(e)}function Si(e){var t=xi(e,`string`);return bi(t)==`symbol`?t:t+``}function Ci(e,t,n){return(t=Si(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}var wi=class extends p.Abstract{constructor(e){super(),Ci(this,`isBlank`,!0),Ci(this,`recordUndo`,!1),Ci(this,`type`,`state_change`),this.workspaceId=e.id}};u.register(u.Type.EVENT,`state_change`,wi);function Ti(e){let t=oe();if(!t)return;let n=t.getBlockById(e);if(!n)return;let r=n.getRootBlock();if(!r)return;let i=r.getRelativeToSurfaceXY(),a=i.x*t.scale,o=i.y*t.scale;t.scroll(-a,-o)}function Ei(){let e=oe();if(!e)return;let t=e.getTopBlocks(!0)?.[0];t&&Ti(t.id)}l.Classic.blockStyles={color_blocks:{colourPrimary:`#a5745b`,colourSecondary:`#ede3de`,colourTertiary:`#845d49`,hat:``},event_blocks:{colourPrimary:`#a5a55b`,colourSecondary:`#ededde`,colourTertiary:`#848449`,hat:``},list_blocks:{colourPrimary:`#745ba5`,colourSecondary:`#e3deed`,colourTertiary:`#5d4984`,hat:``},logic_blocks:{colourPrimary:`#5b80a5`,colourSecondary:`#dee6ed`,colourTertiary:`#496684`,hat:``},loop_blocks:{colourPrimary:`#5ba55b`,colourSecondary:`#deedde`,colourTertiary:`#498449`,hat:``},math_blocks:{colourPrimary:`#5b67a5`,colourSecondary:`#dee1ed`,colourTertiary:`#495284`,hat:``},method_blocks:{colourPrimary:`#995ba5`,colourSecondary:`#ebdeed`,colourTertiary:`#7a4984`,hat:``},object_blocks:{colourPrimary:`#80a55b`,colourSecondary:`#e6edde`,colourTertiary:`#668449`,hat:``},procedure_blocks:{colourPrimary:`#995ba5`,colourSecondary:`#ebdeed`,colourTertiary:`#7a4984`,hat:``},property_blocks:{colourPrimary:`#5ba5a5`,colourSecondary:`#deeded`,colourTertiary:`#498484`,hat:``},state_blocks:{colourPrimary:`#a55b67`,colourSecondary:`#eddee1`,colourTertiary:`#844952`,hat:``},text_blocks:{colourPrimary:`#5ba58c`,colourSecondary:`#deede8`,colourTertiary:`#498470`,hat:``},time_blocks:{colourPrimary:`#5b99a5`,colourSecondary:`#deebed`,colourTertiary:`#497a84`,hat:``},variable_blocks:{colourPrimary:`#a55b80`,colourSecondary:`#eddee6`,colourTertiary:`#844966`,hat:``}},l.Classic.categoryStyles={color_category:{colour:`#a5745b`},common_category:{colour:`#757575`},compute_category:{colour:`#757575`},data_category:{colour:`#757575`},event_category:{colour:`#a5a55b`},flow_category:{colour:`#757575`},func_category:{colour:`#757575`},list_category:{colour:`#745ba5`},logic_category:{colour:`#5b80a5`},loop_category:{colour:`#5ba55b`},math_category:{colour:`#5b67a5`},method_category:{colour:`#995ba5`},misc_category:{colour:`#757575`},object_category:{colour:`#80a55b`},procedure_category:{colour:`#995ba5`},property_category:{colour:`#5ba5a5`},resource_category:{colour:`#757575`},state_category:{colour:`#a55b67`},text_category:{colour:`#5ba58c`},time_category:{colour:`#5b99a5`},variable_category:{colour:`#a55b80`}};const Di=o.defineTheme(`light`,{name:`light`,base:l.Classic,componentStyles:{workspaceBackgroundColour:`#ffffff`,toolboxBackgroundColour:`#eeeeee`,toolboxForegroundColour:``,flyoutBackgroundColour:`#eeeeee`,flyoutForegroundColour:`#000000`,flyoutOpacity:.8,scrollbarColour:``,insertionMarkerColour:``,insertionMarkerOpacity:.3,scrollbarOpacity:.4,cursorColour:``}}),Oi=o.defineTheme(`dark`,{name:`dark`,base:l.Classic,componentStyles:{workspaceBackgroundColour:`#1e1e1e`,toolboxBackgroundColour:`#272727`,toolboxForegroundColour:``,flyoutBackgroundColour:`#272727`,flyoutForegroundColour:`#ffffff`,flyoutOpacity:.8,scrollbarColour:``,insertionMarkerColour:``,insertionMarkerOpacity:.3,scrollbarOpacity:.4,cursorColour:``}});function ki(e){let t=oe();switch(e){case`light`:t.setTheme(Di);break;case`dark`:t.setTheme(Oi);break}}function Ai(e,t){e.find(e=>e===t)||e.push(t)}const ji=[`get_app_property_v1`,`get_app_state_v1`];function Mi(e){let t=[];function n(e){for(let r of e.getChildren(!0))ji.includes(r.type)&&t.push(r),n(r)}return n(e),t}function Ni(e){let t=[];for(let n of e)n.type===`get_app_property_v1`?Ai(t,Xe(`propertyTrigger`,n.property.id)):n.type===`get_app_state_v1`?Ai(t,Xe(`stateTrigger`,n.state.id)):console.assert(!1);return t}function Pi(e){let t=[];for(let n of e){if(n.type!==`app_bind_entry_v1`)continue;let e=n;e.kind===`property`?Ai(t,Xe(`propertyTrigger`,e.property.id)):e.kind===`state`&&Ai(t,Xe(`stateTrigger`,e.state.id))}return t}function Fi(e){let t={watchEffect:{ids:[],triggers:{}},bind:{sets:{},triggers:{}}},n=e.getTopBlocks(!0);if(!n)return t;for(let e of n)if(e.type===`watch_effect_v1`){let n=Ni(Mi(e));for(let r of n)t.watchEffect.triggers[r]||(t.watchEffect.triggers[r]=[]),Ai(t.watchEffect.triggers[r],e.id);t.watchEffect.ids.push(e.id)}else if(e.type===`app_bind_v1`){let n=Pi(e.getChildren(!0));t.bind.sets[e.id]=n;for(let r of n)t.bind.triggers[r]||(t.bind.triggers[r]=[]),Ai(t.bind.triggers[r],e.id)}return t}const Ii=Symbol();function Li(e){Tt(Ii,e)}function Ri(){return _t(Ii)}var zi=gt({__name:`index`,props:{lock:{type:Boolean,required:!0}},setup(e,{expose:t}){let{t:n}=zt(),r=Bt(),i=Ri(),a=D(()=>r.smAndDown.value),o=()=>{if(!i.workspace){console.assert(!1);return}if(e.lock){je(n(`x-block-lib.msg.cannotOperateInLockedState`));return}i.workspace.cleanUp()},s=()=>{o()};return t({cleanWorkspace:o}),(e,t)=>{let r=N(`v-btn`),i=N(`v-tooltip`);return M(),mt(i,{disabled:a.value,text:P(n)(`x-block-lib.tip.hotkeyCtrlQ`)},{activator:Ft(({props:e})=>[A(r,bt(e,{density:`comfortable`,icon:`mdi-broom`,variant:`outlined`,onClick:s}),null,16)]),_:1},8,[`disabled`,`text`])}}});function Bi(e,t){let n=t.newBlock(`json_root_v1`);n.initSvg(),n.render();let r=(e,n)=>{if(e===null)return;let i;if(e instanceof Array)i=`json_array_v1`;else{let t=typeof e;if(t===`object`)i=`json_map_v1`;else if(t===`string`)i=`json_string_v1`;else if(t===`number`)i=`json_number_v1`;else if(t===`boolean`)i=`json_boolean_v1`;else return}let a=t.newBlock(i);if(a.initSvg(),a.render(),n.connect(a.outputConnection),i===`json_map_v1`){let t=[];for(let n in e)t.push(n);a.initData(t);for(let n=0;n<t.length;n++){let i=t[n],o=a.getInput(`ENTRY`+n);r(e[i],o.connection)}}else if(i===`json_array_v1`){a.initData(e.length);for(let t=0;t<e.length;t++)r(e[t],a.getInput(`ENTRY`+t).connection)}else i===`json_string_v1`||i===`json_number_v1`?a.setFieldValue(e,`VALUE`):i===`json_boolean_v1`&&a.setFieldValue(e?`true`:`false`,`VALUE`)};r(e,n.getInput(`JSON`).connection),p.fire(new(p.get(p.FINISHED_LOADING))(t))}function Vi(e){let t=e=>{if(!e)return null;if(e.type===`json_root_v1`)return t(e.getInputTargetBlock(`JSON`));if(e.type===`json_map_v1`){let n={};for(let r=0;r<e.length;r++){let i=e.getFieldValue(`KEY`+r);n[i]=t(e.getInputTargetBlock(`ENTRY`+r))}return n}else if(e.type===`json_array_v1`){let n=[];for(let r=0;r<e.length;r++)n.push(t(e.getInputTargetBlock(`ENTRY`+r)));return n}else if(e.type===`json_string_v1`)return e.getFieldValue(`VALUE`);else if(e.type===`json_number_v1`)return e.getFieldValue(`VALUE`);else if(e.type===`json_boolean_v1`)return e.getFieldValue(`VALUE`)===`true`;else console.assert(!1)},n=e.getTopBlocks();for(let e of n)if(e.type===`json_root_v1`)return t(e)}var Hi=gt({__name:`index`,props:{modelValue:{type:Boolean,required:!0},modelModifiers:{}},emits:[`update:modelValue`],setup(e){let{t}=zt(),n=Bt(),r=Mt(e,`modelValue`),i=D(()=>n.smAndDown.value);return(e,n)=>{let a=N(`v-btn`),o=N(`v-tooltip`);return M(),mt(o,{disabled:i.value,text:P(t)(`x-block-lib.tip.hotkeyCtrlW`)},{activator:Ft(({props:e})=>[A(a,bt(e,{density:`comfortable`,icon:r.value?`mdi-lock`:`mdi-lock-open`,variant:`outlined`,onClick:n[0]||(n[0]=e=>r.value=!r.value)}),null,16,[`icon`])]),_:1},8,[`disabled`,`text`])}}});const Ui={class:`d-flex flex-column`},Wi={class:`text-body-large ml-6`},Gi={key:0,class:`text-body-small text-grey text-truncate ml-6`,style:{maxWidth:`340px`}};var Ki=gt({__name:`item`,props:{id:{type:String,required:!0},title:{type:String,required:!0},desc:{type:String,required:!0},select:{type:Boolean,required:!0}},emits:[`x-click`],setup(e,{emit:t}){let{primaryColor:n,backgroundColor2:r,highlightColor:i}=Pe(),a=t,o=Et(!1),s=D(()=>{let t={position:`relative`,background:o.value?i.value:r.value,boxSizing:`border-box`,width:`100%`,height:`48px`,marginTop:`1px`,userSelect:`none`};return e.select?(t.borderTop=`1px solid `+n.value,t.borderBottom=`1px solid `+n.value):(t.borderTop=void 0,t.borderBottom=void 0),t});return(t,n)=>{let r=N(`v-spacer`),i=N(`v-icon`),c=kt(`ripple`);return It((M(),O(`div`,{class:`d-flex align-center cursor-pointer`,style:j(s.value),onClick:n[1]||(n[1]=t=>a(`x-click`,e.id)),onMouseout:n[2]||(n[2]=e=>o.value=!1),onMouseover:n[3]||(n[3]=e=>o.value=!0)},[k(`div`,Ui,[k(`span`,Wi,At(e.title),1),e.desc?(M(),O(`span`,Gi,At(e.desc),1)):ht(`v-if`,!0)]),A(r),A(i,{class:`x-handle cursor-move mr-3`,icon:`mdi-drag-horizontal-variant`,onMousedown:n[0]||(n[0]=Rt(()=>{},[`stop`]))})],36)),[[c]])}}});const qi={key:1,class:`text-body-small text-grey`};var Ji=((e,t)=>{let n=e.__vccOpts||e;for(let[e,r]of t)n[e]=r;return n})(gt({__name:`index`,props:yt({lock:{type:Boolean,required:!0}},{modelValue:{type:Boolean,required:!0},modelModifiers:{}}),emits:[`update:modelValue`],setup(t,{expose:r}){let{t:i}=zt(),a=Mt(t,`modelValue`),o=Ri(),s=Et([]);r({update:()=>{if(!o.workspace){console.assert(!1);return}let e=[];o.workspace.getTopBlocks(!0).forEach(t=>{let n=t.id===se()?.id,r=``;if(t.type.startsWith(`on_app_event_v`)){let e=t,n=T(e.node.key);n&&(r=i(n.name),e.node.alias&&(r+=` / `+e.node.alias),r+=` - `+et(e.event.kind,e.event.names))}else if(t.type.startsWith(`watch_effect_v`))r=i(`x-block-lib.watchEffect`);else if(t.type.startsWith(`app_bind_v`))r=i(`x-block-lib.bind`);else if(t.type.startsWith(`implement_app_method_v`)){let e=t;r=i(`x-block-lib.implementMethod`),r+=` - `+tt(e.method.kind,e.method.names)}else r=t.type.startsWith(`func_entry_v`)?i(`x-block-lib.funcEntry`):t.type.startsWith(`procedure_def_v`)?i(`x-block-lib.procedure`)+` - `+t.getFieldValue(`NAME`):i(`x-block-lib.temporaryBlock`);let a=t.getCommentText()??``;e.push({id:t.id,name:r,desc:a,select:n})}),s.value=e}});let c=[],l=()=>{if(t.lock){je(i(`x-block-lib.msg.cannotOperateInLockedState`));return}let e=[];s.value.forEach(({id:t})=>{e.push(t)}),c=e},u=()=>!t.lock,ee=t=>{if(!o.workspace){console.assert(!1);return}if(t.oldIndex===void 0||t.newIndex===void 0){console.assert(!1);return}if(t.oldIndex===t.newIndex)return;let n=c[t.oldIndex],r=o.workspace.getBlockById(n);if(!r){console.assert(!1);return}let i=``;t.newIndex>t.oldIndex?i=c[t.newIndex]:t.newIndex>0&&(i=c[t.newIndex-1]);let a=-10;i!==``&&(a=o.workspace.getBlockById(i).getRelativeToSurfaceXY().y+10);let s=r.getRelativeToSurfaceXY();r.moveTo(new e.Coordinate(s.x,a)),o.workspace.cleanUp(),Ei()},d=async e=>{if(!o.workspace){console.assert(!1);return}let t=o.workspace.getBlockById(e);n.setSelected(t),Ti(e),a.value=!1};return(e,t)=>s.value.length>0?(M(),mt(P(xe),{key:0,modelValue:s.value,"onUpdate:modelValue":t[0]||(t[0]=e=>s.value=e),animation:150,"ghost-class":`ghost`,handle:`.x-handle`,onEnd:ee,onMove:u,onStart:l},{default:Ft(()=>[(M(!0),O(pt,null,Dt(s.value,e=>(M(),mt(Ki,{id:e.id,key:e.id,desc:e.desc,select:e.select,title:e.name,onXClick:d},null,8,[`id`,`desc`,`select`,`title`]))),128))]),_:1},8,[`modelValue`])):(M(),O(`span`,qi,At(P(i)(`x-block-lib.noOption`)),1))}}),[[`__scopeId`,`data-v-x-block-lib-ca7316a0`]]),Yi=gt({__name:`index`,props:{modelValue:{type:Boolean,required:!0},modelModifiers:{}},emits:[`update:modelValue`],setup(e,{expose:t}){let r=Mt(e,`modelValue`),i=Ri();t({update:()=>{if(!i.workspace){console.assert(!1);return}}});let a=e=>{let t=oe();if(!t){console.assert(!1);return}let i=t.getBlockById(e);n.setSelected(i),Ti(e),r.value=!1};return(e,t)=>(M(),O(`div`,{onClick:t[0]||(t[0]=e=>a(``))},`blockTree`))}});const Xi={class:`text-body-large`};var Zi=gt({__name:`index`,props:{type:{type:String,required:!0},lock:{type:Boolean,required:!0}},setup(e,{expose:t}){let{t:n}=zt(),r=Bt(),{sysBarAvail:i}=Fe(),{backgroundColor1:a}=Pe(),o=D(()=>r.smAndDown.value),s=D(()=>{let e=`100%`;return r.mdAndUp.value&&(e=`400px`),{background:a.value,width:e,height:`100%`}}),c=D(()=>{let e=48;return i.value&&(e+=24),{position:`relative`,height:`calc(100% - ${e}px)`}}),l=D(()=>({height:`60px`})),{open:u}=Ie(`blocklyNavigatorDlg${jt()}`);wt(()=>{u.value=!1});let ee=Nt(`blockList`),d=Nt(`blockTree`);return t({open:u,update:()=>{e.type===`list`?ee.value?.update():e.type===`tree`&&d.value?.update()}}),(t,r)=>{let a=N(`v-sheet`),f=N(`v-btn`),te=N(`v-spacer`),ne=N(`v-dialog`),re=N(`v-tooltip`);return M(),O(pt,null,[A(ne,{modelValue:P(u),"onUpdate:modelValue":r[5]||(r[5]=e=>vt(u)?u.value=e:null),eager:``,fullscreen:``,"no-click-animation":``,persistent:``,transition:`scroll-x-reverse-transition`,onKeydown:r[6]||(r[6]=Lt(Rt(e=>u.value=!1,[`stop`,`prevent`]),[`esc`]))},{default:Ft(()=>[k(`div`,{class:`w-100 h-100 d-flex flex-row-reverse`,onClick:r[3]||(r[3]=Rt(e=>u.value=!1,[`self`])),onContextmenu:r[4]||(r[4]=Rt(e=>u.value=!1,[`self`,`prevent`]))},[k(`div`,{class:`elevation-2`,style:j(s.value)},[P(i)?(M(),mt(a,{key:0,color:`transparent`,height:24})):ht(`v-if`,!0),A(a,{class:`d-flex align-center px-2`,color:`transparent`,height:48},{default:Ft(()=>[A(f,{density:`comfortable`,icon:`mdi-close`,variant:`text`,onClick:r[0]||(r[0]=e=>u.value=!1)}),k(`span`,Xi,At(P(n)(`x-block-lib.navigator`)),1),A(te)]),_:1}),k(`div`,{class:`overflow-y-auto`,style:j(c.value)},[e.type===`list`?(M(),mt(Ji,{key:0,ref_key:`blockList`,ref:ee,modelValue:P(u),"onUpdate:modelValue":r[1]||(r[1]=e=>vt(u)?u.value=e:null),lock:e.lock},null,8,[`modelValue`,`lock`])):e.type===`tree`?(M(),mt(Yi,{key:1,ref_key:`blockTree`,ref:d,modelValue:P(u),"onUpdate:modelValue":r[2]||(r[2]=e=>vt(u)?u.value=e:null)},null,8,[`modelValue`])):ht(`v-if`,!0),k(`div`,{style:j(l.value)},null,4)],4)],4)],32)]),_:1},8,[`modelValue`]),A(re,{disabled:o.value,text:P(n)(`x-block-lib.tip.hotkeyCtrlE`)},{activator:Ft(({props:e})=>[A(f,bt(e,{density:`comfortable`,icon:`mdi-navigation-variant`,variant:`outlined`,onClick:r[7]||(r[7]=e=>u.value=!0)}),null,16)]),_:1},8,[`disabled`,`text`])],64)}}}),Qi=ue();const Z=e.xml;function Q(e){let t=Z.createElement(`label`);return t.setAttribute(`text`,e),t}function $(e,t){let n=Z.createElement(`block`);if(n.setAttribute(`type`,e),t)for(let e of t)n.appendChild(e);return n}function $i(e){let t=Z.createElement(`mutation`);for(let{key:n,value:r}of e)t.setAttribute(n,r);return t}function ea(e,t){t===void 0&&(t=``);let n=Z.createElement(`value`);n.setAttribute(`name`,e);let r=Z.createElement(`shadow`);r.setAttribute(`type`,`text_v1`);let i=Z.createElement(`field`);i.setAttribute(`name`,`TEXT`);let a=Z.createTextNode(t);return i.appendChild(a),r.appendChild(i),n.appendChild(r),n}function ta(e,t){t===void 0&&(t=0);let n=Z.createElement(`value`);n.setAttribute(`name`,e);let r=Z.createElement(`shadow`);r.setAttribute(`type`,`math_number_v1`);let i=Z.createElement(`field`);i.setAttribute(`name`,`NUM`);let a=Z.createTextNode(String(t));return i.appendChild(a),r.appendChild(i),n.appendChild(r),n}function na(e,t){t===void 0&&(t=!1);let n=Z.createElement(`value`);n.setAttribute(`name`,e);let r=Z.createElement(`shadow`);r.setAttribute(`type`,`logic_boolean_v1`);let i=Z.createElement(`field`);i.setAttribute(`name`,`BOOL`);let a=Z.createTextNode(t?`TRUE`:`FALSE`);return i.appendChild(a),r.appendChild(i),n.appendChild(r),n}function ra(){let{activeObject:e,activeComp:t}=C.app;return!(e.type!==`comp`||!t.meta.states||t.meta.states.length<=0)}function ia(){let e=[];return e.push(Q(F(`LABEL_EVENT`))),U(`onEvent`)&&e.push($(`on_app_event_v1`)),U(`triggerEvent`)&&e.push($(`trigger_app_event_v1`)),e.push($(`app_bind_v1`,[$i([{key:`items`,value:`2`}])])),e.push($(`watch_effect_v1`)),(U(`getProperty`)||U(`setProperty`))&&e.push(Q(F(`LABEL_PROPERTY`))),U(`getProperty`)&&e.push($(`get_app_property_v1`)),U(`setProperty`)&&e.push($(`set_app_property_v1`)),ra()&&(e.push(Q(F(`LABEL_STATE`))),e.push($(`get_app_state_v1`)),e.push($(`set_app_state_v1`))),(U(`callMethod`)||U(`implementMethod`))&&e.push(Q(F(`LABEL_METHOD`))),U(`callMethod`)&&e.push($(`call_app_method_v1`)),U(`implementMethod`)&&(e.push($(`implement_app_method_v1`)),U(`implementMethodOutput`)&&e.push($(`set_app_method_output_v1`)),e.push($(`procedure_return_v1`))),e}const aa={name:`APP_COMP_CATEGORY`,callback:ia};function oa(){let e=[];return e.push(Q(F(`LABEL_FUNC`))),e.push(Q(F(`LABEL_FLOW`))),e}const sa={name:`APP_COMPUTE_CATEGORY`,callback:oa};function ca(){let e=[];return e.push($(`app_debug_trace_v1`,[ea(`OBJECT`)])),e.push($(`popup_message_v1`,[ea(`TEXT`)])),e.push($(`open_confirm_dlg_v1`)),e.push($(`open_prompt_dlg_v1`)),e}const la={name:`APP_MESSAGE_CATEGORY`,callback:ca};function ua(){for(let e of C.app.appList)if(e.pages.length>0)return!0;return!1}function da(){let e=[];return e.push($(`app_env_is_v1`)),ua()&&e.push($(`navigate_to_v1`)),e}const fa={name:`APP_MISC_CATEGORY`,callback:da};function pa(){let{activeObject:e,activePage:t}=C.app;return!(e.type!==`page`||!t.meta.states||t.meta.states.length<=0)}function ma(){let{activeObject:e,activePage:t}=C.app;return!(e.type!==`page`||!t.meta.arguments||t.meta.arguments.length<=0)}function ha(){let e=[];return e.push(Q(F(`LABEL_EVENT`))),U(`onEvent`)&&e.push($(`on_app_event_v1`)),e.push($(`app_bind_v1`,[$i([{key:`items`,value:`2`}])])),e.push($(`watch_effect_v1`)),(U(`getProperty`)||U(`setProperty`))&&e.push(Q(F(`LABEL_PROPERTY`))),U(`getProperty`)&&e.push($(`get_app_property_v1`)),U(`setProperty`)&&e.push($(`set_app_property_v1`)),pa()&&(e.push(Q(F(`LABEL_STATE`))),e.push($(`get_app_state_v1`)),e.push($(`set_app_state_v1`))),U(`callMethod`)&&(e.push(Q(F(`LABEL_METHOD`))),e.push($(`call_app_method_v1`))),ma()&&(e.push(Q(F(`LABEL_ARGUMENT`))),e.push($(`get_page_argument_v1`))),e}const ga={name:`APP_PAGE_CATEGORY`,callback:ha};function _a(){let e=[];return e.push(Q(F(`LABEL_RESOURCE`))),e.push($(`upload_resource_v1`)),e}const va={name:`APP_RESOURCE_CATEGORY`,callback:_a},ya=e.xml;function ba(){let e=[];{let t=ya.createElement(`label`);t.setAttribute(`text`,`%{BKY_LABEL_PROCEDURE}`),e.push(t)}{let t=ya.createElement(`block`);t.setAttribute(`type`,`procedure_def_v1`);{let e=ya.createElement(`field`);e.setAttribute(`name`,`NAME`);let n=ya.createTextNode(F(`PROCEDURE_DEFAULT_NAME`));e.appendChild(n),t.appendChild(e)}e.push(t)}{let t=ya.createElement(`block`);t.setAttribute(`type`,`procedure_return_v1`),e.push(t)}return e}const xa={name:`PROCEDURE_CATEGORY`,callback:ba},Sa=e.xml;function Ca(){let e=oe(),t=[];{let e=Sa.createElement(`label`);e.setAttribute(`text`,`%{BKY_LABEL_VARIABLE}`),t.push(e)}{let n=document.createElement(`button`);n.setAttribute(`text`,`%{BKY_NEW_VARIABLE}`),n.setAttribute(`callbackKey`,`CREATE_VARIABLE`),e.registerButtonCallback(`CREATE_VARIABLE`,function(e){d.createVariableButtonHandler(e.getTargetWorkspace())}),t.push(n)}let n=e.getVariablesOfType(``);if(n.length<=0)return t;n.sort(d.compareByName);{let e=Sa.createElement(`label`);e.setAttribute(`text`,F(`LABEL_CREATED`)),t.push(e)}return n.forEach(e=>{{let n=Sa.createElement(`block`);n.setAttribute(`type`,`variable_get_v1`),n.appendChild(d.generateVariableFieldDom(e)),t.push(n)}{let n=Sa.createElement(`block`);n.setAttribute(`type`,`variable_set_v1`),n.appendChild(d.generateVariableFieldDom(e)),t.push(n)}}),t}const wa={name:`VARIABLE_CATEGORY`,callback:Ca};function Ta(){let e=[];if(Y().length>0)e.push(Q(F(`LABEL_OPERATION`))),e.push($(`add_data_v1`)),e.push($(`delete_data_v1`)),e.push($(`update_data_v1`)),e.push($(`query_data_v1`)),e.push($(`transaction_v1`)),e.push($(`interrupt_transaction_v1`,[ea(`VALUE`)])),e.push(Q(F(`LABEL_CONDITION`))),e.push($(`cond_logic_v1`)),e.push($(`cond_atomic_v1`,[ea(`VALUE`)])),e.push(Q(F(`LABEL_QUERY_EXTRA`))),e.push($(`query_extra_limit_v1`,[ta(`OFFSET`,0),ta(`LIMIT`,1)])),e.push($(`query_extra_sortby_v1`,[ea(`COLUMN`),na(`DESC`)]));else{let t=document.createElement(`button`);t.setAttribute(`text`,F(`BUTTON_NO_TABLE`)),t.setAttribute(`callbackKey`,`NO_TABLE`),e.push(t)}return e}const Ea={name:`COMPUTE_DATA_CATEGORY`,callback:Ta};function Da(){return Er(`flow`).length>0}function Oa(){let e=[];return C.compute.activeObject.type===`flow`&&e.push($(`on_flow_state_event_v1`)),Da()&&console.assert(!0),e}const ka={name:`COMPUTE_FLOW_CATEGORY`,callback:Oa};function Aa(){return Er(`func`).length>0}function ja(){let{activeObject:e,activeFunc:t}=C.compute,n=[];return e.type===`func`&&(n.push($(`func_entry_v1`)),t.outputs&&t.outputs.length>0&&n.push($(`set_func_output_v1`)),n.push($(`procedure_return_v1`))),Aa()&&n.push($(`call_func_internal_v1`)),n}const Ma={name:`COMPUTE_FUNC_CATEGORY`,callback:ja};function Na(){let e=[];return e.push($(`compute_debug_trace_v1`,[ea(`OBJECT`)])),e}const Pa={name:`COMPUTE_MISC_CATEGORY`,callback:Na},Fa={kind:`category`,name:`%{BKY_CATEGORY_COLOR}`,categorystyle:`color_category`,contents:[{kind:`block`,type:`color_picker_v1`},{kind:`block`,type:`color_random_v1`},{kind:`block`,type:`color_rgb_v1`,inputs:{RED:{shadow:{type:`math_number_v1`,fields:{NUM:0}}},GREEN:{shadow:{type:`math_number_v1`,fields:{NUM:0}}},BLUE:{shadow:{type:`math_number_v1`,fields:{NUM:0}}}}},{kind:`block`,type:`color_blend_v1`,inputs:{COLOR1:{shadow:{type:`color_picker_v1`,fields:{COLOR:`#ff0000`}}},COLOR2:{shadow:{type:`color_picker_v1`,fields:{COLOR:`#00ff00`}}},RATIO:{shadow:{type:`math_number_v1`,fields:{NUM:.5}}}}}]},Ia={kind:`category`,name:`%{BKY_CATEGORY_LIST}`,categorystyle:`list_category`,contents:[{kind:`label`,text:`%{BKY_LABEL_LIST}`},{kind:`block`,type:`list_create_v1`,extraState:{itemCount:0}},{kind:`label`,text:`%{BKY_LABEL_GET}`},{kind:`block`,type:`list_is_empty_v1`},{kind:`block`,type:`list_length_v1`},{kind:`block`,type:`list_get_v1`,inputs:{AT:{shadow:{type:`math_number_v1`,fields:{NUM:1}}}}},{kind:`block`,type:`list_get_sublist_v1`,inputs:{START:{shadow:{type:`math_number_v1`,fields:{NUM:1}}},END:{shadow:{type:`math_number_v1`,fields:{NUM:1}}}}},{kind:`label`,text:`%{BKY_LABEL_SET}`},{kind:`block`,type:`list_set_v1`,inputs:{AT:{shadow:{type:`math_number_v1`,fields:{NUM:1}}}}},{kind:`block`,type:`list_delete_v1`,inputs:{AT:{shadow:{type:`math_number_v1`,fields:{NUM:1}}}}},{kind:`block`,type:`list_join_v1`,inputs:{DELIM:{shadow:{type:`text_v1`,fields:{TEXT:``}}}}},{kind:`block`,type:`list_reverse_v1`}]},La={kind:`category`,name:`%{BKY_CATEGORY_LOGIC}`,categorystyle:`logic_category`,contents:[{kind:`label`,text:`%{BKY_LABEL_BOOLEAN}`},{kind:`block`,type:`logic_boolean_v1`},{kind:`label`,text:`%{BKY_LABEL_BRANCH}`},{kind:`block`,type:`logic_if_v1`},{kind:`label`,text:`%{BKY_LABEL_LOGIC_OPERATION}`},{kind:`block`,type:`logic_compare_v1`},{kind:`block`,type:`logic_operation_v1`},{kind:`block`,type:`logic_negate_v1`},{kind:`block`,type:`logic_ternary_v1`}]},Ra={kind:`category`,name:`%{BKY_CATEGORY_LOOP}`,categorystyle:`loop_category`,contents:[{kind:`block`,type:`repeat_v1`,inputs:{TIMES:{shadow:{type:`math_number_v1`,fields:{NUM:10}}}}},{kind:`block`,type:`while_until_v1`},{kind:`block`,type:`for_v1`,inputs:{FROM:{shadow:{type:`math_number_v1`,fields:{NUM:1}}},TO:{shadow:{type:`math_number_v1`,fields:{NUM:10}}},BY:{shadow:{type:`math_number_v1`,fields:{NUM:1}}}}},{kind:`block`,type:`for_each_v1`},{kind:`block`,type:`flow_control_v1`}]},za={kind:`category`,name:`%{BKY_CATEGORY_MATH}`,categorystyle:`math_category`,contents:[{kind:`label`,text:`%{BKY_LABEL_VALUE}`},{kind:`block`,type:`math_number_v1`,fields:{NUM:0}},{kind:`block`,type:`math_constant_v1`},{kind:`block`,type:`math_random_float_v1`},{kind:`block`,type:`math_random_int_v1`,inputs:{FROM:{shadow:{type:`math_number_v1`,fields:{NUM:1}}},TO:{shadow:{type:`math_number_v1`,fields:{NUM:100}}}}},{kind:`label`,text:`%{BKY_LABEL_MATH_OPERATION}`},{kind:`block`,type:`math_arithmetic_v1`,inputs:{A:{shadow:{type:`math_number_v1`,fields:{NUM:1}}},B:{shadow:{type:`math_number_v1`,fields:{NUM:1}}}}},{kind:`block`,type:`math_round_v1`,inputs:{NUM:{shadow:{type:`math_number_v1`,fields:{NUM:3.1}}}}},{kind:`block`,type:`math_single_v1`,inputs:{NUM:{shadow:{type:`math_number_v1`,fields:{NUM:9}}}}},{kind:`block`,type:`math_trig_v1`,inputs:{NUM:{shadow:{type:`math_number_v1`,fields:{NUM:45}}}}},{kind:`block`,type:`math_modulo_v1`,inputs:{DIVIDEND:{shadow:{type:`math_number_v1`,fields:{NUM:64}}},DIVISOR:{shadow:{type:`math_number_v1`,fields:{NUM:10}}}}},{kind:`block`,type:`math_number_property_v1`,inputs:{NUM:{shadow:{type:`math_number_v1`,fields:{NUM:2}}}}},{kind:`block`,type:`math_on_list_v1`}]},Ba={kind:`category`,name:`%{BKY_CATEGORY_OBJECT}`,categorystyle:`object_category`,contents:[{kind:`label`,text:`%{BKY_LABEL_OBJECT}`},{kind:`block`,type:`object_create_v1`},{kind:`block`,type:`object_from_json_v1`},{kind:`block`,type:`object_to_json_v1`},{kind:`label`,text:`%{BKY_LABEL_PROPERTY}`},{kind:`block`,type:`object_get_v1`,inputs:{KEY:{shadow:{type:`text_v1`,fields:{TEXT:``}}}}},{kind:`block`,type:`object_set_v1`,inputs:{KEY:{shadow:{type:`text_v1`,fields:{TEXT:``}}}}},{kind:`block`,type:`object_delete_v1`,inputs:{KEY:{shadow:{type:`text_v1`,fields:{TEXT:``}}}}}]},Va={kind:`category`,name:`%{BKY_CATEGORY_TEXT}`,categorystyle:`text_category`,contents:[{kind:`label`,text:`%{BKY_LABEL_TEXT}`},{kind:`block`,type:`text_v1`},{kind:`block`,type:`text_join_v1`,extraState:{itemCount:2}},{kind:`label`,text:`%{BKY_LABEL_GET}`},{kind:`block`,type:`text_is_empty_v1`},{kind:`block`,type:`text_length_v1`},{kind:`block`,type:`text_char_at_v1`,inputs:{AT:{shadow:{type:`math_number_v1`,fields:{NUM:1}}}}},{kind:`block`,type:`text_substring_v1`,inputs:{START:{shadow:{type:`math_number_v1`,fields:{NUM:1}}},END:{shadow:{type:`math_number_v1`,fields:{NUM:1}}}}},{kind:`block`,type:`text_index_of_v1`,inputs:{SUBSTR:{shadow:{type:`text_v1`,fields:{TEXT:``}}}}},{kind:`block`,type:`text_count_v1`,inputs:{SUBSTR:{shadow:{type:`text_v1`,fields:{TEXT:``}}}}},{kind:`label`,text:`%{BKY_LABEL_SET}`},{kind:`block`,type:`text_append_v1`,inputs:{TEXT:{shadow:{type:`text_v1`,fields:{TEXT:``}}}}},{kind:`block`,type:`text_replace_v1`,inputs:{FROM:{shadow:{type:`text_v1`,fields:{TEXT:``}}},TO:{shadow:{type:`text_v1`,fields:{TEXT:``}}}}},{kind:`block`,type:`text_split_v1`,inputs:{DELIM:{shadow:{type:`text_v1`,fields:{TEXT:``}}}}},{kind:`block`,type:`text_change_case_v1`},{kind:`block`,type:`text_trim_v1`},{kind:`block`,type:`text_reverse_v1`}]},Ha={kind:`category`,name:`%{BKY_CATEGORY_TIME}`,categorystyle:`time_category`,contents:[{kind:`block`,type:`create_timer_v1`},{kind:`block`,type:`delay_v1`,inputs:{DURATION:{shadow:{type:`math_number_v1`,fields:{NUM:1e3}}}}}]},Ua={kind:`categoryToolbox`,contents:[{kind:`category`,name:`%{BKY_CATEGORY_COMP}`,categorystyle:`misc_category`,custom:aa.name},{kind:`category`,name:`%{BKY_CATEGORY_MESSAGE}`,categorystyle:`misc_category`,custom:la.name},{kind:`category`,name:`%{BKY_CATEGORY_MISC}`,categorystyle:`misc_category`,custom:fa.name},Ra,La,za,Va,Ia,Ba,Fa,Ha,{kind:`category`,name:`%{BKY_CATEGORY_VARIABLE}`,categorystyle:`variable_category`,custom:wa.name},{kind:`category`,name:`%{BKY_CATEGORY_PROCEDURE}`,categorystyle:`procedure_category`,custom:xa.name},{kind:`category`,name:`%{BKY_CATEGORY_RESOURCE}`,categorystyle:`resource_category`,custom:va.name},{kind:`category`,name:`%{BKY_CATEGORY_COMPUTE}`,categorystyle:`compute_category`,custom:sa.name}]},Wa={kind:`categoryToolbox`,contents:[{kind:`category`,name:`%{BKY_CATEGORY_FUNC}`,categorystyle:`func_category`,custom:Ma.name},{kind:`category`,name:`%{BKY_CATEGORY_FLOW}`,categorystyle:`flow_category`,custom:ka.name},{kind:`category`,name:`%{BKY_CATEGORY_DATA}`,categorystyle:`data_category`,custom:Ea.name},{kind:`category`,name:`%{BKY_CATEGORY_MISC}`,categorystyle:`misc_category`,custom:Pa.name},Ra,La,za,Va,Ia,Ba,Fa,{kind:`category`,name:`%{BKY_CATEGORY_VARIABLE}`,categorystyle:`variable_category`,custom:wa.name},{kind:`category`,name:`%{BKY_CATEGORY_PROCEDURE}`,categorystyle:`procedure_category`,custom:xa.name}]},Ga={kind:`categoryToolbox`,contents:[{kind:`category`,name:`%{BKY_CATEGORY_FUNC}`,categorystyle:`func_category`,custom:Ma.name},{kind:`category`,name:`%{BKY_CATEGORY_FLOW}`,categorystyle:`flow_category`,custom:ka.name},{kind:`category`,name:`%{BKY_CATEGORY_DATA}`,categorystyle:`data_category`,custom:Ea.name},{kind:`category`,name:`%{BKY_CATEGORY_MISC}`,categorystyle:`misc_category`,custom:Pa.name},Ra,La,za,Va,Ia,Ba,Fa,{kind:`category`,name:`%{BKY_CATEGORY_VARIABLE}`,categorystyle:`variable_category`,custom:wa.name},{kind:`category`,name:`%{BKY_CATEGORY_PROCEDURE}`,categorystyle:`procedure_category`,custom:xa.name}]},Ka={kind:`categoryToolbox`,contents:[{kind:`category`,name:`%{BKY_CATEGORY_JSON}`,colour:`330`,contents:[{kind:`block`,type:`json_map_v1`},{kind:`block`,type:`json_array_v1`},{kind:`block`,type:`json_string_v1`},{kind:`block`,type:`json_number_v1`},{kind:`block`,type:`json_boolean_v1`}]}]},qa={kind:`categoryToolbox`,contents:[{kind:`category`,name:`%{BKY_CATEGORY_PAGE}`,categorystyle:`misc_category`,custom:ga.name},{kind:`category`,name:`%{BKY_CATEGORY_MESSAGE}`,categorystyle:`misc_category`,custom:la.name},{kind:`category`,name:`%{BKY_CATEGORY_MISC}`,categorystyle:`misc_category`,custom:fa.name},Ra,La,za,Va,Ia,Ba,Fa,Ha,{kind:`category`,name:`%{BKY_CATEGORY_VARIABLE}`,categorystyle:`variable_category`,custom:wa.name},{kind:`category`,name:`%{BKY_CATEGORY_PROCEDURE}`,categorystyle:`procedure_category`,custom:xa.name},{kind:`category`,name:`%{BKY_CATEGORY_RESOURCE}`,categorystyle:`resource_category`,custom:va.name},{kind:`category`,name:`%{BKY_CATEGORY_COMPUTE}`,categorystyle:`compute_category`,custom:sa.name}]},Ja={grid:{length:2,snap:!0,spacing:20},maxInstances:{func_entry_v1:1},media:`/media/`,move:{drag:!0,scrollbars:!0,wheel:!0},readOnly:!1,theme:`light`,trashcan:!1,zoom:{maxScale:1,minScale:.1,scaleSpeed:1.25,startScale:1,wheel:!0}};function Ya(e,t,n,r){Ja.theme=r?`dark`:`light`,Ja.toolbox=Xa(t,n);let i=ee(e,Ja);return i.addChangeListener(e=>{if(e.type===`state_change`){let e=i.getAllBlocks();for(let t of e){let e=t;e.checkWarning_&&e.checkWarning_()}}setTimeout(()=>{(0,Qi.shadowBlockConversionChangeListener)(e)},0)}),Za(i,t,n),Qa(i),i}function Xa(e,t){let n;return e===`page`?t===`v1`&&(n=qa):e===`comp`?t===`v1`&&(n=Ua):e===`func`?t===`v1`&&(n=Ga):e===`flow`?t===`v1`&&(n=Wa):e===`json`&&t===`v1`&&(n=Ka),console.assert(!!n,`invalid toolbox type=${e} version=${t}`),n}function Za(e,t,n){function r({name:n,callback:r}){e.registerToolboxCategoryCallback(n,()=>r(t))}t===`page`?n===`v1`&&(r(ga),r(la),r(fa),r(wa),r(xa),r(va),r(sa)):t===`comp`?n===`v1`&&(r(aa),r(la),r(fa),r(wa),r(xa),r(va),r(sa)):t===`func`?n===`v1`&&(r(Ma),r(ka),r(Ea),r(Pa),r(wa),r(xa)):t===`flow`&&n===`v1`&&(r(Ma),r(ka),r(Ea),r(Pa),r(wa),r(xa))}function Qa(e){let{router:t}=Ae;e.registerButtonCallback(`NO_COMPUTE`,()=>{let e=t.resolve({path:`/compute/`+Date.now()});setTimeout(()=>{window.open(e.href,`_blank`)},100)}),e.registerButtonCallback(`NO_TABLE`,()=>{let e=t.resolve({path:`/data/`+Date.now()});setTimeout(()=>{window.open(e.href,`_blank`)},100)})}const $a={class:`position-relative w-100 h-100`};var eo=gt({__name:`index`,props:yt({type:{type:String,required:!0},version:{type:String,required:!0},locale:{type:String,required:!0},dark:{type:Boolean,required:!0}},{lock:{type:Boolean,required:!0},lockModifiers:{},scale:{type:Number,required:!0},scaleModifiers:{}}),emits:yt([`ready`],[`update:lock`,`update:scale`]),setup(e,{expose:t,emit:n}){let{backgroundColor2:r}=Pe(),i=Mt(e,`lock`),a=Mt(e,`scale`),o=n,s=`blocklyEditor${jt()}`,c=Et(),l=Nt(`parentContainer`),u=Nt(`clean`),ee=Nt(`navigator`),d={};Li(d);let f=Et(!0),te=Et(!1),ne=D(()=>e.type===`json`?`tree`:`list`),re=D(()=>({width:`100%`,height:`calc(100% - 48px)`})),ae=D(()=>({position:`absolute`,background:r.value,bottom:`0px`,width:`100%`,height:`48px`})),m=D(()=>({position:`absolute`,background:e.dark?`#0000007f`:`#ffffff7f`,top:`1px`,left:`0px`,width:`56px`,height:`calc(100% - 49px)`,zIndex:999})),oe=D(()=>({position:`absolute`,top:`0px`,right:`0px`,zIndex:20})),h=D(()=>({position:`absolute`,background:e.dark?`#0000007f`:`#ffffff7f`,top:`0px`,left:`0px`,width:`100%`,height:`calc(100% - 48px)`,pointerEvents:`none`})),se=D(()=>({position:`absolute`,background:e.dark?`#0000007f`:`#ffffff7f`,top:`1px`,left:`0px`,width:`56px`,height:`calc(100% - 49px)`,zIndex:999})),ce=D(()=>({position:`fixed`,top:0,left:0,zIndex:3e3})),{open:_}=Ie(`blocklyEditorFlyout${jt()}`);Ct(async()=>{if(!c.value||!l.value){console.assert(!1);return}le(l.value),await Vt(e.locale),d.workspace=Ya(c.value,e.type,e.version,e.dark),d.workspace.addChangeListener(p.disableOrphans),d.workspace.addChangeListener(ue);let t=document.querySelector(`#${s} .blocklyFlyout`);new MutationObserver(e=>{e.forEach(e=>{e.type===`attributes`&&e.attributeName===`style`&&(_.value=d.workspace.getFlyout().isVisible())})}).observe(t,{attributes:!0}),_.value=d.workspace.getFlyout().isVisible(),ge(),_e(),await xt(),o(`ready`)}),St(()=>{_.value=!1}),we(c,()=>{d.workspace&&ie(d.workspace)});async function ue(e){if(e.type===p.FINISHED_LOADING){Ei(),setTimeout(()=>{ee.value?.update()},0),f.value=!1;return}if(!f.value){if(e.type===p.VIEWPORT_CHANGE){a.value=d.workspace.getScale();return}e.type===p.BLOCK_DRAG&&(e.isStart?te.value=!0:te.value=!1),setTimeout(()=>{ee.value?.update()},0)}}let de=t=>{f.value=!0,e.type===`json`?Bi(t,d.workspace):g.workspaces.load(t,d.workspace)},fe=()=>e.type===`json`?Vi(d.workspace):g.workspaces.save(d.workspace),pe=e=>{g.blocks.append(e,d.workspace)},me=()=>{if(e.type===`json`)console.assert(!1);else return x.workspaceToCode(d.workspace)},he=()=>Fi(d.workspace),ge=()=>{d.workspace.setIsReadOnly(i.value),d.workspace.isReadOnly()&&(_.value=!1)},_e=()=>{d.workspace.setScale(a.value)},v=()=>{p.fire(new(p.get(`state_change`))(d.workspace))},ve=()=>{u.value?.cleanWorkspace()},ye=()=>{i.value=!i.value},y=()=>{ee.value&&(ee.value.open=!0)};return Ct(()=>{ke.on(`cleanWorkspace`,ve),ke.on(`toggleBlocklyLock`,ye),ke.on(`openBlocklyNavigator`,y)}),St(()=>{ke.off(`cleanWorkspace`,ve),ke.off(`toggleBlocklyLock`,ye),ke.off(`openBlocklyNavigator`,y)}),Pt(()=>e.locale,e=>{Vt(e)}),Pt(()=>e.dark,e=>{ki(e?`dark`:`light`)}),Pt(_,e=>{e||d.workspace?.hideChaff()}),Pt(i,()=>{ge()}),Pt(a,()=>{_e()}),t({loading:f,load:de,save:fe,appendBlock:pe,generateCode:me,generateReactivity:he,fireStateChange:v}),(e,t)=>{let n=N(`v-icon`),r=N(`x-loading`);return M(),O(`div`,$a,[k(`div`,{id:s,ref_key:`blocklyDiv`,ref:c,style:j(re.value)},null,4),k(`div`,{style:j(ae.value)},[Ot(e.$slots,`bottom`)],4),te.value?(M(),O(`div`,{key:0,class:`d-flex flex-column justify-center align-center`,style:j(m.value)},[A(n,{icon:`mdi-delete`,size:`x-large`})],4)):ht(`v-if`,!0),f.value?ht(`v-if`,!0):(M(),O(`div`,{key:1,class:`d-flex align-end ga-3 pt-3 pr-3`,style:j(oe.value)},[A(zi,{ref_key:`clean`,ref:u,lock:i.value},null,8,[`lock`]),A(Hi,{modelValue:i.value,"onUpdate:modelValue":t[0]||(t[0]=e=>i.value=e)},null,8,[`modelValue`]),A(Zi,{ref_key:`navigator`,ref:ee,lock:i.value,type:ne.value},null,8,[`lock`,`type`])],4)),i.value?(M(),O(`div`,{key:2,style:j(se.value)},null,4)):ht(`v-if`,!0),i.value?(M(),O(`div`,{key:3,style:j(h.value)},null,4)):ht(`v-if`,!0),k(`div`,{ref_key:`parentContainer`,ref:l,style:j(ce.value)},null,4),A(r,{open:f.value,"z-index":99},null,8,[`open`])])}}}),to=gt({__name:`index`,props:{code:{type:String,required:!0}},setup(e){_e.registerLanguage(`javascript`,be);let t=Ce.component,{backgroundColor2:n}=Pe();return(r,i)=>{let a=N(`v-sheet`);return M(),mt(a,{color:P(n),height:`100%`,width:`100%`},{default:Ft(()=>[A(P(t),{code:e.code,language:`js`},null,8,[`code`])]),_:1},8,[`color`])}}});const no={class:`text-body-large`},ro={class:`w-100 h-100 overflow-auto`};var io=gt({__name:`index`,setup(e){let{t}=zt(),{sysBarAvail:n}=Fe(),{backgroundColor0:r,backgroundColor2:i}=Pe(),a=Et(``),o=D(()=>{let e=48;return n.value&&(e+=24),{position:`relative`,height:`calc(100% - ${e}px)`}}),{open:s}=Ie(`sourceDlg`,e=>{a.value=e.code});return(e,c)=>{let l=N(`v-sheet`),u=N(`v-btn`),ee=N(`v-spacer`),d=N(`v-dialog`);return M(),mt(d,{modelValue:P(s),"onUpdate:modelValue":c[1]||(c[1]=e=>vt(s)?s.value=e:null),fullscreen:``,"no-click-animation":``,persistent:``,transition:`dialog-bottom-transition`,onKeydown:c[2]||(c[2]=Lt(Rt(e=>s.value=!1,[`stop`,`prevent`]),[`esc`]))},{default:Ft(()=>[A(l,{color:P(r),height:`100%`,width:`100%`},{default:Ft(()=>[P(n)?(M(),mt(l,{key:0,color:P(i),height:24},null,8,[`color`])):ht(`v-if`,!0),A(l,{class:`d-flex align-center px-2`,color:P(i),height:48},{default:Ft(()=>[A(u,{density:`comfortable`,icon:`mdi-close`,variant:`text`,onClick:c[0]||(c[0]=e=>s.value=!1)}),k(`span`,no,At(P(t)(`x-block-lib.dlg.source.title`)),1),A(ee)]),_:1},8,[`color`]),k(`div`,{style:j(o.value)},[k(`div`,ro,[A(to,{code:a.value},null,8,[`code`])])],4)]),_:1},8,[`color`])]),_:1},8,[`modelValue`])}}});const ao=e=>{e.component(`XBlockly`,eo),e.component(`XSourceDlg`,io)};async function oo(e){if(e===`en`)return(await import(`./i18n-en.fzzizejc.js`).then(e=>e.t)).default;if(e===`zhHans`)return(await import(`./i18n-zhHans.b0wqxx8d.js`).then(e=>e.t)).default;throw Error(`invalid locale=${e}`)}var so={install:ao};export{eo as XBlockly,so as default,tr as getCallMethodInfo,ar as getImplementMethodInfo,W as getNodeInfo,Jn as getOnEventInfo,mr as getPropertyInfo,Zn as getTriggerEventInfo,ao as install,oo as loadLocaleMessageBlock};
376
+ `)}(${t}, ${n}, ${r})`,_.FUNCTION_CALL]},t([{type:`text_reverse_v1`,message0:`%{BKY_TEXT_V1_REVERSE_TITLE}`,args0:[{type:`input_value`,name:`TEXT`,check:`String`}],inputsInline:!0,output:`String`,style:`text_blocks`,tooltip:`%{BKY_TEXT_V1_REVERSE_TOOLTIP}`,helpUrl:`%{BKY_TEXT_V1_REVERSE_HELPURL}`}]),g.forBlock.text_reverse_v1=function(e){return[(g.valueToCode(e,`TEXT`,_.MEMBER)||`''`)+`.split('').reverse().join('')`,_.FUNCTION_CALL]},t([{type:`text_split_v1`,message0:`%{BKY_TEXT_V1_SPLIT_TITLE}`,args0:[{type:`input_value`,name:`TEXT`,check:`String`},{type:`input_value`,name:`DELIM`,check:`String`}],inputsInline:!0,output:`Array`,style:`text_blocks`,tooltip:`%{BKY_TEXT_V1_SPLIT_TOOLTIP}`,helpUrl:`%{BKY_TEXT_V1_SPLIT_HELPURL}`}]),g.forBlock.text_split_v1=function(e){return[`${g.valueToCode(e,`TEXT`,_.MEMBER)||`''`}.split(${g.valueToCode(e,`DELIM`,_.NONE)||`''`})`,_.FUNCTION_CALL]},t([{type:`text_substring_v1`,message0:`%{BKY_TEXT_V1_SUBSTRING_TITLE}`,args0:[{type:`input_value`,name:`TEXT`,check:`String`},{type:`input_value`,name:`START`,check:`Number`},{type:`input_value`,name:`END`,check:`Number`}],inputsInline:!0,output:`String`,style:`text_blocks`,tooltip:`%{BKY_TEXT_V1_SUBSTRING_TOOLTIP}`,helpUrl:`%{BKY_TEXT_V1_SUBSTRING_HELPURL}`}]),g.forBlock.text_substring_v1=function(e){return[`${g.valueToCode(e,`TEXT`,_.MEMBER)||`''`}.slice(${g.getAdjusted(e,`START`)}, ${g.getAdjusted(e,`END`,1)})`,_.FUNCTION_CALL]},t([{type:`text_trim_v1`,message0:`%{BKY_TEXT_V1_TRIM_TITLE}`,args0:[{type:`field_dropdown`,name:`MODE`,options:[[`%{BKY_TEXT_TRIM_OPERATOR_BOTH}`,`BOTH`],[`%{BKY_TEXT_TRIM_OPERATOR_LEFT}`,`LEFT`],[`%{BKY_TEXT_TRIM_OPERATOR_RIGHT}`,`RIGHT`]]},{type:`input_value`,name:`TEXT`,check:`String`}],output:`String`,style:`text_blocks`,tooltip:`%{BKY_TEXT_V1_TRIM_TOOLTIP}`,helpUrl:`%{BKY_TEXT_V1_TRIM_HELPURL}`}]),g.forBlock.text_trim_v1=function(e){return[`__trimV1__(${g.valueToCode(e,`TEXT`,_.NONE)||`''`}, ${{BOTH:0,LEFT:1,RIGHT:2}[e.getFieldValue(`MODE`)]})`,_.ATOMIC]},y.create_timer_v1={init:function(){this.appendDummyInput().appendField(`%{BKY_TIME_V1_CREATE_TIMER_TITLE}`),this.setPreviousStatement(!0,null),this.setNextStatement(!0,null),this.setStyle(`time_blocks`),this.setTooltip(`%{BKY_TIME_V1_CREATE_TIMER_TOOLTIP}`),this.setHelpUrl(`%{BKY_TIME_V1_CREATE_TIMER_HELPURL}`)},saveExtraState:function(){return{}},loadExtraState:function(){this.updateShape_(),this.updateShadow_()},updateShape_:function(){this.getInput(`CALLBACK`)||this.appendStatementInput(`CALLBACK`).appendField(`%{BKY_TIME_DO}`),this.getInput(`IMMEDIATE`)||(this.appendValueInput(`IMMEDIATE`).setCheck(`Boolean`).setAlign(u.Align.RIGHT).appendField(`%{BKY_TIME_IMMEDIATE}`),this.moveInputBefore(`IMMEDIATE`,`CALLBACK`)),this.getInput(`COUNT`)||(this.appendValueInput(`COUNT`).setCheck(`Number`).setAlign(u.Align.RIGHT).appendField(`%{BKY_TIME_COUNT}`),this.moveInputBefore(`COUNT`,`IMMEDIATE`)),this.getInput(`LOOP`)||(this.appendValueInput(`LOOP`).setCheck(`Boolean`).setAlign(u.Align.RIGHT).appendField(`%{BKY_TIME_LOOP}`),this.moveInputBefore(`LOOP`,`COUNT`)),this.getInput(`INTERVAL`)||(this.appendValueInput(`INTERVAL`).setCheck(`Number`).setAlign(u.Align.RIGHT).appendField(`%{BKY_TIME_INTERVAL_MS}`),this.moveInputBefore(`INTERVAL`,`LOOP`))},updateShadow_:function(){if(this.isInsertionMarker())return;let e=fn(1e3);this.getInput(`INTERVAL`)?.setShadowDom(e);let t=pn(!1);this.getInput(`LOOP`)?.setShadowDom(t);let n=fn(1);this.getInput(`COUNT`)?.setShadowDom(n);let r=pn(!1);this.getInput(`IMMEDIATE`)?.setShadowDom(r)}},g.forBlock.create_timer_v1=function(e){return`__createTimerV1__(${g.valueToCode(e,`INTERVAL`,_.ATOMIC)||`1000`}, ${g.valueToCode(e,`LOOP`,_.ATOMIC)||`false`}, ${g.valueToCode(e,`COUNT`,_.ATOMIC)||`1`}, ${g.valueToCode(e,`IMMEDIATE`,_.ATOMIC)||`false`}, async function() {
377
+ ${g.statementToCode(e,`CALLBACK`)}});\n`},t([{type:`delay_v1`,message0:`%{BKY_TIME_V1_DELAY_TITLE}`,args0:[{type:`input_value`,name:`DURATION`,check:`Number`}],previousStatement:null,nextStatement:null,style:`time_blocks`,tooltip:`%{BKY_TIME_V1_DELAY_TOOLTIP}`,helpUrl:`%{BKY_TIME_V1_DELAY_HELPURL}`}]),g.forBlock.delay_v1=function(e){return`await __delayV1__(${g.valueToCode(e,`DURATION`,_.ATOMIC)||`0`});\n`};const di={customContextMenu:function(e){if(!this.isInFlyout){let t,n;this.type===`variable_get_v1`?(t=`variable_set_v1`,n=F(`VARIABLE_GET_CREATE_SET`)):this.type===`variable_set_v1`?(t=`variable_get_v1`,n=F(`VARIABLE_SET_CREATE_GET`)):console.assert(!1);let r=this.getField(`VAR`),i={type:t,fields:{VAR:r.saveState(!0)}};e.push({enabled:this.workspace.remainingCapacity()>0,text:n.replace(`%1`,r.getText()),callback:Oe.callbackFactory(this,i)})}else if(this.type===`variable_get_v1`){let t={text:F(`RENAME_VARIABLE`),enabled:!0,callback:fi(this)},n=this.getField(`VAR`).getText(),r={text:F(`DELETE_VARIABLE`).replace(`%1`,n),enabled:!0,callback:pi(this)};e.unshift(t),e.unshift(r)}}},fi=function(e){return function(){let t=e.workspace,n=e.getField(`VAR`).getVariable();c.renameVariable(t,n)}},pi=function(e){return function(){let t=e.getField(`VAR`).getVariable();t&&c.deleteVariable(t.getWorkspace(),t,e)}};m.registerMixin(`context_menu_variable_v1`,di),t([{type:`variable_get_v1`,message0:`%1`,args0:[{type:`field_variable`,name:`VAR`}],output:null,style:`variable_blocks`,tooltip:`%{BKY_VARIABLE_V1_GET_TOOLTIP}`,helpUrl:`%{BKY_VARIABLE_V1_GET_HELPURL}`,extensions:[`context_menu_variable_v1`]}]),g.forBlock.variable_get_v1=function(t){return[g.nameDB_.getName(t.getFieldValue(`VAR`),e.NameType.VARIABLE),_.ATOMIC]},t([{type:`variable_set_v1`,message0:`%{BKY_VARIABLE_V1_SET_TITLE}`,args0:[{type:`field_variable`,name:`VAR`,variable:``},{type:`input_value`,name:`VALUE`}],previousStatement:null,nextStatement:null,style:`variable_blocks`,tooltip:`%{BKY_VARIABLE_V1_SET_TOOLTIP}`,helpUrl:`%{BKY_VARIABLE_V1_SET_HELPURL}`,extensions:[`context_menu_variable_v1`]}]),g.forBlock.variable_set_v1=function(t){return`${g.nameDB_.getName(t.getFieldValue(`VAR`),e.NameType.VARIABLE)} = ${g.valueToCode(t,`VALUE`,_.ASSIGNMENT)||`0`};\n`},ae.setConfirm(async(e,t)=>{t(!!await Ne({title:``,text:e}))}),ae.setPrompt(async(e,t,n)=>{let r=await Pe({title:``,value:t});r!==void 0&&n(String(r))});const mi=b.prototype;mi.doClassValidation_=function(e){return e};const hi=mi.doValueUpdate_;mi.doValueUpdate_=function(e){hi.call(this,e),this.selectedOption&&this.selectedOption[1]!==e&&(this.selectedOption=null)};const gi=mi.getText_;mi.getText_=function(){if(this.selectedOption)return gi.call(this);let{i18n:e}=je,t=this.getSourceBlock();if(this.name===`APP`)return t.app.name;if(this.name===`PAGE`)return t.page.name;if(this.name===`ELEMENT`)return t.element.name;if(this.name===`NODE`){let n=w(t.node.key);if(n)return`${e.global.t(n.name)} / ${t.node.alias}`}else if(this.name===`PROPERTY`){let{kind:e,names:n}=t.property;return rt(e,n)}else if(this.name===`EVENT`){let{kind:e,names:n}=t.event;return tt(e,n)}else if(this.name===`METHOD`){let{kind:e,names:n}=t.method;return nt(e,n)}else if(this.name===`SPACE`)return t.space.name;else if(this.name===`FUNC`)return t.func.name;else if(this.name===`OUTPUT`)return t.output.name;else if(this.name===`TABLE`)return t.table.name;else if(this.name===`COLUMN`)return t.column.name;else if(this.name===`DIR`)return t.dir.name;else if(this.name===`RESOURCE`)return t.resource.name;return`<n/a>`},ee.prototype.cleanUp=function(){this.setResizesEnabled(!1);let e=x.getGroup();e||x.setGroup(!0);let t=this.getTopBlocks(!0),n=t.filter(e=>e.isMovable()),r=t.filter(e=>!e.isMovable()).map(e=>e.getBoundingRectangle()),i=function(e){for(let t of r)if(e.intersects(t))return t;return null},a=0;for(let e of n){let t=e.getBoundingRectangle();e.moveBy(-t.left,a-t.top,[`cleanup`]),e.snapToGrid(),t=e.getBoundingRectangle();let n=i(t);for(;n!=null;)a=n.top+n.getHeight()+60,e.moveBy(0,a-t.top,[`cleanup`]),e.snapToGrid(),t=e.getBoundingRectangle(),n=i(t);a=e.getRelativeToSurfaceXY().y+e.getHeightWidth().height+60}x.setGroup(e),this.setResizesEnabled(!0)};var _i=Te();function vi(e){let t=e.getParent();return t&&vi(t)?!0:!t&&!!(e.outputConnection||e.previousConnection)}var yi=class{init(){let e=de.registry.getItem(`blockDisable`);e&&(e.preconditionFn=function(e){let t=e.block;return t&&!t.isInFlyout&&t.workspace.options.disable&&t.isEditable()?t.getInheritedDisabled()||vi(t)?`disabled`:`enabled`:`hidden`})}};(0,En.registerFieldColour)(),d.registry.unregister(te.names.ESCAPE),new _i.CrossTabCopyPaste().init({contextMenu:!0,shortcut:!0}),new yi().init();function bi(e){"@babel/helpers - typeof";return bi=typeof Symbol==`function`&&typeof Symbol.iterator==`symbol`?function(e){return typeof e}:function(e){return e&&typeof Symbol==`function`&&e.constructor===Symbol&&e!==Symbol.prototype?`symbol`:typeof e},bi(e)}function xi(e,t){if(bi(e)!=`object`||!e)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var r=n.call(e,t||`default`);if(bi(r)!=`object`)return r;throw TypeError(`@@toPrimitive must return a primitive value.`)}return(t===`string`?String:Number)(e)}function Si(e){var t=xi(e,`string`);return bi(t)==`symbol`?t:t+``}function Ci(e,t,n){return(t=Si(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}var wi=class extends x.Abstract{constructor(e){super(),Ci(this,`isBlank`,!0),Ci(this,`recordUndo`,!1),Ci(this,`type`,`state_change`),this.workspaceId=e.id}};Ce.register(Ce.Type.EVENT,`state_change`,wi);function Ti(e){let t=s();if(!t)return;let n=t.getBlockById(e);if(!n)return;let r=n.getRootBlock();if(!r)return;let i=r.getRelativeToSurfaceXY(),a=i.x*t.scale,o=i.y*t.scale;t.scroll(-a,-o)}function Ei(){let e=s();if(!e)return;let t=e.getTopBlocks(!0)?.[0];t&&Ti(t.id)}a.Classic.blockStyles={color_blocks:{colourPrimary:`#a5745b`,colourSecondary:`#ede3de`,colourTertiary:`#845d49`,hat:``},event_blocks:{colourPrimary:`#a5a55b`,colourSecondary:`#ededde`,colourTertiary:`#848449`,hat:``},list_blocks:{colourPrimary:`#745ba5`,colourSecondary:`#e3deed`,colourTertiary:`#5d4984`,hat:``},logic_blocks:{colourPrimary:`#5b80a5`,colourSecondary:`#dee6ed`,colourTertiary:`#496684`,hat:``},loop_blocks:{colourPrimary:`#5ba55b`,colourSecondary:`#deedde`,colourTertiary:`#498449`,hat:``},math_blocks:{colourPrimary:`#5b67a5`,colourSecondary:`#dee1ed`,colourTertiary:`#495284`,hat:``},method_blocks:{colourPrimary:`#995ba5`,colourSecondary:`#ebdeed`,colourTertiary:`#7a4984`,hat:``},object_blocks:{colourPrimary:`#80a55b`,colourSecondary:`#e6edde`,colourTertiary:`#668449`,hat:``},procedure_blocks:{colourPrimary:`#995ba5`,colourSecondary:`#ebdeed`,colourTertiary:`#7a4984`,hat:``},property_blocks:{colourPrimary:`#5ba5a5`,colourSecondary:`#deeded`,colourTertiary:`#498484`,hat:``},state_blocks:{colourPrimary:`#a55b67`,colourSecondary:`#eddee1`,colourTertiary:`#844952`,hat:``},text_blocks:{colourPrimary:`#5ba58c`,colourSecondary:`#deede8`,colourTertiary:`#498470`,hat:``},time_blocks:{colourPrimary:`#5b99a5`,colourSecondary:`#deebed`,colourTertiary:`#497a84`,hat:``},variable_blocks:{colourPrimary:`#a55b80`,colourSecondary:`#eddee6`,colourTertiary:`#844966`,hat:``}},a.Classic.categoryStyles={color_category:{colour:`#a5745b`},common_category:{colour:`#757575`},compute_category:{colour:`#757575`},data_category:{colour:`#757575`},event_category:{colour:`#a5a55b`},flow_category:{colour:`#757575`},func_category:{colour:`#757575`},list_category:{colour:`#745ba5`},logic_category:{colour:`#5b80a5`},loop_category:{colour:`#5ba55b`},math_category:{colour:`#5b67a5`},method_category:{colour:`#995ba5`},misc_category:{colour:`#757575`},object_category:{colour:`#80a55b`},procedure_category:{colour:`#995ba5`},property_category:{colour:`#5ba5a5`},resource_category:{colour:`#757575`},state_category:{colour:`#a55b67`},text_category:{colour:`#5ba58c`},time_category:{colour:`#5b99a5`},variable_category:{colour:`#a55b80`}};const Di=ne.defineTheme(`light`,{name:`light`,base:a.Classic,componentStyles:{workspaceBackgroundColour:`#ffffff`,toolboxBackgroundColour:`#eeeeee`,toolboxForegroundColour:``,flyoutBackgroundColour:`#eeeeee`,flyoutForegroundColour:`#000000`,flyoutOpacity:.8,scrollbarColour:``,insertionMarkerColour:``,insertionMarkerOpacity:.3,scrollbarOpacity:.4,cursorColour:``}}),Oi=ne.defineTheme(`dark`,{name:`dark`,base:a.Classic,componentStyles:{workspaceBackgroundColour:`#1e1e1e`,toolboxBackgroundColour:`#272727`,toolboxForegroundColour:``,flyoutBackgroundColour:`#272727`,flyoutForegroundColour:`#ffffff`,flyoutOpacity:.8,scrollbarColour:``,insertionMarkerColour:``,insertionMarkerOpacity:.3,scrollbarOpacity:.4,cursorColour:``}});function ki(e){let t=s();switch(e){case`light`:t.setTheme(Di);break;case`dark`:t.setTheme(Oi);break}}function Ai(e,t){e.find(e=>e===t)||e.push(t)}const ji=[`get_app_property_v1`,`get_app_state_v1`];function Mi(e){let t=[];function n(e){for(let r of e.getChildren(!0))ji.includes(r.type)&&t.push(r),n(r)}return n(e),t}function Ni(e){let t=[];for(let n of e)n.type===`get_app_property_v1`?Ai(t,Ze(`propertyTrigger`,n.property.id)):n.type===`get_app_state_v1`?Ai(t,Ze(`stateTrigger`,n.state.id)):console.assert(!1);return t}function Pi(e){let t=[];for(let n of e){if(n.type!==`app_bind_entry_v1`)continue;let e=n;e.kind===`property`?Ai(t,Ze(`propertyTrigger`,e.property.id)):e.kind===`state`&&Ai(t,Ze(`stateTrigger`,e.state.id))}return t}function Fi(e){let t={watchEffect:{ids:[],triggers:{}},bind:{sets:{},triggers:{}}},n=e.getTopBlocks(!0);if(!n)return t;for(let e of n)if(e.type===`watch_effect_v1`){let n=Ni(Mi(e));for(let r of n)t.watchEffect.triggers[r]||(t.watchEffect.triggers[r]=[]),Ai(t.watchEffect.triggers[r],e.id);t.watchEffect.ids.push(e.id)}else if(e.type===`app_bind_v1`){let n=Pi(e.getChildren(!0));t.bind.sets[e.id]=n;for(let r of n)t.bind.triggers[r]||(t.bind.triggers[r]=[]),Ai(t.bind.triggers[r],e.id)}return t}const Ii=Symbol();function Li(e){Tt(Ii,e)}function Ri(){return _t(Ii)}var zi=gt({__name:`index`,props:{lock:{type:Boolean,required:!0}},setup(e,{expose:t}){let{t:n}=zt(),r=Bt(),i=Ri(),a=E(()=>r.smAndDown.value),o=()=>{if(!i.workspace){console.assert(!1);return}if(e.lock){Me(n(`x-block-lib.msg.cannotOperateInLockedState`));return}i.workspace.cleanUp()},s=()=>{o()};return t({cleanWorkspace:o}),(e,t)=>{let r=N(`v-btn`),i=N(`v-tooltip`);return M(),D(i,{disabled:a.value,text:P(n)(`x-block-lib.tip.hotkeyCtrlQ`)},{activator:Ft(({props:e})=>[A(r,bt(e,{density:`comfortable`,icon:`mdi-broom`,variant:`outlined`,onClick:s}),null,16)]),_:1},8,[`disabled`,`text`])}}});function Bi(e,t){let n=t.newBlock(`json_root_v1`);n.initSvg(),n.render();let r=(e,n)=>{if(e===null)return;let i;if(e instanceof Array)i=`json_array_v1`;else{let t=typeof e;if(t===`object`)i=`json_map_v1`;else if(t===`string`)i=`json_string_v1`;else if(t===`number`)i=`json_number_v1`;else if(t===`boolean`)i=`json_boolean_v1`;else return}let a=t.newBlock(i);if(a.initSvg(),a.render(),n.connect(a.outputConnection),i===`json_map_v1`){let t=[];for(let n in e)t.push(n);a.initData(t);for(let n=0;n<t.length;n++){let i=t[n],o=a.getInput(`ENTRY`+n);r(e[i],o.connection)}}else if(i===`json_array_v1`){a.initData(e.length);for(let t=0;t<e.length;t++)r(e[t],a.getInput(`ENTRY`+t).connection)}else i===`json_string_v1`||i===`json_number_v1`?a.setFieldValue(e,`VALUE`):i===`json_boolean_v1`&&a.setFieldValue(e?`true`:`false`,`VALUE`)};r(e,n.getInput(`JSON`).connection),x.fire(new(x.get(x.FINISHED_LOADING))(t))}function Vi(e){let t=e=>{if(!e)return null;if(e.type===`json_root_v1`)return t(e.getInputTargetBlock(`JSON`));if(e.type===`json_map_v1`){let n={};for(let r=0;r<e.length;r++){let i=e.getFieldValue(`KEY`+r);n[i]=t(e.getInputTargetBlock(`ENTRY`+r))}return n}else if(e.type===`json_array_v1`){let n=[];for(let r=0;r<e.length;r++)n.push(t(e.getInputTargetBlock(`ENTRY`+r)));return n}else if(e.type===`json_string_v1`)return e.getFieldValue(`VALUE`);else if(e.type===`json_number_v1`)return e.getFieldValue(`VALUE`);else if(e.type===`json_boolean_v1`)return e.getFieldValue(`VALUE`)===`true`;else console.assert(!1)},n=e.getTopBlocks();for(let e of n)if(e.type===`json_root_v1`)return t(e)}var Hi=gt({__name:`index`,props:{modelValue:{type:Boolean,required:!0},modelModifiers:{}},emits:[`update:modelValue`],setup(e){let{t}=zt(),n=Bt(),r=Mt(e,`modelValue`),i=E(()=>n.smAndDown.value);return(e,n)=>{let a=N(`v-btn`),o=N(`v-tooltip`);return M(),D(o,{disabled:i.value,text:P(t)(`x-block-lib.tip.hotkeyCtrlW`)},{activator:Ft(({props:e})=>[A(a,bt(e,{density:`comfortable`,icon:r.value?`mdi-lock`:`mdi-lock-open`,variant:`outlined`,onClick:n[0]||(n[0]=e=>r.value=!r.value)}),null,16,[`icon`])]),_:1},8,[`disabled`,`text`])}}});const Ui={class:`d-flex flex-column`},Wi={class:`text-body-large ml-6`},Gi={key:0,class:`text-body-small text-grey text-truncate ml-6`,style:{maxWidth:`340px`}};var Ki=gt({__name:`item`,props:{id:{type:String,required:!0},title:{type:String,required:!0},desc:{type:String,required:!0},select:{type:Boolean,required:!0}},emits:[`x-click`],setup(e,{emit:t}){let{primaryColor:n,backgroundColor2:r,highlightColor:i}=Fe(),a=t,o=Et(!1),s=E(()=>{let t={position:`relative`,background:o.value?i.value:r.value,boxSizing:`border-box`,width:`100%`,height:`48px`,marginTop:`1px`,userSelect:`none`};return e.select?(t.borderTop=`1px solid `+n.value,t.borderBottom=`1px solid `+n.value):(t.borderTop=void 0,t.borderBottom=void 0),t});return(t,n)=>{let r=N(`v-spacer`),i=N(`v-icon`),c=kt(`ripple`);return It((M(),O(`div`,{class:`d-flex align-center cursor-pointer`,style:j(s.value),onClick:n[1]||(n[1]=t=>a(`x-click`,e.id)),onMouseout:n[2]||(n[2]=e=>o.value=!1),onMouseover:n[3]||(n[3]=e=>o.value=!0)},[k(`div`,Ui,[k(`span`,Wi,At(e.title),1),e.desc?(M(),O(`span`,Gi,At(e.desc),1)):ht(`v-if`,!0)]),A(r),A(i,{class:`x-handle cursor-move mr-3`,icon:`mdi-drag-horizontal-variant`,onMousedown:n[0]||(n[0]=Rt(()=>{},[`stop`]))})],36)),[[c]])}}});const qi={key:1,class:`text-body-small text-grey`};var Ji=((e,t)=>{let n=e.__vccOpts||e;for(let[e,r]of t)n[e]=r;return n})(gt({__name:`index`,props:yt({lock:{type:Boolean,required:!0}},{modelValue:{type:Boolean,required:!0},modelModifiers:{}}),emits:[`update:modelValue`],setup(e,{expose:t}){let{t:n}=zt(),r=Mt(e,`modelValue`),i=Ri(),a=Et([]);t({update:()=>{if(!i.workspace){console.assert(!1);return}let e=[];i.workspace.getTopBlocks(!0).forEach(t=>{let r=t.id===ie()?.id,i=``;if(t.type.startsWith(`on_app_event_v`)){let e=t,r=w(e.node.key);r&&(i=n(r.name),e.node.alias&&(i+=` / `+e.node.alias),i+=` - `+tt(e.event.kind,e.event.names))}else if(t.type.startsWith(`watch_effect_v`))i=n(`x-block-lib.watchEffect`);else if(t.type.startsWith(`app_bind_v`))i=n(`x-block-lib.bind`);else if(t.type.startsWith(`implement_app_method_v`)){let e=t;i=n(`x-block-lib.implementMethod`),i+=` - `+nt(e.method.kind,e.method.names)}else i=t.type.startsWith(`func_entry_v`)?n(`x-block-lib.funcEntry`):t.type.startsWith(`procedure_def_v`)?n(`x-block-lib.procedure`)+` - `+t.getFieldValue(`NAME`):n(`x-block-lib.temporaryBlock`);let a=t.getCommentText()??``;e.push({id:t.id,name:i,desc:a,select:r})}),a.value=e}});let o=[],s=()=>{if(e.lock){Me(n(`x-block-lib.msg.cannotOperateInLockedState`));return}let t=[];a.value.forEach(({id:e})=>{t.push(e)}),o=t},c=()=>!e.lock,l=e=>{if(!i.workspace){console.assert(!1);return}if(e.oldIndex===void 0||e.newIndex===void 0){console.assert(!1);return}if(e.oldIndex===e.newIndex)return;let t=o[e.oldIndex],n=i.workspace.getBlockById(t);if(!n){console.assert(!1);return}let r=``;e.newIndex>e.oldIndex?r=o[e.newIndex]:e.newIndex>0&&(r=o[e.newIndex-1]);let a=-10;r!==``&&(a=i.workspace.getBlockById(r).getRelativeToSurfaceXY().y+10);let s=n.getRelativeToSurfaceXY();n.moveTo(new p.Coordinate(s.x,a)),i.workspace.cleanUp(),Ei()},u=async e=>{if(!i.workspace){console.assert(!1);return}let t=i.workspace.getBlockById(e);ke.setSelected(t),Ti(e),r.value=!1};return(e,t)=>a.value.length>0?(M(),D(P(ue),{key:0,modelValue:a.value,"onUpdate:modelValue":t[0]||(t[0]=e=>a.value=e),animation:150,"ghost-class":`ghost`,handle:`.x-handle`,onEnd:l,onMove:c,onStart:s},{default:Ft(()=>[(M(!0),O(mt,null,Dt(a.value,e=>(M(),D(Ki,{id:e.id,key:e.id,desc:e.desc,select:e.select,title:e.name,onXClick:u},null,8,[`id`,`desc`,`select`,`title`]))),128))]),_:1},8,[`modelValue`])):(M(),O(`span`,qi,At(P(n)(`x-block-lib.noOption`)),1))}}),[[`__scopeId`,`data-v-x-block-lib-ca7316a0`]]),Yi=gt({__name:`index`,props:{modelValue:{type:Boolean,required:!0},modelModifiers:{}},emits:[`update:modelValue`],setup(e,{expose:t}){let n=Mt(e,`modelValue`),r=Ri();t({update:()=>{if(!r.workspace){console.assert(!1);return}}});let i=e=>{let t=s();if(!t){console.assert(!1);return}let r=t.getBlockById(e);ke.setSelected(r),Ti(e),n.value=!1};return(e,t)=>(M(),O(`div`,{onClick:t[0]||(t[0]=e=>i(``))},`blockTree`))}});const Xi={class:`text-body-large`};var Zi=gt({__name:`index`,props:{type:{type:String,required:!0},lock:{type:Boolean,required:!0}},setup(e,{expose:t}){let{t:n}=zt(),r=Bt(),{sysBarAvail:i}=Ie(),{backgroundColor1:a}=Fe(),o=E(()=>r.smAndDown.value),s=E(()=>{let e=`100%`;return r.mdAndUp.value&&(e=`400px`),{background:a.value,width:e,height:`100%`}}),c=E(()=>{let e=48;return i.value&&(e+=24),{position:`relative`,height:`calc(100% - ${e}px)`}}),l=E(()=>({height:`60px`})),{open:u}=Le(`blocklyNavigatorDlg${jt()}`);wt(()=>{u.value=!1});let ee=Nt(`blockList`),te=Nt(`blockTree`);return t({open:u,update:()=>{e.type===`list`?ee.value?.update():e.type===`tree`&&te.value?.update()}}),(t,r)=>{let a=N(`v-sheet`),d=N(`v-btn`),f=N(`v-spacer`),ne=N(`v-dialog`),p=N(`v-tooltip`);return M(),O(mt,null,[A(ne,{modelValue:P(u),"onUpdate:modelValue":r[5]||(r[5]=e=>vt(u)?u.value=e:null),eager:``,fullscreen:``,"no-click-animation":``,persistent:``,transition:`scroll-x-reverse-transition`,onKeydown:r[6]||(r[6]=Lt(Rt(e=>u.value=!1,[`stop`,`prevent`]),[`esc`]))},{default:Ft(()=>[k(`div`,{class:`w-100 h-100 d-flex flex-row-reverse`,onClick:r[3]||(r[3]=Rt(e=>u.value=!1,[`self`])),onContextmenu:r[4]||(r[4]=Rt(e=>u.value=!1,[`self`,`prevent`]))},[k(`div`,{class:`elevation-2`,style:j(s.value)},[P(i)?(M(),D(a,{key:0,color:`transparent`,height:24})):ht(`v-if`,!0),A(a,{class:`d-flex align-center px-2`,color:`transparent`,height:48},{default:Ft(()=>[A(d,{density:`comfortable`,icon:`mdi-close`,variant:`text`,onClick:r[0]||(r[0]=e=>u.value=!1)}),k(`span`,Xi,At(P(n)(`x-block-lib.navigator`)),1),A(f)]),_:1}),k(`div`,{class:`overflow-y-auto`,style:j(c.value)},[e.type===`list`?(M(),D(Ji,{key:0,ref_key:`blockList`,ref:ee,modelValue:P(u),"onUpdate:modelValue":r[1]||(r[1]=e=>vt(u)?u.value=e:null),lock:e.lock},null,8,[`modelValue`,`lock`])):e.type===`tree`?(M(),D(Yi,{key:1,ref_key:`blockTree`,ref:te,modelValue:P(u),"onUpdate:modelValue":r[2]||(r[2]=e=>vt(u)?u.value=e:null)},null,8,[`modelValue`])):ht(`v-if`,!0),k(`div`,{style:j(l.value)},null,4)],4)],4)],32)]),_:1},8,[`modelValue`]),A(p,{disabled:o.value,text:P(n)(`x-block-lib.tip.hotkeyCtrlE`)},{activator:Ft(({props:e})=>[A(d,bt(e,{density:`comfortable`,icon:`mdi-navigation-variant`,variant:`outlined`,onClick:r[7]||(r[7]=e=>u.value=!0)}),null,16)]),_:1},8,[`disabled`,`text`])],64)}}}),Qi=ge();const Z=p.xml;function Q(e){let t=Z.createElement(`label`);return t.setAttribute(`text`,e),t}function $(e,t){let n=Z.createElement(`block`);if(n.setAttribute(`type`,e),t)for(let e of t)n.appendChild(e);return n}function $i(e){let t=Z.createElement(`mutation`);for(let{key:n,value:r}of e)t.setAttribute(n,r);return t}function ea(e,t){t===void 0&&(t=``);let n=Z.createElement(`value`);n.setAttribute(`name`,e);let r=Z.createElement(`shadow`);r.setAttribute(`type`,`text_v1`);let i=Z.createElement(`field`);i.setAttribute(`name`,`TEXT`);let a=Z.createTextNode(t);return i.appendChild(a),r.appendChild(i),n.appendChild(r),n}function ta(e,t){t===void 0&&(t=0);let n=Z.createElement(`value`);n.setAttribute(`name`,e);let r=Z.createElement(`shadow`);r.setAttribute(`type`,`math_number_v1`);let i=Z.createElement(`field`);i.setAttribute(`name`,`NUM`);let a=Z.createTextNode(String(t));return i.appendChild(a),r.appendChild(i),n.appendChild(r),n}function na(e,t){t===void 0&&(t=!1);let n=Z.createElement(`value`);n.setAttribute(`name`,e);let r=Z.createElement(`shadow`);r.setAttribute(`type`,`logic_boolean_v1`);let i=Z.createElement(`field`);i.setAttribute(`name`,`BOOL`);let a=Z.createTextNode(t?`TRUE`:`FALSE`);return i.appendChild(a),r.appendChild(i),n.appendChild(r),n}function ra(){let{activeObject:e,activeComp:t}=S.app;return!(e.type!==`comp`||!t.meta.states||t.meta.states.length<=0)}function ia(){let e=[];return e.push(Q(F(`LABEL_EVENT`))),U(`onEvent`)&&e.push($(`on_app_event_v1`)),U(`triggerEvent`)&&e.push($(`trigger_app_event_v1`)),e.push($(`app_bind_v1`,[$i([{key:`items`,value:`2`}])])),e.push($(`watch_effect_v1`)),(U(`getProperty`)||U(`setProperty`))&&e.push(Q(F(`LABEL_PROPERTY`))),U(`getProperty`)&&e.push($(`get_app_property_v1`)),U(`setProperty`)&&e.push($(`set_app_property_v1`)),ra()&&(e.push(Q(F(`LABEL_STATE`))),e.push($(`get_app_state_v1`)),e.push($(`set_app_state_v1`))),(U(`callMethod`)||U(`implementMethod`))&&e.push(Q(F(`LABEL_METHOD`))),U(`callMethod`)&&e.push($(`call_app_method_v1`)),U(`implementMethod`)&&(e.push($(`implement_app_method_v1`)),U(`implementMethodOutput`)&&e.push($(`set_app_method_output_v1`)),e.push($(`procedure_return_v1`))),e}const aa={name:`APP_COMP_CATEGORY`,callback:ia};function oa(){let e=[];return e.push(Q(F(`LABEL_FUNC`))),e.push(Q(F(`LABEL_FLOW`))),e}const sa={name:`APP_COMPUTE_CATEGORY`,callback:oa};function ca(){let e=[];return e.push($(`app_debug_trace_v1`,[ea(`OBJECT`)])),e.push($(`popup_message_v1`,[ea(`TEXT`)])),e.push($(`open_confirm_dlg_v1`)),e.push($(`open_prompt_dlg_v1`)),e}const la={name:`APP_MESSAGE_CATEGORY`,callback:ca};function ua(){for(let e of S.app.appList)if(e.pages.length>0)return!0;return!1}function da(){let e=[];return e.push($(`app_env_is_v1`)),ua()&&e.push($(`navigate_to_v1`)),e}const fa={name:`APP_MISC_CATEGORY`,callback:da};function pa(){let{activeObject:e,activePage:t}=S.app;return!(e.type!==`page`||!t.meta.states||t.meta.states.length<=0)}function ma(){let{activeObject:e,activePage:t}=S.app;return!(e.type!==`page`||!t.meta.arguments||t.meta.arguments.length<=0)}function ha(){let e=[];return e.push(Q(F(`LABEL_EVENT`))),U(`onEvent`)&&e.push($(`on_app_event_v1`)),e.push($(`app_bind_v1`,[$i([{key:`items`,value:`2`}])])),e.push($(`watch_effect_v1`)),(U(`getProperty`)||U(`setProperty`))&&e.push(Q(F(`LABEL_PROPERTY`))),U(`getProperty`)&&e.push($(`get_app_property_v1`)),U(`setProperty`)&&e.push($(`set_app_property_v1`)),pa()&&(e.push(Q(F(`LABEL_STATE`))),e.push($(`get_app_state_v1`)),e.push($(`set_app_state_v1`))),U(`callMethod`)&&(e.push(Q(F(`LABEL_METHOD`))),e.push($(`call_app_method_v1`))),ma()&&(e.push(Q(F(`LABEL_ARGUMENT`))),e.push($(`get_page_argument_v1`))),e}const ga={name:`APP_PAGE_CATEGORY`,callback:ha};function _a(){let e=[];return e.push(Q(F(`LABEL_RESOURCE`))),e.push($(`upload_resource_v1`)),e}const va={name:`APP_RESOURCE_CATEGORY`,callback:_a},ya=p.xml;function ba(){let e=[];{let t=ya.createElement(`label`);t.setAttribute(`text`,`%{BKY_LABEL_PROCEDURE}`),e.push(t)}{let t=ya.createElement(`block`);t.setAttribute(`type`,`procedure_def_v1`);{let e=ya.createElement(`field`);e.setAttribute(`name`,`NAME`);let n=ya.createTextNode(F(`PROCEDURE_DEFAULT_NAME`));e.appendChild(n),t.appendChild(e)}e.push(t)}{let t=ya.createElement(`block`);t.setAttribute(`type`,`procedure_return_v1`),e.push(t)}return e}const xa={name:`PROCEDURE_CATEGORY`,callback:ba},Sa=p.xml;function Ca(){let e=s(),t=[];{let e=Sa.createElement(`label`);e.setAttribute(`text`,`%{BKY_LABEL_VARIABLE}`),t.push(e)}{let n=document.createElement(`button`);n.setAttribute(`text`,`%{BKY_NEW_VARIABLE}`),n.setAttribute(`callbackKey`,`CREATE_VARIABLE`),e.registerButtonCallback(`CREATE_VARIABLE`,function(e){c.createVariableButtonHandler(e.getTargetWorkspace())}),t.push(n)}let n=e.getVariablesOfType(``);if(n.length<=0)return t;n.sort(c.compareByName);{let e=Sa.createElement(`label`);e.setAttribute(`text`,F(`LABEL_CREATED`)),t.push(e)}return n.forEach(e=>{{let n=Sa.createElement(`block`);n.setAttribute(`type`,`variable_get_v1`),n.appendChild(c.generateVariableFieldDom(e)),t.push(n)}{let n=Sa.createElement(`block`);n.setAttribute(`type`,`variable_set_v1`),n.appendChild(c.generateVariableFieldDom(e)),t.push(n)}}),t}const wa={name:`VARIABLE_CATEGORY`,callback:Ca};function Ta(){let e=[];if(Y().length>0)e.push(Q(F(`LABEL_OPERATION`))),e.push($(`add_data_v1`)),e.push($(`delete_data_v1`)),e.push($(`update_data_v1`)),e.push($(`query_data_v1`)),e.push($(`transaction_v1`)),e.push($(`interrupt_transaction_v1`,[ea(`VALUE`)])),e.push(Q(F(`LABEL_CONDITION`))),e.push($(`cond_logic_v1`)),e.push($(`cond_atomic_v1`,[ea(`VALUE`)])),e.push(Q(F(`LABEL_QUERY_EXTRA`))),e.push($(`query_extra_limit_v1`,[ta(`OFFSET`,0),ta(`LIMIT`,1)])),e.push($(`query_extra_sortby_v1`,[ea(`COLUMN`),na(`DESC`)]));else{let t=document.createElement(`button`);t.setAttribute(`text`,F(`BUTTON_NO_TABLE`)),t.setAttribute(`callbackKey`,`NO_TABLE`),e.push(t)}return e}const Ea={name:`COMPUTE_DATA_CATEGORY`,callback:Ta};function Da(){return Er(`flow`).length>0}function Oa(){let e=[];return S.compute.activeObject.type===`flow`&&e.push($(`on_flow_state_event_v1`)),Da()&&console.assert(!0),e}const ka={name:`COMPUTE_FLOW_CATEGORY`,callback:Oa};function Aa(){return Er(`func`).length>0}function ja(){let{activeObject:e,activeFunc:t}=S.compute,n=[];return e.type===`func`&&(n.push($(`func_entry_v1`)),t.outputs&&t.outputs.length>0&&n.push($(`set_func_output_v1`)),n.push($(`procedure_return_v1`))),Aa()&&n.push($(`call_func_internal_v1`)),n}const Ma={name:`COMPUTE_FUNC_CATEGORY`,callback:ja};function Na(){let e=[];return e.push($(`compute_debug_trace_v1`,[ea(`OBJECT`)])),e}const Pa={name:`COMPUTE_MISC_CATEGORY`,callback:Na},Fa={kind:`category`,name:`%{BKY_CATEGORY_COLOR}`,categorystyle:`color_category`,contents:[{kind:`block`,type:`color_picker_v1`},{kind:`block`,type:`color_random_v1`},{kind:`block`,type:`color_rgb_v1`,inputs:{RED:{shadow:{type:`math_number_v1`,fields:{NUM:0}}},GREEN:{shadow:{type:`math_number_v1`,fields:{NUM:0}}},BLUE:{shadow:{type:`math_number_v1`,fields:{NUM:0}}}}},{kind:`block`,type:`color_blend_v1`,inputs:{COLOR1:{shadow:{type:`color_picker_v1`,fields:{COLOR:`#ff0000`}}},COLOR2:{shadow:{type:`color_picker_v1`,fields:{COLOR:`#00ff00`}}},RATIO:{shadow:{type:`math_number_v1`,fields:{NUM:.5}}}}}]},Ia={kind:`category`,name:`%{BKY_CATEGORY_LIST}`,categorystyle:`list_category`,contents:[{kind:`label`,text:`%{BKY_LABEL_LIST}`},{kind:`block`,type:`list_create_v1`,extraState:{itemCount:0}},{kind:`label`,text:`%{BKY_LABEL_GET}`},{kind:`block`,type:`list_is_empty_v1`},{kind:`block`,type:`list_length_v1`},{kind:`block`,type:`list_get_v1`,inputs:{AT:{shadow:{type:`math_number_v1`,fields:{NUM:1}}}}},{kind:`block`,type:`list_get_sublist_v1`,inputs:{START:{shadow:{type:`math_number_v1`,fields:{NUM:1}}},END:{shadow:{type:`math_number_v1`,fields:{NUM:1}}}}},{kind:`label`,text:`%{BKY_LABEL_SET}`},{kind:`block`,type:`list_set_v1`,inputs:{AT:{shadow:{type:`math_number_v1`,fields:{NUM:1}}}}},{kind:`block`,type:`list_delete_v1`,inputs:{AT:{shadow:{type:`math_number_v1`,fields:{NUM:1}}}}},{kind:`block`,type:`list_join_v1`,inputs:{DELIM:{shadow:{type:`text_v1`,fields:{TEXT:``}}}}},{kind:`block`,type:`list_reverse_v1`}]},La={kind:`category`,name:`%{BKY_CATEGORY_LOGIC}`,categorystyle:`logic_category`,contents:[{kind:`label`,text:`%{BKY_LABEL_BOOLEAN}`},{kind:`block`,type:`logic_boolean_v1`},{kind:`label`,text:`%{BKY_LABEL_BRANCH}`},{kind:`block`,type:`logic_if_v1`},{kind:`label`,text:`%{BKY_LABEL_LOGIC_OPERATION}`},{kind:`block`,type:`logic_compare_v1`},{kind:`block`,type:`logic_operation_v1`},{kind:`block`,type:`logic_negate_v1`},{kind:`block`,type:`logic_ternary_v1`}]},Ra={kind:`category`,name:`%{BKY_CATEGORY_LOOP}`,categorystyle:`loop_category`,contents:[{kind:`block`,type:`repeat_v1`,inputs:{TIMES:{shadow:{type:`math_number_v1`,fields:{NUM:10}}}}},{kind:`block`,type:`while_until_v1`},{kind:`block`,type:`for_v1`,inputs:{FROM:{shadow:{type:`math_number_v1`,fields:{NUM:1}}},TO:{shadow:{type:`math_number_v1`,fields:{NUM:10}}},BY:{shadow:{type:`math_number_v1`,fields:{NUM:1}}}}},{kind:`block`,type:`for_each_v1`},{kind:`block`,type:`flow_control_v1`}]},za={kind:`category`,name:`%{BKY_CATEGORY_MATH}`,categorystyle:`math_category`,contents:[{kind:`label`,text:`%{BKY_LABEL_VALUE}`},{kind:`block`,type:`math_number_v1`,fields:{NUM:0}},{kind:`block`,type:`math_constant_v1`},{kind:`block`,type:`math_random_float_v1`},{kind:`block`,type:`math_random_int_v1`,inputs:{FROM:{shadow:{type:`math_number_v1`,fields:{NUM:1}}},TO:{shadow:{type:`math_number_v1`,fields:{NUM:100}}}}},{kind:`label`,text:`%{BKY_LABEL_MATH_OPERATION}`},{kind:`block`,type:`math_arithmetic_v1`,inputs:{A:{shadow:{type:`math_number_v1`,fields:{NUM:1}}},B:{shadow:{type:`math_number_v1`,fields:{NUM:1}}}}},{kind:`block`,type:`math_round_v1`,inputs:{NUM:{shadow:{type:`math_number_v1`,fields:{NUM:3.1}}}}},{kind:`block`,type:`math_single_v1`,inputs:{NUM:{shadow:{type:`math_number_v1`,fields:{NUM:9}}}}},{kind:`block`,type:`math_trig_v1`,inputs:{NUM:{shadow:{type:`math_number_v1`,fields:{NUM:45}}}}},{kind:`block`,type:`math_modulo_v1`,inputs:{DIVIDEND:{shadow:{type:`math_number_v1`,fields:{NUM:64}}},DIVISOR:{shadow:{type:`math_number_v1`,fields:{NUM:10}}}}},{kind:`block`,type:`math_number_property_v1`,inputs:{NUM:{shadow:{type:`math_number_v1`,fields:{NUM:2}}}}},{kind:`block`,type:`math_on_list_v1`}]},Ba={kind:`category`,name:`%{BKY_CATEGORY_OBJECT}`,categorystyle:`object_category`,contents:[{kind:`label`,text:`%{BKY_LABEL_OBJECT}`},{kind:`block`,type:`object_create_v1`},{kind:`block`,type:`object_from_json_v1`},{kind:`block`,type:`object_to_json_v1`},{kind:`label`,text:`%{BKY_LABEL_PROPERTY}`},{kind:`block`,type:`object_get_v1`,inputs:{KEY:{shadow:{type:`text_v1`,fields:{TEXT:``}}}}},{kind:`block`,type:`object_set_v1`,inputs:{KEY:{shadow:{type:`text_v1`,fields:{TEXT:``}}}}},{kind:`block`,type:`object_delete_v1`,inputs:{KEY:{shadow:{type:`text_v1`,fields:{TEXT:``}}}}}]},Va={kind:`category`,name:`%{BKY_CATEGORY_TEXT}`,categorystyle:`text_category`,contents:[{kind:`label`,text:`%{BKY_LABEL_TEXT}`},{kind:`block`,type:`text_v1`},{kind:`block`,type:`text_join_v1`,extraState:{itemCount:2}},{kind:`label`,text:`%{BKY_LABEL_GET}`},{kind:`block`,type:`text_is_empty_v1`},{kind:`block`,type:`text_length_v1`},{kind:`block`,type:`text_char_at_v1`,inputs:{AT:{shadow:{type:`math_number_v1`,fields:{NUM:1}}}}},{kind:`block`,type:`text_substring_v1`,inputs:{START:{shadow:{type:`math_number_v1`,fields:{NUM:1}}},END:{shadow:{type:`math_number_v1`,fields:{NUM:1}}}}},{kind:`block`,type:`text_index_of_v1`,inputs:{SUBSTR:{shadow:{type:`text_v1`,fields:{TEXT:``}}}}},{kind:`block`,type:`text_count_v1`,inputs:{SUBSTR:{shadow:{type:`text_v1`,fields:{TEXT:``}}}}},{kind:`label`,text:`%{BKY_LABEL_SET}`},{kind:`block`,type:`text_append_v1`,inputs:{TEXT:{shadow:{type:`text_v1`,fields:{TEXT:``}}}}},{kind:`block`,type:`text_replace_v1`,inputs:{FROM:{shadow:{type:`text_v1`,fields:{TEXT:``}}},TO:{shadow:{type:`text_v1`,fields:{TEXT:``}}}}},{kind:`block`,type:`text_split_v1`,inputs:{DELIM:{shadow:{type:`text_v1`,fields:{TEXT:``}}}}},{kind:`block`,type:`text_change_case_v1`},{kind:`block`,type:`text_trim_v1`},{kind:`block`,type:`text_reverse_v1`}]},Ha={kind:`category`,name:`%{BKY_CATEGORY_TIME}`,categorystyle:`time_category`,contents:[{kind:`block`,type:`create_timer_v1`},{kind:`block`,type:`delay_v1`,inputs:{DURATION:{shadow:{type:`math_number_v1`,fields:{NUM:1e3}}}}}]},Ua={kind:`categoryToolbox`,contents:[{kind:`category`,name:`%{BKY_CATEGORY_COMP}`,categorystyle:`misc_category`,custom:aa.name},{kind:`category`,name:`%{BKY_CATEGORY_MESSAGE}`,categorystyle:`misc_category`,custom:la.name},{kind:`category`,name:`%{BKY_CATEGORY_MISC}`,categorystyle:`misc_category`,custom:fa.name},Ra,La,za,Va,Ia,Ba,Fa,Ha,{kind:`category`,name:`%{BKY_CATEGORY_VARIABLE}`,categorystyle:`variable_category`,custom:wa.name},{kind:`category`,name:`%{BKY_CATEGORY_PROCEDURE}`,categorystyle:`procedure_category`,custom:xa.name},{kind:`category`,name:`%{BKY_CATEGORY_RESOURCE}`,categorystyle:`resource_category`,custom:va.name},{kind:`category`,name:`%{BKY_CATEGORY_COMPUTE}`,categorystyle:`compute_category`,custom:sa.name}]},Wa={kind:`categoryToolbox`,contents:[{kind:`category`,name:`%{BKY_CATEGORY_FUNC}`,categorystyle:`func_category`,custom:Ma.name},{kind:`category`,name:`%{BKY_CATEGORY_FLOW}`,categorystyle:`flow_category`,custom:ka.name},{kind:`category`,name:`%{BKY_CATEGORY_DATA}`,categorystyle:`data_category`,custom:Ea.name},{kind:`category`,name:`%{BKY_CATEGORY_MISC}`,categorystyle:`misc_category`,custom:Pa.name},Ra,La,za,Va,Ia,Ba,Fa,{kind:`category`,name:`%{BKY_CATEGORY_VARIABLE}`,categorystyle:`variable_category`,custom:wa.name},{kind:`category`,name:`%{BKY_CATEGORY_PROCEDURE}`,categorystyle:`procedure_category`,custom:xa.name}]},Ga={kind:`categoryToolbox`,contents:[{kind:`category`,name:`%{BKY_CATEGORY_FUNC}`,categorystyle:`func_category`,custom:Ma.name},{kind:`category`,name:`%{BKY_CATEGORY_FLOW}`,categorystyle:`flow_category`,custom:ka.name},{kind:`category`,name:`%{BKY_CATEGORY_DATA}`,categorystyle:`data_category`,custom:Ea.name},{kind:`category`,name:`%{BKY_CATEGORY_MISC}`,categorystyle:`misc_category`,custom:Pa.name},Ra,La,za,Va,Ia,Ba,Fa,{kind:`category`,name:`%{BKY_CATEGORY_VARIABLE}`,categorystyle:`variable_category`,custom:wa.name},{kind:`category`,name:`%{BKY_CATEGORY_PROCEDURE}`,categorystyle:`procedure_category`,custom:xa.name}]},Ka={kind:`categoryToolbox`,contents:[{kind:`category`,name:`%{BKY_CATEGORY_JSON}`,colour:`330`,contents:[{kind:`block`,type:`json_map_v1`},{kind:`block`,type:`json_array_v1`},{kind:`block`,type:`json_string_v1`},{kind:`block`,type:`json_number_v1`},{kind:`block`,type:`json_boolean_v1`}]}]},qa={kind:`categoryToolbox`,contents:[{kind:`category`,name:`%{BKY_CATEGORY_PAGE}`,categorystyle:`misc_category`,custom:ga.name},{kind:`category`,name:`%{BKY_CATEGORY_MESSAGE}`,categorystyle:`misc_category`,custom:la.name},{kind:`category`,name:`%{BKY_CATEGORY_MISC}`,categorystyle:`misc_category`,custom:fa.name},Ra,La,za,Va,Ia,Ba,Fa,Ha,{kind:`category`,name:`%{BKY_CATEGORY_VARIABLE}`,categorystyle:`variable_category`,custom:wa.name},{kind:`category`,name:`%{BKY_CATEGORY_PROCEDURE}`,categorystyle:`procedure_category`,custom:xa.name},{kind:`category`,name:`%{BKY_CATEGORY_RESOURCE}`,categorystyle:`resource_category`,custom:va.name},{kind:`category`,name:`%{BKY_CATEGORY_COMPUTE}`,categorystyle:`compute_category`,custom:sa.name}]},Ja={grid:{length:2,snap:!0,spacing:20},maxInstances:{func_entry_v1:1},media:`/media/`,move:{drag:!0,scrollbars:!0,wheel:!0},readOnly:!1,theme:`light`,trashcan:!1,zoom:{maxScale:1,minScale:.1,scaleSpeed:1.25,startScale:1,wheel:!0}};function Ya(e,t,n,r){Ja.theme=r?`dark`:`light`,Ja.toolbox=Xa(t,n);let i=o(e,Ja);return i.addChangeListener(e=>{if(e.type===`state_change`){let e=i.getAllBlocks();for(let t of e){let e=t;e.checkWarning_&&e.checkWarning_()}}setTimeout(()=>{(0,Qi.shadowBlockConversionChangeListener)(e)},0)}),Za(i,t,n),Qa(i),i}function Xa(e,t){let n;return e===`page`?t===`v1`&&(n=qa):e===`comp`?t===`v1`&&(n=Ua):e===`func`?t===`v1`&&(n=Ga):e===`flow`?t===`v1`&&(n=Wa):e===`json`&&t===`v1`&&(n=Ka),console.assert(!!n,`invalid toolbox type=${e} version=${t}`),n}function Za(e,t,n){function r({name:n,callback:r}){e.registerToolboxCategoryCallback(n,()=>r(t))}t===`page`?n===`v1`&&(r(ga),r(la),r(fa),r(wa),r(xa),r(va),r(sa)):t===`comp`?n===`v1`&&(r(aa),r(la),r(fa),r(wa),r(xa),r(va),r(sa)):t===`func`?n===`v1`&&(r(Ma),r(ka),r(Ea),r(Pa),r(wa),r(xa)):t===`flow`&&n===`v1`&&(r(Ma),r(ka),r(Ea),r(Pa),r(wa),r(xa))}function Qa(e){let{router:t}=je;e.registerButtonCallback(`NO_COMPUTE`,()=>{let e=t.resolve({path:`/compute/`+Date.now()});setTimeout(()=>{window.open(e.href,`_blank`)},100)}),e.registerButtonCallback(`NO_TABLE`,()=>{let e=t.resolve({path:`/data/`+Date.now()});setTimeout(()=>{window.open(e.href,`_blank`)},100)})}const $a={class:`position-relative w-100 h-100`};var eo=gt({__name:`index`,props:yt({type:{type:String,required:!0},version:{type:String,required:!0},locale:{type:String,required:!0},dark:{type:Boolean,required:!0}},{lock:{type:Boolean,required:!0},lockModifiers:{},scale:{type:Number,required:!0},scaleModifiers:{}}),emits:yt([`ready`],[`update:lock`,`update:scale`]),setup(e,{expose:t,emit:n}){let{backgroundColor2:r}=Fe(),i=Mt(e,`lock`),a=Mt(e,`scale`),o=n,s=`blocklyEditor${jt()}`,c=Et(),u=Nt(`parentContainer`),ee=Nt(`clean`),te=Nt(`navigator`),d={};Li(d);let f=Et(!0),ne=Et(!1),p=E(()=>e.type===`json`?`tree`:`list`),re=E(()=>({width:`100%`,height:`calc(100% - 48px)`})),m=E(()=>({position:`absolute`,background:r.value,bottom:`0px`,width:`100%`,height:`48px`})),h=E(()=>({position:`absolute`,background:e.dark?`#0000007f`:`#ffffff7f`,top:`1px`,left:`0px`,width:`56px`,height:`calc(100% - 49px)`,zIndex:999})),ie=E(()=>({position:`absolute`,top:`0px`,right:`0px`,zIndex:20})),ae=E(()=>({position:`absolute`,background:e.dark?`#0000007f`:`#ffffff7f`,top:`0px`,left:`0px`,width:`100%`,height:`calc(100% - 48px)`,pointerEvents:`none`})),oe=E(()=>({position:`absolute`,background:e.dark?`#0000007f`:`#ffffff7f`,top:`1px`,left:`0px`,width:`56px`,height:`calc(100% - 49px)`,zIndex:999})),ce=E(()=>({position:`fixed`,top:0,left:0,zIndex:3e3})),{open:ue}=Le(`blocklyEditorFlyout${jt()}`);Ct(async()=>{if(!c.value||!u.value){console.assert(!1);return}se(u.value),await Vt(e.locale),d.workspace=Ya(c.value,e.type,e.version,e.dark),d.workspace.addChangeListener(x.disableOrphans),d.workspace.addChangeListener(de);let t=document.querySelector(`#${s} .blocklyFlyout`);new MutationObserver(e=>{e.forEach(e=>{e.type===`attributes`&&e.attributeName===`style`&&(ue.value=d.workspace.getFlyout().isVisible())})}).observe(t,{attributes:!0}),ue.value=d.workspace.getFlyout().isVisible(),ge(),_e(),await xt(),o(`ready`)}),St(()=>{ue.value=!1}),Se(c,()=>{d.workspace&&le(d.workspace)});async function de(e){if(e.type===x.FINISHED_LOADING){Ei(),setTimeout(()=>{te.value?.update()},0),f.value=!1;return}if(!f.value){if(e.type===x.VIEWPORT_CHANGE){a.value=d.workspace.getScale();return}e.type===x.BLOCK_DRAG&&(e.isStart?ne.value=!0:ne.value=!1),setTimeout(()=>{te.value?.update()},0)}}let fe=t=>{f.value=!0,e.type===`json`?Bi(t,d.workspace):l.workspaces.load(t,d.workspace)},pe=()=>e.type===`json`?Vi(d.workspace):l.workspaces.save(d.workspace),me=e=>{l.blocks.append(e,d.workspace)},_=()=>{if(e.type===`json`)console.assert(!1);else return g.workspaceToCode(d.workspace)},he=()=>Fi(d.workspace),ge=()=>{d.workspace.setIsReadOnly(i.value),d.workspace.isReadOnly()&&(ue.value=!1)},_e=()=>{d.workspace.setScale(a.value)},ve=()=>{x.fire(new(x.get(`state_change`))(d.workspace))},ye=()=>{ee.value?.cleanWorkspace()},be=()=>{i.value=!i.value},xe=()=>{te.value&&(te.value.open=!0)};return Ct(()=>{Ae.on(`cleanWorkspace`,ye),Ae.on(`toggleBlocklyLock`,be),Ae.on(`openBlocklyNavigator`,xe)}),St(()=>{Ae.off(`cleanWorkspace`,ye),Ae.off(`toggleBlocklyLock`,be),Ae.off(`openBlocklyNavigator`,xe)}),Pt(()=>e.locale,e=>{Vt(e)}),Pt(()=>e.dark,e=>{ki(e?`dark`:`light`)}),Pt(ue,e=>{e||d.workspace?.hideChaff()}),Pt(i,()=>{ge()}),Pt(a,()=>{_e()}),t({loading:f,load:fe,save:pe,appendBlock:me,generateCode:_,generateReactivity:he,fireStateChange:ve}),(e,t)=>{let n=N(`v-icon`),r=N(`x-loading`);return M(),O(`div`,$a,[k(`div`,{id:s,ref_key:`blocklyDiv`,ref:c,style:j(re.value)},null,4),k(`div`,{style:j(m.value)},[Ot(e.$slots,`bottom`)],4),ne.value?(M(),O(`div`,{key:0,class:`d-flex flex-column justify-center align-center`,style:j(h.value)},[A(n,{icon:`mdi-delete`,size:`x-large`})],4)):ht(`v-if`,!0),f.value?ht(`v-if`,!0):(M(),O(`div`,{key:1,class:`d-flex align-end ga-3 pt-3 pr-3`,style:j(ie.value)},[A(zi,{ref_key:`clean`,ref:ee,lock:i.value},null,8,[`lock`]),A(Hi,{modelValue:i.value,"onUpdate:modelValue":t[0]||(t[0]=e=>i.value=e)},null,8,[`modelValue`]),A(Zi,{ref_key:`navigator`,ref:te,lock:i.value,type:p.value},null,8,[`lock`,`type`])],4)),i.value?(M(),O(`div`,{key:2,style:j(oe.value)},null,4)):ht(`v-if`,!0),i.value?(M(),O(`div`,{key:3,style:j(ae.value)},null,4)):ht(`v-if`,!0),k(`div`,{ref_key:`parentContainer`,ref:u,style:j(ce.value)},null,4),A(r,{open:f.value,"z-index":99},null,8,[`open`])])}}}),to=gt({__name:`index`,props:{code:{type:String,required:!0}},setup(e){we.registerLanguage(`javascript`,Ee);let t=xe.component,{backgroundColor2:n}=Fe();return(r,i)=>{let a=N(`v-sheet`);return M(),D(a,{color:P(n),height:`100%`,width:`100%`},{default:Ft(()=>[A(P(t),{code:e.code,language:`js`},null,8,[`code`])]),_:1},8,[`color`])}}});const no={class:`text-body-large`},ro={class:`w-100 h-100 overflow-auto`};var io=gt({__name:`index`,setup(e){let{t}=zt(),{sysBarAvail:n}=Ie(),{backgroundColor0:r,backgroundColor2:i}=Fe(),a=Et(``),o=E(()=>{let e=48;return n.value&&(e+=24),{position:`relative`,height:`calc(100% - ${e}px)`}}),{open:s}=Le(`sourceDlg`,e=>{a.value=e.code});return(e,c)=>{let l=N(`v-sheet`),u=N(`v-btn`),ee=N(`v-spacer`),te=N(`v-dialog`);return M(),D(te,{modelValue:P(s),"onUpdate:modelValue":c[1]||(c[1]=e=>vt(s)?s.value=e:null),fullscreen:``,"no-click-animation":``,persistent:``,transition:`dialog-bottom-transition`,onKeydown:c[2]||(c[2]=Lt(Rt(e=>s.value=!1,[`stop`,`prevent`]),[`esc`]))},{default:Ft(()=>[A(l,{color:P(r),height:`100%`,width:`100%`},{default:Ft(()=>[P(n)?(M(),D(l,{key:0,color:P(i),height:24},null,8,[`color`])):ht(`v-if`,!0),A(l,{class:`d-flex align-center px-2`,color:P(i),height:48},{default:Ft(()=>[A(u,{density:`comfortable`,icon:`mdi-close`,variant:`text`,onClick:c[0]||(c[0]=e=>s.value=!1)}),k(`span`,no,At(P(t)(`x-block-lib.dlg.source.title`)),1),A(ee)]),_:1},8,[`color`]),k(`div`,{style:j(o.value)},[k(`div`,ro,[A(to,{code:a.value},null,8,[`code`])])],4)]),_:1},8,[`color`])]),_:1},8,[`modelValue`])}}});const ao=e=>{e.component(`XBlockly`,eo),e.component(`XSourceDlg`,io)};async function oo(e){if(e===`en`)return(await import(`./i18n-en.fzzizejc.js`).then(e=>e.t)).default;if(e===`zhHans`)return(await import(`./i18n-zhHans.b0wqxx8d.js`).then(e=>e.t)).default;throw Error(`invalid locale=${e}`)}var so={install:ao};export{eo as XBlockly,so as default,tr as getCallMethodInfo,ar as getImplementMethodInfo,W as getNodeInfo,Jn as getOnEventInfo,mr as getPropertyInfo,Zn as getTriggerEventInfo,ao as install,oo as loadLocaleMessageBlock};