@datatechsolutions/ui 2.11.90 → 2.11.92

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (114) hide show
  1. package/README.md +58 -39
  2. package/dist/astrlabe/index.js +108 -106
  3. package/dist/astrlabe/index.mjs +5 -3
  4. package/dist/astrlabe/workflow-canvas.js +5 -3
  5. package/dist/astrlabe/workflow-canvas.mjs +4 -2
  6. package/dist/{chunk-M7PKDVKA.js → chunk-24QKSC74.js} +6 -6
  7. package/dist/{chunk-M7PKDVKA.js.map → chunk-24QKSC74.js.map} +1 -1
  8. package/dist/{chunk-R5D6LLDF.js → chunk-2RDGJXYZ.js} +67 -67
  9. package/dist/{chunk-R5D6LLDF.js.map → chunk-2RDGJXYZ.js.map} +1 -1
  10. package/dist/{chunk-MR3BLQAU.mjs → chunk-3PKG4KFY.mjs} +4 -4
  11. package/dist/{chunk-MR3BLQAU.mjs.map → chunk-3PKG4KFY.mjs.map} +1 -1
  12. package/dist/{chunk-T3S6KZN3.mjs → chunk-3SUFSAP6.mjs} +3 -3
  13. package/dist/{chunk-T3S6KZN3.mjs.map → chunk-3SUFSAP6.mjs.map} +1 -1
  14. package/dist/{chunk-QHTA2ISY.js → chunk-43GCSCQA.js} +12 -12
  15. package/dist/{chunk-QHTA2ISY.js.map → chunk-43GCSCQA.js.map} +1 -1
  16. package/dist/{chunk-UZ3FGGUP.mjs → chunk-4TY55HGO.mjs} +3 -3
  17. package/dist/{chunk-UZ3FGGUP.mjs.map → chunk-4TY55HGO.mjs.map} +1 -1
  18. package/dist/{chunk-RTQOGG4T.mjs → chunk-6NAZVG2O.mjs} +4 -4
  19. package/dist/{chunk-RTQOGG4T.mjs.map → chunk-6NAZVG2O.mjs.map} +1 -1
  20. package/dist/{chunk-S3JHPXOX.mjs → chunk-A3BFURJB.mjs} +560 -6
  21. package/dist/chunk-A3BFURJB.mjs.map +1 -0
  22. package/dist/{chunk-YXPHJ2BQ.js → chunk-ARVLVWUC.js} +18 -5
  23. package/dist/chunk-ARVLVWUC.js.map +1 -0
  24. package/dist/{chunk-FXLGNKP4.js → chunk-BUI7BCUN.js} +33 -33
  25. package/dist/{chunk-FXLGNKP4.js.map → chunk-BUI7BCUN.js.map} +1 -1
  26. package/dist/{chunk-APXM5GFL.js → chunk-DADFESAQ.js} +4 -4
  27. package/dist/{chunk-APXM5GFL.js.map → chunk-DADFESAQ.js.map} +1 -1
  28. package/dist/{chunk-64DLD6FB.js → chunk-DB64YDV2.js} +55 -55
  29. package/dist/{chunk-64DLD6FB.js.map → chunk-DB64YDV2.js.map} +1 -1
  30. package/dist/{chunk-WAOCUWO3.js → chunk-DIMLLLZR.js} +36 -36
  31. package/dist/{chunk-WAOCUWO3.js.map → chunk-DIMLLLZR.js.map} +1 -1
  32. package/dist/{chunk-K6FX26BG.mjs → chunk-DWFLIXES.mjs} +3 -3
  33. package/dist/{chunk-K6FX26BG.mjs.map → chunk-DWFLIXES.mjs.map} +1 -1
  34. package/dist/{chunk-7GDDBF6E.js → chunk-FUVJHNNI.js} +67 -67
  35. package/dist/{chunk-7GDDBF6E.js.map → chunk-FUVJHNNI.js.map} +1 -1
  36. package/dist/{chunk-FS6SU7RE.mjs → chunk-HGN5W56D.mjs} +3 -3
  37. package/dist/{chunk-FS6SU7RE.mjs.map → chunk-HGN5W56D.mjs.map} +1 -1
  38. package/dist/{chunk-TLTYLDX4.mjs → chunk-LKJZGFM4.mjs} +3 -3
  39. package/dist/{chunk-TLTYLDX4.mjs.map → chunk-LKJZGFM4.mjs.map} +1 -1
  40. package/dist/{chunk-MWZQF2D5.js → chunk-MEEFOZC4.js} +4 -4
  41. package/dist/{chunk-MWZQF2D5.js.map → chunk-MEEFOZC4.js.map} +1 -1
  42. package/dist/{chunk-ZV5ZRT6E.mjs → chunk-MLAXYDEU.mjs} +3 -3
  43. package/dist/{chunk-ZV5ZRT6E.mjs.map → chunk-MLAXYDEU.mjs.map} +1 -1
  44. package/dist/{chunk-5NOWS6T3.mjs → chunk-MZAS6TG4.mjs} +3 -3
  45. package/dist/{chunk-5NOWS6T3.mjs.map → chunk-MZAS6TG4.mjs.map} +1 -1
  46. package/dist/{chunk-DIKLHCEM.js → chunk-NA57KK4O.js} +4 -4
  47. package/dist/{chunk-DIKLHCEM.js.map → chunk-NA57KK4O.js.map} +1 -1
  48. package/dist/{chunk-ULWVYDDG.js → chunk-PTGPQJZJ.js} +15 -15
  49. package/dist/{chunk-ULWVYDDG.js.map → chunk-PTGPQJZJ.js.map} +1 -1
  50. package/dist/{chunk-64G2HBRQ.mjs → chunk-PU2KTO4O.mjs} +18 -6
  51. package/dist/chunk-PU2KTO4O.mjs.map +1 -0
  52. package/dist/{chunk-QYH6WLKE.mjs → chunk-RELMVNNR.mjs} +4 -4
  53. package/dist/{chunk-QYH6WLKE.mjs.map → chunk-RELMVNNR.mjs.map} +1 -1
  54. package/dist/{chunk-FDK3PUTV.js → chunk-SFVSDGNF.js} +129 -129
  55. package/dist/{chunk-FDK3PUTV.js.map → chunk-SFVSDGNF.js.map} +1 -1
  56. package/dist/{chunk-5EBDOY4M.js → chunk-TBPWMPZU.js} +26 -26
  57. package/dist/{chunk-5EBDOY4M.js.map → chunk-TBPWMPZU.js.map} +1 -1
  58. package/dist/{chunk-ODEUUB2T.mjs → chunk-VGSWSQQU.mjs} +4 -4
  59. package/dist/{chunk-ODEUUB2T.mjs.map → chunk-VGSWSQQU.mjs.map} +1 -1
  60. package/dist/{chunk-76XIV6VV.mjs → chunk-WI663467.mjs} +7 -7
  61. package/dist/{chunk-76XIV6VV.mjs.map → chunk-WI663467.mjs.map} +1 -1
  62. package/dist/{chunk-WETG7OO3.js → chunk-XSBZNPUO.js} +53 -53
  63. package/dist/{chunk-WETG7OO3.js.map → chunk-XSBZNPUO.js.map} +1 -1
  64. package/dist/{chunk-B3DI2QUM.js → chunk-XXYDLYIT.js} +64 -64
  65. package/dist/{chunk-B3DI2QUM.js.map → chunk-XXYDLYIT.js.map} +1 -1
  66. package/dist/{chunk-IL5RSF2U.mjs → chunk-Y3WJAYOY.mjs} +6 -6
  67. package/dist/{chunk-IL5RSF2U.mjs.map → chunk-Y3WJAYOY.mjs.map} +1 -1
  68. package/dist/{chunk-MJOYUX2C.mjs → chunk-YEWXDCCI.mjs} +4 -4
  69. package/dist/{chunk-MJOYUX2C.mjs.map → chunk-YEWXDCCI.mjs.map} +1 -1
  70. package/dist/{chunk-CM5C4M4F.mjs → chunk-ZHUPYX4Q.mjs} +3 -3
  71. package/dist/{chunk-CM5C4M4F.mjs.map → chunk-ZHUPYX4Q.mjs.map} +1 -1
  72. package/dist/{chunk-ZBX2QSNH.js → chunk-ZKUYNCAG.js} +561 -5
  73. package/dist/chunk-ZKUYNCAG.js.map +1 -0
  74. package/dist/index.d.mts +152 -2
  75. package/dist/index.d.ts +152 -2
  76. package/dist/index.js +754 -744
  77. package/dist/index.mjs +3 -1
  78. package/dist/platform/admin/index.js +12 -10
  79. package/dist/platform/admin/index.mjs +6 -4
  80. package/dist/platform/agents-workspace.js +8 -8
  81. package/dist/platform/agents-workspace.mjs +7 -7
  82. package/dist/platform/app-shell.js +5 -3
  83. package/dist/platform/app-shell.mjs +4 -2
  84. package/dist/platform/auth/index.js +29 -27
  85. package/dist/platform/auth/index.mjs +6 -4
  86. package/dist/platform/billing/index.js +5 -3
  87. package/dist/platform/billing/index.mjs +4 -2
  88. package/dist/platform/impersonation/index.js +5 -3
  89. package/dist/platform/impersonation/index.mjs +4 -2
  90. package/dist/platform/index.d.mts +1 -1
  91. package/dist/platform/index.d.ts +1 -1
  92. package/dist/platform/index.js +100 -100
  93. package/dist/platform/index.mjs +20 -20
  94. package/dist/platform/pages/index.d.mts +2 -2
  95. package/dist/platform/pages/index.d.ts +2 -2
  96. package/dist/platform/pages/index.js +197 -195
  97. package/dist/platform/pages/index.js.map +1 -1
  98. package/dist/platform/pages/index.mjs +9 -7
  99. package/dist/platform/pages/index.mjs.map +1 -1
  100. package/dist/platform/settings/index.js +9 -7
  101. package/dist/platform/settings/index.mjs +8 -6
  102. package/dist/platform/workflow-api-client.d.mts +1 -1
  103. package/dist/platform/workflow-api-client.d.ts +1 -1
  104. package/dist/platform/workflow-api-client.js +64 -60
  105. package/dist/platform/workflow-api-client.mjs +1 -1
  106. package/dist/platform/workflow-canvas-shell.js +6 -4
  107. package/dist/platform/workflow-canvas-shell.mjs +5 -3
  108. package/dist/{workflow-api-client-C8gPn_D1.d.mts → workflow-api-client-wLoap-tt.d.mts} +54 -3
  109. package/dist/{workflow-api-client-Dy1Ph8W-.d.ts → workflow-api-client-zVtc8FIl.d.ts} +54 -3
  110. package/package.json +1 -1
  111. package/dist/chunk-64G2HBRQ.mjs.map +0 -1
  112. package/dist/chunk-S3JHPXOX.mjs.map +0 -1
  113. package/dist/chunk-YXPHJ2BQ.js.map +0 -1
  114. package/dist/chunk-ZBX2QSNH.js.map +0 -1
