x-block-lib 0.3.4 → 0.3.19

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,9 +1,9 @@
1
1
  (function(){"use strict";try{if(typeof document<"u"){var e=document.createElement("style");e.id="x-block-lib",e.appendChild(document.createTextNode(".blocklyToolboxDiv{overflow-x:hidden;width:56px}")),document.head.appendChild(e)}}catch(d){console.error("vite-plugin-css-injected-by-js",d)}})();
2
- import { defineComponent as F, ref as A, onMounted as D, nextTick as N, onBeforeUnmount as M, watch as k, resolveDirective as V, openBlock as U, createElementBlock as Y, withDirectives as G, createElementVNode as W } from "vue";
3
- import { useLocale as H, useTheme as z } from "vuetify";
4
- import { openConfirmDlg as X, openPromptDlg as J, useViewStack as j } from "x-essential-lib";
5
- import { d as g, j as $, O as q, E as p, u as c, M as f, C as Q, a as y, b as B, s as Z, S as u, c as S, g as h, i as b, e as T, f as O, h as d, k as v, G as L, B as ee, T as C, l as P, m as te, n as oe, o as ne } from "./blockly-gskixv9t.js";
6
- g([
2
+ import { defineComponent as A, ref as N, onMounted as D, onBeforeUnmount as M, watch as C, resolveDirective as V, openBlock as U, createElementBlock as Y, withDirectives as G, createElementVNode as W } from "vue";
3
+ import { storeToRefs as H } from "pinia";
4
+ import { openConfirmDlg as z, openPromptDlg as X, useGlobalStore as J, useViewStack as j } from "x-essential-lib";
5
+ import { d as h, j as $, O as q, E as p, u as i, M as f, C as Q, a as d, b as R, s as Z, S as u, c as L, g as O, i as m, e as I, f as b, h as g, k as B, G as v, B as ee, T as k, l as x, m as te, n as oe, o as ne } from "./blockly-kru4jhu1.js";
6
+ h([
7
7
  {
8
8
  type: "boolean_v1",
9
9
  message0: "%1",
@@ -32,7 +32,7 @@ const re = {
32
32
  mutationToDom: function() {
33
33
  if (this.elseIfCount_ <= 0 && !this.hasElse_)
34
34
  return null;
35
- const t = c.xml.createElement("mutation");
35
+ const t = i.xml.createElement("mutation");
36
36
  return this.elseIfCount_ > 0 && t.setAttribute("elseIf", String(this.elseIfCount_)), this.hasElse_ && t.setAttribute("else", "TRUE"), t;
37
37
  },
38
38
  domToMutation: function(t) {
@@ -50,23 +50,23 @@ const re = {
50
50
  decompose: function(t) {
51
51
  const e = t.newBlock("if_if_v1");
52
52
  e.initSvg();
53
- let o = e.nextConnection;
54
- for (let n = 0; n < this.elseIfCount_; n++) {
53
+ let n = e.nextConnection;
54
+ for (let o = 0; o < this.elseIfCount_; o++) {
55
55
  const r = t.newBlock(
56
56
  "if_else_if_v1"
57
57
  );
58
- r.initSvg(), o.connect(r.previousConnection), o = r.nextConnection;
58
+ r.initSvg(), n.connect(r.previousConnection), n = r.nextConnection;
59
59
  }
60
60
  if (this.hasElse_) {
61
- const n = t.newBlock("if_else_v1");
62
- n.initSvg(), o.connect(n.previousConnection);
61
+ const o = t.newBlock("if_else_v1");
62
+ o.initSvg(), n.connect(o.previousConnection);
63
63
  }
64
64
  return e;
65
65
  },
66
66
  compose: function(t) {
67
67
  let e = t.nextConnection.targetBlock();
68
68
  this.elseIfCount_ = 0, this.hasElse_ = !1;
69
- const o = [null], n = [null];
69
+ const n = [null], o = [null];
70
70
  let r = null;
71
71
  for (; e; ) {
72
72
  if (e.isInsertionMarker()) {
@@ -75,9 +75,9 @@ const re = {
75
75
  }
76
76
  switch (e.type) {
77
77
  case "if_else_if_v1":
78
- this.elseIfCount_++, o.push(
78
+ this.elseIfCount_++, n.push(
79
79
  e.valueConnection_
80
- ), n.push(
80
+ ), o.push(
81
81
  e.statementConnection_
82
82
  );
83
83
  break;
@@ -90,13 +90,13 @@ const re = {
90
90
  e = e.getNextBlock();
91
91
  }
92
92
  this.updateShape_(), this.reconnectChildBlocks_(
93
- o,
94
93
  n,
94
+ o,
95
95
  r
96
96
  );
97
97
  },
98
98
  saveConnections: function(t) {
99
- let e = t.nextConnection.targetBlock(), o = 1;
99
+ let e = t.nextConnection.targetBlock(), n = 1;
100
100
  for (; e; ) {
101
101
  if (e.isInsertionMarker()) {
102
102
  e = e.getNextBlock();
@@ -104,13 +104,13 @@ const re = {
104
104
  }
105
105
  switch (e.type) {
106
106
  case "if_else_if_v1": {
107
- const n = this.getInput("IF" + o), r = this.getInput("DO" + o);
108
- e.valueConnection_ = n && n.connection.targetConnection, e.statementConnection_ = r && r.connection.targetConnection, o++;
107
+ const o = this.getInput("IF" + n), r = this.getInput("DO" + n);
108
+ e.valueConnection_ = o && o.connection.targetConnection, e.statementConnection_ = r && r.connection.targetConnection, n++;
109
109
  break;
110
110
  }
111
111
  case "if_else_v1": {
112
- const n = this.getInput("ELSE");
113
- e.statementConnection_ = n && n.connection.targetConnection;
112
+ const o = this.getInput("ELSE");
113
+ e.statementConnection_ = o && o.connection.targetConnection;
114
114
  break;
115
115
  }
116
116
  default:
@@ -121,16 +121,16 @@ const re = {
121
121
  },
122
122
  rebuildShape_: function() {
123
123
  const t = [null], e = [null];
124
- let o = null;
125
- this.getInput("ELSE") && (o = this.getInput("ELSE").connection.targetConnection);
126
- for (let n = 1; this.getInput("IF" + n); n++) {
127
- const r = this.getInput("IF" + n), a = this.getInput("DO" + n);
128
- t.push(r.connection.targetConnection), e.push(a.connection.targetConnection);
124
+ let n = null;
125
+ this.getInput("ELSE") && (n = this.getInput("ELSE").connection.targetConnection);
126
+ for (let o = 1; this.getInput("IF" + o); o++) {
127
+ const r = this.getInput("IF" + o), s = this.getInput("DO" + o);
128
+ t.push(r.connection.targetConnection), e.push(s.connection.targetConnection);
129
129
  }
130
130
  this.updateShape_(), this.reconnectChildBlocks_(
131
131
  t,
132
132
  e,
133
- o
133
+ n
134
134
  );
135
135
  },
136
136
  updateShape_: function() {
@@ -141,11 +141,11 @@ const re = {
141
141
  this.appendValueInput("IF" + t).setCheck("Boolean").appendField(f.LOGIC_ELSE_IF), this.appendStatementInput("DO" + t).appendField(f.LOGIC_DO);
142
142
  this.hasElse_ && this.appendStatementInput("ELSE").appendField(f.LOGIC_ELSE);
143
143
  },
144
- reconnectChildBlocks_: function(t, e, o) {
145
- var n, r;
146
- for (let a = 1; a <= this.elseIfCount_; a++)
147
- (n = t[a]) == null || n.reconnect(this, "IF" + a), (r = e[a]) == null || r.reconnect(this, "DO" + a);
148
- o == null || o.reconnect(this, "ELSE");
144
+ reconnectChildBlocks_: function(t, e, n) {
145
+ var o, r;
146
+ for (let s = 1; s <= this.elseIfCount_; s++)
147
+ (o = t[s]) == null || o.reconnect(this, "IF" + s), (r = e[s]) == null || r.reconnect(this, "DO" + s);
148
+ n == null || n.reconnect(this, "ELSE");
149
149
  }
150
150
  };
151
151
  p.registerMutator(
@@ -154,7 +154,7 @@ p.registerMutator(
154
154
  void 0,
155
155
  ["if_else_if_v1", "if_else_v1"]
156
156
  );
157
- g([
157
+ h([
158
158
  {
159
159
  type: "if_v1",
160
160
  message0: "%{BKY_LOGIC_IF} %1",
@@ -206,8 +206,8 @@ const se = {
206
206
  customContextMenu: function(t) {
207
207
  if (this.isInFlyout)
208
208
  return;
209
- const e = this.getField("VAR"), o = e.getVariable(), n = o == null ? void 0 : o.name;
210
- if (!this.isCollapsed() && n) {
209
+ const e = this.getField("VAR"), n = e.getVariable(), o = n == null ? void 0 : n.name;
210
+ if (!this.isCollapsed() && o) {
211
211
  const r = {
212
212
  type: "variables_get",
213
213
  fields: {
@@ -216,7 +216,7 @@ const se = {
216
216
  };
217
217
  t.push({
218
218
  enabled: !0,
219
- text: f.VARIABLES_SET_CREATE_GET.replace("%1", n),
219
+ text: f.VARIABLES_SET_CREATE_GET.replace("%1", o),
220
220
  callback: Q.callbackFactory(this, r)
221
221
  });
222
222
  }
@@ -250,16 +250,16 @@ const ae = /* @__PURE__ */ new Set([
250
250
  },
251
251
  onchange: function(t) {
252
252
  const e = this.workspace;
253
- if (!e.isDragging || e.isDragging() || t.type !== y.BLOCK_MOVE && t.type !== y.BLOCK_CREATE)
253
+ if (!e.isDragging || e.isDragging() || t.type !== d.BLOCK_MOVE && t.type !== d.BLOCK_CREATE)
254
254
  return;
255
- const o = this.getSurroundLoop();
256
- if (console.log(t.type, o), this.setWarningText(
257
- o ? null : f.LOOP_FLOW_CONTROL_WARNING
255
+ const n = this.getSurroundLoop();
256
+ if (console.log(t.type, n), this.setWarningText(
257
+ n ? null : f.LOOP_FLOW_CONTROL_WARNING
258
258
  ), !this.isInFlyout)
259
259
  try {
260
- y.setRecordUndo(!1), this.setDisabledReason(!o, "FLOW_CONTROL_NOT_IN_LOOP");
260
+ d.setRecordUndo(!1), this.setDisabledReason(!n, "FLOW_CONTROL_NOT_IN_LOOP");
261
261
  } finally {
262
- y.setRecordUndo(!0);
262
+ d.setRecordUndo(!0);
263
263
  }
264
264
  }
265
265
  };
@@ -267,7 +267,7 @@ p.registerMixin(
267
267
  "flow_control_in_loop_check_v1",
268
268
  le
269
269
  );
270
- g([
270
+ h([
271
271
  {
272
272
  type: "flow_control_v1",
273
273
  message0: "%1",
@@ -295,7 +295,7 @@ p.register(
295
295
  "VAR"
296
296
  )
297
297
  );
298
- g([
298
+ h([
299
299
  {
300
300
  type: "for_v1",
301
301
  message0: "%{BKY_LOOP_V1_FOR_TITLE}",
@@ -346,7 +346,7 @@ p.register(
346
346
  "VAR"
347
347
  )
348
348
  );
349
- g([
349
+ h([
350
350
  {
351
351
  type: "for_each_v1",
352
352
  message0: "%{BKY_LOOP_V1_FOR_EACH_TITLE}",
@@ -383,7 +383,7 @@ p.register(
383
383
  UNTIL: "%{BKY_LOOP_V1_WHILE_UNTIL_TOOLTIP_UNTIL}"
384
384
  })
385
385
  );
386
- g([
386
+ h([
387
387
  {
388
388
  type: "while_until_v1",
389
389
  message0: "%1 %2",
@@ -416,41 +416,48 @@ g([
416
416
  extensions: ["while_until_tooltip_v1"]
417
417
  }
418
418
  ]);
419
- B.setConfirm(async (t, e) => {
420
- const o = await X({
419
+ R.setConfirm(async (t, e) => {
420
+ const n = await z({
421
421
  title: "",
422
422
  text: t
423
423
  });
424
- e(!!o);
424
+ e(!!n);
425
425
  });
426
- B.setPrompt(async (t, e, o) => {
427
- const n = await J({
426
+ R.setPrompt(async (t, e, n) => {
427
+ const o = await X({
428
428
  title: "",
429
429
  value: e
430
430
  });
431
- o(n);
431
+ n(o);
432
432
  });
433
- const ie = (t, e) => {
433
+ const ie = (t, e, n) => {
434
434
  const o = t[e];
435
- return o ? typeof o == "function" ? o() : Promise.resolve(o) : new Promise((n, r) => {
436
- (typeof queueMicrotask == "function" ? queueMicrotask : setTimeout)(r.bind(null, new Error("Unknown variable dynamic import: " + e)));
435
+ return o ? typeof o == "function" ? o() : Promise.resolve(o) : new Promise((r, s) => {
436
+ (typeof queueMicrotask == "function" ? queueMicrotask : setTimeout)(
437
+ s.bind(
438
+ null,
439
+ new Error(
440
+ "Unknown variable dynamic import: " + e + (e.split("/").length !== n ? ". Note that variables only represent file names one level deep." : "")
441
+ )
442
+ )
443
+ );
437
444
  });
438
445
  };
439
- async function E(t) {
440
- const e = await ie(/* @__PURE__ */ Object.assign({ "./msg/en/index.ts": () => import("./en-c75t6n0y.js"), "./msg/zhHans/index.ts": () => import("./zhHans-dmzotd2n.js") }), `./msg/${t}/index.ts`);
446
+ async function P(t) {
447
+ const e = await ie(/* @__PURE__ */ Object.assign({ "./msg/en/index.ts": () => import("./en-jrrs2wmb.js"), "./msg/zhHans/index.ts": () => import("./zhHans-jrrs2wmb.js") }), `./msg/${t}/index.ts`, 4);
441
448
  Z(e.default);
442
449
  }
443
450
  class ce {
444
- init({ contextMenu: e = !0, shortcut: o = !0 } = {
451
+ init({ contextMenu: e = !0, shortcut: n = !0 } = {
445
452
  contextMenu: !0,
446
453
  shortcut: !0
447
454
  }) {
448
- e && (this.blockCopyToStorageContextMenu(), this.blockPasteFromStorageContextMenu()), o && (u.registry.unregister(
449
- S.names.COPY
455
+ e && (this.blockCopyToStorageContextMenu(), this.blockPasteFromStorageContextMenu()), n && (u.registry.unregister(
456
+ L.names.COPY
450
457
  ), u.registry.unregister(
451
- S.names.CUT
458
+ L.names.CUT
452
459
  ), u.registry.unregister(
453
- S.names.PASTE
460
+ L.names.PASTE
454
461
  ), this.blockCopyToStorageShortcut(), this.blockCutToStorageShortcut(), this.blockPasteFromStorageShortcut());
455
462
  }
456
463
  blockCopyToStorageContextMenu() {
@@ -459,172 +466,172 @@ class ce {
459
466
  return f.CROSS_TAB_COPY ? f.CROSS_TAB_COPY : "Copy";
460
467
  },
461
468
  preconditionFn: function() {
462
- const o = h();
463
- return !o || !b(o) || !o.isDeletable() || !T(o) || !o.isMovable() || !O(o) ? "disabled" : "enabled";
469
+ const n = O();
470
+ return !n || !m(n) || !n.isDeletable() || !I(n) || !n.isMovable() || !b(n) ? "disabled" : "enabled";
464
471
  },
465
- callback: function(o) {
466
- var n;
472
+ callback: function(n) {
473
+ var o;
467
474
  localStorage.setItem(
468
475
  "blocklyStash",
469
- JSON.stringify((n = o.block) == null ? void 0 : n.toCopyData())
476
+ JSON.stringify((o = n.block) == null ? void 0 : o.toCopyData())
470
477
  );
471
478
  },
472
- scopeType: d.ScopeType.BLOCK,
479
+ scopeType: g.ScopeType.BLOCK,
473
480
  id: "blockCopyToStorage",
474
481
  weight: 0
475
482
  };
476
- d.registry.register(e);
483
+ g.registry.register(e);
477
484
  }
478
485
  blockPasteFromStorageContextMenu() {
479
486
  const e = {
480
487
  displayText: function() {
481
488
  return f.CROSS_TAB_PASTE ? f.CROSS_TAB_PASTE : "Paste";
482
489
  },
483
- preconditionFn: function(o) {
484
- var a;
485
- const n = localStorage.getItem("blocklyStash");
486
- if (!n)
490
+ preconditionFn: function(n) {
491
+ var s;
492
+ const o = localStorage.getItem("blocklyStash");
493
+ if (!o)
487
494
  return "disabled";
488
- const r = JSON.parse(n);
489
- return !r || !((a = o.workspace) != null && a.isCapacityAvailable(r.typeCounts)) ? "disabled" : "enabled";
495
+ const r = JSON.parse(o);
496
+ return !r || !((s = n.workspace) != null && s.isCapacityAvailable(r.typeCounts)) ? "disabled" : "enabled";
490
497
  },
491
- callback: function(o) {
492
- const n = localStorage.getItem("blocklyStash");
493
- if (!n)
498
+ callback: function(n) {
499
+ const o = localStorage.getItem("blocklyStash");
500
+ if (!o)
494
501
  return;
495
- const r = JSON.parse(n);
496
- r && o.workspace && v.paste(r, o.workspace);
502
+ const r = JSON.parse(o);
503
+ r && n.workspace && B.paste(r, n.workspace);
497
504
  },
498
- scopeType: d.ScopeType.WORKSPACE,
505
+ scopeType: g.ScopeType.WORKSPACE,
499
506
  id: "blockPasteFromStorage",
500
507
  weight: 0
501
508
  };
502
- d.registry.register(e);
509
+ g.registry.register(e);
503
510
  }
504
511
  blockCopyToStorageShortcut() {
505
512
  const e = u.registry.createSerializedKey(
506
- c.KeyCodes.C,
507
- [c.KeyCodes.CTRL]
508
- ), o = u.registry.createSerializedKey(
509
- c.KeyCodes.C,
510
- [c.KeyCodes.ALT]
513
+ i.KeyCodes.C,
514
+ [i.KeyCodes.CTRL]
511
515
  ), n = u.registry.createSerializedKey(
512
- c.KeyCodes.C,
513
- [c.KeyCodes.META]
516
+ i.KeyCodes.C,
517
+ [i.KeyCodes.ALT]
518
+ ), o = u.registry.createSerializedKey(
519
+ i.KeyCodes.C,
520
+ [i.KeyCodes.META]
514
521
  ), r = {
515
522
  name: "copy",
516
- preconditionFn: function(a) {
517
- if (a.options.readOnly || L.inProgress())
523
+ preconditionFn: function(s) {
524
+ if (s.options.readOnly || v.inProgress())
518
525
  return !1;
519
- const l = h();
520
- return !(!l || !b(l) || !l.isDeletable() || !T(l) || !l.isMovable() || !O(l));
526
+ const a = O();
527
+ return !(!a || !m(a) || !a.isDeletable() || !I(a) || !a.isMovable() || !b(a));
521
528
  },
522
- callback: function(a, l) {
523
- l.preventDefault();
524
- const s = h();
525
- if (!s || !O(s))
529
+ callback: function(s, a) {
530
+ a.preventDefault();
531
+ const l = O();
532
+ if (!l || !b(l))
526
533
  return !1;
527
- const i = s.toCopyData();
528
- return i ? (a.hideChaff(), localStorage.setItem("blocklyStash", JSON.stringify(i)), !0) : !1;
534
+ const c = l.toCopyData();
535
+ return c ? (s.hideChaff(), localStorage.setItem("blocklyStash", JSON.stringify(c)), !0) : !1;
529
536
  },
530
- keyCodes: [e, o, n]
537
+ keyCodes: [e, n, o]
531
538
  };
532
539
  u.registry.register(r);
533
540
  }
534
541
  blockCutToStorageShortcut() {
535
542
  const e = u.registry.createSerializedKey(
536
- c.KeyCodes.X,
537
- [c.KeyCodes.CTRL]
538
- ), o = u.registry.createSerializedKey(
539
- c.KeyCodes.X,
540
- [c.KeyCodes.ALT]
543
+ i.KeyCodes.X,
544
+ [i.KeyCodes.CTRL]
541
545
  ), n = u.registry.createSerializedKey(
542
- c.KeyCodes.X,
543
- [c.KeyCodes.META]
546
+ i.KeyCodes.X,
547
+ [i.KeyCodes.ALT]
548
+ ), o = u.registry.createSerializedKey(
549
+ i.KeyCodes.X,
550
+ [i.KeyCodes.META]
544
551
  ), r = {
545
552
  name: "cut",
546
- preconditionFn: function(a) {
547
- if (a.options.readOnly || L.inProgress())
553
+ preconditionFn: function(s) {
554
+ if (s.options.readOnly || v.inProgress())
548
555
  return !1;
549
- const l = h();
550
- return !(!l || !b(l) || !l.isDeletable() || !T(l) || !l.isMovable() || !O(l) || l.workspace.isFlyout);
556
+ const a = O();
557
+ return !(!a || !m(a) || !a.isDeletable() || !I(a) || !a.isMovable() || !b(a) || a.workspace.isFlyout);
551
558
  },
552
- callback: function(a, l) {
553
- l.preventDefault();
554
- const s = h();
555
- if (!s || !b(s) || !s.isDeletable() || !O(s))
559
+ callback: function(s, a) {
560
+ a.preventDefault();
561
+ const l = O();
562
+ if (!l || !m(l) || !l.isDeletable() || !b(l))
556
563
  return !1;
557
- const i = s.toCopyData();
558
- return i ? (localStorage.setItem("blocklyStash", JSON.stringify(i)), s instanceof ee ? s.checkAndDelete() : s.dispose(), !0) : !1;
564
+ const c = l.toCopyData();
565
+ return c ? (localStorage.setItem("blocklyStash", JSON.stringify(c)), l instanceof ee ? l.checkAndDelete() : l.dispose(), !0) : !1;
559
566
  },
560
- keyCodes: [e, o, n]
567
+ keyCodes: [e, n, o]
561
568
  };
562
569
  u.registry.register(r);
563
570
  }
564
571
  blockPasteFromStorageShortcut() {
565
572
  const e = u.registry.createSerializedKey(
566
- c.KeyCodes.V,
567
- [c.KeyCodes.CTRL]
568
- ), o = u.registry.createSerializedKey(
569
- c.KeyCodes.V,
570
- [c.KeyCodes.ALT]
573
+ i.KeyCodes.V,
574
+ [i.KeyCodes.CTRL]
571
575
  ), n = u.registry.createSerializedKey(
572
- c.KeyCodes.V,
573
- [c.KeyCodes.META]
576
+ i.KeyCodes.V,
577
+ [i.KeyCodes.ALT]
578
+ ), o = u.registry.createSerializedKey(
579
+ i.KeyCodes.V,
580
+ [i.KeyCodes.META]
574
581
  ), r = {
575
582
  name: "paste",
576
- preconditionFn: function(a) {
577
- if (a.options.readOnly || L.inProgress())
583
+ preconditionFn: function(s) {
584
+ if (s.options.readOnly || v.inProgress())
578
585
  return !1;
579
- const l = localStorage.getItem("blocklyStash");
580
- if (!l)
586
+ const a = localStorage.getItem("blocklyStash");
587
+ if (!a)
581
588
  return !1;
582
- const s = JSON.parse(l);
583
- return !(!s || !a.isCapacityAvailable(s.typeCounts));
589
+ const l = JSON.parse(a);
590
+ return !(!l || !s.isCapacityAvailable(l.typeCounts));
584
591
  },
585
- callback: function(a, l) {
586
- l.preventDefault();
587
- const s = localStorage.getItem("blocklyStash");
588
- if (!s)
592
+ callback: function(s, a) {
593
+ a.preventDefault();
594
+ const l = localStorage.getItem("blocklyStash");
595
+ if (!l)
589
596
  return !1;
590
- const i = JSON.parse(s);
591
- return i ? (v.paste(i, a), !0) : !1;
597
+ const c = JSON.parse(l);
598
+ return c ? (B.paste(c, s), !0) : !1;
592
599
  },
593
- keyCodes: [e, o, n]
600
+ keyCodes: [e, n, o]
594
601
  };
595
602
  u.registry.register(r);
596
603
  }
597
604
  }
598
605
  class ue {
599
606
  init() {
600
- const e = d.registry.getItem("cleanWorkspace");
601
- e && (e.callback = function(o) {
602
- const n = o.workspace;
603
- if (!n)
607
+ const e = g.registry.getItem("cleanWorkspace");
608
+ e && (e.callback = function(n) {
609
+ const o = n.workspace;
610
+ if (!o)
604
611
  return;
605
- n.setResizesEnabled(!1), y.setGroup(!0);
606
- const r = n.getTopBlocks(!0);
607
- let a = 0;
608
- for (let l = 0, s; s = r[l]; l++) {
609
- if (!s.isMovable())
612
+ o.setResizesEnabled(!1), d.setGroup(!0);
613
+ const r = o.getTopBlocks(!0);
614
+ let s = 0;
615
+ for (let a = 0, l; l = r[a]; a++) {
616
+ if (!l.isMovable())
610
617
  continue;
611
- const i = s.getRelativeToSurfaceXY();
612
- s.moveBy(-i.x, a - i.y, ["cleanup"]), s.snapToGrid(), a = s.getRelativeToSurfaceXY().y + s.getHeightWidth().height + 100;
618
+ const c = l.getRelativeToSurfaceXY();
619
+ l.moveBy(-c.x, s - c.y, ["cleanup"]), l.snapToGrid(), s = l.getRelativeToSurfaceXY().y + l.getHeightWidth().height + 100;
613
620
  }
614
- y.setGroup(!1), n.setResizesEnabled(!0);
621
+ d.setGroup(!1), o.setResizesEnabled(!0);
615
622
  });
616
623
  }
617
624
  }
618
- function R(t) {
625
+ function K(t) {
619
626
  const e = t.getParent();
620
- return e && R(e) ? !0 : !e && !!(t.outputConnection || t.previousConnection);
627
+ return e && K(e) ? !0 : !e && !!(t.outputConnection || t.previousConnection);
621
628
  }
622
629
  class _e {
623
630
  init() {
624
- const e = d.registry.getItem("blockDisable");
625
- e && (e.preconditionFn = function(o) {
626
- const n = o.block;
627
- return n && !n.isInFlyout && n.workspace.options.disable && n.isEditable() ? n.getInheritedDisabled() || R(n) ? "disabled" : "enabled" : "hidden";
631
+ const e = g.registry.getItem("blockDisable");
632
+ e && (e.preconditionFn = function(n) {
633
+ const o = n.block;
634
+ return o && !o.isInFlyout && o.workspace.options.disable && o.isEditable() ? o.getInheritedDisabled() || K(o) ? "disabled" : "enabled" : "hidden";
628
635
  });
629
636
  }
630
637
  }
@@ -634,7 +641,7 @@ const fe = new ue();
634
641
  fe.init();
635
642
  const ye = new _e();
636
643
  ye.init();
637
- C.Classic.blockStyles = {
644
+ k.Classic.blockStyles = {
638
645
  color_blocks: {
639
646
  colourPrimary: "#a5745b",
640
647
  colourSecondary: "#ede3de",
@@ -708,7 +715,7 @@ C.Classic.blockStyles = {
708
715
  hat: ""
709
716
  }
710
717
  };
711
- C.Classic.categoryStyles = {
718
+ k.Classic.categoryStyles = {
712
719
  calc_category: {
713
720
  colour: "#757575"
714
721
  },
@@ -758,9 +765,9 @@ C.Classic.categoryStyles = {
758
765
  colour: "#a55b80"
759
766
  }
760
767
  };
761
- const de = P.defineTheme("light", {
768
+ const de = x.defineTheme("light", {
762
769
  name: "light",
763
- base: C.Classic,
770
+ base: k.Classic,
764
771
  componentStyles: {
765
772
  workspaceBackgroundColour: "#ffffff",
766
773
  toolboxBackgroundColour: "#eeeeee",
@@ -774,9 +781,9 @@ const de = P.defineTheme("light", {
774
781
  scrollbarOpacity: 0.4,
775
782
  cursorColour: ""
776
783
  }
777
- }), ge = P.defineTheme("dark", {
784
+ }), ge = x.defineTheme("dark", {
778
785
  name: "dark",
779
- base: C.Classic,
786
+ base: k.Classic,
780
787
  componentStyles: {
781
788
  workspaceBackgroundColour: "#1e1e1e",
782
789
  toolboxBackgroundColour: "#272727",
@@ -845,17 +852,18 @@ const Oe = {
845
852
  }, Ce = {
846
853
  kind: "categoryToolbox",
847
854
  contents: [Oe, be]
848
- }, me = { class: "position-relative w-100 h-100" }, ke = /* @__PURE__ */ F({
855
+ }, me = { class: "position-relative w-100 h-100" }, ke = /* @__PURE__ */ A({
849
856
  __name: "index",
850
857
  props: {
851
858
  type: {},
852
- version: {}
859
+ version: {},
860
+ active: { type: Boolean }
853
861
  },
854
862
  emits: ["ready", "change"],
855
863
  setup(t, { emit: e }) {
856
- const o = H(), n = z(), { open: r } = j("blocklyEditorFlyout"), a = t, l = e, s = A(null);
857
- let i;
858
- const I = {
864
+ const n = J(), { locale: o, dark: r } = H(n), { open: s } = j("blocklyEditorFlyout"), a = t, l = e, c = N();
865
+ let y;
866
+ const E = {
859
867
  grid: {
860
868
  length: 2,
861
869
  snap: !0,
@@ -868,7 +876,7 @@ const Oe = {
868
876
  wheel: !0
869
877
  },
870
878
  readOnly: !1,
871
- theme: n.current.value.dark ? "dark" : "light",
879
+ theme: r.value ? "dark" : "light",
872
880
  trashcan: !1,
873
881
  zoom: {
874
882
  maxScale: 1,
@@ -879,43 +887,40 @@ const Oe = {
879
887
  }
880
888
  };
881
889
  D(async () => {
882
- if (!s.value)
890
+ if (!c.value)
883
891
  return;
884
- await E(o.current.value);
892
+ await P(o.value);
885
893
  let _;
886
- a.type === "app" && a.version === "v1" && (_ = Ce), I.toolbox = _, i = oe(s.value, I), i.addChangeListener(y.disableOrphans), i.addChangeListener(K), await N(), l("ready", i);
894
+ a.type === "app" && a.version === "v1" && (_ = Ce), E.toolbox = _, y = oe(c.value, E), y.addChangeListener(d.disableOrphans), y.addChangeListener(F), setTimeout(() => {
895
+ S(), l("ready", y);
896
+ }, 1);
897
+ }), M(() => {
898
+ s.value = !1;
887
899
  });
888
- function x() {
889
- i && ne(i);
900
+ function S() {
901
+ y && ne(y);
890
902
  }
891
- function K(_) {
903
+ function F(_) {
892
904
  l("change", _);
893
905
  }
894
- return M(() => {
895
- r.value = !1;
896
- }), k(r, (_) => {
897
- var m;
898
- _ || (m = i.getToolbox()) == null || m.clearSelection();
899
- }), k(
900
- () => o.current.value,
901
- (_) => {
902
- E(_);
903
- }
904
- ), k(
905
- () => n.current.value.dark,
906
- (_) => {
907
- he(_ ? "dark" : "light");
908
- }
909
- ), (_, m) => {
906
+ return C(o, (_) => {
907
+ P(_);
908
+ }), C(r, (_) => {
909
+ he(_ ? "dark" : "light");
910
+ }), C(s, (_) => {
911
+ var T;
912
+ _ || (T = y.getToolbox()) == null || T.clearSelection();
913
+ }), C(() => a.active, (_) => {
914
+ _ && setTimeout(() => S(), 0);
915
+ }), (_, T) => {
910
916
  const w = V("resize");
911
917
  return U(), Y("div", me, [
912
918
  G(W("div", {
913
919
  class: "w-100 h-100",
914
920
  ref_key: "blocklyDiv",
915
- ref: s,
916
- id: "blocklyEditor"
921
+ ref: c
917
922
  }, null, 512), [
918
- [w, x]
923
+ [w, S]
919
924
  ])
920
925
  ]);
921
926
  };