@goplasmatic/dataflow-ui 2.0.7 → 2.0.9

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
@@ -175,6 +175,15 @@ const Check = createLucideIcon("Check", [["path", { d: "M20 6 9 17l-5-5", key: "
175
175
  const ChevronDown = createLucideIcon("ChevronDown", [
176
176
  ["path", { d: "m6 9 6 6 6-6", key: "qrunsl" }]
177
177
  ]);
178
+ /**
179
+ * @license lucide-react v0.462.0 - ISC
180
+ *
181
+ * This source code is licensed under the ISC license.
182
+ * See the LICENSE file in the root directory of this source tree.
183
+ */
184
+ const ChevronLeft = createLucideIcon("ChevronLeft", [
185
+ ["path", { d: "m15 18-6-6 6-6", key: "1wnfg3" }]
186
+ ]);
178
187
  /**
179
188
  * @license lucide-react v0.462.0 - ISC
180
189
  *
@@ -184,6 +193,26 @@ const ChevronDown = createLucideIcon("ChevronDown", [
184
193
  const ChevronRight = createLucideIcon("ChevronRight", [
185
194
  ["path", { d: "m9 18 6-6-6-6", key: "mthhwq" }]
186
195
  ]);
196
+ /**
197
+ * @license lucide-react v0.462.0 - ISC
198
+ *
199
+ * This source code is licensed under the ISC license.
200
+ * See the LICENSE file in the root directory of this source tree.
201
+ */
202
+ const ChevronsLeft = createLucideIcon("ChevronsLeft", [
203
+ ["path", { d: "m11 17-5-5 5-5", key: "13zhaf" }],
204
+ ["path", { d: "m18 17-5-5 5-5", key: "h8a8et" }]
205
+ ]);
206
+ /**
207
+ * @license lucide-react v0.462.0 - ISC
208
+ *
209
+ * This source code is licensed under the ISC license.
210
+ * See the LICENSE file in the root directory of this source tree.
211
+ */
212
+ const ChevronsRight = createLucideIcon("ChevronsRight", [
213
+ ["path", { d: "m6 17 5-5-5-5", key: "xnjwq" }],
214
+ ["path", { d: "m13 17 5-5-5-5", key: "17xmmf" }]
215
+ ]);
187
216
  /**
188
217
  * @license lucide-react v0.462.0 - ISC
189
218
  *
@@ -205,6 +234,17 @@ const CircleCheckBig = createLucideIcon("CircleCheckBig", [
205
234
  ["path", { d: "M21.801 10A10 10 0 1 1 17 3.335", key: "yps3ct" }],
206
235
  ["path", { d: "m9 11 3 3L22 4", key: "1pflzl" }]
207
236
  ]);
237
+ /**
238
+ * @license lucide-react v0.462.0 - ISC
239
+ *
240
+ * This source code is licensed under the ISC license.
241
+ * See the LICENSE file in the root directory of this source tree.
242
+ */
243
+ const CircleX = createLucideIcon("CircleX", [
244
+ ["circle", { cx: "12", cy: "12", r: "10", key: "1mglay" }],
245
+ ["path", { d: "m15 9-6 6", key: "1uzhvr" }],
246
+ ["path", { d: "m9 9 6 6", key: "z0biqf" }]
247
+ ]);
208
248
  /**
209
249
  * @license lucide-react v0.462.0 - ISC
210
250
  *
@@ -311,6 +351,15 @@ const ListTree = createLucideIcon("ListTree", [
311
351
  ["path", { d: "M3 6v4c0 1.1.9 2 2 2h3", key: "1ywdgy" }],
312
352
  ["path", { d: "M3 10v6c0 1.1.9 2 2 2h3", key: "2wc746" }]
313
353
  ]);
354
+ /**
355
+ * @license lucide-react v0.462.0 - ISC
356
+ *
357
+ * This source code is licensed under the ISC license.
358
+ * See the LICENSE file in the root directory of this source tree.
359
+ */
360
+ const LoaderCircle = createLucideIcon("LoaderCircle", [
361
+ ["path", { d: "M21 12a9 9 0 1 1-6.219-8.56", key: "13zald" }]
362
+ ]);
314
363
  /**
315
364
  * @license lucide-react v0.462.0 - ISC
316
365
  *
@@ -11006,7 +11055,7 @@ let CATEGORY_COLORS, DataLogicEditor, OPERATORS, applyTreeLayout, jsonLogicToNod
11006
11055
  }
11007
11056
  ]
11008
11057
  ];
11009
- const ChevronLeft = createLucideIcon2("chevron-left", __iconNode$o);
11058
+ const ChevronLeft2 = createLucideIcon2("chevron-left", __iconNode$o);
11010
11059
  const __iconNode$n = [
11011
11060
  [
11012
11061
  "path",
@@ -11068,7 +11117,7 @@ let CATEGORY_COLORS, DataLogicEditor, OPERATORS, applyTreeLayout, jsonLogicToNod
11068
11117
  }
11069
11118
  ]
11070
11119
  ];
11071
- const CircleX = createLucideIcon2("circle-x", __iconNode$l);
11120
+ const CircleX2 = createLucideIcon2("circle-x", __iconNode$l);
11072
11121
  const __iconNode$k = [
11073
11122
  [
11074
11123
  "path",
@@ -11696,7 +11745,7 @@ let CATEGORY_COLORS, DataLogicEditor, OPERATORS, applyTreeLayout, jsonLogicToNod
11696
11745
  "database": Database,
11697
11746
  "boxes": Boxes,
11698
11747
  "circle-help": CircleQuestionMark,
11699
- "circle-x": CircleX,
11748
+ "circle-x": CircleX2,
11700
11749
  "git-commit-horizontal": GitCommitHorizontal,
11701
11750
  "search": Search2,
11702
11751
  "divide": Divide,
@@ -18866,7 +18915,7 @@ let CATEGORY_COLORS, DataLogicEditor, OPERATORS, applyTreeLayout, jsonLogicToNod
18866
18915
  onClick: stepBackward,
18867
18916
  disabled: isAtStart,
18868
18917
  title: "Step backward (Left Arrow)",
18869
- children: jsx(ChevronLeft, {
18918
+ children: jsx(ChevronLeft2, {
18870
18919
  size: 18
18871
18920
  })
18872
18921
  }),
@@ -19753,7 +19802,7 @@ function WorkflowFlowView({
19753
19802
  }
19754
19803
  function DataLogicView({ value }) {
19755
19804
  const { resolvedTheme } = useTheme();
19756
- return /* @__PURE__ */ jsx("div", { className: "df-details-content", children: /* @__PURE__ */ jsx("div", { className: "df-details-logic-editor", children: /* @__PURE__ */ jsx(
19805
+ return /* @__PURE__ */ jsx("div", { className: "df-details-content", children: /* @__PURE__ */ jsx("div", { className: "df-details-logic-editor", "data-theme": resolvedTheme, children: /* @__PURE__ */ jsx(
19757
19806
  DataLogicEditor,
19758
19807
  {
19759
19808
  value,
@@ -20282,7 +20331,7 @@ function getParentFolderIds(path) {
20282
20331
  return ids;
20283
20332
  }
20284
20333
  function TreeView({ workflows, selection: selection2, onSelect, debugMode = false }) {
20285
- const debuggerContext = useDebugger();
20334
+ const debuggerContext = useDebuggerOptional();
20286
20335
  const effectiveDebugContext = debugMode ? debuggerContext : null;
20287
20336
  const folderTree = useMemo(() => buildFolderTree(workflows), [workflows]);
20288
20337
  const sortedRootFolders = useMemo(() => {
@@ -20423,1854 +20472,2151 @@ function TreeView({ workflows, selection: selection2, onSelect, debugMode = fals
20423
20472
  }
20424
20473
  ) });
20425
20474
  }
20426
- function SearchInput({
20427
- value,
20428
- onChange,
20429
- onClear,
20430
- placeholder = "Search...",
20431
- className = ""
20432
- }) {
20433
- return /* @__PURE__ */ jsxs("div", { className: `df-search-input ${className}`, children: [
20434
- /* @__PURE__ */ jsx(Search, { className: "df-search-icon", size: 16 }),
20435
- /* @__PURE__ */ jsx(
20436
- "input",
20437
- {
20438
- type: "text",
20439
- value,
20440
- onChange: (e) => onChange(e.target.value),
20441
- placeholder,
20442
- className: "df-search-field"
20443
- }
20444
- ),
20445
- value && onClear && /* @__PURE__ */ jsx(
20446
- "button",
20447
- {
20448
- onClick: onClear,
20449
- className: "df-search-clear",
20450
- "aria-label": "Clear search",
20451
- children: /* @__PURE__ */ jsx(X, { size: 14 })
20452
- }
20453
- )
20454
- ] });
20455
- }
20456
- function JsonViewer({
20457
- data,
20458
- initialExpanded = false,
20459
- maxStringLength = 50,
20460
- className = ""
20461
- }) {
20462
- return /* @__PURE__ */ jsx("div", { className: `df-json-viewer ${className}`, children: /* @__PURE__ */ jsx(
20463
- JsonNode,
20464
- {
20465
- data,
20466
- initialExpanded,
20467
- maxStringLength
20468
- }
20469
- ) });
20470
- }
20471
- function JsonNode({
20472
- data,
20473
- initialExpanded,
20474
- maxStringLength,
20475
- keyName,
20476
- isLast = true
20477
- }) {
20478
- const [expanded, setExpanded] = useState(initialExpanded);
20479
- const renderValue = () => {
20480
- if (data === null) {
20481
- return /* @__PURE__ */ jsx("span", { className: "df-json-null", children: "null" });
20482
- }
20483
- if (data === void 0) {
20484
- return /* @__PURE__ */ jsx("span", { className: "df-json-undefined", children: "undefined" });
20485
- }
20486
- if (typeof data === "boolean") {
20487
- return /* @__PURE__ */ jsx("span", { className: "df-json-boolean", children: data.toString() });
20488
- }
20489
- if (typeof data === "number") {
20490
- return /* @__PURE__ */ jsx("span", { className: "df-json-number", children: data });
20491
- }
20492
- if (typeof data === "string") {
20493
- const display = data.length > maxStringLength ? `${data.slice(0, maxStringLength)}...` : data;
20494
- return /* @__PURE__ */ jsxs("span", { className: "df-json-string", children: [
20495
- '"',
20496
- display,
20497
- '"'
20498
- ] });
20499
- }
20500
- if (Array.isArray(data)) {
20501
- if (data.length === 0) {
20502
- return /* @__PURE__ */ jsx("span", { className: "df-json-bracket", children: "[]" });
20475
+ function DebuggerControls({ compact = false, className = "" }) {
20476
+ const {
20477
+ state,
20478
+ play,
20479
+ pause,
20480
+ stop,
20481
+ reset,
20482
+ stepForward,
20483
+ stepBackward,
20484
+ setSpeed,
20485
+ isAtStart,
20486
+ isAtEnd,
20487
+ hasTrace,
20488
+ progress,
20489
+ totalSteps
20490
+ } = useDebugger();
20491
+ const { playbackState, playbackSpeed, currentStepIndex, isExecuting } = state;
20492
+ const handleKeyDown = useCallback(
20493
+ (e) => {
20494
+ if (e.target instanceof HTMLInputElement || e.target instanceof HTMLTextAreaElement) {
20495
+ return;
20503
20496
  }
20504
- return /* @__PURE__ */ jsxs("span", { className: "df-json-array", children: [
20505
- /* @__PURE__ */ jsx(
20506
- "button",
20507
- {
20508
- onClick: () => setExpanded(!expanded),
20509
- className: "df-json-toggle",
20510
- children: expanded ? /* @__PURE__ */ jsx(ChevronDown, { size: 12 }) : /* @__PURE__ */ jsx(ChevronRight, { size: 12 })
20497
+ switch (e.key) {
20498
+ case " ":
20499
+ e.preventDefault();
20500
+ if (playbackState === "playing") {
20501
+ pause();
20502
+ } else if (hasTrace) {
20503
+ play();
20511
20504
  }
20512
- ),
20513
- /* @__PURE__ */ jsx("span", { className: "df-json-bracket", children: "[" }),
20514
- !expanded && /* @__PURE__ */ jsxs("span", { className: "df-json-preview", children: [
20515
- data.length,
20516
- " item",
20517
- data.length !== 1 ? "s" : ""
20518
- ] }),
20519
- expanded && /* @__PURE__ */ jsx("div", { className: "df-json-children", children: data.map((item, index2) => /* @__PURE__ */ jsx(
20520
- JsonNode,
20521
- {
20522
- data: item,
20523
- initialExpanded: false,
20524
- maxStringLength,
20525
- isLast: index2 === data.length - 1
20526
- },
20527
- index2
20528
- )) }),
20529
- /* @__PURE__ */ jsx("span", { className: "df-json-bracket", children: "]" })
20530
- ] });
20531
- }
20532
- if (typeof data === "object") {
20533
- const entries = Object.entries(data);
20534
- if (entries.length === 0) {
20535
- return /* @__PURE__ */ jsx("span", { className: "df-json-bracket", children: "{}" });
20536
- }
20537
- return /* @__PURE__ */ jsxs("span", { className: "df-json-object", children: [
20538
- /* @__PURE__ */ jsx(
20539
- "button",
20540
- {
20541
- onClick: () => setExpanded(!expanded),
20542
- className: "df-json-toggle",
20543
- children: expanded ? /* @__PURE__ */ jsx(ChevronDown, { size: 12 }) : /* @__PURE__ */ jsx(ChevronRight, { size: 12 })
20505
+ break;
20506
+ case "ArrowRight":
20507
+ e.preventDefault();
20508
+ if (hasTrace && !isAtEnd) {
20509
+ stepForward();
20544
20510
  }
20545
- ),
20546
- /* @__PURE__ */ jsx("span", { className: "df-json-bracket", children: "{" }),
20547
- !expanded && /* @__PURE__ */ jsxs("span", { className: "df-json-preview", children: [
20548
- entries.length,
20549
- " key",
20550
- entries.length !== 1 ? "s" : ""
20551
- ] }),
20552
- expanded && /* @__PURE__ */ jsx("div", { className: "df-json-children", children: entries.map(([key, value], index2) => /* @__PURE__ */ jsx(
20553
- JsonNode,
20554
- {
20555
- keyName: key,
20556
- data: value,
20557
- initialExpanded: false,
20558
- maxStringLength,
20559
- isLast: index2 === entries.length - 1
20560
- },
20561
- key
20562
- )) }),
20563
- /* @__PURE__ */ jsx("span", { className: "df-json-bracket", children: "}" })
20564
- ] });
20565
- }
20566
- return /* @__PURE__ */ jsx("span", { children: String(data) });
20511
+ break;
20512
+ case "ArrowLeft":
20513
+ e.preventDefault();
20514
+ if (hasTrace && !isAtStart) {
20515
+ stepBackward();
20516
+ }
20517
+ break;
20518
+ case "Escape":
20519
+ e.preventDefault();
20520
+ stop();
20521
+ break;
20522
+ case "r":
20523
+ if (e.metaKey || e.ctrlKey) {
20524
+ e.preventDefault();
20525
+ reset();
20526
+ }
20527
+ break;
20528
+ }
20529
+ },
20530
+ [playbackState, hasTrace, isAtEnd, isAtStart, play, pause, stop, stepForward, stepBackward, reset]
20531
+ );
20532
+ useEffect(() => {
20533
+ window.addEventListener("keydown", handleKeyDown);
20534
+ return () => window.removeEventListener("keydown", handleKeyDown);
20535
+ }, [handleKeyDown]);
20536
+ const handleSpeedChange = (e) => {
20537
+ setSpeed(Number(e.target.value));
20567
20538
  };
20568
- return /* @__PURE__ */ jsxs("div", { className: "df-json-node", children: [
20569
- keyName !== void 0 && /* @__PURE__ */ jsxs(Fragment, { children: [
20570
- /* @__PURE__ */ jsxs("span", { className: "df-json-key", children: [
20571
- '"',
20572
- keyName,
20573
- '"'
20574
- ] }),
20575
- /* @__PURE__ */ jsx("span", { className: "df-json-colon", children: ": " })
20576
- ] }),
20577
- renderValue(),
20578
- !isLast && /* @__PURE__ */ jsx("span", { className: "df-json-comma", children: "," })
20579
- ] });
20580
- }
20581
- function _arrayLikeToArray(r, a) {
20582
- (null == a || a > r.length) && (a = r.length);
20583
- for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e];
20584
- return n;
20585
- }
20586
- function _arrayWithHoles(r) {
20587
- if (Array.isArray(r)) return r;
20588
- }
20589
- function _defineProperty$1(e, r, t) {
20590
- return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, {
20591
- value: t,
20592
- enumerable: true,
20593
- configurable: true,
20594
- writable: true
20595
- }) : e[r] = t, e;
20596
- }
20597
- function _iterableToArrayLimit(r, l2) {
20598
- var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"];
20599
- if (null != t) {
20600
- var e, n, i, u, a = [], f = true, o = false;
20601
- try {
20602
- if (i = (t = t.call(r)).next, 0 === l2) ;
20603
- else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l2); f = true) ;
20604
- } catch (r2) {
20605
- o = true, n = r2;
20606
- } finally {
20607
- try {
20608
- if (!f && null != t.return && (u = t.return(), Object(u) !== u)) return;
20609
- } finally {
20610
- if (o) throw n;
20611
- }
20612
- }
20613
- return a;
20614
- }
20615
- }
20616
- function _nonIterableRest() {
20617
- throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
20618
- }
20619
- function ownKeys$1(e, r) {
20620
- var t = Object.keys(e);
20621
- if (Object.getOwnPropertySymbols) {
20622
- var o = Object.getOwnPropertySymbols(e);
20623
- r && (o = o.filter(function(r2) {
20624
- return Object.getOwnPropertyDescriptor(e, r2).enumerable;
20625
- })), t.push.apply(t, o);
20626
- }
20627
- return t;
20628
- }
20629
- function _objectSpread2$1(e) {
20630
- for (var r = 1; r < arguments.length; r++) {
20631
- var t = null != arguments[r] ? arguments[r] : {};
20632
- r % 2 ? ownKeys$1(Object(t), true).forEach(function(r2) {
20633
- _defineProperty$1(e, r2, t[r2]);
20634
- }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys$1(Object(t)).forEach(function(r2) {
20635
- Object.defineProperty(e, r2, Object.getOwnPropertyDescriptor(t, r2));
20636
- });
20637
- }
20638
- return e;
20639
- }
20640
- function _objectWithoutProperties(e, t) {
20641
- if (null == e) return {};
20642
- var o, r, i = _objectWithoutPropertiesLoose(e, t);
20643
- if (Object.getOwnPropertySymbols) {
20644
- var n = Object.getOwnPropertySymbols(e);
20645
- for (r = 0; r < n.length; r++) o = n[r], -1 === t.indexOf(o) && {}.propertyIsEnumerable.call(e, o) && (i[o] = e[o]);
20646
- }
20647
- return i;
20648
- }
20649
- function _objectWithoutPropertiesLoose(r, e) {
20650
- if (null == r) return {};
20651
- var t = {};
20652
- for (var n in r) if ({}.hasOwnProperty.call(r, n)) {
20653
- if (-1 !== e.indexOf(n)) continue;
20654
- t[n] = r[n];
20655
- }
20656
- return t;
20657
- }
20658
- function _slicedToArray(r, e) {
20659
- return _arrayWithHoles(r) || _iterableToArrayLimit(r, e) || _unsupportedIterableToArray(r, e) || _nonIterableRest();
20660
- }
20661
- function _toPrimitive(t, r) {
20662
- if ("object" != typeof t || !t) return t;
20663
- var e = t[Symbol.toPrimitive];
20664
- if (void 0 !== e) {
20665
- var i = e.call(t, r);
20666
- if ("object" != typeof i) return i;
20667
- throw new TypeError("@@toPrimitive must return a primitive value.");
20668
- }
20669
- return ("string" === r ? String : Number)(t);
20670
- }
20671
- function _toPropertyKey(t) {
20672
- var i = _toPrimitive(t, "string");
20673
- return "symbol" == typeof i ? i : i + "";
20674
- }
20675
- function _unsupportedIterableToArray(r, a) {
20676
- if (r) {
20677
- if ("string" == typeof r) return _arrayLikeToArray(r, a);
20678
- var t = {}.toString.call(r).slice(8, -1);
20679
- return "Object" === t && r.constructor && (t = r.constructor.name), "Map" === t || "Set" === t ? Array.from(r) : "Arguments" === t || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t) ? _arrayLikeToArray(r, a) : void 0;
20680
- }
20681
- }
20682
- function _defineProperty(obj, key, value) {
20683
- if (key in obj) {
20684
- Object.defineProperty(obj, key, {
20685
- value,
20686
- enumerable: true,
20687
- configurable: true,
20688
- writable: true
20689
- });
20690
- } else {
20691
- obj[key] = value;
20692
- }
20693
- return obj;
20694
- }
20695
- function ownKeys(object2, enumerableOnly) {
20696
- var keys = Object.keys(object2);
20697
- if (Object.getOwnPropertySymbols) {
20698
- var symbols = Object.getOwnPropertySymbols(object2);
20699
- if (enumerableOnly) symbols = symbols.filter(function(sym) {
20700
- return Object.getOwnPropertyDescriptor(object2, sym).enumerable;
20701
- });
20702
- keys.push.apply(keys, symbols);
20703
- }
20704
- return keys;
20705
- }
20706
- function _objectSpread2(target) {
20707
- for (var i = 1; i < arguments.length; i++) {
20708
- var source = arguments[i] != null ? arguments[i] : {};
20709
- if (i % 2) {
20710
- ownKeys(Object(source), true).forEach(function(key) {
20711
- _defineProperty(target, key, source[key]);
20712
- });
20713
- } else if (Object.getOwnPropertyDescriptors) {
20714
- Object.defineProperties(target, Object.getOwnPropertyDescriptors(source));
20715
- } else {
20716
- ownKeys(Object(source)).forEach(function(key) {
20717
- Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key));
20718
- });
20719
- }
20720
- }
20721
- return target;
20722
- }
20723
- function compose$1() {
20724
- for (var _len = arguments.length, fns = new Array(_len), _key = 0; _key < _len; _key++) {
20725
- fns[_key] = arguments[_key];
20726
- }
20727
- return function(x) {
20728
- return fns.reduceRight(function(y, f) {
20729
- return f(y);
20730
- }, x);
20731
- };
20732
- }
20733
- function curry$1(fn) {
20734
- return function curried() {
20735
- var _this = this;
20736
- for (var _len2 = arguments.length, args = new Array(_len2), _key2 = 0; _key2 < _len2; _key2++) {
20737
- args[_key2] = arguments[_key2];
20738
- }
20739
- return args.length >= fn.length ? fn.apply(this, args) : function() {
20740
- for (var _len3 = arguments.length, nextArgs = new Array(_len3), _key3 = 0; _key3 < _len3; _key3++) {
20741
- nextArgs[_key3] = arguments[_key3];
20742
- }
20743
- return curried.apply(_this, [].concat(args, nextArgs));
20744
- };
20745
- };
20746
- }
20747
- function isObject$1(value) {
20748
- return {}.toString.call(value).includes("Object");
20749
- }
20750
- function isEmpty(obj) {
20751
- return !Object.keys(obj).length;
20752
- }
20753
- function isFunction(value) {
20754
- return typeof value === "function";
20755
- }
20756
- function hasOwnProperty(object2, property) {
20757
- return Object.prototype.hasOwnProperty.call(object2, property);
20758
- }
20759
- function validateChanges(initial, changes) {
20760
- if (!isObject$1(changes)) errorHandler$1("changeType");
20761
- if (Object.keys(changes).some(function(field) {
20762
- return !hasOwnProperty(initial, field);
20763
- })) errorHandler$1("changeField");
20764
- return changes;
20765
- }
20766
- function validateSelector(selector2) {
20767
- if (!isFunction(selector2)) errorHandler$1("selectorType");
20768
- }
20769
- function validateHandler(handler) {
20770
- if (!(isFunction(handler) || isObject$1(handler))) errorHandler$1("handlerType");
20771
- if (isObject$1(handler) && Object.values(handler).some(function(_handler) {
20772
- return !isFunction(_handler);
20773
- })) errorHandler$1("handlersType");
20774
- }
20775
- function validateInitial(initial) {
20776
- if (!initial) errorHandler$1("initialIsRequired");
20777
- if (!isObject$1(initial)) errorHandler$1("initialType");
20778
- if (isEmpty(initial)) errorHandler$1("initialContent");
20779
- }
20780
- function throwError$1(errorMessages2, type) {
20781
- throw new Error(errorMessages2[type] || errorMessages2["default"]);
20782
- }
20783
- var errorMessages$1 = {
20784
- initialIsRequired: "initial state is required",
20785
- initialType: "initial state should be an object",
20786
- initialContent: "initial state shouldn't be an empty object",
20787
- handlerType: "handler should be an object or a function",
20788
- handlersType: "all handlers should be a functions",
20789
- selectorType: "selector should be a function",
20790
- changeType: "provided value of changes should be an object",
20791
- changeField: 'it seams you want to change a field in the state which is not specified in the "initial" state',
20792
- "default": "an unknown error accured in `state-local` package"
20793
- };
20794
- var errorHandler$1 = curry$1(throwError$1)(errorMessages$1);
20795
- var validators$1 = {
20796
- changes: validateChanges,
20797
- selector: validateSelector,
20798
- handler: validateHandler,
20799
- initial: validateInitial
20800
- };
20801
- function create(initial) {
20802
- var handler = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : {};
20803
- validators$1.initial(initial);
20804
- validators$1.handler(handler);
20805
- var state = {
20806
- current: initial
20807
- };
20808
- var didUpdate = curry$1(didStateUpdate)(state, handler);
20809
- var update = curry$1(updateState)(state);
20810
- var validate = curry$1(validators$1.changes)(initial);
20811
- var getChanges = curry$1(extractChanges)(state);
20812
- function getState2() {
20813
- var selector2 = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : function(state2) {
20814
- return state2;
20815
- };
20816
- validators$1.selector(selector2);
20817
- return selector2(state.current);
20818
- }
20819
- function setState2(causedChanges) {
20820
- compose$1(didUpdate, update, validate, getChanges)(causedChanges);
20821
- }
20822
- return [getState2, setState2];
20823
- }
20824
- function extractChanges(state, causedChanges) {
20825
- return isFunction(causedChanges) ? causedChanges(state.current) : causedChanges;
20826
- }
20827
- function updateState(state, changes) {
20828
- state.current = _objectSpread2(_objectSpread2({}, state.current), changes);
20829
- return changes;
20830
- }
20831
- function didStateUpdate(state, handler, changes) {
20832
- isFunction(handler) ? handler(state.current) : Object.keys(changes).forEach(function(field) {
20833
- var _handler$field;
20834
- return (_handler$field = handler[field]) === null || _handler$field === void 0 ? void 0 : _handler$field.call(handler, state.current[field]);
20835
- });
20836
- return changes;
20837
- }
20838
- var index = {
20839
- create
20840
- };
20841
- var config$1 = {
20842
- paths: {
20843
- vs: "https://cdn.jsdelivr.net/npm/monaco-editor@0.55.1/min/vs"
20844
- }
20845
- };
20846
- function curry(fn) {
20847
- return function curried() {
20848
- var _this = this;
20849
- for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
20850
- args[_key] = arguments[_key];
20851
- }
20852
- return args.length >= fn.length ? fn.apply(this, args) : function() {
20853
- for (var _len2 = arguments.length, nextArgs = new Array(_len2), _key2 = 0; _key2 < _len2; _key2++) {
20854
- nextArgs[_key2] = arguments[_key2];
20855
- }
20856
- return curried.apply(_this, [].concat(args, nextArgs));
20857
- };
20858
- };
20859
- }
20860
- function isObject(value) {
20861
- return {}.toString.call(value).includes("Object");
20862
- }
20863
- function validateConfig(config2) {
20864
- if (!config2) errorHandler("configIsRequired");
20865
- if (!isObject(config2)) errorHandler("configType");
20866
- if (config2.urls) {
20867
- informAboutDeprecation();
20868
- return {
20869
- paths: {
20870
- vs: config2.urls.monacoBase
20871
- }
20872
- };
20873
- }
20874
- return config2;
20875
- }
20876
- function informAboutDeprecation() {
20877
- console.warn(errorMessages.deprecation);
20878
- }
20879
- function throwError(errorMessages2, type) {
20880
- throw new Error(errorMessages2[type] || errorMessages2["default"]);
20881
- }
20882
- var errorMessages = {
20883
- configIsRequired: "the configuration object is required",
20884
- configType: "the configuration object should be an object",
20885
- "default": "an unknown error accured in `@monaco-editor/loader` package",
20886
- deprecation: "Deprecation warning!\n You are using deprecated way of configuration.\n\n Instead of using\n monaco.config({ urls: { monacoBase: '...' } })\n use\n monaco.config({ paths: { vs: '...' } })\n\n For more please check the link https://github.com/suren-atoyan/monaco-loader#config\n "
20887
- };
20888
- var errorHandler = curry(throwError)(errorMessages);
20889
- var validators = {
20890
- config: validateConfig
20891
- };
20892
- var compose = function compose2() {
20893
- for (var _len = arguments.length, fns = new Array(_len), _key = 0; _key < _len; _key++) {
20894
- fns[_key] = arguments[_key];
20539
+ if (compact) {
20540
+ return /* @__PURE__ */ jsxs("div", { className: `df-debug-controls df-debug-controls-compact ${className}`, children: [
20541
+ /* @__PURE__ */ jsx(
20542
+ "button",
20543
+ {
20544
+ className: "df-debug-btn",
20545
+ onClick: stepBackward,
20546
+ disabled: !hasTrace || isAtStart || isExecuting,
20547
+ title: "Previous step (Left Arrow)",
20548
+ children: /* @__PURE__ */ jsx(SkipBack, { size: 16 })
20549
+ }
20550
+ ),
20551
+ playbackState === "playing" ? /* @__PURE__ */ jsx(
20552
+ "button",
20553
+ {
20554
+ className: "df-debug-btn df-debug-btn-primary",
20555
+ onClick: pause,
20556
+ disabled: !hasTrace || isExecuting,
20557
+ title: "Pause (Space)",
20558
+ children: /* @__PURE__ */ jsx(Pause, { size: 18 })
20559
+ }
20560
+ ) : /* @__PURE__ */ jsx(
20561
+ "button",
20562
+ {
20563
+ className: "df-debug-btn df-debug-btn-primary",
20564
+ onClick: play,
20565
+ disabled: !hasTrace || isAtEnd || isExecuting,
20566
+ title: "Play (Space)",
20567
+ children: /* @__PURE__ */ jsx(Play, { size: 18 })
20568
+ }
20569
+ ),
20570
+ /* @__PURE__ */ jsx(
20571
+ "button",
20572
+ {
20573
+ className: "df-debug-btn",
20574
+ onClick: stepForward,
20575
+ disabled: !hasTrace || isAtEnd || isExecuting,
20576
+ title: "Next step (Right Arrow)",
20577
+ children: /* @__PURE__ */ jsx(SkipForward, { size: 16 })
20578
+ }
20579
+ ),
20580
+ /* @__PURE__ */ jsxs("span", { className: "df-debug-step-counter", children: [
20581
+ currentStepIndex + 1,
20582
+ " / ",
20583
+ totalSteps
20584
+ ] })
20585
+ ] });
20895
20586
  }
20896
- return function(x) {
20897
- return fns.reduceRight(function(y, f) {
20898
- return f(y);
20899
- }, x);
20900
- };
20901
- };
20902
- function merge(target, source) {
20903
- Object.keys(source).forEach(function(key) {
20904
- if (source[key] instanceof Object) {
20905
- if (target[key]) {
20906
- Object.assign(source[key], merge(target[key], source[key]));
20907
- }
20908
- }
20909
- });
20910
- return _objectSpread2$1(_objectSpread2$1({}, target), source);
20911
- }
20912
- var CANCELATION_MESSAGE = {
20913
- type: "cancelation",
20914
- msg: "operation is manually canceled"
20915
- };
20916
- function makeCancelable(promise) {
20917
- var hasCanceled_ = false;
20918
- var wrappedPromise = new Promise(function(resolve, reject) {
20919
- promise.then(function(val) {
20920
- return hasCanceled_ ? reject(CANCELATION_MESSAGE) : resolve(val);
20921
- });
20922
- promise["catch"](reject);
20923
- });
20924
- return wrappedPromise.cancel = function() {
20925
- return hasCanceled_ = true;
20926
- }, wrappedPromise;
20927
- }
20928
- var _excluded = ["monaco"];
20929
- var _state$create = index.create({
20930
- config: config$1,
20931
- isInitialized: false,
20932
- resolve: null,
20933
- reject: null,
20934
- monaco: null
20935
- }), _state$create2 = _slicedToArray(_state$create, 2), getState = _state$create2[0], setState = _state$create2[1];
20936
- function config(globalConfig) {
20937
- var _validators$config = validators.config(globalConfig), monaco = _validators$config.monaco, config2 = _objectWithoutProperties(_validators$config, _excluded);
20938
- setState(function(state) {
20939
- return {
20940
- config: merge(state.config, config2),
20941
- monaco
20942
- };
20943
- });
20587
+ return /* @__PURE__ */ jsxs("div", { className: `df-debug-controls ${className}`, children: [
20588
+ /* @__PURE__ */ jsxs("div", { className: "df-debug-controls-main", children: [
20589
+ /* @__PURE__ */ jsx(
20590
+ "button",
20591
+ {
20592
+ className: "df-debug-btn",
20593
+ onClick: stop,
20594
+ disabled: !hasTrace || isExecuting,
20595
+ title: "Stop (Escape)",
20596
+ children: /* @__PURE__ */ jsx(Square, { size: 20 })
20597
+ }
20598
+ ),
20599
+ /* @__PURE__ */ jsx(
20600
+ "button",
20601
+ {
20602
+ className: "df-debug-btn",
20603
+ onClick: stepBackward,
20604
+ disabled: !hasTrace || isAtStart || isExecuting,
20605
+ title: "Previous step (Left Arrow)",
20606
+ children: /* @__PURE__ */ jsx(SkipBack, { size: 20 })
20607
+ }
20608
+ ),
20609
+ playbackState === "playing" ? /* @__PURE__ */ jsx(
20610
+ "button",
20611
+ {
20612
+ className: "df-debug-btn df-debug-btn-primary",
20613
+ onClick: pause,
20614
+ disabled: !hasTrace || isExecuting,
20615
+ title: "Pause (Space)",
20616
+ children: /* @__PURE__ */ jsx(Pause, { size: 24 })
20617
+ }
20618
+ ) : /* @__PURE__ */ jsx(
20619
+ "button",
20620
+ {
20621
+ className: "df-debug-btn df-debug-btn-primary",
20622
+ onClick: play,
20623
+ disabled: !hasTrace || isAtEnd || isExecuting,
20624
+ title: "Play (Space)",
20625
+ children: /* @__PURE__ */ jsx(Play, { size: 24 })
20626
+ }
20627
+ ),
20628
+ /* @__PURE__ */ jsx(
20629
+ "button",
20630
+ {
20631
+ className: "df-debug-btn",
20632
+ onClick: stepForward,
20633
+ disabled: !hasTrace || isAtEnd || isExecuting,
20634
+ title: "Next step (Right Arrow)",
20635
+ children: /* @__PURE__ */ jsx(SkipForward, { size: 20 })
20636
+ }
20637
+ ),
20638
+ /* @__PURE__ */ jsx(
20639
+ "button",
20640
+ {
20641
+ className: "df-debug-btn",
20642
+ onClick: reset,
20643
+ disabled: !hasTrace || isExecuting,
20644
+ title: "Reset (Ctrl+R)",
20645
+ children: /* @__PURE__ */ jsx(RotateCcw, { size: 20 })
20646
+ }
20647
+ )
20648
+ ] }),
20649
+ /* @__PURE__ */ jsxs("div", { className: "df-debug-progress", children: [
20650
+ /* @__PURE__ */ jsx("div", { className: "df-debug-progress-bar", children: /* @__PURE__ */ jsx(
20651
+ "div",
20652
+ {
20653
+ className: "df-debug-progress-fill",
20654
+ style: { width: `${progress * 100}%` }
20655
+ }
20656
+ ) }),
20657
+ /* @__PURE__ */ jsxs("span", { className: "df-debug-step-counter", children: [
20658
+ "Step ",
20659
+ currentStepIndex + 1,
20660
+ " of ",
20661
+ totalSteps
20662
+ ] })
20663
+ ] }),
20664
+ /* @__PURE__ */ jsxs("div", { className: "df-debug-speed", children: [
20665
+ /* @__PURE__ */ jsx(Gauge, { size: 14 }),
20666
+ /* @__PURE__ */ jsx(
20667
+ "input",
20668
+ {
20669
+ type: "range",
20670
+ min: "100",
20671
+ max: "2000",
20672
+ step: "100",
20673
+ value: playbackSpeed,
20674
+ onChange: handleSpeedChange,
20675
+ className: "df-debug-speed-slider",
20676
+ title: `Playback speed: ${playbackSpeed}ms`
20677
+ }
20678
+ ),
20679
+ /* @__PURE__ */ jsxs("span", { className: "df-debug-speed-label", children: [
20680
+ playbackSpeed,
20681
+ "ms"
20682
+ ] })
20683
+ ] })
20684
+ ] });
20944
20685
  }
20945
- function init() {
20946
- var state = getState(function(_ref) {
20947
- var monaco = _ref.monaco, isInitialized = _ref.isInitialized, resolve = _ref.resolve;
20948
- return {
20949
- monaco,
20950
- isInitialized,
20951
- resolve
20952
- };
20953
- });
20954
- if (!state.isInitialized) {
20955
- setState({
20956
- isInitialized: true
20686
+ function MessageInputPanel({
20687
+ onExecute,
20688
+ isExecuting = false,
20689
+ className = ""
20690
+ }) {
20691
+ const { setInputPayload, state } = useDebugger();
20692
+ const { inputPayload } = state;
20693
+ const [expandedSections, setExpandedSections] = useState(
20694
+ /* @__PURE__ */ new Set(["payload"])
20695
+ );
20696
+ const [editingSection, setEditingSection] = useState(null);
20697
+ const [editText, setEditText] = useState("");
20698
+ const [parseError, setParseError] = useState(null);
20699
+ const payload = inputPayload || {};
20700
+ const toggleSection = (section) => {
20701
+ setExpandedSections((prev) => {
20702
+ const next = new Set(prev);
20703
+ if (next.has(section)) {
20704
+ next.delete(section);
20705
+ } else {
20706
+ next.add(section);
20707
+ }
20708
+ return next;
20957
20709
  });
20958
- if (state.monaco) {
20959
- state.resolve(state.monaco);
20960
- return makeCancelable(wrapperPromise);
20710
+ };
20711
+ const startEditing = () => {
20712
+ setEditingSection("payload");
20713
+ setEditText(JSON.stringify(payload, null, 2));
20714
+ setParseError(null);
20715
+ };
20716
+ const cancelEditing = () => {
20717
+ setEditingSection(null);
20718
+ setEditText("");
20719
+ setParseError(null);
20720
+ };
20721
+ const saveEditing = useCallback(() => {
20722
+ if (!editingSection) return;
20723
+ try {
20724
+ const parsed = JSON.parse(editText);
20725
+ setInputPayload(parsed);
20726
+ setEditingSection(null);
20727
+ setEditText("");
20728
+ setParseError(null);
20729
+ } catch (err) {
20730
+ setParseError(err instanceof Error ? err.message : "Invalid JSON");
20961
20731
  }
20962
- if (window.monaco && window.monaco.editor) {
20963
- storeMonacoInstance(window.monaco);
20964
- state.resolve(window.monaco);
20965
- return makeCancelable(wrapperPromise);
20732
+ }, [editingSection, editText, setInputPayload]);
20733
+ const handleLoadSample = () => {
20734
+ setInputPayload({
20735
+ id: "123",
20736
+ name: "John Doe",
20737
+ email: "john@example.com",
20738
+ amount: 100
20739
+ });
20740
+ };
20741
+ const handleClear = () => {
20742
+ setInputPayload({});
20743
+ };
20744
+ const formatValue2 = (value) => {
20745
+ if (Object.keys(value).length === 0) {
20746
+ return "(empty)";
20966
20747
  }
20967
- compose(injectScripts, getMonacoLoaderScript)(configureLoader);
20968
- }
20969
- return makeCancelable(wrapperPromise);
20970
- }
20971
- function injectScripts(script) {
20972
- return document.body.appendChild(script);
20973
- }
20974
- function createScript(src) {
20975
- var script = document.createElement("script");
20976
- return src && (script.src = src), script;
20977
- }
20978
- function getMonacoLoaderScript(configureLoader2) {
20979
- var state = getState(function(_ref2) {
20980
- var config2 = _ref2.config, reject = _ref2.reject;
20981
- return {
20982
- config: config2,
20983
- reject
20984
- };
20985
- });
20986
- var loaderScript = createScript("".concat(state.config.paths.vs, "/loader.js"));
20987
- loaderScript.onload = function() {
20988
- return configureLoader2();
20748
+ return JSON.stringify(value, null, 2);
20989
20749
  };
20990
- loaderScript.onerror = state.reject;
20991
- return loaderScript;
20992
- }
20993
- function configureLoader() {
20994
- var state = getState(function(_ref3) {
20995
- var config2 = _ref3.config, resolve = _ref3.resolve, reject = _ref3.reject;
20996
- return {
20997
- config: config2,
20998
- resolve,
20999
- reject
21000
- };
21001
- });
21002
- var require2 = window.require;
21003
- require2.config(state.config);
21004
- require2(["vs/editor/editor.main"], function(loaded) {
21005
- var monaco = loaded.m || loaded;
21006
- storeMonacoInstance(monaco);
21007
- state.resolve(monaco);
21008
- }, function(error) {
21009
- state.reject(error);
21010
- });
21011
- }
21012
- function storeMonacoInstance(monaco) {
21013
- if (!getState().monaco) {
21014
- setState({
21015
- monaco
21016
- });
21017
- }
21018
- }
21019
- function __getMonacoInstance() {
21020
- return getState(function(_ref4) {
21021
- var monaco = _ref4.monaco;
21022
- return monaco;
21023
- });
21024
- }
21025
- var wrapperPromise = new Promise(function(resolve, reject) {
21026
- return setState({
21027
- resolve,
21028
- reject
21029
- });
21030
- });
21031
- var loader = {
21032
- config,
21033
- init,
21034
- __getMonacoInstance
21035
- };
21036
- var le = { wrapper: { display: "flex", position: "relative", textAlign: "initial" }, fullWidth: { width: "100%" }, hide: { display: "none" } }, v = le;
21037
- var ae = { container: { display: "flex", height: "100%", width: "100%", justifyContent: "center", alignItems: "center" } }, Y = ae;
21038
- function Me({ children: e }) {
21039
- return require$$0.createElement("div", { style: Y.container }, e);
21040
- }
21041
- var Z = Me;
21042
- var $ = Z;
21043
- function Ee({ width: e, height: r, isEditorReady: n, loading: t, _ref: a, className: m, wrapperProps: E }) {
21044
- return require$$0.createElement("section", { style: { ...v.wrapper, width: e, height: r }, ...E }, !n && require$$0.createElement($, null, t), require$$0.createElement("div", { ref: a, style: { ...v.fullWidth, ...!n && v.hide }, className: m }));
21045
- }
21046
- var ee = Ee;
21047
- var H = memo(ee);
21048
- function Ce(e) {
21049
- useEffect(e, []);
21050
- }
21051
- var k = Ce;
21052
- function he(e, r, n = true) {
21053
- let t = useRef(true);
21054
- useEffect(t.current || !n ? () => {
21055
- t.current = false;
21056
- } : e, r);
21057
- }
21058
- var l = he;
21059
- function D() {
20750
+ const isEmptyPayload = Object.keys(payload).length === 0;
20751
+ const isExpanded = expandedSections.has("payload");
20752
+ const isEditing = editingSection === "payload";
20753
+ return /* @__PURE__ */ jsxs("div", { className: `df-debug-input-panel ${className}`, children: [
20754
+ /* @__PURE__ */ jsxs("div", { className: "df-debug-input-header", children: [
20755
+ /* @__PURE__ */ jsx("span", { className: "df-debug-input-title", children: "Test Payload" }),
20756
+ /* @__PURE__ */ jsxs("div", { className: "df-debug-input-actions", children: [
20757
+ /* @__PURE__ */ jsxs(
20758
+ "button",
20759
+ {
20760
+ className: "df-debug-btn-sm",
20761
+ onClick: handleLoadSample,
20762
+ title: "Load sample data",
20763
+ children: [
20764
+ /* @__PURE__ */ jsx(FileJson, { size: 12 }),
20765
+ "Sample"
20766
+ ]
20767
+ }
20768
+ ),
20769
+ /* @__PURE__ */ jsxs(
20770
+ "button",
20771
+ {
20772
+ className: "df-debug-btn-sm",
20773
+ onClick: handleClear,
20774
+ title: "Clear all data",
20775
+ children: [
20776
+ /* @__PURE__ */ jsx(RefreshCw, { size: 12 }),
20777
+ "Clear"
20778
+ ]
20779
+ }
20780
+ )
20781
+ ] })
20782
+ ] }),
20783
+ /* @__PURE__ */ jsx("div", { className: "df-debug-input-sections", children: /* @__PURE__ */ jsxs("div", { className: "df-debug-input-section", children: [
20784
+ /* @__PURE__ */ jsxs(
20785
+ "div",
20786
+ {
20787
+ className: "df-debug-input-section-header",
20788
+ onClick: () => !isEditing && toggleSection("payload"),
20789
+ children: [
20790
+ /* @__PURE__ */ jsx("span", { className: "df-debug-section-toggle", children: isExpanded ? /* @__PURE__ */ jsx(ChevronDown, { size: 14 }) : /* @__PURE__ */ jsx(ChevronRight, { size: 14 }) }),
20791
+ /* @__PURE__ */ jsx("span", { className: "df-debug-section-label", children: "Payload" }),
20792
+ isEmptyPayload && /* @__PURE__ */ jsx("span", { className: "df-debug-section-empty", children: "(empty)" }),
20793
+ !isEditing && /* @__PURE__ */ jsx(
20794
+ "button",
20795
+ {
20796
+ className: "df-debug-section-edit",
20797
+ onClick: (e) => {
20798
+ e.stopPropagation();
20799
+ startEditing();
20800
+ },
20801
+ title: "Edit Payload",
20802
+ children: "Edit"
20803
+ }
20804
+ )
20805
+ ]
20806
+ }
20807
+ ),
20808
+ isExpanded && /* @__PURE__ */ jsx("div", { className: "df-debug-input-section-content", children: isEditing ? /* @__PURE__ */ jsxs("div", { className: "df-debug-input-editor", children: [
20809
+ /* @__PURE__ */ jsx(
20810
+ "textarea",
20811
+ {
20812
+ className: "df-debug-input-textarea",
20813
+ value: editText,
20814
+ onChange: (e) => setEditText(e.target.value),
20815
+ placeholder: "Enter payload as JSON...",
20816
+ spellCheck: false
20817
+ }
20818
+ ),
20819
+ parseError && /* @__PURE__ */ jsx("div", { className: "df-debug-input-error", children: parseError }),
20820
+ /* @__PURE__ */ jsxs("div", { className: "df-debug-input-editor-actions", children: [
20821
+ /* @__PURE__ */ jsx(
20822
+ "button",
20823
+ {
20824
+ className: "df-debug-btn-sm df-debug-btn-cancel",
20825
+ onClick: cancelEditing,
20826
+ children: "Cancel"
20827
+ }
20828
+ ),
20829
+ /* @__PURE__ */ jsx(
20830
+ "button",
20831
+ {
20832
+ className: "df-debug-btn-sm df-debug-btn-save",
20833
+ onClick: saveEditing,
20834
+ children: "Save"
20835
+ }
20836
+ )
20837
+ ] })
20838
+ ] }) : /* @__PURE__ */ jsx("pre", { className: "df-debug-input-preview", children: formatValue2(payload) }) })
20839
+ ] }) }),
20840
+ /* @__PURE__ */ jsx("div", { className: "df-debug-input-footer", children: /* @__PURE__ */ jsx(
20841
+ "button",
20842
+ {
20843
+ className: "df-debug-run-btn",
20844
+ onClick: onExecute,
20845
+ disabled: isExecuting,
20846
+ children: isExecuting ? /* @__PURE__ */ jsxs(Fragment, { children: [
20847
+ /* @__PURE__ */ jsx(RefreshCw, { size: 14, className: "df-debug-spin" }),
20848
+ "Executing..."
20849
+ ] }) : /* @__PURE__ */ jsxs(Fragment, { children: [
20850
+ /* @__PURE__ */ jsx(Play, { size: 14 }),
20851
+ "Run Debug"
20852
+ ] })
20853
+ }
20854
+ ) })
20855
+ ] });
21060
20856
  }
21061
- function h(e, r, n, t) {
21062
- return De(e, t) || be(e, r, n, t);
20857
+ function MessageStatePanel({ className = "" }) {
20858
+ const { currentStep, currentMessage, currentChanges } = useDebugger();
20859
+ const [activeTab, setActiveTab] = useState("message");
20860
+ if (!currentStep || !currentMessage) {
20861
+ return /* @__PURE__ */ jsx("div", { className: `df-debug-state-panel df-debug-state-empty ${className}`, children: /* @__PURE__ */ jsx("p", { children: "No step selected. Run debug to see message state changes." }) });
20862
+ }
20863
+ const { workflow_id, task_id, result } = currentStep;
20864
+ const tabs = [
20865
+ { key: "message", label: "Message" },
20866
+ { key: "changes", label: `Changes (${currentChanges.length})` }
20867
+ ];
20868
+ return /* @__PURE__ */ jsxs("div", { className: `df-debug-state-panel ${className}`, children: [
20869
+ /* @__PURE__ */ jsx("div", { className: "df-debug-state-header", children: /* @__PURE__ */ jsx("div", { className: "df-debug-state-tabs", children: tabs.map(({ key, label }) => /* @__PURE__ */ jsx(
20870
+ "button",
20871
+ {
20872
+ className: `df-debug-state-tab ${activeTab === key ? "df-debug-state-tab-active" : ""}`,
20873
+ onClick: () => setActiveTab(key),
20874
+ children: label
20875
+ },
20876
+ key
20877
+ )) }) }),
20878
+ /* @__PURE__ */ jsxs("div", { className: "df-debug-state-content", children: [
20879
+ activeTab === "message" && /* @__PURE__ */ jsx(MessageView, { message: currentMessage }),
20880
+ activeTab === "changes" && /* @__PURE__ */ jsx(ChangesView, { changes: currentChanges })
20881
+ ] }),
20882
+ /* @__PURE__ */ jsxs("div", { className: "df-debug-state-footer", children: [
20883
+ /* @__PURE__ */ jsxs("div", { className: "df-debug-state-step-type", children: [
20884
+ /* @__PURE__ */ jsx("span", { className: `df-debug-state-badge df-debug-state-badge-${result}`, children: result }),
20885
+ /* @__PURE__ */ jsxs("span", { className: "df-debug-state-type-label", children: [
20886
+ workflow_id,
20887
+ task_id ? ` / ${task_id}` : ""
20888
+ ] })
20889
+ ] }),
20890
+ currentMessage.errors.length > 0 && /* @__PURE__ */ jsxs("div", { className: "df-debug-state-error", children: [
20891
+ "Errors: ",
20892
+ currentMessage.errors.length
20893
+ ] })
20894
+ ] })
20895
+ ] });
21063
20896
  }
21064
- function De(e, r) {
21065
- return e.editor.getModel(te(e, r));
20897
+ function MessageView({ message }) {
20898
+ const [expandedSections, setExpandedSections] = useState(
20899
+ /* @__PURE__ */ new Set(["context"])
20900
+ );
20901
+ const toggleSection = (section) => {
20902
+ setExpandedSections((prev) => {
20903
+ const next = new Set(prev);
20904
+ if (next.has(section)) {
20905
+ next.delete(section);
20906
+ } else {
20907
+ next.add(section);
20908
+ }
20909
+ return next;
20910
+ });
20911
+ };
20912
+ const sections = [
20913
+ { key: "context", value: message.context },
20914
+ { key: "payload", value: message.payload },
20915
+ { key: "errors", value: message.errors },
20916
+ { key: "audit_trail", value: message.audit_trail }
20917
+ ];
20918
+ return /* @__PURE__ */ jsx("div", { className: "df-debug-message-view", children: sections.map(({ key, value }) => {
20919
+ const isExpanded = expandedSections.has(key);
20920
+ const isEmpty2 = Array.isArray(value) ? value.length === 0 : typeof value === "object" && value !== null ? Object.keys(value).length === 0 : !value;
20921
+ return /* @__PURE__ */ jsxs("div", { className: "df-debug-message-section", children: [
20922
+ /* @__PURE__ */ jsxs(
20923
+ "div",
20924
+ {
20925
+ className: "df-debug-message-section-header",
20926
+ onClick: () => toggleSection(key),
20927
+ children: [
20928
+ /* @__PURE__ */ jsx("span", { className: "df-debug-section-arrow", children: isExpanded ? "▼" : "▶" }),
20929
+ /* @__PURE__ */ jsx("span", { className: "df-debug-section-key", children: key }),
20930
+ isEmpty2 && /* @__PURE__ */ jsx("span", { className: "df-debug-section-empty", children: "(empty)" })
20931
+ ]
20932
+ }
20933
+ ),
20934
+ isExpanded && /* @__PURE__ */ jsx("pre", { className: "df-debug-message-section-content", children: JSON.stringify(value, null, 2) })
20935
+ ] }, key);
20936
+ }) });
21066
20937
  }
21067
- function be(e, r, n, t) {
21068
- return e.editor.createModel(r, n, t ? te(e, t) : void 0);
20938
+ function ChangesView({ changes }) {
20939
+ if (changes.length === 0) {
20940
+ return /* @__PURE__ */ jsx("div", { className: "df-debug-changes-empty", children: "No changes recorded in this step" });
20941
+ }
20942
+ return /* @__PURE__ */ jsx("div", { className: "df-debug-changes-view", children: changes.map((change, index2) => {
20943
+ const isModified = change.old_value !== void 0 && change.new_value !== void 0;
20944
+ const isAdded = change.old_value === void 0 && change.new_value !== void 0;
20945
+ const isRemoved = change.old_value !== void 0 && change.new_value === void 0;
20946
+ const changeType = isAdded ? "added" : isRemoved ? "removed" : "modified";
20947
+ return /* @__PURE__ */ jsxs("div", { className: `df-debug-change-item df-debug-change-${changeType}`, children: [
20948
+ /* @__PURE__ */ jsxs("div", { className: "df-debug-change-header", children: [
20949
+ /* @__PURE__ */ jsx("span", { className: `df-debug-change-op df-debug-change-op-${changeType}`, children: changeType }),
20950
+ /* @__PURE__ */ jsx("span", { className: "df-debug-change-path", children: change.path })
20951
+ ] }),
20952
+ isModified && /* @__PURE__ */ jsxs("div", { className: "df-debug-change-values", children: [
20953
+ /* @__PURE__ */ jsx("span", { className: "df-debug-change-old", children: formatValue(change.old_value) }),
20954
+ /* @__PURE__ */ jsx("span", { className: "df-debug-change-arrow", children: "→" }),
20955
+ /* @__PURE__ */ jsx("span", { className: "df-debug-change-new", children: formatValue(change.new_value) })
20956
+ ] }),
20957
+ isAdded && /* @__PURE__ */ jsx("div", { className: "df-debug-change-values", children: /* @__PURE__ */ jsx("span", { className: "df-debug-change-new", children: formatValue(change.new_value) }) }),
20958
+ isRemoved && /* @__PURE__ */ jsx("div", { className: "df-debug-change-values", children: /* @__PURE__ */ jsx("span", { className: "df-debug-change-old", children: formatValue(change.old_value) }) })
20959
+ ] }, index2);
20960
+ }) });
21069
20961
  }
21070
- function te(e, r) {
21071
- return e.Uri.parse(r);
20962
+ function formatValue(value) {
20963
+ if (value === void 0) return "undefined";
20964
+ if (value === null) return "null";
20965
+ if (typeof value === "string") return `"${value}"`;
20966
+ if (typeof value === "object") return JSON.stringify(value);
20967
+ return String(value);
21072
20968
  }
21073
- function Oe({ original: e, modified: r, language: n, originalLanguage: t, modifiedLanguage: a, originalModelPath: m, modifiedModelPath: E, keepCurrentOriginalModel: g = false, keepCurrentModifiedModel: N = false, theme: x = "light", loading: P = "Loading...", options: y = {}, height: V = "100%", width: z = "100%", className: F, wrapperProps: j = {}, beforeMount: A = D, onMount: q = D }) {
21074
- let [M, O] = useState(false), [T, s] = useState(true), u = useRef(null), c = useRef(null), w = useRef(null), d = useRef(q), o = useRef(A), b = useRef(false);
21075
- k(() => {
21076
- let i = loader.init();
21077
- return i.then((f) => (c.current = f) && s(false)).catch((f) => (f == null ? void 0 : f.type) !== "cancelation" && console.error("Monaco initialization: error:", f)), () => u.current ? I() : i.cancel();
21078
- }), l(() => {
21079
- if (u.current && c.current) {
21080
- let i = u.current.getOriginalEditor(), f = h(c.current, e || "", t || n || "text", m || "");
21081
- f !== i.getModel() && i.setModel(f);
21082
- }
21083
- }, [m], M), l(() => {
21084
- if (u.current && c.current) {
21085
- let i = u.current.getModifiedEditor(), f = h(c.current, r || "", a || n || "text", E || "");
21086
- f !== i.getModel() && i.setModel(f);
21087
- }
21088
- }, [E], M), l(() => {
21089
- let i = u.current.getModifiedEditor();
21090
- i.getOption(c.current.editor.EditorOption.readOnly) ? i.setValue(r || "") : r !== i.getValue() && (i.executeEdits("", [{ range: i.getModel().getFullModelRange(), text: r || "", forceMoveMarkers: true }]), i.pushUndoStop());
21091
- }, [r], M), l(() => {
21092
- var _a, _b;
21093
- (_b = (_a = u.current) == null ? void 0 : _a.getModel()) == null ? void 0 : _b.original.setValue(e || "");
21094
- }, [e], M), l(() => {
21095
- let { original: i, modified: f } = u.current.getModel();
21096
- c.current.editor.setModelLanguage(i, t || n || "text"), c.current.editor.setModelLanguage(f, a || n || "text");
21097
- }, [n, t, a], M), l(() => {
21098
- var _a;
21099
- (_a = c.current) == null ? void 0 : _a.editor.setTheme(x);
21100
- }, [x], M), l(() => {
21101
- var _a;
21102
- (_a = u.current) == null ? void 0 : _a.updateOptions(y);
21103
- }, [y], M);
21104
- let L = useCallback(() => {
21105
- var _a;
21106
- if (!c.current) return;
21107
- o.current(c.current);
21108
- let i = h(c.current, e || "", t || n || "text", m || ""), f = h(c.current, r || "", a || n || "text", E || "");
21109
- (_a = u.current) == null ? void 0 : _a.setModel({ original: i, modified: f });
21110
- }, [n, r, a, e, t, m, E]), U = useCallback(() => {
21111
- var _a;
21112
- !b.current && w.current && (u.current = c.current.editor.createDiffEditor(w.current, { automaticLayout: true, ...y }), L(), (_a = c.current) == null ? void 0 : _a.editor.setTheme(x), O(true), b.current = true);
21113
- }, [y, x, L]);
20969
+ function DebugInfoBubble({
20970
+ step,
20971
+ targetRef,
20972
+ visible,
20973
+ onClose
20974
+ }) {
20975
+ var _a;
20976
+ const [position, setPosition] = useState({ top: 0, left: 0 });
20977
+ const bubbleRef = useRef(null);
21114
20978
  useEffect(() => {
21115
- M && d.current(u.current, c.current);
21116
- }, [M]), useEffect(() => {
21117
- !T && !M && U();
21118
- }, [T, M, U]);
21119
- function I() {
21120
- var _a, _b, _c, _d;
21121
- let i = (_a = u.current) == null ? void 0 : _a.getModel();
21122
- g || ((_b = i == null ? void 0 : i.original) == null ? void 0 : _b.dispose()), N || ((_c = i == null ? void 0 : i.modified) == null ? void 0 : _c.dispose()), (_d = u.current) == null ? void 0 : _d.dispose();
20979
+ if (!visible || !targetRef.current) return;
20980
+ const updatePosition = () => {
20981
+ var _a2, _b;
20982
+ const targetRect = (_a2 = targetRef.current) == null ? void 0 : _a2.getBoundingClientRect();
20983
+ const bubbleRect = (_b = bubbleRef.current) == null ? void 0 : _b.getBoundingClientRect();
20984
+ if (!targetRect) return;
20985
+ let top = targetRect.bottom + 8;
20986
+ let left = targetRect.left;
20987
+ if (bubbleRect) {
20988
+ if (left + bubbleRect.width > window.innerWidth - 16) {
20989
+ left = window.innerWidth - bubbleRect.width - 16;
20990
+ }
20991
+ if (top + bubbleRect.height > window.innerHeight - 16) {
20992
+ top = targetRect.top - bubbleRect.height - 8;
20993
+ }
20994
+ }
20995
+ setPosition({ top, left });
20996
+ };
20997
+ updatePosition();
20998
+ window.addEventListener("scroll", updatePosition, true);
20999
+ window.addEventListener("resize", updatePosition);
21000
+ return () => {
21001
+ window.removeEventListener("scroll", updatePosition, true);
21002
+ window.removeEventListener("resize", updatePosition);
21003
+ };
21004
+ }, [visible, targetRef]);
21005
+ if (!visible) return null;
21006
+ const { workflow_id, task_id, result, message } = step;
21007
+ const state = result === "executed" ? "executed" : "skipped";
21008
+ const hasError = message && message.errors && message.errors.length > 0;
21009
+ const displayState = hasError ? "error" : state;
21010
+ return createPortal(
21011
+ /* @__PURE__ */ jsxs(
21012
+ "div",
21013
+ {
21014
+ ref: bubbleRef,
21015
+ className: "df-debug-bubble",
21016
+ style: {
21017
+ position: "fixed",
21018
+ top: position.top,
21019
+ left: position.left
21020
+ },
21021
+ children: [
21022
+ /* @__PURE__ */ jsxs("div", { className: "df-debug-bubble-header", children: [
21023
+ /* @__PURE__ */ jsx(StateIcon, { state: displayState }),
21024
+ /* @__PURE__ */ jsx("span", { className: "df-debug-bubble-title", children: task_id ? "Task Step" : "Workflow Skipped" }),
21025
+ onClose && /* @__PURE__ */ jsx("button", { className: "df-debug-bubble-close", onClick: onClose, children: /* @__PURE__ */ jsx(X, { size: 14 }) })
21026
+ ] }),
21027
+ /* @__PURE__ */ jsxs("div", { className: "df-debug-bubble-content", children: [
21028
+ /* @__PURE__ */ jsxs("div", { className: "df-debug-bubble-row", children: [
21029
+ /* @__PURE__ */ jsx("span", { className: "df-debug-bubble-label", children: "Workflow:" }),
21030
+ /* @__PURE__ */ jsx("span", { className: "df-debug-bubble-value", children: workflow_id })
21031
+ ] }),
21032
+ task_id && /* @__PURE__ */ jsxs("div", { className: "df-debug-bubble-row", children: [
21033
+ /* @__PURE__ */ jsx("span", { className: "df-debug-bubble-label", children: "Task:" }),
21034
+ /* @__PURE__ */ jsx("span", { className: "df-debug-bubble-value", children: task_id })
21035
+ ] }),
21036
+ /* @__PURE__ */ jsxs("div", { className: "df-debug-bubble-row", children: [
21037
+ /* @__PURE__ */ jsx("span", { className: "df-debug-bubble-label", children: "Result:" }),
21038
+ /* @__PURE__ */ jsx("span", { className: `df-debug-bubble-state df-debug-bubble-state-${displayState}`, children: result })
21039
+ ] }),
21040
+ hasError && (message == null ? void 0 : message.errors) && /* @__PURE__ */ jsxs("div", { className: "df-debug-bubble-error", children: [
21041
+ /* @__PURE__ */ jsx(CircleAlert, { size: 14 }),
21042
+ /* @__PURE__ */ jsx("span", { children: ((_a = message.errors[0]) == null ? void 0 : _a.message) || "Unknown error" })
21043
+ ] })
21044
+ ] })
21045
+ ]
21046
+ }
21047
+ ),
21048
+ document.body
21049
+ );
21050
+ }
21051
+ function StateIcon({ state }) {
21052
+ switch (state) {
21053
+ case "executed":
21054
+ return /* @__PURE__ */ jsx(Check, { size: 16, className: "df-debug-icon-executed" });
21055
+ case "skipped":
21056
+ return /* @__PURE__ */ jsx(SkipForward, { size: 16, className: "df-debug-icon-skipped" });
21057
+ case "error":
21058
+ return /* @__PURE__ */ jsx(CircleAlert, { size: 16, className: "df-debug-icon-error" });
21059
+ case "current":
21060
+ return /* @__PURE__ */ jsx(Clock, { size: 16, className: "df-debug-icon-current" });
21061
+ case "pending":
21062
+ default:
21063
+ return /* @__PURE__ */ jsx(Clock, { size: 16, className: "df-debug-icon-pending" });
21123
21064
  }
21124
- return require$$0.createElement(H, { width: z, height: V, isEditorReady: M, loading: P, _ref: w, className: F, wrapperProps: j });
21125
21065
  }
21126
- var ie = Oe;
21127
- memo(ie);
21128
- function He(e) {
21129
- let r = useRef();
21130
- return useEffect(() => {
21131
- r.current = e;
21132
- }, [e]), r.current;
21066
+ function DebugStateBadge({
21067
+ state,
21068
+ conditionResult,
21069
+ size = "sm"
21070
+ }) {
21071
+ const iconSize = size === "sm" ? 12 : 14;
21072
+ return /* @__PURE__ */ jsxs("span", { className: `df-debug-badge df-debug-badge-${state} df-debug-badge-${size}`, children: [
21073
+ /* @__PURE__ */ jsx(StateIcon, { state }),
21074
+ conditionResult !== void 0 && /* @__PURE__ */ jsx("span", { className: `df-debug-badge-condition ${conditionResult ? "df-debug-badge-condition-pass" : "df-debug-badge-condition-fail"}`, children: conditionResult ? /* @__PURE__ */ jsx(Check, { size: iconSize }) : /* @__PURE__ */ jsx(X, { size: iconSize }) })
21075
+ ] });
21133
21076
  }
21134
- var se = He;
21135
- var _ = /* @__PURE__ */ new Map();
21136
- function Ve({ defaultValue: e, defaultLanguage: r, defaultPath: n, value: t, language: a, path: m, theme: E = "light", line: g, loading: N = "Loading...", options: x = {}, overrideServices: P = {}, saveViewState: y = true, keepCurrentModel: V = false, width: z = "100%", height: F = "100%", className: j, wrapperProps: A = {}, beforeMount: q = D, onMount: M = D, onChange: O, onValidate: T = D }) {
21137
- let [s, u] = useState(false), [c, w] = useState(true), d = useRef(null), o = useRef(null), b = useRef(null), L = useRef(M), U = useRef(q), I = useRef(), i = useRef(t), f = se(m), Q = useRef(false), B = useRef(false);
21138
- k(() => {
21139
- let p = loader.init();
21140
- return p.then((R) => (d.current = R) && w(false)).catch((R) => (R == null ? void 0 : R.type) !== "cancelation" && console.error("Monaco initialization: error:", R)), () => o.current ? pe() : p.cancel();
21141
- }), l(() => {
21142
- var _a, _b, _c, _d;
21143
- let p = h(d.current, e || t || "", r || a || "", m || n || "");
21144
- p !== ((_a = o.current) == null ? void 0 : _a.getModel()) && (y && _.set(f, (_b = o.current) == null ? void 0 : _b.saveViewState()), (_c = o.current) == null ? void 0 : _c.setModel(p), y && ((_d = o.current) == null ? void 0 : _d.restoreViewState(_.get(m))));
21145
- }, [m], s), l(() => {
21146
- var _a;
21147
- (_a = o.current) == null ? void 0 : _a.updateOptions(x);
21148
- }, [x], s), l(() => {
21149
- !o.current || t === void 0 || (o.current.getOption(d.current.editor.EditorOption.readOnly) ? o.current.setValue(t) : t !== o.current.getValue() && (B.current = true, o.current.executeEdits("", [{ range: o.current.getModel().getFullModelRange(), text: t, forceMoveMarkers: true }]), o.current.pushUndoStop(), B.current = false));
21150
- }, [t], s), l(() => {
21077
+ function IntegratedDebugToolbar({
21078
+ workflows,
21079
+ payload,
21080
+ autoExecute = false,
21081
+ onExecutionComplete,
21082
+ onExecutionError,
21083
+ className = ""
21084
+ }) {
21085
+ const {
21086
+ state,
21087
+ play,
21088
+ pause,
21089
+ stop,
21090
+ reset,
21091
+ stepForward,
21092
+ stepBackward,
21093
+ goToStep,
21094
+ startExecution,
21095
+ executeTrace,
21096
+ setExecutionError,
21097
+ runExecution,
21098
+ isAtStart,
21099
+ isAtEnd,
21100
+ hasTrace,
21101
+ totalSteps,
21102
+ isEngineReady
21103
+ } = useDebugger();
21104
+ const { playbackState, currentStepIndex, isExecuting, executionError, trace } = state;
21105
+ const lastExecutionRef = useRef(null);
21106
+ const handleExecute = useCallback(async () => {
21151
21107
  var _a, _b;
21152
- let p = (_a = o.current) == null ? void 0 : _a.getModel();
21153
- p && a && ((_b = d.current) == null ? void 0 : _b.editor.setModelLanguage(p, a));
21154
- }, [a], s), l(() => {
21155
- var _a;
21156
- g !== void 0 && ((_a = o.current) == null ? void 0 : _a.revealLine(g));
21157
- }, [g], s), l(() => {
21158
- var _a;
21159
- (_a = d.current) == null ? void 0 : _a.editor.setTheme(E);
21160
- }, [E], s);
21161
- let X2 = useCallback(() => {
21162
- var _a;
21163
- if (!(!b.current || !d.current) && !Q.current) {
21164
- U.current(d.current);
21165
- let p = m || n, R = h(d.current, t || e || "", r || a || "", p || "");
21166
- o.current = (_a = d.current) == null ? void 0 : _a.editor.create(b.current, { model: R, automaticLayout: true, ...x }, P), y && o.current.restoreViewState(_.get(p)), d.current.editor.setTheme(E), g !== void 0 && o.current.revealLine(g), u(true), Q.current = true;
21108
+ if (!isEngineReady || workflows.length === 0) return;
21109
+ const workflowsJson = JSON.stringify(workflows);
21110
+ const payloadJson = JSON.stringify(payload || {});
21111
+ const current = { workflows: workflowsJson, payload: payloadJson };
21112
+ if (((_a = lastExecutionRef.current) == null ? void 0 : _a.workflows) === current.workflows && ((_b = lastExecutionRef.current) == null ? void 0 : _b.payload) === current.payload) {
21113
+ return;
21167
21114
  }
21168
- }, [e, r, n, t, a, m, x, P, y, E, g]);
21169
- useEffect(() => {
21170
- s && L.current(o.current, d.current);
21171
- }, [s]), useEffect(() => {
21172
- !c && !s && X2();
21173
- }, [c, s, X2]), i.current = t, useEffect(() => {
21174
- var _a, _b;
21175
- s && O && ((_a = I.current) == null ? void 0 : _a.dispose(), I.current = (_b = o.current) == null ? void 0 : _b.onDidChangeModelContent((p) => {
21176
- B.current || O(o.current.getValue(), p);
21177
- }));
21178
- }, [s, O]), useEffect(() => {
21179
- if (s) {
21180
- let p = d.current.editor.onDidChangeMarkers((R) => {
21181
- var _a;
21182
- let G = (_a = o.current.getModel()) == null ? void 0 : _a.uri;
21183
- if (G && R.find((J) => J.path === G.path)) {
21184
- let J = d.current.editor.getModelMarkers({ resource: G });
21185
- T == null ? void 0 : T(J);
21186
- }
21187
- });
21188
- return () => {
21189
- p == null ? void 0 : p.dispose();
21190
- };
21115
+ startExecution();
21116
+ try {
21117
+ const result = await runExecution(workflows, payload || {});
21118
+ if (result) {
21119
+ executeTrace(result);
21120
+ lastExecutionRef.current = current;
21121
+ onExecutionComplete == null ? void 0 : onExecutionComplete(result);
21122
+ }
21123
+ } catch (err) {
21124
+ const errorMessage = err instanceof Error ? err.message : "Execution failed";
21125
+ setExecutionError(errorMessage);
21126
+ onExecutionError == null ? void 0 : onExecutionError(errorMessage);
21191
21127
  }
21192
- return () => {
21193
- };
21194
- }, [s, T]);
21195
- function pe() {
21196
- var _a, _b;
21197
- (_a = I.current) == null ? void 0 : _a.dispose(), V ? y && _.set(m, o.current.saveViewState()) : (_b = o.current.getModel()) == null ? void 0 : _b.dispose(), o.current.dispose();
21198
- }
21199
- return require$$0.createElement(H, { width: z, height: F, isEditorReady: s, loading: N, _ref: b, className: j, wrapperProps: A });
21200
- }
21201
- var fe = Ve;
21202
- var de = memo(fe);
21203
- var Ft = de;
21204
- function findPathLineNumbers(jsonString, paths) {
21205
- if (!paths || paths.length === 0) return [];
21206
- const lines = jsonString.split("\n");
21207
- const lineNumbers = [];
21208
- for (const path of paths) {
21209
- const pathParts = path.split(".");
21210
- const lastKey = pathParts[pathParts.length - 1];
21211
- const keyPattern = new RegExp(`^\\s*"${lastKey}"\\s*:`);
21212
- for (let i = 0; i < lines.length; i++) {
21213
- if (keyPattern.test(lines[i])) {
21214
- if (pathParts.length === 1) {
21215
- lineNumbers.push(i + 1);
21216
- } else {
21217
- let matchedParents = 0;
21218
- for (let j = i - 1; j >= 0 && matchedParents < pathParts.length - 1; j--) {
21219
- const parentKey = pathParts[pathParts.length - 2 - matchedParents];
21220
- const parentPattern = new RegExp(`^\\s*"${parentKey}"\\s*:`);
21221
- if (parentPattern.test(lines[j])) {
21222
- matchedParents++;
21223
- }
21128
+ }, [
21129
+ isEngineReady,
21130
+ workflows,
21131
+ payload,
21132
+ startExecution,
21133
+ runExecution,
21134
+ executeTrace,
21135
+ setExecutionError,
21136
+ onExecutionComplete,
21137
+ onExecutionError
21138
+ ]);
21139
+ const handleReset = useCallback(() => {
21140
+ reset();
21141
+ lastExecutionRef.current = null;
21142
+ }, [reset]);
21143
+ const goToFirst = useCallback(() => {
21144
+ if (hasTrace) {
21145
+ stop();
21146
+ }
21147
+ }, [hasTrace, stop]);
21148
+ const goToLast = useCallback(() => {
21149
+ if (hasTrace && totalSteps > 0) {
21150
+ goToStep(totalSteps - 1);
21151
+ }
21152
+ }, [hasTrace, totalSteps, goToStep]);
21153
+ useEffect(() => {
21154
+ if (!autoExecute || !isEngineReady || workflows.length === 0) return;
21155
+ const timeoutId = setTimeout(() => {
21156
+ handleExecute();
21157
+ }, 500);
21158
+ return () => clearTimeout(timeoutId);
21159
+ }, [autoExecute, isEngineReady, workflows, payload]);
21160
+ const handleKeyDown = useCallback(
21161
+ (e) => {
21162
+ if (e.target instanceof HTMLInputElement || e.target instanceof HTMLTextAreaElement) {
21163
+ return;
21164
+ }
21165
+ switch (e.key) {
21166
+ case " ":
21167
+ e.preventDefault();
21168
+ if (playbackState === "playing") {
21169
+ pause();
21170
+ } else if (hasTrace && !isAtEnd) {
21171
+ play();
21224
21172
  }
21225
- if (matchedParents >= Math.min(pathParts.length - 1, 2)) {
21226
- lineNumbers.push(i + 1);
21173
+ break;
21174
+ case "ArrowRight":
21175
+ e.preventDefault();
21176
+ if (hasTrace && !isAtEnd) {
21177
+ stepForward();
21227
21178
  }
21228
- }
21179
+ break;
21180
+ case "ArrowLeft":
21181
+ e.preventDefault();
21182
+ if (hasTrace && !isAtStart) {
21183
+ stepBackward();
21184
+ }
21185
+ break;
21186
+ case "Home":
21187
+ e.preventDefault();
21188
+ if (hasTrace) {
21189
+ goToFirst();
21190
+ }
21191
+ break;
21192
+ case "End":
21193
+ e.preventDefault();
21194
+ if (hasTrace) {
21195
+ goToLast();
21196
+ }
21197
+ break;
21198
+ case "r":
21199
+ if (e.metaKey || e.ctrlKey) {
21200
+ e.preventDefault();
21201
+ handleReset();
21202
+ }
21203
+ break;
21229
21204
  }
21205
+ },
21206
+ [playbackState, hasTrace, isAtEnd, isAtStart, play, pause, stepForward, stepBackward, goToFirst, goToLast, handleReset]
21207
+ );
21208
+ useEffect(() => {
21209
+ window.addEventListener("keydown", handleKeyDown);
21210
+ return () => window.removeEventListener("keydown", handleKeyDown);
21211
+ }, [handleKeyDown]);
21212
+ const getStatusIcon = () => {
21213
+ var _a;
21214
+ if (isExecuting) {
21215
+ return /* @__PURE__ */ jsx(LoaderCircle, { size: 14, className: "df-debug-spin" });
21230
21216
  }
21231
- }
21232
- return [...new Set(lineNumbers)];
21233
- }
21234
- const defineThemes = (monaco) => {
21235
- monaco.editor.defineTheme("vscode-dark", {
21236
- base: "vs-dark",
21237
- inherit: true,
21238
- rules: [
21239
- { token: "string.key.json", foreground: "9CDCFE" },
21240
- { token: "string.value.json", foreground: "CE9178" },
21241
- { token: "number", foreground: "B5CEA8" },
21242
- { token: "keyword", foreground: "569CD6" },
21243
- { token: "delimiter", foreground: "D4D4D4" }
21244
- ],
21245
- colors: {
21246
- "editor.background": "#1e1e1e",
21247
- "editor.foreground": "#d4d4d4",
21248
- "editor.lineHighlightBackground": "#2d2d2d",
21249
- "editor.selectionBackground": "#264f78",
21250
- "editorCursor.foreground": "#aeafad",
21251
- "editorLineNumber.foreground": "#858585",
21252
- "editorLineNumber.activeForeground": "#c6c6c6",
21253
- "editorIndentGuide.background": "#404040",
21254
- "editorIndentGuide.activeBackground": "#707070",
21255
- "editor.selectionHighlightBackground": "#3a3d41",
21256
- "editorBracketMatch.background": "#0064001a",
21257
- "editorBracketMatch.border": "#888888",
21258
- "editorGutter.background": "#1e1e1e",
21259
- "scrollbarSlider.background": "#79797966",
21260
- "scrollbarSlider.hoverBackground": "#646464b3",
21261
- "scrollbarSlider.activeBackground": "#bfbfbf66",
21262
- "minimap.background": "#1e1e1e"
21217
+ if (executionError) {
21218
+ return /* @__PURE__ */ jsx(CircleX, { size: 14, className: "df-debug-toolbar-status-error" });
21263
21219
  }
21264
- });
21265
- monaco.editor.defineTheme("vscode-light", {
21266
- base: "vs",
21267
- inherit: true,
21268
- rules: [
21269
- { token: "string.key.json", foreground: "0451A5" },
21270
- { token: "string.value.json", foreground: "A31515" },
21271
- { token: "number", foreground: "098658" },
21272
- { token: "keyword", foreground: "0000FF" },
21273
- { token: "delimiter", foreground: "000000" }
21274
- ],
21275
- colors: {
21276
- "editor.background": "#ffffff",
21277
- "editor.foreground": "#000000",
21278
- "editor.lineHighlightBackground": "#f5f5f5",
21279
- "editor.selectionBackground": "#add6ff",
21280
- "editorCursor.foreground": "#000000",
21281
- "editorLineNumber.foreground": "#999999",
21282
- "editorLineNumber.activeForeground": "#000000",
21283
- "editorIndentGuide.background": "#d3d3d3",
21284
- "editorIndentGuide.activeBackground": "#939393",
21285
- "editor.selectionHighlightBackground": "#add6ff4d",
21286
- "editorBracketMatch.background": "#0064001a",
21287
- "editorBracketMatch.border": "#b9b9b9",
21288
- "editorGutter.background": "#ffffff",
21289
- "scrollbarSlider.background": "#64646466",
21290
- "scrollbarSlider.hoverBackground": "#646464b3",
21291
- "scrollbarSlider.activeBackground": "#00000099",
21292
- "minimap.background": "#ffffff"
21220
+ if (hasTrace) {
21221
+ const finalStep = trace == null ? void 0 : trace.steps[trace.steps.length - 1];
21222
+ const hasErrors = ((_a = finalStep == null ? void 0 : finalStep.message) == null ? void 0 : _a.errors) && finalStep.message.errors.length > 0;
21223
+ if (hasErrors) {
21224
+ return /* @__PURE__ */ jsx(CircleAlert, { size: 14, className: "df-debug-toolbar-status-warning" });
21225
+ }
21226
+ return /* @__PURE__ */ jsx(CircleCheckBig, { size: 14, className: "df-debug-toolbar-status-success" });
21227
+ }
21228
+ return null;
21229
+ };
21230
+ const getStepText = () => {
21231
+ if (isExecuting) {
21232
+ return "Executing...";
21233
+ }
21234
+ if (!hasTrace) {
21235
+ return "Ready";
21293
21236
  }
21294
- });
21295
- };
21296
- function JsonEditor({
21237
+ if (currentStepIndex < 0) {
21238
+ return "Ready";
21239
+ }
21240
+ return `Step ${currentStepIndex + 1} / ${totalSteps}`;
21241
+ };
21242
+ return /* @__PURE__ */ jsxs("div", { className: `df-debug-toolbar-integrated ${className}`, children: [
21243
+ /* @__PURE__ */ jsxs("div", { className: "df-debug-toolbar-status", children: [
21244
+ getStatusIcon(),
21245
+ /* @__PURE__ */ jsx("span", { className: "df-debug-toolbar-step-text", children: getStepText() })
21246
+ ] }),
21247
+ /* @__PURE__ */ jsxs("div", { className: "df-debug-toolbar-controls", children: [
21248
+ /* @__PURE__ */ jsx(
21249
+ "button",
21250
+ {
21251
+ className: "df-debug-toolbar-btn",
21252
+ onClick: goToFirst,
21253
+ disabled: !hasTrace || isAtStart || isExecuting,
21254
+ title: "First step (Home)",
21255
+ children: /* @__PURE__ */ jsx(ChevronsLeft, { size: 14 })
21256
+ }
21257
+ ),
21258
+ /* @__PURE__ */ jsx(
21259
+ "button",
21260
+ {
21261
+ className: "df-debug-toolbar-btn",
21262
+ onClick: stepBackward,
21263
+ disabled: !hasTrace || isAtStart || isExecuting,
21264
+ title: "Previous step (Left Arrow)",
21265
+ children: /* @__PURE__ */ jsx(ChevronLeft, { size: 14 })
21266
+ }
21267
+ ),
21268
+ playbackState === "playing" ? /* @__PURE__ */ jsx(
21269
+ "button",
21270
+ {
21271
+ className: "df-debug-toolbar-btn df-debug-toolbar-btn-primary",
21272
+ onClick: pause,
21273
+ disabled: !hasTrace || isExecuting,
21274
+ title: "Pause (Space)",
21275
+ children: /* @__PURE__ */ jsx(Pause, { size: 14 })
21276
+ }
21277
+ ) : /* @__PURE__ */ jsx(
21278
+ "button",
21279
+ {
21280
+ className: "df-debug-toolbar-btn df-debug-toolbar-btn-primary",
21281
+ onClick: play,
21282
+ disabled: !hasTrace || isAtEnd || isExecuting,
21283
+ title: "Play (Space)",
21284
+ children: /* @__PURE__ */ jsx(Play, { size: 14 })
21285
+ }
21286
+ ),
21287
+ /* @__PURE__ */ jsx(
21288
+ "button",
21289
+ {
21290
+ className: "df-debug-toolbar-btn",
21291
+ onClick: stepForward,
21292
+ disabled: !hasTrace || isAtEnd || isExecuting,
21293
+ title: "Next step (Right Arrow)",
21294
+ children: /* @__PURE__ */ jsx(ChevronRight, { size: 14 })
21295
+ }
21296
+ ),
21297
+ /* @__PURE__ */ jsx(
21298
+ "button",
21299
+ {
21300
+ className: "df-debug-toolbar-btn",
21301
+ onClick: goToLast,
21302
+ disabled: !hasTrace || isAtEnd || isExecuting,
21303
+ title: "Last step (End)",
21304
+ children: /* @__PURE__ */ jsx(ChevronsRight, { size: 14 })
21305
+ }
21306
+ )
21307
+ ] }),
21308
+ /* @__PURE__ */ jsx("div", { className: "df-debug-toolbar-actions", children: hasTrace ? /* @__PURE__ */ jsxs(
21309
+ "button",
21310
+ {
21311
+ className: "df-debug-toolbar-btn-action df-debug-toolbar-btn-reset",
21312
+ onClick: handleReset,
21313
+ disabled: isExecuting,
21314
+ title: "Reset (Ctrl+R)",
21315
+ children: [
21316
+ /* @__PURE__ */ jsx(RotateCcw, { size: 12 }),
21317
+ /* @__PURE__ */ jsx("span", { children: "Reset" })
21318
+ ]
21319
+ }
21320
+ ) : /* @__PURE__ */ jsxs(
21321
+ "button",
21322
+ {
21323
+ className: "df-debug-toolbar-btn-action df-debug-toolbar-btn-run",
21324
+ onClick: handleExecute,
21325
+ disabled: !isEngineReady || isExecuting || workflows.length === 0,
21326
+ title: "Run workflow",
21327
+ children: [
21328
+ isExecuting ? /* @__PURE__ */ jsx(LoaderCircle, { size: 12, className: "df-debug-spin" }) : /* @__PURE__ */ jsx(Play, { size: 12 }),
21329
+ /* @__PURE__ */ jsx("span", { children: isExecuting ? "Running..." : "Run" })
21330
+ ]
21331
+ }
21332
+ ) })
21333
+ ] });
21334
+ }
21335
+ function SearchInput({
21297
21336
  value,
21298
21337
  onChange,
21299
- readOnly = false,
21300
- className = "",
21301
- theme = "dark",
21302
- onCursorChange,
21303
- highlightedPaths
21338
+ onClear,
21339
+ placeholder = "Search...",
21340
+ className = ""
21304
21341
  }) {
21305
- const editorRef = useRef(null);
21306
- const decorationsRef = useRef([]);
21307
- const handleEditorMount = useCallback((editor, monaco) => {
21308
- editorRef.current = editor;
21309
- monaco.languages.json.jsonDefaults.setDiagnosticsOptions({
21310
- validate: true,
21311
- schemas: [],
21312
- allowComments: false,
21313
- trailingCommas: "error"
21314
- });
21315
- if (onCursorChange) {
21316
- editor.onDidChangeCursorPosition((e) => {
21317
- onCursorChange(e.position.lineNumber, e.position.column);
21318
- });
21342
+ return /* @__PURE__ */ jsxs("div", { className: `df-search-input ${className}`, children: [
21343
+ /* @__PURE__ */ jsx(Search, { className: "df-search-icon", size: 16 }),
21344
+ /* @__PURE__ */ jsx(
21345
+ "input",
21346
+ {
21347
+ type: "text",
21348
+ value,
21349
+ onChange: (e) => onChange(e.target.value),
21350
+ placeholder,
21351
+ className: "df-search-field"
21352
+ }
21353
+ ),
21354
+ value && onClear && /* @__PURE__ */ jsx(
21355
+ "button",
21356
+ {
21357
+ onClick: onClear,
21358
+ className: "df-search-clear",
21359
+ "aria-label": "Clear search",
21360
+ children: /* @__PURE__ */ jsx(X, { size: 14 })
21361
+ }
21362
+ )
21363
+ ] });
21364
+ }
21365
+ function JsonViewer({
21366
+ data,
21367
+ initialExpanded = false,
21368
+ maxStringLength = 50,
21369
+ className = ""
21370
+ }) {
21371
+ return /* @__PURE__ */ jsx("div", { className: `df-json-viewer ${className}`, children: /* @__PURE__ */ jsx(
21372
+ JsonNode,
21373
+ {
21374
+ data,
21375
+ initialExpanded,
21376
+ maxStringLength
21319
21377
  }
21320
- if (!readOnly) {
21321
- editor.focus();
21378
+ ) });
21379
+ }
21380
+ function JsonNode({
21381
+ data,
21382
+ initialExpanded,
21383
+ maxStringLength,
21384
+ keyName,
21385
+ isLast = true
21386
+ }) {
21387
+ const [expanded, setExpanded] = useState(initialExpanded);
21388
+ const renderValue = () => {
21389
+ if (data === null) {
21390
+ return /* @__PURE__ */ jsx("span", { className: "df-json-null", children: "null" });
21322
21391
  }
21323
- }, [onCursorChange, readOnly]);
21324
- useEffect(() => {
21325
- if (!editorRef.current || !highlightedPaths || highlightedPaths.length === 0) {
21326
- if (editorRef.current && decorationsRef.current.length > 0) {
21327
- decorationsRef.current = editorRef.current.deltaDecorations(decorationsRef.current, []);
21328
- }
21329
- return;
21392
+ if (data === void 0) {
21393
+ return /* @__PURE__ */ jsx("span", { className: "df-json-undefined", children: "undefined" });
21330
21394
  }
21331
- const lineNumbers = findPathLineNumbers(value, highlightedPaths);
21332
- if (lineNumbers.length > 0) {
21333
- const decorations = lineNumbers.map((lineNumber) => ({
21334
- range: {
21335
- startLineNumber: lineNumber,
21336
- startColumn: 1,
21337
- endLineNumber: lineNumber,
21338
- endColumn: 1
21339
- },
21340
- options: {
21341
- isWholeLine: true,
21342
- className: "df-highlighted-line",
21343
- glyphMarginClassName: "df-highlighted-glyph",
21344
- overviewRuler: {
21345
- color: theme === "dark" ? "#4ec9b0" : "#388a34",
21346
- position: 1
21347
- // Left
21348
- }
21349
- }
21350
- }));
21351
- decorationsRef.current = editorRef.current.deltaDecorations(
21352
- decorationsRef.current,
21353
- decorations
21354
- );
21355
- } else {
21356
- decorationsRef.current = editorRef.current.deltaDecorations(decorationsRef.current, []);
21395
+ if (typeof data === "boolean") {
21396
+ return /* @__PURE__ */ jsx("span", { className: "df-json-boolean", children: data.toString() });
21357
21397
  }
21358
- }, [value, highlightedPaths, theme]);
21359
- const handleChange = useCallback((newValue) => {
21360
- onChange(newValue || "");
21361
- }, [onChange]);
21362
- return /* @__PURE__ */ jsx("div", { className: `df-monaco-editor-wrapper ${className}`, children: /* @__PURE__ */ jsx(
21363
- Ft,
21364
- {
21365
- height: "100%",
21366
- defaultLanguage: "json",
21367
- value,
21368
- onChange: handleChange,
21369
- onMount: handleEditorMount,
21370
- beforeMount: defineThemes,
21371
- theme: theme === "dark" ? "vscode-dark" : "vscode-light",
21372
- options: {
21373
- readOnly,
21374
- minimap: { enabled: false },
21375
- fontSize: 13,
21376
- fontFamily: "'SF Mono', Monaco, 'Cascadia Code', 'Roboto Mono', Consolas, monospace",
21377
- lineHeight: 20,
21378
- tabSize: 2,
21379
- insertSpaces: true,
21380
- automaticLayout: true,
21381
- scrollBeyondLastLine: false,
21382
- wordWrap: "on",
21383
- wrappingIndent: "indent",
21384
- folding: true,
21385
- foldingStrategy: "indentation",
21386
- showFoldingControls: "mouseover",
21387
- bracketPairColorization: { enabled: true },
21388
- guides: {
21389
- bracketPairs: false,
21390
- indentation: false,
21391
- highlightActiveBracketPair: true,
21392
- highlightActiveIndentation: false
21393
- },
21394
- renderLineHighlight: readOnly ? "none" : "line",
21395
- selectOnLineNumbers: true,
21396
- roundedSelection: true,
21397
- cursorBlinking: "smooth",
21398
- cursorSmoothCaretAnimation: "on",
21399
- smoothScrolling: true,
21400
- padding: { top: 8, bottom: 8 },
21401
- scrollbar: {
21402
- vertical: "auto",
21403
- horizontal: "auto",
21404
- verticalScrollbarSize: 10,
21405
- horizontalScrollbarSize: 10
21406
- },
21407
- overviewRulerBorder: false,
21408
- hideCursorInOverviewRuler: true,
21409
- contextmenu: true,
21410
- quickSuggestions: false,
21411
- suggestOnTriggerCharacters: false,
21412
- acceptSuggestionOnEnter: "off",
21413
- formatOnPaste: true,
21414
- formatOnType: false,
21415
- glyphMargin: highlightedPaths && highlightedPaths.length > 0
21398
+ if (typeof data === "number") {
21399
+ return /* @__PURE__ */ jsx("span", { className: "df-json-number", children: data });
21400
+ }
21401
+ if (typeof data === "string") {
21402
+ const display = data.length > maxStringLength ? `${data.slice(0, maxStringLength)}...` : data;
21403
+ return /* @__PURE__ */ jsxs("span", { className: "df-json-string", children: [
21404
+ '"',
21405
+ display,
21406
+ '"'
21407
+ ] });
21408
+ }
21409
+ if (Array.isArray(data)) {
21410
+ if (data.length === 0) {
21411
+ return /* @__PURE__ */ jsx("span", { className: "df-json-bracket", children: "[]" });
21416
21412
  }
21413
+ return /* @__PURE__ */ jsxs("span", { className: "df-json-array", children: [
21414
+ /* @__PURE__ */ jsx(
21415
+ "button",
21416
+ {
21417
+ onClick: () => setExpanded(!expanded),
21418
+ className: "df-json-toggle",
21419
+ children: expanded ? /* @__PURE__ */ jsx(ChevronDown, { size: 12 }) : /* @__PURE__ */ jsx(ChevronRight, { size: 12 })
21420
+ }
21421
+ ),
21422
+ /* @__PURE__ */ jsx("span", { className: "df-json-bracket", children: "[" }),
21423
+ !expanded && /* @__PURE__ */ jsxs("span", { className: "df-json-preview", children: [
21424
+ data.length,
21425
+ " item",
21426
+ data.length !== 1 ? "s" : ""
21427
+ ] }),
21428
+ expanded && /* @__PURE__ */ jsx("div", { className: "df-json-children", children: data.map((item, index2) => /* @__PURE__ */ jsx(
21429
+ JsonNode,
21430
+ {
21431
+ data: item,
21432
+ initialExpanded: false,
21433
+ maxStringLength,
21434
+ isLast: index2 === data.length - 1
21435
+ },
21436
+ index2
21437
+ )) }),
21438
+ /* @__PURE__ */ jsx("span", { className: "df-json-bracket", children: "]" })
21439
+ ] });
21417
21440
  }
21418
- ) });
21419
- }
21420
- class ErrorBoundary extends Component {
21421
- constructor(props) {
21422
- super(props);
21423
- this.state = { hasError: false, error: null };
21424
- }
21425
- static getDerivedStateFromError(error) {
21426
- return { hasError: true, error };
21427
- }
21428
- componentDidCatch(error, errorInfo) {
21429
- console.error("ErrorBoundary caught an error:", error, errorInfo);
21430
- }
21431
- render() {
21432
- var _a;
21433
- if (this.state.hasError) {
21434
- if (this.props.fallback) {
21435
- return this.props.fallback;
21441
+ if (typeof data === "object") {
21442
+ const entries = Object.entries(data);
21443
+ if (entries.length === 0) {
21444
+ return /* @__PURE__ */ jsx("span", { className: "df-json-bracket", children: "{}" });
21436
21445
  }
21437
- return /* @__PURE__ */ jsx("div", { className: "df-error-boundary", children: /* @__PURE__ */ jsxs("div", { className: "df-error-boundary-content", children: [
21438
- /* @__PURE__ */ jsx("h3", { className: "df-error-boundary-title", children: "Something went wrong" }),
21439
- /* @__PURE__ */ jsx("p", { className: "df-error-boundary-message", children: ((_a = this.state.error) == null ? void 0 : _a.message) || "An unexpected error occurred" }),
21446
+ return /* @__PURE__ */ jsxs("span", { className: "df-json-object", children: [
21440
21447
  /* @__PURE__ */ jsx(
21441
21448
  "button",
21442
21449
  {
21443
- className: "df-error-boundary-button",
21444
- onClick: () => this.setState({ hasError: false, error: null }),
21445
- children: "Try again"
21450
+ onClick: () => setExpanded(!expanded),
21451
+ className: "df-json-toggle",
21452
+ children: expanded ? /* @__PURE__ */ jsx(ChevronDown, { size: 12 }) : /* @__PURE__ */ jsx(ChevronRight, { size: 12 })
21446
21453
  }
21447
- )
21448
- ] }) });
21454
+ ),
21455
+ /* @__PURE__ */ jsx("span", { className: "df-json-bracket", children: "{" }),
21456
+ !expanded && /* @__PURE__ */ jsxs("span", { className: "df-json-preview", children: [
21457
+ entries.length,
21458
+ " key",
21459
+ entries.length !== 1 ? "s" : ""
21460
+ ] }),
21461
+ expanded && /* @__PURE__ */ jsx("div", { className: "df-json-children", children: entries.map(([key, value], index2) => /* @__PURE__ */ jsx(
21462
+ JsonNode,
21463
+ {
21464
+ keyName: key,
21465
+ data: value,
21466
+ initialExpanded: false,
21467
+ maxStringLength,
21468
+ isLast: index2 === entries.length - 1
21469
+ },
21470
+ key
21471
+ )) }),
21472
+ /* @__PURE__ */ jsx("span", { className: "df-json-bracket", children: "}" })
21473
+ ] });
21449
21474
  }
21450
- return this.props.children;
21475
+ return /* @__PURE__ */ jsx("span", { children: String(data) });
21476
+ };
21477
+ return /* @__PURE__ */ jsxs("div", { className: "df-json-node", children: [
21478
+ keyName !== void 0 && /* @__PURE__ */ jsxs(Fragment, { children: [
21479
+ /* @__PURE__ */ jsxs("span", { className: "df-json-key", children: [
21480
+ '"',
21481
+ keyName,
21482
+ '"'
21483
+ ] }),
21484
+ /* @__PURE__ */ jsx("span", { className: "df-json-colon", children: ": " })
21485
+ ] }),
21486
+ renderValue(),
21487
+ !isLast && /* @__PURE__ */ jsx("span", { className: "df-json-comma", children: "," })
21488
+ ] });
21489
+ }
21490
+ function _arrayLikeToArray(r, a) {
21491
+ (null == a || a > r.length) && (a = r.length);
21492
+ for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e];
21493
+ return n;
21494
+ }
21495
+ function _arrayWithHoles(r) {
21496
+ if (Array.isArray(r)) return r;
21497
+ }
21498
+ function _defineProperty$1(e, r, t) {
21499
+ return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, {
21500
+ value: t,
21501
+ enumerable: true,
21502
+ configurable: true,
21503
+ writable: true
21504
+ }) : e[r] = t, e;
21505
+ }
21506
+ function _iterableToArrayLimit(r, l2) {
21507
+ var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"];
21508
+ if (null != t) {
21509
+ var e, n, i, u, a = [], f = true, o = false;
21510
+ try {
21511
+ if (i = (t = t.call(r)).next, 0 === l2) ;
21512
+ else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l2); f = true) ;
21513
+ } catch (r2) {
21514
+ o = true, n = r2;
21515
+ } finally {
21516
+ try {
21517
+ if (!f && null != t.return && (u = t.return(), Object(u) !== u)) return;
21518
+ } finally {
21519
+ if (o) throw n;
21520
+ }
21521
+ }
21522
+ return a;
21451
21523
  }
21452
21524
  }
21453
- function getSelectionInfo(selection2) {
21454
- switch (selection2.type) {
21455
- case "workflow-condition":
21456
- return {
21457
- title: "Workflow Condition",
21458
- subtitle: selection2.workflow.name
21459
- };
21460
- case "task":
21461
- return {
21462
- title: selection2.task.name,
21463
- subtitle: `${selection2.workflow.name} / ${selection2.task.function.name}`
21464
- };
21465
- case "task-condition":
21466
- return {
21467
- title: "Task Condition",
21468
- subtitle: `${selection2.workflow.name} / ${selection2.task.name}`
21469
- };
21470
- case "mapping":
21471
- return {
21472
- title: selection2.mapping.path,
21473
- subtitle: `${selection2.workflow.name} / ${selection2.task.name}`
21474
- };
21475
- case "validation-rule":
21476
- return {
21477
- title: selection2.rule.message,
21478
- subtitle: `${selection2.workflow.name} / ${selection2.task.name}`
21479
- };
21480
- default:
21481
- return null;
21525
+ function _nonIterableRest() {
21526
+ throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
21527
+ }
21528
+ function ownKeys$1(e, r) {
21529
+ var t = Object.keys(e);
21530
+ if (Object.getOwnPropertySymbols) {
21531
+ var o = Object.getOwnPropertySymbols(e);
21532
+ r && (o = o.filter(function(r2) {
21533
+ return Object.getOwnPropertyDescriptor(e, r2).enumerable;
21534
+ })), t.push.apply(t, o);
21535
+ }
21536
+ return t;
21537
+ }
21538
+ function _objectSpread2$1(e) {
21539
+ for (var r = 1; r < arguments.length; r++) {
21540
+ var t = null != arguments[r] ? arguments[r] : {};
21541
+ r % 2 ? ownKeys$1(Object(t), true).forEach(function(r2) {
21542
+ _defineProperty$1(e, r2, t[r2]);
21543
+ }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys$1(Object(t)).forEach(function(r2) {
21544
+ Object.defineProperty(e, r2, Object.getOwnPropertyDescriptor(t, r2));
21545
+ });
21546
+ }
21547
+ return e;
21548
+ }
21549
+ function _objectWithoutProperties(e, t) {
21550
+ if (null == e) return {};
21551
+ var o, r, i = _objectWithoutPropertiesLoose(e, t);
21552
+ if (Object.getOwnPropertySymbols) {
21553
+ var n = Object.getOwnPropertySymbols(e);
21554
+ for (r = 0; r < n.length; r++) o = n[r], -1 === t.indexOf(o) && {}.propertyIsEnumerable.call(e, o) && (i[o] = e[o]);
21555
+ }
21556
+ return i;
21557
+ }
21558
+ function _objectWithoutPropertiesLoose(r, e) {
21559
+ if (null == r) return {};
21560
+ var t = {};
21561
+ for (var n in r) if ({}.hasOwnProperty.call(r, n)) {
21562
+ if (-1 !== e.indexOf(n)) continue;
21563
+ t[n] = r[n];
21564
+ }
21565
+ return t;
21566
+ }
21567
+ function _slicedToArray(r, e) {
21568
+ return _arrayWithHoles(r) || _iterableToArrayLimit(r, e) || _unsupportedIterableToArray(r, e) || _nonIterableRest();
21569
+ }
21570
+ function _toPrimitive(t, r) {
21571
+ if ("object" != typeof t || !t) return t;
21572
+ var e = t[Symbol.toPrimitive];
21573
+ if (void 0 !== e) {
21574
+ var i = e.call(t, r);
21575
+ if ("object" != typeof i) return i;
21576
+ throw new TypeError("@@toPrimitive must return a primitive value.");
21577
+ }
21578
+ return ("string" === r ? String : Number)(t);
21579
+ }
21580
+ function _toPropertyKey(t) {
21581
+ var i = _toPrimitive(t, "string");
21582
+ return "symbol" == typeof i ? i : i + "";
21583
+ }
21584
+ function _unsupportedIterableToArray(r, a) {
21585
+ if (r) {
21586
+ if ("string" == typeof r) return _arrayLikeToArray(r, a);
21587
+ var t = {}.toString.call(r).slice(8, -1);
21588
+ return "Object" === t && r.constructor && (t = r.constructor.name), "Map" === t || "Set" === t ? Array.from(r) : "Arguments" === t || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t) ? _arrayLikeToArray(r, a) : void 0;
21589
+ }
21590
+ }
21591
+ function _defineProperty(obj, key, value) {
21592
+ if (key in obj) {
21593
+ Object.defineProperty(obj, key, {
21594
+ value,
21595
+ enumerable: true,
21596
+ configurable: true,
21597
+ writable: true
21598
+ });
21599
+ } else {
21600
+ obj[key] = value;
21601
+ }
21602
+ return obj;
21603
+ }
21604
+ function ownKeys(object2, enumerableOnly) {
21605
+ var keys = Object.keys(object2);
21606
+ if (Object.getOwnPropertySymbols) {
21607
+ var symbols = Object.getOwnPropertySymbols(object2);
21608
+ if (enumerableOnly) symbols = symbols.filter(function(sym) {
21609
+ return Object.getOwnPropertyDescriptor(object2, sym).enumerable;
21610
+ });
21611
+ keys.push.apply(keys, symbols);
21612
+ }
21613
+ return keys;
21614
+ }
21615
+ function _objectSpread2(target) {
21616
+ for (var i = 1; i < arguments.length; i++) {
21617
+ var source = arguments[i] != null ? arguments[i] : {};
21618
+ if (i % 2) {
21619
+ ownKeys(Object(source), true).forEach(function(key) {
21620
+ _defineProperty(target, key, source[key]);
21621
+ });
21622
+ } else if (Object.getOwnPropertyDescriptors) {
21623
+ Object.defineProperties(target, Object.getOwnPropertyDescriptors(source));
21624
+ } else {
21625
+ ownKeys(Object(source)).forEach(function(key) {
21626
+ Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key));
21627
+ });
21628
+ }
21629
+ }
21630
+ return target;
21631
+ }
21632
+ function compose$1() {
21633
+ for (var _len = arguments.length, fns = new Array(_len), _key = 0; _key < _len; _key++) {
21634
+ fns[_key] = arguments[_key];
21482
21635
  }
21636
+ return function(x) {
21637
+ return fns.reduceRight(function(y, f) {
21638
+ return f(y);
21639
+ }, x);
21640
+ };
21483
21641
  }
21484
- function VisualizerInner({
21485
- workflows,
21486
- onTaskSelect,
21487
- onWorkflowSelect,
21488
- executionResult,
21489
- debugMode = false
21490
- }) {
21491
- const { resolvedTheme } = useTheme();
21492
- const debuggerContext = debugMode ? useDebugger() : null;
21493
- const [selection2, setSelection] = useState({ type: "none" });
21494
- const [leftPanelWidth, setLeftPanelWidth] = useState(280);
21495
- const [isDragging, setIsDragging] = useState(false);
21496
- const [treePanelHeight, setTreePanelHeight] = useState(50);
21497
- const [isVerticalDragging, setIsVerticalDragging] = useState(false);
21498
- const containerRef = useRef(null);
21499
- const leftPanelRef = useRef(null);
21500
- const handleSelection = (newSelection) => {
21501
- setSelection(newSelection);
21502
- if (newSelection.type === "workflow-condition") {
21503
- onWorkflowSelect == null ? void 0 : onWorkflowSelect(newSelection.workflow);
21504
- } else if (newSelection.type === "task" || newSelection.type === "task-condition" || newSelection.type === "mapping" || newSelection.type === "validation-rule") {
21505
- onTaskSelect == null ? void 0 : onTaskSelect(newSelection.task, newSelection.workflow);
21642
+ function curry$1(fn) {
21643
+ return function curried() {
21644
+ var _this = this;
21645
+ for (var _len2 = arguments.length, args = new Array(_len2), _key2 = 0; _key2 < _len2; _key2++) {
21646
+ args[_key2] = arguments[_key2];
21506
21647
  }
21507
- };
21508
- const handleMouseDown = useCallback((e) => {
21509
- e.preventDefault();
21510
- setIsDragging(true);
21511
- }, []);
21512
- const handleVerticalMouseDown = useCallback((e) => {
21513
- e.preventDefault();
21514
- setIsVerticalDragging(true);
21515
- }, []);
21516
- useEffect(() => {
21517
- if (!isDragging) return;
21518
- const handleMouseMove = (e) => {
21519
- if (containerRef.current) {
21520
- const rect = containerRef.current.getBoundingClientRect();
21521
- const newWidth = e.clientX - rect.left;
21522
- setLeftPanelWidth(Math.max(200, Math.min(450, newWidth)));
21523
- }
21524
- };
21525
- const handleMouseUp = () => {
21526
- setIsDragging(false);
21527
- };
21528
- document.addEventListener("mousemove", handleMouseMove);
21529
- document.addEventListener("mouseup", handleMouseUp);
21530
- return () => {
21531
- document.removeEventListener("mousemove", handleMouseMove);
21532
- document.removeEventListener("mouseup", handleMouseUp);
21533
- };
21534
- }, [isDragging]);
21535
- useEffect(() => {
21536
- if (!isVerticalDragging) return;
21537
- const handleMouseMove = (e) => {
21538
- if (leftPanelRef.current) {
21539
- const rect = leftPanelRef.current.getBoundingClientRect();
21540
- const relativeY = e.clientY - rect.top;
21541
- const percentage = relativeY / rect.height * 100;
21542
- setTreePanelHeight(Math.max(20, Math.min(80, percentage)));
21648
+ return args.length >= fn.length ? fn.apply(this, args) : function() {
21649
+ for (var _len3 = arguments.length, nextArgs = new Array(_len3), _key3 = 0; _key3 < _len3; _key3++) {
21650
+ nextArgs[_key3] = arguments[_key3];
21543
21651
  }
21652
+ return curried.apply(_this, [].concat(args, nextArgs));
21544
21653
  };
21545
- const handleMouseUp = () => {
21546
- setIsVerticalDragging(false);
21547
- };
21548
- document.addEventListener("mousemove", handleMouseMove);
21549
- document.addEventListener("mouseup", handleMouseUp);
21550
- return () => {
21551
- document.removeEventListener("mousemove", handleMouseMove);
21552
- document.removeEventListener("mouseup", handleMouseUp);
21553
- };
21554
- }, [isVerticalDragging]);
21555
- const selectionInfo = getSelectionInfo(selection2);
21556
- const hasDebugTrace = debugMode && (debuggerContext == null ? void 0 : debuggerContext.hasTrace);
21557
- const displayMessage = hasDebugTrace ? debuggerContext == null ? void 0 : debuggerContext.currentMessage : executionResult;
21558
- const currentChanges = hasDebugTrace ? debuggerContext == null ? void 0 : debuggerContext.currentChanges : [];
21559
- const currentStepIndex = hasDebugTrace ? debuggerContext == null ? void 0 : debuggerContext.state.currentStepIndex : -1;
21560
- const highlightedPaths = useMemo(() => {
21561
- if (!currentChanges || currentChanges.length === 0) return void 0;
21562
- return currentChanges.map((change) => change.path);
21563
- }, [currentChanges]);
21564
- const isDraggingAny = isDragging || isVerticalDragging;
21565
- return /* @__PURE__ */ jsx(ErrorBoundary, { children: /* @__PURE__ */ jsxs(
21566
- "div",
21567
- {
21568
- ref: containerRef,
21569
- className: `df-visualizer-horizontal df-theme-${resolvedTheme} ${isDraggingAny ? "df-dragging" : ""}`,
21570
- children: [
21571
- /* @__PURE__ */ jsxs(
21572
- "div",
21573
- {
21574
- ref: leftPanelRef,
21575
- className: "df-visualizer-left",
21576
- style: { width: leftPanelWidth },
21577
- children: [
21578
- /* @__PURE__ */ jsxs(
21579
- "div",
21580
- {
21581
- className: `df-visualizer-left-tree ${displayMessage ? "df-with-result" : ""}`,
21582
- style: displayMessage ? { height: `${treePanelHeight}%` } : void 0,
21583
- children: [
21584
- /* @__PURE__ */ jsx("div", { className: "df-visualizer-left-header", children: /* @__PURE__ */ jsx("span", { className: "df-visualizer-left-title", children: "Explorer" }) }),
21585
- /* @__PURE__ */ jsx("div", { className: "df-visualizer-left-content", children: workflows.length === 0 ? /* @__PURE__ */ jsx("div", { className: "df-empty-state", children: /* @__PURE__ */ jsx("p", { children: "No workflows to display" }) }) : /* @__PURE__ */ jsx(
21586
- TreeView,
21587
- {
21588
- workflows,
21589
- selection: selection2,
21590
- onSelect: handleSelection,
21591
- debugMode
21592
- }
21593
- ) })
21594
- ]
21595
- }
21596
- ),
21597
- displayMessage && /* @__PURE__ */ jsx(
21598
- "div",
21599
- {
21600
- className: `df-visualizer-divider-horizontal ${isVerticalDragging ? "df-divider-active" : ""}`,
21601
- onMouseDown: handleVerticalMouseDown
21602
- }
21603
- ),
21604
- displayMessage && /* @__PURE__ */ jsxs(
21605
- "div",
21606
- {
21607
- className: "df-visualizer-result-panel",
21608
- style: { height: `${100 - treePanelHeight}%` },
21609
- children: [
21610
- /* @__PURE__ */ jsxs("div", { className: "df-visualizer-result-header", children: [
21611
- /* @__PURE__ */ jsx("span", { className: "df-visualizer-result-title", children: hasDebugTrace ? currentStepIndex !== void 0 && currentStepIndex >= 0 ? `Step ${currentStepIndex + 1}` : "Ready" : "Result" }),
21612
- hasDebugTrace && currentChanges && currentChanges.length > 0 && /* @__PURE__ */ jsxs("span", { className: "df-visualizer-result-changes", children: [
21613
- currentChanges.length,
21614
- " change",
21615
- currentChanges.length !== 1 ? "s" : ""
21616
- ] })
21617
- ] }),
21618
- /* @__PURE__ */ jsx("div", { className: "df-visualizer-result-content", children: /* @__PURE__ */ jsx(
21619
- JsonEditor,
21620
- {
21621
- value: JSON.stringify(displayMessage, null, 2),
21622
- onChange: () => {
21623
- },
21624
- readOnly: true,
21625
- theme: resolvedTheme === "dark" ? "dark" : "light",
21626
- highlightedPaths
21627
- }
21628
- ) })
21629
- ]
21630
- }
21631
- )
21632
- ]
21633
- }
21634
- ),
21635
- /* @__PURE__ */ jsx(
21636
- "div",
21637
- {
21638
- className: `df-visualizer-divider ${isDragging ? "df-divider-active" : ""}`,
21639
- onMouseDown: handleMouseDown
21640
- }
21641
- ),
21642
- /* @__PURE__ */ jsxs("div", { className: "df-visualizer-right", children: [
21643
- selectionInfo && /* @__PURE__ */ jsx("div", { className: "df-details-header", children: /* @__PURE__ */ jsxs("div", { className: "df-details-header-info", children: [
21644
- /* @__PURE__ */ jsx("span", { className: "df-details-header-title", children: selectionInfo.title }),
21645
- /* @__PURE__ */ jsx("span", { className: "df-details-header-subtitle", children: selectionInfo.subtitle })
21646
- ] }) }),
21647
- /* @__PURE__ */ jsx(DetailsPanel, { selection: selection2 })
21648
- ] })
21649
- ]
21650
- }
21651
- ) });
21654
+ };
21652
21655
  }
21653
- function WorkflowVisualizer({
21654
- workflows,
21655
- onWorkflowSelect,
21656
- onTaskSelect,
21657
- theme = "system",
21658
- className = "",
21659
- executionResult,
21660
- debugMode = false
21661
- }) {
21662
- return /* @__PURE__ */ jsx(ThemeProvider, { defaultTheme: theme, children: /* @__PURE__ */ jsx("div", { className: `df-root ${className}`, children: /* @__PURE__ */ jsx(
21663
- VisualizerInner,
21664
- {
21665
- workflows,
21666
- onTaskSelect,
21667
- onWorkflowSelect,
21668
- executionResult,
21669
- debugMode
21670
- }
21671
- ) }) });
21656
+ function isObject$1(value) {
21657
+ return {}.toString.call(value).includes("Object");
21672
21658
  }
21673
- function DebuggerControls({ compact = false, className = "" }) {
21674
- const {
21675
- state,
21676
- play,
21677
- pause,
21678
- stop,
21679
- reset,
21680
- stepForward,
21681
- stepBackward,
21682
- setSpeed,
21683
- isAtStart,
21684
- isAtEnd,
21685
- hasTrace,
21686
- progress,
21687
- totalSteps
21688
- } = useDebugger();
21689
- const { playbackState, playbackSpeed, currentStepIndex, isExecuting } = state;
21690
- const handleKeyDown = useCallback(
21691
- (e) => {
21692
- if (e.target instanceof HTMLInputElement || e.target instanceof HTMLTextAreaElement) {
21693
- return;
21694
- }
21695
- switch (e.key) {
21696
- case " ":
21697
- e.preventDefault();
21698
- if (playbackState === "playing") {
21699
- pause();
21700
- } else if (hasTrace) {
21701
- play();
21702
- }
21703
- break;
21704
- case "ArrowRight":
21705
- e.preventDefault();
21706
- if (hasTrace && !isAtEnd) {
21707
- stepForward();
21708
- }
21709
- break;
21710
- case "ArrowLeft":
21711
- e.preventDefault();
21712
- if (hasTrace && !isAtStart) {
21713
- stepBackward();
21714
- }
21715
- break;
21716
- case "Escape":
21717
- e.preventDefault();
21718
- stop();
21719
- break;
21720
- case "r":
21721
- if (e.metaKey || e.ctrlKey) {
21722
- e.preventDefault();
21723
- reset();
21724
- }
21725
- break;
21726
- }
21727
- },
21728
- [playbackState, hasTrace, isAtEnd, isAtStart, play, pause, stop, stepForward, stepBackward, reset]
21729
- );
21730
- useEffect(() => {
21731
- window.addEventListener("keydown", handleKeyDown);
21732
- return () => window.removeEventListener("keydown", handleKeyDown);
21733
- }, [handleKeyDown]);
21734
- const handleSpeedChange = (e) => {
21735
- setSpeed(Number(e.target.value));
21659
+ function isEmpty(obj) {
21660
+ return !Object.keys(obj).length;
21661
+ }
21662
+ function isFunction(value) {
21663
+ return typeof value === "function";
21664
+ }
21665
+ function hasOwnProperty(object2, property) {
21666
+ return Object.prototype.hasOwnProperty.call(object2, property);
21667
+ }
21668
+ function validateChanges(initial, changes) {
21669
+ if (!isObject$1(changes)) errorHandler$1("changeType");
21670
+ if (Object.keys(changes).some(function(field) {
21671
+ return !hasOwnProperty(initial, field);
21672
+ })) errorHandler$1("changeField");
21673
+ return changes;
21674
+ }
21675
+ function validateSelector(selector2) {
21676
+ if (!isFunction(selector2)) errorHandler$1("selectorType");
21677
+ }
21678
+ function validateHandler(handler) {
21679
+ if (!(isFunction(handler) || isObject$1(handler))) errorHandler$1("handlerType");
21680
+ if (isObject$1(handler) && Object.values(handler).some(function(_handler) {
21681
+ return !isFunction(_handler);
21682
+ })) errorHandler$1("handlersType");
21683
+ }
21684
+ function validateInitial(initial) {
21685
+ if (!initial) errorHandler$1("initialIsRequired");
21686
+ if (!isObject$1(initial)) errorHandler$1("initialType");
21687
+ if (isEmpty(initial)) errorHandler$1("initialContent");
21688
+ }
21689
+ function throwError$1(errorMessages2, type) {
21690
+ throw new Error(errorMessages2[type] || errorMessages2["default"]);
21691
+ }
21692
+ var errorMessages$1 = {
21693
+ initialIsRequired: "initial state is required",
21694
+ initialType: "initial state should be an object",
21695
+ initialContent: "initial state shouldn't be an empty object",
21696
+ handlerType: "handler should be an object or a function",
21697
+ handlersType: "all handlers should be a functions",
21698
+ selectorType: "selector should be a function",
21699
+ changeType: "provided value of changes should be an object",
21700
+ changeField: 'it seams you want to change a field in the state which is not specified in the "initial" state',
21701
+ "default": "an unknown error accured in `state-local` package"
21702
+ };
21703
+ var errorHandler$1 = curry$1(throwError$1)(errorMessages$1);
21704
+ var validators$1 = {
21705
+ changes: validateChanges,
21706
+ selector: validateSelector,
21707
+ handler: validateHandler,
21708
+ initial: validateInitial
21709
+ };
21710
+ function create(initial) {
21711
+ var handler = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : {};
21712
+ validators$1.initial(initial);
21713
+ validators$1.handler(handler);
21714
+ var state = {
21715
+ current: initial
21736
21716
  };
21737
- if (compact) {
21738
- return /* @__PURE__ */ jsxs("div", { className: `df-debug-controls df-debug-controls-compact ${className}`, children: [
21739
- /* @__PURE__ */ jsx(
21740
- "button",
21741
- {
21742
- className: "df-debug-btn",
21743
- onClick: stepBackward,
21744
- disabled: !hasTrace || isAtStart || isExecuting,
21745
- title: "Previous step (Left Arrow)",
21746
- children: /* @__PURE__ */ jsx(SkipBack, { size: 16 })
21747
- }
21748
- ),
21749
- playbackState === "playing" ? /* @__PURE__ */ jsx(
21750
- "button",
21751
- {
21752
- className: "df-debug-btn df-debug-btn-primary",
21753
- onClick: pause,
21754
- disabled: !hasTrace || isExecuting,
21755
- title: "Pause (Space)",
21756
- children: /* @__PURE__ */ jsx(Pause, { size: 18 })
21757
- }
21758
- ) : /* @__PURE__ */ jsx(
21759
- "button",
21760
- {
21761
- className: "df-debug-btn df-debug-btn-primary",
21762
- onClick: play,
21763
- disabled: !hasTrace || isAtEnd || isExecuting,
21764
- title: "Play (Space)",
21765
- children: /* @__PURE__ */ jsx(Play, { size: 18 })
21766
- }
21767
- ),
21768
- /* @__PURE__ */ jsx(
21769
- "button",
21770
- {
21771
- className: "df-debug-btn",
21772
- onClick: stepForward,
21773
- disabled: !hasTrace || isAtEnd || isExecuting,
21774
- title: "Next step (Right Arrow)",
21775
- children: /* @__PURE__ */ jsx(SkipForward, { size: 16 })
21776
- }
21777
- ),
21778
- /* @__PURE__ */ jsxs("span", { className: "df-debug-step-counter", children: [
21779
- currentStepIndex + 1,
21780
- " / ",
21781
- totalSteps
21782
- ] })
21783
- ] });
21717
+ var didUpdate = curry$1(didStateUpdate)(state, handler);
21718
+ var update = curry$1(updateState)(state);
21719
+ var validate = curry$1(validators$1.changes)(initial);
21720
+ var getChanges = curry$1(extractChanges)(state);
21721
+ function getState2() {
21722
+ var selector2 = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : function(state2) {
21723
+ return state2;
21724
+ };
21725
+ validators$1.selector(selector2);
21726
+ return selector2(state.current);
21784
21727
  }
21785
- return /* @__PURE__ */ jsxs("div", { className: `df-debug-controls ${className}`, children: [
21786
- /* @__PURE__ */ jsxs("div", { className: "df-debug-controls-main", children: [
21787
- /* @__PURE__ */ jsx(
21788
- "button",
21789
- {
21790
- className: "df-debug-btn",
21791
- onClick: stop,
21792
- disabled: !hasTrace || isExecuting,
21793
- title: "Stop (Escape)",
21794
- children: /* @__PURE__ */ jsx(Square, { size: 20 })
21795
- }
21796
- ),
21797
- /* @__PURE__ */ jsx(
21798
- "button",
21799
- {
21800
- className: "df-debug-btn",
21801
- onClick: stepBackward,
21802
- disabled: !hasTrace || isAtStart || isExecuting,
21803
- title: "Previous step (Left Arrow)",
21804
- children: /* @__PURE__ */ jsx(SkipBack, { size: 20 })
21805
- }
21806
- ),
21807
- playbackState === "playing" ? /* @__PURE__ */ jsx(
21808
- "button",
21809
- {
21810
- className: "df-debug-btn df-debug-btn-primary",
21811
- onClick: pause,
21812
- disabled: !hasTrace || isExecuting,
21813
- title: "Pause (Space)",
21814
- children: /* @__PURE__ */ jsx(Pause, { size: 24 })
21815
- }
21816
- ) : /* @__PURE__ */ jsx(
21817
- "button",
21818
- {
21819
- className: "df-debug-btn df-debug-btn-primary",
21820
- onClick: play,
21821
- disabled: !hasTrace || isAtEnd || isExecuting,
21822
- title: "Play (Space)",
21823
- children: /* @__PURE__ */ jsx(Play, { size: 24 })
21824
- }
21825
- ),
21826
- /* @__PURE__ */ jsx(
21827
- "button",
21828
- {
21829
- className: "df-debug-btn",
21830
- onClick: stepForward,
21831
- disabled: !hasTrace || isAtEnd || isExecuting,
21832
- title: "Next step (Right Arrow)",
21833
- children: /* @__PURE__ */ jsx(SkipForward, { size: 20 })
21834
- }
21835
- ),
21836
- /* @__PURE__ */ jsx(
21837
- "button",
21838
- {
21839
- className: "df-debug-btn",
21840
- onClick: reset,
21841
- disabled: !hasTrace || isExecuting,
21842
- title: "Reset (Ctrl+R)",
21843
- children: /* @__PURE__ */ jsx(RotateCcw, { size: 20 })
21844
- }
21845
- )
21846
- ] }),
21847
- /* @__PURE__ */ jsxs("div", { className: "df-debug-progress", children: [
21848
- /* @__PURE__ */ jsx("div", { className: "df-debug-progress-bar", children: /* @__PURE__ */ jsx(
21849
- "div",
21850
- {
21851
- className: "df-debug-progress-fill",
21852
- style: { width: `${progress * 100}%` }
21853
- }
21854
- ) }),
21855
- /* @__PURE__ */ jsxs("span", { className: "df-debug-step-counter", children: [
21856
- "Step ",
21857
- currentStepIndex + 1,
21858
- " of ",
21859
- totalSteps
21860
- ] })
21861
- ] }),
21862
- /* @__PURE__ */ jsxs("div", { className: "df-debug-speed", children: [
21863
- /* @__PURE__ */ jsx(Gauge, { size: 14 }),
21864
- /* @__PURE__ */ jsx(
21865
- "input",
21866
- {
21867
- type: "range",
21868
- min: "100",
21869
- max: "2000",
21870
- step: "100",
21871
- value: playbackSpeed,
21872
- onChange: handleSpeedChange,
21873
- className: "df-debug-speed-slider",
21874
- title: `Playback speed: ${playbackSpeed}ms`
21875
- }
21876
- ),
21877
- /* @__PURE__ */ jsxs("span", { className: "df-debug-speed-label", children: [
21878
- playbackSpeed,
21879
- "ms"
21880
- ] })
21881
- ] })
21882
- ] });
21728
+ function setState2(causedChanges) {
21729
+ compose$1(didUpdate, update, validate, getChanges)(causedChanges);
21730
+ }
21731
+ return [getState2, setState2];
21883
21732
  }
21884
- function MessageInputPanel({
21885
- onExecute,
21886
- isExecuting = false,
21887
- className = ""
21888
- }) {
21889
- const { setInputPayload, state } = useDebugger();
21890
- const { inputPayload } = state;
21891
- const [expandedSections, setExpandedSections] = useState(
21892
- /* @__PURE__ */ new Set(["payload"])
21893
- );
21894
- const [editingSection, setEditingSection] = useState(null);
21895
- const [editText, setEditText] = useState("");
21896
- const [parseError, setParseError] = useState(null);
21897
- const payload = inputPayload || {};
21898
- const toggleSection = (section) => {
21899
- setExpandedSections((prev) => {
21900
- const next = new Set(prev);
21901
- if (next.has(section)) {
21902
- next.delete(section);
21903
- } else {
21904
- next.add(section);
21733
+ function extractChanges(state, causedChanges) {
21734
+ return isFunction(causedChanges) ? causedChanges(state.current) : causedChanges;
21735
+ }
21736
+ function updateState(state, changes) {
21737
+ state.current = _objectSpread2(_objectSpread2({}, state.current), changes);
21738
+ return changes;
21739
+ }
21740
+ function didStateUpdate(state, handler, changes) {
21741
+ isFunction(handler) ? handler(state.current) : Object.keys(changes).forEach(function(field) {
21742
+ var _handler$field;
21743
+ return (_handler$field = handler[field]) === null || _handler$field === void 0 ? void 0 : _handler$field.call(handler, state.current[field]);
21744
+ });
21745
+ return changes;
21746
+ }
21747
+ var index = {
21748
+ create
21749
+ };
21750
+ var config$1 = {
21751
+ paths: {
21752
+ vs: "https://cdn.jsdelivr.net/npm/monaco-editor@0.55.1/min/vs"
21753
+ }
21754
+ };
21755
+ function curry(fn) {
21756
+ return function curried() {
21757
+ var _this = this;
21758
+ for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
21759
+ args[_key] = arguments[_key];
21760
+ }
21761
+ return args.length >= fn.length ? fn.apply(this, args) : function() {
21762
+ for (var _len2 = arguments.length, nextArgs = new Array(_len2), _key2 = 0; _key2 < _len2; _key2++) {
21763
+ nextArgs[_key2] = arguments[_key2];
21905
21764
  }
21906
- return next;
21907
- });
21908
- };
21909
- const startEditing = () => {
21910
- setEditingSection("payload");
21911
- setEditText(JSON.stringify(payload, null, 2));
21912
- setParseError(null);
21765
+ return curried.apply(_this, [].concat(args, nextArgs));
21766
+ };
21913
21767
  };
21914
- const cancelEditing = () => {
21915
- setEditingSection(null);
21916
- setEditText("");
21917
- setParseError(null);
21768
+ }
21769
+ function isObject(value) {
21770
+ return {}.toString.call(value).includes("Object");
21771
+ }
21772
+ function validateConfig(config2) {
21773
+ if (!config2) errorHandler("configIsRequired");
21774
+ if (!isObject(config2)) errorHandler("configType");
21775
+ if (config2.urls) {
21776
+ informAboutDeprecation();
21777
+ return {
21778
+ paths: {
21779
+ vs: config2.urls.monacoBase
21780
+ }
21781
+ };
21782
+ }
21783
+ return config2;
21784
+ }
21785
+ function informAboutDeprecation() {
21786
+ console.warn(errorMessages.deprecation);
21787
+ }
21788
+ function throwError(errorMessages2, type) {
21789
+ throw new Error(errorMessages2[type] || errorMessages2["default"]);
21790
+ }
21791
+ var errorMessages = {
21792
+ configIsRequired: "the configuration object is required",
21793
+ configType: "the configuration object should be an object",
21794
+ "default": "an unknown error accured in `@monaco-editor/loader` package",
21795
+ deprecation: "Deprecation warning!\n You are using deprecated way of configuration.\n\n Instead of using\n monaco.config({ urls: { monacoBase: '...' } })\n use\n monaco.config({ paths: { vs: '...' } })\n\n For more please check the link https://github.com/suren-atoyan/monaco-loader#config\n "
21796
+ };
21797
+ var errorHandler = curry(throwError)(errorMessages);
21798
+ var validators = {
21799
+ config: validateConfig
21800
+ };
21801
+ var compose = function compose2() {
21802
+ for (var _len = arguments.length, fns = new Array(_len), _key = 0; _key < _len; _key++) {
21803
+ fns[_key] = arguments[_key];
21804
+ }
21805
+ return function(x) {
21806
+ return fns.reduceRight(function(y, f) {
21807
+ return f(y);
21808
+ }, x);
21918
21809
  };
21919
- const saveEditing = useCallback(() => {
21920
- if (!editingSection) return;
21921
- try {
21922
- const parsed = JSON.parse(editText);
21923
- setInputPayload(parsed);
21924
- setEditingSection(null);
21925
- setEditText("");
21926
- setParseError(null);
21927
- } catch (err) {
21928
- setParseError(err instanceof Error ? err.message : "Invalid JSON");
21810
+ };
21811
+ function merge(target, source) {
21812
+ Object.keys(source).forEach(function(key) {
21813
+ if (source[key] instanceof Object) {
21814
+ if (target[key]) {
21815
+ Object.assign(source[key], merge(target[key], source[key]));
21816
+ }
21929
21817
  }
21930
- }, [editingSection, editText, setInputPayload]);
21931
- const handleLoadSample = () => {
21932
- setInputPayload({
21933
- id: "123",
21934
- name: "John Doe",
21935
- email: "john@example.com",
21936
- amount: 100
21818
+ });
21819
+ return _objectSpread2$1(_objectSpread2$1({}, target), source);
21820
+ }
21821
+ var CANCELATION_MESSAGE = {
21822
+ type: "cancelation",
21823
+ msg: "operation is manually canceled"
21824
+ };
21825
+ function makeCancelable(promise) {
21826
+ var hasCanceled_ = false;
21827
+ var wrappedPromise = new Promise(function(resolve, reject) {
21828
+ promise.then(function(val) {
21829
+ return hasCanceled_ ? reject(CANCELATION_MESSAGE) : resolve(val);
21937
21830
  });
21831
+ promise["catch"](reject);
21832
+ });
21833
+ return wrappedPromise.cancel = function() {
21834
+ return hasCanceled_ = true;
21835
+ }, wrappedPromise;
21836
+ }
21837
+ var _excluded = ["monaco"];
21838
+ var _state$create = index.create({
21839
+ config: config$1,
21840
+ isInitialized: false,
21841
+ resolve: null,
21842
+ reject: null,
21843
+ monaco: null
21844
+ }), _state$create2 = _slicedToArray(_state$create, 2), getState = _state$create2[0], setState = _state$create2[1];
21845
+ function config(globalConfig) {
21846
+ var _validators$config = validators.config(globalConfig), monaco = _validators$config.monaco, config2 = _objectWithoutProperties(_validators$config, _excluded);
21847
+ setState(function(state) {
21848
+ return {
21849
+ config: merge(state.config, config2),
21850
+ monaco
21851
+ };
21852
+ });
21853
+ }
21854
+ function init() {
21855
+ var state = getState(function(_ref) {
21856
+ var monaco = _ref.monaco, isInitialized = _ref.isInitialized, resolve = _ref.resolve;
21857
+ return {
21858
+ monaco,
21859
+ isInitialized,
21860
+ resolve
21861
+ };
21862
+ });
21863
+ if (!state.isInitialized) {
21864
+ setState({
21865
+ isInitialized: true
21866
+ });
21867
+ if (state.monaco) {
21868
+ state.resolve(state.monaco);
21869
+ return makeCancelable(wrapperPromise);
21870
+ }
21871
+ if (window.monaco && window.monaco.editor) {
21872
+ storeMonacoInstance(window.monaco);
21873
+ state.resolve(window.monaco);
21874
+ return makeCancelable(wrapperPromise);
21875
+ }
21876
+ compose(injectScripts, getMonacoLoaderScript)(configureLoader);
21877
+ }
21878
+ return makeCancelable(wrapperPromise);
21879
+ }
21880
+ function injectScripts(script) {
21881
+ return document.body.appendChild(script);
21882
+ }
21883
+ function createScript(src) {
21884
+ var script = document.createElement("script");
21885
+ return src && (script.src = src), script;
21886
+ }
21887
+ function getMonacoLoaderScript(configureLoader2) {
21888
+ var state = getState(function(_ref2) {
21889
+ var config2 = _ref2.config, reject = _ref2.reject;
21890
+ return {
21891
+ config: config2,
21892
+ reject
21893
+ };
21894
+ });
21895
+ var loaderScript = createScript("".concat(state.config.paths.vs, "/loader.js"));
21896
+ loaderScript.onload = function() {
21897
+ return configureLoader2();
21938
21898
  };
21939
- const handleClear = () => {
21940
- setInputPayload({});
21941
- };
21942
- const formatValue2 = (value) => {
21943
- if (Object.keys(value).length === 0) {
21944
- return "(empty)";
21899
+ loaderScript.onerror = state.reject;
21900
+ return loaderScript;
21901
+ }
21902
+ function configureLoader() {
21903
+ var state = getState(function(_ref3) {
21904
+ var config2 = _ref3.config, resolve = _ref3.resolve, reject = _ref3.reject;
21905
+ return {
21906
+ config: config2,
21907
+ resolve,
21908
+ reject
21909
+ };
21910
+ });
21911
+ var require2 = window.require;
21912
+ require2.config(state.config);
21913
+ require2(["vs/editor/editor.main"], function(loaded) {
21914
+ var monaco = loaded.m || loaded;
21915
+ storeMonacoInstance(monaco);
21916
+ state.resolve(monaco);
21917
+ }, function(error) {
21918
+ state.reject(error);
21919
+ });
21920
+ }
21921
+ function storeMonacoInstance(monaco) {
21922
+ if (!getState().monaco) {
21923
+ setState({
21924
+ monaco
21925
+ });
21926
+ }
21927
+ }
21928
+ function __getMonacoInstance() {
21929
+ return getState(function(_ref4) {
21930
+ var monaco = _ref4.monaco;
21931
+ return monaco;
21932
+ });
21933
+ }
21934
+ var wrapperPromise = new Promise(function(resolve, reject) {
21935
+ return setState({
21936
+ resolve,
21937
+ reject
21938
+ });
21939
+ });
21940
+ var loader = {
21941
+ config,
21942
+ init,
21943
+ __getMonacoInstance
21944
+ };
21945
+ var le = { wrapper: { display: "flex", position: "relative", textAlign: "initial" }, fullWidth: { width: "100%" }, hide: { display: "none" } }, v = le;
21946
+ var ae = { container: { display: "flex", height: "100%", width: "100%", justifyContent: "center", alignItems: "center" } }, Y = ae;
21947
+ function Me({ children: e }) {
21948
+ return require$$0.createElement("div", { style: Y.container }, e);
21949
+ }
21950
+ var Z = Me;
21951
+ var $ = Z;
21952
+ function Ee({ width: e, height: r, isEditorReady: n, loading: t, _ref: a, className: m, wrapperProps: E }) {
21953
+ return require$$0.createElement("section", { style: { ...v.wrapper, width: e, height: r }, ...E }, !n && require$$0.createElement($, null, t), require$$0.createElement("div", { ref: a, style: { ...v.fullWidth, ...!n && v.hide }, className: m }));
21954
+ }
21955
+ var ee = Ee;
21956
+ var H = memo(ee);
21957
+ function Ce(e) {
21958
+ useEffect(e, []);
21959
+ }
21960
+ var k = Ce;
21961
+ function he(e, r, n = true) {
21962
+ let t = useRef(true);
21963
+ useEffect(t.current || !n ? () => {
21964
+ t.current = false;
21965
+ } : e, r);
21966
+ }
21967
+ var l = he;
21968
+ function D() {
21969
+ }
21970
+ function h(e, r, n, t) {
21971
+ return De(e, t) || be(e, r, n, t);
21972
+ }
21973
+ function De(e, r) {
21974
+ return e.editor.getModel(te(e, r));
21975
+ }
21976
+ function be(e, r, n, t) {
21977
+ return e.editor.createModel(r, n, t ? te(e, t) : void 0);
21978
+ }
21979
+ function te(e, r) {
21980
+ return e.Uri.parse(r);
21981
+ }
21982
+ function Oe({ original: e, modified: r, language: n, originalLanguage: t, modifiedLanguage: a, originalModelPath: m, modifiedModelPath: E, keepCurrentOriginalModel: g = false, keepCurrentModifiedModel: N = false, theme: x = "light", loading: P = "Loading...", options: y = {}, height: V = "100%", width: z = "100%", className: F, wrapperProps: j = {}, beforeMount: A = D, onMount: q = D }) {
21983
+ let [M, O] = useState(false), [T, s] = useState(true), u = useRef(null), c = useRef(null), w = useRef(null), d = useRef(q), o = useRef(A), b = useRef(false);
21984
+ k(() => {
21985
+ let i = loader.init();
21986
+ return i.then((f) => (c.current = f) && s(false)).catch((f) => (f == null ? void 0 : f.type) !== "cancelation" && console.error("Monaco initialization: error:", f)), () => u.current ? I() : i.cancel();
21987
+ }), l(() => {
21988
+ if (u.current && c.current) {
21989
+ let i = u.current.getOriginalEditor(), f = h(c.current, e || "", t || n || "text", m || "");
21990
+ f !== i.getModel() && i.setModel(f);
21991
+ }
21992
+ }, [m], M), l(() => {
21993
+ if (u.current && c.current) {
21994
+ let i = u.current.getModifiedEditor(), f = h(c.current, r || "", a || n || "text", E || "");
21995
+ f !== i.getModel() && i.setModel(f);
21996
+ }
21997
+ }, [E], M), l(() => {
21998
+ let i = u.current.getModifiedEditor();
21999
+ i.getOption(c.current.editor.EditorOption.readOnly) ? i.setValue(r || "") : r !== i.getValue() && (i.executeEdits("", [{ range: i.getModel().getFullModelRange(), text: r || "", forceMoveMarkers: true }]), i.pushUndoStop());
22000
+ }, [r], M), l(() => {
22001
+ var _a, _b;
22002
+ (_b = (_a = u.current) == null ? void 0 : _a.getModel()) == null ? void 0 : _b.original.setValue(e || "");
22003
+ }, [e], M), l(() => {
22004
+ let { original: i, modified: f } = u.current.getModel();
22005
+ c.current.editor.setModelLanguage(i, t || n || "text"), c.current.editor.setModelLanguage(f, a || n || "text");
22006
+ }, [n, t, a], M), l(() => {
22007
+ var _a;
22008
+ (_a = c.current) == null ? void 0 : _a.editor.setTheme(x);
22009
+ }, [x], M), l(() => {
22010
+ var _a;
22011
+ (_a = u.current) == null ? void 0 : _a.updateOptions(y);
22012
+ }, [y], M);
22013
+ let L = useCallback(() => {
22014
+ var _a;
22015
+ if (!c.current) return;
22016
+ o.current(c.current);
22017
+ let i = h(c.current, e || "", t || n || "text", m || ""), f = h(c.current, r || "", a || n || "text", E || "");
22018
+ (_a = u.current) == null ? void 0 : _a.setModel({ original: i, modified: f });
22019
+ }, [n, r, a, e, t, m, E]), U = useCallback(() => {
22020
+ var _a;
22021
+ !b.current && w.current && (u.current = c.current.editor.createDiffEditor(w.current, { automaticLayout: true, ...y }), L(), (_a = c.current) == null ? void 0 : _a.editor.setTheme(x), O(true), b.current = true);
22022
+ }, [y, x, L]);
22023
+ useEffect(() => {
22024
+ M && d.current(u.current, c.current);
22025
+ }, [M]), useEffect(() => {
22026
+ !T && !M && U();
22027
+ }, [T, M, U]);
22028
+ function I() {
22029
+ var _a, _b, _c, _d;
22030
+ let i = (_a = u.current) == null ? void 0 : _a.getModel();
22031
+ g || ((_b = i == null ? void 0 : i.original) == null ? void 0 : _b.dispose()), N || ((_c = i == null ? void 0 : i.modified) == null ? void 0 : _c.dispose()), (_d = u.current) == null ? void 0 : _d.dispose();
22032
+ }
22033
+ return require$$0.createElement(H, { width: z, height: V, isEditorReady: M, loading: P, _ref: w, className: F, wrapperProps: j });
22034
+ }
22035
+ var ie = Oe;
22036
+ memo(ie);
22037
+ function He(e) {
22038
+ let r = useRef();
22039
+ return useEffect(() => {
22040
+ r.current = e;
22041
+ }, [e]), r.current;
22042
+ }
22043
+ var se = He;
22044
+ var _ = /* @__PURE__ */ new Map();
22045
+ function Ve({ defaultValue: e, defaultLanguage: r, defaultPath: n, value: t, language: a, path: m, theme: E = "light", line: g, loading: N = "Loading...", options: x = {}, overrideServices: P = {}, saveViewState: y = true, keepCurrentModel: V = false, width: z = "100%", height: F = "100%", className: j, wrapperProps: A = {}, beforeMount: q = D, onMount: M = D, onChange: O, onValidate: T = D }) {
22046
+ let [s, u] = useState(false), [c, w] = useState(true), d = useRef(null), o = useRef(null), b = useRef(null), L = useRef(M), U = useRef(q), I = useRef(), i = useRef(t), f = se(m), Q = useRef(false), B = useRef(false);
22047
+ k(() => {
22048
+ let p = loader.init();
22049
+ return p.then((R) => (d.current = R) && w(false)).catch((R) => (R == null ? void 0 : R.type) !== "cancelation" && console.error("Monaco initialization: error:", R)), () => o.current ? pe() : p.cancel();
22050
+ }), l(() => {
22051
+ var _a, _b, _c, _d;
22052
+ let p = h(d.current, e || t || "", r || a || "", m || n || "");
22053
+ p !== ((_a = o.current) == null ? void 0 : _a.getModel()) && (y && _.set(f, (_b = o.current) == null ? void 0 : _b.saveViewState()), (_c = o.current) == null ? void 0 : _c.setModel(p), y && ((_d = o.current) == null ? void 0 : _d.restoreViewState(_.get(m))));
22054
+ }, [m], s), l(() => {
22055
+ var _a;
22056
+ (_a = o.current) == null ? void 0 : _a.updateOptions(x);
22057
+ }, [x], s), l(() => {
22058
+ !o.current || t === void 0 || (o.current.getOption(d.current.editor.EditorOption.readOnly) ? o.current.setValue(t) : t !== o.current.getValue() && (B.current = true, o.current.executeEdits("", [{ range: o.current.getModel().getFullModelRange(), text: t, forceMoveMarkers: true }]), o.current.pushUndoStop(), B.current = false));
22059
+ }, [t], s), l(() => {
22060
+ var _a, _b;
22061
+ let p = (_a = o.current) == null ? void 0 : _a.getModel();
22062
+ p && a && ((_b = d.current) == null ? void 0 : _b.editor.setModelLanguage(p, a));
22063
+ }, [a], s), l(() => {
22064
+ var _a;
22065
+ g !== void 0 && ((_a = o.current) == null ? void 0 : _a.revealLine(g));
22066
+ }, [g], s), l(() => {
22067
+ var _a;
22068
+ (_a = d.current) == null ? void 0 : _a.editor.setTheme(E);
22069
+ }, [E], s);
22070
+ let X2 = useCallback(() => {
22071
+ var _a;
22072
+ if (!(!b.current || !d.current) && !Q.current) {
22073
+ U.current(d.current);
22074
+ let p = m || n, R = h(d.current, t || e || "", r || a || "", p || "");
22075
+ o.current = (_a = d.current) == null ? void 0 : _a.editor.create(b.current, { model: R, automaticLayout: true, ...x }, P), y && o.current.restoreViewState(_.get(p)), d.current.editor.setTheme(E), g !== void 0 && o.current.revealLine(g), u(true), Q.current = true;
21945
22076
  }
21946
- return JSON.stringify(value, null, 2);
21947
- };
21948
- const isEmptyPayload = Object.keys(payload).length === 0;
21949
- const isExpanded = expandedSections.has("payload");
21950
- const isEditing = editingSection === "payload";
21951
- return /* @__PURE__ */ jsxs("div", { className: `df-debug-input-panel ${className}`, children: [
21952
- /* @__PURE__ */ jsxs("div", { className: "df-debug-input-header", children: [
21953
- /* @__PURE__ */ jsx("span", { className: "df-debug-input-title", children: "Test Payload" }),
21954
- /* @__PURE__ */ jsxs("div", { className: "df-debug-input-actions", children: [
21955
- /* @__PURE__ */ jsxs(
21956
- "button",
21957
- {
21958
- className: "df-debug-btn-sm",
21959
- onClick: handleLoadSample,
21960
- title: "Load sample data",
21961
- children: [
21962
- /* @__PURE__ */ jsx(FileJson, { size: 12 }),
21963
- "Sample"
21964
- ]
21965
- }
21966
- ),
21967
- /* @__PURE__ */ jsxs(
21968
- "button",
21969
- {
21970
- className: "df-debug-btn-sm",
21971
- onClick: handleClear,
21972
- title: "Clear all data",
21973
- children: [
21974
- /* @__PURE__ */ jsx(RefreshCw, { size: 12 }),
21975
- "Clear"
21976
- ]
21977
- }
21978
- )
21979
- ] })
21980
- ] }),
21981
- /* @__PURE__ */ jsx("div", { className: "df-debug-input-sections", children: /* @__PURE__ */ jsxs("div", { className: "df-debug-input-section", children: [
21982
- /* @__PURE__ */ jsxs(
21983
- "div",
21984
- {
21985
- className: "df-debug-input-section-header",
21986
- onClick: () => !isEditing && toggleSection("payload"),
21987
- children: [
21988
- /* @__PURE__ */ jsx("span", { className: "df-debug-section-toggle", children: isExpanded ? /* @__PURE__ */ jsx(ChevronDown, { size: 14 }) : /* @__PURE__ */ jsx(ChevronRight, { size: 14 }) }),
21989
- /* @__PURE__ */ jsx("span", { className: "df-debug-section-label", children: "Payload" }),
21990
- isEmptyPayload && /* @__PURE__ */ jsx("span", { className: "df-debug-section-empty", children: "(empty)" }),
21991
- !isEditing && /* @__PURE__ */ jsx(
21992
- "button",
21993
- {
21994
- className: "df-debug-section-edit",
21995
- onClick: (e) => {
21996
- e.stopPropagation();
21997
- startEditing();
21998
- },
21999
- title: "Edit Payload",
22000
- children: "Edit"
22001
- }
22002
- )
22003
- ]
22077
+ }, [e, r, n, t, a, m, x, P, y, E, g]);
22078
+ useEffect(() => {
22079
+ s && L.current(o.current, d.current);
22080
+ }, [s]), useEffect(() => {
22081
+ !c && !s && X2();
22082
+ }, [c, s, X2]), i.current = t, useEffect(() => {
22083
+ var _a, _b;
22084
+ s && O && ((_a = I.current) == null ? void 0 : _a.dispose(), I.current = (_b = o.current) == null ? void 0 : _b.onDidChangeModelContent((p) => {
22085
+ B.current || O(o.current.getValue(), p);
22086
+ }));
22087
+ }, [s, O]), useEffect(() => {
22088
+ if (s) {
22089
+ let p = d.current.editor.onDidChangeMarkers((R) => {
22090
+ var _a;
22091
+ let G = (_a = o.current.getModel()) == null ? void 0 : _a.uri;
22092
+ if (G && R.find((J) => J.path === G.path)) {
22093
+ let J = d.current.editor.getModelMarkers({ resource: G });
22094
+ T == null ? void 0 : T(J);
22004
22095
  }
22005
- ),
22006
- isExpanded && /* @__PURE__ */ jsx("div", { className: "df-debug-input-section-content", children: isEditing ? /* @__PURE__ */ jsxs("div", { className: "df-debug-input-editor", children: [
22007
- /* @__PURE__ */ jsx(
22008
- "textarea",
22009
- {
22010
- className: "df-debug-input-textarea",
22011
- value: editText,
22012
- onChange: (e) => setEditText(e.target.value),
22013
- placeholder: "Enter payload as JSON...",
22014
- spellCheck: false
22015
- }
22016
- ),
22017
- parseError && /* @__PURE__ */ jsx("div", { className: "df-debug-input-error", children: parseError }),
22018
- /* @__PURE__ */ jsxs("div", { className: "df-debug-input-editor-actions", children: [
22019
- /* @__PURE__ */ jsx(
22020
- "button",
22021
- {
22022
- className: "df-debug-btn-sm df-debug-btn-cancel",
22023
- onClick: cancelEditing,
22024
- children: "Cancel"
22025
- }
22026
- ),
22027
- /* @__PURE__ */ jsx(
22028
- "button",
22029
- {
22030
- className: "df-debug-btn-sm df-debug-btn-save",
22031
- onClick: saveEditing,
22032
- children: "Save"
22033
- }
22034
- )
22035
- ] })
22036
- ] }) : /* @__PURE__ */ jsx("pre", { className: "df-debug-input-preview", children: formatValue2(payload) }) })
22037
- ] }) }),
22038
- /* @__PURE__ */ jsx("div", { className: "df-debug-input-footer", children: /* @__PURE__ */ jsx(
22039
- "button",
22040
- {
22041
- className: "df-debug-run-btn",
22042
- onClick: onExecute,
22043
- disabled: isExecuting,
22044
- children: isExecuting ? /* @__PURE__ */ jsxs(Fragment, { children: [
22045
- /* @__PURE__ */ jsx(RefreshCw, { size: 14, className: "df-debug-spin" }),
22046
- "Executing..."
22047
- ] }) : /* @__PURE__ */ jsxs(Fragment, { children: [
22048
- /* @__PURE__ */ jsx(Play, { size: 14 }),
22049
- "Run Debug"
22050
- ] })
22051
- }
22052
- ) })
22053
- ] });
22054
- }
22055
- function MessageStatePanel({ className = "" }) {
22056
- const { currentStep, currentMessage, currentChanges } = useDebugger();
22057
- const [activeTab, setActiveTab] = useState("message");
22058
- if (!currentStep || !currentMessage) {
22059
- return /* @__PURE__ */ jsx("div", { className: `df-debug-state-panel df-debug-state-empty ${className}`, children: /* @__PURE__ */ jsx("p", { children: "No step selected. Run debug to see message state changes." }) });
22096
+ });
22097
+ return () => {
22098
+ p == null ? void 0 : p.dispose();
22099
+ };
22100
+ }
22101
+ return () => {
22102
+ };
22103
+ }, [s, T]);
22104
+ function pe() {
22105
+ var _a, _b;
22106
+ (_a = I.current) == null ? void 0 : _a.dispose(), V ? y && _.set(m, o.current.saveViewState()) : (_b = o.current.getModel()) == null ? void 0 : _b.dispose(), o.current.dispose();
22060
22107
  }
22061
- const { workflow_id, task_id, result } = currentStep;
22062
- const tabs = [
22063
- { key: "message", label: "Message" },
22064
- { key: "changes", label: `Changes (${currentChanges.length})` }
22065
- ];
22066
- return /* @__PURE__ */ jsxs("div", { className: `df-debug-state-panel ${className}`, children: [
22067
- /* @__PURE__ */ jsx("div", { className: "df-debug-state-header", children: /* @__PURE__ */ jsx("div", { className: "df-debug-state-tabs", children: tabs.map(({ key, label }) => /* @__PURE__ */ jsx(
22068
- "button",
22069
- {
22070
- className: `df-debug-state-tab ${activeTab === key ? "df-debug-state-tab-active" : ""}`,
22071
- onClick: () => setActiveTab(key),
22072
- children: label
22073
- },
22074
- key
22075
- )) }) }),
22076
- /* @__PURE__ */ jsxs("div", { className: "df-debug-state-content", children: [
22077
- activeTab === "message" && /* @__PURE__ */ jsx(MessageView, { message: currentMessage }),
22078
- activeTab === "changes" && /* @__PURE__ */ jsx(ChangesView, { changes: currentChanges })
22079
- ] }),
22080
- /* @__PURE__ */ jsxs("div", { className: "df-debug-state-footer", children: [
22081
- /* @__PURE__ */ jsxs("div", { className: "df-debug-state-step-type", children: [
22082
- /* @__PURE__ */ jsx("span", { className: `df-debug-state-badge df-debug-state-badge-${result}`, children: result }),
22083
- /* @__PURE__ */ jsxs("span", { className: "df-debug-state-type-label", children: [
22084
- workflow_id,
22085
- task_id ? ` / ${task_id}` : ""
22086
- ] })
22087
- ] }),
22088
- currentMessage.errors.length > 0 && /* @__PURE__ */ jsxs("div", { className: "df-debug-state-error", children: [
22089
- "Errors: ",
22090
- currentMessage.errors.length
22091
- ] })
22092
- ] })
22093
- ] });
22108
+ return require$$0.createElement(H, { width: z, height: F, isEditorReady: s, loading: N, _ref: b, className: j, wrapperProps: A });
22094
22109
  }
22095
- function MessageView({ message }) {
22096
- const [expandedSections, setExpandedSections] = useState(
22097
- /* @__PURE__ */ new Set(["context"])
22098
- );
22099
- const toggleSection = (section) => {
22100
- setExpandedSections((prev) => {
22101
- const next = new Set(prev);
22102
- if (next.has(section)) {
22103
- next.delete(section);
22104
- } else {
22105
- next.add(section);
22110
+ var fe = Ve;
22111
+ var de = memo(fe);
22112
+ var Ft = de;
22113
+ function findPathLineNumbers(jsonString, paths) {
22114
+ if (!paths || paths.length === 0) return [];
22115
+ const lines = jsonString.split("\n");
22116
+ const lineNumbers = [];
22117
+ for (const path of paths) {
22118
+ const pathParts = path.split(".");
22119
+ const lastKey = pathParts[pathParts.length - 1];
22120
+ const keyPattern = new RegExp(`^\\s*"${lastKey}"\\s*:`);
22121
+ for (let i = 0; i < lines.length; i++) {
22122
+ if (keyPattern.test(lines[i])) {
22123
+ if (pathParts.length === 1) {
22124
+ lineNumbers.push(i + 1);
22125
+ } else {
22126
+ let matchedParents = 0;
22127
+ for (let j = i - 1; j >= 0 && matchedParents < pathParts.length - 1; j--) {
22128
+ const parentKey = pathParts[pathParts.length - 2 - matchedParents];
22129
+ const parentPattern = new RegExp(`^\\s*"${parentKey}"\\s*:`);
22130
+ if (parentPattern.test(lines[j])) {
22131
+ matchedParents++;
22132
+ }
22133
+ }
22134
+ if (matchedParents >= Math.min(pathParts.length - 1, 2)) {
22135
+ lineNumbers.push(i + 1);
22136
+ }
22137
+ }
22106
22138
  }
22107
- return next;
22139
+ }
22140
+ }
22141
+ return [...new Set(lineNumbers)];
22142
+ }
22143
+ const defineThemes = (monaco) => {
22144
+ monaco.editor.defineTheme("vscode-dark", {
22145
+ base: "vs-dark",
22146
+ inherit: true,
22147
+ rules: [
22148
+ { token: "string.key.json", foreground: "9CDCFE" },
22149
+ { token: "string.value.json", foreground: "CE9178" },
22150
+ { token: "number", foreground: "B5CEA8" },
22151
+ { token: "keyword", foreground: "569CD6" },
22152
+ { token: "delimiter", foreground: "D4D4D4" }
22153
+ ],
22154
+ colors: {
22155
+ "editor.background": "#1e1e1e",
22156
+ "editor.foreground": "#d4d4d4",
22157
+ "editor.lineHighlightBackground": "#2d2d2d",
22158
+ "editor.selectionBackground": "#264f78",
22159
+ "editorCursor.foreground": "#aeafad",
22160
+ "editorLineNumber.foreground": "#858585",
22161
+ "editorLineNumber.activeForeground": "#c6c6c6",
22162
+ "editorIndentGuide.background": "#404040",
22163
+ "editorIndentGuide.activeBackground": "#707070",
22164
+ "editor.selectionHighlightBackground": "#3a3d41",
22165
+ "editorBracketMatch.background": "#0064001a",
22166
+ "editorBracketMatch.border": "#888888",
22167
+ "editorGutter.background": "#1e1e1e",
22168
+ "scrollbarSlider.background": "#79797966",
22169
+ "scrollbarSlider.hoverBackground": "#646464b3",
22170
+ "scrollbarSlider.activeBackground": "#bfbfbf66",
22171
+ "minimap.background": "#1e1e1e"
22172
+ }
22173
+ });
22174
+ monaco.editor.defineTheme("vscode-light", {
22175
+ base: "vs",
22176
+ inherit: true,
22177
+ rules: [
22178
+ { token: "string.key.json", foreground: "0451A5" },
22179
+ { token: "string.value.json", foreground: "A31515" },
22180
+ { token: "number", foreground: "098658" },
22181
+ { token: "keyword", foreground: "0000FF" },
22182
+ { token: "delimiter", foreground: "000000" }
22183
+ ],
22184
+ colors: {
22185
+ "editor.background": "#ffffff",
22186
+ "editor.foreground": "#000000",
22187
+ "editor.lineHighlightBackground": "#f5f5f5",
22188
+ "editor.selectionBackground": "#add6ff",
22189
+ "editorCursor.foreground": "#000000",
22190
+ "editorLineNumber.foreground": "#999999",
22191
+ "editorLineNumber.activeForeground": "#000000",
22192
+ "editorIndentGuide.background": "#d3d3d3",
22193
+ "editorIndentGuide.activeBackground": "#939393",
22194
+ "editor.selectionHighlightBackground": "#add6ff4d",
22195
+ "editorBracketMatch.background": "#0064001a",
22196
+ "editorBracketMatch.border": "#b9b9b9",
22197
+ "editorGutter.background": "#ffffff",
22198
+ "scrollbarSlider.background": "#64646466",
22199
+ "scrollbarSlider.hoverBackground": "#646464b3",
22200
+ "scrollbarSlider.activeBackground": "#00000099",
22201
+ "minimap.background": "#ffffff"
22202
+ }
22203
+ });
22204
+ };
22205
+ function JsonEditor({
22206
+ value,
22207
+ onChange,
22208
+ readOnly = false,
22209
+ className = "",
22210
+ theme = "dark",
22211
+ onCursorChange,
22212
+ highlightedPaths
22213
+ }) {
22214
+ const editorRef = useRef(null);
22215
+ const decorationsRef = useRef([]);
22216
+ const handleEditorMount = useCallback((editor, monaco) => {
22217
+ editorRef.current = editor;
22218
+ monaco.languages.json.jsonDefaults.setDiagnosticsOptions({
22219
+ validate: true,
22220
+ schemas: [],
22221
+ allowComments: false,
22222
+ trailingCommas: "error"
22108
22223
  });
22109
- };
22110
- const sections = [
22111
- { key: "context", value: message.context },
22112
- { key: "payload", value: message.payload },
22113
- { key: "errors", value: message.errors },
22114
- { key: "audit_trail", value: message.audit_trail }
22115
- ];
22116
- return /* @__PURE__ */ jsx("div", { className: "df-debug-message-view", children: sections.map(({ key, value }) => {
22117
- const isExpanded = expandedSections.has(key);
22118
- const isEmpty2 = Array.isArray(value) ? value.length === 0 : typeof value === "object" && value !== null ? Object.keys(value).length === 0 : !value;
22119
- return /* @__PURE__ */ jsxs("div", { className: "df-debug-message-section", children: [
22120
- /* @__PURE__ */ jsxs(
22121
- "div",
22122
- {
22123
- className: "df-debug-message-section-header",
22124
- onClick: () => toggleSection(key),
22125
- children: [
22126
- /* @__PURE__ */ jsx("span", { className: "df-debug-section-arrow", children: isExpanded ? "▼" : "▶" }),
22127
- /* @__PURE__ */ jsx("span", { className: "df-debug-section-key", children: key }),
22128
- isEmpty2 && /* @__PURE__ */ jsx("span", { className: "df-debug-section-empty", children: "(empty)" })
22129
- ]
22224
+ if (onCursorChange) {
22225
+ editor.onDidChangeCursorPosition((e) => {
22226
+ onCursorChange(e.position.lineNumber, e.position.column);
22227
+ });
22228
+ }
22229
+ if (!readOnly) {
22230
+ editor.focus();
22231
+ }
22232
+ }, [onCursorChange, readOnly]);
22233
+ useEffect(() => {
22234
+ if (!editorRef.current || !highlightedPaths || highlightedPaths.length === 0) {
22235
+ if (editorRef.current && decorationsRef.current.length > 0) {
22236
+ decorationsRef.current = editorRef.current.deltaDecorations(decorationsRef.current, []);
22237
+ }
22238
+ return;
22239
+ }
22240
+ const lineNumbers = findPathLineNumbers(value, highlightedPaths);
22241
+ if (lineNumbers.length > 0) {
22242
+ const decorations = lineNumbers.map((lineNumber) => ({
22243
+ range: {
22244
+ startLineNumber: lineNumber,
22245
+ startColumn: 1,
22246
+ endLineNumber: lineNumber,
22247
+ endColumn: 1
22248
+ },
22249
+ options: {
22250
+ isWholeLine: true,
22251
+ className: "df-highlighted-line",
22252
+ glyphMarginClassName: "df-highlighted-glyph",
22253
+ overviewRuler: {
22254
+ color: theme === "dark" ? "#4ec9b0" : "#388a34",
22255
+ position: 1
22256
+ // Left
22257
+ }
22130
22258
  }
22131
- ),
22132
- isExpanded && /* @__PURE__ */ jsx("pre", { className: "df-debug-message-section-content", children: JSON.stringify(value, null, 2) })
22133
- ] }, key);
22134
- }) });
22259
+ }));
22260
+ decorationsRef.current = editorRef.current.deltaDecorations(
22261
+ decorationsRef.current,
22262
+ decorations
22263
+ );
22264
+ } else {
22265
+ decorationsRef.current = editorRef.current.deltaDecorations(decorationsRef.current, []);
22266
+ }
22267
+ }, [value, highlightedPaths, theme]);
22268
+ const handleChange = useCallback((newValue) => {
22269
+ onChange(newValue || "");
22270
+ }, [onChange]);
22271
+ return /* @__PURE__ */ jsx("div", { className: `df-monaco-editor-wrapper ${className}`, children: /* @__PURE__ */ jsx(
22272
+ Ft,
22273
+ {
22274
+ height: "100%",
22275
+ defaultLanguage: "json",
22276
+ value,
22277
+ onChange: handleChange,
22278
+ onMount: handleEditorMount,
22279
+ beforeMount: defineThemes,
22280
+ theme: theme === "dark" ? "vscode-dark" : "vscode-light",
22281
+ options: {
22282
+ readOnly,
22283
+ minimap: { enabled: false },
22284
+ fontSize: 13,
22285
+ fontFamily: "'SF Mono', Monaco, 'Cascadia Code', 'Roboto Mono', Consolas, monospace",
22286
+ lineHeight: 20,
22287
+ tabSize: 2,
22288
+ insertSpaces: true,
22289
+ automaticLayout: true,
22290
+ scrollBeyondLastLine: false,
22291
+ wordWrap: "on",
22292
+ wrappingIndent: "indent",
22293
+ folding: true,
22294
+ foldingStrategy: "indentation",
22295
+ showFoldingControls: "mouseover",
22296
+ bracketPairColorization: { enabled: true },
22297
+ guides: {
22298
+ bracketPairs: false,
22299
+ indentation: false,
22300
+ highlightActiveBracketPair: true,
22301
+ highlightActiveIndentation: false
22302
+ },
22303
+ renderLineHighlight: readOnly ? "none" : "line",
22304
+ selectOnLineNumbers: true,
22305
+ roundedSelection: true,
22306
+ cursorBlinking: "smooth",
22307
+ cursorSmoothCaretAnimation: "on",
22308
+ smoothScrolling: true,
22309
+ padding: { top: 8, bottom: 8 },
22310
+ scrollbar: {
22311
+ vertical: "auto",
22312
+ horizontal: "auto",
22313
+ verticalScrollbarSize: 10,
22314
+ horizontalScrollbarSize: 10
22315
+ },
22316
+ overviewRulerBorder: false,
22317
+ hideCursorInOverviewRuler: true,
22318
+ contextmenu: true,
22319
+ quickSuggestions: false,
22320
+ suggestOnTriggerCharacters: false,
22321
+ acceptSuggestionOnEnter: "off",
22322
+ formatOnPaste: true,
22323
+ formatOnType: false,
22324
+ glyphMargin: highlightedPaths && highlightedPaths.length > 0
22325
+ }
22326
+ }
22327
+ ) });
22135
22328
  }
22136
- function ChangesView({ changes }) {
22137
- if (changes.length === 0) {
22138
- return /* @__PURE__ */ jsx("div", { className: "df-debug-changes-empty", children: "No changes recorded in this step" });
22329
+ class ErrorBoundary extends Component {
22330
+ constructor(props) {
22331
+ super(props);
22332
+ this.state = { hasError: false, error: null };
22333
+ }
22334
+ static getDerivedStateFromError(error) {
22335
+ return { hasError: true, error };
22336
+ }
22337
+ componentDidCatch(error, errorInfo) {
22338
+ console.error("ErrorBoundary caught an error:", error, errorInfo);
22339
+ }
22340
+ render() {
22341
+ var _a;
22342
+ if (this.state.hasError) {
22343
+ if (this.props.fallback) {
22344
+ return this.props.fallback;
22345
+ }
22346
+ return /* @__PURE__ */ jsx("div", { className: "df-error-boundary", children: /* @__PURE__ */ jsxs("div", { className: "df-error-boundary-content", children: [
22347
+ /* @__PURE__ */ jsx("h3", { className: "df-error-boundary-title", children: "Something went wrong" }),
22348
+ /* @__PURE__ */ jsx("p", { className: "df-error-boundary-message", children: ((_a = this.state.error) == null ? void 0 : _a.message) || "An unexpected error occurred" }),
22349
+ /* @__PURE__ */ jsx(
22350
+ "button",
22351
+ {
22352
+ className: "df-error-boundary-button",
22353
+ onClick: () => this.setState({ hasError: false, error: null }),
22354
+ children: "Try again"
22355
+ }
22356
+ )
22357
+ ] }) });
22358
+ }
22359
+ return this.props.children;
22139
22360
  }
22140
- return /* @__PURE__ */ jsx("div", { className: "df-debug-changes-view", children: changes.map((change, index2) => {
22141
- const isModified = change.old_value !== void 0 && change.new_value !== void 0;
22142
- const isAdded = change.old_value === void 0 && change.new_value !== void 0;
22143
- const isRemoved = change.old_value !== void 0 && change.new_value === void 0;
22144
- const changeType = isAdded ? "added" : isRemoved ? "removed" : "modified";
22145
- return /* @__PURE__ */ jsxs("div", { className: `df-debug-change-item df-debug-change-${changeType}`, children: [
22146
- /* @__PURE__ */ jsxs("div", { className: "df-debug-change-header", children: [
22147
- /* @__PURE__ */ jsx("span", { className: `df-debug-change-op df-debug-change-op-${changeType}`, children: changeType }),
22148
- /* @__PURE__ */ jsx("span", { className: "df-debug-change-path", children: change.path })
22149
- ] }),
22150
- isModified && /* @__PURE__ */ jsxs("div", { className: "df-debug-change-values", children: [
22151
- /* @__PURE__ */ jsx("span", { className: "df-debug-change-old", children: formatValue(change.old_value) }),
22152
- /* @__PURE__ */ jsx("span", { className: "df-debug-change-arrow", children: "→" }),
22153
- /* @__PURE__ */ jsx("span", { className: "df-debug-change-new", children: formatValue(change.new_value) })
22154
- ] }),
22155
- isAdded && /* @__PURE__ */ jsx("div", { className: "df-debug-change-values", children: /* @__PURE__ */ jsx("span", { className: "df-debug-change-new", children: formatValue(change.new_value) }) }),
22156
- isRemoved && /* @__PURE__ */ jsx("div", { className: "df-debug-change-values", children: /* @__PURE__ */ jsx("span", { className: "df-debug-change-old", children: formatValue(change.old_value) }) })
22157
- ] }, index2);
22158
- }) });
22159
22361
  }
22160
- function formatValue(value) {
22161
- if (value === void 0) return "undefined";
22162
- if (value === null) return "null";
22163
- if (typeof value === "string") return `"${value}"`;
22164
- if (typeof value === "object") return JSON.stringify(value);
22165
- return String(value);
22362
+ function getSelectionInfo(selection2) {
22363
+ switch (selection2.type) {
22364
+ case "workflow-condition":
22365
+ return {
22366
+ title: "Workflow Condition",
22367
+ subtitle: selection2.workflow.name
22368
+ };
22369
+ case "task":
22370
+ return {
22371
+ title: selection2.task.name,
22372
+ subtitle: `${selection2.workflow.name} / ${selection2.task.function.name}`
22373
+ };
22374
+ case "task-condition":
22375
+ return {
22376
+ title: "Task Condition",
22377
+ subtitle: `${selection2.workflow.name} / ${selection2.task.name}`
22378
+ };
22379
+ case "mapping":
22380
+ return {
22381
+ title: selection2.mapping.path,
22382
+ subtitle: `${selection2.workflow.name} / ${selection2.task.name}`
22383
+ };
22384
+ case "validation-rule":
22385
+ return {
22386
+ title: selection2.rule.message,
22387
+ subtitle: `${selection2.workflow.name} / ${selection2.task.name}`
22388
+ };
22389
+ default:
22390
+ return null;
22391
+ }
22166
22392
  }
22167
- function DebugInfoBubble({
22168
- step,
22169
- targetRef,
22170
- visible,
22171
- onClose
22393
+ function VisualizerInner({
22394
+ workflows,
22395
+ onTaskSelect,
22396
+ onWorkflowSelect,
22397
+ executionResult,
22398
+ debugConfig,
22399
+ debugPayload
22172
22400
  }) {
22173
- var _a;
22174
- const [position, setPosition] = useState({ top: 0, left: 0 });
22175
- const bubbleRef = useRef(null);
22401
+ const { resolvedTheme } = useTheme();
22402
+ const debugMode = (debugConfig == null ? void 0 : debugConfig.enabled) ?? false;
22403
+ const debuggerContext = useDebuggerOptional();
22404
+ const effectiveDebugContext = debugMode ? debuggerContext : null;
22405
+ const [selection2, setSelection] = useState({ type: "none" });
22406
+ const [leftPanelWidth, setLeftPanelWidth] = useState(280);
22407
+ const [isDragging, setIsDragging] = useState(false);
22408
+ const [treePanelHeight, setTreePanelHeight] = useState(50);
22409
+ const [isVerticalDragging, setIsVerticalDragging] = useState(false);
22410
+ const containerRef = useRef(null);
22411
+ const leftPanelRef = useRef(null);
22412
+ const handleSelection = (newSelection) => {
22413
+ setSelection(newSelection);
22414
+ if (newSelection.type === "workflow-condition") {
22415
+ onWorkflowSelect == null ? void 0 : onWorkflowSelect(newSelection.workflow);
22416
+ } else if (newSelection.type === "task" || newSelection.type === "task-condition" || newSelection.type === "mapping" || newSelection.type === "validation-rule") {
22417
+ onTaskSelect == null ? void 0 : onTaskSelect(newSelection.task, newSelection.workflow);
22418
+ }
22419
+ };
22420
+ const handleMouseDown = useCallback((e) => {
22421
+ e.preventDefault();
22422
+ setIsDragging(true);
22423
+ }, []);
22424
+ const handleVerticalMouseDown = useCallback((e) => {
22425
+ e.preventDefault();
22426
+ setIsVerticalDragging(true);
22427
+ }, []);
22176
22428
  useEffect(() => {
22177
- if (!visible || !targetRef.current) return;
22178
- const updatePosition = () => {
22179
- var _a2, _b;
22180
- const targetRect = (_a2 = targetRef.current) == null ? void 0 : _a2.getBoundingClientRect();
22181
- const bubbleRect = (_b = bubbleRef.current) == null ? void 0 : _b.getBoundingClientRect();
22182
- if (!targetRect) return;
22183
- let top = targetRect.bottom + 8;
22184
- let left = targetRect.left;
22185
- if (bubbleRect) {
22186
- if (left + bubbleRect.width > window.innerWidth - 16) {
22187
- left = window.innerWidth - bubbleRect.width - 16;
22188
- }
22189
- if (top + bubbleRect.height > window.innerHeight - 16) {
22190
- top = targetRect.top - bubbleRect.height - 8;
22191
- }
22429
+ if (!isDragging) return;
22430
+ const handleMouseMove = (e) => {
22431
+ if (containerRef.current) {
22432
+ const rect = containerRef.current.getBoundingClientRect();
22433
+ const newWidth = e.clientX - rect.left;
22434
+ setLeftPanelWidth(Math.max(200, Math.min(450, newWidth)));
22192
22435
  }
22193
- setPosition({ top, left });
22194
22436
  };
22195
- updatePosition();
22196
- window.addEventListener("scroll", updatePosition, true);
22197
- window.addEventListener("resize", updatePosition);
22437
+ const handleMouseUp = () => {
22438
+ setIsDragging(false);
22439
+ };
22440
+ document.addEventListener("mousemove", handleMouseMove);
22441
+ document.addEventListener("mouseup", handleMouseUp);
22198
22442
  return () => {
22199
- window.removeEventListener("scroll", updatePosition, true);
22200
- window.removeEventListener("resize", updatePosition);
22443
+ document.removeEventListener("mousemove", handleMouseMove);
22444
+ document.removeEventListener("mouseup", handleMouseUp);
22201
22445
  };
22202
- }, [visible, targetRef]);
22203
- if (!visible) return null;
22204
- const { workflow_id, task_id, result, message } = step;
22205
- const state = result === "executed" ? "executed" : "skipped";
22206
- const hasError = message && message.errors && message.errors.length > 0;
22207
- const displayState = hasError ? "error" : state;
22208
- return createPortal(
22446
+ }, [isDragging]);
22447
+ useEffect(() => {
22448
+ if (!isVerticalDragging) return;
22449
+ const handleMouseMove = (e) => {
22450
+ if (leftPanelRef.current) {
22451
+ const rect = leftPanelRef.current.getBoundingClientRect();
22452
+ const relativeY = e.clientY - rect.top;
22453
+ const percentage = relativeY / rect.height * 100;
22454
+ setTreePanelHeight(Math.max(20, Math.min(80, percentage)));
22455
+ }
22456
+ };
22457
+ const handleMouseUp = () => {
22458
+ setIsVerticalDragging(false);
22459
+ };
22460
+ document.addEventListener("mousemove", handleMouseMove);
22461
+ document.addEventListener("mouseup", handleMouseUp);
22462
+ return () => {
22463
+ document.removeEventListener("mousemove", handleMouseMove);
22464
+ document.removeEventListener("mouseup", handleMouseUp);
22465
+ };
22466
+ }, [isVerticalDragging]);
22467
+ const selectionInfo = getSelectionInfo(selection2);
22468
+ const hasDebugTrace = debugMode && (effectiveDebugContext == null ? void 0 : effectiveDebugContext.hasTrace);
22469
+ const displayMessage = hasDebugTrace ? effectiveDebugContext == null ? void 0 : effectiveDebugContext.currentMessage : executionResult;
22470
+ const currentChanges = hasDebugTrace ? effectiveDebugContext == null ? void 0 : effectiveDebugContext.currentChanges : [];
22471
+ const currentStepIndex = hasDebugTrace ? effectiveDebugContext == null ? void 0 : effectiveDebugContext.state.currentStepIndex : -1;
22472
+ const highlightedPaths = useMemo(() => {
22473
+ if (!currentChanges || currentChanges.length === 0) return void 0;
22474
+ return currentChanges.map((change) => change.path);
22475
+ }, [currentChanges]);
22476
+ const isDraggingAny = isDragging || isVerticalDragging;
22477
+ return /* @__PURE__ */ jsx(ErrorBoundary, { children: /* @__PURE__ */ jsxs("div", { className: `df-visualizer-container df-theme-${resolvedTheme}`, children: [
22478
+ /* @__PURE__ */ jsxs("div", { className: "df-visualizer-title-bar", children: [
22479
+ /* @__PURE__ */ jsx("span", { className: "df-visualizer-title", children: "Workflows" }),
22480
+ debugMode && debugConfig && /* @__PURE__ */ jsx(
22481
+ IntegratedDebugToolbar,
22482
+ {
22483
+ workflows,
22484
+ payload: debugPayload ?? debugConfig.initialPayload,
22485
+ autoExecute: debugConfig.autoExecute,
22486
+ onExecutionComplete: debugConfig.onExecutionComplete,
22487
+ onExecutionError: debugConfig.onExecutionError
22488
+ }
22489
+ )
22490
+ ] }),
22209
22491
  /* @__PURE__ */ jsxs(
22210
22492
  "div",
22211
22493
  {
22212
- ref: bubbleRef,
22213
- className: "df-debug-bubble",
22214
- style: {
22215
- position: "fixed",
22216
- top: position.top,
22217
- left: position.left
22218
- },
22494
+ ref: containerRef,
22495
+ className: `df-visualizer-horizontal ${isDraggingAny ? "df-dragging" : ""}`,
22219
22496
  children: [
22220
- /* @__PURE__ */ jsxs("div", { className: "df-debug-bubble-header", children: [
22221
- /* @__PURE__ */ jsx(StateIcon, { state: displayState }),
22222
- /* @__PURE__ */ jsx("span", { className: "df-debug-bubble-title", children: task_id ? "Task Step" : "Workflow Skipped" }),
22223
- onClose && /* @__PURE__ */ jsx("button", { className: "df-debug-bubble-close", onClick: onClose, children: /* @__PURE__ */ jsx(X, { size: 14 }) })
22224
- ] }),
22225
- /* @__PURE__ */ jsxs("div", { className: "df-debug-bubble-content", children: [
22226
- /* @__PURE__ */ jsxs("div", { className: "df-debug-bubble-row", children: [
22227
- /* @__PURE__ */ jsx("span", { className: "df-debug-bubble-label", children: "Workflow:" }),
22228
- /* @__PURE__ */ jsx("span", { className: "df-debug-bubble-value", children: workflow_id })
22229
- ] }),
22230
- task_id && /* @__PURE__ */ jsxs("div", { className: "df-debug-bubble-row", children: [
22231
- /* @__PURE__ */ jsx("span", { className: "df-debug-bubble-label", children: "Task:" }),
22232
- /* @__PURE__ */ jsx("span", { className: "df-debug-bubble-value", children: task_id })
22233
- ] }),
22234
- /* @__PURE__ */ jsxs("div", { className: "df-debug-bubble-row", children: [
22235
- /* @__PURE__ */ jsx("span", { className: "df-debug-bubble-label", children: "Result:" }),
22236
- /* @__PURE__ */ jsx("span", { className: `df-debug-bubble-state df-debug-bubble-state-${displayState}`, children: result })
22237
- ] }),
22238
- hasError && (message == null ? void 0 : message.errors) && /* @__PURE__ */ jsxs("div", { className: "df-debug-bubble-error", children: [
22239
- /* @__PURE__ */ jsx(CircleAlert, { size: 14 }),
22240
- /* @__PURE__ */ jsx("span", { children: ((_a = message.errors[0]) == null ? void 0 : _a.message) || "Unknown error" })
22241
- ] })
22497
+ /* @__PURE__ */ jsxs(
22498
+ "div",
22499
+ {
22500
+ ref: leftPanelRef,
22501
+ className: "df-visualizer-left",
22502
+ style: { width: leftPanelWidth },
22503
+ children: [
22504
+ /* @__PURE__ */ jsxs(
22505
+ "div",
22506
+ {
22507
+ className: `df-visualizer-left-tree ${displayMessage ? "df-with-result" : ""}`,
22508
+ style: displayMessage ? { height: `${treePanelHeight}%` } : void 0,
22509
+ children: [
22510
+ /* @__PURE__ */ jsx("div", { className: "df-visualizer-left-header", children: /* @__PURE__ */ jsx("span", { className: "df-visualizer-left-title", children: "Explorer" }) }),
22511
+ /* @__PURE__ */ jsx("div", { className: "df-visualizer-left-content", children: workflows.length === 0 ? /* @__PURE__ */ jsx("div", { className: "df-empty-state", children: /* @__PURE__ */ jsx("p", { children: "No workflows to display" }) }) : /* @__PURE__ */ jsx(
22512
+ TreeView,
22513
+ {
22514
+ workflows,
22515
+ selection: selection2,
22516
+ onSelect: handleSelection,
22517
+ debugMode
22518
+ }
22519
+ ) })
22520
+ ]
22521
+ }
22522
+ ),
22523
+ displayMessage && /* @__PURE__ */ jsx(
22524
+ "div",
22525
+ {
22526
+ className: `df-visualizer-divider-horizontal ${isVerticalDragging ? "df-divider-active" : ""}`,
22527
+ onMouseDown: handleVerticalMouseDown
22528
+ }
22529
+ ),
22530
+ displayMessage && /* @__PURE__ */ jsxs(
22531
+ "div",
22532
+ {
22533
+ className: "df-visualizer-result-panel",
22534
+ style: { height: `${100 - treePanelHeight}%` },
22535
+ children: [
22536
+ /* @__PURE__ */ jsxs("div", { className: "df-visualizer-result-header", children: [
22537
+ /* @__PURE__ */ jsx("span", { className: "df-visualizer-result-title", children: hasDebugTrace ? currentStepIndex !== void 0 && currentStepIndex >= 0 ? `Step ${currentStepIndex + 1}` : "Ready" : "Result" }),
22538
+ hasDebugTrace && currentChanges && currentChanges.length > 0 && /* @__PURE__ */ jsxs("span", { className: "df-visualizer-result-changes", children: [
22539
+ currentChanges.length,
22540
+ " change",
22541
+ currentChanges.length !== 1 ? "s" : ""
22542
+ ] })
22543
+ ] }),
22544
+ /* @__PURE__ */ jsx("div", { className: "df-visualizer-result-content", children: /* @__PURE__ */ jsx(
22545
+ JsonEditor,
22546
+ {
22547
+ value: JSON.stringify(displayMessage, null, 2),
22548
+ onChange: () => {
22549
+ },
22550
+ readOnly: true,
22551
+ theme: resolvedTheme === "dark" ? "dark" : "light",
22552
+ highlightedPaths
22553
+ }
22554
+ ) })
22555
+ ]
22556
+ }
22557
+ )
22558
+ ]
22559
+ }
22560
+ ),
22561
+ /* @__PURE__ */ jsx(
22562
+ "div",
22563
+ {
22564
+ className: `df-visualizer-divider ${isDragging ? "df-divider-active" : ""}`,
22565
+ onMouseDown: handleMouseDown
22566
+ }
22567
+ ),
22568
+ /* @__PURE__ */ jsxs("div", { className: "df-visualizer-right", children: [
22569
+ selectionInfo && /* @__PURE__ */ jsx("div", { className: "df-details-header", children: /* @__PURE__ */ jsxs("div", { className: "df-details-header-info", children: [
22570
+ /* @__PURE__ */ jsx("span", { className: "df-details-header-title", children: selectionInfo.title }),
22571
+ /* @__PURE__ */ jsx("span", { className: "df-details-header-subtitle", children: selectionInfo.subtitle })
22572
+ ] }) }),
22573
+ /* @__PURE__ */ jsx(DetailsPanel, { selection: selection2 })
22242
22574
  ] })
22243
22575
  ]
22244
22576
  }
22245
- ),
22246
- document.body
22247
- );
22248
- }
22249
- function StateIcon({ state }) {
22250
- switch (state) {
22251
- case "executed":
22252
- return /* @__PURE__ */ jsx(Check, { size: 16, className: "df-debug-icon-executed" });
22253
- case "skipped":
22254
- return /* @__PURE__ */ jsx(SkipForward, { size: 16, className: "df-debug-icon-skipped" });
22255
- case "error":
22256
- return /* @__PURE__ */ jsx(CircleAlert, { size: 16, className: "df-debug-icon-error" });
22257
- case "current":
22258
- return /* @__PURE__ */ jsx(Clock, { size: 16, className: "df-debug-icon-current" });
22259
- case "pending":
22260
- default:
22261
- return /* @__PURE__ */ jsx(Clock, { size: 16, className: "df-debug-icon-pending" });
22262
- }
22577
+ )
22578
+ ] }) });
22263
22579
  }
22264
- function DebugStateBadge({
22265
- state,
22266
- conditionResult,
22267
- size = "sm"
22580
+ function WorkflowVisualizer({
22581
+ workflows,
22582
+ onWorkflowSelect,
22583
+ onTaskSelect,
22584
+ theme = "system",
22585
+ className = "",
22586
+ executionResult,
22587
+ debugConfig,
22588
+ debugPayload
22268
22589
  }) {
22269
- const iconSize = size === "sm" ? 12 : 14;
22270
- return /* @__PURE__ */ jsxs("span", { className: `df-debug-badge df-debug-badge-${state} df-debug-badge-${size}`, children: [
22271
- /* @__PURE__ */ jsx(StateIcon, { state }),
22272
- conditionResult !== void 0 && /* @__PURE__ */ jsx("span", { className: `df-debug-badge-condition ${conditionResult ? "df-debug-badge-condition-pass" : "df-debug-badge-condition-fail"}`, children: conditionResult ? /* @__PURE__ */ jsx(Check, { size: iconSize }) : /* @__PURE__ */ jsx(X, { size: iconSize }) })
22273
- ] });
22590
+ if (debugConfig == null ? void 0 : debugConfig.enabled) {
22591
+ return /* @__PURE__ */ jsx(ThemeProvider, { defaultTheme: theme, children: /* @__PURE__ */ jsx(
22592
+ DebuggerProvider,
22593
+ {
22594
+ engineFactory: debugConfig.engineFactory,
22595
+ autoActivate: true,
22596
+ initialPayload: debugPayload ?? debugConfig.initialPayload,
22597
+ children: /* @__PURE__ */ jsx("div", { className: `df-root ${className}`, children: /* @__PURE__ */ jsx(
22598
+ VisualizerInner,
22599
+ {
22600
+ workflows,
22601
+ onTaskSelect,
22602
+ onWorkflowSelect,
22603
+ executionResult,
22604
+ debugConfig,
22605
+ debugPayload
22606
+ }
22607
+ ) })
22608
+ }
22609
+ ) });
22610
+ }
22611
+ return /* @__PURE__ */ jsx(ThemeProvider, { defaultTheme: theme, children: /* @__PURE__ */ jsx("div", { className: `df-root ${className}`, children: /* @__PURE__ */ jsx(
22612
+ VisualizerInner,
22613
+ {
22614
+ workflows,
22615
+ onTaskSelect,
22616
+ onWorkflowSelect,
22617
+ executionResult
22618
+ }
22619
+ ) }) });
22274
22620
  }
22275
22621
  class WasmEngine {
22276
22622
  __destroy_into_raw() {
@@ -22497,6 +22843,7 @@ export {
22497
22843
  DebuggerProvider,
22498
22844
  ErrorBoundary,
22499
22845
  FunctionTypeBadge,
22846
+ IntegratedDebugToolbar,
22500
22847
  JsonViewer,
22501
22848
  MessageInputPanel,
22502
22849
  MessageStatePanel,