@@ -4,6 +4,7 @@
4
4
  var chunkUZ3CMNUJ_js = require('./chunk-UZ3CMNUJ.js');
5
5
  var chunkYXN2K77G_js = require('./chunk-YXN2K77G.js');
6
6
  var chunkS7KHTUHA_js = require('./chunk-S7KHTUHA.js');
7
+ var chunkARVLVWUC_js = require('./chunk-ARVLVWUC.js');
7
8
  var Headless6 = require('@headlessui/react');
8
9
  var clsx = require('clsx');
9
10
  var React12 = require('react');
@@ -2529,7 +2530,11 @@ function AgentAnalysisCard({ name, avatar, duration, output }) {
2529
2530
  /* @__PURE__ */ jsxRuntime.jsx("p", { className: "text-[8px] text-gray-400 leading-relaxed", children: output })
2530
2531
  ] });
2531
2532
  }
2532
- function DashboardView({ spec, className }) {
2533
+ function DashboardView({
2534
+ spec,
2535
+ className,
2536
+ renderInputRequest
2537
+ }) {
2533
2538
  const layout = spec.layout ?? "grid";
2534
2539
  const hasCharts = (spec.charts?.length ?? 0) > 0;
2535
2540
  const chartGrid = layout === "grid" && (spec.charts?.length ?? 0) > 1 ? "grid grid-cols-1 gap-4 lg:grid-cols-2" : "grid grid-cols-1 gap-4";
@@ -2564,7 +2569,8 @@ function DashboardView({ spec, className }) {
2564
2569
  spec.sections && spec.sections.length > 0 && /* @__PURE__ */ jsxRuntime.jsx("div", { className: "space-y-4", children: spec.sections.map((section, index) => /* @__PURE__ */ jsxRuntime.jsx(
2565
2570
  DashboardSectionRenderer,
2566
2571
  {
2567
- section
2572
+ section,
2573
+ renderInputRequest
2568
2574
  },
2569
2575
  `${section.type}-${index}`
2570
2576
  )) }),
@@ -2635,7 +2641,10 @@ function formatNumber(value) {
2635
2641
  if (Math.abs(value) >= 1e3) return new Intl.NumberFormat("en-US").format(Math.round(value));
2636
2642
  return value.toFixed(Math.abs(value) < 10 ? 2 : 1);
2637
2643
  }
2638
- function DashboardSectionRenderer({ section }) {
2644
+ function DashboardSectionRenderer({
2645
+ section,
2646
+ renderInputRequest
2647
+ }) {
2639
2648
  switch (section.type) {
2640
2649
  case "entity":
2641
2650
  return /* @__PURE__ */ jsxRuntime.jsx(EntitySection, { data: section.data });
@@ -2655,10 +2664,30 @@ function DashboardSectionRenderer({ section }) {
2655
2664
  return /* @__PURE__ */ jsxRuntime.jsx(ScoreSection, { data: section.data });
2656
2665
  case "note":
2657
2666
  return /* @__PURE__ */ jsxRuntime.jsx(NoteSection, { data: section.data });
2667
+ case "input_request":
2668
+ return renderInputRequest ? /* @__PURE__ */ jsxRuntime.jsx(jsxRuntime.Fragment, { children: renderInputRequest(section.data) }) : /* @__PURE__ */ jsxRuntime.jsx(InputRequestReadOnly, { data: section.data });
2658
2669
  default:
2659
2670
  return /* @__PURE__ */ jsxRuntime.jsx(NoteSection, { data: { body: JSON.stringify(section, null, 2), tone: "info" } });
2660
2671
  }
2661
2672
  }
2673
+ function InputRequestReadOnly({ data }) {
2674
+ return /* @__PURE__ */ jsxRuntime.jsxs("section", { className: "rounded-xl border border-sky-500/20 bg-sky-500/5 p-4 dark:border-sky-400/30 dark:bg-sky-500/10", children: [
2675
+ /* @__PURE__ */ jsxRuntime.jsx("h3", { className: "text-sm font-semibold text-slate-900 dark:text-slate-100", children: data.prompt }),
2676
+ data.description && /* @__PURE__ */ jsxRuntime.jsx("p", { className: "mt-1 text-xs text-slate-600 dark:text-slate-400", children: data.description }),
2677
+ /* @__PURE__ */ jsxRuntime.jsx("ul", { className: "mt-3 space-y-1", children: data.fields.map((field) => /* @__PURE__ */ jsxRuntime.jsxs("li", { className: "text-xs", children: [
2678
+ /* @__PURE__ */ jsxRuntime.jsxs("span", { className: "font-medium text-slate-700 dark:text-slate-300", children: [
2679
+ field.label,
2680
+ field.required && /* @__PURE__ */ jsxRuntime.jsx("span", { className: "ml-1 text-rose-500", children: "*" })
2681
+ ] }),
2682
+ /* @__PURE__ */ jsxRuntime.jsxs("span", { className: "ml-2 text-slate-500 dark:text-slate-400", children: [
2683
+ "(",
2684
+ field.kind,
2685
+ ")"
2686
+ ] })
2687
+ ] }, field.key)) }),
2688
+ /* @__PURE__ */ jsxRuntime.jsx("p", { className: "mt-3 text-[11px] italic text-slate-500 dark:text-slate-400", children: "Esta requisi\xE7\xE3o requer entrada do operador \u2014 abra a run ao vivo para responder." })
2689
+ ] });
2690
+ }
2662
2691
  function EntitySection({ data }) {
2663
2692
  const statusKey = data.status?.tone === "success" ? "success" : data.status?.tone === "danger" ? "error" : data.status?.tone === "warning" ? "pending" : data.status?.tone === "info" ? "processing" : "active";
2664
2693
  return /* @__PURE__ */ jsxRuntime.jsx(
@@ -2859,6 +2888,531 @@ function formatTimestamp(iso) {
2859
2888
  return iso;
2860
2889
  }
2861
2890
  }
2891
+ function InputRequestForm({
2892
+ runId,
2893
+ data,
2894
+ onResolved
2895
+ }) {
2896
+ const [values, setValues] = React12.useState(
2897
+ () => initialValues(data.fields)
2898
+ );
2899
+ const [submitting, setSubmitting] = React12.useState(false);
2900
+ const [resolved, setResolved] = React12.useState(null);
2901
+ const [error, setError] = React12.useState(null);
2902
+ async function submit(decision) {
2903
+ if (submitting || resolved) return;
2904
+ setSubmitting(true);
2905
+ setError(null);
2906
+ try {
2907
+ const payload = decision === "approved" ? sanitizeForSubmit(values) : void 0;
2908
+ const reason = decision === "rejected" ? typeof values.reason === "string" ? values.reason : "rejected" : void 0;
2909
+ await chunkARVLVWUC_js.submitApproval(runId, data.nodeId, {
2910
+ approved: decision === "approved",
2911
+ ...payload ? { payload } : {},
2912
+ ...reason ? { reason } : {}
2913
+ });
2914
+ setResolved({
2915
+ approved: decision === "approved",
2916
+ message: decision === "approved" ? "Aprovado \u2014 workflow retomado." : "Rejeitado \u2014 workflow encerrado."
2917
+ });
2918
+ onResolved?.({
2919
+ approved: decision === "approved",
2920
+ payload: payload ?? {}
2921
+ });
2922
+ } catch (e) {
2923
+ setError(
2924
+ e instanceof Error ? e.message : "Falha ao registrar a decis\xE3o."
2925
+ );
2926
+ } finally {
2927
+ setSubmitting(false);
2928
+ }
2929
+ }
2930
+ function onFieldChange(key, value) {
2931
+ setValues((prev) => ({ ...prev, [key]: value }));
2932
+ }
2933
+ function onSubmitForm(event) {
2934
+ event.preventDefault();
2935
+ void submit("approved");
2936
+ }
2937
+ const accentClasses = TONE_BLOCK2[data.tone ?? "info"];
2938
+ return /* @__PURE__ */ jsxRuntime.jsxs(
2939
+ "form",
2940
+ {
2941
+ onSubmit: onSubmitForm,
2942
+ className: `rounded-xl border p-4 ${accentClasses}`,
2943
+ children: [
2944
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
2945
+ /* @__PURE__ */ jsxRuntime.jsx("h3", { className: "text-sm font-semibold text-slate-900 dark:text-slate-100", children: data.prompt }),
2946
+ data.description && /* @__PURE__ */ jsxRuntime.jsx("p", { className: "mt-1 text-xs text-slate-600 dark:text-slate-400", children: data.description })
2947
+ ] }),
2948
+ /* @__PURE__ */ jsxRuntime.jsx("div", { className: "mt-4 space-y-3", children: data.fields.map((field) => /* @__PURE__ */ jsxRuntime.jsx(
2949
+ FieldInput,
2950
+ {
2951
+ field,
2952
+ value: values[field.key],
2953
+ disabled: submitting || Boolean(resolved),
2954
+ onChange: (value) => onFieldChange(field.key, value)
2955
+ },
2956
+ field.key
2957
+ )) }),
2958
+ error && /* @__PURE__ */ jsxRuntime.jsx("p", { className: "mt-3 text-xs text-rose-700 dark:text-rose-300", children: error }),
2959
+ resolved ? /* @__PURE__ */ jsxRuntime.jsx("p", { className: "mt-3 text-xs font-medium text-emerald-800 dark:text-emerald-200", children: resolved.message }) : /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "mt-4 flex flex-wrap items-center justify-end gap-2", children: [
2960
+ data.rejectLabel !== null && /* @__PURE__ */ jsxRuntime.jsx(
2961
+ "button",
2962
+ {
2963
+ type: "button",
2964
+ disabled: submitting,
2965
+ onClick: () => submit("rejected"),
2966
+ className: "rounded-md border border-rose-500/30 bg-rose-500/5 px-3 py-1.5 text-sm font-medium text-rose-700 hover:bg-rose-500/10 disabled:opacity-50 dark:text-rose-300",
2967
+ children: data.rejectLabel ?? "Rejeitar"
2968
+ }
2969
+ ),
2970
+ /* @__PURE__ */ jsxRuntime.jsx(
2971
+ "button",
2972
+ {
2973
+ type: "submit",
2974
+ disabled: submitting,
2975
+ className: "rounded-md bg-emerald-600 px-3 py-1.5 text-sm font-medium text-white hover:bg-emerald-500 disabled:opacity-50",
2976
+ children: submitting ? "Enviando\u2026" : data.submitLabel ?? "Aprovar"
2977
+ }
2978
+ )
2979
+ ] })
2980
+ ]
2981
+ }
2982
+ );
2983
+ }
2984
+ function FieldInput({
2985
+ field,
2986
+ value,
2987
+ disabled,
2988
+ onChange
2989
+ }) {
2990
+ const labelEl = /* @__PURE__ */ jsxRuntime.jsxs(
2991
+ "label",
2992
+ {
2993
+ htmlFor: `input-${field.key}`,
2994
+ className: "block text-xs font-medium text-slate-700 dark:text-slate-300",
2995
+ children: [
2996
+ field.label,
2997
+ field.required && /* @__PURE__ */ jsxRuntime.jsx("span", { className: "ml-1 text-rose-500", children: "*" })
2998
+ ]
2999
+ }
3000
+ );
3001
+ const helpEl = field.helpText ? /* @__PURE__ */ jsxRuntime.jsx("p", { className: "mt-1 text-[11px] text-slate-500 dark:text-slate-400", children: field.helpText }) : null;
3002
+ switch (field.kind) {
3003
+ case "text":
3004
+ return /* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
3005
+ labelEl,
3006
+ /* @__PURE__ */ jsxRuntime.jsx(
3007
+ "input",
3008
+ {
3009
+ id: `input-${field.key}`,
3010
+ type: "text",
3011
+ disabled,
3012
+ required: field.required,
3013
+ placeholder: field.placeholder,
3014
+ value: typeof value === "string" ? value : "",
3015
+ onChange: (e) => onChange(e.target.value),
3016
+ className: INPUT_CLASSES
3017
+ }
3018
+ ),
3019
+ helpEl
3020
+ ] });
3021
+ case "number":
3022
+ return /* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
3023
+ labelEl,
3024
+ /* @__PURE__ */ jsxRuntime.jsx(
3025
+ "input",
3026
+ {
3027
+ id: `input-${field.key}`,
3028
+ type: "number",
3029
+ disabled,
3030
+ required: field.required,
3031
+ placeholder: field.placeholder,
3032
+ min: field.min,
3033
+ max: field.max,
3034
+ step: field.step,
3035
+ value: typeof value === "number" ? value : typeof value === "string" ? value : "",
3036
+ onChange: (e) => {
3037
+ const raw = e.target.value;
3038
+ onChange(raw === "" ? "" : Number(raw));
3039
+ },
3040
+ className: INPUT_CLASSES
3041
+ }
3042
+ ),
3043
+ helpEl
3044
+ ] });
3045
+ case "textarea":
3046
+ return /* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
3047
+ labelEl,
3048
+ /* @__PURE__ */ jsxRuntime.jsx(
3049
+ "textarea",
3050
+ {
3051
+ id: `input-${field.key}`,
3052
+ disabled,
3053
+ required: field.required,
3054
+ placeholder: field.placeholder,
3055
+ rows: field.rows ?? 3,
3056
+ value: typeof value === "string" ? value : "",
3057
+ onChange: (e) => onChange(e.target.value),
3058
+ className: INPUT_CLASSES
3059
+ }
3060
+ ),
3061
+ helpEl
3062
+ ] });
3063
+ case "select":
3064
+ return /* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
3065
+ labelEl,
3066
+ /* @__PURE__ */ jsxRuntime.jsxs(
3067
+ "select",
3068
+ {
3069
+ id: `input-${field.key}`,
3070
+ disabled,
3071
+ required: field.required,
3072
+ value: typeof value === "string" ? value : "",
3073
+ onChange: (e) => onChange(e.target.value),
3074
+ className: INPUT_CLASSES,
3075
+ children: [
3076
+ /* @__PURE__ */ jsxRuntime.jsx("option", { value: "", disabled: true, children: "Selecione\u2026" }),
3077
+ field.options.map((option) => /* @__PURE__ */ jsxRuntime.jsx("option", { value: option.value, children: option.label }, option.value))
3078
+ ]
3079
+ }
3080
+ ),
3081
+ helpEl
3082
+ ] });
3083
+ case "boolean":
3084
+ return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center gap-2", children: [
3085
+ /* @__PURE__ */ jsxRuntime.jsx(
3086
+ "input",
3087
+ {
3088
+ id: `input-${field.key}`,
3089
+ type: "checkbox",
3090
+ disabled,
3091
+ checked: Boolean(value),
3092
+ onChange: (e) => onChange(e.target.checked),
3093
+ className: "h-4 w-4 rounded border-zinc-300 text-emerald-600 focus:ring-emerald-500"
3094
+ }
3095
+ ),
3096
+ /* @__PURE__ */ jsxRuntime.jsx(
3097
+ "label",
3098
+ {
3099
+ htmlFor: `input-${field.key}`,
3100
+ className: "text-xs text-slate-700 dark:text-slate-300",
3101
+ children: field.label
3102
+ }
3103
+ )
3104
+ ] });
3105
+ default:
3106
+ return null;
3107
+ }
3108
+ }
3109
+ function initialValues(fields) {
3110
+ const out = {};
3111
+ for (const field of fields) {
3112
+ if ("defaultValue" in field && field.defaultValue !== void 0) {
3113
+ out[field.key] = field.defaultValue;
3114
+ } else if (field.kind === "boolean") {
3115
+ out[field.key] = false;
3116
+ } else {
3117
+ out[field.key] = "";
3118
+ }
3119
+ }
3120
+ return out;
3121
+ }
3122
+ function sanitizeForSubmit(values) {
3123
+ const out = {};
3124
+ for (const [key, value] of Object.entries(values)) {
3125
+ if (value === "" || value === void 0) continue;
3126
+ out[key] = value;
3127
+ }
3128
+ return out;
3129
+ }
3130
+ var INPUT_CLASSES = "mt-1 block w-full rounded-md border border-zinc-300 bg-white px-2.5 py-1.5 text-sm text-slate-900 shadow-sm focus:border-emerald-500 focus:outline-none focus:ring-1 focus:ring-emerald-500 disabled:opacity-50 dark:border-zinc-700 dark:bg-zinc-900 dark:text-slate-100";
3131
+ var TONE_BLOCK2 = {
3132
+ default: "border-zinc-950/10 bg-white dark:border-white/10 dark:bg-zinc-900",
3133
+ info: "border-sky-500/20 bg-sky-500/5 dark:border-sky-400/30 dark:bg-sky-500/10",
3134
+ success: "border-emerald-500/20 bg-emerald-500/5 dark:border-emerald-400/30 dark:bg-emerald-500/10",
3135
+ warning: "border-amber-500/20 bg-amber-500/5 dark:border-amber-400/30 dark:bg-amber-500/10",
3136
+ danger: "border-rose-500/20 bg-rose-500/5 dark:border-rose-400/30 dark:bg-rose-500/10"
3137
+ };
3138
+ function StreamingDashboard({
3139
+ runId,
3140
+ initialSpec,
3141
+ initialStatus,
3142
+ className
3143
+ }) {
3144
+ const [spec, setSpec] = React12.useState(
3145
+ initialSpec ?? null
3146
+ );
3147
+ const [timeline, setTimeline] = React12.useState([]);
3148
+ const [phase, setPhase] = React12.useState(
3149
+ () => derivePhase(initialStatus)
3150
+ );
3151
+ const [error, setError] = React12.useState(null);
3152
+ const specRef = React12.useRef(initialSpec ?? null);
3153
+ React12.useEffect(() => {
3154
+ if (phase === "completed" || phase === "failed" || phase === "cancelled") {
3155
+ return;
3156
+ }
3157
+ const unsubscribe = chunkARVLVWUC_js.subscribeToRunEvents(
3158
+ runId,
3159
+ (event) => handleEvent(event),
3160
+ (err) => {
3161
+ console.warn("streaming-dashboard sse error", err);
3162
+ }
3163
+ );
3164
+ return unsubscribe;
3165
+ }, [runId]);
3166
+ function handleEvent(event) {
3167
+ switch (event.type) {
3168
+ case "run_started":
3169
+ setPhase("running");
3170
+ break;
3171
+ case "node_started":
3172
+ if (event.nodeId) {
3173
+ setTimeline((prev) => upsertTimelineRunning(prev, event));
3174
+ }
3175
+ break;
3176
+ case "node_completed":
3177
+ if (event.nodeId) {
3178
+ setTimeline(
3179
+ (prev) => upsertTimelineDone(prev, event, "done")
3180
+ );
3181
+ mergeNodeOutput(event);
3182
+ }
3183
+ break;
3184
+ // The engine emits `node_error` (not `node_failed`) for executor
3185
+ // errors. Keep `node_failed` as a soft alias in case a future
3186
+ // event source uses it.
3187
+ case "node_error":
3188
+ case "node_failed":
3189
+ if (event.nodeId) {
3190
+ setTimeline(
3191
+ (prev) => upsertTimelineDone(prev, event, "failed")
3192
+ );
3193
+ }
3194
+ break;
3195
+ case "run_paused":
3196
+ setPhase("paused");
3197
+ if (event.nodeId) {
3198
+ setTimeline(
3199
+ (prev) => upsertTimelineDone(prev, event, "paused")
3200
+ );
3201
+ }
3202
+ appendPauseSection(event);
3203
+ break;
3204
+ case "ui_render":
3205
+ appendSectionFromEvent(event);
3206
+ break;
3207
+ case "run_completed":
3208
+ setPhase("completed");
3209
+ break;
3210
+ case "run_failed":
3211
+ setPhase("failed");
3212
+ setError(event.error ?? "Workflow run failed");
3213
+ break;
3214
+ }
3215
+ }
3216
+ function mergeNodeOutput(event) {
3217
+ const output = event.outputs;
3218
+ if (!output) return;
3219
+ const candidateSpec = isDashboardSpecLike(output) ? output : null;
3220
+ if (candidateSpec) {
3221
+ setSpec((prev) => mergeSpec(prev, candidateSpec));
3222
+ specRef.current = mergeSpec(specRef.current, candidateSpec);
3223
+ return;
3224
+ }
3225
+ if (isSectionLike(output)) {
3226
+ const section = output;
3227
+ setSpec((prev) => appendSectionToSpec(prev, section));
3228
+ specRef.current = appendSectionToSpec(specRef.current, section);
3229
+ }
3230
+ }
3231
+ function appendSectionFromEvent(event) {
3232
+ const sectionPayload = event.outputs?.section ?? event.outputs;
3233
+ if (!sectionPayload || !sectionPayload.type) return;
3234
+ setSpec((prev) => appendSectionToSpec(prev, sectionPayload));
3235
+ specRef.current = appendSectionToSpec(specRef.current, sectionPayload);
3236
+ }
3237
+ function appendPauseSection(event) {
3238
+ const promptValue = event.outputs?.prompt;
3239
+ const payloadValue = event.outputs?.payload;
3240
+ const prompt = typeof promptValue === "string" ? promptValue : void 0;
3241
+ const section = {
3242
+ type: "note",
3243
+ data: {
3244
+ title: "Aguardando aprova\xE7\xE3o",
3245
+ body: prompt ? prompt : "O workflow pausou e aguarda decis\xE3o do operador.",
3246
+ tone: "warning"
3247
+ }
3248
+ };
3249
+ setSpec((prev) => appendSectionToSpec(prev, section));
3250
+ specRef.current = appendSectionToSpec(specRef.current, section);
3251
+ if (payloadValue && typeof payloadValue === "object") {
3252
+ const followUp = {
3253
+ type: "note",
3254
+ data: {
3255
+ title: "Contexto",
3256
+ body: JSON.stringify(payloadValue, null, 2),
3257
+ tone: "info"
3258
+ }
3259
+ };
3260
+ setSpec((prev) => appendSectionToSpec(prev, followUp));
3261
+ specRef.current = appendSectionToSpec(specRef.current, followUp);
3262
+ }
3263
+ }
3264
+ return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: className ?? "space-y-6", children: [
3265
+ /* @__PURE__ */ jsxRuntime.jsx(PhaseBadge, { phase }),
3266
+ timeline.length > 0 && /* @__PURE__ */ jsxRuntime.jsx(Timeline, { entries: timeline }),
3267
+ spec && /* @__PURE__ */ jsxRuntime.jsx(
3268
+ DashboardView,
3269
+ {
3270
+ spec,
3271
+ renderInputRequest: (data) => /* @__PURE__ */ jsxRuntime.jsx(
3272
+ InputRequestForm,
3273
+ {
3274
+ runId,
3275
+ data,
3276
+ onResolved: (result) => {
3277
+ setPhase(result.approved ? "running" : "failed");
3278
+ }
3279
+ }
3280
+ )
3281
+ }
3282
+ ),
3283
+ !spec && phase !== "completed" && /* @__PURE__ */ jsxRuntime.jsx("div", { className: "rounded-xl border border-dashed border-zinc-300 p-8 text-center text-sm text-slate-500 dark:border-zinc-700 dark:text-slate-400", children: phase === "paused" ? "Run paused \u2014 aguardando entrada do operador." : "Aguardando dados do workflow\u2026" }),
3284
+ error && /* @__PURE__ */ jsxRuntime.jsxs("section", { className: "rounded-xl border border-rose-500/30 bg-rose-500/10 p-4 text-sm text-rose-900 dark:text-rose-100", children: [
3285
+ /* @__PURE__ */ jsxRuntime.jsx("p", { className: "font-semibold", children: "Run falhou" }),
3286
+ /* @__PURE__ */ jsxRuntime.jsx("p", { className: "mt-1 whitespace-pre-line text-xs", children: error })
3287
+ ] })
3288
+ ] });
3289
+ }
3290
+ function derivePhase(status) {
3291
+ switch (String(status ?? "").toLowerCase()) {
3292
+ case "completed":
3293
+ return "completed";
3294
+ case "failed":
3295
+ return "failed";
3296
+ case "cancelled":
3297
+ return "cancelled";
3298
+ case "paused_for_approval":
3299
+ return "paused";
3300
+ case "running":
3301
+ return "running";
3302
+ case "pending":
3303
+ case "":
3304
+ return "pending";
3305
+ default:
3306
+ return "pending";
3307
+ }
3308
+ }
3309
+ function PhaseBadge({ phase }) {
3310
+ const map = {
3311
+ pending: { status: "pending", label: "Pendente" },
3312
+ running: { status: "processing", label: "Em execu\xE7\xE3o" },
3313
+ paused: { status: "pending", label: "Aguardando aprova\xE7\xE3o" },
3314
+ completed: { status: "success", label: "Conclu\xEDdo" },
3315
+ failed: { status: "error", label: "Falhou" },
3316
+ cancelled: { status: "inactive", label: "Cancelado" }
3317
+ };
3318
+ const entry = map[phase];
3319
+ return /* @__PURE__ */ jsxRuntime.jsx("div", { className: "flex items-center justify-between", children: /* @__PURE__ */ jsxRuntime.jsx(StatusBadge, { status: entry.status, label: entry.label }) });
3320
+ }
3321
+ function Timeline({ entries }) {
3322
+ return /* @__PURE__ */ jsxRuntime.jsx("ol", { className: "flex flex-wrap gap-2", children: entries.map((entry) => {
3323
+ const dotClass = entry.status === "done" ? "bg-emerald-500" : entry.status === "failed" ? "bg-rose-500" : entry.status === "paused" ? "bg-amber-500" : "animate-pulse bg-sky-500";
3324
+ return /* @__PURE__ */ jsxRuntime.jsxs(
3325
+ "li",
3326
+ {
3327
+ className: "flex items-center gap-2 rounded-full border border-zinc-950/10 bg-white px-3 py-1 text-xs dark:border-white/10 dark:bg-zinc-900",
3328
+ title: entry.error ?? entry.nodeId,
3329
+ children: [
3330
+ /* @__PURE__ */ jsxRuntime.jsx("span", { className: `h-2 w-2 rounded-full ${dotClass}` }),
3331
+ /* @__PURE__ */ jsxRuntime.jsx("span", { className: "font-medium text-slate-700 dark:text-slate-300", children: entry.nodeId }),
3332
+ entry.nodeType && /* @__PURE__ */ jsxRuntime.jsx("span", { className: "text-[10px] uppercase tracking-wide text-slate-400", children: entry.nodeType })
3333
+ ]
3334
+ },
3335
+ entry.nodeId
3336
+ );
3337
+ }) });
3338
+ }
3339
+ function upsertTimelineRunning(prev, event) {
3340
+ if (!event.nodeId) return prev;
3341
+ const idx = prev.findIndex((entry) => entry.nodeId === event.nodeId);
3342
+ const fresh = {
3343
+ nodeId: event.nodeId,
3344
+ nodeType: event.nodeType,
3345
+ status: "running",
3346
+ startedAt: event.timestamp
3347
+ };
3348
+ if (idx === -1) return [...prev, fresh];
3349
+ const next = [...prev];
3350
+ next[idx] = { ...next[idx], ...fresh };
3351
+ return next;
3352
+ }
3353
+ function upsertTimelineDone(prev, event, status) {
3354
+ if (!event.nodeId) return prev;
3355
+ const idx = prev.findIndex((entry) => entry.nodeId === event.nodeId);
3356
+ if (idx === -1) {
3357
+ return [
3358
+ ...prev,
3359
+ {
3360
+ nodeId: event.nodeId,
3361
+ nodeType: event.nodeType,
3362
+ status,
3363
+ startedAt: event.timestamp,
3364
+ finishedAt: event.timestamp,
3365
+ error: event.error
3366
+ }
3367
+ ];
3368
+ }
3369
+ const next = [...prev];
3370
+ next[idx] = {
3371
+ ...next[idx],
3372
+ status,
3373
+ finishedAt: event.timestamp,
3374
+ error: event.error ?? next[idx].error
3375
+ };
3376
+ return next;
3377
+ }
3378
+ function isDashboardSpecLike(value) {
3379
+ if (!value || typeof value !== "object") return false;
3380
+ const candidate = value;
3381
+ return typeof candidate.title === "string" || Array.isArray(candidate.sections) || Array.isArray(candidate.kpis) || Array.isArray(candidate.charts) || typeof candidate.recommendation === "string";
3382
+ }
3383
+ function isSectionLike(value) {
3384
+ if (!value || typeof value !== "object") return false;
3385
+ const candidate = value;
3386
+ return typeof candidate.type === "string" && "data" in candidate;
3387
+ }
3388
+ function mergeSpec(prev, next) {
3389
+ if (!prev) return next;
3390
+ return {
3391
+ ...prev,
3392
+ ...next,
3393
+ title: next.title ?? prev.title,
3394
+ sections: mergeSections(prev.sections, next.sections)
3395
+ };
3396
+ }
3397
+ function mergeSections(a, b) {
3398
+ if (!a && !b) return void 0;
3399
+ if (!a) return b;
3400
+ if (!b) return a;
3401
+ const seen = /* @__PURE__ */ new Set();
3402
+ const merged = [];
3403
+ for (const section of [...a, ...b]) {
3404
+ const key = JSON.stringify(section);
3405
+ if (seen.has(key)) continue;
3406
+ seen.add(key);
3407
+ merged.push(section);
3408
+ }
3409
+ return merged;
3410
+ }
3411
+ function appendSectionToSpec(prev, section) {
3412
+ const base = prev ?? { title: "" };
3413
+ const sections = base.sections ? [...base.sections, section] : [section];
3414
+ return { ...base, sections };
3415
+ }
2862
3416
 
