x-block-lib 0.11.0 → 0.11.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -1,11 +1,11 @@
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.g11x21ec.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{$ 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=`
2
2
  <block type="parameter_v1">
3
3
  <mutation key="${n}" name="${r}" locale="${i?`TRUE`:`FALSE`}"/>
4
4
  </block>
5
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(`
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||=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}=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__) => {
9
9
  try {
10
10
  ${Le(r,4)}${Le(i,2)} } catch (e) {
11
11
  __messageV1__('error', e);
@@ -161,10 +161,10 @@ ${t}if (__tx__ && !__success__) {
161
161
  ${t}${t}throw __message__;
162
162
  ${t}}
163
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_||=[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+`) {
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
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 {
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||=e,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}) {
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
168
  ${t}${n} = ${o}[${s}];
169
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
170
  function ${x.FUNCTION_NAME_PLACEHOLDER_}(n) {
@@ -374,4 +374,4 @@ function ${x.FUNCTION_NAME_PLACEHOLDER_}(haystack, needle, replacement) {
374
374
  return haystack.replace(new RegExp(needle, 'g'), replacement);
375
375
  }
376
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();var bi=class extends p.Abstract{isBlank=!0;recordUndo=!1;type=`state_change`;constructor(e){super(),this.workspaceId=e.id}};u.register(u.Type.EVENT,`state_change`,bi);function xi(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 Si(){let e=oe();if(!e)return;let t=e.getTopBlocks(!0)?.[0];t&&xi(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 Ci=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:``}}),wi=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 Ti(e){let t=oe();switch(e){case`light`:t.setTheme(Ci);break;case`dark`:t.setTheme(wi);break}}function Ei(e,t){e.find(e=>e===t)||e.push(t)}const Di=[`get_app_property_v1`,`get_app_state_v1`];function Oi(e){let t=[];function n(e){for(let r of e.getChildren(!0))Di.includes(r.type)&&t.push(r),n(r)}return n(e),t}function ki(e){let t=[];for(let n of e)n.type===`get_app_property_v1`?Ei(t,Xe(`propertyTrigger`,n.property.id)):n.type===`get_app_state_v1`?Ei(t,Xe(`stateTrigger`,n.state.id)):console.assert(!1);return t}function Ai(e){let t=[];for(let n of e){if(n.type!==`app_bind_entry_v1`)continue;let e=n;e.kind===`property`?Ei(t,Xe(`propertyTrigger`,e.property.id)):e.kind===`state`&&Ei(t,Xe(`stateTrigger`,e.state.id))}return t}function ji(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=ki(Oi(e));for(let r of n)t.watchEffect.triggers[r]||(t.watchEffect.triggers[r]=[]),Ei(t.watchEffect.triggers[r],e.id);t.watchEffect.ids.push(e.id)}else if(e.type===`app_bind_v1`){let n=Ai(e.getChildren(!0));t.bind.sets[e.id]=n;for(let r of n)t.bind.triggers[r]||(t.bind.triggers[r]=[]),Ei(t.bind.triggers[r],e.id)}return t}const Mi=Symbol();function Ni(e){Tt(Mi,e)}function Pi(){return _t(Mi)}var Fi=gt({__name:`index`,props:{lock:{type:Boolean,required:!0}},setup(e,{expose:t}){let{t:n}=zt(),r=Bt(),i=Pi(),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 Ii(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 Li(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 Ri=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]||=e=>r.value=!r.value}),null,16,[`icon`])]),_:1},8,[`disabled`,`text`])}}});const zi={class:`d-flex flex-column`},Bi={class:`text-body-large ml-6`},Vi={key:0,class:`text-body-small text-grey text-truncate ml-6`,style:{maxWidth:`340px`}};var Hi=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]||=t=>a(`x-click`,e.id),onMouseout:n[2]||=e=>o.value=!1,onMouseover:n[3]||=e=>o.value=!0},[k(`div`,zi,[k(`span`,Bi,At(e.title),1),e.desc?(M(),O(`span`,Vi,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]||=Rt(()=>{},[`stop`])})],36)),[[c]])}}});const Ui={key:1,class:`text-body-small text-grey`};var Wi=((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=Pi(),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(),Si()},d=async e=>{if(!o.workspace){console.assert(!1);return}let t=o.workspace.getBlockById(e);n.setSelected(t),xi(e),a.value=!1};return(e,t)=>s.value.length>0?(M(),mt(P(xe),{key:0,modelValue:s.value,"onUpdate:modelValue":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(Hi,{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`,Ui,At(P(i)(`x-block-lib.noOption`)),1))}}),[[`__scopeId`,`data-v-x-block-lib-ca7316a0`]]),Gi=gt({__name:`index`,props:{modelValue:{type:Boolean,required:!0},modelModifiers:{}},emits:[`update:modelValue`],setup(e,{expose:t}){let r=Mt(e,`modelValue`),i=Pi();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),xi(e),r.value=!1};return(e,t)=>(M(),O(`div`,{onClick:t[0]||=e=>a(``)},`blockTree`))}});const Ki={class:`text-body-large`};var qi=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]||=e=>vt(u)?u.value=e:null,eager:``,fullscreen:``,"no-click-animation":``,persistent:``,transition:`scroll-x-reverse-transition`,onKeydown: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]||=Rt(e=>u.value=!1,[`self`]),onContextmenu: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]||=e=>u.value=!1}),k(`span`,Ki,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(Wi,{key:0,ref_key:`blockList`,ref:ee,modelValue:P(u),"onUpdate:modelValue":r[1]||=e=>vt(u)?u.value=e:null,lock:e.lock},null,8,[`modelValue`,`lock`])):e.type===`tree`?(M(),mt(Gi,{key:1,ref_key:`blockTree`,ref:d,modelValue:P(u),"onUpdate:modelValue":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]||=e=>u.value=!0}),null,16)]),_:1},8,[`disabled`,`text`])],64)}}}),Ji=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 Yi(e){let t=Z.createElement(`mutation`);for(let{key:n,value:r}of e)t.setAttribute(n,r);return t}function Xi(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 Zi(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 Qi(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 $i(){let{activeObject:e,activeComp:t}=C.app;return!(e.type!==`comp`||!t.meta.states||t.meta.states.length<=0)}function ea(){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`,[Yi([{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`)),$i()&&(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 ta={name:`APP_COMP_CATEGORY`,callback:ea};function na(){let e=[];return e.push(Q(F(`LABEL_FUNC`))),e.push(Q(F(`LABEL_FLOW`))),e}const ra={name:`APP_COMPUTE_CATEGORY`,callback:na};function ia(){let e=[];return e.push($(`app_debug_trace_v1`,[Xi(`OBJECT`)])),e.push($(`popup_message_v1`,[Xi(`TEXT`)])),e.push($(`open_confirm_dlg_v1`)),e.push($(`open_prompt_dlg_v1`)),e}const aa={name:`APP_MESSAGE_CATEGORY`,callback:ia};function oa(){for(let e of C.app.appList)if(e.pages.length>0)return!0;return!1}function sa(){let e=[];return e.push($(`app_env_is_v1`)),oa()&&e.push($(`navigate_to_v1`)),e}const ca={name:`APP_MISC_CATEGORY`,callback:sa};function la(){let{activeObject:e,activePage:t}=C.app;return!(e.type!==`page`||!t.meta.states||t.meta.states.length<=0)}function ua(){let{activeObject:e,activePage:t}=C.app;return!(e.type!==`page`||!t.meta.arguments||t.meta.arguments.length<=0)}function da(){let e=[];return e.push(Q(F(`LABEL_EVENT`))),U(`onEvent`)&&e.push($(`on_app_event_v1`)),e.push($(`app_bind_v1`,[Yi([{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`)),la()&&(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`))),ua()&&(e.push(Q(F(`LABEL_ARGUMENT`))),e.push($(`get_page_argument_v1`))),e}const fa={name:`APP_PAGE_CATEGORY`,callback:da};function pa(){let e=[];return e.push(Q(F(`LABEL_RESOURCE`))),e.push($(`upload_resource_v1`)),e}const ma={name:`APP_RESOURCE_CATEGORY`,callback:pa},ha=e.xml;function ga(){let e=[];{let t=ha.createElement(`label`);t.setAttribute(`text`,`%{BKY_LABEL_PROCEDURE}`),e.push(t)}{let t=ha.createElement(`block`);t.setAttribute(`type`,`procedure_def_v1`);{let e=ha.createElement(`field`);e.setAttribute(`name`,`NAME`);let n=ha.createTextNode(F(`PROCEDURE_DEFAULT_NAME`));e.appendChild(n),t.appendChild(e)}e.push(t)}{let t=ha.createElement(`block`);t.setAttribute(`type`,`procedure_return_v1`),e.push(t)}return e}const _a={name:`PROCEDURE_CATEGORY`,callback:ga},va=e.xml;function ya(){let e=oe(),t=[];{let e=va.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=va.createElement(`label`);e.setAttribute(`text`,F(`LABEL_CREATED`)),t.push(e)}return n.forEach(e=>{{let n=va.createElement(`block`);n.setAttribute(`type`,`variable_get_v1`),n.appendChild(d.generateVariableFieldDom(e)),t.push(n)}{let n=va.createElement(`block`);n.setAttribute(`type`,`variable_set_v1`),n.appendChild(d.generateVariableFieldDom(e)),t.push(n)}}),t}const ba={name:`VARIABLE_CATEGORY`,callback:ya};function xa(){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`,[Xi(`VALUE`)])),e.push(Q(F(`LABEL_CONDITION`))),e.push($(`cond_logic_v1`)),e.push($(`cond_atomic_v1`,[Xi(`VALUE`)])),e.push(Q(F(`LABEL_QUERY_EXTRA`))),e.push($(`query_extra_limit_v1`,[Zi(`OFFSET`,0),Zi(`LIMIT`,1)])),e.push($(`query_extra_sortby_v1`,[Xi(`COLUMN`),Qi(`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 Sa={name:`COMPUTE_DATA_CATEGORY`,callback:xa};function Ca(){return Er(`flow`).length>0}function wa(){let e=[];return C.compute.activeObject.type===`flow`&&e.push($(`on_flow_state_event_v1`)),Ca()&&console.assert(!0),e}const Ta={name:`COMPUTE_FLOW_CATEGORY`,callback:wa};function Ea(){return Er(`func`).length>0}function Da(){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`))),Ea()&&n.push($(`call_func_internal_v1`)),n}const Oa={name:`COMPUTE_FUNC_CATEGORY`,callback:Da};function ka(){let e=[];return e.push($(`compute_debug_trace_v1`,[Xi(`OBJECT`)])),e}const Aa={name:`COMPUTE_MISC_CATEGORY`,callback:ka},ja={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}}}}}]},Ma={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`}]},Na={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`}]},Pa={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`}]},Fa={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`}]},Ia={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:``}}}}}]},La={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`}]},Ra={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}}}}}]},za={kind:`categoryToolbox`,contents:[{kind:`category`,name:`%{BKY_CATEGORY_COMP}`,categorystyle:`misc_category`,custom:ta.name},{kind:`category`,name:`%{BKY_CATEGORY_MESSAGE}`,categorystyle:`misc_category`,custom:aa.name},{kind:`category`,name:`%{BKY_CATEGORY_MISC}`,categorystyle:`misc_category`,custom:ca.name},Pa,Na,Fa,La,Ma,Ia,ja,Ra,{kind:`category`,name:`%{BKY_CATEGORY_VARIABLE}`,categorystyle:`variable_category`,custom:ba.name},{kind:`category`,name:`%{BKY_CATEGORY_PROCEDURE}`,categorystyle:`procedure_category`,custom:_a.name},{kind:`category`,name:`%{BKY_CATEGORY_RESOURCE}`,categorystyle:`resource_category`,custom:ma.name},{kind:`category`,name:`%{BKY_CATEGORY_COMPUTE}`,categorystyle:`compute_category`,custom:ra.name}]},Ba={kind:`categoryToolbox`,contents:[{kind:`category`,name:`%{BKY_CATEGORY_FUNC}`,categorystyle:`func_category`,custom:Oa.name},{kind:`category`,name:`%{BKY_CATEGORY_FLOW}`,categorystyle:`flow_category`,custom:Ta.name},{kind:`category`,name:`%{BKY_CATEGORY_DATA}`,categorystyle:`data_category`,custom:Sa.name},{kind:`category`,name:`%{BKY_CATEGORY_MISC}`,categorystyle:`misc_category`,custom:Aa.name},Pa,Na,Fa,La,Ma,Ia,ja,{kind:`category`,name:`%{BKY_CATEGORY_VARIABLE}`,categorystyle:`variable_category`,custom:ba.name},{kind:`category`,name:`%{BKY_CATEGORY_PROCEDURE}`,categorystyle:`procedure_category`,custom:_a.name}]},Va={kind:`categoryToolbox`,contents:[{kind:`category`,name:`%{BKY_CATEGORY_FUNC}`,categorystyle:`func_category`,custom:Oa.name},{kind:`category`,name:`%{BKY_CATEGORY_FLOW}`,categorystyle:`flow_category`,custom:Ta.name},{kind:`category`,name:`%{BKY_CATEGORY_DATA}`,categorystyle:`data_category`,custom:Sa.name},{kind:`category`,name:`%{BKY_CATEGORY_MISC}`,categorystyle:`misc_category`,custom:Aa.name},Pa,Na,Fa,La,Ma,Ia,ja,{kind:`category`,name:`%{BKY_CATEGORY_VARIABLE}`,categorystyle:`variable_category`,custom:ba.name},{kind:`category`,name:`%{BKY_CATEGORY_PROCEDURE}`,categorystyle:`procedure_category`,custom:_a.name}]},Ha={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`}]}]},Ua={kind:`categoryToolbox`,contents:[{kind:`category`,name:`%{BKY_CATEGORY_PAGE}`,categorystyle:`misc_category`,custom:fa.name},{kind:`category`,name:`%{BKY_CATEGORY_MESSAGE}`,categorystyle:`misc_category`,custom:aa.name},{kind:`category`,name:`%{BKY_CATEGORY_MISC}`,categorystyle:`misc_category`,custom:ca.name},Pa,Na,Fa,La,Ma,Ia,ja,Ra,{kind:`category`,name:`%{BKY_CATEGORY_VARIABLE}`,categorystyle:`variable_category`,custom:ba.name},{kind:`category`,name:`%{BKY_CATEGORY_PROCEDURE}`,categorystyle:`procedure_category`,custom:_a.name},{kind:`category`,name:`%{BKY_CATEGORY_RESOURCE}`,categorystyle:`resource_category`,custom:ma.name},{kind:`category`,name:`%{BKY_CATEGORY_COMPUTE}`,categorystyle:`compute_category`,custom:ra.name}]},Wa={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 Ga(e,t,n,r){Wa.theme=r?`dark`:`light`,Wa.toolbox=Ka(t,n);let i=ee(e,Wa);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,Ji.shadowBlockConversionChangeListener)(e)},0)}),qa(i,t,n),Ja(i),i}function Ka(e,t){let n;return e===`page`?t===`v1`&&(n=Ua):e===`comp`?t===`v1`&&(n=za):e===`func`?t===`v1`&&(n=Va):e===`flow`?t===`v1`&&(n=Ba):e===`json`&&t===`v1`&&(n=Ha),console.assert(!!n,`invalid toolbox type=${e} version=${t}`),n}function qa(e,t,n){function r({name:n,callback:r}){e.registerToolboxCategoryCallback(n,()=>r(t))}t===`page`?n===`v1`&&(r(fa),r(aa),r(ca),r(ba),r(_a),r(ma),r(ra)):t===`comp`?n===`v1`&&(r(ta),r(aa),r(ca),r(ba),r(_a),r(ma),r(ra)):t===`func`?n===`v1`&&(r(Oa),r(Ta),r(Sa),r(Aa),r(ba),r(_a)):t===`flow`&&n===`v1`&&(r(Oa),r(Ta),r(Sa),r(Aa),r(ba),r(_a))}function Ja(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 Ya={class:`position-relative w-100 h-100`};var Xa=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={};Ni(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=Ga(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){Si(),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`?Ii(t,d.workspace):g.workspaces.load(t,d.workspace)},fe=()=>e.type===`json`?Li(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=()=>ji(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=>{Ti(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`,Ya,[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(Fi,{ref_key:`clean`,ref:u,lock:i.value},null,8,[`lock`]),A(Ri,{modelValue:i.value,"onUpdate:modelValue":t[0]||=e=>i.value=e},null,8,[`modelValue`]),A(qi,{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`])])}}}),Za=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 Qa={class:`text-body-large`},$a={class:`w-100 h-100 overflow-auto`};var eo=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]||=e=>vt(s)?s.value=e:null,fullscreen:``,"no-click-animation":``,persistent:``,transition:`dialog-bottom-transition`,onKeydown: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]||=e=>s.value=!1}),k(`span`,Qa,At(P(t)(`x-block-lib.dlg.source.title`)),1),A(ee)]),_:1},8,[`color`]),k(`div`,{style:j(o.value)},[k(`div`,$a,[A(Za,{code:a.value},null,8,[`code`])])],4)]),_:1},8,[`color`])]),_:1},8,[`modelValue`])}}});const to=e=>{e.component(`XBlockly`,Xa),e.component(`XSourceDlg`,eo)};async function no(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 ro={install:to};export{Xa as XBlockly,ro as default,tr as getCallMethodInfo,ar as getImplementMethodInfo,W as getNodeInfo,Jn as getOnEventInfo,mr as getPropertyInfo,Zn as getTriggerEventInfo,to as install,no as loadLocaleMessageBlock};
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};