2863
3417
  // src/types/dashboard-spec.ts
2864
3418
  function validateDashboardSpec(spec) {
@@ -25285,6 +25839,7 @@ exports.InfoPopover = InfoPopover;
25285
25839
  exports.InlineForm = InlineForm;
25286
25840
  exports.InlineSpinner = InlineSpinner;
25287
25841
  exports.Input = Input;
25842
+ exports.InputRequestForm = InputRequestForm;
25288
25843
  exports.InteractiveGeoMap = InteractiveGeoMap;
25289
25844
  exports.InventoryDemo = InventoryDemo;
25290
25845
  exports.ItemSummary = ItemSummary;
@@ -25463,6 +26018,7 @@ exports.StatusToggle = StatusToggle;
25463
26018
  exports.StepFormPage = StepFormPage;
25464
26019
  exports.StepNavigationButtons = StepNavigationButtons;
25465
26020
  exports.StepTimeline = StepTimeline;
26021
+ exports.StreamingDashboard = StreamingDashboard;
25466
26022
  exports.Strong = Strong;
25467
26023
  exports.Subheading = Subheading;
25468
26024
  exports.SwipeableRow = SwipeableRow;
@@ -25809,5 +26365,5 @@ exports.usePullToRefresh = usePullToRefresh;
25809
26365
  exports.validateDashboardSpec = validateDashboardSpec;
25810
26366
  exports.xScale = xScale;
25811
26367
  exports.yScale = yScale;
25812
- //# sourceMappingURL=chunk-ZBX2QSNH.js.map
25813
- //# sourceMappingURL=chunk-ZBX2QSNH.js.map
26368
+ //# sourceMappingURL=chunk-ZKUYNCAG.js.map
26369
+ //# sourceMappingURL=chunk-ZKUYNCAG.js.map